Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
chore: canonical-writer census and page-body-reader baseline for the #6982 guards
garrytan3df90af88a12
diff --git a/docs/architecture/canonical-writers.tsv b/docs/architecture/canonical-writers.tsvindex 52f34132ac..5d30b0fa6c 100644--- a/docs/architecture/canonical-writers.tsv+++ b/docs/architecture/canonical-writers.tsv@@ -86,9 +86,9 @@ src/core/facts/withdrawal-schema.ts 1 schema Migration v174 DDL/backfill expiressrc/core/facts/withdrawal.ts 2 coordinator Publication is transaction-scoped under admitted authority, source/page guards and revision checks.src/core/facts/write-single.ts 2 coordinator Managed brains publish the single fact through the managed_facts_entity intent before the legacy supersession or DB-only insert; those legacy writes run only unmanaged and stay trigger-guarded.src/core/git-remote.ts 0 filesystem_guard Clone, pull and rebase entry points check the durable root refusal registry.-src/core/github-source.ts 3 coordinator Managed connector imports, deletion and checkpoints use prepared journal publication; unbound API sources explicitly persist in the database and bound sources retain canonical filesystem publication.+src/core/github-source.ts 4 coordinator Managed connector imports, deletion and checkpoints use prepared journal publication; unbound API sources explicitly persist in the database and bound sources retain canonical filesystem publication. #6982: with sync.write_through off or a declared storage.db_only slug, an unmanaged item imports into the database only (importFromContent, versioned) and never touches the checkout; otherwise the replaceable-file guard and the pre-rename byte check bind the file replacement.src/core/google/google-source.ts 3 coordinator Managed connector imports, deletion and checkpoints use prepared journal publication; legacy materialization is confined to unmanaged sources.-src/core/google/sweep-shared.ts 1 coordinator Peeled from google-source.ts (wave 14 PR4, P4.3): the per-path delete used by the contact and calendar sweeps routes a managed source through the managed journal's delete and confines the legacy deletePages call to unmanaged sources.+src/core/google/sweep-shared.ts 2 coordinator Peeled from google-source.ts (wave 14 PR4, P4.3): the per-path delete used by the contact and calendar sweeps routes a managed source through the managed journal's delete and confines the legacy deletePages call to unmanaged sources. #6982: with sync.write_through off or a declared storage.db_only slug, importRendered imports into the database only (importFromContent, versioned) and never touches the checkout; otherwise the replaceable-file guard and the pre-rename byte check bind the file replacement.src/core/google/loops-extract.ts 1 coordinator Managed loop extraction checks the managed fact authority and owner before model calls and publishes its commitment fact through writeSingleFact's coordinator path; the provenance-tagged loop edge is not a guarded canonical table.src/core/import-file.ts 19 coordinator Prepared import applies under journal publication and revision CAS; direct managed imports refuse early, legacy source-path repair follows revision validation inside a savepoint, and a moved file's page is renamed only on the direct (unmanaged) path. Frontmatter tag reconciliation deletes only import-owned tag rows inside the same guarded import transaction. Direct importFromContent calls without prepare refuse on managed brains before any write (assertUnmanagedCanonicalWriter).src/core/page-body/streamed-import.ts 3 coordinator Wave B streamed import of a file over the single-string ceiling: refuses on managed brains before any write (assertUnmanagedCanonicalWriter), then versions, reconciles import-owned tags and adds code-reference links inside one maintenanceTransaction under the import base check, as importFromContent does on an unmanaged brain.@@ -243,7 +243,7 @@ src/core/persistence/page-purge.ts 4 coordinator purgePageInTransaction deletessrc/core/trust/fence-append.ts 1 coordinator withPageTierKept restores the page's prior trust_tier and write_origin in the same coordinated fence-append transaction that wrote the page (fence-write, facts-prepare and memory-prepare callers); it changes no content column.src/commands/sources-trust.ts 1 engine_guard gbrain sources set-trust rewrites only the source's config jsonb (its default trust tier for future writes); the managed writer guard exempts sources rows whose id, incarnation, local_path, archived and checkpoint columns are unchanged, and no knowledge row changes.src/core/trust/claim.ts 2 engine_guard gbrain trust claim-sources records the claim and its lift receipt in the source's config jsonb only (like sources set-trust); the managed writer guard exempts sources rows whose identity columns are unchanged. The tier lift itself runs through trust/backfill.ts inside withCoordinatedWrite on a managed brain.-src/core/cycle/dream-taint.ts 1 engine_guard putDerivedPage writes the unmanaged dream summary page inside derivedMaintenanceTransaction (attributed, tier lowered to the derivation's taint); on a managed brain the canonical table trigger refuses the write outside the coordinator.+src/core/cycle/dream-taint.ts 2 engine_guard putDerivedPage writes the unmanaged dream summary page inside derivedMaintenanceTransaction (attributed, tier lowered to the derivation's taint); on a managed brain the canonical table trigger refuses the write outside the coordinator. It also stores the frontmatter tags the summary file declares (addTag, same transaction) so its own file stays replaceable on a same-date rerun (#6982), after saving a page_versions row of a different prior body.src/core/persistence/derived-facts.ts 1 coordinator insertGatedFacts inserts only gate-allowed conversation fact rows; writeDerivedFacts refuses on a managed brain (writer_coordinator_required) and otherwise runs it inside the attributed maintenance transaction with taint edges.src/core/trust/fence-guard.ts 2 coordinator guardFenceRows detaches and renumbers fence rows more trusted than the writer inside the canonical fence re-projection of the page publication (canonical-projections.ts), in the same journal transaction as the receipt.src/core/trust/held-removals.ts 3 coordinator The owner accept of a held take or timeline removal deletes or re-projects that one row as the page now says, inside withCoordinatedWrite under the page key on a managed brain (withWriteAttribution otherwise), in the transaction that decides the proposal; a refused takes_remove instead reruns as an owner takes_remove through the takes request preparer.@@ -260,3 +260,4 @@ src/core/belief/purge.ts 1 engine_guard bumpPurgeEpoch updates only sources.purgsrc/core/belief/purge-mirror.ts 4 engine_guard W1 restore replay (BELIEF_LEDGER.md 8) of purges newer than the archive: runs only inside the backup restore's single transaction before the restored root is published, granting gbrain.write_sources for that one source in that transaction; its fact, take and page deletes repeat what purge_fact and purgePageInTransaction removed.src/core/persistence/links-extraction-holds.ts 2 engine_guard GBRA-130 A-1: records and clears only the derived pages.links_extract_failure column (a stale-extraction failure record outside the managed writer guard tracked set, like the attendance marker); it touches no canonical body, title, type, tag or frontmatter column.src/core/repair/url-clone-fences.ts 3 engine_guard GBRA-130 C-2: unmanaged brains only (refused on managed). Keeps the fence rows the database already holds database-only in a maintenance transaction, then imports the clone file's HEAD bytes through importFromContent before restoring the file; preview-bound (--expect) with destructive consent and a file backup.+src/core/facts/file-body-guard.ts 1 engine_guard #6982 replaceStoredBody mirrors a checkout file body over the page row only inside its caller's maintenanceTransaction, after re-reading the row under a row lock and confirming it still equals the body the caller compared, and saves a page_versions row first; on a managed brain the canonical table trigger refuses the write outside the coordinator.diff --git a/scripts/page-body-readers-baseline.tsv b/scripts/page-body-readers-baseline.tsvindex 90342063b5..f1ae7adc08 100644--- a/scripts/page-body-readers-baseline.tsv+++ b/scripts/page-body-readers-baseline.tsv@@ -534,6 +534,7 @@ src/core/think/gather.ts renderPagesBlockDetailed field LEAD segmented page: getsrc/core/think/gather.ts runGather field LEAD visibleLeads reads Page.compiled_truth from listPages/search: segmented page: getter throws page_body_segmented (lead source in PR 2)src/core/think/index.ts composeExtractiveFallback field LEADsrc/core/think/index.ts persistSynthesis call:putPage SEGW+src/core/think/persist-take.ts assertTakeFileCanonical field SEGW compares the inline page body outside the takes section with the file; a segmented page reads NULL, never matches, and the take is refused before any writesrc/core/timeline-dedup-repair.ts repairLegacyTimelineSourceRows field STREAMsrc/core/timeline-dedup-repair.ts repairLegacyTimelineSourceRows sql STREAMsrc/core/timeline-extract.ts pruneTimelineOrphans sql STREAM