Design doc only (no code). Diagnoses the agent-merge lock leak — locks are emergent git-diff state released only via autoship's forceReleaseLocks, so agent self-merges and non-default parents leak — and specifies a dedicated LockManager: parent-scoped lock domains, all-or-nothing acquisition with a demotion queue, merge-into-parent release (mediated + git-ancestry poll), update-on-grant merge, and nested worktrees with cascade re-target. Indexed in PLAN.md.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
M0 (the stream-json spike) was completed earlier but its code was left
uncommitted in a sibling worktree and never landed on any branch. This
commits it verbatim as the M1 baseline:
- NucleicCore: AgentEvent/JSONValue model, AgentBackend protocol,
ApprovalCoordinator, ProcessHost, Transcript writer/reader,
ClaudeStreamDecoder, in-process MCP approval server, ClaudeCodeBackend
- nucleic-spike CLI + fake-claude wire stub
- 41 hermetic tests (golden + contract + drift) and live captures under
fixtures/claude/2.1.167/
- PLAN.md / ADAPTERS.md updated with M0 findings; docs/M0_RESULTS.md
Built and tested with `swift build/test --build-system native` (iCloud
codesign workaround).
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>