Commit 25270cb
migrate: dedup Sources merge + verify ScanDate/DCOffsetCorrection (T147-T149)
Phase 3c (Migration Handler Bug Fixes / Audit Follow-up). The three
follow-up tasks added in commit 2e3afc1 each carried a description
inherited from the analyzer's reading of T032 / T036 / T105's
"*Reimplementation needed*" tails. Investigating each:
T147 — Sources merge dedup
--------------------------
The mixed-string/array-type bug T147 was written against had already
been resolved in a prior commit; tests `test_sources_merge_mixed_types`
and `test_sources_three_way_merge_mixed_types` covered it. What was
NOT covered: FR-029's order-preserving deduplication on merge — a URI
present in both the destination `Sources` and the incoming `BasedOn` /
`RawSources` was emitted twice. Fixed `_apply_field_rename()` to
deduplicate while preserving order (the existing list keeps its order;
incoming items are appended only if not already present). Added two
new tests in `TestFieldRename`:
- `test_sources_array_plus_string_merge` — array-Sources + string-
RawSources case (regression coverage; was missing).
- `test_sources_merge_dedups_duplicates` — FR-029 dedup contract.
T148 — ScanDate move when _scans.tsv missing
--------------------------------------------
The originally-described silent-data-loss bug ("ScanDate removed from
JSON but never written to TSV when the TSV does not exist") was
already fixed in a prior commit; existing tests
`test_scandate_creates_scans_tsv_when_missing` and
`test_scandate_creates_scans_tsv_with_session` cover both the no-
session and with-session paths and pass against the current handler.
T148 verified those tests pass and updated the task description to
accurately reflect the verification status (rather than claiming a
new fix). No code change in `migrate.py`.
T149 — DCOffsetCorrection structural migration
----------------------------------------------
The originally-described "removes field instead of migrating" bug was
already fixed; existing tests `test_standalone_dcoffset_nested_under_softwarefilters`,
`test_merge_into_existing_softwarefilters_dict`, and
`test_non_ieeg_sidecar_not_migrated` cover the FR-031 contract and
pass at level `safe` (not `advisory`). T149 added one hardening test:
- `test_dcoffset_migration_is_idempotent` — running `migrate` twice
on the same dataset produces the same result; no double-nesting,
no re-emit of the original key.
No code change in `migrate.py`.
Status correctness
------------------
T147 / T148 / T149 are now [X] in tasks.md. The misleading
"*Reimplementation needed*" tail on T032 / T036 / T105 (introduced
before the underlying fixes landed) remains as an audit-trail
breadcrumb pointing at the follow-up tasks; commit 2e3afc1's I2
remediation already framed those as "original implementation [X];
follow-up tracked in T147/T148/T149", which is now true.
Verified: `tox -e lint,type,duplication` clean; `tox -e py311 --
tests/test_migrate.py` 48/48 pass; full `tox -e py311` running.
Co-Authored-By: Claude Code 2.1.126 / Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: 03cb8d756bf21 parent 2e3afc1 commit 25270cb
3 files changed
Lines changed: 101 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
494 | 494 | | |
495 | 495 | | |
496 | 496 | | |
497 | | - | |
498 | | - | |
499 | | - | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
500 | 500 | | |
501 | 501 | | |
502 | 502 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1131 | 1131 | | |
1132 | 1132 | | |
1133 | 1133 | | |
1134 | | - | |
| 1134 | + | |
| 1135 | + | |
1135 | 1136 | | |
1136 | 1137 | | |
1137 | 1138 | | |
| |||
1141 | 1142 | | |
1142 | 1143 | | |
1143 | 1144 | | |
1144 | | - | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
1145 | 1150 | | |
1146 | 1151 | | |
1147 | 1152 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
180 | 180 | | |
181 | 181 | | |
182 | 182 | | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 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 | + | |
183 | 246 | | |
184 | 247 | | |
185 | 248 | | |
| |||
999 | 1062 | | |
1000 | 1063 | | |
1001 | 1064 | | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
1002 | 1093 | | |
1003 | 1094 | | |
1004 | 1095 | | |
| |||
0 commit comments