Commit Graph

470 Commits

Author SHA1 Message Date
Steve Yegge
066ef722ae OSS launch polish: fix hook paths, add OSS files, update README
- Fix slashes in agent identity causing invalid hook file paths (gt-vqhc)
- Add Prerequisites section to README (gt-vzic)
- Create CONTRIBUTING.md, CODE_OF_CONDUCT.md, SECURITY.md (gt-xbfw)
- Update Install section for future package managers (gt-7wcf)

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-24 23:28:31 -08:00
Steve Yegge
76ad6ed436 docs: Add handoff bead documentation to Witness and Refinery templates
- Witness: Added Handoff Bead section with nudge state schema
- Refinery: Added Handoff Bead section with merge queue state schema
- Both reference their respective pinned handoff beads

Closes gt-poxd

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-24 23:20:50 -08:00
Steve Yegge
de04f4177c docs: clarify stream engine model, reduce swarm terminology (gt-wexr)
Gas Town is a stream engine, not a swarm engine. Polecats can start
and land independently at any time. "Swarm" is used lightly for
batch coordination, but there are no swarm IDs or batch boundaries.

Changes:
- architecture.md: Add stream engine intro paragraph, update
  references from "swarming" to "parallel polecats" or "batch"
- prompts.md: Rename SWARM_* messages to BATCH_*, update terminology
- crew.md.tmpl: Replace "swarm" references with "transient worker pool"
  and "batch work"

The gt swarm command and internal/swarm/ package remain as-is since
they provide the tooling for batch operations.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-24 23:13:51 -08:00
Steve Yegge
5803103e71 gt spawn: fix proto ID for mol-polecat-work (gt-lwuu)
The proto ID is gt-lwuu, not mol-polecat-work. bd mol run looks up
by ID, not title. Updated spawn to use correct proto ID.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-24 22:55:57 -08:00
Steve Yegge
fca57f7468 gt spawn: auto-use mol-polecat-work for issue-based spawns
Issue-based spawns now automatically use mol-polecat-work to give
polecats a structured workflow with crash recovery checkpoints.
Use --molecule to override with a different molecule.

Completes gt-qvn7.3.1 (Phase 3: Polecat Work Cycle)

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-24 22:50:08 -08:00
Steve Yegge
e73529092d gt prime: Show molecule execution prompt with current step (gt-qvn7.2.3)
Phase 2 Hook Execution Protocol: When agent has attached molecule work,
gt prime now calls bd mol current to show:
- Molecule progress (completed/total steps)
- Current step ID and title
- Step description/instructions
- Propulsion directive ("EXECUTE THIS STEP NOW")
- Close/ready instructions for workflow advancement

Key insight from bd-hulf/bd-3zm7 rejection: Molecule state is derived
from child beads being open/closed - no separate state files needed.
"Advancing" = closing the current step bead.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-24 22:38:52 -08:00
Steve Yegge
7451e63a34 mail: default to wisp (ephemeral) for all messages
All mail is now ephemeral by default, matching the Gas Town design
that mail is transient operational state. Add --permanent flag for
the rare case when non-ephemeral mail is needed.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-24 22:34:05 -08:00
Steve Yegge
7e568770de refactor: remove legacy .beads-wisp infrastructure (gt-5klh)
Wisps are now just a flag on regular beads issues (Wisp=true).
No separate directory needed - hooks stored in .beads/.

Changes:
- wisp package: WispDir now points to .beads/, removed PatrolCycle
- manager.go: removed initWispBeads() - no separate dir to create
- mrqueue.go: MRs stored in .beads/mq/ instead of .beads-wisp/mq/
- doctor: removed obsolete wisp directory checks
- docs: updated wisp-architecture.md to reflect simplified model

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-24 21:34:14 -08:00
Steve Yegge
3763bde9fc fix: gt mol status now shows slung work from wisp hook files
The hook system had two disconnected mechanisms:
1. beads pinned field (bd pin) - what mol status checked
2. wisp hook files (gt hook) - what prime/startup checked

Now gt mol status checks BOTH, so hooked work via gt hook/sling/handoff
shows up properly in mol status output.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-24 21:24:28 -08:00
Steve Yegge
23600af50c docs: comprehensive hook/sling/handoff/nudge audit
- Update propulsion-principle.md: implementation status now accurate
- Update beads-data-plane.md: correct command syntax
- Fix hook.go: clarify durability semantics, add related commands
- Fix sling.go: use reliable NudgePane instead of raw tmux send-keys
- Add tmux.NudgePane: pane-targeted reliable message delivery

The command menagerie:
  gt hook    = assign (durability)
  gt nudge   = communicate (generic messaging)
  gt sling   = hook + nudge "start working"
  gt handoff = hook + restart (GUPP kicks in)

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-24 21:17:25 -08:00
Steve Yegge
57179c1e33 fix: gt sling now hooks + runs (no restart), update docs
Corrected sling behavior:
- gt hook: attach only (durability primitive)
- gt sling: attach + inject run prompt (preserve context)
- gt handoff: attach + restart (fresh context via GUPP)

Sling can now target other agents: gt sling <bead> <target>

Updated docs/sling-design.md with full command menagerie.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-24 21:04:24 -08:00
Steve Yegge
32cac078e5 refactor: split gt sling into gt hook + gt handoff <bead> (gt-z4bw)
- Add gt hook <bead>: durability primitive, attaches work to hook
- Update gt handoff: accept optional bead arg (detects bead vs role)
- Deprecate gt sling: shows warning, points to new commands
- Update doctor fix hint to reference new commands

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-24 20:41:51 -08:00
Steve Yegge
4801a98793 feat: simplify mail wisps - single DB with --wisp flag (gt-fgms)
Removed dual-routing architecture that used separate .beads-wisp/ directory.
Now uses single .beads/ with --wisp flag passed to bd create.

Changes:
- router.go: Remove resolveWispDir(), simplify shouldBeWisp()
- mailbox.go: Remove wispDir field and dual-source query logic
- types.go: Rename Ephemeral to Wisp, remove MessageSource
- mail.go: Rename --ephemeral to --wisp flag
- spawn.go: Use Wisp field for lifecycle messages

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-24 20:16:14 -08:00
Steve Yegge
200a09a02d feat: mail uses wisps for ephemeral orchestration messages (gt-lg66)
Add dual-inbox architecture where ephemeral messages go to
.beads-wisp/.beads/ instead of .beads/. Lifecycle messages
(POLECAT_STARTED, NUDGE, etc.) auto-detect as ephemeral.

Changes:
- Add Ephemeral and Source fields to mail.Message
- Add --ephemeral flag to gt mail send
- Router auto-detects lifecycle message patterns
- Mailbox merges messages from both persistent and wisp storage
- Inbox displays (ephemeral) indicator for wisp messages
- Delete/archive works for both message types

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-24 20:03:58 -08:00
Steve Yegge
b77e0fe09a chore: remove stale prompts/, mayor/, and scripts/ directories
- Delete prompts/roles/*.md (duplicates of internal/templates/roles/*.md.tmpl)
- Delete mayor/rig/docs/ (stale draft, canonical version in docs/)
- Delete scripts/ (replaced by Makefile and internal/daemon/)
- Update doctor check to validate internal/templates/roles/*.md.tmpl
- Update docs/prompts.md to reflect actual template location

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-24 16:46:56 -08:00
Steve Yegge
7c7b8b551d fix: critical issues in wisp hook system
Code review fixes:

1. CRITICAL: Move polecat check to start of runSling
   - Previously wrote wisp THEN failed, leaving orphan
   - Now fails fast before any file operations

2. CRITICAL: Sanitize slashes in agent IDs for filenames
   - Agent IDs like 'gastown/crew/joe' were creating subdirs
   - Now converts '/' to '--' for safe filenames
   - Added sanitizeAgentID/unsanitizeAgentID helpers

3. MODERATE: Use git root instead of WorkDir in prime.go
   - Hooks are written to clone root, not cwd
   - Added getGitRoot() helper for consistency

4. MODERATE: Fix silent error swallowing
   - Now logs non-ErrNoHook errors when reading hooks
   - Warns if bead doesn't exist before burning hook
   - Preserves hook if bead is missing for debugging
2025-12-24 16:20:04 -08:00
Steve Yegge
b2f1b58f13 feat: implement gt sling and wisp hook system (gt-qvn7.1)
Phase 1 of tracer bullet: Slinging Handoff

- Add internal/wisp package for ephemeral work attachment
- Add gt sling command to attach work and restart
- Update gt prime to check/burn slung work on hook
- Add .beads-wisp/ to gitignore
2025-12-24 16:08:15 -08:00
Steve Yegge
5560b64083 crew restart/at: use NudgeSession with longer delay for resume prompt
The resume prompt wasn't getting its Enter key reliably. Changed from
SendKeysDelayedDebounced (3s delay, 300ms debounce) to NudgeSession
(5s delay, 500ms debounce) which is the battle-tested method for
messaging Claude sessions.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-24 16:08:05 -08:00
Steve Yegge
e8dff71b37 crew at: don't link windows by default, add --detached flag
When running `gt crew at` from inside tmux:
- No longer auto-links the target session as a tab
- Just prints "Started X. Use C-b s to switch."
- User stays in their current pane

When running from outside tmux:
- Default: attach to the session (existing behavior)
- With -d/--detached: start session without attaching

This gives users more control over tmux session navigation and
reduces confusion for tmux newcomers.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-24 15:22:12 -08:00
Steve Yegge
b930704b5f fix: prevent tmux link-window from auto-switching windows (gt-wmhj)
When running `gt crew at <other>` from inside tmux, the linked window
would auto-select, causing users to unknowingly switch agents. Add -d
flag to keep user in their current window.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-24 14:34:25 -08:00
Steve Yegge
c10709dc3f terminology: spawn → pour/wisp for molecules (gt-9uy0)
Molecules use chemistry verbs, not spawn:
- pour = create persistent mol (liquid)
- wisp = create ephemeral wisp (vapor)
- spawn = polecats only (workers)

Changes:
- Delete chemistry-design-changes.md (migration doc)
- Remove migration tables from sling-design.md
- Update bond tables: Spawn → Pour/Wisp
- Rename spawnMoleculeFromProto → pourMoleculeFromProto
- Rename spawnMoleculeOnIssue → runMoleculeOnIssue
- Update templates: bd mol spawn → bd wisp
- Update prime.go: commands and messages
- Clean all docs and comments

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-24 14:04:19 -08:00
Steve Yegge
8705e843c7 refactor: replace 'spawn' with 'create/wisp' for molecule terminology (gt-9uy0)
'Spawn' should only be used for polecats (workers). Molecules use:
- bd wisp <proto> - create ephemeral wisp
- bd pour <proto> - create persistent mol

Updated:
- prompts/roles/deacon.md: bd mol spawn → bd wisp
- internal/templates/roles/deacon.md.tmpl: spawn → create/wisp
- internal/templates/roles/witness.md.tmpl: gt mol spawn → bd wisp
- internal/cmd/prime.go: all mol spawn calls → wisp calls
- docs/molecular-chemistry.md: spawn terminology → create/instantiate

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-24 13:17:22 -08:00
Steve Yegge
e7f9dc8576 docs: design Deacon molecule health-scan step (gt-gaxo.5)
ZFC cleanup: health checking belongs in Deacon molecule, not Go code.

Updated health-scan step with:
- Specific commands: gt witness status, gt refinery status
- Signal assessment table for Claude to interpret
- Cycle tracking for persistent unresponsive state
- Decision matrix with suggested (not hardcoded) thresholds
- Restart and escalation workflows

Key ZFC principle: Claude makes the judgment call about what is
stuck or unresponsive - no hardcoded time.Duration in Go.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-24 00:23:40 -08:00
Steve Yegge
bca357e4eb refactor: remove polecat state derivation from issue status (gt-gaxo.4)
ZFC cleanup: Go should be message transport, not decision-maker.

Before: loadFromBeads used switch on issue.Status to derive polecat
state (open/in_progress -> working, closed -> done).

After: Simple rule - has issue assigned = working, no issue = idle.
We do not interpret what issue.Status means; that is for Claude in
the Deacon molecule.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-24 00:21:31 -08:00
Steve Yegge
b6817899b4 refactor: ZFC cleanup - move Go heuristics to Deacon molecule (gt-gaxo)
Remove Go code that makes workflow decisions. All health checking,
staleness detection, nudging, and escalation belongs in the Deacon
molecule where Claude executes it.

Removed:
- internal/daemon/backoff.go (190 lines) - exponential backoff decisions
- internal/doctor/stale_check.go (284 lines) - staleness detection
- IsFresh/IsStale/IsVeryStale from keepalive.go
- pokeMayor, pokeWitnesses, pokeWitness from daemon.go
- Heartbeat staleness classification from pokeDeacon

Changed:
- Lifecycle parsing now uses structured body (JSON or simple text)
  instead of keyword matching on subject line
- Daemon now only ensures Deacon is running and sends simple heartbeats
- No backoff, no staleness classification, no decision-making

Total: ~800 lines removed from Go code

The Deacon molecule will handle all health checking, nudging, and
escalation. Go is now just a message router.

See gt-gaxo epic for full rationale.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-24 00:11:15 -08:00
Steve Yegge
c483602231 refactor: remove Go patrol logic from witness manager (gt-kh6q)
Patrol logic is now handled by mol-witness-patrol molecule executed by Claude.
Removed ~985 lines of Go code:
- run(), checkAndProcess(), healthCheck()
- handleStuckPolecat(), getNudgeCount(), recordNudge(), clearNudgeCount()
- processShutdownRequests(), verifyPolecatState()
- autoSpawnForReadyWork(), getActivePolecatCount(), isAlreadySpawned(), spawnPolecat()
- Plus all helper functions

Kept: NewManager(), stateFile(), loadState(), saveState(), Status(), Start(), Stop()

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 23:44:54 -08:00
Steve Yegge
2afc72dd86 refactor: remove molecule logic from witness Go code
Remove embedded molecule management from witness - this logic belongs
in molecule definitions (YAML + hooks), not Go code.

Removed:
- WitnessHandoffState, WorkerState types
- Handoff bead management (load/save/ensure)
- Patrol instance creation (ensurePatrolInstance)
- Polecat arm tracking (ensurePolecatArm, closePolecatArm)
- updateWorkerActivity function

Simplified:
- Nudge tracking now uses only SpawnedIssues (in-memory)
- run() no longer loads handoff state or creates patrol instances
- healthCheck() no longer manages tracking arms

Fixed:
- escalateToMayor: bd mail send → gt mail send
- ackMessage: bd mail ack → gt mail archive

The witness now does its core job (health checks, nudges, escalation,
cleanup) without trying to manage molecule state. Molecule tracking
should be handled by the molecule system itself via bd mol commands.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 23:02:20 -08:00
Steve Yegge
ecb1ba6fe3 bd sync: 2025-12-23 22:30:36 2025-12-23 22:42:24 -08:00
Steve Yegge
a7c843f72d feat: witness closes mol-polecat-arm when polecat cleaned up (gt-59zd.5)
Add arm closing to witness cleanup:

- Add closePolecatArm(name, reason) method that:
  - Looks up arm ID in handoff state
  - Closes the arm issue with the given reason
  - Clears arm ID from handoff state

- Call closePolecatArm() at end of cleanupPolecat()

This completes the arm lifecycle: created when polecat discovered,
closed when polecat cleaned up. The Christmas Ornament pattern now
tracks the full polecat lifecycle.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 22:32:12 -08:00
Steve Yegge
af360662d9 feat: witness bonds mol-polecat-arm for each polecat (gt-59zd.4)
Add arm bonding to witness health check:

- Add ensurePolecatArm() method that:
  - Checks if arm already exists for polecat (ArmID in WorkerState)
  - If not, calls `gt mol bond mol-polecat-arm` with template vars
  - Parses arm ID from output and stores in handoff state

- Call ensurePolecatArm() in healthCheck() for each running polecat

This creates the Christmas Ornament pattern where mol-witness-patrol
has dynamically bonded mol-polecat-arm children, one per active polecat.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 22:31:03 -08:00
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