Repository navigation
[CTX-1830] test(runtime): home PGO-4/PGO-5/PGO-20 crash and disable recovery rows (bitty#2476) - #3163
Conversation
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
|
Warning Review limit reachedYou'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. View limit details
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. |
Xuepoo
left a comment
There was a problem hiding this comment.
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:5109fn 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); }— afterclear_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, andPanelEdgeReleasecarries no successor field, so crash ≠ reload is enforced by the signature, not just by the call. - Port
Nonestill short-circuits at:1852-1854beforelast_panel_edgeis written, so headless behaviour is byte-for-byte the previous behaviour;rc1_wall_recovery(4) and the--librollback tests still pass with no port installed. - Nit (non-blocking): the body's "the same order
dispose_inneruses" is slightly broader than the code.dispose_innerrunsoverlay_capture/presentation_overlayrevokes (:3846,:3852) before the edge (:3863);rollbacknow runs the edge (:5155) before those revokes (:5162-5164,:5167-5169). Only the claim that matters holds (content release → edge → entry reuse), andpresent_placeholdertouches 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:2996drivespump_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 atcrates/bitty-terminal/src/plugin_runtime.rs:1226. So the producer is reachable in the binary, not only from tests. PlaceholderReason::Crashedis a real reason token on the recovery side:crates/bitty-ui/src/panel_recovery.rs:1049asserts"crashed"classifies toPlaceholder(Crashed), sopresent_placeholderaccepts it rather than rejecting it atregistry/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 thePanelGenerationPortimpl at:745-792, which mirrorsAppPanelGenerationPort(crates/bitty-terminal/src/plugin_runtime.rs:829-897) line for line —panels_bound_to→present_placeholderon release,panels_bound_to+panels_ended_at→rebind_panelon 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_placeholderwrites viarelease_generation_scope,registry/panel.rs:2326-2400)::1261container unbound;:1266placeholder present;:1271reasonCrashed;:1275unbound_generation == ended;:1280-1287unbind_release_recordnames the generation withgrants == 2;:1289grant row empty;:1296-1298retained ceiling under the right owner;:1300recovery_attempts == 1;:1306recovery_records().len() == 1;:1341/:1346the edge attempted exactly one container and committed it; and in PGO-20:1405-1414per-container placeholder/one-record/unbound,:1475reload,:1480-1497rebound tocontroller_generation(2), placeholder cleared, crashed row still empty, successor row{CREATE, FOCUS}. - Corroboration only, and worth knowing when reading the rustdoc claims:
:1439timer_deadline() == Nonecannot detect a dropped timer, becausetimer_deadline(mod.rs:2425-2433) filters toLifecycleState::Active, so aFailedentry reports no deadline whether or not its timers survived;:1444/:1449recover_wall_failed_plugins() == 0follows fromSuspendReason::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
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)2. Per-row result
tests/panel_generation_ownership.rs,pgo_4_a_crash_inside_a_callback_presents_crashed_and_contains_the_damagepgo_20_a_crashed_generation_is_bounded_and_loses_its_authority_at_the_next_bindSub-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 inbitty-runtime— nothing callsnote_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 withInstructionBudgetExceeded,fail_runtime_on_suspend→fail_runtime_classified→PluginRuntime::rollbackends 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}, andPlaceholderReason::Crashedhad no producer anywhere in the tree.rollbacknow callsrelease_panel_generation(id, ended, PlaceholderReason::Crashed)(:5155), afterclear_ui_blocksand before the entry is reused — the same orderdispose_inneruses — with no successor, because a crash is not a reload (OQ-084 A.2/E.1). PortNonekeeps the previous behaviour exactly, so headless builds are unaffected.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 reasoncrashednaming the ended generation;unbind_release_recordnames that generation with both grants released and the grant row empty;retained_grant_ceilingcarries 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() == 0twice); focus + MRU intact; afterreload, 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
disabledhas exactly one production producer:dispose_innercalled fromrecover_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 isFailedwithFailureClass::WallSliceTimeout. Nothing turns a live generation that still binds containers into adisabledone:PluginRuntimehas no disable entry;suspendparks a generation and asks the port for nothing, anddisposenamesunloaded;package::set_enabled(crates/bitty-runtime/src/plugin_runtime/package.rs:1441) only writes the store index, anddiscover_innerskips a disabled record without touching a live entry (mod.rs:2852);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
disabledcannot 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. InventingPluginRuntime::disablehere 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 ownCARGO_TARGET_DIR; only the production hunks reverted (the test file unchanged):and the unit test pre-fix:
All three pass on the PR head.
6. Gates (all
--offline,CARGO_TARGET_DIR=.targets/ctx-1830)cargo fmt --all --checkcargo clippy -p bitty-runtime --all-targets -- -D warningscargo test -p bitty-runtime --test panel_generation_ownershipcargo test -p bitty-runtime --test panel_rebind --test panel_placeholder_boundscargo +1.85 check -p bitty-runtime --testsExtra regression runs on the paths
rollbackshares, 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
PGO-15fence remain open;statusof the decision record is untouched (draft), and nothing here is claimed as acceptance evidence.