Skip to content

spec(port): port specs/port/trios-railway/bin/seed-agent/src/main.t27 (Closes #9800) - #10133

Closed
dmitrii-f-t27 wants to merge 1 commit into
gHashTag:masterfrom
dmitrii-f-t27:zcode-port-9800-seed-agent-main
Closed

dmitrii-f-t27 wants to merge 1 commit into
gHashTag:masterfrom
dmitrii-f-t27:zcode-port-9800-seed-agent-main

Conversation

@dmitrii-f-t27

Copy link
Copy Markdown
Contributor

Summary

Port gHashTag/trios-railway:bin/seed-agent/src/main.rs (at 5cc46e798dda, main from line 89) as specs/port/trios-railway/bin/seed-agent/src/main.t27 — Roadmap Stage 6 (goal #4548), target t27c gen-rust. Closes #9800.

The original is the ADR-0081 pull-based trainer worker: it boots, resolves its Postgres URL, retries the connection, registers the worker and pulls experiments until shutdown.

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 TLS setup, the Postgres connection, the UUID, the worker registration and the iteration runs are the callers' plumbing) with 6 tests (25 runtime asserts, 0 vacuous, 100% function coverage):

  • the L-NEON-RENAME URL chain (original lines 110-115): a present, non-empty --neon-url flag (clap-bound to RAILWAY_POSTGRES_URL) wins; an absent or empty one falls back to the legacy NEON_DATABASE_URL; neither is the boot error;
  • the connect-retry patience (lines 151-169): up to 30 attempts, 2s apart — the attempt that reaches the cap is the bail;
  • the pull loop's wait shape (lines 193-207): a trained or pruned experiment pulls the next at once, an idle queue waits the 30s poll interval, an iteration error backs off 30s;
  • the shutdown release (lines 188-192): the signal ends the loop cleanly;
  • the early-stop rule the CLI carries (lines 62-69): at step 1000 a BPB strictly exceeding the 2.60 ceiling prunes — the ceiling itself does not prune;
  • the CLI defaults (acc1, local-perplexity, seed-agent-auto, trainer external) carried as consts.

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: 6/6 tested (100%) — no transports in this port.
  • t27c test-report: 6 tests / 6 pass / 0 FAIL / 0 BLOCKED, 0 vacuous passes — the URL chain all three ways plus the empty-flag fallthrough, the boot gate at each source, the retry patience at 0/29/30/31, the wait shape for all four outcomes, the shutdown both ways, and the strict ceiling at 2.59/2.60/2.61.
  • All four generators were run before the push: gen (110 lines, 0 'not yet implemented'), gen-rust, gen-c, gen-verilog.
  • grep -cE '^\s*(pub )?fn (main)\(': 1. grep -cE '^[[:space:]]*test[[:space:]]+("|[A-Za-z_])': 6 (≥ 1).
  • Boundary: git status --short — exactly this one file. The repo's lefthook pre-commit passed.
  • dupe_scan: all 6 function names unique across the corpus (checked before the commit); the bare scan reports zero error lines — no new duplicate group, none grew.

Dmitrii Fedorov (@dmitrii-f-t27)

…Closes gHashTag#9800)

Port gHashTag/trios-railway:bin/seed-agent/src/main.rs (at 5cc46e798dda,
main from line 89) as specs/port/trios-railway/bin/seed-agent/src/
main.t27 - Roadmap Stage 6, goal gHashTag#4548, target t27c gen-rust.

The ADR-0081 pull-based trainer worker's boot decisions are ported as
pure functions and tested (6 tests, 6 pass, 0 vacuous, 25 runtime
asserts, 100% function coverage): the L-NEON-RENAME URL chain (a
present, non-empty --neon-url flag bound to RAILWAY_POSTGRES_URL wins;
an absent or empty one falls back to the legacy NEON_DATABASE_URL;
neither is the boot error), the connect-retry patience (up to 30
attempts, 2s apart - the attempt that reaches the cap is the bail),
the pull loop's wait shape (a trained or pruned experiment pulls the
next at once, an idle queue waits the 30s poll interval, an iteration
error backs off 30s), the shutdown release (the signal ends the loop
cleanly), and the early-stop rule the CLI carries (at step 1000 a BPB
strictly exceeding the 2.60 ceiling prunes - the ceiling itself does
not prune). The CLI defaults (acc1, local-perplexity,
seed-agent-auto, poll 30s, step 1000, ceiling 2.60, trainer external)
are carried as consts. The TLS setup, the Postgres connection, the
UUID, the worker registration and the iteration runs are the caller's
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 6/6, test-report 6/6 pass, 0 BLOCKED, gen 110 lines with
0 'not yet implemented', boundary exactly this one file, dupe_scan:
all 6 function names unique, bare scan reports zero error lines.

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 (ca0d712, on current master — no extra merge needed):

  • Required CI trio green: validate, check-linked-issue, parse-ratchet; also Check L1 TRACEABILITY, duplicate-bodies and cli-tri green.
  • The t27b-native-run artifact of this head (commit ca0d712, run 39074329780) row for specs/port/trios-railway/bin/seed-agent/src/main.t27: reference pass, t27b pass, tests 6, invariants 0, asserts 25, 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 (UNJUDGED/STALE); the identical error fails on master itself. This spec declares no struct or enum.
    • t27b-native-ratchet: the registration debt, red on master across this whole port series.

After the merge I will: verify the spec file live on the merge SHA, confirm #9800 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/trios-railway:bin/seed-agent/src/main.rs (Rust, 1 function) to specs/port/trios-railway/bin/seed-agent/src/main.t27

2 participants