Alert intake and scheduled work
OpenSRE turns operational signals into investigations, reports, and notices through several entry paths. External alerts can enter a running process for operator review, explicit investigation requests can run in the foreground or in a worker, and saved schedules can start recurring agent or investigation work. This page is a child of Operational automation; Delivery and deployment covers downstream report and service-hosting concerns, Operational analytics covers the records used to inspect operations, and GitHub CI repair automation covers one scheduled agent path.
Operational work sources
Operational work starts from an alert, an explicit investigation request, or a saved schedule. These paths share the investigation and delivery services where useful, but they have different ownership and response rules.
| Source | First result | Work that follows |
|---|---|---|
External POST /alerts | An alert enters the process inbox | The interactive shell shows it and records it for status views. It does not start an investigation by itself. |
| Interactive shell background mode | A task and background investigation record | A detached investigation runs while the shell remains usable. |
| Asynchronous HTTP investigation API | A queued investigation record and an ID | A worker claims the record, runs the investigation, and stores the report. |
| Scheduled task | A cron tick | The scheduler admits the tick, runs the selected agent or investigation runner, and delivers the result. |
The main relationship between these paths is that intake is not the same as execution. The alert inbox is a short-lived signal buffer, while background and scheduled work have their own task or run state.
This diagram shows how an external signal or saved schedule reaches automated operational work.
flowchart TD
alert[External alert] --> intake[POST /alerts]
intake --> inbox[Process alert inbox]
inbox --> shellView[Shell alert view]
request[Explicit investigation request] --> queued[Investigation queue]
queued --> worker[Background investigation worker]
schedule[Saved scheduled task] --> cron[Scheduler cron tick]
cron --> executor[Task executor]
executor --> runner[Investigation or headless agent runner]
runner --> delivery[Report delivery]
worker --> report[Stored investigation report]
Work initiation paths
The system keeps signal receipt separate from long-running work so an alert sender receives a quick queue response and a scheduler can manage its own timing. Investigation requests and scheduled tasks then use the appropriate worker or runner for their lifetime.
References: infrastructure/alert_intake.py• L119-160 gateway/…/investigations.py• L90-117 infrastructure/…/runner.py• L178-224
Alert intake
The alert intake service accepts small JSON alert objects and places valid alerts into a process-wide inbox. The gateway web app and the interactive shell can host the same intake router, which keeps the alert boundary independent from either host.
HTTP alert intake
home/…/alert_intake.py exposes POST /alerts as a fast intake path. A request must pass the local-or-token trust check, stay within the request-body limit, provide a bounded JSON object, and include alert text; the service supplies a receive time when the sender does not provide one. A valid request returns 202 Accepted with queue information rather than waiting for investigation work.
The inbox has a fixed capacity. When it is full, the oldest alert is removed so a new alert can enter, and the response reports that an alert was dropped. This protects the host from unbounded alert traffic while making loss visible to the sender.
References: infrastructure/alert_intake.py• L34-52 infrastructure/alert_intake.py• L114-172 core/…/inbox.py• L18-45
Alert host paths
The gateway starts an inbox before it serves its web app. The interactive shell starts a local listener only when its alert-listener setting is enabled, then stops that listener with the shell. Both hosts can therefore receive the same alert shape, but the shell also owns the live display of queued alerts.
Remote callers need the gateway's OPENSRE_GATEWAY_LISTENER_TOKEN; during rollout, the older OPENSRE_ALERT_LISTENER_TOKEN is also accepted. Without a configured token, only trusted loopback program calls can mutate the inbox; browser calls that reach loopback from another site are rejected. The listener reports health separately from alert acceptance, so a health check does not imply that an investigation worker is running.
References: infrastructure/alert_intake.py• L34-112 gateway/…/startup.py• L27-43 surfaces/…/controller.py• L72-109 gateway/…/webapp.py• L54-60
Alert presentation
The shell watcher waits for the inbox event and drains alerts as they arrive. It renders each alert and records it in the shell session, while the /status view can use the bounded session history later. This path makes incoming signals visible without coupling alert receipt to a slow agent turn.
References: surfaces/…/workers.py• L21-52 surfaces/…/workers.py• L89-107 surfaces/…/__init__.py• L95-112 surfaces/…/alert_inbox.py• L21-40
Background investigation triggers
Background investigations are explicit long-running jobs. They let an operator start an investigation from text, a file, or a sample alert without blocking the interactive prompt, and they keep enough state for later review.
Interactive shell background investigations
When background investigation mode is active, the shell routes text and sample-alert requests to a daemon worker instead of running them in the foreground. The launcher creates a task record, starts the investigation with cooperative cancellation, and posts a notice when the work completes, fails, or is cancelled.
The result is reduced to a durable background-investigation record. That record carries the task identity, outcome, root cause, key analysis, next steps, and notification results. The store is shared across processes and retains a recent history, so the result can outlive the shell session.
References: surfaces/…/investigation.py• L299-320 surfaces/…/investigation.py• L369-383 surfaces/…/runner.py• L153-258 core/…/background_investigations.py• L22-55
Asynchronous HTTP investigations
The authenticated /api/investigations API is a separate queue-based trigger for clients that cannot hold an HTTP request open. It creates an organization-owned record, returns an investigation ID, and starts the worker when the process is configured to run one.
The worker claims queued records, waits for the shared process capacity, runs the canonical investigation path, and saves local and optional durable report artifacts. Clients poll the record for completion or failure. A client can cancel only while the record is still queued.
References: gateway/…/investigations.py• L55-117 gateway/…/investigations.py• L121-178 gateway/…/worker.py• L47-89 gateway/…/worker.py• L91-135
Investigation result storage
Background investigation state has two roles. The task registry supports live shell control such as listing and cancelling work, while the background-investigation store preserves the investigation result for later inspection and notification tracking.
The result store writes one organization-scoped document under a file lock and rotates old records. A damaged store is treated as an error rather than silently replaced, because replacing it could erase the investigation history.
References: infrastructure/…/task_registry.py• L30-51 infrastructure/…/task_registry.py• L132-178 infrastructure/…/store.py• L58-107 infrastructure/…/store.py• L143-210
Scheduled work
Scheduled work uses a persisted task definition for intent and a separate execution record for each attempt. The scheduler validates the trigger, admits each fire time before worker submission, claims the tick with a lease, runs the selected work path, and separates work outcome from message delivery.
Schedule definitions
A scheduled task names the work kind, cron expression, time zone, delivery provider, destination, reporting window, and optional parameters. Supported kinds cover recurring investigations, headless agent reports, pinned recurring skills, operational checks, work-item notices, and interactive-shell loops.
Tasks can carry an owning organization. The task store treats that owner and the full schedule behavior as part of schedule identity, so repeated confirmation of one schedule does not create duplicate work while matching schedules from different organizations remain separate. Task visibility also follows the current organization scope; non-organization contexts can inspect the shared store.
Loop ownership is separate from delivery. A loop made by a member can be shared or private; a private loop runs as its owner and uses that member's personal connections and memory, while a shared loop uses workspace connections. Process-created loops have no member owner. Private loops are visible and editable only to their owner.
Schedules accept the standard five-field cron form. A six-field form adds seconds for work that must poll more often than once per minute. Cron weekday numbers keep crontab meaning, including both 0 and 7 for Sunday. Invalid fields, run times, or time zones are rejected before a task can become an active schedule. Ordinary prompt loops are capped at no more than one run per hour, while the CI repair loop can keep a faster polling schedule.
The shell's loop helpers provide a human-facing way to create recurring prompt tasks. A loop can frame a tick as a report or as an agent action. It can also name a deterministic report builder instead of using a model turn. Loops can deliver to the interactive shell and configured external channels. Repeating the same complete schedule resolves to one stored task instead of creating duplicate work. Loop summaries classify an enabled loop as active, a disabled loop with prior work as paused, and a disabled loop with no prior work as draft.
Loop edits apply to the current loop group instead of creating replacement tasks. They validate the changed name, prompt, schedule, time zone, lookback window, mode, and delivery settings as one update. A prompt or mode is editable only for an ordinary stored-prompt loop; managed templates, deterministic reports, and skills keep their instructions under their owning source. Delivery edits can change the supported loop channels and their destinations, while one-shot work-item reminders are not edited through the loop interface.
Loop text has two sources. A named shipped template supplies the current prompt and description when it is available; a stored copy remains as a fallback if the template is no longer shipped. An agent loop can use a skill from the active catalog or an installed skill folder. Catalog skills resolve by name, while an installed skill stores its absolute folder and reads SKILL.md again on every tick, so an updated local skill affects the next run. An installed card must be readable, non-empty, and no larger than 64 KiB. Either skill source fails rather than running without its required recipe, and skills that need helper scripts or an entry menu are not valid scheduled loop recipes.
Onboarding seeds disabled starter loops. They show useful schedule examples without sending messages until an operator enables or creates a loop.
References: infrastructure/…/cron_expression.py• L1-12 infrastructure/…/cron_expression.py• L98-126 infrastructure/…/cron_expression.py• L159-179 infrastructure/…/installed_skill.py• L15-54 infrastructure/…/loop_constants.py• L20-62 infrastructure/…/loop_edit.py• L55-165 infrastructure/…/loop_edit.py• L168-234 infrastructure/…/loop_owner.py• L45-92 infrastructure/…/loops.py• L339-452 infrastructure/…/loops.py• L484-575 infrastructure/…/loops.py• L606-653 infrastructure/…/task_store.py• L260-351 infrastructure/…/task_visibility.py• L11-17
Scheduled report format
Scheduled loop work produces portable Markdown with a fixed report shape. The loop prompt defines the subject, while the shared report guide defines a short title, one-line headline, focused sections, concise bullets, links, time display, and a coverage note when source data is incomplete. Delivery adapters render that Markdown for each destination, so the agent does not write provider-specific syntax.
The guide also sets a length budget from the configured destinations. This keeps one report readable when a loop fans out to channels with different display limits and preserves the same operational message across those channels.
References: infrastructure/…/report_style.py• L1-14 infrastructure/…/report_style.py• L22-84 infrastructure/…/report_style.py• L87-98
Schedule execution
The scheduler uses the trigger's intended fire time as the identity of a tick. It normalizes that time to UTC and keeps seconds in the key, so a sub-minute schedule cannot collapse several fires into one run. A pending record is written before worker submission, and the execution claim then prevents another host from running the same task and fire time.
The scheduler limits total scheduled workers and allows only one active instance of each task. A claimant holds a two-minute lease. One shared renewal loop confirms active leases, and the worker checks confirmed ownership before it retains or delivers a report. If a process stops renewing, recovery can claim the unfinished attempt after the lease expires.
Schedule edits carry a cutover time. Pending automatic ticks from before the edit, or ticks that no longer match the new trigger, are retired or skipped. Explicit run-now and retry actions use a distinct fractional fire-time key, so an operator action is not rejected as an obsolete automatic tick.
This diagram shows the normal scheduled lifecycle and the recovery path for work that loses its owner.
flowchart TD
definition[Enabled task definition] --> trigger[Validated cron or date trigger]
trigger --> pending[Persist pending fire time]
pending --> claim[Claim leased execution]
claim --> build[Build report or agent result]
build --> retained[Retain report and work outcome]
retained --> fanout[Resolve and deliver destinations]
fanout --> run[Record per-target delivery and run status]
claim -. lease expires .-> recovery[Recovery sweep]
recovery --> claim
definition -. edited, disabled, or removed .-> skipped[Skip obsolete or cancelled tick]
claim -. cancellation recheck .-> skipped
When a scheduler starts after a short outage, it can run the latest missed fire within the allowed catch-up window. Several missed slots coalesce to the latest one, and a recorded fire time is not run again. A dedicated scheduler can remain idle with no enabled tasks, while an embedded host can stop when its filtered task set becomes empty.
References: infrastructure/…/runner.py• L117-137 infrastructure/…/runner.py• L178-319 infrastructure/…/runner.py• L348-431 infrastructure/…/runner.py• L434-609 infrastructure/…/runner.py• L630-691 infrastructure/…/claim_lease.py• L31-100 infrastructure/…/schedule_change.py• L12-33 infrastructure/…/run_store.py• L155-316
Schedule cancellation
Schedule cancellation keeps a worker from completing work after an operator disables or removes its task. The executor re-reads the task state before message building, report retention, and delivery, while queued and expired ticks are completed as skipped so recovery cannot revive old work.
A disabled task is skipped as disabled; a removed task is skipped as missing_task. A missing task store is not treated as cancellation because an in-memory or not-yet-persisted task may still be valid. A terminal work block can pause a task as part of normal outcome handling without being mistaken for a user cancellation. An explicit run-now operation can continue through a pause, but deletion still cancels it.
References: infrastructure/…/schedule_cancel.py• L27-74 infrastructure/…/executor.py• L124-185 infrastructure/…/executor.py• L197-262 infrastructure/…/runner.py• L226-289 infrastructure/…/task_store.py• L354-394 infrastructure/…/run_store.py• L392-454
Scheduled work outcomes
The scheduler records two related facts for each run. The work outcome states whether the requested operation succeeded, did nothing, was blocked, failed, or remained incomplete. Delivery outcomes state what happened at each destination, so a successful report can still have partial delivery.
The built report is retained before delivery. This gives recovery and failed-only retry a safe copy of the work result without running the agent again. A failed-only retry narrows to destinations with known failures; unreadable or missing target history does not widen the retry to every destination. A non-retryable block pauses the schedule after the result is recorded.
References: infrastructure/…/outcomes.py• L8-49 infrastructure/…/types.py• L108-195 infrastructure/…/executor.py• L230-373 infrastructure/…/runner.py• L694-794 infrastructure/…/run_store.py• L505-526 infrastructure/…/run_store.py• L676-707
Scheduled delivery
After a report is built, the executor resolves the task's destinations once and sends the same report through the installed provider adapters. Explicit provider-and-chat targets take precedence over loop channels; otherwise the configured channels resolve to ordered, de-duplicated destinations. Email loops are validated with a sender account and bounded recipient list. Each target keeps its own success, message ID, error, and attempt count in the run record.
A task can produce no message on a quiet tick, such as an uptime watch with no state change. That tick is recorded without delivery. When several destinations are configured, partial success remains visible in the run record instead of being hidden as a full failure.
Interactive-shell loops use a local delivery inbox. The shell adapter strips HTML before it records the report, then sends a delivery event to analytics. The event keeps a stable message ID and delivery time, so a repeated capture updates the same analytics record. Registration passes can resend up to 50 reports from the last six hours at most every 30 minutes; malformed or incomplete messages are skipped, and analytics opt-out disables the resend. The task registry supplies the organization for each resend.
References: infrastructure/…/delivery_plan.py• L1-13 infrastructure/…/delivery_plan.py• L68-131 infrastructure/…/delivery_plan.py• L134-228 infrastructure/…/loops.py• L339-452 infrastructure/…/loops.py• L784-839 infrastructure/…/executor.py• L287-373 infrastructure/…/interactive_shell_delivery.py• L20-32 infrastructure/…/loop_report_telemetry.py• L65-120 infrastructure/…/local_delivery.py• L27-112
Run continuity
Each scheduled loop tick starts in a fresh session, but its run history can provide limited context to the next tick. The run record keeps the final report, work and delivery outcomes, compact summaries of successful mutating or external actions, and a short carry-forward note. Read-only and bookkeeping calls are omitted, and action text is shortened and credential-redacted before it is stored.
The next tick receives only recent finished attempts for its own task. The history is marked as quoted data rather than instructions, redacted before it is shortened, and bounded so a report or external text cannot take over the next prompt. This lets a loop follow up on prior work without treating an old file dump or report excerpt as a new task.
References: infrastructure/…/previous_runs.py• L1-17 infrastructure/…/previous_runs.py• L72-79 infrastructure/…/previous_runs.py• L184-227 infrastructure/…/run_activity.py• L41-90 infrastructure/…/tool_actions.py• L1-12 infrastructure/…/tool_actions.py• L157-234
Run history
Execution state has two complementary records. SQLite is the authority for claims, leases, reports, outcomes, delivery targets, and recovery. A per-task JSON history is an inspectable copy of completed attempts that the shell and exports can read without changing claim state.
The history captures the task as it looked when claimed. It records the attempt state, model messages, the retained report, per-target delivery, tool actions, and the carry-forward note. Records are bounded and redacted, and analytics receives one stable event per attempt. Recording is best effort and does not change whether the scheduled work succeeds.
References: infrastructure/…/run_store.py• L1-39 infrastructure/…/run_store.py• L457-565 infrastructure/…/run_record_store.py• L1-8 infrastructure/…/run_record_store.py• L72-95 infrastructure/…/run_history.py• L174-265 infrastructure/…/__init__.py• L11-48
Scheduler telemetry
Scheduler telemetry gives operators a view of configured work and completed loop reports without reading host files directly. Registry events report a bounded allowlist of task display fields, while run events and loop delivery events report the state of individual attempts.
Telemetry removes credentials from task text and skill inputs, limits event size, and marks task snapshots as incomplete when the task store could not be read in full. Registry events include truncation state so a partial snapshot is visible. Registry and loop-report events can be sent again after a time limit, while stable event identity prevents a resend from creating a second record. Analytics capture failures do not fail the scheduled work or the delivery that already reached the local inbox.
References: infrastructure/…/registry_telemetry.py• L1-10 infrastructure/…/registry_telemetry.py• L79-159 infrastructure/…/loop_report_telemetry.py• L1-8 infrastructure/…/loop_report_telemetry.py• L65-120 infrastructure/…/run_history.py• L241-265
Schedule ownership
The scheduler is a platform service that can run inside the gateway or as a dedicated scheduler process. The interactive shell can host a filtered scheduler for its own prompt loops, while the gateway can host the full task set for long-lived operation. Embedded hosts can stop the scheduler when their work ends, while a dedicated host can remain idle until a task is added.
Task writers do not directly edit live scheduler jobs. They update the shared task store and request a reload. A live host watches both the reload signal and the store file, so a missed best-effort signal still converges on the current task definitions.
The task store uses locked, atomic writes. An unreadable store is preserved instead of being replaced with an empty task list. Legacy task kinds are normalized before strict task validation; retired investigation kinds become disabled manual-loop records with a migration notice, while old work-item reminders gain an absolute run time when the referenced item can be resolved. When the task file is missing but the run database still has history, backlog status reports an incomplete snapshot rather than claiming that the scheduler has no state. Removing a task does not erase its execution history.
The scheduler also provides a small on-demand run port. A host installs the starter for that port, which starts a loop in the background with scheduled-run semantics rather than making it act as the requesting chat turn. Processes without the host integration refuse the request and direct the caller to the supported loop page.
References: infrastructure/…/runner.py• L511-583 infrastructure/…/runner.py• L612-691 infrastructure/…/task_store.py• L71-226 infrastructure/…/task_store.py• L321-394 infrastructure/…/legacy_task_migration.py• L30-102 infrastructure/…/backlog_status.py• L16-53 infrastructure/…/__init__.py• L1-48 infrastructure/…/loop_owner.py• L39-92 infrastructure/…/loops.py• L484-575 infrastructure/…/run_now.py• L1-33
Bootstrap paths
Automated work depends on explicit startup wiring. The process profile loads shared environment and harness setup, then the host installs the runner and delivery seams that connect the scheduler to investigations, headless agents, skills, and providers.
Process bootstrap
The dedicated scheduler process uses the scheduler-worker profile. That profile loads the environment, observability, harness adapters, scheduler runners, and delivery adapters before the blocking scheduler starts. One-shot scheduled commands use a lighter scheduled-command profile.
The gateway uses its normal gateway profile and installs scheduler runners later in GatewayController.start_scheduler. This keeps the gateway's chat startup separate from scheduler hosting while allowing both to share the process capacity gate.
References: bootstrap/process.py• L98-125 bootstrap/process.py• L146-179 surfaces/…/cron.py• L280-298 gateway/…/controller.py• L92-167
Background scheduler service
The background scheduler service keeps scheduled work running when no interactive shell is open. On macOS it uses a per-user LaunchAgent, and on Linux it uses a per-user systemd unit; both start the scheduler command, restart it after exit, and write service output to the scheduler log.
The service records the build that installed its unit. A later health or repair check can restart a stale service, but it defers that restart while a live scheduled execution holds a lease so an active run is not killed during an upgrade. Install and removal report the state known by the operating system, and unsupported platforms require an explicitly managed scheduler process.
References: infrastructure/…/background_service.py• L1-7 infrastructure/…/background_service.py• L86-134 infrastructure/…/background_service.py• L199-280 infrastructure/…/background_service.py• L283-340
Runner registration
The composition root assembles the scheduler runner seams. One seam connects scheduled work to the canonical investigation pipeline, and the agent seam connects headless scheduled work to integration-specific behavior. Hosts can wrap the complete runner bundle with the same capacity gate before installing it.
The runner bundle is an explicit value rather than mutable global state. A host can derive a gated bundle once, so a model-backed scheduled turn consumes one capacity permit without applying the gate again when the bundle is passed between hosts. A scheduler that starts without a required runner fails the affected task clearly instead of silently doing nothing.
The host also installs the on-demand loop starter when that surface is supported. The starter shares the host's background execution and shutdown controls, while the run itself uses the same ownership and delivery rules as an unattended scheduled tick.
References: bootstrap/adapters.py• L96-115 infrastructure/…/agent_runner.py• L1-28 infrastructure/…/runners.py• L27-77 infrastructure/…/investigation_runner.py• L1-36 infrastructure/…/run_now.py• L12-33 tools/…/scheduler_bootstrap.py• L1-36
Scheduled agent routing
Headless scheduled tasks share one agent-runner boundary. The scheduled payload includes a stable source value, and the bootstrap router sends it to the matching manual-loop, uptime-watch, GitHub, PostHog, Sentry, or recurring-skill path. CLI-only source values remain separate from scheduled source values so direct commands do not become indistinguishable from unattended ticks.
Recurring skills use a pinned skill name and revision. The task builder validates the saved definition and resolves approved legacy names before the turn runs. The integration runner fetches integration-owned context when needed and runs one unattended headless turn that returns report text. The runner tells the agent not to send messages or change external systems; the scheduler owns delivery after the turn returns. Scheduled task builders also remove credential fields from agent payloads and attach scheduled trace and credit context to the turn.
When no member turn is active, a private loop runs in its owner's storage scope and credits the loop's creator. A shared loop uses workspace scope. A member-triggered run keeps the active member context instead of replacing it with unattended ownership.
This routing keeps task construction in the scheduler while leaving integration behavior in the integration layer. A new scheduled agent feature must preserve the source-to-runner contract, the input and report contract, and its bootstrap registration.
References: integrations/scheduled_agent_bootstrap.py• L1-37 infrastructure/…/agent_runner.py• L18-28 infrastructure/…/loop_owner.py• L75-92 infrastructure/…/sources.py• L1-23 infrastructure/…/tasks.py• L47-104 infrastructure/…/tasks.py• L231-340 infrastructure/…/loop_prompt.py• L49-87
Change checklist
When these files or sections are changed, remember to consider these:
- When the
IncomingAlertshape, intake limits, or listener trust rule changes, check the HTTP response contract, shell rendering, session history, gateway tenant-token rollout, and any investigation trigger that consumes alert metadata. - When a
TaskKindor scheduled payload source changes, update the message builder and the correct investigation or headless-agent routing seam together. - When source labels change, preserve the distinction between scheduled and CLI-originated payloads so routing and trace filtering remain correct.
- When cron parsing or loop rate limits change, keep five-field and six-field meaning aligned with weekday conversion, missed-fire catch-up, and the CI repair exception.
- When loop templates, prompts, report guides, or skills change, preserve stored-copy fallback, active-catalog validation, installed SKILL.md refresh and size checks, and the rule that unsupported helper scripts or menus fail the tick.
- When loop edits change, preserve group-level atomicity, managed-instruction restrictions, schedule cutover fencing, destination validation, and recalculation of the next run.
- When loop creator or private-loop fields change, keep owner resolution, organization scope, visibility, edit rights, run-now behavior, and personal-account access aligned.
- When schedule definitions are written or removed, preserve reload signaling so both the shell scheduler and a gateway or dedicated scheduler host converge on the same task set.
- When task ownership or schedule identity changes, preserve organization isolation and the rule that a repeated full schedule does not create duplicate work.
- When a work-item reminder contract changes, preserve validation of its durable work-item reference and migration of its absolute run time before strict task validation.
- When scheduler fire-time or claim behavior changes, preserve the exact UTC fire-time key, the two-minute lease and renewal interval, and the recovery path so one tick is not delivered twice or left unfinished.
- When schedule changes are persisted, keep the edit cutoff aligned with pending-tick retirement, live admission, recovery, and explicit fractional run-now keys.
- When claim renewal changes, keep ownership checks aligned with report retention, completion, delivery, service restart deferral, and recovery of expired claims.
- When scheduler concurrency or host mode changes, keep the admission record, worker limit, one-instance rule, backlog snapshot, catch-up behavior, idle behavior, and embedded-host shutdown behavior aligned.
- When background service commands or unit definitions change, keep build detection, install, removal, status reporting, restart deferral, and scheduler log paths consistent on both supported operating systems.
- When runner registration or process profiles change, keep the investigation registration and agent bundle available before scheduled execution, install delivery adapters in every host that can execute scheduled work, and install the on-demand starter only where its host controls are available.
- When a scheduled report or work outcome changes, preserve the retained report, terminal-block pause rule, per-target delivery history, and the narrow scope used by failed-only retries.
- When delivery target resolution changes, keep explicit target precedence, channel de-duplication, target order, email validation, and failed-only retry identity aligned.
- When loop delivery or result fields change, update the local inbox, analytics resend path, run-history lookup, previous-runs context, and shell loop views as one attempt-level contract.
- When run records change, keep SQLite claim state, inspectable per-task history, analytics event bounds, action capture, and carry-forward notes consistent.
- When tool side-effect classification or action summaries change, keep read-only and bookkeeping calls out, retain verified work outcomes, and preserve credential redaction before truncation.
- When scheduler telemetry changes, preserve allowlisting, redaction, size limits, completeness flags, and stable event identity so analytics cannot expose secrets or duplicate attempts.
- When recurring skill inputs, names, revisions, or runner instructions change, keep legacy-name migration, revision resolution, input validation, read-only unattended behavior, and scheduler-owned delivery aligned.
- When legacy task kinds or work-item reminder rows change, keep migration before strict task validation and preserve the disabled-task notice or absolute run time needed by the new schedule path.
- When a task store write path changes, preserve locked atomic writes and quarantine behavior so an unreadable store cannot become an empty live task set.
- When task-store status or backlog inspection changes, keep a missing task store distinct from an empty store and fail closed if run history shows that scheduler state existed.
- When task visibility changes, keep organization-scoped reads and writes aligned with task ownership and schedule identity.
- When task disable or removal behavior changes, keep the live cancellation recheck, queued-tick skipping, and
disabledversusmissing_taskrun reasons aligned.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A remote alert sender omits the listener token | The alert is rejected and does not enter the inbox | Use loopback access or configure the gateway's OPENSRE_GATEWAY_LISTENER_TOKEN; the legacy fleet token remains a rollout fallback. |
| Alert traffic exceeds inbox capacity | The oldest queued alert is dropped | Monitor the dropped value in the 202 response and keep a separate durable trigger when every alert must be investigated. |
| A browser page from another site posts to a loopback listener | The request is rejected even though it targets a loopback address | Keep the origin and host checks enabled, or use an authorized bearer token for remote callers. |
| A scheduled task has an invalid cron expression, date, or time zone | The task is skipped during job registration | Validate the schedule before enabling it and inspect scheduler logs. |
| A prompt loop uses a sub-hour schedule without the CI repair exception | The scheduler widens it to at most one run per hour | Use a slower loop for reports and reserve fast polling for the CI repair path. |
| A work-item reminder has no durable work-item ID or absolute run time | The task cannot become a valid runnable date task | Keep the work-item reference and let migration resolve its absolute run time before validation. |
| Two scheduler hosts admit the same task tick | Only the host that wins the execution claim runs the work and delivery | Keep the shared run database available to every scheduler host. |
| A scheduler process loses its execution lease | The old worker cannot complete the run, and recovery can reclaim it after the lease expires | Keep the shared run database available and let the lease renewer and recovery sweep handle unfinished runs. |
| Claim renewal is not confirmed before report retention or delivery | A stale worker can lose ownership while still holding a report or sending it | Keep fenced ownership checks around retention, completion, and delivery. |
| A schedule changes while an automatic tick is pending | The old tick can run work for a schedule that is no longer current | Persist the edit cutoff, retire pending old ticks, and reject incompatible automatic fire times. |
| A task is disabled or removed while its worker is running | The in-flight tick is skipped before further work or delivery, and queued ticks are marked skipped | Keep task-store cancellation checks and queued-run cleanup enabled. |
| A task build fails before a report is retained | The run is marked failed and no delivery is attempted | Inspect the run stage and scheduler logs; do not treat a missing report as a successful quiet tick. |
| Work succeeds but one delivery target fails | The run records partial delivery and a later retry can target the failed destination | Preserve per-target outcomes and use the failed-only retry scope. |
| Per-target delivery history is missing or unreadable | A failed-only retry refuses to run rather than reposting to every destination | Repair or retain the run database before retrying. |
| Explicit delivery targets and loop channels disagree | The task can send to an unintended destination or retry the wrong target | Keep one fan-out mode per task and preserve explicit-target precedence. |
| An email loop has invalid recipients or no sender account | The loop cannot be created or edited as a valid delivery path | Keep the bounded recipient and smtp: or gmail: account checks. |
| A work outcome is a non-retryable block | The run is recorded as blocked and the schedule is disabled | Mark only known permanent conditions as non-retryable and recreate the task after the condition is fixed. |
| A private loop has no resolvable owner or organization scope | The tick cannot act through the owner's personal connections | Keep member resolution and organization ownership data available before enabling private loops. |
| A scheduler starts without its investigation or agent runner | The affected task fails instead of producing a report | Run the matching process bootstrap before starting the scheduler. |
| A scheduled payload has an unknown or mismatched source value | The task reaches no matching integration path or produces the wrong kind of report | Keep source constants and bootstrap registrations aligned. |
| A recurring skill has an invalid revision, input, helper script, or menu | The scheduled run fails before the unattended turn produces a report | Pin a resolvable skill revision and validate that the recipe is safe for headless scheduling. |
| An installed skill folder is missing, unreadable, empty, or larger than 64 KiB | The scheduled run fails before the unattended turn produces a report | Keep the folder and its SKILL.md available and within the size limit. |
| A persisted recurring skill uses an approved retired name but cannot be updated | The task may run with its old name and later fail skill resolution | Keep the task store writable and review the rename operation warning. |
| An unattended skill tries to send a message or change an external system | The scheduler's delivery boundary is bypassed or the run violates its safety contract | Keep the skill runner read-only and let the scheduler perform all outbound delivery. |
| Run now is requested in a process without an installed loop starter | The request is refused instead of starting a background run | Use the host-integrated Run now surface. |
| A background service is installed but its OS activation fails | The scheduler does not run and the unit is removed rather than reported as active | Check the service state and scheduler log after installation. |
| A stale service is restarted while a live run holds a lease | The active run can be killed during a build upgrade | Defer the restart until no live scheduled claim remains. |
| A delivery provider is not installed or a destination cannot be resolved | The run is marked failed or partially delivered | Install the scheduled-delivery adapter bundle and validate provider destinations when creating the task. |
| A local loop report reaches the inbox but analytics capture fails | The shell still has the report, but dashboards can miss it until a resend pass | Keep recent inbox reports and run the bounded resend path. |
| A task store or run schema cannot be read or migrated | New schedule changes or execution history may be blocked without erasing old data | Preserve unreadable task stores and apply the SQLite migration before scheduling work. |
| A task store is missing while the run database contains history | Status can falsely report an empty scheduler and hide waiting work | Inspect the run history through the backlog status path and treat the snapshot as incomplete. |
| A task is read from the shared store outside its organization scope | One organization can inspect or change another organization's schedule | Apply request-scoped task visibility and keep ownership stamps on persisted tasks. |
| Previous-run text contains an instruction or a file dump | The next loop can follow stale external text or repeat an unhelpful dump | Mark history as data, redact and bound it, and omit file-dump reports. |
Key files
| File | Why to read it |
|---|---|
| infrastructure/alert_intake.py | Defines the shared HTTP alert boundary, per-gateway token trust, browser-loopback protection, and size checks. |
| core/…/inbox.py | Defines the in-process alert queue and its overflow behavior. |
| surfaces/…/controller.py | Shows how the shell starts and stops its alert listener and runtime workers. |
| surfaces/…/workers.py | Shows how queued alerts become shell-visible output without blocking the prompt. |
| surfaces/…/runner.py | Shows how explicit shell investigations become cancellable background tasks and durable results. |
| gateway/…/investigations.py | Defines the authenticated asynchronous investigation API and its polling contract. |
| gateway/…/worker.py | Shows how queued HTTP investigations are claimed, capacity-limited, run, and stored. |
| infrastructure/…/types.py | Defines scheduled tasks, organization ownership, work outcomes, delivery outcomes, and execution records. |
| infrastructure/…/cron_expression.py | Defines accepted cron forms, weekday meaning, and rate limits used by task creation and scheduler registration. |
| infrastructure/…/loop_constants.py | Names shared loop fields, execution modes, report builders, and loop summary states. |
| infrastructure/…/loop_owner.py | Defines member ownership, private-loop scope, and the boundary between member and process-created loops. |
| infrastructure/…/loop_prompt.py | Resolves current template text and validates catalog or installed skills that scheduled agent loops can run. |
| infrastructure/…/report_style.py | Defines the common Markdown report contract and destination-aware length guidance. |
| infrastructure/…/installed_skill.py | Defines how a local SKILL.md folder becomes a refreshed skill recipe for each tick. |
| infrastructure/…/loops.py | Shows how manual loops, channels, ownership, loop status, onboarding starter schedules, and group edits become task definitions. |
| infrastructure/…/loop_edit.py | Defines validated group edits and the limits on changing managed loop instructions. |
| infrastructure/…/runner.py | Shows trigger creation, bounded scheduling, fire-time admission, catch-up, reload, recovery, cancellation, and immediate retry paths. |
| infrastructure/…/run_now.py | Defines the host-installed boundary for starting one loop in the background on demand. |
| infrastructure/…/schedule_change.py | Defines the cutover rules that reject obsolete automatic ticks after a schedule edit. |
| infrastructure/…/schedule_cancel.py | Defines live cancellation checks and the exception for explicit runs on paused tasks. |
| infrastructure/…/claim_lease.py | Defines process-level confirmation and renewal of active execution ownership. |
| infrastructure/…/executor.py | Connects a claimed task to report building, ownership checks, cancellation, fan-out delivery, and run status. |
| infrastructure/…/delivery_plan.py | Resolves ordered, de-duplicated destinations and the scope for failed-only delivery retries. |
| infrastructure/…/outcomes.py | Defines work status and retry or terminal-block evidence independent of delivery. |
| infrastructure/…/legacy_task_migration.py | Normalizes retired task kinds and adds absolute run times to old work-item reminders before validation. |
| infrastructure/…/tasks.py | Maps scheduled work kinds to investigation, headless-agent, skill, work-item, and owner-scope paths. |
| infrastructure/…/sources.py | Defines the source labels that connect scheduled payloads to headless runner paths and keep CLI sources distinct. |
| infrastructure/…/task_store.py | Defines organization-aware schedule identity, durable task updates, de-duplication, reload signaling, cancellation cleanup, and damaged-store protection. |
| infrastructure/…/task_visibility.py | Defines request-scoped visibility for organization-owned task definitions. |
| infrastructure/…/run_store.py | Defines admitted ticks, leased claims, retained reports, backlog inspection, recovery, cancellation cleanup, per-target outcomes, and run history. |
| infrastructure/…/run_record_store.py | Defines the inspectable per-task attempt history used by shell views and previous-run context. |
| infrastructure/…/__init__.py | Exposes the task and run persistence boundary used by scheduler callers. |
| infrastructure/…/previous_runs.py | Builds the bounded, redacted history block passed to a loop's next tick. |
| infrastructure/…/run_activity.py | Tracks side-effect actions and carry-forward notes for one attempt. |
| infrastructure/…/tool_actions.py | Filters successful mutating or external tool calls and records short, redacted action summaries. |
| infrastructure/…/run_history.py | Projects an attempt into durable and analytics-safe run history. |
| infrastructure/…/interactive_shell_delivery.py | Delivers loop reports to the local shell inbox and reports delivery telemetry. |
| infrastructure/…/loop_report_telemetry.py | Resends recent local loop reports with stable event identity when analytics capture may have been dropped. |
| infrastructure/…/registry_telemetry.py | Reports a bounded, redacted, and refreshable view of the saved task registry. |
| infrastructure/…/background_service.py | Describes supported per-user services, build-aware restart behavior, and liveness checks that keep scheduled work running without a shell. |
| infrastructure/…/agent_runner.py | Defines the scheduler-neutral contract for headless agent reports. |
| infrastructure/…/runners.py | Bundles the agent seam with host-session tracing and model-turn capacity behavior. |
| integrations/scheduled_skill_runner.py | Shows how pinned recurring skills validate inputs and return scheduler-owned report text. |
| tools/…/scheduler_bootstrap.py | Connects scheduled investigation work to the canonical investigation capability. |
| bootstrap/adapters.py | Assembles the runner and delivery seams used by each process host. |
| gateway/…/controller.py | Shows gateway ownership of the co-hosted scheduler and its capacity boundary. |