Commit 4ab7218
feat: Phase 7 —
* feat: Phase 7 — `swarph spawn <role>` (v0.6.0)
Implements the operator-tooling layer of substrate-doc R7 §11.1.7
4-layer R2 mechanism stack (merged on hedge-fund-mcp main as a50d1a2
earlier today). Wraps `claude` with the three R5/R7 disambiguation
flags so sibling-cell instances on shared peer-id are distinguishable
at the session-resume layer.
What ships:
* `swarph spawn <role-or-path>` — exec-replaces with
`claude --name <role> --session-id <uuid> --append-system-prompt <starter>`
* `swarph_cli/cell.py` — cell.yaml v1 parser + Lineage shape +
atomic sidecar UUID persistence to $XDG_STATE_HOME
* cell.yaml schema FROZEN at `schema_version: "v1"` per drop-mother
review #890 (C2) — v0.7 swarph-shared migration is symbol-relocation
only, no field changes
* lineage block (parent_peer_id + spawn_manifest_signature) parsed
but not enforced — alpha #891 (D1) reserved shape for v2
cryptographic-lineage tier
* `--onboarding mesh-gateway://...` URL form parsed but raises
NotImplementedError — alpha #891 (D2) v0.6→v0.7 no-flag-change
upgrade path
* `./cell.yaml` auto-discovery in cwd — alpha #891 (D3)
* atomic UUID write (tempfile + fsync + rename) — drop-mother (C1)
load-bearing for R5 disambiguation; torn write would silently
regenerate on next spawn and defeat the primitive
* mitosis-cell ASCII banner per commander pick — explicitly nods to
§1.22 mitosis primitive (R6/R7)
Resolution precedence:
1. --onboarding <path-or-url> explicit override (alias: --cell)
2. positional ending .yaml/.yml literal path
3. positional plain role name $XDG_CONFIG_HOME/swarph/cells/<role>.yaml
4. no positional auto-discover ./cell.yaml in cwd
5. mesh-gateway://... v0.7+ NotImplementedError today
Falsifiability gates (substrate-doc R7 F4/F5 applied):
* F-spawn-1: swarph spawn <role> --dry-run --print-id idempotent
across consecutive calls (R5 invariant)
* F-spawn-2: cell.yaml-pinned session_id never touches sidecar
* F-spawn-3: corrupted sidecar regenerates rather than crashing
* F-spawn-4: dry-run output redacts long starter prompts
* F-spawn-5: provider != "claude" rejected with "v0.7+ feature" hint
Tests: 43 new tests pass, full suite 200 pass + 3 skipped (live-API
gates unaffected). End-to-end smoke verified — auto-discovery + UUID
mint + persist + reuse all working with real cell.yaml under /tmp.
Deferred to v0.7+:
* beta #892 (B1) auto-suffix on --name collision
* beta #892 (B2) --new-instance flag for sibling-spawn
* non-Claude provider spawn
* swarph-shared cell.yaml relocation (symbol-only refactor)
* SessionStart memory-injection hook (complementary to
--append-system-prompt per R7 §11.1.7.1 #1)
* S-G mesh-gateway:// URL implementation (substrate primitive)
Pre-PR consumer review:
* drop-mother #890 — C1-C5 production-context observer (CLEAN scope)
* drop-on-meta-edge alpha #891 — D1-D3 spawn-target consumer
* drop-on-meta-edge beta #892 — B1-B3 sibling-instance consumer
* alpha #893 concurrence on beta + cross-refs
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* docs: known-limitations note — single-instance-per-role at v0.6 (beta #897)
beta consumer-side review #897 surfaced the sibling-spawn case:
alpha + beta co-existing on `drop-on-meta-edge` peer-id cannot be
reproduced via v0.6 spawn because the sidecar resolution always
reuses the first-minted UUID. Multi-instance sibling spawn requires
v0.7's --new-instance flag (already deferred per §18.6).
Manual sibling workflow (tmux + explicit --session-id pinning) still
works unchanged — v0.6 does not regress that path, it just doesn't
yet expose a CLI shape for it.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>swarph spawn <role> (v0.6.0) (#8)1 parent 39cafee commit 4ab7218
8 files changed
Lines changed: 1295 additions & 11 deletions
File tree
- src/swarph_cli
- commands
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
28 | 29 | | |
29 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
30 | 85 | | |
31 | 86 | | |
32 | 87 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
| 7 | + | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
36 | 40 | | |
37 | 41 | | |
38 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
0 commit comments