BOHICA-LABS / BOHICA-LABS/vsdd-factory

enhancement(orchestrator): parallel agent bursts on factory-artifacts orphan branch race on staging area; commits co-mingle work from multiple agents

Open
#273 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
2
Forks
1
Avg merge
6h 43m
Merged PRs (30d)
29

Description

## Summary

Observed twice in one switchboard-blue session: when the orchestrator dispatches two agents in parallel that both touch the `factory-artifacts` orphan branch (mounted at `.factory/`), the second agent to commit may inadvertently include the first agent's still-unstaged changes.

**Occurrence 1:** spec-steward + state-manager parallel burst. spec-steward's `git add` picked up unstaged error-taxonomy.md drift from a prior burst, producing inadvertent commit `04eb5f5` followed by the intended `918acb4`.

**Occurrence 2:** PO + architect Wave 3 planning. Both committed at the same time; final commit `e6aa5ba` includes "10 files, 453 insertions" — the diff is the SUM of both agents' work, not either one's individual output. The commit message ("docs(arch): refresh ARCH for Wave 3...") attributes only to architect, but PO's BC-2.05.008, VP-058, error-taxonomy E-ADM-002 row update, and BC-INDEX update are all in the same commit.

## Why this happens

Both agents have write access to the same git worktree at `.factory/`. They:
1. `git status` → see no staging
2. Make file edits in parallel (file-level isolation: PO touches `BC-*.md`, architect touches `ARCH-*.md` — no overlap)
3. Both `git add` their own files
4. **But the second `git add` also picks up the FIRST agent's tracked modifications** (because they're now untracked-but-modified in the index)
5. Or both `git commit -m "..."` race, and one wins with the combined diff

## Impact

- **Commit attribution is wrong.** Reading the commit log doesn't tell you who did what.
- **Reverting becomes lossy.** `git revert e6aa5ba` rolls back two distinct work products.
- **Audit traceability degrades.** Cycle-closing-checklist relies on commits-per-agent for findings codification.

## Possible mitigations

1. **Serialize factory-artifacts bursts** — orchestrator-side rule. Adds <5 min latency per multi-agent burst. Simplest.
2. **Each agent stash-pushes the index before staging** — `git stash push --keep-index` before their first edit, pop after commit. Race-safe but operationally complex.
3. **Per-agent worktree on factory-artifacts** — mount multiple worktrees on the same orphan branch, one per agent. Git would refuse this (same branch). Could use ephemeral branches that fast-forward-merge into factory-artifacts.
4. **Atomic commit via plumbing** — agent writes its diff to a temp file and uses `git apply --cached` + `git commit` as an atomic sequence. Still races but smaller window.
5. **Pre-commit hook on factory-artifacts** that fails if the diff exceeds an agent-declared file allowlist.

## Recommendation

Document this as a known issue and implement option 1 (serialize) by default in the orchestrator prompts. Optionally migrate to option 5 (allowlist) once tooling matures.

## Reproduction

Switchboard-blue session `b8690230-7b5d-4e57-b71c-8b9ffeee3d9a`. Two confirmed occurrences. Likely silent on prior bursts that happened to have file-disjoint outputs.

## Related (this batch)

- drbothen/vsdd-factory#272 — P19: architect hallucinated internal/ packages

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.