Commit Graph

20 Commits

Author SHA1 Message Date
gastown/crew/max
f7d497ba07 fix(zfc): remove strings.Contains conflict detection from Go code
hq-hcil1: Remove deprecated HasConflict/HasAuthFailure/IsNotARepo/HasRebaseConflict
methods that violated ZFC by having Go code decide error types based on stderr parsing.

Changes:
- Remove deprecated helper methods from GitError and SwarmGitError
- Export GetConflictingFiles() which uses git porcelain output (diff --diff-filter=U)
- Update CheckConflicts(), engineer.go, and integration.go to use GetConflictingFiles()
- Update tests to verify raw stderr is available for agent observation

ZFC principle: Go code transports raw output to agents; agents observe and decide.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 22:31:55 -08:00
gastown/crew/max
131dac91c8 refactor(zfc): derive state from files instead of in-memory cache
Apply ZFC (Zero Forge Cache) principle across git error handling and
feed curation. Agents now observe raw git output and make their own
decisions rather than relying on pre-interpreted error types.

- Add GitError type with raw stdout/stderr for observation
- Add SwarmGitError following the same pattern
- Remove in-memory deduplication maps from Curator
- Curator now reads state from feed/events files

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 22:23:44 -08:00
julianknutsen
ea8bef2029 refactor: unify agent startup with Manager pattern
- Create mayor.Manager for mayor lifecycle (Start/Stop/IsRunning/Status)
- Create deacon.Manager for deacon lifecycle with respawn loop
- Move session.Manager to polecat.SessionManager (clearer naming)
- Add zombie session detection for mayor/deacon (kills tmux if Claude dead)
- Remove duplicate session startup code from up.go, start.go, mayor.go
- Rename sessMgr -> polecatMgr for consistency
- Make witness/refinery SessionName() public for status display

All agent types now follow the same Manager pattern:
  mgr := agent.NewManager(...)
  mgr.Start(...)
  mgr.Stop()
  mgr.IsRunning()
  mgr.Status()

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-06 22:32:35 -08:00
gastown/crew/jack
eea4435269 feat(rig): Add --branch flag for custom default branch
Add --branch flag to `gt rig add` to specify a custom default branch
instead of auto-detecting from remote. This supports repositories that
use non-standard default branches like `develop` or `release`.

Changes:
- Add --branch flag to `gt rig add` command
- Store default_branch in rig config.json
- Propagate default branch to refinery, witness, daemon, and all commands
- Rename ensureMainBranch to ensureDefaultBranch for clarity
- Add Rig.DefaultBranch() method for consistent access
- Update crew/manager.go and swarm/manager.go to use rig config

Based on PR #49 by @kustrun - rebased and extended with additional fixes.

Co-authored-by: kustrun <kustrun@users.noreply.github.com>

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-04 14:01:02 -08:00
max
1b69576573 fix: Address golangci-lint errors (errcheck, gosec) (#76)
Apply PR #76 from dannomayernotabot:

- Add golangci exclusions for internal package false positives
- Tighten file permissions (0644 -> 0600) for sensitive files
- Add ReadHeaderTimeout to HTTP server (slowloris prevention)
- Explicit error ignoring with _ = for intentional cases
- Add //nolint comments with justifications
- Spelling: cancelled -> canceled (US locale)

Co-Authored-By: dannomayernotabot <noreply@github.com>

🤖 Generated with Claude Code
2026-01-03 16:11:55 -08:00
Steve Yegge
e362be3c41 fix: Use BeadsPath() for swarm status to read from git-synced beads (gt-1rxz5)
The swarm status was stale because bd commands were running from the rig
root path instead of the mayor/rig clone which has proper beads sync config.

Changes:
- Add Rig.BeadsPath() method to return mayor/rig path when available
- Update all bd commands in swarm.go to use BeadsPath()
- Update swarm manager to use separate beadsDir and gitDir paths
- beadsDir for bd commands (git-synced location)
- gitDir for git operations and mail (rig root)

This ensures swarm status reflects the latest beads data from the
git-synced beads-sync branch instead of stale local daemon data.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 23:46:59 -08:00
Steve Yegge
10e797895a Fix swarm not tracking dynamically added workers (gt-qd9p0)
Two bugs fixed in loadTasksFromBeads():
1. JSON field name mismatch: code parsed dependencies but bd show
   returns dependents - meant worker discovery always failed
2. Missing Assignee field: even if field name was correct, assignees
   were not being extracted from the bd show output

Also added hooked status to TaskInProgress mapping since workers
with hooked beads are actively working.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 21:58:06 -08:00
Steve Yegge
d3a27b2650 Rewrite swarm tests to use beads-backed API (gt-kc7yj.4)
- Add LoadSwarm method for loading swarms from beads
- Rewrite tests to use LoadSwarm, GetSwarm, GetReadyTasks, IsComplete
- Remove tests for deprecated Create, Start, UpdateState methods
- Keep E2E lifecycle documentation test

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 18:26:23 -08:00
Steve Yegge
da4829fb07 Add E2E swarm integration test documentation (gt-kc7yj.4)
Document the complete swarm lifecycle test protocol in manager_test.go:
- Epic creation with diamond-shaped DAG (A→B,C→D)
- bd swarm validate wave analysis
- bd swarm create molecule creation
- Ready front tracking and advancement
- Issue completion unblocks dependents
- Swarm auto-close behavior (requires Witness)

Filed gt-594a4 for gt swarm status/land routing issue.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 18:24:59 -08:00
Steve Yegge
f7393b6cdb refactor: Remove in-memory swarms map, make Manager stateless
The swarm Manager was maintaining an in-memory map of swarms that was
never persisted and duplicated state from beads. This caused stale state
after restarts and confusion about source of truth.

Changes:
- Remove swarms map from Manager (now stateless)
- Add LoadSwarm() that queries beads for swarm state
- Refactor all methods to use LoadSwarm() instead of in-memory lookup
- Discover workers from assigned tasks in beads
- Remove obsolete unit tests that tested in-memory behavior
- Keep type/state tests that do not need beads

The E2E test (gt-kc7yj.4) now covers the beads integration.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-29 17:12:30 -08:00
Steve Yegge
b0d185b88e fix: Correct JSON field name for swarm task loading (gt-552hb)
The loadTasksFromBeads() function was reading 'dependents' from bd show
output, but the actual JSON field is 'dependencies'. This caused swarms
to have empty task lists, requiring manual dispatch.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 16:16:25 -08:00
Steve Yegge
34b5a3bb8d Document intentional error suppressions with comments (gt-zn9m)
All 156 instances of _ = error suppression in non-test code now have
explanatory comments documenting why the error is intentionally ignored.

Categories of intentional suppressions:
- non-fatal: session works without these - tmux environment setup
- non-fatal: theming failure does not affect operation - visual styling
- best-effort cleanup - defer cleanup on failure paths
- best-effort notification - mail/notifications that should not block
- best-effort interrupt - graceful shutdown attempts
- crypto/rand.Read only fails on broken system - random ID generation
- output errors non-actionable - fmt.Fprint to io.Writer

This addresses the silent failure and debugging concerns raised in the
issue by making the intentionality explicit in the code.

Generated with Claude Code https://claude.com/claude-code

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 23:14:29 -08:00
Steve Yegge
4048cdc373 fix(lint): resolve all errcheck warnings
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>
2025-12-19 12:44:42 -08:00
Steve Yegge
dc09b0987e feat: swarm worker spawning, mail routing improvements, beads sync 2025-12-18 18:49:54 -08:00
Steve Yegge
e1c041f3b0 fix: spawn and swarm bug fixes from MVP testing
- spawn.go: Parse bd show --json as array, fix issue_type json tag
- session/manager.go: Check filesystem directly in hasPolecat()
  to handle newly-created polecats
- swarm/manager.go: Use bd show to get children via dependents field
  instead of non-existent bd list --parent flag

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-16 22:07:13 -08:00
Steve Yegge
59921d52c8 feat: refactor mail system to use bd mail backend
- Mail commands (send/inbox/read/delete) now wrap bd mail CLI
- Address translation: mayor/ → mayor, rig/polecat → rig-polecat
- Beads stores messages as type=message issues
- Legacy JSONL mode retained for crew workers (local mail)
- Refinery notifications use new mail interface
- Swarm landing notifications use new mail interface

Closes gt-u1j.6, gt-u1j.12

🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-16 21:45:42 -08:00
Steve Yegge
f8c177e17b feat: add witness swarm landing protocol
- ExecuteLanding: Full landing protocol for swarms
- Phase 1: Stop all polecat sessions
- Phase 2: Git audit (uncommitted/unpushed detection)
- Phase 3: Branch cleanup
- Phase 4: Mail notification to Mayor
- Code at risk detection with escalation
- Beads-only changes considered safe
- Updated gt swarm land to use full protocol

Closes gt-kmn.6

Generated with Claude Code

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-16 14:22:52 -08:00
Steve Yegge
807ba76a9b feat: add integration branch management for swarms
- CreateIntegrationBranch: create from BaseCommit, push to origin
- MergeToIntegration: merge worker branch with conflict detection
- LandToMain: merge integration to target branch
- CleanupBranches: remove all swarm branches after landing
- Helper functions for branch naming conventions

Closes gt-kmn.3

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-16 14:01:46 -08:00
Steve Yegge
515d8f82ce feat: add SwarmManager for swarm lifecycle operations
- Create/Start/Cancel swarm lifecycle methods
- State transition validation (Created->Active->Merging->Landed)
- Task assignment and state tracking
- GetReadyTasks/GetActiveTasks queries
- IsComplete check for swarm completion
- Integration with beads CLI for task loading

Closes gt-kmn.2

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-16 14:00:07 -08:00
Steve Yegge
355759be15 feat: add swarm package with core types
Types:
- Swarm: coordinated multi-agent work unit
- SwarmTask: single task assigned to worker
- SwarmState: lifecycle states (created/active/merging/landed/failed/cancelled)
- TaskState: task states (pending/assigned/in_progress/review/merged/failed)
- SwarmSummary: high-level progress overview

Methods:
- SwarmState.IsTerminal(), IsActive()
- TaskState.IsComplete()
- Swarm.Summary(), Progress()

Closes gt-kmn.1

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-16 13:31:56 -08:00