docs: Clarify metadata error handling patterns in init.go

Add detailed comments distinguishing between:
- Configuration metadata (issue_prefix, sync.branch): Pattern A (fatal)
- Tracking metadata (bd_version, repo_id, clone_id): Pattern B (warnings)

The code already followed the correct patterns from ERROR_HANDLING.md,
but lacked explicit documentation explaining WHY different metadata types
use different error handling strategies.

Resolves: bd-b2c
This commit is contained in:
Steve Yegge
2025-11-24 00:33:25 -08:00
parent aeffb8d0ac
commit 836c731cbe

View File

@@ -29,7 +29,7 @@
{"id":"bd-9msn","content_hash":"69ef2ebc5a847eb407c37e9039391d8ebc761a4cee3b60537de4f5a12011bec3","title":"Add monitoring and alerting","description":"Observability for production Agent Mail server.\n\nAcceptance Criteria:\n- Health check endpoint (/health)\n- Prometheus metrics export\n- Grafana dashboard\n- Alerts for server downtime\n- Alerts for high error rate\n- Log aggregation config\n\nFile: deployment/agent-mail/monitoring/","status":"closed","priority":3,"issue_type":"task","created_at":"2025-11-07T22:43:43.354117-08:00","updated_at":"2025-11-23T23:38:56.81073-08:00","closed_at":"2025-11-23T23:38:56.81073-08:00","source_repo":".","dependencies":[{"issue_id":"bd-9msn","depends_on_id":"bd-z3s3","type":"blocks","created_at":"2025-11-07T23:04:28.050074-08:00","created_by":"daemon"}]}
{"id":"bd-afd","content_hash":"fbd5cfa6509144a3650092f743b61f5301926f4086962879290a8478f8dcbcc0","title":"bd doctor --fix should auto-fix metadata.json jsonl_export mismatch","description":"## Root Cause\n\nThe version tracking code (cmd/bd/version_tracking.go:33-38) auto-recreates metadata.json using DefaultConfig() if it doesn't exist. DefaultConfig() hardcodes jsonl_export to 'issues.jsonl', but many repos (including beads itself) use 'beads.jsonl'.\n\nWhen metadata.json goes missing (git clean, merge conflict, rebase, etc.), the next bd command recreates it with the wrong filename, causing a mismatch with the actual JSONL file.\n\n## Impact\n\nThis affects ANY user whose metadata.json gets deleted and who uses a non-default JSONL filename. Normal git operations can trigger this.\n\n## Fix Requirements\n\n1. bd doctor --fix should auto-detect and fix the mismatch (check which .jsonl file exists, update metadata.json)\n2. Version tracking should detect actual JSONL file instead of using hardcoded default\n3. DefaultConfig() should scan for existing .jsonl files before defaulting\n4. Daemon should auto-detect config changes without restart\n\n## Related Code\n\n- internal/configfile/configfile.go:18-23 (DefaultConfig hardcodes issues.jsonl)\n- cmd/bd/version_tracking.go:33-38 (auto-creates config with default) \n- internal/beads/beads.go:245-246 (FindJSONLPath defaults to issues.jsonl)","status":"closed","priority":2,"issue_type":"bug","created_at":"2025-11-23T22:57:34.03414-08:00","updated_at":"2025-11-23T23:11:15.270911-08:00","closed_at":"2025-11-23T23:11:15.270911-08:00","source_repo":"."}
{"id":"bd-b0c8","content_hash":"87b423a42d509b9405b52b089b2ba92b33a90ad472d6d9094986b48715399a99","title":"Research hooks/skills approach for enforcing issue descriptions","description":"## Solution: Hooks/Skills (mentioned in discussion)\n\nResearch the hooks/skills system mentioned by riordanpawley in discussion #366:\nhttps://www.reddit.com/r/ClaudeAI/s/wrn2tjkMHX\n\n## Investigation Tasks\n\n1. Review the Reddit post to understand the approach\n2. Determine if beads hooks can enforce validation\n3. Check if Claude Code skills/hooks can intercept MCP calls\n4. Assess feasibility and user burden\n\n## Notes\n\nFrom discussion #366:\n\u003e I'm using a skills/hooks system to get Claude to do that kind of thing right similar to https://www.reddit.com/r/ClaudeAI/s/wrn2tjkMHX\n\nThis might be a client-side solution rather than server-side.\n\n## Deliverable\n\nDocument findings in issue notes, with recommendation on whether to pursue this approach.","status":"open","priority":3,"issue_type":"task","created_at":"2025-11-23T14:01:01.57079-08:00","updated_at":"2025-11-23T14:01:01.57079-08:00","source_repo":"."}
{"id":"bd-b2c","content_hash":"30cc1cec173c606964f15ebd39d3b2346d37e66ac8613bc43047b876664e249e","title":"Clarify metadata handling in init.go (config vs tracking)","description":"Review init.go:207-228 to ensure configuration metadata (issue_prefix, sync.branch) uses Pattern A consistently, while tracking metadata (bd_version, repo_id, etc.) uses Pattern B. Add comments explaining the distinction.","status":"open","priority":2,"issue_type":"task","created_at":"2025-11-24T00:28:53.199481-08:00","updated_at":"2025-11-24T00:28:53.199481-08:00","source_repo":".","dependencies":[{"issue_id":"bd-b2c","depends_on_id":"bd-1qwo","type":"blocks","created_at":"2025-11-24T00:28:53.200299-08:00","created_by":"daemon"}]}
{"id":"bd-b2c","content_hash":"4628ae4a4e4170cd4b2786b1dac3630acdb8ee84fc15a75a952cb6f4d2bd5c2c","title":"Clarify metadata handling in init.go (config vs tracking)","description":"Review init.go:207-228 to ensure configuration metadata (issue_prefix, sync.branch) uses Pattern A consistently, while tracking metadata (bd_version, repo_id, etc.) uses Pattern B. Add comments explaining the distinction.","status":"closed","priority":2,"issue_type":"task","created_at":"2025-11-24T00:28:53.199481-08:00","updated_at":"2025-11-24T00:33:24.654007-08:00","closed_at":"2025-11-24T00:33:24.654007-08:00","source_repo":".","dependencies":[{"issue_id":"bd-b2c","depends_on_id":"bd-1qwo","type":"blocks","created_at":"2025-11-24T00:28:53.200299-08:00","created_by":"daemon"}]}
{"id":"bd-b55e2ac2","content_hash":"44122b61b1dcd06407ecf36f57577ea72c5df6dc8cc2a8c1b173b37d16a10267","title":"Fix autoimport tests for content-hash collision scoring","description":"## Overview\nThree autoimport tests are failing after bd-cbed9619.4 because they expect behavior based on the old reference-counting collision resolution, but the system now uses deterministic content-hash scoring.\n\n## Failing Tests\n1. `TestAutoImportMultipleCollisionsRemapped` - expects local versions preserved\n2. `TestAutoImportAllCollisionsRemapped` - expects local versions preserved \n3. `TestAutoImportCollisionRemapMultipleFields` - expects specific collision resolution behavior\n\n## Root Cause\nThese tests were written when ScoreCollisions used reference counting to determine which version to keep. Now it uses content-hash comparison (introduced in commit 2e87329), which produces different but deterministic results.\n\n## Example\nOld behavior: Issue with more references would be kept\nNew behavior: Issue with lexicographically lower content hash is kept\n\n## Solution\nUpdate each test to:\n1. Verify the new content-hash based behavior is correct\n2. Check that the remapped issue (not necessarily local/remote) has the expected content\n3. Ensure dependencies are preserved on the correct remapped issue\n\n## Acceptance Criteria\n- All three autoimport tests pass\n- Tests verify content-hash determinism (same collision always resolves the same way)\n- Tests check dependency preservation on remapped issues\n- Test documentation explains content-hash scoring expectations\n\n## Files to Modify\n- `cmd/bd/autoimport_collision_test.go`\n\n## Testing\nRun: `go test ./cmd/bd -run \"TestAutoImport.*Collision\" -v`","status":"closed","priority":2,"issue_type":"task","created_at":"2025-10-28T19:17:28.358028-07:00","updated_at":"2025-11-23T23:20:43.995595-08:00","closed_at":"2025-11-23T23:20:43.995595-08:00","source_repo":"."}
{"id":"bd-bt6y","content_hash":"462f08aa379cf2f196b4c0ca096271fa47ab5e1a18c5663c28d2d86fd02115cf","title":"Improve compact/daemon/merge documentation and UX","description":"Multiple documentation and UX issues encountered:\n1. \"bd compact --analyze\" fails with misleading \"requires SQLite storage\" error when daemon is running. Needs --no-daemon or better error.\n2. \"bd merge\" help text is outdated (refers to 3-way merge instead of issue merging).\n3. Daemon mode purpose isn't clear to local-only users.\n4. Compact/cleanup commands are hard to discover.\n\nProposed fixes:\n- Fix compact+daemon interaction or error message.\n- Update \"bd merge\" help text.\n- Add \"when to use daemon\" section to docs.\n- Add maintenance section to quickstart.\n","status":"open","priority":2,"issue_type":"task","created_at":"2025-11-20T18:55:43.637047-05:00","updated_at":"2025-11-20T18:55:43.637047-05:00","source_repo":"."}
{"id":"bd-bwk2","content_hash":"b69758a5dd9ce7605a61dc6e1fe3e753b87dfc6824c248d6ad56e038d47e77e7","title":"Centralize error handling patterns in storage layer","description":"80+ instances of inconsistent error handling across sqlite.go with mix of %w, %v, and no wrapping.\n\nLocation: internal/storage/sqlite/sqlite.go (throughout)\n\nProblem:\n- Some use fmt.Errorf(\"op failed: %w\", err) - correct wrapping\n- Some use fmt.Errorf(\"op failed: %v\", err) - loses error chain\n- Some return err directly - no context\n- Hard to debug production issues\n- Can't distinguish error types\n\nSolution: Create internal/storage/sqlite/errors.go:\n- Define sentinel errors (ErrNotFound, ErrInvalidID, etc.)\n- Create wrapDBError(op string, err error) helper\n- Convert sql.ErrNoRows to ErrNotFound\n- Always wrap with operation context\n\nImpact: Lost error context; inconsistent messages; hard to debug\n\nEffort: 5-7 hours","status":"open","priority":1,"issue_type":"task","created_at":"2025-11-16T14:51:54.974909-08:00","updated_at":"2025-11-16T14:51:54.974909-08:00","source_repo":"."}