Skip to content

feat(policy): record mode-dial changes in the drift ledger via log_change#85

Merged
fu351 merged 1 commit into
mainfrom
feat/policy/mode-dial-ledger
Jul 6, 2026
Merged

feat(policy): record mode-dial changes in the drift ledger via log_change#85
fu351 merged 1 commit into
mainfrom
feat/policy/mode-dial-ledger

Conversation

@fu351

@fu351 fu351 commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Slice

Closes #79

What this PR does

doberman mode <m> and the setup wizard called config.save_mode() directly — a paranoid → light downgrade recorded nothing. Both user-initiated call sites now route through a shared _apply_mode_change helper that audit-logs via drift.log_change (the scope-enforced, audited-but-not-gated path from #72) before saving:

  • Downgrades land as weaken / method="logged" rows in doberman policy-history; upgrades as strengthen.
  • No-op (same mode) skips the ledger call — no confusing neutral rows.
  • Best-effort by design: a ledger failure prints a warning and the mode change still applies (the dial stays frictionless; the audit is the addition, not a new gate).
  • Unknown-mode error behavior unchanged (resolve_mode raises before anything happens).

Test-fixture save_mode calls (6 test files) were deliberately left unwired — not user-initiated.

Tests added (run in CI)

tests/unit/test_mode_ledger.py (4): downgrade→weaken row · upgrade→strengthen row · same-mode records nothing · monkeypatched ledger failure → warning + mode still applied.

Security checklist

Notes

Pre-existing doc bug spotted (out of scope, not fixed here): README references doberman policy set-mode <mode>, but the actual command is doberman mode <name>.

@fu351 fu351 merged commit b679848 into main Jul 6, 2026
6 checks passed
@fu351 fu351 deleted the feat/policy/mode-dial-ledger branch July 6, 2026 20:08
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.

Wire the mode dial (doberman mode / setup) through log_change so mode changes hit the ledger

1 participant