fix(exo): allow richer behaviorMethods#1809
Conversation
55c660a to
ebf8a11
Compare
61b2bb5 to
82f1d2c
Compare
82f1d2c to
d113f32
Compare
d113f32 to
87f1cf8
Compare
4aa969f to
aa5925a
Compare
5776030 to
d50a60b
Compare
d50a60b to
1522ef7
Compare
992248d to
7460a13
Compare
|
@michaelfig , reviewers, I rebased and resolved merge conflicts with #1831 |
de5766c to
6dc17f6
Compare
fa32908 to
a315a7c
Compare
|
At #1809 (review) @michaelfig writes:
All quibbles resolved. PTAL.
|
a315a7c to
2e6ed72
Compare
|
Reviewers, |
2e6ed72 to
f35d7de
Compare
turadg
left a comment
There was a problem hiding this comment.
I raised some issues at the periphery with assertions and documentation.
We need at least to bikeshed from the currently awful names (
defineExoClassFromJSClass).
I think "bikeshed" here is facetious but I want to point out that API naming in Endo merits careful consideration. They will stick around a long time and we want to avoid developers being confused by them or having misconceptions about what they do.
That said, I don't think defineExoClassFromJSClass is awful. It's long but it says what it does. It's probably also not the end state for the dev-facing API because I expect defining the class with decorators will be the most common.
f35d7de to
d3b9abb
Compare
I agree completely, which is why these awful names --- as well as the entirety of the That said, even as a |
f2dbf29 to
25633d6
Compare
turadg
left a comment
There was a problem hiding this comment.
No blocking concerns. I do think the underscores are worth considering before merging.
I'd also suggest cleaning up the commits to reduce noise in the changelog. Most of the "fix" are really "fixup" that should be squashed into noteworthy commits.
Btw, if a commit shouldn't appear in the changelog, it shouldn't have conventional commit message. Noise in the commit history isn't as bad as noise in the changelog.
a9db3d8 to
336b138
Compare
Manually squashed those away before merging. Done. |
336b138 to
1f29d4a
Compare
closes: #1817
refs: #1815 #1808 #1773 #1766
Description
The intention of the exo-making methods was to be able to use a JS class'
.prototypeas a source of raw methods. This PRdefineExoClassFromJSClass).superand late-boundselfin inheritance among these methods, withsupercalls bypassing guards, whileselfcalls are guarded.This PR also provides tests demonstrating the use of JS classes to directly provide unguarded behavior at the
@endo/pass-style/Farlevel of abstraction. This PR makes no changes to thesrc/code at this level, demonstrating what support is already possible. Unlike the above exo-level support, we do not recommend the coding style shown in these pass-style level tests. However, neither can we reasonably prevent it, so we need to understand it.Security Considerations
Corresponding examples at
endo/packages/pass-style/test/test-far-wobbly-point.js
Lines 132 to 144 in d50a60b
and
endo/packages/exo/test/test-exo-wobbly-point.js
Lines 183 to 193 in d50a60b
demonstrates that the demonstrated non-recommended use of class inheritance at the far level of abstraction has a security vulnerability absent from the use of class inheritance at the exo level of abstraction. This is one reason why we do not recommend the former but may recommend the latter.
Scaling Considerations
If classes had large number of methods and class inheritance chains were deep, this has somewhat worse scaling than a JS class programmer would normally expect. However, if either of these are reasonably small, there should not be any significant scaling problem.
Documentation Considerations
If we decide that we like and wish to promote the use of JS classes demonstrated by this PR, we should move some support (
defineExoClassFromJSClass) into exported sources and we should document the whole approach. The purpose of this PR is not to establish such practice or decide on its exact shape, but merely to demonstrate that this PR makes such JS class-based practice possible.In particular, we may be able to improve of the usability shown in this PR by using JS class decorators. It is a worthy experiment. (attn @mhofman )
Testing Considerations
The
srcchanges that this PR makes are only toexo-tools.jscode shared among heap, virtual, and durable exos. However, the tests only test the behavior of heap exos. Once agoric-sdk is upgraded to depend on the changes from this PR, we should reproduce these tests for virtual and durable exos. Ideally, we would use Zones to write the tests once and then reuse it to test all three types of zone.This PR makes no effort to test JS classes used for facets of exo kits. Nor does it provide any hypothetical helper functions to help write such exo kits. If we decide that this code pattern for using JS classes is attractive, a later PR should indeed extend the approach to exo kits.
Upgrade Considerations
This PR makes no changes to data. For existing exo-making code that only uses object literals for own enumerable methods, this PR should not result in any behavior change or even internal representation change. The only code it should make a difference for is code that previously did not work because it needed the fixes and features provided by this PR. We are not aware of any such code prior to this PR.