Skip to content

3.x.x: gate the accepted-revision-work paging rule like the other criticals - #496

Merged
djh58 merged 3 commits into
3.x.xfrom
djh58/prism-493-revision-work-critical-gates
Sep 22, 2026
Merged

djh58 merged 3 commits into
3.x.xfrom
djh58/prism-493-revision-work-critical-gates

Conversation

@djh58

@djh58 djh58 commented Sep 22, 2026 •

Copy link
Copy Markdown
Member

Refs #493 (points 2, 3 and 8; point 1 mitigated, not resolved). Rule surface, fixtures and HELP only: no landing, coordinator or ledger change, no deployment.

What paged falsely

PrismAcceptedRevisionWorkPendingCritical was the only paging rule in docs/prism-native-alert-rules.json with for: 0s, no_data_state: Alerting and no and on(job, instance, network) conjunction with the snapshot gauges, the scrape or connected miners. Reproduced with promtool against the unmodified rule (six scenarios, all firing): no connected miners, stale snapshot, unavailable snapshot, scrape down with a retained value, no gating series at all, and a single 307 s sample. A frontend with no connected miners has no mining.notify write that can close its wait (stratum.rs:944 is the only closer), so it paged 307 s after every pool block and never cleared.

Change

  • Critical rule: (pending >= bool 307) and (pending >= 0) and (snapshot available and not stale) and (authorized_clients > 0) and (up == 1), for: 1m, no_data_state/exec_err_state: OK. Same shape as PrismSemanticWorkCoverageLossCritical, plus the explicit up term so the scrape-down case is testable.
  • Dwell: the gauge is monotonic during a stall, so one minute only suppresses single-scrape gate flaps (four 15 s scrapes) and stays well under the five-minute hold that delayed PRISM: an orphaned own block stalls job delivery for ~300 s on every lost tip race #413. A prolonged known stall with miners connected still pages (scenario included).
  • Miner-disconnect tradeoff: a frontend whose miners all disconnect during a stall stops paging here; that state is owned by the connected-clients and coverage rules, consistent with the coverage critical's gate. Stated in the rule basis and in docs/prism-native-metrics.md.
  • Warning rule unchanged: zero dwell, no-data Alerting, so missing and unknown measurements stay visible.
  • HELP for accepted_block_to_revision_work_seconds and accepted_block_revision_work_pending_seconds now says every frontend samples every block from its own observation (sum across instances counts one block once per frontend). Names and types unchanged; inventory regenerated.
  • Fixture: 13 existing landing scenarios gain the gate series; landing tracking unknown, landing missing gauge and landing scrape down now expect no critical sample; landing increasing age at 307s expects the alert pending, not firing; 11 new scenarios cover each gate, the dwell boundaries, a miner flap under the dwell and a stall outlasting it. scripts/test_prism_alert_deployment.py asserts the rendered paging rule's for, noDataState and execErrState.

Verification (local, this branch)

  • scripts/test_prism_alert_promql.py with the CI-pinned promtool 3.14.0: 31 expressions, 103 scenarios, 198 expression assertions, 138 alert assertions passed.
  • scripts/generate_prism_alerts.py --check --snapshot … and scripts/generate_prism_metrics.py --check: clean; deployment patch regenerated (new specification SHA-256).
  • scripts/test_prism_alert_deployment.py --snapshot … against the frozen reviewed snapshot: patch applies, 10 Jinja gate combinations, 78 original / 65 proposed rules, rendered paging rule for 1m, noDataState/execErrState OK.
  • Negative control: the six pre-fix repro scenarios fail against the new rule (no alert), as intended.
  • Not run locally: the Rust observability tests (inventory.rs invokes both generators and checks HELP against the inventory; stratum.rs checks rendered HELP). The host is below the 10 GiB free-disk floor for a cargo build, so CI is the evidence for those.

Left out on purpose (#493 remainder)

  • Point 1, lost race on the offering frontend: still pages until its orphan proof, because that frontend has miners and the pending age is a metric decision (coordinator.rs:2031-2035 opens the wait on any accepted reply; tests/landing_metrics.rs:106-107 asserts it). The same row already pages through PrismBlockCandidateOldestPendingCritical (reconciliation is in UNFINISHED_SQL). Proposed seam: an unlanded flag in landing.rs set at acceptance and cleared at active proof or first confirmation, excluded by age() but keeping the acceptance clock for the histogram; one integration test in tests/landing_metrics.rs asserting the pending gauge stays 0 for a reconciliation row and the histogram still samples from acceptance once it lands.
  • Point 5, timeout-counter attribution after a lost COMMIT reply: revision_work_build reports pending while only unknown state remains, so every later initial-job timeout increments the counter. Proposed seam: Build.pending computed from known pending count only, with a unit test in src/metrics/landing/tests.rs that drops a settlement, times out a build and asserts the counter stays 0.
  • Points 4, 6, 7: accepted 3.x.x: Landing-phase metrics — time from block acceptance to new-revision work, with the alerts 2.x.x had #458 contract (restart horizon, saturation as unknown, warning dwell for 3.x.x: Cutover qualification — migration rehearsal, failover drill, soak, go/no-go #291).

🤖 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.

djh58 and others added 3 commits September 22, 2026 15:21
…ticals

Refs #493.

PrismAcceptedRevisionWorkPendingCritical was the only paging rule with
for 0s, no_data_state Alerting and no conjunction with the snapshot
gauges, the scrape or connected miners. A frontend with no connected
miners has no mining.notify write that can close its wait, so it paged
307 s after every pool block and never cleared; a stale or unavailable
snapshot, a failed scrape and a missing series paged too.

The rule now requires a known age (>= 0), an available and fresh
metrics snapshot, a scraped target and at least one authorized miner on
the reporting frontend, with a one-minute dwell and no-data and
evaluation errors treated as OK. The dwell only suppresses single-scrape
gate flaps on a gauge that is monotonic during a stall and stays well
under the five-minute hold that delayed #413; a prolonged known stall
with miners connected still pages. The warning keeps zero dwell and
no-data Alerting, so missing or unknown measurements stay visible.

HELP for the histogram and pending gauge now states that every frontend
samples every block from its own observation; metric names and types
are unchanged, and no landing, coordinator or ledger state changes.

Scenarios: thirteen existing landing cases gain the gate series, three
now expect no critical sample where the guard drops -1 or absent data,
and eleven new cases cover each gate, the dwell, a miner flap under the
dwell and a stall outlasting it. The deployment test asserts the
rendered paging rule's for, noDataState and execErrState.

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

Refs #493. Review follow-up on #496.

The paging rule no longer conjoins the metrics snapshot gauges: the
pending gauge is a live overlay rendered on every scrape, and a
database-pool stall that also stalls the health publisher must still
page. The known-age, authorized-miner and scraped-target terms and the
one-minute dwell stay. The miner count is a snapshot family, so while
the snapshot is stale the gate uses a count a few refresh intervals
old; that rare false page is accepted over a missed stall. The two
snapshot fixtures now expect the page.

The rule basis, the regenerated migration table and deployment patch,
and the metrics document now say what happens when every miner leaves
a frontend during a stall: this page resolves and nothing else pages
for that frontend, because the coverage rules cannot fire with zero
authorized clients and the connected-clients rule is a cluster-wide
non-paging warning; only the pending warning keeps reporting the age.

The miner-flap fixture is now discriminating: a one-sample flap at
1m15s expects no alert while a new no-flap control at the same
evaluation expects firing. The deployment test asserts, for every
native page=true rule, a non-zero dwell, OK no-data and error states,
and an availability conjunction, with the one-minute check separate.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Refs #493. Resolves the scenario fixture as a by-name union (the #463
advisory-lock scenarios plus this branch's landing cases) and regenerates
the deployment patch. The native paging-rule assertion now also covers
the #463 advisory-lock critical, which already satisfies it; the exact
set check becomes a subset check so new paging rules are covered rather
than listed.

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

djh58 commented Sep 22, 2026

Copy link
Copy Markdown
Member Author

Review ledger (final)

Head reviewed: 9c8d9b8c (merge of 3.x.x into 40a111ae; net diff against 3.x.x unchanged by the merge). Stakes: low (alert specification, PromQL fixtures, HELP strings, one Python test assertion).

Lanes

Lane Status
CI on 8b979e02 green, 20 jobs
CI on 40a111ae no run: the PR was unmergeable after 3.x.x advanced (#463, #472); resolved by merging the base, no force-push
CI on 9c8d9b8c green on attempt 2, all 20 checks, after rerun of the PostgreSQL contracts shard 0 (see the flake entry)
Independent adversarial review (Claude Fable) of 8b979e02 run: 1 major, 2 minor (F1–F3)
Independent quality review: thermo-nuclear pass + code-review medium (Claude Fable) of 8b979e02 run: no defect; T1–T6, CR1–CR2
Independent adversarial delta review of 40a111ae run: CLEAN, with mutation controls for F1, the flap pair and T1
Coordinator merge check of 9c8d9b8c run: net diff against 3.x.x unchanged; the T1 equality-to-subset relaxation accepted because the gate loop still covers the #463 rules
Codex adversarial lane NOT RUN: capacity unavailable
Codex-on-GitHub no review posted on this PR
Cursor bugbot not summoned (low stakes)

Findings and dispositions

Id Claim Disposition
F1 = T2 = CR1 (major) The snapshot available/stale conjunction silenced the page in a database-pool stall that also stalls the health publisher; the pending gauge is a live overlay and needs no snapshot gate fixed in 40a111ae: conjunction dropped, kept >= 0, authorized_clients > 0, up == 1, 1 m dwell; both snapshot fixtures now expect the page; basis restates the provenance and the accepted stale-miner-count tradeoff
F2 (minor) Description claimed a frontend whose miners all leave is covered by the connected-clients and coverage rules; the coverage rules cannot fire with zero authorized clients and connected-clients is a cluster-wide non-paging warning fixed in 40a111ae: every copy (rule JSON, migration table, deployment patch, metrics doc) now states that the page resolves and nothing else pages for that frontend; only the pending warning keeps reporting
F3 = CR2 (minor) Miner-flap fixture at 59 s passed with or without the flap fixed in 40a111ae: one-sample flap evaluated at 1m15s expects no alert, a no-flap control at the same evaluation expects firing; both directions verified by mutation in the delta review
T1 (medium) Paging invariant enforced only by one hand-written assertion fixed in 40a111ae/9c8d9b8c: every native page: true rule is asserted to dwell, be OK on no data and errors, and conjoin an availability gate; covers the #463 advisory-lock critical too (local-only evidence: CI does not run the deployment test)
Delta note N1 T1 matches substrings over the whole rendered rule, description included deferred: no current description satisfies it and four mutations prove the check bites; narrowing to the query model is a follow-up
T3 (low) up == 1 is redundant in production (staleness markers) won't fix: harmless, makes the scrape-down scenario expressible, matches the connected-clients rule
T4 (low) Long description duplicated into three artifacts deferred: pre-existing prefix + basis convention; deriving description in the generator is a follow-up
T5 (low) Fixture growth by copy-paste; a generator exists for the pool-wait family deferred: moving the landing family into a Python generator is a follow-up
T6 (low) Floor and dwell are literals, unlike the sibling criticals' deployment overrides won't fix: no deployment variable exists for this rule; the basis states that tuning is a specification change for #291
CI shard 0 on 9c8d9b8c offer_lifecycle::every_unfinished_state_is_claimable_retained_and_reserved_only_once failed unrelated known flake (same failure on recent 3.x.x pushes); this PR changes no crate code beyond two HELP strings; rerun green

Left for follow-up (not in this PR): #493 points 1 (lost-race pending semantics) and 5 (timeout-counter attribution after a lost COMMIT reply), with the seams proposed in the PR description; points 4, 6, 7 are the accepted #458 contract.

@djh58
djh58 merged commit 7b78ea6 into 3.x.x Sep 22, 2026
38 of 41 checks passed
djh58 added a commit that referenced this pull request Sep 23, 2026
) (#500)

* 3.x.x: attribute build deadlines to known revision-work waits only (#493)

After a lost or cancelled settlement COMMIT reply, the accepting frontend's
landing tracking is unknown for that block (`unknown_revision`), yet the
block still counted toward `pending_count`. `revision_work_build` derived
`Build.pending` from that raw count (or saturation), so every later
initial-job deadline, including admission and database waits unrelated to
the block, incremented `revision_work_build_timeouts_total` and stamped
`degraded` on the unknown wait (#493 point 5).

`Build.pending` now comes from the known waits only: open identities with
neither a lost settlement reply nor an unsettled orphan verdict, and no lost
ordering history, which is exactly the set the pending gauge reports. While
only unknown tracking remains, a deadline hit is an ordinary
`job_delivery_failures_total` event, the tracking-unknown gauge keeps
reporting the unknown state and the pending gauge stays -1; nothing is
counted as a revision-work failure or as zero. A known wait beside unknown
tracking still attributes its deadline as before. Mining, delivery, fences
and the #493/#496 paging rules are unchanged; HELP, inventory and the rule
basis state the known-wait rule.

Tests: three landing unit tests (lost settlement reply with a recovering
first confirmation, known wait beside unknown tracking, unsettled orphan
verdict, untrackable identity and lost ordering); one PostgreSQL-gated test
that loses a real COMMIT reply through the wire proxy and then holds a real
Stratum initial-job build at admission until its deadline; two promtool
scenarios for the corrected series (unknown-only with no timeout, unknown
beside a known 308 s stall with a real timeout).

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

* 3.x.x: attribute a build deadline to a wait that recovered mid-build (#493)

Review finding F1 on #500: `Build.pending` is a snapshot at the build's
start, so a wait that was unknown then (lost settlement reply) and recovered
through a proven first confirmation while the build was in flight was not
attributed when the deadline fired, and its later delivery read `published`;
the base counted that deadline. `deadline_hit` now also attributes when a
known wait accepted before the build is open at the deadline instant; the
degraded stamp for open waits accepted before the build is unchanged.
Unknown-only tracking at both instants still counts nothing.

The reviewer's discriminating test is adopted as a regression test; the
inventory prose and metadata state the two attribution instants.

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

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
djh58 added a commit that referenced this pull request Sep 24, 2026
… the unknown warning (#493) (#503)

* 3.x.x: keep a lost race out of the revision-work paging age and dwell 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]>

* 3.x.x: keep the gated-test list sorted (#493)

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]>

* 3.x.x: read the landing-failed age from the missing pool-block row, not 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]>

* 3.x.x: prove the errored post-offer path is reported and keep deadlines 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]>

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
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