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 step finds spawned polecats that are now ready and sends them a trigger to start working.

**ZFC-Compliant Observation** (AI observes AI):

```bash
# View pending spawns with captured terminal output
gt deacon pending
```

For each pending session, analyze the captured output:
- Look for Claude's prompt indicator "> " at the start of a line
- If prompt is visible, Claude is ready for input
- Make the judgment call yourself - you're the AI observer

For each ready polecat:
```bash
# 1. Trigger the polecat
gt nudge <session> "Begin."

# 2. Clear from pending list
gt deacon pending <session>
```

This triggers the UserPromptSubmit hook, which injects mail so the polecat sees its assignment.

**Bootstrap mode** (daemon-only, no AI available):
The daemon uses `gt deacon trigger-pending` with regex detection. This ZFC violation is acceptable during cold startup when no AI agent is running yet.


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-processes check currently has a bug that misidentifies active crew
sessions as orphaned. Until this is fixed:

1. Run `gt status` first to see what's actually running
2. Run `gt doctor -v` to see what it thinks is orphaned
3. If orphan-processes lists ANY PIDs, DO NOT run --fix
4. Only run `gt doctor --fix` if orphan-processes reports 0 orphans

```bash
# Check what's actually running
gt status

# Check what doctor sees
gt doctor -v

# ONLY if orphan-processes shows 0:
gt doctor --fix
```

The goal is for `gt doctor --fix` to be safe and idempotent. If it's not,
that's a bug in the detection logic that needs to be fixed.

gt doctor non-responsive; will retry next cycle


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:
- Write state to persistent storage
- Exit cleanly
- Let the daemon orchestrator respawn a fresh Deacon

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

This enables infinite patrol duration via context-aware respawning.


Fire notifications

Fire notifications for convoy and cross-rig events.

After convoy completion or cross-rig dependency resolution, notify relevant parties.

**Convoy completion notifications:**
When a convoy closes (all tracked issues done), notify the Overseer:
```bash
# Convoy gt-convoy-xxx just completed
gt mail send mayor/ -s "Convoy complete: <convoy-title>" \
  -m "Convoy <id> has completed. All tracked issues closed.
      Duration: <start to end>
      Issues: <count>

      Summary: <brief description of what was accomplished>"
```

**Cross-rig resolution notifications:**
When a cross-rig dependency resolves, notify the affected rig:
```bash
# Issue bd-xxx closed, unblocking gt-yyy
gt mail send gastown/witness -s "Dependency resolved: <bd-xxx>" \
  -m "External dependency bd-xxx has closed.
      Unblocked: gt-yyy (<title>)
      This issue may now proceed."
```

**Notification targets:**
- Convoy complete → mayor/ (for strategic visibility)
- Cross-rig dep resolved → <rig>/witness (for operational awareness)

Keep notifications brief and actionable. The recipient can run bd show for details.


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/deacon-plugins.md for full documentation.

Gate types:
- cooldown: Time since last run (e.g., 24h)
- cron: Schedule-based (e.g., "0 9 * * *")
- condition: Metric threshold (e.g., wisp count > 50)
- event: Trigger-based (e.g., startup, heartbeat)

For each plugin:
1. Read plugin.md frontmatter to check gate
2. Compare against state.json (last run, etc.)
3. If gate is open, execute the plugin

Plugins marked parallel: true can run concurrently using Task tool subagents. Sequential plugins run one at a time in directory order.

Skip this step if ~/gt/plugins/ does not exist or is empty.


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** (await_type: timer):
Check if elapsed time since creation exceeds the timeout duration.

```bash
# List all open gates
bd gate list --json

# For each timer gate, check if elapsed:
# - CreatedAt + Timeout < Now → gate is ready to close
# - Close with: bd gate close <id> --reason "Timer elapsed"
```

**GitHub gates** (await_type: gh:run, gh:pr) - handled in separate step.

**Human/Mail gates** - require external input, skip here.

After closing a gate, the Waiters field contains mail addresses to notify.
Send a brief notification to each waiter that the gate has cleared.


Resolve external dependencies

Resolve external dependencies across rigs.

When an issue in one rig closes, any dependencies in other rigs should be notified. This enables cross-rig coordination without tight coupling.

**Step 1: Check recent closures from feed**
```bash
gt feed --since 10m --plain | grep "✓"
# Look for recently closed issues
```

**Step 2: For each closed issue, check cross-rig dependents**
```bash
bd show <closed-issue>
# Look at 'blocks' field - these are issues that were waiting on this one
# If any blocked issue is in a different rig/prefix, it may now be unblocked
```

**Step 3: Update blocked status**
For blocked issues in other rigs, the closure should automatically unblock them (beads handles this). But verify:
```bash
bd blocked
# Should no longer show the previously-blocked issue if dependency is met
```

**Cross-rig scenarios:**
- bd-xxx closes → gt-yyy that depended on it is unblocked
- External issue closes → internal convoy step can proceed
- Rig A issue closes → Rig B issue waiting on it proceeds

No manual intervention needed if dependencies are properly tracked - this step just validates the propagation occurred.


Check own context limit

Check own context limit.

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

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

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

This enables the Deacon to burn and respawn cleanly.


Digest: mol-deacon-patrol

Patrol cycle 16: All agents healthy, no lifecycle requests, no incidents


🤝 HANDOFF: Routine patrol cycle

Completed 20 patrols, all systems healthy.

## Session Summary
- Patrols 1-20: All complete, no issues
- Mayor (gt-mayor): Running
- Witnesses (beads, gastown): Both running
- Refineries (beads, gastown): Both running
- Crews (dave, max): Both running

## Next Steps
Continue patrol loop as normal.


Dynamic priming subsystem improvements

Eliminate static AGENTS.md/CLAUDE.md files in favor of fully dynamic priming via gt prime. See docs/priming-subsystem.md for design.

Key goals:
- Session state detection (normal, post-handoff, crash-recovery, autonomous)
- Post-handoff context injection to prevent handoff loops
- Thin static files to bootstrap pointers only
- Observability via gt prime --explain

This fixes the handoff loop bug properly and prevents future static-file drift.


Digest: mol-deacon-patrol

Patrol 15: all nominal


Digest: mol-deacon-patrol

Patrol 14: quiet, all healthy


📋 Work Assignment: Witness should verify polecat submitted before stopping session

Issue: gt-ldk8
Title: Witness should verify polecat submitted before stopping session
Priority: P1
Type: bug

Description:
## Problem

Witness stopped dementus's session before it could call `gt done`, losing the MR submission. I had to manually push and submit the branch.

## Root Cause

Witness cleanup is triggered by nudge/manual check rather than by receiving POLECAT_DONE message. When Witness cleans up based on issue status (closed), it doesn't wait for the polecat to complete its shutdown sequence.

## Expected Behavior

Witness should only stop a polecat session after:
1. Receiving POLECAT_DONE message from that polecat, OR
2. Timeout waiting for POLECAT_DONE after issue is closed

## Current Behavior

Witness stops sessions immediately when asked to check for completions, even if polecat hasn't called `gt done` yet.

## Fix

In mol-witness-patrol inbox-check step:
- Only clean up polecats that have sent POLECAT_DONE
- For polecats with closed issues but no DONE message, nudge them to complete
- Add timeout before force-killing

## 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 2: All healthy, no changes.


Digest: mol-deacon-patrol

Patrol cycle 10: Routine, all healthy


Digest: mol-deacon-patrol

Patrol cycle 16 complete: all clear.


Digest: mol-deacon-patrol

Patrol cycle 13: All healthy


POLECAT_STARTED gastown/nux

Issue: gt-vmk7
Session: gt-gastown-nux


Digest: mol-deacon-patrol

## Molecule Execution Summary

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

**Completed**: 9/9

---

### Steps

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

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

2. **[closed]** 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:
-...

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

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

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

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

See docs/deaco...

8. **[closed]** 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-...

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


BLOCKED: gt-um6q - Features not implemented

Polecat valkyrie reporting.

Task gt-um6q (Update docs with molecule navigation workflow) is BLOCKED.

Problem: The features I need to document don't exist:
- bd mol current - command not implemented
- bd close --continue - flag not implemented

The specs (gt-fly0, gt-qswb) were closed as "Moved to beads" but never implemented there.

Options:
1. Implement features in beads first
2. Assign different work
3. Wait

Awaiting instructions.


📋 Work Assignment: Phase 1.3: gt doctor checks for ephemeral health

Issue: gt-3x0z.3
Title: Phase 1.3: gt doctor checks for ephemeral health
Priority: P2
Type: task

Description:
Add doctor checks for ephemeral beads repo.

## Checks

1. **ephemeral-exists**: .beads-ephemeral/ directory exists for each rig
2. **ephemeral-git**: It's a valid git repo
3. **ephemeral-orphans**: Molecules started but never squashed (>24h old)
4. **ephemeral-size**: Warn if ephemeral repo is >100MB (should be cleaned)
5. **ephemeral-stale**: Molecules with no activity in last hour

## Auto-fix

--fix can:
- Create missing ephemeral repo
- Clean up old completed molecules (already squashed)
- NOT auto-squash incomplete molecules (needs AI summary)

## 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 cycle 10: all clear, halfway to handoff


Digest: mol-deacon-patrol

Patrol 3: handled refinery handoff, all clear


Digest: mol-deacon-patrol

Patrol 4: routine


Digest: mol-deacon-patrol

Patrol cycle 11


📋 Work Assignment: mol-christmas-launch: 3-day execution plan

Issue: bd-p5za
Title: mol-christmas-launch: 3-day execution plan
Priority: P0
Type: epic

Description:
Christmas Launch Molecule - execute phases in order, survive restarts.

PIN THIS BEAD. Check progress each session start.

## Step: phase0-beads-foundation
Fix blocking issues before swarming:
1. Verify gastown beads schema works: bd list --status=open
2. Ensure bd mol bond exists (check bd-usro)
3. Verify bd-2vh3 (squash) is filed

## Step: phase1-polecat-loop
Serial work on polecat execution:
1. gt-9nf: Fresh polecats only
2. gt-975: Molecule execution support
3. gt-8v8: Refuse uncommitted work
Then swarm: gt-e1y, gt-f8v, gt-eu9
Needs: phase0-beads-foundation

## Step: phase2-refinery
Serial work on refinery autonomy:
1. gt-5gkd: Refinery CLAUDE.md
2. gt-bj6f: Refinery context in gt prime
3. gt-0qki: Refinery-Witness protocol
Needs: phase1-polecat-loop

## Step: phase3-deacon
Health monitoring infrastructure:
1. gt-5af.4: Simplify daemon
2. gt-5af.7: Crew session patterns
3. gt-976: Crew lifecycle
Needs: phase2-refinery

## Step: phase4-code-review
Self-improvement flywheel:
1. Define mol-code-review (gt-fjvo)
2. Test on open MRs
3. Integrate with Refinery
Needs: phase3-deacon

## Step: phase5-polish
Demo readiness:
1. gt-b2hj: Find orphaned work
2. Doctor checks
3. Clean up open MRs
Needs: phase4-code-review

## Step: verify-flywheel
Success criteria:
- gt spawn works with molecules
- Refinery processes MRs autonomously
- mol-code-review runs on a PR
- bd cleanup --ephemeral works
Needs: phase5-polish

## 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 2: All agents healthy, 2 convoys tracking, gastown refinery processing 1 item


POLECAT_STARTED beads/alpha

Issue: bd-6sm6
Session: gt-beads-alpha


Digest: mol-deacon-patrol

Patrol cycle 11: Nominal


📋 Work Assignment: test sling pinned

Issue: gt-xdhg
Title: test sling pinned
Priority: P2
Type: task

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

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

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


Digest: mol-deacon-patrol

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


🤝 HANDOFF: Post-refactoring restart

## Context
Major refactoring completed this session:
1. Town mail now uses beads
2. .beads-wisp eliminated - wisps now in beads DB with ephemeral flag
3. Hooks stored in beads, not separate wisp files

## Session Work Done
- Implemented gt hook command (durability primitive)
- Fixed gt sling to hook+run (not restart)
- Updated gt handoff to accept bead arg
- Fixed gt mol status to check wisp hooks
- Comprehensive docs audit for hook/sling/handoff/nudge

## The Command Algebra
```
gt hook   = assign (durability)
gt nudge  = communicate
gt sling  = hook + nudge "start working"
gt handoff = hook + restart
```

## After Restart
1. Verify mail system works: gt mail inbox
2. Check mol status works with new beads-based hooks
3. Test gt hook <bead> -> gt mol status flow
4. Continue with Phase 2 work (gt-qvn7.2)


Deferred HOP schema additions (P2/P3)

Moved from beads bd-zt59 - out of scope for Beads today.

Deferred from bd-7pwh after review. Add when semantics are clearer and actually needed:

- assignee_ref: Structured EntityRef alongside string assignee
- work_type: 'mutex' vs 'open_competition' (everything is mutex in v0.1)
- crystallizes: bool for work that compounds vs evaporates (can derive from issue_type)
- cross_refs: URIs to beads in other repos (needs federation first)
- skill_vector: []float32 embeddings placeholder (YAGNI)

These can be added later without breaking changes (all optional fields).

Note: HOP-specific schema concerns belong in town HQ, not in the beads tool itself.


Digest: mol-deacon-patrol

Patrol cycle 6: 17 running, all healthy


Digest: mol-deacon-patrol

Cycle 19: Clean


SPAWN: nux starting on gt-3x0z.5

Polecat spawn notification.

Polecat: nux
Issue: gt-3x0z.5
Session: gt-gastown-nux
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-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: Quick cycle.


Digest: mol-deacon-patrol

Patrol 2: Town idle, all healthy, 2 convoys open


Digest: mol-deacon-patrol

Patrol cycle 21: All agents healthy, cleaned 7 stale locks, noted 3 diverged clones


Digest: mol-deacon-patrol

## Molecule Execution Summary

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

**Completed**: 9/9

---

### Steps

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

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

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

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

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

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

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

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

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

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

Decision point at end of patrol cycle:

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

If context is HIGH:
-...


bd compact --purge-tombstones: Clean up old deleted issues

## Problem

After aggressive tombstone deletion or normal operation over time, the database accumulates tombstones (soft-deleted issues) that are no longer needed. These:
- Bloat the database and JSONL
- Can cause hash ID collisions requiring longer IDs
- Slow down queries

## Solution

Add `bd compact --purge-tombstones` that safely removes tombstones:

1. Find all tombstones (issues with deleted_at set)
2. Check which tombstones have live OPEN issues depending on them
3. Delete deps from CLOSED issues to tombstones (historical, not needed)
4. Delete tombstones that have no remaining live deps
5. Clean up any orphaned labels/deps created by the deletion
6. Export to JSONL and commit

## Safety

- Never delete tombstones that open issues depend on
- Show preview of what will be deleted with --dry-run
- Require --force or confirmation for large deletions

## Example

```bash
bd compact --purge-tombstones --dry-run
# Would delete 1653 tombstones (22 kept due to open deps)

bd compact --purge-tombstones
# Deleted 1653 tombstones
```


Digest: mol-deacon-patrol

Patrol 2: routine, all healthy


Digest: mol-deacon-patrol

Cycle 272: All clear


Digest: mol-deacon-patrol

Patrol cycle 15: No messages, all healthy.


Digest: mol-deacon-patrol

Patrol 10: Auto


Digest: mol-deacon-patrol

Patrol 11: town idle, all healthy


Digest: mol-deacon-patrol

Patrol cycle 20: All quiet, 3 rigs healthy, handoff


Digest: mol-deacon-patrol

Patrol 5: 5 polecats working. All healthy.


Digest: mol-deacon-patrol

Patrol 12: All healthy, no inbox


Digest: mol-deacon-patrol

Patrol cycle 2: routine check, all agents healthy, no incidents


Digest: mol-deacon-patrol

Patrol 4: Routine.


Digest: mol-deacon-patrol

Patrol 20: Fixed orphan, all healthy. Handoff threshold reached.


Digest: mol-deacon-patrol

Patrol cycle 1: closed convoy hq-cv-c64t6 (tracked issue gt-01jpg completed), all agents healthy, ran doctor --fix (cleaned 1 orphan session, reset refinery branch to main)


Digest: mol-deacon-patrol

Patrol #10: routine, all healthy


Digest: mol-deacon-patrol

Patrol 11: Quiet. All healthy.


Digest: mol-deacon-patrol

Patrol cycle 12: All healthy


Digest: mol-deacon-patrol

Cycle 70: All healthy


Digest: mol-deacon-patrol

Patrol 3: Processed Mayor handoff, all healthy


Digest: mol-deacon-patrol

Patrol C31: All healthy, no callbacks, no orphans


POLECAT_STARTED gastown/furiosa

Issue: gt-vci
Session: gt-gastown-furiosa


Digest: mol-deacon-patrol

Patrol 5: Clean


Digest: mol-deacon-patrol

Patrol 174: All healthy, nux polecat started


Digest: mol-deacon-patrol

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


Phase 3: Priming observability and guardrails

Add debugging tools and drift prevention.

Implementation:
1. gt prime --dry-run: Show what would be injected without injecting
2. gt prime --state: Show detected session state only (normal/post-handoff/crash/autonomous)
3. gt prime --explain: Show why each section was included
4. gt doctor warning: AGENTS.md > 20 lines
5. gt doctor warning: CLAUDE.md differs from rendered template
6. gt doctor --fix: Regenerate static files from templates

This makes the priming system debuggable and prevents future drift.


Digest: mol-deacon-patrol

Patrol complete: inbox empty, gates clear, no convoys, all agents healthy, no abandoned work, no orphan sessions, no plugins to run. Patrol count now 1.


LIFECYCLE: gastown-crew-max requesting cycle

Lifecycle request from gastown-crew-max.

Action: cycle
Time: 2025-12-21T01:23:01-08:00

Please verify state and execute lifecycle action.


Digest: mol-deacon-patrol

Cycle 14: Quiet


Digest: mol-deacon-patrol

Patrol 1: All agents healthy, no callbacks, no orphans, doctor 24/28 passed


Digest: mol-deacon-patrol

Patrol cycle 32: Routine


Digest: mol-deacon-patrol

Patrol 10: All healthy


Digest: mol-deacon-patrol

Patrol cycle 15: All quiet


Digest: mol-deacon-patrol

Patrol cycle 14: All healthy


Digest: mol-deacon-patrol

Patrol 9: All healthy.


Digest: mol-deacon-patrol

Patrol 18: Town quiet


Digest: mol-deacon-patrol

Patrol complete: all agents healthy, no pending callbacks, no orphaned work, clone-divergence noted (witness responsibility)


New MR: gt-rana.2

Merge request gt-zbx5 ready:
- branch: polecat/nux
- content: Daemon attachment detection for patrol system

Please process.


Digest: mol-deacon-patrol

Patrol 11: Routine, all healthy


Digest: mol-deacon-patrol

Patrol cycle 4: all quiet


Digest: mol-deacon-patrol

Patrol 15: Healthy


Digest: mol-deacon-patrol

Patrol 8: All agents healthy, no callbacks, no orphans


Digest: mol-deacon-patrol

Patrol 2: all healthy, no incidents


Digest: mol-deacon-patrol

Cycle 9: stable


Digest: mol-deacon-patrol

Patrol 2: all healthy, no issues


Digest: mol-deacon-patrol

Patrol 91: Routine


Digest: mol-deacon-patrol

Patrol 18: routine, all healthy


Digest: mol-deacon-patrol

C120: All healthy, 20 cycles complete


🤝 HANDOFF: Epic vs Molecule distinction needed

## Context

Previous session added Dependency Trap warning to all role templates (pushed).

## Pending Clarification: docs/beads-data-plane.md

The doc conflates epics and molecules. Needs revision to clarify:

**Epics** = One molecular *shape* (a TODO list pattern)
- Tree structure: parent + child issues
- Can nest (child epics model work trees)
- Think: linear decomposition

**Molecules** = Arbitrary work *graphs*
- Can CONTAIN epics
- Multiple shapes: TODO List (epic), Christmas Ornament (Witness patrol), compound/nested
- Can model complex projects with dependencies, not just trees

## The Golden Rule (needs chemistry name)

**A bead should be sized ≤ one session of work.**

If larger → decompose.

Violation triggers "Sad Path" in session lifecycle:
- Oversized Bead Protocol
- Mid-step handoff complexities
- Partial implementation vs decomposition decisions

Suggested chemistry names:
- **Single-Bond Principle** (already in session-lifecycle.md)
- **Atomic Bead Rule**
- **Molar Limit** (one session = one mol of work?)

## Files to Review

- docs/beads-data-plane.md (epic/molecule conflation)
- docs/session-lifecycle.md (has Single-Bond Principle)
- ~/gt/beads/crew/dave/CLAUDE.md (has good dependency guidance)

## Task

Revise beads-data-plane.md to properly distinguish molecular shapes from the molecule abstraction itself.


🤝 HANDOFF: Christmas Launch - Gated on Beads

## Christmas Launch Status

### Completed This Session
- **gt-xp2s**: Identity collision fix (lock mechanism with prevention/detection/correction)
- Cleaned stale handoff messages

### Current Gate
**gt-3x0z.9** (mol-deacon-patrol uses ephemeral) is in_progress but blocked on:
- **bd-kwjh.3** (`bd mol bond --ephemeral`) - Dave working on this in Beads

### Phase Status
| Epic | Status |
|------|--------|
| gt-3x0z (Wisp) | Phases 1-3 done, Phase 4 gated |
| gt-rana (Patrol) | Phase 1 done (4/4 closed) |
| bd-kwjh (Beads wisp) | .3 in_progress (Dave) |

### When Unblocked
Once bd-kwjh.3 ships:
1. Complete gt-3x0z.9 (deacon patrol uses ephemeral)
2. Then gt-3x0z.10+ (witness/refinery patrols)

### Commands
```bash
bd show bd-kwjh      # Beads wisp epic (Dave's work)
bd show gt-3x0z.9    # Current blocker
bd show gt-ngpz      # Christmas plan
```


Incoming: 13-task swarm

Witness is spawning polecats for 13 tasks. Expect PRs for:

Test coverage: bd-6sm6, bd-fx7v, bd-llfl, bd-m8ro, bd-n386, bd-sh4c
Bug fixes: bd-de6, bd-yck, bd-indn
Code quality: bd-y2v, bd-dhza, bd-05a8
Feature: bd-0fvq

Please process PRs as they arrive. All are independent - merge order doesn't matter.


Digest: mol-deacon-patrol

Patrol 99: Routine


Digest: mol-deacon-patrol

Patrol 2: All healthy, routine cycle.


Digest: mol-deacon-patrol

Cycle 11


Digest: mol-deacon-patrol

Cycle 270: All clear, gastown MQ processed 6 items


Digest: mol-deacon-patrol

Patrol 20: Routine


Digest: mol-deacon-patrol

Patrol 16: Routine, all healthy


Digest: mol-deacon-patrol

Patrol complete: checked inbox, all agents healthy, cleaned 54 stale wisps


Digest: mol-deacon-patrol

Cycle 30: Routine


Digest: mol-deacon-patrol

Patrol cycle 15: Healthy.


Digest: mol-deacon-patrol

Patrol 2: town idle, all agents healthy, no issues


Digest: mol-deacon-patrol

Patrol 18: OK


Digest: mol-deacon-patrol

Patrol C69: routine, all healthy


Digest: mol-deacon-patrol

Patrol cycle 105: All healthy


Digest: mol-deacon-patrol

Patrol cycle 4: All agents healthy (3W/3R), routine


Digest: mol-deacon-patrol

Patrol 23: All healthy


Digest: mol-deacon-patrol

Patrol cycle 5 complete: all clear. Patrol count 5.


Dynamic priming subsystem improvements

Eliminate static AGENTS.md/CLAUDE.md files in favor of fully dynamic priming via gt prime. See docs/priming-subsystem.md for design.


POLECAT_DONE Logger

Exit: COMPLETED
Issue: bd-u2sc.4
MR: bd-s1pz
Branch: polecat/Logger


Digest: mol-deacon-patrol

Patrol C59: all healthy


POLECAT_STARTED beads/valkyrie

Issue: bd-05a8
Session: gt-beads-valkyrie


📋 Work Assignment: bd template commands fail with daemon mode

Issue: bd-indn
Title: bd template commands fail with daemon mode
Priority: P2
Type: bug

Description:
The `bd template show` and `bd template instantiate` commands fail with 'Error loading template: no database connection' when daemon is running.

**Reproduction:**
```bash
bd daemon --start
bd template show bd-qqc  # Error: no database connection
bd template show bd-qqc --no-daemon  # Works
```

**Expected:** Template commands should work with daemon like other commands.

**Workaround:** Use `--no-daemon` flag.

**Location:** Likely in cmd/bd/template.go - daemon RPC path not implemented for template operations.

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

Cycle 269: All clear


Digest: mol-deacon-patrol

Patrol 7: All healthy


📋 Work Assignment: Enhanced polecat decommission prompting

Issue: gt-sd6
Title: Enhanced polecat decommission prompting
Priority: P1
Type: task

Description:
Add decommission checklist to polecat AGENTS.md.template. Make crystal clear: verify ALL before signaling done.

## Checklist for AGENTS.md.template

```markdown
## Decommission Checklist

**CRITICAL**: Before signaling done, you MUST complete this checklist.
The Witness will verify each item and bounce you back if dirty.

### Pre-Done Verification

```bash
# 1. Git status - must be clean
git status
# Expected: "nothing to commit, working tree clean"

# 2. Stash list - must be empty
git stash list
# Expected: (empty output)

# 3. Beads sync - must be up to date
bd sync --status
# Expected: "Up to date" or "Nothing to sync"

# 4. Branch merged - your work must be on main
git log main --oneline -1
git log HEAD --oneline -1
# Expected: Same commit
```

### If Any Check Fails

- **Uncommitted changes**: Commit them or discard if unnecessary
- **Stashes**: Pop and commit, or drop if obsolete
- **Beads out of sync**: Run `bd sync`
- **Branch not merged**: Complete the merge workflow

### Signaling Done

Only after ALL checks pass:

```bash
bd close <issue-id>
bd sync
town mail send <rig>/witness -s "Work Complete" -m "Issue <id> done."
```
```

## Implementation

Add to AGENTS.md.template in the polecat prompting section.

## 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 72: All healthy. No incidents.


Digest: mol-deacon-patrol

Patrol cycle 114: All healthy


Digest: mol-deacon-patrol

Patrol 12 complete: all healthy


🤝 HANDOFF: Cleanup + Cross-Project Deps Design

## Session Summary

### Accomplished

1. **gt-47tq**: Simplified spawn.go to use bd mol run (95→50 lines)

2. **Cross-Project Dependencies Design** (ultrathought from first principles)
   - Capability-based: provides:X labels, not issue IDs
   - bd ship command with protected namespace
   - external:project:capability in blocked_by
   - Parked molecules = in_progress + no assignee + blocked step
   - Design doc: gastown/docs/cross-project-deps.md

3. **Stale Branch Cleanup**
   - Deleted 23 polecat branches from origin
   - Fixed polecat template: removed git push, use merge queue only
   - Removed orphan polecat (furiosa)

4. **Filed Issues**
   - Beads: bd-h807 epic (ship, external:, config, ready resolution)
   - Gas Town: gt-hbg5 epic (park, spawn --continue, patrol)
   - gt-upom: Witness patrol for idle orphan cleanup

### Wave Status (Christmas Launch)
- gt-3x0z: Phase 1-3 complete, Phase 4.1 (gt-3x0z.9) in_progress but unowned
- gt-rana: Phase 1 complete (4/4)
- 0 polecats active - ready to spawn

### Next Steps
1. Spawn polecat on gt-3x0z.9 (mol-deacon-patrol uses ephemeral)
2. Or pick from tech debt (gt-5n2f has 7 remaining)
3. Beads work (Dave): bd-h807 children for cross-project deps

### Commands
- bd show gt-3x0z.9 - Current blocker
- bd show gt-ngpz - Christmas plan
- gt spawn gastown --issue gt-3x0z.9 --create - Resume wave


🤝 HANDOFF: Swarm session complete, ready for next batch

## Completed This Session

### Activity Feed TUI
- Explored Beads activity/molecule tracking
- Created design doc: history/activity-feed-tui-design.md
- Filed epic gt-rivr with 6 subtasks
- Spawned 3 beads polecats for API work (bd-gqxd, bd-l13p, bd-0oqz) - all closed

### Polecat Template Cleanup
- Filed epic gt-t9u7 with 9 subtasks - all closed by gastown/furiosa

### Gastown Swarm (5 polecats)
- gt-o3is: closed (root-caused to beads, filed bd-phtv)
- gt-vmk7: REOPENED - nux closed without implementing
- gt-ci84, gt-h1n5, gt-qz2l: closed, filed P2 reviews

### Bugs Filed
- gt-u2vg: gt spawn --issue should auto-attach mol-polecat-work

### Next Steps
1. Clean up town (no active polecats)
2. Reboot witnesses/refineries
3. Ready for next swarm batch

### Reviews Pending
- gt-dw6v: Deacon wisp storage
- gt-8bes: Witness patrol template
- gt-0b1c: Refinery patrol template


POLECAT_STARTED beads/nux

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


Digest: mol-deacon-patrol

Patrol #13: All clear


Digest: mol-deacon-patrol

Patrol 31: healthy


gt rig status shows polecats with dead tmux sessions

When a polecat's tmux session dies (or is killed externally), gt rig status still shows the polecat as existing. The status check should verify the tmux session exists and mark/remove orphaned polecats.

Repro: furiosa showed as 'done' in rig status but had no tmux session. Had to manually nuke.

Fix: In polecat status detection, verify tmux session exists. If not, either auto-cleanup or show as 'orphaned'.


Daemon heartbeat too slow for stuck agent detection (10 min)

The daemon's recoveryHeartbeatInterval is set to 10 MINUTES (daemon.go:134).

This means if an agent gets stuck, it can waste up to 10 minutes before Boot is spawned to triage. Today the Deacon was stuck for 13+ minutes partly because:
1. 10-minute gap between daemon heartbeats
2. Boot was spawned but never completed its triage cycle

The 10-minute interval was designed as a 'safety net' assuming normal wake comes from feed subscription (bd activity --follow). But when agents get stuck in loops (like the jq error today), feed-based wake doesn't help.

Suggested fix: Reduce heartbeat to 2-3 minutes, or add a separate fast-path stuck-detection check.


Digest: mol-deacon-patrol

Patrol 11: All healthy. Doctor warns: gt-boot orphan (false positive), 8 stale config files. NO --fix run per Overseer directive.


🤝 HANDOFF: Wisp & Patrol implementation

## Next Work: Wisp Molecules & Patrol System

Work on these epics in order:

### 1. gt-3x0z: Wisp Molecules (Transient Molecule Storage)
Check `bd show gt-3x0z` for subtasks. Key items:
- .beads-wisp/ directory support
- Ephemeral molecule bonding (--wisp flag)
- Squash/burn lifecycle

### 2. gt-rana: Patrol System
After wisps are working, implement patrol runner.

### Context
- Just refactored witness to REMOVE embedded molecule logic (503 lines)
- Molecule management belongs in bd mol commands, not Go code
- See wisp-architecture.md for design spec
- Dave working on molecule operators in Beads

### Phase Status
- Phase 0: ✅ Complete
- Phase 1: ✅ Complete (gt-8v8, gt-9nf, gt-975 all closed)
- Phase 2+: Needs wisp support first

Run `bd show gt-3x0z` and `bd ready` to find available work.

Superseded by patrol formula work. Critical bugs filed (bd-hr39, bd-j4cr). Polish tasks handed off.


Digest: mol-deacon-patrol

Patrol complete: inbox clear, health OK, 1 orphan session cleaned (gt-boot)


Digest: mol-deacon-patrol

Patrol 9: All healthy, no inbox


Digest: mol-deacon-patrol

Patrol cycle 1: processed handoff, all agents healthy, cleaned 6 stale locks and 1 orphan session


Digest: mol-deacon-patrol

Patrol #4: routine, all healthy


Digest: mol-deacon-patrol

Patrol 89: All healthy. No incidents.


POLECAT_DONE max

Exit: COMPLETED
Issue: bd-m8ro
MR: bd-hlyr
Branch: polecat/max


Digest: mol-deacon-patrol

Patrol complete: 10 quiet cycles, all agents healthy, handoff


Engineer in a Box

Full workflow from design to merge.

## Step: design
Think carefully about architecture. Consider:
- Existing patterns in the codebase
- Trade-offs between approaches
- Testability and maintainability

Write a brief design summary before proceeding.

## Step: implement
Write the code. Follow codebase conventions.
Needs: design

## Step: review
Self-review the changes. Look for:
- Bugs and edge cases
- Style issues
- Missing error handling
Needs: implement

## Step: test
Write and run tests. Cover happy path and edge cases.
Fix any failures before proceeding.
Needs: implement

## Step: submit
Submit for merge via refinery.
Needs: review, test


🤝 HANDOFF: Ready to work on bd-ul59

## Pinned Work

bd-ul59: Update molecular chemistry docs with discoveries (P2)
- Pinned via `bd pin` - shows in `bd hook`
- NOT in gt mol layer (gt sling doesn't fully attach yet)

## Key Discoveries to Document

From previous session research:
1. Molecules ARE epics (protos just have template label)
2. Staleness = orphaned + blocking (graph pressure)
3. Parallelism is default; sequential opt-in via deps
4. progress.Completed/Total computed on-demand

## Next Steps

Run `bd show bd-ul59` and update the molecular chemistry docs accordingly.


Digest: mol-deacon-patrol

Patrol cycle 2: All healthy


Digest: mol-deacon-patrol

Patrol cycle: all agents healthy, queues empty


Digest: mol-deacon-patrol

Patrol 3 complete: all agents healthy


Digest: mol-deacon-patrol

Patrol cycle 9: Routine, all healthy


Digest: mol-deacon-patrol

Patrol 12: All healthy.


Digest: mol-deacon-patrol

Patrol 20: all clear, handoff threshold reached


Digest: mol-deacon-patrol

Patrol cycle 7: All agents healthy


Digest: mol-deacon-patrol

Patrol 73: All healthy. No incidents.


Digest: mol-deacon-patrol

Patrol 2: all healthy, MQ beads:8 gastown:13


P1 Epic: Dynamic Molecule Bonding (bd-xo1o)

Dave,

I've filed a critical epic for Beads: bd-xo1o - Dynamic Molecule Bonding.

This enables the 'Christmas Ornament' pattern for patrol molecules where a Witness
can dynamically spawn inspection arms per-polecat at runtime.

## The Vision

Instead of parsing agent logs, users see structured work state:

    [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

This is the activity feed - work state as real-time data, not agent rambling.

## Children (4 tasks)

1. bd-xo1o.1: bd mol bond with variable substitution (P1)
2. bd-xo1o.2: WaitsFor directive for fanout gates (P1)
3. bd-xo1o.3: bd activity real-time state feed (P1)
4. bd-xo1o.4: Parallel step detection (P2)

## Why This Matters

This is foundational for Gas Town's patrol system. mol-witness-patrol needs to
monitor N polecats where N varies at runtime. The current linear molecule can't
express this. With dynamic bonding, the molecule grows arms as polecats are
discovered.

The activity feed transforms debugging from 'read the logs' to 'watch the feed'.
It's the UX breakthrough that makes molecular work visible and satisfying.

See the epic description for full technical details.

- Mayor


Digest: mol-deacon-patrol

Patrol 1: All systems healthy, cleaned 1 stale lock, 4 polecats working


Digest: mol-deacon-patrol

Patrol 10: quiet


Digest: mol-deacon-patrol

Cycle 10: stable


Digest: mol-deacon-patrol

Patrol #18: routine


Digest: mol-deacon-patrol

Patrol #14: Town now IDLE. All active polecat work completed. 3 convoys closed this session.


Digest: mol-deacon-patrol

Patrol 3: Routine, no incidents


Digest: mol-deacon-patrol

Patrol: checked health, force-killed wyvern/refinery (unresponsive), ran doctor --fix. 16 sessions healthy.


Digest: mol-deacon-patrol

Patrol 20: final cycle, all healthy


Digest: mol-deacon-patrol

Patrol 20 - final


POLECAT_STARTED Logger

Issue: bd-u2sc.4
Session: gt-beads-Logger


Digest: mol-deacon-patrol

Cycle 79: All healthy


Digest: mol-deacon-patrol

Patrol 6: Nominal


Digest: mol-deacon-patrol

Patrol cycle 11: quick cycle, no issues


Digest: mol-deacon-patrol

Patrol cycle 2: routine, all agents healthy


SPAWN: nux starting on gt-5wb7

Polecat spawn notification.

Polecat: nux
Issue: gt-5wb7
Session: gt-gastown-nux
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-nux "Check your inbox with 'gt mail inbox' and begin working." Enter

The polecat has a work assignment in its inbox.


🤝 HANDOFF: Fix gt-tocb: handoff path parsing

User discovered that 'gt handoff gastown/crew/max' fails with 'unknown session type'. The resolveRoleToSession function in internal/cmd/handoff.go needs to be enhanced to parse full paths like '<rig>/crew/<name>' and '<rig>/<role>' into tmux session names. Created gt-tocb for this. All the gt handoff standardization work (gt-yt6g) is complete and pushed.


Digest: mol-deacon-patrol

Patrol 3: all healthy, idle


Digest: mol-deacon-patrol

Patrol 5: All healthy.


Digest: mol-deacon-patrol

Cycle 277: All clear


Digest: mol-deacon-patrol

Patrol 1: All agents healthy (gastown, beads witnesses/refineries running). 3 convoys active (PR#970, PR#975, docs). No callbacks, no orphans, no stale hooks.


Digest: mol-deacon-patrol

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


Digest: mol-deacon-patrol

Patrol C41: All healthy


Digest: mol-deacon-patrol

Patrol cycle 5: routine check


WORK_DONE: hq-0cgd3

Exit: COMPLETED
Issue: hq-0cgd3
MR: gt-svz4f
Branch: polecat/rictus-mk7d3w9l


Digest: mol-deacon-patrol

Patrol cycle 14: All quiet


Digest: mol-deacon-patrol

Patrol 1: restarted wyvern refinery, cleaned orphan sessions, all agents healthy


Digest: mol-deacon-patrol

Patrol 20: routine


📋 Work Assignment: Phase 2.3: Polecat CLAUDE.md molecule workflow protocol

Issue: gt-3x0z.6
Title: Phase 2.3: Polecat CLAUDE.md molecule workflow protocol
Priority: P1
Type: task

Description:
Update polecat prompting for molecule-based work.

## CLAUDE.md Updates

Add section on molecule workflow:

```markdown
## Molecule Workflow

When assigned a molecule (check gt prime output):

1. Follow molecule steps in order
2. Mark steps complete: bd mol step complete <step-id>
3. Before signaling done:
   a. Generate summary of work performed
   b. Run: bd squash <molecule-root> --summary "<your summary>"
4. Then signal done as normal

### Summary Guidelines

Your summary should include:
- What was the task?
- What did you do?
- What was the outcome?
- Any issues or follow-ups?

Keep it to 2-4 sentences. This becomes the permanent record.
```

## 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 8: Auto


Digest: mol-deacon-patrol

Patrol 1: Cleaned 1195 stale wisps. 4 polecats working. All witnesses/refineries healthy. No issues.


Digest: mol-deacon-patrol

Patrol 15: routine, all healthy


POLECAT_STARTED delta

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


🤝 HANDOFF: GH#692 epic - bd-u2sc.3 and bd-u2sc.4 remaining

## Context

Continuing GH#692 code quality epic (bd-u2sc). Two tasks completed, two remaining.

## Work Completed This Session

- **bd-u2sc.1** [CLOSED] - Replaced map[string]interface{} with typed JSON response structs
  - 15 typed structs added across 4 files
  - compact.go, cleanup.go, daemons.go, daemon_lifecycle.go
  - Commit: 4c380755

## Previously Completed

- **bd-u2sc.2** [CLOSED] - Migrated sort.Slice to slices.SortFunc (16 files)

## Remaining Epic Work (bd-u2sc)

1. **bd-u2sc.3** [P3] - Split large cmd/bd files into logical modules
   - sync.go (2201 lines)
   - init.go (1742 lines)
   - show.go (1380 lines)
   - Larger refactor, consider breaking into sub-tasks

2. **bd-u2sc.4** [P3] - Introduce slog for structured daemon logging
   - Replace fmt.Printf-style logging with slog
   - More focused task

## Notes

- 3 map[string]interface{} remain in compact.go for RPC args and storage updates
  (internal APIs, would require interface changes)
- All tests passing
- Original issue: https://github.com/steveyegge/beads/issues/692

## Commands

```bash
bd show bd-u2sc           # View epic
bd update bd-u2sc.3 --status in_progress  # Start file splitting
bd update bd-u2sc.4 --status in_progress  # Start slog work
```


Digest: mol-deacon-patrol

Patrol 2: All agents healthy. No inbox messages. Cleaned gt-boot orphan session. Witnesses/refineries running (wyvern:0, beads:8, gastown:13 pending MQ items).


Digest: mol-deacon-patrol

Patrol 14: routine


Digest: mol-deacon-patrol

Patrol 16: all clear


Digest: mol-deacon-patrol

Patrol cycle 15: Routine


Digest: mol-deacon-patrol

Patrol 2: All clear, agents healthy


Digest: mol-deacon-patrol

Patrol cycle 1: Inbox clear, 3 rigs healthy, 1 orphan session cleaned


Dog: testclean

location:deacon/dogs/testclean rig:town role_type:dog was:agent


Digest: mol-deacon-patrol

Patrol complete: all agents healthy, 2 convoys in progress, no incidents


POLECAT_STARTED nux

Issue: gt-lnji
Session: gt-gastown-nux


Digest: mol-deacon-patrol

Patrol cycle 18: No messages, all healthy.


Digest: mol-deacon-patrol

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


POLECAT_STARTED beads/keeper

Issue: bd-g9eu
Session: gt-beads-keeper


Digest: mol-deacon-patrol

Patrol 55: Stable


SPAWN: capable starting on bd-bqcc

Polecat spawn notification.

Polecat: capable
Issue: bd-bqcc
Session: gt-beads-capable
Spawned by: beads/crew/dave

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.


BUG: Deacon can spin indefinitely on errors without cycling

The Deacon got stuck on a jq error and 'shimmied' for 13+ minutes without making progress. During this time, no patrol cycles ran, no health checks happened.

## Root Cause
The Deacon patrol formula (mol-deacon-patrol.formula.toml) tells Claude to manually track health state in context memory, but:
1. Context memory is ephemeral - lost on cycle/restart
2. The Go code has proper persistent tooling that's NOT being used:
   - `gt deacon health-check <agent>` - tracks consecutive failures, returns exit code 2 when force-kill needed
   - `gt deacon health-state` - shows persistent state (currently empty - never used)

## Who Watches the Watchman?
Boot has one-time stall detection (`gt peek deacon/` looking for '> Try' prompt) but nothing CONTINUOUSLY watches the Deacon during runtime.

## Fix Required
1. Update mol-deacon-patrol health-scan step to use `gt deacon health-check` instead of raw `gt nudge`
2. Add a continuous watchdog for the Deacon itself (Boot daemon? Witness ping check?)
3. Ensure health-check-state.json is actually populated and used

Fixed Deacon spin issue with three changes:
1. Updated mol-deacon-patrol health-scan step to use persistent gt deacon health-check command instead of ephemeral context memory tracking
2. Added heartbeat checking to Boot degraded triage - detects and handles stuck Deacon (>15min stale nudges, >30min stale restarts)
3. Added checkDeaconHeartbeat to daemon heartbeat cycle as belt-and-suspenders fallback


POLECAT_STARTED gastown/tracer

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


Digest: mol-deacon-patrol

Patrol 7: quiet, preparing handoff


Digest: mol-deacon-patrol

Cycle 7: Clean


Digest: mol-deacon-patrol

Patrol complete: all agents healthy, cleaned 3 stale locks + 1 orphan session, convoy hq-cv-mp7cm still open


Digest: mol-deacon-patrol

Patrol 1: Cleaned 203 wisps, fixed 4 stale locks, all 6 agents healthy


Digest: mol-deacon-patrol

Patrol 20: healthy - handoff threshold


Digest: mol-deacon-patrol

Patrol 2: Quick cycle, all healthy, no incidents


🤝 HANDOFF: GH#692 refactoring work ready for implementation

## Context

Analyzed GitHub issue #692 (rsnodgrass's refactoring suggestions) and created actionable beads issues. Had a good design discussion about completion triggers - concluded that molecules handle this better than lifecycle hooks.

## Work Created

### Epic: bd-u2sc (external_ref: gh-692)
GH#692: Code quality and refactoring improvements

Children (all ready to work):
- bd-u2sc.1 [P2] - Replace map[string]interface{} with typed JSON response structs
  - ~20 instances in compact.go, cleanup.go, daemons.go, daemon_lifecycle.go

- bd-u2sc.2 [P3] - Migrate sort.Slice to slices.SortFunc
  - ~15 instances across cmd/bd/*.go
  - Safe, mechanical refactor - GOOD QUICK WIN

- bd-u2sc.3 [P3] - Split large cmd/bd files into logical modules
  - sync.go (2201 lines), init.go (1742), show.go (1380)

- bd-u2sc.4 [P3] - Introduce slog for structured daemon logging

### Separate Feature: bd-bqcc [P2]
Consolidate maintenance commands into bd doctor --fix

## Key Design Decision

Discussed how to trigger 'close GH#692 when epic completes':
- Hooks escape the beads data plane - not auditable, not resumable
- Molecule tail steps are better - everything in beads, delegatable to haiku
- Closed bd-y0fj (lifecycle hooks) as molecules already cover this

## Recommended Next Steps

1. Quick win: Start with bd-u2sc.2 (slices.SortFunc migration)
2. Then: bd-u2sc.1 (typed JSON structs)
3. Later: bd-u2sc.3, bd-u2sc.4, bd-bqcc

## Commands

bd show bd-u2sc
bd update bd-u2sc.2 --status in_progress
grep -rn 'sort.Slice' cmd/bd/*.go


Digest: mol-deacon-patrol

Patrol 4: Quiet.


Digest: mol-deacon-patrol

Patrol 2: all agents healthy, 2 convoys active


Digest: mol-deacon-patrol

Patrol 1: All agents healthy, no callbacks, no issues


Digest: mol-deacon-patrol

Patrol 1: Inbox clear, health OK, nux working, 3 convoys active


Digest: mol-deacon-patrol

Patrol #1: burned 20 stale wisps, all agents healthy, no lifecycle events


Digest: mol-deacon-patrol

Patrol 13: Nominal


🤝 HANDOFF: Chemistry Docs Complete - Implementation Ready

## Session Summary

Completed UX design session with Overseer for molecular chemistry metaphor.

### Created Documentation

1. docs/molecular-chemistry.md - Comprehensive guide (500+ lines)
   - Three phases: Proto (solid), Mol (liquid), Wisp (vapor)
   - Operators: pour, wisp, bond, squash, burn, distill
   - Agent attachment: hooks and pins

2. docs/chemistry-design-changes.md - Implementation roadmap
   - New commands: bd pour, bd wisp, bd pin, bd hook
   - Flag changes: --persistent to --pour

### Key Design Decisions

- bd pour = instantiate proto as mol (liquid)
- bd wisp = instantiate proto as wisp (vapor)
- bd pin = attach mol to agent hook
- --pour flag overrides phase to liquid

### Remaining for gt-3x0z.9

1. Update daemon: Remove checkDeaconAttachment - Deacon self-spawns wisps
2. Update deacon.md.tmpl: Use bd wisp mol-deacon-patrol pattern

### Blocked On Beads

Dave needs to implement: bd pour, bd wisp, bd pin, --pour flag on bond

### Files Pushed

- docs/molecular-chemistry.md (new)
- docs/chemistry-design-changes.md (new)


📋 Work Assignment: Enrich MutationEvent with title and assignee

Issue: bd-gqxd
Title: Enrich MutationEvent with title and assignee
Priority: P2
Type: feature

Description:
Current MutationEvent only has IssueID, no context. Add Title and Assignee fields so activity feeds can display meaningful info without extra lookups. Emit these fields when creating mutation events in server_core.go.

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

Cycle 13


POLECAT_STARTED mike

Issue: bd-0fvq
Session: gt-beads-mike


Dog: testdog3


Digest: mol-deacon-patrol

Patrol 117: All healthy.


Digest: mol-deacon-patrol

Patrol 94: all healthy


Digest: mol-deacon-patrol

Patrol 2: Quick cycle - no callbacks, all clear.


SPAWN: rictus starting on gt-3x0z.9

Polecat spawn notification.

Polecat: rictus
Issue: gt-3x0z.9
Session: gt-gastown-rictus
Spawned by: gastown/polecats/furiosa

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

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

The polecat has a work assignment in its inbox.


POLECAT_DONE slit

Exit: COMPLETED
Issue: gt-ci84
MR: gt-fuqx
Branch: polecat/slit


Digest: mol-deacon-patrol

Patrol 20: all healthy, session complete


Digest: mol-deacon-patrol

Patrol #1: closed 2 convoys (PR#970, PR#980), all agents healthy, cleaned gt-boot orphan


Digest: mol-deacon-patrol

Patrol cycle 5: All healthy


Digest: mol-deacon-patrol

Patrol #6: routine


Digest: mol-deacon-patrol

Patrol 17: Town quiet


Digest: mol-deacon-patrol

Cycle 271: All clear


Digest: mol-deacon-patrol

Patrol 15: Quiet. All healthy.


Digest: mol-deacon-patrol

Patrol 1: healthy witnesses/refineries, killed gt-boot orphan, all rigs running


Digest: mol-deacon-patrol

Patrol #9: routine


Digest: mol-deacon-patrol

Patrol 1: All witnesses running, gastown refinery active (7 pending), wyvern refinery stopped (dormant rig), cleaned 5 stale polecat locks


Digest: mol-deacon-patrol

Patrol cycle 15: All healthy, gastown monitoring 2 polecats


Digest: mol-deacon-patrol

Patrol 89: all healthy


📋 Work Assignment: gt rig add / gt doctor: patrol awareness and wiring

Issue: gt-7923
Title: gt rig add / gt doctor: patrol awareness and wiring
Priority: P1
Type: feature

Description:
## Problem

When a rig is installed or audited, we need to ensure all built-in patrols and role hooks are properly wired up.

## gt rig add Changes

When adding a rig, automatically:

1. **Create patrol molecules** for each role:
   - mol-deacon-patrol (town-level)
   - mol-witness-patrol (per-rig)
   - mol-refinery-patrol (per-rig)

2. **Set up hooks** that trigger patrols:
   - Deacon: daemon timer / heartbeat
   - Witness: daemon timer / polecat lifecycle events
   - Refinery: MR submission events / daemon timer

3. **Configure daemon** to manage these patrols:
   - Register patrol molecules in daemon config
   - Set up respawn behavior for each role

4. **Create plugin directories**:
   - ~/gt/plugins/ (town-level)
   - <rig>/plugins/ (rig-level, if needed)

## gt doctor Changes

Add patrol health checks:

### patrol-molecules-exist
- Verify mol-deacon-patrol, mol-witness-patrol, mol-refinery-patrol exist
- Check they parse correctly (valid steps, dependencies)

### patrol-hooks-wired
- Verify hooks trigger patrol execution
- Check daemon is configured to manage patrols

### patrol-not-stuck
- Detect wisps that have been in-progress too long
- Flag orphaned patrol molecules (no active session)

### patrol-plugins-accessible
- Verify plugin directories exist and are readable
- Check plugin frontmatter parses correctly

### patrol-roles-have-prompts
- Verify prompts/roles/*.md exist for each role
- Check they reference the correct patrol molecule

## Auto-fix

gt doctor --fix can:
- Create missing patrol molecules
- Wire up missing hooks
- Create plugin directories
- NOT restart stuck patrols (needs human decision)

## Related
- gt-7920 (mol-refinery-patrol)
- gt-7921 (await-work and plugin-run)
- docs/wisp-architecture.md

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

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

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


POLECAT_STARTED echo

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


MR Ready: Compactor (bd-thgk)

Compactor completed. Compact tests improved. Branch: polecat/Compactor ready for merge.


Digest: mol-deacon-patrol

Patrol 1: inbox empty, gates/pending/convoys checked, health OK (3 witnesses + 2 refineries running), cleaned 4 stale locks, no orphans


Digest: mol-deacon-patrol

Patrol 6: closed 3 convoys (PRs #42, #51, #52), cleaned 5 stale locks, all agents healthy


📋 Work Assignment: Phase 1.4: Basic patrol runner in Deacon

Issue: gt-rana.4
Title: Phase 1.4: Basic patrol runner in Deacon
Priority: P1
Type: task

Description:
Deacon CLAUDE.md and prime context for patrol execution.

## Deacon Context
- Update Deacon CLAUDE.md with patrol instructions
- On wake: check pinned bead for attachment
- If attached: resume molecule from current step
- Execute steps, close each when done
- On final step: burn molecule, go naked

## gt prime Enhancement
- Detect if agent has attached molecule
- Show molecule progress in prime output
- Include patrol-specific instructions

Depends: gt-rana.3

## 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 cycle 3: Routine, all healthy


POLECAT_DONE rictus

Exit: COMPLETED
Issue: gt-7923
MR: gt-xnzp
Branch: polecat/rictus


Digest: mol-deacon-patrol

Patrol 2: Nominal


Digest: mol-deacon-patrol

Patrol 87: quiet


Digest: mol-deacon-patrol

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


Digest: mol-deacon-patrol

Patrol 10: All healthy, beads MQ:5, gastown MQ:1


🧬 Molecule: mol-polecat-work (step 1/4)

Issue: gt-mol-c68
Title: mol-polecat-work
Priority: P2
Type: epic

Description:
Full polecat lifecycle from assignment to decommission.

This proto enables nondeterministic idempotence for polecat work. A polecat that crashes after any step can restart, read its molecule state, and continue from the last completed step. No work is lost.

## Variables

| Variable | Required | Description |
|----------|----------|-------------|
| issue | Yes | The source issue ID being worked on |

## Molecule Workflow
You are working on step 1 of 4 in molecule mol-polecat-work.
Molecule root: gt-mol-c68

After completing this step:
1. Run `bd close <step-id>`
2. Run `bd ready --parent gt-mol-c68` to find next ready steps
3. If more steps are ready, continue working on them
4. When all steps are done, run `gt done` to signal completion

## 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. Check `bd ready --parent gt-mol-c68` for more steps
5. Repeat steps 2-4 for each ready step
6. When all steps done: run `bd sync`, then `gt done`

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


Digest: mol-deacon-patrol

Patrol cycle 6: All healthy


Digest: mol-deacon-patrol

Patrol 6: thorough check, all healthy


POLECAT_DONE dementus

Exit: COMPLETED
Issue: bd-au0.7
MR: bd-n5ug
Branch: polecat/dementus


Digest: mol-deacon-patrol

Patrol cycle 115: All healthy


🤝 HANDOFF: Land polecats, clean town

## Mission
Land all polecat work, merge it, despawn workers, clean the town.

## Polecats with Unpushed Code Work

| Polecat | Issue | Commits | Status |
|---------|-------|---------|--------|
| dementus | gt-j6s8 Refinery patrol auto-bond | 2 | Needs push+MR |
| furiosa | gt-caih Witness handoff persistence | 1 | Needs push+MR |
| rictus | gt-7923 Patrol awareness | 1 | Has MR gt-xnzp |
| valkyrie | gt-yd98 Molecule format bridge | 1 | Has MR gt-jq0f |
| angharad | bd-4opy SQLite test refactor | 1 | Needs push+MR (beads) |
| immortan | - | - | ✅ Rescued by crew/max |
| slit | gt-5xph | bd sync only | Check if code done |
| scrotus | gt-lz13 | clean | Check if code done |

## Pending MRs
- gt-jq0f: Merge gt-yd98 (valkyrie)
- gt-xnzp: Merge gt-7923 (rictus)
- gt-ubd4: Merge gt-tnca.1

## Landing Protocol
For each polecat with work:
1. Check git status - any uncommitted changes?
2. If unpushed commits exist, push: git push origin HEAD
3. Create MR if needed: bd create --type=merge-request
4. Process MRs via refinery or manual merge

## Cleanup Protocol
After all work landed:
1. Stop polecat sessions: gt session stop <rig>/<polecat>
2. Remove worktrees: gt polecat remove <rig> <name>
3. Or use gt rig reset to clean all

## This Session
- Fixed spawn.go bug: was using wrong manager for refinery/witness auto-start
- Added check-refinery step to mol-witness-patrol
- Filed follow-ups: gt-s18k, gt-tr3d, gt-9wv0

## Key Commands
- gt polecat list <rig> - see polecats
- gt polecat git-state <rig>/<polecat> - check for uncommitted work
- gt session stop <rig>/<polecat> - kill session
- gt polecat remove <rig> <name> - remove worktree


Digest: mol-deacon-patrol

Patrol #10: routine


Digest: mol-deacon-patrol

Patrol 13: Swarm active.


Digest: mol-deacon-patrol

Patrol 67: All healthy. No incidents.


Digest: mol-deacon-patrol

Patrol 7: routine, all healthy


SPAWN: furiosa starting on gt-r6td

Polecat spawn notification.

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

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


Digest: mol-deacon-patrol

Patrol #25: Resumed after 93min idle. beads/crew/emma active (2h). Gastown refinery queue: 3. All healthy.


🤝 HANDOFF: Account management ready for implementation

Context: Designed system for Gas Town multi-account Claude Code management.

DONE:
- Researched CLAUDE_CONFIG_DIR mechanism
- Created docs/design/account-management.md
- Filed epic gt-3133 with 6 tasks
- Ultrathink confirmed design is sound

READY TO IMPLEMENT:
Start with gt-58tu (no blockers) - parse mayor/accounts.yaml

Then unblocked: gt-hs6y (list), gt-nq1a (add), gt-0c7s (default), gt-74a7 (env var), gt-plcg (flag)

Run: bd show gt-3133 for epic, bd show gt-58tu for first task


Digest: mol-deacon-patrol

Patrol cycle 1: All agents healthy, no inbox messages, cleaned 16 stale wisps, ran gt doctor --fix


SPAWN: immortan starting on gt-tnca.1

Polecat spawn notification.

Polecat: immortan
Issue: gt-tnca.1
Session: gt-gastown-immortan
Spawned by: beads/crew/dave

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 92: All healthy. No incidents.


Digest: mol-deacon-patrol

Patrol complete: closed convoy hq-cv-6eou6, notified mayor, all agents healthy


Digest: mol-deacon-patrol

Patrol 179: All healthy


Digest: mol-deacon-patrol

Patrol 164: All healthy, quiet


POLECAT_STARTED cheedo

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


Digest: mol-deacon-patrol

Patrol 6: Fixed 1 orphan. All healthy.


📋 Work Assignment: Improve test coverage for internal/compact (18.2% → 70%)

Issue: bd-thgk
Title: Improve test coverage for internal/compact (18.2% → 70%)
Priority: P1
Type: task

Description:
Improve test coverage for internal/compact package from 17% to 70%.

## Current State
- Coverage: 17.3%
- Files: compactor.go, git.go, haiku.go
- Tests: compactor_test.go (minimal tests)

## Functions Needing Tests

### compactor.go (core compaction)
- [ ] New - needs config validation tests
- [ ] CompactTier1 - needs single issue compaction tests
- [ ] CompactTier1Batch - needs batch processing tests
- [ ] compactSingleWithResult - internal, test via public API

### git.go
- [ ] GetCurrentCommitHash - needs git repo fixture tests

### haiku.go (AI summarization) - MOCK REQUIRED
- [ ] NewHaikuClient - needs API key validation tests
- [ ] SummarizeTier1 - needs mock API response tests
- [ ] callWithRetry - needs retry logic tests
- [ ] isRetryable - needs error classification tests
- [ ] renderTier1Prompt - needs template rendering tests

## Implementation Guide

1. **Mock the Anthropic API:**
   ```go
   // Create mock HTTP server
   server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
       json.NewEncoder(w).Encode(map[string]interface{}{
           "content": []map[string]string{{"text": "Summarized content"}},
       })
   }))
   defer server.Close()

   // Point client at mock
   client.baseURL = server.URL
   ```

2. **Test scenarios:**
   - Successful compaction with AI summary
   - API failure with retry
   - Rate limit handling
   - Empty issue handling
   - Large issue truncation

3. **Use test database:**
   ```go
   store, cleanup := testutil.NewTestStore(t)
   defer cleanup()
   ```

## Success Criteria
- Coverage ≥ 70%
- AI calls properly mocked (no real API calls in tests)
- Retry logic verified
- Error paths covered

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

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

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

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


Digest: mol-deacon-patrol

Patrol 18: Swarm active.


Digest: mol-deacon-patrol

Patrol 11: Quick cycle.


Digest: mol-deacon-patrol

Patrol #1: Inbox empty, all agents healthy, no orphans. Clone divergence noted (zoey/jack).


POLECAT_STARTED gastown/dag

Issue: gt-xuzo
Session: gt-gastown-dag


POLECAT_STARTED beads/dementus

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


📋 Work Assignment: Phase 1.3: gt doctor checks for ephemeral health

Issue: gt-3x0z.3
Title: Phase 1.3: gt doctor checks for ephemeral health
Priority: P2
Type: task

Description:
Add doctor checks for ephemeral beads repo.

## Checks

1. **ephemeral-exists**: .beads-ephemeral/ directory exists for each rig
2. **ephemeral-git**: It's a valid git repo
3. **ephemeral-orphans**: Molecules started but never squashed (>24h old)
4. **ephemeral-size**: Warn if ephemeral repo is >100MB (should be cleaned)
5. **ephemeral-stale**: Molecules with no activity in last hour

## Auto-fix

--fix can:
- Create missing ephemeral repo
- Clean up old completed molecules (already squashed)
- NOT auto-squash incomplete molecules (needs AI summary)

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


SPAWN: slit starting on gt-i4kq

Polecat spawn notification.

Polecat: slit
Issue: gt-i4kq
Session: gt-gastown-slit
Spawned by: gastown/crew/max

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


Digest: mol-deacon-patrol

Patrol cycle 2: All agents healthy, no inbox messages


Digest: mol-deacon-patrol

Patrol 66: All healthy


Digest: mol-deacon-patrol

Patrol 9: Routine check, ace/warboy spawning


Digest: mol-deacon-patrol

Patrol cycle 106: All healthy


Role: polecat

Polecat Role Definition


Digest: mol-deacon-patrol

Patrol 14: town idle, all healthy


Digest: mol-deacon-patrol

P17: clear


Digest: mol-deacon-patrol

Patrol 20: final check passed, all healthy


POLECAT_STARTED furiosa

Issue: gt-83k0
Session: gt-gastown-furiosa


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

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

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

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

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

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

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

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

The orphan-...

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

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

**Timer gates**...

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

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


Digest: mol-deacon-patrol

Patrol 1: Processed handoff, fixed 1 orphan session, all witnesses/refineries healthy


Digest: mol-deacon-patrol

Patrol 12: Quiet. All healthy.


Digest: mol-deacon-patrol

Patrol cycle 11: All healthy


Digest: mol-deacon-patrol

Patrol 5 complete: all healthy


🧬 Molecule: mol-polecat-work (step 1/4)

Issue: gt-mol-3g1
Title: mol-polecat-work
Priority: P2
Type: epic

Description:
Full polecat lifecycle from assignment to decommission.

This proto enables nondeterministic idempotence for polecat work. A polecat that crashes after any step can restart, read its molecule state, and continue from the last completed step. No work is lost.

## Variables

| Variable | Required | Description |
|----------|----------|-------------|
| issue | Yes | The source issue ID being worked on |

## Molecule Workflow
You are working on step 1 of 4 in molecule mol-polecat-work.
Molecule root: gt-mol-3g1

After completing this step:
1. Run `bd close <step-id>`
2. Run `bd ready --parent gt-mol-3g1` to find next ready steps
3. If more steps are ready, continue working on them
4. When all steps are done, run `gt done` to signal completion

## 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. Check `bd ready --parent gt-mol-3g1` for more steps
5. Repeat steps 2-4 for each ready step
6. When all steps done: run `bd sync`, then `gt done`

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


MR Ready: Beader (bd-tvu3)

Beader completed. Coverage 48.4%→80.2%. Branch: polecat/Beader ready for merge.


Digest: mol-deacon-patrol

Patrol cycle 4: all clear, no convoys, no issues


🤝 HANDOFF: Session cycling

let's hope the handoff worked; if so, you should look for ready open work after we restart


Digest: mol-deacon-patrol

Patrol C37: All healthy


Digest: mol-deacon-patrol

Patrol 20: Final patrol, handoff after this


Digest: mol-deacon-patrol

Patrol 11: Clean, post-wisp-cleanup


Digest: mol-deacon-patrol

Patrol cycle 1: inbox empty, no gates, no pending spawns, 2 convoys open, all witnesses+refineries healthy, ran doctor --fix


Digest: mol-deacon-patrol

Patrol 26: healthy


Digest: mol-deacon-patrol

Patrol cycle 20: clean, handoff at threshold


Digest: mol-deacon-patrol

Patrol 1: No actionable callbacks, all agents healthy, cleaned 6 stale locks, clone jack divergence noted


🤝 HANDOFF: Continue wisp epic (bd-kwjh)

## Context

Working on the wisp storage epic (bd-kwjh) for Gas Town patrol cycles.
Wisps are ephemeral molecules stored in `.beads-wisp/` that get squashed
into permanent digests.

## Completed This Session

- **bd-kwjh.4**: Implemented cross-store wisp→digest squash
  - `bd mol squash` auto-detects wisps in `.beads-wisp/`
  - Creates digest in permanent `.beads/`
  - Deletes wisp from ephemeral storage
  - Full test coverage added

- **Fixed**: Renamed `.beads-wisps` → `.beads-wisp` (singular) to match
  architecture doc at `gastown/mayor/rig/docs/wisp-architecture.md`

## Remaining Tasks

1. **bd-kwjh.7: bd mol burn** - Delete wisp WITHOUT creating digest
   - Simple: just delete from wisp storage, no permanent record
   - Use case: abandoned/failed patrol cycles

2. **bd-kwjh.5: bd wisp list** - List wisps in `.beads-wisp/`
   - Show in-progress ephemeral molecules
   - Useful for debugging stuck wisps

3. **bd-kwjh.6: bd wisp gc** - Garbage collect orphaned wisps
   - Clean up wisps from crashed processes
   - Check process_id or age threshold

## Key Files

- `cmd/bd/mol_squash.go` - squash implementation
- `cmd/bd/mol_bond.go` - bond with --wisp flag
- `internal/beads/beads.go` - wisp storage helpers (NewWispStorage, etc.)
- `gastown/mayor/rig/docs/wisp-architecture.md` - design doc

## Suggested Order

burn → list → gc (burn is simplest, gc needs list)

Good luck!


Digest: mol-deacon-patrol

Patrol 101: All healthy. 3 rigs, 6 core agents running. No incidents.


Digest: mol-deacon-patrol

Patrol 1: All agents healthy, escalated beads/refinery clone divergence (80 commits behind) to Mayor


Digest: mol-deacon-patrol

Cycle 12


Digest: mol-deacon-patrol

Patrol 34: healthy


🤝 HANDOFF: Christmas Launch - gt-3x0z.9 Unblocked

## Christmas Launch Status

### This Session Completed
- **gt-2xiv**: Fixed crew worker mail identity (Postel's Law normalization)
- **gt-3x0z.3**: Implemented wisp doctor checks (wisp-exists, -git, -orphans, -size, -stale)
- **Wisp terminology**: Unified .beads-wisp/, transient polecats, throughout Gas Town

### UNBLOCKED: gt-3x0z.9
Dave completed bd mol squash with cross-store support. All dependencies for gt-3x0z.9 are now met:
- [x] gt-3x0z.8 (mol-polecat-work squash step)
- [x] gt-rana.3 (mol-deacon-patrol definition)
- [x] bd-kwjh.3 (bd mol bond --wisp)
- [x] bd-kwjh.4 (bd mol squash cross-store)

### Next Priority
**gt-3x0z.9**: Implement deacon patrol using wisps
- Modify daemon to run patrol as wisp molecule
- Each patrol cycle: bond -> execute -> squash
- Use bd mol bond mol-deacon-patrol --wisp
- Squash at end of each cycle

### After gt-3x0z.9
- gt-3x0z.10: Witness/Refinery patrol molecules
- gt-3x0z.11: Documentation
- gt-3x0z.12: Error handling/recovery

### Dave's Remaining Beads Work (not blocking us)
- bd-kwjh.5: wisp list
- bd-kwjh.6: wisp gc
- bd-kwjh.7: mol burn

### Commands
```bash
bd show gt-3x0z.9     # Next task
bd show gt-3x0z       # Wisp epic
bd show gt-ngpz       # Christmas plan
```


Digest: mol-deacon-patrol

Patrol 12: all nominal


Digest: mol-deacon-patrol

Patrol C55: all healthy


Digest: mol-deacon-patrol

Cycle 74: All healthy


POLECAT_DONE slit

Exit: COMPLETED
Issue: bd-7z4
MR: mr-1766562564-378e59a6
Branch: polecat/slit


Digest: mol-deacon-patrol

Patrol 10: thorough check all clear


Digest: mol-deacon-patrol

Patrol 14: Routine.


Digest: mol-deacon-patrol

Patrol 96: Routine


Digest: mol-deacon-patrol


POLECAT_DONE cheedo

Exit: COMPLETED
Issue: bd-dxtc
MR: bd-u8g4
Branch: polecat/cheedo


Digest: mol-deacon-patrol

Patrol cycle 1: Burned 106 stale patrol wisps, all agents healthy (18 procs), 2 convoys open, beads refinery has 5 pending


Digest: mol-deacon-patrol

Cycle 267: All clear


Digest: mol-deacon-patrol

Patrol 3: All agents healthy, cleaned stale wisp hq-wisp-m1a, no incidents


Digest: mol-deacon-patrol

Patrol 16: Stable


Digest: mol-deacon-patrol

Patrol cycle 15: all healthy, nux working


Digest: mol-deacon-patrol

Patrol #7: 3 polecats active. All healthy.


gt convoy list --tree: Show convoy + child status tree

Add a --tree flag to 'gt convoy list' that shows convoys with their child issues in a tree format.

Example output:
```
🚚 hq-cv-wvqi6: Boot + Polish swarm (16/17)
├── ✓ bd-11lm: Increase ClaudeStartTimeout
├── ✓ bd-49oe: Cache GetGitDir()
├── ○ gt-74ivo: Witness: Don't nuke polecats with open MRs  ← remaining
└── ...

🚚 hq-cv-w3nm6: Messaging Channels (4/10)
├── ✓ gt-0q3cg: Add isQueueAddress()
├── ○ gt-27bzi: Add gt mail announces
└── ...
```

Makes convoy progress visible at a glance without running 'gt convoy status' on each one.


Digest: mol-deacon-patrol

Cycle 27: Routine, all healthy


Digest: mol-deacon-patrol

Patrol 3: All healthy.


🤝 HANDOFF: Patrol formulas cooked, critical bugs filed

## Session Summary

### Completed
- Filed bd-weu8, bd-wa2l for Dave (formula parser, bd cook)
- Built & installed bd with cook command
- Fixed 4 patrol formulas (added title fields)
- Cooked 4 protos: deacon(9), witness(10), refinery(11), polecat-arm(6)
- Reviewed cooked protos, found critical bugs

### Critical Bugs for Dave (blockers)
- bd-hr39: needs field not converted to step dependencies
- bd-j4cr: waits_for field not preserved (gates broken)

### Polish Tasks (in hq-a71z)
- bd-47qx: Proto prefix consistency
- gt-i6k1: Clean up duplicate protos
- gt-j755: Add nudge_text variable
- gt-x0a5: Placeholder syntax consistency

### Next Steps
1. Wait for Dave to fix bd-hr39, bd-j4cr
2. Then re-cook formulas to get correct dependencies
3. Polish tasks can be done anytime


Digest: mol-deacon-patrol

Patrol cycle 3: closed convoy hq-cv-zffhg (ga- prefix fix), gt commands SIGKILL


Digest: mol-deacon-patrol

Patrol 19: Routine


Digest: mol-deacon-patrol

Cycle 20: stable, handoff due


Digest: mol-deacon-patrol

Patrol 3: Quick cycle - no callbacks.


Digest: mol-deacon-patrol

Patrol 3: All clear


Digest: mol-deacon-patrol

Patrol C57: all healthy


Digest: mol-deacon-patrol

Patrol cycle 6: Nominal


Digest: mol-deacon-patrol

Patrol cycle 112: All healthy


Digest: mol-deacon-patrol

Patrol #3: routine, all healthy


🤝 HANDOFF: Clean up town root untracked files

## Context

Town root (~/gt) has untracked files causing bd sync issues.

## Modified Files (intentional user edits)
- CLAUDE.md - updated mail instructions
- gastown/AGENTS.md - likely agent docs update

## Untracked Files to Review
- .beads/bd.sock.startlock - runtime lock file, can delete
- beads/.beads.old/ - old beads backup, review then delete
- beads/refinery/ - stale refinery state?
- beads/witness/ - stale witness state?
- deacon/ - deacon runtime state
- docs/LAUNCH_PLAN.md - new doc, should commit or gitignore
- docs/temporal-integration.md - new doc, should commit or gitignore
- gastown/.beads.old/ - old beads backup, review then delete
- gastown/refinery/ - stale refinery state?
- gastown/witness/ - stale witness state?
- gt - built binary, should be gitignored

## Suggested Actions
1. Delete runtime files: bd.sock.startlock, .beads.old dirs
2. Gitignore built binary: gt
3. Review docs/ files - commit if useful, delete if stale
4. Review refinery/witness dirs - likely stale state to delete
5. Commit the CLAUDE.md and AGENTS.md changes if intentional

## Commands
cd ~/gt
rm .beads/bd.sock.startlock
rm -rf beads/.beads.old gastown/.beads.old
echo 'gt' >> .gitignore  # if not already there
git status


Digest: mol-deacon-patrol

Patrol 58: All healthy


Digest: mol-deacon-patrol

Patrol 8: All agents healthy. No incidents.


Digest: mol-deacon-patrol

Patrol cycle 8: clean, gastown now 4 polecats


📋 Work Assignment: Update templates for Propulsion Principle

Issue: gt-i4kq
Title: Update templates for Propulsion Principle
Priority: P1
Type: task

Description:
Overhaul agent prompts to embody the Universal Gas Town Propulsion Principle:

> If you find something on your hook, YOU RUN IT.

Templates to update:
- [ ] deacon.md.tmpl - Check hook first, no decision logic
- [ ] polecat.md.tmpl - Propulsion startup, follow molecule
- [ ] witness.md.tmpl - Sling wisps when spawning agents
- [ ] refinery.md.tmpl - Accept slung epics

Key changes:
1. Remove 'should I run this?' decision points
2. Add 'check your hook' as step 1 of startup
3. Make molecule-following the default mode
4. Simplify - agents don't think, they execute

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


Digest: mol-deacon-patrol

Patrol 13: all clear


Test6

Debug test


Digest: mol-deacon-patrol

Patrol 11: all nominal


POLECAT_STARTED dag

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


Digest: mol-deacon-patrol

Patrol 16: routine, no incidents


Digest: mol-deacon-patrol

Patrol 95: All healthy. No incidents.


Digest: mol-deacon-patrol

Patrol 2: Inbox clear, all healthy, no orphans, no gates


📋 Work Assignment: gt molecule current: Show what agent should be working on

Issue: gt-ay1r
Title: gt molecule current: Show what agent should be working on
Priority: P1
Type: feature

Description:
Query what an agent identity is supposed to be working on via breadcrumb trail.

## Command
```bash
gt molecule current <identity>
gt molecule current gastown/furiosa
gt molecule current deacon
```

## Logic
1. Find handoff bead for identity (pinned bead titled "<role> Handoff")
2. Parse attachment field → molecule ID
3. If no attachment → "naked" (no active molecule)
4. If attached → load molecule, find current step:
   - bd ready --parent=<mol-id> → next unblocked step
   - Or first in_progress step

## Output
```
Identity: gastown/furiosa
Handoff:  gt-8v2 (Furiosa Handoff)
Molecule: gt-mol-abc (mol-polecat-work)
Progress: 3/8 steps complete
Current:  gt-mol-abc.4 - verify-tests
```

Or if naked:
```
Identity: gastown/angharad
Handoff:  gt-9x1 (Angharad Handoff)
Molecule: (none attached)
Status:   naked - awaiting work assignment
```

## Use Cases
- Mayor checking what polecats are doing
- Witness verifying polecat progress
- Debug: "why isnt this polecat working?"
- Deacon patrol: track all agent states

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

Exit: COMPLETED
Issue: bd-t4u1
MR: mr-1766562566-811d6a15
Branch: polecat/capable


Digest: mol-deacon-patrol

Patrol 3: REMEDIATION - restarted wyvern witness (was stopped)


Digest: mol-deacon-patrol

Patrol cycle 107: All healthy


Digest: mol-deacon-patrol

Final routine patrol before handoff


Digest: mol-deacon-patrol

Patrol 4: routine, no incidents


SPAWN: furiosa starting on gt-3x0z.1

Polecat spawn notification.

Polecat: furiosa
Issue: gt-3x0z.1
Session: gt-gastown-furiosa
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-furiosa "Check your inbox with 'gt mail inbox' and begin working." Enter

The polecat has a work assignment in its inbox.


Digest: mol-deacon-patrol

Patrol complete: checked inbox (1 handoff msg), health check passed (2 witnesses, 2 refineries), no orphans


Digest: mol-deacon-patrol

Cycle 25: Routine, all healthy


SPAWN: scrotus starting on gt-lz13

Polecat spawn notification.

Polecat: scrotus
Issue: gt-lz13
Session: gt-gastown-scrotus
Spawned by: beads/crew/dave

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 12: all clear


Digest: mol-deacon-patrol

Patrol 8: Quiet cycle. All healthy.


Digest: mol-deacon-patrol

Patrol 11: Closed 1 convoy (mail clear), all 3 rigs healthy


Digest: mol-deacon-patrol

Patrol 2: inbox clear, all agents healthy


POLECAT_DONE nux

Exit: COMPLETED
Issue: bd-l13p
MR: bd-bijf
Branch: polecat/nux


Digest: mol-deacon-patrol

Patrol 118: All healthy.


Digest: mol-deacon-patrol

Patrol complete: restarted gastown witness and refinery (both dead), cleaned 1 orphan session (gt-boot), no inbox messages


Digest: mol-deacon-patrol

Patrol 20: Final cycle, all healthy


Digest: mol-deacon-patrol

Patrol 4: Town quiet


📋 Work Assignment: Improve test coverage for internal/export (37.1% → 60%)

Issue: bd-6sm6
Title: Improve test coverage for internal/export (37.1% → 60%)
Priority: P2
Type: task

Description:
The export package has only 37.1% test coverage. Export functionality needs good coverage to ensure data integrity.

Current coverage: 37.1%
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.


🤝 HANDOFF: Continue bug fixing from backlog

## Session Summary

Fixed 3 GitHub issues this session:
- GH#671: priority:0 omitempty (was already fixed, just closed)
- GH#674: bd create -f nil pointer (was already fixed, just closed)
- GH#719: bd create -f daemon mode failure (implemented fix in bd6fa5cb)

## Bug Fixing Approach

We're working through the backlog of open GitHub issues. Run:
```bash
gh issue list --state open --limit 20
bd ready
```

## Good Candidates for Next Session

From the GH issues list, these look achievable:
- GH#714: bd doctor count mismatch (needs investigation, user reported weird counts)
- GH#709: FindJSONLInDir returns interactions.jsonl (bug, should default to issues.jsonl)
- GH#704: Absolute paths in global gitignore with --stealth (bug)

From beads issues:
- bd-4opy: Refactor long SQLite test files (P2 task)
- bd-bqcc: Consolidate maintenance commands into bd doctor --fix (P2 feature, higher risk)

## Notes

- There's a pre-existing flaky test: TestDatabaseReinitialization/database_removal_scenario
- Not caused by our changes, was failing on main before the fix
- May want to file an issue for it if one doesn't exist

## Git State

All clean, pushed to main. No uncommitted work.


🤝 HANDOFF: bd-bkul: Wisp simplification in progress

## Work in Progress: bd-bkul (Simplify Wisp Architecture)

### Context
Eliminating the separate `.beads-wisp/` directory. Wisps are now just
issues with `Wisp=true` in the main database. JSONL export already
skips wisps (line ~365 in export.go).

### Completed
1. **bd create --wisp** - Creates issue with Wisp=true
2. **bd wisp create** - Uses main db, not separate wisp storage
3. **bd wisp list** - Queries main db with Wisp filter (RPC support added)
4. **bd wisp gc** - Works with main db

### Still TODO
1. **mol squash** - Remove cross-store logic:
   - Delete `runWispSquash()` function (lines 209-281)
   - Delete `squashWispToPermanent()` function (lines 434-511)
   - Simplify `runMolSquash()` - remove wisp storage checking (lines 86-129)
   - Update `squashMolecule()` to clear Wisp flag instead of delete

2. **mol burn** - Similar simplification needed (check mol_burn.go)

3. **Deprecate wisp storage functions** in internal/beads/beads.go:
   - FindWispDir()
   - FindWispDatabasePath()
   - NewWispStorage()
   - EnsureWispGitignore()
   - IsWispDatabase()

4. **Test** - Run tests, verify build

### Key Files
- cmd/bd/mol_squash.go - Partially updated, needs finish
- cmd/bd/mol_burn.go - Needs similar updates
- internal/beads/beads.go - Wisp storage functions to deprecate

### Terminology Note
- "stale" = graph-pressure staleness (complete but blocking other work)
- "old/abandoned" = time-based cleanup (for ephemeral wisps)
See bd-anv2 for proper stale definition.


Digest: mol-deacon-patrol

Patrol 1: All systems healthy, no callbacks, 8 sessions active


Digest: mol-deacon-patrol

Patrol 99: All healthy


📋 Work Assignment: Work on gt-8tmz.36: Validate expanded step IDs are unique...

Issue: bd-qy37
Title: Work on gt-8tmz.36: Validate expanded step IDs are unique...
Priority: P2
Type: task

Description:
Work on gt-8tmz.36: Validate expanded step IDs are unique. After ApplyExpansions in internal/formula/expand.go, new steps can be created that might have duplicate IDs. Add validation in ApplyExpansions to check for duplicate step IDs after expansion. If duplicates found, return an error with the duplicate IDs. 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.


cv-startup: Agent Startup Consolidation Swarm

## Overview

Swarm execution plan for gt-85whr (Agent Startup Consolidation).
Quick fix (gt-7swyi) already landed. This convoy handles the full solution.

## Swarm Phases

### Phase 1: Foundation (Parallel - 2 polecats)

| Polecat | Issue | Task | Est. Complexity |
|---------|-------|------|-----------------|
| A | gt-bgfqy | Create StartupNudge function with seance metadata | Medium |
| B | gt-dc2fs | Add runtime configuration for LLM commands | Medium |

**gt-bgfqy details:**
- Create internal/session/startup.go
- Define StartupNudgeConfig struct (Recipient, Sender, Topic, MolID)
- Format: `[GAS TOWN] gastown/crew/gus ← deacon • 2025-12-30T15:42 • topic`
- Use t.NudgeSession() for delivery
- Add tests

**gt-dc2fs details:**
- Create internal/config/runtime.go
- Define RuntimeConfig struct (Command, Args, InitialPrompt)
- Add LoadRuntimeConfig() and BuildCommand()
- Default: claude --dangerously-skip-permissions
- Support future runtimes (aider, etc.) via config
- Add tests

### Phase 2: Integration (Parallel - 2 polecats, after Phase 1)

| Polecat | Issue | Task | Est. Complexity |
|---------|-------|------|-----------------|
| C | gt-j0546 | Refactor all startup paths to use StartupNudge | Large |
| D | gt-7qvd7 | Add gt seance command | Medium |

**gt-j0546 details:**
- Refactor 8+ files to use new StartupNudge + RuntimeConfig
- Files: start.go, crew_lifecycle.go, crew_at.go, handoff.go, deacon.go, witness.go, polecat_spawn.go
- Remove hardcoded "claude --dangerously-skip-permissions"
- Each startup path gets proper seance metadata (sender, topic)

**gt-7qvd7 details:**
- Create internal/cmd/seance.go
- Parse Claude Code session history (or tmux sessions + our metadata)
- Display: ID, ROLE, STARTED, TOPIC
- Flags: --role, --rig, --recent N, --resume <id>
- Parse the StartupNudge format to extract metadata

## Execution Order

```
Phase 1:  [bgfqy]──┬──▶ Phase 2:  [j0546]
          [dc2fs]──┘              [7qvd7]
```

## Success Criteria

1. All agent startups use unified StartupNudge
2. Runtime command comes from config, not hardcode
3. Sessions identifiable in /resume by role, sender, time, topic
4. gt seance works for predecessor discovery

## Tracking

- Epic: gt-85whr
- Phase 1 issues: gt-bgfqy, gt-dc2fs
- Phase 2 issues: gt-j0546, gt-7qvd7
- Quick fix (done): gt-7swyi

All tracked issues completed (bgfqy, dc2fs, j0546, 7qvd7 all closed)


Digest: mol-deacon-patrol

Final patrol before handoff - all healthy


Digest: mol-deacon-patrol

Patrol 20: All healthy, handing off


Digest: mol-deacon-patrol

Patrol C34: All healthy


Digest: mol-deacon-patrol

Patrol 4: all nominal


Digest: mol-deacon-patrol

Patrol #2: 3 polecats active (nux, rictus, slit). Gastown witness/refinery healthy. 7 convoys tracked. No incidents.