Files
OpenShell/crates/openshell-core
krishicks 92434dcb2b test(windows): repair the Windows MSVC test suite (#4862)
* fix(isolation): validate Unix socket paths the same way on every host

Prior to this change, SandboxTransport::validate checked Unix socket
paths with Path::is_absolute(). On Windows that requires a drive or UNC
prefix, so a POSIX path such as /run/backend.sock was rejected as
"invalid boundary control transport endpoint". The isolation backend
registration work in #3898 added tests that register Unix endpoints
in the core registration types, gateway config, gateway config
preflight, and supervisor backend setup; all of them failed on the
Windows MSVC runners. The Windows test job only runs on PRs labeled
test:windows, so the break went unnoticed on main.

Unix transport is refused at runtime on non-Unix hosts, so these paths
are always POSIX paths regardless of where they are validated. Now, both
the core registration validator and the sandbox backend protocol
validator use a new openshell_core::paths::is_posix_absolute helper,
which applies the POSIX rule (the path starts with '/') on every host.
On Unix this matches is_absolute() exactly.

Signed-off-by: Kris Hicks <khicks@nvidia.com>

* test(supervisor): run baseline write-back cases only on Unix hosts

The startup policy write-refusal tests from #3785 rely on
enrich_proto_baseline_paths adding the proxy baseline paths (/usr,
/tmp, /dev/null, ...) to a policy, which triggers a write-back that the
fake gateway then refuses. Enrichment only adds paths that exist on the
host. Prior to this change, the tests assumed those paths exist, so on
Windows enrichment added nothing, the precondition assertions failed,
and the baseline case of permanent_codes_still_exit never saw a write
to refuse.

Now, the four baseline write-back tests are gated to Unix, and
permanent_codes_still_exit checks the image policy upload case on every
host and the baseline write-back case only on Unix.

Signed-off-by: Kris Hicks <khicks@nvidia.com>

* test(server): scale the SQLite concurrent-write test for Windows fsync

sqlite_concurrent_writes_return_their_own_resource_version (#4408) runs
8 writers that each make 25 unconditional and 25 version-checked writes
against one row of an on-disk WAL database with synchronous=FULL.
Writers serialize on the SQLite write lock and wait out sqlx's default
5s busy_timeout. Prior to this change, the per-commit fsync cost on the
Windows runners was high enough that a waiting writer starved past that
timeout and failed with "database is locked" after about 7s.

Now, each writer makes 5 writes on Windows and 25 elsewhere. The test
still races every writer on the same row, which is what it checks.

Signed-off-by: Kris Hicks <khicks@nvidia.com>

* test(server): hold scope-mix locks for wall-clock time, not timer ticks

random_scope_mix_never_deadlocks (#4147) runs 64 tasks of 50 random
lock operations and holds each operation's locks for 0-2 ms, failing if
the mix does not finish within 20s. Prior to this change, the hold was a
tokio::time::sleep. Windows timers round a 1 ms sleep up to about 16 ms,
and a quarter of the operations take the exclusive global lock, so the
serialized holds alone took several seconds and the full mix exceeded
the 20s deadline on the Windows runners.

Now, occupy yields until a std::time::Instant deadline, so holds last
0-2 ms of wall-clock time on every platform and the deadline means the
same thing everywhere.

Signed-off-by: Kris Hicks <khicks@nvidia.com>

* test(supervisor): run sandbox instance host tests only on Unix hosts

The sandbox_instance_host tests added with per-instance supervisor
state (#4701) admit hosted instances through SandboxInstanceHost::new,
which prepares a private directory per instance. Hosted sandbox
instances are Unix-only: on other hosts prepare_private_dir returns
"hosted sandbox instances require a Unix host". Prior to this change,
the test module still compiled and ran on Windows, so all three tests
failed while creating their host.

Now, the test module is gated to Unix, and the Unix-only permission
check inside one test no longer needs its own cfg attribute.

Signed-off-by: Kris Hicks <khicks@nvidia.com>

---------

Signed-off-by: Kris Hicks <khicks@nvidia.com>
2026-10-23 18:06:35 +00:00
..

openshell-core

Shared types, constants, configuration, and helpers used across OpenShell crates.

Isolation registrations

isolation_registration owns the operator registry's backend names, byte-stream endpoints, and shared validation. Its fallible conversions carry registrations through the compute-driver protobuf and back into the supervisor's JSON launch file. These routes contain no credentials or driver-owned launch coordinates.

Object Metadata

Top-level user-facing objects use a Kubernetes-style metadata convention. The metadata shape provides:

  • Stable server-generated ID.
  • Human-readable name.
  • Creation timestamp.
  • Optional labels for filtering and automation.

Code that works with object metadata should use the traits in openshell_core::metadata instead of reaching into protobuf fields directly:

use openshell_core::{ObjectId, ObjectLabels, ObjectName};

let id = sandbox.object_id();
let name = sandbox.object_name();
let labels = sandbox.object_labels();

Trait methods must tolerate missing metadata and return safe empty values rather than panicking.

Label Rules

Labels follow Kubernetes-style key and value conventions:

  • Keys may include an optional DNS-prefix followed by /.
  • Names are limited to alphanumeric characters plus -, _, and ..
  • Values use the same character set and may be empty.
  • Selectors use comma-separated key=value pairs with AND semantics.

Validate labels at API ingress before persisting objects.

Inference Profiles

Provider inference profiles live in this crate so the gateway, sandbox, and router agree on provider defaults. Profiles define:

  • Auth header style.
  • Default upstream headers.
  • Client-supplied passthrough headers.
  • Supported inference protocol shapes.

Do not duplicate provider-specific inference behavior in callers. Add shared behavior here, then consume it from the gateway, sandbox, and router.

Middleware Contracts

Built-in supervisor middleware identifiers, host-selector matching, and pure configuration validation live in openshell_core::middleware. Policy admission and the supervisor runtime consume the same contract without introducing a dependency from the policy crate to the supervisor implementation.

Protobuf Struct Conversion

Use openshell_core::proto_struct when crossing between serde_json values and prost_types::{Struct, Value}. Both conversion directions live in this module; JSON-to-protobuf conversion is fallible so callers cannot silently replace an unrepresentable number.