Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ To move to 1.0, read the [migration guide](docs/site/migration/to-1-0.md).
- The OSCAL structural validator is bound through `standards.lock` as the `oscal-1.1.0-structural` oracle, the `oscal` profile of `prismpm oracle` (#209, SPEC §10.1). Acceptance is JSON structural validity only, not control implementation or whole-standard conformance.

### Breaking Changes

- `prismpm::holo::canonical::{encode_canonical, decode_canonical}` moved to `prismpm::holo::model_document`, since they validate the model document and the canonical value codec stays in `errors` (#448).
- `CanonicalDocument::parse` and `from_value` refuse the 19 contracts whose semantic checks belong to another module (SDK locks, acceptance records, browser receipts, native-library evidence, model documents) with PP9001. Parse them with the owner's `parse_contract`/`contract_from_value` (for example `prismpm::sdk::contract_from_value`), or with `prismpm::contract_owners::{parse, from_value}` when you hold only the id. The checks themselves are unchanged (#448, #449).
- `prism-code check` without a holo is removed (#584). It was the 0.2.0 spelling of `build --check`, announced as removed in 0.4.0 but still running through 0.7.2 with a warning that named that version. It is now a usage error (exit 64) that names `prism-code build --check`. Migration: replace `prism-code check [args]` with `prism-code build --check [args]`.
- `prismpm export-browser` and `verify-browser-publication` return `prismpm/browser-export/2` and `prismpm/browser-publication-integrity/2`, whose file lists hold exactly closure v1 (six files) or closure v2 (sixteen). Releases built now export sixteen files, so a consumer that pins the six-file closure or a `/1` receipt, such as a Pages publication contract, must move to closure v2. The `/1` contracts stay registered.
- A plain `prismpm build` of an application now needs a `prismpm/sdk-lock/2` or `/3` lock, because the provenance statement is derived from it (#268). An absent or `/1` lock is refused with `PP3018` before compiling; bind the SDK with `prismpm update --toolchain <digest-ref>`, migrate the lock, or pass `--no-provenance`.
Expand All @@ -64,6 +67,8 @@ To move to 1.0, read the [migration guide](docs/site/migration/to-1-0.md).
- A `VerificationError` with no verdict that reaches the top of `prism-code` exits 2 instead of 1 (#348), such as `attest` on a holo whose footer does not verify. `check` keeps 0, 1 and 2 unchanged.

### Other Changes

- Module cuts for the nine modules (#448, #449): each contract's semantic check moved from `contracts` to the module that owns it, the SDK advisory disposition moved from `supply_chain` to `sdk/advisory.rs` (verify), and OCI reference syntax moved from `oci` to `reference.rs` (verify). `oci` and `supply_chain` re-export what moved. `cargo xtask check-modules` now holds 3 pending cuts instead of 15, and `contracts` and `workbench` have left the old cycle.
- The spec digest in `prismpm/sdk-lock/3` covers `intent.md` in place of the `intent/` directory reserved by #264, and the lock gains an optional `authoring` record. A lock with that record needs an SDK image built from this change.

## [0.4.0] - 2026-10-27
Expand Down
11 changes: 5 additions & 6 deletions crates/conformance/src/bin/prismpm-conformance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,11 @@ fn run() -> Result<Vec<u8>, Box<dyn std::error::Error>> {
"sdk_digest":arguments.sdk_digest,
"status":if complete { "accepted" } else { "passed" }
});
Ok(prismpm::contracts::CanonicalDocument::from_value(
"prismpm/production-acceptance/1",
transcript,
)?
.bytes()
.to_vec())
Ok(
prismpm::acceptance::contract_from_value("prismpm/production-acceptance/1", transcript)?
.bytes()
.to_vec(),
)
}

fn main() -> std::process::ExitCode {
Expand Down
62 changes: 19 additions & 43 deletions crates/conformance/src/cases/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1469,20 +1469,14 @@ fn verify_sdk(id: &str) {
let value = serde_json::json!({"schema":"prismpm/sdk-lock/2", "sdk_version":"0.3.0",
"sdk_image":format!("ghcr.io/uor-foundation/prismpm-sdk@sha256:{}", sha256(index.as_bytes())),
"sdk_index":index, "standards_lock":lock.value()["standards_lock"], "platforms":platforms});
let indexed = prismpm::contracts::CanonicalDocument::from_value(
"prismpm/sdk-lock/2",
value.clone(),
)
.unwrap();
let indexed =
prismpm::sdk::contract_from_value("prismpm/sdk-lock/2", value.clone()).unwrap();
let migration = serde_json::json!({"schema":"prismpm/sdk-lock-migration/1",
"patch":[{"op":"test","path":"","value":lock.value()},
{"op":"replace","path":"","value":value}],
"compatibility_review":"required", "generated_output_diff":"required", "security_review":"required"});
prismpm::contracts::CanonicalDocument::from_value(
"prismpm/sdk-lock-migration/1",
migration.clone(),
)
.unwrap();
prismpm::sdk::contract_from_value("prismpm/sdk-lock-migration/1", migration.clone())
.unwrap();
for mutation in 0..4 {
let mut rejected = migration.clone();
match mutation {
Expand All @@ -1491,7 +1485,7 @@ fn verify_sdk(id: &str) {
2 => rejected["patch"].as_array_mut().unwrap().reverse(),
_ => rejected["patch"][1]["path"] = serde_json::json!("/sdk_image"),
}
assert!(prismpm::contracts::CanonicalDocument::from_value(
assert!(prismpm::sdk::contract_from_value(
"prismpm/sdk-lock-migration/1",
rejected,
)
Expand All @@ -1500,18 +1494,14 @@ fn verify_sdk(id: &str) {
let proposal = serde_json::json!({"schema":"prismpm/sdk-lock-update/2",
"changes":[], "proposed_lock":value,
"compatibility_review":"required", "generated_output_diff":"required", "security_review":"required"});
prismpm::contracts::CanonicalDocument::from_value(
"prismpm/sdk-lock-update/2",
proposal.clone(),
)
.unwrap();
prismpm::sdk::contract_from_value("prismpm/sdk-lock-update/2", proposal.clone())
.unwrap();
let mut unreviewed = proposal;
unreviewed["security_review"] = serde_json::json!("passed");
assert!(prismpm::contracts::CanonicalDocument::from_value(
"prismpm/sdk-lock-update/2",
unreviewed,
)
.is_err());
assert!(
prismpm::sdk::contract_from_value("prismpm/sdk-lock-update/2", unreviewed,)
.is_err()
);
for (position, platform) in ["linux/amd64", "linux/arm64"].into_iter().enumerate() {
prismpm::sdk::validate_running_inventory(
&indexed,
Expand All @@ -1528,19 +1518,11 @@ fn verify_sdk(id: &str) {
}
let mut missing = value.clone();
missing["platforms"].as_array_mut().unwrap().pop();
assert!(prismpm::contracts::CanonicalDocument::from_value(
"prismpm/sdk-lock/2",
missing
)
.is_err());
assert!(prismpm::sdk::contract_from_value("prismpm/sdk-lock/2", missing).is_err());
let mut swapped = value.clone();
swapped["platforms"][0]["manifest_digest"] =
value["platforms"][1]["manifest_digest"].clone();
assert!(prismpm::contracts::CanonicalDocument::from_value(
"prismpm/sdk-lock/2",
swapped
)
.is_err());
assert!(prismpm::sdk::contract_from_value("prismpm/sdk-lock/2", swapped).is_err());
}
"DK-02" => {
let lock = sdk_lock_value();
Expand Down Expand Up @@ -2155,11 +2137,8 @@ fn verify_browser_export(root: &Path) {
"tree_digest":tree_digest
})
);
let document = prismpm::contracts::CanonicalDocument::from_value(
"prismpm/browser-export/1",
receipt.clone(),
)
.unwrap();
let document =
prismpm::oci::contract_from_value("prismpm/browser-export/1", receipt.clone()).unwrap();
assert_eq!(
document.bytes(),
prismpm::holo::canonical::encode_value(&receipt).unwrap()
Expand Down Expand Up @@ -3670,16 +3649,13 @@ fn verify_holo(root: &Path, id: &str) {
}
let value = json(&root.join("tests/data/text-model-document.json"));
let document: prismpm::holo::ModelDocument = serde_json::from_value(value.clone()).unwrap();
let bytes = prismpm::holo::canonical::encode_canonical(&document).unwrap();
let bytes = prismpm::holo::model_document::encode_canonical(&document).unwrap();
assert_eq!(
prismpm::holo::canonical::decode_canonical(&bytes).unwrap(),
prismpm::holo::model_document::decode_canonical(&bytes).unwrap(),
document
);
prismpm::contracts::CanonicalDocument::from_value(
"prismpm/model-document/2",
value.clone(),
)
.unwrap();
prismpm::model_contract::contract_from_value("prismpm/model-document/2", value.clone())
.unwrap();
for (pointer, replacement, code) in [
(
"/schema",
Expand Down
4 changes: 2 additions & 2 deletions crates/conformance/src/cases/native_library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ fn accepted(root: &Path, project: &Path, verified: &prismpm::controller::VerifyR
phases[1]["processes"][2]["exporter"]
);
assert_eq!(phases[1]["processes"], json!(&processes[5..9]));
prismpm::contracts::CanonicalDocument::from_value(
prismpm::contract_owners::from_value(
"prismpm/library-verification-manifest/2",
manifest.clone(),
)
Expand Down Expand Up @@ -228,7 +228,7 @@ fn accepted(root: &Path, project: &Path, verified: &prismpm::controller::VerifyR
let mut changed = manifest.clone();
*changed.pointer_mut(pointer).unwrap() = replacement;
assert!(
prismpm::contracts::CanonicalDocument::from_value(
prismpm::contract_owners::from_value(
"prismpm/library-verification-manifest/2",
changed,
)
Expand Down
4 changes: 2 additions & 2 deletions crates/conformance/src/fixtures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,10 @@ pub fn check(dir: &Path) -> Result<(), Box<dyn std::error::Error>> {
if case.command == "holo-noncanonical" {
let mut malformed = bytes;
malformed.insert(1, b' ');
return prismpm::holo::canonical::decode_canonical(&malformed)
return prismpm::holo::model_document::decode_canonical(&malformed)
.map(|_| Vec::new());
}
let mut holo = prismpm::holo::canonical::decode_canonical(&bytes)?;
let mut holo = prismpm::holo::model_document::decode_canonical(&bytes)?;
if case.command == "holo-dangling-edge" {
let count = holo.architecture.components.len() as u64;
holo.architecture
Expand Down
2 changes: 1 addition & 1 deletion crates/conformance/src/golden.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ fn validate(files: &[(String, Vec<u8>)]) -> Result<(Value, Value, Value), String
"golden build closure differs",
)?;
let model_bytes = file(&files, "build/model.prism.json")?;
let model = prismpm::holo::canonical::decode_canonical(model_bytes)
let model = prismpm::holo::model_document::decode_canonical(model_bytes)
.map_err(|error| error.to_string())?;
ensure(
golden["compiler_semantics_id"] == model.provenance.compiler_semantics_id
Expand Down
74 changes: 58 additions & 16 deletions crates/prismpm/src/acceptance.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Digest-bound closure of executed production acceptance evidence.

use crate::contracts::CanonicalDocument;
use crate::contracts::{strictly_ordered, CanonicalDocument, OwnerCheck};
use crate::error::PrismError;
use crate::oci::{self, PRISM_PRODUCTION_ACCEPTANCE};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -66,6 +66,52 @@ pub(crate) fn verify_closure(value: &Value) -> Result<(), PrismError> {
verify_transcript(value)
}

/// The semantic checks of the acceptance contracts, which this module owns.
const CONTRACT_CHECK: OwnerCheck = OwnerCheck {
owner: "acceptance",
check: check_contract,
};

fn check_contract(id: &str, value: &Value) -> Result<(), PrismError> {
match id {
"prismpm/production-acceptance/1" => {
verify_transcript(value)?;
let rows = value["cases"].as_array().expect("schema-validated array");
if !strictly_ordered(rows, |row| match row["kind"].as_str()? {
"feature" => Some(format!("0/{}", row["feature_id"].as_str()?)),
"diagnostic" => Some(format!("1/{}", row["diagnostic"].as_str()?)),
_ => None,
}) {
return Err(PrismError::new(
"PP1101",
"production acceptance cases are duplicate or noncanonical",
));
}
Ok(())
}
"prismpm/conformance-result/1" => verify_result_counts(value),
_ => Err(PrismError::new(
"PP9001",
format!("acceptance owns no semantic check for {id}"),
)),
}
}

/// Validate an acceptance contract value, including the transcript and count
/// rules this module owns.
pub fn contract_from_value(
id: &'static str,
value: Value,
) -> Result<CanonicalDocument, PrismError> {
CanonicalDocument::from_value_owned(id, value, CONTRACT_CHECK)
}

/// Validate exact canonical acceptance contract bytes, including the rules
/// this module owns.
pub fn parse_contract(id: &'static str, bytes: &[u8]) -> Result<CanonicalDocument, PrismError> {
CanonicalDocument::parse_owned(id, bytes, CONTRACT_CHECK)
}

pub(crate) fn verify_transcript(value: &Value) -> Result<(), PrismError> {
let features = registered_values(include_str!("../model/ids.toml"), "id", "id")?;
let diagnostics = registered_values(include_str!("../model/errors.toml"), "error", "code")?;
Expand Down Expand Up @@ -310,7 +356,7 @@ pub(crate) fn attach(root: &Path, reference: &str, input: &Path) -> Result<Value
let digest = release_digest(reference)?;
let bytes = std::fs::read(input)
.map_err(|error| PrismError::new("PP6002", format!("acceptance evidence: {error}")))?;
let document = CanonicalDocument::parse("prismpm/production-acceptance/1", &bytes)?;
let document = parse_contract("prismpm/production-acceptance/1", &bytes)?;
let (descriptor, sdk_digest) = attach_document(root, digest, &document)?;
Ok(json!({
"acceptance_digest": sha(document.bytes()),
Expand All @@ -331,7 +377,7 @@ fn result_document(
path: &str,
) -> Result<Value, PrismError> {
verify_closure(transcript.value())?;
CanonicalDocument::from_value(
contract_from_value(
"prismpm/conformance-result/1",
json!({
"diagnostic_count":transcript.value()["diagnostic_count"],
Expand Down Expand Up @@ -392,7 +438,7 @@ pub(crate) fn run(root: &Path, reference: &str) -> Result<Value, PrismError> {
.strip_suffix('\n')
.unwrap_or(&record.stdout)
.as_bytes();
let document = CanonicalDocument::parse("prismpm/production-acceptance/1", bytes)?;
let document = parse_contract("prismpm/production-acceptance/1", bytes)?;
let expected_runner = format!("sha256:{}", record.executable_sha256);
if document.value()["runner_digest"].as_str() != Some(expected_runner.as_str()) {
return Err(PrismError::new(
Expand Down Expand Up @@ -1286,8 +1332,8 @@ pub fn validate_ecosystem_release_closure(

#[cfg(test)]
mod tests {
use super::contract_from_value;
use super::{registered_values, result_document, verify_closure};
use crate::contracts::CanonicalDocument;
use serde_json::{json, Value};

#[test]
Expand Down Expand Up @@ -1355,7 +1401,7 @@ mod tests {
fn exact_feature_and_diagnostic_closure_is_required() {
let value = complete();
verify_closure(&value).unwrap();
CanonicalDocument::from_value("prismpm/production-acceptance/1", value.clone()).unwrap();
contract_from_value("prismpm/production-acceptance/1", value.clone()).unwrap();
let mut missing = value;
missing["cases"].as_array_mut().unwrap().pop();
assert_eq!(
Expand All @@ -1380,8 +1426,7 @@ mod tests {
.iter()
.any(|row| row["diagnostic"] == "PP2009"));
let transcript =
CanonicalDocument::from_value("prismpm/production-acceptance/1", value.clone())
.unwrap();
contract_from_value("prismpm/production-acceptance/1", value.clone()).unwrap();
let digest = "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
let result = result_document(
&transcript,
Expand All @@ -1398,7 +1443,7 @@ mod tests {
let mut stale = result.clone();
stale[field] = json!(stale[field].as_u64().unwrap() - 1);
assert_eq!(
CanonicalDocument::from_value("prismpm/conformance-result/1", stale)
contract_from_value("prismpm/conformance-result/1", stale)
.unwrap_err()
.code,
"PP6002"
Expand All @@ -1421,7 +1466,7 @@ mod tests {
missing[count] = json!(missing[count].as_u64().unwrap() - 1);
assert_eq!(verify_closure(&missing).unwrap_err().code, "PP6002");
assert_eq!(
CanonicalDocument::from_value("prismpm/production-acceptance/1", missing)
contract_from_value("prismpm/production-acceptance/1", missing)
.unwrap_err()
.code,
"PP6002"
Expand All @@ -1439,8 +1484,7 @@ mod tests {
.retain(|row| row["feature_id"] != "HO-11");
value["feature_count"] = json!(value["feature_count"].as_u64().unwrap() - 1);
let transcript =
CanonicalDocument::from_value("prismpm/production-acceptance/1", value.clone())
.unwrap();
contract_from_value("prismpm/production-acceptance/1", value.clone()).unwrap();
assert_eq!(verify_closure(&value).unwrap_err().code, "PP6002");
let digest = "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
assert_eq!(
Expand All @@ -1466,14 +1510,12 @@ mod tests {
] {
let mut bad = value.clone();
*bad.pointer_mut(pointer).unwrap() = replacement;
assert!(CanonicalDocument::from_value("prismpm/production-acceptance/1", bad).is_err());
assert!(contract_from_value("prismpm/production-acceptance/1", bad).is_err());
}
let mut duplicate = value;
let row = duplicate["cases"][0].clone();
duplicate["cases"].as_array_mut().unwrap().insert(0, row);
duplicate["feature_count"] = json!(duplicate["feature_count"].as_u64().unwrap() + 1);
assert!(
CanonicalDocument::from_value("prismpm/production-acceptance/1", duplicate).is_err()
);
assert!(contract_from_value("prismpm/production-acceptance/1", duplicate).is_err());
}
}
Loading
Loading