Commit Graph

1808 Commits

Author SHA1 Message Date
Steve Yegge
fa2997c5ca Implement Polecat-Witness protocol handlers (gt-m5w4g.3)
Add protocol message parsing and handlers for polecat→witness communication:
- POLECAT_DONE: Parse completion messages, create cleanup wisps
- HELP: Parse help requests, assess if Witness can help or escalate to Mayor
- MERGED: Parse refinery merge confirmations
- LIFECYCLE:Shutdown: Handle daemon-triggered shutdowns
- SWARM_START: Parse batch work initialization

Files added:
- internal/witness/protocol.go: Message classification and parsing
- internal/witness/handlers.go: Handler implementations with wisp/mail integration
- internal/witness/protocol_test.go: Unit tests for all parsing functions

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 10:44:34 -08:00
Steve Yegge
907eba7194 Instrument gt commands to emit events to activity feed (gt-7aw1m)
Add events.LogFeed calls to the following gt commands:
- nudge.go: Log TypeNudge events when nudging agents
- unsling.go: Log TypeUnhook events when removing work from hooks
- up.go: Log TypeBoot events when starting Gas Town services
- down.go: Log TypeHalt events when stopping Gas Town services
- stop.go: Log TypeKill events when stopping polecat sessions
- polecat_spawn.go: Log TypeSpawn events when spawning polecats

Also add helper functions to events package:
- UnhookPayload: Creates payload for unhook events
- KillPayload: Creates payload for kill events
- HaltPayload: Creates payload for halt events

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 10:43:34 -08:00
Steve Yegge
3cd849e981 docs: Add gt swarm documentation (gt-1z4m)
Add comprehensive documentation for the gt swarm feature:
- New docs/swarm.md with full guide to swarm lifecycle, commands, and workflows
- Update reference.md with swarm CLI commands in "Swarm Management" section
- Add architecture note explaining swarm coordination model

The swarm package was fully implemented but undocumented.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 10:41:02 -08:00
Steve Yegge
c6a9201b5e Add infrastructure formulas for dog tasks (gt-0x5og.5)
Create five formulas for dog-executed infrastructure tasks:
- mol-convoy-cleanup: Archive convoy, notify overseer
- mol-dep-propagate: Cross-rig dependency resolution
- mol-digest-generate: Daily digest for overseer
- mol-orphan-scan: Find and reassign orphaned work
- mol-session-gc: Clean stale sessions

Each formula follows the standard TOML structure with:
- Description and dog contract
- Step-by-step workflow with dependencies
- Variable definitions
- Squash configuration for digests

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 10:39:36 -08:00
Steve Yegge
ddf5b5a9f4 Add Dog infrastructure package for Deacon helper workers (gt-0x5og.2)
Dogs are reusable workers managed by the Deacon for cross-rig infrastructure
tasks. Unlike polecats (single-rig, ephemeral), dogs have worktrees into
multiple rigs and persist between tasks.

Key components:
- internal/dog/types.go: Dog struct, State enum, DogState JSON schema
- internal/dog/manager.go: Manager with Add/Remove/List/Get/Refresh operations
- internal/dog/manager_test.go: Unit tests

Features:
- Multi-rig worktrees: Each dog gets a worktree per configured rig
- State tracking: .dog.json with idle/working state, last-active, work assignment
- Worktree refresh: Recreate stale worktrees with fresh branches
- Branch cleanup: Remove orphaned dog branches across all rigs

Directory structure: ~/gt/deacon/dogs/<name>/
  - <rig>/ (worktree into each rig: gastown/, beads/, etc.)
  - .dog.json (state file)

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 10:38:18 -08:00
Steve Yegge
5204dd0eb4 feat: Allow remove and restart to take multiple crew names 2025-12-30 10:29:53 -08:00
Steve Yegge
f492aac19b feat: Allow starting multiple crew members at once
gt crew start beads/grip beads/fang beads/wolf now works
2025-12-30 10:23:45 -08:00
Steve Yegge
afb7b85b35 bd sync: 2025-12-30 10:21:48 2025-12-30 10:21:48 -08:00
Steve Yegge
79a6b249a6 bd sync: 2025-12-30 10:20:59 2025-12-30 10:21:37 -08:00
Steve Yegge
be979c66a2 feat: Use base36 encoding for shorter polecat branch names 2025-12-30 10:20:51 -08:00
Steve Yegge
08d966a601 Add patrol hygiene: inbox cleanup for Witness/Refinery/Deacon (gt-h5e0)
Each patrol formula now includes:
- Explicit archive instructions after processing messages
- New patrol-cleanup step for end-of-cycle inbox hygiene
- Deacon: log rotation and state.json pruning

Changes:
- mol-witness-patrol v2: POLECAT_STARTED archive, patrol-cleanup step
- mol-refinery-patrol v3: MERGE_READY archive after merge, patrol-cleanup step
- mol-deacon-patrol v3: log-maintenance step, patrol-cleanup step

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 09:59:09 -08:00
Steve Yegge
a7831ba11d Add human escalation path with severity levels (gt-1z3z)
Implements structured escalation channel for Gas Town:
- gt escalate command with CRITICAL/HIGH/MEDIUM severity levels
- Mayor startup check for pending escalations
- Escalation beads with tag for audit trail
- Mail routing to overseer with priority mapping
- Documentation in docs/escalation.md

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 09:58:14 -08:00
Steve Yegge
ab30b974a4 Design wisp squash architecture: cadences, templates, retention (gt-cekg)
Adds comprehensive design for how wisps squash to digests:
- Cadences: patrol wisps squash per-cycle, work wisps on completion
- Templates: structured formats for patrol and work digests, formula-defined
- Retention: 30d active, 1yr archive, weekly/monthly rollups
- Activity feed integration for observability

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 07:07:28 -08:00
Steve Yegge
3889d31713 Add static mailing list support (list:name syntax) (gt-2rfvq)
Implement static mailing list expansion for the mail system:

- Add list:name address syntax (e.g., list:oncall)
- Load lists from ~/gt/config/messaging.json
- Fan-out delivery: each list member gets their own message copy
- Clear error handling for unknown list names
- Add tests for list detection, parsing, and expansion
- Update gt mail send help text with list:name documentation
- Show recipients in output when sending to a list

Example:
  gt mail send list:oncall -s "Alert" -m "System down"
  # Expands to: mayor/, gastown/witness
  # Creates 2 message copies

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 06:57:37 -08:00
Steve Yegge
dd3391bb68 bd sync: 2025-12-30 06:47:27 2025-12-30 06:47:27 -08:00
Steve Yegge
c1e2257497 bd sync: 2025-12-30 06:45:27 2025-12-30 06:45:46 -08:00
Steve Yegge
800e218b7c bd sync: 2025-12-30 02:07:44 2025-12-30 06:45:46 -08:00
Steve Yegge
5329865332 bd sync: 2025-12-30 02:06:28 2025-12-30 06:45:46 -08:00
Steve Yegge
4389d4fcd2 bd sync: 2025-12-30 01:54:04 2025-12-30 06:45:46 -08:00
Steve Yegge
9acb275526 bd sync: 2025-12-30 01:52:52 2025-12-30 06:45:46 -08:00
Steve Yegge
b0c00b78e3 bd sync: 2025-12-30 01:51:51 2025-12-30 06:45:46 -08:00
Steve Yegge
437d42c7fa ZFC #4: Replace daemon identity parsing with agent self-registration
Implements role-based lifecycle configuration where agent types self-register
via role beads instead of hardcoded identity string parsing in the daemon.

Changes:
- Add RoleConfig struct with lifecycle fields (session_pattern, work_dir_pattern,
  needs_pre_sync, start_command, env_vars)
- Add ParseRoleConfig/FormatRoleConfig/ExpandRolePattern to beads package
- Add role bead ID helpers (RoleBeadID, MayorRoleBeadID, etc.)
- Refactor daemon to use single parseIdentity function as ONLY place where
  identity strings are parsed
- Daemon now looks up role beads to get lifecycle config, with fallback to
  defaults when role bead is missing or has no config
- Updated all role beads (mayor, deacon, witness, refinery, crew, polecat)
  with structured lifecycle configuration fields
- Add comprehensive unit tests for RoleConfig parsing and expansion

This makes the daemon ZFC-compliant by trusting what agents self-report in
their role beads rather than encoding agent-specific knowledge in Go code.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 02:13:14 -08:00
Steve Yegge
ede5406d36 ZFC #5: Move merge/conflict decisions from Go to Refinery agent
Remove decision-making logic from Go code and document agent responsibility:

- ProcessMR() now returns error indicating agent handles processing
- Foreground mode deprecated with message directing to background mode
- Retry() no longer calls ProcessMR (agent picks up retried MRs)
- Added ZFC compliance section to refinery role template
- Marked unused helper functions as deprecated (runTests, getMergeConfig, pushWithRetry)

The Refinery agent (Claude) now:
- Runs git commands directly (fetch, checkout, merge, push)
- Detects conflicts and decides: retry, notify polecat, escalate
- Runs tests and decides: proceed, rollback, retry
- Makes all engineering decisions based on command output

Go code provides only primitives: queue listing, status, mail notifications.

(gt-sxa64)

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 02:12:43 -08:00
Steve Yegge
e72882cdcb Add feed curator to daemon for activity feed curation (gt-38doh)
Implements the feed daemon goroutine that:
- Tails ~/gt/.events.jsonl for raw events
- Filters by visibility tag (keeps feed/both, drops audit)
- Deduplicates repeated done events from same actor
- Aggregates sling events when multiple occur in window
- Writes curated events to ~/gt/.feed.jsonl with summaries

The curator runs as a goroutine in the gt daemon, starting when
the daemon starts and stopping gracefully on shutdown.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 02:12:01 -08:00
Steve Yegge
8e96e12e37 Remove stats from .runtime/*.json observable state (gt-lfi2d)
Remove Stats fields from witness and refinery types that tracked
observable metrics (total counts, today counts). These are now
handled by the activity stream/beads system instead.

Removed:
- WitnessStats type and Stats field from Witness
- RefineryStats type and Stats field from Refinery
- LastCheckAt field from Witness
- Stats display from gt witness status
- Stats display from gt refinery status
- Stats increment code from refinery.completeMR()

Kept minimal process state:
- RigName, State, PID, StartedAt (both)
- MonitoredPolecats, Config, SpawnedIssues (witness)
- CurrentMR, PendingMRs, LastMergeAt (refinery)

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 02:05:54 -08:00
Steve Yegge
04f0e46619 Add MQ summary to gt status output (gt-tvwnz)
Shows merge queue status under the Refinery section:
- pending: Open MRs ready to merge (no blockers)
- in-flight: MRs currently being processed
- blocked: MRs waiting on dependencies

Output appears as: MQ: 4 pending, 1 in-flight

Also adds MQ summary to JSON output in RigStatus.mq field.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 01:56:18 -08:00
Steve Yegge
1d4b27cf06 Wire witness patrol events to gt feed display
Add support for displaying gt events (from ~/gt/.events.jsonl) in the
gt feed TUI, including witness patrol activity:

- Add event symbols for patrol events (patrol_started, patrol_complete,
  polecat_checked, polecat_nudged, escalation_sent), merge events, and
  general gt events (sling, hook, handoff, mail, spawn, etc.)

- Create GtEventsSource that parses .events.jsonl format with proper
  extraction of rig/role from actor paths and human-readable message
  generation from event payloads

- Create CombinedSource that merges multiple event sources (bd activity
  and gt events) using fan-in pattern

- Update feed command to use combined source for TUI mode

- Add appropriate styling for new event types (nudges/escalations in
  red, patrol complete in green, etc.)

Example gt feed output now shows:
  09:45 ✓ witness: All polecats healthy
  09:44  witness: nudged nux (idle 10m)
  09:40 🎯 mayor: slung gt-rbncw to furiosa

(gt-rbncw)

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 01:55:09 -08:00
Steve Yegge
4f9bf643bd feat: Wire MQ lifecycle events to gt feed display (gt-lak31)
- Add MQ event types and logging in mrqueue/events.go
- Have refinery emit merge_started, merged, merge_failed, merge_skipped events
- Create MQEventSource to read from mq_events.jsonl
- Add MultiSource to combine events from bd activity and MQ events
- Add color coding: green for merged, red for failed
- Update feed help with MQ event symbols

Events are stored in .beads/mq_events.jsonl and displayed in the feed TUI
with appropriate symbols and colors.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 01:45:04 -08:00
Steve Yegge
ff37dc3d60 bd sync: 2025-12-30 01:03:55 2025-12-30 01:03:55 -08:00
Steve Yegge
21158c4c12 bd sync: 2025-12-30 01:03:09 2025-12-30 01:03:09 -08:00
Steve Yegge
559ab84d49 bd sync: 2025-12-30 01:02:01 2025-12-30 01:02:23 -08:00
Steve Yegge
59f90f2bb2 bd sync: 2025-12-30 01:00:48 2025-12-30 01:02:23 -08:00
Steve Yegge
bf72f6c59a bd sync: 2025-12-30 00:49:28 2025-12-30 01:02:23 -08:00
Steve Yegge
44d783fca3 bd sync: 2025-12-30 00:48:24 2025-12-30 01:02:23 -08:00
Steve Yegge
a2d16b619a bd sync: 2025-12-30 00:46:35 2025-12-30 01:02:23 -08:00
Steve Yegge
c0832d000f bd sync: 2025-12-30 00:33:23 2025-12-30 01:02:23 -08:00
Steve Yegge
16076913ae fix: use rig-specific prefix for agent bead IDs (bd-otyh)
When spawning polecats in non-gastown rigs like beads, the agent bead ID
was incorrectly using the hardcoded "gt-" prefix instead of the rig's
configured prefix (e.g., "bd-" for beads).

Changes:
- Add GetPrefixForRig() in routes.go to look up prefix from routes.jsonl
- Update agentIDToBeadID() in sling.go to use rig's prefix via the new
  *WithPrefix functions instead of hardcoded "gt"
- Add unit tests for the new functionality

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 01:02:23 -08:00
Steve Yegge
3e64a4a630 bd sync: 2025-12-30 00:18:58 2025-12-30 01:02:23 -08:00
Steve Yegge
f9b554b683 bd sync: 2025-12-30 00:15:53 2025-12-30 01:02:23 -08:00
Steve Yegge
ebec23cfea bd sync: 2025-12-30 00:09:02 2025-12-30 01:02:23 -08:00
Steve Yegge
90bb64f7e4 bd sync: 2025-12-30 00:08:39 2025-12-30 01:02:23 -08:00
Steve Yegge
40d1e0c2a4 bd sync: 2025-12-29 23:58:14 2025-12-30 01:02:23 -08:00
Steve Yegge
910c6fc076 Remove stubbed ProcessMRFromQueue and mrqueue package (gt-u4fh)
The mrqueue package was aspirational 'beads-based MR automation' that was
never completed. The Refinery agent is prompt-driven and uses beads/mail
for coordination, not a Go-based polling queue.

Removed:
- internal/mrqueue/mrqueue.go (entire package)
- internal/cmd/mq_migrate.go (migration command for mrqueue)
- mrqueue submission from done.go and mq_submit.go
- Engineer.ProcessMRFromQueue() and related queue handlers
- Engineer.Run(), Stop(), processOnce() methods
- mrQueue field and stopCh from Engineer struct
- stopCh assertion from TestNewEngineer

Kept:
- Bead creation for merge-requests (audit record)
- Engineer struct and NewEngineer for potential future use
- Engineer.ProcessMR() (works with beads.Issue)
- Manager.ProcessMR() which is the working implementation

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 00:59:29 -08:00
Steve Yegge
212d818305 fix: Capture stderr instead of suppressing in command execution
Several files were setting cmd.Stderr = nil, which hides potentially
critical error messages:

- prime.go: bd prime, gt mail check, and bd show commands now log
  stderr on failure for debugging
- orphans.go: git fsck now includes stderr in error messages
- patrol_helpers.go: bd list/show/catalog commands now log stderr

Daemon launch cases (up.go, daemon.go, daemon_check.go) correctly
use nil for I/O detachment but now have clarifying comments.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 00:52:02 -08:00
Steve Yegge
4e67f7e637 feat: Add convoy patrol steps to Deacon formula
Added three new patrol steps for convoy orchestration:
- check-convoy-completion: Watch for tracked issue closures, auto-close convoys
- resolve-external-deps: Propagate cross-rig dependency resolution
- fire-notifications: Notify Overseer/Witnesses of convoy and dep events

Updated health-scan to depend on fire-notifications (runs after convoy steps).

(gt-wthcc)

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 00:50:24 -08:00
Steve Yegge
d8be33d13e fix: Witness cleanup uses gt polecat nuke for correct repo base
The witness template previously instructed using raw git commands:
- git worktree remove polecats/<name>
- git branch -d polecat/<name>

This failed because git worktree operations must run from the repo
that created the worktree (mayor/rig or .repo.git), not the rig root.

Now uses `gt polecat nuke` which handles repo base detection via
the repoBase() function and properly cleans up worktrees.

Fixes gt-gp6i

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 00:49:51 -08:00
Steve Yegge
a68cf54057 fix: Detect and auto-remove circular redirect files in beads (gt-csbjj)
Added multiple layers of protection against circular redirects:

1. ResolveBeadsDir now detects when a redirect points back to itself
   and auto-removes the errant redirect file with a warning

2. ensureBeadsRedirect now includes safety checks:
   - Prevents creating redirects inside mayor/rig/ (the canonical location)
   - Validates that the redirect target is not the same as the beads dir

3. Added test case for circular redirect detection

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 00:48:52 -08:00
Steve Yegge
de32cb0be2 Fix mail inbox detecting wrong identity from witness/refinery dirs
When GT_ROLE env var is not set, detectSender() now falls back to
cwd-based detection instead of immediately returning "overseer".
This allows running mail commands from witness/refinery directories
without GT_ROLE set (e.g., debugging sessions) and correctly detecting
the identity from the current working directory path.

(gt-od1g)

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 00:43:20 -08:00
Steve Yegge
46868a5bab fix: Implement gt swarm dispatch command (gt-s94gq)
The dispatch command was documented in help text but never implemented.
Now it:
- Finds unassigned ready tasks in an epic
- Locates idle polecats (no hooked work)
- Slings the first available task to the first idle worker

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 00:35:21 -08:00
Steve Yegge
c47a7466d8 chore: Remove obsolete polecat formula files
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 00:19:12 -08:00