Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
Merge remote-tracking branch 'origin/capy/large-pages-segmented-storage' into capy/large-pages-1e
garrytanffc6b0cab9b3
diff --cc package.jsonindex ec666955de,c000e36285..c5e184374e--- a/package.json+++ b/package.json@@@ -158,7 -158,7 +158,8 @@@"check:durable-flush": "bun scripts/check-durable-flush.ts","check:windows-hide": "bun scripts/check-windows-hide.ts","check:engine-sql-ratchet": "bun scripts/check-engine-sql-ratchet.ts",+ "check:chunk-visibility": "bun scripts/check-chunk-visibility.ts",+ "check:page-body-readers": "bun scripts/check-page-body-readers.ts","check:engine-sql-dynamic": "bun scripts/check-engine-sql-dynamic.ts","check:engine-sql-brands": "bun scripts/check-engine-sql-brands.ts","check:sync-run-state": "bun scripts/check-sync-run-state.ts",diff --cc scripts/page-body-readers-baseline.tsvindex 0000000000,52a95a933b..1a4ae854e8mode 000000,100644..100644--- a/scripts/page-body-readers-baseline.tsv+++ b/scripts/page-body-readers-baseline.tsv@@@ -1,0 -1,531 +1,529 @@@+ # Page body reader ratchet baseline (Wave B segmented storage, spec 1.5 layer 4).+ # Enforced by scripts/check-page-body-readers.ts via `bun run check:page-body-readers` (in verify).+ # Rows: path<TAB>unit<TAB>kind<TAB>action<TAB>note+ # kind field | sql | call:<name>+ # action STREAM | LEAD | META | SEGW | INLINE | NONE (see the script's header)+ # note how the site treats a segmented page today (throw, refuse, logged+ # skip, SQL exclusion); empty when the site relies on the throwing+ # getters alone and was not changed in PR 1. NONE needs a note.+ # Rows only shrink: when a site moves to the segment reader or writer, delete+ # its row (`bun scripts/check-page-body-readers.ts --prune` drops stale rows).+ # A new whole-body reader never gets a row: use the segment reader, a bounded+ # lead (boundedBodyPrefixSql), body_bytes or content_hash instead.+ # docs/TESTING.md#page-body-readers+ src/cli/main.ts formatResult field STREAM renders a get_page result body; segmented bodies stream in PR 2+ src/cli/page-render.ts formatGetPage call:serializeMarkdown SEGW+ src/cli/page-render.ts formatGetPage field STREAM+ src/commands/brainstorm.ts runBrainstormCli call:serializeMarkdown SEGW+ src/commands/core.ts runCore field INLINE+ src/commands/core.ts setMarking call:serializePageToMarkdown INLINE+ src/commands/core.ts suggestCandidates field INLINE+ src/commands/core.ts suggestCandidates sql INLINE+ src/commands/doctor/checks/calibration.ts checkLinkResolutionOpportunity field LEAD+ src/commands/doctor/checks/calibration.ts checkLinkResolutionOpportunity sql LEAD+ src/commands/doctor/checks/content-quality.ts runContentSanity sql META+ src/commands/doctor/checks/data-integrity.ts runMarkdownBody sql META+ src/commands/doctor/checks/derived-visibility.ts derivedVisibilityCheck sql NONE not the page body: p.* in a CTE, only metadata columns read+ src/commands/doctor/checks/graph-health.ts runGraphCoverage field NONE not the page body: timeline count alias+ src/commands/doctor/checks/graph-health.ts runGraphCoverage sql NONE not the page body: timeline coverage count alias+ src/commands/enrich.ts enrichOneLocked call:serializeMarkdown SEGW+ src/commands/enrich.ts enrichOneLocked field SEGW+ src/commands/export.ts runExport call:serializeMarkdown SEGW+ src/commands/export.ts runExport field STREAM+ src/commands/export.ts runExport sql STREAM+ src/commands/extract-conversation-facts.ts regularPageVersionToken field STREAM+ src/commands/extract-mentions-explain.ts explainMention field STREAM+ src/commands/extract-mentions-explain.ts explainMention sql STREAM+ src/commands/extract-mentions-explain.ts pageNames sql STREAM+ src/commands/extract-mentions-explain.ts rejectedDeclaration sql STREAM+ src/commands/extract-timeline-db.ts extractTimelineFromDB field STREAM+ src/commands/extract-timeline-db.ts plannedTimeline field STREAM+ src/commands/extract.ts extractFromDB field STREAM+ src/commands/extract.ts extractLinksFromDB field STREAM+ src/commands/extract.ts extractMentionsFromDb field STREAM+ src/commands/extract.ts extractStaleFromDB field STREAM+ src/commands/extract.ts runExtractCore field STREAM+ src/commands/integrity.ts cmdAuto field STREAM+ src/commands/integrity.ts scanIntegrity field STREAM+ src/commands/integrity.ts scanIntegrityBatch field STREAM+ src/commands/integrity.ts scanIntegrityBatch sql STREAM+ src/commands/jobs.ts JOBS_HELP sql NONE not the page body: help text+ src/commands/lint.ts lintContent field STREAM+ src/commands/migrate-engine.ts copyPageToTarget call:putPage SEGW+ src/commands/migrate-engine.ts copyPageToTarget field STREAM+ src/commands/migrations/v0_32_2.ts phaseCVerify call:serializePageToMarkdown SEGW+ src/commands/quarantine.ts runClear call:serializeMarkdown SEGW+ src/commands/quarantine.ts runClear field SEGW+ src/commands/quarantine.ts runScan call:serializePageToMarkdown SEGW+ src/commands/quarantine.ts runScan field SEGW+ src/commands/reconcile-links.ts runReconcileLinks field STREAM+ src/commands/reindex-aliases.ts runReindexAliases field STREAM+ src/commands/reindex-code.ts estimateReindexCost field INLINE+ src/commands/reindex-code.ts fetchCodePages sql INLINE+ src/commands/reindex-code.ts runReindexCode field INLINE+ src/commands/reindex.ts readBatch sql STREAM+ src/commands/reindex.ts runReindex call:serializeMarkdown SEGW+ src/commands/reindex.ts runReindex field STREAM+ src/commands/sources.ts runAudit field SEGW+ src/commands/sync/finalize.ts backstopAffectedPageFacts field STREAM+ src/core/ai/decide/review-lane.ts pagePairAnchor field LEAD bounded prefix row+ src/core/ai/decide/review-lane.ts pagePairAnchor sql LEAD boundedBodyPrefixSql (truth_lead for segmented), sliced to PAGE_TEXT_LIMIT+ src/core/attendance-repair.ts prepareOrigin field META+ src/core/attendance-repair.ts readOrigin sql META+ src/core/brainstorm/domain-bank.ts fetchFar field LEAD+ src/core/brainstorm/orchestrator.ts _runBrainstormInner field LEAD+ src/core/by-mention.ts scanStaleMentions sql STREAM+ src/core/chronicle/backfill.ts runChronicleBackfill field STREAM+ src/core/chronicle/backfill.ts runChronicleBackfill sql STREAM+ src/core/chronicle/execute.ts executeChronicleRow field LEAD+ src/core/chronicle/extract-events.ts chronicleJudgeContext field LEAD+ src/core/chronicle/ledger.ts decideChronicle field LEAD+ src/core/chronicle/publish.ts publishChronicleGeneration call:putPage INLINE+ src/core/chronicle/publish.ts publishChronicleGeneration call:serializeMarkdown INLINE+ src/core/code-chunks.ts prepareCodeChunks field INLINE+ src/core/company-brain/inspection.ts readPage field STREAM+ src/core/company-brain/profile.ts importCompanyBrainFile field META+ src/core/company-brain/verification.ts verifyCompanyBrain field STREAM+ src/core/content-repair/judgment.ts judgmentParticipant field STREAM+ src/core/content-sanity.ts assessContentSanity field STREAM+ src/core/context/compile-view.ts compileView field LEAD+ src/core/context/compile-view.ts renderEntry field LEAD+ src/core/context/retrieval-reflex.ts resolveEntitiesToPointers sql LEAD boundedBodyPrefixSql AS compiled_truth+ src/core/context/retrieval-reflex.ts safeSynopsis field LEAD bounded prefix rows+ src/core/context/retrieval-reflex.ts weakTitleHits sql LEAD boundedBodyPrefixSql AS compiled_truth+ src/core/conversation-parser/body.ts readSummaryBody field STREAM+ src/core/core-memory.ts applyCoreSensitivity field INLINE+ src/core/core-memory.ts listCorePages field INLINE+ src/core/core-memory.ts listCorePages sql INLINE+ src/core/core-memory.ts renderCorePage field INLINE+ src/core/cycle/chronicle.ts discover sql STREAM+ src/core/cycle/concept-publication.ts composeConceptRepublication call:serializeMarkdown INLINE+ src/core/cycle/concept-publication.ts composeConceptRepublication field INLINE+ src/core/cycle/concept-publication.ts conceptPreservationHold field INLINE+ src/core/cycle/concept-publication.ts fileHoldsPage field INLINE+ src/core/cycle/concept-publication.ts preserveCanonicalFences call:serializeMarkdown INLINE after assertInlineBody+ src/core/cycle/concept-publication.ts preserveCanonicalFences field INLINE assertInlineBody: refuses a segmented page (concept pages inline; enrich/connector callers SEGW)+ src/core/cycle/concept-publication.ts publishClassicConcept call:serializeMarkdown INLINE+ src/core/cycle/concept-publication.ts publishClassicConcept field INLINE+ src/core/cycle/concept-publication.ts publishManagedConcept call:serializeMarkdown INLINE+ src/core/cycle/dream-taint.ts putDerivedPage call:putPage SEGW+ src/core/cycle/drift.ts runPhaseDrift call:putPage INLINE+ src/core/cycle/drift.ts runPhaseDrift call:serializeMarkdown INLINE+ src/core/cycle/edge-contradictions.ts removeTimelineLine call:serializeMarkdown SEGW+ src/core/cycle/edge-contradictions.ts removeTimelineLine field SEGW+ src/core/cycle/extract-atoms-page-state.ts transferLegacyAtomPageState field META compares two snapshots; segmented page: getter throws page_body_segmented+ src/core/cycle/extract-atoms.ts discoverExtractablePages field STREAM see sql row; CAS is on content_hash + knowledge_revision+ src/core/cycle/extract-atoms.ts discoverExtractablePages sql STREAM minCompiledTruthChars is false for NULL: segmented pages are never discovered (skip until per-segment extraction, PR 4)+ src/core/cycle/extract-atoms.ts minCompiledTruthChars sql STREAM false for a segmented page (NULL body): skip+ src/core/cycle/extract-atoms.ts runPhaseExtractAtoms call:serializeMarkdown SEGW+ src/core/cycle/extract-facts.ts canonicalCacheState field STREAM segmented page: getter throws page_body_segmented+ src/core/cycle/extract-facts.ts planFenceReconcile field STREAM managed preparer: segmented page: getter throws page_body_segmented before any write+ src/core/cycle/extract-facts.ts runExtractFacts field STREAM segmented page skipped with warning FACTS_RECONCILE_SEGMENTED; its facts index is preserved (per-segment reconcile, PR 4)+ src/core/cycle/extract-takes.ts extractTakesFromDb field STREAM+ src/core/cycle/extract-takes.ts plannedTakes field STREAM+ src/core/cycle/extract-takes.ts prepareTakesReextract sql STREAM+ src/core/cycle/extract-takes.ts reconcilePageTakes field STREAM+ src/core/cycle/extract-takes.ts reextractCoordinated field STREAM+ src/core/cycle/extract-takes.ts reextractCoordinated sql STREAM+ src/core/cycle/grade-takes.ts GradeTakesPhase.process field STREAM+ src/core/cycle/link-manifest.ts buildLinkManifest field STREAM+ src/core/cycle/pattern-claim-sources.ts dedupePatternClaimSources call:serializePageToMarkdown SEGW+ src/core/cycle/patterns.ts gatherReflections field LEAD bounded prefix row+ src/core/cycle/patterns.ts gatherReflections sql LEAD boundedBodyPrefixSql, truncated to a 600-byte excerpt+ src/core/cycle/patterns.ts groundPatternPages call:serializePageToMarkdown SEGW+ src/core/cycle/patterns.ts groundPatternPages field LEAD+ src/core/cycle/patterns.ts groundPatternPages sql LEAD+ src/core/cycle/patterns.ts renderPageToMarkdown call:serializeMarkdown SEGW+ src/core/cycle/patterns.ts renderPageToMarkdown field LEAD+ src/core/cycle/phantom-redirect-managed.ts redirectManagedPhantom call:serializePageToMarkdown SEGW spread of a segmented page throws+ src/core/cycle/phantom-redirect-managed.ts redirectManagedPhantom field SEGW segmented page: getter throws page_body_segmented in preparation (nothing written)+ src/core/cycle/phantom-redirect.ts fenceDbDrift field SEGW segmented page: getter throws page_body_segmented+ src/core/cycle/phantom-redirect.ts materializeCanonicalToDisk call:serializeMarkdown SEGW canonical asserted inline by the caller+ src/core/cycle/phantom-redirect.ts materializeCanonicalToDisk field SEGW canonical asserted inline by the caller+ src/core/cycle/phantom-redirect.ts phantomHasResidue field SEGW phantom stubs are small; segmented page: getter throws page_body_segmented+ src/core/cycle/phantom-redirect.ts tryRedirectPhantom call:contentHash META hash of the reparsed inline file+ src/core/cycle/phantom-redirect.ts tryRedirectPhantom call:refreshPageBody SEGW assertInlineBody on the canonical first+ src/core/cycle/phantom-redirect.ts tryRedirectPhantom field SEGW canonical target asserted inline before the disk fence append; per-phantom throw is logged and the walk continues+ src/core/cycle/propose-takes.ts listCandidatePages sql STREAM+ src/core/cycle/propose-takes.ts ProposeTakesPhase.process call:contentHash META+ src/core/cycle/propose-takes.ts ProposeTakesPhase.process field STREAM+ src/core/cycle/synthesize-concepts.ts runPhaseSynthesizeConcepts field INLINE+ src/core/cycle/synthesize-concepts.ts runPhaseSynthesizeConcepts sql INLINE+ src/core/cycle/synthesize-postprocess.ts postprocessManagedSynthesis call:serializePageToMarkdown INLINE+ src/core/cycle/synthesize-postprocess.ts postprocessManagedSynthesis field INLINE+ src/core/cycle/synthesize-postprocess.ts sameBody field INLINE+ src/core/cycle/synthesize-verify-epochs.ts loadPreRunRevision field STREAM+ src/core/cycle/synthesize-verify-epochs.ts loadPreRunRevision sql STREAM+ src/core/cycle/synthesize-verify.ts quarantineUnits field INLINE+ src/core/cycle/synthesize-verify.ts verifyAndRepairDreamPages call:serializePageToMarkdown INLINE+ src/core/cycle/synthesize-verify.ts verifyAndRepairDreamPages field INLINE+ src/core/cycle/synthesize-verify.ts verifyDreamPage field INLINE+ src/core/cycle/synthesize.ts renderPageToMarkdown call:serializePageToMarkdown INLINE+ src/core/cycle/synthesize.ts reverseWriteRefs call:serializePageToMarkdown INLINE+ src/core/cycle/synthesize.ts writeSummaryPage call:serializeMarkdown INLINE+ src/core/cycle/synthesize.ts writeSummaryPage field INLINE+ src/core/cycle/transcript-discovery.ts discoverConversationPages field STREAM+ src/core/cycle/transcript-discovery.ts discoverConversationPages sql STREAM+ src/core/eligibility/fence-overlay.ts loadFenceChunkOverlay field STREAM+ src/core/eligibility/scan.ts assess field STREAM+ src/core/eligibility/scan.ts SELECT sql STREAM+ src/core/embed-consent.ts estimateEmbedBackfillUsd sql META+ src/core/embed-stale-images.ts embedStaleImages sql INLINE+ src/core/embedding-migration-worst-case.ts REPROJECTED_PAGE sql META+ src/core/embedding-readiness.ts countArchivedEmbeddingWork sql META+ src/core/engine-sql/chunks.ts chunklessPagesWhere sql META lane 1e file: body <> '' predicate+ src/core/engine-sql/chunks.ts getChunkWindows sql STREAM lane 1e file: ships whole bodies per hit; NULL for segmented (chunk windows by stored spans in PR 2)+ src/core/engine-sql/chunks.ts listChunklessPagesWithContent field STREAM lane 1e file+ src/core/engine-sql/chunks.ts listChunklessPagesWithContent sql STREAM lane 1e file+ src/core/engine-sql/chunks.ts listEmbeddingStateRows sql META lane 1e file: octet_length metadata+ src/core/engine-sql/page-body.ts createSegmentedPageShell sql NONE not a reader: the segmented storage writer sets the body columns NULL on the shell row+ src/core/engine-sql/page-body.ts flipBodyGeneration sql NONE not a reader: the generation flip sets the body columns NULL and the segmented body columns+ src/core/engine-sql/pages.ts listCorpusSample sql LEAD segmented pages excluded from the sample in SQL (skip)+ src/core/engine-sql/pages.ts listPrefixSampledPages sql LEAD segmented pages excluded from the sample in SQL (skip)+ src/core/engine-sql/pages.ts listStalePagesForExtraction sql STREAM segmented pages skipped in SQL, still counted by countStalePagesForExtraction (visible as stale)+ src/core/engine-sql/pages.ts PAGE_VERSION_COLUMNS sql SEGW lane 1e: versions of segmented pages carry no body+ src/core/engine-sql/pages.ts putPage call:contentHash META hash of the incoming inline body+ src/core/engine-sql/pages.ts putPage field SEGW incoming PageInput body (a string); see putPage sql+ src/core/engine-sql/pages.ts putPage sql SEGW blank-guard reads body_bytes for a segmented page (an empty put over it refuses); a non-empty put over a segmented row is refused by the body-storage CHECK+ src/core/engine-sql/pages.ts refreshPageBody sql SEGW UPDATE of the body columns; the body-storage CHECK refuses it over a segmented row; callers assert first+ src/core/engine-sql/pages.ts revertToVersion sql SEGW lane 1e: refuses a segmented page/version (revert deferred to PR 3)+ src/core/engine-sql/pages.ts toDomainBankRow field LEAD maps sampled rows; segmented pages are never sampled+ src/core/engine-sql/salience.ts listEnrichCandidates sql META+ src/core/engine-sql/timeline.ts getTimeline sql NONE not the page body: SELECT * FROM pages inside a LATERAL used for the page id only+ src/core/enrichment-service.ts enrichEntity call:putPage INLINE+ src/core/enrichment-service.ts enrichEntity call:serializeMarkdown INLINE+ src/core/export-snapshot.ts readExportPage field STREAM export refuses a segmented page: segmented page: getter throws page_body_segmented (streaming export in PR 2)+ src/core/export-snapshot.ts readExportPage sql STREAM+ src/core/extract-ner.ts extractNerLinks field STREAM+ src/core/extract-takes-from-pages.ts extractTakesFromPages call:serializePageToMarkdown SEGW+ src/core/extract-takes-from-pages.ts extractTakesFromPages field STREAM inline rows only (SQL filter)+ src/core/extract-takes-from-pages.ts extractTakesFromPages sql STREAM length(COALESCE(compiled_truth, '')) > 200 skips segmented pages; head-only slice(0, 20000) for inline+ src/core/extract-timeline-from-meetings.ts extractTimelineFromMeetings field STREAM+ src/core/extract-timeline-from-meetings.ts extractTimelineFromMeetings sql STREAM+ src/core/extract/receipt-writer.ts writeReceipt call:putPage INLINE+ src/core/facts/backstop.ts runFactsBackstop field STREAM+ src/core/facts/backstop.ts runPipeline field STREAM+ src/core/facts/drain.ts estimateBacklogUsd sql META+ src/core/facts/eligibility.ts isFactsBackstopEligible field LEAD+ src/core/facts/fence-write.ts writeFactsToFence call:contentHash META+ src/core/facts/fence-write.ts writeFactsToFence call:refreshPageBody SEGW+ src/core/facts/fence-write.ts writeFactsToFence field SEGW+ src/core/facts/forget.ts forgetFactInFence call:contentHash META inline pages only+ src/core/facts/forget.ts forgetFactInFence call:refreshPageBody SEGW assertInlineBody first+ src/core/facts/forget.ts forgetFactInFence field SEGW assertInlineBody before the DB strike/mirror (best-effort: the withdrawal record stays authoritative)+ src/core/facts/proposal-supersede.ts acceptUnmanaged field SEGW mirrorBody refuses a segmented page before the file publish+ src/core/facts/proposal-supersede.ts mirrorBody call:contentHash META inline pages only+ src/core/facts/proposal-supersede.ts mirrorBody call:refreshPageBody SEGW assertInlineBody first+ src/core/facts/proposal-supersede.ts mirrorBody field SEGW assertInlineBody before refreshPageBody (inside the transaction, before the file publish)+ src/core/facts/proposal-supersede.ts prepareProposalMutation call:serializePageToMarkdown SEGW spread of a segmented page throws+ src/core/facts/proposal-supersede.ts prepareProposalMutation field SEGW segmented page: getter throws page_body_segmented in preparation (nothing written)+ src/core/facts/proposal-supersede.ts undoUnmanaged field SEGW segmented page: getter throws page_body_segmented+ src/core/facts/purge-verify.ts verifyFactPurge sql STREAM pages store reports unverified (segmented_body) while the source holds segmented pages; segment probe in PR 2+ src/core/facts/purge-verify.ts verifyPagePurge sql STREAM source_prose store reports unverified (segmented_body) while the source holds segmented pages; segment probe in PR 2+ src/core/facts/purge.ts planFactPurge sql SEGW strpos over NULL never matches a segmented page; the purge refuses segmented targets (rewritePageBodies)+ src/core/facts/purge.ts redactPageVersions field SEGW lane 1e: segmented versions carry no body+ src/core/facts/purge.ts redactPageVersions sql SEGW lane 1e: segmented versions carry no body+ src/core/facts/purge.ts rewritePageBodies call:contentHash META inline pages only (see sql row)+ src/core/facts/purge.ts rewritePageBodies field SEGW segmented page: getter throws page_body_segmented+ src/core/facts/purge.ts rewritePageBodies sql SEGW refuses a segmented target with page_body_segmented before rewriting (segment purge in PR 2)+ src/core/facts/reconcile-watermark.ts readFactsReconcileBacklog sql STREAM+ src/core/facts/reconcile-watermark.ts selectFactsReconcileDrain sql STREAM+ src/core/facts/relink-publish.ts prepareRelinkMutation call:serializePageToMarkdown SEGW+ src/core/facts/relink-publish.ts prepareRelinkMutation field SEGW+ src/core/facts/subject-infer-write.ts linkAllowed field STREAM+ src/core/facts/unfenced-facts.ts auditUnadoptableFacts call:serializePageToMarkdown SEGW+ src/core/facts/unfenced-facts.ts fenceFilePage call:contentHash META+ src/core/facts/unfenced-facts.ts fenceFilePage call:refreshPageBody SEGW+ src/core/facts/unfenced-facts.ts fenceFilePage field SEGW+ src/core/facts/unfenced-facts.ts planManagedPage call:serializePageToMarkdown SEGW+ src/core/facts/withdrawal-discovery.ts discoverWithdrawalTargets field STREAM inline rows only+ src/core/facts/withdrawal-discovery.ts discoverWithdrawalTargets sql STREAM page scan reads inline bodies (NULL never matches); segmented pages are found by the chunk scan and their mirror writers refuse or skip (per-segment discovery, PR 2)+ src/core/fence-repair/census.ts judgePages field STREAM+ src/core/fence-repair/content.ts contentPass field STREAM+ src/core/fence-repair/hold-fix.ts fenceFileLine field STREAM+ src/core/fence-repair/import-step.ts applyImportFences field STREAM+ src/core/fence-repair/import-step.ts hiddenFenceRows field STREAM+ src/core/fence-repair/import-step.ts resolveImportFences field STREAM+ src/core/fence-repair/import-step.ts settleImportFences field STREAM+ src/core/fence-repair/import-step.ts storedPageStep field STREAM+ src/core/fence-repair/normalize.ts withSections field STREAM+ src/core/fence-repair/page-checks.ts sectionsOf field STREAM+ src/core/fence-repair/refusal.ts completeFenceLocation field STREAM+ src/core/fence-repair/refusal.ts scanCanonicalFences field STREAM+ src/core/fence-repair/repair-io.ts pageSha field SEGW+ src/core/fence-repair/repair-io.ts readFenceTarget field SEGW+ src/core/fence-repair/repair-io.ts spliceFileSections field SEGW+ src/core/fence-repair/repair-io.ts writeFenceRepair call:serializePageToMarkdown SEGW+ src/core/fence-repair/repair-io.ts writeFenceRepair field SEGW+ src/core/fence-repair/repair-tiers.ts holderAt field STREAM+ src/core/fence-repair/tier1.ts pageHasFenceText field STREAM+ src/core/fts-language.ts pageSearchVectorTriggerFnSql sql LEAD+ src/core/google/loops-extract.ts runLoopsExtract field STREAM tail slice(-12000) of a getPage body; per-job: segmented page: getter throws page_body_segmented+ src/core/import-file.ts applyImportTransaction call:putPage SEGW lane 1d file (streaming ingest); code/image pages inline+ src/core/import-file.ts importCodeFile call:putPage SEGW lane 1d file (streaming ingest); code/image pages inline+ src/core/import-file.ts importFromContent call:contentHash META lane 1d file+ src/core/import-file.ts importFromContent call:putPage SEGW lane 1d file (streaming ingest); code/image pages inline+ src/core/import-file.ts importFromContent call:refreshPageBody SEGW lane 1d file (streaming ingest); code/image pages inline+ src/core/import-file.ts importFromContent field SEGW lane 1d file (streaming ingest); code/image pages inline+ src/core/import-file.ts importImageFile field SEGW lane 1d file (streaming ingest); code/image pages inline+ src/core/import-identity.ts decideImportIdentity field META+ src/core/import-screen.ts assessImportSanity field STREAM+ src/core/import-screen.ts screenImportContent call:contentHash META+ src/core/import-screen.ts screenImportContent field STREAM+ src/core/link-reconciliation.ts reconcileSourceLinks field STREAM segmented page skipped with failure code page_body_segmented; the cursor moves past it (per-segment links, PR 4)+ src/core/link-temporal-apply.ts applyTemporalEvidence field STREAM+ src/core/link-temporal-evidence.ts deriveTemporalEvidence field STREAM+ src/core/markdown-chunks.ts overlaidChunks field STREAM+ src/core/markdown-chunks.ts prepareFenceAwareMarkdownChunks call:prepareMarkdownChunks STREAM+ src/core/markdown-chunks.ts prepareFenceAwareMarkdownChunks field STREAM+ src/core/markdown.ts parseMarkdown field STREAM+ src/core/markdown.ts serializePageToMarkdown call:serializeMarkdown SEGW+ src/core/markdown.ts serializePageToMarkdown field STREAM+ src/core/mentions/aliases.ts deriveEntityAliases field STREAM+ src/core/mentions/pass.ts pagesMatchingNames sql STREAM segmented pages excluded in SQL+ src/core/mentions/pass.ts reconcileSource field STREAM inline rows only+ src/core/mentions/pass.ts reconcileSource sql STREAM segmented pages excluded in SQL (stay due and pending until the per-segment pass)+ src/core/mentions/pass.ts refreshAliases sql STREAM segmented pages excluded in SQL+ src/core/minions/handlers/facts-absorb.ts makeFactsAbsorbHandler field STREAM+ src/core/minions/handlers/subagent-oneshot.ts runSubagentOneshot call:serializeMarkdown SEGW+ src/core/ops/admin.ts get_versions field SEGW lane 1e: segmented versions return metadata only+ src/core/ops/attribution.ts get_write_attribution field NONE not the page body: timeline entry id param+ src/core/ops/attribution.ts rowTarget field NONE not the page body: timeline entry id param+ src/core/ops/get-page-body.ts bodyBytes field META+ src/core/ops/get-page-body.ts readPartialBody call:serializePageToMarkdown SEGW+ src/core/ops/get-page-projection.ts projectFetchText call:serializePageToMarkdown STREAM fetch text of an inline page; spread of a segmented page throws+ src/core/ops/get-page-projection.ts projectGetPage call:serializePageToMarkdown STREAM full content render of an inline page+ src/core/ops/get-page-projection.ts projectGetPage field STREAM segmented page: getter throws page_body_segmented (windowed read in PR 2)+ src/core/ops/pages.ts get_page field STREAM get_page full body: segmented page: getter throws page_body_segmented (windowed read in PR 2)+ src/core/ops/pages.ts stripPrivacyFencesForRemoteReader field STREAM segmented page: getter throws page_body_segmented+ src/core/output/post-write.ts runPostWriteLint field INLINE+ src/core/output/validators/link.ts linkValidator field INLINE+ src/core/output/validators/triple-hr.ts tripleHrValidator field INLINE+ src/core/output/writer.ts runValidators field INLINE+ src/core/output/writer.ts WriteTxImpl.createEntity call:putPage INLINE+ src/core/output/writer.ts WriteTxImpl.createEntity field INLINE+ src/core/output/writer.ts WriteTxImpl.setCompiledTruth call:putPage INLINE+ src/core/output/writer.ts WriteTxImpl.setCompiledTruth field INLINE+ src/core/output/writer.ts WriteTxImpl.setFrontmatterField call:putPage INLINE+ src/core/output/writer.ts WriteTxImpl.setFrontmatterField field INLINE+ src/core/oversized-backfill.ts PAGE_BYTES_SQL sql SEGW+ src/core/oversized-backfill.ts reindexPage call:serializeMarkdown SEGW+ src/core/oversized-backfill.ts reindexPage field SEGW+ src/core/page-body/body-scan.ts scanMarkdownString field NONE not a stored body: scans an incoming markdown string for the segmenter+ src/core/page-body/content-hash-stream.ts ContentHashStream.fromState field NONE not a stored body: resumes the streaming content hash over incoming text+ src/core/page-body/content-hash-stream.ts streamingContentHash field NONE not a stored body: hashes an incoming page streamed region by region+ src/core/page-body/page-shape.ts pageBodyBytes field INLINE inline branch of pageBodyBytes; a segmented page answers body_bytes+ src/core/page-body/schema.ts PAGE_GENERATION_BUMP_FN_SQL sql STREAM trigger DDL: compares the body columns of inline rows; segmented rows compare body_generation (lane 1a)-src/core/page-embedding-budget.ts pageBytes field META lane 1e file: body_bytes for segmented pages+ src/core/page-embedding-budget.ts planPageEmbedding field META lane 1e file: body_bytes for segmented pages+ src/core/page-embedding-budget.ts readPageSizeStates sql META lane 1e file: body_bytes for segmented pages-src/core/page-embedding-budget.ts sizeStateField field META lane 1e file: body_bytes for segmented pages+ src/core/page-snapshot-batch.ts readPageSnapshotsBatch field STREAM same as readPageSnapshot: overlay skipped for a segmented page+ src/core/page-snapshot-batch.ts readPageSnapshotsBatch sql STREAM p.* feeds rowToPage; the byte budget counts a segmented row as 0 (no body shipped); fingerprint over a NULL body is empty+ src/core/page-state/credential-reseal.ts PENDING sql STREAM regex over NULL is false: segmented pages postdate the v189 unseal and are chunked by the credential-safe segment chunker; pem regions in PR 2+ src/core/page-state/import-guard.ts canonicalFields field META+ src/core/page-state/import-guard.ts sameContentAnyKeyOrder field META+ src/core/page-state/materialize.ts materializePageSnapshot call:contentHash META inline pages only+ src/core/page-state/materialize.ts materializePageSnapshot field SEGW assertInlineBody before the UPDATE+ src/core/page-state/materialize.ts materializePageSnapshot sql SEGW assertInlineBody before the UPDATE+ src/core/page-state/projection-schema.ts PAGE_SEARCH_VECTOR_TRIGGER_SQL sql STREAM trigger DDL: the search vector reads timeline for inline rows and timeline_lead for segmented rows (lane 1a)+ src/core/page-state/projections.ts preparePageProjection call:prepareMarkdownChunks STREAM+ src/core/page-state/projections.ts readGuardedProjectionSnapshot field STREAM+ src/core/page-state/projections.ts sealImportedPage field STREAM+ src/core/page-state/projections.ts sealPageTextProjection field STREAM+ src/core/page-state/schema.ts PAGE_STATE_SCHEMA_STATEMENTS sql STREAM revision trigger tuple (lane 1a adds body_generation)+ src/core/page-state/snapshot.ts overlayCanonicalBodies field STREAM overlays a caller-supplied body string (file bytes), not a stored segmented body+ src/core/page-state/snapshot.ts overlayCanonicalBodies sql STREAM normalizes the caller-supplied body+ src/core/page-state/snapshot.ts readSnapshotStatement field STREAM withdrawal overlay runs on inline pages only; segmented page skips it (per-window overlay in PR 2)+ src/core/page-state/snapshot.ts readSnapshotStatement sql STREAM p.* feeds rowToPage (projects body_storage/body_bytes); the fingerprint over a NULL body is empty+ src/core/page-state/versions.ts createPageVersion field SEGW lane 1e file: segmented versions reference a generation+ src/core/page-state/versions.ts createPageVersion sql SEGW lane 1e file: segmented versions reference a generation+ src/core/page-window/bounded-lead.ts overlaidBoundedPrefix field LEAD see overlaidBoundedRows+ src/core/page-window/bounded-lead.ts overlaidBoundedRows field LEAD rows carry boundedBodyPrefixSql (truth_lead for segmented); a segmented page whose lead holds a facts fence gets an empty lead (fail closed)+ src/core/page-window/document.ts projectPageText field STREAM+ src/core/page-window/document.ts readPageDocument call:pageDocument STREAM+ src/core/page-window/document.ts readPageDocument field STREAM+ src/core/persistence/atom-maintenance.ts prepareManagedAtomMutation field META+ src/core/persistence/atom-maintenance.ts readAtomOrigin field META+ src/core/persistence/atom-retry.ts retryManagedAtomBatch field STREAM+ src/core/persistence/canonical-projections.ts canonicalTakeRows field STREAM per-page projection: segmented page: getter throws page_body_segmented+ src/core/persistence/canonical-projections.ts compileCanonicalProjections field STREAM per-page projection: segmented page: getter throws page_body_segmented+ src/core/persistence/canonical-projections.ts materializeTimeline field STREAM per-page projection: segmented page: getter throws page_body_segmented+ src/core/persistence/canonical-projections.ts prepareCanonicalProjections field STREAM per-page projection: segmented page: getter throws page_body_segmented+ src/core/persistence/canonical-projections.ts safeBody field STREAM per-page projection: segmented page: getter throws page_body_segmented+ src/core/persistence/connector-google-receipts.ts prepareGoogleReceiptPatch call:contentHash META+ src/core/persistence/connector-google-receipts.ts prepareGoogleReceiptPatch call:serializePageToMarkdown SEGW+ src/core/persistence/connector-sync.ts ManagedConnectorSync.page call:serializePageToMarkdown SEGW+ src/core/persistence/connector-sync.ts prepareConnectorMutation call:serializePageToMarkdown SEGW+ src/core/persistence/connector-sync.ts prepareConnectorMutation field SEGW+ src/core/persistence/core-guard.ts prepareCoreGuard field INLINE+ src/core/persistence/effect-facts.ts bodyAlreadyOffered field META+ src/core/persistence/effect-links.ts mentionTargets field STREAM per-page effect: segmented page: getter throws page_body_segmented+ src/core/persistence/effects.ts gitPage call:serializePageToMarkdown SEGW segmented target skipped (skipped reason page_body_segmented) before the serialize+ src/core/persistence/effects.ts mirrorPage call:serializePageToMarkdown SEGW segmented target skipped (skipped reason page_body_segmented) before the serialize; per-segment mirror in PR 2+ src/core/persistence/embedding-settlement.ts listEmbeddingCandidates sql META+ src/core/persistence/facts-maintenance.ts prepareManagedFactsSession field META+ src/core/persistence/facts-prepare.ts prepareManagedFactsMutation call:serializePageToMarkdown SEGW assertInlineBody first+ src/core/persistence/facts-prepare.ts prepareManagedFactsMutation field SEGW assertInlineBody on the entity snapshot before the fence write+ src/core/persistence/file-repair.ts canonicalRepairFields field META+ src/core/persistence/grandfather.ts prepareGrandfatherMutation call:contentHash META+ src/core/persistence/grandfather.ts prepareGrandfatherMutation call:serializePageToMarkdown SEGW+ src/core/persistence/import-prepare.ts prepareManagedImportMutation call:serializePageToMarkdown SEGW+ src/core/persistence/large-page-guard.ts assertLargePageAdmission sql META stored size = body_bytes for a segmented page, octet_length of the columns for an inline page+ src/core/persistence/links-maintenance.ts extractManagedStaleLinks field NONE not the page body: result.timeline counter+ src/core/persistence/links-maintenance.ts formatManagedStaleExtraction field NONE not the page body: result.timeline counter+ src/core/persistence/links-preparation.ts prepareAutomaticLinks field STREAM reads the incoming parsed page, not a stored body+ src/core/persistence/loop-fact-retirement.ts prepareLoopFactRetirement call:serializePageToMarkdown SEGW+ src/core/persistence/loop-fact-retirement.ts prepareLoopFactRetirement field SEGW+ src/core/persistence/memory-mutations.ts planRememberTarget call:serializePageToMarkdown SEGW+ src/core/persistence/memory-mutations.ts planRememberTarget field STREAM+ src/core/persistence/memory-prepare.ts prepareMemoryMutation call:serializePageToMarkdown SEGW assertInlineBody first+ src/core/persistence/memory-prepare.ts prepareMemoryMutation field SEGW assertInlineBody before the fence write+ src/core/persistence/page-advisories.ts lineGrammarAdvisory field STREAM+ src/core/persistence/page-advisories.ts preparePageAdvisories field STREAM+ src/core/persistence/page-edit.ts pageSegments call:serializePageToMarkdown SEGW+ src/core/persistence/page-edit.ts pageSegments field SEGW+ src/core/persistence/page-input.ts normalizeSubagentPageInput call:serializeMarkdown SEGW+ src/core/persistence/page-input.ts normalizeSubagentPageInput field SEGW+ src/core/persistence/page-prepare.ts canonical field SEGW lane 1d file; segmented page: getter throws page_body_segmented+ src/core/persistence/page-prepare.ts fileMatchesSnapshot field SEGW lane 1d file; segmented page: getter throws page_body_segmented+ src/core/persistence/page-prepare.ts preparePageMutation call:serializePageToMarkdown SEGW lane 1d file+ src/core/persistence/page-prepare.ts preparePageMutation field SEGW lane 1d file: preserveProtectedTakes reads the snapshot body; segmented page: getter throws page_body_segmented+ src/core/persistence/page-purge.ts purgePageInTransaction call:contentHash META+ src/core/persistence/page-purge.ts purgePageInTransaction field STREAM+ src/core/persistence/page-purge.ts purgePageInTransaction sql STREAM+ src/core/persistence/prepared-maintenance.ts stampMaintenancePage call:serializePageToMarkdown SEGW+ src/core/persistence/prepared-maintenance.ts verifyMaintenanceOutputs call:serializePageToMarkdown SEGW+ src/core/persistence/purged-intent.ts intentCarriesPurgedContent call:contentHash META+ src/core/persistence/purged-intent.ts intentCarriesPurgedContent field STREAM+ src/core/persistence/reconcile-audit.ts auditCanonicalSource sql META+ src/core/persistence/reconcile-merge.ts reconcileCanonical field INLINE+ src/core/persistence/reconcile-prepare.ts prepareReconcileMutation call:serializePageToMarkdown INLINE+ src/core/persistence/reconcile-prepare.ts prepareReconcileResult call:serializePageToMarkdown INLINE+ src/core/persistence/reconcile-prepare.ts prepareReconcileResult field INLINE+ src/core/persistence/reconcile-state.ts readReconcileState sql INLINE+ src/core/persistence/reconcile.ts runReconcilePreview call:serializePageToMarkdown SEGW+ src/core/persistence/semantic-pages.ts prepareSemanticPageMutation call:serializePageToMarkdown SEGW assertInlineBody first+ src/core/persistence/semantic-pages.ts prepareSemanticPageMutation field SEGW assertInlineBody after the identity check (tag and timeline writes refuse)+ src/core/persistence/sync-prepare.ts prepareManagedSyncCode field INLINE code pages are never segmented+ src/core/persistence/sync-prepare.ts prepareManagedSyncMutation call:serializePageToMarkdown SEGW lane 1d file+ src/core/persistence/sync-prepare.ts prepareManagedSyncMutation field SEGW lane 1d file: preserveProtectedTakes; segmented page: getter throws page_body_segmented+ src/core/persistence/takes-prepare.ts prepare call:serializePageToMarkdown SEGW+ src/core/persistence/writer-guard-schema.ts MANAGED_WRITER_GUARD_FUNCTION_SQL sql STREAM managed-writer guard tuple (lane 1a adds body_generation)+ src/core/pglite-engine.ts PGLiteEngine.putPage call:putPage SEGW delegation to engine-sql putPage+ src/core/pglite-engine.ts PGLiteEngine.refreshPageBody call:refreshPageBody SEGW delegation to engine-sql refreshPageBody+ src/core/post-upgrade-reembed.ts computeReembedEstimate sql META+ src/core/postgres-engine.ts PostgresEngine.putPage call:putPage SEGW delegation to engine-sql putPage+ src/core/postgres-engine.ts PostgresEngine.refreshPageBody call:refreshPageBody SEGW delegation to engine-sql refreshPageBody+ src/core/quarantine-override.ts quarantineOverrideBinding field META+ src/core/quarantine-override.ts quarantineOverrideFor field META+ src/core/questions/freshness.ts OWNER_BODY_HASH_SQL sql META owner-evidence change signal: content_hash for a segmented page, md5 of the body for inline (stored evidence unchanged)+ src/core/questions/pages.ts readQuestionPage field INLINE see sql row+ src/core/questions/pages.ts readQuestionPage sql INLINE question pages are inline by construction; assertInlineBody refuses a segmented one+ src/core/questions/pages.ts renderPage call:serializePageToMarkdown INLINE+ src/core/questions/pages.ts syncQuestionPage field INLINE+ src/core/questions/refresh.ts refreshPin field INLINE owner claims of the question page (readQuestionPage asserts inline)+ src/core/questions/refresh.ts retrieveEvidence field LEAD inline candidates only+ src/core/questions/refresh.ts retrieveEvidence sql LEAD segmented candidate pages excluded in SQL (skip): their excerpt and laundering check need the body+ src/core/reindex-consent.ts estimateReindexSpend sql META+ src/core/repair/captured-facts.ts strikeFencedRows call:serializePageToMarkdown SEGW+ src/core/repair/captured-facts.ts strikeFencedRows field SEGW+ src/core/repair/connector-fences.ts candidates sql STREAM+ src/core/repair/connector-fences.ts connectorFencesRepair call:serializePageToMarkdown SEGW+ src/core/repair/connector-fences.ts connectorFencesRepair field STREAM+ src/core/repair/connector-fences.ts relocateTimelineFences field STREAM+ src/core/repair/conversation-labels.ts classifyLabelFacts sql STREAM+ src/core/repair/conversation-labels.ts countLabelFacts sql STREAM+ src/core/repair/extractor-facts.ts restorePageFacts field STREAM+ src/core/repair/extractor-facts.ts restorePageFacts sql STREAM+ src/core/repair/fences.ts afterBytes field STREAM+ src/core/repair/fences.ts fencesRepair field STREAM+ src/core/repair/frontmatter.ts analyzeFile field LEAD+ src/core/repair/frontmatter.ts pagesByOrigin sql LEAD+ src/core/repair/orphan-children.ts PROBE_SQL sql META+ src/core/repair/safe-chunks.ts safeChunksRepair sql META+ src/core/repair/slug-conflicts.ts pageContent call:serializePageToMarkdown SEGW+ src/core/repair/stale-atoms.ts staleAtoms sql META+ src/core/repair/take-supersession.ts readPage call:serializePageToMarkdown SEGW+ src/core/repair/timeline-comments.ts timelineCommentsRepair call:serializePageToMarkdown SEGW+ src/core/repair/timeline-comments.ts timelineCommentsRepair field STREAM+ src/core/repair/timeline-comments.ts timelineCommentsRepair sql STREAM+ src/core/repair/timeline.ts classifyTimelinePage field STREAM+ src/core/repair/timeline.ts recountTimelinePages sql STREAM+ src/core/repair/timeline.ts removedRowIds field STREAM+ src/core/repair/timeline.ts scanTimelineHistory sql STREAM+ src/core/repair/timeline.ts timelineRepair call:serializePageToMarkdown SEGW+ src/core/repair/timeline.ts timelineRepair field STREAM+ src/core/repair/visibility.ts planVisibilityRepair sql META+ src/core/repair/visibility.ts visibilityRepair call:serializePageToMarkdown SEGW+ src/core/schema-migrations/v091-pages-generation-trigger-and-bookmark.ts v091 sql NONE not the page body: historical generation trigger+ src/core/schema-migrations/v123-configurable-fts-language.ts v123 sql NONE not the page body: historical+ src/core/schema-migrations/v124-page-search-vector-drop-compiled-truth.ts v124 sql NONE not the page body: historical search-vector trigger+ src/core/schema-migrations/v189-pages-credential-projection-pending.ts v189 sql NONE not a live reader: historical migration over inline pages (segmented pages did not exist)+ src/core/schema-migrations/v248-segmented-page-storage.ts COMMON_SQL sql NONE not a live reader: migration DDL for the segmented body columns and their CHECK+ src/core/schema-pack/field-usage.ts runFieldUsage field LEAD+ src/core/schema-pack/field-usage.ts runFieldUsage sql LEAD+ src/core/schema-pack/page-to-alias.ts resolveValue field LEAD+ src/core/schema-pack/page-to-alias.ts runPageToAliasCore field LEAD+ src/core/schema-pack/page-to-alias.ts runPageToAliasCore sql LEAD+ src/core/schema-pack/page-to-link.ts resolveSlug field LEAD+ src/core/schema-pack/page-to-link.ts runPageToLinkCore field LEAD+ src/core/schema-pack/page-to-link.ts runPageToLinkCore sql LEAD+ src/core/search-vector-backfill.ts backfillPageVectors field LEAD+ src/core/search-vector-backfill.ts backfillPageVectors sql LEAD+ src/core/search/alias-hop.ts aliasInjectedRow field LEAD projectedLead over getPage: segmented page: getter throws page_body_segmented (lead source in PR 2)+ src/core/search/chunk-windows.ts mapChunkWindowRows field STREAM+ src/core/search/entity-anchor.ts entityAnchoredPages sql STREAM+ src/core/search/evidence-delivery.ts deliverEvidence field STREAM+ src/core/search/exact-lookup.ts structuralExactLookup field LEAD projectedLead over getPage: segmented page: getter throws page_body_segmented (lead source in PR 2)+ src/core/search/provenance-demotion.ts applyGeneratedDemotion field LEAD+ src/core/search/provenance-demotion.ts applyGeneratedDemotion sql LEAD+ src/core/search/read-enrichment.ts readAliases sql NONE not the page body: SELECT * FROM pages used for identity columns+ src/core/search/read-enrichment.ts readChainHop sql META SELECT * FROM pages by id; protectedBodyFilter(ev) reads body_flags for a segmented page+ src/core/search/relational-recall.ts hydrate field LEAD synopsis from boundedBodyPrefixSql+ src/core/search/safe-chunks.ts bodyWriteChunkVersion sql SEGW spliced into inline body writes only; a segmented row refuses those writes (CHECK)+ src/core/search/safe-chunks.ts protectedBodyFilter sql META segmented page: body_flags.has_protected decides, missing flag counts as protected (fail closed)+ src/core/shared-skills/migration-export.ts exportInventory call:serializeMarkdown INLINE+ src/core/shared-skills/migration-export.ts exportInventory field INLINE+ src/core/shared-skills/migration-projection.ts assertExportProjectionRoundtrip field INLINE+ src/core/sweep.ts runLinksTimelinePass field STREAM segmented page skipped (skip reason page_body_segmented:links_timeline)+ src/core/sweep.ts runMaintenanceSweep sql STREAM LIKE over NULL never matches a segmented page (skip)+ src/core/think/gather.ts renderPagesBlockDetailed field LEAD segmented page: getter throws page_body_segmented+ src/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 LEAD+ src/core/think/index.ts persistSynthesis call:putPage SEGW+ src/core/timeline-dedup-repair.ts repairLegacyTimelineSourceRows field STREAM+ src/core/timeline-dedup-repair.ts repairLegacyTimelineSourceRows sql STREAM+ src/core/timeline-extract.ts pruneTimelineOrphans field STREAM+ src/core/timeline-extract.ts pruneTimelineOrphans sql STREAM+ src/core/timeline-extract.ts retractCoordinated field STREAM+ src/core/timeline-extract.ts retractCoordinated sql STREAM+ src/core/timeline-extract.ts retractRemovedTimelineEntries field STREAM+ src/core/timeline-extract.ts retractRemovedTimelineEntries sql STREAM+ src/core/timeline-write-through.ts writeTimelineEntryThrough field SEGW assertInlineBody before the file or row is touched+ src/core/timeline-write-through.ts writeTimelineEntryThrough sql SEGW assertInlineBody before the file or row is touched+ src/core/transcripts/recover.ts userlessCodexSessions sql STREAM+ src/core/transcripts/secret-audit.ts auditTranscriptSecrets field STREAM+ src/core/transcripts/secret-audit.ts auditTranscriptSecrets sql STREAM+ src/core/trust/page-handlers.ts markdownWithoutMarker call:serializeMarkdown SEGW+ src/core/trust/page-handlers.ts markdownWithoutMarker field SEGW+ src/core/trust/page-handlers.ts versionMarkdown call:serializePageToMarkdown SEGW+ src/core/trust/page-handlers.ts versionMarkdown field SEGW+ src/core/utils.ts contentHash field META hashes a whole inline page; a segmented page hashes as a stream (1.4) and keeps content_hash; called on a segmented Page the getter throws+ src/core/utils.ts contentHashLegacy field META legacy formula over an inline page; segmented: getter throws+ src/core/utils.ts rowToPage field INLINE installs throwing body getters on a segmented row (guardSegmentedBody); inline rows copy the columns+ src/core/utils.ts rowToStalePage field STREAM listStalePagesForExtraction lists inline pages only (segmented skipped in SQL, still counted stale)+ src/core/verbs/entity-card-identity.ts readCardIdentity field LEAD+ src/core/verbs/entity-card.ts selectEntityCandidates sql LEAD boundedBodyPrefixSql AS compiled_truth+ src/core/verbs/entity-names.ts lookupOne field LEAD bounded prefix rows+ src/core/verbs/entity-names.ts lookupOne sql LEAD boundedBodyPrefixSql AS compiled_truth+ src/core/write-gate-scan.ts SPECS field STREAM+ src/core/write-gate-scan.ts SPECS sql STREAM+ src/core/write-gate.ts assessPageForGate field STREAM+ src/core/write-through.ts writePageThrough call:serializePageToMarkdown SEGW+ src/eval/brainbench/metrics/trust-reads.ts canaryHeld sql STREAM+ src/eval/brainbench/metrics/trust-reads.ts canaryPersisted sql STREAM+ src/eval/chronicle/harness.ts seedChronicleEvalCorpus call:putPage SEGW+ src/eval/longmemeval/call-plan.ts planPages call:prepareMarkdownChunks INLINE+ src/eval/longmemeval/call-plan.ts planPages field INLINE+ src/core/page-body/segmenter.ts Segmenter.blocked field NONE not the page body: st.timeline is the segmenter's timeline-run parser state+ src/core/page-body/segmenter.ts Segmenter.line field NONE not the page body: st.timeline is the segmenter's timeline-run parser state+ src/core/page-body/segmenter.ts Segmenter.piece field NONE not the page body: st.timeline is the segmenter's timeline-run parser statediff --cc scripts/run-verify-parallel.shindex cf553c96b0,139c7f80f1..6d83253401--- a/scripts/run-verify-parallel.sh+++ b/scripts/run-verify-parallel.sh@@@ -177,9 -177,9 +177,12 @@@ CHECKS=# Goal (a) (refactor wave 1): engine SQL only shrinks; baseline# scripts/engine-sql-baseline.tsv."check:engine-sql-ratchet"+ # Wave B segmented storage (spec 1.5 layer 4): whole-body page readers only+ # shrink; baseline scripts/page-body-readers-baseline.tsv.+ "check:page-body-readers"+ # Wave B large pages: every content_chunks reader applies the chunk-visibility+ # predicate or carries a reason; baseline scripts/chunk-visibility-baseline.tsv only shrinks.+ "check:chunk-visibility"# CQ3 / EO17 (refactor wave 1): engine-sql splices only constant text, no# composed $n, no expanded IN lists."check:engine-sql-dynamic"diff --cc src/core/ops/get-page-body.tsindex 38b6884610,bd54ab8cc7..d80b6f38f4--- a/src/core/ops/get-page-body.ts+++ b/src/core/ops/get-page-body.ts@@@ -269,6 -269,15 +270,16 @@@ function setNext(out: Record<string, unout.next = { tool: 'get_page', arguments: { slug: page.slug, source_id: page.source_id, cursor, ...(markdown ? { view: 'markdown' } : {}) } };}+ /** The `body: 'none'` response: `out` plus chunk and embedding counts, no text. */+ async function noneResult(ctx: OperationContext, page: Page, out: Record<string, unknown>, truncated: boolean): Promise<Record<string, unknown>> {+ const [counts] = await ctx.engine.executeRaw<{ total: unknown; embedded: unknown }>(- `SELECT count(*) AS total, count(*) FILTER (WHERE embedded_at IS NOT NULL) AS embedded FROM content_chunks WHERE page_id = $1`, [page.id]);++ `SELECT count(*) AS total, count(*) FILTER (WHERE embedded_at IS NOT NULL) AS embedded FROM content_chunks++ WHERE page_id = $1 AND ${chunkGenerationProbe('content_chunks')}`, [page.id]);+ const fm = (page.frontmatter ?? {}) as Record<string, unknown>;+ return { ...out, chunks: { total: Number(counts?.total ?? 0), embedded: Number(counts?.embedded ?? 0) },+ ...(fm.embed_skip ? { embed_skip: true } : {}), truncated };+ }+/*** The partial (none / outline / window / auto-above-threshold) response. Never* carries compiled_truth, timeline or content.diff --cc src/core/page-embedding-budget.tsindex 3c003f963a,5e9b6cb892..e9ab6095ab--- a/src/core/page-embedding-budget.ts+++ b/src/core/page-embedding-budget.ts@@@ -32,8 -32,7 +32,9 @@@* budget it may already have used.*/import type { BrainEngine } from './engine.ts';-import { assessSampledJunk } from './content-sanity.ts';+import { JUNK_SAMPLE_CHARS, assessJunkWindows, assessSampledJunk } from './content-sanity.ts';- import type { ManifestRow } from './page-body/types.ts';++import type { BodyStorage, ManifestRow } from './page-body/types.ts';++import { isSegmentedPage, pageBodyBytes } from './page-body/page-shape.ts';import { estimateCostFromChars, lookupEmbeddingPrice } from './embedding-pricing.ts';import { PAGE_INLINE_MAX_BYTES, isLargePageBytes } from './page-size-policy.ts';import { isEmbedSkipped } from './embed-skip.ts';@@@ -74,42 -72,10 +75,33 @@@ export type PageEmbedDecisioninterface BudgetRow { state: PageBudgetState; reason: string | null; embedding_signature: string | null; spent_usd: number; reserved_usd: number; stale_reservation: boolean; cap_usd: number | null }-type BudgetPage = { id: number; compiled_truth: string; timeline?: string | null };+/** A segmented page (Wave B) carries `body_bytes` and no body strings; an inline page carries its body. */- type BudgetPage = { id: number; body_storage?: string | null; body_bytes?: number | string | null; compiled_truth?: string; timeline?: string | null };-- function isSegmentedBudgetPage(page: BudgetPage): boolean {- return page.body_storage === 'segmented';- }-- function pageBytes(page: BudgetPage): number {- if (isSegmentedBudgetPage(page)) return Number(page.body_bytes);- return Buffer.byteLength(page.compiled_truth ?? '', 'utf-8') + Buffer.byteLength(page.timeline ?? '', 'utf-8');- }++type BudgetPage = { id: number; body_storage?: BodyStorage | null; body_bytes?: number | null; compiled_truth?: string; timeline?: string | null };-function pageBytes(page: BudgetPage): number {- return Buffer.byteLength(page.compiled_truth, 'utf-8') + Buffer.byteLength(page.timeline ?? '', 'utf-8');+/**+ * The head, middle and tail sample windows of a segmented page, read one+ * segment at a time from the live manifest (never the whole body): the head+ * window from the first segments, the middle window from the segment at the+ * middle byte on, the tail window from the last segments back.+ */+async function segmentedSampleWindows(engine: BrainEngine, pageId: number): Promise<string[]> {+ const manifest = await engine.readManifest(pageId);+ if (manifest.length === 0) return [''];+ const decoder = new TextDecoder();+ const read = async (row: ManifestRow) => {+ const texts = await engine.readSegmentTexts(row.sourceId, [row.sha256]);+ return decoder.decode(texts.get(Buffer.from(row.sha256).toString('hex')) ?? new Uint8Array());+ };+ const forward = async (from: number) => {+ let text = '';+ for (let i = from; i < manifest.length && text.length < JUNK_SAMPLE_CHARS; i++) text += await read(manifest[i]!);+ return text.slice(0, JUNK_SAMPLE_CHARS);+ };+ let tail = '';+ for (let i = manifest.length - 1; i >= 0 && tail.length < JUNK_SAMPLE_CHARS; i--) tail = await read(manifest[i]!) + tail;+ const totalBytes = manifest.reduce((n, row) => n + row.byteLen, 0);+ const middle = manifest.findIndex(row => row.byteStart + row.byteLen > totalBytes / 2);+ return [await forward(0), await forward(Math.max(0, middle)), tail.slice(-JUNK_SAMPLE_CHARS)];}function currentPricePerMTok(signature: string | null | undefined): { rate: number; priced: boolean } {@@@ -133,7 -99,7 +125,7 @@@ export async function holdPageEmbeddingexport async function planPageEmbedding(engine: BrainEngine, page: BudgetPage,stale: ReadonlyArray<{ chunk_index: number; chunk_text: string }>,opts: { signature?: string | null; approvedCapUsd?: number; maxMarkupRatio?: number } = {}): Promise<PageEmbedDecision> {-- if (!isLargePageBytes(pageBytes(page)) || stale.length === 0) return { kind: 'unmetered' };++ if (!isLargePageBytes(pageBodyBytes(page)) || stale.length === 0) return { kind: 'unmetered' };const approved = opts.approvedCapUsd !== undefined;const configured = await resolvePageEmbedCapUsd(engine);const { rate, priced } = currentPricePerMTok(opts.signature);@@@ -145,9 -111,7 +137,9 @@@if (!row) return { kind: 'unmetered' } as const;if (row.state === 'held' && !approved) return { kind: 'held', reason: row.reason ?? 'awaiting_approval' } as const;if (!approved && row.state === 'open') {- const junk = isSegmentedBudgetPage(page)- const junk = assessSampledJunk(`${page.compiled_truth}\n${page.timeline ?? ''}`, { max_markup_ratio: opts.maxMarkupRatio });++ const junk = isSegmentedPage(page)+ ? assessJunkWindows(await segmentedSampleWindows(tx, page.id), { max_markup_ratio: opts.maxMarkupRatio })+ : assessSampledJunk(`${page.compiled_truth}\n${page.timeline ?? ''}`, { max_markup_ratio: opts.maxMarkupRatio });if (junk.junk) {const reason = junk.reasons.join(',');await tx.executeRaw(`UPDATE page_embedding_budget SET state = 'held', reason = $2, updated_at = now() WHERE page_id = $1`, [page.id, reason]);@@@ -314,10 -278,9 +306,9 @@@ export async function readPageSizeState/** The receipt field for one written page: `{ size_state }` for a large or embed_skip page, else nothing (no query). */export async function sizeStateField(engine: Pick<BrainEngine, 'executeRaw'>, sourceId: string, slug: string,- page: { body_storage?: string | null; body_bytes?: number | string | null; compiled_truth?: string | null; timeline?: string | null; frontmatter?: Record<string, unknown> | null } | null | undefined): Promise<{ size_state?: PageSizeState }> {- page: { compiled_truth?: string | null; timeline?: string | null; frontmatter?: Record<string, unknown> | null } | null | undefined): Promise<{ size_state?: PageSizeState }> {++ page: { body_storage?: BodyStorage | null; body_bytes?: number | null; compiled_truth?: string | null; timeline?: string | null; frontmatter?: Record<string, unknown> | null } | null | undefined): Promise<{ size_state?: PageSizeState }> {if (!page) return {};- const bytes = page.body_storage === 'segmented' ? Number(page.body_bytes)- : Buffer.byteLength(page.compiled_truth ?? '', 'utf-8') + Buffer.byteLength(page.timeline ?? '', 'utf-8');- const bytes = Buffer.byteLength(page.compiled_truth ?? '', 'utf-8') + Buffer.byteLength(page.timeline ?? '', 'utf-8');++ const bytes = pageBodyBytes(page);if (!isLargePageBytes(bytes) && !isEmbedSkipped(page.frontmatter)) return {};const [state] = await readPageSizeStates(engine, sourceId, [slug]);return state ? { size_state: { embedding: state.embedding, reason: state.reason, bytes: state.bytes } } : {};diff --cc src/core/page-state/projections.tsindex 877e0c8909,c7b82d6508..c075896bbf--- a/src/core/page-state/projections.ts+++ b/src/core/page-state/projections.ts@@@ -16,8 -16,6 +16,8 @@@ import { getEmbeddingModel } from '../aimport { jsonRowBatches } from '../batch-rows.ts';import { refreshProjectionStatistics } from '../search/projection-statistics.ts';import { belowSafeChunkFence, movableChunkSql } from '../search/safe-chunks.ts';+import { buildSegmentedProjection } from '../page-body/projection.ts';- import { isSegmentedSnapshotPage } from './versions.ts';++import { isSegmentedPage } from '../page-body/page-shape.ts';import { acceptedEmbeddingInputHashes, embeddingInputHash, plainEmbeddingTier, synopsisBodyHash,type EmbeddingInputContext, type EmbeddingTier } from '../embedding-input-hash.ts';@@@ -159,7 -153,7 +159,7 @@@ export async function readProjectionSnaasync function readGuardedProjectionSnapshot(tx: BrainEngine, slug: string, sourceId: string,opts: { allowUnsealed?: boolean; maxChunkTokens?: number; requireLiveSource?: boolean }): Promise<ProjectionSnapshot | null> {const snapshot = await tx.readPageSnapshot(slug, { sourceId, ...(opts.requireLiveSource && { requireLiveSource: true }) });- if (!snapshot || isSegmentedSnapshotPage(snapshot.page) || (!opts.allowUnsealed && snapshot.page.text_projection_revision !== snapshot.revision)) return null;- if (!snapshot || (!opts.allowUnsealed && snapshot.page.text_projection_revision !== snapshot.revision)) return null;++ if (!snapshot || isSegmentedPage(snapshot.page) || (!opts.allowUnsealed && snapshot.page.text_projection_revision !== snapshot.revision)) return null;const context = await indexingContext(tx, snapshot, opts.maxChunkTokens);const fenceOverlay = context.pageKind === 'markdown' ? await loadFenceChunkOverlay(tx, { sourceId, slug, compiled_truth: snapshot.page.compiled_truth, timeline: snapshot.page.timeline }) : undefined;return { snapshot, chunks: await tx.getChunks(slug, { sourceId, includeUnsealed: true }), indexingContext: context.key,@@@ -288,7 -282,7 +288,7 @@@ export async function installPageEmbeddawait tx.lockPageKeys([{ sourceId, slug }]);const current = await tx.readPageSnapshot(slug, { sourceId });if (!current || current.page.deleted_at || current.sourceIncarnation !== snapshot.sourceIncarnation || current.page.id !== snapshot.page.id- || current.page.text_projection_revision !== current.revision || isSegmentedSnapshotPage(current.page)) return refused;- || current.page.text_projection_revision !== current.revision) return refused;++ || current.page.text_projection_revision !== current.revision || isSegmentedPage(current.page)) return refused;const [source] = await tx.executeRaw<{ archived: boolean }>('SELECT archived FROM sources WHERE id=$1', [sourceId]);if (!source || source.archived) return refused;const context = await indexingContext(tx, current, prepared.maxChunkTokensOverride);diff --cc src/core/page-state/versions.tsindex 14a1c41bd5,dd9abc5715..ff4b8903f8--- a/src/core/page-state/versions.ts+++ b/src/core/page-state/versions.ts@@@ -2,11 -2,14 +2,11 @@@ import type { BrainEngine } from '../enimport type { PageVersion } from '../types.ts';import type { PageSnapshot } from './types.ts';import { PAGE_INLINE_MAX_BYTES, isLargePageBytes } from '../page-size-policy.ts';+import { LARGE_PAGE_VERSIONS_KEPT, readPageBodyPolicy } from '../page-body/limits.ts';+import { opError, type OperationError } from '../ops/contract.ts';- import type { RegistryCode } from '../error-registry.ts';++import { isSegmentedPage } from '../page-body/page-shape.ts';-/**- * Snapshots of a large page (over the inline cap) kept per page. Each one is a- * full copy of the body, so an append-heavy 24 MiB page would otherwise grow- * history by 24 MiB per write. Snapshots at or under the inline cap, and every- * snapshot of a small page, are never pruned.- */-export const LARGE_PAGE_VERSIONS_KEPT = 5;+export { LARGE_PAGE_VERSIONS_KEPT };/*** Version the same canonical view an API reader receives, including withdrawals.@@@ -16,7 -19,6 +16,7 @@@export async function createPageVersion(engine: BrainEngine, slug: string, sourceId: string, preimage?: PageSnapshot): Promise<PageVersion> {const insert = async (tx: BrainEngine, snapshot: PageSnapshot) => {const { page, tags, revision } = snapshot;- if (isSegmentedSnapshotPage(page)) return insertSegmentedVersion(tx, snapshot);++ if (isSegmentedPage(page)) return insertSegmentedVersion(tx, snapshot);const rows = await tx.executeRaw<PageVersion>(`INSERT INTO page_versions(page_id,compiled_truth,frontmatter,knowledge_revision,timeline,title,type,tags,is_deleted,source_path)VALUES ($1,$2,$3::text::jsonb,$4::uuid,$5,$6,$7,$8::text::jsonb,$9,$10) RETURNING *`,@@@ -36,76 -38,3 +36,65 @@@return insert(tx, snapshot);});}+- /**- * A segmented page row: `body_storage` once the snapshot projects it (lane- * 1c's page shape), else the NULL body only a segmented row stores- * (`pages_body_storage_chk`). `body_storage` is read first, so lane 1c's body- * getters never fire here.- */- export function isSegmentedSnapshotPage(page: PageSnapshot['page']): boolean {- const storage = (page as { body_storage?: unknown }).body_storage;- return storage === undefined ? page.compiled_truth == null : storage === 'segmented';- }-+/**+ * Wave B (spec 5): a segmented page's version is a reference, not a copy: the+ * page's live body generation (its manifest rows stay alive as a GC root),- * body_bytes and content_hash with NULL body columns, O(1) at any page size.++ * body_bytes and content_hash; its body columns stay NULL. O(1) at any page size.+ * It references the generation live when it is inserted, so a caller versions+ * before its generation flip, as every caller versions before its page write.+ * Then the page's segmented history is pruned by `pruneSegmentedVersions`.+ */+async function insertSegmentedVersion(tx: BrainEngine, snapshot: PageSnapshot): Promise<PageVersion> {+ const { page, tags, revision } = snapshot;+ const [row] = await tx.executeRaw<PageVersion>(`INSERT INTO page_versions- (page_id,compiled_truth,timeline,body_storage,body_generation,body_bytes,content_hash,frontmatter,knowledge_revision,title,type,tags,is_deleted,source_path)- SELECT p.id,NULL,NULL,'segmented',p.body_generation,p.body_bytes,p.content_hash,$2::text::jsonb,$3::uuid,$4,$5,$6::text::jsonb,$7,$8++ (page_id,body_storage,body_generation,body_bytes,content_hash,frontmatter,knowledge_revision,title,type,tags,is_deleted,source_path)++ SELECT p.id,'segmented',p.body_generation,p.body_bytes,p.content_hash,$2::text::jsonb,$3::uuid,$4,$5,$6::text::jsonb,$7,$8+ FROM pages p WHERE p.id = $1 AND p.body_storage = 'segmented' RETURNING *`,+ [page.id, JSON.stringify(page.frontmatter), revision, page.title, page.type, JSON.stringify(tags), page.deleted_at != null, page.source_path ?? null]);+ if (!row) throw new Error(`createVersion failed: page id ${page.id} is no longer segmented`);+ if ((await pruneSegmentedVersions(tx, page.id)) > 0) await tx.sweepSegments({ pageId: page.id });+ return { ...row, snapshot_at: new Date(row.snapshot_at) };+}++/**+ * Segmented retention (spec 5): keep the newest `versions.segmented_max_per_page`+ * segmented versions of the page, and prune oldest-first while the bytes they+ * pin beyond the live generation (manifest rows a kept version's generation+ * references that are closed, each counted once) exceed+ * max(`versions.segmented_max_pinned_bytes`, the page's body_bytes). A row's+ * bytes count from the newest version that references it, so the pinned bytes+ * of the newest k versions are a running sum and the kept set is a prefix.+ * Inline snapshots of the page are never touched here. Returns the versions deleted.+ */+export async function pruneSegmentedVersions(tx: BrainEngine, pageId: number): Promise<number> {+ const policy = await readPageBodyPolicy(tx);+ const deleted = await tx.executeRaw(`WITH v AS (+ SELECT id, body_generation AS g, row_number() OVER (ORDER BY id DESC) AS rk+ FROM page_versions WHERE page_id = $1 AND body_storage = 'segmented'),+ pinned AS (+ SELECT min(v.rk) AS rk, m.byte_len+ FROM page_body_manifest m JOIN v ON m.gen_from <= v.g AND v.g < m.gen_to+ WHERE m.page_id = $1 AND m.gen_to IS NOT NULL AND m.staging_id IS NULL+ GROUP BY m.occurrence_id, m.gen_from, m.byte_len),+ per_rank AS (SELECT rk, sum(byte_len) AS bytes FROM pinned GROUP BY rk),+ kept AS (+ SELECT v.id, v.rk, sum(COALESCE(per_rank.bytes, 0)) OVER (ORDER BY v.rk) AS bytes+ FROM v LEFT JOIN per_rank ON per_rank.rk = v.rk),+ cap AS (SELECT GREATEST($3::bigint, COALESCE(body_bytes, 0)) AS bytes FROM pages WHERE id = $1)+ DELETE FROM page_versions WHERE id IN (SELECT kept.id FROM kept, cap WHERE kept.rk > $2 OR kept.bytes > cap.bytes)+ RETURNING id`, [pageId, policy.versionsMaxPerPage, policy.versionsMaxPinnedBytes]);+ return deleted.length;+}++/**+ * `revert_version` of a segmented page or version is not available until the+ * segment writer (Wave B PR 3): the version's body lives in segments, and the+ * revert path rebuilds the page from an inline body. Refused before anything is written.+ */+export function segmentedRevertRefusal(slug: string, versionId: unknown): OperationError {- return opError('page_body_segmented' as RegistryCode,++ return opError('page_body_segmented',+ `Page ${slug} or its version ${String(versionId)} is stored in segments, so revert_version cannot restore it yet; nothing was changed.`,+ `Read the version with get_versions (body_bytes, content_hash), then write the content you want with put_page or edit_page.`,+ { reason: 'segmented_revert' });+}diff --cc src/core/persistence/page-prepare.tsindex ecc240dd57,717e365be7..58c266d270--- a/src/core/persistence/page-prepare.ts+++ b/src/core/persistence/page-prepare.ts@@@ -41,7 -41,6 +41,8 @@@ import { isUnboundSourcePage } from './import { sealImportedPage, sealPageTextProjection } from '../page-state/projections.ts';import { pipelined } from '../page-state/transactions.ts';import { overlayCanonicalBodies } from '../page-state/snapshot.ts';+import { segmentedRevertRefusal } from '../page-state/versions.ts';++import { isSegmentedPage } from '../page-body/page-shape.ts';import { materializeTimeline, prepareCanonicalProjections, type TimelineRowsRemoved } from './canonical-projections.ts';import { assertTimelineNotOmitted, timelineWritePolicy } from './timeline-omission.ts';import { preserveProtectedTakes } from './protected-takes.ts';@@@ -441,7 -440,6 +442,7 @@@ export async function preparePageMutati'SELECT * FROM page_versions WHERE id=$1 AND page_id=$2', [p.version_id, page.id]);if (!version) throw pageRefusal('not_found', 'Version not found for this page.', row,`Version ${String(p.version_id)} is not in the history of page ${row.slug}, so nothing was reverted. List the page's versions (get_versions; CLI: gbrain history) and revert to one of them.`);- if (version.body_storage === 'segmented' || (page as { body_storage?: unknown }).body_storage === 'segmented') throw segmentedRevertRefusal(row.slug, p.version_id);++ if (version.body_storage === 'segmented' || isSegmentedPage(page)) throw segmentedRevertRefusal(row.slug, p.version_id);targetDeleted = version.is_deleted ?? (snapshot.page.deleted_at != null);page = { ...page, compiled_truth: version.compiled_truth, frontmatter: version.frontmatter,...(version.timeline !== null && version.timeline !== undefined ? { timeline: version.timeline } : {}),