Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@
"sha256": "83279cfa6d46b15f2a41e8849422a934613fc80f4554b73a156be5a4b9deeffc"
},
{
"bytes": 227119,
"bytes": 235931,
"license": "MIT",
"path": "crates/labcolors-core/src/program_session.rs",
"role": "program_source",
"sha256": "ba097479052d32a71b5d167d63c04b35928c7e888945eddbab6b6acf49c0ea5c"
"sha256": "4ef60e5e93f5efd7631dd0dc198feb9385c6b8efc0fc66fa43e837aa964c6ab9"
},
{
"bytes": 21872,
Expand All @@ -125,11 +125,11 @@
"sha256": "aa6aa7c0b630437f1c1ba8c2ceafb0dadf6551c42331559504076a6cd44e6331"
},
{
"bytes": 27055,
"bytes": 27141,
"license": "MIT",
"path": "crates/labcolors-core/src/session.rs",
"role": "session_runtime_source",
"sha256": "38c65b46a3e392b399092e8c4834d7f31acb2b91eff626d6faa1b1aaa90b52f3"
"sha256": "67245bc8b35f32edbd159ad5ffed4a26c5e276a6ef44d5e4ab319a5ab17b4d4a"
},
{
"bytes": 34105,
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ac397fa06ead9b3c981653271e8a019f8909306e8125f07f35eb5ab249d346eb receipt-v1.json
1624e1b90bc0c7962997cb1c13264613d9f16182d33efa4c597a8ed77d2e1d90 receipt-v1.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions crates/labcolors-core/src/generic_boundary_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1323,9 +1323,9 @@ fn shared_observation_ssot_has_one_backing_without_lifecycle_or_adapter_facades(
"compiled schema and observations must share the same Rc-backed schema",
);
assert!(
OBSERVATION_SOURCE.contains(
"#[derive(Debug, PartialEq, Eq)]\n#[cfg_attr(test, derive(Clone))]\npub(crate) struct CanonicalObservationSchemaV1",
),
OBSERVATION_SOURCE.contains("#[derive(Debug, PartialEq, Eq)]")
&& OBSERVATION_SOURCE.contains("#[cfg_attr(test, derive(Clone))]")
&& OBSERVATION_SOURCE.contains("pub(crate) struct CanonicalObservationSchemaV1"),
Comment thread
lemone112 marked this conversation as resolved.
Outdated
"production schema ownership must not expose a general Clone capability",
);
assert_eq!(
Expand Down Expand Up @@ -1891,7 +1891,7 @@ fn program_session_keeps_physical_evidence_separate_from_lazy_lcs_capability() {
let lcs_adapter = source_scope(
CONSTRAINTS_SOURCE,
"pub(crate) struct ProgramLcsPointAdapterV1 {",
"#[cfg(test)]\nimpl Evaluator<ProgramLcsPointTargetV1>",
"impl Evaluator<ProgramLcsPointTargetV1>",
);
assert!(
!lcs_adapter.contains("Option<ModeledLcsOccurrenceV1>"),
Expand Down
1 change: 1 addition & 0 deletions crates/labcolors-core/src/point_support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ impl SessionPlanV1 for CompiledPointSupportRecheckV1 {
&mut self,
_owner: &Self::OwnerLease,
observation: RevisionBoundObservationV1,
_previous: Option<&Self::Verified>,
_permit: SessionObservationBindingPermitV1,
) -> Result<SessionDecision<Self::Verified, Self::Violation>, Self::Error> {
let assessment = evaluate_bound_point_support(self, &observation)?;
Expand Down
229 changes: 229 additions & 0 deletions crates/labcolors-core/src/private_fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,8 @@ mod tests {
use core::cell::{Cell, RefCell, UnsafeCell};
use std::rc::Rc;

use crate::program_session::CORE_PROGRAM_ASSESSMENT_CALLS;

use super::*;

#[derive(Debug, Default)]
Expand Down Expand Up @@ -2202,4 +2204,231 @@ mod tests {
Srgb8::new([64, 64, 64])
);
}

fn two_case_opaque_authored() -> AuthoredPrivateFixtureV1 {
AuthoredPrivateFixtureV1 {
source: Srgb8::new([64, 64, 64]),
opacity: 1.0,
appearance: AuthoredAppearanceV1 {
adapting_luminance_cd_m2: 64.0,
background_luminance_ratio_yb_yw: 0.2,
surround: AuthoredSurroundV1::Dim,
},
expected_final_visible: Srgb8::new([64, 64, 64]),
sink_output: 501,
stream: 31,
revision: 1,
scenarios: ScenarioWireSetV2 {
len: 2,
values: [
ScenarioWireV2 {
id: 1,
backdrop: Srgb8::new([128, 128, 128]),
},
ScenarioWireV2 {
id: 2,
backdrop: Srgb8::new([192, 192, 192]),
},
],
},
}
Comment thread
lemone112 marked this conversation as resolved.
}

fn two_case_observed_update(
revision: u64,
first: Srgb8,
second: Srgb8,
) -> ObservationUpdateWireV2 {
ObservationUpdateWireV2::Observed {
stream: 31,
revision,
scenarios: ScenarioWireSetV2 {
len: 2,
values: [
ScenarioWireV2 {
id: 1,
backdrop: first,
},
ScenarioWireV2 {
id: 2,
backdrop: second,
},
],
},
}
}

fn two_case_active_instance() -> (
PrivateFixtureInstanceV1<NativeFixtureHostV1>,
Rc<RefCell<HostOracleV1>>,
CertifiedPrivateFixtureResultV1,
) {
let mut instance = PrivateFixtureInstanceV1::new();
let generation = instance.begin_run().unwrap();
let (host, oracle) = native_host(generation);
let executed = execute_private_fixture_v1(two_case_opaque_authored(), host).unwrap();
let initial = instance
.complete_run(generation, executed)
.unwrap()
.unwrap();
(instance, oracle, initial)
}

#[test]
fn unchanged_cases_skip_evaluator_work_on_revision_only_update() {
let (mut instance, _oracle, initial) = two_case_active_instance();
CORE_PROGRAM_ASSESSMENT_CALLS.with(|calls| calls.set(0));

let updated = instance
.update(two_case_observed_update(
2,
Srgb8::new([128, 128, 128]),
Srgb8::new([192, 192, 192]),
))
.unwrap();

assert_eq!(updated.state, PrivateFixtureStateV2::Ready);
assert_eq!(updated.revision, 2);
assert_eq!(updated.content_identity, initial.content_identity);
assert_eq!(updated.paint_source, initial.paint_source);
assert_eq!(updated.paint_opacity_bits, initial.paint_opacity_bits);
assert_eq!(
CORE_PROGRAM_ASSESSMENT_CALLS.with(Cell::get),
0,
"an unchanged observation must not re-run the evaluator"
);
}

#[test]
fn single_changed_case_recomputes_only_the_affected_case() {
let (mut instance, _oracle, _initial) = two_case_active_instance();
CORE_PROGRAM_ASSESSMENT_CALLS.with(|calls| calls.set(0));

let updated = instance
.update(two_case_observed_update(
2,
Srgb8::new([129, 129, 129]),
Srgb8::new([192, 192, 192]),
))
.unwrap();

assert_eq!(updated.state, PrivateFixtureStateV2::Ready);
assert_eq!(updated.revision, 2);
assert_eq!(
CORE_PROGRAM_ASSESSMENT_CALLS.with(Cell::get),
1,
"a single changed case must recompute exactly that case"
);
}

#[test]
fn incremental_revision_update_parities_fresh_full_resolve() {
let mut authored = two_case_opaque_authored();
authored.revision = 2;
let fresh = run_details(authored);
assert_eq!(fresh.status, 0);

let (mut instance, _oracle, _initial) = two_case_active_instance();
let updated = instance
.update(two_case_observed_update(
2,
Srgb8::new([128, 128, 128]),
Srgb8::new([192, 192, 192]),
))
.unwrap();

assert_eq!(encode_result_v1(updated), fresh.result);
}

#[test]
fn changed_every_case_full_resolve_parities_and_stays_certified() {
let mut authored = two_case_opaque_authored();
authored.revision = 2;
authored.scenarios.values = [
ScenarioWireV2 {
id: 1,
backdrop: Srgb8::new([1, 2, 3]),
},
ScenarioWireV2 {
id: 2,
backdrop: Srgb8::new([250, 251, 252]),
},
];
let fresh = run_details(authored);
assert_eq!(fresh.status, 0);

let (mut instance, _oracle, _initial) = two_case_active_instance();
CORE_PROGRAM_ASSESSMENT_CALLS.with(|calls| calls.set(0));
let updated = instance
.update(two_case_observed_update(
2,
Srgb8::new([1, 2, 3]),
Srgb8::new([250, 251, 252]),
))
.unwrap();

assert_eq!(updated.state, PrivateFixtureStateV2::Ready);
assert_eq!(updated.revision, 2);
assert_eq!(encode_result_v1(updated), fresh.result);
assert_eq!(CORE_PROGRAM_ASSESSMENT_CALLS.with(Cell::get), 2);
}

#[test]
fn conflicting_revisions_are_rejected_and_the_baseline_is_preserved() {
let (mut instance, _oracle, initial) = two_case_active_instance();

assert_eq!(
instance.update(two_case_observed_update(
0,
Srgb8::new([128, 128, 128]),
Srgb8::new([192, 192, 192]),
)),
Err(PrivateFixtureErrorV1::UpdateRejected)
);
assert_eq!(
instance.update(two_case_observed_update(
1,
Srgb8::new([1, 2, 3]),
Srgb8::new([192, 192, 192]),
)),
Err(PrivateFixtureErrorV1::UpdateRejected)
);

let replay = instance
.update(two_case_observed_update(
2,
Srgb8::new([128, 128, 128]),
Srgb8::new([192, 192, 192]),
))
.unwrap();
assert_eq!(replay.revision, 2);
assert_eq!(replay.content_identity, initial.content_identity);
}

#[test]
fn unknown_transition_preserves_the_ready_baseline_for_later_reuse() {
let (mut instance, _oracle, initial) = two_case_active_instance();

let unknown = instance
.update(ObservationUpdateWireV2::Unknown {
stream: 31,
revision: 2,
reason: 7,
})
.unwrap();
assert_eq!(unknown.state, PrivateFixtureStateV2::Stale);
assert_eq!(unknown.revision, 2);
assert_eq!(unknown.output, 0);

let recovered = instance
.update(two_case_observed_update(
3,
Srgb8::new([128, 128, 128]),
Srgb8::new([192, 192, 192]),
))
.unwrap();
assert_eq!(recovered.state, PrivateFixtureStateV2::Ready);
assert_eq!(recovered.revision, 3);
assert_eq!(recovered.content_identity, initial.content_identity);
}
Comment thread
lemone112 marked this conversation as resolved.
}
Loading
Loading