Skip to content

Commit 4f20614

Browse files
fix(plugin-security): the boot report names a refused grant's candidates and the bind; a refused suggestion's fix follows its column (#33930)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} --> _Requested by **Steedos** · [project thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbTGhxJSYAmQXU7efVdNqrpw)_ Fixes #32753 Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:启动时的目录引用报告现在把「两个包都持有同名权限集、而授权未指明包」的授权列为被拒绝,并列出全部候选包与 `os migrate stored-references bind` 修复;受众绑定建议在包列已有值时不再给出不适用的 bind 提示。 - 为什么改:原报告把这类授权当作「目录解析不到」,建议「重新声明权限集」,而这改变不了什么;建议的拒绝文案给出的 bind 命令对非空包列直接拒绝。 - 风险与回滚:只改日志与拒绝文案,没有授权因此多给或少给;回滚即还原两个源文件。 - 先看:`catalog-reference-report.ts` 的授权循环与授权行日志;`suggested-audience-bindings.ts` 的 `refusedSuggestionFix`;`catalog-reference-report.test.ts` 末尾新 describe。 - 两分钟验证:`pnpm --filter @objectstack/plugin-security exec vitest run src/catalog-reference-report.test.ts -t "name two packages hold"`,预期 4 passed。 - 需要你做的:无,席位落地。 ## What changes - **Boot report, permission-set half** (`catalog-reference-report.ts`). A grant whose name the catalog holds but refuses for the grant (a grant naming no package, of a name two packages hold: `ambiguous-in-environment`) is still listed on the grant line, now with the resolver's refusal: `refusal` on the row (`packageId` = the column, `reason`, every candidate, the resolver's sentence), and `refusals` in that organization's meta. The line's fix, appended only when a refusal is listed, follows the column: a refused grant naming no package is bound after review with `os migrate stored-references bind --table sys_user_permission_set --id ID --package PACKAGE`; one that already names a package is granted again naming the candidate meant, then removed. A name nothing holds keeps the old line byte for byte. - **Boot report, position half**: unchanged code; now pinned for the two-holder case (`ambiguous-in-environment`, both candidates named). - **Suggestion refusal** (`suggested-audience-bindings.ts`, `resolveSuggestedSet`). The refused suggestion's fix follows its `permission_set_package`: a column naming no package keeps the bind; a column that already names a package (one that no longer serves the set) names that package and says the bind does not apply (it writes only a null column), then gives the fix that does: install or enable that package again if its set is the one meant, or dismiss the suggestion. No refusal code or status changes: the `409` and `SuggestionStateError` are as before. ## Tests - `catalog-reference-report.test.ts`: new describe, four cases: position half (both holders), permission-set half (bare grant with both candidates, stale-column grant with its column, a ghost set with no refusal), the logged line (meta refusals plus both fix sentences), and a CONTROL that a line with no refusal names neither fix. - `suggested-audience-bindings.test.ts`: one case in the existing package-scoped harness: two non-null-column refusals carry no bind and name their package and fix; an accepted row's withheld reason says the same. The existing null-column pin (bind named with the row id) is unchanged and green. ## Acceptance notes - The card's item 2 says "grant"; the only refusal that appends the bind for a stale column is a suggestion's (`resolveSuggestedSet`), which has no re-grant or delete door (the table is read-only through the API). Its fix therefore names the two acts that exist: serve the set from the column's package again, or dismiss. - `os doctor` does not read this report (no reference to it under `packages/cli/src/commands/doctor.ts`). Surfacing it there is a cli change, left out of this PR. ## Verification Measured at 843e83d (objectstack-ai/objectstack). The head, 1a99d2a, adds only a merge of origin/main, which touches no file under packages/plugins/plugin-security or packages/core. - `pnpm --filter @objectstack/plugin-security typecheck`: exit 0. `pnpm --filter @objectstack/plugin-security test`: 267 files passed, 6686 passed, 45 skipped. - eslint `--no-inline-config` on the four touched source and test files: exit 0. - Ablations (each through `scripts/ablation-replace.mjs`, restored to blob == HEAD, `git diff HEAD` empty): (1) the grant row's refusal not attached: 2 red (the permission-set half and the logged line); (2) the suggestion fix always given the null-column branch, the old text: 1 red (the new suggestion pin); (3) the position refusal not recorded: 1 red (the position half). - Derived gate families: `node scripts/pm/dispatch-gates.mjs --commands` derived 71 families at 843e83d; 68 exit 0. NOT MEASURED, each left to CI: `check:dual-build-cjs-loads` and `check:i18n` (exit 3, PREREQUISITE NOT MET: whole-workspace build absent), `check:type-check-debt` (verify-lock queue, exit 99, then the 10-minute foreground cap on retry). `--ran` reconciliation: 71 accounted, 0 UNRUN. `check-partof-closing-keyword` on this body: exit 0. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01QsR2jTEivi2wogPpeo3xd5 --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent a8261ce commit 4f20614

5 files changed

Lines changed: 247 additions & 9 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@objectstack/plugin-security': patch
3+
---
4+
5+
fix(plugin-security): the catalog reference boot report names a refused grant's candidates and the reviewed bind, and a refused audience-binding suggestion's fix follows its package column
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
The catalog reference boot report listed a grant naming no package, of a permission-set name two packages hold, as a grant naming a set the catalog does not resolve, with no candidates and the fix "declare the permission set again", which changes nothing. Such a grant is now listed on the same line with the resolver's refusal (`refusals` in the line's meta: the grant, the package its column names, the reason and every candidate), and the line's fix names `os migrate stored-references bind --table sys_user_permission_set --id ID --package PACKAGE` for a refused grant naming no package, and, for one that already names a package, to grant the candidate meant again naming its package and then remove the listed grant. The position half of the report already named its refusals and candidates.
11+
12+
A suggestion refused for a `permission_set_package` column that already names a package (a package that no longer serves the set) no longer offers `os migrate stored-references bind`, which writes only a column naming no package. Its refusal now names the package and the fix that applies: install or enable that package again if its set is the one meant, or dismiss the suggestion. A suggestion whose column names no package keeps the bind.
13+
14+
No grant or suggestion confers more or less: only the report's lines and the refusal's text move.

‎packages/plugins/plugin-security/src/catalog-reference-report.test.ts‎

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,3 +822,116 @@ describe('[ADR-0150 D2/D8, #31698] the report lists each stale-column grant whos
822822
});
823823
});
824824
});
825+
826+
/**
827+
* [ADR-0150 D3] A name two packages hold is held, not missing: a grant naming
828+
* no package of it, and a position of no package binding it, are each refused
829+
* with every candidate named. Both halves of the report name that refusal and
830+
* the fix it allows — for a grant, the reviewed bind when its column names no
831+
* package, never "declare the set again".
832+
*/
833+
describe('[ADR-0150 D3] a name two packages hold: both halves of the report name the refusal and every candidate', () => {
834+
const CRM = 'com.acme.crm';
835+
const HR = 'com.acme.hr';
836+
/** Of HR's namespace, holding no set: a stale column. */
837+
const HR_OLD = 'com.acme.hr-old';
838+
const HR_TWO = 'com.acme.hr-two';
839+
const NAMESPACES: Record<string, string> = { [CRM]: 'crm', [HR]: 'hr', [HR_OLD]: 'hr', [HR_TWO]: 'hr' };
840+
/** `shared` held by CRM and HR; `twin` by HR and HR_TWO, one namespace. */
841+
const HOLDERS: Record<string, string[]> = { shared: [CRM, HR], twin: [HR, HR_TWO] };
842+
const set = (name: string, packageId: string) => ({ name, _packageId: packageId, systemPermissions: [`cap_${name}`] });
843+
const position = { name: 'env_lead', label: 'Lead', permissionSets: ['shared'] };
844+
const catalog = createSecurityCatalogReader({
845+
registry: {
846+
getItem: () => undefined,
847+
listItems: (type: string) => (type === 'permission'
848+
? Object.entries(HOLDERS).flatMap(([name, ids]) => ids.map((id) => set(name, id)))
849+
: []),
850+
isPackageDisabled: () => false,
851+
packageScopedHoldersOf: (type: string, name: string) => (type === 'permission' ? HOLDERS[name] ?? [] : []),
852+
getPackageScopedItem: (type: string, name: string, packageId: string) =>
853+
type === 'permission' && (HOLDERS[name] ?? []).includes(packageId) ? set(name, packageId) : undefined,
854+
getEnvironmentScopedItem: () => undefined,
855+
getArtifactItem: () => undefined,
856+
getPackage: (id: string) => (NAMESPACES[id] ? { manifest: { id, namespace: NAMESPACES[id] } } : undefined),
857+
getAllPackages: () => [],
858+
} as any,
859+
metadata: {
860+
get: (type: string, name: string) => (type === 'position' && name === position.name ? position : undefined),
861+
list: (type: string) => (type === 'position' ? [position] : []),
862+
},
863+
});
864+
const grant = (id: string, set: string, column: string | null) =>
865+
({ id, user_id: 'usr_a', permission_set: set, permission_set_package: column, organization_id: ORG });
866+
const rows = [
867+
grant('g_bare', 'shared', null),
868+
grant('g_stale', 'twin', HR_OLD),
869+
// CONTROL: the column names a holder, so the grant resolves.
870+
grant('g_crm', 'shared', CRM),
871+
// CONTROL: a set nothing holds is listed with no refusal.
872+
grant('g_ghost', 'ghost', null),
873+
];
874+
const engine: CatalogReferenceReportEngine = {
875+
getObject: () => ({}),
876+
find: async (object, options: any) =>
877+
object === 'sys_user_permission_set' ? rows.slice(options.offset ?? 0, (options.offset ?? 0) + options.limit) : [],
878+
};
879+
880+
it('the position half lists the position with the refusal naming both holders', async () => {
881+
const report = await collectCatalogReferences(engine, { catalog });
882+
expect(report.positions).toEqual([{
883+
position: position.name,
884+
packageId: null,
885+
permissionSets: ['shared'],
886+
refusals: [{
887+
permissionSet: 'shared',
888+
reason: 'ambiguous-in-environment',
889+
candidates: [expect.stringContaining(CRM), expect.stringContaining(HR)],
890+
message: expect.stringContaining(CRM),
891+
}],
892+
}]);
893+
});
894+
895+
it('the permission-set half lists each refused grant with the refusal naming every candidate, and the column it names', async () => {
896+
const report = await collectCatalogReferences(engine, { catalog });
897+
const grants = report.organizations.flatMap((o) => o.permissionSetGrants);
898+
expect(grants.map((g) => g.id)).toEqual(['g_bare', 'g_stale', 'g_ghost']);
899+
expect(grants[0].refusal).toEqual({
900+
packageId: null,
901+
reason: 'ambiguous-in-environment',
902+
candidates: [expect.stringContaining(CRM), expect.stringContaining(HR)],
903+
message: expect.stringContaining(HR),
904+
});
905+
expect(grants[1].refusal).toMatchObject({
906+
packageId: HR_OLD,
907+
candidates: [expect.stringContaining(HR), expect.stringContaining(HR_TWO)],
908+
});
909+
expect(grants[2].refusal).toBeUndefined();
910+
});
911+
912+
it('logs the refusals in the grant line, and its fix names the bind for a grant naming no package and the re-grant for one naming a package', async () => {
913+
const logger = { info: vi.fn(), warn: vi.fn(), error: vi.fn() };
914+
await reportCatalogReferences(engine, { catalog, logger });
915+
const lines = logger.error.mock.calls.filter(([, , meta]: any[]) => meta?.organizations?.items?.[0]?.grants);
916+
expect(lines).toHaveLength(1);
917+
const [line, , meta] = lines[0];
918+
expect(meta.organizations.items[0].refusals.items.map((r: any) => [r.id, r.packageId, r.candidates.length]))
919+
.toEqual([['g_bare', null, 2], ['g_stale', HR_OLD, 2]]);
920+
expect(String(line)).toContain('os migrate stored-references bind --table sys_user_permission_set --id ID --package PACKAGE');
921+
expect(String(line)).toContain('grant the candidate meant again naming its package, then remove the listed grant');
922+
});
923+
924+
it('CONTROL: a grant line with no refusal names neither the bind nor the re-grant', async () => {
925+
const logger = { info: vi.fn(), warn: vi.fn(), error: vi.fn() };
926+
const ghostOnly: CatalogReferenceReportEngine = {
927+
getObject: () => ({}),
928+
find: async (object) => (object === 'sys_user_permission_set' ? [grant('g_ghost', 'ghost', null)] : []),
929+
};
930+
await reportCatalogReferences(ghostOnly, { catalog, logger });
931+
const lines = logger.error.mock.calls.filter(([, , meta]: any[]) => meta?.organizations?.items?.[0]?.grants);
932+
expect(lines).toHaveLength(1);
933+
expect(lines[0][2].organizations.items[0].refusals).toBeUndefined();
934+
expect(String(lines[0][0])).not.toContain('stored-references bind');
935+
expect(String(lines[0][0])).not.toContain('refusals');
936+
});
937+
});

‎packages/plugins/plugin-security/src/catalog-reference-report.ts‎

Lines changed: 82 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@
1818
* 1. **Assignments naming no position** — `sys_user_position` rows whose
1919
* `position` the catalog does not resolve.
2020
* 2. **Grants naming no permission set** — `sys_user_permission_set` rows
21-
* whose `permission_set` the catalog does not resolve.
21+
* whose `permission_set` the catalog does not resolve. [ADR-0150 D3] A name
22+
* the catalog holds but refuses for the grant — a grant naming no package,
23+
* of a name two packages hold, is the usual one — is listed here with the
24+
* resolver's refusal naming every candidate, and the fix follows the
25+
* grant's package column: one that names no package is bound after review
26+
* (`os migrate stored-references bind`), one that names a package already
27+
* is granted again naming the package meant, then removed.
2228
* 3. **Grants that name nothing** — `sys_user_permission_set` rows whose
2329
* `permission_set` is empty. The v18 ceremony's verified rewrite names
2430
* every grant it can before the legacy id column is dropped, and blocks on
@@ -103,7 +109,7 @@ import {
103109
type SecurityCatalogType,
104110
} from '@objectstack/core';
105111
import { GRANT_OBJECT, GRANT_SET_NAME_FIELD } from './grant-permission-set-name.js';
106-
import { PERMISSION_SET_PACKAGE_COLUMN } from './stored-permission-set-package-backfill.js';
112+
import { bindCommandFor, PERMISSION_SET_PACKAGE_COLUMN } from './stored-permission-set-package-backfill.js';
107113

108114
/** The user ↔ position assignment object (ADR-0057 D4). */
109115
export const POSITION_ASSIGNMENT_OBJECT = 'sys_user_position';
@@ -143,6 +149,23 @@ export interface UnresolvedReference {
143149
userId: string | null;
144150
/** The name the row carries. */
145151
name: string;
152+
/**
153+
* [ADR-0150 D3] A grant's name the catalog holds but refuses for the grant,
154+
* with every candidate — absent when nothing holds the name.
155+
*/
156+
refusal?: GrantRefusal;
157+
}
158+
159+
/** [ADR-0150 D3] Why the catalog refuses a grant's name: every candidate named, none picked. */
160+
export interface GrantRefusal {
161+
/** The package the grant's column names, or `null` for a grant naming none — the bind applies only to `null`. */
162+
packageId: string | null;
163+
/** The resolver's reason (`ambiguous-in-environment` for a grant naming no package). */
164+
reason: string;
165+
/** Every candidate holder, described. */
166+
candidates: string[];
167+
/** The resolver's sentence. */
168+
message: string;
146169
}
147170

148171
/** One grant that names no permission set. */
@@ -376,6 +399,34 @@ function staleColumnHolderOutsideNamespace(
376399
};
377400
}
378401

402+
/**
403+
* [ADR-0150 D3] The catalog's refusal of a stored grant's name, read in the
404+
* grant's own scope (`storedPermissionSetScope`), or `undefined` when the
405+
* catalog does not refuse it (a name nothing holds, or a reader that cannot
406+
* tell a refusal from a miss). Each (name, column) is asked once.
407+
*/
408+
function grantRefusal(
409+
catalog: SecurityCatalogReader,
410+
): (name: string, packageColumn: unknown) => Promise<GrantRefusal | undefined> {
411+
const memo = new Map<string, GrantRefusal | undefined>();
412+
return async (name, packageColumn) => {
413+
const scope = storedPermissionSetScope(packageColumn);
414+
const key = `${name}\u0000${scope?.packageId ?? ''}`;
415+
if (memo.has(key)) return memo.get(key);
416+
let answer: Awaited<ReturnType<typeof resolveCatalogReference>>;
417+
try {
418+
answer = await resolveCatalogReference(catalog, 'permission', name, scope);
419+
} catch (e) {
420+
throw new ReportStop('catalog-unreadable', 'the security catalog', e);
421+
}
422+
const refusal = answer.status === 'refused'
423+
? { packageId: scope?.packageId ?? null, reason: answer.reason, candidates: [...answer.candidates], message: answer.message }
424+
: undefined;
425+
memo.set(key, refusal);
426+
return refusal;
427+
};
428+
}
429+
379430
/**
380431
* Read the stored references and the catalog, and return what resolves
381432
* nowhere. Logs nothing; {@link reportCatalogReferences} is the boot entry.
@@ -416,6 +467,7 @@ export async function collectCatalogReferences(
416467
};
417468
const resolves = catalogResolver(deps.catalog);
418469
const outsideNamespaceHolder = staleColumnHolderOutsideNamespace(deps.catalog);
470+
const refusalOf = grantRefusal(deps.catalog);
419471

420472
try {
421473
if (readAssignments) {
@@ -464,8 +516,13 @@ export async function collectCatalogReferences(
464516
});
465517
continue;
466518
}
519+
// [ADR-0150 D3] A name the catalog holds but refuses for this grant
520+
// (two holders, none named) carries the refusal: declaring the set
521+
// again would change nothing.
522+
const refusal = await refusalOf(name, row[PERMISSION_SET_PACKAGE_COLUMN]);
467523
bucket(organizationOf(row)).permissionSetGrants.push({
468524
id: String(row.id), userId: stringOrNull(row.user_id), name,
525+
...(refusal ? { refusal } : {}),
469526
});
470527
continue;
471528
}
@@ -586,16 +643,35 @@ function logReport(report: CatalogReferenceReport, logger?: CatalogReferenceRepo
586643
);
587644
}
588645

589-
const grants = perOrganization(report, (o) => o.permissionSetGrants, (items) => ({
590-
permissionSets: nameCounts(items), grants: listed(items.map((i) => i.id)),
591-
}));
646+
const refused = report.organizations.flatMap((o) => o.permissionSetGrants).flatMap((i) => (i.refusal ? [i.refusal] : []));
647+
const grants = perOrganization(report, (o) => o.permissionSetGrants, (items) => {
648+
const refusals = items.flatMap((i) => (i.refusal ? [{ id: i.id, userId: i.userId, permissionSet: i.name, ...i.refusal }] : []));
649+
return {
650+
permissionSets: nameCounts(items),
651+
grants: listed(items.map((i) => i.id)),
652+
...(refusals.length > 0 ? { refusals: listed(refusals) } : {}),
653+
};
654+
});
592655
if (grants.count > 0) {
593656
logError(
594657
logger,
595658
`[security] ${grants.count} ${GRANT_OBJECT} grant(s) name a permission set the security catalog does not ` +
596659
'resolve at this boot (ADR-0131 D4), so each confers nothing, while Setup still lists it. Nothing was ' +
597660
'changed. Fix: declare the permission set again (its package, or its environment definition), or remove ' +
598-
'the grants.',
661+
'the grants.' +
662+
(refused.length > 0
663+
? ' A grant listed under refusals names a set that is held, but the catalog refuses the reading the grant ' +
664+
'asks for — more than one holder, and none named (ADR-0150 D3) — so declaring it again changes nothing: ' +
665+
'each refusal names every candidate, and nothing picks one.'
666+
: '') +
667+
(refused.some((r) => r.packageId === null)
668+
? ' Bind a refused grant that names no package to the candidate meant, after review: ' +
669+
`${bindCommandFor(GRANT_OBJECT)}.`
670+
: '') +
671+
(refused.some((r) => r.packageId !== null)
672+
? ' A refused grant that already names a package is not bound (the bind writes only a grant naming none): ' +
673+
'grant the candidate meant again naming its package, then remove the listed grant.'
674+
: ''),
599675
{ count: grants.count, organizations: grants.organizations },
600676
);
601677
}

‎packages/plugins/plugin-security/src/suggested-audience-bindings.test.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,25 @@ describe('[ADR-0150 D8 R3] a suggestion reads its set by its package column', ()
11631163
expect(rows(ql).map((r: any) => r.status)).toEqual(['pending', 'pending']);
11641164
});
11651165

1166+
it('⛔ a refused row whose column already names a package never offers the bind (it writes only a null column): the fix follows the column', async () => {
1167+
const ql = scopedQl();
1168+
rows(ql).push(row('s_stale', SUITE, 'com.example.gone'), row('s_other_column', HR, OPS));
1169+
for (const [id, column] of [['s_stale', 'com.example.gone'], ['s_other_column', OPS]] as const) {
1170+
const err = await confirmAudienceBindingSuggestion(makeDeps(ql), ADMIN_CTX, id).catch((e) => e);
1171+
expect(err, id).toBeInstanceOf(SuggestionStateError);
1172+
expect(err.message, id).not.toContain('--table sys_audience_binding_suggestion');
1173+
expect(err.message, id).toContain(`already names package "${column}"`);
1174+
expect(err.message, id).toContain(`enable "${column}" again if its set is the one meant, or dismiss the suggestion`);
1175+
}
1176+
// The withheld reason of an accepted row is the same sentence.
1177+
rows(ql).push(row('a_stale', SUITE, 'com.example.gone', 'confirmed'));
1178+
const derived = await readAcceptedEveryoneSets(ql);
1179+
expect(derived.withheld).toEqual([
1180+
expect.objectContaining({ packageId: SUITE, reason: expect.stringContaining('already names package "com.example.gone"') }),
1181+
]);
1182+
expect(derived.withheld[0].reason).not.toContain('--id a_stale');
1183+
});
1184+
11661185
it('the derivation reads an accepted row by its column, and withholds a refused one with every candidate', async () => {
11671186
const ql = scopedQl();
11681187
rows(ql).push(row('a_crm', CRM, CRM, 'confirmed'), row('a_suite', SUITE, null, 'confirmed'));

‎packages/plugins/plugin-security/src/suggested-audience-bindings.ts‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,10 @@ async function recordRow(ql: any, organizationId: string, id: string): Promise<a
999999
* `permission_set_package` names, else the suggesting package (`package_id`)
10001000
* as the D3 caller, else — a host-declared name, no row — a caller with no
10011001
* package. A name the rule refuses answers no entry and the refusal's own
1002-
* sentence, which names every candidate, plus the operator's bind.
1002+
* sentence, which names every candidate, plus the fix the row's column
1003+
* allows: the operator's bind for a column naming no package — the only
1004+
* column the bind writes — and, for one that names a package already, the
1005+
* package named or the dismissal.
10031006
*/
10041007
async function resolveSuggestedSet(
10051008
reader: SecurityCatalogReader | undefined,
@@ -1011,12 +1014,25 @@ async function resolveSuggestedSet(
10111014
const answer = await resolveCatalogReference(reader, 'permission', name, scope);
10121015
if (answer.status === 'resolved') return { entry: answer.entry };
10131016
if (answer.status === 'refused') {
1014-
const bind = row ? ` Review it and bind one: \`${bindCommandFor(SUGGESTION_OBJECT, row.id)}\`.` : '';
1015-
return { refusal: `${answer.message}${bind}` };
1017+
return { refusal: `${answer.message}${row ? refusedSuggestionFix(row, scope?.packageId) : ''}` };
10161018
}
10171019
return {};
10181020
}
10191021

1022+
/**
1023+
* [ADR-0150 D10] The fix a refused suggestion's sentence ends with, following
1024+
* its package column: a column naming no package is bound after review; the
1025+
* bind writes no other column, so one that names a package already — a
1026+
* package that no longer serves the set, or the read would not be refused — is
1027+
* served again by that package, or the suggestion is dismissed.
1028+
*/
1029+
function refusedSuggestionFix(row: Record<string, unknown>, column: string | undefined): string {
1030+
if (column === undefined) return ` Review it and bind one: \`${bindCommandFor(SUGGESTION_OBJECT, row.id)}\`.`;
1031+
return ` Its permission_set_package already names package "${column}", which no longer serves the set, so ` +
1032+
'`os migrate stored-references bind` (which writes only a column naming no package) does not apply: install or ' +
1033+
`enable "${column}" again if its set is the one meant, or dismiss the suggestion.`;
1034+
}
1035+
10201036
/**
10211037
* The catalog entry of the set `row` suggests, or the 409 naming why nothing
10221038
* is suggested any more: the catalog does not serve the set, another package

0 commit comments

Comments
 (0)