Skip to content

feat(objectql): ADR-0048 Phase 1+2 — namespace install gate + prefer-local resolution - #1810

Merged
xuyushun441-sys merged 5 commits into
mainfrom
feat/adr-0048-phase1-2-backend
Jun 13, 2026
Merged

xuyushun441-sys merged 5 commits into
mainfrom
feat/adr-0048-phase1-2-backend

Conversation

@xuyushun441-sys

Copy link
Copy Markdown
Collaborator

Implements Phase 1 and Phase 2 (backend) of the revised ADR-0048. Frontend (objectui) prefer-local ships in a companion PR.

Phase 1 — install-time namespace gate

SchemaRegistry.installPackage refuses a package whose manifest.namespace is already owned by a different installed package (new exported NamespaceConflictError). This makes explicit and early the constraint the object/table layer already enforces implicitly — a duplicate CREATE TABLE <ns>_<obj> fails loudly at the DB mid-install. Same-package reinstall is excluded; shareable platform namespaces (base/system/sys) are exempt; OS_METADATA_COLLISION=warn downgrades to a warning.

Phase 2 — prefer-local (container-scoped) resolution

getItem(type, name, currentNamespace?) resolves a bare name to the item owned by that namespace's package before any cross-package fallback. Precedence: (1) bare-key runtime/DB overlay (ADR-0005, unchanged) → (2) the namespace owner's composite entry → (3) legacy first-match. Omitting currentNamespace preserves the old behaviour exactly (backward compatible). getApp uses it (in v1 app.name ≡ namespace).

The per-item collision guard narrows: it now fires only where prefer-local cannot disambiguate — the two packages share a namespace (possible only for shareable sys) or lack one (legacy). Two packages with distinct namespaces now legitimately coexist on the same bare name (page/home in crm and hr) — the marketplace coexistence the revision targets.

Tests

  • registry-namespace-install-gate.test.ts — conflict, same-package reload, distinct namespaces, shareable-namespace exemption, warn downgrade, uninstall-releases.
  • registry-prefer-local-resolution.test.ts — coexistence, prefer-local pick, context-free fallback, overlay precedence, owner-misses fallback, shared-namespace still-fails.
  • Full @objectstack/objectql suite green (600). Every pre-existing ADR-0048 collision test still passes unchanged.

No public signature breaks — the new getItem param is optional.

🤖 Generated with Claude Code

os-zhuang and others added 2 commits June 13, 2026 10:14
feat(ADR-0046): package documentation portal + nav entry (#1686)

objectui@893e5302174c7cbf75a7bed9e8e6dcb935273363
…local resolution

Phase 1 — install-time namespace gate. `SchemaRegistry.installPackage` refuses
a package whose `manifest.namespace` is already owned by a DIFFERENT installed
package (new `NamespaceConflictError`), making explicit and early the constraint
the object/table layer already enforces implicitly (a duplicate
`CREATE TABLE <ns>_<obj>` fails at the DB). Same-package reinstall and shareable
platform namespaces (base/system/sys) are exempt; OS_METADATA_COLLISION=warn
downgrades to a warning.

Phase 2 — prefer-local (container-scoped) resolution. `getItem(type, name, ns?)`
resolves a bare name to the item owned by `ns`'s package before any
cross-package fallback, preserving ADR-0005 overlay precedence and remaining
backward compatible (param optional). `getApp` resolves prefer-local against its
own name (app.name ≡ namespace in v1). The per-item collision guard now narrows
to the cases prefer-local CANNOT disambiguate (shared/missing namespace), so two
DIFFERENT-namespace packages legitimately coexist on the same bare name — the
marketplace coexistence the revised ADR-0048 targets. Every existing collision
test still passes (namespace-less fixtures remain a hard error).

Tests: registry-namespace-install-gate.test.ts (7), registry-prefer-local-
resolution.test.ts (7). Full objectql suite green (600).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 13, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spec Ready Ready Preview, Comment Jun 13, 2026 7:36am

Request Review

…solution

Per the sharpened ADR-0048 decision: the URL/route key is the package id (A),
not the namespace. Migration cost is symmetric between A and B (both change one
thing), so A wins on the dimensions that matter for an open marketplace —
coordination-free global uniqueness, a single identity coordinate, no
land-grab, and a self-describing URL.

Backend:
- getItem(type, name, currentPackageId?) prefers `${currentPackageId}:${name}`
  directly (was namespace→owner indirection). ADR-0005 overlay precedence and
  backward compatibility unchanged.
- getApp(name, currentPackageId?) resolves prefer-local by package id.
- Retire the per-item CROSS-package throw: package ids are globally unique, so
  package-scoped resolution always disambiguates two distinct packages — what
  the old guard flagged is now the supported coexistence case. Remove the now-
  dead MetadataCollisionError, findOtherPackageOwner, isPreferLocalDisambiguable,
  isRealPackage, SYS_METADATA_OWNER. collisionPolicy now governs only the Phase
  1 namespace gate.

Tests: rewrite *-cross-package-collision.test.ts from "throws" to "coexists +
package-scoped resolves"; prefer-local test keys on package id. Full objectql
suite green (598).

ADR: §3.3 package-scoped (package-id) resolution; §3.4 cross-package throw
retired; §3.6 transparent package-id URL + optional per-tenant namespace alias;
phasing marks Phase 1 + Phase 2 backend/frontend done, package-id routing as the
remaining frontend step.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…2-backend

# Conflicts:
#	packages/objectql/src/registry-prefer-local-resolution.test.ts
#	packages/objectql/src/registry.ts
@github-actions github-actions Bot added documentation Improvements or additions to documentation size/l and removed size/m labels Jun 13, 2026
@xuyushun441-sys
xuyushun441-sys merged commit c78ebd9 into main Jun 13, 2026
12 checks passed
@xuyushun441-sys
xuyushun441-sys deleted the feat/adr-0048-phase1-2-backend branch June 13, 2026 07:41

This branch was successfully deployed

1 active deployment
Preview — 82e887e9 Deployed Jun 13, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/l tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants