Skip to content

[CTX-1830] test(runtime): home PGO-4/PGO-5/PGO-20 crash and disable recovery rows (bitty#2476) - #3163

Merged
Xuepoo merged 1 commit into
mainfrom
ctx-1830/pgo-crash-disable-rows
Nov 14, 2026
Merged

Xuepoo merged 1 commit into
mainfrom
ctx-1830/pgo-crash-disable-rows

Conversation

@Xuepoo

@Xuepoo Xuepoo commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Related #2476

Homes PGO-4 and the crash arm of PGO-20 as production-driven rows, and records PGO-5 / PGO-20's disable arm as blocked with the exact symbols rather than implying coverage. No merge, no issue closed.

1. Decision F, quoted (specifications/panel-generation-ownership-decision.md, status draft)

PGO-4 — Crash during a callback: FS-2 ladder output is unchanged; only the owning generation is affected; sibling panels and terminals stay responsive (FS-P2); the panel's placeholder reason is crashed.

PGO-5 — Disable, then re-enable: Placeholder appears with disabled, disappears on rebind after activation, and content is not restored from the disabled generation.

PGO-20 — Bounded recovery under crash and disable: Crash: placeholder crashed, one FS-4 record, no respawn within the driver's reload window, container, title, and focus history intact, and no authority from the crashed generation survives the next bind. Disable: placeholder disabled, re-enable permits a rebind, and the disabled generation's grants are not restored by the rebind. Fails for an implementation that treats re-enable as resuming the old binding.

2. Per-row result

Row Result Where
PGO-4 homed tests/panel_generation_ownership.rs, pgo_4_a_crash_inside_a_callback_presents_crashed_and_contains_the_damage
PGO-20, crash arm homed same file, pgo_20_a_crashed_generation_is_bounded_and_loses_its_authority_at_the_next_bind
PGO-5, PGO-20 disable arm blocked-with-evidence named in the file's "still without a row" block

Sub-clause not assertable on this tree, stated rather than implied: PGO-4's "FS-2 ladder output is unchanged". bitty-plugin-host/src/lifecycle.rs (LifecycleEnforcer, EnforcementRecord) has no production consumer in bitty-runtime — nothing calls note_violation, so there is no ladder output a crash could change. What is observable is the registry's FS-4-style recovery record (Registry::recovery_attempts / recovery_records), which PGO-4 asserts is exactly one, and PGO-20 asserts does not grow across two recovery passes.

3. The production seam, and the missing mechanism it needed

Rows drive PluginRuntime, not a test binder. The crash is produced by the host itself: the fixture arms a timer whose body never returns, the manifest carries [limits] fuel_instructions = 200000, the pump drives the callback under that budget, the VM stops it with InstructionBudgetExceeded, fail_runtime_on_suspend → fail_runtime_classified → PluginRuntime::rollback ends the generation. The port installed in the test is the same delegation the composition root installs (crates/bitty-terminal/src/plugin_runtime.rs).

The seam that was missing:

  • PluginRuntime::rollback (crates/bitty-runtime/src/plugin_runtime/mod.rs:5109) released the generation's own content (clear_ui_blocks) but never asked the panel host. dispose_inner (:3818) did, so dispose/unload/disable/reload released a generation's containers and a crash did not: the generation stayed bound, kept {panel.create, panel.focus}, and PlaceholderReason::Crashed had no producer anywhere in the tree.
  • Fix (smallest correct change): rollback now calls release_panel_generation(id, ended, PlaceholderReason::Crashed) (:5155), after clear_ui_blocks and before the entry is reused — the same order dispose_inner uses — with no successor, because a crash is not a reload (OQ-084 A.2/E.1). Port None keeps the previous behaviour exactly, so headless builds are unaffected.
  • Unit test for the mechanism itself: plugin_runtime::tests::rollback_runs_the_generation_edge_with_the_crashed_reason (mod.rs:6099).

What each new test asserts, read back through the same accessors the verbs use: container keeps PanelId/attachment/title and is unbound; placeholder reason crashed naming the ended generation; unbind_release_record names that generation with both grants released and the grant row empty; retained_grant_ceiling carries the released set under the right owner; one recovery record (recovery_attempts == 1); a sibling plugin's container stays bound with its own grants and the crash edge attempted exactly one container (FS-P2); no respawn (timer_deadline() == None, recover_wall_failed_plugins() == 0 twice); focus + MRU intact; after reload, both containers bound to the successor, placeholder cleared, the crashed generation's row still empty.

4. Why PGO-5 / PGO-20-disable is blocked, not faked

disabled has exactly one production producer: dispose_inner called from recover_wall_failed_plugins (crates/bitty-runtime/src/plugin_runtime/mod.rs:3934, index branch :3970, dispose :3974), and that pass only selects a generation that is Failed with FailureClass::WallSliceTimeout. Nothing turns a live generation that still binds containers into a disabled one:

  • PluginRuntime has no disable entry; suspend parks a generation and asks the port for nothing, and dispose names unloaded;
  • package::set_enabled (crates/bitty-runtime/src/plugin_runtime/package.rs:1441) only writes the store index, and discover_inner skips a disabled record without touching a live entry (mod.rs:2852);
  • the application classes a plugin-set change as restart-required — "the plugin set is not part of the config plan and has no live apply path" (crates/bitty-terminal/src/config_reload.rs:128).

The one reachable route (crash first, then disable the index) arrives with the containers already released by the crash edge in this PR, so disabled cannot be presented on a container that generation still holds. Homing the row needs a live disable entry plus a live enable/rebind path in the plugin host — a product decision, not a test-side reason token. Inventing PluginRuntime::disable here would ship an "implemented-only" API with no caller, which the record's own ledger counts as not landed.

5. Discrimination proof

Worktree copied to $HOME/.hermes/cache/scratch/ctx-1830-proof/ with its own CARGO_TARGET_DIR; only the production hunks reverted (the test file unchanged):

test pgo_4_a_crash_inside_a_callback_presents_crashed_and_contains_the_damage ... FAILED
  crates/bitty-runtime/tests/panel_generation_ownership.rs:1261:
  assertion `left == right` failed: the crashed generation no longer binds its container
    left: Some(Generation(4294967297))   # controller_generation(1) — still bound
   right: None
test pgo_20_a_crashed_generation_is_bounded_and_loses_its_authority_at_the_next_bind ... FAILED
  crates/bitty-runtime/tests/panel_generation_ownership.rs:1405:
  every container of the crashed generation presents a placeholder
test result: FAILED. 0 passed; 2 failed

and the unit test pre-fix:

rollback_runs_the_generation_edge_with_the_crashed_reason ... FAILED
  mod.rs:6120: left: []  right: [(PluginId("bitty-featured.rollback-edge"), 7, Crashed)]

All three pass on the PR head.

6. Gates (all --offline, CARGO_TARGET_DIR=.targets/ctx-1830)

Command Exit
cargo fmt --all --check 0
cargo clippy -p bitty-runtime --all-targets -- -D warnings 0
cargo test -p bitty-runtime --test panel_generation_ownership 0 (15 passed, 0 failed)
cargo test -p bitty-runtime --test panel_rebind --test panel_placeholder_bounds 0 (11 + 6 passed)
cargo +1.85 check -p bitty-runtime --tests 0

Extra regression runs on the paths rollback shares, all exit 0: --lib (1628 passed), plugin_timers (17), rc1_wall_recovery (4), plugin_runtime (18), plugin_ui (25), overlay_capture_api (9), plugin_budgets (8).

7. Non-claims

  • No existing assertion deleted or weakened; the coverage map and the "still without a row" block are extended, and PGO-5/PGO-20-disable are named there with their blocking symbols instead of counted as covered.
  • No contract decided: the disable/enable live path and the PGO-15 fence remain open; status of the decision record is untouched (draft), and nothing here is claimed as acceptance evidence.
  • This PR is related to the issue named at the top and closes no issue.

bitty#2476 residual 4 named the events that run the panel generation edge and
`rollback` -- the one a *fault* reaches -- was not among them. A generation that
died inside a callback kept its container bound, kept its grant row, and
presented no placeholder at all: the silent orphan Decision E forbids, with
`PlaceholderReason::Crashed` having no production producer.

`PluginRuntime::rollback` now runs the same `release_panel_generation` edge
`dispose_inner` runs, after `clear_ui_blocks` released the generation's own
content and before the entry is reused, naming `PlaceholderReason::Crashed` and
the generation the rollback ended. The app-installed `PanelGenerationPort`
answers it through the existing delegation, so the retired-ceiling tombstone is
written, the four families are released, and only then is the placeholder
presented -- with no successor, because a crash is not a reload.

Rows homed in crates/bitty-runtime/tests/panel_generation_ownership.rs, both
driven through the real plugin host (a timer body that exhausts the
generation's own `[limits]` instruction budget, so the crash is the host's, not
the test's):

- PGO-4: container unbound and kept, reason `crashed`, release record and
  tombstone for the ended generation, one recovery record, sibling plugin's
  binding and grants untouched.
- PGO-20 (crash arm): one FS-4-style record, no respawn across two recovery
  passes, container/title/attachment/focus/MRU intact, and no authority of the
  crashed generation survives the successor's bind.

PGO-5 and PGO-20's disable arm are not homed: no production path disables a
live generation that still binds containers. They stay named in the file's
"still without a row" block with the blocking symbols rather than being faked
with a test-side reason token.

Unit test: plugin_runtime::tests::rollback_runs_the_generation_edge_with_the_crashed_reason.

Related #2476
@Xuepoo Xuepoo added this to the v0.1.0 milestone Nov 14, 2026
@Xuepoo Xuepoo added feat Feature P1 Priority: high area:panel Area: panel surface labels Nov 14, 2026
@coderabbitai

coderabbitai Bot commented Nov 14, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 12 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 16680192-9fa7-4d7e-bee3-ea71accbebb8
Commits

Reviewing files that changed from the base of the PR and between ce14e80 and 744a6d2.

Files selected for processing: 2

  • crates/bitty-runtime/src/plugin_runtime/mod.rs
  • crates/bitty-runtime/tests/panel_generation_ownership.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@Xuepoo Xuepoo left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Independent review — 744a6d256100f1ff1bcec372326d52f37ab1fd33

Reviewed by an independent reviewer (Hermes agent subagent, separate from the author and from the CTX-1830 lane), read-only on the lane worktree; every command below ran under target dirs outside it (ctx-1830-head, ctx-1830-msrv, and a scratch copy for the pre-fix arm at $HOME/.hermes/cache/scratch/rev-3163/proof).

1. Production change is the smallest correct one — PASS (one doc nit)

  • crates/bitty-runtime/src/plugin_runtime/mod.rs:5109 fn rollback; the ended generation is read at :5114 (self.entries.get(id).map(|entry| entry.generation)), before the entry is rewritten.
  • The edge is :5154-5155: if let Some(ended) = ended { self.release_panel_generation(id, ended, PlaceholderReason::Crashed); } — after clear_ui_blocks (:5135) and after the entry borrow ends (:5144), before any reuse. No successor is passed: release_panel_generation (:1846) takes (owner, ended, reason) only, and PanelEdgeRelease carries no successor field, so crash ≠ reload is enforced by the signature, not just by the call.
  • Port None still short-circuits at :1852-1854 before last_panel_edge is written, so headless behaviour is byte-for-byte the previous behaviour; rc1_wall_recovery (4) and the --lib rollback tests still pass with no port installed.
  • Nit (non-blocking): the body's "the same order dispose_inner uses" is slightly broader than the code. dispose_inner runs overlay_capture/presentation_overlay revokes (:3846, :3852) before the edge (:3863); rollback now runs the edge (:5155) before those revokes (:5162-5164, :5167-5169). Only the claim that matters holds (content release → edge → entry reuse), and present_placeholder touches only the registry, so nothing reads the capture/overlay state the edge now precedes. The sentence is worth narrowing to what is true.

2. Crashed has a real producer on the composition-root path — PASS

  • The only non-test producer in the tree is mod.rs:5155. Every other hit is either a token conversion (crates/bitty-ui/src/panel_recovery.rs:414/429/481/497) or inside #[cfg(test)] modules (crates/bitty-runtime/src/registry/panel.rs:5613+; crates/bitty-ui/src/panel_recovery.rs:1049).
  • Reachability: crates/bitty-terminal/src/terminal_app.rs:2996 drives pump_due_timers_at → fail_runtime_on_suspend (mod.rs:2524, :2567) → fail_runtime_classified (:5027) → rollback; the port is installed on that same runtime by the composition root at crates/bitty-terminal/src/plugin_runtime.rs:1226. So the producer is reachable in the binary, not only from tests.
  • PlaceholderReason::Crashed is a real reason token on the recovery side: crates/bitty-ui/src/panel_recovery.rs:1049 asserts "crashed" classifies to Placeholder(Crashed), so present_placeholder accepts it rather than rejecting it at registry/panel.rs:2301.

3. Tests drive the production seam and read the verb's own accessors — PASS (two assertions are corroboration, not load-bearing)

  • The seam is production: PluginRuntime::discover/activate/reload/pump_due_timers_at/recover_wall_failed_plugins/timer_deadline/last_panel_edge (tests/panel_generation_ownership.rs:1158-1246, :1475). The one test double is the PanelGenerationPort impl at :745-792, which mirrors AppPanelGenerationPort (crates/bitty-terminal/src/plugin_runtime.rs:829-897) line for line — panels_bound_to → present_placeholder on release, panels_bound_to + panels_ended_at → rebind_panel on bind — and the port call itself is separately pinned by the runtime's own unit test (mod.rs:6099, recording port, asserts (id, 7, Crashed)).
  • Load-bearing assertions (all of them fail or become unreachable without the hunk, because each reads state only present_placeholder writes via release_generation_scope, registry/panel.rs:2326-2400): :1261 container unbound; :1266 placeholder present; :1271 reason Crashed; :1275 unbound_generation == ended; :1280-1287 unbind_release_record names the generation with grants == 2; :1289 grant row empty; :1296-1298 retained ceiling under the right owner; :1300 recovery_attempts == 1; :1306 recovery_records().len() == 1; :1341/:1346 the edge attempted exactly one container and committed it; and in PGO-20 :1405-1414 per-container placeholder/one-record/unbound, :1475 reload, :1480-1497 rebound to controller_generation(2), placeholder cleared, crashed row still empty, successor row {CREATE, FOCUS}.
  • Corroboration only, and worth knowing when reading the rustdoc claims: :1439 timer_deadline() == None cannot detect a dropped timer, because timer_deadline (mod.rs:2425-2433) filters to LifecycleState::Active, so a Failed entry reports no deadline whether or not its timers survived; :1444/:1449 recover_wall_failed_plugins() == 0 follows from SuspendReason::InstructionBudgetExceeded → FailureClass::Unclassified (mod.rs:5045-5049) and would fail only if classification changed. Neither depends on the hunk. The sibling/title/attachment/focus/MRU assertions also pass pre-fix; they are containment evidence, not discrimination.

4. Discrimination — PASS (reproduced independently)

Pre-fix arm: worktree copied to $HOME/.hermes/cache/scratch/rev-3163/proof with .git removed, mod.rs reverted to HEAD~1, test file left at head, its own CARGO_TARGET_DIR:

test pgo_4_a_crash_inside_a_callback_presents_crashed_and_contains_the_damage ... FAILED
  tests/panel_generation_ownership.rs:1261:5
  assertion `left == right` failed: the crashed generation no longer binds its container
    left: Some(Generation(4294967297))   right: None
test pgo_20_a_crashed_generation_is_bounded_and_loses_its_authority_at_the_next_bind ... FAILED
  tests/panel_generation_ownership.rs:1405:18
  every container of the crashed generation presents a placeholder
test result: FAILED. 13 passed; 2 failed

Head, in a target dir that had never seen another checkout: cargo test -p bitty-runtime --test panel_generation_ownership --offline --locked → 15 passed; 0 failed. I also reproduced the unit test's arm separately (head mod.rs with only the two added statements removed, unit test kept): mod.rs:6130 left: [], right: [(PluginId("bitty-featured.rollback-edge"), 7, Crashed)] — the body's :6120 is the same assertion at a different file offset.

5. Claims vs reality (PGO-5 / PGO-20-disable "blocked-with-evidence") — PASS on substance, one body inaccuracy

Verified exactly as named: package::set_enabled (crates/bitty-runtime/src/plugin_runtime/package.rs:1441) only reads the index, flips record.enabled, writes it back and hardens it — its only non-test caller is crates/bitty-terminal/src/plugin.rs:7769; recover_wall_failed_plugins (mod.rs:3934) selects only LifecycleState::Failed(reason) with entry.failure_class == FailureClass::WallSliceTimeout (:3948-3953), the disabled branch is :3970 disposing at :3974; there is no fn disable/pub fn disable anywhere on PluginRuntime; suspend_inner (:3690-3754) asks the port for nothing; dispose names Unloaded (:3812); discover_inner skips a disabled record at :2852; crates/bitty-terminal/src/config_reload.rs:128 carries the quoted "no live apply path". Nothing in the test file claims the disable arm: disabled appears only in rustdoc (:64-91, :1368).

Inaccuracy (body only, no code impact): §2 says LifecycleEnforcer/EnforcementRecord "has no production consumer in bitty-runtime — nothing calls note_violation". The method is report_violation (crates/bitty-plugin-host/src/lifecycle.rs:303); note_violation exists nowhere in the tree. The substantive claim holds — LifecycleEnforcer has no reference under crates/bitty-runtime or crates/bitty-terminal, and report_violation is called only from crates/bitty-plugin-host/tests/{lifecycle,safe_recovery}.rs — but the symbol should be corrected in the body before it is quoted as evidence.

Two smaller accuracy points, both non-blocking: the PGO-4 row also says "sibling panels and terminals stay responsive (FS-P2)"; the test asserts sibling panels (and the FS-2 ladder clause is disclaimed), not terminals. And this hunk does remove the only route that could ever present disabled on a container the generation held (wall-timeout crash + disabled index now presents crashed, because the crash edge released the container first) — §4 of the body says this, but it is the kind of consequence worth calling a trade rather than a side note. Both are consistent with the PR's own "non-claims" section, so neither blocks.

6. MSRV 1.85 — PASS

Added code contains one if let Some(ended) = ended { (:5154) and no let-chain, no if let match guard, no let-else; grep over the added lines in both files found nothing else. cargo +1.85 check -p bitty-runtime --tests --offline --locked on the lane head exits 0 (1.85 toolchain is installed here), and clippy.toml declares msrv = "1.85" so the lint run below also checks API-level MSRV.

7. Clippy / test hygiene — PASS

cargo clippy -p bitty-runtime --test panel_generation_ownership --offline --locked -- -D warnings → exit 0 on the head; the test-target fingerprint under the head target dir was refreshed by that run (test-integration-test-panel_generation_ownership, 06:13), so the new file was actually linted, not skipped. Full file: 15 passed. Shared paths re-run here: panel_rebind 11, panel_placeholder_bounds 6, rc1_wall_recovery 4, --lib rollback_ 7 — all pass, matching the body's numbers.

8. Nothing unrelated — PASS

Two files only (+551/-12). The 12 deletions are the coverage-map paragraph, the "still without a row" block, the PGO-11 bullet (extended to mention rollback's Crashed), the import line, and the write_plugin → write_plugin_with extraction (:691-748), which is behaviour-preserving: empty extra_manifest and the same one-line init produce the identical manifest/init text. No assertion deleted or weakened, no #[allow]/#[expect] added (grep over the added lines), no drive-by formatting. The PGO-4/PGO-20 coverage-map rows and the blocked note are the decision-row content this PR is for.


Non-blocking follow-ups: correct note_violation → report_violation in the body; consider narrowing "the same order dispose_inner uses" to the ordering that is actually identical; the decision record's ledger entry (specifications/panel-generation-ownership-decision.md, row 9) still lists PGO-4/PGO-20 as unhomed — a docs sync, out of this tree by design.

VERDICT: APPROVE

@Xuepoo
Xuepoo merged commit d4cb95b into main Nov 14, 2026
21 checks passed
@Xuepoo
Xuepoo deleted the ctx-1830/pgo-crash-disable-rows branch November 14, 2026 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:panel Area: panel surface feat Feature P1 Priority: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant