Skip to content

fix(agents): cancel native descendants on session stop - #169700

Merged
vincentkoc merged 10 commits into
mainfrom
fix/shellbench-native-cancel-upstream-20261012
Oct 12, 2026
Merged

vincentkoc merged 10 commits into
mainfrom
fix/shellbench-native-cancel-upstream-20261012

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Stopping a session can leave native Codex descendants running or lose confirmed cancellation results when another child fails. A failed durable acknowledgment can also consume a cancellation delivery too early.

User Impact

Session stop and reset cancel the descendants they own, wait for settlement, and preserve completed output and children outside the selected scope. Partial failures retain confirmed child results. Failed cancellation acknowledgments remain retryable after reopening SQLite.

Why This Change Was Made

Carry the existing cancellation authority and session generation through the Gateway, harness host, and native-child lifecycle. The same owners handle active children, pending admissions, late registrations, and durable completion acknowledgment.

The upstream integrations preserve current child-agent/session-entry ownership and parent write authority. The submission-store adapter now lives with its existing assignment-store owner; queued compaction keeps the existing policy-change refusal and its no-client/no-RPC assertions.

Evidence

Current pushed revision: 661d2798b9455a9bcb5cef0108b30c92654d99bd.

  • R18 passed 38 focused tests: the full chat-abort cascade suite (20 tests, 83.738 s), child-owner matching (14 tests, 4.275 s), and four registered current-owner/raw-replacement cases (54.807 s).
  • Current core types, Gateway test types, touched lint and formatting passed. All 14 setup/check commands exited 0; source inventory stayed unchanged and formatting produced no patch. The archive, digest and index have verified S3 readback.
  • Unaffected R17 proof on parent 83a583b64ccaeeb6cf49b7827159747f94b08c51 passed two compaction/parent-authority cases (73.084 s), three submission-store lifecycle/refusal cases (58.203 s), extension types, Codex test types, touched lint and formatting. These checks were not rerun for the final two-file ownership integration.

Earlier evidence remains attributed to its original revision:

  • R15 on 72d1c7eeae9cd643a2d1f8823b3c1502b06eb7f6 passed nine static checks, including zero runtime/Madge cycles and the 3,699-export SDK surface.
  • R14 on 0103b35733deefc74de97a716a608b970ece78b4 passed 25 host-capability tests in 49.25 s and 80 registered Gateway tests in 171.04 s.
  • R13 retains two SQLite acknowledgment regressions failing on pre-fix owners and passing on repaired owners.
  • R16's compact expectation and max-lines failures were repaired and proved by R17. Its inherited update-migration type failure remains historical; the later main integration changed that owner, and R18's current core-type check passed. The old 72d1 hosted catalog-fixture failure is also historical and supplies no current-head exception.

Natural hosted run 38273271552 attempt 1 failed the Codex registration-import test and its CI aggregate. The eager session-binding SDK import reaches live session/config diagnostics. All 29 implicated and assertion/resolution source inputs equal the actual tested main parent 6fa67453cd0caaf3b794a55d47bc512cc8829a15 in tested merge d16c3efc9fd068c5bc9d0e1007c99e604bf57f09. This establishes inherited source attribution; no failing or passing execution on main is claimed. The native inherited-failure exception remains subject to its security, review and writer-authority checks.

A separate campaign smoke recorded three passing and seven failing cases. Its offline path used a retained custom package, while its online path installed registry packages; it does not qualify the retained candidate or execute this PR revision. The failure evidence has verified S3 readback. Campaign runtime qualification remains pending installation, admission and settlement repairs.

No full repository suite or current hosted-green result is claimed. Independent source reviews covered the full change and both conflict resolutions.

@vincentkoc vincentkoc self-assigned this Oct 12, 2026
@clawsweeper

clawsweeper Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling extensions: codex size: XL labels Oct 12, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 12, 2026
@clawsweeper

clawsweeper Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR connects session Stop to native Codex descendant cancellation and preserves confirmed results through partial failures and durable acknowledgment.

Example: Stop agent:main:native-stop after parent-run yields to child-turn.

  • Before: The native child can continue running after its parent stops.
  • After: Stop interrupts the selected child, waits for terminal settlement, and preserves unrelated children and successful results.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) Useful owner-based repair with no concrete source finding, but authority and existing-state qualification remain incomplete.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Stopping a session can leave native descendants running or lose confirmed cancellation outcomes when another child fails.
Reason: Reliable Stop has clear user value, and this maintainer-authored PR establishes approval of the supporting harness-contract direction.

Merge readiness

⛔ Blocked before merge - 5 items remain

Keep this maintainer-authored PR open: it addresses a distinct cancellation gap, and review found no concrete introduced defect.

Priority: P2
Reviewed head: 661d2798b9455a9bcb5cef0108b30c92654d99bd

Before merge

  • Add real behavior proof - Authority-chain proof required: provide redacted Gateway and real native-client output showing selected descendants reach terminal settlement, foreign requesters cause no interrupt I/O, and revocation or reassignment during awaited retry prevents the next write. The inspected owner/client tests use simulated native transport; the historical screenshots cover completed-child command cleanup. Redact API keys, IPs, phone numbers, and non-public endpoints. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve security review attention item - Source guards are present, but retained cancellation authority still needs final-effect qualification.
  • Resolve merge risk - Retained request custody now governs native interruption after foreground completion; isolation from foreign requesters and invalidation after revocation or reassignment remain unqualified at the final effect.
  • Complete next step - Classify the failing exact-head Codex registration-import check against the base, repairing a PR-caused failure or recording matching inherited-failure evidence.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

None.

Tests

  • Missing end-to-end proof: Missing production-path native cancellation and final-effect authorization evidence; supplied base-failing acknowledgment regressions do not establish a v2026.10.2 upgrade.
Agent review details

How this fits together

Gateway Stop handlers authorize and capture the selected request, harness owners reserve its native descendants, and the Codex client interrupts exact turns before existing SQLite owners acknowledge cancellation.

flowchart TD
  A[Session Stop] --> B[Gateway authorization]
  B --> C[Captured request custody]
  C --> D[Harness cancellation owner]
  D --> E[Codex native descendants]
  E --> F[Terminal settlement]
  F --> G[SQLite acknowledgment]
Loading

Technical review

Best possible solution:

Land the existing owner-based cancellation path after authority, durable recovery, and CI qualification are complete.

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

Current-main source exposes the missing harness cancellation path, and the supplied regression cases exercise native settlement and acknowledgment failures; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch extends existing Gateway, harness, native lifecycle, and SQLite owners rather than adding a competing cancellation mechanism; inspection found no discrete introduced bug.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 96496dc78274.

Merge-risk options

Maintainer options:

  1. Hold for authority qualification (recommended)
    Keep this PR open until the allowed and nearest-forbidden requester scenarios are demonstrated through native interruption, including revocation or reassignment before retry I/O.

Provenance checked

  • Gateway request and descendant cancellation keeps the original intent (f61b347: Capture original request ownership, drain descendant commands, preserve later human work, and report incomplete cleanup truthfully.)
  • Native assignment and submission recovery keeps the original intent (41784ac: Preserve accepted native follow-ups and earlier results through parent rotation, cleanup, and restart recovery.)
  • Completion custody after parent yield keeps the original intent (4875b96: Retain authority for accepted child completion while refusing revoked or replaced requesters.)
  • Parent session write authority keeps the original intent (bc60cd9: Prepare session facts in workers and retain existing writer validation at effects.)

Testing

Proof path: in-process harness.

Security

Needs attention: Source guards are present, but retained cancellation authority still needs final-effect qualification.

Evidence

What I checked:

Likely related people:

  • Shakker: Raw commit f61b347 adds src/gateway/server-methods/chat-abort-descendants.ts:39 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: f61b347ee408; files: src/gateway/server-methods/chat-abort-descendants.ts)

PR surface

Source +1007, Tests +1164, Docs +10. Total +2181 across 36 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 28 1158 151 +1007
Tests 7 1281 117 +1164
Docs 1 11 1 +10
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 36 2450 269 +2181

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Repairs a bounded session Stop and native-descendant lifecycle failure.
  • merge-risk: 🚨 compatibility: Adds an optional plugin-facing harness cancellation contract and changes durable cancellation acknowledgment; maintainer authorship establishes direction.
  • merge-risk: 🚨 security-boundary: Captured requester custody authorizes native interruption across foreground lifetimes, requiring final-effect isolation and revocation qualification.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

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

  • Add final-effect evidence for allowed and forbidden requesters, including revocation or reassignment before retry I/O.
  • Demonstrate upgrading v2026.10.2 with pending assignments and receipts preserved, followed by failed-acknowledgment recovery after SQLite reopen.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (8 earlier review cycles)
  • reviewed 2026-10-12T07:13:18.089Z sha fdd0f7a :: needs real behavior proof before merge. :: [P2] Consume cancelled durable assignments before unregistering the child | [P2] Retain confirmed cancellations when another native child fails
  • reviewed 2026-10-12T10:44:07.118Z sha afa719e :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-12T11:47:24.197Z sha 0103b35 :: needs real behavior proof before merge. :: [P2] [P2] Reconcile the new exports with the SDK surface budget
  • reviewed 2026-10-12T12:45:27.210Z sha 72d1c7e :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-12T12:54:17.225Z sha 72d1c7e :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-12T13:07:47.026Z sha 72d1c7e :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-12T15:12:25.033Z sha 83a583b :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-12T15:36:42.820Z sha 83a583b :: needs real behavior proof before merge. :: none

Reviewed October 12, 2026, 12:13 PM ET / 16:13 UTC (Revision 9).

@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. label Oct 12, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review October 12, 2026 11:39
@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 661d2798b9455a9bcb5cef0108b30c92654d99bd
  • Maintainer: @vincentkoc
  • Repository role: admin

These security sensitive changes were made:

  • src/gateway/server-methods/chat-abort-authorization.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@vincentkoc
vincentkoc enabled auto-merge (squash) October 12, 2026 11:40
@vincentkoc
vincentkoc disabled auto-merge October 12, 2026 12:10
@openclaw-barnacle openclaw-barnacle Bot reopened this Oct 12, 2026
@vincentkoc
vincentkoc merged commit d4820c4 into main Oct 12, 2026
142 of 145 checks passed
@vincentkoc
vincentkoc deleted the fix/shellbench-native-cancel-upstream-20261012 branch October 12, 2026 16:28
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
* fix(agents): cancel native descendants on session stop

* refactor(gateway): keep session abort origin with authorization

* fix(agents): retain partial cancellation and durable acknowledgement

* test(codex): admit follow-up custody before cancellation

* fix(codex): keep cancellation types within existing contracts

* fix(codex): preserve checks after session authority integration
RomneyDa pushed a commit that referenced this pull request Oct 26, 2026
…79050)

* fix(codex): retire completed grandchildren without restart replay

* test(codex): align native assignment acknowledgement expectation

Release adaptation: stable has no Stop-driven descendant cancellation (#169700 is main-only), so the inventory gains the generic acknowledge() owner directly instead of renaming settleCancelled, and the main-only cancellationRequested guard and withDescendantCancellation hunks were dropped. The monitor keeps its stable thread-status-revision readHistory wrapper. Tests use client.notify with existing notification builders instead of the main-only client.item/completeTurn helpers and drop listPendingChildren probes.

(cherry picked from commit b189a9f)
RomneyDa pushed a commit that referenced this pull request Oct 26, 2026
fix(codex): release the parent pin when an interrupted Codex child loses custody

When a native Codex child run was genuinely interrupted, it could keep its claim on the parent's execution pin after it no longer held executable custody. A later legitimate cold resume of the parent was then refused as already claimed. The pin is now released once the child has really lost custody; a child that still owns its work keeps it.

Evidence: built Gateway with the real Codex app-server and a real OpenAI provider run, child interrupted through a public RPC. On main the parent's cold resume with changed instructions was refused (twice); with this change the original parent resumes and replies with its full assignment unchanged (twice). Runs without a child behave as before.

Thanks @wtfichigo.

Co-authored-by: Ayaan Zaidi <[email protected]>

Release adaptation: the stable child-unregister path keeps its thread-status revision collection. The main-only cancellation test file (descendant Stop, #169700) was not added; the shared custody fixture extraction is kept for the custody suite. New direct-authority and parent-retention cases use the stable lifecycle-timing options object and assignment-store factory signature.

(cherry picked from commit 42d4156)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation extensions: codex gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. security-sensitive-changed size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant