Skip to content
Closed
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
1 change: 0 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,6 @@ jobs:
"stable-cam16-glow-target-or-maximum-selection",
"renderer-or-output-pipeline-equivalence",
"spatial-glow-field",
"display-p3",
];
if (
JSON.stringify(manifest.supported) !== JSON.stringify(expectedSupported) ||
Expand Down
2 changes: 1 addition & 1 deletion bindings/swift/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Swift/UniFFI evidence сейчас ограничено описанным вы
runtime. Solve-hex — квантование трансцендентного резолва, ±1 LSB на канал.
Неуспешный solve возвращает `ColorError.Failure(category, code)`: category —
закрытый enum `FailureCategory`, а не произвольная строка. Он
отделяет доказанную `unreachable` от `unresolved`, `rejected` и `unsupported`,
отделяет доказанную `unreachable` от `unresolved` и `rejected`,
а code задаёт конкретную машинную причину. Оба поля приходят из одного
core-owned descriptor и проверяются conformance-паком.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ final class ConformanceTests: XCTestCase {
case "unreachable": return .unreachable
case "unresolved": return .unresolved
case "rejected": return .rejected
case "unsupported": return .unsupported
default: fatalError("неизвестная failure category в pack: \(key)")
}
}
Expand Down
2 changes: 1 addition & 1 deletion conformance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ adjacent bytes или нормативного отношения пересчи
- `(category, code)` — атомарная core-owned классификация, общая для всех
биндингов: `unreachable/exceeds_range`, `unreachable/floor_unreachable`,
`unresolved/bounded_search_exhausted`, `rejected/invalid_input`,
`unreachable/below_contrast_floor` и `unsupported/gamut_unsupported`. Только
`unreachable/below_contrast_floor`. Только
`unreachable` доказывает отсутствие
решения в объявленном полном domain; `unresolved` не делает утверждения о
непроверенных кандидатах.
Expand Down
3 changes: 1 addition & 2 deletions crates/labcolors-conformance/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ pub enum SolveOutcome {
floor_override: bool,
},
/// Resolver не вернул цвет; category отделяет доказанную недостижимость от
/// unresolved, rejected и unsupported исходов.
/// unresolved и rejected исходов.
Failure {
/// Стабильная семантическая категория core failure.
category: String,
Expand Down Expand Up @@ -883,7 +883,6 @@ mod tests {
"unreachable",
"floor_unreachable",
),
(F::GamutUnsupported, "unsupported", "gamut_unsupported"),
(
F::InvalidInput("fixture".into()),
"rejected",
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
"bg=#FFFFFF contract=text(150) floor=default hue=264 chroma=neutral": "err exceeds_range target_bits=4062c00000000000 max_achievable_bits=405a829a490ad002",
"bg=#FFFFFF contract=text(3) floor=none hue=0 chroma=neutral": "err below_contrast_floor target_bits=4008000000000000",
"bg=#FFFFFF contract=text(30) floor=default hue=264 chroma=neutral": "ok hex=#767676 lc_bits=40510fca61d5b9ee wcag_ratio_bits=40122b3d05125164 floor_override=true jp_bits=404a3678a8f0c874 h_ok_bits=0000000000000000 s_bits=3f92a6b801503a78",
"bg=#FFFFFF contract=text(60) floor=default hue=0 chroma=neutral gamut=display-p3": "err gamut_unsupported",
"bg=#FFFFFF contract=text(60) floor=default hue=264 chroma=neutral": "ok hex=#767676 lc_bits=40510fca61d5b9ee wcag_ratio_bits=40122b3d05125164 floor_override=true jp_bits=404a3678a8f0c874 h_ok_bits=0000000000000000 s_bits=3f92a6b801503a78",
"bg=#FFFFFF contract=text(7.3) floor=none hue=0 chroma=neutral": "ok hex=#EDEDED lc_bits=401e6aa8625b8742 wcag_ratio_bits=3ff2bb539763a677 floor_override=false jp_bits=4057afba8603b8da h_ok_bits=0000000000000000 s_bits=3f8f614c4436cac4",
"bg=#FFFFFF contract=text(7.35) floor=none hue=0 chroma=neutral": "ok hex=#EDEDED lc_bits=401e6aa8625b8742 wcag_ratio_bits=3ff2bb539763a677 floor_override=false jp_bits=4057afba8603b8da h_ok_bits=0000000000000000 s_bits=3f8f614c4436cac4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
"bg=#FFFFFF contract=text(150) floor=default hue=264 chroma=neutral": "err exceeds_range target_bits=4062c00000000000 max_achievable_bits=405a829a490ad002",
"bg=#FFFFFF contract=text(3) floor=none hue=0 chroma=neutral": "err below_contrast_floor target_bits=4008000000000000",
"bg=#FFFFFF contract=text(30) floor=default hue=264 chroma=neutral": "ok hex=#767676 lc_bits=40510fca61d5b9ee wcag_ratio_bits=40122b3d05125164 floor_override=true jp_bits=404a3678a8f0c874 h_ok_bits=0000000000000000 s_bits=3f92a6b801503a78",
"bg=#FFFFFF contract=text(60) floor=default hue=0 chroma=neutral gamut=display-p3": "err gamut_unsupported",
"bg=#FFFFFF contract=text(60) floor=default hue=264 chroma=neutral": "ok hex=#767676 lc_bits=40510fca61d5b9ee wcag_ratio_bits=40122b3d05125164 floor_override=true jp_bits=404a3678a8f0c874 h_ok_bits=0000000000000000 s_bits=3f92a6b801503a78",
"bg=#FFFFFF contract=text(7.3) floor=none hue=0 chroma=neutral": "ok hex=#EDEDED lc_bits=401e6aa8625b8742 wcag_ratio_bits=3ff2bb539763a677 floor_override=false jp_bits=4057afba8603b8da h_ok_bits=0000000000000000 s_bits=3f8f614c4436cac4",
"bg=#FFFFFF contract=text(7.35) floor=none hue=0 chroma=neutral": "ok hex=#EDEDED lc_bits=401e6aa8625b8742 wcag_ratio_bits=3ff2bb539763a677 floor_override=false jp_bits=4057afba8603b8da h_ok_bits=0000000000000000 s_bits=3f8f614c4436cac4",
Expand Down
1 change: 0 additions & 1 deletion crates/labcolors-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ pub use solve::{
SolveFailureCategory, SolveJob, Solved, solve, solve_many,
};
pub use spaces::oklch::{css_alpha_value, oklch_css_from_hex, oklch_from_hex};
pub use spaces::p3::{p3_css_from_hex, p3_from_hex};
pub use spaces::srgb::srgb_encoded_from_hex;
pub use spaces::vc::ViewingConditions;

Expand Down
14 changes: 4 additions & 10 deletions crates/labcolors-core/src/scale.rs
Original file line number Diff line number Diff line change
Expand Up @@ -752,16 +752,10 @@ fn quadratic_roots(d: f64, c: f64, b: f64) -> ([f64; 3], usize) {
(roots, 2)
}

/// Стена гамута **Display P3** при `(L, h)` — та же бисекция, что
/// [`max_chroma_bisect`], но валидность кандидата проверяется в ЛИНЕЙНОМ P3
/// (Oklab → линейный sRGB → XYZ → линейный P3; первые два шага — линейная
/// алгебра, корректная и за пределами sRGB-куба).
///
/// Этап 1 gamut-aware солвера (2026-07-03): геометрия стен и решётка эмиссии;
/// перевод `Solved`/эмиссии на P3-кандидаты — этап 2. Чистая гамут-геометрия
/// CSS Color 4 матриц — нуля подгонки (класс M-13 инвентаря).
// Прод-потребитель — этап 2 (P3-кандидаты солвера); до него читается тестами.
#[cfg_attr(not(test), allow(dead_code))]
/// Test-only physical Display P3 gamut boundary. This is geometry, not a
/// released output capability: no production selector, encoder, or verifier
/// consumes it yet.
#[cfg(test)]
pub(crate) fn max_chroma_p3_bisect(l_ok: f64, h_ok_deg: f64) -> f64 {
let h_ok = h_ok_deg.to_radians();
let cos_h = h_ok.cos();
Expand Down
63 changes: 20 additions & 43 deletions crates/labcolors-core/src/semantic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
//! текущего фона и viewing conditions; сериализация принадлежит биндингу.
//!
//! Граница набора атомарна. Доказанная недостижимость и незавершённый bounded
//! search остаются типизированными исходами отдельных ролей; rejected,
//! unsupported и internal закрывают вызов через [`ResolveSetError`] без
//! search остаются типизированными исходами отдельных ролей; rejected и
//! internal закрывают вызов через [`ResolveSetError`] без
//! частичного успешного вектора. Нулевое значение представлено явно через
//! [`Resolved::None`].
//!
Expand Down Expand Up @@ -1335,8 +1335,6 @@ impl std::error::Error for RoleFailure {
pub enum ResolveSetErrorKind {
/// Значение запроса вышло за объявленный домен.
Rejected,
/// Запрос требует capability, которую этот резолвер не реализует.
Unsupported,
/// Состояние, произведённое ядром, нарушило внутренний постинвариант.
Internal,
}
Expand All @@ -1346,7 +1344,6 @@ impl ResolveSetErrorKind {
pub const fn as_str(self) -> &'static str {
match self {
Self::Rejected => SolveFailureCategory::Rejected.as_str(),
Self::Unsupported => SolveFailureCategory::Unsupported.as_str(),
Self::Internal => "internal",
}
}
Expand All @@ -1355,16 +1352,15 @@ impl ResolveSetErrorKind {
#[derive(Debug, Clone, PartialEq)]
enum ResolveSetErrorState {
Rejected(BoundaryFailure),
Unsupported(BoundaryFailure),
Internal(SolveFailure),
}

/// Отказ всего набора из [`resolve_named_set`].
///
/// Rejected-запросы, неподдержанные capability и внутренний дрейф закрывают
/// весь вызов. Конструкторы приватны; допуск делит [`SolveFailure::boundary`]
/// с [`RoleFailure`], а [`Self::kind`] и [`Self::code`] остаются
/// авторитетной whole-call-классификацией.
/// Rejected-запросы и внутренний дрейф закрывают весь вызов. Конструкторы
/// приватны; допуск делит [`SolveFailure::boundary`] с [`RoleFailure`], а
/// [`Self::kind`] и [`Self::code`] остаются авторитетной whole-call-
/// классификацией.
#[derive(Debug, Clone, PartialEq)]
pub struct ResolveSetError {
state: ResolveSetErrorState,
Expand All @@ -1375,26 +1371,23 @@ impl ResolveSetError {
pub const fn kind(&self) -> ResolveSetErrorKind {
match &self.state {
ResolveSetErrorState::Rejected(_) => ResolveSetErrorKind::Rejected,
ResolveSetErrorState::Unsupported(_) => ResolveSetErrorKind::Unsupported,
ResolveSetErrorState::Internal(_) => ResolveSetErrorKind::Internal,
}
}

/// Стабильный машинный код ядра для rejected/unsupported-отказов.
/// Стабильный машинный код ядра для rejected-отказов.
/// У внутреннего дрейфа намеренно нет публичного solver-кода.
pub const fn code(&self) -> Option<&'static str> {
match &self.state {
ResolveSetErrorState::Rejected(evidence)
| ResolveSetErrorState::Unsupported(evidence) => Some(evidence.boundary.code()),
ResolveSetErrorState::Rejected(evidence) => Some(evidence.boundary.code()),
ResolveSetErrorState::Internal(_) => None,
}
}

/// Структурированный исходный отказ — диагностика и точные evidence-поля.
pub const fn reason(&self) -> &SolveFailure {
match &self.state {
ResolveSetErrorState::Rejected(evidence)
| ResolveSetErrorState::Unsupported(evidence) => &evidence.reason,
ResolveSetErrorState::Rejected(evidence) => &evidence.reason,
ResolveSetErrorState::Internal(reason) => reason,
}
}
Expand All @@ -1418,10 +1411,9 @@ type PendingResolution = Result<Resolved, SolveFailure>;
/// Исход резолва одной допущенной роли: решённый цвет, честный ноль,
/// типизированная численная неопределённость или локальный отказ роли.
///
/// Доказанная недостижимость и незавершённый bounded search отдаются
/// пер-ролью и не маскируются. Rejected/unsupported/internal провенанс в этом
/// типе жить не может: он закрывает [`resolve_named_set`] через
/// [`ResolveSetError`].
/// Доказанная недостижимость и незавершённый bounded search отдаются пер-ролью
/// и не маскируются. Rejected/internal провенанс в этом типе жить не может: он
/// закрывает [`resolve_named_set`] через [`ResolveSetError`].
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive]
pub enum Resolved {
Expand Down Expand Up @@ -1479,9 +1471,6 @@ fn classify_role_failure(reason: SolveFailure) -> Result<RoleFailure, ResolveSet
SolveFailureCategory::Rejected => Err(ResolveSetError {
state: ResolveSetErrorState::Rejected(BoundaryFailure { reason, boundary }),
}),
SolveFailureCategory::Unsupported => Err(ResolveSetError {
state: ResolveSetErrorState::Unsupported(BoundaryFailure { reason, boundary }),
}),
},
None => Err(ResolveSetError {
state: ResolveSetErrorState::Internal(reason),
Expand Down Expand Up @@ -3766,11 +3755,9 @@ fn demotion_outcome(
Err(failure) => match failure.boundary().map(|boundary| boundary.category()) {
Some(SolveFailureCategory::Unreachable) => Ok(None),
Some(SolveFailureCategory::Unresolved) | None => Err(failure),
Some(SolveFailureCategory::Rejected | SolveFailureCategory::Unsupported) => {
Err(SolveFailure::InternalInvariant(format!(
"validated sRGB hierarchy demotion produced {failure}"
)))
}
Some(SolveFailureCategory::Rejected) => Err(SolveFailure::InternalInvariant(format!(
"validated sRGB hierarchy demotion produced {failure}"
))),
},
}
}
Expand Down Expand Up @@ -3990,11 +3977,6 @@ mod tests {
ResolveSetErrorKind::Rejected,
Some("invalid_input"),
),
(
SolveFailure::GamutUnsupported,
ResolveSetErrorKind::Unsupported,
Some("gamut_unsupported"),
),
(
SolveFailure::InternalInvariant("injected drift".into()),
ResolveSetErrorKind::Internal,
Expand Down Expand Up @@ -4258,7 +4240,6 @@ mod tests {
floor: 4.5,
max_ratio: 3.0,
},
SolveFailure::GamutUnsupported,
SolveFailure::InvalidInput("generated probe".into()),
] {
assert!(
Expand Down Expand Up @@ -4319,15 +4300,11 @@ mod tests {
] {
assert_eq!(demotion_outcome(Err(failure), 20.0), Ok(None));
}
for failure in [
SolveFailure::GamutUnsupported,
SolveFailure::InvalidInput("generated request".into()),
] {
assert!(matches!(
demotion_outcome(Err(failure), 20.0),
Err(SolveFailure::InternalInvariant(_))
));
}
let failure = SolveFailure::InvalidInput("generated request".into());
assert!(matches!(
demotion_outcome(Err(failure), 20.0),
Err(SolveFailure::InternalInvariant(_))
));
}

#[test]
Expand Down
Loading
Loading