loop-engineering icon indicating copy to clipboard operation
loop-engineering copied to clipboard

loop-context budget resolution fails when node is absent from PATH

Open lhy-dcf opened this issue 3 weeks ago • 0 comments

Proposed Title

loop-context: pattern budget resolution fails when node is not on PATH

Problem

An application can start loop-context using an absolute Node executable path without exposing node on PATH. Both pattern budget resolvers nevertheless launch loop-cost with spawn('node', ...), so they fail despite an already-running compatible runtime.

This affects both --budget-from-pattern and --daily-budget-from-pattern, as well as the corresponding budget-resolver module APIs. It reports an error, rather than silently allowing a run.

Reproduction

  1. Use a checkout with installed loop-context/loop-cost dependencies and built dist.
  2. Launch tools/loop-context/dist/cli.js using an absolute Node executable, with an empty child PATH and a fresh working directory.
  3. Supply a valid ledger on stdin and --check --budget-from-pattern ci-sweeper --budget-level L2 --json. Repeat with --daily-budget-from-pattern ci-sweeper --daily-state-dir <temporary-directory>.

Actual on Windows, Node 22.16.0: exit 1, empty stdout, loop-context failed: spawn node ENOENT. An absolute-Node --version control succeeds in the same environment. Both resolver APIs also reject with ENOENT.

Expected: use the caller's running Node executable for loop-cost, resolve the budgets, and emit the usual breaker decision. A run above the resolved cap should escalate with exit 2.

Bounded Fix

Use process.execPath at the shared subprocess launch point. Add real subprocess regressions for both API paths and both CLI budget triggers. No dependency changes or changes to package resolution are needed.

Validation

Unmodified baseline: 62/62 package tests pass. Four new regressions fail before the fix and pass afterward; complete npm test passes 66/66. Only Windows/Node 22.16.0 and monorepo sibling resolution have been exercised. No issue has been published; this is a proposal only.

lhy-dcf avatar Nov 08 '26 05:11 lhy-dcf