Repository navigation
doc(#9572): C4 quota forecasting design — prediction record, scoring, methodology log - #13268
Conversation
…coring rules, methodology-change log Acceptance item 1 of #9572. Grounds the design in the landed Stage-3 forecast product (S1 #12695, S2 #12696) and specifies what it does not cover: downtime windows, reset-duration ranges, day-type/spike adjustments (data-gated), model/plan arrivals, forecast push alerts. Live-loop remainder filed as #13257, #13258, #13259, #13260, #13261, #13262.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 59 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review Summary: ✅ CompletedThis 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: a5785f3bbf
ℹ️ 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".
| ```jsonc | ||
| { | ||
| "record_version": 1, | ||
| "id": "c4:<kind>:<subject-key>:<issued-at-epoch-ms>", |
There was a problem hiding this comment.
Include the basis in prediction record IDs
When §2 publishes parallel since_last_reset and trailing_30d forecasts for the same pool/window on one gatherer tick, both records receive the same ID under this format. That makes ID-based supersession and attribution of scores to individual predictions ambiguous, undermining the stated head-to-head comparison of bases. Include the basis and any concurrently published model variant in the record identity, or use a unique ID independent of the subject and issuance timestamp.
Useful? React with 👍 / 👎.
| `postIncident` precedent, source `quota-prediction`, deduped on | ||
| the prediction record id, thresholded per S3.15's selectivity |
There was a problem hiding this comment.
Deduplicate forecast alerts by the predicted event
For a downtime or workhorse-wall forecast that persists across gatherer ticks, deduplicating on the prediction record ID creates a fresh alert each tick: §1 makes that ID issuance-time-specific, while AlertsStore.postIncident in pm-stack/aggregator/src/alerts.ts suppresses duplicates only for matching (source, incident_key). The selectivity threshold limits which forecast kinds alert, but does not suppress repeated alerts for the same impending outage. Use a stable event/episode key for alert deduplication and retain the prediction ID as supporting detail.
Useful? React with 👍 / 👎.
) Publish downtime_window prediction records on gatherer ticks, in the C4 design's record format (doc/2026-11-13T15-12-00Z_design_ reporting-architecture-event-driven/c4-forecasting-design.md §1/§7, landed by PR #13268): appended to quota-predictions.jsonl beside the forecast product and mirrored into the Turso ledger under the C4 source "quota-prediction". src/quota-downtime.ts derives each record from the tick's Stage-3 forecast product (#12695): per-pool wall intervals [wall, reset) intersected across every routing pool (canonical provider id); earliest = the last member wall, latest = the earliest member reset; basis since_last_reset, named with its detail; the §4 range rendering stored at issuance; supersedes linked from the log's tail. Honesty per §1 and #13257 criterion 3: providers the forecast cannot project publish insufficient_history with a named reason (and veto a no-window verdict); an overlap no member reset bounds is an honesty state, not an unbounded prediction; a defensible no-window tick publishes no record — absence is the scored no-prediction signal. First methodology entry c4-meth:1 recorded in c4-methodology-log.jsonl (§6). Acceptance: criteria 1 (records published on gatherer ticks) and 3 (honesty state) of #13257. Criterion 2 (scoring per §3 in the accuracy ledger) is the next slice; the mirrored records are its input. Tests: src/quota-downtime.test.ts (15 tests: record shape, intersection range, in-progress windows, union within a provider, disjoint overlaps, honesty states, supersedes, §4 rendering, ledger mirror), mutation-checked; the gather-quota integration test now also asserts the tick appends the downtime record. Oracle: the C4 design §1/§7 over the #12695 forecast product.
New pure module pm-stack/aggregator/src/quota-reset-duration.ts implementing the builder slice of the C4.2 reset-duration kind, per the C4 design (PR #13268, sections 1/4/7) and the prepared scope recorded on the issue by Lane WC. - ResetDurationRecord in the design's section-1 shape: kind reset_duration, subject pool+window, singular basis reset_cadence, methodology c4-meth:1, supersedes link. - Reopening range: anchored on the published resetsAt when one exists, ranged by the reset jitter observed over completed reset periods (realized resets estimated at the midpoint of the bracketing readings); with no published reset, projected one observed cadence interval past the last published reset. - earliest == latest refused: a degenerate spread widens to the observation resolution (half the median reading gap). - Honesty states with named reasons: no_basis (no snapshot history) and insufficient_history (no completed period, or the ranged reopening already in the past — stale inputs). - Rendered strings from the one shared section-4 formatter (renderPredictionRange in quota-downtime.ts), stored at issuance; ledger mirror rows under source quota-prediction. Tests: quota-reset-duration.test.ts, 13 tests — jitter-spread range construction from synthetic snapshot history, degenerate spread widening, subject selection (walled + near-wall only), both honesty states, stale-input guards, cadence projection, the section-4 duration and calendar rendering forms, and the ledger mirror.
Refs #9572 (acceptance item 1 of 3; the issue stays open for items 2–3, filed as C4.1–C4.6 below).
What this is
The C4 component design, landed in the #9568 program folder beside the C7 design (
c7-rollups-design.md):c4-forecasting-design.md.Done check behind it (verified against origin/main 1edebd5)
The Stage-3 line already covers ONE C4 kind — per-pool exhaustion as a point projection, published per tick (S1 #12695 / PR #12724) and scored (S2 #12696: accuracy ledger + backtest, 5,028 forecasts). The design grounds itself in that product instead of restating it, and specifies what it does not cover:
basis(S2.14), range as a first-class value calibrated by the S2 error ledger, storedrenderedstring (S2.13 formats), methodology version, honesty states;Gate check: #9572 is NOT gated on the C3 chain (#9571 / PR #12226) — its substrate (gatherer, snapshot store, Stage-3 forecast product, alerts ledger) is live; the design records this explicitly.
Remainder, filed under #9572
Docs only; no code, no new dependencies, no schedule created or changed.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.