fix(sync): reconcile sync-failures.jsonl with reality#479
Conversation
492c88d to
d6485fc
Compare
|
Rebased onto v0.26.0 (3c032d7). Squashed in a fixup that aligns the two new Verified on production brain — schema v32, all sync paths working. |
d6485fc to
436a8fc
Compare
436a8fc to
0ad309e
Compare
Bug 9 follow-up. v0.31 already shipped acknowledgeSyncFailures + the `--skip-failed`/`--retry-failed` operator workflows, but the JSONL was still append-only between cycles: a file that legitimately succeeded on a later attempt stayed listed as failed forever, padding doctor noise and confusing operators. resolveSyncFailure(path) drops every entry for that path (or removes the file when the last entry is cleared), and now fires from: - gbrain import — on successful import and on hash-identical skip - gbrain sync — on delete (file gone), on rename (both from + to), on per-file import success, on per-file hash-identical skip Same read-modify-write concurrency caveat as acknowledgeSyncFailures — sync vs autopilot races are still possible, both writers are idempotent on retry, and failures are rare enough that this isn't worth a lock. 4 new tests in sync-failures.test.ts cover removal-with-count, no-op on unmatched path, last-entry file deletion, and absent-file case.
0ad309e to
f06ffcb
Compare
|
Thanks for this contribution — and apologies for the slow triage. We did a full pass over the entire PR backlog. gbrain has moved fast, and the maintainer's larger "cathedral" rewrites have superseded a big share of community PRs: the AI gateway + recipes + user_provided_models system replaced almost all individual provider PRs; #1805 fixed the whole Postgres module-singleton class; #1542 unified the type taxonomy; #1657 the retrieval path; #1802 the doctor; and so on. We're closing this one in that cleanup — either the fix already landed on master, it duplicates another PR or merged change, or it's outside the current merge bar. Where a closed PR carried a genuinely valuable idea, we've recorded it in docs/designs/COMMUNITY_IDEAS.md so nothing good is lost (a few may graduate into TODOs). Please don't read the close as a judgment of the work — thank you for contributing. If you believe the underlying issue is still live on the latest master, reopen with a quick note and we'll take another look. 🙏 |
Summary
Bug 9 follow-up. v0.31 already shipped
acknowledgeSyncFailures+ the--skip-failed/--retry-failedoperator workflows, but the JSONL was still append-only between cycles: a file that legitimately succeeded on a later attempt stayed listed as failed forever, padding doctor noise and confusing operators.Tight on scope after rebase to v0.32.0 — this PR now only adds the missing reconciliation primitive and its call sites. The empty-diff
--retry-failed/--skip-failedfallthrough is already on master from upstream's own work, so this branch no longer touches that surface.Real-world trigger
A brain with CJK-named pages hit a transient parse failure on 2026-04-27, recorded 6 entries to
~/.gbrain/sync-failures.jsonl, then self-healed in the DB through a subsequentput_pageflow — but the JSONL kept those 6 entries forever. Everygbrain doctorrun flagged them as broken even though the underlying error (Invalid slug: ""from pre-#115 CJK slugify) no longer occurs.Changes
src/core/sync.ts: newresolveSyncFailure(path: string): number. Removes all JSONL entries by path; unlinks the file when the last entry clears. Same read-modify-write concurrency caveat asacknowledgeSyncFailures(documented inline).src/commands/import.ts: on successful import and on hash-identical skip, callsresolveSyncFailure(relativePath).src/commands/sync.ts: same primitive fires fromdeletes(file gone),renames(bothfrom+to), and the per-file import success / hash-identical skip paths insideimportOnePath.test/sync-failures.test.ts: 4 new cases — removal-with-count, no-op on unmatched path, last-entry file deletion, absent-file return-zero.Test plan
bun test test/sync-failures.test.ts— 45/45 passbun run typecheckclean (after freshbun installto drop stale lock entries)0ad309e) — clean apply, no conflicts after the scope reductionNote on prior scope
This PR was originally larger (8 tests, ~250 lines) and included the
--retry-failedfallthrough at thelastCommit === headCommitearly return. Upstream landed that exact handling independently before v0.32.0, so the rebased version drops the overlap and ships only the missing reconciliation hook.🤖 Generated with Claude Code