Skip to content

A collection is created from a title, its name derived, and a taken name says why with a free one - #471

Merged
zlareb1 merged 1 commit into
mainfrom
feat/collection-titles
Nov 10, 2026
Merged

zlareb1 merged 1 commit into
mainfrom
feat/collection-titles

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • New Feature

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 collection is created from a title: collection.create with derive_name derives its col-… name, and the Library shows titles. A name already used answers COLLECTION_NAME_TAKEN, which says whether a deleted collection held it and offers a free name.

Why

Creating a collection in the Library asked for a unique col-… name, and a name already used in the org was refused with PRECONDITION_FAILED, the code a failed if_match_sha256 check also answers, so neither a caller nor the dashboard could say what happened. Names stay unique in the org and are never reused: the name is the address that grants, search scope, audit and erasure key on. What changes is what a person types and what they are told.

  • Titles. A person types a title; titles may repeat across the org and across people. The server derives the name from it: the title's slug (Q3 Plans → col-q3-plans), else the slug with a four-character suffix hashed from (org, caller, parent, title, attempt). The derivation runs on the server because only the server sees every reason a name is taken (another namespace, someone else's collection, other people's grants, leftover data, a deleted collection).
  • A title names one collection within one parent (at the top level, one per creator). A derived create whose title one already has answers it with created: false. That makes the create safe to retry with no idempotency key, and a folder upload, which comes next, safe to repeat. An untitled collection whose name is the title's plain slug counts as the title's, so collections made before titles are reused rather than duplicated; only its admin's create writes the title onto it. At the top level a collection whose creator no longer writes it is not the title's.
  • derive_name is explicit. The MCP transport fills a blank namespace with the caller's default, and the SDK adds its own, so a blank name cannot carry the intent. With derive_name the server ignores namespace. The dashboard also sends the plain derived name, which a server a release behind (which ignores title and derive_name) creates.
  • The refusal says what is true. COLLECTION_NAME_TAKEN (409) carries deleted and suggestion. "the name 'col-x' is already used in acme", or "… belonged to a deleted collection in acme: a deleted name is never used again, so its old grants, audit rows and links cannot reach new content". The dashboard shows it with a Use col-x-ab12 button. A server a release behind still refuses with PRECONDITION_FAILED, which the dashboard shows with the server's words.

Design notes:

  • Where the title lives: loom.namespaces.title (migration 092), beside description. A separate table was considered and rejected. Every writer of an existing directory row copies it whole (dict(existing), SELECT * REPLACE), so a build that does not know the column keeps it. namespace.register refuses col- names, so registry_row only builds a collection's fresh row; it now carries title from an existing row anyway.
  • Claims: each candidate name takes its account claim and then the org's tree claim, the documented order. Under both, the sibling-title read runs again, so two creates of one title serialize and the second finds the first. A cheap read without claims skips candidates someone else holds, so a common title does not take 16 claim pairs.
  • Cost of the sibling read: under the claims, each candidate a derived create tries reads the parent's children (loom.collections by parent, not in its sort key, so a scan of the org's tree rows with FINAL) and their labels. It runs again per candidate so two creates of one title serialize; a cheap read without claims skips candidates someone else holds, so most creates read once. A folder upload creates one collection at a time, so the cost grows with the folders sent and the size of the org's tree; the org's collection count bounds it.
  • Audit: a new Operation.audit_namespace hook files collection.create's audit row under the collection it made or found, not the name the request sent (which derive_name ignores and MCP fills with the caller's default).
  • Scoped tokens: a token whose ns_write lists namespaces is never handed a derived name, sibling or suggestion outside that list; with none left the create answers AUTH_INSUFFICIENT, asking for an explicit name.
  • A title is not an identity. Titles are what people read; the address is what grants, search, audit and erasure key on. Invisible characters that would disguise a title are refused, and characters that may draw as nothing are ignored when titles are compared (the joiners and tags that shape emoji and scripts count). Confusable letters from different scripts are not prevented: the dashboard shows the address beside a title that looks like another, and in About.
  • Disclosure: deleted tells "a collection that was deleted" from "in use" for a name in the org. The name's existence is already disclosed by today's refusal.

Scope and risk

  • Server: collection.create (two paths: named, derived), collection.list (title), the directory read that lists labels, the personal-collection retirement blanks title as it blanks description.
  • Dashboard: New collection asks for a title, previews the address, and has Choose the address myself for an explicit one. The collection select, the parent pickers in New collection and Move, the About popover and the delete confirm show titles. A title shown twice carries its address, and siblings sort by what they show. The select's search matches title, address and description.
  • Left alone: renaming a title (no collection.update exists), folder upload and many-file upload (separate PRs built on this one).
  • Risk: an existing collection created by name keeps no title and shows its name, as today.

Compatibility, rollout and rollback

  • Wire: collection.create gains title (stripped and NFC-normalized, then ≤ 200 characters; it refuses control characters, format characters other than the joiners, the soft hyphen and the flag tags, and the characters that draw as blank: the Hangul fillers, the combining grapheme joiner, the braille blank and the line and paragraph separators) and derive_name (default false); namespace is now optional when derive_name is set; the output gains title. collection.list entries gain title. Break: a taken name answered PRECONDITION_FAILED; it now answers COLLECTION_NAME_TAKEN, still 409, so both SDKs still raise PreconditionFailed.
  • Operation gains audit_namespace (internal).
  • Migration 092: ALTER TABLE loom.namespaces ADD COLUMN IF NOT EXISTS title String DEFAULT ''. N-1 reads and writes ignore it; rows it copies keep it.
  • During the rollout, a title-only create served by a replica a release behind makes the plain name the dashboard sends (col-<slug>, or a col-c-… placeholder for a title with nothing to spell) without a title. On the new build, a later create of the same title reuses a col-<slug> one (an untitled collection by the name the title spells counts as its), but not a placeholder one: such a title then gets a second collection.
  • Operator steps: none.
  • Rollback: reverting leaves the column (unused) and any titles written in it.

Tests

  • tests/unit/test_collection_titles.py: derivation and its retry, a top-level title skipping a collection its creator no longer writes, only an admin titling an untitled collection, invisible characters refused and joiners kept, a title another person used, the sibling rule under a parent and at the top level, an untitled collection reused and titled only by its admin, a create cut short finished by its retry, a lagging sibling read still finding one's own, a client-filled namespace ignored under derive_name, a deleted name and a used name refused with a free suggestion, a scoped token, the audit row's namespace, list titles, input rules.
  • tests/unit/test_collection_create_name_in_use.py and test_namespaces_writers_mirror_classification.py updated; test_sdk_errors_from_response.py lists the new code. tests/analyzer/shapes.txt carries the schema dump's new shape.
  • tests/integration/test_knowledge_sharing.py::test_a_collection_made_from_its_title_is_found_again_by_it: creates from a title, reads the directory row back, lists, retries, a second person, the refusal. The whole file passes against a private server and ClickHouse (32 passed).
  • Frontend: CreateCollectionDialog.test.tsx (create from a title, an existing title opening its collection, a refusal with Use …, the title rule, plainName), LibraryCollections.test.tsx (titles, repeated titles, order), errorWords.test.ts (the line a taken name reads as).
  • Ran: make format lint typecheck, the unit files above, the full unit suite once (the only failures were test_tunable_constants, since fixed, and three clickhouse-local SQL files that fail on main on this host too), vitest on the four touched suites (all pass), npm --prefix frontend run build, npm --prefix frontend run budget, make migrate and make schema-dump on a private ClickHouse.

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 design went through four rounds of adversarial review against the code before the first line was written.

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

Checklist

  • make format-check, make lint, make typecheck and make test-unit pass; the integration suite passes if server behaviour changed. (Format, lint, typecheck and the touched unit files pass; the full unit suite runs on the rebased head before merge; the integration suite in CI.)
  • Generated files are regenerated in this PR, not by hand.
  • A new migration is additive and numbered after the latest on main; no merged migration is edited.
  • 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.
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.

🤖 Generated with Claude Code

…ame says why with a free one

People name a collection by its title (titles repeat); collection.create with derive_name derives the col- name, adding a short hashed suffix when the plain one is taken, and a title already used within the same parent answers that collection. A name already used answers COLLECTION_NAME_TAKEN with whether a deleted collection held it and a free name to use.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
@zlareb1
zlareb1 force-pushed the feat/collection-titles branch from d6cc9ff to c1e6a42 Compare November 10, 2026 18:42
@zlareb1
zlareb1 merged commit bf7a96f into main Nov 10, 2026
36 of 38 checks passed
@zlareb1
zlareb1 deleted the feat/collection-titles branch November 10, 2026 19:32
@zlareb1 zlareb1 mentioned this pull request Nov 12, 2026
3 tasks done
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