diff --git a/.changeset/33922-install-local-namespace-gate.md b/.changeset/33922-install-local-namespace-gate.md new file mode 100644 index 00000000000..2e4c57aae15 --- /dev/null +++ b/.changeset/33922-install-local-namespace-gate.md @@ -0,0 +1,20 @@ +--- +'@objectstack/cloud-connection': patch +--- + +fix(cloud-connection)!: `POST /api/v1/marketplace/install-local` parses the manifest `namespace` through its declaration, as it already parses the id + +Clause-②: no (narrowing) +Metadata-protocol: none (the declaration `ManifestSchema.shape.namespace` already refuses these values; this door now enforces it. The dev confirms against the diff.) + + + +**BREAKING** for a caller of the install-local door whose package declares a `namespace` the manifest declaration refuses: anything but 2–20 characters of lowercase letters, digits and `_` opening with a lowercase letter. + +- FROM: an inline manifest declaring `namespace: ''`, `'QA_N'` or `'9-Bad Ns!'` answered `200`, was registered and ledgered under that namespace, and `QA_N` installed beside an existing owner of `qa_n` without the install-time namespace gate answering. TO: it answers `400 PLUGIN_MANIFEST_INVALID` with the declaration's own sentence and nothing is registered, synced or written. +- FROM: an inline manifest declaring `namespace: null` or a non-string `namespace` was admitted, the key unparsed (a `null` read as no namespace). TO: it answers the same `400 PLUGIN_MANIFEST_INVALID`; only an absent key means no namespace. +- FROM: a cloud-fetched snapshot declaring such a namespace installed the same way. TO: it answers `502 PLUGIN_MANIFEST_INVALID`, the status the door already gives an invalid upstream snapshot. + +**Not moved.** A manifest whose `namespace` key is absent installs as before (the key is optional). A member of a multi-package artifact declaring such a namespace keeps the artifact-entry refusal it already had (`INVALID_ARTIFACT_PACKAGE_ENTRY`, 422). A conforming namespace installs as before, and one another package owns still meets the registry's own namespace gate. A package an older build already installed under such a namespace still rehydrates at boot and can still be uninstalled; it cannot be re-installed until its namespace conforms. + +The fix for a caller: declare the namespace in lowercase snake form (`qa_n`, not `QA_N`), or omit it. diff --git a/packages/cloud-connection/src/marketplace-install-local-namespace-gate-33922.test.ts b/packages/cloud-connection/src/marketplace-install-local-namespace-gate-33922.test.ts new file mode 100644 index 00000000000..15ca26fb897 --- /dev/null +++ b/packages/cloud-connection/src/marketplace-install-local-namespace-gate-33922.test.ts @@ -0,0 +1,366 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * `POST /api/v1/marketplace/install-local` parses the `namespace` of every + * package it installs through its declaration — `ManifestSchema.shape.namespace` + * (`NAMESPACE_PATTERN`), by reference — the way it already parses the id. + * + * ## What was wrong + * + * The door parsed `manifest.id` and `installModes` through the declaration but + * never `namespace`, so an inline manifest declaring `''`, `'QA_N'` or + * `'9-Bad Ns!'` installed with a 200 and was registered and ledgered under it. + * `QA_N` installed beside an existing owner of `qa_n`: the registry's + * install-time namespace gate (ADR-0048 §2, unique per installation) compares + * namespaces as written and never read the two as one. + * + * ## What these cases pin + * + * - each refused value answers `400 PLUGIN_MANIFEST_INVALID` in the declared + * envelope, carrying the declaration's own sentence (read from the schema + * here, never copied), and nothing is registered, synced or ledgered — on + * a flat manifest and a compiled bundle's nested manifest, judged on the + * body registration reads (its top-level `namespace`); a cloud snapshot + * answers the same code at `502`; a multi-package artifact's MEMBER keeps + * the refusal the artifact-entry parse already gave it; + * - a conforming namespace and an ABSENT one still install (the declaration + * makes the key optional); + * - over a real engine: `QA_N` beside an owner of `qa_n` is the 400 above and + * the registry does not hold it, while `qa_n` beside that owner still meets + * the registry's own namespace gate — the gate's comparison needed no change. + */ + +import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; +import { mkdtempSync, rmSync, readdirSync } from 'node:fs'; +import { join } from 'node:path'; +import { tmpdir } from 'node:os'; +import { ManifestSchema } from '@objectstack/spec/kernel'; +import { BaseResponseSchema, ApiErrorSchema, envelopeViolations } from '@objectstack/spec/api'; +// The plugin reaches `@objectstack/runtime` through a lazy `import()`; its first +// load is paid here, at module top, never inside a clocked `it`. +import '@objectstack/runtime'; +import { ObjectKernel } from '@objectstack/core'; +import { ObjectQLPlugin, type ObjectQL } from '@objectstack/objectql'; +import { MarketplaceInstallLocalPlugin } from './marketplace-install-local-plugin.js'; +import { LocalManifestSource } from './local-manifest-source.js'; +import { installerAuthService, withInstallerGrants } from './install-local-principal.fixtures.js'; + +type Bag = Record; +type Handler = (c: any) => Promise; + +const ROUTE = '/api/v1/marketplace/install-local'; + +/** The three values the card's probe installed. */ +const REFUSED: ReadonlyArray = [ + ['the empty string', ''], + ['upper case (a case variant of an owned namespace)', 'QA_N'], + ['a digit-initial value with a hyphen, spaces and punctuation', '9-Bad Ns!'], +]; + +/** + * A compiled body whose own manifest still carries a nested `manifest` object + * after the door's one-level normalization: registration reads the outer + * body's top-level `namespace`, so that is the key the gate must judge. + */ +const stillNested = (id: string, namespace: string): Bag => ({ + manifest: { id, name: 'p', version: '1.0.0', type: 'app', namespace, manifest: { namespace: 'qa_ok' } }, +}); + +/** The declaration's own sentence for a value, read from the schema — never a copy of it. */ +function declaredSentence(value: unknown): string { + const parsed = ManifestSchema.shape.namespace.safeParse(value); + expect(parsed.success).toBe(false); + return parsed.success ? '' : parsed.error.issues[0]!.message; +} + +function makeRawApp() { + const routes = new Map(); + return { + routes, + get: (p: string, h: Handler) => routes.set(`GET ${p}`, h), + post: (p: string, h: Handler) => routes.set(`POST ${p}`, h), + delete: (p: string, h: Handler) => routes.set(`DELETE ${p}`, h), + }; +} + +function makeC(body: any) { + const json = vi.fn((payload: any, status?: number) => ({ payload, status: status ?? 200 })); + return { + req: { + url: `http://localhost:3000${ROUTE}`, + raw: new Request(`http://localhost:3000${ROUTE}`), + json: async () => body, + param: () => undefined, + }, + json, + }; +} + +/** The plugin through its real lifecycle, every writer the install path reaches recorded. */ +async function mount(dir: string, opts: { controlPlaneUrl?: string } = {}) { + const rawApp = makeRawApp(); + const hooks = new Map(); + const registry: any[] = []; + const register = vi.fn((m: any) => { registry.push({ manifest: m }); }); + const syncSchemas = vi.fn(async () => undefined); + const services: Record = { + manifest: { register }, + auth: installerAuthService(), + objectql: withInstallerGrants({ syncSchemas, registry: { getAllPackages: () => registry } }), + }; + const ctx = { + hook: (e: string, h: any) => hooks.set(e, h), + getService: (name: string) => { + if (name === 'http-server') return { getRawApp: () => rawApp }; + const svc = services[name]; + if (svc === undefined) throw new Error(`no ${name}`); + return svc; + }, + logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() }, + }; + const plugin = new MarketplaceInstallLocalPlugin({ controlPlaneUrl: opts.controlPlaneUrl ?? 'off', storageDir: dir }); + await plugin.start(ctx as any); + await hooks.get('kernel:ready')?.(); + const registeredAtBoot = register.mock.calls.length; + const syncedAtBoot = syncSchemas.mock.calls.length; + return { + install: (body: Bag) => rawApp.routes.get(`POST ${ROUTE}`)!(makeC(body)), + installRegistrations: () => register.mock.calls.slice(registeredAtBoot).map((call) => call[0]), + installSyncs: () => syncSchemas.mock.calls.length - syncedAtBoot, + }; +} + +function expectDeclaredRefusal(res: { payload: any; status: number }, status: number) { + expect(res.status, JSON.stringify(res.payload)).toBe(status); + expect(BaseResponseSchema.safeParse(res.payload).success).toBe(true); + expect(envelopeViolations(res.payload)).toEqual([]); + expect(ApiErrorSchema.safeParse(res.payload.error).success).toBe(true); + expect(res.payload.success).toBe(false); + expect(res.payload.error.code).toBe('PLUGIN_MANIFEST_INVALID'); +} + +let dir: string; +const kernels: ObjectKernel[] = []; +beforeEach(() => { dir = mkdtempSync(join(tmpdir(), 'mil-namespace-gate-')); }); +afterEach(async () => { + while (kernels.length) { + const k = kernels.pop()!; + if (k.getState() === 'running') await k.shutdown(); + } + rmSync(dir, { recursive: true, force: true }); + vi.unstubAllGlobals(); + vi.unstubAllEnvs(); + vi.restoreAllMocks(); +}); + +function expectNothingWritten(h: { installRegistrations: () => unknown[]; installSyncs: () => number }) { + expect(h.installRegistrations()).toEqual([]); + expect(h.installSyncs()).toBe(0); + expect(readdirSync(dir)).toEqual([]); +} + +describe('install-local parses the inline manifest\'s `namespace` through its declaration', () => { + for (const [why, namespace] of REFUSED) { + it(`refuses ${why} (${JSON.stringify(namespace)}) — 400, the declaration's sentence, nothing written`, async () => { + const h = await mount(dir); + const res = await h.install({ + manifest: { id: 'com.qa.p-up', name: 'p', version: '1.0.0', type: 'app', namespace, objects: [] }, + }); + expectDeclaredRefusal(res, 400); + expect(res.payload.error.message).toContain('`namespace`'); + expect(res.payload.error.message).toContain(declaredSentence(namespace)); + expectNothingWritten(h); + }); + } + + it('refuses a non-string namespace rather than registering it', async () => { + const h = await mount(dir); + const res = await h.install({ manifest: { id: 'com.qa.p-num', version: '1.0.0', namespace: 7, objects: [] } }); + expectDeclaredRefusal(res, 400); + expect(res.payload.error.message).toContain(declaredSentence(7)); + expectNothingWritten(h); + }); + + it('refuses a COMPILED bundle whose nested `manifest.namespace` is refused', async () => { + const h = await mount(dir); + const res = await h.install({ + manifest: { manifest: { id: 'com.qa.p-up', namespace: 'QA_N', version: '1.0.0', type: 'app' }, objects: [] }, + }); + expectDeclaredRefusal(res, 400); + expect(res.payload.error.message).toContain(declaredSentence('QA_N')); + expectNothingWritten(h); + }); + + it('UNMOVED — an artifact MEMBER\'s refused namespace keeps the artifact-entry parse\'s refusal, nothing written', async () => { + // Each `packages[]` entry is parsed whole through `ArtifactPackageSchema` + // before any write; this door adds no second judge of it. + const h = await mount(dir); + const thrown = await h.install({ + manifest: { + id: 'com.qa.suite', + version: '1.0.0', + packages: [ + { manifest: { id: 'com.qa.one', name: 'qa_one', version: '1.0.0', type: 'app', namespace: 'qa_one', objects: [] } }, + { manifest: { id: 'com.qa.two', name: 'qa_two', version: '1.0.0', type: 'module', namespace: 'QA_N', objects: [] } }, + ], + }, + }).then(() => undefined, (e: unknown) => e as { code?: string; status?: number; message?: string }); + expect(thrown?.code).toBe('INVALID_ARTIFACT_PACKAGE_ENTRY'); + expect(thrown?.status).toBe(422); + expect(thrown?.message).toContain(declaredSentence('QA_N')); + expectNothingWritten(h); + }); + + it('lit control — the same artifact with conforming member namespaces installs', async () => { + const h = await mount(dir); + const res = await h.install({ + manifest: { + id: 'com.qa.suite', + version: '1.0.0', + packages: [ + { manifest: { id: 'com.qa.one', name: 'qa_one', version: '1.0.0', type: 'app', namespace: 'qa_one', objects: [] } }, + { manifest: { id: 'com.qa.two', name: 'qa_two', version: '1.0.0', type: 'module', namespace: 'qa_two', objects: [] } }, + ], + }, + }); + expect(res.status, JSON.stringify(res.payload)).toBe(200); + expect(readdirSync(dir)).toEqual(['com.qa.suite.json']); + }); + + it('judges the namespace on the body registration reads, not a nested `manifest` it still carries', async () => { + const h = await mount(dir); + const res = await h.install({ manifest: stillNested('com.qa.p-up', 'QA_N') }); + expectDeclaredRefusal(res, 400); + expect(res.payload.error.message).toContain(declaredSentence('QA_N')); + expectNothingWritten(h); + }); + + it('lit control — a conforming namespace still installs', async () => { + const h = await mount(dir); + const res = await h.install({ manifest: { id: 'com.qa.p-ok', version: '1.0.0', type: 'app', namespace: 'qa_ok', objects: [] } }); + expect(res.status, JSON.stringify(res.payload)).toBe(200); + expect(h.installRegistrations().map((m) => m.namespace)).toEqual(['qa_ok']); + expect(readdirSync(dir)).toEqual(['com.qa.p-ok.json']); + }); + + it('lit control — an ABSENT namespace installs, as the declaration allows', async () => { + expect(ManifestSchema.shape.namespace.safeParse(undefined).success).toBe(true); + const h = await mount(dir); + const res = await h.install({ manifest: { id: 'com.qa.p-none', version: '1.0.0', type: 'app', objects: [] } }); + expect(res.status, JSON.stringify(res.payload)).toBe(200); + expect(h.installRegistrations().map((m) => m.id)).toEqual(['com.qa.p-none']); + expect(new LocalManifestSource(dir).read('com.qa.p-none').entry?.manifestId).toBe('com.qa.p-none'); + }); +}); + +describe('install-local parses the cloud snapshot\'s `namespace` through the same declaration', () => { + it('refuses a snapshot whose namespace the declaration refuses — 502 (an upstream payload), nothing written', async () => { + vi.stubEnv('OS_MARKETPLACE_PUBLIC_BASE_URL', 'off'); + vi.stubEnv('OS_CLOUD_API_KEY', 'svc-test-key'); + const fetchMock = vi.fn(async () => new Response( + JSON.stringify({ data: { manifest: { id: 'com.qa.p-up', version: '1.0.0', namespace: 'QA_N', objects: [] }, version: '1.0.0', version_id: 'ver_1' } }), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + )); + vi.stubGlobal('fetch', fetchMock); + const h = await mount(dir, { controlPlaneUrl: 'http://cloud.test' }); + const res = await h.install({ packageId: 'pkg_qa' }); + expect(fetchMock).toHaveBeenCalledTimes(1); + expectDeclaredRefusal(res, 502); + expect(res.payload.error.message).toContain(declaredSentence('QA_N')); + expectNothingWritten(h); + }); + + it('judges a snapshot\'s namespace on the body registration reads too — 502, nothing written', async () => { + vi.stubEnv('OS_MARKETPLACE_PUBLIC_BASE_URL', 'off'); + vi.stubEnv('OS_CLOUD_API_KEY', 'svc-test-key'); + const fetchMock = vi.fn(async () => new Response( + JSON.stringify({ data: { manifest: stillNested('com.qa.p-up', 'QA_N'), version: '1.0.0', version_id: 'ver_1' } }), + { status: 200, headers: { 'Content-Type': 'application/json' } }, + )); + vi.stubGlobal('fetch', fetchMock); + const h = await mount(dir, { controlPlaneUrl: 'http://cloud.test' }); + const res = await h.install({ packageId: 'pkg_qa' }); + expect(fetchMock).toHaveBeenCalledTimes(1); + expectDeclaredRefusal(res, 502); + expect(res.payload.error.message).toContain(declaredSentence('QA_N')); + expectNothingWritten(h); + }); +}); + +describe('over a real engine, the case variant never reaches the registry\'s namespace gate', () => { + const HOLDER = { id: 'com.qa.n-one', name: 'n', version: '1.0.0', type: 'app', namespace: 'qa_n', objects: [] }; + + /** The plugin over a REAL engine's `manifest` service and registry, booted to `kernel:ready`. */ + async function bootPlugin() { + const kernel = new ObjectKernel({ logger: { level: 'silent' }, gracefulShutdown: false } as never); + kernels.push(kernel); + await kernel.use(new ObjectQLPlugin()); + await kernel.bootstrap(); + const ql = kernel.getService('objectql'); + ql.registry.logLevel = 'silent'; + const rawApp = makeRawApp(); + const hooks = new Map Promise>(); + const services: Record = { + manifest: kernel.getService('manifest'), + auth: installerAuthService(), + objectql: withInstallerGrants({ + convertPackageBodyForward: (body: unknown) => ql.convertPackageBodyForward(body), + registry: ql.registry, + get manifests() { return (ql as unknown as { manifests: Map }).manifests; }, + syncSchemas: async () => undefined, + }), + }; + const ctx = { + hook: (e: string, h: () => Promise) => hooks.set(e, h), + getService: (name: string) => { + if (name === 'http-server') return { getRawApp: () => rawApp }; + if (!(name in services)) throw new Error(`no ${name}`); + return services[name]; + }, + logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn(), debug: vi.fn() }, + }; + const plugin = new MarketplaceInstallLocalPlugin({ controlPlaneUrl: 'off', storageDir: dir }); + const p = plugin as unknown as Record; + p.bindArtifactHandlers = async () => undefined; + p.applySideEffects = async () => ({ translationsLoaded: 0, seeded: { mode: 'none' } }); + await plugin.start(ctx as never); + await hooks.get('kernel:ready')?.(); + const install = (body: Bag) => rawApp.routes.get(`POST ${ROUTE}`)!(makeC(body)); + const holderRes = await install({ manifest: HOLDER }); + expect(holderRes.status, JSON.stringify(holderRes.payload)).toBe(200); + return { ql, install }; + } + + const ledgerIds = () => new LocalManifestSource(dir).list().entries.map((e) => e.manifestId).sort(); + + it('`QA_N` beside an owner of `qa_n` answers the 400 and the registry does not hold it', async () => { + const { ql, install } = await bootPlugin(); + const res = await install({ manifest: { id: 'com.qa.p-up', name: 'p', version: '1.0.0', type: 'app', namespace: 'QA_N', objects: [] } }); + expectDeclaredRefusal(res, 400); + expect(res.payload.error.message).toContain(declaredSentence('QA_N')); + expect(ql.registry.getPackage('com.qa.p-up')).toBeUndefined(); + expect(ql.registry.getNamespaceOwners('qa_n')).toEqual([HOLDER.id]); + expect(ledgerIds()).toEqual([HOLDER.id]); + }); + + it('the same refusal on the body registration reads: the registry holds nothing under that namespace', async () => { + const { ql, install } = await bootPlugin(); + const res = await install({ manifest: stillNested('com.qa.p-up', 'QA_N') }); + expectDeclaredRefusal(res, 400); + expect(ql.registry.getPackage('com.qa.p-up')).toBeUndefined(); + expect(ql.registry.getNamespaceOwners('QA_N')).toEqual([]); + expect(ledgerIds()).toEqual([HOLDER.id]); + }); + + it('CONTROL — `qa_n` beside that owner still meets the registry\'s own namespace gate, unchanged', async () => { + const { ql, install } = await bootPlugin(); + const res = await install({ manifest: { id: 'com.qa.n-two', name: 'n2', version: '1.0.0', type: 'app', namespace: 'qa_n', objects: [] } }); + expect(res.status, JSON.stringify(res.payload)).toBe(422); + expect(res.payload.error.code).toBe('PLUGIN_REGISTER_FAILED'); + expect(res.payload.error.message).toContain(HOLDER.id); + expect(res.payload.error.message).toContain('qa_n'); + expect(ql.registry.getPackage('com.qa.n-two')).toBeUndefined(); + expect(ql.registry.getNamespaceOwners('qa_n')).toEqual([HOLDER.id]); + expect(ledgerIds()).toEqual([HOLDER.id]); + }); +}); diff --git a/packages/cloud-connection/src/marketplace-install-local-plugin.ts b/packages/cloud-connection/src/marketplace-install-local-plugin.ts index 4f0a8908aab..124c88a63a1 100644 --- a/packages/cloud-connection/src/marketplace-install-local-plugin.ts +++ b/packages/cloud-connection/src/marketplace-install-local-plugin.ts @@ -27,6 +27,9 @@ * before anything else looks at it; an id the declaration refuses * answers `PLUGIN_MANIFEST_INVALID` (400 for an inline manifest, * 502 for a cloud snapshot) and nothing is registered or written. + * So is its `namespace`, through `ManifestSchema.shape.namespace` + * (#33922): absent is admitted, a value the declaration refuses + * answers `PLUGIN_MANIFEST_INVALID` the same way. * A package declaring code this door cannot run answers * `VALIDATION_ERROR` (422) the same way: an enabled job with no * `body`, or one whose `body` the declaration refuses (#21585), and @@ -960,6 +963,40 @@ function judgeWithheldMaps( return { ok: true, withheldMaps: declared.data ?? [] }; } +/** + * [#33922, ADR-0048 §2] The package's `namespace`, parsed through its + * declaration (`ManifestSchema.shape.namespace`, `NAMESPACE_PATTERN`), by + * reference, ON THE BODY REGISTRATION READS: `manifest` is the body this door + * hands `manifest.register` (after `normalizeBundle`), and the registry + * installs it under that body's own top-level `namespace` — the key its install-time namespace + * gate compares. ⛔ Never a nested read ({@link declaredPackageManifest}): a + * judge reading any other key than the one registration reads answers about + * a namespace nothing installs under. `null` admits it; otherwise the refusal + * sentence. + * + * Absent is admitted, as the declaration admits it. Without this, `''`, + * `'QA_N'` or `'9-Bad Ns!'` registered as written: a namespace no author can + * declare, and a case variant of an owned one (`QA_N` beside `qa_n`) that the + * gate's uniqueness comparison never reads as the same namespace. + * + * ⛔ Not the members of a multi-package artifact: each `packages[]` entry is + * already parsed WHOLE through `ArtifactPackageSchema` (the core's + * `resolveArtifactPackageOrder`, reached here through {@link unrunnableCode} + * before any write), whose refusal of the same namespace is + * `INVALID_ARTIFACT_PACKAGE_ENTRY` / 422. A second judge here would move that + * answer, not close a gap. + * + * The sentence is the declaration's own inside the frame an invalid + * `installModes` is answered with ({@link judgeInstallMode}); no wording is + * minted. + */ +function namespaceRefusal(manifest: Record, manifestId: string): string | null { + const declared = ManifestSchema.shape.namespace.safeParse(manifest.namespace); + if (declared.success) return null; + const [issue] = declared.error.issues; + return `Package '${manifestId}' declares an invalid \`namespace\`: ${issue?.message ?? 'refused by its declaration'}.`; +} + /** * [#28640 ruling ③A] The operator's line for an install that received * withheld maps: each one named, once, at `warn` — the connector is installed @@ -2603,6 +2640,26 @@ export class MarketplaceInstallLocalPlugin implements Plugin { const manifestId = declaredId.data; if (inlineManifest) packageId = manifestId; + // 1b″. [#33922, ADR-0048 §2] ⭐ THE DOOR PARSES THE PACKAGE NAMESPACE — + // through its declaration, `ManifestSchema.shape.namespace`, by + // reference ({@link namespaceRefusal}), right after the id and at + // the same converged point, judged on the body registration reads, + // so neither the registry's install-time namespace gate nor the + // ledger write ever sees a namespace no author can declare. Before + // this, `''`, `'QA_N'` and `'9-Bad Ns!'` installed with a 200, and + // `QA_N` beside an owner of `qa_n` passed the gate, whose + // uniqueness comparison never read the two as one namespace. An + // absent namespace is admitted, as the declaration admits it. + // The id gate's status split (400 caller input, 502 upstream + // snapshot) and its rehydrate exemption (an entry an older build + // ledgered under such a namespace still loads and can be removed). + { + const refusal = namespaceRefusal(manifest, manifestId); + if (refusal !== null) { + return c.json({ success: false, error: { code: 'PLUGIN_MANIFEST_INVALID', message: refusal } }, callerManifest ? 400 : 502); + } + } + // 1b′. [#31963, cloud#3624 ruling A] ⭐ THE GRANT GOVERNS THE COPY. A // grant-path inline manifest is copied only when it declares the // package and version the control plane granted: the cloud