GeezerVison is showing github.com — mcpx testing: one seed per run -- format (UUIDv7), derivation, and how it reaches every test · Issue #1949 · developing-today/code
mcpx testing: one seed per run -- format (UUIDv7), derivation, and how it reaches every test #1949DescriptionRelocated from dezren39/darwin-nix#121 on 2026-10-28 (placement audit): mcpx's single source lives in developing-today/code (pkgs/mcpx); re-home tracked at #309. Original body below; issue references inside it are historical (dezren39/nix numbering).
Parent: #93
Summary
Decide the run seed: what one looks like, how every random input in every test is derived from it, how it reaches every go test process (locally and in CI), and how a failure is reproduced from it with one command. Per #91 this is step 1 of the testing strategy: it must land before the first randomized test does, or the first fuzz failure is unreproducible.
Where the seeds are stored and collected is #122. Which library consumes the seed is #123. Generator registry and versioning detail is #124.
Original notes
- testing
- agents should make at least 1 simple, new test for every bug observed from any source, when cheap to do so-- aggresively test many permutations.
- you can absolutely rely on fuzzing anywhere you can fit it and you should whenever you can-- but you must use a single seed per-run to generate all inputs. (this could eventually be discussed with careful consideration.) it should be appended into a test tracking structured file in the repo and it can be committed. ideally main branch commit's seed or pr merge seed should make it back into file eventually. to prevent churn, maybe ci appends the seed into a gha var (race/overwrite risk?), or attached as artifact to each workflow in init job before tests begin-- a collector job can scoop them up sometime later. once a day/week/on-release/every-100-commits. im thinking touch tests/seeds/ or uv has a seed generate job. anyways ci it should end up in that dir, then as an artifact if gha and main branch, then passed into the test matrix. if uv test without arg- warn, generate and write it yourself pass it to all tests, if some other testing method there should not be a static seed, throw for empty or setup should make the seed. avoid changing how seed generates data. im not sure if a convenient uuid with time, v7?, is valid, but as long as its enough entropy whatever works. either put nothing in their or compact json, consider seeds/v1/id/<first 2 char>/<--symlink: seeds/yyyy/mm/dd/ avoiding conflicts is important.
"uv test" in the notes: mcpx is Go and has no uv. This issue reads it as "the test entrypoint/wrapper" -- a just recipe or pkgs/mcpx/scripts/test.sh that everyone (agents, humans, CI) calls instead of bare go test.
Current state (re-checked at 05c78b2)
| Fact |
Where |
No randomness in any test: 735 func Test* across 64 files, no math/rand, testing/quick, rapid, Fuzz*. Clean slate: no existing inputs to preserve. |
rg over pkgs/mcpx |
No test wrapper. CI calls go test ./... -count=1 directly; the repo justfile has no mcpx test recipe. |
.github/workflows/mcpx.yml; rg mcpx justfile (no hits) |
go test ./... builds one test binary per package and runs each as a separate process. Anything minted inside a test process is per package, not per run. |
go help test |
e2e passes os.Environ() into every mcpx subprocess, so an env var reaches the daemon and runtimes for free. |
internal/e2e/e2e_test.go:52 |
Only flags in a fixed "cacheable" set keep go test results cacheable; -shuffle and any -args flag disable caching. A test that reads an env var is cached keyed on that var's value. |
go help test lines 76-89 |
-shuffle off,on,N: N is an integer seed and is printed for reproducibility. |
go help testflag |
math/rand/v2: NewChaCha8(seed [32]byte), NewPCG(seed1, seed2 uint64). go doc math/rand/v2 makes no promise that Rand methods (IntN, Shuffle, Perm, ...) return the same values across Go releases; the ChaCha8 stream itself is specified (chacha8rand, C2SP). |
go doc math/rand/v2 |
google/uuid v1.6.0 (already an indirect dep) implements NewV7 with the 12-bit rand_a filled from the sub-millisecond clock, not randomness. |
github.com/google/[email protected]/version7.go:80-103 |
package.nix checkPhase re-runs 18 unit packages inside the nix sandbox, where no seed env var exists. |
pkgs/mcpx/package.nix |
internal/logging/trace.go:168 records every MCPX_* env var into traces, so MCPX_TEST_SEED would show up in daemon traces from e2e runs (useful). Settings env names are "MCPX_" + path (internal/settings/schema.go:220-224), so a future setting under test. would collide with MCPX_TEST_*. |
|
MCPX_TEST_SEED would be an MCPX_* variable that the code reads and no setting declares, which is exactly the class #172 (in flight) inventories. #172's recommended guard bans os.Getenv("MCPX_*") outside the settings package unless the name is on an allowlist with a reason. The seed helper's read needs that allowlist entry, or _test.go files and internal/testsupport need to be out of the guard's scope. #171's TestNoHandRolledSettingEnv (internal/settings/consumed_test.go:145) only covers names the registry owns, so it does not flag the seed variable today. |
#172 |
Design
1. Seed format
| Format |
Distinct across runs |
Human-copyable |
Time-ordered |
Notes |
| u64 integer |
64 bits |
yes |
no |
what -shuffle and rapid take; too easy to hand-pick ("seed 1") |
| UUIDv4 |
122 bits |
yes |
no |
standard, but no ordering |
| random 128/256-bit hex |
128/256 bits |
long |
no |
entropy beyond ~64 bits buys nothing here (see below) |
| UUIDv7 |
74 bits (62 with google/uuid) + ms timestamp |
yes |
yes |
recommended |
derived from run_id/run_attempt |
~34 bits of run id |
yes |
yes |
CI-only, predictable; evaluated in #122 |
Facts for v7 (RFC 9562 section 5.7): 48-bit unix_ts_ms, 4-bit version, 12-bit rand_a, 2-bit variant, 62-bit rand_b. RFC 9562 section 6.2 lets implementations spend rand_a on sub-ms precision or a counter, which is what google/uuid does -- so budget 62 random bits, not 74. Either is ample: a collision needs two runs in the same millisecond and then a ~2^31 birthday bound on the random part.
Entropy is not the constraint anyway. A PRNG needs a fixed-size key (ChaCha8: 32 bytes), so the id is never used as a key directly: it is hashed into one (section 2). What the id needs is to be distinct per run and easy to copy; v7 adds free time ordering (ids sort by mint time, and the date is recoverable from the id without a lookup, which #122 uses).
Recommendation: mint UUIDv7 (canonical lowercase, 36 chars). On input, accept any string matching [A-Za-z0-9._-]{1,128} (so a human can reproduce with an old id, and the format is not locked in forever); only the wrapper and CI mint, and they mint v7.
Minting without a Go dependency (works in a CI init job before setup-go, and on macOS where BSD date has no %3N):
python3 -c "import os,time;b=bytearray(int(time.time()*1000).to_bytes(6,'big')+os.urandom(10));b[6]=b[6]&15|0x70;b[8]=b[8]&63|0x80;h=b.hex();print(f'{h[:8]}-{h[8:12]}-{h[12:16]}-{h[16:20]}-{h[20:]}')"
# e.g. 01a0f101-2378-7c1c-9dc1-5a1ae1571eca (74 random bits)
2. Derivation: one root, many independent streams
root = SHA-256("mcpx-test-seed/v1\x00" || seedID)
stream(t, g@v) = SHA-256(root || 0x00 || "g@v" || 0x00 || t.Name()) -> ChaCha8 key
shuffle = int64(big-endian(SHA-256(root || "shuffle")[:8]) & MaxInt63) -> go test -shuffle=N
rapid (if used) = non-zero uint64 from SHA-256(root || "rapid") -> RAPID_SEED
- Adding, removing or reordering tests never shifts another test's inputs (each stream is keyed by test name, not by draw order in the process).
- Changing generator
g (a new version) never shifts generator h's inputs.
- Renaming a test changes its inputs. Acceptable; documented.
v1 in the domain tag is the derivation version. Changing the derivation is v2; old seeds replay under v1.
3. "avoid changing how seed generates data"
- Same commit + same seed reproduces exactly, always -- the commit pins the generator code. Generator stability matters only for cross-commit replay (an old stored seed against today's code), which is what the stored seeds in Update module golang.org/x/crypto to v0.52.0 [SECURITY] #122 are for.
- Every generator is
name@version. Any change that alters its output for the same stream is a new version; the old version is kept while any stored seed references it, or frozen. Registry detail in Update Rust crate tracing-subscriber to v0.3.20 [SECURITY] - autoclosed #124.
- Guard test: per
generator@version, a checked-in hash of its first N outputs from a fixed test-vector key. It fails when a generator's output changes without a version bump -- including when a Go upgrade changes IntN/Shuffle (not promised stable). The test vector pins the generator; it is not a static seed for testing mcpx, which the notes forbid.
- To shrink Go-release coupling: generators draw only
Uint64() from the ChaCha8 source and do their own range reduction (a few lines), so the only external dependency is ChaCha8's specified stream.
4. How the seed reaches tests
MCPX_TEST_SEED env var is the one channel. Reserve the MCPX_TEST_* prefix (a settings guard can assert no setting path starts with test.).
internal/testsupport/seed helper, read lazily: seed.Rand(t, gen) derives the stream for (t.Name(), gen@version) and registers a t.Cleanup that, if t.Failed(), logs the seed, test, generator and the exact reproduce command. Packages that never call it never read the env var and stay cacheable; packages that do are re-run whenever the seed changes (correct).
- No
TestMain needed anywhere.
- Wrapper (
just mcpx-test or pkgs/mcpx/scripts/test.sh; exact home decided with Bump unsafe-libyaml from 0.2.8 to 0.2.10 in /sources/pavex/examples/realworld #99): mints once if unset, exports it, derives and passes -shuffle=N, runs go test with any extra args. One seed for every package process.
5. No seed given
| Situation |
Behaviour |
Wrapper, MCPX_TEST_SEED unset or empty |
warn on stderr, mint v7, print MCPX_TEST_SEED=<id>, write it to a gitignored pkgs/mcpx/.cache/test-seed/last (+ local history), export, run. |
Bare go test, unset or empty |
helper mints once per process (sync.Once), logs a warning on first use: "no MCPX_TEST_SEED; generated for this package only -- use the wrapper for one seed per run". Still reproducible (the id is printed on failure). |
CI (CI=true / GITHUB_ACTIONS=true), unset or empty |
fail (helper t.Fatal, wrapper exit 1). CI must never mint inside a test process. |
| Anywhere |
never a static default in code. |
"write it yourself": locally the seed is written to a gitignored file, not the committed store -- local runs committing into the repo would be the churn the notes want to avoid. Committed seeds come from CI via #122 (open question below).
6. Reproduce from a seed (one command)
MCPX_TEST_SEED=01a0f101-2378-7c1c-9dc1-5a1ae1571eca just mcpx-test -run '^TestX$' ./internal/codegen
The wrapper derives the same -shuffle value from the seed. The helper prints exactly this line on failure, with the commit. In CI, a workflow_dispatch input seed re-runs the whole matrix on CI runners with a given seed.
Caveat: this reproduces inputs and test order, not timing. Execution is not deterministic (#126); a timing bug may need several tries under the same seed.
7. Minting in CI (mechanism only; the matrix is #95's)
jobs:
seed:
runs-on: ubuntu-latest
outputs:
seed: ${{ steps.mint.outputs.seed }}
steps:
- id: mint
env: { SEED_IN: "${{ inputs.seed }}" } # workflow_dispatch override
run: |
seed="${SEED_IN:-$(python3 -c '...v7 one-liner above...')}"
echo "seed=$seed" >> "$GITHUB_OUTPUT"
echo "MCPX_TEST_SEED=\`$seed\`" >> "$GITHUB_STEP_SUMMARY"
jq -n --arg seed "$seed" --arg sha "$GITHUB_SHA" --arg ref "$GITHUB_REF" \
--arg event "$GITHUB_EVENT_NAME" --arg run "$GITHUB_RUN_ID" --arg attempt "$GITHUB_RUN_ATTEMPT" \
'$ARGS.named' > seed.json
- uses: actions/upload-artifact@v4
with: { name: test-seed, path: seed.json }
test:
needs: seed
env: { MCPX_TEST_SEED: "${{ needs.seed.outputs.seed }}" }
# matrix owned by #95
Approaches
A -- TestMain in every package mints or reads the seed (least recommended)
About 30 TestMains. Bare go test ./... then produces ~30 different seeds for one "run", and a new package without a TestMain is silently unseeded. Printing happens at process start, far from the failure. Nothing here is better than C.
B -- a -seed test flag (registered in TestMain) plus a wrapper
Familiar (-rapid.seed, -shuffle look like this). But go test ./... -args -seed=X errors in every package whose test binary does not define -seed ("flag provided but not defined"), so every package needs the TestMain from A anyway; and any -args flag disables go test caching for all packages, including the ones that never use randomness. Could be offered in addition to the env var for single-package runs, but it adds a second channel to keep in sync.
A variant that fixes bare go test ./... without a wrapper: all package test binaries are children of the same go process, so the first to start could create $TMPDIR/mcpx-test-seed.<ppid> (write temp + os.Link, atomic) and the rest read it. Clever, ~30 lines, but breaks under -exec, go test -c, IDE runners and go test inside nix build. Not the default; possible later.
C -- env var + lazy helper + one wrapper that mints once (recommended)
As in sections 4-7. One channel that works for subprocesses (e2e, daemon, runtimes), keeps unrelated packages cacheable, needs no per-package boilerplate, fails closed in CI, and gives a one-command reproduction. The wrapper is also where #99's "what to run locally" policy naturally lives. It does not need to reap daemons: #182 fixed #52's leak in the harness itself (newEnv cleans up with stop --all and sets MCPX_AUTOSTART_IDLE_EXIT=60s, internal/e2e/e2e_test.go:68,79).
Open questions
- Wrapper home:
just mcpx-test in the repo justfile, pkgs/mcpx/scripts/test.sh, or both (just calling the script)? Windows (in the Bump golang.org/x/crypto from 0.14.0 to 0.17.0 in /sources/chat #97 env wish-list) favours a script that also runs under Git Bash, or a Go cmd under internal/testsupport/cmd.
- Should local seeds ever reach the committed store (e.g. only failing ones, via an explicit
just mcpx-seed-keep)? Default proposed: no.
-shuffle disables test caching; is shuffling on by default locally, or CI-only (Bump unsafe-libyaml from 0.2.8 to 0.2.10 in /sources/pavex/examples/realworld #99 decides)?
- Env var name:
MCPX_TEST_SEED (proposed) vs MCPX_SEED. Whichever it is, reserve the prefix in Phase 2: membership, delegation, groups, and server config #172's allowlist when that lands, so the "read but never declared" guard treats it as test-only rather than as a missing setting.
- Accept arbitrary strings as seed ids on input, or v7 only? Proposed: accept, but the store (Update module golang.org/x/crypto to v0.52.0 [SECURITY] #122) only files v7 ids minted by CI.
- Budget knob (
MCPX_TEST_FUZZ=off|quick|ci|soak) belongs here or in Update Rust crate tracing-subscriber to v0.3.20 [SECURITY] - autoclosed #124? Proposed: named here, sized in Update Rust crate tracing-subscriber to v0.3.20 [SECURITY] - autoclosed #124 with Bump golang.org/x/crypto from 0.16.0 to 0.17.0 in /sources/launcher #95.
Ease · Impact · Related
Ease S (helper + wrapper ~150 lines; CI init job ~20 lines) · Impact high (every randomized test depends on it)
Depends on / related: #91 (strategy step 1), #93, #122, #123, #124, #125 (lands it), #126; #95 (consumes the seed job output, owns the matrix and the nix double run), #99 (wrapper as the local entrypoint, -shuffle and flake policy), #172 (in flight: its allowlist must admit the seed variable), #52 (closed, fixed in #182; the harness cleans up after itself now, so the wrapper has nothing to reap).
Security/auth deferred; see tracker. Activitydeveloping-today commented on Oct 28, 2026 dezren39 commented on Oct 28, 2026 History carried over from dezren39/darwin-nix#121 (verbatim, oldest first):
@dezren39 · 2026-09-30T07:20:45Z
Integration pass. Placed in the DAG rooted at #181.
@dezren39 · 2026-09-30T12:03:21Z
Issues pass (2026-09-30, at 05c78b2).
- Re-checked Current state at 05c78b2. There are now 735
func Test* across 64 files, and still no randomness anywhere. EnvName moved to internal/settings/schema.go:220-224.
- New fact:
MCPX_TEST_SEED would be an MCPX_* variable that the code reads and no setting declares, which is exactly the class Phase 2: membership, delegation, groups, and server config #172 (in flight) is about to guard. Its allowlist needs an entry for the seed variable, or the test helpers need to be out of its scope. This is noted in Current state and Open questions.
- chore(deps): bump build/buck/preludes/buck2-prelude from
d956689 to e7457f6 #52 is closed (fixed in Phase 5: tag event bodies must travel with the event #182 inside the harness: stop --all cleanup, MCPX_AUTOSTART_IDLE_EXIT=60s). I dropped "the wrapper can reap leaked daemons" from Approach C and Related, because the wrapper has nothing left to reap.
- The design, the A/B/C options and the recommendation are unchanged. No claim about CI shape went stale: it is still one job.
dezren39 commented on Oct 29, 2026 dezren39 commented on Oct 29, 2026 🤖 Agent note · done (triage)
- Agent: queue worker (repo-worker-code), lane B shift
- Session / ID: queue task 2845 (triage)
- Found via: queue claim
- Task: Triage of relocated mcpx testing: one seed per run -- format (UUIDv7), derivation, and how it reaches every test #1949 (was mcpx testing: one seed per run -- format (UUIDv7), derivation, and how it reaches every test dezren39/darwin-nix#121) complete. Verdict: not a duplicate; design confirmed implementable against current main; implementation is already owned and queued as mcpx testing: review all tests, set up the fuzz framework and its policies #1960 — no new packet (one would duplicate mcpx testing: review all tests, set up the fuzz framework and its policies #1960's deliverable 2).
- Links: landing issue mcpx testing: review all tests, set up the fuzz framework and its policies #1960 (already
queue/queued) · siblings mcpx testing: seed store layout and collector (file per seed, artifact + scheduled collector) #1953 (store), mcpx testing: choose the generator engine for one run-wide seed (native fuzz, testing/quick, rapid, hand-rolled) #1956 (engine), mcpx testing: bug-shape generators -- registry, versioning, budget, first shapes #1958 (registry) · tracker mcpx testing: fuzzing and property tests with one seed per run #1896
Triage verdict
Dedupe. The testing-seed family relocated as a set, and each sibling owns exactly one part: #1953 the seed store + collector (was #122), #1956 the generator engine choice (was #123), #1958 the generator registry/versioning (was #124), and #1960 the landing (was #125), whose own summary reads: "execute #121–#124 in the smallest useful slice… the seed helper + wrapper + first generator landed". #1960 already carries queue/queued — a task for it is in the queue. This issue is the design/decision record for the seed itself (format, derivation, transport), the same relationship #1601 (design) has to its phase issues. Enqueueing a fresh implementation packet from here would duplicate #1960 deliverable 2, so none is enqueued.
Scope confirmed on current main (c58507a, 2026-10-29):
- No
MCPX_TEST_SEED anywhere in the repo (grep across Go/YAML/shell: no hits) — the channel does not exist yet.
- No seed helper:
internal/testsupport/ exists (fake MCP servers, temp dirs) but has no seed package.
- CI still calls
go test directly with no seed job (.github/workflows/mcpx.yml:119), exactly as the issue's current-state table says.
- The issue's "clean slate" claim is now slightly stale — a small number of tests reference randomness-adjacent helpers (e.g.
internal/daemon/handoff_conns_test.go, internal/e2e/keepalive_takeover_test.go) — which strengthens rather than weakens the case: mcpx testing: review all tests, set up the fuzz framework and its policies #1960's inventory deliverable should classify them, and the seed helper should land before randomized tests multiply, per the strategy's step-1 reasoning.
Decision record (for #1960's pass): the issue's recommendations stand as the spec — UUIDv7 minted only by the wrapper/CI, arbitrary seed strings accepted on input; SHA-256 domain-separated derivation (mcpx-test-seed/v1) with per-test, per-generator streams into ChaCha8; generators draw only Uint64(); MCPX_TEST_SEED as the single channel; lazy internal/testsupport/seed helper; fail-closed in CI when unset; no static default ever. The open questions (wrapper home — just vs script vs both; the MCPX_TEST_* allowlist entry owed to the settings guard; shuffle-by-default locally) are implementation-time choices for #1960, with the issue's proposed defaults as the starting position; none of them blocks starting.
State after triage: this issue stays open as the design record until #1960 lands the helper + wrapper + CI seed job, at which point it can close with a link to that PR. Claim labels removed; no queue/* label is set because no queue task exists for this issue itself — the live task is #1960's. developing-today commented on Nov 8, 2026 🤖 Agent note · picked up
- Agent: queue worker (repo-worker-code), lane code-z
- Session / ID: task 13250
- Found via: queue claim (resume)
- Task: resuming task 13250 for issue mcpx testing: one seed per run -- format (UUIDv7), derivation, and how it reaches every test #1949 from the prior awaiting_ci checkpoint: PR test(mcpx): plumb one run seed through tests and CI (#1949) #7690 (branch queue/13250-1949-run-seed, head bdef98e) verified fresh — OPEN, MERGEABLE, no hard-stop labels on issue mcpx testing: one seed per run -- format (UUIDv7), derivation, and how it reaches every test #1949, no Codex review findings on PR test(mcpx): plumb one run seed through tests and CI (#1949) #7690. Re-checking PR test(mcpx): plumb one run seed through tests and CI (#1949) #7690 checks; merge when green, otherwise park on CI pending.
- Expectation: PR test(mcpx): plumb one run seed through tests and CI (#1949) #7690 merged with checks green, or task 13250 parked with the CI-pending resume condition.
- Links: issue mcpx testing: one seed per run -- format (UUIDv7), derivation, and how it reaches every test #1949; PR test(mcpx): plumb one run seed through tests and CI (#1949) #7690
developing-today commented on Nov 8, 2026 🤖 Agent note · parked
- Agent: queue worker (repo-worker-code), lane code-z
- Session / ID: task 13250
- Found via: queue claim (direct lane; resume)
- Task: Correction to lane code-z's picked-up note on task 13250 / issue mcpx testing: one seed per run -- format (UUIDv7), derivation, and how it reaches every test #1949: lane code-z claimed task 13250 concurrently, verified PR test(mcpx): plumb one run seed through tests and CI (#1949) #7690 fresh (OPEN, MERGEABLE, head bdef98e, no Codex findings, checks pending), then checkpoint and heartbeat both returned the verdict "task 13250 is not claimed by repo-worker-code". Lane code-a's parked note (comment 6725080839) shows lane code-a parked task 13250 on PR test(mcpx): plumb one run seed through tests and CI (#1949) #7690's QUEUED checks. Lane code-z stands down per the claim-gone verdict rule — no work done on PR test(mcpx): plumb one run seed through tests and CI (#1949) #7690, no merge attempted. Labels corrected back to the parked state lane code-a recorded.
- Expectation: on resume, re-check PR test(mcpx): plumb one run seed through tests and CI (#1949) #7690 checks fresh and merge when green (no Codex findings).
- Links: issue mcpx testing: one seed per run -- format (UUIDv7), derivation, and how it reaches every test #1949; PR test(mcpx): plumb one run seed through tests and CI (#1949) #7690
dezren39 commented on Nov 8, 2026
task 13250 parked (lane code-w, 2026-11-08): PR #7690 OPEN at head bdef98e, no hard-stop labels, no Codex findings. All 5 basic checks stayed QUEUED across a full 5-minute poll (18:28-18:32Z) — fleet-wide CI stall. Resume: merge PR #7690 when checks green on that head. dezren39 commented on Nov 8, 2026
Task 13250 (small_fix, issue #1949): resumed by lane code-v (direct). PR #7690 re-verified fresh: OPEN, head bdef98e, no hard-stop labels, no Codex/review findings, all 5 basic checks still QUEUED (fleet-wide CI stall, same as lanes code-a/code-w/code-z earlier today). Parking task 13250 awaiting CI per the 5-minute rule. Resume: merge PR #7690 when checks green on that head. developing-today commented on Nov 8, 2026
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|