Commit 17543ba
authored
feat(mvrs): add MVR supersession, latest dated MVR per SVC determines verdict (#399)
* feat(mvrs): supersession — latest MVR per SVC wins (#72)
When an SVC is manually verified more than once (e.g. a first MVR
fails, a fix is applied, and a second MVR passes), the requirement
was incorrectly reported as not met because all MVRs were counted.
Supersession rule: the MVR with the latest date is the verdict for
that SVC; older ones are retained as audit history but excluded from
the pass/fail computation.
Changes:
- Add optional `date` field (RFC 3339 date-time with timezone) to
mvrs.yml schema; `date` is required when >1 MVR references the
same SVC.
- `MVRData.date: Optional[datetime]` — timezone-aware; stored as
original ISO string in SQLite, sorted via SQLite's `datetime()`
function so mixed offsets compare correctly by UTC moment.
- `RequirementsRepository.get_effective_mvr_for_svc()` — new SQL
query using `ORDER BY datetime(date) DESC NULLS LAST LIMIT 1`.
- `RequirementsRepository.get_superseded_mvrs_for_svc()` — all
non-effective MVRs for a SVC (audit history).
- `StatisticsService` — verdict computed from effective MVR per SVC;
removes the now-redundant `_get_mvr_stats` helper.
- `details.py` — `_compute_meets` uses effective MVR; `get_svc_details`
adds `date` and `superseded` fields to each MVR.
- `SemanticValidator._validate_mvr_supersession` — errors on missing
`date` when multiple MVRs reference the same SVC, and on exact UTC
timestamp ties.
- Report templates (AsciiDoc + Markdown) — show `date` and mark
superseded MVRs as history.
- Export service + schema — include `date` field.
Closes #72
Signed-off-by: Jimisola Laursen <jimisola@jimisola.com>
* fix(mvrs): address PR review findings
- export_service: serialize MVRData.date as ISO string (.isoformat()) to
prevent TypeError on JSON export
- details.py: serialize date in get_svc_details and get_mvr_details the
same way; both previously passed raw datetime objects to callers
- report.py: same fix for the Jinja2 template dict (renders T not space)
- schema.py: add idx_mvrs_date index to support ORDER BY datetime(date)
- requirements_repository: replace cascading-N+1 in
get_superseded_mvrs_for_svc with a single ROW_NUMBER window query;
add get_effective_mvr_verdict_counts() batch aggregation method;
document the datetime() TZ-normalization in get_effective_mvr_for_svc
- statistics_service: replace per-SVC loop in _calculate_global_totals
with single get_effective_mvr_verdict_counts() call (eliminates N+1)
- tests: add _validate_mvr_supersession unit tests (missing date,
tie-break, valid pair, single undated); add supersession scenarios to
test_details (compute_meets, get_svc_details superseded flag,
get_mvr_details date field); add 3-MVR and global-totals tests to
test_statistics_service; add date serialization round-trip tests to
test_export_service
Signed-off-by: Jimisola Laursen <jimisola@jimisola.com>
* docs: document MVR supersession and date field
- usage.adoc: update Manual Tests column description to mention
supersession; add new [[mvr-supersession]] section with YAML example,
date field rules (required when >1 MVR per SVC, RFC 3339 format,
tie-break is a validation error, quotes required in YAML)
- how_it_works.adoc: add MVR verdict and supersession section explaining
the single-query effective-MVR selection and global totals semantics
Signed-off-by: Jimisola Laursen <jimisola@jimisola.com>
* docs: use RFC 3339 instead of ISO 8601 for MVR date field
Signed-off-by: Jimisola Laursen <jimisola@jimisola.com>
* docs: update mcp.adoc and lsp.adoc for MVR date and superseded fields
Signed-off-by: Jimisola Laursen <jimisola@jimisola.com>
---------
Signed-off-by: Jimisola Laursen <jimisola@jimisola.com>1 parent f8a7017 commit 17543ba
24 files changed
Lines changed: 784 additions & 50 deletions
File tree
- docs/modules/ROOT/pages
- src/reqstool
- commands/report
- templates
- asciidoc
- markdown
- common
- queries
- validators
- model_generators
- models
- generated
- resources/schemas/v1
- services
- storage
- tests/unit/reqstool
- common
- queries
- validators
- services
- storage
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
39 | 49 | | |
40 | 50 | | |
41 | 51 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
249 | | - | |
| 249 | + | |
250 | 250 | | |
251 | 251 | | |
252 | 252 | | |
253 | | - | |
| 253 | + | |
254 | 254 | | |
255 | 255 | | |
256 | 256 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
134 | 137 | | |
135 | 138 | | |
136 | 139 | | |
| |||
139 | 142 | | |
140 | 143 | | |
141 | 144 | | |
142 | | - | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
143 | 148 | | |
144 | 149 | | |
145 | 150 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
| 111 | + | |
| 112 | + | |
112 | 113 | | |
113 | 114 | | |
114 | 115 | | |
| |||
120 | 121 | | |
121 | 122 | | |
122 | 123 | | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
123 | 156 | | |
124 | 157 | | |
125 | 158 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | 17 | | |
19 | 18 | | |
20 | 19 | | |
| |||
161 | 160 | | |
162 | 161 | | |
163 | 162 | | |
164 | | - | |
| 163 | + | |
165 | 164 | | |
166 | | - | |
167 | | - | |
168 | | - | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
169 | 178 | | |
170 | 179 | | |
171 | 180 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
9 | 13 | | |
10 | 14 | | |
11 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
9 | 13 | | |
10 | 14 | | |
11 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | | - | |
| 27 | + | |
29 | 28 | | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
34 | 32 | | |
35 | 33 | | |
36 | 34 | | |
| |||
109 | 107 | | |
110 | 108 | | |
111 | 109 | | |
112 | | - | |
113 | 110 | | |
| 111 | + | |
114 | 112 | | |
| 113 | + | |
115 | 114 | | |
116 | 115 | | |
117 | 116 | | |
| |||
154 | 153 | | |
155 | 154 | | |
156 | 155 | | |
| 156 | + | |
157 | 157 | | |
| 158 | + | |
158 | 159 | | |
159 | 160 | | |
160 | 161 | | |
| |||
181 | 182 | | |
182 | 183 | | |
183 | 184 | | |
| 185 | + | |
184 | 186 | | |
185 | 187 | | |
186 | 188 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
50 | 54 | | |
51 | 55 | | |
52 | 56 | | |
| |||
215 | 219 | | |
216 | 220 | | |
217 | 221 | | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
218 | 276 | | |
219 | 277 | | |
220 | 278 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
78 | 79 | | |
79 | 80 | | |
80 | 81 | | |
| |||
0 commit comments