Skip to content

feat(corrections): validator v2, migrate and new-record scripts, report for both forms - #240

Merged
bketelsen merged 5 commits into
mainfrom
lucilla/corrections-v2-tools
Nov 13, 2026
Merged

bketelsen merged 5 commits into
mainfrom
lucilla/corrections-v2-tools

Conversation

@frostyard-machines

@frostyard-machines frostyard-machines commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Implements the tools and texts of ADR-0081: each correction record is 1 file in .memory/corrections/, so 2 PRs that each add a record no longer conflict on .memory/corrections.jsonl. Core keeps its own old file in this PR; its move comes in a later PR.

  • scripts/check-corrections.mjs (validator v2). Without --base: the folder form (name <date>-<slug>.json, slug at most 60 characters, the 5 string fields, name date = date, canonical bytes JSON.stringify(record, null, 2) + "\n", only regular files and an optional empty .gitkeep), the old form with the v1 line rules, a failure for both forms, and no records for neither. With --base: folder → folder (no removed, renamed or changed record except a filled empty promoted_to; no new legacy- record), folder → old file (refused), old → old (the v1 append-only rule), old → folder (every base line N is <date>-legacy-<NNNN>.json with the same record, no other legacy- file), folder → neither and old → neither (refused). A bad ref or an unreadable object stays fatal. --file is removed; no caller uses it.
  • scripts/migrate-corrections.mjs (new). Moves the old file into the folder. It checks every line first, plans every output before it writes, keeps an equal file, stops with no change on a clash, writes each file through a temp file and a rename, and then deletes the old file. --pr N converts the lines of an open PR after a merge of main: lines match legacy- records by their 4 key fields; the promotion table of ADR-0081 applies; unmatched lines become <date>-pr-<N>-<k>.json.
  • scripts/new-correction.mjs (new). Writes 1 record in canonical form, refuses an existing name and a repository that still has the old file.
  • scripts/corrections-report.mjs. Reads both forms at --ref and in working trees. Each record and each unreadable entry gets source (the path in the repository); a folder record has line: null; path keeps its meaning; a new top-level records key equals lines. Order: date, source, line.
  • Docs and skills. Row B2 (the folder, with the legacy clause until every repository moves), .memory/README.md, docs/org-adrs.md, and text that names both forms in AGENTS.md, the quality loop, the review rubric, and the frostyard-acmm-conformance and frostyard-repo-docs skills. The repo-docs skill no longer says to delete a correction entry: records are permanent (ADR-0018, ADR-0081).

The 3 CLI scripts import only node: modules, so another repository can take each one from core at 1 commit with git show.

Risk tier

Risk tier: 2 — validator and report code that other repositories copy, plus docs and shared skills. No path of .github/risk-paths.json matches.

Docs housekeeping

  • Cross-links added in both directions (ADR ↔ design ↔ spec ↔ plan): the baseline spec, the quality loop and the rubric link ADR-0081, which links them
  • Conformance aliases (ADR-0029) untouched — canonical targets edited instead

Verification

  • make verify green locally at 043eb47: docs gate 1.000 / 1.000 / 1.000, ok corrections: 40 lines (legacy form: migrate to .memory/corrections/), 846 tests pass, 0 fail; node scripts/check-corrections.mjs --base origin/main passes
  • node --test test/check-corrections.test.mjs test/migrate-corrections.test.mjs test/new-correction.test.mjs test/corrections-report.test.mjs: 139 pass
  • Dry run on a scratch worktree of this branch: migrate-corrections.mjs --root . → migrated 37 records (37 new files, 0 unchanged, 0 promoted); then check-corrections.mjs --root . --base HEAD → ok corrections: 37 records, append-only vs HEAD; the report reads 37 records. The scratch worktree was removed; core's file is unchanged here.

Cross-review

  • Reviewer openai/gpt-6.1-sol; coders deepseek/deepseek-flash (scripts, tests) and anthropic/claude-opus-5-5 (docs, skills).
  • Initial review at d74d043 in 3 batches (scripts and docs; tests; report): 6 blocking findings: a symbolic link at .memory passed --base; a predictable temp path in the migration followed a link; the writers followed a linked .memory/corrections; a lossy UTF-8 decode in the migration and the move proof; 2 report records with the same fields merged into 1; the report followed a .memory link in a checkout without the ref. Fixed in 9d41622, each with a test.
  • Re-review 1 at 9d41622 (plus batch 2, the tests): 3 blocking findings: the report merge could still move a promotion; the restart test filtered out a leftover temp file; the decoder dropped a leading BOM. Fixed in 48706a1, each with a test.
  • 96132c7 merges main (38a2ddd, docs only). The only conflict was .memory/corrections.jsonl (both sides appended 1 line; main's line first, then this PR's; check-corrections.mjs --base origin/main passes). git diff 9d41622 96132c7 -- scripts test is empty; the reviewer's compatibility check: Compatible.
  • Re-review 2 at 48706a1: 1 blocking finding: a legacy line number alone merged 2 branch records. Fixed in 043eb47.
  • Re-review 3 at 043eb47: Ready, Blocking: none. Budget: 1 review + 3 re-reviews used.
  • Guards: each fix has a targeted test; 2 lines in .memory/corrections.jsonl (core's current form) record the lessons.
  • Revert test: in a scratch worktree of d74d043, scripts/check-corrections.mjs and scripts/corrections-report.mjs reset to origin/main, tests kept: node --test test/check-corrections.test.mjs test/corrections-report.test.mjs → 51 fail (for example "base folder: a removed record fails", "base old file: a move that drops a line fails", "the folder fixture is the exact report in the working tree and at a ref"). The coder reverted each later fix in a scratch copy and saw its new test fail. The scratch worktree was removed.

…rt for both forms

Validator v2 checks the record folder .memory/corrections/ and the old
.memory/corrections.jsonl, refuses a tree with both, and with --base
enforces the cut-over rules of ADR-0081 (no removed, renamed or changed
record; the old file does not come back; the move keeps every line).
--file is removed.

scripts/migrate-corrections.mjs moves the old file into the folder
(--pr N for an open PR that still added lines). scripts/new-correction.mjs
writes 1 record in canonical form. The corrections report reads both
forms and adds source and records.

Docs and shared skills name both forms until every repository moves.
@github-actions github-actions Bot added the level:L3 Skim label Nov 13, 2026
…keep distinct records

- check-corrections, migrate-corrections and new-correction refuse a
  symbolic link at .memory or .memory/corrections, so no record leaves
  its path unseen.
- migrate-corrections writes each temp file with the exclusive flag and
  a random name, and decodes the old file with a fatal UTF-8 decoder;
  the move proof in check-corrections fails a base file that is not
  valid UTF-8.
- corrections-report merges records by key and place, so 2 records with
  the same 4 fields stay 2, and it does not follow a .memory link in a
  checkout without the ref. The fixture tests compare the exact JSON text.

Each fix has a test that fails without it; 1 corrections line records
the lesson.
…2-tools

# Conflicts:
#	.memory/corrections.jsonl
…s, keep a BOM

- corrections-report merges the checkouts of 1 repository by the
  permanent identity of a record (legacy line number, or file name), so
  a promotion never moves to another record with the same fields.
- migrate-corrections removes its own leftover temp files from a stopped
  run before it writes, and keeps a leading BOM so the line rules reject
  it; the restart test compares complete trees.

Each fix has a test; 1 corrections line records the lesson.
… report

A legacy line number names a record only within 1 history: 2 branches can
append different records at the same line. The report's merge identity of
a legacy record is now its line number with its 4 key fields, so 2
different records stay 2 and a promoted copy of 1 record still merges.
@frostyard-machines frostyard-machines added the ready-for-human Reviewed, CI green: ready for Brian to review and merge label Nov 13, 2026
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