Configuration and security boundaries
OpenSRE uses runtime configuration to select its operating environment, services, and model path. It keeps identity scope and secrets separate from ordinary settings, then adds safety limits around network access, tool use, telemetry, and persistent evidence.
Runtime configuration
Runtime configuration combines process environment values with local environment files and selected non-secret setup defaults. The process environment remains authoritative when a value is already present, so local files and wizard state do not silently replace an explicit deployment choice.
Environment resolution
The shared environment loader accepts normal assignments and shell-style export KEY=value lines. It skips comments and missing files, strips simple surrounding quotes, and preserves existing process values unless a caller explicitly requests replacement (home/…/env_assignment.py• L14-43).
OpenSRE chooses its environment file from an explicit OPENSRE_PROJECT_ENV_PATH, then from the installed application location for a bundled install, or from the project root for a source run. In a bundled install, the wizard can fill unset non-secret provider and model values from its local setup store. An explicit environment path disables that wizard fallback because the path itself is an operator choice (home/…/local_env.py• L14-16, home/…/local_env.py• L34-70, home/…/local_env.py• L78-100).
The bootstrap is process-local and idempotent. The shared skip switch prevents both environment-file loading and wizard-store defaults. A blank explicit provider also stays blank rather than allowing a lower-priority source to supply a different provider (home/…/local_env.py• L94-110, home/…/test_local_env.py• L114-157).
The constants package exposes names from focused leaf modules through a lazy public interface. This keeps configuration names stable for callers without loading every integration module when one setting is used (home/…/exports.py• L1-10, home/…/exports.py• L720-732, home/…/__init__.py• L1-16).
References: home/…/env_assignment.py• L14-43 home/…/local_env.py• L14-16 home/…/local_env.py• L34-70 home/…/local_env.py• L78-110 home/…/exports.py• L1-10 home/…/exports.py• L720-732 home/…/__init__.py• L1-16 home/…/test_local_env.py• L30-170
Observability configuration
Telemetry configuration maps Grafana Cloud settings to OpenTelemetry only when the operator has supplied the required endpoint and credentials. Existing standard OpenTelemetry values win over Grafana defaults, while an explicit Grafana Cloud endpoint requires the related hosted IDs, URLs, write key, and authorization header before the setup is accepted (home/…/grafana_cloud.py• L31-36, home/…/grafana_cloud.py• L122-185).
The same environment-file rules apply to Grafana settings. A skip switch prevents .env loading, and the shared parser gives OpenSRE bootstrap and Grafana setup the same assignment behavior (home/…/grafana_cloud.py• L22-36, home/…/test_config.py• L39-107).
References: home/…/grafana_cloud.py• L7-19 home/…/grafana_cloud.py• L22-36 home/…/grafana_cloud.py• L122-185 home/…/test_config.py• L39-107
Runtime facts
Runtime facts describe the environment that the agent may safely use in its reasoning. They report local capabilities such as available tools, operating system, cloud identity, cluster configuration, and workspace repository identity without invoking shell commands or querying cloud instance metadata (home/…/probes.py• L1-8, home/…/probes.py• L91-199).
Workspace identity prefers an explicit repository value and otherwise reads the checkout remotes. GitHub URLs normalize to owner/repo only for an exact GitHub host, while unknown identity remains empty. This prevents a crafted remote URL from becoming a false repository fact in prompts or reports (home/…/probes.py• L202-297, home/…/test_workspace_identity.py• L20-70, home/…/test_workspace_identity.py• L137-172).
Capability facts make limits visible at boot. Network egress is false unless OPENSRE_ALLOW_NETWORK has an accepted opt-in value, and missing shell or Python tools become warnings rather than hidden assumptions (home/…/probes.py• L299-338, home/…/test_workspace_identity.py• L88-134).
References: home/…/probes.py• L91-199 home/…/probes.py• L202-297 home/…/probes.py• L299-338 home/…/test_workspace_identity.py• L20-70 home/…/test_workspace_identity.py• L88-172
For detailed precedence and identity resolution, see Configuration resolution and identity.
Principal and scope context
A principal is the owner of credentials, integrations, billing, and stored work. An actor is the member or process acting for that principal. Their pair defines the scope used to attribute work and select data, so a shared process does not become the owner of every request.
Scope propagation
The active principal and actor context follows a request through the runtime. When work starts a child process, only the controlled scope identifiers cross the process boundary, and the child accepts them only when they match the organization served by the deployment (home/…/principal.py• L1-8, home/…/principal.py• L16-75, home/…/scope_handoff.py• L1-11, home/…/scope_handoff.py• L25-57).
This diagram shows how request identity becomes an owner-aware execution scope.
flowchart LR
R[Request identity] --> S[Principal and actor scope]
S --> T[Scope-bound turn]
T --> C[Child-process handoff when needed]
T --> D[Matching owner and member data]
References: home/…/principal.py• L1-8 home/…/principal.py• L16-75 home/…/scope_handoff.py• L1-11 home/…/scope_handoff.py• L25-57
Workspace identity boundaries
The deployment identity and the acting member answer different security questions. The deployment identifies the organization that the process serves, while the actor identifies the member who caused the work. Keeping them separate supports tenant isolation and member-level attribution (home/…/tenancy.py• L7-11, home/…/tenancy.py• L13-29, home/…/tenancy.py• L36-52).
Persistent organization data, member session data, and integration credentials use separate logical roots. This prevents a credential or one member's state from becoming ordinary workspace data. See Persistent state and evidence handling for the full state and evidence model.
References: home/…/tenancy.py• L7-11 home/…/tenancy.py• L13-29 home/…/tenancy.py• L36-52 home/…/paths.py• L153-184 home/…/paths.py• L250-260
Secret handling
Secret resolution uses a single order: the process environment first, then an owner-only local credential file. Secret callers can report the source tier without exposing the value, while save and delete operations fail when local persistence did not succeed (home/…/store.py• L1-13, home/…/store.py• L61-80, home/…/store.py• L103-149).
Credential storage
The local credential file is a fallback for environments that do not inject secrets through the process. The OPENSRE_DISABLE_KEYRING switch disables that local persistence path. In that mode environment values remain usable, but file reads are skipped and writes fail instead of claiming that a secret was saved (home/…/store.py• L30-58, home/…/store.py• L70-80, home/…/store.py• L103-126, home/…/test_secret_store.py• L219-238).
Secret writes are durable only after the owner-only local store accepts them. A failed write raises an explicit unavailable error. Delete also raises when the store is locked or unavailable, because logout must not report success while the old credential can still resolve (home/…/store.py• L120-149, home/…/test_secret_store.py• L157-180, home/…/test_secret_store.py• L205-216).
References: home/…/store.py• L1-13 home/…/store.py• L30-58 home/…/store.py• L61-100 home/…/store.py• L103-149 home/…/test_secret_store.py• L69-120 home/…/test_secret_store.py• L136-246
Secret source contracts
The secret tier is part of the operational contract. Environment values override stored copies, a default applies only when no tier has a value, and a stored value can be inspected without allowing the environment to mask it (home/…/store.py• L61-100, home/…/test_secret_store.py• L80-108).
The credential store tolerates a temporary read conflict as a missing secret during startup, but it does not hide a failed write or delete. The result is fail-closed persistence with a usable environment-injection path (home/…/store.py• L70-80, home/…/store.py• L120-149, home/…/test_secret_store.py• L110-145).
References: home/…/store.py• L61-100 home/…/store.py• L120-149 home/…/test_secret_store.py• L80-145 home/…/test_secret_store.py• L249-281
Action safety controls
Authentication identifies who may act, but it does not make every action safe. OpenSRE adds separate controls for approval, model-owned connection data, execution isolation, network access, and resource use.
Approval modes
The REPL autonomy level controls how much user approval is required for agent actions. High is the default and allows normal actions without a prompt, while Med and Low require approval for shell and mutation-capable tools; Off requires approval for every tool. Some risks remain prompt-gated at every level or cannot use a session-wide approval, including generated Python code and generated code that enables network access (home/…/repl_autonomy.py• L14-30, home/…/repl_autonomy.py• L49-93).
The displayed status and the approval rules describe the same boundary. This lets an operator see the current level without treating autonomy as a shell command allowlist or as a replacement for execution isolation.
References: home/…/repl_autonomy.py• L14-30 home/…/repl_autonomy.py• L49-93
Configuration-controlled connections
Connection details belong to trusted configuration rather than model-generated tool input. This keeps credentials, destinations, local transports, and security switches outside the model's control and lets integrations enforce their own approved boundary (home/…/tool_params.py• L1-7, home/…/tool_params.py• L13-85). User-configured MCP servers are an explicit exception because the server owns the argument contract and its credentials; their bridged tools keep their real server arguments instead of treating names such as user or endpoint as connection settings (home/…/mcp.py• L11-16, home/…/tool_params.py• L62-82).
Execution and network limits
Sandboxed code runs with a narrow environment and bounded access. Network egress is blocked by default, and the runtime reports that limit as a capability fact so the agent does not treat missing network access as an unexplained failure (home/…/probes.py• L299-338, home/…/test_workspace_identity.py• L88-134).
The sandbox is defense in depth rather than a complete trust boundary. Outer process isolation remains necessary for untrusted code, while path, process, credential, and time limits reduce the impact of a mistake within the sandbox (home/…/runner.py• L21-40, home/…/runner.py• L102-201, home/…/runner.py• L343-463).
References: home/…/tool_params.py• L1-7 home/…/tool_params.py• L13-85 home/…/mcp.py• L11-16 home/…/probes.py• L299-338 home/…/runner.py• L21-40 home/…/runner.py• L102-201 home/…/runner.py• L343-463
Evidence boundaries
Internal tool results and prompt content can contain secrets or private data. External events and reports therefore use a redacted view instead of raw execution data, and shared limits keep telemetry investigations from becoming an unbounded data path (home/…/secret_redaction.py• L1-36, home/…/telemetry.py• L1-12, home/…/prompt_log.py• L43-81).
Persistent evidence also needs a clear owner and lifecycle. Security and completion records support audit and reporting, but they do not replace the action or make a failed audit write look successful. See Persistent state and evidence handling for how state and evidence remain within their scope (home/…/skill_success.py• L1-26, home/…/security_audit.py• L1-15, home/…/security_audit.py• L60-111).
References: home/…/secret_redaction.py• L1-36 home/…/telemetry.py• L1-12 home/…/prompt_log.py• L43-81 home/…/skill_success.py• L1-26 home/…/security_audit.py• L1-15 home/…/security_audit.py• L60-111
Change checklist
When these files or sections are changed, remember to consider these:
- Keep environment-file parsing, process precedence, bundled-install paths, wizard defaults, and skip-switch behavior as one resolution contract.
- Keep explicit project environment paths from falling through to wizard-store defaults.
- Keep the public constant export map aligned with its leaf modules so lazy imports expose every supported name and no stale name.
- Keep Grafana Cloud validation tied to the effective endpoint and preserve existing OpenTelemetry values when they are already set.
- Keep workspace identity exact-host validation and the empty-identity behavior aligned with prompt and report consumers.
- Keep network capability facts aligned with the sandbox default and its accepted opt-in values.
- Keep principal, actor, deployment organization, child-process handoff, and data-root scope checks aligned.
- Keep environment-first secret lookup separate from local persistence, and do not report a save or logout as successful after a store failure.
- Keep the disabled local-storage switch fail-closed: it must not create a weaker secret tier.
- Keep autonomy labels, approval sets, always-ask tools, external side-effect prompts, and network-argument exclusions aligned.
- Keep model-supplied connection fields excluded from tool inputs, preserve the configured MCP argument exception, and preserve outer isolation around sandboxed code.
- Keep redaction and telemetry bounds applied before data crosses an external evidence boundary.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| An explicit environment path is set but wizard defaults still apply | A local setup choice can override the selected deployment configuration | Treat the explicit path as authoritative and skip wizard defaults (home/…/local_env.py• L57-70) |
| Grafana Cloud is selected with missing hosted credentials | Telemetry setup can fail after selecting a cloud endpoint | Validate all required cloud values when the effective endpoint uses a Grafana host (home/…/grafana_cloud.py• L168-185) |
A crafted remote contains github.com only in its path or another host name | Prompts and reports can claim a false workspace repository | Normalize only exact GitHub hosts (home/…/probes.py• L222-237, home/…/test_workspace_identity.py• L157-172) |
| A child process receives a mismatched organization scope | Work can cross the deployment tenant boundary | Reject scope handoffs that do not match the served organization (home/…/scope_handoff.py• L36-49) |
| Local secret storage is disabled or a credential write fails | A caller can believe a credential is durable when only an environment value exists | Raise an unavailable error and require environment injection or retry (home/…/store.py• L103-126) |
| Logout cannot clear the local credential file | The old credential remains usable after a reported logout | Raise instead of reporting success (home/…/store.py• L133-149) |
| Network capability is assumed from tool presence alone | Sandboxed code can be sent down a path that needs blocked egress | Report network as unavailable unless the explicit opt-in is set (home/…/probes.py• L299-338) |
| Raw prompt or tool data reaches an external sink | Secrets or private content can leak into telemetry or evidence | Apply the shared redaction boundary before serialization (home/…/secret_redaction.py• L12-36) |
| A session approval is applied to generated Python code or its network-enable argument | Untrusted generated code can run or send data without the required prompt | Keep the tool always-ask rule and exclude allow_network from session approval (home/…/repl_autonomy.py• L77-93) |
| Generic connection filtering is applied to a tool bridged from a configured MCP server | A valid server argument can be removed or a server-owned boundary can be misread | Preserve the MCP exception and use the configured server contract (home/…/mcp.py• L11-16, home/…/tool_params.py• L72-82) |
Key files
| File | Why to read it |
|---|---|
| home/…/env_assignment.py | See the shared .env assignment rules |
| home/…/local_env.py | See environment-file selection and bundled-install defaults |
| home/…/grafana_cloud.py | See telemetry endpoint mapping and cloud validation |
| home/…/probes.py | See safe runtime facts, workspace identity, and capability warnings |
| home/…/principal.py | See the principal and actor scope model |
| home/…/scope_handoff.py | See child-process scope validation |
| home/…/store.py | See secret precedence, persistence, and failure reporting |
| home/…/exports.py | See the public lazy map for configuration constants |
| home/…/tool_params.py | See which connection settings remain outside model control |
| home/…/repl_autonomy.py | See approval levels and actions that always require approval |
| home/…/mcp.py | See the configured MCP server boundary and tool naming contract |
| home/…/runner.py | See the execution and resource boundary for sandboxed code |
| home/…/secret_redaction.py | See the boundary for data sent to external sinks |
| docs/configuration-resolution.md | Follow detailed configuration and identity resolution |
| docs/state-and-evidence.md | Follow persistent state and evidence ownership |