Skip to content

[CTX-1380] feat(runtime): production component request surface reaches bitty-net (#2254) - #2296

Merged
Xuepoo merged 2 commits into
mainfrom
ctx-2254/feat-component-request
Oct 20, 2026
Merged

Xuepoo merged 2 commits into
mainfrom
ctx-2254/feat-component-request

Conversation

@Xuepoo

@Xuepoo Xuepoo commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Priority: P1 | Area: runtime | Labels: feat,P1,area:runtime | Milestone: 0.0.24 | RFC: DIR-030 | Task: CTX-1380

What shipped

The production request producer #2254's Expected clause needed. #2267 wired the
ComponentBroker at the composition root and #2276 added activation state, but nothing
outside tests ever submitted a request. This adds the narrowest existing seam — a Lua host
surface — because plugins are the intended consumers and the accepted capability model
already covers them. No new protocol, no new spawn path, no IPC scope invention.

  • bitty.component.request{ id, method, url, headers?, body?, timeout_ms? } validates
    shape and bounds, enqueues one submission, and returns a ticket. It never spawns, sends,
    or waits, so no Lua callback can hold the owner thread for a component deadline.
  • bitty.component.poll(ticket) returns nil while in flight, a bounded response
    table (status, headers, body, bytes, untrusted = true) on success, and raises
    the stable typed class on failure.
  • Wiring reuses the existing broker. The composition root
    (bitty_terminal::component_bridge) drains submissions once per cold tick, calls
    Runtime::submit_component_request (the [CTX-1361] feat(runtime): wire the ComponentBroker at the composition root #2267 authorization + submit path), then delivers
    broker events back. Deadlines cancel the broker request; a suspended, reloaded, or
    disposed generation has its tickets purged and its in-flight requests cancelled.
  • Capability model unchanged. Requests need an Activated plugin, the activation-time
    manifest generation, a non-denied grant record bound to that hash, and the canonical
    GrantStore::is_granted + [[network.egress]] intersection. The enqueue-time gate only
    refuses a generation that holds no granted network.connect capability; the runtime
    re-authorizes every submission, and the broker re-resolves and digest-verifies the
    installed component before every spawn.
  • Composition-root registry mirror. mirror_plugin_authority copies each activated
    generation's manifest and already-decided grant into the runtime's policy host. Before
    this, that host was empty in production, so every component request would have denied as
    "plugin is not registered". Nothing is granted by the mirror.

Bounds (all explicit, fail-closed)

Bound Value Enforcement
Request payload (id + URL + headers + body) 8 KiB bridge marshalling ceiling + explicit check, before enqueue
Response body 8 KiB broker max_body_bytes + bridge assembly; oversize fails budget
Headers 16 per request/response, 1 KiB each bridge
Deadline default 5 s, ceiling 30 s enqueue time + pump expiry, then Cancel
Queue 32 submissions, 4 held per plugin enqueue refusal (budget)
Completion window 32 results oldest dropped, late poll reports budget

Typed classes: E_COMPONENT_CAPABILITY_DENIED (capability_denied),
E_COMPONENT_NOT_ACTIVE (plugin_not_active, the #2276 label), E_COMPONENT_BUDGET
(budget), E_COMPONENT_TIMEOUT (timeout), E_COMPONENT_PAYLOAD_TOO_LARGE,
E_COMPONENT_UNAVAILABLE, E_COMPONENT_UNTRUSTED, E_COMPONENT_REQUEST_FAILED, ...

Evidence

Headless integration (crates/bitty-runtime/tests/component_request_surface.rs), fixture
installed through the real bitty extension add and driven by plugin Lua through the
production pump:

served:   ok:200:http://api.example.com/v1/ping (component pid Some(...), spawns 1)
denied:   err:E_COMPONENT_CAPABILITY_DENIED
oversize: err:E_COMPONENT_PAYLOAD_TOO_LARGE   (queue pending 0, in-flight 0)
crashed:  err:E_COMPONENT_REQUEST_FAILED      (StopOutcome::Crashed recorded)
deadline: err:E_COMPONENT_TIMEOUT

Headed harness with the real bitty-net (built from the sibling bitty-network checkout,
installed through bitty extension add), isolated XDG, recorded PIDs only, Hyprland
workspace 5: the plugin's timer issues one GET http://127.0.0.1:18080/hello and the UI
reports bitty-net (component request): status=200 body=hello.
Screenshot: recording/ctx-2254-component-request/workspace5-full.png (local, gitignored);
the owner's workspace was restored afterwards and no bitty-net child survived.

Gates

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets --locked -- -D warnings
  • cargo clippy -p bitty-terminal --features dev-tools --all-targets --locked -- -D warnings
  • cargo nextest run -p bitty-runtime -p bitty-terminal -p bitty-lua -p bitty-plugin-host --locked — 4716 passed, 3 skipped
  • cargo check --workspace --all-targets --locked --target x86_64-pc-windows-msvc
  • ./scripts/check-scratch-paths.sh
  • just ci-local

Non-claims

  • No IPC verb: an IPC producer would need a user-level authority mapping the accepted model
    does not define, and the task explicitly preferred Lua when plugins are the consumers.
  • No streaming, watch, subscription, or retained handle: one request, one bounded response.
  • The response body crosses as lossy UTF-8 with a real bytes count; binary component
    payloads are not a supported Lua shape.
  • The runtime policy-host mirror happens at startup for Active generations; a plugin
    suspended only in the plugin runtime after startup keeps its mirrored grant until the next
    start (component requests from it then fail closed at the plugin-runtime lifecycle, which
    parks its commands).
  • No claim for graphics/agent/execution component wiring; no claim that the CDN artifacts
    are published ([0.1.0] Upstream extension binary distribution via R2 + CDN (registry backend) #2111).
  • bitty-net in the headed run came from local sources (the CDN extensions/net paths are
    still 404), same limitation as [CTX-1361] feat(cli): report component activation state + bitty-net acceptance evidence #2276.

Docs: the network candidate now records the surface (bitty-terminal-docs PR #250).

Closes #2254

reviewer added 2 commits October 20, 2026 09:24
…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.
…ivating 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.
@Xuepoo Xuepoo added this to the 0.0.24 milestone Oct 20, 2026
@Xuepoo Xuepoo added feat Feature P1 Priority: high area:runtime Area: runtime orchestration labels Oct 20, 2026
@coderabbitai

coderabbitai Bot commented Oct 20, 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 2 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
  • Configuration used: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c09a22ea-5fd0-420e-9532-a2e403df36e6
📥 Commits

Reviewing files that changed from the base of the PR and between 470c20a and 8f15add.

📒 Files selected for processing: 15
  • crates/bitty-lua/src/host.rs
  • crates/bitty-lua/src/lib.rs
  • crates/bitty-lua/tests/component_bridge.rs
  • crates/bitty-runtime/src/component/broker.rs
  • crates/bitty-runtime/src/component/host.rs
  • crates/bitty-runtime/src/component/mod.rs
  • crates/bitty-runtime/src/plugin_runtime/component_requests.rs
  • crates/bitty-runtime/src/plugin_runtime/mod.rs
  • crates/bitty-runtime/src/plugin_runtime/services.rs
  • crates/bitty-runtime/src/runtime/component_host.rs
  • crates/bitty-runtime/tests/component_request_surface.rs
  • crates/bitty-terminal/src/component_bridge.rs
  • crates/bitty-terminal/src/lib.rs
  • crates/bitty-terminal/src/main.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

Comment @coderabbitai help to get the list of available commands.

@Xuepoo

Xuepoo commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

Local just ci-local (act) note

The act run fails on exactly one test, unrelated to this diff:

bitty-runtime::spawn_surface granted_production_backend_runs_confined_git
left: Some("E_SPAWN_FAILED") / right: Some("OK")

The identical test passes on the host with the same build (cargo nextest run -p bitty-runtime --test spawn_surface → 5 passed), so the failure is the act container blocking the Landlock
syscalls the confined-spawn adapter needs, not a regression. Every other Quality gates step
(fmt, clippy -D warnings, the rest of the suite) passed in the container. Remote CI remains
the acceptance gate. Excerpt: recording/ctx-2254-component-request/ci-local-failure.txt.

@Xuepoo

Xuepoo commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

Windows job: unrelated bitty-config wall-clock flake

Windows check and test failed on one test outside this diff:

bitty-config file::tests::lua_full_scalar_tables_and_keymaps_parse
full: InvalidInput { message: "config exceeded Lua budgets (suspended: WallClockExceeded { elapsed_ms: 86, budget_ms: 50 })" }

bitty-config is untouched by this PR; the RC-1 50 ms wall budget tripped on a slow Windows
runner (the same accounting area tracked by CTX-1379). 7211/7212 Windows tests passed,
including every component/plugin test added here. Re-running the failed job.

@Xuepoo
Xuepoo merged commit 048d20f into main Oct 20, 2026
24 of 27 checks passed
@Xuepoo
Xuepoo deleted the ctx-2254/feat-component-request branch October 20, 2026 02:32
Xuepoo added a commit that referenced this pull request Oct 20, 2026
The first pass was audited at `470c20ab`; four commits merged while it was open
and one of them changes a claim the entry makes.

- #2296 adds the production component request surface
  (`bitty.component.request` / `bitty.component.poll`) and closes #2254, so the
  Known issues bullet no longer says no request producer exists. Its real
  limits replace it: no IPC verb, no streaming or retained handle, lossy UTF-8
  response bodies, and a mirrored grant surviving a runtime-only suspend.
- #2295 hardens the activation record against a planted symlink on both the
  write and read side, with a typed `ActivationWriteError`.
- #2291 moves all six extracted extension pins to their upstream heads and adds
  the pin drift gate.
- #2298 deflakes the cross-VM `command_invoke` test against the 50 ms
  production RC-1 wall budget.

The provenance line now records the audited head `6c4ae437`. The RC-1 fuel
accounting fix is still not claimed: PR #2292 remains open.

Docs-only: no code, scripts, workflows, or pins touched.
Xuepoo added a commit that referenced this pull request Oct 20, 2026
The first pass was audited at `470c20ab`; four commits merged while it was open
and one of them changes a claim the entry makes.

- #2296 adds the production component request surface
  (`bitty.component.request` / `bitty.component.poll`) and closes #2254, so the
  Known issues bullet no longer says no request producer exists. Its real
  limits replace it: no IPC verb, no streaming or retained handle, lossy UTF-8
  response bodies, and a mirrored grant surviving a runtime-only suspend.
- #2295 hardens the activation record against a planted symlink on both the
  write and read side, with a typed `ActivationWriteError`.
- #2291 moves all six extracted extension pins to their upstream heads and adds
  the pin drift gate.
- #2298 deflakes the cross-VM `command_invoke` test against the 50 ms
  production RC-1 wall budget.

The provenance line now records the audited head `6c4ae437`. The RC-1 fuel
accounting fix is still not claimed: PR #2292 remains open.

Docs-only: no code, scripts, workflows, or pins touched.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:runtime Area: runtime orchestration feat Feature P1 Priority: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[0.0.24] Native components are installable but never executed: no production ComponentBroker host

1 participant