Platform v2 step 1.8 (APPS_PLATFORM D-8, section 6.3).
- devices + device_pair_requests tables (Alembic 0007_devices); sessions.device_id
becomes a FK. Device tokens are stored as sha256 only; the plain token is generated
when the device picks it up, once.
- /api/devices: pair-request (public, rate-limited, LAN-only in the proxy) + polling
with a per-request secret; manager approve/list/rename/config/login mode/link/
reassign/revoke (key core.devices.manage); the device's own /me and /me/users.
- Approving or reassigning checks the app's licence and its `devices` limit
(license.limit_reached); after a downgrade the newest devices beyond the limit are
refused, the oldest keep working.
- X-Xenia-Device: core/access/context.py loads the device (device.not_paired /
device.revoked), tags logs with device=, throttles last_seen_at. check() and
module_required() apply the app's scope (device.out_of_scope); require_device(app).
- POST /api/auth/login {client: "terminal"} uses the device's login mode (device ->
auth.default_login_mode -> app's first mode); tap/none only here. The session is
bound to the device (device.required without its header) and replaces the
device's previous user. Revoke/reassign end the device's sessions.
- Registry: a device app with user logins must declare '<app>.access'.
- Proxy: location /api/devices/pair-request LAN-only on the :443 servers (both copies).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Guard tests (APPS_PLATFORM D-17)
Tests that protect platform-wide rules rather than one feature. They must stay green; if one fails, fix the code, not the guard. Changing a guard's rule is a design decision: record it in APPS_PLATFORM §2 first.
| File | Rule | Filled in |
|---|---|---|
test_migrations.py |
Models and Alembic revisions don't drift; AUTOINCREMENT survives batch rebuilds; the schema is built only by Alembic; v1 databases are refused; revision data backfills | steps 1.0, 1.1 |
test_no_naive_time.py |
No datetime.utcnow/datetime.now, date.today(), argument-less .astimezone(), tz-less fromtimestamp, or Column(DateTime outside core/timeutil.py |
step 1.1 |
test_route_access.py |
Every route declares require(...), require_device(...) or public() |
step 1.5 (placeholder until then) |