Repository navigation
[CTX-1361] feat(runtime): wire the ComponentBroker at the composition root - #2267
Conversation
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
There was a problem hiding this comment.
🔇 Additional comments: 12
crates/bitty-runtime/src/component/host.rs: 1
1-342: LGTM!crates/bitty-runtime/src/component/mod.rs: 1
78-78: LGTM!Also applies to: 101-102
crates/bitty-runtime/src/runtime.rs: 1
134-134: LGTM!Also applies to: 467-479, 1468-1473, 1718-1720, 1990-1992
crates/bitty-runtime/src/runtime/component_host.rs: 1
1-148: LGTM!Also applies to: 173-221
crates/bitty-runtime/src/runtime/present.rs: 1
1807-1810: LGTM!crates/bitty-runtime/tests/component_host.rs: 1
1-671: LGTM!crates/bitty-terminal/Cargo.toml: 1
23-36: LGTM!crates/bitty-terminal/src/lib.rs: 1
1-19: LGTM!crates/bitty-terminal/src/component_host.rs: 1
1-95: LGTM!crates/bitty-terminal/src/main.rs: 1
234-234: LGTM!Also applies to: 1293-1316
crates/bitty-runtime/Cargo.toml: 1
103-108: LGTM!crates/bitty-terminal/src/main.rs-927-933: 1
927-933: 🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win
⚠️ Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.Do not install the component host when
--safeis set.
install_component_hostruns on the primary and fallback paths without checkingargs.safe. Under--safe, other code skips third-party execution: no plugin VM, no session restore, no config reload. The component host still gets a broker that can spawn installed native extension binaries. Those binaries are third-party code from the extension store. The repository guide requires: "Preserve a safe startup path with no third-party plugins."No request producer exists today. Even so, the safe path should not hold the authority. Guard both calls:
🛡️ Proposed fix
- install_component_host(&mut runtime); + if !args.safe { + install_component_host(&mut runtime); + }- install_component_host(&mut rt); + if !args.safe { + install_component_host(&mut rt); + }Also fix the doc comment on
install_component_host, Lines 1293-1297. It says missing data roots leave the runtime without a host. The comment at Lines 930-932 says the system tier always resolves. If the system tier always resolves, the "no component data root" log branch never runs.As per coding guidelines: "Preserve a safe startup path with no third-party plugins."
Also applies to: 1262-1263
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI (base), Organization UI (inherited)
- Review profile: CHILL
- Plan: Advanced
- Run ID:
f48b327b-5c30-4784-b0f6-9a3e9581755f
⛔ Files ignored due to path filters: 1
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing: 11
crates/bitty-runtime/Cargo.tomlcrates/bitty-runtime/src/component/host.rscrates/bitty-runtime/src/component/mod.rscrates/bitty-runtime/src/runtime.rscrates/bitty-runtime/src/runtime/component_host.rscrates/bitty-runtime/src/runtime/present.rscrates/bitty-runtime/tests/component_host.rscrates/bitty-terminal/Cargo.tomlcrates/bitty-terminal/src/component_host.rscrates/bitty-terminal/src/lib.rscrates/bitty-terminal/src/main.rs
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
Cover the full `v0.0.23..main` range instead of the earlier partial passes: all 71 merged commits are grouped under Added, Changed, Fixed, Security, and Documentation, with PR numbers and the affected CTX tasks. Explicit call-outs: copy keeps combining marks and ZWJ (#2266), multi-line paste duplication and ghost fixed by the cursor clamp across wide spacers (#2272), combining marks paint so decomposed `é` matches precomposed (#2279), kitty font query and `bitty +show-font` (#2277), bounded native clipboard acquisition path B (#2273), bounded `bitty.fs.list` (#2271), the `bitty.history` Lua surface (#2268), the production ComponentBroker plus activation state (#2267, #2276), Enter-confirm paste (#2269), the `fill` DPI fix (#2283), landlock `no_new_privs` (#2284), and spawn descriptor reservation (#2289). Partials are marked honestly: #2254's request surface is still pending, the #2213 disposition stays open, #2286 is feature-gated and unwired, the macOS clipboard read stays a typed refusal, and the RC-1 fuel accounting fix is not claimed because PR #2292 is unmerged. The heading reads `unreleased` because the release is on hold; the tag date is set at tag time. Docs-only: no code, scripts, workflows, or pins touched.
Cover the full `v0.0.23..main` range instead of the earlier partial passes: all 71 merged commits are grouped under Added, Changed, Fixed, Security, and Documentation, with PR numbers and the affected CTX tasks. Explicit call-outs: copy keeps combining marks and ZWJ (#2266), multi-line paste duplication and ghost fixed by the cursor clamp across wide spacers (#2272), combining marks paint so decomposed `é` matches precomposed (#2279), kitty font query and `bitty +show-font` (#2277), bounded native clipboard acquisition path B (#2273), bounded `bitty.fs.list` (#2271), the `bitty.history` Lua surface (#2268), the production ComponentBroker plus activation state (#2267, #2276), Enter-confirm paste (#2269), the `fill` DPI fix (#2283), landlock `no_new_privs` (#2284), and spawn descriptor reservation (#2289). Partials are marked honestly: #2254's request surface is still pending, the #2213 disposition stays open, #2286 is feature-gated and unwired, the macOS clipboard read stays a typed refusal, and the RC-1 fuel accounting fix is not claimed because PR #2292 is unmerged. The heading reads `unreleased` because the release is on hold; the tag date is set at tag time. Docs-only: no code, scripts, workflows, or pins touched.
…s bitty-net (#2254) (#2296) * [CTX-1380] feat(runtime): add the plugin component request surface (#2254) The ComponentBroker wired by #2267 had no production request producer, so an installed component was unreachable from any user action. This adds the narrowest existing seam: a Lua host surface, because plugins are the intended consumers and the accepted capability model already covers them. - `bitty.component.request{ id, method, url, headers?, body?, timeout_ms? }` validates shape and bounds and enqueues one submission, returning a ticket. It never spawns, sends, or waits, so no Lua callback blocks on a component. - `bitty.component.poll(ticket)` reads `nil` while in flight, a bounded response table on success, and raises the stable typed class on failure (`E_COMPONENT_CAPABILITY_DENIED`, `E_COMPONENT_NOT_ACTIVE`, `E_COMPONENT_BUDGET`, `E_COMPONENT_TIMEOUT`, ...). - Bounds: 8 KiB request payload (the existing bridge ceiling), 8 KiB response, 16 headers, 30 s deadline ceiling, 32 submissions, 4 held per plugin, and a 32-entry completion window. - Authorization is unchanged and canonical: the composition root mirrors each activated generation's manifest and grant into the runtime policy host, then `Runtime::submit_component_request` re-checks lifecycle, manifest generation, grant record, and the egress intersection before the broker resolves and digest-verifies the component. Denials fail closed before any spawn. - Wiring: `pump_component_requests` drains submissions and delivers broker events once per cold tick; deadlines cancel abandoned broker requests and a suspended/reloaded/disposed generation's tickets are purged. Evidence: `tests/component_request_surface.rs` installs the fixture through the real `bitty extension add`, drives one request through the plugin surface (200 + echoed body), and proves denied (`capability_denied`), over-bound payload (rejected before enqueue), crashed component, and deadline failures. * [CTX-1380] fix(runtime): register all mirrored generations before activating any (#2254) register_plugin resolves dependencies against the runtime registry, so a dependent plugin mirrored ahead of its dependency would be refused and stay unmirrored. Snapshot the active generations, register every one, then grant and activate; a refusal still warns and leaves that plugin failing closed. --------- Co-authored-by: reviewer <[email protected]>
Priority: P1 | Area: runtime | Labels: feat,P1,area:runtime | Milestone: 0.0.24 | RFC: DIR-030 | Task: CTX-1361
What shipped
ComponentHostowns exactly one existingComponentBroker;Runtimeowns the host and installs it on both the primary and headless-fallback startup paths. No second broker, protocol, or spawn path.$XDG_DATA_HOME/bitty/extensions(user tier over system tier under the install rules);PATHis never consulted. Every spawn re-runs resolution and descriptor digest verification, so unknown components and digest tampering fail closed.Activatedplugin, the caller's manifest hash to match the registered generation, a non-denied grant record bound to that hash, and each capability to pass the canonicalGrantStore::is_granted(includingdenied_capsfrom an explicit revoke).PluginGrantis derived from declared[[network.egress]]; an offline grant denies before spawn.tick_atpumps broker lifecycle into a bounded event queue drained bypoll_component_events/take_component_events; synchronousrequestretains other request ids' events for a later poll. Runtime shutdown stops recorded children before PTY teardown.bitty extension addimplementation, request/response through the production host, plus a realbitty-net 0.0.1HTTP 200 through the same host. Committed regressions cover absent host, revoked capability, non-active lifecycle, wrong/foreign manifest hash, denied record, undeclared capability, digest mutation, andtick_atlifecycle/delivery.Gates
cargo fmt --all -- --checkcargo clippy --workspace --all-targets --locked -- -D warningscargo clippy -p bitty-terminal --features dev-tools --all-targets --locked -- -D warningscargo nextest run -p bitty-runtime -p bitty-terminal -p bitty-platform --locked— 3944 passed, 2 skippedcargo check --workspace --all-targets --locked --target x86_64-pc-windows-msvc./scripts/check-scratch-paths.shbitty-netharness: 1 passedMutations M1–M7 each kill their test (roundtrip, absent host, offline grant, digest,
tick_atpump, canonicalis_granted,Activatedstate).Non-claims
add+ fixture round-trip) is met; bullets 2 and 3 remain partial/unmet: thebitty-netproof is an#[ignore]d harness run with no headed run, andbitty extension listhas no activation state.activate_plugincaller, and no Lua/IPC verb exists; installed components are therefore not yet reachable from a user action. That is a blocking follow-up.ComponentRequestpath can block up to 310 s and must stay off the owner/UI thread; the async delivery surface is a prerequisite for the future Lua verb.Refs #2254 (intentionally not
Closes, per the non-claims above).Summary by CodeRabbit