Skip to content

refactor: single-source node wire interface from Rust + reserved-handle consts#84

Merged
xiduzo merged 3 commits into
mainfrom
refactor/wire-interface-single-source
Jun 26, 2026
Merged

refactor: single-source node wire interface from Rust + reserved-handle consts#84
xiduzo merged 3 commits into
mainfrom
refactor/wire-interface-single-source

Conversation

@xiduzo

@xiduzo xiduzo commented Jun 26, 2026

Copy link
Copy Markdown
Owner

Follow-through on an architecture review: two deepenings + one recorded "no".

C1 — node wire interface single-sourced from Rust refactor(web)

Ports/emits were authored twice — compile-checked Rust consts and hand-typed in node-components.json — reconciled only by the parity test. Now Rust is the single source:

  • The Catalog Parity Guard generates apps/web/wire-interface.generated.json from ComponentRegistry::declared() under BLESS_WIRE_INTERFACE=1, otherwise asserts the committed file is current (a stale mirror fails CI).
  • Codegen reads the sidecar; impls[].ports/emits are removed from the catalog.
  • Generated TS is byte-identical — the diff is doc-only, no runtime behavior change.
  • bun run catalog:sync blesses + re-codegens in one step.

C3 — reserved runtime handle names as consts refactor(core)

The executor's Port / Internal Event / Hardware Callback routing used bare '_'-prefix checks and "_pin_change"/"_i2c_reply" literals across emit, match, and test sites. Hoisted into a reserved_handles module so the reserved set lives in one place; routing keeps its deep generic catch-all (other => dispatch_internal(&other[1..])). No behavior change.

C2 — not done; recorded as ADR-0010 docs(adr)

The review's top pick — hoisting the desired→live subscription diff into core — contradicts the explicit per-host rationale at subscriptions.rs:13: the diff operates on host-local broker state (rumqttc vs mqtt.js), while the drift-dangerous winner-selection (reconcile_desired) is already shared. Recorded as ADR-0010 so future reviews don't re-suggest it.

Verification

  • cargo test --workspace — core 381 + catalog_parity 2, green.
  • cargo clippy --workspace -- -D warnings -W clippy::pedantic — clean.
  • tsc --noEmit clean; bun run codegen output unchanged (values identical).

New developer loop

Edit Rust ports()/emits()bun run catalog:sync. No more hand-editing the catalog mirror.

🤖 Generated with Claude Code

xiduzo and others added 3 commits June 26, 2026 11:43
The executor decided Port vs Internal Event vs Hardware Callback by bare
'_'-prefix checks and "_pin_change"/"_i2c_reply" string literals spread across
the emit, match, and test sites. Hoist them into a `reserved_handles` module so
the reserved set lives in one place; routing keeps its deep generic catch-all
(`other => dispatch_internal(&other[1..])`). No behavior change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ored catalog mirror

Ports/emits were authored twice — as compile-checked Rust consts and again by
hand in node-components.json — reconciled only by the parity test. Make Rust the
single source: the Catalog Parity Guard now generates wire-interface.generated.json
from ComponentRegistry::declared() under BLESS_WIRE_INTERFACE=1, else asserts the
committed file is current; codegen reads the sidecar; impls[].ports/emits are
removed from the catalog. Generated TS is byte-identical (doc-only diff).
`bun run catalog:sync` blesses + re-codegens in one step. CONTEXT.md refreshed
(incl. the now-deleted build.rs codegen and the reserved_handles consts).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Records the decision to keep the desired→live subscription diff per-host (it
operates on host-local broker state, rumqttc vs mqtt.js) while winner-selection
stays core policy — so future architecture reviews don't re-suggest hoisting the
diff into core. Formalizes the existing rationale at subscriptions.rs:13.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@xiduzo xiduzo merged commit 9619637 into main Jun 26, 2026
7 checks passed
@xiduzo xiduzo deleted the refactor/wire-interface-single-source branch June 26, 2026 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant