Repository navigation
refactor(sessions): stop chat work by a recorded cause, not by a changed id - #200326
Merged
Merged
Conversation
Contributor
|
🦞👀 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. |
Contributor
|
Codex review: stale review; fresh review needed. Summary Next step Review history (1 earlier review cycle)
|
…ged id Typed Stop no longer compares the sender's leaf or session id. It stops the chat's work as it is when the Gateway receives it; work that starts after the Stop is not captured and is not cancelled. A send retained during a plugin reload is addressed by its chat key. Reset and delete stop it through their shared runtime cleanup with the cause "reset" or "deleted", so the replay no longer compares the target's lifecycle revision or transcript id. Co-authored-by: obviyus <[email protected]>
…t keep them Co-authored-by: obviyus <[email protected]>
… a microtask race Co-authored-by: obviyus <[email protected]>
obviyus
force-pushed
the
obviyus/identity-stop-cause
branch
from
November 17, 2026 02:02
c28f7cc to
fb1d0cd
Compare
Collaborator
Author
|
Landed as 307e88c.
|
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Nov 17, 2026
…ged id (openclaw#200326) ## What Problem This Solves Work was stopped by inference. Two checks compared ids that change on their own and treated a change as a stop: - **Typed Stop refused.** A `chat.send` "/stop" (queue mode other than steer) had to see the same session id and, with an empty view, an empty transcript. A client that had not loaded history yet sent "/stop" during a running turn: the Gateway answered "active branch changed; review and retry" and the turn kept running. - **Retained send fenced by revision.** A `sessions_send` held during a plugin reload replayed with the target's lifecycle revision and transcript id pinned. A reset was caught only because it rotates the revision ("Target session lifecycle changed before retained send."). A compaction successor of the target changed the transcript id, so the replay was refused even though the chat was the same. ## Why This Change Was Made A stop is a recorded act with a cause, on the existing stop paths. No new service. - **Typed Stop** stops the chat's work as it is when the Gateway receives it. Deleted: the `stop` branch of `assertExpectedLeafActive`, `assertExpectedLeafActiveAsync`, and the `beforeAbort` hook in the chat abort runtime. Work that starts after the Stop is not captured, so it is not cancelled. - **Retained sends** are addressed by chat key. Reset and delete stop them in their shared runtime cleanup (`clearSessionResetRuntimeState`) with the cause `reset` or `deleted`. The replay reports `{ status: "not_delivered", stopCause }`. Deleted: the lifecycle-revision compare and its option, the replay's transcript-id pin, and the "refused target incarnation" check. Retained sends are held through `WeakRef`, so a handoff that never replays does not keep them. - `config/session-identity-allowlist.txt`: 6587 → 6584 pins on current `main`. Accepted edge: a reset that lands after the replay has started does not stop that replay. A started request may finish, as before. Production code (`src`, `extensions`, without tests): +73 / −127. ## User Impact - A typed "/stop" stops the running turn even if the client's view is empty or behind. - A Stop does not cancel a turn, a replacement chat or a child started after it. - A reset or delete of the target stops a held send, with the cause in the result. - A held send to a compacted target is no longer refused for the new transcript id. ## Evidence Base = merge base `7683f1bdbebd`, head = this PR. | Journey | Tier | Base | Head | |---|---|---|---| | Turn 1 runs a 45 s foreground exec; client sends `chat.send` "/stop" with `expectedLeafEntryId: null`, queue mode followup; then sends turn 2 at once | `ocx src` scratch Gateway, real Claude model | Stop refused (`active-leaf-changed`); turn 1 not stopped | Stop ok, turn 1 `aborted`; turn 2 (started after the Stop) `final` with the expected reply | | Caller holds a reloading plugin, sends to its child (held), child is reset before replay | real Gateway, real plugin reload, scripted model (scratch variant of `server.plugin-reload-send-continuation.product.test.ts`) | `error`: "Target session lifecycle changed before retained send."; child got 0 sends | `not_delivered`, `stopCause: "reset"`; child got 0 sends | Tests: - `chat.stop-cascade.test.ts`: a Stop with a stale leaf and another session id stops the chat's work; after a parent replacement or branch, the original child is cancelled and the successor's runs and child are not. - `sessions-send-self-hold.test.ts`: a reset of the target settles the held send once with `stopCause: "reset"` and never replays it. - `server.plugin-reload-send-continuation.product.test.ts` (resume, followup, failed reload) passes on head. - `server-worker-placement-cancel.test.ts` revoked worker Stop authority in a microtask after the first check and relied on an await that this change removes. It now revokes before the effect's own check. `server.plugin-reload-send-revocation.product.test.ts` times out the same way on base and head locally. Gates: oxfmt, oxlint, `pnpm tsgo:core`, `pnpm check:test-types`, import-cycle checks, `check:session-identity-ratchet`, and `ocx test` on the Stop, abort, chat-send, self-hold and reset-cleanup suites. Local review: complete, no findings. Co-authored-by: Ayaan Zaidi <[email protected]>
RomneyDa
added a commit
that referenced
this pull request
Nov 18, 2026
Backport #200326 from 307e88c. Typed Stop cancels captured current work despite stale or empty sender history while preserving live authority and successor isolation. Reset/delete explicitly settle matching retained sends as not_delivered with their cause. Remove obsolete incarnation fences without changing the logical task/run/source guards. Accepted edge: reset after replay starts does not retract an already started request; existing cancellation owns it. Proof: five Stop plus four retained-send baseline failures, 67 owner and 146 worker sibling tests, and 105 assembled parent tests passed. Parent reviewed the complete change; one missing-braces lint finding repaired without behavior change. Worker live reload probe has an unclassified baseline gap; no live-model success claimed. Publication held. Co-authored-by: RomneyDa <[email protected]>
scribe-dandelion-cult
added a commit
to karmaterminal/openclaw
that referenced
this pull request
Nov 19, 2026
…stage 2) Catches the pure continuation candidate bc7e568 up to openclaw/openclaw main 41bdde2 (fetched 2026-11-19T14:32:59Z), 2,996 upstream commits past the old merge base 401a1de. Merge commit only; rerere disabled, so every resolution was made here. 80 conflicted paths (77 content, 3 modify/delete), each recorded with base, ours and theirs blobs and its reason in the lane's stage2-conflicts.md: - 8 take upstream whole: the openclaw#197153 pg16-smoke cherry-pick (6909b64) now ships upstream (ci.yml, ci-build-manifest, ci-workflow-planning test), the Control UI settings child moved onto runDistArtifactChild, the canary worker target and two active-facts migration tests. - 3 deleted with upstream: session-fork and update-candidate-canary suites whose production paths upstream removed; cwd-split folded away (openclaw#198916), its one continuation case rehomed to attempt.continuation-tools.test.ts. - One-owner cutovers where upstream now owns a fork extraction: the requester-origin projection and replacement-text helpers (openclaw#200533) replace the fork's byte-identical copies in user-turn-transcript.metadata.ts. - Ports into fork-extracted owners: removalReason in the queued-start plan and collector-group sweep (openclaw#199868), the async prepared-pricing usage diagnostic, the announce flow types, and the session-delivery codec, which gains upstream's mediaCandidate kind, reviewedTaskId and their schemas (openclaw#198227), importing its retention type from the leaf types module. - Transcript repair (openclaw#201304, post-b894): upstream's payload-free adapter kernel carries the fork's continue_delegate attachment redaction through a payload-adapter-only fact and a withBlock update. - Reset cleanup: upstream's process and retained-send stops (openclaw#199079, openclaw#200326) with the fork's continuation-aware reason as the single input; the chat reset's retention adapter wraps upstream's stopSessionResetWork, the Gateway preemption keeps stopSessionResetSubagents as upstream does. - Schema: upstream owns agent 42 (tool usage) and 43 (pending-input endings) and is at 43; 44 is unused upstream. Continuation's recipient authority moves 42 -> 44: version constants, step order, historical schemas, witness additive table and version set, backup scope, PostgreSQL ladder (V43 = current minus the authority table) and port descriptor. package.json schemaVersions state 40, agent 44. - Generated outputs regenerated, never hand-merged: config baseline, gateway validators, postgres schema catalogs, worker-access inventory. - Compile follow-through for upstream's delivery-union narrowing and its readSessionDelivery callers. Refs openclaw#129388
RomneyDa
added a commit
that referenced
this pull request
Nov 19, 2026
…ged id (#200326) Work was stopped by inference. Two checks compared ids that change on their own and treated a change as a stop: - **Typed Stop refused.** A `chat.send` "/stop" (queue mode other than steer) had to see the same session id and, with an empty view, an empty transcript. A client that had not loaded history yet sent "/stop" during a running turn: the Gateway answered "active branch changed; review and retry" and the turn kept running. - **Retained send fenced by revision.** A `sessions_send` held during a plugin reload replayed with the target's lifecycle revision and transcript id pinned. A reset was caught only because it rotates the revision ("Target session lifecycle changed before retained send."). A compaction successor of the target changed the transcript id, so the replay was refused even though the chat was the same. A stop is a recorded act with a cause, on the existing stop paths. No new service. - **Typed Stop** stops the chat's work as it is when the Gateway receives it. Deleted: the `stop` branch of `assertExpectedLeafActive`, `assertExpectedLeafActiveAsync`, and the `beforeAbort` hook in the chat abort runtime. Work that starts after the Stop is not captured, so it is not cancelled. - **Retained sends** are addressed by chat key. Reset and delete stop them in their shared runtime cleanup (`clearSessionResetRuntimeState`) with the cause `reset` or `deleted`. The replay reports `{ status: "not_delivered", stopCause }`. Deleted: the lifecycle-revision compare and its option, the replay's transcript-id pin, and the "refused target incarnation" check. Retained sends are held through `WeakRef`, so a handoff that never replays does not keep them. - `config/session-identity-allowlist.txt`: 6587 → 6584 pins on current `main`. Accepted edge: a reset that lands after the replay has started does not stop that replay. A started request may finish, as before. Production code (`src`, `extensions`, without tests): +73 / −127. - A typed "/stop" stops the running turn even if the client's view is empty or behind. - A Stop does not cancel a turn, a replacement chat or a child started after it. - A reset or delete of the target stops a held send, with the cause in the result. - A held send to a compacted target is no longer refused for the new transcript id. Base = merge base `726a8dd49857`, head = this PR. | Journey | Tier | Base | Head | |---|---|---|---| | Turn 1 runs a 45 s foreground exec; client sends `chat.send` "/stop" with `expectedLeafEntryId: null`, queue mode followup; then sends turn 2 at once | `ocx src` scratch Gateway, real Claude model | Stop refused (`active-leaf-changed`); turn 1 not stopped | Stop ok, turn 1 `aborted`; turn 2 (started after the Stop) `final` with the expected reply | | Caller holds a reloading plugin, sends to its child (held), child is reset before replay | real Gateway, real plugin reload, scripted model (scratch variant of `server.plugin-reload-send-continuation.product.test.ts`) | `error`: "Target session lifecycle changed before retained send."; child got 0 sends | `not_delivered`, `stopCause: "reset"`; child got 0 sends | Tests: - `chat.stop-cascade.test.ts`: a Stop with a stale leaf and another session id stops the chat's work; after a parent replacement or branch, the original child is cancelled and the successor's runs and child are not. - `sessions-send-self-hold.test.ts`: a reset of the target settles the held send once with `stopCause: "reset"` and never replays it. - `server.plugin-reload-send-continuation.product.test.ts` (resume, followup, failed reload) passes on head. - `server-worker-placement-cancel.test.ts` revoked worker Stop authority in a microtask after the first check and relied on an await that this change removes. It now revokes before the effect's own check. `server.plugin-reload-send-revocation.product.test.ts` times out the same way on base and head locally. Gates: oxfmt, oxlint, `pnpm tsgo:core`, `pnpm check:test-types`, import-cycle checks, `check:session-identity-ratchet`, and `ocx test` on the Stop, abort, chat-send, self-hold and reset-cleanup suites. Local review: complete, no findings. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 307e88c) Release adaptation: Retain baseline task-run and branch-navigation admission guards; remove only obsolete Stop leaf recheck and retained transcript identity. Keep deleted identity allowlist deleted.: Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 853a66f5867f4d940ecdc71f0f14f838f0ab473e)
RomneyDa
added a commit
that referenced
this pull request
Nov 19, 2026
Release adaptation: combine #200191 and #200326 using canonical307e88 hadTask/expectTargetTask replay admission, retaining explicit reset/delete stop settlement. Independent source review and 26 focused tests pass; targeted type-aware lint and formatting pass. Co-authored-by: RomneyDa <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
Work was stopped by inference. Two checks compared ids that change on their own and treated a change as a stop:
chat.send"/stop" (queue mode other than steer) had to see the same session id and, with an empty view, an empty transcript. A client that had not loaded history yet sent "/stop" during a running turn: the Gateway answered "active branch changed; review and retry" and the turn kept running.sessions_sendheld during a plugin reload replayed with the target's lifecycle revision and transcript id pinned. A reset was caught only because it rotates the revision ("Target session lifecycle changed before retained send."). A compaction successor of the target changed the transcript id, so the replay was refused even though the chat was the same.Why This Change Was Made
A stop is a recorded act with a cause, on the existing stop paths. No new service.
stopbranch ofassertExpectedLeafActive,assertExpectedLeafActiveAsync, and thebeforeAborthook in the chat abort runtime. Work that starts after the Stop is not captured, so it is not cancelled.clearSessionResetRuntimeState) with the causeresetordeleted. The replay reports{ status: "not_delivered", stopCause }. Deleted: the lifecycle-revision compare and its option, the replay's transcript-id pin, and the "refused target incarnation" check. Retained sends are held throughWeakRef, so a handoff that never replays does not keep them.config/session-identity-allowlist.txt: 6587 → 6584 pins on currentmain.Accepted edge: a reset that lands after the replay has started does not stop that replay. A started request may finish, as before.
Production code (
src,extensions, without tests): +73 / −127.User Impact
Evidence
Base = merge base
726a8dd49857, head = this PR.chat.send"/stop" withexpectedLeafEntryId: null, queue mode followup; then sends turn 2 at onceocx srcscratch Gateway, real Claude modelactive-leaf-changed); turn 1 not stoppedaborted; turn 2 (started after the Stop)finalwith the expected replyserver.plugin-reload-send-continuation.product.test.ts)error: "Target session lifecycle changed before retained send."; child got 0 sendsnot_delivered,stopCause: "reset"; child got 0 sendsTests:
chat.stop-cascade.test.ts: a Stop with a stale leaf and another session id stops the chat's work; after a parent replacement or branch, the original child is cancelled and the successor's runs and child are not.sessions-send-self-hold.test.ts: a reset of the target settles the held send once withstopCause: "reset"and never replays it.server.plugin-reload-send-continuation.product.test.ts(resume, followup, failed reload) passes on head.server-worker-placement-cancel.test.tsrevoked worker Stop authority in a microtask after the first check and relied on an await that this change removes. It now revokes before the effect's own check.server.plugin-reload-send-revocation.product.test.tstimes out the same way on base and head locally.Gates: oxfmt, oxlint,
pnpm tsgo:core,pnpm check:test-types, import-cycle checks,check:session-identity-ratchet, andocx teston the Stop, abort, chat-send, self-hold and reset-cleanup suites. Local review: complete, no findings.