Skip to content

Flaky test: agy-auth-cache '#1077 re-probes after unauth TTL lapses' races TTL against process-spawn latency #1435

Open

Description

@amrmelsayed

Flake (diagnosed by the bugfix-1433 builder, 2026-08-12; hit PR #1434's CI)

packages/codev agy-auth-cache.test.ts '#1077 re-probes after unauth TTL lapses' sets a 50ms TTL, then awaits runLane - which spawns a process - before asserting the cache entry. Under CI load the spawn exceeds 50ms, the entry expires mid-test, the read returns null, and the assertion fails. Classic TTL-vs-latency race: the test is timing-dependent, not behavior-dependent.

Fix direction

Either inject a fake clock so TTL lapse is deterministic, or split the assertion: one test that the entry exists immediately post-write (no spawn in between), one that an EXPIRED entry re-probes (explicitly aged, not raced). Detail in codev/state/bugfix-1433_thread.md once that lane merges.

Impact

Fails unrelated PRs' Unit Tests job intermittently (observed PR #1434, run 2).

Activity

  1. added
    area/consult
    on Aug 12, 2026
  2. amrmelsayed commented on Aug 15, 2026

    @amrmelsayed
    CollaboratorAuthor

    Escalation: this flake has started turning main red, not just PR branches.

    At 2026-08-15T01:56:18Z the Tests workflow failed on main at 0fd90b8e0 (the merge commit of PR #1453), and the CI-health cron alerted on it. The failing job was Unit Tests, and the failure is this issue:

    FAIL src/commands/consult/__tests__/agy-auth-cache.test.ts
      > gemini lane burst behaviour (#1077 regression)
      > re-probes after the unauth TTL lapses, recovering once the user signs in
    AssertionError: expected null to be 'unauth'
    
    Test Files  1 failed | 244 passed | 3 skipped (248)
          Tests  1 failed | 4843 passed | 60 skipped (4904)
    

    One test out of 4,904. PR #1453 was assets plus a render script and touches nothing in the consult lane, and its own full check list was verified green before the merge — so this is the race, not a regression from that PR. Re-running the failed job.

    Why the change of venue matters more than the failure rate.

    A flake that reds a PR costs a rerun and an architect's attention. A flake that reds main does something worse: it destroys the meaning of the only signal we have for "is trunk healthy". Concretely, in the twenty-four hours around this:

    That is the failure mode worth pricing in: not the minutes lost to reruns, but the alarm being trained out of usefulness. The same argument was made about afx cleanup reporting a false "not found" (#1445) — our tooling's failure modes keep presenting as findings, and each one that goes unfixed makes the next real finding cheaper to ignore.

    Bumping this to the top of the consult queue on that basis. A test asserting behaviour that depends on wall-clock TTL against a spawn whose latency is unbounded in CI cannot be made reliable by tuning the margin; the fix direction is to make the clock injectable so the test controls it, rather than racing it.

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

    area/consult

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions