Skip to content

feat(server): reject unknown protobuf fields at ingress and in stored policies - #6114

Draft
mrunalp wants to merge 10 commits into
mainfrom
feat/6097-grpc-field-validation/mrunalp
Draft

mrunalp wants to merge 10 commits into
mainfrom
feat/6097-grpc-field-validation/mrunalp

Conversation

@mrunalp

@mrunalp mrunalp commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Implement RFC 0027: the gateway rejects protobuf fields and enum values it does not know, both at gRPC ingress and when loading stored policies, so version skew can no longer silently drop policy restrictions. Patch release trains now freeze proto/.

Related Issue

Part of #6097. Not closing yet: the supported_policy_capabilities discovery field and the RFC 0014 companion edit are still open.

Changes

Each step is a separate commit for review.

  • Wire scanner: a descriptor-guided protobuf walker reports unknown or reserved tags and unrecognized enum values with dotted field paths. It caps nesting at 32 and violations at 16, skips bytes/string payloads by length, and never echoes field contents.
  • Ingress: a wrapper ahead of the gateway interceptors checks every frame of strict RPCs. Strict RPCs are those with unauthenticated, bearer, operator, or dual auth, plus any RPC whose request reaches a policy type, such as SubmitPolicyAnalysis. Unary and server-streaming requests are fully checked before dispatch, so a rejected request never consumes its request_id. Rejections return INVALID_ARGUMENT with ErrorInfo reason UNKNOWN_PROTOBUF_FIELD and BadRequest violations. Interceptor body collection, the ExecSandboxInteractive start frame, and ForwardTcp now keep that status instead of turning it into INTERNAL or closing silently.
  • Persistence boundary: policy revisions, the global policy setting, draft chunks, provider-profile endpoints, and Sandbox.spec.policy are scanned before prost decodes them. Unknown restrictions return FAILED_PRECONDITION, which yields a not-admitted configuration. Sandbox writes through the Store, and the policy-revision projection, keep the stored spec.policy bytes when an update leaves the known policy unchanged. A test pins the five durable roots that reach policy types.
  • CI: check_proto_compatibility.py classifies the train as none, patch, or minor. On patch trains, added services, RPCs, messages, fields, enums, or enum values fail.
  • Docs: upgrade order, version skew, and rollback in the support matrix; UNKNOWN_PROTOBUF_FIELD in API errors; authoring rules in proto/README.md; two new metrics.

Review notes:

  • Extra read on sandbox writes: Store writes to an existing sandbox row now do one extra read to preserve the stored policy bytes.
  • Test race fix: oversized_configuration_is_rejected_over_grpc_and_smaller_configuration_recovers now truncates providers with compare-and-swap. Its unconditional write could lose to the gateway's concurrent admission update, and the extra read made that race reproducible.
  • Effect on open PRs: main is in a patch train (v0.1.11), so PRs that add protobuf definitions fail the compatibility check until that train ships.

Release Notes

The gateway now rejects requests and stored policies that use protobuf fields or enum values it does not know, returning UNKNOWN_PROTOBUF_FIELD instead of silently dropping them. Upgrade gateways before clients and supervisors.

Testing

  • Checks appropriate to the affected code and behavior pass: cargo clippy -p openshell-server --tests, ruff, markdownlint, docs:nav
  • Unit tests added/updated: 2965 openshell-server tests pass. The 8 that failed locally also fail without this change, because the local sandbox blocks Unix-socket binds and writes under ~/.local/state. The new check_proto_compatibility_test.py includes end-to-end buf cases.
  • E2E tests added/updated (if applicable): a mixed-version (N/N+1) gateway rollout is not covered yet

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)

🤖 Generated with Claude Code

mrunalp and others added 6 commits November 30, 2026 21:59
Implement step 1 of RFC 0027. The scanner walks raw protobuf bytes
against the compiled public and storage descriptors before prost decodes
them, reporting unknown tags, reserved tags, and unrecognized enum values
with dotted field paths. It bounds nesting at 32 levels and stops after
16 violations, never echoes field contents, and redacts enum values on
fields marked secret. Rejections map to INVALID_ARGUMENT with ErrorInfo
reason UNKNOWN_PROTOBUF_FIELD and BadRequest field violations.

Add helpers that extract, scan, and splice raw Sandbox.spec.policy bytes
so read-modify-writes on an older gateway can preserve policy fields a
newer gateway wrote. Ingress and persistence callers follow in later
steps.

Refs #6097

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
Implement step 2 of RFC 0027. A wrapper ahead of the gateway interceptors
scans every request frame of strict RPCs against the method's input
descriptor before interceptors or tonic decode it. Strict RPCs are those
with unauthenticated, bearer, operator, or dual auth, plus any RPC whose
request reaches a policy type, such as SubmitPolicyAnalysis. Non-policy
sandbox, peer, and supervisor RPCs stay exempt during 0.x.

Unary and server-streaming requests are reassembled and validated before
dispatch, so a rejected request never reaches durable request admission.
Client streams are validated frame by frame and end with the scanner's
status. Compressed frames return UNIMPLEMENTED and frames above the
route's decoding limit return RESOURCE_EXHAUSTED.

Keep the exact status and details when a request body fails: interceptor
body collection, the interactive exec start frame, and ForwardTcp relay
frames now pass the validation status to the client. Rejections count in
openshell_server_grpc_unknown_fields_total.

Refs #6097

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
Implement step 3 of RFC 0027. Stored payloads that carry policy are
scanned before prost decodes them, so a policy written by a newer
gateway is refused instead of silently broadened:

- Policy revisions and the global policy setting are scanned on load
  and fail with FAILED_PRECONDITION, which configuration delivery turns
  into a not-admitted configuration. Only the legacy NetworkBinary
  advisor flag is tolerated.
- Draft chunks scan proposed_rule and both effective policies before
  the proposed rule is re-encoded.
- Stored provider profiles scan their endpoint restrictions.
- Sandbox.spec.policy is scanned from the raw row wherever it is
  evaluated, canonicalized, compared, or delivered.

Sandbox writes through the store, and the policy-revision projection,
keep the stored spec.policy bytes when the update leaves the policy this
build understands unchanged, so an unrelated status or label update on an
older gateway no longer erases newer restrictions. A test pins the
durable roots that reach policy types.

Make the oversized-configuration delivery test truncate providers with
compare-and-swap. Its unconditional write raced the gateway's concurrent
admission update and could be lost.

Rejections count in openshell_server_stored_policy_unknown_fields_total.

Refs #6097

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
Implement the release-train check from RFC 0027 step 4. train_policy()
now classifies the active train as none, patch, or minor instead of
returning one allows_breaks flag:

- none: no pre-release train is active. Additive changes may merge so a
  feat change can start the next minor train; breaking changes fail.
- patch: proto/ is frozen. Added services, RPCs, messages, fields,
  extensions, enums, or enum values fail alongside breaking changes.
- minor: additive changes pass and breaking changes are warnings during
  0.x.

Additions are found by comparing definition inventories from buf JSON
images, keyed by number so renames are not additions. Add unit tests,
including an end-to-end buf check when buf is installed, and run them
with test:python-scripts.

Refs #6097

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
Describe RFC 0027 for operators and API authors:

- The support matrix gains the gateway-first upgrade order, the
  collector-settings exception, version-skew behavior, and rollback
  guidance, and notes that new protobuf definitions ship only in minor
  releases.
- proto/README.md asks authors to add definitions only on minor trains,
  leave unset fields at defaults, and gate new policy restrictions on a
  supervisor capability.
- Gateway metrics list the ingress and stored-policy rejection counters.

Refs #6097

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
Cover the RFC 0027 acceptance case for the two RPCs that carry policy:
UpdateConfig, which sandboxes may call, and SubmitPolicyAnalysis, which
is sandbox-authenticated but strict because its proposed rule reaches a
policy type. A restriction nested inside the policy is rejected before
dispatch with UNKNOWN_PROTOBUF_FIELD and its field path.

Refs #6097

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
@mrunalp mrunalp added topic:security Vulnerability management, security analysis/auditing, bypass detection, and abuse prevention. area:platform SDKs, CLIs, APIs, gateway infrastructure, persistence, configuration, and session management. topic:api Public APIs, gRPC/protobuf, SDK interfaces, versioning, compatibility, and API design standards. topic:policy Policy authoring, validation, proving, distribution, enforcement, ergonomics, and hardening. labels Dec 1, 2026
@github-actions github-actions Bot added the state:accepted A maintainer decided OpenShell should pursue this issue label Dec 1, 2026
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown

//!
//! A gateway that decodes a `Sandbox` written by a newer gateway drops the
//! newer policy restrictions. Re-encoding that `Sandbox` after an unrelated
//! change (status, labels, image state) would erase them from storage. These

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🤖 blocking 🔴 – Image updates still erase newer policy fields. ImageTransaction::write_projection in persistence/sandbox_image.rs calls sandbox.encode_to_vec() and writes directly to SQLite or PostgreSQL. Carry the policy bytes from the locked row through both begin and complete, and test that the stored bytes survive each operation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 924ce73. lock_sandbox now returns the migrated stored payload with the decoded sandbox, and write_projection encodes through encode_preserving_spec_policy, so both begin and complete keep the stored spec.policy bytes. image_updates_preserve_newer_spec_policy_bytes checks the stored bytes after each operation.

return Ok(());
}
let Some(record) = store
.get(Sandbox::object_type(), sandbox.object_id())

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🤖 blocking 🔴 – This fetch can validate a different revision from the Sandbox the caller evaluates. If the row is replaced or deleted between reads, the check can succeed and the caller can deliver the earlier policy with unknown fields already stripped. Validate and decode the same row, or require matching resource versions and retry the whole read on a mismatch.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 924ce73. with_known_spec_policy replaces require_known_spec_policy, and callers use the sandbox it returns. When the caller's policy equals the known fields of the stored row, that row is scanned. When a sandbox read from storage no longer matches the row, it returns ABORTED so the caller reads again; a deleted row returns NOT_FOUND. I compare policies rather than resource versions because unconditional put does not bump the version. Unsaved sandboxes (version 0) keep their in-memory policy, which create validation needs. spec_policy_check_and_use_share_one_stored_row covers the stripped copy, the replaced row, a deleted row, and an unsaved sandbox.

source: StoredPolicySource,
) -> Result<(), Status> {
match scan_named(SANDBOX_POLICY, payload, LEGACY) {
Ok(()) | Err(WireRejection::Malformed(_)) => Ok(()),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🤖 blocking 🔴 – A scanner error does not guarantee a prost decode error. For example, prost supports unknown protobuf groups while FieldIter reports them as malformed. Returning Ok(()) lets a policy pass without a complete scan. Reject unscannable stored data before decoding it, including in the draft and provider-profile loaders.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 924ce73. Any scan error now refuses the stored payload: require_known_stored_policy for revisions, global and spec policy, plus the draft and provider-profile loaders. unscannable_stored_policy_is_refused uses an unknown group that prost decodes successfully, to show the scanner is the only guard.

.await
.map_err(|e| {
Status::internal(format!("list platform provider profiles failed: {e}"))
crate::grpc::persistence_error_to_status(e, "list platform provider profiles")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🤖 should-fix 🟡 – One incompatible platform profile now rejects configuration for every sandbox, including sandboxes with no providers. load_sandbox_config_inputs snapshots the entire catalog, and collect_messages stops on the first incompatible row. Keep the incompatibility associated with that profile and reject configurations that depend on it. Cover an unrelated sandbox in the same test.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 924ce73. The user profile source decodes rows one at a time. An unreadable profile is left out of the catalog and recorded with its scope. load_sandbox_config_inputs refuses only sandboxes whose providers resolve to it, using the same workspace/platform resolution as get_type_profile_for_scope. unreadable_provider_profile_rejects_only_dependent_configurations builds a dependent sandbox (not admitted) and an unrelated one (built). I also made DeleteProviderProfile read the raw row, so an operator can still remove an unreadable profile.


let sandbox_id_in = sandbox_id.to_string();
let channel_id_in = channel_id.to_string();
let tx_in = tx.clone();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🤖 should-fix 🟡 – tx_in keeps the response channel open after relay EOF if the client leaves its request stream open. The detached task can wait indefinitely in inbound.message() while the client waits for response EOF. Tie the task to the relay reader’s lifetime, and test relay EOF with the request sender still open.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 924ce73. The request reader now holds a WeakSender and upgrades it only to report a rejected frame, so the response ends when the relay reader drops its sender. I left the reader running after relay EOF so TCP half-close still delivers late client data. forward_tcp_response_ends_at_relay_eof_while_request_stream_stays_open would hang with the previous strong sender.

match crate::wire_validation::stored::scan_draft_chunk_payload(payload) {
Ok(()) | Err(crate::wire_validation::WireRejection::Malformed(_)) => {}
Err(rejection) => {
return Err(PersistenceError::UnknownFields(format!(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🤖 should-fix 🟡 – GetDraftPolicy and ApproveDraftChunk wrap this new UnknownFields error in Status::internal. Use persistence_error_to_status at the draft RPC boundaries so clients receive FAILED_PRECONDITION for an incompatible stored draft. Assert the status through the RPC.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 924ce73. Every draft read in grpc/policy.rs (11 sites, including GetDraftPolicy and ApproveDraftChunk) now goes through persistence_error_to_status. draft_rpcs_refuse_drafts_with_newer_restrictions asserts FAILED_PRECONDITION through both RPCs.


@property
def allows_breaks(self) -> bool:
return self.kind == MINOR

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🤖 should-fix 🟡 – Every minor train permits breaking changes here, including v1.0.x to v1.1.0. The RFC requires additive-only changes within 1.x. Include the major version in this decision and test a breaking change on a 1.x minor train.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 7a8d05f. Added a major train kind. Breaking changes are allowed only on 0.x minor trains and on major trains (including 1.0.0); 1.x minor trains are additive-only. Tests cover the classification and an end-to-end breaking change on a 1.x minor train with real buf.

mrunalp and others added 2 commits December 1, 2026 04:18
Address review feedback on RFC 0027 persistence-boundary validation:

- Image update begin and complete keep the locked row's spec.policy
  bytes; they wrote the sandbox directly and erased newer restrictions.
- The spec policy check and its use share one stored row. A sandbox
  read from storage whose policy no longer matches the row gets ABORTED
  so the caller reads again, and a deleted row gets NOT_FOUND. Resource
  versions alone cannot detect this because unconditional writes keep
  them.
- Stored policies, drafts, and profile endpoints the scanner cannot
  parse are refused, even where prost would decode them, such as
  unknown groups.
- An unreadable provider profile no longer fails the whole catalog. It
  is left out, configurations whose providers resolve to it are not
  admitted, and DeleteProviderProfile can still remove it.
- Draft RPCs map an unreadable stored draft to FAILED_PRECONDITION
  instead of INTERNAL.
- ForwardTcp holds a weak response sender in its request reader, so the
  response still ends at relay EOF while the client keeps sending.

Refs #6097

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
Breaking changes are now allowed only on 0.x minor trains and on major
trains, including 1.0.0. Within 1.x and later majors, a minor train is
additive-only, as RFC 0027 requires. Add a major train kind and test a
breaking change on a 1.x minor train.

Refs #6097

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
return Ok(policy);
}
sandbox
Box::pin(with_known_spec_policy(store, sandbox))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🤖 blocking 🔴 – A single incompatible sandbox policy can still prevent the gateway from starting. With provider composition enabled, startup calls current_base_policy_for_sandbox for every sandbox with providers and propagates the first error out of run_server. Handle the stored-policy incompatibility per sandbox during preflight and retain the refusal on delivery. Cover startup with one affected sandbox and one healthy sandbox.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 6ac8a47. Stored-data incompatibility refusals now carry ErrorInfo reason UNKNOWN_PROTOBUF_FIELD (wire_validation::stored::is_incompatible). The startup preflight sets aside a sandbox whose stored policy, or whose provider profile, this gateway cannot read, and keeps validating the rest; configuration delivery still refuses that sandbox. startup_preflight_sets_aside_a_sandbox_with_an_unreadable_policy runs the preflight with one affected and one healthy sandbox and checks that delivery refuses the affected one; startup_preflight_still_checks_sandboxes_beside_an_unreadable_policy checks that a real violation elsewhere still fails startup.

});
}
build_effective_profiles(snapshots)
let mut catalog = build_effective_profiles(snapshots)?;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🤖 blocking 🔴 – The token broker reads this catalog through get_type_profile_for_scope, which ignores incompatible. When a workspace profile is unreadable and a same-ID platform profile exists, GetSandboxProviderAccessToken can authorize a grant from the platform profile. Enforce incompatibility in scoped resolution itself and test this case through the token RPC.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 6ac8a47. scoped_type_profile_for_scope now calls require_compatible_profile first and returns None when the profile in the resolving scope is unreadable, so it never falls back to a same-ID platform profile. Every caller already treats None as fail-closed. unreadable_workspace_profile_never_falls_back_to_the_platform_grant drives grant_configuration, the profile-authorization step of GetSandboxProviderAccessToken: the grant is authorized with only the platform profile, and refused with PERMISSION_DENIED once an unreadable workspace profile shadows it. I tested that step rather than the full RPC because the full RPC needs a signed sandbox session and a persisted session lineage.

warn_incompatible_profile(&name, &reason);
incompatible.push((name, resource_version));
}
Err(error) => {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🤖 should-fix 🟡 – An unreadable endpoint can still take down the whole catalog. decode_record runs legacy_time_wire::migrate before the profile scanner. A group inside an endpoint fails migration as PersistenceError::Decode and takes this branch, so unrelated sandboxes get INTERNAL. Classify unscannable raw endpoint bytes before migration and extend the isolation test to cover this path.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 6ac8a47. decode_record now scans provider-profile endpoints on the raw row before legacy migration. Endpoints contain no messages the time-field migration rewrites, so the raw and migrated scans agree. An endpoint group now surfaces as UnknownFields and stays isolated to its profile. The isolation test runs both an unknown endpoint field and an endpoint group, and checks that an unrelated sandbox still builds.

// Read the row without decoding it: a profile this build cannot read
// safely (RFC 0027) must still be removable.
let existing = state
.store

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🤖 should-fix 🟡 – Raw lookup makes an unused incompatible profile deletable, but an in-use profile still cannot be repaired in place. profile_update_target_diagnostics and handle_update_provider_profiles both decode the old profile and return INTERNAL, even for a full compatible replacement with the correct resource version. Read the row metadata independently and retain the existing version check on replacement.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 6ac8a47. stored_profile_metadata reads only StoredProviderProfile.metadata (tag 1) from the raw row, migrates and decodes that, and takes the resource version from the row. profile_update_target_diagnostics and handle_update_provider_profiles use it, so a compatible full replacement can repair an unreadable profile, and the MatchResourceVersion check is unchanged. unreadable_custom_profile_can_be_replaced_in_place checks that a stale version gets ABORTED, the correct version repairs the profile, and labels and the ID are kept.

Address the second round of RFC 0027 review feedback:

- Startup preflight sets aside a sandbox whose stored policy or provider
  profile this gateway cannot read, instead of failing run_server.
  Delivery still refuses it. Such refusals now carry ErrorInfo reason
  UNKNOWN_PROTOBUF_FIELD so callers can tell them apart.
- Scoped profile resolution enforces incompatibility itself, so an
  unreadable workspace profile never falls back to a same-ID platform
  profile, including for brokered token grants.
- Provider profile endpoints are scanned before legacy migration, so an
  unreadable endpoint, such as one with a group, stays isolated to that
  profile instead of failing the whole catalog.
- UpdateProviderProfiles reads only the stored metadata and row version,
  so a compatible full replacement can repair an unreadable profile in
  place while keeping the version check.

Refs #6097

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>

let raw = hex::decode(encoded)
.map_err(|e| Status::internal(format!("global policy decode failed: {e}")))?;
crate::wire_validation::stored::require_known_stored_policy(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🤖 blocking 🔴 – An incompatible global policy still prevents gateway startup. validate_provider_composition_startup_preflight decodes the global override to decide whether composition is enabled. This rejection reaches run_server before it can serve repair requests. Treat the incompatible override as present for preflight, keep refusing configuration delivery, and test that a compatible replacement restores delivery.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in a867864. provider_policy_composition_enabled now treats a global policy this gateway cannot read as a present global override (composition off), so neither the startup preflight nor profile changes fail on it. Configuration delivery still refuses it. unreadable_global_policy_starts_the_gateway_and_can_be_replaced stores an unreadable global policy, runs the preflight, checks that delivery is refused, replaces the policy through UpdateConfig with global: true, and checks that delivery recovers. I also checked the other startup step, endpoint-status reconciliation: it does not decode policies.

.await
.unwrap()
.unwrap()
.resource_version;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🤖 should-fix 🟡 – This test gets the repair version directly from the store. Operators get it through GetProviderProfile or CLI export. An unreadable workspace profile is absent from that lookup, so export returns NOT_FOUND or the same-ID platform profile and its version. Return the incompatibility with the affected row’s resource version and exercise repair using only public RPCs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in a867864. IncompatibleProfile now records its row resource version. GetProviderProfile calls require_compatible_profile for the requested scope before the catalog lookup, so an unreadable profile is reported with UNKNOWN_PROTOBUF_FIELD, resource_version in ErrorInfo metadata, and the version in the message, never NOT_FOUND or the same-ID platform profile. The repair test now uses public RPCs only, with a same-ID platform profile present: GetProviderProfile (refused, with version), LintProviderProfiles, UpdateProviderProfiles with that version (a stale version gets ABORTED), then GetProviderProfile returns the repaired workspace profile. The CLI shows the message, which includes the version; it does not yet parse the metadata itself.

.get_message_by_name::<StoredProviderProfile>(workspace, target_id)
.await
.map_err(|e| Status::internal(format!("fetch provider profile failed: {e}")))?
if stored_profile_metadata(store, workspace, target_id)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🤖 should-fix 🟡 – A CLI update containing a stable_placeholder credential calls LintProviderProfiles before the update RPC. Its profile_conflict_diagnostics still does a typed read to check existence, so an unreadable existing profile returns INTERNAL even with the correct version and a compatible replacement. Use a metadata-only existence check there too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in a867864. Both existence checks in profile_conflict_diagnostics use stored_profile_metadata. The repair test calls LintProviderProfiles with the replacement and gets the normal "already exists" diagnostic instead of INTERNAL.

.await
{
Ok(policy) => policy,
Err(error) if crate::wire_validation::stored::is_incompatible(&error) => {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🤖 should-fix 🟡 – The same isolation is missing in profile_attached_sandbox_diagnostics. It reads each sandbox’s base policy before checking whether any attached provider uses the profile being changed. An unreadable policy on an unrelated sandbox can block every platform profile import or update. Identify affected sandboxes before loading their policies and retain validation for actual dependents.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in a867864. profile_attached_sandbox_diagnostics now fetches a sandbox's providers first and skips the sandbox before loading its base policy unless a provider uses a changed profile, which is the condition the old imported_profiles_used.is_empty() check applied after the load. unreadable_policy_blocks_only_profile_changes_its_sandbox_depends_on checks that a platform import succeeds beside an unrelated sandbox with an unreadable policy, while an import a dependent sandbox uses is still refused with the incompatibility.

Address the third round of RFC 0027 review feedback:

- An unreadable global policy counts as a global override, so provider
  composition is treated as off. Startup and profile changes no longer
  fail on it, delivery still refuses it, and a compatible UpdateConfig
  replacement restores delivery.
- GetProviderProfile reports an unreadable profile in the requested
  scope with its row resource_version in ErrorInfo metadata and the
  message, instead of NOT_FOUND or a same-ID platform profile. Operators
  can repair it using public RPCs alone.
- LintProviderProfiles checks profile existence from stored metadata
  only, so linting a replacement for an unreadable profile works.
- Profile change diagnostics load a sandbox's base policy only when the
  sandbox uses a changed profile, so an unrelated unreadable policy no
  longer blocks platform profile imports or updates.

Refs #6097

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:platform SDKs, CLIs, APIs, gateway infrastructure, persistence, configuration, and session management. state:accepted A maintainer decided OpenShell should pursue this issue topic:api Public APIs, gRPC/protobuf, SDK interfaces, versioning, compatibility, and API design standards. topic:policy Policy authoring, validation, proving, distribution, enforcement, ergonomics, and hardening. topic:security Vulnerability management, security analysis/auditing, bypass detection, and abuse prevention.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant