Relationships, Headings, and Templates
Audience: collection authors.
Authoritative for:
- relationship kinds, the relationship block shape, and relationship constraints
- heading rules, including the H1 and H2 contracts
- template content obligations
See also:
- Note Links: how internal note links are parsed and resolved
- Note Type Schemas: the schema file contract and
template.filepath rules - Foundations: parsing and string comparison baselines
- Template Tracking: template-region ownership, receipt state, drift classification, and reconciliation
- Content Expansion: derived Markdown regions, rendering, synchronization, and ejection
Relationship Model#
belongs_to models primary ownership or governing context; related_to models
secondary association. Schema declarations constrain typed relationship
instances, not the permission to write ordinary internal links. Instances come
from resolved note links under the rules below.
Rules:
- RHT-5 Concrete relationship instances are computed from resolved internal note links using the rules in Note Links.
- RHT-6 Metadata properties contribute typed relationship instances only when their field definitions declare
relationship_kind. - RHT-7 Body internal note links participate only in the
related_torelationship model, and contribute typed relationship instances only for target note types declared underrelated_to; every other body link is purely navigational. - RHT-10 Inverse views MAY be derived by tooling and MUST NOT require duplicate schema declarations.
Relationship Constraints#
A relationship block contains belongs_to.allowed_note_types and
related_to.allowed_note_types. Both default to empty. Each target has optional
min/max bounds, defaulting to zero/unbounded.
Rules:
- RHT-14 If a schema file physically declares
relationships, it MUST define bothrelationships.belongs_to.allowed_note_typesandrelationships.related_to.allowed_note_types. - RHT-15 Every referenced target note type MUST be a note type defined in the same collection; it MAY be abstract.
- RHT-20 Within a single relationship kind, a target note type identifier MUST appear at most once.
- RHT-21 The target note type sets for
belongs_toandrelated_toMUST be disjoint for a given source note type, after expanding abstract targets to their concrete descendants. - RHT-25 If present,
minandmaxMUST be non-negative integers. - RHT-26 If both are present,
maxMUST be greater than or equal tomin. - RHT-27 If a target note type is not declared, no typed-relationship constraint applies to links targeting notes of that type; such links remain valid internal note links and do not create typed relationship instances.
- RHT-30 Schema-definition validation MUST validate declaration shape, referenced note types, cardinality values, and disjointness of relationship kinds.
- RHT-31 Concrete relationship instance validation MUST evaluate the resolved typed relationship instances against the declared targets and cardinality of the source note type's effective schema.
- RHT-32 For
belongs_to, concrete relationship instances are the unique resolved targets referenced by frontmatter fields withrelationship_kind: belongs_to. - RHT-33 For
related_to, concrete relationship instances are the union of:- unique resolved targets referenced by frontmatter fields with
relationship_kind: related_to - unique resolved targets referenced by internal note links in the note body
- unique resolved targets referenced by frontmatter fields with
- RHT-34 Only resolved managed-note targets create concrete relationship instances.
- RHT-35 Unresolved placeholders do not satisfy minimum-cardinality requirements until they resolve to concrete targets.
- RHT-36 Duplicate concrete links from the same source note to the same target note under the same relationship kind are semantically idempotent and count once.
- RHT-37 A logically deleted target MUST be excluded from relationship cardinality while its note links remain resolvable.
- RHT-39 Link validity failures are reported as
invalid_note_link; cardinality failures on declared targets are reported asinvalid_relationship_instance, as defined in Collection Model. - RHT-40 A Markdown link in body content with a destination that is not a supported internal note-link form does not participate in typed relationship conformance.
- RHT-41 Temporary draft states during authoring or UI workflows are outside persisted conformance.
- RHT-42 Applications MAY allow transient draft states during authoring, but a persisted note or instantiated collection claimed as conforming MUST satisfy the cardinality rules derived from its note type.
For example, a declared target with min: 1 needs one resolved, non-deleted
managed target. A deleted source is still validated against its own constraints;
deletion does not exempt the source from validation.
Heading Rules#
Headings are unconstrained unless configured. The effective defaults are empty
required/optional H2 lists, allow_other_h2: true, require_order: false, and
require_h1_title: false.
Rules:
- RHT-47 Heading detection MUST use CommonMark 0.31.2 block structure, excluding code blocks and code spans.
- RHT-48 H1 headings are ungoverned by default: a managed note MAY contain zero or more H1 headings, and no relationship between an H1 and the
titlefield is assumed. - RHT-49 A
headingsblock MAY declarerequire_h1_titleto couple the body H1 to the note'stitlefield. - RHT-50
require_h1_titleMUST be a boolean; if omitted, it defaults tofalse. - RHT-51 With
require_h1_title: true, the body MUST have exactly one H1 that precedes every other heading and equals the effective Core title. - RHT-52 A null effective title cannot satisfy
require_h1_title. - RHT-53 A
require_h1_titleviolation is aninvalid_headingfailure. - RHT-54 H1 and H2 text MUST use the same extraction procedure.
- RHT-55 Other heading validation applies to H2 headings only.
- RHT-56 Heading text MUST be the block parser's inline source after removing ATX/setext delimiters, joining setext content lines with spaces, and trimming outer whitespace without interpreting inline Markdown.
- RHT-57 A managed-note H2 heading matches a declared heading entry when their texts are equal under the string comparison rules defined in Foundations.
- RHT-58
required_h2entries MUST appear exactly once unless a future specification version says otherwise. - RHT-59
optional_h2entries MAY appear zero or one time. - RHT-60 If
allow_other_h2isfalse, undeclared H2 headings MUST NOT appear. - RHT-61 If
allow_other_h2istrue, undeclared H2 headings MAY appear. - RHT-62 With
require_order: true, matched headings MUST preserve the relative order within each declared list independently. - RHT-63 If
require_orderisfalse, declared H2 headings MAY appear in any order. - RHT-64 H3 and deeper headings are unconstrained by this version of the specification.
- RHT-285 Each required/optional H2 list MUST contain unique non-empty text entries.
- RHT-286 The required and optional H2 lists MUST be disjoint under the string comparison baseline.
For example, required [Context, Decision] and optional [Notes, References]
allow Context, Notes, Decision, References when ordering is enabled. ## Context ##
and a setext H2 named Context both match Context; ## *Context* matches
the literal entry *Context*, not Context.
Templates#
A template is starter state, not a persisted managed note. When no explicit template is selected and the conventional file is absent, the starter state is derived from the concrete schema: declared fields have null placeholders, mandatory tags have their required values, required H2s are empty sections, and there is no additional prose.
An existing template overrides that derived state. Its YAML frontmatter can be partial or absent; omission does not erase a derived field. An explicitly named missing file is an error rather than a reason to hide a broken reference.
## Context
Explain the background.
## Decision
Rules:
- RHT-65 A concrete type MUST use its explicit template when supplied, otherwise its existing conventional template or derived starter state.
- RHT-67 Present template frontmatter MUST be a valid YAML mapping.
- RHT-68 An explicit template MUST be checked against the referencing type's effective field contracts.
- RHT-69 Omitted template fields MUST retain the derived starter values.
- RHT-70 An invalid existing template makes its referencing type non-conforming.
- RHT-71 Templates MUST NOT invent metadata fields merely to mirror relationship declarations.
- RHT-72 Derived starter bodies MUST include required H2 sections in declared order.
- RHT-73 An explicitly named template file MUST exist.
- RHT-74 A validator MUST NOT infer template drift from unmarked template or note content.
- RHT-75 A conventional template path MUST use the same path resolution as an explicit reference.
- RHT-76 Template frontmatter MUST NOT introduce undeclared fields except those permitted by Core or an applicable extension.
- RHT-77 A template MAY use null as an unresolved placeholder even for a non-nullable declared field.
- RHT-78 A template MAY use an empty string as an unresolved text or link placeholder.
- RHT-79 Template placeholders MUST be distinguished from explicit values supplied by a note author or scaffold caller.
- RHT-80 Non-placeholder template values MUST satisfy the effective field constraints.
- RHT-81 Instantiation MUST apply supplied values, deterministic defaults, and applicable generation before claiming the created note conforms.
- RHT-82 Unresolved placeholders that violate note constraints MUST prevent an instantiated-note conformance claim.
- RHT-83 Note storage, relationship cardinality, and heading conformance are evaluated on the instantiated note, not on unresolved starter state.
- RHT-89 Derived mandatory tags MUST be present as concrete starter values rather than null placeholders.
- RHT-92 Instantiated tags MUST satisfy the effective policy in Managed Notes and Properties.
Explicit stored nulls in existing notes are not template placeholders. Normalization preserves those nulls unless their replacement is explicitly requested. Template derivation neither writes a file nor manufactures missing domain values needed by the resulting note.
Template Drift Tracking#
See Template Drift Tracking for the authoritative contract.
Ownership and Marker Grammar#
See Ownership and Marker Grammar for the authoritative contract.
Receipts and Region Digests#
See Receipts and Region Digests for the authoritative contract.
Drift Classification#
See Drift Classification for the authoritative contract.
Reconciliation and Detachment#
See Reconciliation and Detachment for the authoritative contract.
Content Expansion#
See Content Expansion for the authoritative contract.
Marker Grammar#
See Marker Grammar for the authoritative contract.
Sources and Rendering#
See Sources and Rendering for the authoritative contract.
Materialization, Synchronization, and Drift#
See Materialization, Synchronization, and Drift for the authoritative contract.
Moved rule references
- RHT-100
- RHT-101
- RHT-102
- RHT-103
- RHT-104
- RHT-105
- RHT-106
- RHT-107
- RHT-108
- RHT-109
- RHT-110
- RHT-111
- RHT-112
- RHT-113
- RHT-114
- RHT-115
- RHT-116
- RHT-117
- RHT-118
- RHT-119
- RHT-120
- RHT-121
- RHT-122
- RHT-123
- RHT-124
- RHT-125
- RHT-126
- RHT-127
- RHT-128
- RHT-129
- RHT-130
- RHT-131
- RHT-132
- RHT-133
- RHT-134
- RHT-135
- RHT-136
- RHT-137
- RHT-138
- RHT-139
- RHT-140
- RHT-141
- RHT-142
- RHT-143
- RHT-144
- RHT-145
- RHT-146
- RHT-147
- RHT-148
- RHT-149
- RHT-150
- RHT-151
- RHT-152
- RHT-153
- RHT-154
- RHT-155
- RHT-156
- RHT-157
- RHT-158
- RHT-159
- RHT-16
- RHT-160
- RHT-161
- RHT-162
- RHT-163
- RHT-164
- RHT-165
- RHT-166
- RHT-167
- RHT-168
- RHT-169
- RHT-17
- RHT-170
- RHT-171
- RHT-172
- RHT-173
- RHT-174
- RHT-175
- RHT-176
- RHT-177
- RHT-178
- RHT-179
- RHT-18
- RHT-180
- RHT-181
- RHT-182
- RHT-183
- RHT-184
- RHT-185
- RHT-186
- RHT-187
- RHT-188
- RHT-189
- RHT-19
- RHT-190
- RHT-191
- RHT-192
- RHT-193
- RHT-194
- RHT-195
- RHT-196
- RHT-197
- RHT-198
- RHT-199
- RHT-200
- RHT-201
- RHT-202
- RHT-203
- RHT-204
- RHT-205
- RHT-206
- RHT-207
- RHT-208
- RHT-209
- RHT-210
- RHT-211
- RHT-212
- RHT-213
- RHT-214
- RHT-215
- RHT-216
- RHT-217
- RHT-218
- RHT-219
- RHT-220
- RHT-221
- RHT-222
- RHT-223
- RHT-224
- RHT-225
- RHT-226
- RHT-227
- RHT-228
- RHT-229
- RHT-230
- RHT-231
- RHT-232
- RHT-233
- RHT-234
- RHT-235
- RHT-236
- RHT-237
- RHT-238
- RHT-239
- RHT-240
- RHT-241
- RHT-242
- RHT-243
- RHT-244
- RHT-245
- RHT-246
- RHT-247
- RHT-248
- RHT-249
- RHT-250
- RHT-251
- RHT-252
- RHT-253
- RHT-254
- RHT-255
- RHT-256
- RHT-257
- RHT-258
- RHT-259
- RHT-260
- RHT-261
- RHT-262
- RHT-263
- RHT-264
- RHT-265
- RHT-266
- RHT-267
- RHT-268
- RHT-269
- RHT-270
- RHT-271
- RHT-272
- RHT-273
- RHT-274
- RHT-275
- RHT-276
- RHT-277
- RHT-278
- RHT-279
- RHT-280
- RHT-281
- RHT-282
- RHT-283
- RHT-284
- RHT-287
- RHT-288
- RHT-289
- RHT-290
- RHT-291
- RHT-93
- RHT-94
- RHT-95
- RHT-96
- RHT-97
- RHT-98
- RHT-99