sync: patrol cycle complete, queue empty

This commit is contained in:
beads/refinery
2026-01-12 16:46:12 -08:00
committed by Steve Yegge
parent b171ab083c
commit c706e0ac0f

View File

@@ -864,7 +864,7 @@
{"id":"bd-beads-crew-giles","title":"Crew worker giles in beads - human-managed persistent workspace.","description":"Crew worker giles in beads - human-managed persistent workspace.\n\nrole_type: crew\nrig: beads\nagent_state: idle\nhook_bead: null\nrole_bead: gt-crew-role\ncleanup_status: null\nactive_mr: null\nnotification_level: null","status":"open","priority":2,"issue_type":"agent","created_at":"2026-01-04T11:22:11.009942-08:00","created_by":"mayor","updated_at":"2026-01-12T16:41:13.739029-08:00"}
{"id":"bd-beads-crew-grip","title":"Crew worker grip in beads - human-managed persistent workspace.","description":"Crew worker grip in beads - human-managed persistent workspace.\n\nrole_type: crew\nrig: beads\nagent_state: idle\nhook_bead: null\nrole_bead: gt-crew-role\ncleanup_status: null","status":"open","priority":2,"issue_type":"agent","created_at":"2025-12-30T23:14:04.739788-08:00","created_by":"deacon","updated_at":"2026-01-12T16:39:08.539119-08:00"}
{"id":"bd-beads-crew-testcrew456","title":"Crew worker testcrew456 in beads - human-managed persistent workspace.","description":"Crew worker testcrew456 in beads - human-managed persistent workspace.\n\nrole_type: crew\nrig: beads\nagent_state: idle\nhook_bead: null\nrole_bead: hq-crew-role\ncleanup_status: null\nactive_mr: null\nnotification_level: null","status":"open","priority":2,"issue_type":"agent","created_at":"2026-01-09T22:03:44.377795-08:00","created_by":"deacon","updated_at":"2026-01-09T22:03:44.639847-08:00"}
{"id":"bd-beads-crew-wolf","title":"Crew worker wolf in beads - human-managed persistent workspace.","description":"Crew worker wolf in beads - human-managed persistent workspace.\n\nrole_type: crew\nrig: beads\nagent_state: idle\nhook_bead: null\nrole_bead: gt-crew-role\ncleanup_status: null","status":"open","priority":2,"issue_type":"agent","created_at":"2025-12-30T23:14:04.805884-08:00","created_by":"deacon","updated_at":"2026-01-12T16:40:11.409499-08:00"}
{"id":"bd-beads-crew-wolf","title":"Crew worker wolf in beads - human-managed persistent workspace.","description":"Crew worker wolf in beads - human-managed persistent workspace.\n\nrole_type: crew\nrig: beads\nagent_state: idle\nhook_bead: null\nrole_bead: gt-crew-role\ncleanup_status: null","status":"open","priority":2,"issue_type":"agent","created_at":"2025-12-30T23:14:04.805884-08:00","created_by":"deacon","updated_at":"2026-01-12T16:44:45.414887-08:00"}
{"id":"bd-beads-polecat-amber","title":"bd-beads-polecat-amber","description":"bd-beads-polecat-amber\n\nrole_type: polecat\nrig: beads\nagent_state: spawning\nhook_bead: bd-uuo9\nrole_bead: hq-polecat-role\ncleanup_status: has_stash\nactive_mr: bd-3mky\nnotification_level: null","status":"closed","priority":2,"issue_type":"agent","created_at":"2026-01-04T16:17:26.278115-08:00","created_by":"mayor","updated_at":"2026-01-10T16:38:00.102831-08:00","closed_at":"2026-01-05T19:45:45.481449-08:00","close_reason":"Polecat cleaned up","labels":["gt:agent"]}
{"id":"bd-beads-polecat-garnet","title":"bd-beads-polecat-garnet","description":"bd-beads-polecat-garnet\n\nrole_type: polecat\nrig: beads\nagent_state: spawning\nhook_bead: bd-hmeb\nrole_bead: hq-polecat-role\ncleanup_status: null\nactive_mr: bd-o64zq\nnotification_level: null","status":"tombstone","priority":2,"issue_type":"agent","created_at":"2026-01-04T15:12:49.812132-08:00","created_by":"mayor","updated_at":"2026-01-10T21:13:27.005496-08:00","close_reason":"Polecat cleaned up","labels":["gt:agent"],"deleted_at":"2026-01-10T21:13:27.005496-08:00","deleted_by":"beads/witness","delete_reason":"delete","original_type":"agent"}
{"id":"bd-beads-polecat-jasper","title":"bd-beads-polecat-jasper","description":"bd-beads-polecat-jasper\n\nrole_type: polecat\nrig: beads\nagent_state: spawning\nhook_bead: bd-oos3\nrole_bead: gt-polecat-role\ncleanup_status: null\nactive_mr: bd-srhu\nnotification_level: null","status":"tombstone","priority":2,"issue_type":"agent","created_at":"2026-01-02T12:41:56.3782-08:00","created_by":"mayor","updated_at":"2026-01-10T21:12:27.803897-08:00","deleted_at":"2026-01-02T16:57:50.038825-08:00","deleted_by":"mayor","delete_reason":"delete","original_type":"agent"}
@@ -2204,6 +2204,7 @@
{"id":"bd-wcfeu","title":"Review and test PR #975: sync --import-only fix","description":"dispatched_by: beads/crew/emma\n\nReview PR #975 from juanre that fixes sync --import-only failing with 'no database store available' when daemon was connected.\n\n## PR Details\n- URL: https://github.com/steveyegge/beads/pull/975\n- Author: juanre\n- Additions: 143 (mostly test code), Deletions: 0\n\n## Fix Summary\nWhen running bd sync --import-only while daemon is connected:\n1. PersistentPreRun connects to daemon, returns early without initializing store\n2. sync command closes daemon connection\n3. sync --import-only calls importFromJSONLInline which requires store != nil\n4. Fix: call ensureStoreActive() after closing daemon in sync.go\n\n## Your Task\n1. Fetch and checkout the PR branch locally\n2. Run tests: go test ./...\n3. Verify the specific test passes: go test -run TestImportFromJSONLInlineAfterDaemonDisconnect ./cmd/bd/\n4. Review the code change in cmd/bd/sync.go (6 lines)\n5. If everything looks good, approve and merge the PR\n\n## Commands\ngit fetch origin pull/975/head:pr-975\ngit checkout pr-975\ngo test ./...\ngh pr review 975 --repo steveyegge/beads --approve\ngh pr merge 975 --repo steveyegge/beads --squash","status":"closed","priority":2,"issue_type":"task","assignee":"beads/crew/dave","created_at":"2026-01-09T13:44:11.403407-08:00","created_by":"beads/crew/emma","updated_at":"2026-01-09T13:45:43.994469-08:00","closed_at":"2026-01-09T13:45:43.994469-08:00","close_reason":"PR #975 already merged by steveyegge. Verified fix adds ensureStoreActive() after daemon disconnect in sync.go, with comprehensive test."}
{"id":"bd-wcgla","title":"Digest: mol-refinery-patrol","description":"Patrol: queue empty, 0 branches merged, no issues","status":"closed","priority":2,"issue_type":"task","created_at":"2026-01-11T01:23:15.769966-08:00","updated_at":"2026-01-11T01:23:15.769966-08:00","closed_at":"2026-01-11T01:23:15.769922-08:00","close_reason":"Squashed from 11 wisps"}
{"id":"bd-wcl","title":"Document CLI + hooks as recommended approach over MCP","description":"Update documentation to position CLI + bd prime hooks as the primary recommended approach over MCP server, explaining why minimizing context matters even with large context windows (compute cost, energy, environment, latency).","status":"closed","priority":2,"issue_type":"task","created_at":"2025-11-12T00:15:25.923025-08:00","updated_at":"2025-12-09T18:38:37.707666172-05:00","closed_at":"2025-11-26T18:06:51.020351-08:00"}
{"id":"bd-wd0g3","title":"Digest: mol-refinery-patrol","description":"Patrol: queue empty, inbox clear, no branches to merge","status":"closed","priority":2,"issue_type":"task","created_at":"2026-01-12T16:44:00.484253-08:00","updated_at":"2026-01-12T16:44:00.484253-08:00","closed_at":"2026-01-12T16:44:00.4842-08:00","close_reason":"Squashed from 5 wisps","dependencies":[{"issue_id":"bd-wd0g3","depends_on_id":"bd-wisp-ec4","type":"parent-child","created_at":"2026-01-12T16:44:00.485214-08:00","created_by":"beads/refinery"}]}
{"id":"bd-wdn03","title":"Session ended: gt-beads-witness","status":"closed","priority":2,"issue_type":"event","created_at":"2026-01-10T21:32:30.54266-08:00","created_by":"beads/witness","updated_at":"2026-01-10T21:32:30.585178-08:00","closed_at":"2026-01-10T21:32:30.585178-08:00","close_reason":"auto-closed session cost wisp","ephemeral":true}
{"id":"bd-wdp83","title":"Add 'quality_score' field for aggregate quality metric","description":"dispatched_by: beads/crew/emma\n\nAdd float32 field (0.0-1.0) for aggregate quality score on issues. Validators (Refineries) can populate on merge. Foundation for proof-of-stake reputation. Distinct from per-Validation.Score.","status":"closed","priority":2,"issue_type":"task","assignee":"beads/crew/wolf","created_at":"2026-01-10T16:34:07.238429-08:00","created_by":"gastown/crew/max","updated_at":"2026-01-10T19:34:18.170174-08:00","closed_at":"2026-01-10T19:34:18.170174-08:00","close_reason":"Implementation complete","dependencies":[{"issue_id":"bd-wdp83","depends_on_id":"bd-imi7w","type":"parent-child","created_at":"2026-01-10T16:34:21.616554-08:00","created_by":"gastown/crew/max"}]}
{"id":"bd-we4p","title":"Cache getMultiRepoJSONLPaths() result during sync to avoid redundant calls","description":"From bd-xo6b code review: getMultiRepoJSONLPaths() is called 3x per sync cycle.\n\n**Current behavior:**\ndaemon_sync.go calls getMultiRepoJSONLPaths() three times per sync:\n- Line 505: Snapshot capture before pull\n- Line 575: Merge/prune after pull\n- Line 613: Base snapshot update after import\n\n**Cost per call:**\n- Config lookup (likely cached, but still overhead)\n- Path construction: O(N) where N = number of repos\n- String allocations: (N + 1) × filepath.Join() calls\n\n**Total per sync:** 3N path constructions + 3 config lookups + 3 slice allocations\n\n**Impact:**\n- For N=3 repos: Negligible (\u003c 1ms)\n- For N=10 repos: Still minimal\n- For N=100+ repos: Wasteful\n\n**Solution:**\nCall once at sync start, reuse result:\n\n```go\nfunc createSyncFunc(...) func() {\n return func() {\n // ... existing setup ...\n \n // Call once at start\n multiRepoPaths := getMultiRepoJSONLPaths()\n \n // Snapshot capture\n if multiRepoPaths != nil {\n for _, path := range multiRepoPaths {\n if err := captureLeftSnapshot(path); err != nil { ... }\n }\n }\n \n // ... later ...\n \n // Merge/prune - reuse same paths\n if multiRepoPaths != nil {\n for _, path := range multiRepoPaths { ... }\n }\n \n // ... later ...\n \n // Base snapshot update - reuse same paths\n if multiRepoPaths != nil {\n for _, path := range multiRepoPaths { ... }\n }\n }\n}\n```\n\n**Files:**\n- cmd/bd/daemon_sync.go:449-636 (createSyncFunc)\n\n**Note:** This is a performance optimization, not a correctness fix. Low priority unless multi-repo usage scales significantly.","status":"closed","priority":2,"issue_type":"chore","created_at":"2025-11-06T19:31:32.128674-08:00","updated_at":"2025-11-06T19:40:50.871176-08:00","closed_at":"2025-11-06T19:40:50.871176-08:00","dependencies":[{"issue_id":"bd-we4p","depends_on_id":"bd-xo6b","type":"discovered-from","created_at":"2025-11-06T19:32:12.39754-08:00","created_by":"daemon"}]}
@@ -2233,7 +2234,7 @@
{"id":"bd-wisp-540","title":"Update CHANGELOG.md","description":"Write the [Unreleased] section with all changes for 0.45.0.\n\nFormat: Keep a Changelog (https://keepachangelog.com)\n\nSections:\n- ### Added\n- ### Changed\n- ### Fixed\n- ### Documentation\n\nThe bump script will stamp the date automatically.\n","status":"closed","priority":2,"issue_type":"task","created_at":"2026-01-06T20:07:32.256772-08:00","updated_at":"2026-01-06T20:09:49.901996-08:00","closed_at":"2026-01-06T20:09:49.901996-08:00","close_reason":"CHANGELOG.md updated with 0.45.0 changes","dependencies":[{"issue_id":"bd-wisp-540","depends_on_id":"bd-wisp-9jo","type":"blocks","created_at":"2026-01-06T20:07:32.273791-08:00","created_by":"beads/crew/dave"}]}
{"id":"bd-wisp-5j5","title":"beads-release","description":"Beads release workflow v2 - gate-aware async release.\n\nThis formula orchestrates a complete release cycle with async gates:\n\nPhase 1 (Polecat Work):\n 1. Preflight checks (clean git, up to date)\n 2. Documentation updates (CHANGELOG, info.go)\n 3. Version bump (all components)\n 4. Git operations (commit, tag, push)\n\nGate (Async Wait):\n 5. await-ci: Gate on GitHub Actions release.yml completion\n\nPhase 2 (Parallel Verification):\n 6. Verify GitHub release, npm package, PyPI package (concurrent)\n\nPhase 3 (Installation):\n 7. Local installation update\n 8. Daemon restart\n\n## Usage\n\n```bash\nbd mol wisp create beads-release --var version=0.44.0\n```\n\nOr assign to a polecat:\n```bash\ngt sling beads/polecats/p1 --formula beads-release --var version=0.44.0\n```\n\nThe polecat will complete Phase 1, then signal phase-complete. The gate blocks\nuntil release.yml finishes. A new polecat (or the same one) resumes for Phases 2-3.\n","status":"open","priority":2,"issue_type":"epic","created_at":"2026-01-12T03:17:16.705057-08:00","updated_at":"2026-01-12T03:17:16.705057-08:00","ephemeral":true}
{"id":"bd-wisp-60x","title":"Preflight: Check git status \u0026 auto-stash","description":"Ensure working tree is clean before starting release.\n\n```bash\ngit status --short\n```\n\n**Handling uncommitted changes:**\n\nIf changes are in release-related files (CHANGELOG, version files), you may want to:\n- Include them in the release commit\n- Or stash and apply after version bump\n\nIf changes are in **non-release files** (e.g., .beads/config.yaml, .claude/settings.json, local configs):\n```bash\n# Auto-stash non-release files\ngit stash push -m \"pre-release: non-release changes\" -- .beads/ .claude/ *.local* .env*\n\n# Verify working tree is now clean (or only has release files)\ngit status --short\n```\n\n**Important:** The bump script may fail if non-release files are modified. Always stash:\n- `.beads/` directory (local config)\n- `.claude/` directory (agent settings)\n- Any `.local`, `.env`, or personal config files\n\nAfter release completes, restore with:\n```bash\ngit stash pop\n```\n","status":"closed","priority":2,"issue_type":"task","created_at":"2026-01-12T03:17:16.706064-08:00","updated_at":"2026-01-12T03:18:19.285076-08:00","closed_at":"2026-01-12T03:18:19.285076-08:00","close_reason":"Closed","dependencies":[{"issue_id":"bd-wisp-60x","depends_on_id":"bd-wisp-5j5","type":"parent-child","created_at":"2026-01-12T03:17:16.716027-08:00","created_by":"beads/crew/emma"},{"issue_id":"bd-wisp-60x","depends_on_id":"bd-wisp-3ii","type":"blocks","created_at":"2026-01-12T03:17:16.745775-08:00","created_by":"beads/crew/emma"}],"ephemeral":true}
{"id":"bd-wisp-66z","title":"End-of-cycle inbox hygiene","description":"Verify inbox hygiene before ending patrol cycle.\n\n**Step 1: Check inbox state**\n```bash\ngt mail inbox\n```\n\nInbox should contain ONLY:\n- Unprocessed MERGE_READY messages (will process next cycle)\n- Active work items\n\n**Step 2: Archive any stale messages**\n\nLook for messages that were processed but not archived:\n- PATROL: Wake up that was acknowledged → archive\n- HELP/Blocked that was handled → archive\n- MERGE_READY where merge completed but archive was missed → archive\n\n```bash\n# For each stale message found:\ngt mail archive \u003cmessage-id\u003e\n```\n\n**Step 3: Check for orphaned MR beads**\n\nLook for open MR beads with no corresponding branch:\n```bash\nbd list --type=merge-request --status=open\n```\n\nFor each open MR bead:\n1. Check if branch exists: `git ls-remote origin refs/heads/\u003cbranch\u003e`\n2. If branch gone, verify work is on main: `git log origin/main --oneline | grep \"\u003csource_issue\u003e\"`\n3. If work on main → close MR with reason \"Merged (verified on main)\"\n4. If work NOT on main → investigate before closing:\n - Check source_issue validity (should be gt-xxxxx, not branch name)\n - Search reflog/dangling commits if possible\n - If unverifiable, close with reason \"Unverifiable - no audit trail\"\n - File bead if this indicates lost work\n\n**NEVER close an MR bead without verifying the work landed or is unrecoverable.**\n\n**Goal**: Inbox should have ≤3 active messages at end of cycle.\nKeep only: pending MRs in queue.","status":"closed","priority":2,"issue_type":"task","created_at":"2026-01-12T02:44:24.392901-08:00","updated_at":"2026-01-12T16:43:53.779102-08:00","closed_at":"2026-01-12T16:43:53.779102-08:00","close_reason":"Inbox clear, 0 messages","dependencies":[{"issue_id":"bd-wisp-66z","depends_on_id":"bd-wisp-ec4","type":"parent-child","created_at":"2026-01-12T02:44:24.402169-08:00","created_by":"beads/refinery"}],"ephemeral":true}
{"id":"bd-wisp-66z","title":"End-of-cycle inbox hygiene","description":"Verify inbox hygiene before ending patrol cycle.\n\n**Step 1: Check inbox state**\n```bash\ngt mail inbox\n```\n\nInbox should contain ONLY:\n- Unprocessed MERGE_READY messages (will process next cycle)\n- Active work items\n\n**Step 2: Archive any stale messages**\n\nLook for messages that were processed but not archived:\n- PATROL: Wake up that was acknowledged → archive\n- HELP/Blocked that was handled → archive\n- MERGE_READY where merge completed but archive was missed → archive\n\n```bash\n# For each stale message found:\ngt mail archive \u003cmessage-id\u003e\n```\n\n**Step 3: Check for orphaned MR beads**\n\nLook for open MR beads with no corresponding branch:\n```bash\nbd list --type=merge-request --status=open\n```\n\nFor each open MR bead:\n1. Check if branch exists: `git ls-remote origin refs/heads/\u003cbranch\u003e`\n2. If branch gone, verify work is on main: `git log origin/main --oneline | grep \"\u003csource_issue\u003e\"`\n3. If work on main → close MR with reason \"Merged (verified on main)\"\n4. If work NOT on main → investigate before closing:\n - Check source_issue validity (should be gt-xxxxx, not branch name)\n - Search reflog/dangling commits if possible\n - If unverifiable, close with reason \"Unverifiable - no audit trail\"\n - File bead if this indicates lost work\n\n**NEVER close an MR bead without verifying the work landed or is unrecoverable.**\n\n**Goal**: Inbox should have ≤3 active messages at end of cycle.\nKeep only: pending MRs in queue.","status":"open","priority":2,"issue_type":"task","created_at":"2026-01-12T02:44:24.392901-08:00","updated_at":"2026-01-12T02:44:24.392901-08:00","dependencies":[{"issue_id":"bd-wisp-66z","depends_on_id":"bd-wisp-ec4","type":"parent-child","created_at":"2026-01-12T02:44:24.402169-08:00","created_by":"beads/refinery"}],"ephemeral":true}
{"id":"bd-wisp-6fb","title":"Check refinery mail","description":"Check mail for MERGE_READY submissions, escalations, and messages.\n\n```bash\ngt mail inbox\n```\n\nFor each message:\n\n**MERGE_READY**:\nA polecat's work is ready for merge. Extract details and track for processing.\n\n```bash\n# Parse MERGE_READY message body:\n# Branch: \u003cbranch\u003e\n# Issue: \u003cissue-id\u003e\n# Polecat: \u003cpolecat-name\u003e\n# MR: \u003cmr-bead-id\u003e\n# Verified: clean git state, issue closed\n\n# Track in your merge queue for this patrol cycle:\n# - Branch name\n# - Issue ID\n# - Polecat name (REQUIRED for MERGED notification)\n# - MR bead ID (REQUIRED for closing after merge)\n```\n\n**IMPORTANT**: You MUST track the polecat name, MR bead ID, AND message ID - you will need them\nin merge-push step to send MERGED notification, close the MR bead, and archive the mail.\n\nMark as read. The work will be processed in queue-scan/process-branch.\n**Do NOT archive yet** - archive after merge/reject decision in merge-push step.\n\n**PATROL: Wake up**:\nWitness detected MRs waiting but refinery idle. Acknowledge and archive:\n```bash\ngt mail archive \u003cmessage-id\u003e\n```\n\n**HELP / Blocked**:\nAssess and respond. If you can't help, escalate to Mayor.\nArchive after handling:\n```bash\ngt mail archive \u003cmessage-id\u003e\n```\n\n**HANDOFF**:\nRead predecessor context. Check for in-flight merges.\nArchive after absorbing context:\n```bash\ngt mail archive \u003cmessage-id\u003e\n```\n\n**Hygiene principle**: Archive messages after they're fully processed.\nKeep only: pending MRs in queue. Inbox should be near-empty.","status":"closed","priority":2,"issue_type":"task","created_at":"2026-01-12T00:34:44.778123-08:00","updated_at":"2026-01-12T00:34:59.807466-08:00","closed_at":"2026-01-12T00:34:59.807466-08:00","close_reason":"No messages in inbox","ephemeral":true}
{"id":"bd-wisp-75s","title":"mol-refinery-patrol","description":"Merge queue processor patrol loop.\n\nThe Refinery is the Engineer in the engine room. You process polecat branches, merging them to main one at a time with sequential rebasing.\n\n**The Scotty Test**: Before proceeding past any failure, ask yourself: \"Would Scotty walk past a warp core leak because it existed before his shift?\"\n\n## Merge Flow\n\nThe Refinery receives MERGE_READY mail from Witnesses when polecats complete work:\n\n```\nWitness Refinery Git\n │ │ │\n │ MERGE_READY │ │\n │─────────────────────────\u003e│ │\n │ │ │\n │ (verify branch) │\n │ │ fetch \u0026 rebase │\n │ │──────────────────────────\u003e│\n │ │ │\n │ (run tests) │\n │ │ │\n │ (if pass) │\n │ │ merge \u0026 push │\n │ │──────────────────────────\u003e│\n │ │ │\n │ MERGED │ │\n │\u003c─────────────────────────│ │\n │ │ │\n```\n\nAfter successful merge, Refinery sends MERGED mail back to Witness so it can\ncomplete cleanup (nuke the polecat worktree).","status":"open","priority":2,"issue_type":"epic","created_at":"2026-01-12T01:30:34.393395-08:00","updated_at":"2026-01-12T01:30:34.393395-08:00","ephemeral":true}
{"id":"bd-wisp-7qw","title":"Push to main","description":"Push the release commit to origin.\n\n```bash\ngit push origin main\n```\n\nIf rejected, someone else pushed. Pull, rebase, try again.\n","status":"closed","priority":2,"issue_type":"task","created_at":"2026-01-06T20:07:32.257955-08:00","updated_at":"2026-01-06T20:12:28.230572-08:00","closed_at":"2026-01-06T20:12:28.230572-08:00","close_reason":"Pushed to main","dependencies":[{"issue_id":"bd-wisp-7qw","depends_on_id":"bd-wisp-cf3","type":"blocks","created_at":"2026-01-06T20:07:32.279279-08:00","created_by":"beads/crew/dave"}]}