Skip to content

fix(schema): let memoryType satisfy conceptType's required check - #275

Merged
zircote merged 1 commit into
mainfrom
fix/274-concepttype-memorytype-anyof
Jul 15, 2026
Merged

fix(schema): let memoryType satisfy conceptType's required check#275
zircote merged 1 commit into
mainfrom
fix/274-concepttype-memorytype-anyof

Conversation

@zircote

@zircote zircote commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Closes #274.

Problem

schema/mif.schema.json's required list only ever accepted conceptType, unconditionally — despite README.md, docs/SCHEMA-REFERENCE.md, ns/README.md, and ADR-001's compliance audit all describing memoryType as a deprecated v0.1 alias for conceptType, "retained for backward compatibility." A document carrying only the legacy memoryType field always failed validation regardless of age — the documented promise was never actually implemented.

This surfaced concretely in PR #205, where an example using memoryType per that documented framing failed CI.

Fix

  • schema/mif.schema.json (+ public/schema/mif.schema.json): replaced the flat conceptType requirement with a top-level anyOf: [{required:[conceptType]}, {required:[memoryType]}], mirroring the existing DocumentReference $defs entry's own url/id anyOf pattern already in the same file.
  • schema/container.schema.json (+ its mirror): the Container Profile envelope schema has its own duplicate conceptType-required anchor for kind:memory records (documented as needing to stay in sync with mif.schema.json) — fixed the same way, so a legacy memoryType-only record inside a *.corpus.json envelope is no longer rejected at the envelope level after passing the per-unit schema.
  • Propagated both fixes to every schema mirror that is currently "live" — public/schema/1.3.0/, latest/, and v1/, which public/schema/index.json's aliases currently point at and which were confirmed (via diff) to be byte-identical to the pre-fix canonical root, not a frozen prior release. Older frozen versions (1.2.2, 1.2.1, 1.2.0, 1.0.0, 0.1.0) are untouched.
  • Added scripts/test_concept_type_alias.py (15 cases) as a permanent regression gate, wired into .github/workflows/validate.yml: conceptType-alone/memoryType-alone/both/neither across both schemas, mirror-consistency checks, and negative cases confirming the anyOf doesn't mask an unrelated missing required field or bypass the triad enum.

Verification

Re-ran every existing local gate against the change: okf_validate.py (15 concepts, PASS), mif_convert.py roundtrip (lossless, PASS), scripts/validate_container.py (PASS), ajv compile on all 5 copies of both schemas (all valid), full emit-jsonld + ajv validate over all 15 examples (all valid), test_subtype_of.py and test_temporal_and_properties.py (unaffected, still pass).

Test plan

  • python -m pytest scripts/test_concept_type_alias.py -v — 15 passed
  • python scripts/okf_validate.py examples profiles/ai-memory/examples docs/examples/memories — PASS
  • python scripts/mif_convert.py roundtrip examples profiles/ai-memory/examples docs/examples/memories — PASS
  • python scripts/validate_container.py — PASS
  • ajv compile on schema/ and all public/schema/ mirrors for both mif.schema.json and container.schema.json — all valid

schema/mif.schema.json's required list only ever accepted conceptType,
even though README.md, docs/SCHEMA-REFERENCE.md, ns/README.md, and
ADR-001's compliance audit describe memoryType as a deprecated alias
"retained for backward compatibility." A document carrying only the
legacy memoryType field always failed validation regardless of age.

Replaces the flat conceptType requirement with a top-level
anyOf: [{required: [conceptType]}, {required: [memoryType]}], mirroring
the existing DocumentReference $defs entry's own url/id anyOf pattern.
Applied the same fix to schema/container.schema.json's duplicate
kind:memory discrimination anchor (documented as needing to stay in
sync with mif.schema.json), and propagated both to every mirror that
is currently live (public/schema/, and the 1.3.0/latest/v1 dirs that
public/schema/index.json's aliases currently point at -- confirmed
via diff that those three are presently identical to the canonical
root, not a frozen prior release.

Adds scripts/test_concept_type_alias.py as a permanent regression gate
(15 cases: conceptType-alone/memoryType-alone/both/neither across both
schemas, mirror-consistency checks, and negative cases confirming the
anyOf doesn't mask other missing required fields or bypass the triad
enum), wired into validate.yml.
EOF
)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request fixes a long-standing schema/documentation mismatch by allowing the deprecated memoryType field (v0.1 alias) to satisfy the “required concept type” constraint that previously only accepted conceptType. It updates both the core MIF schema and the Container Profile envelope schema (plus their public mirrors), and adds a dedicated regression test to prevent future drift.

Changes:

  • Updated mif.schema.json to require either conceptType or memoryType via a top-level anyOf.
  • Updated container.schema.json’s kind: "memory" discrimination anchor to accept conceptType or memoryType, keeping it aligned with the core schema.
  • Added a new pytest regression suite and wired it into CI, including checks that public schema mirrors remain byte-identical where expected.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
scripts/test_concept_type_alias.py New regression tests for conceptType/memoryType required-alias behavior + mirror consistency checks.
schema/mif.schema.json Makes conceptType requirement satisfiable by legacy memoryType using anyOf.
schema/container.schema.json Aligns the Container Profile kind:memory required anchor with the new core schema behavior and updates descriptive text.
public/schema/mif.schema.json Propagates the core schema fix to the public canonical mirror.
public/schema/container.schema.json Propagates the container schema fix to the public canonical mirror.
public/schema/latest/mif.schema.json Propagates the core schema fix to the latest alias mirror.
public/schema/latest/container.schema.json Propagates the container schema fix to the latest alias mirror.
public/schema/v1/mif.schema.json Propagates the core schema fix to the v1 alias mirror.
public/schema/v1/container.schema.json Propagates the container schema fix to the v1 alias mirror.
public/schema/1.3.0/mif.schema.json Propagates the core schema fix to the current live versioned mirror.
public/schema/1.3.0/container.schema.json Propagates the container schema fix to the current live versioned mirror.
.github/workflows/validate.yml Adds CI execution of the new regression test suite.

@zircote
zircote merged commit e580302 into main Jul 15, 2026
27 checks passed
@zircote
zircote deleted the fix/274-concepttype-memorytype-anyof branch July 15, 2026 22:17
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.

memoryType is documented as a backward-compatible alias for conceptType, but schema/mif.schema.json never accepts it as sufficient

2 participants