-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Currently, if two agents heartbeat at the same time and both see a task with status "ready", they could both mark it "in-progress" and start working on it. With file-based coordination there's no locking mechanism.
The problem
Markdown files have no atomic compare-and-swap. Two agents reading the same project note simultaneously will both see "ready" and both start work. This wastes compute and could produce conflicting results.
Possible approaches
-
Claim-by-edit race: First agent to successfully write "in-progress" wins. The second agent should check the status again after writing and back off if someone else claimed it. Simple but has a race window.
-
Agent-scoped assignment: Chief of staff writes the agent slug into the task entry (e.g., "Assigned: billing-dev"). Workers only pick up tasks assigned to them. Eliminates conflict but requires the coordinator to be active.
-
Lock files: Create a .lock file when claiming a task. Other agents check for the lock. Adds filesystem clutter.
-
Git-based CAS: If the team directory is a git repo, use commit-and-push as the atomic operation. Merge conflicts = claim conflicts. Elegant but requires git.
Discussion
Which approach fits the "simple markdown" philosophy best? Should the protocol spec take a position, or leave it to implementations?
This becomes more important as teams scale beyond 2-3 agents.