Skip to content

Leave the explicit type key to the collection in starter types - #14

Merged
callumalpass merged 1 commit into
mainfrom
fix/type-key-portability
Oct 2, 2026
Merged

callumalpass merged 1 commit into
mainfrom
fix/type-key-portability

Conversation

@callumalpass

Copy link
Copy Markdown
Contributor

Apps create records by naming a type (create({ type: "person", … })), and the engine records it under the collection's configured settings.explicit_type_keys: type by default, but e.g. mdbase_type in Reader collections where type holds CSL data. Three starters also required type and pinned it to their own name, so their records fail validation in any collection whose key is something else:

explicit_type_keys: [mdbase_type]  →  create person  →  schema_required: type

View's closed top-level schema (additionalProperties: false) additionally rejected whichever key it did not declare, so no View type file could work under both keys.

Changes

  • types/person/3.md, types/comment/2.md, types/view/2.md: drop the pinned type property and its required entry. View v2's top level accepts unknown fields (nested query-language objects stay strict). Each keeps match: where: type: <name> so hand-written type: <name> records are still recognised, including in collections without explicit keys.
  • mdbase.contact 1.3.0, mdbase.comment 1.0.1, mdbase.view 1.0.1 ship them with upgrade_from the previous starter, so an unmodified installed seed is offered a reviewed upgrade. The superseded packs are visibility: hidden; their provisions stay byte-identical to main (contact 1.2.0 is now asserted alongside 1.0.0/1.1.0).
  • scripts/starter-type-keys.test.mjs: every current starter leaves type/types undeclared and unrequired and is not closed at the top level.
  • Comment tests read the v2 starter; a comment without type, or with mdbase_type, is valid. The People install matrix adds 1.3.0 and 1.2.0 → 1.3.0.

Behaviour (mdbase CLI, person starter)

explicit_type_keys app-created, before → after hand-written type: person
[type, types] valid → valid valid
[mdbase_type] invalid → valid valid (via match)
[] invalid → invalid (no key to record membership) valid

Not in this PR

  • runtime_* types are synced from the spec's standard packs, are closed, and their contracts map a contract field to type; that needs a contract-level decision.
  • contact v2 is no longer installed by any offered pack.
  • Downstream copies (Reader, Writer, Editor, TaskNotes) need their vendored packs updated after this merges.

Verification

npm test with MDBASE_VERIFY_CLI (mdbase 0.1.0-beta.120): 27 unit tests and 42 pack tests pass, including CLI dry run, install and repeat assessment of every catalog pack.

Apps create records by naming a type, and the engine records it under the
collection's configured explicit_type_keys. The Person, Comment and View
starters also required `type` and pinned it to their own name, so their
records failed validation (schema_required: type) in any collection whose key
is not `type`, such as Reader collections that use `mdbase_type` because
`type` holds citation data. View's closed top-level schema also rejected
whichever key it did not declare.

Person v3, Comment v2 and View v2 drop the pinned `type` property, and View v2
accepts unknown top-level fields. Each keeps its match rule so hand-written
`type: <name>` records are still recognised. mdbase.contact 1.3.0,
mdbase.comment 1.0.1 and mdbase.view 1.0.1 ship them with upgrade_from the
previous starter, and the superseded packs are hidden from the catalog with
their provisions byte-identical. A new test guards every current starter.
@callumalpass
callumalpass merged commit 7d3d31e into main Oct 2, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant