Skip to content

A platform admin's own authority reaches every standard namespace of every org - #2169

Open
zlareb1 wants to merge 24 commits into
mainfrom
fix/platform-admin-standard-namespaces
Open

zlareb1 wants to merge 24 commits into
mainfrom
fix/platform-admin-standard-namespaces

Conversation

@zlareb1

@zlareb1 zlareb1 commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Backward Incompatible Change

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):

A platform admin signed in to Loom (the dashboard, loom login) reaches every namespace of every org that is not restricted and not a repository, as the role's admin views already did, instead of being refused on namespaces its sign-in token does not name. Minted and bot platform-admin tokens reach the same namespaces, which includes other orgs' standard namespaces; a third-party MCP client's OAuth session does not. An MCP call that names another org and no namespace takes no default namespace, rather than running on the caller's default namespace name in that org: an op that requires a namespace fails validation naming it, one with an optional namespace runs org-wide there, and loom_search searches the caller's namespaces of that org.

Why

A person listed in LOOM_PLATFORM_ADMINS signs in with a token whose namespaces claim names only their own namespaces (login._identity_from_rows) and whose role is platform_admin. _check_authorized_claims honoured the role only through that claim: auth.can_access / auth.can_write need the namespace named, or * in the token's own org. So the gate refused, with "(JWT namespaces + no grant)", every namespace op on a namespace the person holds no grant on. Where the token named a namespace and the person held a lower grant there, claim_cap capped the claim to that grant, so a platform admin who is a viewer member of a namespace was a viewer there. Meanwhile:

  • the dashboard (roleOnNamespace, hasAdminClaim) shows a platform admin as admin of every namespace, so the admin controls it offers were refused by the server;
  • context.reads_every_namespace reads any org whole for a platform admin, and sharing.check admits it to every collection, whatever the claim;
  • a --platform-admin bot's and a loom mint-token --platform-admin token claim *, which covers every namespace of the token's own org and none of another org's.

Reproduction against main, with the claim cap, restricted check, code read, grant lookup, acted-for check and tenancy stubbed out: check_authorized(AuthInfo(subject="ada@example.com", org="o", namespaces=("personal-ada",), roles=(PLATFORM_ADMIN,)), ADMIN, "o", "team") is refused, and so is the same call on org other. The same token with namespaces=("*",) is admitted on o/team and refused on other/team. On this branch all four are admitted.

Design

The role spans every org, so the gate reads it as the principal's own authority rather than through the namespace claim. In _check_authorized_claims, _platform_covers(auth, required_role, org, namespace) is true for authz.is_own_platform_admin(auth) on a namespace that is not a repository, in an org that names a tenant: a blank, - or * org (cell.ORG_FREE, which tenancy.ensure_held passes) gets none. The gate asks it only where the token's claim, after claim_cap, does not cover the namespace. Where it holds:

  • the namespace counts as covered, the way a * claim covers its own org's, for every org;
  • no grant row caps it, since it is asked after the cap and covers whatever the cap left. A * claim is never capped either: names_namespace ignores *, so claim_cap returns None for it.

A write the claim already covers (a * bot in its own org, a session in its own namespace) never asks it, so it reads no registry row. Neither does one a known grant admits: a listing or default (CachedGate) hands the grant in, and where it reaches the role and no claim cap overrides it, the grant step admits the call and platform authority is not asked.

Unchanged, because each branch returns before this step or the predicate excludes it:

  • a mirror or code store name (is_reserved_name) is refused first;
  • a collection goes only through sharing.check;
  • a delegated token goes through _check_delegated;
  • a restricted namespace goes through _check_restricted, where platform authority stays limited to repository viewer reads;
  • a repository keeps its read-only platform authority (_platform_repository_read): writes, refreshes and administration of an index keep the claim and grant checks;
  • scoped (ns_roles), delegated (creator, parents) and impersonated tokens are not own platform authority (is_own_platform_admin), so they gain nothing;
  • check_acted_for and tenancy.ensure_held run first, so a cell still serves only the orgs it holds;
  • a token's ns_write claim still bounds its writes, as it bounds a * claim's.

What counts as a repository depends on the role asked:

  • A read leaves out the entries this process's configuration and registry snapshot hold (code_entry), with no I/O. Platform authority reads every repository anyway (_platform_repository_read), so a repository the snapshot does not hold yet costs nothing. Leaving out the snapshot's entries keeps the member write check (member_writes, a viewer check with allow_repository_read=False that runs only on those entries) the grant's.
  • A write also leaves out a namespace with an active loom.code_repos row read at the write, under sequential_reads() (NamespaceDirectory.is_repository, repo_registry.registered). The snapshot is refreshed every 30 s, so a repository another replica added a moment ago is in the registry before it is in the snapshot. The read fails closed: when the registry cannot be read, platform authority covers no write, the grant check decides, and a refusal is marked unverified. Only an own platform admin's write that its claim does not cover, on a namespace with no snapshot entry, pays this read: SELECT active, row_kind ... LIMIT 1 on the (org, namespace) ordering key of loom.code_repos (CodeRepo.is_registered_repository, with its analyzer shape). A maintainer's access row names no repository, as the snapshot, the mirrors and active_code_repo_count leave it out, so reads and writes agree on what a repository is. With self-service off it reads nothing, as the snapshot reads no registry then.
  • The MCP default pick asks the same gate through authz.CachedGate, starting with the person's saved dashboard pick at writer (caller_home._pick_default). For a platform admin whose saved pick is a namespace only platform authority reaches (no claim and no grant admits a write there), every MCP call, reads included, pays this one registry read while it picks the default: one point read of loom.code_repos per call, on a single node too, plus the sequential-consistency wait on a replicated cluster (sequential_reads() sets the consistency flag; it adds no read). CachedGate also decides proposal review and the visibility of unapproved definitions, so it keeps the write rule rather than answering from the snapshot alone. The same holds for a platform admin's org-wide rollup that asks the gate at admin per namespace: learnings.quality without a namespace checks each namespace holding unapproved drafts (learning_access.private_candidates_visible), so one with no claim or grant there pays one such read per namespace, one after another. On main those checks were refused from the cached grant maps with no read. Reading the org's registry namespaces once per rollup would remove the per-namespace cost; it is not done here. CachedGate does not memoize the read (its docstring says the gate reads it at each such check): within one gate a namespace is asked at most twice (the assistant's role probe asks admin, then writer, of a repository), and a per-gate memo would not reduce the rollup's one read per namespace, which only the batched read would.
  • A directory row's kind decides nothing. namespace.register takes it from its caller, so a namespace admin could otherwise mark a standard namespace code and take it out of platform authority, which would not read it either.

claim_cap itself is unchanged; platform authority overrides its cap at the gate's call site, where the namespace is known to be standard. claim_cap also feeds live_claims (the jwt rows of namespace.list_mine), which does not check restriction: exempting there would list a restricted namespace the gate refuses. As a result, namespace.list_mine may leave out the jwt row of a namespace a platform admin's token names after its grant there was revoked, though the gate admits it. That is an omission, not an exposure, and the dashboard does not read those rows for an admin claim.

Alternatives

  • Keep the narrow reach and make the dashboard show the server's answer. The dashboard would read namespace.list_mine for a platform admin and lock controls on every namespace without a grant. That costs a platform admin a grant on each namespace they administer. It also keeps the gate disagreeing with the role's documented span ("spans every org"), the org-wide rollups and the collection gate, and leaves a person, a bot and a minted token with different reach under one role.
  • Put * into a platform admin's sign-in claim. A * claim covers only the token's own org, so another org stays refused. It would also change what every listing built from named claims shows for that session, and the refresh path would have to re-derive the claim as well as the role.
  • Exempt platform authority inside claim_cap. Rejected for the live_claims reason above.
  • Classify repositories from the registry snapshot alone. A repository registered on another replica would read as a standard namespace on this one until its next refresh, so platform authority could write it for up to 30 s.
  • Classify repositories from the directory's kind column. The column is caller-declared, and the kinds are cached per org for 30 s, so it would both shrink platform authority on request and leave the same write window.

Scope and risk

This is an auth-model change, and it widens reach. Every own platform-admin token (a signed-in person, a --platform-admin bot, a loom mint-token --platform-admin token) reaches the standard namespaces of every org the deployment holds, at the role's level, without a grant there. Minted and bot platform-admin tokens reached only their own org's namespaces before. Consequences:

  • Revoking a platform admin's grant on a namespace no longer ends its reach there, as revoking a grant never ended a * claim's. Removing the person from LOOM_PLATFORM_ADMINS (an OAuth refresh re-derives the role), taking a person who holds the role through LOOM_OIDC_PLATFORM_ADMIN_GROUP out of that group (the first refresh whose verified ID token no longer lists it drops the role; while the provider cannot be reached the refresh answers 503 and the role is kept), disabling the bot, or revoking the token does.
  • Cross-tenant isolation holds for every principal that is not an own platform admin. The gate's only new admission is is_own_platform_admin, and tests/integration/test_cross_principal_leakage.py probes as another namespace's writer and viewer and as another org. Its new case checks the one widening: a platform admin of another org reads and writes a standard namespace, and the same claims with the admin and writer roles reach nothing.
  • A platform admin's first write to a name no row holds in another org registers it with no owner (namespace_autoregister.ensure_registered(ownerless=True), the row a write into a name in use leaves): a name in a tenant org is not an outside writer's to own, so only an admin of that name completes its registration. A first write in the admin's own org, or by an org-wide (*) token, keeps its writer as owner, as before. docs/features/namespaces-and-sharing.md and the setting's description say so.
  • A third-party MCP client's OAuth session (session_id set, first_party false: oauth.py sets first_party only for Loom's own sign-ins) gets no platform reach (_platform_covers); it keeps its claim and its grants. Loom already gives such a session nothing that outlives it: it registers no bot and links no sign-in (admin_account_routes._only_a_person), and its children end with it (delegation). An admin reach over every org would let it create lasting grants anywhere. The dashboard's password sign-in (no session), its SSO session and loom login (both first_party) keep the reach. The repository read authority (_platform_repository_read) is unchanged.
  • Every standard namespace is in reach, a tracker namespace and its sources' administration (tracker.source.*, at admin) included, as for a * claim in its own org. security.md says so.
  • Names from the caller's own org are not applied in another org, where platform authority would admit another org's namespace of the same name:
    • An MCP call that names another org and no namespace takes no default namespace (mcp_call._bind_caller_identity), for every token, an org-wide one's included (a call with no token, on a single-user server, takes the install's namespace whatever org it names, as gates.with_single_user_identity fills it over HTTP): the default is a namespace of the caller's own org, so the call names its namespace; else an op that requires one fails validation naming namespace, and one with an optional namespace runs org-wide in that org. loom_search, whose namespace the MCP screen drops, searches the caller's namespaces of that org instead (_address_home from that org's fan-out, the one named after the caller first), and fails validation naming namespace when it reaches none there. A fan-out error there is answered as raised, with a token-attributed refusal row as for a failed defaults read, since no default stands in: a server fault, or any failure that is not Loom's (a raw driver error, a bug) as BackendUnavailableError, answers a 503 and is logged; the caller's own (an org another cell holds, WrongCellError, or a new org name past the limit, the two caller errors tenancy.ensure_held raises beside the PermissionError the fan-out's gate reads as a refusal) answers a tool error with its code, as the gate would. The fan-out is read for the org as the gates read it, so a padded org is that org. A blank or - namespace names none there, as the gates read it: the binding drops it, so the op never runs on that literal namespace of the other org. A namespace refusal in another org names the grant to request and never advises omitting the namespace (mcp_auth._not_accessible_result(away=True)), as omitting it would only fail validation there. A search that lands on a namespace not named after the caller carries the namespace_defaulted note, as a defaulted one does; on main an all_mine search (its default scope) was re-addressed the same way when it reached any, and a this search ran on the namesake. Without this, a platform admin's loom_memory_set {"org": "other"} would land on the other org's namesake of its own default. docs/reference/mcp.md says so.
    • A code read's lessons default (lesson_namespaces) is set after the connection's code scope is applied, and only when the read acts in the caller's org or names none anywhere (gates.org_for_op is the caller's org or None): a code plane or scope of another org would read that org's namesake of the home.
    • A token's named claims are namespaces of its own org, of every org for an org-wide token (context.named_claims(auth, org)). In another org, the all_mine fan-out (resolve_my_namespaces), readable_named_claims, the org rollups' refused-claim list (every_namespace_scope) and the jwt rows of namespace.list_mine take none of them.
  • Not changed here: a token from a trusted external issuer keeps its signed roles, so one that carries platform_admin gets this reach as any own platform-admin token does; and an SDK or CLI that sends its own default namespace with an explicit org names that namespace on the wire.
  • Outside this gate, the org-wide rollups (context.reads_every_namespace) and the collection gate (sharing.check) test has_role(PLATFORM_ADMIN), not is_own_platform_admin, so a scoped or impersonated token with that role passes them. This PR does not change that, and the gate does not admit those tokens. The collection gate also admits a third-party client's session holding the role, so such a session can still create collection grants in any org (grants.create on a collection); it is the same has_role check and is left to the same follow-up.

Tests whose expectations encoded the narrow reach are changed, not loosened:

  • test_erasure_authz_matrix.py: a platform admin of another org may already request the erasure of o/A and o/B. Its namespace export and namespace-saga status of those namespaces change from refused to ok. Its user_id and namespace_list status stay hidden, since they need a token of the saga's org.
  • test_blacklist_authority.py: the "hides another namespace's pattern" case no longer runs for PLATFORM_ADMIN. A test asserts instead that a platform admin sweeps that namespace's pattern.
  • test_platform_admin_repository_read.py: the two registry tests classify their unregistered name as restricted, so the registry entry stays the only thing that admits the read. An unregistered standard name is one platform authority reaches.
  • test_default_namespace_gate_property.py: its oracle takes a token's claims as namespaces of its own org (every org for an org-wide token), as named_claims does, so a token of another org holding the platform-admin role names none of the world's org; the minted home of a delegated * token is still read off the claim as sent, as caller_home.minted_home reads it.
  • tests/unit/conftest.py: an autouse fixture answers the registry read with no row, as unit fakes answer statements by shape, unless a test is marked registry_rows (pyproject.toml). Without it a platform-admin write outside its claim would take the unreadable branch and refuse, so a test still expecting the narrow reach would pass for the wrong reason.

Compatibility, rollout and rollback

  • Wire: no op or field added, changed or removed. Behaviour break: an MCP call that names another org and no namespace takes no default namespace for every token, an org-wide one's included (not a call with no token on a single-user server), where it ran on the caller's default namespace name in that org: an op that requires a namespace answers VALIDATION_FAILED on namespace (a client that meant that namespace names it), one with an optional namespace runs org-wide there, and loom_search searches the caller's namespaces of that org.
  • Operator steps: none required. The LOOM_PLATFORM_ADMINS description in the configuration reference names this reach, and docs/operations/sso.md#platform-admins names it for members of the LOOM_OIDC_PLATFORM_ADMIN_GROUP group, so an operator can check that everyone listed or in the group should hold it.
  • Rolling upgrade: while builds N-1 and N serve side by side, an N-1 replica refuses what N admits for a platform admin. A refused request succeeds on retry once the rollout completes. No row or schema depends on it.
  • Rollback: a revert restores the narrow reach and leaves no rows, migrations or generated files behind.

Tests

  • Focused unit modules (pytest -n 8 -p randomly): test_platform_admin_repository_read.py, test_readable_named_claims.py, test_default_namespace_gate_property.py, test_blacklist_authority.py, test_erasure_authz_matrix.py, test_exception_text_ratchet.py, test_package_contracts.py, test_doc_links.py, test_public_copy.py, test_mcp_default_namespace.py, test_absent_org_runs_under_target.py, test_list_mine_inherited.py, test_delete_by_key.py, test_mcp_assistant_toolset.py, test_mcp_home_namespace.py, test_memory_code_plane_reads.py, test_policy_after_read_scope.py, test_request_id_binding.py, test_namespace_autoregister.py, test_admission_parity.py, test_settings_reference.py, test_namespace_restore_existing_target.py, test_mcp_named_identity.py, test_agent_instructions.py, test_namespace_resolve.py, test_mcp_worker_live_privacy.py and the five modules below, on the branch merged with main: 1545 passed (with the loom_search modules, test_all_mine_fanout.py and test_delete_by_key.py). The loom_search modules are test_loom_search_home_answers_first.py, test_loom_search_fanout_kinds.py, test_loom_search_mcp_render.py, test_mcp_readonly_toolset.py, test_mcp_client_provenance.py and test_search_default_mode.py; test_delete_by_key.py drops its source-text test of the call site: the behaviour tests in test_mcp_default_namespace.py cover when the home is chosen. Settings modules (test_live_settings.py, test_settings_defaults.py, test_settings_env_contract.py, test_settings_file.py, test_settings_every_field_read.py, test_settings_reference.py): 61 passed. The modules whose directory fakes implement code_entry and not is_repository (test_delegation.py, test_request_sli.py, test_sa_inherit_flag_gate.py, test_connected_source_authority.py, test_mcp_prescreen_org_readable.py) are among them. In test_namespace_autoregister.py, a first write from a token of another org records no owner, at the ownerless version, and the hook passes ownerless only for that token, not for one of the org or an org-wide one. Added cases cover a platform admin reaching a standard namespace at viewer, writer and admin, in its own org and another. Scoped, impersonated and delegated platform-admin tokens are refused. A viewer or revoked grant on a named namespace does not cap the admin, while the same claim under an admin role is capped. An ns_write claim bounds writes. A repository with a registry row the snapshot does not hold is read with no row read and refused for writes. A namespace whose directory row says code with no repository entry is reached at every role. An unreadable registry refuses a write, unverified, and leaves reads alone. A write the claim covers reads no registry row, nor does one a known grant admits, while a known grant below the role still asks it (that case fails without the known-grant check). A repository write is refused in the admin's own org and from another org. A third-party client's session gets no platform reach at viewer, writer or admin, in the admin's org or another, while the same session marked first_party keeps it. Within an ns_write claim no grant caps platform writes, and a write outside it is refused (these seven cases fail without the two checks). Platform authority covers nothing in a * or - org, at viewer or writer (these four cases fail without the ORG_FREE check). The registry read counts only an active row that is not a maintainer's access row; a configured entry is a repository with no read, and an unreadable registry raises ClassificationUnavailable. A dashboard-shaped platform-admin token writes another org's standard namespace over HTTP and MCP, and the same token scoped is refused (403 over HTTP). Restricted namespaces at viewer and admin, collections (registered as a repository or not), mirror names, tenancy and SCIM provisioning refuse as before. With main's server/auth/authz.py, the 9 reach, cap and ns_write cases fail. In test_mcp_default_namespace.py, a platform admin's and an org-wide token's call takes the default namespace only in the caller's org, a code read's lessons default only when the read acts in the caller's org or names no org (cases: the caller's code plane, a code plane or a code scope of another org, an explicit other org; test_memory_code_plane_reads.py covers a read with no org anywhere), and an MCP call naming another org and no namespace answers VALIDATION_FAILED on namespace without reaching the handler, with the key absent, blank, whitespace or - (the last three ran the handler on that literal namespace before the binding dropped it). A loom_search naming another org whose fan-out raises WrongCellError or a ValidationError answers a tool error with that code and one refusal row, never reaching the handler (both cases raised out of _call_tool before the catch). A call with no token naming another org takes the install's namespace, the key absent or - (both failed validation before). A search naming a padded org (acme) reads that org's fan-out (it read the padded name's, which holds nothing, before _address_home read the org through present). Through _screen_tool_call, a refused namespace in another org, plain or padded, names the grant alone, while in the caller's org, named or not, it keeps the omit advice (the two away cases fail when the screen does not pass away). In test_error_envelope.py, a namespace refusal in another org names the grant and not omitting the namespace, on the assistant toolset and the others, while one in the caller's org keeps that advice. A loom_search naming another org, through the MCP screen and the binding, at all_mine and this, for a platform admin and an org-wide token, searches the caller's namespace of that org named after it, else the first of that org's fan-out, and none when it reaches none (these six cases fail without the call-site change). The same search notes a namespace that is not the caller's own, raises BackendUnavailableError with one refusal row when that org's fan-out cannot be read (a raw RuntimeError too, with no namespace, - or blank), while one in the caller's org keeps its default and writes no row; a filled default moves to the caller's home among the fan-out; and an op with an optional namespace (learnings.quality) naming another org binds with none and validates (the note, raise, wrap and ledger cases fail without their lines). In test_readable_named_claims.py, a platform admin of another org reads team through platform authority while neither its named claims nor its all_mine namespaces there include it. In test_list_mine_inherited.py, a platform admin listing another org gets no jwt row for its own claim's name (it fails without the org rule in named_claims).
  • On the head merged with main after An identity-provider group can confer platform_admin #2167 (9360554; the commits after it change only docs, a settings comment and its generated reference, which test_doc_links, test_public_copy, test_settings_reference, test_settings_defaults, test_repo_docs and Prettier pass on): this branch's changed unit test files with the OIDC, OAuth, device-login, machine-trust, settings, ratchet, package-contract and agent-instruction modules, 1522 passed; the namespace.list_mine / namespace_membership modules, 670 passed, 1 skipped; make format-check, ruff and mypy on the merged namespace_membership.py.
  • On an earlier merge with main (8f23a8c), with -n 8 -p randomly: test_mcp_default_namespace.py, test_error_envelope.py, test_access_refusal.py, test_request_sli.py, test_all_mine_fanout.py, test_delete_by_key.py, test_platform_admin_repository_read.py, test_namespace_autoregister.py, test_list_mine_inherited.py, test_transport_layering.py, test_package_contracts.py, test_public_copy.py, test_doc_links.py, test_knowledge_move.py, test_mcp_defaults.py, test_mcp_home_namespace.py, test_mcp_named_identity.py, test_mcp_prescreen_org_readable.py, test_mcp_refusal_codes.py, test_mcp_loom_op.py, test_mcp_code_scope.py, test_mcp_assistant_toolset.py, test_mcp_auth_error_redaction.py, test_mcp_memory_repo_tag.py, test_mcp_unauthenticated.py, test_cell_tenancy.py, test_memory_code_plane_reads.py, test_readable_named_claims.py, test_default_namespace_gate_property.py, test_loom_search_home_answers_first.py, test_loom_search_fanout_kinds.py, test_loom_search_mcp_render.py, test_search_default_mode.py, test_mcp_readonly_toolset.py, test_mcp_client_provenance.py, test_exception_text_ratchet.py, test_degraded_unnoted.py, test_mcp_worker_live_privacy.py, test_namespace_resolve.py, test_repo_at_branch.py, test_absent_org_runs_under_target.py: 1388 passed. The function-length gate stays at its baseline (52 in 48 files).
  • Every other unit module that stubs namespace_autoregister or reaches maybe_autoregister (gates.authorize, knowledge.move, the upload routes), 41 modules, with tests/analyzer: 1491 passed, 2 skipped, on this head. test_knowledge_ingest.py, test_mirror_names_refused.py and test_store_names_refused.py (98 failures) fail locally the same at the merge base, in this local environment, and CI runs them. test_knowledge_move.py: two stand-ins for the caller named a subject and no org, which the ownerless rule reads; each names the org the move lands in, and its ensure_registered stub takes ownerless, asserted false for a token of that org.
  • The full unit suite and the integration suite are left to CI; no full local run is reported here.
  • Integration (test_cross_principal_leakage.py, the auth-on isolation part in CI; not run locally, as no local server is up): a platform-admin token of another org reads the seeded canary of a standard namespace and writes a fresh one, read back field by field (actor, source_class, identity tuple), while a token with the same claims under admin/writer roles reads nothing and is refused the write with AUTH_INSUFFICIENT; namespace.get then shows the fresh namespace registered with no owner and tagged auto-registered.
  • Not covered by a test: every_namespace_scope in another org. There, for a platform admin, the gate admits every claimed name that the restricted, collection and reserved-name clauses do not already hide, so its refused-claim list is empty with or without the org rule, and a test could not fail.
  • make format, make lint: pass. make typecheck: the mypy gate reports two files this diff does not touch (server/clients/mcp_source.py, server/llm/vertex_auth.py; missing stubs in the local virtualenv) and nothing in it.
  • pytest tests/analyzer (no ClickHouse, so the EXPLAIN checks skip; CI runs them): 10 passed. shapes.txt was regenerated with no .env and fake providers, and adds the one is_registered_repository shape (SELECT active, row_kind ...). The branch merges main; the regenerated corpus differs from main's by that one shape.

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. The reproduction was run against main and this branch, the new tests were checked to fail on main's gate, and every changed test expectation was traced to the rule above.

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

Checklist

  • Local format, lint, type checks and focused tests pass. The full make test-unit and applicable integration results are reported by CI; a full local run is not required before pushing.
  • Generated files are regenerated in this PR, not by hand (docs/reference/configuration.md, schemas/loom-settings.schema.json, loom.example.yaml, tests/analyzer/shapes.txt): the SDK op tables, docs/reference/configuration.md and the docs/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).
  • n/a: A new migration is additive and numbered after the latest on main; no merged migration is edited.
  • n/a: A behaviour change to any file a plugin ships (hooks/, lib/, bin/, skills/, .mcp.json, the Codex plugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.
  • n/a: 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; the history goes in this description (tests/unit/test_public_copy.py).
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.
  • I signed the Contributor License Agreement (CLA) if CLA assistant requested a signature.

🤖 Generated with Claude Code


Note

High Risk
This widens cross-tenant authorization for platform administrators and changes MCP default-namespace semantics; mistakes in _platform_covers or cross-org binding could admit or mis-route access across orgs.

Overview
Own platform-admin tokens (dashboard/loom login, --platform-admin bots, minted platform-admin tokens) now pass the namespace gate on every standard namespace in every tenant org without a matching JWT claim or grant, via new _platform_covers in check_authorized. Restricted namespaces, repository writes, mirrors/collections/delegated/scoped/impersonated tokens, and third-party MCP OAuth sessions (first_party false) stay on the old rules; repository reads keep the existing platform read path. Grants no longer cap this authority (same as * claims). Writes may hit a live is_repository registry read when the claim does not already cover the namespace.

MCP/HTTP caller identity changes so a call that names another org and omits namespace does not inherit the home-org default: required-namespace ops fail validation, optional ones run org-wide, and loom_search resolves namespaces from that org’s fan-out. named_claims(auth, org) only lists namespaces for the token’s org, and namespace auto-register records no owner on a first write from another org’s token.

Docs, settings text, and tests are updated to match the wider admin reach and the cross-org MCP behavior.

Reviewed by Cursor Bugbot for commit bd01386. Bugbot is set up for automated code reviews on this repo. Configure here.

…every org

A sign-in token names only the person's own namespaces, and the gate read
platform_admin only through the claim, so it refused the person the
namespace ops the role stands for; a bot's or a minted token's `*` claim
reached every namespace of its own org and none of another's. Own platform
authority (not scoped, delegated or impersonated) covers every namespace
that is not a repository, in every org, and no grant row caps it, as none
caps a `*` claim. Restricted namespaces, collections, mirrors and code
stores, repository writes, tenancy and the acted-for check keep their own
rules; an `ns_write` claim still bounds writes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
@vercel

vercel Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
loom-docs Ready Ready Preview Dec 5, 2026 6:41am UTC
loom-telemetry Ready Ready Preview Dec 5, 2026 6:41am UTC

Request Review

The registry snapshot each process holds is refreshed on a timer, so a
repository another replica registered a moment ago may not be in it.
Platform coverage also asks the kind directory (kind `code`), read fail
closed: kinds that cannot be read cover nothing and the refusal is
unverified. The docs name the cases platform authority leaves to their
own rules and how a `*` claim adds its own org's repositories.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread server/auth/authz.py Resolved
Comment thread server/auth/authz.py Resolved
zlareb1 and others added 2 commits December 5, 2026 01:29
`IdentityDirectory.is_repository` passed the caught error's text into
`ClassificationUnavailable`; `caller_text` gives the code and message a
Loom error writes for callers, and `kind_map` has already logged the
failure (`test_exception_text_ratchet`).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…ind column

`namespace.register` takes a namespace's kind from its caller, so a
directory row of kind `code` took a standard namespace out of platform
authority, though it is no repository and platform authority does not
read it. The kinds were also cached per org for 30 s, so a repository
another replica added could still be written for that long.

A read leaves out the entries this process's configuration and registry
snapshot hold, which keeps the member write check the grant's; platform
authority reads any other repository anyway. A write also reads the
namespace's registry row at the write, under sequential reads, and a
registry that cannot be read covers no write. The kind column decides
nothing, and the property test's fake `kind_map` keeps its signature.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread server/code/app/index/repo_registry.py Resolved
The default namespace an MCP call is filled with is one of the caller's
own org, but the fill kept a call's explicit org, so a call naming another
org and no namespace ran on that org's namesake of the default. Platform
authority admits that pair, so the call names its namespace or fails
validation naming `namespace`.

The gate asks platform authority only where the claim, after its cap,
does not cover the namespace, so a write the claim covers reads no
registry row. A unit fixture answers the registry read with no row unless
a test is marked `registry_rows`, in place of four copies of that stub;
tests cover the read itself and the directory's answer. The concept page
names platform authority with the role, the gate and the grant cap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread server/auth/authz.py Resolved
zlareb1 and others added 5 commits December 5, 2026 03:03
`named_claims` returned the claim's names for whatever org a caller asked
about, and the namespace resolvers (`resolve_my_namespaces`,
`readable_named_claims`, `every_namespace_scope`, `namespace.list_mine`)
relied on the gate refusing them in another org. Platform authority
reaches another org's namespace of the same name, so an `all_mine`
fan-out there read it as the caller's own. `named_claims(auth, org)`
returns none outside the token's org (every org for an org-wide token).

A code read's lessons default is set after its code scope is applied,
and only when the read acts in the caller's org: its plane or scope may
be another org's, where the home's name is another namespace.

The registry read is one `SELECT active ... LIMIT 1` point read
(`CodeRepo.code_repo_active`, with its analyzer shape), and reads
nothing with self-service off, where the snapshot reads no registry.
The MCP reference names the default-namespace rule. Tests cover the
read, the directory's answer, the defaults in another org, and a
platform admin's write to another org over HTTP and MCP.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…pository

- `_platform_covers` returns False for a blank, `-` or `*` org
  (`cell.ORG_FREE`). `tenancy.ensure_held` passes those, and a platform
  admin of another org was admitted there.
- `code_repo_active` reads `row_kind` and counts no maintainer's `access`
  row, as the snapshot, the mirrors and `active_code_repo_count` leave it
  out. Reads and writes then agree on what a repository is. The analyzer
  shape is regenerated.
- A code read's lessons default applies when `org_for_op` is the caller's
  org or None: a read that names no org anywhere acts in no other org.
- `mcp_call` splits `in_home_org` out of `unnamed`.
- Tests: platform authority refused in a `*` or `-` org, an access row
  that is no repository, and a platform admin's `list_mine` in another org
  listing no claim row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
- `namespace_autoregister.ensure_registered` takes `ownerless`, and the
  transport hook sets it for a token of another org (not `*`): the row
  names no owner, at the ownerless version, as for a name in use. A name in
  a tenant org is not an outside writer's to own. The setting's
  description, its generated reference, schema and example, and the
  namespaces page say so.
- The gate asks platform authority only where a known grant does not
  admit the call: a listing or default (`CachedGate`) that hands in a
  grant reaching the role, with no claim cap over it, reads no registry
  row.
- The `_platform_covers` and module docstrings say plainly what platform
  authority covers; the concepts page says an `ns_write` claim still
  bounds its writes.
- Tests: the known-grant case, a repository write refused from another
  org, the HTTP scoped refusal is a 403, the ownerless first write, and an
  integration case in the leakage suite where a platform admin of another
  org reads and writes a standard namespace that the same claims under an
  org admin's roles do not reach.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…andard-namespaces

Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>

# Conflicts:
#	tests/analyzer/shapes.txt
- `_platform_covers` returns False for a sign-in session that is not
  Loom's own (`session_id` set, `first_party` false). Loom already gives
  such a session nothing that outlives it (`_only_a_person`,
  `delegation`), and an admin reach over every org would let it grant
  lasting access anywhere. The dashboard, `loom login`, bots and minted
  tokens keep the reach.
- An `ns_write` claim bounds platform writes instead of dropping them: a
  write inside the claim is covered, with no grant capping it.
- `_grant_admits` names the known-grant check; `code_repo_active` is
  `is_registered_repository`; the MCP variable is `takes_default_ns`.
- The `LOOM_PLATFORM_ADMINS` description names what the role reaches;
  the security page says a third-party session has none of it and that
  tracker namespaces are in reach. Generated settings files are
  regenerated.
- Tests: the third-party session at every role in both orgs, a capped
  claim inside `ns_write`, and the integration case reads back the
  ownerless registry row with `namespace.get`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread server/auth/authz.py Resolved
zlareb1 and others added 2 commits December 5, 2026 05:02
- The MCP screen drops a `loom_search` namespace, and a call naming
  another org takes no default, so such a search failed validation with
  no way to name one. `_bind_caller_identity` now addresses it through
  `_address_home` from that org's fan-out, at either scope, the
  namespace named after the caller first; it fails validation only when
  the caller reaches none there.
- `docs/reference/mcp.md` says what a call naming another org and no
  namespace does per op: a required namespace fails validation, an
  optional one runs org-wide, `loom_search` searches that org's fan-out.
- `security.md` names the ownerless first write from another org; the
  `LOOM_PLATFORM_ADMINS` description is reworded and regenerated.
- Tests: `loom_search` naming another org through the MCP screen and the
  binding; `test_delete_by_key.py`'s source check names the new
  condition.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
- `_address_home` re-raises a fan-out failure when no default filled the
  namespace: with nothing to fall back to, the failure is the server's
  (a 503), not a validation error asking for a namespace the caller
  cannot name. A filled default still stands, as before.
- A search it addresses with no default carries the `namespace_defaulted`
  note when the namespace is not the caller's own.
- The call-site condition reads without a double negative, and the
  comment and docstring say what an op with an optional namespace does
  and that the caller's home is picked first.
- Tests: the note, the fan-out failure in another org and in the
  caller's, and an optional-namespace op naming another org.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

There are 3 total unresolved issues (including 2 from previous reviews).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 72dd287. Configure here.

Comment thread server/transport/mcp_call.py Resolved
zlareb1 and others added 12 commits December 5, 2026 05:51
- `_address_home` reads the namespace as the gates do (a blank or "-"
  names none), once. With none named, a fan-out failure is the server's:
  a `LoomServerError` raises as is, anything else as
  `BackendUnavailableError` from it, so no bare 500 escapes the call or
  drops a batch's other answers. The refusal is ledgered against the
  token, as a failed defaults read is.
- `test_delete_by_key.py` stops pinning the call site's source text; a
  behaviour test covers a filled default moving to the caller's home.
- Tests: a raw error with no, "-" or blank namespace answers
  `BackendUnavailableError`, the refusal row, and the filled default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
A call naming another org takes no default namespace, but a blank,
whitespace or "-" value it sent stayed in its arguments, so the op ran
on that literal namespace of the other org. The binding drops it there
(`_in_home_org`): an op that requires a namespace fails validation
naming it, as over HTTP.

A namespace refusal in another org does not advise omitting the
namespace, which would only fail validation there. A fan-out that cannot
be read for such a search is logged, and a server error is re-raised as
is. The source-text test of the search call site is gone, behaviour
tests cover it, and the CachedGate docstring names the registry read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
`maybe_autoregister` reads the token's org to decide whether a first
write records an owner, and two tests stood in a caller with a subject
alone. Each stand-in names the org the move lands in, and the
`ensure_registered` stub takes `ownerless`, asserted false for a token
of that org.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
A loom_search naming an org another cell holds, or a new org name past
the limit, raised WrongCellError or ValidationError out of the binding,
before any phase that frames them, so the call escaped `_call_tool`
unframed. `_call_tool` answers them as tool errors with their code, as
the gate would; only a server fault logs.

A call with no token on a single-user server takes the install's
namespace whatever org it names, as HTTP fills it. `_in_home_org` is a
predicate again, and the binding drops a blank namespace on its own
line. The namespace refusal text is plain branches.

The corpus is regenerated after merging main: main's knowledge_sources
read was not listed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…d it

The binding read a padded org (" acme ") through `present` and took the
call as one in another org, but `_address_home` read the fan-out of the
padded name, which holds nothing, so the search failed validation where
"acme" searched. It reads the org through `present` too.

The MCP screen passes whether the call names another org into its
namespace check, from the org it already read, and a test through the
screen covers the refusal text there. The binding names the
"another org, no namespace" check once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…andard-namespaces

Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>

# Conflicts:
#	docs/concepts/identities-and-namespaces.md
#	docs/guides/tokens-and-grants.md
#	docs/operations/sso.md
#	docs/reference/configuration.md
#	loom.example.yaml
#	schemas/loom-settings.schema.json
#	server/identity/app/namespace_membership.py
#	server/settings/catalog.py
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
Two sso.md lines read as if namespace access came only from grants,
which a platform admin's reach contradicts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
The collection gate and the org-wide rollups test the role alone, so a
third-party client session holding platform_admin still passes them;
the SSO page and the gate's rationale now say so. Also says what a
platform admin reads in repositories, that a JIT account can sign in
as platform_admin, and that the group's members hold the reach the
platform_admins setting describes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…eeps

It still reads every repository, and the rollups exceed the gate for any
token holding the role that the gate gives no platform authority. The
group setting's comment says a refresh keeps the role while listed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>

This branch has not been deployed

No deployments
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