Skip to content

H-1 · Parallel Branches s4 + s5 Both Mutate package.json Concurrently Without Resource Locks #121

@huberp

Description

@huberp

Reference: huberp/agentloop · run 24935457632 · job 73020142658 step 6
Sorted by: criticality (Critical → High → Medium → Low)

H-1 · Parallel Branches s4 + s5 Both Mutate package.json Concurrently Without Resource Locks

Log evidence (lines 230-240):

runnable: ["p1.b0.s4", "p1.b1.s5"]   ← dispatched simultaneously

s4 (npm install @anthropic-ai/sdk):
  → npm error ETARGET No matching version found for @anthropic-ai/sdk@^0.25.3
  → retry: npm install @anthropic-ai/sdk@latest → installed

s5 (file-edit package.json, adding @anthropic-ai/sdk ^0.25.3):
  → success (wrote stale/conflicting version string)

Both steps ran in parallel and both modified package.json. npm install @latest rewrote the lockfile and package.json at the same time as file-edit inserted ^0.25.3. The result is a package.json with ^0.25.3 in dependencies but @latest in node_modules (and possibly the lockfile) — an inconsistent state.

Root cause: The scheduler in src/langgraph/scheduler.ts has a correct file:write: locking mechanism, but it is entirely inert here because the planner LLM never emitted resources: ["file:WRITE:package.json"] hints in the plan. The scheduler can only protect what is declared.

Structural problem: Resource hints are purely advisory and LLM-generated. The planner has no enforced obligation to declare them, and the schema hint in BLOCKS_PLAN_SCHEMA_HINT only shows them as an example. The consequence is that the entire write-conflict protection system is silently bypassed whenever the planner omits resources.

Actionable fixes:

  1. Add npm-install to serial-only steps: Instruct the planner explicitly — "Steps that run npm install, pip install, cargo build, or any package manager command must never be parallelised with steps that edit the corresponding manifest file." Add this as a hard constraint in BLOCKS_PLANNER_SYSTEM.
  2. Infer file locks from toolsNeeded: In compileBlocksPlanToDag, if toolsNeeded contains file-edit or file-write, mark the step as potentially writing to files and prevent its parallelisation with npm-install steps automatically.
  3. Post-plan validation: After the planner produces the plan, validate that no parallel branch pair contains one npm-install-like step and one file-edit step without a declared resource lock, and trigger refinement if so.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions