Repository navigation
The SQL surface page says a grant is per namespace and serves all five views - #2211
Merged
Merged
Conversation
…ve views A reader of the Access section could not tell what one grant reaches: that a grant on a member's personal namespace also serves that member's memories and conversation turns, or that a count of sessions across members has another route. docs/reference/sql-surface.md: `loom sql-access grant` gives a user all five views over every namespace in its scope, so a grant on a personal namespace serves the memories, memory versions and conversation turns stored there, with that namespace's request ledger. A count of sessions across a team's members needs no such grant: under each member's own token, `run.list` lists the runs of that member's personal namespace with their `session_id`, and its first page answers `total`. Signed-off-by: Mohammad Lareb Zafar <lareb.zafar@clickhouse.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
The Access section sent a reader who counts sessions across a team to each member's personal namespace. A run is stored in the namespace its `run.begin` addressed, which for a team whose sessions address the shared namespace is the shared one: `run.list` on a personal namespace then lists none of those runs, with no error, and the count is short. docs/reference/sql-surface.md: `run.list` lists the runs of the namespace it addresses. The runs of the sessions that address the shared namespace are listed there, under any member's token, and those of the sessions that address a member's personal namespace are listed there, under that member's own token. Signed-off-by: Mohammad Lareb Zafar <lareb.zafar@clickhouse.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
An MCP session's own run has no `run.begin` from the client. The transport opens it on the session's first run-scoped call, in the caller's default namespace, whichever namespace the call names. A session that names a shared namespace on every call can therefore have its run in a member's personal namespace, and `run.list` on the shared namespace does not list that run. The Access paragraph of `docs/reference/sql-surface.md` states both rules: a run is stored in the namespace its `run.begin` addressed, and a session's own run in the caller's default namespace. It links to "MCP sessions" on the runs page and names the listed runs by the namespace that stores them. Signed-off-by: Mohammad Lareb Zafar <lareb.zafar@clickhouse.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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: #1232
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):
Not required.
Why
The Access section of
docs/reference/sql-surface.mddoes not say what one grant reaches. A team lead who wants session counts across members cannot tell from it that a grant on a member's personal namespace also serves that member's memories and conversation turns, or that the count has another route.The section gains one paragraph, after the sentence on which rows a view admits:
loom sql-access grantgives a user all five views (sql_v1_memories,sql_v1_memory_history,sql_v1_conversations,sql_v1_agent_eventsandsql_v1_usage_daily) over every namespace in its scope.run.list(roleviewer) lists the runs of the namespace it addresses, each with itssession_id, and its first page answerstotal.run.beginaddressed, and an MCP session's own run in the caller's default namespace, whichever namespace its calls name: the runs stored in the shared namespace are listed there, under any member's token, and those stored in a member's personal namespace are listed there, under that member's own token.The paragraph links to "A namespace a team shares" in
docs/features/namespaces-and-sharing.mdand to "MCP sessions" indocs/features/runs.md, and repeats neither.Each statement was read in the code first:
server/insights/domain/sql_surface.py(VIEWS) and the fivesql_v1_*views ofschemas/schema.sqlloom.sql_accessis ordered by(user_name, org, namespace)and has no view column (schemas/migrations/090_sql_surface.sql);loom sql-access granttakes--user,--org,--namespaces,--alland--rotate(server/cli/sql_access.py)grant_sqlgrantsSELECTon each ofVIEWSon every call, and each view admits the samescoperows (schemas/migrations/118_store_names_reserved.sql);tests/unit/test_sql_surface.pyasserts both (test_a_new_user_is_granted_the_views_alone,test_every_view_scopes_and_excludes_alike)run.listanswersserver/tasks/app/run.py(handle_run_list) reads the runs of the addressed(org, namespace)at roleviewer;RunRowcarriessession_id;totalis counted whenoffsetis 0run.beginaddressedserver/tasks/app/run.py(_open_run) writes the run row withinput.organdinput.namespace;server/tasks/store/runs.py(list_runs) filters on bothserver/transport/mcp_runs.py(ensure) opens the run with thenamespaceof the caller's defaults, andbegin_session_run(server/tasks/app/run.py) writes the row there;_bind_caller_identity(server/transport/mcp_call.py) resolves those defaults with_caller_defaults, which takes the token and the client's name and no argument of the call;docs/features/runs.md("MCP sessions") anddocs/reference/mcp.md("Implicit run") say the samerun.listneedsviewer, andRoleordersviewerbelowwriterandadmin(server/operations/base.py)Where the code differs from the statement this change set out to add, the page says what the code does:
loom sql-access grant, so the paragraph names the command.run.listcounts runs, not sessions.totalis the number of runs the filters match, and one session can hold several runs. The paragraph says that the op lists runs with theirsession_idand whattotalcounts; it does not calltotala session count.totalis null on a full page after the first, so the paragraph says the first page answers it.run.beginaddressed, and the coding plugin'srun.beginsends the namespace it resolves fromLOOM_NAMESPACE, then thenamespaceofconfig.json, then the token's first namespace that is not a wildcard, thencoding(integrations/claude-code-plugin/lib/loom-client.mjs,scopeFor). A member granted a role on the shared namespace before a first sign-in also gets no personal namespace:ensure_personal_namespace_cached(server/auth/personal_namespace.py) provisions one only for a subject with no live grant.run.liston a namespace that holds none of a team's runs answers an empty list and no error, so the paragraph names the namespace by what holds the runs and gives both cases: the shared namespace, read under any member's token, and a personal namespace, read under that member's own token.run.beginfor it:ensure(server/transport/mcp_runs.py) begins it in the caller's default namespace, which anamespacenamed on the call does not change. The default is the caller's saved pick, then the namespaces the token names, then the caller's grants ranked by role (_pick_default,server/identity/app/caller_home.py). With no saved pick and a token that names no namespace, a member who holdsadminon a personal namespace andwriteron the shared one has the personal namespace as the default. That member's session can name the shared namespace on every call while its run is stored in the personal namespace:run.liston the shared namespace lists no run of that session and answers no error.handle_run_listfilters on neitherenvironmentnormetadata.implicit, so the run is a row ofrun.listin the personal namespace, and a session of an MCP client that sends norun.beginhas no other run. The paragraph states both rules and names the listed runs by where they are stored.*for every namespace of an org,--allfor the deployment), so the paragraph says "every namespace in its scope".highrow, a redacted value, rejected and deleted rows and every row of a restricted namespace. The sentence on a personal namespace links to "What the views never show".docs/features/namespaces-and-sharing.mdhas no sentence on the SQL surface. Its one SQL statement is aninsights.querycall, an op that reads one namespace under the caller's token, so no link is added there.Scope and risk
Touches one page: 17 lines added to
docs/reference/sql-surface.md. No code, test, view, grant, op or generated page changes.Left alone:
docs/features/namespaces-and-sharing.md, for the reason above, andi18n/(the translation workflow reads the English page after the merge).run.listis refused to a token narrowed below the namespace (server/identity/domain/read_scope.pynames it in neitherSCOPED_OPSnorNARROW_SAFE_OPS), whichdocs/concepts/identities-and-namespaces.mdstates for every op that list does not name. A token carries the scopenamespaceunless it is minted narrower.What could break: a statement that is wrong. Each was read in the code, as the table shows. No hook, op, stored row or permission changes.
Compatibility, rollout and rollback
Tests
No new test: the change is prose, and the existing docs tests cover links, anchors and public copy.
What ran at this head, with no ClickHouse and no server:
pytest -n 2overtests/unit/test_doc_links.py,test_public_copy.py,test_help_docs.py,test_docs_reference.py,test_agent_instructions.py, the repository scans (test_package_contracts.py,test_op_transport_contract.py,test_tunable_constants.py,test_store_names_refused.py,test_degraded_unnoted.py) andtests/analyzer: 647 passed, 12 skipped.npx prettier@3.9.9 --check docs/reference/sql-surface.md: pass.ruff format --checkon the page, which formats the Python blocks in Markdown: pass.python3 .claude/skills/loom-writing/scripts/check_prose.pyon the page, each commit message and this description: no hit.ruff checkover the pathsmake lintgives it (server extractor sdk/python tests scripts .claude) andmake typecheck: pass.Run at the first commit and not again, since no module changed after it:
VIEWS, oneGRANT SELECTfromgrant_sqlfor each, the columns of a scope row (user_name,org,namespace,granted,updated_at), no op withsqlin its name, andrun.listwith the output fieldsrunsandtotal.Not run:
make lintandmake format-checkas wholes. No check ofmake lintreads this paragraph: its generators render from code, andtest_docs_reference.pycovers the generated regions ofdocs/reference/. The two formatters that read Markdown were run on the page.tests/integration/test_sql_surface_live_ch.pycovers the views and the grant in CI, and this change alters neither.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 wrote the paragraph, read each statement in the code and ran the checks listed under Tests.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make test-unitand applicable integration results are reported by CI; a full local run is not required before pushing.docs/reference/configuration.mdand thedocs/reference/tables (python scripts/codegen/docs_reference.py), the reach manifest,schemas/schema.sql(make schema-dump), the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py) and the standalone skill bundles (python3 scripts/codegen/standalone_skills.py).main; no merged migration is edited.hooks/,lib/,bin/,skills/,.mcp.json, the Codexplugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.npm --prefix frontend run build) and its tests pass, iffrontend/changed.docs/describe the system as it now is, and this description names any operator steps and wire changes.tests/unit/test_public_copy.py).git commit -s), as CONTRIBUTING.md asks.Unticked: this change has no generated file, no migration, no shipped plugin file and no frontend file, so those four checks do not apply; the CLA line is the committer's to confirm. The first box is ticked with the gap named under "Not run":
make lintandmake format-checkwere not run as wholes.🤖 Generated with Claude Code
Note
Low Risk
Documentation-only change to one markdown page; no code, permissions, or wire behavior changes.
Overview
Expands the Access section of
docs/reference/sql-surface.mdwith a new paragraph clarifying howloom sql-access grantscopes work and how run/session visibility relates to namespaces.The prose states that grants are namespace-scoped, not view-scoped: one grant exposes all five
sql_v1_*views for every namespace in scope (including what a personal namespace holds, minus what the views never show). It also documents an alternative for cross-member activity:run.listat viewer role lists runs (withsession_id) and returnstotalon the first page, without needing SQL surface access—with separate notes for runs in a shared team namespace vs a member's personal namespace, including MCP session placement. Links point to namespaces-and-sharing,run.list, runs/MCP, and the visibility exclusions section.Reviewed by Cursor Bugbot for commit 8d670aa. Bugbot is set up for automated code reviews on this repo. Configure here.