Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix(g6): census rows for the moved concept write and the batched entity metadata writes; tag the import census source reads (GBRA-60)

garrytan6b0ed2eeacaf
diff --git a/docs/architecture/canonical-writers.tsv b/docs/architecture/canonical-writers.tsv
index 362788e370..9632df9387 100644
--- a/docs/architecture/canonical-writers.tsv
+++ b/docs/architecture/canonical-writers.tsv
@@ -202,7 +202,8 @@ src/core/persistence/connector-google-receipts.ts 1 coordinator Account and mess
src/core/persistence/purge-deleted.ts 3 coordinator Unmanaged brains keep the engine bulk purge; a managed brain purges each expired tombstone through submitPageMutation delete_page purge bound to its revision. The second engine reference is the dry-run count for the D6 consent request (#6114), read-only. W1 (BELIEF_LEDGER.md 6.5): the third reference is the unmanaged per-tombstone expiry for sources the belief ledger records; it deletes one expired tombstone under its page key inside a belief batch (page.expired), the same retention rule as the bulk purge.
src/core/persistence/unbound-source.ts 1 coordinator Stamps the durable unbound_source classification on a page inside the coordinator publication transaction that published it; the column is not a canonical content column.
src/core/persistence/detached-pages.ts 1 coordinator #6609 restore --detach: clears source_path and stamps database_only_reason='detached' on the restored page only from classifyUnboundPage inside the restore_page coordinator publication transaction; neither is a canonical content column.
-src/core/cycle/synthesize-concepts.ts 2 coordinator A managed brain publishes concepts through publishMaintenancePage after maintenancePreflight; the unmanaged importFromContent path refuses on managed brains.
+src/core/cycle/synthesize-concepts.ts 0 coordinator GBRA-60 G6: its concept writes moved to concept-writes.ts.
+src/core/cycle/concept-writes.ts 2 coordinator GBRA-60 G6 (moved from synthesize-concepts.ts): a managed brain publishes concepts through publishMaintenancePages after maintenancePreflight; the unmanaged importFromContent path refuses on managed brains and, for a canonical: git source, refuses with strict_requires_managed before writing.
src/core/cycle/concept-publication.ts 1 coordinator GBRA-161 PR 5 (C-4): replaceConceptProvenanceLinks retires the concept-provenance edges of atoms that left a republished concept's group and banks the new edges in one transaction, coordinated (withCoordinatedWrite) on a managed brain, and only while the concept is still at the revision its publication produced.
src/core/cycle/synthesize-verify.ts 2 early_refusal Legacy direct content import. Direct importFromContent calls without prepare refuse on managed brains before any write (assertUnmanagedCanonicalWriter).
src/core/persistence/reconcile-prepare.ts 3 coordinator Coordinated preparation module. Its importFromContent calls carry prepare and run inside the coordinator publication. The reconcile publication callback records the slug-derived source_path of a database-only page (the #5254 unbound collision) inside the admitted put_page transaction, after the pinned preimages and backup verify; it touches only the reconciled page and only while its source_path is still NULL. When the reconciled page gains a canonical origin, the same callback clears its #5254 unbound_source classification.
diff --git a/docs/architecture/coordinated-writes.tsv b/docs/architecture/coordinated-writes.tsv
index 9fc43d0933..f1f1dde1f9 100644
--- a/docs/architecture/coordinated-writes.tsv
+++ b/docs/architecture/coordinated-writes.tsv
@@ -9,7 +9,7 @@
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/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 coordinated 1 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.
+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.
src/core/facts/purge.ts submitPurgeFactMutation 1 facts_lane purge_fact physical erasure waits on the G4 product ruling (erasure versus git history, GBRA-190); until then it stays a database write paired with its mirror commit.
src/core/mentions/pass.ts aliasWrite 1 projection Mention-pass alias and mention-edge rows are derived from committed page text; a re-run of the pass over the same tree reproduces them.
src/core/ops/chronicle.ts handler 1 facts_lane ontology_propose observations are database-only until G4 (GBRA-190) gives ontology observations a page home.
diff --git a/test/canonical-writer-inventory.test.ts b/test/canonical-writer-inventory.test.ts
index 0b4b6bd965..26ce076d67 100644
--- a/test/canonical-writer-inventory.test.ts
+++ b/test/canonical-writer-inventory.test.ts
@@ -40,15 +40,16 @@ test('a planted bypass in a converted writer or a new file fails the census', ()
const inventory = loadInventory();
// test-reads-source-ok[structural]: the census is a source-text tripwire by design; the planted copy proves it flags a new bypass.
const links = readFileSync(join(root, 'src/core/ops/links.ts'), 'utf8');
- const concepts = readFileSync(join(root, 'src/core/cycle/synthesize-concepts.ts'), 'utf8');
- expect(gapsFor([['src/core/ops/links.ts', links], ['src/core/cycle/synthesize-concepts.ts', concepts]], inventory)).toEqual([]);
+ // G6: the unmanaged concept write moved from synthesize-concepts.ts to concept-writes.ts with its ceiling.
+ const concepts = readFileSync(join(root, 'src/core/cycle/concept-writes.ts'), 'utf8');
+ expect(gapsFor([['src/core/ops/links.ts', links], ['src/core/cycle/concept-writes.ts', concepts]], inventory)).toEqual([]);
expect(gapsFor([
['src/core/ops/links.ts', `${links}\nawait ctx.engine.addLink(a, b, '', '', 'manual');`],
- ['src/core/cycle/synthesize-concepts.ts', `${concepts}\nawait importFromContent(engine, slug, md, { sourceId });`],
+ ['src/core/cycle/concept-writes.ts', `${concepts}\nawait importFromContent(engine, slug, md, { sourceId });`],
['src/core/cycle/new-writer.ts', 'await engine.putPage(slug, page);'],
], inventory)).toEqual([
'src/core/ops/links.ts: 4 write references; reviewed ceiling 3',
- 'src/core/cycle/synthesize-concepts.ts: 3 write references; reviewed ceiling 2',
+ 'src/core/cycle/concept-writes.ts: 3 write references; reviewed ceiling 2',
'src/core/cycle/new-writer.ts: 1 write references; reviewed ceiling 0',
]);
});
diff --git a/test/strict-source-unmanaged-import.test.ts b/test/strict-source-unmanaged-import.test.ts
index c7083a3510..3ecbe92d88 100644
--- a/test/strict-source-unmanaged-import.test.ts
+++ b/test/strict-source-unmanaged-import.test.ts
@@ -83,6 +83,7 @@ function unpreparedGuards(text: string, names: string[]): Record<string, boolean
test('census: every direct import write (importFromContent, importCodeFile, importImageFile, importStreamedMarkdownFile) checks its source before writing', () => {
const names = ['importFromContent', 'importCodeFile', 'importImageFile'];
+ // test-reads-source-ok[structural]: the census is an AST tripwire over the import entry points; planted removals prove it flags a missing guard.
const text = readFileSync(join(root, 'src/core/import-file.ts'), 'utf8');
const fileGuard = "if (!opts.prepare) await assertUnmanagedCanonicalWriter(engine, 'direct file import', { sourceId: opts.sourceId ?? 'default' });";
const lastFileGuard = text.lastIndexOf(fileGuard);
@@ -93,6 +94,7 @@ test('census: every direct import write (importFromContent, importCodeFile, impo
.toEqual({ importFromContent: true, importCodeFile: false, importImageFile: true });
expect(unpreparedGuards(text.slice(0, lastFileGuard) + text.slice(lastFileGuard + fileGuard.length), names))
.toEqual({ importFromContent: true, importCodeFile: true, importImageFile: false });
+ // test-reads-source-ok[structural]: the same census over the streamed import entry point.
const streamed = readFileSync(join(root, 'src/core/page-body/streamed-import.ts'), 'utf8');
expect(unpreparedGuards(streamed, ['importStreamedMarkdownFile'])).toEqual({ importStreamedMarkdownFile: true });
expect(unpreparedGuards(streamed.replace("'direct content import', { sourceId: opts.sourceId ?? 'default' })", "'direct content import')"), ['importStreamedMarkdownFile']))