Skip to content

aggregator(forecast): capped resampling trials are censored, not completions (#6386) - #6701

Merged
dezren39 merged 1 commit into
mainfrom
queue/fallback-6386-censored-trials
Nov 7, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/fallback-6386-censored-trials

Conversation

@dezren39

@dezren39 dezren39 commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

Fixes #6386 — the Codex P2 finding on PR #6169 that was never fixed or responded to.

The bug

resampledWeeksToComplete in pm-stack/aggregator/src/forecast.ts pushed weeks unconditionally after the capped loop, so a trial that hit the 100,000-week cap unfinished was recorded as a completion at the cap. The cap comment even claimed that was "conservative" — for a trial whose true completion exceeds the cap it is the opposite: it pulls the percentile earlier than the true completion.

Reproduced on main before this change (reviewer's example, verbatim): buckets [1, 1, 1, 1], 100,001 remaining units → P50 and P80 both published at exactly 100,000 weeks (one week before the work can possibly finish), confidence medium, no limitation.

The fix

  • Capped trials are censored observations (null, sorted last), never completions at the cap.
  • A percentile whose nearest rank falls on a censored sample returns no date, with a limitation naming the censored share (e.g. "P50 exceeds the simulation horizon: 4096 of 4096 resampled trials did not complete within the 100000-week cap (censored observations, not completions), so no P50 date is returned"). When both percentiles are censored, confidence is unavailable.
  • An exact early-censoring check (remaining units exceed what drawing the largest bucket every remaining week could cover) ends hopeless trials early without changing their outcome — the reviewer's example now derives in ~0.3s instead of ~1.9s.
  • FORECAST_MODEL_VERSION bumps forecast/v2 → forecast/v3, with the reason recorded at the definition (outputs change materially for horizon-exceeding scopes).

Tests

  • New regression: the reviewer's example verbatim — oracle is exact arithmetic (constant pace 1/week needs exactly 100,001 weeks, so every trial is censored): both dates null, confidence unavailable, censored limitations present.
  • New regression: partially censored distribution (buckets [0, 0, 0, 4], 99,600 remaining; exact binomial CDF puts ~77% of trials inside the horizon): P50 dated just inside the horizon, P80 null with a censored limitation.
  • bun test test/forecast-3982.test.ts: 33 pass / 0 fail (includes the pre-existing MBT exact-DP-oracle and constant-bucket exactness suites, unchanged).
  • bunx tsc --noEmit: clean (after bun install in the worktree; on the bare clones it fails with a pre-existing TS2688 missing-bun-types error, also on clean main).
  • Full aggregator suite: 1526 pass / 15 fail — the failures (source-gate boot timeouts, program registry docs(dashboard): build out the Repo fleet project section (/program/repo-fleet) #1126, hook timeouts) reproduce identically on clean main without this change (verified by stashing), so they are pre-existing and unrelated.

Filed from a queue-worker fallback shift (broker backend down, issue #6619): the issue's comments carry the claim and the release.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…letions (#6386)

resampledWeeksToComplete recorded a trial that hit the 100000-week cap as a completion at the cap, pulling P50/P80 earlier than the true completion (Codex P2 on PR #6169: buckets [1,1,1,1] with 100001 remaining published both dates at 100000 weeks, one week before the work can finish). Trials that do not finish within the cap are now censored observations (null, sorted last); a percentile whose rank falls on a censored trial returns no date, with a limitation naming the censored share, and when both percentiles are censored the confidence is unavailable. An exact early-censoring check (remaining units exceed what drawing the largest bucket every remaining week could cover) ends hopeless trials without changing their outcome. FORECAST_MODEL_VERSION bumps forecast/v2 -> forecast/v3: outputs change materially for horizon-exceeding scopes.

Regression tests in forecast-3982.test.ts: the reviewer example verbatim (exact-arithmetic oracle: constant pace 1/week needs exactly 100001 weeks, so every trial is censored) and a partially censored distribution (buckets [0,0,0,4], 99600 remaining: P50 dated just inside the horizon, P80 censored, per the exact binomial CDF).
@dezren39
dezren39 requested a review from a team as a code owner November 7, 2026 02:51
@coderabbitai

coderabbitai Bot commented Nov 7, 2026

Copy link
Copy Markdown

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 47 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: c2ea9034-a5f9-4685-98cf-d7ad8111d329
Commits

Reviewing files that changed from the base of the PR and between bc96489 and ca8b06d.

Files selected for processing: 2

  • pm-stack/aggregator/src/forecast.ts
  • pm-stack/aggregator/test/forecast-3982.test.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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-07T02:53:19.083766Z ca8b06d PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@dezren39
dezren39 merged commit 4007b41 into main Nov 7, 2026
3 checks passed
@dezren39
dezren39 deleted the queue/fallback-6386-censored-trials branch November 7, 2026 02:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

aggregator(forecast): capped resampling trials are recorded as completions, publishing optimistic P50/P80 dates

1 participant