Commit Graph

2884 Commits

Author SHA1 Message Date
Keith Wyatt
7d8d96f7f9 perf(up): parallelize all agent startup with concurrency limit (#476)
* perf(up): parallelize agent startup with worker pool and channel-based collection

- Run daemon, deacon, mayor, and rig prefetch all in parallel (4-way concurrent init)
- Use fixed worker pool instead of goroutine-per-task for bounded concurrency
- Replace mutex-protected maps with channel-based result collection (zero lock contention)
- Pre-allocate maps with known capacity to reduce allocations
- Use string concatenation instead of fmt.Sprintf for display names
- Reduce `gt up` startup time from ~50s to ~10s for towns with multiple rigs

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(lint): fix errcheck and misspell issues in orphans.go

- Check error return from fmt.Scanln calls
- Fix "Cancelled" -> "Canceled" spelling

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 13:46:50 -08:00
sigfawn
69110309cc fix(mail): refactor duplicated inbox logic and fix clear race condition (#435) 2026-01-13 13:45:25 -08:00
sigfawn
901b60e927 fix(beads): cache version check and add timeout to prevent cli lag (#436)
Reviewed: Good optimizations - sync.Once caching, 2s timeout, pre-compiled regex. All idiomatic Go.
2026-01-13 13:44:13 -08:00
sigfawn
712a37b9c1 fix(mail_queue): add nil check for queue config (#437)
* fix(beads): cache version check and add timeout to prevent cli lag

* fix(mail_queue): add nil check for queue config

Prevents potential nil pointer panic when queue config exists
in map but has nil value. Added || queueCfg == nil check to
the queue lookup condition in runMailClaim function.

Fixes potential panic that could occur if a queue entry exists
in config but with a nil value.
2026-01-13 13:43:54 -08:00
sigfawn
aa0bfd0c40 fix(hook): handle error from events.LogFeed (#440)
* fix(beads): cache version check and add timeout to prevent cli lag

* fix(mail_queue): add nil check for queue config

Prevents potential nil pointer panic when queue config exists
in map but has nil value. Added || queueCfg == nil check to
the queue lookup condition in runMailClaim function.

Fixes potential panic that could occur if a queue entry exists
in config but with a nil value.

* fix(migrate_agents_test): fix icon expectations to match actual output

The printMigrationResult function uses icons with two leading spaces
("  ✓", "  ⊘", "  ✗") but the test expected icons without spaces.
This fixes the test expectations to match the actual output format.

* fix(hook): handle error from events.LogFeed

Previously the error from LogFeed was silently ignored with _.
Now we log the error to stderr at warning level but don't fail
the operation since the primary hook action succeeded.
2026-01-13 13:40:57 -08:00
Julian Knutsen
1453b8b592 fix(handoff): use correct witness working directory (#444)
The witness role doesn't have a /rig worktree like the refinery does.
The handoff command was trying to cd to <rig>/witness/rig which doesn't
exist, causing the respawned pane to fail immediately and the session
to die.

Changed witness workdir from <rig>/witness/rig to <rig>/witness.

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 13:39:55 -08:00
Julian Knutsen
65c5e05c43 fix(polecat): kill orphan sessions and clear stale hooks during allocation (#448)
ReconcilePool now detects and kills orphan tmux sessions (sessions without
corresponding polecat directories). This prevents allocation from being
blocked by broken state from crashed polecats.

Changes:
- Add tmux to Manager to check for orphan sessions during reconciliation
- Add ReconcilePoolWith for testable session/directory reconciliation logic
- Always clear hook_bead slot when reopening agent beads (fixes stale hooks)
- Prune stale git worktree entries during reconciliation

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 13:37:00 -08:00
Julian Knutsen
bd2a5ab56a fix(sling): fix formula lookup in --on mode (#422) (#449)
Reviewed: Fix is correct - cook runs from cwd for formula access, wisp gets GT_ROOT for formula lookup.
2026-01-13 13:36:07 -08:00
Julian Knutsen
f32a63e6e5 feat(done): complete self-cleaning by killing tmux session (#450)
Polecats now fully clean up after themselves on `gt done`:
- Step 1: Nuke worktree (existing behavior)
- Step 2: Kill own tmux session (new)

This completes the "done means gone" model - both worktree and
session are terminated. Previously the session survived as a zombie.

Audit logging added to both systems:
- townlog: EventKill for `gt log` visibility
- events: TypeSessionDeath with structured payload

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 13:34:49 -08:00
Subhrajit Makur
c61b67eb03 fix(config): implement role_agents support in BuildStartupCommand (#19) (#456)
* fix(config): implement role_agents support in BuildStartupCommand

The role_agents field in TownSettings and RigSettings existed but was
not being used by the startup command builders. All services fell back
to the default agent instead of using role-specific agent assignments.

Changes:
- BuildStartupCommand now extracts GT_ROLE from envVars and uses
  ResolveRoleAgentConfig() for role-based agent selection
- BuildStartupCommandWithAgentOverride follows the same pattern when
  no explicit override is provided
- refinery/manager.go uses ResolveRoleAgentConfig with constants
- cmd/start.go uses ResolveRoleAgentConfig with constants
- Updated comments from hardcoded agent name to generic "agent"
- Added ValidateAgentConfig() to check agent exists and binary is in PATH
- Added lookupAgentConfigIfExists() helper for validation
- ResolveRoleAgentConfig now warns to stderr and falls back to default
  if configured agent is invalid or binary is missing

Resolution priority (now working):
1. Explicit --agent override
2. Rig's role_agents[role] (validated)
3. Town's role_agents[role] (validated)
4. Rig's agent setting
5. Town's default_agent
6. Hardcoded default fallback

Adds tests for:
- TestBuildStartupCommand_UsesRoleAgentsFromTownSettings
- TestBuildStartupCommand_RigRoleAgentsOverridesTownRoleAgents
- TestBuildAgentStartupCommand_UsesRoleAgents
- TestValidateAgentConfig
- TestResolveRoleAgentConfig_FallsBackOnInvalidAgent

Fixes: role_agents configuration not being applied to services

* fix(config): add GT_ROOT to BuildStartupCommandWithAgentOverride

- Fixes missing GT_ROOT and GT_SESSION_ID_ENV exports in
  BuildStartupCommandWithAgentOverride, matching BuildStartupCommand behavior
- Adds test for override priority over role_agents
- Adds test verifying GT_ROOT is included in command

This addresses the Greptile review comment about agents started with
an override not having access to town-level resources.

Co-authored-by: Steve Yegge <steve.yegge@gmail.com>
2026-01-13 13:34:22 -08:00
Steve Yegge
fa99e615f0 Merge pull request #452 from julianknutsen/fix/close-delete-hard-bug-workaround
fix(beads): use close instead of delete for agent bead lifecycle
2026-01-13 13:32:56 -08:00
gus
ff6c02b15d fix(lint): fix errcheck and misspell in orphans.go
- Check fmt.Scanln return values (errcheck)
- Fix "Cancelled" → "Canceled" spelling (misspell)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 13:32:13 -08:00
dustin
66805079de fix: prevent gt down --all from respawning bd daemon (#457)
CountBdDaemons() was using `bd daemon list --json` which triggers
daemon auto-start as a side effect. During shutdown verification,
this caused a new daemon to spawn after all daemons were killed,
resulting in "bd daemon shutdown incomplete: 1 still running" error.

Replaced all `bd daemon killall` calls with pkill in:
- stopBdDaemons()
- restartBdDaemons()

Changed CountBdDaemons() to use pgrep instead of bd daemon list.
Also removed the now-unused parseBdDaemonCount helper function and its tests.
2026-01-13 13:28:16 -08:00
beads/crew/emma
bedccb1634 fix(handoff): use workspace.FindFromCwd for town root detection
detectTownRootFromCwd() only checked for mayor/town.json, but
workspace.FindFromCwd() also accepts mayor/ directory as a secondary
marker. This fixes handoff failing in workspaces without town.json.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 13:27:25 -08:00
Daniel Sauer
e0e5a00dfc feat: Add worktree setup hooks for injecting local configurations (#458)
* feat: Add worktree setup hooks for injecting local configurations

Implements GitHub issue #220 - Worktree setup hook for injecting
local configurations.

When polecats are spawned, their worktrees are created from the rig's
repo. Previously, there was no way to inject custom configurations
during this process.

Now users can place executable hooks in <rig>/.runtime/setup-hooks/
to run custom scripts during worktree creation:

  rig/
    .runtime/
      setup-hooks/
        01-git-config.sh    <- Inject git config
        02-copy-secrets.sh  <- Copy secrets
        99-finalize.sh      <- Final setup

Features:
- Hooks execute in alphabetical order
- Non-executable files are skipped with a warning
- Hooks run with worktree as working directory
- Environment variables: GT_WORKTREE_PATH, GT_RIG_PATH
- Hook failures are non-fatal (warn but continue)

Example hook to inject git config:
  #!/bin/sh
  git config --local user.signingkey ~/.ssh/key.asc
  git config --local commit.gpgsign true

Related to: hq-fq2zg, GitHub issue #220

* fix(lint): remove unused error return from buildCVSummary

buildCVSummary always returned nil for its error value, causing
golangci-lint to fail with "result 1 (error) is always nil".

The function handles errors internally by returning partial data,
so the error return was misleading. Removed it and updated caller.
2026-01-13 13:27:04 -08:00
Steve Yegge
275910b702 Merge pull request #461 from sauerdaniel/pr/sling-fixes
fix(sling): auto-attach work molecule and handle dead polecats
2026-01-13 13:22:05 -08:00
Daniel Sauer
fdd4b0aeb0 test: Add test coverage for 16 files (40.3% → 45.5%) (#463)
* test: Add test coverage for 16 files (40.3% -> 45.5%)

Add comprehensive tests for previously untested packages:
- internal/agent/state_test.go
- internal/cmd/errors_test.go
- internal/crew/types_test.go
- internal/doctor/errors_test.go
- internal/dog/types_test.go
- internal/mail/bd_test.go
- internal/opencode/plugin_test.go
- internal/rig/overlay_test.go
- internal/runtime/runtime_test.go
- internal/session/town_test.go
- internal/style/style_test.go
- internal/ui/markdown_test.go
- internal/ui/terminal_test.go
- internal/wisp/io_test.go
- internal/wisp/types_test.go
- internal/witness/types_test.go

style_test.go uses func(...string) to match lipgloss variadic Render signature.

* fix(lint): remove unused error return from buildCVSummary

buildCVSummary always returned nil for its error value, causing
golangci-lint to fail with "result 1 (error) is always nil".

The function handles errors internally by returning partial data,
so the error return was misleading. Removed it and updated caller.
2026-01-13 13:19:27 -08:00
Keith Wyatt
f42ec42268 fix(sling): register hq-cv- prefix for convoy beads (#475)
Instead of changing the convoy ID format, register the hq-cv- prefix
as a valid route pointing to town beads. This preserves the semantic
meaning of convoy IDs (hq-cv-xxxxx) while fixing the prefix mismatch.

Changes:
- Register hq-cv- prefix during gt install
- Add doctor check and fix for missing convoy route
- Update routes_check tests for both hq- and hq-cv- routes

Fixes: gt-4nmfh

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 13:19:15 -08:00
dustin
503e66ba8d fix: add --allow-stale to --no-daemon reads for resilience (#465)
The beads.go run() function uses --no-daemon for faster read operations,
but this fails when the database is out of sync with JSONL (e.g., after
the daemon is killed during shutdown before it can sync).

Adding --allow-stale prevents these failures and makes witness/refinery
startup more reliable after gt down --all.
2026-01-13 13:18:07 -08:00
beads/crew/emma
8051c8bdd7 feat(hook): auto-detect agent in gt hook show
When no argument is provided, `gt hook show` now auto-detects the
current agent from context using resolveSelfTarget(), matching the
behavior of other commands like `gt hook` and `gt mail inbox`.

Fixes steveyegge/beads#1078

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 13:17:51 -08:00
Daniel Sauer
c0526f244e fix(lint): remove unused error return from buildCVSummary (#466)
buildCVSummary always returned nil for its error value, causing
golangci-lint to fail with "result 1 (error) is always nil".

The function handles errors internally by returning partial data,
so the error return was misleading. Removed it and updated caller.
2026-01-13 13:16:44 -08:00
Will Saults
bda248fb9a feat(refinery,boot): add --agent flag for model selection (#469)
* feat(refinery,boot): add --agent flag for model selection (hq-7d5m)

Add --agent flag to gt refinery start/attach/restart and gt boot spawn
commands for consistent model selection across all agent launch points.

Implementation follows the existing pattern from gt deacon start:
- Add StringVar flag for agent alias
- Pass override to Manager/Boot via SetAgentOverride()
- Use BuildAgentStartupCommandWithAgentOverride when override is set

Files affected:
- cmd/gt/refinery.go: add flags to start/attach/restart commands
- internal/refinery/manager.go: add SetAgentOverride and use in Start()
- cmd/gt/boot.go: add flag to spawn command
- internal/boot/boot.go: add SetAgentOverride and use in spawnTmux()

Closes #438

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* refactor(refinery,boot): use parameter-passing pattern for --agent flag

Address PR review feedback:

1. ADD TESTS: Add tests for --agent flag existence following witness_test.go pattern
   - internal/cmd/refinery_test.go: tests for start/attach/restart
   - internal/cmd/boot_test.go: test for spawn

2. ALIGN PATTERN: Change from setter pattern to parameter-passing pattern
   - Manager.Start(foreground, agentOverride) instead of SetAgentOverride + Start
   - Boot.Spawn(agentOverride) instead of SetAgentOverride + Spawn
   - Matches witness.go style: Start(foreground bool, agentOverride string, ...)

Updated all callers to pass empty string for default agent:
- internal/daemon/daemon.go
- internal/cmd/rig.go
- internal/cmd/start.go
- internal/cmd/up.go

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: furiosa <will@saults.io>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 13:14:47 -08:00
Jack Tastic
45de02db43 feat: Add explicit escalation instructions to polecat template (#468)
Replace weak "If You're Stuck" section with comprehensive escalation
guidance including:
- When to escalate (specific scenarios)
- How to escalate (gt escalate, mail to Witness, mail to Mayor)
- What to do after escalating (continue or exit cleanly)
- Anti-pattern example showing wrong vs right approach

This prevents polecats from filing beads and passively waiting for
human input, which caused them to appear stuck in sessions.

Fixes: hq-t8zy
2026-01-13 13:09:28 -08:00
gastown/refinery
9315248134 fix(mq): persist MR rejection to beads storage
The RejectMR function was modifying the in-memory MR object but never
persisting the change to beads storage. This caused rejected MRs to
continue showing in the queue with status "open".

Fix: Call beads.CloseWithReason() to properly close the MR bead before
updating the in-memory state.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 12:54:54 -08:00
gastown/refinery
73a349e5ee fix(tests): resolve test failures in costs and polecat tests
Merge polecat/dementus-mkcdzdlu: Test fixes.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 12:09:16 -08:00
dementus
a2607b5b72 fix(tests): resolve test failures in costs and polecat tests
1. TestQuerySessionEvents_FindsEventsFromAllLocations
   - Skip test when running inside Gas Town workspace to prevent
     daemon interaction causing hangs
   - Add filterGTEnv helper to isolate subprocess environment

2. TestAddWithOptions_HasAgentsMD / TestAddWithOptions_AgentsMDFallback
   - Create origin/main ref manually after adding local directory as
     remote since git fetch doesn't create tracking branches for local
     directories

Refs: gt-zbu3x

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 12:07:50 -08:00
gastown/refinery
18893e713a feat(orphans): add list and kill subcommands for Claude process orphans
Merge polecat/rictus-mkd0azo9: Adds `gt orphans procs` command group
for managing orphaned Claude processes (PPID=1).

- `gt orphans procs` / `gt orphans procs list` - list orphan processes
- `gt orphans procs kill [-f]` - kill orphan processes with confirmation

Resolves conflict with existing `gt orphans kill` (for git commits) by
placing process orphan commands under `procs` subcommand.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 12:07:00 -08:00
rictus
ea12679a5a feat(orphans): add list and kill subcommands for Claude process orphans
Add commands to find and terminate orphan Claude processes (those with
PPID=1 that survived session termination):

- gt orphans list: Show orphan Claude processes
- gt orphans kill: Kill with confirmation
- gt orphans kill -f: Force kill without confirmation

Detection excludes:
- tmux processes (may contain "claude" in args)
- Claude.app desktop application processes
- Claude Helper processes

The original `gt orphans` functionality for finding orphan git commits
is preserved.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 12:02:38 -08:00
gastown/refinery
b1fcb7d3e7 fix(tmux): explicit process kill before session termination
Merge polecat/nux-mkd083ff: Updates KillSessionWithProcesses to use
cleaner inline exec.Command style and improved documentation.

Prevents orphan processes that survive tmux kill-session due to
SIGHUP being ignored by Claude processes.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 12:00:53 -08:00
rictus
a43c89c01b feat(orphans): add kill command to remove orphaned commits
Adds `gt orphans kill` subcommand that permanently removes orphaned
commits by running `git gc --prune=now`.

Flags:
- --dry-run: Preview without deleting
- --days N: Kill orphans from last N days (default 7)
- --all: Kill all orphans regardless of age
- --force: Skip confirmation prompt

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 11:54:52 -08:00
nux
e043f4a16c feat(tmux): add KillSessionWithProcesses for explicit process termination
Before calling tmux kill-session, explicitly kill the pane's process tree
using pkill. This ensures claude processes don't survive session termination
due to SIGHUP being caught/ignored.

Implementation:
- Add KillSessionWithProcesses() to tmux.go
- Update killSessionsInOrder() in start.go to use new method
- Update stopSession() in down.go to use new method

Fixes: gt-5r7zr

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 11:53:57 -08:00
dementus
87fde4b4fd feat(spawn): migrate to NewSessionWithCommand pattern
Migrate witness, boot, and deacon spawns to use NewSessionWithCommand
instead of NewSession+SendKeys to ensure BD_ACTOR is visible in the
process tree for orphan detection via ps.

Refs: gt-emi5b

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 11:06:21 -08:00
mayor
e083317cc3 fix(lint): remove unused error return from buildCVSummary
buildCVSummary always returned nil for its error value, causing
golangci-lint to fail with "result 1 (error) is always nil".

The function handles errors internally by returning partial data,
so the error return was misleading. Removed it and updated caller.
2026-01-13 17:44:15 +01:00
mayor
7924921d17 fix(sling): auto-attach work molecule and handle dead polecats
Combines three related sling improvements:

1. Auto-attach mol-polecat-work (Issue #288)
   - Automatically attach work molecule when slinging to polecats
   - Ensures polecats have standard guidance molecule attached

2. Fix polecat hook with molecule (Issue #197)
   - Use beads.ResolveHookDir() for correct directory resolution
   - Prevents bd cook from failing in polecat worktree

3. Spawn fresh polecat when target has no session
   - When slinging to a dead polecat, spawn fresh one instead of failing
   - Fixes stale convoys not progressing due to done polecats
2026-01-13 14:01:49 +01:00
mayor
278b2f2d4d fix(mayor): match handoff priming for gt may at startup (hq-osbot)
When starting Mayor via 'gt may at', the session now:
1. Works from townRoot (~/gt) instead of mayorDir (~/gt/mayor)
2. Includes startup beacon with explicit instructions in initial prompt
3. Removes redundant post-start nudges (beacon has instructions)

This matches the 'gt handoff' behavior where the agent immediately
knows to check hook and mail on startup.

Fixes: hq-h3449 (P0 escalation - horrendous starting UX)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 03:24:42 -08:00
mayor
791b388a93 chore: add design docs and ready command
- Add convoy-lifecycle.md design doc
- Add formula-resolution.md design doc
- Add mol-mall-design.md design doc
- Add ready.go command implementation
- Move dog-pool-architecture.md to docs/design/
- Update .gitignore for beads sync files

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 03:24:42 -08:00
julianknutsen
6becab4a60 fix(beads): use close instead of delete for agent bead lifecycle
bd delete --hard --force creates tombstones instead of truly deleting,
which blocks agent bead recreation when polecats are respawned with the
same name. The tombstone is invisible to bd show/reopen but still
triggers UNIQUE constraint on create.

Workaround: Use CloseAndClearAgentBead instead of DeleteAgentBead when
cleaning up agent beads. Closed beads can be reopened by
CreateOrReopenAgentBead.

Changes:
- Add CloseAndClearAgentBead() for soft-delete that allows reopen
- Clears mutable fields (hook_bead, active_mr, cleanup_status, agent_state)
  in description before closing to emulate delete --force --hard
- Update RemoveWithOptions to use close instead of delete
- Update RepairWorktreeWithOptions similarly
- Add comprehensive tests documenting the bd bug and verifying the workaround

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 10:44:07 +00:00
dementus
38bedc03e8 feat(spawn): migrate to NewSessionWithCommand pattern
Migrate witness, boot, and deacon spawns to use NewSessionWithCommand
instead of NewSession+SendKeys to ensure BD_ACTOR is visible in the
process tree for orphan detection via ps.

Refs: gt-emi5b

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 01:27:03 -08:00
capable
e7b0af0295 fix(done): verify commits exist before completing (hq-xthqf)
Add critical checks to prevent lost work when polecats call gt done
without having made any commits:

1. Block if working directory not available (cannot verify git state)
2. Block if uncommitted changes exist (would be lost on completion)
3. Check commits against origin/main not local main (ensures actual work)

If any check fails, refuse completion and suggest using --status DEFERRED.
This preserves the worktree so work is not lost.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 00:58:04 -08:00
dementus
f9ca7bb87b fix(done): handle getcwd errors when worktree deleted (hq-3xaxy)
gt done now completes successfully even if the polecat's worktree is
deleted mid-operation by the Witness or another process.

Changes:
- Add FindFromCwdWithFallback() that returns townRoot from GT_TOWN_ROOT
  env var when getcwd fails
- Update runDone() to use fallback paths and env vars (GT_BRANCH,
  GT_POLECAT) when cwd is unavailable
- Update updateAgentStateOnDone() to use env vars (GT_ROLE, GT_RIG,
  GT_POLECAT) for role detection fallback
- All bead operations are now explicitly non-fatal with warnings

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 00:17:59 -08:00
rictus
392ff1d31b feat(convoy): add --owner flag for targeted completion notifications
Add --owner flag to gt convoy create to track who requested a convoy.
Owner receives completion notification when convoy closes (in addition
to any --notify subscribers). Notifications are de-duplicated if owner
and notify are the same address.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 00:03:02 -08:00
george
58207a00ec refactor(mrqueue): remove mrqueue package, use beads for MRs (gt-dqi)
Remove the mrqueue side-channel from gastown. The merge queue now uses
beads merge-request wisps exclusively, not parallel .beads/mq/*.json files.

Changes:
- Delete internal/mrqueue/ package (~830 lines removed)
- Move scoring logic to internal/refinery/score.go
- Update Refinery engineer to query beads via ReadyWithType("merge-request")
- Add MRInfo struct to replace mrqueue.MR
- Add ClaimMR/ReleaseMR methods using beads assignee field
- Update HandleMergeReady to not create duplicate queue entries
- Update gt refinery commands (claim, release, unclaimed) to use beads
- Stub out MQEventSource (no longer needed)

The Refinery now:
- Lists MRs via beads.ReadyWithType("merge-request")
- Claims via beads.Update(..., {Assignee: worker})
- Closes via beads.CloseWithReason("merged", mrID)
- Blocks on conflicts via beads.AddDependency(mrID, taskID)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 23:48:56 -08:00
gus
f0192c8b3d fix(zfc): NamePool.InUse is transient, not persisted (hq-lng09)
ZFC violation: InUse was being persisted to JSON and loaded from disk,
but Reconcile() immediately overwrites it with filesystem-derived state.

Changes:
- Mark InUse with json:"-" to exclude from serialization
- Load() now initializes InUse as empty (derived via Reconcile)
- Updated test to verify OverflowNext persists but InUse does not

Per ZFC "Discover, Don't Track", InUse should always be derived from
existing polecat directories, not tracked as separate state.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 23:10:29 -08:00
mayor
15cfb76c2c feat(crew): accept rig name as positional arg in crew status
Allow `gt crew status <rig>` to work without requiring --rig flag.
This matches the pattern already used by crew start and crew stop.

Desire path: hq-v33hb

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 23:07:49 -08:00
nux
2d8949a3d3 feat(polecat): add identity show command with CV summary
Add `gt polecat identity show <rig> <polecat>` command that displays:
- Identity bead ID and creation date
- Session count
- Completion statistics (completed, failed, abandoned)
- Language breakdown from file extensions in git history
- Work type breakdown (feat, fix, refactor, etc.)
- Recent work list with relative timestamps
- First-pass success rate

Supports --json flag for programmatic output.

Closes: hq-d17es.4

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 22:55:39 -08:00
gastown/crew/george
f79614d764 feat(daemon): event-driven convoy completion check (hq-5kmkl)
Add ConvoyWatcher that monitors bd activity for issue closes and
triggers convoy completion checks immediately rather than waiting
for patrol.

- Watch bd activity --follow --town --json for status=closed events
- Query SQLite for convoys tracking the closed issue
- Trigger gt convoy check when tracked issue closes
- Convoys close within seconds of last issue closing

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 18:39:11 -08:00
gastown/crew/dennis
e442212c05 feat(convoy): add close command for manual convoy closure
Add `gt convoy close` command to manually close convoys regardless of
tracked issue status. This addresses the desire path identified in
convoy-lifecycle.md.

Features:
- Close convoy with optional --reason flag
- Send notification with optional --notify flag
- Idempotent: closing already-closed convoy is a no-op
- Validates convoy type before closing

Closes hq-2i8yw

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 18:12:47 -08:00
gus
6b2a7438e1 feat(deacon): add dog-health-check step to patrol
Adds supervision for dispatched dogs that may get stuck.

The new step (between dog-pool-maintenance and orphan-check):
- Lists dogs in "working" state
- Checks work duration vs plugin timeout (default 10m)
- Decision matrix based on how long overdue:
  - < 2x timeout: log warning, check next cycle
  - 2x-5x timeout: file death warrant
  - > 5x timeout: force clear + escalate to Mayor
- Tracks chronic failures for repeat offenders

This closes the supervision gap where dogs could hang forever
after being dispatched via `gt dog dispatch --plugin`.

Closes: gt-s4dp3

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 18:12:39 -08:00
jack
1902182f3a fix(start): use errors.Is consistently, remove redundant session check
- Use errors.Is() for all ErrAlreadyRunning comparisons (consistency)
- Remove redundant HasSession check before Start() (was a race anyway)
- Remove unused tmux parameters from startRigAgents and startWitnessForRig

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 18:00:14 -08:00
slit
c99b004aeb fix(plugin): add BEADS_DIR env to Recorder bd commands
The Recorder calls bd commands but wasn't setting the BEADS_DIR
environment variable. This could cause plugin run beads to be
created in the wrong database when redirects are in play.

Fixes: gt-z4ct5

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 17:48:07 -08:00