Summary
Add a template that extracts structured invariants (MUST/SHOULD/MAY constraints, state transitions, timing assumptions, error conditions) from existing specifications or source code. This is Phase 3 of the specification integrity roadmap.
Motivation
Invariant extraction is foundational for two use cases:
- Feeding audit templates — extracting structured requirements from an RFC or legacy spec so they can be audited with
audit-traceability or audit-code-compliance
- Standalone analysis — understanding what a spec or codebase actually guarantees, in a machine-readable format
Scope
New components needed:
- Template:
extract-invariants — consumes specification text or source code; produces a structured invariant set (requirements-document format with MUST/SHOULD/MAY classification)
- Protocol (optional): May need a thin
invariant-extraction reasoning protocol, or may be able to compose requirements-elicitation + requirements-from-implementation depending on whether input is spec or code
Reused components:
specification-analyst or reverse-engineer persona (depending on input type)
requirements-doc format (invariants are structured requirements)
anti-hallucination + self-verification guardrails
Open questions
- Should this be one template handling both spec and code inputs, or two separate templates?
- Should the output format be
requirements-doc or a new invariant-set format with additional structure (e.g., state machine notation)?
- How does this relate to the existing
reverse-engineer-requirements template? Is this an extension or a separate concern?
Acceptance criteria
Summary
Add a template that extracts structured invariants (MUST/SHOULD/MAY constraints, state transitions, timing assumptions, error conditions) from existing specifications or source code. This is Phase 3 of the specification integrity roadmap.
Motivation
Invariant extraction is foundational for two use cases:
audit-traceabilityoraudit-code-complianceScope
New components needed:
extract-invariants— consumes specification text or source code; produces a structured invariant set (requirements-document format with MUST/SHOULD/MAY classification)invariant-extractionreasoning protocol, or may be able to composerequirements-elicitation+requirements-from-implementationdepending on whether input is spec or codeReused components:
specification-analystorreverse-engineerpersona (depending on input type)requirements-docformat (invariants are structured requirements)anti-hallucination+self-verificationguardrailsOpen questions
requirements-docor a newinvariant-setformat with additional structure (e.g., state machine notation)?reverse-engineer-requirementstemplate? Is this an extension or a separate concern?Acceptance criteria
tests/validate-manifest.pypassesdocs/scenarios.md