Repository navigation
docs(spawn): canonical vs parallel model + 5-tier team resolution - #1188
Conversation
Closes #1166. Carved-out doc deliverable from the tui-spawn-dx wish (PR #1172). Code-only — zero .ts/.tsx/.js in the diff; all changes under docs/. - **New**: docs/SPAWN-TEAM-RESOLUTION.md — single-source page covering the four identities (canonical / parallel / team / generic spawn), the state-gated spawn state machine (missing → create; dead → resume; alive → parallel <name>-<s4>), the five-tier team-resolution precedence (options.team → agent.entry.team → GENIE_TEAM → discoverTeamName → findTeamsContainingAgent), the short-id collision extension policy, and a worked "simone reproducer" example. Every claim cites source file + line number (resolveTeamName at src/term-commands/agents.ts:1675; pickParallelShortId at :1725; resolveSpawnIdentity at :1783; findTeamsContainingAgent at src/lib/claude-native-teams.ts:195). - **Updated**: docs/CLI-REFERENCE.md — `genie spawn` section gains a state-gated outcome table, the five-tier precedence table, and canonical/parallel CLI examples. Links to SPAWN-TEAM-RESOLUTION.md as the authoritative source. - **Updated**: docs/SPAWN-AUTO-RESUME.md — adds a callout tying auto-resume to the canonical-UUID invariant, links to SPAWN-TEAM-RESOLUTION.md, and flags that parallels are off the bare-name auto-resume path. - **Updated**: docs/ARCHITECTURE.md — one-liner in the TUI directory section: "a skin over the CLI, not an alternate control plane". Links to SPAWN-TEAM-RESOLUTION.md. Validation (all passed): - Every symbol cited in the docs is grep-findable in source at the cited file. - Diff contains only .md files (no code). - Markdown fences balanced across all 4 files. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces comprehensive documentation for the genie spawn command and the team resolution logic, centered around the new SPAWN-TEAM-RESOLUTION.md file. The changes detail the state-gated spawn model (canonical vs. parallel), the five-tier team-resolution precedence chain, and the handling of short-ID collisions. Updates were also made to existing documentation to ensure consistency. Review feedback identified several areas for technical clarification, specifically regarding the definition of generic spawns, the orchestration of the spawn state machine, and the use of clearer terminology to distinguish between ID prefix lengths and resolution tiers.
| | **Canonical agent** | `<name>` | stable, lives forever | **yes** — `genie spawn <name>` when canonical is dead | endless | | ||
| | **Parallel** | `<name>-<s4>` (e.g. `simone-a3f7`) | fresh per parallel | **no** — only `genie spawn <name>-<s4>` revives it | semi-ephemeral; persisted, explicit-id resume only | | ||
| | **Team** | separate `teams` table | — | — | grouped lifecycle: leader + members, own tmux session, own worktree | | ||
| | **Generic spawn** | `<team>-<role>` via `genie agent spawn <role> --team <t>` | fresh | depends on role | ad-hoc workers within a team | |
There was a problem hiding this comment.
The description of 'Generic spawn' as <team>-<role> is slightly inaccurate for the default behavior. In the current implementation, genie agent spawn <role> --team <t> follows the state machine (canonical/parallel). The <team>-<role> scheme is only used when an explicit --role is provided (legacy path).
| | **Generic spawn** | `<team>-<role>` via `genie agent spawn <role> --team <t>` | fresh | depends on role | ad-hoc workers within a team | | |
| | **Generic spawn** | <team>-<role> via explicit --role | fresh | depends on role | legacy multi-worker deployments | |
|
|
||
| ## Single-verb state machine | ||
|
|
||
| `resolveSpawnIdentity` in `src/term-commands/agents.ts:1783` is the state machine. It decides, based on the current `agents` table, whether `genie spawn <name>` creates canonical, resumes canonical, or creates a parallel. |
There was a problem hiding this comment.
The text attributes the following state machine diagram to resolveSpawnIdentity, but that function specifically handles the branches where a fresh UUID is minted (Canonical Create or Parallel Create). The 'RESUME' path is actually handled upstream by findDeadResumable. It would be clearer to state that the diagram represents the overall genie spawn <name> logic.
| `resolveSpawnIdentity` in `src/term-commands/agents.ts:1783` is the state machine. It decides, based on the current `agents` table, whether `genie spawn <name>` creates canonical, resumes canonical, or creates a parallel. | |
| The overall logic for genie spawn <name> follows this state machine (orchestrated by handleWorkerSpawn using findDeadResumable and resolveSpawnIdentity): |
| `pickParallelShortId` in `src/term-commands/agents.ts:1725` computes the parallel row id from the parallel's own fresh UUID: | ||
|
|
||
| ```ts | ||
| slice = uuid.slice(0, 4) // tier-4 (s4): 65 536 possibilities per name |
There was a problem hiding this comment.
The term tier-4 is confusing here as it might be mistaken for 'Tier 4' of the team-resolution precedence. Since this refers to the 4-character hex prefix length, using 4-char or similar would be more precise.
| slice = uuid.slice(0, 4) // tier-4 (s4): 65 536 possibilities per name | |
| slice = uuid.slice(0, 4) // 4-char prefix (s4): 65 536 possibilities per name |
Closes #1166. Carved-out doc deliverable from the `tui-spawn-dx` wish (PR #1172). Code-only — zero `.ts`/`.tsx`/`.js` in the diff; all changes under `docs/`.
Summary
Documents the single-verb state-gated spawn semantics and the five-tier team-resolution precedence that landed across PRs #1164 (tmux fallback), #1172 (four-tier resolver), and `40ec8bbd` + #1174 (on-disk fallback + auto-team-of-one). The canonical-UUID-per-name invariant established by `perfect-spawn-hierarchy` / `fix-ghost-approval-p0` is now discoverable from the docs rather than only from source.
Files
Source citations (re-verify if source moves)
Validation
Test plan
Wish: `.genie/wishes/tui-spawn-dx-docs/WISH.md` (workspace-local).
🤖 Generated with Claude Code