Fix ~50 errcheck warnings across the codebase:
- Add explicit `_ =` for intentionally ignored error returns (cleanup,
best-effort operations, etc.)
- Use `defer func() { _ = ... }()` pattern for defer statements
- Handle tmux SetEnvironment, KillSession, SendKeysRaw returns
- Handle mail router.Send returns
- Handle os.RemoveAll, os.Rename in cleanup paths
- Handle rand.Read returns for ID generation
- Handle fmt.Fprint* returns when writing to io.Writer
- Fix for-select with single case to use for-range
- Handle cobra MarkFlagRequired returns
All tests pass. Code compiles without errors.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implements per-agent backoff tracking to reduce noise for busy agents:
- AgentBackoff type tracks interval, miss count, and last activity
- BackoffManager manages state across all agents
- Geometric backoff strategy (1.5x factor, 10min cap)
- Integrates with keepalive to skip pokes when agents are fresh
- Resets backoff immediately when activity detected
Closes gt-8bx
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add missing gt commands to match PGT functionality:
- gt session restart: Restart polecat session (stop + start)
- gt session status: Show detailed session status with uptime
- gt rig shutdown: Gracefully stop all agents in a rig
- gt mail reply: Convenience command for replying to messages
- gt witness attach: Attach to witness tmux session
Closes: gt-hw6, gt-99m, gt-6db, gt-e76, gt-hzr, gt-sqi
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add docs/harness.md covering:
- What a harness (installation directory) is
- Directory structure with mayor/ config files
- Town-level vs rig-level mayor presence
- Beads architecture and resolution via BEADS_DIR
- Relationship between harness and rigs
- Example configurations and setup workflow
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add `gt crew restart <name>` command that kills the tmux session and
starts fresh with Claude. Unlike `refresh`, this does not send handoff
mail - it is a clean slate restart. Useful when a crew member gets
confused or needs context cleared.
Alias: gt crew rs
Resolves: gt-1fl
🤝 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add three built-in molecule definitions that are automatically seeded
during `gt install`:
- engineer-in-box: Full workflow from design to merge (5 steps)
- quick-fix: Fast path for small changes (3 steps)
- research: Investigation workflow (2 steps)
These molecules provide reusable workflow templates that polecats can
instantiate to execute multi-step procedures with proper dependency
tracking between steps.
Closes gt-4nn.4
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add 'gt mq integration land <epic>' command that:
- Verifies all MRs targeting integration/<epic> are merged
- Verifies integration branch exists
- Merges integration/<epic> to main (--no-ff)
- Runs tests on main (if configured)
- Pushes to origin
- Deletes integration branch (local and remote)
- Updates epic status to closed
Options:
- --force: land even if some MRs still open
- --skip-tests: skip test run
- --dry-run: preview only
Also adds:
- MergeNoFF() and DeleteRemoteBranch() to git package
- WorkDir() accessor for git.Git
- Unit tests for mq helper functions
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Document what a harness is (private repo containing GT installation),
why you would want one (work on public projects privately), and how to
configure beads redirects for multi-rig workflows.
Closes: gt-346, gt-5qc, gt-l1o
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The spawn context inject was sending Enter too quickly after pasting
large messages. Claude needs time to process the paste before Enter
is sent (Claude shows "Pasted text #1 +N lines" message).
Increased debounce timing:
- Base delay: 100ms → 200ms
- Per-KB scaling: 50ms → 100ms
- Max cap: 500ms → 1500ms
For a typical 4KB spawn context, this gives 600ms (vs 300ms before).
Fixes: gt-eqys
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add `gt molecule` subcommands for managing workflow templates:
- list: Show all molecules (type=molecule issues)
- show: Display molecule with parsed step structure
- parse: Validate molecule and show parsed details
- instantiate: Create child beads from molecule template
- instances: Show all instantiations of a molecule
Also add `--molecule` flag to `gt spawn` for molecule-based workflows.
When specified, the molecule is instantiated on the parent issue first,
then the polecat is spawned on the first ready step.
🤝 Co-authored-by: Claude <noreply@anthropic.com>
Replace tmux display-message (subtle status bar notification) with
send-keys to echo a visible banner to the terminal. This ensures
mail notifications are actually seen by agents.
Closes gt-vnp9
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When adding a polecat, check if the branch already exists (e.g., from a
previous polecat that was removed but whose branch wasn't cleaned up).
If so, reuse the existing branch with WorktreeAddExisting instead of
failing with 'a branch named polecat/X already exists'.
Fixes: gt-bmjw
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When sending keys via tmux send-keys, there is a race condition where the
Enter key can be processed before the pasted text completes. This causes
messages to appear in the prompt but not be submitted.
- Add SendKeysDebounced method with configurable delay between paste and Enter
- Update SendKeys to use 100ms default debounce
- Update Inject to scale debounce based on message size (100ms + 50ms/KB)
Fixes beads-62h
Replace mail-based handoff system with pinned beads that persist
across sessions. This fixes the issue where handoff messages get
closed before successors can read them.
Changes:
- beads: Add StatusPinned constant and handoff functions:
- HandoffBeadTitle() for well-known naming
- FindHandoffBead() to locate role handoff bead
- GetOrCreateHandoffBead() to ensure bead exists
- UpdateHandoffContent() to set handoff message
- ClearHandoffContent() to reset after reading
- cmd/handoff: Update to use pinned beads instead of mail
- sendHandoffMail() now updates pinned bead content
- cmd/prime: Display handoff content on startup
- outputHandoffContent() reads and shows handoff bead
- cmd/rig: Add reset command with --handoff flag
- gt rig reset --handoff clears handoff content
Generated with Claude Code
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This implements the ephemeral polecat model where polecats are spawned
fresh for each task and deleted upon completion.
Key changes:
**Spawn (internal/cmd/spawn.go):**
- Always create fresh worktree from main branch
- Run bd init in new worktree to initialize beads
- Remove --create flag (now implicit)
- Replace stale polecats with fresh worktrees
**Handoff (internal/cmd/handoff.go):**
- Add rig/polecat detection from environment and tmux session
- Send shutdown requests to correct witness (rig/witness)
- Include polecat name in lifecycle request body
**Witness (internal/witness/manager.go):**
- Add mail checking in monitoring loop
- Process LIFECYCLE shutdown requests
- Implement full cleanup sequence:
- Kill tmux session
- Remove git worktree
- Delete polecat branch
**Polecat state machine (internal/polecat/types.go):**
- Primary states: working, done, stuck
- Deprecate idle/active (kept for backward compatibility)
- New polecats start in working state
- ClearIssue transitions to done (not idle)
**Polecat commands (internal/cmd/polecat.go):**
- Update list to show "Active Polecats"
- Normalize legacy states for display
- Add deprecation warnings to wake/sleep commands
Closes gt-7ik
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Changes:
- Remove creation of mayor/mail/ directory with legacy JSONL inbox
- Initialize town-level beads DB (gm- prefix) via `bd init` instead of
creating a .beads/redirect placeholder file
- Update help text and next-steps output to reflect new architecture
Town beads (gm-*) store mayor mail, cross-rig coordination, and handoffs.
Rig beads remain separate with their own prefixes.
Closes: gt-jpt
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The spawn command now accepts --polecat and --rig flags as an
alternative to the positional rig/polecat argument. When using
--polecat without --rig, the rig is inferred from the current
working directory.
Examples:
gt spawn --issue gt-xyz --polecat Angharad
gt spawn --issue gt-abc --rig gastown --polecat Toast
Fixes gt-selw
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implement 'gt mq integration create <epic>' command to create integration
branches for batch work on epics. The command:
1. Verifies the epic exists in beads
2. Creates branch integration/<epic-id> from origin/main
3. Pushes the branch to origin
4. Stores integration branch info in the epic's metadata
Also adds helper methods to git package:
- CreateBranchFrom: create branch from specific ref
- BranchExists: check if local branch exists
- RemoteBranchExists: check if branch exists on remote
Future MRs for the epic's children can target the integration branch
with: gt mq submit --epic <epic-id>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Adds two new commands to transition polecats back to idle state:
- gt polecat done (alias: finish): Transitions from working/done/stuck
states to idle, clearing the assigned issue. For normal workflow when
work is complete but session was not properly cleaned up.
- gt polecat reset: Force resets any state to idle. For recovery when
polecat is stuck in an unexpected state.
Both commands check that the session is stopped before modifying state.
Fixes gt-s3m0
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When gt rig add creates workspaces by cloning a repository, the cloned
repos CLAUDE.md would be inherited, causing crew workers to show refinery
context. Now explicitly create role-appropriate CLAUDE.md files after each
clone to ensure correct agent prompting.
Fixes gt-vdp0
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add the witness monitoring agent command with start, stop, and status
subcommands. The witness monitors polecats for stuck/idle states and
can nudge blocked workers.
Closes gt-kcee
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When using `gt spawn rig --create` and no polecats exist (or all are
busy), the command now automatically generates a Mad Max themed polecat
name and creates it, rather than failing with "no available polecats".
This improves agent UX by making the --create flag work intuitively.
Fixes: gt-szsq
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The refinery start command was only updating state.json without
actually starting a session. Now it spawns a tmux session named
gt-{rig}-refinery that runs the refinery in foreground mode.
Also updated Stop() and Status() to properly check tmux session
state alongside the PID-based tracking for backwards compatibility.
Fixes: gt-17zr
🤝 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add MergeQueueConfig struct and RigConfig type with:
- All merge queue settings (enabled, target_branch, on_conflict, etc.)
- Default values via DefaultMergeQueueConfig()
- Validation for on_conflict strategy and poll_interval duration
- Load/Save/Validate functions following existing config patterns
- Comprehensive tests for round-trip, custom config, and validation
Implements gt-h5n.8.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
'gt session capture rig/polecat 50' now works in addition to
'gt session capture rig/polecat -n 50'. Agent UX: commands should
work the way agents guess they work.
Closes: gt-d7i
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The addressToIdentity function was stripping the trailing slash from
'mayor/' addresses, causing a mismatch with beads messages that have
assignee 'mayor/'. This fix ensures mayor addresses always use 'mayor/'
for consistent mail routing.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add 200ms delay after NewSession before sending keys to fix race
condition where shell is not ready (mayor.go, crew.go)
- Use merge-request type instead of task for gt mq submit (mq.go)
Fixes gt-tulx
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>