Requirements Generation
Requirement Generation Slice
This feature manages the generation of system requirements and sub-system requirements using AI. It operates completely decoupled from the database, performing pure business logic driven by Wolverine messages.
Architectural Components
1. RequirementGenerationHandler
The entry point for the requirement feature worker.
- It consumes a
RequirementGenerationRequestedevent. - It uses the provided
InputClaimCheckKeyto retrieve aRequirementGenerationPayloadfrom the S3 Claim-Check Store. - It maps and applies the project’s LLM presets (
AiPresetConfigs) to theIAIService. - It delegates the core processing to the
RequirementGenerationCore. - Finally, it saves the generation result back to the Claim-Check Store and returns a
RequirementGenerationCompletedmessage to Wolverine.
2. RequirementGenerationCore
The pure logic core that drives the AI generation.
- Deduplication: Ensures that generated requirements are unique by comparing normalized body text (Jaccard similarity > 80%).
- Formatting: Assigns unique, sequential IDs to the generated requirements based on the document section title (e.g.,
REQ-SEC-001). - Prompt Rendering: Uses
PromptLibraryto combine the system prompts with context data. - Handling Source Fallback: If no source files are available, it defaults to validating and improving a single existing requirement.
- State Transformation: Packages the generated items into
RequirementBlockCreateandRequirementBlockUpdatestructures so the API knows exactly how to apply the changes to the relational database.
Generation Sequence
The following diagram illustrates how the Requirements feature processes a request from the API.
sequenceDiagram participant API as API Apply/Prepare participant Broker as RabbitMQ participant S3 as Claim-Check Store participant Handler as RequirementGenerationHandler participant Core as RequirementGenerationCore participant AI as IAIService API->>S3: PutAsync(RequirementGenerationPayload) API->>Broker: Publish RequirementGenerationRequested Broker->>Handler: Consume Message Handler->>S3: GetAsync(PayloadKey) Handler->>Core: GenerateAsync(Payload, IAIService) alt Has Source Files Core->>AI: GenerateAsync(SystemPrompt, Context) AI-->>Core: JSON Requirements Array Core->>Core: DeduplicateRequirements() Core->>Core: Assign Sequential IDs Core-->>Handler: RequirementGenerationResult (Updates & Creates) else No Source Files Core->>AI: ValidateSingle(ExistingRequirement) AI-->>Core: Improved Requirement Text Core-->>Handler: RequirementGenerationResult (Single Update) end Handler->>S3: PutAsync(RequirementGenerationResult) Handler->>Broker: Publish RequirementGenerationCompleted Broker->>API: Deliver Completed Event
Business Intent
The goal of the Requirements Generation feature is to ensure that functional, structural, and safety requirements are derived effectively from the actual system context or source files. It guarantees that:
- Every requirement is uniquely identifiable.
- Duplicate descriptions are purged automatically to maintain a clean requirement specification.
- A consistent safety level (e.g., QM) and status (e.g., Reviewed) are enforced out-of-the-box.
- When generating multiple requirements from a single block, it prepares one “Update” to mutate the existing block, and multiple “Creates” for its siblings, providing a seamless data-entry transition in the UI.