Skip to content

fix(automation): recheck cancellation before journal reservation - #1187

Merged
ScriptedAlchemy merged 5 commits into
codex/tracedecay-total-redesign-plan-reopenedfrom
fix/automation-admission-cancel-order
Sep 10, 2026
Merged

fix(automation): recheck cancellation before journal reservation#1187
ScriptedAlchemy merged 5 commits into
codex/tracedecay-total-redesign-plan-reopenedfrom
fix/automation-admission-cancel-order

Conversation

@ScriptedAlchemy

Copy link
Copy Markdown
Owner

Fixes defects introduced by #1181 and #1180, found in independent review.

  • test(automation) + fix(automation): recheck cancellation before journal reservationrefactor(automation): move effect settlement into runtime #1181 hoisted admission out of the settlement kernel so it ran before retirement classification (a spawn_blocking file read); a run cancelled during classification then proceeded to reserve durable journal state. The kernel now re-evaluates the live cancellation signal (CancellationSignal::context() re-reads the atomic) and the deadline against a fresh tracedecay_contracts::try_now_micros() immediately before reserve_or_replay_indexed_blocking — the durable boundary, with nothing durable between — mapping Cancelled/TimedOut to the typed PreAdmissionProblem. observed_at stays the pinned admission instant on the durable record. RED→GREEN: cancelled_after_admission_does_not_reserve_journal and the timeout twin both assert the journal file and recovery index are empty.
  • refactor(automation): keep one pre-admission gauge authorityobserve_admission_decision in settlement.rs is the single owner of daemon.effect_admission.refused.pre_admission_total; root's own early pre-admission refusal calls it, so the census has no hole and the "every effect settles into exactly one outcome" doc holds.
  • fix(daemon-service): surface host admission recovery at warnrefactor(lifecycle): move replay, PR git kernels, and query wait to owners #1180 moved the replay worker from the unconditional daemon log to tracing::info!, so profile_host_admission_bootstrap_recovered/_retry vanished under the default WARN filter; raised to WARN (the stopped/exhausted events branch_admin.rs asserts were already WARN and are untouched).
  • refactor(code-index-runtime): single disable check for deferred mountscode_index_disabled_for_scope was checked in both the root spawn wrapper and the runtime helper; the unreachable runtime copy and the dead _scope parameter are gone, and the two invariant comments refactor(lifecycle): move replay, PR git kernels, and query wait to owners #1180 dropped (lagged receiver; once-a-second polling cost) are restored.

Verification: settlement 59; root daemon::automation_effect 9; deferred-mount 3; clippy -D warnings --tests on automation-runtime, daemon-service, code-index-runtime (lib) and root; fmt; commitlint. Two independent Opus passes; second pass's items (stale-clock deadline recheck, gauge hole, dead parameter) fixed and folded. The only clippy noise left in this area is the pre-existing format_collect in code_index_scheduler/tests.rs, fixed separately in #1184.

@changeset-bot

changeset-bot Bot commented Sep 10, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: a6159eb

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a6159eb61d

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1222 to +1225
let live_admission = context
.clone()
.with_cancellation(cancellation.context())
.admission_at(live_at);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Recheck admission inside the reservation worker

When the blocking pool is saturated, cancellation or deadline expiry can occur after this live check but before the spawn_blocking closure reaches reserve_or_replay_indexed_blocking; the closure will then still create the pending-index entry and durable journal reservation. This leaves the exact cancellation/timeout window the change is intended to close and can cause a cancelled run to be recovered or executed later, so the check must be performed at the actual reservation boundary rather than before scheduling the worker.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector

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-09-10T01:10:24.923938Z a6159eb PR opened
ℹ️ 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.

@github-actions

Copy link
Copy Markdown
Contributor

Performance Comparison codex/tracedecay-total-redesign-plan-reopenedfix/automation-admission-cancel-order

Total Elapsed Time: 3.96s → 3.99s (+0.8%)
CPU Baseline: 80.89µs → 84.08µs (+3.9%)
Benchmark ID: index-bench-timing

timing - Execution duration of functions.

+------------------------------------------+----------------------------+--------------------------------+--------------------------------+----------------------------------+------------------------------+
| Function                                 | Calls                      | Avg                            | P95                            | Total                            | % Total                      |
+------------------------------------------+----------------------------+--------------------------------+--------------------------------+----------------------------------+------------------------------+
| tracedecay-index-bench                   | 1 → 1 (+0.0%)              | 3.96s → 3.99s (+0.8%)          | 3.96s → 3.99s (+0.8%)          | 3.96s → 3.99s (+0.8%)            | 100.00% → 100.00% (+0.0%)    |
+------------------------------------------+----------------------------+--------------------------------+--------------------------------+----------------------------------+------------------------------+
| query.artifact.append_pages              | 13 → 13 (+0.0%)            | 122.02ms → 122.75ms (+0.6%)    | 166.07ms → 165.81ms (-0.2%)    | 1.59s → 1.60s (+0.6%)            | 40.07% → 40.01% (-0.1%)      |
+------------------------------------------+----------------------------+--------------------------------+--------------------------------+----------------------------------+------------------------------+
| code_index.workers.install               | 83 → 83 (+0.0%)            | 13.77ms → 13.66ms (-0.8%)      | 47.32ms → 47.48ms (+0.3%)      | 1.14s → 1.13s (-0.9%)            | 28.87% → 28.43% (-1.5%)      |
+------------------------------------------+----------------------------+--------------------------------+--------------------------------+----------------------------------+------------------------------+
| domain.canonical.sha256                  | 110414 → 110414 (+0.0%)    | 9.29µs → 9.19µs (-1.1%)        | 12.57µs → 12.33µs (-1.9%)      | 1.03s → 1.01s (-1.9%)            | 25.92% → 25.43% (-1.9%)      |
+------------------------------------------+----------------------------+--------------------------------+--------------------------------+----------------------------------+------------------------------+
| query.artifact.batch.sqlite              | 13 → 13 (+0.0%)            | 70.52ms → 70.58ms (+0.1%)      | 95.35ms → 93.85ms (-1.6%)      | 916.71ms → 917.50ms (+0.1%)      | 23.16% → 23.00% (-0.7%)      |
+------------------------------------------+----------------------------+--------------------------------+--------------------------------+----------------------------------+------------------------------+
| code_index.build.and_publish             | 2 → 2 (+0.0%)              | 457.65ms → 452.07ms (-1.2%)    | 534.51ms → 528.48ms (-1.1%)    | 915.30ms → 904.15ms (-1.2%)      | 23.12% → 22.67% (-1.9%)      |
+------------------------------------------+----------------------------+--------------------------------+--------------------------------+----------------------------------+------------------------------+
| query.artifact.batch.postings            | 13 → 13 (+0.0%)            | 61.66ms → 62.06ms (+0.6%)      | 84.48ms → 84.21ms (-0.3%)      | 801.54ms → 806.79ms (+0.7%)      | 20.25% → 20.23% (-0.1%)      |
+------------------------------------------+----------------------------+--------------------------------+--------------------------------+----------------------------------+------------------------------+
| code_index.chunk.index_file              | 276 → 276 (+0.0%)          | 2.15ms → 2.85ms (+32.6%) ⚠️    | 3.19ms → 3.20ms (+0.3%)        | 592.48ms → 786.68ms (+32.8%) ⚠️  | 14.97% → 19.72% (+31.7%) ⚠️  |
+------------------------------------------+----------------------------+--------------------------------+--------------------------------+----------------------------------+------------------------------+
| query.artifact.finalization.advance_wake | 14 → 14 (+0.0%)            | 42.87ms → 45.13ms (+5.3%)      | 273.68ms → 286.26ms (+4.6%)    | 600.20ms → 631.78ms (+5.3%)      | 15.16% → 15.84% (+4.5%)      |
+------------------------------------------+----------------------------+--------------------------------+--------------------------------+----------------------------------+------------------------------+
| code_index.extract.parser_artifact       | 276 → 276 (+0.0%)          | 2.06ms → 2.08ms (+1.0%)        | 3.19ms → 3.23ms (+1.3%)        | 569.86ms → 572.77ms (+0.5%)      | 14.40% → 14.36% (-0.3%)      |
+------------------------------------------+----------------------------+--------------------------------+--------------------------------+----------------------------------+------------------------------+
| query.artifact.prepare_pages             | 13 → 13 (+0.0%)            | 42.76ms → 42.96ms (+0.5%)      | 61.51ms → 62.16ms (+1.1%)      | 555.84ms → 558.42ms (+0.5%)      | 14.04% → 14.00% (-0.3%)      |
+------------------------------------------+----------------------------+--------------------------------+--------------------------------+----------------------------------+------------------------------+
| query.artifact.batch.postings.ngram_rows | 13 → 13 (+0.0%)            | 34.31ms → 34.39ms (+0.2%)      | 47.55ms → 47.09ms (-1.0%)      | 446.06ms → 447.01ms (+0.2%)      | 11.27% → 11.21% (-0.5%)      |
+------------------------------------------+----------------------------+--------------------------------+--------------------------------+----------------------------------+------------------------------+
| query.artifact.batch.parallel_prepare    | 13 → 13 (+0.0%)            | 33.92ms → 34.04ms (+0.4%)      | 48.92ms → 49.28ms (+0.7%)      | 441.02ms → 442.58ms (+0.4%)      | 11.14% → 11.10% (-0.4%)      |
+------------------------------------------+----------------------------+--------------------------------+--------------------------------+----------------------------------+------------------------------+
| code_index.build.assemble                | 2 → 2 (+0.0%)              | 201.99ms → 201.55ms (-0.2%)    | 208.93ms → 208.67ms (-0.1%)    | 403.98ms → 403.09ms (-0.2%)      | 10.21% → 10.11% (-1.0%)      |
+------------------------------------------+----------------------------+--------------------------------+--------------------------------+----------------------------------+------------------------------+
| code_index.chunk.build                   | 276 → 276 (+0.0%)          | 1.34ms → 1.34ms (+0.0%)        | 1.95ms → 1.93ms (-1.0%)        | 369.79ms → 370.56ms (+0.2%)      | 9.34% → 9.29% (-0.5%)        |
+------------------------------------------+----------------------------+--------------------------------+--------------------------------+----------------------------------+------------------------------+

Generated with hotpath-rs

@ScriptedAlchemy
ScriptedAlchemy merged commit e8b9467 into codex/tracedecay-total-redesign-plan-reopened Sep 10, 2026
28 of 38 checks passed
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.

1 participant