← Back to Pull requests

fix(shell): recover every lock a panic poisoned instead of failing until restart (2/4) #227

Merged
constant1n0 merged 14 files (1091 lines) on Nov 30, 2026 15:02 UTC
View on GitHub
constant1n0 constant1n0 commented on Nov 30, 2026 13:49 UTC
Author

Later work left by the reviews of #222–#225: a panic while a lock is held no longer leaves the shell or the supervisor failing until restart.

Chain context

  • Strategy: stacked PRs to main. This PR runs from de47b0d to 219ee2d and depends on PR 1/4.

  • Until PR 1/4 is merged, this PR also shows its commits. Review from de47b0d.
  • main (f700fd1)
     └─ PR 1/4  fix/checkpoint-restart-final-batch-a  f700fd1..de47b0d  (296 lines)
         └─ 📍 PR 2/4  fix/checkpoint-restart-final-batch-b  de47b0d..219ee2d  (795 lines)
             └─ PR 3/4  fix/checkpoint-restart-final-batch-c  219ee2d..39ae1b2  (563 lines)
                 └─ PR 4/4  fix/checkpoint-restart-final-batch-d  39ae1b2..2e997b8  (763 lines)
    

  • Size: 795 changed lines (571 added, 224 removed). That is over the 400-line budget, so size:exception is requested. It is one rule applied to every lock in two crates, plus 15 tests that each poison a table.
  • What changes

  • Async commands settle after a poisoned lock.

  • - On the async side, the run, candidate, active-workspace, wrong-root and publication tables were locked with .expect.
    - A lock poisoned by an earlier panic made the command panic, and Tauri never settled it.
    - These locks now recover their data with PoisonError::into_inner, as the adapter state already did.
  • The launch gate and the supervisor recover too.

  • - with_gate and the supervisor's tables (children, settling, stopping, lingering, terminals, outputs) used to answer an error on every call until the app restarted.
    - Now a running child can still be observed and stopped.
    - Recovery cannot lose an approval or a child: the gate holds no in-memory state, and the child table is only written in place.
    - The self-exit reaper recovers the child table too, so a child that exits by itself still ends its run. Recovering a lock does not clear its poison flag, so the reaper used to panic on every later poll (Codex review, 219ee2d).
  • Accessors.

  • - ExecutableState's gate and candidates are private behind recovering accessors.
    - active_workspace delegates to active_workspace_in, so it can be tested without an AppHandle.
  • Harness-log prune test. It now names its files as the shell writes them (run-{seconds}-…, with unpadded seconds), so it keeps passing once PR 3/4 parses run names strictly.
  • Checks

  • Suites:

  • - cargo test -p omnifrons-supervisor: 199 passed.
    - cargo test -p omnifrons-shell: all passed.
    - clippy: clean, also cross-target for the supervisor.
  • RED: each of the 14 new lock tests panicked at the old expect before the fix. The self-exit test ended with no final state (left: None) while the reaper panicked.

  • pick_workspace refusal: an earlier review asked for a test. It is already pinned by a_workspace_pick_is_refused_while_a_switch_step_holds_the_slot, and two mutations fail it.

  • Independent verification: every non-test lock in the shell and the supervisor recovers.

  • Native review (risk, resilience and reliability lenses): approved.
  • Risk

  • Concurrency. After a panic, commands act on the state the panic left behind. A half-finished supervisor update can show a run as running until the next settle corrects it.
  • Out of scope (later work)

  • A log line when a lock is recovered (native review advisory).
  • Diff: 1091 lines (+821 / -270) across 14 files Reviewer: constant1n0 Review duration: 73m
    All Vouch review confidence checks passed
    Residual risk 0.14 = Change Risk (0.76) × (1 − Review Confidence (0.82)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.76 · 1091 lines diff across 14 files
    0.76
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.86 · 3 substantive comment(s)
    0.86
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    82%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.400
    Self Review self_review
    0.140
    Real PR Conversation Timeline
    5 items
    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on Nov 30, 2026 13:49 UTC
    Bot

    <!-- codex-pull-request-review-summary -->
    <!-- codex-review-state:v1 {"code_review":{"commit_sha":"38eeddc3341b7fe3064c308ae584432c877995c4","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} -->

    <details>
    <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary>

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

    | Review | Status | Commit | Review trigger |
    | --- | --- | --- | --- |
    | 📝 Code Review | ✅ Completed <relative-time datetime="2026-11-30T13:53:32.000384Z">2026-11-30T13:53:32.000384Z</relative-time> | 38eeddc | PR opened |

    <details> <summary>ℹ️ About Codex in GitHub</summary>
    <br/>

    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.

    </details>

    </details>

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on code on Nov 30, 2026 13:53 UTC
    Code Review
    crates/omnifrons-supervisor/src/lib.rs:1
    @@ -2096,6 +2085,15 @@ pub struct TokioProcessSupervisor {
     
     /// The state every [`TokioProcessSupervisor`] handle shares a clone of.
     ///
    +/// A panic while one of its tables is locked poisons that lock; every
    +/// later accessor takes the table as the panic left it
    +/// (`PoisonError::into_inner`) instead of panicking in turn, so a running
    +/// child can still be observed and stopped. Nothing is lost: an entry is
    +/// only ever updated in place or evicted once terminal, and a settle left
    +/// half-done shows its child as running until `settle_wait` elapses. The
    +/// one exception is the self-exit reaper's `try_reap`, which still panics
    +/// on a poisoned `children` table; `observe` then confirms the reap.

    <sub><sub>!P1 Badge</sub></sub> Clear poison before relying on self-exit reapers

    When children has ever been poisoned, recovering it with PoisonError::into_inner does not clear the mutex's poison flag, so every current and future self-exit reaper still reaches the TryLockError::Poisoned panic in try_reap. observe can reap one child when explicitly called, but normal adapter launches wait on the subscribed output channel for the reaper's final state frame and do not continuously call observe; a naturally exiting run can therefore remain stuck, and the same happens to subsequent runs until restart. Recover the poisoned guard in try_reap or clear the poison flag after recovery.

    Useful? React with 👍 / 👎.

    <!-- codex-code-review-finding:v1 -->

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on Nov 30, 2026 13:53 UTC
    Reviewer

    <!-- codex-review-receipt:v1 -->

    💡 Codex Review

    Here are some automated review suggestions for this pull request.

    Reviewed commit: 38eeddc334

    <details> <summary>ℹ️ About Codex in GitHub</summary>
    <br/>

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

    </details>

    constant1n0 constant1n0 commented on code on Nov 30, 2026 14:35 UTC
    Code Review
    crates/omnifrons-supervisor/src/lib.rs:1
    @@ -2096,6 +2085,15 @@ pub struct TokioProcessSupervisor {
     
     /// The state every [`TokioProcessSupervisor`] handle shares a clone of.
     ///
    +/// A panic while one of its tables is locked poisons that lock; every
    +/// later accessor takes the table as the panic left it
    +/// (`PoisonError::into_inner`) instead of panicking in turn, so a running
    +/// child can still be observed and stopped. Nothing is lost: an entry is
    +/// only ever updated in place or evicted once terminal, and a settle left
    +/// half-done shows its child as running until `settle_wait` elapses. The
    +/// one exception is the self-exit reaper's `try_reap`, which still panics
    +/// on a poisoned `children` table; `observe` then confirms the reap.

    Fixed in 219ee2d. try_reap now takes a poisoned children table with into_inner, as every other accessor does, instead of panicking. Regression test: a_child_that_exits_by_itself_after_the_children_table_was_poisoned_ends_its_run. Before the fix, the reaper panicked and the run never got its final state.

    Reviewers
    Assignees
    constant1n0 constant1n0
    Labels
    risk: low confidence: 82% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 76% (HIGH) · Higher = larger blast radius
    76%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 82% · Lower = rushed or shallow review
    82%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 13.7% · Safe to merge
    13.7%