Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript
30.8 KB
Raw Blame

Key files: Core Persistence (managed facts)

Subsystem index · Core Persistence. Read only the entries relevant to your change. Current behavior and load-bearing invariants; history belongs in Git and CHANGELOG. Managed facts extraction: the entity-intent preparer and publisher, conversation facts batches and the unmanaged derived index. The extraction pipeline itself is in Google and Loops (continued) (src/core/facts/backstop.ts) and Core Services (2/3) (src/core/facts/extract.ts).

  • src/core/facts/bulk-days.ts — #7247 the one rule doctor fact_bulk_dates and gbrain repair fact-claim-dates share. findBulkFactDays (one read-only aggregate over active facts of active sources, optionally scoped) returns each UTC valid_from day holding at least BULK_DAY_RULE (200 facts, 25% of the source, 20 entities) with counts, top source tags and dated_claims. claimDate returns a claim's only YYYY-MM-DD token when it is a real date from 1900 to the day before; the aggregate's SQL applies the same token and bounds.

  • src/core/persistence/{facts-maintenance,facts-prepare}.ts — the managed facts publisher and preparer behind the backstop's publishManagedFacts / resumeManagedFacts and the explicit fact writers (managed-fact-write.ts, remember); the shared maintenance dispatch they ride is in Core Persistence. GST-2635: under attributeFallback (writeSingleFact, the loops extraction's call) a page-less entity holdingHome refuses (an exact page rule, an unreadable access state) throws refuseUnheldFact (facts/held-fact-move.ts) before any request is admitted, instead of falling through to a database-only memory/unattributed row. Each ManagedFactsSession carries one MaintenanceWriteWait (maintenance-wait.ts) built from the caller's FactsBackstopCtx.deadlineAtMs (the facts-absorb job passes its deadline; other callers get the 30 s base) and its abort signal: collectManagedFacts waits that long for each accepted request through awaitWrite, a cancelled job stops waiting at once, and a request still nonterminal after the wait leaves as write_pending with its receipt (#6778, test/facts-absorb-publish-wait-6778.test.ts). GBRA-130 A-36: collectManagedFacts awaits every row before it throws. An entity request that ended on a code of its own page (ENTITY_REFUSAL_CODES: revision_conflict, invalid_fence, page_body_segmented, …; not a file-check or withdrawal refusal, which the follow-up walks own) is reported as refused (slug, code, request id) on ManagedFactsResult and the extract_facts result when the session sets reportRefusals and another entity of the batch committed (the backstop sets it; managed-fact-write.ts and remember do not and keep the refusal), and the completion receipt refused only as incomplete is not a failure of its own; any other terminal row, then a pending one, then a refusal with nothing committed beside it, throws as its receipt. Test: test/pathological/a-36-facts-batch-partial-refusal.test.ts (PGLite and Postgres). facts-maintenance.ts / facts-prepare.ts (#6506): an automatic extraction's entity intent carries withdrawn: 'skip' (set by the backstop's publishManagedFacts call, never by managed-fact-write.ts or remember), under which prepareManagedFactsMutation skips a candidate isFactWithdrawn matches at any visibility (after assertFactNotPurged, which still refuses purged_content) and counts it as withdrawn_skipped on the entity outcome, summed into the completion outcome, ManagedFactsResult and the extract_facts result (the unmanaged pipeline counts its own B-10 skip into the same field); without the flag the refusal stands. At locked validation the per-entry purge and withdrawal checks run before the page's fence re-validation, and under the flag a claim forgotten since preparation refuses revision_conflict with error.withdrawn (so the receipt's error_detail.origin is withdrawal); no extract_facts request is re-prepared. resumeManagedFacts runs followWithdrawalRefusals for an input-keyed session (inputKeyed, no request id): the followFileRefusals walk generalized as followRefusals, matching entity refusals by withdrawnFromDetail(error_detail) or the pre-detail invalid_params + FACT_WITHDRAWN_MESSAGE pair, re-admitting the retained facts under digest([batchKey, 'withdrawal-retry', n]) with the flag (readmitWithdrawnFacts; every follow-up, file-check and moved-entity ones included, carries the flag and narrows its facts to the current default visibility, so a claim forgotten at any visibility is skipped at preparation and refused at locked validation), bounded by MAX_FILE_REFUSAL_RETRIES, historical receipts untouched. Tests: test/managed-facts-withdrawn-skip-6506.test.ts, test/managed-facts-withdrawal-recovery-6506.test.ts (PGLite and Postgres). #7602: an automatic extraction with no caller request id (entityMoveRetry, set by the backstop; explicit writers keep the refusal) also runs followEntityMoves, after admission in publishManagedFacts and on resume: an entity request refused revision_conflict because another write moved its entity page (FACTS_ENTITY_MOVED_MESSAGES in verb-errors.ts: changed after admission, changed during preparation, deduplication state changed, the coordinator's PAGE_CHANGED_DURING_PREPARATION_MESSAGE, which coordinator.ts and group-publish.ts throw, and the page layer's PAGE_CHANGED_AFTER_READ_MESSAGE, how a move during preparation was stored before the fix; isEntityMovedRefusal is the one predicate the walk and the repair preview share) is re-admitted under digest([batchKey, 'entity-moved-retry', n]) at the page's current revision with its retained intent (readmitMovedFacts; a deleted or replaced page keeps the refusal), no model call, each batch settled first so a follow-up that loses again is followed in the same run, bounded by MAX_FILE_REFUSAL_RETRIES; a follow-up refused for another reason (a held file) is not re-admitted, and the walk carries every request it did not follow. A follow-up's source-page check in facts-prepare.ts accepts a source page moved only by a committed request of the same extraction (same principal and input digest, at the page's current revision), such as a fact the batch wrote onto its own source page; any other change still refuses The source page changed during fact extraction. A refusal collectManagedFacts still throws after the walks is marked retryable: false, so the worker ends the facts-absorb job dead on its first attempt (jobRefusal; revision_conflict is not in DETERMINISTIC_WRITE_REFUSALS, so this is not the facts_absorb_write_refused path). Test: test/facts-entity-moved-7602.test.ts (PGLite and Postgres). #8526: a page-triggered or input-keyed session also runs followEmbeddingRefusals, re-admitting facts the owner's consumer refused embedding_configuration (through readmitMovedFacts: retained visibility, unattributed groups kept) under digest([batchKey, 'embedding-retry', n]) only once no live full or promoted consumer that started before the refusal remains (ownerRestartedSince: the worktree owner host's consumers, every consumer for a batch with no worktree; with no live consumer row, as on PGLite, admission's check of the retained signature against the brain's current config is the gate), bounded by MAX_FILE_REFUSAL_RETRIES. Test: test/facts-embedding-refusal-heal-8526.test.ts (PGLite and Postgres). gbrain repair failed-writes (failed-writes.ts, Core Utilities (2/2)) lists refused fact extractions. #7602: fact rows (moved-entity refusals included) use factsRecovery: recover: (retry-dead reset) only while the page write's facts-absorb job is dead and the entity page is the one admitted, pending: while that job runs, not recoverable: for a deleted page, and re-extract: otherwise (replaced page, completed or missing job, exhausted follow-ups, a page write the job's own readFactsBackstopJobPage check now skips (written again since, or a narrowed writer grant), an extraction whose open entity requests are not all moved-entity or all held-file refusals, a guard refusal). Only the preview reads fact rows (failedWrites(..., { facts: true })); the sync-time remember replay and apply-by-id keep the guard/drift query.

  • src/core/facts/same-page-shadow.ts — #6333 the shadow counter both fact writers share. samePageRewording(engine, sourceId, fact, embedding) re-reads the entity's nearest live same-visibility candidate (listSupersessionCandidates, the pool and filters of decideSingleFact's cosine pass) and answers whether wouldDedupSamePage (capture-dedup.ts: same lane, same source_session, same visibility, cosine ≥ 0.85, no diverging guard token) would have called the fact a rewording; warnSamePageShadow is the one stderr spelling ([facts-backstop] #6333 shadow: …; both kept). facts-prepare.ts calls it for every candidate decideSingleFact did not match and counts would_dedup_same_page on the entity outcome, the completion outcome, ManagedFactsResult and the extract_facts result; the count is frozen in the receipt, so a replay reports it and does not recount. Nothing is dropped; this is the managed mirror of the unmanaged backstop's counter (backstop.ts), which never fired on a managed brain. Tests: test/backstop-same-page-shadow-managed-6333.test.ts (PGLite and Postgres), test/backstop-same-page-shadow-6333.test.ts (unmanaged).

  • src/core/persistence/derived-facts.ts — writeDerivedFacts: the unmanaged conversation fact index commits in one maintenance transaction under the maintenance principal; on a managed brain it refuses with writer_coordinator_required, because every managed facts/takes writer publishes a receipted maintenance request (test/receipt-coverage.test.ts lists every coordinated write site). Tests: test/write-attribution-misc.test.ts.

  • src/core/facts/conversation-publication.ts — managed conversation facts as database-only managed_maintenance_conversation_facts batch requests (submitDatabaseMaintenanceIntent on ANCHOR_SLUG, a dot-led slug no page can hold, dispatched from prepareMaintenanceMutation). Each page's frozen entry (buildConversationPage: FrozenExtractedFact rows, its generation and attempt, vectors only under the brain's facts embedding signature) joins the run's batch; enqueueManagedPage publishes it once DEFAULT_BATCH_CAPS is reached (25 pages, 10 with extracted facts, 8 MiB) and flushManagedBatch at the end of the run. The generation key (protocol, source incarnation, page id, revision, parser-input version token, CONVERSATION_EXTRACTOR_VERSION, selectors, newest extractor row id) is checked before model work by startManagedPage against loadGenerationIndex (the writer's unsettled and failed batches on the anchor, read once per run): a member of an unsettled batch waits and replays its receipt, a member of a retryably failed batch is resubmitted from its stored entry, a deterministic failure of a batch that held it alone or three failed batches block it (GBRA-130 A-51: publishBatch re-publishes a multi-page batch that failed deterministically in halves, so only the page that fails alone takes the code; test/pathological/a-51-conversation-batch-booking.test.ts); all without model calls. The batch request id digests its members' (generation, attempt) pairs; submitConversationPages raises every member's attempt past an id another write holds, or whose receipt lost its intent without committing (#7516: a redacted purged_content refusal or a compacted failure takes the attempt history loadGenerationIndex reads, so the same id came back on every run as idempotency_conflict after a paid extraction; test test/conversation-facts-redacted-batch-7516.test.ts, + Postgres arm). The preparer locks every member's key and applies each on its own (applyEntry): a deleted, replaced or moved page is skipped and reported, a page whose rows fail validation gets a durable blocked: not-extractable outcome, vectors under another signature are dropped; none fails the batch. estimateConversationIntentBytes/conversationIntentByteLimit skip a page whose largest entry cannot fit before any model call; assertConversationAdmissionHeadroom stops admitting at 80% of the writer's outstanding requests, reserved receipt bytes or lifetime ids (maintenance_backpressure, exit 12, naming the resource and a --limit that fits), up front for the run's planned batches and before each new batch. publishConversationFacts (the managed apply and the unmanaged writer) passes fact rows through the write gate at the page's derived tier and retires the prior batch only for a complete replacement (#7013: full scope, at least one fact, nothing held or rejected) or on a page with no active extractor facts, through replaceConversationFacts, which deletes the page's extractor rows (expiring referenced and keeping label-retired ones) and inserts the rows numbered above every remaining row, failing on a lost insert. Otherwise the prior facts stay: the outcome row replaces the page's prior outcome rows (so the page is not paid for again), a window run (--since dropped messages) adds its facts beside them, and a partial run (a --segment-limit cut, a page changed mid-run) publishes no facts over them. Each entry carries its scope; an entry frozen without one is partial without its outcome, window with a --since selector, else full. Rows carry an optional slot (GBRA-574 B2: dimension, value, value_hash, dim_status 'active'): insertableSlots drops a slot outside the vocabulary, without an entity, or whose unique slot key the page or an earlier row of the batch already holds (the fact stays), and clearConversationFacts clears the slot of every row it keeps expired in the same UPDATE. Tests: test/pathological/h4-conversation-facts-zero-yield.test.ts (managed and unmanaged, + Postgres arm). Tests: test/conversation-facts-managed.test.ts (+ Postgres arm), managed-connector contract cases extract_conversation_facts*.

  • src/core/facts/slots.ts — GBRA-574 B2/G4 conversation fact slots: the closed vocabulary (location, employer, role), normalizeSlot (entity required, value at most 80 characters), CHANGE_CUE and deriveSlotEnds, which works out read-time validity ends per (source, entity, dimension): a run of one value is one stint, and the next distinct value ends it at its valid_from only when it starts later and comes from a page the stint came from or its fact states a change; otherwise both values stay open. Nothing is written. The ontology keeps its own domain: getOntology, discoverOntologyDimensions, findOntologyConflicts, mergeOntologyFact and the ontology-facts repair skip conversation rows (chronicle/ontology.ts NOT_CONVERSATION_SLOT_SQL), mergeOntologyFact and the re-key dedup (facts/ontology-rekey.ts, also run by the twin merge) clear the slot of a conversation row that holds an observation's exact stint key instead of dropping either, and windows read conversation rows only. Tests: test/facts-slot-windows-gbra574.test.ts (+ Postgres arm), test/facts/extract-slots.test.ts, test/facts/normalize-slot.test.ts.

  • src/core/facts/slot-tagging.ts — GBRA-574 slot tagging: the main extraction call never asks for a slot, so extractConversationWindow sends a second small call (tagSlots, the facts extraction model, SLOT_TAG_SYSTEM, at most 10 facts and 400 output tokens) over the window's fact and event rows whose entity was named exactly (the extractor's name resolves to the same page through resolveStrictEntityReference: exact slug, unique basename or unique alias, never a prefix guess or a near name; or subject inference) and is a live, unretired person page, or whose entity is a name key the window kept for a full name with no page (unbacked, bracketed with the extractor's own name text); no candidate, no call, and BrainBench's injected extractor skips it. Each reply pair goes through normalizeSlot. A failed or unreadable reply keeps the facts without slots and counts slot_tagging_failed; abort and BudgetExhausted propagate. The per-page cap (conversation-incremental.ts) and conversationRunEstimate add one tagging call per window at its largest (SLOT_TAG_INPUT_CHARS). Tests: test/facts/slot-tagging.test.ts, test/large-pages/conversation-slot-tagging-segmented.test.ts. The name keys come from src/core/entities/resolve-on-save.ts (GBRA-574 F): conversation extraction alone passes the unbacked map while facts.unbacked_entity_keys is on (unbackedEntityKeysEnabled), and a fallback name of at least two words keeps its bare basename key (unbackedEntityKey: Alice Example, alice-example and people/alice-example give alice-example) unless a live page sits at that bare slug, counted as unbacked_key_count; no page is created and every other writer still stores NULL.

  • src/core/facts/subject-infer.ts — zero-LLM fact subject inference shared by the write paths (remember, the facts backstop) and gbrain facts relink. inferFactSubject(engine, sourceId, { fact, pageSlug?, mode, excludePrivate? }) returns { slug, via: 'page' | 'mention' } or a miss reason (ambiguous, unverified_match, no_mention, no_page). Page tier: the trusted page the fact came from, when it is a live fact-entity page. Mention tier: strong extractCandidates names plus slugs written in the text (lowercase Unicode page-slug letters without combining marks; a literal glued to further letters is not a literal), resolved through resolveStrictEntityReference (exact slug, unique basename, unique alias; relink mode adds the same-name trigram arm); exactly one entity links. Any other real name that does not resolve to the same entity (including names with no page and bare first names) vetoes the link; sentence-start capitals, weekdays/months and role terms (CEO, Q3) do not. excludePrivate removes private pages before uniqueness is counted. Also appendContextNote/contextHead (the " — " note convention), recordedPageSlug (page provenance of page-extraction rows only) and isEntityInferenceEnabled (facts.entity_inference kill switch for write-time inference; relink ignores it). resolveStrictEntityReference in entities/resolve.ts never guesses from a bare-name prefix and never slug-falls-back. Pinned by test/facts-subject-infer.test.ts (a 40+ fact labeled fixture: write precision >= 0.99, relink free tiers >= 0.95).

  • src/core/facts/conversation-subject-infer.ts — #6764 write-time subject inference for gbrain extract-conversation-facts (both the classic and managed branches, trusted local only) and the free conversation relink. inferConversationSubject is the per-fact rule (a withdrawn claim misses as withdrawn); inferConversationSubjects(engine, sourceId, visibility, rows) gives each row the extractor left without an entity the slug inferFactSubject proves in write mode (mention tier; excludePrivate for world rows) plus the entity inferred from <tier> context note, unless facts.entity_inference is off or the claim was withdrawn. The row stays a derived row of the conversation page (entity_slug column only). Test: test/conversation-facts-unlinked-6764.test.ts.

  • src/core/facts/conversation-relink.ts — gbrain facts relink --conversation [--source] [--slugs] [--dry-run] [--json] (#6764, dispatched from src/commands/facts.ts): the free relink of the conversation extractor's unlinked derived rows, which plain relink never examines. Pages are the named --slugs, else the 50 with the most unlinked rows not yet tried (conversationRelinkPages). Each row runs inferConversationSubject (write mode, visibility-filtered, withdrawn claims skipped; no model); a row the assistant or a third party said is never linked, never picks a page, and is counted as not_user_attributed (#7270). A page's links are one write: a managed brain publishes one database-only managed_maintenance_conversation_relink request on the anchor .maintenance/conversation-relink holding the page key (prepareConversationRelink, dispatched in persistence/prepared-maintenance.ts; the request id comes from the planned links, and a failed attempt retries under the next id), an unmanaged brain one writeDerivedFacts transaction. The write sets entity_slug and appends entity relinked from <tier> only on rows still exactly as planned (same claim, unlinked, active, target page live) and records a linked attempt; unresolved rows get a conversation_unresolved memo in fact_relink_attempts (reason the miss), which moves doctor unlinked_facts to the paid re-extraction fallback, and the report prints that command for their pages. Test: test/conversation-relink-6764.test.ts. GBRA-574 C1 --unbacked (planUnbackedPages): rows on an unbacked name key (withdrawal-schema.ts unbackedEntitySql) re-key onto the page the key's words resolve to through resolveStrictEntityReference with sameName (exact slug, unique basename, unique alias, same name ignoring corporate suffixes; a retired page answers through its superseded_by target; excludePrivate for world rows); each planned row carries from (the key), the write re-checks the row is still on that key, runs dropRekeyDuplicates first so a slot never collides, notes entity relinked from unbacked and records a linked attempt with tier unbacked; misses keep their key and write no memo. Test: test/conversation-unbacked-keys-gbra574.test.ts (both engines; Postgres via test/e2e/conversation-unbacked-keys-gbra574-postgres.test.ts).

  • src/core/facts/conversation-memo.ts — #6764 what makes free relink, then paid re-extraction, then linking by hand converge, all in fact_relink_attempts: conversationTriedSql (a conversation_unresolved memo, re-armed for the free relink by any page created in the source after it unless RELINK_REASONS memoizes the reason), conversationPaidSql and recordReextractMemo (tier paid_reextract, target_slug the page, reason its content_hash, keyed on the page's completion outcome row; written when an extraction of the page completes, unmanaged in extract-conversation-facts.ts and managed in conversation-publication.ts applyEntry). No schema change. Test: test/conversation-memo-6764.test.ts.

  • src/core/facts/conversation-relink-carry.ts — #6764 how a free conversation relink survives a batch replacement: clearConversationFacts (conversation-publication.ts) expires the page's relinked rows (RELINKED_DERIVED_ROW: entity set and entity relinked from in the context) instead of deleting them, after deleting the previous clear's expired copies, and inheritRelinkedEntities gives each inserted row with no entity whose claim matches one of them that entity (live page only) and the relink note, in every insert publishConversationFacts makes (managed and unmanaged, replacement or addition) and in insertGatedFacts. One active copy, link kept. Test: test/conversation-relink-6764.test.ts.

  • src/core/repair/duplicate-facts.ts — gbrain repair duplicate-facts (#7043), explicit-only and preview-bound (consent destructive). findDuplicateFacts (read-only) groups active facts by source, visibility, attributed_to and gbrain_fact_fingerprint(fact), keeps the oldest fenced row, else the oldest row (created_at, id; G4: a database-only legacy copy of a fenced claim is retired onto the fence row, so the unfenced copy no longer holds its page out of fact reconciliation) and classes each group same_entity or cross_entity (retired only with --include-cross-entity). The apply sets expired_at and superseded_by on database-only copies (coordinatedDatabaseWrite with the relink_facts operation on a managed brain, one maintenanceTransaction per group otherwise) and strikes a fenced copy as superseded by #N through a revision-bound put_page when the kept row shares its fence; a copy whose kept row is elsewhere is listed as fence_kept_elsewhere, one on a segmented page as segmented_page (preview and apply). Near duplicates are never touched; a row changed since the preview reports changed_since_preview. Tests: test/repair-duplicate-facts-7043.test.ts (PGLite and Postgres).

  • src/commands/doctor/checks/fact-bulk-dates.ts — fact_bulk_dates (wave check, #7247): findBulkFactDays over the scoped sources (remote callers: their permitted sources); warns per day with fact and entity counts, top source tags and dated_claims, says the dates record loading, not occurrence, and names the gbrain repair fact-claim-dates --source <id> preview. Read-only.

  • src/commands/doctor/checks/conversation-coverage.ts — conversation_format_coverage: samples up to 50 newest pages per concrete conversation type, the list the extractor reads (pageTypesForAllowed(ALLOWED_TYPES), granular collector aliases such as slack-thread included, #8469), keeps the pages isConversationFactsEligiblePage admits, parses each without polish or fallback and warns above 10% unmatched transcript-claiming pages. Test: test/doctor-conversation-granular-coverage-8469.test.ts.

  • src/core/repair/fact-claim-dates.ts — gbrain repair fact-claim-dates --source <id> [--day YYYY-MM-DD] (#7247), explicit-only, preview-bound, destructive (--yes). Candidates: active facts on a bulk day (findBulkFactDays, or --day) whose claim has exactly one earlier ISO date (claimDate). A fence row's valid_from cell is rewritten in the page's one fence section and published by revision-bound put_page (the facts row is re-projected); a database-only fact is updated in one maintenanceTransaction on an unmanaged brain and counted database_only_managed on a managed one. Pages with an unparsed, split or segmented fence, or a rewrite that does not read back as the planned rows, are listed and kept. The hash binds revisions, row numbers and new dates; a fresh apply recomputes the plan and refuses preview_changed on any difference. Test: test/repair-fact-claim-dates-7247.test.ts.

  • src/core/facts/fence-fact-append.ts — prepareFenceFactAppend(engine, row, config, snapshot, { fact, pendingTier, mode?, supersede? | rowNum }, signal): the one way a coordinator preparer puts a single fact into the facts fence of the request's page (row.slug); remember uses it, and so does a managed owner release of a held fact (trust/release-publish.ts, the trust_release operation: append for a held fact with an entity slug, index-existing for a hold naming payload.row_num, whose cell fields the owner previewed and the request binds: a moved cell refuses preview_changed; journaled as mode index-previewed, which a preparer built before the field preview refuses, and an index-existing request with no fields digest refuses preview_changed asking for a rerun). It returns { prepared, rowNum, fencesNormalized, apply(tx) }: prepared is the page write to compose (its file, exclusiveSources, validate; null in index-existing), and apply runs in the publication transaction after the coordinator published the file, writing the page row (tier kept, trust/fence-append.ts) and then the facts row with row_num and source_markdown_slug, so a facts row never precedes its fence row in Git. append (default) normalizes the stored fence (#6188), renders the row with fenceRowOf (unfenced-facts.ts, the one renderer) at one past the highest row number in the fence and among the page's facts rows (#6696 C9), strikes supersede.rowNum when given, and prepares the page write unprojected (preparePageMutation option: the helper writes the facts row, so the page publishes without canonical projection whatever the operation) under withPendingFenceRows at pendingTier. index-existing takes a row the file already holds (a fence-guard hold's payload.row_num): the cell must pass fenceCellReadBackProblem against the fact, else it refuses fence_row_changed (reason row_missing / struck / empty / visibility / text) and writes nothing; otherwise the facts row derives from the cell (extractFactsFromFenceText, what a re-import projects) with the caller's embedding and session, and no file changes; the caller's observedRevision is snapshot.revision, which the coordinator re-checks under the page lock. An occupied row number fails the insert with storage_error naming the occupant. Tests: test/fence-fact-append.test.ts (PGLite and Postgres: append, supersede, index-existing from a real fence-guard hold, each refusal, and remember's fence row byte for byte against the earlier construction). GST-2497: on a holding page (not segmented), apply then keeps the page's newest five inline saved versions (pruneHoldingPageVersions). GST-2492: prepareFenceRowRetirement strikes one or several rows of another page as a companion (a forgotten held row reads back forgotten:; remove takes the rows out instead of striking them).

  • src/core/facts/held-fact-move.ts — GST-2492 moveHeldFacts(engine, sourceId), run by the extract_facts phase: facts a strict source held on memory/unattributed (an entity cell naming a page that did not exist) move into that page once it exists, one managed_maintenance_move_held_fact publication per entity (the fact-fence adoption preparer in persistence/prepared-maintenance.ts, plus the holding rows struck as a companion, the belief ledger told the rows transferred). A row that cannot move (a database-only target, a malformed fence, a duplicate claim, a prior refusal) stays held and is reported held_fact_unmovable; a move into a restricted page removes the holding rows instead of striking them. GST-2497: the sync path's due check (moveRuledSharedHeld) is true only when a rule covers a held row's entity but not its holding page (a rule over the holding page alone narrows nothing), and planningView bounds getConfig too. refuseUnheldFact is the one refusal for a fact holdingHome will not hold (remember's planRememberTarget and, GST-2635, publishManagedFacts' attribute fallback call it before anything is admitted): an exact page rule on a strict source throws git_home_required (facts_lane, through assertStrictGitHome) naming the entity's page, an unreadable access state access_policy_pending naming the entity. Test: test/strict-fallback-refusal-gst2635.test.ts (PGLite and Postgres). GST-2667: holdingPageFor rethrows an error of its access read that the persistence consumer prepares again (transientDatabaseFailure / transientInterruption: a statement cancel, a stale plan, contention, a lost connection, a pooler's client cap) instead of reading it as access_unreadable, so a fact preparing on a strict source is prepared again rather than refused; any other error (permission denied on the access tables) still reads as access_unreadable. Test: test/holding-read-transient-gst2667.test.ts (PGLite and Postgres).

  • src/core/page-slug-grammar.ts — OP_PAGE_SLUG_RE / isOpPageSlug, the page slug grammar operations accept (moved out of ops/context.ts so facts-fence.ts can validate the entity cell of memory/unattributed without importing the operations layer).