Skip to content

Commit 76e7954

Browse files
committed
chore: merge main into HTTP response middleware
Signed-off-by: Piotr Mlocek <pmlocek@nvidia.com>
2 parents 0b089c4 + 8751e35 commit 76e7954

94 files changed

Lines changed: 3836 additions & 434 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.agents/skills/helm-dev-environment/SKILL.md‎

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,15 +256,19 @@ Key Helm values:
256256

257257
### Keycloak OIDC
258258

259-
One-time setup — only needed once per cluster lifetime:
259+
Initial setup — rerun it whenever you want to rotate the development CA:
260260

261261
```bash
262262
mise run keycloak:k8s:setup
263263
```
264264

265265
This deploys Keycloak (`quay.io/keycloak/keycloak:24.0`) into the `keycloak` namespace,
266-
imports the openshell realm from `scripts/keycloak-realm.json`, and prints a port-forward
267-
command for acquiring tokens from the CLI.
266+
imports the openshell realm from `scripts/keycloak-realm.json`, generates a short-lived
267+
development TLS certificate, and publishes its trust anchor as the
268+
`openshell-keycloak-ca` ConfigMap in the OpenShell namespace. The command prints a
269+
port-forward command for acquiring tokens from the CLI. Rerunning setup rotates the
270+
development certificate and trust anchor; redeploy the gateway afterward so it reloads
271+
the mounted CA bundle.
268272

269273
Then activate OIDC in the OpenShell Helm chart:
270274
1. Uncomment `#- ci/values-keycloak.yaml` in `skaffold.yaml`
@@ -294,6 +298,25 @@ ServiceAccount bootstrap and gateway-minted sandbox JWT path; the selected
294298
Kubernetes compute driver validates the projected token before the gateway
295299
mints its JWT.
296300

301+
### Vault Credential Driver
302+
303+
The `credential-driver-vault` Skaffold profile applies
304+
`ci/values-credential-driver-vault.yaml`. Its external OpenBao/Vault backend
305+
must expose HTTPS at the configured service DNS name and publish the issuing CA
306+
certificate as the `ca.crt` key in the `openbao-ca` ConfigMap. Local e2e uses
307+
OpenBao dev TLS and an `openbao-0` DNS alias matching its generated certificate.
308+
The Helm value
309+
`server.credentialDrivers.vault.caConfigMapName` mounts that key into the
310+
gateway and renders the driver's `ca_bundle` setting. Non-loopback HTTP
311+
addresses fail gateway startup, and hostname verification requires the service
312+
DNS name in the server certificate SANs.
313+
314+
```bash
315+
cd deploy/helm/openshell
316+
skaffold run -p credential-driver-vault
317+
kubectl -n openshell logs statefulset/openshell -c openshell-gateway --tail=200
318+
```
319+
297320
---
298321

299322
## Cluster Lifecycle (stop/start)
@@ -353,6 +376,7 @@ for dependencies still declared in `Chart.yaml`.
353376
| `deploy/helm/openshell/ci/values-spire.yaml` | SPIFFE/SPIRE provider token grant overlay |
354377
| `deploy/helm/openshell/ci/values-spire-stack.yaml` | SPIRE hardened chart values for local dev |
355378
| `deploy/helm/openshell/ci/values-tls-disabled.yaml` | Lint-only: TLS + auth disabled (reverse-proxy edge termination) |
379+
| `deploy/helm/openshell/ci/values-credential-driver-vault.yaml` | Vault credential-driver validation overlay with HTTPS and private-CA trust |
356380
| `deploy/kube/manifests/envoy-gateway-openshell.yaml` | GatewayClass for Envoy Gateway (`mise run helm:gateway:apply`) |
357381
| `tasks/scripts/helm-k3s-local.sh` | k3d cluster create/delete/start/stop/status |
358-
| `tasks/scripts/keycloak-k8s-setup.sh` | Keycloak deploy + realm import |
382+
| `tasks/scripts/keycloak-k8s-setup.sh` | Keycloak deploy, realm import, and development TLS trust anchor |

‎.agents/skills/launch-openshell-gator/SKILL.md‎

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ For gator's PR/issue validation policy, load `gator-gate` inside the launched sa
1313

1414
## Non-Negotiable Rules
1515

16-
- Keep normal gator launches supervised: use `--watch --background` and let the in-sandbox supervisor own sleeping and relaunching bounded cycles.
16+
- Keep normal gator launches supervised: use `--watch` and let the in-sandbox supervisor own sleeping and relaunching bounded cycles.
1717
- Do not add passive `sleep` loops in the operator session to watch gator. Check logs or status once, then report the current state or launch a proper watcher outside the model session only when explicitly asked.
1818
- Do not change the default gator model in `scripts/agents/gator/agent.yaml` for experiments. Use `CODEX_MODEL=...` and, if needed, a temporary `--from` Docker context or `--codex-bin` override.
1919
- Do not push to contributor branches, approve, merge, post `/ok to test`, or broaden gator scope unless the operator explicitly authorized that action.
@@ -34,7 +34,6 @@ For gator's PR/issue validation policy, load `gator-gate` inside the launched sa
3434
| `scripts/agents/gator/bin/validate-review-findings` | Enforces the blocker evidence schema and downgrades unsupported hypotheses. |
3535
| `scripts/agents/gator/prompts/gator.md` | Rendered top-level prompt template baked into the payload. |
3636
| `scripts/agents/gator/skills/gator-gate/SKILL.md` | In-sandbox gator state-machine skill. |
37-
| `scripts/agents/gator/logs/` | Background launch and supervisor logs. |
3837

3938
## Preflight
4039

@@ -156,11 +155,12 @@ sandbox_name="gator-pr-${pr_number}-supervised"
156155
--gateway "$gateway_name" \
157156
--name "$sandbox_name" \
158157
--watch \
159-
--background \
160158
"Review and monitor PR #${pr_number} through the gator-gate workflow. Scope this invocation only to PR #${pr_number}."
161159
```
162160

163-
The launcher queries gateway's selected compute driver, builds gator image in matching Docker or Podman image store, stages immutable payload, imports provider profiles, configures provider credentials and refresh, creates and uploads sandbox payload, then starts agent supervisor with `sandbox exec`. It writes a background log under `scripts/agents/gator/logs/`. `CONTAINER_ENGINE`, when set, must match gateway driver.
161+
The launcher queries the gateway's selected compute driver, builds the gator image in the matching Docker or Podman image store, stages the immutable payload, imports provider profiles, configures provider credentials and refresh, and starts the agent supervisor as the sandbox's canonical main process. The detached main process survives loss of the host CLI connection and reconnects to a restarted gateway. Unless `--keep` is set, the sandbox is marked ephemeral so the gateway deletes it after the supervisor exits. `CONTAINER_ENGINE`, when set, must match the gateway driver.
162+
163+
The launcher streams image-build and provisioning output until the detached workload is ready, then exits. Use `openshell logs <sandbox-name>` or the TUI for runtime output.
164164

165165
### Launch An Issue Or Issue/PR Pair
166166

@@ -177,7 +177,6 @@ sandbox_name="gator-issue-${issue_number}-supervised"
177177
--gateway "$gateway_name" \
178178
--name "$sandbox_name" \
179179
--watch \
180-
--background \
181180
"Run gator on issue #${issue_number}. Scope this invocation only to issue #${issue_number}."
182181
```
183182

@@ -198,7 +197,6 @@ sandbox_name="gator-pr-${pr_number}-supervised"
198197
--gateway "$gateway_name" \
199198
--name "$sandbox_name" \
200199
--watch \
201-
--background \
202200
"Review and monitor PR #${pr_number} with linked issue #${issue_number} through the gator-gate workflow. Scope this invocation only to PR #${pr_number} and issue #${issue_number}."
203201
```
204202

@@ -219,7 +217,6 @@ sandbox_name="gator-pr-${pr_number}-supervised"
219217
--gateway "$gateway_name" \
220218
--name "$sandbox_name" \
221219
--watch \
222-
--background \
223220
"Review and monitor PR #${pr_number} through the gator-gate workflow. Scope this invocation only to PR #${pr_number}. The operator explicitly authorizes applying the test:e2e label, posting /ok to test for the current head SHA, and rerunning the relevant current-head workflow when the E2E Label Help bot says that is required."
224221
```
225222

@@ -241,7 +238,6 @@ CODEX_MODEL=gpt-5.6-sol \
241238
--gateway "$gateway_name" \
242239
--name "$sandbox_name" \
243240
--watch \
244-
--background \
245241
"Review and monitor PR #${pr_number} through the gator-gate workflow. Scope this invocation only to PR #${pr_number}. This launch is intentionally testing Codex model gpt-5.6-sol via the CLI launcher."
246242
```
247243

@@ -266,27 +262,22 @@ CODEX_MODEL=gpt-5.6-sol \
266262
--name "$sandbox_name" \
267263
--from "$tmp_context" \
268264
--watch \
269-
--background \
270265
"Review and monitor PR #${pr_number} through the gator-gate workflow. Scope this invocation only to PR #${pr_number}."
271266
```
272267

273268
## Monitoring
274269

275270
### Read The Launch Result
276271

277-
The launcher prints the log path when `--background` is used:
278-
279-
```text
280-
Started in background. Log: scripts/agents/gator/logs/<sandbox-name>.log
281-
```
282-
283-
Read that file directly. Important markers:
272+
The launcher streams image-build and provisioning output to the terminal. Important markers:
284273

285274
- `Built image ...` means the local image build completed.
286275
- `Created sandbox: <name>` means OpenShell accepted the sandbox.
287276
- `openshell-agent: starting watch cycle` means the in-sandbox supervisor began a bounded cycle.
288277
- `OpenAI Codex v...` plus `model: ...` confirms the Codex CLI and model actually used.
289278
- `OPENSHELL_AGENT_RESULT {...}` is the bounded-cycle sentinel. In watch mode, the supervisor sleeps and relaunches after this line.
279+
- `/sandbox/.openshell-agent/status.json` is the atomic current state snapshot. Its `result.notes` field is Gator's plain-language diagnosis and next action for that cycle.
280+
- `/sandbox/.openshell-agent/history.jsonl` contains the latest 100 supervisor transitions, including active-cycle starts and completed cycle results.
290281
- `openshell-agent: still running watch cycle ...` is a heartbeat during long active model cycles.
291282
- `review_feedback_lookup_failed` means Gator could not build the required cross-SHA feedback ledger and deliberately skipped a context-free review.
292283

@@ -314,6 +305,11 @@ If `sandbox get` is not supported by the local CLI shape, use `openshell sandbox
314305
| `status=terminal_failure` | Unrecoverable or stale immutable payload. | Inspect the reason; rebuild/relaunch for `stale_gator_payload`. |
315306
| `status=complete` | Target closed, merged, or one-shot complete. | Delete sandbox if no longer needed. |
316307

308+
Prefer the state snapshot over scraping transient `/tmp` cycle output. Use the
309+
history file to tell whether a failure is repeating or whether the supervisor
310+
has begun a fresh cycle. Runtime logs remain useful for full command output and
311+
transport diagnostics.
312+
317313
## Restarting A Gator
318314

319315
Restart when the payload must change, the sandbox is wedged without a sentinel, the model/tooling version changed, or a transient failure repeats past the useful retry point.
@@ -339,7 +335,6 @@ openshell --gateway "$gateway_name" sandbox delete "$sandbox_name"
339335
--gateway "$gateway_name" \
340336
--name "$sandbox_name" \
341337
--watch \
342-
--background \
343338
"<same scoped operator prompt, updated only with the reason for relaunch>"
344339
```
345340

@@ -401,7 +396,6 @@ When you launch or inspect gator, report:
401396

402397
- Sandbox name.
403398
- Gateway name.
404-
- Log path.
405399
- Target issue/PR scope.
406400
- Harness and model when relevant.
407401
- Whether image build and sandbox creation succeeded.

‎Cargo.lock‎

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ tokio = { version = "1.43", features = ["full"] }
1818

1919
# gRPC/Protobuf
2020
tonic = "0.14"
21+
tonic-types = "0.14"
2122
tonic-prost = "0.14"
2223
tonic-prost-build = "0.14"
2324
prost = "0.14"

‎architecture/build.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ Runtime layout:
221221
gateway bundles z3, so the image does not need a distro-provided z3 runtime.
222222
The base is pinned to a multi-architecture digest; distro security updates
223223
require refreshing that digest and rebuilding the gateway image.
224+
Updating the container's glibc package does not raise the binary's glibc
225+
compatibility floor.
224226
- **VM driver**: host GNU-linked binary installed at
225227
`/usr/libexec/openshell/openshell-driver-vm` in Linux packages and published
226228
as a release artifact. Linux GNU VM driver binaries must not reference

‎architecture/gateway.md‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ The gateway validates this requirement before constructing the selected driver.
5353

5454
## Protocol and Auth
5555

56+
Gateway validation and concurrency errors use the standard rich gRPC error
57+
envelope. Shared field validators attach `google.rpc.BadRequest`, and conditional
58+
write conflicts attach `google.rpc.ErrorInfo` with a stable reason and current
59+
version when available. `google.rpc.RetryInfo` expresses a minimum retry delay;
60+
it does not establish that a mutation is safe to repeat. SDKs retain the original
61+
transport status, metadata, and unknown details alongside decoded fields.
62+
Python cleanup inspects the original gRPC call beneath a typed error wrapper,
63+
preserving missing-resource handling without suppressing other failures.
64+
5665
The gateway listens on one service port and multiplexes gRPC and HTTP traffic.
5766
The default local single-user deployment mode is mTLS user authentication:
5867
clients present a certificate signed by the local deployment CA, and the
@@ -215,7 +224,7 @@ Supported auth modes:
215224
| Plaintext | Local development or a trusted reverse proxy boundary. |
216225
| Unauthenticated local users | Trusted Kubernetes dev or fully trusted proxy deployments only. |
217226
| Cloudflare JWT | Edge-authenticated deployments where Cloudflare Access supplies identity. |
218-
| OIDC | Bearer-token auth for users, with browser or device-code PKCE and client credentials login. JWKS validation accepts RS256, RS384, RS512, PS256, PS384, PS512, ES256, ES384, and EdDSA (Ed25519) signing keys. |
227+
| OIDC | Bearer-token auth for users, with browser or device-code PKCE and client credentials login. Discovery and JWKS retrieval require HTTPS, reject redirects, and pin JWKS to the issuer origin or an explicit origin allowlist. JWKS validation accepts RS256, RS384, RS512, PS256, PS384, PS512, ES256, ES384, and EdDSA (Ed25519) signing keys. |
219228

220229
The CLI persists the scopes requested during OIDC login in gateway metadata and
221230
reuses them when refreshing an access token. This preserves the intended API
@@ -457,6 +466,12 @@ credential storage for defense in depth. Multi-replica deployments can use that
457466
default with a shared database and shared key-encryption key, or opt into an
458467
external backend such as Vault or Kubernetes Secrets.
459468

469+
The Vault credential driver requires HTTPS for every non-loopback backend,
470+
never follows HTTP redirects, and keeps standard certificate hostname
471+
verification enabled. Operators can add private Vault trust roots with a PEM
472+
CA bundle; the driver does not replace platform roots or expose a certificate
473+
verification bypass.
474+
460475
Sandbox workload templates are workspace-scoped gateway resources. Workspace
461476
admins create and delete them; workspace users can read and list them. A
462477
template owns reusable workload intent: image, environment, CPU and memory

‎architecture/sandbox.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,10 @@ Security-relevant sandbox behavior uses OCSF structured events; internal
508508
diagnostics use ordinary tracing.
509509
The OCSF device describes the sandbox environment, with type ID Other and type
510510
label `Sandbox`; its operating system is a separate attribute.
511+
HTTP Activity records contain a request or response; early rejections with only
512+
connection context use Network Activity. Producer regression tests validate
513+
required fields and `at_least_one` constraints against the vendored OCSF 1.8
514+
schemas.
511515

512516
## Policy Proposals
513517

‎architecture/security-policy.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ supervisor polls for config revisions and attempts to load new dynamic policy
189189
into the in-process OPA engine; CLI reads of the latest sandbox policy use the
190190
same effective configuration path.
191191

192+
The OPA loader checks the object and list shapes of raw policy data before injecting runtime fields, normalizing values, or expanding access presets. It rejects the first malformed container with a fixed structural error that excludes authored keys and values. This check preserves valid versionless OPA data and runtime-only fields. A rejected OPA engine reload leaves that engine's installed policy, generation, and decisions unchanged; the supervisor separately applies its configured runtime rejection mode.
193+
192194
The supervisor validates complete effective policy generations before
193195
activation. Overlapping endpoint selectors may contribute request allow and
194196
deny rules only when their connection and request-processing metadata agree;

‎crates/openshell-cli/src/main.rs‎

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,7 +1372,7 @@ enum SandboxCommands {
13721372
no_tty: bool,
13731373

13741374
/// Start the canonical main process without attaching to it.
1375-
#[arg(long, conflicts_with_all = ["editor", "no_keep"])]
1375+
#[arg(long, conflicts_with = "editor")]
13761376
detach: bool,
13771377

13781378
/// Auto-create missing providers from local credentials.
@@ -5461,10 +5461,35 @@ mod tests {
54615461
}
54625462

54635463
#[test]
5464-
fn sandbox_create_detach_rejects_ephemeral_sandbox() {
5465-
let result =
5466-
Cli::try_parse_from(["openshell", "sandbox", "create", "--detach", "--no-keep"]);
5467-
assert!(result.is_err());
5464+
fn sandbox_create_detach_accepts_ephemeral_sandbox() {
5465+
let cli = Cli::try_parse_from([
5466+
"openshell",
5467+
"sandbox",
5468+
"create",
5469+
"--detach",
5470+
"--no-keep",
5471+
"--",
5472+
"worker",
5473+
])
5474+
.expect("detached ephemeral sandbox should parse");
5475+
5476+
match cli.command {
5477+
Some(Commands::Sandbox {
5478+
command:
5479+
Some(SandboxCommands::Create {
5480+
detach,
5481+
no_keep,
5482+
command,
5483+
..
5484+
}),
5485+
..
5486+
}) => {
5487+
assert!(detach);
5488+
assert!(no_keep);
5489+
assert_eq!(command, ["worker"]);
5490+
}
5491+
other => panic!("expected SandboxCommands::Create, got: {other:?}"),
5492+
}
54685493
}
54695494

54705495
#[test]

‎crates/openshell-cli/tests/sandbox_create_lifecycle_integration.rs‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,6 +1700,46 @@ async fn detached_command_does_not_declare_main_process_attachment() {
17001700
assert!(!requests[0].await_main_process_attachment);
17011701
}
17021702

1703+
#[tokio::test]
1704+
async fn detached_ephemeral_command_delegates_cleanup_to_gateway() {
1705+
let server = run_server().await;
1706+
let fake_ssh_dir = tempfile::tempdir().unwrap();
1707+
let xdg_dir = tempfile::tempdir().unwrap();
1708+
let _env = test_env(&fake_ssh_dir, &xdg_dir);
1709+
let tls = test_tls(&server);
1710+
install_fake_ssh(&fake_ssh_dir);
1711+
1712+
run::sandbox_create(
1713+
&server.endpoint,
1714+
"openshell",
1715+
run::SandboxCreateConfig {
1716+
name: Some("detached-ephemeral-main"),
1717+
keep: false,
1718+
command: &["worker".into()],
1719+
detach: true,
1720+
..test_config()
1721+
},
1722+
"default",
1723+
&tls,
1724+
)
1725+
.await
1726+
.expect("detached ephemeral sandbox create should succeed");
1727+
1728+
let requests = create_requests(&server).await;
1729+
assert!(!requests[0].await_main_process_attachment);
1730+
assert_eq!(
1731+
requests[0]
1732+
.annotations
1733+
.get("openshell.nvidia.com/retention")
1734+
.map(String::as_str),
1735+
Some("ephemeral")
1736+
);
1737+
assert!(
1738+
deleted_names(&server).await.is_empty(),
1739+
"the gateway owns cleanup after a detached canonical process exits"
1740+
);
1741+
}
1742+
17031743
#[tokio::test]
17041744
async fn sandbox_create_sends_driver_config_json() {
17051745
let server = run_server().await;

0 commit comments

Comments
 (0)