Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions docs/adr/0070-package-first-authoring.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ADR-0070: Package-first authoring — every runtime-authored item lives in a writable package (base); no orphans

**Status**: Accepted (2026-06-24) — P1–P3 implemented, merged & live-verified (see *Implementation status*); D4–D6 remaining · **Superseded in part by [ADR-0146](./0146-studio-designs-setup-administers-one-editor-per-item-paired-customize-package.md)** (2026-10-31) — D3's prompt to create a base, for the paired case only: a customer's first customization of an installed base lands in the auto-created `<base>.custom` package without a prompt (ADR-0146 D3); D5's destination for a package-less overlay row of a packaged item: the base's `<base>.custom`, as a declared override, after which the package-less write closes (ADR-0146 D11). D1, D2, D4 and D6 stand; D3's prompt stands everywhere else. · **Amended** (2026-10-31, [#28117](https://github.com/objectstack-ai/objectstack/issues/28117) — the maintainer's ruling of 2026-10-30, 「大包 + 设置里启用模块」, then 「同意」: a `type: module` sub-package of an installed app may be **disabled**, not authored into, by an admin, on the tie PR [#28308](https://github.com/objectstack-ai/objectstack/pull/28308) shipped; see the amendment note under D2. D2's two kinds and its writability predicate stand.) · **Amended** (2026-11-29, [#38150](https://github.com/objectstack-ai/objectstack/issues/38150) — ruling record [comment 7184753035](https://github.com/objectstack-ai/objectstack/issues/37424#issuecomment-7184753035), question 3, ruled C, as [ADR-0084](./0084-application-builder-information-architecture.md#amendment-2026-11-26-org) records it: D5's "move into a base" is the move-in door, and D5's bulk assignment to a default base is superseded; see the amendment note under D5. D1 and D6 stand.)
**Status**: Accepted (2026-06-24) — P1–P3 implemented, merged & live-verified (see *Implementation status*); D4–D6 remaining · **Superseded in part by [ADR-0146](./0146-studio-designs-setup-administers-one-editor-per-item-paired-customize-package.md)** (2026-10-31) — D3's prompt to create a base, for the paired case only: a customer's first customization of an installed base lands in the auto-created `<base>.custom` package without a prompt (ADR-0146 D3); D5's destination for a package-less overlay row of a packaged item: the base's `<base>.custom`, as a declared override, after which the package-less write closes (ADR-0146 D11). D1, D2, D4 and D6 stand; D3's prompt stands everywhere else. · **Amended** (2026-10-31, [#28117](https://github.com/objectstack-ai/objectstack/issues/28117) — the maintainer's ruling of 2026-10-30, 「大包 + 设置里启用模块」, then 「同意」: a `type: module` sub-package of an installed app may be **disabled**, not authored into, by an admin, on the tie PR [#28308](https://github.com/objectstack-ai/objectstack/pull/28308) shipped; see the amendment note under D2. D2's two kinds and its writability predicate stand.) · **Amended** (2026-11-29, [#38150](https://github.com/objectstack-ai/objectstack/issues/38150) — ruling record [comment 7184753035](https://github.com/objectstack-ai/objectstack/issues/37424#issuecomment-7184753035), question 3, ruled C, as [ADR-0084](./0084-application-builder-information-architecture.md#amendment-2026-11-26-org) records it: D5's "move into a base" is the move-in door, and D5's bulk assignment to a default base is superseded; see the amendment note under D5. D1 and D6 stand.) · **Amended** (2026-12-03, [#38174](https://github.com/objectstack-ai/objectstack/issues/38174) — ruling record [comment 7184753035](https://github.com/objectstack-ai/objectstack/issues/37424#issuecomment-7184753035), question 2, ruled A, as [ADR-0084](./0084-application-builder-information-architecture.md#amendment-2026-11-26-org) records it, and ruling record [comment 7380917604](https://github.com/objectstack-ai/objectstack/issues/38174#issuecomment-7380917604), ruled A: the kernel refuses a create that names no package, five writers keep a named exemption (the four of the first ruling and, by the second, the organization-ownership ceremony's conversions of rows stored before the upgrade), and a loose row that exists is still saved in place; [PR #39386](https://github.com/objectstack-ai/objectstack/pull/39386) closes the kernel save, and D1 is complete except for one open door outside that save, Setup's datasource create, tracked in [#39398](https://github.com/objectstack-ai/objectstack/issues/39398); see the amendment note under D1. D1's text stands.)
**Deciders**: ObjectStack Protocol Architects
**Builds on**: [ADR-0005](./0005-metadata-customization-overlay.md) (`allowOrgOverride` / runtime overlay model; one Zod source per type), [ADR-0048](./0048-cross-package-metadata-collision.md) (one app per package; package id is the addressing unit), [ADR-0033](./0033-ai-assisted-metadata-authoring.md) (AI authors metadata as drafts), [ADR-0067](./0067-commit-history-and-rollback-for-ai-authoring.md) (commit history & rollback for AI authoring)
**Consumers**: `@objectstack/objectql` (`protocol.saveMetaItem` write path), `@objectstack/spec` (metadata-type registry), `../objectui` (Studio create flow, package scope selector, `PackagesPage`), `../cloud` (`service-ai-studio` — `create_metadata` / `resolvePackageId` / `apply_blueprint`)
Expand All @@ -23,6 +23,7 @@ Built across the three surfaces and verified end-to-end in a real environment vi
- **P3 — AI (D3)** — `../cloud` `service-ai-studio` ([cloud#479](https://github.com/objectstack-ai/cloud/pull/479), [cloud#481](https://github.com/objectstack-ai/cloud/pull/481); tests [cloud#480](https://github.com/objectstack-ai/cloud/pull/480)): drops the shared `com.workspace` catch-all and auto-creates an **intentional named** base via `protocol.installPackage` (a real, Studio-visible package); single-writable-base coherence groups an incremental build into one base; an explicit platform/system `packageId` is discarded; empty field props are sanitized.
- **Live dogfood (real LLM + runtime)**: a one-sentence magic build plus iterative business-user changes (add a related object, add a field) all landed in **one** app base (`app.iojn`), live and editable — no `com.workspace`, no orphans.
- **Remaining**: **D4** (package-as-lifecycle-unit: delete-cascade / export / duplicate), **D5** (orphan migration + stopgap removal), **D6** (framing). The P1 kernel rejection becomes the runtime backstop once the framework release is consumed by the cloud runtime (today's runtime links the published framework).
- **D1's kernel close (2026-12-03, [#38174](https://github.com/objectstack-ai/objectstack/issues/38174))** — P1 refused a runtime create that names a read-only package, and still accepted one that names no package. [PR #39386](https://github.com/objectstack-ai/objectstack/pull/39386) closes that create too: the kernel save answers `422 WRITABLE_PACKAGE_REQUIRED` and names the writable packages. The kernel save is closed and D3's Kernel bullet is done. D1 is complete except for one open door outside the kernel save, Setup's datasource create, tracked in [#39398](https://github.com/objectstack-ai/objectstack/issues/39398); the amendment note under D1 has the exemptions and what stays open.

## TL;DR

Expand Down Expand Up @@ -56,6 +57,18 @@ A runtime **create** (`intent = runtime-only`, i.e. not an overlay of an artifac
- `null` / `sys_metadata`-scope ceases to be a *write* destination for new items. It survives only as (a) the read-side rehydration tag for legacy rows and (b) the source set for the D5 migration.
- Overlays of artifact items (`intent = override-artifact`, `allowOrgOverride`) are **unchanged** — they keep their binding to the packaged item they customise.

> **Amended 2026-12-03 ([#38174](https://github.com/objectstack-ai/objectstack/issues/38174), ruling record [comment 7184753035](https://github.com/objectstack-ai/objectstack/issues/37424#issuecomment-7184753035), question 2, ruled A, written into [ADR-0084's amendment of 2026-11-26](./0084-application-builder-information-architecture.md#amendment-2026-11-26-org); and ruling record [comment 7380917604](https://github.com/objectstack-ai/objectstack/issues/38174#issuecomment-7380917604), ruled A) — the kernel refuses a create that names no package; five writers keep a named exemption, and a loose row that exists is still saved in place.** This note records the implementation status of the decision above, with the exemptions the two rulings name. Before [PR #39386](https://github.com/objectstack-ai/objectstack/pull/39386), the kernel enforced one half of it: it refused a runtime create that named a read-only package, and it accepted one that named no package and stored a loose row. That PR closes the second half, in the same phase as the interface's ask and after it, with no flag.
>
> - **What is refused.** A save through `protocol.saveMetaItem`, draft or publish, that names no package is a create when no package holds the name, as an item or as a draft, and no package-less row or draft of it is stored. It is refused before anything is written, with `422 WRITABLE_PACKAGE_REQUIRED`, D1's own code, in a sentence that names the type and the name and lists, up to a cap, the writable packages the caller may name. `os meta register` is closed with the rest: a new item needs its `--package`. The permission-set clone door is closed with it too: a copy with no package to land in (a loose source, or a set a kernel package ships) is refused, and Setup's clone dialog asks for the landing package, offering the writable packages (claim amendment [7389333883](https://github.com/objectstack-ai/objectstack/issues/38174#issuecomment-7389333883), ruled A on 2026-12-03, with no new exemption).
> - **Five writers keep a named exemption.** The ruling of 2026-11-26 names four. An overlay of a kernel item, until the platform pair's whitelist exists: an overlay is `intent = override-artifact`, which the third bullet above leaves unchanged. The ruled import of an external datasource, which the server stamps `writeFace: 'external-import'`. A migration that preserves a binding, which re-saves a stored row under a server-stated `source`. Platform registration, which writes the metadata service's own store and does not pass the kernel save. The ruling of 2026-12-03 names the fifth, which the next bullet gives with its bound. A remote caller can state none of the marks these exemptions are read by. Decisions Q-a, answered A, and Q-b, answered C, add no metadata type and no case to the five (ADR-0084's first note of 2026-12-03 gives them).
> - **The fifth: the organization-ownership ceremony's conversions of rows stored before the upgrade** (ruling record [comment 7380917604](https://github.com/objectstack-ai/objectstack/issues/38174#issuecomment-7380917604): on the decision card the maintainer chose the option 「A 迁移照旧落为散落项」, and the record is the maintainer's word for "four writers, and no other" becoming five). `os migrate organization-ownership --apply` makes two creates that name no package (`packages/cli/src/utils/organization-ownership-apply.ts`): it converts an organization's authored positions and permission sets into environment metadata, and it promotes an email template. Both state one server-side provenance, the request field `packagelessCreateProvenance: 'organization-ownership-ceremony'`, on the precedent of the external import's `writeFace`, and no wire body can state it. Only the create judgment reads it. `source` is not set, so every other gate still judges these saves: a permission set that grants on an object that does not exist is still refused, and the ceremony reports it as a blocker. That is the exemption's bound: the ceremony's conversions of rows stored before the upgrade, and no other save. The converted items land loose. The ceremony's report lists what it left loose and names the door that moves it into a package, `POST /api/v1/packages/:id/move-in` (the amendment note under D5).
> - **What stays open.** A loose row that exists is saved in place, as a draft or as a published item, and it is deleted and its draft published as before. A save that names no package for a name a package holds is unchanged too: the name is not new, and [ADR-0150](./0150-behavioural-metadata-addressed-by-package-objects-keep-the-literal-prefix.md) D4 judges the save as before ("A package-less row that bears a package-held name is a customization, never a second item"). A name whose only stored row is a draft that a package holds is not new either: a save of it that names no package is no create, and the draft address judges it as before (`packages/metadata-protocol/src/sys-metadata-repository.ts#unboundItemDraftAddress`).
> - **The automation definition doors.** `POST /api/v1/automation` and `PUT /api/v1/automation/:name` created flows that belong to no package. The first is retired, and the second updates a flow that exists and refuses a new name (decision Q-g, answered C: [comment 7234518908](https://github.com/objectstack-ai/objectstack/issues/37424#issuecomment-7234518908)). A flow is created with `PUT /api/v1/meta/flow/NAME?package=PKG`, which registers the flow and arms it at once. The refusal of a notify node that names an unregistered channel, which the automation doors ran and that save did not, moves onto it ([comment 7378011450](https://github.com/objectstack-ai/objectstack/issues/38174#issuecomment-7378011450)).
> - **One open door outside the kernel save.** Setup's `POST /api/v1/datasources` creates a runtime `datasource` and inserts its row into `sys_metadata` with no package, directly (`persistDatasourceRow`), so the write never reaches `protocol.saveMetaItem` and the close does not meet it. It is none of the five exemptions, the census that ruling record [comment 7184753035](https://github.com/objectstack-ai/objectstack/issues/37424#issuecomment-7184753035) ruled on did not list it, and no ruling covers it. Until [#39398](https://github.com/objectstack-ai/objectstack/issues/39398) closes it (or a ruling exempts it), D1 is not complete for that door.
> - **Not reached.** Sharing rules, queues and assignment rules that an organization authors in Setup are data rows, and no metadata save writes them; ADR-0084's first note of 2026-12-03 corrects the sentence that bound them to a package.
>
> D1's three bullets stand as written.

### D2 — Two package kinds; only writable packages are authoring targets [existing->ruled]

- **Code / installed packages** — manifest `source: 'filesystem'`, or installed via the marketplace; scope `system` / `cloud` (already filtered out of the Studio selector). **Read-only.** New items may not be authored into them; only `allowOrgOverride` overlays are permitted (ADR-0005). This mirrors Airtable's installed apps/templates.
Expand All @@ -71,7 +84,7 @@ Every authoring surface follows the same contract; none silently defaults into a

- **Studio UI** [new]: the scope selector defaults to a *writable* package (the user's most-recent base) or, when none exists, the create entry points (`新建`) **prompt to create a base** (reuse the existing `PackagesPage` create dialog) before opening the designer. New items are bound to the active writable package. The "Local / Custom" (`sys_metadata`) scope is removed as a create destination (see D5).
- **AI authoring** [new] (`../cloud` `service-ai-studio`): `resolvePackageId` **drops the auto-`com.workspace` fallback** (`metadata-tools.ts`) and the `applyDraft` re-bind (); when no writable package is resolvable it returns an actionable error directing the agent to `create_package` or `set_active_package`. `apply_blueprint` requires a package context (its `ensureAppPackage` is invoked only after an explicit create/confirm). Skill prompts (`metadata-authoring-skill.ts`, `solution-design-skill.ts`) are updated to make "establish the base first" a hard step, not a hint.
- **Kernel** [new]: D1 is the backstop — even if a surface regresses, the write is rejected, not orphaned.
- **Kernel** [new]: D1 is the backstop — even if a surface regresses, the write is rejected, not orphaned. *(Done 2026-12-03, [#38174](https://github.com/objectstack-ai/objectstack/issues/38174): the kernel refuses a create that names no package — the amendment note under D1; Setup's datasource create, which writes outside the kernel save, stays open in [#39398](https://github.com/objectstack-ai/objectstack/issues/39398).)*

### D4 — The package is the lifecycle unit (delete / export / snapshot / duplicate) [new]

Expand Down
Loading
Loading