Skip to content

feat(lint): enforce no-chained-type-assertions in clean owner scopes - #124119

Merged
steipete merged 1 commit into
mainfrom
steipete/chained-assert-enable
Aug 15, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/chained-assert-enable

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

OpenClaw had no automated boundary guard preventing new chained TypeScript assertions in owner scopes that have already burned this pattern down. Without a ratchet, constructs such as value as unknown as Target could return silently while the remaining legacy findings were being removed elsewhere.

Why This Change Was Made

This vendors anti-slop's no-chained-type-assertions rule into the existing openclaw-boundaries oxlint plugin and enables it only across the clean owner scopes. The rule reports the outermost assertion once for nested as and angle-bracket chains, permits single assertions and all-const chains, skips test/mock/harness paths, and keeps the explicit boundary-guard fixture root linted.

The broad roots stay maintainable (src, extensions, packages, ui/src, plus the fixture root), while excludedRoots records the 50 dirty scopes as a shrink-only burn-down ledger. src/runtime.ts is excluded as a file, not as all of src; the scanner's ui scope maps to ui/src.

User Impact

No user-visible runtime change. Contributors get an immediate lint failure when a new chained type assertion enters a clean owner scope, while existing test fixtures/mocks and the remaining dirty production scopes are unaffected until their dedicated burn-downs land.

Evidence

Fixture behavior reports exactly the three intended chains—two-step, three-step, and mixed angle/as syntax—once each. The legal single assertion and all-const chain produce no diagnostic:

$ node scripts/run-oxlint.mjs --openclaw-focused-config --config config/oxlint/boundary-guards.json test/fixtures/oxlint-boundary-guards/chained-type-assertions-violation.ts
...:3:1: error openclaw-boundaries(no-chained-type-assertions): This assertion chain discards type evidence. ...
...:4:1: error openclaw-boundaries(no-chained-type-assertions): This assertion chain discards type evidence. ...
...:5:1: error openclaw-boundaries(no-chained-type-assertions): This assertion chain discards type evidence. ...
[oxlint] FAILED (exit 1)
fixture_exit=1

The production scan is clean with the 50-scope ledger active:

$ pnpm lint:no-chained-type-assertions
$ node scripts/run-oxlint.mjs --openclaw-focused-config --config config/oxlint/boundary-guards.json src extensions packages ui/src
full_scan_exit=0

Negative control: temporarily removing only ui/src from excludedRoots makes the same package script fail with 37 diagnostics; the exclusion was then restored and the full scan returned to exit 0:

$ pnpm lint:no-chained-type-assertions
ui/src/components/terminal/terminal-runtime.ts:14:20: error openclaw-boundaries(no-chained-type-assertions): This assertion chain discards type evidence. ...
ui/src/app/native-window-drag.ts:11:5: error openclaw-boundaries(no-chained-type-assertions): This assertion chain discards type evidence. ...
ui/src/pages/chat/chat-send-delivery.ts:677:24: error openclaw-boundaries(no-chained-type-assertions): This assertion chain discards type evidence. ...
ui/src/components/app-sidebar-session-narration.ts:540:20: error openclaw-boundaries(no-chained-type-assertions): This assertion chain discards type evidence. ...
ui/src/pages/chat/chat-send-queue-state.ts:86:22: error openclaw-boundaries(no-chained-type-assertions): This assertion chain discards type evidence. ...
[oxlint] FAILED (exit 1)
negative_control_diagnostics=37
negative_control_exit=1

$ pnpm lint:no-chained-type-assertions  # after restoring ui/src
restored_full_scan_exit=0

Focused tests:

$ node scripts/run-vitest.mjs test/scripts/oxlint-boundary-guards.test.ts test/scripts/run-additional-boundary-checks.test.ts
Test Files  1 passed (1)
Tests       4 passed (4)
Test Files  1 passed (1)
Tests       23 passed (23)
[test] passed 2 Vitest shards in 5.89s

Changed-file checks:

$ node scripts/check-changed.mjs
[check:changed] no ready Crabbox provider; remote checks did not run
[check:changed] fell back to local execution
exit 0 (all selected tooling, format, typecheck, lint, and boundary guards passed)

Autoreview:

$ .claude/skills/autoreview/scripts/autoreview --mode branch --base origin/main
trufflehog: clean
autoreview clean: no accepted/actionable findings reported
overall: patch is correct (0.99)

Provenance: rule semantics adapted from dmmulroy/anti-slop commit 446268e5d15baa968eaec669ff65358d36ae6259, MIT licensed.

The prior burn-downs #124060, #124073, #124079, and #124082 are landed. The remaining follow-up is 252 findings across these 50 excluded scopes; this ledger is shrink-only:

Dirty-scope ledger (50)
extensions/amazon-bedrock-mantle
extensions/anthropic-vertex
extensions/browser
extensions/codex
extensions/copilot
extensions/deepinfra
extensions/diagnostics-otel
extensions/diagnostics-prometheus
extensions/discord
extensions/github-copilot
extensions/google
extensions/googlechat
extensions/imessage
extensions/line
extensions/llm-task
extensions/longcat
extensions/matrix
extensions/microsoft-foundry
extensions/msteams
extensions/qa-lab
extensions/reef
extensions/signal
extensions/slack
extensions/sms
extensions/synology-chat
extensions/telegram
extensions/tlon
extensions/voice-call
extensions/whatsapp
extensions/workboard
extensions/zalo
extensions/zalouser
packages/ai
src/runtime.ts
src/acp
src/agents
src/channels
src/commands
src/config
src/gateway
src/infra
src/media
src/meeting-bot
src/plugin-sdk
src/plugins
src/process
src/proxy-capture
src/shared
src/trajectory
ui/src

@clawsweeper

clawsweeper Bot commented Aug 15, 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 15, 2026 08:54
@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: M maintainer Maintainer-authored PR labels Aug 15, 2026
@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 15, 2026
@clawsweeper

clawsweeper Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 15, 2026, 5:11 AM ET / 09:11 UTC.

ClawSweeper review

What this changes

Adds an Oxlint rule that rejects chained TypeScript assertions in clean production scopes and runs it in supplemental CI.

Merge readiness

⚠️ Needs maintainer review before merge - 2 items remain

Keep open: the new rule has a P2 syntactic bypass through TypeScript non-null assertions, so it does not yet enforce its stated ratchet.

Priority: P3
Reviewed head: 06ae70a1a7af65da1d16f6df19a85aa67e3530d0

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Focused proof is strong, but the rule needs one small correctness repair before merge.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR supplies current-head terminal evidence for fixture diagnostics, the production scan, and supplemental checks; the remaining problem is an uncovered syntactic case.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR supplies current-head terminal evidence for fixture diagnostics, the production scan, and supplemental checks; the remaining problem is an uncovered syntactic case.
Evidence reviewed 5 items Non-null wrapper bypass: The two chain walks unwrap only ParenthesizedExpression. A source expression such as input as unknown! as Target leaves TSNonNullExpression between the assertions, so each visitor sees only one assertion and reports nothing.
AST contract corroboration: The locally available Oxlint plugin types define TSAsExpression and TSTypeAssertion with expression/parent links and include TSNonNullExpression in Expression, matching the bypass shape; package.json pins the reviewed repository to Oxlint 1.75.0.
Existing wrapper recognizes the missing node: The pre-existing expression wrapper already treats TSNonNullExpression as transparent, confirming that this expression shape is relevant to this lint-plugin architecture.
Findings 1 actionable finding [P2] Unwrap non-null assertion wrappers
Security None None.

How this fits together

OpenClaw’s local Oxlint plugin defines repository-specific boundary rules. Its configuration enables those rules, and the supplemental boundary runner executes them in CI against selected production roots.

flowchart LR
A[Production TypeScript] --> B[Boundary guard configuration]
B --> C[Local Oxlint plugin]
C --> D[Assertion-chain detection]
D --> E[Lint diagnostics]
E --> F[Supplemental CI]
Loading

Before merge

  • Unwrap non-null assertion wrappers (P2) - Late finding: input as unknown! as Target puts TSNonNullExpression between the assertions. Both walks stop there, so each assertion is counted as a one-step chain and the rule emits no diagnostic. Treat that wrapper as transparent and add a fixture.
  • Resolve merge risk (P1) - Merging would leave a straightforward as unknown! as Target escape hatch in the new type-safety ratchet despite green direct-chain fixtures.

Findings

  • [P2] Unwrap non-null assertion wrappers — scripts/oxlint-boundary-guards.mjs:126
Agent review details

Security

None.

PR surface

Tests +21, Config +1, Other +181. Total +203 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 3 21 0 +21
Docs 0 0 0 0
Config 1 1 0 +1
Generated 0 0 0 0
Other 3 184 3 +181
Total 7 206 3 +203

Review metrics

Metric Value Why it matters
Production versus test delta production +185/-3; tests and fixtures +21/-0 The production growth implements and wires the lint rule; the test additions cover diagnostics and CI registration but need the missing wrapper case.

Merge-risk options

Maintainer options:

  1. Close the non-null assertion gap (recommended)
    Unwrap TSNonNullExpression while determining the outermost assertion and counting the chain, then add a fixture proving the expression is rejected once.

Technical review

Best possible solution:

Treat non-null assertions as transparent in both chain walks, add a regression fixture for the bypass, then validate the corrected rule on the rebased head.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: linting a clean-scope input as unknown! as Target expression follows the two one-assertion paths and produces no diagnostic; a regression fixture should confirm it on the PR runtime.

Is this the best way to solve the issue?

No: the existing local-rule approach is appropriate, but both assertion walks must treat TypeScript non-null wrappers as transparent before the guard is complete.

Full review comments:

  • [P2] Unwrap non-null assertion wrappers — scripts/oxlint-boundary-guards.mjs:126
    Late finding: input as unknown! as Target puts TSNonNullExpression between the assertions. Both walks stop there, so each assertion is counted as a one-step chain and the rule emits no diagnostic. Treat that wrapper as transparent and add a fixture.
    Confidence: 0.98
    Late finding: first raised on code an earlier review cycle already covered.

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 447393dc3221.

Labels

Label changes:

  • add merge-risk: 🚨 other: The new guard can be bypassed by a semantically equivalent assertion chain that CI does not currently test.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (terminal): The PR supplies current-head terminal evidence for fixture diagnostics, the production scan, and supplemental checks; the remaining problem is an uncovered syntactic case.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: ⏳ waiting on author.

Label justifications:

  • P3: This is a developer-facing static-analysis improvement with no claimed runtime behavior change.
  • merge-risk: 🚨 other: The new guard can be bypassed by a semantically equivalent assertion chain that CI does not currently test.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (terminal): The PR supplies current-head terminal evidence for fixture diagnostics, the production scan, and supplemental checks; the remaining problem is an uncovered syntactic case.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR supplies current-head terminal evidence for fixture diagnostics, the production scan, and supplemental checks; the remaining problem is an uncovered syntactic case.

Evidence

What I checked:

  • Non-null wrapper bypass: The two chain walks unwrap only ParenthesizedExpression. A source expression such as input as unknown! as Target leaves TSNonNullExpression between the assertions, so each visitor sees only one assertion and reports nothing. (scripts/oxlint-boundary-guards.mjs:126, 06ae70a1a7af)
  • AST contract corroboration: The locally available Oxlint plugin types define TSAsExpression and TSTypeAssertion with expression/parent links and include TSNonNullExpression in Expression, matching the bypass shape; package.json pins the reviewed repository to Oxlint 1.75.0. (package.json:2094, 447393dc3221)
  • Existing wrapper recognizes the missing node: The pre-existing expression wrapper already treats TSNonNullExpression as transparent, confirming that this expression shape is relevant to this lint-plugin architecture. (scripts/oxlint-boundary-guards.mjs:2, 447393dc3221)
  • Coverage and CI wiring: The PR enables the rule, invokes it from the supplemental boundary runner, and tests only direct, three-link, mixed angle/as, single, and all-const examples; no non-null-wrapper case is covered. (test/fixtures/oxlint-boundary-guards/chained-type-assertions-violation.ts:3, 06ae70a1a7af)
  • Current-main status and provenance: Current main does not contain this PR head; the existing boundary-guard framework dates to the adjacent current-main commit by the same area contributor. (scripts/oxlint-boundary-guards.mjs:1, 3f6bf166b676)

Likely related people:

  • steipete: Git history attributes the existing focused Oxlint boundary framework and this proposed rule to the same contributor. (role: boundary-guard framework author and recent area contributor; confidence: high; commits: 3f6bf166b676, 06ae70a1a7af; files: scripts/oxlint-boundary-guards.mjs, scripts/run-additional-boundary-checks.mts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Handle TSNonNullExpression as a transparent assertion-chain wrapper.
  • Add and run a regression fixture for as unknown! as Target on the rebased head.

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-15T09:00:19.234Z sha 06ae70a :: needs maintainer review before merge. :: none

@steipete

Copy link
Copy Markdown
Contributor Author

Resolved the remaining ClawSweeper rank-up move with direct inspection of the installed Oxlint 1.75.0 dependency contract:

  • node_modules/oxlint/configuration_schema.json documents local jsPlugins loading, matching the focused config's plugin path.
  • node_modules/oxlint/dist/lint.js loads the module's default export, derives the plugin name from meta.name, registers rules, constructs the per-rule context, accepts create(context), and dispatches context.report({ node, messageId }) through the rule metadata messages.
  • node_modules/oxlint/dist/plugins-dev.d.ts defines context.physicalFilename, context.cwd, TSAsExpression and TSTypeAssertion visitors, and both assertion node shapes with expression, typeAnnotation, and parent. ParenthesizedExpression likewise carries expression and parent, which is the exact contract used to collapse nested chains to one outermost report.
  • The fixture and full CI run exercised that installed parser/runtime: mixed as/angle chains report once, the all-const chain stays legal, the production scan is clean, and check-additional-boundaries-* passed on the exact PR head.

No code change was needed; the dependency-layer verification gap is closed on reviewed head 06ae70a1a7af65da1d16f6df19a85aa67e3530d0.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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 15, 2026
@steipete
steipete merged commit fe5fa80 into main Aug 15, 2026
386 of 388 checks passed
@steipete
steipete deleted the steipete/chained-assert-enable branch August 15, 2026 09:13
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant