Repository navigation
namespace.inventory reports what a namespace holds, with members apart from the identities seen on its rows - #170
Merged
Merged
Conversation
…served identities Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… has its description Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ake providers for health and inventory Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…eir planes, and reports an unreadable admin check as the server's Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…tage, and counts personal and inherited collections honestly Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…any scope, and survives an unknown embedding model Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…e counted by a statement in their store 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]>
…tuses); one live-record rule in the record store Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…oin the analyzer corpus Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…te; field comments say which counts the scope bounds Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ays how it reuses the page statement Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…bers are named as grant holders; one run tally statement Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…s as scoped Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… one tuple in core.errors Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…tested for no write time Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
zlareb1
force-pushed
the
feat/i160-inventory
branch
from
November 1, 2026 15:39
a24c8e9 to
55dbdcb
Compare
…eeps its total, tested on real SQL 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]>
… holds grants Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…n one statement; a failed admin check stays in its section Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…cstring names agent grants Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…age; any_live_grant is gone Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… checks its reason 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]>
This was referenced Nov 1, 2026
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):
namespace.inventoryreports what a namespace holds and who appears in it: live counts and newest write for memories, records, documents, runs and integrations, the member count, and the agents, authors and subjects observed on memory rows, each labeledcomplete: falsewith a reason when it was not counted. Under a read scope bound to one user, the memory and run counts and the observed agents, authors and subjects are that user's; documents and members are counted namespace-wide, and records and integrations are not counted./v1/healthnow reportsfake_embedding(and soproviders_degraded) for a keyed embedding model with no key and forLOOM_EMBEDDING_PROVIDER=fake, which are served by the fake embedder.Why
Issue 160's "What is in this project?" and "Who are the users in this project?" starters need one read that answers with counts and freshness per plane and says which sections are missing, and that keeps registered members, row authors and memory subjects as separate populations.
namespace.summarycounts memory types and recent activity only, and nothing today reports documents, records, runs or members beside memory, or names what a caller could not see.namespace.inventory(viewer, read-only,experimental) composes existing tables; it adds no storage:memories(loom.memory, the rows a read serves: not tombstoned and in a served status, throughserved_status_sql, the definition the search legs use, so a duplicate, superseded, proposed or rejected row is not counted; a row pastexpires_atorvalid_tois served bymemory.listandmemory.getuntil the sweep, so it counts (search leaves it out).memory.list's default page also keeps rejected rows, which is left as it is here: its repository functions serve other callers with every status. The observed populations read the same rows),records(loom.memory_records, active rows: a rewritten record keeps its earlier version as asupersededrow, and the record reads serveactiverows only),documents(loom.documents, current versions),runs(loom.agent_runs),integrations(loom.memory_webhooks, not removed). Each carriescount,latest_at(None when empty) andcomplete. Each count is read through the plane that owns its table (memory.app.query.memory_tally,memory.app.records.record_tally,knowledge.app.document_reads.document_tally,tasks.app.run.run_tally,memory.app.webhooks.webhook_tally, a count statement inserver/memory/store/webhooks.pythat reads no URL or secret), so each table's liveness rule stays in its own store, and the observed identities come frommemory.app.query.identity_tally. The observed identities are read from the memory store, not from a store of the identity plane's own.memberscounts the grant holders, the people holding an active grant, folded asgrants.listfolds them (server/identity/store/grants.py::member_countcounts overgrants.list's own statement, with the namespace predicate widened to a lineage). For acol-collection the lineage is the collection and its ancestors (from the cached tree), since a parent's grant reaches every child, so a child's count includes the people its parents grant. A pending join request alone, a group, an agent and a service account are not people and are not counted. A grant toeveryone, a group or an agent (every end user signed in under that agent) anywhere on the lineage, or a code namespace marked readable by the whole org (authz.is_org_readable_code_namespace, now public), widens who can read without naming them, so the count is thencomplete: falsewith that reason; a personal collection, whose owner holds no grant, is not counted. The subject kinds come fromserver/core/principals.py(aSERVICE_ACCOUNTconstant is added there) and match lowercase.grants.liston the namespace (and, for a collection, on each ancestor) lists those grants. A token whose own claims name the namespace reads it without a grant and is never counted; the count is of grant holders, not of everyone who can read.agents,authors(the server-stampedactor) andsubjects(user_id) are distinct values on live memory rows, each with its total and the largestpopulation_limitby row count.subjectsnever includes the unset-./v1/healthand this op read it through the same two helpers (theembedder_key_missinghealth problem keeps its own key check:loom doctorruns it before boot from the keys and environment it is handed, not the process's),server.llm.client.llm_is_fakeandserver.embedding.embedder.embedder_is_fake. The embedder helper uses the condition the embedder factory falls back to the fake on (_key_missing, shared with_served): a fake model orLOOM_EMBEDDING_PROVIDER=fake, or a keyed provider without its key./v1/health'sfake_embeddingtherefore now also turns true in two cases it missed: a keyed embedding model with no key, andLOOM_EMBEDDING_PROVIDER=fakeover a model name that does not start withfake. Both are what the process serves, and the first is what its docstring already promised;providers_degradedfollows it. A model name no provider serves (provider_forraises) reads as not fake, as before: building its embedder fails, so no fake serves it, and health and the inventory still answer.asyncio.TaskGroup, on its own (one helper,_attempt, decides how a read fails; the outage errors are one tuple,server.core.errors.BACKEND_NOT_NOW, which the sharing gate now also reads): a failed read is logged and iscomplete: falsewithread failed: <error type>, and the rest still answer. A store that is down, past its deadline or overloaded fails the whole call with its usual error, as any read does, and cancels the other legs' reads, so an outage is never answered as a successful report of empty sections.Access: the integrations count is shown only to a namespace admin, as
webhook.listis admin-only. When that check could not read the grants (an unverified refusal), the section readsread failedand the request is marked the server's failure (note_answered_unverified), asrow_in_scopedoes; the rest still answer. The op is classified inSCOPED_OPS: under a token pinned to one user, or a request withread_scope=own_user/own_session, every memory and run count, and each observed population, carries the scope's user (and session) predicate. Documents and members are counted namespace-wide under any scope, as theknowledge.*ops andgrants.list(which a narrowed token may call) read them. Records and integrations are not read and are reported as not counted: a record key holds one active record whoever wrote it last (nomemory.record.*op serves a narrowed token), andwebhook.listis refused to a narrowed token. A namespace-wide caller narrows to one user withread_scope=own_useranduser_id, which the "Analyze one user's memories" starter needs.Scope and risk
col-collection the members leg first reads the cached tree), each filtered on(org, namespace), the key prefix of every table read, except two org-wide reads the member count shares withgrants.listand the sharing checks: the alias join ofgrants.list's statement readsloom.namespaces FINALby org, and acol-collection's tree comes from the grant cache (loom.collectionsby org). The observed populations are oneGROUP BYover live memory rows each, the most expensive of the nine. Budget: 800 ms p99.system.query_logeach of the three population statements and the memory count reads 300,000 rows; the population statements take 30–37 ms at the median and at most 153 ms (the first, cold call), with at most 9.1 MiB of memory; the member count takes 71 MiB at its peak on the grant folding, over an empty grants table. That is the folding statement's own cost:grants.list's page statement peaks at the same 71 MiB, and the count with the page's two sorts and its limit removed peaks at 68.5 MiB against 68.5 MiB with them, so reusing the page statement adds nothing measurable.experimental, so it is not listed under?toolset=all; over MCP it is reachable throughloom_op. It joins the assistant MCP toolset (a separate open change) after both merge.Compatibility, rollout and rollback
namespace.inventory. No existing op or field changes.Tests
tests/unit/test_namespace_inventory.py): every plane and population counted namespace-wide; underown_userevery memory and run statement binds the user, documents and members are counted namespace-wide, and records and webhooks are never read; underown_sessionevery statement binds the session; a failed read is labeled and the others answer; integrations are not read for a non-admin, an unverified admin refusal readsread failedand marks the request the server's, and any other admin-check error is labeled too, leaving the other sections complete; a grant to everyone, a group or an agent leaves the member count incomplete with its reason, a collection's count is taken over its whole lineage in one statement, the lineage statement binds both of its grant reads, a personal collection reads no grants, an org-readable code namespace leaves the count incomplete, and a plain namespace never reads the collection tree; a store outage fails the call and cancels the other reads; a zeropopulation_limitkeeps the totals; the capabilities follow the two fake-provider helpers.test_read_scope_admission.pyholds the three new scoped readers (reads.live_tally,reads.identity_tally,runs.run_tally) to a requiredscopeargument. The analyzer corpus (tests/analyzer) now runs the inventory handler, so its nine statements are inshapes.txt, and the grants case adds the member count over a lineage.test_embedder_is_fake.py: the helper agrees with the embedder_servedbuilds for a fake model, a fake provider, a keyed model without its key and one with it, and a model no provider serves reads as not fake.test_health_problems.py: the likely-cause case now gives its real embedding model a key, since without one the process serves the fake, and a keyed model without its key readsfake_embeddingandproviders_degraded.tests/integration/test_namespace_inventory.py, private ClickHouse and server): memory rows for two users and the unset user, one document, one record written twice, a run for each user, one webhook, grants for two people (one under two spellings), one pending join request, one revoked grant and one service-account grant, and stored duplicate, superseded, proposed and rejected rows plus one row past its expiry; the namespace-wide inventory counts five memories, one record, one document, two runs, one integration, two members (complete), two subjects with the unset user left out, the writing agent and the stamped author; a viewer token gets every section but integrations; a token pinned to one user counts only that user's two rows and its one run, reports records as not counted, names that user alone as a subject, counts the namespace's document and its two members, and reports integrations as not counted; a namespace-wide token asking forread_scope=own_usergets that user's counts; a population limit of 1 lists one subject and keeps the total of two; four collections created through the ops (creator service-account grants on each): a root granting one end user counts one member, complete; its child granting another counts both, complete; a collection granting an end user and an agent counts one, incomplete; one granted toeveryonecounts none, incomplete; an empty namespace reports every plane at 0 with no write time (if(n = 0, NULL, max(...)), not the epoch) and empty observed populations.make format lint typecheck,make test-unit.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's scope predicate, the admin gate and the integration run against 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