Skip to content

namespace.list_mine lists the namespaces a person was granted under their email - #152

Merged
pufit merged 2 commits into
mainfrom
pufit/list-mine-aliases
Oct 25, 2026
Merged

pufit merged 2 commits into
mainfrom
pufit/list-mine-aliases

Conversation

@pufit

@pufit pufit commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in a release)

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.list_mine now lists the namespaces a person was granted under their email as well as those under their login handle, and clears is_new on a visit under either spelling. The dashboard no longer refuses ("Your account cannot read this namespace") a namespace the server already lets the person read, and the header picker shows it.

Why

One person is one principal (server/auth/aliases.py): grants written by operators, bootstrap scripts, invitations and syncs name the person's email, the login token names the self-signup row's handle (u-…), and every read folds the two — the auth context, the login widening, the restricted gate, grant_role_for, caller_home, token_grants, the grants list. namespace.list_mine was the one reader that did not: it queried loom.namespace_grants for the caller's exact subject, so a grant written under the email before the person's first sign-in (the handle does not exist yet, and grants.py canonicalizes to the handle only once the row does) never appeared in the person's membership list. The dashboard decides readability from that list (App.tsx canReadNamespace) and renders NamespaceNoAccess before issuing a read, so a link to such a namespace was refused although memory.* reads against it succeed, and the namespace was missing from the picker.

Seen on a deployment where a control plane pre-provisions grants for every member of a tenant by email: a member who signs in afterwards sees only their personal namespace. Reproduced against ClickHouse: the exact-subject query returned 1 row for the person, the alias-folded one 12.

The same handler folds aliases for a token's creator three lines below (_inherited_rows); this makes the caller's own rows follow the same rule.

Scope and risk

  • handle_namespace_list_mine resolves subject_aliases(org, caller) (cached per grant_cache_ttl_seconds, falls back to the subject alone when the directory read fails — unchanged behavior in that case) and reads the membership rows for all spellings. _one_per_namespace folds a namespace granted under both spellings into one row: the newest grant stands, the highest role wins (grant_rank, as fold_by_alias does for the Readers list), and the namespace is new only if no spelling has visited it.
  • _MEMBERSHIP_SQL: the namespace_visits join is now max(last_seen_at) over the same subs, instead of equality with the grant row's own subject — otherwise an email-keyed grant would carry is_new forever, since namespace.mark_seen records visits under the login handle.
  • Leaves alone: the gate and every other reader (already folding), the JWT-claim rows, the inherited rows, canonical_subject (grants are still written under the handle when the row exists). Service-account and wildcard subjects have no aliases, so their lists are unchanged.
  • Risk: a person now sees in their list exactly what the gate lets them read — nothing the gate refuses becomes visible; no stored data changes.

Compatibility, rollout and rollback

  • Wire: no op or field added, changed or removed; rows that were missing are now present.
  • Operator steps: none.
  • Generated: tests/analyzer/shapes.txt — one statement shape replaced (the membership read's visits join), via python -m tests.analyzer.corpus --write.
  • Rollback: reverting restores the exact-subject list and the previous shape; nothing else is left behind.

Tests

  • tests/unit/test_list_mine_aliases.py: email-keyed grants are listed for the handle (and the read asks for both spellings at once); a namespace granted under both spellings is one row with the highest role, is_new cleared by either spelling and the newest grant's joined_at; a subject with no aliases lists only its own rows; the visits side of the SQL filters by the same subs as the grants side.
  • The new SQL was run read-only against a ClickHouse 26.8 Cloud service holding real rows: 12 rows for a person's two spellings, roles and is_new as expected.
  • make test-unit equivalent (pytest tests/unit -p randomly), ruff, mypy-gate and function-length-gate pass locally.

Generated by Nerve

pufit added 2 commits October 25, 2026 05:57
…heir email

One person is one principal (server/auth/aliases.py): grants written by
operators, invitations and syncs name the person's email, the login token
names the self-signup row's handle, and every read folds the two — except
namespace.list_mine, which queried loom.namespace_grants for the caller's
exact subject. A grant written under the email before the person's first
sign-in never appeared in their membership list, so the dashboard refused a
namespace the server already serves and the picker did not show it.

The handler now reads the membership rows for all of the caller's spellings
and folds a namespace granted under both into one row (newest grant stands,
highest role wins), and the visits join clears is_new on a visit under any
spelling, since mark_seen records visits under the login handle.

Signed-off-by: pufit <[email protected]>
…join

python -m tests.analyzer.corpus --write: one shape replaced (the visits side of _MEMBERSHIP_SQL).

Signed-off-by: pufit <[email protected]>
@pufit
pufit merged commit 111af0f into main Oct 25, 2026
21 of 22 checks passed
@pufit
pufit deleted the pufit/list-mine-aliases branch October 25, 2026 18:33
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.

2 participants