fix(bd-53c): Add reverse ZFC check to prevent stale DB from corrupting JSONL

Root cause: bd sync exports DB to JSONL BEFORE pulling from remote.
If the local DB is stale (fewer issues than JSONL), the stale data gets
exported and committed, potentially corrupting the remote when pushed.

The existing ZFC (Zero-Fill Check) only detected when DB had MORE issues
than JSONL, missing the dangerous reverse case.

Fix: Added "reverse ZFC" check in sync.go that detects when JSONL has
significantly more issues than DB (>20% divergence or empty DB).
When detected, it imports JSONL first to sync the database before
any export occurs.

This prevents stale/fresh clones from exporting their incomplete
database state over a well-populated JSONL file.

Version bump: 0.26.0 -> 0.26.1

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-11-29 17:01:36 -08:00
parent 5a0d6db4dd
commit 340016c9c6
4 changed files with 53 additions and 27 deletions

View File

@@ -43,6 +43,8 @@ func exportToJSONLWithStore(ctx context.Context, store storage.Storage, jsonlPat
}
// Safety check: prevent exporting empty database over non-empty JSONL
// Note: The main bd-53c protection is in sync.go's reverse ZFC check which runs BEFORE export.
// Here we only block the most catastrophic case (empty DB) to allow legitimate deletions.
if len(issues) == 0 {
existingCount, err := countIssuesInJSONL(jsonlPath)
if err != nil {