Skip to content

Add a restore of the synced fields from a stored snapshot - #2

Merged
timlichtenberg merged 1 commit into
mainfrom
tl/restore
Oct 22, 2026
Merged

timlichtenberg merged 1 commit into
mainfrom
tl/restore

Conversation

@timlichtenberg

Copy link
Copy Markdown
Member

Summary

Adds python -m board_sync.restore, which sets the synced fields back to the values of a stored snapshot.json from the state repository. I want this in place before the first bulk apply, so a wrong apply can be undone.

Changes

  • board_sync/restore.py: plan the writes that return each synced field to its stored value (or clear it), print the plan with a plan id, and apply it with --apply --expect <plan id> --report <file>. The report is written on every path, before the first write and at the end; the run stops after 5 failed writes in a row; skipped values and issues, places and fields in only one read are counted.
  • board_sync/core.py: synced_names(place), used by missing_fields and by the restore.
  • tests/test_restore.py: plan cases, the real github.write mutations through a recording client, plan id, apply, partial failure, failures in a row, interrupted run, report paths, setup errors, command line.
  • README: a Restore section with the steps, which commit holds the right snapshot.json and state.json, and the approval fields to clear.
  • .gitignore: restore.txt.

Validation

  • coverage run -m pytest -q: 163 passed; coverage report: board_sync/restore.py 100% of lines and branches, total 99%.
  • ruff check . and ruff format --check .: clean.
  • Round trip with core.plan(old, {}) and restore.plan(old, applied) on the snapshot of the dry run https://github.com/Interra-Project/board-sync/actions/runs/39748240410 (304 issues): the 1687 planned sync writes, applied in memory, give 1687 restore writes on the same issues, places and fields with the stored values, and a second restore plan is empty.
  • python -m board_sync.restore snapshot.json against the live boards: 0 planned writes, since nothing changed after the snapshot; with 1 value changed in a copy of the snapshot, exactly 1 planned write.
  • Next sync plan after a restore, on the same snapshot, with core.plan: with the state.json from after the apply, 1137 writes of which 987 clear stored values; with no state, the 1687 writes again, which stop at the limit of 20. With the 1687 write keys left in bulk_keys, plan_and_apply writes 400 of them without a stop, which is why the README clears that field.

Not checked

No --apply against the live boards: the restore has not written a value yet.

The first apply of the sync writes about 1700 values across the boards and issues. A restore sets the synced fields back to the values of a stored snapshot.json, so a wrong bulk apply can be undone.

python -m board_sync.restore reads all places, plans one write per difference (the stored value, or a clear), and prints the plan with a plan id. --apply writes only when --expect names the plan id of the run, needs --report, writes the report before the first write and again at the end, and stops after 5 failed writes in a row. Issues, places and fields that are in only one of the two reads are counted in the report. synced_names moves to core, where missing_fields uses it too.

The README lists the steps around a restore. It names the commit for snapshot.json and for state.json, and says to clear bulk_keys, bulk_idle and failures in the replaced state.json: a state.json saved after the undone writes makes the next run clear original values, and an older approval lets a scheduled run write the undone values again.
@timlichtenberg
timlichtenberg merged commit 4ce528c into main Oct 22, 2026
1 check passed
@timlichtenberg
timlichtenberg deleted the tl/restore branch October 22, 2026 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant