Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(trust): content_origin is off the starter schema, accepted everywhere (P8 precedent)
garrytan962c46d854bd
diff --git a/docs/mcp/TOOL_REFERENCE.md b/docs/mcp/TOOL_REFERENCE.mdindex 7d65e54f52..70bf59787f 100644--- a/docs/mcp/TOOL_REFERENCE.md+++ b/docs/mcp/TOOL_REFERENCE.md@@ -53,6 +53,7 @@ Capture a quick note into the brain — the "just remember this" write. Auto-der| `expected_revision` | string | Revision returned by the page read. Required when replacing an existing page unless force is true. Omit both for create-only writes. Carry the read's `source_id` with it: if this revision is the current revision of the same slug in another source you can read, the `revision_conflict` refusal names that source and its fix re-reads the page there. || `force` | boolean | Explicitly overwrite the current revision. Mutually exclusive with expected_revision; does not bypass authorization or the empty-content guard. || `request_id` | string | Optional caller-generated UUID for this write. Reuse the same UUID and original arguments to recover its outcome after a timeout; a different intent requires a new UUID. |+| `content_origin` | string (`user_said`, `tool_output`, `inferred`) | Where the content came from. `tool_output` (web page, email, file or other tool text) stores the write as external, untrusted; `user_said` and `inferred` store it as written by an agent. Advertised on the verbs and full surfaces only; a starter client that passes it is still honored. || `who` | string | For event captures, comma-separated entity slugs. || `what` | string | For event captures, the event description. || `where` | string | For event captures, the location. |@@ -274,6 +275,7 @@ Replace a complete canonical Markdown page. Read get_page with include_content:t| `expected_revision` | string | Revision returned by the page read. Required when replacing an existing page unless force is true. Omit both for create-only writes. || `force` | boolean | Explicitly overwrite the current revision. Mutually exclusive with expected_revision; does not bypass authorization or the empty-content guard. || `request_id` | string | Optional caller-generated UUID for this write. Reuse the same UUID and original arguments to recover its outcome after a timeout; a different intent requires a new UUID. |+| `content_origin` | string (`user_said`, `tool_output`, `inferred`) | Where the content came from. `tool_output` (web page, email, file or other tool text) stores the write as external, untrusted; `user_said` and `inferred` store it as written by an agent. Advertised on the verbs and full surfaces only; a starter client that passes it is still honored. || `slug` (required) | string | Page slug || `content` (required) | string | Complete markdown content with YAML frontmatter. REPLACES the entire page; this is not a partial edit. Read the canonical page first with `get_page include_content:true` before modifying it. || `allow_empty` | boolean | Allow overwriting an existing non-empty page with empty/whitespace-only content (default: false). Without it, put_page rejects the empty overwrite — the empty-stdin failure class. |@@ -347,6 +349,7 @@ MEMORY VERB (v1): save one fact to durable agent memory — the protocol write v| `expected_revision` | string | Revision returned by the page read. Required when replacing an existing page unless force is true. Omit both for create-only writes. || `force` | boolean | Explicitly overwrite the current revision. Mutually exclusive with expected_revision; does not bypass authorization or the empty-content guard. || `request_id` | string | Optional caller-generated UUID for this write. Reuse the same UUID and original arguments to recover its outcome after a timeout; a different intent requires a new UUID. |+| `content_origin` | string (`user_said`, `tool_output`, `inferred`) | Where the content came from. `tool_output` (web page, email, file or other tool text) stores the write as external, untrusted; `user_said` and `inferred` store it as written by an agent. Advertised on the verbs and full surfaces only; a starter client that passes it is still honored. || `fact` (required) | string | The fact to remember, one claim per call. || `provenance` (required) | string | Where this fact came from (REQUIRED, free text, max 500 chars). Examples: "conversation 2026-06-12", "user said in chat", "import: meeting-notes.md". || `ttl` | string | Optional expiry: duration shorthand ("30d", "12h", "45m") or absolute ISO 8601 timestamp ("2026-07-12T00:00:00Z"). NOT ISO-8601 durations ("P30D" is rejected). Omit = never expires. |diff --git a/docs/protocol/MEMORY_VERBS_v1.md b/docs/protocol/MEMORY_VERBS_v1.mdindex 12edc922c9..f666fabf47 100644--- a/docs/protocol/MEMORY_VERBS_v1.md+++ b/docs/protocol/MEMORY_VERBS_v1.md@@ -292,6 +292,18 @@ text equal to the target is `status: duplicate` and changes nothing. On success`superseded_by` and its `## Facts` row is struck with `superseded by #N` inthe same publication. Every `superseded` response carries `superseded_fact_id`.+#### remember content_origin (additive)++`content_origin` (string: `user_said`, `tool_output` or `inferred`): where the+fact's text came from. `tool_output` (a web page, email, file or other tool's+text) stores the fact as `external_untrusted`; `user_said` and `inferred` store+it at the agent tier (`agent_written`), so `user_said` never confers owner+authority. Any other value is `invalid_params` listing the accepted values.+Optional, and safety never depends on it. Like `replaces`, it is advertised on+the verbs and full surfaces but left out of the starter surface's schema (to+keep that tool list inside its size budget); a starter client that passes it+is still honored. `put_page` and `capture` take the same parameter.+#### remember entity attribution fields (additive)Optional response fields; clients must ignore any they do not know.diff --git a/llms-full.txt b/llms-full.txtindex 8f3a634427..11fefe6e70 100644--- a/llms-full.txt+++ b/llms-full.txt@@ -8349,6 +8349,18 @@ text equal to the target is `status: duplicate` and changes nothing. On success`superseded_by` and its `## Facts` row is struck with `superseded by #N` inthe same publication. Every `superseded` response carries `superseded_fact_id`.+#### remember content_origin (additive)++`content_origin` (string: `user_said`, `tool_output` or `inferred`): where the+fact's text came from. `tool_output` (a web page, email, file or other tool's+text) stores the fact as `external_untrusted`; `user_said` and `inferred` store+it at the agent tier (`agent_written`), so `user_said` never confers owner+authority. Any other value is `invalid_params` listing the accepted values.+Optional, and safety never depends on it. Like `replaces`, it is advertised on+the verbs and full surfaces but left out of the starter surface's schema (to+keep that tool list inside its size budget); a starter client that passes it+is still honored. `put_page` and `capture` take the same parameter.+#### remember entity attribution fields (additive)Optional response fields; clients must ignore any they do not know.diff --git a/src/core/persistence/params.ts b/src/core/persistence/params.tsindex 4127259cbd..273b68b4f5 100644--- a/src/core/persistence/params.ts+++ b/src/core/persistence/params.ts@@ -52,6 +52,9 @@ export const CONTENT_ORIGIN_PARAM: ParamDef = {type: 'string',enum: ['user_said', 'tool_output', 'inferred'],description: 'Where the content came from: user_said, tool_output (web page, email, file or other tool text: stored as untrusted), inferred. Set it.',+ // Like remember.replaces: advertised on the verbs and full surfaces, accepted on every surface (dispatch validates+ // against the registry), off the starter schema so its list stays inside its size budget; safety never depends on it.+ fullSurfaceOnly: true,};/** Page mutation params plus `content_origin`, for verbs whose caller supplies the content (put_page, put_pages, capture, edit_page, remember). */export const AGENT_CONTENT_PARAMS: Record<string, ParamDef> = { ...PAGE_MUTATION_PARAMS, content_origin: CONTENT_ORIGIN_PARAM };diff --git a/test/trust-channel-writes.test.ts b/test/trust-channel-writes.test.tsindex 21e8e7b4c3..649444754a 100644--- a/test/trust-channel-writes.test.ts+++ b/test/trust-channel-writes.test.ts@@ -21,7 +21,9 @@ import { join } from 'node:path';import { PGLiteEngine } from '../src/core/pglite-engine.ts';import type { BrainEngine } from '../src/core/engine.ts';import type { OperationContext } from '../src/core/ops/contract.ts';-import { operationsByName } from '../src/core/operations.ts';+import { operations, operationsByName } from '../src/core/operations.ts';+import { dispatchToolCall } from '../src/mcp/dispatch.ts';+import { allowedOpNames, filterOpsForSurface } from '../src/mcp/surface.ts';import { mintLegacyToken } from '../src/core/token-mint.ts';import { registerLocalWriter, readLocalWriter } from '../src/core/persistence/identity.ts';import { disposePersistenceConsumer } from '../src/core/persistence/service.ts';@@ -150,6 +152,20 @@ describe('channel tiers on journaled writes', () => {}}), 60_000);+ test('content_origin is off the starter schema but a starter caller that passes it is honored (dispatch)', async () => withEnv({ GBRAIN_HOME: home }, async () => {+ const b = await brain(engines[0]!);+ for (const op of ['remember', 'put_page', 'capture']) {+ const advertised = (surface: 'verbs' | 'starter' | 'full') => filterOpsForSurface(operations, surface).find(o => o.name === op)?.params ?? {};+ expect({ op, starter: 'content_origin' in advertised('starter'), full: 'content_origin' in advertised('full') }).toEqual({ op, starter: false, full: true });+ }+ expect('content_origin' in filterOpsForSurface(operations, 'verbs').find(o => o.name === 'remember')!.params).toBe(true);+ const response = await dispatchToolCall(b.engine, 'put_page', { slug: 'notes/starter-tool-example', content: page('Starter', 'Pasted web text.'),+ content_origin: 'tool_output', request_id: randomUUID() }, { ...b.remote, allowedOps: allowedOpNames(operations, 'starter') });+ expect(response.isError).toBeFalsy();+ expect(JSON.stringify(response)).not.toContain('content_origin');+ expect((await pageRow(b, 'notes/starter-tool-example')).trust_tier).toBe('external_untrusted');+ }), 60_000);+test('an unknown content_origin is invalid_params listing the accepted values, on remember and put_page', async () => withEnv({ GBRAIN_HOME: home }, async () => {const b = await brain(engines[0]!);const failure = async (p: Promise<unknown>) => { try { await p; return null; } catch (e) { return e as { code?: string; message: string }; } };