@agoric/swingset-liveslots 0.10.3-u18a.0 → 0.10.3-u19.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 (66) hide show
  1. package/package.json +22 -22
  2. package/src/boyd-gc.d.ts +12 -0
  3. package/src/boyd-gc.d.ts.map +1 -0
  4. package/src/cache.d.ts +71 -0
  5. package/src/cache.d.ts.map +1 -0
  6. package/src/capdata.d.ts +12 -0
  7. package/src/capdata.d.ts.map +1 -0
  8. package/src/collectionManager.d.ts +46 -0
  9. package/src/collectionManager.d.ts.map +1 -0
  10. package/src/facetiousness.d.ts +25 -0
  11. package/src/facetiousness.d.ts.map +1 -0
  12. package/src/index.d.ts +4 -0
  13. package/src/index.d.ts.map +1 -0
  14. package/src/kdebug.d.ts +7 -0
  15. package/src/kdebug.d.ts.map +1 -0
  16. package/src/liveslots.d.ts +42 -0
  17. package/src/liveslots.d.ts.map +1 -0
  18. package/src/liveslots.js +4 -2
  19. package/src/message.d.ts +45 -0
  20. package/src/message.d.ts.map +1 -0
  21. package/src/parseVatSlots.d.ts +125 -0
  22. package/src/parseVatSlots.d.ts.map +1 -0
  23. package/src/types.d.ts +76 -0
  24. package/src/types.d.ts.map +1 -0
  25. package/src/vatDataTypes.d.ts +170 -0
  26. package/src/vatDataTypes.d.ts.map +1 -0
  27. package/src/vatDataTypes.ts +272 -0
  28. package/src/vatstore-iterators.d.ts +4 -0
  29. package/src/vatstore-iterators.d.ts.map +1 -0
  30. package/src/vatstore-usage.md +197 -0
  31. package/src/virtualObjectManager.d.ts +44 -0
  32. package/src/virtualObjectManager.d.ts.map +1 -0
  33. package/src/virtualReferences.d.ts +61 -0
  34. package/src/virtualReferences.d.ts.map +1 -0
  35. package/src/vpid-tracking.md +92 -0
  36. package/src/watchedPromises.d.ts +31 -0
  37. package/src/watchedPromises.d.ts.map +1 -0
  38. package/test/dummyMeterControl.d.ts +2 -0
  39. package/test/dummyMeterControl.d.ts.map +1 -0
  40. package/test/engine-gc.d.ts +3 -0
  41. package/test/engine-gc.d.ts.map +1 -0
  42. package/test/gc-and-finalize.d.ts +5 -0
  43. package/test/gc-and-finalize.d.ts.map +1 -0
  44. package/test/liveslots-helpers.d.ts +63 -0
  45. package/test/liveslots-helpers.d.ts.map +1 -0
  46. package/test/liveslots-real-gc.test.js +9 -7
  47. package/test/util.d.ts +25 -0
  48. package/test/util.d.ts.map +1 -0
  49. package/test/vat-util.d.ts +9 -0
  50. package/test/vat-util.d.ts.map +1 -0
  51. package/test/waitUntilQuiescent.d.ts +3 -0
  52. package/test/waitUntilQuiescent.d.ts.map +1 -0
  53. package/tools/fakeCollectionManager.d.ts +14 -0
  54. package/tools/fakeCollectionManager.d.ts.map +1 -0
  55. package/tools/fakeVirtualObjectManager.d.ts +32 -0
  56. package/tools/fakeVirtualObjectManager.d.ts.map +1 -0
  57. package/tools/fakeVirtualSupport.d.ts +278 -0
  58. package/tools/fakeVirtualSupport.d.ts.map +1 -0
  59. package/tools/prepare-strict-test-env.d.ts +37 -0
  60. package/tools/prepare-strict-test-env.d.ts.map +1 -0
  61. package/tools/prepare-test-env.d.ts +2 -0
  62. package/tools/prepare-test-env.d.ts.map +1 -0
  63. package/tools/setup-vat-data.d.ts +9 -0
  64. package/tools/setup-vat-data.d.ts.map +1 -0
  65. package/tools/vo-test-harness.d.ts +2 -0
  66. package/tools/vo-test-harness.d.ts.map +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/swingset-liveslots",
3
- "version": "0.10.3-u18a.0",
3
+ "version": "0.10.3-u19.0",
4
4
  "description": "SwingSet ocap support layer",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -14,31 +14,32 @@
14
14
  "lint-fix": "yarn lint:eslint --fix",
15
15
  "lint": "run-s --continue-on-error lint:*",
16
16
  "lint:types": "tsc",
17
- "lint:eslint": "eslint ."
17
+ "lint:eslint": "eslint .",
18
+ "prepack": "tsc --build tsconfig.build.json",
19
+ "postpack": "git clean -f ':!src/types-index.d.ts' '*.d.ts*' '*.tsbuildinfo'"
18
20
  },
19
21
  "dependencies": {
20
- "@agoric/internal": "^0.4.0-u18a.0",
21
- "@agoric/store": "^0.9.3-u18.1",
22
+ "@agoric/internal": "^0.4.0-u19.0",
23
+ "@agoric/store": "^0.9.3-u19.0",
22
24
  "@endo/env-options": "^1.1.8",
23
- "@endo/errors": "^1.2.8",
24
- "@endo/eventual-send": "^1.2.8",
25
- "@endo/exo": "^1.5.7",
26
- "@endo/far": "^1.1.9",
27
- "@endo/init": "^1.1.7",
28
- "@endo/marshal": "^1.6.2",
29
- "@endo/nat": "^5.0.13",
30
- "@endo/pass-style": "^1.4.7",
31
- "@endo/patterns": "^1.4.7",
32
- "@endo/promise-kit": "^1.1.8"
25
+ "@endo/errors": "^1.2.9",
26
+ "@endo/eventual-send": "^1.3.0",
27
+ "@endo/exo": "^1.5.8",
28
+ "@endo/far": "^1.1.10",
29
+ "@endo/init": "^1.1.8",
30
+ "@endo/marshal": "^1.6.3",
31
+ "@endo/nat": "^5.0.14",
32
+ "@endo/pass-style": "^1.4.8",
33
+ "@endo/patterns": "^1.4.8",
34
+ "@endo/promise-kit": "^1.1.9"
33
35
  },
34
36
  "devDependencies": {
35
- "@agoric/kmarshal": "^0.1.1-u18.1",
37
+ "@agoric/kmarshal": "^0.1.1-u19.0",
36
38
  "ava": "^5.3.0"
37
39
  },
38
40
  "files": [
39
- "src/**/*.js",
40
- "src/**/*.d.ts",
41
- "test/**/*.js",
41
+ "src",
42
+ "test",
42
43
  "tools",
43
44
  "exported.js"
44
45
  ],
@@ -59,14 +60,13 @@
59
60
  "require": [
60
61
  "@endo/init/debug.js"
61
62
  ],
62
- "timeout": "20m",
63
- "workerThreads": false
63
+ "timeout": "20m"
64
64
  },
65
65
  "publishConfig": {
66
66
  "access": "public"
67
67
  },
68
68
  "typeCoverage": {
69
- "atLeast": 75.24
69
+ "atLeast": 75.2
70
70
  },
71
- "gitHead": "4e4d2b4dedc5a268178712fc6beb89496518480a"
71
+ "gitHead": "29e9704c375a06bb617027093b30d2d25faa6471"
72
72
  }
@@ -0,0 +1,12 @@
1
+ export function makeBOYDKit({ gcTools, slotToVal, vrm, kernelRecognizableRemotables, syscall, possiblyDeadSet, possiblyRetiredSet, }: {
2
+ gcTools: any;
3
+ slotToVal: any;
4
+ vrm: any;
5
+ kernelRecognizableRemotables: any;
6
+ syscall: any;
7
+ possiblyDeadSet: any;
8
+ possiblyRetiredSet: any;
9
+ }): {
10
+ scanForDeadObjects: () => Promise<void>;
11
+ };
12
+ //# sourceMappingURL=boyd-gc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boyd-gc.d.ts","sourceRoot":"","sources":["boyd-gc.js"],"names":[],"mappings":"AA+YO;;;;;;;;;;EAqMN"}
package/src/cache.d.ts ADDED
@@ -0,0 +1,71 @@
1
+ /**
2
+ * @template V
3
+ * @callback CacheGet
4
+ * @param {string} key
5
+ * @returns {V | undefined}
6
+ */
7
+ /**
8
+ * @template V
9
+ * @callback CacheSet
10
+ * @param {string} key
11
+ * @param {V} value
12
+ * @returns {void}
13
+ */
14
+ /**
15
+ * @callback CacheDelete
16
+ * @param {string} key
17
+ * @returns {void}
18
+ *
19
+ * @callback CacheFlush
20
+ * @returns {void}
21
+ *
22
+ * @callback CacheInsistClear
23
+ * @returns {void}
24
+ */
25
+ /**
26
+ * @template V
27
+ * @typedef {object} Cache
28
+ * @property {CacheGet<V>} get
29
+ * @property {CacheSet<V>} set
30
+ * @property {CacheDelete} delete
31
+ * @property {CacheFlush} flush
32
+ * @property {CacheInsistClear} insistClear
33
+ */
34
+ /**
35
+ * Cache of virtual object/collection state
36
+ *
37
+ * This cache is empty between deliveries. Within a delivery, the
38
+ * first access to some data will cause vatstore reads to populate the
39
+ * cache, then the data is retained until end-of-delivery. Writes to
40
+ * data will update the cache entry and mark it as dirty. At
41
+ * end-of-delivery, we flush the cache, writing out any dirty entries,
42
+ * and deleting all entries.
43
+ *
44
+ * This needs RAM for everything read during a delivery (rather than
45
+ * having a fixed maximum size), but yields a simple (easy to debug)
46
+ * deterministic relationship between data access and reads/writes to
47
+ * the backing store.
48
+ *
49
+ * @template V
50
+ * @param {(key: string) => V} readBacking
51
+ * @param {(key: string, value: V) => void} writeBacking
52
+ * @param {(key: string) => void} deleteBacking
53
+ * @returns {Cache<V>}
54
+ *
55
+ * This cache is part of the virtual object manager and is not intended to be
56
+ * used independently; it is exported only for the benefit of test code.
57
+ */
58
+ export function makeCache<V>(readBacking: (key: string) => V, writeBacking: (key: string, value: V) => void, deleteBacking: (key: string) => void): Cache<V>;
59
+ export type CacheGet<V> = (key: string) => V | undefined;
60
+ export type CacheSet<V> = (key: string, value: V) => void;
61
+ export type CacheDelete = (key: string) => void;
62
+ export type CacheFlush = () => void;
63
+ export type CacheInsistClear = () => void;
64
+ export type Cache<V> = {
65
+ get: CacheGet<V>;
66
+ set: CacheSet<V>;
67
+ delete: CacheDelete;
68
+ flush: CacheFlush;
69
+ insistClear: CacheInsistClear;
70
+ };
71
+ //# sourceMappingURL=cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["cache.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH;;;;;;GAMG;AACH;;;;;;;;;;GAUG;AACH;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,0BATa,CAAC,eACH,CAAC,GAAG,EAAE,MAAM,KAAK,CAAC,gBAClB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI,iBAC/B,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GACnB,KAAK,CAAC,CAAC,CAAC,CAkDpB;qBAvGY,CAAC,UAEH,MAAM,KACJ,CAAC,GAAG,SAAS;qBAIb,CAAC,UAEH,MAAM,SACN,CAAC,KACC,IAAI;gCAIN,MAAM,KACJ,IAAI;+BAGJ,IAAI;qCAGJ,IAAI;kBAGJ,CAAC;SAEA,QAAQ,CAAC,CAAC,CAAC;SACX,QAAQ,CAAC,CAAC,CAAC;YACX,WAAW;WACX,UAAU;iBACV,gBAAgB"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Assert function to ensure that something expected to be a capdata object
3
+ * actually is. A capdata object should have a .body property that's a string
4
+ * and a .slots property that's an array of strings.
5
+ *
6
+ * @param {any} capdata The object to be tested
7
+ * @throws {Error} if, upon inspection, the parameter does not satisfy the above
8
+ * criteria.
9
+ * @returns {asserts capdata is import('./types.js').SwingSetCapData}
10
+ */
11
+ export function insistCapData(capdata: any): asserts capdata is import("./types.js").SwingSetCapData;
12
+ //# sourceMappingURL=capdata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capdata.d.ts","sourceRoot":"","sources":["capdata.js"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,uCALW,GAAG,GAGD,QAAQ,OAAO,IAAI,OAAO,YAAY,EAAE,eAAe,CAQnE"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * @param {*} syscall
3
+ * @param {import('./virtualReferences.js').VirtualReferenceManager} vrm
4
+ * @param {() => number} allocateExportID
5
+ * @param {() => number} allocateCollectionID
6
+ * @param {(val: any) => string | undefined} convertValToSlot
7
+ * @param {*} convertSlotToVal
8
+ * @param {*} registerValue
9
+ * @param {ToCapData<string>} serialize
10
+ * @param {FromCapData<string>} unserialize
11
+ * @param {(capDatas: any) => void} assertAcceptableSyscallCapdataSize
12
+ */
13
+ export function makeCollectionManager(syscall: any, vrm: import("./virtualReferences.js").VirtualReferenceManager, allocateExportID: () => number, allocateCollectionID: () => number, convertValToSlot: (val: any) => string | undefined, convertSlotToVal: any, registerValue: any, serialize: ToCapData<string>, unserialize: FromCapData<string>, assertAcceptableSyscallCapdataSize: (capDatas: any) => void): {
14
+ initializeStoreKindInfo: () => void;
15
+ makeScalarBigMapStore: <K, V>(label?: string, options?: StoreOptions) => MapStore<K, V>;
16
+ makeScalarBigWeakMapStore: <K, V>(label?: string, options?: StoreOptions) => WeakMapStore<K, V>;
17
+ makeScalarBigSetStore: <K>(label?: string, options?: StoreOptions) => SetStore<K>;
18
+ makeScalarBigWeakSetStore: <K>(label?: string, options?: StoreOptions) => WeakSetStore<K>;
19
+ provideBaggage: () => any;
20
+ flushSchemaCache: () => void;
21
+ getRetentionStats: () => {};
22
+ testHooks: {
23
+ obtainStoreKindID: (kindName: any) => any;
24
+ storeSizeInternal: (vobjID: any) => number;
25
+ makeCollection: (label: any, kindName: any, isDurable: any, keyShape: any, valueShape: any) => (string | {
26
+ has: (key: any) => boolean;
27
+ get: (key: any) => any;
28
+ init: (key: any, value: any) => void;
29
+ addToSet: (key: any) => void;
30
+ addAllToSet: (elems: any) => void;
31
+ addAllToMap: (mapEntries: any) => void;
32
+ set: (key: any, value: any) => void;
33
+ delete: (key: any) => void;
34
+ })[];
35
+ };
36
+ };
37
+ export const collectionMetaKeys: Set<string>;
38
+ export type SchemaCacheValue = {
39
+ keyShape: Pattern;
40
+ valueShape: Pattern;
41
+ label: string;
42
+ schemataCapData: object;
43
+ };
44
+ import type { ToCapData } from '@endo/marshal';
45
+ import type { FromCapData } from '@endo/marshal';
46
+ //# sourceMappingURL=collectionManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collectionManager.d.ts","sourceRoot":"","sources":["collectionManager.js"],"names":[],"mappings":"AAmHA;;;;;;;;;;;GAWG;AACH,+CAXW,GAAC,OACD,OAAO,wBAAwB,EAAE,uBAAuB,oBACxD,MAAM,MAAM,wBACZ,MAAM,MAAM,oBACZ,CAAC,GAAG,EAAE,GAAG,KAAK,MAAM,GAAG,SAAS,oBAChC,GAAC,iBACD,GAAC,aACD,UAAU,MAAM,CAAC,eACjB,YAAY,MAAM,CAAC,sCACnB,CAAC,QAAQ,EAAE,GAAG,KAAK,IAAI;;4BAs+BnB,CAAC,EAAC,CAAC,UACL,MAAM,YACN,YAAY,KACV,QAAQ,CAAC,CAAC,EAAC,CAAC,CAAC;gCASb,CAAC,EAAC,CAAC,UACL,MAAM,YACN,YAAY,KACV,YAAY,CAAC,CAAC,EAAC,CAAC,CAAC;4BASjB,CAAC,UACH,MAAM,YACN,YAAY,KACV,QAAQ,CAAC,CAAC,CAAC;gCASX,CAAC,UACH,MAAM,YACN,YAAY,KACV,YAAY,CAAC,CAAC,CAAC;;;;;;;;;;;;;;;;;;EAsB7B;AA7lCD,6CAIG;;cAIW,OAAO;gBACP,OAAO;WACP,MAAM;qBACN,MAAM;;+BAlDqB,eAAe;iCAAf,eAAe"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Assess the facetiousness of a value. If the value is an object containing
3
+ * only named properties and each such property's value is a function, `obj`
4
+ * represents a single facet and 'one' is returned. If each property's value
5
+ * is instead an object of facetiousness 'one', `obj` represents multiple
6
+ * facets and 'many' is returned. In all other cases `obj` does not represent
7
+ * any kind of facet abstraction and 'not' is returned.
8
+ *
9
+ * @typedef {'one'|'many'|'not'} Facetiousness
10
+ *
11
+ * @param {*} obj The (alleged) object to be assessed
12
+ * @returns {Facetiousness} an assessment of the facetiousness of `obj`
13
+ */
14
+ export function assessFacetiousness(obj: any): Facetiousness;
15
+ export function checkAndUpdateFacetiousness(tag: any, desc: any, proposedFacetNames: any): any;
16
+ /**
17
+ * Assess the facetiousness of a value. If the value is an object containing
18
+ * only named properties and each such property's value is a function, `obj`
19
+ * represents a single facet and 'one' is returned. If each property's value
20
+ * is instead an object of facetiousness 'one', `obj` represents multiple
21
+ * facets and 'many' is returned. In all other cases `obj` does not represent
22
+ * any kind of facet abstraction and 'not' is returned.
23
+ */
24
+ export type Facetiousness = "one" | "many" | "not";
25
+ //# sourceMappingURL=facetiousness.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"facetiousness.d.ts","sourceRoot":"","sources":["facetiousness.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,yCAHW,GAAC,GACC,aAAa,CA+BzB;AAGM,+FAwCN;;;;;;;;;4BA7EY,KAAK,GAAC,MAAM,GAAC,KAAK"}
package/src/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * from "./types-index.js";
2
+ export { makeLiveSlots, makeMarshaller } from "./liveslots.js";
3
+ export { insistMessage, insistVatDeliveryObject, insistVatDeliveryResult, insistVatSyscallObject, insistVatSyscallResult } from "./message.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.js"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ export function kdebugEnable(flag: any): void;
2
+ export function kdebug(...args: any[]): void;
3
+ export function legibilizeValue(val: any, slots: any, smallcaps: any): any;
4
+ export function legibilizeMethod(method: any, smallcaps: any): string;
5
+ export function extractMethod(methargsCapdata: any): string;
6
+ export function legibilizeMessageArgs(methargsCapdata: any): any[] | "<unintelligible message args>";
7
+ //# sourceMappingURL=kdebug.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kdebug.d.ts","sourceRoot":"","sources":["kdebug.js"],"names":[],"mappings":"AAEA,8CAEC;AAED,6CAIC;AAED,2EAwEC;AAED,sEAmDC;AAED,4DAaC;AAED,qGAkBC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Instantiate the liveslots layer for a new vat and then populate the vat with
3
+ * a new root object and its initial associated object graph, if any.
4
+ *
5
+ * @param {*} syscall Kernel syscall interface that the vat will have access to
6
+ * @param {*} forVatID Vat ID label, for use in debug diagostics
7
+ * @param {*} vatPowers
8
+ * @param {import('./types.js').LiveSlotsOptions} liveSlotsOptions
9
+ * @param {*} gcTools { WeakRef, FinalizationRegistry, waitUntilQuiescent }
10
+ * @param {LimitedConsole} [liveSlotsConsole]
11
+ * @param {*} [buildVatNamespace]
12
+ *
13
+ * @returns {*} { dispatch }
14
+ *
15
+ * setBuildRootObject should be called, once, with a function that will
16
+ * create a root object for the new vat The caller provided buildRootObject
17
+ * function produces and returns the new vat's root object:
18
+ *
19
+ * buildRootObject(vatPowers, vatParameters)
20
+ *
21
+ * Within the vat, `import { E } from '@endo/eventual-send'` will
22
+ * provide the E wrapper. For any object x, E(x) returns a proxy object
23
+ * that converts any method invocation into a corresponding eventual send
24
+ * to x. That is, E(x).foo(arg1, arg2) is equivalent to x~.foo(arg1,
25
+ * arg2)
26
+ *
27
+ * If x is the presence in this vat of a remote object (that is, an object
28
+ * outside the vat), this will result in a message send out of the vat via
29
+ * the kernel syscall interface.
30
+ *
31
+ * In the same vein, if x is the presence in this vat of a kernel device,
32
+ * vatPowers.D(x) returns a proxy such that a method invocation on it is
33
+ * translated into the corresponding immediate invocation of the device
34
+ * (using, once again, the kernel syscall interface). D(x).foo(args) will
35
+ * perform an immediate syscall.callNow on the device node.
36
+ */
37
+ export function makeLiveSlots(syscall: any, forVatID: any | undefined, vatPowers: any | undefined, liveSlotsOptions: import("./types.js").LiveSlotsOptions, gcTools: any, liveSlotsConsole?: LimitedConsole, buildVatNamespace?: any): any;
38
+ export function makeMarshaller(syscall: any, gcTools: any, vatID?: string): {
39
+ m: any;
40
+ };
41
+ import type { LimitedConsole } from '@agoric/internal/src/js-utils.js';
42
+ //# sourceMappingURL=liveslots.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"liveslots.d.ts","sourceRoot":"","sources":["liveslots.js"],"names":[],"mappings":"AAm9CA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,uCAhCW,GAAC,YACD,GAAC,yBACD,GAAC,gCACD,OAAO,YAAY,EAAE,gBAAgB,WACrC,GAAC,qBACD,cAAc,sBACd,GAAC,GAEC,GAAC,CAgDb;AAGD;;EAIC;oCAtgDiC,kCAAkC"}
package/src/liveslots.js CHANGED
@@ -14,6 +14,8 @@ import { makeCollectionManager } from './collectionManager.js';
14
14
  import { makeWatchedPromiseManager } from './watchedPromises.js';
15
15
  import { makeBOYDKit } from './boyd-gc.js';
16
16
 
17
+ /** @import {LimitedConsole} from '@agoric/internal/src/js-utils.js'; */
18
+
17
19
  const SYSCALL_CAPDATA_BODY_SIZE_LIMIT = 10_000_000;
18
20
  const SYSCALL_CAPDATA_SLOTS_LENGTH_LIMIT = 10_000;
19
21
 
@@ -32,7 +34,7 @@ const SYSCALL_CAPDATA_SLOTS_LENGTH_LIMIT = 10_000;
32
34
  * @param {import('./types.js').LiveSlotsOptions} liveSlotsOptions
33
35
  * @param {*} gcTools { WeakRef, FinalizationRegistry, waitUntilQuiescent, gcAndFinalize,
34
36
  * meterControl }
35
- * @param {Pick<Console, 'debug' | 'log' | 'info' | 'warn' | 'error'>} console
37
+ * @param {LimitedConsole} console
36
38
  * @param {*} buildVatNamespace
37
39
  *
38
40
  * @returns {*} { dispatch }
@@ -1496,7 +1498,7 @@ function build(
1496
1498
  * @param {*} vatPowers
1497
1499
  * @param {import('./types.js').LiveSlotsOptions} liveSlotsOptions
1498
1500
  * @param {*} gcTools { WeakRef, FinalizationRegistry, waitUntilQuiescent }
1499
- * @param {Pick<Console, 'debug' | 'log' | 'info' | 'warn' | 'error'>} [liveSlotsConsole]
1501
+ * @param {LimitedConsole} [liveSlotsConsole]
1500
1502
  * @param {*} [buildVatNamespace]
1501
1503
  *
1502
1504
  * @returns {*} { dispatch }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @typedef {{
3
+ * methargs: import('./types.js').SwingSetCapData, // of [method, args]
4
+ * result: string | undefined | null,
5
+ * }} Message
6
+ */
7
+ /**
8
+ * Assert function to ensure that something expected to be a message object
9
+ * actually is. A message object should have a .method property that's a
10
+ * string, a .args property that's a capdata object, and optionally a .result
11
+ * property that, if present, must be a string.
12
+ *
13
+ * @param {any} message The object to be tested
14
+ *
15
+ * @throws {Error} if, upon inspection, the parameter does not satisfy the above
16
+ * criteria.
17
+ *
18
+ * @returns {asserts message is Message}
19
+ */
20
+ export function insistMessage(message: any): asserts message is Message;
21
+ /**
22
+ * @param {unknown} vdo
23
+ * @returns {asserts vdo is import('./types').VatDeliveryObject}
24
+ */
25
+ export function insistVatDeliveryObject(vdo: unknown): asserts vdo is import("./types").VatDeliveryObject;
26
+ /**
27
+ * @param {unknown} vdr
28
+ * @returns {asserts vdr is VatDeliveryResult}
29
+ */
30
+ export function insistVatDeliveryResult(vdr: unknown): asserts vdr is VatDeliveryResult;
31
+ /**
32
+ * @param {unknown} vso
33
+ * @returns {asserts vso is import('./types').VatSyscallObject}
34
+ */
35
+ export function insistVatSyscallObject(vso: unknown): asserts vso is import("./types").VatSyscallObject;
36
+ /**
37
+ * @param {unknown} vsr
38
+ * @returns {asserts vsr is import('./types').VatSyscallResult}
39
+ */
40
+ export function insistVatSyscallResult(vsr: unknown): asserts vsr is import("./types").VatSyscallResult;
41
+ export type Message = {
42
+ methargs: import("./types.js").SwingSetCapData;
43
+ result: string | undefined | null;
44
+ };
45
+ //# sourceMappingURL=message.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message.d.ts","sourceRoot":"","sources":["message.js"],"names":[],"mappings":"AAGA;;;;;GAKG;AAEH;;;;;;;;;;;;GAYG;AAEH,uCARW,GAAG,GAKD,QAAQ,OAAO,IAAI,OAAO,CAStC;AAED;;;GAGG;AAEH,6CAJW,OAAO,GACL,QAAQ,GAAG,IAAI,OAAO,SAAS,EAAE,iBAAiB,CAwD9D;AAED;;;GAGG;AAEH,6CAJW,OAAO,GACL,QAAQ,GAAG,IAAI,iBAAiB,CAkB5C;AAED;;;GAGG;AAEH,4CAJW,OAAO,GACL,QAAQ,GAAG,IAAI,OAAO,SAAS,EAAE,gBAAgB,CA4E7D;AAED;;;GAGG;AAEH,4CAJW,OAAO,GACL,QAAQ,GAAG,IAAI,OAAO,SAAS,EAAE,gBAAgB,CAkB7D;sBAlNY;IACV,QAAQ,EAAE,OAAO,YAAY,EAAE,eAAe,CAAC;IAC/C,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;CACjC"}
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Parse a vref string into its component parts:
3
+ * {
4
+ * type: STRING, // 'object', 'device', 'promise'
5
+ * allocatedByVat: BOOL, // true=>allocated by vat, false=>by the kernel
6
+ * id: Nat,
7
+ * subid: Nat,
8
+ * baseRef: STRING,
9
+ * facet: Nat,
10
+ * virtual: BOOL, // true=>vref designates a "merely virtual" object (not durable, not ephemeral)
11
+ * durable: BOOL, // designates a durable (not merely virtual, not ephemeral)
12
+ * }
13
+ *
14
+ * A vref string can take one of the forms:
15
+ *
16
+ * T-N
17
+ * T+N
18
+ * T+DN/I
19
+ * T+DN/I:F
20
+ *
21
+ * Where:
22
+ *
23
+ * T is a single character encoding the type of entity being referenced: 'd'
24
+ * for 'device', 'o' for 'object', or 'p' for 'promise'. One of the string
25
+ * values 'device', 'object', or 'promise' is returned as the `type`
26
+ * property of the result.
27
+ *
28
+ * '+' or '-' encodes who allocated the reference: '-' for the kernel
29
+ * (typically an import) or '+ for the vat (typically an export). This is
30
+ * returned in the `allocatedByVat` property of the result as a boolean.
31
+ *
32
+ * D is the durability status: for object exports ("o+"), this will
33
+ * be the letter 'd' for durable objects, the letter 'v' for
34
+ * non-durable ("merely virtual") objects, or empty for
35
+ * "Remotable" (ephemeral) objects. It is empty for object
36
+ * imports ("o-"), and both both imports and exports of all other
37
+ * types (promises, devices)
38
+ *
39
+ * N is a decimal integer representing the identity of the referenced entity.
40
+ * This is returned in the `id` property of the result as a BigInt.
41
+ *
42
+ * I if present (only allowed if T is 'o') is a decimal integer representing
43
+ * the instance id of the referenced object. In this case N denotes a
44
+ * category of objects that share a common shape, either one of the store
45
+ * types or a virtual object kind, and I indicates which instance of that
46
+ * category is being referred to. If present this is returned as the
47
+ * `subid` property of the result as a BigInt.
48
+ *
49
+ * F if present (only allowed if I is also present) is a decimal integer
50
+ * referencing a facet of the referenced object. In this case N/I denotes
51
+ * a particular object instance and F indicates which of several possible
52
+ * facets of that instance is being addressed. If present this is returned
53
+ * in the `facet` property of the result as a BigInt.
54
+ *
55
+ * The `baseRef` property of the result is `vref` stripped of any facet indicator.
56
+ *
57
+ * A "vref" identifies an entity visible to vat code to which messages may be
58
+ * sent and which may be compared for equality to other such entities. Let's
59
+ * call such an entity an "addressable object".
60
+ *
61
+ * A "baseRef" designates an entity that is managed by LiveSlots, both as a unit
62
+ * of garbage collection specifically and as a unit of memory management more
63
+ * generally. Such an entity may be a promise or remotable object or imported
64
+ * presence, all of which will always be JavaScript objects in memory, or it may
65
+ * be a virtual object or collection, which can be in memory or on disk or both.
66
+ * Let's call such an entity a "base object". In most cases this is one and the
67
+ * same with the addressable object that the vref designates, but in the case of
68
+ * a faceted object it is the cohort record as a whole rather than any particular
69
+ * individual facet.
70
+ *
71
+ * XXX TODO: The previous comment suggests some renaming is warranted:
72
+ *
73
+ * In the current implementation, a vref string may only include decimal digits,
74
+ * the letters 'd'/'o'/'p'/'v', and the punctuation characters '+', '-', '/',
75
+ * and ':'. Future evolution of the vref syntax might add more characters to
76
+ * this set, but the characters '|' and ',' are permanently excluded: '|' is
77
+ * used (notably by the collection manager) as delimiter in vatstore keys that
78
+ * include vrefs, and ',' is used as a separator in lists of vrefs.
79
+ *
80
+ * `slotToVal` maps a baseRef to a base object (actually to a weakRef that
81
+ * points to a base object)
82
+ * `getValForSlot` maps a baseRef to a base object, or to undefined if it is not
83
+ * resident in memory
84
+ * `convertSlotToVal` maps a vref to to an addressable object, loading it from
85
+ * disk if necessary
86
+ *
87
+ * `valToSlot` maps an addressable object to a vref
88
+ * `getSlotForVal` maps an addressable object to a vref
89
+ * `convertValToSlot` maps an addressable object to a vref, generating a new
90
+ * vref if necessary
91
+ *
92
+ * @param {string} vref The string to be parsed, as described above.
93
+ *
94
+ * @returns {*} a vref components descriptor corresponding to the vref string
95
+ * parameter, assuming it is syntactically well formed.
96
+ *
97
+ * @throws if the given vref string is syntactically incorrect.
98
+ */
99
+ export function parseVatSlot(vref: string): any;
100
+ /**
101
+ * Generate a vat slot reference string given a type, ownership, and id.
102
+ *
103
+ * @param {'object'|'device'|'promise'} type The type
104
+ * @param {boolean} allocatedByVat Flag: true=>vat allocated, false=>kernel allocated
105
+ * @param {number | bigint} id The id, a Nat.
106
+ *
107
+ * @returns {string} the corresponding vat slot reference string.
108
+ *
109
+ * @throws if type is not one of the above known types.
110
+ */
111
+ export function makeVatSlot(type: "object" | "device" | "promise", allocatedByVat: boolean, id: number | bigint): string;
112
+ export function makeBaseRef(kindID: any, id: any, isDurable: any): string;
113
+ /**
114
+ * Assert function to ensure that a vat slot reference string refers to a
115
+ * slot of a given type.
116
+ *
117
+ * @param {string} type The vat slot type desired, a string.
118
+ * @param {string} vatSlot The vat slot reference string being tested
119
+ *
120
+ * @throws if vatSlot is not of the given type or is malformed.
121
+ *
122
+ * @returns {void}
123
+ */
124
+ export function insistVatType(type: string, vatSlot: string): void;
125
+ //# sourceMappingURL=parseVatSlots.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseVatSlots.d.ts","sourceRoot":"","sources":["parseVatSlots.js"],"names":[],"mappings":"AAcA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiGG;AACH,mCAPW,MAAM,GAEJ,GAAC,CA4Db;AAED;;;;;;;;;;GAUG;AACH,kCARW,QAAQ,GAAC,QAAQ,GAAC,SAAS,kBAC3B,OAAO,MACP,MAAM,GAAG,MAAM,GAEb,MAAM,CAsBlB;AAED,0EAEC;AAED;;;;;;;;;;GAUG;AACH,oCAPW,MAAM,WACN,MAAM,GAIJ,IAAI,CAKhB"}
package/src/types.d.ts ADDED
@@ -0,0 +1,76 @@
1
+ export type makeLiveSlots = () => any;
2
+ /**
3
+ * The MeterControl object gives liveslots a mechanism to disable metering for certain GC-sensitive
4
+ * regions of code. Only the XS worker can actually do metering, but we track the enabled/disabled
5
+ * status on all workers, so that the assertions can be exercised more thoroughly (via non-XS unit
6
+ * tests). MeterControl.isMeteringDisabled()===false does not mean metering is happening, it just
7
+ * means that MeterControl isn't disabling it.
8
+ */
9
+ export type MeterControl = {
10
+ /**
11
+ * Ask whether metering is currently disabled.
12
+ */
13
+ isMeteringDisabled: () => boolean;
14
+ assertIsMetered: any;
15
+ assertNotMetered: any;
16
+ /**
17
+ * Run a callback outside metering
18
+ */
19
+ runWithoutMetering: any;
20
+ /**
21
+ * Run an async callback outside metering
22
+ */
23
+ runWithoutMeteringAsync: any;
24
+ /**
25
+ * Wrap a callback with runWithoutMetering
26
+ */
27
+ unmetered: any;
28
+ };
29
+ export type LiveSlotsOptions = {
30
+ enableDisavow?: boolean;
31
+ relaxDurabilityRules?: boolean;
32
+ allowStateShapeChanges?: boolean;
33
+ };
34
+ export type SwingSetCapData = import("@endo/marshal").CapData<string>;
35
+ export type Message = {
36
+ methargs: SwingSetCapData;
37
+ result: string | undefined | null;
38
+ };
39
+ export type VatDeliveryMessage = [tag: "message", target: string, msg: Message];
40
+ export type VatOneResolution = [vpid: string, isReject: boolean, data: SwingSetCapData];
41
+ export type VatDeliveryNotify = [tag: "notify", resolutions: VatOneResolution[]];
42
+ export type VatDeliveryDropExports = [tag: "dropExports", vrefs: string[]];
43
+ export type VatDeliveryRetireExports = [tag: "retireExports", vrefs: string[]];
44
+ export type VatDeliveryRetireImports = [tag: "retireImports", vrefs: string[]];
45
+ export type VatDeliveryChangeVatOptions = [tag: "changeVatOptions", options: Record<string, unknown>];
46
+ export type VatDeliveryStartVat = [tag: "startVat", vatParameters: SwingSetCapData];
47
+ export type VatDeliveryStopVat = [tag: "stopVat", disconnectObject: SwingSetCapData];
48
+ export type VatDeliveryBringOutYourDead = [tag: "bringOutYourDead"];
49
+ export type VatDeliveryObject = VatDeliveryMessage | VatDeliveryNotify | VatDeliveryDropExports | VatDeliveryRetireExports | VatDeliveryRetireImports | VatDeliveryChangeVatOptions | VatDeliveryStartVat | VatDeliveryStopVat | VatDeliveryBringOutYourDead;
50
+ export type MeterConsumption = {
51
+ compute: number;
52
+ };
53
+ export type VatDeliveryResult = [tag: "ok", results: any, usage: MeterConsumption | null] | [tag: "error", message: string, usage: MeterConsumption | null];
54
+ export type VatSyscallSend = [tag: "send", target: string, msg: Message];
55
+ export type VatSyscallCallNow = [tag: "callNow", target: string, method: string, args: SwingSetCapData];
56
+ export type VatSyscallSubscribe = [tag: "subscribe", vpid: string];
57
+ export type VatSyscallResolve = [tag: "resolve", resolutions: VatOneResolution[]];
58
+ export type VatSyscallExit = [tag: "exit", isFailure: boolean, info: SwingSetCapData];
59
+ export type VatSyscallVatstoreGet = [tag: "vatstoreGet", key: string];
60
+ export type VatSyscallVatstoreGetNextKey = [tag: "vatstoreGetNextKey", priorKey: string];
61
+ export type VatSyscallVatstoreSet = [tag: "vatstoreSet", key: string, data: string];
62
+ export type VatSyscallVatstoreDelete = [tag: "vatstoreDelete", key: string];
63
+ export type VatSyscallDropImports = [tag: "dropImports", slots: string[]];
64
+ export type VatSyscallRetireImports = [tag: "retireImports", slots: string[]];
65
+ export type VatSyscallRetireExports = [tag: "retireExports", slots: string[]];
66
+ export type VatSyscallAbandonExports = [tag: "abandonExports", slots: string[]];
67
+ export type VatSyscallObject = VatSyscallSend | VatSyscallCallNow | VatSyscallSubscribe | VatSyscallResolve | VatSyscallExit | VatSyscallVatstoreGet | VatSyscallVatstoreGetNextKey | VatSyscallVatstoreSet | VatSyscallVatstoreDelete | VatSyscallDropImports | VatSyscallRetireImports | VatSyscallRetireExports | VatSyscallAbandonExports;
68
+ export type VatSyscallResultOk = [tag: "ok", data: SwingSetCapData | string | string[] | null];
69
+ export type VatSyscallResultError = [tag: "error", err: string];
70
+ export type VatSyscallResult = VatSyscallResultOk | VatSyscallResultError;
71
+ export type VatSyscallHandler = (vso: VatSyscallObject) => VatSyscallResult;
72
+ export type PromiseWatcher<V, A extends any[] = unknown[]> = {
73
+ onFulfilled?: (value: V, ...args: A) => void;
74
+ onRejected?: (reason: unknown, ...args: A) => void;
75
+ };
76
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@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