Skip to content

ci: the directory report depends on file listing order when overlapping snapshots tie #4131

Open

Description

@schlessera

Part of #2948.

Observed

bun scripts/ci-timings.ts report --out <dir> reads snapshots in directory-listing order (readSnapshots, readOperationalData in scripts/ci-timings.ts), and deduplicate keeps the later-read copy when two copies of one attempt have the same collectedAt. The hourly collector rewrites seeded snapshots with new PR attribution but keeps their collectedAt. Across the 39 retained artifacts created before 2026-10-24, 146 of 1,080 run attempts have same-time copies that differ in run.prs and run.attribution.

The same 39 artifacts, extracted into sibling directories and reported directly, gave coverage.unattributedCIAttempts 87 and pairedPRs 57. The archive built from them (#2955) gave 1 and 84, because compaction orders equal-time copies deterministically and lets the attributed copy win. Readdir order is filesystem-dependent, so the directory report can change between machines without any change in its inputs.

Context pointers (main 9e7429a91)

  • deduplicate (scripts/ci-timings.ts:202-215): at equal collectedAt, Date.parse(old) <= Date.parse(new) picks the later-read copy. It only back-fills run.prs from the older copy when the newer one has none and the older one was attributed by exact merged squash SHA.
  • readSnapshots (scripts/ci-timings.ts:352-360) and readOperationalData (scripts/ci-timings.ts:403-428) iterate readdir results in the order the filesystem returns them.

Scope

  • Make the directory report's result independent of listing order. Either sort what it reads deterministically, or make deduplicate's tie-break independent of input order. In both cases, at equal collectedAt the PR-attributed copy of an attempt wins.
  • Apply the same rule to the operational records readOperationalData merges, wherever their deduplication also depends on read order.

Out of scope

Acceptance criteria

  • The directory report gives the same summary for the same files whatever the listing order, proven by a test that reverses or shuffles the read order.
  • At equal collectedAt, the PR-attributed copy of an attempt wins, as it does in the archive.

Verification

  • A test in tests/ci-timings.test.ts that reads the same snapshot set in forward and reversed or shuffled order and gets the same summary. It fails on main before the change.
  • bun run test tests/ci-timings.test.ts tests/ci-timings-collection.test.ts.

Contract impact

None.

2026-11-17 triage: added source pointers, Scope, Out of scope and Verification from the observed behaviour. The acceptance criteria are unchanged.

Activity

  1. added
    type: fix
    area: ci
    on Nov 17, 2026
  2. added
    priority: p2
    agent-ready
    on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readyarea: cipriority: p2type: fix

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions