Skip to content

spec(port): port specs/port/trios/crates/trios-agents/src/lib.t27 (Closes #7218) - #9948

Merged
gHashTag merged 1 commit into
gHashTag:masterfrom
dmitrii-f-t27:zcode-port-7218-agents-lib
Oct 17, 2026
Merged

gHashTag merged 1 commit into
gHashTag:masterfrom
dmitrii-f-t27:zcode-port-7218-agents-lib

Conversation

@dmitrii-f-t27

Copy link
Copy Markdown
Contributor

Summary

Port gHashTag/trios:crates/trios-agents/src/lib.rs (at 8b229e9489ee, 145+ lines) as specs/port/trios/crates/trios-agents/src/lib.t27 — Roadmap Stage 6 (goal #4548), target t27c gen-rust. Closes #7218.

The original is the HTTP client and MCP proxy for zig-agents, providing AI agent orchestration.

Per the issue's rule ("Port the decision, not the plumbing"), all six listed functions are ported under their names as pure functions (no transports — the HTTP client and the atomic counter are the callers' plumbing) with 7 tests (26 runtime asserts, 0 vacuous, 100% function coverage), including the original's own create-agent and status tests:

  • simple_id — the FNV-1a hash: the offset basis 0xcbf29ce484222325, the prime 0x100000001b3, xor-then-multiply per byte, the answer formatted as 16 hex chars (the formatting itself is the caller's plumbing); the probe-verified exact values — the empty seed answers the basis unchanged, the single-byte seed answers basis ^ byte times the prime (original lines 81-88);
  • create_agent — the agent id is the simple_id of the agent name alone; the description and the type ride along in the config but never enter the id (lines 91-94);
  • get_agent_status — the idle status with no task (lines 97-103);
  • spawn_agent_task — the task-id plan: the id differs from the agent id and across counters (the name joined to the monotonic counter, the join the caller's plumbing) (lines 106-109);
  • monotonic_id — the fetch-from-1 contract: the first answer is 1, pre-increment-then-use (lines 112-116);
  • get_task_result — the completed status with the empty JSON object (lines 119-125).

The measured language finding this port carries

The language's integer multiply panics on overflow (measured in this suite's runtime: u64 and u32 alike — 0xffffffffffffffff * 2 fails), so the original's wrapping_mul is not directly expressible. It is rebuilt honestly from 32-bit halves, every intermediate value below 2^64 — low = aL*bL fits, the cross terms are taken mod 2^32, and the halves recombine in range — verified against the wrap contract: (2^64−1)·2 mod 2^64 = 2^64−2, and small values multiply exactly.

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: 14/14 tested (100%) — no transports in this port.
  • t27c test-report: 7 tests / 7 pass / 0 FAIL / 0 BLOCKED, 0 vacuous passes — the FNV basis and single-byte exact values, the determinism and seed-sensitivity, the wrap contract with the exact products, the name-only id with its insensitivity to the description and type, the idle status, the counter contract with the spawn plan, and the completed result.
  • t27c gen | grep -c 'not yet implemented': 0; gen | wc -l: 141 (> 12).
  • grep -cE '^\s*(pub )?fn (simple_id|create_agent|get_agent_status|spawn_agent_task|monotonic_id|get_task_result)\(': 6. grep -cE '^\s*test\s+(["|[A-Za-z_])': 7 (≥ 6).
  • Boundary: git status --short — exactly this one file. The repo's lefthook pre-commit passed.
  • dupe_scan: all 9 introduced names unique across 2040 specs, and the SpawnPlan 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)

…oses gHashTag#7218)

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

The agents client's decisions are ported as pure functions and
tested (7 tests, 7 pass, 0 vacuous, 26 runtime asserts, 100%
function coverage), including the original's own create-agent and
status tests: the FNV-1a hash of simple_id - the offset basis
0xcbf29ce484222325, the prime 0x100000001b3, xor-then-multiply per
byte - with the probe-verified exact values (the empty seed answers
the basis; the single-byte seed answers basis^byte times the
prime); create_agent id-ing the NAME alone (the description and
type never entering the id); get_agent_status answering idle with
no task; the monotonic counter's fetch-from-1 contract (the first
answer 1, pre-increment-then-use) with the spawn plan - the task id
differs from the agent id and across counters; and get_task_result
answering completed with the empty JSON object.

The language's integer multiply PANICS on overflow (measured:
u64 and u32 alike in this suite's runtime), so the original's
wrapping_mul is rebuilt honestly from 32-bit halves - low = aL*bL
fits, the cross terms taken mod 2^32, the halves recombining in
range - verified against the wrap contract ((2^64-1)*2 mod 2^64 =
2^64-2). The hex formatting of the id and the HTTP client are the
callers' plumbing.

Verified: parse OK, spec-status IMPLEMENTED, typecheck 0 errors,
coverage 14/14, test-report 7/7 pass, 0 BLOCKED, gen 128 lines
with 0 'not yet implemented', boundary exactly this one file,
dupe_scan: all 9 introduced names unique across 2040 specs AND the
SpawnPlan 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))
@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 #7218 port — crates/trios-agents/src/lib.rs (gHashTag/trios, at 8b229e9489ee, 145+ lines) re-authored as specs/port/trios/crates/trios-agents/src/lib.t27. One file, one commit, head 237303f08, Closes #7218.

What is verified:

  • t27c parse OK, spec-status IMPLEMENTED, typecheck 0 errors / 0 warnings, coverage 14/14 (100%) — no transports in this port, t27c test-report 7 tests / 7 pass / 0 FAIL / 0 BLOCKED, 0 vacuous — the FNV-1a exact values (the empty seed answers the basis; the single-byte seed answers basis^byte times the prime), the determinism and seed-sensitivity, the wrap contract, the name-only agent id, the idle status, the fetch-from-1 counter contract with the spawn plan, and the completed result — including the original's own create-agent and status tests.
  • gen → 141 lines, 0 not yet implemented; the 6 required names count exactly 6; 7 test blocks; boundary exactly the one file.
  • dupe_scan: all 9 introduced names unique across 2040 specs, and the SpawnPlan 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 measured language finding this port carries: the language's integer multiply panics on overflow (u64 and u32 alike, measured in this suite's runtime), so the original's wrapping_mul is rebuilt honestly from 32-bit halves — every intermediate value below 2^64, verified against the wrap contract ((2^64−1)·2 mod 2^64 = 2^64−2) and the small-value products.
  • The t27b-native-run artifact of this head (commit 237303f, run 39038210986): lib.t27 row — reference pass, t27b pass, tests 7, invariants 0, asserts 26, blockers [], detail empty, reference_disagree: [].

CI (head 237303f): 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 #7218 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-agents/src/lib.rs (Rust, 6 functions) to specs/port/trios/crates/trios-agents/src/lib.t27

2 participants