Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
31ae6e5
wip(metadata-protocol): the move door's protocol method and spec sche…
claude Nov 28, 2026
ecc88e3
wip(runtime): POST /packages/:id/move-in, its ledger row and SDK meth…
claude Nov 28, 2026
b0e096d
wip(metadata-protocol): objects move outside the transaction with an …
claude Nov 28, 2026
767556b
wip: spec baselines, schema and SDK tests, changeset (#38150)
claude Nov 28, 2026
7fa55cf
Merge remote-tracking branch 'origin/main' into claude/project-thread…
claude Nov 28, 2026
a976ac3
fix(metadata-protocol): keep protocol.ts at its line ceiling; route-l…
claude Nov 28, 2026
56df8b4
fix(spec): register the move-in door's three codes in the error-code …
claude Nov 28, 2026
4965c0c
test(spec): the domain-501 sentence census counts packages_move_in_un…
claude Nov 28, 2026
5ea8aad
chore(changeset): Metadata-protocol added, spec at minor, by the clai…
claude Nov 28, 2026
650b2b0
fix(metadata-protocol): the move-in undo writes the registry back in …
claude Nov 28, 2026
0d9ab26
fix(metadata-protocol): record the move-in door's saveMetaItem among …
claude Nov 28, 2026
3777fbc
fix(metadata-protocol): no tracker id in the registry-question row's …
claude Nov 28, 2026
61d7ebc
fix(metadata-protocol,runtime): the move-in door judges each item's t…
claude Nov 28, 2026
7ab2d91
test(metadata-protocol): the projector and signal censuses count the …
claude Nov 28, 2026
23ca501
docs(permissions),test(metadata-protocol): the move-in door's system-…
claude Nov 28, 2026
0d0078f
Merge branch 'main' of https://github.com/objectstack-ai/objectstack …
claude Nov 28, 2026
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
29 changes: 29 additions & 0 deletions .changeset/38150-move-into-package-door.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
'@objectstack/spec': minor
'@objectstack/metadata-protocol': patch
'@objectstack/runtime': patch
'@objectstack/client': patch
---

feat(runtime): `POST /api/v1/packages/:id/move-in` moves a selection of loose items into one package, each through the save door

Clause-②: yes (widening)
Metadata-protocol: added — the five new `@objectstack/spec/api` MoveIntoPackage* schemas enter the `api` authorable-surface shard (23 keys); no metadata key an author writes is added

The door ADR-0084's amendment of 2026-11-26 names ("Loose items stay where they are, and one door moves them"; ruling 7184753035, question 3). It takes a selection, never "everything loose": `{ items: [{ type, name, member? }], dryRun? }` (`MoveIntoPackageRequestSchema`, strict). New in the public surface: the route, `MoveIntoPackageRequestSchema`, `MoveIntoPackageResponseSchema` and their item schemas and types in `@objectstack/spec/api`, the protocol method `moveIntoPackage`, the SDK method `client.packages.moveIn(id, request)`, and the message key `packages_move_in_unsupported` (four locales). Nothing an author writes into metadata changes.

What a move does:

- Only an item bound to no package moves. An overlay of a shipped item and a `.custom` pair item are not loose and are refused `NOT_LOOSE`.
- The target is judged by the save door's own predicates: an uninstalled package is refused `422 WRITABLE_PACKAGE_REQUIRED`, and a package the deployment ships is refused as every package write door refuses it.
- An object is judged against the target by the save door's object judges: the namespace prefix (`NAMESPACE_PREFIX`), the namespace clash (`NAMESPACE_CONFLICT`), the package that owns the name (`OBJECT_OVERLAY_PACKAGE_MISMATCH`) and the `__c` reservation.
- The selection is judged as a set (ADR-0150 D3 (a)): a moved item that names a loose item of a package-scoped type the selection leaves behind is refused `REFERENCE_LEFT_BEHIND`, with the names in `references`.
- Each selected item's type is judged as a write of that type: moving a `datasource` needs the platform-settings capability and moving a `knowledge_source` needs the knowledge-source capability and passes that source's own admission, as saving one does (`403`).
- Then every item goes through the delete door (storage kept, naming the version the judgement read, so a save in between answers `409 METADATA_CONFLICT`) and the save door into the target, so every other save-door judge runs too, and each type writes through to the registry at once: a moved flow and dataset are read at the package's address with no restart. Items other than objects and the package commit (`operation: 'apply'`) run in one transaction. Objects move just before it, outside it, because an object's save syncs its storage, and that DDL waits forever on the lock a SQLite transaction holds. A later refusal undoes them.
- Whole or nothing: any refusal answers `422` with the first item's code in `error.code` and the whole answer (`outcome: 'refused'`, every item's refusal) in `error.details`. What had moved is moved back, with the registry and the mutation signal replayed at both addresses, so every item is loose and resolves as before. A failure that is not a refusal answers `500`, every item loose as before; if moving an item back fails, the `500` names the items that did not go back.
- `dryRun: true` answers `outcome: 'would_move'` with what each item's addresses become from the judgement made before any door runs (loose, target, the object judges, the set). It calls no door and writes nothing, so a save-door judge that runs only on the real move can still refuse an item a dry run passed.
- `client.packages.moveIn` resolves the answer for `moved` and `would_move`. A refusal, a refused dry run included, rejects with the first item's code as `code` and the whole answer as `details`.

Measured on this door: after a move, `_env/NAME` answers `409 RESOURCE_CONFLICT` naming the package that now holds the item, and the bare name and `NAMESPACE/NAME` answer `200`.

`POST /packages/:id/adopt-orphans` is unchanged here. Its retirement is the second half of #38150 and ships in the same release.
6 changes: 3 additions & 3 deletions content/docs/permissions/system-context.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ One of the largest consumers of the flag;
| 43 | Approval actor / submitter / pending-approver checks bypassed (9 sites) | plugin-approvals | Get: approve, reject, recall, reassign without being a pending approver or the submitter, and a decision or comment that attaches files the actor did not upload (every other caller attaches only files it uploaded, in the request's organization) | `isOverrideActor`, `resolveActor`, `sendBack`, `resubmit`, `reassign`, `remind`, `requestInfo`, `comment`, `assertAttachmentsUploadedByCaller` |
| 44 | Attachment access hooks return early (insert + update + delete, the referenced-file check on insert + update, and the read AST) | service-storage | Lose: attachment visibility scoping | `installAttachmentAccessHooks`, `installAttachmentFileReferenceGate`, `installAttachmentReadVisibility` |
| 45 | Comment access hooks return early (insert + update + delete, and the read AST), and so do the activity and audit-log read gates (their read AST), the activity field redaction and the audit-log field redaction (the rows a read serves), the activity summary's message code (the rows a read serves), and the query guard over both objects' value-bearing columns (the read AST) | plugin-audit | Get: the whole activity row and the whole `sys_audit_log` row, its before/after snapshots included, and the activity row's stored summary code (`metadata.summary_message`), on `find` / `findOne` — the audit writer, each read gate's bounded probe and the activity backfill — and a filter, sort or grouping by those columns. Lose: comment visibility scoping, the narrowing of `sys_activity` and of `sys_audit_log` to rows whose parent record the caller can read, the redaction of a parent field's value from an activity row's text and recorded change and from a ledger row's before/after snapshots, the withholding of an activity row recording an update whose every changed field the reader is withheld, of a fired milestone row whose watched fields it is not all served, and of an unstamped row (on `count` and `aggregate` too, so a total agrees with the rows), the removal of that summary code from the activity row's `metadata` (its params are field values), and the refusal of a query over those columns for a reader withheld a field of the objects it can reach, and the withholding of those columns from such a reader's server-chosen search set (#34700) | `installCommentAccessHooks`, `installCommentReadVisibility`, `installActivityReadVisibility`, `installAuditLogReadVisibility`, `installActivityFieldRedaction`, `installAuditLogFieldRedaction`, `installActivitySummaryLocale`, `installParentFieldQueryGuard`, `withheldSearchColumns` |
| 46 | Knowledge search returns hits unfiltered, and searches every source; a knowledge source is saved without its author being judged | service-knowledge, metadata-core, runtime | Lose: the permission filter over search results, and the source admission ahead of it — an `object` source over an object the caller's exposure decision refuses (disabled package, `apiEnabled` / `apiMethods` for `search`, a `sys_*` object without `enable.aiReadable: true`), or serving a field the caller may not query, is searched. Lose at the `/meta` and MCP save doors: the same admission asked for the author before a `knowledge_source` is saved (ADR-0161 K4), so the engine's own write saves a source over an object or a field no author was judged for. Lose at the package duplicate door: the same admission asked for the caller, for each knowledge source the copy would save | `applyPermissionFilter`, `admitSources`, `searchByKey`, `admitAuthoredSource`, `authoredKnowledgeSourceRefusal`, `refuseDuplicatedKnowledgeSources` |
| 46 | Knowledge search returns hits unfiltered, and searches every source; a knowledge source is saved without its author being judged | service-knowledge, metadata-core, runtime | Lose: the permission filter over search results, and the source admission ahead of it — an `object` source over an object the caller's exposure decision refuses (disabled package, `apiEnabled` / `apiMethods` for `search`, a `sys_*` object without `enable.aiReadable: true`), or serving a field the caller may not query, is searched. Lose at the `/meta` and MCP save doors: the same admission asked for the author before a `knowledge_source` is saved (ADR-0161 K4), so the engine's own write saves a source over an object or a field no author was judged for. Lose at the package duplicate door: the same admission asked for the caller, for each knowledge source the copy would save. Lose at the package move-in door: the same admission asked for the caller, for each selected knowledge source the move saves again under the package | `applyPermissionFilter`, `admitSources`, `searchByKey`, `admitAuthoredSource`, `authoredKnowledgeSourceRefusal`, `refuseDuplicatedKnowledgeSources`, `handlePackagesRequest` |
| 47 | The inbound-mail read gates return early (the read AST) | service-mailbox | Get: every `sys_mail_message` and `sys_mail_association` row on `find` / `findOne` — the ingest writer and each gate's own pre-scan, which read the association and mailbox rows a decision needs. Lose: the narrowing of a message to callers who can read a record it is associated with or who own its mailbox (so the unassociated pool is restricted), and of an association to callers who can read the record it names (on `count` and `aggregate` too, so a total agrees with the rows) | `gateMiddleware` |
| 47b | The inbound-mail ingest seam: `ingest` admits the system context ALONE, and `rematch` admits it without the organization, owner or `manage_mailboxes` check | service-mailbox | Get: a mail source hands a mailbox its messages, and server code re-matches any mailbox. Lose: nothing a user held — every other caller of `ingest` is refused (`PERMISSION_DENIED`), because an ingested message is shown on every record its correspondents' addresses match and a user who could hand the seam a message could write one in a correspondent's name; every other caller of `rematch` must be in the mailbox's organization and own the mailbox or hold `manage_mailboxes` | `ingest`, `authorizeRematch` |
| 47c | The inbound-mail IMAP sync: `syncMailbox` and `syncAll` admit the system context ALONE | service-mailbox | Get: the sync job reads every mailbox row (its organization, address and IMAP cursor), writes the cursor back, and hands each fetched message to `ingest` under the system context. Lose: nothing a user held — every other caller is refused (`PERMISSION_DENIED`), because a sync stores a mailbox's mail and moves its cursor | `syncMailbox`, `syncAll` |
Expand All @@ -211,7 +211,7 @@ One of the largest consumers of the flag;
| 52 | Anonymous-deny seam satisfied on the domain dispatchers and the package/federation routes | runtime, rest | Get: passes with no `userId` | `handleActionsRequest`, `dispatchActionRequest`, `resumeActionRunRequest`, `handleAIRequest`, `handleAutomationRequest`, `handleMetadataRequest`, `handleSecurityRequest`, `handlePackagesRequest`, `handleAnalyticsRequest`, `handleI18nRequest`, `registerExternalDatasourceRoutes`, `refusePackageRequest` |
| 53 | MCP principal check satisfied | runtime | Get: MCP surface reachable with no user | `handleMcpRequest` |
| 54 | Package REST route capability gate bypassed | rest | Get: a marketplace publish over REST (`POST /packages/publish`, the one route the REST registrar mounts since #14503) without `manage_metadata`; the package read cohort (`studio.access` / `setup.access`) is enforced by the dispatcher `/packages` domain's own read gate, where the reads are served | `refusePackageRequest` |
| 55 | Package domain capability gates bypassed | runtime | Get: package management and package-inventory reads without the capability; and a write to a package that holds a knowledge source (the twelve doors that write an existing package) without `manage_knowledge_sources` beside it (ADR-0161 K4) | `requireManageMetadata`, `requireReadCapability`, `refuseKnowledgeSourcePackageWrite` |
| 55 | Package domain capability gates bypassed | runtime | Get: package management and package-inventory reads without the capability; and a write to a package that holds a knowledge source (the twelve doors that write an existing package) without `manage_knowledge_sources` beside it (ADR-0161 K4); and, on the move-in door, a selected `datasource` or `knowledge_source` moved without the capability its `/meta` write asks (`manage_platform_settings`, `manage_knowledge_sources`) | `requireManageMetadata`, `requireReadCapability`, `refuseKnowledgeSourcePackageWrite`, `handlePackagesRequest` |
| 56 | Activation write / authoring refusals do not fire | runtime | Get: activation artifacts writable and authorable without the activation-authoring capability | `refuseUngrantedActivationWrite`, `refuseUngrantedActivationAuthoring` |
| 55b | Walled environment-metadata refusal does not fire | metadata-core, rest, runtime | Get: under `isolated` / `group`, a write of the environment's metadata, of any type, at the `/meta` write doors (save, reset, publish, rollback) and `POST /meta/_migrate-stored` on both transports, at every `/packages` write door (create, the manifest `PATCH`, enable, disable, publish, `publish-drafts`, `discard-drafts`, `revert`, `rollback`, `commits/:commitId/revert`, `duplicate`, `adopt-orphans`, delete), at the `/automation` definition writes (create, update, delete, clone), at the permission-set clone door, at the import of a remote table as an object (the REST import route and the MCP `import_object` tool), at the open MCP server's draft save and discard (`save_metadata_draft`, `delete_metadata_draft`), and at the refresh of a federated datasource's cached catalog. Every other caller below the platform-operator rung is refused `403` there (ADR-0131 D3, D12 items 7–8, D11), because one organization's write would change what every organization resolves. The seeders, the package door and migrations write the environment's metadata this way. Under `single` the refusal is inert for every caller | `walledCatalogWriteVerdict`, `walledCatalogRefusal`, `refuseWalledCatalogPackageWrite`, `refuseWalledFlowDefinitionWrite`, `registerExternalDatasourceRoutes`, `federationService`, `openWriter` |
| 57 | Automation run-state read, flow-authoring write, the paused-run caller gate (screen read and resume), the two operator run-lifecycle writes, and the elevated self-triggered start, the AI-service-account elevated start and the start-record check at every door that starts a flow by name all pass | runtime | Get: run state, flow writes, a paused run's screen and its resume with no grant and without being the run's starter — and cancelling or restoring a suspension without the platform-operator rung. The screen read and the resume ask one predicate, so this is one bypass for both. The lifecycle bypass is the in-process owner's door: plugin-approvals' revise-window recall (ADR-0044) cancels on behalf of a decision it already authorized and recorded. And starting a flow declared `runAs: 'system'` whose type is self-triggered (`autolaunched`, `record_change`, `schedule`) through any door that starts a flow by name — the trigger route, an action of `type: 'flow'` (REST `/actions` and the MCP `run_action` bridge) and a declared endpoint of `type: 'flow'` — which every other caller, the guest principal included, is refused `403 PERMISSION_DENIED` (the maintainer's rulings, letters B and A) — and starting, through the same doors, a flow whose `requiredPermissions` the caller does not hold (ruling record 6377848497, letter A) — and starting, through the same doors, a flow declared `runAs: 'system'` as an AI service account (an agent acting for itself, with no `onBehalfOf`) where the action's `ai.exposed: true` opt-in is not in hand, which that account is refused `403 PERMISSION_DENIED` (ADR-0151 Non-goals, ruling record 6812617393, letter C; a trigger route and a declared endpoint carry no opt-in, so there it is always refused, and the refusal names the action door that admits it). And starting, through the same doors, a flow on a record key the caller's own scope does not deliver, which every other caller is refused with the action door's `404 RECORD_NOT_FOUND` before the run exists (and `400 VALIDATION_FAILED` for a key that is not one id, or for an elevated start that names no object). The three doors ask one check, so this is one bypass for all of them, and it is the in-process caller's, such as a job: inbound HTTP never carries the flag | `mayReadRunState`, `refuseUngrantedFlowWrite`, `isRunStarterOrRunStateReader`, `refuseUngrantedRunLifecycleWrite`, `flowStartRefusal`, `refuseUnreadableFlowStartRecords` |
Expand Down Expand Up @@ -693,7 +693,7 @@ and CI refuses one that differs from what the tree produces.
| `packages/runtime/src/domains/mcp.ts#membershipReachRefusal` | 1 | 62b |
| `packages/runtime/src/domains/mcp.ts#resumeActionRunRequest` | 1 | 52 |
| `packages/runtime/src/domains/meta.ts#handleMetadataRequest` | 5 | 50, 52 |
| `packages/runtime/src/domains/packages.ts#handlePackagesRequest` | 1 | 52 |
| `packages/runtime/src/domains/packages.ts#handlePackagesRequest` | 3 | 46, 52, 55 |
| `packages/runtime/src/domains/packages.ts#refuseDuplicatedKnowledgeSources` | 1 | 46 |
| `packages/runtime/src/domains/packages.ts#refuseKnowledgeSourcePackageWrite` | 1 | 55 |
| `packages/runtime/src/domains/packages.ts#refuseWalledCatalogPackageWrite` | 1 | 55b |
Expand Down
5 changes: 4 additions & 1 deletion content/docs/references/api/automation-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ const result = AutomationApiErrorCode.parse(data);

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **code** | `Enum<'VALIDATION_ERROR' \| 'INVALID_FIELD' \| 'MISSING_REQUIRED_FIELD' \| 'INVALID_FORMAT' \| 'VALUE_TOO_LONG' \| 'VALUE_TOO_SHORT' \| 'VALUE_OUT_OF_RANGE' \| … +382 more>` | ✅ | The inner refusal's code in its WIRE spelling - the ADR-0112 member a record save of the same write answers in `error.code` (e.g. `UNIQUE_VIOLATION`); the closed set `ApiErrorSchema.code` parses against |
| **code** | `Enum<'VALIDATION_ERROR' \| 'INVALID_FIELD' \| 'MISSING_REQUIRED_FIELD' \| 'INVALID_FORMAT' \| 'VALUE_TOO_LONG' \| 'VALUE_TOO_SHORT' \| 'VALUE_OUT_OF_RANGE' \| … +385 more>` | ✅ | The inner refusal's code in its WIRE spelling - the ADR-0112 member a record save of the same write answers in `error.code` (e.g. `UNIQUE_VIOLATION`); the closed set `ApiErrorSchema.code` parses against |
| **message** | `string` | ✅ | The inner refusal's own diagnostic text, verbatim, without the node and operation prefixes the run's failure text adds |

### Allowed Values: `FlowInnerRefusal.code`
Expand Down Expand Up @@ -665,6 +665,7 @@ const result = AutomationApiErrorCode.parse(data);
* `METADATA_SCHEMA_INVALID`
* `MIXED_ARTIFACT_COLLECTION_SHAPE`
* `MONGODB_MULTI_TENANT_UNSUPPORTED`
* `MOVE_FAILED`
* `MULTI_REPLICA_PACKAGE_CHANGE_REFUSED`
* `MULTI_UPDATE_HOOK_KEY_DIVERGENCE`
* `NAMESPACE_CONFLICT`
Expand All @@ -676,6 +677,7 @@ const result = AutomationApiErrorCode.parse(data);
* `NOT_COMPENSABLE`
* `NOT_CREATABLE`
* `NOT_FOUND`
* `NOT_LOOSE`
* `NOT_OVERRIDABLE`
* `NOT_UNDOABLE`
* `NO_ACTIVE_ORGANIZATION`
Expand Down Expand Up @@ -729,6 +731,7 @@ const result = AutomationApiErrorCode.parse(data);
* `RECORD_GONE`
* `RECORD_LOCKED`
* `RECORD_NOT_ELIGIBLE`
* `REFERENCE_LEFT_BEHIND`
* `REGISTRY_TYPE_NOT_CANONICAL`
* `REQUEST_NOT_FOUND`
* `RESEED_NO_ROWS`
Expand Down
Loading
Loading