Skip to content

spec(port): port specs/port/trios/crates/trios-rainbow-bridge/src/bridge.t27 (Closes #9474) - #9924

Merged
gHashTag merged 1 commit into
gHashTag:masterfrom
dmitrii-f-t27:zcode-port-9474-rainbow-bridge
Oct 17, 2026
Merged

gHashTag merged 1 commit into
gHashTag:masterfrom
dmitrii-f-t27:zcode-port-9474-rainbow-bridge

Conversation

@dmitrii-f-t27

Copy link
Copy Markdown
Contributor

Summary

Port gHashTag/trios:crates/trios-rainbow-bridge/src/bridge.rs (at 8b229e9489ee, 250 lines) as specs/port/trios/crates/trios-rainbow-bridge/src/bridge.t27 — Roadmap Stage 6 (goal #4548), target t27c gen-rust. Closes #9474.

The original is the Rainbow Bridge state machine: Bridge::accept is the single entry point evaluating the full seven-branch legality predicate (INV-8) for one incoming event, answering Ok with the event merkle-appended and fanned out, or the typed error of the first violated branch.

Per the issue's rule ("Port the decision, not the plumbing"), all five listed functions are ported under their names as pure functions (no transports — the hash maps and the funnel are the callers' plumbing) with 7 tests (39 runtime asserts, 0 vacuous, 100% function coverage):

  • Bridge_new — the fresh start: the two layers, the four maps, the funnel (original lines 121-131);
  • Bridge_register_honey_key — the key replaces any previous one (lines 134-136);
  • Bridge_merkle_root_hex / Bridge_lamport — the operator- and test-facing layer readbacks (lines 139-146);
  • Bridge_accept — the fixed check order: the cheapest structural channel-payload mismatch first, then the per-agent lamport monotonicity, then the payload branch (the duplicate-claim gate — a distinct agent at the same lamport; the heartbeat staleness; the unsigned-honey gate — un-signed or rejected by the registered key, with no key meaning the signature presence alone gates; the split-brain State commit), then the layers advance, and the funnel latency budget runs last — the event already advanced when an over-budget latency answers FunnelUnreachable (lines 150-250).

The heartbeat and latency budgets (HEARTBEAT_MAX_S, LATENCY_P95_MS) live in the crate's lib.rs, not this file: their comparison rules are carried with the thresholds as parameters, inventing no values.

Verification (all run live from the worktree root, zig 0.16.0)

  • t27c parse: OK. t27c spec-status: IMPLEMENTED. t27c typecheck: 0 errors, 0 warnings.
  • t27c coverage: 16/16 tested (100%) — no transports in this port.
  • t27c test-report: 7 tests / 7 pass / 0 FAIL / 0 BLOCKED, 0 vacuous passes — the INV-8 catalogue, the fresh construction with its seven fields, the channel and lamport gates (strict advance, first sight passes), the duplicate-claim gate (distinct agent, same lamport, first-claim records), the heartbeat and honey gates (boundary at the budget, un-signed, rejected, no-key), the split-brain gate, and the fixed accept order with the funnel last.
  • t27c gen | grep -c 'not yet implemented': 0; gen | wc -l: 173 (> 12).
  • grep -cE '^\s*(pub )?fn (Bridge_new|Bridge_register_honey_key|Bridge_merkle_root_hex|Bridge_lamport|Bridge_accept)\(': 5. grep -cE '^\s*test\s+(["|[A-Za-z_])': 7 (≥ 5).
  • Boundary: git status --short — exactly this one file. The repo's lefthook pre-commit passed.
  • dupe_scan: all 11 introduced names unique across 2040 specs (checked before the commit); the bare body scan adds no duplicate group (752 bodies / 221 groups on base, identical with this spec present).

Dmitrii Fedorov (@dmitrii-f-t27)

…dge.t27 (Closes gHashTag#9474)

Port gHashTag/trios:crates/trios-rainbow-bridge/src/bridge.rs (at
8b229e9489ee, 250 lines) as specs/port/trios/crates/trios-
rainbow-bridge/src/bridge.t27 - Roadmap Stage 6, goal gHashTag#4548,
target t27c gen-rust.

The Rainbow Bridge state machine's decisions are ported as pure
functions and tested (7 tests, 7 pass, 0 vacuous, 39 runtime
asserts, 100% function coverage): the INV-8 seven-branch legality
catalogue, the fixed check order of Bridge_accept (the cheap
structural channel-payload mismatch first, then the per-agent
lamport monotonicity, then the payload branch, then the layers
advance, and the funnel latency budget LAST - the event already
advanced when an over-budget latency answers FunnelUnreachable),
the duplicate-claim gate (a distinct agent at the same lamport),
the heartbeat staleness over the lib.rs budget, the unsigned-honey
gate (un-signed or rejected by the registered key, with no key
meaning the signature presence alone gates), and the split-brain
State commit gate. The heartbeat and latency budgets live in the
crate's lib.rs, not this file: their comparison rules are carried
with the thresholds as parameters, inventing no values. The hash
maps and the funnel are the callers' plumbing.

Verified: parse OK, spec-status IMPLEMENTED, typecheck 0 errors,
coverage 16/16, test-report 7/7 pass, 0 BLOCKED, gen 173 lines with
0 'not yet implemented', boundary exactly this one file, dupe_scan:
all 11 introduced names unique across 2040 specs (checked before
the commit), bare body scan adds no duplicate group (752/221
unchanged).

Dmitrii Fedorov ([@dmitrii-f-t27](https://github.com/dmitrii-f-t27))
@dmitrii-f-t27

Copy link
Copy Markdown
Contributor Author

@gHashTag Please merge this PR into master via the golden chain — rights on gHashTag/t27 are read-only for me (403), so the merge itself needs your action.

What this is: the #9474 port — crates/trios-rainbow-bridge/src/bridge.rs (gHashTag/trios, at 8b229e9489ee, 250 lines) re-authored as specs/port/trios/crates/trios-rainbow-bridge/src/bridge.t27. One file, one commit, head 8a660a9d8, Closes #9474.

What is verified:

  • t27c parse OK, spec-status IMPLEMENTED, typecheck 0 errors / 0 warnings, coverage 16/16 (100%) — no transports in this port, t27c test-report 7 tests / 7 pass / 0 FAIL / 0 BLOCKED, 0 vacuous — the INV-8 seven-branch catalogue, the fixed accept order (the cheapest structural channel-payload mismatch first, then the per-agent lamport monotonicity, then the payload branch, then the layers advance, and the funnel latency budget LAST — the event already advanced when an over-budget latency answers FunnelUnreachable), the duplicate-claim gate (a distinct agent at the same lamport), the heartbeat staleness at the budget boundary, the unsigned-honey gate (un-signed or rejected by the registered key, with no key meaning the signature presence alone gates), and the split-brain State commit gate.
  • gen → 173 lines, 0 not yet implemented; the 5 required names count exactly 5; 7 test blocks; boundary exactly the one file.
  • The heartbeat and latency budgets (HEARTBEAT_MAX_S, LATENCY_P95_MS) live in the crate's lib.rs, not this file: their comparison rules are carried with the thresholds as parameters, inventing no values.
  • dupe_scan: all 11 introduced names unique across 2040 specs (checked before the commit); the bare body scan adds no duplicate group (752/221 unchanged).
  • The t27b-native-run artifact of this head (commit 8a660a9, run 39027791039): bridge.t27 row — reference pass, t27b pass, tests 7, invariants 0, asserts 39, blockers [], detail empty, reference_disagree: [].

CI (head 8a660a9): required trio green — validate, check-linked-issue, parse-ratchet — Check L1 TRACEABILITY green and Corpus ratchet green; 26 checks pass overall, incl. emit-bitexact, t27b-native-linux, t27b-native-macos.

The 3 reds are the base-red trio, not this change: cli-tri (the #3324 include_str!), duplicate-bodies (only the known base names), t27b-native-ratchet (the same verdict red the Queen's port PRs carry; this spec's own row is reference pass + t27b pass — the registration debt is the UNLISTED class).

After the merge I will: verify the spec file live on the merge SHA, confirm #9474 auto-closed, and file the 14-step report.

Dmitrii Fedorov (@dmitrii-f-t27)

This was referenced Oct 17, 2026
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.

Port gHashTag/trios:crates/trios-rainbow-bridge/src/bridge.rs (Rust, 5 functions) to specs/port/trios/crates/trios-rainbow-bridge/src/bridge.t27

2 participants