Skip to content

feat(packages): consolidate package subsystem so AI-built app packages surface in Studio#1551

Merged
xuyushun441-sys merged 1 commit into
mainfrom
feat/adr-0033-package-consolidation
Jun 3, 2026
Merged

feat(packages): consolidate package subsystem so AI-built app packages surface in Studio#1551
xuyushun441-sys merged 1 commit into
mainfrom
feat/adr-0033-package-consolidation

Conversation

@xuyushun441-sys

Copy link
Copy Markdown
Contributor

Context

When the AI builds an app it auto-creates an app.<name> package (#1550) so the drafted artifacts have a home — but that package never appeared in Studio's package selector or detail. Root cause: the package subsystem was split across two stores that never met, with no reconciliation in either direction:

  • In-memory SchemaRegistry (registry.ts) — written by boot-time registerApp() and HTTP POST /api/v1/packages. This is the only store Studio reads (its selector hits the dispatcher's /api/v1/packages, whose list = registry.getAllPackages() and detail = registry.getPackage()).
  • sys_packages table (service-package) — where the AI writes (ensureAppPackagepackageService.publish). Nothing loaded it into the registry; the dispatcher never read it.

So the AI's package landed in sys_packages, Studio read the registry → invisible. And protocol.installPackage was declared in the interface but never implemented.

Change — one write primitive, one read source

  • @objectstack/objectql: implement ObjectStackProtocolImplementation.installPackage — the canonical write primitive. Registers the package in the in-memory registry and best-effort persists to sys_packages via the optional package service. Non-fatal when no package service is wired (registry write still succeeds).
  • @objectstack/runtime: dispatcher POST /api/v1/packages routes through protocol.installPackage (falls back to the bare registry write when the protocol is unavailable) — HTTP installs are durable too.
  • @objectstack/service-package: on boot, reconcile sys_packages rows back into the registry without clobbering filesystem-registered packages — persisted packages survive a restart and stay visible.
  • @objectstack/service-ai: apply_blueprint's ensureAppPackage prefers protocol.installPackage (falls back to the legacy package-service publish), so an app package lands where Studio reads it.

Verification

  • Live (showcase :3000): POST /api/v1/packages (→ protocol.installPackage) returns 201, GET /api/v1/packages/<id> returns 200, and the package now appears in GET /api/v1/packages (list count 15 → 16) — the read path Studio's selector consumes.
  • Unit (all green): protocol.installPackage writes registry + calls publish, skips/persists gracefully when the service is absent or rejects; dispatcher POST routes through the primitive and falls back; service-package boot-hydration hydrates a persisted row and does not overwrite an existing id; apply_blueprint prefers protocol.installPackage and falls back to publish. Full suites: objectql 491, runtime 336, service-package 2, service-ai 471. ESM/CJS/DTS builds clean.

Scope

Still the legacy package_id plane — sealed sys_package_version versioning and cross-environment promotion remain ADR-0027 follow-ups.

🤖 Generated with Claude Code

Implement protocol.installPackage as the single canonical write primitive
(registry + best-effort sys_packages), route the dispatcher's POST /packages
and the AI's apply_blueprint app-home through it, and reconcile sys_packages
back into the registry on boot — so an AI-created app.<name> package surfaces
in Studio's package selector/detail and survives restart.

- objectql: implement ObjectStackProtocolImplementation.installPackage
- runtime: POST /api/v1/packages → protocol.installPackage (registry fallback)
- service-package: boot-hydrate sys_packages → registry (no filesystem clobber)
- service-ai: ensureAppPackage prefers protocol.installPackage, publish fallback

Still the legacy package_id plane; sealed sys_package_version + cross-env
promotion remain ADR-0027 follow-ups.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 2, 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 3, 2026 12:01am

Request Review

@github-actions github-actions Bot added documentation Improvements or additions to documentation tests tooling labels Jun 2, 2026
@github-actions github-actions Bot added the size/m label Jun 3, 2026
@xuyushun441-sys xuyushun441-sys merged commit 4fbb86a into main Jun 3, 2026
14 of 15 checks passed
@xuyushun441-sys xuyushun441-sys deleted the feat/adr-0033-package-consolidation branch June 3, 2026 00:10
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/m tests tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants