refactor(gem): decompose default handlers per GEM capability + YAML role bindings

register_default_handlers was a relocated app main(): one 1086-line function,
all-or-nothing. It is now 15 per-capability registration functions along the
lines GEM itself defines (S1F19): identification, equipment constants, clock,
event reports, remote commands, trace/limits, spooling, alarms, exceptions,
material tracking (E90/E116/E157), carriers (E87), recipes, object services
(E39), jobs (E40/E94), terminal services. A sensor-class tool registers three
functions instead of carrying carrier/job handlers it doesn't have;
register_default_handlers composes all 15. Each function derives exactly the
runtime aliases its handlers use (generated programmatically from the moved
bodies with boundary/substitution guards — zero hand-retyping).

Magic constants are gone: the control-state/clock SVIDs (were hardcoded 1/2)
and the CJ Executing/Completed CEIDs (were 400/401) now come from a "roles:"
block in equipment.yaml via EquipmentDescriptor, with historical defaults
when absent, loader parsing, and validation (CEID roles must name declared
events). The coupling is now visible in ONE file instead of silently split
between YAML and C++ — the exact drift class this repo's spec-as-data
philosophy exists to kill.

Tests: capability subsetting, role-driven SVID refresh via S1F3, roles
loader (shipped/custom/absent). Battery: core 473/3087 incl. the 53-handler
conformance sweep, daemon 125/125, live GEM300 demo (client exit 0), daemon
interop 20/20 vs secsgem-py.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-06-10 22:43:41 +02:00
parent cf230d4119
commit 912304966f
9 changed files with 822 additions and 527 deletions
+9
View File
@@ -93,3 +93,12 @@ spool:
# CEID emitted automatically whenever the control state machine transitions
# (i.e. on every change-handler call). Set to null to disable.
emit_on_control_change: 100
# Role bindings: which of the ids declared above the engine's built-in
# behaviours target. Explicit here so the coupling is visible in ONE file
# instead of constants in C++ that silently had to match.
roles:
control_state_svid: 1 # refreshed with the control-state name on S1F3
clock_svid: 2 # refreshed with the clock string on S1F3
cj_executing_ceid: 400 # fired when a control job enters Executing
cj_completed_ceid: 401 # fired when a control job enters Completed