fix(H-1): auto-serialize parallel pkg-manager/file-edit steps via inferred resource locks#122
Merged
Merged
Conversation
…ce locks - Fix 1: Update BLOCKS_PLANNER_SYSTEM with hard constraint that package-manager steps (npm install, yarn, pnpm, pip, cargo, go get, etc.) must declare file:WRITE:<manifest> resources and must never be parallelised with steps that edit the same manifest file. Also requires file-edit/file-write steps to declare their file:WRITE resources explicitly. - Fix 2: Add inferMissingResources() in compiler.ts that auto-infers file:write:<manifest> resource locks from step descriptions (matching package-manager patterns) and from toolsNeeded (file-edit/file-write tool + manifest file name in description). compileBlocksPlanToDag() now merges inferred resources into every step node so the scheduler enforces serialisation even when the planner omits the resource hints. - Fix 3: Export detectPkgManifestConflicts() from compiler.ts for post-plan validation. planNode in graph.ts calls it after parsePlanOutput and logs a structured warning when a parallel branch pair contains a pkg-manager step and a file-edit step without proper serialisation. - 19 new unit tests covering inferMissingResources, compiler inference integration, scheduler serialisation of the H-1 scenario, and detectPkgManifestConflicts. Agent-Logs-Url: https://github.com/huberp/agentloop/sessions/9a3f05ac-a1f7-4956-a137-7c0bae9b4d4f Co-authored-by: huberp <4027454+huberp@users.noreply.github.com>
…malisation comment Agent-Logs-Url: https://github.com/huberp/agentloop/sessions/9a3f05ac-a1f7-4956-a137-7c0bae9b4d4f Co-authored-by: huberp <4027454+huberp@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix concurrent mutations of package.json in parallel branches
fix(H-1): auto-serialize parallel pkg-manager/file-edit steps via inferred resource locks
Apr 25, 2026
huberp
approved these changes
Apr 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The scheduler's file-write exclusion mechanism was silently bypassed whenever the planner LLM omitted
resourceshints — allowingnpm installandfile-edit package.jsonto run concurrently and produce an inconsistent manifest/lockfile state.Changes
src/langgraph/graph.ts— Planner hard constraintsBLOCKS_PLANNER_SYSTEM: package-manager commands (npm install,yarn,pnpm,pip install,cargo build,go get,bundle) must declareresources: ["file:WRITE:<manifest>"]and must not be placed in the same parallel block as steps that edit that manifest;file-edit/file-writesteps must declare their write targets.src/langgraph/compiler.ts— Structural safety netinferMissingResources()(exported): detects pkg-manager invocations indescriptionandfile-edit/file-writetool use mentioning a known manifest, then produces the missingfile:write:<manifest>lock strings.compileBlocksPlanToDag(): merges inferred resources into every compiled step node so the scheduler enforces serialisation regardless of what the planner emitted.detectPkgManifestConflicts()(exported): post-plan scan that identifies parallel branch pairs with a pkg-manager step vs. a file-edit step sharing a manifest without a declared lock; called fromplanNodeto emit a structuredwarn.Inference example (H-1 scenario)
Tests
19 new unit tests covering
inferMissingResources(all supported package managers, file-edit+manifest, no-op cases), the H-1 scheduler serialisation scenario end-to-end, anddetectPkgManifestConflicts(conflict, sequential, unrelated branches).Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
duckduckgo.com/usr/local/bin/node /usr/local/bin/node /home/REDACTED/work/agentloop/agentloop/node_modules/jest-worker/build/processChild.js(dns block)/usr/local/bin/node /usr/local/bin/node /home/REDACTED/work/agentloop/agentloop/node_modules/jest-worker/build/processChild.js tnet/tools/git git bran�� -v -d ','x')}catch(e){} --local user.email /snap/bin/git git s__/��(dns block)If you need me to access, download, or install something from one of these locations, you can either: