Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
9eca892
test(dogfood): a position created into a writable package binds sets …
claude Nov 28, 2026
8c326f1
test(dogfood): a live edit naming no package lands on the set a packa…
claude Nov 28, 2026
b8dd0d3
feat(app-shell): a create with no named package asks to pick or creat…
claude Nov 28, 2026
337b029
test(app-shell): pin the create ask, and retarget the package-less cr…
claude Nov 28, 2026
0a67e2d
test(app-shell): pin the ask's own wiring, the console create-app rou…
claude Nov 28, 2026
5c2a6d8
chore(changeset): the create ask
claude Nov 28, 2026
ecb49ab
Merge remote-tracking branch 'origin/main' into claude/project-thread…
claude Nov 28, 2026
f7433b6
test(app-shell): the same-address pin hands the ask, not the retired …
claude Nov 28, 2026
0119d24
fix(app-shell): the editor holds the create's chosen package for the …
claude Nov 28, 2026
1e5b3fa
test(app-shell): pay the source's dynamic imports at collection, inhe…
claude Nov 28, 2026
328b0d2
fix(app-shell): Setup access directory reads its sub-path at the pack…
claude Nov 28, 2026
4b15ae4
test(app-shell): the scoped list address is spelled at the setup alias
claude Nov 28, 2026
5bb904f
test(app-shell): the cross-package leg's create answers the package ask
claude Nov 28, 2026
e9cf656
test(app-shell): the chart door reads the routed app's package; the a…
claude Nov 28, 2026
dca3013
test(app-shell): pin the create-ask paths the in-app creates now take
claude Nov 28, 2026
958d1c1
test(app-shell): pay the lint load at collection in the retargeted cr…
claude Nov 28, 2026
b99efee
Merge origin/main into claude/project-thread-dbfcfi
claude Nov 28, 2026
6b589fc
fix(app-shell): Setup's catalog asks for a new item's package once, a…
claude Nov 28, 2026
75fbb8d
chore(changeset): the catalog's create asks at Save
claude Nov 28, 2026
65a8b19
fix(app-shell): the cross-package leg's ask pre-selects nothing
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
23 changes: 23 additions & 0 deletions .changeset/38149-create-asks-for-package.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
'@object-ui/app-shell': patch
'@object-ui/plugin-designer': patch
'@object-ui/i18n': patch
---

feat(app-shell): a create whose address names no package asks the person to pick a package or create one

Clause-②: yes (widening)
Metadata-protocol: none

The console no longer saves a new item naming no package. Where a create's package is not named, the person is asked to choose one of the packages the server says they may write (`writable: true` on `GET /api/v1/packages`, kernel packages left out), or to create a new one with the Packages page's create dialog. Nothing is written until they answer, and Cancel writes nothing.

- Setup's metadata lists: New on a list scoped by the list's own heuristic pick (no `?package=` in the address, or the one the list wrote itself) asks, with that pick pre-selected. A `?package=` the person put in the address, by a link or by the scope selector, opens the create there with no ask, as before. New waits while the package list loads.
- Setup's catalog (`?scope=environment`): New opens the create in the environment scope, and the editor's Save asks for the package, once. Studio's cross-package leg (`/studio/~all/metadata/TYPE`): New asks, with nothing pre-selected.
- The item editor at a create address naming no package (a deep link to `/new`): Save asks first; the item is saved as a draft in the chosen package and published at once, and the editor opens it under that package. A position or a permission set takes this path too, instead of the live package-less create.
- A new view or report in an app: saved into the app's writable package or its customization package, as before; where neither can be had the person is asked. In a system app the create is refused with the reason (a view: save it to My views or add it in a business app; a report: create it in a business app). Where the customization package's door refuses the caller (`403`), the create is refused with the door's reason. The "saved outside this app" notice no longer runs.
- The console's create-app route asks for the package, then saves the wizard's app as a draft there and publishes it. `CreateAppPage` (plugin-designer) takes an optional `saveApp(name, app)` that replaces its own save; answering `false` keeps the wizard open with nothing done.
- Datasource Sync lands each object through the server's import door (`POST /api/v1/datasources/:name/external/tables/:remote/import`), which lands it in the datasource's own package, its read-only base's `.custom` pair, or no package for a datasource that has none, instead of a client save naming none.
- Setup → Access control → Positions and permissions reads its own sub-path at the address the shell serves Setup at (`/apps/com.objectstack.setup/...`) as well as at the `setup` alias, so New on a position or a permission set opens the editor in Studio instead of a blank page, and a list gets the environment scope on both addresses (objectstack#38206).
- New `studio` catalogue keys `engine.packageAsk.*` (English and Chinese).

Nothing to migrate. No server route, spec key or stored row changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
//
// [ADR-0070 D3, ADR-0084 amendment of 2026-11-26, ADR-0150 D3/D7] A position
// the console creates INTO a writable package still confers the permission
// sets an administrator binds from outside that package: a set another
// package holds, a set a code package ships, and a loose (package-less) set.
//
// ## Why this file exists
//
// Setup's Positions and Permission sets pages create through the environment
// scope today, so a new position and a new set name no package and the set is
// written live. The App Studio create ask moves those creates into a package:
// the administrator picks a writable package (or creates one) before the
// first save, and the item is saved there as a draft and published. The
// premise that move rests on is measured here, on a real booted showcase and
// through the same REST doors the console's editor uses (`PUT
// /meta/:type/:name?mode=draft&package=ID`, then `POST
// /meta/:type/:name/publish?package=ID`): a holder of such a position is
// granted every set the position names, whatever package (or none) holds it.
//
// The read that decides it is the security catalog's `referenceCaller`
// (core `security-catalog.ts`): a position a package SHIPS resolves its
// `permissionSets` from that package's closure, while a position authored
// at runtime is the environment's reference, resolved environment-wide. A
// change that made a runtime package's position resolve from its own closure
// would refuse the loose set and the other package's set; the first case
// below goes red on that.
//
// Controls: the position really is held under the new package (the catalog
// says so), the holder really holds it, and a set the position does NOT name
// is not granted.

import { describe, it, expect, beforeAll, afterAll } from 'vitest';
import { resolveUserAuthzGrants, securityCatalogReaderOf } from '@objectstack/core';
import { type VerifyStack } from '@objectstack/verify';
import { bootShowcase } from './showcase-boot.js';

/** Infrastructure rows, not tenant data: the store's own posture. */
const SYSTEM_CTX = { isSystem: true, positions: [], permissions: [] };

/** The new writable package the position is created into. */
const HOME = 'app.pickprobe-home';
/** A second writable package, holding a set of its own. */
const OTHER = 'app.pickprobe-other';

const POSITION = 'pkhome_reviewer';
/** A set saved into the position's own package, as the editor saves one. */
const OWN_SET = 'pkhome_reviewer_set';
/** A set the second runtime package holds. */
const OTHER_SET = 'pkother_shared_set';
/** A set the showcase (a code package) ships (`src/security`). */
const SHIPPED_SET = 'showcase_auditor';
/** A set saved through the environment scope: no package holds it. */
const LOOSE_SET = 'pickprobe_loose_set';
/** A loose set the position does not name: never granted to its holder. */
const UNNAMED_SET = 'pickprobe_unnamed_set';

const HOLDER_EMAIL = 'pick.probe.holder@example.com';

interface Engine {
find(object: string, options?: unknown): Promise<Array<Record<string, unknown>>>;
insert(object: string, data: Record<string, unknown>, options?: unknown): Promise<unknown>;
}

/** The organization a `single` session is active in (ADR-0131 D9). */
const sessionOrgOf = async (s: VerifyStack): Promise<string | undefined> =>
(await (await s.kernel.getServiceAsync<{ defaultOrgId(): Promise<string | null> }>('tenancy')).defaultOrgId()) ?? undefined;

describe('a position created into a writable package binds sets from outside it', () => {
let stack: VerifyStack;
let admin: string;
let ql: Engine;
let holder: string;

const call = async (method: string, path: string, body?: unknown) => {
const res = await stack.apiAs(admin, method, path, body);
const text = await res.text();
let json: any = {};
try { json = JSON.parse(text); } catch { /* not JSON */ }
return { status: res.status, json, text };
};
/** The console editor's create: the item's draft in the package, then its own publish. */
const createInPackage = async (type: string, name: string, body: Record<string, unknown>, pkg: string) => {
const draft = await call('PUT', `/meta/${type}/${name}?mode=draft&package=${encodeURIComponent(pkg)}`, body);
expect(draft.status, `draft ${type}/${name}: ${draft.text}`).toBe(200);
const live = await call('POST', `/meta/${type}/${name}/publish?package=${encodeURIComponent(pkg)}`, {});
expect(live.status, `publish ${type}/${name}: ${live.text}`).toBe(200);
};
/** The environment scope's create: a set written live, naming no package. */
const createLoose = async (name: string) => {
const saved = await call('PUT', `/meta/permission/${name}`, { name, label: name, objects: {} });
expect(saved.status, `loose permission/${name}: ${saved.text}`).toBe(200);
};

beforeAll(async () => {
stack = await bootShowcase();
admin = await stack.signIn();
ql = (await stack.kernel.getServiceAsync('objectql')) as unknown as Engine;

for (const [id, ns] of [[HOME, 'pkhome'], [OTHER, 'pkother']] as const) {
const created = await call('POST', '/packages', {
manifest: { id, name: `Pick probe ${ns}`, version: '0.1.0', type: 'app', namespace: ns },
});
expect(created.status, created.text).toBe(201);
}
await createInPackage('permission', OTHER_SET, { name: OTHER_SET, label: 'Other package set', objects: {} }, OTHER);
await createInPackage('permission', OWN_SET, { name: OWN_SET, label: 'Own package set', objects: {} }, HOME);
await createLoose(LOOSE_SET);
await createLoose(UNNAMED_SET);
await createInPackage('position', POSITION, {
name: POSITION,
label: 'Pick probe reviewer',
permissionSets: [OWN_SET, OTHER_SET, SHIPPED_SET, LOOSE_SET],
}, HOME);

await stack.signUp(HOLDER_EMAIL);
const [user] = await ql.find('sys_user', { where: { email: HOLDER_EMAIL }, limit: 1, context: SYSTEM_CTX });
expect(user?.id, `no sys_user row for ${HOLDER_EMAIL}`).toBeTruthy();
holder = String(user.id);
await ql.insert('sys_user_position', { id: 'usp_pick_probe', user_id: holder, position: POSITION }, { context: SYSTEM_CTX });
}, 180_000);

afterAll(async () => {
await stack?.stop();
});

it('the position is held under the new package, and the sets under theirs', async () => {
const reader = securityCatalogReaderOf(ql);
expect(reader, 'no security catalog bound to the booted engine').toBeTruthy();
const position = await reader!.resolve('position', POSITION);
expect(position?.packageId).toBe(HOME);
expect((position?.definition as { permissionSets?: string[] } | undefined)?.permissionSets)
.toEqual([OWN_SET, OTHER_SET, SHIPPED_SET, LOOSE_SET]);
expect((await reader!.resolve('permission', OTHER_SET))?.packageId).toBe(OTHER);
expect((await reader!.resolve('permission', OWN_SET))?.packageId).toBe(HOME);
expect((await reader!.resolve('permission', LOOSE_SET))?.packageId).toBeUndefined();
});

it('a holder is granted the own set, the other package\'s set, the shipped set and the loose set', async () => {
const grants = await resolveUserAuthzGrants(ql as never, holder, { tenantId: await sessionOrgOf(stack) });
expect(grants.positions).toContain(POSITION);
expect(grants.permissions).toEqual(expect.arrayContaining([OWN_SET, OTHER_SET, SHIPPED_SET, LOOSE_SET]));
});

// Setup's permission matrix mounts with no package and saves the set live,
// naming none (`PermissionMatrixEditPage` at the environment door). A set
// the ask put in a package must take that edit in its own row: one row of
// the name, still the package's, carrying the edit.
it('a live edit naming no package lands on the set the package holds', async () => {
const edited = await call('PUT', `/meta/permission/${OWN_SET}`, { name: OWN_SET, label: 'Own package set, edited', objects: {} });
expect(edited.status, edited.text).toBe(200);
const rows = await ql.find('sys_metadata', { where: { type: 'permission', name: OWN_SET }, context: SYSTEM_CTX });
const live = rows.filter((r) => r.state !== 'draft');
expect(live.map((r) => r.package_id ?? null), JSON.stringify(rows.map((r) => [r.package_id, r.state]))).toEqual([HOME]);
const reader = securityCatalogReaderOf(ql);
const set = await reader!.resolve('permission', OWN_SET);
expect(set?.packageId).toBe(HOME);
expect((set?.definition as { label?: string } | undefined)?.label).toBe('Own package set, edited');
});

it('control: a loose set the position does not name is not granted', async () => {
const grants = await resolveUserAuthzGrants(ql as never, holder, { tenantId: await sessionOrgOf(stack) });
expect(grants.permissions).not.toContain(UNNAMED_SET);
});
});
3 changes: 2 additions & 1 deletion ui/packages/app-shell/src/console/AppContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ const MetadataResourceHistoryPage = routeChunk.lazy(() => import('../views/metad
// App authoring + dashboard editor pages — sourced from
// @object-ui/plugin-designer so third-party hosts can opt out by not
// registering these routes.
const CreateAppPage = routeChunk.lazy(() => import('@object-ui/plugin-designer').then(m => m.CreateAppPage));
// objectstack#38149 — the console's wrapper saves the new app into a package the author picks or creates.
const CreateAppPage = routeChunk.lazy(() => import('./ConsoleCreateAppPage.js').then(m => m.ConsoleCreateAppPage));
const EditAppPage = routeChunk.lazy(() => import('@object-ui/plugin-designer').then(m => m.EditAppPage));
const DashboardDesignPage = routeChunk.lazy(() => import('@object-ui/plugin-designer').then(m => m.DashboardDesignPage));

Expand Down
46 changes: 46 additions & 0 deletions ui/packages/app-shell/src/console/ConsoleCreateAppPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.

/**
* objectstack#38149 — the console's create-app route (`/apps/:app/create-app`,
* reached from the no-apps call to action and from App Management): the
* plugin-designer wizard, whose new app is saved into a package the author
* picks or creates first (`PackageCreateAsk.tsx`), never naming none. The app
* is saved as Studio's new-app door saves it (`newAppDoor.ts`): a draft in
* that package under the first-write pin, then that one item's publish, so it
* opens at once. Cancel writes nothing and keeps the wizard open.
*/

import * as React from 'react';
import { CreateAppPage } from '@object-ui/plugin-designer';
import { usePackageCreateAsk } from '../views/metadata-admin/PackageCreateAsk.js';
import { translateMetadataType, useMetadataLocale } from '../views/metadata-admin/i18n.js';
import { useMetadataClient } from '../views/metadata-admin/useMetadata.js';
import { publishSavedItem } from '../views/studio-design/studioSaveBar.js';
import { draftReceiptVersion } from '../views/metadata-admin/DraftConflictDialog.js';

export function ConsoleCreateAppPage() {
const client = useMetadataClient();
const locale = useMetadataLocale();
const { ask, dialog } = usePackageCreateAsk();
const saveApp = React.useCallback(
async (name: string, app: Record<string, unknown>): Promise<boolean> => {
const packageId = await ask({ typeLabel: translateMetadataType('app', locale, 'App') });
if (!packageId) return false;
const receipt = await client.save('app', name, app, { mode: 'draft', packageId, ifNoneMatch: '*' });
const live = await publishSavedItem(
client,
{ type: 'app', name, packageId, draftVersion: draftReceiptVersion(receipt) },
false,
);
if (!live.ok) throw live.error;
return true;
},
[ask, client, locale],
);
return (
<>
<CreateAppPage saveApp={saveApp} />
{dialog}
</>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
*/

import '@testing-library/jest-dom/vitest';
// The source under test reaches a dynamic `@objectstack/lint` import; its first
// load is paid here, at collection (`check:test-source-alias`).
import '@objectstack/lint';
import { describe, it, expect, vi, beforeEach } from 'vitest';
import React from 'react';
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
Expand Down Expand Up @@ -93,6 +96,11 @@ vi.mock('@object-ui/plugin-designer', async (importOriginal) => ({
// identical to the component's own, so ESM hands the lazy factory this
// already-resolved module.
import '@object-ui/plugin-designer';
// objectstack#38149 — the route's lazy boundary is now the console's wrapper
// (`React.lazy(() => import('./ConsoleCreateAppPage.js'))`), whose own graph
// (the package ask, the Packages page's create dialog) was a second unbounded
// load inside the same `findByTestId` budget. Paid here too, for the same reason.
import '../ConsoleCreateAppPage';

vi.mock('@object-ui/i18n', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@ vi.mock('@object-ui/plugin-designer', async (importOriginal) => ({
// identical to the component's own, so ESM hands the lazy factory this
// already-resolved module.
import '@object-ui/plugin-designer';
// objectstack#38149 — the route's lazy boundary is now the console's wrapper
// (`React.lazy(() => import('./ConsoleCreateAppPage.js'))`), whose own graph
// (the package ask, the Packages page's create dialog) was a second unbounded
// load inside the same `findByTestId` budget. Paid here too, for the same reason.
import '../ConsoleCreateAppPage';

/**
* The probe that makes the bug visible: it reports WHICH app's shell rendered.
Expand Down
Loading
Loading