Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

test: train census pins for the memory ops and v287-v289 (GBRA-286)

garrytan195ca0abe422
diff --git a/docs/TOOL_CATALOG.md b/docs/TOOL_CATALOG.md
index 02935ded53..1d644c5193 100644
--- a/docs/TOOL_CATALOG.md
+++ b/docs/TOOL_CATALOG.md
@@ -4,7 +4,7 @@
<!-- Regenerate: bun run scripts/generate-tool-catalog.ts -->
<!-- Freshness-guarded by scripts/check-tool-catalog-fresh.sh (bun run verify). -->
-Every non-localOnly operation on the MCP surface: 169 tools across 27 areas. **Starter** marks membership in the ~43-op `starter` surface (`src/mcp/surface.ts`); **Gate** names the config key that must be true before remote callers see/call the op (`gbrain config set <key> true`). What a given token actually sees is further filtered per request by scope, bound-client fence, publish gates, and the per-client surface — see `docs/operations/mcp-surface-runbook.md`. Area names are non-contractual groupings.
+Every non-localOnly operation on the MCP surface: 169 tools across 26 areas. **Starter** marks membership in the ~43-op `starter` surface (`src/mcp/surface.ts`); **Gate** names the config key that must be true before remote callers see/call the op (`gbrain config set <key> true`). What a given token actually sees is further filtered per request by scope, bound-client fence, publish gates, and the per-client surface — see `docs/operations/mcp-surface-runbook.md`. Area names are non-contractual groupings.
## admin
@@ -81,6 +81,8 @@ Every non-localOnly operation on the MCP surface: 169 tools across 27 areas. **S
| Tool | Description | Scope | Starter | Gate |
|---|---|---|---|---|
| `get_ingest_log` | Recent ingestion log entries: what was already imported, and when. | read | 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 | |
| `log_ingest` | Record one ingestion event (source type, reference, pages updated, summary) in the brain's ingest log. | write | | |
## insights
@@ -176,13 +178,6 @@ Every non-localOnly operation on the MCP surface: 169 tools across 27 areas. **S
| `ontology_get` | Life Chronicle: the current resolved per-entity ontology (dimension → value) at `asof` (default now), with provenance + confidence + validity. | read | | |
| `ontology_propose` | Life Chronicle: record one ontology observation (entity has dimension=value), sourced + confidence-weighted + bi-temporal. | write | | |
-## other
-
-| Tool | Description | Scope | Starter | Gate |
-|---|---|---|---|---|
-| `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 | |
-
## pages
| Tool | Description | Scope | Starter | Gate |
diff --git a/docs/architecture/KEY_FILES.md b/docs/architecture/KEY_FILES.md
index 9a3892bcc3..5d7b127688 100644
--- a/docs/architecture/KEY_FILES.md
+++ b/docs/architecture/KEY_FILES.md
@@ -9,8 +9,7 @@ Find a path's entry:
rg -n -F 'src/core/ops/pages.ts' docs/architecture/key-files/
```
-Ranges use each entry's first path; an entry can cover several
-files. Search when a path crosses subsystems.
+Ranges use each entry's first path. Search when a path crosses subsystems.
Edit the subsystem entry, not this page, when behavior changes.
Keep entries current-state: history belongs in `CHANGELOG.md` and Git.
Where a new storage method, migration, doctor check, command, route or sync
@@ -47,7 +46,7 @@ link it here; never raise the cap.
| [Core Minions (2/2)](key-files/core-minions-2.md) | `src/core/minions/queue.ts` through `src/core/minions/worker.ts` |
| [Core Persistence](key-files/core-persistence.md) | `src/core/persistence/` journal, coordinator, effects, managed sync |
| [Core Persistence (continued)](key-files/core-persistence-continued.md) | connectors, holds, receipts; [Git writer](key-files/core-persistence-git.md); [fence repair](key-files/core-fence-repair.md) |
-| [Persistence capacity](key-files/core-persistence-capacity.md) | write caps, true-up; [history](key-files/page-history.md) |
+| [Persistence capacity](key-files/core-persistence-capacity.md) | write caps, true-up; [history](key-files/page-history.md), [as_of](key-files/valid-time.md) |
| [Core Persistence (seams)](key-files/core-persistence-request-indexes.md) | `checkpoint-validation`, `fault-points`, `native-file-target`, `admission-retry`, `unbound-source` |
| [Core Persistence (managed facts)](key-files/core-persistence-facts.md) | `facts-maintenance.ts`, `facts-prepare.ts`, `derived-facts.ts`, `same-page-shadow.ts` |
| [Core Persistence (engine graduation)](key-files/core-persistence-graduation.md) | `engine-graduation*.ts`, `graduation-*.ts`, `commands/migrate-graduation.ts` |
diff --git a/docs/architecture/canonical-writers.tsv b/docs/architecture/canonical-writers.tsv
index a578c5cc50..c9c381dbc8 100644
--- a/docs/architecture/canonical-writers.tsv
+++ b/docs/architecture/canonical-writers.tsv
@@ -113,6 +113,7 @@ src/core/output/writer.ts 6 engine_guard Canonical table SQL trigger requires co
src/core/page-state/materialize.ts 1 coordinator Publication is transaction-scoped under admitted authority, source/page guards and revision checks.
src/core/page-state/projection-schema.ts 1 schema Schema installation and forward-reference DDL; coordinated activation quiesces canonical writers.
src/core/page-state/projections.ts 3 projection Derived indexing, retrieval telemetry, or source settings; canonical fields remain guarded by SQL triggers.
+src/core/page-state/versions.ts 2 projection GBRA-217: stamps only pages.version_history_gap_at (history metadata outside the canonical trigger's guarded fields) in the caller's versioning transaction, when an import reports a multi-commit gap or a prune drops snapshots; no canonical field or body is written.
src/core/page-state/image-seal.ts 1 projection The explicit image seal (#6803) sets only text_projection_revision on an importer-attested image page, under its page guard with a revision compare-and-set; no canonical field or body is written.
src/core/page-state/schema.ts 3 schema Schema installation and forward-reference DDL; coordinated activation quiesces canonical writers. The pages DO block constrains an empty pages table only; populated tables are finalized by revision-backfill-schema.ts.
src/core/page-state/revision-backfill-schema.ts 2 schema Migration-pass backfill of pages.knowledge_revision for rows written before the column (#5216): only NULL revisions are assigned, in committed id batches; canonical content is never written, and the revision trigger treats a NULL old revision without reading bodies.
diff --git a/docs/architecture/managed-mutating-writers.tsv b/docs/architecture/managed-mutating-writers.tsv
index d7988c78dd..c5e3692daa 100644
--- a/docs/architecture/managed-mutating-writers.tsv
+++ b/docs/architecture/managed-mutating-writers.tsv
@@ -72,6 +72,10 @@ op run_onboard no_canonical_write Runs remediation steps; each step keeps its ow
op run_skillopt no_canonical_write Skill files and proposals outside the brain database.
op loops_close coordinator open_loops state rows; the commitment fact is retired (expired, fence row struck) through the loop-fact-retirement coordinator mutation (#5869).
op loops_mute no_canonical_write Loop suppression rows.
+op ingest coordinator Source, entity and report pages through submitPageMutation and facts through the remember handler; the attempt journal is an op_checkpoints row.
+op ingest_undo coordinator Fence-row strikes and soft deletes through submitPageMutation (revision-bound); the attempt journal is an op_checkpoints row.
+op memory_conversation_mode no_canonical_write Returns the rule for the rest of the calling conversation; stores nothing.
+op set_memory_writeback no_canonical_write memory.agent_writeback config row plus an mcp_request_log audit row; no page content.
op mute_notice no_canonical_write Notice mute list in <GBRAIN_HOME>/notices/muted.json; no brain table or canonical file.
op questions_pin coordinator pinned_questions side-table rows; the question page publishes through coordinated put_page (trusted local callers only).
op questions_refresh coordinator Answer and evidence pointers in the pinned_questions side tables; question page sync through coordinated put_page (trusted local callers only).
diff --git a/plugin-variants/gbrain-coding/skills/ingest/SKILL.md b/plugin-variants/gbrain-coding/skills/ingest/SKILL.md
index 6f28cb33e1..fbba352990 100644
--- a/plugin-variants/gbrain-coding/skills/ingest/SKILL.md
+++ b/plugin-variants/gbrain-coding/skills/ingest/SKILL.md
@@ -5,6 +5,7 @@ triggers:
- "ingest this"
- "save this to brain"
- "process this meeting"
+ - "save this pasted document"
tools:
- ingest
- ingest_undo
@@ -22,7 +23,7 @@ writes_to:
- concepts/
- meetings/
- sources/
-when_to_use: "Use when the user asks: \"ingest this\", \"save this to brain\", \"process this meeting\"."
+when_to_use: "Use when the user asks: \"ingest this\", \"save this to brain\", \"process this meeting\", \"save this pasted document\"."
---
# Ingest Skill
diff --git a/plugin-variants/gbrain-daily/skills/ingest/SKILL.md b/plugin-variants/gbrain-daily/skills/ingest/SKILL.md
index 6f28cb33e1..fbba352990 100644
--- a/plugin-variants/gbrain-daily/skills/ingest/SKILL.md
+++ b/plugin-variants/gbrain-daily/skills/ingest/SKILL.md
@@ -5,6 +5,7 @@ triggers:
- "ingest this"
- "save this to brain"
- "process this meeting"
+ - "save this pasted document"
tools:
- ingest
- ingest_undo
@@ -22,7 +23,7 @@ writes_to:
- concepts/
- meetings/
- sources/
-when_to_use: "Use when the user asks: \"ingest this\", \"save this to brain\", \"process this meeting\"."
+when_to_use: "Use when the user asks: \"ingest this\", \"save this to brain\", \"process this meeting\", \"save this pasted document\"."
---
# Ingest Skill
diff --git a/plugin/skills/ingest/SKILL.md b/plugin/skills/ingest/SKILL.md
index 6f28cb33e1..fbba352990 100644
--- a/plugin/skills/ingest/SKILL.md
+++ b/plugin/skills/ingest/SKILL.md
@@ -5,6 +5,7 @@ triggers:
- "ingest this"
- "save this to brain"
- "process this meeting"
+ - "save this pasted document"
tools:
- ingest
- ingest_undo
@@ -22,7 +23,7 @@ writes_to:
- concepts/
- meetings/
- sources/
-when_to_use: "Use when the user asks: \"ingest this\", \"save this to brain\", \"process this meeting\"."
+when_to_use: "Use when the user asks: \"ingest this\", \"save this to brain\", \"process this meeting\", \"save this pasted document\"."
---
# Ingest Skill
diff --git a/skills/ingest/SKILL.md b/skills/ingest/SKILL.md
index b10e98ff4d..9c4f44f2aa 100644
--- a/skills/ingest/SKILL.md
+++ b/skills/ingest/SKILL.md
@@ -5,6 +5,7 @@ triggers:
- "ingest this"
- "save this to brain"
- "process this meeting"
+ - "save this pasted document"
tools:
- ingest
- ingest_undo
diff --git a/skills/skills.lock.json b/skills/skills.lock.json
index 63d0a7f042..0aeb29009e 100644
--- a/skills/skills.lock.json
+++ b/skills/skills.lock.json
@@ -93,7 +93,7 @@
"idea-ingest/SKILL.md": "863be3660ead12a45d3b86309d73df0ffda6c5db6ca69873cce1810680df79b4",
"idea-lineage/SKILL.md": "8cb36179dbf94abc17065613b8e773b1bb2b22670742aa77347b91ac885a05c5",
"idea-lineage/routing-eval.jsonl": "ee2e00704b9accb7dd58bb8f126a3bc04a2c40be499180fa505dbf6d5061cd41",
- "ingest/SKILL.md": "7d9520d39098e82ffc622c4b41227fb7bb670dfc08f7866d3721fdf9483b9ac0",
+ "ingest/SKILL.md": "40180c3fd6ed4b36dade9e13a79b867e6ddbaece5993d9fe3e94e30cda97bbc5",
"maintain/SKILL.md": "6faf40cb944a0deb7d032e41f44b66f05fe0ebe8178bd84d3cf05e2f766f6127",
"manifest.json": "357aa185d380f0a357cb15cd513317e290cbc5fcf5ca4e3860b0e829fdcbf1e4",
"mcp-access/SKILL.md": "1bc16338b89f476aa8c24ffec79c989fa60716793998af264d357f7886d2bc96",
diff --git a/src/core/eligibility/registry.ts b/src/core/eligibility/registry.ts
index 103d162b4d..f63b4091ff 100644
--- a/src/core/eligibility/registry.ts
+++ b/src/core/eligibility/registry.ts
@@ -51,6 +51,9 @@ export const OP_READ_TRUST: Readonly<Record<string, ReadTrustHandling>> = {
get_active_schema_pack: 'text_free', list_schema_packs: 'text_free', schema_stats: 'text_free', schema_lint: 'text_free',
schema_graph: 'text_free', schema_explain_type: 'text_free',
list_write_conflicts: 'text_free', get_brain_health: 'text_free',
+ // Held at the unlisted default (refused under a token floor) pending a trust-posture call: it returns config-derived
+ // settings and rule text, no stored memory text, so text_free would describe it but would admit floored connections.
+ get_memory_settings: 'labeled',
};
/** The class an op resolves to; an unlisted read op is held to the strictest (`labeled`) rule. */
diff --git a/src/core/hardened-git.ts b/src/core/hardened-git.ts
index 38881721d4..77d702653d 100644
--- a/src/core/hardened-git.ts
+++ b/src/core/hardened-git.ts
@@ -39,7 +39,7 @@ function operatorConfigSafeDirectories(): string[] {
const key = operatorConfigKey();
const known = freshOperatorConfig(key);
if (known) return known;
- const run = spawnSync('git', OPERATOR_CONFIG_ARGS, { ...operatorConfigOptions(), stdio: ['ignore', 'pipe', 'ignore'] });
+ const run = spawnSync('git', OPERATOR_CONFIG_ARGS, { ...operatorConfigOptions(), env: { ...gitChildEnv(), LC_ALL: 'C' }, stdio: ['ignore', 'pipe', 'ignore'] });
return rememberOperatorConfig(key, run.status === 0 ? run.stdout : null);
}
@@ -48,12 +48,12 @@ async function operatorConfigSafeDirectoriesAsync(): Promise<string[]> {
const key = operatorConfigKey();
const known = freshOperatorConfig(key);
if (known) return known;
- const stdout = await promisify(execFile)('git', OPERATOR_CONFIG_ARGS, { ...operatorConfigOptions(), encoding: 'buffer' }).then(run => run.stdout, () => null);
+ const stdout = await promisify(execFile)('git', OPERATOR_CONFIG_ARGS, { ...operatorConfigOptions(), env: { ...gitChildEnv(), LC_ALL: 'C' }, encoding: 'buffer' }).then(run => run.stdout, () => null);
return rememberOperatorConfig(key, stdout);
}
const OPERATOR_CONFIG_ARGS = ['config', '--includes', '--show-scope', '-z', '--get-all', 'safe.directory'];
-const operatorConfigOptions = () => ({ cwd: '/', env: { ...gitChildEnv(), LC_ALL: 'C' }, timeout: 10_000, maxBuffer: 1024 * 1024, killSignal: 'SIGKILL' as const });
+const operatorConfigOptions = () => ({ cwd: '/', timeout: 10_000, maxBuffer: 1024 * 1024, killSignal: 'SIGKILL' as const });
const operatorConfigKey = () => ['HOME', 'XDG_CONFIG_HOME', 'GIT_CONFIG_GLOBAL', 'GIT_CONFIG_SYSTEM', 'GIT_CONFIG_NOSYSTEM', 'PATH'].map(name => process.env[name] ?? '').join('\0');
const freshOperatorConfig = (key: string) => operatorConfig?.key === key && Date.now() - operatorConfig.at < OPERATOR_CONFIG_TTL_MS ? operatorConfig.values : null;
@@ -73,11 +73,7 @@ export function __resetOperatorGitConfigForTests(): void { operatorConfig = null
* (system, global, then environment, as Git orders them), carried as environment config (#7584). They relax only Git's
* ownership check for a repository owned by another user, which the operator allowed for their own `git` too.
*/
-export function hardenedGitEnvironment(): NodeJS.ProcessEnv {
- return hardenedEnvironmentWith(operatorConfigSafeDirectories());
-}
-
-function hardenedEnvironmentWith(operatorSafeDirectories: string[]): NodeJS.ProcessEnv {
+export function hardenedGitEnvironment(operatorSafeDirectories: string[] = operatorConfigSafeDirectories()): NodeJS.ProcessEnv {
const env = Object.fromEntries(Object.entries(process.env).filter(([key]) => !key.startsWith('GIT_')));
return { ...env, GIT_CONFIG_NOSYSTEM: '1', GIT_CONFIG_GLOBAL: '/dev/null', GIT_OPTIONAL_LOCKS: '0',
GIT_NO_LAZY_FETCH: '1', GIT_NO_REPLACE_OBJECTS: '1', GIT_TERMINAL_PROMPT: '0', GIT_LFS_SKIP_SMUDGE: '1', LC_ALL: 'C',
@@ -185,7 +181,7 @@ export function hardenedGitStream(root: string, args: string[],
let onChunk = opts.onChunk;
return operatorConfigSafeDirectoriesAsync().then(operator => new Promise<HardenedGitStreamResult>((accept, reject) => {
const child = spawn('git', [...HARDENED_GIT_ARGS, '-C', root, ...args],
- { env: hardenedEnvironmentWith(operator), stdio: [stdin === undefined ? 'ignore' : 'pipe', 'pipe', 'ignore'] });
+ { env: hardenedGitEnvironment(operator), stdio: [stdin === undefined ? 'ignore' : 'pipe', 'pipe', 'ignore'] });
let bytes = 0;
let last = -1;
let stopped: 'timeout' | 'too_large' | undefined;
diff --git a/src/core/operation-load.ts b/src/core/operation-load.ts
index eb862e74e0..7f8efe15dc 100644
--- a/src/core/operation-load.ts
+++ b/src/core/operation-load.ts
@@ -74,8 +74,8 @@ const OP_AREAS: Record<string, string> = {
sources_status: 'sources', sources_resolve_path: 'sources',
// sync (localOnly)
sync_brain: 'sync',
- // ingest log
- log_ingest: 'ingest', get_ingest_log: 'ingest',
+ // ingest (the log and document ingest)
+ log_ingest: 'ingest', get_ingest_log: 'ingest', ingest: 'ingest', ingest_undo: 'ingest',
get_usage: 'admin',
// files (localOnly)
file_list: 'files', file_upload: 'files', file_url: 'files',
diff --git a/src/core/operation-manifest.generated.ts b/src/core/operation-manifest.generated.ts
index a75feefbc7..91ffd2cdcf 100644
--- a/src/core/operation-manifest.generated.ts
+++ b/src/core/operation-manifest.generated.ts
@@ -5699,11 +5699,13 @@ export const OPERATION_MANIFEST: OperationMeta[] = [
"outputRedaction": "retrieval",
"writeInference": "explicit_llm",
"mutating": true,
+ "idempotent": false,
"scope": "write",
"cliHints": {
"name": "ingest",
"hidden": true
- }
+ },
+ "area": "ingest"
},
{
"name": "ingest_undo",
@@ -5726,11 +5728,13 @@ export const OPERATION_MANIFEST: OperationMeta[] = [
"outputRedaction": "no_stored_text",
"writeInference": "none",
"mutating": true,
+ "idempotent": true,
"scope": "write",
"cliHints": {
"name": "ingest-undo",
"hidden": true
- }
+ },
+ "area": "ingest"
},
{
"name": "entity_identity_link",
@@ -6434,6 +6438,7 @@ export const OPERATION_MANIFEST: OperationMeta[] = [
{
"name": "get_memory_settings",
"mutating": false,
+ "idempotent": true,
"outputRedaction": "no_stored_text",
"description": "Memory writeback settings: the mode agents follow, the exact rule text, every mode's rule, background capture state, and whether you may change it.",
"params": {},
@@ -6472,6 +6477,8 @@ export const OPERATION_MANIFEST: OperationMeta[] = [
},
{
"name": "memory_conversation_mode",
+ "mutating": true,
+ "idempotent": true,
"outputRedaction": "no_stored_text",
"description": "Use when the user says \"save everything from here\" (all) or \"stop saving\" (off): returns this conversation's memory rule. Stores nothing.",
"params": {
diff --git a/src/core/ops/ingest.ts b/src/core/ops/ingest.ts
index 40ee8b44db..2072b36d36 100644
--- a/src/core/ops/ingest.ts
+++ b/src/core/ops/ingest.ts
@@ -701,6 +701,7 @@ const ingest: Operation = {
outputRedaction: 'retrieval',
writeInference: 'explicit_llm',
mutating: true,
+ idempotent: false,
scope: 'write',
handler: async (ctx, p) => runIngest(ctx, p),
cliHints: { name: 'ingest', hidden: true },
@@ -717,6 +718,7 @@ const ingest_undo: Operation = {
outputRedaction: 'no_stored_text',
writeInference: 'none',
mutating: true,
+ idempotent: true,
scope: 'write',
handler: async (ctx, p) => runUndo(ctx, p),
cliHints: { name: 'ingest-undo', hidden: true },
diff --git a/src/core/ops/memory-settings.ts b/src/core/ops/memory-settings.ts
index e0cea82323..4a00b2ed30 100644
--- a/src/core/ops/memory-settings.ts
+++ b/src/core/ops/memory-settings.ts
@@ -85,6 +85,7 @@ function degradedNote(res: AgentWritebackResolution): string | undefined {
const get_memory_settings: Operation = {
name: 'get_memory_settings',
mutating: false,
+ idempotent: true,
outputRedaction: 'no_stored_text',
description: 'Memory writeback settings: the mode agents follow, the exact rule text, every mode\'s rule, background capture state, and whether you may change it.',
params: {},
@@ -199,6 +200,8 @@ const set_memory_writeback: Operation = {
const memory_conversation_mode: Operation = {
name: 'memory_conversation_mode',
+ mutating: true,
+ idempotent: true,
outputRedaction: 'no_stored_text',
description: 'Use when the user says "save everything from here" (all) or "stop saving" (off): returns this conversation\'s memory rule. Stores nothing.',
params: {
diff --git a/test/callable-predicate.test.ts b/test/callable-predicate.test.ts
index e7f4856002..d502f6b7e8 100644
--- a/test/callable-predicate.test.ts
+++ b/test/callable-predicate.test.ts
@@ -12,11 +12,13 @@ import { isCallable, publishGatesFromDisabled, type CallableContext } from '../s
import { filterOpsForSurface } from '../src/mcp/surface.ts';
import { operationScopesAllowed } from '../src/core/scope.ts';
import { dispatchToolCall } from '../src/mcp/dispatch.ts';
+import { PUBLISH_GATE_KEYS } from '../src/mcp/publish-gates.ts';
import type { BrainEngine } from '../src/core/engine.ts';
const SURFACES = ['verbs', 'starter', 'full'] as const;
const SCOPE_SETS: readonly string[][] = [['read'], ['read', 'write'], ['admin'], ['agent'], ['admin', 'skills_member_self']];
-const GATE_STATES: Record<string, boolean>[] = [{}, { 'mcp.publish_skills': true, 'mcp.publish_advisor': true }];
+const ALL_GATES_ON: Record<string, boolean> = Object.fromEntries([...PUBLISH_GATE_KEYS].map(key => [key, true]));
+const GATE_STATES: Record<string, boolean>[] = [{}, ALL_GATES_ON];
/** The pre-A2 HTTP list filter minus F5's owner-only (`cliOnly`) ops, kept here as the independent oracle. */
function legacyHttpList(surface: typeof SURFACES[number], scopes: string[], gates: Record<string, boolean>): string[] {
@@ -72,7 +74,7 @@ describe('dispatch refuses what the list hides on the dispatch-enforced axes', (
test(`${transport} ${surface}: unknown_tool ⇔ not callable on surface/locality`, async () => {
const allowed = surface === 'full' ? undefined : new Set(filterOpsForSurface(operations, surface).map(o => o.name));
const allScopes = ['admin', 'agent', ...new Set(operations.flatMap(o => o.requiredScopes ?? []))];
- const ctx: CallableContext = { transport, surface, scopes: allScopes, publishGates: { 'mcp.publish_skills': true, 'mcp.publish_advisor': true } };
+ const ctx: CallableContext = { transport, surface, scopes: allScopes, publishGates: ALL_GATES_ON };
const mismatches: string[] = [];
for (const op of operations) {
const hidden = !isCallable(op, ctx);
diff --git a/test/fixtures/fold-hook-noop-6712.json b/test/fixtures/fold-hook-noop-6712.json
index 7b3709b41e..ae1061dce9 100644
--- a/test/fixtures/fold-hook-noop-6712.json
+++ b/test/fixtures/fold-hook-noop-6712.json
@@ -52,6 +52,7 @@
"RELEASE SAVEPOINT gbrain_nested_1",
"WITH chosen AS ( SELECT p.* FROM pages p WHERE p.slug=$1 AND p.source_id=$2 ORDER BY (p.slug=$1) DESC, (p.source_id=$3) DESC, p.source_id ASC LIMIT 1 ) SELECT p.*, (SELECT s.incarnation FROM sources s WHERE s.id=p.source_id) AS source_incarnation, COALESCE((SELECT jsonb_agg(t.tag ORDER BY t.tag) FROM tags t WHERE t.page_id=p.id), '[]'::jsonb) AS snapshot_tags, wd.snapshot_withdrawals, wd.snapshot_global_purges, CASE WHEN wd.snapshot_withdrawals <> '[]'::jsonb OR (wd.snapshot_global_purges->>'count')::int > 0 THEN (SELECT string_agg(regexp_replace(lower(line), '[[:space:]]+', ' ', 'g'), chr(10) ORDER BY ord) FROM unnest(string_to_array(p.compiled_truth,chr(10))) WITH ORDINALITY AS lines(line,ord)) END AS fingerprint_body, CASE WHEN wd.snapshot_withdrawals <> '[]'::jsonb OR (wd.snapshot_global_purges->>'count')::int > 0 THEN (SELECT string_agg(regexp_replace(lower(line), '[[:space:]]+', ' ', 'g'), chr(10) ORDER BY ord) FROM unnest(string_to_array(p.timeline,chr(10))) WITH ORDINALITY AS lines(line,ord)) END AS fingerprint_timeline FROM chosen p CROSS JOIN LATERAL (SELECT COALESCE((SELECT jsonb_agg(jsonb_build_object('visibility',w.visibility,'fact_hash',w.fact_hash,'withdrawn_at',w.withdrawn_at) ORDER BY w.visibility,w.fact_hash) FROM (SELECT visibility,fact_hash,min(withdrawn_at) AS withdrawn_at FROM fact_withdrawals WHERE source_id=p.source_id AND (subject='*' OR subject=p.slug) GROUP BY visibility,fact_hash) w), '[]'::jsonb) || COALESCE((SELECT jsonb_agg(jsonb_build_object('visibility',x.visibility,'fact_hash',x.fact_hash,'withdrawn_at',x.purged_at,'purged',true) ORDER BY x.visibility,x.fact_hash) FROM (SELECT visibility,fact_hash,min(purged_at) AS purged_at FROM fact_purges WHERE source_id=p.source_id AND subject=p.slug GROUP BY visibility,fact_hash) x), '[]'::jsonb) AS snapshot_withdrawals, (SELECT jsonb_build_object('count',count(*),'latest',max(g.purged_at)) FROM fact_purges g WHERE g.source_id=p.source_id AND g.subject='*' ) AS snapshot_global_purges) wd",
"UPDATE pages SET chunker_version=$5, text_projection_revision=CASE WHEN knowledge_revision=$4::uuid THEN knowledge_revision ELSE text_projection_revision END, search_vector=CASE WHEN knowledge_revision=$4::uuid THEN setweight(to_tsvector('english',gbrain_fts_input(COALESCE(title,''))),'A') || setweight(to_tsvector('english',gbrain_fts_input(left($3::text,65536))),'C') ELSE search_vector END WHERE source_id=$1 AND slug=$2 RETURNING id",
+ "SELECT frontmatter, compiled_truth, timeline, body_storage, content_hash FROM pages WHERE source_id = $1 AND slug = $2 AND deleted_at IS NULL",
"SELECT set_config('gbrain.write_sources',$1,true),set_config('gbrain.write_request',$2,true),set_config('gbrain.write_principal_kind',$3,true),set_config('gbrain.write_principal_id',$4,true),set_config('gbrain.write_trust_tier',$5,true),set_config('gbrain.write_origin',$6,true),set_config('gbrain.git_protocol',$7,true)",
"SELECT h.local_path FROM persistence_host_bindings h JOIN persistence_worktrees w ON w.id=h.worktree_id AND w.owner_host_id=h.host_id WHERE w.id=$1::uuid",
"SELECT value FROM config WHERE key = $1",
@@ -87,7 +88,7 @@
"SELECT c.chunk_index, c.embedding_input_hash, p.contextual_retrieval_mode, c.embedding_image IS NULL AND c.embedding_multimodal IS NULL AND c.embedded_text_hash = md5(c.chunk_text) AS text_only, c.embedding IS NULL AND c.embedding_image IS NULL AND c.embedding_multimodal IS NULL AND c.embedding_input_hash IS NULL AND c.embedded_text_hash IS NULL AS unembedded FROM content_chunks c JOIN pages p ON p.id = c.page_id WHERE p.source_id = $1 AND p.slug = $2",
"SELECT key, value FROM config WHERE key IN ('search_embedding_column', 'embedding_columns')",
"SELECT cc.id, cc.page_id, cc.chunk_index, cc.chunk_text, cc.chunk_source, cc.model, cc.token_count, cc.embedded_at, cc.language, cc.symbol_name, cc.symbol_type, cc.start_line, cc.end_line, cc.parent_symbol_path, cc.doc_comment, cc.symbol_name_qualified, cc.modality, cc.projected_byte_start, cc.projected_byte_end, (cc.\"embedding\" IS NULL) AS embedding_is_null , cc.\"embedding\" AS embedding FROM content_chunks cc JOIN pages p ON p.id = cc.page_id LEFT JOIN page_body_manifest m ON cc.occurrence_id IS NOT NULL AND m.page_id = cc.page_id AND m.occurrence_id = cc.occurrence_id AND m.staging_id IS NULL AND m.gen_from <= p.body_generation AND (m.gen_to IS NULL OR m.gen_to > p.body_generation) WHERE p.slug = $1 AND p.source_id = $2 AND ((p.text_projection_revision = p.knowledge_revision) IS TRUE AND (cc.body_generation IS NULL OR cc.body_generation <= p.body_generation)) AND p.chunker_version >= 4 ORDER BY m.byte_start, cc.local_ordinal, cc.chunk_index",
- "INSERT INTO page_versions (page_id,compiled_truth,frontmatter,knowledge_revision,timeline,title,type,tags,is_deleted,source_path) VALUES ($1,$2,$3::text::jsonb,$4::uuid,$5,$6,$7,$8::text::jsonb,$9,$10) RETURNING *",
+ "INSERT INTO page_versions (page_id,compiled_truth,frontmatter,knowledge_revision,timeline,title,type,tags,is_deleted,source_path,change_reason) VALUES ($1,$2,$3::text::jsonb,$4::uuid,$5,$6,$7,$8::text::jsonb,$9,$10,$11) RETURNING *",
"SELECT id, slug, source_path, deleted_at FROM pages WHERE source_id=$1 AND slug=$2",
"SELECT local_path, config->>'slug_root_mode' AS mode FROM sources WHERE id=$1",
"INSERT INTO pages (source_id, slug, type, page_kind, title, compiled_truth, timeline, frontmatter, content_hash, updated_at, effective_date, effective_date_source, import_filename, chunker_version, source_path, source_kind, source_uri, ingested_via, ingested_at, contextual_retrieval_mode, corpus_generation) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, now(), $10, $11, $12, $13::smallint, $14, $15, $16, $17, $18, $19, $20) ON CONFLICT (source_id, slug) DO UPDATE SET contextual_retrieval_mode = EXCLUDED.contextual_retrieval_mode, corpus_generation = EXCLUDED.corpus_generation, type = EXCLUDED.type, page_kind = EXCLUDED.page_kind, title = EXCLUDED.title, compiled_truth = EXCLUDED.compiled_truth, timeline = EXCLUDED.timeline, frontmatter = EXCLUDED.frontmatter, content_hash = EXCLUDED.content_hash, updated_at = now(), deleted_at = NULL, effective_date = COALESCE(EXCLUDED.effective_date, pages.effective_date), effective_date_source = COALESCE(EXCLUDED.effective_date_source, pages.effective_date_source), import_filename = COALESCE(EXCLUDED.import_filename, pages.import_filename), chunker_version = CASE WHEN pages.compiled_truth IS NOT DISTINCT FROM EXCLUDED.compiled_truth AND pages.timeline IS NOT DISTINCT FROM EXCLUDED.timeline THEN pages.chunker_version WHEN pages.chunker_version < 0 OR (CASE WHEN pages.body_storage = 'segmented' THEN pages.body_flags->>'has_protected' IS DISTINCT FROM 'false' ELSE (COALESCE(pages.compiled_truth, '') ~ '<!--- gbrain:(facts|takes):(begin|end) -->' OR COALESCE(pages.timeline, '') ~ '<!--- gbrain:(facts|takes):(begin|end) -->') END) OR COALESCE(EXCLUDED.compiled_truth, '') ~ '<!--- gbrain:(facts|takes):(begin|end) -->' OR COALESCE(EXCLUDED.timeline, '') ~ '<!--- gbrain:(facts|takes):(begin|end) -->' THEN -1 ELSE LEAST(COALESCE(pages.chunker_version, 0), 3) END, source_path = COALESCE(EXCLUDED.source_path, pages.source_path), database_only_reason = CASE WHEN EXCLUDED.source_path IS NOT NULL AND pages.database_only_reason IN ('detached', 'origin_twin', 'mirror_read_only') THEN NULL ELSE pages.database_only_reason END, source_kind = COALESCE(EXCLUDED.source_kind, pages.source_kind), source_uri = COALESCE(EXCLUDED.source_uri, pages.source_uri), ingested_via = COALESCE(EXCLUDED.ingested_via, pages.ingested_via), ingested_at = COALESCE(EXCLUDED.ingested_at, pages.ingested_at) RETURNING knowledge_revision, text_projection_revision, id, source_id, slug, type, title, compiled_truth, timeline, frontmatter, content_hash, created_at, updated_at, effective_date, effective_date_source, import_filename, source_kind, source_uri, ingested_via, ingested_at",
@@ -181,6 +182,7 @@
"SELECT from_page_id, to_page_id, link_type FROM links WHERE (origin_page_id = $1 OR (origin_page_id IS NULL AND from_page_id = $1)) AND link_type = ANY($2::text[]) UNION SELECT from_page_id, to_page_id, link_type FROM link_transitions WHERE origin_page_id = $1 UNION SELECT from_page_id, to_page_id, link_type FROM link_relationships WHERE from_page_id = $1 AND scope = 'all'",
"WITH chosen AS ( SELECT p.* FROM pages p WHERE p.slug=$1 AND p.source_id=$2 ORDER BY (p.slug=$1) DESC, (p.source_id=$3) DESC, p.source_id ASC LIMIT 1 ) SELECT p.*, (SELECT s.incarnation FROM sources s WHERE s.id=p.source_id) AS source_incarnation, COALESCE((SELECT jsonb_agg(t.tag ORDER BY t.tag) FROM tags t WHERE t.page_id=p.id), '[]'::jsonb) AS snapshot_tags, wd.snapshot_withdrawals, wd.snapshot_global_purges, CASE WHEN wd.snapshot_withdrawals <> '[]'::jsonb OR (wd.snapshot_global_purges->>'count')::int > 0 THEN (SELECT string_agg(regexp_replace(lower(line), '[[:space:]]+', ' ', 'g'), chr(10) ORDER BY ord) FROM unnest(string_to_array(p.compiled_truth,chr(10))) WITH ORDINALITY AS lines(line,ord)) END AS fingerprint_body, CASE WHEN wd.snapshot_withdrawals <> '[]'::jsonb OR (wd.snapshot_global_purges->>'count')::int > 0 THEN (SELECT string_agg(regexp_replace(lower(line), '[[:space:]]+', ' ', 'g'), chr(10) ORDER BY ord) FROM unnest(string_to_array(p.timeline,chr(10))) WITH ORDINALITY AS lines(line,ord)) END AS fingerprint_timeline FROM chosen p CROSS JOIN LATERAL (SELECT COALESCE((SELECT jsonb_agg(jsonb_build_object('visibility',w.visibility,'fact_hash',w.fact_hash,'withdrawn_at',w.withdrawn_at) ORDER BY w.visibility,w.fact_hash) FROM (SELECT visibility,fact_hash,min(withdrawn_at) AS withdrawn_at FROM fact_withdrawals WHERE source_id=p.source_id AND (subject='*' OR subject=p.slug) GROUP BY visibility,fact_hash) w), '[]'::jsonb) || COALESCE((SELECT jsonb_agg(jsonb_build_object('visibility',x.visibility,'fact_hash',x.fact_hash,'withdrawn_at',x.purged_at,'purged',true) ORDER BY x.visibility,x.fact_hash) FROM (SELECT visibility,fact_hash,min(purged_at) AS purged_at FROM fact_purges WHERE source_id=p.source_id AND subject=p.slug GROUP BY visibility,fact_hash) x), '[]'::jsonb) AS snapshot_withdrawals, (SELECT jsonb_build_object('count',count(*),'latest',max(g.pur",
"UPDATE pages SET chunker_version=$5, text_projection_revision=CASE WHEN knowledge_revision=$4::uuid THEN knowledge_revision ELSE text_projection_revision END, search_vector=CASE WHEN knowledge_revision=$4::uuid THEN setweight(to_tsvector('english',gbrain_fts_input(COALESCE(title,''))),'A') || setweight(to_tsvector('english',gbrain_fts_input(left($3::text,65536))),'C') ELSE search_vector END WHERE source_id=$1 AND slug=$2 RETURNING id",
+ "SELECT frontmatter, compiled_truth, timeline, body_storage, content_hash FROM pages WHERE source_id = $1 AND slug = $2 AND deleted_at IS NULL",
"SELECT value FROM config WHERE key = $1",
"SELECT 1 FROM chronicle_page_state WHERE source_id=$1 AND page_id=$2 AND state='extracted' AND cardinality(event_hashes) > 0 LIMIT 1",
"INSERT INTO persistence_effects (request_id,kind,revision,data,source_id,source_incarnation,worktree_id) SELECT $1::uuid,t.e->>'kind',$2::uuid,t.e->'data',$3,$4::uuid,$5::uuid FROM jsonb_array_elements($6::text::jsonb) WITH ORDINALITY AS t(e,n) WHERE NOT (COALESCE((t.e->>'gated')::boolean,false) AND EXISTS (SELECT 1 FROM config WHERE key IN ('auto_link',$7) AND lower(btrim(value,E' \\t\\r\\n')) IN ('false','0','no','off'))) ORDER BY t.n ON CONFLICT(request_id,kind) DO NOTHING RETURNING kind",
@@ -218,7 +220,7 @@
"SELECT key, value FROM config WHERE key IN ('search_embedding_column', 'embedding_columns')",
"-- chunk-visibility-ok: whether any chunk row of a segmented body exists, no row is returned SELECT has_table_privilege('page_body_manifest', 'SELECT') AS readable, NOT has_table_privilege('page_body_manifest', 'SELECT') AND (EXISTS (SELECT 1 FROM content_chunks WHERE body_generation IS NOT NULL) OR EXISTS (SELECT 1 FROM content_chunks WHERE occurrence_id IS NOT NULL)) AS segmented",
"SELECT cc.id, cc.page_id, cc.chunk_index, cc.chunk_text, cc.chunk_source, cc.model, cc.token_count, cc.embedded_at, cc.language, cc.symbol_name, cc.symbol_type, cc.start_line, cc.end_line, cc.parent_symbol_path, cc.doc_comment, cc.symbol_name_qualified, cc.modality, cc.projected_byte_start, cc.projected_byte_end, (cc.\"embedding\" IS NULL) AS embedding_is_null , cc.\"embedding\" AS embedding FROM content_chunks cc JOIN pages p ON p.id = cc.page_id LEFT JOIN page_body_manifest m ON cc.occurrence_id IS NOT NULL AND m.page_id = cc.page_id AND m.occurrence_id = cc.occurrence_id AND m.staging_id IS NULL AND m.gen_from <= p.body_generation AND (m.gen_to IS NULL OR m.gen_to > p.body_generation) WHERE p.slug = $1 AND p.source_id = $2 AND ((p.text_projection_revision = p.knowledge_revision) IS TRUE AND (cc.body_generation IS NULL OR cc.body_generation <= p.body_generation)) AND p.chunker_version >= 4 ORDER BY m.byte_start, cc.local_ordinal, cc.chunk_index",
- "INSERT INTO page_versions (page_id,compiled_truth,frontmatter,knowledge_revision,timeline,title,type,tags,is_deleted,source_path) VALUES ($1,$2,$3::text::jsonb,$4::uuid,$5,$6,$7,$8::text::jsonb,$9,$10) RETURNING *",
+ "INSERT INTO page_versions (page_id,compiled_truth,frontmatter,knowledge_revision,timeline,title,type,tags,is_deleted,source_path,change_reason) VALUES ($1,$2,$3::text::jsonb,$4::uuid,$5,$6,$7,$8::text::jsonb,$9,$10,$11) RETURNING *",
"DELETE FROM content_chunks WHERE page_id = (SELECT id FROM pages WHERE slug = $1 AND source_id = $2)",
"DELETE FROM page_aliases WHERE source_id = $1 AND slug = $2 AND origin IN ('declared','subject')",
"SELECT id, slug, source_path, deleted_at FROM pages WHERE source_id=$1 AND slug=$2",
diff --git a/test/fixtures/goldens/cli/tools-json.json b/test/fixtures/goldens/cli/tools-json.json
index c15966da32..3db29a3bd0 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": 278507,
- "stdoutSha256": "8b48348d77364b33846c7b34c36f5e38a0327347552eb2373d26ce4e8015ca33",
+ "stdoutBytes": 278503,
+ "stdoutSha256": "a330c0d3f62d08f5106cf86b509c134c80da998f1e34b9b089cc7d5ac5a3a195",
"toolNames": [
"remember",
"entity",
@@ -6645,7 +6645,7 @@
},
{
"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,
+ "idempotent": true,
"local_only": false,
"mutating": true,
"name": "ingest_undo",
@@ -7418,7 +7418,7 @@
},
{
"description": "Memory writeback settings: the mode agents follow, the exact rule text, every mode's rule, background capture state, and whether you may change it.",
- "idempotent": false,
+ "idempotent": true,
"local_only": false,
"mutating": false,
"name": "get_memory_settings",
@@ -7468,9 +7468,9 @@
},
{
"description": "Use when the user says \"save everything from here\" (all) or \"stop saving\" (off): returns this conversation's memory rule. Stores nothing.",
- "idempotent": false,
+ "idempotent": true,
"local_only": false,
- "mutating": false,
+ "mutating": true,
"name": "memory_conversation_mode",
"parameters": {
"mode": "string"
diff --git a/test/fixtures/goldens/doctor/json-postgres-fresh.json b/test/fixtures/goldens/doctor/json-postgres-fresh.json
index 8436154ea1..a55223504f 100644
--- a/test/fixtures/goldens/doctor/json-postgres-fresh.json
+++ b/test/fixtures/goldens/doctor/json-postgres-fresh.json
@@ -1111,7 +1111,7 @@
{
"category": "meta",
"elapsed_ms": "<volatile>",
- "message": "All 171 table(s) the applied migrations create exist.",
+ "message": "All 172 table(s) the applied migrations create exist.",
"name": "schema_missing_tables",
"status": "ok"
},
diff --git a/test/fixtures/goldens/pglite-upgrade-replay/catalog-after-boot.json b/test/fixtures/goldens/pglite-upgrade-replay/catalog-after-boot.json
index 820cb66e92..a09e539d83 100644
--- a/test/fixtures/goldens/pglite-upgrade-replay/catalog-after-boot.json
+++ b/test/fixtures/goldens/pglite-upgrade-replay/catalog-after-boot.json
@@ -416,6 +416,8 @@
"raw_data.raw_data_page_id_fkey": "f FOREIGN KEY (page_id) REFERENCES pages(id) ON DELETE CASCADE",
"raw_data.raw_data_page_id_source_key": "u UNIQUE (page_id, source)",
"raw_data.raw_data_pkey": "p PRIMARY KEY (id)",
+ "reason_purge_tombstones.reason_purge_tombstones_pkey": "p PRIMARY KEY (source_id, commit_sha, path)",
+ "reason_purge_tombstones.reason_purge_tombstones_source_id_fkey": "f FOREIGN KEY (source_id) REFERENCES sources(id) ON DELETE CASCADE",
"retrieval_event_links.retrieval_event_links_event_id_fkey": "f FOREIGN KEY (event_id) REFERENCES retrieval_events(id) ON DELETE CASCADE",
"retrieval_event_links.retrieval_event_links_pkey": "p PRIMARY KEY (event_id, source_id, edge_key, to_slug)",
"retrieval_event_pages.retrieval_event_pages_event_id_fkey": "f FOREIGN KEY (event_id) REFERENCES retrieval_events(id) ON DELETE CASCADE",
@@ -1008,6 +1010,9 @@
"raw_data": [
"<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
],
+ "reason_purge_tombstones": [
+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
+ ],
"retrieval_event_links": [
"<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
],
@@ -1544,6 +1549,7 @@
"question_evidence_question_idx": "CREATE INDEX question_evidence_question_idx ON public.question_evidence USING btree (question_id, answer_revision)",
"raw_data_page_id_source_key": "CREATE UNIQUE INDEX raw_data_page_id_source_key ON public.raw_data USING btree (page_id, source)",
"raw_data_pkey": "CREATE UNIQUE INDEX raw_data_pkey ON public.raw_data USING btree (id)",
+ "reason_purge_tombstones_pkey": "CREATE UNIQUE INDEX reason_purge_tombstones_pkey ON public.reason_purge_tombstones USING btree (source_id, commit_sha, path)",
"retrieval_event_links_pkey": "CREATE UNIQUE INDEX retrieval_event_links_pkey ON public.retrieval_event_links USING btree (event_id, source_id, edge_key, to_slug)",
"retrieval_event_pages_pkey": "CREATE UNIQUE INDEX retrieval_event_pages_pkey ON public.retrieval_event_pages USING btree (event_id, source_id, slug)",
"retrieval_events_pkey": "CREATE UNIQUE INDEX retrieval_events_pkey ON public.retrieval_events USING btree (id)",
@@ -3410,7 +3416,9 @@
"21 body_storage text/text NOT NULL DEFAULT 'inline'::text",
"22 body_generation bigint/int8 NULL",
"23 body_bytes bigint/int8 NULL",
- "24 content_hash text/text NULL"
+ "24 content_hash text/text NULL",
+ "25 change_reason text/text NULL",
+ "26 successor_pruned boolean/bool NULL"
],
"flags": "relkind=r rls=false force_rls=false"
},
@@ -3491,7 +3499,8 @@
"53 links_extract_failure jsonb/jsonb NULL",
"54 withheld_source_path text/text NULL",
"55 page_readers ARRAY/_text NULL",
- "56 folder_rule_ids ARRAY/_text NULL"
+ "56 folder_rule_ids ARRAY/_text NULL",
+ "57 version_history_gap_at timestamp with time zone/timestamptz NULL"
],
"flags": "relkind=r rls=false force_rls=false"
},
@@ -3832,6 +3841,15 @@
],
"flags": "relkind=r rls=false force_rls=false"
},
+ "reason_purge_tombstones": {
+ "columns": [
+ "1 source_id text/text NOT NULL",
+ "2 commit_sha text/text NOT NULL",
+ "3 path text/text NOT NULL",
+ "4 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ ],
+ "flags": "relkind=r rls=true force_rls=false"
+ },
"retrieval_event_links": {
"columns": [
"1 event_id text/text NOT NULL",
diff --git a/test/fold-hook-noop-6712.test.ts b/test/fold-hook-noop-6712.test.ts
index 70ca112db7..b427968124 100644
--- a/test/fold-hook-noop-6712.test.ts
+++ b/test/fold-hook-noop-6712.test.ts
@@ -17,6 +17,9 @@
* hook runs in, which no pipelined call reaches.
*
* PGLite here; Postgres through test/e2e/fold-hook-noop-6712-postgres.test.ts.
+ * Pinned additions since that commit (neither is hook work): GBRA-217 names `change_reason` in the canonical import's
+ * page_versions insert (null when the commit carries no reason trailer) and adds the valid-time advisory's read of the
+ * written page after put_page's apply (persistence/valid-time-advisory.ts).
* CAPTURE_FOLD_NOOP=1 rewrites the fixture for the engine under test (only ever from the pre-hook commit).
*/
import { describe, expect, test } from 'bun:test';
diff --git a/test/mcp-schema-budget.test.ts b/test/mcp-schema-budget.test.ts
index 0620aaaa5f..5952742c89 100644
--- a/test/mcp-schema-budget.test.ts
+++ b/test/mcp-schema-budget.test.ts
@@ -68,9 +68,9 @@ const SERVED_STARTER_MAX_CHARS = 20_270; // GBRA-217: +120 for get_page `as_of`
const SERVED_STARTER_MIN_HEADROOM = 200;
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 = 21_833; // GBRA-156: 19,431 measured; GST-927: +100 for get_page's one-window-selector rule; GBRA-217 get_page as_of: +100 (19,905 measured at the lane D merge); 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-219 (#7795, GBRA-108 decision A): +301 for memory_conversation_mode on starter, trimmed first; GBRA-216 (#7810, train merge): +15 for remember's typed-claim params (21,833 measured on the train)
+const SERVED_STARTER_MAX_JSON_CHARS = 21_914; // GBRA-286 train: +81 for the agent-contract annotations its starter ops now declare (memory_conversation_mode readOnlyHint false + idempotentHint, ingest_undo idempotentHint); GBRA-156: 19,431 measured; GST-927: +100 for get_page's one-window-selector rule; GBRA-217 get_page as_of: +100 (19,905 measured at the lane D merge); 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-219 (#7795, GBRA-108 decision A): +301 for memory_conversation_mode on starter, trimmed first; GBRA-216 (#7810, train merge): +15 for remember's typed-claim params (21,833 measured on the train)
/** 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 = 21_894; // 26,546 before GBRA-156, 19,489 after; GST-927: +100 for get_page's one-window-selector rule; GBRA-217 get_page as_of: +100 (19,963 measured at the lane D merge); 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; GBRA-219 (#7795, GBRA-108 decision A): memory_conversation_mode joins starter (the per-conversation save switch, approved in the GBRA-219 plan), its description and the instructions clause trimmed first: +360; GBRA-216 (#7810, train merge): +15 for remember's typed-claim params (21,894 measured on the train)
+const SERVED_STARTER_MAX_RESULT_BYTES = 21_975; // GBRA-286 train: +81 for the same annotations; 26,546 before GBRA-156, 19,489 after; GST-927: +100 for get_page's one-window-selector rule; GBRA-217 get_page as_of: +100 (19,963 measured at the lane D merge); 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; GBRA-219 (#7795, GBRA-108 decision A): memory_conversation_mode joins starter (the per-conversation save switch, approved in the GBRA-219 plan), its description and the instructions clause trimmed first: +360; GBRA-216 (#7810, train merge): +15 for remember's typed-claim params (21,894 measured on the train)
/** 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_219; // GBRA-219 (#7795, GBRA-108 decision A): memory_conversation_mode joins starter (the per-conversation save switch, approved in the GBRA-219 plan), its description and the instructions clause trimmed first: +111 for the switch clause at the maximal rendering; #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 clause
const DESCRIPTION_HARD_CAP = 1_200;
@@ -104,6 +104,8 @@ const PARAM_DESCRIPTION_HARD_CAP = 200;
* that a reply without valid_time is the current page) on top of GST-927's one-window-selector rule, measured at 700.
* 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.
+ * memory_conversation_mode 420 -> 470 (GBRA-286 train): the agent-contract annotations it now declares (readOnlyHint
+ * false, idempotentHint), measured at 470.
*/
const TOOL_BUDGETS: Record<string, number> = {
add_timeline_entry: 730, cancel_job: 270, cancel_write_request: 350, capture: 710, context_pack: 500,
@@ -111,7 +113,7 @@ const TOOL_BUDGETS: Record<string, number> = {
get_backlinks: 710, get_ingest_log: 280, get_page: 700, get_recent_salience: 450, get_skill: 490,
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,
- memory_conversation_mode: 420, mute_notice: 420, put_skill: 1420, query: 1700, recall: 840, remember: 940, request_tools: 530, resolve_slugs: 410, search: 1420,
+ memory_conversation_mode: 470, 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,
};
diff --git a/test/mcp-stdio-gate-list.test.ts b/test/mcp-stdio-gate-list.test.ts
index 1b3a108380..3ae3c72c2f 100644
--- a/test/mcp-stdio-gate-list.test.ts
+++ b/test/mcp-stdio-gate-list.test.ts
@@ -55,7 +55,7 @@ describe('stdioVisibleTools (B1)', () => {
});
test('both gates on: full surfaced set returned unchanged', async () => {
- const engine = engineWithGates({ 'mcp.publish_skills': 'true', 'mcp.publish_advisor': 'true' });
+ const engine = engineWithGates({ 'mcp.publish_skills': 'true', 'mcp.publish_advisor': 'true', 'mcp.publish_memory_settings': 'true' });
const visible = await stdioVisibleTools(engine, operations);
expect(visible.map(op => op.name)).toEqual(operations.filter(op => !op.requiredScopes?.length && !op.cliOnly).map(op => op.name));
for (const op of operations.filter(op => op.requiredScopes?.length)) expect(visible).not.toContain(op);
diff --git a/test/operations-coverage-ledger.test.ts b/test/operations-coverage-ledger.test.ts
index b6f7776c4e..aefd6f3d44 100644
--- a/test/operations-coverage-ledger.test.ts
+++ b/test/operations-coverage-ledger.test.ts
@@ -216,6 +216,12 @@ const LEDGER: Record<string, string> = {
entity_identity_link: 'test/entity-identity.test.ts',
entity_identity_unlink: 'test/entity-identity.test.ts',
entity_identity_list: 'test/entity-identity.test.ts',
+ // GBRA-286 memory train: document ingest (GBRA-215) and memory settings (GBRA-219).
+ ingest: 'test/ingest.serial.test.ts',
+ ingest_undo: 'test/ingest.serial.test.ts',
+ get_memory_settings: 'test/memory-settings.test.ts',
+ set_memory_writeback: 'test/memory-settings.test.ts',
+ memory_conversation_mode: 'test/memory-settings.test.ts',
};
/**
diff --git a/test/operations-source-isolation-matrix.test.ts b/test/operations-source-isolation-matrix.test.ts
index 235ff1a56d..9e00116fdb 100644
--- a/test/operations-source-isolation-matrix.test.ts
+++ b/test/operations-source-isolation-matrix.test.ts
@@ -129,6 +129,7 @@ const MATRIX: Row[] = [
{ name: 'get_brain_identity', mode: 'brainwide', args: {}, rationale: 'brain-level identity document by design' },
{ name: 'get_brain_health', mode: 'skip', reason: 'returns count bands with no slug or source identity, so the beta-marker scan here would pass vacuously; test/doctor-ops-remote-6696.test.ts seeds per-source write failures and pins the handler to the scalar and federated grant' },
{ name: 'whoami', mode: 'brainwide', args: {}, rationale: 'caller identity/transport echo, no page data' },
+ { name: 'get_memory_settings', mode: 'brainwide', args: {}, rationale: 'brain-wide memory writeback config and its rule text; no page data' },
{ name: 'sources_list', mode: 'brainwide', args: {}, rationale: 'listing sources is its purpose; exposes ids/names only' },
{ name: 'request_tools', mode: 'brainwide', args: { tools: ['get_page'] }, rationale: 'tool registry surface, no page data' },
{ name: 'list_link_sources', mode: 'brainwide', args: {}, rationale: 'distinct link-origin kinds; enumerates kinds not content' },
diff --git a/test/remote-privacy-sweep.test.ts b/test/remote-privacy-sweep.test.ts
index e9dc63b904..869a987077 100644
--- a/test/remote-privacy-sweep.test.ts
+++ b/test/remote-privacy-sweep.test.ts
@@ -222,6 +222,9 @@ const PARAM_FACTORY: Record<string, Record<string, unknown>> = {
takes_add: { slug: WORLD_PAGE_SLUG, claim: 'fresh sweep take', kind: 'take', holder: 'world' },
delete_page: { slug: 'notes/sweep-fresh-write' },
restore_page: { slug: 'notes/sweep-fresh-write' },
+ // A valid mode, so the call reaches the publish gate (pinned off in beforeAll) instead of failing validation.
+ set_memory_writeback: { mode: 'off' },
+ memory_conversation_mode: { mode: 'all' },
};
// Per-(op × shape) overrides for ops whose behavior legitimately differs
@@ -237,6 +240,8 @@ const COORDINATED_WRITES = new Set(['put_page', 'put_pages', 'capture', 'delete_
const EXPECTED_BY_SHAPE: Record<string, Partial<Record<Shape, Outcome>>> = {
whoami: { scalar: 'error', federated: 'ok' },
list_jobs: { scalar: 'error', federated: 'ok' },
+ // The switch needs a connection that can call remember: the read-only federated grant cannot.
+ memory_conversation_mode: { scalar: 'ok', federated: 'error' },
};
// ── Expected outcome per op ──────────────────────────────────────────────
@@ -356,6 +361,13 @@ const EXPECTED_OUTCOME: Record<string, Outcome> = {
get_skill: 'denied',
list_brain_skillpack: 'denied',
advisor: 'denied',
+ set_memory_writeback: 'denied',
+ // Memory settings reads and the per-conversation switch return config and rule text, never corpus data.
+ get_memory_settings: 'ok',
+ memory_conversation_mode: 'ok', // base unused — per-shape override in EXPECTED_BY_SHAPE (above)
+ // Document ingest: the generic invocation omits content and attempt_id; undo omits the required attempt_id.
+ ingest: 'error',
+ ingest_undo: 'error',
// mutating ops (fresh-slug targets; envelope-echo checks only)
remember: 'ok',
// GST-359 D: memory_write saves only as an attested person; the sweep's callers attest none (actor_required).
@@ -500,6 +512,7 @@ beforeAll(async () => {
// mcp.publish_* enabled in ~/.gbrain config can't flip the denied arm.
await engine.setConfig('mcp.publish_skills', 'false');
await engine.setConfig('mcp.publish_advisor', 'false');
+ await engine.setConfig('mcp.publish_memory_settings', 'false');
// ── Seed the corpus (source: default) ──────────────────────────────
const put = operationsByName['put_page'];
diff --git a/test/retrieval-op-redaction.test.ts b/test/retrieval-op-redaction.test.ts
index 229ae33fcd..348e944a15 100644
--- a/test/retrieval-op-redaction.test.ts
+++ b/test/retrieval-op-redaction.test.ts
@@ -184,6 +184,7 @@ const SWEEP: Record<string, Row> = {
add_timeline_entry: { args: { slug: 'notes/n1', date: TODAY, summary: planted('new timeline'), request_id: randomUUID() } },
ontology_propose: { skip: 'write op; returns the merged ontology row, covered by the wrapper registration test' },
extract_entities: { skip: 'write op over the extraction pipeline; covered by the wrapper registration test' },
+ ingest: { skip: 'LLM-backed document ingest write (explicit_llm); its report and remote posture are owned by test/ingest.serial.test.ts' },
quarantine_list: { args: {}, content: false },
get_agent_job: { skip: 'agent-scope job poll needs a submitted agent job; covered by the wrapper registration test' },
// no_stored_text — read
@@ -215,6 +216,7 @@ const SWEEP: Record<string, Row> = {
schema_explain_type: { args: { type: 'note' } },
schema_review_orphans: { args: { limit: 50 } },
list_write_conflicts: { args: {} },
+ get_memory_settings: { args: {} },
// no_stored_text — write receipts (the planted content is the caller's own
// input here; the receipt must not echo it)
remember: { args: { fact: planted('remembered'), provenance: 'test:sweep', request_id: randomUUID() } },
diff --git a/test/schema-bootstrap-coverage.test.ts b/test/schema-bootstrap-coverage.test.ts
index e003c79540..a9eef167aa 100644
--- a/test/schema-bootstrap-coverage.test.ts
+++ b/test/schema-bootstrap-coverage.test.ts
@@ -976,6 +976,12 @@ const COLUMN_EXEMPTIONS = new Set<string>([
// column order; no blob statement or index reads it, and the DCR insert falls
// back to the unmarked insert while the column is missing.
'oauth_clients.registered_via',
+ // GBRA-217 page change reasons (v289 page_change_reasons): migration-only so
+ // fresh and upgraded brains share column ordinals; no blob statement or index
+ // reads them, and only post-migration writers and readers name them.
+ 'page_versions.change_reason',
+ 'page_versions.successor_pruned',
+ 'pages.version_history_gap_at',
// GBRA-156 access_tokens/oauth_clients.private_pages (migration
// principal_private_pages): migration-only like min_trust, so fresh and
// upgraded catalogs keep the same column order; no blob statement or index
diff --git a/test/truthful-catalog.e2e-lite.test.ts b/test/truthful-catalog.e2e-lite.test.ts
index d9c47563ba..7c450612ef 100644
--- a/test/truthful-catalog.e2e-lite.test.ts
+++ b/test/truthful-catalog.e2e-lite.test.ts
@@ -167,11 +167,12 @@ afterAll(async () => {
// Harness helpers
// ---------------------------------------------------------------------------
-/** Flip BOTH publish gates together on the DB plane (per-key independence is
+/** Flip EVERY publish gate together on the DB plane (per-key independence is
* pinned by test/publish-gates.test.ts; the matrix treats gates as one axis). */
async function setGates(on: boolean): Promise<void> {
await engine.setConfig('mcp.publish_skills', on ? 'true' : 'false');
await engine.setConfig('mcp.publish_advisor', on ? 'true' : 'false');
+ await engine.setConfig('mcp.publish_memory_settings', on ? 'true' : 'false');
}
interface Cell {