Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions dokimi/changelog.d/20261114_130000_partial-status-guard.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Fixed

- **A routing result marked `"status": "partial"` without a `partial` block is a partial result to the overwrite guard** — a capped `novelty routing` run may replace it, and a finished result is kept as before. `novelty items` already refused such a probe file.
2 changes: 1 addition & 1 deletion dokimi/dokimi/commands/novelty_routing_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ def _is_partial_file(path: Path) -> bool:
earlier = json.loads(path.read_text(encoding="utf-8"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anchored at line 531; the finding is at line 528, outside the diff.

nit: the change also reaches the atoms, probe and analyze partial sidecars, not just novelty routing

dokimi/dokimi/commands/novelty_routing_report.py:528: _is_partial_file is shared through _partial_destinations/_takes_partial, used by novelty_budget.partial_destination/partial_write. So a status-only <stem>.partial.json is now overwritten in place by capped atoms/probe/analyze runs; base wrote <stem>.partial2.json.

How to check: atoms.partial.json = {"status":"partial"}, capped atoms run → head writes atoms.partial.json (base: atoms.partial2.json, changed).
Expected: Probably intended consistency; the PR body and changelog fragment name routing only.
Fix: Mention the sidecar paths in the changelog fragment, and add one test on partial_destination with a status-only file.

except (OSError, ValueError):
return False
return isinstance(earlier, dict) and "partial" in earlier
return isinstance(earlier, dict) and ("partial" in earlier or earlier.get("status") == "partial")


def _takes_partial(candidate: Path) -> bool:
Expand Down
10 changes: 10 additions & 0 deletions dokimi/tests/test_novelty_routing_spend_cap_partial.py
Original file line number Diff line number Diff line change
Expand Up @@ -815,3 +815,13 @@ def test_a_partial_single_run_rates_its_selections_over_the_calls_it_made(tmp_pa
hits = sum(1 for row in model["per_query"] if row.get("correct"))
assert model["n_calls"] == 2
assert model["selection_rate"] == round(hits / 2, 4)


def test_a_file_marked_partial_by_status_alone_is_a_partial_result_to_write_over(tmp_path):
from dokimi.commands.novelty_routing_report import _is_partial_file, save_result

marked = tmp_path / "routing.json"
marked.write_text('{"status": "partial"}', encoding="utf-8")
assert _is_partial_file(marked)
assert save_result({}, marked, {"partial": PARTIAL}) == marked
assert json.loads(marked.read_text(encoding="utf-8"))["partial"] == PARTIAL
Loading