Repository navigation
fix(gateway): rehome stale native completion authorization - #167638
Leon-SK668 wants to merge 3 commits into
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 real behavior proof before merge. What this changesThis PR runs authorization under the existing Gateway execution owner when a completion callback inherits an aborted foreground work scope. Example: On OpenClaw 2026.10.1, a parent yields while its native Codex child waits 70 seconds and completes.
Review scores
ProductKind: Bug fix · Worth it: Needs a maintainer decision · Fix scope: Complete Merge readiness⛔ Blocked before merge - 3 items remain Keep this PR open: it addresses a demonstrated native-completion failure, but current main now passes its focused acceptance cases without the patch, and no formally linked merged fix establishes that the complete native workflow is resolved. Priority: P1 Decision needed
Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherNative child results enter the completion SDK with retained requester custody, pass through in-process Gateway authorization and turn admission, and become a new parent model input. flowchart TD
A[Native child completion] --> B[Completion custody owner]
B --> C[In-process Gateway dispatch]
C --> D[Internal agent turn facade]
D --> E[Gateway authorization]
E --> F[Turn admission]
F --> G[Parent successor turn]
Technical reviewBest possible solution: Preserve current main’s worker-backed authorization and cleanup, and retain a production scope repair only for a demonstrated remaining native-completion failure. Do we have a high-confidence way to reproduce the issue? The historical failure has a concrete owned-source reproduction and an installed-release report, but no high-confidence current-main reproduction remains: the contributor reports the focused cases passing without this patch, consistent with the inspected worker-backed authorization path. Is this the best way to solve the issue? The historical hunk repairs preparation through the existing Gateway work owner without creating another authorization policy; carrying it onto current main requires evidence that the native path still fails. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 5a290d637963. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +8, Tests +69. Total +77 across 2 files. Added test files: 0. 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. LabelsLabel changes: No label changes. Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (4 earlier review cycles)
Reviewed October 13, 2026, 7:50 AM ET / 11:50 UTC (Revision 5). |
|
Reproduced the completed-child / yielded-parent symptom with OpenClaw and the official Codex plugin both on 2026.10.1. The parent spawned one native Codex child and called Subscription authentication and ordinary foreground replies worked. Channel access and outbound delivery also worked; a manually recovered answer was delivered and independently verified. This rules out an archived thread, exhausted subscription quota, or a general channel-send failure for this reproduction. Native children now use the Codex harness's binding/assignment/result receipts rather than the retired Tasks view. Old The completed result was preserved and recovered without repeating the research or other completed actions. Automatic parent wake remains the unresolved behavior. The failure matches #167410: the completion's pre-dispatch authorization inherits a drained foreground Verification of the proposed executable hunk on the installed 2026.10.1 core:
This is an actual model/native-runtime spawn → yield → successor verification, with external delivery and the message tool disabled. It does not claim an automatic external-channel test or fixes for other stale-scope consumers or previously interrupted inputs. Independent reviews found no blocking correctness/security issue in this hunk. |
|
Heads-up: once this lands (or main otherwise stops aborting the stale-scope path), native child results the parent already consumed in the foreground will still be redelivered and wake the parent again, so users would get duplicate answers. On our 2026.10.1 install this affects 30 of 31 delegated children; today the abort hides it. That needs receipt matching fixed first or alongside, details: #149490 (comment) |
|
Withdrawing this proposal after rechecking its necessity against current main. Unpatched main A complete current-main native spawn -> yield -> successor replay is still missing. The October 13 duplicate-result report also needs separate verification before extending this repair. I am stopping further integration and proof expenditure on this production hunk until a remaining failure can be demonstrated. This withdrawal does not establish that the full native-completion workflow is fixed. Issue #167410 remains open, and the contribution branch and historical evidence are preserved for a future evidence-backed repair. No branch deletion or history rewrite is involved. |
Closes #167410
October 13 maintenance status: current-main acceptance gap requires revalidation
The original regression is no longer red on current main
0cbcfbe8721360edcfbf9412e29bdbb9c1454255. During conflict triage, the contributor temporarily used that main's exact production facade, without this PR's production patch, and ran the three real authorization/projection cases introduced here. All three passed (39 other cases skipped, exit 0). Measured wall time: 123.83 seconds; wrapper: 122.72 seconds; Vitest: 113.98 seconds. Local log SHA-256:42df424325b4564ad6ba136d3acd8d819dbe73d09d29b1b2afc2af66f0c80802.That result invalidates a current-main acceptance-red claim for this test seam. Main has meanwhile moved session reads and authority into workers in #169622, and added pre-dispatch custody cleanup in #170855. The contributor is holding further patch publication pending a current-main native spawn/yield replay that demonstrates a remaining gap. No claim is made that the full native behavior is already fixed, or that these focused cases replace the missing native trace. Contributor head remains
d17eeb73bdffba8da20ffe329481385feac1ff75; the conflict integration was not published. Historical before/after evidence below remains explicitly tied to its older baseline.What Problem This Solves
Native Codex completion callbacks can re-enter the Gateway after the originating foreground run has closed. The retained completion still has valid custody, but the in-process
agentdispatch performs its authorization projection under the already-aborted callerAsyncWorkScope; the parent continuation is rejected before it can start.This restores parent continuation for that stale-scope path while keeping the existing authorization, revocation, admission, and request-entry checks intact.
Why This Change Was Made
createInternalAgentTurnFacadeis the owner of in-process agent dispatch. Its caller isdispatchGatewayMethodInProcess, and its authorization callee reads the session-row placement projection. The existingGatewayRequestContext.trackExecutionalready owns the live Gateway execution scope. When the ambient signal is aborted, this change runs only the pre-dispatch authorization through that owner before projection reads; ordinary requests retain the existing single execution entry.The implementation reuses the existing Gateway work owner rather than adding a new scope, bypassing authorization, or adding a Codex-specific fallback. The Codex protocol contract remains unchanged: the app-server emits a terminal turn completion notification, and OpenClaw continues to use its existing retained completion custody and agent dispatch path.
User Impact
Users whose native Codex child completes after its parent foreground run yields can resume the parent session instead of receiving an aborted-scope admission error. Normal Gateway agent requests and cancellation/revocation behavior are unchanged.
Evidence
Independent native-runtime reproduction and repaired readback — October 11, 2026
Independent public verification by jeanmonet reports the failure and a successful model/native-runtime replay. This is the verifier's reported execution, not a contributor-run replay or an independently downloaded trace artifact.
2026.10.1.sessions_yield; the child completed normally and saved its result, but the parent transcript remained at the yielded tool result, with no successor model turn. Ordinary foreground authentication/replies and separately tested channel delivery worked.AsyncWorkScope. The original failed withAbortError; the candidate passed the stale-scope authorization preflight. Ordinary live-scope dispatch, permission denial, explicit cancellation before/during authorization, context revocation, closed request entry, and closed Gateway-owner rejection remained intact. This comparison used boundary stubs and stopped at validation; it is separate from the native-runtime replay below.3efeb8dc52f1a4d5be50de00511eefbe5dda9285on that installed core, warmed the shared native connection with a completed foreground turn, then used a separate isolated parent to spawn a child with a 70-second wait and immediately yield.sourceTool: agent_harness_completion; the parent committed the expected final answer and reacheddone. No queued input remained; the assignment was removed from its active binding; no announce failure or retry exhaustion was observed.Scope and limits: this verifies the proposed production hunk in a real spawn → yield → successor path on installed
2026.10.1, with external delivery and the message tool disabled. It does not establish a complete PR-branch build, automatic external-channel delivery, recovery of previously interrupted inputs, or other stale-scope consumers. Session IDs, raw.jsonltraces and downloaded proof artifacts were not included in the public report, so none are invented here. The public report is the available provenance for these observations.Contributor source and focused validation
60f703...: the current-main path fails after native Codex completion because the stale signal is observed during session authorization.src/gateway/agent-turn/internal-facade.ts→authorizeGatewayRequestPreDispatch→ session-row placement projection. Earlier maindcbceeb0cae158494469b6946608ea932ec46a2estill invoked authorization directly. The newer current-main comparison above passes without the production patch, so the older call ordering alone is not evidence of a remaining defect.src/gateway/server-plugin-in-process-dispatch.authorization.test.ts. They bind and materialize a real SQLite-backed session-row projection, drain the foreground work, then dispatch under a live Gateway owner through the actual authorization and preflight paths. The allowed case is accepted; missingoperator.writeand explicit cancellation remain rejected. Only final model execution is mocked. This proves the authorization/projection regression, not a native model spawn/yield replay.codex-rs/core/src/agent/control.rssubscribes to child status;codex-rs/core/src/agent/status.rsmapsTurnCompletetoCompleted;codex-rs/app-server/src/bespoke_event_handling.rsemitsTurnCompletedNotification. No dependency protocol change is needed.trackExecutionseam is the appropriate owner.Passed during the October 9 implementation at contributor head
3efeb8dc52f1a4d5be50de00511eefbe5dda9285:October 13 exact-head regression receipt
Contributor head:
d17eeb73bdffba8da20ffe329481385feac1ff75; tree:de3c8bb05c089094977550e5182448f12bee0e1c. The production hunk is byte-identical to3efeb8dc52f1a4d5be50de00511eefbe5dda9285. Commit7e4fd468472a6aff6f91e927cf185ddabf211d9breplaced the mocked test with the real authorization/projection cases above; the final test-only follow-up explicitly publishes the fixture's runtime config before writing its session, matching current main's prepared-config contract.Paired acceptance command:
70c839ac6bc812bf930ee7cc06a6895117c09d9c, keeping the new tests identical. The allowed handoff fails withAbortError; the denied and canceled cases pass. Result: 1 failed, 2 passed, 36 skipped, exit 1. Measured wall time 103.51 seconds; wrapper 102.63 seconds.7e4fd468472a6aff6f91e927cf185ddabf211d9b: the same command passed 3 tests, skipped 36, exit 0. Measured wall time 44.47 seconds; wrapper 43.69 seconds. The unfixed production source was fully restored to the candidate before commit.node scripts/run-vitest.mjs src/gateway/server-plugin-in-process-dispatch.authorization.test.ts src/gateway/agent-turn/internal-facade.test.ts --maxWorkers=1passed all 61 tests in 2 files, exit 0, both before the first test commit and after the explicit runtime-config fixture correction. The final run used the exact source bytes committed atd17eeb73bdffba8da20ffe329481385feac1ff75, with wrapper duration 74.34 seconds and Vitest duration 67.16 seconds; no separate wall measurement was captured for that final run. The earlier run measured wall time 149.15 seconds and wrapper duration 148.20 seconds.oxfmt --check --threads=1, focusednode scripts/run-oxlint.mjs --openclaw-focused-config, andgit diff --check.Local log integrity (SHA-256; logs are retained locally, not represented as downloadable public artifacts):
Production LOC: +15 / -7. Test LOC: +69 / -0. Files changed: 2. The former facade test has no net change against the PR base. Production growth selects the existing work owner before asynchronous authorization; it adds no second authorization policy or runtime fallback.
CI maintenance: CI run 38363611143, failed shard 115183957123 checked head
7e4fd468472a6aff6f91e927cf185ddabf211d9bmerged into14c5ff2371a0095fe5cfd9976c294b01ffa008ef. All three new cases stopped during fixture session creation withRuntime config is not prepared, before testing dispatch. Current main now requires a prepared runtime snapshot; the final follow-up initializes that snapshot before the write. The local final run passes, and new-head CI is being checked separately. No required-CI-green claim is made here.Current limits: no fresh independent code review is claimed. The independent installed-runtime report above concerns the identical production hunk, but inspectable native after-fix logs or traces are still missing. These focused tests are not substituted for that native behavior artifact. The available Crabbox CLI is installed, but the broker preflight returns
whoami requires a configured coordinator; no remote lease or full native replay has been run during this maintenance.Compatibility and risk
This is an internal Gateway execution-scope repair. It does not add configuration, alter public protocol shapes, change persisted data, or loosen authorization. If the Gateway owner is unavailable,
trackExecutionstill fails closed; the patch does not bypass lifecycle admission. The changed preflight scope and ordinary dispatch/cancellation guards have focused coverage, while the independent native-runtime replay verifies the repaired continuation path within the limits stated above.AI disclosure
This PR was prepared and maintained with AI assistance. The contributor inspected the source ownership path, dependency protocol, patch, validation results and the linked independent public verification. No credentials, private session data, or undisclosed live-provider execution are included.