Commit 6136ea8
Align CBM serialized form with declared schema (#1065)
* Align CBM serialized form with declared schema
`ConsecutiveBlockMinimization`'s `ProblemSchemaEntry::fields` declares
`matrix` and `bound`, but its serialized form also wrote `num_rows` and
`num_cols`, and its `try_from` rejected JSON that lacked them. This made
the schema-driven `pred create` path fail with "missing field `num_rows`"
for any caller that built JSON from the declared schema fields.
`num_rows` and `num_cols` are fully derived from `matrix` (just
`matrix.len()` and `matrix[0].len()`), so they don't belong in the wire
format. Switch to symmetric `serde(try_from / into = Def)` so both
serialize and deserialize round-trip through the minimal `{matrix, bound}`
form, and let `try_new` recompute the cached dimensions on the way in.
The cached fields stay on the in-memory struct for fast getter access.
Replace the now-unreachable inconsistent-dimensions test with one that
pins the minimal wire format and one that exercises ragged-matrix
rejection — the actual remaining input validation.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix: update CBM CLI rejection test for new wire format
The CI Test job for #1065 failed because cli_tests.rs:445 still asserted
the old "num_cols must match matrix column count" error. Under the new
serde definition, extra num_rows/num_cols fields in the JSON are silently
ignored (serde's default behavior for unknown fields when not using
deny_unknown_fields), so the previous JSON now deserializes successfully
and the CLI no longer rejects it.
Switch the test to exercise the actual remaining input validation —
ragged-matrix rejection — which is what `validate_matrix_dimensions`
guards against and what the in-tree unit test now also covers. Rename
the test accordingly.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>1 parent e3b8870 commit 6136ea8
3 files changed
Lines changed: 31 additions & 26 deletions
File tree
- problemreductions-cli/tests
- src
- models/algebraic
- unit_tests/models/algebraic
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
423 | 423 | | |
424 | 424 | | |
425 | 425 | | |
426 | | - | |
| 426 | + | |
427 | 427 | | |
428 | 428 | | |
429 | 429 | | |
430 | | - | |
431 | | - | |
432 | | - | |
| 430 | + | |
433 | 431 | | |
434 | 432 | | |
435 | 433 | | |
436 | | - | |
| 434 | + | |
437 | 435 | | |
438 | 436 | | |
439 | 437 | | |
| |||
442 | 440 | | |
443 | 441 | | |
444 | 442 | | |
445 | | - | |
| 443 | + | |
446 | 444 | | |
447 | 445 | | |
448 | 446 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
62 | 65 | | |
63 | 66 | | |
64 | 67 | | |
| |||
184 | 187 | | |
185 | 188 | | |
186 | 189 | | |
187 | | - | |
| 190 | + | |
188 | 191 | | |
189 | 192 | | |
190 | | - | |
191 | | - | |
192 | 193 | | |
193 | 194 | | |
194 | 195 | | |
195 | 196 | | |
196 | 197 | | |
197 | 198 | | |
198 | 199 | | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
211 | 209 | | |
212 | | - | |
213 | 210 | | |
214 | 211 | | |
215 | 212 | | |
| |||
Lines changed: 13 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
95 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
96 | 106 | | |
97 | | - | |
| 107 | + | |
98 | 108 | | |
99 | 109 | | |
100 | 110 | | |
| |||
0 commit comments