Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
test(sync): an open episode re-imports only pages that are not already current
garrytan8270e74b7de0
diff --git a/src/core/persistence/sync-pass.ts b/src/core/persistence/sync-pass.tsindex aa38ac8723..36242c23ed 100644--- a/src/core/persistence/sync-pass.ts+++ b/src/core/persistence/sync-pass.ts@@ -809,8 +809,7 @@ export async function readShadowLevel(engine: BrainEngine, input: { sourceId: stspelling: legacySpelling.has(path) ? 'legacy' : twins.has(path),episodeUnsatisfied: input.pass ? !!input.pass.episodeFullId && live && (record ? pages.fullEpisode[at!] : undefined) !== input.pass.episodeFullId: input.full === true && live,- derivedCurrent: live && pages.derivedCurrent(at!),- fullObligation: input.pass ? !!input.pass.episodeFullId : input.full === true,+ derivedCurrent: live && pages.derivedCurrent(at!), fullObligation: input.pass ? !!input.pass.episodeFullId : input.full === true,keepDb: !mirror && keepDbPrefixes.length > 0 && row && isKeepDbSlug(pages.slug[at!]!, keepDbPrefixes),openWork: row && open.pageIds.has(Number(pages.id[at!])) || open.origins.has(origin),};diff --git a/test/sync-pass-rulings-6712.test.ts b/test/sync-pass-rulings-6712.test.tsindex 734e87aa18..fca2fa89cd 100644--- a/test/sync-pass-rulings-6712.test.ts+++ b/test/sync-pass-rulings-6712.test.ts@@ -200,6 +200,9 @@ describe('#6712 PR 4b classifier rulings (pglite)', () => {[managedCursorKey(incarnation, undefined), JSON.stringify({ sourceId: 'default', incarnation, runId: randomUUID(), index: 1, total: 3, done: false,processingOptions: { noEmbed: true, noExtract: true, noSchemaPack: false }, syncOptions: full ? { full: true } : {} })]);writeFileSync(join(root, 'notes/a.md'), note('notes/a', 'A committed change of notes/a.')); commit(root, 'change a');+ // An episode admits a current page without a reparse (sync-classify.ts `inPlace`); b and c carry a stale contextual+ // mode, which only an open episode re-imports, so a seeded episode shows as their re-import.+ await engine.executeRaw("UPDATE pages SET contextual_retrieval_mode=NULL WHERE source_id='default' AND slug IN ('notes/b','notes/c')");const result = await performManagedSync(engine, { sourceId: 'default', noPull: true });expect(result.status).toBe('synced');expect([...result.inherited_options ?? []].sort()).toEqual(['noEmbed', 'noExtract']);diff --git a/test/sync-pass-shadow-6712.test.ts b/test/sync-pass-shadow-6712.test.tsindex 153252a311..012cb7f1d3 100644--- a/test/sync-pass-shadow-6712.test.ts+++ b/test/sync-pass-shadow-6712.test.ts@@ -140,7 +140,7 @@ describe('#6712 PR 4a convergence shadow (pglite)', () => {expect(committed.counts.import ?? 0).toBe(0);}, { setup }), 120_000);- test('probe 46: a parser change on fileSame ∧ dbSame pages is reparse with zero decisions; --full makes every page reparse', () => managedBrain(async ({ engine }) => {+ test('probe 46: a parser change on fileSame ∧ dbSame pages is reparse with zero decisions; --full makes every page reparse that is not already current', () => managedBrain(async ({ engine }) => {expect((await performManagedSync(engine, SYNC)).status).toBe('first_sync');await engine.executeRaw(`UPDATE op_checkpoints SET completed_keys=jsonb_set(completed_keys, '{0,parser,parser_version}', '"import=0"')WHERE op=$1 AND completed_keys->0->>'origin'='notes/alpha.md'`, [SYNC_IMPORT_PROVENANCE_OP]);@@ -148,6 +148,11 @@ describe('#6712 PR 4a convergence shadow (pglite)', () => {expect(receipt.counts).toEqual({ matched: 2, reparse: 1 });expect(receipt.decisions).toEqual({ both: 0, unknown: 0, deleted: 0 });expect(receipt.samples.reparse![0]).toMatchObject({ path: 'notes/alpha.md', reason: 'parser or schema pack changed', action: 'owner' });+ // A current page satisfies the full obligation in place (sync-classify.ts `inPlace`); one chunked at an older chunker+ // version, which a plain pass leaves matched, is reparsed under --full.+ expect((await shadowConvergence(engine, { sourceId: 'default', full: true }))!.counts).toEqual({ matched: 2, reparse: 1 });+ await engine.executeRaw("UPDATE pages SET chunker_version=chunker_version-1 WHERE source_id='default'");+ expect((await shadowConvergence(engine, { sourceId: 'default' }))!.counts).toEqual({ matched: 2, reparse: 1 });expect((await shadowConvergence(engine, { sourceId: 'default', full: true }))!.counts).toEqual({ reparse: 3 });}, { setup }), 120_000);