feat(backend): module registry, manifests, enable/disable without restart

Platform v2 step 1.3 (APPS_PLATFORM §4, §5.3, D-4, D-19).
- core/modules: Module/Perm/Limit/SettingDef/DeviceApp/Mount model; registry
  that discovers modules/<key>/manifest.py and validates it (keys, kinds,
  dependencies and cycles, permission prefixes and roles, unique settings,
  each router claimed once and importable, device_app only on apps, workers);
  free_tier.py (D-5 constant, used from 1.4)
- 25 manifests (the §4.2 map) with permission keys + default roles derived
  from today's perm_* meaning, limits, device apps and the 55 settings
- main.py mounts every router from the manifests; non-core routers carry
  Depends(module_required(key)) -> 403 module.disabled while off
- site_modules table (revision 0004), cached enablement; disabling a module
  also turns off modules that depend on it; core can't be disabled
- worker supervisor: connect_menu / connect_orders / connect_remote are now
  separate workers (v1's single _connect_loop split), started and stopped as
  their modules turn on and off; crashes are logged and restarted
- GET /api/platform/bootstrap (venue name/tz/language/currency, effective
  modules, user, language, role-template permission keys), GET /modules,
  PUT /modules/{key}
- settings API derives its key list and defaults from the manifests
- reports router split: history endpoints on history_router (`history`
  module, free tier later) under the same /api/reports prefix
- tests: registry validation, mount coverage, toggle round-trip, dependency
  propagation, bootstrap/catalogue shape, supervisor; pack rule CS-13

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-12 17:46:52 +02:00
co-authored by Claude Opus 5.5
parent 968b6c78fb
commit 231a97c186
69 changed files with 1396 additions and 195 deletions
+26
View File
@@ -0,0 +1,26 @@
"""Module manifest — see core/modules/model.py and APPS_PLATFORM §4."""
from core.modules.model import Module, Mount, Perm, SettingDef
MODULE = Module(
key='fiscal',
kind='integration',
name='Fiscal device',
description='Send receipts to the fiscal device (ΦΗΜ) via its folder bridge.',
depends=('ordering',),
permissions=(
Perm('fiscal.manage', 'Set up the fiscal device', roles=('owner',)),
),
settings=(
SettingDef('fiscal.clerk_id', '2', "Clerk ID sent in CR/CD commands (integer string, e.g. '2')", type='int'),
SettingDef('fiscal.eftpos_id', '1', "EFTPOS terminal ID sent in CD commands (integer string, e.g. '1')", type='int'),
SettingDef('fiscal.enabled', 'false', "Master switch for fiscal printing: 'true' | 'false'", type='bool'),
SettingDef('fiscal.end_message', '[]', 'JSON array of up to 5 strings printed at end of receipt via FM commands', type='json'),
SettingDef('fiscal.in_folder', '', 'Path the backend reads fiscal reply files FROM (output of the fiscal driver)', type='json'),
SettingDef('fiscal.out_folder', '', 'Path the backend writes fiscal command files TO (input for the fiscal driver)', type='json'),
SettingDef('fiscal.type', 'txt_file', "Fiscal driver type: 'txt_file' (dTEC100extra) — more types coming", type='str'),
SettingDef('fiscal.vat_groups', '[]', 'JSON array of VAT group definitions: [{machine_id: int, friendly_name: str}]', type='json'),
),
routers=(
Mount('routers.fiscal', '/api/fiscal'),
),
)