From 4199ba65733919937aa1636c49e80745ec3a97bd Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Mon, 14 Sep 2026 13:19:16 -0500 Subject: [PATCH] fix(ci): quarantine three merge-group flaky tests (#2730) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Quarantine the three new candidates auto-filed by issue #2730's merge-group flake-detection run (CI run 34670762927, head 1499a74b, 2026-09-12T04:27:48Z → 04:34:14Z): tests/unit/telemetry/init-rehome.test.ts → scripts/ci/quarantined-tests.txt (general ledger) Ubuntu-latest coverage-shard 3 only, 2026-09-12T04:04:09Z: Attempt 1 failed → Passed on retry 1 (passed-on-retry flake). Sibling coverage-shards 1/2/4/5/6 green. Coverage runs ubuntu-only and honors ONLY the general ledger (scripts/ci/run-coverage-gate.sh:85,111 never branches per-OS). tests/unit/hooks/pr-feedback-scope-controller.test.ts → scripts/ci/quarantined-tests-macos.txt (macOS ledger) macos-latest unit-shard 1 only, 2026-09-12T03:56:04Z: Attempt 1 failed → Passed on retry 1 (passed-on-retry flake). Sibling macos shards 2/4/5/6, all ubuntu shards 1-4, all windows shards 2/3/4/6 green or did not run the file (round-robin). tests/unit/utils/bun-compat-exit-first-2530.test.ts → scripts/ci/quarantined-tests-macos.txt (macOS ledger) macos-latest unit-shard 5 only, 2026-09-12T03:57:26Z: Attempt 1 failed → Attempt 2 failed → ::error file=...::FAILED (hard failure, both retries exhausted). Failing cell is `native Bun reports bounded output overflow and terminates the child` at tests/unit/utils/bun-compat-exit-first-2530.test.ts:450-454: `expect(receipt.exitCode !== 0 || receipt.signalCode !== null) .toBe(true)` fails because native Bun on macos-latest returns both exitCode 0 and signalCode null after the bounded-output termination path. Sibling macos shards 1/2/4/6 and all ubuntu/windows shards green or did not run the file. Each new entry carries the structured # OWNER: / # EXPIRY: metadata required by scripts/check-invariants.ts Check 7 (issue #2477). EXPIRY 2026-10-14 is 30 days out, well inside the 14-day grace window so the gate warns rather than fails. The fourth candidate listed in the issue body (tests/unit/scripts/ci/repository-validation-real-process-2675.test.ts) is already quarantined in scripts/ci/quarantined-tests-macos.txt by issue #2738 (commit ad8c53ae3, 2026-09-12). Re-listing it in any other ledger would be a silent no-op for the detection script's Rule A and a confusing cross-ledger duplicate for triage; the new pinning test asserts the path stays in the macOS ledger (the existing #2738 entry) and is not duplicated. Adds a 14-test pinning regression file (tests/unit/scripts/ci/ci-yml-quarantine-2730.test.ts) covering all three new entries (ledger placement, scope isolation, OWNER/EXPIRY metadata, on-disk path presence) plus the no-duplicate invariant for the #2738 entry. RED check performed: with the ledger entries reverted, the new file fails exactly its 6 ledger/metadata assertions (8 pass / 6 fail); green at HEAD (14 pass / 0 fail). Tests pass locally on this checkout (21/21 quarantined cases pass in ~5.7s on TMPDIR=~/.cache/hermes-tmp). Includes the mandated pending release fragment (docs/releases/pending/issue-2730-three-merge-group-flaky-tests-quarantine.md) covering What changed / Why / Migration steps / Known caveats. Every file path, identifier, and line number cited in the fragment was verified against the codebase before commit. Refs: #2730 (this issue), #1782 (flake-detection workflow), #2477 (OWNER/EXPIRY metadata grammar enforced by Check 7), #2738 (the pre-existing #2675 macOS-ledger entry this PR defers to), #2368 (precedent for coverage-shard general-ledger quarantine), #1908 (general-ledger retirement precedent). --- ...hree-merge-group-flaky-tests-quarantine.md | 158 ++++++++++ scripts/ci/quarantined-tests-macos.txt | 63 +++- scripts/ci/quarantined-tests.txt | 33 +- .../scripts/ci/ci-yml-quarantine-2730.test.ts | 287 ++++++++++++++++++ 4 files changed, 539 insertions(+), 2 deletions(-) create mode 100644 docs/releases/pending/issue-2730-three-merge-group-flaky-tests-quarantine.md create mode 100644 tests/unit/scripts/ci/ci-yml-quarantine-2730.test.ts diff --git a/docs/releases/pending/issue-2730-three-merge-group-flaky-tests-quarantine.md b/docs/releases/pending/issue-2730-three-merge-group-flaky-tests-quarantine.md new file mode 100644 index 000000000..27044cd1a --- /dev/null +++ b/docs/releases/pending/issue-2730-three-merge-group-flaky-tests-quarantine.md @@ -0,0 +1,158 @@ +# Quarantine three merge-group flaky tests (issue #2730) + +## What changed + +- Appended two new entries to the macOS-only CI quarantine ledger, + `scripts/ci/quarantined-tests-macos.txt`: + - `tests/unit/hooks/pr-feedback-scope-controller.test.ts` + (macos-latest unit-shard 1, passed-on-retry flake) + - `tests/unit/utils/bun-compat-exit-first-2530.test.ts` + (macos-latest unit-shard 5, hard failure on both attempts) +- Appended one new entry to the general/global CI quarantine ledger, + `scripts/ci/quarantined-tests.txt`: + - `tests/unit/telemetry/init-rehome.test.ts` + (ubuntu-latest coverage-shard 3, passed-on-retry flake) +- Each entry carries the structured `# OWNER:` / `# EXPIRY:` metadata + block required by `scripts/check-invariants.ts` Check 7 (issue + #2477), so the entries hard-fail the gate if the EXPIRY lapses beyond + the 14-day grace window and is not renewed. +- Added a 14-test pinning regression file + (`tests/unit/scripts/ci/ci-yml-quarantine-2730.test.ts`) covering the + three new entries (ledger placement, scope isolation, OWNER/EXPIRY + metadata, on-disk path presence) and the no-duplicate invariant for + the path that is already quarantined by issue #2738. +- No source, hook, or workflow code changed. The change is confined to + the two ledger files, the new pinning test file, and this pending + release fragment. + +## Why + +Issue #2730 was auto-filed by the `flake-detection` workflow (issue +#1782, introduced by the merge-group flake-detection phase §6) after a +merge-group CI run (`ci.yml` run 34670762927, head `1499a74b`, +2026-09-12T04:27:48Z → 04:34:14Z) reported four candidate paths. The +issue body listed: + +``` +# CORE-TREE (requires human review): tests/unit/hooks/pr-feedback-scope-controller.test.ts +tests/unit/scripts/ci/repository-validation-real-process-2675.test.ts +tests/unit/telemetry/init-rehome.test.ts +tests/unit/utils/bun-compat-exit-first-2530.test.ts +``` + +Tracing the detection job back to its upstream CI run (via the +`Fetching artifact list for workflow run N` log line in +flake-detection.yml), I cross-referenced the per-shard `flake-annotations-*` +artifacts against the run's `unit (RUNNER_OS, SHARD)` jobs and confirmed +single-OS evidence for each new entry: + +- `tests/unit/hooks/pr-feedback-scope-controller.test.ts` — macos-latest + unit-shard 1 (`Attempt 1 failed, retrying (1/2)` → + `Passed on retry 1 (flaky)` at 2026-09-12T03:56:04Z). All sibling + macos shards (2/4/5/6), all ubuntu unit shards (1-4), and all + windows unit shards (2/3/4/6) were green on this file or did not run + it by shard round-robin distribution. macOS ledger is correct. +- `tests/unit/utils/bun-compat-exit-first-2530.test.ts` — macos-latest + unit-shard 5 (`Attempt 1 failed, retrying (1/2)` then + `Attempt 2 failed, retrying (2/2)` → `##[error]FAILED` at + 2026-09-12T03:57:26Z). Sibling macos shards and all ubuntu/windows + shards were green on this file or did not run it. The failing cell is + `native Bun reports bounded output overflow and terminates the + child` at + `tests/unit/utils/bun-compat-exit-first-2530.test.ts:450-454` — + `expect(receipt.exitCode !== 0 || receipt.signalCode !== null).toBe(true)` + fails because native Bun on macos-latest returns both `exitCode 0` + and `signalCode null` after the bounded-output termination path, + defeating the exit-or-signal expectation. macOS ledger is correct. +- `tests/unit/telemetry/init-rehome.test.ts` — ubuntu-latest + coverage-shard 3 (`Attempt 1 failed, retrying (1/2)` → + `Passed on retry 1 (flaky)` at 2026-09-12T04:04:09Z). Sibling + coverage-shards 1/2/4/5/6 were green. The coverage job runs + ubuntu-only and honors ONLY the general ledger + (`scripts/ci/run-coverage-gate.sh:85,111` — its own header comment at + `:98-104` states coverage is ubuntu-only and must never branch + per-OS), so the general ledger is the only correct target. + +The fourth candidate from the issue body, +`tests/unit/scripts/ci/repository-validation-real-process-2675.test.ts`, +is already quarantined in the macOS ledger via issue #2738 (commit +`ad8c53ae3`, 2026-09-12). The detection script's Rule A drops +already-quarantined candidates, so re-listing it in any other ledger +would be a silent no-op for detection but a confusing cross-ledger +duplicate for triage; the new pinning test asserts that the path stays +in the macOS ledger (the existing #2738 entry) and is NOT duplicated +into the general or windows ledgers by this PR. + +Local reproduction on this checkout (per the recipe's local-pass +gotcha, run under a clean `TMPDIR`): + +``` +TMPDIR=~/.cache/hermes-tmp bun test \ + tests/unit/hooks/pr-feedback-scope-controller.test.ts \ + tests/unit/telemetry/init-rehome.test.ts \ + tests/unit/utils/bun-compat-exit-first-2530.test.ts \ + --timeout 120000 + + 21 pass + 0 fail + 87 expect() calls +Ran 21 tests across 3 files. [5.70s] +``` + +This is the expected quarantine rationale: the flake is +environment-sensitive (merge-group OS matrix / coverage instrumentation), +not a logic bug. All three files pass locally. The `ci.yml` retry loop +discards attempt-1 output when a retry passes, so no assertion text +exists for `pr-feedback-scope-controller` or `init-rehome`; for +`bun-compat-exit-first-2530` both retries were exhausted and the +captured assertion is the one cited above (the native Bun path on +macOS does not terminate the child with a non-zero exit or a signal +when the bounded-output stream is closed mid-write). + +## Migration steps + +None. The macOS and general ledgers are honored by the existing +`scripts/ci/run-unit-tests-local.ts` (`bun run test:unit:ci`) consumer +and by the corresponding steps in `ci.yml` (macOS branch at +`.github/workflows/ci.yml:632` for the macOS ledger, the unconditional +general-ledger read at the same step for the global ledger). After this +commit merges, subsequent merge-group CI runs will skip the three files +in their respective unit and coverage jobs. + +## Known caveats + +- **Quarantine is not a fix.** These entries suppress flake-induced red + shards in CI but do not address the underlying environment + sensitivity. Retirement should be pursued under a dedicated + test-stability sprint (the original test-stability sprint, issue + #1782, is closed; a follow-up issue should be opened when one is + created). +- **`scripts/check-invariants.ts` Check 7** hard-fails any quarantine + entry whose `# EXPIRY:` lapses beyond the 14-day grace window. The + EXPIRYs below are set inside the grace window (30 days out); if the + underlying flakes persist past EXPIRY, the entries must be renewed + with an updated criterion (or the tests root-fixed) to keep CI green. +- The macOS entries are single-OS: macOS-latest merge-group flakes with + green sibling shards. If a future flake-detection run produces + cross-OS evidence for either file, the entries should be moved to + the general ledger (matching the precedent set by issue #2368's + `dispatch-lanes.test.ts` general-ledger quarantine after a + coverage-shard flake on ubuntu). +- The `init-rehome.test.ts` entry is in the general ledger rather than + a per-OS ledger. That is a deliberate choice for this PR: the + coverage job (`scripts/ci/run-coverage-gate.sh`) never branches + per-OS, so the file would be exercised by coverage no matter where + it is listed — but only the general ledger stops the next + coverage-shard run from re-filing the same flake (Rule A only drops + already-quarantined candidates). +- Sibling auto-fix branches can hold unmerged quarantine entries that + conflict textually with this one. Per the recipe, ledger state on the + task branch = `origin/main` state at checkout; textual conflicts + between sibling quarantine PRs are the wrapper's concern, not a + blocker. + +Refs: issue #2730, issue #1782 (flaky-test detection workflow), +issue #2477 (OWNER/EXPIRY metadata grammar enforced by Check 7), +issue #2738 (the pre-existing #2675 macOS-ledger entry this PR +defers to), issue #2368 (precedent for a coverage-shard general-ledger +quarantine with captured assertion text). \ No newline at end of file diff --git a/scripts/ci/quarantined-tests-macos.txt b/scripts/ci/quarantined-tests-macos.txt index 0c9ff728c..6dfd06cf5 100644 --- a/scripts/ci/quarantined-tests-macos.txt +++ b/scripts/ci/quarantined-tests-macos.txt @@ -12,7 +12,8 @@ # the gate; an EXPIRY more than 14 days in the past also fails (inside # the grace window it only warns). # -# No active macOS-only quarantines besides the entry below. +# macOS-only quarantines live here; entry count is tracked by the file size +# of active (non-comment) lines plus the OWNER/EXPIRY header convention. # OWNER: zaxbysauce — issue #2738 (deterministic macOS signal-child failure: # the crash fixture survives the delivered POSIX signal and exits 0 on @@ -21,3 +22,63 @@ # EXPIRY: 2026-09-26 — remove when the fixture/harness signal handling is # fixed and the test passes on macos-latest. tests/unit/scripts/ci/repository-validation-real-process-2675.test.ts +# +# tests/unit/hooks/pr-feedback-scope-controller.test.ts (issue #2730) +# --------------------------------------------------------------------------- +# Tests the PR_FEEDBACK dedicated coder scope controller (8 cases): fails +# closed before immutable verification settles, authorizes exactly one +# planless coder Task and enforces its bound files, gives an authenticated +# synthetic PR-feedback scope precedence over an unrelated plan, gives an +# authenticated PR-feedback scope precedence over stale plan Stage-A state, +# invalidates a prepared scope when the feedback revision changes, +# atomically reserves one PR-feedback declaration when Task calls race, +# does not consume a replacement declaration after classifying its +# predecessor, and preserves normal-plan Stage-A rejection without scope +# or evidence leaks. Flaky on macos-latest merge-group unit-shard 1 only: +# CI run 34670762927 (merge_group, head 1499a74b, 2026-09-12T03:56:04Z) +# had Attempt 1 fail and Passed on retry 1 (passed-on-retry flake); sibling +# macos-latest unit shards 2/4/5/6, all ubuntu-latest unit shards 1-4, and +# all windows-latest unit shards 2/3/4/6 either ran the file green or did +# not run it (shard round-robin). The ci.yml retry loop discards +# attempt-1 output when a retry passes, so no assertion text exists to +# drive a root-cause fix; the file passes locally on this checkout in +# ~1.2s (8/8 cases). Pre-existing, unrelated to any specific PR. +# Quarantined per issue #2730; tracked under #1782 (test-stability sprint). +# OWNER: zaxbysauce — issue #2730 (macos-latest-only merge-group flake; +# single-OS evidence: macos-1 retry-pass, siblings green) +# EXPIRY: 2026-10-14 — root-fix the macos-only flake pattern or renew with +# an updated criterion. Inside the 14-day grace window Check 7 only warns. +tests/unit/hooks/pr-feedback-scope-controller.test.ts +# +# tests/unit/utils/bun-compat-exit-first-2530.test.ts (issue #2730) +# --------------------------------------------------------------------------- +# Tests the bunSpawn Node fallback exit-first output consumption surface +# (issue #2530): Node fallback preserves empty/small/large/nonzero +# dual-stream outcomes, native Bun preserves the same, native Bun +# immediate getReader retains stdout ownership, Node fallback reports +# bounded output overflow and terminates the child, native Bun reports +# the same, Node fallback timeout preserves partial output and +# termination outcome, native Bun timeout preserves the same, and the +# plain-Node built public isCleanWorktree path handles a clean Git repo. +# Flaky on macos-latest merge-group unit-shard 5 only: CI run 34670762927 +# (merge_group, head 1499a74b, 2026-09-12T03:57:26Z) had Attempt 1 fail, +# Attempt 2 fail, then the error surfaced as `::error file=...::FAILED` +# (hard failure); sibling macos-latest unit shards 1/2/4/6 either ran +# the file green or did not run it (shard round-robin), and all +# ubuntu/windows shards were green or did not run it. The failing cell +# is `native Bun reports bounded output overflow and terminates the +# child` at tests/unit/utils/bun-compat-exit-first-2530.test.ts:450-454: +# `expect(receipt.exitCode !== 0 || receipt.signalCode !== null).toBe(true)` +# fails because native Bun on macos-latest returns both exitCode 0 and +# signalCode null after the bounded-output termination path. The ci.yml +# retry loop captures the assertion (both retries exhausted); the file passes +# locally on this checkout in ~3.6s (8/8 cases). Pre-existing, unrelated to +# any specific PR. +# Quarantined per issue #2730; tracked under #1782 (test-stability sprint). +# OWNER: zaxbysauce — issue #2730 (macos-latest-only merge-group flake; +# single-OS evidence: macos-5 hard fail both attempts, siblings green) +# EXPIRY: 2026-10-14 — root-fix the macos-only native Bun output-overflow +# termination surface (e.g. SIGTERM the child on macos to mirror the Node +# fallback path) or renew with an updated criterion. Inside the 14-day +# grace window Check 7 only warns. +tests/unit/utils/bun-compat-exit-first-2530.test.ts diff --git a/scripts/ci/quarantined-tests.txt b/scripts/ci/quarantined-tests.txt index 998a02b2a..3f03d2686 100644 --- a/scripts/ci/quarantined-tests.txt +++ b/scripts/ci/quarantined-tests.txt @@ -11,4 +11,35 @@ # the gate; an EXPIRY more than 14 days in the past also fails (inside # the grace window it only warns). # -# No active global test quarantines. Issue #1908 retired the tracked backlog. +# No active global test quarantines. Issue #1908 retired the tracked backlog; +# (post-#1908 entries live below). + +# tests/unit/telemetry/init-rehome.test.ts (issue #2730) +# --------------------------------------------------------------------------- +# Tests the telemetry re-home on directory change path (issue #2472 W9): init +# A then init B produces two telemetry.jsonl files and B receives subsequent +# events; same-directory re-init stays an idempotent no-op; events emitted +# before any init are dropped without creating a file; failed new-stream +# creation retains the previous project's stream (fail-open ownership +# retention); windows case-variant spelling of the same root keeps the +# stream destination (canonical same-directory check). Flaky on +# ubuntu-latest merge-group coverage-shard 3 only: CI run 34670762927 +# (merge_group, head 1499a74b, 2026-09-12T04:04:09Z) had Attempt 1 fail and +# Passed on retry 1 (passed-on-retry flake); sibling coverage-shards +# 1/2/4/5/6 were green on this file in the same run. The coverage job +# runs ubuntu-only and honors ONLY the general ledger +# (scripts/ci/run-coverage-gate.sh:85,111 never branches per-OS — its +# own header comment at :98-104 says coverage is ubuntu-only and must +# never partition by RUNNER_OS), so this is the only correct ledger +# target. The ci.yml retry loop discards attempt-1 output when a retry +# passes, so no assertion text exists to drive a root-cause fix; the file +# passes locally on this checkout in ~149ms (5/5 cases). Pre-existing, +# unrelated to any specific PR. +# Quarantined per issue #2730; tracked under #1782 (test-stability sprint). +# OWNER: zaxbysauce — issue #2730 (ubuntu-only merge-group coverage-shard +# flake; general-ledger target because run-coverage-gate.sh never +# branches per-OS) +# EXPIRY: 2026-10-14 — root-fix the coverage/isolate retry-flake or renew +# with an updated criterion. Inside the 14-day grace window Check 7 only +# warns. +tests/unit/telemetry/init-rehome.test.ts diff --git a/tests/unit/scripts/ci/ci-yml-quarantine-2730.test.ts b/tests/unit/scripts/ci/ci-yml-quarantine-2730.test.ts new file mode 100644 index 000000000..a20af7e8a --- /dev/null +++ b/tests/unit/scripts/ci/ci-yml-quarantine-2730.test.ts @@ -0,0 +1,287 @@ +import { describe, expect, test } from 'bun:test'; +import { existsSync, readFileSync } from 'node:fs'; +import { join } from 'node:path'; + +// Regression pinning tests for the issue #2730 quarantine entries. +// +// Issue #2730 listed 4 candidates from a merge-group flake-detection run +// (CI run 34670762927, head 1499a74b, 2026-09-12T04:27:48Z → 04:34:14Z): +// - tests/unit/hooks/pr-feedback-scope-controller.test.ts +// (macos-latest unit-shard 1, passed-on-retry flake) +// - tests/unit/scripts/ci/repository-validation-real-process-2675.test.ts +// (macos-latest unit-shard 1, hard fail — already quarantined in +// scripts/ci/quarantined-tests-macos.txt by issue #2738, so this PR +// does NOT add a second entry; the detection script's Rule A drops +// already-quarantined candidates, and the duplicate would be a +// no-op for the flake-detection script and a confusing cross-ledger +// duplicate for triage.) +// - tests/unit/telemetry/init-rehome.test.ts +// (ubuntu-latest coverage-shard 3, passed-on-retry flake — must go +// in the GENERAL ledger because run-coverage-gate.sh never branches +// per-OS) +// - tests/unit/utils/bun-compat-exit-first-2530.test.ts +// (macos-latest unit-shard 5, hard fail both attempts) +// +// Each pinning test below reads the real ledger files off disk and +// asserts the entry is present in the correct ledger and absent from +// the others, that the on-disk file exists, and that the entry block +// carries the OWNER/EXPIRY metadata required by Check 7 (issue #2477). + +const REPO_ROOT = join(import.meta.dir, '../../../..'); +const GENERAL_LEDGER_PATH = join(REPO_ROOT, 'scripts/ci/quarantined-tests.txt'); +const MACOS_LEDGER_PATH = join( + REPO_ROOT, + 'scripts/ci/quarantined-tests-macos.txt', +); +const WINDOWS_LEDGER_PATH = join( + REPO_ROOT, + 'scripts/ci/quarantined-tests-windows.txt', +); +const INTEGRATION_LEDGER_PATH = join( + REPO_ROOT, + 'scripts/ci/quarantined-integration-tests.txt', +); + +const PR_FEEDBACK_SCOPE_CONTROLLER = + 'tests/unit/hooks/pr-feedback-scope-controller.test.ts'; +const INIT_REHOME = 'tests/unit/telemetry/init-rehome.test.ts'; +const BUN_COMPAT_EXIT_FIRST = + 'tests/unit/utils/bun-compat-exit-first-2530.test.ts'; +const REPO_VALIDATION_REAL_PROCESS_2675 = + 'tests/unit/scripts/ci/repository-validation-real-process-2675.test.ts'; + +// Mirror ci.yml's active-entry extraction exactly: +// grep -vE '^\s*#|^\s*$' scripts/ci/quarantined-tests-.txt +// (CRLF is normalized first so the assertion holds on any checkout config.) +function activeEntries(ledgerPath: string): string[] { + const raw = readFileSync(ledgerPath, 'utf8').replace(/\r\n/g, '\n'); + return raw + .split('\n') + .filter((line: string) => !/^\s*#/.test(line) && !/^\s*$/.test(line)) + .map((line: string) => line.trim()); +} + +describe('ci.yml integration — quarantine ledger entries for issue #2730 merge-group flake detection', () => { + describe('pr-feedback-scope-controller.test.ts (macos-latest, unit-shard 1)', () => { + test('is an active entry in the macOS ledger (single-OS evidence)', () => { + // Without this entry, the flake-detection script keeps + // re-filing the candidate (Rule A only drops already-quarantined + // files). The flake originated on macos-latest unit-shard 1 + // (CI run 34670762927, 2026-09-12T03:56:04Z, Attempt 1 failed → + // Passed on retry 1) with no other OS showing the same flake. + expect(existsSync(MACOS_LEDGER_PATH)).toBe(true); + expect(activeEntries(MACOS_LEDGER_PATH)).toContain( + PR_FEEDBACK_SCOPE_CONTROLLER, + ); + }); + + test('is scoped to the macOS ledger only (not general, not windows, not integration)', () => { + // The general ledger applies on every RUNNER_OS — listing it + // there would suppress the file on ubuntu/windows too, but the + // flake was macos-only; the windows and integration ledgers + // apply on their respective runners and would similarly over- + // suppress. + expect(activeEntries(GENERAL_LEDGER_PATH)).not.toContain( + PR_FEEDBACK_SCOPE_CONTROLLER, + ); + expect(activeEntries(WINDOWS_LEDGER_PATH)).not.toContain( + PR_FEEDBACK_SCOPE_CONTROLLER, + ); + if (existsSync(INTEGRATION_LEDGER_PATH)) { + expect(activeEntries(INTEGRATION_LEDGER_PATH)).not.toContain( + PR_FEEDBACK_SCOPE_CONTROLLER, + ); + } + }); + + test('carries OWNER + EXPIRY metadata (issue #2477 Check 7)', () => { + // Check 7 hard-fails any active entry missing OWNER/EXPIRY or + // with EXPIRY past the 14-day grace window. Reading the raw + // file here is more direct than invoking check:invariants and + // gives a focused, fast RED signal if the next entry edit + // drops one of the two required lines. + const raw = readFileSync(MACOS_LEDGER_PATH, 'utf8').replace( + /\r\n/g, + '\n', + ); + const lines = raw.split('\n'); + const entryIdx = lines.findIndex( + (l: string) => l.trim() === PR_FEEDBACK_SCOPE_CONTROLLER, + ); + expect(entryIdx).toBeGreaterThan(-1); + const blockAbove: string[] = []; + for (let i = entryIdx - 1; i >= 0; i -= 1) { + const above = lines[i] ?? ''; + if (above.trim() === '' || /^\s*#/.test(above)) { + blockAbove.push(above); + } else { + break; + } + } + const block = blockAbove.reverse().join('\n'); + expect(block.includes('# OWNER:')).toBe(true); + expect(block.match(/#\s*EXPIRY:\s*\d{4}-\d{2}-\d{2}/) !== null).toBe( + true, + ); + }); + + test('the quarantined path exists and is discovered by the ci.yml find chain', () => { + // A typo'd ledger path would be a silent no-op: CI's + // `comm -23` gated set would never exclude it (the path never + // appears in all-tests.txt) and the flake would keep + // re-filing. The discovery chain globs tests/unit/**/*.test.ts, + // so the on-disk file must exist at exactly the ledger path + // relative to the repo root. + expect(existsSync(join(REPO_ROOT, PR_FEEDBACK_SCOPE_CONTROLLER))).toBe( + true, + ); + }); + }); + + describe('init-rehome.test.ts (ubuntu-latest, coverage-shard 3)', () => { + test('is an active entry in the GENERAL ledger (coverage job is ubuntu-only)', () => { + // The coverage job runs ubuntu-only and honors ONLY the + // general ledger (run-coverage-gate.sh:85,111 never branches + // per-OS — its own header comment at :98-104 says coverage is + // ubuntu-only and must never partition by RUNNER_OS). The + // flake originated on ubuntu-latest coverage-shard 3 + // (CI run 34670762927, 2026-09-12T04:04:09Z, Attempt 1 failed → + // Passed on retry 1). + expect(existsSync(GENERAL_LEDGER_PATH)).toBe(true); + expect(activeEntries(GENERAL_LEDGER_PATH)).toContain(INIT_REHOME); + }); + + test('is scoped to the general ledger only (not per-OS, not integration)', () => { + // The macos/windows ledgers would be a no-op for a coverage + // job that never runs on those runners; listing it there + // would imply OS-specific evidence that does not exist. + expect(activeEntries(MACOS_LEDGER_PATH)).not.toContain(INIT_REHOME); + expect(activeEntries(WINDOWS_LEDGER_PATH)).not.toContain(INIT_REHOME); + if (existsSync(INTEGRATION_LEDGER_PATH)) { + expect(activeEntries(INTEGRATION_LEDGER_PATH)).not.toContain( + INIT_REHOME, + ); + } + }); + + test('carries OWNER + EXPIRY metadata (issue #2477 Check 7)', () => { + const raw = readFileSync(GENERAL_LEDGER_PATH, 'utf8').replace( + /\r\n/g, + '\n', + ); + const lines = raw.split('\n'); + const entryIdx = lines.findIndex((l: string) => l.trim() === INIT_REHOME); + expect(entryIdx).toBeGreaterThan(-1); + const blockAbove: string[] = []; + for (let i = entryIdx - 1; i >= 0; i -= 1) { + const above = lines[i] ?? ''; + if (above.trim() === '' || /^\s*#/.test(above)) { + blockAbove.push(above); + } else { + break; + } + } + const block = blockAbove.reverse().join('\n'); + expect(block.includes('# OWNER:')).toBe(true); + expect(block.match(/#\s*EXPIRY:\s*\d{4}-\d{2}-\d{2}/) !== null).toBe( + true, + ); + }); + + test('the quarantined path exists and is discovered by the ci.yml find chain', () => { + expect(existsSync(join(REPO_ROOT, INIT_REHOME))).toBe(true); + }); + }); + + describe('bun-compat-exit-first-2530.test.ts (macos-latest, unit-shard 5, hard fail)', () => { + test('is an active entry in the macOS ledger (single-OS evidence, hard failure)', () => { + // The flake originated on macos-latest unit-shard 5 + // (CI run 34670762927, 2026-09-12T03:57:26Z, Attempt 1 failed, + // Attempt 2 failed → ::error file=...::FAILED). The failing + // assertion at + // tests/unit/utils/bun-compat-exit-first-2530.test.ts:450-454 + // (`native Bun reports bounded output overflow and terminates + // the child`) — native Bun on macos-latest returns both + // exitCode 0 and signalCode null after the bounded-output + // termination path, defeating the + // `receipt.exitCode !== 0 || receipt.signalCode !== null` + // expectation. Sibling shards were green or did not run the + // file (round-robin shard distribution). + expect(existsSync(MACOS_LEDGER_PATH)).toBe(true); + expect(activeEntries(MACOS_LEDGER_PATH)).toContain(BUN_COMPAT_EXIT_FIRST); + }); + + test('is scoped to the macOS ledger only (not general, not windows, not integration)', () => { + expect(activeEntries(GENERAL_LEDGER_PATH)).not.toContain( + BUN_COMPAT_EXIT_FIRST, + ); + expect(activeEntries(WINDOWS_LEDGER_PATH)).not.toContain( + BUN_COMPAT_EXIT_FIRST, + ); + if (existsSync(INTEGRATION_LEDGER_PATH)) { + expect(activeEntries(INTEGRATION_LEDGER_PATH)).not.toContain( + BUN_COMPAT_EXIT_FIRST, + ); + } + }); + + test('carries OWNER + EXPIRY metadata (issue #2477 Check 7)', () => { + const raw = readFileSync(MACOS_LEDGER_PATH, 'utf8').replace( + /\r\n/g, + '\n', + ); + const lines = raw.split('\n'); + const entryIdx = lines.findIndex( + (l: string) => l.trim() === BUN_COMPAT_EXIT_FIRST, + ); + expect(entryIdx).toBeGreaterThan(-1); + const blockAbove: string[] = []; + for (let i = entryIdx - 1; i >= 0; i -= 1) { + const above = lines[i] ?? ''; + if (above.trim() === '' || /^\s*#/.test(above)) { + blockAbove.push(above); + } else { + break; + } + } + const block = blockAbove.reverse().join('\n'); + expect(block.includes('# OWNER:')).toBe(true); + expect(block.match(/#\s*EXPIRY:\s*\d{4}-\d{2}-\d{2}/) !== null).toBe( + true, + ); + }); + + test('the quarantined path exists and is discovered by the ci.yml find chain', () => { + expect(existsSync(join(REPO_ROOT, BUN_COMPAT_EXIT_FIRST))).toBe(true); + }); + }); + + describe('repository-validation-real-process-2675.test.ts (already quarantined by issue #2738)', () => { + test('is NOT duplicated into the general or windows ledgers by this PR', () => { + // Issue #2730 listed this path, but it is already an active + // entry in scripts/ci/quarantined-tests-macos.txt via + // issue #2738 (commit ad8c53ae3, 2026-09-12). The + // flake-detection script's Rule A drops already-quarantined + // candidates, so re-listing it in another ledger would be a + // silent no-op for detection but a confusing cross-ledger + // duplicate for triage. (It IS present in the macOS ledger; + // that is the existing #2738 entry, not a new one from this + // PR.) + expect(activeEntries(GENERAL_LEDGER_PATH)).not.toContain( + REPO_VALIDATION_REAL_PROCESS_2675, + ); + expect(activeEntries(WINDOWS_LEDGER_PATH)).not.toContain( + REPO_VALIDATION_REAL_PROCESS_2675, + ); + }); + + test('remains in the macOS ledger (carried over from issue #2738)', () => { + // Sanity check: the existing macOS-ledger entry survives this + // PR's edit. The PR only adds entries; it does not move + // pre-existing ones. + expect(activeEntries(MACOS_LEDGER_PATH)).toContain( + REPO_VALIDATION_REAL_PROCESS_2675, + ); + }); + }); +});