feat: undo a restore from the safety copy it took
Some checks failed
ci / rust (push) Has been cancelled
ci / supply-chain (push) Has been cancelled
ci / web (push) Has been cancelled

- POST /refresh-runs accepts undo_of: restores the safety copy of a completed restore back onto the same
  target through the normal run engine (checks, countdown, progress, and a new safety copy so the undo can be
  undone); refused when something was restored after it or the copy is gone
- a safety copy is accepted as a source only for the target it was taken from (hub and agent both check)
- run views carry undo and undo_available; audited as refresh.undo_started
- the modal offers Undo last restore and, after a restore, Undo this restore
- proven with a real agent and PostgreSQL: restore, undo back to the original contents, undo of the undo

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-16 16:47:02 +07:00
parent 854e3572e9
commit 648c8c6a2a
16 changed files with 457 additions and 41 deletions

View File

@@ -39,6 +39,14 @@ test("what the person is told never contains the database's own words", () => {
assert.equal(outcomeOf(run("restoring", "safety"), { target: "Staging" }).tone, "busy");
});
test("an undo is worded as putting the target back, and its own safety copy keeps it undoable", () => {
const done = outcomeOf({ ...run("completed"), undo: true }, { target: "Staging", orbit: "ledger", when: "Nov 15, 11:57 AM" });
assert.equal(done.tone, "good");
assert.match(done.title, /Staging was rolled back/);
assert.match(done.detail, /holds what it held before that restore/);
assert.match(outcomeOf({ ...run("restore_failed", "apply_failed"), undo: true }, { target: "Staging" }).title, /undo failed/i);
});
test("restore points are named by environment, and by target only when two share one", () => {
const rel = (id, env, name) => ({ id, target_environment: env, target_name: name, usable: true });
assert.deepEqual(