Skip to content

Commit d5d32a0

Browse files
committed
feat(runtime): reconcile the new-similar target rule to the shared helper, add the objects limb, ledger note, tests, changeset
Claude-Session: https://claude.ai/code/session_01FEkQ5khiLzZmecWFfjSZLc Co-authored-by: Claude <noreply@anthropic.com>
1 parent e2657fe commit d5d32a0

6 files changed

Lines changed: 403 additions & 143 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
'@objectstack/runtime': patch
3+
---
4+
5+
feat(runtime)!: the permission-set clone door lands "new similar" in a writable target package — by default the source package's `.custom`, never package-less (#28563)
6+
7+
Clause-②: yes (narrowing) — `POST /security/permission-sets/:name/clone` takes an optional `package` and its answer names the package the copy landed in (widening); a copy of a set shipped by a read-only package now lands in that package's paired `<X>.custom`, ensured through the pair's one creation path, so a source whose package the ensure door refuses (it declares no namespace, its version is not SemVer, or another package owns the pair's namespace) is refused 409/422 where it was copied package-less before, and a given target that is unknown, read-only or out of reach is refused.
8+
Metadata-protocol: none
9+
10+
<!-- adr-0087: not-required (no-migration-prescription) No metadata key, value or type changes: the door's HTTP body gains an optional key and its answer gains one, and the copy's own definition is the same whole-definition copy as before. A refused clone writes nothing and its refusal names the remedy, so there is nothing stored for a migration to rewrite and no tombstone. -->
11+
12+
**BREAKING** accept-set narrowing at the permission-set clone door (`@objectstack/runtime`).
13+
14+
- **Before.** Every copy was saved environment-wide with no package, whatever package shipped the set it was copied from. The body was `{ name, label }`.
15+
- **Now (ADR-0146 D3/D6).** The body is `{ name, label, package? }` and the answer is `{ permissionSet, package, notice }`.
16+
- `package` omitted, the set shipped by a read-only package X: the copy is saved in X's paired customization package `<X>.custom`, created through the ensure door (`ensureCustomizationPackage`) on the first copy and reused after. The stored row is bound to the pair; the copy's definition still names no package.
17+
- `package` omitted, the set already in a writable package (a base you own, or `<X>.custom`): the copy is saved in that package.
18+
- `package` omitted, the set authored in the environment: unchanged, environment-wide (`package: null`).
19+
- `package` given: it must be installed and writable (else 422 `WRITABLE_PACKAGE_REQUIRED`), and its dependency closure must reach the source's package and every object the set grants on (else 409 `RESOURCE_CONFLICT`). The rule is the one the flow clone door uses.
20+
- **Unchanged.** A new name is mandatory and a taken one is 409; `manage_metadata` and the walled catalog refusal answer first; the copy is assignable by its bare name through a position or a direct assignment.
21+
- **Who sees it.** An administrator copying a packaged set from Setup: the copy now travels with the package's customizations. A copy of a set from a package the ensure door cannot pair is refused with the ensure door's own sentence.
22+
23+
**The remedy.** For a refused pair: give the base package a namespace (and a SemVer version), or name a writable target with `package`.

‎packages/qa/dogfood/test/permission-set-clone-door.dogfood.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,19 @@ describe('the permission-set clone door, on a booted showcase', () => {
221221
}
222222
});
223223

224+
it('a platform set (the lock-and-clone rule\'s commonest source) copies into its shipping package\'s pair', async () => {
225+
const reader = securityCatalogReaderOf(ql)!;
226+
const source = await reader.resolve('permission', 'member_default');
227+
expect(source?.packageId, 'member_default is not packaged on this boot').toBeTruthy();
228+
229+
const res = await clone(token, 'member_default', { name: 'my_member_baseline', label: 'My Member Baseline' });
230+
const text = await res.clone().text();
231+
expect(res.status, text).toBe(200);
232+
const landed = ((await res.json()) as any).data.package;
233+
expect(landed).toBe(`${source!.packageId}.custom`);
234+
expect((await reader.resolve('permission', 'my_member_baseline'))?.packageId).toBe(landed);
235+
});
236+
224237
it('CONTROL — an environment-authored source still copies environment-wide, with no package', async () => {
225238
const saved = await stack.apiAs(token, 'PUT', '/meta/permission/env_authored_source', {
226239
name: 'env_authored_source', label: 'Env Authored', objects: { showcase_task: { allowRead: true } },

0 commit comments

Comments
 (0)