📋 Work Assignment: Refinery patrol: Add banners and wisp-based execution

Issue: gt-qz2l
Title: Refinery patrol: Add banners and wisp-based execution
Priority: P1
Type: task

Description:
Bring Refinery patrol up to Deacon's level of sophistication:

## Current state
- mol-refinery-patrol exists (needs verification)
- Basic merge queue processing

## Needed
1. **Banners** - Print step banners like Deacon does:
   ```
   ═══════════════════════════════════════════════════════════════
     ⚗ QUEUE-CHECK
     Processing merge queue entries
   ═══════════════════════════════════════════════════════════════
   ```

2. **Wisp-based execution** - Spawn patrol as wisp, squash when complete
3. **Handoff bead attachment** - Refinery needs its own handoff bead with attached_molecule
4. **Loop-or-exit step** - Context-aware cycling like Deacon
5. **Patrol summary banner** at end of each cycle

## Reference
See Deacon patrol implementation in ~/gt/deacon/CLAUDE.md

## Workflow
1. Run `gt prime` to load polecat context
2. Work on your task, commit changes regularly
3. Run `bd close <issue-id>` when done
4. Run `bd sync` to push beads changes
5. Push code: `git push origin HEAD`
6. Run `gt done` to signal completion

## Handoff Protocol
Before signaling done, ensure:
- Git status is clean (no uncommitted changes)
- Issue is closed with `bd close`
- Beads are synced with `bd sync`
- Code is pushed to origin

The `gt done` command verifies these and signals the Witness.


Digest: mol-deacon-patrol

Patrol cycle 7: All quiet


Digest: mol-deacon-patrol

Patrol cycle 6: All agents healthy


Digest: mol-deacon-patrol

Patrol cycle 12: All healthy


Digest: mol-deacon-patrol

Patrol #22: beads/crew/emma active (1h+). All healthy.


Digest: mol-deacon-patrol

Patrol 18: all clear


Digest: mol-deacon-patrol

Patrol 16: All healthy.


Digest: mol-deacon-patrol

Patrol 64: All healthy, 3 convoys, no incidents.


📋 Work Assignment: Update templates with molecule navigation workflow

Issue: gt-lz13
Title: Update templates with molecule navigation workflow
Priority: P1
Type: task

Description:
Update all agent templates to use new molecule navigation commands.

## Commands to integrate
- bd mol current: orientation after startup/handoff (bd-sal9)
- bd close --continue: seamless step transitions (bd-ieyy)

## Templates to update

### prompts/roles/polecat.md
- Add bd mol current to 'Finding Your Work' section
- Replace manual 3-command dance with bd close --continue
- Update 'Working Through Steps' section

### prompts/roles/crew.md
- Add molecule navigation to workflow section
- Show bd mol current for session startup

### prompts/roles/refinery.md
- Update patrol step transitions to use --continue

### prompts/roles/witness.md
- Update patrol step transitions to use --continue

### prompts/roles/deacon.md
- Update patrol step transitions to use --continue

## Key message
The Propulsion Principle: close a step, immediately get handed the next.
No friction, no forgetting, no 3-command dance.

## Blocked by (Beads features)
- bd-sal9: bd mol current
- bd-ieyy: bd close --continue

## Workflow
1. Run `gt prime` to load polecat context
2. Work on your task, commit changes regularly
3. Run `bd close <issue-id>` when done
4. Run `bd sync` to push beads changes
5. Push code: `git push origin HEAD`
6. Run `gt done` to signal completion

## Handoff Protocol
Before signaling done, ensure:
- Git status is clean (no uncommitted changes)
- Issue is closed with `bd close`
- Beads are synced with `bd sync`
- Code is pushed to origin

The `gt done` command verifies these and signals the Witness.


Digest: mol-deacon-patrol

P16: clear


Digest: mol-deacon-patrol

Patrol cycle 6: All healthy.


Digest: mol-deacon-patrol

Patrol 13: Clean


Digest: mol-deacon-patrol

Patrol cycle 8 complete: all clear.


Deacon Patrol

Mayor's daemon patrol loop.

The Deacon is the Mayor's background process that runs continuously,
handling callbacks, monitoring rig health, and performing cleanup.
Each patrol cycle runs these steps in sequence, then loops or exits.

## Step: inbox-check
Handle callbacks from agents.

Check the Mayor's inbox for messages from:
- Witnesses reporting polecat status
- Refineries reporting merge results
- Polecats requesting help or escalation
- External triggers (webhooks, timers)

Process each message:
```bash
gt mail inbox
# For each message:
gt mail read <id>
# Handle based on message type
```

Callbacks may spawn new polecats, update issue state, or trigger other actions.

## Step: health-scan
Ping Witnesses and Refineries.

For each rig, verify:
- Witness is responsive
- Refinery is processing queue
- No stalled operations

```bash
gt status --health
# Check each rig
for rig in $(gt rigs); do
    gt rig status $rig
done
```

Report any issues found. Restart unresponsive components if needed.
Needs: inbox-check

## Step: plugin-run
Execute registered plugins.

Run any plugins registered with the Deacon:
- Custom health checks
- Integration hooks (Slack, GitHub, etc.)
- Metrics collection
- External system sync

Plugins are defined in the Mayor's config and run on each patrol cycle.
Skip this step if no plugins are registered.
Needs: health-scan

## Step: orphan-check
Find abandoned work.

Scan for orphaned state:
- Issues marked in_progress with no active polecat
- Polecats that stopped responding mid-work
- Merge queue entries with no polecat owner
- Wisp sessions that outlived their spawner

```bash
bd list --status=in_progress
gt polecats --all --orphan
```

For each orphan:
- Check if polecat session still exists
- If not, mark issue for reassignment or retry
- File incident beads if data loss occurred
Needs: health-scan

## Step: session-gc
Clean dead sessions.

Garbage collect terminated sessions:
- Remove stale polecat directories
- Clean up wisp session artifacts
- Prune old logs and temp files
- Archive completed molecule state

```bash
gt gc --sessions
gt gc --wisps --age=1h
```

Preserve audit trail. Only clean sessions confirmed dead.
Needs: orphan-check

## Step: context-check
Check own context limit.

The Deacon runs in a Claude session with finite context.
Check if approaching the limit:

```bash
gt context --usage
```

If context is high (>80%), prepare for handoff:
- Summarize current state
- Note any pending work
- Write handoff to molecule state

This enables the Deacon to burn and respawn cleanly.
Needs: session-gc

## Step: loop-or-exit
Burn and let daemon respawn, or exit if context high.

Decision point at end of patrol cycle:

If context is LOW:
- Sleep briefly (avoid tight loop)
- Return to inbox-check step

If context is HIGH:
- Write state to persistent storage
- Exit cleanly
- Let the daemon orchestrator respawn a fresh Deacon

The daemon ensures Deacon is always running:
```bash
# Daemon respawns on exit
gt daemon status
```

This enables infinite patrol duration via context-aware respawning.
Needs: context-check


📋 Work Assignment: Add date and priority filters to bd search

Issue: bd-au0.5
Title: Add date and priority filters to bd search
Priority: P1
Type: task

Description:
Add date and priority filters to bd search for parity with bd list.

## Current State
bd search supports: --status, --type, --assignee, --label, --limit
bd list supports: all of the above PLUS date ranges and priority filters

## Filters to Add

### Priority Filters
```bash
bd search "query" --priority 1           # Exact priority
bd search "query" --priority-min 0       # P0 and above (higher priority)
bd search "query" --priority-max 2       # P2 and below (lower priority)
```

### Date Filters
```bash
bd search "query" --created-after 2025-01-01
bd search "query" --created-before 2025-12-31
bd search "query" --updated-after 2025-01-01
bd search "query" --closed-after 2025-01-01
```

### Content Filters
```bash
bd search "query" --desc-contains "bug"
bd search "query" --notes-contains "todo"
bd search "query" --empty-description    # Issues with no description
bd search "query" --no-assignee          # Unassigned issues
bd search "query" --no-labels            # Issues without labels
```

## Files to Modify

### 1. cmd/bd/search.go
Add flag definitions in init():
```go
searchCmd.Flags().IntP("priority", "p", -1, "Filter by exact priority (0-4)")
searchCmd.Flags().Int("priority-min", -1, "Filter by minimum priority")
searchCmd.Flags().Int("priority-max", -1, "Filter by maximum priority")
searchCmd.Flags().String("created-after", "", "Filter by creation date (YYYY-MM-DD)")
searchCmd.Flags().String("created-before", "", "Filter by creation date")
searchCmd.Flags().String("updated-after", "", "Filter by update date")
searchCmd.Flags().String("updated-before", "", "Filter by update date")
searchCmd.Flags().String("closed-after", "", "Filter by close date")
searchCmd.Flags().String("closed-before", "", "Filter by close date")
searchCmd.Flags().String("desc-contains", "", "Filter by description content")
searchCmd.Flags().String("notes-contains", "", "Filter by notes content")
searchCmd.Flags().Bool("empty-description", false, "Filter issues with empty description")
searchCmd.Flags().Bool("no-assignee", false, "Filter unassigned issues")
searchCmd.Flags().Bool("no-labels", false, "Filter issues without labels")
```

### 2. internal/rpc/protocol.go
Update SearchArgs struct:
```go
type SearchArgs struct {
    Query             string
    Filter            types.IssueFilter
    // Already has most fields via IssueFilter
}
```

Note: types.IssueFilter already has these fields - just need to wire them up!

### 3. cmd/bd/search.go Run function
Parse flags and populate filter:
```go
if priority, _ := cmd.Flags().GetInt("priority"); priority >= 0 {
    filter.Priority = &priority
}
if createdAfter, _ := cmd.Flags().GetString("created-after"); createdAfter != "" {
    t, err := time.Parse("2006-01-02", createdAfter)
    if err != nil {
        FatalError("invalid date format for --created-after: %v", err)
    }
    filter.CreatedAfter = &t
}
// ... similar for other flags
```

## Implementation Steps

1. **Check types.IssueFilter** - verify all needed fields exist
2. **Add flags to search.go** init()
3. **Parse flags** in Run function
4. **Pass to SearchIssues** via filter
5. **Test all combinations**

## Testing
```bash
# Create test issues
bd create "Test P1" -p 1
bd create "Test P2" -p 2 --description "Has description"

# Test filters
bd search "" --priority 1
bd search "" --priority-min 0 --priority-max 1
bd search "" --empty-description
bd search "" --desc-contains "description"
```

## Success Criteria
- All filters work in both direct and daemon mode
- Date parsing handles YYYY-MM-DD format
- --json output includes filtered results
- Help text documents all new flags

## Workflow
1. Run `gt prime` to load polecat context
2. Work on your task, commit changes regularly
3. Run `bd close <issue-id>` when done
4. Run `bd sync` to push beads changes
5. Push code: `git push origin HEAD`
6. Run `gt done` to signal completion

## Handoff Protocol
Before signaling done, ensure:
- Git status is clean (no uncommitted changes)
- Issue is closed with `bd close`
- Beads are synced with `bd sync`
- Code is pushed to origin

The `gt done` command verifies these and signals the Witness.


Digest: mol-deacon-patrol

Patrol cycle 1: All healthy. 3 rigs running. No callbacks, no convoys completed, no orphans.


📋 Work Assignment: test pin fix 2

Issue: gt-0yn0
Title: test pin fix 2
Priority: P2
Type: task

## Workflow
1. Run `gt prime` to load polecat context
2. Work on your task, commit changes regularly
3. Run `bd close <issue-id>` when done
4. Run `bd sync` to push beads changes
5. Push code: `git push origin HEAD`
6. Run `gt done` to signal completion

## Handoff Protocol
Before signaling done, ensure:
- Git status is clean (no uncommitted changes)
- Issue is closed with `bd close`
- Beads are synced with `bd sync`
- Code is pushed to origin

The `gt done` command verifies these and signals the Witness.


Digest: mol-deacon-patrol

Patrol cycle 18: All healthy.


Digest: mol-deacon-patrol

Patrol cycle 10: Nominal


Digest: mol-deacon-patrol

Patrol 19: All healthy.


Digest: mol-deacon-patrol

Patrol cycle 18: all healthy


SPAWN: nux starting on gt-rana.2

Polecat spawn notification.

Polecat: nux
Issue: gt-rana.2
Session: gt-gastown-nux
Spawned by: mayor/

Please monitor this polecat's startup. When Claude is ready (you can see the prompt
in the tmux session), send a nudge to start working:

    tmux send-keys -t gt-gastown-nux "Check your inbox with 'gt mail inbox' and begin working." Enter

The polecat has a work assignment in its inbox.


Digest: mol-deacon-patrol

Patrol 20: routine, handoff threshold reached


Digest: mol-deacon-patrol

Patrol 11: Routine.


Digest: mol-deacon-patrol

Patrol 1: All agents healthy, no callbacks, no orphans, no pending spawns


Digest: mol-deacon-patrol

Patrol cycle 16: gastown/crew/joe started


Digest: mol-deacon-patrol

Patrol 13 complete: all healthy


Digest: mol-deacon-patrol

Patrol 47: All healthy


Digest: mol-deacon-patrol

Patrol 10: routine, no incidents


🤝 HANDOFF: Molecule lifecycle research complete, beads filed

## Session Summary

Deep research session on molecule/wisp lifecycle and "closing out" semantics.

### Key Discoveries Documented

1. **Molecules ARE epics** - The "template" label is the only structural difference for protos.
   Molecules add lifecycle semantics (pour/squash/burn/bond), not structure.

2. **Staleness redefined** - Not time-based. Stale = orphaned (no owner) + blocking other work
   (graph pressure). Created a 2x2 matrix: orphaned × blocking dimensions.

3. **Parallelism is default** - No deps = parallel. Sequential is opt-in via `depends_on`.
   No need for "parallel" labels on parent epics.

4. **progress.Completed/Total** - Computed on-demand from subgraph traversal, not stored fields.

### Beads Filed

- **bd-ujz5**: Explore wiki-style documentation (P3)
- **bd-ul59**: Update molecular chemistry docs with discoveries (P2)
- **bd-anv2**: Implement `bd mol stale` command (P2)
- **bd-6a5z**: Add stale mol check to bd doctor (P3, blocked by bd-anv2)
- **bd-o34a**: Design auto-squash behavior for wisps (P4, backlog)

### Docs Created

- `~/gt/docs/agent-feature-requests.md` - Claude Code feature requests (PostMolComplete hook)

### Decisions Made

- No timestamp tracking needed (compute completion on-demand)
- Staleness detection belongs in patrol molecules, not platform hooks
- Auto-squash is a Gas Town policy decision, not Beads primitive
- `gt handoff` should NOT block on stale mols - patrols handle cleanup

### Ready Work

Run `bd ready` - the chemistry docs update (bd-ul59) is probably the highest value next step.


🤝 HANDOFF: Code review gt-9nf fresh polecat work

## Code Review Request: gt-9nf Fresh Polecat Worktrees

Review the implementation of fresh polecat worktrees in gt spawn.

### Files Changed

1. **internal/polecat/manager.go** - Added `Recreate()` method (~60 lines)
   - Removes old worktree and branch
   - Creates fresh worktree from HEAD
   - Sets up shared beads via redirect

2. **internal/cmd/spawn.go** - Modified spawn logic (~70 lines changed)
   - Checks if polecat exists
   - If exists: safety checks then recreate
   - If not exists: create new (unchanged)

### Review Checklist

- [ ] Error handling in Recreate() - are all failure modes covered?
- [ ] Force flag behavior - does --force bypass the right checks?
- [ ] Branch deletion - is force delete safe? Could lose unpushed work?
- [ ] Worktree cleanup - does WorktreeRemove handle edge cases?
- [ ] Shared beads setup - is redirect file created correctly?
- [ ] Variable shadowing in spawn.go (polecatAddress, router defined twice)

### Test Scenarios

1. Spawn to new polecat name (should create)
2. Spawn to existing idle polecat (should recreate)
3. Spawn to polecat with uncommitted work (should error)
4. Spawn to polecat with uncommitted work + --force (should warn and proceed)
5. Spawn to working polecat (should error, cannot interrupt)

### Context

Commit: 82d718e feat(spawn): always create fresh polecat worktrees
Closed: gt-9nf, gt-tmm, gt-x7c


Digest: mol-deacon-patrol

Patrol #17: All healthy.


Digest: mol-deacon-patrol

Patrol 8: routine, all healthy


SPAWN: rictus starting on gt-3x0z.6

Polecat spawn notification.

Polecat: rictus
Issue: gt-3x0z.6
Session: gt-gastown-rictus
Spawned by: gastown/crew/max

Please monitor this polecat's startup. When Claude is ready (you can see the prompt
in the tmux session), send a nudge to start working:

    tmux send-keys -t gt-gastown-rictus "Check your inbox with 'gt mail inbox' and begin working." Enter

The polecat has a work assignment in its inbox.


Digest: mol-deacon-patrol

Patrol 15: routine, all healthy


Digest: mol-deacon-patrol

Patrol 2: All agents healthy, no incidents.


POLECAT_DONE Errata

Exit: COMPLETED
Issue: bd-qioh
MR: bd-kptp
Branch: polecat/Errata


Digest: mol-deacon-patrol

Patrol cycle 11: all quiet


Digest: mol-deacon-patrol

Patrol 12: All healthy.


Digest: mol-deacon-patrol

Patrol 6: Routine


Digest: mol-deacon-patrol

Patrol C36: All healthy


Test bd archive

Testing bd mail archive


Digest: mol-deacon-patrol

Cycle 21: No callbacks, no convoys, no gates, all agents healthy (gastown 15q, beads 8q, wyvern stopped/0q), cleaned orphan session gt-boot, no orphans, no plugins


Digest: mol-deacon-patrol

Patrol 84: All healthy. 12 polecats working. 3 convoys open. No incidents.


Digest: mol-deacon-patrol

Patrol 16: routine, all healthy


Digest: mol-deacon-patrol

Patrol 17: routine, all healthy


Digest: mol-deacon-patrol

Patrol 5: healthy


Digest: mol-deacon-patrol

Patrol cycle 3: all healthy, no callbacks, no orphans


Digest: mol-deacon-patrol

Patrol cycle 17: all healthy, fixed 1 orphan


Digest: mol-deacon-patrol

Patrol 39: All healthy


🤝 HANDOFF: Critical Review - Mail Routing & Shared Beads

## Critical Infrastructure Review Needed

The mail routing and shared beads implementation is complete but needs thorough validation before launch. This is the orchestration layer - errors here break everything.

## What Was Implemented

### 1. Mail Routing (internal/mail/router.go, mailbox.go)
- Router resolves correct beads DB based on recipient address
- Town-level (mayor/, deacon/) -> ~/gt/.beads
- Rig-level (rig/polecat) -> ~/gt/<rig>/.beads
- Sets BEADS_DIR env var for all bd commands

### 2. Shared Beads for Polecats (internal/polecat/manager.go)
- setupSharedBeads() creates .beads/redirect after worktree creation
- Redirect contains '../../.beads' pointing to rig's shared DB
- Eliminates JSONL merge conflicts between polecat clones

## Review Tasks

### Architecture Docs Overhaul
- [ ] Update docs/architecture.md with two-level beads model
- [ ] Document mail routing flow (sender -> router -> correct beads)
- [ ] Document shared beads redirect mechanism
- [ ] Update CLAUDE.md files for mayor, crew, polecats with accurate info

### Code Review
- [ ] Review router.go: detectTownRoot(), resolveBeadsDir(), isTownLevelAddress()
- [ ] Review mailbox.go: BEADS_DIR usage in all bd command calls
- [ ] Review manager.go: setupSharedBeads() error handling
- [ ] Check edge cases: What if rig .beads doesn't exist? What if redirect is invalid?

### Testing
- [ ] Test: Mayor sends to polecat (should use rig beads)
- [ ] Test: Polecat sends to mayor (should use town beads)
- [ ] Test: Polecat sends to sibling polecat (should use rig beads)
- [ ] Test: Spawn new polecat, verify redirect created
- [ ] Test: bd commands from polecat use shared rig database
- [ ] Test: Multiple polecats can read/write same issues without conflicts

### Edge Cases to Verify
- What happens if town root detection fails?
- What happens if rig beads dir doesn't exist when sending?
- What happens if redirect file is malformed?
- Do crew workers (real .beads, not redirects) still work?

## Files Changed
- gastown/crew/max/internal/mail/router.go
- gastown/crew/max/internal/mail/mailbox.go
- gastown/crew/max/internal/polecat/manager.go
(synced to polecats/nux, polecats/furiosa)

## Key Commit
gastown main: b9f93fc 'feat: implement rig/town-level mail routing and shared beads for polecats'

-- Mayor

Review complete. Found critical branch divergence - feature/rename-harness-to-hq has bd v0.32.0 migration but origin/main has multi-level routing. These need to be merged before testing. Created handoff with details and recommended action. See hq-xxx for follow-up.


Digest: mol-deacon-patrol

Patrol 14: Routine


Digest: mol-deacon-patrol

Patrol cycle 20: All healthy.


Digest: mol-deacon-patrol

Patrol 17


Digest: mol-deacon-patrol

Patrol cycle 18: clean


Digest: mol-deacon-patrol

Patrol 3: Quiet cycle.


Digest: mol-deacon-patrol

Patrol cycle 3: cleaned 1 orphan session, all agents healthy


Digest: mol-deacon-patrol

Patrol cycle 1: All healthy, no incidents


Digest: mol-deacon-patrol

Patrol cycle 18: all clear


Digest: mol-deacon-patrol

Patrol 38: All healthy


Digest: mol-deacon-patrol

Patrol cycle 31: Routine


Convoy System: Cross-Rig Work Orders

## Overview

Convoys are cross-rig work orders that track multiple issues to completion. Unlike epics
(hierarchical decomposition), convoys GROUP work for tracking purposes.

This epic lives in town beads (organization chain) and TRACKS implementation in project chains.

## Key Concepts

- **Convoy**: Cross-rig work order (hq- prefix, type=convoy)
- **War Rig**: Per-rig execution unit (discovered, not tracked)
- **Tracks**: New relation type - convoy tracks issues without blocking them
- **Town Feed**: Aggregated activity from all rigs for cross-rig visibility

## Chain Hierarchy

This epic demonstrates the two-level beads architecture:
- **Organization chain** (hq-*): This coordination epic
- **Project chains**: Implementation tasks below

## Implementation Tasks (Project Chains)

**Beads project chain (bd-*):**
- bd-3roq: Add 'tracks' relation type [P1]
- bd-hj0s: Add 'convoy' issue type with reactive completion [P1]
- bd-dx6e: bd activity --town aggregated feed [P2]

**Gastown project chain (gt-*):**
- gt-frvun: gt convoy create/status/list commands [P2]
- gt-sifj5: gt feed --follow town-level stream [P2]
- gt-wthcc: Deacon convoy patrol steps [P2]
- gt-3eqof: Overseer inbox for strategic notifications [P3]

## Dependency Chain

```
bd-3roq (tracks) ─────────────────────────────────────┐
    │                                                 │
    ▼                                                 │
bd-hj0s (convoy type) ──────────────────┬─────────────┤
                                        │             │
bd-dx6e (bd activity --town)            │             │
    │                                   │             │
    ▼                                   │             │
gt-sifj5 (gt feed)                      │             │
    │                                   │             │
    ▼                                   ▼             ▼
gt-wthcc (Deacon patrol) ◄──────────────┴─────────────┘
    │
    ▼
gt-3eqof (Overseer inbox)
```

## Design Decisions

- Convoys live in town-level beads (hq- prefix)
- Implementation lives in project chains (bd-*, gt-*)
- War Rigs are discovered at display time, not explicitly tracked
- wontfix counts toward completion
- Optional molecule orchestration via --molecule flag

## Reference

- docs/patrol-system-design.md#convoys-and-war-rigs
- docs/PRIMING.md (Chain Hierarchy section)

All 6 implementation tasks completed (tracks relation, convoy type, gt convoy commands, town feed, deacon patrol steps, overseer inbox)


Add 'tracks' relation type to beads

Add a new relation type 'tracks' for convoy → issue relationships. Unlike 'depends_on', tracks is non-blocking. Convoy tracks issues without creating a dependency.

Refiling in correct project chains (bd-* for beads schema, gt-* for gastown CLI)


Add 'convoy' issue type with reactive completion

Add convoy as a new issue type. Convoys auto-close when all tracked issues close (including wontfix). This requires watching for tracked issue closures and triggering convoy completion.


gt convoy create/status/list commands

CLI for convoy management:
- gt convoy create <name> <issues...> [--molecule <mol>] [--notify <addr>]
- gt convoy status [id]
- gt convoy list


Town feed: bd activity --town / gt feed --follow

Aggregated activity feed from all rigs. Uses routes.jsonl to discover rigs. Essential for cross-rig convoy tracking and dependency resolution.


Deacon convoy patrol steps

New Deacon patrol steps:
1. check-convoy-completion - watch for tracked issue closures
2. resolve-external-deps - propagate cross-rig closures
3. fire-notifications - notify overseer on convoy complete


Overseer inbox for strategic notifications

New address overseer/ for strategic notifications:
- Convoy completions
- Cross-rig dep resolutions
- Escalations
- Daily digests


🤝 HANDOFF: Testing handoff command

Just shipped /handoff command globally. User is about to test it on this session. Party mode activated.


🤝 HANDOFF: External deps work complete, ready for next task

## Session Summary

Completed external deps cluster:
- bd-vks2: bd dep tree now shows external deps as synthetic leaf nodes
- bd-mv6h: Added test coverage for external dep edge cases
- bd-d9mu: Closed as superseded (all child work done)

All changes committed and pushed to main (ad02b803).

## Ready Work

Run 'bd ready' - 8 issues available including:
- bd-h0we: Review SQLite indexes and scaling bottlenecks (P2)
- bd-4opy: Refactor long SQLite test files (P2)
- bd-bqcc: Consolidate maintenance commands into bd doctor --fix (P2)
- bd-kzda: Implement conditional bond type for mol bond (P3)
- bd-xsl9: Remove legacy autoflush code paths (P3)

## Notes

- Pre-existing test failure: TestDatabaseReinitialization/database_removal_scenario
  (was failing before my changes, unrelated to external deps work)
- HOP docs read at session start - good strategic context loaded

## Git State

Clean working tree, up to date with origin/main.


Digest: mol-deacon-patrol

Patrol 10: Town quiet, halfway point


Digest: mol-deacon-patrol

## Molecule Execution Summary

**Molecule**: mol-deacon-patrol
**Steps**: 9

**Completed**: 9/9

---

### Steps

1. **[closed]** Check Witness and Refinery health
   Check Witness and Refinery health for each rig.

**ZFC Principle**: You (Claude) make the judgment call about what is "stuck" or "unresponsive" - there are no hardcoded thresholds in Go. Read the sign...

2. **[closed]** Nudge newly spawned polecats
   Nudge newly spawned polecats that are ready for input.

When polecats are spawned, their Claude session takes 10-20 seconds to initialize. The spawn command returns immediately without waiting. This s...

3. **[closed]** Execute registered plugins
   Execute registered plugins.

Scan ~/gt/plugins/ for plugin directories. Each plugin has a plugin.md with YAML frontmatter defining its gate (when to run) and instructions (what to do).

See docs/deaco...

4. **[closed]** Clean dead sessions
   Clean dead sessions and orphaned state.

Run `gt doctor -v` to check for issues, then `gt doctor --fix` to clean up.

**⚠ CRITICAL: The Deacon NEVER kills crew workers or polecats!**

The orphan-...

5. **[closed]** Handle callbacks from agents
   Handle callbacks from agents.

Check the Mayor's inbox for messages from:
- Witnesses reporting polecat status
- Refineries reporting merge results
- Polecats requesting help or escalation
- External ...

6. **[closed]** Find abandoned work
   Find abandoned work.

Scan for orphaned state:
- Issues marked in_progress with no active polecat
- Polecats that stopped responding mid-work
- Merge queue entries with no polecat owner
- Wisp session...

7. **[closed]** Check own context limit
   Check own context limit.

The Deacon runs in a Claude session with finite context. Check if approaching the limit:

```bash
gt context --usage
```

If context is high (>80%), prepare for handoff:
- Su...

8. **[closed]** Evaluate pending async gates
   Evaluate pending async gates.

Gates are async coordination primitives that block until conditions are met.
The Deacon is responsible for monitoring gates and closing them when ready.

**Timer gates**...

9. **[closed]** Burn and respawn or loop
   Burn and let daemon respawn, or exit if context high.

Decision point at end of patrol cycle:

If context is LOW:
- Sleep briefly (avoid tight loop)
- Return to inbox-check step

If context is HIGH:
-...


Digest: mol-deacon-patrol

Patrol 15: quick check


Digest: mol-deacon-patrol

Patrol 19: Routine


Digest: mol-deacon-patrol

Patrol cycle 7: Routine, gastown+wyvern refineries started


Digest: mol-deacon-patrol

Patrol complete: completed prior to handoff


Digest: mol-deacon-patrol

Patrol cycle 1: All agents healthy, no callbacks, no orphans


Digest: mol-deacon-patrol

Patrol cycle 5: all 3 witnesses healthy, refineries stable (gastown 14, beads 8, wyvern 0)


Digest: mol-deacon-patrol

Cycle 20: All healthy, preparing handoff


Digest: mol-deacon-patrol

Patrol 112: All healthy.


Digest: mol-deacon-patrol

Patrol 5: Nudged warboy to handoff (7% context)


Digest: mol-deacon-patrol

Patrol 15: All clear


Digest: mol-deacon-patrol

Patrol 17: all healthy


Digest: mol-deacon-patrol

Patrol #24


Digest: mol-deacon-patrol

Patrol 7 complete: all healthy


Digest: mol-deacon-patrol

Patrol 5: Stable


Digest: mol-deacon-patrol

Patrol 8: Routine, all healthy


Digest: mol-deacon-patrol

Patrol 4: No callbacks, all healthy


Digest: mol-deacon-patrol

Patrol 1: closed 2 convoys (bd-uuo9, bd-p7i2), cleaned 2 stale locks, all agents healthy


Digest: mol-deacon-patrol

Patrol 8: routine, no incidents


Digest: mol-deacon-patrol

Patrol 40: Final cycle - all agents healthy, 3 convoys active


Digest: mol-deacon-patrol

Patrol #1: Inbox empty, all agents healthy (3 witnesses, 2 refineries, mayor), no orphans, no pending spawns, no gates


🤝 HANDOFF: Continue refactoring large files

## Current State
Completed refactoring crew.go (1184 lines → 8 focused modules). All tests pass, pushed to main.

## Next Task
Continue refactoring large files in this order:

| File | Lines |
|------|-------|
| internal/refinery/manager.go | 934 |
| internal/cmd/polecat.go | 836 |
| internal/witness/manager.go | 808 |
| internal/cmd/mail.go | 766 |

## Approach (follow the pattern from mq.go and crew.go)
1. Read the file and identify natural groupings
2. Create new files for each group (e.g., manager_queue.go, manager_merge.go)
3. Move functions to their logical homes
4. Keep main types and init in the primary file
5. Run `go build ./...` and `go test ./...` to verify
6. Commit and push to main

## Notes
- Work directly on main branch (crew worker workflow)
- Run `git pull` first to get latest
- Each file should end up under ~250 lines ideally


Digest: mol-deacon-patrol

Patrol 20: final cycle


Digest: mol-deacon-patrol

Patrol 10: Routine


Digest: mol-deacon-patrol

Patrol 16: Routine


POLECAT_STARTED rictus

Issue: gt-sd6
Session: gt-gastown-rictus


Digest: mol-deacon-patrol

Patrol 10: All systems healthy


Digest: mol-deacon-patrol

Patrol 67


Digest: mol-deacon-patrol

Patrol 3: routine, all clear


Digest: mol-deacon-patrol

Patrol cycle 19: All quiet, 3 rigs healthy


Digest: mol-deacon-patrol

Patrol cycle 21: All agents healthy, 3 convoys active (Hanoi, Boot+Polish, Messaging), nux idle 6h, no callbacks, no incidents


POLECAT_STARTED gastown/rictus


Digest: mol-deacon-patrol

Patrol 15: routine


Digest: mol-deacon-patrol

Patrol 8: all healthy


Digest: mol-deacon-patrol

Patrol 13: routine, all healthy


Deacon Patrol

Mayor's daemon patrol loop for handling callbacks, health checks, and cleanup.


Digest: mol-deacon-patrol

Patrol cycle 2: All healthy, no changes


Digest: mol-deacon-patrol

Patrol 13: quiet cycle


Digest: mol-deacon-patrol

Patrol 53: Stable


Digest: mol-deacon-patrol

Patrol 18: Routine.


Digest: mol-deacon-patrol

Patrol cycle 15: clean


Digest: mol-deacon-patrol

Patrol 30: Full health check - all agents healthy, 3 convoys active


Digest: mol-deacon-patrol

Patrol #5: All clear


Digest: mol-deacon-patrol

Patrol #9: All healthy.


Digest: mol-deacon-patrol

Patrol 52: Stable


Digest: mol-deacon-patrol

Patrol cycle 10: No messages, all agents healthy.


POLECAT_STARTED slit

Issue: gt-g2d
Session: gt-gastown-slit


Digest: mol-deacon-patrol

Patrol cycle 11: All quiet, 3 rigs healthy


🤝 HANDOFF: Code Health Review Epic (bd-tggf)

## Context
Working on Code Health Review Dec 2025: Technical Debt Cleanup epic (bd-tggf).

## Completed This Session
- **bd-4nqq**: Removed dead test code from info_test.go (2 permanently skipped tests)
- **bd-74w1**: Consolidated duplicate path-finding utilities
  - Added git.GetRepoRoot() with Windows path normalization
  - Replaced all findBeadsDir() calls with beads.FindBeadsDir()
  - Removed duplicate function definitions across 8 files

## Remaining Tasks (6)
Run `bd dep tree bd-tggf` to see current state.

Priority order suggestion:
1. **bd-9g1z** (P2) - Fix or remove TestFindJSONLPathDefault - quick win
2. **bd-dhza** (P3) - Reduce global state in main.go - medium effort
3. **bd-ork0** (P3) - Add comments to 30+ ignored errors - tedious but straightforward
4. **bd-05a8** (P2) - Split large files (doctor.go, sync.go) - significant effort
5. **bd-qioh** (P2) - Standardize error handling patterns - medium effort
6. **bd-rgyd** (P2) - Split queries.go - significant effort

## Notes
- Pre-existing flaky test: TestDatabaseReinitialization/database_removal_scenario
  (git operations failing, unrelated to our changes)
- PR #715 reviewed, requested contributor split into separate PRs
- All 38 open GitHub issues are triaged

## Commands to Resume
```bash
bd dep tree bd-tggf    # See epic status
bd show bd-9g1z        # Next suggested task
```


Digest: mol-deacon-patrol

Patrol cycle 4: routine check, all healthy


Digest: mol-deacon-patrol

Patrol 2: Routine cycle, all healthy, cleaned gt-boot orphan


Digest: mol-deacon-patrol

Patrol 10: healthy


Digest: mol-deacon-patrol

Patrol 10: All healthy.


Digest: mol-deacon-patrol

Patrol 4: town idle, all healthy


Digest: mol-deacon-patrol

Patrol 14: All healthy.


Digest: mol-deacon-patrol

Patrol 7: Quiet


Digest: mol-deacon-patrol

Patrol cycle 13: all healthy


🤝 HANDOFF: v0.34.0 release - wisp bd-25c

## Release v0.34.0 - Wisp Handoff

The release commit and tag are pushed. A wisp (bd-25c) tracks remaining steps.

### Wisp Location
```bash
bd --no-daemon --db /Users/stevey/gt/beads/mayor/rig/.beads-wisp/beads.db wisp list
```

### Completed Steps
- ✅ Kill daemons, run tests
- ✅ Update CHANGELOG.md, info.go, all version files
- ✅ Fix orphaned repo_test.go, version threshold test
- ✅ Commit release: 199def9f
- ✅ Push tag v0.34.0
- ✅ go install to ~/go/bin/bd

### Remaining Steps (in wisp)
- bd-pe3: Update Homebrew formula (run ./scripts/update-homebrew.sh 0.34.0)
- bd-eoq: Upgrade local Homebrew (brew upgrade bd)
- bd-xx8: Restart daemon (bd daemon --stop && bd daemon --start)
- bd-6wy: Upgrade beads-mcp (pip install --upgrade beads-mcp)

### When Complete
Squash the wisp to create permanent digest:
```bash
bd --no-daemon mol squash bd-25c --summary "Released v0.34.0: wisp commands, chemistry UX, cross-project deps"
```

This closes the wisp and creates a tombstone in the main .beads/ for the audit trail.


🤝 HANDOFF: Claude Settings Audit & Documentation

## Session Summary

Fixed the spawn priming race condition (gt-6957) with a comprehensive solution:

### What Was Done

1. **Created internal/claude package** with embedded settings templates:
   - settings-autonomous.json: gt prime && gt mail check --inject (SessionStart)
   - settings-interactive.json: gt prime only (SessionStart)

2. **Updated session creation** to ensure settings exist:
   - witness.go: EnsureSettingsForRole() before session
   - refinery/manager.go: EnsureSettingsForRole() before session
   - session/manager.go: EnsureSettingsForRole() for polecats

3. **Removed broken patterns**:
   - time.Sleep + SendKeys('gt prime') in witness
   - time.Sleep + NudgeSession in refinery
   - time.Sleep + Inject(issue) in polecat sessions
   - time.Sleep + NudgeSession in spawn.go

4. **Added trigger-pending-spawns to deacon patrol** (builtin molecule updated)

### Commits
- 588c0f5: Fix spawn priming race (spawn.go + builtin molecule)
- 59d6564: Add Claude settings templates for autonomous roles

### Audit Tasks for Successor

1. **Documentation audit**:
   - Does docs/architecture.md mention Claude settings?
   - Is there a best-practices doc for Gas Town setup?
   - Should we add docs/claude-configuration.md?

2. **gt doctor audit**:
   - Should gt doctor check for .claude/settings.json in worker directories?
   - Verify SessionStart hook has gt prime?
   - Check autonomous roles have mail check in SessionStart?

3. **Consistency check**:
   - Verify all polecats have updated settings (furiosa, nux, slit done)
   - Verify beads rig workers (dave, zoey) have proper settings
   - Check if any other startup code has broken timing patterns

4. **Template sync**:
   - The gastown repo's CLAUDE.md templates may reference old patterns
   - Check prompts/roles/*.md for outdated startup instructions

### Key Files
- internal/claude/settings.go - EnsureSettings function
- internal/claude/config/*.json - Embedded templates
- internal/cmd/witness.go - Updated
- internal/refinery/manager.go - Updated
- internal/session/manager.go - Updated
- internal/cmd/spawn.go - Updated earlier

### Architecture Decision
Autonomous roles (polecat, witness, refinery) need mail in SessionStart because they may be triggered externally. Interactive roles (mayor, crew) rely on UserPromptSubmit since user types first.


Digest: mol-deacon-patrol

Patrol cycle 5: all clear


Digest: mol-deacon-patrol

Patrol 22: All healthy. No incidents.


Quick Fix

Fast path for small changes.

## Step: implement
Make the fix. Keep it focused.

## Step: test
Run relevant tests. Fix any regressions.
Needs: implement

## Step: submit
Submit for merge.
Needs: test


BUG: Formula wisp create produces incomplete/broken molecule

dispatched_by: mayor

When running 'bd mol wisp create mol-deacon-patrol':
1. Only 9 of 12 steps were created
2. Dependencies referenced IDs from a previously burned wisp
3. The parent-child relationship creates circular blocking

This breaks automated patrol execution. The deacon cannot run its loop until this is fixed.

Bug no longer reproduces. Tested wisp creation twice - both created all 12 steps with correct dependencies. The issue may have been a transient state problem (cached IDs from burned wisps) that has since cleared.


Digest: mol-deacon-patrol

Patrol 20: Clean


MR Ready: gt-usy0

Merge request gt-usy0 is ready for processing.

Branch: polecat/rictus → main
Source issue: gt-3x0z.3 (gt doctor ephemeral health checks)

Please review and merge.


Digest: mol-deacon-patrol

Patrol cycle 12: all clear


Digest: mol-deacon-patrol

Patrol 108: All healthy.


Digest: mol-deacon-patrol

Patrol 7: Routine, all healthy


Digest: mol-deacon-patrol

Patrol 10: Clean


Test wisp direct

test body


📋 Work Assignment: Bug: parseLifecycleRequest always matches 'cycle' due to LIFECYCLE prefix

Issue: gt-rixa
Title: Bug: parseLifecycleRequest always matches 'cycle' due to LIFECYCLE prefix
Priority: P2
Type: bug

Description:
In lifecycle.go, parseLifecycleRequest checks strings.Contains(title, "cycle") first, but the prefix "LIFECYCLE:" contains the word "cycle". This means ALL lifecycle messages match the cycle action, making restart and shutdown unreachable. Fix: check for restart/shutdown before cycle, or use word boundaries.

## Workflow
1. Run `gt prime` to load polecat context
2. Run `bd sync --from-main` to get fresh beads
3. Work on your task, commit changes regularly
4. Run `bd close <issue-id>` when done
5. Run `bd sync` to push beads changes
6. Push code: `git push origin HEAD`
7. Run `gt done` to signal completion

## Handoff Protocol
Before signaling done, ensure:
- Git status is clean (no uncommitted changes)
- Issue is closed with `bd close`
- Beads are synced with `bd sync`
- Code is pushed to origin

The `gt done` command verifies these and signals the Witness.


Digest: mol-deacon-patrol

Patrol 6: No callbacks, all healthy


Digest: mol-deacon-patrol

Patrol C62: all healthy


Digest: mol-deacon-patrol

Patrol 17: healthy


🤝 HANDOFF: Code review needed for async gates (bd-udsi)

Time: 2025-12-23T12:08:22-08:00
Role: crew
Action: cycle

## Code Review Needed

Commit 47b86b35 adds async gates for agent coordination (bd-udsi). This is a significant feature that needs review before we consider it production-ready.

### What was implemented:
1. Gate issue type (types.TypeGate)
2. Gate-specific fields: AwaitType, AwaitID, Timeout, Waiters
3. SQLite migration 027_gate_columns
4. CLI commands: bd gate create/show/list/close/wait

### Review focus areas:
- internal/types/types.go - Gate field definitions and ComputeContentHash
- internal/storage/sqlite/migrations/027_gate_columns.go - New migration
- cmd/bd/gate.go - New CLI commands (525 lines)
- All modified storage files (queries.go, transaction.go, etc.)

### Questions to consider:
- Is the Wisp flag correct for gates? (ephemeral by default)
- Should gate commands work via daemon RPC? (currently --no-daemon required)
- Is the await spec parsing robust enough?
- Are the JSON serialization patterns correct for Duration and []string fields?

### Commands to review:
git show 47b86b35 --stat
git show 47b86b35 -- cmd/bd/gate.go

### Remaining epic tasks (in gt, not beads):
bd-is6m, bd-2l03, bd-ykqu, bd-rl5t - Deacon patrol integration


Digest: mol-deacon-patrol

Patrol 4: routine, all healthy


Digest: mol-deacon-patrol

Patrol cycle 8: all healthy


Digest: mol-deacon-patrol

Patrol 18: All healthy.


Digest: mol-deacon-patrol

Patrol 3: routine


POLECAT_DONE india

Exit: COMPLETED
Issue: bd-indn
MR: mr-1766558481-65f7b096
Branch: polecat/india


Digest: mol-deacon-patrol

Patrol #1: All agents healthy. Gastown witness/refinery pinged. 1 stale hook cleaned. 6 convoys active. No incidents.


POLECAT_STARTED gastown/slit

Issue: gt-ci84
Session: gt-gastown-slit


Digest: mol-deacon-patrol

Patrol #11: routine


Digest: mol-deacon-patrol

Patrol 3: Routine, all healthy


Digest: mol-deacon-patrol

Patrol C71: routine


Digest: mol-deacon-patrol

Patrol 3: All systems healthy


Digest: mol-deacon-patrol

Patrol cycle 4: Healthy.


Digest: mol-deacon-patrol

Patrol 12: Quiet


🤝 HANDOFF: Critical Code Review - Branch Merge Needed

## Summary

Completed critical review of mail routing and shared beads implementation per hq-7c8.

## Critical Finding: Branch Divergence

Two parallel development lines need to be merged:

**feature/rename-harness-to-hq** (current branch):
- Pinned sorting (b3ef048)
- bd v0.32.0 migration - uses bd list/create instead of bd mail (5791752)
- Lifecycle SIGUSR1 (e5c88ae)

**origin/main**:
- Multi-level mail routing - town vs rig beads (b9f93fc)
- Shared beads redirect for polecats (fc1f505)
- Still uses bd mail commands

## Key Files Reviewed

### mailbox.go
- Feature branch: Uses `bd list --type message` + BEADS_DIR env var
- Main: Uses `bd mail inbox --json` + BEADS_DIR env var
- Both approaches work; need to pick one

### router.go
- Feature branch: Simple router without town root detection
- Main: Full multi-level routing (detectTownRoot, resolveBeadsDir)
- Main's routing is more complete but uses `bd mail send`

### manager.go (shared beads)
- setupSharedBeads() at line 536 - creates .beads/redirect file
- Points polecat .beads/ to rig .beads/ via relative path
- Called during spawn (line 144), non-fatal on error
- Implementation looks correct

### types.go
- Feature branch: Has ParseLabels() method with cached values
- Main: Inlines label parsing in ToMessage()
- Feature branch approach is cleaner

## Recommended Action

1. Switch to main: `git checkout main && git pull`
2. Merge feature branch: `git merge feature/rename-harness-to-hq`
3. Resolve conflicts by keeping:
   - Main's routing code (detectTownRoot, resolveBeadsDir, multi-level routing)
   - Feature branch's bd command approach (bd list/create instead of bd mail)
   - Feature branch's ParseLabels() method
   - Both pinned sorting implementations (should be similar)
4. Update router.go to use `bd create --type message` instead of `bd mail send`
5. Test mail routing: mayor↔polecat, polecat↔polecat, crew workers

## Files to Watch
- internal/mail/mailbox.go
- internal/mail/router.go
- internal/mail/types.go
- internal/polecat/manager.go

## Context
- bd CLI v0.30.6 has both bd mail and bd list/create
- bd v0.32.0 may have changes that motivated the migration
- The routing on main is critical for multi-agent communication


Digest: mol-deacon-patrol

Patrol 28: routine, all healthy


Digest: mol-deacon-patrol

Patrol 17: Swarm active.


POLECAT_STARTED Syncer

Issue: bd-io8c
Session: gt-beads-Syncer


Digest: mol-deacon-patrol

Patrol cycle 19: all healthy


Digest: mol-deacon-patrol

Patrol 7: Routine, all healthy


Digest: mol-deacon-patrol

Cycle 5: stable


Digest: mol-deacon-patrol

Patrol 12: Town quiet


Digest: mol-deacon-patrol

## Molecule Execution Summary

**Molecule**: mol-deacon-patrol
**Steps**: 9

**Completed**: 9/9

---

### Steps

1. **[closed]** Burn and respawn or loop
   Burn and let daemon respawn, or exit if context high.

Decision point at end of patrol cycle:

If context is LOW:
- Sleep briefly (avoid tight loop)
- Return to inbox-check step

If context is HIGH:
-...

2. **[closed]** Check Witness and Refinery health
   Check Witness and Refinery health for each rig.

**ZFC Principle**: You (Claude) make the judgment call about what is "stuck" or "unresponsive" - there are no hardcoded thresholds in Go. Read the sign...

3. **[closed]** Evaluate pending async gates
   Evaluate pending async gates.

Gates are async coordination primitives that block until conditions are met.
The Deacon is responsible for monitoring gates and closing them when ready.

**Timer gates**...

4. **[closed]** Clean dead sessions
   Clean dead sessions and orphaned state.

Run `gt doctor -v` to check for issues, then `gt doctor --fix` to clean up.

**⚠ CRITICAL: The Deacon NEVER kills crew workers or polecats!**

The orphan-...

5. **[closed]** Find abandoned work
   Find abandoned work.

Scan for orphaned state:
- Issues marked in_progress with no active polecat
- Polecats that stopped responding mid-work
- Merge queue entries with no polecat owner
- Wisp session...

6. **[closed]** Nudge newly spawned polecats
   Nudge newly spawned polecats that are ready for input.

When polecats are spawned, their Claude session takes 10-20 seconds to initialize. The spawn command returns immediately without waiting. This s...

7. **[closed]** Execute registered plugins
   Execute registered plugins.

Scan ~/gt/plugins/ for plugin directories. Each plugin has a plugin.md with YAML frontmatter defining its gate (when to run) and instructions (what to do).

See docs/deaco...

8. **[closed]** Check own context limit
   Check own context limit.

The Deacon runs in a Claude session with finite context. Check if approaching the limit:

```bash
gt context --usage
```

If context is high (>80%), prepare for handoff:
- Su...

9. **[closed]** Handle callbacks from agents
   Handle callbacks from agents.

Check the Mayor's inbox for messages from:
- Witnesses reporting polecat status
- Refineries reporting merge results
- Polecats requesting help or escalation
- External ...


MR Ready: Modular (bd-u2sc.3)

Modular completed. Split cmd/bd files. Branch: polecat/Modular ready for merge.


Digest: mol-deacon-patrol

Patrol 12: all healthy


Digest: mol-deacon-patrol

Patrol 2: All healthy, no events


Digest: mol-deacon-patrol

Patrol 9: Routine, all healthy


Digest: mol-deacon-patrol

Cycle 278: All clear


Digest: mol-deacon-patrol

Patrol 20: Healthy


📋 Work Assignment: Split large cmd/bd files: doctor.go (2948 lines), sync.go (2121 lines)

Issue: bd-05a8
Title: Split large cmd/bd files: doctor.go (2948 lines), sync.go (2121 lines)
Priority: P2
Type: task

Description:
Code health review found several oversized files:

1. doctor.go - 2948 lines, 48 functions mixed together
   - Should split into doctor/checks/*.go for individual diagnostics
   - applyFixes() and previewFixes() are nearly identical

2. sync.go - 2121 lines
   - ZFC (Zero Flush Check) logic embedded inline (lines 213-247)
   - Multiple mode handlers should be extracted

3. init.go - 1732 lines
4. compact.go - 1097 lines
5. show.go - 1069 lines

Recommendation: Extract into focused sub-packages or split into logical files.

## Workflow
1. Run `gt prime` to load polecat context
2. Work on your task, commit changes regularly
3. Run `bd close <issue-id>` when done
4. Run `bd sync` to push beads changes
5. Push code: `git push origin HEAD`
6. Run `gt done` to signal completion

## Handoff Protocol
Before signaling done, ensure:
- Git status is clean (no uncommitted changes)
- Issue is closed with `bd close`
- Beads are synced with `bd sync`
- Code is pushed to origin

The `gt done` command verifies these and signals the Witness.


Digest: mol-deacon-patrol

Patrol 28: healthy


Digest: mol-deacon-patrol

Patrol cycle 13: All healthy.


Digest: mol-deacon-patrol

Patrol 19: Quiet


Digest: mol-deacon-patrol

Patrol 15: Routine, all healthy


Digest: mol-deacon-patrol

Patrol 2: All agents healthy. 2 convoys in progress. No incidents.


📋 Work Assignment: gt polecat git-state command for pre-kill verification

Issue: gt-lnji
Title: gt polecat git-state command for pre-kill verification
Priority: P1
Type: task

Description:
Add git-state subcommand to gt polecat for Witness pre-kill verification.

## Usage
```bash
gt polecat git-state <rig>/<polecat>
```

## Output
```
Git State: gastown/furiosa

  Working Tree: clean | dirty
  Uncommitted:  0 files | N files (list)
  Unpushed:     0 commits | N commits ahead
  Stashes:      0 | N stashes

  Verdict: CLEAN (safe to kill) | DIRTY (needs cleanup)
```

## JSON output (--json flag)
```json
{
  "clean": true,
  "uncommitted_files": [],
  "unpushed_commits": 0,
  "stash_count": 0
}
```

## Used by
- Witness pre-kill verification (mol-witness-patrol)
- Manual cleanup checks

## Implementation
- Check git status in polecat worktree
- Check git log origin/main..HEAD
- Check git stash list

## Workflow
1. Run `gt prime` to load polecat context
2. Work on your task, commit changes regularly
3. Run `bd close <issue-id>` when done
4. Run `bd sync` to push beads changes
5. Push code: `git push origin HEAD`
6. Run `gt done` to signal completion

## Handoff Protocol
Before signaling done, ensure:
- Git status is clean (no uncommitted changes)
- Issue is closed with `bd close`
- Beads are synced with `bd sync`
- Code is pushed to origin

The `gt done` command verifies these and signals the Witness.


Digest: mol-deacon-patrol

Patrol #18: Town idle.


Digest: mol-deacon-patrol

Patrol 1: inbox clear, all witnesses/refineries healthy, no orphans, no plugins


Digest: mol-deacon-patrol

Patrol 35: All healthy


Digest: mol-deacon-patrol

Patrol cycle 24: Routine check, all healthy.


Digest: mol-deacon-patrol

Patrol 1: inbox empty, all agents healthy, no orphans


POLECAT_STARTED slit

Issue: gt-ci84
Session: gt-gastown-slit


Digest: mol-deacon-patrol

Patrol complete: quiet cycle, all agents healthy


Digest: mol-deacon-patrol

Patrol 26: routine, all healthy


🤝 HANDOFF: gt-4u5z complete: Refinery as worktree

## Completed This Session

### gt-4u5z: Refinery as Worktree (Epic - CLOSED)
- Refinery now 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 pushed to origin after merge
- New mrqueue package for wisp MR storage
- Updated docs/merge-queue-design.md

### Also Done
- Cleaned up 5 orphaned polecat branches from origin (from before this fix)
- Started deacon for patrol

### Ready For
- Swarm work (deacon running, architecture clean)
- Check bd ready for next work


Digest: mol-deacon-patrol

Patrol 9: Healthy


Test popup

Testing new banner


Digest: mol-deacon-patrol

Patrol 4: healthy


Digest: mol-deacon-patrol

Patrol 90: All healthy. No incidents.


Digest: mol-deacon-patrol

Patrol 10: Final patrol this session, all healthy


Digest: mol-deacon-patrol

Patrol cycle 14: all healthy


Digest: mol-deacon-patrol

Patrol 27: All healthy


Digest: mol-deacon-patrol

Patrol cycle 6: clean


Digest: mol-deacon-patrol

Patrol #20: final before handoff


Session ended: gt-gastown-crew-george


🚧 BLOCKED: gt-lz13 - Missing beads features

Polecat scrotus reporting.

My assigned task gt-lz13 (Update templates with molecule navigation workflow)
is blocked. The required beads features don't exist:

- `bd mol current` - command not implemented
- `bd close --continue` - flag not implemented

The gt issues (gt-fly0, gt-qswb) were closed with "Moved to beads: bd-ieyy/bd-sal9"
but those beads issues don't exist in any beads database I can find.

Options:
1. Wait for beads features to be implemented
2. Assign me different work from bd ready list
3. Update templates to reference future commands (risky - agents will try to use them)

Awaiting instructions.


POLECAT_STARTED beads/delta

Issue: bd-m8ro
Session: gt-beads-delta


Digest: mol-deacon-patrol

Patrol #6: All healthy.


Test message for reset

This should be cleared


Digest: mol-deacon-patrol

Patrol 11: quiet cycle


deacon Handoff


Handle callbacks from agents.

Handle callbacks from agents.

Check the Mayor's inbox for messages from:
- Witnesses reporting polecat status
- Refineries reporting merge results
- Polecats requesting help or escalation
- External triggers (webhooks, timers)

Process each message:
```bash
gt mail inbox
# For each message:
gt mail read <id>
# Handle based on message type
```

Callbacks may spawn new polecats, update issue state, or trigger other actions.

instantiated_from: hq-70c
step: inbox-check


Ping Witnesses and Refineries.

Ping Witnesses and Refineries.

For each rig, verify:
- Witness is responsive
- Refinery is processing queue
- No stalled operations

```bash
gt status --health
# Check each rig
for rig in $(gt rigs); do
    gt rig status $rig
done
```

Report any issues found. Restart unresponsive components if needed.

instantiated_from: hq-70c
step: health-scan


Execute registered plugins.

Execute registered plugins.

Run any plugins registered with the Deacon:
- Custom health checks
- Integration hooks (Slack, GitHub, etc.)
- Metrics collection
- External system sync

Plugins are defined in the Mayor's config and run on each patrol cycle.
Skip this step if no plugins are registered.

instantiated_from: hq-70c
step: plugin-run


Find abandoned work.

Find abandoned work.

Scan for orphaned state:
- Issues marked in_progress with no active polecat
- Polecats that stopped responding mid-work
- Merge queue entries with no polecat owner
- Wisp sessions that outlived their spawner

```bash
bd list --status=in_progress
gt polecats --all --orphan
```

For each orphan:
- Check if polecat session still exists
- If not, mark issue for reassignment or retry
- File incident beads if data loss occurred

instantiated_from: hq-70c
step: orphan-check


Clean dead sessions.

Clean dead sessions.

Garbage collect terminated sessions:
- Remove stale polecat directories
- Clean up wisp session artifacts
- Prune old logs and temp files
- Archive completed molecule state

```bash
gt gc --sessions
gt gc --wisps --age=1h
```

Preserve audit trail. Only clean sessions confirmed dead.

instantiated_from: hq-70c
step: session-gc


Check own context limit.

Check own context limit.

The Deacon runs in a Claude session with finite context.
Check if approaching the limit:

```bash
gt context --usage
```

If context is high (>80%), prepare for handoff:
- Summarize current state
- Note any pending work
- Write handoff to molecule state

This enables the Deacon to burn and respawn cleanly.

instantiated_from: hq-70c
step: context-check


Burn and let daemon respawn, or exit if context high.

Decision point at end of patrol cycle:

If context is LOW:
- Sleep briefly (avoid tight loop)
- Return to inbox-check step

If context is HIGH:
- Write state to persistent storage
- Exit cleanly
- Let the daemon orchestrator respawn a fresh Deacon

The daemon ensures Deacon is always running:
```bash
# Daemon respawns on exit
gt daemon status
```

This enables infinite patrol duration via context-aware respawning.

instantiated_from: hq-70c
step: loop-or-exit


POLECAT_STARTED morsov

Issue: gt-4my
Session: gt-gastown-morsov


🤝 HANDOFF: Tmux status line icons

## What We Did

Added icons to tmux status bars for all Gas Town agents:

| Agent | Icon |
|-------|------|
| Mayor | 🎩 |
| Deacon | 🦉 |
| Witness | 👁 |
| Refinery | 🏭 |
| Crew | 👷 |
| Polecat | 😺 |

Icons now appear in TWO places:
1. **Left side**: Before the brackets, e.g. `👷 [gastown/max] crew`
2. **Right side**: In the dynamic status, e.g. `👷 | 16:30`

## What to Expect

User is restarting to test. They should see:
- Left side: `👷 [gastown/max] crew` (icon before brackets)
- Right side: `👷 | HH:MM` (icon with time)

If the time is split across lines (hour on one line, minutes on next), that's a ZWJ emoji bug - we fixed that by avoiding complex emojis.

## Related Beads

Created beads for future polecat mood system:
- gt-aqd8: Witness Patrol Molecule
- gt-u818: Witness Plugin System
- gt-kjnt: Polecat Mood Plugin (standard)
- gt-6y5b: Polecat mood command and status line display

## Files Changed

- internal/cmd/agents.go - AgentTypeIcons map
- internal/cmd/statusline.go - Right side status for all roles
- internal/tmux/tmux.go - Left side roleIcons map + SetStatusFormat


Digest: mol-deacon-patrol

Patrol complete: all healthy, no issues


POLECAT_DONE keeper

Exit: COMPLETED
Issue: gt-h6eq.6
MR: gt-iahc
Branch: polecat/keeper


Digest: mol-deacon-patrol

Patrol #15: routine


Digest: mol-deacon-patrol

Patrol cycle 16: All quiet, 3 rigs healthy


Digest: mol-deacon-patrol

Patrol 12: routine


Start work

Work on gt-qz2l: Refinery patrol banners and wisp-based execution. Read the issue with 'bd show gt-qz2l', implement the fix, test, commit, push, close the issue, then run 'gt done'.


Digest: mol-deacon-patrol

Patrol cycle 14: 17 running, all healthy


Digest: mol-deacon-patrol

Patrol cycle 16: all quiet


POLECAT_DONE Polish

Exit: COMPLETED
Issue: bd-4qfb
MR: bd-ibl9
Branch: polecat/Polish


POLECAT_STARTED tracer

Issue: gt-aobh
Session: gt-gastown-tracer


Digest: mol-deacon-patrol

Patrol cycle 2: All healthy, 3 polecats working, no issues


Digest: mol-deacon-patrol

Patrol 2: all clear


Digest: mol-deacon-patrol

Patrol cycle 20: all healthy, handing off


Digest: mol-deacon-patrol

Patrol 15: All healthy, no inbox


Test routing fix

This should land in town beads


Digest: mol-deacon-patrol

Cycle 265: All clear


Digest: mol-deacon-patrol

Patrol cycle 11: Routine


Digest: mol-deacon-patrol

Patrol cycle 19: All quiet


Digest: mol-deacon-patrol

Patrol cycle: all healthy, no issues


Digest: mol-deacon-patrol

Patrol cycle 10: All agents healthy, 1 orphan cleaned


Digest: mol-deacon-patrol

## Molecule Execution Summary

**Molecule**: mol-deacon-patrol
**Steps**: 9

**Completed**: 9/9

---

### Steps

1. **[closed]** Execute registered plugins
   Execute registered plugins.

Scan ~/gt/plugins/ for plugin directories. Each plugin has a plugin.md with YAML frontmatter defining its gate (when to run) and instructions (what to do).

See docs/deaco...

2. **[closed]** Check own context limit
   Check own context limit.

The Deacon runs in a Claude session with finite context. Check if approaching the limit:

```bash
gt context --usage
```

If context is high (>80%), prepare for handoff:
- Su...

3. **[closed]** Evaluate pending async gates
   Evaluate pending async gates.

Gates are async coordination primitives that block until conditions are met.
The Deacon is responsible for monitoring gates and closing them when ready.

**Timer gates**...

4. **[closed]** Handle callbacks from agents
   Handle callbacks from agents.

Check the Mayor's inbox for messages from:
- Witnesses reporting polecat status
- Refineries reporting merge results
- Polecats requesting help or escalation
- External ...

5. **[closed]** Burn and respawn or loop
   Burn and let daemon respawn, or exit if context high.

Decision point at end of patrol cycle:

If context is LOW:
- Sleep briefly (avoid tight loop)
- Return to inbox-check step

If context is HIGH:
-...

6. **[closed]** Nudge newly spawned polecats
   Nudge newly spawned polecats that are ready for input.

When polecats are spawned, their Claude session takes 10-20 seconds to initialize. The spawn command returns immediately without waiting. This s...

7. **[closed]** Clean dead sessions
   Clean dead sessions and orphaned state.

Run `gt doctor -v` to check for issues, then `gt doctor --fix` to clean up.

**⚠ CRITICAL: The Deacon NEVER kills crew workers or polecats!**

The orphan-...

8. **[closed]** Check Witness and Refinery health
   Check Witness and Refinery health for each rig.

**ZFC Principle**: You (Claude) make the judgment call about what is "stuck" or "unresponsive" - there are no hardcoded thresholds in Go. Read the sign...

9. **[closed]** Find abandoned work
   Find abandoned work.

Scan for orphaned state:
- Issues marked in_progress with no active polecat
- Polecats that stopped responding mid-work
- Merge queue entries with no polecat owner
- Wisp session...


Digest: mol-deacon-patrol

Cycle 6: Clean


Digest: mol-deacon-patrol

Patrol 12: routine, all healthy


Digest: mol-deacon-patrol

Patrol 4: Quiet


Digest: mol-deacon-patrol

Patrol 35: Full check - all agents healthy


Digest: mol-deacon-patrol

Patrol 177: All healthy


Digest: mol-deacon-patrol

Patrol 14: Routine


Digest: mol-deacon-patrol

Patrol 1 complete: inbox empty, all witnesses healthy (gastown/wyvern/beads), all refineries running, no orphans, no pending spawns, doctor run


Digest: mol-deacon-patrol

Patrol complete: Town idle, all agents healthy, 2 open convoys (PR #970, docs), no orphans or zombies


Digest: mol-deacon-patrol

Patrol 2: Routine - all healthy


Digest: mol-deacon-patrol

Patrol 9: 11 polecats working. Swarm ramping up.


Digest: mol-deacon-patrol

Patrol 5: All healthy.


Digest: mol-deacon-patrol

Patrol 9: Routine, all healthy


Digest: mol-deacon-patrol

Patrol cycle 3: Restarted 3 idle agents (gastown/witness, gastown/refinery, wyvern/refinery). No inbox messages, no orphans, 21 sessions healthy.


Digest: mol-deacon-patrol

Patrol 43: Stable


Digest: mol-deacon-patrol

Patrol 14: all healthy


Test CC

Testing CC to overseer

cc:overseer from:gastown/crew/joe thread:thread-6b87426cac87 was:message


Digest: mol-deacon-patrol

Patrol 6: Stable


🤝 HANDOFF: Chemistry Commands Implemented - Testing Needed

## Session Summary

Implemented the molecular chemistry UX commands per the mayor's request (hq-oup7).

### Committed (cadf798b)

**New Commands:**
- bd pour <proto> - Instantiate proto as persistent mol (liquid phase)
- bd wisp create <proto> - Instantiate proto as ephemeral wisp (vapor)
- bd hook [--agent] - Inspect what's on an agent's hook

**Enhanced Commands:**
- bd mol spawn --pour - New flag (--persistent deprecated with warning)
- bd mol bond --pour - Force liquid phase when attaching to wisp
- bd pin --for <agent> --start - Chemistry workflow support

### Next Steps

**Issue bd-hhv3** has detailed test scenarios.

### Key Files

- cmd/bd/pour.go (new)
- cmd/bd/hook.go (new)
- cmd/bd/wisp.go (added create subcommand)
- cmd/bd/mol_spawn.go (--pour flag)
- cmd/bd/mol_bond.go (--pour flag)
- cmd/bd/pin.go (--for, --start flags)

### Design Docs

- gastown/mayor/rig/docs/molecular-chemistry.md
- gastown/mayor/rig/docs/chemistry-design-changes.md

### Git State

Branch main pushed. All changes committed. bd sync complete.


Digest: mol-deacon-patrol

Patrol 15: Town idle, convoys unchanged


Digest: mol-deacon-patrol

Cycle 266: All clear


Digest: mol-deacon-patrol

Patrol 8 complete: inbox clear, all 3 witnesses running, beads/gastown refineries running with queued items, wyvern refinery idle, gt-boot orphan session cleaned, 1 active polecat in gastown


Digest: mol-deacon-patrol

Patrol 2: Quiet cycle, all agents healthy, no incidents


Digest: mol-deacon-patrol

Patrol cycle 2 complete: inbox empty, gates clear, all agents healthy. Patrol count now 2.


Digest: mol-deacon-patrol

Cycle 15: All healthy, 5 crew running


📋 Work Assignment: Test createTombstone and deleteIssue wrappers

Issue: bd-d28c
Title: Test createTombstone and deleteIssue wrappers
Priority: P1
Type: task

Description:
Add tests for the createTombstone and deleteIssue wrapper functions in cmd/bd/delete.go.

## Functions under test
- createTombstone (cmd/bd/delete.go:335) - Wrapper around SQLite CreateTombstone
- deleteIssue (cmd/bd/delete.go:349) - Wrapper around SQLite DeleteIssue

## Test scenarios for createTombstone
1. Successful tombstone creation
2. Tombstone with reason and actor tracking
3. Error when issue doesn't exist
4. Verify tombstone status set correctly
5. Verify audit trail recorded
6. Rollback/error handling

## Test scenarios for deleteIssue
1. Successful issue deletion
2. Error on non-existent issue
3. Verify issue removed from database
4. Error handling when storage backend doesn't support delete

## Coverage target
Current: 0%
Target: >85%

## Related
- Parent epic: bd-kyll
- Original issue: bd-7z4

## Workflow
1. Run `gt prime` to load polecat context
2. Work on your task, commit changes regularly
3. Run `bd close <issue-id>` when done
4. Run `bd sync` to push beads changes
5. Push code: `git push origin HEAD`
6. Run `gt done` to signal completion

## Handoff Protocol
Before signaling done, ensure:
- Git status is clean (no uncommitted changes)
- Issue is closed with `bd close`
- Beads are synced with `bd sync`
- Code is pushed to origin

The `gt done` command verifies these and signals the Witness.


Digest: mol-deacon-patrol

Patrol 81: All agents healthy, 3 convoys active, 1 polecat (nux) working


Digest: mol-deacon-patrol

Patrol 19: routine


Digest: mol-deacon-patrol

Patrol 9: Stable


🤝 HANDOFF: Continue ready work

let's continue working on ready open work

## Session Summary
Fixed GH#720: Parallel execution migration race condition (d677554e)

## Status
- Git: clean, pushed
- Tests: all passing
- bd sync: done

## Next
Continue with bd ready or GH issues.


Digest: mol-deacon-patrol

Patrol 4: All healthy


Digest: mol-deacon-patrol

Patrol #20: beads/crew/emma active. Handoff threshold reached.


Digest: mol-deacon-patrol

Patrol 11: Town idle


POLECAT_STARTED Doctor

Issue: bd-ykd9
Session: gt-beads-Doctor


SPAWN: rictus starting on gt-rana.1

Polecat spawn notification.

Polecat: rictus
Issue: gt-rana.1
Session: gt-gastown-rictus
Spawned by: mayor/

Please monitor this polecat's startup. When Claude is ready (you can see the prompt
in the tmux session), send a nudge to start working:

    tmux send-keys -t gt-gastown-rictus "Check your inbox with 'gt mail inbox' and begin working." Enter

The polecat has a work assignment in its inbox.


Digest: mol-deacon-patrol

Patrol cycle 4: no messages, all steps completed


Digest: mol-deacon-patrol

Patrol cycle 9: healthy


Digest: mol-deacon-patrol

Patrol 20: All healthy - handoff threshold reached


Digest: mol-deacon-patrol

Patrol 20: nominal


Digest: mol-deacon-patrol

Patrol cycle 4: All agents healthy, routine


📋 Work Assignment: 📋 Work Assignment: Code review: bd mol bond --ref and bd activity (bd-xo1o work)

Issue: hq-uwg3
Title: 📋 Work Assignment: Code review: bd mol bond --ref and bd activity (bd-xo1o work)
Priority: P1
Type: message

Description:
Issue: bd-ymqn
Title: Code review: bd mol bond --ref and bd activity (bd-xo1o work)
Priority: P1
Type: task

Description:
Review dave's recent commits for bd-xo1o (Dynamic Molecule Bonding):

## Commits to Review
- ee04b1ea: feat: add dynamic molecule bonding with --ref flag (bd-xo1o.1)
- be520d90: feat: add bd activity command for real-time state feed (bd-xo1o.3)

## Review Focus
1. Code quality and correctness
2. Error handling
3. Edge cases
4. Test coverage
5. Documentation

## Deliverables
- File beads for any issues found
- Note any concerns or suggestions
- Verify the implementation matches the bd-xo1o epic requirements

## Workflow
1. Run `gt prime` to load polecat context
2. Work on your task, commit changes regularly
3. Run `bd close <issue-id>` when done
4. Run `bd sync` to push beads changes
5. Push code: `git push origin HEAD`
6. Run `gt done` to signal completion

## Handoff Protocol
Before signaling done, ensure:
- Git status is clean (no uncommitted changes)
- Issue is closed with `bd close`
- Beads are synced with `bd sync`
- Code is pushed to origin

The `gt done` command verifies these and signals the Witness.

## Workflow
1. Run `gt prime` to load polecat context
2. Work on your task, commit changes regularly
3. Run `bd close <issue-id>` when done
4. Run `bd sync` to push beads changes
5. Push code: `git push origin HEAD`
6. Run `gt done` to signal completion

## Handoff Protocol
Before signaling done, ensure:
- Git status is clean (no uncommitted changes)
- Issue is closed with `bd close`
- Beads are synced with `bd sync`
- Code is pushed to origin

The `gt done` command verifies these and signals the Witness.


Digest: mol-deacon-patrol

Patrol cycle 7: All healthy.


Digest: mol-deacon-patrol

Patrol 10: Town idle, dog pool healthy


Digest: mol-deacon-patrol

Patrol 87: Routine


Digest: mol-deacon-patrol

Patrol cycle 13: all quiet


Digest: mol-deacon-patrol

Patrol 18: routine


POLECAT_STARTED Hooker

Issue: bd-g4b4
Session: gt-beads-Hooker


Digest: mol-deacon-patrol

Patrol 21: All healthy. 3 rigs, 6 witnesses/refineries. Beads MQ: 5, Gastown MQ: 1. No incidents.


Digest: mol-deacon-patrol

Patrol 20: HANDOFF. 20 cycles complete, swarm active, all systems healthy.


Digest: mol-deacon-patrol

Patrol complete: checked inbox (empty), nudged polecats (none pending), evaluated gates (none), health check (all witnesses/refineries running), plugins (none), abandoned work (none found), sessions (22/26 checks passed, no orphans)


Digest: mol-deacon-patrol

Patrol complete: no callbacks, all agents healthy, no orphans


Digest: mol-deacon-patrol

Patrol 4: Restarted wyvern refinery after 4 unresponsive cycles. All now healthy.


POLECAT_DONE dag

Exit: COMPLETED
Issue: bd-c7y5
MR: mr-1766562640-207bdcb0
Branch: polecat/dag


Updated merge queue

Four merge requests now ready:
- gt-c7z9: Merge gt-3x0z.1 (polecat/furiosa)
- gt-3z6x: Merge gt-rana.3 (polecat/dementus)
- gt-5gsx: Merge gt-3x0z.3 (slit)
- gt-hoyd: Merge gt-rana.1 (polecat/rictus)

Please process Wave 1 merges to main.


Digest: mol-deacon-patrol

Patrol 13: routine


SPAWN: furiosa starting on gt-a817

Polecat spawn notification.

Polecat: furiosa
Issue: gt-a817
Session: gt-gastown-furiosa
Spawned by: gastown/crew/max

Please monitor this polecat's startup. When Claude is ready (you can see the prompt
in the tmux session), send a nudge to start working:

    tmux send-keys -t gt-gastown-furiosa "Check your inbox with 'gt mail inbox' and begin working." Enter

The polecat has a work assignment in its inbox.


Digest: mol-deacon-patrol

Patrol 5: healthy


🤝 HANDOFF: Cross-Project Dependencies Designed

## Session Summary

### Accomplished
1. Reviewed and simplified spawn.go to use bd mol run (gt-47tq) - committed
2. Designed cross-project dependency system from first principles
3. Created design doc: gastown/docs/cross-project-deps.md
4. Updated molecules.md with parking section

### Key Design Decisions
- Capability-based deps: `provides:X` labels, not issue IDs
- `bd ship` command to publish capabilities (protected namespace)
- `external:project:capability` syntax in blocked_by
- "Parked" is derived state (in_progress + no assignee + blocked step)
- No Gas Town coupling in Beads - works with any orchestrator

### Issues Filed

**Beads (bd-*):**
- bd-h807: Cross-project dependency support (epic)
- bd-eijl: bd ship command
- bd-om4a: external: prefix in blocked_by
- bd-66w1: external_projects config
- bd-zmmy: bd ready resolution (depends on om4a, 66w1)

**Gas Town (gt-*):**
- gt-hbg5: Cross-project dependency workflow (epic)
- gt-zniu: gt park command
- gt-in3x: gt spawn --continue
- gt-5uf3: Patrol auto-resume (P3, future)

### Next Steps
1. Beads work (Dave): Implement bd-h807 children
2. Gas Town work: gt-zniu, gt-in3x depend on Beads features
3. Launch: Manual resume first, patrol auto-resume later

### Commands
- bd show bd-h807 - Beads epic
- bd show gt-hbg5 - Gas Town epic
- Read: gastown/docs/cross-project-deps.md


Digest: mol-deacon-patrol

Patrol cycle 12: all healthy, fixed 1 orphan


Digest: mol-deacon-patrol

Patrol cycle 3: All healthy, no messages


Digest: mol-deacon-patrol

Patrol 5: Quick cycle.


MR Ready: Errata (bd-qioh)

Errata completed. Error handling standardized. Branch: polecat/Errata ready for merge.


📌 PIN: Working on bd-ffjt mol unification

## Current Work

Unifying template.go and mol.go under bd mol (bd-ffjt)

## Plan
1. Cherry-pick mol.go from rictus branch to main
2. Standardize on internal/ui (not fatih/color)
3. Add deprecation wrappers to bd template commands
4. Consolidate duplicate functions
5. Delete molecule.go (bd-8b0x - blocked by this)

## Dependency Chain
bd-ffjt → bd-8b0x (remove molecule.go)
bd-ffjt → bd-icnf (mol run) → bd-akcq (step hooks)

## Key Files
- beads/mayor/rig/cmd/bd/template.go (main)
- beads/mayor/rig/cmd/bd/molecule.go (main - to delete)
- beads/polecats/rictus/cmd/bd/mol.go (branch - to merge)

Time: 2025-12-20T23:54:50-08:00


Digest: mol-deacon-patrol

Patrol cycle 8: all clear


📋 Work Assignment: Refactor duplicate JSONL-from-git parsing code

Issue: bd-y2v
Title: Refactor duplicate JSONL-from-git parsing code
Priority: P2
Type: task

Description:
Both readFirstIssueFromGit() in init.go and importFromGit() in autoimport.go have similar code patterns for:
1. Running git show <ref>:<path>
2. Scanning the output with bufio.Scanner
3. Parsing JSON lines

Could be refactored to share a helper like:
- readJSONLFromGit(gitRef, path string) ([]byte, error)
- Or a streaming version: streamJSONLFromGit(gitRef, path string) (io.Reader, error)

Files:
- cmd/bd/autoimport.go:225-256 (importFromGit)
- cmd/bd/init.go:1212-1243 (readFirstIssueFromGit)

Priority is low since code duplication is minimal and both functions work correctly.

## Workflow
1. Run `gt prime` to load polecat context
2. Work on your task, commit changes regularly
3. Run `bd close <issue-id>` when done
4. Run `bd sync` to push beads changes
5. Run `gt done` to signal completion (branch stays local)

## Handoff Protocol
Before signaling done, ensure:
- Git status is clean (no uncommitted changes)
- Issue is closed with `bd close`
- Beads are synced with `bd sync`

The `gt done` command verifies these and signals the Witness.


Digest: mol-deacon-patrol

Patrol 16: all healthy


Digest: mol-deacon-patrol

Patrol 4: quiet cycle


POLECAT_STARTED beads/golf

Issue: bd-de6
Session: gt-beads-golf


Digest: mol-deacon-patrol

Patrol cycle 14: all quiet


Digest: mol-deacon-patrol

Patrol 9: Nominal


📋 Work Assignment: Phase 1.1: gt rig init creates .beads-ephemeral/

Issue: gt-3x0z.1
Title: Phase 1.1: gt rig init creates .beads-ephemeral/
Priority: P1
Type: task

Description:
Add ephemeral beads repo creation to rig initialization.

## Implementation

In `gt rig init` (or equivalent setup):
1. Create `<rig>/.beads-ephemeral/` directory
2. Initialize as git repo
3. Create minimal beads config (no sync-branch needed)
4. Add to .gitignore if not already

## Config

```yaml
# .beads-ephemeral/config.yaml
ephemeral: true
# No sync-branch - ephemeral is local only
```

## Verification

```bash
gt rig init gastown
ls gastown/.beads-ephemeral/  # Should exist
```

## Workflow
1. Run `gt prime` to load polecat context
2. Run `bd sync --from-main` to get fresh beads
3. Work on your task, commit changes regularly
4. Run `bd close <issue-id>` when done
5. Run `bd sync` to push beads changes
6. Push code: `git push origin HEAD`
7. Run `gt done` to signal completion

## Handoff Protocol
Before signaling done, ensure:
- Git status is clean (no uncommitted changes)
- Issue is closed with `bd close`
- Beads are synced with `bd sync`
- Code is pushed to origin

The `gt done` command verifies these and signals the Witness.


Digest: mol-deacon-patrol

Patrol 4 complete: all healthy


POLECAT_STARTED ace

Issue: gt-tr3d
Session: gt-gastown-ace


Digest: mol-deacon-patrol

Patrol cycle 20: All healthy


POLECAT_STARTED beads/foxtrot

Issue: bd-sh4c
Session: gt-beads-foxtrot


Digest: mol-deacon-patrol

Patrol 41: All healthy, 3 convoys active, no incidents


Digest: mol-deacon-patrol

Patrol 85: quiet


SPAWN: furiosa starting on gt-rana.4

Polecat spawn notification.

Polecat: furiosa
Issue: gt-rana.4
Session: gt-gastown-furiosa
Spawned by: gastown/polecats/furiosa

Please monitor this polecat's startup. When Claude is ready (you can see the prompt
in the tmux session), send a nudge to start working:

    tmux send-keys -t gt-gastown-furiosa "Check your inbox with 'gt mail inbox' and begin working." Enter

The polecat has a work assignment in its inbox.


Digest: mol-deacon-patrol

Patrol 16: Routine


Digest: mol-deacon-patrol

Patrol 2: all clear, no incidents


Digest: mol-deacon-patrol

Patrol 3: routine, all healthy, 1 convoy pending


Digest: mol-deacon-patrol

Patrol 29: All healthy


Digest: mol-deacon-patrol

Patrol 6: All healthy, no inbox


Digest: mol-deacon-patrol

Patrol 23: routine, all healthy


Digest: mol-deacon-patrol

Patrol 7: Clean


Digest: mol-deacon-patrol

Cycle 10: healthy


Digest: mol-deacon-patrol

Patrol C40: All healthy


🤝 HANDOFF: v0.35.0 released

## Session Summary

### v0.35.0 Release Complete
- Version bumped, lint fixed, CI passed
- GitHub Release live (6 assets)
- Homebrew, npm, PyPI all updated via CI
- Local installs upgraded

### Release Tooling
- scripts/bump-version.sh: added --publish-npm, --publish-pypi, --publish-all
- bd-nqyp: mol-beads-release molecule (10 steps)

### Async Gates Epic (hq-65jk)
- Deacon-managed wisp gates for async waits
- Await types: gh:run, gh:pr, timer, human, mail
- Caller specifies timeout, multiple waiters supported

## Key Issues
- bd-nqyp: mol-beads-release (beads)
- hq-65jk: Async Gates epic (Gas Town)

## Next
- Implement async gates children
- Test mol-beads-release on next bump


Digest: mol-deacon-patrol

Patrol cycle 15: routine


Digest: mol-deacon-patrol

Patrol 17: Stable


Digest: mol-deacon-patrol

Patrol cycle 8: All healthy


Digest: mol-deacon-patrol

Patrol 30: town idle, all healthy


Digest: mol-deacon-patrol

Patrol cycle 17: all quiet


Digest: mol-deacon-patrol

Patrol 19: All healthy.


Digest: mol-deacon-patrol

Patrol 15: nominal


Digest: mol-deacon-patrol

Patrol complete: cleaned 80 stale wisps, all agents healthy (Mayor, Witness, Refinery running), 2 convoys open (PR #970, nudge docs), no inbox messages


🤝 HANDOFF: Patrol formula polish tasks

## Lower Priority Patrol Formula Issues

Filed during review of cooked patrol protos. Not blockers, but should be addressed.

### Issues to Address

| Issue | Priority | Description |
|-------|----------|-------------|
| bd-47qx | P2 | Proto ID prefix should match project prefix |
| gt-i6k1 | P2 | Clean up duplicate patrol protos (gt-qflq, gt-iep9) |
| gt-j755 | P2 | mol-polecat-arm: Add nudge_text variable definition |
| gt-x0a5 | P3 | Inconsistent variable placeholder syntax |

### Context

- Patrol formulas cooked successfully (4 protos created)
- Critical bugs filed for Dave: bd-hr39 (needs), bd-j4cr (waits_for)
- These polish tasks can wait until critical bugs fixed

### Quick Fixes

**gt-i6k1** (duplicate protos):
```bash
bd close gt-qflq --reason="Superseded by mol-witness-patrol"
# gt-iep9 already closed
```

**gt-j755** (missing variable):
Add to mol-polecat-arm.formula.yaml variables section:
```yaml
- name: nudge_text
  required: false
  default: "How's progress? Need any help?"
```

**gt-x0a5** (placeholder syntax):
Standardize on {{var}} for cook-time interpolation, <var> for human placeholders.


Digest: mol-deacon-patrol

Patrol cycle 10: routine


Digest: mol-deacon-patrol

Patrol 10: Idle


📋 Work Assignment: Zombie session detection for refinery/witness

Issue: gt-tr3d
Title: Zombie session detection for refinery/witness
Priority: P2
Type: task

Description:
A Claude session can crash or hang while still appearing as 'running' in tmux. The current IsRunning checks only verify tmux session exists, not that Claude is actually processing.

## Problem
- Refinery session might be hung (Claude crashed, infinite loop, etc.)
- tmux HasSession returns true, so auto-start doesn't trigger
- MRs pile up with no processing

## Solution Options
1. **Activity-based detection**: Check last output timestamp in tmux
2. **Heartbeat file**: Agents write timestamp to file, check staleness
3. **Prompt detection**: Look for Claude '>' prompt indicating idle/stuck

## Related
- gt-bjft (spawn auto-start) assumes IsRunning means healthy
- Witness patrol assumes running refinery is processing

## Workflow
1. Run `gt prime` to load polecat context
2. Work on your task, commit changes regularly
3. Run `bd close <issue-id>` when done
4. Run `bd sync` to push beads changes
5. Push code: `git push origin HEAD`
6. Run `gt done` to signal completion

## Handoff Protocol
Before signaling done, ensure:
- Git status is clean (no uncommitted changes)
- Issue is closed with `bd close`
- Beads are synced with `bd sync`
- Code is pushed to origin

The `gt done` command verifies these and signals the Witness.


Digest: mol-deacon-patrol

Patrol 25: All healthy


POLECAT_DONE toast

Exit: COMPLETED
Issue: bd-kzda
MR: bd-fmdy
Branch: polecat/toast


Digest: mol-deacon-patrol

Patrol #27


Digest: mol-deacon-patrol

Patrol 21: no callbacks, all agents healthy, 1 diverged clone noted (beads/crew/zoey)


POLECAT_STARTED Polish

Issue: bd-4qfb
Session: gt-beads-Polish


Digest: mol-deacon-patrol

Patrol 19: All healthy, no inbox


POLECAT_STARTED nux

Issue: gt-sye
Session: gt-gastown-nux


Digest: mol-deacon-patrol

Patrol 1: inbox empty, closed convoy hq-cv-3cahq, all agents healthy, cleaned gt-boot orphan session


Digest: mol-deacon-patrol

Patrol cycle 3: all quiet


Digest: mol-deacon-patrol

Patrol cycle 1: No inbox messages, no pending spawns, all rigs healthy (gastown witness/refinery freshly restarted), no stale polecats, no orphans


Digest: mol-deacon-patrol

Patrol 84: All healthy


Digest: mol-deacon-patrol

Patrol 3: quiet, all healthy


Digest: mol-deacon-patrol

Patrol 13: routine


Digest: mol-deacon-patrol

Patrol 5: Nominal


Digest: mol-deacon-patrol

Patrol 2: All clear, 1 orphan cleaned


POLECAT_STARTED nux

Issue: bd-l13p
Session: gt-beads-nux


Digest: mol-deacon-patrol

Patrol cycle 5: all quiet


Digest: mol-deacon-patrol

Patrol 20: routine, no incidents


Digest: mol-deacon-patrol

Cycle 9: Clean


Digest: mol-deacon-patrol

Patrol 15: all healthy, 10 sessions valid


POLECAT_DONE furiosa

Exit: COMPLETED
Issue: bd-gqxd
MR: bd-5rj1
Branch: polecat/furiosa


Digest: mol-deacon-patrol

Patrol 5: 26 sessions running, all healthy


Digest: mol-deacon-patrol

Patrol 180: Final cycle, all healthy, 4 polecats working


Digest: mol-deacon-patrol

Patrol 1: Checked inbox (1 handoff), evaluated gates (none), nudged polecats (none), checked health (all healthy), executed plugins (none), found abandoned (none), cleaned sessions (0 orphans), context low - looping


Digest: mol-deacon-patrol

Patrol 14: Healthy


Digest: mol-deacon-patrol

Patrol cycle 2: All agents healthy (3W/3R), no callbacks, no issues


Digest: mol-deacon-patrol

Patrol 2 complete: all agents healthy, no incidents


Digest: mol-deacon-patrol

Patrol 58: Stable


Digest: mol-deacon-patrol

Patrol 3: All agents healthy, no issues


Digest: mol-deacon-patrol

Patrol 2: All healthy, routine checks


Digest: mol-deacon-patrol

Patrol 22: All agents healthy, 3 convoys active, no callbacks


Digest: mol-deacon-patrol

Patrol cycle 11: 17 running, all healthy


Digest: mol-deacon-patrol

Patrol 1: All healthy - no gates, convoys, lifecycle requests. Doctor flagged false positive orphans.


Digest: mol-deacon-patrol

Cycle 19


Digest: mol-deacon-patrol

Patrol #3: All agents healthy, no pending work.


Digest: mol-deacon-patrol

Patrol 18: All healthy, no inbox


🤝 HANDOFF: gt-tca polecat auto-cleanup after MR

## Issue
gt-tca: Polecats should auto-cleanup after MR submission (P1)

## Problem
Polecats must manually run 'gt handoff --shutdown' after completing work.
This is error-prone and leaves stale polecats around.

## Blocked By
gt-9nf: gt spawn should create fresh polecat worktree, never reuse
Check if this is resolved before starting.

## Desired Flow
1. Polecat completes work
2. Polecat runs 'gt mq submit'
3. MR is added to integration queue
4. Polecat automatically cleans up

## Implementation Options
A. mq submit triggers cleanup - cleanest, single command does both
B. Refinery triggers cleanup via Witness message
C. Molecule-driven - define cleanup as final phase

## Recommendation
Option A is simplest - add cleanup to mq submit:
1. Submit MR to queue
2. Automatically run cleanup (same as gt handoff --shutdown)
3. Polecat session terminates

## Files to Look At
- internal/cmd/mq.go - mq submit command
- internal/cmd/handoff.go - handoff --shutdown logic
- internal/polecat/ - polecat cleanup logic

## Next Steps
1. Check if gt-9nf is resolved
2. Find the cleanup logic in handoff --shutdown
3. Add it to mq submit (or call handoff --shutdown internally)


Digest: mol-deacon-patrol

Patrol 6: All clear


Digest: mol-deacon-patrol

Patrol 13: Routine


SPAWN: furiosa starting on gt-7919

Polecat spawn notification.

Polecat: furiosa
Issue: gt-7919
Session: gt-gastown-furiosa
Spawned by: gastown/crew/max

The Deacon will trigger this polecat when Claude is ready (WaitForClaudeReady).
The polecat's SessionStart hook runs gt prime, and work assignment is in its inbox.
Monitor for stuck/idle state after a few minutes.


Digest: mol-deacon-patrol

Patrol cycle 12: quiet


📋 Work Assignment: Witness patrol: Add banners and wisp-based execution

Issue: gt-h1n5
Title: Witness patrol: Add banners and wisp-based execution
Priority: P1
Type: task

Description:
Bring Witness patrol up to Deacon's level of sophistication:

## Current state
- mol-witness-patrol exists (gt-qflq)
- Basic step definitions

## Needed
1. **Banners** - Print step banners like Deacon does:
   ```
   ═══════════════════════════════════════════════════════════════
     👁 POLECAT-SCAN
     Checking polecat health and nudging stale workers
   ═══════════════════════════════════════════════════════════════
   ```

2. **Wisp-based execution** - Spawn patrol as wisp, squash when complete
3. **Handoff bead attachment** - Witness needs its own handoff bead with attached_molecule
4. **Loop-or-exit step** - Context-aware cycling like Deacon
5. **Patrol summary banner** at end of each cycle

## Reference
See Deacon patrol implementation in ~/gt/deacon/CLAUDE.md

## Workflow
1. Run `gt prime` to load polecat context
2. Work on your task, commit changes regularly
3. Run `bd close <issue-id>` when done
4. Run `bd sync` to push beads changes
5. Push code: `git push origin HEAD`
6. Run `gt done` to signal completion

## Handoff Protocol
Before signaling done, ensure:
- Git status is clean (no uncommitted changes)
- Issue is closed with `bd close`
- Beads are synced with `bd sync`
- Code is pushed to origin

The `gt done` command verifies these and signals the Witness.


Digest: mol-deacon-patrol

Patrol cycle 1: inbox clear, 3 witnesses healthy, 3 refineries healthy, fixed 1 orphan session (gt-boot), no lifecycle requests, no abandoned work


Digest: mol-deacon-patrol

Patrol 14: Stable


Digest: mol-deacon-patrol

Patrol cycle 17: quiet


Digest: mol-deacon-patrol

Patrol 107: All healthy.


Digest: mol-deacon-patrol

Cycle 28: Routine, all healthy


Messaging Channels Implementation

Convoy tracking 10 issues
Notify: overseer

Replaced by hq-cv-w3nm6 (with cv- prefix)


Digest: mol-deacon-patrol

C80: Healthy.


📋 Work Assignment: Introduce slog for structured daemon logging

Issue: bd-u2sc.4
Title: Introduce slog for structured daemon logging
Priority: P3
Type: task

Description:
Introduce slog for structured daemon logging.

## Current State
Daemon uses fmt.Fprintf for logging:
```go
fmt.Fprintf(os.Stderr, "Warning: failed to detect user role: %v\n", err)
fmt.Fprintf(logFile, "[%s] %s\n", time.Now().Format(time.RFC3339), msg)
```

This produces unstructured, hard-to-parse logs.

## Target State
Use Go 1.21+ slog for structured logging:
```go
slog.Warn("failed to detect user role", "error", err)
slog.Info("sync completed", "created", 5, "updated", 3, "duration_ms", 150)
```

## Implementation

### 1. Create logger setup (internal/daemon/logger.go)

```go
package daemon

import (
    "io"
    "log/slog"
    "os"
)

// SetupLogger configures the daemon logger.
// Returns a cleanup function to close the log file.
func SetupLogger(logPath string, jsonFormat bool, level slog.Level) (func(), error) {
    var w io.Writer = os.Stderr
    var cleanup func()

    if logPath \!= "" {
        f, err := os.OpenFile(logPath, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600)
        if err \!= nil {
            return nil, err
        }
        w = io.MultiWriter(os.Stderr, f)
        cleanup = func() { f.Close() }
    }

    var handler slog.Handler
    opts := &slog.HandlerOptions{Level: level}

    if jsonFormat {
        handler = slog.NewJSONHandler(w, opts)
    } else {
        handler = slog.NewTextHandler(w, opts)
    }

    slog.SetDefault(slog.New(handler))

    return cleanup, nil
}
```

### 2. Add log level flag

In cmd/bd/daemon.go:
```go
daemonCmd.Flags().String("log-level", "info", "Log level (debug, info, warn, error)")
daemonCmd.Flags().Bool("log-json", false, "Output logs in JSON format")
```

### 3. Replace fmt.Fprintf with slog calls

**Pattern 1: Simple messages**
```go
// Before
fmt.Fprintf(os.Stderr, "Starting daemon on %s\n", socketPath)

// After
slog.Info("starting daemon", "socket", socketPath)
```

**Pattern 2: Errors**
```go
// Before
fmt.Fprintf(os.Stderr, "Error: failed to connect: %v\n", err)

// After
slog.Error("failed to connect", "error", err)
```

**Pattern 3: Debug info**
```go
// Before
if debug {
    fmt.Fprintf(os.Stderr, "Received request: %s\n", method)
}

// After
slog.Debug("received request", "method", method)
```

**Pattern 4: Structured data**
```go
// Before
fmt.Fprintf(logFile, "Import: %d created, %d updated\n", created, updated)

// After
slog.Info("import completed",
    "created", created,
    "updated", updated,
    "unchanged", unchanged,
    "duration_ms", duration.Milliseconds())
```

### 4. Files to Update

| File | Changes |
|------|---------|
| cmd/bd/daemon.go | Add log flags, call SetupLogger |
| internal/daemon/server.go | Replace fmt with slog |
| internal/daemon/rpc_handler.go | Replace fmt with slog |
| internal/daemon/sync.go | Replace fmt with slog |
| internal/daemon/autoflush.go | Replace fmt with slog |
| internal/daemon/logger.go | New file |

### 5. Log output examples

**Text format (default):**
```
time=2025-12-23T12:30:00Z level=INFO msg="daemon started" socket=/tmp/bd.sock pid=12345
time=2025-12-23T12:30:01Z level=INFO msg="import completed" created=5 updated=3 duration_ms=150
time=2025-12-23T12:30:05Z level=WARN msg="sync branch diverged" local_ahead=2 remote_ahead=1
```

**JSON format (--log-json):**
```json
{"time":"2025-12-23T12:30:00Z","level":"INFO","msg":"daemon started","socket":"/tmp/bd.sock","pid":12345}
{"time":"2025-12-23T12:30:01Z","level":"INFO","msg":"import completed","created":5,"updated":3,"duration_ms":150}
```

## Migration Strategy

1. **Add logger.go** with SetupLogger
2. **Update daemon startup** to initialize slog
3. **Convert one file at a time** (start with server.go)
4. **Test after each file**
5. **Remove old logging code** once all converted

## Testing

```bash
# Start daemon with debug logging
bd daemon start --log-level debug

# Check logs
bd daemons logs . | head -20

# Test JSON output
bd daemon start --log-json --log-level debug
bd daemons logs . | jq .
```

## Success Criteria
- All daemon logging uses slog
- --log-level controls verbosity
- --log-json produces machine-parseable output
- Log entries have consistent structure
- No fmt.Fprintf to stderr in daemon code

## Workflow
1. Run `gt prime` to load polecat context
2. Work on your task, commit changes regularly
3. Run `bd close <issue-id>` when done
4. Run `bd sync` to push beads changes
5. Push code: `git push origin HEAD`
6. Run `gt done` to signal completion

## Handoff Protocol
Before signaling done, ensure:
- Git status is clean (no uncommitted changes)
- Issue is closed with `bd close`
- Beads are synced with `bd sync`
- Code is pushed to origin

The `gt done` command verifies these and signals the Witness.


Digest: mol-deacon-patrol

Patrol 13: Interrupted by stall.


Digest: mol-deacon-patrol

Patrol 15: all healthy


Digest: mol-deacon-patrol

Patrol complete: checked inbox (empty), no pending polecats, no gates, all witnesses/refineries healthy, cleaned 2 stale locks, no abandoned work


POLECAT_DONE Syncer

Exit: COMPLETED
Issue: bd-io8c
MR: bd-bhg7
Branch: polecat/Syncer


📋 Work Assignment: Workspace doctor checks: Config, state, mail, Mayor, rigs

Issue: gt-f9x.5
Title: Workspace doctor checks: Config, state, mail, Mayor, rigs
Priority: P1
Type: task

Description:
Workspace-level doctor checks.

## Checks

### ConfigExists
- Verify config/ directory exists
- Verify config/town.json exists
- Fix: Cannot auto-fix (need gt install)

### ConfigValid
- Parse town.json
- Verify required fields (type, version, name)
- Verify type == "town"
- Fix: Cannot auto-fix

### RigsRegistryValid
- Parse config/rigs.json
- Verify each registered rig directory exists
- Warn on missing rigs
- Fix: Remove missing rigs from registry

### MayorExists
- Verify mayor/ directory exists
- Verify mayor/CLAUDE.md exists
- Fix: Create from template

### MayorMailboxExists
- Verify mayor/mail/ directory exists
- Verify mayor/mail/inbox.jsonl exists (can be empty)
- Fix: Create directory and empty file

### MayorStateValid
- Parse mayor/state.json if exists
- Verify valid JSON
- Fix: Reset to default state

## Implementation

```go
var WorkspaceChecks = []Check{
    &ConfigExistsCheck{},
    &ConfigValidCheck{},
    &RigsRegistryValidCheck{},
    &MayorExistsCheck{},
    &MayorMailboxExistsCheck{},
    &MayorStateValidCheck{},
}
```

## Workflow
1. Run `gt prime` to load polecat context
2. Work on your task, commit changes regularly
3. Run `bd close <issue-id>` when done
4. Run `bd sync` to push beads changes
5. Push code: `git push origin HEAD`
6. Run `gt done` to signal completion

## Handoff Protocol
Before signaling done, ensure:
- Git status is clean (no uncommitted changes)
- Issue is closed with `bd close`
- Beads are synced with `bd sync`
- Code is pushed to origin

The `gt done` command verifies these and signals the Witness.


🤝 HANDOFF: Molecule code review complete, tests added

## Session Summary

Completed code review of mol bond and added comprehensive test coverage.

### Changes (commits 65801782, 213a61c2)

**1. Smart --var detection for distill**
- Both spawn-style (variable=value) and substitution-style work
- Detects which side appears in text, uses that as the find value

**2. Fixed bondProtoProto label persistence bug**
- Labels field was not being persisted (stored in separate table)
- Added explicit AddLabel call after CreateIssue

**3. Comprehensive mol_test.go**
- TestParseDistillVar - 10 test cases for smart detection
- TestBondProtoProto/ProtoMol/MolMol - full bonding coverage

### Issues
- bd-f7p1: Add tests for mol spawn --attach (still open)
- bd-68bf: Code review mol bond - CLOSED (fixed bug)
- bd-iw4z: Compound visualization - DEFERRED

### Next Steps
1. bd-f7p1: Add tests for spawn --attach (P2)
2. Move to phase1-polecat-loop (gastown work)
3. Or continue molecule polish


Digest: mol-deacon-patrol

Patrol 163: All healthy, quiet


Digest: mol-deacon-patrol

Patrol 3: all agents healthy


Digest: mol-deacon-patrol

Patrol 9: All healthy


Replace WaitForClaudeReady with gt peek for steady-state agent observation

## Problem

WaitForClaudeReady uses regex to detect Claude's prompt, which is a ZFC violation.

## Architectural Fix

**Bootstrap (ZFC violation acceptable):**
During cold town startup, no AI is available. Regex to get Deacon online is acceptable.

**Steady State (proper ZFC):**
Once any agent is running, AI should observe AI:
- Deacon starting polecats → Deacon uses gt peek
- Deacon restarting → Mayor watches via gt peek
- Mayor restarting → Deacon watches via gt peek

## Implementation

1. Keep WaitForClaudeReady for daemon bootstrap only
2. Update gt deacon trigger-pending to use gt peek
3. Document bootstrap vs steady-state distinction


Digest: mol-deacon-patrol

Patrol cycle 19: routine


MR Ready: Searcher (bd-au0.5)

Searcher completed. Date/priority filters for bd search. Branch: polecat/Searcher ready for merge.


Digest: mol-deacon-patrol

Patrol 80


Digest: mol-deacon-patrol

Patrol 8: All healthy


Digest: mol-deacon-patrol

Patrol cycle 12: all quiet


Digest: mol-deacon-patrol

Patrol cycle 17: No messages, all healthy.


Digest: mol-deacon-patrol

Patrol cycle 2: cleaned 1 orphan session, all agents healthy


Digest: mol-deacon-patrol

Patrol 20: final routine cycle, all healthy, clean handoff


Digest: mol-deacon-patrol

Patrol cycle: all agents healthy, no issues, doctor 22/29 passed with 7 config warnings


Digest: mol-deacon-patrol

Patrol 23: All healthy. No incidents.


📋 Work Assignment: Phase 1.2: Configure bd for ephemeral molecule bonding

Issue: gt-3x0z.2
Title: Phase 1.2: Configure bd for ephemeral molecule bonding
Priority: P1
Type: task

Description:
Ensure bd mol bond --ephemeral works with Gas Town setup.

## Questions for Dave

1. Does bd automatically find .beads-ephemeral/ or need explicit path?
2. How does bd mol bond --ephemeral know which repo to use?
3. Is there a redirect mechanism for ephemeral like main beads?

## Integration

From polecat/crew working directory:
```bash
bd mol bond mol-polecat-work --ephemeral --assignee $(gt whoami)
```

Should create molecule in rig's .beads-ephemeral/, not main beads.

## Workflow
1. Run `gt prime` to load polecat context
2. Run `bd sync --from-main` to get fresh beads
3. Work on your task, commit changes regularly
4. Run `bd close <issue-id>` when done
5. Run `bd sync` to push beads changes
6. Push code: `git push origin HEAD`
7. Run `gt done` to signal completion

## Handoff Protocol
Before signaling done, ensure:
- Git status is clean (no uncommitted changes)
- Issue is closed with `bd close`
- Beads are synced with `bd sync`
- Code is pushed to origin

The `gt done` command verifies these and signals the Witness.