Skip to content

test(env-options,marshal): per-compartment options are scoped#3299

Open
kriskowal wants to merge 2 commits into
masterfrom
kriskowal-2879-env-options-per-compartment
Open

test(env-options,marshal): per-compartment options are scoped#3299
kriskowal wants to merge 2 commits into
masterfrom
kriskowal-2879-env-options-per-compartment

Conversation

@kriskowal

Copy link
Copy Markdown
Member

Closes: #2879

Description

Adds a test confirming that @endo/env-options reads globalThis.process.env from the compartment it runs in, so settings like ENDO_RANK_STRINGS are scoped per compartment rather than leaking from the parent.

The test loads @endo/env-options into a sub-compartment via @endo/compartment-mapper's importLocation, with the sub-compartment's own process.env supplied through per-compartment globals.process.env. It then checks that string ranking inside the sub-compartment follows that compartment's ENDO_RANK_STRINGS setting (unicode-code-point-order) while the parent retains the default (utf16-code-unit-order), and that two sibling sub-compartments observe their own envs independently.

Security Considerations

No new authorities. The change is test-only; it documents and pins existing per-compartment isolation of env-options rather than altering any boundary.

Scaling Considerations

None. The added test runs at the same cost as the package's existing tests.

Documentation Considerations

None. The behavior under test (env-options reading the running compartment's process.env) is already the intended contract.

Testing Considerations

This PR is itself the test. It exercises the captor through @endo/compartment-mapper the way a real downstream consumer would, rather than constructing a ModuleSource by hand.

Compatibility Considerations

None. No usage patterns change.

Upgrade Considerations

None.

kriskowal added 2 commits June 6, 2026 22:41
Adds a test that loads `@endo/env-options` into a sub-compartment via
`@endo/compartment-mapper`'s `importLocation`, with the sub-compartment's
own `process.env` plumbed in through per-compartment `globals.process.env`.
The captor inside the sub-compartment reads the sub-compartment's env, not
the parent's.

Exercises the `ENDO_RANK_STRINGS` switch: string ranking inside the
sub-compartment follows the per-compartment setting
(`unicode-code-point-order`) while the parent retains the default
(`utf16-code-unit-order`), and sibling sub-compartments observe their own
envs independently.

Closes #2879
@changeset-bot

changeset-bot Bot commented Jun 7, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 884e2a8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

kriskowal pushed a commit to kriskowal/garden that referenced this pull request Jun 7, 2026
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.

Need a test for a per-compartment env-options setting and import

1 participant