beads/internal
Steve Yegge 9088988edd Improve staleness check error handling and optimization (bd-n4td, bd-o4qy, bd-c4rq)
This commit implements three related improvements to database staleness checking:

**bd-n4td (P2): Add warning when staleness check errors**
- Added stderr warnings when CheckStaleness fails in ensureDatabaseFresh
- Users now see "Warning: could not check database staleness: <error>"
- Provides visibility into staleness check failures while allowing operations to proceed

**bd-o4qy (P2): Improve CheckStaleness error handling**
- Updated CheckStaleness to distinguish between expected and abnormal conditions:
  * Returns (false, nil) for expected "no data yet" scenarios (missing metadata, missing JSONL)
  * Returns (false, err) for abnormal errors (glob failures, permission errors)
- Updated RPC server (2 locations) to log staleness errors but allow requests to proceed
- Prevents blocking operations due to transient staleness check issues
- Added comprehensive function documentation

**bd-c4rq (P3): Refactor staleness check to avoid function call overhead**
- Moved daemon check from inside ensureDatabaseFresh to all 8 call sites
- Avoids unnecessary function call when running in daemon mode
- Updated: list.go, info.go, status.go, show.go, stale.go, duplicates.go, ready.go, validate.go
- Extracted staleness functions to new staleness.go for better organization

**Code review fixes:**
- Removed dead code in CheckStaleness (unreachable jsonlPath == "" check)
- Removed unused ensureDatabaseFreshQuiet function

**Files changed:**
- New: cmd/bd/staleness.go (extracted staleness checking functions)
- Modified: 8 command files (added daemon check before staleness calls)
- Modified: internal/autoimport/autoimport.go (improved error handling)
- Modified: internal/rpc/server_export_import_auto.go (handle errors gracefully)
2025-11-20 20:45:39 -05:00
..
autoimport Improve staleness check error handling and optimization (bd-n4td, bd-o4qy, bd-c4rq) 2025-11-20 20:45:39 -05:00
beads Resolve merge conflict in beads.jsonl 2025-11-20 19:08:23 -05:00
compact Optimize test suite with testing.Short() guards 2025-11-06 17:31:15 -08:00
config Centralize BD_DEBUG logging into internal/debug package 2025-11-06 20:14:34 -08:00
configfile Remove version field from metadata.json 2025-11-08 18:16:39 -08:00
daemon test: improve internal/daemon test coverage to 60% 2025-11-08 01:20:03 -08:00
debug Centralize BD_DEBUG logging into internal/debug package 2025-11-06 20:14:34 -08:00
git Fix branchExists test after signature change 2025-11-02 20:30:31 -08:00
importer Optimize test suite with testing.Short() guards 2025-11-06 17:31:15 -08:00
lockfile Standardize daemon detection with tryDaemonLock probe (bd-wgu4) 2025-11-07 21:02:38 -08:00
merge Annotate gosec-safe file accesses 2025-11-17 10:12:46 -07:00
routing Fix TestRoutingIntegration and improve DetectUserRole robustness 2025-11-20 19:04:42 -05:00
rpc Improve staleness check error handling and optimization (bd-n4td, bd-o4qy, bd-c4rq) 2025-11-20 20:45:39 -05:00
storage Optimize bd list: replace N+1 label queries with bulk fetch 2025-11-20 20:27:09 -05:00
syncbranch Add sync.branch configuration support (bd-b7d2) 2025-11-02 15:37:57 -08:00
testutil Annotate gosec-safe file accesses 2025-11-17 10:12:46 -07:00
types feat: Add ancestor_id field and implement epic/child filtering 2025-11-05 00:44:41 -08:00
util Extract normalizeLabels to internal/util/strings.go 2025-11-06 20:00:08 -08:00
utils fix: improve ResolvePartialID / ResolveID handling for bd show (issue #336) 2025-11-19 05:54:28 -05:00
validation Refactor: Extract duplicated validation logic to internal/validation 2025-11-20 20:39:23 -05:00