#4547·career-ops

openrouter-runner reserves report numbers against the code root, overwriting existing reports

Author: abankar1Created Sep 28, 2026Updated Sep 28, 2026
Labelsbug🔧 scripts

Summary

openrouter-runner.mjs reserves report numbers by scanning the code root's reports/, then writes the report into the data root's reports/. So the allocator is asked whether a number is free somewhere the report will never be written, it answers yes for numbers already in use, and the write silently replaces an existing evaluation.

This is the failure the reservation exists to prevent, and it needs no race — one worker reaches it alone.

The rule the file states, and then breaks

openrouter-runner.mjs:173-180:

javascript
// Anchored to the career-ops data root, not to __dirname. scan.mjs resolves
// every path it touches through getCareerOpsRoot(), so with CAREER_OPS_DATA_DIR
// set this module was reading a DIFFERENT data/scan-history.tsv than the shared
// writers it now delegates to — dedup would clear a URL the writer then found
// present, or skip one it had never seen.
const DATA_ROOT = getCareerOpsRoot();

Four paths do not follow it:

javascript
// :697
reservedNumbers = await reserveReportNumbers(1, {
  rootDir: __dirname,
  reportsDir: path.join(__dirname, 'reports'),
});
// :740
await releaseReportNumbers(reservedNumbers, { reportsDir: path.join(__dirname, 'reports') });
// :786
const reportsDir = path.join(__dirname, 'reports');
// :91
const BLACKLIST_FILE = path.join(__dirname, 'data', 'model-blacklist.json');

reserve-report-num.mjs:35 defaults to getCareerOpsRoot(), so these options actively redirect it away from the correct root.

Measured

With reports/001-003 present in the data root and tracker row 3 pointing at 003:

runner options (code root)    -> [ 1 ]
allocator default (data root) -> [ 4 ]

The report is then written by writeFile() (:715), which resolves through DATA_ROOT. So the runner reserves 1 and overwrites {DATA_ROOT}/reports/001-acme-2026-01-01.md with a different company's evaluation. The tracker addition it writes alongside (:730) carries the same number, so merge-tracker links row 1 to a report that is now someone else's.

The allocator treats report files, sentinels, tracker row IDs and tracker report links as occupied, and all four of those live in the data root — so misdirecting it defeats every signal it has at once. AGENTS.md: "Never let parallel workers compute max+1 themselves — that is the #749 race." Here the allocator itself is misinformed, which is worse than a worker guessing.

The release call has the same directory, so the sentinel is dropped where the reservation never was, and the real one waits for the 4h GC.

The report lookup

:786 reads the same wrong directory, so a report this tool wrote cannot be found by its number. Reachable through the real CLI with no API key, since cmdApply resolves the report before any model call:

$ CAREER_OPS_DATA_DIR=$SB node openrouter-runner.mjs apply 1     # reports/001-… exists there
Report not found: 1

The model blacklist

:91 puts data/model-blacklist.json on the code root while everything else this module reads and writes goes through DATA_ROOT. Milder: a model rate-limited into the blacklist is remembered in the wrong place, so the rotation retries it after a restart and burns the same failure — the "survives process restarts" promise in its own comment.

Expected

All four resolve through getCareerOpsRoot(). With no env and no .career-ops-data marker, getCareerOpsRoot() returns the same directory __dirname did, so the default layout is byte-identical — as the comment at :173-180 already notes.

Related

Same class as #3511, #4208, #4211, #4348 and #4545 — a user-layer path pinned to the code root. This one is the most damaging of the set, because the collision destroys an existing report rather than reading an empty one.