GeezerVison is showing github.com — impl(quota-plane): stage-3 S3 — shadow placement: forecast ordering logged beside live ordering (#12697) by dezren39 · Pull Request #12748 · developing-today/code
Conversation
dezren39
commented
Nov 23, 2026
•
edited by blacksmith-sh
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Stage-3 S3 implementation for #12697 (epic #12694, design D3 in doc/2026-11-22T22-35-00Z_design_quota-plane-stage-3). Deliberately does not close #12697: its first acceptance criterion is one week of accumulated shadow diff records, which is calendar time after this lands and the laptop aggregator redeploys; the issue stays open for that, with the summary to be posted on #12694.
What lands
pm-stack/aggregator/src/quota-shadow-placement.ts — a pure per-tick projection (S1/pool-state idiom: no I/O, clock only through arguments) emitting the per-decision diff record:
- Live ordering — burn-by-expiry from the measured data (quota-current) alone: tiers open → unknown → caution (≥85%,
NEAR_PCT) → walled, soonest reset first within a tier. Unknown is not closed: an unreadable pool stays in the ordering, it just has no measured expiry to burn by.
- Shadow ordering — the same ordering with one adjustment: an open-tier pool whose consumed forecast projects a wall before its reset is demoted into the caution tier — before it reaches the caution zone. That is the whole forecast effect.
- The record (
quota-shadow-placement.json latest + one appended line per tick in quota-shadow-placement-history.jsonl): both orderings, the decision point (gatherer tick + the current/forecast products' generatedAt stamps), and per pool the measured inputs, every forecast window row with its honesty state and whether it was consumed or excluded (and why), both ranks, and movement reasons — everything S7 needs to score shadow-vs-live after the fact.
Consumption rules, binding S2's findings (#12696):
- The bare
opencode-go pool's monthly forecast is never consumed — S2 showed that series is a cross-workspace mixing artifact (precision 0.054 vs 0.93–1.0 per-workspace); the exclusion is logged on the record. Per-workspace pools consume their monthly rows normally.
insufficient-history rows are logged with state + reason, never consumed — no ordering is invented from an unscoreable series.
- A forecast window whose underlying reading is outside quota-current's freshness bounds degrades to no forecast for that window (the design's freshness contract), logged as an exclusion.
- The forecast can never promote a measured demotion, never remove a pool, never close anything. Weekly projections running late (S2) is calibration knowledge for S7, not a consumption rule — v1 consumes the projection as published and lets the shadow record measure how the demotions fare.
scripts/gather-quota.ts — after the forecast block (i.e. after every live output is written), the tick builds the record from the in-process forecast (null if the forecast failed — the record still lands, shadow == live) and writes both files, fail-soft like the forecast and pool-state writes. QUOTA_SHADOW_PLACEMENT_PATH / QUOTA_SHADOW_PLACEMENT_HISTORY_PATH override the defaults beside QUOTA_CURRENT_PATH. No live path reads the record.
Evidence (sandbox venue)
- Fail-before: the new suite on pristine
origin/main fails with module-not-found (./quota-shadow-placement.ts), the expected whole-surface-missing failure.
- Pass-after:
quota-shadow-placement.test.ts 14/14 (63 expects), including the no-live-effect battery — live ordering identical across forecast variants (null, empty, every-pool-projected-to-wall, honesty-only, stale) and equal to the exported liveOrderingFor(current) — the demotion-before-caution case, the bare-opencode-go exclusion vs per-workspace consumption, and the permutation property (shadow never adds/removes a pool).
- Neighbours: quota-forecast + quota-forecast-accuracy + pool-state + quota-analytics + quota-gather-map suites green (82/82 across the six files).
- Full aggregator suite: 3,225 pass / 4 fail — the same 4 tests fail identically on pristine
origin/main in the same venue (verified by a scratch-worktree run): deriveEpicEta censored-distribution (timing), charges feed-gate fallback, parsePhaseMapping real-file read, dashboard: clean up the page list (12 registered pages, overlaps to resolve) #1497 curation manifest. Zero new failures.
tsc --noEmit clean; biome check clean on the three changed files. No new dependencies.
What remains

Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…live ordering (#12697)
Stage-3 S3 (design D3): a pure projection over the tick's
quota-current + quota-forecast that computes the live placement
ordering (burn-by-expiry, measured data only) and the shadow
ordering (an open pool projected to wall before its reset is
demoted into the caution tier, before the caution zone), and emits
the per-decision diff record S7 scores: both orderings, the
decision point, per-pool measured inputs, every forecast window
row with its honesty state and consumption verdict, both ranks,
movement reasons.
Consumption binds S2's findings: the bare opencode-go monthly
forecast (cross-workspace mixing artifact) is never consumed and
the exclusion is logged; insufficient-history rows are logged,
never consumed; a stale forecast reading degrades to no forecast.
The forecast can never promote a measured demotion, remove a
pool, or close anything; the live ordering is a function of the
measured data alone (pinned by tests across forecast variants:
null, empty, all-wall, honesty-only, stale).
After the forecast block, each tick writes quota-shadow-placement
.json beside quota-current.json and appends the record to
quota-shadow-placement-history.jsonl (QUOTA_SHADOW_PLACEMENT_PATH
/ QUOTA_SHADOW_PLACEMENT_HISTORY_PATH override). Fail-soft like
the forecast: a shadow failure never fails the tick, and a failed
forecast still yields a record with shadow == live. No live path
reads the record.
Warning
Review limit reached
You'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 48 minutes.
Check out review usage here.
View limit details
-
Limit details: You’ve used the included review currently available.
Learn how review limits work.
Review configuration:
Run configuration
-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: defaults
- Review profile: CHILL
- Plan: Advanced
- Run ID:
a369c4d4-d25d-4d91-8a9c-bd1f42fe43e9
Commits
-
Reviewing files that changed from the base of the PR and between a7e088c and 8675bbc.
Files selected for processing: 3
-
pm-stack/aggregator/scripts/gather-quota.ts
pm-stack/aggregator/src/quota-shadow-placement.test.ts
pm-stack/aggregator/src/quota-shadow-placement.ts
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Share
-
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Nov 23, 2026
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Nov 23, 2026
This was referenced Nov 24, 2026
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|