Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions .agents/skills/helm-dev-environment/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,15 +256,19 @@ Key Helm values:

### Keycloak OIDC

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

```bash
mise run keycloak:k8s:setup
```

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

Then activate OIDC in the OpenShell Helm chart:
1. Uncomment `#- ci/values-keycloak.yaml` in `skaffold.yaml`
Expand Down Expand Up @@ -355,4 +359,4 @@ for dependencies still declared in `Chart.yaml`.
| `deploy/helm/openshell/ci/values-tls-disabled.yaml` | Lint-only: TLS + auth disabled (reverse-proxy edge termination) |
| `deploy/kube/manifests/envoy-gateway-openshell.yaml` | GatewayClass for Envoy Gateway (`mise run helm:gateway:apply`) |
| `tasks/scripts/helm-k3s-local.sh` | k3d cluster create/delete/start/stop/status |
| `tasks/scripts/keycloak-k8s-setup.sh` | Keycloak deploy + realm import |
| `tasks/scripts/keycloak-k8s-setup.sh` | Keycloak deploy, realm import, and development TLS trust anchor |
30 changes: 12 additions & 18 deletions .agents/skills/launch-openshell-gator/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ For gator's PR/issue validation policy, load `gator-gate` inside the launched sa

## Non-Negotiable Rules

- Keep normal gator launches supervised: use `--watch --background` and let the in-sandbox supervisor own sleeping and relaunching bounded cycles.
- Keep normal gator launches supervised: use `--watch` and let the in-sandbox supervisor own sleeping and relaunching bounded cycles.
- 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.
- 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.
- Do not push to contributor branches, approve, merge, post `/ok to test`, or broaden gator scope unless the operator explicitly authorized that action.
Expand All @@ -34,7 +34,6 @@ For gator's PR/issue validation policy, load `gator-gate` inside the launched sa
| `scripts/agents/gator/bin/validate-review-findings` | Enforces the blocker evidence schema and downgrades unsupported hypotheses. |
| `scripts/agents/gator/prompts/gator.md` | Rendered top-level prompt template baked into the payload. |
| `scripts/agents/gator/skills/gator-gate/SKILL.md` | In-sandbox gator state-machine skill. |
| `scripts/agents/gator/logs/` | Background launch and supervisor logs. |

## Preflight

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

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.
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.

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.

### Launch An Issue Or Issue/PR Pair

Expand All @@ -177,7 +177,6 @@ sandbox_name="gator-issue-${issue_number}-supervised"
--gateway "$gateway_name" \
--name "$sandbox_name" \
--watch \
--background \
"Run gator on issue #${issue_number}. Scope this invocation only to issue #${issue_number}."
```

Expand All @@ -198,7 +197,6 @@ sandbox_name="gator-pr-${pr_number}-supervised"
--gateway "$gateway_name" \
--name "$sandbox_name" \
--watch \
--background \
"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}."
```

Expand All @@ -219,7 +217,6 @@ sandbox_name="gator-pr-${pr_number}-supervised"
--gateway "$gateway_name" \
--name "$sandbox_name" \
--watch \
--background \
"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."
```

Expand All @@ -241,7 +238,6 @@ CODEX_MODEL=gpt-5.6-sol \
--gateway "$gateway_name" \
--name "$sandbox_name" \
--watch \
--background \
"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."
```

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

## Monitoring

### Read The Launch Result

The launcher prints the log path when `--background` is used:

```text
Started in background. Log: scripts/agents/gator/logs/<sandbox-name>.log
```

Read that file directly. Important markers:
The launcher streams image-build and provisioning output to the terminal. Important markers:

- `Built image ...` means the local image build completed.
- `Created sandbox: <name>` means OpenShell accepted the sandbox.
- `openshell-agent: starting watch cycle` means the in-sandbox supervisor began a bounded cycle.
- `OpenAI Codex v...` plus `model: ...` confirms the Codex CLI and model actually used.
- `OPENSHELL_AGENT_RESULT {...}` is the bounded-cycle sentinel. In watch mode, the supervisor sleeps and relaunches after this line.
- `/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.
- `/sandbox/.openshell-agent/history.jsonl` contains the latest 100 supervisor transitions, including active-cycle starts and completed cycle results.
- `openshell-agent: still running watch cycle ...` is a heartbeat during long active model cycles.
- `review_feedback_lookup_failed` means Gator could not build the required cross-SHA feedback ledger and deliberately skipped a context-free review.

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

Prefer the state snapshot over scraping transient `/tmp` cycle output. Use the
history file to tell whether a failure is repeating or whether the supervisor
has begun a fresh cycle. Runtime logs remain useful for full command output and
transport diagnostics.

## Restarting A Gator

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.
Expand All @@ -339,7 +335,6 @@ openshell --gateway "$gateway_name" sandbox delete "$sandbox_name"
--gateway "$gateway_name" \
--name "$sandbox_name" \
--watch \
--background \
"<same scoped operator prompt, updated only with the reason for relaunch>"
```

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

- Sandbox name.
- Gateway name.
- Log path.
- Target issue/PR scope.
- Harness and model when relevant.
- Whether image build and sandbox creation succeeded.
Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/conformance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ jobs:
name: openshell-conformance-x86_64-unknown-linux-musl
path: conformance-input

- name: Run RPM gateway continuity conformance
- name: Run RPM smoke conformance
shell: bash
run: |
set -euo pipefail
Expand All @@ -169,11 +169,9 @@ jobs:
--distro fedora \
--with podman-rootless \
--with selinux \
--copy "${candidate_cli_package[0]}:/var/lib/openshell-conformance/candidate/openshell.rpm" \
--copy "${candidate_gateway_package[0]}:/var/lib/openshell-conformance/candidate/openshell-gateway.rpm" \
--install "${candidate_cli_package[0]}" \
--install "${candidate_gateway_package[0]}" \
--copy conformance-input/openshell-conformance:/tmp/openshell-conformance \
--copy nix/test-guest/conformance-plans/gateway-upgrade-restart.toml:/tmp/conformance-plan.toml \
--provision openshell-rpm-latest-release \
--provision openshell-rpm \
--provision gateway-podman \
--provision openshell-rpm-gateway-upgrade \
-- /tmp/openshell-conformance run --plan /tmp/conformance-plan.toml
-- /tmp/openshell-conformance run smoke
3 changes: 2 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ tokio = { version = "1.43", features = ["full"] }

# gRPC/Protobuf
tonic = "0.14"
tonic-types = "0.14"
tonic-prost = "0.14"
tonic-prost-build = "0.14"
prost = "0.14"
Expand Down
11 changes: 5 additions & 6 deletions architecture/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ Runtime layout:
gateway bundles z3, so the image does not need a distro-provided z3 runtime.
The base is pinned to a multi-architecture digest; distro security updates
require refreshing that digest and rebuilding the gateway image.
Updating the container's glibc package does not raise the binary's glibc
compatibility floor.
- **VM driver**: host GNU-linked binary installed at
`/usr/libexec/openshell/openshell-driver-vm` in Linux packages and published
as a release artifact. Linux GNU VM driver binaries must not reference
Expand Down Expand Up @@ -292,12 +294,9 @@ pulls and explicit publication. OCI pulls require a trusted manifest digest
and retain that provenance with the local entry; mutable tags are used only
for explicit publication.

CLI conformance runs after target provisioning. Action-free scenarios operate
only through the configured OpenShell CLI. A versioned conformance plan may add
an ordered sequence of target-supplied host-side actions, such as a gateway
restart, while the scenario remains responsible for black-box sandbox
continuity checks. The plan exposes opaque executable paths and timeouts rather
than driver or package-manager configuration; target setup owns those details.
CLI conformance runs after target provisioning and operates only through the
configured OpenShell CLI. The smoke scenario verifies the black-box sandbox
lifecycle by creating, inspecting, executing in, and deleting a sandbox.

## Python Wheel Packaging

Expand Down
11 changes: 10 additions & 1 deletion architecture/gateway.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ The gateway validates this requirement before constructing the selected driver.

## Protocol and Auth

Gateway validation and concurrency errors use the standard rich gRPC error
envelope. Shared field validators attach `google.rpc.BadRequest`, and conditional
write conflicts attach `google.rpc.ErrorInfo` with a stable reason and current
version when available. `google.rpc.RetryInfo` expresses a minimum retry delay;
it does not establish that a mutation is safe to repeat. SDKs retain the original
transport status, metadata, and unknown details alongside decoded fields.
Python cleanup inspects the original gRPC call beneath a typed error wrapper,
preserving missing-resource handling without suppressing other failures.

The gateway listens on one service port and multiplexes gRPC and HTTP traffic.
The default local single-user deployment mode is mTLS user authentication:
clients present a certificate signed by the local deployment CA, and the
Expand Down Expand Up @@ -215,7 +224,7 @@ Supported auth modes:
| Plaintext | Local development or a trusted reverse proxy boundary. |
| Unauthenticated local users | Trusted Kubernetes dev or fully trusted proxy deployments only. |
| Cloudflare JWT | Edge-authenticated deployments where Cloudflare Access supplies identity. |
| 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. |
| 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. |

The CLI persists the scopes requested during OIDC login in gateway metadata and
reuses them when refreshing an access token. This preserves the intended API
Expand Down
4 changes: 4 additions & 0 deletions architecture/sandbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,10 @@ Security-relevant sandbox behavior uses OCSF structured events; internal
diagnostics use ordinary tracing.
The OCSF device describes the sandbox environment, with type ID Other and type
label `Sandbox`; its operating system is a separate attribute.
HTTP Activity records contain a request or response; early rejections with only
connection context use Network Activity. Producer regression tests validate
required fields and `at_least_one` constraints against the vendored OCSF 1.8
schemas.

## Policy Proposals

Expand Down
35 changes: 30 additions & 5 deletions crates/openshell-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,7 @@ enum SandboxCommands {
no_tty: bool,

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

/// Auto-create missing providers from local credentials.
Expand Down Expand Up @@ -5461,10 +5461,35 @@ mod tests {
}

#[test]
fn sandbox_create_detach_rejects_ephemeral_sandbox() {
let result =
Cli::try_parse_from(["openshell", "sandbox", "create", "--detach", "--no-keep"]);
assert!(result.is_err());
fn sandbox_create_detach_accepts_ephemeral_sandbox() {
let cli = Cli::try_parse_from([
"openshell",
"sandbox",
"create",
"--detach",
"--no-keep",
"--",
"worker",
])
.expect("detached ephemeral sandbox should parse");

match cli.command {
Some(Commands::Sandbox {
command:
Some(SandboxCommands::Create {
detach,
no_keep,
command,
..
}),
..
}) => {
assert!(detach);
assert!(no_keep);
assert_eq!(command, ["worker"]);
}
other => panic!("expected SandboxCommands::Create, got: {other:?}"),
}
}

#[test]
Expand Down
40 changes: 40 additions & 0 deletions crates/openshell-cli/tests/sandbox_create_lifecycle_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1700,6 +1700,46 @@ async fn detached_command_does_not_declare_main_process_attachment() {
assert!(!requests[0].await_main_process_attachment);
}

#[tokio::test]
async fn detached_ephemeral_command_delegates_cleanup_to_gateway() {
let server = run_server().await;
let fake_ssh_dir = tempfile::tempdir().unwrap();
let xdg_dir = tempfile::tempdir().unwrap();
let _env = test_env(&fake_ssh_dir, &xdg_dir);
let tls = test_tls(&server);
install_fake_ssh(&fake_ssh_dir);

run::sandbox_create(
&server.endpoint,
"openshell",
run::SandboxCreateConfig {
name: Some("detached-ephemeral-main"),
keep: false,
command: &["worker".into()],
detach: true,
..test_config()
},
"default",
&tls,
)
.await
.expect("detached ephemeral sandbox create should succeed");

let requests = create_requests(&server).await;
assert!(!requests[0].await_main_process_attachment);
assert_eq!(
requests[0]
.annotations
.get("openshell.nvidia.com/retention")
.map(String::as_str),
Some("ephemeral")
);
assert!(
deleted_names(&server).await.is_empty(),
"the gateway owns cleanup after a detached canonical process exits"
);
}

#[tokio::test]
async fn sandbox_create_sends_driver_config_json() {
let server = run_server().await;
Expand Down
Loading
Loading