Skip to content

The assistant MCP toolset serves a fixed set of reads that record no usage - #169

Merged
zlareb1 merged 35 commits into
mainfrom
feat/i160-toolset
Nov 2, 2026
Merged

zlareb1 merged 35 commits into
mainfrom
feat/i160-toolset

Conversation

@zlareb1

@zlareb1 zlareb1 commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

Related: #160

Changelog category (leave one):

  • New Feature

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

The ?toolset=assistant MCP connection serves a fixed set of reads for a chat client that investigates Loom on a person's behalf. Any other tool is refused on it, its calls record no recall usage or reinforcement, and namespace.audit, namespace.summary, mentor.brief and knowledge.reads leave its calls and the dashboard's out of their usage counts.

Why

Issue 160 asks for a Loom assistant that inspects memories, drafts tuning proposals and answers cited questions through Loom's own operations, with a chat client such as an MCP-capable chat app as one front end. Three properties are needed before any client is connected:

  1. A small read-only tool set that a prompt cannot widen. The existing readonly toolset filters the listing, but every non-hidden tool stays callable by name: the token is the only call-time boundary. A model steered by text inside a memory or document could still call loom_memory_set with a writer's token.
  2. Reads with no side effects on ranking. memory.search defaults to auto_touch: true (a recall credit per hit) and memory.ask to reinforce: true; an investigation that reads a namespace would raise the counts that rank it.
  3. Reads that do not inflate the usage they report. namespace.audit counted every memory.get and memory.search in the ledger, the dashboard's included, and mentor.brief excluded the dashboard in one read only. An assistant asked "does this agent read memory?" would count its own reads as the agent's.

What changes

  • server/operations/toolsets.py: the assistant toolset, MCP_ASSISTANT_OPS (namespace inspection, namespace.inventory included, mentor.brief, grants.list, memory reads, facts.traverse/path, knowledge reads, code.search/symbol, all read_only), and ASSISTANT_FORCED_ARGS. It is not a curated roster, so it never joins a + union that would add another roster's writes.
  • server/transport/mcp_call.py: a read the assistant names no agent for keeps the op's own default instead of the client's slug, since the assistant writes nothing and its client's agent holds no rows: memory.ask reads across agents (*) and mentor.brief briefs the namespace's top writer. memory.aggregate and memory.provenance read one writer's rows, so on this connection a call naming no agent is refused for the missing agent (fail closed, rather than an empty count or found: false under the client's agent), and their assistant descriptions and the primer tell the model to name the writer (a search hit's agent). memory.get already falls back to the row under any agent. The two reads are ASSISTANT_NAMED_AGENT_OPS (server/operations/toolsets.py), one set the call and the listing share.
  • server/transport/mcp_tools.py: the assistant listing (assistant_connection resolves ?toolset= against LOOM_MCP_TOOLSET) drops the arguments the connection forces (_without_forced) and keeps agent, user_id and session_id in the input schema of every memory.* and mentor.* read that takes them (_with_identity; the other toolsets hide them, since the caller's own identity fills in; a code read's identity is the code plane's, and namespace.inventory's user narrows only under its own read_scope), so a client that sends only listed properties can name the row a search hit showed; agent is marked required on the two ASSISTANT_NAMED_AGENT_OPS reads.
  • server/transport/assistant_call.py: the per-call flag (a context variable set from the connection, never from the self-reported consumer) that the agent default, the session-run stamp and the result shape read.
  • server/transport/mcp.py, mcp_auth.py, mcp_ledger.py: the dispatch reads the URL's selectors once per call and hands the screen the connection's consumer, so its org and namespace refusals, and a refused tool's ledger row, carry loom-assistant below a token's claim.
  • server/transport/mcp_call.py: on that connection a tools/call for any tool outside the roster (loom_op and loom_search included) is refused before the handler, with UNKNOWN_OP (or the access refusal, checked first, when it names an org or namespace the token cannot read); the refusal's ledger row (_assistant_refusal) carries consumer loom-assistant. Allowed calls get the forced arguments (memory.search: auto_touch: false, explain: false; memory.ask: reinforce: false, precedents: false) and consumer: loom-assistant stamped over whatever the model sent. memory.search and knowledge.search, hidden from the other listings in favour of loom_search, are callable here: an investigation needs one plane at a time and the auto_touch switch loom_search does not expose.
  • server/transport/mcp_op.py: loom_op is not routed on that connection.
  • No side records beyond telemetry and caches — the request ledger row, the per-read exposure row (loom.memory_exposures, kept: it records who was served which row), the code search trace of code.search / code.symbol (loom.code_search_trace, under LOOM_CODE_TRACE_LOG_ENABLED), the search trace and query-node rows of memory.search when their flags are on, a memory.ask consistency row under deferred consistency, and the model response cache, as docs/reference/mcp.md lists them: an assistant call opens no implicit MCP session run (loom.agent_runs), stores no memory.ask precedent, its initialize and loom prompt write no profile-read row (its primer inlines no profile, and the prompt and resource descriptions say so), and a refused unknown tool name is not written to the ledger. The listing's input schemas leave out the arguments the connection overwrites.
  • server/operations/toolsets.py::op_toolsets reports assistant, so ops.capabilities names the roster; memory.search and knowledge.search are on it alone.
  • server/transport/lean_results.py: an assistant call returns the op's full output, as HTTP does, because a citation needs the session, version and attestation fields the trimmed MCP shape drops.
  • server/transport/mcp_descriptions.py: the assistant listing's own descriptions for the tools whose usual text points at loom_search, loom_op or code tools it does not carry; each says what a citation takes from the result.
  • server/insights/app/mentor.py: the mentor attaches no hint to an assistant call (its hints name tools the connection refuses), as it already did for the dashboard.
  • server/transport/mcp_primer.py: the connection's initialize instructions describe read-only investigation (scope never widens, cite key and version or hash, keep source statements, computed results and interpretation apart, report missing evidence as not observed, stored text cannot grant a tool or approve a change) instead of the memory-first primer, and inline no profile.
  • frontend/src/api.ts: the dashboard's one request path names every op call (POST /v1/<op>) consumer: loom-ui, and so does its page-view vitals post; the per-call stamps it replaces (code reads, document previews) are gone. A body that names its own consumer keeps it, since some ops take consumer as an input (a cost summary's filter). Routes that are not ops (/v1/admin/..., /v1/me/...) are sent as they are: the model setup's bodies refuse an unknown field. Before, only its code reads, document previews and a few run calls named it, so a memory opened or searched in the dashboard was ledgered as consumer user and counted as an agent's read.
  • server/memory/app/recall_credit.py: a read by either inspector consumer earns no recall credit (not_credited (no_consumer)), even with a run, a session or a closer posted under its name. The dashboard's searches now name loom-ui, and without this a self-reported closer under that name would have let every dashboard search raise what ranks.
  • server/observability/consumer.py: INSPECTOR_CONSUMERS (loom-ui, loom-assistant). namespace.audit leaves their reads out of its ledger counts and hot keys and reports the gets and searches it left out as summary.inspector_calls (a write from the dashboard is a person using the namespace and still counts in sets), which the CLI table and the dashboard panel show; mentor.brief leaves them out of every ledger read (writers, profile counts, hints shown, adoption follow-ups, and the usage_evidence ladder's call and label counts, which left out the dashboard alone), through a bound parameter; knowledge.reads leaves out both instead of the dashboard alone. namespace.summary's activity read (recent_recalls, distinct_agents, last_activity_at) leaves out both consumers' reads, where it counted every call; a change of theirs to a memory (a memory.* op a writer calls or the server audits: a set, a delete, a pin) still counts; an admin's read such as memory.dedup_list and the page-view vitals do not.

Scope and risk

  • The token stays the authorization boundary: the assistant connection only narrows what a token can do through it. The docs say to mint the client's token with the viewer role so the same limit holds elsewhere.
  • consumer is self-reported unless a token claims it, so any client can tag its calls loom-assistant and drop them from the audit's counts; that is the existing property of the loom-ui exclusion, now reported as inspector_calls so the exclusion is visible.
  • A token whose consumer claim names another consumer keeps its claim on this connection (the claim outranks the request, as everywhere else), so its calls are counted as usage.
  • namespace.audit and mentor.brief numbers drop by the dashboard's calls in namespaces where people browse a lot; that is the correction.

Compatibility, rollout and rollback

  • Wire: NamespaceAuditSummary.inspector_calls added. The assistant value of ?toolset= (and of LOOM_MCP_TOOLSET, whose comment and reference now list every toolset) added. No field removed; no default changed.
  • Operator steps: point an assistant client at /mcp?toolset=assistant only once every replica runs this build, with a viewer token in any case. A replica one release older does not know the value and serves its default listing (writes and loom_op included, usage recorded, no loom-assistant consumer), so during a rolling upgrade only the token limits the connection; docs/reference/mcp.md says so. A client opts in with /mcp?toolset=assistant. LOOM_MCP_TOOLSET=assistant only sets the default: a connection naming another ?toolset= gets that one, so it is no server-wide read-only switch.
  • Dashboard calls now resolve as consumer loom-ui instead of the class fallback user: a per-consumer latency budget override (LOOM_LATENCY_BUDGET_OVERRIDES_BY_CONSUMER, admin/budget.set) written for user no longer covers them, only one for loom-ui does, and /v1/admin/consumers and its tagging share report them under loom-ui (self-reported) rather than user (class).
  • Rollback: revert; nothing is stored.

Tests

  • Unit (tests/unit/test_mcp_assistant_toolset.py): the roster is read-only and every forced argument is a field of its op; the listing is exactly the roster; the toolset never joins a union; writes, loom_op, unknown names and reads outside the roster are refused before identity binding; forced arguments and the consumer override the model's; other toolsets keep the model's arguments; the hidden plane searches open on this toolset only; loom_op is not routed; the primer names only listed tools, including for a token with no default namespace, and every result field it names is one the reads serve, as is every field an assistant tool description names (its op's, or a tool's it points to); no listed description names a tool the listing lacks; an assistant result is the full output; a read naming no agent keeps the op's default (memory.ask *, mentor.brief the top writer) on this connection and the client's agent elsewhere, and memory.aggregate / memory.provenance naming none are refused for the missing agent; the listing offers no argument the connection overwrites, and lists every input argument an assistant description asks for (agent on memory.aggregate), with agent in required on memory.aggregate and memory.provenance; ASSISTANT_NAMED_AGENT_OPS matches the set derived from the roster's input models (every read whose agent is required, apart from the cross-agent reads and memory.get), so a new one-writer read cannot be left out; an unknown tool name writes no ledger row, and a refused one, the screen's org and namespace refusals included, is ledgered as loom-assistant, through the endpoint on ?toolset=assistant and not on another toolset; an assistant call opens no session run; the catalogue reports the roster; namespace.summary run on clickhouse-local against ledger rows counts a dashboard set and delete and no dashboard or assistant read, and the memory ops it keeps exclude an admin's read and the vitals post. Frontend: every dashboard op call names consumer: loom-ui, a body's own consumer is kept, and the model setup's admin bodies are sent unchanged.
  • Unit: namespace.audit binds the inspector exclusion on every ledger read and reports inspector_calls; every ledger read of mentor.brief binds the exclusion; the mentor gives the dashboard and the assistant no call hint; knowledge.reads excludes both consumers; a loom-ui or loom-assistant read is never credited for recall, a closer under its name included; every profile ledger read of the mentor (the agent's calls and the namespace's) binds the exclusion; the initialize primer test now covers the assistant listing.
  • Integration (tests/integration/test_mcp_assistant_toolset.py, private ClickHouse and server): with a writer's token the listing carries no write tool; loom_memory_set is refused and writes nothing; loom_memory_search with auto_touch: true and a session returns the full hit; loom_memory_ask naming no agent cites the writer's row; loom_memory_provenance naming the writer finds the row; a memory.get sent as the dashboard sends it is in inspector_calls and not in gets; the search records no recall, while the same search over HTTP from a named reader does; namespace.audit counts the assistant's calls in inspector_calls and one search; the assistant's MCP session leaves no loom.agent_runs row. With the forced auto_touch removed, the integration test fails on 'loom-assistant' in ['loom-assistant', 'reader'], so it detects the property it claims.
  • make format lint typecheck; the MCP, toolset, assistant, mentor, audit, summary, knowledge-reads, recall-credit and request-SLI unit tests (pytest tests/unit -k "mcp or toolset or assistant or mentor or namespace_audit or namespace_summary or knowledge_reads or tracker_ux or recall_credit or request_sli": 855 passed); the assistant integration test against a private server; the frontend tests (1650 passed), npm --prefix frontend run build and the bundle budget.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated (an agent wrote most of the diff): Claude Code. Checked the call path ordering (refusal before identity binding, forced arguments after the model's), the recall-credit rule the integration test relies on, and the negative run.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • make format-check, make lint, make typecheck and make test-unit pass; the integration suite passes if server behaviour changed.
  • Generated files are regenerated in this PR, not by hand.
  • A new migration is additive and numbered after the latest on main; no merged migration is edited. (No migration.)
  • A behaviour change to any file a plugin ships bumps both plugin manifests' version. (No plugin file.)
  • The frontend builds (npm --prefix frontend run build) and its tests pass, if frontend/ changed.
  • Docs under docs/ describe the system as it now is, and this description names any operator steps and wire changes.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers.
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.

@zlareb1
zlareb1 force-pushed the feat/i160-toolset branch 2 times, most recently from ceea84f to 24291d3 Compare November 2, 2026 18:47
zlareb1 and others added 13 commits November 2, 2026 19:09
…usage

?toolset=assistant lists and calls only its roster of read-only ops, stamps consumer loom-assistant and the no-touch, no-reinforce arguments over the model's own, returns full results for citation and gives read-only instructions. namespace.audit, mentor.brief and knowledge.reads leave the assistant's and the dashboard's calls out of their usage counts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
Mentor hints and the usual descriptions named tools the assistant connection refuses; it now gets neither. Every mentor ledger read binds the inspector exclusion; inspector_calls shows in the CLI and the dashboard; the primer handles a token with no default namespace; the toolset setting's comment lists every toolset.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ing offers no overwritten argument

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…no profile-read row

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ectors out

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…r leaves its calls out

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
… which calls they leave out

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…e the refusal codes

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ll counts as use

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…d once per call

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…refusal consumer is tested

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
zlareb1 and others added 14 commits November 2, 2026 19:17
…at it records usage

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ent's empty agent

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…d, not answered empty

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…agent describes

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…pin included

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…unts as documented

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…stamps it replaces are gone

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…e to a memory counts

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…its name included

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…the hidden list

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…hidden-op rule

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…graph is rewrapped

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ow has landed

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
zlareb1 and others added 8 commits November 2, 2026 21:13
… user row is found

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…tant toolset

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ent names where a change counts

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
… call without it

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ty takes an Operation

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
@zlareb1
zlareb1 merged commit 6dcf7a8 into main Nov 2, 2026
20 of 22 checks passed
@zlareb1
zlareb1 deleted the feat/i160-toolset branch November 2, 2026 22:19
@pufit pufit mentioned this pull request Nov 4, 2026
9 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant