Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
49 changes: 35 additions & 14 deletions crates/labcolors-core/contracts/clean-set-srgb8-v1/receipt-v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
},
"artifacts": [
{
"bytes": 84737,
"bytes": 85483,
"license": "MIT",
"path": "crates/labcolors-core/src/appearance.rs",
"role": "appearance_executor_source",
"sha256": "2302258dec70a76acbb4ac5c3a1a472997716c3e58fc7bc1b9aaeb105526a709"
"sha256": "99e3172a91b91e702b0c65935ccd1f9ac630e054671a162cd9927520bd9bd0a3"
},
{
"bytes": 6373,
Expand Down Expand Up @@ -62,11 +62,32 @@
"sha256": "8c9838107077775c51d80638ba0b59f9672d14347ca404dfd4c63e2fb62d1c45"
},
{
"bytes": 173158,
"bytes": 37994,
"license": "MIT",
"path": "crates/labcolors-core/src/program/attachment.rs",
"role": "point_attachment_source",
"sha256": "c8a15ef0efcae327a6735c08a46f751946cee48752e8a529391ae2366112d766"
},
{
"bytes": 16857,
"license": "MIT",
"path": "crates/labcolors-core/src/program/attachment/support.rs",
"role": "point_attachment_test_support",
"sha256": "6c1a336c40eeffc6ccce4afaa9c3dada311d221c35d594a731561179259568d6"
},
{
"bytes": 27692,
"license": "MIT",
"path": "crates/labcolors-core/src/program/attachment/tests.rs",
"role": "point_attachment_tests",
"sha256": "6b55723fefcf25c8500afd36a50c9bbe47e20ba001f61f361acf72724aeb24d7"
},
{
"bytes": 162073,
"license": "MIT",
"path": "crates/labcolors-core/src/program.rs",
"role": "program_facade_source",
"sha256": "b93e1d066d03d28abc49bdfd492025da7c8fd8531fd19d8ab29526aeeb29a7ae"
"sha256": "1f8e732bf70876cbc69ddfaf2503a682bdf1e2881f3655961386c2472d875976"
},
{
"bytes": 71522,
Expand All @@ -76,18 +97,18 @@
"sha256": "8f0366079e6fa0006360ab19b0449e622add48fdb08431a02258236e1371d78a"
},
{
"bytes": 154789,
"bytes": 159084,
"license": "MIT",
"path": "crates/labcolors-core/src/program_session.rs",
"role": "program_source",
"sha256": "a236381dcf80760e1ea39743b3a20d10de938fe1a9d6c64e9a9075f6265b6eb3"
"sha256": "141e69abffa86dc01e69b439a7e48932f8aed9c0f042f9725f1d883e522eeae4"
},
{
"bytes": 21649,
"bytes": 21546,
"license": "MIT",
"path": "crates/labcolors-core/src/program_clean_set_tests.rs",
"role": "program_tests",
"sha256": "30bbb97208b428d2ca0e5a230bffa0e2a8e1ede5b0b071979c7a7b2590f57d93"
"sha256": "44c30c5e10494dec4d6865e4597cf9f5e616955eff8279bb606d1f5a9f3ce35f"
},
{
"bytes": 11370,
Expand All @@ -97,11 +118,11 @@
"sha256": "aa6aa7c0b630437f1c1ba8c2ceafb0dadf6551c42331559504076a6cd44e6331"
},
{
"bytes": 15043,
"bytes": 21061,
"license": "MIT",
"path": "crates/labcolors-core/src/session.rs",
"role": "session_runtime_source",
"sha256": "4c24ffb02ac5909d8436410ba233aec8abd99156e55ac9d65232ca614de92905"
"sha256": "faf5bdffa7bc82a17d4ead99d34f1a22c24b0b511e253e8280ded86629c24e2e"
},
{
"bytes": 34105,
Expand All @@ -118,18 +139,18 @@
"sha256": "6c95324eb05476f35f75375a9af0b2b4a41b8b2978c46e67d2ce1aea5adde342"
},
{
"bytes": 39302,
"bytes": 39567,
"license": "MIT",
"path": "scripts/verify_clean_set_receipt.py",
"role": "verifier_source",
"sha256": "c6d9025235c1c53b54ce4c7b231fb02a412d5505740f82cdbba42f80ea375472"
"sha256": "6e07ec6d9d72e5cfe084773b27e45cf6ea7df8c98eca860d19f8646a893afd62"
},
{
"bytes": 31194,
"bytes": 32751,
"license": "MIT",
"path": "scripts/test_verify_clean_set_receipt.py",
"role": "verifier_tests",
"sha256": "2831e67431294c28ba60753a892d0ad5e3ff972144d483500eeb10c47bb9d760"
"sha256": "b46386785ccd6d7a87051b6656486f16e17f51fad93f3d865ad39139518dda4b"
}
],
"excluded_claims": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e55be72b39800c75b3009378734089b2474041e8598557e3ac3f82dbe67dc985 receipt-v1.json
9190d17fe46f6588cd26fd0a65eed4956afbffefba7d1ef34e192fcf0922f418 receipt-v1.json

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions crates/labcolors-core/src/appearance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1935,6 +1935,21 @@ impl CompiledAppearanceGraph {
Some(CompiledOccurrenceSlotV1 { index, id })
}

/// Находит объявленный subject Paint одного канонического Occurrence.
///
/// Cold compiler lookup не читает вычисленные значения и не создаёт
/// runtime-состояние. Hot path сохраняет полученный Paint ID в закрытом
/// compiled binding вместо повторного поиска.
pub(crate) fn occurrence_subject(&self, id: OccurrenceId) -> Option<PaintId> {
let index = self
.occurrences
.binary_search_by_key(&id, |occurrence| occurrence.id)
.ok()?;
self.occurrences
.get(index)
.map(|occurrence| occurrence.subject_id)
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

/// Создаёт полномочие только для `Occurrence`, который не потребляется
/// другим `Occurrence` этого точечного графа: промежуточный слой нельзя
/// принять за финальный моделируемый результат.
Expand Down
18 changes: 18 additions & 0 deletions crates/labcolors-core/src/appearance_graph_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,24 @@ fn compiled_slots_have_canonical_ordinals_across_declaration_permutations() {
}
}

#[test]
fn occurrence_subject_is_an_exact_cold_lookup_across_declaration_permutations() {
let canonical = slot_component(false).compile().unwrap();
let reversed = slot_component(true).compile().unwrap();

for (occurrence, subject) in [
(FILL_OCCURRENCE, FILL_PAINT),
(OTHER_OCCURRENCE, SOLID_PAINT),
] {
assert_eq!(canonical.occurrence_subject(occurrence), Some(subject));
assert_eq!(reversed.occurrence_subject(occurrence), Some(subject));
}
assert_eq!(
canonical.occurrence_subject(OccurrenceId::new(u32::MAX)),
None
);
}

#[test]
fn evaluation_view_rejects_same_ordinal_slots_with_different_nominal_ids() {
let compile_single = |paint, occurrence| {
Expand Down
113 changes: 58 additions & 55 deletions crates/labcolors-core/src/generic_boundary_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,25 @@ const LIB_SOURCE: &str = include_str!("lib.rs");
const LCS_OCCURRENCE_SOURCE: &str = include_str!("lcs_occurrence.rs");
const OBSERVATION_SOURCE: &str = include_str!("observation.rs");
const OUTPUT_PROJECTION_SOURCE: &str = include_str!("output_projection.rs");
const PROGRAM_ATTACHMENT_SOURCE: &str = include_str!("program/attachment.rs");
const PROGRAM_SOURCE: &str = include_str!("program.rs");
const POINT_SUPPORT_SOURCE: &str = include_str!("point_support.rs");
const PROGRAM_IDENTITY_SOURCE: &str = include_str!("program_identity.rs");
const PROGRAM_SESSION_SOURCE: &str = include_str!("program_session.rs");
const SESSION_SOURCE: &str = include_str!("session.rs");
const WCAG22_CONSTRAINT_SOURCE: &str = include_str!("constraints/wcag22.rs");

const GENERIC_SOURCES: [(&str, &str); 4] = [
const GENERIC_SOURCES: [(&str, &str); 5] = [
("appearance.rs", APPEARANCE_SOURCE),
("lcs_occurrence.rs", LCS_OCCURRENCE_SOURCE),
("program/attachment.rs", PROGRAM_ATTACHMENT_SOURCE),
("program_identity.rs", PROGRAM_IDENTITY_SOURCE),
("program_session.rs", PROGRAM_SESSION_SOURCE),
];

const CLEAN_SET_PROGRAM_SOURCES: &[(&str, &str)] = &[
("clean_set.rs", CLEAN_SET_SOURCE),
("program/attachment.rs", PROGRAM_ATTACHMENT_SOURCE),
("program.rs", PROGRAM_SOURCE),
("program_session.rs", PROGRAM_SESSION_SOURCE),
("program_identity.rs", PROGRAM_IDENTITY_SOURCE),
Expand Down Expand Up @@ -138,6 +141,7 @@ fn clean_set_program_guard_covers_the_complete_classifier_and_program_path() {
[
"clean_set.rs",
"program.rs",
"program/attachment.rs",
"program_identity.rs",
"program_session.rs",
],
Expand Down Expand Up @@ -355,7 +359,7 @@ fn staged_program_draft_wraps_the_single_canonical_core_graph() {
}

#[test]
fn staged_session_keeps_evidence_but_owner_alone_grants_updates_and_operations() {
fn staged_session_is_evidence_only_and_retired_operation_authority_cannot_return() {
assert_eq!(
normalized_source_scope(
PROGRAM_SOURCE,
Expand Down Expand Up @@ -402,7 +406,7 @@ fn staged_session_keeps_evidence_but_owner_alone_grants_updates_and_operations()
let evidence_api = source_scope(
PROGRAM_SOURCE,
"impl<'a> EvidenceViewV1<'a> {",
"struct BorrowScopeV1<'owner, 'session>",
"/// Полностью вычисленный, но ещё не опубликованный переход одной Session.",
);
for forbidden in [
"fn revision(",
Expand All @@ -422,18 +426,18 @@ fn staged_session_keeps_evidence_but_owner_alone_grants_updates_and_operations()
"pub(crate) struct ScenarioV1<'a> {",
);
for required in [
"pub(crate) fn project<'owner, 'session>(",
"pub(crate) fn prepare_update<'owner, 'session>(",
"pub(crate) fn prepare_update<'session>(",
".owns_session(&session.session)",
"pub(crate) fn instantiate(",
] {
assert!(
owner_api.contains(required),
"the exact owner must remain the only operation authority; missing `{required}`",
"the evidence-only owner/session seam is incomplete; missing `{required}`",
);
}
let prepare = source_scope(
owner_api,
"pub(crate) fn prepare_update<'owner, 'session>(",
"pub(crate) fn prepare_update<'session>(",
"pub(crate) fn instantiate(",
);
assert!(
Expand All @@ -445,10 +449,20 @@ fn staged_session_keeps_evidence_but_owner_alone_grants_updates_and_operations()
.expect("owner prepare must delegate one prepared Session transition"),
"owner mismatch must be rejected before admission, allocation, or evaluation",
);
assert!(
!owner_api.contains("pub(crate) fn update<'owner, 'session>("),
"Owner must not retain an immediate prepare-and-commit authority",
);
for forbidden in [
"pub(crate) fn project(",
"pub(crate) fn update(",
"OperationV1",
"SetV1",
"RemoveV1",
"HoldV1",
"BorrowScopeV1",
] {
assert!(
!PROGRAM_SOURCE.contains(forbidden),
"evidence must not regain retired sink authority `{forbidden}`",
);
}

let session_code = normalized_production_code(SESSION_SOURCE);
let program_code = normalized_production_code(PROGRAM_SOURCE);
Expand Down Expand Up @@ -519,29 +533,50 @@ fn staged_session_keeps_evidence_but_owner_alone_grants_updates_and_operations()
"commit must remain infallible move-only publication; found `{forbidden}`",
);
}
for required in ["drop(owner);", "*raw_head =", "*state = next_state;"] {
for required in [
"let (view, retirement) = self.commit_deferred();",
"drop(retirement);",
"mem::replace(raw_head,",
"mem::replace(state, next_state)",
"_owner: owner,",
] {
assert!(
core_commit.contains(required),
"commit must publish under the pinned owner; missing `{required}`",
);
}
let owner_release = core_commit
.find("drop(owner);")
.expect("commit must release its exact owner explicitly");
for publication in ["*raw_head =", "*state = next_state;"] {
let owner_retirement = core_commit
.find("_owner: owner,")
.expect("deferred commit must park its exact owner");
for publication in ["mem::replace(raw_head,", "mem::replace(state, next_state)"] {
let last_publication = core_commit
.rfind(publication)
.unwrap_or_else(|| panic!("commit must contain `{publication}`"));
assert!(
last_publication < owner_release,
"every `{publication}` path must publish before releasing the exact owner",
last_publication < owner_retirement,
"every `{publication}` path must publish before parking the exact owner",
);
}
let deferred_retirement = source_scope(
SESSION_SOURCE,
"pub(crate) struct DeferredSessionRetirement<Plan: SessionPlanV1>",
"/// Линейный, полностью вычисленный",
);
let retired_evidence = deferred_retirement
.find("_retired_verified: Option<Plan::Verified>,")
.expect("retirement must own displaced verified evidence");
let retired_owner = deferred_retirement
.find("_owner: Plan::OwnerLease,")
.expect("retirement must retain the exact owner");
assert!(
retired_evidence < retired_owner,
"retired evidence must drop before its exact owner",
);

let concrete_prepared = source_scope(
PROGRAM_SOURCE,
"/// Полностью вычисленный, но ещё не опубликованный переход одной Session.",
"impl<'owner, 'session> PreparedSessionTransitionV1<'owner, 'session>",
"impl<'session> PreparedSessionTransitionV1<'session>",
);
let concrete_must_use =
"#[must_use = \"commit the prepared transition or drop it intentionally\"]";
Expand All @@ -562,25 +597,14 @@ fn staged_session_keeps_evidence_but_owner_alone_grants_updates_and_operations()

let concrete_commit = source_scope(
PROGRAM_SOURCE,
"impl<'owner, 'session> PreparedSessionTransitionV1<'owner, 'session>",
"/// Проверенная Owner-and-snapshot проекция",
"impl<'session> PreparedSessionTransitionV1<'session>",
"/// Collision-resistant адрес канонического физического содержания Program.",
);
assert!(
concrete_commit.contains("session: transition.commit(),")
concrete_commit.contains("session: self.transition.commit(),")
&& !concrete_commit.contains("Result<")
&& !concrete_commit.contains("?;"),
"Program commit must only project the already committed Session view",
);

let staged_access_errors = source_scope(
PROGRAM_SOURCE,
"pub(crate) enum AccessErrorV1 {",
"impl OwnerV1",
);
assert!(
staged_access_errors.contains("OwnerMismatch,")
&& !staged_access_errors.contains("OwnerExpired"),
"operation projection must distinguish foreign ownership, not expose internal expiry",
"evidence-only commit must only project the already committed Session view",
);
let staged_update_errors = source_scope(
PROGRAM_SOURCE,
Expand All @@ -601,27 +625,6 @@ fn staged_session_keeps_evidence_but_owner_alone_grants_updates_and_operations()
.contains("fn map_plan_error(error: CoreProgramPlanErrorV1) -> UpdateErrorV1",),
"update errors must retain payloads in the authoritative enum before kind projection",
);

for (payload, end) in [
(
"pub(crate) struct SetV1<'owner, 'session> {",
"impl<'session> SetV1<'_, 'session>",
),
(
"pub(crate) struct RemoveV1<'owner, 'session> {",
"impl RemoveV1<'_, '_>",
),
] {
assert!(
source_scope(PROGRAM_SOURCE, payload, end)
.contains("_scope: BorrowScopeV1<'owner, 'session>,"),
"{payload} must retain both owner and immutable Session borrows",
);
}
assert!(
!PROGRAM_SOURCE.contains("HoldV1") && !PROGRAM_SOURCE.contains("OperationV1::Hold"),
"past evidence must not become a current emission authority",
);
}

#[test]
Expand Down
Loading
Loading