specfact-cli 0.49.1__py3-none-any.whl → 0.50.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- specfact_cli/__init__.py +1 -1
- specfact_cli/cli.py +3 -1
- specfact_cli/models/project.py +10 -1
- specfact_cli/modules/init/module-package.yaml +3 -3
- specfact_cli/modules/init/src/first_run_selection.py +5 -0
- specfact_cli/registry/module_grouping.py +8 -1
- specfact_cli/registry/module_packages.py +11 -0
- specfact_cli/requirements/__init__.py +28 -0
- specfact_cli/requirements/context.py +330 -0
- {specfact_cli-0.49.1.dist-info → specfact_cli-0.50.2.dist-info}/METADATA +3 -2
- {specfact_cli-0.49.1.dist-info → specfact_cli-0.50.2.dist-info}/RECORD +14 -12
- {specfact_cli-0.49.1.dist-info → specfact_cli-0.50.2.dist-info}/WHEEL +0 -0
- {specfact_cli-0.49.1.dist-info → specfact_cli-0.50.2.dist-info}/entry_points.txt +0 -0
- {specfact_cli-0.49.1.dist-info → specfact_cli-0.50.2.dist-info}/licenses/LICENSE +0 -0
specfact_cli/__init__.py
CHANGED
specfact_cli/cli.py
CHANGED
|
@@ -87,6 +87,7 @@ KNOWN_BUNDLE_GROUP_OR_SHIM_NAMES: frozenset[str] = frozenset(
|
|
|
87
87
|
"project",
|
|
88
88
|
"spec",
|
|
89
89
|
"govern",
|
|
90
|
+
"requirements",
|
|
90
91
|
"contract",
|
|
91
92
|
"sdd",
|
|
92
93
|
"generate",
|
|
@@ -110,6 +111,7 @@ _INVOKED_TO_MARKETPLACE_MODULE: dict[str, str] = {
|
|
|
110
111
|
"govern": "nold-ai/specfact-govern",
|
|
111
112
|
"enforce": "nold-ai/specfact-govern",
|
|
112
113
|
"patch": "nold-ai/specfact-govern",
|
|
114
|
+
"requirements": "nold-ai/specfact-requirements",
|
|
113
115
|
}
|
|
114
116
|
|
|
115
117
|
# Removed flat root aliases -> canonical grouped replacement (see docs/migration/migration-guide.md).
|
|
@@ -418,7 +420,7 @@ Transform your development workflow with automated quality gates,
|
|
|
418
420
|
runtime contract validation, and state machine workflows.
|
|
419
421
|
|
|
420
422
|
Run **specfact init** or **specfact module install** to add workflow bundles
|
|
421
|
-
(backlog, code, project, spec, govern).
|
|
423
|
+
(backlog, code, project, spec, govern, requirements).
|
|
422
424
|
|
|
423
425
|
**Backlog Management**: Use `specfact backlog refine` for AI-assisted template-driven
|
|
424
426
|
refinement of backlog items from GitHub Issues, Azure DevOps, and other tools.
|
specfact_cli/models/project.py
CHANGED
|
@@ -559,7 +559,13 @@ class ProjectBundle(BaseModel):
|
|
|
559
559
|
if progress_callback:
|
|
560
560
|
progress_callback(current + 1, total_artifacts, "bundle.manifest.yaml")
|
|
561
561
|
manifest_data = load_structured_file(manifest_path)
|
|
562
|
-
|
|
562
|
+
if not isinstance(manifest_data, dict):
|
|
563
|
+
raise ValueError("Bundle manifest must be a mapping")
|
|
564
|
+
manifest_mapping = cast(dict[str, Any], manifest_data)
|
|
565
|
+
extensions_data = manifest_mapping.get("extensions", {})
|
|
566
|
+
if not isinstance(extensions_data, dict):
|
|
567
|
+
raise ValueError("ProjectBundle extensions must be a mapping")
|
|
568
|
+
manifest = BundleManifest.model_validate(manifest_mapping)
|
|
563
569
|
current += 1
|
|
564
570
|
|
|
565
571
|
slots = _BundleLoadSlots()
|
|
@@ -585,6 +591,7 @@ class ProjectBundle(BaseModel):
|
|
|
585
591
|
features=slots.features,
|
|
586
592
|
clarifications=slots.clarifications,
|
|
587
593
|
change_tracking=change_tracking,
|
|
594
|
+
extensions=dict(extensions_data),
|
|
588
595
|
)
|
|
589
596
|
|
|
590
597
|
@beartype
|
|
@@ -663,6 +670,8 @@ class ProjectBundle(BaseModel):
|
|
|
663
670
|
progress_callback(total_artifacts, total_artifacts, "bundle.manifest.yaml")
|
|
664
671
|
manifest_path = bundle_dir / "bundle.manifest.yaml"
|
|
665
672
|
manifest_data = self.manifest.model_dump(mode="json")
|
|
673
|
+
if self.extensions:
|
|
674
|
+
manifest_data["extensions"] = self.extensions
|
|
666
675
|
if num_features > 1000:
|
|
667
676
|
import json
|
|
668
677
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
name: init
|
|
2
|
-
version: 0.1.
|
|
2
|
+
version: 0.1.43
|
|
3
3
|
commands:
|
|
4
4
|
- init
|
|
5
5
|
category: core
|
|
@@ -17,5 +17,5 @@ publisher:
|
|
|
17
17
|
description: Initialize SpecFact workspace and bootstrap local configuration.
|
|
18
18
|
license: Apache-2.0
|
|
19
19
|
integrity:
|
|
20
|
-
checksum: sha256:
|
|
21
|
-
signature:
|
|
20
|
+
checksum: sha256:0addb2798172b9d6081de452c44e48b02effbffd4d6d1ba6528b20b17da366c6
|
|
21
|
+
signature: UsuEKTYI/jRHxXJGJ/WRkN79HhbjKaZPiXCFyjmGoHTytV0cHFDhgdKnc2POh9n70NwD50GecvZJNoCFlflBBQ==
|
|
@@ -146,6 +146,7 @@ _INSTALL_ALL_BUNDLES: tuple[str, ...] = (
|
|
|
146
146
|
"specfact-codebase",
|
|
147
147
|
"specfact-spec",
|
|
148
148
|
"specfact-govern",
|
|
149
|
+
"specfact-requirements",
|
|
149
150
|
)
|
|
150
151
|
|
|
151
152
|
# Includes marketplace-only bundles referenced by profiles (e.g. specfact-code-review).
|
|
@@ -158,6 +159,7 @@ MARKETPLACE_ONLY_BUNDLES: dict[str, str] = {
|
|
|
158
159
|
"specfact-codebase": "nold-ai/specfact-codebase",
|
|
159
160
|
"specfact-spec": "nold-ai/specfact-spec",
|
|
160
161
|
"specfact-govern": "nold-ai/specfact-govern",
|
|
162
|
+
"specfact-requirements": "nold-ai/specfact-requirements",
|
|
161
163
|
"specfact-code-review": "nold-ai/specfact-code-review",
|
|
162
164
|
}
|
|
163
165
|
|
|
@@ -170,6 +172,7 @@ BUNDLE_ALIAS_TO_CANONICAL: dict[str, str] = {
|
|
|
170
172
|
"code_review": "specfact-code-review",
|
|
171
173
|
"spec": "specfact-spec",
|
|
172
174
|
"govern": "specfact-govern",
|
|
175
|
+
"requirements": "specfact-requirements",
|
|
173
176
|
}
|
|
174
177
|
|
|
175
178
|
# Optional: names of *bundled* module dirs shipped inside this CLI wheel (see module_installer). Workflow
|
|
@@ -180,6 +183,7 @@ BUNDLE_TO_MODULE_NAMES: dict[str, list[str]] = {
|
|
|
180
183
|
"specfact-codebase": [],
|
|
181
184
|
"specfact-spec": [],
|
|
182
185
|
"specfact-govern": [],
|
|
186
|
+
"specfact-requirements": [],
|
|
183
187
|
"specfact-code-review": [],
|
|
184
188
|
}
|
|
185
189
|
|
|
@@ -194,6 +198,7 @@ BUNDLE_DISPLAY: dict[str, str] = {
|
|
|
194
198
|
"specfact-codebase": "Codebase quality (analyze, drift, validate, repro)",
|
|
195
199
|
"specfact-spec": "Spec & API (contract, spec, sdd, generate)",
|
|
196
200
|
"specfact-govern": "Governance (enforce, patch)",
|
|
201
|
+
"specfact-requirements": "Requirements evidence (requirements)",
|
|
197
202
|
"specfact-code-review": "Scored code review (code review gate)",
|
|
198
203
|
}
|
|
199
204
|
|
|
@@ -8,17 +8,21 @@ from icontract import ensure, require
|
|
|
8
8
|
from specfact_cli.models.module_package import ModulePackageMetadata
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
VALID_CATEGORIES = frozenset({"core", "project", "backlog", "codebase", "spec", "govern"})
|
|
11
|
+
VALID_CATEGORIES = frozenset({"core", "project", "backlog", "codebase", "spec", "govern", "requirements"})
|
|
12
12
|
CATEGORY_TO_GROUP_COMMAND: dict[str, str] = {
|
|
13
13
|
"project": "project",
|
|
14
14
|
"backlog": "backlog",
|
|
15
15
|
"codebase": "code",
|
|
16
16
|
"spec": "spec",
|
|
17
17
|
"govern": "govern",
|
|
18
|
+
"requirements": "requirements",
|
|
18
19
|
}
|
|
19
20
|
LEGACY_GROUP_COMMAND_ALIASES: dict[tuple[str, str], str] = {
|
|
20
21
|
("codebase", "codebase"): "code",
|
|
21
22
|
}
|
|
23
|
+
LEGACY_CATEGORY_ALIASES: dict[tuple[str, str], str] = {
|
|
24
|
+
("project", "requirements"): "requirements",
|
|
25
|
+
}
|
|
22
26
|
|
|
23
27
|
|
|
24
28
|
class ModuleManifestError(Exception):
|
|
@@ -71,6 +75,9 @@ def normalize_legacy_bundle_group_command(meta: ModulePackageMetadata) -> Module
|
|
|
71
75
|
"""Normalize known legacy bundle group values to canonical grouped commands."""
|
|
72
76
|
if meta.category is None or meta.bundle_group_command is None:
|
|
73
77
|
return meta
|
|
78
|
+
normalized_category = LEGACY_CATEGORY_ALIASES.get((meta.category, meta.bundle_group_command))
|
|
79
|
+
if normalized_category is not None:
|
|
80
|
+
meta.category = normalized_category
|
|
74
81
|
normalized = LEGACY_GROUP_COMMAND_ALIASES.get((meta.category, meta.bundle_group_command))
|
|
75
82
|
if normalized is not None:
|
|
76
83
|
meta.bundle_group_command = normalized
|
|
@@ -1252,6 +1252,17 @@ def _build_bundle_to_group() -> dict[str, tuple[str, str, Any]]:
|
|
|
1252
1252
|
"specfact-project": ("project", "Project lifecycle commands.", build_project_app),
|
|
1253
1253
|
"specfact-spec": ("spec", "Spec and contract commands: contract, api, sdd, generate.", build_spec_app),
|
|
1254
1254
|
"specfact-govern": ("govern", "Governance and quality gates: enforce, patch.", build_govern_app),
|
|
1255
|
+
"specfact-requirements": (
|
|
1256
|
+
"requirements",
|
|
1257
|
+
"Requirements evidence commands.",
|
|
1258
|
+
lambda: build_member_group(
|
|
1259
|
+
name="requirements",
|
|
1260
|
+
help_text="Requirements evidence commands.",
|
|
1261
|
+
members=(("requirements", "requirements"),),
|
|
1262
|
+
flatten_same_name="requirements",
|
|
1263
|
+
install_hint_module="nold-ai/specfact-requirements",
|
|
1264
|
+
),
|
|
1265
|
+
),
|
|
1255
1266
|
}
|
|
1256
1267
|
|
|
1257
1268
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""Requirements context adapter helpers."""
|
|
2
|
+
|
|
3
|
+
from specfact_cli.requirements.context import (
|
|
4
|
+
RequirementContextAdapter,
|
|
5
|
+
RequirementContextCoverageSummary,
|
|
6
|
+
RequirementContextDiagnostic,
|
|
7
|
+
RequirementContextDiagnosticSeverity,
|
|
8
|
+
RequirementContextImportResult,
|
|
9
|
+
attach_requirements_to_bundle,
|
|
10
|
+
inspect_requirement_context_coverage,
|
|
11
|
+
load_requirements_from_bundle,
|
|
12
|
+
normalize_requirement_records,
|
|
13
|
+
validate_requirement_context,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
__all__ = [
|
|
18
|
+
"RequirementContextAdapter",
|
|
19
|
+
"RequirementContextCoverageSummary",
|
|
20
|
+
"RequirementContextDiagnostic",
|
|
21
|
+
"RequirementContextDiagnosticSeverity",
|
|
22
|
+
"RequirementContextImportResult",
|
|
23
|
+
"attach_requirements_to_bundle",
|
|
24
|
+
"inspect_requirement_context_coverage",
|
|
25
|
+
"load_requirements_from_bundle",
|
|
26
|
+
"normalize_requirement_records",
|
|
27
|
+
"validate_requirement_context",
|
|
28
|
+
]
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
"""Core requirements context adapter contracts and helpers."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from collections.abc import Mapping, Sequence
|
|
6
|
+
from enum import StrEnum
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Any, Literal, Protocol, cast, get_args
|
|
9
|
+
|
|
10
|
+
from beartype import beartype
|
|
11
|
+
from icontract import ensure, require
|
|
12
|
+
from pydantic import BaseModel, ConfigDict, Field, ValidationError
|
|
13
|
+
|
|
14
|
+
from specfact_cli.models.project import ProjectBundle
|
|
15
|
+
from specfact_cli.models.requirements import (
|
|
16
|
+
RequirementEvidenceLinkType,
|
|
17
|
+
RequirementInput,
|
|
18
|
+
load_requirements_input_extension,
|
|
19
|
+
requirements_input_extension_payload,
|
|
20
|
+
)
|
|
21
|
+
from specfact_cli.models.validation import ValidationReport
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
RequirementContextValidationProfile = Literal[
|
|
25
|
+
"solo",
|
|
26
|
+
"startup",
|
|
27
|
+
"team",
|
|
28
|
+
"enterprise",
|
|
29
|
+
"strict",
|
|
30
|
+
"solo_developer",
|
|
31
|
+
"api_first_team",
|
|
32
|
+
"enterprise_full_stack",
|
|
33
|
+
]
|
|
34
|
+
KNOWN_REQUIREMENT_CONTEXT_PROFILES: frozenset[str] = frozenset(get_args(RequirementContextValidationProfile))
|
|
35
|
+
STRICT_REQUIREMENT_CONTEXT_PROFILES: frozenset[str] = frozenset({"enterprise", "strict", "enterprise_full_stack"})
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class RequirementContextDiagnosticSeverity(StrEnum):
|
|
39
|
+
"""Severity for bounded requirements context diagnostics."""
|
|
40
|
+
|
|
41
|
+
INFO = "info"
|
|
42
|
+
WARNING = "warning"
|
|
43
|
+
ERROR = "error"
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@beartype
|
|
47
|
+
class RequirementContextDiagnostic(BaseModel):
|
|
48
|
+
"""Bounded diagnostic emitted while importing requirement context."""
|
|
49
|
+
|
|
50
|
+
model_config = ConfigDict(use_enum_values=True)
|
|
51
|
+
|
|
52
|
+
severity: RequirementContextDiagnosticSeverity = Field(..., description="Diagnostic severity")
|
|
53
|
+
code: str = Field(..., min_length=1, description="Stable diagnostic code")
|
|
54
|
+
message: str = Field(..., min_length=1, description="Human-readable diagnostic message")
|
|
55
|
+
source_locator: str | None = Field(default=None, description="Optional upstream source locator")
|
|
56
|
+
requirement_id: str | None = Field(default=None, description="Best-effort requirement identifier")
|
|
57
|
+
record_index: int | None = Field(
|
|
58
|
+
default=None,
|
|
59
|
+
ge=0,
|
|
60
|
+
description="Zero-based source record index when available",
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@beartype
|
|
65
|
+
class RequirementContextImportResult(BaseModel):
|
|
66
|
+
"""Normalized requirement import result plus bounded diagnostics."""
|
|
67
|
+
|
|
68
|
+
requirements: list[RequirementInput] = Field(default_factory=list, description="Normalized requirement records")
|
|
69
|
+
diagnostics: list[RequirementContextDiagnostic] = Field(
|
|
70
|
+
default_factory=list,
|
|
71
|
+
description="Import diagnostics for records that could not be normalized",
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
@beartype
|
|
76
|
+
class RequirementContextCoverageSummary(BaseModel):
|
|
77
|
+
"""Machine-readable coverage summary for normalized requirement inputs."""
|
|
78
|
+
|
|
79
|
+
total_requirements: int = Field(..., ge=0, description="Total normalized requirements")
|
|
80
|
+
with_business_rules: int = Field(..., ge=0, description="Requirements with business rules")
|
|
81
|
+
with_constraints: int = Field(..., ge=0, description="Requirements with constraints")
|
|
82
|
+
with_evidence_links: int = Field(..., ge=0, description="Requirements with evidence links")
|
|
83
|
+
with_architecture_links: int = Field(..., ge=0, description="Requirements linked to architecture evidence")
|
|
84
|
+
with_code_links: int = Field(..., ge=0, description="Requirements linked to code evidence")
|
|
85
|
+
with_test_links: int = Field(..., ge=0, description="Requirements linked to test evidence")
|
|
86
|
+
missing_evidence_requirement_ids: list[str] = Field(
|
|
87
|
+
default_factory=list,
|
|
88
|
+
description="Requirement IDs missing downstream evidence links",
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class RequirementContextAdapter(Protocol):
|
|
93
|
+
"""Protocol for module adapters that import requirement-like sources."""
|
|
94
|
+
|
|
95
|
+
@beartype
|
|
96
|
+
@require(lambda source: isinstance(source, Path), "source must be a Path")
|
|
97
|
+
def import_requirements(self, source: Path, config: Mapping[str, Any]) -> RequirementContextImportResult:
|
|
98
|
+
"""Import source-attributed requirement records from an upstream source."""
|
|
99
|
+
raise NotImplementedError
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def _all_records_supported(records: Sequence[RequirementInput | Mapping[str, Any]]) -> bool:
|
|
103
|
+
return all(isinstance(record, RequirementInput | Mapping) for record in records)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def _normalization_result_valid(result: RequirementContextImportResult) -> bool:
|
|
107
|
+
return all(isinstance(requirement, RequirementInput) for requirement in result.requirements)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def _record_requirement_id(record: RequirementInput | Mapping[str, Any]) -> str | None:
|
|
111
|
+
if isinstance(record, RequirementInput):
|
|
112
|
+
return _optional_text(record.requirement_id)
|
|
113
|
+
value = record.get("requirement_id")
|
|
114
|
+
return _optional_text(value) if isinstance(value, str) and value else None
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def _validation_error_message(exc: ValidationError) -> str:
|
|
118
|
+
first_error = exc.errors()[0] if exc.errors() else {"msg": str(exc)}
|
|
119
|
+
location = ".".join(str(part) for part in first_error.get("loc", ()))
|
|
120
|
+
message = str(first_error.get("msg", "invalid requirement input")) or "invalid requirement input"
|
|
121
|
+
return f"{location}: {message}" if location else message
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def _optional_text(value: str | None) -> str | None:
|
|
125
|
+
if not value:
|
|
126
|
+
return None
|
|
127
|
+
realize = getattr(value, "__ch_realize__", None)
|
|
128
|
+
if callable(realize):
|
|
129
|
+
realized = realize()
|
|
130
|
+
return realized if isinstance(realized, str) else str(realized)
|
|
131
|
+
return value
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def _profile_nonempty(profile: str) -> bool:
|
|
135
|
+
return profile.strip() != ""
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def _profile_supported(profile: str) -> bool:
|
|
139
|
+
return profile in KNOWN_REQUIREMENT_CONTEXT_PROFILES
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def _source_locator_supported(source_locator: str | None) -> bool:
|
|
143
|
+
return source_locator is None or type(source_locator) is str
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def _coverage_summary_consistent(result: RequirementContextCoverageSummary) -> bool:
|
|
147
|
+
return result.total_requirements >= len(result.missing_evidence_requirement_ids)
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def _requirements_with_evidence_link_type(
|
|
151
|
+
requirements: Sequence[RequirementInput],
|
|
152
|
+
link_type: RequirementEvidenceLinkType,
|
|
153
|
+
) -> int:
|
|
154
|
+
count = 0
|
|
155
|
+
for requirement in requirements:
|
|
156
|
+
if any(link.link_type == link_type for link in requirement.evidence_links):
|
|
157
|
+
count += 1
|
|
158
|
+
return max(0, count)
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def _missing_evidence_requirement_ids(requirements: Sequence[RequirementInput]) -> list[str]:
|
|
162
|
+
return [requirement.requirement_id for requirement in requirements if not requirement.evidence_links]
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def _invalid_requirement_diagnostic(
|
|
166
|
+
exc: ValidationError,
|
|
167
|
+
record: RequirementInput | Mapping[str, Any],
|
|
168
|
+
source_locator: str | None,
|
|
169
|
+
record_index: int,
|
|
170
|
+
) -> RequirementContextDiagnostic:
|
|
171
|
+
return RequirementContextDiagnostic(
|
|
172
|
+
severity=RequirementContextDiagnosticSeverity.ERROR,
|
|
173
|
+
code="invalid_requirement_input",
|
|
174
|
+
message=_validation_error_message(exc),
|
|
175
|
+
source_locator=_optional_text(source_locator),
|
|
176
|
+
requirement_id=_record_requirement_id(record),
|
|
177
|
+
record_index=record_index,
|
|
178
|
+
)
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
@beartype
|
|
182
|
+
@require(_all_records_supported, "records must be RequirementInput or mapping values")
|
|
183
|
+
@require(_source_locator_supported, "source_locator must be text when provided")
|
|
184
|
+
@ensure(_normalization_result_valid)
|
|
185
|
+
def normalize_requirement_records(
|
|
186
|
+
records: Sequence[RequirementInput | Mapping[str, Any]],
|
|
187
|
+
*,
|
|
188
|
+
source_locator: str | None = None,
|
|
189
|
+
) -> RequirementContextImportResult:
|
|
190
|
+
"""Normalize source-attributed requirement records with bounded diagnostics."""
|
|
191
|
+
normalized: list[RequirementInput] = []
|
|
192
|
+
diagnostics: list[RequirementContextDiagnostic] = []
|
|
193
|
+
|
|
194
|
+
for record_index, record in enumerate(records):
|
|
195
|
+
if isinstance(record, RequirementInput):
|
|
196
|
+
normalized.append(record)
|
|
197
|
+
continue
|
|
198
|
+
try:
|
|
199
|
+
normalized.append(RequirementInput.model_validate(record))
|
|
200
|
+
except ValidationError as exc:
|
|
201
|
+
diagnostics.append(_invalid_requirement_diagnostic(exc, record, source_locator, record_index))
|
|
202
|
+
|
|
203
|
+
return RequirementContextImportResult(requirements=normalized, diagnostics=diagnostics)
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
@beartype
|
|
207
|
+
@require(lambda bundle: isinstance(bundle, ProjectBundle), "bundle must be a ProjectBundle")
|
|
208
|
+
@require(lambda requirements: all(isinstance(record, RequirementInput) for record in requirements))
|
|
209
|
+
@ensure(lambda result: isinstance(result, ProjectBundle))
|
|
210
|
+
def attach_requirements_to_bundle(bundle: ProjectBundle, requirements: Sequence[RequirementInput]) -> ProjectBundle:
|
|
211
|
+
"""Store normalized requirements on the existing requirements.inputs extension."""
|
|
212
|
+
bundle.set_extension("requirements", "inputs", requirements_input_extension_payload(list(requirements)))
|
|
213
|
+
return bundle
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
@beartype
|
|
217
|
+
@require(lambda bundle: isinstance(bundle, ProjectBundle), "bundle must be a ProjectBundle")
|
|
218
|
+
@ensure(lambda result: all(isinstance(record, RequirementInput) for record in result))
|
|
219
|
+
def load_requirements_from_bundle(bundle: ProjectBundle) -> list[RequirementInput]:
|
|
220
|
+
"""Load normalized requirements from the requirements.inputs extension."""
|
|
221
|
+
payload = bundle.get_extension("requirements", "inputs", default=None)
|
|
222
|
+
if payload is None:
|
|
223
|
+
return []
|
|
224
|
+
if not isinstance(payload, dict):
|
|
225
|
+
raise ValueError("requirements.inputs extension must be a mapping payload")
|
|
226
|
+
return load_requirements_input_extension(cast(dict[str, Any], payload))
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
@beartype
|
|
230
|
+
@require(lambda requirements: all(isinstance(record, RequirementInput) for record in requirements))
|
|
231
|
+
@ensure(_coverage_summary_consistent)
|
|
232
|
+
def inspect_requirement_context_coverage(
|
|
233
|
+
requirements: Sequence[RequirementInput],
|
|
234
|
+
) -> RequirementContextCoverageSummary:
|
|
235
|
+
"""Return machine-readable coverage counts for normalized requirement inputs."""
|
|
236
|
+
requirement_list = list(requirements)
|
|
237
|
+
return RequirementContextCoverageSummary(
|
|
238
|
+
total_requirements=len(requirement_list),
|
|
239
|
+
with_business_rules=sum(bool(requirement.business_rules) for requirement in requirement_list),
|
|
240
|
+
with_constraints=sum(bool(requirement.constraints) for requirement in requirement_list),
|
|
241
|
+
with_evidence_links=sum(bool(requirement.evidence_links) for requirement in requirement_list),
|
|
242
|
+
with_architecture_links=_requirements_with_evidence_link_type(
|
|
243
|
+
requirement_list,
|
|
244
|
+
RequirementEvidenceLinkType.ARCHITECTURE,
|
|
245
|
+
),
|
|
246
|
+
with_code_links=_requirements_with_evidence_link_type(requirement_list, RequirementEvidenceLinkType.CODE),
|
|
247
|
+
with_test_links=_requirements_with_evidence_link_type(requirement_list, RequirementEvidenceLinkType.TEST),
|
|
248
|
+
missing_evidence_requirement_ids=_missing_evidence_requirement_ids(requirement_list),
|
|
249
|
+
)
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
def _missing_evidence_severity(profile: RequirementContextValidationProfile) -> str:
|
|
253
|
+
return "error" if profile in STRICT_REQUIREMENT_CONTEXT_PROFILES else "warning"
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
def _empty_requirements_report() -> ValidationReport:
|
|
257
|
+
return ValidationReport(
|
|
258
|
+
status="warnings",
|
|
259
|
+
violations=[
|
|
260
|
+
{
|
|
261
|
+
"severity": "warning",
|
|
262
|
+
"message": "No requirements.inputs records are attached to the bundle.",
|
|
263
|
+
"location": "requirements.inputs",
|
|
264
|
+
}
|
|
265
|
+
],
|
|
266
|
+
summary={"total_checks": 1, "passed": 0, "failed": 0, "warnings": 1},
|
|
267
|
+
)
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
def _missing_evidence_violations(
|
|
271
|
+
coverage: RequirementContextCoverageSummary,
|
|
272
|
+
*,
|
|
273
|
+
severity: str,
|
|
274
|
+
) -> list[dict[str, str]]:
|
|
275
|
+
return [
|
|
276
|
+
{
|
|
277
|
+
"severity": severity,
|
|
278
|
+
"message": "Requirement input has no downstream evidence links.",
|
|
279
|
+
"location": f"requirements.inputs[{requirement_id}].evidence_links",
|
|
280
|
+
}
|
|
281
|
+
for requirement_id in coverage.missing_evidence_requirement_ids
|
|
282
|
+
]
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
def _validation_status(failed: int, warnings: int) -> Literal["passed", "failed", "warnings"]:
|
|
286
|
+
if failed:
|
|
287
|
+
return "failed"
|
|
288
|
+
if warnings:
|
|
289
|
+
return "warnings"
|
|
290
|
+
return "passed"
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
def _validation_summary(
|
|
294
|
+
requirements: Sequence[RequirementInput],
|
|
295
|
+
coverage: RequirementContextCoverageSummary,
|
|
296
|
+
violations: Sequence[Mapping[str, str]],
|
|
297
|
+
) -> dict[str, int]:
|
|
298
|
+
failed = sum(violation["severity"] == "error" for violation in violations)
|
|
299
|
+
warnings = sum(violation["severity"] == "warning" for violation in violations)
|
|
300
|
+
return {
|
|
301
|
+
"total_checks": max(1, len(requirements) * 2),
|
|
302
|
+
"passed": len(requirements) + coverage.with_evidence_links,
|
|
303
|
+
"failed": failed,
|
|
304
|
+
"warnings": warnings,
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
@beartype
|
|
309
|
+
@require(lambda bundle: isinstance(bundle, ProjectBundle), "bundle must be a ProjectBundle")
|
|
310
|
+
@require(_profile_nonempty, "profile must not be empty")
|
|
311
|
+
@require(_profile_supported, "profile must be a supported requirements context validation profile")
|
|
312
|
+
@ensure(lambda result: isinstance(result, ValidationReport))
|
|
313
|
+
def validate_requirement_context(
|
|
314
|
+
bundle: ProjectBundle,
|
|
315
|
+
*,
|
|
316
|
+
profile: RequirementContextValidationProfile = "startup",
|
|
317
|
+
) -> ValidationReport:
|
|
318
|
+
"""Validate requirements context evidence usefulness for a ProjectBundle."""
|
|
319
|
+
requirements = load_requirements_from_bundle(bundle)
|
|
320
|
+
if not requirements:
|
|
321
|
+
return _empty_requirements_report()
|
|
322
|
+
|
|
323
|
+
coverage = inspect_requirement_context_coverage(requirements)
|
|
324
|
+
violations = _missing_evidence_violations(coverage, severity=_missing_evidence_severity(profile))
|
|
325
|
+
summary = _validation_summary(requirements, coverage, violations)
|
|
326
|
+
return ValidationReport(
|
|
327
|
+
status=_validation_status(summary["failed"], summary["warnings"]),
|
|
328
|
+
violations=violations,
|
|
329
|
+
summary=summary,
|
|
330
|
+
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: specfact-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.50.2
|
|
4
4
|
Summary: AI-bloat defense CLI for Python teams. Run deterministic code review, cleanup forecasts, and spec/contract evidence for AI-assisted and brownfield delivery.
|
|
5
5
|
Project-URL: Homepage, https://github.com/nold-ai/specfact-cli
|
|
6
6
|
Project-URL: Repository, https://github.com/nold-ai/specfact-cli.git
|
|
@@ -436,7 +436,7 @@ Optional module-deep paths include:
|
|
|
436
436
|
|
|
437
437
|
## Module system
|
|
438
438
|
|
|
439
|
-
Official workflow behavior ships from `nold-ai/specfact-cli-modules`. The core CLI owns bootstrap, runtime contracts, trust checks, logging, and the grouped command surface. Installed modules add families such as `project`, `backlog`, `code`, `spec`, and `
|
|
439
|
+
Official workflow behavior ships from `nold-ai/specfact-cli-modules`. The core CLI owns bootstrap, runtime contracts, trust checks, logging, and the grouped command surface. Installed modules add families such as `project`, `backlog`, `code`, `spec`, `govern`, and `requirements`.
|
|
440
440
|
|
|
441
441
|
Install examples:
|
|
442
442
|
|
|
@@ -446,6 +446,7 @@ specfact module install nold-ai/specfact-backlog
|
|
|
446
446
|
specfact module install nold-ai/specfact-codebase
|
|
447
447
|
specfact module install nold-ai/specfact-code-review
|
|
448
448
|
specfact module install nold-ai/specfact-govern
|
|
449
|
+
specfact module install nold-ai/specfact-requirements
|
|
449
450
|
```
|
|
450
451
|
|
|
451
452
|
If startup warns that modules are missing or outdated, run:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
specfact_cli/__init__.py,sha256=
|
|
1
|
+
specfact_cli/__init__.py,sha256=5aLWxVa92m2D0PdiV-WXTPCPTEx6gfUJMSnrigokpWQ,2764
|
|
2
2
|
specfact_cli/__main__.py,sha256=EpP5xlutNYI5AuMlMw8fGt1TywZUR1-CXHpzpWKyNuo,141
|
|
3
|
-
specfact_cli/cli.py,sha256=
|
|
3
|
+
specfact_cli/cli.py,sha256=GRsW3xTJh1pPJl7VpshvPT6YiHgJMMsKt7lE94ZcrAA,53151
|
|
4
4
|
specfact_cli/runtime.py,sha256=4tEcOsz2bE6-KuZF5nuHvHuwinO7l8fNAGzrra9pNrc,13474
|
|
5
5
|
specfact_cli/telemetry.py,sha256=LS34mq8jIJPcXFCm9SgLRjDUe7Ks41fPWvZmD6PXcVM,31079
|
|
6
6
|
specfact_cli/adapters/__init__.py,sha256=phzCwBSYzkXSLA6nIZan_EyInGNJ4SedmdRuAp3hyho,932
|
|
@@ -106,7 +106,7 @@ specfact_cli/models/enforcement.py,sha256=OvSyzVisApSEJHdlyozX-9t2sdvOqjniboGEKq
|
|
|
106
106
|
specfact_cli/models/module_package.py,sha256=YD2aLBxyWkQ8oIBL9ZtRwLJo1PB2wvv38GNrH0l26gs,8284
|
|
107
107
|
specfact_cli/models/persona_template.py,sha256=XLDnKJTl8K9fsC8qk5yPr33H3ctWri0dhcLbAahCao4,3967
|
|
108
108
|
specfact_cli/models/plan.py,sha256=6vP2MW-n8L9yxM4RQ6SeE-LQUtnB1eRk1pdXCxObJ6I,16808
|
|
109
|
-
specfact_cli/models/project.py,sha256=
|
|
109
|
+
specfact_cli/models/project.py,sha256=9kQDKEQWUvaCTA-IUlOtXbGgIo2YoNn4YfHuRtzk1DM,37707
|
|
110
110
|
specfact_cli/models/protocol.py,sha256=s9SpUIH9qf0W0Io_wWEYjERTdf1VOowq6rj20I3p9To,900
|
|
111
111
|
specfact_cli/models/quality.py,sha256=c12xINjFoW8mEZMNH4iwdS0ZJeKaJaV6-4decFisYMY,1050
|
|
112
112
|
specfact_cli/models/requirements.py,sha256=RFl0ZuMf-dHQ2ZVSVmjBo5514JaGuZ00TmAoobQLKt0,7217
|
|
@@ -120,11 +120,11 @@ specfact_cli/modes/router.py,sha256=VK9kk3US-agR6rF7fVB5EY5MyHjTKzFTTApwOVx-BCk,
|
|
|
120
120
|
specfact_cli/modules/__init__.py,sha256=jcxpCTLc1M4TFNN80MOyhzegG4QTkHbRPJb6UK33hVg,112
|
|
121
121
|
specfact_cli/modules/_bundle_import.py,sha256=KfaNZoNvS1N8dVrUdxpx5sI6clxq590e0x1V0LRCBdY,1602
|
|
122
122
|
specfact_cli/modules/module_io_shim.py,sha256=gNUVuzuvCf2cyQb8UK5-eG4QHZkrig0MPl7Y7VfbThA,3423
|
|
123
|
-
specfact_cli/modules/init/module-package.yaml,sha256=
|
|
123
|
+
specfact_cli/modules/init/module-package.yaml,sha256=RFdzvTzwIGfD_bP4CY1P6joEQ-ToOmTD4cCJVaVCfSo,688
|
|
124
124
|
specfact_cli/modules/init/src/__init__.py,sha256=hCfRT0VH7kl70Rm_jHlNFlCLerJoI8InHi7OS74WIL8,39
|
|
125
125
|
specfact_cli/modules/init/src/app.py,sha256=laUNKmpNqrFl1Jab3bBYICAaq3GUsj5hN5yjVFYAjvE,107
|
|
126
126
|
specfact_cli/modules/init/src/commands.py,sha256=iU5J-0qbIjd36USQu9E6bigfS6M9sySVZq9vQQpN_Qg,30632
|
|
127
|
-
specfact_cli/modules/init/src/first_run_selection.py,sha256=
|
|
127
|
+
specfact_cli/modules/init/src/first_run_selection.py,sha256=HONyTI6mUghwkZsKnivg1G7TObxRDubaW7XDVbBAxN4,23364
|
|
128
128
|
specfact_cli/modules/module_registry/module-package.yaml,sha256=iV9YB6TaE3yIuADP-3ymn9YlBy-NzNI4YsMTdJLjXDQ,699
|
|
129
129
|
specfact_cli/modules/module_registry/src/__init__.py,sha256=Y97pOZc6y1DLxUBSHeh15AQ-sWCrg67ESyUNI5NRShY,42
|
|
130
130
|
specfact_cli/modules/module_registry/src/app.py,sha256=sAKRXfaJNVM22rA952DFpG-12c8dazEb_zBQuc1KCF0,351
|
|
@@ -148,13 +148,15 @@ specfact_cli/registry/marketplace_client.py,sha256=BH1WKr80UccV4VX-N2sL0IxQIC_Et
|
|
|
148
148
|
specfact_cli/registry/metadata.py,sha256=mSIW8UZgBzBdiAH_52K8GL-VBMgZoyGQXIXg0bsl1Oc,806
|
|
149
149
|
specfact_cli/registry/module_availability.py,sha256=_fWsXUcWVY-aVhkjtKrYfb3Qkr80KsZ8P0y75PXCW-8,8115
|
|
150
150
|
specfact_cli/registry/module_discovery.py,sha256=kQ9DxfxxHRBaGncjDg8j6Owc3npIWcYOA_5MDurV5Ic,9317
|
|
151
|
-
specfact_cli/registry/module_grouping.py,sha256=
|
|
151
|
+
specfact_cli/registry/module_grouping.py,sha256=ywEby-SlRyOh8BTIMWoqgvQTea625oMKU5gC-I4wfEo,3527
|
|
152
152
|
specfact_cli/registry/module_installer.py,sha256=72OlptZI43UrHr-3_5a6QyyL7vBU51ojuBpM5AnH5vc,45148
|
|
153
153
|
specfact_cli/registry/module_lifecycle.py,sha256=17QhSER6lQV4JeTn3rvF6lsFRTIjT_UrIzMGpVveFEw,9541
|
|
154
|
-
specfact_cli/registry/module_packages.py,sha256=
|
|
154
|
+
specfact_cli/registry/module_packages.py,sha256=jpyxc5tPwitHDWXtJyqdy18W7EVvHNxdVvo7rDS9Hss,67115
|
|
155
155
|
specfact_cli/registry/module_security.py,sha256=RfKJmkR9sdBXP7q1YBsK1Io-ys0vhHshhPR06uk5TjM,4517
|
|
156
156
|
specfact_cli/registry/module_state.py,sha256=zBMPrjJOhTBZmSY7tur5gOABcRgXZWf_qpOL9iIRRLY,3463
|
|
157
157
|
specfact_cli/registry/registry.py,sha256=FnQz9-jkiQ1f1e9YjfOZ_Rx7yRVj_mhKQuvoCgmSA78,6856
|
|
158
|
+
specfact_cli/requirements/__init__.py,sha256=pjKgqaX2Wl6IwhBqg1PrZDkf4NeYqpLUHxBo7bgt1hQ,857
|
|
159
|
+
specfact_cli/requirements/context.py,sha256=upTAzn04uZL-3E4niWlEJiMpZ-h2GQsHbr-CI02gGfw,13379
|
|
158
160
|
specfact_cli/resources/semgrep/async.yml,sha256=pz4xuPx7_CAEAwN-iq1zyc8srcid3GYtl7exsr1_5k8,8232
|
|
159
161
|
specfact_cli/resources/semgrep/code-quality.yml,sha256=Nx-E2XuShwioUJhG-JvjEgOMPU9FuNr7H-VCCjKia30,7749
|
|
160
162
|
specfact_cli/resources/semgrep/feature-detection.yml,sha256=6nZ6sqVtAmGWZxgZYJwu_YNv59xIYgRJsM-5ZtFxXUw,21538
|
|
@@ -288,8 +290,8 @@ specfact_cli/resources/templates/policies/kanban.yaml,sha256=9jt7YYfZ8e8aB5skY2D
|
|
|
288
290
|
specfact_cli/resources/templates/policies/mixed.yaml,sha256=-fkrT-TLKLTBzjKeKr8bEJHFC-nh1TlyLOEFfgRdSi8,243
|
|
289
291
|
specfact_cli/resources/templates/policies/safe.yaml,sha256=uiwe5_ABvaU4nmq6rsLUn8zRotkBITItPUsdPZPTHTw,157
|
|
290
292
|
specfact_cli/resources/templates/policies/scrum.yaml,sha256=6FHYOntkjCxHAn-ga14IQzA1PvYUJgxfLsEQYtWJILM,188
|
|
291
|
-
specfact_cli-0.
|
|
292
|
-
specfact_cli-0.
|
|
293
|
-
specfact_cli-0.
|
|
294
|
-
specfact_cli-0.
|
|
295
|
-
specfact_cli-0.
|
|
293
|
+
specfact_cli-0.50.2.dist-info/METADATA,sha256=XPwGf6uCIlEgJLAx0O0rUxyjhRxziUi1jVL7kP2ld-Y,25659
|
|
294
|
+
specfact_cli-0.50.2.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
|
|
295
|
+
specfact_cli-0.50.2.dist-info/entry_points.txt,sha256=pwDD5Ttu6AF3p3T05M4G0aR2BELFyUu3214kjMRGEow,96
|
|
296
|
+
specfact_cli-0.50.2.dist-info/licenses/LICENSE,sha256=nWX_6oozyEFlF3mDaSWyBD9HLpyLRmCYYqdcgoVOrOk,11361
|
|
297
|
+
specfact_cli-0.50.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|