MarkSpec — Markdown Flavor Specification
Introduction
MarkSpec is a Markdown flavor for traceable industrial documentation. It targets safety-critical and high-availability systems where requirements, traceability, and compliance documentation must live alongside code in version control.
MarkSpec is a three-layer stack:
- CommonMark — the parsing baseline.
- GFM / GLFM shared subset — platform extensions portable across GitHub and GitLab.
- MarkSpec extensions — entry authoring, captions, inline references, directives, and book structure.
Source files are pure, readable Markdown. They render correctly on GitHub and GitLab without any build step. PDF generation, traceability matrices, and reference resolution are build concerns — not format concerns.
Core vs. profile
MarkSpec splits responsibility between a core — this specification — and a profile — an external vocabulary pack that names concrete entry types and declares their attributes, relation names, and rules.
- The core defines two entry shapes (Authored and Reference), the syntax for
authoring entries, a single identity attribute (
Id:), a small universal attribute set, and the rules for discriminating shape fromId:value format. It contains no type vocabulary. - A profile declares concrete types (
requirement,test,unit,standard,dependency, …) within the two shapes, per-type attributes, traceability relations, and validation rules.
A bundled default profile ships with MarkSpec and loads by default (it can
be opted out of in .markspec.yaml). Compliance profiles (ASPICE, ISO 26262,
DO-178C, IEC 62304, MISRA-C) stack on top via an extends: chain.
This specification is the normative reference for the MarkSpec core. Profile
schemas are specified by each profile’s markspec.yaml manifest; the default
profile’s manifest is the reference for the out-of-box type vocabulary.
Part 1 — Markdown Flavor
1.1 CommonMark
MarkSpec accepts all CommonMark syntax. The following features are supported without modification:
Headings:
# Document Title
## Section
### Subsection
Paragraphs and inline formatting:
The braking system shall achieve full braking force within 150ms of driver
input. The _debounce window_ is configurable. Use **bold** for emphasis and
`debounce_input()` for code.
Block quotes:
> The system shall meet all requirements specified in ISO 26262-6 §9.4 for
> software unit testing.
Lists:
- Pressure sensor
- Speed sensor
- Temperature sensor
1. Capture raw input
2. Apply debounce filter
3. Validate plausible range
Fenced code blocks (language required):
```rust
fn debounce_input(raw: u16) -> u16 {
// implementation
}
```
Inline links:
See [ISO 26262-6](https://www.iso.org/standard/68388.html) for software-level
requirements.
Reference links:
See [ISO 26262-6] for software-level requirements.
[ISO 26262-6]: https://www.iso.org/standard/68388.html
Images (alt text required):

Hard line breaks (trailing \):
First line ends here,\
and the next line continues.
Horizontal rules:
---
HTML comments (used for directives):
<!-- markspec:ignore -->
MarkSpec restricts the following CommonMark features:
| Feature | CommonMark | MarkSpec restriction |
|---|---|---|
| Headings | ATX and setext | ATX only. |
| Code blocks | Fenced (backtick and tilde) and indented | Backtick-fenced only. |
| Emphasis | *text* and _text_ | _text_ only. |
| Strong | **text** and __text__ | **text** only. |
| List markers | -, *, + | - only. |
| Horizontal rules | ---, ***, ___ | --- only. |
| Hard line breaks | Trailing \ and trailing double-space | Trailing \ only. |
| Inline HTML | Any HTML element | Comments only (<!-- -->). No HTML elements. |
| Front matter | YAML --- blocks (not CommonMark) | YAML (---) and TOML (+++) allowed at the top of the file; schema defined in §1.3 §6 and Part 6. |
MarkSpec requires beyond CommonMark minimums:
| Requirement | Rule |
|---|---|
| First line | Must be an H1 heading. |
| H1 count | Exactly one H1 per file. Summary documents are exempt — additional H1s are part headings. |
| Heading levels | Must not skip (H2 → H4 is invalid). |
| Code fence language | Required. Use text for plain output. |
| Image alt text | Required on every image. |
1.2 GFM / GLFM shared subset
Only features supported by both GFM and GLFM are used. Platform-specific extensions are not part of the flavor.
Tables
Pipe syntax. Rows are exempt from line width limits.
| Sensor | Min | Max | Unit |
| -------- | --- | ---- | ---- |
| Pressure | 0 | 1023 | kPa |
| Speed | 0 | 255 | km/h |
Strikethrough
~~deprecated requirement~~
Task lists
- [x] Define sensor thresholds
- [ ] Validate against hardware spec
- [ ] Update traceability matrix
Footnotes
Supplementary context only — not for traceability.
The debounce window[^1] shall be configurable per sensor type.
[^1]: Debouncing eliminates transient electrical noise from raw sensor readings.
Syntax highlighting
Language identifier is required on all fenced code blocks.
```rust
fn debounce_input(raw: u16, window_ms: u32) -> u16 {
// implementation
}
```
Opaque DSL content. A fenced block whose language identifier is unknown to
the toolchain is passed through verbatim — never parsed, reformatted, or
prose-analyzed. markspec fmt also leaves inline code spans byte-for-byte
unchanged, and an unknown reference DSL embedded in a span — for example the
interaction-reference form ux:media.home/play — draws no markspec check
diagnostic. External profiles rely on this to host their own embedded
vocabularies before those vocabularies land in core.
Math
Inline and block math expressions:
The response time is $t = 150\text{ms}$ under nominal conditions.
$$
d = v \cdot t
$$
Alerts
> [!NOTE]
> This requirement derives from ISO 26262-6 §9.4.
> [!WARNING]
> Failure to debounce may lead to spurious brake activation.
> [!CAUTION]
> **ASIL-B constraint** — changes require impact analysis.
Supported types: NOTE, TIP, IMPORTANT, WARNING, CAUTION. Custom title
via bold text on the first line.
1.3 MarkSpec extensions
All extensions use valid CommonMark syntax — they render on GitHub and GitLab without tooling.
§1 Entry blocks
A list item starting with - [DISPLAY_ID] followed by a title on the same line,
and indented body content on subsequent lines. The display ID is the entry’s
human-readable identifier. The title is the rest of the paragraph that starts
after the closing ]. A title that soft-wraps onto more physical lines is one
logical title; markspec fmt wraps a title that is longer than the line width
onto continuation lines indented at the list item’s content column, as
prim fmt does, and joins a wrapped title that fits on one line. When the
wrapped form is not equivalent to the title, the title stays on one line
(MSL-F012).
- [DISPLAY_ID] Title
Body paragraphs.
Key: Value
Key: Value
A - [DISPLAY_ID] with no indented body is a normal list item — not an entry
block.
Example 1 — entry block:
- [SRS_BRK_0107] Sensor input debouncing
The sensor driver shall debounce raw inputs to eliminate electrical noise
before processing.
The debounce window shall be configurable per sensor type:
| Sensor type | Window (ms) | Sample rate (Hz) |
| ----------- | ----------- | ---------------- |
| Pressure | 10 | 100 |
| Speed | 5 | 200 |
| Temperature | 50 | 20 |
Id: 01HGW2Q8MNP3RSTVWXYZABCDE
type: software-requirement
Satisfies: SYS_BRK_0042
Labels: ASIL-B
Example 2 — not an entry block:
- [See documentation] for details on configuration.
No indented body. Normal list item.
Emphasis (_text_) must not appear inside entry blocks. Strong (**text**) and
inline code are allowed.
Part 2 defines the two entry shapes (Authored, Reference), the rule that discriminates them, the universal attributes that apply to both, and the profile-declared extensions layered on top.
Rendering of entry blocks (admonition-style left border, type coloring, label pills, cross-reference links) is specified in the Typography chapter, §“Entry rendering”.
§2 Attribute blocks
The canonical attribute block is the trailing indented code block of an
entry. The parser also accepts the unindented shapes described below. Each
content line is a single Key: Value pair. No trailing line-continuation
characters. The value of a free-text attribute (an attribute of type text, or
a key that neither the core nor the profile declares) keeps a U+FEFF or a
non-breaking space (U+00A0) at either end; any other whitespace around it is
removed. The value of every other core attribute, such as Id:, a trace link or
Labels:, loses all whitespace around it, so an invisible character copied with
an identifier does not break it. A profile attribute that the active profile
declares with a type other than text (as a universal attribute, a type-scoped
attribute or a traceability relation), and never with the type text, is a
typed attribute too: once the profile is loaded, its value loses all whitespace
around it in two ways. markspec fmt (of a Markdown file, so the file loses the
character), the fmt-drift gate of markspec check (so check agrees with
fmt) and compile trim a key that some type declares with a type other than
text, when no type declares it text, whatever the type of the entry.
Attribute validation trims the value for an entry whose own type declares the
key with a type other than text. markspec fmt only stamps Id: in a
.feature file, which keeps the character. For the fmt, check and compile
trim the key is matched in canonical case (first letter upper case, all others
lower case, as markspec fmt writes keys), so HAZARD: is trimmed like a
declared Hazard; attribute validation still matches the declared name exactly.
A key declared text by any type is never trimmed by markspec fmt or
compile, although attribute validation still trims it for an entry whose type
declares it with another type. Two limits apply: a line whose value is made only
of such characters is not a valid attribute line (MSL-P021), and markspec fmt
removes it; and the line needs an ASCII space after the colon.
The block is indented 4 spaces relative to the entry body indent (CommonMark
indented-code-block rule). Inside a Markdown list item, that means 6 spaces of
indentation before the Key; inside a source-file doc comment (no enclosing
list), 4 spaces of indentation relative to the comment content column.
Example 3 — attribute block:
- [SRS_BRK_0001] Sensor debouncing
Sensor driver shall debounce raw inputs.
Id: 01HGW2Q8MNP3RSTVWXYZABCDE
Satisfies: SYS_BRK_0042
Labels: ASIL-B
The set of valid attributes is the universal set (Part 2 §2.1) plus whatever the active profile declares for the entry’s shape and inferred type.
Generated attributes (build-time inverses of authored relations such as
Verified-by from Verifies, Cited-by from References) are computed by
tooling and never appear in source. The exact set is profile-declared.
Disambiguation from body code blocks. The trailing indented code block
qualifies as an attribute block only when every one of its content lines matches
the pattern ^[A-Z][A-Za-z-]*: (followed by a space). Otherwise it remains a
regular code block and the entry is treated as having no attribute block. Fenced
code blocks (triple-backtick fences) anywhere in the entry are body content and
never confused with the attribute block — different syntactic shape.
Trailing position is required. If body prose appears after an indented
Key: Value block, that block is not trailing — it is treated as a regular code
block with no attribute meaning. Authors must place attributes at the very end
of the entry.
Unindented trailers. The parser also accepts a trailer that is not indented,
in two shapes. In a Markdown file, markspec fmt rewrites both to the canonical
indented block after a blank line, and keeps the Id: value. markspec fmt
does not rewrite source files, so a source doc comment keeps its git-style
trailer.
- Git-style trailer. The final paragraph of the entry, after a blank line,
when every line is
Key: Valueand the paragraph holds anId:line (the keyIDcounts asId;fmtcanonicalises it) or uses only core trailer keys (Part 2 §2.1 universal attributes and the core trace relations). This is the shape thatgit interpret-trailersreads. The parser has no profile, so a key that only a profile declares qualifies only through theId:line. In Markdown,checkreportsMSL-P023(warning) at the first line of the block when any trailer line is indented less than 4 columns past the list-item content.MSL-P023is not reported when a trailer line ends with the legacy trailing\(that shape has its own diagnostic). In a source doc comment the git-style trailer is a valid alternative to the indented block; the parser reports no parse diagnostic (MSL-P0xx) for source files. - Run under prose. A run of
Key: Valuelines directly under body prose, with no blank line, when any line of the run is anId:line (orID:), indented or not. TheId:line shows that the run is a trailer, so the entry keeps its identity.checkreports it asMSL-P020(warning), and not asMSL-P023. When other content follows the run in the same list item, the run is not the trailer, and a run with anId:line getsMSL-P025instead (see “Content after the trailer”).
A git-style trailer in Markdown. This is not the canonical layout: check
reports MSL-P023, and markspec fmt indents the two trailer lines.
- [SRS_BRK_0001] Sensor debouncing
Sensor driver shall debounce raw inputs.
Id: 01HGW2Q8MNP3RSTVWXYZABCDE
Satisfies: SYS_BRK_0042
Nested entry. In a Markdown file, a list item inside an entry that is itself entry-shaped, at any depth, is not an entry: nested entries are not supported. A list item, bullet or ordered, is entry-shaped when its title is a display ID as in the entry header and it has body content or a trailer. A title-only item is not, except in a references document, where a title-only item with a slug display ID is a Reference-shape entry and so entry-shaped. Only the outermost entry-shaped item of a branch counts: an entry-shaped item inside it is part of it.
The parser removes the lines of each such item from the entry’s content before
it reads the body and the trailer, so the item’s text, including its Id:, is
not part of the entry, and the entry keeps its own trailer and Id: when that
trailer is the last content of the entry, ignoring the removed lines. A plain
list item that holds the nested item keeps its other content as body of the
entry. A list that holds a nested entry is transparent to the trailer search:
the entry’s trailer above it stays the entry’s own, although that list text
follows it. (For a list without a nested entry the usual rule applies: an Id:
block followed by it is MSL-P025, other content after the trailer is
MSL-P020.) The marker line of a wrapping item is removed with its nested items
only when the item holds nothing else: a bare marker line and lists whose items
are all nested entries. Plain items next to a nested entry stay in the body. A
Key: Value paragraph at the end of the nested item, at the entry’s trailer
indent (content indent plus 4), is the entry’s trailer, but only when the entry
has no trailer above its first nested item and the nested item’s own content
indent differs from that indent. When they are equal, which is the case for a
nested entry inside a plain list item, the placement is ambiguous and the
paragraph belongs to the nested item.
check reports MSL-P024 (warning) once for each outermost nested item, at the
item, in Markdown files only: a source doc comment gets no parse diagnostic (see
above). markspec fmt leaves an entry that holds a nested item unchanged and
stamps no Id: on it. Two things still apply to such an entry: tab-marker
normalization of the entry’s own list marker, when it does not change the list
structure, and the trace-value canonicalization of ADR-026 that fmt does for
the whole file. Move each item to the top level, as a separate entry.
Content after the trailer. The trailer is the last block of the entry. When
a trailer-shaped block that holds an Id: line is followed by any other block
in the same list item (a plain list item, a paragraph, a fenced code block, a
block quote), the block is not the trailer: its lines are body text, and its
Id: is not the entry’s. A trailer-shaped block is a non-fenced indented block
whose lines are all Key: Value lines, or a paragraph that ends with a run of
Key: Value lines (the git-style trailer and the run under prose, see
“Unindented trailers”); for a paragraph, the Id: line must be in that final
run. A Key: Value line that starts a paragraph and that a tab indents less
than 4 columns past the list-item content is such a paragraph: for example, in a
list item with a 2-column content indent, a tab at column 0 expands to column 4,
which is 2 columns past the content. The entry has an Id: only when a later
trailer that holds one is read; when no trailer is read, or the later trailer
has no Id:, the entry has none. In Markdown files, when the entry has no Id:
attribute and holds no nested entry (MSL-P024), check reports MSL-P025
(warning) at the first line after the last such block, instead of the MSL-P020
error, and the MSL-I003 message names MSL-P025. A block without an Id:
line (for example Satisfies: only) keeps the MSL-P020 rule. markspec fmt
leaves such an entry unchanged and stamps no Id: on it. Two things still
apply, as for MSL-P024: tab-marker normalization of the entry’s own list
marker, when it does not change the list structure, and the trace-value
canonicalization of ADR-026 that fmt does for the whole file. Move the content
above the trailer.
Legacy trailing \. A trailer line that ends with \ (the legacy
paragraph-with-trailing-\ shape) is accepted in the indented block and in both
unindented shapes, and emits a deprecation diagnostic
(MSL-DEPRECATED-ATTR-001).
Continuation lines. A whitespace-led line directly below a trailer line that
ends with \ or , stays in the trailer, but each attribute takes exactly one
line, so the line is not read as part of a value. check reports it as
MSL-P021 (error), and markspec fmt leaves the whole trailer unchanged: it
drops no line and stamps no replacement Id:. This is intended: a trailer with
a continuation line is still the trailer, so its Id: is never lost. Multi-line
attribute values are not part of the trailer rule. The MSL-P023 quick fix also
leaves such a trailer unchanged, so the author fixes MSL-P021 by hand; the
MSL-P023 message then says so instead of suggesting markspec fmt.
Id-like line. In the run of Key: value lines at the end of an entry, a
line whose key is id in any case, with any spacing before the colon, and that
the parser does not read as an Id: attribute is an Id-like line. In Markdown
and source entries these are id: and Id :: a key starts with an uppercase
letter and has no space before the colon, so ID: is an attribute line. In a
Markdown file, markspec fmt canonicalises the ID: key to Id:, in the
indented block and in a git-style block (the latter also gets MSL-P023), and
check never reports MSL-I009 for it. In a source doc comment fmt rewrites
nothing, so ID: stays as written: it is an attribute with an unknown key, and
check reports the missing Id: (MSL-R003, MSL-I003) and the unknown key
(MSL-R010, MSL-A005), not MSL-I009. In a .feature header, # ID: is an
Id-like line too: findIdLikeIndex flags every non-Id: spelling of the key,
and the line also parses as the attribute ID (MSL-R010, MSL-A005). fmt
does not canonicalise it. An Id-like line is not an identity: check reports it
as MSL-I009 (error) at the line, and markspec fmt leaves the whole entry
unchanged until the key is fixed, so no Id: is stamped and the line is not
hidden behind a second identity. The author corrects the key to Id: by hand.
An ID: text line in earlier body prose is not in the final run and is not
reported.
Any other trailing Key: value line is body prose: for example Status: draft
directly under a prose line, or a final paragraph of Rationale: and Note:
lines. Only Id: and core trace relation keys (Satisfies:, Verifies:, …)
in body prose raise MSL-P020, because such a line does not create a trace
link:
- error, when other body content or the trailer block follows the line (in a
Markdown file, an
Id:block followed by content isMSL-P025instead when the entry has no readId:and no nested entry, see “Content after the trailer”); - warning, when the line is in the trailing
Key: Valuerun of an entry that has no trailer.
A trailing line that looks like a trailer line but is not a valid attribute
line, for example below: (no value), architecture : (a space before the
colon), or some_signal_name: the speed. (a key with characters outside
[A-Za-z][A-Za-z0-9-]*), is not read as an attribute and stays in the body. The
80-column wrap of markspec fmt can produce such a line.
check reads the trailing lines of the body from the bottom up. It skips blank
lines, <!-- markspec:* --> directive comments, valid Key: value lines and
lines that are body text (see below), so it can reach a line in an earlier
paragraph. It stops at the first line it reports, at a prose line, or at a line
with a value whose key has only valid characters but that is not a valid
attribute line (note: x, Key2: x, Id : X), which it does not report.
MSL-I009 reports the Id : X line when it is in the final run of Key: value
lines at the end of the body (see “Id-like line”). A directive comment ends that
run, so an Id : X line with a <!-- markspec:* --> comment below it gets no
diagnostic. A line with a value whose key is a core trace relation key after
normalization (Satisfies : X, Satisfies:X) is the exception: check reports
it as MSL-P021, because it creates no trace link. So it reports at most one
line; the author sees the next one after fixing it. Because the scan stops at a
prose line and, without a report, at a line such as note: x, Key2: x or
Id : X, a malformed trace relation line above one of these lines is never
reached and gets no diagnostic: for example Satisfies : X, then
and more text., or Satisfies : X, then note: x.
For each line it reads, except a line where it stops without a report, check
decides from the run of that line: the line together with the trailer-like lines
(valid or not) and directive comments directly above and below it, with no blank
line between. MSL-P021 and MSL-P022 report the line in these cases:
- a line of the run is indented by 4 or more columns (the indented block);
- the run holds an
Id:line or an Id-like line (id:,Id :), which shows that the author meant a trailer; - the run reaches the end of the body and the trailer starts on the next line,
with no blank line between (
Some prose here., thensatisfies:, then an indentedId:line); - the run is a final unindented paragraph (it starts the body or follows a blank
line, and nothing follows it) that holds no valid key other than recognized
trailer keys. A paragraph of only malformed lines, such as a lone
satisfies:orbelow:, is reported too, although the parser reads no trailer from it: it can be a broken trailer written by hand; - the line has an empty value or an invalid key, and its key is
Idor a core trace relation key after normalization, compared case-sensitively (Verified by: TST_1,Satisfies:), even directly under prose. The normalization replaces each run of whitespace and.,/,,,',"characters with one hyphen, and removes hyphens at both ends of the key; - the line has a value and a key of valid characters, and its key is a core
trace relation key after the same normalization (
Satisfies : STK_1,Verifies : TST_1), even directly under prose.
In any other case the line is body text, and check reports no diagnostic for
it. This holds when the run is directly under a non-blank line that is not in
the run (prose, a heading, a list item or a closing fence), or when the run
starts the body or follows a blank line and other content or a trailer follows
it, or it holds a valid key that is not a recognized trailer key (for example a
Note: lead-in). So a lowercase satisfies: directly under prose is body text,
unless its run touches the trailer, is indented or holds an Id: line.
An indented block directly under body prose, with no blank line, continues the
paragraph in CommonMark. The parser still reads it as the trailer, as it did
before, and markspec fmt inserts the blank line.
§3 Table captions
Emphasized paragraph starting with Table: immediately above a pipe table.
Example 4 — table with caption:
_Table: Sensor thresholds_
| Sensor | Min | Max |
| -------- | --- | ---- |
| Pressure | 0 | 1023 |
Slug: tbl.sensor-thresholds. Derived by stripping the Table: prefix, then
applying the GFM anchor algorithm (lowercase, spaces to hyphens, punctuation
stripped).
Example 5 — not a caption:
_This is just italic text._
| Column A | Column B |
| -------- | -------- |
Does not start with Table:.
§4 Figure captions and diagrams
Diagrams are embedded using standard Markdown image syntax with relative paths only:

Absolute URLs (https://…), repo-root links (/docs/…), and paths that escape
the document folder via repeated ../../ are not permitted. Relative paths keep
the document self-contained — when a folder is moved or reorganized, the diagram
travels with the document. Non-relative image references are flagged by
MSL-D008.
Diagrams are always stored as SVG files — never embedded as inline fenced
code blocks (e.g., ```mermaid). SVG renders consistently across GitHub,
GitLab, PDF, and presentation output.
Authoring recommendations by use case:
- PlantUML — simple structured diagrams: sequences, state machines, class diagrams with ~13 classes or fewer.
- draw.io (or Inkscape, Excalidraw) — advanced authoring with free-form shapes, swimlanes, complex layouts.
- Raw SVG — AI-assisted authoring, scripts, or hand-authored.
Storage conventions:
- Source embedded in the SVG →
<name>.<source>.svg(e.g.architecture.drawio.svg,unlock-sequence.plantuml.svg). - Source not embedded → source and SVG side by side (e.g.
architecture.dot+architecture.svg).
PNG is acceptable when SVG does not make sense — photographs, screenshots,
heatmaps, dense bitmap data. Use a descriptive filename with no source-format
suffix (dashboard-screenshot.png).
For sizing, visual style, and tooling details (PlantUML viewport, draw.io embedding, color palettes, stroke weights), see the Typography chapter.
Captions: an emphasized paragraph starting with Figure: immediately below
an image. Alternatively, the image alt text is the caption.
Example 6 — explicit caption:

_Figure: High-level architecture of the braking system_
Slug: fig.high-level-architecture-of-the-braking-system. Derived by stripping
the Figure: prefix, then applying the GFM anchor algorithm.
Example 7 — alt text as caption:

Slug: fig.system-overview. Explicit caption takes precedence.
§5 In-code entries
Entries can be authored in doc comments in source files. A doc comment beginning
with [DISPLAY_ID] is recognized as a MarkSpec entry. The leading - bullet is
optional in doc comments — the bracket pattern alone is sufficient.
Example 8 — Rust doc comment test entry:
#![allow(unused)]
fn main() {
/// [SWT_BRK_0107] Debounce unit test
///
/// Given a debounce window of 10ms, a transient spike shorter
/// than the window must not alter the stable output.
///
/// Id: 01HGW3R9QLP4ABCDEFGHJKMNPQ
/// Verifies: SRS_BRK_0107
/// Tests: braking_core::controller::debounce_input
/// Labels: ASIL-B
#[test]
fn swt_brk_0107_debounce_filters_noise() {
// test implementation
}
}
The doc comment declares the entry; the function body is the executable
artifact. The SWT_ prefix triggers the active profile’s type inference (e.g.,
type: unit-test under an ASPICE profile). Authors do not write type: in
source. The file path is observable as the file.path property (see Part 6).
A production unit declares what it realizes via its own doc comment. Because the
display ID is a symbolic namespace path with no declared prefix pattern, the
author writes type: explicitly:
#![allow(unused)]
fn main() {
/// [braking_core::controller::debounce_input] Debounce function
///
/// Rejects transient noise on raw sensor readings.
///
/// Id: 01HGW3D6QRST7IJKLMNOPQRSTUV
/// type: unit
/// Realizes: 01HGW2Q8MNP3RSTVWXYZABCDEF
fn debounce_input(raw: u16) -> u16 { ... }
}
Tooling extracts these doc comments to produce the same traceability output as Markdown-authored entries.
§6 Front matter
Document-level metadata is authored in YAML front matter — a ----delimited
block at the very top of the file, before the H1.
Example 8b — document with front matter:
---
document-id: 01HGW2D0DOCPQ4FGHIJKLMNOPQR
document-type: requirements
labels: [requirements, ASIL-B]
external-id: doors:VHC:SRS-BRK
---
# Braking Software Requirements
## Introduction
...
Front matter carries:
- Document identity (
document-id,document-type). - Universal attributes (
labels,external-id,supersedes,deprecated,references) — same set and semantics as entry-level universal attributes. Draft state viaDRAFTlabel; retirement viasupersedes:ordeprecated:. - A reserved
metadata:map for org-specific free-form fields. - Optional profile-declared keys (e.g., automotive
asil:). - Optional allowlisted ecosystem keys declared in
.markspec.yaml(for Hugo / Jekyll / Docusaurus interop).
Forbidden keys (Markdown-native concepts; duplication creates drift):
title, description, toc, sections, authors, author, date,
created, modified, cover, images. These live in H1, body paragraphs, or
git history — never in front matter.
Casing convention: front matter keys use kebab-case (document-id),
matching YAML ecosystem convention. Entry trailers keep Title-Case (Id:,
Satisfies:, Labels:), matching git-trailers convention.
TOML tolerance: +++-delimited TOML front matter is accepted as input (for
GitLab-flavored Markdown parity); the formatter normalizes to YAML.
Full document-structure specification: see Part 6 — Document Model.
§7 Entries in .feature files
A Gherkin .feature file can declare entries. An entry is a Feature, Rule
or Scenario node with a header: a run of comment lines whose first line is
# [ID] Title. See the guide for a full
example.
Header syntax. The header text is the comment lines with the # and the
spaces after it removed. The first line is [DISPLAY_ID] Title. The following
lines are the body prose and the trailer, parsed as for a source doc comment
(§5), except that git-style trailers (no indent) are canonical and give no
MSL-P023. A header that has only a title is an entry with an empty body.
Header ID. The DISPLAY_ID of a header must match
[A-Z][A-Z0-9]*[_-][A-Za-z0-9_.-]*[A-Za-z0-9]: an uppercase letter, then
uppercase letters or digits, at least one _ or - separator, and a letter or
digit at the end. This is a subset of the display-ID grammar without /. A
bracketed comment whose text is not such an ID (# [TODO] fix later,
# [x] done, # [WIP]) is a plain comment: it gives no entry and no
diagnostic, and fmt does not change it. In the rules below, [ID] means a
bracketed ID of this shape.
Header detection.
- A header is the run of consecutive comment lines that ends directly above a
node keyword. Tag lines and plain comment lines (a line that does not start
with
[ID]) may stand between the run and the keyword. - A blank line, or any other line, between the run and the node breaks the link.
- A comment line whose text starts with
[ID]starts a new run, so stacked headers are separate headers. Only the lowest header of a stack is directly above the node; each upper header has no node, is not an entry, and givesMSL-B069. - A
# language:line is never part of a header. - A header above a
Background, anExamplestable or a step, or one that is not directly above a node, is not an entry and givesMSL-B069.
A file with no # [ID] header line gives no entries and no diagnostic. A file
that has a header line and does not parse gives no entries and one MSL-B062.
Ownership. A scenario belongs to at most one entry. A headed Scenario is
its own entry. A scenario with no header belongs to the nearest enclosing headed
Rule, else to the headed Feature; a Rule with no header does not stop the
search. A scenario with no headed ancestor is in no entry. Nesting creates no
relation: no Part-of is generated, and tags are not labels.
Entry body. The body is the header prose, then the Gherkin description of
the node, joined by a blank line. The body AST is the header prose blocks, the
blocks of the description, and one Feature node (§1.3 of the data model). The
FeatureNode.source is the text of the owning node, from its first tag line or
keyword line to its last line. The text of a nested entry is blank in it. Its
feature holds the owned scenarios and the Background steps that apply to
them, with ranges relative to that text. The Feature node therefore gives
Entry.criteria and the block-role checks of Part 8 §8.12.
Entry source. Each entry has source of kind feature-file with node
feature, rule or scenario. Locations are line and column of the .feature
file. The type of an entry follows the resolution chain (data model §1.3.1),
where step 6a gives Feature and Rule the type Requirement and Scenario
the type Test. When no display-id-pattern matches a .feature entry,
profile classification resolves it through the same chain (steps 3, 4 and 6
still win over 6a), so the entry is never un-classified (no MSL-T003), and it
has a type even without a profile.
Discovery. check, lint, fmt and lock find .feature files like
other project files. compile does no discovery and reads the .feature files
named in its paths. A .feature file with no header changes no output of these
commands, except that the scope line of a bare check or fmt counts it.
Formatting. markspec fmt inserts a missing # Id: <ULID> line into a
header, in front of its first trailer line, and changes nothing else. A file
that does not parse is left unchanged. MSL-F010 reports a header without
Id:.
The language server indexes .feature files and gives diagnostics, navigation,
rename and Id stamping for headers; see
Editor support.
§8 Gherkin blocks in entries
A fenced code block in an entry body is a feature block when its info string
is gherkin or feature. A feature block is parsed as Gherkin; the result is
the Feature node of the body AST (see the AST). The rules below
describe a feature block in an entry of a Markdown file or a source doc comment.
For entries declared in a .feature file, see §7. The design record is
ADR-038.
Which blocks count. The diagnostics of this section (MSL-B062 to
MSL-B068) check a feature block at the top level of the body and a feature
block nested in a list item at any depth. The scenario index (below) reads
top-level blocks only: a feature block nested in a list item or another
container gives no scenario to a locator.
Block role. The role of a feature block follows the resolved type of its entry. The role is derived when needed and is not stored on the entry.
| Entry type | Role |
|---|---|
is, or extends, Requirement or Contract | criteria |
is, or extends, Test | procedure |
| any other type | illustration |
| no resolved type | no role |
The type is resolved through the profile’s extends chain when a profile is
loaded, else through the core type hierarchy. The roles do not overlap: a type
has one parent, and Requirement, Contract and Test are siblings in the
core hierarchy. An entry with no resolved type has no role: a validator check
classifies the entry with the profile first, so an entry that the profile does
not type gets no role-based diagnostic. A feature block that does not parse
(below) is skipped by every role check.
- A
criteriablock: each scenario is an acceptance criterion. A scenario with no outcome step givesMSL-B064. - A
procedureblock: each scenario is a test procedure, read with the step rule below. A procedure step with actions and no expected result givesMSL-B063; one with an expected result and no action givesMSL-B065; a# Steplabel that labels no step givesMSL-B067. - An
illustrationblock: the block is an example and has no further meaning. It givesMSL-B068once, at its first line, and no other role check. - A scenario that starts with
AndorButgivesMSL-B066in acriteriaorprocedureblock; the step is read as an action.
Procedure steps. The role of a step follows its keyword: Given is a
precondition, When is an action, Then is an outcome, and * is always an
action. And and But take the role of the step before them; a first And or
But is an action. The steps of the Background that apply to a scenario, then
the leading precondition steps of the scenario, are its preconditions. The
remaining steps form numbered procedure steps, counted from 1 in order. A new
procedure step opens at an action that follows an outcome, and at a precondition
that follows an action or an outcome. A precondition in a later procedure step
is part of that step’s setup. The examples of a Scenario Outline are not
expanded. Role is a function of the parsed AST and is not stored on it.
Step labels. A comment line #, optional spaces, the word Step, then
whitespace or the end of the line (# Step, # Step 2, #Step 2) is a step
label. # Step-by-step, # Step: 1 and # Steps 1 are not labels. A label
inside a scenario names the procedure step that opens at the next step line; its
text is the comment without the #, trimmed. A label never changes the number
of its step. A label is unplaced, and gives MSL-B067 in a procedure block,
when it is above a leading precondition or above a step that does not open a
procedure step, when a description line lies between it and the step, when no
step follows it (including a label before Examples: and a label outside every
scenario), or when a second label stands above the same step.
Scenario names as locator targets. A scenario of a feature block in a
criteria entry is a criterion. Its name is normalized (Unicode NFC, trim, each
whitespace run collapsed to one space) and a Satisfies: or Verifies: value
can address it with a bracketed locator (see Part 8 §8.4 and
Locators; design record
ADR-037). The feature blocks
of one entry form one scope. A name that occurs more than once in the entry, or
an empty name, is not addressable: MSL-B060 and MSL-B061 report it, and a
locator that names it gives MSL-L007. The name comes from the parsed Gherkin
AST, in any spoken language of the block.
Parse failure. A feature block that the Gherkin parser rejects gives
MSL-B062, for an entry of any type. The block keeps its source text and a
parse error, and has no feature. Its role checks are skipped. The scenario
names of a top-level block that did not parse are read by a line scanner that
knows English keywords only: Example, Scenario, Scenario Outline and
Scenario Template; Background and Rule are not scenarios, and lines inside
a doc string are skipped. A block in another spoken language that does not parse
therefore gives no scenario names for keywords that are not English. The scanner
is also used when the Gherkin parser could not be loaded. A block that begins
without a Feature line is wrapped in a synthetic line that holds the Feature
keyword of the block language (Feature: for English) for parsing; the
synthetic line does not shift the positions that the AST reports.
| Rule | Diagnostic |
|---|---|
| Duplicate or empty scenario name | MSL-B060, MSL-B061 |
| Block does not parse | MSL-B062 |
| Procedure step with no result | MSL-B063 |
| Criteria scenario with no outcome | MSL-B064 |
| Procedure step with no action | MSL-B065 |
Scenario starts with And/But | MSL-B066 |
| Step label that labels no step | MSL-B067 |
| Illustration block | MSL-B068 |
All rows are specified in Part 8 §8.12. Guide: Gherkin scenarios and Scenario locators.
Part 2 — Entry Shapes
Part 1 defines the format — how to write entry blocks and attribute blocks. This
part defines the core entry model: the two shapes the core recognizes, the
single Id: identity attribute, the value-format rule that discriminates shape,
the universal attributes shared between shapes, and the relationship between the
core and profile-declared type vocabulary.
MarkSpec recognizes two shapes:
| Shape | Intent | Id: value | Display ID role |
|---|---|---|---|
| Authored | Content the project authors and owns | ULID (26-char Crockford b32) | Human-readable alias |
| Reference | Citation pointing to an external work | URI (RFC 3986, scheme req.) | Slug (pandoc/BibTeX cite-key) |
Every entry carries exactly one Id: attribute. Its value format determines
the shape:
Id: 01HGW2P4KFR7ABCDEFGHJKMNPQ # ULID → Authored
Id: urn:iso:std:iso:26262:-6:ed-2 # URI → Reference
Id: pkg:cargo/serde@1.0.0 # URI (purl) → Reference
Id: doi:10.1109/IEEESTD.2008.4610935 # URI → Reference
The two value formats are visually disjoint — a ULID has no scheme; a URI must
carry a scheme followed by :. A bare slug (no scheme, not a ULID) is rejected
as an Id: value.
Concrete types (requirement, test, unit, standard, dependency,
hazard, …) are declared by the active profile, not by the core. The core has
no TYPE vocabulary and no family enum.
2.1 Universal attributes
The following attributes apply to every family:
| Attribute | Type | Required | Description |
|---|---|---|---|
Labels | tag-list | no | Classification tags (includes DRAFT marker) |
Discipline | text | no | ADR-017 Slice 3 — author-asserted discipline kind. Value matches /^[a-z][a-z0-9-]*$/. Takes precedence over the classifier’s type/allocation channels. Single-cardinality. |
Discipline-frozen | text | no | ADR-017 Slice 3 — cached snapshot of a past derivation: <kind> or <kind> @ <YYYY-MM-DD>. The formatter stamps today’s UTC date when written bare. Single-cardinality. |
References | citation | no | External reference citations with locator |
External-id | external-id | no | Cross-system identifier(s) |
Supersedes | id | no | Same-shape entry this one replaces |
Superseded-by | id | — | Generated inverse of Supersedes |
Deprecated | string | no | Retirement reason (non-replacement case) |
Draft state is carried by the DRAFT label — a plain universal tag with no
exclusive-group semantics. Authors set Labels: DRAFT on entries that are
merged but not yet authoritative.
Retirement is structural, expressed two ways:
- Replacement — successor entry authors
Supersedes: <predecessor-id>; the predecessor automatically gains the generatedSuperseded-by:inverse. - Non-replacement — entry authors
Deprecated: "<free-text reason>"(e.g., “Feature cut from scope in v3.0”).
An entry is retired when either signal is present. The two are complementary
(a replacement may still carry a Deprecated: reason for additional context).
Tooling emits severity-tiered diagnostics when a relation target is retired or
draft: DRAFT target → info, retired target → warning, unresolved target →
error. There is no DEPRECATED / WITHDRAWN label — retirement lives in
Supersedes and Deprecated. Supersedes operates within a shape: an Authored
entry supersedes an Authored entry; a Reference entry supersedes a Reference
entry.
See §2.5 for attribute value types (multi-line repeat vs CSV, canonical form).
2.2 Authored entries
An Authored entry is a content unit the project authors and owns: a requirement, a test, a rule, a component, a code unit, a hardware part, a glossary term, a hazard, a design decision. Its identity is project-local and machine-generated.
Display ID: any non-empty, project-unique string. The core does not
constrain format. Profiles tighten by declaring per-type display-id-pattern:
templates; the active profile determines what shape Authored-entry display IDs
take in a given project. Common conventions:
SRS_BRK_0107 ← typed prefix + scope + number
braking_core::controller::debounce_input ← symbolic namespace path
REQ-042, NOTE-007 ← simple typed prefix + number
Identity: Id: carries a bare 26-character ULID
(^[0-9A-HJKMNP-TV-Z]{26}$). Assigned by markspec fmt, never hand-authored,
immutable once assigned. The ULID is the stable identity; the display ID is a
renumberable alias that resolves through the ULID for cross-references.
Type: profile-declared. Normally inferred by the active profile from the
display-ID prefix (SRS_BRK_0107 → type: software-requirement under an ASPICE
profile that declares
software-requirement: display-id-pattern: "SRS_{scope}_{n:04d}"). An explicit
type: attribute in source overrides inference and is required when the display
ID matches no declared pattern. Types whose IDs are named, not numbered — e.g.
components SWC_LIGHT_CTRL, HWC_PIU — declare a counter-less pattern
(sw-component: display-id-pattern: "SWC_{name}") so they are classified by
prefix without an explicit type: (see annex §B.3.2).
Profile-declared attributes: every attribute beyond the universal set (§2.1) is declared by the active profile. Examples — declared by an automotive ASPICE profile, not by the core:
Derived-from,Satisfies,Allocated-toon requirementsVerifies,Tests,Test-levelon testsRealizes,Depends-on,Part-of,Element-kindon units / artifactsASIL,Safety-goal,Risk-classon hazards / safety-relevant entries
The core does not define any of these names. They live in the profile manifest
and are validated against the profile’s attributes: / traceability:
declarations.
Example 9 — inferred type (SRS prefix):
- [SRS_BRK_0107] Sensor input debouncing
The sensor driver shall debounce raw inputs to eliminate electrical noise
before processing.
Id: 01HGW2Q8MNP3RSTVWXYZABCDE
Derived-from: SYS_BRK_0042
Labels: ASIL-B
Example 10 — explicit type override (symbolic path):
- [braking_core::controller::debounce_input] Debounce function
Rejects transient noise on raw sensor readings using a configurable window.
Id: 01HGW3D6QRST7IJKLMNOPQRSTUV
type: unit
Realizes: 01HGW2Q8MNP3RSTVWXYZABCDE
The author writes type: unit because no display-id-pattern matches a
symbolic namespace path. Realizes: references the upstream entry by its ULID
identity (the stable handle), not by display ID.
2.3 Reference entries
A Reference entry is a bibliographic citation of an external artifact: a standard, a regulation, a paper, an RFC, a corporate specification, a package dependency, a hardware part from an external catalog.
Display ID (slug): matches ^[A-Za-z]([A-Za-z0-9._/-]*[A-Za-z0-9])?$
(pandoc/BibTeX-style cite-key, restricted to a portable character set). Common
conventions:
ISO-26262-6 ← ISO 26262-6:2018
ISO/IEC-15504 ← ISO/IEC 15504
DO-178C ← RTCA DO-178C
RFC-2119 ← IETF RFC
serde ← Rust crate (dependency)
smith2021 ← academic citation
Both [@ISO-26262-6] and [ISO-26262-6] are accepted in the entry header; the
leading @ is pandoc-citation sugar and is stripped during parsing. Inline
pandoc citations [@ISO-26262-6] in prose resolve to the matching Reference
entry.
Identity: Id: carries a URI per RFC 3986 — any scheme, but the scheme is
required (urn:, doi:, pkg:, https:, isbn:, …):
Id: urn:iso:std:iso:26262:-6:ed-2 ← URN (preferred for standards)
Id: doi:10.1109/IEEESTD.2008.4610935 ← DOI (preferred for papers)
Id: pkg:cargo/serde@1.0.0 ← purl (Package URL, for dependencies)
Id: isbn:9780132350884 ← ISBN
Id: https://www.rfc-editor.org/rfc/rfc2119
Author-provided, not tooling-generated. A bare slug (no scheme) is rejected as
an Id: value — the slug lives in the display ID, not in Id:.
Type: profile-declared. Normally inferred by the active profile from the URI
scheme or the display ID (Id: pkg:cargo/... → type: dependency;
Id: urn:iso:... → type: standard). An explicit type: overrides inference.
Body is optional for Reference entries — a minimal entry may consist of
display ID, title, and Id: only.
Universal attributes (§2.1) apply, except that References: is not
applicable to Reference entries (a Reference entry does not itself cite other
Reference entries via References:; the replacement relation is expressed via
the universal Supersedes).
Universal attributes on Reference entries (core):
In addition to the universal attributes in §2.1, Reference entries accept
Reference-url: as a core attribute — an HTTPS navigation link used by
tooling (notably markspec lock) to fetch and hash the cited bytes for
trace-audit reproducibility. The attribute is optional; absent Reference-url:,
the lockfile records identity only (no hash, no drift detection for that row).
Profile-declared attributes: profiles may declare convenience attributes for
Reference entries — Reference-document: (canonical citation string),
License: (SPDX license expression for dependencies), etc.
Example 11 — normative standard:
- [@ISO-26262-6] ISO 26262 Part 6
Road vehicles — Functional safety — Part 6: Software level.
Id: urn:iso:std:iso:26262:-6:ed-2
Reference-url: https://www.iso.org/standard/68383.html
Reference-document: ISO 26262-6:2018
Labels: functional-safety, automotive
Example 12 — dependency (purl):
- [serde] serde Rust serialization framework
Id: pkg:cargo/serde@1.0.0
License: Apache-2.0 OR MIT
2.4 Shape discrimination
The shape of an entry is determined by the value format of its Id:
attribute. An entry has exactly one Id:.
if Id matches ULID regex (^[0-9A-HJKMNP-TV-Z]{26}$) → Authored
if Id is a scheme-qualified URI (RFC 3986) → Reference
otherwise → validation error
Properties of this rule:
- Disjoint — ULIDs and URIs do not overlap. A ULID has no scheme; a URI
requires a scheme followed by
:. No value matches both. - Complete — every well-formed
Id:value is either a ULID or a URI; the two exhaust the accepted formats. - Independent of display ID — shape is decided by the
Id:value, not by the display-ID format. - Independent of document context — shape is intrinsic to the entry, not dependent on which document it appears in.
- Independent of profile — shape resolution completes without consulting any profile.
When a new entry is authored without an Id: attribute, markspec fmt
classifies it using a heuristic on the display ID and the document directive
(see Part 3), then either mints a fresh ULID (Authored) or prompts for a URI
(Reference). Once Id: is assigned, the shape is fixed by the value’s format.
2.5 Attribute value types
Every attribute declares a value type that determines which input forms the parser accepts and which form the formatter produces.
| Type | Cardinality | Multi-line repeat | CSV on one line | Description |
|---|---|---|---|---|
id | single | — | — | Display ID or slug |
id-list | repeatable | ✓ | ✓ | Multiple identifiers |
uri | single | — | — | URI per RFC 3986 (URN, DOI, HTTPS URL) |
url | single | — | — | HTTPS navigation link |
path | single | — | — | Filesystem path |
path-or-id | single | — | — | Filesystem path or element display ID |
enum | single | — | — | One value from a closed vocabulary |
tag-list | repeatable | ✓ | ✓ | Free-form tags |
text | single | — | — | Free-form single-line text |
citation | repeatable | ✓ | ✗ | Slug + optional free-text locator (locator may contain ,) |
external-id | repeatable | ✓ | ✓ | scheme:value qualified identifier |
integer | single | — | — | Whole number |
date | single | — | — | ISO 8601 date (YYYY-MM-DD) |
boolean | single | — | — | true or false |
Multi-line repeat (git-trailers canonical form):
Derived-from: SYS_BRK_0042
Derived-from: SYS_BRK_0043
Labels: ASIL-B
Labels: safety
CSV on one line (accepted when no value contains a comma):
Derived-from: SYS_BRK_0042, SYS_BRK_0043
Labels: ASIL-B, safety
The formatter rewrites every repeatable attribute to multi-line form. CSV is an accepted input but never a canonical output.
CSV is forbidden for the citation type. References values may carry
free-text locators like §9.4, Table 7 that would be ambiguous in CSV.
The id and id-list types accept a 26-char ULID, a scheme-qualified URI, or a
display ID. Any of these may be followed by a locator in brackets
(REQ_BRK_0010 [Brake at 20 m]); the value-format gate checks the target before
the locator only. A display ID is resolved to its target by existence; an
unresolved display ID is reported by MSL-L006, not by the value-format gate.
Display IDs are the canonical form across the full toolchain surface.
markspec fmt canonicalises a raw ULID trace value to the target’s current
display ID and heals a renamed reference via the markspec.lock ledger (see the
fmt command reference for details). The LSP ID-reference completion inserts
display IDs directly, and the MCP read tools (entry_show, entry_list,
entry_neighborhood, entry_context) present all trace targets as display IDs
— authors and agents never see raw ULIDs in cross-references.
Part 3 — Directives
Directives are HTML comments starting with markspec:. They are invisible on
GitHub and GitLab. A markspec: token at the start of a line inside an HTML
comment begins a directive. Everything until the next markspec: or --> is
the payload.
3.1 Syntax
Example 13 — single directive:
<!-- markspec:glossary -->
Example 14 — multiple directives in one comment:
<!--
markspec:deck
markspec:paginate
-->
Each markspec: line begins a separate directive; see the parsing rules below
for how a directive that takes a payload (such as the range directives
markspec:columns or markspec:section) extends it onto continuation lines.
Parsing rules:
- Scan each HTML comment for lines starting with
markspec:. - Token after
markspec:is the directive name. - Remainder of line is the start of the payload.
- Lines not starting with
markspec:are payload continuation. - A new
markspec:line or-->terminates the payload. - Range directives closed by
<!-- markspec:end NAME -->.
A markspec: directive comment is permitted anywhere inside an entry body and
is inert there — it is not entry content and never a trailer line, regardless of
its position relative to the trailer block or of whitespace after <!--. Only
non-directive raw HTML in a body is rejected (MSL-B043).
3.2 Document directives
Placed in the first HTML comment after the H1 heading.
| Directive | Payload | Context |
|---|---|---|
markspec:glossary | none | doc |
markspec:summary | none | doc |
markspec:deck | none | deck |
markspec:specs | none | doc |
markspec:tests | none | doc |
markspec:elements | none | doc |
markspec:references | none | doc |
markspec:paginate | none | deck |
Type directives (glossary, summary, deck) are mutually exclusive.
Family-hint directives (specs, tests, elements, references) hint at the
predominant entry family in the document — used by markspec fmt to classify
new entries before they carry an identity attribute. markspec:references
additionally marks the document as a references listing whose entries are
validated as bibliographic Reference citations (§6.5). doc is the default — no
directive for it.
Cross-repository federation is not declared with a directive. A project
declares its upstreams in project.yaml via the dependencies: and
references: lists; those upstreams are pinned in markspec.lock and resolved
offline from a local snapshot cache. See §6.5.
Document-level retirement uses the deprecated: front-matter key (or
supersedes: for replacement retirement), not a directive. See §6.2.
glossary and summary are auto-detected from filename (GLOSSARY.md,
SUMMARY.md). Family-hint directives are auto-detected from filename:
tests.md implies markspec:tests, elements.md implies markspec:elements,
references.md implies markspec:references. The directive is needed when the
file has a different name. deck is never auto-detected — it always requires an
explicit directive.
Example 15 — deck with pagination:
# Architecture Review
<!--
markspec:deck
markspec:paginate
-->
---
## System Boundaries
...
Example 16 — deprecated glossary:
---
document-type: glossary
supersedes: 01HGW2D0GLOSPQ4FGHIJKLMNOPQ # platform-glossary.md document-id
---
# Legacy Terms
Or for a glossary with no successor:
---
document-type: glossary
deprecated: "Archived after platform migration; content no longer maintained."
---
# Legacy Terms
Example 17 — references listing directive:
# Braking Standards
<!--
markspec:references
-->
The markspec:references directive marks the file as a references listing, so
its Reference-shape entries are validated as bibliographic citations (§6.5). It
takes no payload; the filename references.md triggers the same listing without
the directive. Federating against another project’s entries is a project.yaml
concern, not a directive — see §6.5.
3.3 Inline directives
Placed anywhere in the document body.
| Directive | Payload | Closing | Context |
|---|---|---|---|
markspec:break | page, column | — | both |
markspec:columns | count (2, 3) | markspec:end columns | both |
markspec:section | section name | — | deck |
markspec:notes | free text | inside comment | deck |
markspec:disable | MSL rule ID(s) | markspec:end disable | both |
markspec:disable-next-line | MSL rule ID(s) | — | both |
markspec:ignore | none | markspec:end ignore | both |
markspec:disable opens a range closed by markspec:end disable.
markspec:disable-next-line suppresses rules for the next line only.
markspec:ignore skips all MarkSpec processing — content inside the range is
treated as plain Markdown with no requirement parsing, reference resolution, or
MSL validation.
Example 18 — multi-column layout:
<!-- markspec:columns 2 -->
Content in the first column.
<!-- markspec:break column -->
Content in the second column.
<!-- markspec:end columns -->
In decks, markspec:break column works within a slide without the
markspec:columns range — slide boundaries are the implicit region.
Example 19 — slide section:
---
<!-- markspec:section Architecture -->
## System Boundaries
A high-level view of the braking subsystem
---
## Component Design
...
The section name appears in slide footers until the next markspec:section.
Example 20 — speaker notes:
<!--
markspec:notes
Mention the 150ms response time requirement from
STK_BRK_0001. The debounce window was determined
by bench testing with the Bosch sensor module.
-->
Notes are entirely inside an HTML comment. The --> closes the payload — no
markspec:end notes needed.
Example 21 — page break:
<!-- markspec:break page -->
Example 22 — lint suppression:
<!-- markspec:disable MSL-R011 -->
- [SRS_BRK_0108] Some _legacy_ requirement
<!-- markspec:end disable -->
<!-- markspec:disable-next-line MSL-R011 -->
- [SRS_BRK_0109] Another _legacy_ one
Part 4 — Book Structure
A MarkSpec book organizes MarkSpec files into a single navigable document. The
book is defined by a source directory containing a SUMMARY.md at its root.
4.1 Layout
The book source directory contains the SUMMARY.md and all files it references.
Directory structure is free-form — the SUMMARY.md defines the navigation, not
the file tree.
Example 23 — book source directory:
src/
├── SUMMARY.md
├── GLOSSARY.md
├── overview.md
├── product/
│ ├── stakeholder-requirements.md
│ └── software-requirements/
│ ├── README.md
│ └── braking.md
├── architecture/
│ └── system-architecture.md
└── guide/
└── getting-started.md
4.2 Summary
The summary is a SUMMARY.md file at the root of the book source directory. It
is a manually authored table of contents — not a generated file tree. The author
decides what appears and in what order.
The core structure is a nested list of links. Each link is a chapter. Nesting creates sub-chapters.
Example 24 — SUMMARY.md without parts:
# Braking Controller
- [Overview](overview.md)
- [Requirements](requirements.md)
- [Architecture](architecture.md)
- [Getting Started](getting-started.md)
- [Glossary](GLOSSARY.md)
Optional elements:
- Unnested links — links outside a list. Front matter (before the first
---) and back matter (after the last---). Rendered without numbering. - Part headings — H1 headings (
# Part Name) label groups of chapters. Rendered as unclickable section dividers. - Separators —
---separates front matter, body, and back matter.
Example 25 — SUMMARY.md with front matter, parts, back matter, and annexes:
# Braking Controller
[Overview](overview.md) [Introduction](introduction.md)
---
# Product
- [Stakeholder Requirements](product/stakeholder-requirements.md)
- [System Requirements](product/system-requirements.md)
- [Software Requirements](product/software-requirements/README.md)
- [Braking](product/software-requirements/braking.md)
- [Steering](product/software-requirements/steering.md)
- [Diagnostics](product/software-requirements/diagnostics.md)
# Architecture
- [System Architecture](architecture/system-architecture.md)
- [Software Architecture](architecture/software-architecture.md)
- [Interface Contracts](architecture/interface-contracts.md)
- [Decisions](architecture/decisions/README.md)
- [ADR-001: Documentation Format](architecture/decisions/adr-001.md)
# Guide
- [Getting Started](guide/getting-started.md)
- [Configuration](guide/configuration.md)
- [Troubleshooting](guide/troubleshooting.md)
# Verification
- [Traceability Matrix](verification/traceability-matrix.md)
- [Test Reports](verification/test-reports.md)
---
# Annexes
- [Color Palettes](annexes/color-palettes.md)
- [Coding Standards](annexes/coding-standards.md)
---
[Glossary](GLOSSARY.md) [Contributing](CONTRIBUTING.md)
[Changelog](CHANGELOG.md) [License](LICENSE.md)
The first H1 is the book title. Subsequent H1s are part headings. Front matter
(unnested links before the first ---) introduces the book. Back matter
(unnested links after the last ---) is reference and administrative content.
Both render without numbering.
Rules:
- The first H1 is the book title.
- Summary documents are exempt from the single-H1 rule — additional H1s are part headings.
---separates front matter, body, and back matter.- Every file referenced must exist.
- Empty links (
- [Title]()) are not allowed. - The summary is committed and human-authored — tooling may validate it but does not generate it.
4.3 Glossary
The glossary is a GLOSSARY.md file (or any file with a markspec:glossary
directive). It uses heading-based structure.
Example 26 — glossary:
# Glossary
## A
### ASIL
Automotive Safety Integrity Level. Risk classification defined by [ISO 26262]
ranging from QM (quality managed, no safety relevance) to D (highest
criticality). The level is determined by the [HARA] process.
### ASPICE
Automotive SPICE. A process assessment model for the automotive industry derived
from [ISO/IEC 15504].
## H
### HARA
Hazard Analysis and Risk Assessment. Systematic process defined in [ISO 26262]
Part 3 for identifying hazards and assigning [ASIL] levels.
<!-- Internal references -->
[ASIL]: #asil
[ASPICE]: #aspice
[HARA]: #hara
<!-- External references -->
[ISO 26262]: https://www.iso.org/standard/68383.html
[ISO/IEC 15504]: https://www.iso.org/standard/60555.html
Structure rules:
- H1 for the title.
- H2 for letter groupings.
- H3 for terms — alphabetically sorted within each group.
- Link reference definitions at the end of the file — internal cross-links first, external references second.
Part 5 — Inline References
Inline references resolve content entities across all documents in the project.
They use double braces: {{namespace.id}}.
5.1 Syntax
Example 27 — spec and test references:
This module implements {{spec.SRS_BRK_0107}}. Verified by {{test.SWT_BRK_0107}}.
Example 28 — reference to a standard:
Derived from {{ref.ISO-26262-6}}.
Example 29 — figure, table, and heading references:
See {{fig.system-overview}} and {{tbl.sensor-thresholds}}. Refer to
{{h.requirement-format}} for the full syntax.
On GitHub/GitLab: the braces render as plain text — the ID is human-readable. At build time: resolved to links.
5.2 Namespaces
| Namespace | References | ID source |
|---|---|---|
spec | Spec entries (any TYPE) | Display ID |
test | Test entries | Display ID |
element | Element entries | Display ID |
ref | Reference entries, resolution chain | Slug |
fig | Figures | Slug from caption |
tbl | Tables | Slug from caption |
h | Headings | GFM anchor |
Slugs use the GFM algorithm: lowercase, spaces to hyphens, punctuation stripped.
5.3 Rules
- Exactly two braces:
{{and}}. - The first period separates namespace from ID (e.g.,
{{ref.ISO-26262-6}}→ namespaceref, IDISO-26262-6). - No whitespace inside braces.
- No sections (
{{#}}), inverted sections ({{^}}), or partials ({{>}}). - Every reference must resolve at build time.
- References are never committed in resolved form.
- References inside fenced code blocks are not resolved — they render as literal text.
Part 6 — Document Model
6.1 Project properties
Shared across all documents. Every property always resolves. The project.yaml
schema is the closed org project schema, defined at
https://driftsys.github.io/schemas/project/v1.json.
MarkSpec retains tested exceptions to the org schema: it rejects an empty
project version: "", converts numeric project versions to strings with a
warning, requires projectRef names to match [A-Za-z0-9][A-Za-z0-9._-]* for
cache-directory safety, and accepts local paths with ./, ../, /, or
Windows drive C:\ prefixes and scp-style Git URLs in dependencies:. Other
project version types are rejected with ConfigError. An empty projectRef
version string means auto, as when absent. Other projectRef URLs must satisfy
the schema’s URI format.
In .markspec.yaml, exclude: and caption-conventions: accept null or an
empty YAML key as the default empty list or mapping. Profile specifiers must be
local paths starting with ./ or ../, Git specifiers of the form
git+<http|https|file>://<repository>.git[/subpath]#<ref>, or npm specifiers of
the form npm:[@scope/]name@<range>.
| Property | Source | Fallback |
|---|---|---|
| project | project.yaml → name | Repo directory name |
| repository | project.yaml → repository | git remote get-url origin |
| version | project.yaml → version | git describe |
| license | project.yaml → license | proprietary |
The optional dependencies: and references: fields must be non-empty lists of
distinct project-reference objects when present. Omit a field when it has no
entries; [], null, and an empty YAML key are invalid. Duplicate detection
compares object values independently of key order.
license: defaults to proprietary — absence of a declared license means all
rights reserved. Use SPDX identifiers when specifying a license.
6.2 Document attributes and properties
Per-file metadata splits into two tiers (mirroring the entry model):
- Attributes — authored by the author in YAML front matter.
- Properties — observed by tooling (filename, git history, filesystem).
Document attributes (authored in front matter)
| Attribute | Type | Required | Description |
|---|---|---|---|
document-id | id | no | Document ULID — 01H… 26-char Crockford base32 |
document-type | enum | no | Overrides filename/directive detection (see §6.3) |
labels | tag-list | no | Classification tags (includes DRAFT marker) |
external-id | external-id | no | Cross-system identifier (scheme:value) |
supersedes | id | no | document-id of a document this one replaces |
deprecated | string | no | Retirement reason (non-replacement case) |
references | citation | no | External reference citations with optional locator |
metadata | map | no | Org free-form metadata, never validated |
Document lifecycle mirrors entry lifecycle: DRAFT label for work in progress;
supersedes: for replacement retirement; deprecated: for non-replacement
retirement. There is no separate status: front-matter key. There is no
DEPRECATED / WITHDRAWN label.
All attribute value types follow the 14-type system from §2.6. Profiles may
declare additional keys; projects may allowlist SSG-ecosystem keys in
.markspec.yaml → frontMatter.allowedKeys (see §9.1).
Document properties (observed)
| Property | Source | Fallback |
|---|---|---|
| title | H1 heading | Filename stem |
| revision | Merge-to-main count | 0 |
| authors | project.yaml | Git unique commit authors |
| created | Git first commit timestamp | File system creation time |
| modified | Git last merge commit timestamp | File system modification time |
These are never authored in front matter — title:, author:, date:,
description:, toc:, cover: in front matter are errors (see §8.6 MSL-D001).
The H1, first paragraph, git history, and filesystem are the authoritative
sources.
revision: starts at 0. Increments on each merged PR/MR that modifies the
file. Commits within a branch do not count.
authors: project.yaml recommended — Git history is fragile across moves
and migrations.
draft / retirement: structural signals, not derived. Documents carry DRAFT
via labels: and/or deprecated: via front matter. Replacement is via
supersedes:. No branch-derived lifecycle inference.
6.3 Document types
| Type | Detection | Description |
|---|---|---|
doc | default | Any Markdown file |
glossary | GLOSSARY.md or directive | Heading-based term definitions |
summary | SUMMARY.md or directive | Book table of contents |
references | references.md or directive | Reference-entry collection |
deck | directive only | Slide deck (--- = slide breaks) |
code | file extension | Source files with doc comments |
Profiles may declare additional document types and bind them to per-type
collections (e.g., requirements.md, tests.md mapped to specific
profile-declared Authored types). The core ships only the generic types above.
Heading rules by type:
- doc — one H1, no skipped levels.
- glossary — one H1 (title), H2 (letter groups), H3 (terms).
- summary — first H1 is the book title, additional H1s are part headings. Exempt from single-H1.
- references and other profile-declared collection types — one H1, standard heading rules.
- deck — one H1 (deck title).
---creates slide breaks. H2 headings start each slide. Heading hierarchy is per-slide — H3/H4 within a slide are valid regardless of other slides.
6.4 Content entities
| Entity | Source | ID |
|---|---|---|
| Authored | Authored entry blocks (ULID-valued Id:) | Display ID |
| Reference | Reference entry blocks (URI-valued Id:) | Slug |
| fig | Figure captions, alt text | Slug |
| tbl | Table captions | Slug |
| h | Headings | GFM anchor |
The active profile classifies Authored and Reference entries into specific types
(requirement, test, unit, standard, dependency, …). The core
distinguishes only the two shapes; everything finer is profile-declared.
6.5 References
References (standards, regulations, external specifications) are resolved
through a resolution chain. Projects declare their upstreams in project.yaml
via the dependencies: field (federated git repositories) and the references:
field (published upstream compile-output sites). Resolution order: local project
→ declared dependencies (in declaration order) → declared references (in
declaration order). Every tier is resolved offline from the snapshot cache
that markspec lock pins under .markspec/cache/upstreams/; no upstream is
fetched at build time.
{{ref.ID}} inline references and Derived-from: attribute values are
validated against the resolution chain at build time.
6.6 Rule activation
Entry rules (MSL-R*) activate on any file containing - [DISPLAY_ID] entry
blocks. Traceability rules (MSL-T*) activate on entries carrying an identity
attribute. Glossary rules (MSL-G*) activate only on glossary documents.
Summary rules (MSL-S*) activate only on summary documents.
Part 7 — Formatting Rules
Fixed rules:
| Rule | Value |
|---|---|
| Line endings | lf |
| Emphasis | _text_ (underscores) |
| Strong | **text** (asterisks) |
| List marker | - (dashes) |
| List indent | the content column: 2 spaces for -, 3 for 1., 4 for 10. |
| Code fences | backticks, language required |
| Trailing whitespace | removed, except U+FEFF and U+00A0 ending a free-text attribute value |
| Final newline | single \n |
| Table columns | aligned, padded (tables exempt from line width) |
| Horizontal rules | --- |
| Reference definitions | end of file, alphabetical within groups |
Configurable rules (with defaults):
| Rule | Default | Options |
|---|---|---|
| Line width | 80 | any positive integer |
| Prose wrap | always | always, preserve |
MarkSpec normalization
- Attribute blocks — sorted to canonical order, trailing backslashes normalized.
- Entry titles — wrapped at the line width, with continuation lines indented
at the list item’s content column (§1). A wrap that starts a continuation with
an
Id:-like line is skipped. - Tabs after entry list markers — normalized to a dash followed by one space
only when the complete document retains the same CommonMark structure under
the ADR-029 semantic equivalence comparator. List hierarchy, body and trailer
containment, and existing entry identities must be preserved. Otherwise the
entry stays byte-for-byte unchanged, no
Id:is stamped, andfmtemitsMSL-F013(warning). Other entries are formatted as usual. A parent that holds the refused child as a nested entry (MSL-P024) is left unformatted and unstamped too (except for the exceptions of the nested-entry rule); child attributes are not copied to the parent. An entry with content after anId:trailer block (MSL-P025) is left unformatted and unstamped in the same way. The surrounding list layout and following indented blocks, including paragraphs outside the list item, are preserved where needed to keep refusal stable on repeated runs. Later indented trailers associated with the refused entry are also preserved, including their trace reference values. - Reference definitions — moved to end of file, sorted alphabetically within groups.
- Alerts — markers uppercased, spacing normalized.
- Front matter — YAML form; keys sorted to canonical order (core keys, then
profile-declared, then
metadata:, then allowlisted ecosystem keys); forbidden keys removed with an info diagnostic (MSL-D001). See §6.
Part 8 — Lint Rules
8.1 Severity
| Severity | CI behavior |
|---|---|
| error | Fails the build |
| warning | Reported, does not fail |
| notice | Verbose mode only |
8.2 Entry format (MSL-R)
| ID | Severity | Rule |
|---|---|---|
MSL-R001 | error | Entry block: - [DISPLAY_ID] with indented body (Reference-entry body is optional). |
MSL-R002 | error | Display ID is non-empty; matches the active profile’s display-id-pattern: for its inferred type when one applies. |
MSL-R003 | error | Exactly one Id: attribute per entry. |
MSL-R004 | error | Id: value well-formed: bare ULID (^[0-9A-HJKMNP-TV-Z]{26}$) for Authored entries; scheme-qualified URI (RFC 3986) for Reference entries. |
MSL-R005 | error | ULID unique across repository. |
MSL-R006 | error | Display ID unique within project and resolution chain. |
MSL-R007 | warning | When a profile declares a display-id-pattern: for the entry’s inferred type, the display ID matches it. |
MSL-R008 | error | Slug-shaped display ID (no scheme, not a ULID) on a Reference entry must match the slug regex. |
MSL-R009 | warning | Sequence number > 0 in patterned display IDs. |
MSL-R010 | warning | Unknown attributes (not in core universal set, not a core relation key, not Type, not declared on a core type, not declared by active profile). Generated attributes must not appear in source. |
MSL-R011 | error | No emphasis inside entry blocks. |
MSL-R012 | warning | Canonical attribute order. Auto-fixed. |
MSL-R013 | warning | Sequential numbering expected within a scope. |
MSL-R014 | error | Display ID or Id: collides with one owned by a read-only corpus — a profile-delivered corpus tier (ADR-030) or a locked upstream (ADR-031). Covers project↔corpus, project↔upstream, upstream↔upstream, and upstream↔corpus collisions; the message names both origins. Rename the reusing entry. |
MSL-R001 and MSL-R011 apply to all entry blocks. MSL-R002–R010 apply to entries
carrying an Id: attribute.
8.3 Traceability (MSL-T)
| ID | Severity | Rule |
|---|---|---|
MSL-T001 | error | Satisfies: target must resolve to an existing spec entry. |
MSL-T004 | warning | Derived-from: target must resolve to an existing spec entry. |
MSL-T005 | error | References: slug must resolve to an existing reference entry. |
MSL-T006 | error | Allocated-to: target must resolve to an existing element entry. |
MSL-T007 | error | Realizes: target (on elements) must resolve to an existing spec entry. |
MSL-T008 | error | Verifies: target (on tests) must resolve to an existing spec entry. |
MSL-T009 | error | Tests: target (on tests) must resolve to an existing element entry. |
MSL-T010 | error | Part-of: target must resolve to an existing element entry. |
MSL-T011 | error | Depends-on: target must resolve to an existing element entry. |
MSL-T012 | error | Supersedes: target must resolve to an existing same-family entry. |
MSL-T013 | tiered | Link target is non-active: DRAFT label=info; Superseded-by: set or Deprecated: set=warning. |
MSL-T014 | warning | Trace target unresolved after upstream federation — the downstream project declares dependencies:/references:, but the target resolves in neither the project nor any declared upstream. |
Type resolution and per-type attribute validation (spec §1.3, §1.6):
| ID | Severity | Rule |
|---|---|---|
MSL-T020 | error | Type: value is neither a core type nor a profile-declared type. |
MSL-T021 | warning | Core type inferred (display-ID prefix, URI scheme, or discriminating attribute); declare Type: explicitly to silence. |
MSL-T022 | warning | Attribute is core-known but not valid on the entry’s resolved type. |
MSL-T023 | error | Type: value looks like a profile-declared type but no profile is loaded (core-only mode). |
MSL-T024 | warning | Entry carries a type-specific attribute but its core type could not be resolved (no Type:, no profile, no inferable signal). |
MSL-T025 | error | Discipline: value is not a known kind (core or profile-declared) — ADR-017 Slice 3. |
MSL-T026 | error | Discipline-frozen: value is malformed (expected <kind> or <kind> @ YYYY-MM-DD, calendar-valid date) — ADR-017 Slice 3. |
MSL-T027 | error | Discipline-frozen: parses but its kind is not in the effective kind set — ADR-017 Slice 3. |
MSL-T028 | warning | Discipline: override conflicts with the type-based derivation (channel 3) — ADR-017 Slice 3. |
MSL-T029 | warning | Discipline: override conflicts with the allocation-based derivation (channel 4) — ADR-017 Slice 3. |
MSL-T030 | warning | Discipline-frozen: kind differs from the current channels-3/4 derivation. Not suppressed when current derivation defaults to system — ADR-017 Slice 3. |
MSL-T031 | warning | Discipline: and Discipline-frozen: both well-formed and reference known kinds, but disagree — ADR-017 Slice 3. |
Profile-declared enum attributes (e.g., ASIL, Test-level, Element-kind)
are validated against the vocabulary declared in the active profile’s manifest.
The core defines no enum vocabularies of its own.
Direction and level-crossing rules (e.g., “acceptance tests verify stakeholder requirements”) are profile concerns, not core concerns.
8.4 Link rules (MSL-L)
Existence and cardinality rules for the targets of trace-relation links.
| ID | Severity | Rule |
|---|---|---|
MSL-L006 | warning | Profile trace-relation target does not resolve to any entry (resolved by display ID or ULID). Scheme-qualified URIs are exempt. |
MSL-L007 | warning | A locator on Satisfies: or Verifies: names no addressable scenario of its target. Reported only when the target resolves to a Requirement or Contract entry. |
MSL-L008 | warning | A locator on a trace relation that does not accept one. Only References:, Derived-from:, Satisfies: and Verifies: accept a locator. |
MSL-L009 | warning | A trace value has a [ after whitespace that no ] closes. It has no locator; commas after the [ still separate values (A [x], B [z, C → A [x], B [z, C). |
A trace value can carry a locator after its target, as in the value
REQ_BRK_0010 [Brake at 20 m] of a Verifies: attribute (see
Locators). The locator does not change the
link target: the link goes to REQ_BRK_0010 whether the locator resolves or
not, and MSL-L006 checks the target only. A locator on a target that does not
resolve raises MSL-L006 and never MSL-L007. A locator on a target that
carries no scenarios (an entry that is not a Requirement or Contract, or a
Reference entry) is free text and raises no MSL-L007. MSL-L008 keeps the
link to the target and ignores the locator. A locator that names a scenario name
used more than once in the target is not addressable and raises MSL-L007.
A value without a closed locator is read as it was before locators existed. A
Derived-from: or References: value links to its first whitespace-separated
token. Any other trace value links to the whole value, so
Satisfies: SYS_BRK_0042 (braking) links to SYS_BRK_0042 (braking), which
MSL-L006 reports when no such entry exists.
8.5 References (MSL-M)
| ID | Severity | Rule |
|---|---|---|
MSL-M001 | error | Every {{namespace.id}} must resolve. |
MSL-M002 | error | Namespace: spec, test, element, ref, fig, tbl, h. |
MSL-M003 | error | No sections, inverted sections, or partials. |
8.6 Document structure (MSL-D)
| ID | Severity | Rule |
|---|---|---|
MSL-D001 | error | Front matter keys must be core, profile-declared, metadata, or allowlisted in .markspec.yaml. Forbidden keys (title, description, toc, authors, author, date, created, modified, cover, images, sections) are errors with auto-fix to remove. |
MSL-D002 | warning | Footnotes must not contain requirement IDs. |
MSL-D003 | notice | Non-standard alert types. |
MSL-D004 | warning | Caption format: _Table:_ above, _Figure:_ below. |
MSL-D005 | warning | SVGs: viewBox required, no fixed width/height. |
MSL-D006 | configurable | Inline links vs reference-style links. Controlled by referenceLinks config: none (no check), warn (prefer reference-style), enforce (require reference-style). |
MSL-D007 | warning | Reference definitions at end of document, alphabetical within groups. Auto-fixed. |
MSL-D008 | error | Image paths must be relative and stay within the document folder. Absolute URLs (https://...), repo-root links (/...), and paths escaping via ../../ are not permitted (ADR-003). |
8.7 Glossary (MSL-G)
| ID | Severity | Rule |
|---|---|---|
MSL-G001 | error | H1 title, H2 letter groups, H3 terms. |
MSL-G002 | warning | Terms sorted within letter groups. |
MSL-G003 | warning | Link references at end of file, alphabetical within groups (internal then external). |
MSL-G004 | error | Cross-links reference existing headings. |
8.8 Summary (MSL-S)
| ID | Severity | Rule |
|---|---|---|
MSL-S001 | error | Every link target must reference an existing file. |
MSL-S002 | error | No empty links (- [Title]()). |
MSL-S003 | error | No duplicate file paths. |
MSL-S004 | warning | Markdown files in the source directory not referenced in summary. |
8.9 Formatting (MSL-F)
Drift between a file’s on-disk form and what markspec fmt would write, plus
diagnostics for rewrites that fmt refuses. MSL-F010 and MSL-F011 fire only
in the project-wide composite markspec check gate (ADR-027) and mirror
markspec fmt / markspec fmt --check exactly, from the same .gitignore- and
exclude:-aware corpus. They cover Markdown files and .feature files;
markspec fmt never rewrites source files. For a .feature file, MSL-F010
means only that a header has no # Id: line.
| ID | Severity | Rule |
|---|---|---|
MSL-F010 | error | Formatter drift: the file’s whitespace / attribute form differs from markspec fmt output (indentation, backslashes, attribute order, modal-verb casing, …). |
MSL-F011 | error | Reference-canonicalization drift: a trace-relation value is a ULID or stale display ID that markspec fmt would rewrite to its current canonical display ID (ADR-026). Kept distinct from MSL-F010 so the author knows which fmt concern fired. |
MSL-F012 | info | Markdown-pass fallback. The prose formatter failed, or its output changed CommonMark semantics, body block kinds, or how MarkSpec reads an entry’s identity or trailer. The formatter kept the text from before the Markdown pass (ADR-029). |
MSL-F013 | warning | Tab-separated entry marker cannot be normalized without changing CommonMark structure; kept the entry unchanged. No Id: is stamped into the refused entry. |
MSL-F014 | warning | A line shaped like Id: appears in the entry’s title continuation or body. The formatter preserves the identity line and skips stamping. |
MSL-F010 and MSL-F011 are project-wide-only — a file-local
markspec check <file> does not fire them (the canonical agent path runs fmt
before check). MSL-F012 is emitted directly by fmt (and format-on-save)
when the whole-document Markdown pass (ADR-029) falls back on a single entry, so
it fires file-locally too — it is not gated on the composite check corpus.
MSL-F013 is also emitted directly by fmt, including file-local formatting,
when tab-marker normalization is refused. MSL-F014 likewise fires when fmt
finds an unread identity line outside the trailer. Fenced code examples and
empty placeholders in canonical trailer blocks are exempt. The MSL-F prefix is
a bounded early adoption of the nextgen “format reports” family (ADR-012), the
same pattern as MSL-B044 / MSL-C072; see ADR-012’s ADR-027 amendment.
8.10 Lockfile and external sync (MSL-L, MSL-S)
The lockfile (MSL-L###) and external-sync (MSL-S###) diagnostic families
(ADR-022, ADR-012 amendment) are catalogued below. The offline composite
markspec check gate emits MSL-L212 and MSL-L215; the network
markspec lock flow emits MSL-L213, MSL-L214, and MSL-L216:
| ID | Severity | Rule |
|---|---|---|
MSL-L212 | error | Canonical edge-hash drift: the project’s traceability edges no longer match the hash pinned in markspec.lock (run markspec lock). Fires only when markspec.lock exists; checked offline (no network — upstream resolution stays in markspec lock --check). |
MSL-L213 | warning | A declared dependencies: or references: upstream could not be locked — no derivable id, a fetch/ls-remote failure, a malformed manifest or tree, or a schema-version mismatch. Emitted during markspec lock (warn-and-write: markspec lock still writes every pin that did resolve). |
MSL-L214 | warning | Restore-flow snapshot mismatch: a references: cache needed restoring, but the re-fetched content’s hash no longer matches the pinned snapshot (the published site moved). Emitted during markspec lock; run markspec lock --update=<id> to move the pin deliberately. |
MSL-L215 | warning | A dependencies: pin resolved to a branch or bare sha, not a tag (an unreleased state). Advisory by default; promoted to an error under markspec check --strict — release builds require every dependency to be tag-pinned. |
MSL-L216 | warning | An upstream id is claimed by both a references: and a dependencies: entry. The dependency is skipped (the reference snapshot owns the shared cache); set a distinct name: on one of them. Emitted by markspec lock, which then exits 2. |
Prefix overlap (known, pre-existing). The
MSL-L###lockfile family shares its prefix with §8.4’s link rules (MSL-L006), and theMSL-S###external-sync family shares its prefix with §8.8’s summary rules (MSL-S001–S004). This overlap predates the composite gate; disambiguation is deferred to the sequenced ADR-012 scheme migration, not resolved here (code names are a public interface — renumbering is a breaking change).
8.11 Book build (MSL-K)
Build-time diagnostics raised by markspec book build when a book’s chapter set
cannot produce a coherent static site. Emitted to stderr as
error[MSL-K001]: …; an error aborts the build before any file is written, so a
broken site is never emitted.
| ID | Severity | Rule |
|---|---|---|
MSL-K001 | error | Chapter slug collision: two distinct chapter source paths flatten to the same output slug (e.g. recipes/deploy.md and recipes-deploy.md → recipes-deploy.html). Rename one chapter to disambiguate. |
The MSL-K prefix is a bounded early adoption of a nextgen “book build” family,
recorded on the same footing as the MSL-F formatting family (§8.9) and the
MSL-L / MSL-S families (§8.10) (ADR-012’s book-build amendment).
8.12 Body (MSL-B)
Diagnostics for the content of an entry body. This table lists the codes about
feature blocks (fenced gherkin or feature blocks). The other body codes
(MSL-B040 to MSL-B044) are listed in the core data model specification.
A feature block is read with a Gherkin parser, so its keywords can be in any
language that Gherkin supports (# language: fr). A block that has no
Feature: line is read as if it had one, and the added line is not counted in
any position.
Free text between a scenario line and its first step is the description of the scenario, not an error.
| ID | Severity | Rule |
|---|---|---|
MSL-B060 | warning | A scenario name occurs more than once in the feature blocks of one Requirement or Contract entry. Reported on the second and later occurrences, at column 1 of the scenario line. A locator cannot address that name. |
MSL-B061 | info | A scenario in a feature block of a Requirement or Contract entry has an empty name. Reported at column 1 of the scenario line. A locator cannot address it. |
MSL-B062 | warning | A feature block of an entry of any type, also one nested in a list item, does not parse as Gherkin. Reported at the file line of the first parser error, at column 1. The scenario names of a top-level block are then read by a line scanner that knows English keywords only. For a .feature file, reported only when the file has a # [ID] header line, at the file line and column of the first parser error (or at line 1 when the Gherkin parser fails to load); the file then gives no entries (see §1.3 §7). |
MSL-B063 | warning | A step of the procedure of a scenario in a feature block has one or more actions and no expected result. Checked for entries whose type is or extends Test, so the check needs a profile that types the entry: a Type: Test trailer with no profile is not checked. A headed .feature entry is typed without a profile (step 6a, ADR-038 Case B decision 6). Reported at the file line of the last action of the step, at column 1. A block that does not parse is skipped. The roles are Given precondition, When and * action, Then outcome, with And and But taking the role of the previous step; an action after an outcome, or a precondition after an action or outcome, opens a new numbered step (see Procedure steps). |
MSL-B064 | warning | A scenario of a criteria block has no outcome step. A criteria block is a feature block in an entry whose type is or extends Requirement or Contract, so the check needs a profile that types the entry; a headed .feature entry is typed without a profile (step 6a, ADR-038 Case B decision 6). Nested blocks at any depth are checked. The scenario has no Then step (including an And or But after one), or no step at all; a scenario with Given and Then and no action is valid. Scenario Outline Examples are not considered. A block that does not parse is skipped. Reported at the file line of the Scenario keyword, at column 1 (see Role of a Gherkin block). |
MSL-B065 | info | A step of the procedure of a scenario in a procedure block has an expected result and no action. A procedure block is a feature block in an entry whose type is or extends Test. Reported at the file line of the first expected-result step of that step, at column 1 (see Procedure steps). |
MSL-B066 | info | A scenario in a criteria block or a procedure block starts with And or But, which is read as an action. Reported at the file line of that step, at column 1. Not reported for an illustration. |
MSL-B067 | info | A # Step comment (#, optional spaces, Step, then whitespace or the end of the line) in a procedure block labels no step: it is above a leading precondition or a step that does not open a procedure step, it has a description line between it and the next step, it has no step after it (also one before Examples: or outside every scenario), or it is a second label above the same step. Reported at the file line of the comment, at column 1 (see Step labels). |
MSL-B068 | info | A feature block is in an entry that has a type but whose type is neither a Requirement, a Contract nor a Test (or an extension of one), so the block is an illustration. Reported at the first line of the block, at column 1. An entry with no type, after classification with the profile, is not reported. |
MSL-B069 | warning | In a .feature file, a # [ID] header comment stands above a Background, an Examples table or a step, or is not directly above any node, so it is not an entry. Reported at the first line of the header, at the column of its #. |
Part 9 — Configuration
9.1 Schema
.markspec.yaml:
referenceLinks: warn # none | warn | enforce
frontMatter:
allowedKeys:
- layout # Hugo
- permalink # Jekyll
- sidebar_position # Docusaurus
- draft
- aliases
.markspec.toml:
referenceLinks = "warn"
[frontMatter]
allowedKeys = ["layout", "permalink", "sidebar_position", "draft", "aliases"]
| Property | Type | Default | Values |
|---|---|---|---|
referenceLinks | string | "warn" | none, warn, enforce |
frontMatter.allowedKeys | string[] | [] | Top-level front-matter keys to accept beyond core / profile / metadata. Preserved verbatim, not validated. |
All formatting rules are fixed, with one exception: the effective profile
convention modal-keywords.casing changes the casing of modal and EARS keywords
in entry bodies. There is no formatter choice — dprint is the formatter.
The default casing, which rfc2119 and iso also select, lowercases SHALL,
SHOULD, MAY and MUST (with a following NOT), and lowercases the EARS
keywords When, While, Where and Unless in the middle of a sentence. The
effective profile convention modal-keywords.casing: preserve keeps the source
casing of modal and EARS keywords in entry bodies during formatting. The CLI
formatter, the project-wide format-drift gate (MSL-F010), the editor formatter
and MarkDesk proposals use the same effective convention, each with the profile
of its own project. Without preserve or rfc8174, the core casing rules
apply. The MSL-M060 warning, which reports an uppercase modal keyword, does
not fire under preserve; the missing-modal hint MSL-M061 and unrelated prose
findings remain active.
Under modal-keywords.casing: rfc8174, MSL-M060 is not emitted, because
uppercase is the normative form. Instead, MSL-M062 (info) reports each
lowercase modal keyword in an entry whose type resolves to Requirement: the
core type, a profile type that extends it (set by an explicit Type: or by the
profile display-ID pattern), the built-in REQ display-ID prefix, or a
.feature Feature or Rule entry. Like MSL-M060, MSL-M062 does not report a
keyword in inline code, link destinations, titles and labels, autolinks, images,
link reference definitions, footnote labels or raw HTML, which the formatter
keeps as written. MSL-M062 also reports a lowercase may, should, will
and should not, which markspec fmt does not change (see below): it clears
the note only for shall and must, so the note on may, should or will
stays until the author uppercases the word, if it is normative, or leaves it as
plain English.
Under rfc8174, markspec fmt uppercases shall and must in entry bodies,
in any casing, together with a not that directly follows them (shall not
becomes SHALL NOT). It leaves may, should, will and the EARS keywords as
written, because a lowercase may or will is often plain English. A
hyphenated word such as must-have is not changed. A not that starts the next
line of the same paragraph is uppercased too (must at the end of a line and
not at the start of the next become MUST and NOT), so that fmt gives the
final form in one pass when it joins the lines. This includes a two-space hard
line break, but not a backslash hard break (must\ at a line end): there the
not on the next line is kept as written. A not that starts another
paragraph, a list item, or the line after a heading, also inside a blockquote,
is not changed. A keyword on a paragraph continuation line indented four or more
spaces needs a second fmt pass in both casings. Under rfc8174, a keyword and
not on two lines of a nested blockquote also need a second pass
(> > It shall and > > not fail. become >> It SHALL not fail., then
>> It SHALL NOT fail.). Under the default casing, > > It SHALL and
> > NOT fail. become >> It shall NOT fail., and later passes keep it,
because the split NOT keeps its case. The rewrite applies to must and
shall in the body of a Markdown entry of any type, not only requirements, and
to plain English such as a sentence-initial Must we .... fmt does not
rewrite source doc comments, and in a .feature file it only stamps a missing
# Id:, so an MSL-M062 in a source doc-comment or .feature entry is fixed
by hand. Inline code, link destinations and titles, autolinks, images and HTML
keep any word as written. A table is cased one cell at a time, as under the
default casing: shall and must in a table cell are uppercased, with a not
that follows them in the same cell, and preserve keeps a cell as written. The
check fmt-drift gate (MSL-F010), the LSP formatter and MarkDesk proposals
apply the same rule.
9.2 CI
lint:
steps:
- name: Format check
run: markspec fmt --check
- name: Lint
run: markspec check
9.3 Editor integration
- Format-on-save: dprint (
dprint.vscode). - Diagnostics: markdownlint (David Anson) for generic rules; MarkSpec LSP
(
markspec-lsp) for MSL rules.
Annex A — Formatter Compatibility
dprint is the MarkSpec formatter. This table maps MarkSpec rules to dprint settings and equivalent Prettier settings for teams migrating from Prettier.
| Behavior | dprint | Prettier (reference) |
|---|---|---|
| Emphasis | emphasisKind: underscores | _text_ (default) |
| Strong | strongKind: asterisks | **text** (default) |
| Lists | unorderedListKind: dashes | - (default) |
| Table alignment | aligned | aligned |
| Trailing whitespace | removed | removed |
| Final newline | ensured | ensured |
| Line width | lineWidth: 80 | printWidth: 80 |
| Prose wrap | textWrap: "always" | proseWrap: "always" |
| Line endings | newLineKind: "lf" | endOfLine: "lf" |
| Indent | (global) 2 | tabWidth: 2 |
Prettier’s proseWrap defaults to "preserve". MarkSpec requires "always".
Annex B — dprint.json
{
"$schema": "https://dprint.dev/schemas/v0.json",
"incremental": true,
"markdown": {
"lineWidth": 80,
"textWrap": "always",
"newLineKind": "lf",
"emphasisKind": "underscores",
"strongKind": "asterisks",
"unorderedListKind": "dashes"
},
"includes": ["**/*.md"],
"excludes": [
"**/node_modules",
"**/target",
"**/dist",
"**/build",
"CHANGELOG.md"
],
"plugins": [
"https://plugins.dprint.dev/markdown-0.22.1.wasm"
]
}
Annex C — .prettierrc (migration reference)
Prettier is not the MarkSpec formatter. This config is provided for teams migrating from Prettier to dprint, to verify equivalent output during transition.
{
"$schema": "https://json.schemastore.org/prettierrc",
"printWidth": 80,
"proseWrap": "always",
"tabWidth": 2,
"useTabs": false,
"endOfLine": "lf",
"embeddedLanguageFormatting": "auto",
"overrides": [
{
"files": ["CHANGELOG.md"],
"options": {
"proseWrap": "preserve"
}
}
]
}
Annex D — .markdownlint.yaml (standalone)
heading-increment: true
heading-style: { style: atx }
no-missing-space-atx: true
no-multiple-space-atx: true
blanks-around-headings: true
heading-start-left: true
no-duplicate-heading: { siblings_only: true }
single-title: true # override to false for SUMMARY.md
no-trailing-punctuation: true
first-line-heading: true
ul-style: { style: dash }
list-indent: true
ul-indent: { indent: 2 }
ol-prefix: { style: ordered }
list-marker-space: true
blanks-around-lists: true
no-trailing-spaces: true
no-hard-tabs: true
no-multiple-blanks: true
single-trailing-newline: true
line-length:
line_length: 80 # from .markspec.yaml lineWidth
tables: false
code_blocks: false
headings: false
blanks-around-fences: true
fenced-code-language: true
code-block-style: { style: fenced }
code-fence-style: { style: backtick }
no-emphasis-as-heading: false
no-space-in-emphasis: true
emphasis-style: { style: underscore }
strong-style: { style: asterisk }
no-bare-urls: true
no-space-in-links: true
no-empty-links: true
no-alt-text: true
link-fragments: true
link-image-reference-definitions: true
link-image-style: true
no-inline-html: true
no-multiple-space-blockquote: true
no-blanks-blockquote: false
hr-style: { style: "---" }
required-headings: false
proper-names: false
Annex E — .markdownlint-dprint.yaml
Formatting rules disabled (→ dprint).
heading-increment: true
heading-style: { style: atx }
no-missing-space-atx: true
no-multiple-space-atx: true
blanks-around-headings: false # → dprint
heading-start-left: true
no-duplicate-heading: { siblings_only: true }
single-title: true # override to false for SUMMARY.md
no-trailing-punctuation: true
first-line-heading: true
ul-style: { style: dash }
list-indent: true
ul-indent: { indent: 2 }
ol-prefix: { style: ordered }
list-marker-space: true
blanks-around-lists: false # → dprint
no-trailing-spaces: true # safety net
no-hard-tabs: true
no-multiple-blanks: false # → dprint
single-trailing-newline: false # → dprint
line-length:
line_length: 80 # from .markspec.yaml lineWidth
tables: false
code_blocks: false
headings: false
blanks-around-fences: false # → dprint
fenced-code-language: true
code-block-style: { style: fenced }
code-fence-style: { style: backtick }
no-emphasis-as-heading: false
no-space-in-emphasis: true
emphasis-style: { style: underscore } # safety net
strong-style: { style: asterisk } # safety net
no-bare-urls: true
no-space-in-links: true
no-empty-links: true
no-alt-text: true
link-fragments: true
link-image-reference-definitions: true
link-image-style: true
no-inline-html: true
no-multiple-space-blockquote: true
no-blanks-blockquote: false
hr-style: { style: "---" }
required-headings: false
proper-names: false
Annex F — In-Code Entries by Language
A doc comment starting with [TYPE_XYZ_NNNN] (with or without a leading -) is
recognized as a MarkSpec entry. The following examples show the same entry in
each supported language.
Rust
#![allow(unused)]
fn main() {
/// [SWT_BRK_0107] Debounce unit test
///
/// Given a 10ms debounce window, a 5ms noise spike
/// must not alter the stable output.
///
/// Id: 01HGW3R9QLP4ABCDEFGHJKMNPQ
/// Verifies: SRS_BRK_0107
/// Tests: braking_core::controller::debounce_input
/// Labels: ASIL-B
#[test]
fn swt_brk_0107_debounce_filters_noise() {
// test implementation
}
}
Kotlin
/**
* [SWT_BRK_0107] Debounce unit test
*
* Given a 10ms debounce window, a 5ms noise spike
* must not alter the stable output.
*
* Id: 01HGW3R9QLP4ABCDEFGHJKMNPQ
* Verifies: SRS_BRK_0107
* Tests: braking_core::controller::debounce_input
* Labels: ASIL-B
*/
@Test
fun `swt_brk_0107 debounce filters noise`() {
// test implementation
}
C++ (Doxygen)
/// [SWT_BRK_0107] Debounce unit test
///
/// Given a 10ms debounce window, a 5ms noise spike
/// must not alter the stable output.
///
/// Id: 01HGW3R9QLP4ABCDEFGHJKMNPQ
/// Verifies: SRS_BRK_0107
/// Tests: braking_core::controller::debounce_input
/// Labels: ASIL-B
auto debounce_input(uint16_t raw) -> uint16_t;
C (Doxygen)
/**
* [SWT_BRK_0107] Debounce unit test
*
* Given a 10ms debounce window, a 5ms noise spike
* must not alter the stable output.
*
* Id: 01HGW3R9QLP4ABCDEFGHJKMNPQ
* Verifies: SRS_BRK_0107
* Tests: braking_core::controller::debounce_input
* Labels: ASIL-B
*/
void debounce_input(uint16_t* raw);
Java (JDK 23+)
/// [SWT_BRK_0107] Debounce unit test
///
/// Given a 10ms debounce window, a 5ms noise spike
/// must not alter the stable output.
///
/// Id: 01HGW3R9QLP4ABCDEFGHJKMNPQ
/// Verifies: SRS_BRK_0107
/// Tests: braking_core::controller::debounce_input
/// Labels: ASIL-B
@Test
void swt_brk_0107_debounce_filters_noise() {
// test implementation
}
Java (legacy Javadoc)
Trailing backslashes are omitted — they render as literal characters in Javadoc. Attributes are on consecutive lines.
/**
* [SWT_BRK_0107] Debounce unit test
*
* Given a 10ms debounce window, a 5ms noise spike
* must not alter the stable output.
*
* Id: 01HGW3R9QLP4ABCDEFGHJKMNPQ
* Verifies: SRS_BRK_0107
* Tests: braking_core::controller::debounce_input
* Labels: ASIL-B
*/
@Test
void swt_brk_0107_debounce_filters_noise() {
// test implementation
}
Language support summary
| Language | Doc syntax | Markdown native? |
|---|---|---|
| Rust | /// | yes |
| Kotlin | /** */ KDoc | yes |
| C++ | /// Doxygen | yes (since 1.8) |
| C | /** */ Doxygen | yes (since 1.8) |
| Java 23+ | /// (JEP 467) | yes |
| Java (legacy) | /** */ Javadoc | no (HTML) |