commit f6237db0d0013ef1771eb30d1d3fd623411c6ba3
parent 1e1dbc3f58fefd819ba306effb64440ab2d993f7
Author: triesap <tyson@radroots.org>
Date: Tue, 6 Oct 2026 03:24:32 +0000
test: Execute shared Food cases through the native codec
- Consume the checked manifest with the exact pinned public Rust APIs.
- Verify 66 actual cases and reject missing, corrupt and mismatched inputs.
- Define timestamp and raw identifier boundaries with explicit JavaScript limits.
- Preserve production dependencies and keep combined orchestration pending.
Diffstat:
8 files changed, 1513 insertions(+), 68 deletions(-)
diff --git a/contracts/interop/food_availability/numeric_boundaries.v1.json b/contracts/interop/food_availability/numeric_boundaries.v1.json
@@ -0,0 +1,168 @@
+{
+ "schema_version": 1,
+ "profile": "food_availability_profile",
+ "contract_version": "1.0.0",
+ "revision": "189c49b74b4bafc142b00b76b296477931139e72",
+ "provenance": "Synthetic reviewed boundary recipes from actual pinned FoodPublishedAt/FoodIdentifier constructors and unsigned Food codec; no signed events, keys, operator data or independent protocol policy.",
+ "vectors": [
+ {
+ "id": "food_timestamp_zero_hcr014",
+ "kind": "timestamp",
+ "value": "0",
+ "expected": {
+ "native": {
+ "result": "rejected",
+ "code": "food_published_at_invalid"
+ },
+ "typescript": {
+ "result": "rejected",
+ "code": "timestamp_invalid"
+ }
+ }
+ },
+ {
+ "id": "food_timestamp_one_hcr014",
+ "kind": "timestamp",
+ "value": "1",
+ "expected": {
+ "native": {
+ "result": "accepted",
+ "timestamp": "1",
+ "encoded_published_at": "1"
+ },
+ "typescript": {
+ "result": "accepted",
+ "timestamp": "1",
+ "encoded_published_at": "1"
+ }
+ }
+ },
+ {
+ "id": "food_timestamp_safe_minus_one_hcr014",
+ "kind": "timestamp",
+ "value": "9007199254740990",
+ "expected": {
+ "native": {
+ "result": "accepted",
+ "timestamp": "9007199254740990",
+ "encoded_published_at": "9007199254740990"
+ },
+ "typescript": {
+ "result": "accepted",
+ "timestamp": "9007199254740990",
+ "encoded_published_at": "9007199254740990"
+ }
+ }
+ },
+ {
+ "id": "food_timestamp_safe_max_hcr014",
+ "kind": "timestamp",
+ "value": "9007199254740991",
+ "expected": {
+ "native": {
+ "result": "accepted",
+ "timestamp": "9007199254740991",
+ "encoded_published_at": "9007199254740991"
+ },
+ "typescript": {
+ "result": "accepted",
+ "timestamp": "9007199254740991",
+ "encoded_published_at": "9007199254740991"
+ }
+ }
+ },
+ {
+ "id": "food_timestamp_unsafe_first_hcr014",
+ "kind": "timestamp",
+ "value": "9007199254740992",
+ "expected": {
+ "native": {
+ "result": "accepted",
+ "timestamp": "9007199254740992",
+ "encoded_published_at": "9007199254740992"
+ },
+ "typescript": {
+ "result": "unsupported",
+ "reason": "Canonical timestamp exceeds Number.MAX_SAFE_INTEGER; current JavaScript adapter must reject it without rounding."
+ }
+ }
+ },
+ {
+ "id": "food_timestamp_unsafe_next_hcr014",
+ "kind": "timestamp",
+ "value": "9007199254740993",
+ "expected": {
+ "native": {
+ "result": "accepted",
+ "timestamp": "9007199254740993",
+ "encoded_published_at": "9007199254740993"
+ },
+ "typescript": {
+ "result": "unsupported",
+ "reason": "Canonical timestamp exceeds Number.MAX_SAFE_INTEGER; current JavaScript adapter must reject it without rounding."
+ }
+ }
+ },
+ {
+ "id": "food_timestamp_u64_max_hcr014",
+ "kind": "timestamp",
+ "value": "18446744073709551615",
+ "expected": {
+ "native": {
+ "result": "accepted",
+ "timestamp": "18446744073709551615",
+ "encoded_published_at": "18446744073709551615"
+ },
+ "typescript": {
+ "result": "unsupported",
+ "reason": "Canonical timestamp exceeds Number.MAX_SAFE_INTEGER; current JavaScript adapter must reject it without rounding."
+ }
+ }
+ },
+ {
+ "id": "food_timestamp_u64_overflow_hcr014",
+ "kind": "timestamp",
+ "value": "18446744073709551616",
+ "expected": {
+ "native": {
+ "result": "rejected",
+ "code": "food_published_at_invalid"
+ },
+ "typescript": {
+ "result": "unsupported",
+ "reason": "Canonical timestamp exceeds Number.MAX_SAFE_INTEGER; current JavaScript adapter must reject it without rounding."
+ }
+ }
+ },
+ {
+ "id": "food_raw_identifier_nfc_hcr014",
+ "kind": "identifier",
+ "value": "é",
+ "expected": {
+ "native": {
+ "result": "accepted",
+ "identifier": "é"
+ },
+ "typescript": {
+ "result": "accepted",
+ "identifier": "é"
+ }
+ }
+ },
+ {
+ "id": "food_raw_identifier_nfd_hcr014",
+ "kind": "identifier",
+ "value": "é",
+ "expected": {
+ "native": {
+ "result": "accepted",
+ "identifier": "é"
+ },
+ "typescript": {
+ "result": "accepted",
+ "identifier": "é"
+ }
+ }
+ }
+ ]
+}
diff --git a/contracts/interop/food_availability/oracle/tests/native_manifest.rs b/contracts/interop/food_availability/oracle/tests/native_manifest.rs
@@ -0,0 +1,406 @@
+// SPDX-License-Identifier: GPL-3.0-only
+// Native test consumer, using this existing target's exact public Lib189 graph.
+// No product engine, key, signing, network or parent documentation dependency.
+#![forbid(unsafe_code)]
+
+mod support;
+
+use radroots_blossom::Sha256;
+use radroots_event::wire::{EventWireError, Nip01EventWire};
+use radroots_event_codec::verify::verify_nip01_event;
+use serde_json::{Value, json};
+use std::{
+ collections::{BTreeMap, BTreeSet},
+ fs,
+ path::{Component, Path, PathBuf},
+};
+
+const REVISION: &str = "189c49b74b4bafc142b00b76b296477931139e72";
+const PROFILE: &str = "food_availability_profile";
+const FOOD: &str = "contracts/interop/food_availability/";
+const INPUTS: [&str; 11] = [
+ "contracts/interop/food_availability/corpus.v1.json",
+ "contracts/interop/food_availability/source_profile.v1.json",
+ "contracts/interop/food_availability/provenance.v1.json",
+ "contracts/interop/food_availability/oracle/src/main.rs",
+ "contracts/interop/food_availability/oracle/Cargo.toml",
+ "radroots.lib.source-lock.v1.toml",
+ "web/tests/conformance/food-writer-rust.v1.json",
+ "contracts/interop/food_availability/web_templates.v1.json",
+ "contracts/interop/food_availability/numeric_boundaries.v1.json",
+ "contracts/interop/food_availability/oracle/tests/native_manifest.rs",
+ "contracts/interop/food_availability/oracle/tests/support/mod.rs",
+];
+
+type Inputs = BTreeMap<String, Vec<u8>>;
+
+fn root() -> PathBuf {
+ Path::new(env!("CARGO_MANIFEST_DIR"))
+ .join("../../../..")
+ .canonicalize()
+ .unwrap()
+}
+
+fn bounded_read(base: &Path, name: &str) -> Result<Vec<u8>, String> {
+ let mut path = base.to_owned();
+ for component in Path::new(name).components() {
+ let Component::Normal(segment) = component else {
+ return Err("noncanonical fixture path".into());
+ };
+ path.push(segment);
+ if fs::symlink_metadata(&path)
+ .map_err(|error| error.to_string())?
+ .file_type()
+ .is_symlink()
+ {
+ return Err("fixture symlink rejected".into());
+ }
+ }
+ let metadata = fs::symlink_metadata(&path).map_err(|error| error.to_string())?;
+ if !metadata.is_file() || metadata.len() == 0 || metadata.len() > 1024 * 1024 {
+ return Err("fixture must be a bounded regular file".into());
+ }
+ let bytes = fs::read(path).map_err(|error| error.to_string())?;
+ if u64::try_from(bytes.len()).unwrap() != metadata.len() {
+ return Err("fixture changed during read".into());
+ }
+ Ok(bytes)
+}
+
+fn load() -> (Value, Inputs) {
+ let base = root();
+ let manifest =
+ serde_json::from_slice(&bounded_read(&base, "contracts/interop/manifest.json").unwrap())
+ .unwrap();
+ let inputs = INPUTS
+ .iter()
+ .map(|name| (name.to_string(), bounded_read(&base, name).unwrap()))
+ .collect();
+ (manifest, inputs)
+}
+
+fn required(condition: bool, message: &str) -> Result<(), String> {
+ if condition {
+ Ok(())
+ } else {
+ Err(message.into())
+ }
+}
+
+fn parse(inputs: &Inputs, name: &str) -> Result<Value, String> {
+ serde_json::from_slice(inputs.get(name).ok_or("missing input")?)
+ .map_err(|error| error.to_string())
+}
+
+fn descriptor(inputs: &Inputs, row: &Value) -> Result<(), String> {
+ let path = row["path"].as_str().ok_or("missing raw path")?;
+ let bytes = inputs.get(path).ok_or("undeclared raw path")?;
+ required(
+ row["sha256"] == Sha256::digest(bytes).to_hex(),
+ "raw hash mismatch",
+ )?;
+ required(
+ row["bytes"].as_u64() == Some(u64::try_from(bytes.len()).unwrap()),
+ "raw length mismatch",
+ )
+}
+
+fn consume(manifest: &Value, inputs: &Inputs, selected_profile: &str) -> Result<Value, String> {
+ required(
+ manifest["schema_version"] == 1
+ && manifest["qualification"] == "FIXTURE_ONLY_NOT_DEPLOYED_TERA"
+ && manifest["signing"] == "NOT_RUN_NO_KEYS",
+ "qualification metadata changed",
+ )?;
+ required(
+ manifest["oracle"]["revision"] == REVISION
+ && manifest["oracle"]["repository"] == "https://github.com/radrootslabs/lib",
+ "oracle identity changed",
+ )?;
+ let expected_inputs: BTreeSet<_> = INPUTS.iter().copied().collect();
+ required(
+ inputs.keys().map(String::as_str).collect::<BTreeSet<_>>() == expected_inputs,
+ "input membership changed",
+ )?;
+ let descriptors = manifest["inputs"]
+ .as_array()
+ .ok_or("missing input descriptors")?;
+ required(
+ descriptors.len() == INPUTS.len(),
+ "input descriptor count changed",
+ )?;
+ let paths = descriptors
+ .iter()
+ .map(|row| row["path"].as_str().ok_or("missing input path"))
+ .collect::<Result<BTreeSet<_>, _>>()?;
+ required(
+ paths == expected_inputs,
+ "input descriptor membership changed",
+ )?;
+ for row in descriptors {
+ descriptor(inputs, row)?;
+ }
+ let source_lock = std::str::from_utf8(&inputs["radroots.lib.source-lock.v1.toml"])
+ .map_err(|error| error.to_string())?;
+ required(
+ source_lock
+ .lines()
+ .filter(|line| line.starts_with("revision = "))
+ .collect::<Vec<_>>()
+ == [format!("revision = \"{REVISION}\"")],
+ "source lock revision changed",
+ )?;
+ let corpus = parse(inputs, &(FOOD.to_owned() + "corpus.v1.json"))?;
+ let profile = parse(inputs, &(FOOD.to_owned() + "source_profile.v1.json"))?;
+ let provenance = parse(inputs, &(FOOD.to_owned() + "provenance.v1.json"))?;
+ required(
+ corpus["revision"] == REVISION
+ && corpus["contract_version"] == "1.0.0"
+ && profile["contract_version"] == "1.0.0"
+ && profile["suite"] == PROFILE,
+ "public profile changed",
+ )?;
+ required(
+ corpus["source_sha256"]
+ == Sha256::digest(&inputs[&(FOOD.to_owned() + "source_profile.v1.json")]).to_hex()
+ && provenance["public_source"]["sha256"] == corpus["source_sha256"]
+ && provenance["public_source"]["revision"] == REVISION,
+ "public source provenance mismatch",
+ )?;
+ descriptor(
+ inputs,
+ &json!({"path":FOOD.to_owned()+"corpus.v1.json","sha256":provenance["corpus"]["sha256"],"bytes":provenance["corpus"]["bytes"]}),
+ )?;
+ let writers = parse(inputs, &(FOOD.to_owned() + "web_templates.v1.json"))?;
+ let boundaries = parse(inputs, &(FOOD.to_owned() + "numeric_boundaries.v1.json"))?;
+ required(
+ boundaries["revision"] == REVISION
+ && boundaries["profile"] == PROFILE
+ && boundaries["contract_version"] == "1.0.0"
+ && boundaries["schema_version"] == 1,
+ "boundary profile changed",
+ )?;
+ let public = corpus["vectors"]
+ .as_array()
+ .ok_or("missing public vectors")?;
+ let source = profile["vectors"]
+ .as_array()
+ .ok_or("missing source recipes")?;
+ let writers = writers.as_array().ok_or("missing website recipes")?;
+ let boundaries = boundaries["vectors"]
+ .as_array()
+ .ok_or("missing boundary recipes")?;
+ required(
+ public.len() == 40 && source.len() == 40 && writers.len() == 16 && boundaries.len() == 10,
+ "fixture membership changed",
+ )?;
+ let mut recipes = BTreeMap::new();
+ for (index, row) in public.iter().enumerate() {
+ required(
+ json!({"id":row["id"],"kind":row["kind"],"input":row["input"],"expected":row["expected"]})
+ == source[index],
+ "public recipe differs from source",
+ )?;
+ recipes.insert(
+ row["id"].as_str().ok_or("missing public ID")?,
+ ("corpus.v1.json", index, row),
+ );
+ }
+ for (index, row) in writers.iter().enumerate() {
+ required(
+ recipes
+ .insert(
+ row["id"].as_str().ok_or("missing writer ID")?,
+ ("web_templates.v1.json", index, row),
+ )
+ .is_none(),
+ "duplicate writer ID",
+ )?;
+ }
+ for (index, row) in boundaries.iter().enumerate() {
+ required(
+ recipes
+ .insert(
+ row["id"].as_str().ok_or("missing boundary ID")?,
+ ("numeric_boundaries.v1.json", index, row),
+ )
+ .is_none(),
+ "duplicate boundary ID",
+ )?;
+ }
+ let cases = manifest["cases"]
+ .as_array()
+ .ok_or("missing manifest cases")?;
+ required(
+ cases.len() == recipes.len() && recipes.len() == 66,
+ "manifest cases missing",
+ )?;
+ let mut seen = BTreeSet::new();
+ let mut results = Vec::new();
+ for case in cases {
+ let id = case["id"].as_str().ok_or("missing case ID")?;
+ required(seen.insert(id), "duplicate case ID")?;
+ let (file, index, row) = recipes.get(id).ok_or("unknown case ID")?;
+ required(
+ case["protocol"]["profile"] == PROFILE
+ && case["protocol"]["contract_version"] == "1.0.0"
+ && case["oracle_revision"] == REVISION
+ && case["participation"]["native_consumer"] == "REQUIRED_NATIVE_TEST",
+ "case participation changed",
+ )?;
+ required(
+ case["fixture"]["path"] == FOOD.to_owned() + file
+ && case["fixture"]["case_index"].as_u64() == Some(u64::try_from(*index).unwrap())
+ && case["fixture"]["case_id"] == id,
+ "raw case pointer changed",
+ )?;
+ descriptor(inputs, &case["fixture"])?;
+ let expected = if *file == "web_templates.v1.json" {
+ json!({"result":"accepted","wire_parts":row["wire_parts"]})
+ } else {
+ row["expected"].clone()
+ };
+ required(
+ case["expected"] == expected,
+ "case expectation differs from recipe",
+ )?;
+ if case["protocol"]["profile"] != selected_profile {
+ continue;
+ }
+ let (actual, expected) = match *file {
+ "corpus.v1.json" => {
+ for (field, raw) in row["signed_wires"]
+ .as_object()
+ .ok_or("missing signed wires")?
+ {
+ let raw = raw.as_str().ok_or("invalid signed wire")?;
+ let wire =
+ Nip01EventWire::parse_json(raw).map_err(|error| error.to_string())?;
+ wire.verify_id().map_err(|error| error.to_string())?;
+ required(
+ serde_json::from_str::<Value>(raw).map_err(|error| error.to_string())?
+ == row["input"][field],
+ "signed raw differs from recipe",
+ )?;
+ }
+ (support::actual(row), expected)
+ }
+ "web_templates.v1.json" => {
+ let template =
+ serde_json::from_value((*row).clone()).map_err(|error| error.to_string())?;
+ let mut actual = support::consume_template(&template)?;
+ actual.as_object_mut().unwrap().remove("id");
+ (actual, expected)
+ }
+ "numeric_boundaries.v1.json" => (support::boundary(row), expected["native"].clone()),
+ _ => return Err("unhandled fixture".into()),
+ };
+ required(
+ actual == expected,
+ &format!("actual pinned codec differs for {id}"),
+ )?;
+ results.push(json!({"id":id,"result":"PASS","actual":actual}));
+ }
+ required(!results.is_empty(), "zero matching native cases")?;
+ Ok(
+ json!({"consumer":"native_public_food_codec","revision":REVISION,"qualification":"FIXTURE_ONLY_NOT_DEPLOYED_TERA","signing":"NOT_RUN_NO_KEYS","matched_cases":results.len(),"cases":results}),
+ )
+}
+
+#[test]
+fn native_manifest_executes_actual_pinned_food_codec() {
+ let (manifest, inputs) = load();
+ let result = consume(&manifest, &inputs, PROFILE).unwrap();
+ assert_eq!(result["matched_cases"], 66);
+ println!("{}", serde_json::to_string(&result).unwrap());
+}
+
+#[test]
+fn native_consumer_rejects_corruption_and_zero_matching_cases() {
+ let (manifest, inputs) = load();
+ for mutation in [
+ "duplicate",
+ "missing",
+ "hash",
+ "revision",
+ "path",
+ "expected",
+ "participation",
+ ] {
+ let mut changed = manifest.clone();
+ match mutation {
+ "duplicate" => changed["cases"][1]["id"] = changed["cases"][0]["id"].clone(),
+ "missing" => {
+ changed["cases"].as_array_mut().unwrap().pop();
+ }
+ "hash" => changed["cases"][0]["fixture"]["sha256"] = json!("0".repeat(64)),
+ "revision" => changed["oracle"]["revision"] = json!("0".repeat(40)),
+ "path" => changed["cases"][0]["fixture"]["path"] = json!("web/static/private.json"),
+ "expected" => changed["cases"][0]["expected"] = json!({"result":"wrong"}),
+ "participation" => {
+ changed["cases"][0]["participation"]["native_consumer"] = json!("PASS")
+ }
+ _ => unreachable!(),
+ }
+ assert!(consume(&changed, &inputs, PROFILE).is_err(), "{mutation}");
+ }
+ assert_eq!(
+ consume(&manifest, &inputs, "unavailable_profile").unwrap_err(),
+ "zero matching native cases"
+ );
+ let mut changed = inputs.clone();
+ changed.get_mut(INPUTS[0]).unwrap().push(b' ');
+ assert!(consume(&manifest, &changed, PROFILE).is_err());
+ changed = inputs.clone();
+ changed.remove(INPUTS[0]);
+ assert!(consume(&manifest, &changed, PROFILE).is_err());
+}
+
+#[test]
+fn actual_native_codec_rejects_noncanonical_price_and_changed_signed_bytes() {
+ let (_, inputs) = load();
+ let mut writers = parse(&inputs, &(FOOD.to_owned() + "web_templates.v1.json")).unwrap();
+ let tags = writers[0]["wire_parts"]["tags"].as_array_mut().unwrap();
+ let price = tags.iter_mut().find(|tag| tag[0] == "price").unwrap();
+ price[1] = json!("1e3");
+ let template = serde_json::from_value(writers[0].clone()).unwrap();
+ assert!(support::consume_template(&template).is_err());
+ let corpus = parse(&inputs, INPUTS[0]).unwrap();
+ let mut event: Value = serde_json::from_str(
+ corpus["vectors"][13]["signed_wires"]["event"]
+ .as_str()
+ .unwrap(),
+ )
+ .unwrap();
+ let original_signature = event["sig"].clone();
+ event["sig"] = json!("0".repeat(128));
+ let wire = Nip01EventWire::parse_json(&serde_json::to_string(&event).unwrap()).unwrap();
+ wire.verify_id().unwrap();
+ assert!(verify_nip01_event(wire.into_envelope().unwrap()).is_err());
+ event["sig"] = original_signature;
+ event["id"] = json!("0".repeat(64));
+ // This actual public parser checks the canonical identifier before it
+ // returns a wire. Assert that stage, rather than unwrapping a rejection.
+ assert!(matches!(
+ Nip01EventWire::parse_json(&serde_json::to_string(&event).unwrap()),
+ Err(EventWireError::EventIdMismatch { .. })
+ ));
+}
+
+#[test]
+fn actual_native_boundaries_preserve_full_u64_and_raw_identifier_spelling() {
+ let (_, inputs) = load();
+ let fixture = parse(&inputs, &(FOOD.to_owned() + "numeric_boundaries.v1.json")).unwrap();
+ let rows = fixture["vectors"].as_array().unwrap();
+ for row in rows {
+ assert_eq!(support::boundary(row), row["expected"]["native"]);
+ }
+ assert_eq!(
+ support::boundary(&rows[6])["timestamp"],
+ u64::MAX.to_string()
+ );
+ assert_ne!(
+ support::boundary(&rows[8])["identifier"],
+ support::boundary(&rows[9])["identifier"]
+ );
+}
diff --git a/contracts/interop/food_availability/oracle/tests/support/mod.rs b/contracts/interop/food_availability/oracle/tests/support/mod.rs
@@ -0,0 +1,409 @@
+// SPDX-License-Identifier: GPL-3.0-only
+// Public fixture recipes and API readback follow Radroots Lib revision
+// 189c49b74b4bafc142b00b76b296477931139e72's food_availability_conformance.rs
+// (MIT OR Apache-2.0). This tool never signs or receives private keys.
+#![forbid(unsafe_code)]
+
+use radroots_blossom::{BlobDescriptor, BlobUrl, MediaType, Sha256};
+use radroots_event::envelope::EventEnvelope;
+use radroots_event::food::availability::{
+ FoodAvailabilityDetails, FoodAvailabilityDetailsParts, FoodAvailabilityError,
+ FoodAvailabilityImage, FoodAvailabilityStatus, FoodContent, FoodCurrency, FoodIdentifier,
+ FoodImageDimensions, FoodPrice, FoodPublishedAt, FoodQuantity, FoodText, FoodUnit,
+};
+use radroots_event::listing::classified::ClassifiedListingPartition;
+use radroots_event::media::AuthoredImage;
+use radroots_event::wire::Nip01EventWire;
+use radroots_event_codec::admission::food_availability::{
+ RadrootsFoodAvailabilityAdmissionOutcome, validate_food_availability_revision,
+ verify_and_admit_food_availability_event,
+};
+use radroots_event_codec::decode::food_availability::{
+ RadrootsFoodAvailabilityProjectionOutcome, RadrootsInboundFoodAvailabilityProjection,
+ project_verified_food_availability_event,
+};
+use radroots_event_codec::encode::food_availability::{
+ RadrootsFoodAvailabilityEncodeError, authored_food_availability_build_tags,
+ authored_food_availability_to_wire_parts,
+};
+use radroots_event_codec::verify::{RadrootsSignatureVerifiedEvent, verify_nip01_event};
+use serde::Deserialize;
+use serde_json::{Value, json};
+
+#[derive(Deserialize)]
+#[serde(deny_unknown_fields)]
+struct Details {
+ content: Value,
+ identifier: String,
+ title: String,
+ summary: String,
+ published_at: u64,
+ location: String,
+ price: Price,
+ quantity: Option<Quantity>,
+ status: String,
+ images: Vec<Image>,
+}
+#[derive(Deserialize)]
+#[serde(deny_unknown_fields)]
+struct Price {
+ amount: String,
+ currency: String,
+ unit: String,
+}
+#[derive(Deserialize)]
+#[serde(deny_unknown_fields)]
+struct Quantity {
+ amount: String,
+ unit: String,
+}
+#[derive(Deserialize)]
+#[serde(deny_unknown_fields)]
+struct Image {
+ bytes_utf8: String,
+ url: String,
+ media_type: String,
+ uploaded_at: u64,
+ dimensions: String,
+}
+
+fn text(recipe: &Value) -> String {
+ if let Some(value) = recipe.get("value").and_then(Value::as_str) {
+ assert_eq!(recipe.as_object().unwrap().len(), 1);
+ value.to_owned()
+ } else {
+ assert_eq!(recipe.as_object().unwrap().len(), 2);
+ let character = recipe["repeat"].as_str().unwrap();
+ assert_eq!(character.chars().count(), 1);
+ let count = usize::try_from(recipe["count"].as_u64().unwrap()).unwrap();
+ assert!(count <= 262_144, "fixture recipe exceeds tooling bound");
+ character.repeat(count)
+ }
+}
+
+fn details(input: &Value) -> FoodAvailabilityDetails {
+ let input: Details = serde_json::from_value(input.clone()).unwrap();
+ let images = input
+ .images
+ .iter()
+ .map(|image| {
+ let bytes = image.bytes_utf8.as_bytes();
+ let media_type = MediaType::parse(&image.media_type).unwrap();
+ let verified = BlobDescriptor::new(
+ BlobUrl::parse(&image.url).unwrap(),
+ Sha256::digest(bytes),
+ u64::try_from(bytes.len()).unwrap(),
+ media_type.clone(),
+ image.uploaded_at,
+ )
+ .unwrap()
+ .approve_reference()
+ .unwrap()
+ .verify_bytes(bytes, &media_type)
+ .unwrap();
+ FoodAvailabilityImage::new(
+ AuthoredImage::try_from_verified_descriptor(verified).unwrap(),
+ FoodImageDimensions::parse(&image.dimensions).unwrap(),
+ )
+ })
+ .collect();
+ FoodAvailabilityDetails::new(FoodAvailabilityDetailsParts {
+ content: FoodContent::new(text(&input.content)).unwrap(),
+ identifier: FoodIdentifier::parse(&input.identifier).unwrap(),
+ title: FoodText::new(input.title).unwrap(),
+ summary: FoodText::new(input.summary).unwrap(),
+ published_at: FoodPublishedAt::new(input.published_at).unwrap(),
+ location: FoodText::new(input.location).unwrap(),
+ price: FoodPrice::new(
+ input.price.amount,
+ FoodCurrency::parse(&input.price.currency).unwrap(),
+ FoodUnit::parse(&input.price.unit).unwrap(),
+ )
+ .unwrap(),
+ quantity: input.quantity.map(|quantity| {
+ FoodQuantity::new(quantity.amount, FoodUnit::parse(&quantity.unit).unwrap()).unwrap()
+ }),
+ status: FoodAvailabilityStatus::parse(&input.status).unwrap(),
+ images,
+ })
+ .unwrap()
+}
+
+fn envelope(value: &Value) -> EventEnvelope {
+ let raw = serde_json::to_string(value).unwrap();
+ let wire = Nip01EventWire::parse_json(&raw).unwrap();
+ wire.verify_id().unwrap();
+ let event = wire.into_envelope().unwrap();
+ // Check every signed field after the real wire parser, before admission.
+ assert_eq!(event.id_hex(), value["id"].as_str().unwrap());
+ assert_eq!(event.author().to_hex(), value["pubkey"].as_str().unwrap());
+ assert_eq!(
+ event.created_at_u64(),
+ value["created_at"].as_u64().unwrap()
+ );
+ assert_eq!(u64::from(event.kind_u32()), value["kind"].as_u64().unwrap());
+ assert_eq!(json!(event.tags_as_vec()), value["tags"]);
+ assert_eq!(event.content(), value["content"].as_str().unwrap());
+ event
+}
+
+fn verified(value: &Value) -> RadrootsSignatureVerifiedEvent {
+ verify_nip01_event(envelope(value)).unwrap()
+}
+
+fn partition(value: ClassifiedListingPartition) -> &'static str {
+ match value {
+ ClassifiedListingPartition::FocusedFoodAvailability => "focused_food_availability",
+ ClassifiedListingPartition::OperationalListing => "operational_listing",
+ ClassifiedListingPartition::GenericNip99 => "generic_nip99",
+ ClassifiedListingPartition::Ambiguous => "ambiguous",
+ }
+}
+
+fn projection(value: &RadrootsInboundFoodAvailabilityProjection) -> Value {
+ let images: Vec<_> = value
+ .images()
+ .iter()
+ .map(|image| {
+ let dimensions = image
+ .dimensions()
+ .map(|size| json!({"width":size.width(),"height":size.height()}));
+ json!({
+ "raw_tag":image.raw_tag(),"url":image.url(),"dimensions":dimensions,
+ "diagnostics":image.diagnostics().iter().map(|d|d.code()).collect::<Vec<_>>(),
+ "qualifies":image.qualifies()
+ })
+ })
+ .collect();
+ json!({
+ "content":value.content().as_str(),"identifier":value.identifier().as_str(),
+ "title":value.title().as_str(),"summary":value.summary().as_str(),
+ "published_at":value.published_at().as_u64(),"location":value.location().as_str(),
+ "price":{"amount":value.price().amount(),"currency":value.price().currency().as_str(),"unit":value.price().unit().as_str()},
+ "quantity":value.quantity().map(|q|json!({"amount":q.amount(),"unit":q.unit().as_str()})),
+ "status":value.status().as_str(),"images":images,
+ "diagnostics":value.diagnostics().iter().map(|d|d.code()).collect::<Vec<_>>()
+ })
+}
+
+fn authored_error(error: &RadrootsFoodAvailabilityEncodeError) -> Value {
+ match error {
+ RadrootsFoodAvailabilityEncodeError::Domain(FoodAvailabilityError::PublishedAtFuture {
+ published_at,
+ created_at,
+ }) => {
+ json!({"code":error.code(),"message":error.to_string(),"published_at":published_at,"created_at":created_at})
+ }
+ RadrootsFoodAvailabilityEncodeError::EventWireTooLarge { max, actual } => {
+ json!({"code":error.code(),"message":error.to_string(),"max":max,"actual":actual})
+ }
+ _ => json!({"code":error.code(),"message":error.to_string()}),
+ }
+}
+
+pub(super) fn actual(vector: &Value) -> Value {
+ let kind = vector["kind"].as_str().unwrap();
+ let input = &vector["input"];
+ match kind {
+ "food_availability.build_authored_draft.valid"
+ | "food_availability.build_authored_draft.invalid" => {
+ let details = details(&input["details"]);
+ let created_at = input["created_at"].as_u64().unwrap();
+ match authored_food_availability_to_wire_parts(&details, created_at) {
+ Ok(wire) => {
+ assert_eq!(
+ wire.tags,
+ authored_food_availability_build_tags(&details, created_at).unwrap()
+ );
+ if vector["expected"]["wire_parts"]
+ .get("content_length")
+ .is_some()
+ {
+ json!({"wire_parts":{"kind":wire.kind,"content_length":wire.content.len(),"tags":wire.tags}})
+ } else {
+ json!({"wire_parts":{"kind":wire.kind,"content":wire.content,"tags":wire.tags}})
+ }
+ }
+ Err(error) => json!({"error":authored_error(&error)}),
+ }
+ }
+ "food_availability.project_verified_event.valid"
+ | "food_availability.project_verified_event.invalid" => {
+ let event = verified(&input["event"]);
+ match project_verified_food_availability_event(&event) {
+ Ok(RadrootsFoodAvailabilityProjectionOutcome::Focused(value))
+ if vector["expected"].get("projection").is_some() =>
+ {
+ json!({"outcome":"focused","event_id":event.event().id_hex(),"projection":projection(&value)})
+ }
+ Ok(RadrootsFoodAvailabilityProjectionOutcome::Focused(value)) => {
+ json!({"outcome":"focused","event_id":event.event().id_hex(),"image_count":value.images().len(),"diagnostics":value.diagnostics().iter().map(|d|d.code()).collect::<Vec<_>>(),"first_raw_tag":value.images().first().unwrap().raw_tag(),"last_raw_tag":value.images().last().unwrap().raw_tag()})
+ }
+ Ok(RadrootsFoodAvailabilityProjectionOutcome::Excluded(value)) => {
+ json!({"outcome":"excluded","event_id":event.event().id_hex(),"partition":partition(value)})
+ }
+ Ok(_) => panic!("unqualified projection outcome"),
+ Err(error) => json!({"error":{"code":error.code(),"message":error.to_string()}}),
+ }
+ }
+ "food_availability.verify_and_admit_event.valid"
+ | "food_availability.verify_and_admit_event.invalid" => {
+ match verify_and_admit_food_availability_event(envelope(&input["event"])) {
+ Ok(RadrootsFoodAvailabilityAdmissionOutcome::Admitted(event)) => {
+ json!({"outcome":"admitted","event_id":event.event().id_hex(),"projection":projection(event.projection())})
+ }
+ Ok(RadrootsFoodAvailabilityAdmissionOutcome::Excluded(event)) => {
+ json!({"outcome":"excluded","event_id":event.event().id_hex(),"partition":partition(event.partition())})
+ }
+ Ok(_) => panic!("unqualified admission outcome"),
+ Err(error) => json!({"error":{"code":error.code(),"message":error.to_string()}}),
+ }
+ }
+ "food_availability.validate_revision.valid"
+ | "food_availability.validate_revision.invalid" => {
+ let previous = verified(&input["previous"]);
+ let current = verified(&input["current"]);
+ match validate_food_availability_revision(&previous, ¤t) {
+ Ok(()) => json!({"result":"accepted","current_event_id":current.event().id_hex()}),
+ Err(error) => json!({"error":{"code":error.code(),"message":error.to_string()}}),
+ }
+ }
+ _ => panic!("unqualified vector kind {kind}"),
+ }
+}
+
+#[derive(Deserialize)]
+#[serde(deny_unknown_fields)]
+pub(super) struct WebTemplate {
+ id: String,
+ created_at: u64,
+ wire_parts: WebParts,
+ summary: String,
+}
+#[derive(Deserialize)]
+#[serde(deny_unknown_fields)]
+struct WebParts {
+ kind: u32,
+ content: String,
+ tags: Vec<Vec<String>>,
+}
+
+pub(super) fn consume_template(template: &WebTemplate) -> Result<Value, String> {
+ if template.id.is_empty()
+ || template.id.len() > 128
+ || template.created_at > 9_007_199_254_740_991
+ || template.wire_parts.kind != 30402
+ || template.wire_parts.content.len() > 16 * 1024
+ || template.wire_parts.tags.len() > 9
+ {
+ return Err("unsupported bounded website template".into());
+ }
+ let value = |name: &str| -> Result<&str, String> {
+ let tags = template
+ .wire_parts
+ .tags
+ .iter()
+ .filter(|tag| tag.first().is_some_and(|key| key == name))
+ .collect::<Vec<_>>();
+ match tags.as_slice() {
+ [tag] if tag.len() == 2 => Ok(tag[1].as_str()),
+ _ => Err("invalid website singleton tag".into()),
+ }
+ };
+ let price_tags = template
+ .wire_parts
+ .tags
+ .iter()
+ .filter(|tag| tag.first().is_some_and(|key| key == "price"))
+ .collect::<Vec<_>>();
+ let price = match price_tags.as_slice() {
+ [tag] if tag.len() == 3 => *tag,
+ _ => return Err("invalid website price tag".into()),
+ };
+ let quantity_tags = template
+ .wire_parts
+ .tags
+ .iter()
+ .filter(|tag| tag.first().is_some_and(|key| key == "radroots:quantity"))
+ .collect::<Vec<_>>();
+ let quantity = match quantity_tags.as_slice() {
+ [] => None,
+ [tag] if tag.len() == 3 => Some(
+ FoodQuantity::new(
+ &tag[1],
+ FoodUnit::parse(&tag[2]).map_err(|error| error.to_string())?,
+ )
+ .map_err(|error| error.to_string())?,
+ ),
+ _ => return Err("invalid website quantity tag".into()),
+ };
+ if value("summary")? != template.summary {
+ return Err("website review summary differs from public template".into());
+ }
+ // Actual pinned public constructors and codec consume the website fields.
+ // No synthetic signature, signer, native runtime or private key is involved.
+ let details = FoodAvailabilityDetails::new(FoodAvailabilityDetailsParts {
+ content: FoodContent::new(&template.wire_parts.content)
+ .map_err(|error| error.to_string())?,
+ identifier: FoodIdentifier::parse(value("d")?).map_err(|error| error.to_string())?,
+ title: FoodText::new(value("title")?).map_err(|error| error.to_string())?,
+ summary: FoodText::new(value("summary")?).map_err(|error| error.to_string())?,
+ published_at: FoodPublishedAt::parse(value("published_at")?)
+ .map_err(|error| error.to_string())?,
+ location: FoodText::new(value("location")?).map_err(|error| error.to_string())?,
+ price: FoodPrice::new(
+ &price[1],
+ FoodCurrency::parse(&price[2]).map_err(|error| error.to_string())?,
+ FoodUnit::parse(value("radroots:price_unit")?).map_err(|error| error.to_string())?,
+ )
+ .map_err(|error| error.to_string())?,
+ quantity,
+ status: FoodAvailabilityStatus::parse(value("status")?)
+ .map_err(|error| error.to_string())?,
+ images: Vec::new(),
+ })
+ .map_err(|error| error.to_string())?;
+ let actual = authored_food_availability_to_wire_parts(&details, template.created_at)
+ .map_err(|error| error.to_string())?;
+ if actual.kind != template.wire_parts.kind
+ || actual.content != template.wire_parts.content
+ || actual.tags != template.wire_parts.tags
+ {
+ return Err("website wire parts differ from actual pinned Rust codec".into());
+ }
+ Ok(
+ json!({"id":template.id,"result":"accepted","wire_parts":{"kind":actual.kind,"content":actual.content,"tags":actual.tags}}),
+ )
+}
+
+pub(super) fn boundary(row: &Value) -> Value {
+ let value = row["value"].as_str().unwrap();
+ let (identifier, timestamp) = match row["kind"].as_str().unwrap() {
+ "timestamp" => match FoodPublishedAt::parse(value) {
+ Ok(timestamp) => ("boundary-id", timestamp.as_u64()),
+ Err(error) => return json!({"result":"rejected","code":error.code()}),
+ },
+ "identifier" => (value, 1),
+ _ => panic!("unknown boundary kind"),
+ };
+ let recipe = json!({
+ "content":{"value":"Fresh food available locally."},
+ "identifier":identifier,"title":"Fresh food","summary":"Fresh food available locally.",
+ "published_at":timestamp,"location":"Victoria",
+ "price":{"amount":"1","currency":"CAD","unit":"g"},
+ "quantity":null,"status":"active","images":[]
+ });
+ let wire = authored_food_availability_to_wire_parts(&details(&recipe), timestamp).unwrap();
+ let tag = |name: &str| {
+ wire.tags
+ .iter()
+ .find(|tag| tag.first().is_some_and(|key| key == name))
+ .unwrap()[1]
+ .clone()
+ };
+ if row["kind"] == "identifier" {
+ json!({"result":"accepted","identifier":tag("d")})
+ } else {
+ json!({"result":"accepted","timestamp":timestamp.to_string(),"encoded_published_at":tag("published_at")})
+ }
+}
diff --git a/contracts/interop/manifest.json b/contracts/interop/manifest.json
@@ -46,6 +46,21 @@
"path": "contracts/interop/food_availability/web_templates.v1.json",
"sha256": "afa91541c4a66b715d2c5eeb54a7cacd6e562024c56efc19464a2a11323721c0",
"bytes": 33805
+ },
+ {
+ "path": "contracts/interop/food_availability/numeric_boundaries.v1.json",
+ "sha256": "9789690d06e0453c6f5e85e5f9df57f01fb95cb4872f9dd420081cbeb313a105",
+ "bytes": 4741
+ },
+ {
+ "path": "contracts/interop/food_availability/oracle/tests/native_manifest.rs",
+ "sha256": "61b8ad6ee64bedd2f72705f7050e244abf744453bfb4305aa2032781baf85d5d",
+ "bytes": 15785
+ },
+ {
+ "path": "contracts/interop/food_availability/oracle/tests/support/mod.rs",
+ "sha256": "3ae2b0cebc224e5094c3c6a64a4941d88540f8a9a867c18dcdd62b279dc49262",
+ "bytes": 17427
}
],
"fixture_authority": {
@@ -54,9 +69,7 @@
"manifest": "Derived metadata and expectations, not a second editable protocol policy."
},
"pending_checks": [
- "native_consumer_HCR014",
"combined_orchestration_HCR015",
- "native_full_u64_vs_unsafe_js_common_boundary_HCR014",
"Message_adapters_HCP071_HCP130",
"deployed_Tera_qualification"
],
@@ -123,7 +136,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "UNSUPPORTED_CURRENT_ADAPTER",
"unsupported_reason": "Public authored-details recipes include profile capabilities beyond the strict text-only prototype builder; its separate sixteen actual outputs are shared below."
}
@@ -190,7 +203,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "UNSUPPORTED_CURRENT_ADAPTER",
"unsupported_reason": "Public authored-details recipes include profile capabilities beyond the strict text-only prototype builder; its separate sixteen actual outputs are shared below."
}
@@ -257,7 +270,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "UNSUPPORTED_CURRENT_ADAPTER",
"unsupported_reason": "Public authored-details recipes include profile capabilities beyond the strict text-only prototype builder; its separate sixteen actual outputs are shared below."
}
@@ -324,7 +337,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "UNSUPPORTED_CURRENT_ADAPTER",
"unsupported_reason": "Public authored-details recipes include profile capabilities beyond the strict text-only prototype builder; its separate sixteen actual outputs are shared below."
}
@@ -391,7 +404,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "UNSUPPORTED_CURRENT_ADAPTER",
"unsupported_reason": "Public authored-details recipes include profile capabilities beyond the strict text-only prototype builder; its separate sixteen actual outputs are shared below."
}
@@ -458,7 +471,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "UNSUPPORTED_CURRENT_ADAPTER",
"unsupported_reason": "Public authored-details recipes include profile capabilities beyond the strict text-only prototype builder; its separate sixteen actual outputs are shared below."
}
@@ -535,7 +548,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "UNSUPPORTED_CURRENT_ADAPTER",
"unsupported_reason": "Public authored-details recipes include profile capabilities beyond the strict text-only prototype builder; its separate sixteen actual outputs are shared below."
}
@@ -602,7 +615,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "UNSUPPORTED_CURRENT_ADAPTER",
"unsupported_reason": "Public authored-details recipes include profile capabilities beyond the strict text-only prototype builder; its separate sixteen actual outputs are shared below."
}
@@ -664,7 +677,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "UNSUPPORTED_CURRENT_ADAPTER",
"unsupported_reason": "Public authored-details recipes include profile capabilities beyond the strict text-only prototype builder; its separate sixteen actual outputs are shared below."
}
@@ -731,7 +744,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "UNSUPPORTED_CURRENT_ADAPTER",
"unsupported_reason": "Public authored-details recipes include profile capabilities beyond the strict text-only prototype builder; its separate sixteen actual outputs are shared below."
}
@@ -793,7 +806,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "UNSUPPORTED_CURRENT_ADAPTER",
"unsupported_reason": "Public authored-details recipes include profile capabilities beyond the strict text-only prototype builder; its separate sixteen actual outputs are shared below."
}
@@ -822,7 +835,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "UNSUPPORTED_CURRENT_ADAPTER",
"unsupported_reason": "Public authored-details recipes include profile capabilities beyond the strict text-only prototype builder; its separate sixteen actual outputs are shared below."
}
@@ -851,7 +864,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "UNSUPPORTED_CURRENT_ADAPTER",
"unsupported_reason": "Public authored-details recipes include profile capabilities beyond the strict text-only prototype builder; its separate sixteen actual outputs are shared below."
}
@@ -896,7 +909,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "food_reader",
"unsupported_reason": null
}
@@ -938,7 +951,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "food_reader",
"unsupported_reason": null
}
@@ -964,7 +977,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "food_reader",
"unsupported_reason": null
}
@@ -990,7 +1003,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "food_reader",
"unsupported_reason": null
}
@@ -1017,7 +1030,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "food_reader",
"unsupported_reason": null
}
@@ -1044,7 +1057,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "food_reader",
"unsupported_reason": null
}
@@ -1071,7 +1084,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "food_reader",
"unsupported_reason": null
}
@@ -1098,7 +1111,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "food_reader",
"unsupported_reason": null
}
@@ -1125,7 +1138,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "food_reader",
"unsupported_reason": null
}
@@ -1152,7 +1165,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "food_reader",
"unsupported_reason": null
}
@@ -1179,7 +1192,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "food_reader",
"unsupported_reason": null
}
@@ -1206,7 +1219,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "food_reader",
"unsupported_reason": null
}
@@ -1233,7 +1246,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "food_reader",
"unsupported_reason": null
}
@@ -1260,7 +1273,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "food_reader",
"unsupported_reason": null
}
@@ -1287,7 +1300,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "food_reader",
"unsupported_reason": null
}
@@ -1384,7 +1397,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "food_reader",
"unsupported_reason": null
}
@@ -1423,7 +1436,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "food_reader",
"unsupported_reason": null
}
@@ -1450,7 +1463,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "food_reader",
"unsupported_reason": null
}
@@ -1475,7 +1488,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "UNSUPPORTED_CURRENT_ADAPTER",
"unsupported_reason": "Current website reader is not a revision-transition adapter; original head-selection checkpoints retain this obligation."
}
@@ -1502,7 +1515,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "UNSUPPORTED_CURRENT_ADAPTER",
"unsupported_reason": "Current website reader is not a revision-transition adapter; original head-selection checkpoints retain this obligation."
}
@@ -1529,7 +1542,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "UNSUPPORTED_CURRENT_ADAPTER",
"unsupported_reason": "Current website reader is not a revision-transition adapter; original head-selection checkpoints retain this obligation."
}
@@ -1556,7 +1569,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "UNSUPPORTED_CURRENT_ADAPTER",
"unsupported_reason": "Current website reader is not a revision-transition adapter; original head-selection checkpoints retain this obligation."
}
@@ -1583,7 +1596,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "UNSUPPORTED_CURRENT_ADAPTER",
"unsupported_reason": "Current website reader is not a revision-transition adapter; original head-selection checkpoints retain this obligation."
}
@@ -1610,7 +1623,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "UNSUPPORTED_CURRENT_ADAPTER",
"unsupported_reason": "Current website reader is not a revision-transition adapter; original head-selection checkpoints retain this obligation."
}
@@ -1637,7 +1650,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "UNSUPPORTED_CURRENT_ADAPTER",
"unsupported_reason": "Current website reader is not a revision-transition adapter; original head-selection checkpoints retain this obligation."
}
@@ -1664,7 +1677,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "UNSUPPORTED_CURRENT_ADAPTER",
"unsupported_reason": "Current website reader is not a revision-transition adapter; original head-selection checkpoints retain this obligation."
}
@@ -1689,7 +1702,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "UNSUPPORTED_CURRENT_ADAPTER",
"unsupported_reason": "Current website reader is not a revision-transition adapter; original head-selection checkpoints retain this obligation."
}
@@ -1757,7 +1770,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "food_writer",
"unsupported_reason": null
}
@@ -1825,7 +1838,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "food_writer",
"unsupported_reason": null
}
@@ -1893,7 +1906,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "food_writer",
"unsupported_reason": null
}
@@ -1961,7 +1974,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "food_writer",
"unsupported_reason": null
}
@@ -2029,7 +2042,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "food_writer",
"unsupported_reason": null
}
@@ -2097,7 +2110,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "food_writer",
"unsupported_reason": null
}
@@ -2165,7 +2178,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "food_writer",
"unsupported_reason": null
}
@@ -2233,7 +2246,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "food_writer",
"unsupported_reason": null
}
@@ -2301,7 +2314,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "food_writer",
"unsupported_reason": null
}
@@ -2369,7 +2382,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "food_writer",
"unsupported_reason": null
}
@@ -2432,7 +2445,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "food_writer",
"unsupported_reason": null
}
@@ -2500,7 +2513,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "food_writer",
"unsupported_reason": null
}
@@ -2568,7 +2581,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "food_writer",
"unsupported_reason": null
}
@@ -2636,7 +2649,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "food_writer",
"unsupported_reason": null
}
@@ -2704,7 +2717,7 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "food_writer",
"unsupported_reason": null
}
@@ -2772,10 +2785,329 @@
},
"participation": {
"rust_oracle": "REQUIRED",
- "native_consumer": "PENDING_HCR014",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
"typescript": "food_writer",
"unsupported_reason": null
}
+ },
+ {
+ "id": "food_timestamp_zero_hcr014",
+ "protocol": {
+ "profile": "food_availability_profile",
+ "contract_version": "1.0.0"
+ },
+ "fixture": {
+ "path": "contracts/interop/food_availability/numeric_boundaries.v1.json",
+ "sha256": "9789690d06e0453c6f5e85e5f9df57f01fb95cb4872f9dd420081cbeb313a105",
+ "bytes": 4741,
+ "case_index": 0,
+ "case_id": "food_timestamp_zero_hcr014"
+ },
+ "oracle_revision": "189c49b74b4bafc142b00b76b296477931139e72",
+ "expected": {
+ "native": {
+ "result": "rejected",
+ "code": "food_published_at_invalid"
+ },
+ "typescript": {
+ "result": "rejected",
+ "code": "timestamp_invalid"
+ }
+ },
+ "participation": {
+ "rust_oracle": "REQUIRED",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
+ "typescript": "food_boundary",
+ "unsupported_reason": null
+ }
+ },
+ {
+ "id": "food_timestamp_one_hcr014",
+ "protocol": {
+ "profile": "food_availability_profile",
+ "contract_version": "1.0.0"
+ },
+ "fixture": {
+ "path": "contracts/interop/food_availability/numeric_boundaries.v1.json",
+ "sha256": "9789690d06e0453c6f5e85e5f9df57f01fb95cb4872f9dd420081cbeb313a105",
+ "bytes": 4741,
+ "case_index": 1,
+ "case_id": "food_timestamp_one_hcr014"
+ },
+ "oracle_revision": "189c49b74b4bafc142b00b76b296477931139e72",
+ "expected": {
+ "native": {
+ "result": "accepted",
+ "timestamp": "1",
+ "encoded_published_at": "1"
+ },
+ "typescript": {
+ "result": "accepted",
+ "timestamp": "1",
+ "encoded_published_at": "1"
+ }
+ },
+ "participation": {
+ "rust_oracle": "REQUIRED",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
+ "typescript": "food_boundary",
+ "unsupported_reason": null
+ }
+ },
+ {
+ "id": "food_timestamp_safe_minus_one_hcr014",
+ "protocol": {
+ "profile": "food_availability_profile",
+ "contract_version": "1.0.0"
+ },
+ "fixture": {
+ "path": "contracts/interop/food_availability/numeric_boundaries.v1.json",
+ "sha256": "9789690d06e0453c6f5e85e5f9df57f01fb95cb4872f9dd420081cbeb313a105",
+ "bytes": 4741,
+ "case_index": 2,
+ "case_id": "food_timestamp_safe_minus_one_hcr014"
+ },
+ "oracle_revision": "189c49b74b4bafc142b00b76b296477931139e72",
+ "expected": {
+ "native": {
+ "result": "accepted",
+ "timestamp": "9007199254740990",
+ "encoded_published_at": "9007199254740990"
+ },
+ "typescript": {
+ "result": "accepted",
+ "timestamp": "9007199254740990",
+ "encoded_published_at": "9007199254740990"
+ }
+ },
+ "participation": {
+ "rust_oracle": "REQUIRED",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
+ "typescript": "food_boundary",
+ "unsupported_reason": null
+ }
+ },
+ {
+ "id": "food_timestamp_safe_max_hcr014",
+ "protocol": {
+ "profile": "food_availability_profile",
+ "contract_version": "1.0.0"
+ },
+ "fixture": {
+ "path": "contracts/interop/food_availability/numeric_boundaries.v1.json",
+ "sha256": "9789690d06e0453c6f5e85e5f9df57f01fb95cb4872f9dd420081cbeb313a105",
+ "bytes": 4741,
+ "case_index": 3,
+ "case_id": "food_timestamp_safe_max_hcr014"
+ },
+ "oracle_revision": "189c49b74b4bafc142b00b76b296477931139e72",
+ "expected": {
+ "native": {
+ "result": "accepted",
+ "timestamp": "9007199254740991",
+ "encoded_published_at": "9007199254740991"
+ },
+ "typescript": {
+ "result": "accepted",
+ "timestamp": "9007199254740991",
+ "encoded_published_at": "9007199254740991"
+ }
+ },
+ "participation": {
+ "rust_oracle": "REQUIRED",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
+ "typescript": "food_boundary",
+ "unsupported_reason": null
+ }
+ },
+ {
+ "id": "food_timestamp_unsafe_first_hcr014",
+ "protocol": {
+ "profile": "food_availability_profile",
+ "contract_version": "1.0.0"
+ },
+ "fixture": {
+ "path": "contracts/interop/food_availability/numeric_boundaries.v1.json",
+ "sha256": "9789690d06e0453c6f5e85e5f9df57f01fb95cb4872f9dd420081cbeb313a105",
+ "bytes": 4741,
+ "case_index": 4,
+ "case_id": "food_timestamp_unsafe_first_hcr014"
+ },
+ "oracle_revision": "189c49b74b4bafc142b00b76b296477931139e72",
+ "expected": {
+ "native": {
+ "result": "accepted",
+ "timestamp": "9007199254740992",
+ "encoded_published_at": "9007199254740992"
+ },
+ "typescript": {
+ "result": "unsupported",
+ "reason": "Canonical timestamp exceeds Number.MAX_SAFE_INTEGER; current JavaScript adapter must reject it without rounding."
+ }
+ },
+ "participation": {
+ "rust_oracle": "REQUIRED",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
+ "typescript": "UNSUPPORTED_JAVASCRIPT_U64",
+ "unsupported_reason": "Canonical timestamp exceeds Number.MAX_SAFE_INTEGER; current JavaScript adapter must reject it without rounding."
+ }
+ },
+ {
+ "id": "food_timestamp_unsafe_next_hcr014",
+ "protocol": {
+ "profile": "food_availability_profile",
+ "contract_version": "1.0.0"
+ },
+ "fixture": {
+ "path": "contracts/interop/food_availability/numeric_boundaries.v1.json",
+ "sha256": "9789690d06e0453c6f5e85e5f9df57f01fb95cb4872f9dd420081cbeb313a105",
+ "bytes": 4741,
+ "case_index": 5,
+ "case_id": "food_timestamp_unsafe_next_hcr014"
+ },
+ "oracle_revision": "189c49b74b4bafc142b00b76b296477931139e72",
+ "expected": {
+ "native": {
+ "result": "accepted",
+ "timestamp": "9007199254740993",
+ "encoded_published_at": "9007199254740993"
+ },
+ "typescript": {
+ "result": "unsupported",
+ "reason": "Canonical timestamp exceeds Number.MAX_SAFE_INTEGER; current JavaScript adapter must reject it without rounding."
+ }
+ },
+ "participation": {
+ "rust_oracle": "REQUIRED",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
+ "typescript": "UNSUPPORTED_JAVASCRIPT_U64",
+ "unsupported_reason": "Canonical timestamp exceeds Number.MAX_SAFE_INTEGER; current JavaScript adapter must reject it without rounding."
+ }
+ },
+ {
+ "id": "food_timestamp_u64_max_hcr014",
+ "protocol": {
+ "profile": "food_availability_profile",
+ "contract_version": "1.0.0"
+ },
+ "fixture": {
+ "path": "contracts/interop/food_availability/numeric_boundaries.v1.json",
+ "sha256": "9789690d06e0453c6f5e85e5f9df57f01fb95cb4872f9dd420081cbeb313a105",
+ "bytes": 4741,
+ "case_index": 6,
+ "case_id": "food_timestamp_u64_max_hcr014"
+ },
+ "oracle_revision": "189c49b74b4bafc142b00b76b296477931139e72",
+ "expected": {
+ "native": {
+ "result": "accepted",
+ "timestamp": "18446744073709551615",
+ "encoded_published_at": "18446744073709551615"
+ },
+ "typescript": {
+ "result": "unsupported",
+ "reason": "Canonical timestamp exceeds Number.MAX_SAFE_INTEGER; current JavaScript adapter must reject it without rounding."
+ }
+ },
+ "participation": {
+ "rust_oracle": "REQUIRED",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
+ "typescript": "UNSUPPORTED_JAVASCRIPT_U64",
+ "unsupported_reason": "Canonical timestamp exceeds Number.MAX_SAFE_INTEGER; current JavaScript adapter must reject it without rounding."
+ }
+ },
+ {
+ "id": "food_timestamp_u64_overflow_hcr014",
+ "protocol": {
+ "profile": "food_availability_profile",
+ "contract_version": "1.0.0"
+ },
+ "fixture": {
+ "path": "contracts/interop/food_availability/numeric_boundaries.v1.json",
+ "sha256": "9789690d06e0453c6f5e85e5f9df57f01fb95cb4872f9dd420081cbeb313a105",
+ "bytes": 4741,
+ "case_index": 7,
+ "case_id": "food_timestamp_u64_overflow_hcr014"
+ },
+ "oracle_revision": "189c49b74b4bafc142b00b76b296477931139e72",
+ "expected": {
+ "native": {
+ "result": "rejected",
+ "code": "food_published_at_invalid"
+ },
+ "typescript": {
+ "result": "unsupported",
+ "reason": "Canonical timestamp exceeds Number.MAX_SAFE_INTEGER; current JavaScript adapter must reject it without rounding."
+ }
+ },
+ "participation": {
+ "rust_oracle": "REQUIRED",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
+ "typescript": "UNSUPPORTED_JAVASCRIPT_U64",
+ "unsupported_reason": "Canonical timestamp exceeds Number.MAX_SAFE_INTEGER; current JavaScript adapter must reject it without rounding."
+ }
+ },
+ {
+ "id": "food_raw_identifier_nfc_hcr014",
+ "protocol": {
+ "profile": "food_availability_profile",
+ "contract_version": "1.0.0"
+ },
+ "fixture": {
+ "path": "contracts/interop/food_availability/numeric_boundaries.v1.json",
+ "sha256": "9789690d06e0453c6f5e85e5f9df57f01fb95cb4872f9dd420081cbeb313a105",
+ "bytes": 4741,
+ "case_index": 8,
+ "case_id": "food_raw_identifier_nfc_hcr014"
+ },
+ "oracle_revision": "189c49b74b4bafc142b00b76b296477931139e72",
+ "expected": {
+ "native": {
+ "result": "accepted",
+ "identifier": "é"
+ },
+ "typescript": {
+ "result": "accepted",
+ "identifier": "é"
+ }
+ },
+ "participation": {
+ "rust_oracle": "REQUIRED",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
+ "typescript": "food_boundary",
+ "unsupported_reason": null
+ }
+ },
+ {
+ "id": "food_raw_identifier_nfd_hcr014",
+ "protocol": {
+ "profile": "food_availability_profile",
+ "contract_version": "1.0.0"
+ },
+ "fixture": {
+ "path": "contracts/interop/food_availability/numeric_boundaries.v1.json",
+ "sha256": "9789690d06e0453c6f5e85e5f9df57f01fb95cb4872f9dd420081cbeb313a105",
+ "bytes": 4741,
+ "case_index": 9,
+ "case_id": "food_raw_identifier_nfd_hcr014"
+ },
+ "oracle_revision": "189c49b74b4bafc142b00b76b296477931139e72",
+ "expected": {
+ "native": {
+ "result": "accepted",
+ "identifier": "é"
+ },
+ "typescript": {
+ "result": "accepted",
+ "identifier": "é"
+ }
+ },
+ "participation": {
+ "rust_oracle": "REQUIRED",
+ "native_consumer": "REQUIRED_NATIVE_TEST",
+ "typescript": "food_boundary",
+ "unsupported_reason": null
+ }
}
]
}
diff --git a/web/tests/conformance/food-boundaries.test.ts b/web/tests/conformance/food-boundaries.test.ts
@@ -0,0 +1,88 @@
+import assert from 'node:assert/strict';
+import { readFile } from 'node:fs/promises';
+import test from 'node:test';
+import { buildFoodTemplate } from '../../src/lib/contracts/food-availability-v1/write.ts';
+const fixture = JSON.parse(
+ await readFile(
+ new URL(
+ '../../../contracts/interop/food_availability/numeric_boundaries.v1.json',
+ import.meta.url
+ ),
+ 'utf8'
+ )
+) as {
+ vectors: {
+ id: string;
+ kind: 'timestamp' | 'identifier';
+ value: string;
+ expected: { typescript: Record<string, unknown> };
+ }[];
+};
+const base = {
+ identifier: 'boundary-id',
+ title: 'Fresh food',
+ description: 'Fresh food available locally.',
+ location: 'Victoria',
+ amount: '1',
+ currency: 'CAD',
+ unit: 'g',
+ status: 'active' as const,
+ published_at: 1,
+ created_at: 1
+};
+assert.equal(fixture.vectors.length, 10);
+for (const row of fixture.vectors)
+ void test(`actual TS Food boundary ${row.id}`, () => {
+ if (row.kind === 'identifier') {
+ const result = buildFoodTemplate({ ...base, identifier: row.value });
+ assert.ok(result.ok);
+ assert.deepEqual(
+ { result: 'accepted', identifier: result.wire_parts.tags[0][1] },
+ row.expected.typescript
+ );
+ return;
+ }
+ assert.match(row.value, /^(0|[1-9][0-9]*)$/u);
+ const value = BigInt(row.value);
+ const result = buildFoodTemplate({
+ ...base,
+ published_at: Number(value),
+ created_at: Number(value)
+ });
+ if (value > BigInt(Number.MAX_SAFE_INTEGER)) {
+ assert.equal(result.ok, false);
+ if (!result.ok) assert.equal(result.error.code, 'timestamp_invalid');
+ assert.deepEqual(row.expected.typescript, {
+ result: 'unsupported',
+ reason:
+ 'Canonical timestamp exceeds Number.MAX_SAFE_INTEGER; current JavaScript adapter must reject it without rounding.'
+ });
+ } else if (!result.ok) {
+ assert.deepEqual(
+ { result: 'rejected', code: result.error.code },
+ row.expected.typescript
+ );
+ } else {
+ assert.deepEqual(
+ {
+ result: 'accepted',
+ timestamp: String(Number(value)),
+ encoded_published_at: result.wire_parts.tags.find(
+ (tag) => tag[0] === 'published_at'
+ )?.[1]
+ },
+ row.expected.typescript
+ );
+ }
+ });
+void test('canonical raw identifier spellings remain distinct in actual unsigned outputs', () => {
+ const results = fixture.vectors
+ .filter((row) => row.kind === 'identifier')
+ .map((row) => buildFoodTemplate({ ...base, identifier: row.value }));
+ assert.equal(results.length, 2);
+ assert.ok(results[0].ok && results[1].ok);
+ assert.notEqual(
+ results[0].wire_parts.tags[0][1],
+ results[1].wire_parts.tags[0][1]
+ );
+});
diff --git a/web/tests/conformance/interop-manifest.test.ts b/web/tests/conformance/interop-manifest.test.ts
@@ -34,9 +34,9 @@ const manifest = JSON.parse(
};
}[];
};
-void test('one manifest binds actual forty public cases and sixteen website outputs to the pinned oracle', () => {
+void test('one manifest binds forty public cases, sixteen website outputs and ten native boundaries to the pinned oracle', () => {
validateInteropManifest(manifest, inputs, webTemplates);
- assert.equal(manifest.cases.length, 56);
+ assert.equal(manifest.cases.length, 66);
assert.equal(
manifest.cases.filter(
(row) => row.participation.typescript === 'food_reader'
diff --git a/web/tests/conformance/interop-manifest.ts b/web/tests/conformance/interop-manifest.ts
@@ -14,7 +14,10 @@ export const interopInputPaths = [
`${food}oracle/Cargo.toml`,
'radroots.lib.source-lock.v1.toml',
'web/tests/conformance/food-writer-rust.v1.json',
- `${food}web_templates.v1.json`
+ `${food}web_templates.v1.json`,
+ `${food}numeric_boundaries.v1.json`,
+ `${food}oracle/tests/native_manifest.rs`,
+ `${food}oracle/tests/support/mod.rs`
] as const;
const hash = (bytes: Uint8Array) =>
createHash('sha256').update(bytes).digest('hex');
@@ -31,6 +34,15 @@ interface Corpus {
source_sha256: string;
vectors: Vector[];
}
+interface Boundary {
+ id: string;
+ kind: 'timestamp' | 'identifier';
+ value: string;
+ expected: {
+ native: Record<string, unknown>;
+ typescript: { result: string; reason?: string };
+ };
+}
export function buildInteropManifest(
inputs: InteropInputs,
templates: typeof webTemplates
@@ -114,6 +126,18 @@ export function buildInteropManifest(
JSON.stringify(templates, null, 2) + '\n'
);
assert.deepEqual(bytes(`${food}web_templates.v1.json`), templateBytes);
+ const boundaries = JSON.parse(text(`${food}numeric_boundaries.v1.json`)) as {
+ schema_version: number;
+ profile: string;
+ contract_version: string;
+ revision: string;
+ vectors: Boundary[];
+ };
+ assert.equal(boundaries.schema_version, 1);
+ assert.equal(boundaries.profile, profile.suite);
+ assert.equal(boundaries.contract_version, profile.contract_version);
+ assert.equal(boundaries.revision, revision);
+ assert.equal(boundaries.vectors.length, 10);
const fixture = (path: string, caseIndex: number, caseId: string) => ({
...descriptor(path),
case_index: caseIndex,
@@ -132,7 +156,7 @@ export function buildInteropManifest(
expected: row.expected,
participation: {
rust_oracle: 'REQUIRED',
- native_consumer: 'PENDING_HCR014',
+ native_consumer: 'REQUIRED_NATIVE_TEST',
typescript: reader ? 'food_reader' : 'UNSUPPORTED_CURRENT_ADAPTER',
unsupported_reason: reader
? null
@@ -153,13 +177,32 @@ export function buildInteropManifest(
expected: { result: 'accepted', wire_parts: row.wire_parts },
participation: {
rust_oracle: 'REQUIRED',
- native_consumer: 'PENDING_HCR014',
+ native_consumer: 'REQUIRED_NATIVE_TEST',
typescript: 'food_writer',
unsupported_reason: null
}
}));
- const cases = [...publicCases, ...writers];
- assert.equal(cases.length, 56);
+ const boundaryCases = boundaries.vectors.map((row, index) => ({
+ id: row.id,
+ protocol: {
+ profile: profile.suite,
+ contract_version: profile.contract_version
+ },
+ fixture: fixture(`${food}numeric_boundaries.v1.json`, index, row.id),
+ oracle_revision: revision,
+ expected: row.expected,
+ participation: {
+ rust_oracle: 'REQUIRED',
+ native_consumer: 'REQUIRED_NATIVE_TEST',
+ typescript:
+ row.expected.typescript.result === 'unsupported'
+ ? 'UNSUPPORTED_JAVASCRIPT_U64'
+ : 'food_boundary',
+ unsupported_reason: row.expected.typescript.reason ?? null
+ }
+ }));
+ const cases = [...publicCases, ...writers, ...boundaryCases];
+ assert.equal(cases.length, 66);
assert.equal(new Set(cases.map((row) => row.id)).size, cases.length);
assert.equal(
publicCases.filter((row) => row.participation.typescript === 'food_reader')
@@ -181,9 +224,7 @@ export function buildInteropManifest(
'Derived metadata and expectations, not a second editable protocol policy.'
},
pending_checks: [
- 'native_consumer_HCR014',
'combined_orchestration_HCR015',
- 'native_full_u64_vs_unsafe_js_common_boundary_HCR014',
'Message_adapters_HCP071_HCP130',
'deployed_Tera_qualification'
],
diff --git a/web/tools/generate-interop-manifest.mjs b/web/tools/generate-interop-manifest.mjs
@@ -73,7 +73,8 @@ console.log(
website_cases: 16,
signed_reader_cases: 18,
revision: manifest.oracle.revision,
- native_consumer: 'PENDING_HCR014',
+ native_consumer: 'REQUIRED_NATIVE_TEST',
+ boundary_cases: 10,
qualification: manifest.qualification,
action: args[0] === '--write' ? 'EXPLICIT_GENERATION' : 'CHECK_ONLY'
})