bd daemon sync: 2026-01-12 02:43:42

This commit is contained in:
beads/refinery
2026-01-12 02:43:42 -08:00
committed by Steve Yegge
parent 47c19515f3
commit b1b07c8af6

View File

@@ -1042,6 +1042,7 @@
{"id":"bd-dow9","title":"Improve CheckStaleness error handling","description":"## Problem\n\nCheckStaleness returns 'false' (not stale) for multiple error conditions instead of returning errors. This masks problems.\n\n**Location:** internal/autoimport/autoimport.go:253-285\n\n## Edge Cases That Return False\n\n1. **Invalid last_import_time format** (line 259-262)\n - Corrupted metadata returns 'not stale'\n - Could show stale data\n\n2. **No JSONL file found** (line 267-277)\n - If glob fails, falls back to 'issues.jsonl'\n - If that's empty, returns 'not stale'\n\n3. **JSONL stat fails** (line 279-282)\n - Permission denied, file missing\n - Returns 'not stale' even though can't verify\n\n## Current Code\n\n```go\nlastImportTime, err := time.Parse(time.RFC3339, lastImportStr)\nif err \\!= nil {\n return false, nil // ← Should return error\n}\n\n// ...\n\nif jsonlPath == \"\" {\n return false, nil // ← Should return error\n}\n\nstat, err := os.Stat(jsonlPath)\nif err \\!= nil {\n return false, nil // ← Should return error\n}\n```\n\n## Fix\n\n```go\nlastImportTime, err := time.Parse(time.RFC3339, lastImportStr)\nif err \\!= nil {\n return false, fmt.Errorf(\"corrupted last_import_time: %w\", err)\n}\n\n// ...\n\nif jsonlPath == \"\" {\n return false, fmt.Errorf(\"no JSONL file found\")\n}\n\nstat, err := os.Stat(jsonlPath)\nif err \\!= nil {\n return false, fmt.Errorf(\"cannot stat JSONL: %w\", err)\n}\n```\n\n## Impact\nMedium - edge cases are rare but should be handled\n\n## Effort \n30 minutes - requires updating callers in RPC server\n\n## Dependencies\nRequires: bd-n4td (warning on errors)","status":"closed","priority":2,"issue_type":"bug","created_at":"2025-11-20T20:16:45.658965-05:00","updated_at":"2025-12-14T00:32:11.049429-08:00","closed_at":"2025-12-13T23:32:56.573608-08:00"}
{"id":"bd-dp4w","title":"Test message","description":"This is a test message body","status":"tombstone","priority":2,"issue_type":"message","created_at":"2025-12-16T18:11:58.467876-08:00","updated_at":"2025-12-17T16:11:17.070763-08:00","deleted_at":"2025-12-17T16:11:17.070763-08:00","deleted_by":"batch delete","delete_reason":"batch delete","original_type":"message"}
{"id":"bd-dpbm","title":"Test no validate","description":"Quick capture","status":"closed","priority":2,"issue_type":"bug","created_at":"2026-01-01T19:24:58.637574-08:00","created_by":"beads/polecats/opal","updated_at":"2026-01-01T19:25:09.044121-08:00","closed_at":"2026-01-01T19:25:09.044121-08:00","close_reason":"Test issue cleanup"}
{"id":"bd-dpij0","title":"Session ended: gt-beads-crew-emma","status":"closed","priority":2,"issue_type":"event","owner":"steve.yegge@gmail.com","created_at":"2026-01-12T02:43:41.92036-08:00","created_by":"beads/crew/emma","updated_at":"2026-01-12T02:43:41.980821-08:00","closed_at":"2026-01-12T02:43:41.980821-08:00","close_reason":"auto-closed session cost wisp","ephemeral":true}
{"id":"bd-dpkdm","title":"Add AllowStale option to beads List API for resilient GUPP detection","description":"## Problem\n\nWhen the beads database is out of sync with the JSONL file (common after another agent syncs), `bd list` fails with \"Database out of sync with JSONL\". This causes `checkSlungWork()` in gastown's `gt prime` to silently fail, which means:\n\n1. AUTONOMOUS WORK MODE is never shown\n2. Normal startup directive is displayed instead\n3. Agents follow that instead of GUPP\n4. **Hooked work sits idle - massive GUPP violation**\n\nRoot cause: Commit 1da3e18 made staleness checks stricter, and `checkSlungWork()` silently returns false on error.\n\n## Solution\n\nImplement a resilient three-layer approach:\n\n### Step 1: Add AllowStale to ListOptions (beads)\n- Add `AllowStale bool` field to `ListOptions` struct\n- Update `List()` to pass `--allow-stale` flag when set\n\n### Step 2: Update checkSlungWork in gastown\n- Try quick `bd sync --import-only` first (best effort)\n- Try normal list\n- If error, log warning and retry with `AllowStale: true`\n- Only return false if both attempts fail\n\n### Step 3: Never fail silently\n- Always log errors instead of silent `return false`\n\n## Concurrency Note\n\nMultiple workers may spin up and try `bd sync` simultaneously. SQLite's own locking serializes writes, so this is safe but potentially slow. No additional mutex needed for correctness.\n\n## Files to Change\n\n**In beads:**\n- `internal/beads/beads.go` - Add AllowStale to ListOptions, update List()\n\n**In gastown (separate PR):**\n- `internal/cmd/prime.go` - Update checkSlungWork() with resilient logic\n\n## Testing\n- Simulate stale DB by modifying JSONL without importing\n- Verify AUTONOMOUS MODE shows with AllowStale fallback\n- Test concurrent worker startup","status":"closed","priority":1,"issue_type":"epic","assignee":"beads/crew/dave","created_at":"2026-01-09T00:36:54.636297-08:00","created_by":"gastown/crew/george","updated_at":"2026-01-09T00:42:33.462367-08:00","closed_at":"2026-01-09T00:42:33.462367-08:00","close_reason":"Implemented AllowStale option in List API - added to ListArgs struct and CLI passthrough. Daemon already handles staleness gracefully. Gastown step 2 pending separately."}
{"id":"bd-dq74","title":"bd repair: Handle .beads/redirect files","description":"The bd repair command hardcodes .beads/beads.db path but doesn't follow .beads/redirect files like other commands do. This means repair won't work on clones that use redirected beads directories.\n\nFix: Check for .beads/redirect file and follow it to find the actual database location.","status":"closed","priority":2,"issue_type":"bug","created_at":"2025-12-29T12:47:53.089729-08:00","created_by":"stevey","updated_at":"2025-12-29T12:59:05.121303-08:00","closed_at":"2025-12-29T12:59:05.121303-08:00","close_reason":"Fixed in commit d7a67ad6"}
{"id":"bd-dq8pu","title":"Session ended: gt-beads-refinery","status":"closed","priority":2,"issue_type":"event","owner":"steve.yegge@gmail.com","created_at":"2026-01-11T22:58:53.861683-08:00","created_by":"beads/refinery","updated_at":"2026-01-11T22:58:53.906534-08:00","closed_at":"2026-01-11T22:58:53.906534-08:00","close_reason":"auto-closed session cost wisp","ephemeral":true}