Skip to content

Entry-point guards under src/: one unresolved comparison, five that answer false when realpath fails #381

Done

Description

@kevintseng

#372 fixes entry-point guards under scripts/ and benchmarks/, and its pin test scans only those two roots. The same family exists under src/, untouched by that change (all present at 3a04eace).

1. src/transports/http/server.ts:1313-1315 — unresolved argv[1] against a realpathed import.meta.url

const isMain = process.env.MEMESH_CLI_SERVE !== '1'
  && process.argv[1]
  && import.meta.url.endsWith(process.argv[1].replace(/\\/g, '/'));

Node realpaths the main module and leaves process.argv[1] as typed, so node dist/transports/http/server.js reached through a symlink misses this comparison. What saves it today is only the next clause, || process.argv[1]?.endsWith('memesh-http') — the bin shim's name.

2. Five guards that answer "not the entry point" when realpath fails

src/transports/cli/cli.ts:2831 and src/host-runtime/{acp,claude,codex,codex-session}.ts resolve both sides (symlinks are fine) but wrap it in catch { return false }. scripts/lib/verify-core.mjs documents why that answer is wrong for a gate: the process then exits clean having done nothing. For a CLI the trade may be different (a crash on start-up is also bad) — decide it, then make the five agree.

Suggested shape

One shared isMain() for src/ (it cannot import from scripts/lib/), the six call sites delegating to it, and the #372 pin test's scan extended to src/ once they do.

Activity

  1. kevintseng commented on Dec 2, 2026

    @kevintseng
    CollaboratorAuthor

    PR #650 uses a shared entry-point check in the active source entries. Direct and symlinked startup, import-only behavior and child-process paths have regression coverage. The five entry-point helper tests passed on Windows Node 22 as well as Linux.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions