Skip to content

PATCH user managed=false: implicitly unlock + reconcile - #27

Merged
luma-founder merged 1 commit into
mainfrom
unmanaged-implies-unlocked
May 9, 2026
Merged

luma-founder merged 1 commit into
mainfrom
unmanaged-implies-unlocked

Conversation

@luma-founder

@luma-founder luma-founder commented May 9, 2026 •

Copy link
Copy Markdown

Summary

  • Enforce the invariant that an unmanaged user is never locked at the DB level: PATCH /v1/users/{user} with managed: false on a currently-locked user clears manual_lock, audits user.unlock with payload={"reason": "managed_to_unmanaged"}, and dispatches a plugin reconcile via BackgroundTasks so external state (smart plug, DNS sinkhole, etc.) follows.
  • Audit order is user.unlock then user.update so the operator can read the trail as "unlocked them as part of unmanaging them".
  • Reverse direction (managed: true) is unchanged — pure flag flip, no auto-lock, no auto-anything. Operator chose to manage; we don't decide for them.
  • Added 4 tests covering: lock cleared, audit order + payload, no implicit unlock when not locked, and managed=true doesn't touch a stale lock row.

Test plan

  • just check clean (254 Python tests + 23 web tests + lint + mypy + build)
  • Live smoke: create user, lock, PATCH managed: false, confirm /status reports unlocked, audit log shows user.unlock then user.update, and reftest plugin sentinel cleared if assigned

Enforce the invariant that an unmanaged user is never locked at the DB
level. When PATCH /v1/users/{user} flips ``managed`` to false on a
currently-locked user, clear ``manual_lock`` first, audit a
``user.unlock`` row with ``reason: managed_to_unmanaged`` (so the trail
reads unlock-then-update), and schedule a plugin reconcile so external
state (smart plugs, DNS sinkhole, etc.) follows the unlocked state. The
reverse direction (``managed=true``) is left as a pure flag flip — the
operator chose to manage; we don't auto-anything.
@luma-founder
luma-founder merged commit a9d78a6 into main May 9, 2026
4 checks passed
@luma-founder
luma-founder deleted the unmanaged-implies-unlocked branch May 9, 2026 02:04
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.

2 participants