[P3] Committed comparison-v2.json predates #20's key reordering, so the README's documented cmp reproduction step fails at HEAD #122

Open
opened 2026-10-31 19:47:41 +00:00 by pedro · 0 comments
Owner

Priority: P3
Type: bug
Source: full codebase review requested 2026-10-31 (independently reproduced against 2cac7cf)

Location: docs/qa/decompression/comparison-v2.json:2597, docs/qa/decompression/comparison-v2.json:2733, docs/qa/decompression/comparison-v2.json:2874, scripts/reference-validation/compare-extended.ts:75, scripts/reference-validation/compare-extended.ts:76, scripts/reference-validation/README.md:106

Problem and evidence

compare-extended.ts lines 75-76 build demandUsage by copying demandDive.gasUsage and then adding Oxygen from oxygenUsage. Commit #20 introduced this split. Because of it, Oxygen is now serialized after CCR:180:450 in the demandLitres of the three ccr-cap rows. The committed docs/qa/decompression/comparison-v2.json was last written in efc5d97, before #20, and has Oxygen first. The values are identical and every check still passes. Only the key order differs. Even so, the byte-level step in scripts/reference-validation/README.md:106-107 (cmp docs/qa/decompression/comparison-v2.json /tmp/comparison-v2.json) fails on HEAD, so anyone following the documented reproduction sees a spurious mismatch.

I ran node --import tsx scripts/reference-validation/compare-extended.ts <tmpdir>/comparison-v2.json from the checkout. It exited 0 with {"nativeControlPass":16,"nativeControlDiscrepancy":0,"ccrPointPass":18,"ccrPointDiscrepancy":0,"total":21,"pass":21,"discrepancy":0}. Then cmp docs/qa/decompression/comparison-v2.json <tmp> reported "differ: byte 63183, line 2597". diff showed exactly 3 hunks, at lines 2597-2598, 2733-2734 and 2874-2875. Each swaps the order of "Oxygen" (53.444/52.444/52.444) and "CCR:180:450" (31.5815…) with identical values. git log on the report shows its last change was efc5d97.

Suggested correction

Regenerate docs/qa/decompression/comparison-v2.json with the current harness (node --import tsx scripts/reference-validation/compare-extended.ts docs/qa/decompression/comparison-v2.json). This is a derived report, not a frozen oracle. Optionally, make the harness serialize demandLitres (or the whole report) with sorted keys, so future accounting refactors that only reorder keys do not change the byte output.

Acceptance criteria

On HEAD with the fix, running compare-extended.ts to /tmp/comparison-v2.json and then cmp docs/qa/decompression/comparison-v2.json /tmp/comparison-v2.json succeeds with exit 0. The summary stays at 21/21 rows, 18/18 CCR points and 16/16 native controls. Optional regression guard: a test that regenerates the report in memory and compares it byte-for-byte with the committed file, or with key-sorted canonical JSON. pnpm verify passes.

Scope: maintenance of the educational simulator. Preserve historical R1 acceptance and operational-validation limits.

Priority: P3 Type: bug Source: full codebase review requested 2026-10-31 (independently reproduced against `2cac7cf`) Location: `docs/qa/decompression/comparison-v2.json:2597`, `docs/qa/decompression/comparison-v2.json:2733`, `docs/qa/decompression/comparison-v2.json:2874`, `scripts/reference-validation/compare-extended.ts:75`, `scripts/reference-validation/compare-extended.ts:76`, `scripts/reference-validation/README.md:106` Problem and evidence compare-extended.ts lines 75-76 build `demandUsage` by copying `demandDive.gasUsage` and then adding `Oxygen` from `oxygenUsage`. Commit #20 introduced this split. Because of it, `Oxygen` is now serialized after `CCR:180:450` in the `demandLitres` of the three ccr-cap rows. The committed docs/qa/decompression/comparison-v2.json was last written in efc5d97, before #20, and has `Oxygen` first. The values are identical and every check still passes. Only the key order differs. Even so, the byte-level step in scripts/reference-validation/README.md:106-107 (`cmp docs/qa/decompression/comparison-v2.json /tmp/comparison-v2.json`) fails on HEAD, so anyone following the documented reproduction sees a spurious mismatch. I ran `node --import tsx scripts/reference-validation/compare-extended.ts <tmpdir>/comparison-v2.json` from the checkout. It exited 0 with {"nativeControlPass":16,"nativeControlDiscrepancy":0,"ccrPointPass":18,"ccrPointDiscrepancy":0,"total":21,"pass":21,"discrepancy":0}. Then `cmp docs/qa/decompression/comparison-v2.json <tmp>` reported "differ: byte 63183, line 2597". `diff` showed exactly 3 hunks, at lines 2597-2598, 2733-2734 and 2874-2875. Each swaps the order of "Oxygen" (53.444/52.444/52.444) and "CCR:180:450" (31.5815…) with identical values. `git log` on the report shows its last change was efc5d97. Suggested correction Regenerate docs/qa/decompression/comparison-v2.json with the current harness (`node --import tsx scripts/reference-validation/compare-extended.ts docs/qa/decompression/comparison-v2.json`). This is a derived report, not a frozen oracle. Optionally, make the harness serialize `demandLitres` (or the whole report) with sorted keys, so future accounting refactors that only reorder keys do not change the byte output. Acceptance criteria On HEAD with the fix, running compare-extended.ts to /tmp/comparison-v2.json and then `cmp docs/qa/decompression/comparison-v2.json /tmp/comparison-v2.json` succeeds with exit 0. The summary stays at 21/21 rows, 18/18 CCR points and 16/16 native controls. Optional regression guard: a test that regenerates the report in memory and compares it byte-for-byte with the committed file, or with key-sorted canonical JSON. pnpm verify passes. Scope: maintenance of the educational simulator. Preserve historical R1 acceptance and operational-validation limits.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: pedro/DiveSim#122
No description provided.