Skip to content

Commit 6eb23c8

Browse files
fix(cloud-connection): the install-local answer names the pending Everyone suggestion an isDefault set leaves (#38637)
<!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9St4eUWHFcCKuRUrCZPperJ)_ Fixes #38247 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:安装带默认权限集的应用后,安装结果和命令行输出会列出每条待接受的"全员授权建议",并说明去哪里接受;不再只说"应用已可用"。 - 为什么做:这是"安装后普通成员被拒"那张卡的提示半边,维护者已裁定按设计保留人工接受、只补提示。 - 出错会怎样:最坏是提示漏列或多列一条建议,不会替任何人授权;改动只增加提示,可直接撤回。 - 要你做什么:无 ## What changes - **Producer — `packages/cloud-connection`, the managed `POST /api/v1/marketplace/install-local` answer.** A new step 8, after every step that makes the version live, asks the security service's existing listing (`ISecurityService.listAudienceBindingSuggestions`, as the system, filtered to `status: 'pending'` and the package) and names each pending `everyone` row on a new key, `pendingSuggestions`, omitted when empty. Each element has the advisory shape of `advisories` (`rule: 'audience-binding-suggestion-pending'`, `severity`, `where`, `path`, `message`, `hint`) plus `suggestionId`, `packageId`, `permissionSet`, `anchor`. The `hint` says where to accept it: Grant on the package's Marketplace page, or `POST /api/v1/security/suggested-bindings/ID/confirm`. While a suggestion is pending, the `note` no longer says the app is available to everyone. - **Why this source (the dispatch's question a/b/c, answered with evidence):** route (b) through an existing service, with no timing dependence. The listing's contract is "Re-syncs before reading" (`packages/spec/src/contracts/security-service.ts`). It runs the same convergent `syncAudienceBindingSuggestions` that a boot, a package publish and every Setup list run, so the answer names a row only once it exists as `pending`. It never names one already accepted, dismissed or observed in the baseline, and it does not wait on the fire-and-forget `onMetadataMutation` listener. The door's own header (`announceHotInstall`) records that the security catalog serves an installed package's sets as soon as register resolves. The real-stack pin below measures that. Route (a), reading `isDefault` off the manifest, would claim suggestions the reconcile does not create (an accepted or baseline set), so it is used only as a pre-filter that decides whether to ask at all. No new kernel service, no new cross-plugin coupling: the door already reaches the security plugin through services (`security.accessUpgradeCheck`). - **Nothing is accepted.** ADR-0090 D5 stands ("It is never auto-bound"): the reconcile only records suggestions, and no acceptance verb is called (pinned). - **Composed artifacts:** rows are matched against the install's unit (`installedUnitPackageIds`, the ids the uninstall withdraws), so a member package's suggestion is named under its own `packageId`. - **Consumer — `packages/cli`, `os package install` (and `os deploy`, which runs it):** after the managed install summary, it prints one warning, one line per pending set with its package, and each element's `hint`. It prints from the answer only, and nothing when the key is absent. - Changeset: `.changeset/38247-install-pending-suggestion.md` (patch ×2). ## Tests - `packages/cloud-connection/src/marketplace-install-local-pending-suggestions-38247.test.ts` (new, 11 tests). These run at the real install seam, with a stub security service. An `isDefault` install names the pending row, with the id, the accept route and the changed note. The CONTROL install without one never asks and lists nothing. Accepted, baseline, dismissed, guest and other-package rows are not named. With no security service, or one without the listing, the key is omitted. A throwing listing omits the key, warns once with its cause, and still answers 200. No acceptance verb is called. - `packages/cli/test/package-install-pending-suggestions-38247.test.ts` (new, unit tier, 6 tests): printed for hot-loaded and not-hot-loaded answers; nothing printed for an absent or empty list. - Real-stack pin, added to the existing harness `packages/cli/test/package-install-local-sample-owner.integration.test.ts`, which already installs an `isDefault` set through `os start`. The install answer's `pendingSuggestions` names exactly the row that `GET /api/v1/security/suggested-bindings?status=pending&packageId=…` lists right after it, with the same id. This file is in the integration tier, which CI owns. It was run once locally as the measurement, and passed. <details><summary>Local readings (head fe3fc53)</summary> All readings are at head `fe3fc53bc`. Heavy runs went through `scripts/pm/os-verify-lock.sh`, so each figure is a VERDICT line. - `pnpm --filter @objectstack/cloud-connection exec vitest run --maxWorkers=2` → `Test Files 95 passed (95)`, `Tests 1370 passed (1370)`, VERDICT command-exit 0. - `pnpm --filter @objectstack/cli exec vitest run --project unit --maxWorkers=2` → `Test Files 2 failed | 448 passed (450)`. The two failures were `published-subpath-console.pin` and `published-subpath-hook-body.pin`, which refused with "packages/cli is not built". After `pnpm --filter @objectstack/cli build`, those two files gave `Test Files 2 passed (2)`, `Tests 29 passed (29)`. - `pnpm --filter @objectstack/cli exec vitest run --project integration --maxWorkers=2 test/package-install-local-sample-owner.integration.test.ts` → `Test Files 1 passed (1)`, `Tests 7 passed (7)`. This was run once locally as the measurement; CI owns this tier. - `pnpm --filter @objectstack/cloud-connection --filter @objectstack/cli typecheck` → VERDICT command-exit 0. The cloud-connection typecheck includes `tsconfig.test.json`. - Ablations, run through `scripts/ablation-replace.mjs`, each restored with blob == HEAD and an empty `git diff HEAD`: - Dropping the answer key turned the new cloud-connection file red: `1 failed | 10 passed (11)`. - Dropping the CLI print call turned the new CLI file red: `2 failed | 4 passed (6)`. - `node scripts/pm/dispatch-gates.mjs --ran` → `77 derived famil(ies) accounted for — 75 run, 2 NOT-MEASURED`, both exit 3 PREREQUISITE NOT MET: - `check-plugin-teardown-shape --self-test` needs an unshallowed clone. - `check:dual-build-cjs-loads` needs unbuilt dists. - CI runs both. The three i18n families first refused with "CLI not built" and were run again after the CLI build: exit 0. </details> ## Acceptance notes - New test files rather than a shared harness. Each install-local answer key has its own per-feature file (`-withheld-maps`, `-credential-refs`, …), and there is no shared harness file to join. The real-stack pin joined the existing integration harness. - The pre-filter (does the body declare an `isDefault: true` set, via `resolveStackCollection(converted, 'permissions')`) has one gap. On the lenient path (register failed, `hotLoaded: false`), a pending row of the previous version is not named when the new body declares no default. The note there already says that the package loads at the next restart. - An unmanaged install copies sets into the environment as env-authored. An unowned `isDefault` set is never suggested (ADR-0086 D3), so that answer gains nothing. This is unchanged behaviour, noted only. - A walled deployment whose host declares `acceptedDefaultPermissionSets` makes the listing throw (there is no record to accept in). The answer then names nothing, and the door warns once with the security plugin's own remedy sentence (add the set's name to that option). ## Verification Two-minute check: `pnpm --filter @objectstack/cloud-connection exec vitest run --maxWorkers=2 src/marketplace-install-local-pending-suggestions-38247.test.ts` → 11 passed. The first case shows `pendingSuggestions[0].suggestionId === 'sug_01pending'` and the confirm route in its `hint`. Read first, by risk: 1. `packages/cloud-connection/src/marketplace-install-local-plugin.ts`, `describePendingSuggestions`: the system-context listing call and its failure arm. 2. Same file, `pendingSuggestionsOf`: the row filter (pending, `everyone`, a package of this install's unit). 3. `packages/cli/src/commands/package/install.ts`, `printPendingSuggestions`. --- _Generated by [Claude Code](https://claude.ai/code/session_01ADHkmRar3Kkg6SpwVgaaVE)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01ADHkmRar3Kkg6SpwVgaaVE <!-- signed: repo:objectstack#3 · os-steve · session_01ADHkmRar3Kkg6SpwVgaaVE --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent e6634ce commit 6eb23c8

6 files changed

Lines changed: 562 additions & 2 deletions
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
'@objectstack/cloud-connection': patch
3+
'@objectstack/cli': patch
4+
---
5+
6+
fix(cloud-connection): the install-local answer names the pending Everyone suggestion an `isDefault` permission set leaves
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
A managed `POST /api/v1/marketplace/install-local` of a package declaring a permission set with `isDefault: true` answered "App is now available in this runtime" and said nothing about the set being only suggested for every signed-in member. Installing never accepts the suggestion (ADR-0090 D5), so until a `manage_metadata` holder does, a member without a grant of the set is refused on what it grants.
12+
13+
The answer now carries `pendingSuggestions`: one element per suggestion of the installed package (or of a member of the composed artifact it installed) that the deployment's record holds `pending` for the Everyone position. Each element has the advisory shape of `advisories` (`rule: 'audience-binding-suggestion-pending'`, `severity: 'warning'`, `where`, `path`, `message`, `hint`) plus `suggestionId`, `packageId`, `permissionSet` and `anchor`. The `hint` says where to accept it: Grant on the package's page in the console's Marketplace, or `POST /api/v1/security/suggested-bindings/:id/confirm`. The list is read through the security service's own suggestion listing, which reconciles the record before it reads, so an accepted, dismissed or baseline suggestion is never named. The install accepts nothing. The key is omitted when nothing is pending, when the body declares no `isDefault` set, and when the composition has no security service. A listing that throws is logged once at `warn` with its cause, and the install still succeeds. While a suggestion is pending, the answer's `note` says the app is available only to members holding one of its permission sets.
14+
15+
`os package install` (and so `os deploy`) prints each pending set with its package and the `hint`, after the install summary. An answer without the list prints nothing new.

‎packages/cli/src/commands/package/install.ts‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,35 @@ function printWithheldMaps(withheldMaps: unknown): void {
139139
console.log(' Re-enter each map where the connector is authored.');
140140
}
141141

142+
/**
143+
* [ADR-0090 D5] The package's `isDefault` permission sets the `everyone`
144+
* position still waits on, as the managed install-local answer names them
145+
* (`pendingSuggestions`): one warning, one line per suggestion — the set and
146+
* the suggesting package — then where it is accepted, each element's own
147+
* `hint` verbatim. Installing never accepts a suggestion, so until a
148+
* `manage_metadata` holder does, a member without a grant of the set is
149+
* refused on what it grants; the operator who installed is told here.
150+
*
151+
* Printed from the answer only: an answer without the list (nothing pending,
152+
* or a runtime that predates the key) prints nothing, and nothing is guessed
153+
* from the artifact the command sent.
154+
*/
155+
function printPendingSuggestions(pendingSuggestions: unknown): void {
156+
const pending: Array<{ permissionSet?: unknown; packageId?: unknown; hint?: unknown }> =
157+
Array.isArray(pendingSuggestions) ? pendingSuggestions : [];
158+
if (pending.length === 0) return;
159+
console.log('');
160+
printWarning(
161+
`${pending.length} permission set(s) are suggested for every signed-in member (the Everyone position) and NOT `
162+
+ 'accepted: installing never accepts one. Until each is accepted, a member without a grant of the set is refused:',
163+
);
164+
for (const entry of pending) {
165+
const from = typeof entry.packageId === 'string' ? ` (suggested by ${entry.packageId})` : '';
166+
console.log(` ${String(entry.permissionSet)}${from}`);
167+
if (typeof entry.hint === 'string' && entry.hint.trim()) console.log(` ${entry.hint.trim()}`);
168+
}
169+
}
170+
142171
export default class PackageInstall extends Command {
143172
static override description =
144173
'Install a package into a running ObjectStack runtime (catalog id or local artifact file)';
@@ -634,6 +663,7 @@ export default class PackageInstall extends Command {
634663
if (data.installedAt) printKV(' Installed', String(data.installedAt));
635664
if (notHotLoaded && hotLoadError) printKV(' Hot-load error', hotLoadError);
636665
printWithheldMaps(data.withheldMaps);
666+
printPendingSuggestions(data.pendingSuggestions);
637667
console.log('');
638668
// #6721: the cache directory is quoted from the RESPONSE, never from a
639669
// literal or a locally-resolved constant. The directory lives on the

‎packages/cli/test/package-install-local-sample-owner.integration.test.ts‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@ const byName = (rows: OwnedRow[]) => [...rows].sort((x, y) => x.name.localeCompa
242242
/** What both boots recorded, phase by phase; the `it`s read it. */
243243
interface Recorded {
244244
install?: Answer;
245+
/** The administrator's Setup listing of the package's pending suggestions, read right after the install. */
246+
pendingListed?: Answer;
245247
admin?: Session;
246248
installedDeals?: OwnedRow[];
247249
installedNotes?: OwnedRow[];
@@ -279,6 +281,7 @@ beforeAll(async () => {
279281
const admin = await signIn(a, ADMIN);
280282
rec.admin = admin;
281283
rec.install = await http(a, 'POST', ROUTE, admin.token, { manifest: ARTIFACT });
284+
rec.pendingListed = await http(a, 'GET', `/api/v1/security/suggested-bindings?status=pending&packageId=${APP_ID}`, admin.token);
282285
rec.installedDeals = byName(owned(await http(a, 'GET', `/api/v1/data/${DEAL}`, admin.token)));
283286
rec.installedNotes = owned(await http(a, 'GET', `/api/v1/data/${NOTE}`, admin.token));
284287

@@ -401,3 +404,23 @@ describe('#30324: an installed package\'s sample rows are owned by the person wh
401404
}
402405
});
403406
});
407+
408+
describe('ADR-0090 D5: the install answer names the pending Everyone suggestion its isDefault set leaves', () => {
409+
it('`pendingSuggestions` names the set and the very row Setup lists as pending, with its accept route', () => {
410+
expect(rec.install?.status, JSON.stringify(rec.install?.body)).toBe(200);
411+
expect(rec.pendingListed?.status, JSON.stringify(rec.pendingListed?.body)).toBe(200);
412+
const listed: any[] = rec.pendingListed?.body?.data?.suggestions ?? [];
413+
const row = listed.find((r) => r.permission_set_name === SET && r.anchor === 'everyone');
414+
expect(row, JSON.stringify(listed)).toMatchObject({ package_id: APP_ID, status: 'pending' });
415+
const named: any[] = rec.install?.body?.data?.pendingSuggestions ?? [];
416+
expect(named, JSON.stringify(rec.install?.body?.data)).toHaveLength(1);
417+
expect(named[0]).toMatchObject({
418+
rule: 'audience-binding-suggestion-pending',
419+
suggestionId: row.id,
420+
packageId: APP_ID,
421+
permissionSet: SET,
422+
anchor: 'everyone',
423+
});
424+
expect(named[0].hint).toContain(`/api/v1/security/suggested-bindings/${row.id}/confirm`);
425+
});
426+
});
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* [ADR-0090 D5] `os package install` prints the pending Everyone suggestions
5+
* the managed install-local answer names (`pendingSuggestions`).
6+
*
7+
* A package declaring an `isDefault: true` permission set only SUGGESTS it for
8+
* every signed-in member; installing never accepts it, so until a
9+
* `manage_metadata` holder does, a member without a grant of the set is
10+
* refused on what it grants. Before this change the command printed
11+
* "Package installed into the running kernel" and nothing else about it.
12+
*
13+
* Pinned, for a managed install (hot-loaded and not):
14+
* - an answer carrying the list prints one warning, one line per set with
15+
* its suggesting package, and each element's `hint` (where to accept it);
16+
* - an answer without the list (absent or empty) prints none of those lines;
17+
* - the install still succeeds — the warning changes no exit code.
18+
*/
19+
20+
import { describe, it, expect, afterEach, vi } from 'vitest';
21+
import PackageInstall from '../src/commands/package/install.js';
22+
23+
/** Stub the runtime's install POST with the given `data` block. */
24+
function stubRuntime(data: Record<string, unknown>): void {
25+
vi.stubGlobal('fetch', vi.fn(async () => ({
26+
ok: true,
27+
status: 200,
28+
statusText: 'OK',
29+
headers: { get: () => null },
30+
json: async () => ({ success: true, data }),
31+
}) as any));
32+
}
33+
34+
/** Run the command; return everything it printed and how it exited. */
35+
async function runInstall(args: string[]): Promise<{ out: string; exit: number | undefined }> {
36+
const lines: string[] = [];
37+
const capture = (...a: unknown[]) => { lines.push(a.map(String).join(' ')); };
38+
vi.spyOn(console, 'log').mockImplementation(capture);
39+
vi.spyOn(console, 'error').mockImplementation(capture);
40+
let exit: number | undefined;
41+
try {
42+
await PackageInstall.run([...args, '--url', 'http://runtime.test']);
43+
} catch (err: any) {
44+
exit = err?.oclif?.exit ?? err?.code ?? 1;
45+
}
46+
return { out: lines.join('\n'), exit };
47+
}
48+
49+
const HINT = 'A manage_metadata holder accepts it once for the whole deployment: '
50+
+ 'POST /api/v1/security/suggested-bindings/sug_01pending/confirm.';
51+
52+
/** The list as install-local answers it. */
53+
const PENDING = [{
54+
rule: 'audience-binding-suggestion-pending',
55+
severity: 'warning',
56+
where: 'permission set "helpdesk_agent" · position "everyone"',
57+
path: 'permissions.helpdesk_agent',
58+
message: "The package 'com.example.helpdesk' suggests granting the permission set 'helpdesk_agent' …",
59+
hint: HINT,
60+
suggestionId: 'sug_01pending',
61+
packageId: 'com.example.helpdesk',
62+
permissionSet: 'helpdesk_agent',
63+
anchor: 'everyone',
64+
}];
65+
66+
const MANAGED = {
67+
manifestId: 'com.example.helpdesk', version: '1.0.0', versionId: 'ver_1', installedAt: '2026-11-29T00:00:00.000Z',
68+
hotLoaded: true, storageDir: '/srv/runtime/.objectstack/installed-packages',
69+
};
70+
const MANAGED_NOT_HOT = { ...MANAGED, hotLoaded: false, hotLoadError: 'register threw' };
71+
72+
const WARNING = /1 permission set\(s\) are suggested for every signed-in member \(the Everyone position\) and NOT accepted/;
73+
74+
describe('os package install — prints the pending Everyone suggestions the install left', () => {
75+
afterEach(() => {
76+
vi.unstubAllGlobals();
77+
vi.restoreAllMocks();
78+
});
79+
80+
describe.each([
81+
['managed, hot-loaded', MANAGED],
82+
['managed, not hot-loaded', MANAGED_NOT_HOT],
83+
] as const)('%s', (_label, data) => {
84+
it('names each pending set with its package, then where to accept it', async () => {
85+
stubRuntime({ ...data, pendingSuggestions: PENDING });
86+
87+
const { out, exit } = await runInstall(['com.example.helpdesk']);
88+
89+
expect(exit).toBeUndefined();
90+
expect(out).toMatch(WARNING);
91+
const lines = out.split('\n').map((line) => line.trim());
92+
expect(lines).toContain('helpdesk_agent (suggested by com.example.helpdesk)');
93+
expect(lines).toContain(HINT);
94+
});
95+
96+
it.each([
97+
['absent', undefined],
98+
['empty', []],
99+
])('prints no suggestion line when the answer\'s list is %s', async (_which, list) => {
100+
stubRuntime({ ...data, ...(list === undefined ? {} : { pendingSuggestions: list }) });
101+
102+
const { out, exit } = await runInstall(['com.example.helpdesk']);
103+
104+
expect(exit).toBeUndefined();
105+
expect(out).not.toContain('suggested for every signed-in member');
106+
expect(out).not.toContain('suggested-bindings');
107+
});
108+
});
109+
});

0 commit comments

Comments
 (0)