Skip to content

fix(runtime): cancel preparation cooperatively before owned settlement - #293

Merged
lg2m merged 10 commits into
mainfrom
fix/qq-preparation-deadline-v0.1.6
Oct 16, 2026
Merged

lg2m merged 10 commits into
mainfrom
fix/qq-preparation-deadline-v0.1.6

Conversation

@integrate-your-mind

@integrate-your-mind integrate-your-mind commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Take over the existing PR on its original branch, targeting main. Stop avoidable runtime-construction work after a run deadline or cancellation without publishing a terminal result while preparation is still alive.

This supersedes the old early-settlement design. Terminal settlement continues to follow owned loader drain; the session reservation and scheduler capacity remain held until preparation actually exits.

What changed

  • Add cooperative cancellation to the existing per-load RuntimeLoadProgress, preserving default behavior for legacy embedding loaders.
  • Signal cancellation on initial-load and routing-reload deadlines or explicit cancellation, then await the same loader before settlement.
  • Production construction checks before blocking work and between configuration, credential, provider, reviewer, tool, and plan phases.
  • A cancellation observed during compilation fails inside the cache compile closure before generation publication; no partially constructed generation is installed.
  • Preserve the secret-free stage captured at expiry and prevent expired-run model dispatch.
  • Add synchronized cooperative deadline/cancel tests for initial and routed loads, retained-ownership tests for noncooperating loaders, and production credential/phase/cache regressions.
  • Make the existing hanging-provider budget test deterministic: wait for provider entry, advance virtual time, and retain the exact-one-request assertion. No increased allowance or relaxed assertion.
  • Relocate existing sleep-baseline line numbers only; no new sleeps or ceiling changes.

Verification

  • Red regression before fix: loader must receive cooperative cancellation (expected 1, observed 0).
  • Focused preparation/deadline/routing/production tests passed; focused budget/deadline tests passed after deterministic timing repair.
  • Affected-package gate: 1,948 passed, 13 skipped; formatting, lint and strict Clippy passed.
  • Full-workspace gate at final head 082ffe27de54: 2,474/2,474 passed, 14 skipped; doctests, strict workspace Clippy, formatting and lint passed. Minimal-provider Clippy and 211/211 tests passed. Total 233.9s.
  • Smoke: implementation agent ran all 6 scenarios, 0 failures.
  • Independent static review: Approve; loader ownership, phase checks, cancellation notification and cache publication reviewed.

Full gate commands: cargo xtask check --full; cargo xtask check --evidence. Affected gate: cargo xtask check --base origin/main.

Design and compatibility

No dependency, wire/protocol, descriptor, or store-schema changes. Legacy loaders remain supported and fully drained. Reused the existing cancellation primitive rather than adding detached teardown tasks or a new runtime.

Cancellation is cooperative, not OS-call interruption: a credential/filesystem call already executing must return before the next checkpoint can stop construction. Cache single-flight waits remain owned and drained. Cancellation racing after the final check may leave a valid complete generation cached; it cannot install an incomplete one. This PR does not claim immediate terminal response during a blocked Keychain call, signing fixes, or native macOS credential acceptance.

History

Original PR history is preserved without force-pushing. Current-main reconciliation excludes the old branch's unrelated unmerged auth/diagnostic stack. No replacement PR or branch was created. Installer work remains separately merged in #287.

Retain credential coalescing, typed review diagnostics and remaining tool allowances for the protocol 31 compatibility line.
Preserve original branch history while selecting current main as the audited baseline. Old early-settlement candidate remains in history and will only be reintroduced where justified by preparation ownership review; exclude unrelated unmerged auth and diagnostics ancestry.
PR #293 gate follow-up: freeze virtual time through preparation, observe provider entry, and explicitly advance the unchanged 100ms deadline. Preserve exact-one request assertions and remove the wall-clock timeout. Relocate existing sleep baseline lines only.
@lg2m lg2m changed the title WIP: settle preparation deadlines before loader drain fix(runtime): cancel preparation cooperatively before owned settlement Oct 16, 2026
@lg2m
lg2m changed the base branch from fix/qq-v0.1.6-recovery-base to main October 16, 2026 02:20
@lg2m
lg2m marked this pull request as ready for review October 16, 2026 02:26
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T03:11:50.204204Z 0abc250 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@lg2m

lg2m commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator

Updated to current main tip ffa46942 and resolved conflicts in the hanging-provider budget regression and line-pinned sleep baseline. Preserved the deterministic provider-entry/virtual-time test and current main's other changes. Shared branch history was preserved via a merge, not rewritten/force-pushed.

New head: 0abc250101c9.

Verification on this head:

  • cargo xtask check --full: passed. Workspace 2,642/2,642 tests passed, 15 skipped; formatting, lint, strict workspace Clippy and doctests passed. Minimal-provider Clippy and 211/211 tests passed.
  • cargo xtask smoke: 6 passed, 0 failed.
  • Re-fetched main after verification and confirmed its tip remains an ancestor of this head.

Benefit: expired/cancelled runtime preparation receives a cooperative stop signal and skips later credential/provider/reviewer/tool/plan phases at safe checkpoints. It still drains owned work before terminal settlement/session release, preventing hidden background construction. Already-running OS credential calls are not forcibly interrupted. The old early-RunFinished approach is not included.

@lg2m
lg2m merged commit 3d58b3d into main Oct 16, 2026
6 checks passed
@lg2m
lg2m deleted the fix/qq-preparation-deadline-v0.1.6 branch October 16, 2026 03:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants