diff --git a/.changeset/38929-step19-notice-relevance.md b/.changeset/38929-step19-notice-relevance.md new file mode 100644 index 00000000000..0a0f4e0a691 --- /dev/null +++ b/.changeset/38929-step19-notice-relevance.md @@ -0,0 +1,26 @@ +--- +'@objectstack/spec': patch +'@objectstack/cli': patch +--- + +fix(spec,cli): `os migrate meta --from 18` proves the protocol-19 notices a stack has no surface for absent, and says why when it cannot + +Clause-②: yes (widening) +Metadata-protocol: none + +Widened: `MigrationChainResult` (`@objectstack/spec/migrations`) gains the optional member `unanswered` — `{ todos, unread }`, the entries whose relevance question the chain could not answer and what it could not read (`plugins`, `devPlugins`, `tiers`, a key whose value is not a list or a map, an unreadable manifest or package body). It moves nothing off any list; it only says why. `os migrate meta --json` emits it, under the same name, when a question stayed open; otherwise the payload is unchanged. + +Most protocol-19 semantic entries whose surface is metadata authored under top-level stack keys now carry a `relevantWhen` question naming each key it can be written under, nested sites included (an action an object carries inline counts under `objects`). On a stack that declares none of them, the chain proves the entry absent, and `os migrate meta` counts it rather than listing it (`--all` lists it). The rule: a surface that a stored copy of the same metadata also meets still takes a question, since the proof covers the stack the command loads and never what a deployment stores. An entry stays listed to every stack when its surface is host code, a deployment's own state and doors (installed packages, rows written at run time), or something every stack carries, or when its own check runs over the rows a deployment stores — the protocol-19 permission-set field vote and the move of forms out of views among them. No prose is matched. + +The question now also reads the stack's own `manifest`, as it reads a package body: a seed dataset declared under `manifest.data` keeps the seed notices listed. + +`os migrate meta` prints the count of notices proven absent even when it is zero, whenever the run crossed an entry that asks, and says why a question stayed open. A stack that lists a plugin (`plugins:`, `devPlugins:`) or a `tiers` preset proves nothing absent, because a plugin can register metadata at boot that the stack does not show. The 18.x blank template lists three connector plugins, so an app scaffolded from it keeps every notice listed, and the report now says so: + +``` + 0 more manual change(s) not listed: no surface they ask about was proven absent from this stack. + N of the manual change(s) listed above ask whether this stack declares their surface, and this run could not prove it absent: it cannot read `plugins`. +``` + +The proof covers the definitions the stack declares. Two sources of metadata are outside it, and the line that scopes the count names both: what a deployment stores (Studio, the metadata API), and what the app's `onEnable` hook registers through the engine it is handed at start. `onEnable` is not treated as a carrier: it is described for action handlers and drivers, and registering metadata there is off-label. + +An app that lists no plugins, such as one scaffolded from the current blank template, sees the protocol-19 notices about agents, knowledge sources and the other surfaces it does not author, among those that carry a question, leave the default list. diff --git a/packages/cli/src/commands/migrate/meta.relevance-count.test.ts b/packages/cli/src/commands/migrate/meta.relevance-count.test.ts new file mode 100644 index 00000000000..558adcb5b38 --- /dev/null +++ b/packages/cli/src/commands/migrate/meta.relevance-count.test.ts @@ -0,0 +1,179 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * `os migrate meta` — group ④ counts the notices proven absent, zero + * included, and says why a question it could not answer left its notice on + * the list (`utils/migrate-meta-relevance.ts`). + * + * The input is the scaffold's own blank template, loaded the way the command + * loads it (`loadConfig(…, { authoredSource: true })`, then the map → array + * pass only) and replayed through the command's own chain + * (`applyMetaMigrationsToPackages`). That template lists no `plugins:`, so + * the chain proves `agents` and `knowledgeSources` absent from it and their + * two protocol-19 notices leave ③. The same stack with a plugin listed — the + * shape the 18.6.0 template had, three connector plugins — proves nothing + * absent, and ④ prints the zero count and the reason instead. + */ + +import { dirname, resolve } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { stripVTControlCharacters } from 'node:util'; +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; +import { ObjectStackDefinitionSchema, normalizeStackInput } from '@objectstack/spec'; +import { MIGRATION_MAJORS, type MigrationChainResult } from '@objectstack/spec/migrations'; +import { PROTOCOL_MAJOR } from '@objectstack/spec/kernel'; +import { loadConfig } from '../../utils/config.js'; +import { applyMetaMigrationsToPackages, printMigrationReport, type MigrationReport } from './meta.js'; +import { NONE_PROVEN_ABSENT_LINE } from '../../utils/migrate-meta-relevance.js'; +// The packages the command reaches through dynamic imports, loaded at module top so the +// first load is paid during collection, never inside a clocked case (`check:test-source-alias`). +import '@objectstack/cloud-connection'; +import '@objectstack/driver-sql'; +import '@objectstack/driver-turso'; +import '@objectstack/metadata'; +import '@objectstack/metadata-protocol'; +import '@objectstack/platform-objects/plugin'; +import '@objectstack/plugin-hono-server'; +import '@objectstack/plugin-security'; +import '@objectstack/rest'; +import '@objectstack/service-automation'; +import '@objectstack/service-datasource'; +import '@objectstack/service-settings'; +import '@objectstack/service-storage'; + +const HERE = dirname(fileURLToPath(import.meta.url)); +const BLANK_CONFIG = resolve(HERE, '../../../../create-objectstack/src/templates/blank/objectstack.config.ts'); + +/** Where the chain ends by default — derived, so the file survives the next major. */ +const TERMINUS = Math.max(PROTOCOL_MAJOR, ...MIGRATION_MAJORS); + +const AGENT_ENTRY = '19:agent-model-provider-retired'; +const KNOWLEDGE_ENTRY = '19:knowledge-source-publish-refuses-missing-references-and-gated-objects'; + +/** ④'s count line when some notices were proven absent — the line `meta.report-order.test.ts` pins. */ +const ABSENT_COUNT_RE = /^ {2}(\d+) more manual change\(s\) not listed: their surfaces are absent from this stack /; +const UNANSWERED_RE = /^ {4}(\d+) of the manual change\(s\) listed above ask whether this stack declares their surface, and this run could not prove it absent: it cannot read (.+)\.$/; +const PLUGIN_REASON_RE = /^ {4}A plugin, or a platform plugin a `tiers` preset loads, can register metadata at boot /; + +class ConnectorLikePlugin { + name = 'com.example.connector'; +} + +let printed: string[] = []; + +beforeEach(() => { + printed = []; + vi.spyOn(console, 'log').mockImplementation((...args: unknown[]) => { + printed.push(args.map(String).join(' ')); + }); +}); + +afterEach(() => { + vi.restoreAllMocks(); +}); + +/** The blank template's stack as the command reads it: authored source, map → array only. */ +async function blankStack(): Promise> { + const { config } = await loadConfig(BLANK_CONFIG, { authoredSource: true }); + return normalizeStackInput(config as Record, { convert: false }); +} + +/** Replay `--from 18` the way the command does and print the human report; `amend` edits the result. */ +function report( + stack: Record, + amend: (r: MigrationChainResult) => MigrationChainResult = (r) => r, +): { result: MigrationChainResult; lines: string[] } { + const result = amend(applyMetaMigrationsToPackages(stack, 18, TERMINUS)); + const parsed = ObjectStackDefinitionSchema.safeParse(result.stack); + const migrationReport: MigrationReport = { + result, + normalized: stack, + schemaValid: parsed.success, + refusals: parsed.success ? [] : parsed.error.issues, + dataMigrations: [], + step: false, + all: false, + elapsed: '1ms', + }; + vi.mocked(console.log).mockClear(); + printed = []; + printMigrationReport(migrationReport); + return { result, lines: stripVTControlCharacters(printed.join('\n')).split('\n') }; +} + +const ids = (todos: MigrationChainResult['todos']) => todos.map((t) => `${t.toMajor}:${t.id}`); + +describe('the blank template proves agents and knowledge sources absent (ACCEPTANCE)', () => { + it('lists no `plugins:`, so both notices leave ③ and ④ counts them', async () => { + const stack = await blankStack(); + expect(stack.plugins).toBeUndefined(); + const { result, lines } = report(stack); + expect(ids(result.absentTodos)).toEqual(expect.arrayContaining([AGENT_ENTRY, KNOWLEDGE_ENTRY])); + expect(result.unanswered).toBeUndefined(); + + const count = lines.find((l) => ABSENT_COUNT_RE.test(l)); + expect(count, 'the count line').toBeDefined(); + expect(Number(ABSENT_COUNT_RE.exec(count!)![1])).toBe(result.absentTodos.length); + expect(lines.filter((l) => UNANSWERED_RE.test(l))).toEqual([]); + // The scope line names both sources the proof does not read. + const scope = lines.filter((l) => l.startsWith(' Absent is proven over the stack this run loaded; ')); + expect(scope).toHaveLength(1); + expect(scope[0]).toContain('metadata a deployment stores'); + expect(scope[0]).toContain('`onEnable`'); + for (const t of result.absentTodos.filter((u) => [AGENT_ENTRY, KNOWLEDGE_ENTRY].includes(`${u.toMajor}:${u.id}`))) { + expect(lines, `${t.id} is counted, not listed`).not.toContain(` ⚠ [protocol ${t.toMajor}] ${t.surface} → ${t.replacement}`); + } + }); + + it('a template that declares an agent keeps its notice listed (control)', async () => { + const stack = { ...(await blankStack()), agents: [{ name: 'helper', label: 'Helper' }] }; + const { result } = report(stack); + expect(ids(result.absentTodos)).not.toContain(AGENT_ENTRY); + expect(ids(result.absentTodos)).toContain(KNOWLEDGE_ENTRY); + }); +}); + +describe('④ prints the zero count, and why a question stayed open (PRINTER)', () => { + it('the template with a plugin listed proves nothing absent: zero, the count of open questions, and why', async () => { + const stack = { ...(await blankStack()), plugins: [new ConnectorLikePlugin(), new ConnectorLikePlugin()] }; + const { result, lines } = report(stack); + expect(result.absentTodos).toEqual([]); + expect(ids(result.unanswered!.todos)).toEqual(expect.arrayContaining([AGENT_ENTRY, KNOWLEDGE_ENTRY])); + + expect(lines.filter((l) => l === NONE_PROVEN_ABSENT_LINE)).toHaveLength(1); + const open = lines.filter((l) => UNANSWERED_RE.test(l)); + expect(open).toHaveLength(1); + const [, n, unread] = UNANSWERED_RE.exec(open[0]!)!; + expect(Number(n)).toBe(result.unanswered!.todos.length); + expect(unread).toBe('`plugins`'); + expect(lines.filter((l) => PLUGIN_REASON_RE.test(l))).toHaveLength(1); + // Both notices are still listed in ③. + for (const t of result.todos.filter((u) => [AGENT_ENTRY, KNOWLEDGE_ENTRY].includes(`${u.toMajor}:${u.id}`))) { + expect(lines).toContain(` ⚠ [protocol ${t.toMajor}] ${t.surface} → ${t.replacement}`); + } + // The order: ③'s header, then the zero count, then the reason. + const semantic = lines.findIndex((l) => /^ {2}\d+ manual change\(s\) require your judgment:$/.test(l)); + const zero = lines.indexOf(NONE_PROVEN_ABSENT_LINE); + expect(semantic).toBeGreaterThan(-1); + expect(zero).toBeGreaterThan(semantic); + expect(lines.findIndex((l) => UNANSWERED_RE.test(l))).toBe(zero + 1); + }); + + it('an unreadable key is named, with no plugin sentence', async () => { + const stack = { ...(await blankStack()), agents: 'helper' }; + const { lines } = report(stack); + const open = lines.filter((l) => UNANSWERED_RE.test(l)); + expect(open).toHaveLength(1); + expect(UNANSWERED_RE.exec(open[0]!)![2]).toBe('`agents`'); + expect(lines.filter((l) => PLUGIN_REASON_RE.test(l))).toEqual([]); + }); + + it('prints no zero count when no crossed entry asks a question', async () => { + const { lines } = report(await blankStack(), (r) => ({ + ...r, + todos: r.todos.map(({ relevantWhen: _question, ...rest }) => rest), + absentTodos: [], + })); + expect(lines.filter((l) => l === NONE_PROVEN_ABSENT_LINE)).toEqual([]); + }); +}); diff --git a/packages/cli/src/commands/migrate/meta.report-order.test.ts b/packages/cli/src/commands/migrate/meta.report-order.test.ts index ee991d86436..8bf86206cdc 100644 --- a/packages/cli/src/commands/migrate/meta.report-order.test.ts +++ b/packages/cli/src/commands/migrate/meta.report-order.test.ts @@ -64,6 +64,7 @@ import { } from '@objectstack/spec/migrations'; import { PROTOCOL_MAJOR } from '@objectstack/spec/kernel'; import { printMigrationReport, type MigrationReport } from './meta.js'; +import { NONE_PROVEN_ABSENT_LINE } from '../../utils/migrate-meta-relevance.js'; // The packages the command reaches through dynamic imports, loaded at module top so the // first load is paid during collection, never inside a clocked case (`check:test-source-alias`). import '@objectstack/cloud-connection'; @@ -613,9 +614,11 @@ describe('the notices proven absent leave ③ for one counting line, and --all l for (const t of result.absentTodos) expect(t.relevantWhen, `${t.id} carries relevantWhen`).toBeDefined(); }); - it('prints no ④ at all when the chain proved nothing absent', () => { + it('prints only the zero count as ④ when the chain proved nothing absent', () => { const { lines } = run(FINDINGS_STACK, MIGRATION_SUPPORT_FLOOR, TERMINUS, (r) => ({ ...r, absentTodos: [] })); expect(lines.filter((l) => ABSENT_COUNT_RE.test(l) || ABSENT_SCOPE_RE.test(l) || ABSENT_HEADER_RE.test(l))).toEqual([]); + // The count is printed at zero too (`meta.relevance-count.test.ts` pins its conditions). + expect(lines.filter((l) => l === NONE_PROVEN_ABSENT_LINE)).toHaveLength(1); }); it('a run whose only notices are proven absent still counts them and still writes --out', () => { diff --git a/packages/cli/src/commands/migrate/meta.ts b/packages/cli/src/commands/migrate/meta.ts index 62e6334bfe4..74291ca08ac 100644 --- a/packages/cli/src/commands/migrate/meta.ts +++ b/packages/cli/src/commands/migrate/meta.ts @@ -21,6 +21,7 @@ import { PROTOCOL_MAJOR, PROTOCOL_VERSION } from '@objectstack/spec/kernel'; import { FILE_REFERENCE_TYPES, REFERENCE_VALUE_TYPES, STRUCTURED_JSON_TYPES } from '@objectstack/spec/data'; import { FILE_REFERENCES_MIGRATION_ID, VALUE_SHAPES_MIGRATION_ID } from '@objectstack/spec/system'; import { loadConfig } from '../../utils/config.js'; +import { printNoneProvenAbsent, printUnansweredRelevance } from '../../utils/migrate-meta-relevance.js'; import { authoringRuleUnionStack } from '../../utils/stack-collections.js'; import { printHeader, @@ -1183,7 +1184,12 @@ function absentKeysText(t: MigrationTodo): string { */ function printAbsentNotices(result: MigrationChainResult, all: boolean): void { const count = result.absentTodos.length; - if (count === 0) return; + // Zero is a count too: printed whenever a crossed entry asks, with + // why a question stayed open (`utils/migrate-meta-relevance.ts`). + if (count === 0) { + printNoneProvenAbsent(result); + return; + } if (!all) { console.log( chalk.dim( @@ -1194,9 +1200,10 @@ function printAbsentNotices(result: MigrationChainResult, all: boolean): void { console.log( chalk.dim( ' Absent is proven over the stack this run loaded; metadata a deployment stores ' - + '(Studio, the metadata API) is not read here.', + + '(Studio, the metadata API), and what an `onEnable` hook registers at start, is not read here.', ), ); + printUnansweredRelevance(result); console.log(''); return; } @@ -1205,6 +1212,7 @@ function printAbsentNotices(result: MigrationChainResult, all: boolean): void { printNotice(t); console.log(chalk.dim(` absent: nothing is declared under ${absentKeysText(t)}`)); } + printUnansweredRelevance(result); console.log(''); } @@ -1595,6 +1603,10 @@ export default class MigrateMeta extends Command { // subset the chain proved irrelevant to this stack (ADR-0087 D3), // so a machine consumer reads the default list as the difference. absentTodos: result.absentTodos, + // Only when a relevance question stayed open: those entries (all + // still in `todos`) and what the chain could not read, as the + // human report's why line prints them. + ...(result.unanswered ? { unanswered: result.unanswered } : {}), // Only when the run crosses into protocol 19 and the form move // left a site: without one the payload is what it always was. ...(formSites.length > 0 ? { formMoveSites: formSites } : {}), diff --git a/packages/cli/src/utils/migrate-meta-relevance.ts b/packages/cli/src/utils/migrate-meta-relevance.ts new file mode 100644 index 00000000000..5acf3d63312 --- /dev/null +++ b/packages/cli/src/utils/migrate-meta-relevance.ts @@ -0,0 +1,74 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * `os migrate meta` — the two lines group ④ adds beside its count of the + * notices proven absent (ADR-0087 D3; the count itself is printed by + * `printAbsentNotices` in `commands/migrate/meta.ts`). + * + * - The count is printed even when it is zero, whenever the run crossed an + * entry that carries a relevance question: an author reading a full list + * can tell "nothing was proven absent" from "nothing was asked". + * - The entries whose question the chain could not answer + * (`MigrationChainResult.unanswered`) are counted, with what it could not + * read: a stack that lists a plugin proves nothing absent, and says so + * instead of handing every notice over without a reason. + * + * Both lines only explain. Neither moves a notice off ③'s list, and neither + * reads prose: the count comes from `absentTodos`, the explanation from + * `unanswered`, both the chain's. + */ + +import chalk from 'chalk'; +import type { MigrationChainResult } from '@objectstack/spec/migrations'; + +/** + * The `unread` paths that are carriers of metadata the stack does not show — + * `MigrationChainResult.unanswered` documents them — and whose presence the + * second explanatory line is about. + */ +const PLUGIN_CARRIERS: ReadonlySet = new Set(['plugins', 'devPlugins', 'tiers']); + +/** The line counting the notices proven absent when there are none, printed only if a question was asked. */ +export const NONE_PROVEN_ABSENT_LINE = + ' 0 more manual change(s) not listed: no surface they ask about was proven absent from this stack.'; + +/** + * Says why the questions the chain could not answer left their notices on + * the list above: how many, and what the evaluation could not read. Prints + * nothing when every question was answered. + */ +export function printUnansweredRelevance(result: MigrationChainResult): void { + const open = result.unanswered; + if (!open || open.todos.length === 0) return; + // The chain names at least one path for every open question; should it name + // none, the line says so rather than printing an empty list. + const unread = open.unread.length > 0 + ? open.unread.map((path) => `\`${path}\``).join(', ') + : 'a value it was not told about'; + console.log( + chalk.dim( + ` ${open.todos.length} of the manual change(s) listed above ask whether this stack declares their ` + + `surface, and this run could not prove it absent: it cannot read ${unread}.`, + ), + ); + if (open.unread.some((path) => PLUGIN_CARRIERS.has(path))) { + console.log( + chalk.dim( + ' A plugin, or a platform plugin a `tiers` preset loads, can register metadata at boot that the ' + + 'stack does not show, so no surface is proven absent while one is listed.', + ), + ); + } +} + +/** + * Group ④ when the chain proved nothing absent: the zero count, when the run + * crossed an entry that carries a relevance question, then why the questions + * it could not answer stayed open. Prints nothing when no entry crossed asks. + */ +export function printNoneProvenAbsent(result: MigrationChainResult): void { + if (!result.todos.some((t) => t.relevantWhen)) return; + console.log(chalk.dim(NONE_PROVEN_ABSENT_LINE)); + printUnansweredRelevance(result); + console.log(''); +} diff --git a/packages/spec/src/migrations/chain.ts b/packages/spec/src/migrations/chain.ts index 4776c104d69..361074edafe 100644 --- a/packages/spec/src/migrations/chain.ts +++ b/packages/spec/src/migrations/chain.ts @@ -76,6 +76,16 @@ function foldVerdicts(verdicts: Iterable): SemanticRel return unknown ? 'unknown' : 'absent'; } +/** + * What a relevance evaluation could not read, as stack paths — collected only + * to say WHY a question answered `unknown` (`MigrationChainResult.unanswered`). + * It never decides a verdict: the verdict is the fold of the answers alone. + */ +export type SemanticRelevanceUnread = Set; + +/** The `unread` path for a stack that is not a plain object, or whose read threw. */ +const STACK_UNREADABLE = '(stack)'; + /** * The `stack-declares` question over ONE stack: does it declare anything under * any of `keys`, at the top level or inside an assembled `packages[].manifest` @@ -84,28 +94,61 @@ function foldVerdicts(verdicts: Iterable): SemanticRel * Conservative by construction (ADR-0087 D3, "never silence"): `absent` is a * positive proof — the stack is a plain object, no `plugins` / `devPlugins` * entry and no `tiers` preset could contribute what it does not show, every - * carrier of the keys was read, and none held anything. Whatever the evaluation cannot read answers + * carrier of the keys was read (the top level, the stack's own `manifest`, + * each package body), and none held anything. Whatever the evaluation cannot read answers * `unknown`, and a read that throws (a getter, a proxy) answers `unknown` too. + * + * Each read that answers `unknown` names what it could not read in `unread` + * (see {@link SemanticRelevanceUnread}). */ -function stackDeclaresVerdict(stack: unknown, keys: readonly string[]): SemanticRelevanceVerdict { - if (!isPlainDict(stack)) return 'unknown'; +function stackDeclaresVerdict( + stack: unknown, + keys: readonly string[], + unread: SemanticRelevanceUnread, +): SemanticRelevanceVerdict { + if (!isPlainDict(stack)) { + unread.add(STACK_UNREADABLE); + return 'unknown'; + } try { - const verdicts: SemanticRelevanceVerdict[] = keys.map((key) => collectionVerdict(stack[key])); + const verdicts: SemanticRelevanceVerdict[] = []; + const read = (value: unknown, path: string): void => { + const verdict = collectionVerdict(value); + if (verdict === 'unknown') unread.add(path); + verdicts.push(verdict); + }; + for (const key of keys) read(stack[key], key); + + // The stack's own manifest is read as a package body is: it declares + // collections of its own (`manifest.data`, the seed datasets the runtime + // loads at boot, among them), so a key there counts too. Reading it can + // only move an answer from `absent` to `present` or `unknown`. + const manifest = stack.manifest; + if (manifest !== undefined) { + if (!isPlainDict(manifest)) { + unread.add('manifest'); + verdicts.push('unknown'); + } else { + for (const key of keys) read(manifest[key], `manifest.${key}`); + } + } // An assembled multi-package stack (`composeStacks(…, { manifest: 'preserve' })`) // carries its collections in each package body rather than at the top level. const packages = stack.packages; if (packages !== undefined) { if (!Array.isArray(packages)) { + unread.add('packages'); verdicts.push('unknown'); } else { - for (const entry of packages) { + for (const [index, entry] of packages.entries()) { if (!isPlainDict(entry) || !isPlainDict(entry.manifest)) { + unread.add(`packages[${index}]`); verdicts.push('unknown'); continue; } const body = entry.manifest; - for (const key of keys) verdicts.push(collectionVerdict(body[key])); + for (const key of keys) read(body[key], `packages[${index}].manifest.${key}`); } } } @@ -115,12 +158,25 @@ function stackDeclaresVerdict(stack: unknown, keys: readonly string[]): Semantic // plugins the host loads the same way. So while one is listed, no key can // be proven absent from what this stack deploys (a key the stack visibly // declares is still present). + // + // `onEnable` is NOT a carrier here. It is the app's start hook, described + // for action handlers and drivers, and the engine it receives can also + // register objects, apps, hooks and actions. What it registers that way is + // outside the proof, as metadata a deployment stores is: `absent` is a + // proof over the definitions this stack declares, and the printer's scope + // line names both limits. A top-level `export const onEnable` is not on + // the stack object either, so reading it would need the loader to hand it + // over. for (const carrier of ['plugins', 'devPlugins', 'tiers']) { - if (collectionVerdict(stack[carrier]) !== 'absent') verdicts.push('unknown'); + if (collectionVerdict(stack[carrier]) !== 'absent') { + unread.add(carrier); + verdicts.push('unknown'); + } } return foldVerdicts(verdicts); } catch { + unread.add(STACK_UNREADABLE); return 'unknown'; } } @@ -132,21 +188,55 @@ function stackDeclaresVerdict(stack: unknown, keys: readonly string[]): Semantic * when it is absent from all of them. Reading every checkpoint keeps a key a * conversion renames or removes from reading as absent on either side of it. * + * When the answer is `unknown` and `unread` is given, what the evaluation could + * not read is added to it; any other answer adds nothing, since a question that + * was answered owes no reason. + * * Exported for the chain's own tests; not part of the published entry. */ export function semanticRelevanceVerdict( relevance: SemanticRelevance, stacks: readonly unknown[], + unread?: SemanticRelevanceUnread, ): SemanticRelevanceVerdict { + const local: SemanticRelevanceUnread = new Set(); + let verdict: SemanticRelevanceVerdict; switch (relevance.kind) { case 'stack-declares': - return stacks.length === 0 - ? 'unknown' - : foldVerdicts(stacks.map((s) => stackDeclaresVerdict(s, relevance.keys))); + if (stacks.length === 0) { + local.add(STACK_UNREADABLE); + verdict = 'unknown'; + } else { + verdict = foldVerdicts(stacks.map((s) => stackDeclaresVerdict(s, relevance.keys, local))); + } + break; default: // A question this build does not know how to answer proves nothing. - return 'unknown'; + local.add(`(a question of kind ${String((relevance as { kind?: unknown }).kind)})`); + verdict = 'unknown'; } + if (verdict === 'unknown' && unread) for (const path of local) unread.add(path); + return verdict; +} + +/** + * The relevance answer one semantic TODO takes in a run, or `undefined` when + * it is listed whatever its question answers: it carries no question, or it + * judges a conversion that applied an edit in this run (an applied edit is + * itself a proof its surface is there). `unread` collects what an `unknown` + * answer could not read (see {@link semanticRelevanceVerdict}). + * + * Exported for the chain's own tests; not part of the published entry. + */ +export function semanticTodoVerdict( + todo: MigrationTodo, + checkpoints: readonly unknown[], + appliedConversionIds: ReadonlySet, + unread?: SemanticRelevanceUnread, +): SemanticRelevanceVerdict | undefined { + if (!todo.relevantWhen) return undefined; + if (todo.conversionIds?.some((id) => appliedConversionIds.has(id))) return undefined; + return semanticRelevanceVerdict(todo.relevantWhen, checkpoints, unread); } /** @@ -162,9 +252,7 @@ export function semanticTodoAbsent( checkpoints: readonly unknown[], appliedConversionIds: ReadonlySet, ): boolean { - if (!todo.relevantWhen) return false; - if (todo.conversionIds?.some((id) => appliedConversionIds.has(id))) return false; - return semanticRelevanceVerdict(todo.relevantWhen, checkpoints) === 'absent'; + return semanticTodoVerdict(todo, checkpoints, appliedConversionIds) === 'absent'; } /** Thrown when `--from N` is below the documented support floor. */ @@ -197,7 +285,9 @@ export class MigrationFloorError extends Error { * chain made of it (ADR-0087 D3: an entry may leave a printer's default list * only on a structured, stack-derived proof). An entry that judges a * conversion which applied an edit in this run is never named there, whatever - * its question answers. + * its question answers. `unanswered` names the entries whose question answered + * `unknown`, with what the evaluation could not read, so a printer can say why + * they stay listed; it moves nothing off any list. */ export function applyMetaMigrations( stack: Record, @@ -243,10 +333,17 @@ export function applyMetaMigrations( const todos: MigrationTodo[] = []; const absentTodos: MigrationTodo[] = []; + const unansweredTodos: MigrationTodo[] = []; + const unread: SemanticRelevanceUnread = new Set(); const hops: MigrationHopResult[] = replayed.map(({ step, stack: hopStack, applied: hopApplied }) => { const hopTodos: MigrationTodo[] = step.semantic.map((s) => ({ ...s, toMajor: step.toMajor })); // The same objects, never copies: `absentTodos` is a subset of `todos`. - const hopAbsent = hopTodos.filter((todo) => semanticTodoAbsent(todo, checkpoints, appliedConversionIds)); + const hopAbsent: MigrationTodo[] = []; + for (const todo of hopTodos) { + const verdict = semanticTodoVerdict(todo, checkpoints, appliedConversionIds, unread); + if (verdict === 'absent') hopAbsent.push(todo); + else if (verdict === 'unknown') unansweredTodos.push(todo); + } todos.push(...hopTodos); absentTodos.push(...hopAbsent); return { @@ -259,5 +356,15 @@ export function applyMetaMigrations( }; }); - return { fromMajor, toMajor, stack: current, applied, todos, absentTodos, hops }; + return { + fromMajor, + toMajor, + stack: current, + applied, + todos, + absentTodos, + // Only when a question stayed open: why each such entry is still listed. + ...(unansweredTodos.length > 0 ? { unanswered: { todos: unansweredTodos, unread: [...unread] } } : {}), + hops, + }; } diff --git a/packages/spec/src/migrations/entries/semantic/19.action-body-regexp-literal-token-refused.ts b/packages/spec/src/migrations/entries/semantic/19.action-body-regexp-literal-token-refused.ts index af6b3178fc3..b87e555edb0 100644 --- a/packages/spec/src/migrations/entries/semantic/19.action-body-regexp-literal-token-refused.ts +++ b/packages/spec/src/migrations/entries/semantic/19.action-body-regexp-literal-token-refused.ts @@ -43,4 +43,5 @@ export const entry: SemanticMigration = { + 'actions[N].body.source or objects[N].actions[N].body.source. PUT /api/v1/meta/action/NAME with each such body ' + 'corrected answers 200, and running the action on POST /api/v1/actions/OBJECT/ACTION/ID answers the body\'s ' + 'result instead of 500.', + relevantWhen: { kind: 'stack-declares', keys: ['actions', 'objects'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.body-regexp-pattern-refused.ts b/packages/spec/src/migrations/entries/semantic/19.body-regexp-pattern-refused.ts index a339ed717a2..b49b5270edd 100644 --- a/packages/spec/src/migrations/entries/semantic/19.body-regexp-pattern-refused.ts +++ b/packages/spec/src/migrations/entries/semantic/19.body-regexp-pattern-refused.ts @@ -57,4 +57,5 @@ export const entry: SemanticMigration = { + 'objects[N].actions[N].body.source, hooks[N].body.source, hooks[N].handler or jobs[N].body.source. ' + 'PUT /api/v1/meta/action/NAME or PUT /api/v1/meta/hook/NAME with each such body corrected answers 200, and ' + 'running it answers the body\'s result instead of the compile failure.', + relevantWhen: { kind: 'stack-declares', keys: ['actions', 'objects', 'hooks', 'jobs'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.book-audience-two-gates-and-catch-all-claim-refused.ts b/packages/spec/src/migrations/entries/semantic/19.book-audience-two-gates-and-catch-all-claim-refused.ts index 75ccb40bca5..96be223eb37 100644 --- a/packages/spec/src/migrations/entries/semantic/19.book-audience-two-gates-and-catch-all-claim-refused.ts +++ b/packages/spec/src/migrations/entries/semantic/19.book-audience-two-gates-and-catch-all-claim-refused.ts @@ -31,4 +31,5 @@ export const entry: SemanticMigration = { acceptanceCriteria: 'os validate reports no `book-gated-catch-all-include` and accepts every book audience; a save of every book the ' + 'package carries succeeds.', + relevantWhen: { kind: 'stack-declares', keys: ['books'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.cel-list-equality-refused.ts b/packages/spec/src/migrations/entries/semantic/19.cel-list-equality-refused.ts index f164774e8e7..8caaf2315bf 100644 --- a/packages/spec/src/migrations/entries/semantic/19.cel-list-equality-refused.ts +++ b/packages/spec/src/migrations/entries/semantic/19.cel-list-equality-refused.ts @@ -56,4 +56,8 @@ export const entry: SemanticMigration = { + 'field is a membership test, a null test or a whole-list match, and the condition answers per row. A stored row ' + 'carrying the shape still loads and is served; its next save through a door that runs the publish lint is ' + 'refused until it is corrected.', + relevantWhen: { + kind: 'stack-declares', + keys: ['objects', 'objectExtensions', 'actions', 'pages', 'hooks', 'sharingRules', 'permissions', 'flows'], + }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.compose-stacks-job-name-across-packages-refused.ts b/packages/spec/src/migrations/entries/semantic/19.compose-stacks-job-name-across-packages-refused.ts index 9ba3bd2fbea..68cf6aada02 100644 --- a/packages/spec/src/migrations/entries/semantic/19.compose-stacks-job-name-across-packages-refused.ts +++ b/packages/spec/src/migrations/entries/semantic/19.compose-stacks-job-name-across-packages-refused.ts @@ -37,4 +37,5 @@ export const entry: SemanticMigration = { + 'finding "Job \'NAME\' is declared enabled twice across the packages of one composed artifact" or "Job \'NAME\' ' + 'is declared twice in jobs", and the boot log carries no NOT SCHEDULED error for a job name: composition counts ' + 'each job once per place it is reached, as the binder binds it.', + relevantWhen: { kind: 'stack-declares', keys: ['jobs'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.field-group-shadowed-six-highlights.ts b/packages/spec/src/migrations/entries/semantic/19.field-group-shadowed-six-highlights.ts index fbd5ca1ea47..cdbde4ba02b 100644 --- a/packages/spec/src/migrations/entries/semantic/19.field-group-shadowed-six-highlights.ts +++ b/packages/spec/src/migrations/entries/semantic/19.field-group-shadowed-six-highlights.ts @@ -25,4 +25,5 @@ export const entry: SemanticMigration = { acceptanceCriteria: 'os validate reports no `field-group-shadowed` warning; one that remains names a group whose only visible ' + 'member is the record title.', + relevantWhen: { kind: 'stack-declares', keys: ['objects', 'objectExtensions'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.field-inline-edit-boolean-retired.ts b/packages/spec/src/migrations/entries/semantic/19.field-inline-edit-boolean-retired.ts index 2fa246bb37a..948f2808f80 100644 --- a/packages/spec/src/migrations/entries/semantic/19.field-inline-edit-boolean-retired.ts +++ b/packages/spec/src/migrations/entries/semantic/19.field-inline-edit-boolean-retired.ts @@ -26,4 +26,5 @@ export const entry: SemanticMigration = { + 'Every child whose rows are meant to be entered in the parent\'s form is named by a field group of the ' + 'parent (`fieldGroups[].relatedList`), and `os validate` reports no new issue.', conversionIds: ['field-inline-edit-boolean-removed'], + relevantWhen: { kind: 'stack-declares', keys: ['objects', 'objectExtensions'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.flow-concurrent-branch-durable-pause-refused.ts b/packages/spec/src/migrations/entries/semantic/19.flow-concurrent-branch-durable-pause-refused.ts index 44d77613a0f..ed6dc8524ce 100644 --- a/packages/spec/src/migrations/entries/semantic/19.flow-concurrent-branch-durable-pause-refused.ts +++ b/packages/spec/src/migrations/entries/semantic/19.flow-concurrent-branch-durable-pause-refused.ts @@ -58,4 +58,5 @@ export const entry: SemanticMigration = { + 'it is rewritten. Behaviour to re-check after the rewrite, because it changes on purpose: chained steps ' + 'now open their requests one after the other, and a single `unanimous` step opens one request for all ' + 'approver groups.', + relevantWhen: { kind: 'stack-declares', keys: ['flows'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.flow-condition-bare-ordering-before-record-date-arithmetic-refused.ts b/packages/spec/src/migrations/entries/semantic/19.flow-condition-bare-ordering-before-record-date-arithmetic-refused.ts index 2b654825a5e..7fa743aa7b7 100644 --- a/packages/spec/src/migrations/entries/semantic/19.flow-condition-bare-ordering-before-record-date-arithmetic-refused.ts +++ b/packages/spec/src/migrations/entries/semantic/19.flow-condition-bare-ordering-before-record-date-arithmetic-refused.ts @@ -40,4 +40,5 @@ export const entry: SemanticMigration = { + 'field; POST /api/v1/packages/PKG/publish-drafts publishes the flow; a write that should start it runs past ' + 'the condition instead of failing there. A stored flow carrying the shape still registers (registerFlow logs it ' + 'as an advisory) and keeps failing at that condition on every run until it is rewritten and published.', + relevantWhen: { kind: 'stack-declares', keys: ['flows'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.flow-condition-mixed-or-index-spelling-date-text-refused.ts b/packages/spec/src/migrations/entries/semantic/19.flow-condition-mixed-or-index-spelling-date-text-refused.ts index 527f4de1507..4b55eb4e988 100644 --- a/packages/spec/src/migrations/entries/semantic/19.flow-condition-mixed-or-index-spelling-date-text-refused.ts +++ b/packages/spec/src/migrations/entries/semantic/19.flow-condition-mixed-or-index-spelling-date-text-refused.ts @@ -53,4 +53,5 @@ export const entry: SemanticMigration = { + 'start it runs past the condition instead of failing there. A stored flow carrying the shape still registers ' + '(registerFlow logs it as an advisory) and keeps failing at that condition on every run until it is ' + 'rewritten and published.', + relevantWhen: { kind: 'stack-declares', keys: ['flows'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.flow-condition-record-date-arithmetic-refused.ts b/packages/spec/src/migrations/entries/semantic/19.flow-condition-record-date-arithmetic-refused.ts index 9289645a23b..653fdaa088f 100644 --- a/packages/spec/src/migrations/entries/semantic/19.flow-condition-record-date-arithmetic-refused.ts +++ b/packages/spec/src/migrations/entries/semantic/19.flow-condition-record-date-arithmetic-refused.ts @@ -37,4 +37,5 @@ export const entry: SemanticMigration = { + 'publishes the flow; a write that should start it runs past the condition instead of failing there. A stored ' + 'flow carrying the shape still registers (registerFlow logs it as an advisory) and keeps failing at that ' + 'condition on every run until it is rewritten and published.', + relevantWhen: { kind: 'stack-declares', keys: ['flows'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.flow-dotted-write-read-by-run-expressions-only.ts b/packages/spec/src/migrations/entries/semantic/19.flow-dotted-write-read-by-run-expressions-only.ts index ed3d5d9c5d9..5a4dc5f772f 100644 --- a/packages/spec/src/migrations/entries/semantic/19.flow-dotted-write-read-by-run-expressions-only.ts +++ b/packages/spec/src/migrations/entries/semantic/19.flow-dotted-write-read-by-run-expressions-only.ts @@ -20,4 +20,5 @@ export const entry: SemanticMigration = { acceptanceCriteria: 'Every text hole and $record read that should show a value a run computed reads a variable the run assigned ' + 'that value to, and a test run of each such flow shows the computed value there.', + relevantWhen: { kind: 'stack-declares', keys: ['flows'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.flow-sequential-branch-durable-pause-refused.ts b/packages/spec/src/migrations/entries/semantic/19.flow-sequential-branch-durable-pause-refused.ts index 8b393e8aa3d..1899450cf79 100644 --- a/packages/spec/src/migrations/entries/semantic/19.flow-sequential-branch-durable-pause-refused.ts +++ b/packages/spec/src/migrations/entries/semantic/19.flow-sequential-branch-durable-pause-refused.ts @@ -66,4 +66,5 @@ export const entry: SemanticMigration = { + 'Behaviour to re-check after the rewrite, because it changes on purpose: the branch that used to be ' + 'dropped now runs (before the pause, or after it on resume), or a `decision` now takes exactly one ' + 'branch.', + relevantWhen: { kind: 'stack-declares', keys: ['flows'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.hook-action-body-system-identity-assignment-update-by-id-refused.ts b/packages/spec/src/migrations/entries/semantic/19.hook-action-body-system-identity-assignment-update-by-id-refused.ts index c9a477cfcaf..9775abd40e6 100644 --- a/packages/spec/src/migrations/entries/semantic/19.hook-action-body-system-identity-assignment-update-by-id-refused.ts +++ b/packages/spec/src/migrations/entries/semantic/19.hook-action-body-system-identity-assignment-update-by-id-refused.ts @@ -47,4 +47,5 @@ export const entry: SemanticMigration = { + '`sys_user_position`, `sys_user_permission_set`, `sys_invitation` or `sys_member`. Saving each formerly ' + 'affected hook or action through the metadata API succeeds instead of answering a 422 that names ' + '`body.source`.', + relevantWhen: { kind: 'stack-declares', keys: ['hooks', 'actions', 'objects'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.hook-action-text-key-optional-call-refused.ts b/packages/spec/src/migrations/entries/semantic/19.hook-action-text-key-optional-call-refused.ts index bde170bccf7..7f5cacdb18d 100644 --- a/packages/spec/src/migrations/entries/semantic/19.hook-action-text-key-optional-call-refused.ts +++ b/packages/spec/src/migrations/entries/semantic/19.hook-action-text-key-optional-call-refused.ts @@ -29,4 +29,5 @@ export const entry: SemanticMigration = { acceptanceCriteria: 'objectstack validate reports no issue at body.source or handler for any hook that declares texts, and ' + 'every key its code asks for through ctx.text or the optional call ctx.text?.( is a key of its texts.', + relevantWhen: { kind: 'stack-declares', keys: ['hooks'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.hook-and-action-bodies-calling-an-ungranted-gate-refused.ts b/packages/spec/src/migrations/entries/semantic/19.hook-and-action-bodies-calling-an-ungranted-gate-refused.ts index fd4d43f80f1..a2e6c5c3e0a 100644 --- a/packages/spec/src/migrations/entries/semantic/19.hook-and-action-bodies-calling-an-ungranted-gate-refused.ts +++ b/packages/spec/src/migrations/entries/semantic/19.hook-and-action-bodies-calling-an-ungranted-gate-refused.ts @@ -53,4 +53,5 @@ export const entry: SemanticMigration = { + 'hooks[N].body.capabilities, and no `action-body-capability-undeclared` finding at ' + 'actions[N].body.capabilities or objects[N].actions[M].body.capabilities. PUT /api/v1/meta/hook/NAME and PUT /api/v1/meta/action/NAME with each such body ' + 'granted or corrected answer 200, and the call runs instead of answering 403.', + relevantWhen: { kind: 'stack-declares', keys: ['hooks', 'actions', 'objects'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.hook-job-body-does-not-compile-refused.ts b/packages/spec/src/migrations/entries/semantic/19.hook-job-body-does-not-compile-refused.ts index 01f59514e98..236c621f166 100644 --- a/packages/spec/src/migrations/entries/semantic/19.hook-job-body-does-not-compile-refused.ts +++ b/packages/spec/src/migrations/entries/semantic/19.hook-job-body-does-not-compile-refused.ts @@ -51,4 +51,5 @@ export const entry: SemanticMigration = { + 'hooks[N].body.source or hooks[N].handler, and no `job-body-does-not-compile` finding at error at ' + 'jobs[N].body.source. PUT /api/v1/meta/hook/NAME with each such hook body corrected answers 200, and the ' + 'hook runs on its next event instead of failing it.', + relevantWhen: { kind: 'stack-declares', keys: ['hooks', 'jobs'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.incremental-source-delete-policy-stated.ts b/packages/spec/src/migrations/entries/semantic/19.incremental-source-delete-policy-stated.ts index 165ad4b6014..5a8dfbacc84 100644 --- a/packages/spec/src/migrations/entries/semantic/19.incremental-source-delete-policy-stated.ts +++ b/packages/spec/src/migrations/entries/semantic/19.incremental-source-delete-policy-stated.ts @@ -36,4 +36,5 @@ export const entry: SemanticMigration = { + 'check it by hand). A mapping stored at run time, which no build parses, is judged on both arms by ' + 'its next pull: a failed sys_sync_run naming delete_policy_unhonourable or mapping_target_refused is ' + 'the signal to apply the replacement.', + relevantWhen: { kind: 'stack-declares', keys: ['mappings'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.internal-record-forms-not-loaded.ts b/packages/spec/src/migrations/entries/semantic/19.internal-record-forms-not-loaded.ts index d3e05869d4f..206498aa48e 100644 --- a/packages/spec/src/migrations/entries/semantic/19.internal-record-forms-not-loaded.ts +++ b/packages/spec/src/migrations/entries/semantic/19.internal-record-forms-not-loaded.ts @@ -27,4 +27,5 @@ export const entry: SemanticMigration = { '`os validate` reports no `form-view-internal-not-loaded` warning, or each one is a form you keep on ' + 'purpose as inert. Opening New and Edit on each object that had an internal form shows the sections, ' + 'required fields and create defaults you want, from the field groups and the field rules.', + relevantWhen: { kind: 'stack-declares', keys: ['views', 'viewItems', 'forms'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.knowledge-service-held-without-embedder-or-store.ts b/packages/spec/src/migrations/entries/semantic/19.knowledge-service-held-without-embedder-or-store.ts index eebe6fd6890..46c035c3d66 100644 --- a/packages/spec/src/migrations/entries/semantic/19.knowledge-service-held-without-embedder-or-store.ts +++ b/packages/spec/src/migrations/entries/semantic/19.knowledge-service-held-without-embedder-or-store.ts @@ -33,4 +33,5 @@ export const entry: SemanticMigration = { 'On a deployment that should search its knowledge sources, the boot logs no line saying the knowledge service ' + 'is not enabled, `search_knowledge` is listed on MCP, and a search answers hits. On a deployment that should ' + 'not, the boot logs that line once and the sources are listed and held.', + relevantWhen: { kind: 'stack-declares', keys: ['knowledgeSources', 'requires'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.lookup-depends-on-param-computed-field-refused-on-tree.ts b/packages/spec/src/migrations/entries/semantic/19.lookup-depends-on-param-computed-field-refused-on-tree.ts index c8d842ef360..d46af0e93e4 100644 --- a/packages/spec/src/migrations/entries/semantic/19.lookup-depends-on-param-computed-field-refused-on-tree.ts +++ b/packages/spec/src/migrations/entries/semantic/19.lookup-depends-on-param-computed-field-refused-on-tree.ts @@ -32,4 +32,5 @@ export const entry: SemanticMigration = { 'Run objectstack validate: no object-field-ref-unknown finding at fields.NAME.dependsOn[N] of a tree field. For ' + 'each entry it named, the filter key is a stored field of the object that declares the tree, or the entry is ' + 'gone, and importing the column resolves its cells within the scope.', + relevantWhen: { kind: 'stack-declares', keys: ['objects', 'objectExtensions'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.lookup-depends-on-param-computed-field-refused.ts b/packages/spec/src/migrations/entries/semantic/19.lookup-depends-on-param-computed-field-refused.ts index dc58b44ee3c..cfe94e084c3 100644 --- a/packages/spec/src/migrations/entries/semantic/19.lookup-depends-on-param-computed-field-refused.ts +++ b/packages/spec/src/migrations/entries/semantic/19.lookup-depends-on-param-computed-field-refused.ts @@ -28,4 +28,5 @@ export const entry: SemanticMigration = { 'Run objectstack validate: no object-field-ref-unknown finding says a dependsOn entry names a field ' + 'computed on read. For each entry it named, the filter key is a stored field of the referenced object, or ' + 'the entry is gone, and the record picker lists candidates once the field it depends on has a value.', + relevantWhen: { kind: 'stack-declares', keys: ['objects', 'objectExtensions'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.lookup-filter-record-path-structured-refused.ts b/packages/spec/src/migrations/entries/semantic/19.lookup-filter-record-path-structured-refused.ts index d92c6ba0387..936e1d9e438 100644 --- a/packages/spec/src/migrations/entries/semantic/19.lookup-filter-record-path-structured-refused.ts +++ b/packages/spec/src/migrations/entries/semantic/19.lookup-filter-record-path-structured-refused.ts @@ -43,4 +43,5 @@ export const entry: SemanticMigration = { + 'fields.NAME.lookupFilters[N].value.$record that names a structured field. PUT ' + '/api/v1/meta/object/NAME?mode=draft&package=PKG with each such path pointing at a single-valued scalar field (or ' + 'one single-valued hop to one) answers 200, and POST /api/v1/packages/PKG/publish-drafts publishes it.', + relevantWhen: { kind: 'stack-declares', keys: ['objects', 'objectExtensions'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.lowered-hook-and-action-bodies-capabilities-judged.ts b/packages/spec/src/migrations/entries/semantic/19.lowered-hook-and-action-bodies-capabilities-judged.ts index f26773980f2..7206764c75a 100644 --- a/packages/spec/src/migrations/entries/semantic/19.lowered-hook-and-action-bodies-capabilities-judged.ts +++ b/packages/spec/src/migrations/entries/semantic/19.lowered-hook-and-action-bodies-capabilities-judged.ts @@ -55,4 +55,5 @@ export const entry: SemanticMigration = { + '`hook-body-capability-undeclared` finding and no `action-body-capability-undeclared` finding. PUT ' + '/api/v1/meta/hook/NAME and PUT /api/v1/meta/action/NAME with a rebuilt artifact\'s hook or action, or with a ' + 'hand-written body beside a string handler or target that declares each token it calls, answer 200.', + relevantWhen: { kind: 'stack-declares', keys: ['hooks', 'actions', 'objects'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.master-detail-related-list-tab-by-default.ts b/packages/spec/src/migrations/entries/semantic/19.master-detail-related-list-tab-by-default.ts index 197a804e9fb..6a7efdd63b6 100644 --- a/packages/spec/src/migrations/entries/semantic/19.master-detail-related-list-tab-by-default.ts +++ b/packages/spec/src/migrations/entries/semantic/19.master-detail-related-list-tab-by-default.ts @@ -76,4 +76,5 @@ export const entry: SemanticMigration = { + 'record page as before: a body table with no tab of its own, whether or not a group positions it. Where ' + 'a parent field group names such a child, the parent\'s create and edit forms inline it (inlineEdit or ' + 'not); where none does, they do not, inlineEdit or not. `os validate` reports no new issue.', + relevantWhen: { kind: 'stack-declares', keys: ['objects', 'objectExtensions'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.navigation-mode-record-open-deprecated.ts b/packages/spec/src/migrations/entries/semantic/19.navigation-mode-record-open-deprecated.ts index 6dbe21767ed..29b30d942de 100644 --- a/packages/spec/src/migrations/entries/semantic/19.navigation-mode-record-open-deprecated.ts +++ b/packages/spec/src/migrations/entries/semantic/19.navigation-mode-record-open-deprecated.ts @@ -49,4 +49,5 @@ export const entry: SemanticMigration = { + '`navigation: { preventNavigation: true }` opens no record on any click on a desktop. A page ' + 'block declaring `navigation: { mode: \'page\' }` still opens the record page. No list view or ' + 'object `listViews` entry still declares `drawer`, `page` or `new_window`.', + relevantWhen: { kind: 'stack-declares', keys: ['views', 'viewItems', 'objects'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.object-extension-place-and-cross-package-lists.ts b/packages/spec/src/migrations/entries/semantic/19.object-extension-place-and-cross-package-lists.ts index af164009e14..a574aed00cd 100644 --- a/packages/spec/src/migrations/entries/semantic/19.object-extension-place-and-cross-package-lists.ts +++ b/packages/spec/src/migrations/entries/semantic/19.object-extension-place-and-cross-package-lists.ts @@ -45,4 +45,5 @@ export const entry: SemanticMigration = { + 'none; on an object that declares fieldGroups, a field an extension places shows in the named group ' + 'right after (before) the named member; an object that declares neither, and an extension that writes ' + 'no place, shows the same as before.', + relevantWhen: { kind: 'stack-declares', keys: ['objects', 'objectExtensions'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.object-grid-single-click-edit-retired.ts b/packages/spec/src/migrations/entries/semantic/19.object-grid-single-click-edit-retired.ts index eee36a1ff99..9342583d016 100644 --- a/packages/spec/src/migrations/entries/semantic/19.object-grid-single-click-edit-retired.ts +++ b/packages/spec/src/migrations/entries/semantic/19.object-grid-single-click-edit-retired.ts @@ -29,4 +29,5 @@ export const entry: SemanticMigration = { + 'Enter, F2 or typing that opens its editor, with each cell saved on its own and no "Save All". No ' + 'editable grid relies on `keyboardNavigation: false` to keep its cells separate Tab stops.', conversionIds: ['object-grid-single-click-edit-removed'], + relevantWhen: { kind: 'stack-declares', keys: ['pages'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.publish-refuses-data-model-fields-that-save-and-do-not-work.ts b/packages/spec/src/migrations/entries/semantic/19.publish-refuses-data-model-fields-that-save-and-do-not-work.ts index 93ebb27a1d9..f0ec21f3c7e 100644 --- a/packages/spec/src/migrations/entries/semantic/19.publish-refuses-data-model-fields-that-save-and-do-not-work.ts +++ b/packages/spec/src/migrations/entries/semantic/19.publish-refuses-data-model-fields-that-save-and-do-not-work.ts @@ -33,4 +33,5 @@ export const entry: SemanticMigration = { + 'as any warning does.', acceptanceCriteria: 'os validate reports neither error; a publish of every object the package carries succeeds.', + relevantWhen: { kind: 'stack-declares', keys: ['objects', 'objectExtensions'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.publish-refuses-flows-that-save-and-do-not-run.ts b/packages/spec/src/migrations/entries/semantic/19.publish-refuses-flows-that-save-and-do-not-run.ts index b7a29a56dfd..8bc2074dea1 100644 --- a/packages/spec/src/migrations/entries/semantic/19.publish-refuses-flows-that-save-and-do-not-run.ts +++ b/packages/spec/src/migrations/entries/semantic/19.publish-refuses-flows-that-save-and-do-not-run.ts @@ -49,4 +49,5 @@ export const entry: SemanticMigration = { acceptanceCriteria: 'os validate reports none of the seven errors it runs and no `flow-subflow-unknown` warning for a flow the ' + 'deployment lacks; a publish or package install of every flow the package carries succeeds.', + relevantWhen: { kind: 'stack-declares', keys: ['flows'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.publish-refuses-list-view-grouping-by-a-dotted-path.ts b/packages/spec/src/migrations/entries/semantic/19.publish-refuses-list-view-grouping-by-a-dotted-path.ts index 7ad25dc84f9..8034a8ca5f5 100644 --- a/packages/spec/src/migrations/entries/semantic/19.publish-refuses-list-view-grouping-by-a-dotted-path.ts +++ b/packages/spec/src/migrations/entries/semantic/19.publish-refuses-list-view-grouping-by-a-dotted-path.ts @@ -26,4 +26,5 @@ export const entry: SemanticMigration = { + 'fix named.', acceptanceCriteria: 'os validate reports no list-view-field-dotted error; a publish of every view and object the package carries succeeds.', + relevantWhen: { kind: 'stack-declares', keys: ['views', 'viewItems', 'objects'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.publish-refuses-list-view-grouping-the-engine-does-not-group-by.ts b/packages/spec/src/migrations/entries/semantic/19.publish-refuses-list-view-grouping-the-engine-does-not-group-by.ts index b694399da45..02d87919b89 100644 --- a/packages/spec/src/migrations/entries/semantic/19.publish-refuses-list-view-grouping-the-engine-does-not-group-by.ts +++ b/packages/spec/src/migrations/entries/semantic/19.publish-refuses-list-view-grouping-the-engine-does-not-group-by.ts @@ -25,4 +25,5 @@ export const entry: SemanticMigration = { + 'a grid grouping is refused with the fix named.', acceptanceCriteria: 'os validate reports no list-view-group-field-ungroupable error; a publish of every view and object the package carries succeeds.', + relevantWhen: { kind: 'stack-declares', keys: ['views', 'viewItems', 'objects'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.publish-refuses-metadata-the-runtime-ignores.ts b/packages/spec/src/migrations/entries/semantic/19.publish-refuses-metadata-the-runtime-ignores.ts index 57dad60c510..981ed02d6f4 100644 --- a/packages/spec/src/migrations/entries/semantic/19.publish-refuses-metadata-the-runtime-ignores.ts +++ b/packages/spec/src/migrations/entries/semantic/19.publish-refuses-metadata-the-runtime-ignores.ts @@ -34,4 +34,5 @@ export const entry: SemanticMigration = { 'os validate reports none of the four errors (`flow-node-type-no-executor` is judged only at publish, against the ' + 'deployment\'s sealed vocabulary) and no `flow-http-timeout-missing` warning; a publish of every flow, object and ' + 'action the package carries succeeds.', + relevantWhen: { kind: 'stack-declares', keys: ['flows', 'objects', 'objectExtensions', 'actions'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.publish-refuses-seeds-and-actions-that-save-and-do-not-work.ts b/packages/spec/src/migrations/entries/semantic/19.publish-refuses-seeds-and-actions-that-save-and-do-not-work.ts index 089e2e1dbb2..28429585a9e 100644 --- a/packages/spec/src/migrations/entries/semantic/19.publish-refuses-seeds-and-actions-that-save-and-do-not-work.ts +++ b/packages/spec/src/migrations/entries/semantic/19.publish-refuses-seeds-and-actions-that-save-and-do-not-work.ts @@ -39,4 +39,5 @@ export const entry: SemanticMigration = { acceptanceCriteria: 'os validate reports none of the three errors; a publish of every seed, flow, action and object the package carries ' + 'succeeds.', + relevantWhen: { kind: 'stack-declares', keys: ['data', 'flows', 'actions', 'objects'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.publish-refuses-views-and-dashboards-that-save-and-do-not-work.ts b/packages/spec/src/migrations/entries/semantic/19.publish-refuses-views-and-dashboards-that-save-and-do-not-work.ts index 93b756c40d5..4c706a884f8 100644 --- a/packages/spec/src/migrations/entries/semantic/19.publish-refuses-views-and-dashboards-that-save-and-do-not-work.ts +++ b/packages/spec/src/migrations/entries/semantic/19.publish-refuses-views-and-dashboards-that-save-and-do-not-work.ts @@ -28,4 +28,5 @@ export const entry: SemanticMigration = { + 'or object carrying such a filter is refused with the fix named; the warnings never refuse.', acceptanceCriteria: 'os validate reports no list-view-filter-field-virtual error; a publish of every view and object the package carries succeeds.', + relevantWhen: { kind: 'stack-declares', keys: ['views', 'viewItems', 'objects', 'dashboards', 'apps'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.refusal-reasons-list-literal-judged.ts b/packages/spec/src/migrations/entries/semantic/19.refusal-reasons-list-literal-judged.ts index 0a90b8bda7d..3b7860a1650 100644 --- a/packages/spec/src/migrations/entries/semantic/19.refusal-reasons-list-literal-judged.ts +++ b/packages/spec/src/migrations/entries/semantic/19.refusal-reasons-list-literal-judged.ts @@ -26,4 +26,5 @@ export const entry: SemanticMigration = { 'Every hook and `script` action that declares `refusals` saves (`os validate` reports no undeclared-reason issue ' + 'at `body.source`), and no run of it answers the 500 refusal-list fault: every thrown `reasons` key is a ' + 'non-empty list of reasons its code declares, with no `reason` beside it.', + relevantWhen: { kind: 'stack-declares', keys: ['hooks', 'actions', 'objects'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.related-lists-declared-is-tab-list.ts b/packages/spec/src/migrations/entries/semantic/19.related-lists-declared-is-tab-list.ts index 58c44527a0f..198b8def7e7 100644 --- a/packages/spec/src/migrations/entries/semantic/19.related-lists-declared-is-tab-list.ts +++ b/packages/spec/src/migrations/entries/semantic/19.related-lists-declared-is-tab-list.ts @@ -43,4 +43,5 @@ export const entry: SemanticMigration = { + 'listed related lists and built-in tabs in the listed order, then (if unlisted) approvals when the ' + 'record has requests and the activity stream last; an object that declares no relatedLists shows ' + 'the same tabs as before.', + relevantWhen: { kind: 'stack-declares', keys: ['objects', 'objectExtensions'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.seal-default-chain-column-refused.ts b/packages/spec/src/migrations/entries/semantic/19.seal-default-chain-column-refused.ts index 0fb3855297e..66cdfdb3ffe 100644 --- a/packages/spec/src/migrations/entries/semantic/19.seal-default-chain-column-refused.ts +++ b/packages/spec/src/migrations/entries/semantic/19.seal-default-chain-column-refused.ts @@ -36,4 +36,5 @@ export const entry: SemanticMigration = { + 'verifying one organization with --org reads the rows sealed before the change as late and unsealed ' + '(ADR-0154 D10 note); expect those findings for that object only. An object that had no tenant_id field had no ' + 'checkpoints, and verifies ok once it seals.', + relevantWhen: { kind: 'stack-declares', keys: ['objects'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.seed-key-blank-record-refused.ts b/packages/spec/src/migrations/entries/semantic/19.seed-key-blank-record-refused.ts index 364eb6a0e5b..fac5d5dff6a 100644 --- a/packages/spec/src/migrations/entries/semantic/19.seed-key-blank-record-refused.ts +++ b/packages/spec/src/migrations/entries/semantic/19.seed-key-blank-record-refused.ts @@ -32,4 +32,5 @@ export const entry: SemanticMigration = { 'Every seed record carries a value for each field of its dataset\'s `externalId`; after three restarts over the ' + 'same database each seeded object holds one row per record, and neither the boot log nor the seed load result ' + 'carries a blank-key seed refusal.', + relevantWhen: { kind: 'stack-declares', keys: ['data'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.seed-mode-insert-replace-retired.ts b/packages/spec/src/migrations/entries/semantic/19.seed-mode-insert-replace-retired.ts index cb0852a104b..d4bfe19b3c2 100644 --- a/packages/spec/src/migrations/entries/semantic/19.seed-mode-insert-replace-retired.ts +++ b/packages/spec/src/migrations/entries/semantic/19.seed-mode-insert-replace-retired.ts @@ -34,4 +34,5 @@ export const entry: SemanticMigration = { 'os validate reports no seed dataset whose `mode` is `insert` or `replace`; every dataset that declared one ' + 'declares `ignore` or `upsert` with an `externalId` naming fields its object has; after two restarts over the ' + 'same database the seeded object holds one row per record, and the boot log carries no seed-mode refusal.', + relevantWhen: { kind: 'stack-declares', keys: ['data'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.seed-record-refused-before-load.ts b/packages/spec/src/migrations/entries/semantic/19.seed-record-refused-before-load.ts index 31c528078f6..5adf4617fba 100644 --- a/packages/spec/src/migrations/entries/semantic/19.seed-record-refused-before-load.ts +++ b/packages/spec/src/migrations/entries/semantic/19.seed-record-refused-before-load.ts @@ -40,4 +40,5 @@ export const entry: SemanticMigration = { '`os validate` and `os build` exit 0 with no "Seed records the seed load refuses" block; after a boot the seed ' + 'load result carries no record dropped by a validation rule or refused for a blank key field, and `os verify` ' + 'reports no dropped seed row.', + relevantWhen: { kind: 'stack-declares', keys: ['data'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.seed-summary-value-not-stored.ts b/packages/spec/src/migrations/entries/semantic/19.seed-summary-value-not-stored.ts index 7e0058c83d2..b270e2eb2b3 100644 --- a/packages/spec/src/migrations/entries/semantic/19.seed-summary-value-not-stored.ts +++ b/packages/spec/src/migrations/entries/semantic/19.seed-summary-value-not-stored.ts @@ -40,4 +40,5 @@ export const entry: SemanticMigration = { 'No seed record supplies a value for a `summary` field: the boot log and a seed validation carry no roll-up ' + 'drop warning for any dataset, and every seeded roll-up equals the aggregate of its seeded child rows after the ' + 'first boot and after a restart.', + relevantWhen: { kind: 'stack-declares', keys: ['data'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.stack-residual-extension-registered-and-jobs-judged.ts b/packages/spec/src/migrations/entries/semantic/19.stack-residual-extension-registered-and-jobs-judged.ts index d8780c0d847..a490ec9f4fb 100644 --- a/packages/spec/src/migrations/entries/semantic/19.stack-residual-extension-registered-and-jobs-judged.ts +++ b/packages/spec/src/migrations/entries/semantic/19.stack-residual-extension-registered-and-jobs-judged.ts @@ -48,4 +48,5 @@ export const entry: SemanticMigration = { + 'finding "Job \'NAME\' is declared twice in jobs" or "Object extension of \'OBJECT\' is declared twice in ' + 'objectExtensions". The boot log carries no error saying a stack registers several extensions of one object ' + 'under one id, and every field of the residual extension is served on its target object.', + relevantWhen: { kind: 'stack-declares', keys: ['jobs', 'objectExtensions'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.transfer-cascade-never-offered-refused.ts b/packages/spec/src/migrations/entries/semantic/19.transfer-cascade-never-offered-refused.ts index 020d0fdfc0c..e45f147865b 100644 --- a/packages/spec/src/migrations/entries/semantic/19.transfer-cascade-never-offered-refused.ts +++ b/packages/spec/src/migrations/entries/semantic/19.transfer-cascade-never-offered-refused.ts @@ -41,4 +41,5 @@ export const entry: SemanticMigration = { 'Load every stack (`os validate` or `os build`): no `transfer-cascade-parent-without-change-owner`, ' + '`transfer-cascade-extension-child-ineligible` or `transfer-cascade-child-update-unexposed` finding. For a ' + 'cascade kept, GET /api/v1/data/PARENT/change-owner/cascades lists the relationship.', + relevantWhen: { kind: 'stack-declares', keys: ['objects', 'objectExtensions'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.translation-form-tails-move-to-forms.ts b/packages/spec/src/migrations/entries/semantic/19.translation-form-tails-move-to-forms.ts index 4900f8744a7..207169b71be 100644 --- a/packages/spec/src/migrations/entries/semantic/19.translation-form-tails-move-to-forms.ts +++ b/packages/spec/src/migrations/entries/semantic/19.translation-form-tails-move-to-forms.ts @@ -30,4 +30,5 @@ export const entry: SemanticMigration = { + '`os i18n check` passes; and each moved form shows its translated title and submit message in every ' + 'locale you ship.', conversionIds: ['translation-view-form-tails-to-forms'], + relevantWhen: { kind: 'stack-declares', keys: ['translations'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.translation-related-list-key-under-arrangement-refused.ts b/packages/spec/src/migrations/entries/semantic/19.translation-related-list-key-under-arrangement-refused.ts index bb0fc0f1c43..ed317977923 100644 --- a/packages/spec/src/migrations/entries/semantic/19.translation-related-list-key-under-arrangement-refused.ts +++ b/packages/spec/src/migrations/entries/semantic/19.translation-related-list-key-under-arrangement-refused.ts @@ -34,4 +34,5 @@ export const entry: SemanticMigration = { 'Run objectstack validate: no translation-target-unknown finding names an objects._relatedLists key. For ' + 'each key the finding named, either the key is gone, or the .custom arrangement\'s entry for that list ' + 'carries a label and the record page shows the translated title in that locale.', + relevantWhen: { kind: 'stack-declares', keys: ['translations'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.ui-action-type-ask-ai-retired.ts b/packages/spec/src/migrations/entries/semantic/19.ui-action-type-ask-ai-retired.ts index 7ceb9232197..29b01f591cd 100644 --- a/packages/spec/src/migrations/entries/semantic/19.ui-action-type-ask-ai-retired.ts +++ b/packages/spec/src/migrations/entries/semantic/19.ui-action-type-ask-ai-retired.ts @@ -34,4 +34,5 @@ export const entry: SemanticMigration = { + 'the stack does not define (`os validate` reports no `action-name-undefined` finding); every source ' + 'parses under the new schema.', conversionIds: ['action-type-ask-ai-removed'], + relevantWhen: { kind: 'stack-declares', keys: ['actions', 'objects', 'pages', 'dashboards'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.ui-form-view-modal-size-retired.ts b/packages/spec/src/migrations/entries/semantic/19.ui-form-view-modal-size-retired.ts index 00c06f1a0e9..175b965f429 100644 --- a/packages/spec/src/migrations/entries/semantic/19.ui-form-view-modal-size-retired.ts +++ b/packages/spec/src/migrations/entries/semantic/19.ui-form-view-modal-size-retired.ts @@ -34,4 +34,5 @@ export const entry: SemanticMigration = { + 'On an app that comes from 18.x, New and Edit on each object whose form carried the key open at a size ' + 'you accept.', conversionIds: ['form-view-modal-size-removed'], + relevantWhen: { kind: 'stack-declares', keys: ['views', 'viewItems', 'forms'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.ui-form-view-subforms-retired.ts b/packages/spec/src/migrations/entries/semantic/19.ui-form-view-subforms-retired.ts index 8819771f421..8b346b6d4d5 100644 --- a/packages/spec/src/migrations/entries/semantic/19.ui-form-view-subforms-retired.ts +++ b/packages/spec/src/migrations/entries/semantic/19.ui-form-view-subforms-retired.ts @@ -42,4 +42,5 @@ export const entry: SemanticMigration = { + '`relatedList` and New and Edit on that object draw the table where you want it, or you accept that its ' + 'rows are entered from the record\'s related list.', conversionIds: ['form-view-subforms-removed'], + relevantWhen: { kind: 'stack-declares', keys: ['views', 'viewItems', 'forms'] }, }; diff --git a/packages/spec/src/migrations/entries/semantic/19.validation-rule-message-template-holes.ts b/packages/spec/src/migrations/entries/semantic/19.validation-rule-message-template-holes.ts index 1a84d7209a3..66b1588c70b 100644 --- a/packages/spec/src/migrations/entries/semantic/19.validation-rule-message-template-holes.ts +++ b/packages/spec/src/migrations/entries/semantic/19.validation-rule-message-template-holes.ts @@ -32,4 +32,5 @@ export const entry: SemanticMigration = { + 'rule\'s `message` (`objects[N].validations[M].message`, `.then.message`, `objectExtensions[N].validations[M]' + '.message`) or at a `translations[N].LOCALE.objects.OBJECT._validations.RULE.message`. Trigger each rule whose ' + 'message you reworded and confirm the refusal reads as intended in every locale the bundle carries.', + relevantWhen: { kind: 'stack-declares', keys: ['objects', 'objectExtensions', 'translations'] }, }; diff --git a/packages/spec/src/migrations/semantic-relevance-coverage-38929.test.ts b/packages/spec/src/migrations/semantic-relevance-coverage-38929.test.ts new file mode 100644 index 00000000000..fe42364540f --- /dev/null +++ b/packages/spec/src/migrations/semantic-relevance-coverage-38929.test.ts @@ -0,0 +1,596 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * Relevance COVERAGE of the migration chain, from protocol 19 on, and why a + * question stays open. + * + * `os migrate meta --from 18` hands a two-object app every protocol-19 manual + * notice unless an entry carries a structured `relevantWhen` question the + * stack can answer `absent` (ADR-0087 D3, "never silence": the one exit, and + * never a match against the prose of `surface`). So every entry from + * protocol 19 on is in exactly one of two places: + * + * - it carries `relevantWhen` (enumerated, keys and all, by the reviewed + * table of `semantic-relevance.test.ts`); or + * - it is on {@link STAYS_LISTED} below, which says why no question over the + * stack can judge it: its surface is host code, or a deployment's own state + * and doors, or something every stack carries. + * + * An entry in neither place is NAMED: its id is printed on a warning line in + * every run's output (and carried by a `todo` with what to do), and it fails + * nothing. That is how an entry that lands later is judged and not + * broken: the coverage enumerates the registry, never a list or a count of + * today's entries, so a new entry file shows up in every run's output on the + * day it lands, and a red would instead stop a pull that never touched this + * file. What does fail is what the reviewed tables state: an entry on + * STAYS_LISTED that carries a question, a row naming no registered entry, a + * row with no class or reason; and the enumeration of + * `semantic-relevance.test.ts` fails when an entry gains, loses or changes a + * question. + * + * SITES pins the keys by behaviour: for every place a protocol-19 surface can + * be authored (an action an object carries inline, a field an extension adds, + * a seed under the stack's own `manifest.data`, …), a stack carrying only that + * site must not prove the entries written there absent. The table is written + * from where the schemas embed each shape, not from the entries' key lists, so + * a key left out of an entry and out of its enumeration row still goes red. + * + * The second half pins why a question stays open (`MigrationChainResult.unanswered`): + * a stack listing a plugin answers `unknown`, and the result names the + * entries and what could not be read, so the printer can say why they are + * still listed. And it pins the acceptance shapes: the blank template's stack + * (no `plugins:`) proves `agents` and `knowledgeSources` absent; the 18.6.0 + * template's stack (three connector plugins) cannot, and says so. + */ + +import { describe, expect, it, vi } from 'vitest'; + +import { normalizeStackInput } from '../shared/metadata-collection.zod.js'; +import { applyMetaMigrations, semanticRelevanceVerdict } from './chain.js'; +import { MIGRATIONS_BY_MAJOR, MIGRATION_MAJORS } from './registry.js'; +import type { MigrationChainResult, SemanticRelevance } from './types.js'; + +/** The first major whose every entry this coverage judges. */ +const COVERAGE_FROM_MAJOR = 19; + +/** + * Why an entry carries no question: + * + * - `code` — the surface is host code (an import, an exported helper or + * schema, a service interface, a React prop, or a source registered through + * one), which no stack key carries; + * - `deployment` — the surface is a deployment's own state or doors (rows it + * stores, the packages it installs and which of them hold a name, a save, a + * read or a grant at run time), or the entry's check is run against the + * rows a deployment stores — none of which the stack shows; + * - `every-stack` — the surface is something every stack carries, so no + * stack can prove it absent. + */ +type StaysListedClass = 'code' | 'deployment' | 'every-stack'; + +/** `major:id` → why the entry is listed whatever the stack holds. */ +const STAYS_LISTED: Readonly> = { + '19:ai-build-progress-frame-retired': { class: 'code', why: 'host code importing six exported names' }, + '19:ai-context-package-scoped-name': { + class: 'deployment', + why: 'a context-pack name the installed packages hold, read and written by name at run time', + }, + '19:ai-pending-action-queue-merged-into-confirmation-service': { + class: 'code', + why: 'service interface members a host implements or calls', + }, + '19:bare-write-beside-disabled-row-refused-naming-shippers': { + class: 'deployment', + why: 'a write that names no package beside rows of installed, disabled packages', + }, + '19:bundle-without-canonical-member-bare-read-absent': { + class: 'deployment', + why: 'a read by name of a bundle member an address does or does not hold', + }, + '19:chart-series-measure-format-carrier-refused': { + class: 'code', + why: 'a static SDUI node of the UI types package and its TypeScript twin, not a stack schema', + }, + '19:data-table-staged-edit-retired': { class: 'code', why: 'host component props and a renderer schema' }, + '19:define-form-studio-helper-renamed-define-metadata-form': { + class: 'code', + why: 'an exported helper renamed, and the module suffix of its callers', + }, + '19:disabled-holder-package-less-row-bare-read-judged-as-absent': { + class: 'deployment', + why: 'a read that names no package, judged against installed packages and stored rows', + }, + '19:disabled-holder-package-less-row-bare-write-refused': { + class: 'deployment', + why: 'a write that names no package, judged against installed packages and stored rows', + }, + '19:doc-bare-read-environment-entry-first': { + class: 'deployment', + why: 'a read of a doc beside the environment\'s own stored row of its name', + }, + '19:environment-action-on-another-object-answers-first': { + class: 'deployment', + why: 'a read of an action beside the environment\'s own stored row of its name', + }, + '19:flow-variable-key-reserved-segment-refused': { + class: 'deployment', + why: 'its check is `os migrate meta --stored` over the flows a deployment stores, and a run\'s resume signal', + }, + '19:form-type-define-form-and-packageless-list-at-form-name': { + class: 'code', + why: 'an exported helper, and a package-less view write at run time', + }, + '19:hydrated-doc-row-wears-no-holder-envelope': { + class: 'deployment', + why: 'a read after a restart of stored rows beside installed packages', + }, + '19:knowledge-chunk-metadata-retired': { class: 'code', why: 'an adapter\'s chunk literals' }, + '19:knowledge-search-uncoded-adapter-throw-refused': { + class: 'code', + why: 'what an adapter throws at search time', + }, + '19:knowledge-source-content-lists-fields': { + class: 'code', + why: 'a source registered in code (the service plugin\'s sources, the service\'s registerSource) too', + }, + '19:knowledge-source-file-http-kinds-retired': { + class: 'code', + why: 'host code calling the service\'s indexDocument / deleteDocument too', + }, + '19:knowledge-source-inert-keys-retired': { + class: 'code', + why: 'a source registered in code, and exported schemas, too', + }, + '19:knowledge-source-registration-governed': { class: 'code', why: 'a source registered in code' }, + '19:knowledge-source-save-refused-while-knowledge-service-not-enabled': { + class: 'deployment', + why: 'an author\'s save at run time on a deployment with no embedder or store', + }, + '19:knowledge-source-save-refused-without-knowledge-service': { + class: 'deployment', + why: 'an author\'s save at run time on a deployment whose stack declares no knowledge — the surface is the absence', + }, + '19:knowledge-source-unmounted-adapter-refused-at-save': { + class: 'deployment', + why: 'an author\'s save at run time naming an adapter the deployment does not mount', + }, + '19:non-pair-custom-arrangement-refused': { + class: 'deployment', + why: 'a `.custom` package\'s extension at the save, publish and install doors; `os validate` does not judge it', + }, + '19:package-less-action-row-judged-at-its-key': { + class: 'deployment', + why: 'a read of an action beside installed packages and a stored package-less row', + }, + '19:packages-adopt-orphans-door-retired': { class: 'code', why: 'a REST door and the client method that calls it' }, + '19:permission-view-all-modify-all-cast-no-field-vote': { + class: 'deployment', + why: 'its check covers every permission set the deployment stores, which no conversion rewrites', + }, + '19:protocol-18-range-refused': { + class: 'every-stack', + why: 'the manifest\'s protocol range — every stack has a manifest — and every installed package\'s', + }, + '19:publish-refuses-object-draft-the-current-schema-refuses': { + class: 'deployment', + why: 'the publish of a stored object draft', + }, + '19:record-currency-sibling-extension-judged-as-served': { + class: 'deployment', + why: 'saves, installs and reloads on a running server; not the cold boot a stack makes', + }, + '19:seed-object-unknown-refused': { class: 'deployment', why: 'a seed saved through the metadata save door' }, + '19:self-registration-permission-set-reaches-invited-sign-ups': { + class: 'deployment', + why: 'the deployment\'s sign-up posture and its pending invitations', + }, + '19:share-user-recipient-unresolved-refused': { + class: 'deployment', + why: 'a share or a sharing rule written at run time', + }, + '19:stack-package-duplicate-entry-refused-at-every-door': { + class: 'every-stack', + why: 'a duplicate in any named collection of a composed package: no key set narrower than the whole stack', + }, + '19:view-column-state-retired': { class: 'deployment', why: 'stored view rows only' }, + '19:view-forms-move-to-form-type': { + class: 'deployment', + why: 'its check previews the deployment\'s protocol switch over the forms it stores', + }, +}; + +const STAYS_LISTED_CLASSES: readonly StaysListedClass[] = ['code', 'deployment', 'every-stack']; + +/** Every registered entry from {@link COVERAGE_FROM_MAJOR} on, keyed `major:id`. */ +const COVERED = MIGRATION_MAJORS.filter((m) => m >= COVERAGE_FROM_MAJOR).flatMap((major) => + MIGRATIONS_BY_MAJOR[major]!.semantic.map((entry) => ({ key: `${major}:${entry.id}`, entry })), +); + +/** The entries from protocol 19 on that carry no question and are not on {@link STAYS_LISTED}. */ +const UNJUDGED = COVERED.filter(({ key, entry }) => !entry.relevantWhen && !(key in STAYS_LISTED)).map( + ({ key }) => key, +); + +/** Prints the entries no question judges yet, one id per line, so every run's output names them. */ +function reportUnjudged(keys: readonly string[]): void { + if (keys.length === 0) return; + console.warn( + `semantic relevance coverage: ${keys.length} entr${keys.length === 1 ? 'y' : 'ies'} from protocol ` + + `${COVERAGE_FROM_MAJOR} on carr${keys.length === 1 ? 'ies' : 'y'} no relevantWhen and ` + + `${keys.length === 1 ? 'is' : 'are'} not on STAYS_LISTED:\n${keys.map((k) => ` - ${k}`).join('\n')}`, + ); +} + +describe('entries no question judges yet: each named in the run\'s output, none failed (COVERAGE, report)', () => { + // Each entry named here is listed to every stack, whatever it holds. If its + // surface is authored metadata under top-level stack keys, give it + // `relevantWhen: { kind: 'stack-declares', keys: [...] }` naming every key it + // can be written under (its row in semantic-relevance.test.ts, and a site in + // SITES below); otherwise add it to STAYS_LISTED, with why no question over + // the stack can judge it. Not a red: the pull that lands such an entry never + // touched this file. + it('prints the id of every entry no question judges yet', () => { + // The spy calls through, so the report reaches the run's output. + const warn = vi.spyOn(console, 'warn'); + try { + reportUnjudged(UNJUDGED); + const printed = warn.mock.calls.map((call) => String(call[0])).join('\n'); + for (const key of UNJUDGED) expect(printed).toContain(key); + if (UNJUDGED.length === 0) expect(warn).not.toHaveBeenCalled(); + } finally { + warn.mockRestore(); + } + }); + for (const key of UNJUDGED) { + it.todo(`${key}: carries no relevantWhen and is not on STAYS_LISTED — give it a question or a row`); + } +}); + +describe('every entry from protocol 19 on is judged for relevance (COVERAGE)', () => { + it('an entry on the table carries no question: one that gains a question leaves the table', () => { + const both = COVERED.filter(({ key, entry }) => entry.relevantWhen && key in STAYS_LISTED).map(({ key }) => key); + expect(both).toEqual([]); + }); + + it('the table names only registered entries, each with a class and a reason', () => { + const registered = new Set(COVERED.map(({ key }) => key)); + expect(Object.keys(STAYS_LISTED).filter((k) => !registered.has(k))).toEqual([]); + for (const [key, row] of Object.entries(STAYS_LISTED)) { + expect(STAYS_LISTED_CLASSES, key).toContain(row.class); + expect(row.why.trim().length, key).toBeGreaterThan(0); + } + }); + + it('anti-vacuity: the coverage reads a non-empty population holding both kinds', () => { + expect(COVERED.some(({ entry }) => entry.relevantWhen)).toBe(true); + expect(COVERED.some(({ key }) => key in STAYS_LISTED)).toBe(true); + }); +}); + +const ids = (todos: MigrationChainResult['todos']) => todos.map((t) => `${t.toMajor}:${t.id}`); + +/** A manifest that declares no collection of its own. */ +const BARE_MANIFEST = { id: 'com.example.site', name: 'Site', version: '1.0.0', type: 'app' }; + +/** Ids of protocol-19 entries, without the `19:` prefix, for the site table below. */ +const ACTION_BODY = [ + 'action-body-regexp-literal-token-refused', + 'body-regexp-pattern-refused', + 'hook-action-body-system-identity-assignment-update-by-id-refused', + 'hook-and-action-bodies-calling-an-ungranted-gate-refused', + 'lowered-hook-and-action-bodies-capabilities-judged', + 'refusal-reasons-list-literal-judged', + 'publish-refuses-seeds-and-actions-that-save-and-do-not-work', +]; +const ACTION_TYPE = ['ui-action-type-ask-ai-retired', 'action-locations-page-parts-retired', 'cel-list-equality-refused']; +const LIST_VIEW = [ + 'navigation-mode-record-open-deprecated', + 'publish-refuses-list-view-grouping-by-a-dotted-path', + 'publish-refuses-list-view-grouping-the-engine-does-not-group-by', + 'publish-refuses-views-and-dashboards-that-save-and-do-not-work', + 'view-bulk-actions-declared-on-the-action', +]; +const FORM_VIEW = ['internal-record-forms-not-loaded', 'ui-form-view-modal-size-retired', 'ui-form-view-subforms-retired']; +const FIELD = [ + 'field-inline-edit-boolean-retired', + 'lookup-depends-on-param-computed-field-refused', + 'lookup-depends-on-param-computed-field-refused-on-tree', + 'lookup-filter-record-path-structured-refused', + 'master-detail-related-list-tab-by-default', + 'transfer-cascade-never-offered-refused', + 'publish-refuses-data-model-fields-that-save-and-do-not-work', + 'cel-list-equality-refused', +]; +const ARRANGEMENT = [ + 'field-group-shadowed-six-highlights', + 'related-lists-declared-is-tab-list', + 'object-extension-place-and-cross-package-lists', +]; +const VALIDATION = [ + 'validation-rule-message-template-holes', + 'cel-list-equality-refused', + 'publish-refuses-metadata-the-runtime-ignores', +]; +const SEED = [ + 'seed-key-blank-record-refused', + 'seed-mode-insert-replace-retired', + 'seed-record-refused-before-load', + 'seed-summary-value-not-stored', + 'publish-refuses-seeds-and-actions-that-save-and-do-not-work', +]; +const seed = { object: 'site_thing', mode: 'upsert', externalId: 'name', records: [{ name: 'a' }] }; + +/** + * Every place a protocol-19 surface can be authored, as a stack that carries + * it and nothing else, with the entries whose surface can be written there. + * Written from the schemas (where a shape is embedded), never from an entry's + * `relevantWhen`, so a key missing from an entry's list AND from its row in + * `semantic-relevance.test.ts` still goes red here: such a stack must never + * prove the entry absent. + */ +const SITES: ReadonlyArray<{ site: string; stack: Record; entries: readonly string[] }> = [ + { + site: 'objects[].actions (an action an object carries inline)', + stack: { objects: [{ name: 'site_thing', actions: [{ name: 'run', type: 'script' }] }] }, + entries: [...ACTION_BODY, ...ACTION_TYPE], + }, + { + site: 'objects[].listViews', + stack: { objects: [{ name: 'site_thing', listViews: { all: { label: 'All' } } }] }, + entries: LIST_VIEW, + }, + { + site: 'objects[] fields, fieldGroups, relatedLists, lifecycle', + stack: { objects: [{ name: 'site_thing', fields: { title: { type: 'text' } } }] }, + entries: [...FIELD, ...ARRANGEMENT, 'seal-default-chain-column-refused'], + }, + { + site: 'objects[].validations', + stack: { objects: [{ name: 'site_thing', validations: [{ name: 'v' }] }] }, + entries: VALIDATION, + }, + { + site: 'objectExtensions[] fields, fieldGroups, relatedLists, place', + stack: { objectExtensions: [{ extend: 'site_thing', fields: { extra: { type: 'text' } } }] }, + entries: [...FIELD, ...ARRANGEMENT], + }, + { + site: 'objectExtensions[].validations', + stack: { objectExtensions: [{ extend: 'site_thing', validations: [{ name: 'v' }] }] }, + entries: VALIDATION, + }, + { site: 'actions[] (a standalone action)', stack: { actions: [{ name: 'run', type: 'script' }] }, entries: [...ACTION_BODY, ...ACTION_TYPE, 'publish-refuses-metadata-the-runtime-ignores'] }, + { site: 'views[] (a list view, a form view)', stack: { views: [{ name: 'v' }] }, entries: [...LIST_VIEW, ...FORM_VIEW] }, + { site: 'viewItems[]', stack: { viewItems: [{ name: 'v' }] }, entries: [...LIST_VIEW.slice(0, 4), ...FORM_VIEW] }, + { site: 'forms[]', stack: { forms: [{ name: 'site_thing.form' }] }, entries: FORM_VIEW }, + { + site: 'pages[] components', + stack: { pages: [{ name: 'p' }] }, + entries: ['action-locations-page-parts-retired', 'object-grid-single-click-edit-retired', 'ui-action-type-ask-ai-retired', 'view-bulk-actions-declared-on-the-action', 'cel-list-equality-refused'], + }, + { site: 'dashboards[] (a header action)', stack: { dashboards: [{ name: 'd' }] }, entries: ['ui-action-type-ask-ai-retired', 'publish-refuses-views-and-dashboards-that-save-and-do-not-work'] }, + { site: 'apps[]', stack: { apps: [{ name: 'a' }] }, entries: ['publish-refuses-views-and-dashboards-that-save-and-do-not-work'] }, + { + site: 'hooks[]', + stack: { hooks: [{ name: 'h' }] }, + entries: [ + 'body-regexp-pattern-refused', + 'hook-action-body-system-identity-assignment-update-by-id-refused', + 'hook-and-action-bodies-calling-an-ungranted-gate-refused', + 'lowered-hook-and-action-bodies-capabilities-judged', + 'refusal-reasons-list-literal-judged', + 'hook-action-text-key-optional-call-refused', + 'hook-job-body-does-not-compile-refused', + 'cel-list-equality-refused', + ], + }, + { + site: 'jobs[]', + stack: { jobs: [{ name: 'j' }] }, + entries: ['body-regexp-pattern-refused', 'hook-job-body-does-not-compile-refused', 'compose-stacks-job-name-across-packages-refused', 'stack-residual-extension-registered-and-jobs-judged'], + }, + { + site: 'flows[]', + stack: { flows: [{ name: 'f' }] }, + entries: [ + 'flow-concurrent-branch-durable-pause-refused', + 'flow-condition-bare-ordering-before-record-date-arithmetic-refused', + 'flow-condition-mixed-or-index-spelling-date-text-refused', + 'flow-condition-record-date-arithmetic-refused', + 'flow-dotted-write-read-by-run-expressions-only', + 'flow-sequential-branch-durable-pause-refused', + 'publish-refuses-flows-that-save-and-do-not-run', + 'publish-refuses-metadata-the-runtime-ignores', + 'publish-refuses-seeds-and-actions-that-save-and-do-not-work', + 'cel-list-equality-refused', + ], + }, + { site: 'sharingRules[]', stack: { sharingRules: [{ name: 's' }] }, entries: ['cel-list-equality-refused'] }, + { site: 'permissions[]', stack: { permissions: [{ name: 'p' }] }, entries: ['cel-list-equality-refused'] }, + { site: 'data[] (a seed dataset)', stack: { data: [seed] }, entries: SEED }, + { + site: 'manifest.data (a seed dataset the stack\'s own manifest declares)', + stack: { manifest: { ...BARE_MANIFEST, data: [seed] } }, + entries: SEED, + }, + { site: 'packages[].manifest.data', stack: { packages: [{ manifest: { ...BARE_MANIFEST, data: [seed] } }] }, entries: SEED }, + { + site: 'translations[]', + stack: { translations: [{ en: {} }] }, + entries: ['translation-form-tails-move-to-forms', 'translation-related-list-key-under-arrangement-refused', 'validation-rule-message-template-holes'], + }, + { site: 'mappings[]', stack: { mappings: [{ name: 'm' }] }, entries: ['incremental-source-delete-policy-stated'] }, + { site: 'books[]', stack: { books: [{ name: 'b' }] }, entries: ['book-audience-two-gates-and-catch-all-claim-refused'] }, + { site: 'requires (a knowledge capability)', stack: { requires: ['knowledge'] }, entries: ['knowledge-service-held-without-embedder-or-store'] }, + { + site: 'knowledgeSources[]', + stack: { knowledgeSources: [{ name: 'k' }] }, + entries: ['knowledge-service-held-without-embedder-or-store', 'knowledge-source-publish-refuses-missing-references-and-gated-objects'], + }, + { site: 'agents[]', stack: { agents: [{ name: 'a' }] }, entries: ['agent-model-provider-retired'] }, +]; + +const BY_KEY = new Map(COVERED.map(({ key, entry }) => [key, entry])); + +describe('a stack carrying a surface at any one site it can be authored is never proven absent (SITES)', () => { + for (const { site, stack, entries } of SITES) { + it(site, () => { + const withManifest = { manifest: BARE_MANIFEST, ...stack }; + for (const id of entries) { + const entry = BY_KEY.get(`19:${id}`); + expect(entry, `19:${id} is registered`).toBeDefined(); + if (!entry!.relevantWhen) continue; // listed to every stack: nothing to prove + expect(semanticRelevanceVerdict(entry!.relevantWhen, [withManifest]), `19:${id} at ${site}`).not.toBe('absent'); + } + }); + } + + it('every protocol-19 entry that carries a question is pinned at one site or more', () => { + const pinned = new Set(SITES.flatMap(({ entries }) => entries.map((id) => `19:${id}`))); + const unpinned = COVERED.filter(({ key, entry }) => key.startsWith('19:') && entry.relevantWhen && !pinned.has(key)); + expect(unpinned.map(({ key }) => key)).toEqual([]); + }); + + it('anti-vacuity: a stack with no site proves every seed entry absent', () => { + for (const id of SEED.slice(0, 4)) { + expect(semanticRelevanceVerdict(BY_KEY.get(`19:${id}`)!.relevantWhen!, [{ manifest: BARE_MANIFEST }]), id).toBe('absent'); + } + }); +}); + +describe('seeds the stack\'s own manifest declares keep their notices, through the command\'s load pass (CHAIN)', () => { + it('a stack whose only seed site is manifest.data names no seed entry absent', () => { + const stack = normalizeStackInput( + { + manifest: { ...BARE_MANIFEST, data: [{ ...seed, mode: 'insert' }] }, + objects: [{ name: 'site_thing', label: 'Thing', fields: { name: { type: 'text', label: 'Name' } } }], + }, + { convert: false }, + ); + expect((stack as Record).data).toBeUndefined(); // the load pass does not lift it: the evaluator must read it where it is + const result = applyMetaMigrations(stack, 18, 19); + for (const id of SEED) expect(ids(result.absentTodos), id).not.toContain(`19:${id}`); + for (const id of SEED) expect(ids(result.todos), id).toContain(`19:${id}`); + }); +}); + +/** The stack the blank template authors: collections from its barrels, no `plugins:`. */ +const BLANK_TEMPLATE_STACK = { + manifest: { + id: 'com.example.blank', + namespace: 'blank', + version: '0.1.0', + type: 'app', + name: 'Blank Starter', + engines: { protocol: '^18' }, + }, + requires: ['automation', 'triggers'], + objects: [ + { name: 'company', label: 'Company', fields: { name: { type: 'text', label: 'Name' } } }, + { name: 'contact', label: 'Contact', fields: { name: { type: 'text', label: 'Name' } } }, + ], + views: [], + actions: [], + flows: [], + dashboards: [], + apps: [{ name: 'blank_app', label: 'Blank' }], + skills: [], + picklists: [], + permissions: [], + datasets: [], +}; + +/** A plugin instance, as the 18.6.0 template's `new ConnectorRestPlugin()` hands one over. */ +class ConnectorLikePlugin { + name = 'com.example.connector'; +} + +const AGENT_ENTRY = '19:agent-model-provider-retired'; +const KNOWLEDGE_ENTRY = '19:knowledge-source-publish-refuses-missing-references-and-gated-objects'; + +describe('the blank template proves agents and knowledge sources absent; a plugin says why it cannot (ACCEPTANCE)', () => { + const run = (stack: Record) => applyMetaMigrations(stack, 18, 19); + + it('the blank template\'s stack names both notices absent, and leaves no question open', () => { + const result = run(BLANK_TEMPLATE_STACK); + expect(ids(result.absentTodos)).toEqual(expect.arrayContaining([AGENT_ENTRY, KNOWLEDGE_ENTRY])); + // Anti-vacuity: notices about what it does author stay listed. + expect(ids(result.absentTodos)).not.toContain('19:field-group-shadowed-six-highlights'); + expect(result.unanswered).toBeUndefined(); + }); + + it('a stack that declares an agent and a knowledge source keeps both notices (control)', () => { + const result = run({ + ...BLANK_TEMPLATE_STACK, + agents: [{ name: 'helper', label: 'Helper' }], + knowledgeSources: [{ name: 'kb', label: 'KB' }], + }); + expect(ids(result.todos)).toEqual(expect.arrayContaining([AGENT_ENTRY, KNOWLEDGE_ENTRY])); + expect(ids(result.absentTodos)).not.toContain(AGENT_ENTRY); + expect(ids(result.absentTodos)).not.toContain(KNOWLEDGE_ENTRY); + }); + + it('the 18.6.0 template\'s stack (three connector plugins) proves nothing absent, and names why', () => { + const plugins = [new ConnectorLikePlugin(), new ConnectorLikePlugin(), new ConnectorLikePlugin()]; + const result = run({ ...BLANK_TEMPLATE_STACK, plugins }); + expect(result.absentTodos).toEqual([]); + expect(result.unanswered).toBeDefined(); + expect(ids(result.unanswered!.todos)).toEqual(expect.arrayContaining([AGENT_ENTRY, KNOWLEDGE_ENTRY])); + expect(result.unanswered!.unread).toEqual(['plugins']); + }); + + it('names only the entries whose question stayed open, as the same objects, in chain order', () => { + const result = run({ ...BLANK_TEMPLATE_STACK, plugins: [new ConnectorLikePlugin()] }); + const open = result.unanswered!.todos; + for (const t of open) { + expect(result.todos.includes(t), `${t.id} is the todos object`).toBe(true); + expect(t.relevantWhen, `${t.id} carries a question`).toBeDefined(); + } + const position = new Map(result.todos.map((t, i) => [t, i])); + const at = open.map((t) => position.get(t)!); + expect(at).toEqual(at.slice().sort((a, b) => a - b)); + // A question the stack visibly answers `present` (it declares objects) is not open. + expect(ids(open)).not.toContain('19:field-group-shadowed-six-highlights'); + }); + + it('a value the question cannot read is named by its key; a tier preset by `tiers`', () => { + const unreadable = run({ ...BLANK_TEMPLATE_STACK, agents: () => [] }); + expect(ids(unreadable.unanswered!.todos)).toContain(AGENT_ENTRY); + expect(unreadable.unanswered!.unread).toEqual(['agents']); + expect(ids(unreadable.absentTodos)).toContain(KNOWLEDGE_ENTRY); + + const tiered = run({ ...BLANK_TEMPLATE_STACK, tiers: ['ai'] }); + expect(tiered.unanswered!.unread).toEqual(['tiers']); + }); +}); + +describe('what an unknown answer could not read (EVALUATION)', () => { + const q = { kind: 'stack-declares', keys: ['agents'] } as unknown as SemanticRelevance; + + it('collects only when the answer is unknown', () => { + const unread = new Set(); + expect(semanticRelevanceVerdict(q, [{}], unread)).toBe('absent'); + expect(semanticRelevanceVerdict(q, [{ agents: [{}], plugins: ['x'] }], unread)).toBe('present'); + expect([...unread]).toEqual([]); + expect(semanticRelevanceVerdict(q, [{ plugins: ['x'] }], unread)).toBe('unknown'); + expect([...unread]).toEqual(['plugins']); + }); + + it('names a package body by its position, and a stack that is not a plain object as `(stack)`', () => { + const unread = new Set(); + expect( + semanticRelevanceVerdict(q, [{ packages: [{ manifest: { id: 'a' } }, 'b', { manifest: { agents: 'x' } }] }], unread), + ).toBe('unknown'); + expect([...unread]).toEqual(['packages[1]', 'packages[2].manifest.agents']); + + const other = new Set(); + expect(semanticRelevanceVerdict(q, [[]], other)).toBe('unknown'); + expect([...other]).toEqual(['(stack)']); + }); + + it('over several checkpoints, a checkpoint that answered present leaves nothing to explain', () => { + const unread = new Set(); + expect(semanticRelevanceVerdict(q, [{ plugins: ['x'] }, { agents: [{}] }], unread)).toBe('present'); + expect([...unread]).toEqual([]); + }); +}); diff --git a/packages/spec/src/migrations/semantic-relevance.test.ts b/packages/spec/src/migrations/semantic-relevance.test.ts index 6384d8fb055..a359eb52cee 100644 --- a/packages/spec/src/migrations/semantic-relevance.test.ts +++ b/packages/spec/src/migrations/semantic-relevance.test.ts @@ -28,11 +28,21 @@ import { MIGRATIONS_BY_MAJOR, MIGRATION_MAJORS, MIGRATION_SUPPORT_FLOOR } from ' import type { MigrationTodo, SemanticRelevance } from './types.js'; /** - * The first batch: the entries whose surface lives ONLY under the named - * top-level stack keys — no runtime request body, no code door (a direct - * caller of an exported evaluator or compiler) — and whose acceptance criteria - * send the author to no stored row and no runtime door. `major:id` → the keys - * its question names. + * The entries that carry a question, `major:id` → the keys it names. + * + * Protocols 17 and 18 (the first batch): the entries whose surface lives ONLY + * under the named top-level stack keys — no runtime request body, no code door + * (a direct caller of an exported evaluator or compiler) — and whose + * acceptance criteria send the author to no stored row and no runtime door. + * + * Protocol 19 on: every entry whose surface is authored metadata under + * top-level stack keys, each key it can be written under named (a key too + * many keeps a notice listed; a key missing would prove it absent wrongly). A + * refusal or a change of meaning that a stored copy of the same metadata meets + * too still counts: the printer says that the proof covers the stack it + * loaded and not what a deployment stores. Every entry that carries no + * question is on the reviewed STAYS_LISTED table of + * `semantic-relevance-coverage-38929.test.ts`, with why. */ const EXPECTED_RELEVANCE: Readonly> = { '17:dashboard-widget-compareto-offset': ['dashboards'], @@ -62,9 +72,61 @@ const EXPECTED_RELEVANCE: Readonly> = { '18:job-timeout-unit-in-key': ['jobs'], '18:mapping-lookup-params-retired': ['mappings'], '18:permission-restore-purge-bits-retired': ['permissions'], + '19:action-body-regexp-literal-token-refused': ['actions', 'objects'], '19:action-locations-page-parts-retired': ['actions', 'objects', 'pages'], '19:agent-model-provider-retired': ['agents'], + '19:body-regexp-pattern-refused': ['actions', 'objects', 'hooks', 'jobs'], + '19:book-audience-two-gates-and-catch-all-claim-refused': ['books'], + '19:cel-list-equality-refused': + ['objects', 'objectExtensions', 'actions', 'pages', 'hooks', 'sharingRules', 'permissions', 'flows'], + '19:compose-stacks-job-name-across-packages-refused': ['jobs'], + '19:field-group-shadowed-six-highlights': ['objects', 'objectExtensions'], + '19:field-inline-edit-boolean-retired': ['objects', 'objectExtensions'], + '19:flow-concurrent-branch-durable-pause-refused': ['flows'], + '19:flow-condition-bare-ordering-before-record-date-arithmetic-refused': ['flows'], + '19:flow-condition-mixed-or-index-spelling-date-text-refused': ['flows'], + '19:flow-condition-record-date-arithmetic-refused': ['flows'], + '19:flow-dotted-write-read-by-run-expressions-only': ['flows'], + '19:flow-sequential-branch-durable-pause-refused': ['flows'], + '19:hook-action-body-system-identity-assignment-update-by-id-refused': ['hooks', 'actions', 'objects'], + '19:hook-action-text-key-optional-call-refused': ['hooks'], + '19:hook-and-action-bodies-calling-an-ungranted-gate-refused': ['hooks', 'actions', 'objects'], + '19:hook-job-body-does-not-compile-refused': ['hooks', 'jobs'], + '19:incremental-source-delete-policy-stated': ['mappings'], + '19:internal-record-forms-not-loaded': ['views', 'viewItems', 'forms'], + '19:knowledge-service-held-without-embedder-or-store': ['knowledgeSources', 'requires'], '19:knowledge-source-publish-refuses-missing-references-and-gated-objects': ['knowledgeSources'], + '19:lookup-depends-on-param-computed-field-refused': ['objects', 'objectExtensions'], + '19:lookup-depends-on-param-computed-field-refused-on-tree': ['objects', 'objectExtensions'], + '19:lookup-filter-record-path-structured-refused': ['objects', 'objectExtensions'], + '19:lowered-hook-and-action-bodies-capabilities-judged': ['hooks', 'actions', 'objects'], + '19:master-detail-related-list-tab-by-default': ['objects', 'objectExtensions'], + '19:navigation-mode-record-open-deprecated': ['views', 'viewItems', 'objects'], + '19:object-extension-place-and-cross-package-lists': ['objects', 'objectExtensions'], + '19:object-grid-single-click-edit-retired': ['pages'], + '19:publish-refuses-data-model-fields-that-save-and-do-not-work': ['objects', 'objectExtensions'], + '19:publish-refuses-flows-that-save-and-do-not-run': ['flows'], + '19:publish-refuses-list-view-grouping-by-a-dotted-path': ['views', 'viewItems', 'objects'], + '19:publish-refuses-list-view-grouping-the-engine-does-not-group-by': ['views', 'viewItems', 'objects'], + '19:publish-refuses-metadata-the-runtime-ignores': ['flows', 'objects', 'objectExtensions', 'actions'], + '19:publish-refuses-seeds-and-actions-that-save-and-do-not-work': ['data', 'flows', 'actions', 'objects'], + '19:publish-refuses-views-and-dashboards-that-save-and-do-not-work': + ['views', 'viewItems', 'objects', 'dashboards', 'apps'], + '19:refusal-reasons-list-literal-judged': ['hooks', 'actions', 'objects'], + '19:related-lists-declared-is-tab-list': ['objects', 'objectExtensions'], + '19:seal-default-chain-column-refused': ['objects'], + '19:seed-key-blank-record-refused': ['data'], + '19:seed-mode-insert-replace-retired': ['data'], + '19:seed-record-refused-before-load': ['data'], + '19:seed-summary-value-not-stored': ['data'], + '19:stack-residual-extension-registered-and-jobs-judged': ['jobs', 'objectExtensions'], + '19:transfer-cascade-never-offered-refused': ['objects', 'objectExtensions'], + '19:translation-form-tails-move-to-forms': ['translations'], + '19:translation-related-list-key-under-arrangement-refused': ['translations'], + '19:ui-action-type-ask-ai-retired': ['actions', 'objects', 'pages', 'dashboards'], + '19:ui-form-view-modal-size-retired': ['views', 'viewItems', 'forms'], + '19:ui-form-view-subforms-retired': ['views', 'viewItems', 'forms'], + '19:validation-rule-message-template-holes': ['objects', 'objectExtensions', 'translations'], '19:view-bulk-actions-declared-on-the-action': ['views', 'objects', 'pages'], }; @@ -88,14 +150,6 @@ describe('which entries carry a relevance question (ENUMERATION)', () => { expect(actual).toEqual(EXPECTED_RELEVANCE); }); - it('is 31 entries: 5 of protocol 17, 22 of protocol 18 and 4 of protocol 19', () => { - const keys = Object.keys(EXPECTED_RELEVANCE); - expect(keys).toHaveLength(31); - expect(keys.filter((k) => k.startsWith('17:'))).toHaveLength(5); - expect(keys.filter((k) => k.startsWith('18:'))).toHaveLength(22); - expect(keys.filter((k) => k.startsWith('19:'))).toHaveLength(4); - }); - it('the table names only registered entries (anti-vacuity for the comparison above)', () => { const registered = new Set(ENTRIES.map(({ major, entry }) => `${major}:${entry.id}`)); expect(Object.keys(EXPECTED_RELEVANCE).filter((k) => !registered.has(k))).toEqual([]); diff --git a/packages/spec/src/migrations/types.ts b/packages/spec/src/migrations/types.ts index cb79169a31f..1901b0d5518 100644 --- a/packages/spec/src/migrations/types.ts +++ b/packages/spec/src/migrations/types.ts @@ -55,7 +55,8 @@ export type SemanticRelevanceKey = Exclude< * ABSENT, and any other value (a function, a promise, a scalar) is UNKNOWN. The * same key inside each `packages[].manifest` body counts too, since an * assembled multi-package stack carries its collections there and not at the - * top level. + * top level, and so does the same key in the stack's own `manifest`, which + * declares collections of its own (`manifest.data`, seed datasets). */ export interface StackDeclaresRelevance { /** The discriminant: a question about which top-level keys the stack declares. */ @@ -86,8 +87,15 @@ export interface StackDeclaresRelevance { * surface) names the entry in {@link MigrationChainResult.absentTodos} — it * stays in `todos` too; `present` and `unknown` (a value the question cannot * read, a stack that is not a plain object, or a `plugins` / `devPlugins` / - * `tiers` entry that can contribute metadata the stack does not show) do not. The proof is about the definition the chain reads: metadata - * a deployment stores at runtime (Studio, the metadata API) is not part of it. + * `tiers` entry that can contribute metadata the stack does not show) do not. + * + * The proof is about the definitions the stack declares, and two sources of + * metadata are outside it: what a deployment stores at run time (Studio, the + * metadata API), and what the app's `onEnable` hook registers through the + * engine it is handed at start. Neither is read, and `os migrate meta` names + * both in the line that scopes its count. `onEnable` is no carrier: it is + * described for action handlers and drivers, and registering metadata there is + * off-label. */ export type SemanticRelevance = StackDeclaresRelevance; @@ -140,13 +148,34 @@ export interface SemanticMigration { * rather than listing it (`--all` lists it). See {@link SemanticRelevance} * for the evaluation. * - * Omit it — the entry is then always listed — unless the surface lives ONLY - * under top-level stack keys the question names. Two cases keep it listed by - * construction: an unreadable stack answers `unknown`, and an entry whose - * `conversionIds` names a conversion that applied an edit in the same run is - * listed whatever the question answers, since the edit is itself a proof the - * surface is there. Every entry carrying this field is enumerated by - * `semantic-relevance.test.ts`, so adding one is a reviewed edit. + * When to give it (the rule from protocol 19 on): whenever the entry's + * surface is metadata authored under top-level stack keys, naming EVERY key + * it can be written under, nested sites included (an action an object + * carries inline is under `objects`; a field an extension adds is under + * `objectExtensions`). A key too many only keeps the notice listed; a key + * missing proves it absent wrongly. A surface that a stored copy of the same + * metadata also meets (a refusal at the metadata save door, a change of + * meaning on a stored row) still takes a question: the proof covers the stack + * this run loads, never what a deployment stores, and the printer says so. + * + * Omit it — the entry is then always listed — when no question over the + * stack can judge it: the surface is host code (an import, an exported + * helper, a service interface, a source registered in code), a deployment's + * own state or doors (installed packages, rows written at run time), or + * something every stack carries; or the entry's own check runs over the rows + * a deployment stores. Protocols 17 and 18 used a narrower rule (a surface + * that lives ONLY under the named keys, with no runtime door), and their + * entries keep it. + * + * Two cases keep an entry listed by construction: an unreadable stack + * answers `unknown`, and an entry whose `conversionIds` names a conversion + * that applied an edit in the same run is listed whatever the question + * answers, since the edit is itself a proof the surface is there. Every entry + * carrying this field is enumerated by `semantic-relevance.test.ts`, each + * one from protocol 19 on with no field sits on the reviewed table of + * `semantic-relevance-coverage-38929.test.ts`, and the sites the keys rely on + * are pinned there by behaviour, so adding or changing one is a reviewed + * edit. */ relevantWhen?: SemanticRelevance; } @@ -231,6 +260,33 @@ export interface MigrationChainResult { * the stack answers `absent`. */ absentTodos: MigrationTodo[]; + /** + * Why a relevance question stayed open: the entries of {@link todos} whose + * {@link SemanticMigration.relevantWhen} question answered `unknown` over + * the stack and its checkpoints, and what the evaluation could not read. + * Each such entry stays listed (it is never in {@link absentTodos}); this + * field only says why, so a printer can tell the author why a notice it + * could not prove irrelevant is still on the list. + * + * `unread` names each thing the evaluation could not read, as a stack path: + * `plugins`, `devPlugins` or `tiers` while one lists an entry (a plugin, or + * the platform plugins a tier preset loads, can register metadata at boot + * that the stack does not show), a key whose value is not a list or a map + * (`agents`, `manifest.data`), a manifest or a package body that cannot be + * read (`manifest`, `packages`, `packages[1]`, `packages[1].manifest.agents`), + * `(stack)` when the stack itself is not a plain object or a read of it + * threw, or a question of a kind this build cannot answer. + * + * Absent when no question answered `unknown`. An entry that judges a + * conversion which applied an edit in this run is listed for that reason and + * is not named here. + */ + unanswered?: { + /** The entries, a subset of {@link todos}: the same objects, in chain order. */ + todos: MigrationTodo[]; + /** What could not be read, each named once, in the order first met. */ + unread: string[]; + }; /** Per-hop checkpoints, in order (for `--step` bisection). */ hops: MigrationHopResult[]; }