Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

docs(inventory): fence-fact-append.ts gains its reviewed write; memory-prepare drops to 2 (G4b)

garrytanf294d1efa25c
diff --git a/docs/architecture/canonical-writers.tsv b/docs/architecture/canonical-writers.tsv
index 46ac07850b..7adb081031 100644
--- a/docs/architecture/canonical-writers.tsv
+++ b/docs/architecture/canonical-writers.tsv
@@ -83,6 +83,7 @@ src/core/enrichment-service.ts 4 coordinator #6262: on a managed brain extract_e
src/core/extract/receipt-writer.ts 1 engine_guard Canonical table SQL trigger requires coordinator capability; legacy calls fail before canonical DB publication.
src/core/extract-timeline-from-meetings.ts 2 coordinator #6273: on a managed brain each entity page's meeting rows publish as one database-only managed_maintenance_meeting_timeline request, re-gated at the meetings' stored tier inside the coordinated apply; the unmanaged batch insert runs in maintenanceTransaction, which the guard refuses on a managed brain.
src/core/facts/backstop.ts 3 engine_guard Canonical table SQL trigger requires coordinator capability; legacy calls fail before canonical DB publication.
+src/core/facts/fence-fact-append.ts 1 coordinator prepareFenceFactAppend (G4) inserts one facts row only inside apply(tx), the coordinator's publication transaction, after the file holding its fence row was published and after the page row; index-existing mode first reads the cell back from the published file and refuses fence_row_changed, so no facts row exists ahead of its fence row.
src/core/facts/fence-write.ts 2 coordinator Managed brains publish fence rows through the managed_facts_entity intent before any file or row write; unmanaged writes keep the source filesystem ownership check before editing canonical fact fences.
src/core/facts/forget.ts 4 filesystem_guard Managed callers journal withdrawal; legacy filesystem helper and the supersession-only expiry require coordinated write.
src/core/facts/ontology-rekey.ts 2 engine_guard B-10 (#6948 sweep): dropRekeyDuplicates deletes the ontology observations a re-key would duplicate on idx_facts_ontology_stint_dedup and repoints supersession links at the survivor, inside its caller's transaction immediately before the caller's UPDATE (the rename's maintenanceTransaction, the relink_facts publication, the phantom redirect's fact move, repair facts-rehome's move). The canonical table SQL trigger requires coordinator capability, so a legacy call fails before publication.
@@ -115,7 +116,7 @@ src/core/page-state/schema.ts 3 schema Schema installation and forward-reference
src/core/page-state/revision-backfill-schema.ts 2 schema Migration-pass backfill of pages.knowledge_revision for rows written before the column (#5216): only NULL revisions are assigned, in committed id batches; canonical content is never written, and the revision trigger treats a NULL old revision without reading bodies.
src/core/page-state/tags.ts 5 engine_guard Canonical table SQL trigger requires coordinator capability; legacy calls fail before canonical DB publication. The frontmatter-claim and explicit-add inserts are two branches of one guarded statement. #5984: addPageTags is the same two-branch statement for many tags of a page the import wrote in its guarded transaction.
src/core/persistence/memory-mutations.ts 1 coordinator Publication is transaction-scoped under admitted authority, source/page guards and revision checks.
-src/core/persistence/memory-prepare.ts 3 coordinator Publication is transaction-scoped under admitted authority, source/page guards and revision checks.
+src/core/persistence/memory-prepare.ts 2 coordinator Publication is transaction-scoped under admitted authority, source/page guards and revision checks.
src/core/persistence/page-prepare.ts 13 coordinator Publication, including versioned tombstone restoration, is transaction-scoped under admitted authority, source/page guards and revision checks; the sixth SQL site reconciles trusted first-write provenance with prepared canonical frontmatter and the seventh records canonical source_path in that same guarded transaction. Identical canonical no-ops do not heal physical metadata. The added local-CLI purge deletePage call runs in the prepared publication callback after recorded-artifact removal, under the same source/page identity, revision and durable authority guards as receipt completion; permanent journal IDs and outcomes survive the hard delete. The ninth site pins an inferred slug_root_mode on sources in the same publication transaction as the first bound origin. Its importFromContent calls carry prepare and run inside the coordinator publication. The segmented tag flip (prepareSegmentedTagMutation: createVersion, removeTag/addTag and the content_hash update) runs in the prepared publication callback under the same admitted authority, source/page guards and revision check as the inline tag write.
src/core/persistence/segmented-apply.ts 2 coordinator Wave B segmented apply inside the page write's publication transaction: sealSegmentedPage stamps only projection state (text_projection_revision, chunker_version, search_vector); demoteSegmentedPage turns a segmented row inline with an empty body that the same transaction's inline write fills, under the request's revision and page guards.
src/core/persistence/semantic-pages.ts 1 coordinator Publication is transaction-scoped under admitted authority, source/page guards and revision checks.
diff --git a/docs/architecture/system-of-record.md b/docs/architecture/system-of-record.md
index 214e41dca2..683235ba9c 100644
--- a/docs/architecture/system-of-record.md
+++ b/docs/architecture/system-of-record.md
@@ -244,6 +244,7 @@ or a physical projection that leaves attribution untouched):
- `src/core/facts/conversation-publication.ts` (4): the managed conversation-facts preparer clears each member page's prior rows and inserts its frozen entry (or a blocked outcome row) inside the coordinator publication of its admitted batch request, clearing only for a complete replacement (#7013); the unmanaged writer runs the same publication in `maintenanceTransaction`. Its page clear also expires the rows `gbrain facts relink --conversation` linked (after deleting the previous clear's expired copies), inside the same transaction (#6764).
- `src/core/facts/conversation-relink.ts` (1): `gbrain facts relink --conversation`: a `managed_maintenance_conversation_relink` request on managed brains; the unmanaged relink runs in `writeDerivedFacts` (`maintenanceTransaction`).
- `src/core/facts/derivation-inputs.ts` (3): `hideDerivedRows` expires derived facts, deactivates derived takes and soft-deletes derived pages inside the purge's coordinated transaction, attributed to the purge request.
+- `src/core/facts/fence-fact-append.ts` (1): `prepareFenceFactAppend` inserts the facts row of a fence row the request's page file holds, in its caller's coordinated publication after the page row (remember and its callers).
- `src/core/facts/fence-write.ts` (1): the markdown-first fence reconcile insert runs in `maintenanceTransaction` (its page body mirror goes through `facts/file-body-guard.ts`).
- `src/core/facts/file-body-guard.ts` (2): the #6982 checked body mirror (`replaceStoredBody`: the page_versions row and the body refresh, under the page row lock) runs in its caller's `maintenanceTransaction` (fence write, unfenced-facts fence, phantom redirect, forget, proposal supersede).
- `src/core/facts/forget.ts` (4): the legacy fence expiry, withdrawal and strike-through each run in `maintenanceTransaction` (nested inside a caller's coordinated write, they keep its actor).
@@ -283,7 +284,7 @@ or a physical projection that leaves attribution untouched):
- `src/core/persistence/links-maintenance.ts` (1): coordinated maintenance.
- `src/core/persistence/loop-fact-retirement.ts` (1): request preparer.
- `src/core/persistence/memory-mutations.ts` (1): `forget` inside its request's coordinated write.
-- `src/core/persistence/memory-prepare.ts` (3): `remember` request preparer.
+- `src/core/persistence/memory-prepare.ts` (2): `remember` request preparer; the fence row and its facts row go through `prepareFenceFactAppend`.
- `src/core/persistence/page-append.ts` (1): segmented `append_page` / `edit_page` request preparer; the splice versions the page inside its request's publication.
- `src/core/persistence/page-prepare.ts` (12): page request preparer (including the restore of a segmented page over 24 MiB, which flips `deleted_at` without re-serializing, and the tag flip of a segmented page, which versions it and changes its tag rows and `content_hash` without re-serializing).
- `src/core/persistence/prepared-maintenance.ts` (4): managed maintenance request preparer (consolidation closes an unfenced fact in the database and a fenced one from its published fence cell).