Skip to content

chore(ci): archive and report red-main incidents, flakes, cancellations and merges during red - #4013

Merged
schlessera merged 5 commits into
mainfrom
chore/2953-red-main-evidence
Nov 15, 2026
Merged

schlessera merged 5 commits into
mainfrom
chore/2953-red-main-evidence

Conversation

@schlessera

@schlessera schlessera commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Closes #2953. Part of #2948.

What changes

The hourly ci-timings collector gains --red-main, and the scheduled workflow passes it. It writes normalized red-main evidence next to the existing timing files. That output is what #2955's daily compaction will move into the data ref. ci-timings report gains a redMain section in summary.json and summary.md, which is the report #2956 builds on.

  • Lifecycle (red-main.json): reads the shared coordination ref through Git (no API), walking only the commits that changed red-main.json, back to the last green state before the window. Each record is keyed by its opening run and gives: opened, first bad SHA with its bisect refinements, failing tests and categories with estimator reasons, incident issue, declared and expedited fixes, non-fix squashes reported while red, and the clear. Time to green is opened → cleared, on server time.
  • Flake verdicts: each suspect's probe outcome and issue, per test. An escalation to real (repeated-suspected-flake with its prior suspect run, or probe-reproduced) comes from the incident failure's reasons.
  • Cancellations (coordinator-<run>-attempt-<n>.json): parses the coordinator's BRAIN_RED_MAIN lines from red-main workflow runs created while main was red. A green window costs no API request. Each archived attempt is seeded forward (the seed now accepts these files) and never fetched twice.
  • Gate refusals: PR CI attempts whose changeset job failed the "Refuse doomed proof while main is red" step, read from the existing timing snapshots.
  • Runner minutes: consumed time comes from the stopped run's timing snapshot. Estimated saving is the median successful PR CI attempt minus that consumed time. A missing snapshot, a missing reference or an unreadable coordinator log is counted under unknownConsumed, unknownSaved or acquisition.coordinatorUnknown, never as zero. A run that finished before its cancel took effect saved 0.
  • Merges during red: each reported squash with its PR, from the exact squash identity (push-run attribution or the PR's merge commit). unknownPR counts the rest.
  • Coordinator (one line, scripts/red-main-coordinator.ts): the probe path now prints the same BRAIN_RED_MAIN cancellation line as the main-run path. Its cancellations were otherwise invisible. Its decisions are unchanged. Earlier successful probe attempts without the line read as no cancellations; docs/process/ci-throughput.md records that limit.

Archive prerequisite: the #2955 data ref does not need to exist first. These records go into the hourly artifact like reservations.json. No archive ref is written here. Record versions are 1, as for the existing kinds; #2950's inventory should list them.

Acceptance criteria

Criterion Test
A fixture red-main lifecycle produces one incident record with the correct time to green tests/ci-red-main.test.ts "a fixture red-main lifecycle…" (overlapping archives, 90 min), plus the native offline-remote history walk
A flake verdict followed by a second suspicion on the same test shows the escalation to real "a suspected flake followed by a second…", using the real classifyFailure
Runner minutes saved by cancellation are reported, unknowns counted separately "runner minutes saved by cancellation and refusal…"
A merge during red appears in the report with its PR number "a merge during red appears…", plus the native report CLI test

Mutation receipts

Each guard was broken, the named assertion failed for the claimed reason, and the guard was restored:

Mutation Failing assertion
clear matched on open instead of clear TIME_TO_GREEN_FROM_OPEN_TO_CLEAR
incidents keyed per record state instead of by opening run ONE_INCIDENT_PER_RECORD (length > 1)
repeated-suspect escalation dropped ESCALATED_TO_REAL
missing reference counted as 0 saving NO_REFERENCE_IS_UNKNOWN
missing snapshot counted as 0 CANCELLED_SAVINGS_AND_UNKNOWNS
cancelled attempt not preferred over a later rerun CANCELLED_SAVINGS_AND_UNKNOWNS
squash PR lookup removed MERGE_DURING_RED_HAS_PR
history walk bound removed EARLIER_INCIDENT_OUTSIDE_WINDOW
empty red intervals kept GREEN_HOURS_COST_NOTHING
failed coordinator without a line read as none FAILED_BEFORE_PRINTING_IS_UNKNOWN
archived attempt refetched ARCHIVED_ATTEMPT_NOT_REFETCHED
unread coordinator scope not a gap UNREAD_COORDINATOR_LOGS_ARE_A_GAP
seed regex without coordinator files COORDINATOR_OBSERVATION_SEEDED
probe-path print removed PROBE_CANCELLATIONS_PRINTED (tests/red-main.test.ts)

Validation

  • bun run check:pr --base origin/main passed: lint and leakage, environment docs, changesets, and affected fast invariants (1222 tests). This host has no zip binary, which tests/ci-timings-collection.test.ts uses to build its seed fixture. Without it the seeded tests fail the same way on origin/main. I put a Python zipfile shim on PATH for the local run. No test or harness was changed for this.
  • bun run typecheck is clean.
  • No changeset: the change touches only repository scripts, tests, workflow and docs. The contribution changeset gate passed.
{"version":1,"kind":"brain-check-pr-receipt","head":"db486064efcb62814cf66438fab2fefb711c5c56","base":"origin/main","mode":"focused","startedAt":"2026-11-15T13:37:32.747Z","finishedAt":"2026-11-15T13:38:57.362Z","checks":[{"name":"all lint and leakage gates","categories":["changeset"],"outcome":"passed","elapsedMs":12383.291926999998},{"name":"environment documentation","categories":["changeset"],"outcome":"passed","elapsedMs":124.16728599999988},{"name":"pending changeset package names","categories":["changeset"],"outcome":"passed","elapsedMs":142.14264600000024},{"name":"contribution changeset","categories":["changeset"],"outcome":"passed","elapsedMs":17.50779700000021},{"name":"affected fast invariants","categories":["verify","unit"],"outcome":"passed","elapsedMs":71930.943212}]}

Refreshed by merging origin/main (#4006, #4011); neither touches this PR's files, so the receipt above still describes its changes.

Contract impact: none.

🤖 Generated with Claude Code

…ns and merges during red

The hourly collector reads the red-main record's history from the shared
coordination ref, and the coordinator's cancellation lines for the hours main
was red, into normalized archive files. The report gains a red-main section:
each incident's lifecycle and time to green, flake verdicts with their
escalation to real, PR proof cancelled or refused by the gate with consumed
and estimated saved runner minutes (unknowns counted separately), and non-fix
merges during red with their PR. The probe path now prints the same
cancellation line as a main run.

Refs #2953

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@schlessera schlessera added this to the 0.45.0 milestone Nov 15, 2026
@schlessera schlessera added type: chore Tooling, CI, release plumbing, dependencies. area: ci CI workflows, the gates they run, release scripts, packaging. labels Nov 15, 2026
@schlessera

Copy link
Copy Markdown
Owner Author

Collisions at head db486064efcb62814cf66438fab2fefb711c5c56 (bun scripts/collisions.ts --json --pr 4013): no path collisions; closure-only overlap with #3056, #3059, #3116, #3437, #3622, #3806, #4002, #4007, #4008, #4011 and #4012 on the shared CI-script test closure.

@schlessera
schlessera marked this pull request as ready for review November 15, 2026 15:44
@schlessera
schlessera merged commit 7e36fdc into main Nov 15, 2026
40 of 52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ci CI workflows, the gates they run, release scripts, packaging. type: chore Tooling, CI, release plumbing, dependencies.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci: archive and report red-main incidents, flake verdicts, cancellations and merges during red

1 participant