You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ca8ea6b
Browse filesBrowse the repository at this point in the historyBrowse files
feat(gateway/sandbox): add global and sandbox runtime settings flow
Closes#405
Refactor the sandbox policy polling channel into an effective settings response with config revision tracking, global policy source metadata, and merged global/sandbox key resolution.
Add gateway-global and sandbox-scoped setting mutations with per-key mutual exclusion, global delete unlock semantics, and global policy override behavior.
Extend the CLI with settings get/set/delete and --global policy flows, then document the new control-plane behavior in architecture and user docs.
Signed-off-by: John Myers <[email protected]>
-**Provider management** (`openshell provider`): Create, update, list, and delete external service credentials.
239
239
-**Inference management** (`openshell cluster inference`): Configure cluster-level inference by specifying a provider and model. The gateway resolves endpoint and credential details from the named provider record.
Copy file name to clipboardExpand all lines: architecture/gateway.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -231,7 +231,7 @@ These RPCs are called by sandbox pods at startup to bootstrap themselves.
231
231
232
232
| RPC | Description |
233
233
|-----|-------------|
234
-
|`GetSandboxPolicy`| Returns the `SandboxPolicy` from a sandbox's spec, looked up by sandbox ID. |
234
+
|`GetSandboxPolicy`| Returns effective sandbox config looked up by sandbox ID: policy payload, policy metadata, and effective settings. Global settings override sandbox-level values per key. |
235
235
|`GetSandboxProviderEnvironment`| Resolves provider credentials into environment variables for a sandbox. Iterates the sandbox's `spec.providers` list, fetches each `Provider`, and collects credential key-value pairs. First provider wins on duplicate keys. Skips credential keys that do not match `^[A-Za-z_][A-Za-z0-9_]*$`. |
Copy file name to clipboardExpand all lines: architecture/sandbox.md
+10-8Lines changed: 10 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -347,11 +347,11 @@ sequenceDiagram
347
347
The `run_policy_poll_loop()` function in `crates/openshell-sandbox/src/lib.rs` implements this loop:
348
348
349
349
1.**Connect once**: Create a `CachedOpenShellClient` that holds a persistent mTLS channel to the gateway. This avoids TLS renegotiation on every poll.
350
-
2.**Fetch initial version**: Call `poll_policy(sandbox_id)` to establish the baseline `current_version`. On failure, log a warning and retry on the next interval.
350
+
2.**Fetch initial config revision**: Call `poll_policy(sandbox_id)` to establish baseline `current_config_revision`. On failure, log a warning and retry on the next interval.
351
351
3.**Poll loop**: Sleep for the configured interval, then call `poll_policy()` again.
352
-
4.**Version comparison**: If `result.version <= current_version`, skip. The version is a monotonically increasing `u32` per sandbox.
353
-
5.**Reload attempt**: Call `opa_engine.reload_from_proto(&result.policy)`. This runs the full `from_proto()` pipeline on the new policy, then atomically swaps the inner engine.
354
-
6.**Status reporting**: On success, report `PolicyStatus::Loaded` to the gateway via `ReportPolicyStatus` RPC. On failure, report `PolicyStatus::Failed` with the error message. Status report failures are logged but do not affect the poll loop.
352
+
4.**Config comparison**: If `result.config_revision == current_config_revision`, skip.
353
+
5.**Reload attempt**: Call `opa_engine.reload_from_proto(policy)` when a policy payload is present. This runs the full `from_proto()` pipeline on the new policy, then atomically swaps the inner engine.
354
+
6.**Status reporting**: On success/failure, report status only for sandbox-scoped policy revisions (`policy_source = SANDBOX`, `version > 0`). Global policy overrides still reload, but they do not write per-sandbox policy status history.
-**`connect(endpoint)`**: Establish an mTLS channel and return a new client.
376
-
-**`poll_policy(sandbox_id)`**: Call `GetSandboxPolicy` RPC and return a `PolicyPollResult` containing the policy, version, and hash.
378
+
-**`poll_policy(sandbox_id)`**: Call `GetSandboxPolicy` RPC and return a `PolicyPollResult` containing policy payload (optional), policy metadata, effective config revision, and policy source.
377
379
-**`report_policy_status(sandbox_id, version, loaded, error_msg)`**: Call `ReportPolicyStatus` RPC with the appropriate `PolicyStatus` enum value (`Loaded` or `Failed`).
378
380
-**`raw_client()`**: Return a clone of the underlying `OpenShellClient<Channel>` for direct RPC calls (used by the log push task).
379
381
380
382
### Server-side policy versioning
381
383
382
-
The gateway assigns a monotonically increasing version number to each policy revision per sandbox. The `GetSandboxPolicyResponse`includes `version` and `policy_hash` fields. The `ReportPolicyStatus` RPC records which version the sandbox successfully loaded (or failed to load), enabling operators to query `GetSandboxPolicyStatus` for the current active version and load history.
384
+
The gateway assigns a monotonically increasing version number to each sandbox policy revision. `GetSandboxPolicyResponse`now also carries effective settings and a `config_revision` fingerprint that changes when effective policy/settings change (including global overrides).
0 commit comments