Introducing a new way to review your PRs.

Read the announcement

tracer-cloud / opensre

The open-source agent for CI/CD reliability.

View on GitHub

25 documents · Updated Nov 23, 2026

docs / service-entrypoints

Service entrypoints and transports

OpenSRE exposes one SRE agent through terminal commands, an interactive shell, an always-on gateway, an ASGI web app, and chat transports. Each entrypoint owns its input and output boundary while shared process boot and turn services keep the core capability consistent across local and hosted use.

Entry point map

The entrypoint map separates local use from long-running service use. The opensre launcher is the composition point for the CLI, shell, and foreground gateway; the gateway daemon supervises the hosted web, prompt, and chat surfaces.

Command-line entrypoint

The opensre command is the main local process entry. A bare terminal invocation can open the interactive shell, a named invocation runs one CLI command, and gateway start selects the hosted gateway path. python main.py reaches the same route, so direct Python use and the installed launcher keep the same behavior.

The CLI also provides a headless ask path for one configured agent request and a cron path for scheduled-work administration. Cron commands can create, inspect, run, retry failed destinations, and review retained execution and delivery results; a dedicated cron start --service invocation can own scheduled work as a long-lived process. Account commands give the local user a clear boundary for sign-in, status, hosted credits, usage, and logout. Provider authentication is a separate auth surface for API-key and subscription sign-in, status, live verification, and logout. It treats these as different provider profiles: API-key flows can validate before saving, while subscription flows authorize an account and limit model choices to models that account can use. onboard guides LLM setup and can configure one integration at a time, including alerting and chat services, while triage offers an opt-in foreground telemetry watch with retained reports. Credential setup can finish with a verified, unverified, deferred, or session-only result, so the user can continue without hiding whether durable setup succeeded. The CLI also exposes local lifecycle, health, version, and sensitive-data guardrail checks, plus integration-specific Sentry and PostHog report commands. The hidden package-smoke command checks that release artifacts still expose essential tools, skills, integration verifiers, guidance, and TLS support. Global output, debug, onboarding, and interactive choices are copied into shared runtime state so commands and the shell use the same invocation settings. A requested session resume takes the shell path even when the normal interactive setting is off.

References: surfaces/entrypoint.py• L1-9 surfaces/entrypoint.py• L20-57 surfaces/…/app.py• L99-163 surfaces/…/app.py• L166-281 surfaces/…/runtime_flags.py• L10-26 surfaces/…/command_specs.py• L29-57 surfaces/…/command_specs.py• L63-71 surfaces/…/command_specs.py• L163-173 surfaces/…/auth.py• L122-231 surfaces/…/subscription_auth.py• L15-44 surfaces/…/auth_profiles.py• L16-109 surfaces/…/auth_service.py• L54-175 surfaces/…/subscription_service.py• L19-90 surfaces/…/package_smoke.py• L86-147 surfaces/…/triage.py• L29-72 surfaces/…/triage.py• L133-150 surfaces/…/flow.py• L265-275 surfaces/…/llm_credential.py• L238-468 surfaces/…/subscription.py• L15-31 surfaces/…/_integration_configurators.py• L57-109 surfaces/…/account.py• L124-182 surfaces/…/account.py• L234-322 surfaces/…/cron.py• L51-419 surfaces/…/cron_results.py• L10-115 surfaces/…/general.py• L21-127 surfaces/…/guardrails.py• L12-75 surfaces/…/posthog_report.py• L25-257 surfaces/…/sentry_digest.py• L25-459 surfaces/…/invocation.py• L7-9 main.py• L1-16

Process boot profiles

Shared process boot gives each host a known starting state before it serves users or runs agent work. A boot profile selects the shared steps for that host, while one ordered sequence keeps environment loading and adapter setup consistent across hosts. Surface-owned hosts use surfaces/…/process_boot.py to supply the capability adapters that the infrastructure boot sequence cannot import directly.

Host profileMain role
CLIPrepares local commands and the interactive shell.
GatewayPrepares the long-running chat, prompt, and web service.
WebPrepares a web-only ASGI process.
Scheduler command or workerPrepares one scheduled operation or a dedicated scheduler process.
EmbeddedLets another Python process use agent sessions with shared adapters.

Boot does not run an agent turn. The selected surface starts the user interaction after boot. Profiles are safe to apply more than once, which lets a hosted web app share a process with the gateway or shell.

References: infrastructure/…/boot.py• L38-59 infrastructure/…/boot.py• L74-167 infrastructure/…/boot.py• L241-281 surfaces/…/process_boot.py• L1-40 gateway/…/webapp.py• L18-31

Gateway process entrypoint

The gateway is the always-on service that connects chat platforms and web callers to OpenSRE. Production starts it through opensre gateway start or opensre gateway start --foreground; the CLI supplies the headless slash-command ports that gateway turns need.

Gateway startup follows one service lifecycle:

  1. Load local environment and gateway credentials.
  2. Apply the gateway boot profile.
  3. Create one shared turn handler.
  4. Start remote prompt intake, the web app, and configured chat transports.
  5. Host the scheduler and knowledge workers when this process owns scheduled work.
  6. Publish component state and mark the process ready.

Workspace knowledge scans run in the gateway after service startup when knowledge is enabled. They keep knowledge from connected integrations current, while an organization gateway can mirror that state to the web app. Credential refresh can wake the scan service when a new integration becomes available. These background tasks do not block gateway readiness.

The same headless slash-command ports let gateway turns handle literal commands such as status or setup requests. Commands that need an interactive wizard return guidance for a suitable web or CLI surface instead of blocking a hosted turn.

The package entry python -m gateway is not a production route. It fails closed because it cannot supply the surface-owned slash ports.

References: surfaces/gateway_entry.py• L1-37 gateway/…/controller.py• L105-157 gateway/…/controller.py• L386-420 gateway/…/controller.py• L422-451 gateway/…/credential_hydration.py• L1-23 gateway/…/credential_hydration.py• L157-169 gateway/…/credential_hydration.py• L215-231 gateway/startup.py• L67-126 gateway/…/job_store.py• L1-10 gateway/__main__.py• L1-21

Gateway process supervision

Background gateway mode is a supervised child process. The CLI chooses the child command, while the gateway process module owns the PID file, log file, start check, stop request, and forced stop after a timeout.

Shutdown shares one bounded time budget across the scheduler, prompt worker, web server, chat workers, and knowledge workers. The gateway records whether each important group stopped before the process ended, so the next start can report a clean stop or an interrupted one. Health also exposes counts of stored sessions, memory notes, and scheduled tasks so an operator can compare service state across restarts.

This boundary keeps process supervision separate from the task scheduler. Foreground mode skips the detached child and keeps the gateway attached to the calling terminal.

References: surfaces/…/gateway_entrypoint.py• L1-14 surfaces/…/gateway_entrypoint.py• L41-51 gateway/…/supervision.py• L1-9 gateway/…/supervision.py• L41-72 gateway/…/shutdown_budget.py• L1-65 gateway/…/shutdown_record.py• L1-84 gateway/…/state_counts.py• L1-36 gateway/…/controller.py• L209-273 surfaces/…/gateway.py• L31-57

Hosted service surfaces

The gateway composes one web surface with a remote prompt API and several optional chat transports. The composer starts and stops them as one service group, but each surface keeps its own protocol, workload, and status.

ASGI web surface

ASGI, or Asynchronous Server Gateway Interface, is the protocol used to host OpenSRE's FastAPI web app. The app provides health and readiness probes, alert intake, and remote prompt submission and polling; it is not a chat channel and does not use a chat reply stream.

The same app can run in a web-only process or inside the gateway and interactive shell. Importing the app applies the web boot profile, so standalone and embedded hosting use the same process setup. A web-only process can serve health and alert routes, but remote prompt intake is available only when the gateway attaches its queue and worker. The server can run in the foreground on the configured PORT or in a background thread with a handle that reports its bound address and stops the server. This keeps standalone hosting and embedded hosting on one lifecycle contract.

Health reports model configuration, environment, persisted-state counts, and the previous gateway shutdown result. Readiness is separate from liveness: the gateway marks itself ready only after its required startup work completes.

References: gateway/…/webapp.py• L1-8 gateway/…/webapp.py• L18-31 gateway/…/webapp.py• L52-59 gateway/…/webapp.py• L62-99 gateway/…/web_server.py• L1-37 infrastructure/asgi_server.py• L1-7 infrastructure/asgi_server.py• L21-59

Remote prompt transport

The remote prompt transport lets an authenticated control plane submit one prompt over HTTP and poll for its result. It is asynchronous by design: the request creates a bounded job, a worker takes jobs in order, the worker runs each job through the shared turn service, and the caller reads a stable state such as queued, running, done, needs_input, or failed.

The queue keeps prompts from the same conversation in order while different conversations can run at the same time. A deployment-backed record store makes accepted jobs and follow-up answers visible to a replacement task. Heartbeats distinguish a live owner from a stopped one; a stale running job settles as interrupted instead of running twice. A request ID makes a retry refer to the existing job rather than create another turn.

The caller supplies optional bounded context and an actor identity. Context reaches the turn as known facts, while a literal slash command remains the caller's command. The worker attaches organization scope, usage attribution, and credit metering to the turn. A turn that needs a user choice or tool approval returns the question instead of waiting on a server terminal; a follow-up answer resumes the same unattended session. Invalid answers leave the question available for a later valid answer, while progress, completed results, and settled errors remain available for a limited retention period.

The route uses the same local-or-bearer-token trust boundary as alert intake. It is separate from chat transport because the caller polls for a result instead of receiving a platform reply.

References: gateway/…/prompt_routes.py• L1-15 gateway/…/prompt_routes.py• L67-175 gateway/…/jobs.py• L135-233 gateway/…/jobs.py• L307-365 gateway/…/job_store.py• L35-61 gateway/…/worker.py• L99-163 gateway/…/worker.py• L200-300 gateway/…/output.py• L16-81 gateway/startup.py• L76-126

Chat transport surface

A chat transport is an inbound adapter that receives a platform message, checks access, maps it to a logical session, and sends the result back through that platform. The adapter calls the shared chat turn service instead of creating a platform-specific agent loop.

The gateway currently recognizes these transport types:

TransportConnection modelUser-facing role
TelegramLong pollingReceives and replies to Telegram messages.
SlackSocket Mode or Events API HTTPReceives and replies to Slack events.
DiscordGateway WebSocketReceives and replies to Discord messages.
BuzzMention pollingReceives and replies to Buzz mentions.

Web and remote prompts are deliberately outside this set. Their HTTP request and polling contracts do not have a platform reply channel. Chat output stays platform-aware at the last boundary: Slack shows progress in the triggering thread's status and posts one final answer. Discord uses reactions and platform-sized messages. Buzz and Telegram use their own reply outputs while sharing the same session, approval, stop, timeout, and credit rules. Status text hides tool arguments from users, and raw failure details stay in server logs while users receive safe error copy.

Slack admission separates direct requests from ambient thread traffic. Addressed messages and direct conversations can start a turn, while untagged replies must belong to an active bot conversation and pass attention and address checks. The dispatcher drops duplicate mention deliveries, acknowledges visible work before waiting on session state, and keeps unresolved workspace or user identity from running a turn. Stop commands and stop actions use the same conversation cancellation path outside the turn lock. Slack thread history and shared files can restore or extend the turn context, while the final status marks the turn as done or failed.

Telegram uses long polling for messages and callback queries. Identity policy controls who may send agent text, and pairing, help, and session rotation stay outside the agent turn. The handler registers cancellation before execution so /stop can prevent a queued turn from starting. It runs the turn away from the polling loop, reports approvals through Telegram controls, and applies scoped usage metering before it calls the shared agent callback.

Buzz uses polled mentions and resolves each event to a principal and conversation session before execution. Its handler protects per-conversation order, runs the turn away from the poll loop, and acknowledges work that finishes in the executor even if the waiting task is cancelled, so completed side effects are not replayed.

Write tools use a transport-neutral approval gate. The gateway turns an approval request into an authorized platform action, waits for Approve or Deny, and closes the wait as denial on expiry or shutdown. Each platform supplies its own button or menu surface while the shared turn path keeps the tool contract the same.

References: gateway/…/names.py• L1-17 gateway/…/startup.py• L1-12 gateway/…/startup.py• L35-40 gateway/startup.py• L1-9 gateway/…/single_message_output.py• L1-14 gateway/…/single_message_output.py• L74-169 gateway/…/inbound_handler.py• L38-236 gateway/…/dispatcher.py• L86-366 gateway/…/turn_output.py• L30-171 gateway/…/dispatcher.py• L89-461 gateway/…/stop_requests.py• L1-107 gateway/…/turn_output.py• L1-9 gateway/…/turn_output.py• L42-230 gateway/…/integration_links.py• L48-109 gateway/…/dedupe.py• L1-45 gateway/…/listener.py• L43-101 gateway/…/worker.py• L73-111 gateway/…/inbound_handler.py• L41-227 gateway/…/background.py• L66-223 gateway/…/inbound_security.py• L46-138 gateway/…/client.py• L20-101 gateway/…/settings.py• L22-31 gateway/…/settings.py• L87-190 gateway/…/approvals.py• L1-13 gateway/…/approvals.py• L48-182 gateway/README.md• L51-86

Interactive shell surface

The interactive shell is the terminal-facing surface for live prompts, slash commands, progress, approvals, and local session control. The process entrypoint gives it the same CLI command group used by one-shot commands, while the shell owns the terminal loop and its shutdown.

An ordinary interactive run passes an account sign-in gate before the shell starts. The shared account state distinguishes active, signed-out, incomplete, invalid, and unavailable sessions, and hosted-credit reads keep an unavailable balance separate from a real zero balance. Startup can check a saved account in the background while the launch screen is shown, then keep the saved login when the service is unavailable instead of treating the user as signed out. It can also check configured integrations in parallel and warm repository scope data; these warm-ups reduce first-turn delay without changing the later boot checks. setup and onboard can guide first-run account, model, subscription, credential, or integration setup. Successful onboarding may open the shell when a usable terminal is present.

When onboarding is enabled, an interactive launch can enter the onboarding skill directly and show its choice menu before the first model turn. The user's selection becomes the first message the agent sees. The same menu can be opened later with /demo, while --skip-onboarding leaves the shell available without the startup menu.

The shell accepts multiline prompts and slash-command completion in a bounded composer. It keeps terminal input separate from turn execution, reserves input for interactive menus, and lets cancellation or approval decisions interrupt the current turn without losing shell control. Hosted account model choices are shown in the prompt status, while provider and model changes validate credentials and refresh the active runtime route. When hosted credits end, the shell presents routes to usage, balance, or another model rather than retrying the blocked turn.

Session resume can start from a command-line session ID or from /resume. With no argument in a TTY, the shell shows a bounded list of recent conversations ordered by activity. Selecting one restores its context under a session execution lock, then returns control to the live shell; Esc leaves the current session unchanged.

The shell can also host the shared alert intake app. This lets local use receive alerts without starting the full gateway, while the gateway can host the same alert route for an always-on deployment.

References: surfaces/entrypoint.py• L20-57 surfaces/…/app.py• L179-205 surfaces/…/main.py• L67-169 surfaces/…/main.py• L248-333 surfaces/…/cli_parity.py• L196-379 surfaces/…/cli_parity.py• L381-555 surfaces/…/switching.py• L102-273 surfaces/…/account_gate.py• L23-55 surfaces/…/account_gate.py• L106-172 surfaces/…/integrations_prefetch.py• L20-45 surfaces/…/repo_scope_prewarm.py• L20-39 surfaces/…/demo_picker.py• L44-95 surfaces/…/sign_in.py• L77-117 surfaces/…/account_session.py• L45-67 surfaces/…/account_session.py• L157-256 surfaces/…/auth_service.py• L54-175 surfaces/…/subscription_service.py• L18-84 surfaces/…/env_sync.py• L126-245 surfaces/…/knowledge_cmds.py• L1-123 surfaces/…/knowledge_text.py• L1-62 surfaces/…/resume_picker.py• L23-41 surfaces/…/resume_picker.py• L147-185 surfaces/…/resume.py• L50-85 surfaces/…/resume.py• L170-220 surfaces/…/state.py• L83-295 surfaces/…/turn_host.py• L310-427 surfaces/…/terminal_ui.py• L64-180 surfaces/…/reply_preview.py• L1-40 surfaces/…/loop.py• L100-196 infrastructure/alert_intake.py• L1-7 infrastructure/alert_intake.py• L118-127

Scheduler host

The scheduler is a background producer of agent work, not a user-facing surface or a chat transport. The gateway may host it after the web and chat surfaces start, or a dedicated scheduler process may own it when deployments need separate scheduling.

Keeping this role separate matters because scheduled work has no live user or reply channel. Model-turn jobs use the same process capacity gate as chat and release one slot when they finish, while deterministic builder work does not consume a model-turn slot. CLI and shell scheduling commands change the task store and signal the owning scheduler to reload. Integration-specific report commands use the same scheduler store while keeping their own task kinds and delivery prerequisites; run-now output separates work status from delivery status so an operator can see whether a report was built, delivered, or only partly delivered.

References: gateway/AGENTS.md• L31-51 gateway/…/controller.py• L159-207 gateway/…/controller.py• L254-297 infrastructure/…/boot.py• L136-160 surfaces/…/process_boot.py• L19-40 surfaces/…/cron.py• L295-419 surfaces/…/cron_results.py• L10-115 surfaces/…/posthog_report.py• L35-257 surfaces/…/sentry_digest.py• L40-459 surfaces/…/scheduling.py• L30-62 gateway/…/test_scheduler_runners.py• L1-133

Capability paths

The entrypoint selects how work enters OpenSRE. The work type then selects the shared chat path, remote prompt path, alert intake path, terminal command path, or headless ask path.

This diagram shows where local and hosted entrypoints join shared services and where their output paths remain separate.

flowchart TD
    A[opensre] --> B{Invocation}
    B -->|bare terminal| C[Interactive shell]
    B -->|CLI command| D[One-shot CLI command]
    B -->|ask| E[Headless ask]
    B -->|gateway start| F[Gateway process]
    F --> G[ASGI web surface]
    F --> H[Remote prompt queue]
    F --> I[Chat transport registry]
    I --> J[Telegram]
    I --> K[Slack]
    I --> L[Discord]
    I --> M[Buzz]
    J --> N[Shared chat turn service]
    K --> N
    L --> N
    M --> N
    H --> N
    G --> O[Health, readiness, alert intake, prompt polling]
    C --> P[Interactive shell turn path]
    D --> Q[CLI capability path]
    E --> R[Headless ask turn path]

Chat turn path

A chat message enters through a platform adapter and leaves through that platform's output channel. The shared turn service supplies common session, capacity, policy, approval, and cancellation behavior, while the adapter keeps control of platform rules and reply formatting.

The gateway reuses one agent for a logical chat session and binds the current transport output for each turn. Each dispatcher first checks identity and conversation admission, then resolves scoped session state before it calls the shared callback. Output is finalized through the active platform boundary, so a later turn cannot overwrite an answer already delivered. Slack, Discord, Telegram, and Buzz add their own status, reaction, approval, and message rules only at this last boundary. This keeps conversation state across messages without coupling the agent to a platform. See the Gateway runtime for request handling and turn lifecycle details.

Slack adds platform-specific continuity around this shared path. An accepted message resolves to the user's scoped session, restores thread history when needed, and adds shared files as bounded turn context. The turn then uses the common usage, credit, cancellation, timeout, and terminal-outcome rules before Slack delivers the final thread reply. A stop command or stop action cancels the active turn without waiting for the conversation lock. The final reply can include a link to the web app when the user must configure an integration. This keeps Slack behavior aligned with the other chat transports while preserving its thread contract.

References: gateway/…/chat_agent_build.py• L1-32 gateway/…/controller.py• L132-144 gateway/…/single_message_output.py• L74-169 gateway/…/inbound_handler.py• L71-228 gateway/…/dispatcher.py• L86-366 gateway/…/turn_output.py• L30-171 gateway/…/approvals.py• L156-182 gateway/…/test_session_agents.py• L104-209 gateway/…/dispatcher.py• L119-461 gateway/…/stop_requests.py• L28-51 gateway/…/turn_output.py• L42-230 gateway/…/integration_links.py• L48-109 gateway/…/inbound_handler.py• L62-227 gateway/…/test_turn_output.py• L272-332 gateway/AGENTS.md• L114-124 gateway/AGENTS.md• L157-174 gateway/README.md• L84-87

Remote prompt path

An HTTP caller submits a prompt and receives a prompt ID rather than waiting for the agent turn. The gateway worker takes that job, runs it with the shared turn service, and stores either the answer, a user question, progress, or a stable failure code for polling.

This path is useful for a control plane that needs OpenSRE work without a live chat connection. It uses the process turn gate and credit boundary, but it does not expose chat output or wait for terminal input. A caller can answer a deferred question through a follow-up job, including a tool approval, without starting a new unrelated session. The queue retains enough parent and answer state to rebuild the exchange when a resumed session has no stored transcript, and durable records let a replacement gateway continue the same exchange.

References: gateway/…/prompt_routes.py• L31-73 gateway/…/prompt_routes.py• L92-125 gateway/…/jobs.py• L405-521 gateway/…/jobs.py• L678-742 gateway/…/worker.py• L200-300 gateway/…/worker.py• L357-413 gateway/…/job_store.py• L64-169

Alert intake path

An external system sends a JSON alert to POST /alerts. The shared intake checks the caller boundary, limits and validates the request, and places the alert in the host process's inbox for later handling.

The gateway and interactive shell can both mount this path because it depends on the alert domain and inbox rather than on either surface. A configured bearer token permits non-loopback callers; without one, only loopback callers are accepted.

References: infrastructure/alert_intake.py• L1-7 infrastructure/alert_intake.py• L47-66 infrastructure/alert_intake.py• L69-115 gateway/…/webapp.py• L52-59

Headless ask path

The opensre ask command runs one configured agent request without opening the interactive shell. It is designed for scripts and local automation, so it returns a stable outcome through plain text or JSON and uses process exit codes for success, needed input, approval denial, cancellation, and error.

The path can attach bounded UTF-8 text as explicitly untrusted context. A request can persist a session for a later --resume, or use --ephemeral when no session state is needed. A pending choice becomes structured output so a caller can answer it in a later process rather than waiting on a terminal prompt. Persisted sessions use an execution lease, so overlapping runs cannot resume the same conversation at the same time.

References: surfaces/…/ask.py• L24-29 surfaces/…/ask.py• L54-89 surfaces/…/ask.py• L96-193 surfaces/…/file_input.py• L12-15 surfaces/…/file_input.py• L71-129 surfaces/…/service.py• L50-123 surfaces/…/service.py• L286-391 surfaces/…/service.py• L475-608 surfaces/…/session.py• L26-67 surfaces/…/session.py• L97-140

Terminal capability path

The CLI exposes one-shot commands for automation and administration. This includes direct agent requests through ask, account and hosted-credit management, provider authentication, onboarding and integration setup, telemetry triage, scheduled-work operations through cron, integration-specific Sentry and PostHog reports, local health and lifecycle checks, sensitive-data guardrail checks, and knowledge inspection and scan operations through knowledge. The interactive shell exposes the same command vocabulary inside a persistent terminal session, then adds prompt-driven conversation and local control around it.

The shell delegates commands that need the full CLI contract to the CLI boundary while retaining terminal-specific presentation and cancellation around agent turns. Interactive commands that need a real terminal, such as setup or provider authorization, run on the local CLI surface; hosted chat receives guidance instead of trying to open a browser or wizard. Both paths use shared agent and process services, but they own different output contracts. Read User surfaces for command behavior, shell interaction, and user-facing choices.

References: surfaces/entrypoint.py• L1-9 surfaces/…/command_specs.py• L31-173 surfaces/…/auth.py• L122-272 surfaces/…/triage.py• L29-150 surfaces/…/cron.py• L51-419 surfaces/…/general.py• L21-127 surfaces/…/guardrails.py• L12-75 surfaces/…/posthog_report.py• L25-257 surfaces/…/sentry_digest.py• L25-459 surfaces/…/flow.py• L265-514 surfaces/…/cli_parity.py• L381-555 surfaces/…/cli_parity.py• L562-761 surfaces/…/turn_host.py• L429-532 surfaces/…/action_rendering.py• L323-435

Change checklist

When these files or sections are changed, remember to consider these:

  • When changing CLI routing, preserve the separate paths for a bare terminal, a one-shot command, a headless ask, and a foreground gateway.
  • When changing root CLI flags, keep Click values, shared runtime flags, shell startup behavior, onboarding behavior, and command output aligned.
  • When adding or renaming a CLI command, update the lazy command index, the shell parity commands, and any hosted guidance for commands that need a real terminal.
  • When changing provider authentication, keep API-key and subscription profiles, status and verification metadata, account-scoped model selection, provider env sync, and logout behavior aligned.
  • When changing onboarding, keep provider choice, model choice, live validation, durable or session-only credential outcome, integration selection, persistence recovery, and the optional shell handoff aligned.
  • When changing the sign-in gate, keep saved-login validation, unavailable-service handling, login subprocess handoff, and the decision to enter the shell aligned.
  • When changing integration setup, keep the picker taxonomy, configurator, validator, and health result exposed through the same wizard flow.
  • When changing the package-smoke command, keep the frozen artifact checks aligned with baked discovery data, required tools, skills, verifiers, guidance, and CA support.
  • When changing chat output, keep placeholder release, continuation delivery, status redaction, platform limits, streaming fallback, final feedback, and safe error copy aligned.
  • When changing Discord output, keep content splitting, continuation messages, final feedback components, status previews, and the 2,000-character platform boundary aligned.
  • When changing interactive shell startup, preserve the account gate, prefetch waits, repository warm-up, TTY behavior, initial-input replay, direct onboarding menu, session resume, and clean session teardown.
  • When changing shell turns, keep input reading separate from queued turn execution and retain cancellation, approval, credit recovery, and confirmation state transitions.
  • When changing shell prompt presentation, keep completion, exclusive-stdin, multiline input, inline-menu cleanup, reply preview, terminal redraw, and streaming behavior aligned.
  • When changing model switching, keep account-managed model locks, provider credential checks, custom endpoint requirements, model validation, env sync, and runtime cache reset aligned.
  • When changing account state, keep browser login, local account metadata, saved-login availability, hosted-model validation, credit reads, shell gating, and JSON output aligned.
  • When changing account, onboarding, authentication, triage, or knowledge commands, update the CLI command index and the shell's parity commands together.
  • When changing process boot, keep environment loading and adapter setup aligned for CLI, gateway, web, scheduler, and embedded hosts. Keep surfaces/…/process_boot.py and the gateway-side registrar set equivalent.
  • When changing scheduled CLI commands, keep task kind, integration prerequisites, cron validation, delivery adapters, run-now output, and retained work-versus-delivery results aligned.
  • When changing scheduler ownership, ensure exactly one process owns scheduled delivery for a deployment and that CLI or shell writes trigger a reload.
  • When changing gateway credential hydration, keep bootstrap identity, tenant store source precedence, explicit store path, HTTPS API use, and refresh status aligned.
  • When changing gateway child startup, update Python module, installed launcher, and frozen-binary paths together.
  • When changing the gateway composition boundary, keep headless slash ports available and keep bare python -m gateway fail-closed.
  • When changing prompt intake, keep route authentication, request limits, idempotency, queue capacity, conversation ordering, durable records, heartbeats, recovery, approval follow-ups, progress, result retention, worker shutdown, and prompt state names aligned.
  • When adding a chat transport, update its registry, inbound contract, status, and stop behavior so one failed channel does not hide the state of others.
  • When changing Buzz dispatch, keep principal resolution, per-conversation ordering, executor completion acknowledgement, cancellation, timeout, metering, and output delivery aligned.
  • When changing Slack stop handling, keep slash-command, native session-stop, and message-shortcut payloads mapped to the same conversation key and cancellation registry.
  • When changing Slack final delivery, keep successful-post checks aligned with any downstream delivery credit or skill-value recording.
  • When changing Slack integration links, keep the integration catalog ids, web app origin, configured-service filter, button actions, and final reply blocks aligned.
  • When changing Slack Socket Mode, keep envelope acknowledgement, event claims, claim release on queue failure, bounded retention, and listener-thread interactive actions aligned.
  • When changing Slack admission or dispatch, keep mention de-duplication, thread attention, principal scope, session seeding, stop handling, approvals, metering, and terminal outcome updates aligned.
  • When changing Discord dispatch, keep admission, scoped session resolution, thread attention, attachment context, reactions, cancellation, metering, and terminal outcomes aligned.
  • When changing Telegram inbound security or settings, keep environment and integration credential precedence, pairing, connected private-chat authorization, allowed users, session rotation, and callback authorization aligned.
  • When changing the Telegram poll loop, keep detached turn dispatch, /stop registration, approval delivery, token-safe errors, active-turn cleanup, and shutdown drain aligned.
  • When changing Telegram inbound dispatch, keep per-chat ordering, cancellation before execution, scoped metering, timeout handling, and executor isolation aligned.
  • When changing the ASGI server contract, preserve standalone web hosting and embedded gateway or shell hosting, and keep prompt intake gateway-only.
  • When changing alert intake, review both gateway mounting and shell-only hosting, plus the local-or-token trust boundary.
  • When changing scheduler runner gating, keep one capacity permit per model turn and do not charge deterministic builder work as a model turn.
  • When changing shutdown, pass one bounded budget through all service groups and keep the persisted shutdown result meaningful for the next health report.

Important failure modes

TriggerConsequenceGuard
python -m gateway is used as the production launcherChat starts without the surface-owned slash portsUse opensre gateway start or opensre gateway start --foreground.
A bare opensre runs without a usable TTYNo prompt can accept inputThe CLI prints the landing page or returns without opening the shell.
An interactive shell starts without an active accountThe shell does not openThe sign-in gate offers login or exit and directs non-interactive callers to account setup.
The account service cannot be reached during the sign-in checkA valid saved login may be treated as neither active nor rejectedKeep the saved login and retry the launch instead of prompting for a new login.
Gateway startup lacks the slash-port factoryThe gateway cannot provide its headless command pathThe composition root injects headless ports and the gateway fails closed without them.
Gateway credential hydration is partly configuredThe process may serve the wrong tenant or no tenantRequire the organization and bootstrap secret, then fail closed on incomplete or unsafe configuration.
A configured integration secret has no explicit store pathStartup and turn scopes may resolve different credential filesRequire one explicit integrations store path.
The prompt worker is not attachedPrompt HTTP requests return prompt_intake_unavailableRun prompt intake inside the gateway composition; web-only mode does not claim this capability.
The prompt queue is fullA new prompt is rejected instead of being silently droppedThe route returns too_many_prompts and the caller can retry later.
A prompt cannot be written to the deployment storeThe caller cannot rely on another task recovering the accepted workReturn prompt_store_unavailable and do not acknowledge the prompt.
A prompt turn needs user inputThe worker cannot wait for a terminal answerThe job settles as needs_input with a caller-facing question.
A follow-up answer does not match the pending choiceThe original prompt could be lost or resumed with invalid stateReopen the parent job and keep the pending question until a valid answer arrives.
A gateway task stops while a prompt is runningA replacement must not replay an unknown or live turnHeartbeats mark live ownership; stale work settles as interrupted, and a waiting question can accept a new answer.
Prompt context or actor data exceeds its contractThe prompt is rejected before queue insertionThe route validates prompt size, context shape, context value size, and actor length.
A chat transport has missing credentialsThat channel is unavailableThe registry records not configured and starts the remaining channels.
A transport fails during startup or readinessThat channel is unavailable while other channels may serve usersThe registry records failed and continues the startup pass.
A continuation tries to edit a released chat messageA later turn could overwrite an answer the user already readRelease the message id at final delivery and let the transport create a fresh continuation message.
A Discord answer exceeds the platform limitThe answer cannot be delivered as one messageSplit the answer into bounded chunks and attach feedback to the final chunk.
Slack redelivers an event or sends it to two listener threadsOne user message could start two turnsA listener acknowledges first, then claims the event ID in a bounded store before queueing work.
Slack cannot queue work after claiming an eventA later retry could be dropped even though no turn ranRelease the provisional claim when queue submission fails.
A Slack Socket Mode burst exceeds the hard dedupe capAn old event may be forgotten and a retry may run againKeep the store bounded, warn on hard-cap eviction, and rely on the retry window for normal bursts.
Slack final message delivery failsThe user may see no final answer, the loading status is cleared, and delivery-dependent skill insight is not creditedSlackTurnOutput records the delivery failure and downstream recording runs only after a successful post.
A Slack final answer exceeds the markdown block limitThe rich answer block is omittedSend the bounded text fallback and keep any required integration action links.
A Slack turn stops, times out, or fails after its working state is postedThe thread can show stale work or no visible resultUse one terminal outcome arbiter to finalize the reply and mark the message failed or done.
Slack receives a stop shortcut or native stop event with incomplete idsThe active turn cannot be found safelyParse only complete team, user, channel, and message or thread identifiers.
Slack needs an integration link but no web app origin is configuredThe answer has no Configure buttonReturn the normal answer without a link and configure the web app origin for guided setup.
A Telegram bot token is missing or invalidThe Telegram channel cannot start or send repliesLoad env and integration settings through the validated gateway settings and fail the channel closed.
A Telegram message comes from an unauthorized user or chatThe message does not run an agent turnApply the identity policy, pairing rules, allowed users, and connected private-chat check before dispatch.
A Telegram API error includes the bot tokenCredentials could leak through logs or caller-visible error textRedact the token before logging or returning the transport error.
A Telegram approval is pending during shutdownA turn can wait past the stop budget for a callback that cannot arriveClose the approval broker as denial, then drain or cancel active turns.
A Slack team or user cannot resolve to a storage principalThe message does not run and cannot read or bill another principal's sessionThe dispatcher fails closed before admission and turn execution.
Slack receives an untagged reply outside the bot's active thread attention or address rulesHuman conversation traffic is ignored instead of starting an agent turnRequire an addressed message or a passing thread admission decision.
The web app cannot bind its portHealth, alert, and prompt HTTP access are unavailable while chat may continueGateway startup records the web failure separately from chat status.
An organization-bound gateway has no usable analytics destinationRemote usage events are dropped and startup reports analytics failureConfigure the delivery secret and URL, or explicitly opt out of telemetry.
A non-loopback caller posts alerts or prompts without the configured tokenThe request is rejectedWeb intake requires a valid bearer token for non-loopback callers.
An alert or prompt body is malformed or exceeds the request limitThe request is not queuedRequest-size middleware and payload validation reject it before domain insertion.
An API-key credential fails validationThe provider is not selected with an unverified keyauth login validates before saving unless the caller explicitly disables validation.
A subscription login is attempted without browser access or a usable callbackThe provider is not activatedShow a token-free authorization URL and keep model selection limited to the account's available models.
A subscription user selects a model outside the account's returned model listThe local provider route could point at a model the account cannot useValidate explicit and interactive model choices against the account-scoped list before saving the selection.
Provider auth metadata is staleThe shell may show a provider as configured while its next request failsExpose stale status and direct the user to auth verify.
A credential save fails during onboardingSetup may claim success while the runtime cannot reload the credentialOffer retry, repick, cancel, or a clearly labeled session-only path; never report an unsaved value as durable.
A provider endpoint remains after a failed validationRetry may probe the same wrong endpoint without asking againClear endpoint settings before retry or provider repick for endpoint-based providers.
A signed-in OpenSRE account tries to switch local providersThe shell could write settings that the hosted account does not useKeep account-managed model routing locked until the user signs out.
A custom provider switch has no base URL or modelThe next LLM load cannot build a valid routeReject the switch and direct the user to configure the endpoint, model, or onboarding flow.
An integration wizard check failsInvalid service settings may be saved as if healthyRun the service validator and present its health result before treating setup as complete.
The package-smoke command cannot find baked discovery data or required capabilitiesA frozen release may pass startup but fail on its first actionFail the artifact smoke check with the missing capability list.
A shell startup prefetch failsFirst-turn startup may be slower, but the shell must still startTreat prefetch as an optimization and let normal boot perform the authoritative read.
A shell turn is cancelled while a blocking worker remains activeThe prompt can close while session state is still in useMark the worker detached, delay session teardown, and keep the turn slot owned until cleanup.
A shell confirmation opens while typeahead remains in the composerHidden input may submit after the confirmation closesMove the runtime to the confirmation phase and clear the prompt buffer before waiting.
Two processes resume the same ask sessionThe second process cannot safely continue the conversationSession execution locking rejects the overlapping invocation.
A headless ask turn needs user inputNo terminal prompt can answer itThe command returns structured questions and a resumable session ID.
The startup demo cannot queue its entry menuThe shell must not start an unexpected model turnClear the partial skill state and continue without silently submitting a prompt.
A scheduled task has an invalid cron or timezone valueThe task can be stored but never run at the intended timeValidate the expression and timezone before creating the task.
cron run retries a partially delivered task without --failed-onlyDestinations that already received the report receive it againWarn about the duplicate and provide the failed-destination retry path.
Scheduler storage cannot provide readable backlog or target historyAn operator may mistake unknown state for an empty or safe backlogReport status as unknown and refuse a failed-only retry when its scope cannot be proven.
A Sentry or PostHog scheduled command lacks its integration or delivery providerThe task cannot build or deliver its reportCheck integration and provider prerequisites before storing or running the task.
The gateway receives a stop signal after its budget is spentSome workers or scheduled jobs may remain activeOne shutdown budget is shared across components and the next start records incomplete cleanup.

Key files

FileWhy to read it
main.pyDirect Python entry that reaches the common CLI.
surfaces/entrypoint.pyComposition point for the CLI, interactive shell, and foreground gateway.
surfaces/…/app.pyRoot CLI routing, shell selection, resume selection, and global invocation flags.
surfaces/…/startup.pyCLI process preparation, error reporting, terminal adapters, and signal setup before Click runs.
surfaces/…/runtime_flags.pyShared runtime flag contract used after Click parses the root options.
surfaces/…/command_specs.pyLazy top-level CLI command index and root help contract.
surfaces/…/cron.pyScheduled task administration, scheduler status, run-now retry choices, retained logs, and dedicated scheduler start.
surfaces/…/cron_results.pyWork and delivery result presentation for scheduled runs.
surfaces/…/general.pyLocal update, uninstall, version, and health entrypoints.
surfaces/…/guardrails.pySensitive-information guardrail setup, testing, audit, and rule inspection.
surfaces/…/posthog_report.pyPostHog report execution and schedule lifecycle.
surfaces/…/sentry_digest.pySentry digest and uptime-watch execution and schedule lifecycle.
surfaces/…/auth.pyProvider authentication entrypoint for API-key and subscription flows.
surfaces/…/subscription_auth.pyBrowser authorization presentation and account-scoped model choice for subscription login.
surfaces/…/package_smoke.pyRelease-artifact capability check for frozen builds.
surfaces/…/triage.pyOpt-in telemetry watch and retained incident report entrypoint.
surfaces/…/flow.pyLLM onboarding flow, persistence summary, and shell handoff.
surfaces/…/llm_credential.pyCredential validation, durable-save recovery, deferred setup, and session-only fallback during onboarding.
surfaces/…/subscription.pySubscription authorization handoff from onboarding.
surfaces/…/_integration_configurators.pyIntegration picker and configurator boundary.
surfaces/…/catalog.pyShared provider, model, credential, and endpoint catalog.
surfaces/…/auth_profiles.pyUser-facing split between API-key and subscription authentication paths.
surfaces/…/auth_service.pyProvider auth status, validation, persistence, verification, and logout.
surfaces/…/subscription_service.pyBrowser subscription authorization and account model access.
surfaces/…/env_sync.pyProvider selection and model configuration sync boundary.
surfaces/…/account_session.pyAccount validation used by CLI and shell.
surfaces/…/process_boot.pySurface-owned capability registration passed to the common process boot sequence.
surfaces/embedded.pyEmbedded Python session entrypoint and embedded process boot profile.
infrastructure/…/boot.pyShared ordered boot profiles for CLI, gateway, web, scheduler, and embedded hosts.
surfaces/gateway_entry.pyProduction gateway composition root and headless port injection.
gateway/…/controller.pyGateway lifecycle, readiness, scheduler ownership, knowledge workers, and shutdown boundary.
gateway/…/credential_hydration.pyTenant credential loading and refresh boundary before gateway service.
gateway/startup.pyComposition of prompt intake, web app, chat transport group, analytics status, and shutdown.
gateway/…/jobs.pyPrompt states, conversation ordering, follow-up answers, cancellation, progress, and retention.
gateway/…/job_store.pyDurable prompt records and recovery boundary across gateway task replacement.
gateway/…/worker.pyQueued remote prompt execution, approval follow-up, session resume, and caller-facing outcomes.
gateway/…/single_message_output.pyShared chat placeholder, status, continuation, and final delivery contract.
gateway/…/turn_output.pyDiscord message splitting, final feedback, and continuation delivery boundary.
gateway/…/dispatcher.pySlack admission, scoped session dispatch, thread continuity, cancellation, approvals, metering, and terminal outcomes.
gateway/…/turn_output.pySlack loading status, final reply, rich blocks, safe errors, and output limits.
gateway/…/inbound_handler.pyBuzz mention dispatch, scoped sessions, per-conversation ordering, cancellation, and executor completion.
gateway/…/background.pyTelegram polling, detached turn dispatch, stop handling, approval delivery, and shutdown drain.
gateway/…/inbound_handler.pyTelegram message dispatch, scoped sessions, cancellation, metering, and turn outcomes.
gateway/…/startup.pyChat transport registry and partial-start behavior.
gateway/…/webapp.pyFastAPI health, readiness, alert, and prompt route host.
gateway/…/prompt_routes.pyHTTP submission, polling, answer, cancel, and validation contract for remote prompts.
gateway/…/web_server.pyForeground and embedded ASGI server entrypoints.
surfaces/…/main.pyInteractive shell lifecycle, account gate, startup work, resume, and terminal-facing start path.
surfaces/…/account_gate.pyAccount check and sign-in gate before the shell starts.
surfaces/…/integrations_prefetch.pyBounded startup read of configured integrations.
surfaces/…/repo_scope_prewarm.pyBackground repository-scope warm-up for the first turn.
surfaces/…/cli_parity.pyShell-to-CLI delegation, hosted guidance, and command parity.
infrastructure/asgi_server.pyStandalone and embedded ASGI server contract.
infrastructure/alert_intake.pyShared alert HTTP contract used by gateway and shell hosts.