hydo-assert 0.0.0-stage → 0.3.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.
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,249 @@
1
- # Temporary Holding Version
1
+ # hydo-assert for JavaScript (Node.js)
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [hydo](https://github.com/kakoc/hydo) runs a whole system in a deterministic virtual machine,
4
+ injects faults (process kills, network faults, power cuts, disk errors) and replays every
5
+ failure bit for bit. This package lets a Node.js program that runs under hydo say, from the
6
+ inside, what must be true and what should happen. hydo collects what the program reports, and
7
+ an exploration (many runs with different faults) reports each property as passed, failed (with
8
+ a schedule that replays the failure) or never exercised.
9
+
10
+ The package has no dependencies, and it works from CommonJS and from ES modules. It ships
11
+ TypeScript types, and it needs Node.js 16 or later. Outside hydo it does almost nothing: the records go to
12
+ standard error (or nowhere), and fault points stay off.
13
+
14
+ ## Install
15
+
16
+ ```sh
17
+ npm install hydo-assert
18
+ ```
19
+
20
+ In a guest image without npm, copy `package.json`, `index.js` and `index.mjs` (and
21
+ `history.js` and `history.mjs` for histories) to `node_modules/hydo-assert/` next to the
22
+ program.
23
+
24
+ ## A complete program
25
+
26
+ A small key/value store that declares three properties and checks them:
27
+
28
+ ```js
29
+ const ha = require('hydo-assert'); // or: import * as ha from 'hydo-assert';
30
+
31
+ const READ_BACK = ha.always('kv.read_back', 'every acknowledged write reads back with its value');
32
+ const OVERWRITE = ha.sometimes('kv.overwrite', 'a write replaced an existing value');
33
+ const LOST_REPLY = ha.buggify('kv.lost_reply', 'the write lands but its reply is lost');
34
+
35
+ ha.catalog(); // list every property, also the ones that never run
36
+ const store = new Map();
37
+ ha.setupComplete(); // the system is ready: hydo may start injecting faults
38
+
39
+ for (const [key, value] of [['a', 1], ['b', 2], ['a', 3]]) {
40
+ const old = store.get(key);
41
+ store.set(key, value);
42
+ OVERWRITE.check(old !== undefined, { key });
43
+ if (LOST_REPLY.fire({ key })) {
44
+ continue; // the client never hears back (only when hydo turns this point on)
45
+ }
46
+ const acked = store.get(key) === value;
47
+ READ_BACK.check(acked, { key, value });
48
+ }
49
+ ```
50
+
51
+ Run it with `HYDO_ASSERT_OUT=stderr` to see what it reports. It writes these lines (under hydo
52
+ they go to the guest's console, where hydo reads them):
53
+
54
+ ```text
55
+ HYDO-ASSERT-DECL {"t":"always","id":"kv.read_back","msg":"every acknowledged write reads back with its value"}
56
+ HYDO-ASSERT-DECL {"t":"sometimes","id":"kv.overwrite","msg":"a write replaced an existing value"}
57
+ HYDO-ASSERT-DECL {"t":"sometimes","id":"buggify.kv.lost_reply","msg":"fault point fired: the write lands but its reply is lost"}
58
+ HYDO-SETUP-COMPLETE
59
+ HYDO-ASSERT {"t":"always","id":"kv.read_back","ok":true,"msg":"every acknowledged write reads back with its value","details":{"key":"a","value":1}}
60
+ HYDO-ASSERT {"t":"sometimes","id":"kv.overwrite","ok":true,"msg":"a write replaced an existing value","details":{"key":"a"}}
61
+ ```
62
+
63
+ A process writes each outcome of a property once: the first pass and the first failure, with
64
+ the details of that evaluation. That is why the later passes of `kv.read_back` write nothing.
65
+
66
+ ## How to
67
+
68
+ ### Declare properties and check them
69
+
70
+ A property has an id (stable across versions of your program) and a message for people. Its
71
+ kind says what hydo expects:
72
+
73
+ | kind | the property holds when | hydo reports a failure when |
74
+ |---|---|---|
75
+ | `always` | the condition is true every time, and it is checked at least once | it is false once, or never checked |
76
+ | `alwaysOrUnreachable` | the condition is true every time it is checked | it is false once |
77
+ | `sometimes` | the condition is true at least once in an exploration | it is never true |
78
+ | `reachable` | the code is reached at least once in an exploration | it is never reached |
79
+ | `unreachable` | the code is never reached | it is reached |
80
+
81
+ Declare properties at the top level of a module, so that the catalog lists them once the
82
+ module is loaded:
83
+
84
+ ```js
85
+ const ha = require('hydo-assert');
86
+
87
+ const STORED = ha.always('kv.stored', 'every acknowledged write is stored');
88
+ const PARSES = ha.alwaysOrUnreachable('kv.log_parses', 'every complete log line parses');
89
+ const RETRIED = ha.sometimes('kv.retried', 'a client retried a request');
90
+ const RECOVERED = ha.reachable('kv.recovered', 'the server replayed a non-empty log');
91
+ const UNKNOWN = ha.unreachable('kv.unknown_command', 'the server got a command it does not know');
92
+
93
+ STORED.check(true, { key: 'a' }); // returns the condition
94
+ PARSES.check(true); // the details are optional
95
+ RETRIED.check(false); // a false `sometimes` writes nothing
96
+ RECOVERED.hit({ entries: 3 });
97
+ const command = 'GET';
98
+ if (command !== 'GET' && command !== 'SET') {
99
+ UNKNOWN.hit({ command });
100
+ }
101
+ ```
102
+
103
+ ### Compare two values
104
+
105
+ `cmp` checks `left op right` and puts both values and the operator into the details, so a
106
+ failure shows them:
107
+
108
+ ```js
109
+ const ha = require('hydo-assert');
110
+
111
+ const LOG_SIZE = ha.always('kv.log_size', 'the log stays under its cap');
112
+ const size = 12;
113
+ LOG_SIZE.cmp(size, '<=', 10000); // details: {"left":12,"op":"<=","right":10000}
114
+ ```
115
+
116
+ The operator is one of `<`, `<=`, `==`, `!=`, `>=` and `>`; the values are numbers or bigints.
117
+
118
+ ### Check that something happens in time (eventually)
119
+
120
+ An `eventually` property says that after this point, the condition becomes true within a
121
+ deadline. For example: after a restart, the server answers within 5 seconds. Time inside a hydo
122
+ guest is deterministic, so the verdict is the same on every replay.
123
+
124
+ ```js
125
+ const ha = require('hydo-assert');
126
+
127
+ const BACK = ha.eventually('kv.back', 'the server answers within 5 s of its start', 5000); // ms
128
+ const started = Date.now();
129
+ const answers = async () => Date.now() - started >= 20; // stands for a real request
130
+
131
+ (async () => {
132
+ const inTime = await BACK.awaitCond(answers, 5); // polls every 5 ms
133
+ if (!inTime) throw new Error('late');
134
+
135
+ // Or mark the start and the end yourself:
136
+ const watch = BACK.begin();
137
+ // ... the server comes up ...
138
+ watch.done(); // or watch.expire() when you know it will not
139
+ })();
140
+ ```
141
+
142
+ `awaitCond` keeps the event loop running between checks, and its condition may return a
143
+ promise. `awaitCondSync` blocks the thread instead, for scripts that have nothing else to do.
144
+
145
+ ### Add a fault point (BUGGIFY)
146
+
147
+ A fault point is a place where your program misbehaves on purpose: it drops a reply, fails a
148
+ write, waits too long. Normally the point does nothing (`fire` returns false). hydo can turn
149
+ points on for a run, so that faults happen where only your program can make them. FoundationDB
150
+ calls this technique BUGGIFY.
151
+
152
+ ```js
153
+ const ha = require('hydo-assert');
154
+
155
+ const LOST_REPLY = ha.buggify('kv.lost_reply_point', 'the write lands but its reply is lost');
156
+ const SLOW_DISK = ha.buggify('kv.slow_disk', 'a write takes 10 ms longer');
157
+
158
+ let reply = 'OK';
159
+ if (LOST_REPLY.fire()) {
160
+ reply = null; // misbehave: the client never gets the reply
161
+ }
162
+ const delay = SLOW_DISK.fire({ key: 'a' }) ? 10 : 0;
163
+ setTimeout(() => console.log(reply), delay);
164
+ ```
165
+
166
+ To let hydo turn the points on, add `buggify: true` to the project's `hydo.yaml` and explore
167
+ with `hydo explore --buggify`. Each run then gets a seed that turns some points on, and a point
168
+ that is on fires on some of its calls. To try it outside hydo, set
169
+ `HYDO_BUGGIFY=<seed in hex>,<points on, per mille>,<calls that fire, per mille>`; for example
170
+ `HYDO_BUGGIFY=2a,1000,1000` makes every point fire every time.
171
+
172
+ ### Record an operation history
173
+
174
+ hydo can check a whole history of operations after a run. It checks that every read is
175
+ consistent with the writes before it (linearizability per key), and that no list append goes
176
+ missing. Your workload's
177
+ client records each operation twice: when it starts (`invoke`) and when the outcome is known.
178
+
179
+ ```js
180
+ const hh = require('hydo-assert/history'); // or: import * as hh from 'hydo-assert/history';
181
+
182
+ const kv = hh.history('kv');
183
+ const write = kv.invoke(3, 'write', 'k1', hh.enc('v1')); // client 3, before the request
184
+ // ... send the request, then record the outcome:
185
+ write.ok(); // it happened; fail(): it did not; info(): the outcome is unknown
186
+ const read = kv.invoke(3, 'read', 'k1');
187
+ read.ok('k1', hh.valueOrNil('v1'));
188
+ ```
189
+
190
+ Then name the history in the project's `hydo.yaml`:
191
+
192
+ ```yaml
193
+ checks:
194
+ - id: kv.linearizable
195
+ type: linearizable
196
+ model: register
197
+ history: kv
198
+ msg: every read sees the latest acknowledged write
199
+ ```
200
+
201
+ `hydo guide checks` describes the checks and their options.
202
+
203
+ ### Choose where the records go
204
+
205
+ Under hydo the records go to the guest's console (`/dev/ttyS0` for properties, `/dev/console`
206
+ for histories), which hydo reads even when the program's standard output goes to a log file.
207
+ Outside hydo, where the console cannot be opened, they go to standard error. Two variables
208
+ change this, and each is read once, at the first record:
209
+
210
+ - `HYDO_ASSERT_OUT`: a path of an existing file, `stderr`, or `off` for the properties;
211
+ - `HYDO_HIST_OUT`: a path (created if missing), `stderr`, or `off` for the histories.
212
+
213
+ ### Run a Node.js program in a hydo guest
214
+
215
+ A complete project with a `hydo.yaml` for hydo on a Mac is the node-kv example:
216
+ <https://github.com/kakoc/hydo/tree/main/hydo/onboard/examples/node-kv>.
217
+
218
+ ## Reference
219
+
220
+ - The API: the TypeScript declarations `index.d.ts` and `history.d.ts`, with a comment on every
221
+ call (your editor shows them).
222
+ - The records, and how hydo judges each property type:
223
+ <https://github.com/kakoc/hydo/blob/main/hydo/ASSERTIONS.md>.
224
+ - The history format and the checkers:
225
+ <https://github.com/kakoc/hydo/blob/main/hydo/HISTORIES.md>.
226
+ - The same SDK for Rust, Python and Go writes the same records, byte for byte:
227
+ <https://github.com/kakoc/hydo/tree/main/sdk>.
228
+
229
+ Rules of this package:
230
+
231
+ - The catalog (`catalog()`) lists the properties in the order they were declared. Call it
232
+ once, early, in the process whose console hydo reads.
233
+ - Details are encoded as Go's `encoding/json` encodes the same values:
234
+ - object and `Map` keys in UTF-8 byte order;
235
+ - a `Set` or a typed array as an array, and a `Uint8Array` or `Buffer` as base64;
236
+ - a bigint as an integer, with `undefined` and functions left out.
237
+
238
+ Details that are not an object are wrapped as `{"value": ...}`. A record whose details hold a
239
+ NaN, an infinity, or a cycle is not written.
240
+ - Every record is one synchronous write, so it is on the console before the call returns. The
241
+ ES module entry re-exports the CommonJS one, so a program that uses both has one state; a
242
+ worker thread has its own.
243
+ - A history's process is an integer or a token without spaces; its arguments are tokens
244
+ (encode free-form values with `enc`). Versions are int64 values (pass a bigint beyond 2^53).
245
+ A process has at most one operation in flight.
246
+
247
+ ## License
248
+
249
+ Apache-2.0.
package/history.d.mts ADDED
@@ -0,0 +1,4 @@
1
+ // Types of hydo-assert/history (ESM entry): the same declarations as the CommonJS entry.
2
+ import m from './history.js';
3
+ export * from './history.js';
4
+ export default m;
package/history.d.ts ADDED
@@ -0,0 +1,66 @@
1
+ // Types of hydo-assert/history (CommonJS entry). The wire format and checkers:
2
+ // https://github.com/kakoc/hydo/blob/main/hydo/HISTORIES.md
3
+
4
+ /** A record argument: a string that is already one token (see enc), or an integer. */
5
+ export type Token = string | number | bigint;
6
+
7
+ /** The value of an absent key (register model). */
8
+ export declare const NIL: 'nil';
9
+
10
+ /**
11
+ * One named history: the `history:` of a check in the project's `hydo.yaml`.
12
+ * @example const kv = new History('kv');
13
+ */
14
+ export declare class History {
15
+ /** @param name the history's name, `[A-Za-z0-9_.-]+` */
16
+ constructor(name: string);
17
+ /** The history's name. */
18
+ readonly name: string;
19
+ /**
20
+ * Records the invocation of f(args...) by process `proc` (an integer, or a token without
21
+ * spaces) and returns the operation. Record it before sending the request.
22
+ */
23
+ invoke(proc: number | bigint | string, f: string, ...args: Token[]): Op;
24
+ /** Writes one raw record (`type` is invoke, ok, fail or info). */
25
+ record(proc: number | bigint | string, type: 'invoke' | 'ok' | 'fail' | 'info' | string, f: string, ...args: Token[]): void;
26
+ }
27
+
28
+ /** An invoked operation waiting for its completion. */
29
+ export declare class Op {
30
+ private constructor();
31
+ /** The history the operation belongs to. */
32
+ readonly history: History;
33
+ /** The process that invoked it. */
34
+ readonly proc: string;
35
+ /** The operation's function, for example `'write'`. */
36
+ readonly f: string;
37
+ /** The invocation's arguments, as tokens. */
38
+ readonly args: string[];
39
+ /** A successful completion; with no args the invocation's are repeated. */
40
+ ok(...args: Token[]): void;
41
+ /** The operation definitely had no effect. */
42
+ fail(): void;
43
+ /** The outcome is unknown (a timeout, a lost connection). */
44
+ info(): void;
45
+ }
46
+
47
+ /** new History(name). */
48
+ export declare function history(name: string): History;
49
+
50
+ /** One token from a value: Go's hydohist.Enc on the UTF-8 bytes. */
51
+ export declare function enc(v: string | number | bigint): string;
52
+ /** "enc(v)@version" (version: an int64). */
53
+ export declare function ver(v: string | number | bigint, version: number | bigint): string;
54
+ /**
55
+ * enc(v) if present, else NIL. With one argument, null and undefined are absent; with two, the
56
+ * second says whether the value is present (Go's ValOrNil(v, ok)).
57
+ */
58
+ export declare function valueOrNil(v: string | number | bigint | null | undefined, ok?: boolean): string;
59
+ /** "[e1,e2,...]" with each element encoded. */
60
+ export declare function list(...elems: Array<string | number | bigint>): string;
61
+ /** The txn micro-op "a:<k>:<e>". */
62
+ export declare function append(k: string | number | bigint, e: string | number | bigint): string;
63
+ /** The txn micro-op "r:<k>" (invocation). */
64
+ export declare function read(k: string | number | bigint): string;
65
+ /** The txn micro-op "r:<k>:[...]" (completion). */
66
+ export declare function readResult(k: string | number | bigint, ...l: Array<string | number | bigint>): string;