Skip to content

spec(port): port specs/port/trios/crates/trios-cli/src/db.t27 (Closes #9169) - #9905

Merged
gHashTag merged 1 commit into
gHashTag:masterfrom
dmitrii-f-t27:zcode-port-9169-cli-db
Oct 17, 2026
Merged

gHashTag merged 1 commit into
gHashTag:masterfrom
dmitrii-f-t27:zcode-port-9169-cli-db

Conversation

@dmitrii-f-t27

Copy link
Copy Markdown
Contributor

Summary

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

The original is the SQLite leaderboard: local persistent storage for experiment results.

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 SQLite connection and the SQL round-trips are the callers' plumbing) with 9 tests (26 runtime asserts, 0 vacuous, 100% function coverage):

  • Leaderboard_path / Leaderboard_open — the fixed database path .trinity/leaderboard.db, the parent directory created on demand, the nine-column leaderboard table and its two indexes covering the two common queries (original lines 30-66, 208-211);
  • Leaderboard_insert — the eight value columns written, answering the rowid (lines 69-87);
  • Leaderboard_top — the best-N rows by val_bpb ascending under the limit (lines 90-116);
  • Leaderboard_by_agent — the agent's rows newest-timestamp-first (lines 119-145);
  • Leaderboard_by_exp_id — the one row with that experiment id, or none (lines 148-172);
  • Leaderboard_delete — removal by the exp_id key (lines 175-178);
  • Leaderboard_stats — the three aggregates: the count, the minimum and the average val_bpb (lines 181-197).

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: 9 tests / 9 pass / 0 FAIL / 0 BLOCKED, 0 vacuous passes.
  • t27c gen | grep -c 'not yet implemented': 0; gen | wc -l: 126 (> 12).
  • grep -cE '^\s*(pub )?fn (Leaderboard_open|Leaderboard_insert|Leaderboard_top|Leaderboard_by_agent|Leaderboard_by_exp_id|Leaderboard_delete|Leaderboard_stats|Leaderboard_path)\(': 8. grep -cE '^\s*test\s+(["|[A-Za-z_])': 9 (≥ 8).
  • Boundary: git status --short — exactly this one file. The repo's lefthook pre-commit passed.
  • dupe_scan: all 10 introduced names unique across 2040 specs, and both struct names 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)

…HashTag#9169)

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

The leaderboard SQLite storage's decisions are ported as pure
functions and tested (9 tests, 9 pass, 0 vacuous, 26 runtime
asserts, 100% function coverage): the fixed database path at
.trinity/leaderboard.db with its parent directory created on
demand, the nine-column entry shape with the id optional until
insert answers it, the two indexes covering the two common queries
(val_bpb for top, agent for by_agent), the eight value columns the
insert writes, the best-N ordering of top (val_bpb ascending under
the limit), the newest-first ordering of by_agent, the one-row-or-
none optionality of by_exp_id, the exp_id key of delete, and the
three aggregates of stats (count, MIN(val_bpb), AVG(val_bpb)). The
SQLite connection and the SQL round-trips are the callers'
plumbing.

Verified: parse OK, spec-status IMPLEMENTED, typecheck 0 errors,
coverage 16/16, test-report 9/9 pass, 0 BLOCKED, gen 126 lines with
0 'not yet implemented', boundary exactly this one file, dupe_scan:
all 10 introduced names unique across 2040 specs AND both struct
names (OpenPlan, StatsShape) 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 #9169 port — crates/trios-cli/src/db.rs (gHashTag/trios, at 8b229e9489ee, 211 lines) re-authored as specs/port/trios/crates/trios-cli/src/db.t27. One file, one commit, head c3aff2642, Closes #9169.

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 9 tests / 9 pass / 0 FAIL / 0 BLOCKED, 0 vacuous — the fixed database path .trinity/leaderboard.db with the parent directory created on demand, the nine-column entry shape with the id optional until insert answers it, the two indexes covering the two common queries (val_bpb for top, agent for by_agent), the eight value columns the insert writes, the best-N ordering of top (val_bpb ascending under the limit, with the over-cap and zero-limit cases), the newest-first ordering of by_agent, the one-row-or-none optionality of by_exp_id, the exp_id key of delete, and the three aggregates of stats (count, MIN, AVG over val_bpb).
  • gen → 126 lines, 0 not yet implemented; the 8 required names count exactly 8; 9 test blocks; boundary exactly the one file.
  • dupe_scan: all 10 introduced names unique across 2040 specs, and both struct names (OpenPlan, StatsShape) 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 c3aff26, run 39019860627): db.t27 row — reference pass, t27b pass, tests 9, invariants 0, asserts 26, blockers [], detail empty, reference_disagree: [].

CI (head c3aff26): 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 #9169 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-cli/src/db.rs (Rust, 8 functions) to specs/port/trios/crates/trios-cli/src/db.t27

2 participants