Skip to content

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

Merged
djh58 merged 2 commits into
3.x.xfrom
djh58/prism-b493-timeout-attribution
Sep 23, 2026
Merged

djh58 merged 2 commits into
3.x.xfrom
djh58/prism-b493-timeout-attribution

Conversation

@djh58

@djh58 djh58 commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Refs #493 (point 5). Telemetry attribution only: no landing, delivery, fence, paging-rule or deployment change.

Problem

A lost or cancelled settlement COMMIT reply leaves the accepting frontend's tracking for that block unknown (unknown_revision), by design. The block still counted toward pending_count, and revision_work_build derived Build.pending from that raw count (or from saturation). Every later initial-job deadline on that frontend, including admission and database waits with no relation to the block, then incremented revision_work_build_timeouts_total and stamped degraded on the unknown wait, until restart. Reproduced first with failing tests: a unit test that drops a settlement and times out a build (counter read 1, expected 0), and a PostgreSQL-gated test that loses a real COMMIT reply through the wire proxy and then holds a real Stratum initial-job build at admission past its deadline (same false count).

Change

  • Build.pending is computed from the known waits only: open identities with neither a lost settlement reply nor an unsettled orphan verdict, and no lost ordering history. This is the same set the pending gauge reports, so the counter and the gauge now agree. Saturation without a known wait no longer counts either: it is unknown, and the tracking-unknown gauge already reports it.
  • While only unknown tracking remains, a deadline hit is an ordinary job_delivery_failures_total event; the tracking-unknown gauge stays 1, the pending gauge stays -1, nothing is counted as a revision-work failure and nothing is reported as zero. A later proven first confirmation that recovers the wait is not stamped degraded by a deadline the build never attributed.
  • A known wait beside unknown tracking attributes its deadline exactly as before (test).
  • HELP, docs/prism-native-metrics.md, the metric metadata and the PrismRevisionWorkBuildTimeouts basis state the known-wait rule; migration table and the review-only qbit-tools patch regenerated (specification SHA-256 changed).

Verification

Local, on the branch head, with a worktree-local target and the shared build lock:

  • Reproduction first: the new unit tests fail on the unmodified base at the counter assertion (1, expected 0); the new PostgreSQL-gated test fails on base with "a deadline hit while only unknown tracking remained was counted as a revision-work failure".
  • After the fix: metrics::landing unit tests 22/22; the whole landing_metrics gated binary 35/35 against PostgreSQL 16.15 with fsync on, gate manifest showing all 17 of its gated tests executed including the new one; observability test binary green.
  • 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: 33 expressions, 120 scenarios, 233 expression assertions, 145 alert assertions, including the two new scenarios; generate_prism_metrics.py --check and generate_prism_alerts.py --check clean; test_prism_alert_deployment.py --snapshot against the reviewed snapshot: patch applies, 10 gate combinations, 78 original / 67 proposed rules.
  • 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: coordinator review of the landing change (approved, no findings) as the independent lane; then an adversarial read-only review of head 645f535c (no blockers, one minor F1, two notes).
  • F1 (fixed in the second commit): attribution was a snapshot at the build's start, so a wait that recovered from unknown to known while a build was in flight was not counted when that build's deadline fired. deadline_hit now also attributes when a known wait accepted before the build is open at the deadline instant; the reviewer's discriminating test is adopted as a regression test. F2 (saturation and lost ordering stay silent on the counter, by design, exposed by the tracking-unknown gauge) and F3 (a wait closed mid-build still counts, pre-existing) are unchanged.
  • Codex: not run.

🤖 Generated with Claude Code

)

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]>
…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]>
@djh58

djh58 commented Sep 23, 2026

Copy link
Copy Markdown
Member Author

Review ledger (final)

Head: bfb86b68 = 645f535c plus the F1 fix. Stakes: low. Only metric attribution and alert-basis prose change; mining, delivery, fences and paging expressions are unchanged.

Lanes

Lane Status
Coordinator review of 645f535c Run; no findings.
Independent adversarial review (Claude, separate session, read-only) of 645f535c Run: no blockers; 1 minor (F1), 2 notes. The reviewer applied the patch on the base and verified the code, not the claims. It ran the CI-pinned promtool suite (120 scenarios) plus two controls of its own: an old frontend counting in the unknown state still warns and does not page, and a known 400 s stall with a flat counter still pages on age. It also ran both generator checks and the deployment-patch test, and the landing unit tests on the candidate and with the base landing.rs swapped in; the author's two new tests fail on the base, as claimed. For the gated PostgreSQL evidence it cites CI on 645f535c.
Coordinator delta check of bfb86b68 Run; clean. The fix matches the reviewer's proposal, and the reviewer's discriminating test is adopted as a regression test.
Codex adversarial Not run; capacity unavailable.
CI on bfb86b68 At the time of posting: 17 passed, Rust PRISM PostgreSQL and multi-instance contracts (shard 2) still running, 0 failed. A failure on the last check will be reported here.

Findings and dispositions

# Source Finding Disposition
F1 Independent review, minor Build.pending was a snapshot at build start. A wait that recovered from unknown to known while a build was in flight (lost settlement reply, then a proven first confirmation) was not attributed when that build's deadline fired, and its later delivery read published. The base counted it. The effect is bounded to the recovery window plus one initial-job timeout, is warning-class only, and does not affect paging. Fixed in bfb86b68. deadline_hit also attributes when a known wait accepted before the build is open at the deadline instant; unknown-only tracking at both instants still counts nothing. A regression test was added, and the inventory prose and metadata now state both attribution instants.
F2 Independent review, note Once tracking saturates or ordering is lost, later deadlines are no longer counted; the base counted every one until restart, which was the #493 complaint. By design. The state stays exposed: unknown() is unchanged, the pending gauge reads -1 and PrismAcceptedRevisionWorkPending fires. The paging rule already requires a known age (#496), so paging coverage is unchanged. That a saturated frontend stays blind until restart predates this PR.
F3 Independent review, note (pre-existing) A build that starts with a known wait open still counts if another session's delivery closes that wait before the deadline (the start-snapshot rule, pinned by an existing test). Unchanged. The base behaves identically, and F1's fix keeps this conservative side (`self.pending

Verification of bfb86b68: landing unit tests 23/23; the gated landing_metrics suite 35/35 on PostgreSQL 16 with fsync on, with all 17 of its gated ids executed; clippy with all targets and fmt clean; promtool 120 scenarios; both generators clean.

The #494 carry-over threads are assessed on #493; nothing from them is folded into this PR.

@djh58
djh58 merged commit 8fc94fa into 3.x.x Sep 23, 2026
21 checks passed
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