Skip to content

docs(spawn): canonical vs parallel model + 5-tier team resolution - #1188

Merged
automagik-genie merged 1 commit into
devfrom
docs/tui-spawn-dx-canonical-parallel-model
Apr 18, 2026
Merged

automagik-genie merged 1 commit into
devfrom
docs/tui-spawn-dx-canonical-parallel-model

Conversation

@automagik-genie

Copy link
Copy Markdown
Contributor

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

  • New: `docs/SPAWN-TEAM-RESOLUTION.md` — single-source page for the four identities (canonical / parallel / team / generic spawn), the state machine (missing → create; dead → resume; alive → parallel `-`), the 5-tier precedence, the short-id collision policy, and a worked "simone reproducer" example. Every claim cites source file + line number.
  • Updated: `docs/CLI-REFERENCE.md` — `genie spawn` section now carries a state-gated outcome table, the precedence table, and canonical/parallel examples. Links to the new authoritative page.
  • Updated: `docs/SPAWN-AUTO-RESUME.md` — callout tying auto-resume to the canonical-UUID invariant; flags parallels as off the bare-name resume path.
  • Updated: `docs/ARCHITECTURE.md` — one-liner in the TUI section: "a skin over the CLI, not an alternate control plane".

Source citations (re-verify if source moves)

Symbol File Line
`resolveTeamName` `src/term-commands/agents.ts` 1675
`pickParallelShortId` `src/term-commands/agents.ts` 1725
`resolveSpawnIdentity` `src/term-commands/agents.ts` 1783
`findTeamsContainingAgent` `src/lib/claude-native-teams.ts` 195

Validation

  • Every cited symbol grep-findable in source.
  • `git diff --name-only dev...HEAD` contains only `.md` files.
  • Markdown fences balanced across all 4 files.
  • Pre-push full suite: 2630 pass / 0 fail.

Test plan

  • CI Quality Gate green.
  • Reader unfamiliar with the codebase can answer "what happens if I run `genie spawn simone` while simone is alive?" after reading only `SPAWN-TEAM-RESOLUTION.md`.
  • No claim in the docs contradicts current behavior on `dev` HEAD.

Wish: `.genie/wishes/tui-spawn-dx-docs/WISH.md` (workspace-local).

🤖 Generated with Claude Code

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>
@coderabbitai

coderabbitai Bot commented Apr 18, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 09b22f08-f985-4fdc-8afc-87a37d4d9cae

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/tui-spawn-dx-canonical-parallel-model

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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).

Suggested change
| **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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
`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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
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

@automagik-genie
automagik-genie merged commit dbba248 into dev Apr 18, 2026
6 checks passed
@automagik-genie
automagik-genie deleted the docs/tui-spawn-dx-canonical-parallel-model branch September 25, 2026 04:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant