Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(sync): mark importErrored on skipped+error rename destinations (#2683) (#4624)
Masa271a707b7feb
diff --git a/scripts/module-size-limits.tsv b/scripts/module-size-limits.tsvindex 4448aa94f6..ae29e95d57 100644--- a/scripts/module-size-limits.tsv+++ b/scripts/module-size-limits.tsv@@ -8,7 +8,7 @@ src/core/operations.ts 316 ratchet peel target: containment sprint C4-C7; grownsrc/core/postgres-engine.ts 5625 ratchet lowered wave-g: #4477 bootstrap peel to src/core/postgres-engine/ modules (ratchet holds the win); +2 on wave-g-prs merge true-up; wave-k: +2 semantic takes retrieval (#3776), +5 NUL-sanitize shared chunk_text local (#3998), +11 getAllConfig bulk read (#3980)src/core/pglite-engine.ts 6110 ratchet grown v0.46.26.0 megawave parity twins + master v0.46.26.0 private-queue columns; +#3754 traverseGraph soft-delete filters; grown wave-g (#4524 #4527): canonical islanded orphans + timestamp-preserving migrate; wave-k: +1 semantic takes retrieval delegate (#3776), +5 NUL-sanitize shared chunk_text local (#3998), +7 getAllConfig bulk read (#3980)src/core/migrate.ts 687 region-exempt append-only MIGRATIONS array grows freely; runner logic is ratcheted — grown v0.46.26.0: repair-handler hooks (#3957 pages-upsert-arbiter); wave-k v142 takes-embedding resize is in-region (renumbered from v141; master consumed v141 for #4482)-src/commands/sync.ts 5652 ratchet grown v0.46.26.0 megawave: image sync, ingest-log gating, dry-run purity, checkpoint honesty (#2683 #4342 #3875) + 3 nosemgrep dataflow annotations (path-traversal audit); +#2683 residual: status-error failure recording at both import sites; +143 wave G #3974: working-tree drift surfacing + opt-in --working-tree import; grown wave-g (#4412 #4543): break-lock ambient source resolution + named failing files; wave-k: #3570 rename-sentinel operator-exit safety (cross-source-scoped resolve, tracked-file liveness index, orphaned-sentinel self-heal) + #4027 --include-hidden dot-prune waiver (threaded into the hoisted syncOpts)+src/commands/sync.ts 5658 ratchet grown v0.46.26.0 megawave: image sync, ingest-log gating, dry-run purity, checkpoint honesty (#2683 #4342 #3875) + 3 nosemgrep dataflow annotations (path-traversal audit); +#2683 residual: status-error failure recording at both import sites; +143 wave G #3974: working-tree drift surfacing + opt-in --working-tree import; grown wave-g (#4412 #4543): break-lock ambient source resolution + named failing files; wave-k: #3570 rename-sentinel operator-exit safety (cross-source-scoped resolve, tracked-file liveness index, orphaned-sentinel self-heal) + #4027 --include-hidden dot-prune waiver (threaded into the hoisted syncOpts); +6 #2683 residual: the rename lane's errored-skip branch now sets importErrored too, closing the gap left when status-error handling was added only for the throw and status='error' casessrc/core/ai/gateway.ts 4568 ratchet grown v0.46.26.0 megawave: config-plane probes + halt telemetry (#3387 #4312); +21 lines (OpenAI Responses API reasoning-item echo: ChatBlock 'reasoning' variant, chat()/toModelMessages() round-trip); wave-k absorbs: OCR routing seam (#4107 class), config-snapshot reader block (#3980)src/cli.ts 3777 ratchet grown v0.46.26.0 megawave: SIGCHLD reaper install, silent-failure surfacing, confirm-race gate (#2443 #2898 #2297); grown wave-g (#4488 #4508): in-band error exit codes + think --source validation; +chat-connectors wiring; wave-k +24 for #4083 auth self-help entry + top-level auth usage lines + takes self-help branchsrc/core/cycle.ts 3186 ratchet grown v0.46.26.0 megawave (#4102 #2608) + master v0.46.26.0 cycle-start orphan recovery; +10 wave G #3974: cycle-sync uncommitted-drift warn; grown wave-g (#4416): synthesize_concepts source threading (same fix absorbed as #4417 on wave-k)diff --git a/src/commands/sync.ts b/src/commands/sync.tsindex 4ee86e915b..8084f0c4cf 100644--- a/src/commands/sync.ts+++ b/src/commands/sync.ts@@ -2753,6 +2753,12 @@ async function performSyncInner(engine: BrainEngine, opts: SyncOpts): Promise<Sy// import; counting it as a failure would gate the bookmark forever.serr(` Skipped (malformed filename): ${sanitizePathForDisplay(to)}`);} else if (result.status === 'skipped' && (result as { error?: string }).error) {+ // An errored skip (frontmatter slug-authority rejection, invalid+ // YAML, symlink refusal, oversize file, ...) means the+ // destination never materialized — same as status 'error' below,+ // this must gate the success sentinel + markCompleted(to), or a+ // resumed sync would treat the rename as permanently done.+ importErrored = true;failedFiles.push({ path: to, error: String((result as { error?: string }).error) });} else if (result.status === 'error') {// importImageFile (and importFile's frontmatter gate) reportdiff --git a/test/sync-rename-reconcile.serial.test.ts b/test/sync-rename-reconcile.serial.test.tsindex 5e4d2ea350..6f9d55aece 100644--- a/test/sync-rename-reconcile.serial.test.ts+++ b/test/sync-rename-reconcile.serial.test.ts@@ -2485,3 +2485,57 @@ describe('#3583 review: GATE25 — the upgrade path for someone already wedged b)).toHaveLength(1);});});++describe('rename destination import: an errored skip must not checkpoint the rename as done', () => {+ test('a frontmatter slug-authority rejection at the destination is retried, never falsely checkpointed', async () => {+ const { performSync } = await import('../src/commands/sync.ts');+ const repo = mkRepo({ 'people/alpha.md': personMd('Alpha', 'Alpha is a person.') });+ await performSync(engine, { repoPath: repo, ...SYNC_OPTS });+ expect(await engine.getPage('people/alpha')).not.toBeNull();++ // Rename alpha -> beta, but the destination's frontmatter claims a slug+ // that does not match its path. importFile enforces slug authority (the+ // path on disk is the source of truth) and rejects this, returning+ // status 'skipped' with an .error set — never status 'error'. Title/body+ // stay byte-identical to alpha (only a `slug:` line is injected) so+ // git's similarity-based rename detection still classifies this as a+ // RENAME rather than a delete+add (a rewritten body drops similarity+ // below git's threshold and takes a completely different code path).+ execSync('git mv people/alpha.md people/beta.md', { cwd: repo, stdio: 'pipe' });+ writeFileSync(join(repo, 'people/beta.md'), [+ '---', 'type: person', 'title: Alpha', 'slug: totally-different', '---',+ '', 'Alpha is a person.',+ ].join('\n'));+ execSync('git add -A && git commit -m "rename alpha to beta, corrupted frontmatter"', {+ cwd: repo, stdio: 'pipe',+ });++ const first = await performSync(engine, { repoPath: repo, ...SYNC_OPTS });+ expect(first.status).toBe('blocked_by_failures');+ // The cheap DB-level rename (updateSlug) runs unconditionally before+ // content import is attempted, so the row is already named 'people/beta'+ // — but its content is untouched (import never wrote anything for the+ // rejected file): compiled_truth still reads the pre-rename body.+ const afterFirst = await engine.getPage('people/beta');+ expect(afterFirst).not.toBeNull();+ expect(afterFirst?.compiled_truth).toBe('Alpha is a person.');++ // Discriminating assertion: without importErrored gating the checkpoint,+ // run 1 falsely marks `to` as done despite the recorded failure, so this+ // SECOND run (same still-rejected content) would read "already done" and+ // report success without ever having imported the destination. The fix+ // makes this run fail again, identically to the first — the checkpoint+ // is never falsely marked, so compiled_truth still has not moved.+ const second = await performSync(engine, { repoPath: repo, ...SYNC_OPTS });+ expect(second.status).toBe('blocked_by_failures');+ expect((await engine.getPage('people/beta'))?.compiled_truth).toBe('Alpha is a person.');++ // Fixing the content and re-syncing must actually materialize the fixed+ // content — proving the target was never falsely banked as complete.+ writeFileSync(join(repo, 'people/beta.md'), personMd('Alpha', 'Alpha is a person, fixed.'));+ execSync('git add -A && git commit -m "fix beta frontmatter"', { cwd: repo, stdio: 'pipe' });+ const third = await performSync(engine, { repoPath: repo, ...SYNC_OPTS });+ expect(third.status).toBe('synced');+ expect((await engine.getPage('people/beta'))?.compiled_truth).toBe('Alpha is a person, fixed.');+ });+});