Repository navigation
Change history: config-level diff, a record of every apply, rollback N as a normal change (#12, part 1) - #59
Merged
Merged
Conversation
…ply, rollback N as a normal change Part 1 of #12 (risk levels and automatic confirm follow). - `mr plan` / `mr apply` / the web UI's apply dialog show what changes in config terms ("~ wifi.radios[phy1].htmode: HE80 → HE160", "+ firewall.forwards[web]", secrets only as "(changed)"), against gen/applied.yaml + gen/applied-secrets (bookkeeping the plan writes and a rollback restores). `-v`: each generated file's diff, secret values masked. - Every apply records a revision next to its snapshot: rev, time, origin, comment (`mr apply -m`, web UI field), version, the diff and the result. `mr history`; `system.history` (default 20). - `mr rollback N` / 回滚到此前: the config from before change #N applied as a new change (verify + confirm window), the web UI password kept. - Web UI 变更历史 page; tests; mock data. Part of #12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What (part 1 of #12)
Config-level diff. The config last applied is recorded as
gen/applied.yaml(canonical form) andgen/applied-secrets(sha256 per secret, mode 0600) — bookkeeping files the plan writes and every rollback restores; they are not listed among the plan's files.mr plan,mr applyand the web UI's apply dialog now start with what changes in config terms:List items are identified by
name(radios byphy, SSIDs byssid); values switched back to their default show as(default).mr plan -v/mr apply -vadd every generated file's diff with all secret values masked.A record of every apply. Each snapshot gets a
<snapshot>.json: revision number, time, origin (mr apply,web UI+ client address,restore,rollback), comment (mr apply -m "…", a field in the web UI dialog), mr version, the diff above and the result —applying→applied, orpending→confirmed, orrolled back: …(verification failed, not confirmed in time, reverted, at boot).mr history [--json].system.history(5–200, default 20) sets how many snapshots are kept; pruning removes their records too.Rollback as a normal change.
mr rollback N(CLI,--confirmdefault 120 s) and 回滚到此前 in the web UI put the config from before change #N back through validate → plan → apply with the confirm window, as a new revision (originrollback); the web UI password stays the current one (the snapshot's saved hash is not restored). Snapshots taken before this change remain listed and can still be rolled back to.mr rollbackwithout a number keeps its immediate behaviour (undo the pending change / restore a snapshot file).Web UI. The page 备份与回滚 becomes 变更历史: time, origin, comment, result tag, the list of changes, 对比现在 (config before that change → now) and 回滚到此前; the apply dialog shows the config changes and takes a comment; apply and rollback share one progress / confirm view.
Left for part 2 (same issue): risk levels from the admin's own connection, automatic confirm of low-risk changes,
mr apply --wait.Why
A plan used to list only generated files and services — not what changed in router.yaml terms — and the history was a list of anonymous tar files whose "roll back" restarted services directly, without verification or a confirm window.
Verification
mr/history_test.go): config diff (named items, radios by phy, inline lists, defaults, reordering, identical configs → nothing); secret diff never contains values; the applied record and the plan hiding it; revisions numbered, results recorded, pruned with their snapshots; staging a rollback takes the snapshot's router.yaml and secrets but today's web UI password; masked file diffs. Existing apply / confirm / boot-rollback tests updated.tools/ci.shpasses (private and public trees).Part of #12
https://claude.ai/code/session_01HWeUjo1dmS7gBkCYHrVjCr