Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ses): Compartment options migration #2386

Merged
merged 4 commits into from
Jul 30, 2024

Conversation

kriskowal
Copy link
Member

Refs: #400

Description

To converge with XS in the patterns accepted by SES for Compartment construction, this change introduces a __options__ property to the first argument of the Compartment constructor that indicates that the constructor accepts a single options bag argument and does not receive separate endowments and module map arguments.

Security Considerations

None.

Scaling Considerations

None.

Documentation Considerations

This change includes updates for NEWS (with migration instructions and a notice of intent to break deprecated usage patterns) and README (to encourage recommended usage). We intend to follow up with an update to hardenedjs.org upon release.

Testing Considerations

All tests have been updated to use the new constructor pattern except those already marked as legacy, which remain to exercise support for the deprecated usage patterns.

Compatibility Considerations

There is a remote possibility that existing code uses __options__ as the name of an endowment and will now be misinterpreted. We do not imagine any guest programs are in a position to influence their host compartment’s construction.

Upgrade Considerations

None.

@kriskowal kriskowal requested a review from erights July 27, 2024 01:28
Comment on lines 570 to 582
// Internal, to obviate polymorphic dispatch, but may become rigorously
// consistent with @endo/error.
export { makeError, note as annotateError, redactedDetails as X, quote as q };
// consistent with @endo/error:

/** @type {AssertionFunctions['typeof']} */
const assertTypeof = assert.typeof;

export {
assertTypeof,
makeError,
note as annotateError,
redactedDetails as X,
quote as q,
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a drive-by?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, this was my preferred solution to avoid a polymorphic dispatch at assertTypeof elsewhere in this change. You had good feedback elsewhere which will change this to assertEqual if not a more systematic change.

Copy link
Contributor

@erights erights left a comment

Choose a reason for hiding this comment

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

LGTM!

) {
const { __options__, ...options } = args[0];
assert(
__options__ === true,
Copy link
Contributor

Choose a reason for hiding this comment

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

since you require it to have value true, you should be sure to mention that where you explain __option__, such as the doc-comment above. From the doc-comment alone, I would guest that you only tested whether the property is present.

Comment on lines 209 to 211
assertTypeof(
options.modules,
'undefined',
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure you want to check that the value is undefined rather than whether the property is present?

Why typeof? The above code should be equivalent to

Suggested change
assertTypeof(
options.modules,
'undefined',
assertEqual(
options.modules,
undefined,

but the later says what it means better.

@kriskowal kriskowal force-pushed the kriskowal-compartment-options branch from a299074 to 59327f0 Compare July 30, 2024 21:34
@kriskowal kriskowal merged commit b145fe1 into master Jul 30, 2024
17 checks passed
@kriskowal kriskowal deleted the kriskowal-compartment-options branch July 30, 2024 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants