Skip to content

fix(compartment-mapper): policy, parser type fixes#3247

Draft
boneskull wants to merge 2 commits into
boneskull/evasive-pipeline2from
boneskull/fix-module-source-types2
Draft

fix(compartment-mapper): policy, parser type fixes#3247
boneskull wants to merge 2 commits into
boneskull/evasive-pipeline2from
boneskull/fix-module-source-types2

Conversation

@boneskull

Copy link
Copy Markdown
Member
  • Fixes CompartmentDescriptor so that it is generic on the PackagePolicy; externally-defined ParseFns can now refer to the specific contents of a custom PackagePolicy present in a CompartmentDescriptor.
  • Introduces ParseSourceMapHook; differentiated from @endo/module-source's SourceMapHook.
  • Fixes type of PolicyItem; eliminates confusion between void (no extra union members) and any (SomePackagePolicy).

@boneskull

boneskull commented May 7, 2026

Copy link
Copy Markdown
Member Author

Warning

This PR is part of a stack and targets branch boneskull/evasive-pipeline2, not master.
DO NOT MERGE until feat(evasive-transform): expose makeEvasiveTransformVisitor #3217 is merged into master.

📚 Pull Request Stack


Managed by gh-stack

@changeset-bot

changeset-bot Bot commented May 7, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4c88284

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@endo/compartment-mapper Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@boneskull boneskull self-assigned this May 7, 2026
@boneskull boneskull added bug Something isn't working lavamoat labels May 7, 2026
@boneskull boneskull force-pushed the boneskull/evasive-pipeline2 branch from cc633e8 to 58609c1 Compare May 12, 2026 23:27
@boneskull boneskull force-pushed the boneskull/fix-module-source-types2 branch 3 times, most recently from 00302f9 to 1c80621 Compare May 14, 2026 19:00
@boneskull boneskull force-pushed the boneskull/evasive-pipeline2 branch from 58609c1 to 9725c9a Compare May 20, 2026 01:21
@boneskull boneskull force-pushed the boneskull/fix-module-source-types2 branch from 1c80621 to 7289aa0 Compare May 20, 2026 01:21
@boneskull boneskull force-pushed the boneskull/evasive-pipeline2 branch from 9725c9a to 82706e8 Compare May 20, 2026 02:08
@boneskull boneskull force-pushed the boneskull/fix-module-source-types2 branch from 7289aa0 to ecf9587 Compare May 20, 2026 02:08
@boneskull boneskull force-pushed the boneskull/evasive-pipeline2 branch from 82706e8 to 933188b Compare May 20, 2026 02:10
@boneskull boneskull force-pushed the boneskull/fix-module-source-types2 branch from ecf9587 to 2cea83c Compare May 20, 2026 02:10
@boneskull boneskull force-pushed the boneskull/evasive-pipeline2 branch from 933188b to 6f77dc7 Compare May 20, 2026 20:19
@boneskull boneskull force-pushed the boneskull/fix-module-source-types2 branch from 2cea83c to aa54f8d Compare May 20, 2026 20:19
@boneskull boneskull force-pushed the boneskull/evasive-pipeline2 branch from 6f77dc7 to 1d7eeb4 Compare May 20, 2026 21:23
@boneskull boneskull force-pushed the boneskull/fix-module-source-types2 branch from aa54f8d to a220677 Compare May 20, 2026 21:23
@boneskull boneskull force-pushed the boneskull/evasive-pipeline2 branch from 1d7eeb4 to 2df8ad0 Compare May 21, 2026 21:43
@boneskull boneskull force-pushed the boneskull/fix-module-source-types2 branch from a220677 to c824b83 Compare May 21, 2026 21:43
@boneskull boneskull force-pushed the boneskull/evasive-pipeline2 branch from 2df8ad0 to 0ac5359 Compare May 22, 2026 21:47
@boneskull boneskull force-pushed the boneskull/fix-module-source-types2 branch from c824b83 to 1d75de4 Compare May 22, 2026 21:47
@boneskull boneskull force-pushed the boneskull/evasive-pipeline2 branch from 0ac5359 to ba8cedb Compare May 25, 2026 22:14
@boneskull boneskull force-pushed the boneskull/fix-module-source-types2 branch from 1d75de4 to 326f653 Compare May 25, 2026 22:14
@boneskull boneskull force-pushed the boneskull/evasive-pipeline2 branch from ba8cedb to b66011e Compare May 25, 2026 22:32
@boneskull boneskull force-pushed the boneskull/fix-module-source-types2 branch from 326f653 to 3bd323b Compare May 25, 2026 22:32
@boneskull boneskull force-pushed the boneskull/evasive-pipeline2 branch from b66011e to 3b71436 Compare May 26, 2026 02:22
@boneskull boneskull force-pushed the boneskull/fix-module-source-types2 branch from 3bd323b to 06842be Compare May 26, 2026 02:22
@boneskull boneskull force-pushed the boneskull/evasive-pipeline2 branch from 3b71436 to 25002f8 Compare May 29, 2026 00:41
@boneskull boneskull force-pushed the boneskull/fix-module-source-types2 branch from 06842be to 621dfcf Compare May 29, 2026 00:41
@boneskull boneskull force-pushed the boneskull/evasive-pipeline2 branch from 25002f8 to a0b6ba7 Compare May 29, 2026 22:38
@boneskull boneskull force-pushed the boneskull/fix-module-source-types2 branch from 621dfcf to 56238e6 Compare May 29, 2026 22:38
@boneskull boneskull force-pushed the boneskull/evasive-pipeline2 branch from a0b6ba7 to 868963d Compare June 3, 2026 23:04
@boneskull boneskull force-pushed the boneskull/fix-module-source-types2 branch 2 times, most recently from 6cfd746 to c275156 Compare June 3, 2026 23:14
@boneskull boneskull requested a review from Copilot June 3, 2026 23:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates @endo/compartment-mapper’s public TypeScript types to better model policy generics and parser hooks, improving the accuracy of external parser/plugin type-checking.

Changes:

  • Make CompartmentDescriptor generic over the compartment PackagePolicy, enabling externally-defined ParseFns to “see” custom policy shapes.
  • Introduce ParseSourceMapHook (distinct from SourceMapHook) and thread a generic TCompartmentDescriptor through parser types.
  • Fix PolicyItem typing so any no longer collapses the “custom policy item” branch into the void branch.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
yarn.lock Updates lockfile to reflect dependency changes (adds @types/node, removes babel-eslint).
packages/module-source/package.json Adjusts devDependencies (adds @types/node, removes babel-eslint).
packages/compartment-mapper/src/types/typescript.ts Adds IsAny<T> helper for distinguishing wide any in conditional types.
packages/compartment-mapper/src/types/policy-schema.ts Refines PolicyItem typing and updates policy generic parameter naming and “any policy” aliases.
packages/compartment-mapper/src/types/external.ts Adds ParseSourceMapHook, factors parse options, and makes parser types generic over compartment descriptor type.
packages/compartment-mapper/src/types/compartment-map-schema.ts Extends CompartmentDescriptor generics to include policy type; adds “any descriptor” helper types.
packages/compartment-mapper/src/parse-mjs.js Adds a temporary @ts-expect-error for sourceMapHook typing pending a follow-up change.
packages/compartment-mapper/src/parse-archive-mjs.js Same temporary @ts-expect-error for sourceMapHook typing.
.changeset/huge-mammals-give.md Adds a changeset entry documenting the type-level fixes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +68 to +73
* `PackagePolicy<any, any, any, any> = AnyPackagePolicy` was not a supertype of
* policies with extra string literals (for example, LavaMoat's {@code "root"} on
* package imports). A separate branch for a wide
* `any` type parameter yields
* `PolicyItem<any> = WildcardPolicy | PropertyPolicy | any` so
* `AnyPackagePolicy` correctly accepts all package policy item shapes.
import type { CanonicalName } from './canonical-name.js';
import type { FileUrlString } from './external.js';
import type { SomePackagePolicy } from './policy-schema.js';
import type { PackagePolicy, SomePackagePolicy } from './policy-schema.js';
Comment on lines 847 to 852
/**
* An asynchronous module parsing function.
*/
export type AsyncParseFn = { isSyncParser?: false } & ((
...args: ParseArguments
) => Promise<ParseResult>);

/**
* Mapping of `Language` to synchronous {@link ParserImplementation}s only.
*
@boneskull boneskull force-pushed the boneskull/evasive-pipeline2 branch from 868963d to ce5b1cc Compare June 5, 2026 00:59
@boneskull boneskull force-pushed the boneskull/fix-module-source-types2 branch from c275156 to ec8ff8e Compare June 5, 2026 00:59
boneskull added 2 commits June 4, 2026 18:09
- Fixes `CompartmentDescriptor` so that it is generic on the `PackagePolicy`; externally-defined `ParseFn`s can now refer to the specific contents of a custom `PackagePolicy` present in a `CompartmentDescriptor`.
- Introduces `ParseSourceMapHook`; differentiated from `@endo/module-source`'s `SourceMapHook`.
- Fixes type of `PolicyItem`; eliminates confusion between `void` (no extra union members) and `any` (`SomePackagePolicy`).
@boneskull boneskull force-pushed the boneskull/fix-module-source-types2 branch from ec8ff8e to 4c88284 Compare June 5, 2026 01:10

@naugtur naugtur left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

machines are complaining, but I don't care. up to you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lavamoat

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants