Skip to content

cooklang format rounds every quantity to 3 decimal places #701

Closed

Description

@drawmeanelephant

Suggested labels: bug, area: cli


Discovery audit finding M4 (medium) — cooklang/cookcli @ 7c2f48b (v0.38.1), audited 2026-10-12. Repro verified. Data corruption.

Summary

--format cooklang rounds every quantity to 3 decimal places.

Where

crates/format/src/cooklang_source.rs:289 writes q.value().to_string(); cooklang's Number Display rounds to 3 dp.

Repro

  • @saffron{0.0005%g} → @saffron{0.001%g} (2× error)
  • @water{12.3456%ml} → 12.346

JSON output keeps the exact values, so this is pure writer corruption.

Expected

The exact quantity is preserved.

Actual

Every quantity is rounded to 3 decimal places.

Acceptance criteria (red → green)

  • Red: the repro emits @saffron{0.001%g} for 0.0005.
  • Green: the repro emits 0.0005 exactly (matching the JSON output).

Verification

Executed repro.

Activity

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