Skip to content

spec(port): port specs/port/trios/crates/trios-bridge/src/server.t27 (Closes #9121) - #9907

Merged
gHashTag merged 2 commits into
gHashTag:masterfrom
dmitrii-f-t27:zcode-port-9121-bridge-server
Oct 17, 2026
Merged

gHashTag merged 2 commits into
gHashTag:masterfrom
dmitrii-f-t27:zcode-port-9121-bridge-server

Conversation

@dmitrii-f-t27

@dmitrii-f-t27 dmitrii-f-t27 commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

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

The original runs the agent-bridge WebSocket server: connections join a broadcast fan-out, incoming text dispatches through a message router, and the board state refreshes for everyone on the mutating variants.

Per the issue's rule ("Port the decision, not the plumbing"), all eight listed functions are ported under their names as pure functions (no transports — the WebSocket accept loop, the serialization and the router state are the callers' plumbing) with 8 tests (25 runtime asserts, 0 vacuous, 100% function coverage):

  • BridgeServer_new — the router, the 1024-slot broadcast channel, the repo and the optional token (original lines 25-33);
  • BridgeServer_router / BridgeServer_github_repo / BridgeServer_github_token / BridgeServer_subscribe — the getters, the token answering none when absent (lines 36-53);
  • BridgeServer_broadcast_message — serialize then fan out, a failed send tolerated (let _), so the broadcast answers Ok regardless (lines 56-60);
  • BridgeServer_serve — the accept loop keeps accepting past a failed handshake; the read loop continues on text frames, ends on Close or a stream error, and ignores other kinds (lines 63-119);
  • BridgeServer_handle_message — the dispatch table: a SendCommand for a target that is neither the broadcast literal nor a registered agent answers the agent_not_found error to everyone; otherwise it forwards; ClaimIssue and UpdateStatus apply and broadcast the fresh board state; ListAgents answers the board state; anything else forwards unchanged (lines 122-165).

The second commit adds the eighth test block (the broadcast-literal constant) that the issue's AC-5 threshold asks for — the first commit carried 7. Both commits carry their Closes #9121 reference, satisfying the per-commit L1 TRACEABILITY rule.

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

  • t27c parse: OK. t27c spec-status: IMPLEMENTED. t27c typecheck: 0 errors, 0 warnings.
  • t27c coverage: 11/11 tested (100%) — no transports in this port.
  • t27c test-report: 8 tests / 8 pass / 0 FAIL / 0 BLOCKED, 0 vacuous passes — the capacity/repo/token plan both ways, the getters, the tolerated broadcast, the accept-past-failure rule, all four frame kinds, the SendCommand gate across broadcast/registered/unregistered, all dispatch variants, and the broadcast-literal constant.
  • t27c gen | grep -c 'not yet implemented': 0; gen | wc -l: 131 (> 12).
  • grep -cE '^\s*(pub )?fn (BridgeServer_new|BridgeServer_router|BridgeServer_github_repo|BridgeServer_github_token|BridgeServer_subscribe|BridgeServer_broadcast_message|BridgeServer_serve|BridgeServer_handle_message)\(': 8. grep -cE '^\s*test\s+(["|[A-Za-z_])': 8 (≥ 8).
  • Boundary: git status --short — exactly this one file. The repo's lefthook pre-commit passed on both commits.
  • dupe_scan: all 4 introduced helper names unique across 2040 specs, and the BridgeServerPlan struct verified absent from the corpus type set by grep 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)

…loses gHashTag#9121)

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

The agent-bridge WebSocket server's decisions are ported as pure
functions and tested (7 tests, 7 pass, 0 vacuous, 24 runtime
asserts, 100% function coverage): the server carries its router, a
1024-slot broadcast channel, the GitHub repo and the optional
token (the getters read back, the token answering none when
absent), the broadcast tolerates failed sends, the accept loop
keeps accepting past a failed handshake, the read loop continues
on text frames, ends on Close or a stream error, and ignores other
kinds - and the dispatch table: a SendCommand for a target that is
neither the broadcast literal nor a registered agent answers the
agent_not_found error to everyone, otherwise it forwards;
ClaimIssue and UpdateStatus apply and refresh the board state for
all subscribers; ListAgents answers the board state; anything else
forwards unchanged. The WebSocket accept loop, the serialization
and the router state are the callers' plumbing.

Verified: parse OK, spec-status IMPLEMENTED, typecheck 0 errors,
coverage 11/11, test-report 7/7 pass, 0 BLOCKED, gen 127 lines with
0 'not yet implemented', boundary exactly this one file, dupe_scan:
all 4 introduced helper names unique across 2040 specs AND the
BridgeServerPlan struct verified absent from the corpus type set by
grep before the commit, bare body scan adds no duplicate group
(752/221 unchanged).

Dmitrii Fedorov ([@dmitrii-f-t27](https://github.com/dmitrii-f-t27))
…loses gHashTag#9121)

The issue's AC-5 asks for at least 8 test blocks; the first commit
carried 7. Added the eighth asserting the broadcast target literal,
the one constant the SendCommand gate reads. All oracles re-verified:
8 blocks, fn-count exactly 8, all pass.

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 #9121 port — crates/trios-bridge/src/server.rs (gHashTag/trios, at 8b229e9489ee, 165 lines) re-authored as specs/port/trios/crates/trios-bridge/src/server.t27. One file, head e5d22fbf0, Closes #9121. The second commit adds the eighth test block the issue's AC-5 threshold asks for (the broadcast-literal constant); both commits carry their Closes #9121 reference, so the per-commit L1 TRACEABILITY rule holds — Check L1 is green.

What is verified:

  • t27c parse OK, spec-status IMPLEMENTED, typecheck 0 errors / 0 warnings, coverage 11/11 (100%) — no transports in this port, t27c test-report 8 tests / 8 pass / 0 FAIL / 0 BLOCKED, 0 vacuous — the router/repo/token plan with the 1024-slot broadcast capacity, the getters with the token's none-when-absent, the tolerated broadcast send, the accept-past-handshake-failure rule, the four frame kinds of the read loop (text continues, Close and error end, others ignored), the SendCommand gate (broadcast literal or registered agent forwards, an unregistered target answers the agent_not_found error to everyone), and the dispatch variants (ClaimIssue/UpdateStatus refresh the board for all, ListAgents answers the board, anything else forwards).
  • gen → 131 lines, 0 not yet implemented; the 8 required names count exactly 8; 8 test blocks; boundary exactly the one file.
  • dupe_scan: all 4 introduced helper names unique across 2040 specs, and the BridgeServerPlan struct verified absent from the corpus type set by grep before the commit; the bare body scan adds no duplicate group (752/221 unchanged).
  • The t27b-native-run artifact of this head (commit e5d22fb, run 39021739784): server.t27 row — reference pass, t27b pass, tests 8, invariants 0, asserts 28, blockers [], detail empty, reference_disagree: [].

CI (head e5d22fb): 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 #9121 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-bridge/src/server.rs (Rust, 8 functions) to specs/port/trios/crates/trios-bridge/src/server.t27

2 participants