Skip to content

Commit 9243c01

Browse files
committed
feat(policy): manage approval mode via settings; reject _provider_ aliasing
Move proposal_approval_mode out of SandboxSpec and into the existing runtime-mutable settings model so it can be flipped on a running sandbox and pinned fleet-wide via gateway scope. Precedence matches the rest of the settings model: gateway wins over sandbox, default is manual. The CLI's --approval-mode flag on `sandbox create` is now a shorthand that writes the sandbox-scoped setting post-create. Auto-approval audit events carry resolved_from=<gateway|sandbox|default>. Reject agent proposals whose rule_name starts with `_provider_`. That namespace is reserved for provider-profile-synthesized rules; allowing agents to address them by name would bypass the merge guard that splits agent contributions into their own rule so the prover sees them honestly. Refs #1097
1 parent 3aa0d07 commit 9243c01

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

‎crates/openshell-ocsf/src/format/shorthand.rs‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ impl OcsfEvent {
319319
push("auto");
320320
push("source");
321321
push("prover_delta");
322+
push("resolved_from");
322323
if let Some(ver) = u.get("policy_version").and_then(|v| v.as_str()) {
323324
parts.push(format!("version:{ver}"));
324325
}
@@ -847,6 +848,37 @@ mod tests {
847848
);
848849
}
849850

851+
/// Auto-approval audit events carry `auto`, `source`, `prover_delta`, and
852+
/// `resolved_from` as unmapped fields. Lock the suffix order so operators
853+
/// (and the demo's grep) can rely on it.
854+
#[test]
855+
fn test_config_state_change_shorthand_includes_auto_approve_fields() {
856+
let mut b = base(5019, "Device Config State Change", 5, "Discovery", 1, "Log");
857+
b.set_message("auto-approved: no new prover findings (source=agent_authored)");
858+
b.add_unmapped("auto", serde_json::json!("true"));
859+
b.add_unmapped("source", serde_json::json!("agent_authored"));
860+
b.add_unmapped("prover_delta", serde_json::json!("empty"));
861+
b.add_unmapped("resolved_from", serde_json::json!("sandbox"));
862+
b.add_unmapped("policy_version", serde_json::json!("v4"));
863+
b.add_unmapped("policy_hash", serde_json::json!("sha256:cafe"));
864+
865+
let event = OcsfEvent::DeviceConfigStateChange(DeviceConfigStateChangeEvent {
866+
base: b,
867+
state: Some(StateId::Other),
868+
state_custom_label: Some("APPROVED".to_string()),
869+
security_level: None,
870+
prev_security_level: None,
871+
});
872+
873+
let shorthand = event.format_shorthand();
874+
assert_eq!(
875+
shorthand,
876+
"CONFIG:APPROVED [INFO] auto-approved: no new prover findings (source=agent_authored) \
877+
[auto:true source:agent_authored prover_delta:empty resolved_from:sandbox \
878+
version:v4 hash:sha256:cafe]"
879+
);
880+
}
881+
850882
#[test]
851883
fn test_base_event_shorthand() {
852884
let mut b = base(0, "Base Event", 0, "Uncategorized", 99, "Other");

‎crates/openshell-server/src/grpc/policy.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,7 @@ async fn auto_approve_chunk(
873873
sandbox_id,
874874
sandbox_name,
875875
format!(
876-
"auto-approved: no new prover findings (source={source_label}, resolved_from={resolved_from}) — chunk {chunk_id}: {chunk_summary}"
876+
"auto-approved: no new prover findings (source={source_label}) — chunk {chunk_id}: {chunk_summary}"
877877
),
878878
version,
879879
&hash,

0 commit comments

Comments
 (0)