@openlfcp/client 0.1.0-rc.1

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,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,27 @@
1
+ # @openlfcp/client
2
+
3
+ An LFCP client on top of the other packages: the WebSocket session (`SyncClient`), Control and Data Plane synchronization, the outbound queue, applying received units to a Data Profile (`DataUnitApplier`) with the crash-loop breaker, invitations, Snapshots and storage helpers.
4
+
5
+ ```sh
6
+ npm install @openlfcp/client@next
7
+ ```
8
+
9
+ ESM only; Node.js 24 or later (browsers and Electron for every package except `@openlfcp/storage-node`).
10
+
11
+ ## Scope
12
+
13
+ Part of the OpenLFCP TypeScript SDK, which implements the OpenLFCP MVP 0.1
14
+ subset of [LFCP-WIRE-01](https://github.com/openlfcp/spec/blob/main/wire/LFCP-WIRE-01.md)
15
+ at `mvp-0.1-baseline.8`, not every deferred WIRE-01 feature. It does not
16
+ claim full LFCP-WIRE-01 conformance. This is a release candidate
17
+ (`0.1.0-rc.1`, npm dist-tag `next`): APIs may still change.
18
+
19
+ ## Links
20
+
21
+ - Specification: [openlfcp/spec](https://github.com/openlfcp/spec)
22
+ - Source and the other SDK packages: [openlfcp/sdk-ts](https://github.com/openlfcp/sdk-ts)
23
+ - Issues: [openlfcp/sdk-ts/issues](https://github.com/openlfcp/sdk-ts/issues)
24
+
25
+ ## License
26
+
27
+ Apache-2.0. See [LICENSE](LICENSE).
@@ -0,0 +1,299 @@
1
+ import { type ActorSequence, type DataEpoch, type DataUnitId, type PrincipalId, type ResourceId } from "@openlfcp/core";
2
+ import { type ResourceDEK } from "@openlfcp/crypto";
3
+ import type { LfcpStorage } from "@openlfcp/storage";
4
+ import { type ControlView, type DataProfileCodec, type DataUnitCheckOptions, type DataUnitEquivocation, type DataUnitQuarantined, type ReceivedDataUnit } from "@openlfcp/wire";
5
+ /**
6
+ * Applying received Data Units to the Resource's Data Profile (LFCP-033).
7
+ *
8
+ * This is where LFCP security ends and application semantics begin. The
9
+ * LFCP side is receiveDataUnit (LFCP-025), unchanged and in its order:
10
+ * structure → actor → signature → equivocation → referenced head →
11
+ * data/write at that head → epoch and cutoff → DEK → AEAD → profile
12
+ * decode → actor hash chain (accepted or held). Only an accepted unit
13
+ * reaches the profile, and only once: the Data Unit ID is the idempotency
14
+ * boundary.
15
+ *
16
+ * The profile side is a DataProfileHandler, selected by the Resource's
17
+ * Genesis data_profile. The applier knows no profile: the Shared Objects
18
+ * handler lives in @openlfcp/shared-objects. A Resource whose profile has
19
+ * no handler is PROFILE_UNSUPPORTED: its units are verified without a DEK
20
+ * and kept, and their plaintext is never decrypted or applied.
21
+ *
22
+ * Three ways a valid unit can wait, kept apart:
23
+ * - held (§26.2, G-DP1): its actor chain does not link yet; retried here
24
+ * when the actor's previous unit is accepted;
25
+ * - profile-pending: LFCP-accepted, but the profile cannot merge it until
26
+ * other units' content arrives (Automerge dependencies); the handler
27
+ * buffers it and merges it when they do;
28
+ * - quarantined (STALE_DATA_EPOCH): never merged automatically.
29
+ *
30
+ * Crash-loop breaker (EngineGuard): every engine call on received units
31
+ * (decode and apply, also when replaying) runs with a durable record of
32
+ * the units it covers. After a crash those units are suspects, received
33
+ * and replayed alone; a unit that crashes the engine again by itself is
34
+ * quarantined locally (status local-failure, INVALID_AUTOMERGE_BYTES) and
35
+ * never given to the engine again. Exclusion and rebuild (G-EP7) work on
36
+ * units already merged once and are not guarded.
37
+ */
38
+ /** An LFCP-accepted unit as the profile sees it. */
39
+ export interface ProfileUnit {
40
+ readonly unitId: DataUnitId;
41
+ readonly resourceId: ResourceId;
42
+ readonly actor: PrincipalId;
43
+ readonly seq: ActorSequence;
44
+ readonly epoch: DataEpoch;
45
+ }
46
+ /** A profile-level finding about the state after a merge (e.g. a PROFILE_INVALID object). */
47
+ export interface ProfileDiagnostic {
48
+ readonly objectId?: string;
49
+ readonly code: string;
50
+ readonly diagnostic?: string;
51
+ readonly pointer?: string;
52
+ readonly message: string;
53
+ }
54
+ export interface ProfileApplyResult {
55
+ /** Units merged by this call: the unit itself when it merged now, and buffered units it unblocked. */
56
+ readonly merged: readonly DataUnitId[];
57
+ /** Objects whose state changed. */
58
+ readonly objects: readonly string[];
59
+ /** Findings about the merged state; they never undo the merge (profile §77 isolation). */
60
+ readonly diagnostics: readonly ProfileDiagnostic[];
61
+ /** Why the unit is buffered by the profile when it did not merge now. */
62
+ readonly pending?: string;
63
+ }
64
+ /** What a handler's applyBatch reports: per unit merged, pending or rejected, and the objects once. */
65
+ export interface ProfileBatchResult {
66
+ /** Units merged now: the batch's and buffered units it unblocked. */
67
+ readonly merged: readonly DataUnitId[];
68
+ /** Units buffered by the profile (the batch's, and earlier ones still waiting). */
69
+ readonly pending: readonly DataUnitId[];
70
+ /** Units the profile refused, with the code and message apply would have thrown. */
71
+ readonly rejected: readonly {
72
+ readonly unitId: DataUnitId;
73
+ readonly code: string;
74
+ readonly message: string;
75
+ }[];
76
+ readonly objects: readonly string[];
77
+ readonly diagnostics: readonly ProfileDiagnostic[];
78
+ }
79
+ export interface ProfileExcludeResult {
80
+ /** Objects whose state changed. */
81
+ readonly objects: readonly string[];
82
+ /** Merged units that now wait for an excluded unit's content (profile-pending). */
83
+ readonly pending: readonly DataUnitId[];
84
+ }
85
+ /** The application side of one Data Profile. Implemented by profile packages. */
86
+ export interface DataProfileHandler<T> {
87
+ /** The Genesis data_profile it implements (§15, §27). */
88
+ readonly dataProfile: string;
89
+ /**
90
+ * The codec for one unit's plaintext. The unit's Resource and signing
91
+ * actor are known before its plaintext is decoded, so the codec can bind
92
+ * the content to them; decode throws to reject (local-failure, never
93
+ * merged, never marked accepted).
94
+ */
95
+ codecFor(unit: {
96
+ readonly resourceId: ResourceId;
97
+ readonly actor: PrincipalId;
98
+ }): DataProfileCodec<T>;
99
+ /** Merges one accepted unit's decoded value. Throws when the profile refuses it. */
100
+ apply(unit: ProfileUnit, value: T): ProfileApplyResult;
101
+ /**
102
+ * Merges many accepted units at once, as apply would one by one (a
103
+ * refusal rejects only its unit). Optional: with it, receiveBatch and
104
+ * replayStored hand the profile a whole catch-up at once, which an engine
105
+ * such as Automerge applies far faster than unit by unit.
106
+ */
107
+ applyBatch?(units: readonly {
108
+ readonly unit: ProfileUnit;
109
+ readonly value: T;
110
+ }[]): ProfileBatchResult;
111
+ /**
112
+ * LFCP-WIRE-01 §19.1 (G-EP7): takes merged or buffered units out again, so that
113
+ * the state equals the state built from the remaining accepted units.
114
+ */
115
+ exclude(unitIds: readonly DataUnitId[]): ProfileExcludeResult;
116
+ /**
117
+ * Whether the profile state holds this unit's content. With it, units
118
+ * merged after the last persisted checkpoint can be replayed from storage
119
+ * after a restart (DataUnitApplier.replayStored).
120
+ */
121
+ has?(unitId: DataUnitId): boolean;
122
+ /** Forgets the whole profile state, to rebuild it from accepted units (SNAP-EP). */
123
+ reset?(): void;
124
+ }
125
+ interface Applied {
126
+ readonly unitId: DataUnitId;
127
+ readonly dataProfile: string;
128
+ readonly actor: PrincipalId;
129
+ readonly seq: ActorSequence;
130
+ readonly epoch: DataEpoch;
131
+ /**
132
+ * Whether the unit may be advertised in Haves. Always false here: a unit
133
+ * is advertised only once the sync layer knows its storage is durable
134
+ * (LFCP-036).
135
+ */
136
+ readonly haveEligible: false;
137
+ /** Buffered units this one unblocked, merged now. */
138
+ readonly alsoMerged: readonly DataUnitId[];
139
+ /** Held units of the same actor that were retried after this one, with their outcomes. */
140
+ readonly released: readonly ApplyOutcome[];
141
+ }
142
+ /**
143
+ * Two or more signature-valid units for one (resource, actor, seq).
144
+ * LFCP-WIRE-01 §26.2 (G-DP5): no unit of the set stays merged, since keeping the
145
+ * first one would choose by arrival order (§26.2 forbids choosing). Every
146
+ * unit is marked "equivocation" and un-accepted; merged ones were taken out
147
+ * of the profile state.
148
+ */
149
+ export type EquivocationOutcome = DataUnitEquivocation & {
150
+ /** Units of the set that were merged and are now excluded from the profile state. */
151
+ readonly excluded: readonly DataUnitId[];
152
+ /** Objects whose state changed through the exclusion. */
153
+ readonly objects: readonly string[];
154
+ /** Merged units that now wait in the profile for an excluded unit's content. */
155
+ readonly pending: readonly DataUnitId[];
156
+ /** Held units of the actor retried after the exclusion (§26.2, G-DP1-GAP). */
157
+ readonly released: readonly ApplyOutcome[];
158
+ };
159
+ /** The outcome of one received Data Unit. */
160
+ export type ApplyOutcome =
161
+ /** Accepted by LFCP and merged into the profile state. */
162
+ (Applied & {
163
+ readonly kind: "applied";
164
+ readonly objects: readonly string[];
165
+ readonly diagnostics: readonly ProfileDiagnostic[];
166
+ })
167
+ /** Accepted by LFCP; the profile buffers it until the content it builds on arrives. */
168
+ | (Applied & {
169
+ readonly kind: "profile-pending";
170
+ readonly detail: string;
171
+ })
172
+ /** Accepted by LFCP, refused by the profile when merging: never merged. */
173
+ | {
174
+ readonly kind: "profile-rejected";
175
+ readonly unitId: DataUnitId;
176
+ readonly dataProfile: string;
177
+ readonly code: string;
178
+ readonly message: string;
179
+ }
180
+ /** The Resource's Data Profile has no handler (§62 PROFILE_UNSUPPORTED): verified and kept, never decrypted. */
181
+ | {
182
+ readonly kind: "profile-unsupported";
183
+ readonly code: "PROFILE_UNSUPPORTED";
184
+ readonly unitId: DataUnitId;
185
+ readonly dataProfile: string;
186
+ }
187
+ /**
188
+ * A unit whose content a loaded Snapshot already holds: verified without
189
+ * a DEK and accepted, never decrypted or merged again (acceptCovered).
190
+ */
191
+ | {
192
+ readonly kind: "covered";
193
+ readonly unitId: DataUnitId;
194
+ readonly dataProfile: string;
195
+ /** Held units of the same actor that were retried after this one, with their outcomes. */
196
+ readonly released: readonly ApplyOutcome[];
197
+ }
198
+ /**
199
+ * The unit crashed the profile engine twice by itself (EngineGuard): it
200
+ * is quarantined on this device and never applied again. Local only: no
201
+ * wire code; the unit may be valid elsewhere.
202
+ */
203
+ | {
204
+ readonly kind: "engine-crash";
205
+ readonly code: "INVALID_AUTOMERGE_BYTES";
206
+ readonly unitId: DataUnitId;
207
+ readonly message: string;
208
+ } | EquivocationOutcome | Exclude<ReceivedDataUnit<unknown>, {
209
+ readonly kind: "accepted" | "equivocation";
210
+ }>;
211
+ /** A merged unit that a newly known Key Epoch puts beyond its cutoff (G-EP7). */
212
+ export interface ExcludedUnit {
213
+ readonly unitId: DataUnitId;
214
+ readonly quarantine: Omit<DataUnitQuarantined, "kind" | "unitId">;
215
+ }
216
+ export interface EpochReconciliation {
217
+ /** Units taken out of the profile state and now quarantined. */
218
+ readonly excluded: readonly ExcludedUnit[];
219
+ /** Objects whose state changed. */
220
+ readonly objects: readonly string[];
221
+ /** Merged units that now wait in the profile for an excluded unit's content. */
222
+ readonly pending: readonly DataUnitId[];
223
+ /**
224
+ * The Key Epoch cut off units a loaded Snapshot covered: the Snapshot
225
+ * state was dropped and rebuilt from accepted units (SNAP-EP); the units
226
+ * it covered must be fetched again.
227
+ */
228
+ readonly snapshotDropped: boolean;
229
+ /**
230
+ * Held units retried once the excluded units stopped being their actors'
231
+ * latest accepted ones (§26.2, G-DP1-GAP), with their outcomes.
232
+ */
233
+ readonly released: readonly ApplyOutcome[];
234
+ }
235
+ export interface DataUnitApplierOptions extends DataUnitCheckOptions {
236
+ /**
237
+ * Where verified units, their exact bytes, statuses and the accepted
238
+ * marks live (the wire SeenUnits runs on it). InMemoryLfcpStorage for
239
+ * tests and development only.
240
+ */
241
+ readonly storage: Pick<LfcpStorage, "dataUnits" | "snapshots" | "commit" | "localMarks">;
242
+ /** The DEK of a Data Epoch, if this client holds it (e.g. dekResolver). */
243
+ readonly dek: (epoch: DataEpoch) => ResourceDEK | undefined | Promise<ResourceDEK | undefined>;
244
+ /** The profiles this client implements. */
245
+ readonly handlers: readonly DataProfileHandler<unknown>[];
246
+ }
247
+ export declare class DataUnitApplier {
248
+ #private;
249
+ constructor(options: DataUnitApplierOptions);
250
+ /**
251
+ * Receives one Data Unit of the Resource `view` describes. Never creates
252
+ * a Data Unit: received content is applied, not re-sent as local work.
253
+ */
254
+ receive(view: ControlView, bytes: Uint8Array): Promise<ApplyOutcome>;
255
+ /**
256
+ * Receives the units of one DATA_BATCH (or any run of units) of the
257
+ * Resource `view` describes: each passes the LFCP checks of receive in
258
+ * order, unchanged, and the accepted ones reach the profile together
259
+ * through the handler's applyBatch, when it has one. Outcomes come in the
260
+ * order of `units`. An applied unit's objects and diagnostics are those
261
+ * of the whole batch, reported on the last unit merged; the units
262
+ * buffered before that the batch unblocked count as merged by the first.
263
+ * Before an equivocation is handled, the units accepted so far are
264
+ * applied, so its exclusion sees them.
265
+ */
266
+ receiveBatch(view: ControlView, units: readonly Uint8Array[]): Promise<ApplyOutcome[]>;
267
+ /**
268
+ * After a restart: the stored, LFCP-accepted units (merged or buffered by
269
+ * the profile) whose content the restored profile state does not hold
270
+ * (merged after its last checkpoint), decrypted again from their exact
271
+ * stored bytes and applied, in (actor, seq) order. Units covered by a
272
+ * Snapshot are not replayed (their content came with it). Needs the
273
+ * handler's has(); returns what was replayed and what could not be (no
274
+ * DEK, refused). LFCP checks are not repeated: the units passed them when
275
+ * they were accepted.
276
+ */
277
+ replayStored(view: ControlView): Promise<{
278
+ readonly replayed: readonly DataUnitId[];
279
+ readonly skipped: readonly {
280
+ readonly unitId: DataUnitId;
281
+ readonly reason: string;
282
+ }[];
283
+ /** Units quarantined at this start: they crashed the engine twice by themselves. */
284
+ readonly crashed: readonly DataUnitId[];
285
+ }>;
286
+ /**
287
+ * A unit inside the frontier of a Snapshot this client loaded (§29, §66
288
+ * step 3): its content is in the Snapshot, so it is not decrypted or
289
+ * merged again. It gets the DEK-free LFCP checks (structure, signature,
290
+ * equivocation, data/write at its head, epoch cutoff) and is then marked
291
+ * accepted, so the actor's next unit links to it (§26.2). Its own link to
292
+ * the previous unit is not checked: that unit is attested by the signed,
293
+ * authorized Snapshot and was never received. A replay is a duplicate.
294
+ */
295
+ acceptCovered(view: ControlView, bytes: Uint8Array): Promise<ApplyOutcome>;
296
+ reconcileEpochs(view: ControlView): Promise<EpochReconciliation>;
297
+ }
298
+ export {};
299
+ //# sourceMappingURL=apply.d.ts.map