The previous implementation used session.Manager which only works for polecats.
Refinery and Witness have their own managers that handle their tmux sessions.
- Use refinery.Manager for refinery auto-start
- Use witness.Manager for witness auto-start
- Check state before starting to avoid duplicate starts
🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add handling for POLECAT_DONE messages in processShutdownRequests()
- Track which polecats have signaled done (using SpawnedIssues with "done:" prefix)
- For LIFECYCLE:shutdown requests, wait for POLECAT_DONE before cleanup
- Add checkPendingCompletions() to nudge polecats with closed issues
- Add 10-minute timeout with force-kill after waiting for POLECAT_DONE
- Protects against losing MR submissions when Witness cleans up too early
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implements redundant systems to ensure infrastructure stays operational:
- gt spawn: Auto-starts refinery and witness if not running
- mol-witness-patrol: Added check-refinery step to verify refinery is alive
This ensures polecats don't wait forever for merges.
🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
New checks:
- crew-state: Validates crew worker state.json files for completeness
Can regenerate missing/invalid state files with --fix
- lifecycle-hygiene: Detects stale lifecycle state that can wedge the deacon
- Stale lifecycle messages in deacon inbox
- Stuck requesting_* flags in state.json when session is healthy
Can clean up with --fix (external intervention when deacon is stuck)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Three related fixes:
1. lifecycle.go: Use gt mail delete instead of gt mail read to prevent
lifecycle requests from accumulating.
2. handoff.go: Return exec claude command for respawn-pane instead of
gt crew at which tries to attach to existing session.
3. handoff.md skill: Work without --cycle and -m flags, send mail separately.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add persistent state storage for Witness across wisp burns:
- Add WorkerState and WitnessHandoffState types
- Implement loadHandoffState/saveHandoffState for bead persistence
- Update getNudgeCount/recordNudge to use persistent state
- Add activity tracking integration into healthCheck
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When state.json contains empty JSON {}, the ClonePath and other fields
were left empty, causing "can't find pane/session" errors in gt crew at.
Now backfills essential fields (Name, Rig, ClonePath) if missing.
🤝 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implements a new command to query what an agent should be working on:
- Finds handoff bead by agent identity
- Parses attached molecule and tracks progress through steps
- Identifies current/next step (in_progress or first ready)
- Reports status: working, naked, complete, or blocked
Usage:
gt molecule current [identity]
gt mol current gastown/furiosa
gt mol current --json
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Rename outputCrewAttachmentStatus to outputAttachmentStatus and extend
to support both RoleCrew and RolePolecat. The Propulsion Principle
("If you find something on your hook, YOU RUN IT.") now applies to
all worker types, not just crew.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Apply the Universal Gas Town Propulsion Principle to all agent templates:
"If you find something on your hook, YOU RUN IT."
Changes:
- deacon.md.tmpl: Hook-first startup, no decision logic
- polecat.md.tmpl: Simplified propulsion startup, molecule-following
- witness.md.tmpl: Wisp slinging when spawning, propulsion loop
- refinery.md.tmpl: Accept slung branches, hook-based execution
Key principle: Agents don't decide whether to do work. They check their hook
and execute what's there. The hook IS the decision.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add git-state subcommand to gt polecat for Witness pre-kill verification.
Checks working tree, unpushed commits, and stashes to determine if a
polecat worktree is clean (safe to kill) or dirty (needs cleanup).
Usage: gt polecat git-state <rig>/<polecat> [--json]
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Uses tmux respawn-pane to kill and restart agent sessions in place,
bypassing the handoff/manager flow for quick context cycling.
Supports local recycle (current session) and remote recycle (other
roles) with automatic client switching.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Added --exit flag for exit type (COMPLETED, ESCALATED, DEFERRED).
When polecat runs gt done, it now sends mail to Witness with:
- Exit type (COMPLETED, ESCALATED, or DEFERRED)
- Issue ID (if available)
- MR ID (for COMPLETED)
- Branch name
For ESCALATED and DEFERRED, skips MR submission but still notifies
Witness. This enables Witness patrol to see completion in inbox-check
step, verify git state, and close polecat lease.
Paired with spawn notification (gt-r6td) to bracket polecat lifecycle.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When gt spawn creates a polecat, it now sends POLECAT_STARTED notifications
to both Witness and Deacon:
- Witness receives: "POLECAT_STARTED <polecat>" with issue and session info
- Deacon receives: "POLECAT_STARTED <rig>/<polecat>" with issue and session info
This enables:
- Witness to bond a lease to its patrol wisp
- Deacon to verify worker started (redundancy)
- Both to nudge if worker is idle at prompt
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Polecats already have synced beads at spawn time (spawn command syncs before
spawning). Multiple polecats starting simultaneously were all trying to sync
the same shared beads, causing git conflicts/failures.
Fixes gt-oiv0
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Remove redundant phrases like 'ephemeral wisp' and 'ephemeral molecule'
since wisp already implies ephemeral. Keep 'ephemeral' only where it is
definitional (explaining what wisps are) or contrasting (vs durable mol).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The deacon was being detected as Mayor because it started in ~/gt (town root).
Now starts in ~/gt/deacon/ so gt prime correctly detects RoleDeacon.
Also ensures deacon directory exists on start.
TUI improvements for Christmas launch:
- Add phase transition table and lifecycle diagram to `gt molecule --help`
- Add swarm lifecycle diagram to `gt swarm --help`
- Add mail routing diagram to `gt mail --help`
- Add sling mechanics diagram to `gt sling --help`
- Create Lipgloss table helper (internal/style/table.go)
- Migrate mq_list to use styled tables with color-coded priorities
- Migrate molecule list to use styled tables
- Add fuzzy matching "did you mean" suggestions for polecat not found errors
- Add suggest package with Levenshtein distance implementation
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Create internal/claude package with embedded settings templates
- settings-autonomous.json: gt prime && gt mail check --inject (SessionStart)
- settings-interactive.json: gt prime only (SessionStart)
- Update witness.go: EnsureSettings before session, remove broken gt prime injection
- Update refinery/manager.go: EnsureSettings before session, remove broken NudgeSession
- Update session/manager.go: EnsureSettings for polecats, remove broken issue injection
All autonomous roles (polecat, witness, refinery) now get proper SessionStart hooks
automatically when their sessions are created. No more timing-based gt prime injection.
- Remove 3-second sleep and NudgeSession from spawn.go
(Claude takes 10-20s to initialize, message arrived too early)
- Add trigger-pending-spawns step to deacon patrol molecule
(Deacon polls with WaitForClaudeReady, sends trigger when ready)
- SessionStart hook handles gt prime (internal, reliable)
- Deacon sends minimal 'Begin.' trigger to start polecat working
The spawn command now returns immediately after starting the session.
The deacon's patrol cycle will trigger the polecat when it's ready.
Detects when multiple gt-* tmux sessions share the same pane,
which causes messages sent to one session to appear in another.
This catches the bug where gt-deacon and gt-mayor shared a pane,
causing daemon heartbeats to appear as user input in the Mayor.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Updates crew worker startup to detect and auto-continue attached molecules:
- prime.go: Add outputCrewAttachmentStatus() that detects pinned beads
with attached molecules and outputs "AUTO-CONTINUE MODE" directive
- prime.go: Update startup directive to explain the auto-continue pattern
- crew.md: Add "Session Wisp Model" section documenting autonomous work
Key insight: if attached work exists, continue without awaiting input.
This enables overnight autonomous work on long molecules.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Introduces Proto → Wisp → Mol architecture for agent sessions:
- mol-crew-session: Light harness enabling autonomous overnight work
Key insight: if attached mol exists, continue without awaiting input
- mol-polecat-session: One-shot wisp wrapping polecat work assignments
Handles onboard → execute → cleanup lifecycle
This separates "how to work" (proto) from "what to work on" (mol),
enabling session continuity and autonomous long-mol processing.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When 'gt X attach' is run from inside a tmux session, link the target
session's window as a new tab instead of switching sessions entirely.
Use C-b n/p to navigate between tabs.
Outside tmux: unchanged behavior (full attach)
Inside tmux: links window as tab for convenient multi-session viewing
- Add tmux.LinkWindow() and tmux.IsInsideTmux()
- Update attachToTmuxSession() with smart detection
- Update mayor, deacon, crew, refinery attach commands
Updates mol-polecat-work and polecat.md with comprehensive molecule protocol:
Molecule changes:
- Added exit-decision step as convergence point for all exits
- Four exit types: COMPLETED, BLOCKED, REFACTOR, ESCALATE
- Non-linear jumps allowed from any step to exit-decision
- Dynamic modifications allowed (add steps, file work, refresh)
Polecat role documentation:
- Full molecule protocol section explaining the contract
- Exit strategies with concrete commands
- Wisps vs Molecules comparison for context
- Session continuity for multi-session work
- Updated exit checklist
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Adds --stale flag to gt rig reset that:
- Lists all in_progress issues
- Checks if assignee tmux session exists
- Resets orphans to open status with empty assignee
- Skips crew/* assignees (persistent identities)
Also adds --dry-run flag to preview what would be reset.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update mol-polecat-work submit-merge step and polecat.md role docs
to explicitly forbid GitHub PRs and direct to beads merge-requests.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Wait for Claude to start before sending the prime command, and use
NudgeSession (with 500ms debounce) instead of SendKeysDelayed for
reliable message delivery.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Use attachToTmuxSession helper instead of tmux.AttachSession to properly
forward stdin/stdout/stderr when attaching.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Like gt crew at and gt mayor at, gt refinery attach now auto-starts
the refinery session if it is not already running.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
All gt refinery subcommands (start, stop, status, queue, attach) now
accept an optional rig argument. If not provided, the rig is inferred
from the current working directory.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- gt mol catalog: list available molecule protos
- gt mol burn: burn current molecule without digest
- gt mol squash: compress molecule into digest
- Wire --wisp flag in gt sling to use .beads-wisp/ storage
- Add IsWisp field to MoleculeContext
- Update prompts/roles/deacon.md with correct commands
Closes: gt-x74c, gt-9t14, gt-i4i2
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The Refinery now has a formal patrol molecule with structural enforcement
of the Beads Promise via the handle-failures verification gate.
Changes:
- Add RefineryPatrolMolecule() to builtin_molecules.go with 10 steps
- Add prompts/roles/refinery.md template following deacon/witness pattern
- Update test to expect 9 built-in molecules
Key insight: The handle-failures step is a GATE - you cannot proceed to
merge-push without either fixing the issue or filing a bead. This makes
disavowal structurally impossible, not just philosophically discouraged.
The Scotty Test: "Would Scotty walk past a warp core leak because it
existed before his shift?"
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The unified work dispatch command that implements spawn + assign + pin
in one operation, based on the Universal Gas Town Propulsion Principle:
"If you find something on your hook, YOU RUN IT."
Supports:
- Proto names (e.g., gt sling feature polecat/alpha)
- Issue IDs with optional molecule (e.g., gt sling gt-xyz polecat/beta -m bugfix)
- Target addressing (polecat/name, deacon/, witness/, refinery/)
- --wisp flag for ephemeral molecules
- --force flag for hook collision override
- Hook collision detection
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add `gt mol status [target]` command to show what's on an agent's hook:
- Auto-detects current agent from working directory
- Shows pinned bead and attached molecule info
- Displays phase progress with progress bar
- Indicates wisp vs durable molecules
- Provides next action hints
Also adds `mol` alias for the `molecule` command.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>