Repository navigation
refactor(approvals): carry internal authority into worker dispatch - #166050
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
|
Codex review: needs maintainer review before merge. Reviewed October 6, 2026, 6:52 AM ET / 10:52 UTC (Revision 3). ClawSweeper reviewWhat this changesThe PR carries live internal approval guards into the existing SQLite worker dispatcher, preserves native handling for opaque SDK callbacks, and adds boundary regressions and worker-routing documentation. Merge readiness✅ Ready for maintainer review This remains useful work absent from current main. The pinned patch has no actionable correctness or security findings, and the final inventory correction resolves the documented ordering failure. Likely related people: steipete (medium-confidence routing candidate from prior merged approval and authority work). Priority: P2 Review scores
Verification
How this fits togetherGateway approvals receive decisions from internal channel runtimes and agent tools, then persist them and publish resolution events. This change selects the existing worker storage path while retaining the caller's live authority through commit. flowchart TD
A[Internal channel request] --> C[Gateway approval dispatch]
B[Agent tool request] --> C
C --> D{Recognized internal guard?}
D -->|Yes| E[Existing SQLite worker]
D -->|No| F[Native compatibility transaction]
E --> G[Live authority checked before commit]
F --> G
G --> H[Persisted verdict and resolution event]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +74, Tests +300, Docs +12. Total +386 across 8 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Use the existing approval writer for recognized internal callers while preserving live commit checks and the released native callback contract. Do we have a high-confidence way to reproduce the issue? Yes, source inspection establishes that current main routes these guarded internal approvals through native compatibility storage. The captured boundary measurements report failing-before and passing-after results; this read-only review did not rerun them. Is this the best way to solve the issue? Yes, the patch reuses the existing writer and authority owners instead of adding parallel storage machinery, and preserves opaque callbacks at their established synchronous boundary. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 9eb998b7d1b0. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
Preserve prepared question caller authority alongside internal approval worker carriers. Integrate current main dependency and session-authority fixes without rebasing. P2 autoreview is scoped-clean; focused approval and dispatch proof passes, with remaining integration gates tracked before landing.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
The approval carrier test was prepended to the canonical worker inventory. Sorted discovery then disagreed with the planner and CLI ownership assertions. Keep the same host-owned routing and restore alphabetical order. Both failing files now pass all 124 tests; focused P2 autoreview is clean.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
…penclaw#166050) * refactor(approvals): carry internal authority into worker dispatch * style(approvals): brace revocation test guards * fix(test): keep Gateway worker inventory sorted The approval carrier test was prepended to the canonical worker inventory. Sorted discovery then disagreed with the planner and CLI ownership assertions. Keep the same host-owned routing and restore alphabetical order. Both failing files now pass all 124 tests; focused P2 autoreview is clean.
What Problem This Solves
Internal channel approval resolution and in-process agent approval requests still selected native compatibility transactions, leaving approval lookups, verdicts, malformed denials, and cron grant minting on the Gateway thread after the WebSocket cutover in #162549.
Why This Change Was Made
Carry the exact first-party live guard through internal dispatch and the request authority owner into the existing approval writer. The guard remains live at transaction and commit admission. The existing writer retains physical database identity, authoritative row rereads, foreign-commit freshness, FIFO, cron authority publication, and accepted-write settlement. No new worker, schema, durable state, configuration, or cache is introduced.
Opaque SDK callbacks and unrecognized transport callbacks retain native execution. The shipped contract is
v2026.9.8:src/plugin-sdk/gateway-runtime.ts:46→src/gateway/server-methods/shared-types.ts:477(GatewayRequestHandlerOptions.sessionMutationCommitGuard). Its shared SQL kernels remain compatibility debt through the next Plugin SDK major.User Impact
No user-visible decision, permission, retention, durability, or update-format change. First-party approval persistence leaves the caller thread. Production diff: +81 / −7 / net +74 LOC across five files. Static T1: 846 → 846 (reduction 0); the 16 lane sites remain shared with the released native SDK contract.
Existing other-owner source assertions remain live and may perform their pre-existing indexed session reads:
src/agents/harness/native-session/binding-authority.ts:193,src/gateway/session-sharing-source.ts:168, andsrc/agents/agent-harness-completion-recovery.ts:175. This PR does not claim those authority reads are SQL-free.Evidence
--maxWorkers=1, 700.86 seconds wall time on the shared local host (638.43 seconds Vitest). The final standalone carrier file passes all seven cases in 88.86 seconds wall / 6.56 seconds test time, including worker startup. This registered-router/worker composition is necessary because store-only tests already passed before the defect was fixed.--maxWorkers=1, 1,894.30 seconds wall. This includes the runtime-process graph, shared-state and reply import closures, channel/instance dispatch, WebSocket custody, agent-tool routing, and real node auto-review. The new database-backed fixture is routed to the host-owned Gateway project.cd060c5fde74→345619c72051(digestff7b090f). Final follow-up5ce52b9920fechanges only test braces; all production and API inputs remain unchanged.node scripts/check-changed.mjs --base cd060c5fde7434b5834a46bd5b181047db28c021: passed. The only remaining lint diagnostic is an existing max-lines warning in untouchedsrc/gateway/server-close.agent-databases.test.ts.finished,/readyz200, installed build identity and durable/incognito post-update behavior verified. The tarball was built from the pinned base plus the five content-verified production files; its build metadata retains the base SHA. Tarball SHA-256:350d2415ef73ff9bba8d1a4aff6eb247700c4ea36c31c2a2257e065a247da873. The owned lease is released. Testbox expired during local source preparation and AWS refused vCPU capacity before this successful Hetzner fallback; neither ran candidate code.cd060c5fde7434b5834a46bd5b181047db28c021. No newOPENCLAW_*names.Focused real-entry SQL measurements use the shared calibrated native observer on MAIN and workers; prepares are excluded, multi-statement execs are split, and measured failures are zero. Setup and post-request verification are outside the request windows. Resolution rows are identical across three warmed samples per route; malformed denial and first grant mint are single samples.
These synthetic fixtures isolate the moved approval operations; they do not claim removal of the other-owner source reads listed above or measure uninstrumented latency.
Overlap: B2 #165552; cold admission #165680; incognito P7k/P7l/P7m/P7m2 (#165885, #165895, #165890, #165901); locked-write chain (#165859, #165894, #165904, #165921); concurrent SQL-efficiency and W6 entry/auth lanes. Whoever lands second integrates current main. #162433 is now closed and is only historical incidental overlap.
Landing integration and CI diagnosis
Merged main
bcae52b9a85a2207a66b3c9927edc17e56261a58into the branch with merge commit42ba88eb4e0b85e91fdfe9e42b9a9b847fd1008d(no rebase). The two dispatch-authority conflicts preserve main's prepared question caller-read wiring alongside the approval carrier. Independent P2 autoreview is scoped-clean, and ClawSweeper's review of this head has no actionable findings.Integrated-tree validation passed: 11 focused files / 119 tests (
--maxWorkers=1, 1,547.13 seconds wall), core production types and all 27 core test-type groups, formatting, and Madge with zero cycles. The focused set includes approval decisions and revocation, opaque callback compatibility, question authority, native approval effects, dispatch, the runtime-process build graph, and the PR wrapper source closure. No additional host-owned routing or wrapper inventory changes were needed.The committed SDK API report for
bcae52b9a85a→42ba88eb4e0breports no API changes (digestff7b090f). The released callback signature was also checked directly inv2026.9.8andv2026.10.1-beta.1; this PR adds no changed public signature, removed export, or newOPENCLAW_*name.CI run 37446774421 completed with two PR-caused test failures:
ci-node-test-plan.test.tsandvitest-cli-ownership.test.tscompare sorted discovery against the Gateway worker inventory, where this PR had prepended its new test. Their failing CI invocations took 82.56 seconds and 8.95 seconds, respectively. Five full-file runs per file on the PR reproduce the mismatch; five runs per file on the merge base pass (114/114 planner tests and 10/10 CLI ownership tests). The fix belongs in the inventory ordering; no assertion, worker ownership, permission, or runtime behavior needs to change.The inventory correction is
f6044feb22416bc2156beb95bcbf8f907da6af62: it only moves the existing entry into alphabetical position. Both complete failing files now pass all 124 tests (--maxWorkers=1, 219.20 seconds wall; 214.09 seconds Vitest), and a fresh independent P2 autoreview is scoped-clean. All production and SDK inputs are byte-identical to42ba88eb4e0b, so the integrated runtime/type/import and SDK evidence above remains applicable. No assertions were weakened and no retries or sleeps were added.Final-head inherited CI failure
CI run 37452119586, attempt 1 tested head
f6044feb22416bc2156beb95bcbf8f907da6af62through mergeb352013f3e595c7363db1bb76ffbb841e2261d98, whose main parent is46ba1d11d1b1f29610f84e87d627550f63a8f3b6. Its sole root failure is job 112231318431,server-rpc-restart-owner.test.ts/records an actual RPC queued reply awaiting final delivery during restart: a 120-second test timeout followed by a 180-second cleanup timeout. The aggregate CI gate also fails; all other selected jobs passed and none were cancelled.This is inherited from main #165996 (
602c0e8ca10ef8e8c1abec2d0c50ce8f86983539): queue admission intentionally stopped emitting terminal chat events, but the unchanged restart fixture awaitsqueuedRunTerminal.promisebefore releasingfirstGate. The consuming reply cannot finish until that gate is released. The nine fixture, queue, dispatch, and cleanup inputs used to qualify this failure are byte-identical between the CI main parent and tested merge. The request is WebSocketchat.send, which the approval-method predicate excludes; it does not reach this PR's new approval carrier. The operator-authority-loss message occurs only during teardown after the timeout.Isolated Linux attribution run, Node 24.19.0 / pnpm 12.5.1: the exact PR head passes the original two-file order (6/6, 85.124 seconds wall) and five standalone runs (3/3 each). The merge base
bcae52b9a85a2207a66b3c9927edc17e56261a58also passes five standalone runs (3/3 each). Independently pinned mainba41a183375447849a66538e553e7520328f8428fails the same case in the original order (1 failed / 5 passed, 358.047 seconds wall), with the same 120-second test and 180-second hook timeouts. The attribution run correctly exits 1; its owned Testbox lease is stopped. This qualifies the authorized inherited-failure admin route and does not claim CI is green.An earlier local original-order attempt encountered a different prerequisite failure: the imported parent-agent lifecycle case exceeded its 90-second timeout, followed by plugin-metadata-shutdown errors (582.67 seconds total wall). The same unchanged order passes on isolated Linux. Local scheduling/performance remains uncertain; that passing replay is not claimed as a fix for the local timeout.
ClawSweeper completed the exact final head at 2026-10-06T10:52:18.391Z with a ready verdict and no actionable findings (review run). The production and inventory-fix P2 autoreviews are both scoped-clean.
Latest-main source check:
fcf275b642608e459130d62b3dc305e215959319retains all nine causal source blobs from the reproduced mainba41a183375447849a66538e553e7520328f8428; no fix for this failure had landed at that check.