Repository navigation
feat(tooling): adopt noUncheckedIndexedAccess via a strict-ratchet lane (phase 1) - #104577
Conversation
Burns down all 65 noUncheckedIndexedAccess errors in the seven ratchet packages with behavior-identical restructuring (iteration, charAt/slice, regex-group guards, validated hextet tuple). net-policy invariant violations now throw instead of failing open. Adds @openclaw/normalization-core/expect (expectDefined/first/last) with subpath export and tests. memory-host-sdk fixes kept but the package stays out of the lane: it re-exports core src/** so the flag would apply transitively to all of core.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 060ca42217
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "**/node_modules/**" | ||
| ], | ||
| "overrides": [ | ||
| // Keep these package globs aligned with the noUncheckedIndexedAccess ratchet lane. |
There was a problem hiding this comment.
Keep .oxlintrc.json parseable by extension lint
When CI runs the extension-channels or extension-bundled additional-check groups, lint:extensions:channels/lint:extensions:bundled go through scripts/lib/run-extension-oxlint.mjs, whose writeTempOxlintConfig() still reads this file with JSON.parse(...). This new // comment makes .oxlintrc.json invalid JSON, so those lint lanes fail before oxlint runs (locally, JSON.parse(fs.readFileSync('.oxlintrc.json','utf8')) throws Unexpected token '/'). Either keep this config strict JSON or update that runner to parse JSONC/JSON5 as well.
Useful? React with 👍 / 👎.
|
Codex review: needs changes before merge. Reviewed July 11, 2026, 1:24 PM ET / 17:24 UTC. Summary PR surface: Source +72, Tests +75, Config +40, Other +39. Total +226 across 35 files. Reproducibility: yes. for the review finding: source inspection shows that adding a package to the tsconfig and routing constant while omitting Review metrics: 2 noteworthy metrics.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Copy recommended automerge instructionNext step before merge
Security Review findings
Review detailsBest possible solution: Use one focused guard to parse and normalize the package scopes from Do we have a high-confidence way to reproduce the issue? Yes for the review finding: source inspection shows that adding a package to the tsconfig and routing constant while omitting Is this the best way to solve the issue? No, not quite as submitted. The staged ratchet is a sound bounded approach, but its stated compiler, routing, and lint alignment must be enforced by one shared invariant before merge. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 702ba19e3aba. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +72, Tests +75, Config +40, Other +39. Total +226 across 35 files. View PR surface stats
Acceptance criteria:
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
Review history (1 earlier review cycle)
|
|
Merged via squash.
|
…ne (phase 1) (openclaw#104577) * feat(tooling): add noUncheckedIndexedAccess strict-ratchet lane * fix(packages): make indexed access explicit across ratchet packages Burns down all 65 noUncheckedIndexedAccess errors in the seven ratchet packages with behavior-identical restructuring (iteration, charAt/slice, regex-group guards, validated hextet tuple). net-policy invariant violations now throw instead of failing open. Adds @openclaw/normalization-core/expect (expectDefined/first/last) with subpath export and tests. memory-host-sdk fixes kept but the package stays out of the lane: it re-exports core src/** so the flag would apply transitively to all of core. * fix(lint): keep .oxlintrc.json strict-JSON parseable for extension lint wrappers
…le B) (#171920) * fix(google): report the operation that supplied fallback video An empty SDK video result can fall back to a distinct REST operation. Capture its name after that fallback so returned metadata identifies the delivered video. Keep the SDK error check before fallback and preserve requests and media limits. Parameterize the existing fallback regression for SDK 404 and SDK empty results. The real provider entry probe fails on the original empty-result metadata and passes both scenarios with this fix, using synthetic SDK and HTTP responses. * refactor(providers): consolidate old provider and protocol helpers Share exact Gateway schema fields without changing public shapes. Consolidate tool-payload classification, catalog responses, device polling, media formatting, and speech format selection. Remove the Mantle factory's test-only injection seam. Best-effort tradeoffs accepted: - OpenRouter equivalent nested request policies reordered during configuration edits may cause another bounded catalog GET. #102062 supplies synthetic key equivalence, not a human incident; full auth/network policy stays in the key. - Warm Anthropic scans may discover more history than cold scans. #109309/#115259 establish synthetic frontier equality, not a human pagination incident. Charge actual I/O only, retaining the 64MiB read and bounded file/cache limits. - A complete Anthropic read exactly at the I/O cap can now be cached. The former fence supported synthetic cold/warm cost equality; incomplete reads stay out. - Deleted transcript metadata can remain in the bounded cache until eviction. #109309's eager sweeps duplicate current-candidate visibility and bounded retention; no current file means no visible cached row. - A manually sparse single-audio-item array yields empty text rather than an invariant error. #104577/#104558 introduced the throw for a compiler ratchet; the real caller supplies a dense filter result, not a reported runtime failure. Standalone session-memory backend and its registry/factory/tests are untouched. * refactor(qa-lab): consolidate older harness paths Share manifest discovery/linking, bus parser construction, Matrix device verification, registration-local fault history, FIFO starts and mock answers. Remove type-laundering and duplicate work on trusted internal facts. Best-effort tradeoffs accepted - Heap-capture PID fences came from synthetic replacement tests in #137860, not a human actual-use report. A coincident restart may fail or omit this optional diagnostic; the snapshot-writer health barrier remains. - Failed-realpath lexical guessing came from synthetic execution validation in #116912. A disappearing/inaccessible test now fails existing evidence verification instead of guessing its identity; real symlink paths still work. - #143976 introduced duplicate taxonomy parsing alongside both production callers' canonical identity guarantees. Untyped invalid internal build calls omitting required identity are unsupported; external artifact validation stays. - Manifest discovery is invocation-local. A source catalog changed during staging is best-effort and is rescanned on the next invocation, rather than repeatedly scanning the same catalog for each selected plugin. - The search fixture's fixed hostname (8288b4d) needs no URL-parser fallback. No runtime hostname input exists; a future fixture URL rewrite must update its hostname field too. Current output is unchanged. - db4ad84 projected hit objects to hide registration IDs. Those IDs are now gone, and all private callers only read hit facts. Unexpected future internal object mutation may alter QA diagnostics; stable array snapshots remain. Focused owner tests, canonical QA production/test typechecks, syntax lint, formatting, suppression tests, zero runtime/madge cycles and independent P0-P2 review cover the retained cut. No SDK/config/protocol/schema changes. Local broad-proof gaps are recorded in .local/q04-ledger.md: SDK boundary declaration preparation exceeded its existing 300000ms deadline before typed lint ran; the repo-wide SQLite worker scanner was interrupted after more than 25 minutes on an overloaded host. Neither is attributed as inherited CI red. The production, full-tree and script Knip scans also exceeded their existing 600-605s deadlines without a code verdict. Bundled exact-head CI must provide the missing broad proof; no timeout/skip/retry policy was changed. * refactor(android): simplify legacy native owners Use platform accessibility nodes and canonical coroutine cancellation. Remove duplicate sheet validation and unreachable mascot clamps while retaining security, resource bounds and normal lifecycle behavior. Fix DNS-SD display names by preserving advertised UTF-8 text and decoding instance names once. Both Android APK variants, 260 focused native test cases, lint, cycle checks and independent review validate the candidate. * refactor: keep round-3 bundle within old-code scope Drop all hunks in files touched on main within seven days, plus dependent Mantle, Anthropic cache, and QA assertion cuts. Preserve current main tests and baseline without allowances or shims. Keep Google SDK errors in the typed SDK owner and REST errors in its existing helper, without adding assertions. Retain one full mock ask-user roundtrip contract and the two distinct precedence cases. * refactor(anthropic): preserve fresh hosts without map spread * refactor(qa-lab): drop Gateway startup cleanup from bundle Restore the q04 startup import closure and direct tests to main for Telegram menu E2E attribution. Keep Matrix/profile-evidence, provider, and Android changes unchanged.
…le B) (openclaw#171920) * fix(google): report the operation that supplied fallback video An empty SDK video result can fall back to a distinct REST operation. Capture its name after that fallback so returned metadata identifies the delivered video. Keep the SDK error check before fallback and preserve requests and media limits. Parameterize the existing fallback regression for SDK 404 and SDK empty results. The real provider entry probe fails on the original empty-result metadata and passes both scenarios with this fix, using synthetic SDK and HTTP responses. * refactor(providers): consolidate old provider and protocol helpers Share exact Gateway schema fields without changing public shapes. Consolidate tool-payload classification, catalog responses, device polling, media formatting, and speech format selection. Remove the Mantle factory's test-only injection seam. Best-effort tradeoffs accepted: - OpenRouter equivalent nested request policies reordered during configuration edits may cause another bounded catalog GET. openclaw#102062 supplies synthetic key equivalence, not a human incident; full auth/network policy stays in the key. - Warm Anthropic scans may discover more history than cold scans. openclaw#109309/openclaw#115259 establish synthetic frontier equality, not a human pagination incident. Charge actual I/O only, retaining the 64MiB read and bounded file/cache limits. - A complete Anthropic read exactly at the I/O cap can now be cached. The former fence supported synthetic cold/warm cost equality; incomplete reads stay out. - Deleted transcript metadata can remain in the bounded cache until eviction. openclaw#109309's eager sweeps duplicate current-candidate visibility and bounded retention; no current file means no visible cached row. - A manually sparse single-audio-item array yields empty text rather than an invariant error. openclaw#104577/openclaw#104558 introduced the throw for a compiler ratchet; the real caller supplies a dense filter result, not a reported runtime failure. Standalone session-memory backend and its registry/factory/tests are untouched. * refactor(qa-lab): consolidate older harness paths Share manifest discovery/linking, bus parser construction, Matrix device verification, registration-local fault history, FIFO starts and mock answers. Remove type-laundering and duplicate work on trusted internal facts. Best-effort tradeoffs accepted - Heap-capture PID fences came from synthetic replacement tests in openclaw#137860, not a human actual-use report. A coincident restart may fail or omit this optional diagnostic; the snapshot-writer health barrier remains. - Failed-realpath lexical guessing came from synthetic execution validation in openclaw#116912. A disappearing/inaccessible test now fails existing evidence verification instead of guessing its identity; real symlink paths still work. - openclaw#143976 introduced duplicate taxonomy parsing alongside both production callers' canonical identity guarantees. Untyped invalid internal build calls omitting required identity are unsupported; external artifact validation stays. - Manifest discovery is invocation-local. A source catalog changed during staging is best-effort and is rescanned on the next invocation, rather than repeatedly scanning the same catalog for each selected plugin. - The search fixture's fixed hostname (34f2850) needs no URL-parser fallback. No runtime hostname input exists; a future fixture URL rewrite must update its hostname field too. Current output is unchanged. - 2f4f28f projected hit objects to hide registration IDs. Those IDs are now gone, and all private callers only read hit facts. Unexpected future internal object mutation may alter QA diagnostics; stable array snapshots remain. Focused owner tests, canonical QA production/test typechecks, syntax lint, formatting, suppression tests, zero runtime/madge cycles and independent P0-P2 review cover the retained cut. No SDK/config/protocol/schema changes. Local broad-proof gaps are recorded in .local/q04-ledger.md: SDK boundary declaration preparation exceeded its existing 300000ms deadline before typed lint ran; the repo-wide SQLite worker scanner was interrupted after more than 25 minutes on an overloaded host. Neither is attributed as inherited CI red. The production, full-tree and script Knip scans also exceeded their existing 600-605s deadlines without a code verdict. Bundled exact-head CI must provide the missing broad proof; no timeout/skip/retry policy was changed. * refactor(android): simplify legacy native owners Use platform accessibility nodes and canonical coroutine cancellation. Remove duplicate sheet validation and unreachable mascot clamps while retaining security, resource bounds and normal lifecycle behavior. Fix DNS-SD display names by preserving advertised UTF-8 text and decoding instance names once. Both Android APK variants, 260 focused native test cases, lint, cycle checks and independent review validate the candidate. * refactor: keep round-3 bundle within old-code scope Drop all hunks in files touched on main within seven days, plus dependent Mantle, Anthropic cache, and QA assertion cuts. Preserve current main tests and baseline without allowances or shims. Keep Google SDK errors in the typed SDK owner and REST errors in its existing helper, without adding assertions. Retain one full mock ask-user roundtrip contract and the two distinct precedence cases. * refactor(anthropic): preserve fresh hosts without map spread * refactor(qa-lab): drop Gateway startup cleanup from bundle Restore the q04 startup import closure and direct tests to main for Telegram menu E2E attribution. Keep Matrix/profile-evidence, provider, and Android changes unchanged.
* refactor(packages): consolidate protocol and stream ownership Use one tuple-preserving ordered literal-union constructor without changing Gateway protocol JSON, exported shapes, or static inference. Share Anthropic request, refusal, reducer, compaction and terminal ownership while preserving the SDK/fetch adapters and their error profiles. Reuse the existing abort race. Reuse prepared compaction details and table widths, trust typed internal file metadata inputs, and leave the Agent loop as the sole message-snapshot owner. Replace the primitive-only session-options deep clone with a shallow copy. Remove write-only transport scratch indices and duplicate outer cleanup; reuse prepared Markdown token projections. Route Completions context budgeting through the shared calibrated CJK estimator, correcting underestimated rare/halfwidth and supplementary input. Add request-budget regression cases. Best-effort tradeoffs accepted: - Malformed internal assistant/tool-name values violating AgentMessage can throw instead of being silently omitted. The guards came from extractions #85341/#123467, with no cited human malformed-message incident. External tool arguments and patch-result metadata remain validated. - An impossible table column/width mismatch no longer gets a custom error. The removed throw came from strict-index ratchet #104577, not an actual-use report; columns and widths still come from the same ordered allocation. No Phase E standalone session-memory backend, security authority, public protocol/config/SDK contract, schema, dependency or durability change. * test(plugins): make cancellation ownership fixture deterministic Hold the Anthropic fixture's second pull on its existing cleanup gate so the custom cancellation work is actually admitted before testing its ownership. An upstream fetch abort may otherwise error the wrapper before cancel runs, making the test demand settlement of work that was never accepted. Keep every origin-context, drainage, lifetime and reuse assertion unchanged. No production behavior, timeout, retry or skip changes.
…aw#172991) * refactor(packages): consolidate protocol and stream ownership Use one tuple-preserving ordered literal-union constructor without changing Gateway protocol JSON, exported shapes, or static inference. Share Anthropic request, refusal, reducer, compaction and terminal ownership while preserving the SDK/fetch adapters and their error profiles. Reuse the existing abort race. Reuse prepared compaction details and table widths, trust typed internal file metadata inputs, and leave the Agent loop as the sole message-snapshot owner. Replace the primitive-only session-options deep clone with a shallow copy. Remove write-only transport scratch indices and duplicate outer cleanup; reuse prepared Markdown token projections. Route Completions context budgeting through the shared calibrated CJK estimator, correcting underestimated rare/halfwidth and supplementary input. Add request-budget regression cases. Best-effort tradeoffs accepted: - Malformed internal assistant/tool-name values violating AgentMessage can throw instead of being silently omitted. The guards came from extractions openclaw#85341/openclaw#123467, with no cited human malformed-message incident. External tool arguments and patch-result metadata remain validated. - An impossible table column/width mismatch no longer gets a custom error. The removed throw came from strict-index ratchet openclaw#104577, not an actual-use report; columns and widths still come from the same ordered allocation. No Phase E standalone session-memory backend, security authority, public protocol/config/SDK contract, schema, dependency or durability change. * test(plugins): make cancellation ownership fixture deterministic Hold the Anthropic fixture's second pull on its existing cleanup gate so the custom cancellation work is actually admitted before testing its ownership. An upstream fetch abort may otherwise error the wrapper before cancel runs, making the test demand settlement of work that was never accepted. Keep every origin-context, drainage, lifetime and reuse assertion unchanged. No production behavior, timeout, retry or skip changes.
Closes #104558
What Problem This Solves
noUncheckedIndexedAccessis off, soarr[i]/record[key]reads typecheck as always-defined; a fresh probe counts 1,750 would-be errors repo-wide, including real crash paths behind regex-group indexing. Flipping globally is intractable in one change, and an unguided migration would degenerate into!spam (~1,200 non-null assertions already exist unenforced).Why This Change Was Made
Phase 1 of an include-list ratchet:
tsconfig.strict-ratchet.jsoncompiles seven packages (markdown-core,net-policy,media-understanding-common,terminal-core,normalization-core,model-catalog-core,web-content-core) withnoUncheckedIndexedAccess: true. Wired intotsgo:strict-ratchet,check.mjs, the CItest-typesshard (with a historical-target guard matching existing patterns),tsgo:allproject references, andcheck:changedrouting (newstrictRatchetlane); a sync test pins the tsconfig include list, the changed-lanes constant, and routing together so they cannot drift.memory-host-sdkwas planned for phase 1 but excluded with a documented reason: it re-exports coresrc/**directly, so the flag would apply transitively to all of core (1,267 errors); it migrates together withsrc/. Its 5 index-safety fixes are kept — they are valid improvements under the core lane..entries(),toReversed()),charAt/slicefor character access, regex-group guards, and a validated fixed-length hextet tuple innet-policy/ip.ts. In that security-relevant file, impossible invariant violations now throw loudly instead of failing open (a silentundefinedwould have skipped SSRF embedded-IPv4 blocking).@openclaw/normalization-core/expect(expectDefined,first,last) with subpath export, build entry, and tests;expectDefinedhas three production call sites in this diff.getOrCreatewas deliberately omitted (no call sites yet — helpers must pay rent).typescript/no-non-null-assertion: errorscoped to the seven migrated packages (they contain zero!today), so fixed code cannot regress into assertion spam.No
any, no casts, no@ts-expect-error, no fabricated defaults. Later phases:packages/ai+agent-core(196 errors),ui/(304),src/dir-by-dir; the lane is deleted when the base flag flips.User Impact
No runtime behavior change. Index/lookup reads in the migrated packages are now compile-time-proven defined or explicitly handled, and the pattern for the remaining phases is established.
Evidence
node scripts/run-tsgo.mjs -p tsconfig.strict-ratchet.json→ 0 errors (failed with 65 before the burn-down); all existing lanes (core, ui, extensions, scripts, core-test, root-test) fresh non-incremental → 0 errors.pnpm build(new package export packaged), fullpnpm check,pnpm check:test-types, package test suites for all eight touched packages plus the ratchet sync, oxlint-config, changed-lanes, and ci-workflow-guards tests — run link in PR checks.node scripts/run-oxlint.mjs packagesclean with the new override;node scripts/check-tsgo-core-boundary.mjspass.