vibe.review.requirements¶
Requirement loading and management for VIBE Review.
RequirementLoader parses requirement definitions from template config.yml files and manages caching with embeddings in the database.
Requirement Applicability ("Template is Truth"): Requirement applicability is NOT determined by conditions in config.yml. Instead, the template.md uses Jinja conditionals and the req() function to control which requirements apply:
```jinja2
{% if critical_service %}
- {{ req('D5-1') }}: Unlimited audit rights
{% endif %}
```
When the template is probed with context (e.g., critical_service=True),
only requirements that are actually referenced via req() are applicable.
YAML Format Examples:
Pattern 1 - Requirements nested in groups:
groups:
audit_rights:
title: Audit Rights
description: Requirements related to audit and inspection rights
requirements:
D5-1:
label: Unlimited audit rights
description: The contract must grant unrestricted audit rights.
reference: "DORA Article 30(3)(e)"
Pattern 2 - Top-level requirements (like questions):
groups:
audit_rights:
title: Audit Rights
requirements:
D5-1:
label: Unlimited audit rights
description: The contract must grant unrestricted audit rights.
reference: "DORA Article 30(3)(e)"
groups: [audit_rights]
Both patterns can be combined in the same config.
RequirementSet ¶
A complete set of requirements loaded from a template.
| Attributes: |
|
|---|
get_requirements_by_group ¶
get_requirements_by_group(group_id: str) -> list[Requirement]
Get all requirements belonging to a group.
get_requirements_by_ids ¶
get_requirements_by_ids(req_ids: set[str]) -> list[Requirement]
Get requirements by their IDs.
Used with template probing - the template determines which requirements are applicable by calling req('D5-1') etc., and probing collects those IDs.
| Parameters: |
|
|---|
| Returns: |
|
|---|
RequirementLoader ¶
Loads requirement definitions from VIBE template configurations.
Requirements are defined in config.yml under requirements (preferred) or
legacy review_requirements. Group definitions live at top-level groups.
The loader handles:
- Parsing YAML definitions
- Validating requirement structure
- Caching requirements with embeddings in database
- Cache invalidation based on content hash
__init__ ¶
__init__(embedding_provider: EmbeddingProvider | None = None) -> None
Initialize the loader.
| Parameters: |
|
|---|
load_from_dict ¶
load_from_dict(template_id: str, config: dict[str, Any]) -> RequirementSet
Load requirements from a parsed config dictionary.
Supports two patterns:
Pattern 1 - Requirements nested in groups:
groups:
audit_rights:
title: "Audit Rights"
requirements:
D5-1:
label: "..."
Pattern 2 - Top-level requirements (like questions):
requirements:
D5-1:
label: "..."
groups: [audit_rights]
| Parameters: |
|
|---|
| Returns: |
|
|---|
| Raises: |
|
|---|
load_from_yaml ¶
load_from_yaml(template_id: str, yaml_content: str) -> RequirementSet
Load requirements from YAML string.
| Parameters: |
|
|---|
| Returns: |
|
|---|
load_from_file ¶
load_from_file(template_id: str, file_path: str) -> RequirementSet
Load requirements from a config.yml file.
| Parameters: |
|
|---|
| Returns: |
|
|---|
load_with_cache ¶
load_with_cache(template_id: str, config: dict[str, Any], force_refresh: bool = False) -> RequirementSet
Load requirements with database caching and embeddings.
This method: 1. Computes content hash for cache invalidation 2. Checks database for cached requirements with valid hash 3. Computes embeddings for new/changed requirements 4. Updates database cache
| Parameters: |
|
|---|
| Returns: |
|
|---|