Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(ingest): refuse a document that asks for visibility: private on a world ingest; trim ingest starter text and raise the starter budget residuals
garrytand87e9d9aae63
diff --git a/docs/TOOL_CATALOG.md b/docs/TOOL_CATALOG.mdindex b4dd805529..bafebd260b 100644--- a/docs/TOOL_CATALOG.md+++ b/docs/TOOL_CATALOG.md@@ -172,8 +172,8 @@ Every non-localOnly operation on the MCP surface: 166 tools across 26 areas. **S| Tool | Description | Scope | Starter | Gate ||---|---|---|---|---|-| `ingest` | Save a pasted document: the whole text read in windows, every page and fact planned and checked before any write, then the source page, proposed pages for new entities and each fact on the entities it names. | write | yes | |-| `ingest_undo` | Undo one ingest attempt: without yes it previews what would be retracted and returns plan_hash (writes nothing); with yes and expect: <plan_hash> it strikes the facts the attempt wrote and soft-deletes the pages it created, skipping anything edited, promoted, referenced or supported since. | write | yes | |+| `ingest` | Save a pasted document as a source page, proposed pages for new entities and facts on the entities it names, all planned and checked before any write. | write | yes | |+| `ingest_undo` | Undo one ingest attempt. | write | yes | |## pagesdiff --git a/docs/guides/ingest.md b/docs/guides/ingest.mdindex 3ca09e6c66..94c8b92a96 100644--- a/docs/guides/ingest.md+++ b/docs/guides/ingest.md@@ -182,6 +182,7 @@ first, ingest plans that entity once more and reports what it found (`existing`,| `ingest_attempt_not_found` | | check the attempt id || `ingest_undo_unverifiable` | | review the attempt's pages by hand || `ingest_namespace_reserved` | | use ingest-undo or another slug |+| `visibility_not_applied` | `noncanonical_value`, `not_kept` | the document's own frontmatter asks for `visibility: private` (any spelling) and the ingest is world: run it on the brain host with `--visibility private`, or remove the request; nothing was read or written |All of them are in [error codes](error-codes.md); `gbrain errors <code>` explains each offline.diff --git a/docs/guides/write-refusals.md b/docs/guides/write-refusals.mdindex 9431fe3f84..43797ba3d0 100644--- a/docs/guides/write-refusals.md+++ b/docs/guides/write-refusals.md@@ -135,7 +135,7 @@ a receipt can report has a row here.| Reason | Error code | What it means | Recovery || --- | --- | --- | --- || `writer_pool_capacity` | `writer_pool_capacity` | The canonical owner has no free publication slot right now; the write stays queued. | Wait and poll the receipt (`gbrain write-request <id>`). If it persists, check `gbrain sources writer status <source>`. |-| <a id="visibility_not_applied"></a>`noncanonical_value`, `not_kept` | `visibility_not_applied` | A `put_page`, `edit_page` or `capture` write's frontmatter asked for `visibility: private`, but the page would have stayed world-readable, so nothing was written and no no-op was reported (#7841). An `ingest_capture` job (webhook `POST /ingest`, the ingestion daemon) refuses this request on every brain and dead-letters without a retry, its job result carrying the refusal (#7880); the webhook answers 202 before the job runs, so a sender reads the refusal from the job. `gbrain brainstorm` / `gbrain lsd` with `--save` and `gbrain sources reconcile` (a merge that takes a file's `Visibility: private`) refuse it on every brain too and store nothing (#7897). `noncanonical_value`: the key or value is in another case (`Visibility: private`, `visibility: Private`) or another shape (a value on the next line, a block scalar, a list, a flow mapping, an explicit or merged key), which page privacy does not read as private. `not_kept`: the request did not survive into the page that would be stored. The check only refuses; it never widens a page or changes what a remote caller may read or write. When the content's frontmatter is unreadable or ambiguous (the importer would hold it), a private request gets the importer's `invalid_frontmatter` refusal with its reason instead; nothing is written either way. | Read the page and its revision (`gbrain get --source <id> -- <slug>`), write `visibility: private` on its own frontmatter line, lowercase, and submit `put_page` again with a new `request_id`. That is the supported way to make an existing page private, on a git-canonical source too (the page publishes database-only, see [`git_private_commit_refused`](#git_private_commit_refused)). |+| <a id="visibility_not_applied"></a>`noncanonical_value`, `not_kept` | `visibility_not_applied` | A `put_page`, `edit_page` or `capture` write's frontmatter asked for `visibility: private`, but the page would have stayed world-readable, so nothing was written and no no-op was reported (#7841). An `ingest_capture` job (webhook `POST /ingest`, the ingestion daemon) refuses this request on every brain and dead-letters without a retry, its job result carrying the refusal (#7880); the webhook answers 202 before the job runs, so a sender reads the refusal from the job. `gbrain brainstorm` / `gbrain lsd` with `--save` and `gbrain sources reconcile` (a merge that takes a file's `Visibility: private`) refuse it on every brain too and store nothing (#7897). `ingest` refuses a document whose own leading frontmatter asks for it, in any spelling, unless the ingest itself is private (`gbrain ingest --visibility private`), before any provider call or write. `noncanonical_value`: the key or value is in another case (`Visibility: private`, `visibility: Private`) or another shape (a value on the next line, a block scalar, a list, a flow mapping, an explicit or merged key), which page privacy does not read as private. `not_kept`: the request did not survive into the page that would be stored. The check only refuses; it never widens a page or changes what a remote caller may read or write. When the content's frontmatter is unreadable or ambiguous (the importer would hold it), a private request gets the importer's `invalid_frontmatter` refusal with its reason instead; nothing is written either way. | Read the page and its revision (`gbrain get --source <id> -- <slug>`), write `visibility: private` on its own frontmatter line, lowercase, and submit `put_page` again with a new `request_id`. That is the supported way to make an existing page private, on a git-canonical source too (the page publishes database-only, see [`git_private_commit_refused`](#git_private_commit_refused)). || `revision_required` | `revision_required` | The operation must be bound to a revision you reviewed (for example `--if-version` or `expected_revision`), and none was given: a `put_page` of a page that already exists without `expected_revision` reports this since #5385 (earlier releases said `revision_conflict`). | Preview first, then repeat with the revision the preview printed. || `revision_conflict` | `revision_conflict` | The page changed after the revision this write was bound to. Nothing was overwritten. | Re-read the page, merge your change, and save with the new revision. || `revision_changed` | `revision_changed` | An `append_page` with `expected_revision`, or a `commit_page_upload` whose session was bound to a revision, found the page at a newer revision. Nothing was appended or written, and the upload session is aborted with its staged bytes released. | Read the page again (`get_page` with `body: 'none'`), check whether the text is still missing, then append against the new revision with a new `request_id` (for an upload, begin a new session). |diff --git a/src/core/operation-manifest.generated.ts b/src/core/operation-manifest.generated.tsindex 5fb67d23d9..6a7d10f84c 100644--- a/src/core/operation-manifest.generated.ts+++ b/src/core/operation-manifest.generated.ts@@ -5581,27 +5581,27 @@ export const OPERATION_MANIFEST: OperationMeta[] = [},{"name": "ingest",- "description": "Save a pasted document: the whole text read in windows, every page and fact planned and checked before any write, then the source page, proposed pages for new entities and each fact on the entities it names. Returns an ingest report with a status per item, coverage, spend, and approve or undo actions. attempt_id alone reads a report (read-only); with resume: true it continues an incomplete attempt.",+ "description": "Save a pasted document as a source page, proposed pages for new entities and facts on the entities it names, all planned and checked before any write. Returns a report: status per item, coverage, spend, approve and undo actions. attempt_id alone reads a report; with resume: true continues it.","params": {"content": {"type": "string",- "description": "The document text (at most 200,000 characters)."+ "description": "Document text (max 200,000 chars)."},"attempt_id": {"type": "string",- "description": "An attempt id from a report: alone, read that report; with resume, continue it."+ "description": "From a report: alone reads it; with resume continues it."},"resume": {"type": "boolean",- "description": "Continue an incomplete attempt from its stored windows (pass the same content)."+ "description": "Continue an incomplete attempt (same content)."},"type": {"type": "string",- "description": "Page type of the source page (default note)."+ "description": "Source page type (default note)."},"title": {"type": "string",- "description": "Title of the source page."+ "description": "Source page title."},"slug": {"type": "string",@@ -5649,7 +5649,7 @@ export const OPERATION_MANIFEST: OperationMeta[] = [},"dry_run": {"type": "boolean",- "description": "Preview the keyless candidate plan, window count and estimated cost; no provider call, nothing written."+ "description": "Preview candidates, windows and cost; no provider call or write."}},"outputRedaction": "retrieval",@@ -5663,20 +5663,20 @@ export const OPERATION_MANIFEST: OperationMeta[] = [},{"name": "ingest_undo",- "description": "Undo one ingest attempt: without yes it previews what would be retracted and returns plan_hash (writes nothing); with yes and expect: <plan_hash> it strikes the facts the attempt wrote and soft-deletes the pages it created, skipping anything edited, promoted, referenced or supported since.",+ "description": "Undo one ingest attempt. Without yes: a preview and plan_hash, no write. With yes and expect: <plan_hash>: strikes its facts and soft-deletes its pages, skipping anything edited, promoted, referenced or supported since.","params": {"attempt_id": {"type": "string","required": true,- "description": "The attempt id from the ingest report."+ "description": "From the ingest report."},"yes": {"type": "boolean",- "description": "Apply the undo (needs expect)."+ "description": "Apply (needs expect)."},"expect": {"type": "string",- "description": "The plan_hash from the preview you are applying."+ "description": "plan_hash from the preview."}},"outputRedaction": "no_stored_text",diff --git a/src/core/ops/ingest.ts b/src/core/ops/ingest.tsindex 34d63f926f..231f0f87ba 100644--- a/src/core/ops/ingest.ts+++ b/src/core/ops/ingest.ts@@ -13,7 +13,8 @@ import { readFix } from './op-fix.ts';import { VERSION } from '../../version.ts';import type { Page } from '../types.ts';import { stringifyDataFrontmatter } from '../data-frontmatter.ts';-import { serializePageToMarkdown } from '../markdown.ts';+import { parseMarkdown, serializePageToMarkdown } from '../markdown.ts';+import { readPrivateRequest } from '../persistence/visibility-request.ts';import { assertInlineBody } from '../page-body/page-shape.ts';import { strikeFenceRow } from '../facts/forget.ts';import { checkFactAgainstSaved } from '../facts/backstop.ts';@@ -49,6 +50,23 @@ function invalid(code: 'ingest_input_invalid' | 'ingest_option_invalid', reason:return opError(code, message, 'Nothing was written. ' + suggestion, { reason, docs: DOCS + '#errors', ...(fix ? { fix } : {}) });}+/**+ * #7841/#7880/#7897: a document whose leading frontmatter asks for visibility: private (any spelling) is never stored+ * world-readable; ingest keeps the document as the source page's body, so only a private ingest keeps that request.+ */+function assertNoPrivateRequest(text: string): void {+ let frontmatter: Record<string, unknown> | null | undefined;+ let asks: boolean;+ try {+ asks = readPrivateRequest(text, () => (frontmatter = parseMarkdown(text, 'ingest-document.md').frontmatter)) !== null;+ } catch { asks = true; }+ if (!asks) return;+ const reason = frontmatter?.visibility === 'private' ? 'not_kept' : 'noncanonical_value';+ throw opError('visibility_not_applied', 'The document asks for visibility: private, but this ingest would store it world-readable, so nothing was read or written (' + reason + ').',+ 'Nothing was extracted or written. Ingest it on the brain host with gbrain ingest --visibility private, or remove the request from the document if it may be world-readable.',+ { reason, docs: 'docs/guides/write-refusals.md#visibility_not_applied' });+}+/** Rule 1: every input and option is checked before any read of the brain that could lead to a write. */async function validateRun(ctx: OperationContext, p: Params): Promise<{ text: string; options: IngestOptions; maxUsd: number; title: string | null; slug: string | null }> {if (typeof p.content !== 'string') throw invalid('ingest_input_invalid', 'missing', 'No document text was passed.', 'Pass the document as content (CLI: --file <path> or --stdin).');@@ -75,6 +93,7 @@ async function validateRun(ctx: OperationContext, p: Params): Promise<{ text: stconst visibility = p.visibility === undefined ? 'world' : p.visibility;if (visibility !== 'world' && visibility !== 'private') throw invalid('ingest_option_invalid', 'visibility', 'visibility "' + String(visibility).slice(0, 40) + '" is not world or private.', 'Pass visibility world or private.');if (visibility === 'private' && ctx.remote !== false) throw invalid('ingest_option_invalid', 'visibility', 'Only the local CLI can ingest with visibility private.', 'Omit visibility, or run gbrain ingest --visibility private on the brain host.');+ if (visibility !== 'private') assertNoPrivateRequest(text);const configured = Number(await ctx.engine.getConfig(INGEST_MAX_USD_KEY) ?? DEFAULT_MAX_USD);const ceiling = Number.isFinite(configured) && configured >= 0 ? configured : DEFAULT_MAX_USD;let maxUsd = ceiling;@@ -662,13 +681,13 @@ async function runUndo(ctx: OperationContext, p: Params): Promise<Record<string,const ingest: Operation = {name: 'ingest',- description: 'Save a pasted document: the whole text read in windows, every page and fact planned and checked before any write, then the source page, proposed pages for new entities and each fact on the entities it names. Returns an ingest report with a status per item, coverage, spend, and approve or undo actions. attempt_id alone reads a report (read-only); with resume: true it continues an incomplete attempt.',+ description: 'Save a pasted document as a source page, proposed pages for new entities and facts on the entities it names, all planned and checked before any write. Returns a report: status per item, coverage, spend, approve and undo actions. attempt_id alone reads a report; with resume: true continues it.',params: {- content: { type: 'string', description: 'The document text (at most 200,000 characters).' },- attempt_id: { type: 'string', description: 'An attempt id from a report: alone, read that report; with resume, continue it.' },- resume: { type: 'boolean', description: 'Continue an incomplete attempt from its stored windows (pass the same content).' },- type: { type: 'string', description: 'Page type of the source page (default note).' },- title: { type: 'string', description: 'Title of the source page.' },+ content: { type: 'string', description: 'Document text (max 200,000 chars).' },+ attempt_id: { type: 'string', description: 'From a report: alone reads it; with resume continues it.' },+ resume: { type: 'boolean', description: 'Continue an incomplete attempt (same content).' },+ type: { type: 'string', description: 'Source page type (default note).' },+ title: { type: 'string', description: 'Source page title.' },slug: { type: 'string', description: 'Slug of the source page (default inbox/ingest-<hash>).', fullSurfaceOnly: true },source_id: { type: 'string', description: 'Source to write (default: your source).', fullSurfaceOnly: true },valid_from: { type: 'string', description: 'When the document\'s facts became true (ISO date).', fullSurfaceOnly: true },@@ -677,7 +696,7 @@ const ingest: Operation = {trusted_extraction: { type: 'boolean', description: 'Local owner only: create model-typed new entities as real pages instead of proposed.', fullSurfaceOnly: true },max_usd: { type: 'number', description: 'Spend cap for this ingest in USD (default ingest.max_usd, 0.50).', fullSurfaceOnly: true },request_id: { type: 'string', description: 'Idempotency key: a repeat with the same key returns the same attempt.', fullSurfaceOnly: true },- dry_run: { type: 'boolean', description: 'Preview the keyless candidate plan, window count and estimated cost; no provider call, nothing written.' },+ dry_run: { type: 'boolean', description: 'Preview candidates, windows and cost; no provider call or write.' },},outputRedaction: 'retrieval',writeInference: 'explicit_llm',@@ -689,11 +708,11 @@ const ingest: Operation = {const ingest_undo: Operation = {name: 'ingest_undo',- description: 'Undo one ingest attempt: without yes it previews what would be retracted and returns plan_hash (writes nothing); with yes and expect: <plan_hash> it strikes the facts the attempt wrote and soft-deletes the pages it created, skipping anything edited, promoted, referenced or supported since.',+ description: 'Undo one ingest attempt. Without yes: a preview and plan_hash, no write. With yes and expect: <plan_hash>: strikes its facts and soft-deletes its pages, skipping anything edited, promoted, referenced or supported since.',params: {- attempt_id: { type: 'string', required: true, description: 'The attempt id from the ingest report.' },- yes: { type: 'boolean', description: 'Apply the undo (needs expect).' },- expect: { type: 'string', description: 'The plan_hash from the preview you are applying.' },+ attempt_id: { type: 'string', required: true, description: 'From the ingest report.' },+ yes: { type: 'boolean', description: 'Apply (needs expect).' },+ expect: { type: 'string', description: 'plan_hash from the preview.' },},outputRedaction: 'no_stored_text',writeInference: 'none',diff --git a/test/e2e/ingest-postgres.test.ts b/test/e2e/ingest-postgres.test.tsindex 71d1e650e6..8232264135 100644--- a/test/e2e/ingest-postgres.test.ts+++ b/test/e2e/ingest-postgres.test.ts@@ -72,6 +72,8 @@ d('ingest and ingest_undo (live Postgres)', () => {test('two-entity claim (' + label + ')', async () => { fx = await fixture(storage); await S.twoEntityScenario(engine); }, 60_000);test('reserved report namespace (' + label + ')', async () => { fx = await fixture(storage); await S.namespaceScenario(engine); }, 60_000);test('private ingest (' + label + ')', async () => { fx = await fixture(storage); await S.privacyScenario(engine); }, 60_000);+ test('private request in the document (' + label + ')', async () => { fx = await fixture(storage); await S.privateRequestScenario(engine); }, 60_000);+ test('trust tier parity (' + label + ')', async () => { fx = await fixture(storage); await S.trustTierScenario(engine); }, 60_000);test('held natural slug (' + label + ')', async () => { fx = await fixture(storage); await S.heldSlugScenario(engine); }, 60_000);test('grants (' + label + ')', async () => { fx = await fixture(storage); await S.grantScenario(engine); }, 60_000);test('create conflict re-plan (' + label + ')', async () => { fx = await fixture(storage); await S.createConflictScenario(engine); }, 60_000);diff --git a/test/fixtures/goldens/cli/tools-json.json b/test/fixtures/goldens/cli/tools-json.jsonindex 84c8e24f76..0445d67d41 100644--- a/test/fixtures/goldens/cli/tools-json.json+++ b/test/fixtures/goldens/cli/tools-json.json@@ -2,8 +2,8 @@"golden": {"exitCode": 0,"stderr": "",- "stdoutBytes": 274768,- "stdoutSha256": "a0152c6a9965c546202c5d552da0934c7f70536dfed298fb40f88ca854c040ea",+ "stdoutBytes": 274417,+ "stdoutSha256": "d2eb1a29cc30b4e7908cb044201758900a08909aeb640e663c8c06373d5c9f8a","toolNames": ["remember","entity",@@ -6506,7 +6506,7 @@"scope": "write"},{- "description": "Save a pasted document: the whole text read in windows, every page and fact planned and checked before any write, then the source page, proposed pages for new entities and each fact on the entities it names. Returns an ingest report with a status per item, coverage, spend, and approve or undo actions. attempt_id alone reads a report (read-only); with resume: true it continues an incomplete attempt.",+ "description": "Save a pasted document as a source page, proposed pages for new entities and facts on the entities it names, all planned and checked before any write. Returns a report: status per item, coverage, spend, approve and undo actions. attempt_id alone reads a report; with resume: true continues it.","idempotent": false,"local_only": false,"mutating": true,@@ -6531,15 +6531,15 @@"schema": {"properties": {"attempt_id": {- "description": "An attempt id from a report: alone, read that report; with resume, continue it.",+ "description": "From a report: alone reads it; with resume continues it.","type": "string"},"content": {- "description": "The document text (at most 200,000 characters).",+ "description": "Document text (max 200,000 chars).","type": "string"},"dry_run": {- "description": "Preview the keyless candidate plan, window count and estimated cost; no provider call, nothing written.",+ "description": "Preview candidates, windows and cost; no provider call or write.","type": "boolean"},"max_usd": {@@ -6555,7 +6555,7 @@"type": "string"},"resume": {- "description": "Continue an incomplete attempt from its stored windows (pass the same content).",+ "description": "Continue an incomplete attempt (same content).","type": "boolean"},"slug": {@@ -6567,7 +6567,7 @@"type": "string"},"title": {- "description": "Title of the source page.",+ "description": "Source page title.","type": "string"},"trusted_extraction": {@@ -6575,7 +6575,7 @@"type": "boolean"},"type": {- "description": "Page type of the source page (default note).",+ "description": "Source page type (default note).","type": "string"},"valid_from": {@@ -6597,7 +6597,7 @@"scope": "write"},{- "description": "Undo one ingest attempt: without yes it previews what would be retracted and returns plan_hash (writes nothing); with yes and expect: <plan_hash> it strikes the facts the attempt wrote and soft-deletes the pages it created, skipping anything edited, promoted, referenced or supported since.",+ "description": "Undo one ingest attempt. Without yes: a preview and plan_hash, no write. With yes and expect: <plan_hash>: strikes its facts and soft-deletes its pages, skipping anything edited, promoted, referenced or supported since.","idempotent": false,"local_only": false,"mutating": true,@@ -6611,15 +6611,15 @@"schema": {"properties": {"attempt_id": {- "description": "The attempt id from the ingest report.",+ "description": "From the ingest report.","type": "string"},"expect": {- "description": "The plan_hash from the preview you are applying.",+ "description": "plan_hash from the preview.","type": "string"},"yes": {- "description": "Apply the undo (needs expect).",+ "description": "Apply (needs expect).","type": "boolean"}},diff --git a/test/helpers/ingest-scenarios.ts b/test/helpers/ingest-scenarios.tsindex 50b964fe2f..82bb39e129 100644--- a/test/helpers/ingest-scenarios.ts+++ b/test/helpers/ingest-scenarios.ts@@ -567,3 +567,54 @@ export async function undoUnverifiableScenario(engine: BrainEngine): Promise<voiexpect((await factsOn(engine, 'companies/zentrix')).every(f => f.valid_until === null && f.expired_at === null)).toBe(true);}++/**+ * Master's private-request hold (#7841, #7880, #7897) on a pasted document: a document whose leading frontmatter asks for+ * `visibility: private`, in any spelling, is refused `visibility_not_applied` before any provider call or write unless the+ * ingest itself is private; ingest never stores such a document world-readable.+ */+export async function privateRequestScenario(engine: BrainEngine): Promise<void> {+ await seedEntities(engine);+ const stub = stubChat();+ try {+ const body = '\n\nZentrix signed its first enterprise customer last week.\n';+ const cases: Array<[string, string, Partial<OperationContext>]> = [+ ['---\nVisibility: private\n---' + body, 'noncanonical_value', {}],+ ['---\nvisibility: Private\n---' + body, 'noncanonical_value', {}],+ ['---\nvisibility: private\n---' + body, 'not_kept', {}],+ ['---\nvisibility:\n - private\n---' + body, 'noncanonical_value', {}],+ ['---\nVisibility: private\n---' + body, 'noncanonical_value', { remote: true } as never],+ ];+ for (const [content, reason, over] of cases) {+ const before = await pageCount(engine);+ const err = await ingest(engine, { content, title: 'Board notes' }, over).catch(e => e) as OperationError;+ expect(err).toBeInstanceOf(OperationError);+ expect([err.code, err.reason]).toEqual(['visibility_not_applied', reason]);+ expect(stub.calls).toBe(0);+ expect(await pageCount(engine)).toBe(before);+ expect(await ingestCheckpoints(engine)).toBe(0);+ }+ const report = await ingest(engine, { content: '---\nvisibility: private\n---' + body, title: 'Board notes', visibility: 'private' });+ expect(report.status).toBe('complete');+ expect((await engine.getPage(report.source_page.slug))!.frontmatter.visibility).toBe('private');+ } finally { stub.restore(); }+}++/** Trust-tier provenance: ingest's pages carry the tier the page door gives the same caller's own put_page (#7873). */+export async function trustTierScenario(engine: BrainEngine): Promise<void> {+ await seedEntities(engine);+ const stub = stubChat();+ const tier = async (slug: string) => (await engine.executeRaw<{ trust_tier: string | null }>('SELECT trust_tier FROM pages WHERE slug = $1 AND deleted_at IS NULL', [slug]))[0]?.trust_tier ?? null;+ try {+ const caller = await oauthCaller(engine, { boundSlugPrefixes: ['companies/', 'inbox/', 'ingest/', 'notes/'] });+ const remote = await ingest(engine, { content: 'Zentrix signed its first enterprise customer last week.', title: 'Remote notes' }, caller);+ expect(remote.status).toBe('complete');+ await operationsByName.put_page!.handler(reviewCtx(engine, caller), { slug: 'notes/remote-put', content: '---\ntype: note\ntitle: Remote put\n---\n\nZentrix signed.\n' });+ const local = await ingest(engine, { content: 'Zentrix signed its second enterprise customer this week.', title: 'Local notes' });+ await operationsByName.put_page!.handler(reviewCtx(engine), { slug: 'notes/local-put', content: '---\ntype: note\ntitle: Local put\n---\n\nZentrix signed.\n' });+ await drain(engine);+ expect(await tier(remote.source_page.slug)).toBe(await tier('notes/remote-put'));+ expect(await tier(local.source_page.slug)).toBe(await tier('notes/local-put'));+ } finally { stub.restore(); }+}+diff --git a/test/ingest.serial.test.ts b/test/ingest.serial.test.tsindex 154e70618f..46983b6833 100644--- a/test/ingest.serial.test.ts+++ b/test/ingest.serial.test.ts@@ -84,6 +84,14 @@ for (const storage of ['git', 'database'] as ReviewStorage[]) {fx = await reviewDoorFixture(engine, storage);await S.privacyScenario(engine);}, 60_000);+ test('a document asking for visibility: private is refused unless the ingest is private (master private-request hold)', async () => {+ fx = await reviewDoorFixture(engine, storage);+ await S.privateRequestScenario(engine);+ }, 60_000);+ test('ingest pages carry the trust tier the door gives the caller', async () => {+ fx = await reviewDoorFixture(engine, storage);+ await S.trustTierScenario(engine);+ }, 60_000);test('a natural slug held by an unreadable page takes the hash-tagged slug, proposed', async () => {fx = await reviewDoorFixture(engine, storage);await S.heldSlugScenario(engine);diff --git a/test/mcp-schema-budget.test.ts b/test/mcp-schema-budget.test.tsindex 6b234dcd68..09d5eb29d4 100644--- a/test/mcp-schema-budget.test.ts+++ b/test/mcp-schema-budget.test.ts@@ -63,14 +63,14 @@ import { stdioVisibleTools } from '../src/mcp/server.ts';import { buildMcpInstructions, GBRAIN_MCP_INSTRUCTIONS } from '../src/mcp/instructions.ts';import { cl100kAvailable, estimateTokens } from '../src/core/chunkers/token-estimate.ts';-const SERVED_STARTER_MAX_CHARS = 18_300; // GST-927: +100 for get_page's one-window-selector rule (GPT-6.1 Sol sent lines, bytes and around_chunk_id together on 436 of 607 recorded calls); get_page's own text paid 3+const SERVED_STARTER_MAX_CHARS = 19_743; // GST-927: +100 for get_page's one-window-selector rule (GPT-6.1 Sol sent lines, bytes and around_chunk_id together on 436 of 607 recorded calls); get_page's own text paid 3; GBRA-215 L3: +1,443 for ingest and ingest_undo joining starter (the approved starter listing, row ingest_starter_listing), after their descriptions and parameter text were trimmed (ingest 944, ingest_undo 573 JSON characters); measured 19,539, headroom 204 as on master (18,096)/** Headroom the served starter list must keep under the ceiling (wave 16: 24,998 of 25,000 left 2 characters; 200 is what the wave reaches without touching text other threads own, raised to 300 once the entity card and query/search trims land). */const SERVED_STARTER_MIN_HEADROOM = 200;-const SERVED_STARTER_MAX_TOKENS = 4_300;+const SERVED_STARTER_MAX_TOKENS = 4_609; // GBRA-215 L3: +309 for ingest and ingest_undo joining starter (the approved starter listing, row ingest_starter_listing), after their descriptions and parameter text were trimmed (ingest 944, ingest_undo 573 JSON characters); measured 4,432 (4,123 without them)/** The whole tools/list JSON, annotations included (25,735 measured at v0.60.46.0; traverse_graph's `hops` is full-surface-only, 25,941 measured; 26,402 once mute_notice, the dismissal for the coaching notices starter sessions receive, joined starter; 26,671 with #6007's put_page wait_ms param and write guidance, which carry the put_pages hint and the receipt poll rule starter agents need; 26,679 with delta's opaque `cursor` param, paid for by trimming delta's own descriptions, model-visible 24,985; 26,692 with recall's `question` param, paid for by trimming recall's own parameter text, model-visible 24,998; 24,996 after the #6446 merge, recall's grep text trimmed again). */-const SERVED_STARTER_MAX_JSON_CHARS = 19_900; // GBRA-156: 19,431 measured; GST-927: +100 for get_page's one-window-selector rule+const SERVED_STARTER_MAX_JSON_CHARS = 21_417; // GBRA-156: 19,431 measured; GST-927: +100 for get_page's one-window-selector rule; GBRA-215 L3: +1,517 for ingest and ingest_undo joining starter (the approved starter listing, row ingest_starter_listing), after their descriptions and parameter text were trimmed (ingest 944, ingest_undo 573 JSON characters); measured 21,307/** GBRA-156: the UTF-8 bytes of the served starter tools/list result (`{"tools":[...]}`, annotations included) that harnesses re-fetch every turn. */-const SERVED_STARTER_MAX_RESULT_BYTES = 19_900; // 26,546 before GBRA-156, 19,489 after; GST-927: +100 for get_page's one-window-selector rule+const SERVED_STARTER_MAX_RESULT_BYTES = 21_419; // 26,546 before GBRA-156, 19,489 after; GST-927: +100 for get_page's one-window-selector rule; GBRA-215 L3: +1,519 for ingest and ingest_undo joining starter (the approved starter listing, row ingest_starter_listing), after their descriptions and parameter text were trimmed (ingest 944, ingest_undo 573 JSON characters); measured 21,367/** 4,042 at the cost wave + 586 for the operator contract's error protocol, notice prefix and memory loop (F1); no schema guidance moved here. */const INSTRUCTIONS_MAX_CHARS = 5_108; // #6007: +240 for the issue-required write guidance (put_pages, wait_ms); Cat 40 Hard round 4: +107 for batching lists of names (entity names, keyword OR) and sending independent calls together; d5b: +70 for the brief naming the fields compact `entity names` rows carry (the maximal rendering, record types enrolled; +39 at the default) instead of a `referenced_by` walk batch mode cannot do; F4: +63 for instruction 7's governing rule (the record whose terms are in effect on the date asked about governs; page dates are named as page dates), 74 characters longer than the "prefer the newest governing source" sentence it replaces, 11 paid by cutting "the best-ranked excerpts" to "top excerpts" in the same clauseconst DESCRIPTION_HARD_CAP = 1_200;@@ -100,12 +100,14 @@ const PARAM_DESCRIPTION_HARD_CAP = 200;* at 1,826. Without it Haiku 4.5 routes "all the people that work on X" to* search (28/80 at temperature 1; 1/80 with the clause); the batching sentence* `Name lists: entity names.` stays, so the growth is paid by other tools.+ * ingest 970 and ingest_undo 600 (GBRA-215 L3, the approved starter listing): measured at 944 and 573 after+ * their descriptions and parameter text were trimmed, plus about 25 as GBRA-156 sized its rows.*/const TOOL_BUDGETS: Record<string, number> = {add_timeline_entry: 730, cancel_job: 270, cancel_write_request: 350, capture: 710, context_pack: 500,delete_skill: 810, delta: 580, edit_page: 1040, entity: 550, find_anomalies: 400, forget: 530, get_agent_job: 270,get_backlinks: 710, get_ingest_log: 280, get_page: 600, get_recent_salience: 450, get_skill: 490,- get_skill_asset: 530, get_write_request: 360, join_brain: 560, leave_brain: 540, list_brain_skillpack: 230,+ get_skill_asset: 530, get_write_request: 360, ingest: 970, ingest_undo: 600, join_brain: 560, leave_brain: 540, list_brain_skillpack: 230,list_link_sources: 220, list_pages: 850, list_skills: 400, list_write_requests: 370, put_page: 1090,mute_notice: 420, put_skill: 1420, query: 1700, recall: 840, remember: 940, request_tools: 530, resolve_slugs: 410, search: 1420,submit_agent: 420, sync_brain_skills: 770, synthesize: 510, traverse_graph: 600, whoami: 230,@@ -161,10 +163,10 @@ async function served(publishSkills: boolean): Promise<Operation[]> {}describe('served starter tool list (Cat 40 configuration)', () => {- test('publish_skills on (the fresh-init default): 35 tools within the character ceiling', async () => {+ test('publish_skills on (the fresh-init default): 37 tools within the character ceiling', async () => {const ops = await served(true);expect(ops.map(o => o.name)).toContain('get_skill');- expect(ops.length).toBe(35);+ expect(ops.length).toBe(37); // GBRA-215 L3: +2, ingest and ingest_undoexpect(size(ops)).toBeLessThanOrEqual(SERVED_STARTER_MAX_CHARS);expect(json(ops)).toBeLessThanOrEqual(SERVED_STARTER_MAX_JSON_CHARS);});