Skip to content

[CTX-1870] feat(runtime,ui): home the AC-1 presentation-mode clause at the generation rebind edge (bitty#2476) - #3219

Merged
Xuepoo merged 3 commits into
mainfrom
ctx-1870/presentation-seam
Nov 17, 2026
Merged

Xuepoo merged 3 commits into
mainfrom
ctx-1870/presentation-seam

Conversation

@Xuepoo

@Xuepoo Xuepoo commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

What this homes

bitty#2476 AC-1's PresentationMode clause: a reload-driven rebind leaves the panel's presentation
mode intact
— as an observably production fact, not an assertion over a tree a test built.

The mode is a workspace fact on the leaf View (crates/bitty-ui/src/view.rs:227, stamped through
the single gate crates/bitty-ui/src/presentation.rs:157). PanelRuntime holds a Placement mirror,
leases, and scenes, never a LayoutNode, so the host can neither write nor read the mode, and
PanelRuntime::rebind_panel presents nothing. Until now the only would-be row built its own layout,
so it stayed green with the reload edge deleted.

Shape chosen: (a) observe-and-record, not (b) re-present. (b) would add a re-assert step at a seam
that presents nothing, on a per-reload path no consumer reads. (a) records a read of the retained
leaf and exposes one accessor.

The seam (shape (a), with the report split where the layout is)

AppPanelGenerationPort cannot reach a layout (the app owns Runtime, and the port lives inside
PluginRuntime, which TerminalApp mutably borrows on the reload call — a self-referential handle),
so the bind edge names the retained leaf and the app's existing generation-edge drain reads and
records
it. No new public parameter that never varies, no stored duplicate of the truth.

Step Location
bind edge names the retained leaf crates/bitty-terminal/src/plugin_runtime.rs:1153 (bind_successor, Ok(committed) arm, placement_view_of)
new op crates/bitty-terminal/src/plugin_runtime.rs:589 (PluginPanelLayoutOp::ObservePresentation { panel_id, view_id })
production drain crates/bitty-terminal/src/terminal_app.rs:4397 (TerminalApp::apply_plugin_panel_requests → record_plugin_panel_presentation)
leaf read (cross-container) crates/bitty-runtime/src/runtime/layout_focus.rs:2550 (Runtime::view_presentation, layout / floats / pins / scratchpads)
read-only record crates/bitty-runtime/src/registry/host.rs:1121 (PanelRuntime::note_presentation_observation)
single accessor crates/bitty-runtime/src/registry/host.rs:1146 (presentation_observation_of)
row type crates/bitty-runtime/src/registry/host.rs:238 (PanelPresentationObservation { view, mode })
dropped with the record crates/bitty-runtime/src/registry/host.rs:639 (release_panel_mirrors)

Nothing derives placement, paint, a lease, or a grant from the observation. Rows are keyed by panel,
replaced at the next observation (bounded by live panels), and dropped by dispose_panel, so the
leaf stays the only truth and the row can never outlive its container or name a leaf a later panel
occupies. presentation_observation_of therefore has no production caller — only the two test
files read it — which is the declared evidence design and is now said the same way in the code (see
"homed as a report" below).

The one behaviour change this required

A reload's release no longer queues PluginPanelLayoutOp::Close
(crates/bitty-terminal/src/plugin_runtime.rs:1075). The release reason is the closed vocabulary's
PlaceholderReason::Reloaded; every other reason still closes the leaf.

Why, precisely — the ordering matters, because the old failure was the opposite of a failed bind:

  • The Close is queued, not applied. It drains in the app's next tick, i.e. after
    bind_successor on the same edge has already committed. So the old code rebound the container
    successfully and then, one tick later, close_plugin_panel_leaf
    (crates/bitty-terminal/src/chrome_keys.rs:1551) removed its leaf and disposed the just-rebound
    record. That is the defect worth writing down: a successful reload whose container and record
    were destroyed immediately afterwards
    . Nothing in the bind failed, and no not rebound refusal
    was ever logged. (Measured: restoring the old close leaves the bind silent and drops
    panel_count() to 0 on the following tick.)
  • What a reload retains is the container and its leaf, not the placeholder.
    PanelRegistry::rebind_panel clears record.placeholder in D.2 phase 2 step 2
    (crates/bitty-runtime/src/registry/panel.rs:4342) and detach_panel_scene has already removed
    the render scene before the bind, so the rebound container is bound, placeholder-free and
    scene-less. The placeholder a release presents is the transient state between the release and the
    successor bind — it is not something the retained container keeps presenting.

The previous row (plugin_panel_generation_dispose_and_reload_remove_dwindle_leaf) asserted the old
behaviour; it is split: dispose still removes the leaf, reload now keeps container + leaf and is
covered by the new row. reload_inner's own doc already says a reload that fails before its
successor activates "leaves the containers presenting the reload placeholder"
(crates/bitty-runtime/src/plugin_runtime/mod.rs:4184), which is only true if the container stays —
and is one of the two end states this PR does not prove, listed below.

Call chain (grep-confirmed, not assumed)

PluginRuntime::reload                       crates/bitty-runtime/src/plugin_runtime/mod.rs:3992
 └ reload_inner                              .../plugin_runtime/mod.rs:4162
   ├ dispose_inner(.., PlaceholderReason::Reloaded)          :4188
   │  └ release_panel_generation → port.release_generation   :1900
   │     └ AppPanelGenerationPort::release_generation (no Close on Reloaded)
   ├ activate_inner                                           :4206
   └ bind_panel_generation → port.bind_successor              :1929
      └ AppPanelGenerationPort::bind_successor                crates/bitty-terminal/src/plugin_runtime.rs:1095
         ├ PanelRuntime::rebind_panel                         crates/bitty-runtime/src/registry/host.rs:494
         └ push ObservePresentation (retained leaf)           crates/bitty-terminal/src/plugin_runtime.rs:1157
TerminalApp::apply_plugin_panel_requests                      crates/bitty-terminal/src/terminal_app.rs:4375
 └ record_plugin_panel_presentation                           crates/bitty-terminal/src/terminal_app.rs:4418
    ├ Runtime::view_presentation                              crates/bitty-runtime/src/runtime/layout_focus.rs:2550
    └ PanelRuntime::note_presentation_observation             crates/bitty-runtime/src/registry/host.rs:1121

AppPanelGenerationPort is installed by the composition root (discover_with_roots,
crates/bitty-terminal/src/plugin_runtime.rs:1488), and panel_layout_ops reaches the app in
main.rs:1300 → TerminalApp::with_panel_layout_ops, so the drain is the live per-tick path
(terminal_app.rs:2528), not a test harness.

Test rows and their real test result: lines

New row, on the production chain end to end (composition root → AppPanelGenerationPort → app drain;
the test's only authored input is the mode stamp, applied through the production gate
PresentationMode::request_transition):

  • plugin_runtime::tests::a_reload_keeps_the_leaf_and_reports_the_presentation_mode_it_retained
    (crates/bitty-terminal/src/plugin_runtime.rs:5067) — creates a panel through the real verb, ticks
    (leaf materialized), stamps Floating, reloads, ticks, then asserts the container survived, the
    leaf is the same ViewId, the controller generation moved, and
    presentation_observation_of(panel) == Some(PanelPresentationObservation { view, mode: Floating }).
  • registry::host::tests::presentation_observation_is_recorded_replaced_and_cleared
    (crates/bitty-runtime/src/registry/host.rs) — record / replace / refuse-unknown / drop-on-dispose.
  • plugin_runtime::tests::plugin_panel_generation_dispose_removes_the_dwindle_leaf — the split-out
    dispose half. What is unchanged is the assertion quartet (leaf_count 2 → 1, panel_count 0),
    now run against a path — dispose — that this row did not previously touch: the old row only ever
    called reload. It is not "dispose behaviour unchanged"; the assertion set simply moved onto a path
    it had never exercised.
$ cargo test -p bitty-terminal --bin bitty --offline presentation_mode_it_retained
test plugin_runtime::tests::a_reload_keeps_the_leaf_and_reports_the_presentation_mode_it_retained ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 1647 filtered out; finished in 0.07s

$ cargo test -p bitty-terminal --bin bitty --offline            # whole bin suite (regression)
test result: ok. 1648 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 4.51s

$ cargo test -p bitty-runtime --lib --offline
test result: ok. 1680 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 10.50s

$ cargo test -p bitty-runtime --test panel_generation_ownership --test panel_rebind \
      --test panel_unbind_release --test panel_grant_ceiling --offline
tests/panel_generation_ownership.rs  test result: ok. 19 passed; 0 failed; 0 ignored
tests/panel_grant_ceiling.rs         test result: ok. 19 passed; 0 failed; 0 ignored
tests/panel_rebind.rs                test result: ok. 12 passed; 0 failed; 0 ignored
tests/panel_unbind_release.rs        test result: ok.  8 passed; 0 failed; 0 ignored

Every existing assertion in crates/bitty-runtime/tests/panel_generation_ownership.rs is kept. Its
blocking note (:2323) was rewritten to say what is asserted and where, and to record what is still
not proven there; the module-doc coverage table (:63, clause now described as "homed as a
report") and the "still without a row" list were updated the same way.

Discrimination proof (scratch copy, own CARGO_TARGET_DIR, never the lane worktree)

Copy at $SCRATCH/ctx-1870-mutation/tree (CARGO_TARGET_DIR=$SCRATCH/ctx-1870-mutation/target);
each mutation applied there only, row re-run, then restored and re-run green.

  1. Delete the production bind edge's report. bind_successor's
    push_panel_layout_op(PluginPanelLayoutOp::ObservePresentation …) replaced with let _ = (queue, view_id);
    → panicked at crates/bitty-terminal/src/plugin_runtime.rs:5152:
    assertion left == right failed: the reload edge reports the mode the retained leaf still presents
    left: None / right: Some(PanelPresentationObservation { view: ViewId(2), mode: Floating }).
  2. Delete the app drain's consumption. The ObservePresentation arm in
    apply_plugin_panel_requests reduced to let _ = (panel_id, view_id);
    → panicked at crates/bitty-terminal/src/plugin_runtime.rs:5155: same assertion,
    left: None / right: Some(PanelPresentationObservation { view: ViewId(2), mode: Floating }).
  3. Restore the old reload close. if !matches!(edge.reason, PlaceholderReason::Reloaded)
    forced true → bitty: panel 1 presentation not observed (leaf ViewId(2) is gone) then
    panicked at crates/bitty-terminal/src/plugin_runtime.rs:5129:
    assertion left == right failed: a reload retains the container for its successor (D.3)
    left: 0 / right: 1.

Restored → test result: ok. 1 passed; 0 failed; …. The row is sensitive to the edge, the drain, and
the retention; it is not tautological. The independent review added two more mutations of its own
(drain recording a constant Tiled instead of the read mode → fails on the value; Unloaded also
skipping Close → kills the dispose row), both of which also discriminate.

Gates (exit codes, as run)

Gate Exit
cargo fmt --check 0
cargo clippy -p bitty-runtime -p bitty-terminal --all-targets --offline -- -D warnings 0
cargo test -p bitty-runtime --test panel_generation_ownership --test panel_rebind --test panel_unbind_release --test panel_grant_ceiling --offline 0
cargo test -p bitty-runtime --lib --offline 0
cargo test -p bitty-terminal --bin bitty --offline 0
cargo +1.85 check -p bitty-runtime -p bitty-terminal --tests --offline (MSRV: no let-chains / if let guards) 0
RUSTFLAGS="-D warnings" cargo check -p bitty-runtime -p bitty-terminal --tests --target x86_64-pc-windows-gnu --offline 0
RUSTFLAGS="-D warnings" cargo check -p bitty-runtime -p bitty-terminal --tests --target aarch64-apple-darwin --offline 0
RUSTDOCFLAGS="-D warnings" cargo doc -p bitty-runtime --no-deps --offline 0

The two cross-target legs are compile-only (no cross-runner): they prove both crates and their
test targets type-check for Windows GNU and Apple aarch64, nothing about behaviour there. just ci-local was not run (another lane holds it).

What this does not prove

  • No Core path consumes the observation: it is read-only evidence with one accessor. The row
    proves the production edge and the production drain produce the report; it does not prove a
    placement, paint, or grant decision depends on it.
  • The drain applies the report on the tick after the bind (the app drains queued layout ops per
    tick), so this is evidence of the leaf's mode at the edge, not a synchronous part of the bind
    transaction. In the row the bind and the drain are separate steps for exactly that reason.
  • The leaf read covers layout, detached floats, pins and scratchpads, but a panel with no
    attachment (suspended + unmounted, PGO-2) queues nothing and therefore records nothing.
  • PluginRuntime::reload still has no non-test caller in bitty-terminal (only tests and
    discover_probe-built sessions drive it); this change homes the clause at the rebind edge, it does
    not add a user-visible reload trigger.
  • A successful reload leaves the retained leaf presenting nothing. The release detached its render
    scene and rebind_panel clears the placeholder record, and the successor does not re-present that
    leaf — bitty.panel.create mounts a new container — so a reload can leave a content-less pane
    beside whatever the successor creates. No row asserts what the retained leaf paints in that
    window.
  • A reload that fails after dispose_inner leaves its containers stuck. If reload_inner's
    store re-resolution or activate_inner returns Err, or the successor bind is refused, the
    containers stay in the Reloaded placeholder and no Close is ever queued (the old code
    removed them a tick later). A later reload does not repair them either: held() enumerates
    panels_ended_at(owner, predecessor) and the next reload names the generation that just ended, so
    those records keep presenting "Its plugin is reloading." until the plugin is disposed or the pane is
    closed. No row covers this arm.
  • The reload-retention change is asserted at the port/drain level, not against a real window; the
    headless TerminalApp is the production composition root minus the window.

Both end states of the retention change are therefore named and unmeasured — here and in
pgo_1_container_facts_survive_the_rebind_edge's rustdoc
(crates/bitty-runtime/tests/panel_generation_ownership.rs:2360, "What the retention change does
not measure") and in the module header's PGO-1 bullet.

Round 3 — review follow-up (F1–F4)

Independent review at 94b70bab returned CHANGES-REQUESTED on accounting only ("I found no code
defect in it"). f4b573cc addresses all four findings, comment/rustdoc only, no behaviour change:

Finding Disposition Where
F1 — rationale misstates the old ordering and what survives fixed crates/bitty-terminal/src/plugin_runtime.rs:1057-:1074 (comment) and "The one behaviour change this required" above: the Close was deferred one tick (bind succeeded, container died afterwards), and the container + leaf survive — not the placeholder
F2 — the change's two new end states neither covered nor disclaimed disclaimed (the review accepted either) "What this does not prove" above (two bullets) + crates/bitty-runtime/tests/panel_generation_ownership.rs:2360-:2381 + the module header's PGO-1 bullet (:116)
F3 — dispose row is not "unchanged behaviour" fixed crates/bitty-terminal/src/plugin_runtime.rs:5002-:5009 and the test-row bullet above: the assertion quartet is unchanged, the path (dispose) is new for it
F4 — table says "homed" for a seam with no production caller fixed crates/bitty-runtime/tests/panel_generation_ownership.rs:63 — "homed as a report", with the missing consumer named

Gates re-run at f4b573cc from the lane worktree with CARGO_TARGET_DIR pinned outside it:

$ cargo fmt --all -- --check                                             exit 0
$ cargo clippy -p bitty-runtime -p bitty-terminal --all-targets --offline -- -D warnings
                                                                         exit 0
$ cargo test -p bitty-runtime --test panel_generation_ownership --offline
test result: ok. 19 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.02s
$ cargo test -p bitty-terminal --bin bitty --offline presentation_mode_it_retained
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 1647 filtered out; finished in 0.06s
$ cargo test -p bitty-terminal --bin bitty --offline plugin_panel_generation
test plugin_runtime::tests::plugin_panel_generation_dispose_removes_the_dwindle_leaf ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 1647 filtered out; finished in 0.07s
$ cargo +1.85 check -p bitty-runtime --tests --offline                    exit 0

No assertion was weakened or deleted in this round: the diff touches doc comments, one code comment,
and one test comment. (The round-2 numbers in the table above stand for the unchanged rows.)

One reference correction: round 2's body cited the note as "panel_generation_ownership.rs:2323"; the
file is crates/bitty-runtime/**tests**/panel_generation_ownership.rs (the note starts at :2323;
this round's new "what it does not measure" section is at :2360-:2381), not src/runtime/. The
review's own citations point at the same file.

Related #2476

…n mode at the reload rebind edge

bitty#2476 AC-1 asks that a reload-driven rebind leave the panel's
presentation mode intact. The mode is a workspace fact on the leaf View,
so the panel host neither writes nor reads it: the clause had no
production observer, and a row over a test-built tree stayed green with
the edge deleted (the tautology a reviewer measured).

The bind edge now names the leaf the rebind retained and the app's
existing generation-edge drain records what that leaf presents:

- AppPanelGenerationPort::bind_successor queues
  PluginPanelLayoutOp::ObservePresentation{panel_id, view_id} per
  committed rebind, naming the leaf the placement mirror still holds.
- TerminalApp::apply_plugin_panel_requests drains it:
  Runtime::view_presentation (new, across layout/floats/pins/
  scratchpads) -> PanelRuntime::note_presentation_observation.
- PanelRuntime::presentation_observation_of is the single read. Nothing
  derives placement, paint, a lease, or a grant from the row, rows are
  replaced at the next observation, and dispose drops them, so the leaf
  stays the only truth.

A reload's release no longer queues PluginPanelLayoutOp::Close: that
release is not terminal for the container, the same edge rebinds it, and
the placeholder it presents is written into that container, so closing
the leaf destroyed the presentation the edge exists to retain. Every
other PlaceholderReason still closes the leaf.

Test: a new row on the production chain (composition root -> port ->
app drain) asserts the retained Floating mode; the dispose-and-reload
row is split so dispose still removes the leaf.
@Xuepoo Xuepoo added feat Feature P1 Priority: high area:panel Area: panel surface labels Nov 17, 2026
@coderabbitai

coderabbitai Bot commented Nov 17, 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 3 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: ff5e5db4-8fc2-4c08-a798-32ca92a5548f
Commits

Reviewing files that changed from the base of the PR and between 361fa06 and 618006e.

Files selected for processing: 5

  • crates/bitty-runtime/src/registry/host.rs
  • crates/bitty-runtime/src/runtime/layout_focus.rs
  • crates/bitty-runtime/tests/panel_generation_ownership.rs
  • crates/bitty-terminal/src/plugin_runtime.rs
  • crates/bitty-terminal/src/terminal_app.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 — 94b70bab2132bf4d98ed567b7addc92056aac0c0

Reviewed read-only against main (5 files, +467/−54). Every claim below was checked in the code, not taken from the description; the mutation work ran on a copy outside the lane worktree with its own CARGO_TARGET_DIR.

Claim by claim

# Claim Result
1 ObservePresentation{panel_id, view_id} queued per committed rebind, from the placement mirror the rebind leaves untouched PASS — variant plugin_runtime.rs:589; queued in bind_successor :1112–:1128 off placement_view_of :1119. PanelRuntime::rebind_panel writes binding + lease + ceiling only (registry/host.rs:494), so the mirror is genuinely untouched by the bind. The mutable borrow is split into rebound first, so no RefCell double-borrow at the read-back.
2 Drain → record_plugin_panel_presentation → Runtime::view_presentation → note_presentation_observation → single accessor → dropped in release_panel_mirrors PASS — terminal_app.rs:4397, :4418; layout_focus.rs:2550 (find_view :2533 covers layout, detached floats, pins, scratchpads); registry/host.rs:1121, :1146, row type :238; cleared at host.rs:639, reached from dispose_panel :423 and dispose_workspace_panels :448. note_presentation_observation refuses a non-live panel (:1128), so a row cannot outlive its record.
3 No paint/placement/grant consumer PASS — grep for presentation_observation_of|note_presentation_observation|PanelPresentationObservation outside host.rs matches only doc prose, the drain write, and the two test files. Nothing in the present loop, Placement, the lease table, or the grant path reads it. "Evidence, not truth" is accurate.
4 Other PlaceholderReasons still close PASS, with a caveat — :1064 is the only producer of PluginPanelLayoutOp::Close; only Reloaded skips it. Production reasons that reach release_generation are Reloaded (plugin_runtime/mod.rs:4188), Unloaded (:3885), Disabled (:4114), Crashed (:5345); Suspended/Denied/Incompatible have no producer at this edge, so no leaf is left behind for a container that closes. See F2 for the states this creates.
5 Split did not silently drop a dispose assertion PASS — git diff hunk: the old row asserted leaf_count()==2 → reload → leaf_count()==1 + panel_count()==0; the dispose row asserts the same four things with dispose in the middle. Nothing was dropped. See F3 on the wording.
6 Rows and counts PASS — re-run here: presentation_mode_it_retained → 1 passed / 1647 filtered; whole bin suite 1648 passed; bitty-runtime --lib 1680; panel_generation_ownership 19, panel_grant_ceiling 19, panel_rebind 12, panel_unbind_release 8. All match the PR.
7 Discrimination (not tautological) PASS — reproduced, plus two mutations of my own; see below.
8 Doc honesty at panel_generation_ownership.rs:2323 and in "What this does not prove" PASS for the note — :2345 says plainly that the row proves "the report, not the invariant", which is the honest reading. One body/comment defect, F1.
9 API surface, MSRV PASS — cargo +1.85 check -p bitty-runtime -p bitty-terminal --tests exits 0 here; no let-chains, no if let guards, let-else only. No #[allow(dead_code)] anywhere in the diff, no test-only widening, no parameter that never varies. Note F4.
10 Scope vs the brief NECESSARY, not smuggled — the observation shares the tick with the Close and drains after it, so with the old close the row is None by construction, and "mode intact" is false if the leaf does not exist. Retention is the precondition for the clause to be observable in production and it is what D.3/A.2 already say. It is under-accounted for, not unjustified (F1, F2).

Discrimination proof (copy at $SCRATCH/ctx1870-review-mut/tree, own CARGO_TARGET_DIR)

Mutation Result
A bind edge stops queueing (let _ = (self.layout_ops.as_ref(), panel_id);, plugin_runtime.rs:1120) FAILS — panicked at plugin_runtime.rs:5146: assertion left == right failed: the reload edge reports the mode the retained leaf still presents / left: None / right: Some(PanelPresentationObservation { view: ViewId(2), mode: Floating })
B drain stops recording (terminal_app.rs:4401 → let _ = (panel_id, view_id);) FAILS — same assertion at :5153, left: None, same right
C old close restored (!matches!(Reloaded) → !matches!(Suspended)) FAILS — panicked at :5130: assertion left == right failed: a reload retains the container for its successor (D.3) / left: 0 / right: 1, preceded by bitty: panel 1 presentation not observed (leaf ViewId(2) is gone)
D (mine) drain records a constant PresentationMode::Tiled instead of the read mode FAILS — left: Some(PanelPresentationObservation { view: ViewId(2), mode: Tiled }) / right: Some(… mode: Floating }). Proves the mode value is read from the leaf, not merely that a row exists; the PR did not show this.
E (mine) Unloaded also skips Close FAILS — the dispose row dies at :5032 (drive_tick returned None), so the split's dispose half is not vacuous.

Each mutation restored afterwards; the tree returns to 1 passed / 1648 passed. The row is sensitive to the edge, the drain, the retention, and the mode value.

F1 — the rationale for the only behaviour change misstates the old ordering and what is retained (fix before merge)

Two statements are false, and both are load-bearing for a future reader deciding whether !matches!(…Reloaded) is safe:

  1. Ordering. PR body: "left the bind edge rebinding a container whose leaf was already gone." The Close is queued, so it drains in the app's next tick, i.e. after bind_successor has already committed. Mutation C shows the ordering directly: no not rebound warning from the bind, the leaf is still there at bind time, and the drain then reports leaf ViewId(2) is gone while panel_count() drops to 0. So the old defect was not a failed rebind — it was a successful rebind whose container and record were destroyed one tick later (via close_plugin_panel_leaf → dispose_panel). That is the more serious bug and the one worth writing down, because it is what a future reader must not re-introduce.
  2. What survives. The retained presentation is not the placeholder. PanelRegistry::rebind_panel clears record.placeholder = None at phase 2 step 2 (registry/panel.rs:4342), and detach_panel_scene (plugin_runtime.rs:1056) removed the render scene before the bind. After a successful reload the container is bound, placeholder-free and scene-less. The comment at :1057–:1063 ("the placeholder this release just presented is written into that container … the very presentation the edge exists to retain") and the body's shape-(a) argument both read as if the placeholder outlives the bind.

Fix: rewrite plugin_runtime.rs:1057–:1063 and the body's "The one behaviour change this required" paragraph to say (i) the close was deferred and killed the just-rebound container rather than the rebind, and (ii) what is retained is the container and its leaf, not the placeholder.

F2 — the behaviour change's consequences are neither measured nor listed (fix before merge)

The PR's whole claim set is about what is and is not proven, so the consequences of its one semantic change belong in it:

  • After a successful reload the retained leaf presents nothing until the successor mounts a scene, and bitty.panel.create mounts a new container — so a reload can leave a content-less pane beside whatever the successor creates. No row covers it and "What this does not prove" does not name it.
  • A reload that fails after dispose_inner (resolution/activation Err in reload_inner) or whose successor bind is refused leaves the containers in the Reloaded placeholder with no Close ever queued. The old code removed them. Worse, held() enumerates panels_ended_at(owner, predecessor), so a later reload of the same plugin names a different predecessor generation and cannot rebind those orphans — they stay "Its plugin is reloading." until the plugin is disposed or the user closes the pane.

Either add a row for one of these two, or add both to "What this does not prove" and to the note at panel_generation_ownership.rs:2323. No code change is demanded — the claim set is.

F3 — non-blocking, wording

The dispose row is described as "unchanged behaviour", but the old row only ever called reload; it never exercised dispose. What is unchanged is the assertion quartet, now run against a path this row did not previously touch. Say that, rather than implying dispose was already covered here.

F4 — non-blocking, note

presentation_observation_of has no production caller (only the two test files). That is consistent with the declared "evidence" design and it is not hidden behind #[allow(dead_code)], so I am not treating it as a defect — but the module table at panel_generation_ownership.rs:63 says the clause is "homed" without qualification, which reads stronger than "reported". The doc comment at :2345 defuses it; the table would too if it said "homed as a report".

On #4's other-reason question

No other reason can now leak a leaf into a closed container: Close is still queued for every non-Reloaded release and it removes the leaf and disposes the record, so those paths end with neither. The pre-existing asymmetry is the opposite one — Disabled/Unloaded say the container "keeps its container and state" and that re-enabling "permits a rebind" (bitty-ui/src/panel_recovery.rs:235, :240), yet they close the leaf and dispose the record, so no rebind is possible afterwards. That predates this PR and is out of scope; I mention it only because the new !matches! makes the asymmetry explicit.

Bottom line

The seam is real, single-sourced, consumer-free, discriminating, MSRV-clean, and it homes the clause the way the brief asked. I found no code defect in it. What blocks is the accounting around its one behaviour change: the stated rationale is wrong about both ordering and what survives (F1), and the change's two new end states are neither covered nor disclaimed (F2). Both are text-level fixes plus one coverage/caveat addition.

VERDICT: CHANGES-REQUESTED

@Xuepoo

Xuepoo commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

Guard tick (2026-11-17 19:10 CST): independent review landed, round 2 required — not merging

The independent review on 94b70bab posted VERDICT: CHANGES-REQUESTED. The seam itself passed every check (the observation is queued off the untouched placement mirror, drained and stored read-only, has no consumer on any paint/placement/grant path, and the author's mutation claims were reproduced plus two extra mutations — a constant Tiled value reds the row, so the value really is read). Two textual/accounting items block:

  • F1 — the stated rationale for dropping Close on reload is false in two ways. Close was queued, so it drained a tick after the bind committed: the old code did not rebind a container whose leaf was already gone, it rebound successfully and then destroyed container + record one tick later. And the retained presentation is not the A.2 placeholder: rebind_panel clears record.placeholder (registry/panel.rs:4342) and detach_panel_scene already ran, so a successful reload leaves a bound, scene-less container.
  • F2 — the change's two new end states are neither covered nor disclaimed: (a) a successful reload leaves a content-less retained pane (nothing re-presents; panel.create mounts a new container), and (b) a refused/failed reload leaves Reloaded placeholders with no Close ever queued, and held() keys on the predecessor generation so a later reload cannot reach them.

Round 2 must therefore do one of these, and say which in the PR body:

  1. Revert the Close removal and re-point the AC-1 row so it observes the mode at the bind edge while the pre-existing release behaviour stays intact; or
  2. Keep retention (if the one-tick-later destruction is judged a real bug — it plausibly is, but it is a reload leaf-lifetime change, not part of AC-1), with the corrected rationale and both new end states covered by a row each (content-less retained pane; unreachable Reloaded placeholder).

Option 2 changes reload semantics and needs the owner/commander's call, so it is not a call this lane should take on its own. Recording it as an open question against bitty#2476 rather than shipping it inside an AC-1 seam.

Also asked in round 2 (non-blocking): F3 (the dispose row now exercises a path the old row never did — "unchanged behaviour" is a loose phrase) and F4 (presentation_observation_of has no production caller; acceptable under the declared design, but the module table should say "reported", not "homed").

CI context: Linux X11 (xvfb) red on this head is not this PR — both failing rows are crates/bitty-terminal/tests/cli_config_fail_soft.rs:239 / :327 panicking on RC-1 WallClockExceeded { elapsed_ms: 153/162, budget_ms: 50 }, i.e. the config-Lua wall budget under runner load. Supply chain red is repo-wide: bitty#3220 (RUSTSEC-2026-0543, chrono unmaintained, no safe upgrade) — it blocks every PR, not this one.

…ale and disclaim its end states (bitty#2476)

Round-3 accounting fix for the independent review's F1 and F2, plus the two
non-blocking wording findings (F3, F4). Comment and rustdoc only; no behaviour
change.

F1 — the rationale for the one behaviour change was wrong about both ordering
and what survives. `PluginPanelLayoutOp::Close` is *queued*, so it drains in the
app's next tick, after `bind_successor` has already committed
(`plugin_runtime.rs:1057`-`:1073`). The old defect was therefore not a bind
rebinding a leaf-less container: the bind succeeded, and one tick later
`close_plugin_panel_leaf` removed the leaf and disposed the just-rebound record.
What a reload retains is the container and its leaf, not the placeholder —
`PanelRegistry::rebind_panel` clears `record.placeholder` in D.2 phase 2 step 2
(`registry/panel.rs:4342`) and `detach_panel_scene` has already taken the render
scene, so a rebound container is bound, placeholder-free and scene-less.

F2 — the two end states the retention change introduces are now named as
unmeasured in `pgo_1_container_facts_survive_the_rebind_edge`'s rustdoc
(`panel_generation_ownership.rs:2349`-`:2371`) and in the module header's PGO-1
bullet: (a) a successful reload leaves the retained leaf presenting nothing
until a successor mounts a scene, while `bitty.panel.create` mounts a new
container; (b) a reload failing after `dispose_inner` or with a refused
successor bind leaves containers in the `Reloaded` placeholder with no `Close`
ever queued, and `held()`'s `panels_ended_at(owner, predecessor)` key means a
later reload cannot rebind those orphans. Written down rather than given a row;
the review asked for either.

F3 — the split dispose row no longer claims "unchanged behaviour": what is
unchanged is the assertion quartet, now run against a path (`dispose`) the row
did not previously touch.

F4 — the module table says the clause is homed **as a report**, since
`presentation_observation_of` has no production caller.

@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 round 3 (guard-dispatched, agent: auditor)

Scope — 94b70bab..f4b573cc is comment/rustdoc-only (proved, not assumed)

Command ($SCRATCH/recheck-3219/scope-proof.sh, run in the repo root):

STRIP='^[[:space:]]*(//|\*|/\*|\*/|$)'
for f in crates/bitty-runtime/tests/panel_generation_ownership.rs \
         crates/bitty-terminal/src/plugin_runtime.rs; do
  diff -q <(git show 94b70bab:"$f" | grep -vE "$STRIP") \
          <(git show f4b573cc:"$f" | grep -vE "$STRIP")
done
git diff 94b70bab..f4b573cc | grep -E '^[+-]' | grep -vE '^(\+\+\+|---)' \
  | grep -vE '^[+-][[:space:]]*//' | grep -vE '^[+-][[:space:]]*$' | wc -l

Output:

crates/bitty-runtime/tests/panel_generation_ownership.rs: identical after comment strip
crates/bitty-terminal/src/plugin_runtime.rs: identical after comment strip
--- non-comment, non-blank added/removed lines in the range ---
0
--- files touched ---
M	crates/bitty-runtime/tests/panel_generation_ownership.rs
M	crates/bitty-terminal/src/plugin_runtime.rs

Two files, zero executable lines changed: no statement, expression, argument, attribute or assertion moved. PASS. (PR-body edit is a GitHub-side change and cannot smuggle code.)

F1 — the corrected rationale matches the code (verified from the source, not from the body)

(a) the Close is queued, and drains after bind_successor commits.

  • AppPanelGenerationPort::release_generation (crates/bitty-terminal/src/plugin_runtime.rs:1019) only pushes into the shared queue: push_panel_layout_op(queue, PluginPanelLayoutOp::Close { … }) at :1075–:1085. Nothing is applied at release time.
  • There is exactly one drain: TerminalApp::apply_plugin_panel_requests (crates/bitty-terminal/src/terminal_app.rs:4375), called from one place, drive_tick :2528; its Close arm is :4394 → close_plugin_panel_leaf (crates/bitty-terminal/src/chrome_keys.rs:1551), which removes the layout leaf (:1567–:1581) and then disposes the record via dispose_panel (:1583–:1588).
  • Ordering inside the reload: reload_inner (crates/bitty-runtime/src/plugin_runtime/mod.rs:4162) → dispose_inner(…, Reloaded) :4188 → release_panel_generation :3941 → port :1900; then activate_inner :4206 and bind_panel_generation :4224 → port.bind_successor :1929 → PanelRegistry::rebind_panel (plugin_runtime.rs:1112). No drain call exists anywhere between release and bind, so the leaf cannot be closed before the bind commits on any path.
  • Production reaches this: the only non-test generation-reload driver is recover_wall_failed_plugins* (terminal_app.rs:2878, :3160, :3164), which runs after :2528 in the same drive_tick; the queue emptied at :2528 therefore cannot contain the Close that reload queued, so it drains on the following drive_tick.

So the old code rebound successfully, then a queued Close removed the leaf and disposed the just-rebound record — the comment's "a successful reload whose container and record were destroyed right afterwards" is accurate, and the previous "rebind a container whose leaf was already gone" reading is gone.

(b) what survives is the container + leaf, not the placeholder.

  • record.placeholder = None at crates/bitty-runtime/src/registry/panel.rs:4342, inside PanelRegistry::rebind_panel (:4190), phase 2 step 2 — whose own comment (:4335–:4336) says "The placeholder a predecessor's end presented is cleared with it: a controller owns the content again." The new comment's "D.2 phase 2 step 2" citation is exactly right.
  • detach_panel_scene(panel) at plugin_runtime.rs:1056 runs before the branch, and rebind_panel attaches no scene (it writes capabilities :4333, binding :4338, then the facade's lease/ceiling).

Post-bind state = bound container, placeholder None, no scene. "bound, placeholder-free and scene-less" is literally the code. PASS.

F2 — both new end states named, in both required places, and both genuinely new

  • Test-file note: crates/bitty-runtime/tests/panel_generation_ownership.rs:2360–:2381 — a # What the retention change does *not* measure section with (i) :2367–:2373 the content-less retained leaf after a successful reload, (ii) :2374–:2381 the failed-after-dispose_inner / refused-bind orphans with no Close ever queued. Module header repeats it at :116, and the table row at :63 points at it.
  • PR body, "What this does not prove": both bullets at lines 194–198 and 199–205, plus the closing paragraph at 209–212 naming the two venues. The review allowed either a row or this disclaimer; the disclaimer is present in both required places.

Genuineness — neither is a pre-existing condition relabelled:

  1. A persistent content-less pane is new. Before the change Close was queued for every release, so the leaf disappeared one drain later; the only content-less window that existed before was the single tick between release and that drain. Also the successor cannot re-materialize the retained container: bitty.panel.create → PanelRuntime::create_panel (registry/host.rs:305) mints a new PanelId, and materialize_plugin_panel_leaf (chrome_keys.rs:1439) early-returns unless the state is PanelState::Created, which a rebound container is not.
  2. The orphaned Reloaded containers are new. reload_inner can return early after dispose_inner at the ? on :4191 (load_index), :4196 (resolve_record), :4200 and :4203 (verify_module_tree) and :4206 (activate_inner), and a refused bind lands in :1141; under the new predicate none of those queue a Close, where the old code always did. The stated inability of a later reload to repair them checks out: held() (plugin_runtime.rs:1010–:1015) enumerates panels_bound_to and panels_ended_at(owner, generation), and the next reload passes the generation that just ended, so records ended at G1 are not revisited by a reload whose predecessor is G2. PASS.

F3 — dispose row wording

plugin_runtime.rs:5002–:5009 now says what is unchanged is the assertion quartet (leaf_count 2→1, panel_count 0) and the four facts, not the path — the old row only ever called reload. The body says the same at lines 108–112. That matches the hunk: the same four assertions, with dispose substituted for reload in the middle. PASS.

F4 — module-table wording

:63 now reads "homed as a report … no production caller reads the report, and the two end states the retention change creates are listed as not measured in the note below"; :116 and :2344, :2356–:2358 say it again. The missing consumer is named, not implied. Independently: presentation_observation_of is called only from registry/host.rs:2037–:2080 (inside the #[cfg(test)] block opening at :1527) and plugin_runtime.rs:5107/:5168 (inside mod tests, :1662) — no production reader. PASS.

No new overclaim

Every changed sentence was checked against the tree; all of them hold, including the ones I could have been lenient about: "the old code removed them at the next tick", "held() enumerates panels_ended_at(owner, predecessor)", "bitty.panel.create mounts a new container", "close_plugin_panel_leaf removed its leaf and disposed the record". The evidence-only claim ("nothing derives placement, paint, a lease, or a grant from the observation") also still holds — presentation_observations (host.rs:126) is written at :1134, read only by the accessor at :1146, cleared at :639. Nothing in this round reaches the round-2 bar.

Non-blocking nit (pre-existing, not introduced here)

The body's step table line 25 ("plugin_runtime.rs:1153 … Ok(committed) arm, placement_view_of") and the call-chain block lines 81/83 ("bind_successor … :1095", "push ObservePresentation … :1157") are stale: at f4b573cc bind_successor is :1103, placement_view_of inside it is :1132, and the push is :1134–:1138. They were already wrong at 94b70bab (:1092 / :1119 / :1123), so this is not a regression smuggled in by the fix commit — but the +11-line comment shift moved them further out. One-line correction, not a blocker.

Gates at f4b573cc (lane worktree, read-only, own target dirs)

CARGO_TARGET_DIR=…/.targets/ctx-1870-recheck cargo test -p bitty-runtime --test panel_generation_ownership --offline
  test result: ok. 19 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.02s

CARGO_TARGET_DIR=…/.targets/ctx-1870-recheck cargo test -p bitty-terminal --bin bitty --offline presentation_mode_it_retained
  test plugin_runtime::tests::a_reload_keeps_the_leaf_and_reports_the_presentation_mode_it_retained ... ok
  test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 1647 filtered out

cargo +1.85 check -p bitty-runtime --tests --offline
  Finished `dev` profile [unoptimized + debuginfo] target(s)      exit 0

MSRV/lints: the added lines contain no code at all (git diff … | grep -E '^\+' | grep -v '^+ *//' is empty), so no let-chain or if let guard was introduced and clippy cannot have moved; CI's clippy and MSRV 1.85 legs are green at this head.

CI note as briefed: Supply chain (deny/audit) is the chrono RUSTSEC-2026-0543 red being fixed by #3221 — not a defect of this PR. Linux X11 (xvfb) now passes at f4b573cc; the previous WallClockExceeded flake in cli_config_fail_soft.rs did not recur.

Bottom line

F1–F4 are all closed on the evidence the review asked for, the graph of the retention claim is now correct in both venues, and the commit is provably confined to comments and rustdoc. I did not re-run the mutation set: with no executable line changed, discrimination is inherited unchanged from round 2. Ship it; fix the three stale line refs when convenient.

VERDICT: APPROVE

Xuepoo added a commit that referenced this pull request Nov 17, 2026
…s a dated exception (bitty#3220) (#3221)

* [CTX-1872] chore(security): record the chrono unmaintained advisory as a dated exception (bitty#3220)

RUSTSEC-2026-0543 marks chrono unmaintained with `patched = []`, so no lockfile
move can clear it; the supply-chain leg went red on every branch, including
PRs that touch no dependency (#3218, #3219).

The crate is used for the restricted Lua `os.date` local-calendar conversion
(bitty-lua/src/stdlib.rs) plus one bitty-runtime test, the advisory is
informational (no source-visible vulnerability), and both recommended
replacements are blocked today: `time >= 0.3.47` needs rustc 1.88 (MSRV is
1.85) and the jiff migration is its own dependency-adoption decision.

Record the exception where the repo already records this class (deny.toml,
ADR-0004 exception policy) with a 2027-03-31 re-audit bound, and pass the same
ignore to the cargo-audit step so the two lists cannot drift apart.

Verified: cargo deny check -> advisories ok, bans ok, licenses ok, sources ok.

* [CTX-1872] fix(ci): correct the audit-step rationale flagged in the review (bitty#3220)

The comment claimed a deny.toml-only ignore "turns this leg red". It does not:
cargo-audit 0.22.2 reports the unmaintained class as a warning and exits 0, so
`cargo deny check` is the enforcing half. Keep the ignore for list parity and
state why, instead of asserting an enforcement that does not exist.

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

Guard tick (2026-11-17 21:2x CST): head moved via update-branch, reviewed content byte-identical

gh pr update-branch was run after #3221 (the RUSTSEC-2026-0543 / chrono exception)
merged to main as 361fa068; the supply-chain leg was the only red left on this head
and it was red repo-wide because of that advisory.

Head moved f4b573cc → 618006e1. What the update added is exactly main's #3221
commit, nothing else:

$ git diff f4b573cc 618006e1 --stat
 .github/workflows/ci.yml | 11 ++++++++++-
 deny.toml                | 14 +++++++++++++-
 2 files changed, 23 insertions(+), 2 deletions(-)

Round-3 review verdict on f4b573cc — VERDICT: APPROVE (carryctx PX-8729) — still
covers the reviewed content: the round-2 findings F1-F4 were addressed and the fix
commit was proven comment/rustdoc-only (zero non-comment changed lines after stripping
comments from both files).

Residual noted by the reviewer, non-blocking and pre-existing: three line references in
the PR body (:1095/:1153/:1157) are stale (actual :1103/:1132/:1134-1138) and
were already stale at 94b70bab.

@Xuepoo
Xuepoo merged commit cda5b97 into main Nov 17, 2026
21 checks passed
@Xuepoo
Xuepoo deleted the ctx-1870/presentation-seam branch November 17, 2026 14:53
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