Skip to main content

Module state_services

Module state_services 

Source
Expand description

What app_main starts once the app state exists, in the order it started them: the hooks that let an agent be reached and resumed, the job run ledger and the cron scheduler, the sagas an earlier run left unresolved, and the services that run beside the server. Moved out of app_main without a change in behaviour.

Functions§

announce_ready
Tells the launcher srv is ready (the pipe on Windows, then AGENTMUXSRV-ESTART), logs the boot summary and queues the saga log’s pruning.
attach_listeners
Hands the LAN listeners their routers and starts the dev proxy.
install_lan_sync 🔒
What this machine sends the machines on the LAN that are behind: fleet Global Memory entries, and the collections (Kanban boards) it shares with them (SPEC_USER_DATA_SYNC_LAYER §4.2).
install_message_brokers 🔒
Starts the services that run beside the server and need the app state. The panes that watch messages are told as they happen: the Audit when a row is written, the Atlas map when a message goes between two agents.
install_state_hooks
Wires delivery and the restart-time resumers to the app state, and starts the native memory watchers.
install_turn_outcome_notes 🔒
Tells whoever needs to know when a turn’s outcome wasn’t otherwise reported: a worker’s leader (worker_notes, SPEC_AGENT_WORKERS_2026_10_15.md §3.3), and, since #2627, whoever sent the message that started a turn which then died of a retryable failure (sender_failure_note).
install_withhold_alert 🔒
An Audit row when the registry of withheld values refuses a value or degrades its matching: a line with the counts, never a value.
open_stores_and_background
Opens every store and starts the background subsystems that need no app state, then what is read from the data folder.
publish_instance_record
Lists this instance for the other AgentMux instances on this machine (muxspect instances).
queued_alert 🔒
A callback that only queues each line; deliver runs on its own thread. The registry raises an alert from inside message delivery, where the handler’s lock is held, so a deliver that took that lock there would never return.
resume_unresolved_sagas
Compensates the sagas an earlier run left unresolved; non-fatal when it fails.
serve_until_shutdown
Serves the web and WebSocket listeners until one fails or stdin_token is cancelled.
shut_down
What runs once the servers have stopped: this channel leaves the LAN, then every agent closes.
spawn_background_task_sweep 🔒
Background-task rows end when their command exits, whose process is gone, or that nothing has reported on for a day (SPEC_BACKGROUND_TASK_STRUCTURED_FEED_AND_SWARM_OWNERSHIP_2026_09_27.md §5).
spawn_serving_loops
Starts the loops that run for as long as the servers do and stop with stdin_token.
spawn_spend_services 🔒
What agents spend through the model gateway is kept across restarts, and a cap reached is acted on (SPEC_ROUTE_AGENT_BRAKES_2026_11_10.md §3).
spawn_state_services
start_container_status 🔒
The Atlas map and the Swarm show this machine’s agent containers as they change (backend::container_status). A machine with no container runtime is looked at once.
start_data_home_services
Starts what is read from the data folder once the stores and watchers exist: widget packages, job templates and the Vault’s secret-file folder.
start_job_ledger_and_cron
Opens the job run ledger, closes the runs a restart interrupted, then starts the cron scheduler.