Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
feat(ops): every op declares mutating + idempotent; annotations and --tools-json read them
garrytan64f034f08fb6
diff --git a/src/commands/tools-json.ts b/src/commands/tools-json.tsindex a7b346c594..233929e116 100644--- a/src/commands/tools-json.ts+++ b/src/commands/tools-json.ts@@ -10,6 +10,12 @@ import { writeStdoutFinal } from '../core/cli-force-exit.ts';* parse them. WP3 adds the full JSON Schema (param descriptions, enums,* defaults, required array) additively under a new `schema` key per tool,* generated by the same buildToolDefs mapper the MCP transports serve.+ * Each tool also carries its access contract, additively (#5953 + agent+ * contract A2): `scope` and `required_scopes` (what an OAuth token needs to+ * call it), `mutating` (whether it writes), `idempotent` (whether repeating+ * it has the same effect), and `local_only` (reachable only from the local+ * CLI and stdio, never over HTTP) — so a client can derive which ops are+ * read-only from the catalog instead of keeping its own list.*/export async function printToolsJson(): Promise<void> {const defsByName = new Map(buildToolDefs(operations).map(def => [def.name, def]));@@ -23,6 +29,11 @@ export async function printToolsJson(): Promise<void> {]),),schema: defsByName.get(op.name)!.inputSchema,+ scope: op.scope ?? 'read',+ required_scopes: op.requiredScopes ?? [],+ mutating: op.mutating === true,+ idempotent: op.idempotent === true,+ local_only: op.localOnly === true,}));// Awaited delivery (#3423): the catalog is well past 64KiB, the exact sizediff --git a/src/core/ops/admin.ts b/src/core/ops/admin.tsindex 6e3a9ac21d..9a9af64993 100644--- a/src/core/ops/admin.ts+++ b/src/core/ops/admin.ts@@ -35,6 +35,8 @@ function diagnosticScope(ctx: OperationContext): { sourceId?: string; sourceIds?const get_stats: Operation = {name: 'get_stats',+ mutating: false,+ idempotent: true,outputRedaction: 'no_stored_text',description: 'Brain statistics (page count, chunk count, etc.) — remote callers see counters confined to their source grant.',params: {},@@ -47,6 +49,8 @@ const get_stats: Operation = {const get_health: Operation = {name: 'get_health',+ mutating: false,+ idempotent: true,outputRedaction: 'no_stored_text',description: 'Brain health dashboard (embed coverage, stale pages, orphans) — remote callers see counters confined to their source grant. Includes a `migrations {pending, partial, wedged, skipped_future}` block from the host migration ledger so remote agents can detect wedged/outstanding host migrations without shelling into the brain host. `computed_at` is when the counters were read: a repeat call within `health.cache_ttl_ms` (default 30000; env GBRAIN_HEALTH_CACHE_TTL_MS; 0 disables) with no page or config change returns the memoized numbers.',params: {},@@ -100,6 +104,8 @@ const get_health: Operation = {*/const get_brain_identity: Operation = {name: 'get_brain_identity',+ mutating: false,+ idempotent: true,outputRedaction: 'no_stored_text',description: 'Brain identity + counters for thin-client banner — remote callers see counters confined to their source grant. Returns version, engine kind, and page/chunk counts. Read-scope.',params: {},@@ -157,6 +163,8 @@ const get_brain_identity: Operation = {*/const run_doctor: Operation = {name: 'run_doctor',+ mutating: false,+ idempotent: true,outputRedaction: 'no_stored_text',description: 'Run brain health checks and return a structured DoctorReport (thin-client doctor surface).',params: {},@@ -178,6 +186,8 @@ const run_doctor: Operation = {const get_versions: Operation = {name: 'get_versions',+ mutating: false,+ idempotent: true,outputRedaction: { exempt: 'full page version snapshots by slug; a page read governed by visibility like get_page (CEO-17)' },description: 'Page version history. Trusted local and admin callers also get written_by and archived_by (who wrote each snapshot and whose write archived it).',params: {@@ -196,6 +206,7 @@ const get_versions: Operation = {const revert_version: Operation = {name: 'revert_version',+ idempotent: true,outputRedaction: 'no_stored_text',description: 'Revert page to a previous version',params: {@@ -225,6 +236,8 @@ const revert_version: Operation = {*/const quarantine_list: Operation = {name: 'quarantine_list',+ mutating: false,+ idempotent: true,outputRedaction: 'retrieval',description:'List quarantined (hidden) and optionally content-flagged pages by scanning page ' +diff --git a/src/core/ops/attribution.ts b/src/core/ops/attribution.tsindex f729101746..9b72fcc619 100644--- a/src/core/ops/attribution.ts+++ b/src/core/ops/attribution.ts@@ -99,6 +99,8 @@ type RowTarget = { kind: 'fact' | 'take' | 'timeline_entry'; label: string; sql:const get_write_attribution: Operation = {name: 'get_write_attribution',+ mutating: false,+ idempotent: true,outputRedaction: 'no_stored_text',description: 'Admin read: who created and who last changed a page, or one of its facts, takes or timeline entries. '+ 'Each attribution names the request id, operation, principal (kind, id, current name), time and origin 'diff --git a/src/core/ops/brain-membership.ts b/src/core/ops/brain-membership.tsindex 0241639bc3..f4768b7cdf 100644--- a/src/core/ops/brain-membership.ts+++ b/src/core/ops/brain-membership.ts@@ -4,6 +4,7 @@ import { joinBrain, leaveBrain, syncBrain } from '../shared-skills/membership.tsexport const brainMembershipOperations: Operation[] = [{name: 'join_brain', description: 'Enroll this authenticated principal to follow approved shared skills. Shared credentials are one principal. Never grants memory-write or editor authority.',+ idempotent: false,outputRedaction: 'no_stored_text',scope: 'read', mutating: true, requiredScopes: ['skills_member_self'],cliHints: { name: 'join-brain', positional: [] },@@ -12,6 +13,7 @@ export const brainMembershipOperations: Operation[] = [},{name: 'sync_brain_skills', description: 'Get a complete authorized shared-skills view and optionally record an own issued-batch delivery acknowledgment. Unavailable is never an empty catalog.',+ idempotent: false,outputRedaction: { exempt: 'skill catalog files are installed instructions read verbatim; redaction would corrupt approved revisions' },scope: 'read', mutating: true, requiredScopes: ['skills_member_self'],cliHints: { name: 'sync-brain-skills', positional: [] },@@ -20,6 +22,7 @@ export const brainMembershipOperations: Operation[] = [},{name: 'leave_brain', description: 'Stop only this principal’s enrollment. Does not revoke credentials or prove native cached instructions were disabled.',+ idempotent: false,outputRedaction: 'no_stored_text',scope: 'read', mutating: true, requiredScopes: ['skills_member_self'],cliHints: { name: 'leave-brain', positional: [] },diff --git a/src/core/ops/calibration.ts b/src/core/ops/calibration.tsindex c980712392..55099196b1 100644--- a/src/core/ops/calibration.ts+++ b/src/core/ops/calibration.ts@@ -12,6 +12,8 @@ import type { Operation } from './contract.ts';const get_calibration_profile: Operation = {name: 'get_calibration_profile',+ mutating: false,+ idempotent: true,outputRedaction: 'retrieval',description:'Read the active calibration profile for a holder. Returns the latest row from calibration_profiles ' +diff --git a/src/core/ops/chronicle.ts b/src/core/ops/chronicle.tsindex 01da87a983..630e18ee64 100644--- a/src/core/ops/chronicle.ts+++ b/src/core/ops/chronicle.ts@@ -33,6 +33,8 @@ function redactDiaryTimeline<// All route through sourceScopeOpts(ctx) so reads honor source isolation.const chronicle_day: Operation = {name: 'chronicle_day',+ mutating: false,+ idempotent: true,outputRedaction: 'retrieval',description:'Life Chronicle: events + timeline entries on a given day (or its ISO week when week=true), ' +@@ -62,6 +64,8 @@ const chronicle_day: Operation = {const chronicle_on_this_day: Operation = {name: 'chronicle_on_this_day',+ mutating: false,+ idempotent: true,outputRedaction: 'retrieval',description:'Life Chronicle: events from the same calendar day in PRIOR years ("on this day"). ' +@@ -81,6 +85,8 @@ const chronicle_on_this_day: Operation = {const chronicle_since: Operation = {name: 'chronicle_since',+ mutating: false,+ idempotent: true,outputRedaction: 'retrieval',description:'Life Chronicle: events + timeline entries on or after a date, optionally filtered by event kind. ' +@@ -103,6 +109,8 @@ const chronicle_since: Operation = {const chronicle_last_seen: Operation = {name: 'chronicle_last_seen',+ mutating: false,+ idempotent: true,outputRedaction: 'retrieval',description:"Life Chronicle: when an entity was last seen — its own timeline rows OR an event's `who`. " +@@ -131,6 +139,8 @@ const chronicle_last_seen: Operation = {const ontology_get: Operation = {name: 'ontology_get',+ mutating: false,+ idempotent: true,outputRedaction: 'retrieval',description:"Life Chronicle: the current resolved per-entity ontology (dimension → value) at `asof` " +@@ -159,6 +169,7 @@ const ontology_get: Operation = {const ontology_propose: Operation = {name: 'ontology_propose',+ idempotent: false,outputRedaction: 'retrieval',description:'Life Chronicle: record one ontology observation (entity has dimension=value), sourced + ' +@@ -204,6 +215,8 @@ const ontology_propose: Operation = {const ontology_dimensions: Operation = {name: 'ontology_dimensions',+ mutating: false,+ idempotent: true,outputRedaction: 'no_stored_text',description:'Life Chronicle meta-ontology: which dimensions the brain tracks across entities, with ' +@@ -216,6 +229,8 @@ const ontology_dimensions: Operation = {const ontology_conflicts: Operation = {name: 'ontology_conflicts',+ mutating: false,+ idempotent: true,outputRedaction: 'retrieval',description:'Life Chronicle: dimensions with ≥2 distinct current values from ≥2 provenances (genuine ' +@@ -242,6 +257,8 @@ const ontology_conflicts: Operation = {const volunteer_chronicle: Operation = {name: 'volunteer_chronicle',+ mutating: false,+ idempotent: true,outputRedaction: 'retrieval',description:'Life Chronicle agent-orientation: the recent timeline (last N days) + the current ' +@@ -275,6 +292,7 @@ const volunteer_chronicle: Operation = {const chronicle_backfill: Operation = {name: 'chronicle_backfill',+ idempotent: false,outputRedaction: 'no_stored_text',description:'Life Chronicle: sweep existing meeting/conversation/calendar pages into timeline events by ' +diff --git a/src/core/ops/chunks.ts b/src/core/ops/chunks.tsindex 25202d6287..ca48a5b687 100644--- a/src/core/ops/chunks.ts+++ b/src/core/ops/chunks.ts@@ -14,6 +14,8 @@ import { federatedSearchScope, parseSourceIdParam } from './context.ts';const resolve_slugs: Operation = {name: 'resolve_slugs',+ mutating: false,+ idempotent: true,outputRedaction: 'no_stored_text',description: 'Fuzzy-resolve a partial slug to matching page slugs',params: {@@ -39,6 +41,8 @@ const resolve_slugs: Operation = {const get_chunks: Operation = {name: 'get_chunks',+ mutating: false,+ idempotent: true,outputRedaction: { exempt: 'explicit chunk read by slug, the page-read twin of get_page (CEO-17 raw-read exception)' },description: 'Get content chunks for a page',params: {diff --git a/src/core/ops/code-intel.ts b/src/core/ops/code-intel.tsindex e6f48b579b..287717c441 100644--- a/src/core/ops/code-intel.ts+++ b/src/core/ops/code-intel.ts@@ -35,6 +35,8 @@ import {const code_callers: Operation = {name: 'code_callers',+ mutating: false,+ idempotent: true,outputRedaction: 'retrieval',description: CODE_CALLERS_DESCRIPTION,params: {@@ -75,6 +77,8 @@ const code_callers: Operation = {const code_callees: Operation = {name: 'code_callees',+ mutating: false,+ idempotent: true,outputRedaction: 'retrieval',description: CODE_CALLEES_DESCRIPTION,params: {@@ -113,6 +117,8 @@ const code_callees: Operation = {const code_def: Operation = {name: 'code_def',+ mutating: false,+ idempotent: true,outputRedaction: 'retrieval',description: CODE_DEF_DESCRIPTION,params: {@@ -138,6 +144,8 @@ const code_def: Operation = {const code_refs: Operation = {name: 'code_refs',+ mutating: false,+ idempotent: true,outputRedaction: 'retrieval',description: CODE_REFS_DESCRIPTION,params: {@@ -193,6 +201,8 @@ async function attachWalkReadiness(ctx: OperationContext, walk: WalkResult, sourconst code_blast: Operation = {name: 'code_blast',+ mutating: false,+ idempotent: true,outputRedaction: 'retrieval',description: 'BEFORE editing any function, run code_blast with the symbol name to surface every transitive caller grouped by depth (direct → 2-hop → 3-hop). Use this during plan-mode to size the change. Returns up to 200 nodes. Trust an empty/not_found result only when ready=true; ready=false means impact is unknown and requires a safe fallback. Returns: {result, status, ready, depth_groups?, truncation?, cycles_detected?, did_you_mean?, candidates?}. Example ok: {result:"ok", status:"ready", ready:true, depth_groups:[{depth:1, nodes:[{symbol,chunk_id}], confidence:0.77}], truncation:"none"}.',params: {@@ -229,6 +239,8 @@ const code_blast: Operation = {const code_flow: Operation = {name: 'code_flow',+ mutating: false,+ idempotent: true,outputRedaction: 'retrieval',description: 'When tracing how a request flows through the codebase from entry point to side effect (DB write, HTTP call, file I/O), run code_flow from the entry point. Returns ordered execution chain with terminal-node tags. Returns: same envelope as code_blast plus terminal_nodes: [{symbol, sink_kind}] where sink_kind ∈ "db_call"|"http_call"|"file_io"|"process_exec"|"unknown".',params: {@@ -264,6 +276,7 @@ const code_flow: Operation = {const code_traversal_cache_clear: Operation = {name: 'code_traversal_cache_clear',+ idempotent: true,outputRedaction: 'no_stored_text',description: 'Clear cached code_blast / code_flow traversal results. Source-scoped by default; pass all_sources=true to wipe everything (D8 destructive-guard).',params: {diff --git a/src/core/ops/connectors.ts b/src/core/ops/connectors.tsindex 48dcfcbcb1..5506396971 100644--- a/src/core/ops/connectors.ts+++ b/src/core/ops/connectors.ts@@ -28,6 +28,8 @@ import { runConnectorSync } from '../connectors/sync.ts';const connectors_status: Operation = {name: 'connectors_status',+ mutating: false,+ idempotent: true,outputRedaction: 'no_stored_text',description:'Per-provider chat-connector status: strategies, whether a credential is ' +@@ -72,6 +74,7 @@ const connectors_status: Operation = {const connector_sync: Operation = {name: 'connector_sync',+ idempotent: false,outputRedaction: 'no_stored_text',description:'Sync a chat provider\'s conversation history into the brain: list new ' +diff --git a/src/core/ops/embedding-migration.ts b/src/core/ops/embedding-migration.tsindex b5604aaffc..ce8fe38a0f 100644--- a/src/core/ops/embedding-migration.ts+++ b/src/core/ops/embedding-migration.ts@@ -16,6 +16,7 @@ import type { Operation } from './contract.ts';const migrate_embeddings: Operation = {name: 'migrate_embeddings',+ idempotent: false,outputRedaction: 'no_stored_text',description: 'Re-embed the brain onto a different embedding provider/model (#3390): schema dimension transition, NULL-signature (#3391) invalidation, query-cache purge, resumable re-embed. Without yes=true returns the plan + cost estimate only. Local-only admin op; the primary surface is `gbrain migrate embeddings`.',params: {diff --git a/src/core/ops/entity-identity.ts b/src/core/ops/entity-identity.tsindex 2e27e97751..4a2c9aff2d 100644--- a/src/core/ops/entity-identity.ts+++ b/src/core/ops/entity-identity.ts@@ -46,6 +46,7 @@ function resolveWriteSourceId(ctx: Parameters<Operation['handler']>[0], p: Recorconst entity_identity_link: Operation = {name: 'entity_identity_link',+ idempotent: false,outputRedaction: 'no_stored_text',description:'Link a page into a cross-source entity identity group (v1 manual-only; no auto-matching). ' +@@ -81,6 +82,7 @@ const entity_identity_link: Operation = {const entity_identity_unlink: Operation = {name: 'entity_identity_unlink',+ idempotent: false,outputRedaction: 'no_stored_text',description: 'Remove a page from a cross-source entity identity group (v1 manual-only).',params: {@@ -108,6 +110,8 @@ const entity_identity_unlink: Operation = {const entity_identity_list: Operation = {name: 'entity_identity_list',+ mutating: false,+ idempotent: true,outputRedaction: 'no_stored_text',description:'List cross-source entity identity groups and their member pages. Filter by entity_id or by a member slug. ' +diff --git a/src/core/ops/extraction.ts b/src/core/ops/extraction.tsindex 3ee67f526e..d0b14cc401 100644--- a/src/core/ops/extraction.ts+++ b/src/core/ops/extraction.ts@@ -46,6 +46,7 @@ const MAX_EXTRACT_ENTITIES = 200;const extract_entities: Operation = {name: 'extract_entities',+ idempotent: false,outputRedaction: 'retrieval',description: 'Extract entity names (people, companies) from text and create/update their brain stub pages. Stubs from untrusted input land in the quarantine lane (frontmatter `provenance: auto-extracted` + `status: unverified`) — excluded from authoritative retrieval boosts until reviewed. Direct authoritative writes require the trusted local CLI AND --trusted-extraction.',params: {@@ -102,6 +103,8 @@ const extract_entities: Operation = {const extraction_pending: Operation = {name: 'extraction_pending',+ mutating: false,+ idempotent: true,outputRedaction: 'retrieval',description: 'List unverified auto-extracted entity stubs awaiting owner review (the quarantine lane from extract_entities). Promote or reject them with extraction_review.',params: {@@ -148,6 +151,7 @@ const extraction_pending: Operation = {const extraction_review: Operation = {name: 'extraction_review',+ idempotent: false,outputRedaction: 'no_stored_text',description: 'Promote or reject unverified auto-extracted entity stubs (batch). Promote flips `status` to verified (provenance kept for audit); reject soft-deletes the stub. Owner-only: this op is refused for any non-local caller. (The markers are ordinary frontmatter — the boundary against rewriting them wholesale is put_page write authz, same as for any page.)',params: {diff --git a/src/core/ops/facts.ts b/src/core/ops/facts.tsindex e22a32a605..fe06efe505 100644--- a/src/core/ops/facts.ts+++ b/src/core/ops/facts.ts@@ -41,6 +41,7 @@ import { AUDIT_ROW_SOURCES } from '../facts/audit-sources.ts';const extract_facts: Operation = {name: 'extract_facts',+ idempotent: true,outputRedaction: 'no_stored_text',description:'v0.31: extract personal-knowledge facts (events, preferences, commitments, beliefs, ideas, and plain facts) from a conversation turn into the per-source hot memory. Sanitizes turn_text via INJECTION_PATTERNS, calls the configured extraction model (key-aware: any servable provider — OpenAI or Anthropic key both work), runs the cosine fast-path + classifier dedup pipeline, INSERTs into facts. Returns counts by status. With NO servable chat model, returns skipped: extraction_unavailable + an agent_action telling YOU to extract and write via `remember` (visibility: "private"). Skips extraction when the turn is dream-generated content (anti-loop). For agent memory writes of a SINGLE already-formed fact, prefer the `remember` verb (zero LLM, mandatory provenance).',@@ -201,6 +202,8 @@ function recallEvidencePlan(ctx: OperationContext, p: Record<string, unknown>):const recall: Operation = {name: 'recall',+ mutating: false,+ idempotent: true,outputRedaction: { retrieval: { localVerbatim: ['facts'] } },description:'MEMORY VERB (v1): retrieve saved facts/snippets — the protocol read verb. Filters hot-memory facts by entity / since / session_id; pass `query` to ALSO run hybrid search over pages (results[] arm); pass `budget_tokens` for server-side packing (response reports budget_used + dropped_count — never trims client-side). Remote callers see visibility=world facts only. Routing: for ONE known person/company/project card use `entity` (zero LLM); for broad questions needing reasoning use `synthesize` (expensive). Branch on structured fields (status/kind/evidence), never on prose. Every response carries protocol_version.',@@ -607,6 +610,8 @@ const dropAll = <T>(items: T[]) => ({ items: [] as T[], meta: { budget: 0, used:const context_pack: Operation = {name: 'context_pack',+ mutating: false,+ idempotent: true,outputRedaction: { retrieval: { localVerbatim: ['facts'] } },description:'MEMORY VERB (v1): budget-packed session-boundary bundle for a set of standing entities — entity cards + open threads + hot facts, zero-LLM, sub-second. Call at session start (warm cold context) and after compaction (rehydrate what the summary lost). WORLD-ONLY by default; pass include_private (honored for LOCAL trusted callers only) to widen all arms. budget_tokens packs server-side (response reports budget_used + dropped_count; cards pack first, then facts). Branch on structured fields, never prose. protocol_version rides every response.',@@ -722,6 +727,8 @@ const context_pack: Operation = {const delta: Operation = {name: 'delta',+ mutating: false,+ idempotent: true,outputRedaction: { retrieval: { localVerbatim: ['facts'] } },description:'MEMORY VERB (v1): "what changed since T" for heartbeats — pages updated after `since` + hot facts newer than `since` + open-thread events after `since`, zero-LLM. Lets a periodic wake maintain warm state in O(changes) instead of re-deriving. Optionally scope thread deltas to `entities`. WORLD-ONLY by default; include_private honored for local trusted callers only. budget_tokens packs server-side (pages first, then facts; threads are never dropped). protocol_version rides every response.',@@ -949,6 +956,7 @@ const delta: Operation = {const forget_fact: Operation = {name: 'forget_fact',+ idempotent: true,outputRedaction: 'no_stored_text',description: 'Forget a fact by recording a durable withdrawal in its source and visibility. Strikes the Markdown facts fence when writable; otherwise keeps the withdrawal in the database. Stale imports cannot reactivate the same normalized claim. This retracts memory; original prose, files and backups may retain the text. Idempotent on already-expired or unknown ids.',params: {diff --git a/src/core/ops/files.ts b/src/core/ops/files.tsindex be8d0e97be..34369d1368 100644--- a/src/core/ops/files.ts+++ b/src/core/ops/files.ts@@ -18,6 +18,8 @@ const FILE_LIST_LIMIT = 100;const file_list: Operation = {name: 'file_list',+ mutating: false,+ idempotent: true,outputRedaction: 'no_stored_text',description: 'List stored files',params: {@@ -44,6 +46,7 @@ const file_list: Operation = {const file_upload: Operation = {name: 'file_upload',+ idempotent: false,outputRedaction: 'no_stored_text',description: 'Upload a file to storage',params: {@@ -153,6 +156,8 @@ const file_upload: Operation = {const file_url: Operation = {name: 'file_url',+ mutating: false,+ idempotent: true,outputRedaction: 'no_stored_text',description: 'Get a URL for a stored file',params: {diff --git a/src/core/ops/image.ts b/src/core/ops/image.tsindex 46a29d6a92..1f0f6b7139 100644--- a/src/core/ops/image.ts+++ b/src/core/ops/image.ts@@ -17,6 +17,8 @@ import { resolveRequestedScope } from './context.ts';const search_by_image: Operation = {name: 'search_by_image',+ mutating: false,+ idempotent: true,outputRedaction: 'retrieval',description:'v0.36 cross-modal Phase 2: image-as-query retrieval. Accepts a local path (CLI), data: URI, or http(s):// URL ' +diff --git a/src/core/ops/ingest-log.ts b/src/core/ops/ingest-log.tsindex c308d627e0..b257930369 100644--- a/src/core/ops/ingest-log.ts+++ b/src/core/ops/ingest-log.ts@@ -14,6 +14,7 @@ import { linkReadScopeOpts } from './context.ts';const log_ingest: Operation = {name: 'log_ingest',+ idempotent: false,outputRedaction: 'no_stored_text',description: 'Log an ingestion event',params: {@@ -43,6 +44,8 @@ const log_ingest: Operation = {const get_ingest_log: Operation = {name: 'get_ingest_log',+ mutating: false,+ idempotent: true,outputRedaction: 'retrieval',description: 'Get recent ingestion log entries',params: {diff --git a/src/core/ops/insights.ts b/src/core/ops/insights.tsindex 97b2a16459..8f2f8f7a1e 100644--- a/src/core/ops/insights.ts+++ b/src/core/ops/insights.ts@@ -22,6 +22,8 @@ import {const volunteer_context: Operation = {name: 'volunteer_context',+ mutating: false,+ idempotent: true,outputRedaction: 'retrieval',description:'Push-based context: volunteer brain pages relevant to a rolling conversation window ' +@@ -123,6 +125,8 @@ const volunteer_context: Operation = {// v0.33: expertise + relationship-proximity routing. CLI: gbrain whoknows.const find_experts: Operation = {name: 'find_experts',+ mutating: false,+ idempotent: true,outputRedaction: 'retrieval',description: FIND_EXPERTS_DESCRIPTION,scope: 'read',@@ -178,6 +182,8 @@ const find_experts: Operation = {// v0.32.6: contradiction probe MCP surface (M3)const find_contradictions: Operation = {name: 'find_contradictions',+ mutating: false,+ idempotent: true,outputRedaction: 'retrieval',description: FIND_CONTRADICTIONS_DESCRIPTION,scope: 'read',@@ -258,6 +264,8 @@ const find_contradictions: Operation = {const find_trajectory: Operation = {name: 'find_trajectory',+ mutating: false,+ idempotent: true,outputRedaction: 'retrieval',description: FIND_TRAJECTORY_DESCRIPTION,scope: 'read',diff --git a/src/core/ops/jobs.ts b/src/core/ops/jobs.tsindex d198c3c3c5..24a817dbb8 100644--- a/src/core/ops/jobs.ts+++ b/src/core/ops/jobs.ts@@ -79,6 +79,7 @@ async function assertJobOwned(ctx: OperationContext, id: number, owner: string):const submit_job: Operation = {name: 'submit_job',+ idempotent: false,outputRedaction: { exempt: 'admin-scoped job introspection: job params and results are operator data, not retrieved brain text' },description: 'Submit a background job. Remote callers may submit sync, import, lint or lint-fix for their authenticated filesystem source. Other kinds require local CLI or a dedicated operation.',params: {@@ -236,6 +237,7 @@ async function probeQueueStateSafe(// (agent.use_gateway_loop is auto-on for submit_agent jobs).const submit_agent: Operation = {name: 'submit_agent',+ idempotent: false,outputRedaction: { exempt: 'admin-scoped job introspection: job params and results are operator data, not retrieved brain text' },description: 'Submit an LLM agent job that the worker dispatches via the gateway-native tool loop. Requires the `agent` OAuth scope. Tools, source, slug prefixes, max concurrency, and daily budget are bound at OAuth client registration time.',params: {@@ -392,6 +394,8 @@ const submit_agent: Operation = {*/const get_agent_job: Operation = {name: 'get_agent_job',+ mutating: false,+ idempotent: true,outputRedaction: 'retrieval',description: 'Poll an agent job submitted via submit_agent. Returns a trimmed status view (id, status, timestamps, error_text, result) plus queue_position (waiting jobs ahead in claim order; 0 = next) while the job is still waiting. Requires the `agent` OAuth scope; only jobs owned by the calling client are visible.',params: {@@ -475,6 +479,8 @@ const get_agent_job: Operation = {const get_job: Operation = {name: 'get_job',+ mutating: false,+ idempotent: true,outputRedaction: { exempt: 'admin-scoped job introspection: job params and results are operator data, not retrieved brain text' },description: 'Get job status and details by ID. Agent-scoped tokens (no admin) see only jobs they own.',params: {@@ -497,6 +503,8 @@ const get_job: Operation = {const list_jobs: Operation = {name: 'list_jobs',+ mutating: false,+ idempotent: true,outputRedaction: { exempt: 'admin-scoped job introspection: job params and results are operator data, not retrieved brain text' },description: 'List jobs with optional filters. Agent-scoped tokens (no admin) see only jobs they own.',params: {@@ -527,6 +535,7 @@ const list_jobs: Operation = {const cancel_job: Operation = {name: 'cancel_job',+ idempotent: false,outputRedaction: { exempt: 'admin-scoped job introspection: job params and results are operator data, not retrieved brain text' },description: 'Cancel a waiting, active, or delayed job. Agent-scoped tokens (no admin) can cancel only jobs they own.',params: {@@ -553,6 +562,7 @@ const cancel_job: Operation = {const retry_job: Operation = {name: 'retry_job',+ idempotent: false,outputRedaction: { exempt: 'admin-scoped job introspection: job params and results are operator data, not retrieved brain text' },description: 'Re-queue a failed or dead job for retry',params: {@@ -577,6 +587,8 @@ const retry_job: Operation = {const get_job_progress: Operation = {name: 'get_job_progress',+ mutating: false,+ idempotent: true,outputRedaction: { exempt: 'admin-scoped job introspection: job params and results are operator data, not retrieved brain text' },description: 'Get structured progress for a running job. Agent-scoped tokens (no admin) see only jobs they own.',params: {@@ -597,6 +609,7 @@ const get_job_progress: Operation = {const pause_job: Operation = {name: 'pause_job',+ idempotent: false,outputRedaction: { exempt: 'admin-scoped job introspection: job params and results are operator data, not retrieved brain text' },description: 'Pause a waiting, active, or delayed job',params: {@@ -616,6 +629,7 @@ const pause_job: Operation = {const resume_job: Operation = {name: 'resume_job',+ idempotent: false,outputRedaction: { exempt: 'admin-scoped job introspection: job params and results are operator data, not retrieved brain text' },description: 'Resume a paused job back to waiting',params: {@@ -638,6 +652,7 @@ const resume_job: Operation = {const replay_job: Operation = {name: 'replay_job',+ idempotent: false,outputRedaction: { exempt: 'admin-scoped job introspection: job params and results are operator data, not retrieved brain text' },description: 'Replay a completed/failed/dead job, optionally with modified data',params: {@@ -661,6 +676,7 @@ const replay_job: Operation = {const send_job_message: Operation = {name: 'send_job_message',+ idempotent: false,outputRedaction: { exempt: 'admin-scoped job introspection: job params and results are operator data, not retrieved brain text' },description: 'Send a sidechannel message to a running job\'s inbox',params: {@@ -723,6 +739,8 @@ const send_job_message: Operation = {*/const get_job_stats: Operation = {name: 'get_job_stats',+ mutating: false,+ idempotent: true,outputRedaction: 'no_stored_text',description:'Job queue statistics. PER-BLOCK scoping: by_status and queue_health are GLOBAL ' +diff --git a/src/core/ops/links.ts b/src/core/ops/links.tsindex 5a56efe070..d5bc5519f2 100644--- a/src/core/ops/links.ts+++ b/src/core/ops/links.ts@@ -51,6 +51,7 @@ export const MANAGED_LINK_SOURCES = ['markdown', 'frontmatter', 'mentions', 'wikconst add_link: Operation = {name: 'add_link',+ idempotent: false,outputRedaction: 'no_stored_text',description: 'Create link between pages',params: {@@ -128,6 +129,7 @@ const add_link: Operation = {const remove_link: Operation = {name: 'remove_link',+ idempotent: false,outputRedaction: 'no_stored_text',description: 'Remove link between pages',params: {@@ -304,6 +306,8 @@ async function hintScopedLinkMiss(const get_links: Operation = {name: 'get_links',+ mutating: false,+ idempotent: true,outputRedaction: 'retrieval',description: 'List outgoing links from a page',params: {@@ -318,6 +322,8 @@ const get_links: Operation = {const get_backlinks: Operation = {name: 'get_backlinks',+ mutating: false,+ idempotent: true,outputRedaction: 'retrieval',description: 'List incoming links to a page',params: {@@ -332,6 +338,8 @@ const get_backlinks: Operation = {const list_link_sources: Operation = {name: 'list_link_sources',+ mutating: false,+ idempotent: true,outputRedaction: 'no_stored_text',// v114 (#1941): the read-side counterpart to link-add/link-rm. Since// link_source is now an open kebab provenance (no allowlist), this is how an@@ -371,6 +379,8 @@ const DEFAULT_TRAVERSE_DEPTH = 5;const traverse_graph: Operation = {name: 'traverse_graph',+ mutating: false,+ idempotent: true,outputRedaction: 'retrieval',description: `Traverse link graph from a page. Remote callers default to bidirectional edges (GraphPath[]) at depth ${REMOTE_BIDIRECTIONAL_DEFAULT_DEPTH} (pass depth explicitly for deeper walks); trusted local no-filter callers keep the legacy node shape at depth ${DEFAULT_TRAVERSE_DEPTH}.`,params: {diff --git a/src/core/ops/loops.ts b/src/core/ops/loops.tsindex 979425ba8f..18a9d6523b 100644--- a/src/core/ops/loops.ts+++ b/src/core/ops/loops.ts@@ -297,6 +297,8 @@ function renderText(groups: CounterpartyGroup[], stale: boolean, noGoogleSourcesconst open_loops: Operation = {name: 'open_loops',+ mutating: false,+ idempotent: true,outputRedaction: 'retrieval',description:'The open-loop engine\'s killer output: who is waiting on you, what you promised, and the context ' +@@ -480,6 +482,7 @@ const open_loops: Operation = {const loops_close: Operation = {name: 'loops_close',+ idempotent: true,outputRedaction: 'no_stored_text',description:"Close an open loop by id: status 'done' (handled) or 'dropped' (not going to). Closing is a state " +@@ -553,6 +556,7 @@ const loops_close: Operation = {const loops_mute: Operation = {name: 'loops_mute',+ idempotent: true,outputRedaction: 'no_stored_text',description:'Suppress a sender (email address) or thread id from opening NEW loops — the detector feedback ' +@@ -599,6 +603,7 @@ const loops_mute: Operation = {const loops_unmute: Operation = {name: 'loops_unmute',+ idempotent: true,outputRedaction: 'no_stored_text',description:'Remove a sender/thread suppression added by loops_mute, so the detector can open NEW loops for ' +diff --git a/src/core/ops/orphans.ts b/src/core/ops/orphans.tsindex 531d973183..4827251b3e 100644--- a/src/core/ops/orphans.ts+++ b/src/core/ops/orphans.ts@@ -16,6 +16,8 @@ const ORPHANS_MAX_LIMIT = 1000;const find_orphans: Operation = {name: 'find_orphans',+ mutating: false,+ idempotent: true,outputRedaction: 'retrieval',description: 'Find disconnected pages. Default mode "islanded" (no live inbound AND no outbound link) matches get_health.orphan_pages; mode "inbound" is the legacy no-inbound-only view. Essential for content enrichment cycles.',params: {diff --git a/src/core/ops/page-edit.ts b/src/core/ops/page-edit.tsindex 6be8546b03..1f3e38abd0 100644--- a/src/core/ops/page-edit.ts+++ b/src/core/ops/page-edit.ts@@ -9,6 +9,7 @@ import { EDIT_PAGE_MAX_EDITS, parsePageEdits } from '../persistence/page-edit.tsconst edit_page: Operation = {name: 'edit_page',+ idempotent: true,outputRedaction: { exempt: "the diff is the caller's own authorized view of the page it just edited (the get_page boundary), secret-redacted when created because the receipt retains it" },description: 'Change part of an existing page without resending it: prefer this over put_page for small changes to large pages. Read get_page with include_content:true and pass its revision as expected_revision. Each edit replaces old_text with new_text; edits apply in order, each to the text the previous edit produced, and each old_text must match exactly once in that content. Protected takes and facts sections never match (use the takes_* operations or remember/forget). All edits publish together or none do, through the same receipts, fences and write-through as put_page. Returns the new revision and a unified diff of your view (at most 8 KB). Refusals name the edit: edit_no_match, edit_ambiguous_match (with match_count), edit_protected_span, edit_invalid; a stale revision returns revision_conflict with current_revision. Retain request_id and repeat identical arguments after a pending receipt.',params: {diff --git a/src/core/ops/pages.ts b/src/core/ops/pages.tsindex 55a197b85e..423666d7b5 100644--- a/src/core/ops/pages.ts+++ b/src/core/ops/pages.ts@@ -74,6 +74,7 @@ function stripPrivacyFencesForRemoteReader(page: Page): Page {const get_page: Operation = {name: 'get_page',+ idempotent: true,outputRedaction: { exempt: 'explicit page read by slug/id; governed by page visibility, not output redaction (CEO-17 raw-read exception)' },description: 'Read a page by slug (supports optional fuzzy matching). Slug aliases left by renames redirect to the canonical page in the source that owns the alias (archived sources excluded); a redirected read reports `resolved_slug`. To edit a page, pass include_content: true — the returned `content` field is the canonical full markdown (frontmatter + body + timeline sentinel); edit THAT and pass it back to put_page to round-trip losslessly. Reassembling compiled_truth/timeline by hand risks dropping sections. Soft-deleted pages are hidden by default; pass include_deleted: true to surface them with deleted_at populated (see v0.26.5 recovery window). `timeline` is only the markdown section after the timeline sentinel; entries written by add_timeline_entry or extraction live in timeline rows, which include_timeline_entries: true returns as `timeline_entries` (the same rows get_timeline returns).',params: {@@ -210,6 +211,7 @@ const get_page: Operation = {const fetch_page: Operation = {name: 'fetch',+ idempotent: true,outputRedaction: { exempt: 'explicit page read by slug/id; governed by page visibility, not output redaction (CEO-17 raw-read exception)' },description: "Fetch the full text of one search result by its opaque, source-qualified `id` (OpenAI deep-research contract: the search/fetch pair). Pass the id unchanged; it does not grant access. Legacy slug ids work only when unambiguous within your current read scope. Returns { id, title, text, url, metadata } — `text` is the page's canonical markdown. For fuzzy slugs, soft-delete recovery, or lossless edit round-trips, use get_page.",params: {@@ -281,6 +283,7 @@ const fetch_page: Operation = {const put_page: Operation = {name: 'put_page',+ idempotent: true,outputRedaction: 'no_stored_text',description: 'Replace a complete canonical Markdown page. Read get_page with include_content:true and pass its revision as expected_revision; force explicitly overwrites the current revision. Omitting both permits creation only. Retain a UUID request_id and repeat identical arguments after transport failure or a pending receipt. Content, tags, sanitized text projections, versions and the committed receipt publish together; embedding and optional Git effects have separate status. Remote callers preserve protected facts/takes fences; automatic graph links are skipped for untrusted writes. A stdio `gbrain serve` sweeps them at startup + on idle; `gbrain serve --http` does not self-sweep — run `gbrain sweep --once` or use trusted local capture/put_page for inline link extraction. Remote callers receive write_through.warning when no repo is configured. For file input use gbrain capture --file PATH --slug SLUG.',params: {@@ -359,6 +362,7 @@ async function runAutoLink(const delete_page: Operation = {name: 'delete_page',+ idempotent: true,outputRedaction: 'no_stored_text',description: 'Soft-delete a page and remove its markdown file from the source working tree (the source local_path, or sync.repo_path when the source has none). File removal is skipped when sync.write_through is off; the committed receipt reports the persistence mode and write_through outcome. Read the page revision first and pass expected_revision; retain request_id for replay. The row is hidden from search and from get_page/list_pages, but is recoverable via restore_page within 72h, which re-creates the file. The autopilot purge phase hard-deletes after the recovery window. Pass include_deleted: true to get_page to verify the soft-delete landed. purge: true is trusted-local CLI only and removes the row, chunks, links and raw data immediately after its recorded markdown artifact is removed. Purge uses the same revision, request_id and recovery protocol, including for existing tombstones. A removal failure preserves the prior row and never reports purge success; repair the artifact and submit a new request_id. A committed purge warns that git history, synced copies, exports and derived rows may retain content; rotate exposed credentials.',params: {@@ -387,6 +391,7 @@ const delete_page: Operation = {const restore_page: Operation = {name: 'restore_page',+ idempotent: true,outputRedaction: 'no_stored_text',description: 'v0.26.5 — restore a soft-deleted page (clear deleted_at) and re-create its markdown file on disk (the counterpart to delete_page removing it; the result write_through field reports the outcome). Returns success only if the page was actually soft-deleted. After this op, the page reappears in search and in get_page/list_pages without the include_deleted flag.',params: {@@ -413,6 +418,7 @@ const restore_page: Operation = {const purge_deleted_pages: Operation = {name: 'purge_deleted_pages',+ idempotent: false,outputRedaction: 'no_stored_text',description: 'v0.26.5 — admin-only. Hard-deletes pages whose deleted_at is older than older_than_hours (default 72). Cascades through content_chunks, page_links, chunk_relations. Local CLI only (not exposed over HTTP MCP). Manual escape hatch alongside the autopilot purge phase.',params: {@@ -435,6 +441,7 @@ type ListPagesSort = typeof LIST_PAGES_SORT_VALUES[number];const list_pages: Operation = {name: 'list_pages',+ idempotent: true,outputRedaction: 'retrieval',description: LIST_PAGES_DESCRIPTION,params: {@@ -605,6 +612,7 @@ const list_pages: Operation = {*/const capture: Operation = {name: 'capture',+ idempotent: true,outputRedaction: 'no_stored_text',description: CAPTURE_DESCRIPTION,params: {diff --git a/src/core/ops/persistence.ts b/src/core/ops/persistence.tsindex a91224caff..36dc4972cd 100644--- a/src/core/ops/persistence.ts+++ b/src/core/ops/persistence.ts@@ -121,6 +121,7 @@ const requestParam = { type: 'string' as const, required: true, description: 'Thexport const persistenceOperations: Operation[] = [{name: 'get_write_request',+ idempotent: true,outputRedaction: 'no_stored_text',description: 'Read your durable write receipt by request_id. Requires write scope and this operation in the current grant. Foreign, missing, and no-longer-accessible requests return the same not_found error; private journal input and recovery bytes are never returned.',params: { request_id: requestParam },@@ -137,6 +138,7 @@ export const persistenceOperations: Operation[] = [},{name: 'list_write_requests',+ idempotent: true,outputRedaction: 'no_stored_text',description: 'List your currently authorized write receipts in one source, newest first. Useful when an acknowledgment was lost. Results and pagination exclude other principals and inaccessible targets; no private payloads or cross-principal queue counts are exposed.',params: {@@ -169,6 +171,7 @@ export const persistenceOperations: Operation[] = [},{name: 'cancel_write_request',+ idempotent: true,outputRedaction: 'no_stored_text',description: 'Cancel your accepted write before publication starts. Returns the actual receipt: running/recovering or already-terminal requests may remain unchanged. Cancellation cannot undo published bytes or a committed fact withdrawal.',params: { request_id: requestParam },diff --git a/src/core/ops/raw-data.ts b/src/core/ops/raw-data.tsindex f8d2b7e10e..1573de94cc 100644--- a/src/core/ops/raw-data.ts+++ b/src/core/ops/raw-data.ts@@ -13,6 +13,7 @@ import { enforceClientSlugFence } from './context.ts';const put_raw_data: Operation = {name: 'put_raw_data',+ idempotent: false,outputRedaction: 'no_stored_text',description: 'Store raw API response data for a page',params: {@@ -34,6 +35,8 @@ const put_raw_data: Operation = {const get_raw_data: Operation = {name: 'get_raw_data',+ mutating: false,+ idempotent: true,outputRedaction: { exempt: 'explicit raw sidecar read by slug; governed by page visibility (CEO-17 raw-read exception)' },description: 'Retrieve raw data for a page. Raw data follows the page\'s soft-delete: a tombstoned (soft-deleted) page returns [] exactly like a missing page; restore_page brings the rows back, and get_page include_deleted: true verifies the tombstone.',params: {diff --git a/src/core/ops/request-tools.ts b/src/core/ops/request-tools.tsindex 3579742042..72fc8bb141 100644--- a/src/core/ops/request-tools.ts+++ b/src/core/ops/request-tools.ts@@ -112,6 +112,7 @@ async function visibleOpsForCaller(const request_tools: Operation = {name: 'request_tools',+ idempotent: false,outputRedaction: 'no_stored_text',description:'Discover this brain\'s tool catalog and optionally unlock a wider tool surface for your client. ' +diff --git a/src/core/ops/salience.ts b/src/core/ops/salience.tsindex 24284b0af5..694c2f22b3 100644--- a/src/core/ops/salience.ts+++ b/src/core/ops/salience.ts@@ -19,6 +19,8 @@ import {const get_recent_salience: Operation = {name: 'get_recent_salience',+ mutating: false,+ idempotent: true,outputRedaction: 'retrieval',description: GET_RECENT_SALIENCE_DESCRIPTION,scope: 'read',@@ -68,6 +70,8 @@ const get_recent_salience: Operation = {const find_anomalies: Operation = {name: 'find_anomalies',+ mutating: false,+ idempotent: true,outputRedaction: 'retrieval',description: FIND_ANOMALIES_DESCRIPTION,scope: 'read',diff --git a/src/core/ops/schema-packs.ts b/src/core/ops/schema-packs.tsindex 5f8a8886e8..5f0d4921f2 100644--- a/src/core/ops/schema-packs.ts+++ b/src/core/ops/schema-packs.ts@@ -27,6 +27,8 @@ import { sourceScopeOpts } from './context.ts';const get_active_schema_pack: Operation = {name: 'get_active_schema_pack',+ mutating: false,+ idempotent: true,outputRedaction: 'no_stored_text',description: 'v0.40.6.0: cheap identity packet for the active schema pack. Returns {pack_name, version, sha8, page_types_count, link_types_count, primitive_summary, source_tier}. Useful for agents to know which pack they are operating against without paying full manifest load cost.',params: {},@@ -64,6 +66,8 @@ const get_active_schema_pack: Operation = {const list_schema_packs: Operation = {name: 'list_schema_packs',+ mutating: false,+ idempotent: true,outputRedaction: 'no_stored_text',description: 'v0.40.6.0: list installed schema packs (bundled + user-installed). Returns {bundled: string[], installed: string[]}. Read-only directory listing.',params: {},@@ -90,6 +94,8 @@ const list_schema_packs: Operation = {const schema_stats: Operation = {name: 'schema_stats',+ mutating: false,+ idempotent: true,outputRedaction: 'no_stored_text',description: 'v0.40.6.0: per-type page counts + typed-coverage from the DB. Returns {schema_version:1, pack_identity, aggregate, per_source, dead_prefixes}. Multi-source aware via ctx.sourceId/allowedSources.',params: {},@@ -106,6 +112,8 @@ const schema_stats: Operation = {const schema_lint: Operation = {name: 'schema_lint',+ mutating: false,+ idempotent: true,outputRedaction: 'no_stored_text',description: 'v0.40.6.0: lint the active (or named) schema pack. File-plane rules only over MCP — the with_db option is rejected for remote callers (DB-aware rules require local CLI). Returns {ok, errors, warnings} structured report.',params: {@@ -159,6 +167,8 @@ const schema_lint: Operation = {const schema_graph: Operation = {name: 'schema_graph',+ mutating: false,+ idempotent: true,outputRedaction: 'no_stored_text',description: 'v0.40.6.0: schema pack graph as JSON edges. Returns {nodes: [{name, primitive}], edges: [{from, verb, to}]} derived from link_types inference + frontmatter_links.',params: {},@@ -191,6 +201,8 @@ const schema_graph: Operation = {const schema_explain_type: Operation = {name: 'schema_explain_type',+ mutating: false,+ idempotent: true,outputRedaction: 'no_stored_text',description: 'v0.40.6.0: resolved settings for a single page_type in the active pack. Returns {pack, type, primitive, path_prefixes, aliases, extractable, expert_routing}.',params: {@@ -213,6 +225,8 @@ const schema_explain_type: Operation = {const schema_review_orphans: Operation = {name: 'schema_review_orphans',+ mutating: false,+ idempotent: true,outputRedaction: 'no_stored_text',description: 'v0.40.6.0: list pages with no active-pack type match. Returns {orphan_count, orphans: [{slug, source_id}]}.',params: {@@ -236,6 +250,7 @@ const schema_review_orphans: Operation = {const schema_apply_mutations: Operation = {name: 'schema_apply_mutations',+ idempotent: false,outputRedaction: 'no_stored_text',description: 'v0.40.7.0: batched schema pack mutation. ATOMIC: every mutation is validated against an in-memory manifest first, and the pack file is written to disk at most once, after the FULL batch has proven valid — so a failure at any point leaves the pack file byte-identical to its pre-batch state (never a partial write). Audit log records one batch_id. Admin scope; NOT localOnly so remote agents (your OpenClaw, etc.) can author packs over normal MCP. Mutation shape per ApplyMutationsRequest type — supports add_type / remove_type / update_type / add_alias / remove_alias / add_prefix / remove_prefix / add_link_type / remove_link_type / set_extractable / set_expert_routing.',params: {@@ -306,6 +321,7 @@ const schema_apply_mutations: Operation = {const reload_schema_pack: Operation = {name: 'reload_schema_pack',+ idempotent: true,outputRedaction: 'no_stored_text',description: 'v0.40.6.0: flush the in-process schema pack cache so the next loadActivePack re-reads from disk. Cascades through extends-chain (codex C6). Admin scope; NOT localOnly. Returns {invalidated: string[]}.',params: {diff --git a/src/core/ops/search.ts b/src/core/ops/search.tsindex cc4cd77bf9..f9d9d99b00 100644--- a/src/core/ops/search.ts+++ b/src/core/ops/search.ts@@ -320,6 +320,7 @@ async function resolveSnippetCap(ctx: OperationContext, p: Record<string, unknowconst search: Operation = {name: 'search',+ idempotent: true,outputRedaction: 'retrieval',description: SEARCH_DESCRIPTION,params: {@@ -455,6 +456,7 @@ const search: Operation = {const query: Operation = {name: 'query',+ idempotent: true,outputRedaction: 'retrieval',description: QUERY_DESCRIPTION,params: {@@ -913,6 +915,7 @@ const query: Operation = {*/const assemble_evidence: Operation = {name: 'assemble_evidence',+ idempotent: true,outputRedaction: 'retrieval',description:'Deliver whole evidence for an ordered list of search hits (each {source_id, slug, chunk_id} from a prior search/query result): ' +@@ -962,6 +965,8 @@ const assemble_evidence: Operation = {const search_stats: Operation = {name: 'search_stats',+ mutating: false,+ idempotent: true,outputRedaction: 'no_stored_text',description:'Search observability over a window: cache hit rate, intent/mode mix, budget drops, ' +@@ -1003,6 +1008,7 @@ const search_stats: Operation = {const search_modes: Operation = {name: 'search_modes',+ idempotent: true,outputRedaction: 'no_stored_text',description:'Read-only search-mode dashboard: active mode, EVERY mode-bundle knob resolved with ' +@@ -1026,6 +1032,8 @@ const search_modes: Operation = {const search_tune: Operation = {name: 'search_tune',+ mutating: false,+ idempotent: true,outputRedaction: 'no_stored_text',description:'Read-only tuning recommendations derived from the last 7 days of search telemetry: ' +@@ -1045,6 +1053,8 @@ const search_tune: Operation = {const cache_stats: Operation = {name: 'cache_stats',+ mutating: false,+ idempotent: true,outputRedaction: 'no_stored_text',description:'Semantic query-cache introspection: resolved knobs (enabled, similarity threshold, TTL) ' +diff --git a/src/core/ops/skillopt.ts b/src/core/ops/skillopt.tsindex f3b9eaa42e..f8038f2c2a 100644--- a/src/core/ops/skillopt.ts+++ b/src/core/ops/skillopt.ts@@ -38,6 +38,7 @@ import { OperationError } from './contract.ts';// what they would have gotten with the right grants.const run_onboard: Operation = {name: 'run_onboard',+ idempotent: false,outputRedaction: 'no_stored_text',description: 'Probe brain health + optionally submit onboard remediations. Admin scope required. Protected handlers (LLM-bearing) require run_protected_onboard scope ADDITIONALLY.',params: {@@ -126,6 +127,7 @@ const run_onboard: Operation = {// bundled-skill guard). NOT localOnly so admin HTTP MCP clients can invoke.const run_skillopt: Operation = {name: 'run_skillopt',+ idempotent: true,outputRedaction: { exempt: 'skill catalog files are installed instructions read verbatim; redaction would corrupt approved revisions' },description: 'Run SkillOpt against a single skill. Admin scope and remote skill allowlist required. shared_skill stages an exact catalog revision privately and requires explicit skill_editor and put_skill grants; only accepted body changes publish through the original revision CAS. Rate-limited per-skill via DB lock.',params: {diff --git a/src/core/ops/skills-catalog.ts b/src/core/ops/skills-catalog.tsindex 4668303ce0..7d7efbbd5d 100644--- a/src/core/ops/skills-catalog.ts+++ b/src/core/ops/skills-catalog.ts@@ -22,6 +22,8 @@ import {const list_skills: Operation = {name: 'list_skills',+ mutating: false,+ idempotent: true,outputRedaction: 'no_stored_text',description: LIST_SKILLS_DESCRIPTION,publishGateKey: 'mcp.publish_skills',@@ -54,6 +56,8 @@ const list_skills: Operation = {const get_skill: Operation = {name: 'get_skill',+ mutating: false,+ idempotent: true,outputRedaction: { exempt: 'skill catalog files are installed instructions read verbatim; redaction would corrupt approved revisions' },description: GET_SKILL_DESCRIPTION,publishGateKey: 'mcp.publish_skills',@@ -119,6 +123,8 @@ const sharedSkillMutationParams: Operation['params'] = {};const get_skill_asset: Operation = {name: 'get_skill_asset', description: 'Read a bounded, owner-approved file from an exact sealed skill revision. Does not execute downloaded bytes.',+ mutating: false,+ idempotent: true,outputRedaction: { exempt: 'skill catalog files are installed instructions read verbatim; redaction would corrupt approved revisions' },scope: 'read', publishGateKey: 'mcp.publish_skills',cliHints: { name: 'skill-asset', positional: [] },@@ -133,6 +139,7 @@ const get_skill_asset: Operation = {};const put_skill: Operation = {name: 'put_skill', description: 'Publish a complete file-canonical skill revision with CAS and a durable receipt. Requires explicit skill editor authority; cannot expand publication policy.',+ idempotent: true,outputRedaction: 'no_stored_text',scope: 'write', requiredScopes: ['skill_editor'], mutating: true,cliHints: { name: 'put-skill', positional: [] },@@ -145,6 +152,7 @@ const put_skill: Operation = {};const delete_skill: Operation = {name: 'delete_skill', description: 'CAS-delete a canonical shared skill and revoke future managed activation. Previously downloaded bytes are not recalled.',+ idempotent: true,outputRedaction: 'no_stored_text',scope: 'write', requiredScopes: ['skill_editor'], mutating: true, params: sharedSkillMutationParams,cliHints: { name: 'delete-skill', positional: [] },@@ -152,6 +160,7 @@ const delete_skill: Operation = {};const import_skill_proposal: Operation = {name: 'import_skill_proposal', description: 'Publish explicitly reviewed human-edited canonical skill files through the durable coordinator. Requires exact current file hashes and skill revision; trusted local operator only.',+ idempotent: true,outputRedaction: 'no_stored_text',scope: 'admin', localOnly: true, mutating: true,params: { ...put_skill.params, expected_hashes: { type: 'object', required: true, description: 'Reviewed current SHA-256 hashes for every affected file and skillpack.json; null denotes an absent file.' } },@@ -159,6 +168,7 @@ const import_skill_proposal: Operation = {};const set_skill_policy: Operation = {name: 'set_skill_policy', description: 'Explicitly approve a versioned shared-skill disclosure and follow policy. Separate publisher authority is required; editing a skill never grants this permission.',+ idempotent: true,outputRedaction: 'no_stored_text',scope: 'admin', requiredScopes: ['skill_publisher'], mutating: true,cliHints: { name: 'set-skill-policy', positional: [] },@@ -170,6 +180,8 @@ const set_skill_policy: Operation = {};const get_skill_policy: Operation = {name: 'get_skill_policy', description: 'Read the owner publication policy and CAS epoch, including when sharing is disabled. Does not approve or change disclosure.',+ mutating: false,+ idempotent: true,outputRedaction: 'no_stored_text',scope: 'admin', requiredScopes: ['skill_publisher'],cliHints: { name: 'skill-policy', positional: [] },@@ -178,6 +190,8 @@ const get_skill_policy: Operation = {};const get_skill_retention: Operation = {name: 'get_skill_retention', description: 'Inspect retained shared-skill revision counts, protected leases and source storage capacity. Trusted host operator only.',+ mutating: false,+ idempotent: true,outputRedaction: 'no_stored_text',scope: 'admin', localOnly: true,cliHints: { name: 'skill-retention', positional: [] },@@ -186,6 +200,7 @@ const get_skill_retention: Operation = {};const prune_skill_revisions: Operation = {name: 'prune_skill_revisions', description: 'Prune one bounded batch of expired shared-skill history. Preserves heads, tombstones, pending publication refs, delivery leases, pins and permanent write receipts.',+ idempotent: false,outputRedaction: 'no_stored_text',scope: 'admin', localOnly: true, mutating: true,cliHints: { name: 'prune-skill-revisions', positional: [] },@@ -194,6 +209,7 @@ const prune_skill_revisions: Operation = {};const retain_skill_revision: Operation = {name: 'retain_skill_revision', description: 'Pin an exact shared-skill revision for up to 24 hours under a bounded operator quota. Does not grant read or execution permission.',+ idempotent: false,outputRedaction: 'no_stored_text',scope: 'admin', localOnly: true, mutating: true,cliHints: { name: 'retain-skill-revision', positional: [] },@@ -205,6 +221,8 @@ const retain_skill_revision: Operation = {const list_brain_skillpack: Operation = {name: 'list_brain_skillpack',+ mutating: false,+ idempotent: true,outputRedaction: { exempt: 'skill catalog files are installed instructions read verbatim; redaction would corrupt approved revisions' },description:'List brain-resident skillpacks this brain ships (per-source). Returns each pack\'s skills, ' +@@ -228,6 +246,8 @@ const list_brain_skillpack: Operation = {const advisor: Operation = {name: 'advisor',+ mutating: false,+ idempotent: true,outputRedaction: 'retrieval',description:'Ranked, read-only "what to do next" for this brain: version drift, pending migrations, ' +@@ -312,6 +332,8 @@ const advisor: Operation = {*/const get_status_snapshot: Operation = {name: 'get_status_snapshot',+ mutating: false,+ idempotent: true,outputRedaction: 'no_stored_text',description: 'Snapshot for `gbrain status` thin-client mode: sync freshness + last cycle + queue depths + worker liveness. Admin-scope.',params: {},diff --git a/src/core/ops/sources.ts b/src/core/ops/sources.tsindex 1566eda5f1..c3679a88e5 100644--- a/src/core/ops/sources.ts+++ b/src/core/ops/sources.ts@@ -15,6 +15,8 @@ import { resolveAuthCapabilities } from '../harness/capabilities.ts';const whoami: Operation = {name: 'whoami',+ mutating: false,+ idempotent: true,outputRedaction: 'no_stored_text',description:'Introspect the calling identity. Returns one of three transport shapes: ' +@@ -71,6 +73,7 @@ const whoami: Operation = {const sources_add: Operation = {name: 'sources_add',+ idempotent: false,outputRedaction: 'no_stored_text',description:'Register a new source. Supports either --path (existing v0.17 behavior) ' +@@ -154,6 +157,8 @@ const sources_add: Operation = {const sources_list: Operation = {name: 'sources_list',+ mutating: false,+ idempotent: true,outputRedaction: 'no_stored_text',description:'List registered sources with page counts and remote_url. v0.28 surfaces ' +@@ -194,6 +199,7 @@ const sources_list: Operation = {const sources_remove: Operation = {name: 'sources_remove',+ idempotent: false,outputRedaction: 'no_stored_text',description:'Hard-remove a source (cascades pages/chunks/embeddings). Refuses to ' +@@ -243,6 +249,8 @@ const sources_remove: Operation = {const sources_status: Operation = {name: 'sources_status',+ mutating: false,+ idempotent: true,outputRedaction: 'no_stored_text',description:'Per-source diagnostic. Returns clone_state ("healthy" | "missing" | ' +@@ -272,6 +280,7 @@ const sources_status: Operation = {const sources_inspect: Operation = {name: 'sources_inspect',+ idempotent: true,outputRedaction: 'no_stored_text',description: 'Inspect committed company Markdown on the trusted local host without importing, registering a source, changing access, or invoking providers.',params: {diff --git a/src/core/ops/sync-status.ts b/src/core/ops/sync-status.tsindex d5ad4b90fa..c9eaec37ab 100644--- a/src/core/ops/sync-status.ts+++ b/src/core/ops/sync-status.ts@@ -12,6 +12,7 @@ import { OperationError } from './contract.ts';const sync_brain: Operation = {name: 'sync_brain',+ idempotent: false,outputRedaction: 'no_stored_text',description: 'Sync git repo to brain (incremental)',params: {diff --git a/src/core/ops/tags.ts b/src/core/ops/tags.tsindex ae712ab5f7..6af46219e4 100644--- a/src/core/ops/tags.ts+++ b/src/core/ops/tags.ts@@ -14,6 +14,7 @@ import { WRITE_REQUEST_PARAM } from '../persistence/params.ts';const add_tag: Operation = {name: 'add_tag',+ idempotent: true,outputRedaction: 'no_stored_text',description: 'Add tag to page',params: {@@ -34,6 +35,7 @@ const add_tag: Operation = {const remove_tag: Operation = {name: 'remove_tag',+ idempotent: true,outputRedaction: 'no_stored_text',description: 'Remove tag from page',params: {@@ -53,6 +55,8 @@ const remove_tag: Operation = {const get_tags: Operation = {name: 'get_tags',+ mutating: false,+ idempotent: true,outputRedaction: 'no_stored_text',description: 'List tags for a page',params: {diff --git a/src/core/ops/takes.ts b/src/core/ops/takes.tsindex 4f110dd6b8..4c74d173e9 100644--- a/src/core/ops/takes.ts+++ b/src/core/ops/takes.ts@@ -31,6 +31,8 @@ import { privatePagesFilterFragment } from '../search/private-visibility.ts';const takes_list: Operation = {name: 'takes_list',+ mutating: false,+ idempotent: true,outputRedaction: 'retrieval',description: 'List takes (typed/weighted/attributed claims) filtered by holder/kind/active/etc.',scope: 'read',@@ -66,6 +68,8 @@ const takes_list: Operation = {const takes_search: Operation = {name: 'takes_search',+ mutating: false,+ idempotent: true,outputRedaction: 'retrieval',description: 'Keyword search across takes (pg_trgm similarity over claim text)',scope: 'read',@@ -93,6 +97,8 @@ const takes_search: Operation = {*/const takes_scorecard: Operation = {name: 'takes_scorecard',+ mutating: false,+ idempotent: true,outputRedaction: 'no_stored_text',description: 'Calibration scorecard for resolved bets: counts, accuracy, Brier (correct ∨ incorrect only), partial_rate.',scope: 'read',@@ -130,6 +136,8 @@ const takes_scorecard: Operation = {*/const takes_calibration: Operation = {name: 'takes_calibration',+ mutating: false,+ idempotent: true,outputRedaction: 'no_stored_text',description: 'Calibration curve: resolved correct/incorrect bets binned by stated weight; observed vs predicted per bucket.',scope: 'read',@@ -190,6 +198,7 @@ async function countMcpResolved(ctx: OperationContext): Promise<number> {const think: Operation = {name: 'think',+ idempotent: false,outputRedaction: 'retrieval',description: 'Multi-hop synthesis across pages + takes + graph. Pulls relevant evidence and produces a cited answer with conflict + gap analysis.',scope: 'read',@@ -396,6 +405,7 @@ function mirrorWarnFields(mirror: { mirror_warning?: string }): Record<string, sconst takes_add: Operation = {name: 'takes_add',+ idempotent: true,outputRedaction: 'no_stored_text',description:'Record a take (typed claim) on a page: fact / take / bet / hunch, with a holder (who ' +@@ -428,6 +438,7 @@ const takes_add: Operation = {const takes_update: Operation = {name: 'takes_update',+ idempotent: true,outputRedaction: 'no_stored_text',description:'Update a take\'s mutable fields (weight, source, since date). Claim/kind/holder are ' +@@ -457,6 +468,7 @@ const takes_update: Operation = {const takes_supersede: Operation = {name: 'takes_supersede',+ idempotent: true,outputRedaction: 'no_stored_text',description:'Supersede a take with a replacement claim: the old row is struck through (kept for ' +@@ -489,6 +501,7 @@ const takes_supersede: Operation = {const takes_resolve: Operation = {name: 'takes_resolve',+ idempotent: true,outputRedaction: 'no_stored_text',description:'Resolve a take: quality correct / incorrect / partial / unresolvable, with optional ' +diff --git a/src/core/ops/timeline.ts b/src/core/ops/timeline.tsindex d28f9c53e1..11251cf43f 100644--- a/src/core/ops/timeline.ts+++ b/src/core/ops/timeline.ts@@ -19,6 +19,7 @@ import {const add_timeline_entry: Operation = {name: 'add_timeline_entry',+ idempotent: true,outputRedaction: 'retrieval',description: 'Append an entry to the canonical Markdown timeline and structured timeline store in one committed write. Exact replay changes neither store.',params: {@@ -62,6 +63,8 @@ const add_timeline_entry: Operation = {const get_timeline: Operation = {name: 'get_timeline',+ mutating: false,+ idempotent: true,outputRedaction: 'retrieval',description: 'Get timeline entries for a page, optionally filtered by date window',params: {diff --git a/src/core/ops/transcripts.ts b/src/core/ops/transcripts.tsindex 8c7968746a..99b23be656 100644--- a/src/core/ops/transcripts.ts+++ b/src/core/ops/transcripts.ts@@ -12,6 +12,8 @@ import { GET_RECENT_TRANSCRIPTS_DESCRIPTION } from '../operations-descriptions.tconst get_recent_transcripts: Operation = {name: 'get_recent_transcripts',+ mutating: false,+ idempotent: true,outputRedaction: 'retrieval',description: GET_RECENT_TRANSCRIPTS_DESCRIPTION,scope: 'read',diff --git a/src/core/ops/usage.ts b/src/core/ops/usage.tsindex c6c8e5c38c..3bbb31f0a3 100644--- a/src/core/ops/usage.ts+++ b/src/core/ops/usage.ts@@ -29,6 +29,8 @@ const n = (v: number | string | null | undefined): number => Number(v ?? 0);const get_usage: Operation = {name: 'get_usage',+ mutating: false,+ idempotent: true,outputRedaction: 'no_stored_text',description:'Aggregate chat usage + cost from the chat_usage_log ledger (per-model and per-phase token counts, cache reads/writes, USD estimates) with explicit coverage fields.',diff --git a/src/core/verbs.ts b/src/core/verbs.tsindex 7f57864d6f..843f2a4511 100644--- a/src/core/verbs.ts+++ b/src/core/verbs.ts@@ -60,6 +60,7 @@ const PROVENANCE_MAX = 500;const remember: Operation = {name: 'remember',+ idempotent: true,outputRedaction: 'no_stored_text',description:'MEMORY VERB (v1): save one fact to durable agent memory — the protocol write verb. ' +@@ -171,6 +172,8 @@ const remember: Operation = {const entity: Operation = {name: 'entity',+ mutating: false,+ idempotent: true,outputRedaction: 'retrieval',description:'MEMORY VERB (v1): inspect ONE known person/company/project card — zero LLM calls, sub-100ms. ' +@@ -226,6 +229,8 @@ const SYNTHESIS_FAILURE_CODES: Record<string, string> = {const synthesize: Operation = {name: 'synthesize',+ mutating: false,+ idempotent: true,outputRedaction: 'retrieval',description:'[EXPENSIVE / SLOW — makes LLM calls, seconds-to-minutes latency, costs money] ' +@@ -349,6 +354,7 @@ const synthesize: Operation = {const forget: Operation = {name: 'forget',+ idempotent: true,outputRedaction: 'no_stored_text',description:'MEMORY VERB (v1): expire a remembered fact by id — the protocol delete verb. ' +diff --git a/src/mcp/tool-defs.ts b/src/mcp/tool-defs.tsindex 0c93f6091f..5910902c01 100644--- a/src/mcp/tool-defs.ts+++ b/src/mcp/tool-defs.ts@@ -78,18 +78,19 @@ function strictPassthroughProperties(op: Operation): Record<string, unknown> {}/**- * #5037: annotation-driven hosts need to tell reads from writes. An op's- * curated `annotations` win as written. Otherwise derive only what existing- * metadata states: `readOnlyHint: true` for a read-scope op explicitly- * tagged `mutating: false`, `readOnlyHint: false` for an op tagged- * `mutating: true` (its destructiveHint keeps the MCP default, true: no- * metadata separates additive from destructive writes). An untagged op- * stays unannotated.+ * #5037 / agent contract A2: annotation-driven hosts need to tell reads from+ * writes. An op's curated `annotations` win as written. Otherwise derive only+ * what the op's required metadata states (every op declares `mutating` and+ * `idempotent`; test/ops-mutation-tags.test.ts): `readOnlyHint: true` iff+ * `mutating === false`; `readOnlyHint: false` iff `mutating === true`, plus+ * `idempotentHint: true` when the write is also `idempotent`.+ * `destructiveHint` and `openWorldHint` keep the MCP defaults (no metadata+ * separates additive from destructive writes yet).*/export function toolAnnotations(op: Operation): McpToolDef['annotations'] | undefined {if (op.annotations) return op.annotations;- if (op.mutating === true) return { readOnlyHint: false };- if (op.mutating === false && op.scope === 'read') return { readOnlyHint: true };+ if (op.mutating === false) return { readOnlyHint: true };+ if (op.mutating === true) return op.idempotent === true ? { readOnlyHint: false, idempotentHint: true } : { readOnlyHint: false };return undefined;}diff --git a/test/cli.test.ts b/test/cli.test.tsindex 7dd5d8818c..428cd142a6 100644--- a/test/cli.test.ts+++ b/test/cli.test.ts@@ -384,4 +384,39 @@ describe('CLI dispatch integration', () => {expect(tools[0]).toHaveProperty('description');expect(tools[0]).toHaveProperty('parameters');});++ test("--tools-json carries each op's access contract after the legacy keys (#5953)", async () => {+ const home = mkdtempSync(join(tmpdir(), 'gbrain-tools-json-'));+ try {+ const proc = Bun.spawn(['bun', 'run', 'src/cli.ts', '--tools-json'], {+ cwd: repoRoot,+ stdout: 'pipe',+ stderr: 'pipe',+ env: isolatedEnv(home),+ });+ const stdout = await new Response(proc.stdout).text();+ expect(await proc.exited).toBe(0);+ const tools = JSON.parse(stdout) as Array<Record<string, unknown>>;+ const byName = new Map(tools.map(t => [t.name as string, t]));++ expect(Object.keys(byName.get('get_page')!)).toEqual([+ 'name', 'description', 'parameters', 'schema', 'scope', 'required_scopes', 'mutating', 'idempotent', 'local_only',+ ]);+ expect(byName.get('get_page')).toMatchObject({ scope: 'read', required_scopes: [], mutating: false, idempotent: true, local_only: false });+ expect(byName.get('put_page')).toMatchObject({ scope: 'write', mutating: true, local_only: false });+ expect(byName.get('think')).toMatchObject({ scope: 'read', mutating: true });+ expect(byName.get('join_brain')).toMatchObject({ scope: 'read', required_scopes: ['skills_member_self'] });+ expect(byName.get('sync_brain')).toMatchObject({ scope: 'admin', local_only: true });++ const { operations } = await import('../src/core/operations.ts');+ for (const op of operations) {+ const t = byName.get(op.name)!;+ expect([t.scope, t.required_scopes, t.mutating, t.idempotent, t.local_only], op.name).toEqual([+ op.scope ?? 'read', op.requiredScopes ?? [], op.mutating === true, op.idempotent === true, op.localOnly === true,+ ]);+ }+ } finally {+ rmSync(home, { recursive: true, force: true });+ }+ });});diff --git a/test/fixtures/goldens/cli/tools-json.json b/test/fixtures/goldens/cli/tools-json.jsonindex f4ec1add0a..f934e42afb 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": 209860,- "stdoutSha256": "1ec5b407e08b2b2333a2f5fe2c24561fa47447bb9303de69902a0bfe562610df",+ "stdoutBytes": 228714,+ "stdoutSha256": "22642f39ac484d951b49ef713364228cf6a3780157f46daea70dfb8ad931fe80","toolNames": ["remember","entity",@@ -164,6 +164,9 @@"tools": [{"description": "MEMORY VERB (v1): save one fact to durable agent memory — the protocol write verb. provenance is REQUIRED (free text, e.g. \"conversation 2026-06-12\", \"user said in chat\", \"import: notes.md\"). Set `entity` whenever the fact is about a specific person/company/project — entity-scoped recall will not find it otherwise. ttl accepts duration shorthand (\"30d\", \"12h\") or an absolute ISO 8601 timestamp; ISO-8601 durations like \"P30D\" are rejected with a fix. visibility defaults to \"world\" (readable by every agent connected to this brain; pass \"private\" for local-CLI-only facts). Response: branch on `status` (inserted|duplicate|superseded), never on `status_text` (human rendering only). On duplicate, `id` is the EXISTING fact's id. For bulk extraction from a raw transcript use extract_facts instead.",+ "idempotent": true,+ "local_only": false,+ "mutating": true,"name": "remember","parameters": {"entity": "string?",@@ -178,6 +181,7 @@"ttl": "string?","visibility": "string?"},+ "required_scopes": [],"schema": {"properties": {"entity": {@@ -241,14 +245,19 @@"provenance"],"type": "object"- }+ },+ "scope": "write"},{"description": "MEMORY VERB (v1): inspect ONE known person/company/project card — zero LLM calls, sub-100ms. Resolution: alias > exact title > slug-suffix; ties break on most-recently-touched. NEVER errors on a miss: returns found:false plus near-miss suggestions with create_safety hints (exists | probable | unknown — whether writing a new page would duplicate). Routing: for facts/snippets retrieval use recall; for broad questions needing reasoning use synthesize (expensive).",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "entity","parameters": {"name": "string"},+ "required_scopes": [],"schema": {"properties": {"name": {@@ -260,16 +269,21 @@"name"],"type": "object"- }+ },+ "scope": "read"},{"description": "[EXPENSIVE / SLOW — makes LLM calls, seconds-to-minutes latency, costs money] MEMORY VERB (v1): answer a broad question using cross-page LLM reasoning with citations and gap analysis. Prefer recall (facts/snippets) or entity (one known card, zero LLM) for lookups — use synthesize only when the answer requires combining evidence across pages. Response carries a best-effort cost block (model, tokens, usd_estimate) plus compose-status fields (synthesis_status, pages_gathered, takes_gathered, warnings); when the LLM compose step fails but retrieval succeeded, `answer` degrades to an extractive digest of retrieved pages (synthesis_status: \"extractive_fallback\") instead of an error.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "synthesize","parameters": {"question": "string","since": "string?","until": "string?"},+ "required_scopes": [],"schema": {"properties": {"question": {@@ -289,16 +303,21 @@"question"],"type": "object"- }+ },+ "scope": "read"},{"description": "MEMORY VERB (v1): expire a remembered fact by id — the protocol delete verb. `id` is the opaque string id returned by remember and recall (facts[].fact_id) — never a page slug. Idempotent: forgetting an already-expired fact returns expired:false (success), unknown id returns a not_found error. The fact is expired (audit trail kept), not deleted.",+ "idempotent": true,+ "local_only": false,+ "mutating": true,"name": "forget","parameters": {"id": "string","reason": "string?","request_id": "string?"},+ "required_scopes": [],"schema": {"properties": {"id": {@@ -318,10 +337,14 @@"id"],"type": "object"- }+ },+ "scope": "write"},{"description": "Read a page by slug (supports optional fuzzy matching). Slug aliases left by renames redirect to the canonical page in the source that owns the alias (archived sources excluded); a redirected read reports `resolved_slug`. To edit a page, pass include_content: true — the returned `content` field is the canonical full markdown (frontmatter + body + timeline sentinel); edit THAT and pass it back to put_page to round-trip losslessly. Reassembling compiled_truth/timeline by hand risks dropping sections. Soft-deleted pages are hidden by default; pass include_deleted: true to surface them with deleted_at populated (see v0.26.5 recovery window). `timeline` is only the markdown section after the timeline sentinel; entries written by add_timeline_entry or extraction live in timeline rows, which include_timeline_entries: true returns as `timeline_entries` (the same rows get_timeline returns).",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "get_page","parameters": {"fuzzy": "boolean?",@@ -331,6 +354,7 @@"slug": "string","source_id": "string?"},+ "required_scopes": [],"schema": {"properties": {"fuzzy": {@@ -362,10 +386,14 @@"slug"],"type": "object"- }+ },+ "scope": "read"},{"description": "Replace a complete canonical Markdown page. Read get_page with include_content:true and pass its revision as expected_revision; force explicitly overwrites the current revision. Omitting both permits creation only. Retain a UUID request_id and repeat identical arguments after transport failure or a pending receipt. Content, tags, sanitized text projections, versions and the committed receipt publish together; embedding and optional Git effects have separate status. Remote callers preserve protected facts/takes fences; automatic graph links are skipped for untrusted writes. A stdio `gbrain serve` sweeps them at startup + on idle; `gbrain serve --http` does not self-sweep — run `gbrain sweep --once` or use trusted local capture/put_page for inline link extraction. Remote callers receive write_through.warning when no repo is configured. For file input use gbrain capture --file PATH --slug SLUG.",+ "idempotent": true,+ "local_only": false,+ "mutating": true,"name": "put_page","parameters": {"allow_empty": "boolean?",@@ -379,6 +407,7 @@"source_kind": "string?","source_uri": "string?"},+ "required_scopes": [],"schema": {"properties": {"allow_empty": {@@ -427,10 +456,14 @@"content"],"type": "object"- }+ },+ "scope": "write"},{"description": "Soft-delete a page and remove its markdown file from the source working tree (the source local_path, or sync.repo_path when the source has none). File removal is skipped when sync.write_through is off; the committed receipt reports the persistence mode and write_through outcome. Read the page revision first and pass expected_revision; retain request_id for replay. The row is hidden from search and from get_page/list_pages, but is recoverable via restore_page within 72h, which re-creates the file. The autopilot purge phase hard-deletes after the recovery window. Pass include_deleted: true to get_page to verify the soft-delete landed. purge: true is trusted-local CLI only and removes the row, chunks, links and raw data immediately after its recorded markdown artifact is removed. Purge uses the same revision, request_id and recovery protocol, including for existing tombstones. A removal failure preserves the prior row and never reports purge success; repair the artifact and submit a new request_id. A committed purge warns that git history, synced copies, exports and derived rows may retain content; rotate exposed credentials.",+ "idempotent": true,+ "local_only": false,+ "mutating": true,"name": "delete_page","parameters": {"expected_revision": "string?",@@ -440,6 +473,7 @@"slug": "string","source_id": "string?"},+ "required_scopes": [],"schema": {"properties": {"expected_revision": {@@ -471,10 +505,14 @@"slug"],"type": "object"- }+ },+ "scope": "write"},{"description": "List pages with optional filters. For 'what's recent / what did I touch this week' questions, use list_pages with sort=updated_desc instead of semantic search. Default 50 rows; remote callers are capped at 100 (local CLI callers' explicit limits are honored). A result with exactly `limit` rows may be truncated. For exhaustive listing, page with updated_after=<last row's updated_at_iso> + updated_after_slug=<last row's slug> until a page returns fewer rows than the limit (the keyset forces sort=updated_asc; a bare updated_after cursor skips rows sharing the cursor timestamp).",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "list_pages","parameters": {"include_deleted": "boolean?",@@ -487,6 +525,7 @@"updated_after": "string?","updated_after_slug": "string?"},+ "required_scopes": [],"schema": {"properties": {"include_deleted": {@@ -534,10 +573,14 @@},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "v0.26.5 — restore a soft-deleted page (clear deleted_at) and re-create its markdown file on disk (the counterpart to delete_page removing it; the result write_through field reports the outcome). Returns success only if the page was actually soft-deleted. After this op, the page reappears in search and in get_page/list_pages without the include_deleted flag.",+ "idempotent": true,+ "local_only": false,+ "mutating": true,"name": "restore_page","parameters": {"expected_revision": "string?",@@ -546,6 +589,7 @@"slug": "string","source_id": "string?"},+ "required_scopes": [],"schema": {"properties": {"expected_revision": {@@ -573,14 +617,19 @@"slug"],"type": "object"- }+ },+ "scope": "write"},{"description": "v0.26.5 — admin-only. Hard-deletes pages whose deleted_at is older than older_than_hours (default 72). Cascades through content_chunks, page_links, chunk_relations. Local CLI only (not exposed over HTTP MCP). Manual escape hatch alongside the autopilot purge phase.",+ "idempotent": false,+ "local_only": true,+ "mutating": true,"name": "purge_deleted_pages","parameters": {"older_than_hours": "number?"},+ "required_scopes": [],"schema": {"properties": {"older_than_hours": {@@ -590,10 +639,14 @@},"required": [],"type": "object"- }+ },+ "scope": "admin"},{"description": "Capture a quick note into the brain — the \"just remember this\" write. Auto-derives a stable inbox/ slug from the content date + hash (recapturing identical text is idempotent), merges frontmatter, refuses binary/empty payloads, then delegates to put_page (inheriting its fences and provenance stamping). Prefer capture for quick notes and put_page when you need to control the slug, type, or an existing page's content. For structured facts about entities, prefer remember.",+ "idempotent": true,+ "local_only": false,+ "mutating": true,"name": "capture","parameters": {"content": "string",@@ -610,6 +663,7 @@"where": "string?","who": "string?"},+ "required_scopes": [],"schema": {"properties": {"content": {@@ -669,14 +723,19 @@"content"],"type": "object"- }+ },+ "scope": "write"},{"description": "Fetch the full text of one search result by its opaque, source-qualified `id` (OpenAI deep-research contract: the search/fetch pair). Pass the id unchanged; it does not grant access. Legacy slug ids work only when unambiguous within your current read scope. Returns { id, title, text, url, metadata } — `text` is the page's canonical markdown. For fuzzy slugs, soft-delete recovery, or lossless edit round-trips, use get_page.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "fetch","parameters": {"id": "string"},+ "required_scopes": [],"schema": {"properties": {"id": {@@ -688,10 +747,14 @@"id"],"type": "object"- }+ },+ "scope": "read"},{"description": "Change part of an existing page without resending it: prefer this over put_page for small changes to large pages. Read get_page with include_content:true and pass its revision as expected_revision. Each edit replaces old_text with new_text; edits apply in order, each to the text the previous edit produced, and each old_text must match exactly once in that content. Protected takes and facts sections never match (use the takes_* operations or remember/forget). All edits publish together or none do, through the same receipts, fences and write-through as put_page. Returns the new revision and a unified diff of your view (at most 8 KB). Refusals name the edit: edit_no_match, edit_ambiguous_match (with match_count), edit_protected_span, edit_invalid; a stale revision returns revision_conflict with current_revision. Retain request_id and repeat identical arguments after a pending receipt.",+ "idempotent": true,+ "local_only": false,+ "mutating": true,"name": "edit_page","parameters": {"edits": "array",@@ -700,6 +763,7 @@"slug": "string","source_id": "string?"},+ "required_scopes": [],"schema": {"properties": {"edits": {@@ -747,14 +811,19 @@"edits"],"type": "object"- }+ },+ "scope": "write"},{"description": "Read your durable write receipt by request_id. Requires write scope and this operation in the current grant. Foreign, missing, and no-longer-accessible requests return the same not_found error; private journal input and recovery bytes are never returned.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "get_write_request","parameters": {"request_id": "string"},+ "required_scopes": [],"schema": {"properties": {"request_id": {@@ -766,16 +835,21 @@"request_id"],"type": "object"- }+ },+ "scope": "write"},{"description": "List your currently authorized write receipts in one source, newest first. Useful when an acknowledgment was lost. Results and pagination exclude other principals and inaccessible targets; no private payloads or cross-principal queue counts are exposed.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "list_write_requests","parameters": {"before": "string?","limit": "number?","source_id": "string?"},+ "required_scopes": [],"schema": {"properties": {"before": {@@ -794,14 +868,19 @@},"required": [],"type": "object"- }+ },+ "scope": "write"},{"description": "Cancel your accepted write before publication starts. Returns the actual receipt: running/recovering or already-terminal requests may remain unchanged. Cancellation cannot undo published bytes or a committed fact withdrawal.",+ "idempotent": true,+ "local_only": false,+ "mutating": true,"name": "cancel_write_request","parameters": {"request_id": "string"},+ "required_scopes": [],"schema": {"properties": {"request_id": {@@ -813,10 +892,14 @@"request_id"],"type": "object"- }+ },+ "scope": "write"},{"description": "Cheap hybrid search (vector + keyword + RRF) with no LLM expansion. Best for exact known tokens, names, and structured-field lookups. A populated result set is NOT proof of coverage — for concept / synonym / landscape questions use `query` (adds multi-query expansion); for exhaustive enumeration use list_pages pagination. Pass `return_unit` ('window' / 'section' / 'page') for whole evidence instead of chunks; conversation pages already come back whole by default (return_unit 'auto'; 'chunk' opts out). For personal/emotional questions, prefer get_recent_salience or find_anomalies — they surface activity bursts without needing a search term. For code-symbol questions (callers, callees, definitions, blast radius), use code_callers / code_callees / code_def / code_refs instead — those return structural graph data, not text chunks. For agent memory reads (saved facts + budget-packed retrieval), prefer the `recall` verb.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "search","parameters": {"limit": "number?",@@ -832,6 +915,7 @@"token_budget": "number?","types": "array?"},+ "required_scopes": [],"schema": {"properties": {"limit": {@@ -907,10 +991,14 @@"query"],"type": "object"- }+ },+ "scope": "read"},{"description": "Hybrid search with vector + keyword + multi-query expansion. Prefer `query` for concept / synonym / landscape questions ('all the X that do Y', 'the landscape of Z') — expansion recovers synonym- and outcome-phrased matches a single embedding misses. Still top-K, and the default count when `limit` is omitted depends on the configured search mode (10 conservative / 25 balanced / 50 tokenmax — see the `limit` param description); pass `limit` explicitly for a stable count regardless of mode. When the answer needs the surrounding conversation or section, pass `return_unit` ('page' / 'section' / 'window') to get that evidence in one call instead of get_page per hit; conversation pages already come back whole by default (return_unit 'auto'; 'chunk' opts out). For exhaustive enumeration use list_pages; for exact known tokens `search` is cheaper (no expansion LLM call). For personal/emotional questions ('what's going on with me', 'anything notable', 'how am I feeling'), prefer get_recent_salience, find_anomalies, or get_recent_transcripts. Semantic search returns polished pages and misses recent activity bursts. Do NOT assume words like 'crazy', 'notable', or 'big' mean impressive — they often mean difficult or emotionally charged.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "query","parameters": {"adaptive_return": "boolean?",@@ -941,6 +1029,7 @@"until": "string?","walk_depth": "number?"},+ "required_scopes": [],"schema": {"properties": {"adaptive_return": {@@ -1080,10 +1169,14 @@},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "Deliver whole evidence for an ordered list of search hits (each {source_id, slug, chunk_id} from a prior search/query result): the same windows, sections or pages `query` returns with return_unit, packed into token_budget. Use it to widen hits you already have instead of calling get_page per hit. Returns { results, delivery, unresolved }; results carry chunk_text (the evidence) and `delivered`.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "assemble_evidence","parameters": {"detail": "string?",@@ -1092,6 +1185,7 @@"return_window": "number?","token_budget": "number?"},+ "required_scopes": [],"schema": {"properties": {"detail": {@@ -1134,14 +1228,19 @@"hits"],"type": "object"- }+ },+ "scope": "read"},{"description": "Search observability over a window: cache hit rate, intent/mode mix, budget drops, rank-1 score drift, graph-signals failure counts. Same payload as the search-stats dashboard JSON. Coverage caveat: telemetry is best-effort (short-lived CLI calls may not flush), so zero counts can reflect the coverage gap rather than zero usage.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "search_stats","parameters": {"days": "number?"},+ "required_scopes": [],"schema": {"properties": {"days": {@@ -1151,40 +1250,59 @@},"required": [],"type": "object"- }+ },+ "scope": "admin"},{"description": "Read-only search-mode dashboard: active mode, EVERY mode-bundle knob resolved with attribution (mode default vs config override), the three frozen bundles, and a reranker_readiness verdict (whether the resolved reranker will actually run; remote callers get the verdict without the host key inventory). Brain-level planes only — per-call SearchOpts overrides on individual searches are not shown (per_call_note in the payload spells this out). Never mutates; to change modes, tell the user to set the search.mode config key on the brain host.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "search_modes","parameters": {},+ "required_scopes": [],"schema": {"properties": {},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "Read-only tuning recommendations derived from the last 7 days of search telemetry: what should change, why, and the paste-ready config command per recommendation — relay them to the user. Applying is CLI-only by design [CDX-21]: this op NEVER mutates config.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "search_tune","parameters": {},+ "required_scopes": [],"schema": {"properties": {},"required": [],"type": "object"- }+ },+ "scope": "admin"},{"description": "Semantic query-cache introspection: resolved knobs (enabled, similarity threshold, TTL) plus row counts and total hits. Read-only; clearing/pruning the cache stays on the CLI.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "cache_stats","parameters": {},+ "required_scopes": [],"schema": {"properties": {},"required": [],"type": "object"- }+ },+ "scope": "admin"},{"description": "v0.36 cross-modal Phase 2: image-as-query retrieval. Accepts a local path (CLI), data: URI, or http(s):// URL (SSRF-defended). Returns visually-similar image chunks plus any OCR text they carry. Optional `query` text refinement merges via weighted RRF (D13 hybrid intersect). True image→full-text-knowledge requires Phase 3 (`gbrain reindex --multimodal` + `search.unified_multimodal: true`).",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "search_by_image","parameters": {"image_data": "string?",@@ -1196,6 +1314,7 @@"query": "string?","source_id": "string?"},+ "required_scopes": [],"schema": {"properties": {"image_data": {@@ -1233,16 +1352,21 @@},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "Add tag to page",+ "idempotent": true,+ "local_only": false,+ "mutating": true,"name": "add_tag","parameters": {"request_id": "string?","slug": "string","tag": "string"},+ "required_scopes": [],"schema": {"properties": {"request_id": {@@ -1263,16 +1387,21 @@"tag"],"type": "object"- }+ },+ "scope": "write"},{"description": "Remove tag from page",+ "idempotent": true,+ "local_only": false,+ "mutating": true,"name": "remove_tag","parameters": {"request_id": "string?","slug": "string","tag": "string"},+ "required_scopes": [],"schema": {"properties": {"request_id": {@@ -1293,14 +1422,19 @@"tag"],"type": "object"- }+ },+ "scope": "write"},{"description": "List tags for a page",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "get_tags","parameters": {"slug": "string"},+ "required_scopes": [],"schema": {"properties": {"slug": {@@ -1312,10 +1446,14 @@"slug"],"type": "object"- }+ },+ "scope": "read"},{"description": "Create link between pages",+ "idempotent": false,+ "local_only": false,+ "mutating": true,"name": "add_link","parameters": {"context": "string?",@@ -1324,6 +1462,7 @@"link_type": "string?","to": "string"},+ "required_scopes": [],"schema": {"properties": {"context": {@@ -1352,10 +1491,14 @@"to"],"type": "object"- }+ },+ "scope": "write"},{"description": "Remove link between pages",+ "idempotent": false,+ "local_only": false,+ "mutating": true,"name": "remove_link","parameters": {"from": "string",@@ -1363,6 +1506,7 @@"link_type": "string?","to": "string"},+ "required_scopes": [],"schema": {"properties": {"from": {@@ -1387,16 +1531,21 @@"to"],"type": "object"- }+ },+ "scope": "write"},{"description": "List outgoing links from a page",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "get_links","parameters": {"all_sources": "boolean?","slug": "string","source_id": "string?"},+ "required_scopes": [],"schema": {"properties": {"all_sources": {@@ -1416,16 +1565,21 @@"slug"],"type": "object"- }+ },+ "scope": "read"},{"description": "List incoming links to a page",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "get_backlinks","parameters": {"all_sources": "boolean?","slug": "string","source_id": "string?"},+ "required_scopes": [],"schema": {"properties": {"all_sources": {@@ -1445,20 +1599,29 @@"slug"],"type": "object"- }+ },+ "scope": "read"},{"description": "List distinct link_source provenances in the brain with edge counts (e.g. citation-graph, manual, markdown)",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "list_link_sources","parameters": {},+ "required_scopes": [],"schema": {"properties": {},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "Traverse link graph from a page. Remote callers default to bidirectional edges (GraphPath[]) at depth 2 (pass depth explicitly for deeper walks); trusted local no-filter callers keep the legacy node shape at depth 5.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "traverse_graph","parameters": {"all_sources": "boolean?",@@ -1468,6 +1631,7 @@"slug": "string","source_id": "string?"},+ "required_scopes": [],"schema": {"properties": {"all_sources": {@@ -1504,10 +1668,14 @@"slug"],"type": "object"- }+ },+ "scope": "read"},{"description": "Append an entry to the canonical Markdown timeline and structured timeline store in one committed write. Exact replay changes neither store.",+ "idempotent": true,+ "local_only": false,+ "mutating": true,"name": "add_timeline_entry","parameters": {"date": "string",@@ -1517,6 +1685,7 @@"source": "string?","summary": "string"},+ "required_scopes": [],"schema": {"properties": {"date": {@@ -1550,10 +1719,14 @@"summary"],"type": "object"- }+ },+ "scope": "write"},{"description": "Get timeline entries for a page, optionally filtered by date window",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "get_timeline","parameters": {"after": "string?",@@ -1563,6 +1736,7 @@"slug": "string","until": "string?"},+ "required_scopes": [],"schema": {"properties": {"after": {@@ -1594,44 +1768,64 @@"slug"],"type": "object"- }+ },+ "scope": "read"},{"description": "Brain statistics (page count, chunk count, etc.) — remote callers see counters confined to their source grant.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "get_stats","parameters": {},+ "required_scopes": [],"schema": {"properties": {},"required": [],"type": "object"- }+ },+ "scope": "admin"},{"description": "Brain health dashboard (embed coverage, stale pages, orphans) — remote callers see counters confined to their source grant. Includes a `migrations {pending, partial, wedged, skipped_future}` block from the host migration ledger so remote agents can detect wedged/outstanding host migrations without shelling into the brain host. `computed_at` is when the counters were read: a repeat call within `health.cache_ttl_ms` (default 30000; env GBRAIN_HEALTH_CACHE_TTL_MS; 0 disables) with no page or config change returns the memoized numbers.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "get_health","parameters": {},+ "required_scopes": [],"schema": {"properties": {},"required": [],"type": "object"- }+ },+ "scope": "admin"},{"description": "Run brain health checks and return a structured DoctorReport (thin-client doctor surface).",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "run_doctor","parameters": {},+ "required_scopes": [],"schema": {"properties": {},"required": [],"type": "object"- }+ },+ "scope": "admin"},{"description": "Page version history. Trusted local and admin callers also get written_by and archived_by (who wrote each snapshot and whose write archived it).",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "get_versions","parameters": {"slug": "string"},+ "required_scopes": [],"schema": {"properties": {"slug": {@@ -1643,10 +1837,14 @@"slug"],"type": "object"- }+ },+ "scope": "read"},{"description": "Revert page to a previous version",+ "idempotent": true,+ "local_only": false,+ "mutating": true,"name": "revert_version","parameters": {"expected_revision": "string?",@@ -1656,6 +1854,7 @@"source_id": "string?","version_id": "number"},+ "required_scopes": [],"schema": {"properties": {"expected_revision": {@@ -1688,26 +1887,36 @@"version_id"],"type": "object"- }+ },+ "scope": "write"},{"description": "Brain identity + counters for thin-client banner — remote callers see counters confined to their source grant. Returns version, engine kind, and page/chunk counts. Read-scope.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "get_brain_identity","parameters": {},+ "required_scopes": [],"schema": {"properties": {},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "List quarantined (hidden) and optionally content-flagged pages by scanning page frontmatter, newest-updated first. When truncated is true, count is a LOWER BOUND — raise max_scan/limit or run the quarantine list command on the brain host for the full set. Clearing a marker is a local-only trust decision (CLI).",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "quarantine_list","parameters": {"include_flagged": "boolean?","limit": "number?","max_scan": "number?"},+ "required_scopes": [],"schema": {"properties": {"include_flagged": {@@ -1725,10 +1934,14 @@},"required": [],"type": "object"- }+ },+ "scope": "admin"},{"description": "Admin read: who created and who last changed a page, or one of its facts, takes or timeline entries. Each attribution names the request id, operation, principal (kind, id, current name), time and origin (request, maintenance or unrecorded). Remote callers stay inside their source grant and see only world facts.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "get_write_attribution","parameters": {"fact": "number?",@@ -1737,6 +1950,7 @@"timeline": "number?","versions": "boolean?"},+ "required_scopes": [],"schema": {"properties": {"fact": {@@ -1764,10 +1978,14 @@"slug"],"type": "object"- }+ },+ "scope": "admin"},{"description": "List the skills this agent's brain publishes. A skill is a named prose instruction set (NOT executable code) that teaches you how to do a task using this server's other tools. Returns a flat catalog — each entry has a name, one-line description, triggers (phrasings that should invoke it), and `usable_tools` / `unavailable_tools` (which tools the skill calls that you CAN vs CANNOT call given this server + your access). To actually use a skill, call get_skill with its name, read the returned prose, and follow it — calling the correspondingly-named tools on THIS server. The response also carries an `instructions` envelope explaining this protocol. On a shared brain, use schema_version:2 for source-qualified identities, immutable revisions, pagination and complete declared requirements. Only authorized sources and owner-approved file classes are visible; pre-migration servers retain their legacy prose catalog. Read-scope; published only when the brain owner enabled mcp.publish_skills.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "list_skills","parameters": {"cursor": "string?",@@ -1776,6 +1994,7 @@"section": "string?","source_id": "string?"},+ "required_scopes": [],"schema": {"properties": {"cursor": {@@ -1801,10 +2020,14 @@},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "Fetch one skill's full instructions by name. Returns `{name, frontmatter (sanitized), body, usable_tools, unavailable_tools, client_guidance}`. The `body` is prose — read it as your operating instructions for this task, and when it says to search / store / look something up, call the same-named MCP tool on THIS server. There is nothing to 'execute' — the value is the instructions plus your tool calls back to this server. Tools listed in `unavailable_tools` won't work for you (not exposed here, or beyond your access) — adapt accordingly. Size-capped; read-scope; requires the owner to have enabled mcp.publish_skills. On a shared brain, pass schema_version:2 with qualified_id and revision from discovery to fetch exact instructions and their approved dependency manifest. get_skill_asset retrieves declared files from that revision as data; downloading never grants execution or tool permissions.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "get_skill","parameters": {"expected_brain_id": "string?",@@ -1816,6 +2039,7 @@"source_id": "string?","source_incarnation": "string?"},+ "required_scopes": [],"schema": {"properties": {"expected_brain_id": {@@ -1853,40 +2077,59 @@},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "List brain-resident skillpacks this brain ships (per-source). Returns each pack's skills, one-line descriptions, the schema pack it targets + whether that matches this brain, and a git scaffold spec. Read-only; gated by mcp.publish_skills. After orienting, call this and ask the user whether to install any pack the brain offers (gbrain skillpack scaffold <spec>).",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "list_brain_skillpack","parameters": {},+ "required_scopes": [],"schema": {"properties": {},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "Ranked, read-only \"what to do next\" for this brain: version drift, pending migrations, schema-pack issues, stalled jobs, usage-shape gaps, and setup smells. Each finding has a severity, why-it-matters, and the exact fix command. Never mutates. Tell the user; ask before running any fix. Gated by mcp.publish_advisor (separate from mcp.publish_skills because diagnostics are not prose skills).",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "advisor","parameters": {},+ "required_scopes": [],"schema": {"properties": {},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "Snapshot for `gbrain status` thin-client mode: sync freshness + last cycle + queue depths + worker liveness. Admin-scope.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "get_status_snapshot","parameters": {},+ "required_scopes": [],"schema": {"properties": {},"required": [],"type": "object"- }+ },+ "scope": "admin"},{"description": "Read a bounded, owner-approved file from an exact sealed skill revision. Does not execute downloaded bytes.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "get_skill_asset","parameters": {"expected_brain_id": "string?",@@ -1898,6 +2141,7 @@"source_id": "string?","source_incarnation": "string?"},+ "required_scopes": [],"schema": {"properties": {"expected_brain_id": {@@ -1938,10 +2182,14 @@"path"],"type": "object"- }+ },+ "scope": "read"},{"description": "Publish a complete file-canonical skill revision with CAS and a durable receipt. Requires explicit skill editor authority; cannot expand publication policy.",+ "idempotent": true,+ "local_only": false,+ "mutating": true,"name": "put_skill","parameters": {"description": "string?",@@ -1956,6 +2204,9 @@"source_incarnation": "string?","triggers": "array?"},+ "required_scopes": [+ "skill_editor"+ ],"schema": {"properties": {"description": {@@ -2019,10 +2270,14 @@"files"],"type": "object"- }+ },+ "scope": "write"},{"description": "CAS-delete a canonical shared skill and revoke future managed activation. Previously downloaded bytes are not recalled.",+ "idempotent": true,+ "local_only": false,+ "mutating": true,"name": "delete_skill","parameters": {"expected_revision": "string?",@@ -2032,6 +2287,9 @@"source_id": "string?","source_incarnation": "string?"},+ "required_scopes": [+ "skill_editor"+ ],"schema": {"properties": {"expected_revision": {@@ -2065,16 +2323,23 @@"request_id"],"type": "object"- }+ },+ "scope": "write"},{"description": "Explicitly approve a versioned shared-skill disclosure and follow policy. Separate publisher authority is required; editing a skill never grants this permission.",+ "idempotent": true,+ "local_only": false,+ "mutating": true,"name": "set_skill_policy","parameters": {"expected_policy_epoch": "string?","policy": "object","source_id": "string"},+ "required_scopes": [+ "skill_publisher"+ ],"schema": {"properties": {"expected_policy_epoch": {@@ -2095,14 +2360,21 @@"policy"],"type": "object"- }+ },+ "scope": "admin"},{"description": "Read the owner publication policy and CAS epoch, including when sharing is disabled. Does not approve or change disclosure.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "get_skill_policy","parameters": {"source_id": "string"},+ "required_scopes": [+ "skill_publisher"+ ],"schema": {"properties": {"source_id": {@@ -2114,14 +2386,19 @@"source_id"],"type": "object"- }+ },+ "scope": "admin"},{"description": "Inspect retained shared-skill revision counts, protected leases and source storage capacity. Trusted host operator only.",+ "idempotent": true,+ "local_only": true,+ "mutating": false,"name": "get_skill_retention","parameters": {"source_id": "string?"},+ "required_scopes": [],"schema": {"properties": {"source_id": {@@ -2131,14 +2408,19 @@},"required": [],"type": "object"- }+ },+ "scope": "admin"},{"description": "Prune one bounded batch of expired shared-skill history. Preserves heads, tombstones, pending publication refs, delivery leases, pins and permanent write receipts.",+ "idempotent": false,+ "local_only": true,+ "mutating": true,"name": "prune_skill_revisions","parameters": {"source_id": "string?"},+ "required_scopes": [],"schema": {"properties": {"source_id": {@@ -2148,10 +2430,14 @@},"required": [],"type": "object"- }+ },+ "scope": "admin"},{"description": "Pin an exact shared-skill revision for up to 24 hours under a bounded operator quota. Does not grant read or execution permission.",+ "idempotent": false,+ "local_only": true,+ "mutating": true,"name": "retain_skill_revision","parameters": {"hours": "number?",@@ -2161,6 +2447,7 @@"source_id": "string?","source_incarnation": "string"},+ "required_scopes": [],"schema": {"properties": {"hours": {@@ -2195,10 +2482,14 @@"revision"],"type": "object"- }+ },+ "scope": "admin"},{"description": "Publish explicitly reviewed human-edited canonical skill files through the durable coordinator. Requires exact current file hashes and skill revision; trusted local operator only.",+ "idempotent": true,+ "local_only": true,+ "mutating": true,"name": "import_skill_proposal","parameters": {"description": "string?",@@ -2214,6 +2505,7 @@"source_incarnation": "string?","triggers": "array?"},+ "required_scopes": [],"schema": {"properties": {"description": {@@ -2282,15 +2574,22 @@"expected_hashes"],"type": "object"- }+ },+ "scope": "admin"},{"description": "Enroll this authenticated principal to follow approved shared skills. Shared credentials are one principal. Never grants memory-write or editor authority.",+ "idempotent": false,+ "local_only": false,+ "mutating": true,"name": "join_brain","parameters": {"adapter": "string","follow_policy": "object"},+ "required_scopes": [+ "skills_member_self"+ ],"schema": {"properties": {"adapter": {@@ -2307,16 +2606,23 @@"follow_policy"],"type": "object"- }+ },+ "scope": "read"},{"description": "Get a complete authorized shared-skills view and optionally record an own issued-batch delivery acknowledgment. Unavailable is never an empty catalog.",+ "idempotent": false,+ "local_only": false,+ "mutating": true,"name": "sync_brain_skills","parameters": {"acknowledgment": "object?","enrollment_epoch": "number","installation_id": "string"},+ "required_scopes": [+ "skills_member_self"+ ],"schema": {"properties": {"acknowledgment": {@@ -2337,15 +2643,22 @@"enrollment_epoch"],"type": "object"- }+ },+ "scope": "read"},{"description": "Stop only this principal’s enrollment. Does not revoke credentials or prove native cached instructions were disabled.",+ "idempotent": false,+ "local_only": false,+ "mutating": true,"name": "leave_brain","parameters": {"enrollment_epoch": "number","installation_id": "string"},+ "required_scopes": [+ "skills_member_self"+ ],"schema": {"properties": {"enrollment_epoch": {@@ -2362,10 +2675,14 @@"enrollment_epoch"],"type": "object"- }+ },+ "scope": "read"},{"description": "Sync git repo to brain (incremental)",+ "idempotent": false,+ "local_only": true,+ "mutating": true,"name": "sync_brain","parameters": {"dry_run": "boolean?",@@ -2375,6 +2692,7 @@"repo": "string?","source_id": "string?"},+ "required_scopes": [],"schema": {"properties": {"dry_run": {@@ -2404,16 +2722,21 @@},"required": [],"type": "object"- }+ },+ "scope": "admin"},{"description": "Store raw API response data for a page",+ "idempotent": false,+ "local_only": false,+ "mutating": true,"name": "put_raw_data","parameters": {"data": "object","slug": "string","source": "string"},+ "required_scopes": [],"schema": {"properties": {"data": {@@ -2435,15 +2758,20 @@"data"],"type": "object"- }+ },+ "scope": "write"},{"description": "Retrieve raw data for a page. Raw data follows the page's soft-delete: a tombstoned (soft-deleted) page returns [] exactly like a missing page; restore_page brings the rows back, and get_page include_deleted: true verifies the tombstone.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "get_raw_data","parameters": {"slug": "string","source": "string?"},+ "required_scopes": [],"schema": {"properties": {"slug": {@@ -2459,15 +2787,20 @@"slug"],"type": "object"- }+ },+ "scope": "read"},{"description": "Fuzzy-resolve a partial slug to matching page slugs",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "resolve_slugs","parameters": {"partial": "string","source_id": "string?"},+ "required_scopes": [],"schema": {"properties": {"partial": {@@ -2483,14 +2816,19 @@"partial"],"type": "object"- }+ },+ "scope": "read"},{"description": "Get content chunks for a page",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "get_chunks","parameters": {"slug": "string"},+ "required_scopes": [],"schema": {"properties": {"slug": {@@ -2502,10 +2840,14 @@"slug"],"type": "object"- }+ },+ "scope": "read"},{"description": "Log an ingestion event",+ "idempotent": false,+ "local_only": false,+ "mutating": true,"name": "log_ingest","parameters": {"pages_updated": "array",@@ -2513,6 +2855,7 @@"source_type": "string","summary": "string"},+ "required_scopes": [],"schema": {"properties": {"pages_updated": {@@ -2542,14 +2885,19 @@"summary"],"type": "object"- }+ },+ "scope": "write"},{"description": "Get recent ingestion log entries",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "get_ingest_log","parameters": {"limit": "number?"},+ "required_scopes": [],"schema": {"properties": {"limit": {@@ -2559,14 +2907,19 @@},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "Aggregate chat usage + cost from the chat_usage_log ledger (per-model and per-phase token counts, cache reads/writes, USD estimates) with explicit coverage fields.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "get_usage","parameters": {"days": "number?"},+ "required_scopes": [],"schema": {"properties": {"days": {@@ -2576,14 +2929,19 @@},"required": [],"type": "object"- }+ },+ "scope": "admin"},{"description": "List stored files",+ "idempotent": true,+ "local_only": true,+ "mutating": false,"name": "file_list","parameters": {"slug": "string?"},+ "required_scopes": [],"schema": {"properties": {"slug": {@@ -2593,15 +2951,20 @@},"required": [],"type": "object"- }+ },+ "scope": "admin"},{"description": "Upload a file to storage",+ "idempotent": false,+ "local_only": true,+ "mutating": true,"name": "file_upload","parameters": {"page_slug": "string?","path": "string"},+ "required_scopes": [],"schema": {"properties": {"page_slug": {@@ -2617,14 +2980,19 @@"path"],"type": "object"- }+ },+ "scope": "admin"},{"description": "Get a URL for a stored file",+ "idempotent": true,+ "local_only": true,+ "mutating": false,"name": "file_url","parameters": {"storage_path": "string"},+ "required_scopes": [],"schema": {"properties": {"storage_path": {@@ -2635,10 +3003,14 @@"storage_path"],"type": "object"- }+ },+ "scope": "admin"},{"description": "Submit a background job. Remote callers may submit sync, import, lint or lint-fix for their authenticated filesystem source. Other kinds require local CLI or a dedicated operation.",+ "idempotent": false,+ "local_only": false,+ "mutating": true,"name": "submit_job","parameters": {"data": "object?",@@ -2650,6 +3022,7 @@"queue": "string?","timeout_ms": "number?"},+ "required_scopes": [],"schema": {"properties": {"data": {@@ -2689,14 +3062,19 @@"name"],"type": "object"- }+ },+ "scope": "admin"},{"description": "Get job status and details by ID. Agent-scoped tokens (no admin) see only jobs they own.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "get_job","parameters": {"id": "number"},+ "required_scopes": [],"schema": {"properties": {"id": {@@ -2708,10 +3086,14 @@"id"],"type": "object"- }+ },+ "scope": "admin"},{"description": "List jobs with optional filters. Agent-scoped tokens (no admin) see only jobs they own.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "list_jobs","parameters": {"limit": "number?",@@ -2719,6 +3101,7 @@"queue": "string?","status": "string?"},+ "required_scopes": [],"schema": {"properties": {"limit": {@@ -2740,14 +3123,19 @@},"required": [],"type": "object"- }+ },+ "scope": "admin"},{"description": "Cancel a waiting, active, or delayed job. Agent-scoped tokens (no admin) can cancel only jobs they own.",+ "idempotent": false,+ "local_only": false,+ "mutating": true,"name": "cancel_job","parameters": {"id": "number"},+ "required_scopes": [],"schema": {"properties": {"id": {@@ -2759,14 +3147,19 @@"id"],"type": "object"- }+ },+ "scope": "admin"},{"description": "Re-queue a failed or dead job for retry",+ "idempotent": false,+ "local_only": false,+ "mutating": true,"name": "retry_job","parameters": {"id": "number"},+ "required_scopes": [],"schema": {"properties": {"id": {@@ -2778,14 +3171,19 @@"id"],"type": "object"- }+ },+ "scope": "admin"},{"description": "Get structured progress for a running job. Agent-scoped tokens (no admin) see only jobs they own.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "get_job_progress","parameters": {"id": "number"},+ "required_scopes": [],"schema": {"properties": {"id": {@@ -2797,14 +3195,19 @@"id"],"type": "object"- }+ },+ "scope": "admin"},{"description": "Pause a waiting, active, or delayed job",+ "idempotent": false,+ "local_only": false,+ "mutating": true,"name": "pause_job","parameters": {"id": "number"},+ "required_scopes": [],"schema": {"properties": {"id": {@@ -2816,14 +3219,19 @@"id"],"type": "object"- }+ },+ "scope": "admin"},{"description": "Resume a paused job back to waiting",+ "idempotent": false,+ "local_only": false,+ "mutating": true,"name": "resume_job","parameters": {"id": "number"},+ "required_scopes": [],"schema": {"properties": {"id": {@@ -2835,15 +3243,20 @@"id"],"type": "object"- }+ },+ "scope": "admin"},{"description": "Replay a completed/failed/dead job, optionally with modified data",+ "idempotent": false,+ "local_only": false,+ "mutating": true,"name": "replay_job","parameters": {"data_overrides": "object?","id": "number"},+ "required_scopes": [],"schema": {"properties": {"data_overrides": {@@ -2859,16 +3272,21 @@"id"],"type": "object"- }+ },+ "scope": "admin"},{"description": "Send a sidechannel message to a running job's inbox",+ "idempotent": false,+ "local_only": false,+ "mutating": true,"name": "send_job_message","parameters": {"id": "number","payload": "object","sender": "string?"},+ "required_scopes": [],"schema": {"properties": {"id": {@@ -2889,10 +3307,14 @@"payload"],"type": "object"- }+ },+ "scope": "admin"},{"description": "Submit an LLM agent job that the worker dispatches via the gateway-native tool loop. Requires the `agent` OAuth scope. Tools, source, slug prefixes, max concurrency, and daily budget are bound at OAuth client registration time.",+ "idempotent": false,+ "local_only": false,+ "mutating": true,"name": "submit_agent","parameters": {"allowed_slug_prefixes": "array?",@@ -2902,6 +3324,7 @@"prompt": "string","queue": "string?"},+ "required_scopes": [],"schema": {"properties": {"allowed_slug_prefixes": {@@ -2939,14 +3362,19 @@"prompt"],"type": "object"- }+ },+ "scope": "agent"},{"description": "Poll an agent job submitted via submit_agent. Returns a trimmed status view (id, status, timestamps, error_text, result) plus queue_position (waiting jobs ahead in claim order; 0 = next) while the job is still waiting. Requires the `agent` OAuth scope; only jobs owned by the calling client are visible.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "get_agent_job","parameters": {"id": "number"},+ "required_scopes": [],"schema": {"properties": {"id": {@@ -2958,15 +3386,20 @@"id"],"type": "object"- }+ },+ "scope": "agent"},{"description": "Job queue statistics. PER-BLOCK scoping: by_status and queue_health are GLOBAL (unfiltered); by_type is windowed by since_hours; only the wedge block is scoped to the queue param. wedged: true is the silent-halt signal (a worker is alive but claiming nothing while work waits) — suggest restarting the jobs supervisor on the brain host. private_queue: true means the queue is a parent-owned dream-inline queue: wedged is NEVER true for it and a worker restart cannot help — recovery runs automatically at worker spawn / dream-cycle start; suggest gbrain doctor for the per-queue verdict. Host-process diagnostics (renice, backpressure hints) stay on the gbrain jobs stats CLI.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "get_job_stats","parameters": {"queue": "string?","since_hours": "number?"},+ "required_scopes": [],"schema": {"properties": {"queue": {@@ -2980,10 +3413,14 @@},"required": [],"type": "object"- }+ },+ "scope": "admin"},{"description": "Find disconnected pages. Default mode \"islanded\" (no live inbound AND no outbound link) matches get_health.orphan_pages; mode \"inbound\" is the legacy no-inbound-only view. Essential for content enrichment cycles.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "find_orphans","parameters": {"count_only": "boolean?",@@ -2993,6 +3430,7 @@"offset": "number?","source_id": "string?"},+ "required_scopes": [],"schema": {"properties": {"count_only": {@@ -3022,14 +3460,19 @@},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "Read the active calibration profile for a holder. Returns the latest row from calibration_profiles (per-source, per-holder) including Brier score, accuracy, pattern statements, and active bias tags. Source-scoped via sourceScopeOpts — federated_read scopes see the union of allowed sources, scalar source-bound clients see only their source. Returns null when no profile exists yet (cold-brain branch: builds after 5+ resolved takes + a calibration_profile phase run).",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "get_calibration_profile","parameters": {"holder": "string?"},+ "required_scopes": [],"schema": {"properties": {"holder": {@@ -3039,10 +3482,14 @@},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "List takes (typed/weighted/attributed claims) filtered by holder/kind/active/etc.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "takes_list","parameters": {"active": "boolean?",@@ -3054,6 +3501,7 @@"resolved": "boolean?","sort_by": "string?"},+ "required_scopes": [],"schema": {"properties": {"active": {@@ -3091,15 +3539,20 @@},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "Keyword search across takes (pg_trgm similarity over claim text)",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "takes_search","parameters": {"limit": "number?","query": "string"},+ "required_scopes": [],"schema": {"properties": {"limit": {@@ -3115,10 +3568,14 @@"query"],"type": "object"- }+ },+ "scope": "read"},{"description": "Multi-hop synthesis across pages + takes + graph. Pulls relevant evidence and produces a cited answer with conflict + gap analysis.",+ "idempotent": false,+ "local_only": false,+ "mutating": true,"name": "think","parameters": {"anchor": "string?",@@ -3130,6 +3587,7 @@"take": "boolean?","until": "string?"},+ "required_scopes": [],"schema": {"properties": {"anchor": {@@ -3169,10 +3627,14 @@"question"],"type": "object"- }+ },+ "scope": "read"},{"description": "Calibration scorecard for resolved bets: counts, accuracy, Brier (correct ∨ incorrect only), partial_rate.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "takes_scorecard","parameters": {"domain_prefix": "string?",@@ -3180,6 +3642,7 @@"since": "string?","until": "string?"},+ "required_scopes": [],"schema": {"properties": {"domain_prefix": {@@ -3201,15 +3664,20 @@},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "Calibration curve: resolved correct/incorrect bets binned by stated weight; observed vs predicted per bucket.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "takes_calibration","parameters": {"bucket_size": "number?","holder": "string?"},+ "required_scopes": [],"schema": {"properties": {"bucket_size": {@@ -3223,10 +3691,14 @@},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "Record a take (typed claim) on a page: fact / take / bet / hunch, with a holder (who holds the belief: world, people/<slug>, companies/<slug>, or brain), weight 0..1, and optional source/since date. Writes the markdown takes fence first (markdown is canonical) and mirrors to the DB. Remote callers can only write holders in their allow-list (stdio default: world).",+ "idempotent": true,+ "local_only": false,+ "mutating": true,"name": "takes_add","parameters": {"claim": "string",@@ -3239,6 +3711,7 @@"source": "string?","weight": "number?"},+ "required_scopes": [],"schema": {"properties": {"claim": {@@ -3291,10 +3764,14 @@"holder"],"type": "object"- }+ },+ "scope": "write"},{"description": "Update a take's mutable fields (weight, source, since date). Claim/kind/holder are immutable — supersede instead. Markdown-canonical: the target row must exist in the page's takes fence. Remote callers can only touch rows whose holder is in their allow-list; other rows present as not_found.",+ "idempotent": true,+ "local_only": false,+ "mutating": true,"name": "takes_update","parameters": {"local_dir": "string?",@@ -3305,6 +3782,7 @@"source": "string?","weight": "number?"},+ "required_scopes": [],"schema": {"properties": {"local_dir": {@@ -3341,10 +3819,14 @@"row_num"],"type": "object"- }+ },+ "scope": "write"},{"description": "Resolve a take: quality correct / incorrect / partial / unresolvable, with optional evidence text and measured value/unit. Resolutions feed the calibration scorecard. Remote callers: resolved_by is SERVER-STAMPED as mcp:<client> (any passed value is ignored) so agent resolutions stay segregable from owner ground truth; the target row must be in the caller's holder allow-list. Markdown-canonical.",+ "idempotent": true,+ "local_only": false,+ "mutating": true,"name": "takes_resolve","parameters": {"evidence": "string?",@@ -3357,6 +3839,7 @@"unit": "string?","value": "number?"},+ "required_scopes": [],"schema": {"properties": {"evidence": {@@ -3408,10 +3891,14 @@"quality"],"type": "object"- }+ },+ "scope": "write"},{"description": "Supersede a take with a replacement claim: the old row is struck through (kept for archaeology), the replacement appends at the next fence row number. Kind/holder inherit from the target row unless overridden; unset weight decays the target's by 0.1. Markdown-canonical; remote holder fencing as in takes_update.",+ "idempotent": true,+ "local_only": false,+ "mutating": true,"name": "takes_supersede","parameters": {"claim": "string",@@ -3425,6 +3912,7 @@"source": "string?","weight": "number?"},+ "required_scopes": [],"schema": {"properties": {"claim": {@@ -3480,20 +3968,29 @@"claim"],"type": "object"- }+ },+ "scope": "write"},{"description": "Introspect the calling identity. Returns one of three transport shapes: {transport: \"oauth\", client_id, client_name, scopes, expires_at, source_id, federated_read}, {transport: \"legacy\", token_name, scopes, expires_at: null}, or {transport: \"local\", scopes: []}, or {transport: \"stdio\", scopes: []} for the auth-less stdio MCP pipe. Throws unknown_transport when the context is ambiguous (remote=true without auth and no transport marker) — fail-closed posture mirroring the v0.26.9 trust-boundary contract.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "whoami","parameters": {},+ "required_scopes": [],"schema": {"properties": {},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "Register a new source. Supports either --path (existing v0.17 behavior) or --url (v0.28 federated remote-clone path: parses the URL through the SSRF gate, clones into $GBRAIN_HOME/clones/<id>/ via temp-dir + rename atomicity, and stores remote_url in sources.config). Pre-flight collision check on id; rollback on either-side failure.",+ "idempotent": false,+ "local_only": false,+ "mutating": true,"name": "sources_add","parameters": {"clone_dir": "string?",@@ -3503,6 +4000,7 @@"path": "string?","url": "string?"},+ "required_scopes": [],"schema": {"properties": {"clone_dir": {@@ -3534,14 +4032,19 @@"id"],"type": "object"- }+ },+ "scope": "sources_admin"},{"description": "List registered sources with page counts and remote_url. v0.28 surfaces the new remote_url field so a remote MCP caller can confirm a source is managed by clone+pull rather than user-supplied path. Results are confined to the caller's resolved source scope (federated read grant > bound source; #4433) and carry no marker when rows were withheld, so a listing may be incomplete. Only the trusted local CLI (`gbrain sources list`) sees the full registry.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "sources_list","parameters": {"include_archived": "boolean?"},+ "required_scopes": [],"schema": {"properties": {"include_archived": {@@ -3551,10 +4054,14 @@},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "Hard-remove a source (cascades pages/chunks/embeddings). Refuses to delete the auto-managed clone dir unless its resolved path is confined under $GBRAIN_HOME/clones/ (realpath+lstat — symlink-safe). For most workflows prefer the soft-delete path (`gbrain sources archive`). Confined to the caller's WRITE authority, not its read scope: an untrusted caller may remove only its own write source (a federated read grant naming a source does not make it removable); any other id answers not_found, indistinguishable from a nonexistent source. Only the trusted local CLI (`gbrain sources remove`) can remove any source.",+ "idempotent": false,+ "local_only": false,+ "mutating": true,"name": "sources_remove","parameters": {"confirm_destructive": "boolean?",@@ -3562,6 +4069,7 @@"id": "string","keep_storage": "boolean?"},+ "required_scopes": [],"schema": {"properties": {"confirm_destructive": {@@ -3585,14 +4093,19 @@"id"],"type": "object"- }+ },+ "scope": "sources_admin"},{"description": "Per-source diagnostic. Returns clone_state (\"healthy\" | \"missing\" | \"not-a-dir\" | \"no-git\" | \"url-drift\" | \"corrupted\" | \"not-applicable\") so a remote MCP caller can diagnose whether the on-disk clone is syncable without SSH access to the brain host. Confined to the caller's resolved source scope (#4433); an out-of-scope id answers not_found, indistinguishable from a nonexistent source.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "sources_status","parameters": {"id": "string"},+ "required_scopes": [],"schema": {"properties": {"id": {@@ -3604,10 +4117,14 @@"id"],"type": "object"- }+ },+ "scope": "read"},{"description": "Inspect committed company Markdown on the trusted local host without importing, registering a source, changing access, or invoking providers.",+ "idempotent": true,+ "local_only": true,+ "mutating": false,"name": "sources_inspect","parameters": {"exclude": "array?",@@ -3615,6 +4132,7 @@"path": "string","profile": "string?"},+ "required_scopes": [],"schema": {"properties": {"exclude": {@@ -3644,15 +4162,20 @@"path"],"type": "object"- }+ },+ "scope": "read"},{"description": "Discover this brain's tool catalog and optionally unlock a wider tool surface for your client. No arguments → the catalog visible to YOUR credentials, grouped by area (tool names + one-line summaries). {tools: [\"name\", ...]} → full read-only schemas for the visible subset of those names (unknown/hidden names are silently omitted). {surface: \"verbs\"|\"starter\"|\"full\"} → persist that tool surface for this client (bounded by the server ceiling; denied when an operator pinned the surface; ~5 changes/hour), then re-issue tools/list to see the new catalog.",+ "idempotent": false,+ "local_only": false,+ "mutating": true,"name": "request_tools","parameters": {"surface": "string?","tools": "array?"},+ "required_scopes": [],"schema": {"properties": {"surface": {@@ -3675,10 +4198,14 @@},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "Returns readable pages recently touched and ranked by activity salience and recency. Unrestricted local reads include deterministic 0..1 emotional_weight, take density, and recency decay. Holder-restricted reads count only permitted active takes, use zero emotional_weight, and select recent pages by updated_at; unrestricted local reads retain take-driven touches. Use this when the user asks what's been going on, what's notable, what's hot, anything crazy happening, or for any open-ended 'current state' question about themselves or their work. Do NOT run a semantic search for these — salience surfaces what's unusual without needing a search term.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "get_recent_salience","parameters": {"days": "number?",@@ -3686,6 +4213,7 @@"recency_bias": "string?","slugPrefix": "string?"},+ "required_scopes": [],"schema": {"properties": {"days": {@@ -3711,16 +4239,21 @@},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "Returns statistical anomalies in recent page activity, grouped by cohort (tag or type). Use this for questions about what stood out, what's unusual, or what changed recently. Returns explanatory cohorts (e.g. '15 pages tagged wedding touched on 2026-04-28, baseline 0.3/day') so you can speak about patterns the user wouldn't have searched for. Cohort kinds: tag, type. Year cohort is deferred to a later release.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "find_anomalies","parameters": {"lookback_days": "number?","sigma": "number?","since": "string?"},+ "required_scopes": [],"schema": {"properties": {"lookback_days": {@@ -3738,16 +4271,21 @@},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "Returns one-line summaries of recent raw conversation transcripts (NOT polished reflections). Use this FIRST for questions about 'what's going on with me', 'what have I been thinking about', or anything personal/emotional. Raw transcripts are the canonical source for the user's own state — polished pages summarize and flatten. Local-only: rejects remote (MCP/HTTP) callers with a clear permission_denied; call via the gbrain CLI.",+ "idempotent": true,+ "local_only": true,+ "mutating": false,"name": "get_recent_transcripts","parameters": {"days": "number?","limit": "number?","summary": "boolean?"},+ "required_scopes": [],"schema": {"properties": {"days": {@@ -3765,14 +4303,19 @@},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "Per-provider chat-connector status: strategies, whether a credential is present and from where (env/file — never the value), token expiry, last_sync_at, auth_error_at, auto_sync, and the incremental watermark. Local-only; credentials never cross the wire.",+ "idempotent": true,+ "local_only": true,+ "mutating": false,"name": "connectors_status","parameters": {"provider": "string?"},+ "required_scopes": [],"schema": {"properties": {"provider": {@@ -3782,10 +4325,14 @@},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "Sync a chat provider's conversation history into the brain: list new conversations since the watermark, fetch them, and ingest as pages under conversations/<provider>/. Incremental by default; --full re-scans. Local-only (uses on-disk credentials).",+ "idempotent": false,+ "local_only": true,+ "mutating": true,"name": "connector_sync","parameters": {"dry_run": "boolean?",@@ -3793,6 +4340,7 @@"limit": "number?","provider": "string"},+ "required_scopes": [],"schema": {"properties": {"dry_run": {@@ -3816,10 +4364,14 @@"provider"],"type": "object"- }+ },+ "scope": "write"},{"description": "Life Chronicle: events + timeline entries on a given day (or its ISO week when week=true), ordered chronologically; each row backlinks to its depth page. Distinct from `get_timeline`/`gbrain timeline <slug>`, which shows ONE page's timeline. CLI: `gbrain day <date>`.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "chronicle_day","parameters": {"date": "string",@@ -3827,6 +4379,7 @@"narrative": "boolean?","week": "boolean?"},+ "required_scopes": [],"schema": {"properties": {"date": {@@ -3850,15 +4403,20 @@"date"],"type": "object"- }+ },+ "scope": "read"},{"description": "Life Chronicle: events from the same calendar day in PRIOR years (\"on this day\"). CLI: `gbrain on-this-day [--date YYYY-MM-DD]`.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "chronicle_on_this_day","parameters": {"date": "string?","limit": "number?"},+ "required_scopes": [],"schema": {"properties": {"date": {@@ -3872,16 +4430,21 @@},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "Life Chronicle: events + timeline entries on or after a date, optionally filtered by event kind. CLI: `gbrain since <date> [--kind commitment]`.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "chronicle_since","parameters": {"date": "string","kind": "string?","limit": "number?"},+ "required_scopes": [],"schema": {"properties": {"date": {@@ -3901,15 +4464,20 @@"date"],"type": "object"- }+ },+ "scope": "read"},{"description": "Life Chronicle: when an entity was last seen — its own timeline rows OR an event's `who`. Returns last_date, the event slug, and days_ago. CLI: `gbrain last-seen <entity-slug>`.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "chronicle_last_seen","parameters": {"asof": "string?","entity": "string"},+ "required_scopes": [],"schema": {"properties": {"asof": {@@ -3925,10 +4493,14 @@"entity"],"type": "object"- }+ },+ "scope": "read"},{"description": "Life Chronicle: the current resolved per-entity ontology (dimension → value) at `asof` (default now), with provenance + confidence + validity. CLI: `gbrain ontology <entity> [--asof YYYY-MM-DD]`.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "ontology_get","parameters": {"asof": "string?",@@ -3936,6 +4508,7 @@"include_quarantined": "boolean?","min_confidence": "number?"},+ "required_scopes": [],"schema": {"properties": {"asof": {@@ -3959,10 +4532,14 @@"entity"],"type": "object"- }+ },+ "scope": "read"},{"description": "Life Chronicle: record one ontology observation (entity has dimension=value), sourced + confidence-weighted + bi-temporal. Idempotent on (entity,dimension,value,source). A new value supersedes the prior; a backdated conflict is flagged not rewritten. CLI: `gbrain ontology-add <entity> <dimension> <value>`.",+ "idempotent": false,+ "local_only": false,+ "mutating": true,"name": "ontology_propose","parameters": {"confidence": "number?",@@ -3974,6 +4551,7 @@"value": "string","visibility": "string?"},+ "required_scopes": [],"schema": {"properties": {"confidence": {@@ -4019,24 +4597,34 @@"value"],"type": "object"- }+ },+ "scope": "write"},{"description": "Life Chronicle meta-ontology: which dimensions the brain tracks across entities, with entity + observation counts. CLI: `gbrain ontology-dimensions`.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "ontology_dimensions","parameters": {},+ "required_scopes": [],"schema": {"properties": {},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "Life Chronicle: dimensions with ≥2 distinct current values from ≥2 provenances (genuine disagreement, not temporal supersession). CLI: `gbrain ontology-contradictions`.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "ontology_conflicts","parameters": {"min_confidence": "number?"},+ "required_scopes": [],"schema": {"properties": {"min_confidence": {@@ -4046,16 +4634,21 @@},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "Life Chronicle agent-orientation: the recent timeline (last N days) + the current validity-resolved ontology for the named entities, in one zero-LLM payload, so an agent orients before acting. Diary-sourced ontology is redacted for remote callers. CLI: `gbrain orient [--days 7] [--entities people/a,people/b]`.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "volunteer_chronicle","parameters": {"days": "number?","entities": "string?","limit": "number?"},+ "required_scopes": [],"schema": {"properties": {"days": {@@ -4073,16 +4666,21 @@},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "Life Chronicle: sweep existing meeting/conversation/calendar pages into timeline events by enqueuing chronicle_extract jobs (one per eligible page). A page whose current content was already enqueued is skipped (already_enqueued), so repeat runs move on to pages not yet swept. --dry-run counts without enqueuing. Local-only bulk op. CLI: `gbrain chronicle-backfill [--since YYYY-MM-DD] [--limit N] [--dry-run]`.",+ "idempotent": false,+ "local_only": true,+ "mutating": true,"name": "chronicle_backfill","parameters": {"dry_run": "boolean?","limit": "number?","since": "string?"},+ "required_scopes": [],"schema": {"properties": {"dry_run": {@@ -4100,10 +4698,14 @@},"required": [],"type": "object"- }+ },+ "scope": "admin"},{"description": "Push-based context: volunteer brain pages relevant to a rolling conversation window WITHOUT being asked. Zero-LLM, confidence-gated (alias 0.9 / exact-title 0.8 / slug-suffix 0.6, +0.05 for multi-turn or newest-turn mentions; default gate 0.7), capped at 3 pages (max 5). Returns pointers with one-line rationales + synopses — open the page (get_page) before relying on details. Pass stats: true for the approximate volunteered-vs-used precision summary (the feedback loop).",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "volunteer_context","parameters": {"days": "number?",@@ -4115,6 +4717,7 @@"turn": "number?","window": "string?"},+ "required_scopes": [],"schema": {"properties": {"days": {@@ -4152,16 +4755,21 @@},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "Extract entity names (people, companies) from text and create/update their brain stub pages. Stubs from untrusted input land in the quarantine lane (frontmatter `provenance: auto-extracted` + `status: unverified`) — excluded from authoritative retrieval boosts until reviewed. Direct authoritative writes require the trusted local CLI AND --trusted-extraction.",+ "idempotent": false,+ "local_only": false,+ "mutating": true,"name": "extract_entities","parameters": {"source_slug": "string","text": "string","trusted_extraction": "boolean?"},+ "required_scopes": [],"schema": {"properties": {"source_slug": {@@ -4182,15 +4790,20 @@"source_slug"],"type": "object"- }+ },+ "scope": "write"},{"description": "List unverified auto-extracted entity stubs awaiting owner review (the quarantine lane from extract_entities). Promote or reject them with extraction_review.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "extraction_pending","parameters": {"limit": "number?","offset": "number?"},+ "required_scopes": [],"schema": {"properties": {"limit": {@@ -4204,15 +4817,20 @@},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "Promote or reject unverified auto-extracted entity stubs (batch). Promote flips `status` to verified (provenance kept for audit); reject soft-deletes the stub. Owner-only: this op is refused for any non-local caller. (The markers are ordinary frontmatter — the boundary against rewriting them wholesale is put_page write authz, same as for any page.)",+ "idempotent": false,+ "local_only": true,+ "mutating": true,"name": "extraction_review","parameters": {"action": "string","slugs": "array"},+ "required_scopes": [],"schema": {"properties": {"action": {@@ -4232,10 +4850,14 @@"slugs"],"type": "object"- }+ },+ "scope": "write"},{"description": "Link a page into a cross-source entity identity group (v1 manual-only; no auto-matching). The identity key is (source_id, slug); a page belongs to at most one group and re-linking moves it. Set canonical=true to mark the group's primary page (demotes any previous canonical).",+ "idempotent": false,+ "local_only": true,+ "mutating": true,"name": "entity_identity_link","parameters": {"canonical": "boolean?",@@ -4244,6 +4866,7 @@"slug": "string","source_id": "string?"},+ "required_scopes": [],"schema": {"properties": {"canonical": {@@ -4272,16 +4895,21 @@"slug"],"type": "object"- }+ },+ "scope": "write"},{"description": "Remove a page from a cross-source entity identity group (v1 manual-only).",+ "idempotent": false,+ "local_only": true,+ "mutating": true,"name": "entity_identity_unlink","parameters": {"entity_id": "string","slug": "string","source_id": "string?"},+ "required_scopes": [],"schema": {"properties": {"entity_id": {@@ -4302,15 +4930,20 @@"slug"],"type": "object"- }+ },+ "scope": "write"},{"description": "List cross-source entity identity groups and their member pages. Filter by entity_id or by a member slug. Federated callers only see members in sources their grant covers.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "entity_identity_list","parameters": {"entity_id": "string?","slug": "string?"},+ "required_scopes": [],"schema": {"properties": {"entity_id": {@@ -4324,10 +4957,14 @@},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "v0.31: extract personal-knowledge facts (events, preferences, commitments, beliefs, ideas, and plain facts) from a conversation turn into the per-source hot memory. Sanitizes turn_text via INJECTION_PATTERNS, calls the configured extraction model (key-aware: any servable provider — OpenAI or Anthropic key both work), runs the cosine fast-path + classifier dedup pipeline, INSERTs into facts. Returns counts by status. With NO servable chat model, returns skipped: extraction_unavailable + an agent_action telling YOU to extract and write via `remember` (visibility: \"private\"). Skips extraction when the turn is dream-generated content (anti-loop). For agent memory writes of a SINGLE already-formed fact, prefer the `remember` verb (zero LLM, mandatory provenance).",+ "idempotent": true,+ "local_only": false,+ "mutating": true,"name": "extract_facts","parameters": {"entity_hints": "array?",@@ -4339,6 +4976,7 @@"valid_from": "string?","visibility": "string?"},+ "required_scopes": [],"schema": {"properties": {"entity_hints": {@@ -4381,10 +5019,14 @@"turn_text"],"type": "object"- }+ },+ "scope": "write"},{"description": "MEMORY VERB (v1): retrieve saved facts/snippets — the protocol read verb. Filters hot-memory facts by entity / since / session_id; pass `query` to ALSO run hybrid search over pages (results[] arm); pass `budget_tokens` for server-side packing (response reports budget_used + dropped_count — never trims client-side). Remote callers see visibility=world facts only. Routing: for ONE known person/company/project card use `entity` (zero LLM); for broad questions needing reasoning use `synthesize` (expensive). Branch on structured fields (status/kind/evidence), never on prose. Every response carries protocol_version.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "recall","parameters": {"budget_policy": "string?",@@ -4402,6 +5044,7 @@"source_id": "string?","supersessions": "boolean?"},+ "required_scopes": [],"schema": {"properties": {"budget_policy": {@@ -4474,10 +5117,14 @@},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "MEMORY VERB (v1): budget-packed session-boundary bundle for a set of standing entities — entity cards + open threads + hot facts, zero-LLM, sub-second. Call at session start (warm cold context) and after compaction (rehydrate what the summary lost). WORLD-ONLY by default; pass include_private (honored for LOCAL trusted callers only) to widen all arms. budget_tokens packs server-side (response reports budget_used + dropped_count; cards pack first, then facts). Branch on structured fields, never prose. protocol_version rides every response.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "context_pack","parameters": {"budget_tokens": "number?",@@ -4486,6 +5133,7 @@"session_id": "string?","since": "string?"},+ "required_scopes": [],"schema": {"properties": {"budget_tokens": {@@ -4513,10 +5161,14 @@"entities"],"type": "object"- }+ },+ "scope": "read"},{"description": "MEMORY VERB (v1): \"what changed since T\" for heartbeats — pages updated after `since` + hot facts newer than `since` + open-thread events after `since`, zero-LLM. Lets a periodic wake maintain warm state in O(changes) instead of re-deriving. Optionally scope thread deltas to `entities`. WORLD-ONLY by default; include_private honored for local trusted callers only. budget_tokens packs server-side (pages first, then facts; threads are never dropped). protocol_version rides every response.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "delta","parameters": {"budget_tokens": "number?",@@ -4526,6 +5178,7 @@"since": "string?","since_slug": "string?"},+ "required_scopes": [],"schema": {"properties": {"budget_tokens": {@@ -4555,16 +5208,21 @@},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "Forget a fact by recording a durable withdrawal in its source and visibility. Strikes the Markdown facts fence when writable; otherwise keeps the withdrawal in the database. Stale imports cannot reactivate the same normalized claim. This retracts memory; original prose, files and backups may retain the text. Idempotent on already-expired or unknown ids.",+ "idempotent": true,+ "local_only": false,+ "mutating": true,"name": "forget_fact","parameters": {"id": "number","reason": "string?","request_id": "string?"},+ "required_scopes": [],"schema": {"properties": {"id": {@@ -4584,16 +5242,21 @@"id"],"type": "object"- }+ },+ "scope": "write"},{"description": "Stored contradiction reports are temporarily available only to trusted local callers without a source filter. Remote or source-scoped callers receive {contradictions: [], note} with an availability note. For eligible local callers, return suspected-contradiction findings from the most recent `gbrain eval suspected-contradictions` probe run, optionally filtered by slug and/or severity. Use this when the user asks 'what's inconsistent in my brain', 'show me contradictions about Acme', 'high-severity issues only', or wants to act on the probe's findings without re-running it. Returns {contradictions: [{a, b, severity, axis, confidence, resolution_command}]}. An eligible read loads the stored run without triggering a new probe; users run `gbrain eval suspected-contradictions` for that.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "find_contradictions","parameters": {"limit": "number?","severity": "string?","slug": "string?"},+ "required_scopes": [],"schema": {"properties": {"limit": {@@ -4616,16 +5279,21 @@},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "Answers 'who in my brain knows about <topic>'. Returns ranked person/company pages by expertise depth (sub-linear match score), relationship recency (exp decay with 6-month half-life), and salience. Use this for questions like 'who should I talk to about X', 'who knows about Y', 'find me someone who's worked on Z', or any expertise-routing intent. Filters at SQL to person + company pages — does NOT return notes or articles. Pair with --explain (CLI) to surface the per-result factor breakdown.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "find_experts","parameters": {"explain": "boolean?","limit": "number?","topic": "string?"},+ "required_scopes": [],"schema": {"properties": {"explain": {@@ -4643,10 +5311,14 @@},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "v0.35.4 — return the chronological claim trajectory for an entity (typed metric values over time, plus auto-detected regressions and narrative drift). Use this when the user asks 'how has Acme's MRR trended', 'show me what alice-example said about runway over time', 'is this founder consistent', 'find regressions for fund-a's portfolio', or wants a time-series view of an entity's structured claims. Returns `{points: [{fact_id, valid_from, metric, value, unit, period, text, source_session, source_markdown_slug}], regressions: [{metric, from_value, from_date, to_value, to_date, delta_pct}], drift_score: number|null, schema_version: 1}`. Drift score 0 = stable narrative, 1 = every consecutive claim is unrelated; null when fewer than 3 typed points exist. Visibility-filtered for remote callers (world-only); source-scoped by the caller's OAuth source binding. Pair with `gbrain founder scorecard <slug>` for an aggregated rollup of the same data.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "find_trajectory","parameters": {"entity_slug": "string?",@@ -4656,6 +5328,7 @@"since": "string?","until": "string?"},+ "required_scopes": [],"schema": {"properties": {"entity_slug": {@@ -4690,10 +5363,14 @@},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "BEFORE editing any function, run code_callers with the symbol name to find every caller (the people who'd be affected by your change). Returns direct callers from the v0.20+ tree-sitter call graph. Use during plan-mode to size the change. Defaults to source-scoped; for multi-source brains pass source_id or all_sources=true. Returns: `{symbol, count, callers: [{from_symbol_qualified, to_symbol_qualified, edge_type, resolved}]}`. Example: `{symbol:'parseMarkdown', count:4, callers:[{from_symbol_qualified:'callerInA', to_symbol_qualified:'parseMarkdown', edge_type:'calls', resolved:true}]}`. Temporarily available only to trusted local CLI callers; agent-facing code reads are suspended.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "code_callers","parameters": {"all_sources": "boolean?",@@ -4701,6 +5378,7 @@"source_id": "string?","symbol": "string"},+ "required_scopes": [],"schema": {"properties": {"all_sources": {@@ -4724,10 +5402,14 @@"symbol"],"type": "object"- }+ },+ "scope": "read"},{"description": "When tracing how a function flows to its dependencies (DB calls, HTTP calls, file I/O), run code_callees from the entry point. Forward view of the call graph: what does this symbol call? Use this when debugging unexpected behavior or when planning to extract / inline a function. Same shape as code_callers but the field is `callees` and the edge direction is reversed. Temporarily available only to trusted local CLI callers; agent-facing code reads are suspended.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "code_callees","parameters": {"all_sources": "boolean?",@@ -4735,6 +5417,7 @@"source_id": "string?","symbol": "string"},+ "required_scopes": [],"schema": {"properties": {"all_sources": {@@ -4758,16 +5441,21 @@"symbol"],"type": "object"- }+ },+ "scope": "read"},{"description": "Where is this symbol defined? Returns one row per definition site (function, class, type, interface, enum, struct, trait, module, contract). Use this BEFORE reaching for grep when you want to read a definition. Single-result is the common case; multiple results indicate same-name symbols across files (which is information in itself). Returns: `{symbol, count, defs: [{slug, file, language, symbol_type, start_line, end_line, snippet}]}`. Filter by --lang to scope a polyglot brain (e.g., lang='typescript'). Temporarily available only to trusted local CLI callers; agent-facing code reads are suspended.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "code_def","parameters": {"lang": "string?","limit": "number?","symbol": "string"},+ "required_scopes": [],"schema": {"properties": {"lang": {@@ -4787,16 +5475,21 @@"symbol"],"type": "object"- }+ },+ "scope": "read"},{"description": "Find every reference to a symbol across the codebase (every file, every line). Differs from code_callers in two ways: (1) catches references in comments, strings, imports, type annotations — not just call sites; (2) returns line numbers, not symbol-qualified edges. Use this when planning a rename or deprecation where you need to touch every literal mention. Returns: `{symbol, count, refs: [{slug, file, language, line, context}]}`. Temporarily available only to trusted local CLI callers; agent-facing code reads are suspended.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "code_refs","parameters": {"lang": "string?","limit": "number?","symbol": "string"},+ "required_scopes": [],"schema": {"properties": {"lang": {@@ -4816,10 +5509,14 @@"symbol"],"type": "object"- }+ },+ "scope": "read"},{"description": "BEFORE editing any function, run code_blast with the symbol name to surface every transitive caller grouped by depth (direct → 2-hop → 3-hop). Use this during plan-mode to size the change. Returns up to 200 nodes. Trust an empty/not_found result only when ready=true; ready=false means impact is unknown and requires a safe fallback. Returns: {result, status, ready, depth_groups?, truncation?, cycles_detected?, did_you_mean?, candidates?}. Example ok: {result:\"ok\", status:\"ready\", ready:true, depth_groups:[{depth:1, nodes:[{symbol,chunk_id}], confidence:0.77}], truncation:\"none\"}. Temporarily available only to trusted local CLI callers; agent-facing code reads are suspended.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "code_blast","parameters": {"depth": "number?",@@ -4828,6 +5525,7 @@"source_id": "string?","symbol": "string"},+ "required_scopes": [],"schema": {"properties": {"depth": {@@ -4855,10 +5553,14 @@"symbol"],"type": "object"- }+ },+ "scope": "read"},{"description": "When tracing how a request flows through the codebase from entry point to side effect (DB write, HTTP call, file I/O), run code_flow from the entry point. Returns ordered execution chain with terminal-node tags. Returns: same envelope as code_blast plus terminal_nodes: [{symbol, sink_kind}] where sink_kind ∈ \"db_call\"|\"http_call\"|\"file_io\"|\"process_exec\"|\"unknown\". Temporarily available only to trusted local CLI callers; agent-facing code reads are suspended.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "code_flow","parameters": {"depth": "number?",@@ -4867,6 +5569,7 @@"max_nodes": "number?","source_id": "string?"},+ "required_scopes": [],"schema": {"properties": {"depth": {@@ -4894,15 +5597,20 @@"entry_point"],"type": "object"- }+ },+ "scope": "read"},{"description": "Clear cached code_blast / code_flow traversal results. Source-scoped by default; pass all_sources=true to wipe everything (D8 destructive-guard).",+ "idempotent": true,+ "local_only": true,+ "mutating": true,"name": "code_traversal_cache_clear","parameters": {"all_sources": "boolean?","source_id": "string?"},+ "required_scopes": [],"schema": {"properties": {"all_sources": {@@ -4916,10 +5624,14 @@},"required": [],"type": "object"- }+ },+ "scope": "admin"},{"description": "Re-embed the brain onto a different embedding provider/model (#3390): schema dimension transition, NULL-signature (#3391) invalidation, query-cache purge, resumable re-embed. Without yes=true returns the plan + cost estimate only. Local-only admin op; the primary surface is `gbrain migrate embeddings`.",+ "idempotent": false,+ "local_only": true,+ "mutating": true,"name": "migrate_embeddings","parameters": {"dim": "number?",@@ -4930,6 +5642,7 @@"to": "string","yes": "boolean?"},+ "required_scopes": [],"schema": {"properties": {"dim": {@@ -4965,44 +5678,64 @@"to"],"type": "object"- }+ },+ "scope": "admin"},{"description": "v0.40.6.0: cheap identity packet for the active schema pack. Returns {pack_name, version, sha8, page_types_count, link_types_count, primitive_summary, source_tier}. Useful for agents to know which pack they are operating against without paying full manifest load cost.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "get_active_schema_pack","parameters": {},+ "required_scopes": [],"schema": {"properties": {},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "v0.40.6.0: list installed schema packs (bundled + user-installed). Returns {bundled: string[], installed: string[]}. Read-only directory listing.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "list_schema_packs","parameters": {},+ "required_scopes": [],"schema": {"properties": {},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "v0.40.6.0: per-type page counts + typed-coverage from the DB. Returns {schema_version:1, pack_identity, aggregate, per_source, dead_prefixes}. Multi-source aware via ctx.sourceId/allowedSources.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "schema_stats","parameters": {},+ "required_scopes": [],"schema": {"properties": {},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "v0.40.6.0: lint the active (or named) schema pack. File-plane rules only over MCP — the with_db option is rejected for remote callers (DB-aware rules require local CLI). Returns {ok, errors, warnings} structured report.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "schema_lint","parameters": {"pack": "string?"},+ "required_scopes": [],"schema": {"properties": {"pack": {@@ -5012,24 +5745,34 @@},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "v0.40.6.0: schema pack graph as JSON edges. Returns {nodes: [{name, primitive}], edges: [{from, verb, to}]} derived from link_types inference + frontmatter_links.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "schema_graph","parameters": {},+ "required_scopes": [],"schema": {"properties": {},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "v0.40.6.0: resolved settings for a single page_type in the active pack. Returns {pack, type, primitive, path_prefixes, aliases, extractable, expert_routing}.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "schema_explain_type","parameters": {"type": "string"},+ "required_scopes": [],"schema": {"properties": {"type": {@@ -5041,14 +5784,19 @@"type"],"type": "object"- }+ },+ "scope": "read"},{"description": "v0.40.6.0: list pages with no active-pack type match. Returns {orphan_count, orphans: [{slug, source_id}]}.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "schema_review_orphans","parameters": {"limit": "number?"},+ "required_scopes": [],"schema": {"properties": {"limit": {@@ -5058,16 +5806,21 @@},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "v0.40.7.0: batched schema pack mutation. ATOMIC: every mutation is validated against an in-memory manifest first, and the pack file is written to disk at most once, after the FULL batch has proven valid — so a failure at any point leaves the pack file byte-identical to its pre-batch state (never a partial write). Audit log records one batch_id. Admin scope; NOT localOnly so remote agents (your OpenClaw, etc.) can author packs over normal MCP. Mutation shape per ApplyMutationsRequest type — supports add_type / remove_type / update_type / add_alias / remove_alias / add_prefix / remove_prefix / add_link_type / remove_link_type / set_extractable / set_expert_routing.",+ "idempotent": false,+ "local_only": false,+ "mutating": true,"name": "schema_apply_mutations","parameters": {"force": "boolean?","mutations": "array","pack": "string"},+ "required_scopes": [],"schema": {"properties": {"force": {@@ -5091,14 +5844,19 @@"mutations"],"type": "object"- }+ },+ "scope": "admin"},{"description": "v0.40.6.0: flush the in-process schema pack cache so the next loadActivePack re-reads from disk. Cascades through extends-chain (codex C6). Admin scope; NOT localOnly. Returns {invalidated: string[]}.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "reload_schema_pack","parameters": {"pack": "string?"},+ "required_scopes": [],"schema": {"properties": {"pack": {@@ -5108,16 +5866,21 @@},"required": [],"type": "object"- }+ },+ "scope": "admin"},{"description": "Probe brain health + optionally submit onboard remediations. Admin scope required. Protected handlers (LLM-bearing) require run_protected_onboard scope ADDITIONALLY.",+ "idempotent": false,+ "local_only": false,+ "mutating": true,"name": "run_onboard","parameters": {"max_usd": "number?","mode": "string?","target_score": "number?"},+ "required_scopes": [],"schema": {"properties": {"max_usd": {@@ -5135,10 +5898,14 @@},"required": [],"type": "object"- }+ },+ "scope": "admin"},{"description": "Run SkillOpt against a single skill. Admin scope and remote skill allowlist required. shared_skill stages an exact catalog revision privately and requires explicit skill_editor and put_skill grants; only accepted body changes publish through the original revision CAS. Rate-limited per-skill via DB lock.",+ "idempotent": true,+ "local_only": false,+ "mutating": true,"name": "run_skillopt","parameters": {"allow_mutate_bundled": "boolean?",@@ -5159,6 +5926,7 @@"source_id": "string?","source_incarnation": "string?"},+ "required_scopes": [],"schema": {"properties": {"allow_mutate_bundled": {@@ -5234,10 +6002,14 @@"skill_name"],"type": "object"- }+ },+ "scope": "admin"},{"description": "The open-loop engine's killer output: who is waiting on you, what you promised, and the context needed to respond. Grouped by counterparty (default, ranked) or flat. Loops come from the deterministic Gmail thread-state detector and the LLM commitment extractor. Remote callers get redacted evidence (no verbatim quotes); trusted local callers also get quotes, Gmail deep links, entity-card context, and a pre-rendered text digest. Carries google-source freshness (stale flag) and completeness: when it is \"partial\", some mail in the window is held after repeated import failures; present the answer as partial and name the held items and their retry command.",+ "idempotent": true,+ "local_only": false,+ "mutating": false,"name": "open_loops","parameters": {"all_sources": "boolean?",@@ -5250,6 +6022,7 @@"source_id": "string?","status": "string?"},+ "required_scopes": [],"schema": {"properties": {"all_sources": {@@ -5308,10 +6081,14 @@},"required": [],"type": "object"- }+ },+ "scope": "read"},{"description": "Close an open loop by id: status 'done' (handled) or 'dropped' (not going to). Closing is a state transition with an audit trail, never a delete. Thread loops also close automatically when a reply lands.",+ "idempotent": true,+ "local_only": false,+ "mutating": true,"name": "loops_close","parameters": {"id": "number",@@ -5319,6 +6096,7 @@"source_id": "string?","status": "string"},+ "required_scopes": [],"schema": {"properties": {"id": {@@ -5347,16 +6125,21 @@"status"],"type": "object"- }+ },+ "scope": "write"},{"description": "Suppress a sender (email address) or thread id from opening NEW loops — the detector feedback primitive behind \"never track this sender\". Existing loops keep their state.",+ "idempotent": true,+ "local_only": false,+ "mutating": true,"name": "loops_mute","parameters": {"kind": "string","source_id": "string?","value": "string"},+ "required_scopes": [],"schema": {"properties": {"kind": {@@ -5381,16 +6164,21 @@"value"],"type": "object"- }+ },+ "scope": "write"},{"description": "Remove a sender/thread suppression added by loops_mute, so the detector can open NEW loops for it again. Exact-match only. Does not reopen loops closed while the mute was in place.",+ "idempotent": true,+ "local_only": false,+ "mutating": true,"name": "loops_unmute","parameters": {"kind": "string","source_id": "string?","value": "string"},+ "required_scopes": [],"schema": {"properties": {"kind": {@@ -5415,7 +6203,8 @@"value"],"type": "object"- }+ },+ "scope": "write"}]},diff --git a/test/mcp-tool-defs.test.ts b/test/mcp-tool-defs.test.tsindex 2ad38967bf..4bec570e18 100644--- a/test/mcp-tool-defs.test.ts+++ b/test/mcp-tool-defs.test.ts@@ -11,7 +11,7 @@import { describe, test, expect } from 'bun:test';import { operations } from '../src/core/operations.ts';import { buildToolDefs, paramDefToSchema, toolAnnotations } from '../src/mcp/tool-defs.ts';-import type { ParamDef } from '../src/core/operations.ts';+import type { Operation, ParamDef } from '../src/core/operations.ts';// Reference shape — mirrors the canonical `paramDefToSchema` helper from// src/mcp/tool-defs.ts. Drift between the helper and this reference fails@@ -72,8 +72,8 @@ function legacyInlineMap(ops: typeof operations) {}function referenceAnnotations(op: (typeof operations)[number]) {if (op.annotations) return op.annotations;- if (op.mutating === true) return { readOnlyHint: false };- if (op.mutating === false && op.scope === 'read') return { readOnlyHint: true };+ if (op.mutating === true) return op.idempotent === true ? { readOnlyHint: false, idempotentHint: true } : { readOnlyHint: false };+ if (op.mutating === false) return { readOnlyHint: true };return undefined;}@@ -90,7 +90,7 @@ describe('buildToolDefs', () => {expect(JSON.stringify(buildToolDefs(operations, { strictParams: false }))).toBe(base);});- test('ops without annotations or a mutating tag keep the pre-annotations shape exactly (no annotations key)', () => {+ test('ops without annotations or a mutating tag keep the pre-annotations shape exactly (no annotations key; none exist today)', () => {const extracted = buildToolDefs(operations);for (const def of extracted) {const op = operations.find(o => o.name === def.name)!;@@ -101,19 +101,19 @@ describe('buildToolDefs', () => {}});- test('#5037: annotations derive conservatively from scope and explicit mutating tags', () => {+ test('#5037: annotations derive conservatively from the required mutating/idempotent tags', () => {const base = { name: 'x', description: 'x', params: {}, handler: async () => null, outputRedaction: 'no_stored_text' } as const;expect(toolAnnotations({ ...base, scope: 'read', mutating: false })).toEqual({ readOnlyHint: true });- expect(toolAnnotations({ ...base, scope: 'write', mutating: false })).toBeUndefined();+ expect(toolAnnotations({ ...base, scope: 'admin', mutating: false, idempotent: true })).toEqual({ readOnlyHint: true });expect(toolAnnotations({ ...base, scope: 'read' })).toBeUndefined();expect(toolAnnotations({ ...base, scope: 'write', mutating: true })).toEqual({ readOnlyHint: false });+ expect(toolAnnotations({ ...base, scope: 'write', mutating: true, idempotent: true })).toEqual({ readOnlyHint: false, idempotentHint: true });expect(toolAnnotations({ ...base, mutating: true, annotations: { title: 'curated', idempotentHint: true } })).toEqual({ title: 'curated', idempotentHint: true });const defs = new Map(buildToolDefs(operations).map(def => [def.name, def]));- expect(defs.get('put_page')?.annotations).toEqual({ readOnlyHint: false });- expect(defs.get('edit_page')?.annotations).toEqual({ readOnlyHint: false });+ expect(defs.get('put_page')?.annotations).toEqual({ readOnlyHint: false, idempotentHint: true });+ expect(defs.get('submit_job')?.annotations).toEqual({ readOnlyHint: false });expect(defs.get('recall')?.annotations?.readOnlyHint).toBe(true);- // The core reads in ops/pages.ts and ops/search.ts carry explicit tags, so agents see them as read-only.- for (const name of ['get_page', 'fetch', 'list_pages', 'search', 'query', 'assemble_evidence', 'search_modes']) {+ for (const name of ['get_page', 'fetch', 'list_pages', 'search', 'query', 'assemble_evidence', 'search_modes', 'get_links', 'traverse_graph']) {expect({ name, readOnlyHint: defs.get(name)?.annotations?.readOnlyHint }).toEqual({ name, readOnlyHint: true });}for (const op of operations) {@@ -208,6 +208,57 @@ describe('buildToolDefs', () => {// default state's byte-identity is pinned above.// ---------------------------------------------------------------------------+// ---------------------------------------------------------------------------+// #5952 (#5037), ported to the agent-contract rule: hints derive from the+// required `mutating`/`idempotent` tags, not from scope.+// ---------------------------------------------------------------------------++describe('default ToolAnnotations (#5952, ported)', () => {+ const defs = new Map(buildToolDefs(operations).map(d => [d.name, d]));+ const synthetic = (name: string, extra: Partial<Operation>): Operation => ({+ name,+ description: `${name} test op`,+ params: {},+ handler: async () => null,+ outputRedaction: 'no_stored_text',+ ...extra,+ });++ test('writes never carry readOnlyHint: true', () => {+ for (const name of ['put_page', 'delete_page', 'add_link', 'submit_job']) {+ expect(defs.get(name)!.annotations?.readOnlyHint, name).toBe(false);+ }+ });++ test('a read-scoped op that declares mutating is never marked read-only', () => {+ const readScopedWriters = operations.filter(o => o.scope === 'read' && o.mutating === true);+ expect(readScopedWriters.map(o => o.name)).toContain('think');+ for (const op of readScopedWriters) {+ expect(defs.get(op.name)!.annotations?.readOnlyHint, op.name).not.toBe(true);+ }+ });++ test('an untagged synthetic op stays unannotated', () => {+ const [write, read] = buildToolDefs([synthetic('w', { scope: 'write' }), synthetic('r', { scope: 'read', mutating: false })]);+ expect('annotations' in write).toBe(false);+ expect(read.annotations).toEqual({ readOnlyHint: true });+ });++ test("an op's own annotations win verbatim, with nothing merged in", () => {+ const [def] = buildToolDefs([synthetic('r', { scope: 'read', mutating: false, annotations: { title: 'custom' } })]);+ expect(def.annotations).toEqual({ title: 'custom' });+ expect(defs.get('forget')!.annotations).toEqual(operations.find(o => o.name === 'forget')!.annotations!);+ });++ test('every derived readOnlyHint sits on a non-mutating op', () => {+ for (const def of defs.values()) {+ const op = operations.find(o => o.name === def.name)!;+ if (op.annotations || def.annotations?.readOnlyHint !== true) continue;+ expect(op.mutating, def.name).toBe(false);+ }+ });+});+describe('buildToolDefs strictParams emission (WP3/D14.1)', () => {const strictDefs = buildToolDefs(operations, { strictParams: true });diff --git a/test/ops-mutation-tags.test.ts b/test/ops-mutation-tags.test.tsnew file mode 100644index 0000000000..788751ac72--- /dev/null+++ b/test/ops-mutation-tags.test.ts@@ -0,0 +1,33 @@+/**+ * Agent operator contract v1 (A2): every op declares `mutating` and+ * `idempotent`. MCP annotations (`readOnlyHint`, `idempotentHint`),+ * `--tools-json` and the safe-recovery rule (`retryable` only for idempotent+ * writes) all read these tags, so an untagged op would silently fall back to+ * "unknown effect".+ */+import { describe, expect, test } from 'bun:test';+import { operations } from '../src/core/operations.ts';+import { isPersistenceIpcMutation } from '../src/core/persistence/ipc.ts';++describe('op mutation tags', () => {+ test('every op sets mutating and idempotent as booleans', () => {+ const missing = operations.filter(op => typeof op.mutating !== 'boolean' || typeof op.idempotent !== 'boolean').map(op => op.name);+ expect(missing).toEqual([]);+ });++ test('a non-mutating op is idempotent by definition', () => {+ expect(operations.filter(op => op.mutating === false && op.idempotent !== true).map(op => op.name)).toEqual([]);+ });++ test('journaled persistence mutations are mutating and idempotent (same request_id, same effect)', () => {+ const wrong = operations.filter(op => isPersistenceIpcMutation(op.name) && 'request_id' in op.params && !(op.mutating && op.idempotent));+ expect(wrong.map(op => op.name)).toEqual([]);+ });++ test('ops that enqueue or spend are not idempotent', () => {+ for (const name of ['submit_job', 'submit_agent', 'think', 'sync_brain', 'migrate_embeddings']) {+ const op = operations.find(o => o.name === name)!;+ expect({ name, mutating: op.mutating, idempotent: op.idempotent }).toEqual({ name, mutating: true, idempotent: false });+ }+ });+});