#4537·career-ops

flaky (macOS CI): followup-seed test 16 spends its 900ms grace window on process startup

Author: rubiconCreated Sep 27, 2026Updated Sep 28, 2026
Labelsbug⚙️ ci

What happened

followup-seed-tests.mjs test 16 fails on macos-latest and passes on ubuntu-latest and windows-latest in the same run.

Both of its assertions fail together:

FAIL 16. ownerless lock inside the grace period is not stolen → exit 4 — got 0
FAIL 16. the untouched lock directory survives — it was removed

47 passed, 2 failed. The suite exits 1, so test-all.mjs --quick reds the whole macOS job.

The stderr right after the failure carries ✅ Seeded #1: next follow-up 2026-06-27. The child took the lock and ran the seed, which is the exact behavior test 16 exists to forbid.

Observed on https://github.com/career-ops-hq/career-ops/actions/runs/36138015707/job/108080701472. That run belongs to a pull request whose diff touches generate-cover-letter.mjs and two cover-letter tests. Nothing in it reaches locks or follow-ups.

Root cause: a wall-clock budget the test does not control

Test 16 (followup-seed-tests.mjs:505-509) backdates the lock directory 100ms, then spawns the script with a 300ms acquire timeout:

javascript
const heldSince = new Date(Date.now() - 100);
utimesSync(sb.lock, heldSince, heldSince);
const res = run(['1'], sb, {
  CAREER_OPS_FOLLOWUPS_LOCK_STALE_MS: '10',
  CAREER_OPS_FOLLOWUPS_LOCK_TIMEOUT_MS: '300',
});

pipeline-lock.mjs:210 decides reclaimability like this:

javascript
Date.now() - statSync(lockDir).mtimeMs > Math.max(staleMs, OWNERLESS_GRACE_MS)

OWNERLESS_GRACE_MS is 1000 (pipeline-lock.mjs:38), and followup-seed.mjs:313 documents that its own staleMs is floored at it. So the test needs the child's last stale check to land under 900ms after utimesSync.

Four things spend that budget: execFileSync, Node startup, the module graph behind followup-seed.mjs, and up to 300ms of retries. Overspend it and the lock reads as reclaimable. The child then steals it, seeds, exits 0, and removes the directory. Both assertions fail at once, which is the signature in the log.

I measured the spawn half locally on macOS 27 with Node 26.10: 92ms for execFileSync plus the full module-graph import, stable across 3 runs. Local slack is therefore around 500ms and the test passes here. A hosted macOS runner has less margin and no local filesystem cache.

Test 17 asserts the opposite direction and passed in the same run, so the floor itself works. The window is the defect.

Why the test's own comment does not cover this

The comment above test 16 says:

Pinning both sides of the relation keeps the test off the wall clock

It pins the lower bound only. 100ms sits comfortably past staleMs: 10, so unfloored code still reclaims immediately and the test still falsifies. The upper bound is untouched. The age has to stay under 1000ms at the moment the child looks, and that depends on how long a process takes to start.

Three of the four knobs in this relation read the environment. timeoutMs, retryMs and staleMs all do, at pipeline-lock.mjs:374-376 and again at followup-seed.mjs:532-534. OWNERLESS_GRACE_MS is a bare constant, so the test can widen every side except the one that broke.

Steps to reproduce

  1. Run node followup-seed-tests.mjs on a machine where execFileSync plus Node startup plus 300ms of retries exceeds 900ms.
  2. Test 16 reports exit 0 where it expects 4, and its lock directory is gone.

It reproduces on demand by shrinking the headroom instead of waiting for a slow runner: raise heldSince toward 900ms in the past, or lower CAREER_OPS_FOLLOWUPS_LOCK_TIMEOUT_MS. Same defect, latency supplied by hand.

Expected behavior

Test 16's verdict should not depend on process startup latency.

Suggested fix

Give the grace floor an env override beside its 3 siblings:

javascript
export const OWNERLESS_GRACE_MS = Number(process.env.CAREER_OPS_OWNERLESS_GRACE_MS) || 1_000;

Test 16 then sets it to 30000 and test 17 keeps the default. Neither reads the clock for its verdict, and the production default is unchanged.

A cheaper mitigation is heldSince = new Date(), which spends none of the window up front. It stays falsifying, because staleMs: 10 is crossed during spawn on any machine. It narrows the dependency rather than removing it, so the override is the better fix.

Worth checking the same shape elsewhere while this is open. tests/pipeline-lock.test.mjs backdates by multiples of OWNERLESS_GRACE_MS rather than by a fixed 100ms, which is why it has not been hit.

Environment

  • OS: macos-latest runner. Measured locally on macOS 27.0 with Node 26.10.
  • CLI tool: not applicable, this is CI.