Repository navigation
fix(gateway): retain approval authority across storage waits - #150237
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 September 22, 2026, 3:29 PM ET / 19:29 UTC (Revision 14). ClawSweeper reviewWhat this changesThe PR preserves approval authorization across database waits, retries refused expiry operations under their original storage owner, and reconciles uncertain verdicts without replaying writes. Merge readiness✅ Ready for maintainer review This PR remains useful and has no blocking findings after re-review. The earlier authority and expiry findings are addressed, and the updated body supplies the requested test-cost context. Priority: P2 Review scores
Verification
How this fits togetherGateway approval handlers connect operator decisions to pending agent actions. The approval manager and SQLite store retain authorization, record the winning verdict, and release waiting actions and approval events. flowchart TD
A[Operator approval request] --> B[Retained request authority]
B --> C[Approval manager]
C --> D[Storage admission and commit checks]
D --> E[SQLite approval record]
E --> F[Waiter settlement and events]
D --> G[Refusal or uncertain result]
G --> C
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +1060, Tests +2424, Docs +56. Total +3540 across 34 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep request authorization and recovery with the existing approval and storage owners, preserving synchronous SDK guards and unchanged durable records. Do we have a high-confidence way to reproduce the issue? Yes, source and the retained causal controls establish concrete revocation-during-admission and refused-expiry paths. This read-only review did not execute a fresh current-main reproduction. Is this the best way to solve the issue? Yes. The patch extends the existing approval owner, shares transition kernels, and preserves the released synchronous guard contract without introducing another durable store. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 78d5bedb34de. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (13 earlier review cycles; latest 8 shown)
|
a9ae30a to
48b6eef
Compare
|
48b6eef to
66d037d
Compare
Carry original request and database authority through approval lookup, verdict admission, recovery, and local settlement. Preserve the tagged opaque SDK guard contract through the same mutation kernels. Use actual postcommit receipts for auto-review provenance, retain unknown outcomes without confusing refusal with corruption, and fence retries against replaced database owners.
d8b39b4 to
95a13d3
Compare
|
@clawsweeper re-review Please review head The revised body records 521 passing tests, fresh clean P2 review, the exact build/check proof limits, postcommit receipt and physical-owner recovery controls, and the separate remaining internal authority-SQL migration. Hosted CI is attached to this head. |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review Please review current head The updated PR body records the exact final proof scopes, including 65 causal controls, 553 qualified owner cases, normal build, clean managed P2 reviews, and remaining internal-producer SQL work. The original real Gateway native-hook case passes. Exact-head CI is running in 35770681245. |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
* commit 'ba4bc10ee5283f37813593da158cd3146f4cf2bf': (53 commits) fix(tests): drain persistence deliveries before fixture cleanup (openclaw#155934) fix(tests): drain Gateway abort deliveries before teardown (openclaw#155913) fix(test): give the bundled MCP tarball checks time on Windows runners (openclaw#155931) improve: explain where session catalog requests spend time (openclaw#155786) fix(test): recognize deletion cancellation in SQLite lifecycle proof test(gateway): join request lifetimes before fixture teardown test(codex): assert late-abort interrupt identity (openclaw#154853) fix(cron): avoid blocking Gateway during retention discovery (openclaw#155414) fix(tests): drain subagent deliveries before teardown (openclaw#155910) fix(ci): recover Security Review when diff data settles slowly (openclaw#155921) fix(ci): recover Security Review after checkout failures (openclaw#155919) fix(infra): retain SQLite reader modules in PR wrapper inventory ci: pack test jobs and add opt-in Spot cron routing (openclaw#155403) fix(gateway): retain approval authority across storage waits (openclaw#150237) test(media): isolate base64 memory accounting per VM (openclaw#155638) fix(gateway): keep concurrent session descriptions responsive (openclaw#155471) fix(test): await Talk storage cleanup before removing fixtures fix(tests): settle subagent steer work before teardown (openclaw#155888) test(ci): respect retained command worker caps (openclaw#155735) test(ui): synchronize release fixtures with owned lifetimes ...
…w#150237) * fix(gateway): retain approval authority across storage waits Carry original request and database authority through approval lookup, verdict admission, recovery, and local settlement. Preserve the tagged opaque SDK guard contract through the same mutation kernels. Use actual postcommit receipts for auto-review provenance, retain unknown outcomes without confusing refusal with corruption, and fence retries against replaced database owners. * fix(gateway): retain approval owners across retries and policy changes
Backport #150237: d9c0dd6 Backport #155964: fa92bd5 Preserve bound runtime and persistence authority across approval operations, terminal reconciliation and deadline settlement. Keep HTTP operator session execution on its existing capability owner. No schema or configuration bump. Independent review and affected owner/entrypoint regressions are complete. Combined release and hosted CI qualification remain separate. Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vyctorbrzezowski <[email protected]> Co-authored-by: steipete <[email protected]> Co-authored-by: jalehman <[email protected]>
Related: #153591, #153663.
What Problem This Solves
An approval request could lose authority while lookup or verdict work waited for SQLite and still commit or publish a response. Definite storage refusals could incorrectly settle a pending waiter as corrupt, or strand an expired approval after its one-shot timer fired. Lost worker replies could also lose local settlement or auto-review provenance.
User Impact
Approval lookup, history, expiry, and verdicts retain their live request and storage owners across asynchronous work. Disconnect alone preserves authorized completion; revoked requests leave the pending row, waiter, and events unchanged. Existing external synchronous SDK guards continue to work. Public shapes, stored bytes, schema, retention, FIFO, original deadlines, and decision rules stay unchanged.
Why This Change Was Made
Capture the original request binding in unified approval handlers and legacy exec/plugin get/list/wait/resolve. Recheck request, reviewer, source binding, and current policy around awaited work and at transaction/commit admission. Committed config publications retain relevant auth and session-routing facts: equivalent or unrelated settings preserve the request, while permission/routing changes permanently revoke it even after a restore. Both worker and native-compatible requests carry that publication fence and release its listener when the handler completes.
The existing approval store owns FIFO across the worker family and the explicitly selected v2026.9.4 opaque synchronous SDK guard family. Both use the same transition kernels and shared admission owner. The compatibility family stays native so a SQL-capable guard does not wait on its own worker transaction; worker failure never selects that family. Removing it requires a public contract that can require guards safe for worker admission.
Distinguish admission refusal, corruption, and unknown mutation outcomes. Autonomous expiry rearms its existing timer only for canonical pre-execution overload/unavailability, retaining its original database and maintenance/schema/coordinator scopes. Later resolve/deny and local settlement keep that pending-entry fence; they cannot adopt a replaced owner or redirect the pending verdict to another database. Retirement clears the timer, cancellation still closes executable authority immediately, and ordinary corruption retains its fail-closed settlement.
Unknown writes receive one readback under their original physical admission, with no automatic verdict replay. Recheck the admission after readback and before local settlement; a matching row in a replacement database does not restore it. Per-operation postcommit receipts are the sole positive evidence for auto-review provenance. Shared/null runtime resolver IDs cannot establish that provenance; missing receipts retain uncertainty, while a distinct device/channel winner settles as an operator decision. Confirmed pending readback clears an inconclusive attempt under its original owner. No-route denial keeps the null decision used by ask fallback.
Evidence
Final local qualification covers 553 cases across 17 owner files: the unchanged 16 files passed 343 cases, and the RPC owner file passed 210/210 after fixing its two existing get/list helpers to supply the required config reader. Those incomplete contexts were the only six failures in the preceding broad run; no assertions or production guards were weakened. The final 65-case expiry/request-authority matrix passes, including eight demonstrated RED→GREEN cases for replacement, rerouting, and native config ABA. The actual isolated Gateway/WebSocket native-hook flow also passes in its original whole-file order.
The production bytes pass a normal build and fresh full P2 review; the final fixture-only correction passes its type/lint checks and a fresh post-95 P2 review. The complete changed-file gate passed on the preceding candidate, and the final ownership delta passes production types, all three affected Gateway type graphs, focused lint, size checks, formatting, and runtime import-cycle checks (zero cycles). The build reported the same 362.3/362.2 KiB UI startup-budget advisory seen in the preceding retained build; this backend diff does not change the UI. Exact-head hosted CI on this successor passed; timings are recorded below.
Causal controls exercise real worker admission saturation and timer callbacks, recovery without a later client read, original coordinator custody, cancellation/retirement, same-path physical replacement, ordinary retries after refusal, and successful/uncertain lost replies. Registered lookup→verdict controls cover disconnect continuation, durable revocation, equivalent/unrelated config publication, and role/routing ABA for worker and native families. Native full-guard and shared-kernel checks retain the SDK contract. The calibrated parent SQL counters for ordinary store lookup/pending/expiry/history remain prepare=0, exec=0, get=0, all=0, run=0, iterate=0, including worker close. Their scope excludes native compatibility and upstream authority producers; no live channel delivery or native fault-injection campaign is claimed.
Measured test cost
Per-file elapsed test execution recorded by Vitest on the final production bytes (seconds, including test hooks; excludes file import/worker startup and is not additive wall time because files overlap). The first nine rows are from the final broad run; the last is the corrected fixture-owner rerun. The latter covers the changed get/list support helpers; support modules and the routing list are not standalone suites.
src/gateway/exec-approval-manager.expiry.test.tssrc/gateway/operator-approval-store.worker.test.tssrc/gateway/server-methods/approval-shared.storage-failure.test.tssrc/gateway/server-methods/approval-shared.test.tssrc/gateway/server-methods/approval.legacy-authority.test.tssrc/gateway/server-methods/approval.request-authority.test.tssrc/gateway/server-methods/approval.settlement.test.tssrc/gateway/server-methods/approval.test.tssrc/gateway/server.native-hook-request-lifetime.test.tssrc/gateway/server-methods/server-methods.test.tsWhole-command costs: broad 17-file run 236.18 s (Vitest 223.53 s, 547 pass/6 fixture-context failures); corrected 210-case owner 164.22 s (Vitest 160.02 s, all pass); final 65-case authority/expiry control 51.01 s (Vitest 47.18 s, all pass). This is retained measured evidence, not a new run or an estimate of incremental CI overhead.
Exact-head CI run 35770681245 completed successfully: 134 successful jobs, 16 skipped. Available job elapsed times (start to completion, including setup):
build-artifacts221 s,check-prod-types323 s,check-test-types618 s,check-test-types-core-1454 s,check-test-types-core-2266 s,checks-fast-bun-launcher123 s. All 59 compact Node test jobs passed, ranging 84–938 s; these shared jobs are not attributed as this PR’s incremental cost.Historical source-bound evidence retained from the previous PR head
Historical evidence on the previous head and its recorded predecessor sources remains separate: 71 authority/handler tests; the original 139-test, nine-file current-main composition; four subsequent physical-worker transcript/approval controls; and the calibrated six-counter lookup/history proof. Their earlier builds, types, reviews, and ordering controls are not final-candidate qualification. The tooling follow-up retained the original-order four-case RED and seven-case GREEN, four routing controls, and 176 wrapper/provisioning passes. Its isolated operation-lock retry passed at the unchanged deadline; the Darwin accelerated cold/warm provisioning cell still hit its original 120-second limit and is not claimed green. The previously blocking task-identifier fixture import was fixed on main in #153988. Historical CI: https://github.com/openclaw/openclaw/actions/runs/35538566830 (151 successful checks, 14 skipped). It is not qualification for this rewritten current-source candidate.
Remaining authority migration
This PR does not finish every approval-related parent-thread SQL migration. Bundled in-process agent callers still need a trusted worker-safe authority carrier through their run/profile/receipt owners; the external SDK compatibility exception does not cover those internal callers. Profile and placement authority preparation are separate owner-level work, excluded from this PR's zero-SQL counter claim. The remaining cut must preserve live run/claim/placement authority and owner epochs without impersonating WebSocket authority or dropping checks.