Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

GBRA-161 PR 3: canonical-writer and write-attribution inventories for the chronicle adapter

garrytan1a16bcd2ce90
diff --git a/docs/architecture/canonical-writers.tsv b/docs/architecture/canonical-writers.tsv
index 8d0f6b4f63..717bbd6d1b 100644
--- a/docs/architecture/canonical-writers.tsv
+++ b/docs/architecture/canonical-writers.tsv
@@ -5,6 +5,7 @@ src/core/persistence/canonical-projections.ts 10 coordinator Facts, takes, timel
src/core/persistence/derived-retirement-hold.ts 2 contract retireDerivedPages versions, soft-deletes and stamps retired_by/retired_at on derived pages (unmanaged extract_atoms retirement) inside maintenanceTransaction behind the canonical table trigger; it never revives or rewrites content, and the purge hold it defines only keeps rows longer.
src/core/generations/adapters/page.ts 1 contract GBRA-161: importPageItem writes a derived page item through importFromContent inside the generation activation's maintenanceTransaction (publish.ts), behind the canonical table trigger; managed brains keep the coordinator path.
src/core/generations/adapters/atoms.ts 1 contract GBRA-161: the unmanaged atom completion flip (source_hash) runs in the generation activation's maintenanceTransaction after every atom and provenance edge was written and before the items are rechecked live; managed brains keep the coordinator path.
+src/core/generations/adapters/chronicle-events.ts 4 contract GBRA-161 PR 3: the Life Chronicle event adapter writes event pages and their depth timeline projection rows, and removes a retired event's projection row, only inside publishGeneration's maintenanceTransaction or the coordinated managed_generation_activate/_restore request, under the depth and event page keys; managed event pages keep the managed_maintenance_chronicle_event request.
src/core/persistence/links-maintenance.ts 1 coordinator Managed extract --stale and post-sync extraction add only the coordinator's unrecorded canonical timeline tuples inside a revision-bound withCoordinatedWrite transaction that also replaces the page's derived links and stamps its watermark.
src/core/extract-takes-from-pages.ts 0 coordinator Managed bootstrap submits one revision-checked put_page per source page so its complete takes fence and projected rows commit together; unmanaged writes retain the md-first helper.
src/core/persistence/origin-guard.ts 2 engine_guard #6948 bindOrigin records a page origin (and drops an origin_twin marker) only after assertOriginUnclaimed holds the origin advisory lock inside the caller's engine.transaction(); callers are the guarded publication applies and repairs.
@@ -42,7 +43,7 @@ src/core/bootstrap/verify.ts 2 coordinator Probe writes use put_page; a managed
src/core/brain-repo-durability.ts 0 filesystem_guard Hardening checks the root; generated push/rebase helpers honor shared refusal markers.
src/core/brain-writer.ts 0 filesystem_guard Frontmatter repair checks the managed root before backup or file replacement.
src/core/calibration/undo-wave.ts 1 engine_guard Canonical table SQL trigger requires coordinator capability; legacy calls fail before canonical DB publication.
-src/core/chronicle/publish.ts 5 coordinator A managed brain publishes each event page (with its depth timeline row) and each retirement through the managed_maintenance_chronicle_event/_retire requests, re-validating the judged depth page inside the publication; the unmanaged putPage/upsertEventProjection/softDeletePage writes run in maintenanceTransaction behind the canonical table trigger.
+src/core/chronicle/publish.ts 3 coordinator A managed brain publishes each new or changed event page (with its depth timeline row) through the managed_maintenance_chronicle_event request, re-validating the judged depth page inside the publication; a managed_maintenance_chronicle_retire request an earlier release journaled still stamps and drops its projection row there. Unmanaged writes and every retirement moved to generations/adapters/chronicle-events.ts (GBRA-161 PR 3).
src/core/company-brain/admission.ts 1 coordinator Managed registration delegates to source lifecycle; the unmanaged insert runs under native topology locks and a principal/source-locked transaction that validates the approved plan, binds the schema and records the ingestion receipt atomically.
src/core/company-brain/demo.ts 2 isolated_eval Fictional source registration uses a new PGLiteEngine connected with an empty config, so writes remain in an isolated in-memory database that is disconnected after the demo; the configured brain is never opened. Direct importFromContent calls without prepare refuse on managed brains before any write (assertUnmanagedCanonicalWriter).
src/core/company-brain/profile.ts 2 engine_guard Company-profile legacy deletes use withCompanyBrainSource to lock and validate source incarnation, path, receipt and policy; calls without that context retain engine guards, and managed sync routes to the coordinator before this legacy path. Direct importFromContent calls without prepare refuse on managed brains before any write (assertUnmanagedCanonicalWriter).
diff --git a/docs/architecture/system-of-record.md b/docs/architecture/system-of-record.md
index 62a9cb687f..486637ca2a 100644
--- a/docs/architecture/system-of-record.md
+++ b/docs/architecture/system-of-record.md
@@ -227,7 +227,7 @@ or a physical projection that leaves attribution untouched):
- `src/commands/sync/holds.ts` (1): a full sync's move of a held rename (`updateSlug` and its `source_path`) runs in one `maintenanceTransaction`; managed sources publish renames through the sync request preparer.
- `src/commands/sync/rename-collision.ts` (2): the legacy sync rename (`updateSlug`, and the tombstone re-key when the destination slug is a soft-deleted row, #5431) runs with its `source_path` repair in one `maintenanceTransaction`; managed sources publish renames through the sync request preparer.
- `src/core/calibration/undo-wave.ts` (1): the calibration wave undo of take resolutions runs in `maintenanceTransaction`.
-- `src/core/chronicle/publish.ts` (4): Life Chronicle event generations: maintenance requests on managed brains; the unmanaged event write, the version of a retired event, its soft delete and retired stamp run in `maintenanceTransaction`.
+- `src/core/chronicle/publish.ts` (1): the retired stamp (and timeline row removal) of a `managed_maintenance_chronicle_retire` request an earlier release journaled, inside that request's coordinated write; every other chronicle event write moved to `generations/adapters/chronicle-events.ts` (GBRA-161 PR 3).
- `src/core/company-brain/profile.ts` (1): legacy sync soft deletes (`softDeleteSyncPages`) run in `maintenanceTransaction`, inside the company-brain source check when one is active.
- `src/core/cycle/dream-provenance.ts` (1): the dream provenance frontmatter stamp runs per page in `maintenanceTransaction`, or `derivedMaintenanceTransaction` at the child's derived tier when the ref carries its taint (unmanaged brains only; managed synthesis publishes through maintenance requests).
- `src/core/cycle/dream-taint.ts` (3): the unmanaged dream summary page, its frontmatter tags, and the page_versions row of the different body it replaces (#6982), run in `derivedMaintenanceTransaction` at the tier of the pages it indexes; managed brains publish it through a maintenance request.
@@ -259,6 +259,7 @@ or a physical projection that leaves attribution untouched):
- `src/core/trust/timeline-projection.ts` (2): `gbrain extract` timeline walks (file, incremental, stale) and the per-entry fallback write through it: one `maintenanceTransaction` per page tier.
- `src/core/facts/write-single.ts` (2): the legacy single-fact insert and its supersession link each run in `maintenanceTransaction`; managed brains publish through the fact request.
- `src/core/generations/adapters/atoms.ts` (1): the unmanaged atom completion stamp (`source_hash`) runs inside the generation activation's `maintenanceTransaction` (`publish.ts`, GBRA-161).
+- `src/core/generations/adapters/chronicle-events.ts` (3): Life Chronicle event writes, their timeline projection rows and the retirement of dropped events run inside the generation activation's `maintenanceTransaction` (`publish.ts`) on unmanaged brains and inside the coordinated `managed_generation_activate` / `managed_generation_restore` requests on managed brains (GBRA-161 PR 3); a restore runs in the restore runner's (`repair.ts`).
- `src/core/import-file.ts` (12): direct markdown, code and image imports, the moved-file rename (`updateSlug`) and the #3694 legacy-hash re-stamp run in `maintenanceTransaction`; managed imports go through the page request preparer.
- `src/core/minions/handlers/ingest-capture.ts` (1): the capture ingest tombstone soft delete runs in `maintenanceTransaction`.
- `src/core/ops/extraction.ts` (2): extraction review promote (frontmatter) and reject (soft delete) each run in `maintenanceTransaction`.