# The `.ssp` format **The object-centric document abstraction, written as text. Format version 2.1**, as spine emits and reads it after 0.25.1. This document specifies *one serialisation*. The model it serialises is specified in [`ocda-model.md`](ocda-model.md), which the sqlite serialisation shares; read that first if the question is what an object *is* rather than how it is written down. ## The name `.ssp` belongs to the family of SiSU markup extensions, `.sst` (sisu text), `.ssm` (sisu master) and `.ssi` (sisu insert), and a short extension was wanted that sat with them. It stands loosely for **sisu peg**, or **sisu parsable**. `.ssa`, for sisu abstraction, was thought to be taken by other projects. So the extension names the *file family and its parsability*, where `.ocda.db` names the *model and its container*. The two are not parallel in construction and are not meant to be. ## Status This specification is derived from the emitter (`sisudoc/ocda/abstraction/ssp.d` in sisudoc-spine, whose `sspObjectRecord` is "the single definition of what an object looks like in a `.ssp` file"), and every claim in it is checked against the project's 36 document reference set. Where the two could differ, the emitter is normative and this document is wrong. ## 1. What a `.ssp` is A `.ssp` file is the serialisation, as text, of one language of one document after spine has parsed it: the object model, not the markup and not any output format. Spine's pipeline is **markup -> abstraction -> output**. A `.ssp` is the middle stage written down. Since spine 0.25.0 it is also read back, so a document may enter the pipeline at the abstraction stage instead of being parsed, and the output writers cannot tell which happened. The format is: - **line oriented.** Every construct is a whole line. No line continuations. - **order significant.** Sections appear in a fixed order, objects in document order, and an object's properties in a fixed order (section 6.3). - **UTF-8**, without a byte order mark. - **lossless for the abstraction**, not for the markup: a `.ssp` read back and re-emitted is byte identical, which the project's test suite asserts over the whole reference set. ### 1.1 What it is not It does not carry the markup it was made from, and it does not carry its images: it *names* them, with their digests and pixel sizes, and they must be found beside it (`../image/` within a pod) for the document to be complete. An artefact that carries both is the `.ocda.db`, which is built by reading a `.ssp` back, so it can hold nothing this format cannot express. ## 2. Version and compatibility The version is declared **in band**, on the first line of every file: ``` % SiSU Document Abstraction v2.1 ``` and by the sibling sqlite serialisation in its `schema.version` metadata row, so that one bump moves both. ### 2.1 The rule - The **minor** part is raised when a property is **added**. A reader of the newer format still reads the older one. - The **major** part is raised when a property **changes meaning or goes away**. - A reader **checks the major part and refuses what it does not know**, rather than loading an unfamiliar artefact half populated in silence. ### 2.2 History | version | date | what moved | |---------|------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | 2.1 | 2026-09-29 | `.ocn_range`, the first and last ocn of what a container holds. A poem is a container of verses and is cited as their range: it now comes before its first verse, carries ocn `0` and no identifier, and states the range, where it had come after its last verse carrying that verse's ocn and identifier, so that one number named two objects. A minor bump: the property is an addition, the poem was never rendered and has no text, the verses are unchanged, and a 2.0 reader reads a 2.1 file. The same run gathers a note in a poem's last verse into the endnotes, which it had not been: one more endnote in the reference collection. And the editor's notes, `~[* ]~` and `~[+ ]~`, which spine had not recognised and passed through as text, are notes: a third form of note mark, a symbol and a number (`*1`, `+1`), each series numbered through the document; 135 more endnotes, 2,294 in all (section 3.2, "A note begins with its mark"). | | 2.0 | 2026-09-18 | `source.digest` changes meaning: it covers every markup file the document is made of, where it had been the digest of the master file alone. A change of meaning, so the major part. | | 1.1 | 2026-09-10 | The `@source` block; the document metadata the output writers read, carried in full (14 `@meta` and 3 `@make` properties added); `.segment_lv4_is`. | | 0.1 | | The first form. | ## 3. Lexical structure Six line types, distinguished by their first character. Nothing else is a valid line. | line | form | meaning | |--------------------|-----------------|-----------------------------------------------| | comment | `% ...` | file header only (section 4) | | block open | `@name {` | opens a preamble block or a section | | block close | `}` | closes it | | key | ` key: value` | inside a preamble block, two spaces of indent | | object declaration | `[ocn] kind...` | opens an object record (section 6.1) | | property | `.name: value` | a property of the object just declared | | text | `\| text` | a line of the object's text | | blank | | separates records; carries no meaning | A value runs to the **end of the line**. It is not quoted, and it is not trimmed beyond the single space after the colon. A value may therefore contain `:`, spaces, and any UTF-8 character except a line break. ### 3.1 Escaping Only one value is escaped, because only one value is a **joined list**: `.heading_ancestors_text` joins eight slots with `|`. A slot that itself contains `|`, a backslash, or a line break would otherwise be unreadable. | in the value | written as | |-----------------|------------| | `\` | `\\` | | `\|` | `\\|` | | newline | `\n` | | carriage return | `\r` | Unescaping reads left to right: a backslash escapes the next character, `\n` and `\r` become the control characters, any other escaped character stands for itself, and an unescaped `|` ends the slot. **No other value is escaped**, and text lines are not escaped at all: a text line is the object's text verbatim after the two-character `| ` prefix. ### 3.2 Object text is internal markup The text on `|` lines is spine's **internal** representation, neither the author's markup nor any output. It carries the markers spine uses to hold inline structure: The full set is defined in spine's `InlineMarkup` (`ocda/meta/defaults.d`). Counts are occurrences in object text across the 36 document reference collection, which distinguishes what a reader will certainly meet from what it may not. | marker | means | count | where | |-------------|---------------------------------------------|--------|----------------------| | `░` | non-breaking space | 23,048 | | | `┥` `┝` | link text, open and close | 20,290 | | | `┤` `├` | link target, open and close | 20,290 | | | `⑆` | a page number of the source edition follows | 19,099 | | | `┨` `┣` | that page number, open and close | 19,099 | | | `■` | monospace | 10,688 | | | `【` `】` | an inline note, its mark first (below) | 2,294 | | | `¤` | an internal site link | 2,157 | | | `┊` | table cell separator | 695 | `table` objects only | | `┙` | line break, inline | 184 | | | `☼` | an image, in a link's text slot | 63 | | | `┚` | line break, spaced | 50 | `group` objects only | | `〖` `〗` | a starred note | 0 | | | `‖` | a citation | 0 | | | `┘` | line break, plain | 0 | | | `┼` `┿` `╂` | page break: line, page, new page | 0 | | | `┏` `┆` | table open, table paragraph | 0 | | | `␣` | separator | 0 | | **A count of 0 means the reference collection does not exercise it, not that it cannot appear.** All of these are defined by the emitter and a reader must be prepared for them. **A note begins with its mark**, then whitespace, then the note: `【12 text】`. The mark is one of three forms, and a reader must take all three: | mark | what | example | |-------------------------|-------------------------------------------------------------------------------------------------------------------------------|----------------------------| | digits | the author's notes, numbered through the document | `【12 ...】` | | `*` or `+`, repeated | a special note, marked by the symbols alone | `【** ...】` | | `*` or `+`, then digits | an editor's note (2.1): the markup's `~[* ]~` and `~[+ ]~`, each series numbered through the document apart from the author's | `【*3 ...】`, `【+1 ...】` | So the pattern is `【(\d+|[*+]+[0-9]*)\s`. Before 2.1 the third form did not occur: spine did not recognise the editor's-note markup, and it came through as text, `~[* ...]~` and all. Each note of every form is gathered into the `endnotes` section, where its `.anchor_tag` is `note_` and the mark (`note_12`, `note_*3`). Two traps in this table, both found by counting rather than by reading: **`┚` is defined twice**, as the spaced line break and as the table close. In object text it occurs only in `group` objects, never in a `table`, so the object's kind resolves it. A reader should decide by kind rather than by character. **`「` and `」` are not markers here.** They are defined in `InlineMarkup` as the wrapper spine's ODT writer puts around an object number, but that happens at output, after the abstraction. Their 67 occurrences in the reference collection are **Japanese corner brackets in the document's own text**, being quotation marks in Japanese. In a `.ssp` they are always content. Some markers are the ASCII characters `*`, `!`, `/`, `_`, `^` and `,` for emphasis, bold, italic, underscore, superscript and subscript. These are **not distinguishable from ordinary text by inspection**, and a reader that needs them must follow spine's rules for where they apply rather than searching for the characters. A reader that renders text must decode all of this; a reader that only searches or counts need not, and one that wants plain text may strip the non-ASCII markers and take the ASCII ones as text. They are stable and they are part of the format. ## 4. File shape In order, and this order is fixed: ``` % SiSU Document Abstraction v2.1 % Source: @source { ... } @meta { ... } @make { ... } @doc_has { ... } @head { ... } @toc { ... } @body { ... } @endnotes { ... } @glossary { ... } @bibliography { ... } @bookindex { ... } @blurb { ... } @tail { ... } ``` The two `%` lines are the only comments in the file and appear only here. The four preamble blocks are always present and always in that order. The nine section blocks appear in that order. **A section is omitted entirely when the document has no objects for it**, though in practice that is rare: all 36 documents of the reference collection carry all nine, several of them holding a single generated object. ## 5. The preamble blocks Inside a block, every line is ` key: value` with exactly two spaces of indent. Keys are unique within a block. **A key whose value is empty is omitted**, so the set of keys present varies by document; the exceptions are noted below. ### 5.1 `@source` - what this abstraction was made from | key | always? | meaning | |-------------|----------------------------|-----------------------------------------------------------------------------| | `language` | yes | the language of *this* file | | `languages` | when the pod declares them | every language of the document, space separated | | `digest` | yes | sha256 over **every markup file the document is made of**, in a fixed order | The source *filename* is not repeated here; it is on the `% Source:` line. `digest` is what changed in 2.0. It had been the digest of the master file alone, which for a single file document was right and for a multi-file one was close to meaningless: any chapter could be edited without the digest moving. ### 5.2 `@meta` - the document's own metadata Dublin-Core shaped, `group.name`. **43 keys are defined**; a given document carries only those it has. The 28 the reference collection exercises are marked; the remainder are defined and simply unused by these documents. | group | keys | |---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `title.` | `main`*, `subtitle`*, `full`*, `language`*, `edition`* | | `creator.` | `author`*, `author_surname`*, `author_surname_fn`*, `author_email`*, `illustrator`*, `translator`* | | `date.` | `published`*, `created`*, `issued`*, `available`*, `modified`*, `valid`*, `added_to_site`* | | `rights.` | `copyright`*, `license`*, `copyright_text`, `copyright_translation`, `copyright_illustrations`, `copyright_photographs`, `copyright_cover`, `copyright_audio`, `copyright_video` | | `classify.` | `topic_register`*, `subject`, `keywords`, `loc`*, `dewey`* | | `identifier.` | `isbn`, `oclc` | | `notes.` | `summary`*, `abstract`*, `description`* | | `original.` | `source`*, `title`, `language`, `language_char` | | `language.` | `document_char`*, `document` | `classify.topic_register` is structured within its value: topics separated by `;`, levels within a topic by `:`, and alternatives at a level by `|`. ### 5.3 `@make` - how the document is to be built | key | value | meaning | |-------------------------|--------------------------|--------------------------------------------------------------------------------------------------------| | `doc_type` | `article`, `book` | what kind of document this is | | `auto_num_top_at_level` | a level, e.g. `1` | the heading level automatic numbering starts at, **as written in the markup** | | `auto_num_top_lv` | that level's index, 0..8 | the same level as a number (section 4 of [`ocda-model.md`](ocda-model.md)); `9` where numbering is off | | `auto_num_depth` | e.g. `2` | how many levels down numbering continues | | `breaks` | see below | where the output starts a new page, and where it breaks one | | `footer` | slots joined with `\|` | the footer, each slot carrying link markup | | `home_button_text` | link markup | the home link, as internal markup | `auto_num_top_at_level` and `auto_num_top_lv` are **the same value twice**, as the markup wrote it and as an index: `1` and `4`, since the body levels begin at index 4. `breaks` is a small language of its own, `new=` for a new page and `break=` for a page break, each taking a comma separated list of levels, the two separated by `;`: ``` breaks: new=:A,:B; break=:C,1 breaks: new=:B; break=1 breaks: break=1 ``` The level names here are written as they are in the markup, so with or without the leading colon as the document wrote them; a reader should not assume either form. ### 5.4 `@doc_has` - what the document contains, by count Ten keys, **all ten always emitted**, zero included. This block is a summary a reader can use without walking the objects. ``` inline_links inline_notes_reg inline_notes_star tables codeblocks images poems groups blocks quotes ``` ## 6. Objects The nine section blocks hold object records, in document order. An object record is an object declaration line, then its properties, then its text lines, then a blank line. ### 6.1 The declaration line ``` [] [] heading : [] heading : ``` `` is the **object citation number** (see [`ocda-model.md`](ocda-model.md) section 3). `[0]` means the object has none, is shared by many objects, and must never be used as a key; key on position within a section instead. `` is one of sixteen: ``` para heading toc bookindex endnote code bibliography comment verse glossary quote poem block table blurb group ``` A **heading** is the one kind whose declaration line carries more: its markup level after a colon (`:A` `:B` `:C` `:D` for the title levels, `:1`..`:4` for the body levels; `:D` is defined and unexercised by the reference collection), and then its identifier, when it has one that is not simply the ocn. Every other kind carries an identifier, on the same condition, as the `.identifier` property. > **A reader must derive the identifier where it is absent, and the anchor > likewise.** "when it has one that is not simply the ocn" means the > identifier *is* the ocn in every other case, and a reader that leaves the > field empty gives a different model from the one the `.ocda.db` gives, on > nearly every object. Section 9 of [`ocda-model.md`](ocda-model.md) states > both derivations and why they belong to the model rather than to either > format. Two readers written independently from these documents disagreed > for want of it. ### 6.2 Text lines ``` | ``` One line per line of the object's text, in order, each prefixed with `| ` (pipe, space). An object with no text has no text lines. The text is internal markup (section 3.2) and is not escaped. ### 6.3 Properties **Properties appear in a fixed order**, the order of the table below, and a reader may rely on it: checked over the reference set, no object among 56,882 emits a property out of this order. **A property is omitted when it holds its default**, so absence is meaningful and is defined per property in the table. Four properties repeat, appearing once per value rather than carrying a list: `.image`, `.stow_link`, `.lev4_subtoc` and `.anchor_tag`. Two consequences of the order, which a validator needs stated and which hold over the whole reference collection: - **a repeated property's occurrences are consecutive.** They share one position in the order, and nothing is written between them. Checked: no repeat in the collection is separated by another property. - **no property follows the text.** The record is declaration, then properties, then text lines, and once a `|` line has been written no further property appears. Checked: 0 occurrences in the collection. In the table, "emitted when" is the condition under which the property appears at all. Counts are occurrences across the 36 document reference set, as a guide to which parts of the format are load bearing. | # | property | value | emitted when | count | |----|---------------------------|-------------------------------|----------------------------------------------------------------------------------------------------|--------| | 1 | `.identifier` | string | a non-heading has an identifier that is not its ocn (**otherwise it is the ocn**: model section 9) | 353 | | 2 | `.part` | string | the object belongs to a part (`frontmatter`, `body`, ...) | 57,018 | | 3 | `.section` | string | the object's own section differs from the block it sits in | 605 | | 4 | `.parent` | int | **every object except** the document root and `toc` entries | 53,767 | | 5 | `.last_descendant` | int | non-zero: the last ocn under this heading | 3,202 | | 6 | `.ocn_range` | 2 ints | the object is a container: the first and last ocn of what it holds (2.1; a poem, model section 5) | 48 | | 7 | `.children` | ints | the heading has child headings | 827 | | 8 | `.ancestors` | 8 ints | any is non-zero | 53,731 | | 9 | `.ancestors_collapsed` | 8 ints | any is non-zero | 53,731 | | 10 | `.dom_status` | 8 ints | any is non-zero | 3,319 | | 11 | `.dom_status_collapsed` | 8 ints | any is non-zero | 3,319 | | 12 | `.heading_lev_collapsed` | int | it is below 9 | 3,503 | | 13 | `.parent_lev` | int | non-zero | 52,984 | | 14 | `.dummy` | `true` | the heading was introduced to segment an output | 183 | | 15 | `.ocn_off` | `true` | the object has no citation number | 7,543 | | 16 | `.is_of_type` | string | always, in practice | 57,018 | | 17 | `.attrib` | string | set | 1 | | 18 | `.meta_lang` | string | the object carries its own language | 0 | | 19 | `.meta_syntax` | string | the object carries its own markup syntax | 0 | | 20 | `.sha256` | hex | the object's text digest is non-zero | 51,253 | | 21 | `.image` | record | once **per image**, in order of appearance | 63 | | 22 | `.indent` | 2 ints | either indent is non-zero: `base hang` | 7,583 | | 23 | `.bullet` | `true` | the object is a bullet item | 1,903 | | 24 | `.lang` | string | the text attributes carry a language | 0 | | 25 | `.has` | flags | any is set | 11,384 | | 26 | `.table_cols` | int | the object is a table with columns | 32 | | 27 | `.table_widths` | ints | the table has column widths | 32 | | 28 | `.table_aligns` | letters | the table has alignments (`l` `c` `r`) | 32 | | 29 | `.table_header` | `true` | the table has a header row | 29 | | 30 | `.code_linenumbers` | `true` | the code block is numbered | 1 | | 31 | `.stow_link` | url | once **per extracted link** | 1,014 | | 32 | `.segment` | string | the heading opens a segment | 3,355 | | 33 | `.anchor` | string | the anchor differs from the segment name (**otherwise it is the segment name**: model section 9) | 68 | | 34 | `.segment_prev` | string | there is a previous segment | 1,022 | | 35 | `.segment_next` | string | there is a next segment | 1,022 | | 36 | `.heading_lev_anchor` | string | the heading has a level anchor tag | 1,854 | | 37 | `.segment_epub` | string | the heading opens an epub segment | 3,355 | | 38 | `.segment_html_is` | string | the object is inside an html segment | 47,072 | | 39 | `.segment_epub_is` | string | the object is inside an epub segment | 47,072 | | 40 | `.segment_lv4_is` | string | **and** it differs from `.segment_html_is` | 342 | | 41 | `.heading_ancestors_text` | 8 slots, `\|` joined, escaped | any slot is non-empty | 3,319 | | 42 | `.lev4_subtoc` | string | once **per sub-table-of-contents entry** | 1,887 | | 43 | `.anchor_tag` | string | once **per anchor tag** | 8,019 | Three of these need a word here, the first two because the model behind them is easy to misread (see [`ocda-model.md`](ocda-model.md) sections 5 and 7), the third because it is a property of this table rather than of the format. **`.parent: 0` is emitted, not omitted.** A parent of 0 is a real, non-substantive parent and not a missing value, so the property is written out rather than defaulted away: omitting it would make the two cases indistinguishable in the file. A reader walking upward stops at 0. **`.segment` and `.segment_html_is` are different questions**, and both are carried: what a heading opens, and what an object sits in. A reader wanting to know where a paragraph belongs needs the second. **Count 0 does not mean "not in the format".** `.meta_lang`, `.meta_syntax` and `.lang` are emitted by spine under the conditions given, and no document in the reference collection meets them. A reader must handle them; a test corpus does not exercise them. ### 6.4 The `.image` record ``` .image: sha256: bytes: px:x .image: missing:true ``` Filename first, as the object's handle on the image. The remaining fields are self describing `key:value` tokens, **so that further fields may be added without invalidating existing readers**; `px:` is omitted when the pixel size is unknown. `px:` is the file's own size, not the display size, which the object's text already carries. ### 6.5 The `.has` flags Space separated, in this order, each present only when set: ``` links notes_reg notes_star images images_no_dim ``` ## 7. Grammar **This grammar is complete for the file shape and deliberately incomplete for one thing: the order of properties.** A grammar that fixed the order would have to enumerate 42 optional terms in sequence, would be unreadable, and would need editing at every minor version, which is exactly when a property is added. The order is a guarantee of the format (section 6.3) and is stated there, where it can be read; a parser that wants to check it can do so against the table. So: **a file that this grammar accepts and section 6.3 rejects is a malformed file, not an ambiguity in the format.** The grammar is the shape; the table is the contract. **Checked**: every line of the 36 document reference collection matches one of the eight line shapes below, 721,363 lines with none left over. ```peg Document <- Header Source Meta Make DocHas Section* EOF Header <- "% SiSU Document Abstraction v" Version EOL "% Source: " Value EOL Blank Version <- Digit+ "." Digit+ Source <- "@source {" EOL Pair+ "}" EOL Blank Meta <- "@meta {" EOL Pair* "}" EOL Blank Make <- "@make {" EOL Pair* "}" EOL Blank DocHas <- "@doc_has {" EOL Pair+ "}" EOL Blank Pair <- " " Key ": " Value EOL Key <- [a-z_]+ ("." [a-z_]+)? Section <- "@" SectionName " {" EOL Blank Object* "}" EOL Blank SectionName <- "head" / "toc" / "body" / "endnotes" / "glossary" / "bibliography" / "bookindex" / "blurb" / "tail" Object <- Decl Property* TextLine* Blank Decl <- "[" Digit+ "] " (Heading / Kind) EOL Heading <- "heading :" Level (" " Identifier)? Level <- [A-D] / [1-4] Kind <- [a-z]+ Property <- "." Name ": " Value EOL Name <- [a-z_0-9]+ TextLine <- "| " Value EOL # a repeatable property appears once per value rather than carrying a list: # .image .stow_link .lev4_subtoc .anchor_tag # and .image has an inner shape of its own: Image <- ".image: " FileName (" " Field)* EOL Field <- Key ":" Value FileName <- (!" " !EOL .)+ Value <- (!EOL .)* Blank <- EOL EOL <- "\n" Digit <- [0-9] ``` ## 8. Conformance ### 8.1 A reader must - **Check the major version** on the first line and refuse a major it does not know. Loading an unknown major half populated, in silence, is the failure this rule exists to prevent. - **Tolerate unknown properties** within a known major version, since the minor part is raised precisely by adding them. Ignoring them is conforming behaviour. - **Treat `[0]` as not an identity.** Objects with no citation number are numerous and share the number. - **Stop at `.parent: 0`** when walking upward. ### 8.2 A reader should - **Report what it ignored**, at least on request. A reader that silently drops what it does not understand cannot tell its user whether it understood the document, and cannot be used to check this specification against an implementation. ### 8.3 A writer must - Emit the blocks and sections in the order of section 4, an object's properties in the order of section 6.3, and objects in document order. - Omit a property holding its default, per section 6.3. - Escape only what section 3.1 requires, and only where it requires it. ## 9. Relationship to the model, and to the sqlite serialisation The model this format writes down is specified in [`ocda-model.md`](ocda-model.md): objects, citation numbers, structure, sections, segments and digests. This document adds nothing to the model and subtracts nothing from it; it says how the model is written as text. The `.ocda.db` is the same abstraction as sqlite, and is **built by reading a `.ssp` back**: the document is emitted as `.ssp`, read straight in, and what comes back is written. So the database cannot carry an object property this format cannot express, and the two cannot drift. They share the version, which is why a bump moves both. The database is not a competitor to this format. It carries every language of a document in one file, and the markup, images and configuration as well, which this format does not. ## 10. Worked examples - `example-autonomous-contract.ssp` - one document, complete and unedited. - `example-wealth-of-networks.ssp` - an excerpt of a large one: verbatim lines with marked elisions, keeping the preamble, the `@head` section, and a run of body objects including one that embeds an image. Each carries, in its opening comments, the command that regenerates it.