fix: prevent ZFC resurrection by propagating skipExport flag (with debug)

🤖 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-24 23:57:42 -08:00
parent fd4af85981
commit c6f9f7ee05

View File

@@ -300,16 +300,19 @@ Use --merge to merge the sync branch back to main branch.`,
} }
} }
// Post-pull ZFC check (bd-l0r fix): if DB has significantly more issues // Post-pull ZFC check: if skipExport was set by initial ZFC detection,
// than pulled JSONL, trust JSONL as source of truth and skip re-export. // or if DB has more issues than JSONL, skip re-export.
// This prevents resurrection of deleted issues when syncing stale clones. // This prevents resurrection of deleted issues when syncing stale clones.
skipReexport := false skipReexport := skipExport // Carry forward initial ZFC detection
fmt.Printf("DEBUG: skipExport=%v, skipReexport=%v\n", skipExport, skipReexport)
if !skipReexport {
if err := ensureStoreActive(); err == nil && store != nil { if err := ensureStoreActive(); err == nil && store != nil {
dbCountPostImport, dbErr := countDBIssuesFast(ctx, store) dbCountPostImport, dbErr := countDBIssuesFast(ctx, store)
jsonlCountPostPull, jsonlErr := countIssuesInJSONL(jsonlPath) jsonlCountPostPull, jsonlErr := countIssuesInJSONL(jsonlPath)
if dbErr == nil && jsonlErr == nil && jsonlCountPostPull > 0 { if dbErr == nil && jsonlErr == nil && jsonlCountPostPull > 0 {
if dbCountPostImport > jsonlCountPostPull*2 { // DB has >2x issues // Skip re-export if DB has more issues than JSONL (any amount)
fmt.Printf("→ DB (%d) has >2x more issues than JSONL (%d) after pull\n", if dbCountPostImport > jsonlCountPostPull {
fmt.Printf("→ DB (%d) has more issues than JSONL (%d) after pull\n",
dbCountPostImport, jsonlCountPostPull) dbCountPostImport, jsonlCountPostPull)
fmt.Println("→ Trusting JSONL as source of truth (skipping re-export)") fmt.Println("→ Trusting JSONL as source of truth (skipping re-export)")
fmt.Println(" Hint: Run 'bd import --delete-missing' to fully sync DB with JSONL") fmt.Println(" Hint: Run 'bd import --delete-missing' to fully sync DB with JSONL")
@@ -317,6 +320,7 @@ Use --merge to merge the sync branch back to main branch.`,
} }
} }
} }
}
// Step 4.5: Check if DB needs re-export (only if DB differs from JSONL) // Step 4.5: Check if DB needs re-export (only if DB differs from JSONL)
// This prevents the infinite loop: import → export → commit → dirty again // This prevents the infinite loop: import → export → commit → dirty again