Repository navigation
test(scripts): pin assertion-ratchet SAFETY-comment scanner fix - #130191
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
977c84a to
ed95ed9
Compare
|
Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 8:37 PM ET / August 27, 2026, 00:37 UTC. ClawSweeper reviewWhat this changesThis PR adds a regression test that verifies SAFETY comments remain effective after a template-literal substitution and division expression. Merge readiness✅ Ready for maintainer review Keep open. No blocking findings: this focused test protects a current-main scanner repair that is not yet covered by the main-branch test suite; the maintainer label and member authorship require the normal maintainer path. Priority: P3 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — step 1 Assertions:
How this fits togetherThe assertion-safety ratchet scans production TypeScript files for assertions lacking a SAFETY invariant and compares them with a shrink-only baseline. This test protects its source-comment detection before the ratchet reports CI debt. flowchart LR
A[TypeScript source] --> B[SAFETY comment detection]
B --> C[Assertion classification]
C --> D[Baseline comparison]
D --> E[CI ratchet result]
F[Regression fixture] --> B
Before mergeNone. Agent review detailsSecurityNone. PR surfaceTests +15. Total +15 across 1 file. View PR surface stats
Review metrics
Technical reviewBest possible solution: Retain this owner-boundary regression test so a future scanner refactor cannot silently make post-interpolation SAFETY comments ineffective. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR adds coverage for an already-repaired source behavior; its fixture directly encodes the former failure shape without claiming a current-main user failure. Is this the best way to solve the issue? Yes. The test exercises the countUnsafeAssertions owner boundary with the missing template-substitution case and does not add another scanner path or alter production behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 00713ca253da. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
The raw skipTrivia=false scanner in collectSafetyCommentLines never re-scanned the `}` ending a template substitution, so it lexed a phantom NoSubstitutionTemplateLiteral that swallowed every later comment in the file. #129769 already fixed this with per-line text matching, but shipped without a regression test, leaving the fix unpinned against reintroduction.
ed95ed9 to
3d9e21a
Compare
|
Merged via squash.
|
…claw#130191) The raw skipTrivia=false scanner in collectSafetyCommentLines never re-scanned the `}` ending a template substitution, so it lexed a phantom NoSubstitutionTemplateLiteral that swallowed every later comment in the file. openclaw#129769 already fixed this with per-line text matching, but shipped without a regression test, leaving the fix unpinned against reintroduction.
What Problem This Solves
collectSafetyCommentLinesinscripts/check-assertion-safety-ratchet.mtshad zero regression coverage for the exact bug that motivated its rewrite in #129769: a rawts.createScanner(..., skipTrivia=false, ...)pass never re-scans the}that ends a template substitution, so it lexes a phantomNoSubstitutionTemplateLiteralstarting at the template's closing backtick and swallows every later comment in the file — including// SAFETY:comments that should exempt real assertions from the ratchet.Why This Change Was Made
#129769 already replaced the token scanner with per-line text matching and fixed the bug, but shipped without a test pinning the fix. Every existing test in the file passes equally well against the pre-fix scanner code, so a future refactor could reintroduce token-based scanning and nothing would catch it.
User Impact
Test-only; no production behavior change.
Evidence
test/scripts/check-assertion-safety-ratchet.test.ts: a source with a template substitution and a division operator ahead of a SAFETY-commented assertion, plus one genuinely uncommented assertion.4bd88591264^version ofcheck-assertion-safety-ratchet.mts, ran the new test (fails: counts 2 instead of 1 because the SAFETY comment gets swallowed), then restored the current script (diff empty afterward).node scripts/run-vitest.mjs test/scripts/check-assertion-safety-ratchet.test.ts— 5/5 pass on currentmaincode.node scripts/check-changed.mjs -- test/scripts/check-assertion-safety-ratchet.test.ts— test-root typecheck, scripts lint, boundary guards all pass.node --import tsx scripts/check-assertion-safety-ratchet.mts— ratchet green:4248 files, 13304 grandfathered assertions, no stale baseline entries.