Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

GBRA-161 PR 5: read the think save base after the explicit-model check; attribute the single-page adapter

garrytanc992483f6dfd
diff --git a/docs/architecture/system-of-record.md b/docs/architecture/system-of-record.md
index ebfe58960d..0ae92074ca 100644
--- a/docs/architecture/system-of-record.md
+++ b/docs/architecture/system-of-record.md
@@ -230,8 +230,6 @@ or a physical projection that leaves attribution untouched):
- `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.
-- `src/core/cycle/drift.ts` (1): the unmanaged drift report page runs in `maintenanceTransaction`; managed brains publish it through a maintenance request.
- `src/core/cycle/extract-facts.ts` (7): the unmanaged page reconcile and the expiry of fence facts whose page was soft-deleted run in `maintenanceTransaction`; managed brains publish `managed_maintenance_fence_facts` and `managed_maintenance_deleted_page_facts_expire` requests whose preparers write inside the coordinator publication. Both reconcile paths write at the page's tier and gate new rows.
- `src/core/cycle/extract-takes.ts` (1): one projected-takes writer stamps each page's tier and runs the write gate: inside a receipted `managed_maintenance_takes_reextract` request per changed page on managed brains, one `maintenanceTransaction` per page tier for the unmanaged batch upsert.
- `src/core/enrichment-service.ts` (2): the enrichment stub fallback write and its auto-timeline entry run in `maintenanceTransaction` at the source page's derived tier (the stub import is lowered to it afterwards).
@@ -260,6 +258,7 @@ or a physical projection that leaves attribution untouched):
- `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/generations/adapters/single-page.ts` (3): the unmanaged dream summary, saved `think` page and drift report (the page, its tags, and the page_versions copy of the live page it replaces) run inside the generation activation's `maintenanceTransaction` (`publish.ts`), attributed at the derivation's tier when the writer declares one (GBRA-161 PR 5); managed brains publish them through a maintenance request.
- `src/core/generations/managed-retire.ts` (1): the retirement stamp (`retired_by`, `retired_at`) of one synthesis output a managed generation retires runs inside its `managed_generation_retire` request's coordinated write, after the versioned page delete (GBRA-161 PR 4).
- `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`.
@@ -313,7 +312,6 @@ or a physical projection that leaves attribution untouched):
- `src/core/schema-pack/sync.ts` (1): each bounded pack type sync batch runs in `maintenanceTransaction`.
- `src/core/sweep.ts` (1): the maintenance sweep's bounded timeline batch runs in `maintenanceTransaction`.
- `src/core/takes-write.ts` (7): the takes file helpers' DB mirror (add, append, update, supersede, resolve and its self-heal) runs in `maintenanceTransaction`; managed brains publish through the takes request preparer.
-- `src/core/think/index.ts` (1): the saved `think` result page runs in `maintenanceTransaction`.
- `src/core/timeline-dedup-repair.ts` (1): runs only from schema migration v139, before migration v193 adds the attribution columns, so it has no actor to record.
- `src/core/timeline-write-through.ts` (2): the timeline write-through's page row splice and entry insert run in one `maintenanceTransaction`.
- `src/core/trust/fence-guard.ts` (2): the guarded fence re-projection detaches or moves higher-tier fact rows inside the page's coordinated publication.
diff --git a/src/core/think/index.ts b/src/core/think/index.ts
index 147f726055..a813a1b25f 100644
--- a/src/core/think/index.ts
+++ b/src/core/think/index.ts
@@ -614,9 +614,6 @@ export async function runThink(
if (resolvedWindow?.source === 'question') warnings.push('WINDOW_FROM_QUESTION');
const windowMeta = resolvedWindow ? { window_source: resolvedWindow.source } : {};
const temporal = await resolveThinkTemporalContext(engine, { referenceDate: opts.referenceDate });
- const persistSlug = synthesisSlug(opts.question, new Date().toISOString().slice(0, 10));
- const persistBase = { sourceId: opts.sourceId ?? 'default', slug: persistSlug,
- revision: (await engine.readPageSnapshot(persistSlug, { sourceId: opts.sourceId ?? 'default', includeDeleted: true }))?.revision ?? null };
// Resolve the model through the 6-tier chain.
const modelUsed = await resolveModel(engine, {
@@ -641,6 +638,10 @@ export async function runThink(
}
}
+ const persistSlug = synthesisSlug(opts.question, new Date().toISOString().slice(0, 10));
+ const persistBase = { sourceId: opts.sourceId ?? 'default', slug: persistSlug,
+ revision: (await engine.readPageSnapshot(persistSlug, { sourceId: opts.sourceId ?? 'default', includeDeleted: true }))?.revision ?? null };
+
// Optional question embedding — caller decides whether to pay the embedder; an opted-out brain never does.
const questionEmbedding = await embedThinkQuestion(engine, opts, warnings);