REAL-WORLD-SCHEMAS-13: Referential graph: membership and supersession
What it demonstrates
Section titled “What it demonstrates”docRules asserting a milestone’s members all exist and no entity references a superseded id.
Builds on: REAL-WORLD-SCHEMAS-12: First cross-document check: dangling depends_on
How it’s done
Section titled “How it’s done”A TypeScript program against the library API; inline comments show the resulting values and behavior.
const milestone = contract({ frontmatter: z.object({ id: z.string(), members: z.array(z.string()) }).strict(), rules: [ docRule("milestone/members-exist", (doc, ctx) => doc.frontmatter.members.filter(m => !TASK_IDS.has(m)).map(m => ctx.finding({ id: "milestone/members-exist", level: "error", message: `member ${m} has no task` }))), docRule("decision/no-superseded-ref", (doc, ctx) => doc.frontmatter.related.filter(r => SUPERSEDED.has(r)).map(r => ctx.finding({ id: "decision/no-superseded-ref", level: "warn", message: `references superseded ${r}` }))), ],});Surfaces exercised
Section titled “Surfaces exercised”multiple docRule()s per contract; cross-document referential invariantsmixed error/warn finding levels