From 4885e48805b11713c5e685f7ca467130da382302 Mon Sep 17 00:00:00 2001 From: callumalpass Date: Sat, 3 Oct 2026 21:20:07 +1000 Subject: [PATCH] Require invalid_type_pack for schema-level upgrade_from violations --- 05a-data-contracts.md | 3 ++- .../invalid-empty-baselines/_types/note.md | 22 +++++++++++++++++++ .../invalid-empty-baselines/mdbase-pack.yaml | 11 ++++++++++ .../_types/note.md | 22 +++++++++++++++++++ .../mdbase-pack.yaml | 13 +++++++++++ tests/v0.3/type-packs/type-packs.yaml | 22 +++++++++++++++++++ 6 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 examples/v0.3/seed-upgrades/invalid-empty-baselines/_types/note.md create mode 100644 examples/v0.3/seed-upgrades/invalid-empty-baselines/mdbase-pack.yaml create mode 100644 examples/v0.3/seed-upgrades/invalid-incomplete-baseline/_types/note.md create mode 100644 examples/v0.3/seed-upgrades/invalid-incomplete-baseline/mdbase-pack.yaml diff --git a/05a-data-contracts.md b/05a-data-contracts.md index 299ae0d..ae20025 100644 --- a/05a-data-contracts.md +++ b/05a-data-contracts.md @@ -383,7 +383,8 @@ part of the reviewed manifest and its digest. Ordinary seeds are unaffected. Engines that do not support this member MUST reject the manifest. The manifest is invalid (`invalid_type_pack`) when `upgrade_from` appears on a -resource that is not a seed type, when a baseline's digest is not the SHA-256 of +resource that is not a seed type, when it is an empty list, when a baseline lacks +`digest` or `document`, when a baseline's digest is not the SHA-256 of its document, when two baselines share a digest, when a baseline's digest equals the resource's own digest, when a baseline document's frontmatter `kind` or `name` differs from the desired document's, or when a baseline's `version` diff --git a/examples/v0.3/seed-upgrades/invalid-empty-baselines/_types/note.md b/examples/v0.3/seed-upgrades/invalid-empty-baselines/_types/note.md new file mode 100644 index 0000000..1d283b5 --- /dev/null +++ b/examples/v0.3/seed-upgrades/invalid-empty-baselines/_types/note.md @@ -0,0 +1,22 @@ +--- +kind: mdbase.type +name: note +version: 3 +description: A note with a creation date and tags. +match: + where: + type: note +schema: + dialect: json-schema-2020-12 + value: + type: object + required: [title] + properties: + title: { type: string } + created: { type: string, format: date-time } + tags: { type: array, items: { type: string } } + additionalProperties: true +--- +# Note + +A note in this collection. diff --git a/examples/v0.3/seed-upgrades/invalid-empty-baselines/mdbase-pack.yaml b/examples/v0.3/seed-upgrades/invalid-empty-baselines/mdbase-pack.yaml new file mode 100644 index 0000000..0875bb6 --- /dev/null +++ b/examples/v0.3/seed-upgrades/invalid-empty-baselines/mdbase-pack.yaml @@ -0,0 +1,11 @@ +kind: mdbase.type-pack +id: example.seed-notes +version: 3.0.0 +name: Seed note example +resources: + - kind: type + mode: seed + source: _types/note.md + target: _types/note.md + digest: sha256:57160cce297903e123f876d789d518ed83b1cf790edafae660f43f3d44744065 + upgrade_from: [] diff --git a/examples/v0.3/seed-upgrades/invalid-incomplete-baseline/_types/note.md b/examples/v0.3/seed-upgrades/invalid-incomplete-baseline/_types/note.md new file mode 100644 index 0000000..1d283b5 --- /dev/null +++ b/examples/v0.3/seed-upgrades/invalid-incomplete-baseline/_types/note.md @@ -0,0 +1,22 @@ +--- +kind: mdbase.type +name: note +version: 3 +description: A note with a creation date and tags. +match: + where: + type: note +schema: + dialect: json-schema-2020-12 + value: + type: object + required: [title] + properties: + title: { type: string } + created: { type: string, format: date-time } + tags: { type: array, items: { type: string } } + additionalProperties: true +--- +# Note + +A note in this collection. diff --git a/examples/v0.3/seed-upgrades/invalid-incomplete-baseline/mdbase-pack.yaml b/examples/v0.3/seed-upgrades/invalid-incomplete-baseline/mdbase-pack.yaml new file mode 100644 index 0000000..203c3e4 --- /dev/null +++ b/examples/v0.3/seed-upgrades/invalid-incomplete-baseline/mdbase-pack.yaml @@ -0,0 +1,13 @@ +kind: mdbase.type-pack +id: example.seed-notes +version: 3.0.0 +name: Seed note example +resources: + - kind: type + mode: seed + source: _types/note.md + target: _types/note.md + digest: sha256:57160cce297903e123f876d789d518ed83b1cf790edafae660f43f3d44744065 + upgrade_from: + - digest: sha256:28887fbf68c97de99bc271209466bbf457a3635b3ed2ee93e6c5bf8213f53c10 + version: 2 diff --git a/tests/v0.3/type-packs/type-packs.yaml b/tests/v0.3/type-packs/type-packs.yaml index 86d13dc..b94c93c 100644 --- a/tests/v0.3/type-packs/type-packs.yaml +++ b/tests/v0.3/type-packs/type-packs.yaml @@ -433,3 +433,25 @@ groups: code: invalid_type_pack covers: - type_packs.seed_type_upgrade_validation + - id: seed-upgrade-invalid-empty-baselines + name: "invalid upgrade_from (empty-baselines) rejects the manifest with invalid_type_pack" + operation: assess_type_pack + input: + pack: "examples/v0.3/seed-upgrades/invalid-empty-baselines/mdbase-pack.yaml" + expect: + valid: false + error: + code: invalid_type_pack + covers: + - type_packs.seed_type_upgrade_validation + - id: seed-upgrade-invalid-incomplete-baseline + name: "invalid upgrade_from (incomplete-baseline) rejects the manifest with invalid_type_pack" + operation: assess_type_pack + input: + pack: "examples/v0.3/seed-upgrades/invalid-incomplete-baseline/mdbase-pack.yaml" + expect: + valid: false + error: + code: invalid_type_pack + covers: + - type_packs.seed_type_upgrade_validation