Skip to content

spec(port): port specs/port/trinity/src/bsd/verify_lmfdb.t27 (Closes #9611) - #10119

Closed
dmitrii-f-t27 wants to merge 2 commits into
gHashTag:masterfrom
dmitrii-f-t27:zcode-port-9611-verify-lmfdb
Closed

dmitrii-f-t27 wants to merge 2 commits into
gHashTag:masterfrom
dmitrii-f-t27:zcode-port-9611-verify-lmfdb

Conversation

@dmitrii-f-t27

Copy link
Copy Markdown
Contributor

Summary

Port gHashTag/trinity:src/bsd/verify_lmfdb.zig (at ee512359254b, 84 lines) as specs/port/trinity/src/bsd/verify_lmfdb.t27 — Roadmap Stage 5 (goal #4547), target t27c gen-rust. Closes #9611.

The original is the BSD verification command for LMFDB curve data: it loads a JSON of curves, verifies the BSD formula for rank-0 curves and prints a summary.

Per the issue's rule ("Port the decision, not the plumbing"), the one listed function is ported under its name as a pure function (no transports — the JSON load, the table prints and the colour codes are the callers' plumbing) with 7 tests (35 runtime asserts, 0 vacuous, 100% function coverage):

  • the usage gate (original lines 18-23): no argument → the usage block prints and the command returns before any load;
  • the --test default (lines 26-29): --test selects the built-in bsd_test_curves.json; any other argument is the JSON path as-is;
  • the rank-0 filter (line 50): only rank 0 curves are verified — everything else is skipped without failing anything;
  • the BSD formula (lines 52-58): Sha = L(E,1) * torsion² / (Omega * c_p) carried as special_value * torsion² / c_p (special_value = L/Ω), with the orders widened to f64 before the square so no integer multiply can overflow;
  • the 0.5 match window (lines 61-64): the computed Sha matches the known order when the two sit strictly within 0.5 — a difference of exactly 0.5 fails, on either side;
  • the summary verdict (lines 76-80): ALL PASSED exactly when nothing failed — a run with no eligible curves reaches it too (0/0).

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: 7/7 tested (100%) — no transports in this port.
  • t27c test-report: 7 tests / 7 pass / 0 FAIL / 0 BLOCKED, 0 vacuous passes — the usage gate, the --test default and the pass-through, the rank filter both ways (including the skipped-curve outcome), the formula on exact dyadic values, the window at 0.4/0.5/0.6 on both sides, and the command end-to-end for match, mismatch and skip.
  • All four generators emit this spec before the push: gen (110 lines, 0 'not yet implemented'), gen-rust, gen-c, gen-verilog — the W469 lesson applied proactively.
  • grep -cE '^\s*(pub )?fn (runVerifyLMFDBCommand)\(': 1. grep -cE '^[[:space:]]*test[[:space:]]+("|[A-Za-z_])': 7 (≥ 1).
  • Boundary: git status --short — exactly this one file. The repo's lefthook pre-commit passed.
  • dupe_scan: all 7 function names unique across the corpus (checked before the commit); the branch is merged onto current master and the bare body scan on the merged tree reports no error lines — no new duplicate group, none grew.

Dmitrii Fedorov (@dmitrii-f-t27)

…HashTag#9611)

Port gHashTag/trinity:src/bsd/verify_lmfdb.zig (at ee512359254b, 84
lines) as specs/port/trinity/src/bsd/verify_lmfdb.t27 - Roadmap
Stage 5, goal gHashTag#4547, target t27c gen-rust.

The BSD verification command's decisions are ported as pure functions
and tested (7 tests, 7 pass, 0 vacuous, 35 runtime asserts, 100%
function coverage): the usage gate (no argument prints usage and
returns before any load), the --test default (bsd_test_curves.json;
any other argument is the JSON path as-is), the rank-0 filter (only
rank 0 curves are verified; everything else is skipped without
failing), the BSD formula Sha = L(E,1) * torsion^2 / (Omega * c_p)
carried as special_value * torsion^2 / c_p with the orders widened to
f64 before the square so no integer multiply can overflow, the 0.5
match window (strict: a difference of exactly 0.5 fails, on either
side), and the summary verdict (ALL PASSED exactly when nothing
failed - a run with no eligible curves reaches it too). The JSON
load, the table prints and the colour codes are the callers'
plumbing. All four generators (gen, gen-rust, gen-c, gen-verilog)
emit this spec before the push.

Verified: parse OK, spec-status IMPLEMENTED, typecheck 0 errors,
coverage 7/7, test-report 7/7 pass, 0 BLOCKED, gen 110 lines with
0 'not yet implemented', boundary exactly this one file, dupe_scan:
all 7 function names unique, bare body scan adds no group of mine.

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 only you can merge it.

Verification of this head (d34a1c4, the spec commit merged onto current master):

  • Required CI trio green: validate, check-linked-issue, parse-ratchet; also Check L1 TRACEABILITY and duplicate-bodies green — and cli-tri is green on this head too (the ci: repair the two workflows whose failure was in the workflow #3324 base break was fixed upstream).
  • The t27b-native-run artifact of this head (commit d34a1c4, run 39065088628) row for specs/port/trinity/src/bsd/verify_lmfdb.t27: reference pass, t27b pass, tests 7, invariants 0, asserts 35, blockers [], detail empty, reference_disagree: [].
  • All four generators were run locally before the push (gen, gen-rust, gen-c, gen-verilog) — this spec emits cleanly everywhere.
  • The only red checks are proven base-red on master WITHOUT this PR:
    • Corpus ratchet: the failing step is 'Every conflicted type name has a written verdict' — docs/reports/type_conflicts_classified.json disagrees with the tree. The identical error fails on master itself (run 39064558250 on b655dce, and three more consecutive master SHAs before it). This spec declares no struct or enum, so it cannot add a conflicted type name.
    • t27b-native-ratchet: the registration debt, red on master for every port PR of this series.

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

Dmitrii Fedorov (@dmitrii-f-t27)

@gHashTag

Copy link
Copy Markdown
Owner

Landed unchanged (as a merge commit) in #10174, together with ten other green ports, on top of the master fixes #10160/#10172. Closing this as superseded; the linked issue closes when #10174 merges.

@gHashTag gHashTag closed this Oct 18, 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/trinity:src/bsd/verify_lmfdb.zig (Zig, 1 function) to specs/port/trinity/src/bsd/verify_lmfdb.t27

2 participants