Skip to content

Add generated and raw unsafe Classic COM support - #132

Merged
leileizhang (lei9444) merged 7 commits into
mainfrom
feature/com-unsafe-raw
Sep 3, 2026
Merged

Add generated and raw unsafe Classic COM support#132
leileizhang (lei9444) merged 7 commits into
mainfrom
feature/com-unsafe-raw

Conversation

@lei9444

Copy link
Copy Markdown
Contributor

Summary

  • add an isolated Classic COM runtime that can dynamically invoke existing objects and implement metadata-validated IUnknown interfaces in JavaScript using static thunks or libffi closures
  • preserve full COM identity and lifetime semantics across inheritance, multiple interfaces, QueryInterface, canonical IUnknown, AddRef/Release, owner-thread callbacks, transactional outputs, and reentrant release
  • add semantic and raw unsafe subpaths plus generated *Unsafe companions with explicit pointer, ownership, cleanup, counted-buffer, handle, and interface-replacement strategies
  • add a pinned exact-contract registry and reproducible capability census; retain a compact summary and per-interface support index in Git while publishing the full report as a CI artifact
  • integrate COM incremental generation with canonical namespace output, cross-process locking, atomic publication, retained filesystem links, rollback, and stale unsafe-package cleanup

Compatibility and scope

  • keeps the npm package root WinRT-only; Classic COM is exposed under /com, /com/unsafe, and /com/unsafe/raw
  • keeps existing WinRT signature and projection behavior separate from COM-local ABI semantics
  • raises the JavaScript package engine floor to Node.js 18
  • covers in-process, current-apartment outbound Classic COM and owner-thread synchronous JavaScript implementations; cross-apartment dispatch, COM servers, aggregation, and custom marshaling remain out of scope

Capability baseline

For Microsoft.Windows.SDK.Win32Metadata 71.0.14-preview:

  • 5,567 / 7,929 interfaces pass complete safe generation
  • 2,362 interfaces remain safe-incomplete
  • x64 safe-incomplete classification: 418 metadata-complete, 1,554 manual-contract, 390 runtime-blocked
  • 334 exact registry entries are registered and metadata-matched; 291 are consumed by safe plans

Validation

  • full dynwinrt-codegen, dynwinrt, and jswinrt_rs Rust test suites
  • i686 jswinrt_rs compile check
  • JavaScript production build, TypeScript checks, package-facade tests, raw ABI tests, and generated unsafe fake-vtable E2E
  • Classic COM live E2E: 17 / 17 runners
  • two independent capability census generations with byte-identical full reports and retained artifact hashes
  • final staged and post-rebase code reviews found no remaining high-confidence issues

The full npm suite's known WinUI nextTick timing assertion was flaky under load and passed on its isolated rerun.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 9ef7fa55-eb2a-4360-bd17-05feae50fadb
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 9ef7fa55-eb2a-4360-bd17-05feae50fadb
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

Mixed-language test coverage

Workflow status: ✅ Passed

Layer Lines Functions Branches/regions
Rust, including native .pyd/.node 84.84% 79.74% 84.36% regions
Generated Python projections 70.5% n/a 21.71% branches
JavaScript aggregate 21.35% 20.6% 54.04% branches
JavaScript runtime 24.22% 14.28% 7.14% branches
Generated WinRT projections 25.8% 19.3% 54.74% branches
Generated Classic COM projections 14.64% 24.46% 53.75% branches

View workflow run and download full HTML/LCOV/XML reports

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 9ef7fa55-eb2a-4360-bd17-05feae50fadb
@lei9444

Copy link
Copy Markdown
Contributor Author

Addressed the requested changes in f0e4c31:

  1. Direct void* returns now preserve pointer ABI and generated ID3DBlobUnsafe.getBufferPointer() returns DynComRawPointer.
  2. Dispatch marking now occurs at the actual fast-path/libffi call boundary after all fallible coercion, ownership, and storage preparation.
  3. Raw union pointer nullability is preserved through the core plan, executor, JS raw factory, and declarations.
  4. Nested aggregate unions are rejected by the semantic /com/unsafe factory and remain available only under /com/unsafe/raw.
  5. Output transactions recover owner-marked stage/backup residue across process termination, preserve stranded retained links on terminal rollback failure, and retry transient Windows rename sharing failures.
  6. Removed the duplicate root README Classic COM block.

Added unit, real-WinMD, TypeScript, JS runtime, transaction failure-injection, and live E2E regressions. Classic COM E2E passes 17/17; final code review found no remaining high-confidence issues.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 9ef7fa55-eb2a-4360-bd17-05feae50fadb
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 9ef7fa55-eb2a-4360-bd17-05feae50fadb
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 9ef7fa55-eb2a-4360-bd17-05feae50fadb
Stop passing the deleted local Buffer shim to the generated consumer compiler now that @types/node supplies Buffer. Include both compiler output streams in future assertion failures.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@lei9444
leileizhang (lei9444) merged commit 9816ab5 into main Sep 3, 2026
24 checks passed
@lei9444
leileizhang (lei9444) deleted the feature/com-unsafe-raw branch September 3, 2026 09:42
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.

2 participants