Commit Graph

440 Commits

Author SHA1 Message Date
Steve Yegge
c81f02de56 feat: witness instantiates mol-witness-patrol on start (gt-59zd.3)
Add patrol instance tracking to witness manager:

- Add PatrolInstanceID to WitnessHandoffState for tracking
- Add ArmID to WorkerState for per-polecat arm tracking
- Add ensurePatrolInstance() method that:
  - Checks if patrol instance already exists (from previous session)
  - Creates new patrol instance if needed
  - Persists instance ID in handoff state

This enables the molecule-based tracking ledger pattern where the
Go-based witness creates beads issues to track its patrol state.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 22:28:39 -08:00
Steve Yegge
43eaf461b3 feat: add Christmas Ornament pattern integration tests (gt-tnow.4)
Add comprehensive integration tests for the mol-witness-patrol and
mol-polecat-arm molecule pattern:

- TestChristmasOrnamentPattern: verifies mol-witness-patrol structure,
  WaitsFor: all-children on aggregate step, mol-polecat-arm structure,
  template variable expansion, and bonding metadata parsing
- TestEmptyPatrol: tests 0 polecats case (empty arms)
- TestNudgeProgression: verifies nudge matrix documentation
- TestPreKillVerification: tests pre-kill verification flow
- TestWaitsForAllChildren: tests fanout gate semantics
- TestMultipleWaitsForConditions: tests parsing multiple conditions
- TestMolBondCLI: simulates mol bond command behavior
- TestActivityFeed: verifies generate-summary step documentation

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 22:07:11 -08:00
Steve Yegge
a8739f5548 fix: remove bd sync from polecat startup sequence (gt-aobh)
Polecats share the same beads database at the rig level. The refinery
and witness manage syncing beads. Running bd sync on polecat startup
causes contention when multiple polecats spawn simultaneously and
creates potential race conditions.

This change removes bd sync --from-main from:
- prompts/roles/polecat.md On Startup section
- internal/beads/molecules_session.go orient step
- internal/beads/molecules_work.go orient step
- docs/polecat-wisp-architecture.md load context section

Troubleshooting sections that recommend bd sync --from-main for
recovery scenarios are preserved.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 21:53:31 -08:00
Steve Yegge
9f2eefe9ce fix: verify polecat branch pushed before cleanup (gt-gl6s)
Add BranchPushedToRemote() to git package that properly handles
polecat branches without upstream tracking. Update verifyPolecatState
in witness to check that branches are pushed before allowing cleanup.

This prevents the scenario where polecats close issues without pushing
their work, causing all commits to be lost when the worktree is deleted.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 21:50:31 -08:00
Steve Yegge
031a27c062 feat: add WaitsFor parsing and mol bond command (gt-odfr, gt-isje)
WaitsFor parsing:
- Add WaitsFor []string field to MoleculeStep struct
- Parse WaitsFor lines in molecule descriptions
- Enables fanout gate semantics (e.g., WaitsFor: all-children)
- Case-insensitive parsing like Needs/Tier

mol bond command:
- Add gt mol bond for dynamic child molecule creation
- Supports --parent, --ref, and --var flags
- Enables Christmas Ornament pattern for parallel child execution
- Creates child issue with expanded template variables
- Instantiates proto steps under the bonded child

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 21:44:25 -08:00
Steve Yegge
b685879b63 Refinery as worktree: local MR integration (gt-4u5z)
Architecture changes:
- Refinery created as worktree of mayor clone (shares .git)
- Polecat branches stay local (never pushed to origin)
- MRs stored as wisps in .beads-wisp/mq/ (ephemeral)
- Only main gets pushed to origin after merge

New mrqueue package for wisp-based MR storage.
Updated spawn, done, mq_submit, refinery, molecule templates.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 21:25:01 -08:00
Steve Yegge
33f8584e77 feat: implement Christmas Ornament pattern for mol-witness-patrol (gt-tnow.1, gt-tnow.2)
- Update WitnessPatrolMolecule() with dynamic bonding pattern:
  - PREFLIGHT: inbox-check, check-refinery, load-state
  - DISCOVERY: survey-workers (bonds mol-polecat-arm per polecat)
  - CLEANUP: aggregate (WaitsFor: all-children), save-state, generate-summary,
    context-check, burn-or-loop
  - Reduced from 11 sequential steps to 9 with parallel arm execution

- Add PolecatArmMolecule() for per-polecat inspection:
  - 5 sequential steps: capture, assess, load-history, decide, execute
  - Uses {{polecat_name}} and {{rig}} variable substitution
  - Bonded dynamically by survey-workers step

- Update tests: 14 builtin molecules, new test cases

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 21:22:22 -08:00
Steve Yegge
1931ec736a Polecat template cleanup (gt-t9u7)
- Rename "Dependency Trap" to "Gotchas when Filing Beads" in all 6 role templates
- Fix "git clone" to "git worktree" in polecat template
- Simplify completion section to just "gt done"
- Condense Work Protocol section (let molecule define steps)
- Simplify "Before Signaling Done" to trust gt done internals
- Clarify work status: use "gt mol status" as primary command

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 17:08:55 -08:00
Steve Yegge
475dcb37fa gt sling: enable wisp spawning for patrol roles (gt-jsup)
Revert IsWisp: false → true for patrol spawning. bd mol run now
auto-discovers the main database for templates when --db contains
.beads-wisp, so patrol molecules can spawn correctly into ephemeral storage.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 16:39:46 -08:00
Steve Yegge
58c0fae614 gt sling: use mail queue for patrol roles (gt-afn0)
When slinging work to patrol agents (witness, refinery, deacon), queue via
mail instead of replacing the hook. This preserves patrol continuity.

New behavior:
- Default: Check if patrol is running, start default patrol if not, send
  work via mail. Patrol processes queued work during its cycle.
- --urgent: Marks mail as urgent (🚨 URGENT prefix)
- --replace: Legacy behavior, explicitly terminates patrol (break-glass)

New helper functions:
- isPatrolRole(kind): Returns true for witness/refinery/deacon
- getDefaultPatrolMolecule(role): Returns patrol template name
- resolvePatrolMoleculeID(path, title): Looks up beads issue ID by title
- isPatrolRunning(path, addr): Checks if patrol molecule is attached

Note: Patrol spawning currently uses main DB (not wisp storage) because
templates must be looked up from the main database. Wisp support for
patrol instances is a future enhancement.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 16:24:55 -08:00
Steve Yegge
7f37d41da3 gt sling --force: return displaced work to ready pool (gt-o40t)
When slinging with --force to an agent with occupied hook, the displaced
molecule is now returned to the ready pool rather than silently orphaned.

Changes:
- Modified checkHookCollision to take force param and return displaced ID
- Added releaseDisplacedWork helper to unpin and release displaced molecules
- Updated all 5 sling handlers (polecat, crew, witness, refinery, mayor)

Behavior:
- Without --force: still errors "hook already occupied by X"
- With --force: prints warning, releases old work, proceeds with new sling

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 16:07:42 -08:00
Steve Yegge
5e093dadff Fix witness session to start in witness directory
The witness session was starting in the rig root (e.g., /gt/gastown)
instead of the witness directory (e.g., /gt/gastown/witness/rig).
This caused gt prime to detect the Mayor role instead of Witness role.

Now ensureWitnessSession uses the same pattern as ensureRefinerySession:
1. Try <rig>/witness/rig/ first (for rigs with worktree setup)
2. Fall back to <rig>/witness/ (for simpler setups)
3. Last resort: use rig root (shouldn't happen normally)

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 16:07:23 -08:00
Steve Yegge
c8bb8ac6b9 Add Dependency Trap warning to all gt prime role templates
Temporal language like "Phase 1 blocks Phase 2" triggers incorrect
dependency direction. Added a concise warning to all 6 role templates
(crew, polecat, mayor, witness, refinery, deacon) reminding agents:
- Think "X needs Y", not "X comes before Y"
- Verify with `bd blocked`

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 15:13:32 -08:00
Steve Yegge
c3e7baf3f9 Document session cycling protocol in templates (gt-5xph)
- Crew: Updated to use 'gt handoff' instead of manual mail
- Crew: Added note about relaxed cycling (no fixed heuristic)
- Polecat: Added note that 'gt handoff' redirects to 'gt done'

Patrol workers (Deacon, Witness, Refinery) already had their
N-rounds heuristics documented in previous commits.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 14:43:11 -08:00
Steve Yegge
d823ced14c refactor: Nuanced refinery context heuristic - 20 simple or immediate on complex (gt-nqrh)
Most MRs are button-pushes (clean rebase + push). Only complex rebases
(conflicts, test failures) consume significant context.

- 20 simple MRs before handoff
- Immediate handoff after any complex rebase

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 14:11:40 -08:00
Steve Yegge
366d3c8ca7 feat: Add context management heuristics to patrol role templates (gt-nqrh)
Each patrol role now has role-specific context management:
- Deacon: 20 loops or immediate on extraordinary action
- Witness: 15 polecats processed (spawns + nudges + decommissions)
- Refinery: 7 merge requests processed

Templates include state.json format and handoff instructions.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 14:08:35 -08:00
Steve Yegge
9c85b834cd Support full session paths in gt handoff (gt-tocb)
resolveRoleToSession now accepts paths like <rig>/crew/<name>,
<rig>/witness, and <rig>/refinery in addition to role shortcuts.
For example: 'gt handoff gastown/crew/max' now works.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 13:25:59 -08:00
Steve Yegge
1414081e10 Standardize session end with gt handoff (gt-yt6g)
- Update gt handoff to detect polecats (via GT_POLECAT env var) and
  call gt done instead of respawning - polecats have Witness-managed lifecycle
- Update CLAUDE.md Session End Checklist to use gt handoff
- This is the canonical way to end any agent session - it handles mail,
  respawn, and context restoration via SessionStart hook

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 13:07:26 -08:00
Steve Yegge
e3500543f3 Fix handoff to set correct working directory for each role
buildRestartCommand now detects the town root and includes a cd to the
appropriate directory before launching claude. This ensures each role
starts in its correct working directory:
- gt-mayor → town root (~/gt)
- gt-deacon → ~/gt/deacon
- crew sessions → ~/gt/<rig>/crew/<name>
- witness sessions → ~/gt/<rig>/witness
- refinery sessions → ~/gt/<rig>/refinery

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 12:59:41 -08:00
Steve Yegge
8d47911623 Fix deacon startup: use ~/gt/deacon dir and export GT_ROLE
The daemon was creating the deacon session in ~/gt (town root) which loaded
the Mayor CLAUDE.md instead of the Deacon CLAUDE.md. Also, tmux SetEnvironment
does not export variables to spawned processes.

Changes:
- Create deacon session in ~/gt/deacon (correct CLAUDE.md)
- Export GT_ROLE=deacon in launch command (process inherits env)
- Apply to both initial launch and restart paths

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 12:39:04 -08:00
Steve Yegge
5639dd7f84 Document bd pinned field bug in beads.Pin() (gt-o3is)
Added comment explaining that the pinned field gets overwritten by
subsequent bd commands due to a bug in the beads auto-import logic.
The handoff bead attachment mechanism works correctly and is the
primary work assignment mechanism.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 12:27:18 -08:00
Steve Yegge
6383ae6075 Add gt broadcast command to nudge all workers
New command that sends a message to all active workers (polecats + crew).
Supports filtering by rig with --rig flag, and can include infrastructure
agents (mayor, deacon, witness, refinery) with --all flag.

Usage:
  gt broadcast "Check your mail"
  gt broadcast --rig gastown "New work available"
  gt broadcast --all "System maintenance in 5 minutes"
  gt broadcast --dry-run "Test"

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 12:15:25 -08:00
Steve Yegge
fc38fb35d7 feat(doctor): add orphaned-attachments check (gt-h6eq.3)
Add doctor check to detect handoff beads for agents that no longer exist.
This happens when a polecat worktree is deleted but its handoff bead remains.

- Check: orphaned-attachments
- Warning if: Handoff bead exists for agent that no longer has worktree
- Supports polecats (rig/name), crew (rig/crew/name), mayor, witness, refinery
- Suggests re-sling to active agent or close the molecule

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 11:50:31 -08:00
Steve Yegge
90722ee65f feat: add hook status to gt status command (gt-h6eq.6)
Add HookInfo struct and hook discovery to show which agents have work
attached to their hooks. Updates both JSON and text output:

- New HookInfo type with agent, role, has_work, molecule, and title fields
- RigStatus now includes Hooks slice
- StatusSum includes ActiveHooks count
- discoverRigHooks() scans polecats, crew, witness, and refinery
- getAgentHook() retrieves hook status from handoff beads
- Text output shows active hooks per rig with agent and molecule info

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 11:49:28 -08:00
Steve Yegge
00c64a075c feat: add gt mol attach-from-mail command (gt-h6eq.7)
Allows agents to self-pin work from mail messages. The command:
1. Reads a mail message by ID
2. Extracts molecule ID from the body (attached_molecule:, molecule_id:, etc.)
3. Attaches the molecule to the agent's pinned bead (hook)
4. Marks the mail as read

Includes unit tests for the molecule ID extraction logic.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 11:44:34 -08:00
Steve Yegge
8be2146a48 docs: update role templates with hook-first startup protocol (gt-h6eq.9)
Updated all role prompt templates to document the startup hook protocol:
- polecat.md.tmpl: Added gt mol status check, self-pin from mail protocol
- witness.md.tmpl: Added gt mol status check, self-pin from mail protocol
- refinery.md.tmpl: Added gt mol status check, self-pin from mail protocol
- crew.md.tmpl: Added new Startup Protocol section with hook-first flow
- deacon.md.tmpl: Added gt mol status check, self-pin from mail protocol
- mayor.md.tmpl: Expanded startup protocol with hook-first flow

Each template now includes:
1. Check hook first (gt mol status)
2. If empty, check mail for attached work
3. Self-pin protocol (gt mol attach-from-mail) if needed
4. Role-specific fallback behavior

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 11:44:14 -08:00
Steve Yegge
949e1228a6 feat: add gt hooks command to list Claude Code hooks
Add a command to list all hooks in the workspace. Scans for .claude/settings.json
files and displays hooks by type (SessionStart, PreCompact, UserPromptSubmit, etc).

Features:
- Scans town root, rigs, polecats, crew, witness, and refinery directories
- Shows hook type, location, status, and agent that owns it
- Supports --verbose flag to show hook commands
- Supports --json flag for machine-readable output

(gt-h6eq.5)

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 11:42:48 -08:00
Steve Yegge
26a7e54205 feat(doctor): add hook-singleton check (gt-h6eq.1)
Add doctor check to ensure each agent has at most one handoff bead.
Detects when multiple pinned beads exist with the same "{role} Handoff"
title, which can cause confusion about which handoff is authoritative.

- Check: hook-singleton
- Error if: Multiple pinned beads with same '{role} Handoff' title
- Fix: Automatically closes duplicates (keeps oldest) when run with --fix

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 11:42:35 -08:00
Steve Yegge
f2266db12d Add stale-attachments doctor check (gt-h6eq.4)
Implements a new doctor check that detects attached molecules that
haven't been updated in too long, which may indicate stuck work.
The check:
- Finds all pinned beads with attachments across rigs
- Checks the attached molecule's UpdatedAt timestamp
- Reports molecules in_progress with no activity for >1 hour
- Provides actionable fix hints for stuck polecats

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 11:41:43 -08:00
Steve Yegge
9fa4a42030 feat: add audit trail for detach operations (gt-h6eq.8)
Add DetachMoleculeWithAudit() function that logs detach operations
to .beads/audit.log in JSONL format. Each entry captures:
- timestamp
- operation type (detach, burn, squash)
- pinned_bead_id
- detached_molecule
- detached_by (agent identity)
- reason (optional)
- previous_state

Updated callers:
- runMoleculeDetach: logs "detach" operation
- runMoleculeBurn: logs "burn" operation with reason
- runMoleculeSquash: logs "squash" operation with digest ID

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 11:40:06 -08:00
Steve Yegge
78a20f0aad feat(doctor): add hook-attachment-valid check (gt-h6eq.2)
Add doctor check to verify that attached molecules exist and are not closed.
Detects when a hook's attached_molecule field points to a non-existent or
closed issue, which can leave agents with stale work assignments.

- Check: hook-attachment-valid
- Error if: Hook's attached_molecule field points to non-existent or closed issue
- Fix: Automatically detaches invalid molecules when run with --fix

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 11:34:50 -08:00
Steve Yegge
84aa69207a fix: add Pin/Unpin methods and call bd pin in pinToHook (gt-o3is)
Adds Pin() and Unpin() methods to the beads wrapper that call bd pin/unpin.

Updates pinToHook() to call b.Pin() after AttachMolecule() to set the
pinned boolean field and assignee on the work issue. This should enable
bd hook to show pinned work.

NOTE: There's a known issue where bd pin via subprocess doesn't actually
set the pinned field even though it reports success. The handoff bead
attachment remains the primary mechanism until this is resolved.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 04:51:17 -08:00
Steve Yegge
46ce96ae62 merge: resolve conflict in tmux.go (keep SwitchClient) 2025-12-23 04:48:14 -08:00
Steve Yegge
42d8944f71 feat: default crew name to 'max', support town-level override
- Add DefaultCrewName constant ('max') to config package
- Add default_crew_name field to MayorConfig for town-level override
- Update gt rig add to resolve crew name: --crew flag > town config > default
- Update help text to reflect new default

Priority: --crew flag > MayorConfig.DefaultCrewName > config.DefaultCrewName ('max')
2025-12-23 04:47:07 -08:00
Steve Yegge
84c7d48ef4 feat: add crew, witness, refinery, mayor as sling targets
Adds support for slinging work to four new target types:

- crew (e.g., beads/crew/dave): Human-managed persistent workers
  - No worktree recreation
  - No auto-session start
  - Sends work assignment mail

- witness (e.g., gastown/witness): Per-rig lifecycle manager
  - Suggests --wisp for ephemeral work
  - Pins to witness hook

- refinery (e.g., gastown/refinery): Per-rig merge queue
  - Accepts protos, issues, and epics
  - Pins to refinery hook

- mayor (e.g., mayor/): Town-level coordinator
  - Uses town-level beads
  - Human-managed like crew
  - Sends work assignment mail

Updated help text with new target formats and examples.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 04:37:29 -08:00
Steve Yegge
3ee23f5c63 fix: add missing gt account status command
The help text documented this subcommand but it wasn't implemented.
Adds status command showing currently resolved account with source
(GT_ACCOUNT env var or default).

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 04:16:32 -08:00
Steve Yegge
ba2db2bc11 feat: implement account management for multi-account Claude Code (gt-3133)
Adds support for managing multiple Claude Code accounts in Gas Town:

- accounts.json config parsing in mayor/ directory
- gt account list/add/default commands
- GT_ACCOUNT env var support with priority resolution
- --account flag on gt spawn and gt crew at commands
- CLAUDE_CONFIG_DIR injection into tmux sessions

Priority order: GT_ACCOUNT env var > --account flag > default from config

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 04:05:14 -08:00
Steve Yegge
5f2e16f789 refactor: remove shell respawn loops from witness and deacon (gt-zxgu)
Shell loops bypassed the proper lifecycle architecture. Now:

- Witness: Launches Claude directly, daemon/deacon health-scan handles restart
- Deacon: Launches Claude directly, daemon detects exit and restarts
- Daemon: ensureDeaconRunning() now checks if Claude is running (pane cmd)
         and restarts it if session exists but Claude has exited
- gt deacon restart: Now does stop+start instead of Ctrl-C

This enforces proper lifecycle flow through LIFECYCLE mail and daemon
heartbeat rather than bypassing it with shell loops.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 04:02:17 -08:00
Steve Yegge
46a5e38fa2 feat: add restart subcommands to witness and refinery (gt-9kc2)
- Add `gt witness restart <rig>` command (stop + start)
- Add `gt refinery restart [rig]` command (stop + start)
- Add self-cycling documentation to refinery template
- Clarify that restarts are daemon-managed, not shell loops

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 03:56:31 -08:00
Steve Yegge
44bbeb6c7c refactor: split builtin_molecules.go into category files (gt-nmtp)
Split 1620-line file into 4 organized files:
- builtin_molecules.go (77 lines) - type, registry, seeder
- molecules_patrol.go (567 lines) - Deacon, Witness, Refinery patrol
- molecules_work.go (446 lines) - EngineerInBox, QuickFix, Research, PolecatWork, ReadyWork
- molecules_session.go (545 lines) - CrewSession, PolecatSession, Bootstrap, VersionBump, InstallGoBinary

Benefits:
- Easier to find/edit specific molecules
- Smaller diffs on changes
- Clear categorization by purpose

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 02:44:28 -08:00
Steve Yegge
be5509fb18 gt down --all: also kill tmux server 2025-12-23 02:04:17 -08:00
Steve Yegge
18fb0e05fe feat(handoff): add -s/-m flags for ergonomic handoff mail
Agents naturally expect `gt handoff -s "Subject" -m "Message"` to work
like `gt mail send`. Now it does:

- Added --subject/-s and --message/-m flags to gt handoff
- Added --self flag to gt mail send for sending to self
- Handoff auto-sends mail to self before respawning pane

This makes agent-initiated handoff more ergonomic - they can include
context in a single command instead of two separate steps.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 01:51:47 -08:00
Steve Yegge
5459e8e6b1 Deacon startup: auto-bond mol-deacon-patrol on gt prime
- Add auto-spawn logic to outputDeaconPatrolContext()
- Deacon now auto-spawns mol-deacon-patrol if no active patrol
- All three patrol roles now have consistent auto-bond behavior:
  Deacon, Witness, Refinery

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 01:47:41 -08:00
Steve Yegge
0dac49636c Witness startup: auto-bond mol-witness-patrol on gt prime (gt-lx3n)
- Add outputWitnessPatrolContext() function in prime.go
- Witness now auto-spawns mol-witness-patrol if no active patrol
- Fixed catalog ID parsing (strip trailing colon) for both witness and refinery
- Created mol-witness-patrol template with 10 steps (gt-qflq)

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 01:43:49 -08:00
Steve Yegge
78507ff326 refactor(cmd): split molecule.go into focused files
Split the 1929-line molecule.go into 5 focused files:
- molecule.go (376): command definitions, init(), loadMoleculeCatalog
- molecule_status.go (673): status, progress, current commands
- molecule_list.go (432): list, show, export, parse, instances
- molecule_lifecycle.go (359): instantiate, catalog, burn, squash
- molecule_attach.go (128): attach, detach, attachment

No functional changes - pure refactoring for maintainability.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 01:38:34 -08:00
Steve Yegge
8e3beda87c Merge remote-tracking branch 'origin/polecat/dementus' 2025-12-23 01:15:54 -08:00
Steve Yegge
b15557ba37 Merge remote-tracking branch 'origin/polecat/rictus' 2025-12-23 01:15:51 -08:00
Steve Yegge
6e2d901213 Merge remote-tracking branch 'origin/polecat/valkyrie' 2025-12-23 01:15:50 -08:00
Steve Yegge
b3fa1f7edb feat: Add mol-ready-work protomolecule (cherry-pick from polecat/immortan)
Adds autonomous backlog processing patrol molecule for crew workers.
The molecule scans PRs, GitHub issues, and beads; selects work using
an ROI heuristic; executes items; and loops until context is low.

Key features:
- Vapor phase (wisp) - ephemeral patrol cycles
- Scans 4 backlogs: PRs > untriaged > beads > triaged
- ROI-based selection with context awareness
- Per-type execution handlers (PR review, triage, implementation)
- Clean handoff protocol with digest squashing

Original commit: 20e2a13 by immortan
Issue: gt-tnca.1

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 01:08:24 -08:00
Steve Yegge
37c2382767 Unify startup protocols: all roles use 'gt mol status' + RUN IT pattern
- Mayor/Crew: mol attached → RUN IT, else await instruction
- Witness/Refinery/Deacon: mol attached → RUN IT, else spawn patrol
- Polecat: mol attached → RUN IT, else ERROR (polecats must have work)
2025-12-23 01:05:48 -08:00