Repository navigation
memory.inspect reports one user, agent or session's own rows apart from what it reads - #186
Merged
Merged
Conversation
…om what it reads A read-only viewer op: the live rows whose user_id, agent or session_id names the subject (own) apart from every other live row of the namespace (shared), each with counts, tags, categories and the newest rows cited by memory_id, version and content_sha256; the subject's own ledger calls in a window, without the dashboard's and the assistant's; and the guide, categories and, for an org admin, the extraction policy that create its memories. It is in the assistant toolset; a narrowed token cannot call it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…second view others The newest rows are located without the value, then their value_preview read by (memory_id, version), as memory.list does. The second view is `others`, since `shared` names the promoted layer, which neither view counts. A view whose counts failed is not complete; versions are counted distinct; the activity text says the calls are the ones the ledger files under the subject. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
A preview cut between the two escapes of an emoji decoded to a lone surrogate, which the UTF-8 response refused. The counts read signals failure by its value; `versions` says it includes the entity tagger's re-emits; the budget comment counts the reads; the integration test inspects a session that holds a row and checks `versions` against the history table. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…y a cut preview as cut An uncut preview that began with a quoted word lost its tail to the cut handling; the preview read now says whether the value was longer than its preview. Activity is one entry per operation with its calls and successes. Every output field has a description; equal counts sort by name; the unit test's category stubs reach the catalog handler. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…at module top The activity docstring opens with a whole sentence, which the SDK keeps; the two unit tests that build their own fake also serve the catalog handler. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
An inspection names no agent, user or session, so the ledger never filed it under the subject and leaving it out did nothing, while leaving out mentor.brief hid an agent's own brief. The integration test waits for the exact calls that name the agent. 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]>
…fails A failed grant read skipped the whole report; it now lands in `skipped` and the policy stays withheld. The activity text names the narrowed token's pinned user and session, which the ledger files a call under too. 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]>
A namespace's `retention_days` sets its ledger's TTL and replaces the deployment's, so the gap used the wrong number for any namespace that sets one. The docs name what `own` holds for a session. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…er's The SDK surface snapshot gains `inspect`. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
row_in_scope refuses when the grant read fails rather than raising, so the report told an org admin they were not one. The refusal it could not verify is read from fail_closed and lands in `skipped` with its own reason. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…he server's The check-level reset was redundant: the authorization check clears it on entry. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
A clean refusal restores a note an earlier check in the request left, so without the reset a non-admin was told their access could not be read. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… the exposure ledger A short secret's hash can be guessed, so a high-sensitivity row is listed with neither excerpt nor hash, as memory.list lists it. Each call that lists rows writes one exposure-ledger row with their keys, so walking a namespace's subjects is counted. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…request scope The stored column differs from the served hash for an object with a null field, so the listed hash now comes from the reports' citation read, empty for a high row, a value past the hash bound or a row revised between reads. Rows carry `sensitivity`. Every read of memory rows takes the request's read scope. The texts that said nothing is written name the exposure-ledger row. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ndex prunes The citation read by memory_id scanned the namespace's live rows again; by the whole identity it reads only the listed rows' granules. The texts name the usage fold's `acted` credit an exposure row can feed, and every reason a hash is empty. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…oped read 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]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…'s count Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The unit test also checks that the citation read takes the request's scope. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…one accessor identity.app.registration.namespace_retention_days reads it from the directory row; the two store copies are gone. The citation read alone withholds a high row's hash, the activity text names the worker rows it leaves out, and an admin whose policy read fails is tested. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Each read is driven for every subject, both views and a narrowed scope; the corpus gains their shapes. Docstrings name the three agents and what other domains read from identity's namespace directory. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Two rows of one key written in the same second listed in either order at the limit; memory.list breaks the tie the same way. The exposure row's top_k is the most rows a call lists. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…reak is tested 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]>
memory.bulk_set declares no such field. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…is exported Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
zlareb1
force-pushed
the
feat/i160-inspect
branch
from
November 3, 2026 07:04
6487bc9 to
ea7f4af
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related: #160
Changelog category (leave one):
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):
memory.inspect(viewer, read-only) shows one user, agent or session of a namespace: the live rows filed under it (own) apart from every other live row it also reads (others), each with counts, tags, categories and its newest rows cited bymemory_id,versionandcontent_sha256; the calls the ledger files under it in a window; and the guide, categories and, for an org admin, the extraction policy that create its memories. It is in the assistant MCP toolset; a token narrowed below the namespace cannot call it.Why
Issue 160 asks to inspect a user, agent or session and to keep what it wrote apart from what it can read. The existing reads blur the two:
memory.listfiltered onagentlists an agent's rows, but the agent name records the writer and is not a read boundary, so that list never stands for what the agent knows. Nothing read the guide revision, the categories and the extraction settings that shape a subject's memories in one place, and nothing said which of them a caller may not see.What changes
server/memory/api/models_inspect.py,ops_inspect.py:memory.inspect,subject(user,agentorsession) andid; the unset-and*are refused.sample_limit(default 10, at most 50) andwindow_seconds(default 7 days, 1 hour to 90 days). Viewer, idempotent, not audited, soread_onlyand served on the read-only MCP surfaces.server/memory/store/inspect.py: the reads, each on the(org, namespace)prefix of its table's sort key; the subject's column is one of three fixed names and the id is bound.namespace_report_hash_max_bytesnow also bounds the valuesmemory.inspectreads to cite a hash.own: the subject's column equalsid;others: it does not): counts by type, status and source class with the first and last update; the 20 most used tags; the registered categories its rows are filed under (loom.memory_categories); the newest rows with key,memory_id,version, identity,actor,sensitivityand a 200-character excerpt. Theircontent_sha256comes from the reports' citation read (revisions_for, asnamespace.auditcites, with each row named by its whole identity so the primary index prunes the read): the hashmemory.getserves, which differs from the stored column for an object with a null field, so anif_match_sha256taken from it matches. It is empty for a high-sensitivity row (a short secret's hash can be guessed;memory.listwithholds it too), for a value pastnamespace_report_hash_max_bytes, and for a row revised between the two reads. A high-sensitivity row has no excerpt either.scope(scope_and), as the read-scope rule asks of each store reader, though a narrowed token is refused before the handler; the preview and version reads are keyed by the ids those reads returned. The newest rows are located withoutvalue, then theirvalue_previewis read by(memory_id, version)withoutFINAL, asmemory.listdoes: one statement underFINALwould read every row's value before its limit. A preview of a value longer than the 2,048 bytes it keeps (value_len > 2048) is closed and decoded, dropping a cut escape or half of a surrogate pair; an uncut one is decoded whole or kept as it is.memory.promote,loom.shared); each definition says so. The second view isothers, notshared, since Loom names the promoted layer that way.loom.memory_versionsholds for each listed row (uniqExact(version), so a duplicate not yet merged away counts once; the entity tagger's re-emits are counted, whichmemory.historyleaves out, and the field says so).loom.agent_eventsfiles under the subject, one entry per operation with its calls and the ones that succeeded, leaving out worker rows and the dashboard's and the assistant's calls (INSPECTOR_CONSUMERS). The ledger files a call under theagent,user_idandsession_idits arguments name, or the user and session a narrowed token is pinned to, so a call by anyone that names the subject is counted (an agent's ownmentor.briefincluded), and a servedmemory.inspect, which names none, is not; the docs and the description say "the calls the ledger files under the subject".server/memory/app/inspect.py: each section's read is guarded; a failure lands inskippedassection: error type, and a skipped section is not an empty one.settingsreads the guide (revision, summary) and categories through their handlers, and the operator extraction policy only whenrow_in_scopegrants the caller org admin (extraction_policy_unavailablesays why otherwise; a grant read that fails makesrow_in_scoperefuse, and a refusal this check could not verify (fail_closed.unreadable(), cleared just before it, since a clean refusal restores a note an earlier check left) is reported inskippedwith its own reason, not as a non-admin's). It says that extraction instructions are per request: no user, agent or session setting stores them.activity.gapnames a ledger that keeps fewer days than the window, judged by the namespace's ownretention_days(which sets its ledger's TTL) before the deployment's, asmentor.briefdoes. Both read it through one accessor,server.identity.app.registration.namespace_retention_days, over the directory row;mentor.brief's own copy of the statement inserver/insights/store/mentor.pyis removed; an unread retention is skipped and claims no gap. A view whose counts read failed reportscomplete: false.server/operations/toolsets.py:memory.inspectjoins the assistant toolset;server/transport/mcp_descriptions.pygives it a description.server/identity/domain/read_scope.pyis unchanged:memory.inspectis not a scoped op, so a token withread_scopeown_userorown_sessionis refused. A pinned user would read the rest of the namespace throughothers.server/insights/app/op_mix.pyclasses it as a read;OP_BUDGETS_P99_MSgives it 3000 ms.docs/features/namespaces-and-sharing.md: a row in the operations table and a section on what each view holds.Scope and risk
system.query_log):valuefor the listed rows (at mostnamespace_report_hash_max_byteseach): 2.5–16.5 MiB per view, against 84 KiB to locate the rows and 1.4 MiB for their previews. One statement readingvalueunderFINALto list them took 14 MiB.FINALonloom.memory, novalue), so the cost grows with the namespace's row count, not the subject or the size of its values.loom.memory's row count before and after. Its one write is the exposure-ledger row below, which inside a run can feed the usage fold'sactedcredit, asmemory.list's does.memory.list; a high-sensitivity row's excerpt and hash are empty, as onmemory.list.loom.memory_exposures, operationmemory.inspect) with the listed keys, asmemory.listdoes, so walking a namespace's subjects is counted in a token's read breadth.Compatibility, rollout and rollback
memory.inspect, maturityexperimental). Nothing removed or changed.UNKNOWN_OPfor it, and its assistant listing does not carry it.Tests
tests/unit/test_memory_inspect.py): the sentinel ids are refused; the op is a viewerread_onlyop;ownandothersfilter on the subject's column with the id bound, each with its subject's definition; a view counts, lists and cites, the excerpt read from the listed version's preview only; a cut preview decodes; a view whose counts failed is not complete;sample_limit: 0reads no rows; activity leaves out the inspectors and names the retention gap, the namespace's own retention winning over the deployment's, and an unread retention claims none; the extraction policy is read only for an org admin; an unreadable grant (the realrow_in_scopeover a check that notes the failed read and refuses) withholds the policy, lands inskippedwith its own reason and marks the request the server's; an org admin whose policy read fails is told "the policy could not be read" and the section is skipped; while a failed read an earlier check noted is not blamed on a clean refusal; a high-sensitivity row lists no excerpt and no hash; a row revised between the two reads is listed without a hash; each of the four reads that select rows applies its scope; the listed keys go to the exposure ledger, and a call listing none writes no row; a failed section is skipped, not raised.tests/integration/test_memory_inspect.py, private ClickHouse and server with auth on): three agents (one writing a high-sensitivity row) and two users; inspecting the agent splits its two rows (own) from the other agent's one (others), inspecting the user splits its row from the rest, and inspecting a session that holds a row splits it the same way; a high-sensitivity row is listed with no excerpt, no hash andsensitivity: high; an object value with a null field is cited with the hashmemory.getserves; the listed row'smemory_idandcontent_sha256equalmemory.get's and itsversionsequals the versionsloom.memory_versionsholds; tags, a registered category filed on the row, the guide revision and the category count read back; the extraction policy is unavailable to a writer; the agent's activity is exactly the calls that name it (twomemory.set, onememory.get), none of the inspections; nothing is written toloom.memory, and the exposure-ledger rows for the namespace hold the keys listed; a token pinned withread_scope: own_userand a token for another namespace are both refused with 403.tests/integration/test_cross_principal_leakage.pylistsmemory.inspectamong its core surfaces; the walk now builds a Literal field from its values when the shared hint is not one of them, so the op is probed with a tenant B token against tenant A's data. It passes, as does the assistant toolset suite.tests/analyzer): amemory_inspectcase drives every store read for each subject, both views and a narrowed scope;tests/analyzer/shapes.txtgains its 53 shapes, and the analyzer passes them against a migrated ClickHouse.make format-check lint typecheck, the unit tests above and the generator checks.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 each statement against the tables it reads on a live server.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make format-check,make lint,make typecheckandmake test-unitpass; the integration suite passes if server behaviour changed.main; no merged migration is edited. (No migration.)npm --prefix frontend run build) and its tests pass, iffrontend/changed. (No frontend change.)docs/describe the system as it now is, and this description names any operator steps and wire changes.git commit -s), as CONTRIBUTING.md asks.🤖 Generated with Claude Code