Skip to content

test(scripts): pin assertion-ratchet SAFETY-comment scanner fix - #130191

Merged
steipete merged 1 commit into
mainfrom
claude/hopeful-matsumoto-9ba691
Aug 27, 2026
Merged

steipete merged 1 commit into
mainfrom
claude/hopeful-matsumoto-9ba691

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

collectSafetyCommentLines in scripts/check-assertion-safety-ratchet.mts had zero regression coverage for the exact bug that motivated its rewrite in #129769: a raw ts.createScanner(..., skipTrivia=false, ...) pass never re-scans the } that ends a template substitution, so it lexes a phantom NoSubstitutionTemplateLiteral starting 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

  • Added 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.
  • Verified the regression test fails on the pre-fix scanner: temporarily swapped in the 4bd88591264^ version of check-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 current main code.
  • 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.
  • Autoreview (Codex, gpt-5.6-sol, high): clean, no accepted findings, patch correctness 0.99.

@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 26, 2026 15:21
@steipete
steipete force-pushed the claude/hopeful-matsumoto-9ba691 branch from 977c84a to ed95ed9 Compare August 26, 2026 15:39
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 8:37 PM ET / August 27, 2026, 00:37 UTC.

ClawSweeper review

What this changes

This 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
Reviewed head: 3d9e21a1922af8460a88e7ee33c11150bd0901d7

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A normal good focused regression-coverage PR: the fixture is behavior-oriented, its production owner is unchanged, and no correctness concern was found.
Proof confidence 🌊 off-meta tidepool Not applicable: This member-authored, test-only PR is exempt from the external-contributor real-behavior-proof gate; its body also records targeted test and ratchet validation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This member-authored, test-only PR is exempt from the external-contributor real-behavior-proof gate; its body also records targeted test and ratchet validation.
Evidence reviewed 7 items Changed test: The added fixture has a template substitution, division expression, SAFETY-commented assertion, and uncommented assertion; it expects only the latter to count.
Current owner behavior: Current main detects SAFETY comments by line text and countUnsafeAssertions applies those lines while traversing parsed assertion nodes.
Caller and CI entry point: The ratchet's collection path invokes countUnsafeAssertions for every governed source file, and the package script exposes the ratchet as a check.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs test/scripts/check-assertion-safety-ratchet.test.ts

Result: FAIL (failed) — step 1 run node scripts/run-vitest.mjs test/scripts/check-assertion-safety-ratchet.test.ts: previous terminal command was still running after 30 seconds: "node scripts/run-vitest.mjs test/scripts/check-assertion-safety-ratchet.test.ts"

[test] starting test/vitest/vitest.tooling.config.ts

 RUN  v4.1.11 /tmp/clawsweeper-live-proof-130191-4W1zfM/target

stdout | test/scripts/check-assertion-safety-ratchet.test.ts › check-assertion-safety-ratchet › compares an explicit moving base at the branch fork
assertion SAFETY ratchet OK: 2 files, 2 grandfathered assertions.

 ✓  tooling  test/scripts/check-assertion-safety-ratchet.test.ts (5 tests) 355ms

 Test Files  1 passed (1)
      Tests  5 passed (5)
   Start at  00:38:39
   Duration  1.12s (transform 317ms, setup 56ms, import 345ms, tests 355ms, environment 0ms)

[test] passed 1 Vitest shard in 7.62s

Assertions:

  • FAIL expect_output: Tests

How this fits together

The 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
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +15. Total +15 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 15 0 +15
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 15 0 +15

Review metrics

Metric Value Why it matters
Production versus test LOC production 0, tests +15 The PR adds one focused regression fixture without changing runtime or ratchet configuration behavior.

Technical review

Best 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.

Labels

Label changes:

  • remove proof: sufficient: Current real behavior proof status is not_applicable, not sufficient.

Label justifications:

  • P3: This is a focused test-only hardening change with no production behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This member-authored, test-only PR is exempt from the external-contributor real-behavior-proof gate; its body also records targeted test and ratchet validation.

Evidence

What I checked:

Likely related people:

  • steipete: Peter Steinberger introduced the assertion SAFETY ratchet, carried its subsequent refactors and fixes, authored the merged scanner repair, and owns the proposed regression coverage. (role: feature owner and recent area contributor; confidence: high; commits: 203aafc4156c, 4bd88591264a, 3d9e21a1922a; files: scripts/check-assertion-safety-ratchet.mts, test/scripts/check-assertion-safety-ratchet.test.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-26T17:04:06.859Z sha ed95ed9 :: needs maintainer review before merge. :: none

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.
@steipete
steipete force-pushed the claude/hopeful-matsumoto-9ba691 branch from ed95ed9 to 3d9e21a Compare August 27, 2026 00:31
@openclaw-barnacle openclaw-barnacle Bot added size: XS maintainer Maintainer-authored PR labels Aug 27, 2026
@clawsweeper clawsweeper Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Aug 27, 2026
@steipete
steipete merged commit 35adcc6 into main Aug 27, 2026
112 checks passed
@steipete
steipete deleted the claude/hopeful-matsumoto-9ba691 branch August 27, 2026 00:50
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 27, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant