Repository navigation
3.x.x: drive frontends the harness did not launch, through their load balancer, with mergeable per-machine stats (#291) - #662
Conversation
… balancer, with mergeable per-machine stats (#291) #291's failover drill, load-balancer exercise and soak have to load the deployed frontends behind the operator's TCP load balancer, and the harness could only drive frontends it launched itself on a fake node. `qbit-prism-load external --target host:port` drives the harness's own Stratum sessions at any frontend or balancer. The sessions connect, authorize as `<address>.<prefix>-s<i>`, mine real proof of work on the jobs the target sends and reconnect when their connection goes; the open-loop token bucket the phases use places the offers. The mode refuses to send anything without --i-understand-external-target, and never mines a job advertised above --max-difficulty (2^-16 by default), so a mainnet frontend (share difficulty 1,024 and up) would get no share even with the flag. The client mines each job at the difficulty the target advertised for it (DifficultySource::Advertised), as the server binds set_difficulty to the next notify, and searches off the async runtime so a search cannot delay another session's reads. The harness's own sessions keep DifficultySource::Configured and behave exactly as before. Each process writes a qbit.prism.external-load.v1 document whose counts, log-linear latency histograms and per-wall-clock-second timeline add exactly, so the documents of one process per client machine merge with `qbit-prism-load external-merge`: shares/s, accepts and rejects by reason, ACK latency percentiles, reconnects and their outage, time to first job, the advertised difficulty, tip fan-out and the offer accounting. --share-log writes one line per submit, for reconciling the offered, acknowledged, rejected and unanswered ids against the target's ledger. The README documents the frontend settings a target needs for low-difficulty load: the share difficulty, the vardiff floor and maximum, and the connection limits. tests/external_target.rs (database-free) runs the mode against a Stratum target that checks every share against the difficulty it advertised for that share's job. tests/external_frontend.rs (gated) runs two external processes through a round-robin TCP balancer at two in-repo frontends on PostgreSQL 16, one asking for its difficulty with d=, SIGKILLs and relaunches one frontend mid-run, and reconciles the clients' share logs against qbit_share_ledger. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…st, and point the harness's help at them (#291) The tests drove external::run directly, so nothing exercised main.rs's dispatch of `external` and `external-merge` ahead of the harness's own command line and preset expansion. A test now runs the built binary: the guard's refusal is exit 2 with its reason on stderr, two short runs exit 0, and their documents merge through `external-merge`. The harness's --help names both subcommands; no flag is added, so the presets are unchanged. 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: 92ad902006
ℹ️ 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".
…arget count honest at the edges (#291) Codex and /code-review findings on #662. An offer could go to a session that was handshaking or reconnecting, because try_offer checks only the pause and the outstanding count. The session held it until it reconnected: an outage read as dispatched load instead of shortfall, and the held offers went out as a burst on recovery. The collector now keeps a flag per session from its Connected and Disconnected events, and the scheduler offers only to a session that holds work. Once a scan finds no session free, the rest of the tick's offers are shortfall without another scan, so an outage costs one pass a tick rather than one per offer. The drain likewise waits only for sessions that can still be answered. At stop, a session that stopped cleanly had no connection, so the offer it still holds was never sent and is discarded. A session that had to be aborted may have been sending it, so what it held is counted apart, as unknown_at_abort, which has no share-log line. If the stats have not taken in the last event 30 s after the sessions stop, the document is still written, with what arrived and events_cut_off saying so. Before, the whole run failed with no stats. The --out check probed the path itself, which deleted an earlier run's stats before this run had any; it now writes a probe file beside it. A --share-log naming the same file as --out is refused. The SIGINT and SIGTERM handlers are installed before the run starts and fail loudly, instead of in a task that might not have run yet. A session that comes back to a tip is counted on it once, whatever it held in between. The distinct tip count is null with a reason once a process has dropped tips, rather than counting a tip twice across a merge. DifficultySource::Configured carries the harness's difficulty, so SessionConfig has no field an external session leaves unread. The block and off-runtime share searches are one spawn_blocking branch. The tip fan-out percentile uses gate::nearest_rank. New tests: sessions never admitted are never offered work (it fails with the connection check removed), an outage after load is all shortfall, a session back on a tip is counted once, and the output checks leave an earlier run's file alone. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: db94472cbb
ℹ️ 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".
…ut paths through their real directories (#291) Two findings from Codex's second review of #662. The window broke on its first tick at or past its length before minting what was due by then. At --rate 1 --duration-seconds 1 every earlier tick was due 0 offers, so a completed run sent none. Every run lost at least the offer due at the boundary, and a late last tick lost more. The last tick now mints up to the window's length before it stops. A window that ran its length is reported as ending there, so a late tick does not stretch the denominator its offers are rated over. --share-log and --out were compared as absolute paths, and as canonical paths only when both files existed. So 'dir/sub/../x' passed as distinct from 'dir/x' before either existed, and the document replaced the share log. Each is now compared as its file name in its directory's canonical path, which has to exist, as well as through the files when they do. A window at 1/s for 1 s now makes exactly one offer, and at 3/s for 2 s exactly six. The fresh-path alias is refused, and the test fails with the previous comparison. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ce330e9462
ℹ️ 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".
… it reconnects, and follow symlinks when comparing output paths (#291) Two findings from Codex's third review of #662. The scheduler skips a session whose collector flag says it has no connection, but the flag clears only once the collector has taken the session's Disconnected event. An offer placed in that instant was held through the outage and sent with the reconnect: a small burst the outage never offered. No check on a flag can close a check-then-act race, so the session closes it. SessionConfig gains drop_offers_held_while_disconnected: a session with it set drops every offer it took while it had no connection, as a discarded offer, the moment it holds work again. External-target sessions set it. The harness's sessions do not, and send them as before. The output check compared paths through their real directories and through the files, but a dangling symlink has no file to canonicalize. A --share-log symlinked to a --out that did not exist yet passed, the log was created through the link at the document's path, and the document replaced it. Each path's names now include whatever its final symlinks lead to, dangling or not, and any shared name is refused. New tests: a session that takes an offer while disconnected drops it on reconnect and sends nothing, and one without the setting sends it. A share log symlinked to a fresh --out is refused. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 11318bd889
ℹ️ 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 document's partial file (#291) Two findings from Codex's fourth review of #662. The collector wrote share-log lines from the async runtime, so each BufWriter flush was blocking file I/O on a worker. On a slow filesystem that stalls the worker's sessions, and the stall reads as acknowledgement and outage latency, the figures the mode exists to measure. The collector now sends each line to a writer thread, which writes, flushes and reports how many lines it wrote and the first failure. The run waits for that thread off the runtime once the sessions have stopped. The document is written to .<name>.partial and renamed into place. A --share-log at that path, or one symlinked to it, passed the alias check and was overwritten by the document. The partial path and the files its symlinks lead to are now among --out's names. The case is in the output-check test. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0199d2e50f
ℹ️ 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".
…thing to say, and bound the share log's backlog (#291) Two findings from Codex's fifth review of #662. An external session awaited its off-runtime share search, and read nothing from its connection until the search ended. A new job, a new difficulty or the socket ending waited behind it, so the session could send a share on work it had been told was retired, stamp a job's arrival late, and start timing an outage late, by up to a search at the ceiling. The connection's inbound queue now keeps a count of what the reader has queued and the session has not taken. A search off the runtime looks at it every 1,024 nonces and stops as soon as anything is waiting. The interrupted offer keeps its slot and goes back into the session's own work queue, through a weak sender, so it still closes with the handle. The biased select reads the waiting lines first, then mines the offer again on the newest job. Nothing is lost or double counted. The harness's inline search takes no interrupt and is unchanged. The share-log writer thread was fed by an unbounded channel, so a stalled disk let memory grow without limit. The channel now holds 65,536 lines. Past that, a line is dropped and counted in share_log.dropped, and the async collector never waits on the disk. New test: a session whose first job no search of the span is likely to solve, and to which a new easy job arrives mid-search, sends its offer on the new job within seconds. With the interrupt removed it grinds through the span instead and the test fails. The gated runs (external_frontend, load_smoke, faults, ctv_settlement) pass on PostgreSQL 16. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 86fdd8083a
ℹ️ 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".
… and refuse a share log hard-linked to the document (#291) Findings from Codex's sixth review of #662, and a test race CI found. A stop was held behind every search in progress, and a search queued for the blocking pool still ran its whole span after its session had been aborted. Runtime shutdown then waited for all of them, so a busy run could outlive its stats by minutes. SessionShared gains stopping, a run-wide flag kept in its own Arc as the kill fence is. An external search looks at it with the connection's queue, and the runner sets it before it sends Stop. A search stopped for the stop discards its offer instead of putting it back, so nothing spins until the Stop arrives, and a queued search returns before its first hash. The harness never sets it, and its inline search takes no interrupt. The session-event channel is shared with the harness and stays unbounded. Its backlog is now watched. The most events ever waiting is recorded as event_backlog_max, and at 250,000 the run stops itself, as a signal would, with ended saying the stats fell behind. --rate is now at most 100,000 per process. A share costs thousands of hashes, so a faster load needs more client machines. A --share-log that is the document's partial file under another name, a hard link, passed the name comparison. The document's write then truncated the shared inode. Existing names are now also compared by device and inode. a_search_stops_for_a_new_job_and_mines_the_offer_on_it read the session's outstanding count the moment the accepted record arrived. The record goes out just before the slot is released, and on CI's runner the read could land in between, so the test now waits for the slot. The outage test's window is 8 s, so whole seconds after the outage remain inside it on a slow runner. New tests: a stop ends a search at once, rather than after millions of hashes; it fails with the flag check removed. A share log hard-linked to the partial file is refused, and a --rate above the cap is refused. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 310edf48d0
ℹ️ 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".
…istogram extremes that cannot be its samples (#291) Two findings from Codex's seventh review of #662. The last tick mints the offers due by the window's end. A tick the runtime polled late, on a CPU-starved client, sent them at that late instant, and the window was still recorded as ending at its length. The burst then lay outside the window and was rated over a span it did not fit in. A completed window now ends at its length, or where its last offers went out if that was later, so the timeline holds no offer past the window's end and the rate's denominator covers the offers. An on-time window is longer than its length only by the last tick's lateness. external-merge took a histogram whose min exceeded its max as long as its counts added up, and the summary's clamp then panicked. The min and max must now be ordered and fall in the lowest and highest buckets the histogram holds, or the document is refused with the reason. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e7ea814127
ℹ️ 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".
…for the share log's writer (#291) Two findings from Codex's eighth review of #662. The window's end was taken from the tick's start, before the tick's offers were placed. A large catch-up batch could take long enough for its later offers to land past the recorded end. The stamp is now taken after the batch. Once the load was over, the run waited without limit for the share log's writer to write what it held, so a stalled disk could keep the stats from ever being written, signals or not. The wait now lasts at most 60 s, and a second signal ends it at once. Past that, the log is reported unfinished, with the lines it was sent and why, and the document is written regardless. The external path in main keeps its runtime until the process exits: dropping it would wait for any blocking task still running, such as that writer's join. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 895a602ee3
ℹ️ 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".
… again for traffic once a share is found (#291) Two findings from Codex's ninth review of #662. The document went through a fixed .<name>.partial. A directory, an unwritable file or a link already at that name made the final write fail after the whole load, which the entry probe beside --out did not show. The partial file is now named afresh for each write, so nothing already in the directory can be in its way, and the probe's success holds for it. A share log can no longer share the partial's name, so the alias check compares --out's own names only. Its hard-link case is now a link to --out. A search looked at its connection every 1,024 nonces. A share found between two looks was sent even if a new job or the socket's end had arrived in the meantime. The search's result is now checked once more when it returns, and a find with traffic waiting is treated as an interrupted search: the offer is mined again on what arrived. New test: a load with a directory where the old fixed partial name was still writes its document. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6436c01dd7
ℹ️ 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".
From Codex's tenth review of #662: a client_failures entry with more recorded failures than failures underflowed the summary's subtraction, which panics in a debug build and wraps in a release one. Totals::check now holds a document read back for a merge to what every process's totals hold by construction: - dispatched and shortfall add up to the offers minted, overall and per second; - no failure kind records more than it counts; - every tip is first seen no later than last seen, by at least one session. A document that fails is refused with its path and the reason. The summary's two subtractions saturate as well. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2b09a8697b
ℹ️ 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".
…d document's processes and histogram sums (#291) Three findings from Codex's eleventh review of #662. A tick's offers were tallied under the wall-clock second the tick began in. A large catch-up batch could cross into the next second, and the timeline then showed its later offers early. Each offer is now tallied in the second it was placed in. external-merge checked a document's totals, but not that its processes' own counts (accepted, rejected, no-response, offers minted) add up to them. The summary takes rates from the one and counts from the other, so a document edited in only one place merged into figures that contradicted each other. It is now refused, naming the counter. A histogram's sum was taken as given. It must now lie between count x min and count x max, both saturating as the sum does, so a damaged document cannot report a mean outside its own extremes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3d76de4772
ℹ️ 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".
… their own instant, and refuse merges that overflow (#291) Three findings from Codex's twelfth review of #662. Falling 250,000 events behind ended the load as one signal does, and the drain still ran. Sessions reconnecting against a dead target kept adding events throughout it, to the very backlog that had ended the load. Shutdown gains force, a first and a second request at once, and the backlog limit now forces the stop, so the drain is skipped. A completed reconnect was placed in the timeline at the second the stats took it in. Behind a backlog, that could be seconds after the session held work again. Its second now comes from the reconnect's Opened event, which carries the instant itself. Adding documents added their counters unchecked. Two documents, each whole in itself, could pass u64::MAX together, which panics in a debug build and wraps in a release one. Every merge -- totals, tallies, rejections, failures, tips, timeline seconds, histogram buckets and counts -- now adds with checks. A merge that overflows is refused, naming the counter and the document. A histogram's sum still saturates, as recording does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 08d7e7ac53
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a96d08cf78
ℹ️ 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".
…w them, and hold histogram sums to both extremes (#291) Two findings from Codex's sixteenth review of #662. A search queued behind a saturated blocking pool never reached its interrupt check. Meanwhile its session read nothing from its connection, so a job's arrival, an answer, a socket's end and the start of an outage were all stamped when the session got round to them, which could be seconds late in the very CPU-bound failover runs the mode measures. The reader now stamps each line and each closure with the instant it took it off the socket, and Incoming carries it. An external-target session uses that instant for every answer, job, tip, close and outage it records. The harness's sessions keep stamping as they process a line, as their evidence has always been taken, so none of the harness's figures move. A histogram's sum was bounded by count x min and count x max, which a sum leaving no room for one sample at each extreme still passed. The bounds now reserve one sample at min and one at max (a single sample is both, so min must equal max), and an empty histogram's sum must be 0. New test: with the only blocking worker busy for 3 s and an external session's search queued behind it, a close is timed within a second of when it happened. With the reader's instant ignored, it is timed 2.9 s late and the test fails. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 235e91aac5
ℹ️ 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".
…thout walking a window second by second (#291) Two findings from Codex's seventeenth review of #662. The summary's per-second figures expanded the seconds every window covered into a list, one entry each, to count the ones nothing was accepted in. A forged window from the epoch to i64::MAX asked for petabytes. The figures are now computed from the timeline entries that exist, holding nothing per second. A process's window is also held to what a run makes: it ends no earlier than it starts, its seconds are its ends' difference, and it is at most an hour past its length, the most a late last tick could add. The offer accounting narrowed its counts to i64 before subtracting, so counts past i64::MAX went negative. It subtracts in i128 now. Totals::check also requires what the summary accounts for -- submits, offers that failed before a submit, discards, unknowns -- never to outnumber the offers dispatched. Each is one dispatched offer's end. A genuine document, offer failures included, keeps it, and it runs after the identities, so a damaged count is reported as the identity it breaks. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8ac00d1dae
ℹ️ 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".
…roduced (#291) Two findings from Codex's eighteenth review of #662, both a damaged process record in an external-merge input. A window's span was computed in i64 before its ends were checked, so i64::MIN to i64::MAX overflowed. The processes' session counts were summed unchecked. Process::check now holds every merged process to the command line's own bounds: - at most 100,000 sessions, a rate of at most 100,000 a second, a load of at most a week, and a ceiling of at most 2^-14; - a window a run of its length makes, its span taken in i128 and its seconds non-negative. A process held to those carries no value whose sums can overflow, and the summary's session total saturates as a backstop. The bounds are now shared constants with the entry checks. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 14b11b63dd
ℹ️ 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".
… at once, and require a window for any load (#291) Three findings from Codex's nineteenth review of #662. A stop asked for after the load window ran its length still cut the drain short: a signal, or the stats falling behind as the last events came in. The run nonetheless reported completed, exit 0. It now reports interrupted during the drain, with the reason, and exits 6. The minting loop placed a tick's overdue offers one at a time, scanning for a free session for each. A tick hours late, from a suspended process, owed billions and held the process with no way to stop it. Once a scan finds no free session, every offer still due that tick is now counted as shortfall in one step, so a tick costs at most one pass over the sessions however late it comes. A merged process with load counts but no window, or one of no length, dropped out of the rates while its shares stayed in the totals. Process::check now requires a window of positive length wherever there is load to rate. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8100cdcf0a
ℹ️ 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".
… a process's offers by its rate and length (#291) Three findings from Codex's twentieth review of #662. The scheduler's ticker replayed every missed millisecond tick after a stall: about 3.6 million immediate iterations after an hour's pause. The first of them had already caught the offers up, since the offers due come from the clock and not from a count of ticks. Missed ticks are now skipped. A histogram's sum was held only to its extremes. A damaged one whose middle buckets needed far more passed, and reported a mean far below its median. The sum must now fall between what its samples could add up to in their buckets, each in its bucket's bounds, one exactly min in the lowest and one exactly max in the highest. The bounds are taken in u128, admitting a sum saturated at u64::MAX. A merged process could declare more offers minted than its token bucket makes, floor(rate x length). Process::check now refuses that, with one offer of slack for the floating point it is computed in. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 50d01e948c
ℹ️ 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".
…ing counts to what makes them (#291) From Codex's twenty-first review of #662: a stored connections_opened could disagree with the initial connections and completed reconnects it was made of, and nothing checked the three against each other. It is no longer stored. The summary derives it from the two. The other counts nothing tied together are now held to their sources as well, so a damaged document is refused rather than summarized inconsistently: - offers above the difficulty ceiling are among the offer failures; - clean jobs are among the notifies; - the advertised difficulty's extremes are present exactly when there were advertisements, ordered and positive; - a timeline second's sessions holding work are present exactly when a process sampled them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 183468a622
ℹ️ 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".
…indow's first whole second, and bound initial connections by sessions (#291) Three findings from Codex's twenty-second review of #662. Progress lines and the holding-work samples advanced their deadlines by one interval at a time. A process resumed after a long suspension therefore printed a line, and took a sample, on every tick until it had replayed every interval it slept through. Both now set the next deadline from now. The per-wall-second figures skipped the window's first second even when the window began exactly on it, so a 1,000-5,000 ms window counted three whole seconds instead of four. The first whole second is now taken with a ceiling. A merged document could declare more initial connections than its processes hold sessions, and each session's first connection is one. That is now refused. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a9aee34011
ℹ️ 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".
… its configured length (#291) From Codex's twenty-third review of #662. The bound on a process's minted offers used its configured duration. The token bucket stops minting when a stop cuts the window short, so a damaged process configured for a week could claim a one-second window and a week's offers, and the summary rated them over the second. The bound now uses the shorter of the window and the configured length, and is checked once the window itself has been held to what a run makes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 29448ae15b
ℹ️ 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".
A merged document's aggregate checks hold when shares are moved from one process record to another, so a process could report more answers than it was offered. Each submit is one of the process's own dispatched offers, so require its accepted, rejected and unanswered shares to add up to no more than its offers minted. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b1b72bf087
ℹ️ 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".
…out (#291) Shard 0 of run 37383055194 failed only qbit-prism-server's live_regtest real_two_server_mining_failover_audit_and_reorg, whose regtest node never answered RPC before either server started. This PR changes only qbit-prism-load, which nothing else depends on. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5236baae74
ℹ️ 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".
…a window's ends to a clock's readings (#291) A process suspended past its load window's end closes the window when it resumes, so its window can run any length past the configured one. external-merge refused a window over an hour longer than the run's length, which rejected the harness's own output after a long VM pause or SIGSTOP. Drop that cap. A window's ends must instead be readings a clock gives, between the epoch and 9999-12-31T23:59:59.999Z, and its seconds their difference. The summary takes differences of the ends, so they still fit, and the offers a window mints are still bounded by the configured length. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 75cbeacc2a
ℹ️ 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".
…ue offers are shortfall, not a burst (#291) After a late tick (a process suspended and resumed, say), the token bucket owes every offer of the time it missed. A tick placed offers until a full pass found no session free. Sessions on other workers answer and free up while that loop runs, so against a quick target it could keep placing the overdue offers as fast as they were answered: a burst the open-loop bucket never meant, sent while the loop held off the shutdown check. A tick now spends one pass over the sessions in total. Each session is offered at most once a tick, and whatever is still due once the pass is spent is shortfall. The README and the document's definitions say so; a process's ceiling is 1,000 offers a second per session. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 915849545f
ℹ️ 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".
…e remains (#291) An external session's search stops once its connection has something waiting, so a share is not sent on work a job already waiting has retired. The README said it never sends a share on work it has been told is retired. But a job can arrive between the search's last look and the submit's write, and a share then goes out on the old job: the race every share in flight runs with the server's next job, which the network widens to a round trip anyway. Say so, in the README and at the search. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 503210b22f
ℹ️ 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".
Refs #291.
Problem
#291's failover drill, load-balancer exercise and soak have to load the deployed frontends, which sit behind the operator's TCP load balancer.
qbit-prism-loadcould only drive frontends it launched itself on a fake node, so there was no way to put the harness's measured load on a real deployment.Change
qbit-prism-load externaldrives the harness's own Stratum sessions at any frontend or balancer, andqbit-prism-load external-mergeadds several machines' results together. Both are read before the harness's command line and preset expansion, so no harness flag or preset changes.The same client, not a second load generator (3.x.x: Close native E2E gaps in multi-recipient payouts, async failover and lost node replies #474).
client::spawn_sessionconnects, subscribes, authorizes as<address>.<prefix>-s<i>, mines real proof of work on the jobs the target sends and reconnects when its connection goes. The open-loop token bucket the phases use places the offers:--rateper process, round-robin, one submit outstanding per session;An offer that reaches a session in the instant its connection goes is dropped when it reconnects (
SessionConfig::drop_offers_held_while_disconnected).It mines what the target advertises. New
client::DifficultySource::Advertised { ceiling }: each job is mined at the difficulty of the lastmining.set_difficultybefore itsmining.notify, as the server binds them.--difficultyasks for one withd=. The search runs onspawn_blocking, so a slow search cannot delay another session's reads and inflate its ACK latency. The harness's sessions useConfigured, which behaves exactly as before.Mainnet guard. Nothing is resolved or connected without
--i-understand-external-target. The refusal says why: real shares, credited to--address. A second guard: a job advertised above--max-difficultyis never mined. The default is 2^-16 and the most allowed is 2^-14. Each such offer is counted and nothing is sent. A mainnet frontend's share difficulty is at least 1,024 (tests/fixtures/mainnet-compose.env), so on mainnet nothing would be sent even with the flag.Stats. It collects the stats the harness reports today: shares/s, accepts and rejects by
(code, reason_id, message)and class, ACK latency percentiles (p50/p90/p99/p99.9/max), reconnects with their outage, time to first job, the advertised difficulty, tip fan-out and the offer accounting. Each process writes aqbit.prism.external-load.v1document. Its counts, log-linear latency histograms (0.2% buckets) and per-wall-clock-second timeline add exactly, so a merge loses nothing. The rates add per process, and a document given twice is refused. So is a document no run could have written, one damaged or edited after its run. Examples:The collector folds events as they arrive, so an hours-long run holds counts, not records. If it falls 250,000 events behind the sessions, the run stops (exit 6) rather than grow without bound.
Reconciliation input.
--share-logwrites one JSON line per submit: the ledger'sshare_id, the outcome, times and the rejection or no-response reason. The drill can check offered, ACKed, rejected and unknown ids against the promoted primary.Exit codes. 0 ran its window, 2 error or refusal, 3 no session held work within
--work-timeout-seconds, 6 SIGINT/SIGTERM or stats that fell behind. Exits 3 and 6 still write the stats; a second signal skips the drain, and a stop ends any search in progress at once.Searches yield to the connection. An external session's search runs off the runtime and stops as soon as its connection has something waiting: a new job, a new difficulty or the socket ending. So a share is not sent on work a job already waiting has retired, and an outage is timed when it happened, not after the search. A job arriving between the search's last look and the write still meets a share on the old one: the race any share in flight runs. An offer a new job interrupts is mined again on the new job by the same session; one a stop interrupts is counted as discarded.
README, External-target mode. Covers the guard, the run, the document, merging, reconciliation and exit codes. It also lists the frontend settings a target needs for low-difficulty load:
PRISM_STRATUM_SHARE_DIFF.PRISM_STRATUM_VARDIFF_MIN_DIFF, which also floorsd=with vardiff on or off.PRISM_STRATUM_VARDIFF=0, orPRISM_STRATUM_VARDIFF_MAX_DIFFat or below the clients' ceiling. A fixed-rate load outruns vardiff's 15 s target, so it would otherwise climb to the maximum.For the downstream loadgen client: the CLI is
--target,--i-understand-external-target,--address,--sessions,--rateand--duration-seconds, plus--outand optionally--share-log. Every other flag has a default.Tests
TMPDIRwas on a local disk. PostgreSQL 16.10 was built from source, because this host's packaged PostgreSQL is 18 and the server's migration-history check refuses PostgreSQL 18 catalogs. That refusal is pre-existing and unrelated to this PR.cargo test -p qbit-prism-load --test external_target: 20 passed, database-free. The target is a test Stratum server that checks every share's proof of work against the difficulty it advertised for that share's job, so a client mining at any other difficulty is refusedlow-difficulty. Covered:--outis refused (detour, dangling symlink, the partial file);PRISM_TEST_PG_BIN_DIR=<pg16> cargo test -p qbit-prism-load --test external_frontend: passed (27 s), a new gated test registered intest/prism-gated-tests.txtandtest/e2e-scenarios.toml.d=.b1b72bf0, run twice on this shared host (load average 9 on 16 cores). Each process was offered 400 shares, with 0 rejected, 0 unanswered and 0 unaccounted. Each mined exactly the advertised difficulty.qbit_share_ledger, and every committed id is acknowledged or unanswered.load_smoke,ctv_settlementandfaultspassed.load_smoke's tip and churn gates failed twice locally while this shared host's load average was 10–21, and passed when it was calmer.b8aeb291, the tip-delivery p99 was 1.6 s and 1.7 s on this branch, and 1.7 s and 4.6 s on base. That is load, not this change.load_smokeon its own runner, and it passed there.cargo test -p qbit-prism-load: 255 passed, includingharness(150),realism(21) and a unit test that a tick offers each session once however fast sessions free up. 254 of them (all but that later unit test) pass, with clippy, fmt andscripts/check_e2e_scenarios.pyclean, on a trial merge of this branch with the current3.x.x(0f132bf1). No other crate depends onqbit-prism-load. The realism suite holds every preset to the harness's flag list, which is unchanged.cargo clippy --workspace --all-targets -- -D warnings,cargo fmt --checkandscripts/check_e2e_scenarios.pyare clean.Not run here and why
Remaining risks
2^32 x dhashes. The target has to be configured as the README says, andprocesses[].client_cpu_secondsandoffers.shortfallshow when a client machine, not the target, was the limit.external-mergeto hold a damaged input to: reconnects within disconnects.Merge notes
qbit-prism-loadchanges, plus the gated-test list and the scenario manifest.SessionConfig::share_difficultyis replaced bydifficulty: DifficultySource; the harness passesConfigured(<its difficulty>).SessionConfigalso gainsdrop_offers_held_while_disconnected, which isfalsefor the harness.JobStategainsshare_difficulty.EventgainsDifficultyAdvertised, which the harness's collector ignores and aConfiguredsession never sends.SessionSharedgainsstopping, which the harness never sets.Advertisedsession's search is off the runtime and interruptible. AConfiguredsession searches inline, as before.🤖 Generated with Claude Code