SPAWN: nux starting on gt-3x0z.2

Polecat spawn notification.

Polecat: nux
Issue: gt-3x0z.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 18: quiet


Digest: mol-deacon-patrol

Patrol #13: routine


POLECAT_STARTED furiosa

Issue: bd-au0.6
Session: gt-beads-furiosa


Digest: mol-deacon-patrol

Patrol 10 (midpoint)


Digest: mol-deacon-patrol

Patrol cycle 13: All quiet, 3 rigs healthy


Digest: mol-deacon-patrol

Patrol 12: healthy


Digest: mol-deacon-patrol

Patrol cycle 5: All quiet


POLECAT_STARTED dag

Issue: bd-dtl8
Session: gt-beads-dag


Digest: mol-deacon-patrol

Patrol cycle 5: inbox clear, all 6 agents healthy, fixed 1 orphan


Digest: mol-deacon-patrol

Quiet patrol: all stable


Digest: mol-deacon-patrol

Patrol 2: Routine, all healthy


Digest: mol-deacon-patrol

Patrol cycle 16: All healthy


Stranded convoy detection + feeding via dog dispatch

## Problem
Convoys can become **stranded** - they have ready work but no polecats working on it. Work is waiting for a ride.

## Definition: Stranded Convoy
```
convoy is open
  AND has tracked issues where:
    - status = open (not in_progress, not closed)
    - not blocked (dependencies met)
    - no assignee (or assignee session is dead)
```

If all open issues are blocked or have live polecats → convoy is fine (in-flight).
If ready issues exist with nobody working them → convoy is stranded.

## Solution: Deacon patrol + dog dispatch

**Detection (Deacon patrol step):**
Check open convoys for stranded state.

**Dispatch:**
```bash
gt sling mol-convoy-feed deacon/dogs --var convoy=<convoy-id>
```

**mol-convoy-feed formula (single pass):**
1. Load convoy, find ready issues (not blocked, no assignee)
2. Check idle polecat capacity
3. Dispatch min(ready_issues, idle_polecats)
4. Exit

Dog doesn't babysit. Just feeds and leaves. Deacon's patrol loop handles repeated checking - if still stranded next cycle, dispatches dog again.

## Benefit
Stateless, batch-oriented. Convoys become fire-and-forget.


Digest: mol-deacon-patrol

Patrol 8: Quiet


Digest: mol-deacon-patrol

Patrol cycle 1: All healthy, fixed hook attachments, no lifecycle requests


Digest: mol-deacon-patrol

Patrol cycle 3: All nominal, quick pass


📋 Work Assignment: mol-witness-patrol molecule definition

Issue: gt-83k0
Title: mol-witness-patrol molecule definition
Priority: P1
Type: task

Description:
Create mol-witness-patrol in builtin_molecules.go.

## Steps (10 total)
1. inbox-check - Process witness mail (lifecycle, help requests)
2. load-state - Read handoff bead, get nudge counts
3. survey-workers - gt polecat list, categorize by status
4. inspect-workers - tmux capture-pane for each 'working' polecat
5. decide-actions - Apply nudge matrix, queue actions
6. execute-actions - Nudge, kill, or escalate as decided
7. save-state - Update handoff bead with new states
8. generate-summary - Summarize cycle for digest
9. context-check - Check own context usage
10. burn-or-loop - Squash wisp, then loop or cycle session

## Key Behaviors
- Uses wisp storage (.beads-wisp/)
- Reads/writes witness handoff bead for state persistence
- Progressive nudging (3 levels before escalate)
- Pre-kill verification before killing polecats

## Reference
- See prompts/roles/witness.md for protocol details
- See mol-refinery-patrol for similar structure
- Parent epic: gt-aqd8

## 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 10: All healthy


Digest: mol-deacon-patrol

Patrol 19: quiet


Test: new slash format

Testing new slash-based addressing


Digest: mol-deacon-patrol

Patrol cycle 5: Routine


Safeguard town root from accidental branch switches

dispatched_by: mayor

The town root (\~/gt) should stay on the main branch (tracking origin/main for workspace state). Today we discovered the town root had been switched to temp-merge (a gastown polecat branch) which caused:

1. mayor/rigs.json to appear missing (it was on main, not temp-merge)
2. gt commands to fail with 'rig not found'
3. Confusion about what happened

Proposed safeguards:
1. Add a pre-checkout hook in town root that warns/prevents switching off main
2. gt doctor check: verify town root is on expected branch
3. gt commands that run in town root should verify branch before operating

The root cause was likely a git command or gt command running in the wrong directory.


LIFECYCLE: mayor requesting cycle

Lifecycle request from mayor.

Action: cycle
Time: 2025-12-21T01:16:25-08:00
Polecat:

Please verify state and execute lifecycle action.


Digest: mol-deacon-patrol

Patrol C44: All healthy


Process merge queue

Two merge requests ready:
- gt-c7z9: Merge gt-3x0z.1 (branch polecat/furiosa)
- gt-3z6x: Merge gt-rana.3 (branch polecat/dementus)

Please process these merges to main.


Digest: mol-deacon-patrol

Patrol 10: 13 polecats working. Swarm active.


Handoff

attached_molecule: hq-uwg3
attached_at: 2025-12-23T12:35:58Z


Digest: mol-deacon-patrol

Patrol 1: All agents healthy. Clone divergence noted (gastown/crew/jack 64 behind). No incidents.


Digest: mol-deacon-patrol

Patrol 16: routine, all healthy


Digest: mol-deacon-patrol

Patrol 2: All healthy, 12 sessions active, 2 convoys


Digest: mol-deacon-patrol

Patrol 5: All healthy, no incidents


Digest: mol-deacon-patrol

Patrol 4: Healthy


POLECAT_STARTED beads/valkyrie

Issue: bd-a15d
Session: gt-beads-valkyrie


Digest: mol-deacon-patrol

Patrol 28: town idle, all healthy


Digest: mol-deacon-patrol

Patrol 28: All healthy


Digest: mol-deacon-patrol

Patrol 91: All healthy


Digest: mol-deacon-patrol

Patrol 5: Routine.


🤝 HANDOFF: gt-975 Molecularizing polecats

## Next Task: gt-975 - Molecule execution for polecats

### Context
- Phase 1 items gt-9nf, gt-8v8: DONE
- gt-975 is the remaining Phase 1 blocker
- bd mol commands all working (bond, spawn, run, distill, catalog, show)
- Dave refactoring mol.go (bd-cnwx), then bd squash (bd-2vh3)

### gt-975 Implementation Steps
1. Polecat startup: check for assigned molecules via bd ready
2. Polecat work loop: follow molecule DAG, close steps as done
3. Witness: monitor molecule progress, detect stalls
4. Mayor: assign molecules, handle escalations

### Start Here
```
bd show gt-975
bd mol catalog  # See available molecule templates
```

### Side Quests (farmed to crew)
- gt-48bs: gt rig reset mail cleanup
- gt-qivm: auto-prime for crew at (hq-koh handoff)
- gt-tca: polecat auto-cleanup after MR (hq-amn handoff)

### Also Done This Session
- Closed gt-pc5d (stale polecat recovery - done via gt orphans)
- Added PostToolUse hook: auto-signs gt after go build in gastown
  ~/.claude/hooks/post-go-build.sh

- Mayor


Digest: mol-deacon-patrol

Patrol 5: No callbacks, all healthy


Digest: mol-deacon-patrol

Routine patrol: all checks clean


Digest: mol-deacon-patrol

Patrol cycle 5: routine, all healthy


Digest: mol-deacon-patrol

Patrol 19: all clear


POLECAT_STARTED beads/kilo

Issue: bd-dhza
Session: gt-beads-kilo


Digest: mol-deacon-patrol

Patrol 9: Routine


Digest: mol-deacon-patrol

Patrol cycle 8: healthy


🤝 HANDOFF: Patrol formulas created, awaiting bd cook

## This Session

1. Fixed 21 backwards dependencies (children depending on parent epics)
2. Filed bd-nim5: Detect/prevent child→parent dependency anti-pattern
3. Completed gt-ingm.1: Created 4 patrol formula YAML files:
   - mol-deacon-patrol.formula.yaml (8 steps)
   - mol-witness-patrol.formula.yaml (9 steps, Christmas Ornament)
   - mol-refinery-patrol.formula.yaml (10 steps)
   - mol-polecat-arm.formula.yaml (5 steps, dynamic bonding)

## Next Step

gt-ingm.2: Cook patrol formulas into proto beads
- Blocked on gt-8tmz.13 (bd cook command)
- Check if Dave finished bd cook: bd cook --help
- If available, run: bd cook .beads/formulas/*.formula.yaml
- Verify protos created: bd mol list

## Formula Location

~/gt/gastown/crew/joe/.beads/formulas/

## Context

The molecular chemistry cleanup (gt-ingm) replaces embedded Go markdown
with proper formula YAML → cook → proto pipeline.

Filed bd-weu8 and bd-wa2l for Dave. Cross-referenced in gt-8tmz.12 and gt-8tmz.13.


Digest: mol-deacon-patrol

Patrol 19: healthy


Digest: mol-deacon-patrol

Patrol complete: 0 inbox messages, all agents healthy, clone divergence noted (gastown/crew/jack 64 behind)


ZFC violation: PID-based process detection in util/process.go

util/process.go (lines 10-24) checks process existence via PID signaling:
```go
func ProcessExists(pid int) bool {
    process, err := os.FindProcess(pid)
    err = process.Signal(syscall.Signal(0))
    return err == nil
}
```

Per ZFC, Go shouldn't infer process state by checking PID existence. Agent liveness should be derived from beads state or explicit agent reporting, not PID probing.

Removed ProcessExists usage from witness/refinery managers; now use tmux session detection per ZFC


Digest: mol-deacon-patrol

Patrol 11: Town quiet


Digest: mol-deacon-patrol

Patrol 8: healthy


🤝 HANDOFF: P0 wisp spawning bug

## Context
Just implemented gt-afn0 (mail queue for patrol roles) but introduced a P0 bug:
Patrol spawning uses main DB instead of wisp storage.

## P0 Bug: gt-jsup
Patrol molecules should be wisps (ephemeral) but currently spawn into main DB.
Root cause: bd mol run can't find templates when using --db .beads-wisp/beads.db
because templates only exist in main DB.

## Fix needed
bd mol run needs cross-database support:
- Read template from main DB
- Write spawned instance to wisp DB

Check the beads repo for bd mol run implementation.

## Files to fix
- gastown: internal/cmd/sling.go lines 680, 883, 1050 (revert IsWisp: false → true)
- beads: wherever bd mol run is implemented

## What's working
- gt sling to patrol roles queues via mail (gt-afn0 ✓)
- --urgent and --replace flags work
- Just need wisp spawning fixed


🤝 HANDOFF: Batch 1 complete, notifications working

## Polecat Lifecycle Tracer Bullet - Batch 1 Complete

### This Session
- Cleaned up old Furiosa (from Dave's session)
- Spawned 2 polecats in parallel:
  - furiosa → gt-r6td (spawn notifications)
  - nux → gt-jzot (done notifications)
- Both completed and merged via Refinery
- Both polecats cleaned up manually (lifecycle gap we're fixing)

### Now Merged
- **gt spawn**: Notifies Witness + Deacon on polecat start
- **gt done**: Notifies Witness with exit outcome (COMPLETED/ESCALATED/DEFERRED)
- gt rebuilt with both features

### Next: Batch 2
The notifications are in place. Now the Witness needs to READ them:

1. **gt-83k0**: mol-witness-patrol (10-step loop with inbox-check)
2. **gt-lnji**: gt polecat git-state (pre-kill verification)

Then Batch 3 to wire it up:
- gt-lx3n: Witness startup bonds mol-witness-patrol
- gt-caih: State persistence

### Key Issues Filed
- gt-jzot: gt done notify Witness (created this session)
- gt-mmbh: Pre-existing test failures (filed by Refinery)

### Context
- Daemon PID: 25400 (running)
- Refinery/Witness sessions active
- No active polecats
- See gt-ngpz for Christmas plan


Digest: mol-deacon-patrol

Patrol 16: Quiet


Digest: mol-deacon-patrol

Patrol 5: all healthy


Digest: mol-deacon-patrol

C81: Healthy.


Digest: mol-deacon-patrol

Patrol cycle 10: all clear


🤝 HANDOFF: Document account management and walk user through it

## Context
Completed code review of account management implementation (gt-3133).

## What Was Done
- Reviewed all account management code
- Found and fixed missing `gt account status` command (commit 3ee23f5)
- All tests pass

## Remaining Tasks

### 1. Fix Doc Discrepancy
File: docs/design/account-management.md line ~106

The doc says:
  gt crew attach --account=ghosttrack max

But the actual command is:
  gt crew at --account=ghosttrack max

Update the doc to use correct command name.

### 2. Walk User Through Account Management

Give the user a walkthrough of how multi-account Claude Code works in Gas Town:

Key points to cover:
- Why: switching between personal/work accounts, quota management
- Where config lives: ~/gt/mayor/accounts.json
- Commands: gt account list/add/default/status
- How to use: --account flag on spawn/crew at, or GT_ACCOUNT env var
- Priority order: GT_ACCOUNT > --account flag > default

Demo commands to show:
  gt account list
  gt account status
  gt account status with GT_ACCOUNT=yegge
  gt spawn --account=yegge (explain, don't run)
  gt crew at --account=yegge max (explain, don't run)

The implementation is complete and working. Just needs docs fix and user education.


Digest: mol-deacon-patrol

Patrol 7: routine, all healthy


Digest: mol-deacon-patrol

Patrol 7: all clear


Digest: mol-deacon-patrol

Patrol 86: all healthy


Digest: mol-deacon-patrol

Patrol cycle 3: All quiet, 3 rigs healthy


Digest: mol-deacon-patrol

Patrol 13: all healthy


Digest: mol-deacon-patrol

Patrol 40: healthy


Digest: mol-deacon-patrol

Patrol 27: routine, all healthy


Digest: mol-deacon-patrol

Patrol cycle 3: Routine, no issues


Digest: mol-deacon-patrol

Patrol 5: All agents healthy. No incidents.


Digest: mol-deacon-patrol

Cycle 9


Digest: mol-deacon-patrol

Patrol 1: inbox empty, 3 witnesses + 3 refineries healthy, mayor attached, no orphans


Digest: mol-deacon-patrol

Patrol cycle 17: All healthy


Digest: mol-deacon-patrol

Patrol 17: All healthy, no inbox


Digest: mol-deacon-patrol

Patrol 20: healthy


Digest: mol-deacon-patrol

Patrol 8: All healthy


Digest: mol-deacon-patrol

Patrol 14


Digest: mol-deacon-patrol

Patrol 84: all agents healthy, queues processing


Digest: mol-deacon-patrol

Patrol cycle 20: all healthy - handoff threshold reached


Digest: mol-deacon-patrol

Patrol 3: Town idle, no activity


Digest: mol-deacon-patrol

Patrol cycle 12: Routine


📋 Work Assignment: Test suite hangs/never finishes

Issue: bd-9usz
Title: Test suite hangs/never finishes
Priority: P2
Type: bug

Description:
Running 'go test ./... -count=1' hangs indefinitely. The full test suite never completes, making it difficult to verify changes. Need to investigate which tests are hanging and fix or add timeouts.

## 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.


POLECAT_STARTED furiosa

Issue: bd-dxtc
Session: gt-beads-furiosa


Digest: mol-deacon-patrol

Patrol 17: nominal


Digest: mol-deacon-patrol

Patrol 5: nominal


ZFC violation: Hardcoded stuck detection thresholds in deacon/stuck.go

deacon/stuck.go (lines 14-18) has hardcoded thresholds for stuck detection:
```go
const (
    DefaultPingTimeout        = 30 * time.Second
    DefaultConsecutiveFailures = 3
    DefaultCooldown           = 5 * time.Minute
)
```

Per ZFC: Let agents decide thresholds. 'Stuck' is a judgment call, not a hardcoded timer. The line between 'agent thinking' and 'agent stuck' isn't always clear externally (ref: Murder Spree Bug cautionary tale).

Also see patrol_check.go:219-229 with hardcoded 1-hour stuck threshold, and constants.go with ClaudeStartTimeout, ShellReadyTimeout.

Fixed: thresholds now configurable via role bead


Digest: mol-deacon-patrol

Patrol 166: All healthy


📋 Work Assignment: Polecat doesn't auto-start after spawn inject - requires manual nudge

Issue: gt-iu23
Title: Polecat doesn't auto-start after spawn inject - requires manual nudge
Priority: P1
Type: bug

Description:
## Problem

After `gt spawn --issue <id> --create`, the polecat session shows Claude Code started with the injected prompt, but Claude doesn't begin processing. The prompt just sits there until manually nudged.

## Evidence

```
$ gt spawn --issue gt-rixa --rig gastown --create
...
✓ Session started. Attach with: gt session at gastown/furiosa
  Polecat nudged to start working
  Witness notified to monitor startup
```

Session shows:
```
> You have a work assignment. Run 'gt mail inbox' to see it, then start
  working on issue gt-rixa.

  ⏵⏵ bypass permissions on (shift+tab to cycle)
```

But Claude doesn't respond. Manual nudge required:
```
$ gt nudge gt-gastown-furiosa "Please start working..."
```

After nudge, polecat immediately starts working correctly.

## Hypothesis

The spawn inject happens before Claude Code is fully initialized. The text arrives in the input buffer, but Claude hasn't started listening yet. By the time Claude starts, the input has already been 'consumed' as initial prompt text but not submitted.

## Resolution Plan

This will be solved by the **polecat molecule workflow** (mol-polecat-work), which provides structured lifecycle management. The molecule approach handles startup, work, and shutdown as discrete steps with proper state tracking.

**Blocked on**: beads/crew/dave completing ephemeral molecules (bd mol bond, ephemeral beads repo).

## Workaround

For now, use `gt nudge` if a polecat doesn't start within ~30 seconds of spawn.

## 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 complete: quiet cycle, agents healthy


Digest: mol-deacon-patrol

Patrol C64: inbox empty, convoy hq-cv-w3nm6 pending (10 issues), burned 10 stale wisps, all agents healthy


Digest: mol-deacon-patrol

Patrol C52: all healthy, convoy hq-ao67r pending, no callbacks


Digest: mol-deacon-patrol

Patrol 9: Stable


POLECAT_STARTED cheedo

Issue: gt-f9x.5
Session: gt-gastown-cheedo


POLECAT_STARTED beads/dag

Issue: bd-c7y5
Session: gt-beads-dag


Digest: mol-deacon-patrol

Patrol 7: all healthy


Digest: mol-deacon-patrol

Patrol cycle 16: quiet


POLECAT_DONE nux

Exit: COMPLETED
Issue: bd-dtl8
MR: mr-1766562684-7921c41f
Branch: polecat/nux


POLECAT_STARTED max

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


Digest: mol-deacon-patrol

Patrol 2: All healthy, no issues


POLECAT_STARTED slit

Issue: bd-9usz
Session: gt-beads-slit


Digest: mol-deacon-patrol

Patrol cycle 7: Routine


SPAWN: rictus starting on gt-3x0z.3

Polecat spawn notification.

Polecat: rictus
Issue: gt-3x0z.3
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.


📋 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. 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 8: Healthy


Digest: mol-deacon-patrol

Patrol 4


Digest: mol-deacon-patrol

Patrol 5: all clear


Digest: mol-deacon-patrol

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


Digest: mol-deacon-patrol

Patrol cycle 17: all clear


POLECAT_STARTED beads/ace

Issue: bd-ymqn
Session: gt-beads-ace


Digest: mol-deacon-patrol

Cycle 69: All healthy


📌 HANDOFF: Christmas Launch Progress

## Completed This Session

### Molecule Unification (bd-ffjt, bd-8b0x, bd-icnf) ✅
- Added bd mol catalog/show/bond/run commands
- Deprecated bd template commands
- Removed molecule.go (simple instantiation)
- bd mol run = bond + assign + pin (durable execution)

### Documentation Cleanup ✅
- Fixed all bd mail → gt mail references in CLAUDE.md files
- Pushed to both beads and gt repos

### Filed
- hq-s5l: Session-close molecule (P3, needs bead squash)

## Next: Christmas Launch

Check bd-p5za (mol-christmas-launch) for the 3-day execution plan.

Key areas:
1. Gas Town stability (witness, refinery, spawn)
2. Beads polish (molecules, pinning, mail)
3. Documentation for launch
4. Demo/video preparation

Run: bd show bd-p5za

Time: 2025-12-21T00:25:01-08:00


Digest: mol-deacon-patrol

Patrol 10: routine


Digest: mol-deacon-patrol

Patrol 17: Quiet


Digest: mol-deacon-patrol

Patrol 2: routine check, all clear


Digest: mol-deacon-patrol

Patrol 11: Routine


Digest: mol-deacon-patrol

Patrol 49: All healthy


POLECAT_STARTED beads/Beader

Issue: bd-tvu3
Session: gt-beads-Beader


POLECAT_STARTED gastown/slit

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


Digest: mol-deacon-patrol

Patrol 6: routine, no incidents


Digest: mol-deacon-patrol

Patrol 9: Quick cycle.


POLECAT_DONE dag

Exit: COMPLETED
Issue: gt-h6eq.3
MR: gt-23ic
Branch: polecat/dag


bd repair: Fix orphaned deps/labels when database won't open

## Problem

When the database has orphaned foreign key references, the migration invariant check fails, preventing the database from opening. This creates a chicken-and-egg problem where `bd doctor --fix` can't run because it can't open the database.

## Solution

Add `bd repair` command (or `bd doctor --force-repair`) that:
1. Opens SQLite directly, bypassing the normal open path with invariant checks
2. Deletes orphaned dependencies (issue_id or depends_on_id not in issues)
3. Deletes orphaned labels (issue_id not in issues)
4. Runs WAL checkpoint to persist changes
5. Then allows normal bd commands to work

## Implementation

```go
// In cmd/repair.go or extend doctor.go
func repairDatabase(dbPath string) error {
    db, err := sql.Open("sqlite3", dbPath)
    // No migrations, no invariant checks

    // Delete orphans
    db.Exec("DELETE FROM dependencies WHERE NOT EXISTS (SELECT 1 FROM issues WHERE id = issue_id)")
    db.Exec("DELETE FROM dependencies WHERE NOT EXISTS (SELECT 1 FROM issues WHERE id = depends_on_id) AND depends_on_id NOT LIKE 'external:%'")
    db.Exec("DELETE FROM labels WHERE NOT EXISTS (SELECT 1 FROM issues WHERE id = issue_id)")

    db.Exec("PRAGMA wal_checkpoint(TRUNCATE)")
    return nil
}
```

This is the emergency escape hatch when things go wrong.


Digest: mol-deacon-patrol

Patrol cycle 5: All healthy, 5 crew running


Digest: mol-deacon-patrol

Patrol cycle 13: read mayor addendum, all healthy


Digest: mol-deacon-patrol

Patrol 20: routine, all healthy - handoff threshold reached


POLECAT_STARTED beads/slit

Issue: bd-9usz
Session: gt-beads-slit


Digest: mol-deacon-patrol

Patrol cycle 10: All healthy


Digest: mol-deacon-patrol

Patrol 4: Nominal


Session ended: gt-deacon


Digest: mol-deacon-patrol

Patrol 70


Digest: mol-deacon-patrol

Patrol 2: quiet cycle, all agents healthy


Digest: mol-deacon-patrol

Patrol 17: All healthy


SPAWN: dementus starting on gt-ay1r

Polecat spawn notification.

Polecat: dementus
Issue: gt-ay1r
Session: gt-gastown-dementus
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 18: healthy


Digest: mol-deacon-patrol

Cycle 17: Clean


Digest: mol-deacon-patrol

## Molecule Execution Summary

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

**Completed**: 9/9

---

### Steps

1. **[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...

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]** 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-...

4. **[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...

5. **[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**...

6. **[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:
-...

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]** 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 ...

9. **[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...


POLECAT_STARTED beads/dag

Issue: bd-dtl8
Session: gt-beads-dag


SPAWN: nux starting on gt-jzot

Polecat spawn notification.

Polecat: nux
Issue: gt-jzot
Session: gt-gastown-nux
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.


🤝 HANDOFF: Shared Beads + Mail Fixes

## Session Summary

Fixed gt mail system to work with bd v0.32.0 (mail removed from beads).
Investigated shared beads architecture for eliminating git sync overhead.

## Completed

### gt mail migration (DONE)
- mailbox.go: listBeads() uses bd list --type message
- mailbox.go: getBeads() uses bd show
- mailbox.go: markReadBeads() uses bd close
- mailbox.go: listByThreadBeads() uses bd list --label thread:<id>
- router.go: Send() uses bd create --type message with labels
- types.go: Extract from/thread/reply-to from labels
- Added --pinned flag to gt mail send (blocked by bd bug)

Binary installed at ~/gt/gt

### Beads cleanup (DONE)
- Migrated 63 orphan issues from rig-level to clone beads
- Cleaned gm-* prefix mismatch from town beads (now hq-* only)
- Deleted old handoffs, synced

### Investigation: One Beads Per Rig (READY TO IMPLEMENT)
Architecture validated - will eliminate git sync token burn.

Key findings:
- bd already has redirect support (.beads/redirect file)
- Daemon discovery follows redirects (uses resolved dbPath)
- All agents would connect to same daemon socket
- SQLite WAL + daemon serialization handles concurrency
- No race conditions expected

## Blocking Issues

### gt-zr0a [P1]: bd pin command broken
bd pin <id> fails: invalid field for update: pinned
Nudged dave at gt-beads-crew-dave. Blocks --pinned flag.

## Next Steps: Shared Beads Implementation

1. Create shared .beads/ at rig root (e.g., ~/gt/gastown/.beads/)
2. Update gt spawn to create redirect files:
   mkdir -p polecats/nux/.beads
   echo ../../.beads > polecats/nux/.beads/redirect
3. Test that all polecats connect to same daemon
4. Remove git sync from intra-rig workflow
5. Keep JSONL export for backup/cross-rig only

## Key Files Changed This Session
- gastown/mayor/rig/internal/mail/mailbox.go
- gastown/mayor/rig/internal/mail/router.go
- gastown/mayor/rig/internal/mail/types.go
- gastown/mayor/rig/internal/cmd/mail.go

## Redirect Implementation Reference
~/gt/beads/polecats/rictus/internal/beads/beads.go:45 - followRedirect()

-- Mayor


Session ended: hq-mayor


📋 Work Assignment: Phase 2.1: gt spawn --molecule bonds in ephemeral

Issue: gt-3x0z.4
Title: Phase 2.1: gt spawn --molecule bonds in ephemeral
Priority: P1
Type: task

Description:
Make gt spawn molecule-aware with ephemeral bonding.

## New Flag

```bash
gt spawn --issue gt-xxx --molecule mol-polecat-work
```

## Behavior

1. Create polecat with fresh worktree (existing)
2. Bond molecule in ephemeral: `bd mol bond mol-polecat-work --ephemeral`
3. Link molecule root to source issue
4. Include molecule context in work assignment mail
5. Start session

## Work Assignment Mail

```
Subject: Work Assignment: Fix lifecycle bug [MOLECULE]

You are working on gt-rixa as part of molecule mol-polecat-work.

Molecule instance: eph-abc123
Current step: read-assignment (1/8)

Follow the molecule workflow. When complete, generate summary and squash.
```

## 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 19: routine, no incidents


Digest: mol-deacon-patrol

Patrol 20: healthy, all 6 agents running, 4 polecats active


Digest: mol-deacon-patrol

Patrol cycle 4: All healthy.


Digest: mol-deacon-patrol

Patrol 14 complete: all healthy


Digest: mol-deacon-patrol

Patrol 14: routine, all healthy


Digest: mol-deacon-patrol

Patrol 8: all clear


Digest: mol-deacon-patrol

Cycle 80: All healthy, handoff


Digest: mol-deacon-patrol

Patrol C33: All healthy


POLECAT_STARTED rictus

Issue: gt-h1n5
Session: gt-gastown-rictus


Digest: mol-deacon-patrol

Patrol cycle 17: All healthy.


Digest: mol-deacon-patrol

Cycle 12: stable


Digest: mol-deacon-patrol

Patrol 56: All healthy


Digest: mol-deacon-patrol

Patrol 5: routine


Digest: mol-deacon-patrol

Patrol 99: all healthy


Digest: mol-deacon-patrol

Patrol cycle 19: All healthy


Digest: mol-deacon-patrol

Patrol 17: quiet


Digest: mol-deacon-patrol

Patrol cycle 14: Routine


Digest: mol-deacon-patrol

Patrol cycle 18: routine


Digest: mol-deacon-patrol

Patrol cycle 19: all clear


Digest: mol-deacon-patrol

Patrol 1: Inbox 0, Mayor 4 msgs (stale polecat reports from witness), all agents healthy (~50min), no orphans


📋 Work Assignment: Update docs with molecule navigation workflow

Issue: gt-um6q
Title: Update docs with molecule navigation workflow
Priority: P1
Type: task

Description:
Update architecture and workflow docs with new molecule navigation.

## Docs to update

### docs/molecules.md
- Add 'Navigating Molecules' section
- Document bd mol current usage
- Document bd close --continue workflow
- Show the propulsion pattern

### docs/propulsion-principle.md
- Add molecule navigation as key enabler
- Show before/after workflow comparison

### docs/polecat-wisp-architecture.md
- Update step execution section
- Show bd close --continue in examples

## New section content

### Molecule Navigation

Finding your place:
  bd mol current              # Where am I?
  bd mol current gt-abc       # Status of specific molecule

Seamless transitions:
  bd close gt-abc.3 --continue   # Close and advance
  bd close gt-abc.3 --no-auto    # Close but don't auto-claim next

The old way (3 commands):
  bd close gt-abc.3
  bd ready --parent=gt-abc
  bd update gt-abc.4 --status=in_progress

The new way (1 command):
  bd close gt-abc.3 --continue

## 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

Patrol 68


Digest: mol-deacon-patrol

Patrol 17: healthy


Digest: mol-deacon-patrol

Patrol 21: No callbacks, no gates, no pending spawns, all witnesses/refineries healthy, no in_progress issues, clone divergence noted (zoey/jack stopped), context threshold reached


Digest: mol-deacon-patrol

P18: clear


Digest: mol-deacon-patrol

Patrol 5: All clear


Digest: mol-deacon-patrol

Patrol 70: All healthy. No incidents.


Digest: mol-deacon-patrol

Patrol 2 complete: all healthy, no orphans


Digest: mol-deacon-patrol

Patrol cycle 10: all quiet


Digest: mol-deacon-patrol

Patrol 11: All systems healthy


Digest: mol-deacon-patrol

Patrol cycle 14: all healthy, fixed 1 orphan


Digest: mol-deacon-patrol

Patrol cycle 10: closed 3 convoys, health ok, cleaned 13 locks


Digest: mol-deacon-patrol

Patrol 33: routine, all healthy


Digest: mol-deacon-patrol

Patrol 6: All healthy, cleaned 1 orphan session


Missing failsafe: No circuit breaker for stuck agents

When an agent (Deacon, Witness, Refinery) gets stuck, there's no automatic recovery:

1. No timeout on individual steps - an agent can spin forever
2. No watchdog process checking agent health externally
3. No heartbeat/liveness check that triggers restart

Proposed solution:
- Add a watchdog that checks agent last_activity timestamps
- If no activity for >5 minutes, force cycle the agent
- This could be a simple cron job or daemon feature

This is defense-in-depth for the 'who watches the watchers' problem.


Digest: mol-deacon-patrol

Patrol cycle 3: routine, all healthy, gastown refinery queue 3


Digest: mol-deacon-patrol

Patrol cycle 17: clean


Digest: mol-deacon-patrol

Patrol C66: routine, all healthy


POLECAT_STARTED capable

Issue: bd-t4u1
Session: gt-beads-capable


Digest: mol-deacon-patrol

Patrol cycle 2: All 3 rigs healthy, gastown refinery +1 pending


Digest: mol-deacon-patrol

Patrol #4: 3 polecats active. All healthy.


Digest: mol-deacon-patrol

Patrol 18: Clean


Digest: mol-deacon-patrol

Patrol 13: All healthy.


Digest: mol-deacon-patrol

Patrol 8


Digest: mol-deacon-patrol

Cycle 77: All healthy


Digest: mol-deacon-patrol

Patrol 3: Routine check, 2 convoys in progress, all agents healthy


Digest: mol-deacon-patrol

Patrol cycle 6: all clear, health ok


🤝 HANDOFF: Tech Debt Epic gt-5n2f (4 done, 7 remaining)

## Current State
Completed 4 issues from tech debt epic gt-5n2f. All changes pushed to main.

## Completed This Session
1. **gt-7sqi** (P2): Extracted getRig() helper in internal/cmd/rig_helpers.go
   - Eliminated duplication across 5 get*Manager functions

2. **gt-ai1z** (P2): Implemented cycle detection in molecule dependencies
   - DFS-based algorithm in internal/beads/molecule.go
   - Added 4 tests for various cycle scenarios

3. **gt-nz6t** (P4): Removed unused style helpers
   - Deleted RenderSuccess/Warning/Error/Info functions

4. **gt-zhm5** (P3): Implemented epic child filtering in witness
   - Added isChildOfEpic() in internal/witness/manager.go
   - Checks if issue blocks configured epic

## Remaining Issues (by priority)

### P2
- **gt-480b**: Improve test coverage (cmd 6.8%, mail 3.6%, daemon 12.1%)
  - Larger task, may want to break into smaller chunks

### P3 - Good next candidates
- **gt-xnql**: Define constants for magic strings ("mayor", "main", "beads-sync", "rigs.json")
- **gt-cvfg**: Use cmd.OutOrStdout in refinery (30+ fmt.Print occurrences)
- **gt-2xsh**: Audit silent error handling (_ = err patterns)
- **gt-2n6z**: Inconsistent error wrapping patterns

### P4
- **gt-92of**: Consider splitting large files (800+ lines)
- **gt-pbr3**: Add godoc comments to exported functions

## Recommended Next Steps
1. Pick a P3 issue (gt-xnql or gt-2xsh are focused)
2. Run `bd show <id>` for details
3. Run `bd update <id> --status=in_progress` to claim
4. After completing, run session end checklist

## Commands
- `bd show gt-5n2f` - View full epic
- `bd ready` - See unblocked work
- `git log --oneline -5` - See recent commits


🤝 HANDOFF: Routine cycle after 20 patrols

All systems healthy. Mayor, 2 Witnesses, 2 Refineries, 2 Crews all running.


Test echo banner

Testing echo format


Digest: mol-deacon-patrol

Patrol 20: final patrol before handoff


Digest: mol-deacon-patrol

Patrol 18: All healthy


Digest: mol-deacon-patrol

Patrol 2: inbox clear, all rigs healthy, no issues


Digest: mol-deacon-patrol

Patrol 94: 4 polecats active


Digest: mol-deacon-patrol

Patrol 20: Final, all healthy


Digest: mol-deacon-patrol

Patrol cycle 9: all clear


Digest: mol-deacon-patrol

Patrol cycle 9: routine


Digest: mol-deacon-patrol

Patrol cycle 3: clean, all agents healthy


Digest: mol-deacon-patrol

Patrol 6: routine


Test: self-mail

Testing crew self-mail


🔍 CODE REVIEW: Wisp simplification (bd-bkul)

## Code Review Needed

The wisp simplification work (bd-bkul) was just completed. Please review for correctness and edge cases.

### Files Changed

1. cmd/bd/mol_squash.go - Removed cross-store squash functions
2. cmd/bd/mol_burn.go - Rewrote to work with main store
3. cmd/bd/mol_bond.go - Updated bondProtoMol signature for dual flags
4. cmd/bd/pour.go - Updated bondProtoMol call
5. internal/beads/beads.go - Deprecated wisp storage functions

### Key Review Points

- Verify squashMolecule() handles wisp children correctly
- Verify mol burn rejects non-wisp molecules
- Verify bond --wisp creates Wisp=true in main store
- Verify bond --pour creates Wisp=false
- Verify JSONL export still skips wisps
- Check edge cases in phase inheritance logic

### Test Commands

bd create "Test wisp" -t task --wisp --json
bd wisp list --json
bd mol bond mol-xxx bd-yyy --wisp --dry-run
bd --no-daemon mol burn <wisp-id> --dry-run


Digest: mol-deacon-patrol

Patrol #5: routine, all healthy


Digest: mol-deacon-patrol

Patrol cycle 7: all agents healthy, no orphans


📋 Work Assignment: TIDY UP: Your previous work (patrol runner) was already m...

Issue: gt-qns0
Title: TIDY UP: Your previous work (patrol runner) was already m...
Priority: P2
Type: task

Description:
TIDY UP: Your previous work (patrol runner) was already merged to main. Check your git status is clean, sync beads, and if nothing to do, just run 'gt done'.

## 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 10: all healthy


Session ended: gt-gastown-crew-george


Dog: testdog2


Digest: mol-deacon-patrol

Cycle 7: stable


Digest: mol-deacon-patrol

Patrol cycle 16: all healthy, fixed 1 orphan


Digest: mol-deacon-patrol

Patrol cycle 6: Routine


Digest: mol-deacon-patrol

Patrol 20: Final patrol before handoff


Digest: mol-deacon-patrol

Patrol cycle 8: All healthy.


Digest: mol-deacon-patrol

Patrol 20: Nominal


Digest: mol-deacon-patrol

Patrol 10: routine


📋 Work Assignment: mol-witness-patrol

Issue: gt-87jz
Title: mol-witness-patrol
Priority: P1
Type: epic

Description:
Per-rig worker monitor patrol loop using the Christmas Ornament pattern.

The Witness is the Pit Boss for your rig. You watch polecats, nudge them toward
completion, verify clean git state before kills, and escalate stuck workers.

**You do NOT do implementation work.** Your job is oversight, not coding.

## The Christmas Ornament Shape

This molecule uses dynamic bonding to create inspection arms per-polecat:

```
                    ★ mol-witness-patrol (trunk)
                   /|\
            ┌─────┘ │ └─────┐
         PREFLIGHT DISCOVERY CLEANUP
            │       │        │
        ┌───┴───┐ ┌─┴─┐  ┌───┴───┐
        │inbox  │ │sur│  │aggreg │
        │refnry │ │vey│  │save   │
        │load   │ └─┬─┘  │summary│
        └───────┘   │    │contxt │
                    │    │loop   │
          ┌─────────┼─────────┐ └───────┘
          │         │         │
          ●         ●         ●     mol-polecat-arm (dynamic)
         ace       nux      toast
          │         │         │
       ┌──┴──┐   ┌──┴──┐   ┌──┴──┐
       │cap  │   │cap  │   │cap  │
       │ass  │   │ass  │   │ass  │
       │dec  │   │dec  │   │dec  │
       │exec │   │exec │   │exec │
       └──┬──┘   └──┬──┘   └──┬──┘
          │         │         │
          └─────────┴─────────┘
                    │
                 ⬣ base (cleanup)
```

## Phases

### PREFLIGHT (fixed steps)
1. inbox-check - Process lifecycle requests, help messages
2. check-refinery - Ensure MQ is alive and processing
3. load-state - Read persistent state (nudge counts, etc.)

### DISCOVERY (spawns dynamic arms)
4. survey-workers - List polecats, bond mol-polecat-arm per polecat
5. run-plugins - Bond mol-plugin-runner for each witness plugin

### CLEANUP (gate + fixed steps)
6. aggregate - GATE: WaitsFor all arms + plugins to complete
7. save-state - Persist nudge counts, action log
8. generate-summary - Create digest content
9. context-check - Check if context is high
10. burn-or-loop - Squash/burn wisp, then loop or exit

## Dynamic Arms

Each polecat gets mol-polecat-arm bonded as a wisp child:
- capture - Capture tmux output
- assess - Categorize state (working/idle/error/done)
- load-history - Get nudge counts for this polecat
- decide - Apply nudge matrix
- execute - Take action (nudge/kill/escalate/none)

Arms run in PARALLEL. The aggregate step waits for all to complete.

## Activity Feed

This design enables real-time visibility:

```
[14:32:08] + patrol-x7k.arm-ace bonded (5 steps)
[14:32:09] → patrol-x7k.arm-ace.capture in_progress
[14:32:10] ✓ patrol-x7k.arm-ace.capture completed
[14:32:14] ✓ patrol-x7k.arm-ace.decide completed (action: nudge-1)
[14:32:17] ✓ patrol-x7k.arm-ace COMPLETE
```

## Storage

- Wisp storage: .beads-wisp/ (ephemeral, gitignored)
- Persistent state: witness handoff bead (nudge counts, etc.)
- Digests: Squashed summaries in permanent beads

## Dependencies

- bd-xo1o: Dynamic Molecule Bonding epic (in beads rig)
  - bd mol bond with variable substitution
  - WaitsFor directive for fanout gates
  - Activity feed query

Labels: [template, christmas-ornament]

## 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 13


POLECAT_STARTED beads/echo

Issue: bd-n386
Session: gt-beads-echo


Digest: mol-deacon-patrol

Patrol cycle 3: inbox clear, gates clear, convoys ongoing, health good, 1 orphan session cleaned


POLECAT_STARTED beads/Compactor

Issue: bd-thgk
Session: gt-beads-Compactor


Digest: mol-deacon-patrol

Patrol 9: All clear


Digest: mol-deacon-patrol

Patrol 97: quiet


Digest: mol-deacon-patrol

Patrol C51: inbox empty, witness/refinery healthy, no callbacks, 176 stale wisps noted


Digest: mol-deacon-patrol

Patrol 19: all healthy


📋 Work Assignment: Implement gt mol status command

Issue: gt-uym5
Title: Implement gt mol status command
Priority: P1
Type: task

Description:
Show what's on an agent's hook.

```bash
gt mol status [target]
```

Output:
- What's slung (molecule name, associated issue)
- Current phase and progress
- Whether it's a wisp
- Next action hint

If no target, shows current agent's status.

Acceptance:
- [ ] Read pinned bead attachment
- [ ] Display molecule/issue info
- [ ] Show phase progress
- [ ] Indicate wisp vs durable

## 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 3: All healthy, no incidents


Digest: mol-deacon-patrol

Patrol 11: All healthy.


POLECAT_DONE nux

Exit: COMPLETED
Issue: gt-ldk8
MR: gt-z9xv
Branch: polecat/nux


Digest: mol-deacon-patrol

Patrol 9: Auto


Digest: mol-deacon-patrol


Digest: mol-deacon-patrol

Patrol cycle 7: all healthy


📋 Work Assignment: Improve bd doctor output formatting for better readability

Issue: bd-4qfb
Title: Improve bd doctor output formatting for better readability
Priority: P2
Type: task

Description:
Improve bd doctor output formatting for better readability.

## Current State
Doctor output is a wall of text with:
- All checks shown (even passing ones)
- No visual hierarchy
- Hard to spot failures in long output

## Target Output

```
$ bd doctor

bd doctor v0.35.0

Summary: 24 checks passed, 1 warning, 0 errors

─────────────────────────────────────────────────
⚠ Warnings (1)
─────────────────────────────────────────────────

[hooks] Git hooks outdated
  Current version: 0.34.0
  Latest version: 0.35.0
  Fix: bd hooks install

─────────────────────────────────────────────────
✓ Passed (24)  [use --verbose to show details]
─────────────────────────────────────────────────
```

With --verbose:
```
$ bd doctor --verbose

bd doctor v0.35.0

Summary: 24 checks passed, 1 warning, 0 errors

─────────────────────────────────────────────────
⚠ Warnings (1)
─────────────────────────────────────────────────

[hooks] Git hooks outdated
  ...

─────────────────────────────────────────────────
✓ Passed (24)
─────────────────────────────────────────────────

  Database
    ✓ Database exists
    ✓ Database readable
    ✓ Schema up to date

  Git Hooks
    ✓ Pre-commit hook installed
    ✓ Post-merge hook installed
    ⚠ Hooks version mismatch (see above)

  Sync
    ✓ Sync branch configured
    ✓ Remote accessible
    ...
```

## Implementation

### 1. Add check categories (cmd/bd/doctor/categories.go)

```go
type Category string

const (
    CatDatabase  Category = "Database"
    CatHooks     Category = "Git Hooks"
    CatSync      Category = "Sync"
    CatDaemon    Category = "Daemon"
    CatConfig    Category = "Configuration"
    CatIntegrity Category = "Data Integrity"
)

// Assign categories to checks
var checkCategories = map[string]Category{
    "database-exists":     CatDatabase,
    "database-readable":   CatDatabase,
    "schema-version":      CatDatabase,
    "pre-commit-hook":     CatHooks,
    "post-merge-hook":     CatHooks,
    "hooks-version":       CatHooks,
    "sync-branch":         CatSync,
    "remote-access":       CatSync,
    // ... etc
}
```

### 2. Add --verbose flag

```go
// In cmd/bd/doctor.go init()
doctorCmd.Flags().BoolP("verbose", "v", false, "Show all checks including passed")
```

### 3. Create formatter (cmd/bd/doctor/format.go)

```go
type Formatter struct {
    verbose bool
    noColor bool
}

func (f *Formatter) Format(results []CheckResult) string {
    var buf strings.Builder

    // Count by status
    passed, warnings, errors := countByStatus(results)

    // Header
    buf.WriteString(fmt.Sprintf("bd doctor v%s\n\n", version.Version))
    buf.WriteString(fmt.Sprintf("Summary: %d passed, %d warnings, %d errors\n\n",
        passed, warnings, errors))

    // Errors section (always show)
    if errors > 0 {
        f.writeSection(&buf, "✗ Errors", filterByStatus(results, StatusError))
    }

    // Warnings section (always show)
    if warnings > 0 {
        f.writeSection(&buf, "⚠ Warnings", filterByStatus(results, StatusWarning))
    }

    // Passed section (only with --verbose)
    if f.verbose && passed > 0 {
        f.writePassedSection(&buf, filterByStatus(results, StatusPassed))
    } else if passed > 0 {
        buf.WriteString(fmt.Sprintf("✓ Passed (%d)  [use --verbose to show details]\n", passed))
    }

    return buf.String()
}

func (f *Formatter) writeSection(buf *strings.Builder, title string, results []CheckResult) {
    buf.WriteString("─────────────────────────────────────────────────\n")
    buf.WriteString(title + "\n")
    buf.WriteString("─────────────────────────────────────────────────\n\n")

    for _, r := range results {
        buf.WriteString(fmt.Sprintf("[%s] %s\n", r.CheckName, r.Message))
        if r.Details != "" {
            buf.WriteString(fmt.Sprintf("  %s\n", r.Details))
        }
        if r.Fix != "" {
            buf.WriteString(fmt.Sprintf("  Fix: %s\n", r.Fix))
        }
        buf.WriteString("\n")
    }
}

func (f *Formatter) writePassedSection(buf *strings.Builder, results []CheckResult) {
    // Group by category
    byCategory := groupByCategory(results)

    buf.WriteString("─────────────────────────────────────────────────\n")
    buf.WriteString(fmt.Sprintf("✓ Passed (%d)\n", len(results)))
    buf.WriteString("─────────────────────────────────────────────────\n\n")

    for _, cat := range categoryOrder {
        if checks, ok := byCategory[cat]; ok {
            buf.WriteString(fmt.Sprintf("  %s\n", cat))
            for _, r := range checks {
                buf.WriteString(fmt.Sprintf("    ✓ %s\n", r.Message))
            }
            buf.WriteString("\n")
        }
    }
}
```

### 4. Update run function

```go
func runDoctor(cmd *cobra.Command, args []string) {
    verbose, _ := cmd.Flags().GetBool("verbose")
    noColor, _ := cmd.Flags().GetBool("no-color")

    results := runAllChecks()

    formatter := &Formatter{verbose: verbose, noColor: noColor}
    fmt.Print(formatter.Format(results))

    // Exit code based on results
    if hasErrors(results) {
        os.Exit(1)
    }
}
```

## Files to Modify

1. **cmd/bd/doctor.go** - Add --verbose flag, update run function
2. **cmd/bd/doctor/format.go** - New file for formatting logic
3. **cmd/bd/doctor/categories.go** - New file for check categorization
4. **cmd/bd/doctor/common.go** - Add Status field to CheckResult if missing

## Testing

```bash
# Default output (concise)
bd doctor

# Verbose output
bd doctor --verbose

# JSON output (should still work)
bd doctor --json
```

## Success Criteria
- Summary line at top with counts
- Only failures/warnings shown by default
- --verbose shows grouped passed checks
- Visual separators between sections
- Exit code 1 if errors, 0 otherwise

## 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 4: Quick cycle.


Digest: mol-deacon-patrol

Patrol cycle 15: All healthy


Digest: mol-deacon-patrol

Cycle 13: Clean


Digest: mol-deacon-patrol

Patrol 12: Routine


Test archive

Testing archive command


Digest: mol-deacon-patrol

Patrol 11: quiet


Digest: mol-deacon-patrol

Patrol 7: healthy


Digest: mol-deacon-patrol

Patrol cycle 16: Routine


Digest: mol-deacon-patrol

Patrol 54: Stable


POLECAT_STARTED beads/india

Issue: bd-indn
Session: gt-beads-india


Digest: mol-deacon-patrol

Patrol cycle 14: routine


Digest: mol-deacon-patrol

Patrol cycle 5: inbox clear, no convoys, gates clear, health ok, no orphans


Digest: mol-deacon-patrol

Patrol #19: routine


Digest: mol-deacon-patrol

Patrol 93: all healthy


Digest: mol-deacon-patrol

Patrol 5: routine, all healthy


POLECAT_DONE keeper

Exit: COMPLETED
Issue: bd-g9eu
MR: mr-1766562624-dc0bf534
Branch: polecat/keeper


Digest: mol-deacon-patrol

Patrol cycle 6: routine


Digest: mol-deacon-patrol

Patrol 82: All healthy, no changes


📋 Work Assignment: Improve test coverage for internal/daemon (27.3% → 60%)

Issue: bd-n386
Title: Improve test coverage for internal/daemon (27.3% → 60%)
Priority: P2
Type: task

Description:
The daemon package has only 27.3% test coverage. The daemon is critical for background operations and reliability.

Key areas needing tests:
- Daemon autostart logic
- Socket handling
- PID file management
- Health checks

Current coverage: 27.3%
Target coverage: 60%

## 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 25: town idle, all healthy


Digest: mol-deacon-patrol

Patrol 1: all agents healthy, no callbacks, no gates, no orphans


Test self-mail

This should NOT trigger a tmux notification


Digest: mol-deacon-patrol

Patrol 1: Inbox clear, no callbacks, all 3 rigs healthy, 1 orphan session cleaned, no stale polecats


MR Ready: Polish (bd-4qfb)

Polish completed. Doctor output formatting improved. Branch: polecat/Polish ready for merge.


Digest: mol-deacon-patrol

Patrol cycle 1: inbox empty, 3 rigs healthy, no orphans, no pending spawns


POLECAT_STARTED charlie

Issue: bd-llfl
Session: gt-beads-charlie


Digest: mol-deacon-patrol

P20: Final patrol complete, handing off


Digest: mol-deacon-patrol

Final patrol before handoff: all stable


Digest: mol-deacon-patrol

Patrol cycle 10: All healthy


Digest: mol-deacon-patrol

Patrol 4: All healthy.


Digest: mol-deacon-patrol

Patrol 6: routine, all healthy


Digest: mol-deacon-patrol

Patrol 53: All healthy


Digest: mol-deacon-patrol

Patrol 5: All healthy


Digest: mol-deacon-patrol

Patrol 6: healthy


Digest: mol-deacon-patrol

Patrol 10: all healthy


Dog: testdog6


Digest: mol-deacon-patrol

Patrol cycle 13: All healthy. 2 more polecats (dag, cheedo).


Digest: mol-deacon-patrol

Patrol 18: routine, all healthy


Digest: mol-deacon-patrol

Patrol 3: All agents healthy, queues clear


Digest: mol-deacon-patrol

Cycle 8: Clean


Digest: mol-deacon-patrol

Patrol 72


Digest: mol-deacon-patrol

Patrol 13: all healthy


Digest: mol-deacon-patrol

Patrol 3: Quiet cycle, all healthy


Digest: mol-deacon-patrol

Patrol 1: restarted gastown witness, beads witness, gastown refinery (all had dead beads). 2 convoys tracking in-progress bugs.


Digest: mol-deacon-patrol

Patrol 20: Final - 14+ agents running, all healthy


MR Ready: Syncer (bd-io8c)

Syncer completed. Syncbranch test coverage. Branch: polecat/Syncer ready for merge.


Digest: mol-deacon-patrol

Patrol 2: Restarted beads witness, all polecats working


Digest: mol-deacon-patrol

Patrol 83: killed orphan gt-deacon-boot, all agents healthy


🤝 HANDOFF: Cross-project deps - bd-zmmy remaining

## Summary

Implemented 3 of 4 tasks for cross-project dependency support (bd-h807):

**COMPLETED:**
- bd-66w1: external_projects config ✓
- bd-om4a: external: prefix in blocked_by ✓
- bd-eijl: bd ship command ✓

**IN PROGRESS:**
- bd-zmmy: Make bd ready resolve external deps

## What's Done

1. **Config** (internal/config/config.go):
   - GetExternalProjects() - returns map of project names to paths
   - ResolveExternalProjectPath() - resolves name to absolute path

2. **External refs** (cmd/bd/dep.go):
   - bd dep add accepts external:project:capability syntax
   - Validation with ParseExternalRef(), IsExternalRef()

3. **Blocked cache** (blocked_cache.go, ready.go):
   - External refs included in blocked_issues_cache
   - GetBlockedIssues shows external refs in blocked_by

4. **Ship command** (cmd/bd/ship.go):
   - bd ship <capability> finds export: label, adds provides: label
   - Namespace protection for provides:* in label add

## What's Left (bd-zmmy)

Need to make external deps actually resolve. Created helper file:
  internal/storage/sqlite/external_deps.go

Key function: CheckExternalDep() opens remote beads DB and checks
for closed issue with provides:<capability> label.

**Design challenge:** The blocked_cache.go uses pure SQL CTE, but
external dep resolution requires Go code to open external DBs.

**Options:**
1. Two-phase cache rebuild: collect external refs in Go, create temp table, run CTE
2. Post-filter in GetReadyWork: let cache include all external deps, filter at query time
3. Hybrid: mark in cache, but also show resolution status in bd blocked output

I started option 1 but reverted the partial change. The external_deps.go
helper is ready to use.

## Files Changed

- internal/config/config.go (config funcs)
- internal/config/config_test.go (tests)
- cmd/bd/dep.go (external: prefix)
- cmd/bd/external_ref_test.go (tests)
- cmd/bd/ship.go (new command)
- cmd/bd/label.go (namespace protection)
- internal/storage/sqlite/blocked_cache.go (external deps in cache)
- internal/storage/sqlite/ready.go (external deps in GetBlockedIssues)
- internal/storage/sqlite/external_deps.go (resolution helper - WIP)
- docs/CONFIG.md (documentation)

Commits pushed to main.


Digest: mol-deacon-patrol

Patrol 14: quiet cycle


Digest: mol-deacon-patrol

Patrol 9: All systems nominal


🤝 HANDOFF: Routine patrol complete

Completed 20 patrol cycles. All agents healthy throughout (Mayor, 2 Witnesses, 2 Refineries). No lifecycle requests, no orphans, no extraordinary actions. Fresh session should continue patrol.

Stale deacon patrol handoffs - bulk cleanup


Digest: mol-deacon-patrol

Patrol cycle 9: All healthy.


POLECAT_DONE valkyrie

Exit: COMPLETED
Issue: bd-a15d
MR: mr-1766562986-bbf623e3
Branch: polecat/valkyrie


Polecat Wisp Architecture Complete (gt-9g82)

## Summary

Completed the Proto → Wisp → Mol architecture for agent session management.

## Key Deliverables

### 1. Session Wisp Molecules (builtin_molecules.go)
- **mol-crew-session**: Light harness for crew workers with auto-continue
- **mol-polecat-session**: One-shot wisp wrapping polecat work

### 2. Auto-Continue Logic (prime.go)
- `outputCrewAttachmentStatus()` detects pinned beads with attachments
- Outputs "AUTO-CONTINUE MODE" directive when attached work found
- Crew workers now auto-continue without human input if work is attached

### 3. Documentation
- `docs/polecat-wisp-architecture.md` - Full design doc
- `prompts/roles/crew.md` - Session Wisp Model section added

## Commits
- b71c188: mol-crew-session, mol-polecat-session molecules
- 6ec6fb0: Crew auto-continue in gt prime

## The Insight
**If there's attached work, continue without awaiting input.**

This transforms crew workers from interactive assistants to autonomous workers
that can churn through long molecules overnight.

## Follow-up Filed
- gt-op78: Session cycling (auto-spawn successor when context full)

## Integration with Christmas Plan

This enables overnight autonomous work on long molecules. The overseer can:
1. Attach a big feature epic to a crew worker
2. Crew worker processes it across multiple sessions
3. Each session auto-continues from predecessor's handoff

Ready for reset of overall Christmas plan - this thread is complete.


Digest: mol-deacon-patrol

Patrol 5


Digest: mol-deacon-patrol

Patrol 7: routine


Digest: mol-deacon-patrol

Patrol 20: quiet


Digest: mol-deacon-patrol

Patrol 78: All healthy. No incidents.


Digest: mol-deacon-patrol

Patrol cycle 2: All agents healthy, 2 convoys open (PR #140, #149), no orphans, clone divergence noted (gastown/crew/joe 65 commits behind)


Digest: mol-deacon-patrol

Patrol 4: all clear


POLECAT_DONE cheedo

Exit: COMPLETED
Issue: bd-9usz
MR: mr-1766562591-721819af
Branch: polecat/cheedo


Digest: mol-deacon-patrol

Patrol cycle 13: Routine, all healthy


Digest: mol-deacon-patrol

Patrol 8: Stable


🤝 HANDOFF: mol squash code review complete

Completed bd mol squash implementation (bd-2vh3.3) and code review.

## Code Review Summary

### Critical Finding (bd-687g)
deleteEphemeralChildren uses DeleteIssue directly, bypassing:
- Tombstone creation
- Deletion tracking (deletions.jsonl)
- Dependency cleanup

This may be intentional for ephemeral issues (they should never propagate), but needs design decision.

### Minor Issues (not tracked)
1. --json flag not respected in dry-run mode
2. No validation that molecule is complete before squash
3. UTF-8 truncation risk in string truncation
4. Child ordering not deterministic

### Good Practices
- Transaction for atomicity
- Error wrapping
- CheckReadonly guard
- markDirtyAndScheduleFlush called
- Comprehensive tests

## Files Changed
- cmd/bd/mol_squash.go (new - 306 lines)
- cmd/bd/mol_test.go (added 216 lines of tests)

## Epic Progress (bd-2vh3)
- Tier 1 (bd-2vh3.2): CLOSED - ephemeral spawning
- Tier 2 (bd-2vh3.3): CLOSED - mol squash command
- Tier 3 (bd-2vh3.4): OPEN - AI summarization
- Tier 4 (bd-2vh3.5): OPEN - auto-squash
- Tier 5 (bd-2vh3.6): OPEN - archive rotation

Commit: b7c7e7cb pushed to origin/main


Digest: mol-deacon-patrol

Patrol cycle 3: routine, all clear


Rename 'wisp' back to 'ephemeral' in beads API

The beads API uses 'wisp' terminology (Wisp field, bd wisp command) but the underlying SQLite column is 'ephemeral'.

This creates cognitive overhead since wisp is a Gas Town concept.

Rename to use 'ephemeral' consistently:
- types.Issue.Wisp → types.Issue.Ephemeral
- JSON field: wisp → ephemeral
- CLI: bd wisp → bd ephemeral (or just use flags on existing commands)

The SQLite column already uses 'ephemeral' so no schema migration needed.

Duplicate - created bd-o18s in beads rig instead


Digest: mol-deacon-patrol

Patrol 16: healthy


LIFECYCLE: gastown-crew-max requesting cycle

Lifecycle request from gastown-crew-max.

Action: cycle
Time: 2025-12-22T23:54:53-08:00

Please verify state and execute lifecycle action.


Digest: mol-deacon-patrol

Patrol C29: All healthy


Digest: mol-deacon-patrol

Patrol 6: routine


Re: Escalation: 4 dormant polecats with unpushed commits

Polecats were just nuked during cleanup. Three of the four commits are already on main (gt-6r18e.9, gt-xheo6.1, gt-5tipl).

gt-xheo6.3 (worktree remove) work from toast appears lost - commits not recoverable. Task remains open and will need to be reassigned.


Digest: mol-deacon-patrol

Patrol 20: All healthy, handoff


Move pending spawn tracking from deacon to spawn command

## Problem

The pending spawn tracking is currently under `gt deacon pending`, but this functionality is orthogonal to the Deacon role. Anyone might need to observe pending polecats:
- Human stepping in while Deacon is down
- Mayor doing manual spawn management
- Debugging/observability

## Current state

- `gt deacon pending` - command to view/clear pending spawns
- `deacon/pending.go` - core infrastructure
- `deacon/pending.json` - data storage

## Proposed change

Move to `gt spawn pending`:
```bash
gt spawn --issue gt-xyz        # Creates polecat (existing)
gt spawn pending               # Shows pending spawns awaiting trigger
gt spawn pending --clear <session>  # Clear from list after triggering
```

### Tasks
1. Move `pending.go` from `deacon/` to `spawn/` (or new `polecat/` package)
2. Move `pending.json` storage from `deacon/` to somewhere neutral
3. Add `pending` subcommand to `gt spawn`
4. Keep `gt deacon trigger-pending` as bootstrap-mode only (daemon calls this)
5. Update Deacon docs to use new command

This keeps the readiness observation generic while leaving the bootstrap regex mode as a Deacon/daemon detail.

Implemented: pending spawn tracking moved to gt spawn pending


New Assignment: gt-yd98

gt-um6q blocked - reassigning you to gt-yd98 (Molecule format bridge: convert embedded markdown to child issues). Run: bd show gt-yd98 and get started.


Dog: testdog7


Digest: mol-deacon-patrol

Patrol 16: all clear


Digest: mol-deacon-patrol

Patrol 16: Routine.


Digest: mol-deacon-patrol

Patrol 34: routine, all healthy


🤝 HANDOFF: Beads migration and cleanup

## Summary
Two-level beads routing fix is DONE. Mail now always uses town beads.

## Completed
- hq-5k5: Mail routing fix (commits c16324b, 5f20634 in gastown)
- All gt mail commands now use town root beads
- findMailWorkDir() for mail, findLocalBeadsDir() for project work

## Remaining Work

### hq-0l8: Migrate orphaned issues from rig-level beads
The gitignored ~/gt/gastown/.beads/ has 95 gt-* issues that may be orphans.
Clone beads (crew/max) has 422 gt-* issues.

Steps:
1. Export rig-level issues
2. Compare IDs to find orphans (in rig but not in clone)
3. Import relevant orphans to clone beads
4. Document findings

### Prefix mismatch in town beads
bd sync reported: gm-* issues (6) in town beads which should only have hq-*.
These are likely from the beads rig's mail. May need cleanup.

### Old handoff message
hq-ewc is the old handoff - can be deleted after reading this one.

## Files Changed
- internal/cmd/mail.go - routing fix
- internal/cmd/molecule.go - uses findLocalBeadsDir
- internal/cmd/statusline.go - uses findMailWorkDir

-- Mayor


Digest: mol-deacon-patrol

Patrol 29: town idle, all healthy


Digest: mol-deacon-patrol

Patrol cycle 13: routine


POLECAT_STARTED testcat

Issue: bd-d28c
Session: gt-beads-testcat


Digest: mol-deacon-patrol

Patrol 114: All healthy.


Digest: mol-deacon-patrol

Patrol 6: All healthy.


Digest: mol-deacon-patrol

Patrol 3: all healthy


Digest: mol-deacon-patrol

Patrol 22: All healthy


🤝 HANDOFF: Implement spawn --attach flag

## Session Summary

Completed:
- Code reviewed mol bond implementation (filed bd-e7ou, bd-ia3g, bd-kzda)
- Implemented bd mol distill command (bd-iq19) - extracts proto from epic

## Next: bd-obep - Spawn-time bonding

Add --attach flag to bd mol spawn for on-the-fly composition:

```bash
bd mol spawn proto-feature --attach proto-docs --attach proto-testing
```

Implementation notes:
- Add --attach (repeatable) and --attach-type flags to molSpawnCmd
- For each --attach: spawn that proto, then bond to primary
- Use bondProtoMol logic (or call it directly)
- All attached protos share variable namespace from --var flags
- Default bond type: sequential

Reference: mol.go has bondProtoMol at line 707 - can reuse that logic.

## Remaining molecule P2 work
- bd-iw4z: Compound visualization in bd mol show


Digest: mol-deacon-patrol

Patrol cycle 7: inbox clear, all agents healthy (gastown/beads witnesses+refineries running), 3 polecats working, no orphans


Digest: mol-deacon-patrol

Patrol C63: inbox empty, convoy hq-ao67r pending (10 issues), burned 20 stale wisps, cleaned 9 stale locks, all agents healthy


Digest: mol-deacon-patrol

Patrol 14: routine


Digest: mol-deacon-patrol

Patrol #8: All healthy.


Digest: mol-deacon-patrol

Patrol #7: routine


Digest: mol-deacon-patrol

Patrol 11: All healthy


Digest: mol-deacon-patrol

Patrol cycle 12: All healthy. 4 new polecats started (rictus, dementus, capable, toast).


Digest: mol-deacon-patrol

Patrol cycle 18 complete: all clear.


Digest: mol-deacon-patrol

Patrol 5: EXTRAORDINARY - restarted gastown witness/refinery after 3 dead observations


Digest: mol-deacon-patrol

Patrol 17: All healthy


Digest: mol-deacon-patrol

Patrol 48: Stable


Test: new slash to refinery

Testing slash-based refinery address


Digest: mol-deacon-patrol

Patrol 18: Town idle


Digest: mol-deacon-patrol

Patrol 14: all healthy


Digest: mol-deacon-patrol

Patrol #8: All clear


Digest: mol-deacon-patrol

Patrol cycle 18: Routine


Digest: mol-deacon-patrol

Patrol 3: routine, all healthy


Digest: mol-deacon-patrol

Patrol 17: Healthy


Swarm request: 12 backlog issues ready for polecats

## Swarm Request

12 unblocked issues ready for parallel polecat execution:

### P1 Delete Tests (3)
- bd-d28c: Test createTombstone and deleteIssue wrappers
- bd-dxtc: Test daemon RPC delete handler
- bd-dtl8: Test deleteViaDaemon RPC client integration

### P2 Test Coverage (4)
- bd-a15d: Add test files for internal/storage
- bd-m8ro: Improve test coverage for internal/rpc (47.5% → 60%)
- bd-6sm6: Improve test coverage for internal/export (37.1% → 60%)
- bd-g9eu: Investigate TestRoutingIntegration failure

### P2 Bug Fixes (3)
- bd-indn: bd template commands fail with daemon mode
- bd-de6: Fix FindBeadsDir for worktrees
- bd-yck: Fix checkExistingBeadsData to be worktree-aware

### P2 Refactoring (2)
- bd-c7y5: Optimization: Tombstones still synced overhead
- bd-y2v: Refactor duplicate JSONL-from-git parsing code

All issues are unblocked and have concrete acceptance criteria. Please spawn polecats as capacity allows.

-- dave (crew)


Digest: mol-deacon-patrol

Patrol 5: Quiet


Digest: mol-deacon-patrol

Patrol 100: All healthy, cycling for fresh context


Digest: mol-deacon-patrol

Patrol 35: healthy


Test pinned message

Testing pinned flag


Digest: mol-deacon-patrol

Patrol 19: All healthy


Digest: mol-deacon-patrol

Patrol 20: routine, all healthy - handoff threshold reached


RE: P1 Bug: bd pin fixed in v0.32.1

Hey Mayor,

The bd pin bug (gt-zr0a) was already fixed in commit 5d2daf2e.
It's included in v0.32.1.

gt mail send --pinned should work now.

-- dave


Digest: mol-deacon-patrol

Patrol 20: All healthy


🤝 HANDOFF: Config consolidation gt-k1lr tasks 6-8 remain

## Context
Implemented the three-tier config architecture for gt-k1lr (tasks 1-5 complete).

## What Was Done
- Replaced `.gastown/` with `.runtime/` for all runtime state
- Added `settings/` directory for rig behavioral config
- Created MayorConfig type for `mayor/config.json`
- Split RigConfig (identity) from RigSettings (behavioral)
- Updated all code references (20 files changed)
- Updated .gitignore patterns in both town root and gitinit.go template

## Remaining Tasks
Run `bd show gt-k1lr` to see full epic. Three tasks remain:

1. **gt-k1lr.6**: Update gt doctor to check new config locations [P1]
   - Doctor should verify settings/ exists for rigs
   - Doctor should verify .runtime/ is gitignored
   - May need to add migration check for old .gastown/ dirs

2. **gt-k1lr.7**: Update documentation for new config architecture [P2]
   - Update docs/architecture.md with new paths
   - Update CLAUDE.md files if they reference old paths

3. **gt-k1lr.8**: Remove .gastown/ after migration complete [P2]
   - Clean up old ~/gt/.gastown/ directory
   - Clean up old ~/gt/gastown/.gastown/ directory
   - This should be done AFTER doctor migration check is in place

## Key Files to Know
- internal/config/types.go - MayorConfig, RigConfig, RigSettings types
- internal/config/loader.go - Load/Save functions for new types
- internal/constants/constants.go - DirRuntime, DirSettings, path helpers

## Git State
- All changes committed and pushed
- Beads synced


Digest: mol-deacon-patrol

Patrol 8: Quick cycle.


Digest: mol-deacon-patrol

Patrol cycle 6: Routine, all healthy


Digest: mol-deacon-patrol

Patrol cycle 12: All healthy.


Digest: mol-deacon-patrol

Patrol cycle 1: Inbox empty, all 3 witnesses and 3 refineries healthy, cleaned 1 orphan session (gt-boot), no gates/convoys/plugins.


Digest: mol-deacon-patrol

Patrol 23: town idle, all healthy


SPAWN: dementus starting on gt-j6s8

Polecat spawn notification.

Polecat: dementus
Issue: gt-j6s8
Session: gt-gastown-dementus
Spawned by: gastown/polecats/furiosa

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.


📋 Work Assignment: Update vision.md with proto/mol/wisp terminology

Issue: gt-5wb7
Title: Update vision.md with proto/mol/wisp terminology
Priority: P1
Type: task

Description:
Update the Steam Engine Metaphor section to use consistent phase terminology:

Current (vision.md):
- Proto molecules = fuel (templates)
- Wisps = steam (transient execution traces)
- Digests = distillate (permanent records)

New terminology:
- **Proto** = crystal/solid - frozen template
- **Mol** = liquid - reified durable instance (tracked in git)
- **Wisp** = gas - ephemeral instance (evaporates after squash)
- **Digest** = distillate - compressed summary after squash

Key clarification needed:
- Proto → bond → creates either Mol (durable) or Wisp (ephemeral)
- The choice of Mol vs Wisp depends on --wisp flag
- Default is Mol (durable, recorded in main beads)
- Wisp lives in .beads-ephemeral/, squashes away

## 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.


POLECAT_STARTED beads/dementus

Issue: bd-au0.6
Session: gt-beads-dementus


Digest: mol-deacon-patrol

Patrol 3: Routine - all nominal.


Digest: mol-deacon-patrol

Patrol 64: All healthy


SPAWN: rictus starting on gt-c6zs

Polecat spawn notification.

Polecat: rictus
Issue: gt-c6zs
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 12: all clear


Digest: mol-deacon-patrol

Patrol 4: All healthy, no incidents


Digest: mol-deacon-patrol

Patrol 12: Town idle


Digest: mol-deacon-patrol

Patrol cycle 3: stable, no issues


POLECAT_STARTED immortan

Issue: bd-n386
Session: gt-beads-immortan


Digest: mol-deacon-patrol

Patrol 15: All healthy


POLECAT_STARTED beads/cheedo

Issue: bd-dxtc
Session: gt-beads-cheedo


Digest: mol-deacon-patrol

Patrol cycle 5: quiet, mayor has idle polecat notifications


SPAWN: slit starting on gt-vg6u

Polecat spawn notification.

Polecat: slit
Issue: gt-vg6u
Session: gt-gastown-slit
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-slit "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 13: Routine


Digest: mol-deacon-patrol

Patrol 176: All healthy, 4 polecats working


Digest: mol-deacon-patrol

Patrol 13: Routine, all healthy


Digest: mol-deacon-patrol

Patrol 11: routine, all healthy


Digest: mol-deacon-patrol

Patrol 9: All healthy.


🤝 HANDOFF: Session lifecycle doc drafted

## Completed This Session

1. Fixed gt-tocb (handoff path parsing)
2. Created docs/beads-data-plane.md (two-tier architecture with persistent+ephemeral)
3. Filed gt-ci84 (deacon wisps should use town beads)
4. Closed gt-5xph (session cycling in templates)
5. Created docs/session-lifecycle.md (Single-Bond Principle, context budget model)

## Key Concepts Documented

- Single-Bond Principle: one bead ≈ one session
- Context Budget Model: N-heuristics proxy for context consumption
- Happy Path (decomposition) vs Sad Path (compaction)
- Unified cycling model across all roles

## Ready for Refinement

The session-lifecycle.md doc captures the overseer's insights about:
- Agents are persistent identities, sessions are cattle
- N=1 for polecats because every assignment is 'interesting'
- Mid-step handoff is normal and supported
- Oversized Bead Protocol (partial impl vs decomposition)

Successor should review for clarity and consider implementation beads.


Digest: mol-deacon-patrol

Routine


📋 Work Assignment: Improve test coverage for internal/beads (48.1% → 70%)

Issue: bd-tvu3
Title: Improve test coverage for internal/beads (48.1% → 70%)
Priority: P1
Type: task

Description:
Improve test coverage for internal/beads package from 48% to 70%.

## Current State
- Coverage: 48.4%
- Files: beads.go, fingerprint.go
- Tests: beads_test.go (moderate coverage)

## Functions Needing Tests

### beads.go (database discovery)
- [ ] followRedirect - needs redirect file tests
- [ ] findDatabaseInBeadsDir - needs various dir structures
- [x] NewSQLiteStorage - likely covered
- [ ] FindDatabasePath - needs BEADS_DB env var tests
- [ ] hasBeadsProjectFiles - needs file existence tests
- [ ] FindBeadsDir - needs directory traversal tests
- [ ] FindJSONLPath - needs path derivation tests
- [ ] findGitRoot - needs git repo tests
- [ ] findDatabaseInTree - needs nested directory tests
- [ ] FindAllDatabases - needs multi-database tests
- [ ] FindWispDir - needs wisp directory tests
- [ ] FindWispDatabasePath - needs wisp path tests
- [ ] NewWispStorage - needs wisp storage tests
- [ ] EnsureWispGitignore - needs gitignore creation tests
- [ ] IsWispDatabase - needs path classification tests

### fingerprint.go (repo identification)
- [ ] ComputeRepoID - needs various remote URL tests
- [ ] canonicalizeGitURL - needs URL normalization tests
- [ ] GetCloneID - needs clone identification tests

## Implementation Guide

1. **Use temp directories:**
   ```go
   func TestFindBeadsDir(t *testing.T) {
       tmpDir := t.TempDir()
       beadsDir := filepath.Join(tmpDir, ".beads")
       os.MkdirAll(beadsDir, 0755)

       // Create test files
       os.WriteFile(filepath.Join(beadsDir, "beads.db"), []byte{}, 0644)

       // Change to tmpDir and test
       oldWd, _ := os.Getwd()
       os.Chdir(tmpDir)
       defer os.Chdir(oldWd)

       result := FindBeadsDir()
       assert.Equal(t, beadsDir, result)
   }
   ```

2. **Test scenarios:**
   - BEADS_DB environment variable set
   - .beads/ in current directory
   - .beads/ in parent directory
   - Redirect file pointing elsewhere
   - No beads directory found
   - Wisp directory alongside main beads

3. **Git remote URL tests:**
   ```go
   tests := []struct{
       input    string
       expected string
   }{
       {"git@github.com:user/repo.git", "github.com/user/repo"},
       {"https://github.com/user/repo", "github.com/user/repo"},
       {"ssh://git@github.com/user/repo.git", "github.com/user/repo"},
   }
   ```

## Success Criteria
- Coverage ≥ 70%
- All FindXxx functions have tests
- Environment variable handling tested
- Edge cases (missing dirs, redirects) covered

## Run Tests
```bash
go test -v -cover ./internal/beads
go test -race ./internal/beads
```

## 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

All healthy


Digest: mol-deacon-patrol

Patrol 6: All healthy


Digest: mol-deacon-patrol

Patrol cycle 3: All healthy


WORK_DONE: hq-6h9w4o

Exit: COMPLETED
Issue: hq-6h9w4o
MR: gt-evulp
Branch: polecat/furiosa-mk7g7g7t


Digest: mol-deacon-patrol

Patrol 7


Digest: mol-deacon-patrol

Patrol cycle 7: Routine, all healthy


Digest: mol-deacon-patrol

Patrol cycle 4: healthy


Digest: mol-deacon-patrol

Patrol cycle 21: Restarted wyvern refinery (was stopped). All other agents healthy. No callbacks, no orphans, 2 PR convoys still open (140, 149). Gastown refinery cycled multiple times during patrol.


Digest: mol-deacon-patrol

Patrol cycle 21: inbox empty, all agents healthy, no orphans, cleaned stale locks


Digest: mol-deacon-patrol

Patrol cycle 20: Routine


Digest: mol-deacon-patrol

Patrol cycle 7: quiet


POLECAT_DONE golf

Exit: COMPLETED
Issue: bd-de6
MR: mr-1766558043-a6331597
Branch: polecat/golf


Digest: mol-deacon-patrol

Patrol 92: quiet


Digest: mol-deacon-patrol

Cycle 6: Quiet


Digest: mol-deacon-patrol

Patrol 17: all healthy


Digest: mol-deacon-patrol

Patrol cycle 11: All healthy


Digest: mol-deacon-patrol

Patrol 9: Town idle


📋 Work Assignment: Add GetMoleculeProgress RPC endpoint

Issue: bd-0oqz
Title: Add GetMoleculeProgress RPC endpoint
Priority: P2
Type: feature

Description:
New RPC endpoint to get detailed progress for a specific molecule. Returns: moleculeID, title, assignee, and list of steps with their status (done/current/ready/blocked), start/close times. Used when user expands a worker in the activity feed TUI.

## 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 7: routine


Digest: mol-deacon-patrol

Patrol 9: healthy


🤝 HANDOFF: Continue backlog work

## Session Summary

Fixed 2 items this session:
- **GH#709** (94800416): FindJSONLInDir now skips interactions.jsonl, defaults to issues.jsonl
- **Flaky test** (e79558a9): Fixed database_removal_scenario test by making it more realistic

Also filed Gas Town epic **gt-tnca** for mol-ready-work patrol design (4 child tasks).

## Environment State

- Git: clean, up to date with origin
- Tests: all passing
- Cleaned up: merged branches (pr-677, pr-678), pruned 10 stale remotes, removed empty .runtime/

## Good Candidates for Next Session

From GH issues (run `gh issue list --state open --limit 20`):
- **GH#714**: bd doctor count mismatch (needs investigation)
- **GH#704**: Absolute paths in global gitignore with --stealth (bug)
- **GH#664**: bd create --parent fails even when parent exists (bug)

From beads (run `bd ready`):
- **bd-4opy**: Refactor long SQLite test files (P2 task)
- **bd-bqcc**: Consolidate maintenance commands into bd doctor --fix (P2 feature)

## Workflow

1. Pick an issue from GH or bd ready
2. Implement fix with tests
3. Commit and push to main
4. Repeat until context fills

Git is clean, all pushed. Ready to continue.


Digest: mol-deacon-patrol

Patrol cycle 4: All agents healthy, no orphans, routine


Digest: mol-deacon-patrol

Patrol cycle 9: No messages, all healthy.


Digest: mol-deacon-patrol

Patrol 2: No callbacks, all healthy, 3 convoys active


Digest: mol-deacon-patrol

Patrol 10: Routine


Digest: mol-deacon-patrol

Patrol 3: no callbacks, noted witness/refinery dead sessions for monitoring, cleaned stale wisp j4a, no plugins


Digest: mol-deacon-patrol

Patrol cycle 8: Routine


Digest: mol-deacon-patrol

Patrol cycle 8: thorough check, all healthy, wyvern crew dead (expected)


Lifecycle request from gastown-crew-max.

Action: cycle
Time: 2025-12-22T00:14:53-08:00

Please verify state and execute lifecycle action.


📋 Work Assignment: Reduce global state in cmd/bd/main.go (25+ variables)

Issue: bd-dhza
Title: Reduce global state in cmd/bd/main.go (25+ variables)
Priority: P3
Type: task

Description:
Code health review found main.go has 25+ global variables (lines 57-112):

- dbPath, actor, store, jsonOutput, daemonClient, noDaemon
- rootCtx, rootCancel, autoFlushEnabled
- isDirty (marked 'USED BY LEGACY CODE')
- needsFullExport (marked 'USED BY LEGACY CODE')
- flushTimer (marked 'DEPRECATED')
- flushMutex, storeMutex, storeActive
- flushFailureCount, lastFlushError, flushManager
- skipFinalFlush, autoImportEnabled
- versionUpgradeDetected, previousVersion, upgradeAcknowledged

Impact:
- Hard to test individual commands
- Race conditions possible
- State leakage between commands

Fix: Move toward dependency injection. Remove deprecated variables. Consider cmd/bd/internal package.

## 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 20: All healthy. Handoff threshold reached.


Digest: mol-deacon-patrol

Patrol 63: All healthy, no changes


Digest: mol-deacon-patrol

Patrol 2: All agents healthy. No messages, no pending work. Doctor: known warnings only.


Digest: mol-deacon-patrol

Patrol #8: routine


Digest: mol-deacon-patrol

Cycle 263: All clear, 14 polecats, all agents healthy


Digest: mol-deacon-patrol

Patrol 20: all healthy, handoff threshold reached


Digest: mol-deacon-patrol

Patrol 9: All healthy, no incidents


POLECAT_STARTED gastown/dementus

Issue: gt-eu9
Session: gt-gastown-dementus


Digest: mol-deacon-patrol

Patrol 8: quiet cycle


Digest: mol-deacon-patrol

Patrol 14: quiet


Digest: mol-deacon-patrol

Patrol 6: All clear


POLECAT_STARTED gastown/dementus

Issue: gt-qz2l
Session: gt-gastown-dementus


Digest: mol-deacon-patrol

Patrol 4: RESTARTED beads witness, handed refinery handoff


Digest: mol-deacon-patrol

Patrol 65: All healthy, 3 convoys. No incidents.


Digest: mol-deacon-patrol

Patrol 7: Routine


Digest: mol-deacon-patrol

Patrol 8: Routine


Digest: mol-deacon-patrol

Patrol 11: All clear


Digest: mol-deacon-patrol

Patrol cycle 12: All healthy, 1 orphan cleaned


Digest: mol-deacon-patrol

Patrol 4: quiet


Digest: mol-deacon-patrol

Patrol 9: all clear


Digest: mol-deacon-patrol

Patrol cycle 12: all healthy


Digest: mol-deacon-patrol

Patrol 20 (final)


Digest: mol-deacon-patrol

Patrol cycle 20: clean


Digest: mol-deacon-patrol

Patrol 4: healthy


Refactor mol.go then bd squash

Tasks: bd-cnwx (refactor mol.go 1200 lines), then bd-2vh3 (ephemeral cleanup). -Mayor


Digest: mol-deacon-patrol

Patrol: all healthy


Digest: mol-deacon-patrol

Patrol cycle 100: All healthy, cleaned 4 stale locks, no callbacks, 3 convoys tracked


Digest: mol-deacon-patrol

Patrol 8: Stable


Digest: mol-deacon-patrol


Digest: mol-deacon-patrol

Patrol 4: Routine, all healthy


Digest: mol-deacon-patrol

Patrol 36: All healthy


📋 Work Assignment: Add handoff self-initiation protocol to role templates

Issue: gt-v650
Title: Add handoff self-initiation protocol to role templates
Priority: P2
Type: task

Description:
Agents need clear protocol for self-initiated handoff:

1. Recognize: 'I should cycle now'
2. Prepare: Summarize current state, what's next
3. Send: gt mail send <self> -s '🤝 HANDOFF: ...' -m '...'
4. Exit: End session cleanly

This replaces external 'you should cycle now' nudging.
The agent owns its lifecycle.

Include examples for each role type.

## 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 11: No messages, all healthy.


Digest: mol-deacon-patrol

Patrol 6: Town idle


Digest: mol-deacon-patrol

Patrol cycle 10: all healthy


Digest: mol-deacon-patrol

Patrol 19: routine


Digest: mol-deacon-patrol

Patrol 15: town idle, all healthy


Digest: mol-deacon-patrol

Patrol 12: all healthy


Digest: mol-deacon-patrol

Patrol 49: Stable


Digest: mol-deacon-patrol

Patrol 71: All healthy. No incidents.


Digest: mol-deacon-patrol

Patrol 8: routine, all healthy


Digest: mol-deacon-patrol

Patrol 11: routine, all healthy


Digest: mol-deacon-patrol

Patrol 115: All healthy.


Digest: mol-deacon-patrol

Patrol 4: All healthy.


Digest: mol-deacon-patrol

Patrol 11: Swarm active.


Digest: mol-deacon-patrol

Patrol cycle 9: quiet


📌 Session Protocol Active

## Session Close Checklist

When ending session:
1. git status (check changes)
2. git add <files> (stage code)
3. bd sync (commit beads)
4. git commit -m '...'
5. bd sync (any new beads)
6. git push (push to remote)

## Current Work
- Molecules are now unified under bd mol
- bd mol run provides durable execution
- Pinning keeps context across resets

This pin survives compaction.


Digest: mol-deacon-patrol

Patrol 15: All healthy


📋 Work Assignment: Work on gt-8tmz.34: Expansion var overrides not implement...

Issue: bd-njrm
Title: Work on gt-8tmz.34: Expansion var overrides not implement...
Priority: P2
Type: task

Description:
Work on gt-8tmz.34: Expansion var overrides not implemented. The ExpandRule.Vars field exists in internal/formula/types.go but is ignored during expansion in internal/formula/expand.go. Implement: 1) Pass rule.Vars to expandStep in ApplyExpansions, 2) Merge vars with formula defaults (rule.Vars wins), 3) Substitute vars in template placeholders, 4) Add test in expand_test.go. When done, commit and push to main.

## 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 cycle 3: All agents healthy, no incidents


🤝 HANDOFF: Tracer bullet success + gaps filed

## Tracer Bullet Complete

Successfully ran one polecat through full lifecycle:
- Spawned polecat/tracer for gt-aobh
- Manually nudged to start (Deacon gap)
- Polecat fixed 4 files, ran tests, submitted via gt done
- Pushed branch to origin (refinery gap)
- Refinery merged to main: a8739f5
- Witness cleaned up session and worktree

## Gaps Filed as Issues

| Issue | P | Title |
|-------|---|-------|
| gt-t5uk | P1 | Deacon trigger-pending-spawns: Auto-nudge polecats |
| gt-gmqe | P1 | Refinery branch visibility: worktree or push |
| gt-gp6i | P2 | Witness cleanup should know worktree parent |

## What's Next

Fix gt-t5uk and gt-gmqe for reliable swarms without manual intervention.

## Beads State

Synced and reconciled with Dave's work. Main is up to date.


Digest: mol-deacon-patrol

Patrol 44: All healthy


Digest: mol-deacon-patrol

Patrol 9: routine


Digest: mol-deacon-patrol

Patrol 33: healthy


Digest: mol-deacon-patrol

Patrol 1: No callbacks, all agents healthy, 3 convoys open, no orphans


Digest: mol-deacon-patrol

Patrol 20: Complete, handoff time


Digest: mol-deacon-patrol

Cycle 23: Routine, cleaned 1 orphan session


Digest: mol-deacon-patrol

Patrol 1: burned 39 stale wisps, all agents healthy, 2 convoys active


SPAWN: nux starting on gt-ldk8

Polecat spawn notification.

Polecat: nux
Issue: gt-ldk8
Session: gt-gastown-nux
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.


📋 Work Assignment: Update polecat CLAUDE.md with molecule workflow

Issue: gt-a817
Title: Update polecat CLAUDE.md with molecule workflow
Priority: P2
Type: task

Description:
Add molecule execution guidance to polecat context:

## What to Add

### Molecule Awareness
- Polecats execute Wisps (ephemeral molecule instances)
- The work assignment mail includes molecule context
- Current step is tracked in the wisp

### Workflow Protocol
1. Read assignment (includes molecule ID and current step)
2. Execute current step
3. Update step status via bd mol step
4. Generate summary when all steps complete
5. Run bd mol squash to compress wisp into digest

### Key Commands
- bd mol show <wisp-id> - view current molecule state
- bd mol step <wisp-id> --status=complete - mark step done
- bd mol squash <wisp-id> --summary='...' - complete molecule

### Summary Generation
When completing work, generate a summary that:
- Lists what was accomplished
- Notes any deviations from the plan
- Captures key decisions made
- This becomes the permanent digest

## 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

Cycle 63: All healthy


Digest: mol-deacon-patrol

Patrol cycle 1: All agents healthy (gastown/beads/wyvern), cleaned 1 orphan session, no callbacks


Digest: mol-deacon-patrol

Patrol cycle 6: all healthy


Two-level beads architecture: Mail always uses town root

## Problem

Mail routing is broken. gt mail send uses address-based routing that sends messages
to the wrong beads database. Mayor sends to gastown/Toast, lands in gitignored
rig-level beads. Toast never sees it.

## Root Cause: Three-Level Confusion

Current architecture has three levels:
- ~/gt/.beads/ (Town, hq-*) - Mayor mail
- ~/gt/gastown/.beads/ (Rig, gitignored) - BROKEN middle child
- ~/gt/gastown/crew/max/.beads/ (Clone, gt-*) - project issues

## Solution: Two-Level Only

All mail goes to town beads. Period.

| Level | Location | Prefix | Purpose |
|-------|----------|--------|---------|
| Town | ~/gt/.beads/ | hq-* | ALL mail, coordination |
| Clone | <rig>/crew/*/.beads/ | gt-* | Project issues only |

## Implementation

1. gt mail * always uses town root
   - Replace findBeadsWorkDirForAddress() with simple town root lookup
   - All mail commands use workspace.FindFromCwdOrError() directly

2. Remove rig-level .beads/
   - Delete ~/gt/gastown/.beads/
   - Remove any code that creates/uses rig-level beads

3. Issue filing stays in clones
   - bd create in a clone still uses that clone's beads

## Files to Change

- internal/cmd/mail.go: Replace routing logic
- ~/gt/gastown/.beads/: Delete directory
- CLAUDE.md files: Update docs

Replace findBeadsWorkDirForAddress() with simple town root lookup. All gt mail commands use town beads only.

1. gt mail send from mayor to any address lands in town beads
2. gt mail inbox --identity X reads from town beads
3. No rig-level .beads/ directories exist
4. Documentation reflects two-level model

Rig-level beads (gastown/.beads) has 95 stale gt-* issues. Left in place for now as it's gitignored. Routing fix ensures no new data goes there. Can garbage collect later.

Implemented and committed by max. Mail now uses town beads only. Commits: c16324b, 5f20634.


Digest: mol-deacon-patrol

Patrol cycle 26: Routine, all healthy.


Digest: mol-deacon-patrol

Patrol 7: Idle


POLECAT_DONE Pinner

Exit: COMPLETED
Issue: bd-phtv
MR: bd-r06v
Branch: polecat/Pinner


Digest: mol-deacon-patrol

Patrol 3: all clear


Digest: mol-deacon-patrol

Patrol 9


Digest: mol-deacon-patrol

Patrol 10: full status check, all healthy