Skip to content

fix(compaction): stop cancelled queued preparation - #138649

Merged
vincentkoc merged 2 commits into
mainfrom
fix/queued-compaction-preparation-cancellation-20260904
Sep 4, 2026
Merged

vincentkoc merged 2 commits into
mainfrom
fix/queued-compaction-preparation-cancellation-20260904

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 4, 2026 •

Copy link
Copy Markdown
Member

Related: #138184

What Problem This Solves

Fixes an issue where queued compaction could continue preparing a model after
the caller cancelled or the session host lost authority. That stale work could
retain a prepared-runtime lease, and native CLI cancellation could be reported
as an ordinary backend failure instead of a cancelled compaction.

Why This Change Was Made

Queued execution now revalidates cancellation and host authority at the
preparation owner after each asynchronous boundary, and releases any acquired
prepared-runtime lease from one lifecycle-owned cleanup path. Native CLI
signal-owned aborts remain exceptions until the queued owner converts them to
the public cancellation result; ordinary CLI failures remain result-based and
completed work still wins over a late abort.

This is separate from #138473, which repairs Codex thread-binding continuity
after a committed compaction successor.

User Impact

Stop and timeout requests now halt stale queued compaction before further model
or context-engine work. A cancelled native CLI compaction reports
compaction aborted, and replacement session owners do not inherit abandoned
preparation or leases.

Evidence

Exact signed head: dce2f6535e47cf1bc72d0c37aca278099c7d00c0.

  • Red proof: caller cancellation and host expiry previously allowed another
    model-resolution step.
  • Red proof: native CLI cancellation previously surfaced a backend failure
    containing request timed out instead of compaction aborted.
  • Exact-head owner/sibling suite: 227 tests passed across prepared-runtime
    cancellation, queued/native compaction, successor ownership, and overflow
    recovery.
  • Exact-head node scripts/check-changed.mjs: passed with core and
    coreTests; no temp-directory warnings.
  • Exact-head hosted CI: 130 successful checks, 52 intentionally skipped,
    0 failed or pending in
    https://github.com/openclaw/openclaw/actions/runs/33923172518.
  • Native scripts/pr prepare-run accepted that hosted exact-head proof and
    recorded gates_mode=hosted_exact_or_recent_parent.
  • Autoreview at P0-P2: scoped clean, no findings, confidence 0.98.
  • Local ClawSweeper: no concrete bug, regression, or security issue; best-fix
    verdict was the queued lifecycle owner. Its sandbox could not start Vitest
    because artifact writes are read-only, so the executable proof is the
    separate exact-head run above.
  • Current Codex source inspected at
    3921a30d6b11218883e5bb81a48082095cf79b7c: task cancellation is expected to
    terminate promptly, and TurnAborted owns aborted-turn lifecycle handling
    (codex-rs/core/src/tasks/mod.rs:187,
    codex-rs/core/src/tasks/compact.rs:28).
  • Live origin/main was checked at
    6e42083f34e74d122d9773d163e3604dfe9da629; no intervening commit touched the
    four changed files, so the branch was not cosmetically rebased.

Maintainer Decision

Approved for self-landing after exact-head gates. The +24 production-line delta
is accepted because the distinct post-await checks protect caller cancellation,
host authority, and one lease-release owner; collapsing them to one downstream
guard would leave stale preparation running. Native review artifacts record no
findings and recommend READY FOR /prepare-pr.

ClawSweeper's medium-confidence limitation was its read-only/partial-clone
environment, not a source finding. The missing evidence is supplied above by
the exact-head hosted matrix, the 227-test local owner/sibling run, and the live
main overlap check.

Production LOC: +74/-50 (net +24) | Tests: +276/-0.

The positive production delta carries cancellation and host-authority facts
through the existing queued owner and provides one lease-release boundary.
Moving the checks downstream would leave stale preparation active; swallowing
abort at the native backend boundary reproduces the original failure.

No config, schema, dependency, protocol, docs, or changelog surface changes.

@clawsweeper

clawsweeper Bot commented Sep 4, 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.

@vincentkoc vincentkoc self-assigned this Sep 4, 2026
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Sep 4, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review September 4, 2026 21:54
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 4, 2026
@clawsweeper

clawsweeper Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 4, 2026, 6:01 PM ET / 22:01 UTC.

ClawSweeper review

What this changes

This PR makes queued session compaction stop preparation after cancellation or host-authority loss and normalizes native CLI aborts to the public cancelled result.

Merge readiness

⛔ Blocked before merge - 4 items remain

Keep open for explicit maintainer review: the introduced cancellation checks and lease cleanup align with the queued-compaction owner boundary, and no discrete correctness defect was established; the local partial clone could not complete a comparison with fetched current main.

Priority: P1
Reviewed head: dce2f6535e47cf1bc72d0c37aca278099c7d00c0
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is focused, follows the lifecycle owner boundary, and adds targeted regression coverage; final acceptance remains maintainer-owned.
Proof confidence 🌊 off-meta tidepool Not applicable: This MEMBER PR is exempt from the external-contributor proof gate; the reviewed source includes focused asynchronous lifecycle regressions, but no independent execution artifact was available in this read-only environment.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER PR is exempt from the external-contributor proof gate; the reviewed source includes focused asynchronous lifecycle regressions, but no independent execution artifact was available in this read-only environment.
Evidence reviewed 6 items Preparation-owner checks: The branch checks the caller abort signal and host authority after placement resolution, prepared-runtime admission, context-engine resolution, harness-auth preparation, and model materialization; the acquired lease is released in the enclosing finally block.
Prepared-runtime cancellation contract: The prepared-runtime API explicitly accepts an AbortSignal, and this branch supplies the queued compaction signal during lease admission.
Focused regression coverage: Added tests cover cancellation during prepared-runtime admission and context-engine resolution, host expiry after admission and during resolution, model-resolution expiry, and in-flight native CLI cancellation.
Findings None None.
Security None None.

How this fits together

Queued compaction prepares a model runtime and context engine before placing transcript work on session lanes. It must stop when its caller or session owner is no longer active, so stale preparation cannot retain resources or continue into compaction.

flowchart LR
  A[Compaction request] --> B[Resolve session owner]
  B --> C[Prepare model runtime]
  C --> D[Resolve context engine]
  D --> E{Caller and host active?}
  E -- yes --> F[Queued compaction]
  E -- no --> G[Cancelled result and cleanup]
  F --> H[Session transcript update]
Loading

Decision needed

Question Recommendation
Should a maintainer approve this lifecycle-boundary fix and its net +24 production-line increase? Approve the queued-owner repair: Accept the cancellation and lease-cleanup checks as the narrow owner-boundary repair after normal exact-head merge gates complete.

Why: This is a maintainer-authored, protected-label PR; repository policy requires explicit human judgment rather than automated closure or merge recommendation.

Before merge

  • Resolve merge risk (P1) - The bug fix has a net production increase of 24 lines; the added checks are spread across distinct asynchronous owner boundaries, and no smaller single-boundary absorption was evident from the reviewed flow.
  • Complete next step (P2) - Obtain an explicit maintainer review before merging.
  • Resolve review confidence - ClawSweeper must reach high confidence before merge readiness is known.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
Agent review details

Security

None.

PR surface

Source +24, Tests +276. Total +300 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 3 74 50 +24
Tests 1 276 0 +276
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 350 50 +300

Review metrics

Metric Value Why it matters
Production versus regression tests production +24 net; tests +276 The extra production logic is limited to cancellation/authority checks and lease-result normalization, while the larger test addition covers several asynchronous interruption points.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep cancellation normalization at the queued lifecycle owner and retain the shared post-await authority checks, with a maintainer confirming the bounded production growth.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep cancellation normalization at the queued lifecycle owner and retain the shared post-await authority checks, with a maintainer confirming the bounded production growth.

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

Yes—source and focused regression tests provide a high-confidence deterministic path by aborting or expiring host authority while each preparation await is held.

Is this the best way to solve the issue?

Yes—the queue coordinator owns both the caller-facing result and the preparation lifecycle, while the native backend preserves abort identity for that owner to normalize.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 0b1e8697aa8e.

Labels

Label changes:

  • add P1: A cancelled or superseded compaction can otherwise continue model preparation and affect active session workflows.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This MEMBER PR is exempt from the external-contributor proof gate; the reviewed source includes focused asynchronous lifecycle regressions, but no independent execution artifact was available in this read-only environment.

Label justifications:

  • P1: A cancelled or superseded compaction can otherwise continue model preparation and affect active session workflows.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This MEMBER PR is exempt from the external-contributor proof gate; the reviewed source includes focused asynchronous lifecycle regressions, but no independent execution artifact was available in this read-only environment.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Jacqueline Henriksen: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Rank-up moves addressed on unchanged head
dce2f6535e47cf1bc72d0c37aca278099c7d00c0:

  • Maintainer decision: approve the queued-owner repair and its bounded +24
    production-line delta. The distinct post-await checks protect caller
    cancellation, host authority, and the single lease cleanup path.
  • Explicit maintainer review: native scripts/pr review artifacts have zero
    findings and recommend READY FOR /prepare-pr.
  • Review confidence: exact-head hosted CI completed with 130 successful checks,
    52 intentional skips, and no failures; the 227-test owner/sibling run and
    exact check:changed are also recorded in the updated PR body.
  • Current-main comparison: live main was checked and no intervening commit
    touched the four changed files. No rebase or behavior change occurred.

Please refresh the verdict against the updated durable evidence.

@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@vincentkoc
vincentkoc merged commit f9c33e4 into main Sep 4, 2026
254 checks passed
@vincentkoc
vincentkoc deleted the fix/queued-compaction-preparation-cancellation-20260904 branch September 4, 2026 22:08
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 5, 2026
Stop queued compaction preparation when caller cancellation or session-host
authority invalidates the request.

- revalidate cancellation and host ownership after asynchronous preparation
- release acquired prepared-runtime leases from the queued lifecycle owner
- preserve signal-owned native CLI aborts for canonical cancellation reporting
- cover admission, host-expiry, writer, successor, and overflow sibling paths

Exact-head validation: 227 focused owner/sibling tests, `check:changed`, 130
hosted CI checks, autoreview, local ClawSweeper, and native landing gates.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant