Skip to content

fix(corrections-report): keep old-file records in line order - #248

Merged
bketelsen merged 2 commits into
mainfrom
lucilla/report-legacy-line-order
Nov 14, 2026
Merged

bketelsen merged 2 commits into
mainfrom
lucilla/report-legacy-line-order

Conversation

@frostyard-machines

Copy link
Copy Markdown
Contributor

Summary

scripts/corrections-report.mjs sorted every record by date first. In an old .memory/corrections.jsonl the line order is the order the records came in (the file is append-only), and a later line can carry an earlier date. So the pending list, the repeated-scope groups and the text output showed legacy records out of line order.

This PR orders records of the old file by line number, then record files by file name in byte order (ADR-0081 names each record file <date>-<slug>.json, so the file-name order already follows the date for the folder form). The date, the checkout path and the text only break ties between 2 different records at 1 line in 2 checkouts. The JSON schema does not change.

  • scripts/corrections-report.mjs: compareLines keys on form, line, source, then the tie-breakers.
  • test/corrections-report.test.mjs and test/fixtures/corrections-report/legacy.json: the legacy fixture now has decreasing dates; 2 new tests pin the line order (pending and repeated-scope lists, text output) and the file-name order, in working trees and at --ref. Both the fixture test and the line-order test fail without the fix.
  • docs/design/quality-loop.md (Weekly promotion): states the order.
  • .memory/corrections/: 1 record for this finding.

Risk tier

Risk tier: 1 — a read-only report script, its tests and 1 design-doc line; no gate, workflow or risk path changes.

Docs housekeeping

  • Cross-links unchanged; the design doc is updated in place.

Verification

  • make verify green locally (854 tests).
  • node --test test/corrections-report.test.mjs: 39 pass; with the old compareLines, 2 fail (the legacy fixture and the line-order test).

The report sorted every record by date first. In an old
.memory/corrections.jsonl the line order is the order the records came
in, and a later line can carry an earlier date, so the pending list and
the repeated-scope groups showed legacy records out of line order.

Order records of the old file by line number, then record files by
file name in byte order, as the corrections design states. The date,
the checkout path and the text only break ties between 2 different
records at 1 line in 2 checkouts.

The legacy JSON fixture now has decreasing dates, and 2 new tests pin
the line order and the file-name order in working trees and at a ref.
@github-actions github-actions Bot added the level:L3 Skim label Nov 14, 2026
@frostyard-machines

Copy link
Copy Markdown
Contributor Author

Cross-review: reviewer openai/gpt-6.1-sol, coder anthropic/claude-opus-5-5.
Reviewed base 9a9399964bd4e965ad6d75904d2fe4641fc6651e (merge-base) and head 7e0157c734a7d537e05c121504cdf642a3ce42f2, all 5 changed files, 1 initial review.
Result: Ready. Findings: none. Blocking: none.

Revert test: in a scratch worktree at the head, scripts/corrections-report.mjs was reset to the base version and node --test test/corrections-report.test.mjs was run. 2 tests fail on assertions: "the legacy fixture is the exact report in the working tree and at a ref" and "old-file records keep their line order when the dates decrease" (37 pass). At the head: 39 pass. The scratch worktree is removed.

@frostyard-machines frostyard-machines added the ready-for-human Reviewed, CI green: ready for Brian to review and merge label Nov 14, 2026
@bketelsen
bketelsen merged commit 3d3d5c7 into main Nov 14, 2026
5 checks passed
@bketelsen
bketelsen deleted the lucilla/report-legacy-line-order branch November 14, 2026 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

level:L3 Skim ready-for-human Reviewed, CI green: ready for Brian to review and merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants