Repository navigation
refactor: re-check validated run inputs through one shared helper - #173
Merged
Merged
Conversation
A command that validates a run and then writes must confirm that every file the validation read still holds the validated bytes, otherwise the file can be swapped between the check and the write. validateAuditRun returns three such collections: registered artifacts, saved evidence and the historical resources used to validate older run formats. Each command carried its own copy of the loops, and the copies disagreed: only render-report.mjs and validate-audit-run.mjs also covered the historical resources, so every other command could write after one of those files changed. lib/audit-run-validation.mjs now owns the single list of those inputs and exports - assertValidatedRunStable(validation, labels) to re-check them, and - validatedRunSnapshots(validation) for commands that collect snapshots and re-check them in a write hook. Both are re-exported by lib/audit-run.mjs. The 18 hand-written re-check blocks and 5 hand-written collections in 20 files are replaced one for one, keeping the labels that appear in failure messages (saved evidence, sibling registered artifact, predecessor evidence and so on). A command that renders or writes now also covers the historical resources, which closes the gap above; the same helper accepts the shapes of an invalid validation so status reporting is unaffected. tests/validated-run-stability.test.mjs covers each of the three collections refusing a change with its label, custom labels, tolerance of a validation without snapshots, and a guard that fails when a script reintroduces a hand-written loop over validateAuditRun's collections. The hand-written argument parsers, the BOM-stripping JSON read idiom and the usage text are intentionally left as they are: the parsers check their arguments in at least six different orders, so sharing one would change some commands' error precedence or need an ordering parameter, and none of them is a safety property. Verified: verify-all passes on Node.js 22.19.0 (Windows), 92 test files. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Keep all CHANGELOG entries. The Node.js 22 baseline (pull request 171), the HTTP observer retirement (pull request 172) and this change each add one bullet at the same place in the Unreleased section; no other file conflicts. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
github-actions
Bot
deleted the
refactor/centralize-validated-run-recheck
branch
October 12, 2026 13:14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A command that validates a run and then writes must confirm that every file the validation read still holds the validated bytes. Otherwise a file can be swapped between the check and the write.
validateAuditRunreturns three such collections: registered artifacts, saved evidence, and the historical resources used to validate older run formats.Each command carried its own copy of the loops, and the copies disagreed. Only
render-report.mjsandvalidate-audit-run.mjsalso covered the historical resources, so every other command could write after one of those files changed.Change
lib/audit-run-validation.mjsnow owns the single list of those inputs and exportsassertValidatedRunStable(validation, labels)andvalidatedRunSnapshots(validation)(for commands that collect snapshots and re-check them in a write hook). Both are re-exported bylib/audit-run.mjs.tests/validated-run-stability.test.mjscovers each of the three collections refusing a change with its label, custom labels, tolerance of a validation without snapshots, and a guard that fails when a script reintroduces a hand-written loop overvalidateAuditRun's collections.release-files.jsonand a CHANGELOG entry.Verification
node scripts/verify-all.mjson Windows / Node.js 22.19.0: PASS, 92 test filesnode scripts/sync-distributions.mjs --writewas followed by--checktests/validated-run-stability.test.mjsrender-report.mjs,lib/network-cli.mjsandimport-scanner-results.mjs, so the path-filtered report and Web evidence workflows are expected to run.Compatibility
Security and privacy
Merge note
Sibling PRs from the same batch also add one bullet at the same place in
CHANGELOG.md. After one of them merges, the others need a trivial conflict resolution that keeps both bullets.Issue
Part of the follow-ups listed after PR #169. Closes no issue.
🤖 Generated with Claude Code