Skip to content

Commit 48984e0

Browse files
committed
fix(evidence): separate host and process environments
1 parent 183f5f5 commit 48984e0

2 files changed

Lines changed: 59 additions & 21 deletions

File tree

‎src/evidence/registry.rs‎

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
use super::adapter_signal::{AdapterBoundarySignal, adapter_boundary_signal_from_process_output};
44
use super::model::{
5-
AttemptStatus, CapabilityAvailability, CapabilityAvailabilityStatus, EnvironmentBinding,
6-
EvidenceId, NamespacedIdentifier, ObservedPayloadContract, PayloadSchemaBinding,
7-
PermissionState, ProbeCheck, ProbeResult, ProcessExecutionContract, ProvenanceSourceKind,
8-
STRUCTURED_OBSERVATION_RESULTS_V2, STRUCTURED_OBSERVATION_RESULTS_V2_SCHEMA_REF, SchemaVersion,
9-
Sha256Digest, VerificationCapabilityInstance, VerificationCapabilityManifest,
5+
AdapterKind, AttemptStatus, CapabilityAvailability, CapabilityAvailabilityStatus,
6+
EnvironmentBinding, EvidenceId, NamespacedIdentifier, ObservedPayloadContract,
7+
PayloadSchemaBinding, PermissionState, ProbeCheck, ProbeResult, ProcessExecutionContract,
8+
ProvenanceSourceKind, STRUCTURED_OBSERVATION_RESULTS_V2,
9+
STRUCTURED_OBSERVATION_RESULTS_V2_SCHEMA_REF, SchemaVersion, Sha256Digest,
10+
VerificationCapabilityInstance, VerificationCapabilityManifest,
1011
};
1112
use crate::canonical_json::{sha256_json_digest, sha256_prefixed_bytes};
1213
use crate::execution::{BoundedProcessInput, CancellationToken, run_bounded_process};
@@ -1058,6 +1059,9 @@ pub(crate) fn capture_manifest_adapter_environment(
10581059
fn manifest_adapter_environment_names(
10591060
manifest: &VerificationCapabilityManifest,
10601061
) -> Result<Vec<String>> {
1062+
if manifest.adapter_kind != AdapterKind::Process {
1063+
return Ok(Vec::new());
1064+
}
10611065
let names = manifest
10621066
.permissions
10631067
.get("environment")
@@ -3551,6 +3555,28 @@ mod tests {
35513555
);
35523556
}
35533557

3558+
#[test]
3559+
fn only_process_manifests_declare_forwarded_adapter_environment() {
3560+
let mut host_manifest = manifest_value("cargo", vec!["--version"], 1024);
3561+
host_manifest["adapter_kind"] = json!("host");
3562+
host_manifest["permissions"]["environment"] = json!("Chrome extension browser client");
3563+
let host_manifest = manifest(host_manifest);
3564+
3565+
validate_manifest_runtime_permissions(&host_manifest).unwrap();
3566+
let captured = capture_manifest_adapter_environment(&host_manifest).unwrap();
3567+
assert!(captured.values.is_empty());
3568+
assert!(captured.durable_output_redactions.is_empty());
3569+
assert_eq!(captured.binding["names"], json!([]));
3570+
assert_eq!(captured.binding["public_names"], json!([]));
3571+
3572+
let mut process_manifest = manifest_value("cargo", vec!["--version"], 1024);
3573+
process_manifest["permissions"]["environment"] = json!("Chrome extension browser client");
3574+
let error = validate_manifest_runtime_permissions(&manifest(process_manifest))
3575+
.unwrap_err()
3576+
.to_string();
3577+
assert!(error.contains("must use read_env:"), "{error}");
3578+
}
3579+
35543580
#[cfg(unix)]
35553581
#[test]
35563582
fn registry_forwards_only_declared_adapter_environment_and_binds_value_drift() {

‎tests/e2e.rs‎

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5654,7 +5654,7 @@ fn evidence_public_surfaces_share_canonical_service_and_status_codes() {
56545654
}
56555655

56565656
#[test]
5657-
fn evidence_process_adapter_semantic_mismatch_does_not_satisfy_coverage() {
5657+
fn evidence_process_adapter_product_mismatch_routes_finding_without_coverage() {
56585658
let planr_binary_dir = tempdir().unwrap();
56595659
let planr_binary = private_planr_binary(planr_binary_dir.path());
56605660
let planr = || planr_from_binary(&planr_binary);
@@ -5855,28 +5855,39 @@ fn evidence_process_adapter_semantic_mismatch_does_not_satisfy_coverage() {
58555855
let result = &run["object"]["results"][0];
58565856
assert_eq!(result["attempt"]["status"], "failed");
58575857
assert_eq!(
5858-
result["attempt"]["raw_result"]["ordinary_observation_error"],
5859-
json!(
5860-
"ordinary process actual does not satisfy expected predicate for obs-pob-semantic-mismatch"
5861-
)
5858+
result["attempt"]["raw_result"]["ordinary_observation_failed_requirement_ids"],
5859+
json!(["obs-pob-semantic-mismatch"])
5860+
);
5861+
assert!(
5862+
result["attempt"]["raw_result"]
5863+
.get("planr_adapter_gap_reasons")
5864+
.is_none(),
5865+
"{run}"
58625866
);
5867+
let semantic_actual = &result["receipt"]["observations"][0]["actual"];
5868+
assert_eq!(semantic_actual["status"], "ok");
58635869
assert_eq!(
5864-
result["attempt"]["raw_result"]["planr_adapter_gap_reasons"],
5865-
json!(["target_mismatch"])
5870+
semantic_actual["schema_ref"],
5871+
"schema://com.example.health.status"
58665872
);
5867-
let semantic_actual: Value = serde_json::from_str(
5868-
result["receipt"]["observations"][0]["actual"]["stdout_excerpt"]
5869-
.as_str()
5870-
.unwrap(),
5871-
)
5872-
.unwrap();
5873-
assert_eq!(semantic_actual, json!({"status": "ok"}));
58745873
assert_eq!(
58755874
result["receipt"]["observations"][0]["predicate"],
58765875
json!({"status": "missing"})
58775876
);
58785877
assert_eq!(result["receipt"]["observations"][0]["outcome"], "failed");
5879-
assert_eq!(result["receipt"]["proof_gaps"], json!(["target_mismatch"]));
5878+
assert_eq!(result["receipt"]["proof_gaps"], json!([]));
5879+
assert_eq!(
5880+
result["product_finding"]["classification"],
5881+
"product_finding"
5882+
);
5883+
assert_eq!(
5884+
result["product_finding"]["selective_replay_obligation_ids"],
5885+
json!(["pob-semantic-mismatch"])
5886+
);
5887+
assert_eq!(
5888+
result["product_finding"]["next"],
5889+
"maker_repair_then_plan_readiness_refreeze"
5890+
);
58805891

58815892
let coverage = single_json_document(
58825893
&planr()
@@ -5901,7 +5912,8 @@ fn evidence_process_adapter_semantic_mismatch_does_not_satisfy_coverage() {
59015912
assert_eq!(coverage["object"]["verdict"], "unsatisfied");
59025913
assert_eq!(
59035914
coverage["object"]["coverage"]["observation_coverage"][0]["gap_reason"],
5904-
"target_mismatch"
5915+
"missing_observation",
5916+
"{coverage}"
59055917
);
59065918
assert!(
59075919
coverage["object"]["coverage"]["observation_coverage"][0]["covering_receipt_ids"]

0 commit comments

Comments
 (0)