Skip to content

cbrl schema (v0.3)

The cbrl file is validated by the normative JSON Schema published at its canonical URL:

PropertyTypeRequiredDescription
kind"cbrl-file"yes
schemaVersion"0.1.0" | "0.2.0" | "0.3.0"yes
requirementsCbrlRequirement[]yes
typesCbrlRequirementType[]noTyped CBRL (M39): TRLC-style requirement-type declarations — the opt-in types: block. OMITTED when the document declares no types, never defaulted to [], so untyped documents produce byte-identical models. Checked by ./type-check.ts; shapes in ./types.ts.
commentsCbrlComment[]no
notesModelNote[]noFile-level notes (see parser/model-note.ts) — omit-when-empty.
PropertyTypeRequiredDescription
commentsCbrlComment[]no
kind"acceptance-criteria"yes
idstringyes
descriptionstringyes
PropertyTypeRequiredDescription
commentsCbrlComment[]no
kind"access-rule"yes
idstringyes
descriptionstringyes
grantCbrlGrantClauseyes
targetCbrlOnClauseyes
effectCbrlActionClauseyes
whenCbrlPredicateExpr[]yes
PropertyTypeRequiredDescription
kind"action-clause"yes
effect"ALLOW" | "DENY"yes
actionsstring[]yes
PropertyTypeRequiredDescription
kind"and"yes
operandsCbrlPredicateExpr[]yes
PropertyTypeRequiredDescription
namestringyes
paramsRecord<string, unknown>yes
PropertyTypeRequiredDescription
kind"aspect-predicate"yes
namestringyes
paramsRecord<string, unknown>yes
PropertyTypeRequiredDescription
kind"boolean-literal"yes
valuebooleanyes

A source comment attached to the AST node it annotates (Model Text View F5). Trivia, not semantics — see ../comment-trivia.ts. comments? fields are optional and OMITTED when empty, never defaulted to [], so comment-free sources produce byte-identical ASTs.

Type: CommentTrivia

PropertyTypeRequiredDescription
kind"comparison"yes
leftCbrlValueExpryes
op"==" | "!=" | ">" | "<" | ">=" | "<="yes
rightCbrlValueExpryes
PropertyTypeRequiredDescription
kind"dotted-path"yes
namespace"principal" | "resource" | "context"yes
segmentsstring[]yes

One typed-field value bound on a requirement — the TRLC field = value assignment, plus where it was authored. A binding whose value is undefined (hand-edited models only — JSON cannot carry the key’s absence differently) is treated as ABSENT: it satisfies nothing, and a required field without a defined-value binding is reported missing.

PropertyTypeRequiredDescription
namestringyesWhich declared field this binds (verbatim, case-sensitive).
valueCbrlFieldValueyesThe bound value.
positionCbrlSourcePositionnoWhere the binding was authored (omitted for programmatic models).

Type: "string" | "enum" | "number" | "ref"

A typed-field VALUE: a string (for string/enum/ref kinds) or a finite number (for number). Anything else found in a (hand-edited or malformed) model is reported as a wrong-type finding, never thrown on.

Type: string

PropertyTypeRequiredDescription
kind"grant"yes
personasstring[]yes
PropertyTypeRequiredDescription
kind"grouped"yes
exprCbrlPredicateExpryes
PropertyTypeRequiredDescription
kind"in"yes
valueCbrlValueExpryes
targetCbrlListLiteral | CbrlDottedPathyes
PropertyTypeRequiredDescription
kind"list-literal"yes
valuesCbrlValueExpr[]yes
PropertyTypeRequiredDescription
kind"not"yes
operandCbrlPredicateExpryes
PropertyTypeRequiredDescription
kind"not-in"yes
valueCbrlValueExpryes
targetCbrlListLiteral | CbrlDottedPathyes
PropertyTypeRequiredDescription
kind"number-literal"yes
valuenumberyes
PropertyTypeRequiredDescription
kind"on"yes
screenstringyes
PropertyTypeRequiredDescription
kind"or"yes
operandsCbrlPredicateExpr[]yes

Type: CbrlComparisonExpr | CbrlInExpr | CbrlNotInExpr | CbrlAspectExpr | CbrlAndExpr | CbrlOrExpr | CbrlNotExpr | CbrlGroupedExpr

PropertyTypeRequiredDescription
commentsCbrlComment[]no
notesModelNote[]noNode notes (see parser/model-note.ts) — omit-when-empty.
kind"requirement"yes
idstringyes
descriptionstringyes
acceptanceCriteriaCbrlAcceptanceCriteria[]yes
testCasesCbrlTestCase[]yes
involvedAggregatesstring[]yes
linkedStoriesstring[]yes
aspectsCbrlAppliedAspect[]yes
enforcedInvariantsstring[]yes
generatedEventsstring[]yes
accessRulesCbrlAccessRule[]yes
typestringnoTyped CBRL (M39): the declared requirement type this requirement conforms to (a CbrlFile.types[].name). Absent ⇒ the requirement is untyped and skips the type check entirely.
fieldsCbrlFieldBinding[]noTyped CBRL (M39): the typed-field values this requirement carries. OMITTED when empty, never defaulted to [].
positionCbrlSourcePositionnoTyped CBRL (M39): where the requirement was authored (omitted when unknowable) — the anchor for type findings that have no value to point at (unknown type binding, missing required field).

One requirement-type declaration — the TRLC record type. A requirement binds to one by CbrlRequirement.type === name (verbatim, case-sensitive; first declaration wins when names repeat, which the check pass reports as a warn).

PropertyTypeRequiredDescription
namestringyesThe type name.
fieldsCbrlTypeField[]yesThe typed fields, in declaration order (the order fixes findings order).

A source position, on the house contract (../acm/access-rule.ts): offset 0-based, line/column 1-based; fields omitted when unknowable.

PropertyTypeRequiredDescription
offsetnumberno
linenumberno
columnnumberno
PropertyTypeRequiredDescription
kind"string-literal"yes
valuestringyes
PropertyTypeRequiredDescription
commentsCbrlComment[]no
kind"test-case"yes
idstringyes
descriptionstringyes

One typed field of a requirement-type declaration.

PropertyTypeRequiredDescription
namestringyesField name — matched verbatim (case-sensitive) against a requirement's bindings.
typeCbrlFieldTypeyesThe field kind.
requiredbooleannoRequired field; omitted for optional (the TRLC mandatory/optional axis).
patternstringnoRegex SOURCE string (ECMAScript dialect) the value must match IN FULL — the check pass anchors it. Applies to string, enum and ref values. An invalid source never throws: it downgrades to a warn finding and the pattern check is skipped.
enumIdsstring[]notype: "enum" — the allowed ids. Absent/empty ⇒ unconstrained (warn).
positionCbrlSourcePositionnoWhere the field was declared (omitted for programmatic models).

Type: CbrlDottedPath | CbrlStringLiteral | CbrlNumberLiteral | CbrlBooleanLiteral

PropertyTypeRequiredDescription
kind"comment"yes
textstringyesComment content without the marker, trimmed.
position"leading" | "trailing"yes
PropertyTypeRequiredDescription
kind"model-note"yes
idstringyesStable id ("note-" + 12 hex chars); survives JSON round-trips.
audienceModelNoteAudienceyesWho the note is for. Drives delivery: only "agent" reaches agent payloads.
textstringyesMarkdown body.
authorstringno
createdAtstringnoISO 8601 timestamps.
updatedAtstringno
resolvedbooleannoLifecycle flag — resolved ≠ deleted.
fieldstringnoOptional sub-node scope: a member/property name of the anchored node.

Type: "user" | "agent"

Representative cbrl files committed under samples/cbrl/. Each demo shows three views — pick the one you want: Canvas (rendered through the same SvelteFlow component the IDE uses), Mermaid (a static-flowchart fallback), or Raw JSON. All assets are locally served; no GitHub redirect.

↓ download
demo-01-single-requirement.json — Context Studio canvas view

Demo 1 — minimal CBRL file: a single requirement with one acceptance criterion. The smallest viable CBRL shape.

demo-01-single-requirement.json — Demo 1 — minimal CBRL file: a single requirement with one acceptance criterion. The smallest viable CBRL shape. (expand for full JSON)
demo-01-single-requirement.json
{
"kind": "cbrl-file",
"schemaVersion": "0.1.0",
"requirements": [
{
"kind": "requirement",
"id": "REQ-001",
"description": "A todo can be created.",
"acceptanceCriteria": [
{
"kind": "acceptance-criteria",
"id": "AC-001",
"description": "POST /todos returns 201 with the created todo."
}
],
"testCases": [],
"involvedAggregates": ["Todo"],
"linkedStories": [],
"aspects": [],
"enforcedInvariants": [],
"generatedEvents": [],
"accessRules": []
}
]
}
↓ download
demo-02-booking-requirement.json — Context Studio canvas view

Demo 2 — CBRL requirement with multiple acceptance criteria, an involved aggregate, linked story, enforced invariant, and generated event. The canonical 'realistic' example.

demo-02-booking-requirement.json — Demo 2 — CBRL requirement with multiple acceptance criteria, an involved aggregate, linked story, enforced invariant, and generated event. The canonical ‘realistic’ example. (expand for full JSON)
demo-02-booking-requirement.json
{
"kind": "cbrl-file",
"schemaVersion": "0.1.0",
"requirements": [
{
"kind": "requirement",
"id": "BOOK-001",
"description": "A traveler can confirm a booking.",
"acceptanceCriteria": [
{
"kind": "acceptance-criteria",
"id": "AC-BOOK-01",
"description": "POST /bookings/:id/confirm returns 200."
},
{
"kind": "acceptance-criteria",
"id": "AC-BOOK-02",
"description": "A confirmation email is sent within 60 seconds."
}
],
"testCases": [],
"involvedAggregates": ["Booking"],
"linkedStories": ["US-002"],
"aspects": [],
"enforcedInvariants": ["confirmed-has-payment"],
"generatedEvents": ["BookingConfirmed"],
"accessRules": []
}
]
}
↓ download
demo-03-aspects-and-access.json — Context Studio canvas view

Demo 3 — CBRL with cross-cutting aspects (@security, @audit) and ACM access rules. Exercises the cross-model integration vocabulary.

demo-03-aspects-and-access.json — Demo 3 — CBRL with cross-cutting aspects (@security, @audit) and ACM access rules. Exercises the cross-model integration vocabulary. (expand for full JSON)
demo-03-aspects-and-access.json
{
"kind": "cbrl-file",
"schemaVersion": "0.1.0",
"requirements": [
{
"kind": "requirement",
"id": "ADMIN-001",
"description": "Admins can manage users.",
"acceptanceCriteria": [
{
"kind": "acceptance-criteria",
"id": "AC-ADMIN-01",
"description": "Admin can list, view, edit, and delete users."
}
],
"testCases": [],
"involvedAggregates": ["User"],
"linkedStories": [],
"aspects": [
{
"name": "security",
"params": {}
},
{
"name": "audit",
"params": {}
}
],
"enforcedInvariants": [],
"generatedEvents": [],
"accessRules": [
{
"kind": "access-rule",
"id": "rule-l9kh2",
"description": "ALLOW view,edit,delete for admin",
"grant": {
"kind": "grant",
"personas": ["admin"]
},
"target": {
"kind": "on",
"screen": "*"
},
"effect": {
"kind": "action-clause",
"effect": "ALLOW",
"actions": ["view", "edit", "delete"]
},
"when": []
},
{
"kind": "access-rule",
"id": "rule-x2hoa",
"description": "DENY delete for user",
"grant": {
"kind": "grant",
"personas": ["user"]
},
"target": {
"kind": "on",
"screen": "*"
},
"effect": {
"kind": "action-clause",
"effect": "DENY",
"actions": ["delete"]
},
"when": []
}
]
}
]
}
↓ download
demo-04-payment-with-predicate.json — Context Studio canvas view

Demo 4 — CBRL payment requirement with predicate-based access rule, multiple events, and idempotency acceptance criterion.

demo-04-payment-with-predicate.json — Demo 4 — CBRL payment requirement with predicate-based access rule, multiple events, and idempotency acceptance criterion. (expand for full JSON)
demo-04-payment-with-predicate.json
{
"kind": "cbrl-file",
"schemaVersion": "0.1.0",
"requirements": [
{
"kind": "requirement",
"id": "PAY-001",
"description": "A traveler can pay for a booking.",
"acceptanceCriteria": [
{
"kind": "acceptance-criteria",
"id": "AC-PAY-01",
"description": "Card is authorized within 5 seconds."
},
{
"kind": "acceptance-criteria",
"id": "AC-PAY-02",
"description": "Failed authorization emits a PaymentFailed event."
},
{
"kind": "acceptance-criteria",
"id": "AC-PAY-03",
"description": "Idempotency: replays return the original outcome."
}
],
"testCases": [],
"involvedAggregates": ["Payment", "Booking"],
"linkedStories": ["US-002"],
"aspects": [
{
"name": "security",
"params": {}
}
],
"enforcedInvariants": ["amount-positive", "refund-only-after-capture"],
"generatedEvents": [
"PaymentAuthorized",
"PaymentCaptured",
"PaymentRefunded"
],
"accessRules": [
{
"kind": "access-rule",
"id": "rule-herxq",
"description": "ALLOW create for traveler",
"grant": {
"kind": "grant",
"personas": ["traveler"]
},
"target": {
"kind": "on",
"screen": "*"
},
"effect": {
"kind": "action-clause",
"effect": "ALLOW",
"actions": ["create"]
},
"when": []
},
{
"kind": "access-rule",
"id": "rule-y0izl",
"description": "ALLOW view,refund for admin",
"grant": {
"kind": "grant",
"personas": ["admin"]
},
"target": {
"kind": "on",
"screen": "*"
},
"effect": {
"kind": "action-clause",
"effect": "ALLOW",
"actions": ["view", "refund"]
},
"when": []
}
]
}
]
}

The cbrl model is one of the richly-curated records — every downstream surface (CLI, MCP, docs, tests) reads from one record. The pasteable snippet below is the Door 1 anchor a downstream agent should see before touching this model.

paste into AGENTS.md / CLAUDE.md
- **CBRL v0.3.0** — `models/cbrl.json`.
Produces: Requirements doc, Gherkin features, Vitest suites, aspect tests, per-AC behavior tests; requirements seed recipe assembly.
Oracle: per-AC behavior tests must fail first and end green; `ctxbrew check --gate` holds provenance (requirement ↔ story ↔ test).
Downstream: `ctxbrew semantics cbrl` · `ctxbrew://semantics/cbrl/v0.3.0` — read the record first.

The full record (every door — anchor template, tool description hint, response annotations, behavior tripwire, and the complete produced-surface list) is served as JSON at:

  • CLI — ctxbrew semantics cbrl --schema-version 0.3.0
  • MCP — ctxbrew://semantics/cbrl/v0.3.0
  • HTTP — https://contextbrew.dev/schemas/cbrl/v0.3/semantics.json

See the schemas overview for the versioning policy and how these files are generated and kept in sync.