Repository navigation
3.x.x: attribute the current server's stale-job and unknown-job rejections to dense-cadence landings (#480) - #513
Conversation
…tions to dense-cadence landings (#480) The dense-cadence section attributed a rejection to a landing only for `new tip work is pending` or `new payout work is pending`, which the server no longer sends on the submit path. Every #447 dense run at D1/400k therefore attributed none of its 16,461-21,504 stale-job and 1,512-2,997 unknown-job rejections, all `stale job`, and proposed a p99 of 0.0 rejections per landing. A landing now owns, inside its span, stale-job and unknown-job with `stale job` as well as the two older messages. Backend refusals (backend-rpc-unavailable, ledger-confirmation-failed, ledger-outcome-unknown, internal-error), a fee-floor stale-job, pool-closed and harness-bug classes are tallied by reason_id beside the cost, never inside it. A stale-job or unknown-job message the harness does not know, or an unknown reason, is unrecognised: the span's combined window, lost shares and rejected-before-new-revision-work become null with a reason, and the #291 budget is null with its reason rather than a percentile over the rest. Every budget number now carries its own unavailable reason, and a same_edge_as_issue_458 block reports the acceptance -> new-revision-work count and time, the edge qbit_prism_accepted_block_to_revision_work_seconds measures. The README's dense-cadence section names the messages and classes that count. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ognised (#480) stratum.rs refuses a submit with code 20, `too many unknown job submissions` and no reason_id once a session has spent its unknown-job budget. The classifier sent every reason-less message other than `too many connections` to Unknown, so dense-cadence attribution made it Unrecognised, and one such refusal inside a landing's span nulled that span's combined window, lost shares and rejected-before-new-revision-work, and the #291 budget. D1/400k dense runs answer 1,500-3,000 unknown-job submits per run, so the refusal can erase exactly the numbers #480 restores. It is now Expected, and so NotOwned for a landing: a rate limit on job lookups, not retired work. It is matched only on that exact shape (code 20, no reason_id, that message) and tallied beside the cost under the existing `(no reason_id)` marker. The classifier-table and span tests cover it, and the README table and the section's counted_classes text name it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0502610ca3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if let Some(worst) = acceptance_work.iter().copied().max_by(f64::total_cmp) { | ||
| target.acceptance_work_max.push(worst); |
There was a problem hiding this comment.
Use the first frontend delivery for the #458 edge
When a frontend has multiple sessions that receive the new-revision notify at different times, this stores the slowest session in acceptance_work_max and consequently publishes it as same_edge_as_issue_458.acceptance_to_new_revision_work_p99_millis. The server metric ends on the first successful notify write: revision_work_delivered in crates/qbit-prism-server/src/metrics/landing.rs suppresses subsequent deliveries for the same acceptance epoch and revision. Thus the new harness value does not measure the claimed same edge and can overstate it substantially; use the earliest acceptance_work value (the already-computed first_revision_work) for that proposed-budget distribution.
Useful? React with 👍 / 👎.
kiwidream
left a comment
There was a problem hiding this comment.
Review by a delegated agent on behalf of workstream A (head 0502610).
Verdict: request changes. The change is limited to the new same_edge_as_issue_458 block and the README text that describes it. The core #480 fix is correct: the message table matches every stale-job, unknown-job and reason-less code-20 refusal the server can send on the submit path. Spans tile the phase, unattributed is exact, and the null semantics hold everywhere else.
Findings
Medium: the "same edge as #458" number is a different statistic, and the README's offset text is wrong
crates/qbit-prism-load/src/cadence.rs:1057 (also :971, :1457, :1479; crates/qbit-prism-load/README.md:354-364)
-
Statistic.
qbit_prism_accepted_block_to_revision_work_secondsrecords one sample per block per frontend. That sample ends at the earliest successfulmining.notifywrite at revision ≥ target on any session of that frontend:Landing::resolveincrates/qbit-prism-server/src/metrics/landing.rsdoesmin_by_key(at)over the frontend's deliveries. The harness does something different. It collects oneacceptance_workvalue per session, pushes the per-table max intoacceptance_work_max(cadence.rs:1057), and publishes the p99 of those maxima assame_edge_as_issue_458.acceptance_to_new_revision_work_p99_millis. So the harness figure includes the notify fan-out across every session on the frontend, and the server's figure does not. The same block's other number,rejected_before_new_revision_work, already stops at the earliest session (first_revision_workis a min), so the two "same edge" numbers use different end points. The new test pins the max:tests/harness.rs:9253expects2_400.0, which is session 3 at 9.4 s. The server-comparable reading is session 2 at 9.0 s,2_000.0. -
Start offset. The README (
:362-365) and theclock_notesay the server "starts its histogram when the frontend classifies the submitblock reply", so its number "sits inside the harness's by one RPC reply and one notify transit". In factaccepted_blockis called at two points:- On the submitting frontend, at the end of
observe_candidate(coordinator.rs, afterland_offeredreturns). That is afterready_chain_info,ledger.observe_chain_view,getblockhash,getbestblockhashandready_tip. - On every other frontend, from
reconcile, when that frontend discovers the tip itself. The registry help says so: "each frontend samples every block from its own observation".
The server's start therefore trails the node's
submitblockstamp by several RPCs and a ledger round-trip on the submitter, and by tip-discovery latency on the other frontends. It is not one reply transit. The direction is right (the server's interval is shorter than the harness's). The attribution of the gap is wrong, and a reader who reconciles the two p99s would put fan-out and observe latency on "transit". - On the submitting frontend, at the end of
-
Failure scenario. Take a #447-shaped dense run: 400k sessions over several frontends. The harness reports
acceptance_to_new_revision_work_p99_millisas the time until the last session on a frontend got its notify, plus up to one tip-discovery delay per non-submitting frontend. The server histogram reports first-write-per-frontend. A #291 or #458 reader told these are "the same edge" will see a large gap and read it as either a harness or a server defect. -
Fix. Publish the per-table
minofacceptance_work(the earliest session) as the #458-comparable figure. Keep the max beside it, named as fan-out. Rewrite the start-offset sentence to nameobserve_candidate(submitter) andreconcile(other frontends). -
Test that would catch it. In
stale_job_rejections_inside_a_span_are_the_landings_and_outside_are_unattributed, assertsame_edge_as_issue_458.acceptance_to_new_revision_work_p99_millis == 2_000.0, from the earliest session (session 2 at 9.0 s). Today it is2_400.0.
Low: #447's exact shape — landings present, no owned rejection — is untested
crates/qbit-prism-load/src/cadence.rs:1445 (the window_p99 empty reason)
- The README says a
0count from landings whose spans held no owned rejection "is a measured zero". That is the shape that produced #447's0.0. The path only returns a count of0.0with a null window and the "no landing's span held a rejection the landing owns" reason. No test exercises that path. The no-landing test (tests/harness.rs:8712) says "the count was the field that read 0.0 in #447", but the base already reportednullfor the no-landing case. The assertions that fail on the base in that test are the new*_unavailable_reasonkeys, not the null. - Test that would catch a regression. Build a
current_vocabulary_document-style fixture whose spans hold only not-owned rejections. Assertrejections_per_landing_per_frontend_p99 == 0.0,window_p99_millis == null, and that the window reason is present.
Low: shares_found_in_postgres stays a number when shares is null
crates/qbit-prism-load/src/cadence.rs:1327
- When
unrecognised_in_phase > 0,lost_valid_work.sharesisnull, butshares_found_in_postgresis still a number (for example0), computed overshares_recognisedonly. Unrecognised rejections are never checked against PostgreSQL.split_notestill saysshares_found_in_postgres"is checked over"shares. This is not a regression (the base did not check them either), but0next to a nullsharesreads as a clean durability pass over the whole phase. - Fix. Say "checked over shares_recognised". Alternatively, add the unrecognised share IDs to the Postgres check, since the report already holds their
share_id. - Test that would catch it. In
an_unrecognised_message_in_a_span_makes_the_landings_cost_null_with_a_reason, put the unrecognised share's ID incommittedand assert that the report surfaces it.
Low: the acceptance-to-work p99 is nulled by an unrecognised rejection it does not depend on
crates/qbit-prism-load/src/cadence.rs:1457
blockingnulls every number in the budget block, includingacceptance_to_new_revision_work_p99_millis. That figure is a notify timing and does not depend on which rejections a landing owns. A single unexpected message in a run therefore throws away the #458 comparison too. Nulling the cost numbers is right. Nulling the timing is conservative but loses a valid measurement.- Test that would catch it. In the unrecognised-message test, assert that
acceptance_to_new_revision_work_p99_millisis still measured.
Low: README and side-report leftovers
crates/qbit-prism-load/README.md:843still lists "the five count distributions in the dense section". This PR addsstale_job_rejections_per_landingandunknown_job_rejections_per_landing, which also carry"unit": "count", so there are now seven.crates/qbit-prism-load/src/run.rs:2754(outside the diff): the run-wide rejection table'srebuild_pendingflag still usesclassify::is_rebuild_pending, which knows only the two older messages. On the current server, everystale-job/stale jobrow there readsrebuild_pending: false, while the dense section owns the same rejections. Either key it onlanding_cost(..).owned()or rename it to say "older-producer message".crates/qbit-prism-load/README.md:258: "A landing owns the rejections, inside its span, of work it retired". Attribution is by time, not lineage. A share on work retired by landing N-1 but answered after landing N's tip change goes to N. Anunknown-jobmeans the ID left both the live list and the retained graveyard (stratum/retained_jobs.rs: cap and TTL), which any job churn can cause. Suggested wording: "owns the rejections of retired work answered inside its span". No test needed.
Answers to the six questions
-
Message table vs the server: matches. Here is every submit-path refusal:
stale-job/stale job:miner_submit.rs:287(stale_job: ParentGrace/PayoutRevision),:339,:472,:532;tip_observation.rs:763(lease proof);stratum.rs:1541(ResumeExpired).stale-job/job CTV fee is below the current relay floor:miner_submit.rs:318.unknown-job/stale job:stratum.rs:1530.- Reason-less code 20:
too many unknown job submissions(stratum.rs:1516, submit). The authorize path also hastoo many authorization attempts(:1247) andtoo many connections for username(:1301).
new tip work is pendingsurvives only as anensure!anyhow error (tip_observation.rs:627). The resume path maps it tobackend-rpc-unavailable/job resume unavailable(coordinator.rs:2925), and a non-StratumErrorfrom dispatch closes the session without writing a response, so it can never reach the wire. Every submit-path pair maps to the intendedLandingCost.too many authorization attemptswould classify asUnrecognised, but it can only answermining.authorize, not a submit, so no span goes null on it. The README table is consistent withlanding_cost. -
Span attribution. Spans run over the half-open interval
[tip.monotonic, next.tip.monotonic), and the last one runs tophase_ended. They are sorted by the fake node's pool tip stamp on the harness monotonic clock and tested against the client's response-read instant (record.responded). They tile the phase, so a rejection cannot be counted in two spans. A rejection before the first span, or at or afterphase_ended, is unattributed. Tables are perFrontendHealth, one per frontend child (run.rs:1309), so there is no double counting across frontends.unattributed = owned_in_phase − attributedis exact. Thesaturating_subcan never trigger. -
Null semantics. Every null added in the per-landing tables,
lost_valid_workandproposed_budget_for_issue_291has a sibling reason.owned_count_lower_boundcounts only recognised-owned rejections, so it is ≤ the true owned count. Two exceptions are covered above: theshares_found_in_postgreslabelling, and the untested measured-zero path. -
Same edge as #458. The harness start is
TipChange.monotonic, stamped in the fake node'sadvance(), insidesubmitblock, before the reply. The harness end is the client's read of the firstclean_jobsnotify at or after the sampler's bump observation, per session. The server start isaccepted_blockafterobserve_candidate(submitter) orreconcile(other frontends). The server end is the socket write of the earliest delivery at revision ≥ target on the frontend. The README's offsets are wrong on the start side and on the statistic (see the Medium finding). A pre-existing caveat still applies: the end is bounded below by the bump sampler (25 ms interval plus a DB read), so a new-revision notify written before the sampler saw the bump is missed. -
Tests. None of the three compile on the base (
landing_cost,LandingCost,STALE_JOBandUNKNOWN_JOB_BUDGETare new). Reasoning from the base code:stale_job_rejections_inside_a_span…would fail for the stated reason: the base finds 0 rebuild-pending rejections, not 6.an_unrecognised_message…would fail for the stated reason: the base countscombinedas 0, not null.- The no-landing extension's null assertions already held on the base. Only the reason keys and the
strandedsub-case (1 owned, unattributed) are new behaviour. - The
acceptance_to_new_revision_workassertions pin the max statistic (see the Medium finding).
I did not run these tests against the base.
-
Compatibility. All existing keys are kept.
lost_valid_work.sharesand the per-tablelost_valid_sharescan now benull. I found no consumer incrates/,scripts/ordocs/:run.rs::dense_cadence_reportpasses the document through,report.rsdoes not read the section, andvalidate_capacity_evidence(qbit-prism-server/src/capacity.rs,qbit-prism-load/src/artifact.rs) does not readdense_cadence.docs/prism-throughput-measurements.mdmentionsdense_cadenceonly for the phase-start refusal. There is no compatibility finding.
Command log (on minidev-alex1, at the PR head)
cargo build --locked -p qbit-prism-load: passes.cargo clippy --locked -p qbit-prism-load --all-targets -- -D warnings: passes, no warnings.cargo test --locked -p qbit-prism-load: passes.tests/harness.rs130 passed, 0 failed;tests/quorum_replication.rs1 passed; lib, bin and doc 0 tests.python3 scripts/check_gate_env_reads.py: passes ("no direct reads … in 317 Rust files").- Not run: the new tests against the base
6575f595; the gatedtest/prism-native-tests.shsuites (the server is untouched); any live dense run.
…urability checks null (#480 review) The same_edge_as_issue_458 block published the p99 of each landing and frontend's latest session's acceptance -> new-revision-work time. The server's accepted_block_to_revision_work_seconds ends at the earliest delivery on the frontend (Landing::resolve, min_by_key), so the comparable figure is the earliest session's. acceptance_to_new_revision_work_p99_millis now takes the per-table min, and the per-table max is published beside it as acceptance_to_new_revision_work_with_fanout_p99_millis. Both are notify timings, so an unrecognised rejection no longer nulls them; only a run with no landing does. The clock_note and the README name where the server's start really is: the end of observe_candidate on the submitting frontend, and reconcile's tip discovery on the others. lost_valid_work.shares_found_in_postgres is null with a reason when shares is null, and a table's lost_valid_shares_found_in_postgres is null when its lost_valid_shares is. The checks that were made are published apart, including a new lookup of the unrecognised rejections' shares. A test covers #447's exact shape: landings whose spans held no owned rejection report a measured 0 count and a non-null budget, and a null window with its reason. The run-wide rejection table's rebuild_pending flag now uses the dense section's ownership test. The README states that attribution is by time, not lineage, and lists all seven count distributions. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Addressed in
Verified locally: fmt, clippy |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 62e0105af2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // The dense section's ownership test, so this table and its | ||
| // rebuild_pending_rejections_in_phase agree on the current | ||
| // server's `stale job` answers (#480). | ||
| "rebuild_pending": classify::landing_cost(&rejection).owned(), |
There was a problem hiding this comment.
Preserve the rejection report's legacy rebuild flag
For any run containing the current server's stale-job or unknown-job / stale job responses, this now emits rebuild_pending: true, although classify::is_rebuild_pending still defines that run-wide flag as the two explicit legacy pending messages and its test confirms stale job is false. This changes the meaning of the general rejection report outside the dense-cadence attribution section and can make consumers treat retention or unknown-job refusals as explicit rebuild-pending responses; keep is_rebuild_pending here and reserve landing_cost for the dense report.
Useful? React with 👍 / 👎.
Brings in #470, #512, #513, #514 and #515. #515 opens the share append's transaction through AppendConnection::begin, which records BEGIN completion so that a future cancelled before the reply retires the connection instead of returning it to the pool; this branch opens the same transaction with "BEGIN; SET LOCAL plan_cache_mode = force_generic_plan" so the share_id probe is planned once per connection. Resolution keeps both: AppendConnection::begin takes the opening statement and the append passes APPEND_TRANSACTION_BEGIN. SQLx reads every reply of that simple query through its ReadyForQuery before begin returns, so the guard records completion only once the whole batch is in. ledger_cancelled_begin now cancels the append on the custom BEGIN, and a new case holds only the batch's closing ReadyForQuery (the execution proxy gains pause_statement_ready) and proves the connection is still retired. The pool-acquire inventory, the gated-test manifest and the #482 ops notes follow the new call sites. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Refs #480 (workstream A, #261; evidence from #447's dense runs). Harness only:
crates/qbit-prism-loadreporting and its tests. No server change.The defect. The dense-cadence section attributed a rejection to a landing only when its message was
new payout work is pendingornew tip work is pending. The current server sends neither on the submit path:new tip work is pendingsurvives only as an internal issuance error, which a submit that resumes a job answers asbackend-rpc-unavailable. So every #447 dense run at D1/400k reported 0 attributed rejections, anullwindow and a0.0p99 rejections-per-landing while 16k–21kstale-joband 1.5k–3kunknown-jobrejections occurred inside landing spans.What a landing owns now (
classify::landing_cost, README table):stale-jobandunknown-jobwith the server's actual messagestale job, plus the two legacy messages from older producers. Not owned, tallied beside the cost byreason_id: the backend refusals (backend-rpc-unavailable,ledger-confirmation-failed,ledger-outcome-unknown,internal-error), the fee-floorstale-job,pool-closed, the reason-less unknown-job budget refusal, and the harness-bug classes. An unrecognisedstale-job/unknown-jobmessage, or a reason the classifier does not know, makes that span's combined window,lost_valid_sharesandrejected_before_new_revision_worknullwith a reason, and the #291 budgetnullwith the reason (EP-OBSERVABILITY: an unknown is never0.0). The recognised subset is kept asowned_count_lower_bound.Same edge as #458. A span starts at the fake node's
submitblockacceptance stamp and the newacceptance_to_new_revision_work_millisandproposed_budget.same_edge_as_issue_458measure acceptance to the firstclean_jobsnotify, the edge ofqbit_prism_accepted_block_to_revision_work_seconds; the clock offsets are documented.Tests (
tests/harness.rs): syntheticstale-jobrejections inside and outside a span (counts per span, one unattributed, backend and fee-floor tallied not owned, a budget refusal inside a span leaves the cost measured); an unrecognised message yieldsnullwith a reason; a no-landing phase yieldsnull, not0.0, including a phase with strandedstale-jobrejections; the classifier table against the server's messages.Not covered. No live dense run was made against the fixed harness; the first criterion is proven on synthetic input. The harness cannot split
stale-jobby parent vs revision (the wire has no cause; the server metric does). The run-widerejection_reportkeeps its legacyrebuild_pendingflag, outside the dense section.Verification.
cargo fmt --all --check;cargo clippy --locked --workspace --all-targets -- -D warnings;scripts/check_gate_env_reads.py;scripts/check_prism_settings.py;cargo test --locked -p qbit-prism-load(130 harness tests). Written by a delegated worker; reviewed and re-verified by the coordinator.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.