Delivery and deployment services
Delivery and deployment services turn automated operational work into a usable outcome. They create reports, send notices to remote or local destinations, publish investigation results, host the agent turns that produce the work, and place the gateway service on a ready compute host. This page is a child of Operational automation; see Alert intake and scheduled work for the paths that start scheduled work, Operational analytics for result analysis, and GitHub CI repair automation for one automation consumer.
Delivery boundary
The delivery boundary separates operational work from the place where a person receives its result. A scheduled task produces one message, then a provider adapter sends that message to a channel or records it for the local shell.
Report production
Report production maps a scheduled task kind to the system that can produce its text. Investigation reports use the investigation runner seam. Agent-led reports use the headless agent runner seam. This keeps the scheduler independent of the tool and integration layers while still allowing those layers to provide the work.
The task builder also supports quiet results. A successful run with no findings can produce a clear quiet-period report, while a real pipeline error becomes a failed run instead of a false success. Credential values are not passed into report work as normal task data.
References: infrastructure/…/tasks.py• L30-52 infrastructure/…/tasks.py• L55-91 infrastructure/…/tasks.py• L195-368 infrastructure/…/investigation_runner.py• L29-77 infrastructure/…/agent_runner.py• L19-56
Channel delivery
Channel delivery sends the built message through an adapter selected at process start. Remote scheduled delivery supports provider-specific credential and destination checks. Interactive-shell delivery is local: it records the message in a shared inbox so a shell can show it without a remote messaging service.
One scheduled task can target more than one channel. The executor removes duplicate targets, retries loop channels, and reports partial delivery when at least one channel succeeds but another does not. Provider support is deliberately a subset for each consumer, so a provider listed in the common vocabulary is not automatically valid for every feature.
The common delivery vocabulary includes Telegram, Slack, Rocket.Chat, Discord, the interactive shell, and Buzz. The actual supported set depends on the consumer and its adapter wiring.
References: infrastructure/…/delivery_bundle.py• L22-60 infrastructure/…/delivery.py• L121-160 infrastructure/…/delivery.py• L191-248 infrastructure/…/executor.py• L168-245 infrastructure/…/executor.py• L272-330 infrastructure/…/local_delivery.py• L47-111 infrastructure/…/types.py• L38-56
Run coordination
Run coordination makes a scheduled tick safe when more than one scheduler process is active. The scheduler uses a stable UTC fire time as the run identity. A shared claim store accepts only one claim for a task and fire time, then records the final status and delivery result.
The scheduler reads enabled tasks, turns their cron schedules into jobs, and can reconcile jobs while running. Task changes wake the scheduler so an operator does not need to restart the service. Run records and scheduler operations provide the history needed to distinguish skipped, successful, partially delivered, and failed work.
The scheduled flow is therefore:
flowchart LR
A[Persisted task] --> B[Cron trigger]
B --> C[Claim one fire time]
C --> D[Build report]
D --> E[Deliver through adapters]
E --> F[Record outcome]
References: infrastructure/…/runner.py• L100-189 infrastructure/…/runner.py• L204-281 infrastructure/…/executor.py• L26-142 infrastructure/…/claim_store.py• L1-70 infrastructure/…/operation_log.py• L134-175
Turn hosting
Turn hosting provides one shared path for an inbound message to become an agent response. It keeps transport code focused on authorization and session lookup. The host binds the session, output channel, cancellation signal, and capacity policy before it runs the agent.
Session hosting
Session hosting keeps one headless agent for each logical session and reuses it across messages. Each turn binds the current session and output before execution. Turns for different sessions can run at the same time, while turns for one session are kept in order so streamed output cannot move to another message.
The output contract carries progress, tool status, streamed text, and the final answer back to the caller. This lets chat transports and in-process callers use the same turn behavior without creating separate agent runners. A shell session can also retain only its current session when it rotates, which prevents old agents and outputs from remaining live without a caller.
Gateway chat also records the capabilities it withholds from a session: access to the hosted gateway, choosing the language-model provider, and cancelling a task. When the gateway hosts the scheduler in its own process, the policy also marks that mode for scheduling tools, so they register tasks in the store instead of trying to install an operating-system service. The agent harness reads this policy when it plans a turn, so the gateway does not promise actions that it cannot provide.
Unattended sessions give remote or scheduled work a fresh session with no person watching the turn. They disable interactive actions, runtime switching, and terminal-only commands. If the agent needs a user choice, the session records it as deferred instead of waiting for a reply. The caller can later resume that session and submit a checked answer. Approval choices are tied to the exact tool call, so an approval cannot silently move to a different set of arguments. A session reapplies its unattended policy when it resumes and can flush its pending state before it closes.
References: infrastructure/…/turn_runner.py• L64-75 infrastructure/…/turn_runner.py• L104-185 infrastructure/…/turn_runner.py• L240-278 infrastructure/…/session_agents.py• L53-126 infrastructure/…/session_agents.py• L128-195 infrastructure/…/turn_output.py• L15-21 infrastructure/…/capability_policy.py• L1-36 infrastructure/…/unattended_session.py• L1-172
Capacity control
Capacity control protects the process from too many concurrent turns. Chat and synchronous investigation requests fail fast with one shared capacity message. Work that was already accepted by a queue, including scheduled work and queued remote prompts, waits for a bounded time for a slot instead of being discarded immediately.
The same process-wide gate covers chat turns, HTTP investigations, and scheduled runs. A size profile supplies the default limit, and an explicit positive limit can raise it. An invalid or non-positive override is ignored so a bad setting does not remove the capacity guard. This shared policy prevents one entry path from consuming all turn capacity needed by another.
References: infrastructure/…/concurrency.py• L27-69 infrastructure/…/concurrency.py• L72-120 infrastructure/…/slots.py• L1-69 infrastructure/…/runners.py• L35-75 infrastructure/…/turn_runner.py• L114-175
Turn cancellation
Turn cancellation gives each running turn one cancellation signal. A stop request or a host timeout sets that signal. The turn host exposes it through the console used by tools and the agent, then avoids replacing an output that the timeout or stop path already completed.
References: infrastructure/…/cancel_console.py• L1-53 infrastructure/…/turn_runner.py• L164-264
Process hosting
Process hosting gives each service a known boot path and a clear runtime role. Shared boot loads the environment and installs the adapters needed by the selected host. The long-running scheduler and the gateway use these shared services but remain separate process profiles.
Process profiles
Process profiles describe the hosts that can run the system: CLI, gateway, web, scheduler worker, scheduled command, and embedded use. A fixed boot order keeps environment loading ahead of adapter setup. Scheduler workers install both the runner seams and delivery adapters before they accept scheduled work.
Process-wide runtime flags give these hosts one shared execution context. The command-line entry point sets options such as output format, verbosity, debug mode, confirmation, onboarding, and interactive behavior. Integrations and tools read the same state through the process package, so they do not need to depend on the command-line layer. A reset returns the flags to their default user-facing behavior.
References: bootstrap/process.py• L35-133 bootstrap/process.py• L169-200 infrastructure/…/__init__.py• L1-26 infrastructure/…/runtime_flags.py• L1-81
Process monitoring
Process monitoring watches a selected process and turns resource limits into operational alarms. It samples liveness, CPU, memory, and run time. Permission errors remain distinct from process exit, so a watchdog does not report a healthy but unreadable process as dead.
When a threshold is breached, the watchdog sends an alarm through its configured dispatcher. It supports Telegram, Rocket.Chat, and Buzz for this feature. A per-key cooldown suppresses repeat alarms for a short window and reserves the key before the network call, so concurrent checks cannot send the same alarm twice. A one-shot run can stop after its first alarm.
References: tools/…/config.py• L14-22 tools/…/config.py• L91-146 tools/…/process_monitor.py• L15-92 tools/…/runner.py• L49-109 tools/…/runner.py• L112-151 infrastructure/…/cooldown.py• L1-42
Deployment lifecycle
Deployment lifecycle support turns a gateway release into a running and checked service on Amazon EC2. It validates the deployment environment, creates the required cloud resources, starts the gateway, and waits for a service-level ready state before it reports success.
Release artifact assembly
Release artifact assembly makes frozen and packaged releases contain the code and data that operational automation needs at run time. It includes dynamically loaded runtime packages, built-in action skills, loop templates, runtime skill data, explicit runtime data files, and infrastructure data. It leaves out trees that run through a separate deployment system.
The manifest discovers these inputs from known runtime roots and records paths in the form required by the release builder. It excludes files that are not runtime modules and infrastructure trees that have their own deployment path. This gives packaging one source for dynamically loaded modules and runtime data, and reduces the risk that a packaged service starts but loses a tool, skill, template, or data file.
Before the release build, the version sync step converts a release tag or explicit version into the canonical form used by package metadata. This keeps the release smoke check and release notes aligned with the installed package version, including local revision values that contain only digits.
References: infrastructure/…/release_manifest.py• L7-26 infrastructure/…/release_manifest.py• L29-59 infrastructure/…/release_manifest.py• L62-97 infrastructure/…/sync_release_version.py• L13-49
Gateway deployment
The gateway deployment supports two release paths. The image path installs a chosen code revision on a temporary builder, saves that host as a reusable image, and launches later servers from it. The direct path launches a clean server and installs the published binary on that server. The first path favors fast repeat launches. The second favors a simple path without a local image build.
Both paths create an instance role and network boundary, wait for the host and its management agent, provision the gateway settings, and retain deployment outputs for later cleanup. The EC2 gateway is Telegram-only in this deployment path; Slack is operated by a separate gateway so its event consumer is not duplicated.
References: infrastructure/…/lifecycle.py• L164-249 infrastructure/…/build_server_image.py• L134-243 infrastructure/…/install_on_new_server.py• L236-347 infrastructure/…/prep_ec2_deployment.py• L64-126
Gateway readiness
Gateway readiness checks both the service state and an application-ready signal. Provisioning writes the runtime environment through the host management service and restarts the system service. The deployment does not finish until the service is active and its ready signal is visible.
The general deployment health helper also polls a base URL. It tries /health and then /ok, and it reports a timeout when no candidate returns HTTP 200 within the poll budget.
References: infrastructure/…/provision.py• L51-141 infrastructure/…/health_poll.py• L23-79
Service-family resolution
Service-family resolution gives operational tools a stable group name for related integration instances. A family is the canonical bucket for several instances of one service, such as multiple variants of the same monitoring system. The tool layer asks for that bucket without importing the integration registry directly.
The integration layer registers the concrete resolver during startup. Until then, the system uses the service key itself. This fallback keeps lightweight callers deterministic while the registered resolver can merge related service keys for normal operation.
References: infrastructure/…/families.py• L1-50 infrastructure/…/__init__.py• L1-9
Change checklist
When these files or sections are changed, remember to consider these:
- When adding a scheduled task kind, update the task-to-report mapping and the runner wiring that supplies its report source.
- When adding a delivery provider, update the provider vocabulary, adapter bundle, readiness rules, destination resolution, and each consumer's supported subset.
- When changing task identity or scheduling fields, keep the persisted task identity and the claim-store
(task, fire time)identity aligned so a schedule is not merged or posted twice. - When changing a host or turn entry point, keep it on the shared process gate and choose fail-fast or queued capacity behavior based on whether the work can be retried.
- When changing unattended turn behavior, keep its disabled capabilities, deferred choice flow, approval identity, and resume-time policy aligned with every caller that runs without a person watching.
- When a gateway hosts the scheduler in-process, keep its scheduler-host capability aligned with the scheduling tool's choice between store registration and operating-system service installation.
- When changing process-wide runtime flags, keep the CLI bridge, the shared process contract, and all consumers aligned so output and interaction behavior do not diverge between hosts.
- When changing release inputs, update dynamically loaded code, action skills, loop templates, run-time data, and infrastructure exclusions so packaged and frozen releases have the same capabilities without bundling separately deployed trees.
- When changing release version normalization, keep package metadata, release smoke checks, and release notes on the same canonical version string.
- When changing gateway service setup, keep environment validation, image installation, direct installation, provisioning, and readiness checks consistent.
- When changing service keys or integration registration, preserve the family resolver binding and its identity fallback.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| No scheduled delivery adapter is installed for a task provider | The task fails at delivery instead of reaching a channel | Install the delivery adapter bundle during the host boot path |
| A remote channel lacks the credentials or destination required by that task | The run is marked failed or partially delivered | Validate provider readiness and task-specific destinations before enabling the schedule |
| A dynamically loaded module, skill, loop template, or run-time data file is absent from a packaged release | The frozen service starts with missing tools or agent behavior | Build the artifact from the release manifest and validate its module and data entries |
| A release tag and package metadata use different version forms | Release checks or release notes report a version that does not match the built package | Normalize the tag or explicit version before the build and use the resulting package version for release checks and notes |
| Two scheduler processes handle the same cron tick | Only one should post; the other skips the claimed run | Use the stable UTC fire time and the unique claim-store key |
| A task has an invalid cron expression or time zone | The task is skipped and is not registered as a scheduler job | Validate the schedule and inspect the scheduler operation log |
| A turn reaches the process capacity limit | Chat or synchronous investigation gets an immediate capacity response; queued work waits | Use the shared gate and the correct fail-fast or queued slot helper |
| An accepted remote prompt reaches the capacity limit while the wait window expires | The prompt returns without running the agent | Use the bounded waiting slot for accepted work and set its wait budget for the caller |
| An unattended turn waits for an interactive capability | Remote or scheduled work cannot finish because no person can answer it | Disable interactive actions and defer user choices in the unattended session policy |
| An approval is resumed with a different effective tool call | The prior approval does not apply to the resumed action | Build the approval identity from the tool arguments after removing omitted, null, and default values |
| A gateway-hosted scheduler lacks its in-process host capability | A scheduling tool can try to install a service that the gateway process cannot run | Advertise the in-process scheduler mode in the gateway session policy |
| A process reads runtime flags from a different state than the shared process contract | The same command can show different output or prompt behavior across layers | Set flags through the CLI bridge and expose them through infrastructure.process |
| The watchdog can resolve a process but cannot read its fields | Threshold evaluation cannot be trusted | Treat the sample as inaccessible and retry, or fix permissions before monitoring |
| The gateway service does not become active and ready | Deployment stops with a readiness timeout | Check SSM status, service logs, and the gateway ready signal |
Key files
| File | Why to read it |
|---|---|
| infrastructure/…/executor.py | Connects claim, report creation, fan-out delivery, and run outcome. |
| infrastructure/…/runner.py | Shows how persisted schedules become live jobs and how the scheduler resyncs. |
| infrastructure/…/delivery_bundle.py | Defines the provider-neutral adapter boundary. |
| infrastructure/…/tasks.py | Shows the supported report families and their runner seams. |
| infrastructure/…/claim_store.py | Defines duplicate protection and run history. |
| infrastructure/…/turn_runner.py | Defines the one shared inbound turn path. |
| infrastructure/…/session_agents.py | Explains session reuse and same-session isolation. |
| infrastructure/…/concurrency.py | Defines process-wide turn capacity. |
| infrastructure/…/capability_policy.py | Defines capabilities that gateway chat withholds from the agent session and the in-process scheduler mode. |
| infrastructure/…/unattended_session.py | Defines the short-lived, non-interactive session used by work with no person watching, including deferred choices and approval hand-off. |
| bootstrap/process.py | Defines host profiles and shared boot order. |
| infrastructure/…/runtime_flags.py | Defines the shared process-wide behavior flags used across command-line and non-command-line layers. |
| infrastructure/…/__init__.py | Exposes the process status and runtime-flag contract to its consumers. |
| tools/…/runner.py | Shows process sampling, threshold alarms, and notification dispatch. |
| infrastructure/…/cooldown.py | Defines the concurrency-safe per-key alarm cooldown. |
| infrastructure/…/release_manifest.py | Defines the code, skill, template, and data inputs for packaged and frozen releases. |
| infrastructure/…/sync_release_version.py | Aligns release tags or explicit versions with the package metadata used by the build. |
| infrastructure/…/lifecycle.py | Shows the gateway deploy and destroy lifecycle. |
| infrastructure/…/provision.py | Shows service provisioning and gateway readiness checks. |
| infrastructure/…/families.py | Defines the boundary between tool availability and integration-family mapping. |