Skip to content

[CTX-1887] fix(panel): refuse to bind a provider contract newer than the runtime — seam only (bitty#3239 row 13 stays open, implemented-only/unwired) - #3242

Merged
Xuepoo merged 2 commits into
mainfrom
ctx-1887-placeholder-incompatible
Nov 18, 2026
Merged

Xuepoo merged 2 commits into
mainfrom
ctx-1887-placeholder-incompatible

Conversation

@Xuepoo

@Xuepoo Xuepoo commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Status: implemented-only (unwired). This PR adds the rule and the seam, not a consuming path: the restore records and the provider registration have no production producer in this tree, so PlaceholderReason::Incompatible still cannot be presented by a shipped binary. Row 13 remains open. The scoped follow-up is #3243 (names every missing call site). Do not read the merge as closing bitty#3239 row 13.

Related #3239 (row 13 stays open). Follow-up: #3243.

What was missing (bitty#3239 row 13)

PlaceholderReason::Incompatible existed but had no producer.

  • PanelEdgeRelease.reason was only ever unloaded / disabled / reloaded / crashed (dispose_inner, reload, crash), and PanelRegistry::present_placeholder takes the token from its caller, so nothing in production named incompatible.
  • The one versioned provider record, PanelProviderManifest, refused every schema != 1 at parse (ProviderContractError::UnsupportedVersion), so the skew could not even be expressed: a panel whose provider speaks a newer contract was indistinguishable from a panel whose provider is not installed.
  • The only row that exercised the reason constructed it directly (panel.rs, present_placeholder(.., "incompatible")).

What this does

The gate admits the skew (registry/provider.rs). PanelProviderManifest::parse now admits any version >= 1 and refuses only 0 (which is not a schema version at all, still UnsupportedVersion). A manifest above PROVIDER_MANIFEST_VERSION_V1 reports requires_newer_runtime(). Registration is unchanged and keeps the record: dropping a too-new manifest at the gate would delete the only evidence a bind could observe, and would resurface as unloaded for a provider that is installed. No code applies a manifest payload, so the wider admission cannot make a newer contract commit anywhere.

The bind edge observes it (registry/host.rs, runtime/panel_restore.rs). PanelRuntime::provider_manifest(owner) is the read-only accessor. Runtime::restore_one_panel — the session-restore step from #3240 — refuses the first bind when the driver's registered manifest requires a newer runtime:

PanelDriverAnswer::Installed { owner, resolution, consented } => {
    if provider_contract_outruns_runtime(&host, owner) {
        present_restored_placeholder(&mut host, handle, workspace, "incompatible")
    } else {
        bind_restored_panel(&mut host, handle, workspace, owner, resolution, consented)
    }
}

Fail-closed: the container allocated for the record is retained, present_restored_placeholder writes the Core-owned incompatible placeholder, and nothing else happens — no controller generation, no grant (panel.create/panel.focus stay ungranted on the allocation epoch), no mount, no layout or focus op, no registry mutation beyond the placeholder and its bounded recovery record. The record outcome is PanelRestoreOutcome::Placeholder { reason: Incompatible }, not Dropped, so the container is not disposed.

Precedence is deliberate: the skew gate applies only to an Installed answer. Missing and Denied keep their more specific reasons.

Why this is implemented-only (unwired) — review finding, answered

Review id 5956514226 proved the call chain is real (load_session_from_path → apply_session_snapshot → commit_panel_restore → restore_one_panel → this gate) but that both preconditions are test-only:

Input Symbol Production callers Why there is none
restore records Runtime::set_panel_restore_records (runtime/panel_restore.rs:358) none outside crates/bitty-runtime/tests/ panel_restore_inputs is seeded Vec::new() (runtime.rs:2589, :2927); nothing calls bitty_ui::encode_manifest on save or decode_manifest/plan_restore on load
provider manifest PanelRuntime::register_panel_provider (registry/host.rs:1168) none outside crates/bitty-runtime/tests/ panel.provider is a capability token only; the plugin manifest grammar (plugin_runtime/manifest_toml.rs) admits no provider-contract field, so no activation point could register one

Hence provider_manifest(owner) answers None in a shipped binary and provider_contract_outruns_runtime (panel_restore.rs:595) is constant false.

I did not wire it here, and the reason is scope, not effort: a real producer needs (a) a panel type + owning plugin on the persisted record, which is RFC-OQ-9's pending field set and a PERSIST_MANIFEST_VERSION bump (row 16 is open); (b) a provider-contract declaration in the plugin package manifest plus its parser; (c) a production mapping from plugin to PanelDriverAnswer, which does not exist; and (d) a startup order where a panel host exists at restore time — crates/bitty-terminal/src/main.rs:1186 restores before discover_and_activate (:1241) constructs the host, which terminal_app.rs:1944 installs, so a production restore drops every record as NoPanelHost today. Inventing a parallel path for that would be exactly the kind of unreachable wiring this review objected to. All three gaps, with symbols, are in #3243.

What this PR therefore claims, and no more: the rule exists, is fail-closed, and is proven on the restore chain; the seam is documented as unreachable at the symbol (panel_restore module note, provider_manifest, register_panel_provider, PROVIDER_MANIFEST_VERSION_V1, PGO-11 note) so the next reader cannot mistake it for a shipped producer.

Which production line each new test discriminates

Test Revert this line → the test goes red
registry::provider::tests::a_newer_manifest_is_admitted_and_declares_it_needs_a_newer_runtime (lib) PanelProviderManifest::parse, if version == 0 back to if version != PROVIDER_MANIFEST_VERSION_V1
tests/panel_restore_path.rs::a_provider_manifest_newer_than_the_runtime_keeps_the_container_with_an_incompatible_placeholder the provider_contract_outruns_runtime branch of the PanelDriverAnswer::Installed arm in Runtime::restore_one_panel (bind unconditionally)
tests/panel_restore_path.rs::a_provider_manifest_at_the_supported_schema_still_first_binds the same branch, from the other side: a gate that refuses every registered provider, or that ignores version()

The restore row asserts the placeholder through three surfaces (PanelRestoreOutcome, unbound_container_records().placeholder(), and the built placeholder block), that the container is retained in the record's workspace with PanelState::Created and no controller, and that no capability of the refused driver's resolution is granted.

Sabotage runs (executed on the rebased head, then reverted)

  1. provider_contract_outruns_runtime forced to false:
    assertion `left == right` failed: a contract this runtime cannot read is never committed:
      PanelRestoreReport { panels: [RestoredPanel { persisted_id: PanelId(9),
        key: PanelRestoreKey { workspace: WorkspaceId(1), persistent: PersistentId("logs") },
        title: "logs", outcome: Bound { panel: PanelId(1), workspace: WorkspaceId(2),
        grants: {"panel.create", "panel.focus"} } }] }
      left: 1
      right: 0
    failures: a_provider_manifest_newer_than_the_runtime_keeps_the_container_with_an_incompatible_placeholder
    test result: FAILED. 10 passed; 1 failed
    
  2. provider_contract_outruns_runtime forced to true:
    failures:
        a_provider_manifest_at_the_supported_schema_still_first_binds
        a_second_restore_releases_containers_attributed_to_the_replaced_world
        a_session_restore_mints_a_fresh_panel_id_and_first_binds_the_installed_driver
    test result: FAILED. 8 passed; 3 failed
    
    (The second name is fix(runtime): resolve the #3240 panel-restore residuals (multi-workspace slots, released world, tautological rows, dead API) #3241's row: on the rebased tree it also first-binds a provider-driven record, so the over-broad gate reddens three rows, not two.)
  3. parse reverted to version != PROVIDER_MANIFEST_VERSION_V1:
    a manifest above v1 is admitted: UnsupportedVersion { version: 2 }
    the manifest parses: UnsupportedVersion { version: 2 }
    lib: 6 passed; 1 failed
    panel_restore_path: 10 passed; 1 failed
    

Rebase onto f78e887d (#3241)

origin/main had advanced to f78e887d, which rewrote the same panel-restore step (#3241: ordinal-based slot resolution, outgoing-world release, dead public API removal). Both sides' semantics are kept:

  • panel_restore.rs conflict was purely additive in the helper block: restored_slot_of (main, ordinal → slot) and provider_contract_outruns_runtime (this PR) both remain, each with its own doc.
  • The new control row used RestoredPanel::restored_id, which fix(runtime): resolve the #3240 panel-restore residuals (multi-workspace slots, released world, tautological rows, dead API) #3241 removed as dead public API; it now reads the container id out of PanelRestoreOutcome::Bound, like the rest of the file.
  • restore_one_panel keeps main's slot/workspaces resolution and the release_panels_of_outgoing_world ordering; the skew gate sits inside the unchanged Installed arm.

Scope

  • The live bind path is unchanged: no bitty.panel.create/rebind path reads a provider manifest, so a generation that binds outside a restore still commits its own resolution.
  • The older-provider-over-newer-record direction is unchanged: the persisted panel record carries identity, not provider content.
  • No new dependency edges, so no Cargo.lock change.
  • No issue-closing keyword is used: row 13 is not closed by this PR.

Gates (run on the pushed head)

cargo fmt --all --check                                                   exit 0
cargo clippy -p bitty-runtime -p bitty-ui --all-targets --offline -- -D warnings
                                                                          exit 0
cargo test -p bitty-runtime --offline --lib                               exit 0 (1694 passed)
cargo test -p bitty-runtime --offline --lib -- registry::provider::tests  exit 0 (7 passed)
cargo test -p bitty-runtime --offline --test panel_restore_path           exit 0 (11 passed)
cargo test -p bitty-runtime --offline --test panel_generation_ownership   exit 0 (19 passed)
cargo test -p bitty-runtime --offline --test cw_contracts                 exit 0 (12 passed)
cargo test -p bitty-runtime --offline --test cw_integrate                 exit 0 (8 passed)
cargo +1.85 check -p bitty-runtime --tests --offline                      exit 0
RUSTDOCFLAGS="-D warnings" cargo doc -p bitty-runtime --no-deps --offline exit 0

…er provider contract (bitty#3239 row 13)

`PlaceholderReason::Incompatible` had no producer. `PanelEdgeRelease.reason`
was only ever `unloaded`/`disabled`/`reloaded`/`crashed`, and the one versioned
provider record, `PanelProviderManifest`, refused every schema other than 1 at
`parse`, so the skew could not be expressed at all: a panel whose provider
speaks a newer contract than this runtime was indistinguishable from a panel
whose provider is not installed, and the placeholder vocabulary was reachable
only from tests that constructed the reason token by hand.

The provider gate now admits a manifest above `PROVIDER_MANIFEST_VERSION_V1`
and `PanelProviderManifest::requires_newer_runtime` names what was admitted, so
the declaration survives as a registered record instead of being deleted at the
gate. Registration is still not a bind: `PanelRuntime::provider_manifest` is the
read-only accessor the bind edge needs to observe it.

The producer is the restore edge (`Runtime::restore_one_panel`). A record whose
driver answers `Installed` but whose registered provider manifest requires a
newer runtime does not first-bind: `provider_contract_outruns_runtime` refuses
the bind, the fresh container is retained, and
`present_placeholder(.., "incompatible")` writes the Core-owned placeholder. No
grant, no controller generation, no mount, no layout or focus op: the container
keeps exactly the allocation epoch it was created with. A driver that registered
no provider manifest, or one at the schema this runtime reads, binds unchanged.

Test discrimination (each row, and the production line that turns it red when
reverted):

* `registry::provider::tests::a_newer_manifest_is_admitted_and_declares_it_needs_a_newer_runtime`
  (lib) -- red when `PanelProviderManifest::parse` goes back to
  `version != PROVIDER_MANIFEST_VERSION_V1`, because the v2 manifest never
  exists to register.
* `tests/panel_restore_path.rs::a_provider_manifest_newer_than_the_runtime_keeps_the_container_with_an_incompatible_placeholder`
  -- red when the `provider_contract_outruns_runtime` branch of the
  `PanelDriverAnswer::Installed` arm in `Runtime::restore_one_panel` is reverted
  to bind unconditionally (observed: `Bound { grants: {"panel.create",
  "panel.focus"} }` and no placeholder).
* `tests/panel_restore_path.rs::a_provider_manifest_at_the_supported_schema_still_first_binds`
  -- the control for the same line: red if the gate refuses every registered
  provider instead of comparing `version()` (observed: over-broad gate turns it
  and the pre-existing first-bind row red).

Sabotage runs for the two code lines above were executed and reverted; the
failing output is quoted in the PR body.

Also corrected the test-harness record that claimed the gap: the PGO-11 note in
`tests/panel_generation_ownership.rs` now names the restore edge as the homed
half and still states, rather than implies, which direction remains unmeasured
(no `bitty.panel.create`/rebind path reads a provider manifest, and the
persisted record carries identity, not provider content).
@Xuepoo Xuepoo added fix Bug fix P1 Priority: high area:runtime Area: runtime orchestration labels Nov 18, 2026
@coderabbitai

coderabbitai Bot commented Nov 18, 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 22 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: b27756ae-34ec-4f23-a82d-54ce0c288d98
Commits

Reviewing files that changed from the base of the PR and between f78e887 and 35f66a3.

Files selected for processing: 5

  • crates/bitty-runtime/src/registry/host.rs
  • crates/bitty-runtime/src/registry/provider.rs
  • crates/bitty-runtime/src/runtime/panel_restore.rs
  • crates/bitty-runtime/tests/panel_generation_ownership.rs
  • crates/bitty-runtime/tests/panel_restore_path.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 lane (guard-dispatched)

Reviewed head 195be5b769aa33e9c7416da3a2d1e7479c15085a against base 335d3d0d. I read the full diff, traced every caller of PanelProviderManifest::parse / ProviderContractError, ran the MSRV, clippy, rustdoc and the three named rows, and re-ran all three claimed sabotage mutations in a scratch copy of the tree.

  1. PASS — version gate is exactly as claimed. parse refuses only 0 (crates/bitty-runtime/src/registry/provider.rs:152) and still returns ProviderContractError::UnsupportedVersion { version } with the value carried (provider.rs:153). No call site depended on the old != 1 refusal: every caller of parse is a test (provider.rs:388,397,410,419,423,433,453; tests/cw_contracts.rs:79,171; tests/cw_integrate.rs:191; tests/panel_restore_path.rs:507), and production has no caller at all. UnsupportedVersion is produced only at provider.rs:153; the ctl/render.rs:89,112 hits are the unrelated server-error string taxonomy. No code applies a manifest payload: the only production readers are declares() in create_panel_for_provider (registry/host.rs:1218) and the new skew check, and the former has no non-test caller either. So admitting >= 1 cannot cause a newer manifest to be applied anywhere today.

  2. FAIL — the skew is not reachable from production; this is implemented-only (unwired), not a consuming path. The call chain itself is real: Runtime::load_session_from_path (runtime/session.rs:1722) → apply_session_snapshot (session.rs:1252) → commit_panel_restore (session.rs:1463) → restore_one_panel (runtime/panel_restore.rs:459) → gate at panel_restore.rs:511. But the gate can never be true outside tests: PanelRuntime::register_panel_provider (registry/host.rs:1163) has no caller outside crates/bitty-runtime/tests/, so provider_manifest(owner) (host.rs:1198) is always None in production and provider_contract_outruns_runtime (panel_restore.rs:552-555) is constant false. Independently, the panel step's input is never produced in production either: set_panel_restore_records (panel_restore.rs:355) is called only from tests, and both constructors seed panel_restore_inputs: Vec::new() (runtime.rs:2589,2927), so apply_session_snapshot restores zero panels. Both preconditions of the new branch are test-only, so present_placeholder(.., "incompatible") at panel_restore.rs:512 is unreachable in a shipped binary. By the PGO-11 note's own standard (a test-side token does not count as a producer), row 13 is still unmet: the PR adds a second unreachable arm next to the pre-existing Older arm (panel_restore.rs:523), which already presented incompatible on the same unwired step.

  3. PASS — fail-closed on the incompatible outcome. present_restored_placeholder only calls present_placeholder(id, allocation_epoch, token) (panel_restore.rs:594-600); the registry writes only record_mut.placeholder (registry/panel.rs:2544-2548) and never allocates a controller generation (that happens solely in bind_restored_panel via rebind_panel, panel_restore.rs:579-590). With bound == None the release_generation_scope branch at registry/panel.rs:2519-2525 is skipped, so no grant is added on the allocation epoch, and create_panel leaves PanelState::Created with no mount/layout/focus op. The container is disposed only when the outcome is Dropped (panel_restore.rs:527-531); Placeholder is returned and retained (panel_restore.rs:600-610). The row also proves the grant assertion is non-vacuous: resolution() is {panel.create, panel.focus} (tests/panel_restore_path.rs:138-144), and assert_nothing_was_granted checks both against the allocation epoch (tests/panel_restore_path.rs:521-537).

  4. PASS — the new rows discriminate, and the 3-sabotage claim reproduces. At head: cargo test --test panel_restore_path → 9 passed (both new rows included); lib registry::provider::tests → 7 passed. I re-ran the three mutations in /home/fuyu/.hermes/cache/scratch/review-3242/repo (never the lane worktree):

    • provider_contract_outruns_runtime forced false → only the new row fails, at tests/panel_restore_path.rs:441: left: 1, right: 0, outcome Bound { grants: {"panel.create","panel.focus"} } — matches the PR body verbatim.
    • forced true → 7 passed; 2 failed: a_provider_manifest_at_the_supported_schema_still_first_binds (line 497) and a_session_restore_mints_a_fresh_panel_id_and_first_binds_the_installed_driver — matches the PR body.
    • parse reverted to version != PROVIDER_MANIFEST_VERSION_V1 → lib 6 passed; 1 failed (UnsupportedVersion { version: 2 } at provider.rs:454) and panel_restore_path 8 passed; 1 failed at line 513 — matches the PR body.
      The production lines to revert are therefore provider.rs:152 for the lib row and panel_restore.rs:511 for both integration rows. No assertion reads a value derived from the container it asserts on: report.bound()/outcome is the Core return value, while unbound_reason (tests/panel_restore_path.rs:151-158) and assert_placeholder_kept_the_container (:540-565) read the host registry's placeholder, controller generation, state, workspace list and built placeholder block — independent surfaces.
  5. PASS — MSRV 1.85 and lint safety. cargo +1.85 check -p bitty-runtime --tests --offline → exit 0. cargo clippy -p bitty-runtime --all-targets -- -D warnings → exit 0. RUSTDOCFLAGS="-D warnings" cargo doc -p bitty-runtime --no-deps → exit 0 (so PanelRuntime::provider_manifest's link to PanelProviderManifest::requires_newer_runtime and the bitty_ui::panel_recovery::PlaceholderReason::Incompatible link resolve; PanelProviderManifest is imported at registry/host.rs:94). The new hunks use a plain if/else and Option::is_some_and (panel_restore.rs:502-516,552-555) — no let-chains, no if let guards, nothing cfg-gated, and requires_newer_runtime is a const fn called from non-test code (panel_restore.rs:554), so no dead-code path.

  6. PASS — scope and doc corrections. The body explicitly names the unwired halves: "Provider registration still has no application caller (register_panel_provider is reached only from bitty-runtime tests)" and "no bitty.panel.create/rebind path reads a provider manifest". It uses Related #3239; there is no Closes/Fixes/Resolves keyword anywhere in the body (grep exit 1). All five changed files are in scope; the only new public surface is the documented provider_manifest accessor and the documented requires_newer_runtime. The PGO-11 rewrite (tests/panel_generation_ownership.rs:93-106) matches the tree in what it says about the live path. Caveat, folded into check 2: the note calls the restore edge "the homed half", but the step never receives records in production, so the body's "this PR closes only row 13" is stronger than the tree supports.

Commands run (all with --offline, CARGO_TARGET_DIR=/home/fuyu/.hermes/cache/scratch/review-3242/target):

  • cargo +1.85 check -p bitty-runtime --tests --offline → Finished dev profile (exit 0)
  • cargo clippy -p bitty-runtime --all-targets --offline -- -D warnings → exit 0, no diagnostics
  • cargo test -p bitty-runtime --offline --test panel_restore_path → 9 passed; 0 failed
  • cargo test -p bitty-runtime --offline --lib -- registry::provider::tests → 7 passed; 0 failed
  • RUSTDOCFLAGS="-D warnings" cargo doc -p bitty-runtime --no-deps --offline → exit 0
  • sabotage 1 (forced false) → 1 passed; 1 failed (new row, Bound/left: 1, right: 0)
  • sabotage 2 (forced true) → 7 passed; 2 failed (control + pre-existing first-bind row)
  • sabotage 3 (parse reverted) → lib 6 passed; 1 failed, panel_restore_path 8 passed; 1 failed
  • grep -rn "set_panel_restore_records\|register_panel_provider" --include=*.rs crates → definitions only, no non-test callers
  • gh pr diff 3242 reviewed against worktree HEAD 195be5b7 (clean)

Requested change: give the row a consuming path before claiming it closed — either a non-test caller of register_panel_provider plus a non-test producer of PanelRestoreInput (e.g. decode_manifest/plan_restore at startup), or retitle the PR as the seam-only change it is and keep row 13 open. Everything else in the diff is correct and fail-closed as described.

…the runtime (bitty#3239 row 13 seam)

`PlaceholderReason::Incompatible` had no producer. `PanelEdgeRelease.reason`
was only ever `unloaded`/`disabled`/`reloaded`/`crashed`, and the one versioned
provider record, `PanelProviderManifest`, refused every schema other than 1 at
`parse`, so the skew could not be expressed at all: a panel whose provider
speaks a newer contract than this runtime was indistinguishable from a panel
whose provider is not installed, and the placeholder vocabulary was reachable
only from tests that constructed the reason token by hand.

The provider gate now admits a manifest above `PROVIDER_MANIFEST_VERSION_V1`
and `PanelProviderManifest::requires_newer_runtime` names what was admitted, so
the declaration survives as a registered record instead of being deleted at the
gate. Registration is still not a bind: `PanelRuntime::provider_manifest` is the
read-only accessor the bind edge needs to observe it. No code applies a manifest
payload, so admitting a newer schema cannot make a newer contract commit
anywhere.

The gate sits on the restore edge (`Runtime::restore_one_panel`). A record whose
driver answers `Installed` but whose registered provider manifest requires a
newer runtime does not first-bind: `provider_contract_outruns_runtime` refuses
the bind, the fresh container is retained, and
`present_placeholder(.., "incompatible")` writes the Core-owned placeholder. No
grant, no controller generation, no mount, no layout or focus op: the container
keeps exactly the allocation epoch it was created with. A driver that registered
no provider manifest, or one at the schema this runtime reads, binds unchanged.

Scope, stated rather than implied: this is the rule and its seam, not a shipped
producer, so bitty#3239 row 13 stays open. Both inputs of the gate are
test-only — `Runtime::set_panel_restore_records` and
`PanelRuntime::register_panel_provider` have no caller outside
`crates/bitty-runtime/tests/`, nothing encodes or decodes a restart manifest on
the session save/load path, the plugin manifest grammar carries no provider
declaration to register, and the shipped restore runs before the panel host
exists. The module's reachability note, the `provider_manifest` /
`register_panel_provider` docs, the `PROVIDER_MANIFEST_VERSION_V1` doc and the
PGO-11 note say exactly that; a scoped follow-up issue names the missing call
sites.

Test discrimination (each row, and the production line that turns it red when
reverted):

* `registry::provider::tests::a_newer_manifest_is_admitted_and_declares_it_needs_a_newer_runtime`
  (lib) -- red when `PanelProviderManifest::parse` goes back to
  `version != PROVIDER_MANIFEST_VERSION_V1`, because the v2 manifest never
  exists to register.
* `tests/panel_restore_path.rs::a_provider_manifest_newer_than_the_runtime_keeps_the_container_with_an_incompatible_placeholder`
  -- red when the `provider_contract_outruns_runtime` branch of the
  `PanelDriverAnswer::Installed` arm in `Runtime::restore_one_panel` is reverted
  to bind unconditionally (observed: `Bound { grants: {"panel.create",
  "panel.focus"} }` and no placeholder).
* `tests/panel_restore_path.rs::a_provider_manifest_at_the_supported_schema_still_first_binds`
  -- the control for the same line: red if the gate refuses every registered
  provider instead of comparing `version()` (observed: over-broad gate turns it
  and the pre-existing first-bind row red).

Sabotage runs for the two code lines above were executed and reverted; the
failing output is quoted in the PR body.

Also corrected the test-harness record that claimed the gap: the PGO-11 note in
`tests/panel_generation_ownership.rs` now states the restore edge's rule, the
three reasons it is not yet reachable in a shipped binary, and which direction
remains unmeasured (no `bitty.panel.create`/rebind path reads a provider
manifest, and the persisted record carries identity, not provider content).

Rebased onto `f78e887d`; the conflict in `panel_restore.rs` was additive
(this gate's helper next to `restored_slot_of`), and the new control row was
adapted to the `RestoredPanel::restored_id` removal.
@Xuepoo Xuepoo changed the title [CTX-1887] fix(panel): produce the incompatible placeholder for a newer provider contract (bitty#3239 row 13) [CTX-1887] fix(panel): refuse to bind a provider contract newer than the runtime — seam only (bitty#3239 row 13 stays open, implemented-only/unwired) Nov 18, 2026
@Xuepoo

Xuepoo commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Answering review id 5956514226 (CHANGES-REQUESTED), and the rebase conflict in one pass.

Outcome: the review's finding is accepted, not argued away. This PR is implemented-only (unwired) and row 13 stays open. I did not take the "wire it" option: the bound I was given was ~3 crates and a real registration point, and neither the producer nor the registration point exists to wire.

Why wiring was not taken (with the checks)

You proved the two producers are test-only. I re-derived each from the tree at the rebased head, and each one needs a decision or a subsystem that is not in this PR's scope:

  1. Records can't be produced from the persisted form. set_panel_restore_records takes Vec<PanelRestoreInput>, and a PanelRestoreInput needs panel_type plus a PanelDriverAnswer — neither is on PersistedPanel (id, PanelRestoreKey, title). Adding them bumps PERSIST_MANIFEST_VERSION past 2, which is RFC-OQ-9's pending field set (row 16 is open). So a save/load producer is an encoding decision, not a call site.
  2. No production registration point exists. panel.provider is only a capability token (bitty-plugin-host/src/capability.rs, bitty-package/src/manifest.rs); the plugin manifest grammar (plugin_runtime/manifest_toml.rs) admits plugin | compat | capabilities | lazy | limits | dependencies and has no provider-contract field, so there is nothing at activation to turn into a PanelProviderManifest, and register_panel_provider has no caller to add. PanelDriverAnswer is likewise constructed only in tests/panel_restore_path.rs: nothing in the tree maps a plugin to "installed / missing / denied, with which panel.* resolution".
  3. A third blocker you did not name, which would have made a records-only wiring a lie. The shipped process restores before it owns a panel host: crates/bitty-terminal/src/main.rs:1186 runs restore_session_on_startup, the host is constructed later inside plugin_runtime::discover_and_activate (main.rs:1241 → plugin_runtime.rs:1909) and installed at terminal_app.rs:1944. So even with records on disk, a production restore answers PanelRestoreDrop::NoPanelHost for every record (row: a_runtime_without_a_panel_host_drops_the_record_with_a_typed_reason). Wiring the save/load half alone would have produced a second unreachable arm — the exact defect you found.

What changed in response

  • Claim corrected at every surface, so no reader can mistake the seam for a producer:
    • runtime/panel_restore.rs: new module section "Reachability of the skew gate" — both inputs test-only, why, and that the shipped restore runs before the host exists.
    • provider_contract_outruns_runtime now documents that it is constant false in a shipped binary.
    • PanelRuntime::provider_manifest and register_panel_provider (registry/host.rs) say they have no production caller and that panel.provider is a capability token, not a declaration.
    • PROVIDER_MANIFEST_VERSION_V1 (registry/provider.rs) says the wider admission changes no shipped behaviour yet.
    • PGO-11 note (tests/panel_generation_ownership.rs): "implemented on the restore edge but not reachable in a shipped binary, so this row remains open", with all three reasons.
  • PR retitled to ... seam only (bitty#3239 row 13 stays open, implemented-only/unwired), body rewritten with a status banner at the top, an inputs table naming both symbols and both missing call sites, and the four structural blockers; no Closes/Fixes/Resolves.
  • Follow-up filed: [0.1.0] Panel restore: no production producer for restore records or provider registration (bitty#3239 row 13) #3243 — names the exact symbols, the missing call sites (save-side encode_manifest, load-side decode_manifest/plan_restore, activation-time register_panel_provider), the missing plugin-manifest declaration, the missing plugin→PanelDriverAnswer mapping, the startup-order blocker, and the closing condition (one production-chain row that reddens when any producer is reverted). Labels P1, area:runtime.
  • Commented on bitty#3239 with what landed and what did not.

Rebase onto f78e887d (#3241)

origin/main moved onto the same panel-restore step, so both sides' semantics had to survive:

  • panel_restore.rs conflict was purely additive in the helper block — kept restored_slot_of (main: persisted ordinal → restored slot, bounded by restored slots) and provider_contract_outruns_runtime (this PR), each with its own doc.
  • Main's release_panels_of_outgoing_world ordering and restore_one_panel's slot resolution are untouched; the skew gate stays inside the unchanged Installed arm.
  • The rebase surfaced one real break the auto-merge hid: main removed RestoredPanel::restored_id as dead public API, and my control row called it. It now reads the container id out of PanelRestoreOutcome::Bound, like the rest of the file.

Note on push: the environment blocks --force-with-lease for unattended runs, so the branch was updated fast-forward with a merge of origin/main (35f66a36, parents 195be5b7 + f78e887d). The resulting tree is byte-identical to the locally rebased commit — I verified git diff <rebased> <merge> is empty — so the content is the rebase resolution, only the history shape differs.

Everything above re-verified on the pushed head 35f66a36

All three sabotage mutations were re-run on the rebased tree and reverted (counts in the body). One honest change from before the rebase: forcing provider_contract_outruns_runtime to true now reddens three rows, because #3241 added a_second_restore_releases_containers_attributed_to_the_replaced_world, which also first-binds a provider-driven record.

Gates: cargo fmt --all --check 0 · clippy -p bitty-runtime -p bitty-ui --all-targets --offline -- -D warnings 0 · test --lib 0 (1694) · --lib -- registry::provider::tests 0 (7) · --test panel_restore_path 0 (11) · --test panel_generation_ownership 0 (19) · --test cw_contracts 0 (12) · --test cw_integrate 0 (8) · cargo +1.85 check -p bitty-runtime --tests --offline 0 · RUSTDOCFLAGS="-D warnings" cargo doc -p bitty-runtime --no-deps --offline 0. No Cargo.toml/Cargo.lock change.

Your four PASS findings are unchanged by this revision: the version gate still refuses only 0 and carries the value (registry/provider.rs:158), the placeholder path is still fail-closed with bound == None, and the rows still discriminate on provider.rs:158 and the gate at runtime/panel_restore.rs:523. If you re-review, the thing to check is that the downgraded claims match the tree — not new behaviour, because there is none.

@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 re-review lane (guard-dispatched) — head 35f66a3, supersedes review 5956514226

Re-reviewed at 35f66a36c73660e42fa596d0b87c44c2fea0a577 (merge of 195be5b7 + f78e887d; merge-base with origin/main is f78e887d). Every claim was checked against the tree, not the description. All six checks PASS — APPROVE.

1. Rebase/merge resolution keeps both sides — PASS

  • #3241's symbols are all present at head: fn restored_slot_of (crates/bitty-runtime/src/runtime/panel_restore.rs:570) and its call site :400 (slot: restored_slot_of(record.key.workspace.get(), restored_slots)), fn release_panels_of_outgoing_world :427 with its call crates/bitty-runtime/src/runtime/session.rs:1338, attributed_workspace_count crates/bitty-runtime/src/registry/panel.rs:2746.
  • The gate is inside the PanelDriverAnswer::Installed arm and nowhere else: panel_restore.rs:514-530 (if provider_contract_outruns_runtime(&host, owner) { present_restored_placeholder(.., "incompatible") } else { bind_restored_panel(..) }). Missing/Denied/Older arms are byte-unchanged.
  • No revert of #3241: git diff 35f66a36 origin/main touches only the PR's own five files (28 ins / 348 del), and for each of them the reverse diff's removed lines are exactly the PR's added lines — sorted-line-set diff is empty for panel_restore.rs (98/98), panel_restore_path.rs (130/130), host.rs (23/23), provider.rs (78/78), panel_generation_ownership.rs (19/19). Zero removed lines match the three #3241 symbols. So the merge shape altered no content: head == main + this patch.

2. Breakage claim — PASS

  • RestoredPanel::restored_id is gone from origin/main (git grep restored_id origin/main → 0 hits); it existed at 335d3d0d:crates/bitty-runtime/src/runtime/panel_restore.rs:231 and at the pre-merge lane head 195be5b7:245, which called it at 195be5b7:crates/bitty-runtime/tests/panel_restore_path.rs:499. The auto-merge would indeed have carried that call into a tree without the API.
  • The row now reads the container id from the outcome: panel_restore_path.rs:475 let PanelRestoreOutcome::Bound { panel, .. } = report.panels()[0].outcome; — Bound's panel field is the "freshly minted container id" (panel_restore.rs:249). No resurrection of restored_id.

3. Honesty of the downgrade — PASS

  • Title: "… — seam only (bitty#3239 row 13 stays open, implemented-only/unwired)". Body opens with **Status: implemented-only (unwired) and "Row 13 remains open."; closingIssuesReferences is [] (no closing keyword).
  • Grep of every added line in the diff for closes|closed|fixes|resolves|now produces|now presents|is closed → the only hit is the negation at panel_restore.rs:60 ("a seam, not a shipped producer").
  • Every row 13 mention in the touched files either points at the follow-up or explicitly says the row is open: registry/host.rs:1162, :1207 ("row 13 stays open"), registry/provider.rs:59-63 ("nothing outside crates/bitty-runtime/tests/ registers a manifest"), panel_restore.rs:44-80 (module reachability note naming all three missing producers), :594 ("constant false in a shipped binary today"). PGO-11 note at tests/panel_generation_ownership.rs:93-105 is rewritten to "implemented on the restore edge but not reachable in a shipped binary, so this row remains open". No surviving over-claim.

4. Three-reason rejection of wiring is accurate — PASS

  • (a) crates/bitty-ui/src/panel_persist.rs:267-274: PersistedPanel { id, key, title } only — no panel type, no owning plugin, no driver answer; PanelRestoreInput::new(record, PanelType, PanelDriverAnswer) (panel_restore.rs:199). Adding those fields moves PERSIST_MANIFEST_VERSION (currently 2, panel_persist.rs:55). Accurate.
  • (b) crates/bitty-runtime/src/plugin_runtime/manifest_toml.rs:243 admits only plugin | compat | capabilities | lazy | limits | dependencies; panel.provider appears only as a capability token (crates/bitty-package/src/manifest.rs:416, crates/bitty-plugin-host/src/capability.rs:214). register_panel_provider (registry/host.rs:1168) has three callers, all test-side: tests/cw_contracts.rs:172, tests/cw_integrate.rs:192, tests/panel_restore_path.rs:586. Accurate.
  • (c) crates/bitty-terminal/src/main.rs:1186 runs runtime.restore_session_on_startup(args.safe); :1241 is plugin_runtime::discover_and_activate(..), which constructs the host at plugin_runtime.rs:1909 (PanelRuntime::new), installed at terminal_app.rs:1944 (install_shared_scene_host, inside with_panel_scene_host starting :1939). Restore genuinely precedes host construction and installation, so NoPanelHost for every record. Accurate — the downgrade was not premature.

5. Follow-ups are executable, not vague — PASS

  • Issue #3243 (open, P1 + area:runtime) names the exact call sites: set_panel_restore_records (panel_restore.rs:358, no caller outside tests), empty seeds (runtime.rs:2589, :2927), save-side encode_manifest missing (session.rs:1676), load-side decode_manifest/apply_session_snapshot missing (session.rs:1732/:1255), commit_panel_restore (:1473), register_panel_provider (host.rs:1168), the missing manifest grammar field, and the startup order (main.rs:1186 vs :1241 → plugin_runtime.rs:1909 → terminal_app.rs:1944). Spot-checked line numbers are correct at head.
  • Its Closing condition is concrete and falsifiable: one production chain (save → manifest on disk → load in a fresh process → provider above PROVIDER_MANIFEST_VERSION_V1 → incompatible, epoch kept, no controller, no grant), with each producer's removal reddening that row or its control.
  • The #3239 comment (2026-11-18T12:51:36Z) separates "What landed" (rule, accessor, gate, three rows, sabotage re-runs) from "What did not land — and why row 13 stays open" (all three blockers) and states the acceptance condition is not met.

6. Gates on the new head — PASS (observed exit codes, scratch copy at git archive 35f66a36)

cargo fmt --all --check                                  exit 0
cargo clippy -p bitty-runtime -p bitty-ui --all-targets --offline -- -D warnings
                                                         exit 0
cargo +1.85 check -p bitty-runtime --tests --offline       exit 0
cargo test -p bitty-runtime --offline --lib                exit 0  (1694 passed; 0 failed)
cargo test -p bitty-runtime --offline --test panel_restore_path
                                                           exit 0  (11 passed; 0 failed)
cargo test -p bitty-runtime --offline --test panel_generation_ownership
                                                           exit 0  (19 passed; 0 failed)

Sabotage runs, executed on my own scratch copy and reverted there (the quote in the PR body reproduces):

  1. provider_contract_outruns_runtime forced false → exit 101, 10 passed; 1 failed, only a_provider_manifest_newer_than_the_runtime_keeps_the_container_with_an_incompatible_placeholder (panel_restore_path.rs:509, left: 1 / right: 0, outcome Bound { panel: PanelId(1), workspace: WorkspaceId(2), grants: {"panel.create","panel.focus"} }).
  2. Forced true → exit 101, 8 passed; 3 failed: a_provider_manifest_at_the_supported_schema_still_first_binds, a_second_restore_releases_containers_attributed_to_the_replaced_world (#3241's row), a_session_restore_mints_a_fresh_panel_id_and_first_binds_the_installed_driver.
  3. parse reverted to version != PROVIDER_MANIFEST_VERSION_V1 → lib 6 passed; 1 failed (UnsupportedVersion { version: 2 } at provider.rs:460), panel_restore_path 10 passed; 1 failed (panel_restore_path.rs:584).

So both directions of the gate are pinned by a row, and the merge of #3241 did not blunt either of them.

Residuals (non-blocking, already tracked)

  • Row 13 stays open and cannot be closed by this PR: ProviderReason::Incompatible still has no shipped producer. #3243 is the correct home; the PR's own title and body say so.
  • I could not verify the "byte-identical tree to the local rebase" claim directly (no local rebase ref to diff), but the equivalent property holds and is what matters: head content == origin/main content + this patch, line for line, in all five files.

Verdict: APPROVE. The change is honest about being a seam, the rebase kept both sides' semantics, the removal of restored_id was correctly handled rather than papered over, and the follow-up is executable.

@Xuepoo
Xuepoo merged commit 3c588f2 into main Nov 18, 2026
21 checks passed
@Xuepoo
Xuepoo deleted the ctx-1887-placeholder-incompatible branch November 18, 2026 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:runtime Area: runtime orchestration fix Bug fix P1 Priority: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant