Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
test(sync): classify the plain-directory freshness stamp and move two tests off the old plain-directory refusal (#7973)
garrytan4ee9ff4150df
diff --git a/docs/architecture/canonical-writers.tsv b/docs/architecture/canonical-writers.tsvindex 2c4363aadf..4f622560da 100644--- a/docs/architecture/canonical-writers.tsv+++ b/docs/architecture/canonical-writers.tsv@@ -38,6 +38,7 @@ src/commands/sync/preflight.ts 1 coordinator Managed Markdown sync routes to immsrc/commands/sync/rename-collision.ts 3 coordinator The legacy rename onto an occupied slug (#5431) runs the slug update, the tombstone re-key and the source_path repair in one maintenanceTransaction; a unique violation is classified and any other error fails the file; managed sources route renames through the sync request preparer.src/commands/sync/renames.ts 2 coordinator Managed Markdown sync routes to immutable page requests and an exhausted-cursor checkpoint; unsupported Git pull, code/image and connector paths refuse early. (Refactor wave 1: moved from src/commands/sync.ts.)src/commands/sync/holds.ts 2 coordinator Legacy sync only: a full walk moves the page of a held rename destination that now screens clean (updateSlug plus source_path, same id) before importing it; managed brains route sync to immutable page requests and never reach it.+src/commands/sync/plain-directory.ts 1 coordinator #7973: a plain-directory source (no Git checkout at or above it) imports through runImport, which routes managed pages through the coordinator; the one direct write stamps last_sync_at on its own sources row inside withCoordinatedWrite with maintenance attribution.src/core/agent-install/setup.ts 1 engine_guard Canonical table SQL trigger requires coordinator capability; legacy calls fail before canonical DB publication.src/core/atomic-write.ts 0 filesystem_guard Atomic page replacement checks the managed root before temporary bytes are written.src/core/backfill-effective-date.ts 1 projection Derived indexing, retrieval telemetry, or source settings; canonical fields remain guarded by SQL triggers.diff --git a/docs/architecture/coordinated-writes.tsv b/docs/architecture/coordinated-writes.tsvindex 0787a18a60..c78bb91c38 100644--- a/docs/architecture/coordinated-writes.tsv+++ b/docs/architecture/coordinated-writes.tsv@@ -7,6 +7,7 @@# removal (deletes rows only, moving the database toward git), generated (producer output its producer regenerates),# facts_lane (facts, withdrawals and ontology rows; G4 gives them a file form).src/commands/reindex-aliases.ts derivedWrite 1 projection Rebuilds page_aliases from each page's frontmatter aliases and mention policy; the committed page text is the input, so the indexer reproduces every row.+src/commands/sync/plain-directory.ts performPlainDirectorySync 1 operational A plain-directory sync (#7973) stamps last_sync_at on its own sources row after a clean import; sync bookkeeping, not memory content.src/core/bootstrap/verify.ts removeProbes 1 removal Deletes the verify probe's fence facts after the probe page and its file were purged through the door; it only removes rows whose file is already gone.src/core/cycle/concept-publication.ts replaceConceptProvenanceLinks 1 generated Concept-provenance edges are the synthesis output bound to the concept page revision; the next synthesis regenerates them. G6 moves concept publication through the door.src/core/enrichment-service.ts writeManagedEntities 2 metadata Only trust metadata runs here: the derived-tier lowering of an extract_entities page and of an unknown-tier timeline row. The stub, the timeline bullet and its backlink (the bullet's derived markdown edge) are door mutations of the entity page.diff --git a/test/dream-failed-phase-exit.test.ts b/test/dream-failed-phase-exit.test.tsindex 244abd2400..365ccc7833 100644--- a/test/dream-failed-phase-exit.test.ts+++ b/test/dream-failed-phase-exit.test.ts@@ -5,7 +5,7 @@* contained throw. Any failed phase now exits 1.*/import { afterAll, beforeAll, expect, spyOn, test } from 'bun:test';-import { mkdtempSync, rmSync } from 'node:fs';+import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';import { PGLiteEngine } from '../src/core/pglite-engine.ts';@@ -22,6 +22,8 @@ beforeAll(async () => {await engine.initSchema();home = mkdtempSync(join(tmpdir(), 'gbrain-dream-fail-home-'));notGit = mkdtempSync(join(tmpdir(), 'gbrain-dream-fail-src-'));+ // A broken `.git` entry: sync takes its Git path and fails (a plain directory with no `.git` now imports, #7973).+ writeFileSync(join(notGit, '.git'), '');await engine.executeRaw('INSERT INTO sources(id,name,local_path) VALUES($1,$1,$2)', ['user-notes-example', notGit]);}, 120_000);afterAll(async () => {diff --git a/test/receipt-coverage.test.ts b/test/receipt-coverage.test.tsindex 694ce35dd1..67cd2fb258 100644--- a/test/receipt-coverage.test.ts+++ b/test/receipt-coverage.test.ts@@ -53,6 +53,7 @@ const RECEIPT_COVERAGE: Record<string, Coverage> = {'src/core/persistence/database-write.ts': { sites: 1, tables: [], other: 'manual links and chronicle ontology observations (unguarded tables)' },'src/core/shared-skills/retention.ts': { sites: 1, tables: [], other: 'shared-skill revision retention (unguarded table)' },'src/core/persistence/connector-path.ts': { sites: 1, tables: ['sources'], other: 'clears an unbound connector source local_path (source registration, not knowledge)' },+ 'src/commands/sync/plain-directory.ts': { sites: 1, tables: ['sources'], other: 'the plain-directory sync freshness stamp on its own source row (#7973)' },'src/core/persistence/connector-sync.ts': { sites: 1, tables: ['sources'], other: 'the connector lease freshness stamp on its own source row' },'src/core/persistence/sync-run.ts': { sites: 1, tables: ['sources'], other: 'the managed sync freshness heartbeat on its own source row' },'src/core/persistence/sync-pass-run.ts': { sites: 2, tables: ['sources'], other: 'the pass\'s up-to-date and no-checkpoint freshness stamps (#6712 PR 4b) on its own source row, with the pass row' },diff --git a/test/sync-git-autoinit.test.ts b/test/sync-git-autoinit.test.tsindex 16a14eefc4..82c999737c 100644--- a/test/sync-git-autoinit.test.ts+++ b/test/sync-git-autoinit.test.ts@@ -144,7 +144,7 @@ describe('#2964: sync auto-inits a never-git-initialized default brain dir', ()expect(existsSync(join(dir, '.git'))).toBe(true);});- test('a registered non-default local source (sourceId != default, no remote_url) on a non-git dir still throws — not auto-inited', async () => {+ test('a registered non-default local source (sourceId != default, no remote_url) on a non-git dir is imported without Git (#7973) — not auto-inited', async () => {await engine.executeRaw(`INSERT INTO sources (id, name, local_path, config) VALUES ('mysource', 'mysource', $1, '{}'::jsonb)`,[dir],@@ -158,7 +158,7 @@ describe('#2964: sync auto-inits a never-git-initialized default brain dir', ()noEmbed: true,full: true,}),- ).rejects.toThrow(/git repository/i);+ ).resolves.toMatchObject({ status: 'synced' });expect(existsSync(join(dir, '.git'))).toBe(false);});