Repository navigation
Conversation
…es others An export writes one deployment's orgs as a bundle: namespaces, accounts with their password hashes, live grants, groups, blacklist entries, memories, and documents with their originals, each section checksummed in a manifest. An import plans the bundle against the target, refuses a plan while any source name or subject could land on someone else's, and applies the plan whose digest the operator reviewed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
… orgs need the map - An instance.import.done audit row marks each namespace whose content landed; later runs skip it, so what the target deleted or revoked since stays so. Groups get landing rows too, and reruns skip revoked grants and existing blacklist ids. - Two source orgs landing in one target org share its names and groups; a name or group both bring refuses the plan. - everyone, user: and agent: subjects need keep, a mapping or drop in a target org that serves others; memory user ids follow the user: decision, and two source users may not land as one. - Blacklist patterns land narrowed to the moved namespaces they reach. - A merge carries validity, expiry, sensitivity, evidence and grounding, and skips rows that are no live fact; per-type settings land with created namespaces only. - Model calls run under the target org's customer attribution. - The plan digest binds the bundle; the map's flags are strict booleans; collection and alias names are refused. - The export carries only the groups its grants name, filters identity rows by the selected pairs, streams every section, checks each original's hash, and refuses under the Postgres authority while documents await publication. - A claim under another handle plans the same digest when run again. - An integration test moves an org into a live one, field for field, with a merge and a rerun that writes nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…y add - A claimed account handle that already holds access on the target (a platform-admin or trusted-caller setting, a grant, a namespace, a token, a task) refuses the plan with a new-handle proposal, and the apply checks it again under the account claim: the same check self-signup runs, now public as refuse_empowered. - The export reads revocations under SCIM's key and any case, so a deprovisioned account lands with no password and no links. - keep runs the checks no rule runs; it only settles an end user of a shared target org. - A namespace anyone could join at once lands with join_policy approval in a target org that serves others. - A merge writes no key the target namespace holds or has held; a resumed run writes no per-type setting, policy, guide revision or single sign-on link the target holds in any state. - Groups, agents and everyone hold grants on collections only, which do not move: the group path is removed, and such a subject needs drop or a mapping. - Policies and guides move with created namespaces; promoted shared memories, records and end users' documents are counted as left behind. - The digest names sso_same_issuer; merges land under their own audit event, so a target org merged into stays shared; a user: subject maps to any user: subject; an undecided subject maps to nothing. - The dry run checks the regex budget and every original before anything is written; the target orgs are declared only to write a reviewed plan; an export that selects nothing is refused. - The integration test covers a target-held handle, a SCIM-revoked account, a refusal, a document and its original, a public namespace, a merge key both sides hold, and a resume of unfinished landings; it also runs in CI's Postgres pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
… no refusals - An account the source revoked lands with no password, email or link, and its grants stay behind: an empty hash with a contact email was claimable by whoever proved that email at the target's identity provider. - A landed name is this import's own only while its row keeps the source's created_at; a name taken between the audit row and the namespace row is a collision, and a missing row is checked for use and access again. - A merge refuses the rows it brings by the source's refusals in process and stores none on the target's namespace. - The regex budget counts only the patterns a created namespace still has to store and skips finished landings, so a rerun is not refused; a refusal this deployment cannot compile is a plan problem. - A merge reads its target namespace's keys once per run, not per batch. - The bundle writer makes its directories 0700 and files 0600 itself, replacing the process-wide umask; an --out that names a file is refused. - The left-behind counts of a --namespace export cover those namespaces, and the dry run prints each counted kind with its row count. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
… move - The manifest names the namespaces whose content the bundle holds, and instance.import.done is written for those only: an account a --namespace export brought for its grants landed done with none of its content, so a later whole-org import skipped it. The dry run marks row-only landings. - The export leaves out only the reserved mirror and code-store forms and collections, not every acl- or crs- name. - The plan checks no email or link of an account the source revoked, since none of them lands, and says it lands revoked. - Under the Postgres authority, a resume reads every head the authority holds, deleted and unpublished ones included, as written already. - Every read of a plan and apply is sequentially consistent, replacing the per-statement settings. - A merge matches the source refusals with the guard's own matcher. - The integration test's revoked account has a handle of its own, and a new test runs a --namespace bundle and then a whole-org one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
- The import's namespace writer is a known one: it writes the source's full row, classification and join policy included. - The export and the import are classified journal readers: the export sends nothing, and the import's reads decide writes that commit. - The column read names the configured database, not `loom` by value. - No SELECT alias shadows a column its statement filters on. - The write batch says why it is not a setting. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…dation Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…share an email - A grant is left out when the person holds that role or higher under any spelling the directory ties to the subject, case folded, or was revoked there; a pending request is no grant, so the source's replaces it. It is written under the subject `grants.create` would write it under. - The plan refuses two accounts of the bundle that land with one email, which single sign-on refuses, and proposes `drop`. - The plan refuses a map entry that names nothing in the bundle, and a mapping onto a subject that holds grants on collections only. - A landed namespace row its owners deleted is no landing of this import. - Under the Postgres authority, a document head it holds counts as written. - The dry run reads every original back with its hash checked; an apply that finds one changed since stops and says to run it again. - An account single sign-on made on the source lands untagged, so the target never finishes its provisioning with an owner grant the source revoked. - The docs say the export writes no audit row per memory it reads, as a database dump does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
| "revoked_at": None, | ||
| "version": run.next_version(), | ||
| "status": "active", | ||
| } |
There was a problem hiding this comment.
Pending grants survive subject rewrite
Medium Severity
Pending grants are ignored when deciding what the target already holds, and the new row is inserted under canonical_subject, not the pending row's subject. loom.namespace_grants only collapses an exact (org, namespace, subject) match, so a different case or a verified email's handle leaves the pending request in place. It can still be approved after the import.
Reviewed by Cursor Bugbot for commit 14bdc82. Configure here.
…s stay behind - A grant to an email a revoked source account names is dropped: on the source single sign-on admits no one by that address, and the account lands with no email, so on the target it would. Mapping one is refused. - The export leaves a knowledge source's synced documents behind and counts them (`documents_of_sources`): a source registered again writes and keeps only its own copies. - A carried grant is left out for a role the person holds under a verified spelling only, as the gate admits them; any spelling still reaches a revocation. - A landed name counts toward an org the import alone serves only while its row is the one the import wrote, or its content is finished. - A subjects entry naming a namespace that is no account refuses the plan. - The dry run's hint gives the whole apply line, `--expect-plan` included. - `apply` takes `sso_same_issuer` from the plan the digest binds. - One Postgres read of document heads per namespace, not per document. - The docs say an erasure during an unfinished import is run again after it, as after a restore, and correct the email-grant wording. - Tests: per-type settings, policies and guide revisions compared field for field, a single sign-on account landing untagged with its link, the dry run refusing a changed original, apply's stop on one, a revoked account's email grant, a synced document, and a grant past an unverified spelling. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…s move - A `--namespace` export brings the accounts a grant names by email too, by contact or single sign-on link: on the source single sign-on admits no one by an address a revoked or password account names, and the plan needs the account to place such a grant. - A recording source's transcripts move with the bundle: a source registered again lists its last weeks only, and a transcript never changes once written. Every other synced copy stays behind as before. - The `instance.import` audit row records the source row's `created_at`, and `TargetOrg.holds` decides from it whether a landing is still the import's, whichever bundle the plan reads. A row-only landing an earlier bundle made no longer makes the org one that serves others. - A resumed import reads which document addresses the Postgres authority holds without their rows (`pg_documents.held_uris`). - Tests: the selection by email, a landing from another bundle, an original changed after the dry run stopping `_documents` itself, the dry run's hint, a recording transcript landing, and `instance import` among the commands whose default is a dry run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…dation Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…it holds - An email that signs in to a target account is excused only while that account is still this import's landing (`TargetOrg.holds`). A name someone signed up with since, with the same email, now refuses the account with a proposal to map it there, instead of landing it under another handle with an email the target's account also holds. - The apply tests an existing namespace row against the `created_at` the landing's audit row recorded, the value the plan used, not the bundle's: a source row created again between bundles no longer passes the dry run and stops every apply. - The audit helper takes `created_at` as a named argument. - Prose: the consolidation table's wording, and hand-wrapped lines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
- A created namespace skips each source head whose key (agent, user, session and key) the namespace holds or has held, as a merge does, not only the memory ids an earlier run wrote: a fact someone wrote there before the rerun stays theirs. `_seen` reads document addresses only, and `pg_memory.held_in` pages head keys by `KeyInNamespace`. - An account the source revoked after an earlier bundle landed it as one that signs in refuses the plan until the target revokes it, which also ends its tokens and sessions there. `load_target` reads the target's revocations of landed names; the export and the import share the query. - An email that signs in to a target account is proposed `drop`: nothing proves a target account's contact email. Only the import's landing under the handle the map now gives is excused. - A landing that recorded its audit row but no namespace row writes it with the recorded `created_at`. - The bundle's digest is the SHA-256 of the manifest bytes the open read. - The dry run marks a landing an earlier run finished. - Docs: merged memories are embedded as `memory.bulk_set` writes them; a document's extraction record stays behind; rewrapped paragraphs. - Tests: `_land` against a recorded `created_at` that differs from the bundle's, a resumed run and a key written since, a revoke after a landing, a landing under a changed handle, and every column of a landed document. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…he map does - The plan checks every earlier landing of an account the source revoked, before its map entry: one the target still lets sign in, and has not revoked, refuses the plan whether the map keeps the account, drops it or claims it under another handle. The problem text and the docs say the target's `loom revoke-token --subject` reaches the handle in every org. - `pg_memory.held_in` returns the keys themselves; `_held_keys` pages it without a wrapper, and `_seen` is `_held_uris`. - Docs and docstring: created and merged namespaces both receive only keys the target never held; a document's `ingested_at` and `artifact_sha256` are named. - Tests: the revoked landing under `drop` and under another claim, and the dry run's mark on a landing an earlier run finished. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
- Two source namespaces may merge into one target namespace: a document address the run has written is counted as present for the next one, as a memory key is, instead of superseding the first copy. - A landing the target deleted no longer counts as one that still signs in: password and single sign-on read `active`. - Docs: the plan reads earlier landings in the target orgs the map names, and deleting the landed account settles the plan where another org holds the handle, ending only its sign-in. - `pg_memory.held_in` builds keys with `key_in_namespace`; the module docstring is reflowed. - Tests: two merges with one address, a revoked account mapped onto a target account, a finished landing the target deleted, and, end to end, an account revoked on the source after a first bundle landed it refusing a later plan. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
- A merged entry `memory.bulk_set` declines (a pinned peer, or a restatement it folds into a row) is counted as `memories_not_admitted`, so the receipt adds up to the source's count. - The single sign-on links land in their own step (`_links`), run under `sso_same_issuer`, not at the end of `_grants`. - Docs: a document address the namespace holds or has held is left alone, and of two namespaces merged into one the first brings an address or key both hold; the revoked-landing paragraph names the one target org the plan reads and what a delete leads to for an unfinished landing. - The integration test lapses the revocation with a newer row instead of a mutation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
- A merge's `memory.bulk_set` calls check every entry, whatever `bulk_conflict_check_max_entries` caps a call at, send each call oldest first, and turn off update detection and reinforcement, which each rerun would add again. - Under `newest_wins`, a same-key write retires the older rows in every session of its user (of anyone, for a write with no user): a merged key counts as held that far, the merge's own writes included. - A merge no longer carries a source pin, which would refuse the target owners' own later writes of a close fact. - The dry run builds every memory row the apply writes and names each one the target refuses, which would otherwise stop every apply at that row. - The receipt counts single sign-on links; the landings are built once on the run; the Postgres authority's documents are read in `_held_uris`. - Docs: merge admission settings, the `newest_wins` reach, what admission may still mark or retire, pins, the dry run's memory check, and the handle the plan proposes after a delete. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…ch other - A row the merge leaves out (a dropped user's, one not live, a refused one, one the target holds) is decided before it claims a key, so a live row of its key still lands. - Of the merged rows that would retire each other (one key under one agent, user and session, across two merged namespaces too, and under newest_wins as far as a same-key write reaches), the newest by valid_at, then created_at, then bundle order, lands; the receipt counts the others as memories_superseded. A first pass over the bundle finds them, a second writes them. - The dry run measures a merged value against its char_limit as memory.bulk_set does, which refuses the whole call. - Docs: under newest_wins admission may retire a target row stating the same attribute with another value unless the merged row is the older statement; the reach is of keys the target holds or has held; the dry run may name a row the run leaves out; the paragraph is rewrapped. - The integration test merges into a newest_wins namespace and reads back which rows are live. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…its key - Under newest_wins a named write never retires a row with no user, and a write with no user retires the named rows of its key written before it. The merge's rows with no user now compete only with each other, one user's rows only with that user's, and the rows with no user are written in a pass before the named ones: both land, as the source served them, and a run resumed between the two passes writes the same rows. - The exact-identity and newest_wins groups are kept apart, and the counter of merged rows kept is named `carried`. - Docs and docstrings: the newest by valid_at (its created_at where it has none), then the first in the bundle; the order of the two passes. - Tests: a row with no user beside a newer named one, a run resumed after the rows with no user, and the receipt's `memories_superseded` end to end. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
- The unit test puts the row with no user after the named row of its key in the bundle, so only writing the rows with no user first passes it. - The integration test merges an end user's newer row beside the row with no user of its key into the newest_wins target, and reads both back live. - The merged-row counter is `merged`, not the module's `carried`; the docstring says the rows with no user are written first; the second pass is a plain `if`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
- `_bulk_entry` reads the time through `utc_now`, so the unit test pins the clock: a newer row of a key past its expiry is left out and counted as not live, and the older live row of its key lands. - The rerun state compares every row of the merged `team`, with its status and version, so a rerun that writes or retires a merged `newest_wins` row fails it; it replaces the single `team` key read through `memory.get`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
- `_live` decides whether a merge carries a row against the run's start, so the pass that ranks rows and the write agree: a row that expires between them was ranked the winner of its key, then dropped, and its key landed with no row. `_bulk_entry` takes the expiry from the time of writing, at least a second, so such a row lands and expires as it did on the source. - The plan decides only the subjects of namespaces it does not skip: a skipped namespace's grants, owner and end users move nowhere. - A test runs the import with a stale `--expect-plan`: exit 2, with neither the acceptance check nor the apply called. - `as_aware_utc` replaces a copy of it; the docs say a merged row keeps its validity, and only a created namespace its `created_at` and attestation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
- `_live` requires `redacted_at` empty: a redacted head stays active with the placeholder as its value, which no read serves, and a merge wrote it as a fact with its redaction marks dropped. It is counted as not live, so a live row of its key lands. - The plan refuses a mapping of an end user onto `user:-` or `user:`, which would land their rows beside the rows with no user. - The runbook says a row that expires before its write lands with a one-second expiry; `landed_row` uses `as_aware_utc`; the `_kept` docstring names `_live`; the merge test's run starts before its expiry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
- Each merge call reads the target's keys of its entries again just before `memory.bulk_set`, and each document its address before `knowledge.upsert`, with the rule `_kept` uses (`_holds`): a key or address the target's owners write while the run goes on stays theirs. `_held_keys` and `pg_memory.held_in` take the keys to read; `_held_uris` reads only the addresses asked for. - The dry run names a merged row whose `on_expire` is not the one the target's `memory.bulk_set` gives its sensitivity: the target would delete what the source demotes or anonymizes. A created namespace keeps it. - A created row's `verified_by` and `locked_by` name a subject as the plan maps it, and no one where it drops or never planned it. - The plan decides a merged namespace's end users, and its grant subjects only when it carries its grants, never its owner; the dry run says when a created namespace's owner does not land. A mapping onto `user:-` says why it is refused. The runbook covers a source erasure after the export. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ 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 d1626d0. Configure here.
| kind, sep, who = str(m.get(col) or "").partition(":") | ||
| if sep and f"{kind}:" in (HUMAN_PREFIX, PROCESS_PREFIX): | ||
| to = run.subject(d.source_org, who) | ||
| m[col] = f"{kind}:{to}" if to else "" |
There was a problem hiding this comment.
Pipeline actors remapped as subjects
Medium Severity
_row splits every human: and process: verifier and locker and looks the remainder up as a plan subject. Pipeline actors such as process:loom and process:cli:… are not principals. A suffix that matches a mapped handle is rewritten onto that person; any other pipeline actor is cleared on a created namespace.
Reviewed by Cursor Bugbot for commit d1626d0. Configure here.


Related: #2146
Related: #159
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):
loom instance exportwrites one deployment's orgs into a bundle, andloom instance importlands it in another deployment that already serves other teams, by a plan the operator reviews. Accounts land claimable under their old password, grants move under mapped subjects, and the plan refuses any name or subject that would land on someone else's.Why
Teams try Loom on a deployment of their own and then move to a shared one. The tools before this copy rows unchanged (
dev/backup_loom.py), so a source account or namespace that shares a name with a target one replaces it (ReplacingMergeTreefolds the two rows), and a grant toalicereaches whoever isaliceon the target. This is step 1 of #2146: plan, map and apply for namespaces, accounts, grants, memories and documents, which covers one or more source orgs into a live target.Design:
Two commands, run with the CLI where each deployment's servers run.
exportonly reads.importwithout--applyis the plan: it reads the target, prints every decision, and exits non-zero while any problem stands. Each problem names the map entry that settles it, and the run prints those entries as YAML.--applyneeds--expect-plan <digest>, so a target or map that changed after review refuses the write; a clean dry run prints that whole line. The digest binds the bundle, the decisions andsso_same_issuer. The target orgs are declared to the cell gate only once the reviewed digest matches.The bundle is a directory: one gzip JSONL file per section, originals under
originals/<sha256>, and a manifest written last with every section's row count, size and SHA-256. A cut-off or altered section is refused when each run opens the bundle; the digest is the SHA-256 of the manifest bytes that run read, so an edited manifest changes the plan and--expect-planrefuses it. The bundle is the operator's own 0700 directory, so a file changed while a run reads it is their change, not a damaged copy. The dry run reads every original back with its hash checked, and an apply that finds one changed since stops and says to run it again. The manifest'scontentnames the namespaces whose content the bundle holds: an account a--namespaceexport brings for its grants or ownership is a row only. It brings the accounts a grant names by handle, and those it names by email (contact or single sign-on link): single sign-on on the source admits no one by an address a revoked or password account names, and the plan needs the account to land the grant the same way. The bundle holds password hashes andhighmemories, so the writer makes its directories 0700 and its files 0600, whatever the umask. Likedev/backup_loom.py, the export is an operator's dump and writes no audit row perhighmemory it reads (docs/architecture/security.mdsays so). It reuses nothing fromnamespace.snapshot's single-response payload, which has no paging and no documents.Names never fold. A source namespace or account handle the target already holds (a namespace or a released alias), or a name in single sign-on's form, refuses the plan with a
renameorclaimproposal; a name the map gives is checked as a new namespace's name is. Two source orgs mapped to one target org share its names. Apply also refuses a name that holds data with no namespace row (directory().in_use).A landing is the import's own only while its row is. A landed name counts as this source's (not a collision) while its namespace row is active and keeps the source row's
created_at, which the import writes and a name registered since cannot have. The landing's audit row records thatcreated_at, so a later plan and the apply decide it from that one value, whichever bundle they read (TargetOrg.holds). A run stopped between its audit row and the namespace row leaves the name free: if someone takes it before the rerun, the plan refuses it with arenameorclaimproposal, or, when the new account signs in with the person's email, adropproposal. With no row the apply checks the name's use and access again, and writes the row with the recordedcreated_at.A claimed handle holds no access yet. Password login builds roles from the bare handle, and grants fold case, so an account landing as
adminwhereLOOM_PLATFORM_ADMINS=admin, or asbobwhere a token subjectbobholds grants, would take that access. The plan runs self-signup's own check (refuse_empowered, made public here) for each claimed handle and proposes{claim: <handle>-legacy}; the apply runs it again under the account claim.Subjects are mapped, never matched by guess.
dropproposal, and the problem names that account: map it there only if it is the same person in the same org. Nothing proves a target account's contact email, so the printed entries never hand an account to it. Only the import's own landing of that account, under the handle the map now gives, is excused. So is a second account of the bundle, in any source org, that would land with an email another one lands with, since single sign-on refuses an email two accounts hold.sso_same_issuer: true, which also carries its links. With that flag each link's email counts in the check above. An account single sign-on made on the source lands without itsoidc-jittag, so the target's sign-in never finishes its provisioning with an owner grant the source revoked.\0scim:key, any case), lands with no password, no contact email and no links, and its grants stay behind. An active row with an empty hash and an email is what single sign-on resolves by email, so leaving the email would let whoever proves it at the target's identity provider in. Since none of its emails lands, the plan checks none of them, and the dry run says it lands revoked. When the source revoked it after an earlier bundle landed it as an account that signs in, the plan refuses, whatever the map now does with it (drop, or a claim under another handle), until the target revokes that landing (loom revoke-token --subject <handle>): only the target's revocation also ends the tokens and sessions it has had there since. The problem text and the docs say that revocation reaches the handle in every org of the deployment; deleting the landed account ends the refusal too, ending only its sign-in (for an unfinished landing the plan then proposes another handle). It reads earlier landings only in the target org each source org lands in now.grants.createwrites it, and stays an email grant otherwise; it is never tied to an account whose email the source did not verify.user:is kept in a target org only this import lands in. A mapping names an end user's id: one ontouser:-oruser:would land them beside the rows with no user, and is refused. In one that serves others it may name another person, so it needskeep, auser:mapping ordrop. Memoryuser_ids follow that decision, and two end users of one source org landing as one refuse the plan. Across source orgs one person may hold an id in each, so the map decides.group:,agent:andeveryonehold grants on collections only (grants.createrefuses them elsewhere), and collections do not move, so such a subject on a moved namespace is refused with adropproposal. A mapping can turn it into a person's grant; a mapping onto one of them is refused.sa:subjects are dropped. Any other unknown subject refuses the plan.keepruns the same checks as no rule.Who can join. In a target org that serves others, a namespace anyone in the source org could join at once (public with
inherit, oropen) lands withjoin_policy: approval, so its content is not readable by everyone in the target org.Writes go through the existing writers.
restore_rows,checked_rows,without_erased,insert_version_rows), keeping every column andcreated_at, withsource_class=importedand the command asactor. Its verifier and locker (verified_by,locked_by) name a subject as the plan maps it, and no one where the plan drops it or never planned it, so no source subject's act lands as a target subject's. As in a merge, a key the namespace holds or has held is left as it is, so a fact someone wrote there before a rerun is never replaced by the source's. Per-type settings, policies (which only restrict) and guide revisions land too.memory.bulk_set, so admission (blacklist, conflict surfacing, pinned peers) holds, with the settingsmemory.importuses for outside facts: every entry checked whateverbulk_conflict_check_max_entriescaps a call at, each call oldest first (the later of two statements of one attribute in a call retires the earlier), no update detection, and no reinforcement, which each rerun would add again. A merge only adds: a key the target namespace holds or has held under the same agent, user and session is left as the target has it, so it never revises the target's fact or revives one its owners deleted. Eachmemory.bulk_setcall reads the target's keys of its entries again just before it, and each document its address, so a key or address the target's owners write while the run goes on stays theirs too. Undernewest_wins, where a same-key write retires the older rows in every session of its user (of anyone, for a write with no user), a key the target holds or has held that far is held too. A row the merge leaves out (a dropped user's, one not live, a refused one, one the target holds) claims no key, so a live row of its key still lands. Of the rows the bundle brings that a write of one would retire (one key under one agent, user and session, across two merged namespaces too, and undernewest_winsone user's rows of a key, or the rows of a key with no user), the newest byvalid_at(itscreated_atwhere it has none), then the first in the bundle, lands, and the receipt counts the others asmemories_superseded: the first pass over the bundle finds them, holding one rank per group. Undernewest_winsa named write never retires a row with no user, and a write with no user retires the named rows of its key written before it, so the rows with no user are written in a pass before the named ones: a named row lands beside a row with no user of its key, as the source served both, and a run resumed between the two passes writes the same rows. Admission may still mark a target row a merged one contradicts as conflicted, and retire one: undernewest_wins, a row stating the same attribute of the same subject with another value, unless the merged row is the older statement byvalid_at, and, with the conflict resolver on, one it judges the merged row updates. Only facts live when the run starts are written (a redacted head, whose value is the placeholder no read serves, is not one), so every pass of a run decides a row alike; one that expires before its write lands with a one-second expiry, as it expired on the source. Pins and locks are not carried: a pin would refuse the target owners' own later writes of a close fact. An entry admission declines (a pinned peer, or a restatement folded into a row) is counted in the receipt asmemories_not_admitted. The row'screated_atis the import's; its validity, expiry, temporal anchor, sensitivity, evidence and grounding are the source's.memory.bulk_settakes no expiry action and sets the one the target gives a row's sensitivity, so the dry run names a merged row whose own action (on_expire) differs, which the target would otherwise delete where the source demotes or anonymizes it: land its namespace as a created one, which keeps it. The reason recorded for an expiry is not carried.knowledge.upsertwith their originals, so the target's embedder embeds them and the originals land in the target's store. Itsingested_atis the import's time, and the source's record of how it extracted each one (format,parser,coverage,artifact_sha256, its ingestion) stays behind. Two source namespaces may merge into one target: the first copy of an address lands, and a second is counted as present. An address the target namespace holds or has held, a deleted one included, is left as it is. The export checks each original's hash, and under the Postgres authority it refuses while a selected namespace has documents awaiting publication. A document an end user wrote stays behind and is counted: the writer takes its user only from the caller's token, so the target could not erase it as theirs. So does a knowledge source's synced copy: a source registered again rewrites or retires only documents its sync wrote (source_sync.ours), so a copy the import wrote would never be refreshed. A recording source's transcripts move instead: one registered again lists its last weeks only (ZOOM_LISTING_DAYS), a transcript never changes once written, and the source leaves an address another writer holds as it is.grants.createwould write the mapped one under (a verified email's handle), with the import asgranted_by. The person is matched as the gate matches them, case folded: a grant is left out when they hold that role or higher under a verified spelling (an unverified one only caps at the gate), or a target admin revoked them there under any spelling the directory ties to the subject. A pending request is no grant, so the source's grant replaces it.blacklist_guard.match_value, new). A memory one matches is counted as refused, not written. The dry run builds every memory row the bundle brings into a namespace it lands (the restore check, and for a merge the bulk entry andmemory.bulk_set's ownchar_limitmeasure) and names each one the target refuses, such as a date past 2106, text the Postgres authority cannot store, or a value past itschar_limitonce serialized again, which would otherwise stop every apply at that row. It may name a row the run would then leave out, such as a key the target holds; the runbook says so. It refuses a pattern this deployment cannot compile, and a created namespace whose regexes still to be stored would pass the per-scope RE2 budget (finished landings and patterns stored by an earlier run do not count, so a rerun passes).Reruns and resume, with no new table.
instance.importaudit row naming its source (<deployment>/<org>/<name>); a merge writesinstance.import.merge. A later plan reads these as this source's landing, not a collision, so an interrupted run resumes with the same command and the same digest, unless the target changed what the plan reads: a namespace someone created since in a target org only the import landed in, or a landed name someone registered since, makes that org one that serves others, and the dry run shows the new decisions. A merged-into namespace never counts as the import's own.instance.import.donerow marks it, and later runs skip that namespace entirely, so whatever the target's owners deleted or revoked since stays so. Only a namespace the manifest'scontentlists gets one: a row-only landing gets none, so a later bundle that selects the account (a whole-org export) resumes it and brings its content; the dry run marks those landings.source_uriit has held, no setting, policy, guide revision or SSO link it holds, and no grant the person holds at that rank or higher or was revoked from.docs/operations/backup-and-recovery.mdalready says after a restore. A guard that refused resumes after any target erasure would leave the import no way to finish.Left out, and listed. Service accounts, bots and connected accounts are listed in the receipt for their owners to set up again, because their credentials never move. The manifest's
left_behindnames or counts:A
--namespaceexport counts these for its namespaces only, and the dry run prints each counted kind with its row count.Embeddings, caches, traces and the audit log stay behind. Mirror and code-store namespaces (their reserved
acl-/crs-<24 hex>forms) and collections stay behind; any other name moves.memory.bulk_setembeds merged memories as it writes them; a created namespace's are embedded by the embedding worker's next full pass, the same pathnamespace.restorerelies on. An export that selects nothing is refused.Alternatives considered:
_SnapshotMemoryRowpublic. The bundle's memories section isnamespace.snapshot's row, and that module names every row model of an op's output with a leading underscore (_SnapshotTypeRow,_SnapshotGrantRow), as the generated reference shows; the import reads it as the restore does.instance_bundlewith the content sections only.BACKUP DATABASEanddev/backup_loom.py.Not in this PR, as #2146 orders them:
loom instance freezeand the moved hint;Scope and risk
server/cli/instance*.py).server.auth.self_signup._refuse_empoweredis renamedrefuse_empowered, unchanged, for the import to call. Three read-only helpers are added for it:blacklist_guard.match_value(the guard's matcher over patterns the caller holds),pg_memory.held_in(the keys of a namespace's heads, deleted ones included, paged by key) andpg_documents.held_uris(which addresses have a head, without the rows). Two gate tests classify the new files:test_namespaces_writers_mirror_classificationlists the import as a known namespace writer (it writes the source's full row, classification and join policy included), andtest_pg_durable_readslists the export and the import as journal readers. No op, field, setting, migration or table changes.alicewhose handle the target already uses, or that already holds access there, is refused until the map gives it another handle.grants.createwould write it; an explicit map entry maps it as it maps any other subject.rerank_endpoint,classify_endpoint,released_aliases,budget_alert_inbox.password_hashandcontact_emailare cleared, so no plain namespace's email reads as a verified spelling of its owner.namespace.restoreuses under both authorities, and the merge reads keys from both stores. The new integration test also runs in CI's Postgres pass. Not exercised: Cloud as source or target.Compatibility, rollout and rollback
docs/operations/consolidation.md.Tests
tests/unit/test_instance_consolidation.py:--outthat names a file;everyonesubjects refused, withkeeprunning the same checks;user:kept alone and refused in a shared target org;user:maps only touser:; two source users landing as one;drop, and single sign-on link emails undersso_same_issuer;created_atdiffers) refused with arenameproposal, its email no longer excused (adropproposal), and a finished landing never a collision; a landing excused only under the handle the map gives now; a new digest for another bundle or anothersso_same_issuer;--namespaceselection, by handle and by contact or link email, and the export keepingacl-reviewswhile leaving out a mirror's reserved name and a collection;dropproposal;group:engandeveryone, refused;memory.bulk_setcalls: every entry checked, oldest first, no update detection, no reinforcement, no pin, the expiry taken from the time of writing (a row expired since the run began sent with one second), and a declined entry counted asmemories_not_admitted;user:-oruser:refused;memories_superseded; undernewest_winsa key the target holds for the same user in any agent or session, or for anyone where the row has no user, held, a row with no user written first and landing beside a newer named row of its key, and a run resumed after the rows with no user writing the rest; under another policy, or in a created namespace, only the exact key;char_limitonce serialized again among them, but not one a merge leaves out, a dropped user's or a skipped namespace's;--expect-planthat is not the plan's digest: exit 2, before the acceptance check and the apply; an original changed after the dry run read it:_documentsraises on it before writing, and the command turns that into a stop that says to run it again;instance importamong the commands whose default is a dry run (test_cli_apply_default.py);pg_memory.held_inpaged to the end, its keys counted with ClickHouse's, and a document head the authority holds counted as written;_landholding to the recordedcreated_atwhen the bundle's differs: a row it wrote is its own, the row it still owes is written with it, and a row registered since stops the run;newest_winsis left out and counted as held;pg_memory.held_infiltered to given keys;on_expirethe merge cannot keep, and leaving out a redacted one.tests/integration/test_instance_consolidation.py, against a real ClickHouse and server. An org moves into another org of the same deployment that already has analice, ateam, and a grant tobob.rename,claim(alice-legacy, andbob-legacyfrom the access check) anddropentries; the map built from them plans a digest. With an original changed since the export, it refuses; a clean one ends with the whole apply line, digest included.team-legacy;team, whose row matching them is refused; afterwards the target's own write of that row toteamsucceeds;knowledge.upsertowns (ingested_atincluded) and the extraction record; a knowledge source's synced copy stays behind and the manifest counts it, and a recording's transcript lands;team: its new key keeps the source's validity, tags, confidence, sensitivity and expiry, and its key the target holds is left alone; the target'steamusesnewest_wins: of a key the source holds in two sessions only the newer lands, and a key the target holds in another session stays the target's and live, an end user's newer row of a key (itsuser:subject kept by the map) lands beside the row with no user of that key, both read back live from the table, and the receipt counts the older employer row asmemories_superseded;grants: true):erin@src.test, who only asked to join the target'steam, gets the source's viewer grant;dave@src.test, whose target revocation is stored asDave@Src.Test, gets none; andfrank, whose unverified self-signup email holds writer there, gets the source's writer grant;join_policy: approval;aliceorbob;--namespacebundle, then a whole-org bundle: the first lands the owning account as a row only (marked in the dry run, no done row; the second dry run marks the finishedteam) and counts what it leaves behind for that namespace only; the second brings the account's own memory, marks it done, and leaves the finished namespace alone. Between the two, an account the first landed claimable and the source revoked since refuses a later plan until the target revokes it too (source and target share the deployment, so the test takes the source's revocation back before that plan reads the target). Undersso_same_issuer: truean account single sign-on made lands with its link and without JIT's tag, and single sign-on with its email resolves to it on the target.teamwith its status and version, document revision, namespaces, grants and refusals compared), and a finished rerun writes nothing either. Both pass the regex budget with the stored regexes, which a check counting them twice would refuse.docs/reference/cli.mdregenerated (the import gives its own dry-run hint,apply_gated=False). The dry run marks a landing an earlier run finished, which the apply skips. Ruff, mypy and the mypy gate, the function-length gate, the analyzer corpus, the package contracts,test_cell_cli_orgs,test_signup_privilege,test_model_call_writers, the mutation inventory, doc links and public copy all pass.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 by the end-to-end run, the integration test and the unit 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.🤖 Generated with Claude Code
Note
Medium Risk
New operator path copies passwords, high-sensitive memories, and grants into another deployment; mistakes in the YAML map or skipping dry-run could land data on wrong subjects, though plan refusal and
--expect-planmitigate many collision cases.Overview
Adds
loom instance exportandloom instance importso operators can move selected orgs (namespaces, password accounts, grants, memories, documents) from one deployment into another that already serves other teams. Export builds an owner-only bundle (gzip JSONL sections, document originals, manifest with checksums); import dry-runs a reviewed plan (YAML map for org/namespace/subject renames, merges, drops) and applies only when--expect-planmatches the plan digest.Plan/apply behavior refuses collisions (existing namespaces, handles, emails, empowered names) instead of folding rows; merged namespaces write via
memory.bulk_set, created ones via restore; audit rows (instance.import,.merge,.done) support idempotent resume. Export blocks unfinished erasures and unpublished Postgres documents; it does not audit per sensitive memory read (documented likedev/backup_loom.py).Also renames
_refuse_empowered→refuse_empoweredfor import/signup checks, addsblacklist_guard.match_value,pg_memory.held_in,pg_documents.held_urisfor import idempotency under Postgres authority, and shipsdocs/operations/consolidation.mdplus CLI/docs/CI wiring and integration tests.Reviewed by Cursor Bugbot for commit d1626d0. Bugbot is set up for automated code reviews on this repo. Configure here.