Skip to content

3.x.x: Close the four needs-triage rows of the deleted-test map with native tests (#460) - #465

Merged
kiwidream merged 9 commits into
3.x.xfrom
map-gaps-460-evidence
Sep 24, 2026
Merged

kiwidream merged 9 commits into
3.x.xfrom
map-gaps-460-evidence

Conversation

@kiwidream

@kiwidream kiwidream commented Sep 18, 2026 •

Copy link
Copy Markdown
Member

Closes #460 (merge keywords do not fire on 3.x.x; close by hand once merged).

Four needs triage rows of docs/prism-deleted-test-map.md had no issue and no native test. This adds the tests, corrects the rows, and makes one production change the R4 tests exist to pin.

R1 — window multiplier (row 64 → full)

tests/window_multiplier_invariant.rs::every_window_multiplier_literal_matches_the_constant enumerates every literal spelling of PRISM_WINDOW_MULTIPLIER under crates/qbit-prism-server/src/**, migrations/ and crates/qbit-prism/sql/*.sql — 12 sites in 7 files, including inline SQL in ledger/archive.rs and the read models in api/public.rs / api/read_models.rs that the issue did not list — pins each to the constant, reports every disagreeing site at once, and fails when the site set changes. A bound parameter derived from the constant would retire the SQL literals; that is a note for Workstream B, not this PR.

R2 — prior-balance divergence at landing (row 65 → partial)

The row was stale twice: the landing compares a 32-byte digest, not rows, and the changed-amount case was already covered by offer_lifecycle.rs::pending_divergent_landing_refuses_while_the_post_offer_landing_succeeds and coordinator/window_switch_tests.rs::a_parent_landing_late_diverges_the_child_which_lands_as_issued_with_additive_balances. What nothing asserted was the ALERT warning. offer_lifecycle.rs::a_divergent_offered_landing_warns_with_both_digests_and_keeps_its_as_issued_accounts moves the balances the way production does — a second candidate lands and is confirmed between the victim's issue and landing — then asserts the one WARN with its four fields and the provenance marker, the as-issued carry priors and a clean integrity report in the same test; ::an_undisturbed_offered_landing_is_marked_without_a_divergence_alert is the control. The bech32 relabel half has no native subject.

R3 — audit reconstruction permit (row 216 → partial)

tests/audit_reconstruction_permit.rs drives materialize_audit_row with permits from a one-permit semaphore on a runtime whose single blocking thread the test parks, so ordering is a fact rather than a timing: a dropped caller does not release the permit its queued job holds; a second reconstruction waits and both rows hydrate; failure inside the job, failure before it and cancellation each release exactly once. No memory or duration assertion. Not covered: the bounded audit-body read itself (#267, post-GA) and that the job holds the permit for its whole duration.

R4 — Stratum bind order on restart (row 239 → partial)

Production change (Bind Stratum listeners before coordinator startup, decision recorded on #460): both Stratum binds move above Coordinator::new. Coordinator::new writes the starting instance row and nothing retracts it on a later bind error, while fatal-state clear refuses on any row that is not drained/stopped with no staleness allowance — so a restart that lost the bind race left a row an operator had to delete by hand. tests/stratum_restart_bind.rs (real binary, fake node in the parent, database per fixture) asserts: a held primary or high-difficulty port fails startup with the bind error and no instance row, and the next start on a free port serves; listeners accept a connection while the node still holds getblockchaininfo; the high-difficulty listener is present or absent per PRISM_STRATUM_HIGHDIFF_PORT. Not covered, follow-ups with no issue yet: the 2.x.x bind retry (native run binds once) and port release on SIGTERM during the readiness wait (no signal handler exists until every task is spawned).

Map bookkeeping

Rows 64, 65, 216, 239 rewritten; their lines dropped from ## Needs triage; summary counts 5/69/5/7/56 → 6/72/5/3/56. #455 rewrites the rest of the file — whichever lands second rebases.

Verification

cargo fmt --all --check, cargo clippy --locked --workspace --all-targets -- -D warnings, check_gate_env_reads.py, check_prism_settings.py, check_toolchain_pin.py; test/prism-gated-tests.txt sorted with all 11 new ids, each executed in the gate manifest. Suites on the integrated tree: window_multiplier_invariant 1/1, offer_lifecycle 21/21, audit_reconstruction_permit 3/3, stratum_restart_bind 5/5 (also 5 sequential + 3 concurrent runs, no port collisions), candidate_storm_restart 2/2, self_check_cli 5/5. Mutation checks, each restored: a * 9 in dashboard_reward_leaderboard.sql and in archive.rs (named in one failure); the pending fence removed; the provenance marker written as NULL (fails on the marker assertion, not only the warning); the permit dropped with the caller; the bind order reverted (fails on the leftover starting row); the high-difficulty bind skipped.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@kiwidream
kiwidream force-pushed the map-gaps-460-evidence branch from a97f779 to 8c57849 Compare September 22, 2026 19:34
kiwidream and others added 8 commits September 22, 2026 16:19
The payout window's difficulty multiplier has one value,
qbit_prism::PRISM_WINDOW_MULTIPLIER, but several spellings: the dashboard
query files and the shipped schema bake it in as a SQL literal, the archive
horizon spells it in inline SQL, and two read models render it into JSON.
Nothing tied those copies together, so raising the multiplier could leave a
dashboard or the audit window view scaling by the old value.

The new test enumerates the literals across the server's Rust and SQL
sources and the shipped schema, asserts each equals the constant — listing
every disagreeing site in one failure rather than stopping at the first —
and asserts the discovered site set is exactly the expected one, so a new
spelling, or a site the scanner stops recognising, fails with a message
telling the author to derive it from the constant or extend the list. A
scanner that matches nothing fails too. The frozen 2.x schema fixture and
the rollback scripts are outside the scanned roots.

Closes one needs-triage row of docs/prism-deleted-test-map.md (#460).

Co-Authored-By: Claude Opus 5 <[email protected]>
Landing an offered block whose as-issued prior balances are no longer the
canonical ones is allowed — the node has or may have the block — but it is
reported. The refusal, the marker and the additive balances were covered;
the warning itself was not, so it could have been dropped silently.

The new test moves the canonical balances the way production moves them:
a second block of the same window lands, is confirmed, and its carry rows
accrue a below-floor account, so `SUM(gross - onchain)` shifts. Landing the
held claim on those moved balances must raise exactly one WARN naming the
block, its lifecycle state and both digests, and the same test holds the
landing to the rest of its contract — the provenance marker records the
audit that was issued, the carry rows keep the as-issued priors rather than
the moved ones, and the integrity validator stays clean — so the test
cannot pass on the warning alone. A control with no mover asserts the
marker is written anyway and no alert is raised. The subscriber is attached
to the landing future alone, never installed globally, because this binary
runs many tests.

Closes one needs-triage row of docs/prism-deleted-test-map.md (#460).

Co-Authored-By: Claude Opus 5 <[email protected]>
`materialize_audit_row` hands its permit to the blocking job rather than
holding it in the caller's future, because Tokio keeps running a queued
job after the future that awaited it is dropped. Nothing proved that.

Three gated tests drive the function directly, each on a runtime with a
single blocking thread the test parks, so ordering is a fact and no
assertion reads a clock:

- a caller dropped after its job is queued does not release the permit;
  it comes back only once the released thread has run the job;
- a second caller waiting on the same one-permit semaphore reaches no
  statement of its own until that job ends, and both rows then hydrate
  to the signed body and its declared canonical digest;
- EP-ERRORS: a digest mismatch inside the job returns the permit when
  the job ends and not before, while a missing snapshot row and a
  cancellation on the first statement return it with the future.

Row 216 of the deleted-test map moves from `needs triage` to `partial`:
the permit bound is the property now covered, and the bounded audit-body
read the retired Python streaming view asserted is not, since
`materialize_audit_row` still hydrates the whole share array.

Co-Authored-By: Claude Opus 5 <[email protected]>
Integration edits on top of the #460 R1, R2 and R3 tests: the multiplier
scanner also walks crates/qbit-prism-server/migrations/, so a migration that
redefines the window view cannot add a copy unnoticed; row 216 states what the
permit tests do not observe (the job holding its permit for its whole
duration); the summary counts and the "Needs triage" section follow the rows
that left it.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Move the primary Stratum bind, its "PRISM listening" line and the high
difficulty bind above Coordinator::new. Coordinator startup registers the
instance with a `starting` row and nothing retracts it when run returns an
error, so a restart that lost the bind race to its predecessor left a row
behind that `fatal-state clear` refuses on. Every fallible step before
Coordinator::new now touches only configuration and sockets.

The log line's instance and worker fields come from the Config before it
moves into the coordinator; their values are unchanged. The audit HTTP
listener still binds after Coordinator::new because it serves the
coordinator's ledger through ApiState.

Co-Authored-By: Claude Opus 5 <[email protected]>
Add a gated target that runs the real server binary against a fake node and
a database of its own, and proves what the bind order buys. A restart whose
primary or high difficulty port is still held by its predecessor exits with
the bind error and code 1, and qbit_prism_instances stays empty, so nothing
is left for `fatal-state clear` to refuse; the next start on a free port
serves and stops cleanly. While the node holds the chain check inside
Coordinator::new, the announced primary address already accepts a
connection and the instance is still unregistered. The high difficulty
listener is bound when, and only when, its port is configured.

Not covered, and named in the map row: bind retry against a draining
predecessor, retry abort on shutdown and zero-retry fail-fast, which native
`run` has no subject for, and port release on a shutdown during the node
readiness wait, which needs a signal handler that does not exist yet.

Co-Authored-By: Claude Opus 5 <[email protected]>
@kiwidream
kiwidream merged commit d95cb8e into 3.x.x Sep 24, 2026
21 checks passed
@kiwidream
kiwidream deleted the map-gaps-460-evidence branch September 24, 2026 14:20
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.

1 participant