Issue #3608366: Extract the loop-free leaf services from the WorkflowExecutor: token lineage, variables, deadline math, definition resolution, incident store
First of the two follow-ups to #3608236 taking WorkflowExecutor below roughly 2000 lines (3290 to 2422 here; the join and subprocess rework in #3608367 does the rest). Every move is mechanical: docblocks and concurrency comments travel verbatim with their code, and no public signature changes anywhere.
Five leaf services, none of which depends on the executor, so the acyclic graph from #3608236 is preserved:
- TokenLineage (
orchestra.token_lineage, 211 lines): the token-tree walks:lineageIds(),descendantsOf()with the MAX_LINEAGE runaway guard,commonAncestorId(),cohortClosed(),loadToken(). - VariableResolver (
orchestra.variable_resolver, 256 lines):variablesFor()(the lineage-layered view, the engine's hottest read),setVariable()(the per-scope upsert plus audit), andreadInstanceValue()/readInternalCount()/deleteInstanceVariable()absorbing the raw internal-variable query so it never leaks to callers. - DeadlineCalculator (
orchestra.deadline_calculator, 259 lines):parkDeadline(),resolveDuration(), the "until" handling and the node-anchor pair; the pure absolute-date helperstoTimestamp()andapplyOffset()became statics on the existingDurationvalue class. - DefinitionResolver (
orchestra.definition_resolver, 136 lines):definitionFor(),effectiveDefinition(),loadDefinition(),resolveNode(). - IncidentStore (
orchestra.incident_store, 175 lines):raiseIncident(),claimIncident(),resolveOpenIncidents(),openIncidentCount(),openIncidentToken(), shared by the executor's loop and the IncidentManager's operator actions.
Side benefit: claimIncident(), definitionFor() and resolveNode() leave the executor's public surface (they were public only as a callback surface for the collaborators), and the executor drops its GatewayManager dependency.
Verified locally: root kernel suite (183 tests), unit plus all submodule kernel suites (328), all Functional suites in Docker (37), the FunctionalJavascript suites (6), phpcs, cspell, phpstan at parity.