Production Scheduling Runtime Entrypoint
How a Production Scheduling Node instance runs as a process. engine/production_scheduling_main.py
turns this Node Type's config file into a running Node the way engine/node_main.py does for MES and
engine/erp_main.py does for ERP. It wires ProductionSchedulingIngestion, the current_shift answer and PeerListener into one process.
What a running instance does
python -m engine.production_scheduling_main \
--node-type-dir node-types/production-scheduling \
--config /var/lib/kindred-management/staged/config.json \
--node-instance-id scheduling-1
Options:
--node-instance-idis required.--node-type-dirdefaults tonode-types/production-scheduling.--configdefaults to that directory'sexample_node_config.json.--shared-config-dirnames the directory that a config's"$shared"fragment references resolve against (see Sharing configuration fragments).
Settings:
PENDING_SUMMARY_HEARTBEAT_SECONDSsets the interval of the pending-summary announcement (1 to 86400 seconds).RUNTIME_STATE_PATHnames the runtime-state file shared with the management service.
On an appliance this is run by kindred-node.service, which deployment/install_node_service.sh --node-type "Production Scheduling" installs. A running instance does four things:
Polls the external scheduler. rest.poll_path is read on the cadence rest.poll_interval_seconds
gives (default 5 s). A record that differs from the last one polled becomes one
ProductionSchedulingIngestion.ingest() call, which resolves its Schedule identity on the scheduler's
own schedule_id. The same schedule_id with a changed resource or time window is a revision: it is
reconciled onto the existing record, not stored as a second one. A record identical to the last is not
ingested again. An unreachable scheduler or a malformed response is logged and skipped; the next tick
tries again.
Answers the current_shift query. The Communication Interface listener answers
{"query": "current_shift"} with the scheduler's own shift_start and shift_end, read live from
rest.shift_path (default /shift/current) through the same authenticated connector the poll uses.
A scheduler that cannot be reached, or an answer without both fields, is answered with no fields at
all. MES treats that exactly like an unreachable peer.
Answers the two fetch queries. activity_log_entries and identity_record are answered from this
Node's own Activity Log and Identity Store, the same as on every other Node Type, so a peer can build an
order trail or a genealogy that includes this Node's part
(communication-interface.md).
Stops cleanly. A SIGTERM from the service manager ends the dispatch loop, closes the connector
and the listener, removes the runtime-state file and the TLS reload pid file, and exits with status
143, which the unit counts as a normal stop.
How MES uses the answer
MES asks for the current shift once, when its shift handoff task is constructed. It seeds the first summary window from, in order:
- the scheduler's boundary, from a running Production Scheduling instance listed in MES's
communication_interface.peers(node_typeProduction Scheduling); - the shared
shift_handoff.shift_schedule, when the config has one; - the construction time minus the configured shift duration.
Stopping this Node, or taking its scheduler down, moves MES to the second step the next time MES starts. It is a startup seed: a MES that is already running is not re-seeded.
Configuration
The example is node-types/production-scheduling/example_node_config.json. The config needs a rest
section and a communication_interface section. In production mode the listener refuses to start
without mutual TLS, as it does for MES and ERP (see site-pki.md).
rest field | Meaning |
|---|---|
endpoint, api_key |
The scheduler and the credential it accepts (required). |
auth_path, poll_path |
Where the token is requested and the schedule record is read. |
timeout_seconds |
Per-request timeout of the scheduler connector, greater than 0. Default 30. |
poll_interval_seconds |
Seconds between polls. Default 5. |
shift_path |
Where the current shift is read. Default /shift/current. |
field_map or state_transition_rules |
How the scheduler's record maps to schedule_id, order_id, resource_id, window_start, window_end. Rules take precedence. |
Pitfalls
schedule_observedonly records the observation. Nothing drafts anything from a bare schedule observation, so the handler registered for it (the same one ERP uses formaterial_observed) marks the row done and leaves one Activity Log entry, task typetrigger-dispatch: observation recorded. The Schedule identity record is resolved and reconciled before that. A Node Type that gains a Task for the observation registers its own handler for the trigger type in place of this one. The entry appears per changed record and once per restart, because a restarted Node polls the same record again.- One record per poll.
poll_pathis read once per tick and returns one record, matching ERP's single-record scope. A scheduler that returns a list needs a path that selects one slot. - The answer is only as fresh as the scheduler.
shift_startandshift_endare relayed as the scheduler reports them, never computed here. MES rejects a boundary in the future and falls back. - A restart applies a new config. A staged config takes effect when the service restarts.
Release: v0.11.0