|
6 | 6 |
|
7 | 7 | import pytest |
8 | 8 |
|
9 | | -from wwgpt.checkpointing import append_csv_records |
| 9 | +from wwgpt.checkpointing import append_csv_records, csv_commit, reconcile_csv_artifacts |
10 | 10 |
|
11 | 11 |
|
12 | 12 | DOSE_DEFINITION = ( |
@@ -101,6 +101,23 @@ def test_layer_application_index_survives_sequential_appends(tmp_path): |
101 | 101 | assert int(rows[2]["projection_event_number"]) == 3 |
102 | 102 |
|
103 | 103 |
|
| 104 | +def test_reconciled_uncommitted_suffix_does_not_advance_application_count(tmp_path): |
| 105 | + path = tmp_path / "wwpgd_projection.csv" |
| 106 | + append_csv_records(path, [_projection_row(event=0, step=10, dose=0.05, changed=True)]) |
| 107 | + committed = csv_commit(path) |
| 108 | + |
| 109 | + # Simulate rows flushed after the last durable checkpoint, then a restart. |
| 110 | + append_csv_records(path, [_projection_row(event=1, step=20, dose=0.04, changed=True)]) |
| 111 | + assert int(_read_rows(path)[-1]["layer_application_index"]) == 2 |
| 112 | + reconcile_csv_artifacts(tmp_path, {path.name: committed}) |
| 113 | + |
| 114 | + append_csv_records(path, [_projection_row(event=2, step=30, dose=0.03, changed=True)]) |
| 115 | + rows = _read_rows(path) |
| 116 | + assert len(rows) == 2 |
| 117 | + assert int(rows[-1]["layer_application_index"]) == 2 |
| 118 | + assert rows[-1]["is_first_applied_projection"] == "False" |
| 119 | + |
| 120 | + |
104 | 121 | def test_first_application_is_tracked_independently_per_layer(tmp_path): |
105 | 122 | path = tmp_path / "wwpgd_projection.csv" |
106 | 123 | append_csv_records( |
|
0 commit comments