feat: prevent parallel task file collisions for undeclared files (#70) (#70)#71
Merged
feat: prevent parallel task file collisions for undeclared files (#70) (#70)#71
Conversation
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.
Summary
This PR prevents parallel code-writer agents from silently colliding on undeclared files (e.g., test files) by updating the implementation-planner template to require explicit test file paths, adding a
detectBatchCollisions()utility toTaskQueue, and injecting sibling task file lists into code-writer context. Together, these changes close the loop on the file-overlap gap that caused issues like #24.Closes #70
Changes
src/agents/templates/implementation-planner.md: Added a rule requiring every task'sfileslist to include all test files it creates or modifies, and updated the example task block to demonstrate a test file alongside a source file.src/execution/task-queue.ts: AddedTaskQueue.detectBatchCollisions(tasks), a public static method that scans a batch of tasks for file-path collisions and returns human-readable descriptions of each colliding pair.src/agents/context-builder.ts: UpdatedContextBuilder.buildForCodeWriter()to accept an optionalsiblingFiles?: string[]parameter. When provided and non-empty, the files are included in the written context payload so code-writer agents are aware of files touched by sibling tasks.Implementation Details
The three source changes are independent and non-breaking:
detectBatchCollisions()is additive — it does not modifyselectNonOverlappingBatch()or any existing method.siblingFilesparameter is optional; all existing call sites that omit it continue to compile and behave identically.Testing
describe('detectBatchCollisions')block intests/task-queue.test.tswith 8 test cases covering: no collisions, single collision, multiple collisions, three-way collision, empty list, single-task batch, test-file collision, and exclusive file ownership.describe('buildForCodeWriter siblingFiles')block intests/context-builder.test.tswith 4 test cases covering: non-empty siblings included, omitted siblings absent, empty-array siblings absent, and base payload fields always present.describe('test file inclusion rule')block intests/implementation-planner-template.test.tswith 3 assertions verifying the updated template wording and example.Integration Verification
Notes
detectBatchCollisions()is currently a utility method. Calling it after each parallel batch (to emit warnings or fail fast) is a follow-up integration task not included in this PR.siblingFileslist must be populated by the caller (e.g., the orchestrator loop). This PR only wires up the context-builder side; the orchestrator plumbing is a follow-up.Cadre Process Challenges
buildForCodeWritersignature change required care to ensure the optional parameter didn't break existing call sites, but the TypeScript optional parameter pattern handled this cleanly.siblingFilesorchestrator plumbing (who collects sibling files and passes them tobuildForCodeWriter) was explicitly left out of scope. This created a slightly unsatisfying half-implementation — the context-builder accepts sibling files but nothing yet passes them in production. A clearer issue or acceptance criteria would have scoped this more precisely.Closes #70