Skip to content

C4.2 — Reset-duration predictions as ranges in Drew's formats #13258

Open

Description

@dezren39

Component of #9572 (C4 quota forecasting), per its design record (doc/2026-11-13T15-12-00Z_design_reporting-architecture-event-driven/c4-forecasting-design.md).

Scope: per-pool reset-duration predictions (S2.13): how long a wall/downtime lasts until reset reopens the pool, expressed as a RANGE and rendered in Drew's formats — "between X and Y hours from now", "2.5 to 3.7 days", "2 days 4 hours to up to 3 days 16 hours", "likely runs out between tomorrow afternoon and Sunday 2 am" (natural-language windows in America/Chicago). Basis: observed reset cadence/interv​al history per pool from the snapshot store + the current window's resetsAt; each record names its basis (S2.14).

Acceptance:

  • Prediction records of kind reset_duration logged per walled/near-wall pool on gatherer ticks.
  • Range rendering implements the design's format rules, including the natural-language window form.
  • Scored on range coverage + width per the design; first scored outcomes published to the accuracy record.

Activity

  1. developing-today commented on Nov 23, 2026

    @developing-today
    Contributor
  2. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Lane WC (archer) claiming this item for one feature slice: premise + ownership checks passed (issue open, no live claim; the only comment is the queue task link). Working in a laptop worktree off main; one PR landing one acceptance-criterion slice with its test, per the feature-slice instructions.

  3. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Lane WC — HOLD (platform execution-risk flag). While reading the laptop checkout of developing-today/code to scope this slice, a platform execution-risk check tripped on the checkout content. Per the standing hold rule I stopped immediately: nothing was modified, no worktree was created, no script/build/test was run inside the checkout, and I do not assess the flagged content's safety myself. Clearing this needs Drew's plain-words go-ahead for this specific item (#13258); the standing clone approval does not extend to flagged content.

    Premise (verified by reads completed before the stop): TRUE. No reset_duration prediction records and no range rendering exist anywhere in the repo — the only mentions of reset-duration are the design statements (note.md C4; statement-inventory S2.13/S2.14). The neighbouring machinery is all in pm-stack/aggregator/src/: quota-forecast.ts (S1 forecast product + buildForecastLedgerRows, ledger source quota-forecast), quota-analytics.ts (projectWindow pace oracle), quota-forecast-accuracy.ts (S2 scoring/backtest; baselines ledger the weekly review reads), snapshot store records carry resetsAt per reading.

    Prepared scope (one feature slice, ready to run on approval):

    1. New pure module pm-stack/aggregator/src/quota-reset-duration.ts:
      • ResetDurationPrediction record: kind reset_duration, pool/window identity (canonical providerId + serviceId + window name, S1 keying), predicted reopen range [earliestMs, latestMs], the duration range, and a named basis (S2.14: e.g. current-window-resetsAt / observed-reset-cadence from consecutive snapshot resetsAt deltas for the pool/window, rename-joined via S1's forecastSeriesKey).
      • Range construction: for a walled window, the reopen instant is the current window's resetsAt; the range widens it by the observed reset-jitter spread (min/max deviation of realized resets from previously read resetsAt in the snapshot history). For a near-wall window (wallsBeforeReset true in the S1 projection), the duration range runs from the projected wall instant to the same reopen range. Thin/no history → an explicit honesty state with a named reason, never a fabricated range (mirrors the neighbourhood's insufficient-history rule).
      • Rendering in Drew's formats (S2.13), pure functions of (range, now): sub-day spans as "between X and Y hours from now"; day-scale spans as decimals ("2.5 to 3.7 days"); mixed spans compound ("2 days 4 hours to up to 3 days 16 hours"); and the natural-language window form naming America/Chicago wall-clock landmarks ("reopens between tomorrow afternoon and Sunday 2 am") when the range crosses day boundaries.
    2. Tests quota-reset-duration.test.ts in the S1/S2 test style: format-rule table (each design example shape), jitter-spread range construction from synthetic snapshot history, honesty states for thin history, and the exactly-at-boundary cases.
    3. This slice lands criterion 2 (range rendering per the design's format rules, incl. the natural-language form) plus the prediction-record builder criterion 1 consumes; the gatherer-tick wiring (records logged per walled/near-wall pool) and criterion 3 (coverage + width scoring into the accuracy record) follow as the next slices.

    On Drew's go-ahead naming #13258, this takes one lane pass.

  4. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Takeover — Lane YB (archer), 2026-11-23. Adopting Lane WC's orphaned claim: WC claimed at 12:41Z and stopped on a platform execution-risk hold at 12:43Z (record above), with no PR, no done record, and no activity since — the lane has ended. Drew batch-approved all outstanding flag holds on 2026-11-23 07:35 CST ("Approve all the flag holds listed above"), which covers #13258. Landing WC's prepared scope exactly as recorded in its hold comment: new pure module pm-stack/aggregator/src/quota-reset-duration.ts (reset_duration prediction records + range rendering in Drew's formats, incl. the natural-language America/Chicago window form) plus quota-reset-duration.test.ts. This slice lands acceptance criterion 2 and the prediction-record builder criterion 1 consumes; gatherer-tick wiring and criterion-3 scoring remain follow-on slices, so this issue stays open. Working in a laptop worktree off main.

  5. added a commit that references this issue on Nov 23, 2026
  6. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Done (builder slice) — Lane YB (archer), 2026-11-23. Adopted Lane WC's orphaned claim under Drew's 2026-11-23 batch approval of the flag holds and landed WC's prepared scope (its hold record above) exactly: PR #13352 merged (4ca7ab408626, head SHA-guarded at a0953e6ef4a).

    What landed — pm-stack/aggregator/src/quota-reset-duration.ts + quota-reset-duration.test.ts:

    • The reset_duration prediction record in the C4 design's §1 shape: subject pool+window, singular basis reset_cadence (§7), methodology c4-meth:1, supersedes link, inputs naming the rename-joined series (forecastSeriesKey).
    • Range construction: reopening anchored on the published resetsAt, 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 (§1): a degenerate spread widens to the observation resolution (half the median reading gap).
    • Honesty states with named reasons: no_basis (no snapshot history), insufficient_history (no completed period; or the ranged reopening already in the past — stale inputs). Non-subject windows (not walled, not projected to wall before reset) publish nothing.
    • Ledger mirror rows under source quota-prediction (§1), payload verbatim.

    Acceptance mapping: criterion 2 (range rendering per the design's format rules, incl. the natural-language window form) — landed: the stored rendered string comes from the one shared §4 formatter (renderPredictionRange, quota-downtime.ts), with the duration form and the America/Chicago calendar form both pinned by tests. Criterion 1 — the record builder it consumes is landed; the gatherer-tick wiring (assemble history per walled/near-wall pool, log per tick) remains. Criterion 3 (coverage + width scoring into the accuracy record) remains. This issue stays open on criteria 1 and 3.

    Verification (laptop route of record):

    • bun test src/quota-reset-duration.test.ts: 14/14 pass (jitter-spread construction from synthetic history, degenerate-spread widening, subject selection, both honesty states, stale guards, cadence projection, both rendering forms, ledger mirror, null-rollover regression below).
    • Six C4/quota suites together (reset-duration, downtime, arrival, forecast, forecast-alerts, daytype-sufficiency): 86 pass / 0 fail.
    • Full aggregator suite post-bun install: 3255 pass / 20 fail — all 20 failures are server-boot tests failing on port 4871, which the production pm-aggregator service on the laptop holds (verified via ss: the deployed pm-aggregator process, up 11h51m); zero failures in any quota file, and this PR modifies no existing file. (The pre-install run's extra failures were the fresh worktree's missing node_modules.)
    • Remote dispatch (run 45191248128) failed on environment — bun: command not found in the fleet-build container (the fleet: fleet-command dispatch container cannot run nix develop out of the box (experimental features, nixbld group, homeless-shelter purity) #13159 family), not a test result.

    Review: Codex posted one P2 (null resetsAt readings past a published reset would extend the period bracket and bill the publication gap to the reset as jitter). Accepted and fixed forward on the PR before merge, mirroring the accuracy harness's unknown-reset-segment distinction; regression test included (an on-schedule rollover with a two-reading publication gap now measures +75m of jitter, not +150m).

    Design notes filed: the §4 compound example form is unimplemented by the shared formatter and its day form is unreachable as ordered — filed as #13357 for the design owner rather than forked around here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions