fix(kitchen): applyScale scales a reference's quoted quantity (audit C1) #68

Merged
abiwab merged 3 commits from fix/audit-c1 into main 2026-09-30 18:47:52 +02:00
Owner

Audit C1, present since 1.3.0. The documented parity applyScale(compile(ast), k) == compile(ast, { scaleFactor: k }) was false for Use &mix{100g}: applyScale left the quantity quoted in the step at 100 where compile gave 200.

Cause: applyScale's walk over step content only handled tokens with an id and no type (plain ingredients/cookware) or type: "alternative". A reference to an intermediate is created with type: "reference" (processor.ts), so it was skipped. compile({ scaleFactor }) scales it through another path, hence the gap.

Fix: include type: "reference" in that walk.

  • targeted test in the existing "parity with compile({ scaleFactor })" block
  • the it.todo of the B11 property test becomes a real invariant over the seeded random recipes
  • both fail on the previous code; the audit fuzzer (5000 recipes) now reports no violation at all, i.e. this was the only divergence family
  • new patch changeset for kitchen (visible vs 1.3.0)

ci (1325 tests) and conformance 98/98 pass.

Audit C1, present since 1.3.0. The documented parity `applyScale(compile(ast), k) == compile(ast, { scaleFactor: k })` was false for `Use &mix{100g}`: applyScale left the quantity quoted in the step at 100 where compile gave 200. Cause: `applyScale`'s walk over step content only handled tokens with an `id` and no `type` (plain ingredients/cookware) or `type: "alternative"`. A reference to an intermediate is created with `type: "reference"` (processor.ts), so it was skipped. `compile({ scaleFactor })` scales it through another path, hence the gap. Fix: include `type: "reference"` in that walk. - targeted test in the existing "parity with compile({ scaleFactor })" block - the `it.todo` of the B11 property test becomes a real invariant over the seeded random recipes - both fail on the previous code; the audit fuzzer (5000 recipes) now reports no violation at all, i.e. this was the only divergence family - new patch changeset for kitchen (visible vs 1.3.0) ci (1325 tests) and conformance 98/98 pass.
abiwab merged commit b9953b0941 into main 2026-09-30 18:47:52 +02:00
abiwab deleted branch fix/audit-c1 2026-09-30 18:47:52 +02:00
Sign in to join this conversation.
No description provided.