v0.34.2.0 fix(import): path-based checkpoint resume — kills parallel-drop + failed-file-skip + sort-flip bugs#988
Merged
Merged
Conversation
…tent Problem: sync processes files in git-diff order (alphabetical), so meetings/2020-* embeds before meetings/2026-*. After a burst of writes, new pages can be invisible to search for hours while older pages process first. Fix: sort addsAndMods descending in both incremental sync and full import. Brain paths are date-prefixed by convention, so lexicographic descending naturally prioritizes recent content. This ensures the most relevant pages become searchable first.
1 task
Replace gbrain import's positional `processedIndex` checkpoint with a path-set checkpoint via `src/core/import-checkpoint.ts`. A file is only "done" when its processFile returns success — failed files never enter the set, parallel workers can't lose slow files, and sort-order changes don't drop the newest N files on resume. Three bug classes fixed: - Parallel import + slow worker = silent file drop on crash-resume - Failed file = checkpoint advanced past it, never retried until manual clear - Sort-order flip (v0.33.x) = cross-version resume drops newest N files Old positional checkpoints are detected on first resume and discarded with a stderr log line. Re-walking is cheap because content_hash short-circuits unchanged files. Also extracts the descending-lex sort into src/core/sort-newest-first.ts so import.ts and sync.ts share a single source of truth. Tests: - test/sort-newest-first.test.ts (5 hermetic cases) - test/import-checkpoint.test.ts (18 unit cases over the helpers) - test/import-resume.test.ts (refactored — GBRAIN_HOME isolation, drives runImport against PGLite, 5 integration cases including SLUG_MISMATCH retry regression) Includes the original sort-newest-first contribution from @garrytan-agents's PR #964 (commit 8dbcf6a).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Add CLAUDE.md Key Files entries for the path-based import checkpoint work: new entries for src/core/import-checkpoint.ts and src/core/sort-newest-first.ts, plus a dedicated src/commands/import.ts entry covering the v0.34.2.0 refactor. Update src/commands/sync.ts entry to reference sortNewestFirst. Regenerate llms-full.txt. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
scripts/check-privacy.sh banlist includes /data/brain/ (legacy private OpenClaw fork layout). New test files must not use it — CI privacy guard caught this on PR #988's first push. No behavior change. test/import-checkpoint.test.ts is unit-level with no fs access; the dir string is just an identity marker for the loadCheckpoint dir-mismatch guard.
# Conflicts: # CHANGELOG.md # VERSION # package.json
garrytan
added a commit
that referenced
this pull request
May 15, 2026
Master shipped v0.34.2.0 (PR #988, path-based import checkpoint). v0.34.2.0 adds no new migrations (only new helper modules src/core/import-checkpoint.ts and src/core/sort-newest-first.ts), so no migration renumber needed this wave — our embed_stale_partial_index stays at v66. Conflict resolutions: - VERSION: take 0.34.4.0 - package.json: take 0.34.4.0 - CHANGELOG.md: collapse the interleaved auto-merge (master's v0.34.2.0 entry got woven into mine on shared "### Itemized changes" / "#### Added" headers). Reconstructed both entries cleanly back-to-back: v0.34.4.0 topmost, then v0.34.2.0, then v0.34.1.0. Updated CHANGELOG references to migration v66 (was inadvertently still "v60" in three spots from the prior wave's prose — corrected here). Typecheck clean. lockfile unchanged (no dep delta). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
brandonlipman
added a commit
to brandonlipman/gbrain
that referenced
this pull request
May 29, 2026
* upstream/master: v0.35.1.0: embedder shootout prereqs (pricing + gateway export + --resume-from) (garrytan#1055) v0.35.0.0 feat: ZeroEntropy zembed-1 + zerank-2 reranker (garrytan#1008) v0.34.4.0 fix(embed): cursor-paginated --stale hardening wave (D2/D3/D4/D6/D7/D8 + regression test) (garrytan#991) v0.34.3.0 fix: supervisor treats code=0 watchdog exits as crashes (garrytan#1003) v0.34.2.0 fix(import): path-based checkpoint resume — kills parallel-drop + failed-file-skip + sort-flip bugs (garrytan#988) v0.34.1.0 fix(mcp): MCP fix wave — source-isolation P0 + PKCE DCR + federated_read + 3 more (garrytan#996) v0.34.0.0 feat: Cathedral III — recursive code intelligence + Leiden clusters + eval gate (garrytan#994) v0.33.3.0 feat(v0.33.3): code intelligence MCP foundation (v0.34 W0a-c + W3) (garrytan#934) v0.33.2.1 docs: fork-PR workflow for garrytan-agents (garrytan#992) fix(sync): raise maxBuffer to 100 MiB to prevent silent ENOBUFS crash (garrytan#982) v0.33.2.0 feat(search-lite): token budget + semantic query cache + intent weighting (garrytan#897) v0.33.1.1 fix: Voyage output_dimension + flexible-dim guard + OOM-cap rethrow (garrytan#962)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Path-based import checkpoint replaces the pre-v0.34.2 positional checkpoint that silently lost files in three scenarios. Started as a cherry-pick of @garrytan-agents's PR #964 (sort files newest-first), expanded after
/plan-eng-review+ codex outside-voice surfaced two pre-existing P1 bugs in the checkpoint model that plan review missed.Three bug classes closed:
processed++fires on completion not dispatch, so 4 workers + slowfiles[0]+ 3 fast completions wroteprocessedIndex=3and crash-resume slicedfiles.slice(3), dropping the slow file silently.errors++; processed++both fire, so a failure pushed the checkpoint past the bad file. Next run skipped it. The "clear on clean exit" guard at line 268 only triggers whenerrors === 0, so a single failure preserved the bad checkpoint indefinitely.slice(processedIndex)dropped the N newest files on the upgrade run.Fix:
src/core/import-checkpoint.tsstores a set of completed relative paths. A file is "done" only whenprocessFilereturns success. Failed files never enter the set. Sort order is irrelevant to checkpoint correctness.Commits:
e4cc46e2feat(import): path-based checkpoint resume + sort-newest-first helperec750f5cchore: bump version and changelog (v0.34.2.0)a66088e3docs: update project documentation for v0.34.2.08dbcf6a5(cherry-picked from PR feat(sync): sort files newest-first for faster salience on recent content #964 — @garrytan-agents)Test Coverage
Tests: 6378 → 6384 (+6 new — 5 sort-helper + 18 checkpoint-helper + 5 integration. Some merged into existing files.)
Parallel-import regression test deferred to E2E (filed as TODO): real-Postgres parallel-mode requires
DATABASE_URLsetup; the unit-levelrunImportintegration tests pin the path-based contract under serial execution. Plan calls this out explicitly.Pre-Landing Review
3 issues found via
/plan-eng-review— all resolved through implementation, not skipped:sortVersionband-aid concern). Superseded by path-based design — sort order no longer matters to checkpoint correctness.runImport.Outside Voice (Codex)
Ran
codex execagainst the draft plan. 5 substantive findings, all absorbed:completed.addcompletedFileswas a count, not a list → dropped that field; new field iscompletedPaths: string[]loadCheckpoint/saveCheckpoint/resumeFilterdirectly~/.gbrain→ wrapped every case inwithEnv({ GBRAIN_HOME: tmpdir() })Cross-model agreement: yes — codex strictly expanded coverage. No unresolved disagreement.
Plan Completion
Plan file:
~/.claude/plans/velvety-sparking-treehouse.md. All actionable items DONE:src/core/sort-newest-first.tscreatedsrc/core/import-checkpoint.tscreated with full APIsrc/commands/import.tsrefactored to path-basedsrc/commands/sync.tsswapped for helpertest/sort-newest-first.test.tscreatedtest/import-checkpoint.test.tscreatedtest/import-resume.test.tsrefactored with GBRAIN_HOME isolationbun run verifyclean,bun run test6384/0/0Deferred (filed in plan as TODOs):
TODOS
No items in TODOS.md were completed by this PR. (Existing TODOs are all v0.33.x functional-area-resolver follow-ups, unrelated to import checkpoints.)
Documentation
CLAUDE.md— added Key Files entries forsrc/core/import-checkpoint.ts(new module:loadCheckpoint/saveCheckpoint/resumeFilter/clearCheckpoint, path-set checkpoint format, atomic.tmp+rename writes, GBRAIN_HOME-aware) andsrc/core/sort-newest-first.ts(single source of truth for the descending-lex sort shared bygbrain importandgbrain sync); new entry forsrc/commands/import.tscovering the v0.34.2.0 positional→path-set checkpoint refactor and the three bug classes it closes (parallel-slow-worker drop, failed-file-skip, sort-flip drop); updatedsrc/commands/sync.tsentry to note the inline.sort()swap forsortNewestFirst(addsAndMods).llms-full.txt— regenerated viabun run build:llms(mandatory chaser per CLAUDE.md auto-derived rule; CI shard 1test/build-llms.test.tsenforces freshness).README.md,TODOS.md— no updates needed (v0.34.2.0 is an internal bug fix with no new user-facing surface or TODO impact).Test plan
bun run verifyclean (typecheck + 12 shell guards, post-merge)bun run test— 6384 pass / 0 fail / 0 skip, ~393s wall time (post-merge)test/import-resume.test.tsPGLite integration cases pass (5/5)~/.gbrainwrites in tests (test-isolation lint clean)bun run test:e2e) — skips gracefully withoutDATABASE_URL; existing sync E2E expected to pass since the sort change is positional, not semantic. Run pre-merge if shipping today.gbrain import, confirm "Older checkpoint format detected" stderr log fires.To take advantage of v0.34.2.0
gbrain upgradehandles this automatically — no manual step. The firstgbrain importafter upgrade against a pre-existing checkpoint will logOlder checkpoint format detected — re-walking (cheap via content_hash)and walk the brain fresh. Re-walk is cheap becausecontent_hashshort-circuits unchanged files.Co-Authored-By: Claude Opus 4.7 noreply@anthropic.com
🤖 Generated with Claude Code