Skip to content

3.x.x: keep a lost race out of the revision-work paging age and dwell the unknown warning (#493) - #503

Merged
djh58 merged 5 commits into
3.x.xfrom
djh58/prism-b493-lost-race-paging
Sep 24, 2026
Merged

djh58 merged 5 commits into
3.x.xfrom
djh58/prism-b493-lost-race-paging

Conversation

@djh58

@djh58 djh58 commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Refs #493 (points 1 and 7; the last #493 PR). Telemetry and alert semantics only: no mining, submit, landing, payout or deployment change.

Scope, stated plainly. Three new families (accepted_block_unlanded_seconds, block_candidate_oldest_unacknowledged_seconds, block_candidate_oldest_landing_failed_seconds) and two FILTER aggregates on the existing candidate-collector statement; five new rules (PrismAcceptedRevisionWorkTrackingUnknown, PrismAcceptedBlockUnlanded, PrismBlockCandidateStuck, PrismBlockCandidateLandingFailed, PrismBlockCandidateLandingFailedCritical) and the candidate paging rule re-pointed at the unacknowledged age with a mixed-version fallback. Behaviour of the alerts that changes: a lost race no longer pages either critical; a side-chain rejection (inconclusive, duplicate, duplicate-inconclusive) no longer pages; a landing that fails after acceptance moves from paging at 60 s + 3 m on the all-unfinished age to paging at 307 s + 1 m on its own age, measured from the offer reservation. None of it touches control flow in the coordinator or ledger.

Point 1: a routine lost race paged critical

A null submitblock reply called accepted_block whether or not the node held the block on its active chain. No revision is ever bound for a block that never lands, so accepted_block_revision_work_pending_seconds grew until the orphan proof (PRISM_CANDIDATE_ORPHAN_CONFIRMATIONS competitor confirmations plus the reconciliation backoff), and the #496-gated PrismAcceptedRevisionWorkPendingCritical still paged whenever that took longer than 307 s. Reproduced first: the new gated test fails on the unmodified base at "lost race counted as a known pending wait" (pending age > 0 while the row is in reconciliation).

Change

  • Unlanded seam in landing.rs. The offering frontend records a definitive acceptance as unlanded (accepted_unlanded_block, the one call site in coordinator.rs). An unlanded identity is excluded from known_waits(), so it is neither in the pending age nor in build-deadline attribution; it is not unknown tracking either (a lost race is a known state). An active-chain observation lands it on its original acceptance clock through every path that carries one: the post-offer landing observation and reconcile proofs (accepted_block / accepted_landed_block on the existing identity) and the settlement observer's arming (revision_work_settlement, whatever its COMMIT reply). A committed proven orphan closes it without a sample, as before. A tombstone never reopens and a landed block is never downgraded by a later duplicate acceptance.
  • New gauge qbit_prism_accepted_block_unlanded_seconds: age of the oldest unlanded acceptance, live overlay like the pending gauge; zero when none; -1 only under bounded-tracking saturation, when an unlanded acceptance may be untracked and the tracking-unknown gauge is already one (EP-OBSERVABILITY: never a silent zero).
  • New non-paging rule PrismAcceptedBlockUnlanded: >= 1800 s for 3 m, no-data OK. Basis: six competitor confirmations at the 60 s target spacing plus the reconciliation retry backoff is minutes, so a routine lost race clears well inside 30 minutes; past it the row is not reconciling, the node is not advancing or the verdict keeps failing, which is operator work, warned.
  • The critical rule's basis no longer says a lost race pages until its orphan proof.

The histogram keeps measuring from the definitive acceptance: a winning offer's wait rejoins the known age with the time already spent in the landing write, exactly as before. The one documented edge is a side-chain block that becomes active after a long unlanded interval (a deep reorg after a lost race): its known age then starts high, and the critical pages after the one-minute dwell only if delivery does not follow, which is a real stall.

Point 1, second path: the candidate collector paged the same lost race

A reconciliation row is unfinished, so qbit_prism_block_candidate_oldest_pending_seconds aged on every coordinator's database collector and PrismBlockCandidateOldestPendingCritical (60 s, 3 m, paging) fired on the same lost race until its orphan proof. Coordinator decision on this PR: page only on rows that have not demonstrably reached the node.

  • New gauge qbit_prism_block_candidate_oldest_unacknowledged_seconds (database collector, same read-only snapshot, same 3 s deadline, FILTER aggregates on the existing query): the oldest unfinished row the node has not accepted: pending and offer_reserved rows, offered/reconciliation rows whose one submitblock outcome is unknown (a row adopted on the node's own active-chain evidence carries the adoption reply and is excluded), and rows the node definitively rejected unless the reply names a side-chain block (inconclusive, duplicate, duplicate-inconclusive: a lost tip race to a first-arriving block). A bad-*, high-hash or duplicate-invalid reply means the pool built an invalid block, the emergency this rule exists for, and it keeps paging exactly as before. Zero when every unfinished row was accepted; -1 with the other candidate gauges when the collector fails (PrismBlockCandidateMetricsUnavailable gains the terms). The adoption-reply prefix, the landing-failed reason prefix and the side-chain reply list are constants the coordinator and the collector share.

  • PrismBlockCandidateOldestPendingCritical keeps its uid, title, 60 s floor, gates and 3 m dwell but reads the unacknowledged age, falling back to the all-unfinished age on a target that does not export the new series (unless), so a not-yet-upgraded coordinator keeps the base paging behaviour instead of going silent. A found block that is not reaching the node, or one the node refused, pages exactly as before. An unknown outcome keeps paging: receipt is unproven, the block is never offered again, and the row is indistinguishable from an unoffered block until the chain proves an orphan or a later observation lands it; a lost reply is a transport failure or timeout, rare, so the bounded false-page cost is accepted over a missed stuck offer. A node-accepted lost race is accepted and never pages here.

  • New gauge qbit_prism_block_candidate_oldest_landing_failed_seconds and two rules for a won block whose audit landing keeps failing after the offer (the row's last_error carries the shared landing-failed prefix; a lost race carries the not-active reason and a rejection its reply, so both leave this gauge at zero): PrismBlockCandidateLandingFailed warns at 60 s for 3 m (a transient refusal lands on the first retry ten seconds later and never reaches the dwell), and PrismBlockCandidateLandingFailedCritical pages at 307 s for 1 m, the same floor and dwell as PrismAcceptedRevisionWorkPendingCritical, which already pages at 307 s when the landing fails after the frontend's own active-chain observation; a landing that fails before it now pages at the same instant, so the class is never silent whichever step refused. By 307 s the row has been retried about eight times at the reconciliation backoff, so the failure is persistent, never a single deadline. What is at risk is the audit, the pool-block row, the deferred solver credit and the next payout revision; the block reward is on the chain regardless.

  • New non-paging PrismBlockCandidateStuck: all-unfinished age >= 1800 s for 3 m, aligned with PrismAcceptedBlockUnlanded; the catch-all for rows automation is not finishing (the row's last_error names the reason). The 15 s PrismBlockCandidateOldestPending warning is unchanged and still reports a lost race for a few block intervals.

  • Behaviour change stated plainly: a landing that keeps failing after a node acceptance used to page at 60 s + 3 m through the all-unfinished age and now warns at 60 s + 3 m and pages at 307 s + 1 m through its own gauge; a side-chain rejection (inconclusive) used to page and now never does.

  • Note for the candidate-collector owner: collectors.rs (two FILTER aggregates on the existing query, two bound prefix parameters), DatabaseMetrics (two fields), snapshots.rs (publish and invalidate), two registry families and the census (56 families); ledger/candidates.rs exports the three shared constants and coordinator.rs formats its adoption evidence and landing-failed reason through them. No schema, index, lock or query-count change.

  • Rollout: upgrade frontends before applying the rules. Until a target exports the unacknowledged series, the paging expression evaluates its all-unfinished age, so the base behaviour (its lost-race page included) persists on that target; the landing-failed rules are simply absent (no-data OK) until then.

  • After a committed landing whose post-landing observation keeps failing (the pool-block row exists, so the landing-failed age is zero): the block is no longer owned by the candidate row. The chain reconcile lists every prepared immature pool block (coordinator.rs:877-927, pool_blocks_for_reconcile), opens or lands its identity as a known wait from the frontend's own active-chain proof (accepted_block / accepted_landed_block at coordinator.rs:925-927) and confirms it through reconcile_blocks_at_revision, whose settlement binds the revision (ledger/blocks.rs:463-486); the post-landing revision work is then an ordinary known wait that PrismAcceptedRevisionWorkPendingCritical pages at 307 s + 1 m if delivery stalls. The stuck candidate row itself is bookkeeping: the 15 s warning and PrismBlockCandidateStuck report it, nothing pages for it.

  • A build deadline attributed through another known wait no longer marks an unlanded block degraded (unit test). While the terminal probe that carries peer orphan evidence fails, an unlanded-only frontend reads tracking unknown and a -1 pending age; the HELP and contract prose say so.

Point 7: the warning fired on routine refresh errors

PrismAcceptedRevisionWorkPending had for: 0s and included the tracking-unknown gauge and the -1 age, and any failed template refresh marks tracking unknown until the next successful refresh (one 2 s poll interval by default). The unknown terms (tracking_unknown > 0, pending < 0, a missing unknown gauge on a scraped target) move to a new non-paging PrismAcceptedRevisionWorkTrackingUnknown with a two-minute dwell (eight consecutive 15 s scrapes, which a single transient failure cannot span) and no-data Alerting. A lost or cancelled settlement COMMIT reply, an unsettled orphan verdict, saturation and lost ordering persist and still warn. The pending warning keeps its documented no-dwell budget terms (> 1 s, a missing pending series, scrape down) unchanged, so a known age beside unknown tracking still warns immediately and remains eligible for the critical rule.

Surface

  • Registry, metrics.rs, collector and snapshot, census (56 families, 235 startup / 669 populated series), contract expectations, inventory (regenerated), metadata, cardinality/privacy note, the landing contract prose in docs/prism-native-metrics.md, the rules JSON (five new rules, the candidate paging rule re-pointed with a rollout fallback, the unavailable rule extended, updated bases for the pending warning, the revision-work critical, the timeouts rule, the stuck and unlanded warnings), migration table and review-only qbit-tools patch regenerated (new specification SHA-256), test_prism_alert_promql.py now also checks the accepted-block and candidate rules as alerts with their dwells, test_prism_alert_deployment.py asserts 72 proposed rules, that the four new warnings dwell and never carry page, that the landing-failed critical is a gated paging rule with a one-minute dwell, and that the candidate paging rule reads the unacknowledged age with the fallback; the gate manifest gains the four new tests. The regenerated metadata file also drops a duplicate blocks_total key the base carried (the later entry already won at parse time) and reflows three arrays; effective content unchanged.

Verification (local, this branch)

  • Reproduction first: the new gated test fails on the unmodified base at "lost race counted as a known pending wait".
  • metrics::landing unit tests 26/26 (three new); qbit-prism-server --lib 547/547; the whole landing_metrics gated binary 39/39 against PostgreSQL 16 with fsync on, gate manifest showing the four new tests executed; observability 17/17 (census and both generator checks), lost_race_pin 8/8, offer_lifecycle 19/19, ledger_wait_metrics 3/3, metrics_allocation 4/4.
  • cargo fmt --all --check; cargo clippy --locked -p qbit-prism-server --all-targets -- -D warnings.
  • scripts/test_prism_alert_promql.py with the CI-pinned promtool 3.14.0: 38 expressions, 146 scenarios, 328 expression assertions, 227 alert assertions; generate_prism_metrics.py --check and generate_prism_alerts.py --check --snapshot clean; test_prism_alert_deployment.py --snapshot against the reviewed snapshot: patch applies, 10 Jinja gate combinations, 78 original / 72 proposed rules, 26 baseline deletions.
  • Not run locally: workspace-wide clippy and tests, the full gated suite, live_regtest; CI is the evidence for those. No timing runs.

Review ledger

  • Independent review (adversarial, alerting-correctness lens, coordinator-allocated): BLOCKERS 1, major 2, minor 3, notes 3. All fixed in the second commit: B1 (a definitive node rejection no longer paged) by the reply-aware paging set with the side-chain allowlist, plus the reviewer's probe inverted into a gated test that a bad-cb-payee rejection pages and an inconclusive reply does not; M1 (a landing failing before the observation paged nothing) by the landing-failed gauge, its 60 s warning and its 307 s + 1 m paging critical, consistent with the post-observation path, plus a gated test that aborts a real landing transaction through the wire proxy; M2 (rules deployed before frontends silently removed the candidate page) by the unless fallback to the all-unfinished age, a scenario and the rollout note; m1 (adopted rows counted unacknowledged) by excluding the adoption reply; m2 (the -1 HELP wording) and m3 (the backoff prose) in HELP, metadata, docs and rule bases. N1 and N2 unchanged as noted; N3 stated above.

Deep review (second and third commits)

  • Stakes: not high-stakes (telemetry, alert rules, docs and tests; the coordinator and ledger changes are one metrics call, two format strings and shared constants; no funds, consensus, auth or migration). Codex lane skipped by this lane's rule against other providers; the Fable adversarial, thermo-nuclear and /code-review lanes ran.
  • Fixed (third commit): the landing-failed gauge read zero whenever a retry overwrote last_error without the landing-failed prefix (a node or database error inside the landing surfaces as "post-offer processing failed"; a refused operator recovery; a failed lease renewal), so a landing that kept failing on a hard error paged nowhere. The collector now counts every reconciliation row whose qbit_pool_blocks row is absent (the landing transaction is its only writer), keeping the prefix for a landed row that no longer authenticates, and measures the age from the offer reservation so pre-offer backoff never counts toward the 307 s critical. The gated test fails a retry transiently and asserts the age holds and never predates the offer. Found independently by /code-review and the adversarial lane (three findings), auto-promoted.
  • Fixed (third commit, quality lane): one Acceptance::known() predicate; Observation enum instead of two bools; adoption_evidence() as the single writer; side-chain replies bound as text[]; a legible census statement; the redundant unless dropped from the paging fallback; every rule checked as an alert rule by the promtool script; metadata formatting preserved.
  • Deferred: splitting tests/landing_metrics.rs (now over 1k lines) into a candidate-census binary needs the shared fixture helpers hoisted into support/ and gated-registry renames, a mechanical follow-up; a typed adoption outcome instead of the adoption-reply prefix needs a migration.
  • CI: the sorted gated-test list fix is the second commit.
  • Workstream A review (fourth commit): M1 proven and tested (an accepted block whose post-offer processing keeps erroring before the landing has no pool-block row, so the third commit's predicate reports it; gated test with a persistent observation failure, age growing across retries and measured from the offer reservation); L1 fixed (no degraded stamp on unlanded blocks; unit test); L2 documented; N2 is the scope statement at the top.

🤖 Generated with Claude Code

djh58 and others added 3 commits September 24, 2026 10:14
… the unknown warning (#493)

Points 1 and 7 of #493. Telemetry and alert semantics only: no mining,
submit, landing, payout or deployment change.

Point 1. A null `submitblock` reply opened a known delivery wait whether or
not the node held the block on its active chain, so a lost tip race grew
`accepted_block_revision_work_pending_seconds` until its orphan proof
(`PRISM_CANDIDATE_ORPHAN_CONFIRMATIONS` competitor confirmations plus the
reconciliation backoff) and paged the #496-gated critical whenever that took
longer than 307 s. The offering frontend now records such an acceptance as
unlanded: outside the known pending age and build-deadline attribution, on
its own gauge `accepted_block_unlanded_seconds` (age of the oldest one; zero
when none; -1 under bounded-tracking saturation, never a silent zero). The
post-offer landing observation, a reconcile proof or a settlement observation
lands it on its original acceptance clock, so the histogram still measures
from the definitive acceptance; a committed proven orphan closes it without a
sample. A tombstone never reopens and a landed block is never downgraded.
`PrismAcceptedBlockUnlanded` warns (never pages) at 30 minutes for 3 m.

The same lost race also paged `PrismBlockCandidateOldestPendingCritical`
(60 s, 3 m) from the database collector on every coordinator, because a
`reconciliation` row is unfinished. The collector now reads, in the same
snapshot, `block_candidate_oldest_unacknowledged_seconds`: the oldest
unfinished row without a definitive node reply (`pending`, `offer_reserved`,
and offered rows whose one `submitblock` outcome is `unknown`). The paging
rule reads that gauge, so a found block not reaching the node pages exactly
as before and an unknown outcome keeps paging because receipt is unproven,
while a node-accepted lost race, a rejected block or a failing landing age
only the all-unfinished gauge: the 15 s warning still reports them and the
new non-paging `PrismBlockCandidateStuck` warns at 30 minutes for 3 m. All
three candidate gauges read -1 together when the collector fails.

Point 7. `PrismAcceptedRevisionWorkPending` had `for: 0s` and included the
tracking-unknown gauge and the -1 age, so any failed template refresh (one
2 s poll interval of unknown) warned. The unknown terms move to
`PrismAcceptedRevisionWorkTrackingUnknown` with a two-minute dwell and
no-data Alerting; the pending warning keeps its documented no-dwell budget,
missing-series and scrape-down terms unchanged.

Review fixes (independent review: one blocker, two major, three minor). A
definitive node rejection keeps paging through the unacknowledged age; only
a side-chain reply (a lost race to a first-arriving block) is excluded. A
row adopted on the node's own active-chain evidence is not unacknowledged.
A won block whose audit landing keeps failing is reported by
`block_candidate_oldest_landing_failed_seconds`, warned at 60 s for 3 m and
paged at 307 s for 1 m, the floor and dwell the revision-work critical
applies when the landing fails after the frontend's observation, so the
class is never silent whichever step refused. The candidate paging rule
falls back to the all-unfinished age on a target that does not export the
new series, so a mixed-version rollout never loses the page. The -1 HELP
wording and the backoff prose are corrected. The reason and reply
vocabulary is shared as constants between the coordinator and the
collector.

Tests: three landing unit tests (lost race never a known wait, landing on the
acceptance clock through every active-chain path, saturation as -1); four
PostgreSQL-gated tests in `landing_metrics.rs` (a real lost race through the
fake node, retried at five and six competitor confirmations, with an active
block as the positive control; an offer without a definitive reply beside a
node-accepted lost race in the collector's census; a `bad-cb-payee`
rejection beside an `inconclusive` reply; a landing transaction aborted
through the wire proxy and landed on the retry); the census, contract and
inventory updates (56 families); 26 promtool scenarios (one failed refresh
under and after the dwell, persistent unknown under and after the dwell,
saturation beside a known age, the unchanged budget warning, a lost race
that proves its orphan inside the threshold, a stuck unlanded row under and
after the dwell, saturated unlanded tracking, a lost race that never pages
either critical, a pre-offer or unknown-outcome row that still pages, a
rejected block that pages, a stuck reconciliation row that warns, a failing
landing under and past both dwells and one landed on its first retry, the
mixed-version fallback, collector failure); the deployment patch test
asserts the four new warnings dwell and never page, that the landing-failed
critical is a gated one-minute paging rule, and that the candidate paging
rule reads the unacknowledged age with the fallback.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
The expected-list checker requires byte order; the new
`candidate_collector_keeps_an_acknowledged_lost_race_out_of_the_paging_age`
entry was inserted before the `cancelled_*` lines. Moved after them.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…ot the error text (#493)

Deep-review findings on #503, all verified against the code.

The landing-failed gauge was discriminated only by the `last_error` prefix
that `settle_offered_inner` writes for a refused landing. Every other writer
of the same reconciliation row (a node or database error inside the landing,
which surfaces as "post-offer processing failed", a refused operator
recovery, a failed lease renewal) overwrote it, so the age read zero and both
landing-failed alerts resolved while nothing had landed, and a landing that
kept failing on a hard error paged nowhere. The collector now also counts
every reconciliation row with no `qbit_pool_blocks` row: the landing
transaction is that row's only writer, so its absence is the durable fact,
and the prefix only adds a landed row that no longer authenticates. The age
is measured from the offer reservation, the start of the post-offer
lifecycle and the instant the frontend's acceptance clock starts, so
pre-offer retry backoff never counts toward the 307 s critical.

Structure: `Acceptance::known()` is the one predicate behind `known_waits`
and `resolve`; `accept_block` takes an `Observation` (unlanded, active,
confirmed) instead of two bools; `adoption_evidence` is the single writer of
the adoption reply; the side-chain reply list is bound as `text[]`; the
census query is one legible statement with named predicates; the candidate
paging fallback is `unacknowledged or on(...) oldest_pending` (the `unless`
was redundant); the promtool script checks every rule as an alert rule; the
metadata file keeps its hand-authored formatting.

Tests: the landing-failure gated test now also fails a retry transiently (a
tip change under the observation overwrites `last_error`) and asserts the
age holds and never predates the offer.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

@kiwidream kiwidream left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Workstream A file-owner review (an Opus reviewer ran the checks on a read-only checkout of the PR head; I read the diff and the report and stand behind the findings).

Head 0cc9fca, merge base 8fc94fa. Read-only; nothing committed or pushed, worktree clean.

Verdict: request changes (one medium finding)

The A-owned files hold no behaviour change. The landing state machine is sound, and every command asked for passes. One paging gap was verified in the code: an accepted block whose post-offer processing keeps failing before the landing step now pages nowhere. On the base it paged.

Findings (most severe first)

M1 — An accepted block whose post-offer processing keeps erroring no longer pages (medium)

  • Code path (verified by reading):
    • coordinator.rs:2165: settle_offered_candidate writes last_error = "post-offer processing failed (node accepted the offer): …" when settle_offered_inner or land_offered returns an outer Err. The errors that do this are landed_audit_authenticated and rebuild_claim_parts database errors (?), and observe_candidate RPC or readiness errors (?) before the landing.
    • That reason does not start with LANDING_FAILED_REASON_PREFIX (candidates.rs:179).
  • What each gauge sees:
    • collectors.rs:59: the row is offer_outcome='accepted', so it is excluded from oldest_unacknowledged. Its last_error does not match the landing-failed prefix, so it is excluded from oldest_landing_failed.
    • On the landing side, observe_candidate never succeeded, so the identity stays unlanded (landing.rs:78). Pending age is 0 and the critical rule cannot fire.
  • What still alerts: only PrismBlockCandidateOldestPending (15 s, warning), PrismBlockCandidateStuck (1800 s, warning) and PrismAcceptedBlockUnlanded (1800 s, warning).
  • Base behaviour: the base paged this class through PrismBlockCandidateOldestPendingCritical (60 s + 3 m) and, once the block was observed, through the pending critical (307 s + 1 m).
  • Scope: the PR says "a won block whose ledger landing fails is never silent". That holds only for the inner Err(reason) path at coordinator.rs:2191.
  • Suspicion, not verified: how often this class persists in production. A persistent database or rebuild error for one row, or a node that answers but keeps failing the candidate observation, are the realistic triggers.
  • Fix options:
    • Count accepted rows whose last_error starts with post-offer processing failed in the landing-failed age.
    • Or key the landing-failed age on offer_outcome='accepted' AND last_error NOT LIKE 'block is not on the active chain%', so only the proven not-active reason is excluded.
  • Test that would catch it: a gated landing_metrics test modelled on failed_audit_landing_after_the_offer_is_reported_until_a_retry_lands. It accepts an offer, makes observe_candidate fail persistently (for example getblockhash at the candidate height errors, or the wire proxy aborts the rebuild read), and asserts candidate_oldest_landing_failed > 0 or candidate_oldest_unacknowledged > 0.

L1 — A build deadline can mark an unlanded block degraded (low; not a regression)

  • Where: landing.rs:594-606. When the deadline is attributed through a different known wait, the loop sets degraded on every open block with at <= build.at, unlanded ones included.
  • Scenario: known wait X is open, and winning block Y was accepted but its observation has not happened yet (rebuild takes seconds). A deadline hits, then Y lands and publishes. Y's sample is labelled degraded for a deadline that fired before Y was on the chain.
  • Relation to base: the base did the same, because Y was a known wait then. It is inconsistent with the PR's statement that an unlanded block is "not in build-deadline attribution".
  • Test: a unit test with known X plus unlanded Y, deadline_hit, then land and deliver Y. Expect published; today the label is degraded.

L2 — An unlanded-only frontend reads as unknown when the terminal probe fails (low; documentation nuance)

  • Where: landing.rs:122. unknown() includes pending() && terminal_failed, and pending_count counts unlanded identities.
  • Effect: when the database collector fails with only an unlanded lost race open, tracking reads unknown and the pending age reads -1. That contradicts "not unknown tracking" in the PR text.
  • Assessment: defensible, because the probe is the peer-orphan evidence path. The PR text or the HELP text should say so.

Notes

  • N1 (documented by the PR): a side-chain block that later becomes active lands on its original acceptance clock. Its known age starts high, and its histogram sample includes the time it spent on the side chain.
  • N2 (scope): the PR is wider than "unlanded seam and warning dwell".
    • It adds three families and extends the collector SQL.
    • It adds five rules and re-points the candidate paging rule.
    • A side-chain rejection (inconclusive/duplicate/duplicate-inconclusive) no longer pages.
    • A landing that fails after acceptance moves from paging at 60 s + 3 m to paging at 307 s + 1 m.
    • All of this is telemetry and alert semantics. None of it touches control flow in the A files.

Q1 — Behaviour fence: every hunk in the A-owned files

coordinator.rs:

Line Hunk Classification
1764-1767 Operator-recovery adoption evidence built from ADOPTED_OFFER_REPLY_PREFIX No behaviour change. The string is byte-identical to the base ("node reports block " + block + " active …"). It is still written to offer_reply by the same statement.
2095-2101 accepted_block becomes accepted_unlanded_block, plus a comment Pure observation call. It is a metrics-mutex state change with no I/O or await, and nothing on the offer path reads it.
2124-2128 Pre-offer adoption evidence from the prefix constant No behaviour change; byte-identical.
2189-2192 Landing-failed reason from LANDING_FAILED_REASON_PREFIX No behaviour change; byte-identical ("landing failed after the offer" + " ({offer}): {reason}").

ledger/candidates.rs (lines 168-185): three new pub const values, with no executed SQL and no transaction or pool use.

  • ADOPTED_OFFER_REPLY_PREFIX
  • LANDING_FAILED_REASON_PREFIX
  • SIDE_CHAIN_REPLIES_SQL, a static SQL fragment that only metrics/collectors.rs consumes.

ledger.rs:35-36 only re-exports them.

The one SQL change is in metrics/collectors.rs:59, outside the A files. It extends the existing candidate statement with two FILTER aggregates and two bound LIKE parameters. It runs on the same &mut *tx inside the existing REPEATABLE READ READ ONLY transaction, under the same 2 s statement timeout and 3 s deadline. The statement count is unchanged and there is no new pool checkout.

python3 scripts/check_prism_pool_acquires.py exits 0 with this census: borrowed 18, compatibility 9, delegated 117, non-database 17, operator 13, public 36, startup 12, timed 13, plus 404 mutable executor borrows.

Result: no hunk in the A-owned files changes control flow, a query, a lock, a deadline, a write or an error path.

Q2 — Lost-race state machine (per frontend, process-local)

States:

  • absent
  • U (unlanded): open, unlanded=true
  • L (landed-pending): open, unlanded=false, revision bound or not
  • K (unknown): unknown_revision or orphan_uncertain
  • closed-published / degraded / superseded: one histogram sample
  • closed-orphan: no sample
  • tombstone: closed and retained while height > retired_height
  • retired: removed; height <= retired_height rejects re-entry

Transitions:

  • absent → U: accepted_unlanded_block, only at coordinator.rs:2100, after submitblock returns null.
  • absent → L: accepted_block or accepted_landed_block. The callers are the chain-reconcile landing targets (coordinator.rs:925/927) and observe_candidate when the block is active (coordinator.rs:1470).
  • U → L, keeping the original at:
    • accept_block with unlanded=false on an existing identity (landing.rs:306-313)
    • revision_work_settlement (landing.rs:461-466); both settlement sites (blocks.rs:331, blocks.rs:486) follow an active observation
  • L → U: never. An unlanded call on an existing identity is a no-op.
  • U or L → K (orphan uncertainty): revision_work_orphan_settlement arms it.
  • K (orphan) → closed-orphan: the COMMIT succeeds, or the terminal probe finds state='orphaned'.
  • U or L → closed-orphan: orphaned(). Guarded by !closed, so it runs at most once.
  • L → closed-published / degraded / superseded: resolve() after delivery. resolve() only visits !closed blocks and needs revision.is_some(), which a U block never has because bind_landing only runs after settlement, and settlement lands it first.
  • closed → tombstone → retired: revision_work_matured.

Out-of-order cases, all checked:

  • A landing observation after the orphan close cannot reopen the identity (!block.closed guards at landing.rs:310 and :464). The unit test lost_race_acceptance_is_unlanded_and_never_a_known_pending_wait covers the orphan-then-accepted_unlanded-then-accepted_block sequence and asserts no sample.
  • A reconcile proof after a tombstone is a no-op while the identity is retained. After retirement the height watermark rejects it.
  • A duplicate unlanded acceptance after landing is a no-op.
  • No transition can be taken twice: the sample and pending_count decrement are guarded by closed.

Never-taken cases:

  • The main one is M1: a won block whose observation keeps failing stays U. It never lands and never pages.
  • Edge case: a block that matures before this frontend ever observes it active drops out of the landing targets (maturity_state != "mature"). It stays U until restart, and PrismAcceptedBlockUnlanded warns. The base had the same behaviour as a paging known wait, so this is not a regression.

EP-STATE: an earlier landing cannot overwrite a later orphan close. Verified by the code and the unit test.

Q3 — Exactly-once and clocks

  • at is set only on insert (landing.rs:325). The offering frontend inserts right after submitblock returns and before record_offer. Later accept_block or settlement calls never touch at.
  • If an active-chain observation came first, the earlier clock is kept.
  • Each frontend has its own registry. A non-offering frontend opens its own identity on its own first active observation. That sample is per frontend by design, as the HELP text says. It cannot add a second sample to the offering frontend's identity.
  • Within a frontend, closed guards the sample.
  • The tombstone bound is process-local: a HashMap of at most LIMIT = 4096 entries, where reaching the limit sets saturated. It is retired by the mature watermark, with late proofs rejected by retired_height. This part is bounded.

Q4 — Alert semantics

  • PrismAcceptedRevisionWorkPendingCritical: the expression is unchanged from base (known age ≥ 307, age ≥ 0, clients > 0, up == 1, for: 1m). A #413-class stall pages once the age holds at 307 s for 1 m, at about 367 s. The shortest hold that pages is therefore a known age of 307 s held for 60 s.
  • Scenarios at the incident floor:
    • "landing incident critical floor" (307)
    • "landing before incident critical floor" (306.99)
    • "landing increasing age at 307s" (not yet firing, inside the dwell)
    • "landing increasing age fires after the dwell" (fires at 6m7s)
    • "landing critical is pending under the dwell" (30 s)
  • Unknown-tracking warning: it is now the separate PrismAcceptedRevisionWorkTrackingUnknown, for: 2m, no-data Alerting, non-paging.
    • Scenarios just below the dwell: "landing one failed refresh is pending under the unknown dwell" (32 s) and "landing persistent unknown is pending under the dwell" (1m59s). At 2m it fires.
    • The pending warning keeps for: 0s with > 1 s, a missing series, or up == 0.
    • The -1 and unknown conventions are kept, and the critical still needs age ≥ 0.

Q5 — Census and generated docs

  • python3 scripts/generate_prism_alerts.py --check --snapshot <qbit-tools a007a142 snapshot> exits 0, so the migration table and the qbit-tools patch equal the generator output. The template's sha256 matches the manifest.
  • python3 scripts/generate_prism_metrics.py --check exits 0.
  • python3 scripts/test_prism_alert_deployment.py --snapshot … exits 0: "Patch applies cleanly; 10 Jinja gate combinations passed; 78 original / 72 proposed rules; 34 external definitions preserved; 26 baseline deletions…"
  • python3 scripts/test_prism_alert_promql.py with promtool 3.14.0 exits 0: "38 expressions; 146 scenarios; 328 expression assertions; 227 alert assertions passed".
    • The first attempt died because promtool panicked with "preallocate: disk quota exceeded" on /tmp; my own scratch build had filled the /tmp quota. The rerun used TMPDIR on /home and passed.
  • PR #470 conflict, checked with git apply --check of gh pr diff 470. The diff applies cleanly to base 8fc94fa. On the #503 head, four files fail:
    • tests/observability/cardinality.rs: both PRs rewrite the 53/232 and 53/666 asserts, and the DatabaseMetrics literal sits next to #470's hunks.
    • tests/observability/contract.rs: both PRs insert after accepted_block_revision_work_tracking_unknown.
    • docs/prism-metrics-cardinality-privacy.md: both PRs rewrite the "current bound" sentence.
    • src/metrics/registry.rs:135: both PRs change the run-role match arm around RevisionWorkTimeouts.
  • Merging #470 second or #503 second:
    • Whichever lands second resolves to 60 families, 238 startup series and 673 populated series (53 + 3 + 4; 232 + 3 + 3, because rollup lag has no sample at startup; 666 + 3 + 4).
    • Rerun generate_prism_metrics.py (inventory and metadata; #503 also reflowed the metadata JSON).
    • Drop #503's privacy-doc sentence "Adjacent node/rollup additions are outside this branch's census".
    • metrics.rs, the metrics_snapshot tests, the metadata JSON, prism-native-metrics.md and coordinator.rs apply textually. The generated inventory still needs the --check rerun.

Q6 — The test that fails on base

  • Name: landing_metrics::lost_race_stays_unlanded_until_its_orphan_proof_and_an_active_block_still_pages, at tests/landing_metrics.rs:948.
  • On the head: passes, inside the 39/39 run.
  • On base: I exported 8fc94fa with git archive and added the head test file cut to its first 1065 lines. The last three new tests use the new DatabaseMetrics fields and LANDING_FAILED_REASON_PREFIX, so the full file does not compile on base. The cut file compiled against base, because UNLANDED is a string constant in the test file.
  • Result on base: 0 passed, 1 failed, Error: lost race counted as a known pending wait. That is the assertion at line 981, PENDING == 0 after the row reaches reconciliation. It fails for the stated reason, not because of a missing symbol.

Commands and results (head 0cc9fca)

  • cargo build --locked -p qbit-prism-server: exit 0
  • cargo clippy --locked -p qbit-prism-server --all-targets -- -D warnings: exit 0
  • cargo test --locked -p qbit-prism-server --test observability: 17/17 pass
  • test/prism-native-tests.sh cargo-args --locked -p qbit-prism-server --test landing_metrics: 39/39 pass; the gate manifest shows all four new tests executed
  • cargo test --locked -p qbit-prism-server --lib metrics::: 48/48 pass
  • python3 scripts/check_prism_pool_acquires.py: exit 0
  • python3 scripts/test_prism_alert_promql.py (promtool 3.14.0, TMPDIR on /home): exit 0
  • python3 scripts/generate_prism_alerts.py --check --snapshot …: exit 0
  • python3 scripts/generate_prism_metrics.py --check: exit 0
  • python3 scripts/test_prism_alert_deployment.py --snapshot …: exit 0
  • Not run: workspace-wide tests, the full gated suite, live_regtest, cargo fmt.

djh58 and others added 2 commits September 24, 2026 11:06
…es off unlanded blocks (#493)

Workstream A review of #503 (three findings).

M1: an accepted block whose post-offer processing keeps erroring before
the landing (a database error in the landed-audit check or the rebuild, or
a node or readiness error in the candidate observation) carries the
"post-offer processing failed" reason. Every such error returns before the
landing transaction, which is the only writer of the pool-block row, so the
previous commit's no-pool-block predicate already reports it. A gated test
now proves it on real rows: the observation fails on every attempt, the
landing-failed age is positive, keeps growing across a failing retry, never
predates the offer reservation, nothing is unacknowledged and the frontend
identity stays unlanded; restoring the node lands the audit and the age
returns to zero.

L1: a build deadline attributed through another known wait no longer marks
an unlanded block degraded: it has no revision work yet, so a deadline that
fired before it landed cannot have delayed its delivery. Unit test added.

L2: the HELP, metadata and contract prose now state the one deliberate
exception to "an unlanded acceptance is a known state": while the terminal
probe that carries peer orphan evidence fails, an unlanded-only frontend
reads tracking unknown and a -1 pending age, and the unlanded gauge keeps
the age.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…-paging

Both sides add metric families. Conflicts resolved by hand in the census
tests only: `tests/observability/cardinality.rs` re-derived from the merged
registry (60 families; 241 startup and 675 populated series: #504's four
families and six series plus this branch's three unlabeled gauges), and
`tests/observability/contract.rs` keeps both sides' gauge names. #502 and
#507 touch no metrics files. The auto-merged registry, metrics, coordinator,
ledger, metadata, inventory and gated-test list were checked: every family
and constant from both sides is present, the metadata names all resolve in
the registry, the inventory is regenerated, and the gated list is byte-sorted
with no duplicates.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@djh58

djh58 commented Sep 24, 2026

Copy link
Copy Markdown
Member Author

Thanks for the review. Per-finding dispositions, addressed on top of your reviewed head 0cc9fcaa:

  • M1 (medium) — fixed, bc614a2c + 11e0b9db. The landing-failed age no longer depends on the last_error prefix alone. The collector also counts every reconciliation row with no qbit_pool_blocks row: the landing transaction (ledger/blocks.rs, one commit) is that row's only writer, and every pre-landing error in land_offered (the landed-audit check, the rebuild, the candidate observation) returns before it, so the "post-offer processing failed" class, a refused operator recovery and a failed lease renewal all keep the age positive. It is measured from the offer reservation, so pre-offer backoff never counts. Your suggested gated test is in 11e0b9db as persistently_failing_post_offer_observation_is_reported_from_the_offer_reservation: the observation fails on every attempt, the age is positive, keeps growing across a failing retry, never predates the offer, nothing is unacknowledged, the frontend identity stays unlanded, and restoring the node lands the audit and returns the age to zero. After a committed landing whose post-landing observation keeps failing, the block belongs to the chain reconcile (coordinator.rs landing targets, settlement through reconcile_blocks_at_revision), whose known wait pages PrismAcceptedRevisionWorkPendingCritical at 307 s + 1 m if delivery stalls; the stuck candidate row only warns. Stated in the PR body.
  • L1 (low) — fixed, 11e0b9db. The degraded stamp in deadline_hit skips unlanded identities (!block.unlanded), with your unit test (deadline_attributed_to_a_known_wait_does_not_degrade_an_unlanded_block: X degraded, Y published).
  • L2 (low) — documented, 11e0b9db. The HELP text, the metadata and the contract prose now state the one exception: while the terminal probe that carries peer orphan evidence fails, an unlanded-only frontend reads tracking unknown and a -1 pending age; the unlanded gauge keeps the age.
  • N1 — unchanged, as documented in the PR body.
  • N2 (scope) — the PR body now opens with an explicit scope statement: three families, five rules, the re-pointed candidate paging rule (with a mixed-version fallback), side-chain rejections no longer paging, and the landing-failed page moving from 60 s + 3 m to 307 s + 1 m from the offer reservation.
  • 3.x.x: Export node peers, initial block download, observation age and hashrate-rollup lag (#467) #470 conflict note — the branch is now merged with 3.x.x (085eda7c, includes 3.x.x: single-pass tee, chunk-parallel counted-share JSON and lean tip probes for the refresh (#275) #502, 3.x.x: capture own blocks found on same-parent superseded payout work (#478) #504, 3.x.x: make the probe-window dead-connection test deterministic #507); the census is re-derived from the merged registry (60 families, 241 startup / 675 populated series).

Head is 085eda7c. Re-requesting your review.

@djh58
djh58 requested a review from kiwidream September 24, 2026 15:18
@djh58

djh58 commented Sep 24, 2026 •

Copy link
Copy Markdown
Member Author

Deep review: final ledger (head 085eda7c)

Stakes: not high-stakes (telemetry, alert rules, docs and tests; no funds, consensus, auth or migration). Lanes: /code-review medium, thermo-nuclear quality lane, adversarial lane, the Workstream A file-owner review, CI. Result: 16 findings: 14 fixed (bc614a2c, 11e0b9db), 1 deferred, 1 rejected. The lost-race mechanics (points 1 and 7) were confirmed sound by every lane; the one real defect found after the first push (the landing-failed age keyed on error text that later retries overwrite) was raised independently by two lanes and by the file-owner review and is fixed with the pool-block-row discriminator plus gated tests.

Lane Finding Disposition
/code-review medium landing-failed gauge drops to zero when a retry fails for a different reason (post-offer processing failed / operator recovery stopped overwrite last_ fixed (bc614a2)
adversarial lane hard errors in the landing path are written under 'post-offer processing failed' and never carried the landing-failed prefix, so a failing landing pag fixed (bc614a2)
adversarial lane retry_candidate after a lease-renewal failure overwrites last_error and zeroes the landing-failed age for a backoff interval fixed (bc614a2)
adversarial lane landing-failed age measured from created_at includes pre-offer backoff, so a single refusal after a long pre-offer wait could page the 307 s critical fixed (bc614a2)
thermo-nuclear quality lane paging classification decided by prose-prefix matching written at three coordinator sites fixed (bc614a2)
thermo-nuclear quality lane mixed-version fallback carries a redundant unless fixed (bc614a2)
thermo-nuclear quality lane uid-prefix allowlist in the promtool script is dead filtering fixed (bc614a2)
thermo-nuclear quality lane known_waits and resolve no longer share one predicate fixed (bc614a2)
thermo-nuclear quality lane accept_block takes two positional bools with an impossible combination fixed (bc614a2)
thermo-nuclear quality lane tests/landing_metrics.rs crosses 1k lines with census tests that are not landing telemetry deferred
thermo-nuclear quality lane the census query is a 750-character single line with the age expression spelled three times fixed (bc614a2)
CI Rust PostgreSQL contracts shard 1 failed at head 0cc9fca: ledger::connect::acquire::probe_tests::a_dead_idle_connection_inside_the_probe_window_fails rejected
Workstream A review an accepted block whose post-offer processing keeps erroring before the landing paged nowhere at 0cc9fca fixed (11e0b9d)
Workstream A review a build deadline attributed through another known wait marks an unlanded block degraded fixed (11e0b9d)
Workstream A review an unlanded-only frontend reads unknown when the terminal probe fails, contradicting 'not unknown tracking' fixed (11e0b9d)
Workstream A review the PR is wider than 'unlanded seam and warning dwell' fixed (11e0b9d)

Deferred (coordinator-accepted): splitting the now >1k-line landing test file into a candidate-census binary (needs the shared fixture helpers hoisted; mechanical follow-up), and a typed adoption outcome instead of the adoption-reply prefix (needs a migration).

CI: all checks green.

@kiwidream kiwidream left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Workstream A file-owner re-review at head 085eda7 (an Opus reviewer re-ran the checks on a read-only checkout; I read the fix commits and the report and stand behind it).

Merge base with 3.x.x: 623aa86. Fix commits reviewed: bc614a2, 11e0b9d. Upstream merge hunks (#502, #504, #507) are out of scope.
Host: minidev-alex1. Read-only; nothing committed, git status is clean.

Verdict: approve

M1, L1 and L2 are resolved. There is one new Low (L3): a won block whose first post-offer processing hangs before its landing observation, rather than erroring, no longer pages. It could be fixed with one predicate in this PR or tracked as a follow-up. There is also one pre-existing documentation nit (N1).

Prior findings

M1: resolved

  • crates/qbit-prism-server/src/metrics/collectors.rs:70-72,78: the landing-failed filter is now state='reconciliation' AND (last_error LIKE 'landing failed after the offer%' OR NOT EXISTS pool-block row), and the age is measured from COALESCE(offer_reserved_at,created_at).
  • Single writer (verified). The only production INSERT INTO qbit_pool_blocks is ledger/blocks.rs:232, inside the landing transaction. The audit bundle, payout entries, carry-forward and fanouts are written in the same transaction, which commits at line ~246. There is no production DELETE (a grep across .rs, .sql and scripts found only test fixtures). qbit_pool_audit_bundles.block_hash REFERENCES qbit_pool_blocks (crates/qbit-prism/sql/001_share_ledger.sql:811), so the "existing bundle" early commit in land_candidate (blocks.rs:~151-168) cannot run without the row. No path writes the row without the rest of the landing, and none lands without the row.
  • Every pre-landing error in land_offered returns before that transaction (verified) (coordinator.rs:1997-2037). The steps, in order: landed_audit_authenticated (?); stored_inputs_mismatch (?); rebuild_claim_parts (?, the permit, and a 60 s deadline mapped to Ok(Err)); observe_candidate at 2030 (?); then land_candidate_at_revision, whose error maps to Ok(Err) and so to the "landing failed" prefix. A landing whose COMMIT reply is lost while the commit succeeds leaves the row present and the prefix set. It is counted through LIKE $2 until the retry authenticates the landed audit. That is transient and errs toward reporting.
  • Clock (verified). Migration 015's known_offer check (migrations/015_candidate_orphan_disposition.sql:~99-102) requires offer_reserved_at to be non-null on every reconciliation row. Adoption also sets it (ledger/candidates.rs:960). The created_at fallback is therefore unreachable, and the age never starts at claim or enqueue.
  • Fails on 0cc9fca for the stated reason (reasoned from the diff). The test is landing_metrics::persistently_failing_post_offer_observation_is_reported_from_the_offer_reservation (tests/landing_metrics.rs:1340). At 0cc9fca the filter was the prefix only. The row's last_error is "post-offer processing failed …", so the age is 0 and ensure!(first.candidate_oldest_landing_failed > Duration::ZERO, "…was silent") fails. Every symbol it uses (the collectors::database fields and the UNLANDED sample) exists at 0cc9fca except the in-file helper row_reason, which the same commit adds. The failure is therefore an assertion failure, not a missing symbol.
  • Carve-out ("committed landing, post-landing observation keeps failing, only warns"): acceptable. observe_candidate (coordinator.rs:1516-1520) calls accepted_block whenever it sees the block active. If the pre-landing observation at 2030 saw it active, the identity is already landed, a known wait. After the commit the pool-block row exists, so chain reconcile() (coordinator.rs:865-931) observes it through work_ledger.pool_blocks(), lands and confirms it whatever the outbox state is, and revision work is delivered. The stuck outbox row is bookkeeping (PrismBlockCandidateOldestPending/Stuck warnings). If reconcile cannot run either (node unready), the known wait pages PrismAcceptedRevisionWorkPendingCritical at 307 s + 1 m, provided authorized_clients > 0 (a pre-existing gate). If the pre-landing observation saw the block inactive, this is the lost-race class, which is not supposed to page. This is not a second silent class.

L1: resolved

  • Guard at metrics/landing.rs:617 (!block.closed && !block.unlanded && block.at <= self.at).
  • Test: metrics::landing::tests::deadline_attributed_to_a_known_wait_does_not_degrade_an_unlanded_block (landing/tests.rs:743). Without the guard, Y would be degraded, count("degraded") would be 2, and the assertion would fail. It passes at the head.

L2: resolved (documented)

  • Code: unknown() includes pending() && terminal_failed, and pending() counts unlanded identities. age() then returns -1 when no known wait exists (landing.rs:130-151), and unlanded_age() keeps the age (landing.rs:110-119).
  • The HELP text (registry.rs:73), metadata and docs/prism-native-metrics.md (~345-351) state exactly that exception. They match the code.

New findings

L3 (Low, new): a won block that hangs in offered before its landing observation pages nowhere

  • Where. coordinator.rs:2224 opens the identity as unlanded. land_offered then waits on build_slots.acquire_owned() (coordinator.rs:1925), which has no deadline, while the heartbeat keeps renewing the claim (coordinator.rs:1563, "Establish ownership before even waiting for build capacity"). The landing observation that lands the identity comes only after that, at coordinator.rs:2030. The row stays in state offered with outcome accepted throughout.
  • Signals during the hang. Unacknowledged age: 0 (an accepted row is excluded). Landing-failed age: 0 (the filter is state='reconciliation' only, collectors.rs:70). Revision-work pending: 0 (unlanded only). The remaining signals are the OldestPending warning (15 s for 3 m), then Unlanded and Stuck at 1800 s, both warnings.
  • At base 623aa86 the same block paged twice: PrismBlockCandidateOldestPendingCritical (all unfinished rows, 60 s for 3 m) and PrismAcceptedRevisionWorkPendingCritical (the identity was a known wait from acceptance, 307 s + 1 m).
  • Scope. A total build-slot starvation also stalls job builds, so PrismSemanticWorkCoverageLossCritical still pages. The residual gap is partial contention that delays the landing by more than 5 minutes while jobs still flow. The permit queue is shared with job builds (coordinator.rs:1166, 1371) and with other post-offer rebuilds, each of which can hold a permit for up to 60 s.
  • Suggested fix. Use state IN ('offered','reconciliation') in LANDING_FAILED. The age is already measured from the reservation, and a normal-flight offered row lands within the 60 s rebuild deadline, far below 307 s.
  • Tests that would catch it. A gated test that holds every build_slots permit after an accepted offer and asserts candidate_oldest_landing_failed > 0 while the row is offered. A matching prism-alert-scenarios.json case: offered, accepted and unlanded, with unacknowledged 0 and landing-failed rising, paging at 307 s + 1 m.
  • Status: suspicion of impact, verified mechanism. The code path is verified. I did not reproduce it with a test.

N1 (nit, pre-existing and carried forward)

docs/prism-metrics-cardinality-privacy.md:10-11 says "56 families and 669 series … Startup has 235 series", but the census test asserts 60/675/241. The same offset of 4/6/6 already existed at base (53/666/232 against 57/672/238). #470 corrects the document to match the test.

Behaviour fence (coordinator.rs, ledger/candidates.rs, and ledger.rs re-exports), PR diff 623aa86..085eda7

Hunk Classification
coordinator.rs:1813 operator-recovery adoption evidence now comes from adoption_evidence(block, height, &tip) Refactor of a written value. The offer_reply string is byte-identical ("node reports block {hash} active at height {h} with tip {tip}"). No change to control flow, query, lock or deadline.
coordinator.rs:2219-2225 accepted_block becomes accepted_unlanded_block Pure observation call.
coordinator.rs:2247-2251 pre-offer adoption evidence from adoption_evidence(...) Refactor; byte-identical written value.
coordinator.rs:2312-2315 landing-refused reason built from LANDING_FAILED_REASON_PREFIX Refactor; last_error is byte-identical ("landing failed after the offer ({offer}): {reason}").
ledger/candidates.rs:168-196 adds ADOPTED_OFFER_REPLY_PREFIX, adoption_evidence(), LANDING_FAILED_REASON_PREFIX and SIDE_CHAIN_REPLIES Constants and a pure formatter. No SQL, lock, deadline or error path.
ledger.rs:32-36 Re-exports only.

No hunk in the fence changes control flow, a query, a lock, a deadline, a write or an error path.

The collector (metrics/collectors.rs:46-87, not A-owned) changes one existing SELECT: it adds two FILTER aggregates and a NOT EXISTS probe of qbit_pool_blocks by primary key. It still runs inside the existing read-only collector transaction (fetch_one(&mut *tx), line 86) under the existing statement_timeout 2000 and lock_timeout 500. There is no new pool checkout and no new statement, and the only locks taken are the ones a plain read takes. python3 scripts/check_prism_pool_acquires.py passes.

EP-STATE / EP-OBSERVABILITY

  • The pool-block signal is a database census that is read only. It never touches identity state in landing.rs, so it cannot reopen a closed identity. Out-of-order cases are covered and pass: the proven orphan, followed by accepted_unlanded_block and accepted_block on the tombstone, stays closed with no sample (landing/tests.rs lost_race_acceptance_is_unlanded_and_never_a_known_pending_wait); proven_orphan_closes_without_delivery_and_keeps_its_deduplication_horizon; terminal_probe_versions_preserve_newer_failure_and_monotonic_orphan_evidence.
  • The -1 conventions hold. Collector failure makes all three candidate ages -1, which triggers PrismBlockCandidateMetricsUnavailable (fixture "candidate collector failure invalidates the unacknowledged age with the others"). Unlanded saturation reads -1. The HELP text for landing-failed names the clock ("time since the offer reservation").

Paging table (incident class → page and its delay)

Class Base 623aa86 Head 085eda7
Pre-offer pending / offer_reserved row OldestPendingCritical, age ≥60 s, 3 m (≈4 m from enqueue) Same, through the unacknowledged age (≈4 m)
Offered, unknown outcome (not adopted) ≈4 m ≈4 m (unacknowledged)
Adopted active row (unknown outcome, reply "node reports block …") ≈4 m No candidate page (acknowledged); the block's revision work is a known wait
Invalid rejection (e.g. bad-cb-payee) ≈4 m ≈4 m (unacknowledged)
Side-chain rejection (inconclusive/duplicate/duplicate-inconclusive) ≈4 m No page; OldestPending warning, Stuck warning at 1800 s
Accepted lost race (landed audit, awaiting orphan proof) ≈4 m (candidate) and 307 s + 1 m (revision work, the #493 bug) No page; Unlanded and Stuck warnings at 1800 s + 3 m
Accepted, landing refused or errored before the landing (reconciliation, no pool-block row) ≈4 m (all-unfinished age) LandingFailedCritical at 307 s + 1 m from the offer reservation (≈6 m 7 s); LandingFailed warning at 60 s + 3 m
Accepted, landed, post-landing observation keeps failing ≈4 m No candidate page; revision-work critical at 307 s + 1 m if delivery also stalls
Accepted, hung in offered before the landing observation (L3) ≈4 m and 307 s + 1 m No page (warnings only) unless coverage loss pages
Known revision-work stall (#413 class, 307 s hold) 307 s + 1 m (6 m 7 s) Unchanged: fixture "landing increasing age fires after the dwell" fires at 6m7s; "…at 306s" does not; "incident critical floor" is 307
Mixed-version target (no unacknowledged series) n/a Falls back to the all-unfinished age, ≈4 m (fixtures "mixed-version rollout falls back…" at 4m and "…pending under the dwell" at 3m59s)

Fixture coverage (tests/fixtures/prism-alert-scenarios.json):

  • The errored post-offer path feeds the same landing-failed gauge. It is pending at 6m6s and fires at 6m8s ("candidate failing landing is pending under the paging dwell" and "…pages at 307s plus one minute"), bracketing 307 s + 1 m.
  • Side-chain rejection has no fixture of its own. It shares the "lost race in reconciliation never pages" shape (unacknowledged 0) and is proven in Rust by the gated node_rejected_block_pages_as_unacknowledged_but_a_side_chain_reply_does_not (landing_metrics.rs:1161).
  • Mixed version is covered.
  • The unknown-tracking dwell (2 m) is covered: pending at 1m59s, fires at 2m, and one failed refresh never warns.

Census

  • cargo test --locked -p qbit-prism-server --test observability: 17 passed. The census asserts 60 families, 241 startup series, 675 populated series (tests/observability/cardinality.rs). This matches the author's claim.
  • #470 (open, base 3.x.x, head f58fd0e) changes the same lines from 57/238/672 to 61/241/676, so it adds 4 families, 3 startup series and 4 populated series. Whichever of the two merges second hits textual conflicts on both assert_eq! pairs in cardinality.rs and on the bound sentence in docs/prism-metrics-cardinality-privacy.md. If #470 merges second, the expected values become 64 families / 244 startup / 679 populated, and the document line should read "64 families and 679 series … Startup has 244". If #470 also touches the DatabaseMetrics literal or contract.rs family lists, it must add the three new #503 fields and families (candidate_oldest_unacknowledged, candidate_oldest_landing_failed, accepted_block_unlanded_seconds). I did not check #470's other hunks.

Command log (worktree at 085eda7)

Command Result
cargo build --locked -p qbit-prism-server (CARGO_BUILD_JOBS=6) ok (rc 0)
cargo clippy --locked -p qbit-prism-server --all-targets -- -D warnings ok (rc 0)
cargo test --locked -p qbit-prism-server --test observability 17 passed, 0 failed
cargo test --locked -p qbit-prism-server --lib metrics:: 49 passed, 0 failed (516 filtered)
test/prism-native-tests.sh cargo-args --locked -p qbit-prism-server --test landing_metrics 40 passed, 0 failed; gate reports both failed_audit_landing_after_the_offer_is_reported_until_a_retry_lands and persistently_failing_post_offer_observation_is_reported_from_the_offer_reservation as executed
python3 scripts/check_prism_pool_acquires.py ok (rc 0); census borrowed 18, delegated 120 … 414 executor borrows
python3 scripts/test_prism_alert_promql.py (promtool 3.14.0 on PATH, TMPDIR in scratch) "38 expressions; 146 scenarios; 328 expression assertions; 227 alert assertions passed"; the original pool rule fails 2 required scenarios, as expected (rc 0)
python3 scripts/generate_prism_alerts.py --snapshot <snap> --check rc 0, no drift
python3 scripts/test_prism_alert_deployment.py --snapshot <snap> "Patch applies cleanly; 10 Jinja gate combinations passed; 78 original / 72 proposed rules; 34 external definitions preserved; 26 baseline deletions plus every native UID disabled by its gate" (rc 0)

Snapshot: qbit-tools@a007a142 grafana-alert-rules-prism.yml.j2 (sha256 8446692b…, matching tests/fixtures/prism-deployed-alerts.json) plus grafana-alert-rule-group.yml.j2, fetched with gh api.

Not run: the new tests against 0cc9fca. Their failure on the previous head is reasoned from the diff, because I could not check out or stash.

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.

2 participants