Skip to content

bundle stage fails from any cwd other than the engine checkout: tsx resolves the @/ alias from the caller's directory #470

Description

@swapnilpaliwal-sd

run-souffle.sh launches the bundle stage as node_modules/.bin/tsx src/bundle/cli.ts. cli.ts
imports its neighbours through the @/ path alias declared in tsconfig.json. tsx resolves that
alias from the tsconfig it discovers relative to the process's working directory, not relative
to the script it was given. So the stage works when the caller's cwd is the engine checkout — which
is how the three regression suites invoke it — and fails from any other directory with

Error: Cannot find module '@/bundle/build'
Require stack: …/src/bundle/cli.ts

Soufflé has already solved by then; raw/ is complete and the run reports "solve failed" for
what is a module-resolution fault in the last step.

Reproduce

cd /tmp
bash <engine>/src/pipeline/run-souffle.sh --language python \
     --client-ir <ir> --library <empty> --intermediate <int> --output <out>

<out>/raw/ is written; <out>/graph.sqlite is not. Run the identical command with cd <engine>
first and the bundle appears.

Why it matters

Every consumer other than the suites runs the executor from the analysed repository, not from
the engine checkout — a skill, a CLI wrapper, an agent's working directory. The dist/bundle/cli.js
path (taken when tsx is absent) does not have this problem, so an installed package is fine and a
development checkout is the one that breaks, which is the reverse of what a developer expects.

Fix

Either cd "$PKG" (with every path already absolute, which they are) before invoking the stage,
or point tsx at the config explicitly (--tsconfig "$PKG/tsconfig.json"), or drop the alias in
src/bundle/* for relative imports so resolution does not depend on a config file being found.

Activity

  1. added
    bugSomething isn't working
    buildBuild, packaging and developer setup
    platformOS / toolchain portability
    on Sep 14, 2026
  2. suyashpaliwal26 commented on Sep 14, 2026

    @suyashpaliwal26
    Collaborator

    Reproduced on TypeScript too, from the callgraph-benchmark adapter (cwd = the benchmark checkout), engine d54837c, Node 24.11.1: run-souffle.sh --language typescript on the benchmark's TS torture subject solves (116 s, out/raw/call-chain-edges.csv 72 rows), then exits 1 with Cannot find module '@/bundle/build'.

    Verified workaround, no change to the checkout: TSX_TSCONFIG_PATH=<engine>/tsconfig.json in the environment.

    $ cd /tmp && <engine>/node_modules/.bin/tsx <engine>/src/bundle/cli.ts --print-schema
    Error: Cannot find module '@/bundle/build'
    $ cd /tmp && TSX_TSCONFIG_PATH=<engine>/tsconfig.json <engine>/node_modules/.bin/tsx <engine>/src/bundle/cli.ts --print-schema
    # The output bundle — schema
    

    With that set, the benchmark ran axiom end to end on kysely (1,907/2,452 exact, unchanged from engine 9f5e90e). Exporting it inside run-souffle.sh before the bundle stage is a one-line fix.

  3. suyashpaliwal26 commented on Sep 14, 2026

    @suyashpaliwal26
    Collaborator

    Reproduced from the call-graph benchmark, which runs run-souffle.sh from its own work directory, on engine 69a0383 with npm ci done in the engine checkout:

    Error: Cannot find module '@/bundle/build'
    Require stack:
    - …/axiom-code-graph/src/bundle/cli.ts
    

    The solve itself completes (Elapsed (solve): 36s). The bundle stage then exits non-zero, so every caller sees the whole run as failed.

    A workaround needing no code change, verified on the Java and TypeScript torture subjects and on maven-core:

    TSX_TSCONFIG_PATH=<engine>/tsconfig.json bash <engine>/src/pipeline/run-souffle.sh …
    

    (tsx 4.23.1 honours it.) A robust fix inside the script would be to export TSX_TSCONFIG_PATH="$PKG/tsconfig.json", or pass --tsconfig "$PKG/tsconfig.json", just before invoking "${BUNDLE[@]}".

  4. suyashpaliwal26 commented on Sep 14, 2026

    @suyashpaliwal26
    Collaborator

    Downstream impact, for triage: this is one of the two reasons the call-graph benchmark currently reports no axiom row at all, in Java or TypeScript (AxiomCodeAI/callgraph-benchmark#81). The benchmark invokes run-souffle.sh from its own repository root, so the bundle stage fails with Cannot find module '@/bundle/build' before the adapter runs. Reproduced at engine d54837c and 69a0383 from callgraph-benchmark 85533cd. TSX_TSCONFIG_PATH=<engine>/tsconfig.json works around it, and with that set the scores reproduce the committed rows (details in the benchmark issue). Not re-tested after #469 moved the stage to graph/bundle/cli.ts.

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

Metadata

Metadata

Labels

bugSomething isn't workingbuildBuild, packaging and developer setupplatformOS / toolchain portability

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions