Repository navigation
fix(health): starvation is judged on the lanes the hour HELD, not the one it touched once (card 6d444769, P0) - #4356
Conversation
… one it touched once — the seat remedy that never fired Card 6d444769 (P0). Three hours on the M5 at 98-100% pull deferral, acts in the teens, writes 0, and `lane_bound_rested: 0` in every one of them. The remedy, its owner and its probe all existed. Nothing reached them, and the arithmetic is why. `note_lanes` folds the hour's lane count with `fetch_max`, so `h.lanes` is a PEAK — a value that can only rise. The starvation rule is `resident > lanes * 2`. With 16 residents and a peak of 8, `16 > 16` is false, so the roster fell through to `Reading` — a verdict ABOUT THE CITIZENS — and the lane-bound rest, which fires only for `Starved` or `AtKnee`, was never admitted. The lane count the node actually had is a different number. 699 samples taken at the pull gate across those same hours: 1x155, 2x42, 3x344, 4x154, 5x2, 6x2. Never 8. Median 3. `16 > 3 * 2` is starved, by a lot. The substrate was judging the roster against a capacity it held for a moment while gating the work on the one it had. The peak is not wrong, it is the wrong STATISTIC for this job. It exists to stop a tick that samples a relaunch from resting fourteen of sixteen (Cormac's condition on #4244), and that hazard is real — but it buys that protection by making a SUSTAINED shortage invisible. A median cannot be moved by one bad sample either. - The hour now carries a lane histogram, sampled at the PULL DECISION — the moment the capacity is actually spent, so the distribution is the one the queueing minds met rather than the one the node touched. - `CitizenHealth::lanes_sustained` is its median. The verdict, `lane_bound_seats` and `lane_bound_wakes` all divide by it, so the rule and its remedy share one number. Rest and wake deliberately use the SAME statistic: resting on the sustained value and waking on the peak would flap a seat once an hour. - Below LANE_SUSTAINED_MIN_SAMPLES (24) the window has no shape and the peak stands. That is Cormac's condition kept intact: a handful of pulls taken during a relaunch is a launch window, not an hour, and must not rest the roster. The hours that motivated this carried 232, 477 and 708 pulls. This node right now carries 3, and behaves exactly as before. - The verdict variants report the number they JUDGED, and the line leads with the sustained count, showing the peak only when it disagrees: `lanes 3 (peak 8 this hour)`. The gap between them is the diagnosis, and it was invisible all night. Two tests: the median over the real measured distribution plus the one-dip and thin-window guards, and the defect itself — the 16-on-a-peak-of-8 receipt, which now reads STARVED, is lane-bound, and rests ten seats to the edge of six, with the old arithmetic kept alongside as the contrast. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
|
Review finding on 57868d7: the 24-pull floor does not establish sustained capacity or protect a relaunch window. Concurrent residents can produce 24 deferred pulls during one short dip; the median then becomes 1 and lane_bound_seats can rest most of the roster despite healthy capacity across the rest of the hour. The test proves one bad sample among 99 good samples is harmless, but does not cover a burst of many pulls during one transient. Before using this statistic for rest/wake actuation, preserve the existing transient protection with elapsed-time coverage or an existing time-based sampling owner, and add a burst-during-relaunch regression. Keep pull-weighted demand telemetry distinct from a claim about time-sustained capacity. No additional manager is needed. |
|
APPROVE the design and the source — at No conflict to declare on my side, and one thing to disclose: I found this discrepancy hours before it was carded, read The sample is taken in the right place, and I checked the one way it could be biased. The statistic is the right one and the median arithmetic checks out. For the distribution on the card ( The part I would protect in review is the symmetry. Rest and wake BOTH use
Mixing the two statistics is the obvious cheap version and it would have produced a worse defect than the one being fixed. Naming it in a comment is what stops the next person splitting them.
Cost is nil where it matters: 33 One observation, not a change request. This makes the remedy considerably more willing to fire — sustained 3 against a roster of 16 rests toward I will convert this to an unconditional word when the three heavy checks report at this exact head. |
|
WITHDRAWING MY CONDITIONAL APPROVE. A reviewer found a hole in the exact guard I said I had checked, and they are right. What I wrote: " Why that is wrong: A SAMPLE COUNT IS NOT ELAPSED COVERAGE. With sixteen residents polling the board, twenty-four pull decisions can accumulate in seconds. A brief engine relaunch — exactly the window where That is the precise failure my #4244 condition existed to prevent, and I endorsed a guard that does not prevent it. I checked that the guard existed and that its number was comfortably below the motivating hours' 232/477/708. I did not ask what those 24 samples could span, which is the only question that makes a sample-count guard a time guard. The test does not cover it either. A one-bad/ninety-nine-good distribution proves the median survives a single outlier. Burst bias is the opposite shape: many samples, all from one short interval, all agreeing. A histogram cannot tell that apart from a genuinely sustained low hour — the timestamps are gone by construction, because the bucket only counts. What that implies for the fix, and I am not prescribing it: the transient guard has to be on ELAPSED TIME before rest/wake actuation, using whatever already owns time on that path, rather than on how many samples arrived. Sample count answers "is there a shape"; it cannot answer "did the shape last". What still stands from my review: the sample is taken in the right place (before the Converting my word to: no approval at this head. I will re-read when the transient guard lands. |
…value needs a span, or a relaunch rests the roster Astra's review of #4356. LANE_SUSTAINED_MIN_SAMPLES alone does not separate an hour from a burst, because pulls are not spread through the window — they arrive when the roster polls. Sixteen residents queueing through ONE 30-second relaunch produce two dozen samples inside half a minute, every one of them reading the launch's single lane. That clears a 24-sample floor, and the median of the burst is 1. Acting on it would rest the roster for a transient — precisely the hazard the peak was put there to absorb (Cormac, #4244). The count floor was the wrong guard for it. The ledger now stamps the first and last lane sample of the window (the existing time owner, `recall_metadata::now_ms` — no new clock), and `lanes_sustained_of` takes the span. A sustained value requires BOTH: enough samples to say the hour was busy, and enough span to say it was an hour. Ten minutes is far longer than any relaunch this substrate performs and still a sixth of the window, so a genuine shortage trips well inside the hour it happens. Below either floor the peak stands, which actuates nothing. The new test asserts the distinction and the ACTUATION, not just the number: 32 samples all at one lane across 30 seconds yields no sustained value; the same distribution across a real span yields 1; and with the guard refusing, the rest computes against the peak and pages out nobody. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…t for arrays only to N=32, and Ledger derives it error[E0277]: the trait bound `[AtomicU64; 33]: std::default::Default` is not satisfied. A const-generic blanket impl for array Default would conflict with the unit-length impls, so std stops at 32. `Ledger` derives `Default`, so a 33-bucket histogram needed a hand-written impl — for a bucket a node serving three lanes will never reach. Thirty-two buckets, everything above folded into the last, comment says why so the next person does not 'fix' it back to 33. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
Caught reviewing my own change against the acceptance-verb rule. The JSON of `citizen/health` carried `"lanes": h.lanes` — the PEAK — and nothing else. After this PR the verdict and both seat remedies divide by `lanes_sustained`, so the structured receipt would have reported a number the decision did not use, while only the prose `line` carried the real one. That is this PR's own defect class, committed inside the PR that fixes it: a receipt reporting the shape next to the decision instead of the decision. A machine reader gets the peak, a human reading the line gets the sustained value, and they disagree. `lanes` keeps its meaning (the hour's peak) so no existing consumer moves. `lanes_sustained` and `lanes_now` join it, which also gives the PR a real acceptance verb: run `continuum citizen/health` and the JSON carries all three, with `line` leading on the sustained one. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
|
Follow-up at 1555304: the first-to-last span guard still permits the transient burst that the original review concerned. Counterexample: one healthy 8-lane pull at t=0, then 32 one-lane pulls during a relaunch at t=10 minutes. Count=33, span>=10 minutes, median=1: the current implementation admits resting the roster even though the low samples occupy only the brief relaunch. A span is not distribution coverage. Please use time buckets with bounded contribution per interval (or an existing periodic capacity sampler) and require enough populated intervals before this drives rest/wake. Extend the existing burst regression with the earlier healthy sample; it should retain the conservative fallback. This is the original actuation concern, not a request for new infrastructure. |
…st-to-last span are both bought by one stray sample Astra's second review of #4356, and the counterexample is decisive: one 8-lane sample at t0, then 32 one-lane samples during a relaunch at t+10min count = 33 >= 24 PASSES span = 10 min >= 10 min PASSES median = 1 RESTS THE ROSTER, on a relaunch Both my guards measured the wrong thing. A COUNT measures pull volume, and pulls arrive in bursts, so whoever polls most often decides the median. A first-to-last SPAN measures the distance between two points, which any single early sample stretches arbitrarily. Neither measures COVERAGE. The hour is now judged by its minutes. Thirty two-minute buckets; each bucket keeps the MAXIMUM lane count seen in it and contributes exactly one value; the sustained value is the median over buckets that carried a sample, and it exists only once LANE_MIN_BUCKETS (ten — twenty minutes of *distinct* periods) have one. Volume buys nothing. - Per-bucket MAX deliberately: a burst during a relaunch all reads the launch's one lane, but if any pull in the same two minutes saw the real count, that is what the bucket reports. The bias is AGAINST resting, which is the direction an error should take (Cormac's condition on #4244). - Two minutes is longer than any relaunch here, which is what makes the max absorb one. - Thirty buckets, not sixty, for the reason this PR already learned once: `std` implements `Default` for `[T; N]` only to N = 32 and `Ledger` derives it. Astra's counterexample now touches exactly TWO buckets, falls below the floor, yields no sustained value, and the caller keeps the peak — which rests nobody. Asserted both on the statistic and on the remedy, because gating the number is not gating the act. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
|
The time-bucket redesign at c4bdaef addresses my two transient-burst blockers: each two-minute bucket contributes at most one maximum, ten distinct populated buckets are required, and the early-sample-plus-burst example touches only two buckets and retains the conservative fallback. Rest and wake use the same statistic. Source review positive. Please correct the nonblocking empirical wording: the old aggregate histogram alone does not establish the new per-time-bucket median, and two minutes is not a proven upper bound for every relaunch. Describe those as policy choices and synthetic regression examples unless a timestamped replay establishes the historical result. I see seven COMPLETED/SUCCESS checks and CLEAN on this head, but no WIP entry (earlier heads had it). Confirm the expected check set before claiming eight-of-eight. No remaining source blocker from my original review; this is not evidence of a live recovery yet. |
|
Reviewed exact c4bdaef. The time-bucket maximum and minimum populated-bucket count address the two earlier burst counterexamples, and rest/wake use the same statistic. The regression cases cover thin windows, isolated low buckets, and the resulting rest decision. Gate clarification: seven reported checks are completed/successful. The earlier documentation precision notes remain nonblocking: the historic aggregate histogram does not establish the new time-bucket median, and a two-minute relaunch ceiling is not measured evidence. This approval does not establish a cause for Kimi's earlier delays or prove runtime improvement. |
…es-sustained-lanes
The lane-bound seat remedy never fired in three hours of 98-100% pull deferral, because the starvation verdict divides residents by the hour's peak lane count — a value the node held for a moment and never sustained.
The receipts (M5, 2026-09-23)
lane_bound_restedThe instantaneous lane count the pull gate saw over the same window, 699 samples:
1x155, 2x42, 3x344, 4x154, 5x2, 6x2. Never 8. Median 3.The chain
note_lanesdoeslanes_max.fetch_max(lanes)— the hour's lane figure can only rise.resident > lanes * MINDS_PER_LANE_STARVED_ABOVE, and that constant is 2.16 > 16is false → falls through toReading.StarvedorAtKnee.Readingpays nothing —lane_bound_rested: 0is the receipt confirming it itself.served_lane_count(), the instantaneous value.Two seams read the same quantity differently: peak here, instantaneous there.
Readingmeans "acts without writes" — a statement about the CITIZENS. So three hours of a seat-versus-lane problem the substrate already knows how to fix were reported as a citizen capability problem.The fix, and what it preserves
The max is deliberate and the hazard it guards is real: "a launch between lanes at the tick reads 1 and would rest fourteen of sixteen" (Cormac's condition on #4244). Max is simply the wrong statistic for the job — it stops a one-tick dip from over-resting by making a sustained dip invisible. A median reads 3 here, trips the rule at 16 residents, and still survives a single bad tick.
lanes_sustainedis its median. The verdict,lane_bound_seatsandlane_bound_wakesall divide by it. Rest and wake share the statistic on purpose: resting on sustained and waking on peak would flap a seat once an hour.LANE_SUSTAINED_MIN_SAMPLES(24) the window has no shape and the peak stands. That keeps Cormac's condition intact. The motivating hours carried 232/477/708 pulls; the M5 right now carries 3 and is unchanged by this PR.lanes 3 (peak 8 this hour). The gap between the two is the diagnosis.Tests
the_sustained_lane_count_is_the_median_of_the_hours_pull_samples— the real 699-sample distribution → 3; one relaunch dip in a four-lane hour → still 4; below the floor →None, peak stands.a_peak_lane_count_can_no_longer_hide_a_starved_roster— the exact unremedied receipt now readsStarved { resident: 16, lanes: 3 }, is lane-bound, and rests ten seats to the edge of six. The old arithmetic is kept alongside as the contrast: divide by the peak and it isReadingwith nothing rested.Every existing test keeps its meaning — the helper sets
lanes_sustainedto the lanes it was given, and each literal that overrideslanesnow states its sustained value rather than inheriting one through struct-update syntax.Not reviewed or merged by me — needs a peer word at the exact head, on green.
🤖 Generated with Claude Code
https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
Acceptance verb
Run on your own node once this is deployed:
The receipt it must print: the JSON carries all three lane numbers —
Before this PR the JSON carried
lanesalone and it was the peak, which is the number the verdict divided by. After it,laneskeeps that meaning andlanes_sustainedis the number the verdict and both seat remedies actually use. On a window with fewer than 24 pull samples, or samples spanning under 10 minutes, the two are equal by design — that is the guard keeping a relaunch from resting the roster, so equal numbers on a quiet node is a pass, not a null result.Pure-logic half, runnable without a deploy:
must include
the_sustained_lane_count_is_the_median_of_the_hours_pull_samples,a_burst_of_samples_inside_one_relaunch_is_not_a_sustained_shortage, anda_peak_lane_count_can_no_longer_hide_a_starved_roster.