feat: implement priming subsystem improvements

Phase 1 of dynamic priming subsystem:

1. PRIME.md provisioning for all workers (hq-5z76w, hq-ukjrr Part A)
   - Added ProvisionPrimeMD to beads package with Gas Town context template
   - Provision at rig level in AddRig() so all workers inherit it
   - Added fallback provisioning in crew and polecat managers
   - Created PRIME.md for existing rigs

2. Post-handoff detection to prevent handoff loop bug (hq-ukjrr Part B)
   - Added FileHandoffMarker constant (.runtime/handoff_to_successor)
   - gt handoff writes marker before respawn
   - gt prime detects marker and outputs "HANDOFF COMPLETE" warning
   - Marker cleared after detection to prevent duplicate warnings

3. Priming health checks for gt doctor (hq-5scnt)
   - New priming_check.go validates priming subsystem configuration
   - Checks: SessionStart hook, gt prime command, PRIME.md presence
   - Warns if CLAUDE.md is too large (should be bootstrap pointer)
   - Fixable: provisions missing PRIME.md files

This ensures crew workers get Gas Town context (GUPP, hooks, propulsion)
even if the gt prime hook fails, via bd prime fallback.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
mayor
2026-01-09 23:56:38 -08:00
committed by Steve Yegge
parent 7533fed55e
commit db353c247b
10 changed files with 567 additions and 7 deletions

View File

@@ -386,6 +386,15 @@ func (m *Manager) AddRig(opts AddRigOptions) (*Rig, error) {
}
fmt.Printf(" ✓ Initialized beads (prefix: %s)\n", opts.BeadsPrefix)
// Provision PRIME.md with Gas Town context for all workers in this rig.
// This is the fallback if SessionStart hook fails - ensures ALL workers
// (crew, polecats, refinery, witness) have GUPP and essential Gas Town context.
// PRIME.md is read by bd prime and output to the agent.
rigBeadsPath := filepath.Join(rigPath, ".beads")
if err := beads.ProvisionPrimeMD(rigBeadsPath); err != nil {
fmt.Printf(" Warning: Could not provision PRIME.md: %v\n", err)
}
// Create refinery as worktree from bare repo on default branch.
// Refinery needs to see polecat branches (shared .repo.git) and merges them.
// Being on the default branch allows direct merge workflow.