Skip to content

opencode-usage-export: the fifth raw-path entry-point check — symlinked invocation silently no-ops with exit 0 (survived #4325 due to its four-file scope) #5099

Open

Description

@dezren39

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

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

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    priority/normalOrdinary priority (the default)
    queue/queuedHas a queued task in the Supabase agent queue
    effort/xsTrivial: expected under 30 minutes of work
    app/pm-stackpm-stack (Pad/Grist) in developing-today/code
    on Nov 3, 2026
  2. dezren39 commented on Nov 3, 2026

    @dezren39
    MemberAuthor

    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.

  3. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed
    queue/queuedHas a queued task in the Supabase agent queue
    on Nov 3, 2026
  4. dezren39 commented on Nov 3, 2026

    @dezren39
    MemberAuthor

    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.

  5. dezren39 commented on Nov 3, 2026

    @dezren39
    MemberAuthor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

app/pm-stackpm-stack (Pad/Grist) in developing-today/codeeffort/xsTrivial: expected under 30 minutes of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions