@agoric/swingset-liveslots 0.10.3-dev-eb7e9eb.0 → 0.10.3-u11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/package.json +19 -18
  3. package/src/collectionManager.js +41 -112
  4. package/src/index.js +1 -2
  5. package/src/liveslots.js +73 -46
  6. package/src/virtualObjectManager.js +13 -22
  7. package/src/virtualReferences.js +0 -51
  8. package/test/liveslots-helpers.js +4 -4
  9. package/test/mock-gc.js +0 -1
  10. package/test/storeGC/test-lifecycle.js +0 -1
  11. package/test/test-collection-upgrade.js +1 -0
  12. package/test/test-collections.js +13 -103
  13. package/test/test-durabilityChecks.js +2 -2
  14. package/test/test-facetiousness.js +1 -1
  15. package/test/test-gc-sensitivity.js +0 -1
  16. package/test/test-handled-promises.js +5 -4
  17. package/test/test-initial-vrefs.js +1 -1
  18. package/test/test-liveslots-mock-gc.js +0 -1
  19. package/test/test-liveslots-real-gc.js +0 -1
  20. package/test/test-liveslots.js +12 -12
  21. package/test/test-vpid-liveslots.js +1 -1
  22. package/test/util.js +1 -1
  23. package/test/virtual-objects/test-cease-recognition.js +1 -2
  24. package/test/virtual-objects/test-cross-facet.js +1 -1
  25. package/test/virtual-objects/test-empty-data.js +1 -1
  26. package/test/virtual-objects/test-facets.js +1 -1
  27. package/test/virtual-objects/test-kind-changes.js +0 -1
  28. package/test/virtual-objects/test-reachable-vrefs.js +1 -2
  29. package/test/virtual-objects/test-rep-tostring.js +2 -2
  30. package/test/virtual-objects/test-retain-remotable.js +0 -1
  31. package/test/virtual-objects/test-state-shape.js +0 -1
  32. package/test/virtual-objects/test-virtualObjectGC.js +0 -1
  33. package/test/virtual-objects/test-virtualObjectManager.js +0 -5
  34. package/test/virtual-objects/test-vo-real-gc.js +0 -1
  35. package/test/virtual-objects/test-weakcollections-vref-handling.js +1 -1
  36. package/src/vatDataTypes.d.ts +0 -206
  37. package/src/vatDataTypes.js +0 -2
  38. package/tools/fakeCollectionManager.js +0 -44
  39. package/tools/fakeVirtualObjectManager.js +0 -60
  40. package/tools/fakeVirtualSupport.js +0 -375
  41. package/tools/prepare-test-env.js +0 -14
  42. package/tools/setup-vat-data.js +0 -54
  43. package/tools/vo-test-harness.js +0 -143
@@ -1,4 +1,3 @@
1
- // @ts-nocheck
2
1
  import test from 'ava';
3
2
  import '@endo/init/debug.js';
4
3
 
@@ -1,4 +1,3 @@
1
- // @ts-nocheck
2
1
  import test from 'ava';
3
2
  import '@endo/init/debug.js';
4
3
 
@@ -129,7 +128,6 @@ test('multifaceted virtual objects', t => {
129
128
  flushStateCache();
130
129
  t.deepEqual(log.splice(0), [
131
130
  `get kindIDID => undefined`,
132
- `get idCounters => undefined`,
133
131
  `set kindIDID 1`,
134
132
  `set vom.vkind.2.descriptor {"kindID":"2","tag":"multithing"}`,
135
133
  `set vom.${kid}/1 ${multiThingVal('foo', 1)}`,
@@ -205,7 +203,6 @@ test('virtual object operations', t => {
205
203
  const thing4 = makeThing('thing-4', 300); // [t4-0* t3-0* t2-0* t1-0*]
206
204
  // t4-0: 'thing-4' 300 0
207
205
  t.is(log.shift(), `get kindIDID => undefined`);
208
- t.is(log.shift(), `get idCounters => undefined`);
209
206
  t.is(log.shift(), `set kindIDID 1`);
210
207
  t.is(log.shift(), `set vom.vkind.2.descriptor {"kindID":"2","tag":"thing"}`);
211
208
  t.is(log.shift(), `set vom.vkind.3.descriptor {"kindID":"3","tag":"zot"}`);
@@ -470,7 +467,6 @@ test('symbol named methods', t => {
470
467
  const thing2 = makeThing('thing-2', 100); // [t1-0* t2-0*]
471
468
  // t2-0: 'thing-2' 100 0
472
469
  t.is(log.shift(), `get kindIDID => undefined`);
473
- t.is(log.shift(), `get idCounters => undefined`);
474
470
  t.is(log.shift(), `set kindIDID 1`);
475
471
  t.is(
476
472
  log.shift(),
@@ -651,7 +647,6 @@ test('virtual object gc', t => {
651
647
  });
652
648
 
653
649
  t.is(log.shift(), `get kindIDID => undefined`);
654
- t.is(log.shift(), `get idCounters => undefined`);
655
650
  t.is(log.shift(), `set kindIDID 1`);
656
651
  const skit = [
657
652
  'storeKindIDTable',
@@ -1,4 +1,3 @@
1
- // @ts-nocheck
2
1
  /* global WeakRef */
3
2
  import test from 'ava';
4
3
  import '@endo/init/debug.js';
@@ -3,7 +3,7 @@ import '@endo/init/debug.js';
3
3
 
4
4
  import { makeFakeVirtualObjectManager } from '../../tools/fakeVirtualSupport.js';
5
5
 
6
- test('weakMap vref handling', t => {
6
+ test('weakMap vref handling', async t => {
7
7
  const log = [];
8
8
  const {
9
9
  VirtualObjectAwareWeakMap,
@@ -1,206 +0,0 @@
1
- /**
2
- * @file Types for vat-data
3
- *
4
- * Facet is a single object with methods.
5
- * Behavior is a description when defining a kind of what facets it will have.
6
- * For the non-multi defineKind, there is just one facet so it doesn't have a key.
7
- */
8
- import type {
9
- InterfaceGuard,
10
- MapStore,
11
- Pattern,
12
- SetStore,
13
- StoreOptions,
14
- WeakMapStore,
15
- WeakSetStore,
16
- } from '@agoric/store';
17
-
18
- export type { MapStore, Pattern };
19
-
20
- // This needs `any` values. If they were `unknown`, code that uses Baggage
21
- // would need explicit runtime checks or casts for every fetch, which is
22
- // onerous.
23
- export type Baggage = MapStore<string, any>;
24
-
25
- type Tail<T extends any[]> = T extends [head: any, ...rest: infer Rest]
26
- ? Rest
27
- : [];
28
-
29
- type MinusContext<
30
- F extends (context, ...rest: any[]) => any,
31
- P extends any[] = Parameters<F>, // P: are the parameters of F
32
- R = ReturnType<F>, // R: the return type of F
33
- > = (...args: Tail<P>) => R;
34
-
35
- export type KindFacet<O> = { [K in keyof O]: MinusContext<O[K]> };
36
-
37
- export type KindFacets<B> = {
38
- [FacetKey in keyof B]: KindFacet<B[FacetKey]>;
39
- };
40
-
41
- export type KindContext<S, F> = { state: S; self: KindFacet<F> };
42
- export type MultiKindContext<S, B> = { state: S; facets: KindFacets<B> };
43
-
44
- export type PlusContext<C, M> = (c: C, ...args: Parameters<M>) => ReturnType<M>;
45
- export type FunctionsPlusContext<C, O> = {
46
- [K in keyof O]: PlusContext<C, O[K]>;
47
- };
48
-
49
- declare class DurableKindHandleClass {
50
- private descriptionTag: string;
51
- }
52
- export type DurableKindHandle = DurableKindHandleClass;
53
-
54
- /**
55
- * Grab bag of options that can be provided to `defineDurableKind` and its
56
- * siblings. Not all options are meaningful in all contexts. See the
57
- * doc-comments on each option.
58
- */
59
- export type DefineKindOptions<C> = {
60
- /**
61
- * If provided, the `finish` function will be called after the instance is
62
- * made and internally registered, but before it is returned. The finish
63
- * function is to do any post-intantiation initialization that should be
64
- * done before exposing the object to its clients.
65
- */
66
- finish?: (context: C) => void;
67
-
68
- /**
69
- * Meaningful to `makeScalarBigMapStore` and its siblings. These maker
70
- * fuctions will make either virtual or durable stores, depending on
71
- * this flag. Defaults to off, making virtual but not durable collections.
72
- *
73
- * Generally, durable collections are provided with `provideDurableMapStore`
74
- * and its sibling, which use this flag internally. If you do not make
75
- * durable collections by other means, you can consider this as
76
- * intended for internal use only.
77
- */
78
- durable?: boolean;
79
-
80
- /**
81
- * If provided, it describes the shape of all state records of instances
82
- * of this kind.
83
- */
84
- stateShape?: { [name: string]: Pattern };
85
-
86
- /**
87
- * Intended for internal use only.
88
- * Should the raw methods receive their `context` argument as their first
89
- * argument or as their `this` binding? For `defineDurableKind` and its
90
- * siblings (including `prepareSingleton`), this defaults to off, meaning that
91
- * their behavior methods receive `context` as their first argument.
92
- * `prepareExoClass` and its siblings (including `prepareExo`) use
93
- * this flag internally to indicate that their methods receive `context`
94
- * as their `this` binding.
95
- */
96
- thisfulMethods?: boolean;
97
-
98
- /**
99
- * Intended for internal use only.
100
- * If an `interfaceGuard` is provided, then the raw methods passed alongside
101
- * it are wrapped by a function that first checks that this method's guard
102
- * pattern is satisfied before calling the raw method.
103
- *
104
- * In `defineDurableKind` and its siblings, this defaults to off.
105
- * `prepareExoClass` use this internally to protect their raw class methods
106
- * using the provided interface.
107
- */
108
- interfaceGuard?: InterfaceGuard<unknown>;
109
- };
110
-
111
- export type VatData = {
112
- // virtual kinds
113
- /** @deprecated Use defineVirtualExoClass instead */
114
- defineKind: <P, S, F>(
115
- tag: string,
116
- init: (...args: P) => S,
117
- facet: F,
118
- options?: DefineKindOptions<KindContext<S, F>>,
119
- ) => (...args: P) => KindFacet<F>;
120
-
121
- /** @deprecated Use defineVirtualExoClassKit instead */
122
- defineKindMulti: <P, S, B>(
123
- tag: string,
124
- init: (...args: P) => S,
125
- behavior: B,
126
- options?: DefineKindOptions<MultiKindContext<S, B>>,
127
- ) => (...args: P) => KindFacets<B>;
128
-
129
- // durable kinds
130
- makeKindHandle: (descriptionTag: string) => DurableKindHandle;
131
-
132
- /** @deprecated Use defineDurableExoClass instead */
133
- defineDurableKind: <P, S, F>(
134
- kindHandle: DurableKindHandle,
135
- init: (...args: P) => S,
136
- facet: F,
137
- options?: DefineKindOptions<KindContext<S, F>>,
138
- ) => (...args: P) => KindFacet<F>;
139
-
140
- /** @deprecated Use defineDurableExoClassKit instead */
141
- defineDurableKindMulti: <P, S, B>(
142
- kindHandle: DurableKindHandle,
143
- init: (...args: P) => S,
144
- behavior: B,
145
- options?: DefineKindOptions<MultiKindContext<S, B>>,
146
- ) => (...args: P) => KindFacets<B>;
147
-
148
- providePromiseWatcher: unknown;
149
- watchPromise: unknown;
150
-
151
- makeScalarBigMapStore: <K, V>(
152
- label: string,
153
- options?: StoreOptions,
154
- ) => MapStore<K, V>;
155
- makeScalarBigWeakMapStore: <K, V>(
156
- label: string,
157
- options?: StoreOptions,
158
- ) => WeakMapStore<K, V>;
159
-
160
- makeScalarBigSetStore: <K>(
161
- label: string,
162
- options?: StoreOptions,
163
- ) => SetStore<K>;
164
- makeScalarBigWeakSetStore: <K>(
165
- label: string,
166
- options?: StoreOptions,
167
- ) => WeakSetStore<K>;
168
- canBeDurable: (specimen: unknown) => boolean;
169
- };
170
-
171
- // The JSDoc is repeated here and at the function definition so it appears
172
- // in IDEs where it's used, regardless of type resolution.
173
- export interface PickFacet {
174
- /**
175
- * When making a multi-facet kind, it's common to pick one facet to
176
- * expose. E.g.,
177
- *
178
- * const makeFoo = (a, b, c, d) => makeFooBase(a, b, c, d).self;
179
- *
180
- * This helper reduces the duplication:
181
- *
182
- * const makeFoo = pickFacet(makeFooBase, 'self');
183
- */
184
- <M extends (...args: any[]) => any, F extends keyof ReturnType<M>>(
185
- maker: M,
186
- facetName: F,
187
- ): (...args: Parameters<M>) => ReturnType<M>[F];
188
- }
189
-
190
- /** @deprecated Use prepareExoClass instead */
191
- export type PrepareKind = <P, S, F>(
192
- baggage: Baggage,
193
- tag: string,
194
- init: (...args: P) => S,
195
- facet: F,
196
- options?: DefineKindOptions<KindContext<S, F>>,
197
- ) => (...args: P) => KindFacet<F>;
198
-
199
- /** @deprecated Use prepareExoClassKit instead */
200
- export type PrepareKindMulti = <P, S, B>(
201
- baggage: Baggage,
202
- tag: string,
203
- init: (...args: P) => S,
204
- behavior: B,
205
- options?: DefineKindOptions<MultiKindContext<S, B>>,
206
- ) => (...args: P) => KindFacets<B>;
@@ -1,2 +0,0 @@
1
- // Empty JS file to correspond with vatDataTypes.d.ts
2
- export {};
@@ -1,44 +0,0 @@
1
- import { makeCollectionManager } from '../src/collectionManager.js';
2
-
3
- export function makeFakeCollectionManager(vrm, fakeStuff, _options = {}) {
4
- const {
5
- makeScalarBigMapStore,
6
- makeScalarBigWeakMapStore,
7
- makeScalarBigSetStore,
8
- makeScalarBigWeakSetStore,
9
- provideBaggage,
10
- initializeStoreKindInfo,
11
- flushSchemaCache,
12
- } = makeCollectionManager(
13
- fakeStuff.syscall,
14
- vrm,
15
- fakeStuff.allocateExportID,
16
- fakeStuff.allocateCollectionID,
17
- fakeStuff.convertValToSlot,
18
- fakeStuff.convertSlotToVal,
19
- fakeStuff.registerEntry,
20
- fakeStuff.marshal.serialize,
21
- fakeStuff.marshal.unserialize,
22
- fakeStuff.assertAcceptableSyscallCapdataSize,
23
- );
24
- initializeStoreKindInfo();
25
-
26
- const normalCM = {
27
- makeScalarBigMapStore,
28
- makeScalarBigWeakMapStore,
29
- makeScalarBigSetStore,
30
- makeScalarBigWeakSetStore,
31
- provideBaggage,
32
- flushSchemaCache,
33
- };
34
-
35
- const debugTools = {
36
- getValForSlot: fakeStuff.getValForSlot,
37
- setValForSlot: fakeStuff.setValForSlot,
38
- registerEntry: fakeStuff.registerEntry,
39
- deleteEntry: fakeStuff.deleteEntry,
40
- dumpStore: fakeStuff.dumpStore,
41
- };
42
-
43
- return harden({ ...normalCM, ...debugTools });
44
- }
@@ -1,60 +0,0 @@
1
- import { makeVirtualObjectManager } from '../src/virtualObjectManager.js';
2
-
3
- // Note: `fakeVirtualObjectManager` is something of a misnomer here. The
4
- // virtual object manager being used to implement this realized by the actual
5
- // virtual object manager code. What's being faked is everything else the
6
- // virtual object manager is embedded in, i.e., the kernel and the rest of
7
- // liveslots. In particular, this module can be (and is, and is intended to be)
8
- // used for unit tests for the virtual object manager itself. What you get back
9
- // from `makeFakeVirtualObjectManager` can't be used to program as if you were
10
- // running in a vat because the rest of the vat environment is not present, but
11
- // it *will* execute virtual object manager operations in the same way that the
12
- // real one will because underneath it *is* the real one.
13
-
14
- export function makeFakeVirtualObjectManager(vrm, fakeStuff) {
15
- const {
16
- initializeKindHandleKind,
17
- defineKind,
18
- defineKindMulti,
19
- defineDurableKind,
20
- defineDurableKindMulti,
21
- makeKindHandle,
22
- VirtualObjectAwareWeakMap,
23
- VirtualObjectAwareWeakSet,
24
- flushStateCache,
25
- canBeDurable,
26
- } = makeVirtualObjectManager(
27
- fakeStuff.syscall,
28
- vrm,
29
- fakeStuff.allocateExportID,
30
- fakeStuff.getSlotForVal,
31
- fakeStuff.requiredValForSlot,
32
- fakeStuff.registerEntry,
33
- fakeStuff.marshal.serialize,
34
- fakeStuff.marshal.unserialize,
35
- fakeStuff.assertAcceptableSyscallCapdataSize,
36
- );
37
-
38
- const normalVOM = {
39
- initializeKindHandleKind,
40
- defineKind,
41
- defineKindMulti,
42
- defineDurableKind,
43
- defineDurableKindMulti,
44
- makeKindHandle,
45
- canBeDurable,
46
- VirtualObjectAwareWeakMap,
47
- VirtualObjectAwareWeakSet,
48
- };
49
-
50
- const debugTools = {
51
- getValForSlot: fakeStuff.getValForSlot,
52
- setValForSlot: fakeStuff.setValForSlot,
53
- registerEntry: fakeStuff.registerEntry,
54
- deleteEntry: fakeStuff.deleteEntry,
55
- flushStateCache,
56
- dumpStore: fakeStuff.dumpStore,
57
- };
58
-
59
- return harden({ ...normalVOM, ...debugTools });
60
- }