SpecCompiler Core Design

1 Scope

This document describes the software architecture and design of SpecCompiler Core.

2 Pipeline Architecture

2.1 Overview

SpecCompiler uses a layered architecture with the engine orchestrating a five-phase Pipeline that processes documents through registered Handler.

2.2 Component Summary

The architecture comprises 30 CSCs organized in four source layers and two model packages. For the complete decomposition with all 162 CSUs, see the Software Decomposition chapter.

Layer CSC CSUs Responsibility
Core Runtime CSC-001 Core Runtime CSU-001 Pandoc Filter Entry Point, CSU-002 Configuration Parser, CSU-003 Data Loader, CSU-004 Diagnostics Collector, CSU-005 Build Engine, CSU-006 Pipeline Orchestrator, CSU-007 Proof Loader, CSU-008 Type Loader, CSU-009 Validation Policy Pipeline orchestration, metadata/config extraction, model loading, proof loading, validation policy, and runtime control.
Database Persistence CSC-002 Database Persistence CSU-010 Build Cache, CSU-011 Database Handler, CSU-012 Data Manager, CSU-013 Output Cache, CSU-014 Proof View Definitions Canonical insert/query API for SpecIR, transaction handling, build cache, output cache, and proof view definitions.
CSC-005 DB Queries CSU-015 Build Queries, CSU-016 Content Queries, CSU-017 Query Aggregator, CSU-018 Resolution Queries, CSU-019 Search Queries, CSU-020 Type Queries SQL query string modules for all database operations across content, types, build, search, and resolution domains.
CSC-006 DB Schema CSU-021 Build Schema, CSU-022 Content Schema, CSU-023 Schema Aggregator, CSU-024 Search Schema, CSU-025 Type System Schema DDL table creation statements for content, types, build infrastructure, and search tables.
CSC-007 DB Views CSU-026 EAV Pivot Views, CSU-027 Views Aggregator, CSU-028 Public API Views, CSU-029 Resolution Views SQL view definitions for EAV pivots, public API, and resolution helpers.
Pipeline Handlers CSC-003 Pipeline Handlers CSU-030 Include Expansion Filter, CSU-031 Verify Handler Phase handlers implementing initialize, analyze, transform, verify, and emit behavior across five pipeline phases.
CSC-008 Analyze Handlers CSU-032 Attribute Caster, CSU-033 Relation Resolver, CSU-161 Relation Type Inferrer ANALYZE phase handlers for relation resolution, relation type inference, and attribute casting.
CSC-009 Emit Handlers CSU-034 Document Assembler, CSU-035 Float Emitter, CSU-036 View Emitter, CSU-037 Emitter Orchestrator, CSU-038 Float Handler Dispatcher, CSU-039 Float Numbering, CSU-040 Float Resolver, CSU-041 FTS Indexer, CSU-042 Inline Handler Dispatcher, CSU-043 View Handler Dispatcher EMIT phase handlers for document assembly, float resolution, view rendering, FTS indexing, and output generation.
CSC-010 Initialize Handlers CSU-044 Attribute Parser, CSU-046 Float Parser, CSU-047 Object Parser, CSU-048 Relation Parser, CSU-049 View Parser, CSU-050 Specification Parser INITIALIZE phase handlers that parse document AST and populate all SpecIR container tables.
CSC-011 Shared Pipeline Utilities CSU-045 Include Handler, CSU-051 Attribute Paragraph Utilities, CSU-052 Float Base, CSU-053 Include Utilities, CSU-054 Math Render Utilities, CSU-055 Render Utilities, CSU-056 Source Position Compatibility, CSU-057 Specification Base, CSU-058 Spec Object Base, CSU-059 View Utilities Shared infrastructure modules providing base handlers, rendering utilities, and view helpers used across pipeline phases.
CSC-012 Transform Handlers CSU-060 External Render Handler, CSU-061 Float Transformer, CSU-062 Object Render Handler, CSU-063 Specification Render Handler, CSU-064 View Materializer, CSU-162 Relation Link Rewriter TRANSFORM phase handlers for view materialization, external rendering, and spec object/specification rendering.
Infrastructure CSC-004 Infrastructure CSU-065 Hash Utilities, CSU-066 JSON Utilities, CSU-067 Logger, CSU-068 Reference Cache, CSU-069 MathML to OMML Converter Output toolchain integration, hashing, logging, JSON utilities, reference cache management, and external tool wrappers.
CSC-013 Format Utilities CSU-070 Format Writer, CSU-071 XML Utilities, CSU-072 ZIP Utilities Writer adapters, XML utilities, and ZIP archive operations for format-specific output generation.
CSC-014 DOCX Generation CSU-073 OOXML Builder, CSU-074 Preset Loader, CSU-075 Reference Generator, CSU-076 Style Builder OOXML builder, preset loader, reference generator, and style builder for Word document output.
CSC-015 I/O Utilities CSU-077 Document Walker, CSU-078 File Walker AST traversal with source position tracking and basic file I/O operations.
CSC-016 Process Management CSU-079 Pandoc CLI Builder, CSU-080 Task Runner External process spawning via luv and Pandoc command-line argument building.
Default Model CSC-017 Default Model CSU-081 SECTION Object Type, CSU-082 SPEC Specification Type Foundational type model providing base object, float, relation, and view types that all other models extend.
CSC-018 Default Filters CSU-083 DOCX Filter, CSU-084 HTML Filter, CSU-085 Markdown Filter Format-specific Pandoc Lua filters that convert speccompiler markers to native output elements.
CSC-019 Default Postprocessors CSU-086 DOCX Postprocessor, CSU-087 LaTeX Postprocessor Format-specific post-processing applied after Pandoc output generation.
CSC-020 Default Proof Views CSU-089 Spec Missing Required, CSU-090 Spec Invalid Type, CSU-091 Object Missing Required, CSU-092 Object Cardinality Over, CSU-093 Object Cast Failures, CSU-094 Object Invalid Enum, CSU-095 Object Invalid Date, CSU-096 Object Bounds Violation, CSU-097 Float Orphan, CSU-098 Float Duplicate Label, CSU-099 Float Render Failure, CSU-100 Float Invalid Type, CSU-101 Relation Unresolved, CSU-102 Relation Dangling, CSU-103 Relation Ambiguous, CSU-104 View Materialization Failure SQL proof view queries for detecting constraint violations across specifications, objects, floats, relations, and views.
CSC-021 Default Styles CSU-106 DOCX Style Preset, CSU-107 HTML Style Preset Style presets defining page layout, typography, and formatting for DOCX and HTML output.
CSC-022 Default Float Types CSU-108 CHART Float Type, CSU-109 FIGURE Float Type, CSU-110 LISTING Float Type, CSU-111 MATH Float Type, CSU-112 PLANTUML Float Type, CSU-113 TABLE Float Type Float type definitions for numbered content blocks including images, tables, code listings, diagrams, charts, and equations.
CSC-023 Default Relation Types CSU-114 XREF_CITATION Relation Type, CSU-115 XREF_FIGURE Relation Type, CSU-116 XREF_LISTING Relation Type, CSU-117 XREF_MATH Relation Type, CSU-118 XREF_TABLE Relation Type Cross-reference relation type definitions mapping link selectors to target float types.
CSC-024 Default View Types CSU-119 ABBREV View Type, CSU-120 ABBREV_LIST View Type, CSU-121 GAUSS View Type, CSU-122 LOF View Type, CSU-123 MATH_INLINE View Type, CSU-124 TOC View Type View type definitions for inline and block-level data-driven content rendering.
SW Docs Model CSC-025 SW Docs Model CSU-125 HTML5 Postprocessor Domain model for software documentation providing traceable object types, domain-specific proof views, specification types, relation types, and views.
CSC-026 SW Docs Proof Views CSU-126 VC Missing HLR Traceability, CSU-127 TR Missing VC Traceability, CSU-128 HLR Missing VC Coverage, CSU-131 FD Missing CSC Traceability, CSU-132 FD Missing CSU Traceability, CSU-163 CSC Missing FD Allocation, CSU-164 CSU Missing FD Allocation Domain-specific proof view queries for software documentation traceability and naming convention enforcement.
CSC-027 SW Docs Object Types CSU-133 CSC Object Type, CSU-134 CSU Object Type, CSU-135 DD Object Type, CSU-136 DIC Object Type, CSU-137 FD Object Type, CSU-138 HLR Object Type, CSU-139 LLR Object Type, CSU-140 NFR Object Type, CSU-141 SF Object Type, CSU-142 SYMBOL Object Type, CSU-143 TR Object Type, CSU-144 TRACEABLE Base Object Type, CSU-145 VC Object Type Domain object type definitions for traceable specification items including requirements, design decisions, verification cases, and MIL-STD-498 architectural elements.
CSC-028 SW Docs Relation Types CSU-146 BELONGS Relation Type, CSU-147 REALIZES Relation Type, CSU-148 TRACES_TO Relation Type, CSU-149 XREF_DIC Relation Type Domain relation type definitions for traceability links between software documentation elements.
CSC-029 SW Docs Specification Types CSU-150 SDD Specification Type, CSU-151 SRS Specification Type, CSU-152 SUM Specification Type, CSU-153 SVC Specification Type, CSU-154 TRR Specification Type Specification type definitions for SDN document types (SRS, SDD, SVC, SUM, TRR).
CSC-030 SW Docs View Types CSU-155 Coverage Summary View, CSU-156 Requirements Summary View, CSU-157 Test Execution Matrix View, CSU-158 Test Results Matrix View, CSU-159 Traceability Matrix View Domain view type definitions for traceability matrices, test results, and coverage summaries.

3 Type System Architecture

3.1 Overview

SpecCompiler uses a dynamic type system where models define available types for objects, Float, relations, and views.

Figure Type System Architecture (COMP-002)

3.2 Type Module Structure

Each type module exports a category-specific definition:

-- Example: models/default/types/objects/hlr.lua
local M = {}

M.object = {
    id = "HLR",
    long_name = "High-Level Requirement",
    description = "System-level requirement",
    extends = "TEXTUAL",
    attributes = {
        { name = "status", datatype = "STATUS_ENUM", min_occurs = 1 },
        { name = "rationale", datatype = "STRING" }
    }
}

-- Optional handler for custom rendering
M.handler = {
    name = "hlr_render",
    prerequisites = { "spec_objects" },
    on_transform = function(data, ctx, diag) ... end
}

return M

3.3 Type Categories

Category Database Table Key Fields
Specifications spec_specification_types id, long_name, extends, is_default
Objects spec_object_types id, long_name, extends, is_default (HLR, FD, CSC, CSU, VC, etc.)
Floats spec_float_types id, long_name, counter_group, needs_external_render
Relations spec_relation_types id, source_type_ref, target_type_ref, link_selector
Views spec_view_types id, materializer_type, counter_group

3.4 Loading Process

  1. Type Loader scans models/{model}/types/{category}/
  2. Each .lua file is loaded and checked for exports
  3. Type definitions registered in corresponding DB tables
  4. Handlers registered with pipeline if present

4 SpecIR Database Schema

4.1 Overview

The Specification Intermediate Representation (SpecIR) is implemented as a SQLite Database schema composed from:

The schema has four domains:

Table Schema domains
Domain Tables
Type system spec_specification_types, spec_object_types, spec_float_types, spec_relation_types, spec_view_types, datatype_definitions, spec_attribute_types, enum_values
Content specifications, spec_objects, spec_floats, spec_relations, spec_views, spec_attribute_values
Build cache build_graph, source_files, output_cache
Search (FTS5) fts_objects, fts_attributes, fts_floats

4.2 Type + Content (SpecIR)

SpecIR is a ReqIF inspired relational metamodel that lowers textual specifications into a typed intermediate representation against which structural validity is evaluated.

Where Pandoc provides the syntactic bridge from Markdown to a structured AST, SpecIR provides the semantic layer by separating: a type layer (Γ), which defines what may exist and a content layer, which records what does exist.

Validation reduces to relational set operations: constraints are expressed as queries over finite sets of entities and relations, and violations emerge as counterexamples (e.g., anti-joins between expected and actual structures).

5 Pipeline Design

FD-001: Pipeline Execution Orchestration

Allocation: Realized by CSC Core Runtime (Core Runtime) through CSU Build Engine (Build Engine) and CSU Pipeline Orchestrator (Pipeline Orchestrator), with handlers registered via CSC Pipeline Handlers (Pipeline Handlers). Phase-specific handlers are organized in CSC Analyze Handlers (Analyze Handlers), CSC Initialize Handlers (Initialize Handlers), and CSC-012 (Transform Handlers), with shared utilities in CSC Shared Pipeline Utilities (Shared Pipeline Utilities).

The Pipeline execution orchestration function manages the five-phase document processing lifecycle from initial Pandoc hook entry through final output generation. It encompasses Handler registration, dependency-based execution ordering, context propagation, and phase abort logic.

Entry Point: The Pandoc filter (CSU Build Engine) hooks into the Pandoc Meta callback, extracts project metadata via CSU-009, and invokes the build engine. The engine creates the database, initializes the data manager, loads the model via CSU-008, processes document files (with Build Cache checks), and delegates to the pipeline orchestrator.

Handler Registration: During model loading, CSU-008 registers each handler with the Pipeline Orchestrator CSU Pipeline Orchestrator, which enforces the registration contract by validating that every handler declares both a name and a [TERM-24](@) field before accepting registration. The orchestrator rejects duplicate handler names — attempting to register a handler whose name already exists raises an immediate error. Accepted handlers are stored in a lookup table keyed by name for O(1) retrieval during phase execution. Each handler implements phase hooks using the naming convention on_{phase} (e.g., on_initialize, on_analyze, on_transform, on_verify, on_emit). All hooks receive the full contexts array: on_{phase}(data, contexts, diagnostics).

Topological Sort: Before executing each phase, the Pipeline Orchestrator CSU Pipeline Orchestrator applies Kahn’s algorithm to produce a deterministic handler execution order. Only handlers that implement an on_{phase} hook for the current phase participate in the sort; handlers without a relevant hook are skipped entirely. The algorithm begins by building a dependency graph restricted to participants and initializing an in-degree count for each node. Nodes with zero in-degree — handlers whose prerequisites are already satisfied — seed a processing queue. At each step the algorithm dequeues the first node, appends it to the sorted output, and decrements the in-degree of all its dependents; any dependent whose in-degree reaches zero is enqueued. Alphabetical tie-breaking is applied at every dequeue step so that handlers at the same dependency depth are always emitted in the same order, guaranteeing deterministic output across runs. After the queue is exhausted, if the sorted list length is less than the participant count a dependency cycle exists and is reported as an error.

For example, if INITIALIZE has three handlers — specifications (no prerequisites), spec_objects (prerequisite: specifications), and spec_floats (prerequisite: specifications) — the sort produces [specifications, spec_floats, spec_objects], with spec_floats and spec_objects ordered alphabetically since both depend only on specifications.

Phase Execution: The pipeline executes five phases in order:

  1. INITIALIZE Phase — Parse Pandoc Abstract Syntax Tree into Intermediate Representation database tables (specifications, spec_objects, attributes, spec_floats, spec_views, spec_relations)
  2. ANALYZE Phase — Resolve cross-references and infer relation types
  3. TRANSFORM Phase — Render content, materialize views, execute external renderers
  4. VERIFY Phase — Run proof views and collect diagnostics
  5. EMIT Phase — Assemble documents and generate output files

All phases use the same dispatch model: for each handler in sorted order, the Pipeline Orchestrator CSU Pipeline Orchestrator calls the handler’s on_{phase}(data, contexts, diagnostics) hook once with the full set of contexts. Handlers are responsible for iterating over contexts internally. Each handler invocation is bracketed by uv.hrtime() calls at nanosecond precision to record its duration, and the orchestrator also records the aggregate duration of each phase, providing two-level performance visibility (handler-level and phase-level).

Phase Abort: After VERIFY, the Pipeline Orchestrator CSU Pipeline Orchestrator inspects the diagnostics collector for any error-level entries. If errors exist, the pipeline aborts before EMIT — only output generation is skipped, since TRANSFORM has already completed. This design allows proof views to validate transform results before committing to output.

Context Propagation: Each document file produces a context containing the parsed AST, file path, specification ID, and walker state. Contexts are passed through all phases, accumulating state. The diagnostics collector aggregates errors and warnings across all handlers and contexts.

Component Interaction

The pipeline is realized through the core runtime and four handler packages that correspond to pipeline phases.

CSC Core Runtime (Core Runtime) provides the entry point and orchestration layer. CSU Pandoc Filter Entry Point (Pandoc Filter Entry Point) hooks into the Pandoc callback to launch the build. CSU Configuration Parser (Configuration Parser) reads project.yaml and resolves model, output, and logging settings. CSU Data Loader (Data Loader) loads external data files referenced by specifications. CSU Build Engine (Build Engine) coordinates the full build lifecycle — creating the database, loading the model, processing document files with cache checks, and delegating to CSU Pipeline Orchestrator (Pipeline Orchestrator) for phase execution. The orchestrator drives topological sort, handler dispatch, timing, and abort logic across all five phases.

CSC Pipeline Handlers (Pipeline Handlers) registers cross-cutting handlers. CSU Include Expansion Filter (Include Expansion Filter) resolves include directives during INITIALIZE, expanding referenced files into the document AST before entity parsing begins.

CSC Initialize Handlers (Initialize Handlers) parses the Pandoc AST into SpecIR entities. CSU Specification Parser (Specification Parser) extracts document-level metadata, CSU Object Parser (Object Parser) identifies typed content blocks, CSU Attribute Parser (Attribute Parser) extracts key-value attributes from object paragraphs, CSU Float Parser (Float Parser) detects embedded figures, tables, and listings, CSU Relation Parser (Relation Parser) captures cross-reference links, and CSU View Parser (View Parser) identifies view directives.

CSC Analyze Handlers (Analyze Handlers) resolves cross-references and infers types. CSU Relation Resolver (Relation Resolver) matches link targets to spec objects using selector-based resolution. CSU Relation Type Inferrer (Relation Type Inferrer) assigns relation type_refs based on source and target object types. CSU Attribute Caster (Attribute Caster) validates and casts attribute values against their declared datatypes.

CSC Shared Pipeline Utilities (Shared Pipeline Utilities) provides reusable base modules consumed by handlers across phases. CSU Spec Object Base (Spec Object Base) and CSU Specification Base (Specification Base) provide shared parsing logic for objects and specifications. CSU Float Base (Float Base) provides float detection and extraction. CSU Attribute Paragraph Utilities (Attribute Paragraph Utilities) parses attribute blocks from definition-list paragraphs. CSU Include Handler (Include Handler) and CSU Include Utilities (Include Utilities) manage file inclusion and path resolution. CSU Render Utilities (Render Utilities) and CSU Math Render Utilities (Math Render Utilities) provide AST-to-output conversion helpers. CSU View Utilities (View Utilities) supports view parsing and materialization. CSU Source Position Compatibility (Source Position Compatibility) normalizes Pandoc source position data across API versions.

Figure Pipeline Execution Orchestration


TRACEABILITY:
SF-001

DD-CORE-001: SQLite as SpecIR Persistence Engine

Selected SQLite as the persistence engine for the Specification Intermediate Representation.


RATIONALE:

SQLite provides:

  • Zero-configuration embedded database requiring no server process
  • Single-file database portable across platforms (specir.db)
  • SQL-based query interface enabling declarative proof views and resolution logic
  • ACID transactions for reliable incremental builds with cache coherency
  • Built-in FTS5 for full-text search in the web application output
  • Mature Lua binding (lsqlite3) available in the Pandoc ecosystem

DD-CORE-002: EAV Attribute Storage Model

Selected Entity-Attribute-Value storage for dynamic object and float attributes.


RATIONALE:

The EAV model enables runtime schema extension through model definitions:

  • Object types declare custom attributes in Lua modules without DDL changes
  • New models can add attributes by declaring them in type definitions
  • Typed columns provide SQL-level type safety while preserving EAV flexibility
  • Per-type pivot views (view_{type}_objects) generated dynamically from spec_attribute_types restore columnar access for queries
  • Alternative of wide tables rejected: column set unknown at schema creation time since models load after initialization

DD-CORE-003: Five-Phase Pipeline Architecture

Selected a five-phase sequential pipeline (INITIALIZE, ANALYZE, TRANSFORM, VERIFY, EMIT) for document processing.


RATIONALE:

Five phases separate concerns and enable verification before output:

  • INITIALIZE parses AST into normalized relational IR before any resolution
  • ANALYZE resolves cross-references and infers types on the complete IR, not partial state
  • TRANSFORM renders content and materializes views with all references resolved
  • VERIFY runs proof views after TRANSFORM so it can check transform results (e.g., float render failures, view materialization)
  • EMIT generates output only after verification passes, preventing invalid documents
  • VERIFY-before-EMIT enables abort on error without wasting output generation time
  • Phase ordering is fixed; handler ordering within each phase is controlled by topological sort

DD-CORE-004: Topological Sort for Handler Ordering

Selected Kahn’s algorithm with declarative prerequisite arrays for handler execution ordering within each pipeline phase.

RATIONALE:

Declarative prerequisites with topological sort enable:

  • Handlers declare prerequisites = {"handler_a", "handler_b"} rather than manual sequence numbers
  • Only handlers implementing the current phase’s hook participate in the sort
  • Alphabetical tie-breaking at equal dependency depth guarantees deterministic execution across runs
  • Cycle detection with error reporting prevents invalid configurations
  • New handlers (including model-provided handlers) integrate by declaring their prerequisites without modifying existing handlers
  • Alternative of priority numbers rejected: fragile when inserting new handlers between existing priorities

6 Type Discovery Design

FD-002: Type Model Discovery and Registration

Allocation: Realized by CSC Core Runtime (Core Runtime) through CSU Type Loader (Type Loader). The foundational type definitions are provided by CSC Default Model (Default Model), which all domain models extend.

The type model discovery function loads model definitions from the filesystem and registers them with the Pipeline and data manager. It enables domain-specific extensibility by allowing models to define custom specification types, object types, float types, relation types, view types, and pipeline handlers.

Model Path Resolution: The Type Loader (CSU Type Loader) resolves the model directory by checking SPECCOMPILER_HOME/models/{model} first, then falling back to the project root. This two-stage resolution allows global model installation while supporting project-local overrides.

Directory Scanning: The loader scans models/{model}/types/ for category directories matching the five type categories:

Category Directory Export Field Database Table
Specifications specifications/ M.specification spec_specification_types
Objects objects/ M.object spec_object_types
Floats floats/ M.float spec_float_types
Relations relations/ M.relation spec_relation_types
Views views/ M.view spec_view_types

A typical model directory layout for the default model:

models/default/types/
├── specifications/
│   └── srs.lua        -- exports M.specification
├── objects/
│   ├── hlr.lua        -- exports M.object
│   └── section.lua    -- exports M.object
├── floats/
│   ├── figure.lua     -- exports M.float
│   └── plantuml.lua   -- exports M.float + M.handler
├── relations/
│   └── traces_to.lua  -- exports M.relation
└── views/
    └── toc.lua        -- exports M.view

Module Loading: Each .lua file in a category directory is loaded via require(). The loader inspects the module’s export fields to determine the type category and calls the appropriate registration method on the data manager. If a module exports M.handler, the handler is also registered with the pipeline for phase-specific processing.

Attribute Registration: Object and float types may declare attributes tables describing their data schema. The loader registers these with the data manager, creating datatype definitions and attribute constraints (name, datatype, min/max occurs, enum values, bounds) in the spec_attribute_defs and spec_datatype_defs tables.

Handler Registration: Type modules may export a M.handler table with phase hooks. These handlers extend the pipeline’s processing capabilities with type-specific logic (e.g., PlantUML float rendering, traceability matrix view materialization). Handlers declare Prerequisites to control execution ordering via Topological Sort.

Base Types: Relation type modules may export M.base instead of M.relation to act as base types that own resolution logic. Base types are not registered in the database. The type loader registers their M.resolve function into _selector_resolvers (keyed by M.base.link_selector), which the relation resolver dispatches to during the ANALYZE phase. Concrete relation types use M.extend(overrides) to inherit base properties (e.g., link_selector) while adding their own constraints. This follows the same delegation pattern as float type modules (src/pipeline/transform/spec_floats.lua).

Custom Display Text: Relation types that need custom link display text (e.g., showing title instead of PID) export a standard M.handler with on_transform using the shared link_rewrite_utils.rewrite_display_for_type() utility.

Component Interaction

The type discovery function is realized by the core type loader and the default model that provides foundational type definitions.

CSC Core Runtime (Core Runtime) provides CSU Type Loader (Type Loader), which drives the entire model discovery lifecycle — resolving model paths, scanning category directories, loading modules via require(), registering types and handlers with the data manager and pipeline, and propagating inherited attributes and relation properties.

CSC Default Model (Default Model) provides the two foundational types that every domain model inherits. CSU SECTION Object Type (SECTION Object Type) defines the implicit structural type for untitled content sections, enabling document structure representation without requiring explicit type declarations. CSU SPEC Specification Type (SPEC Specification Type) defines the base specification type with version, status, and date attributes that all domain-specific specification types extend.

Figure Type Model Discovery and Registration


TRACEABILITY:
SF-005

DD-CORE-006: Lua-Based Type System with Inheritance

Selected Lua modules with extends chains for type definitions.

RATIONALE:

Lua modules as type definitions enable:

  • Type definitions are executable code, supporting computed defaults and complex attribute constraints
  • extends field enables single-inheritance (e.g., HLR extends TRACEABLE) with automatic attribute propagation
  • Module exports (M.object, M.float, M.handler) co-locate type definition with optional handler registration
  • require() loading reuses Pandoc’s built-in Lua module system without additional dependency
  • Layered model loading (default first, then domain model) with ID-based override enables extension without forking the default model
  • Alternative of YAML/JSON config rejected: no computed defaults, no handler co-location

7 Storage Design

FD-003: SpecIR Persistence and Cache Coherency

Allocation: Realized by CSC Database Persistence (Database Persistence) through CSU Data Manager (Data Manager) and CSU Build Cache (Build Cache). The database schema is defined in CSC DB Schema (DB Schema), queries in CSC DB Queries (DB Queries), and materialized views in CSC DB Views (DB Views).

The Intermediate Representation persistence function manages the SQLite Database database that stores all parsed specification content and provides cache coherency for incremental builds. It encompasses schema management, the EAV Model storage model, build caching, and output caching.

SQLite Persistence: The data manager (CSU Data Manager) wraps all database operations, providing a query API over the SpecIR schema. The database file is created in the project’s output directory and persists across builds. Schema creation is executed inside DataManager.new(), establishing all content and type tables.

SpecIR Schema: The content schema (CSU Output Cache) defines the core entity tables:

The type schema (CSU Proof View Definitions) defines the metamodel tables that describe valid types, attribute definitions, and datatype constraints.

EAV Attribute Model: Attributes are stored as individual rows in spec_attribute_values rather than as columns, enabling dynamic schema extension through model definitions. Each attribute row references its parent entity (object or float), attribute definition, and stores the value as text with type casting at query time.

Build Cache: The build cache (CSU Build Cache) tracks document content hashes in the source_files table. Before parsing a document, the engine computes its SHA1 hash and compares against the stored value. Unchanged documents skip parsing entirely and reuse their cached SpecIR state. To support incremental builds, the build_graph table tracks include dependencies so that changes to included files also trigger rebuilds. When the document hash matches, the Build Engine (CSU-005) queries the build_graph table for all include dependencies recorded during the previous build. It then computes a SHA1 hash for each include file via the Hash Utilities (CSU-065). If an include file is missing, the hash returns nil, which forces a cache miss and a full document rebuild. The resulting path-to-hash map is compared against the stored values; any mismatch invalidates the cache and triggers reparsing of the root document.

Output Cache: The output cache tracks generated output files and their input hashes. Before generating an output file, the emitter checks whether the input hash matches the stored value. If current, the output generation is skipped. This provides incremental output generation independent of the build cache.

Component Interaction

The storage subsystem is realized through four packages that separate runtime operations from static definitions.

CSC Database Persistence (Database Persistence) provides the runtime database layer. CSU Database Handler (Database Handler) wraps raw SQLite operations and connection management with DELETE journal mode for single-file reliability. CSU Data Manager (Data Manager) builds on the handler to provide the high-level query API used by all pipeline phases — inserting spec entities during INITIALIZE, updating references during ANALYZE, and reading assembled content during EMIT. CSU Build Cache (Build Cache) queries source_files and build_graph to detect changed documents via SHA1 comparison. CSU Output Cache (Output Cache) tracks generated output files and their input hashes to skip redundant generation. CSU Proof View Definitions (Proof View Definitions) materializes SQL proof views at build time for the VERIFY phase.

CSC DB Schema (DB Schema) defines the database structure through composable modules. CSU Schema Aggregator (Schema Aggregator) is the entry point, composing: CSU Content Schema (Content Schema) for the core SpecIR tables, CSU Type System Schema (Type System Schema) for attribute and datatype definitions, CSU Build Schema (Build Schema) for source file and dependency tracking, and CSU Search Schema (Search Schema) for FTS5 virtual tables.

CSC DB Queries (DB Queries) mirrors the schema structure with composable query modules. CSU Query Aggregator (Query Aggregator) combines: CSU Content Queries (Content Queries) for spec entity CRUD, CSU Resolution Queries (Resolution Queries) for cross-reference and relation resolution, CSU Build Queries (Build Queries) for cache and dependency lookups, CSU Type Queries (Type Queries) for type definitions and attribute constraints, and CSU Search Queries (Search Queries) for FTS5 population and search.

CSC DB Views (DB Views) provides materialized SQL views over the SpecIR data. CSU Views Aggregator (Views Aggregator) composes: CSU EAV Pivot Views (EAV Pivot Views) for pivoting attribute values into typed columns, CSU Resolution Views (Resolution Views) for joining relations with resolved targets, and CSU Public API Views (Public API Views) for stable query interfaces used by pipeline handlers and external tools.

Figure SpecIR Persistence and Cache Coherency


TRACEABILITY:
SF-002

DD-CORE-007: Content-Addressed Build Caching

Selected SHA1 content hashing for incremental build detection.

RATIONALE:

Content-addressed hashing provides deterministic cache invalidation:

  • SHA1 of document content detects actual changes, ignoring timestamp-only modifications
  • Include dependency tracking via build_graph table ensures changes to included files trigger rebuilds
  • Missing include files force cache miss (hash returns nil), preventing stale IR state
  • Deferred cache updates (after successful pipeline execution) prevent stale entries on error
  • Output cache tracks generated files independently, enabling incremental output generation
  • Uses Pandoc’s built-in pandoc.sha1() when available, falling back to vendor/sha2.lua in standalone mode
  • Alternative of file timestamps rejected: unreliable across platforms (git checkout, copy, WSL2 clock skew)

DD-DB-002: Dynamic SQL View Generation for EAV Pivots

Selected runtime-generated CREATE VIEW statements per object type to pivot EAV attributes into typed columns.

RATIONALE:

Dynamic view generation bridges EAV flexibility with query usability:

  • Views generated after type loading, when attribute definitions are known
  • One view per non-composite object type (view_{type}_objects) with type-appropriate MAX(CASE) pivot expressions
  • Datatype-aware column selection (string_value for STRING, int_value for INTEGER, etc.)
  • External tools query familiar columnar views instead of raw EAV tables
  • Three-stage view initialization: resolution views first, public API views second, EAV pivots last
  • Alternative of application-layer pivoting rejected: pushes N+1 query patterns to every consumer

8 Output Design

FD-004: Multi-Format Publication

Allocation: Realized by CSC Transform Handlers (Transform Handlers) and CSC Emit Handlers (Emit Handlers) through CSU External Render Handler (External Render Handler) and CSU Emitter Orchestrator (Emitter Orchestrator). Output infrastructure is provided by CSC Infrastructure (Infrastructure), with format-specific utilities in CSC Format Utilities (Format Utilities), DOCX generation in CSC DOCX Generation (DOCX Generation), I/O operations in CSC I/O Utilities (I/O Utilities), and external process management in CSC Process Management (Process Management).

The multi-format publication function encompasses the TRANSFORM and EMIT pipeline phases, covering content rendering, view materialization, external subprocess rendering, document assembly from the Intermediate Representation database, Float numbering and resolution, and parallel output generation via Pandoc.

TRANSFORM Phase: Prepares content for output through four handler stages:

EMIT Phase: Assembles and generates output documents in multiple formats, fulfilling multi-format output requirements:

Infrastructure Support: The Pandoc CLI wrapper (CSU Pandoc CLI Builder) builds command arguments for multiple output formats (docx, html5, markdown, json) with reference document, bibliography, and filter support. The reference generator (CSU Reference Generator) creates reference.docx from style presets for DOCX output styling.

Component Interaction

The output subsystem spans the TRANSFORM and EMIT pipeline phases, realized through handler packages and infrastructure components.

CSC Transform Handlers (Transform Handlers) prepares content for output. CSU View Materializer (View Materializer) pre-computes view data as JSON. CSU Float Transformer (Float Transformer) resolves float content not requiring external tools. CSU External Render Handler (External Render Handler) coordinates parallel subprocess rendering via luv. CSU Object Render Handler (Object Render Handler) invokes type-specific header/body renderers. CSU Specification Render Handler (Specification Render Handler) renders document title headers. CSU Relation Link Rewriter (Relation Link Rewriter) rewrites (@) link targets to resolved anchors in the final AST.

CSC Emit Handlers (Emit Handlers) assembles and generates output documents. CSU FTS Indexer (FTS Indexer) populates full-text search tables. CSU Float Numbering (Float Numbering) assigns sequential numbers by counter group. CSU Document Assembler (Document Assembler) reconstructs complete Pandoc AST from SpecIR. CSU Float Resolver (Float Resolver) builds the rendered float lookup map. CSU Float Emitter (Float Emitter) replaces float placeholders with rendered Divs. CSU View Emitter (View Emitter) expands view placeholders with materialized content. CSU Inline Handler Dispatcher (Inline Handler Dispatcher) processes inline elements — links, citations, math. CSU Float Handler Dispatcher (Float Handler Dispatcher) routes float rendering to type-specific handlers. CSU View Handler Dispatcher (View Handler Dispatcher) routes view expansion to type-specific materializers. CSU Emitter Orchestrator (Emitter Orchestrator) coordinates the full emit sequence: numbering, assembly, resolution, filtering, and parallel Pandoc output.

CSC Infrastructure (Infrastructure) provides cross-cutting utilities. CSU Hash Utilities (Hash Utilities) computes SHA1 hashes for cache coherency. CSU Logger (Logger) implements NDJSON structured logging. CSU JSON Utilities (JSON Utilities) handles JSON serialization for AST interchange. CSU Reference Cache (Reference Cache) caches resolved cross-references for O(1) lookup during emit. CSU MathML to OMML Converter (MathML to OMML Converter) translates MathML equations to Office Math Markup for DOCX output.

CSC Format Utilities (Format Utilities) provides format-specific helpers. CSU Format Writer (Format Writer) serializes AST to intermediate JSON for Pandoc consumption. CSU XML Utilities (XML Utilities) generates and manipulates XML for OOXML postprocessing. CSU ZIP Utilities (ZIP Utilities) handles DOCX archive creation and modification.

CSC DOCX Generation (DOCX Generation) produces Word documents. CSU Preset Loader (Preset Loader) reads style preset definitions from Lua files. CSU Style Builder (Style Builder) generates OOXML style elements from preset values. CSU OOXML Builder (OOXML Builder) assembles the final DOCX package with styles, numbering, and content parts. CSU Reference Generator (Reference Generator) creates reference.docx for Pandoc’s --reference-doc option.

CSC I/O Utilities (I/O Utilities) provides file-system operations. CSU Document Walker (Document Walker) traverses specification documents and their includes to build processing contexts. CSU File Walker (File Walker) scans directories for files matching glob patterns during model discovery.

CSC Process Management (Process Management) manages external subprocesses. CSU Pandoc CLI Builder (Pandoc CLI Builder) constructs Pandoc command-line arguments for each output format. CSU Task Runner (Task Runner) provides the luv-based parallel task executor used by both external float rendering and batch Pandoc output generation.

Figure Transform and Emit Pipeline


TRACEABILITY:
SF-004

DD-INFRA-001: NDJSON Logging

Selected Newline-Delimited JSON format for structured logging.


RATIONALE:

NDJSON enables:

  • Machine-parseable log output for CI/CD integration
  • Structured data (level, message, timestamp, context)
  • Easy filtering and analysis with standard tools (jq)
  • Human-readable when formatted

Configuration via config.logging.level with env override SPECCOMPILER_LOG_LEVEL.

DD-INFRA-002: Parallel Task Execution

Selected luv (libuv) for parallel subprocess execution.


RATIONALE:

Document processing benefits from parallel execution:

  • External renderers (PlantUML, ECharts) run concurrently
  • Pandoc output generation runs in parallel for multiple formats
  • luv provides cross-platform async I/O without external dependencies

DD-INFRA-003: Preset-Based DOCX Styles

Selected preset system for DOCX style customization.


RATIONALE:

Corporate documents require consistent styling. The preset system:

  • Loads style definitions from Lua files
  • Generates reference.docx with custom styles
  • Caches generated reference based on preset hash
  • Enables style changes without modifying source documents

DD-TOOLS-001: Deno Runtime for External Tools

Selected Deno as the runtime for TypeScript-based external tools.


RATIONALE:

Deno provides:

  • Single-file TypeScript execution without build step
  • Built-in npm module support via npm: specifiers
  • Permission-based security model
  • Cross-platform compatibility

Tools are spawned via task_runner.spawn_sync() with timeout handling.

DD-CORE-005: Pandoc as Document Processing Engine

Selected Pandoc as the document parsing and output generation engine.

RATIONALE:

Pandoc serves as both input parser and output generator:

  • CommonMark+extensions parsing via pandoc.read() provides a well-defined AST
  • Lua filter API enables in-process AST manipulation without subprocess overhead for parsing
  • Multi-format output (DOCX, HTML5, Markdown, LaTeX/PDF, JSON) from a single intermediate representation
  • --reference-doc support enables DOCX style customization via generated reference.docx
  • --lua-filter support enables format-specific transformations (docx.lua, html.lua)
  • Native bibliography support (–bibliography, –csl) for citation processing
  • Broad ecosystem adoption provides stability and community support

9 Model Design

FD-005: Type System and Domain Model Definition

Allocation: Realized by CSC Default Filters (Default Filters), CSC Default Postprocessors (Default Postprocessors), CSC Default Styles (Default Styles), CSC Default Float Types (Default Float Types), CSC Default Relation Types (Default Relation Types), and CSC Default View Types (Default View Types).

The type system and domain model definition function encompasses the default model components that provide base type definitions, format-specific processing, and style configuration. These components are loaded by the Type Loader (CSU-008) during the model discovery phase described in FD-002 and collectively define the foundational capabilities that all domain models inherit and extend.

Model Directory Structure: Each model provides a standard directory layout with types/ (objects, floats, relations, views, specifications), filters/, postprocessors/, and styles/ subdirectories. The default model (models/default/) establishes baseline definitions for all five type categories.

Type Definitions: CSC Default Float Types defines float types (FIGURE, TABLE, LISTING, PLANTUML, CHART, MATH) with counter groups for shared numbering. CSC Default Relation Types defines cross-reference relation types (XREF_FIGURE, XREF_TABLE, XREF_LISTING, XREF_MATH, XREF_CITATION) that map # link selectors to target float types. CSC Default View Types defines view types (TOC, LOF, ABBREV, ABBREV_LIST, GAUSS, MATH_INLINE) with inline prefix syntax and materializer strategies.

Format Processing: CSC Default Filters provides Pandoc Lua filters for DOCX, HTML, and Markdown output that convert speccompiler-format markers (page breaks, bookmarks, captions, equations) into native output elements. CSC Default Postprocessors applies format-specific post-processing after Pandoc output generation, loading template-specific fixup modules for DOCX and LaTeX. CSC Default Styles defines style presets with page layout, typography, and formatting configuration for DOCX (Letter-sized, standard margins) and HTML (Inter/JetBrains Mono fonts, color palette) output.

Component Interaction

The default model is realized through six packages that define the baseline type system, format processing, and style configuration inherited by all domain models.

CSC Default Float Types (Default Float Types) defines the visual content types. CSU FIGURE Float Type (FIGURE) handles image-based floats. CSU TABLE Float Type (TABLE) handles tabular data with CSV parsing. CSU LISTING Float Type (LISTING) handles code blocks with syntax highlighting. CSU PLANTUML Float Type (PLANTUML) renders UML diagrams via external subprocess. CSU CHART Float Type (CHART) renders ECharts visualizations. CSU MATH Float Type (MATH) renders LaTeX equations via KaTeX. Each type declares a counter group for cross-specification numbering.

CSC Default Relation Types (Default Relation Types) defines cross-reference relations that resolve # link selectors to float targets. CSU XREF_FIGURE Relation Type (XREF_FIGURE) targets FIGURE floats. CSU XREF_TABLE Relation Type (XREF_TABLE) targets TABLE floats. CSU XREF_LISTING Relation Type (XREF_LISTING) targets LISTING floats. CSU XREF_MATH Relation Type (XREF_MATH) targets MATH floats. CSU XREF_CITATION Relation Type (XREF_CITATION) resolves bibliography citations via BibTeX keys.

CSC Default View Types (Default View Types) defines data views with inline prefix syntax. CSU TOC View Type (TOC) generates tables of contents from spec objects. CSU LOF View Type (LOF) generates lists of figures, tables, or listings by counter group. CSU ABBREV View Type (ABBREV) renders inline abbreviation expansions. CSU ABBREV_LIST View Type (ABBREV_LIST) generates abbreviation glossaries. CSU GAUSS View Type (GAUSS) renders Gaussian distribution charts. CSU MATH_INLINE View Type (MATH_INLINE) renders inline LaTeX math expressions.

CSC Default Filters (Default Filters) provides format-specific Pandoc Lua filters applied during EMIT. CSU DOCX Filter (DOCX Filter) converts markers to OOXML-compatible elements — page breaks, bookmarks, and custom styles. CSU HTML Filter (HTML Filter) converts markers to semantic HTML5 elements with CSS classes. CSU Markdown Filter (Markdown Filter) normalizes markers for clean Markdown output.

CSC Default Postprocessors (Default Postprocessors) applies fixups after Pandoc generation. CSU DOCX Postprocessor (DOCX Postprocessor) manipulates the OOXML package — injecting custom styles, fixing table widths, and applying numbering overrides. CSU LaTeX Postprocessor (LaTeX Postprocessor) applies template-specific LaTeX fixups for PDF output.

CSC Default Styles (Default Styles) provides output styling presets. CSU DOCX Style Preset (DOCX Style Preset) defines page layout (Letter, standard margins), heading styles, table formatting, and font selections for Word output. CSU HTML Style Preset (HTML Style Preset) defines the web typography (Inter/JetBrains Mono), color palette, and responsive layout for HTML output.

Figure Type System and Domain Model Definition


DD-MODEL-001: Layered Model Extension with Override Semantics

Selected layered model loading where domain models extend and override the default model by type identifier.

RATIONALE:

ID-based override enables clean domain specialization:

  • Default model loads first, establishing baseline types (SECTION, SPEC, float types, relations, views)
  • Domain model loads second; types with matching IDs replace defaults, new IDs add to the registry
  • Proof views follow the same pattern: domain proofs override defaults by policy_key
  • Attribute inheritance propagated iteratively after all types are loaded, enabling parent attributes to flow to child types across model boundaries
  • Filter, postprocessor, and style directories follow conventional naming for predictable discovery
  • Alternative of mixin composition rejected: ordering ambiguity when multiple mixins define the same attribute

10 Audit & Integrity Design

FD-006: Audit and Integrity

Allocation: Realized by CSC Core Runtime (Core Runtime) and CSC Default Proof Views (Default Proof Views) through CSU Verify Handler (Verify Handler) and CSU-065 (Hash Utilities).

The audit and integrity function ensures deterministic compilation, reproducible builds, and audit trail integrity. It encompasses content-addressed hashing for incremental build detection, structured logging for audit trails, and include dependency tracking for proper cache invalidation.

Include Hash Computation: The engine (CSU Build Engine) queries the build_graph table for known includes from the previous build, then computes SHA1 hashes for each include file. Missing files cause a cache miss (triggering a full rebuild). The resulting map of path-to-hash is compared against stored values to detect changes. SHA1 hashing uses Pandoc’s built-in pandoc.sha1() when available, falling back to vendor/sha2.lua in standalone worker mode.

Document Change Detection: Each document’s content is hashed and compared against the source_files table. Unchanged documents (same content hash and include hashes) skip parsing and reuse cached Intermediate Representation state, providing significant performance improvement for large projects.

Structured Logging: NDJSON (Newline-Delimited JSON) logging provides machine-parseable audit trails with structured data (level, message, timestamp, context). Log level is configurable via config.logging.level with environment override via SPECCOMPILER_LOG_LEVEL. Levels: DEBUG, INFO, WARN, ERROR.

Build Reproducibility: Given identical source files (by content hash), project configuration, and tool versions, the system produces identical outputs. Content-addressed hashing of documents, includes, and the P-IR state ensures deterministic compilation.

Verification Execution: The Verify Handler CSU Verify Handler executes in batch mode during the VERIFY phase. It iterates over all registered proof views, querying each via the Data Manager CSU Data Manager. For each violation row returned, the handler consults the Validation Policy CSU Validation Policy to determine the configured severity level. Error-level violations are emitted as structured diagnostics via the Diagnostics Collector CSU Diagnostics Collector. Violations at the ignore level are suppressed entirely. Each proof view enforces constraints declared by the type metamodel, ensuring that registered types satisfy their validation rules.

After verification completes, the handler stores the verification result (error and warning counts) in all pipeline contexts. The Pipeline Orchestrator CSU Pipeline Orchestrator checks for errors after VERIFY and aborts before EMIT if any exist.

Proof Views — Entity-Based Taxonomy

Proof views follow the SpecIR 5-tuple: S (Specification), O (Object), F (Float), R (Relation), V (View). Each proof is identified by its policy_key.

Specification Proofs (S)

Policy Key View Name Validates
spec_missing_required view_spec_missing_required Required spec attributes present
spec_invalid_type view_spec_invalid_type Specification type is valid

Spec Object Proofs (O)

Policy Key View Name Validates
object_missing_required view_object_missing_required Required object attributes present
object_cardinality_over view_object_cardinality_over Attribute count <= max_occurs
object_cast_failures view_object_cast_failures Attribute value casts to declared type
object_invalid_enum view_object_invalid_enum Enum value exists in enum_values
object_invalid_date view_object_invalid_date Date format is YYYY-MM-DD
object_bounds_violation view_object_bounds_violation Numeric values within min/max bounds
object_duplicate_pid view_object_duplicate_pid PID is globally unique

Spec Float Proofs (F)

Policy Key View Name Validates
float_orphan view_float_orphan Float has a parent object
float_duplicate_label view_float_duplicate_label Float labels unique per specification
float_render_failure view_float_render_failure External render succeeded
float_invalid_type view_float_invalid_type Float type is registered

Spec Relation Proofs (R)

Policy Key View Name Validates
relation_unresolved view_relation_unresolved Link target resolves
relation_dangling view_relation_dangling Target ref points to existing object
relation_ambiguous view_relation_ambiguous Float reference is unambiguous

Spec View Proofs (V)

Policy Key View Name Validates
view_materialization_failure view_view_materialization_failure View materialization succeeded

Component Interaction

The audit subsystem is realized through core runtime components and the default proof view package.

CSC Core Runtime (Core Runtime) provides the verification infrastructure. CSU Build Engine (Build Engine) drives the build lifecycle and content-addressed hash computation. CSU Proof Loader (Proof Loader) discovers and loads proof view modules from model directories, registering them with the data manager for VERIFY phase execution. CSU Validation Policy (Validation Policy) maps proof policy_key values to configured severity levels (error, warn, ignore) from project.yaml. CSU Verify Handler (Verify Handler) iterates over registered proof views during VERIFY, querying each via CSU Data Manager (Data Manager) and emitting violations through CSU Diagnostics Collector (Diagnostics Collector). CSU Pipeline Orchestrator (Pipeline Orchestrator) inspects diagnostics after VERIFY and aborts before EMIT if errors exist.

CSC Default Proof Views (Default Proof Views) provides the baseline verification rules organized by the SpecIR 5-tuple. Specification proofs: CSU Spec Missing Required (Spec Missing Required) validates that required specification attributes are present, and CSU Spec Invalid Type (Spec Invalid Type) validates that specification types are registered. Object proofs: CSU Object Missing Required (Object Missing Required) checks required object attributes, CSU Object Cardinality Over (Object Cardinality Over) enforces max_occurs limits, CSU Object Cast Failures (Object Cast Failures) validates attribute type casts, CSU Object Invalid Enum (Object Invalid Enum) checks enum values against allowed sets, CSU Object Invalid Date (Object Invalid Date) validates YYYY-MM-DD date format, and CSU Object Bounds Violation (Object Bounds Violation) checks numeric bounds. Float proofs: CSU Float Orphan (Float Orphan) detects floats without parent objects, CSU Float Duplicate Label (Float Duplicate Label) enforces label uniqueness per specification, CSU Float Render Failure (Float Render Failure) flags failed external renders, and CSU Float Invalid Type (Float Invalid Type) validates float type registration. Relation proofs: CSU Relation Unresolved (Relation Unresolved) detects links whose targets cannot be resolved, CSU Relation Dangling (Relation Dangling) detects resolved references pointing to nonexistent objects, and CSU Relation Ambiguous (Relation Ambiguous) flags ambiguous float references. View proofs: CSU View Materialization Failure (View Materialization Failure) detects failed view computations.

Figure Audit and Integrity: Build Caching and Verification

TRACEABILITY:
SF-006

11 SW Docs Model Design

FD-007: Software Documentation Domain Model

Allocation: Realized by CSC SW Docs Model (SW Docs Model), with domain proof views in CSC SW Docs Proof Views (SW Docs Proof Views), object types in CSC SW Docs Object Types (SW Docs Object Types), relation types in CSC SW Docs Relation Types (SW Docs Relation Types), specification types in CSC SW Docs Specification Types (SW Docs Specification Types), and view types in CSC SW Docs View Types (SW Docs View Types).

The software documentation domain model extends the default model with traceable object types, domain-specific relation semantics, specification document types, and verification views for MIL-STD-498 and DO-178C compliant software documentation workflows.

Object Type Taxonomy: CSC SW Docs Object Types defines the TRACEABLE abstract base type providing an inherited status enum (Draft, Review, Approved, Implemented) that all domain objects extend. The taxonomy includes requirements (HLR, LLR, NFR), design elements (FD, SF, DD), architectural decomposition (CSC, CSU), verification artifacts (VC, TR), and reference types (DIC, SYMBOL). Each type declares its own attributes, PID prefix, and inheritance chain through the extends field.

Relation Types: CSC SW Docs Relation Types defines domain-specific traceability relations: REALIZES (FD traces to SF via the traceability source attribute), BELONGS (HLR membership in SF via belongs_to), TRACES_TO (general-purpose @ link traceability), XREF_DIC (dictionary cross-references), and XREF_DECOMPOSITION (references targeting CSC/CSU elements). These relations enable automated traceability matrix generation and coverage analysis.

Specification Types: CSC SW Docs Specification Types defines document types for the software documentation lifecycle: SRS (Software Requirements Specification), SDD (Software Design Description), SVC (Software Verification Cases), SUM (Software User Manual), and TRR (Test Results Report). Each type declares version, status, and date attributes.

View Types: CSC SW Docs View Types defines domain-specific views for generating traceability matrices (TRACEABILITY_MATRIX, TEST_EXECUTION_MATRIX, TEST_RESULTS_MATRIX) and coverage summaries (COVERAGE_SUMMARY, REQUIREMENTS_SUMMARY).

Proof Views: CSC SW Docs Proof Views provides domain-specific proof view queries that enforce traceability constraints: VC must trace to HLR, TR must trace to VC, every HLR must be covered by at least one VC, every FD must trace to at least one CSC and CSU, and every CSC and CSU must have at least one FD allocated. CSC SW Docs Model provides the HTML5 postprocessor that generates a single-file documentation web app with embedded CSS, JS, and SQLite-WASM full-text search.

Component Interaction

The software documentation domain model is realized through six packages that extend the default model with traceable types, domain relations, document types, verification views, and proof constraints.

CSC SW Docs Object Types (SW Docs Object Types) defines the domain object taxonomy. CSU TRACEABLE Base Object Type (TRACEABLE Base Object Type) provides the abstract base with an inherited status enum (Draft, Review, Approved, Implemented) that all domain objects extend. Requirements: CSU HLR Object Type (HLR) for high-level requirements, CSU LLR Object Type (LLR) for low-level requirements, and CSU NFR Object Type (NFR) for non-functional requirements. Design elements: CSU FD Object Type (FD) for functional descriptions and CSU SF Object Type (SF) for software functions. Architecture: CSU CSC Object Type (CSC) for computer software components and CSU CSU Object Type (CSU) for computer software units. Verification: CSU VC Object Type (VC) for verification cases and CSU TR Object Type (TR) for test results. Design decisions: CSU DD Object Type (DD) for design decision records. Reference types: CSU DIC Object Type (DIC) for dictionary entries and CSU SYMBOL Object Type (SYMBOL) for symbol definitions.

CSC SW Docs Relation Types (SW Docs Relation Types) defines domain-specific traceability relations. CSU REALIZES Relation Type (REALIZES) traces FD to SF via the traceability source attribute. CSU BELONGS Relation Type (BELONGS) establishes HLR membership in SF via belongs_to. CSU TRACES_TO Relation Type (TRACES_TO) provides general-purpose @ link traceability between any traceable objects. CSU XREF_DIC Relation Type (XREF_DIC) resolves dictionary cross-references targeting DIC entries.

CSC SW Docs Specification Types (SW Docs Specification Types) defines document types for the software documentation lifecycle. CSU SRS Specification Type (SRS) for Software Requirements Specifications. CSU SDD Specification Type (SDD) for Software Design Descriptions. CSU SVC Specification Type (SVC) for Software Verification Cases. CSU SUM Specification Type (SUM) for Software User Manuals. CSU TRR Specification Type (TRR) for Test Results Reports. Each type declares version, status, and date attributes.

CSC SW Docs View Types (SW Docs View Types) defines domain-specific views for documentation output. CSU Traceability Matrix View (Traceability Matrix) generates requirement-to-design traceability matrices. CSU Test Execution Matrix View (Test Execution Matrix) generates verification case execution status tables. CSU Test Results Matrix View (Test Results Matrix) generates test result summary tables. CSU Coverage Summary View (Coverage Summary) computes requirement coverage statistics. CSU Requirements Summary View (Requirements Summary) generates requirement status dashboards.

CSC SW Docs Proof Views (SW Docs Proof Views) provides domain-specific traceability verification rules. CSU VC Missing HLR Traceability (VC Missing HLR Traceability) ensures every verification case traces to at least one HLR. CSU TR Missing VC Traceability (TR Missing VC Traceability) ensures every test result traces to a verification case. CSU HLR Missing VC Coverage (HLR Missing VC Coverage) ensures every HLR is covered by at least one VC. CSU FD Missing CSC Traceability (FD Missing CSC Traceability) ensures every FD references at least one CSC. CSU FD Missing CSU Traceability (FD Missing CSU Traceability) ensures every FD references at least one CSU. CSU CSC Missing FD Allocation (CSC Missing FD Allocation) ensures every CSC is allocated to at least one FD. CSU CSU Missing FD Allocation (CSU Missing FD Allocation) ensures every CSU is allocated to at least one FD.

CSC SW Docs Model (SW Docs Model) provides the domain postprocessor. CSU HTML5 Postprocessor (HTML5 Postprocessor) generates a single-file documentation web application with embedded CSS, JS, navigation, and SQLite-WASM full-text search from the SpecIR database.

Figure Software Documentation Domain Model

12 Low-Level Requirements

The following LLRs define implementation-level contracts that are directly verified by executable tests.

LLR-PIPE-002-01: Handler Registration Requires Name

DESCRIPTION:
Pipeline handler registration shall reject handlers that do not provide a non-empty name field.
TRACEABILITY:
HLR-PIPE-002
VERIFICATION METHOD:
Test

LLR-PIPE-002-02: Handler Registration Requires Prerequisites

DESCRIPTION:
Pipeline handler registration shall reject handlers that do not provide a prerequisites array.
TRACEABILITY:
HLR-PIPE-002
VERIFICATION METHOD:
Test

LLR-PIPE-002-03: Duplicate Handler Names Are Rejected

DESCRIPTION:
Pipeline handler registration shall reject duplicate handler names within the same pipeline instance.
TRACEABILITY:
HLR-PIPE-002
VERIFICATION METHOD:
Test

LLR-PIPE-006-01: Base Context Fields Are Propagated

DESCRIPTION:
Pipeline execution shall propagate the base context fields (validation, build_dir, log, output_format, template, reference_doc, docx, project_root, outputs, html5, bibliography, csl) to handlers.
TRACEABILITY:
HLR-PIPE-006
VERIFICATION METHOD:
Test

LLR-PIPE-006-02: Document Context Is Attached Per Document

DESCRIPTION:
Pipeline execution shall attach doc and spec_id for each processed document context passed to handlers.
TRACEABILITY:
HLR-PIPE-006
VERIFICATION METHOD:
Test

LLR-PIPE-006-03: Project Context Exists Without Documents

DESCRIPTION:
Pipeline execution shall create a fallback project context when the document list is empty, with doc=nil and a derived spec_id.
TRACEABILITY:
HLR-PIPE-006
VERIFICATION METHOD:
Test

LLR-EXT-020-01: Known Type Categories Are Scanned

DESCRIPTION:
Type loading shall scan each known category directory (objects, floats, views, relations, specifications) and register discovered modules.
TRACEABILITY:
HLR-EXT-002
VERIFICATION METHOD:
Test

LLR-EXT-021-01: Exported Handlers Are Registered

DESCRIPTION:
When a type module exports handler, model loading shall call pipeline:register_handler(handler) and propagate registration errors.
TRACEABILITY:
HLR-EXT-003
VERIFICATION METHOD:
Test

LLR-EXT-021-02: Handler attr_order Controls Attribute Display Sequence

DESCRIPTION:
When a type handler is created with an attr_order array in its options, the handler shall render attributes in the specified sequence first; any remaining attributes not listed in attr_order shall be appended alphabetically. When attr_order is absent, all attributes shall render alphabetically.
TRACEABILITY:
HLR-EXT-003
VERIFICATION METHOD:
Test

LLR-EXT-022-01: Schemas Without Identifier Are Ignored

DESCRIPTION:
Category registration helpers shall ignore schema tables that do not provide id; valid schemas shall receive category defaults and attribute enum values shall be registered.
TRACEABILITY:
HLR-EXT-004
VERIFICATION METHOD:
Test

LLR-EXT-023-01: Model Path Resolution Order

DESCRIPTION:
Model path resolution shall check SPECCOMPILER_HOME/models/{model} before checking {cwd}/models/{model}.
TRACEABILITY:
HLR-EXT-005
VERIFICATION METHOD:
Test

LLR-EXT-023-02: Missing Model Paths Fail Fast

DESCRIPTION:
Model loading shall raise an error when the model cannot be located in either SPECCOMPILER_HOME or project-root models/.
TRACEABILITY:
HLR-EXT-005
VERIFICATION METHOD:
Test

LLR-EXT-024-01: Data Views Resolve With Default Fallback

DESCRIPTION:
Chart data view loading shall resolve models.{requested}.types.views.{view} first and fallback to models.default.types.views.{view} when the requested model module is missing.
TRACEABILITY:
HLR-EXT-006
VERIFICATION METHOD:
Test

LLR-EXT-024-02: Sankey Views Inject Series Data And Clear Dataset

DESCRIPTION:
When a chart contains a sankey series and view output returns data/links, injection shall write to series[1].data and series[1].links, and clear dataset to prevent conflicts.
TRACEABILITY:
HLR-EXT-006
VERIFICATION METHOD:
Test

LLR-DB-007-01: DataManager Rollback Cancels Staged Inserts

DESCRIPTION:
DataManager.begin_transaction() followed by facade insert calls and DataManager.rollback() shall leave no persisted staged rows.
TRACEABILITY:
HLR-STOR-001
VERIFICATION METHOD:
Test

LLR-DB-007-02: DataManager CRUD Facade Persists Canonical IR Rows

DESCRIPTION:
DataManager facade methods (insert_specification, insert_object, insert_float, insert_relation, insert_view, insert_attribute_value, query_all, query_one, execute) shall persist and retrieve canonical IR rows in content tables.
TRACEABILITY:
HLR-STOR-001
VERIFICATION METHOD:
Test

LLR-DB-008-01: Attribute Casting Persists Typed Columns For Valid Pending Rows

DESCRIPTION:
Attribute casting shall map raw attribute values to the correct typed columns (string_value, int_value, real_value, bool_value, date_value, enum_ref) and skip updates for invalid casts.
TRACEABILITY:
HLR-STOR-002
VERIFICATION METHOD:
Test

LLR-EXT-024-03: Chart Injection Leaves Config Intact For No-View Or Unsupported View Data

DESCRIPTION:
Chart data injection shall preserve input chart configuration when no view is provided or when view output does not match supported shapes (source or data+links for sankey).
TRACEABILITY:
HLR-EXT-006
VERIFICATION METHOD:
Test

LLR-OUT-029-01: DOCX Preset Loader Resolves, Merges, And Validates Preset Chains

DESCRIPTION:
DOCX preset loading shall resolve preset paths, merge extends chains deterministically, and reject malformed or cyclic preset definitions.
TRACEABILITY:
HLR-OUT-005
VERIFICATION METHOD:
Test

13 Software Decomposition

This chapter defines decomposition and design allocation using MIL-STD-498 nomenclature:

Note: Software Functions (SF) are defined in the SRS alongside their constituent HLRs. Functional Descriptions (FD) trace to SFs via the REALIZES relation and are documented in the SDD design files.

13.1 Core Software Components

13.1.1 Core Runtime Layer

CSC-001: Core Runtime

COMPONENT TYPE:
Layer
DESCRIPTION:
Pipeline orchestration, metadata/config extraction, model loading, proof loading, validation policy, and runtime control.
PATH:
src/core/
CSU-001: Pandoc Filter Entry Point
DESCRIPTION:
Pandoc filter entry point that hooks into Meta(meta) to extract project configuration and invoke engine.run_project(), serving as the bridge between Pandoc and the SpecCompiler build system.
FILE PATH:
src/filter.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-001
CSU-002: Configuration Parser
DESCRIPTION:
Parses and validates project.yaml metadata via Pandoc, extracting project configuration into plain Lua tables for consumption by the engine.
FILE PATH:
src/core/config.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-001
CSU-003: Data Loader
DESCRIPTION:
Loads view modules from models/{model}/types/views/ and invokes their generate() function to produce data for charts and other data-driven consumers.
FILE PATH:
src/core/data_loader.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-001
CSU-004: Diagnostics Collector
DESCRIPTION:
Collects and emits structured errors and warnings (with file, line, column, and diagnostic code) via the logger diagnostic API.
FILE PATH:
src/core/diagnostics.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-001
CSU-005: Build Engine
DESCRIPTION:
Main orchestrator that wires together the pipeline, database, Type Loader , file walker, Build Cache , and output emission to run a full SpecCompiler project build across all documents.
FILE PATH:
src/core/engine.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-001
CSU-006: Pipeline Orchestrator
DESCRIPTION:
Pipeline lifecycle orchestrator that manages a 5-phase (INITIALIZE, ANALYZE, TRANSFORM, VERIFY, EMIT) execution model with declarative handler prerequisites and topological sorting.
FILE PATH:
src/core/pipeline.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-001
CSU-007: Proof Loader
DESCRIPTION:
Discovers, loads, and registers proof view modules from models/{model}/proofs/, maintaining an in-memory registry of proof definitions used for verification policies.
FILE PATH:
src/core/proof_loader.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-001
CSU-008: Type Loader
DESCRIPTION:
Loads type modules (objects, floats, views, relations, specifications) from models/{model}/types/ directories and populates the SpecIR type system tables in the database.
FILE PATH:
src/core/type_loader.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-001
CSU-009: Validation Policy
DESCRIPTION:
Manages configurable validation severity levels (error/warn/ignore) for proof codes, building default policies from loaded proof definitions and allowing project-level overrides.
FILE PATH:
src/core/validation_policy.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-001

13.1.2 Database Persistence Layer

CSC-002: Database Persistence

COMPONENT TYPE:
Layer
DESCRIPTION:
Canonical insert/query API for SpecIR, transaction handling, build cache, output cache, and proof view definitions.
PATH:
src/db/
CSU-010: Build Cache
DESCRIPTION:
Provides incremental build support by comparing SHA1 hashes of source documents against cached values to determine which files need rebuilding.
FILE PATH:
src/db/build_cache.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-002
CSU-011: Database Handler
DESCRIPTION:
Low-level SQLite database handler that wraps lsqlite3, providing execute, query_all, and prepared statement operations for all database access.
FILE PATH:
src/db/handler.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-002
CSU-012: Data Manager
DESCRIPTION:
High-level data manager that initializes the database schema and provides domain-specific insert/update operations for spec objects, floats, relations, and attributes.
FILE PATH:
src/db/manager.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-002
CSU-013: Output Cache
DESCRIPTION:
Checks whether generated output files are up-to-date by comparing the current SpecIR state hash against the cached hash, enabling skipping of unchanged output regeneration.
FILE PATH:
src/db/output_cache.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-002
CSU-014: Proof View Definitions
DESCRIPTION:
Defines SQL CREATE VIEW statements for all proof views used in the VERIFY phase, organized by entity type (specifications, objects, floats, relations, views).
FILE PATH:
src/db/proof_views.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-002

13.1.2.1 DB Queries Package

CSC-005: DB Queries

COMPONENT TYPE:
Package
DESCRIPTION:
SQL query string modules for all database operations across content, types, build, search, and resolution domains.
PATH:
src/db/queries/
CSU-015: Build Queries
DESCRIPTION:
SQL query strings for build infrastructure operations: source file hash lookups, build graph (include dependency) management, and output cache entries.
FILE PATH:
src/db/queries/build.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-005
CSU-016: Content Queries
DESCRIPTION:
SQL query strings for content-layer CRUD operations on spec_objects, spec_floats, spec_relations, spec_views, and spec_attribute_values tables.
FILE PATH:
src/db/queries/content.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-005
CSU-017: Query Aggregator
DESCRIPTION:
Aggregation module that re-exports all domain-specific query sub-modules (types, content, search, build, resolution) under a single Queries namespace.
FILE PATH:
src/db/queries/init.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-005
CSU-018: Resolution Queries
DESCRIPTION:
SQL query strings for resolving relations, float types, cross-references, and relation type inference rules using the weighted quadruple scoring system.
FILE PATH:
src/db/queries/resolution.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-005
CSU-019: Search Queries
DESCRIPTION:
SQL query strings for managing FTS5 full-text search tables, including clearing, indexing, and populating fts_objects, fts_attributes, and fts_floats.
FILE PATH:
src/db/queries/search.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-005
CSU-020: Type Queries
DESCRIPTION:
SQL query strings for inserting and querying type system metadata: float types, relation types, object types, view types, specification types, attribute types, datatype definitions, and enum values.
FILE PATH:
src/db/queries/types.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-005

13.1.2.2 DB Schema Package

CSC-006: DB Schema

COMPONENT TYPE:
Package
DESCRIPTION:
DDL table creation statements for content, types, build infrastructure, and search tables.
PATH:
src/db/schema/
CSU-021: Build Schema
DESCRIPTION:
DDL for build infrastructure tables (build_graph, source_files, output_cache) that enable incremental builds through file dependency tracking and content hashing.
FILE PATH:
src/db/schema/build.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-006
CSU-022: Content Schema
DESCRIPTION:
DDL for content-layer tables (specifications, spec_objects, spec_floats, spec_relations, spec_views, spec_attribute_values) that store parsed specification data.
FILE PATH:
src/db/schema/content.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-006
CSU-023: Schema Aggregator
DESCRIPTION:
Aggregation module that combines all domain-specific schema SQL in dependency order and provides an initialize_views() entry point for post-load view creation.
FILE PATH:
src/db/schema/init.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-006
CSU-024: Search Schema
DESCRIPTION:
DDL for FTS5 virtual tables (fts_objects, fts_attributes, fts_floats) that enable full-text search across specification content with porter stemming.
FILE PATH:
src/db/schema/search.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-006
CSU-025: Type System Schema
DESCRIPTION:
DDL for type system (metamodel) tables (spec_object_types, spec_float_types, spec_relation_types, spec_view_types, spec_specification_types, datatype_definitions, spec_attribute_types, enum_values, implicit_type_aliases).
FILE PATH:
src/db/schema/types.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-006

13.1.2.3 DB Views Package

CSC-007: DB Views

COMPONENT TYPE:
Package
DESCRIPTION:
SQL view definitions for EAV pivots, public API, and resolution helpers.
PATH:
src/db/views/
CSU-026: EAV Pivot Views
DESCRIPTION:
Dynamically generates per-object-type SQL views that pivot the EAV Model into typed columns for external BI queries (e.g., SELECT * FROM view_hlr_objects WHERE status = ‘approved’ ). These views are not used by internal pipeline code, which queries the raw EAV tables directly. See HLR-STOR-006.
FILE PATH:
src/db/views/eav_pivot.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-007
CSU-027: Views Aggregator
DESCRIPTION:
Aggregation module that initializes all database view categories (resolution, public API, and EAV pivot) in the correct dependency order.
FILE PATH:
src/db/views/init.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-007
CSU-028: Public API Views
DESCRIPTION:
Stable BI-friendly SQL views (e.g., public_traceability_matrix) intended as the public interface for external dashboards and query tools.
FILE PATH:
src/db/views/public_api.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-007
CSU-029: Resolution Views
DESCRIPTION:
Internal SQL views for resolving float type aliases, relation types, and cross-references, moving resolution logic from Lua handler code into queryable SQL.
FILE PATH:
src/db/views/resolution.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-007

13.1.3 Pipeline Handlers Layer

CSC-003: Pipeline Handlers

COMPONENT TYPE:
Layer
DESCRIPTION:
Phase handlers implementing initialize, analyze, transform, verify, and emit behavior across five pipeline phases.
PATH:
src/pipeline/
CSU-030: Include Expansion Filter
DESCRIPTION:
Standalone Pandoc Lua filter that recursively expands include code blocks in a subprocess, outputting include dependencies to a JSON metadata file for build graph tracking.
FILE PATH:
src/filters/expand_includes.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-003
CSU-031: Verify Handler
DESCRIPTION:
VERIFY phase handler that iterates over all registered proof views, queries each for violations, and emits structured diagnostics based on validation policy.
FILE PATH:
src/pipeline/verify/verify_handler.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-003

13.1.3.1 Analyze Handlers Package

CSC-008: Analyze Handlers

COMPONENT TYPE:
Package
DESCRIPTION:
ANALYZE phase handlers for relation resolution, relation type inference, and attribute casting.
PATH:
src/pipeline/analyze/
CSU-032: Attribute Caster
DESCRIPTION:
Casts raw attribute values to their typed columns (string, integer, real, boolean, enum, date) based on the datatype definition, returning the appropriate typed field for database storage.
FILE PATH:
src/pipeline/analyze/attribute_caster.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-008
CSU-033: Relation Resolver
DESCRIPTION:
ANALYZE phase handler that resolves spec_relation targets by matching PIDs and header IDs across specifications, populating target_object_id and target_float_id foreign keys.
FILE PATH:
src/pipeline/analyze/relation_resolver.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-008
CSU-161: Relation Type Inferrer
DESCRIPTION:
ANALYZE phase handler that infers relation types using 4-dimension unweighted specificity scoring (selector, source_attribute, source_type, target_type) after relation_resolver has populated targets.
FILE PATH:
src/pipeline/analyze/relation_type_inferrer.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-008

13.1.3.2 Emit Handlers Package

CSC-009: Emit Handlers

COMPONENT TYPE:
Package
DESCRIPTION:
EMIT phase handlers for document assembly, float resolution, view rendering, FTS indexing, and output generation.
PATH:
src/pipeline/emit/
CSU-034: Document Assembler
DESCRIPTION:
Reconstructs a complete Pandoc document from the SpecIR database by querying spec_objects, spec_floats, and spec_views, decoding their stored AST JSON back into Pandoc blocks.
FILE PATH:
src/pipeline/emit/assembler.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-009
CSU-035: Float Emitter
DESCRIPTION:
Transforms Pandoc documents during EMIT by replacing float CodeBlock elements with their rendered content (images, tables, charts) and adding captions and bookmarks.
FILE PATH:
src/pipeline/emit/emit_float.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-009
CSU-036: View Emitter
DESCRIPTION:
Transforms inline Code elements and standalone Code-in-Para patterns during EMIT phase, dispatching to view type handlers to produce rendered inline or block output.
FILE PATH:
src/pipeline/emit/emit_view.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-009
CSU-037: Emitter Orchestrator
DESCRIPTION:
Format-agnostic EMIT phase orchestrator that assembles the Pandoc document from IR, resolves floats, applies numbering, runs format filters and postprocessors, and writes output via Pandoc CLI.
FILE PATH:
src/pipeline/emit/emitter.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-009
CSU-038: Float Handler Dispatcher
DESCRIPTION:
Model-agnostic dispatch layer that queries spec_float_types to discover and cache float handler modules, then dispatches on_render_CodeBlock calls to type-specific handlers.
FILE PATH:
src/pipeline/emit/float_handlers.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-009
CSU-039: Float Numbering
DESCRIPTION:
Assigns sequential numbers to captioned floats per specification and per counter_group, so that related types (e.g., FIGURE, CHART, PLANTUML) share a single numbering sequence within each spec.
FILE PATH:
src/pipeline/emit/float_numbering.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-009
CSU-040: Float Resolver
DESCRIPTION:
Collects floats with their resolved_ast and categorizes them for EMIT phase processing, distinguishing between image-producing floats and handler-dispatched floats.
FILE PATH:
src/pipeline/emit/float_resolver.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-009
CSU-041: FTS Indexer
DESCRIPTION:
EMIT phase handler that populates FTS5 virtual tables by converting stored Pandoc AST JSON to plain text and indexing spec objects, attributes, and floats for full-text search.
FILE PATH:
src/pipeline/emit/fts_indexer.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-009
CSU-042: Inline Handler Dispatcher
DESCRIPTION:
Model-agnostic dispatch layer that queries spec_view_types to discover and cache inline view handler modules, then dispatches on_render_Code calls by matching inline prefixes.
FILE PATH:
src/pipeline/emit/inline_handlers.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-009
CSU-043: View Handler Dispatcher
DESCRIPTION:
Model-agnostic dispatch layer that queries spec_view_types to discover and cache block-level view handler modules, then dispatches on_render_CodeBlock calls for views.
FILE PATH:
src/pipeline/emit/view_handlers.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-009

13.1.3.3 Initialize Handlers Package

CSC-010: Initialize Handlers

COMPONENT TYPE:
Package
DESCRIPTION:
INITIALIZE phase handlers that parse document AST and populate all SpecIR container tables.
PATH:
src/pipeline/initialize/
CSU-044: Attribute Parser
DESCRIPTION:
INITIALIZE phase handler that extracts attributes from BlockQuote elements following headers, parses name: value syntax, casts values via datatype definitions, and stores them in spec_attribute_values.
FILE PATH:
src/pipeline/initialize/attributes.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-010
CSU-045: Include Handler
DESCRIPTION:
Pre-pipeline utility that recursively expands include code blocks by reading referenced files and parsing them through Pandoc, with cycle detection and depth limiting. Called directly by the engine before pipeline execution; not a pipeline handler.
FILE PATH:
src/pipeline/shared/include_handler.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-011
CSU-046: Float Parser
DESCRIPTION:
INITIALIZE phase handler that parses float CodeBlock syntax (type.lang:label), resolves type aliases, and stores float instances in spec_floats.
FILE PATH:
src/pipeline/initialize/spec_floats.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-010
CSU-047: Object Parser
DESCRIPTION:
INITIALIZE phase handler that creates spec_objects rows from L2+ headers parsed by the specifications handler, inferring object types from header prefixes.
FILE PATH:
src/pipeline/initialize/spec_objects.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-010
CSU-048: Relation Parser
DESCRIPTION:
INITIALIZE phase handler that extracts link-based relations ([PID](@) and [PID](#)) from object ASTs and stores them in spec_relations. Type inference and link rewriting are delegated to relation_type_inferrer (ANALYZE) and relation_link_rewriter (TRANSFORM).
FILE PATH:
src/pipeline/initialize/spec_relations.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-010
CSU-049: View Parser
DESCRIPTION:
INITIALIZE phase handler that registers view instances from CodeBlock and inline Code syntax, resolving view type prefixes and storing entries in spec_views.
FILE PATH:
src/pipeline/initialize/spec_views.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-010
CSU-050: Specification Parser
DESCRIPTION:
INITIALIZE phase handler that runs first to parse document headers, register the root specification from the L1 header, and store parsed header data in the pipeline context.
FILE PATH:
src/pipeline/initialize/specifications.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-010

13.1.3.4 Shared Pipeline Utilities Package

CSC-011: Shared Pipeline Utilities

COMPONENT TYPE:
Package
DESCRIPTION:
Shared infrastructure modules providing base handlers, rendering utilities, and view helpers used across pipeline phases.
PATH:
src/pipeline/shared/
CSU-051: Attribute Paragraph Utilities
DESCRIPTION:
Shared utility functions for parsing attribute paragraphs from Pandoc inline nodes, handling Span unwrapping, text extraction, and inline content normalization.
FILE PATH:
src/pipeline/shared/attribute_para_utils.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-011
CSU-052: Float Base
DESCRIPTION:
Shared infrastructure for float type handlers, providing helper functions to update resolved_ast in the database and query floats by type and specification.
FILE PATH:
src/pipeline/shared/float_base.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-011
CSU-053: Include Utilities
DESCRIPTION:
Shared utility functions for identifying include directive CodeBlocks and parsing include file paths, used by both include_handler and expand_includes.
FILE PATH:
src/pipeline/shared/include_utils.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-011
CSU-054: Math Render Utilities
DESCRIPTION:
Shared helpers for AsciiMath and MathML/OMML rendering, providing content hashing, script path resolution, and external process invocation for math conversion.
FILE PATH:
src/pipeline/shared/math_render_utils.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-011
CSU-055: Render Utilities
DESCRIPTION:
Shared rendering utilities for spec object handlers, providing functions to add CSS classes, insert page breaks, create bookmarks, and build styled header elements.
FILE PATH:
src/pipeline/shared/render_utils.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-011
CSU-056: Source Position Compatibility
DESCRIPTION:
Pandoc version compatibility layer that strips inline sourcepos tracking Spans from the AST while preserving line/column data on Link elements for diagnostics.
FILE PATH:
src/pipeline/shared/sourcepos_compat.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-011
CSU-057: Specification Base
DESCRIPTION:
Shared infrastructure for specification type handlers, providing default header rendering and configurable title formatting with optional PID display.
FILE PATH:
src/pipeline/shared/specification_base.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-011
CSU-058: Spec Object Base
DESCRIPTION:
Shared infrastructure for spec object type handlers (HLR, FD, VC, etc.), providing styled headers with PID prefixes, attribute display, and an extensible create_handler() factory.
FILE PATH:
src/pipeline/shared/spec_object_base.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-011
CSU-059: View Utilities
DESCRIPTION:
Shared utility functions for view handlers, providing MathML-to-HTML wrapping, Pandoc element JSON serialization, and other common view rendering operations.
FILE PATH:
src/pipeline/shared/view_utils.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-011

13.1.3.5 Transform Handlers Package

CSC-012: Transform Handlers

COMPONENT TYPE:
Package
DESCRIPTION:
TRANSFORM phase handlers for view materialization, external rendering, and spec object/specification rendering.
PATH:
src/pipeline/transform/
CSU-060: External Render Handler
DESCRIPTION:
TRANSFORM phase handler that orchestrates parallel rendering of external float and view types (PlantUML, charts, math) by batching tasks and dispatching to registered renderer callbacks.
FILE PATH:
src/pipeline/transform/external_render_handler.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-012
CSU-061: Float Transformer
DESCRIPTION:
TRANSFORM phase handler that resolves internal float types (TABLE, CSV, etc.) by dynamically loading type-specific modules; external floats are delegated to external_render_handler.
FILE PATH:
src/pipeline/transform/spec_floats.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-012
CSU-162: Relation Link Rewriter
DESCRIPTION:
TRANSFORM phase handler that rewrites @ and # links in stored spec_object AST JSON, replacing them with resolved anchor targets using the relation lookup built from spec_relations.
FILE PATH:
src/pipeline/transform/relation_link_rewriter.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-012
CSU-062: Object Render Handler
DESCRIPTION:
TRANSFORM phase handler that loads object type modules and invokes their on_render_SpecObject to transform stored AST into styled output with headers, attributes, and bookmarks.
FILE PATH:
src/pipeline/transform/spec_object_render_handler.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-012
CSU-063: Specification Render Handler
DESCRIPTION:
TRANSFORM phase handler that loads specification type modules and invokes their on_render_Specification to generate the document title header.
FILE PATH:
src/pipeline/transform/specification_render_handler.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-012
CSU-064: View Materializer
DESCRIPTION:
TRANSFORM phase handler that pre-computes view data (TOC, traceability matrices, etc.) by querying the database and storing structured JSON in spec_views.resolved_data.
FILE PATH:
src/pipeline/transform/view_materializer.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-012

13.1.4 Infrastructure Layer

CSC-004: Infrastructure

COMPONENT TYPE:
Layer
DESCRIPTION:
Output toolchain integration, hashing, logging, JSON utilities, reference cache management, and external tool wrappers.
PATH:
src/infra/
CSU-065: Hash Utilities
DESCRIPTION:
Provides SHA1 hashing for content and files, using Pandoc’s built-in sha1 when running inside Pandoc or falling back to a pure-Lua SHA1 implementation for standalone workers.
FILE PATH:
src/infra/hash_utils.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-004
CSU-066: JSON Utilities
DESCRIPTION:
Unified JSON encode/decode wrapper using the dkjson pure-Lua library, providing a consistent JSON interface independent of Pandoc’s JSON functions.
FILE PATH:
src/infra/json.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-004
CSU-067: Logger
DESCRIPTION:
TTY-aware logging system that outputs human-readable colored console messages when connected to a terminal, or structured NDJSON when piped, with configurable severity levels.
FILE PATH:
src/infra/logger.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-004
CSU-068: Reference Cache
DESCRIPTION:
Tracks whether reference.docx needs rebuilding by comparing the SHA1 hash of the preset file against a cached hash in the build_meta database table.
FILE PATH:
src/infra/reference_cache.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-004
CSU-069: MathML to OMML Converter
DESCRIPTION:
Converts MathML to Office MathML (OMML) by invoking an external Deno process running the mathml2omml npm library.
FILE PATH:
src/tools/mathml2omml_external.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-004

13.1.4.1 Format Utilities Package

CSC-013: Format Utilities

COMPONENT TYPE:
Package
DESCRIPTION:
Writer adapters, XML utilities, and ZIP archive operations for format-specific output generation.
PATH:
src/infra/format/
CSU-070: Format Writer
DESCRIPTION:
Provides postprocessor and filter loading utilities for template-specific output modifications, discovering format-specific Lua modules from models/{template}/ directories.
FILE PATH:
src/infra/format/writer.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-013
CSU-071: XML Utilities
DESCRIPTION:
XML utility module providing escaping, DOM construction, parsing, and manipulation via the SLAXML library for generating and transforming XML content.
FILE PATH:
src/infra/format/xml.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-013
CSU-072: ZIP Utilities
DESCRIPTION:
Cross-platform ZIP archive utilities using the lua-zip library, providing extract and create operations for DOCX archive manipulation.
FILE PATH:
src/infra/format/zip_utils.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-013

13.1.4.2 DOCX Generation Package

CSC-014: DOCX Generation

COMPONENT TYPE:
Package
DESCRIPTION:
OOXML builder, preset loader, reference generator, and style builder for Word document output.
PATH:
src/infra/format/docx/
CSU-073: OOXML Builder
DESCRIPTION:
Unified OOXML builder for generating Word Open XML, offering both a stateful Builder API (method chaining) and a stateless Static API (inline OOXML generation).
FILE PATH:
src/infra/format/docx/ooxml_builder.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-014
CSU-074: Preset Loader
DESCRIPTION:
Loads Lua preset files that define DOCX styles, executing the preset script and returning the resulting configuration table for use by the reference generator.
FILE PATH:
src/infra/format/docx/preset_loader.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-014
CSU-075: Reference Generator
DESCRIPTION:
Generates reference.docx by merging custom styles from preset definitions into Pandoc’s default DOCX template via ZIP manipulation of the word/styles.xml file.
FILE PATH:
src/infra/format/docx/reference_generator.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-014
CSU-076: Style Builder
DESCRIPTION:
Provides unit conversion (cm/pt/in to twips) and OOXML style-building functions for generating Word paragraph and character style definitions.
FILE PATH:
src/infra/format/docx/style_builder.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-014

13.1.4.3 I/O Utilities Package

CSC-015: I/O Utilities

COMPONENT TYPE:
Package
DESCRIPTION:
AST traversal with source position tracking and basic file I/O operations.
PATH:
src/infra/io/
CSU-077: Document Walker
DESCRIPTION:
Provides AST traversal methods for pipeline handlers, extracting source position (line numbers) from Pandoc data-pos attributes and tracking source file provenance through include expansion.
FILE PATH:
src/infra/io/document_walker.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-015
CSU-078: File Walker
DESCRIPTION:
Provides basic file I/O operations (read file, resolve relative paths, check existence, list directory) using luv for filesystem access.
FILE PATH:
src/infra/io/file_walker.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-015

13.1.4.4 Process Management Package

CSC-016: Process Management

COMPONENT TYPE:
Package
DESCRIPTION:
External process spawning via luv and Pandoc command-line argument building.
PATH:
src/infra/process/
CSU-079: Pandoc CLI Builder
DESCRIPTION:
Builds Pandoc command-line argument arrays from configuration, resolving filter paths and speccompiler home directory for external pandoc process invocation.
FILE PATH:
src/infra/process/pandoc_cli.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-016
CSU-080: Task Runner

DESCRIPTION:
Unified interface for spawning and managing external processes using luv (libuv), providing async I/O, timeouts, CPU count detection, and command existence checking.
FILE PATH:
src/infra/process/task_runner.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-016

13.2 Default Model Components

13.2.1 Default Model

CSC-017: Default Model

COMPONENT TYPE:
Model
DESCRIPTION:
Foundational type model providing base object, float, relation, and view types that all other models extend.
PATH:
models/default/
CSU-081: SECTION Object Type
DESCRIPTION:
Defines the SECTION object type (id=“SECTION”), the default type for headers without explicit TYPE: prefix; numbered, with optional XHTML description attribute.
FILE PATH:
models/default/types/objects/section.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-017
CSU-082: SPEC Specification Type
DESCRIPTION:
Defines the SPEC specification type (id=“SPEC”), the default type for H1 headers without explicit TYPE: prefix; title is unnumbered and does not display a PID.
FILE PATH:
models/default/types/specifications/spec.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-017

13.2.1.1 Default Filters Package

CSC-018: Default Filters

COMPONENT TYPE:
Package
DESCRIPTION:
Format-specific Pandoc Lua filters that convert speccompiler markers to native output elements.
PATH:
models/default/filters/
CSU-083: DOCX Filter
DESCRIPTION:
Pandoc Lua filter for DOCX output that converts speccompiler-format markers (page-break, bookmarks, math-omml, captions, equations) into native OOXML elements.
FILE PATH:
models/default/filters/docx.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-018
CSU-084: HTML Filter
DESCRIPTION:
Pandoc Lua filter for HTML5 output that converts speccompiler-format markers into semantic HTML elements with Bootstrap-compatible styling.
FILE PATH:
models/default/filters/html.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-018
CSU-085: Markdown Filter
DESCRIPTION:
Pandoc Lua filter for Markdown output that converts speccompiler page-break markers to horizontal rules and removes markers with no Markdown equivalent.
FILE PATH:
models/default/filters/markdown.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-018

13.2.1.2 Default Postprocessors Package

CSC-019: Default Postprocessors

COMPONENT TYPE:
Package
DESCRIPTION:
Format-specific post-processing applied after Pandoc output generation.
PATH:
models/default/postprocessors/
CSU-086: DOCX Postprocessor
DESCRIPTION:
DOCX post-processor that loads and applies template-specific OOXML post-processing to fix styles regenerated by Pandoc’s DOCX writer.
FILE PATH:
models/default/postprocessors/docx.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-019
CSU-087: LaTeX Postprocessor
DESCRIPTION:
LaTeX post-processor that loads and applies template-specific LaTeX post-processing to transform Pandoc’s standard LaTeX output.
FILE PATH:
models/default/postprocessors/latex.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-019

13.2.1.3 Default Proof Views Package

CSC-020: Default Proof Views

COMPONENT TYPE:
Package
DESCRIPTION:
SQL proof view queries for detecting constraint violations across specifications, objects, floats, relations, and views.
PATH:
models/default/proofs/
CSU-089: Spec Missing Required
DESCRIPTION:
Proof view detecting specifications missing required attributes.
FILE PATH:
models/default/proofs/sd_101_spec_missing_required.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-020
CSU-090: Spec Invalid Type
DESCRIPTION:
Proof view detecting specifications whose type_ref does not match any registered specification type.
FILE PATH:
models/default/proofs/sd_102_spec_invalid_type.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-020
CSU-091: Object Missing Required
DESCRIPTION:
Proof view detecting spec objects missing required attributes.
FILE PATH:
models/default/proofs/sd_201_object_missing_required.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-020
CSU-092: Object Cardinality Over
DESCRIPTION:
Proof view detecting spec object attributes exceeding their declared max_occurs cardinality.
FILE PATH:
models/default/proofs/sd_202_object_cardinality_over.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-020
CSU-093: Object Cast Failures
DESCRIPTION:
Proof view detecting spec object attributes whose raw values failed to cast to their declared datatype.
FILE PATH:
models/default/proofs/sd_203_object_cast_failures.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-020
CSU-094: Object Invalid Enum
DESCRIPTION:
Proof view detecting spec object ENUM attributes with values not matching any entry in enum_values.
FILE PATH:
models/default/proofs/sd_204_object_invalid_enum.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-020
CSU-095: Object Invalid Date
DESCRIPTION:
Proof view detecting spec object DATE attributes not matching the YYYY-MM-DD format.
FILE PATH:
models/default/proofs/sd_205_object_invalid_date.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-020
CSU-096: Object Bounds Violation
DESCRIPTION:
Proof view detecting numeric attributes falling outside declared min_value/max_value bounds.
FILE PATH:
models/default/proofs/sd_206_object_bounds_violation.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-020
CSU-097: Float Orphan
DESCRIPTION:
Proof view detecting floats with no parent object despite objects existing in the same specification.
FILE PATH:
models/default/proofs/sd_301_float_orphan.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-020
CSU-098: Float Duplicate Label
DESCRIPTION:
Proof view detecting floats sharing the same label within a specification.
FILE PATH:
models/default/proofs/sd_302_float_duplicate_label.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-020
CSU-099: Float Render Failure
DESCRIPTION:
Proof view detecting floats requiring external rendering but with NULL resolved_ast.
FILE PATH:
models/default/proofs/sd_303_float_render_failure.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-020
CSU-100: Float Invalid Type
DESCRIPTION:
Proof view detecting floats whose type_ref does not match any registered float type.
FILE PATH:
models/default/proofs/sd_304_float_invalid_type.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-020
CSU-101: Relation Unresolved
DESCRIPTION:
Proof view detecting relations with target_text but no resolved target_ref.
FILE PATH:
models/default/proofs/sd_401_relation_unresolved.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-020
CSU-102: Relation Dangling
DESCRIPTION:
Proof view detecting relations whose target_ref points to a non-existent identifier.
FILE PATH:
models/default/proofs/sd_402_relation_dangling.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-020
CSU-103: Relation Ambiguous
DESCRIPTION:
Proof view detecting relations flagged as ambiguous where the float reference matched multiple targets.
FILE PATH:
models/default/proofs/sd_407_relation_ambiguous.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-020
CSU-104: View Materialization Failure
DESCRIPTION:
Proof view detecting views whose materialization failed, leaving both resolved_ast and resolved_data as NULL.
FILE PATH:
models/default/proofs/sd_501_view_materialization_failure.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-020

13.2.1.4 Default Styles Package

CSC-021: Default Styles

COMPONENT TYPE:
Package
DESCRIPTION:
Style presets defining page layout, typography, and formatting for DOCX and HTML output.
PATH:
models/default/styles/default/
CSU-106: DOCX Style Preset
DESCRIPTION:
Defines the default DOCX style preset with Letter-sized page configuration, paragraph styles, and standard margins for Word document output.
FILE PATH:
models/default/styles/default/docx.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-021
CSU-107: HTML Style Preset
DESCRIPTION:
Defines the default HTML style preset with typography (Inter/JetBrains Mono fonts), color palette, and layout configuration for web output.
FILE PATH:
models/default/styles/default/html.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-021

13.2.1.5 Default Float Types Package

CSC-022: Default Float Types

COMPONENT TYPE:
Package
DESCRIPTION:
Float type definitions for numbered content blocks including images, tables, code listings, diagrams, charts, and equations.
PATH:
models/default/types/floats/
CSU-108: CHART Float Type
DESCRIPTION:
Defines the CHART float type for ECharts JSON configurations rendered to PNG via Deno; shares FIGURE counter group and requires external rendering.
FILE PATH:
models/default/types/floats/chart.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-022
CSU-109: FIGURE Float Type
DESCRIPTION:
Defines the FIGURE float type for existing image files (PNG, JPG, etc.); does not require external rendering and resolves image paths relative to the source file.
FILE PATH:
models/default/types/floats/figure.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-022
CSU-110: LISTING Float Type
DESCRIPTION:
Defines the LISTING float type for code listings and source code blocks; has its own counter group, supports aliases like src, quadro, and code.
FILE PATH:
models/default/types/floats/listing.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-022
CSU-111: MATH Float Type
DESCRIPTION:
Defines the MATH float type for block-level AsciiMath expressions converted to MathML/OMML; uses the EQUATION counter group and requires external rendering.
FILE PATH:
models/default/types/floats/math.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-022
CSU-112: PLANTUML Float Type
DESCRIPTION:
Defines the PLANTUML float type for PlantUML diagrams rendered to PNG; shares the FIGURE counter group and requires external rendering.
FILE PATH:
models/default/types/floats/plantuml.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-022
CSU-113: TABLE Float Type
DESCRIPTION:
Defines the TABLE float type for tables parsed from CSV, TSV, or list-table syntax using Pandoc’s built-in readers; has its own counter group.
FILE PATH:
models/default/types/floats/table.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-022

13.2.1.6 Default Relation Types Package

CSC-023: Default Relation Types

COMPONENT TYPE:
Package
DESCRIPTION:
Cross-reference relation type definitions mapping link selectors to target float types.
PATH:
models/default/types/relations/
CSU-114: XREF_CITATION Relation Type
DESCRIPTION:
Defines the XREF_CITATION relation type for cross-references to bibliography entries; uses the # link selector with cite/citep prefix aliases.
FILE PATH:
models/default/types/relations/xref_citation.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-023
CSU-115: XREF_FIGURE Relation Type
DESCRIPTION:
Defines the XREF_FIGURE relation type for cross-references to FIGURE, PLANTUML, and CHART floats; default relation type for # references.
FILE PATH:
models/default/types/relations/xref_figure.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-023
CSU-116: XREF_LISTING Relation Type
DESCRIPTION:
Defines the XREF_LISTING relation type for cross-references to LISTING floats; uses the # link selector.
FILE PATH:
models/default/types/relations/xref_listing.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-023
CSU-117: XREF_MATH Relation Type
DESCRIPTION:
Defines the XREF_MATH relation type for cross-references to MATH floats; uses the # link selector.
FILE PATH:
models/default/types/relations/xref_math.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-023
CSU-118: XREF_TABLE Relation Type
DESCRIPTION:
Defines the XREF_TABLE relation type for cross-references to TABLE floats; uses the # link selector.
FILE PATH:
models/default/types/relations/xref_table.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-023

13.2.1.7 Default View Types Package

CSC-024: Default View Types

COMPONENT TYPE:
Package
DESCRIPTION:
View type definitions for inline and block-level data-driven content rendering.
PATH:
models/default/types/views/
CSU-119: ABBREV View Type
DESCRIPTION:
Defines the ABBREV view type for inline abbreviation/acronym definitions using abbrev: syntax with first-use expansion support.
FILE PATH:
models/default/types/views/abbrev.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-024
CSU-120: ABBREV_LIST View Type
DESCRIPTION:
Defines the ABBREV_LIST view type for generating a sorted list of all abbreviations defined in the document.
FILE PATH:
models/default/types/views/abbrev_list.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-024
CSU-121: GAUSS View Type
DESCRIPTION:
Defines the GAUSS view type for generating Gaussian distribution data from inline gauss: syntax with configurable parameters; returns ECharts dataset format.
FILE PATH:
models/default/types/views/gauss.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-024
CSU-122: LOF View Type
DESCRIPTION:
Defines the LOF view type for generating lists of floats (figures, tables) from inline lof:/lot: syntax; queries spec_floats by counter_group.
FILE PATH:
models/default/types/views/lof.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-024
CSU-123: MATH_INLINE View Type
DESCRIPTION:
Defines the MATH_INLINE view type for inline AsciiMath expressions using math:/eq:/formula: syntax; requires external rendering for MathML-to-OMML conversion.
FILE PATH:
models/default/types/views/math_inline.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-024
CSU-124: TOC View Type

DESCRIPTION:
Defines the TOC view type for generating a table of contents from inline toc: syntax with optional depth parameter.
FILE PATH:
models/default/types/views/toc.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-024

13.3 SW Docs Model Components

13.3.1 SW Docs Model

CSC-025: SW Docs Model

COMPONENT TYPE:
Model
DESCRIPTION:
Domain model for software documentation providing traceable object types, domain-specific proof views, specification types, relation types, and views.
PATH:
models/sw_docs/
CSU-125: HTML5 Postprocessor
DESCRIPTION:
HTML5 post-processor that generates a single-file documentation web app with embedded CSS, JS, content, and SQLite-WASM full-text search.
FILE PATH:
models/sw_docs/postprocessors/html5.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-025

13.3.1.1 SW Docs Proof Views Package

CSC-026: SW Docs Proof Views

COMPONENT TYPE:
Package
DESCRIPTION:
Domain-specific proof view queries for software documentation traceability and naming convention enforcement.
PATH:
models/sw_docs/proofs/
CSU-126: VC Missing HLR Traceability
DESCRIPTION:
Proof view detecting verification cases with no traceability link to any high-level requirement.
FILE PATH:
models/sw_docs/proofs/sd_601_vc_missing_hlr_traceability.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-026
CSU-127: TR Missing VC Traceability
DESCRIPTION:
Proof view detecting test results with no traceability link to any verification case.
FILE PATH:
models/sw_docs/proofs/sd_602_tr_missing_vc_traceability.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-026
CSU-128: HLR Missing VC Coverage
DESCRIPTION:
Proof view detecting high-level requirements not covered by any verification case.
FILE PATH:
models/sw_docs/proofs/sd_603_hlr_missing_vc_coverage.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-026
CSU-131: FD Missing CSC Traceability
DESCRIPTION:
Proof view detecting functional descriptions with no traceability link to any Computer Software Component.
FILE PATH:
models/sw_docs/proofs/sd_606_fd_missing_csc_traceability.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-026
CSU-132: FD Missing CSU Traceability
DESCRIPTION:
Proof view detecting functional descriptions with no traceability link to any Computer Software Unit.
FILE PATH:
models/sw_docs/proofs/sd_607_fd_missing_csu_traceability.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-026
CSU-163: CSC Missing FD Allocation
DESCRIPTION:
Proof view detecting Computer Software Components with no functional description (FD) allocated to them.
FILE PATH:
models/sw_docs/proofs/csc_missing_fd_allocation.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-026
CSU-164: CSU Missing FD Allocation
DESCRIPTION:
Proof view detecting Computer Software Units with no functional description (FD) allocated to them.
FILE PATH:
models/sw_docs/proofs/csu_missing_fd_allocation.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-026

13.3.1.2 SW Docs Object Types Package

CSC-027: SW Docs Object Types

COMPONENT TYPE:
Package
DESCRIPTION:
Domain object type definitions for traceable specification items including requirements, design decisions, verification cases, and MIL-STD-498 architectural elements.
PATH:
models/sw_docs/types/objects/
CSU-133: CSC Object Type
DESCRIPTION:
Defines the CSC (Computer Software Component) object type for MIL-STD-498 architectural decomposition, with required component_type and path attributes, extending TRACEABLE.
FILE PATH:
models/sw_docs/types/objects/csc.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-027
CSU-134: CSU Object Type
DESCRIPTION:
Defines the CSU (Computer Software Unit) object type for implementation-level source file units, with required file_path and optional language attributes, extending TRACEABLE.
FILE PATH:
models/sw_docs/types/objects/csu.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-027
CSU-135: DD Object Type
DESCRIPTION:
Defines the DD (Design Decision) object type for recording architectural decisions, with a required rationale XHTML attribute, extending TRACEABLE.
FILE PATH:
models/sw_docs/types/objects/dd.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-027
CSU-136: DIC Object Type
DESCRIPTION:
Defines the DIC (Dictionary Entry) object type for project term definitions, with optional term, acronym, and domain attributes, extending TRACEABLE.
FILE PATH:
models/sw_docs/types/objects/dic.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-027
CSU-137: FD Object Type
DESCRIPTION:
Defines the FD (Functional Description) object type for design elements that realize Software Functions, with optional traceability XHTML attribute, extending TRACEABLE.
FILE PATH:
models/sw_docs/types/objects/fd.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-027
CSU-138: HLR Object Type
DESCRIPTION:
Defines the HLR (High-Level Requirement) object type for top-level system requirements, with priority enum (High/Mid/Low), rationale, and belongs_to attributes, extending TRACEABLE.
FILE PATH:
models/sw_docs/types/objects/hlr.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-027
CSU-139: LLR Object Type
DESCRIPTION:
Defines the LLR (Low-Level Requirement) object type for detailed implementation requirements derived from HLRs, with optional rationale, extending TRACEABLE.
FILE PATH:
models/sw_docs/types/objects/llr.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-027
CSU-140: NFR Object Type
DESCRIPTION:
Defines the NFR (Non-Functional Requirement) object type for quality-attribute requirements, with category enum, priority, and metric attributes, extending TRACEABLE.
FILE PATH:
models/sw_docs/types/objects/nfr.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-027
CSU-141: SF Object Type
DESCRIPTION:
Defines the SF (Software Function) object type for grouping related HLRs into functional units, with optional description and rationale attributes, extending TRACEABLE.
FILE PATH:
models/sw_docs/types/objects/sf.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-027
CSU-142: SYMBOL Object Type
DESCRIPTION:
Defines the SYMBOL object type for code symbols (functions, variables, registers) extracted from firmware analysis, with kind, source, complexity, and calls attributes.
FILE PATH:
models/sw_docs/types/objects/symbol.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-027
CSU-143: TR Object Type
DESCRIPTION:
Defines the TR (Test Result) object type for verification-case execution outcomes, with required result enum (Pass/Fail/Blocked/Not Run) and required traceability to a VC, extending TRACEABLE.
FILE PATH:
models/sw_docs/types/objects/tr.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-027
CSU-144: TRACEABLE Base Object Type
DESCRIPTION:
Defines the TRACEABLE abstract base object type that all traceable objects extend; provides the inherited status enum attribute (Draft/Review/Approved/Implemented) and extends SECTION.
FILE PATH:
models/sw_docs/types/objects/traceable.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-027
CSU-145: VC Object Type
DESCRIPTION:
Defines the VC (Verification Case) object type for test specifications, with required objective and verification_method attributes plus optional preconditions, expected results, and pass criteria, extending TRACEABLE.
FILE PATH:
models/sw_docs/types/objects/vc.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-027

13.3.1.3 SW Docs Relation Types Package

CSC-028: SW Docs Relation Types

COMPONENT TYPE:
Package
DESCRIPTION:
Domain relation type definitions for traceability links between software documentation elements.
PATH:
models/sw_docs/types/relations/
CSU-146: BELONGS Relation Type
DESCRIPTION:
Defines the BELONGS relation type representing HLR membership in a Software Function (SF), resolved from the belongs_to source attribute using the @ link selector.
FILE PATH:
models/sw_docs/types/relations/belongs.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-028
CSU-147: REALIZES Relation Type
DESCRIPTION:
Defines the REALIZES relation type representing a Functional Description (FD) realizing a Software Function (SF), resolved from the traceability source attribute.
FILE PATH:
models/sw_docs/types/relations/realizes.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-028
CSU-148: TRACES_TO Relation Type
DESCRIPTION:
Defines the TRACES_TO relation type, the default (is_default=true) general-purpose traceability link using the @ link selector with no source/target type constraints.
FILE PATH:
models/sw_docs/types/relations/traces_to.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-028
CSU-149: XREF_DIC Relation Type
DESCRIPTION:
Defines the XREF_DIC relation type for cross-references targeting Dictionary (DIC) entries from any source type, using the @ link selector.
FILE PATH:
models/sw_docs/types/relations/xref_dic.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-028

13.3.1.4 SW Docs Specification Types Package

CSC-029: SW Docs Specification Types

COMPONENT TYPE:
Package
DESCRIPTION:
Specification type definitions for SDN document types (SRS, SDD, SVC, SUM, TRR).
PATH:
models/sw_docs/types/specifications/
CSU-150: SDD Specification Type
DESCRIPTION:
Defines the SDD (Software Design Description) specification type with required version, optional status and date attributes.
FILE PATH:
models/sw_docs/types/specifications/sdd.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-029
CSU-151: SRS Specification Type
DESCRIPTION:
Defines the SRS (Software Requirements Specification) specification type with required version, optional status and date attributes.
FILE PATH:
models/sw_docs/types/specifications/srs.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-029
CSU-152: SUM Specification Type
DESCRIPTION:
Defines the SUM (Software User Manual) specification type for user manuals, with required version, optional status and date attributes.
FILE PATH:
models/sw_docs/types/specifications/sum.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-029
CSU-153: SVC Specification Type
DESCRIPTION:
Defines the SVC (Software Verification Cases) specification type with required version, optional status and date attributes.
FILE PATH:
models/sw_docs/types/specifications/svc.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-029
CSU-154: TRR Specification Type
DESCRIPTION:
Defines the TRR (Test Results Report) specification type for aggregating test-execution results, with required version plus optional test_run_id and environment attributes.
FILE PATH:
models/sw_docs/types/specifications/trr.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-029

13.3.1.5 SW Docs View Types Package

CSC-030: SW Docs View Types

COMPONENT TYPE:
Package
DESCRIPTION:
Domain view type definitions for traceability matrices, test results, and coverage summaries.
PATH:
models/sw_docs/types/views/
CSU-155: Coverage Summary View
DESCRIPTION:
Defines the COVERAGE_SUMMARY view generating a table of VC counts and pass rates grouped by Software Function (SF).
FILE PATH:
models/sw_docs/types/views/coverage_summary.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-030
CSU-156: Requirements Summary View
DESCRIPTION:
Defines the REQUIREMENTS_SUMMARY view generating a table of HLR counts grouped by Software Function (SF) via the BELONGS relation.
FILE PATH:
models/sw_docs/types/views/requirements_summary.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-030
CSU-157: Test Execution Matrix View
DESCRIPTION:
Defines the TEST_EXECUTION_MATRIX view generating a deterministic VC-to-HLR-to-procedure/oracle matrix from the SpecIR.
FILE PATH:
models/sw_docs/types/views/test_execution_matrix.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-030
CSU-158: Test Results Matrix View
DESCRIPTION:
Defines the TEST_RESULTS_MATRIX view generating a table of VC-to-TR traceability with pass/fail result status.
FILE PATH:
models/sw_docs/types/views/test_results_matrix.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-030
CSU-159: Traceability Matrix View
DESCRIPTION:
Defines the TRACEABILITY_MATRIX view generating a table showing the full HLR-to-VC-to-TR traceability chain with test results.
FILE PATH:
models/sw_docs/types/views/traceability_matrix.lua
LANGUAGE:
Lua
TRACEABILITY:
CSC-030