Back to home page

EIC code displayed by LXR

 
 

    


Warning, /swf-testbed/docs/e0-e1-state-machine.md is written in an unsupported language. File is not indexed.

0001 # The ePIC E0-E1 State Machine
0002 
0003 The datataking state model at the E0-E1 interface is a set of states and
0004 substates describing collider, detector, DAQ and calibration state.
0005 State will be maintained in a database kept current in real time,
0006 with the definitive version in E0, and mirrored in real time in E1. Current
0007 state will also be carried as
0008 operational metadata on the data and messages crossing the interface,
0009 recording the state at the time of the message.
0010 Downstream consumers — orchestration agents, monitoring, AI tools reading
0011 through MCP (Model Context Protocol) — read from it the datataking context
0012 of the data they are handling.
0013 
0014 The first version of the model is implemented in the streaming workflow
0015 testbed, where the simulated DAQ of the workflow layer drives all testbed
0016 activity through it. The simulator messages system state to participants in the testbed, modeling E0 as definitive state source with real time transmission to E1 via messaging (and concurrent recording in the testbed database).
0017 The state model and run structure are configuration, realized by the
0018 workflow runner and the agents: the runner takes each run through the
0019 state sequence, and the agents transmit and act on the state through the
0020 common state management of the agent base class. State flows through the
0021 system as messages — the run lifecycle (run imminent, start, pause and
0022 resume, end) and data availability vocabulary, each message stamped with
0023 the state and substate in effect — and data carries it too, in STF
0024 filenames (`swf.<date>.<time>.<state>.<substate>.stf`). The baseline
0025 workflows exercise most of the model in daily operation. Transitions are
0026 configured run structure today rather than event-driven; event-triggered
0027 state changes (a good-for-physics declaration, a fault dropping the
0028 detector out of physics) and detector and machine influences on the
0029 state are not yet modeled.
0030 
0031 This document is the state model's definition, maintained
0032 independently of the implementation. Evolution of the state model and its
0033 transition rules is one of the open questions of the E0-E1 interface
0034 named at the July 2026 collaboration meeting, with the interface to be
0035 formalized in the ePIC Streaming Computing Model report (target September
0036 2026); this document carries the current definition and its proposed
0037 near term evolution into that work.
0038 
0039 ## States
0040 
0041 | State | Meaning |
0042 |---|---|
0043 | `off` | Full shutdown — systems not operating |
0044 | `no_beam` | Collider not operating |
0045 | `beam` | Collider operating |
0046 | `run` | Physics running |
0047 | `calib` | Dedicated calibration period |
0048 | `test` | Testing, debugging; any substates can be present during test |
0049 
0050 ## Substates
0051 
0052 Substates fall in two families: readiness substates describing the
0053 collider/detector readiness progression, and data-flavor substates marking
0054 the kind of information flowing.
0055 
0056 Readiness substates:
0057 
0058 | Substate | Meaning | Occurs during states |
0059 |---|---|---|
0060 | `not_ready` | Detector not ready for physics datataking | `no_beam`, `beam`, `calib` |
0061 | `ready` | Collider and detector ready for physics, but not declared as good for physics | `beam` |
0062 | `physics` | Collider and detector declared good for physics | `run` |
0063 | `standby` | Collider and detector still good for physics, but standing by, not physics datataking (dead time) | `run` |
0064 
0065 Data-flavor substates:
0066 
0067 | Substate | Meaning | Occurs during states |
0068 |---|---|---|
0069 | `lumi` | Detector and machine data that is input to luminosity calculations | `beam`, `run` |
0070 | `eic` | Machine data, machine configuration | all |
0071 | `epic` | Detector configuration, data | all |
0072 | `daq` | Information and configuration transmitted from the DAQ | all |
0073 | `calib` | Calibration data types — a catch-all for many, starting small | all (assuming some calibration data can be taken during beam on) |
0074 
0075 ## Transitions
0076 
0077 The defined transitions:
0078 
0079 | Transition | Trigger |
0080 |---|---|
0081 | `off` → `no_beam` | Systems brought into operation |
0082 | `no_beam` → `beam` | Collider begins operating |
0083 | `beam`/`ready` → `run`/`physics` | Collider and detector declared good for physics |
0084 | `run`/`physics` ↔ `run`/`standby` | Datataking pause and resume: standby is the paused state, driven by the `pause_run` and `resume_run` run lifecycle messages in the testbed implementation |
0085 | `run` → `beam` | Collider or detector drops out of good for physics |
0086 | `beam` → `no_beam` | Collider stops operating |
0087 | `no_beam` → `off` | Full shutdown |
0088 
0089 The occurrence rules in the substate tables constrain which state/substate
0090 pairs are legal. A complete transition table — every legal transition, its
0091 triggering condition, and its side effects on the run boundary — is not
0092 yet specified.
0093 
0094 ## Relation to the Echelon 0 run-control model
0095 
0096 The DAQ group's run-control design (J. Landgraf, July 2026 workfest)
0097 states a convergent model from the E0 side: a state model incorporating
0098 continuously running components (such as scalers), a run structure that
0099 configures and selects the enabled detectors, and slow-controls status as
0100 part of the state model. Detector and readout status specifications will
0101 exist at many levels; at the highest level, which detectors are in the run
0102 combines directly with this model, and bears directly on early workflow
0103 integrations such as calibration.
0104 
0105 The remainder of this document proposes the convergence: how these E0
0106 run-control elements enter the state model on the E1 side.
0107 
0108 ## Proposed evolution
0109 
0110 The model above describes what runs in the testbed today. This section
0111 proposes its evolution toward the converged E0-E1 state machine, in light
0112 of the DAQ run-control design and the interface formalization. The
0113 proposal is a basis for discussion with the DAQ and streaming computing
0114 groups.
0115 
0116 ### The global state
0117 
0118 The state generalizes from a single (state, substate) pair to a global
0119 state. The pair carries over unchanged as core state and readiness; the
0120 E0 run-control elements are the additions:
0121 
0122 - **Detector participation** — which detectors are in the run, set by
0123   the run configuration, with per-detector status at the highest level:
0124   in or out. Finer granularity attaches beneath as specifications
0125   develop. Calibration workflows key on the participation of their
0126   detector; a test beam or commissioning configuration is a run with
0127   reduced participation.
0128 - **Slow-controls status** — the per-detector and machine-side
0129   good/degraded/bad rollup entering readiness evaluation; channel-level
0130   data remains in E0-side systems, referenced rather than mirrored.
0131 
0132 The DAQ model's continuously running components — scalers, some
0133 calibration flows — are steady state components: systems operating both
0134 in and out of datataking independently of the run lifecycle, carrying
0135 state alongside the run-scoped state.
0136 
0137 The global state across a datataking arc — concurrent components
0138 alongside the exclusive core state, where a vertical cut is the state at
0139 an instant:
0140 
0141 [![The E0-E1 global state](images/e0-e1-global-state-v1.svg)](images/e0-e1-global-state-v1.svg)
0142 
0143 An early realization route for detector scope is the testbed's
0144 namespace mechanism: namespaces already isolate and organize workflows
0145 and testbed instances, and a hierarchical namespace could carry
0146 (sub)detector scope as a higher-level segment, so that detector-scoped
0147 work — a per-detector calibration workflow, a test beam or commissioning
0148 configuration — runs in a namespace expressing its participation scope,
0149 combining the detector participation component with the isolation
0150 mechanism the testbed already operates.
0151 
0152 ### The state database and its E1 mirror
0153 
0154 State changes are events: each transition is appended to the state
0155 history with its trigger and timestamp, so the database answers both
0156 "what is the state now" and "what was the state when." One event stream
0157 feeds the E1 mirror and stamps the data and messages crossing the
0158 interface. E1 consumers — orchestration, monitoring, calibration
0159 workflows, AI tools through MCP — read the mirror and never reach into
0160 E0. The mirror is the E1 face of a state service with a read API; the
0161 write path belongs to E0.
0162 
0163 ## References
0164 
0165 - Source extracts from the July 2026 interface and DAQ talks:
0166   [E0-E1 interface source notes](e0-e1-interface-source-notes.md).
0167 - State machine definition and implementation status:
0168   [ePIC streaming workflow testbed, January 2026 collaboration meeting talk](https://docs.google.com/presentation/d/1YhWL6icswO5Dcy2dB5oFdKHXZ22o6Y3mdA9-lj6gtfk/)
0169   (state machine implementation slide).
0170 - Interface context and open questions:
0171   [E0-E1 interface notes, January 2026](https://docs.google.com/presentation/d/1hKGmzx91Q9FbFKKyMg_7TerNEVvY-8CxeAq6UINT1pc/)
0172   and [Echelon 0 - Echelon 1 Interface, Status and Open Questions, July 2026](https://indico.bnl.gov/event/31808/contributions/126678/).
0173 - Echelon 0 run-control model:
0174   [Introduction & Streaming DAQ: Overview, Requirements and Timeline, July 2026](https://indico.bnl.gov/event/31808/contributions/126677/).
0175 - Implementation: `swf-testbed/workflows/` — `daq_state_machine.toml`
0176   (the machine's base configuration), `stf_datataking.py` (the
0177   datataking workflow), `workflow_runner.py` (the common runner);
0178   `swf-common-lib` `BaseAgent` (the run lifecycle message vocabulary and
0179   the common agent state management).