Skip to content

Negative quantities round-trip through cooklang format as non-scalable text #722

Closed

Description

@drawmeanelephant

Suggested labels: bug, area: cli


Discovery audit finding L11 (low) — cooklang/cookcli @ 7c2f48b (v0.38.1), audited 2026-10-12. Verified by subagent.

Summary

A negative scale makes --format cooklang emit quantities that reparse as non-scalable text.

Where

crates/format/src/cooklang_source.rs (writer path for negative quantities).

Repro

@flour{-400%g} reparses as {"type":"text","value":"-400","scalable":false} — the quantity silently stops scaling/aggregating.

Expected

A negative quantity round-trips as a scalable quantity (or is rejected at format time).

Actual

It round-trips as non-scalable text.

Acceptance criteria (red → green)

  • Red: reparse of the formatted output yields {"type":"text","value":"-400","scalable":false}.
  • Green: reparse yields a scalable quantity with value -400 (or the formatter rejects the input with an error).

Verification

Verified by subagent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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