Repository navigation
Description
Summary
pm-stack/opencode-usage-export/opencode-usage-export.mjs:383 still uses the pre-#2083 raw-path entry-point check:
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
const { exitCode, doc } = await run({ argv: process.argv.slice(2) });
...
}This is the same bug class as #2083 / #2235 / #2350. process.argv[1] is the path as invoked; import.meta.url is the resolved module URL. Through a file symlink or a path through a symlinked directory (the fleet's own ~/code -> ~/git/code alias), they never match, so the CLI body never runs and the process exits 0 with no output and no files written.
It survived #4325 because that issue scoped itself to four named files (codedb bridge, Supabase and Cloudflare exporters, claimant installer). #4325 has since been fixed and closed by PR #4583 (merge b7d274c08), whose own acceptance grep therefore does not hold repo-wide: this instance is the only raw compare left in the repo after that merge.
Evidence (origin/main b7d274c08, laptop, 2026-11-03)
git grep -nE "pathToFileURL\(process\.argv\[1\]\)|resolve\(process\.argv\[1\]\)" origin/main returns exactly one hit:
origin/main:pm-stack/opencode-usage-export/opencode-usage-export.mjs:383
Live probe with a scratch HOME and --out-dir (no credentials needed):
- Direct:
node pm-stack/opencode-usage-export/opencode-usage-export.mjs --out-dir <scratch>→ exit 3, stdout{"status":"store-missing","exitCode":3}, failure document written (latest.json,history.jsonl). - Via a file symlink: exit 0, no stdout, no stderr, out-dir empty.
- Via a symlinked directory: exit 0, no stdout, no stderr, out-dir empty.
So the exporter's failure-visibility design (always write a store-missing / no-token document so consumers can tell "source down" from a reading) is defeated by symlinked invocation: a timer tick through a symlink leaves latest.json silently stale and the unit green.
Acceptance criteria
- The entry-point check compares real paths (
fs.realpathSyncon both sides, as inbin/proxy-supervise.mjsand now the four files fixed by fix: handle symlinked entry points (#4325) #4583), or an equivalent. Do not use the raw-path compare. - Direct, file-symlink and directory-symlink invocations all run
main()and write the samestore-missingdocument with exit 3 in the no-store case. - Importing the module as a library still does not run
main()(its test suite atpm-stack/opencode-usage-export/opencode-usage-export.test.mjsdoes this). - A regression test covers file-symlink and directory-symlink invocation plus inert import, so the check cannot regress again.
-
git grep -nE "pathToFileURL\(process\.argv\[1\]\)|resolve\(process\.argv\[1\]\)"on the fix branch is empty (meta-exporter instance, if it reappears, is meta-exporter: meta-quota-export still uses the pre-#2083 raw-path entry-point check — invoked via any symlink it silently no-ops with exit 0 #2350, not this issue).
Related: #4325 + PR #4583 (the four sibling files, merged), #2083, #2235, #2350.
Merge Danger
Door: one-way. Blast Radius: narrow — entry-point detection only; imported-module behavior unchanged. No credential or token path is touched.
Found by repo-health queue triage task 8376 (openchamber scheduled lane).
Activity
dezren39 commentedon Nov 3, 2026
agent-note:v1
state: filed
task: 8376 (repo-health-code-pilot, lane c8b9355e-319a-4640-8096-7ad19480d151)
found via: triage of #4325 — its four-file scope left this instance behind; PR #4583 merged as b7d274c and closed #4325, and the issue's acceptance grep then still returned exactly this file.
next: enqueued task 8765 (small_fix, repo-health-code-pilot) with pinned scope — realpathSync entry guard, file/directory symlink + inert-import regression tests, repo-wide grep clean.
dezren39 commentedon Nov 3, 2026
agent-note:v1
event: picked-up
task: 8765 (repo-health-code-pilot; worker repo-worker-code; lane bf419306-c4ef-470f-a553-beabf93239de)
state: claimed; revalidated
verified: Fresh GitHub checks show #5099 OPEN; PR #4583 is MERGED at b7d274c; no PR currently matches #5099. No hard-stop labels are present. No competing PR or branch owner found in GitHub state.
next: inspect/resume task worktree if present, otherwise fast-forward ~/git/code main and create ~/git/fleet/task-8765 on branch queue/8765-5099-usage-export-realpath; reproduce, fix the entry guard, add symlink/inert-import regression tests, then run the targeted test and repo-wide grep.
expectation: effort/xs; complete with fresh issue/PR state and tests recorded.
dezren39 commentedon Nov 3, 2026
agent-note:v1
event: done
task: 8765 (repo-health-code-pilot; worker repo-worker-code; lane bf419306-c4ef-470f-a553-beabf93239de)
state: PR opened; queue task complete
result: PR #5184 is OPEN from queue/8765-5099-usage-export-realpath at ef3ed8c. Replaced the raw-path entry-point check with realpathSync and added direct/file-symlink/directory-symlink execution plus inert-import regression coverage.
verified: node --test pm-stack/opencode-usage-export/opencode-usage-export.test.mjs — 6 passed, 0 failed; repository-wide raw argv-path guard grep clean; git diff --check passed. Fresh PR state is OPEN; checks have not reported yet. Issue #5099 stays open for PR #5184 to close on merge.
labels: removed the queue/claimed, status/in-progress and work/assigned labels set for this claim.