From adfa4d54517a26b73165c47d2a633b10d57c36f4 Mon Sep 17 00:00:00 2001 From: Steve Yegge Date: Mon, 22 Dec 2025 13:24:51 -0800 Subject: [PATCH] bd sync: add gt-7921, gt-7922, gt-7923 (patrol architecture) --- .beads/issues.jsonl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.beads/issues.jsonl b/.beads/issues.jsonl index ca914725..a1cbd37f 100644 --- a/.beads/issues.jsonl +++ b/.beads/issues.jsonl @@ -142,6 +142,9 @@ {"id":"gt-7918","title":"Patrols: Cyclic molecules for autonomous maintenance","description":"## Vision\n\nPatrols are **cyclic molecules** - workflow loops that give Gas Town its autonomous nervous system. While regular molecules are DAGs that terminate, patrols loop forever, performing maintenance tasks at varying cadences.\n\nThis is the \"steam engine\" of Gas Town: converting episodic Claude sessions into continuous autonomous operation.\n\n## Core Concepts\n\n### 1. Cyclic Molecules\n\nRegular molecule: A -\u003e B -\u003e C -\u003e done\nPatrol molecule: A -\u003e B -\u003e C --+\n ^ |\n +-------------+\n\nPatrols have a loop_to field specifying where to restart.\n\n### 2. Cooldown-Aware Steps (Atoms)\n\nSteps encode their own cadence. When patrol reaches a step:\n1. Check: now - last_run \u003e cooldown?\n2. If yes: execute, update last_run\n3. If no: skip (immediately close)\n\nThe patrol runner is simple - steps self-skip. Complexity distributed into atoms.\n\n### 3. The Beacon\n\nThe heartbeat that fires patrol triggers:\n- Internal ticker in Deacon (goroutine)\n- Or external cron firing gt deacon tick\n- Or mail-based triggers\n\nWithout beacon, nothing proactive happens.\n\n### 4. Session Reset as Patrol Step\n\nConnects to auto-handoff (gt-bcwn). Session reset is a patrol step, not a separate mechanism.\n\n### 5. Multi-Role Patrols\n\nEach supervisor has its own patrol:\n\n**Deacon patrol:** health-check (30s), session-gc (5m), beacon-tick (10s)\n**Witness patrol:** orphan-scan (10m), stuck-check (2m), molecule-progress (1m)\n**Refinery patrol:** queue-check (30s), pr-status (1m), merge-ready (30s)\n\n### 6. Cadence Tiers\n\n- Critical (10-30s): Health checks\n- Active (1-5m): Progress, nudges\n- Maintenance (10-30m): Orphans, GC\n- Periodic (1h+): Reports\n\n### 7. Best-Effort Scheduling\n\nNot real-time - more like cron. No hard deadlines. Catch-up, dont pile-up.\nPriority preemption (mail interrupts patrol). Graceful degradation under load.\n\n## Open Questions\n\n1. State persistence: Beads (self-describing) or file (faster)?\n2. Interruption: How does urgent mail preempt patrol?\n3. Error recovery: Backoff? Escalate? Circuit breaker?\n4. Coordination: Can patrols send mail to trigger other patrols?\n\n## Related\n\n- gt-bcwn: Auto-handoff (session reset is a patrol step)\n- Molecule system (patrols extend molecules with loops)\n- Deacon lifecycle management\n\n## Metaphor\n\nClaude was fire. Claude Code was steam. Gas Town is the steam engine. Beads is the train tracks.\n\nThe steam engine converts episodic combustion into continuous rotary motion.\nGas Town converts episodic Claude sessions into continuous autonomous work.","status":"open","priority":1,"issue_type":"epic","created_at":"2025-12-21T12:18:22.99128-08:00","updated_at":"2025-12-21T12:18:22.99128-08:00","dependencies":[{"issue_id":"gt-7918","depends_on_id":"gt-bcwn","type":"blocks","created_at":"2025-12-21T12:18:30.86651-08:00","created_by":"daemon"}]} {"id":"gt-7919","title":"Fix failing beads tests: TestIntegration and TestPolecatWorkMolecule","status":"open","priority":1,"issue_type":"bug","created_at":"2025-12-22T12:46:29.649-08:00","updated_at":"2025-12-22T12:46:29.649-08:00"} {"id":"gt-7920","title":"Create mol-refinery-patrol with test failure gates","description":"## Problem\n\nThe Refinery role lacks:\n1. A formal patrol molecule (Deacon has mol-deacon-patrol)\n2. Engineer identity/philosophy guidance\n3. Structural enforcement of failure handling (not just documentation)\n\nWhen tests fail during merge processing, the current guidance doesn't prevent 'disavowal' - noting a problem exists and proceeding without tracking it.\n\n## The Structural Solution\n\nCreate `mol-refinery-patrol` with **verification gates** that make disavowal structurally impossible:\n\n```markdown\n## Molecule: mol-refinery-patrol\n\n## Step: inbox-check\nCheck mail for MR submissions, escalations, messages.\nProcess any urgent items first.\n\n## Step: queue-scan\nFetch remote, identify polecat branches waiting.\nIf queue empty, skip to context-check.\nTrack branch list for this cycle.\nNeeds: inbox-check\n\n## Step: process-branch\nPick next branch. Rebase on current main.\nIf rebase conflicts: notify polecat, skip to next branch.\nNeeds: queue-scan\n\n## Step: run-tests\nRun go test ./...\nTrack results (pass/fail count).\nNeeds: process-branch\n\n## Step: handle-failures\n**GATE**: If tests passed, this step auto-completes.\nIf tests failed:\n- Diagnose: branch regression or pre-existing?\n- Branch regression → abort, notify polecat\n- Pre-existing → EITHER fix OR \\`bd create --type=bug\\`\n**VERIFY**: Fix committed OR bead filed before proceeding.\nNeeds: run-tests\n\n## Step: merge-push\nMerge to main (ff-only preferred).\nPush immediately.\nDelete polecat branch.\nNeeds: handle-failures\n\n## Step: loop-check\nMore branches? Return to process-branch.\nOtherwise continue to summary.\nNeeds: merge-push\n\n## Step: generate-summary\nSummarize cycle: branches processed, tests results, issues filed.\nNeeds: loop-check\n\n## Step: context-check\nCheck context usage.\nIf high: write handoff, prepare for burn/respawn.\nNeeds: generate-summary\n\n## Step: burn-or-loop\nIf context LOW and queue non-empty: loop (return to queue-scan)\nIf context HIGH or queue empty: burn and exit\nNeeds: context-check\n```\n\n## Implementation Tasks\n\n### 1. Add RefineryPatrolMolecule() to builtin_molecules.go\n- Copy pattern from DeaconPatrolMolecule\n- Include all steps with proper `Needs:` dependencies\n- Emphasize handle-failures gate in description\n\n### 2. Update Refinery CLAUDE.md\nAdd sections:\n- **The Engineer Mindset** (identity/philosophy)\n- **The Scotty Test** (Would Scotty walk past this?)\n- **Patrol Molecule** reference (mol-refinery-patrol)\n- **Test Failure Protocol** (explicit decision tree)\n\n### 3. Create prompts/roles/refinery.md\n- Follow pattern of deacon.md\n- Include patrol execution loop diagram\n- Reference the molecule\n\n### 4. Consider mol-witness-patrol\n- Witness has detailed heartbeat protocol but no formal molecule\n- Similar pattern could apply\n\n## Why This Matters\n\nGUPP: 'If you have work on your hook, you have to run it.'\nThe patrol molecule puts failure handling ON THE HOOK as a mandatory step.\nYou can't skip handle-failures to get to merge-push.\nThe structure enforces good behavior.\n\n## Related\n- gt-7919: Fix failing beads tests (discovered during this session)\n- mol-deacon-patrol (existing pattern to follow)\n- docs/molecular-chemistry.md (chemistry concepts)\n- docs/wisp-architecture.md (wisp vs mol decision)","status":"closed","priority":1,"issue_type":"feature","assignee":"gastown/refinery","created_at":"2025-12-22T13:01:48.588945-08:00","updated_at":"2025-12-22T13:13:36.329669-08:00","closed_at":"2025-12-22T13:13:36.329669-08:00"} +{"id":"gt-7921","title":"Add await-work and plugin-run steps to mol-refinery-patrol","description":"## Context\n\nThe mol-refinery-patrol needs two additional steps:\n\n### 1. await-work (Decision Point)\n\nNot just 'wait for signal' but a crossroads:\n- Check for pending signals (mail, nudge, human)\n- Check plugin gates (any plugins need to run?)\n- Check maintenance schedule (daily/weekly due?)\n- Evaluate context and decide next action\n\nPosition: Between burn-or-loop and inbox-check (the loop point)\n\n### 2. plugin-run (Like Deacon)\n\nRefinery needs plugin support for:\n- **Monitors**: Flag PRs touching sensitive code\n- **Gates**: Block merges under certain conditions\n- **Schedulers**: Reorder queue based on priority/urgency\n- **Maintenance**: Weekly cleanup, audits, stats\n- **Audits**: Log merge statistics, track patterns\n\nPosition: After queue-scan, before process-branch\n\n## Implementation\n\nUpdate RefineryPatrolMolecule() in builtin_molecules.go to include:\n- await-work step with decision tree\n- plugin-run step with gate types\n\n## Related\n- gt-7920 (original mol-refinery-patrol)\n- docs/deacon-plugins.md (existing plugin model)","status":"open","priority":2,"issue_type":"task","created_at":"2025-12-22T13:24:11.267237-08:00","updated_at":"2025-12-22T13:24:11.267237-08:00"} +{"id":"gt-7922","title":"Dynamic wisp modification: insert, reorder, bond mid-execution","description":"## Vision\n\nWisps should be living documents that adapt mid-execution, not static scripts.\n\n## Operations Needed\n\n### bd mol insert\nInsert a step into a running wisp:\n```bash\nbd mol insert \u003cwisp-id\u003e --after \u003cstep\u003e --step 'security-gate: Review auth changes'\n```\n\n### bd mol reorder \nChange step order in a running wisp:\n```bash\nbd mol reorder \u003cwisp-id\u003e --move process-branch --before current\n```\n\n### bd mol bond (to wisp)\nAttach an entire molecule to a running wisp:\n```bash\nbd mol bond mol-weekly-maintenance \u003cwisp-id\u003e --after await-work\n```\n\n### bd mol skip\nSkip a step (with reason):\n```bash\nbd mol skip \u003cwisp-id\u003e \u003cstep\u003e --reason 'Queue empty, skipping summary'\n```\n\n## Use Cases\n\n1. **Hotfix priority**: Reorder queue to process urgent MR first\n2. **Security gate**: Insert review step when PR touches sensitive files\n3. **Scheduled maintenance**: Bond maintenance mol on schedule\n4. **Context adaptation**: Skip steps when they don't apply\n\n## Why This Matters\n\nEngine room problems emerge dynamically. The wisp's flexibility lets agents model situations as they evolve, not execute rigid scripts.\n\nGUPP still applies: whatever's on your hook, you run. But the hook contents can adapt.\n\n## Implementation\n\nThis requires Beads changes to support wisp mutation:\n- Track step ordering in wisp storage\n- Support step insertion/deletion/reordering\n- Handle bond-to-wisp (spawn steps into existing wisp)\n- Preserve audit trail of modifications","status":"open","priority":2,"issue_type":"feature","created_at":"2025-12-22T13:24:26.533247-08:00","updated_at":"2025-12-22T13:24:26.533247-08:00"} +{"id":"gt-7923","title":"gt rig add / gt doctor: patrol awareness and wiring","description":"## Problem\n\nWhen a rig is installed or audited, we need to ensure all built-in patrols and role hooks are properly wired up.\n\n## gt rig add Changes\n\nWhen adding a rig, automatically:\n\n1. **Create patrol molecules** for each role:\n - mol-deacon-patrol (town-level)\n - mol-witness-patrol (per-rig)\n - mol-refinery-patrol (per-rig)\n\n2. **Set up hooks** that trigger patrols:\n - Deacon: daemon timer / heartbeat\n - Witness: daemon timer / polecat lifecycle events\n - Refinery: MR submission events / daemon timer\n\n3. **Configure daemon** to manage these patrols:\n - Register patrol molecules in daemon config\n - Set up respawn behavior for each role\n\n4. **Create plugin directories**:\n - ~/gt/plugins/ (town-level)\n - \u003crig\u003e/plugins/ (rig-level, if needed)\n\n## gt doctor Changes\n\nAdd patrol health checks:\n\n### patrol-molecules-exist\n- Verify mol-deacon-patrol, mol-witness-patrol, mol-refinery-patrol exist\n- Check they parse correctly (valid steps, dependencies)\n\n### patrol-hooks-wired\n- Verify hooks trigger patrol execution\n- Check daemon is configured to manage patrols\n\n### patrol-not-stuck\n- Detect wisps that have been in-progress too long\n- Flag orphaned patrol molecules (no active session)\n\n### patrol-plugins-accessible\n- Verify plugin directories exist and are readable\n- Check plugin frontmatter parses correctly\n\n### patrol-roles-have-prompts\n- Verify prompts/roles/*.md exist for each role\n- Check they reference the correct patrol molecule\n\n## Auto-fix\n\ngt doctor --fix can:\n- Create missing patrol molecules\n- Wire up missing hooks\n- Create plugin directories\n- NOT restart stuck patrols (needs human decision)\n\n## Related\n- gt-7920 (mol-refinery-patrol)\n- gt-7921 (await-work and plugin-run)\n- docs/wisp-architecture.md","status":"open","priority":1,"issue_type":"feature","created_at":"2025-12-22T13:24:43.158379-08:00","updated_at":"2025-12-22T13:24:43.158379-08:00"} {"id":"gt-7hor","title":"Document the Propulsion Principle","description":"Write canonical documentation for the Universal Gas Town Propulsion Principle.\n\nLocation: gastown/mayor/rig/docs/propulsion-principle.md\n\nContent:\n- The One Rule (hook has work → work happens)\n- Why it works (stateless agents, molecule-driven)\n- The sling lifecycle diagram\n- Agent startup protocol\n- Examples and anti-patterns\n\nThis is foundational theory-of-operation documentation.","status":"closed","priority":2,"issue_type":"task","created_at":"2025-12-22T03:17:47.790012-08:00","updated_at":"2025-12-22T12:20:42.807608-08:00","closed_at":"2025-12-22T12:18:20.377092-08:00"} {"id":"gt-7hz3","title":"Merge: gt-92l","description":"branch: polecat/Ace\ntarget: main\nsource_issue: gt-92l\nrig: gastown","status":"closed","priority":2,"issue_type":"merge-request","created_at":"2025-12-19T16:31:37.716367-08:00","updated_at":"2025-12-19T18:26:14.102101-08:00","closed_at":"2025-12-19T17:48:09.627376-08:00"} {"id":"gt-7iek","title":"context-check","description":"Assess own context usage. If high, prepare for handoff.","status":"open","priority":2,"issue_type":"task","created_at":"2025-12-21T17:51:45.43771-08:00","updated_at":"2025-12-21T17:51:45.43771-08:00","dependencies":[{"issue_id":"gt-7iek","depends_on_id":"gt-hbnz","type":"parent-child","created_at":"2025-12-21T17:51:45.442974-08:00","created_by":"stevey"}]}