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
2 changes: 1 addition & 1 deletion .github/workflows/integration-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ on:
type: string
default: >-
[
{"environment":"ubuntu-docker-rootful","installer":"binaries","testsuite":"conformance"},
{"environment":"ubuntu-docker-rootful","installer":"deb","testsuite":"conformance"},
{"environment":"fedora-podman-rootful","installer":"binaries","testsuite":"conformance"},
{"environment":"fedora-podman-rootless","installer":"binaries","testsuite":"conformance"}
]
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/prepare-integration-inputs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ on:
required: false
type: string
default: ""
deb-artifact-name:
description: Debian package artifact to include in the tmachine inputs
required: false
type: string
default: ""
outputs:
source_sha:
description: Source revision of the candidate artifacts
Expand Down Expand Up @@ -65,6 +70,22 @@ jobs:
github-token: ${{ github.token }}
run-id: ${{ inputs['artifact-run-id'] || github.run_id }}

- name: Download Debian package artifact
if: inputs['deb-artifact-name'] != ''
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ inputs['deb-artifact-name'] }}
path: artifacts/packages/download
github-token: ${{ github.token }}
run-id: ${{ inputs['artifact-run-id'] || github.run_id }}

- name: Stage Debian package input
if: inputs['deb-artifact-name'] != ''
run: |
set -euo pipefail
mv artifacts/packages/download/*.deb artifacts/packages/openshell.deb
rmdir artifacts/packages/download

- name: Log in to GHCR
run: echo "${{ github.token }}" | docker login ghcr.io -u "${GITHUB_ACTOR}" --password-stdin

Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/release-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,14 @@ jobs:
checkout-ref: ${{ github.sha }}

prepare-integration:
needs: [build-binaries, build-images]
needs: [build-binaries, build-deb, build-images]
permissions:
actions: read
contents: read
packages: read
uses: ./.github/workflows/prepare-integration-inputs.yml
with:
deb-artifact-name: deb-linux-amd64

conformance-integration:
needs: prepare-integration
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/release-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,14 @@ jobs:
checkout-ref: ${{ needs.compute-versions.outputs.source_sha }}

prepare-integration:
needs: [compute-versions, build-binaries, build-images]
needs: [compute-versions, build-binaries, build-deb, build-images]
permissions:
actions: read
contents: read
packages: read
uses: ./.github/workflows/prepare-integration-inputs.yml
with:
deb-artifact-name: deb-linux-amd64

conformance-integration:
needs: prepare-integration
Expand Down
14 changes: 12 additions & 2 deletions architecture/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ includes, templates, inventory, and requirements. The digest uses sorted
relative paths, file contents, and executable permissions; source symlinks
are unsupported. Both keys also retain the ordered playbook paths and contents,
their base disk contents, and whether Galaxy is enabled; install keys
include named binary inputs. The top-level `.roles` directory is excluded:
include named artifact inputs. The top-level `.roles` directory is excluded:
Galaxy release pins in `requirements.yaml` are treated as immutable, including
any transitive dependency pins. Cache misses with Galaxy enabled reinstall
the required roles and their dependencies before running playbooks.
Expand All @@ -286,7 +286,17 @@ the gateway, sandbox, and supervisor as separate binaries for their respective
Dockerfiles. The helpers stage binaries under `artifacts/binaries` so local and
CI builds expose the same inputs to tmachine and image assembly. The Ubuntu
Docker and Fedora Podman environments import both local runtime images and
configure the gateway to use them.
configure the gateway to use them. The Ubuntu `deb` installer consumes
`artifacts/packages/openshell.deb`; the `binaries` installer remains available
for direct executable installation on every environment. Release Dev and
Release Tag run Ubuntu conformance through the Debian package, while Fedora
continues using direct executable installation until RPM coverage is available.
The Debian qualification profile keeps candidate-image overrides outside the
operator-owned gateway configuration: it writes a harness-owned file under
`/var/lib/openshell-qualification` and selects it through the packaged systemd
unit's `gateway.env` hook. Ordinary package installations continue to use the
gateway's built-in runtime-image defaults unless the operator configures an
override.

## Python Wheel Packaging

Expand Down
4 changes: 4 additions & 0 deletions architecture/compute-runtimes.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ supervisor or Sandbox Runtime process replacement does not resume a running
generation. Planned upgrades stop the sandbox first; the following start mints
a fresh session, TLS identity, and credential pair. An unexpected replacement
leaves the old workload on the normal fail-closed disconnect path.
The gateway commits the new authorization identity and the durable `Starting`
phase in one resource-version update. A concurrent start that loses that update
reuses the winning identity, so every idempotent driver retry receives credentials
that match the persisted sandbox.

A driver stop operation does not complete while its backend still reports an
in-progress stop. This prevents an immediate start from racing the previous
Expand Down
9 changes: 9 additions & 0 deletions architecture/gateway.md
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,15 @@ Allow and deny append requests carry `L7RuleTarget` to declare the rule, endpoin

`GetSandboxProviderStatus` and `ReportProviderReadiness` are unary public gateway RPCs. The first lets authorized users inspect a provider change; the second accepts installation reports only from the sandbox's current authenticated supervisor session.

`CreateSandboxRequest.service_exposures` is an additive public API field. Its
`SandboxServiceExposure` entries register service endpoints as part of sandbox
creation and are represented in the Rust, Python, TypeScript, and Go SDK create
options. The request-only exposure description is not durable; the gateway
persists the resulting `ServiceEndpoint` objects through the existing endpoint
store after it persists the sandbox. `SandboxResponse.service_urls` returns the
routed URLs keyed by service name for `CreateSandbox`; the empty key represents
the unnamed endpoint, and other sandbox operations leave the map empty.

The removed `NetworkBinary.harness` field remains reserved by number and name,
so protobuf implementations cannot reuse its wire slot or source identifier.
The durable-policy compatibility decoder reads the former boolean before Prost
Expand Down
8 changes: 8 additions & 0 deletions architecture/sandbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,14 @@ sandbox workload directly. The relay supports:
`BASH_ENV` when the child environment sets it.
- Tar-based file sync.
- Port forwarding where supported by the CLI/TUI surface.
- Persistent HTTP and WebSocket service routing through gateway-managed
`ServiceEndpoint` records. `CreateSandboxRequest.service_exposures` registers
named or unnamed endpoints as part of sandbox creation, and the gateway
returns their routed URLs keyed by service name. The empty key identifies the
unnamed endpoint. Routing starts only while the sandbox is ready. `sandbox
create --expose PORT` uses the unnamed create-time endpoint and keeps the
sandbox. The standalone service API can add, update, or remove endpoints
later.

Sandbox logs are emitted locally and can also be pushed back to the gateway.
Security-relevant sandbox behavior uses OCSF structured events; internal
Expand Down
83 changes: 79 additions & 4 deletions crates/openshell-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,7 @@ enum SandboxCommands {
keep: bool,

/// Delete the sandbox after the initial command or shell exits.
#[arg(long, conflicts_with_all = ["keep", "editor", "forward"])]
#[arg(long, conflicts_with_all = ["keep", "editor", "forward", "expose"])]
no_keep: bool,

/// Launch a remote editor after the sandbox is ready.
Expand Down Expand Up @@ -1363,6 +1363,16 @@ enum SandboxCommands {
#[arg(long, conflicts_with = "no_keep")]
forward: Option<String>,

/// Expose a loopback HTTP or WebSocket service after the sandbox is ready.
/// Keeps the sandbox alive. Use `openshell service expose` to add a named service.
#[arg(
long,
value_name = "PORT",
value_parser = clap::value_parser!(u16).range(1..),
conflicts_with = "no_keep"
)]
expose: Option<u16>,

/// Allocate a pseudo-terminal for the remote command.
/// Defaults to auto-detection (on when stdin and stdout are terminals).
/// Use --tty to force a PTY even when auto-detection fails, or
Expand Down Expand Up @@ -1416,7 +1426,7 @@ enum SandboxCommands {
approval_mode: String,

/// Output format.
#[arg(short = 'o', long = "output", value_enum, default_value_t = OutputFormat::Table, conflicts_with_all = ["editor", "command", "no_keep", "forward"])]
#[arg(short = 'o', long = "output", value_enum, default_value_t = OutputFormat::Table, conflicts_with_all = ["editor", "no_keep", "forward"])]
output: OutputFormat,

/// Command to run after "--" (defaults to an interactive shell).
Expand Down Expand Up @@ -3144,6 +3154,7 @@ async fn run_async() -> Result<()> {
providers,
policy,
forward,
expose,
tty,
no_tty,
detach,
Expand Down Expand Up @@ -3211,7 +3222,11 @@ async fn run_async() -> Result<()> {
let forward = forward
.map(|s| openshell_core::forward::ForwardSpec::parse(&s))
.transpose()?;
let keep = keep || !no_keep || editor.is_some() || forward.is_some();
let keep = keep
|| !no_keep
|| editor.is_some()
|| forward.is_some()
|| expose.is_some();
let gpu_requirements: Option<GpuResourceRequirements> = gpu.map(Into::into);

let ctx = resolve_gateway(&cli.gateway, &cli.gateway_endpoint)?;
Expand All @@ -3235,6 +3250,7 @@ async fn run_async() -> Result<()> {
providers: &providers,
policy: policy.as_deref(),
forward,
expose,
command: &command,
tty_override,
auto_providers_override,
Expand Down Expand Up @@ -5837,7 +5853,6 @@ mod tests {
fn sandbox_create_output_conflicts_with_side_effect_args() {
for (label, extra_args) in [
("--editor", &["--editor", "code"][..]),
("trailing command", &["--", "claude"][..]),
("--no-keep", &["--no-keep"][..]),
("--forward", &["--forward", "8080"][..]),
] {
Expand All @@ -5852,6 +5867,22 @@ mod tests {
}
}

#[test]
fn sandbox_create_detached_command_accepts_structured_output() {
Cli::try_parse_from([
"openshell",
"sandbox",
"create",
"--detach",
"--output",
"json",
"--",
"codex",
"app-server",
])
.expect("a detached command should support structured create output");
}

#[test]
fn sandbox_create_resource_flags_parse() {
let cli = Cli::try_parse_from([
Expand Down Expand Up @@ -6239,6 +6270,50 @@ mod tests {
);
}

#[test]
fn sandbox_create_accepts_service_exposure() {
let cli = Cli::try_parse_from([
"openshell",
"sandbox",
"create",
"--expose",
"4500",
"--detach",
])
.expect("sandbox create --expose should parse");

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

#[test]
fn sandbox_create_rejects_service_exposure_with_no_keep() {
let result = Cli::try_parse_from([
"openshell",
"sandbox",
"create",
"--expose",
"4500",
"--no-keep",
]);

assert!(result.is_err());
}

#[test]
fn sandbox_create_rejects_zero_service_port() {
let result = Cli::try_parse_from(["openshell", "sandbox", "create", "--expose", "0"]);

assert!(result.is_err());
}

#[test]
fn service_expose_accepts_positional_target_port_and_service() {
let cli = Cli::try_parse_from([
Expand Down
Loading
Loading