Skip to content

Commit d6e0967

Browse files
feat(metadata-protocol,cli,cloud-connection)!: the override write gate — only the base's paired .custom declares an override (ADR-0146 D2) (#28554)
domain:server#1 · os-project-manager · session_01R1q2xdtYgU6FKrZ7LgjPCC <!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> _Requested by **Leehom** · [project thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XNNCo1UH18c8rw38MKwdp8C)_ Fixes #28410 Clause-②: yes (narrowing) New refusals at the save and publish doors, at `os validate` and at the marketplace managed install narrow the accepted set; the base's paired `.custom` declaring an override is admitted beside them. The one `packages/spec/**` file touched is the error-code provenance ledger: two rows naming `os validate` and the marketplace install as emitters of the already-registered `NOT_OVERRIDABLE`; no schema, type or runtime interface moves. Metadata-protocol: narrowed Skills-docs: none — no file under `skills/**` teaches the `overrides` declaration, a `<base>.custom` package or the sealed-write sentence; the `content/docs/references/**` pages that show `overrides` are generated from the spec and do not move. ## 维护者速读 - 改了什么:覆盖写门(ADR-0146 D2,#28390 裁决 A)落在三个门点:保存/发布门、`os validate`、市场托管安装。只有基础包配对的 `<base>.custom` 能声明 `overrides`;依赖包里与闭包内只读包同名的条目被拒(改名),五类拒绝各有一句(未声明同名、非配对包声明、基础包不在闭包或不含该条目、排除类型、object),flow/action 声明答「尚不可用」。 - 为什么改:依赖包可以在基础包的名字下发布条目,读者拿到哪一份没有定论(#28238 的形状:今天 200)。 - 风险与回滚:收窄只拦闭包内同名与不被接纳的声明;预检计数 hotcrm 与仓内示例为 0 处。码与状态不变(`403 NOT_OVERRIDABLE`),未声明同名的拒绝排在各门已有拒绝之后。回滚即 revert,无数据迁移。 - 先看:`packages/metadata-protocol/src/protocol-packaged-base-refusal.ts`(`judgeOverrideWrite`、`overrideWriteItemsOf`),`protocol.ts` 的保存门与 `promoteDraftForPublish` 两处接线,`cloud-connection` 安装门的步骤 2d。 - 两分钟验证:`pnpm --filter @objectstack/metadata-protocol exec vitest run src/protocol.packaged-base-refusal.test.ts`,预期 `Tests 63 passed (63)`。 - 需要你做的:卡上的安装门点从 `installPackage` 移到市场托管安装(席位已批);另有一个开放问题:`os build` 要不要也拒(见报告)。 ## What changes - **The rule, once** (`@objectstack/metadata-protocol`, `protocol-packaged-base-refusal.ts`). `judgeOverrideWrite(subject, closure)` is a pure verdict: `admit`, one named `refuse`, or `not_concerned`. It reads N-08's surface from `@objectstack/spec/kernel` (`OVERRIDE_TYPE_CLASSIFICATION`, `isCustomizationPairOf`, `customizationPackageId`, `customizationBasePackageId`) and copies none of it. `overrideWriteItemsOf(body)` is the item walk the two outside doors share (an action keyed `<objectName>:<name>`, a `views:` container expanded by the loader's own `expandViewContainer`). Both are exported from the package index in one export line. - **The refusals**, all `403 NOT_OVERRIDABLE`, each with its own sentence: - (a) `undeclared_same_name`: a dependent's item under the name a read-only package in its closure ships, on an overridable type. In `<base>.custom`: "Declare it … or rename the item". Elsewhere: "Rename the item". - (b) `declared_outside_pair`: `overrides` on a package that is not the base's pair. - (c) `declared_package_outside_closure` ("Declare a dependency on '<base>' …") and `declared_package_ships_no_such_item`. - (d) `declared_type_not_overridable`: an excluded type, pointing to a new item under a new name. - (e) `declared_object`: pointing to `objectExtensions`. - `declared_type_not_yet_available`: a declared `flow` ("flow customization is not yet available") or `action`. - **Admit.** The pair declaring an override of an item its base ships, on an open type: the save door skips the sealed refusal for it and the repository is told a `runtime-only` write (the pair's own row), at the save and at the promotion. - **Save and publish doors** (`protocol.ts`). The save door judges every save; a refused declaration throws before the flow-only regime check (so a declared flow reads its own sentence, not the clone sentence), and an undeclared same name throws last, just before the store, so every refusal the door already answered keeps its code and status (a view container's name collision keeps its 400, a lock its `ITEM_LOCKED`). The promotion (`publishMetaItem`, `publishPackageDrafts`) judges the draft body and throws once, last before the store; a batch publish reports it in `failed`. - **Base = read-only.** Only a package `isWritablePackage` answers false for is a base the gate guards: an override replaces an installed item, and a writable package's item is edited in place (ADR-0070). Every artifact a kernel serves is registered through `registerApp`, which puts it in `manifests`, so this keeps no real base out. - **The sealed sentence.** On an open type its tail is writer-aware. For the base's pair (or a write naming no package) it reads "To change it, declare an override from '<base>.custom' (overrides: { package: '<base>', basedOn }), or rename the item." For any other package it reads "To change it, rename the item: only <base>.custom may declare an override of <base>." The base id is read through the existing `packagedArtifactOwner`, so no new `lookupArtifactItem` call site. - **A malformed `overrides` is not a declaration.** A value `OverrideDeclarationSchema` refuses is not judged as a declaration: the save door's schema gate answers it (`422 INVALID_METADATA`), and `os validate`'s schema step reports it. - **A save naming no package** is re-judged for the package its address gives (the publish address or the draft address), so it cannot write a dependent's undeclared same-named row. This is the one write behaviour refused on purpose (see Tests). - **`os validate`** (`@objectstack/cli`, `utils/override-declarations.ts`, step 3a-iii). Each package of the artifact (or the stack as one package) is judged against its closure, followed through the artifact's packages. A same name is found where both packages are in the artifact; a declaration is judged whole wherever its base lives. Exit 1, the rows on `errors` with `path`, `code`, `rule`, `packageId`, `message`. - **Marketplace managed install** (`@objectstack/cloud-connection`, step 2d, before any write). Every delivered package (a `packages[]` artifact judged per entry) is judged against its closure (registry dependencies plus the artifact's own) with shippers read from the protocol's per-package listing. A refusal answers `403 NOT_OVERRIDABLE` with `details.refusals`; nothing registers and no ledger entry is written. On an install of a base, `overrideCollisions` on the `200` answer lists each name an installed dependent already holds undeclared (the judge's sentence per row); the key is omitted when empty. ## Tests - `protocol.packaged-base-refusal.test.ts`: the gate describe block, 63 tests in the file, including the package-less save re-judged for its address's package (the one write behaviour refused on purpose). Red first on main (`b24adb3a`): 20 failed, 35 passed. - `protocol.sealed-remedy-kind.test.ts`: the one-sentence pin reads the declare-or-rename tail from the classification, never transcribed. - `packages/cli/src/utils/override-declarations.test.ts` (7, unit tier) and `packages/cli/test/validate-override-declarations.test.ts` (2, the command, exit code). - `packages/cloud-connection/src/marketplace-install-local-override-gate.test.ts` (6): refusals, nothing written, the pair's admit, the control, the collision list. - `protocol.org-scoped-write-refused.test.ts` is green and unchanged (`git diff 23d1303 -- <file>` empty). - The #28409 and #28238 read pins in the rest and objectql suites seed their same-named rows before the gate (pre-gate seeding), so they keep pinning the read side the gate now keeps from being written. - Ablations, 19, each through `scripts/ablation-replace.mjs` with its restore proved clean (`git diff HEAD` empty); each reads red: (a) 7 failed, (b) 4, (c) closure 1, (c) ships 1, (d) 1, (e) 1, not-yet 2, sealed tail 5, read-only base filter 127 (the org-scoped file), save door declared throw 4, save door undeclared throw 5, promotion throw 3, admitted runtime-only intent 1, install refusal 3, install collisions 1, validate wiring 1. Round 2 adds A18 (writer-aware tail, 1 failed), A19 (malformed `overrides` is not a declaration, 5 failed) and A20 (package-less re-judge, 1 failed). Two first attempts were no-ops (the anchor's replacement count did not rise) and were redone; one (an early declared throw at the promotion) read green and was removed as redundant. ## Acceptance notes - **The card's `installPackage` gate point moved to the marketplace managed install** (seat 1 amendment, posted on #28410). `installPackage` takes a manifest and no items (`PackageInstallManifestSchema`), and the unmanaged install copies through the save door, which is gated; the managed install is where a package's items arrive unjudged. - `os build` does not run the gate. The parity ledger records `findOverrideDeclarationRefusals` in `VALIDATE_ONLY_GATES` with the reason; whether the build refuses too is an open question on the card. - The validate and install tests live beside their doors, not in `protocol.packaged-base-refusal.test.ts` as the order put it: metadata-protocol cannot import cli or cloud-connection (they depend on it). - Not handled: a rollback (`rollbackMetaItem`) of a declared override row still computes the `override-artifact` intent from `isArtifactBacked` alone. Rolling back the pair's row is N-10/N-16 territory and not a door this card names. - The install door's collision list reads dependents through the protocol listing (`getMetaItems({ type, packageId })`), which serves code-registered and stored items alike, so a `.custom` built in Studio is covered. ## Verification Run on `21bc1b51` (a merge of `origin/main`) under `os-verify-lock` (`VERDICT command-exit 0`). - Merge: the only conflict was `scripts/engine-double-contract.pinned.json`. Main's pin was taken and regenerated with `check-engine-double-contract.mjs --write`; it differs from main only by this branch's three rows (the gate test's `delete`, `findOne` and `update`). `check:engine-double-contract` exit 0. - `pnpm install --frozen-lockfile` exit 0; closure rebuild exit 0. Typecheck metadata-protocol, cli and cloud-connection: exit 0. - metadata-protocol full suite: Test Files 290 passed | 4 skipped (294), Tests 21929 passed | 26 skipped. - objectql full suite: Test Files 512 passed, Tests 9888 passed. - rest full suite: Test Files 368 passed, Tests 7195 passed | 352 skipped. - cloud-connection full suite: Test Files 64 passed, Tests 778 passed. - cli unit tier plus `test/validate-override-declarations` and `test/validate-build-gate-parity`: Test Files 290 passed | 1 skipped, Tests 3730 passed | 8 skipped. - Derived gates (`dispatch-gates.mjs --commands`, reconciled with `--ran`): `✓ dispatch-gates --ran: 98 derived famil(ies) accounted for — 98 run, 0 NOT-MEASURED`, including `check:error-code-provenance` and the i18n and dual-build families with their prerequisites built first. - Ablations: the round-1 sixteen plus A18–A20, all red, each restore proved clean. Re-run on `cd852e2a` (a merge of `origin/main` bringing in #28595, then the re-seed of `packages-customizations.test.ts`) under `os-verify-lock` (`VERDICT command-exit 0`). - Red first: CI Test Core (3/8), job 124795448012, 2 failed on `21bc1b51` (the two `packages-customizations.test.ts` cases seeding through `saveMetaItem`, which the gate now refuses). - Re-seed: each case first asserts the door's 403 `NOT_OVERRIDABLE` with its own sentence ("carries `overrides`" for the non-pair declaration, "declares no override" for the undeclared pair row), then lays the row down below the gate through the same draft save and publish with the gate shadowed to `not_concerned` for that save alone. The read assertions are unchanged. - `packages-customizations.test.ts`: 13/13. `@objectstack/runtime` full suite: Test Files 505 passed (505), Tests 9106 passed | 19 skipped. - Derived gates: `✓ dispatch-gates --ran: 98 derived famil(ies) accounted for — 98 run, 0 NOT-MEASURED`. - `4a25192b` changes only the `declarationOf` docblock (it now names the door's 422 `INVALID_METADATA`); comment only in a non-exported function, eslint exit 0. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01FEkQ5oYcVD24TCK4yt5e1i --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent d2c4874 commit d6e0967

20 files changed

Lines changed: 1956 additions & 34 deletions
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
'@objectstack/metadata-protocol': minor
3+
'@objectstack/cli': minor
4+
'@objectstack/cloud-connection': minor
5+
'@objectstack/spec': patch
6+
---
7+
8+
**BREAKING** feat(metadata-protocol)!: the override write gate — only a base's paired `<base>.custom` package declares an override, and a dependent's item under a base item's name is refused (ADR-0146 D2, #28410)
9+
10+
Clause-②: yes (narrowing)
11+
Metadata-protocol: narrowed
12+
Skills-docs: none — no file under `skills/**` teaches the `overrides` declaration, a `<base>.custom` package or the sealed-write sentence; the `content/docs/references/**` pages that show `overrides` are generated from the spec and do not move.
13+
14+
<!-- adr-0087: not-required (no-migration-prescription) The narrowing is a refusal at the write doors (publish, `os validate`, the marketplace managed install) of item NAMES and of an `overrides` declaration outside the base's paired package: no metadata key, accepted value, export or error code is removed or renamed, and no stored shape changes. The remedy is a rename of an item, or a declaration added in the base's paired `.custom` package, both authoring choices a person makes; there is no mechanical conversion between two metadata versions for `objectstack migrate meta` to apply, and the precondition count on #28410 found no same-named item inside a dependency closure in hotcrm or the repository's examples. The other categories are closed on facts: all three packages publish (not unpublished); no ADR-0087 id is named or touched (not registered or already-registered); the one `packages/spec/**` file touched is the error-code provenance ledger (`api/error-code-ledger.zod.ts`), two rows naming new emitters of the already-registered `NOT_OVERRIDABLE`, so no schema, type or runtime interface moves (not type-surface-only, not runtime-interface-only); and no export is retired (not runtime-export-retired). -->
15+
16+
A dependent package used to be able to ship, publish or install an item under the name an item of a package in its dependency closure already has, and nothing said which one a reader would get. Ruling A on #28390 settles it: only the base's paired `<base>.custom` package declares an override (`overrides: { package: '<base>', basedOn }`), and a dependent's same-named item has one fix, rename.
17+
18+
**What is refused**, `403 NOT_OVERRIDABLE` (the code and status the sealed write already answers), each with its own sentence:
19+
20+
- **An undeclared same name inside the closure.** A dependent's item bearing the name of an item a read-only (installed) package in its dependency closure ships, on a type a declared override can replace. In `<base>.custom` the sentence says to declare it or rename it; in any other dependent, to rename it.
21+
- **`overrides` outside the pair.** A declaration on a package that is not the base's paired `.custom`.
22+
- **A declaration the closure cannot back.** `overrides.package` outside the declaring package's dependency closure (the sentence says to declare the dependency), or a base that ships no item of that type and name.
23+
- **A type that takes no override.** An excluded type (permission, position, capability, the code-only types…), pointing to creating a new item under a new name; an `object`, pointing to `objectExtensions`.
24+
- **A channel not yet open.** A declared `flow` ("flow customization is not yet available") or `action`.
25+
26+
**Where.** The save door (`saveMetaItem`, so `PUT /api/v1/meta/:type/:name` and every authoring path through it), the promotion (`publishMetaItem` and `publishPackageDrafts`), `os validate` (each package of the artifact against its closure inside the artifact; exit 1), and the marketplace managed install (`POST /api/v1/marketplace/install-local`, before any write). The undeclared-same-name refusal is asked last at the publish doors, so every refusal those doors already answered keeps its code and status.
27+
28+
**Admitted.** The base's paired `.custom` declaring an override of an item its base ships, on an open type: the save and the promotion write it as the pair's own row, and the managed install registers it.
29+
30+
**The install answer lists upgrade collisions.** An install of a base whose new version ships a name an installed dependent already holds, undeclared, answers `200` with `overrideCollisions` (`type`, `name`, `packageId`, `rule`, `message`), one row per held item; the key is omitted when there is none. The install is not refused: the dependent's item is the one to rename, or in `.custom`, to declare.
31+
32+
**The sealed sentence.** A write over a sealed item of a type a declared override can replace now names the writer's route in place of none. Written from the base's paired `.custom`, or naming no package, it ends "To change it, declare an override from '<base>.custom' (overrides: { package: '<base>', basedOn }), or rename the item."; written from any other package, "To change it, rename the item: only '<base>.custom' may declare an override of '<base>'."
33+
34+
**A malformed `overrides` is not a declaration.** A value the spec's `OverrideDeclarationSchema` refuses (null, not an object, no or an empty `package`, no `basedOn`) is not judged by the gate; the save door's schema gate answers it (`422 INVALID_METADATA`), and `os validate` reports it at its schema step.
35+
36+
`@objectstack/metadata-protocol` exports the gate's rule, `judgeOverrideWrite`, and its item walk, `overrideWriteItemsOf`, so the three doors ask one judgement.
37+
38+
`@objectstack/spec` records the two new emitters of `NOT_OVERRIDABLE` in its error-code provenance ledger (`api/error-code-ledger.zod.ts`, under `@objectstack/cli` and `@objectstack/cloud-connection`). The code was already registered, so the union, casing and every schema are unchanged.

‎packages/cli/src/commands/validate.ts‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ import type { PermissionSetNameCollisionDiagnostic } from '@objectstack/plugin-s
7474
// over the parsed stack the way the load path registers it. The verdict is
7575
// `@objectstack/objectql`'s; see the module header.
7676
import { findViewContainerNameRefusals } from '../utils/view-container-names.js';
77+
// [ADR-0146 D2, #28410] The override write gate's author-time half: the publish
78+
// door's own judge, walked over the artifact's packages.
79+
import { findOverrideDeclarationRefusals } from '../utils/override-declarations.js';
7780
// A field `picklist` that names no picklist the stack declares — refused, or
7881
// reported when the declaring package depends on packages outside the stack.
7982
// Walked the way the load path registers, like the refusal above.
@@ -658,6 +661,35 @@ export default class Validate extends Command {
658661
}
659662
}
660663

664+
// 3a-iii. [ADR-0146 D2, #28410] The override write gate, at author time.
665+
// Only the base's paired `<base>.custom` declares an override; a
666+
// dependent's item bearing the name a package in its closure ships is
667+
// refused (rename), and an `overrides` declaration the gate does not
668+
// admit is refused. The verdict is the publish door's own
669+
// (`judgeOverrideWrite`), so a green validate is a publish the door
670+
// accepts; see `utils/override-declarations.ts` for the walk.
671+
const overrideRefusals = findOverrideDeclarationRefusals(result.data as Record<string, unknown>);
672+
if (overrideRefusals.length > 0) {
673+
if (flags.json) {
674+
await emitJson({
675+
valid: false,
676+
errors: overrideRefusals,
677+
warnings: warningsSoFar(),
678+
conversions: conversionNotices,
679+
duration: timer.elapsed(),
680+
});
681+
this.exit(1);
682+
}
683+
const n = overrideRefusals.length;
684+
console.log('');
685+
printError(`The publish door would refuse ${n} item${n > 1 ? 's' : ''} under the override write gate (ADR-0146 D2)`);
686+
printBulletList(
687+
overrideRefusals.map((r) => `${r.path} [${r.code}] ${r.message}`),
688+
{ noun: 'override refusal(s)', remedy: JSON_FULL_LIST_REMEDY },
689+
);
690+
this.exit(1);
691+
}
692+
661693
// 3b. [#3366] Installable-provider preflight — the shift-left of the
662694
// `serve`-time capability check. `os validate` previously only checked
663695
// the `requires` tokens against the vocabulary (ADR-0066), never
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* [ADR-0146 D2, #28410] `findOverrideDeclarationRefusals` — the WALK `os
5+
* validate` runs the override write gate's judge over.
6+
*
7+
* The verdict is `@objectstack/metadata-protocol`'s `judgeOverrideWrite`, the
8+
* function the publish doors ask; the protocol's own file pins its sentences.
9+
* What is pinned here is which items the walk hands the judge, under which
10+
* package and against which closure: every row's message is asserted EQUAL to
11+
* the judge's answer for the same subject, never re-spelled.
12+
*/
13+
14+
import { describe, expect, it } from 'vitest';
15+
import { judgeOverrideWrite } from '@objectstack/metadata-protocol';
16+
import { findOverrideDeclarationRefusals } from './override-declarations.js';
17+
18+
const BASE = 'com.acme.crm';
19+
const PAIR = 'com.acme.crm.custom';
20+
const PARTNER = 'com.acme.partner';
21+
22+
const manifest = (id: string, dependencies: string[] = []) => ({
23+
id, name: id, version: '1.0.0', type: 'app',
24+
...(dependencies.length ? { dependencies: Object.fromEntries(dependencies.map((d) => [d, '*'])) } : {}),
25+
});
26+
const pkg = (id: string, dependencies: string[], collections: Record<string, unknown>) =>
27+
({ manifest: { ...manifest(id, dependencies), ...collections } });
28+
29+
const base = pkg(BASE, [], {
30+
dashboards: [{ name: 'crm_board', label: 'Board' }],
31+
pages: [{ name: 'crm_home', label: 'Home' }],
32+
actions: [{ name: 'log_call', objectName: 'crm_account', label: 'Log' }],
33+
});
34+
35+
const judged = (type: string, name: string, packageId: string, item: unknown, dependencies: string[], shippers: string[]) => {
36+
const v = judgeOverrideWrite({ type, name, packageId, item }, { dependencies, shippers });
37+
if (v.verdict !== 'refuse') throw new Error(`expected a refusal, got ${v.verdict}`);
38+
return v.message;
39+
};
40+
41+
describe('#28410 — findOverrideDeclarationRefusals walks the artifact under the publish door\'s judge', () => {
42+
it('a partner\'s item bearing a name the base in its closure ships is refused, in the judge\'s words', () => {
43+
const item = { name: 'crm_board', label: 'Mine' };
44+
const rows = findOverrideDeclarationRefusals({
45+
manifest: manifest('com.acme.bundle'),
46+
packages: [base, pkg(PARTNER, [BASE], { dashboards: [item] })],
47+
});
48+
expect(rows).toEqual([{
49+
path: 'packages[1].manifest.dashboards[0]',
50+
code: 'NOT_OVERRIDABLE',
51+
rule: 'undeclared_same_name',
52+
packageId: PARTNER,
53+
message: judged('dashboard', 'crm_board', PARTNER, item, [BASE], [BASE]),
54+
}]);
55+
});
56+
57+
it('the closure is transitive through the artifact\'s packages', () => {
58+
const rows = findOverrideDeclarationRefusals({
59+
manifest: manifest('com.acme.bundle'),
60+
packages: [base, pkg('com.acme.mid', [BASE], {}), pkg(PARTNER, ['com.acme.mid'], { pages: [{ name: 'crm_home' }] })],
61+
});
62+
expect(rows.map((r) => [r.packageId, r.rule])).toEqual([[PARTNER, 'undeclared_same_name']]);
63+
});
64+
65+
it('controls: a package outside the closure, an own name, and an action on another object are not refused', () => {
66+
expect(findOverrideDeclarationRefusals({
67+
manifest: manifest('com.acme.bundle'),
68+
packages: [
69+
base,
70+
pkg('com.other', [], { dashboards: [{ name: 'crm_board' }] }),
71+
pkg(PARTNER, [BASE], {
72+
dashboards: [{ name: 'partner_board' }],
73+
actions: [{ name: 'log_call', objectName: 'partner_lead', label: 'Log' }],
74+
}),
75+
],
76+
})).toEqual([]);
77+
});
78+
79+
it('the pair\'s declared override is admitted; its undeclared same name is told to declare or rename', () => {
80+
const declared = { name: 'crm_board', overrides: { package: BASE, basedOn: '1.0.0' } };
81+
const undeclared = { name: 'crm_home' };
82+
const rows = findOverrideDeclarationRefusals({
83+
manifest: manifest('com.acme.bundle'),
84+
packages: [base, pkg(PAIR, [BASE], { dashboards: [declared], pages: [undeclared] })],
85+
});
86+
expect(rows).toEqual([{
87+
path: 'packages[1].manifest.pages[0]',
88+
code: 'NOT_OVERRIDABLE',
89+
rule: 'undeclared_same_name',
90+
packageId: PAIR,
91+
message: judged('page', 'crm_home', PAIR, undeclared, [BASE], [BASE]),
92+
}]);
93+
expect(rows[0].message).toMatch(/Declare it/);
94+
});
95+
96+
it('a one-package .custom stack whose base is installed elsewhere: declarations are judged, the shipped name is left to the door', () => {
97+
const rows = findOverrideDeclarationRefusals({
98+
manifest: manifest(PAIR, [BASE]),
99+
dashboards: [{ name: 'crm_board', overrides: { package: BASE, basedOn: '1.0.0' } }],
100+
objects: [{ name: 'crm_account', overrides: { package: BASE, basedOn: '1.0.0' } }],
101+
flows: [{ name: 'crm_flow', overrides: { package: BASE, basedOn: '1.0.0' } }],
102+
pages: [{ name: 'crm_home', overrides: { package: 'com.unlisted', basedOn: '1.0.0' } }],
103+
});
104+
expect(rows.map((r) => [r.path, r.rule])).toEqual([
105+
['objects[0]', 'declared_object'],
106+
['flows[0]', 'declared_type_not_yet_available'],
107+
['pages[0]', 'declared_outside_pair'],
108+
]);
109+
});
110+
111+
it('a dependent carrying `overrides` is refused, and a declaration of an item the base does not ship is refused', () => {
112+
const rows = findOverrideDeclarationRefusals({
113+
manifest: manifest('com.acme.bundle'),
114+
packages: [
115+
base,
116+
pkg(PARTNER, [BASE], { dashboards: [{ name: 'crm_board', overrides: { package: BASE, basedOn: '1.0.0' } }] }),
117+
pkg(PAIR, [BASE], { dashboards: [{ name: 'no_such_board', overrides: { package: BASE, basedOn: '1.0.0' } }] }),
118+
],
119+
});
120+
expect(rows.map((r) => [r.packageId, r.rule])).toEqual([
121+
[PARTNER, 'declared_outside_pair'],
122+
[PAIR, 'declared_package_ships_no_such_item'],
123+
]);
124+
});
125+
126+
it('a pair that does not depend on its base is told to declare the dependency', () => {
127+
const rows = findOverrideDeclarationRefusals({
128+
manifest: manifest('com.acme.bundle'),
129+
packages: [base, pkg(PAIR, [], { dashboards: [{ name: 'crm_board', overrides: { package: BASE, basedOn: '1.0.0' } }] })],
130+
});
131+
expect(rows.map((r) => r.rule)).toEqual(['declared_package_outside_closure']);
132+
expect(rows[0].message).toMatch(/Declare a dependency on 'com\.acme\.crm'/);
133+
});
134+
});

0 commit comments

Comments
 (0)