Skip to content

Add adopt_tenant_id: pin a legacy project's tenant (#112) - #115

Merged
thorwhalen merged 2 commits into
mainfrom
feat/adopt-tenant-id-112
Oct 14, 2026
Merged

thorwhalen merged 2 commits into
mainfrom
feat/adopt-tenant-id-112

Conversation

@thorwhalen

@thorwhalen thorwhalen commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #112.

Adds nw.adopt_tenant_id(project, *, dry_run=False): an explicit, idempotent one-shot that writes a legacy project's currently-resolved tenant (root+title hash, or song hash) into project.json as tenant_id. The tenant, and so the data the project reads, is unchanged; the key just stops depending on root + title, so a folder removed and recreated by hand can no longer inherit the old Postgres graph. Projects that already have a tenant_id are left alone; nw never calls it itself (the host or a migration command runs it, ideally while the project is intact, since the song-hash form reads the audio file). It adds one key to project.json; no graph data is moved or deleted. Running it over a real deployment's existing projects is the host's call.

Tests: tests/test_tenant_id.py (pins the same tenant, idempotent, dry-run writes nothing, key survives retitle/move, non-project returns None). Full suite 761 passed.

Independent review (fresh Opus): two confirmed problems, both fixed here: (1) a missing song file would have pinned the root+title fallback permanently, so adoption now raises FileNotFoundError instead; (2) a self-keyed storage (MappingStorage) has no tenant_id, so adoption now returns None for it. Noted, not changed: two legacy projects that share audio bytes already share one tenant and adoption keeps that. No path moves or deletes graph data.

thorwhalen and others added 2 commits October 14, 2026 12:43
…oject.json (#112)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ed storages (review fixes, #112)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@thorwhalen
thorwhalen merged commit 3a31339 into main Oct 14, 2026
12 checks passed
@thorwhalen
thorwhalen deleted the feat/adopt-tenant-id-112 branch October 14, 2026 12:48
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.

Legacy projects (no tenant_id) still share a root+title Postgres tenant

1 participant