Repository navigation
fix(update): prevent candidate Doctor authority stack overflows - #157273
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: blocked before merge. Reviewed September 24, 2026, 5:55 PM ET / 21:55 UTC (Revision 3). ClawSweeper reviewWhat this changesThe branch changes shared SQLite admission so candidate Doctor can read requester policy during an authority check, adds regression tests, and documents recovery guidance. Regression provenancePossible regression — suspected (failure trace). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 2 items remain Keep this PR open. Current main still has the admission cycle implicated by the linked managed-update failures, and the proposed repair is focused. The remaining merge gate is an end-to-end upgrade from the published updater into this candidate. Priority: P0 Review scores
Verification
How this fits togetherA chat-triggered update passes requester authority from the installed updater to candidate Doctor. Doctor reads configuration and shared SQLite state before it records the validation result and the updater completes or rolls back. flowchart LR
A[Chat update request] --> B[Installed updater]
B --> C[Candidate Doctor]
C --> D[Requester check]
D --> E[SQLite policy read]
E --> F[Maintenance read admission]
F --> G[Doctor and update result]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +34, Tests +134, Docs +15. Total +183 across 7 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the candidate-side admission repair after an isolated published-2026.9.5-to-candidate managed update demonstrates completion with retained history and a recorded Gateway outcome, then include the fix in a corrective release. Do we have a high-confidence way to reproduce the issue? Yes. Current main's cached policy read can reenter full maintenance admission during candidate Doctor authority checking, and the linked report documents repeated released-version failures; this read-only review did not execute the regression. Is this the best way to solve the issue? Yes. Separating reentrant policy reads from effect admission addresses the shared callback cycle while retaining revocation checks; clearing update history would not fix it. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 1ab1bb09789a. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
Keep synchronous policy reads within their maintenance resource scope without recursively evaluating the same authority callback. Preserve independent parent and child checks, reject nested effects, and retain update history. Cover configured and profile requesters, revocation, nested scopes, and 500 retained runs. Reported by @yoyo837 in #157011.
Assert the current CLI JSON refusal with its run, phase, and driver liveness evidence. Preserve the existing checks that active history and the serving Gateway are unchanged before inactive-run repair.
ab252d1 to
d91641e
Compare
…claw#157273) * fix(update): prevent candidate Doctor authority stack overflows Keep synchronous policy reads within their maintenance resource scope without recursively evaluating the same authority callback. Preserve independent parent and child checks, reject nested effects, and retain update history. Cover configured and profile requesters, revocation, nested scopes, and 500 retained runs. Reported by @yoyo837 in openclaw#157011. * test(update): verify structured repair ownership refusals Assert the current CLI JSON refusal with its run, phase, and driver liveness evidence. Preserve the existing checks that active history and the serving Gateway are unchanged before inactive-run repair.
Fixes #157011. Thanks @yoyo837 for the report and retained failure evidence.
What Problem This Solves
Chat-triggered managed updates can roll back during candidate Doctor with
authority-check-failed: Maximum call stack size exceeded, even on the first attempt.User Impact
The candidate can finish Doctor while retaining failed update history and continuing to reject revoked requesters. The repair needs no history reset, schema migration, new option, or dependency change.
Why This Change Was Made
The recursion is a callback cycle at the shared SQLite maintenance-admission owner:
Profile-backed requesters can also re-enter through their identity lookup, but configured owners already reproduce the defect. Warning text mentioning another run or a macOS path is not traversed as a graph. Reconciliation reads bounded ledger rows; rewriting that valid history would not fix this call cycle.
The canonical synchronous read adapter now uses read admission. It preserves the maintenance scope and its resource custody, checks lifecycle closure, and skips only an authority callback already evaluating its own policy rows. Other scope checks still run. Full effect admission rejects recursive effects, and revocation remains enforced after asynchronous work. An initial autoreview finding about a separately revoked child scope was fixed and covered by regression.
Importer validation also caught an outdated repair-refusal assertion after
7815be4d94e8(#156472) improved the ownership diagnostic. That existing E2E now checks the JSON refusal's exact run ID, requested phase, and missing driver/liveness evidence; all ledger-preservation, Gateway-health, and subsequent repair checks remain.Release behavior:
e1c2a0b476eintroduced the maintenance owner callback after 2026.9.5; tagged 2026.9.6 contains it. Standalone Doctor lacks the candidate's requester callback, and 9.5 lacks this maintenance callback altogether. This is a candidate-side correction reachable through the installed updater; retained failed runs do not require an old-driver patch or data backport. The fix must be included in a corrective release for users targeting 2026.9.6; existing tags should not be rewritten. No release or backport is performed by this PR.Reporter questions: There is no supported retained-history reset.
update cleanupretires eligible recovery originals, and currentupdate repairfinishes/reconciles update work; neither clears the ledger. For the JS stack,NODE_OPTIONS=--stack-trace-limit=200only increases the stored stack depth: it does not make 9.6's message-only catch emit frames instderrTail. Maintainers can run the new requester regression against the pre-fix owner withNODE_OPTIONS=--stack-trace-limit=200 pnpm test src/infra/update-requester-authority.test.ts --maxWorkers=1; Vitest prints the caught error stack. For the released worker itself, a caught-exception debugger or instrumented isolated candidate is needed. Another production retry solely for a stack is unnecessary.Evidence
RangeError: Maximum call stack size exceededthrough the exact cache/admission/requester chain. Its test body took 2.101s; the heavily loaded Mac's shared transform/setup dominated the 593.46s file wall time.--maxWorkers=1: 14 tests across the requester and maintenance-scope files; command walls 34.64s, 15.22s, 15.22s. Warm file durations: requester 12.51s, scope 0.574s. The 500-run regression took 4.807s, two-run cases 72/81ms, and nested-authority regression 2ms. Coverage includes configured/profile requesters, prior-run references, macOS migration warnings, revocation, nested effects, and resource cleanup.node scripts/check-changed.mjs --base 5331425e597912be4b7113a4e045d60b3b5d9170passed on Testbox, including core typechecking, all 25 test type graphs, lint, formatting, docs and applicable guards. A first check against movingorigin/mainselected unrelated reverse differences; using this lane's actual base corrected that scope.ec9c1a1) installation and standalone Doctor passed in isolated HOME/state/config/workspace on Linux Node 24.19.0. The built candidate's real Doctor flow, with current requester authority, then returned{"exitCode":0,"status":"ok"}, with no refusal or failure facts. Reconciliation preserved every record at 2 and 500 retained runs, taking 35.000s cold / 26.916s respectively (worker startup dominates; no history-proportional recursion). Runtime build passed in 83.5s; final Doctor took 131.744s. Published-state Doctor proof, leasetbx_01m39fdxcw0bqrjvfak1t7f29f.@openclaw/model-catalog-core; the final synthetic fixture used existingplugins.entries.ollama.enabled=false, preserving requester configuration and all history. Full declaration preparation also stalled aftercontext canceled; supported runtime-only builds were used for JS consumers while the separate type gates remained enabled.check:changed --base 10063393421798eae5a3dbf435109d0d01852caf -- test/gateway-external-state-ownership.e2e.test.tspassed, including the root-test type graph and all selected guards/lint. Proof, leasetbx_01m39kyjwwyzvhkgna76h8g4he.--mode branch --base origin/mainand returned scoped-clean for final head7e4d071996ad374344b4cfa6b8f47764c1a98912. All task-owned Testboxes are stopped.Production/test/docs LOC: +45/−11 production, +137/−3 tests, +15 docs. No unrelated fixture experiment remains in the diff. Hosted PR CI and its timings are pending.
Importer sweep and remaining validation gaps
The direct-importer and one-barrel lists contain 1,497 files. All groups use isolated Blacksmith Testboxes, fixed input order and source-hash assertions. Existing platform/live opt-ins remain respected.
src/flows/doctor-health.update-schema.test.tsproduced 15ENOENT realpath("\\")failures after the Windows-path fixture. The same eight-file order reproduced them on unchanged base5331425e5979. Cleanup experiments passed reused runs but failed cold validation and were removed. Remaining 205 files in that group passed.test/oauth-refresh-authority-chain.e2e.test.ts:616and:722returnedundefinedfrom shared-credential readback; both failures reproduced in the original 14-file order on the unchanged base. Preceding refresh assertions passed. The swallowed read rejection remains unidentified. The baseline also showed a requester-status failure that passed on the candidate. An optional diagnostic/native-skip attempt was blocked before execution by a two-minute provider sync timeout.src/gateway/session-transcript-readers.test.tspassed all 16 assertions but failed teardown withAgent database resource drainage failed/WorkerTaskError: worker exited with code 1. A bounded 43-file candidate/baseline comparison passed 613 tests on each, but Vitest changed scheduling relative to the larger run. That does not establish a fix or clear the original intermittent failure; synchronous fixture closure versus async drainage remains only a hypothesis.The direct E2E group also reproduced
retains ambiguous Discord announcement custody after an unidentified sendon unchanged base: candidate 108.857s, baseline 116.927s, both timing out at the compound settlement predicate (task complete, delivery ambiguous, numeric next attempt, queue row, and expected log). The fixture removes diagnostics during cleanup, so the unmet term is still unknown. The baseline was stopped after reproducing both initial failures, before redundant rendering cases; it is not reported as a completed passing run. The stale ownership assertion is the only additional test repair retained.Exact Windows-mock baseline input order (
--maxWorkers=4):Exact direct E2E baseline input order (
OPENCLAW_E2E_USE_PREBUILT_DIST=1,--maxWorkers=4):Validation used native Blacksmith Testboxes after the repository wrapper stalled in source staging. Some full declaration preparations stalled after
context canceled; JS/private-QA preparation used the existing skip-declarations and prebuilt-dist controls, with type gates run separately. Native resync also hit two-minute full-sync failures. One fresh testbox retained hydration Git metadata despite matching source bytes; the task's Git bundle corrected only HEAD/index, then the sole test diff and all source hashes were reverified before testing. No source, ignore, baseline, retry, or timeout workaround was used. Slow pre-existing files were recorded under the campaign's explicit waiver.These results do not claim the whole importer sweep or CI is green.