Repository navigation
fix(gateway): finish successful sessions after timestamp races - #119752
Conversation
4d2f01c to
040e26f
Compare
|
@clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Codex review: stale review; fresh review needed. Summary Next step Review history (1 earlier review cycle)
|
f40a7a0 to
b18fe21
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
…law#119752) * fix(gateway): correlate session lifecycle by run * test(qa): expect settled handoffs to survive restart quietly * test(agents): split embedded run persistence coverage
…cope * origin/main: (24 commits) fix(backup): skip transient gateway lock databases (openclaw#119782) test(agents): use canonical auth session fixtures (openclaw#119821) fix(memory): keep QMD file hints after stale docid misses (issue openclaw#113041) (openclaw#113515) test(doctor): align fast-path repair contracts (openclaw#119812) perf(agents): index subagent recovery ownership (openclaw#119793) fix(gateway): keep chat startup off catalog discovery (openclaw#119742) fix(test): keep TUI PTY suites in their owner lane (openclaw#119787) docs: correct dashboard auth precedence (openclaw#119785) docs: document control ui owner handoff fix: grant host-authorized control ui owner access fix(worktrees): preserve registered roots during orphan cleanup (openclaw#119709) fix(matrix): prevent shared client key collisions (openclaw#119667) fix(diagnostics-otel): propagate exported span context (openclaw#112283) fix(worker): isolate state observer failures (openclaw#117507) fix(qa): attest realized profile executions (openclaw#119761) fix(gateway): finish successful sessions after timestamp races (openclaw#119752) fix(agents): fence restart recovery lifecycle (openclaw#119776) fix(ui): preserve chat history and active run timing (openclaw#119729) improve(ollama): reduce inactive startup cost (openclaw#119745) improve(gateway): defer inactive plugin runtime imports (openclaw#119733) ...
Fixes #119407
What Problem This Solves
Fixes an issue where a successful session could remain marked as running when its terminal lifecycle event arrived with a timestamp older than a newer same-run metadata write. This could leave the operator-visible session state stuck even though the agent run had already completed.
Why This Change Was Made
Session lifecycle state now records a private durable run owner in the existing session entry JSON. Accepted starts and recovery runs claim that owner, and terminal events from the same run can settle the session despite timestamp races; events from another session or run remain fenced as stale.
Ownership is explicitly preserved, transferred, or cleared across yielded runs, restart recovery, pending-final dispatch, reset, rotation, fork, checkpoint, terminal, and forced-clear paths. Public Gateway, session, and plugin projections strip this internal field. This uses the existing
entry_jsonstorage, so there is no SQLite DDL, schema-version, Gateway protocol, or plugin SDK change.The QA restart scenario now treats already-delivered handoffs as settled: after restart it proves there is no replay or synthetic interruption output, then uses a new durably delivered task as the observation boundary and proves post-restart completion exactly once. Its previous interruption expectation depended on the stuck-running state fixed here.
The regression was introduced by #117731 (
7c1d5dc7ef5855800894ad04fbf1922e0e16bf34). Thanks to @harjothkhara and #119456 for independently identifying durable run identity as the key missing state; this maintainer repair was derived independently and extends the ownership model across recovery and cleanup boundaries.User Impact
Completed sessions reliably stop showing as running even when same-run persistence events arrive out of timestamp order. Older or unrelated lifecycle events still cannot overwrite newer session state.
Evidence
pnpm tsgo:coreandpnpm tsgo:core:test(keepalive workflow metadata).git diff --check origin/main...HEADpassed locally.subagent-completion-direct-fallbackscenario (1/1) on the runtime- and QA-equivalent preceding head; the final head only splits its persistence test to satisfy the lint budget (Testbox transport run).The changed-gate wrapper could not start in two Testbox attempts because remote rsync cleanup timed out on a busy
node_modules; the directly relevant static lanes above passed. Native hosted CI and the guarded prepare step are the authoritative exact-head merge gates. No fresh authenticated live Codex or channel proof was run for this internal lifecycle-state repair.Production code is +149/-56 (net +93); tests and QA evidence are +323/-64 (net +259). The production increase establishes one durable owner boundary and makes its lifecycle transitions explicit across all session mutation paths rather than compensating at the terminal-event consumer.