Documents Feature (Document Factory)

The Documents Feature is the core component of MILTON. It handles the lifecycle of documents, dynamic sections, block instantiation, templates, traceability, and AI-powered text generation.

Overview

The “Document Factory” uses a robust hierarchical data model to build complex system documentation formats like SRS (Software Requirements Specification), SVD (Software Version Description), STD (Software Test Description), and STR (Software Test Report).

Endpoints

Document Endpoints (DocumentEndpoints.cs)

  • GET /api/documents - Lists all documents with summaries (statuses, block counts).
  • GET /api/documents/blocks/{BlockId}/tracelinks - Retrieves traceability link data for a given block.

Template Endpoints (TemplateEndpoints.cs)

  • POST /api/documents/templates - Creates a new reusable document template.
  • POST /api/documents/templates/instantiate - Instantiates a document from a defined template and triggers the processing saga.

Component Handlers (The “Workers”)

Block processing handlers form the executable units of the document pipeline:

  • RepoScannerHandler (The “Exploder”): Scans repository filesystems for source files, clusters them using AI or directory heuristics, and spawns structured sub-sections.
  • RequirementGeneratorHandler (The “Leaf Worker”): Validates and enriches Requirement blocks utilizing AI contexts mapped against specific source code sections.
  • TestCaseGeneratorHandler (The “Test Generator”): Iterates over Requirement blocks to generate matching test cases and auto-links them for absolute traceability.

Orchestration

The instantiation and AI generation of documents is extremely state-dependent. Thus, it operates heavily with Wolverine Sagas. When a template is instantiated, InstantiateDocumentHandler breaks out the blueprint into a materialized PostgreSQL hierarchy, publishing the DocumentCreatedEvent, which is ingested by the background saga engine (DocumentProcessingSaga) to start recursive, methodical block processing.