Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

F2 rework: the frozen-comparison policy (rendered-body characters, section, chunks reserved first)

garrytana0d34dd623c3
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1b0b1a7195..25279e95a1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,7 +12,7 @@ identifiers and attribution are available in the pre-removal Git revision
## [Unreleased: cat40 next wave part 1, version stamped at merge] - 2026-10-12
-- **Evidence delivery (F2 plumbing): long non-conversation pages can come back in a delivery unit, off by default.** New key `search.long_page_unit` (`off` default | `window` | `section` | `page`; `gbrain config set` refuses other values). Under the implied `auto` on `search` and `query`, a hit on a page whose stored body holds at least 8,000 bytes is delivered in that unit, counted in the existing delivery budget; every other hit keeps its ranked chunk. One precedence table (`docs/evidence-delivery.md`, "Long pages"): an explicit `return_unit`, then a non-`auto` `search.return_unit`, then this key; an explicit `token_budget` or `snippet_chars` keeps it off. The policy is resolved at the search/query caller (`withLongPagePolicy`), so recall, think and `assemble_evidence` are byte-identical with it on. `selectLongPages` runs one byte-count preflight under the read scope; at most 5 long pages and 1,000,000 body bytes per call are fetched in their own bounded batched call under a 2,000 ms deadline, whole pages only; any long page it cannot deliver keeps its ranked chunk (`delivered.reason: "long_page_chunk"`, a `long_page_*` fallback code). Lean rows keep `delivered: {unit, reason}` on long-page rows (plus `truncated: true` when cut); every other lean row keeps `{truncated: true}` only. The off path is byte-identical (`test/evidence-delivery-golden.test.ts` unchanged); a second frozen golden pins the on path (`test/fixtures/goldens/evidence-delivery/long-page-on-path.json`). Tests: `test/evidence-long-page.test.ts` (PGLite), `test/e2e/evidence-long-page.test.ts` (Postgres). No passage selector is built; the unit is chosen later by the frozen-hit comparison.
+- **Evidence delivery (F2 plumbing): long non-conversation pages can come back in a delivery unit, off by default.** New key `search.long_page_unit` (`off` default | `window` | `section` | `page`; `gbrain config set` refuses other values; `section` is the value under test). Under the implied `auto` on `search` and `query`, a hit on a page whose rendered body holds at least `search.long_page_min_chars` characters (new key, default 20,000) is widened to that unit inside the existing `search.return_budget_conversation` budget; every other hit keeps its ranked chunk, reserved first, and widened units fill only what is left. One precedence table (`docs/evidence-delivery.md`, "Long pages"): an explicit `return_unit`, then a non-`auto` `search.return_unit`, then this key; an explicit `token_budget` or a positive `snippet_chars` (which head-cuts every block) keeps it off, and `snippet_chars: 0` leaves it on. The policy is resolved at the search/query caller (`withLongPagePolicy`), so recall, think and `assemble_evidence` are byte-identical with it on. `selectLongPages` runs one character/byte-count preflight under the read scope, and delivery confirms the threshold on the rendered body; at most 5 long pages and 1,000,000 body bytes per call are fetched in their own bounded batched call under a 2,000 ms deadline, whole pages only; any long page it cannot deliver keeps its ranked chunk (`delivered.reason: "long_page_chunk"`, a `long_page_*` fallback code). Lean rows keep `delivered: {unit, reason}` on long-page rows (plus `truncated: true` when cut); every other lean row keeps `{truncated: true}` only. The off path is byte-identical (`test/evidence-delivery-golden.test.ts` unchanged); a second frozen golden pins the on path (`test/fixtures/goldens/evidence-delivery/long-page-on-path.json`). Tests: `test/evidence-long-page.test.ts` (PGLite: replay case, threshold key, cap and explicit-unit paths byte-identical with the key on), `test/e2e/evidence-long-page.test.ts` (Postgres). No passage selector is built; the unit is chosen later by the frozen-hit comparison.
- **Served instructions (F4): the record in effect on the date asked about governs, not the newest one.** Instruction 7 now reads "The record whose terms are in effect on the date asked about governs: a page's `date`/`effective_date` is when it was written, not when its terms take effect, and a change not yet effective does not apply yet; drafts, proposals and agent-written notes do not override records." (`date` is named only where `entity` is callable). It replaces "prefer the newest governing source: a later correction, handoff or executed change outranks an older record". The rule now leads the answering clause and ends inside the first 2,048 characters capped harnesses read (starter 1,566–1,842, full 1,717–1,993; it started at 1,943 and 2,094). New key `mcp.instructions_governing_rule` (`in_effect` default, `newest` serves the earlier sentence for measurement). Budget: the sentence is 74 characters longer; 11 are paid by cutting "the best-ranked excerpts" to "top excerpts" in the same clause, and +63 is recorded in `test/mcp-schema-budget.test.ts` (5,108 for the maximal rendering). Tests: `test/mcp-instructions-governing-rule.test.ts`.
- **Served instructions (d5b): the brief clause no longer recommends a `referenced_by` walk batch mode cannot do.** `src/mcp/instructions.ts`: the walk is on the single-name `entity` card, and the clause names what a compact `entity names` row carries on this brain (its `next` to the card while `entity.names_references` is on, the default; `records` by type once `entity.record_types` enrolls page types, empty by default). Every transport reads both keys at initialize through `readInstructionContent` (fail-closed to the defaults); the static contract, bootstrap's instructions file and the SDK constructor fallback are the defaults rendering. One reader module, `src/core/entity-references-config.ts`, serves both keys. Budget: +70 characters for the maximal rendering (+39 at the default), recorded in `test/mcp-schema-budget.test.ts` and `test/mcp-initialize-instructions.test.ts`. Tests: `test/mcp-instructions-references.test.ts`.
diff --git a/docs/architecture/key-files/core-search-2.md b/docs/architecture/key-files/core-search-2.md
index a769ecf5d7..28842c2115 100644
--- a/docs/architecture/key-files/core-search-2.md
+++ b/docs/architecture/key-files/core-search-2.md
@@ -7,7 +7,7 @@ Current behavior and load-bearing invariants; history belongs in Git and CHANGEL
- `src/core/search/rrf-page-fusion.ts` — `accumulateRrf(lists)`, the one accumulation step behind `rrfFusion` / `rrfFusionWeighted` in `hybrid.ts`. Votes are keyed on the PAGE `(source_id, slug)`: each list adds `weight / (k + rank)` to a page once, at its best rank, chunks stay distinct rows keyed `(source_id, slug, chunk_id)` with their own vote (`own`) and an OR-propagated `keyword_hit` (`keyword_relaxed` only if every holding list was relaxed), and each page's lead chunk (largest `own`, first-seen on ties — a vector arm in `composeFusionLists` order) scores the page's summed vote while its other chunks score their own vote. Pure. Pinned by `test/search/rrf-page-grain.test.ts`.
-- `src/core/search/evidence-delivery.ts` — the `return_unit` evidence assembler (default `auto`: conversation pages by type or `chat/`/`conversations/` slug come back whole under `search.return_budget_conversation` (24,000), every other hit is its unchanged chunk; `effectivePlan` skips the stage when an implied `auto` sees no conversation hit, so that path and `chunk` stay byte-identical). `resolveEvidencePlan` validates `return_unit` / `return_window` (invalid_params naming the allowed values and an example), reads `search.return_unit` / `think.return_unit`, `search.return_window`, `search.return_budget_default` (6,000), `search.return_budget_conversation` (24,000) and clamps remote budgets to `search.return_budget_max_remote` (32,000, reported). Snippet precedence: explicit `snippet_chars` > explicit `return_unit` > subagent default cap > config unit. `deliverEvidence` groups hits by page_id (one block per page at its best rank), makes ONE `engine.getChunkWindows` call (re-authorizes every page; unauthorized pages are dropped, never served from hit text), builds the page text from the stored body sanitized whole and passed through `credentialSafeProjection` before slicing (`pageEvidenceText`: compiled truth + serializer timeline sentinel + timeline; frontmatter excluded; private-key spans become newline-padded `<REDACTED:private_key_pem>` tokens, the same text the chunkers cut from), locates the hit chunks in it (`locateChunks`: exact, then whitespace-insensitive, since the chunker trims and folds whitespace), cuts `window` / `section` (ATX headings outside code fences, or conversation rounds detected structurally, never by page type) / `page` / `auto` (fenced-code hits are placed by their code minus the chunker's synthesized header), counts tokens as the sum of per-line cl100k counts, reserves each page's matching span before enriching by rank, caps blocks at 60,000 characters, redacts secrets before final accounting, and returns NEW rows with `delivered` plus a `delivery` meta. The plan records `budgetExplicit` (the caller passed the budget) and the resolved `packing` (`search.auto_packing` or the library override); `capEngaged` (unit `auto`, explicit budget, packing not `off`) routes allocation to `allocateCapped`: global rank one first (cut with `EVIDENCE_CUT_MARKER` when it alone exceeds the budget), the rank-order prefix of other non-conversation chunks that fits (rest `budget_note`), then conversations by `cap_only` (floors, then enrichment), `breadth_capped` (longest prefix whose title + floor + `return_window` target window fits; rest `breadth_cap`) or `depth_first` (each session grown in turn); nothing spills. `capEvidenceToBudget` recounts title + `chunk_text` at the final boundary (after redaction and `capDeliveredSnippets`, whose marker is paid from the row's own allocation) and rewrites `budget_used`. Without an explicit budget none of this runs and the bytes are the pre-cap path's. Fetch failure/timeout (5 s) falls back to the hit chunk only for live hits. `assembleEvidenceForHits` / op `assemble_evidence` deliver the exact evidence `query` returns for a frozen `(source_id, slug, chunk_id)` list, `effective_date` included (`applyEffectiveDate`, the live rows' normalizer); `evidenceFingerprint` hashes it (gbrain-evals E1/E3 parity). With `search.evidence_date_header` on (`plan.dateHeader`), each block (including `auto` passthrough chunks) starts with its one-line date header from `evidence-date.ts`, reserved in the block floor like the title, counted in `delivered.tokens`, with spans shifted past it and `delivery.date_header: true`; a failed date read renders `unknown` and adds `date_header_unavailable`. `search.long_page_unit` (F2, default `off`): `withLongPagePolicy` (called only by the `search`/`query` caller, so recall, think and `assemble_evidence` never carry it) sets `plan.longPage` under an implied `auto` with no explicit budget or `snippet_chars`; `selectLongPages` runs one byte-count preflight under the read scope (long = `LONG_PAGE_MIN_BYTES` 8,000; at most `LONG_PAGE_MAX_PAGES` 5 and `LONG_PAGE_MAX_INPUT_BYTES` 1,000,000, whole pages only; `LONG_PAGE_DEADLINE_MS` 2,000 for preflight plus fetch) and returns exactly `effectivePlan` when no page is long; `deliverEvidence` fetches the selected pages in their own bounded `getChunkWindows` call, delivers them in the unit with `reason: long_page`, and returns any it cannot deliver (limits, deadline, fetch failure, over budget) as their ranked chunk with `reason: long_page_chunk` and a `long_page_*` fallback. Normative spec: `docs/evidence-delivery.md`. Tests: `test/evidence-delivery.test.ts`, `test/evidence-delivery-golden.test.ts`, `test/e2e/evidence-delivery-leak.test.ts`, `test/e2e/evidence-delivery-parity.test.ts`; bench `scripts/bench-evidence-delivery.ts`.
+- `src/core/search/evidence-delivery.ts` — the `return_unit` evidence assembler (default `auto`: conversation pages by type or `chat/`/`conversations/` slug come back whole under `search.return_budget_conversation` (24,000), every other hit is its unchanged chunk; `effectivePlan` skips the stage when an implied `auto` sees no conversation hit, so that path and `chunk` stay byte-identical). `resolveEvidencePlan` validates `return_unit` / `return_window` (invalid_params naming the allowed values and an example), reads `search.return_unit` / `think.return_unit`, `search.return_window`, `search.return_budget_default` (6,000), `search.return_budget_conversation` (24,000) and clamps remote budgets to `search.return_budget_max_remote` (32,000, reported). Snippet precedence: explicit `snippet_chars` > explicit `return_unit` > subagent default cap > config unit. `deliverEvidence` groups hits by page_id (one block per page at its best rank), makes ONE `engine.getChunkWindows` call (re-authorizes every page; unauthorized pages are dropped, never served from hit text), builds the page text from the stored body sanitized whole and passed through `credentialSafeProjection` before slicing (`pageEvidenceText`: compiled truth + serializer timeline sentinel + timeline; frontmatter excluded; private-key spans become newline-padded `<REDACTED:private_key_pem>` tokens, the same text the chunkers cut from), locates the hit chunks in it (`locateChunks`: exact, then whitespace-insensitive, since the chunker trims and folds whitespace), cuts `window` / `section` (ATX headings outside code fences, or conversation rounds detected structurally, never by page type) / `page` / `auto` (fenced-code hits are placed by their code minus the chunker's synthesized header), counts tokens as the sum of per-line cl100k counts, reserves each page's matching span before enriching by rank, caps blocks at 60,000 characters, redacts secrets before final accounting, and returns NEW rows with `delivered` plus a `delivery` meta. The plan records `budgetExplicit` (the caller passed the budget) and the resolved `packing` (`search.auto_packing` or the library override); `capEngaged` (unit `auto`, explicit budget, packing not `off`) routes allocation to `allocateCapped`: global rank one first (cut with `EVIDENCE_CUT_MARKER` when it alone exceeds the budget), the rank-order prefix of other non-conversation chunks that fits (rest `budget_note`), then conversations by `cap_only` (floors, then enrichment), `breadth_capped` (longest prefix whose title + floor + `return_window` target window fits; rest `breadth_cap`) or `depth_first` (each session grown in turn); nothing spills. `capEvidenceToBudget` recounts title + `chunk_text` at the final boundary (after redaction and `capDeliveredSnippets`, whose marker is paid from the row's own allocation) and rewrites `budget_used`. Without an explicit budget none of this runs and the bytes are the pre-cap path's. Fetch failure/timeout (5 s) falls back to the hit chunk only for live hits. `assembleEvidenceForHits` / op `assemble_evidence` deliver the exact evidence `query` returns for a frozen `(source_id, slug, chunk_id)` list, `effective_date` included (`applyEffectiveDate`, the live rows' normalizer); `evidenceFingerprint` hashes it (gbrain-evals E1/E3 parity). With `search.evidence_date_header` on (`plan.dateHeader`), each block (including `auto` passthrough chunks) starts with its one-line date header from `evidence-date.ts`, reserved in the block floor like the title, counted in `delivered.tokens`, with spans shifted past it and `delivery.date_header: true`; a failed date read renders `unknown` and adds `date_header_unavailable`. `search.long_page_unit` (F2, default `off`): `withLongPagePolicy` (called only by the `search`/`query` caller, so recall, think and `assemble_evidence` never carry it) sets `plan.longPage` (unit plus `search.long_page_min_chars`, default 20,000) under an implied `auto` with no explicit budget or positive `snippet_chars`; `selectLongPages` runs one character/byte-count preflight under the read scope (long = stored body at least `minChars` characters, confirmed on the rendered `pageEvidenceText` at delivery; at most `LONG_PAGE_MAX_PAGES` 5 and `LONG_PAGE_MAX_INPUT_BYTES` 1,000,000, whole pages only; `LONG_PAGE_DEADLINE_MS` 2,000 for preflight plus fetch) and returns exactly `effectivePlan` when no page is long; `deliverEvidence` fetches the selected pages in their own bounded `getChunkWindows` call, delivers them in the unit with `reason: long_page`, and returns any it cannot deliver (limits, deadline, fetch failure, over budget) as their ranked chunk with `reason: long_page_chunk` and a `long_page_*` fallback. Normative spec: `docs/evidence-delivery.md`. Tests: `test/evidence-delivery.test.ts`, `test/evidence-delivery-golden.test.ts`, `test/e2e/evidence-delivery-leak.test.ts`, `test/e2e/evidence-delivery-parity.test.ts`; bench `scripts/bench-evidence-delivery.ts`.
- `src/core/search/evidence-date.ts` — C1 dated evidence blocks: the fixed header grammar (`[observed YYYY-MM-DD|unknown]` for page blocks; `[observed unknown; valid FROM to UNTIL]` for `recall` facts), `pageObservationDate` (effective-date precedence with `event_date` removed and no row-timestamp fallback; mirrors #6020's `resolveObservationDate`, the seam to swap once it lands), `formatBrainDay` from `effective-date.ts` (midnight UTC renders as written, other instants in `brain.timezone`; the one function think's `<page date>` also renders through, while the header's `observed` stays when the text was said, never the content date), `loadPageDateHeaders` (one `pages` read per delivery; only the derived day leaves it) and `evidenceDateHeaderEnabled` (`search.evidence_date_header`, default off). Tests: `test/evidence-date-header.test.ts`.
- `src/core/search/entity-anchor.ts` — entity-anchored retrieval: `entityAnchoredPages` (the entity page plus up to 10 pages that link to it or name it as a word, newest by `COALESCE(effective_date, updated_at)`; question/synthesis/pinned-question pages excluded) and `prefixAnchoredPages`, shared by pinned-question refresh (`questions/refresh.ts` `anchoredSlugs`) and the `query`/`search` ops; `asksForCurrentState` (deterministic cue regex), `namedEntity` (exactly one `isFactEntityPage` page whose title `isTitleMentionedInQuery` matches, the title match before the read-policy filter; a title inside a longer matched title is the same mention); `applyEntityAnchoring` (anchored rows first, at most half the row count, organic rows of the same page moved up, missing pages read through `getChunkWindows` under the caller's scope, rows stamped `entity_anchored`, token budget re-applied, fail-open); `entityAnchoringEnabled` (`search.entity_anchoring`, default off). Tests: `test/search-entity-anchor.test.ts`. Gates: `docs/eval/decisions/entity-anchoring-query/`.
diff --git a/docs/evidence-delivery.md b/docs/evidence-delivery.md
index 380c6cd233..ca80994eb1 100644
--- a/docs/evidence-delivery.md
+++ b/docs/evidence-delivery.md
@@ -85,6 +85,9 @@ Per-call params on `search`, `query`, `recall`:
- `search.long_page_unit` (config only, default `off`): `window` | `section` |
`page` for long non-conversation hits under the implied `auto`; see
[Long pages](#long-pages-searchlong_page_unit).
+- `search.long_page_min_chars` (config only, default 20,000): the
+ rendered-body length in characters at which a page counts as long for
+ `search.long_page_unit`.
- `return_window`: integer 1–3, default from `search.return_window` (default 1).
Used by `window` (and by the `section` fallback to `window`).
- Budget: `token_budget` on `search` / `query`, `budget_tokens` on `recall`.
@@ -196,24 +199,31 @@ delivered unit is always the one around the ranked hit.
|---|---|---|---|
| 1 | `return_unit` on the call | always (`auto` included: an explicit `auto` keeps every non-conversation chunk) | that unit |
| 2 | `search.return_unit` set to anything but `auto` | `return_unit` omitted | that unit, every hit |
-| 3 | `search.long_page_unit` (not `off`) | `return_unit` omitted, `search.return_unit` unset or `auto`, no explicit `token_budget`, no explicit `snippet_chars`, and the hit is a long non-conversation page | that unit (`delivered.reason: "long_page"`) |
+| 3 | `search.long_page_unit` (not `off`) | `return_unit` omitted, `search.return_unit` unset or `auto`, no explicit `token_budget`, no positive `snippet_chars`, and the hit is a long non-conversation page | that unit (`delivered.reason: "long_page"`) |
| 4 | implied `auto` | everything else | conversations whole, other hits their ranked chunk |
The policy is resolved at the `search`/`query` caller and passed to the
assembler, so `recall`, `think` (`think.return_unit`) and `assemble_evidence`
-never read the key and stay byte-identical with it on. An explicit
-`snippet_chars` keeps it off because a cut from the front could drop the hit;
+never read the key and stay byte-identical with it on. A positive
+`snippet_chars` keeps it off because it cuts every delivered block from the
+front, so a widened unit would lose its tail (`snippet_chars: 0`, full text,
+leaves it on and the unit comes back whole);
an explicit `token_budget` keeps it off because the cap (next section) keeps
its own rules, and `query`'s bare `token_budget` is chunk-mode budgeting anyway.
The subagent default snippet cap already keeps the implied `auto` on `chunk`.
-**What is long.** A page whose stored body (compiled truth plus timeline;
-compiled truth only under `detail: "low"`) holds at least **8,000 bytes**
-(`LONG_PAGE_MIN_BYTES`, about 2,000 tokens or four chunks). Conversation pages
+**What is long.** A page whose rendered body (compiled truth plus timeline;
+compiled truth only under `detail: "low"`) holds at least
+`search.long_page_min_chars` characters (default **20,000**;
+`gbrain config set` refuses anything but a positive whole number, and an
+unusable stored value reads as the default). The size preflight compares the
+stored body's character count; delivery confirms the threshold on the rendered
+text (`pageEvidenceText`), and a page under it keeps its ranked chunk with no
+fallback code. Conversation pages
(see [Conversation detection](#conversation-detection)) and saved-fact rows are
never long pages.
-**Limits.** One size preflight query reads the byte counts of the hit pages
+**Limits.** One size preflight query reads the character and byte counts of the hit pages
under the caller's read scope; it never reads a body. Then, in rank order, at
most **5** long pages (`LONG_PAGE_MAX_PAGES`) holding at most **1,000,000**
stored-body bytes together (`LONG_PAGE_MAX_INPUT_BYTES`) are fetched in one
diff --git a/scripts/module-size-limits.tsv b/scripts/module-size-limits.tsv
index 2143f4479a..429b4a6baf 100644
--- a/scripts/module-size-limits.tsv
+++ b/scripts/module-size-limits.tsv
@@ -43,5 +43,5 @@ src/core/ops/pages.ts 683 ratchet crossed the unlisted 1500 cap in the fix wave:
src/core/search/mode.ts 1594 ratchet +10 System One v1: decide.* snapshot subset in loadSearchModeConfig, append-only dec= knobsHash part; +5 #3617 follow-up: v27 same-knobs behavioral-change note (relaxed-row fusion demotion rides the bump); new row: crossed the 1500 unlisted cap in the 2026-08 eval fix wave — KNOBS_HASH v=27 adaptive-return fold (ar/arem/arom/armk/ari parts + KnobsHashContext.adaptiveReturn field + contamination rationale comments) | merged v0.48.1.0 (+#4787) true-up; +master v0.48 merge true-up (reranker succession: no_key preflight, reranker_skipped stage, readiness); ranker wave v0.48.4.0: four knobs (expansion_variant_budget, relational_rerank_pin, keyword_arm_confidence_floor, metadata_boost_gate) + v29 hash parts + doc receipts (+218); #4781 loadSearchModeConfig reads the config table once via loadConfigSnapshot (+6); +4 #4359: update loadSearchModeConfig docstring — the cached path now reads config once (threaded snapshot), not twice; retired provider integration removed; +12 fw3-search: search.source_boosts + search.alias_token_hop read in the mode snapshot; +10 #5691: KnobsHashContext.queryPrefix and its append-only qp= part; P7 relational_planner / relational_orient_onehop knobs (interface docs, bundles, overrides, config parse, hash parts); +18 P7 relational_chain_slots knob (interface doc, bundles, override, config parse, rcs= hash part)
src/commands/eval-longmemeval.ts 1519 ratchet new row: crossed the 1500 unlisted cap in fw3-search (#5092 benchmark-brain recycling: configureBrain split + recycler wiring + test seams; the recycler itself lives in src/eval/longmemeval/harness.ts); +1 P6: tokenmax synopsis-tier wiring (logic in eval/longmemeval/synopsis-tier.ts)
src/commands/doctor/checks/extraction-sync.ts 1523 ratchet +1 undeclared_db_only_pages computes the source Git scope once per source (logic in core/markdown.ts sourceGitScope); new row: crossed the 1500 unlisted cap at the fix wave 9 merge: +7 lane W #5028 (extract_atoms freshness judged by the phase itself) and +3 lane F #5863 (extract_health dates a high halt rate by its last halt), each under the cap alone; +7 #5019: content_hash_duplicates fix pins the pairs' source (GBRAIN_SOURCE) and names a delete that runs; +1 fix wave 10 lane L1 #5556: links_extraction_lag denominator excludes quarantined pages (quarantineFilterFragment import); +11 fix wave 15 P2.8 (#5495): extract_health reads the 7-day halt reasons per kind (halt_reasons, top_halt_reason in details and the top reason in the warn line); the read, the unknown bucket and the ranking live in core/extract/rollup-writer.ts
-src/core/search/evidence-delivery.ts 1631 ratchet new row: crossed the 1500 unlisted cap at the #6367 merge (master 1479, its explicit-budget cap) by the C1 date header threaded through every block path, cap included; pagePlanHits (search/page-plan-hits.ts) and the header loader (evidence-date.ts blockDateHeaders) were peeled first; peel candidate: allocateCapped; +8 at the #6396 merge: page evidence text cut through the fence-chunk trust overlay and the caller minTrust floor (re-summed: our 1504 + master +8); +119 Cat 40 next wave F2: the search.long_page_unit policy (withLongPagePolicy, selectLongPages size preflight with page/byte/deadline limits) and the long-page fetch and fallback in deliverEvidence, kept in the shared seam the plan names (gbrain-evals docs/plans/2026-10-11-cat40-next-wave, F2)
+src/core/search/evidence-delivery.ts 1648 ratchet new row: crossed the 1500 unlisted cap at the #6367 merge (master 1479, its explicit-budget cap) by the C1 date header threaded through every block path, cap included; pagePlanHits (search/page-plan-hits.ts) and the header loader (evidence-date.ts blockDateHeaders) were peeled first; peel candidate: allocateCapped; +8 at the #6396 merge: page evidence text cut through the fence-chunk trust overlay and the caller minTrust floor (re-summed: our 1504 + master +8); +119 Cat 40 next wave F2: the search.long_page_unit policy (withLongPagePolicy, selectLongPages size preflight with page/byte/deadline limits) and the long-page fetch and fallback in deliverEvidence, kept in the shared seam the plan names (gbrain-evals docs/plans/2026-10-11-cat40-next-wave, F2); +17 F2 rework to the frozen-comparison policy: search.long_page_min_chars (rendered-body characters, default 20,000) read in withLongPagePolicy, a character count in the preflight, the rendered-body confirmation in deliverEvidence, and positive-only snippet_chars gating
src/commands/config.ts 1507 ratchet new row: crossed the 1500 unlisted cap in wave 15 P7.4 #5461: set-time validation of think.pages_budget_chars / think.excerpt_ceiling_chars (range + parser live in core/think/pages-budget.ts), mirroring the cycle.consolidate.cluster_threshold hook
diff --git a/src/core/config.ts b/src/core/config.ts
index 8a17514142..846a4a3521 100644
--- a/src/core/config.ts
+++ b/src/core/config.ts
@@ -1406,7 +1406,7 @@ export const KNOWN_CONFIG_KEYS: readonly string[] = [
'search.return_budget_conversation',
'search.return_budget_max_remote',
'search.auto_packing',
- 'search.long_page_unit', // F2: delivery unit for long non-conversation hits under an implied auto: off (default) | window | section | page (search/evidence-delivery.ts)
+ 'search.long_page_unit', 'search.long_page_min_chars', // F2: delivery unit for long (rendered body >= min_chars, default 20000) non-conversation hits under an implied auto: off (default) | window | section | page (search/evidence-delivery.ts)
'search.evidence_date_header', // C1: one-line date header per delivered block (default off; search/evidence-date.ts)
'search.entity_anchoring', // entity-anchored retrieval for entity-scoped current-state query/search (default off; search/entity-anchor.ts)
'search.query_facts_arm', // query adds matching active facts as rows in spare capacity (default on; search/facts-arm.ts)
diff --git a/src/core/search/config-values.ts b/src/core/search/config-values.ts
index 78d80e75b7..3fdea973f4 100644
--- a/src/core/search/config-values.ts
+++ b/src/core/search/config-values.ts
@@ -6,7 +6,7 @@
import { HNSW_ITERATIVE_SCAN_KEY, HNSW_ITERATIVE_SCAN_MODES, hnswIterativeScanValueProblem } from './hnsw-iterative-scan.ts';
import { CJK_KEYWORD_DEADLINE_DEFAULT_MS, CJK_KEYWORD_DEADLINE_KEY, cjkKeywordDeadlineValueProblem } from './cjk-keyword-deadline.ts';
import { AUTO_PACKING_CONFIG_KEY, DEFAULT_AUTO_PACKING, autoPackingValueProblem } from './evidence-packing.ts';
-import { LONG_PAGE_UNIT_CONFIG_KEY, longPageUnitValueProblem } from './evidence-delivery.ts';
+import { DEFAULT_LONG_PAGE_MIN_CHARS, LONG_PAGE_MIN_CHARS_CONFIG_KEY, LONG_PAGE_UNIT_CONFIG_KEY, longPageMinCharsValueProblem, longPageUnitValueProblem } from './evidence-delivery.ts';
interface SearchValueRule {
problem: (value: string) => string | null;
@@ -19,6 +19,7 @@ export const SEARCH_VALUE_RULES: Readonly<Record<string, SearchValueRule>> = {
[CJK_KEYWORD_DEADLINE_KEY]: { problem: cjkKeywordDeadlineValueProblem, example: String(CJK_KEYWORD_DEADLINE_DEFAULT_MS) },
[AUTO_PACKING_CONFIG_KEY]: { problem: autoPackingValueProblem, example: DEFAULT_AUTO_PACKING },
[LONG_PAGE_UNIT_CONFIG_KEY]: { problem: longPageUnitValueProblem, example: 'section' },
+ [LONG_PAGE_MIN_CHARS_CONFIG_KEY]: { problem: longPageMinCharsValueProblem, example: String(DEFAULT_LONG_PAGE_MIN_CHARS) },
};
/** The refusal for an invalid value of a validated `search.*` key, or null. */
diff --git a/src/core/search/evidence-delivery.ts b/src/core/search/evidence-delivery.ts
index 3e472f9ff3..c8c4cd944a 100644
--- a/src/core/search/evidence-delivery.ts
+++ b/src/core/search/evidence-delivery.ts
@@ -325,8 +325,9 @@ export function effectivePlan(plan: EvidencePlan | null, hits: SearchResult[]):
export const LONG_PAGE_UNIT_CONFIG_KEY = 'search.long_page_unit';
export const LONG_PAGE_UNITS = ['off', 'window', 'section', 'page'] as const;
export type LongPageUnit = Exclude<typeof LONG_PAGE_UNITS[number], 'off'>;
-/** A page is long when its stored body (compiled truth, plus timeline unless `detail: "low"`) holds this many bytes: about 2,000 tokens, four or more chunks. */
-export const LONG_PAGE_MIN_BYTES = 8_000;
+/** A page is long when its rendered body (compiled truth, plus timeline unless `detail: "low"`) holds at least this many characters. */
+export const LONG_PAGE_MIN_CHARS_CONFIG_KEY = 'search.long_page_min_chars';
+export const DEFAULT_LONG_PAGE_MIN_CHARS = 20_000;
/** Long pages per call that get the unit, in rank order; later ones keep their chunk (`long_page_pages`). */
export const LONG_PAGE_MAX_PAGES = 5;
/** Stored-body bytes those pages may bring in; a page that would cross it keeps its chunk (`long_page_bytes`), since bodies are read whole and never sliced. */
@@ -334,11 +335,12 @@ export const LONG_PAGE_MAX_INPUT_BYTES = 1_000_000;
/** Cooperative deadline for the size preflight plus the long-page fetch (`long_page_deadline`). */
export const LONG_PAGE_DEADLINE_MS = 2_000;
-export interface LongPagePolicy { unit: LongPageUnit }
+export interface LongPagePolicy { unit: LongPageUnit; minChars: number }
/** The long pages one call delivers in the policy's unit, and the ones that keep their chunk (page id → fallback code). */
export interface LongPageSelection {
unit: LongPageUnit;
+ minChars: number;
pages: ReadonlySet<number>;
kept: ReadonlyMap<number, string>;
deadlineAt: number;
@@ -349,24 +351,33 @@ export function longPageUnitValueProblem(value: string): string | null {
return (LONG_PAGE_UNITS as readonly string[]).includes(value.trim()) ? null : `${LONG_PAGE_UNIT_CONFIG_KEY} must be one of ${LONG_PAGE_UNITS.join(', ')} (got ${JSON.stringify(value.slice(0, 40))}).`;
}
+export function longPageMinCharsValueProblem(value: string): string | null {
+ return /^[1-9][0-9]{0,8}$/.test(value.trim()) ? null : `${LONG_PAGE_MIN_CHARS_CONFIG_KEY} must be a positive whole number of characters (got ${JSON.stringify(value.slice(0, 40))}).`;
+}
+
/**
* The F2 policy for a search/query call. It applies only under an implied
* `auto`: no `return_unit` on the call, `search.return_unit` unset or `auto`,
- * no explicit budget (the cap keeps its rules) and no explicit `snippet_chars`
- * (a head cut could drop the hit). Read errors and unknown values are `off`.
+ * no explicit budget (the cap keeps its rules) and no positive
+ * `snippet_chars` (it head-cuts every delivered block, so a widened unit
+ * would lose its tail; `0` means full text and leaves it on). Read errors and
+ * unknown values are `off`; an unusable threshold is the default.
*/
export async function withLongPagePolicy(engine: BrainEngine, plan: EvidencePlan | null, input: { snippetChars: unknown }): Promise<EvidencePlan | null> {
if (!plan || plan.unit !== 'auto' || plan.explicitUnit || plan.budgetExplicit) return plan;
- if (typeof input.snippetChars === 'number' && Number.isFinite(input.snippetChars)) return plan;
+ if (typeof input.snippetChars === 'number' && Number.isFinite(input.snippetChars) && Math.floor(input.snippetChars) > 0) return plan;
const raw = (await engine.getConfig(LONG_PAGE_UNIT_CONFIG_KEY).catch(() => null))?.trim();
- return raw === 'window' || raw === 'section' || raw === 'page' ? { ...plan, longPage: { unit: raw } } : plan;
+ if (raw !== 'window' && raw !== 'section' && raw !== 'page') return plan;
+ const min = (await engine.getConfig(LONG_PAGE_MIN_CHARS_CONFIG_KEY).catch(() => null)) ?? '';
+ return { ...plan, longPage: { unit: raw, minChars: longPageMinCharsValueProblem(min) ? DEFAULT_LONG_PAGE_MIN_CHARS : Number(min.trim()) } };
}
/**
* The plan to run for these hits once the long-page policy is applied: a
- * size preflight (one query, the caller's read scope) finds the long
- * non-conversation pages and keeps the rank-order ones inside the page and
- * byte limits. With no long page this is exactly effectivePlan, so a
+ * size preflight (one query, the caller's read scope) finds the
+ * non-conversation pages whose stored body reaches the character threshold
+ * and keeps the rank-order ones inside the page and byte limits; delivery
+ * confirms the threshold on the rendered body. With no long page this is exactly effectivePlan, so a
* response without one is unchanged; a failed or late preflight is too.
*/
export async function selectLongPages(engine: BrainEngine, plan: EvidencePlan | null, hits: SearchResult[], scope: DeliveryScope): Promise<{ plan: EvidencePlan | null; longPages?: LongPageSelection }> {
@@ -376,31 +387,33 @@ export async function selectLongPages(engine: BrainEngine, plan: EvidencePlan |
const ids: number[] = [];
for (const h of hits) if (!h.fact_row && conversationSignal(h) === null && Number.isFinite(h.page_id) && !ids.includes(h.page_id)) ids.push(h.page_id);
if (ids.length === 0) return { plan: base };
- let bytes: Map<number, number>;
+ const { unit, minChars } = plan.longPage;
+ let sizes: Map<number, { chars: number; bytes: number }>;
try {
const params: unknown[] = [ids];
const filter = pageReadFilter('p', scope, params, true);
- const timeline = scope.detail === 'low' ? '' : ` + octet_length(COALESCE(p.timeline, ''))`;
- const rows = await withTimeout(engine.executeRaw<{ id: number; bytes: number }>(
- `SELECT p.id, octet_length(COALESCE(p.compiled_truth, ''))${timeline} AS bytes FROM pages p
+ const tl = scope.detail === 'low' ? null : `CASE WHEN COALESCE(p.timeline, '') !~ '\\S' THEN 0 ELSE ${TIMELINE_SEPARATOR.length} + `;
+ const rows = await withTimeout(engine.executeRaw<{ id: number; chars: number; bytes: number }>(
+ `SELECT p.id, char_length(COALESCE(p.compiled_truth, ''))${tl ? ` + ${tl}char_length(p.timeline) END` : ''} AS chars,
+ octet_length(COALESCE(p.compiled_truth, ''))${tl ? ` + ${tl}octet_length(p.timeline) END` : ''} AS bytes FROM pages p
WHERE p.id = ANY($1::int[]) AND ${filter} AND ${currentTextProjectionFilter('p')}${requiresSafeChunks(scope) ? ` AND ${safeChunksFilter('p')}` : ''}`,
params), LONG_PAGE_DEADLINE_MS);
- bytes = new Map(rows.map(r => [Number(r.id), Number(r.bytes)]));
+ sizes = new Map(rows.map(r => [Number(r.id), { chars: Number(r.chars), bytes: Number(r.bytes) }]));
} catch (e) {
- return { plan: base, ...(base ? { longPages: { unit: plan.longPage.unit, pages: new Set(), kept: new Map(), deadlineAt, fallbacks: [e instanceof EvidenceTimeout ? 'long_page_deadline' : 'long_page_preflight_failed'] } } : {}) };
+ return { plan: base, ...(base ? { longPages: { unit, minChars, pages: new Set(), kept: new Map(), deadlineAt, fallbacks: [e instanceof EvidenceTimeout ? 'long_page_deadline' : 'long_page_preflight_failed'] } } : {}) };
}
const pages = new Set<number>();
const kept = new Map<number, string>();
let total = 0;
for (const id of ids) {
- const size = bytes.get(id);
- if (size === undefined || size < LONG_PAGE_MIN_BYTES) continue;
+ const size = sizes.get(id);
+ if (size === undefined || size.chars < minChars) continue;
if (pages.size >= LONG_PAGE_MAX_PAGES) kept.set(id, 'long_page_pages');
- else if (total + size > LONG_PAGE_MAX_INPUT_BYTES) kept.set(id, 'long_page_bytes');
- else { pages.add(id); total += size; }
+ else if (total + size.bytes > LONG_PAGE_MAX_INPUT_BYTES) kept.set(id, 'long_page_bytes');
+ else { pages.add(id); total += size.bytes; }
}
if (pages.size === 0 && kept.size === 0) return { plan: base };
- return { plan, longPages: { unit: plan.longPage.unit, pages, kept, deadlineAt, fallbacks: [] } };
+ return { plan, longPages: { unit, minChars, pages, kept, deadlineAt, fallbacks: [] } };
}
// ---------------------------------------------------------------------------
@@ -1211,6 +1224,10 @@ export async function deliverEvidence(
if (typeof longFetch === 'string') { keepChunks(g, longFetch === 'fetch_timeout' ? 'long_page_deadline' : 'long_page_fetch_failed'); continue; }
const page = longFetch.get(g.pageId!);
if (!page) { dropped.not_readable = (dropped.not_readable ?? 0) + 1; continue; }
+ if (pageEvidenceText(page, scope.detail !== 'low').text.length < long!.minChars) {
+ for (const h of g.hits) passthrough.push({ rank: hits.indexOf(h), hit: h, reason: 'not_conversation' });
+ continue;
+ }
b = planBlock(page, g.hits, long!.unit, plan.window, scope.detail !== 'low');
if (b.unit === 'chunk') { keepChunks(g, b.fallbackReason ?? 'long_page_fallback'); continue; }
} else if (g.pageId === null) {
diff --git a/test/config-search-registry.test.ts b/test/config-search-registry.test.ts
index ef3f12fab3..d94d6ecfa8 100644
--- a/test/config-search-registry.test.ts
+++ b/test/config-search-registry.test.ts
@@ -46,6 +46,7 @@ const DIRECTLY_READ_SINGLETONS = [
'search.return_budget_max_remote',
'search.auto_packing', // search/evidence-delivery.ts (explicit-budget cap)
'search.long_page_unit', // search/evidence-delivery.ts (long non-conversation pages under implied auto)
+ 'search.long_page_min_chars', // search/evidence-delivery.ts (rendered-body threshold for a long page)
'search.evidence_date_header', // search/evidence-delivery.ts (C1)
'search.entity_anchoring', // search/entity-anchor.ts (ops/search.ts)
'search.query_facts_arm', // search/facts-arm.ts (search/query-arms.ts)
diff --git a/test/e2e/evidence-long-page.test.ts b/test/e2e/evidence-long-page.test.ts
index 7da49f03ff..5dccb63810 100644
--- a/test/e2e/evidence-long-page.test.ts
+++ b/test/e2e/evidence-long-page.test.ts
@@ -2,7 +2,10 @@
* F2 (`search.long_page_unit`) on Postgres: the PGLite unit arm
* (test/evidence-long-page.test.ts) run against a real Postgres brain. Pins
* the off path (byte-identical to return_unit chunk), the frozen on-path
- * golden, the serialized lean MCP `delivered {unit, reason}`, the precedence
+ * golden, the replay case (default 20,000-character threshold, section; a
+ * medium and a short hit keep their ranked chunks), the cap and explicit-unit
+ * paths unchanged with the key on, the serialized lean MCP `delivered {unit,
+ * reason}`, the precedence
* of a non-auto global unit, the over-budget fallback, recall/think/
* assemble_evidence unchanged with the key on, and the d5b/F4 instruction
* config readers, all on the same engine.
@@ -17,7 +20,7 @@ import type { SearchResult } from '../../src/core/types.ts';
import { assembleEvidenceForHits } from '../../src/core/search/evidence-delivery.ts';
import { buildMcpInstructions, readInstructionContent } from '../../src/mcp/instructions.ts';
import { isolatedPersistencePostgres } from '../helpers/persistence-postgres.ts';
-import { DECIDING, LONG_SLUG, mcpCall, opCall, seedLongPages, withConfig } from '../helpers/long-page-fixture.ts';
+import { DECIDING, LONG_SLUG, MEDIUM_SLUG, mcpCall, opCall, seedLongPages, withConfig } from '../helpers/long-page-fixture.ts';
const GOLDEN = join(import.meta.dir, '../fixtures/goldens/evidence-delivery/long-page-on-path.json');
const KEY = 'search.long_page_unit';
@@ -57,6 +60,24 @@ run('long-page delivery on Postgres', () => {
expect(String(long(page.rows).chunk_text)).toContain(DECIDING);
});
+ test('replay: section at the default threshold widens only the long hit; every other row is its off-path bytes', async () => {
+ const off = await mcpCall(engine, 'search', { query: 'renewal fee' });
+ const on = await withConfig(engine, { [KEY]: 'section' }, () => mcpCall(engine, 'search', { query: 'renewal fee' }));
+ expect(long(on.rows).delivered).toEqual({ unit: 'section', reason: 'long_page' });
+ expect(on.rows.map(r => r.slug)).toEqual(expect.arrayContaining([MEDIUM_SLUG, 'notes/short-example']));
+ for (const r of on.rows.filter(r => r.slug !== LONG_SLUG)) expect(JSON.stringify(r)).toBe(JSON.stringify(off.rows.find(o => o.slug === r.slug)));
+ const lowered = await withConfig(engine, { [KEY]: 'section', 'search.long_page_min_chars': '5000' }, () => mcpCall(engine, 'search', { query: 'renewal fee' }));
+ expect(lowered.rows.find(r => r.slug === MEDIUM_SLUG)!.delivered).toEqual({ unit: 'section', reason: 'long_page' });
+ });
+
+ test('the cap path and explicit chunk/window units are byte-identical with the key on', async () => {
+ for (const params of [{ token_budget: 4000 }, { return_unit: 'chunk' }, { return_unit: 'window' }]) {
+ const call = { query: 'renewal fee', ...params };
+ const off = await mcpCall(engine, 'search', call);
+ expect((await withConfig(engine, { [KEY]: 'section' }, () => mcpCall(engine, 'search', call))).bytes).toBe(off.bytes);
+ }
+ });
+
test('global window wins over the long-page section; explicit budget keeps it off; over budget keeps the chunk', async () => {
const pick = (rows: unknown) => (rows as Array<SearchResult & { delivered?: { unit: string; reason?: string } }>).find(r => r.slug === LONG_SLUG)!;
const global = await withConfig(engine, { 'search.return_unit': 'window', [KEY]: 'section' }, () => opCall(engine, 'search', { query: 'renewal fee' }));
diff --git a/test/evidence-long-page.test.ts b/test/evidence-long-page.test.ts
index f02e3e9b17..23ddc197c9 100644
--- a/test/evidence-long-page.test.ts
+++ b/test/evidence-long-page.test.ts
@@ -5,9 +5,11 @@
* `return_unit: "chunk"`; the on path is pinned by its own frozen golden
* (test/fixtures/goldens/evidence-delivery/long-page-on-path.json).
*
- * Precedence (docs/evidence-delivery.md "Long pages"): explicit `return_unit`
- * > non-`auto` `search.return_unit` > `search.long_page_unit`; an explicit
- * `token_budget` or `snippet_chars` keeps it off. recall, think and
+ * Long means a rendered body of at least `search.long_page_min_chars`
+ * (default 20,000) characters. Precedence (docs/evidence-delivery.md "Long
+ * pages"): explicit `return_unit` > non-`auto` `search.return_unit` >
+ * `search.long_page_unit`; an explicit `token_budget` or a positive
+ * `snippet_chars` keeps it off. recall, think and
* `assemble_evidence` never read it. Assertions are on the serialized lean
* MCP output a remote agent receives. The Postgres arm is
* test/e2e/evidence-long-page.test.ts.
@@ -19,16 +21,17 @@ import { PGLiteEngine } from '../src/core/pglite-engine.ts';
import type { BrainEngine } from '../src/core/engine.ts';
import type { SearchResult } from '../src/core/types.ts';
import {
- LONG_PAGE_DEADLINE_MS, LONG_PAGE_MAX_INPUT_BYTES, LONG_PAGE_MAX_PAGES, LONG_PAGE_MIN_BYTES, assembleEvidenceForHits, deliverEvidence,
- longPageUnitValueProblem, resolveEvidencePlan, selectLongPages, withLongPagePolicy, type EvidencePlan,
+ DEFAULT_LONG_PAGE_MIN_CHARS, LONG_PAGE_DEADLINE_MS, LONG_PAGE_MAX_INPUT_BYTES, LONG_PAGE_MAX_PAGES, assembleEvidenceForHits, deliverEvidence,
+ longPageMinCharsValueProblem, longPageUnitValueProblem, pageEvidenceText, resolveEvidencePlan, selectLongPages, withLongPagePolicy, type EvidencePlan,
} from '../src/core/search/evidence-delivery.ts';
import { searchConfigValueRefusal } from '../src/core/search/config-values.ts';
import { leanRow } from '../src/core/search/lean-rows.ts';
import { runThink } from '../src/core/think/index.ts';
-import { CONVERSATION_PAGE, DECIDING, LONG_SLUG, mcpCall, opCall, seedLongPages, withConfig } from './helpers/long-page-fixture.ts';
+import { CONVERSATION_PAGE, DECIDING, LONG_SLUG, MEDIUM_SLUG, mcpCall, opCall, seedLongPages, withConfig } from './helpers/long-page-fixture.ts';
const GOLDEN = join(import.meta.dir, 'fixtures/goldens/evidence-delivery/long-page-on-path.json');
const KEY = 'search.long_page_unit';
+const MIN_KEY = 'search.long_page_min_chars';
let engine: PGLiteEngine;
beforeAll(async () => {
@@ -59,10 +62,41 @@ describe('off path', () => {
expect((await withConfig(engine, { [KEY]: 'sentence' }, () => mcpCall(engine, 'search', { query: 'renewal fee' }))).bytes).toBe(chunk.bytes);
expect(longPageUnitValueProblem('section')).toBeNull();
expect(searchConfigValueRefusal(KEY, 'sentence')?.message).toContain('off, window, section, page');
+ expect(longPageMinCharsValueProblem('20000')).toBeNull();
+ for (const bad of ['0', '-5', '1.5', 'many']) expect(searchConfigValueRefusal(MIN_KEY, bad)?.message).toContain('positive whole number');
});
});
describe('on path (serialized lean MCP output)', () => {
+ test('replay: key section, default threshold: the long hit is widened to its section, every other hit keeps its ranked chunk', async () => {
+ const stored = await engine.getPage(LONG_SLUG);
+ expect(pageEvidenceText({ compiled_truth: stored!.compiled_truth, timeline: stored!.timeline ?? '' }, true).text.length).toBeGreaterThanOrEqual(DEFAULT_LONG_PAGE_MIN_CHARS);
+ const medium = await engine.getPage(MEDIUM_SLUG);
+ expect(new TextEncoder().encode(medium!.compiled_truth).length).toBeGreaterThan(8_000);
+ expect(medium!.compiled_truth.length).toBeLessThan(DEFAULT_LONG_PAGE_MIN_CHARS);
+ const off = await mcpCall(engine, 'search', { query: 'renewal fee' });
+ const on = await withConfig(engine, { [KEY]: 'section' }, () => mcpCall(engine, 'search', { query: 'renewal fee' }));
+ const payload = JSON.parse((JSON.parse(on.bytes) as { content: Array<{ text: string }> }).content[0].text) as Array<Record<string, unknown>>;
+ expect(payload.map(r => r.slug)).toEqual(off.rows.map(r => r.slug));
+ expect(payload.map(r => r.slug)).toEqual(expect.arrayContaining([LONG_SLUG, MEDIUM_SLUG, 'notes/short-example']));
+ const row = long(payload);
+ expect(row.delivered).toEqual({ unit: 'section', reason: 'long_page' });
+ expect(String(row.chunk_text)).toContain(String(long(off.rows).chunk_text).slice(0, 120));
+ expect(String(row.chunk_text).startsWith('## ')).toBe(true);
+ expect(String(row.chunk_text).length).toBeLessThan(stored!.compiled_truth.length);
+ expect(String(row.chunk_text)).not.toContain(DECIDING);
+ for (const r of payload.filter(r => r.slug !== LONG_SLUG)) {
+ expect(r.delivered).toBeUndefined();
+ expect(JSON.stringify(r)).toBe(JSON.stringify(off.rows.find(o => o.slug === r.slug)));
+ }
+ });
+
+ test('search.long_page_min_chars moves the line: at 5,000 the medium page is widened too', async () => {
+ const on = await withConfig(engine, { [KEY]: 'section', [MIN_KEY]: '5000' }, () => mcpCall(engine, 'search', { query: 'renewal fee' }));
+ expect(on.rows.find(r => r.slug === MEDIUM_SLUG)!.delivered).toEqual({ unit: 'section', reason: 'long_page' });
+ expect(on.rows.find(r => r.slug === 'notes/short-example')!.delivered).toBeUndefined();
+ });
+
for (const unit of ['window', 'section', 'page'] as const) {
test(`${unit}: the long row carries delivered {unit, reason}; short rows are their off-path bytes`, async () => {
const off = await mcpCall(engine, 'search', { query: 'renewal fee' });
@@ -84,7 +118,7 @@ describe('on path (serialized lean MCP output)', () => {
const off = long((await mcpCall(engine, 'search', { query: 'renewal fee' })).rows);
const deliveredText = async (unit: string) => String(long((await withConfig(engine, { [KEY]: unit }, () => mcpCall(engine, 'search', { query: 'renewal fee' }))).rows).chunk_text);
const section = await deliveredText('section');
- expect(section.startsWith(String(off.chunk_text).slice(0, 200))).toBe(true);
+ expect(section).toContain(String(off.chunk_text).slice(0, 120));
expect(section).not.toContain(DECIDING);
expect(section).not.toContain('## Term and renewal');
expect(await deliveredText('page')).toContain(DECIDING);
@@ -162,11 +196,26 @@ describe('precedence', () => {
expect(row.delivered).toMatchObject({ unit: 'section', reason: 'long_page' });
});
- test('an explicit token_budget or snippet_chars keeps the key off', async () => {
- const budget = await deliveredOf({ [KEY]: 'section' }, { token_budget: 4000 });
- expect(budget.row.delivered?.reason).not.toBe('long_page');
+ test('unchanged paths: with the key on, the cap path and explicit chunk/window units are byte-identical to the key off', async () => {
+ for (const params of [{ token_budget: 4000 }, { return_unit: 'chunk' }, { return_unit: 'window' }]) {
+ for (const name of ['search', 'query'] as const) {
+ const call = { query: 'renewal fee', ...(name === 'query' ? { expand: false } : {}), ...params };
+ const off = await mcpCall(engine, name, call);
+ const on = await withConfig(engine, { [KEY]: 'section' }, () => mcpCall(engine, name, call));
+ expect(`${name} ${JSON.stringify(params)}: ${on.bytes}`).toBe(`${name} ${JSON.stringify(params)}: ${off.bytes}`);
+ }
+ }
+ });
+
+ test('a positive snippet_chars keeps the key off (it head-cuts every block); 0 (full text) leaves it on and the section survives whole', async () => {
const snippet = await withConfig(engine, { [KEY]: 'section' }, () => mcpCall(engine, 'search', { query: 'renewal fee', snippet_chars: 300 }));
expect(snippet.bytes).toBe((await mcpCall(engine, 'search', { query: 'renewal fee', snippet_chars: 300 })).bytes);
+ const whole = await withConfig(engine, { [KEY]: 'section' }, async () => [
+ long((await mcpCall(engine, 'search', { query: 'renewal fee', snippet_chars: 0 })).rows),
+ long((await mcpCall(engine, 'search', { query: 'renewal fee' })).rows),
+ ]);
+ expect(whole[0].delivered).toEqual({ unit: 'section', reason: 'long_page' });
+ expect(whole[0].chunk_text).toBe(whole[1].chunk_text);
});
});
@@ -193,26 +242,28 @@ describe('other callers stay byte-identical with the key on', () => {
});
describe('selection limits (size preflight)', () => {
- const plan = { requestedUnit: 'auto', unit: 'auto', window: 1, budgetTokens: 24000, explicitUnit: false, budgetExplicit: false, packing: 'cap_only', longPage: { unit: 'section' } } as EvidencePlan;
+ const plan = { requestedUnit: 'auto', unit: 'auto', window: 1, budgetTokens: 24000, explicitUnit: false, budgetExplicit: false, packing: 'cap_only', longPage: { unit: 'section', minChars: DEFAULT_LONG_PAGE_MIN_CHARS } } as EvidencePlan;
const hit = (page_id: number, slug = `notes/p${page_id}`): SearchResult => ({ slug, page_id, title: slug, type: 'note', chunk_text: 'x', chunk_source: 'compiled_truth', chunk_id: page_id * 10, chunk_index: 0, score: 1, stale: false });
- const sized = (sizes: Record<number, number>) => ({ executeRaw: async () => Object.entries(sizes).map(([id, bytes]) => ({ id: Number(id), bytes })) }) as unknown as BrainEngine;
+ const sized = (sizes: Record<number, number | [chars: number, bytes: number]>) => ({ executeRaw: async () => Object.entries(sizes).map(([id, v]) => ({ id: Number(id), chars: Array.isArray(v) ? v[0] : v, bytes: Array.isArray(v) ? v[1] : v })) }) as unknown as BrainEngine;
- test(`long means at least ${LONG_PAGE_MIN_BYTES} bytes; no long page is effectivePlan exactly (null without a conversation)`, async () => {
- expect(await selectLongPages(sized({ 1: LONG_PAGE_MIN_BYTES - 1 }), plan, [hit(1)], {})).toEqual({ plan: null });
- const at = await selectLongPages(sized({ 1: LONG_PAGE_MIN_BYTES }), plan, [hit(1)], {});
+ test(`long means at least ${DEFAULT_LONG_PAGE_MIN_CHARS} characters, not bytes; no long page is effectivePlan exactly (null without a conversation)`, async () => {
+ expect(await selectLongPages(sized({ 1: DEFAULT_LONG_PAGE_MIN_CHARS - 1 }), plan, [hit(1)], {})).toEqual({ plan: null });
+ expect(await selectLongPages(sized({ 1: [DEFAULT_LONG_PAGE_MIN_CHARS - 1, DEFAULT_LONG_PAGE_MIN_CHARS * 3] }), plan, [hit(1)], {})).toEqual({ plan: null });
+ const at = await selectLongPages(sized({ 1: DEFAULT_LONG_PAGE_MIN_CHARS }), plan, [hit(1)], {});
expect([...at.longPages!.pages]).toEqual([1]);
+ expect(at.longPages!.minChars).toBe(DEFAULT_LONG_PAGE_MIN_CHARS);
});
test(`at most ${LONG_PAGE_MAX_PAGES} pages, in rank order; later long pages keep their chunk`, async () => {
const ids = Array.from({ length: LONG_PAGE_MAX_PAGES + 2 }, (_, i) => i + 1);
- const sel = await selectLongPages(sized(Object.fromEntries(ids.map(id => [id, 10_000]))), plan, ids.map(id => hit(id)), {});
+ const sel = await selectLongPages(sized(Object.fromEntries(ids.map(id => [id, 25_000]))), plan, ids.map(id => hit(id)), {});
expect([...sel.longPages!.pages]).toEqual(ids.slice(0, LONG_PAGE_MAX_PAGES));
expect([...sel.longPages!.kept]).toEqual(ids.slice(LONG_PAGE_MAX_PAGES).map(id => [id, 'long_page_pages']));
});
test(`at most ${LONG_PAGE_MAX_INPUT_BYTES} body bytes; a page that would cross it is never sliced, it keeps its chunk`, async () => {
const half = Math.floor(LONG_PAGE_MAX_INPUT_BYTES * 0.6);
- const sel = await selectLongPages(sized({ 1: half, 2: half, 3: 9_000 }), plan, [hit(1), hit(2), hit(3)], {});
+ const sel = await selectLongPages(sized({ 1: half, 2: half, 3: 25_000 }), plan, [hit(1), hit(2), hit(3)], {});
expect([...sel.longPages!.pages]).toEqual([1, 3]);
expect([...sel.longPages!.kept]).toEqual([[2, 'long_page_bytes']]);
});
@@ -232,10 +283,13 @@ describe('selection limits (size preflight)', () => {
expect(mixed.longPages?.fallbacks).toEqual(['long_page_deadline']);
}, LONG_PAGE_DEADLINE_MS * 3 + 5_000);
- test('the policy is resolved only under an implied auto, with no explicit budget or snippet_chars', async () => {
+ test('the policy is resolved only under an implied auto, with no explicit budget or positive snippet_chars', async () => {
const resolve = async (input: Record<string, unknown>, config: Record<string, string> = {}) => withConfig(engine, { [KEY]: 'page', ...config }, async () =>
(await withLongPagePolicy(engine, await resolveEvidencePlan(engine, { remote: true, returnUnit: input.return_unit, returnWindow: undefined, budget: input.token_budget, snippetChars: input.snippet_chars, snippetCap: 0, op: 'search' }), { snippetChars: input.snippet_chars }))?.longPage ?? null);
- expect(await resolve({})).toEqual({ unit: 'page' });
+ expect(await resolve({})).toEqual({ unit: 'page', minChars: DEFAULT_LONG_PAGE_MIN_CHARS });
+ expect(await resolve({}, { [MIN_KEY]: '5000' })).toEqual({ unit: 'page', minChars: 5000 });
+ expect(await resolve({}, { [MIN_KEY]: 'lots' })).toEqual({ unit: 'page', minChars: DEFAULT_LONG_PAGE_MIN_CHARS });
+ expect(await resolve({ snippet_chars: 0 })).toEqual({ unit: 'page', minChars: DEFAULT_LONG_PAGE_MIN_CHARS });
expect(await resolve({ return_unit: 'auto' })).toBeNull();
expect(await resolve({ token_budget: 2000 })).toBeNull();
expect(await resolve({ snippet_chars: 200 })).toBeNull();
@@ -247,7 +301,7 @@ describe('selection limits (size preflight)', () => {
const rows = await engine.executeRaw<{ id: number; chunk_index: number; chunk_text: string }>(`SELECT id, chunk_index, chunk_text FROM content_chunks WHERE page_id = $1 ORDER BY chunk_index LIMIT 1`, [page!.id]);
const h: SearchResult = { slug: LONG_SLUG, page_id: page!.id, title: LONG_SLUG, type: 'note', chunk_text: rows[0].chunk_text, chunk_source: 'compiled_truth', chunk_id: rows[0].id, chunk_index: 0, score: 1, stale: false };
const failing = new Proxy(engine, { get: (t, k) => k === 'getChunkWindows' ? async () => { throw new Error('boom'); } : (t as never)[k] }) as BrainEngine;
- const { results, delivery } = await deliverEvidence(failing, [h], plan, {}, { longPages: { unit: 'section', pages: new Set([page!.id]), kept: new Map(), deadlineAt: Date.now() + 1000, fallbacks: [] } });
+ const { results, delivery } = await deliverEvidence(failing, [h], plan, {}, { longPages: { unit: 'section', minChars: DEFAULT_LONG_PAGE_MIN_CHARS, pages: new Set([page!.id]), kept: new Map(), deadlineAt: Date.now() + 1000, fallbacks: [] } });
expect(results[0].chunk_text).toBe(h.chunk_text);
expect(results[0].delivered).toMatchObject({ unit: 'chunk', reason: 'long_page_chunk' });
expect(delivery.fallbacks).toEqual(expect.arrayContaining(['long_page_fetch_failed']));
@@ -256,6 +310,19 @@ describe('selection limits (size preflight)', () => {
});
});
+describe('rendered-body confirmation', () => {
+ test('a page the preflight passed but whose rendered body is under the threshold keeps its ranked chunk, with no fallback', async () => {
+ const page = await engine.getPage(MEDIUM_SLUG);
+ const [c] = await engine.executeRaw<{ id: number; chunk_index: number; chunk_text: string }>(`SELECT id, chunk_index, chunk_text FROM content_chunks WHERE page_id = $1 ORDER BY chunk_index LIMIT 1`, [page!.id]);
+ const h: SearchResult = { slug: MEDIUM_SLUG, page_id: page!.id, title: MEDIUM_SLUG, type: 'note', chunk_text: c.chunk_text, chunk_source: 'compiled_truth', chunk_id: c.id, chunk_index: c.chunk_index, score: 1, stale: false };
+ const plan = { requestedUnit: 'auto', unit: 'auto', window: 1, budgetTokens: 24000, explicitUnit: false, budgetExplicit: false, packing: 'cap_only' } as EvidencePlan;
+ const { results, delivery } = await deliverEvidence(engine, [h], plan, {}, { longPages: { unit: 'section', minChars: DEFAULT_LONG_PAGE_MIN_CHARS, pages: new Set([page!.id]), kept: new Map(), deadlineAt: Date.now() + 1000, fallbacks: [] } });
+ expect(results[0].chunk_text).toBe(h.chunk_text);
+ expect(results[0].delivered).toMatchObject({ unit: 'chunk', reason: 'not_conversation' });
+ expect(delivery.fallbacks.filter(f => f.startsWith('long_page'))).toEqual([]);
+ });
+});
+
describe('lean rows', () => {
test('keep {truncated: true} alone for every other row, and {unit, reason, truncated?} for long-page rows', () => {
const base = { slug: 'a', chunk_text: 't' };
diff --git a/test/fixtures/goldens/evidence-delivery/long-page-on-path.json b/test/fixtures/goldens/evidence-delivery/long-page-on-path.json
index 963579230e..c7867e68f9 100644
--- a/test/fixtures/goldens/evidence-delivery/long-page-on-path.json
+++ b/test/fixtures/goldens/evidence-delivery/long-page-on-path.json
@@ -1,5 +1,5 @@
{
- "mcp-search:window": "{\"content\":[{\"type\":\"text\",\"text\":\"[{\\\"slug\\\":\\\"contracts/msa-example\\\",\\\"title\\\":\\\"contracts/msa-example\\\",\\\"type\\\":\\\"note\\\",\\\"chunk_text\\\":\\\"## Definitions\\\\n\\\\nThe renewal fee means the amount stated in the order form. Clause 1 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 2 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 3 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 4 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 5 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 6 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 7 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 8 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 9 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 10 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 11 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 12 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 13 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 14 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 15 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 16 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 17 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 18 on definitions restates the general obligations of both parties and the notice address for correspondence.\\\\n\\\\n## Fees\\\\n\\\\nNo renewal fee applies to trial seats, and the renewal fee is invoiced in advance. Clause 1 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 2 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 3 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 4 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 5 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 6 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 7 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 8 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 9 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 10 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 11 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 12 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 13 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 14 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 15 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 16 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 17 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 18 on fees restates the general obligations of both parties and the notice address for correspondence.\\\\n\\\\n## Term and renewal\\\\n\\\\nThe agreement renews each year; a renewal fee change needs written notice. Clause 1 on term restates the general obligations of both parties and the notice address for correspondence. Clause 2 on term restates the general obligations of both parties and the notice address for correspondence. Clause 3 on term restates the general obligations of both parties and the notice address for correspondence. Clause 4 on term restates the general obligations of both parties and the notice address for correspondence. Clause 5 on term restates the general obligations of both parties and the notice address for correspondence. Clause 6 on term restates the general obligations of both parties and the notice address for correspondence. Clause 7 on term restates the general obligations of both parties and the notice address for correspondence. Clause 8 on term restates the general obligations of both parties and the notice address for correspondence. Clause 9 on term restates the general obligations of both parties and the notice address for correspondence. Clause 10 on term restates the general obligations of both parties and the notice address for correspondence. Clause 11 on term restates the general obligations of both parties and the notice address for correspondence. Clause 12 on term restates the general obligations of both parties and the notice address for correspondence. Clause 13 on term restates the general obligations of both parties and the notice address for correspondence. Clause 14 on term restates the general obligations of both parties and the notice\\\",\\\"chunk_id\\\":1,\\\"score\\\":0.9518601894378662,\\\"source_id\\\":\\\"default\\\",\\\"effective_date\\\":null,\\\"id\\\":\\\"gbrain-page:v1:WyJkZWZhdWx0IiwiY29udHJhY3RzL21zYS1leGFtcGxlIl0\\\",\\\"evidence\\\":\\\"keyword_exact\\\",\\\"create_safety\\\":\\\"probable\\\",\\\"delivered\\\":{\\\"unit\\\":\\\"window\\\",\\\"reason\\\":\\\"long_page\\\"},\\\"trust_tier\\\":\\\"unknown\\\",\\\"origin\\\":\\\"legacy\\\"},{\\\"slug\\\":\\\"notes/handbook-example\\\",\\\"title\\\":\\\"notes/handbook-example\\\",\\\"type\\\":\\\"note\\\",\\\"chunk_text\\\":\\\"## Renewals\\\\n\\\\nThe handbook describes how a renewal fee is quoted. Clause 1 on handbook restates the general obligations of both parties and the notice address for correspondence. Clause 2 on handbook restates the general obligations of both parties and the notice address for correspondence. Clause 3 on handbook restates the general obligations of both parties and the notice address for correspondence.\\\",\\\"chunk_id\\\":6,\\\"score\\\":0.5802597999572754,\\\"source_id\\\":\\\"default\\\",\\\"effective_date\\\":null,\\\"id\\\":\\\"gbrain-page:v1:WyJkZWZhdWx0Iiwibm90ZXMvaGFuZGJvb2stZXhhbXBsZSJd\\\",\\\"evidence\\\":\\\"weak_semantic\\\",\\\"create_safety\\\":\\\"unknown\\\",\\\"trust_tier\\\":\\\"unknown\\\",\\\"origin\\\":\\\"legacy\\\"},{\\\"slug\\\":\\\"notes/short-example\\\",\\\"title\\\":\\\"notes/short-example\\\",\\\"type\\\":\\\"note\\\",\\\"chunk_text\\\":\\\"A short note: ask about the renewal fee before the call.\\\",\\\"chunk_id\\\":5,\\\"score\\\":0.3964128792285919,\\\"source_id\\\":\\\"default\\\",\\\"effective_date\\\":null,\\\"id\\\":\\\"gbrain-page:v1:WyJkZWZhdWx0Iiwibm90ZXMvc2hvcnQtZXhhbXBsZSJd\\\",\\\"evidence\\\":\\\"weak_semantic\\\",\\\"create_safety\\\":\\\"unknown\\\",\\\"trust_tier\\\":\\\"unknown\\\",\\\"origin\\\":\\\"legacy\\\"}]\"}],\"_meta\":{\"retrieval\":{\"returned_count\":3,\"retrieved_count\":3,\"projection_readiness\":{\"status\":\"ready\",\"ready\":true},\"delivery\":{\"requested_unit\":\"auto\",\"applied_unit\":\"auto\",\"return_window\":1,\"budget_tokens\":24000,\"budget_used\":1181,\"tokens_delivered\":1168,\"tokenizer\":\"cl100k\",\"coordinates\":\"utf16\",\"blocks\":3,\"dropped\":0,\"dropped_reasons\":{},\"fallbacks\":[]},\"rows\":\"lean\"}}}",
- "mcp-search:section": "{\"content\":[{\"type\":\"text\",\"text\":\"[{\\\"slug\\\":\\\"contracts/msa-example\\\",\\\"title\\\":\\\"contracts/msa-example\\\",\\\"type\\\":\\\"note\\\",\\\"chunk_text\\\":\\\"## Definitions\\\\n\\\\nThe renewal fee means the amount stated in the order form. Clause 1 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 2 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 3 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 4 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 5 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 6 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 7 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 8 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 9 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 10 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 11 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 12 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 13 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 14 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 15 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 16 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 17 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 18 on definitions restates the general obligations of both parties and the notice address for correspondence.\\\\n\\\\n## Fees\\\\n\\\\nNo renewal fee applies to trial seats, and the renewal fee is invoiced in advance. Clause 1 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 2 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 3 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 4 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 5 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 6 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 7 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 8 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 9 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 10 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 11 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 12 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 13 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 14 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 15 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 16 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 17 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 18 on fees restates the general obligations of both parties and the notice address for correspondence.\\\",\\\"chunk_id\\\":1,\\\"score\\\":0.9518601894378662,\\\"source_id\\\":\\\"default\\\",\\\"effective_date\\\":null,\\\"id\\\":\\\"gbrain-page:v1:WyJkZWZhdWx0IiwiY29udHJhY3RzL21zYS1leGFtcGxlIl0\\\",\\\"evidence\\\":\\\"keyword_exact\\\",\\\"create_safety\\\":\\\"probable\\\",\\\"delivered\\\":{\\\"unit\\\":\\\"section\\\",\\\"reason\\\":\\\"long_page\\\"},\\\"trust_tier\\\":\\\"unknown\\\",\\\"origin\\\":\\\"legacy\\\"},{\\\"slug\\\":\\\"notes/handbook-example\\\",\\\"title\\\":\\\"notes/handbook-example\\\",\\\"type\\\":\\\"note\\\",\\\"chunk_text\\\":\\\"## Renewals\\\\n\\\\nThe handbook describes how a renewal fee is quoted. Clause 1 on handbook restates the general obligations of both parties and the notice address for correspondence. Clause 2 on handbook restates the general obligations of both parties and the notice address for correspondence. Clause 3 on handbook restates the general obligations of both parties and the notice address for correspondence.\\\",\\\"chunk_id\\\":6,\\\"score\\\":0.5802597999572754,\\\"source_id\\\":\\\"default\\\",\\\"effective_date\\\":null,\\\"id\\\":\\\"gbrain-page:v1:WyJkZWZhdWx0Iiwibm90ZXMvaGFuZGJvb2stZXhhbXBsZSJd\\\",\\\"evidence\\\":\\\"weak_semantic\\\",\\\"create_safety\\\":\\\"unknown\\\",\\\"trust_tier\\\":\\\"unknown\\\",\\\"origin\\\":\\\"legacy\\\"},{\\\"slug\\\":\\\"notes/short-example\\\",\\\"title\\\":\\\"notes/short-example\\\",\\\"type\\\":\\\"note\\\",\\\"chunk_text\\\":\\\"A short note: ask about the renewal fee before the call.\\\",\\\"chunk_id\\\":5,\\\"score\\\":0.3964128792285919,\\\"source_id\\\":\\\"default\\\",\\\"effective_date\\\":null,\\\"id\\\":\\\"gbrain-page:v1:WyJkZWZhdWx0Iiwibm90ZXMvc2hvcnQtZXhhbXBsZSJd\\\",\\\"evidence\\\":\\\"weak_semantic\\\",\\\"create_safety\\\":\\\"unknown\\\",\\\"trust_tier\\\":\\\"unknown\\\",\\\"origin\\\":\\\"legacy\\\"}]\"}],\"_meta\":{\"retrieval\":{\"returned_count\":3,\"retrieved_count\":3,\"projection_readiness\":{\"status\":\"ready\",\"ready\":true},\"delivery\":{\"requested_unit\":\"auto\",\"applied_unit\":\"auto\",\"return_window\":1,\"budget_tokens\":24000,\"budget_used\":878,\"tokens_delivered\":865,\"tokenizer\":\"cl100k\",\"coordinates\":\"utf16\",\"blocks\":3,\"dropped\":0,\"dropped_reasons\":{},\"fallbacks\":[]},\"rows\":\"lean\"}}}",
- "mcp-search:page": "{\"content\":[{\"type\":\"text\",\"text\":\"[{\\\"slug\\\":\\\"contracts/msa-example\\\",\\\"title\\\":\\\"contracts/msa-example\\\",\\\"type\\\":\\\"note\\\",\\\"chunk_text\\\":\\\"## Definitions\\\\n\\\\nThe renewal fee means the amount stated in the order form. Clause 1 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 2 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 3 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 4 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 5 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 6 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 7 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 8 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 9 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 10 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 11 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 12 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 13 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 14 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 15 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 16 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 17 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 18 on definitions restates the general obligations of both parties and the notice address for correspondence.\\\\n\\\\n## Fees\\\\n\\\\nNo renewal fee applies to trial seats, and the renewal fee is invoiced in advance. Clause 1 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 2 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 3 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 4 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 5 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 6 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 7 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 8 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 9 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 10 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 11 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 12 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 13 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 14 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 15 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 16 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 17 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 18 on fees restates the general obligations of both parties and the notice address for correspondence.\\\\n\\\\n## Term and renewal\\\\n\\\\nThe agreement renews each year; a renewal fee change needs written notice. Clause 1 on term restates the general obligations of both parties and the notice address for correspondence. Clause 2 on term restates the general obligations of both parties and the notice address for correspondence. Clause 3 on term restates the general obligations of both parties and the notice address for correspondence. Clause 4 on term restates the general obligations of both parties and the notice address for correspondence. Clause 5 on term restates the general obligations of both parties and the notice address for correspondence. Clause 6 on term restates the general obligations of both parties and the notice address for correspondence. Clause 7 on term restates the general obligations of both parties and the notice address for correspondence. Clause 8 on term restates the general obligations of both parties and the notice address for correspondence. Clause 9 on term restates the general obligations of both parties and the notice address for correspondence. Clause 10 on term restates the general obligations of both parties and the notice address for correspondence. Clause 11 on term restates the general obligations of both parties and the notice address for correspondence. Clause 12 on term restates the general obligations of both parties and the notice address for correspondence. Clause 13 on term restates the general obligations of both parties and the notice address for correspondence. Clause 14 on term restates the general obligations of both parties and the notice address for correspondence. Clause 15 on term restates the general obligations of both parties and the notice address for correspondence. Clause 16 on term restates the general obligations of both parties and the notice address for correspondence. Clause 17 on term restates the general obligations of both parties and the notice address for correspondence. Clause 18 on term restates the general obligations of both parties and the notice address for correspondence.\\\\n\\\\n## Amendment 2\\\\n\\\\nEffective 2026-03-01 the annual renewal fee for acme-example is 4,200 USD. Clause 1 on amendment restates the general obligations of both parties and the notice address for correspondence. Clause 2 on amendment restates the general obligations of both parties and the notice address for correspondence. Clause 3 on amendment restates the general obligations of both parties and the notice address for correspondence. Clause 4 on amendment restates the general obligations of both parties and the notice address for correspondence. Clause 5 on amendment restates the general obligations of both parties and the notice address for correspondence. Clause 6 on amendment restates the general obligations of both parties and the notice address for correspondence.\\\\n\\\\n## Notices\\\\n\\\\nClause 1 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 2 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 3 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 4 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 5 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 6 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 7 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 8 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 9 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 10 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 11 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 12 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 13 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 14 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 15 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 16 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 17 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 18 on notices restates the general obligations of both parties and the notice address for correspondence.\\\",\\\"chunk_id\\\":1,\\\"score\\\":0.9518601894378662,\\\"source_id\\\":\\\"default\\\",\\\"effective_date\\\":null,\\\"id\\\":\\\"gbrain-page:v1:WyJkZWZhdWx0IiwiY29udHJhY3RzL21zYS1leGFtcGxlIl0\\\",\\\"evidence\\\":\\\"keyword_exact\\\",\\\"create_safety\\\":\\\"probable\\\",\\\"delivered\\\":{\\\"unit\\\":\\\"page\\\",\\\"reason\\\":\\\"long_page\\\"},\\\"trust_tier\\\":\\\"unknown\\\",\\\"origin\\\":\\\"legacy\\\"},{\\\"slug\\\":\\\"notes/handbook-example\\\",\\\"title\\\":\\\"notes/handbook-example\\\",\\\"type\\\":\\\"note\\\",\\\"chunk_text\\\":\\\"## Renewals\\\\n\\\\nThe handbook describes how a renewal fee is quoted. Clause 1 on handbook restates the general obligations of both parties and the notice address for correspondence. Clause 2 on handbook restates the general obligations of both parties and the notice address for correspondence. Clause 3 on handbook restates the general obligations of both parties and the notice address for correspondence.\\\",\\\"chunk_id\\\":6,\\\"score\\\":0.5802597999572754,\\\"source_id\\\":\\\"default\\\",\\\"effective_date\\\":null,\\\"id\\\":\\\"gbrain-page:v1:WyJkZWZhdWx0Iiwibm90ZXMvaGFuZGJvb2stZXhhbXBsZSJd\\\",\\\"evidence\\\":\\\"weak_semantic\\\",\\\"create_safety\\\":\\\"unknown\\\",\\\"trust_tier\\\":\\\"unknown\\\",\\\"origin\\\":\\\"legacy\\\"},{\\\"slug\\\":\\\"notes/short-example\\\",\\\"title\\\":\\\"notes/short-example\\\",\\\"type\\\":\\\"note\\\",\\\"chunk_text\\\":\\\"A short note: ask about the renewal fee before the call.\\\",\\\"chunk_id\\\":5,\\\"score\\\":0.3964128792285919,\\\"source_id\\\":\\\"default\\\",\\\"effective_date\\\":null,\\\"id\\\":\\\"gbrain-page:v1:WyJkZWZhdWx0Iiwibm90ZXMvc2hvcnQtZXhhbXBsZSJd\\\",\\\"evidence\\\":\\\"weak_semantic\\\",\\\"create_safety\\\":\\\"unknown\\\",\\\"trust_tier\\\":\\\"unknown\\\",\\\"origin\\\":\\\"legacy\\\"}]\"}],\"_meta\":{\"retrieval\":{\"returned_count\":3,\"retrieved_count\":3,\"projection_readiness\":{\"status\":\"ready\",\"ready\":true},\"delivery\":{\"requested_unit\":\"auto\",\"applied_unit\":\"auto\",\"return_window\":1,\"budget_tokens\":24000,\"budget_used\":1791,\"tokens_delivered\":1778,\"tokenizer\":\"cl100k\",\"coordinates\":\"utf16\",\"blocks\":3,\"dropped\":0,\"dropped_reasons\":{},\"fallbacks\":[]},\"rows\":\"lean\"}}}"
+ "mcp-search:window": "{\"content\":[{\"type\":\"text\",\"text\":\"[{\\\"slug\\\":\\\"contracts/msa-example\\\",\\\"title\\\":\\\"contracts/msa-example\\\",\\\"type\\\":\\\"note\\\",\\\"chunk_text\\\":\\\"## Definitions\\\\n\\\\nThe renewal fee means the amount stated in the order form. Clause 1 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 2 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 3 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 4 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 5 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 6 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 7 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 8 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 9 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 10 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 11 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 12 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 13 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 14 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 15 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 16 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 17 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 18 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 19 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 20 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 21 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 22 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 23 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 24 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 25 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 26 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 27 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 28 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 29 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 30 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 31 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 32 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 33 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 34 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 35 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 36 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 37 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 38 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 39 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 40 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 41 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 42 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 43 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 44 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 45 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 46 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 47 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 48 on definitions restates the general obligations of both parties and the notice address for correspondence.\\\\n\\\\n## Fees\\\\n\\\\nNo renewal fee applies to trial seats, and the renewal fee is invoiced in advance. Clause 1 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 2 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 3 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 4 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 5 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 6 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 7 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 8 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 9 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 10 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 11 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 12 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 13 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 14 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 15 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 16 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 17 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 18 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 19 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 20 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 21 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 22 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 23 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 24 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 25 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 26 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 27 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 28 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 29 on\\\",\\\"chunk_id\\\":2,\\\"score\\\":0.9202436804771423,\\\"source_id\\\":\\\"default\\\",\\\"effective_date\\\":null,\\\"id\\\":\\\"gbrain-page:v1:WyJkZWZhdWx0IiwiY29udHJhY3RzL21zYS1leGFtcGxlIl0\\\",\\\"evidence\\\":\\\"keyword_exact\\\",\\\"create_safety\\\":\\\"probable\\\",\\\"delivered\\\":{\\\"unit\\\":\\\"window\\\",\\\"reason\\\":\\\"long_page\\\"},\\\"trust_tier\\\":\\\"unknown\\\",\\\"origin\\\":\\\"legacy\\\"},{\\\"slug\\\":\\\"notes/policy-example\\\",\\\"title\\\":\\\"notes/policy-example\\\",\\\"type\\\":\\\"note\\\",\\\"chunk_text\\\":\\\"## Renewal policy\\\\n\\\\nThe renewal fee policy is reviewed once a year. Clause 1 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 2 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 3 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 4 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 5 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 6 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 7 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 8 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 9 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 10 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 11 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 12 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 13 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 14 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 15 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 16 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 17 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 18 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 19 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 20 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 21 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 22 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 23 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 24 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 25 on policy restates the general obligations of both parties and the notice address for correspondence.\\\",\\\"chunk_id\\\":10,\\\"score\\\":0.626362681388855,\\\"source_id\\\":\\\"default\\\",\\\"effective_date\\\":null,\\\"id\\\":\\\"gbrain-page:v1:WyJkZWZhdWx0Iiwibm90ZXMvcG9saWN5LWV4YW1wbGUiXQ\\\",\\\"evidence\\\":\\\"keyword_exact\\\",\\\"create_safety\\\":\\\"probable\\\",\\\"trust_tier\\\":\\\"unknown\\\",\\\"origin\\\":\\\"legacy\\\"},{\\\"slug\\\":\\\"notes/handbook-example\\\",\\\"title\\\":\\\"notes/handbook-example\\\",\\\"type\\\":\\\"note\\\",\\\"chunk_text\\\":\\\"## Renewals\\\\n\\\\nThe handbook describes how a renewal fee is quoted. Clause 1 on handbook restates the general obligations of both parties and the notice address for correspondence. Clause 2 on handbook restates the general obligations of both parties and the notice address for correspondence. Clause 3 on handbook restates the general obligations of both parties and the notice address for correspondence.\\\",\\\"chunk_id\\\":14,\\\"score\\\":0.5802597999572754,\\\"source_id\\\":\\\"default\\\",\\\"effective_date\\\":null,\\\"id\\\":\\\"gbrain-page:v1:WyJkZWZhdWx0Iiwibm90ZXMvaGFuZGJvb2stZXhhbXBsZSJd\\\",\\\"evidence\\\":\\\"weak_semantic\\\",\\\"create_safety\\\":\\\"unknown\\\",\\\"trust_tier\\\":\\\"unknown\\\",\\\"origin\\\":\\\"legacy\\\"},{\\\"slug\\\":\\\"notes/short-example\\\",\\\"title\\\":\\\"notes/short-example\\\",\\\"type\\\":\\\"note\\\",\\\"chunk_text\\\":\\\"A short note: ask about the renewal fee before the call.\\\",\\\"chunk_id\\\":9,\\\"score\\\":0.3964128792285919,\\\"source_id\\\":\\\"default\\\",\\\"effective_date\\\":null,\\\"id\\\":\\\"gbrain-page:v1:WyJkZWZhdWx0Iiwibm90ZXMvc2hvcnQtZXhhbXBsZSJd\\\",\\\"evidence\\\":\\\"weak_semantic\\\",\\\"create_safety\\\":\\\"unknown\\\",\\\"trust_tier\\\":\\\"unknown\\\",\\\"origin\\\":\\\"legacy\\\"}]\"}],\"_meta\":{\"retrieval\":{\"returned_count\":4,\"retrieved_count\":4,\"projection_readiness\":{\"status\":\"ready\",\"ready\":true},\"delivery\":{\"requested_unit\":\"auto\",\"applied_unit\":\"auto\",\"return_window\":1,\"budget_tokens\":24000,\"budget_used\":2236,\"tokens_delivered\":2219,\"tokenizer\":\"cl100k\",\"coordinates\":\"utf16\",\"blocks\":4,\"dropped\":0,\"dropped_reasons\":{},\"fallbacks\":[]},\"rows\":\"lean\"}}}",
+ "mcp-search:section": "{\"content\":[{\"type\":\"text\",\"text\":\"[{\\\"slug\\\":\\\"contracts/msa-example\\\",\\\"title\\\":\\\"contracts/msa-example\\\",\\\"type\\\":\\\"note\\\",\\\"chunk_text\\\":\\\"## Definitions\\\\n\\\\nThe renewal fee means the amount stated in the order form. Clause 1 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 2 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 3 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 4 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 5 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 6 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 7 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 8 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 9 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 10 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 11 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 12 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 13 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 14 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 15 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 16 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 17 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 18 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 19 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 20 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 21 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 22 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 23 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 24 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 25 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 26 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 27 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 28 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 29 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 30 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 31 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 32 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 33 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 34 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 35 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 36 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 37 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 38 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 39 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 40 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 41 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 42 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 43 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 44 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 45 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 46 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 47 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 48 on definitions restates the general obligations of both parties and the notice address for correspondence.\\\\n\\\\n## Fees\\\\n\\\\nNo renewal fee applies to trial seats, and the renewal fee is invoiced in advance. Clause 1 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 2 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 3 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 4 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 5 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 6 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 7 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 8 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 9 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 10 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 11 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 12 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 13 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 14 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 15 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 16 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 17 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 18 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 19 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 20 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 21 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 22 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 23 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 24 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 25 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 26 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 27 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 28 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 29 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 30 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 31 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 32 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 33 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 34 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 35 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 36 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 37 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 38 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 39 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 40 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 41 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 42 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 43 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 44 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 45 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 46 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 47 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 48 on fees restates the general obligations of both parties and the notice address for correspondence.\\\",\\\"chunk_id\\\":2,\\\"score\\\":0.9202436804771423,\\\"source_id\\\":\\\"default\\\",\\\"effective_date\\\":null,\\\"id\\\":\\\"gbrain-page:v1:WyJkZWZhdWx0IiwiY29udHJhY3RzL21zYS1leGFtcGxlIl0\\\",\\\"evidence\\\":\\\"keyword_exact\\\",\\\"create_safety\\\":\\\"probable\\\",\\\"delivered\\\":{\\\"unit\\\":\\\"section\\\",\\\"reason\\\":\\\"long_page\\\"},\\\"trust_tier\\\":\\\"unknown\\\",\\\"origin\\\":\\\"legacy\\\"},{\\\"slug\\\":\\\"notes/policy-example\\\",\\\"title\\\":\\\"notes/policy-example\\\",\\\"type\\\":\\\"note\\\",\\\"chunk_text\\\":\\\"## Renewal policy\\\\n\\\\nThe renewal fee policy is reviewed once a year. Clause 1 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 2 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 3 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 4 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 5 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 6 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 7 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 8 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 9 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 10 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 11 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 12 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 13 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 14 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 15 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 16 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 17 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 18 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 19 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 20 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 21 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 22 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 23 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 24 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 25 on policy restates the general obligations of both parties and the notice address for correspondence.\\\",\\\"chunk_id\\\":10,\\\"score\\\":0.626362681388855,\\\"source_id\\\":\\\"default\\\",\\\"effective_date\\\":null,\\\"id\\\":\\\"gbrain-page:v1:WyJkZWZhdWx0Iiwibm90ZXMvcG9saWN5LWV4YW1wbGUiXQ\\\",\\\"evidence\\\":\\\"keyword_exact\\\",\\\"create_safety\\\":\\\"probable\\\",\\\"trust_tier\\\":\\\"unknown\\\",\\\"origin\\\":\\\"legacy\\\"},{\\\"slug\\\":\\\"notes/handbook-example\\\",\\\"title\\\":\\\"notes/handbook-example\\\",\\\"type\\\":\\\"note\\\",\\\"chunk_text\\\":\\\"## Renewals\\\\n\\\\nThe handbook describes how a renewal fee is quoted. Clause 1 on handbook restates the general obligations of both parties and the notice address for correspondence. Clause 2 on handbook restates the general obligations of both parties and the notice address for correspondence. Clause 3 on handbook restates the general obligations of both parties and the notice address for correspondence.\\\",\\\"chunk_id\\\":14,\\\"score\\\":0.5802597999572754,\\\"source_id\\\":\\\"default\\\",\\\"effective_date\\\":null,\\\"id\\\":\\\"gbrain-page:v1:WyJkZWZhdWx0Iiwibm90ZXMvaGFuZGJvb2stZXhhbXBsZSJd\\\",\\\"evidence\\\":\\\"weak_semantic\\\",\\\"create_safety\\\":\\\"unknown\\\",\\\"trust_tier\\\":\\\"unknown\\\",\\\"origin\\\":\\\"legacy\\\"},{\\\"slug\\\":\\\"notes/short-example\\\",\\\"title\\\":\\\"notes/short-example\\\",\\\"type\\\":\\\"note\\\",\\\"chunk_text\\\":\\\"A short note: ask about the renewal fee before the call.\\\",\\\"chunk_id\\\":9,\\\"score\\\":0.3964128792285919,\\\"source_id\\\":\\\"default\\\",\\\"effective_date\\\":null,\\\"id\\\":\\\"gbrain-page:v1:WyJkZWZhdWx0Iiwibm90ZXMvc2hvcnQtZXhhbXBsZSJd\\\",\\\"evidence\\\":\\\"weak_semantic\\\",\\\"create_safety\\\":\\\"unknown\\\",\\\"trust_tier\\\":\\\"unknown\\\",\\\"origin\\\":\\\"legacy\\\"}]\"}],\"_meta\":{\"retrieval\":{\"returned_count\":4,\"retrieved_count\":4,\"projection_readiness\":{\"status\":\"ready\",\"ready\":true},\"delivery\":{\"requested_unit\":\"auto\",\"applied_unit\":\"auto\",\"return_window\":1,\"budget_tokens\":24000,\"budget_used\":2644,\"tokens_delivered\":2627,\"tokenizer\":\"cl100k\",\"coordinates\":\"utf16\",\"blocks\":4,\"dropped\":0,\"dropped_reasons\":{},\"fallbacks\":[]},\"rows\":\"lean\"}}}",
+ "mcp-search:page": "{\"content\":[{\"type\":\"text\",\"text\":\"[{\\\"slug\\\":\\\"contracts/msa-example\\\",\\\"title\\\":\\\"contracts/msa-example\\\",\\\"type\\\":\\\"note\\\",\\\"chunk_text\\\":\\\"## Definitions\\\\n\\\\nThe renewal fee means the amount stated in the order form. Clause 1 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 2 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 3 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 4 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 5 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 6 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 7 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 8 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 9 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 10 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 11 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 12 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 13 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 14 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 15 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 16 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 17 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 18 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 19 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 20 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 21 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 22 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 23 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 24 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 25 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 26 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 27 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 28 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 29 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 30 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 31 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 32 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 33 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 34 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 35 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 36 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 37 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 38 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 39 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 40 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 41 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 42 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 43 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 44 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 45 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 46 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 47 on definitions restates the general obligations of both parties and the notice address for correspondence. Clause 48 on definitions restates the general obligations of both parties and the notice address for correspondence.\\\\n\\\\n## Fees\\\\n\\\\nNo renewal fee applies to trial seats, and the renewal fee is invoiced in advance. Clause 1 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 2 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 3 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 4 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 5 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 6 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 7 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 8 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 9 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 10 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 11 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 12 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 13 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 14 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 15 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 16 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 17 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 18 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 19 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 20 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 21 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 22 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 23 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 24 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 25 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 26 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 27 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 28 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 29 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 30 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 31 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 32 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 33 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 34 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 35 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 36 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 37 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 38 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 39 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 40 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 41 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 42 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 43 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 44 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 45 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 46 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 47 on fees restates the general obligations of both parties and the notice address for correspondence. Clause 48 on fees restates the general obligations of both parties and the notice address for correspondence.\\\\n\\\\n## Term and renewal\\\\n\\\\nThe agreement renews each year; a renewal fee change needs written notice. Clause 1 on term restates the general obligations of both parties and the notice address for correspondence. Clause 2 on term restates the general obligations of both parties and the notice address for correspondence. Clause 3 on term restates the general obligations of both parties and the notice address for correspondence. Clause 4 on term restates the general obligations of both parties and the notice address for correspondence. Clause 5 on term restates the general obligations of both parties and the notice address for correspondence. Clause 6 on term restates the general obligations of both parties and the notice address for correspondence. Clause 7 on term restates the general obligations of both parties and the notice address for correspondence. Clause 8 on term restates the general obligations of both parties and the notice address for correspondence. Clause 9 on term restates the general obligations of both parties and the notice address for correspondence. Clause 10 on term restates the general obligations of both parties and the notice address for correspondence. Clause 11 on term restates the general obligations of both parties and the notice address for correspondence. Clause 12 on term restates the general obligations of both parties and the notice address for correspondence. Clause 13 on term restates the general obligations of both parties and the notice address for correspondence. Clause 14 on term restates the general obligations of both parties and the notice address for correspondence. Clause 15 on term restates the general obligations of both parties and the notice address for correspondence. Clause 16 on term restates the general obligations of both parties and the notice address for correspondence. Clause 17 on term restates the general obligations of both parties and the notice address for correspondence. Clause 18 on term restates the general obligations of both parties and the notice address for correspondence. Clause 19 on term restates the general obligations of both parties and the notice address for correspondence. Clause 20 on term restates the general obligations of both parties and the notice address for correspondence. Clause 21 on term restates the general obligations of both parties and the notice address for correspondence. Clause 22 on term restates the general obligations of both parties and the notice address for correspondence. Clause 23 on term restates the general obligations of both parties and the notice address for correspondence. Clause 24 on term restates the general obligations of both parties and the notice address for correspondence. Clause 25 on term restates the general obligations of both parties and the notice address for correspondence. Clause 26 on term restates the general obligations of both parties and the notice address for correspondence. Clause 27 on term restates the general obligations of both parties and the notice address for correspondence. Clause 28 on term restates the general obligations of both parties and the notice address for correspondence. Clause 29 on term restates the general obligations of both parties and the notice address for correspondence. Clause 30 on term restates the general obligations of both parties and the notice address for correspondence. Clause 31 on term restates the general obligations of both parties and the notice address for correspondence. Clause 32 on term restates the general obligations of both parties and the notice address for correspondence. Clause 33 on term restates the general obligations of both parties and the notice address for correspondence. Clause 34 on term restates the general obligations of both parties and the notice address for correspondence. Clause 35 on term restates the general obligations of both parties and the notice address for correspondence. Clause 36 on term restates the general obligations of both parties and the notice address for correspondence. Clause 37 on term restates the general obligations of both parties and the notice address for correspondence. Clause 38 on term restates the general obligations of both parties and the notice address for correspondence. Clause 39 on term restates the general obligations of both parties and the notice address for correspondence. Clause 40 on term restates the general obligations of both parties and the notice address for correspondence. Clause 41 on term restates the general obligations of both parties and the notice address for correspondence. Clause 42 on term restates the general obligations of both parties and the notice address for correspondence. Clause 43 on term restates the general obligations of both parties and the notice address for correspondence. Clause 44 on term restates the general obligations of both parties and the notice address for correspondence. Clause 45 on term restates the general obligations of both parties and the notice address for correspondence. Clause 46 on term restates the general obligations of both parties and the notice address for correspondence. Clause 47 on term restates the general obligations of both parties and the notice address for correspondence. Clause 48 on term restates the general obligations of both parties and the notice address for correspondence.\\\\n\\\\n## Amendment 2\\\\n\\\\nEffective 2026-03-01 the annual renewal fee for acme-example is 4,200 USD. Clause 1 on amendment restates the general obligations of both parties and the notice address for correspondence. Clause 2 on amendment restates the general obligations of both parties and the notice address for correspondence. Clause 3 on amendment restates the general obligations of both parties and the notice address for correspondence. Clause 4 on amendment restates the general obligations of both parties and the notice address for correspondence. Clause 5 on amendment restates the general obligations of both parties and the notice address for correspondence. Clause 6 on amendment restates the general obligations of both parties and the notice address for correspondence.\\\\n\\\\n## Notices\\\\n\\\\nClause 1 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 2 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 3 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 4 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 5 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 6 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 7 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 8 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 9 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 10 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 11 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 12 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 13 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 14 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 15 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 16 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 17 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 18 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 19 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 20 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 21 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 22 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 23 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 24 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 25 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 26 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 27 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 28 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 29 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 30 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 31 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 32 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 33 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 34 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 35 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 36 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 37 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 38 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 39 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 40 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 41 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 42 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 43 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 44 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 45 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 46 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 47 on notices restates the general obligations of both parties and the notice address for correspondence. Clause 48 on notices restates the general obligations of both parties and the notice address for correspondence.\\\",\\\"chunk_id\\\":2,\\\"score\\\":0.9202436804771423,\\\"source_id\\\":\\\"default\\\",\\\"effective_date\\\":null,\\\"id\\\":\\\"gbrain-page:v1:WyJkZWZhdWx0IiwiY29udHJhY3RzL21zYS1leGFtcGxlIl0\\\",\\\"evidence\\\":\\\"keyword_exact\\\",\\\"create_safety\\\":\\\"probable\\\",\\\"delivered\\\":{\\\"unit\\\":\\\"page\\\",\\\"reason\\\":\\\"long_page\\\"},\\\"trust_tier\\\":\\\"unknown\\\",\\\"origin\\\":\\\"legacy\\\"},{\\\"slug\\\":\\\"notes/policy-example\\\",\\\"title\\\":\\\"notes/policy-example\\\",\\\"type\\\":\\\"note\\\",\\\"chunk_text\\\":\\\"## Renewal policy\\\\n\\\\nThe renewal fee policy is reviewed once a year. Clause 1 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 2 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 3 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 4 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 5 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 6 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 7 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 8 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 9 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 10 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 11 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 12 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 13 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 14 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 15 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 16 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 17 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 18 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 19 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 20 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 21 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 22 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 23 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 24 on policy restates the general obligations of both parties and the notice address for correspondence. Clause 25 on policy restates the general obligations of both parties and the notice address for correspondence.\\\",\\\"chunk_id\\\":10,\\\"score\\\":0.626362681388855,\\\"source_id\\\":\\\"default\\\",\\\"effective_date\\\":null,\\\"id\\\":\\\"gbrain-page:v1:WyJkZWZhdWx0Iiwibm90ZXMvcG9saWN5LWV4YW1wbGUiXQ\\\",\\\"evidence\\\":\\\"keyword_exact\\\",\\\"create_safety\\\":\\\"probable\\\",\\\"trust_tier\\\":\\\"unknown\\\",\\\"origin\\\":\\\"legacy\\\"},{\\\"slug\\\":\\\"notes/handbook-example\\\",\\\"title\\\":\\\"notes/handbook-example\\\",\\\"type\\\":\\\"note\\\",\\\"chunk_text\\\":\\\"## Renewals\\\\n\\\\nThe handbook describes how a renewal fee is quoted. Clause 1 on handbook restates the general obligations of both parties and the notice address for correspondence. Clause 2 on handbook restates the general obligations of both parties and the notice address for correspondence. Clause 3 on handbook restates the general obligations of both parties and the notice address for correspondence.\\\",\\\"chunk_id\\\":14,\\\"score\\\":0.5802597999572754,\\\"source_id\\\":\\\"default\\\",\\\"effective_date\\\":null,\\\"id\\\":\\\"gbrain-page:v1:WyJkZWZhdWx0Iiwibm90ZXMvaGFuZGJvb2stZXhhbXBsZSJd\\\",\\\"evidence\\\":\\\"weak_semantic\\\",\\\"create_safety\\\":\\\"unknown\\\",\\\"trust_tier\\\":\\\"unknown\\\",\\\"origin\\\":\\\"legacy\\\"},{\\\"slug\\\":\\\"notes/short-example\\\",\\\"title\\\":\\\"notes/short-example\\\",\\\"type\\\":\\\"note\\\",\\\"chunk_text\\\":\\\"A short note: ask about the renewal fee before the call.\\\",\\\"chunk_id\\\":9,\\\"score\\\":0.3964128792285919,\\\"source_id\\\":\\\"default\\\",\\\"effective_date\\\":null,\\\"id\\\":\\\"gbrain-page:v1:WyJkZWZhdWx0Iiwibm90ZXMvc2hvcnQtZXhhbXBsZSJd\\\",\\\"evidence\\\":\\\"weak_semantic\\\",\\\"create_safety\\\":\\\"unknown\\\",\\\"trust_tier\\\":\\\"unknown\\\",\\\"origin\\\":\\\"legacy\\\"}]\"}],\"_meta\":{\"retrieval\":{\"returned_count\":4,\"retrieved_count\":4,\"projection_readiness\":{\"status\":\"ready\",\"ready\":true},\"delivery\":{\"requested_unit\":\"auto\",\"applied_unit\":\"auto\",\"return_window\":1,\"budget_tokens\":24000,\"budget_used\":4779,\"tokens_delivered\":4762,\"tokenizer\":\"cl100k\",\"coordinates\":\"utf16\",\"blocks\":4,\"dropped\":0,\"dropped_reasons\":{},\"fallbacks\":[]},\"rows\":\"lean\"}}}"
}
diff --git a/test/fixtures/goldens/exports/runtime.json b/test/fixtures/goldens/exports/runtime.json
index f24c32015c..b91b36e164 100644
--- a/test/fixtures/goldens/exports/runtime.json
+++ b/test/fixtures/goldens/exports/runtime.json
@@ -796,6 +796,7 @@
"AUTO_PACKING_CONFIG_KEY",
"DEFAULT_AUTO_PACKING",
"DEFAULT_CONVERSATION_BUDGET",
+ "DEFAULT_LONG_PAGE_MIN_CHARS",
"DEFAULT_REMOTE_BUDGET_MAX",
"DEFAULT_RETURN_BUDGET",
"EVIDENCE_BLOCK_CHAR_CAP",
@@ -806,7 +807,7 @@
"LONG_PAGE_DEADLINE_MS",
"LONG_PAGE_MAX_INPUT_BYTES",
"LONG_PAGE_MAX_PAGES",
- "LONG_PAGE_MIN_BYTES",
+ "LONG_PAGE_MIN_CHARS_CONFIG_KEY",
"LONG_PAGE_UNITS",
"LONG_PAGE_UNIT_CONFIG_KEY",
"MAX_ASSEMBLE_HITS",
@@ -833,6 +834,7 @@
"evidenceTokenizer",
"isConversationLabels",
"locateChunks",
+ "longPageMinCharsValueProblem",
"longPageUnitValueProblem",
"pageEvidenceText",
"pagePlanHits",
diff --git a/test/fixtures/goldens/exports/types.json b/test/fixtures/goldens/exports/types.json
index 9ef59009fc..6f045ec08e 100644
--- a/test/fixtures/goldens/exports/types.json
+++ b/test/fixtures/goldens/exports/types.json
@@ -6890,6 +6890,13 @@
"24000"
]
},
+ {
+ "kind": "variable",
+ "name": "DEFAULT_LONG_PAGE_MIN_CHARS",
+ "signature": [
+ "20000"
+ ]
+ },
{
"kind": "variable",
"name": "DEFAULT_REMOTE_BUDGET_MAX",
@@ -7059,9 +7066,9 @@
},
{
"kind": "variable",
- "name": "LONG_PAGE_MIN_BYTES",
+ "name": "LONG_PAGE_MIN_CHARS_CONFIG_KEY",
"signature": [
- "8000"
+ "\"search.long_page_min_chars\""
]
},
{
@@ -7081,6 +7088,7 @@
{
"kind": "interface",
"members": [
+ "minChars: number",
"unit: LongPageUnit"
],
"name": "LongPagePolicy"
@@ -7091,6 +7099,7 @@
"deadlineAt: number",
"fallbacks: string[]",
"kept: ReadonlyMap<number, string>",
+ "minChars: number",
"pages: ReadonlySet<number>",
"unit: LongPageUnit"
],
@@ -7304,6 +7313,13 @@
"(text: string, chunks: Array<{ id: number; chunk_index: number; chunk_text: string; }>) => Array<{ id: number; chunk_index: number; start: number; end: number; }>"
]
},
+ {
+ "kind": "function",
+ "name": "longPageMinCharsValueProblem",
+ "signature": [
+ "(value: string) => string | null"
+ ]
+ },
{
"kind": "function",
"name": "longPageUnitValueProblem",
diff --git a/test/helpers/long-page-fixture.ts b/test/helpers/long-page-fixture.ts
index 44fc07c07f..bf50c0035c 100644
--- a/test/helpers/long-page-fixture.ts
+++ b/test/helpers/long-page-fixture.ts
@@ -3,11 +3,13 @@
* `search.long_page_unit`): the PGLite unit arm (test/evidence-long-page.test.ts)
* and the Postgres arm (test/e2e/evidence-long-page.test.ts).
*
- * `contracts/msa-example` is the one long page (well over LONG_PAGE_MIN_BYTES,
- * with ATX sections). Its term words ("renewal fee") recur in clauses that do
- * not decide the value, so a delivered unit has to be anchored on the ranked
- * hit, never on term overlap. The other pages are short; `chat/session-example`
- * is a conversation for the mixed case.
+ * `contracts/msa-example` is the one long page (over the default
+ * `search.long_page_min_chars`, 20,000 rendered characters, with ATX
+ * sections). Its term words ("renewal fee") recur in clauses that do not
+ * decide the value, so a delivered unit has to be anchored on the ranked hit,
+ * never on term overlap. `notes/policy-example` is medium (over the old
+ * 8,000-byte line, under 20,000 characters), the others are short;
+ * `chat/session-example` is a conversation for the mixed case.
*/
import type { BrainEngine } from '../../src/core/engine.ts';
import { operations, type OperationContext } from '../../src/core/operations.ts';
@@ -20,6 +22,7 @@ import { withEnv } from './with-env.ts';
const filler = (topic: string, n: number) => Array.from({ length: n }, (_, i) => `Clause ${i + 1} on ${topic} restates the general obligations of both parties and the notice address for correspondence.`).join(' ');
export const LONG_SLUG = 'contracts/msa-example';
+export const MEDIUM_SLUG = 'notes/policy-example';
export const DECIDING = 'Effective 2026-03-01 the annual renewal fee for acme-example is 4,200 USD.';
export const LONG_PAGE_CORPUS: Array<{ slug: string; type: string; body: string }> = [
@@ -27,14 +30,15 @@ export const LONG_PAGE_CORPUS: Array<{ slug: string; type: string; body: string
slug: LONG_SLUG,
type: 'note',
body: [
- `## Definitions\n\nThe renewal fee means the amount stated in the order form. ${filler('definitions', 18)}`,
- `## Fees\n\nNo renewal fee applies to trial seats, and the renewal fee is invoiced in advance. ${filler('fees', 18)}`,
- `## Term and renewal\n\nThe agreement renews each year; a renewal fee change needs written notice. ${filler('term', 18)}`,
+ `## Definitions\n\nThe renewal fee means the amount stated in the order form. ${filler('definitions', 48)}`,
+ `## Fees\n\nNo renewal fee applies to trial seats, and the renewal fee is invoiced in advance. ${filler('fees', 48)}`,
+ `## Term and renewal\n\nThe agreement renews each year; a renewal fee change needs written notice. ${filler('term', 48)}`,
`## Amendment 2\n\n${DECIDING} ${filler('amendment', 6)}`,
- `## Notices\n\n${filler('notices', 18)}`,
+ `## Notices\n\n${filler('notices', 48)}`,
].join('\n\n'),
},
{ slug: 'notes/short-example', type: 'note', body: 'A short note: ask about the renewal fee before the call.' },
+ { slug: MEDIUM_SLUG, type: 'note', body: `## Renewal policy\n\nThe renewal fee policy is reviewed once a year. ${filler('policy', 100)}` },
{ slug: 'notes/handbook-example', type: 'note', body: `## Renewals\n\nThe handbook describes how a renewal fee is quoted. ${filler('handbook', 3)}` },
];