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(exo): instance testing #1925

Merged
merged 3 commits into from
Jan 19, 2024
Merged

feat(exo): instance testing #1925

merged 3 commits into from
Jan 19, 2024

Conversation

erights
Copy link
Contributor

@erights erights commented Jan 4, 2024

Now staged on #1964

closes: #XXXX
refs: #1924 #1964

Description

This PR adds a third meta-level rights amplification power: the power to tell if an object is a live instance of an exo class, or a live facet instance of an exo class kit.

After revoking and amplifying, the remaining obvious meta-level rights amplification power normally associated with classes is unforgeable instance testing. (In some ocap literature, this is sometimes referred to as "brand testing". But given ERTP's conflicting use of the term "brand", this is best avoided.)

Given revocability and our desire that all these meta-level powers be essentially free, these test only that an object is a live instance of the associated class, or a live facet instance of the associated class kit. In neither case do we distinguish between a revoked former instance vs any other non-live-instance value.

Security Considerations

In many OO languages, such as Java, access to a class bundles the ability to instantiate the class with the ability to reliably test for membership in the class. For exo classes and exo class kits, to follow the principles of least authority and information hiding, we decided to separate the two. As with the other meta-level rights amplification powers, these are not provided by default, and it is easy for a code review to see it they are provided at all, and where these powers might be used.

The obvious JavaScript test, instanceof, is not reliable. However, JavaScript classes do provide a reliable test via
private fields. Like the design in this PR, this power is initially present only within the lexical scope of the class. It is up to code within that lexical scope whether to make that power available to code elsewhere.

Scaling Considerations

Should be free, as it uses the contextMap indirection already present in exos.

Documentation Considerations

For all these meta-level rights amplification powers, the inline doc-comments now contains adequate text to seed real documentation, especially when consulting the tests for illustrative examples. However, none of these are yet implemented for virtual or durable exos, and cannot be until agoric-sdk is upgraded to depend on an endo release incorporating this PR. Until then, we should probably hold back on more public documentation of these APIs.

Testing Considerations

This PR provided only tests for the heap-based exo implementations, which are all that the @endo/exo package provided. Once base-zone is migrated from agoric-sdk to endo, we should rewrite these tests using Zones so they are reusable for virtual and durable exos as well.

Upgrade Considerations

For all these meta-level rights amplification powers, which powers are provided might vary per incarnation. Since amplification and live instance testing are query only powers against representation that exists anyway, having these vary per incarnation should not be a problem. It remains to be seen whether this will also be true for revocation.

@erights erights self-assigned this Jan 4, 2024
@erights erights force-pushed the markm-exo-is-live-instance branch 5 times, most recently from f481a88 to e9bf65a Compare January 13, 2024 01:49
@erights erights force-pushed the markm-exo-is-live-instance branch 2 times, most recently from b21c849 to 224af12 Compare January 13, 2024 22:58
@erights erights force-pushed the markm-exo-is-live-instance branch 2 times, most recently from c6015af to a81350a Compare January 15, 2024 00:44
@erights erights changed the base branch from master to markm-remove-receiveRevoker January 15, 2024 00:45
@erights erights changed the title feat(exo): live instance testing feat(exo): instance testing Jan 15, 2024
@erights erights force-pushed the markm-exo-is-live-instance branch 2 times, most recently from eff17bd to c5c30c6 Compare January 15, 2024 01:02
@erights erights requested a review from FUDCo January 16, 2024 19:04
Base automatically changed from markm-remove-receiveRevoker to master January 16, 2024 19:07
@erights erights force-pushed the markm-exo-is-live-instance branch 4 times, most recently from 62178ed to 1ddc51a Compare January 18, 2024 04:58
Copy link
Contributor

@FUDCo FUDCo left a comment

Choose a reason for hiding this comment

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

LGTM. Still wish we had a better word than "kit" though.

@erights erights enabled auto-merge (squash) January 19, 2024 01:10
@erights erights merged commit 05d46d6 into master Jan 19, 2024
14 checks passed
@erights erights deleted the markm-exo-is-live-instance branch January 19, 2024 01:22
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