Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
Merge PR 4 round-2 lane 4b2 into capy/wave-b-pr4 (synopsis spend through meterPaidCall, compare-and-set install kept)
garrytan200df4614e31
diff --cc src/core/behavior-change-notice.tsindex b56c515cf9,1573a3411e..cb04a07f2e--- a/src/core/behavior-change-notice.ts+++ b/src/core/behavior-change-notice.ts@@@ -1050,9 -1050,9 +1050,10 @@@ export const BEHAVIOR_CHANGES: Readonly// PR 4 4b{ since: 'TBD', text: 'Appending to a long conversation now re-extracts facts only for the new messages.' },{ since: 'TBD', text: 'Atom extraction now covers very large pages, and after an append reads only the new text.' },- { since: 'TBD', text: 'The per-page spend cap now also covers fact and atom extraction on large pages; doctor lists pages it stopped.' },+ { since: 'TBD', text: 'Fact, atom and synopsis extraction on a large page now each have their own per-page spend cap, `derive.max_usd_per_page` (default $2 per kind over the page\'s lifetime; unlimited under `spend.posture tokenmax` when unset; `off` disables it), separate from `embed.max_usd_per_page`, which now counts embeddings only, so extraction never uses up a page\'s embedding budget and a new embedding model does not reset extraction spend. Each call reserves its worst case (every retry) and books what the provider reported; a call that failed after the provider answered is still booked. Doctor lists the pages a cap stopped.' },// PR 4 (Wave B incremental derivation, transcripts) — 4c, contextual synopsis per segment. `since` is restamped at the merge slot.+ { since: 'TBD', text: 'With contextual retrieval set to `per_chunk_synopsis`, a page stored in segments now gets per-chunk synopses instead of staying on the title tier: each chunk\'s synopsis reads the page title, the first 8 KiB of the page and up to 32 KB of its own segment, so the contextual re-embed (`gbrain reindex --markdown` and the per-chunk synopsis backfill) re-synopsizes only the segments an append or edit rewrote and leaves every other chunk\'s vector as it is. The page\'s spend cap (`embed.max_usd_per_page`) bounds the synopsis calls: when it is reached, the rest of the page keeps its title-tier vectors (`budget_limited`) and nothing more is spent. A chunk whose synopsis the model refuses is embedded at the title tier. After `gbrain reindex --segmented --apply` re-chunks a page, the next pass synopsizes its new chunks; a window whose synopsis or embedding fails counts only the synopsis calls the provider may have billed against the cap. Pages read whole are unchanged.' },+ { since: 'TBD', text: 'With contextual retrieval set to `per_chunk_synopsis`, a page stored in segments now gets per-chunk synopses instead of staying on the title tier: each chunk\'s synopsis reads the page title, the first 8 KiB of the page and up to 32 KB of its own segment, so the contextual re-embed (`gbrain reindex --markdown` and the per-chunk synopsis backfill) re-synopsizes only the segments an append or edit rewrote and leaves every other chunk\'s vector as it is. The page\'s synopsis cap (`derive.max_usd_per_page`) bounds the synopsis calls: when it is reached, the rest of the page keeps its title-tier vectors (`budget_limited`) and nothing more is spent. A chunk whose synopsis the model refuses is embedded at the title tier. Pages read whole are unchanged.' },// PR 4 (Wave B incremental derivation, transcripts)// PR 4 4a{ since: 'TBD', text: 'Links, mentions, timeline entries and facts/takes fences of a large (segmented) page are now kept per segment, so a write reads only the segments it changed, and an append reads its new tail instead of the whole page. A rewrite of the whole page does the same work as before. The results are unchanged.' },diff --cc src/core/contextual-retrieval-service.tsindex 74b0b48c4f,b745d26731..40cda7282a--- a/src/core/contextual-retrieval-service.ts+++ b/src/core/contextual-retrieval-service.ts@@@ -70,11 -70,11 +70,11 @@@ import { digest, sha256 } from './persiimport { isLargePageBytes } from './page-size-policy.ts';import { isSegmentedPage, pageBodyBytes } from './page-body/page-shape.ts';import { installSegmentedVectors, listLiveEmbedSegments, listSegmentChunkRows, readSegmentedEmbedPage } from './page-body/segmented-embedding.ts';+import { acquirePageEmbeddingLease } from './page-embedding-lease.ts';import { planSegmentDerivations, segmentDerivationContextHash } from './page-body/derivations.ts';-import { SEGMENTED_CHUNKER_VERSION } from './page-body/segment-chunks.ts';import { embeddingInputHash, synopsisDocumentHash, type EmbeddingTier } from './embedding-input-hash.ts';import { currentEmbeddingSignature } from './embedding.ts';- import { estimatePageEmbedUsd, reservePageSpend } from './page-embedding-budget.ts';+ import { estimatePageEmbedUsd, meterPaidCall } from './page-embedding-budget.ts';import { segmentSynopsisLead } from './page-body/segment-synopsis.ts';/**