Repository navigation
fix: recovery compaction ignores Stop and loses committed counts - #133260
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Stop cancelled or replaced runs before further recovery work while retaining completed compaction facts. Accept successor identity at the host commit boundary, bind fresh-session writers on the initial insert, and account context in producer order without confusing billing usage or public metadata with ownership. Fixes #127523
0479a0c to
bd76099
Compare
Type-check the recovery fixture inputs, distinguish queued target projection, and keep the new QA scenario on the audited serial path. Preserve watchdog identity, caller signals, writer fencing, and committed accounting without suppression exceptions.
|
Land-ready at Final isolated Blacksmith proof on Representative exact commands run in the isolated proof environment: node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run.overflow-context-recovery.test.ts src/agents/embedded-agent-runner/run.timeout-context-recovery.test.ts src/agents/embedded-agent-runner/run.overflow-compaction.test.ts src/agents/embedded-agent-runner/run/overflow-context-recovery.test.ts src/agents/embedded-agent-runner/run.compaction-runtime.test.tspnpm lint:tmp:export-name-collisionsOPENCLAW_BUILD_PRIVATE_QA=1 pnpm buildnode --import tsx test/e2e/qa-lab/runtime/gateway-compaction-abort.ts --artifact-base .artifacts/qa-e2e/compaction-owner-after-127523Fresh Codex review of the integrated repair and final CI delta found no P0 findings. This is real Gateway/SQLite proof with a controlled mock provider and QA channel, not authenticated-provider or native-runtime proof; broader standalone/manual/native reconciliation remains separate. The latest ClawSweeper comment was checked and contains only its acknowledgement—no completed review or Rank-up moves are published. Native exact-head review artifacts are validated; proceeding through the repository's hosted-evidence prepare/merge flow. |
|
Merged via squash.
|
Remove redundant outer ownership state and parameter adapters after the recovery and native-usage repairs (#133260, #133441). Reuse logical-writer comparison, lazy loaders, and resolved runtime facts while preserving fencing, chronology, and standalone subscription behavior. Consolidate test setup without dropping cases. Validation: 902 focused tests, full changed-code gates, build, and independent Codex review. Net -45 production and -45 test/support lines.
…int drift
Refresh onto main and repair the two CI reds this PR owned.
The gateway compaction path now takes an `{ onCommitted }` host argument
(upstream openclaw#133260). That change updated its own native-CLI assertion but
merged textually clean over this PR's auth-tombstone test, which still
asserted the old single-argument arity.
The six cleared-binding assertions this PR converted from `toBeUndefined()`
to a `toStrictEqual` tombstone check added twelve counted lines to
agent-runner-execution-cli-sessions.test.ts, pushing it to 1004 against the
1000-line cap. Collapse them onto a shared `expectClearedAuthTombstone`
helper in the sibling test-support module, which the file's other assertion
helpers already live in. No behavior code changes.
…nclaw#133260) * fix(agents): bind compaction recovery to its run owner Stop cancelled or replaced runs before further recovery work while retaining completed compaction facts. Accept successor identity at the host commit boundary, bind fresh-session writers on the initial insert, and account context in producer order without confusing billing usage or public metadata with ownership. Fixes openclaw#127523 * fix(agents): preserve bound compaction delegates Type-check the recovery fixture inputs, distinguish queued target projection, and keep the new QA scenario on the audited serial path. Preserve watchdog identity, caller signals, writer fencing, and committed accounting without suppression exceptions.
Carry the claimed writer independently of optional ordered context telemetry. Preserve unknown/zero chronology and exact-writer fencing; repair live admission, directory ownership, tool-event capability and cache-contract fixtures. Fixes openclaw#133346. Related to openclaw#133260.
Remove redundant outer ownership state and parameter adapters after the recovery and native-usage repairs (openclaw#133260, openclaw#133441). Reuse logical-writer comparison, lazy loaders, and resolved runtime facts while preserving fencing, chronology, and standalone subscription behavior. Consolidate test setup without dropping cases. Validation: 902 focused tests, full changed-code gates, build, and independent Codex review. Net -45 production and -45 test/support lines.
Additional instructions
MUST: Keep Allow edits from maintainers enabled for this PR so maintainers can help update the branch when needed.
What Problem This Solves
Resolves a problem where stopping an agent during recovery compaction could still rewrite its saved conversation, and where an older run could save a summary after another writer had taken over the same session. It also preserves the count for compaction that already committed when Stop arrives during an after hook.
Closes #127523 — recovery continues after caller cancellation.
Closes #127551 — recovery loses the admitted transcript writer fence.
Why This Change Was Made
Recovery carries the original admitted owner through the actual compactor, transcript rewrites, successor acceptance, and checkpoint commits, revalidating at the write boundary rather than only after asynchronous work returns. Completed compaction and current-context observations are separate from permission to continue: Stop prevents new work without pretending committed work was rolled back, and the outer reply owner remains registered until its bookkeeping settles.
This maintainer-requested repair includes the existing lazy first-session insert and successor handoff. It adds no SQLite schema, table, durable receipt, configuration option, protocol, replacement admission, or provider-specific policy.
User Impact
Stopping a run or replacing its writer prevents stale recovery summaries, truncation, checkpoints, hooks, and further recovery dispatch. Ordinary backend failures and independent safety timeouts remain recoverable while the caller is active. Compaction completed before Stop remains counted for the owning reply; newer model-context observations are not replaced by an older summary estimate, and accounting cannot recreate a deleted session or overwrite another writer.
The ownership rules cover overflow and timeout recovery, queued compaction, direct commands, memory flush, accepted successor sessions, and worker placement. Global-session checkpoint writes retain the explicitly selected agent with a custom store locator. Native provider thread IDs remain separate from OpenClaw session IDs; public model metadata cannot rotate the host session.
Evidence
Hosted landing gate: CI run 33311795888 completed successfully on exact head
9b50abf4354f45e1e016e9fd170d41e293923f86; the requiredopenclaw/ci-gateis successful for that SHA from GitHub Actions.Real Gateway before/after
The checked-in scenario starts an isolated built Gateway with its own state directory and port, a controlled loopback Responses-compatible provider, a real 180,000-character completed tool result, exact
chat.abort, separate-process writer takeover, a loaded internal after-hook barrier, and a same-session successor turn. It checks persisted transcript/metadata/checkpoints, counts, provider requests, run-bound channel delivery, and process cleanup. This is real Gateway + SQLite behavior with a mock provider/channel, not authenticated-provider or native-runtime proof; it uses the repository's mock-Gateway channel-visible proof route rather than a Control UI recording.Baseline: Blacksmith Testbox
tbx_01m18adwx4ys14455jmmm4ydjn, hydration run 33289709016.After: Blacksmith Testbox
tbx_01m198qwyjfafmfaqm95t04y2y, hydration run 33310392330, exact final source tree956c800fd141586217c16c69cc2e3c82d7850e29, wrapper exit 0. The preceding integrated tree544e371793406f72f0b3e8d1b4a24d317378238aand initially published tree93228e552a41a526ce88ab01b61cb489e63704d2also passed all five cases on run 33307407446 and run 33305824457. The linked Actions runs identify hydration; the command's exit status is the proof result. Owned processes were joined, test namespaces removed, and leases stopped. The final Gateway log recordsshutdown completed cleanly in 46ms; process extinction and no late writes were checked separately.All five cases reached the same-session successor checkpoint. The final five-case run passed in 10.42 seconds with no invariant failures.
Gateway verdict summary
{ "test": "gateway-compaction-abort", "sourceTree": "956c800fd141586217c16c69cc2e3c82d7850e29", "gateway": "real built Gateway", "providerMode": "mock-openai", "authenticatedProviderProof": false, "result": "pass", "cases": { "cancel": { "result": "pass", "compactions": 0, "checkpoints": 0, "count": 0 }, "writer-replaced": { "result": "pass", "compactions": 0, "checkpoints": 0, "count": 0 }, "active-failure": { "result": "pass", "compactions": 0, "checkpoints": 0, "count": 0 }, "success": { "result": "pass", "compactions": 1, "checkpoints": 1, "count": 1 }, "cancelled-after-commit": { "result": "pass", "compactions": 1, "checkpoints": 1, "countWhileHookHeld": 1, "finalCount": 1 } } }Regression and integration proof
Twelve selected owner-level regressions failed against the original producers, with positive controls retained. Further real-SQLite regressions cover checkpoint sizing interrupted before commit and a custom-agent/global-key checkpoint incorrectly written into the main partition. The repair reuses the captured commit assertion and carries the already-resolved agent into the actual mutation scope.
The integrated source completed 2,580 selected test executions, all repository typecheck lanes, and the changed-code static guards on Blacksmith hydration run 33303515897. That run stopped on one test-file size limit. The follow-up moves the three existing owner/delivery test executions into a focused file without changing production or assertions; final full lint, 533 dispatcher tests, messaging test types, private-QA build, 169 reply-accounting E2E tests, and all five Gateway cases passed on run 33305824457. No size suppression or baseline increase was added.
An actual merge conflict then required integration with main
d498334714d255a992232f8175be1065fde11627. At that integration, all 72 changed production paths were byte-identical to the previously verified published head. Fixture resolution preserves main's per-test workspace ownership and real queued-work joining, the repair's durable rows and exact admissions, and the projection test's alternate store. On final tree544e371793406f72f0b3e8d1b4a24d317378238a, 1,169 focused test executions, all core-test typecheck shards, core types, full lint, private-QA build, 169 reply E2E tests, and all five Gateway cases passed on run 33307407446. This includes new-main shutdown, raw-stream, provider-error, and LLM-boundary controls. All proof leases were stopped.The first hosted CI run 33308524287 exposed four additional integration gaps: an exported helper name collided with a different resolver; two legacy leaf test builders concealed missing owner/usage inputs behind whole-object casts; two watchdog call sites added unapproved unbound-method suppressions; and the new QA scenario claimed audited parallel safety. The follow-up gives the queued projector its own name, makes both fixture constructors type-checked without changing their assertions, binds and tags the same captured compactor at the watchdog owner, and keeps the scenario on the normal serial scheduler path. Neither allowlist was expanded. Receiver-sensitive marked/unmarked result/error and progress cases protect binding, signal/context forwarding, and watchdog eligibility. Final tree
956c800fd141586217c16c69cc2e3c82d7850e29passed 451 focused test executions, the explicit export guard, all core-test type shards, the complete changed-code gates (including typed lint), the private-QA build, 169 reply E2E tests, and all five Gateway cases on run 33310392330. Fresh Codex review of the full CI-repair delta reported no P0 findings. The final Testbox command exited 0 in 29m24s; all roots and its lease were cleaned up.The late-count failure was traced through the actual build: the recorder was present, the commit was observed, and a durable count-one fact was emitted; the dispatcher then cleared the exact reply operation before accounting, causing its authorization to reject the write. The fix separates owner work from delivery work in the existing local tracker. An extended owner-lifecycle regression fails before the repair; the complementary block-receipt test also demonstrably fails when delivery is incorrectly classified as pre-clear owner work. Seven ACP/hook fixtures now release and join their actual work rather than leaving promises pending or checking cleanup too early. Prompt abort, late-send suppression, and zero-leak assertions remain.
Integration preserves upstream progress-aware compaction watchdogs, Code Mode recovery, keyed-user deduplication across pre-prompt compaction, worker computer-close ordering, and transaction-local transcript projection. Both compactor wrappers inherit the canonical delegate marker and attach private accounting to the actual invocation context after watchdog projection. Fresh Codex autoreview of the final tree completed with no findings at the requested P0 threshold; this is scoped review evidence, not an all-priority correctness certificate.
Reproducible checked-in proof commands, run in isolated test environments:
Ownership, size, and boundaries
The existing transcript-write context, commit hook, and accounting bridge are reused. Private observation happens before awaited extension work; public completion timing remains unchanged. Removed paths include the forwarding-only reply accounting module, duplicate engine disposal, duplicate private accounting from public completion events, and the equal-summary entry scan. Terminal usage follows chronological accounting rather than supplying authority from public metadata.
Against pinned main
d498334714d255a992232f8175be1065fde11627: production +3,694/−2,233, net +1,461; tests/support/scenario +10,286/−2,760, net +7,526. Pure moves cancel: queued entry/execution together add 253 lines, initial-entry extraction and its former owner add 62, and the bridge rename/expansion adds four. Accounting-first settlement, command accounting, and hidden-session cleanup extractions add 95 lines of typed-boundary overhead while reducing the oversized orchestrators. The final dispatcher repair adds seven production lines to distinguish two real lifetimes, not storage or relaxed authorization. The subsequent watchdog binding repair adds 13 production lines to capture, bind, tag, and invoke the same method while removing both suppression exceptions. Remaining growth establishes missing admission/writer, first-insert, successor-commit, and chronological-accounting boundaries. Size/assertion baselines shrink.Provenance: the overflow/timeout catch-all policy predates caller-signal forwarding. The plugin-compaction safety-timeout change brought caller abort into those catches on 2026-05-19 (PR author
@100yenadmin, merger@jalehman, Git committer GitHub); the raw-parent diff ofa059309a9f9a7aeab9f476b6debe68674f60d631was verified. The writer-context omission is present in both inspected main baselines, but its first operator-visible introduction is not established.Direct Codex dependency inspection at
63d213884daea50e4f74efc192cdc44f549b67d5:codex-rs/core/src/compact.rs:174–242,296–307,codex-rs/app-server/src/request_processors/turn_processor.rs:1590–1653, andcodex-rs/app-server/src/request_processors/thread_processor.rs:2345–2358. Interruption is not ordinary retryable failure; completed analytics survive a post-hook stop;thread_compact_startacknowledges submission rather than completion. No native-provider fix or authenticated native verification is claimed.Broader standalone/manual/native post-timeout completion reconciliation and unrelated cumulative-usage inflation remain separate. In particular, the standalone Plugin SDK adapter's abort-time admission closure needs its own reconciliation proof; this Gateway proof does not cover that lifecycle. The delegated Testbox sync-exclusion defect is tracked separately; each qualified batch verified the entire remote source tree before proof.
AI-assisted implementation and review; maintainer-directed, with source and observed-behavior verification. No agent transcripts are included.