Skip to content

fix(cli): do not run gate steps once the time limit is used up - #262

Closed
FredApps wants to merge 2 commits into
DiffCI:mainfrom
FredApps:fix/gate-budget-not-run
Closed

FredApps wants to merge 2 commits into
DiffCI:mainfrom
FredApps:fix/gate-budget-not-run

Conversation

@FredApps

@FredApps FredApps commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #261

Changed behavior

runGate no longer passes a timeout of 0 (no limit) to steps that would start after the --timeout-ms budget is used up. Such checks, the test step, and the narrowed and selected reruns are recorded as not_run without being started. The gate fails because those steps did not pass. A not_run step is not counted as a miss.

Behavior is unchanged while time remains.

Validation

  • New test in tests/client/gate.test.ts: the first step uses the whole 200ms limit. On main the remaining check and the tests still run. With this change only the first step runs, the rest are not_run, the gate fails and there are no misses.
  • node --import tsx --test tests/client/gate.test.ts: 9 passed.
  • tsc --noEmit -p packages/diffci-cli: clean.

Text summary (follow-up)

  • The text summary printed FAIL for a not_run step. It now prints -- with (not run), and the gate line still says the gate failed and names the step.
  • summary.full_ms and diffci_ms leave unrun steps out, so basis is now estimated when any step did not run.

The new test in tests/client/gate.test.ts checks both. It fails without this change.

runGate passed the remaining budget, clamped to 0, as each step's
timeout, and 0 means no limit, so later steps ran unbounded. Record
them as not_run instead, and do not count them as misses.

Fixes DiffCI#261

Signed-off-by: FredApps <[email protected]>
@FredApps

Copy link
Copy Markdown
Contributor Author

Cross-review (FredApps, head 4686b19). Not an approval.

Checked

Fixed: nothing needed.

Open (minor, not blocking)

  • The text summary prints FAIL for a not_run step.
  • summary.full_ms and saved_ms leave out unrun steps without marking the savings estimated. The gate fails anyway, so this only affects the reported numbers.

The text summary printed FAIL for a step the time limit left unrun. It
now prints it as not run; the gate's reason still says it failed. The
totals leave unrun steps out, so the savings are marked estimated.

Fixes DiffCI#261

Signed-off-by: FredApps <[email protected]>
@FredApps

Copy link
Copy Markdown
Contributor Author

Follow-up on the open points in the cross-review.

Real, both fixed in 003b93b

  • The text summary printed FAIL for a not_run step. It now prints -- <id> 0.0s (not run). The gate line still reads FAILED - failed: <steps>.
  • The savings basis. full_ms and diffci_ms leave unrun steps out, so basis is now estimated when any check or the tests did not run.

The time-limit test in tests/client/gate.test.ts now checks both. The unrun check and the tests print as not run, the step that timed out still prints FAIL, and the basis is estimated. It fails without the fix and passes with it. gate.test.ts and cli-help.test.ts: 206 passed. Typecheck is clean.

CI: all checks pass on 003b93b.

@FredApps
FredApps marked this pull request as ready for review November 18, 2026 00:56
@adityankale190895

Copy link
Copy Markdown
Member

Thanks. The new test steps that would start after the time limit is used up are not run is flaky on Windows: it failed 1 of 3 runs on this PR alone (and once in a combined run), with ran empty instead of ["npm run lint"].

The 200ms timeoutMs also has to cover the analysis runGate does before the checks, and on a cold Windows run that analysis alone can use it up, so lint never starts. The behaviour is right; the budget is just too tight for the test. Could you make the test independent of how fast analysis runs? For example, use a larger budget (a few seconds) with the first step still waiting timeoutMs + 50, or skip the analysis in this test.

adityankale190895 pushed a commit that referenced this pull request Nov 18, 2026
A step that would start with no time left was run with a 0ms timeout,
which means no limit at all; it is now reported as not run and the gate
fails. The step budget starts after the DiffCI analysis, so a slow
analysis cannot leave the full gate unrun. Fixes #261.

Signed-off-by: FredApps <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@adityankale190895

Copy link
Copy Markdown
Member

Merged to main as 600faa9 (squashed, authorship kept). One change on top: the step budget now starts after the DiffCI analysis (stepsStarted in runGate), so a slow analysis cannot leave the whole gate unrun. wall_ms still counts from the start. That also made the 200 ms test stable here. Thanks!

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.

gate: steps after the --timeout-ms budget is used up run with no time limit

2 participants