Skip to content

doctor validate reports recipes in non-deterministic order #427

Description

@dubadub

cook doctor validate reports recipes in a different order on each run, so identical input produces non-identical output.

Cause

run_validate walks cooklang_find's RecipeTree, whose children are stored in a HashMap:

// cooklang-find-0.6.1/src/tree/model.rs:30
pub children: HashMap<String, RecipeTree>,

Rust's default HashMap hasher is seeded randomly per process, so iteration order differs between invocations. The walk emits each recipe's 📄 {path} header in whatever order it encounters them.

Impact

  • Output cannot be diffed between runs, so it is hard to tell whether a change to a recipe collection improved or worsened anything.
  • Anything comparing doctor validate output in CI is inherently flaky.
  • Repeated runs while fixing recipes shuffle the list, which is disorienting when working through a large collection.

Only visible with more than one recipe carrying errors or warnings, which is likely why it has gone unnoticed.

Suggested direction

Sort by path before reporting. Directory listing order is not a meaningful contract, and a stable order makes the output diffable.

Noticed while extracting doctor validate into a library crate. The extraction sorts by path — a library returning results in random order is worse than a CLI doing so — so this is fixed on that branch as a side effect. Filing separately because it is a pre-existing defect on main and worth recording independently of whether that branch lands.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions