feat(backend): manager override with one-time PIN approval for cancel, price change, over-limit discount

Platform v2 step 1.9 (APPS_PLATFORM D-10).
- Perm(..., overridable=True). check() answers access.override_possible (not
  access.denied) for such keys, and consumes an X-Xenia-Override token for them.
- POST /api/access/override {key, username, pin}: the approver must hold the key
  (module effective); returns a token valid 60 s, once, for that key and the
  requesting session only (sha256 stored). Wrong PINs throttled per session.
  GET /api/access/overrides: audit list (core.staff.manage).
- access_overrides table (revision 0008): who asked, session, who approved, device,
  key, created/expires/used, target. The revision also grants core.devices.manage and
  the new pricing.discounts.over_limit to existing owners/store managers.
- Overridable: ordering.orders.cancel (the three cancel endpoints; the order audit log
  notes "override #n approved by user m"), ordering.prices.modify (price adjust), and
  new pricing.discounts.over_limit (waiter discounts beyond their limits; the reason
  goes in params). The venue switch discounts.enabled is never overridable.
- /orders/cancel-permissions adds override_possible; permission catalogues expose
  `overridable`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-13 09:57:37 +02:00
co-authored by Claude Opus 5.5
parent c699542565
commit 650fee7873
23 changed files with 589 additions and 32 deletions
+3
View File
@@ -14,6 +14,8 @@ Agent notes:
- `workers` are "package.module:function" strings naming async functions that run
forever. The supervisor imports and starts them while the module is effective and
cancels them when it isn't. Strings keep manifests cheap to import.
- `Perm(..., overridable=True)`: a user without the key gets access.override_possible
and can retry with a manager's one-time approval (core/access/override.py, D-10).
- Permission keys are "<module>.<area>.<action>" (or "<module>.<action>"). Role lists
are the default role template (superadmin always has every key, D-7, so it's
never listed).
@@ -32,6 +34,7 @@ class Perm:
key: str
description: str
roles: tuple[str, ...] = ()
overridable: bool = False # a manager may approve it once with their PIN (D-10)
@dataclass(frozen=True)