Skip to content

feat(rig): add manifest support for rig configuration#727

Closed
easel wants to merge 41 commits intogastownhall:mainfrom
easel:pr/rig-manifest
Closed

feat(rig): add manifest support for rig configuration#727
easel wants to merge 41 commits intogastownhall:mainfrom
easel:pr/rig-manifest

Conversation

@easel
Copy link
Copy Markdown
Contributor

@easel easel commented Jan 17, 2026

Resubmission of #592 (closed because the head branch was main; now using pr/rig-manifest rebased onto upstream/main).

This PR introduces the ability for a rig to describe what resources it wants from a town. The intent is to get it down to a oneliner to, for instance, add rigs for gastown and beads and start a crew so you can build from main and contribute fixes.

Summary

  • Add .gt/rig.toml manifest file support for standardizing rig setup
  • Implement fork detection and upstream/origin remote configuration
  • Add crew presets with agent, model, and account support
  • Add gt rig update command for checking/pulling updates
  • Support setup command execution from manifest

Details

The manifest enables one-liner rig installation with automatic crew workspace creation and proper remote configuration. Key features:

  • Manifest parsing: .gt/rig.toml defines rig defaults (name, prefix, branch), git settings (upstream, fork policy), setup commands, and crew configurations
  • Fork workflow: Detects existing forks, prompts to create/use fork, configures remotes correctly
  • Crew presets: Supports agent type, model, account, branch, args, and env configuration per crew member
  • Update command: gt rig update --check reports ahead/behind status, --pull updates and runs setup

Test plan

  • go build ./... passes
  • go test ./... passes
  • gofmt clean
  • go vet clean
  • Manual testing of gt rig add with manifest
  • Manual testing of fork detection flow
  • Manual testing of gt rig update

🤖 Generated with Claude Code

@easel easel force-pushed the pr/rig-manifest branch 5 times, most recently from f7e1d9f to 1ea3a04 Compare January 23, 2026 03:19
@easel easel force-pushed the pr/rig-manifest branch 6 times, most recently from 980c1ee to b4b1eec Compare February 1, 2026 03:41
easel and others added 18 commits February 1, 2026 14:10
1. Fix mol-witness-patrol.formula.toml TOML syntax error
   - Convert multi-line descriptions to use triple-quoted strings
   - Fixes TestParallelReadySteps test failure

2. Add Windows build support for tmux package
   - Extract syscall.Kill calls to platform-specific signal_unix.go
   - Add no-op signal_windows.go stub (tmux not available on Windows)
   - Fixes Windows CI build failure

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Explicitly ignore error returns from logFile.Close() calls
- Add nolint directive for stopLocked's always-nil error return
- Regenerate embedded formula files to match source

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix lint errors: errcheck for Sscanf, gosec for Close/Remove
- Add nolint:unparam for parseValue (error kept for future)
- Add BuiltProperly ldflags to test helper
- Skip Windows tests for process groups and concurrent atomic writes
- Regenerate formula files to sync with .beads/formulas

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Update role_e2e_test.go for compound GT_ROLE format
- Add normalizeRuntimeConfig call for built-in presets in lookupAgentConfig
- Fix dog_test.go to use filepath.FromSlash for cross-platform paths
- Skip Windows tests with file I/O timing issues

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1. Fix mol-witness-patrol.formula.toml TOML syntax error
   - Convert multi-line descriptions to use triple-quoted strings
   - Fixes TestParallelReadySteps test failure

2. Add Windows build support for tmux package
   - Extract syscall.Kill calls to platform-specific signal_unix.go
   - Add no-op signal_windows.go stub (tmux not available on Windows)
   - Fixes Windows CI build failure

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add e2e tests that verify gt install creates a functional system:
- TestInstallDoctorClean: verifies structure, rig/crew add, commands
- TestInstallWithDaemon: extends above with daemon lifecycle testing

Tests run in isolated Docker container for reproducibility.

Includes:
- Dockerfile.e2e for test container
- Makefile targets: test-e2e, test-e2e-container
- GitHub Actions workflow for CI

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implements two new commands for managing Gas Town processes:

1. gt ps - List all tmux sessions with process information
   - Shows session names, status (alive/dead), commands, PIDs
   - Displays work-on-hook status for polecats
   - Supports --json and --verbose flags
   - Highlights Gas Town sessions

2. gt cleanup - Manage orphaned processes and sessions
   - cleanup orphans: Find work assigned to dead agents
   - cleanup sessions: Clean up dead/zombie tmux sessions
   - cleanup stale: Clean up stale polecats (wraps gt polecat stale)
   - Supports --dry-run flag for safe inspection

Both commands integrate with existing daemon orphan detection logic
and provide manual inspection/triggering of cleanup operations.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Remove --force flag from cleanup sessions command that was declared but never used
- Fix extractRigFromAgentID to handle rig names with hyphens by finding the "-polecat-" delimiter
- Fix extractPolecatNameFromAgentID to handle polecat names with hyphens by taking everything after "-polecat-"

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Revert beads_test.go changes from contrib/process-management that
removed t.Skip() from tests documenting a bd CLI 0.47.2 bug. The
tests cannot pass until the bd CLI issue is resolved, so they need
to remain skipped.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
These tests require tmux and bd which are not available on Windows CI.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Instead of skipping tests on Windows, provide Windows batch script
equivalents for the mock tmux, bd, pgrep, and gt commands.

Update writeScript() helper to accept both Unix and Windows scripts
and write the appropriate one based on runtime.GOOS.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The TestRunPSJSONIncludesAgentDetails and TestCleanupOrphansDryRunReports
tests require complex tmux mocking with argument parsing and loops that
don't translate well to Windows batch scripts. Skip these on Windows
while keeping simpler tests cross-platform.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
easel and others added 23 commits February 1, 2026 14:10
Add `gt formula format` command that converts single-line strings with
\n escapes to proper TOML multi-line strings, making PR diffs readable.

Features:
- --check: Exit 1 if formatting needed (for CI)
- --write: Modify files in-place
- --diff: Show unified diff of changes

Includes property-based testing with pgregory.net/rapid for 100%
round-trip accuracy on arbitrary valid strings.

Also adds PostToolUse hook to auto-format .formula.toml files after
Edit/Write operations.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add WorkDir field to AgentEnvConfig that enables automatic detection of
beads redirects. When a redirect file exists in WorkDir/.beads/redirect,
BEADS_SYNC_BRANCH is set to "" to suppress the "Redirect active...
skipping sync-branch operations" warning.

This consolidates redirect detection into internal/config/env.go,
eliminating the need for callers to import the beads package or
manually check for redirects. Callsites simply pass their working
directory and the config package handles the rest.

The fix only activates when a redirect is actually present, avoiding
false positives for standalone crew/polecat workspaces without redirects.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add `gt epic` command for managing upstream contributions with:

- Epic lifecycle: start → ready → sling → review → submit
- CONTRIBUTING.md discovery and context injection
- Plan parsing using molecule step format
- Subtask creation with dependency tracking
- Stacked PR creation with dependency-aware base targeting
- PR lifecycle management (status, check, sync, respond, resolve)
- Crew member onboarding for planning sessions
- Worker dispatch with --workers flag support

New files:
- internal/epic/contributing.go - CONTRIBUTING.md discovery
- internal/epic/upstream.go - PR types and dependency graph
- internal/epic/sync.go - Rebase and conflict detection
- internal/beads/beads_epic.go - Epic state helpers
- internal/cmd/epic*.go - All epic subcommands

Also modifies:
- sling.go: Add --workers flag for batch dispatch
- prime_output.go: Inject CONTRIBUTING.md for epics
- mayor.md.tmpl: Add epic detection guidance

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add comprehensive test infrastructure for the refinery's DAG-based
branch management workflow. Includes:

- BranchDAG and BranchNode data structures for tracking dependencies
- TopologicalOrder for cascade rebase ordering
- AgentSignaler interface for mocking agent notifications
- TestRepo helpers for creating isolated git repositories in tests
- 37 unit tests and 8 integration tests covering:
  - Linear stack rebases
  - Conflict detection
  - Diamond dependencies
  - Fork workflow (upstream + local PRs)
  - Full workflow orchestration

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add 93 tests covering epic upstream workflow functionality:

- internal/epic/sync_test.go (39 tests):
  - Git operations: FetchUpstream, CheckConflicts, RebaseBranch
  - Force push, conflict file detection
  - Helper functions: getCurrentBranch, countCommits
  - CI/PR status structures

- internal/cmd/epic_test.go (54 tests):
  - Helper functions: sanitizeForBranch, extractStepRef, detectRole
  - State transitions validation
  - PR URL parsing, dependency graph building
  - Crew member detection and listing
  - Plan parsing integration

Bug fix:
- extractStepRef: Fix case-insensitive step prefix extraction

Coverage improvements:
- internal/epic: 36.3% → 79.2%
- Added tests for previously untested sync.go operations

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add interface-based dependency injection for gh CLI operations:
- GHClient interface with GetPRChecks and GetPRReviews methods
- RealGHClient implementation using actual gh CLI
- StubGHClient for testing with configurable responses
- Comprehensive tests achieving 92% coverage

This enables testing CI status and review status logic without
requiring actual GitHub API calls.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add CLI commands to manage stacked PR dependencies:
- gt stack set <base-branch>: Register current branch as depending on another
- gt stack list: Show the PR dependency DAG with status
- gt stack sync: Rebase all dependent PRs when base updates
- gt stack clear: Remove dependency tracking for current branch

Changes:
- Add DependsOn field to MRFields for tracking PR dependencies
- Create internal/cmd/pr_stack.go with stack subcommands
- Wire up DAGOrchestrator for automated rebase coordination

This enables proper stacked PR workflows where:
1. PRs can declare dependencies on other PRs
2. The refinery can merge in correct order
3. Rebases cascade automatically when base branches update

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Engineer now initializes DAGOrchestrator and loads DAG state
- ListReadyMRs filters out MRs whose dependencies haven't merged
- HandleMRInfoSuccess notifies DAG when branch merges, retargeting dependents
- mq_submit auto-registers branches in DAG with target-based dependencies
- TestRepo now uses 'main' as default branch for consistent testing

Adds comprehensive tests for:
- Dependency filtering logic (blocks MRs with unmerged deps)
- Merge notification cascade (retargets and signals dependents)
- Auto-registration logic (target determines dependency)
- MRFields DependsOn parsing integration

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add .gt/rig.toml manifest file support for standardizing rig setup:

- Parse and apply manifest defaults during gt rig add
- Fork detection and upstream/origin remote configuration
- Crew presets with agent, model, and account support
- gt rig update command for checking/pulling updates
- Setup command execution from manifest

The manifest enables one-liner rig installation with automatic
crew workspace creation and proper remote configuration.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Run go generate ./... to synchronize embedded formulas with source.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove unused error return from runAllowFailure, getConflictFiles,
  AbortRebase, and AbortMerge (unparam lint)
- Explicitly ignore os.RemoveAll errors in test helpers (errcheck lint)
- Update GitOperations interface to match implementation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@julianknutsen julianknutsen added kind/enhancement New capability priority/p3 Backlog — good idea, reviewed when there's bandwidth labels Feb 13, 2026
@easel easel marked this pull request as draft February 16, 2026 02:33
@steveyegge
Copy link
Copy Markdown
Collaborator

Closing this draft for now to keep the PR queue tidy. Feel free to reopen when it's ready for review!

@steveyegge steveyegge closed this Feb 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement New capability priority/p3 Backlog — good idea, reviewed when there's bandwidth

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants