Skip to content

refactor(types): drain chained-assertion ledger β€” agents - #124354

Merged
steipete merged 3 commits into
mainfrom
steipete/chained-drain-g2
Aug 16, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/chained-drain-g2

Conversation

@steipete

@steipete steipete commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The chained-type-assertion boundary rule could not enforce src/agents or src/meeting-bot because both directories were excluded wholesale, leaving 34 production findings hidden behind two scope-level ledger entries.

Why This Change Was Made

This removes both scope exclusions, repairs 11 assertions at their owning type boundaries, and converts the 23 load-bearing remainder into 14 explicit file-level entries with one-line reasons. The main owner repair is a single schema-checked erasure adapter for all six session file-tool factories; the other repairs use a discriminated pagination API, parsed dynamic-module hooks, guarded plugin metadata lookup, assignment-compatible stream iterator replacement, and existing session-entry narrowing.

The file-level remainder records the actual contracts that need broader redesign: synthetic messages without provider metadata, provider-only media blocks, DOM/Undici type namespaces, config-only hashing, generic session and meeting projections, SDK header sentinels, and global symbol/Proxy state.

User Impact

No user-visible behavior changes. New chained assertions are now enforced throughout both assigned directories except for the named, reviewable file-level seams.

Evidence

  • Accounting: 34 findings total; 11 fixed, 23 ledgered across 14 files with inline reasons.
  • Assigned scopes: node scripts/run-oxlint.mjs --openclaw-focused-config --config config/oxlint/boundary-guards.json src/agents src/meeting-bot
  • Full lane: node scripts/run-oxlint.mjs --openclaw-focused-config --config config/oxlint/boundary-guards.json src extensions packages ui/src
  • Focused Vitest: 775 assertions passed across unit-fast, agents-core, embedded-runner, and agents-support shards. The final promotion suite passed 31/31.
  • ClawSweeper regression: the writable non-configurable iterator fixture failed before the repair with Cannot redefine property: Symbol(Symbol.asyncIterator) and passes with the assignment-compatible Reflect.set implementation.
  • Changed gate: OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree node scripts/check-changed.mjs passed after the remote ci-fast backend was unavailable and the wrapper fell back locally.
  • Autoreview: .claude/skills/autoreview/scripts/autoreview --mode branch --base origin/main reported no accepted/actionable findings on the refreshed head.
  • Production LOC: +110/-39 (net +71); tests: +31/-0; tooling ledger: +14/-2. Growth is the typed schema-validation adapter, discriminated boundary contracts, and the focused descriptor regression fixture replacing erased casts.
  • Known unrelated anomaly: the existing macOS Unicode-equivalent sandbox-read test reproducibly sees NFC and NFD paths as two matches for one APFS file. It was excluded from the final focused aggregate rather than mixing a filesystem behavior repair into this type-only PR.

@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

πŸ¦žπŸ‘€
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Aug 16, 2026
@steipete
steipete marked this pull request as ready for review August 16, 2026 02:21
@clawsweeper clawsweeper Bot added merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P2 Normal backlog priority with limited blast radius. 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. labels Aug 16, 2026
@clawsweeper

clawsweeper Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 15, 2026, 11:01 PM ET / August 16, 2026, 03:01 UTC.

ClawSweeper review

What this changes

This PR replaces broad chained-type-assertion exclusions in agent and meeting-bot code with typed runtime boundaries and named file-level ledger entries.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open: the prior stream-iterator blocker is fixed, but the provider-hook cleanup replaces a chained assertion with prohibited reflection and needs one focused revision.

Priority: P2
Reviewed head: ada4b5cb04a3ab3177338d8c10e08347da0e6439

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The current head resolves the prior concrete regression, but one focused P2 boundary-cleanup finding remains.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored internal refactor is not subject to the external real-behavior-proof gate; the focused stream regression test is supplemental evidence.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored internal refactor is not subject to the external real-behavior-proof gate; the focused stream regression test is supplemental evidence.
Evidence reviewed 5 items Reflective boundary escape: The new provider-runtime adapter validates an unknown module export, then invokes it through Reflect.apply; root policy explicitly forbids replacing a type assertion with Reflect/property probes for static-analysis cleanup.
Provider export shape: The loaded provider-runtime export is a plain function and does not use receiver state, so a narrowed direct call can retain return-value validation without reflection.
Earlier finding fixed: The stream wrapper now uses assignment-compatible Reflect.set and the added test covers an own writable, non-configurable async-iterator descriptor while draining the stream and result.
Findings 1 actionable finding [P2] Avoid reflection in the provider-hook boundary
Security None None.

How this fits together

Agent runtime assembles file tools, provider-failure classifiers, and model event streams before passing results into sessions and channels. This PR tightens type boundaries around those internal adapters.

flowchart LR
  A[Model tool calls] --> B[Agent tool assembly]
  B --> C[File tool adapters]
  C --> D[Session operations]
  E[Provider errors] --> F[Failover classifier]
  G[Model event streams] --> H[Stream normalization]
  H --> D
Loading

Before merge

  • Avoid reflection in the provider-hook boundary (P2) - Use a narrowed direct callable here rather than Reflect.apply. The loaded export is a normal function in src/plugins/provider-runtime.ts, and this reflection-based replacement violates the repository rule against satisfying assertion cleanup with Reflect/property probes while retaining no needed receiver behavior.

Findings

  • [P2] Avoid reflection in the provider-hook boundary β€” src/agents/failover/provider-patterns.ts:68
Agent review details

Security

None.

PR surface

Source +71, Tests +31, Other +12. Total +114 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 6 110 39 +71
Tests 1 31 0 +31
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 14 2 +12
Total 8 155 41 +114

Review metrics

Metric Value Why it matters
Production versus test delta production +110/-39; tests +31/-0; tooling ledger +14/-2 The cleanup adds a shared runtime validation adapter and should stay justified by real owner-boundary improvements.

Stored data model

Persistent data-model change detected: persistent cache schema: scripts/oxlint-boundary-guards.mjs, serialized state: scripts/oxlint-boundary-guards.mjs, vector/embedding metadata: scripts/oxlint-boundary-guards.mjs. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Keep the typed file-tool and stream-boundary refactor, but invoke the validated provider export directly instead of using reflection.

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

Not applicable for this cleanup PR; the previous PR-head stream-descriptor regression is now directly covered by a focused source test.

Is this the best way to solve the issue?

No: the stream repair is appropriate, but the provider-hook change should use a narrowed direct call rather than reflection.

Full review comments:

  • [P2] Avoid reflection in the provider-hook boundary β€” src/agents/failover/provider-patterns.ts:68
    Use a narrowed direct callable here rather than Reflect.apply. The loaded export is a normal function in src/plugins/provider-runtime.ts, and this reflection-based replacement violates the repository rule against satisfying assertion cleanup with Reflect/property probes while retaining no needed receiver behavior.
    Confidence: 0.9

Overall correctness: patch is incorrect
Overall confidence: 0.9

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • remove merge-risk: 🚨 other: Current PR review selected no merge-risk labels.

Label justifications:

  • P2: This is a bounded internal agent-runtime refactor with one normal-priority review blocker.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored internal refactor is not subject to the external real-behavior-proof gate; the focused stream regression test is supplemental evidence.

Evidence

What I checked:

Likely related people:

  • Vyctor H. Brzezowski: Current-main blame attributes the affected agent adapters and stream wrapper to the recent feature commit; deeper history could not be hydrated from the partial clone. (role: recent area contributor; confidence: medium; commits: 4be9091a3ef6; files: src/agents/agent-tools.read.ts, src/agents/failover/provider-patterns.ts, src/agents/mcp-pagination.ts)

Rank-up moves

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

  • Replace the reflective provider-hook invocation with a narrowed direct call.
  • Run the focused provider-pattern and stream-promotion tests after the revision.

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-16T02:28:00.886Z sha 4aafe13ae864bf67a00302c6a3d82545923c691d :: found issues before merge. :: [P2] Preserve writable non-configurable stream iterators

@steipete
steipete force-pushed the steipete/chained-drain-g2 branch from 4aafe13 to 215704d Compare August 16, 2026 02:49
@steipete
steipete force-pushed the steipete/chained-drain-g2 branch from 215704d to ada4b5c Compare August 16, 2026 02:55
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. label Aug 16, 2026
@steipete
steipete merged commit bb68ad0 into main Aug 16, 2026
183 checks passed
@steipete
steipete deleted the steipete/chained-drain-g2 branch August 16, 2026 03:28
@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 16, 2026
…4354)

* refactor(types): drain chained-assertion ledger β€” agents

* fix(agents): preserve non-configurable stream iterators

* refactor(agents): call provider failover hook directly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: S 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