You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(objectql): switch metadata overlay isolation from project_id to organization_id
ADR-0005 (revised 2026-05): per-env DBs replace per-project isolation.
Each sys_environment owns its own Turso DB, so the legacy project_id
discriminator in sys_metadata is redundant. Inside one env, multiple
sys_organization rows can coexist (multi-org-per-env) and the only
meaningful overlay isolation key is organization_id.
Changes:
- protocol.saveMetaItem now persists organization_id (from request) and
stops writing project_id; existence lookup keyed by (type, name,
organization_id, state='active').
- protocol.getMetaItem: org-specific → env-wide (organization_id IS
NULL) → registry fallback chain. Backwards-compatible: callers
without organizationId behave as env-wide.
- protocol.getMetaItems: unions env-wide and org-specific rows;
org-specific wins on name collision.
- protocol.deleteMetaItem & loadMetaFromDb switched to organization_id
scoping. loadMetaFromDb hydrates only env-wide rows so per-org
overlays don't leak into the process-wide SchemaRegistry.
- ensureOverlayIndex: idempotent migration drops the legacy
(type, name, organization_id, project_id, scope) UNIQUE and creates
(type, name, organization_id) UNIQUE WHERE state='active' in place.
- sys-metadata.object.ts: project_id marked @deprecated; new schema
index spec reflects the new uniqueness key.
- http-dispatcher: resolves active organization id from session and
threads it through saveMetaItem/getMetaItem/getMetaItems.
- protocol-meta.test.ts: 4 new tests cover per-org isolation, env-wide
fallback, and collision-wins semantics.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
0 commit comments