Skip to content

C8b: единый точечный композитор Core - #357

Merged
lemone112 merged 7 commits into
mainfrom
agent/c8b-canonical-point-compositor
Jul 19, 2026
Merged

C8b: единый точечный композитор Core#357
lemone112 merged 7 commits into
mainfrom
agent/c8b-canonical-point-compositor

Conversation

@lemone112

@lemone112 lemone112 commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

Изменение

  • Один versioned encoded-sRGB8 SourceOver-профиль в Core обслуживает graph occurrence и browser shell.
  • JS больше не владеет формулой композиции; скрытый WASM-мост не входит в публичный package API.
  • Каждое occurrence округляется в sRGB8 до следующего ребра.
  • Public init имеет один one-flight lifecycle и не раскрывает сырой InitOutput.
  • CSS admission отклоняет malformed и non-finite результаты вместо правдоподобного чёрного.
  • Performance-стенд теперь реально проходит 8 translucent layers + opaque root и включает стоимость JS↔WASM boundary.

RED → GREEN

  • Два полупрозрачных слоя: старый JS давал #000000, canonical per-occurrence профиль даёт #010000.
  • Exhaustive 65 536 пар каналов при alpha 0.122 сверены с независимым рациональным oracle.
  • Half-tie, ULP seam, порядок цветных слоёв и fractional channels закреплены anti-vacuum тестами.
  • Concurrent, mixed и reentrant init не создают второй instance и не зависают.
  • Malformed hex, rgb и extreme oklch не проходят в resolver.
  • Старый d8 benchmark не вызывал композитор; новый probe доказывает 9 чтений и отличный от opaque-root результат до измерения.

Проверки

  • npm: 242/242
  • Core: 594 passed, 6 ignored
  • WASM: 73/73
  • fmt, Clippy all-targets, TypeScript, rustdoc, release verifier: green
  • targeted mutation: 7 caught, 1 unviable, 0 missed
  • независимые final и release audits: APPROVE

Размер

Canonical Linux run 29701262743 измерил 387058 B raw, на 77 B меньше base-ратчета 387135 B. Policy имеет нулевой произвольный headroom: ceiling = measurement = 387058 B; gzip остаётся diagnostic-only.

Summary by CodeRabbit

  • Новые возможности

    • Улучшена композиция полупрозрачных цветов для более точных и согласованных результатов.
    • Добавлен защищённый мост для вычисления композиции цветов в браузерном runtime.
  • Исправления

    • Уточнена проверка прозрачности и недопустимых значений альфа-канала.
    • fallback теперь должен быть распознаваемым непрозрачным поддерживаемым цветом.
    • Инициализация WASM корректно обрабатывает параллельные async- и sync-вызовы, повторные вызовы и ошибки загрузки.
  • Документация

    • Обновлены описания публичных API, fallback, композиции цветов и поведения инициализации.
    • Внутренние функции композиции больше не представлены как публичные API.

@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 35 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 8de80c9e-3ffa-4a53-a568-3281cbc8486b

📥 Commits

Reviewing files that changed from the base of the PR and between dd9b5f4 and 0c327a2.

📒 Files selected for processing (3)
  • crates/labcolors-core/src/appearance.rs
  • crates/labcolors-core/src/appearance_graph_tests.rs
  • crates/labcolors-core/src/composition.rs

Walkthrough

В Core централизованы профили композиции и admitted alpha, добавлен точечный WASM-композитор, а effectiveBackground переведён на него. Публичные init и initSync получили фасад управления состояниями, обновлены тесты, документация, benchmark и WASM budget metadata.

Changes

Композиция и WASM bridge

Layer / File(s) Summary
Типизированная Core-композиция
crates/labcolors-core/src/composition.rs, crates/labcolors-core/src/appearance.rs, crates/labcolors-core/src/alpha.rs, crates/labcolors-core/src/semantic.rs
CompositionProfileV1 и AdmittedOpacityV1 централизуют валидацию alpha и source-over; appearance runtime, replay и certificates используют admitted-значения.
Точечный WASM-композитинг
crates/labcolors-wasm/src/lib.rs, packages/colors/effective-bg.js
Добавлен packed RGB24 экспорт __over; парсинг цветов и effectiveBackground используют точечную композицию через WASM и отклоняют неподдерживаемый fallback.
Публичный фасад инициализации
packages/colors/index.js, packages/colors/index.d.ts, packages/colors/test/init-lifecycle.test.mjs, packages/colors/test/public-api-cleanup.test.mjs, packages/colors/test/release-contract.test.mjs
init и initSync управляют конкурентными состояниями, кэшируют async flight, обрабатывают ошибки и не раскрывают raw WASM exports.

Интеграция и проверка

Layer / File(s) Summary
Интеграционные тесты и поддерживающие изменения
packages/colors/test/*, packages/colors/bench/*, packages/colors/README.md, packages/colors/*theme*, README.md, scripts/check-wasm-size-budget.mjs
Тесты переведены на __over, добавлены проверки parsing, fallback и lifecycle; обновлены описания API, benchmark initialization, probe обхода и SHA-256 budget metadata.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant effectiveBackground
  participant __over
  participant composite_over_srgb8
  effectiveBackground->>__over: Передаёт packed source, opacity и backdrop
  __over->>composite_over_srgb8: Выполняет Core-композицию
  composite_over_srgb8-->>__over: Возвращает RGB24 или отказ
  __over-->>effectiveBackground: Возвращает packed результат
Loading

Possibly related PRs

  • Labpics-Team/lab-colors#165 — пересекается с обновлением chain-invariants и переходом на WASM bridge __over.
  • Labpics-Team/lab-colors#269 — связан с контрактом composite_over_srgb8 и новым WASM экспортом.
  • Labpics-Team/lab-colors#310 — связан с миграцией appearance graph на общую opacity/composition machinery.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Заголовок коротко и точно отражает главный смысл PR: перенос точечной композиции в единый Core-профиль.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/c8b-canonical-point-compositor

Comment @coderabbitai help to get the list of available commands.

@lemone112
lemone112 marked this pull request as ready for review July 19, 2026 20:03
@lemone112

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lemone112

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lemone112

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/labcolors-core/src/appearance.rs`:
- Around line 1036-1050: Update SourceOverCertificateV1::replay to avoid
revalidating subject_opacity_bits through AdmittedOpacityV1::new; add a trusted
pub(crate) AdmittedOpacityV1::from_bits(bits: u64) constructor that performs
only the round-trip conversion, then use it in replay while preserving the
existing compositing behavior.

In `@crates/labcolors-core/src/composition.rs`:
- Around line 56-61: Добавьте прямой unit-тест для AdmittedOpacityV1::multiply,
проверяющий граничные случаи 0.0*0.0, 1.0*1.0 и перемножение значений,
денормализующееся до 0.0. Сравнивайте результат через публичное значение opacity
и закрепите инвариант, что результат остаётся admitted.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: fdfcf677-f365-42b0-b638-1c2167804269

📥 Commits

Reviewing files that changed from the base of the PR and between 98eda0c and dd9b5f4.

📒 Files selected for processing (25)
  • README.md
  • crates/labcolors-core/src/alpha.rs
  • crates/labcolors-core/src/appearance.rs
  • crates/labcolors-core/src/composition.rs
  • crates/labcolors-core/src/semantic.rs
  • crates/labcolors-wasm/src/lib.rs
  • packages/colors/README.md
  • packages/colors/adapt-theme.d.ts
  • packages/colors/adapt-theme.js
  • packages/colors/bench/hotpath.bench.mjs
  • packages/colors/bench/wasm.json
  • packages/colors/effective-bg.js
  • packages/colors/index.d.ts
  • packages/colors/index.js
  • packages/colors/test/adapt-theme.test.mjs
  • packages/colors/test/chain-invariants.test.mjs
  • packages/colors/test/init-lifecycle.test.mjs
  • packages/colors/test/oklch-parse.test.mjs
  • packages/colors/test/point-composition.test.mjs
  • packages/colors/test/public-api-cleanup.test.mjs
  • packages/colors/test/release-contract.test.mjs
  • packages/colors/test/runtime.test.mjs
  • packages/colors/watch-theme.d.ts
  • packages/colors/watch-theme.js
  • scripts/check-wasm-size-budget.mjs

Comment thread crates/labcolors-core/src/appearance.rs
Comment thread crates/labcolors-core/src/composition.rs
@lemone112
lemone112 merged commit 4968704 into main Jul 19, 2026
10 checks passed
@lemone112
lemone112 deleted the agent/c8b-canonical-point-compositor branch July 19, 2026 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant