Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
test: excludesFile and include edges of the ignore filter; a code or segmented page reparses under a full episode
garrytaneea24a7e5ced
diff --git a/test/ignore-rules.test.ts b/test/ignore-rules.test.tsindex e44d9c213d..d6feebf58a 100644--- a/test/ignore-rules.test.ts+++ b/test/ignore-rules.test.ts@@ -190,4 +190,43 @@ describe('ignore filter', () => {git(root, 'update-index', '--no-split-index');expect(await ignoreCandidates(root, ['notes/new.md'])).toEqual([]);}));++ // Generated by /ship Step 7 coverage audit (gstack), test-only.+ // Value: protects=a checkout whose branch switches into an includeIf onbranch config that sets core.excludesFile is probed again, so Git+ // decides the path; fails_when=the probe stops watching HEAD, so a cached probe clears a path Git now ignores; why_new=only config-file edits+ // invalidate the probe in the tests above; seam=none; no_claim=includeIf gitdir conditions are not exercised+ test('switching onto a branch whose includeIf onbranch config sets core.excludesFile is seen on the next call', hermetic(async () => {+ const root = repo();+ put(root, 'notes/a.md');+ git(root, 'add', '-A'); git(root, 'commit', '-qm', 'seed');+ const excludes = join(root, '.git', 'branch-excludes');+ writeFileSync(excludes, '*.md\n');+ writeFileSync(join(root, '.git', 'feature.gitconfig'), `[core]\n\texcludesFile = ${excludes}\n`);+ git(root, 'config', 'includeIf.onbranch:feature.path', 'feature.gitconfig');+ expect(await ignoreCandidates(root, ['notes/new.md'])).toEqual([]);+ git(root, 'checkout', '-q', '-b', 'feature');+ expect(gitIgnored(root, ['notes/new.md'])).toEqual(new Set(['notes/new.md']));+ expect(await ignoreCandidates(root, ['notes/new.md'])).toEqual(['notes/new.md']);+ git(root, 'checkout', '-q', 'main');+ expect(await ignoreCandidates(root, ['notes/new.md'])).toEqual([]);+ }));++ // Generated by /ship Step 7 coverage audit (gstack), test-only.+ // Value: protects=a relative core.excludesFile, or an include path whose expansion the filter does not reproduce, leaves every path to Git;+ // fails_when=a relative excludesFile is resolved beside the config file instead of left to Git, or an unresolved include stops marking the probe undecidable;+ // why_new=only absolute excludesFile and include paths are tested; seam=none; no_claim=the %(prefix) include names no real file+ test('a relative core.excludesFile or an include path the filter cannot expand leaves Git to decide', hermetic(async () => {+ const root = repo();+ put(root, 'notes/a.md');+ git(root, 'add', '-A'); git(root, 'commit', '-qm', 'seed');+ expect(await ignoreCandidates(root, ['notes/new.md'])).toEqual([]);+ put(root, 'personal-ignore', '*.md\n');+ git(root, 'config', 'core.excludesFile', 'personal-ignore');+ expect(gitIgnored(root, ['notes/new.md'])).toEqual(new Set(['notes/new.md']));+ expect(await ignoreCandidates(root, ['notes/new.md'])).toEqual(['notes/new.md']);+ git(root, 'config', '--unset', 'core.excludesFile');+ expect(await ignoreCandidates(root, ['notes/new.md'])).toEqual([]);+ git(root, 'config', 'include.path', '%(prefix)/etc/example-included.gitconfig');+ expect(await ignoreCandidates(root, ['notes/new.md'])).toEqual(['notes/new.md']);+ }));});diff --git a/test/sync-pass-episode-in-place.test.ts b/test/sync-pass-episode-in-place.test.tsindex be41b9d2d7..90dbff628c 100644--- a/test/sync-pass-episode-in-place.test.ts+++ b/test/sync-pass-episode-in-place.test.ts@@ -33,7 +33,9 @@ import { SYNC_IMPORT_PROVENANCE_OP, writeGitHold } from '../src/core/persistenceimport { performManagedSync } from '../src/core/persistence/sync-run.ts';import { readShadowLevel } from '../src/core/persistence/sync-pass.ts';import { RECOVERY_VERSION } from '../src/core/markdown.ts';+import { withCoordinatedWrite } from '../src/core/persistence/context.ts';import { managedBrain } from './helpers/managed-brain.ts';+import { TEST_WRITE_ATTRIBUTION } from './helpers/write-attribution.ts';import { testBackends } from './helpers/test-backends.ts';const base: SyncPathState = { mode: 'committed', tree: 'A', level: 'A', present: true, dirty: 'clean', diskOid: null,@@ -143,5 +145,29 @@ for (const backend of testBackends()) {expect((await performManagedSync(engine, { ...OPTS, full: true })).status).toBe('synced');expect(await Promise.all(watermarked.map(async slug => ({ record: await recordOf(engine, slug), requests: await requestsFor(engine, slug) })))).toEqual(before);}));++ // Generated by /ship Step 7 coverage audit (gstack), test-only.+ // Value: protects=an open full episode never admits a non-markdown or segmented page in place: it reparses even when revision, chunker and+ // projection are current; fails_when=readPages' derived_current drops its page_kind or body_storage term; why_new=the full-pass test above+ // covers the chunker, contextual and projection terms only; seam=none; no_claim=page kind and storage are set by SQL on synced pages, not by+ // importing a real code file or a segmented body+ test('a code page or a segmented page is reparsed under a full pass even when its revision, chunker and projection are current', () => brain(async ({ engine }) => {+ expect((await performManagedSync(engine, OPTS)).status).toBe('first_sync');+ const watched = ['notes/current.md', 'notes/contextual.md', 'notes/projection.md'];+ const classes = async (full: boolean) => Object.fromEntries((await readShadowLevel(engine, { sourceId: 'default', full }))!.paths+ .filter(entry => watched.includes(entry.path)).map(entry => [entry.path, entry.result.cls]));+ expect(await classes(true)).toEqual({ 'notes/current.md': 'matched', 'notes/contextual.md': 'matched', 'notes/projection.md': 'matched' });+ await engine.transaction(tx => withCoordinatedWrite(tx, ['default'], async () => {+ await tx.executeRaw("UPDATE pages SET page_kind='code' WHERE source_id='default' AND slug='notes/contextual'");+ await tx.executeRaw("UPDATE pages SET body_storage='segmented', compiled_truth=NULL, timeline=NULL, body_bytes=COALESCE(body_bytes, 1) WHERE source_id='default' AND slug='notes/projection'");+ await tx.executeRaw("UPDATE pages SET text_projection_revision=knowledge_revision WHERE source_id='default' AND slug IN ('notes/contextual', 'notes/projection')");+ }, TEST_WRITE_ATTRIBUTION));+ for (const slug of ['notes/contextual', 'notes/projection']) {+ const [{ revision }] = await engine.executeRaw<{ revision: string }>("SELECT knowledge_revision::text AS revision FROM pages WHERE source_id='default' AND slug=$1", [slug]);+ await setRecord(engine, slug, 'revision', revision);+ }+ expect(await classes(false)).toEqual({ 'notes/current.md': 'matched', 'notes/contextual.md': 'matched', 'notes/projection.md': 'matched' });+ expect(await classes(true)).toEqual({ 'notes/current.md': 'matched', 'notes/contextual.md': 'reparse', 'notes/projection.md': 'reparse' });+ }));});}