Skip to content

refactor(npm): isolate offline compiler WASM - #321

Merged
lemone112 merged 10 commits into
mainfrom
agent/issue-296c1-compiler-boundary
Jul 15, 2026
Merged

refactor(npm): isolate offline compiler WASM#321
lemone112 merged 10 commits into
mainfrom
agent/issue-296c1-compiler-boundary

Conversation

@lemone112

@lemone112 lemone112 commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Scope

#296-C1 only: один npm package, две физические execution-role. Package root остаётся runtime-only; @labpics/colors/compiler владеет offline feasibility compiler. Compatibility alias в root не добавлен. C2 atomic A→B и C3 transport publication в этот PR не входят.

Результат

  • Runtime WASM больше не резолвит labcolors-protocol или compiler features; root init() не загружает compiler.
  • Compiler — отдельный Cargo/WASM root и npm subpath с собственными init/initSync, curated types и strict byte boundary.
  • Browser integration документирована как dedicated module Worker; main thread импортирует только runtime или compiler-типы.
  • Rust Core source bytes и finite feasibility semantics не изменены.

Доказательства

  • Native evidence append-only: V1–V3 exact bytes проверяются до historical replay; текущий V4 связан с exact C1 source cone. V3→V4 сохраняет одну deterministic scenario/identity projection.
  • Committed whole-call V3, SHA-256 60e0b0f621fb4e0fcc5c57c527a8f1bf11487ee34581c98239b1ac6c31e6de86, проверяется CI в verify-only mode; ревизия под тестом больше не может сама записать новую истину.
  • Role-aware WASM V5: runtime 454385 B, compiler 175212 B; оба exact Linux-x64 SHA/recipe имеют нулевой headroom.
  • Hostile TypedArray/subclass/detached/shared-view inputs fail closed до избегаемой ABI-копии.
  • Clean package consumer проверяет обе роли, Node 22 floor и browser WASM отдельно.
  • Browser Worker readiness-path проверен в реальном Chrome без задержки: ready → request → pass.

Gates

Closes no issue: owner #296 остаётся открыт для C2/C3.

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Добавлен отдельный offline compiler для WCAG22 feasibility с собственным WASM, npm subpath и типами. Runtime освобождён от feasibility protocol; обновлены role-aware WASM budgets, evidence, release manifest, package smoke-проверки, CI gates и документация.

Changes

Compiler boundary

Layer / File(s) Summary
Compiler API и публикация
crates/labcolors-compiler/*, packages/colors/compiler.*, packages/colors/package.json, packages/colors/test/*
Добавлены compiler crate, wasm-bindgen API, отдельные npm exports и проверки входных байтов, WASM-сборки и compiler surface.
Runtime и compiler type surfaces
crates/labcolors-wasm/*, packages/colors/index.*, packages/colors/wcag22.d.ts, packages/colors/test/release-contract.test.mjs
Feasibility exports и protocol-типы удалены из runtime; общие WCAG-типы и публичные compiler-типы проверяются раздельно.
Compiler boundary evidence
packages/colors/bench/*, packages/colors/test/wcag22-feasibility-*.mjs
Whole-call evidence переведено на compiler entrypoint с отдельными init-sync, warm-operation, memory и outcome-наблюдениями.
Role-aware package release
scripts/prepare-npm-package.mjs, scripts/verify-package-release.mjs, .github/workflows/publish.yml, packages/colors/test/release-*
Metadata и release manifest используют runtime/compiler WASM-записи; tarball read-back проверяет точные ключи, размеры и SHA-256.
WASM budgets и immutable evidence
scripts/check-wasm-size-budget.mjs, crates/labcolors-core/contracts/*, packages/colors/bench/wasm-size-budget-v5.json, .github/workflows/ci.yml
Добавлены budget v5, benchmark v4, immutable hash history и отдельные проверки двух WASM-ролей.
CI capability и benchmark gates
.github/workflows/ci.yml, packages/colors/test/release-contract.test.mjs
CI разделяет direct Core и protocol consumers, проверяет capability boundaries и запускает runtime/compiler smoke и headless tests.
Документация и naming contracts
README.md, CHANGELOG.md, docs/*, scripts/docs-drift.test.mjs, scripts/naming-inventory.mjs
Документация, migration guidance и naming/drift checks обновлены для compiler subpath, двух ролей WASM и generated artifacts.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Consumer
  participant CompilerEntry
  participant CompilerWasm
  Consumer->>CompilerEntry: evaluateWcag22Feasibility(Uint8Array)
  CompilerEntry->>CompilerEntry: validate Uint8Array and size
  CompilerEntry->>CompilerWasm: evaluate request or oversize outcome
  CompilerWasm-->>CompilerEntry: feasibility outcome
  CompilerEntry-->>Consumer: typed outcome
Loading

Possibly related issues

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 44.07% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Заголовок точно отражает основное изменение: вынесение offline compiler WASM в отдельный npm entrypoint.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/issue-296c1-compiler-boundary

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

@lemone112 lemone112 changed the title refactor(npm): split runtime and compiler WASM refactor(npm): isolate offline compiler WASM Jul 15, 2026
@lemone112
lemone112 marked this pull request as ready for review July 15, 2026 07:21
@lemone112

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 15, 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: 5

🤖 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 `@CHANGELOG.md`:
- Line 44: Замените англоязычный заголовок раздела “Breaking (npm API)” на
русскоязычный эквивалент, например “Несовместимые изменения (npm API)”, сохранив
смысл и формат заголовка.

In `@docs/NAMING.md`:
- Around line 55-66: Уточните правило в разделе о subpath’ах, ограничив
требование разрешения в исходник только исходными JS/TS domain exports. Явно
исключите служебные exports `./package.json` и `./build-metadata.json`, а также
артефактные exports `./pkg/labcolors_bg.wasm` и `./compiler/wasm`, сохранив для
них действующие отдельные правила.

In `@README.md`:
- Around line 37-39: Уточните абзац README о `@labpics/colors/compiler`: не
связывайте npm-компилятор с клиентскими `opaque relations` или соседними цветами
и не приписывайте ему поддержку явного домена. Опишите его только через
фактически опубликованный V1-путь; добавлять API и доказательства следует лишь
при наличии соответствующей реализации.

In `@scripts/docs-drift.test.mjs`:
- Around line 74-99: Extend the test “generated WASM names come from package
files without hiding undeclared source” to create a packages/colors/pkg fixture
containing one package.json-declared file and one undeclared extra file, then
assert nonLawFiles(root) includes the undeclared pkg file alongside the existing
compiler results. Keep the declared pkg file excluded and preserve the fixture
cleanup.

In `@scripts/naming-inventory.mjs`:
- Around line 193-211: Обновите nonLawFiles и связанный walk, чтобы директории
packages/colors/pkg и packages/colors/compiler полностью проверялись, включая не
объявленные runtime-артефакты. Расширьте обработку generatedPackageFiles так,
чтобы записи package.json вида files: ["pkg"] и files: ["compiler"] считались
корнями, а не только путями конкретных файлов. Добавьте regression-test,
подтверждающий попадание не объявленного файла из pkg в результат.
🪄 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: 6e0819c8-4268-46f1-a4bc-952a4f4a942f

📥 Commits

Reviewing files that changed from the base of the PR and between 10c44ef and 4a6fe6d.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (37)
  • .github/workflows/ci.yml
  • .github/workflows/publish.yml
  • CHANGELOG.md
  • Cargo.toml
  • README.md
  • crates/labcolors-compiler/Cargo.toml
  • crates/labcolors-compiler/src/lib.rs
  • crates/labcolors-compiler/tests/wasm_parity.rs
  • crates/labcolors-core/benches/wcag22_feasibility_admission.rs
  • crates/labcolors-core/contracts/wcag22-feasibility-benchmark-v4.json
  • crates/labcolors-wasm/Cargo.toml
  • crates/labcolors-wasm/src/lib.rs
  • crates/labcolors-wasm/tests/wasm_parity.rs
  • docs/NAMING.md
  • docs/migrations/exact-alpha-glow.md
  • docs/verification-map.md
  • packages/colors/README.md
  • packages/colors/bench/wasm-size-budget-v5.json
  • packages/colors/bench/wcag22-feasibility-boundary.bench.mjs
  • packages/colors/bench/wcag22-feasibility-wasm-boundary-v3.json
  • packages/colors/compiler.d.ts
  • packages/colors/compiler.js
  • packages/colors/index.d.ts
  • packages/colors/index.js
  • packages/colors/package.json
  • packages/colors/test/compiler-boundary.test.mjs
  • packages/colors/test/release-contract.test.mjs
  • packages/colors/test/release-provenance.test.mjs
  • packages/colors/test/wcag22-feasibility-boundary.test.mjs
  • packages/colors/test/wcag22-feasibility.test.mjs
  • packages/colors/wcag22.d.ts
  • scripts/check-wasm-size-budget.mjs
  • scripts/check_wcag22_feasibility_benchmark.py
  • scripts/docs-drift.test.mjs
  • scripts/naming-inventory.mjs
  • scripts/prepare-npm-package.mjs
  • scripts/verify-package-release.mjs

Comment thread CHANGELOG.md Outdated
Comment thread docs/NAMING.md Outdated
Comment thread README.md Outdated
Comment thread scripts/docs-drift.test.mjs
Comment thread scripts/naming-inventory.mjs Outdated

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
README.md (1)

34-40: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Укажите происхождение и проверку численных параметров.

В абзаце названы WCAG 2.2, sRGB8 и srgb8-neutral-axis-v1, но не указаны их источник, диапазон применимости, sensitivity и тестовый/evidence-артефакт. Сошлитесь на канонический контракт и docs/verification-map.md, не добавляя новые значения в README.

🤖 Prompt for 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.

In `@README.md` around lines 34 - 40, Обновите абзац о полной проверке конечного
домена в README, добавив ссылки на канонический compiler-контракт и
docs/verification-map.md для происхождения и проверки WCAG 2.2, sRGB8 и
srgb8-neutral-axis-v1. Укажите источник, диапазон применимости, sensitivity и
соответствующий тестовый/evidence-артефакт, не вводя новых численных значений.

Source: Coding guidelines

🤖 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.

Outside diff comments:
In `@README.md`:
- Around line 34-40: Обновите абзац о полной проверке конечного домена в README,
добавив ссылки на канонический compiler-контракт и docs/verification-map.md для
происхождения и проверки WCAG 2.2, sRGB8 и srgb8-neutral-axis-v1. Укажите
источник, диапазон применимости, sensitivity и соответствующий
тестовый/evidence-артефакт, не вводя новых численных значений.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: e791c330-0389-467f-8793-6b6a4679215c

📥 Commits

Reviewing files that changed from the base of the PR and between f9f4888 and 34ed85f.

📒 Files selected for processing (2)
  • README.md
  • docs/NAMING.md

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