Skip to content

spec(port): port specs/port/trios/crates/trios-server/src/tools/trios-crypto.t27 (Closes #5641) - #9950

Merged
gHashTag merged 1 commit into
gHashTag:masterfrom
dmitrii-f-t27:zcode-port-5641-server-crypto
Oct 17, 2026
Merged

gHashTag merged 1 commit into
gHashTag:masterfrom
dmitrii-f-t27:zcode-port-5641-server-crypto

Conversation

@dmitrii-f-t27

Copy link
Copy Markdown
Contributor

Summary

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

The original is the MCP tool exposing SHA-256 mining operations.

Per the issue's rule ("Port the decision, not the plumbing"), both listed functions are ported under their names as pure functions (no transports — the SHA-256 FFI and the hex encoding are the callers' plumbing) with 6 tests (38 runtime asserts, 0 vacuous, 100% function coverage):

  • dispatch — the one-tool routing table: only crypto_mine_sha256 routes, anything else answers None (original lines 12-17);
  • crypto_mine_sha256 — the four validation gates with their exact lengths and error strings (data at most 76, required, an array; the target exactly 32, required; start_nonce required; the nonce required and a valid u64), the composed first-violation-answers rule, the 80-byte header layout — the data bytes in the first slots (shorter data leaves zeros behind), the nonce in the last 8 bytes in big-endian at offset 72 — and the four-field mining outcome (nonce, hex hash, computed count, found flag) with the mining failed error prefix (lines 20-98).

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: 19/19 tested (100%) — no transports in this port.
  • t27c test-report: 6 tests / 6 pass / 0 FAIL / 0 BLOCKED, 0 vacuous passes — the header layout, the slot arithmetic (data 0..75, nonce 72..79, the shorter-data zeros), the dispatch table with the unknown-name rejection, all four gates at their boundaries, the composition's first-violation rule, and the outcome shape.
  • t27c gen | grep -c 'not yet implemented': 0; gen | wc -l: 169 (> 12).
  • grep -cE '^\s*(pub )?fn (dispatch|crypto_mine_sha256)\(': 2. grep -cE '^\s*test\s+(["|[A-Za-z_])': 6 (≥ 2).
  • Boundary: git status --short — exactly this one file. The repo's lefthook pre-commit passed.
  • dupe_scan: all 17 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)

…-crypto.t27 (Closes gHashTag#5641)

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

The crypto mining MCP tool's decisions are ported as pure functions
and tested (6 tests, 6 pass, 0 vacuous, 38 runtime asserts, 100%
function coverage): the one-tool dispatch table (only
crypto_mine_sha256 routes; anything else answers None), the four
validation gates with their exact lengths and error strings (data
at most 76 required; target exactly 32 required; start_nonce
required; nonce required and a valid u64), the composed
first-violation-answers rule, the 80-byte header layout - the data
bytes in the first slots with shorter data leaving zeros behind,
the nonce in the LAST 8 bytes in big-endian at offset 72 - and the
four-field mining outcome (nonce, hex hash, computed count, found
flag) with the mining-failed error prefix. The SHA-256 FFI and the
hex encoding are the callers' plumbing.

Verified: parse OK, spec-status IMPLEMENTED, typecheck 0 errors,
coverage 19/19, test-report 6/6 pass, 0 BLOCKED, gen 169 lines
with 0 'not yet implemented', boundary exactly this one file,
dupe_scan: all 17 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 #5641 port — crates/trios-server/src/tools/trios-crypto.rs (gHashTag/trios, at 8b229e9489ee, 99 lines) re-authored as specs/port/trios/crates/trios-server/src/tools/trios-crypto.t27. One file, one commit, head 6d9379179, Closes #5641.

What is verified:

  • t27c parse OK, spec-status IMPLEMENTED, typecheck 0 errors / 0 warnings, coverage 19/19 (100%) — no transports in this port, t27c test-report 6 tests / 6 pass / 0 FAIL / 0 BLOCKED, 0 vacuous — the one-tool dispatch table with the unknown-name rejection, all four validation gates at their boundaries with the exact error strings (data ≤ 76 required; target exactly 32 required; start_nonce required; nonce required and a valid u64), the composed first-violation-answers rule, the 80-byte header layout (data in the first slots with shorter data leaving zeros; the nonce in the last 8 bytes in big-endian at offset 72), and the four-field mining outcome with the mining failed prefix.
  • gen → 169 lines, 0 not yet implemented; the 2 required names count exactly 2; 6 test blocks; boundary exactly the one file.
  • dupe_scan: all 17 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 6d93791, run 39039281261): trios-crypto.t27 row — reference pass, t27b pass, tests 6, invariants 0, asserts 38, blockers [], detail empty, reference_disagree: [].

CI (head 6d93791): 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 #5641 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-server/src/tools/trios-crypto.rs (Rust, 2 functions) to specs/port/trios/crates/trios-server/src/tools/trios-crypto.t27

2 participants