@amalgm/live 0.2.26 → 0.2.28
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/PURPOSE.md +52 -29
- package/README.md +1 -2
- package/dist/contracts/index.d.ts +0 -1
- package/dist/contracts/index.d.ts.map +1 -1
- package/dist/contracts/index.js +0 -1
- package/dist/contracts/index.js.map +1 -1
- package/dist/detection/record-proposal.d.ts +3 -2
- package/dist/detection/record-proposal.d.ts.map +1 -1
- package/dist/detection/record-proposal.js +9 -7
- package/dist/detection/record-proposal.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/machines/index.d.ts +0 -2
- package/dist/machines/index.d.ts.map +1 -1
- package/dist/machines/index.js +0 -2
- package/dist/machines/index.js.map +1 -1
- package/dist/records/authority.d.ts +23 -0
- package/dist/records/authority.d.ts.map +1 -0
- package/dist/records/authority.js +28 -0
- package/dist/records/authority.js.map +1 -0
- package/dist/records/codec.d.ts +6 -0
- package/dist/records/codec.d.ts.map +1 -0
- package/dist/records/codec.js +42 -0
- package/dist/records/codec.js.map +1 -0
- package/dist/records/contracts.d.ts +46 -0
- package/dist/records/contracts.d.ts.map +1 -0
- package/dist/records/contracts.js +114 -0
- package/dist/records/contracts.js.map +1 -0
- package/dist/records/inbox.d.ts +18 -0
- package/dist/records/inbox.d.ts.map +1 -0
- package/dist/records/inbox.js +34 -0
- package/dist/records/inbox.js.map +1 -0
- package/dist/records/index.d.ts +7 -0
- package/dist/records/index.d.ts.map +1 -0
- package/dist/records/index.js +7 -0
- package/dist/records/index.js.map +1 -0
- package/dist/records/outbox.d.ts +20 -0
- package/dist/records/outbox.d.ts.map +1 -0
- package/dist/records/outbox.js +44 -0
- package/dist/records/outbox.js.map +1 -0
- package/dist/registration/user-ground.d.ts +5 -2
- package/dist/registration/user-ground.d.ts.map +1 -1
- package/dist/registration/user-ground.js +14 -3
- package/dist/registration/user-ground.js.map +1 -1
- package/dist/watching/suspicion.d.ts.map +1 -1
- package/dist/watching/suspicion.js +29 -1
- package/dist/watching/suspicion.js.map +1 -1
- package/dist-cjs/contracts/binding.js +26 -0
- package/dist-cjs/contracts/binding.js.map +1 -0
- package/dist-cjs/contracts/content.js +99 -0
- package/dist-cjs/contracts/content.js.map +1 -0
- package/dist-cjs/contracts/docs.js +56 -0
- package/dist-cjs/contracts/docs.js.map +1 -0
- package/dist-cjs/contracts/events.js +44 -0
- package/dist-cjs/contracts/events.js.map +1 -0
- package/dist-cjs/contracts/frames/gateway.js +39 -0
- package/dist-cjs/contracts/frames/gateway.js.map +1 -0
- package/dist-cjs/contracts/frames/stream.js +20 -0
- package/dist-cjs/contracts/frames/stream.js.map +1 -0
- package/dist-cjs/contracts/frames/tunnel.js +60 -0
- package/dist-cjs/contracts/frames/tunnel.js.map +1 -0
- package/dist-cjs/contracts/index.js +34 -0
- package/dist-cjs/contracts/index.js.map +1 -0
- package/dist-cjs/contracts/presence.js +38 -0
- package/dist-cjs/contracts/presence.js.map +1 -0
- package/dist-cjs/contracts/resources.js +114 -0
- package/dist-cjs/contracts/resources.js.map +1 -0
- package/dist-cjs/contracts/snapshot.js +31 -0
- package/dist-cjs/contracts/snapshot.js.map +1 -0
- package/dist-cjs/contracts/validate.js +34 -0
- package/dist-cjs/contracts/validate.js.map +1 -0
- package/dist-cjs/detection/adapter-contract.js +168 -0
- package/dist-cjs/detection/adapter-contract.js.map +1 -0
- package/dist-cjs/detection/batch.js +71 -0
- package/dist-cjs/detection/batch.js.map +1 -0
- package/dist-cjs/detection/classify.js +48 -0
- package/dist-cjs/detection/classify.js.map +1 -0
- package/dist-cjs/detection/content.js +122 -0
- package/dist-cjs/detection/content.js.map +1 -0
- package/dist-cjs/detection/continuity.js +88 -0
- package/dist-cjs/detection/continuity.js.map +1 -0
- package/dist-cjs/detection/diff.js +193 -0
- package/dist-cjs/detection/diff.js.map +1 -0
- package/dist-cjs/detection/echo.js +25 -0
- package/dist-cjs/detection/echo.js.map +1 -0
- package/dist-cjs/detection/enrollment.js +189 -0
- package/dist-cjs/detection/enrollment.js.map +1 -0
- package/dist-cjs/detection/index.js +57 -0
- package/dist-cjs/detection/index.js.map +1 -0
- package/dist-cjs/detection/record-proposal.js +170 -0
- package/dist-cjs/detection/record-proposal.js.map +1 -0
- package/dist-cjs/detection/refusal.js +44 -0
- package/dist-cjs/detection/refusal.js.map +1 -0
- package/dist-cjs/detection/repository.js +67 -0
- package/dist-cjs/detection/repository.js.map +1 -0
- package/dist-cjs/detection/territory.js +82 -0
- package/dist-cjs/detection/territory.js.map +1 -0
- package/dist-cjs/detection/watch-boundary.js +51 -0
- package/dist-cjs/detection/watch-boundary.js.map +1 -0
- package/dist-cjs/entities/bytes.js +92 -0
- package/dist-cjs/entities/bytes.js.map +1 -0
- package/dist-cjs/entities/cloud.js +171 -0
- package/dist-cjs/entities/cloud.js.map +1 -0
- package/dist-cjs/entities/index.js +39 -0
- package/dist-cjs/entities/index.js.map +1 -0
- package/dist-cjs/entities/moves.js +85 -0
- package/dist-cjs/entities/moves.js.map +1 -0
- package/dist-cjs/entities/repo-states.js +256 -0
- package/dist-cjs/entities/repo-states.js.map +1 -0
- package/dist-cjs/entities/rules.js +216 -0
- package/dist-cjs/entities/rules.js.map +1 -0
- package/dist-cjs/entities/types.js +44 -0
- package/dist-cjs/entities/types.js.map +1 -0
- package/dist-cjs/files/commands.js +120 -0
- package/dist-cjs/files/commands.js.map +1 -0
- package/dist-cjs/files/index.js +19 -0
- package/dist-cjs/files/index.js.map +1 -0
- package/dist-cjs/index.js +39 -0
- package/dist-cjs/index.js.map +1 -0
- package/dist-cjs/machines/arbitration.js +41 -0
- package/dist-cjs/machines/arbitration.js.map +1 -0
- package/dist-cjs/machines/backoff.js +38 -0
- package/dist-cjs/machines/backoff.js.map +1 -0
- package/dist-cjs/machines/bootstrap.js +110 -0
- package/dist-cjs/machines/bootstrap.js.map +1 -0
- package/dist-cjs/machines/chunks.js +72 -0
- package/dist-cjs/machines/chunks.js.map +1 -0
- package/dist-cjs/machines/index.js +28 -0
- package/dist-cjs/machines/index.js.map +1 -0
- package/dist-cjs/machines/presence.js +53 -0
- package/dist-cjs/machines/presence.js.map +1 -0
- package/dist-cjs/merge/index.js +25 -0
- package/dist-cjs/merge/index.js.map +1 -0
- package/dist-cjs/merge/merge3.js +191 -0
- package/dist-cjs/merge/merge3.js.map +1 -0
- package/dist-cjs/package.json +1 -0
- package/dist-cjs/records/authority.js +31 -0
- package/dist-cjs/records/authority.js.map +1 -0
- package/dist-cjs/records/codec.js +48 -0
- package/dist-cjs/records/codec.js.map +1 -0
- package/dist-cjs/records/contracts.js +121 -0
- package/dist-cjs/records/contracts.js.map +1 -0
- package/dist-cjs/records/inbox.js +37 -0
- package/dist-cjs/records/inbox.js.map +1 -0
- package/dist-cjs/records/index.js +23 -0
- package/dist-cjs/records/index.js.map +1 -0
- package/dist-cjs/records/outbox.js +48 -0
- package/dist-cjs/records/outbox.js.map +1 -0
- package/dist-cjs/registration/index.js +19 -0
- package/dist-cjs/registration/index.js.map +1 -0
- package/dist-cjs/registration/user-ground.js +183 -0
- package/dist-cjs/registration/user-ground.js.map +1 -0
- package/dist-cjs/transfer/artifacts.js +75 -0
- package/dist-cjs/transfer/artifacts.js.map +1 -0
- package/dist-cjs/transfer/batches.js +44 -0
- package/dist-cjs/transfer/batches.js.map +1 -0
- package/dist-cjs/transfer/download.js +88 -0
- package/dist-cjs/transfer/download.js.map +1 -0
- package/dist-cjs/transfer/index.js +21 -0
- package/dist-cjs/transfer/index.js.map +1 -0
- package/dist-cjs/transfer/parallel.js +35 -0
- package/dist-cjs/transfer/parallel.js.map +1 -0
- package/dist-cjs/transfer/upload.js +161 -0
- package/dist-cjs/transfer/upload.js.map +1 -0
- package/dist-cjs/watching/coverage.js +54 -0
- package/dist-cjs/watching/coverage.js.map +1 -0
- package/dist-cjs/watching/index.js +24 -0
- package/dist-cjs/watching/index.js.map +1 -0
- package/dist-cjs/watching/suspicion.js +105 -0
- package/dist-cjs/watching/suspicion.js.map +1 -0
- package/dist-cjs/workspace/api.js +66 -0
- package/dist-cjs/workspace/api.js.map +1 -0
- package/dist-cjs/workspace/identity.js +32 -0
- package/dist-cjs/workspace/identity.js.map +1 -0
- package/dist-cjs/workspace/index.js +14 -0
- package/dist-cjs/workspace/index.js.map +1 -0
- package/dist-cjs/workspace/memory-store.js +21 -0
- package/dist-cjs/workspace/memory-store.js.map +1 -0
- package/dist-cjs/workspace/registry.js +98 -0
- package/dist-cjs/workspace/registry.js.map +1 -0
- package/dist-cjs/workspace/types.js +3 -0
- package/dist-cjs/workspace/types.js.map +1 -0
- package/package.json +30 -8
- package/dist/contracts/mutation.d.ts +0 -51
- package/dist/contracts/mutation.d.ts.map +0 -1
- package/dist/contracts/mutation.js +0 -55
- package/dist/contracts/mutation.js.map +0 -1
- package/dist/machines/journal.d.ts +0 -63
- package/dist/machines/journal.d.ts.map +0 -1
- package/dist/machines/journal.js +0 -71
- package/dist/machines/journal.js.map +0 -1
- package/dist/machines/ordering.d.ts +0 -53
- package/dist/machines/ordering.d.ts.map +0 -1
- package/dist/machines/ordering.js +0 -87
- package/dist/machines/ordering.js.map +0 -1
package/PURPOSE.md
CHANGED
|
@@ -11,8 +11,8 @@ database, or a user-interface dependency.
|
|
|
11
11
|
|
|
12
12
|
The public developer model is `live.bind(surface, channel)` and is specified
|
|
13
13
|
in `docs/realtime-sdk.md`. The shipped wire behavior this package encodes is
|
|
14
|
-
`docs/local-live-protocol.md`. The
|
|
15
|
-
`docs/
|
|
14
|
+
`docs/local-live-protocol.md`. The entity Record/Send/Receive discipline is
|
|
15
|
+
`docs/entity-record-queues.md`. This repository is where those documents
|
|
16
16
|
become executable and testable; the engine repo keeps read-only copies until
|
|
17
17
|
its cutover.
|
|
18
18
|
|
|
@@ -32,23 +32,24 @@ its cutover.
|
|
|
32
32
|
gateway must share the same versioned schemas and integrity checks. A
|
|
33
33
|
second copy of a protocol or manifest validator is a bug, not a
|
|
34
34
|
compatibility layer.
|
|
35
|
-
4. **
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
5. **One
|
|
39
|
-
|
|
40
|
-
`(
|
|
41
|
-
|
|
42
|
-
6. **
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
4. **A protocol cutover has one path.** A replacement contract is versioned
|
|
36
|
+
explicitly, adopted by every participant, and removes the superseded path.
|
|
37
|
+
The entity record rail has no legacy fallback or compatibility branch.
|
|
38
|
+
5. **One change, one record identity.** Record assigns one mutation id to one
|
|
39
|
+
settled logical transition. The id survives every retry and the authority
|
|
40
|
+
deduplicates it by `(entityId, mutationId)`. Transport packing never merges
|
|
41
|
+
identities; `authorityId` is permission and cargo scope, not channel identity.
|
|
42
|
+
6. **Record owns the local outbox.** Detect's exact proposal and the verified
|
|
43
|
+
notebook state commit together in one local transaction. That record row is
|
|
44
|
+
the outbox; it contains only work created on this computer, is never
|
|
45
|
+
deleted on acknowledgement, and no received record may enter it.
|
|
46
46
|
7. **Lifecycle state is honest.** A socket being open is never `live`.
|
|
47
47
|
`live` means snapshot applied and ordered delivery confirmed; degraded and
|
|
48
48
|
reconnecting states are reported as themselves.
|
|
49
|
-
8. **
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
8. **The filesystem rail is last-write-wins.** Every authorized, complete
|
|
50
|
+
record is accepted without a stale-base comparison. The highest official
|
|
51
|
+
sequence on that entity UUID is current; earlier complete results remain
|
|
52
|
+
immutable history rather than a conflict state.
|
|
52
53
|
9. **Cutover is exclusive per released surface.** When the signed Shell release
|
|
53
54
|
adopts a Live module, this published package is the sole production source
|
|
54
55
|
for that module; no Engine copy or fallback runs beside it. Unreleased
|
|
@@ -71,9 +72,11 @@ its cutover.
|
|
|
71
72
|
14. **Login convergence has one authority.** A first machine conditionally
|
|
72
73
|
publishes the declared home; every later machine materializes that exact
|
|
73
74
|
cloud graph, and a simultaneous first-login loser adopts the winning graph.
|
|
74
|
-
15. **Cloud precedes Watch.** Login becomes ready only after the
|
|
75
|
-
|
|
76
|
-
coverage is established over the resulting user ground.
|
|
75
|
+
15. **Cloud precedes Watch.** Login becomes ready only after the accepted
|
|
76
|
+
portable core baseline agrees with the active cloud snapshot and watcher
|
|
77
|
+
coverage is established over the resulting user ground. Journaled local
|
|
78
|
+
work newer than that baseline survives restart and reports `syncing`; it
|
|
79
|
+
is never overwritten merely to make login look current.
|
|
77
80
|
16. **Files owns Files decisions.** `files register` identity declaration and
|
|
78
81
|
`files add` graph selection are Live operations behind injected effect
|
|
79
82
|
ports. A product shell routes them through its persistent Files host and
|
|
@@ -159,9 +162,10 @@ its cutover.
|
|
|
159
162
|
uses Git object negotiation.
|
|
160
163
|
28. **A doorbell names suspicion, never truth.** Watch preserves every named
|
|
161
164
|
path until one settled observation proves it; paths rung during that
|
|
162
|
-
observation remain suspect. A
|
|
163
|
-
|
|
164
|
-
|
|
165
|
+
observation remain suspect. A named burst widens first to its deepest
|
|
166
|
+
common directory; only a nameless event, a burst with no common directory,
|
|
167
|
+
watcher death, startup, or explicit catch-up suspects the complete covered
|
|
168
|
+
root. Scope may reduce what is read, never change the state that is derived.
|
|
165
169
|
29. **Repository registration trusts Git where Git has truth.** A clean
|
|
166
170
|
tracked worktree child reuses Git's index object identity and Git's own
|
|
167
171
|
attribute/blob classification without reopening or hashing its complete
|
|
@@ -193,6 +197,26 @@ its cutover.
|
|
|
193
197
|
identity and durable order before that Watch generation settles. Applied
|
|
194
198
|
incoming work is silenced only by verified notebook equality, never by
|
|
195
199
|
hiding watcher rings; filesystem absence alone has no lifecycle authority.
|
|
200
|
+
34. **Named Detect costs what changed, not what exists.** A valid named
|
|
201
|
+
suspicion loads indexed notebook rows for that path, its required parents,
|
|
202
|
+
and its nearest repository territory; it never walks or serializes the
|
|
203
|
+
complete workspace. A new directory costs its new subtree. A repository
|
|
204
|
+
costs its Card + Checkpoint scope. Only honestly ambiguous evidence enters
|
|
205
|
+
complete reconciliation. Detect ends after the exact proposal and local
|
|
206
|
+
truth are committed together; cloud publication belongs to Send.
|
|
207
|
+
35. **The entity UUID is the ordered channel.** Cloud assigns a dense sequence
|
|
208
|
+
independently to each entity UUID across all machines. Unrelated entities
|
|
209
|
+
have no semantic order and may be sent concurrently; workspace or delivery
|
|
210
|
+
cursors may discover records but never decide which entity state wins.
|
|
211
|
+
36. **Receive owns the local inbox.** Every cloud-accepted record, including
|
|
212
|
+
one originating on this computer, enters the inbox under
|
|
213
|
+
`(entityId, globalSequence)`. Each entity has its own received-through
|
|
214
|
+
cursor, and Receive advances it without gaps. Locally unaccepted work can
|
|
215
|
+
never enter the inbox.
|
|
216
|
+
37. **Lineage is evidence, not admission control.** Every local record names
|
|
217
|
+
`basedOnState`, `resultState`, and the last official sequence for that
|
|
218
|
+
entity known at Record time. The authority preserves those facts and never
|
|
219
|
+
uses them to reject or reorder an otherwise valid write.
|
|
196
220
|
|
|
197
221
|
## Five surfaces, one behavior
|
|
198
222
|
|
|
@@ -211,11 +235,12 @@ behavior instead of delegating to the SDK is a bug (axiom 3).
|
|
|
211
235
|
|
|
212
236
|
```
|
|
213
237
|
src/contracts/ value types + validators: events, snapshots, resource ids,
|
|
214
|
-
|
|
238
|
+
content manifests, frames (SSE /
|
|
215
239
|
gateway socket / tunnel), doc-write merge outcomes,
|
|
216
240
|
presence.
|
|
217
|
-
src/
|
|
218
|
-
|
|
241
|
+
src/records/ entity record contracts and the pure local-outbox,
|
|
242
|
+
authority-acceptance, and per-entity inbox laws.
|
|
243
|
+
src/machines/ transport-neutral state machines: bootstrap barrier, presence
|
|
219
244
|
TTL, slot arbitration, chunk reassembly, backoff.
|
|
220
245
|
src/entities/ the entity model's rule surface: the six-field record,
|
|
221
246
|
derived versions, lifecycle laws, move planning, the
|
|
@@ -229,15 +254,13 @@ src/registration/ the login-time user-ground convergence operation and its
|
|
|
229
254
|
injected local/cloud effect ports.
|
|
230
255
|
src/transfer/ type-aware immutable artifact upload/download operations;
|
|
231
256
|
chunk storage, R2, files, and Git remain injected effects.
|
|
232
|
-
src/adapters/ the ports a host injects: transport, journal store,
|
|
233
|
-
content store, clock, crypto, logger.
|
|
234
257
|
tests/ unit tests per module, in the engine wall's style: each
|
|
235
258
|
exam states a law; mutants convict.
|
|
236
259
|
tests/parity/ golden-vector harness: the same inputs run against this
|
|
237
260
|
package and the shipped runtime implementation must produce
|
|
238
261
|
identical outputs.
|
|
239
|
-
tests/
|
|
240
|
-
written against the public SDK API only.
|
|
262
|
+
tests/records/ contract and invariant tests for the complete entity-record
|
|
263
|
+
journey, written against the public SDK API only.
|
|
241
264
|
```
|
|
242
265
|
|
|
243
266
|
## Status
|
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ normative specifications live in [docs/](docs/):
|
|
|
19
19
|
| --- | --- |
|
|
20
20
|
| [realtime-sdk.md](docs/realtime-sdk.md) | the public `bind(surface, channel)` model |
|
|
21
21
|
| [local-live-protocol.md](docs/local-live-protocol.md) | the shipped local wire protocol (v1/v2) |
|
|
22
|
-
| [
|
|
22
|
+
| [entity-record-queues.md](docs/entity-record-queues.md) | filesystem Record, local Outbox, per-UUID cloud order, and local Inbox |
|
|
23
23
|
| [shared-realtime-wave-3.md](docs/shared-realtime-wave-3.md) | the multi-user cloud-authority design |
|
|
24
24
|
| [extraction-boundary.md](docs/extraction-boundary.md) | what moves here from the engine runtime, and in what order |
|
|
25
25
|
| [user-ground-login.md](docs/user-ground-login.md) | first-login publication, later-device materialization, and Watch readiness |
|
|
@@ -43,5 +43,4 @@ Every surface delegates to `src/`. One behavior, five doors.
|
|
|
43
43
|
npm install
|
|
44
44
|
npm test # build + unit tests
|
|
45
45
|
npm run test:parity # golden vectors vs the shipped engine runtime
|
|
46
|
-
npm run test:conformance
|
|
47
46
|
```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contracts/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contracts/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC"}
|
package/dist/contracts/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/contracts/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/contracts/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC"}
|
|
@@ -51,8 +51,9 @@ export type ReplayInstruction = StructureReplay | TextReplay | BinaryReplay | Li
|
|
|
51
51
|
export interface DetectedChangeProposal {
|
|
52
52
|
readonly contract: typeof DETECTED_CHANGE_CONTRACT;
|
|
53
53
|
/** The permanent UUID whose ordered rail carries this proposal. */
|
|
54
|
-
readonly
|
|
55
|
-
|
|
54
|
+
readonly entityId: string;
|
|
55
|
+
/** Exact logical state Detect read. Lineage only; never an acceptance gate. */
|
|
56
|
+
readonly basedOnState: string | null;
|
|
56
57
|
/** Complete exact result, not a partial update. */
|
|
57
58
|
readonly result: CloudEntityRecord;
|
|
58
59
|
readonly facets: readonly ChangeFacet[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record-proposal.d.ts","sourceRoot":"","sources":["../../src/detection/record-proposal.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAwB,KAAK,eAAe,EAAE,MAAM,yBAAyB,CAAC;AACrF,OAAO,EAAqB,KAAK,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAEpF,eAAO,MAAM,wBAAwB,sCAAsC,CAAC;AAE5E,MAAM,MAAM,WAAW,GACnB,QAAQ,GACR,QAAQ,GACR,MAAM,GACN,QAAQ,GACR,SAAS,GACT,OAAO,GACP,SAAS,CAAC;AAEd,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;CAC5B;AAED,8EAA8E;AAC9E,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;CAC7B;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,UAAU,CAAC;IACpC,QAAQ,CAAC,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3C,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACtC,Q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
|
25
25
|
const resultCarriesPayload = !DERIVED_PAYLOAD.has(result.type) && result.type !== 'reference';
|
|
26
|
-
if ((base.payloadVersion !== result.payloadVersion
|
|
27
|
-
&& (base.type === result.type || resultCarriesPayload))
|
|
26
|
+
if ((base.payloadVersion !== result.payloadVersion && resultCarriesPayload)
|
|
28
27
|
|| (result.type === 'repo.git' && base.transportVersion !== result.transportVersion)) {
|
|
29
28
|
facets.push('content');
|
|
30
29
|
}
|
|
@@ -34,9 +33,6 @@ const facetsOf = (base, result) => {
|
|
|
34
33
|
else if (base.status === 'trashed' && result.status === 'active')
|
|
35
34
|
facets.push('restore');
|
|
36
35
|
}
|
|
37
|
-
if (DERIVED_PAYLOAD.has(result.type) && facets.length === 0 && base.version !== result.version) {
|
|
38
|
-
facets.push('content');
|
|
39
|
-
}
|
|
40
36
|
return facets;
|
|
41
37
|
};
|
|
42
38
|
const contentRequired = (base, result, facets) => result.status === 'active'
|
|
@@ -138,6 +134,12 @@ export function detectedChangeProposal(input) {
|
|
|
138
134
|
}
|
|
139
135
|
const facets = facetsOf(base, result);
|
|
140
136
|
if (facets.length === 0) {
|
|
137
|
+
if (base !== null && DERIVED_PAYLOAD.has(base.type) && base.type === result.type) {
|
|
138
|
+
// Container membership is a projection of child parentUUID values. Its
|
|
139
|
+
// derived version can move locally, but it is never an independent write
|
|
140
|
+
// that could erase a sibling created by another machine.
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
141
143
|
throw new Error('detected records disagree without a named logical facet');
|
|
142
144
|
}
|
|
143
145
|
if (facets.includes('trash') && input.lifecycleAuthorization !== 'trash') {
|
|
@@ -153,8 +155,8 @@ export function detectedChangeProposal(input) {
|
|
|
153
155
|
}
|
|
154
156
|
return Object.freeze({
|
|
155
157
|
contract: DETECTED_CHANGE_CONTRACT,
|
|
156
|
-
|
|
157
|
-
|
|
158
|
+
entityId: result.uuid,
|
|
159
|
+
basedOnState: base?.version ?? null,
|
|
158
160
|
result,
|
|
159
161
|
facets: Object.freeze(facets),
|
|
160
162
|
replay: input.replay,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record-proposal.js","sourceRoot":"","sources":["../../src/detection/record-proposal.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,YAAY,GAEb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAwB,MAAM,yBAAyB,CAAC;AACrF,OAAO,EAAE,iBAAiB,EAAyB,MAAM,0BAA0B,CAAC;AAEpF,MAAM,CAAC,MAAM,wBAAwB,GAAG,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"record-proposal.js","sourceRoot":"","sources":["../../src/detection/record-proposal.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,YAAY,GAEb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAwB,MAAM,yBAAyB,CAAC;AACrF,OAAO,EAAE,iBAAiB,EAAyB,MAAM,0BAA0B,CAAC;AAEpF,MAAM,CAAC,MAAM,wBAAwB,GAAG,mCAAmC,CAAC;AAkF5E,MAAM,IAAI,GAAG,gBAAgB,CAAC;AAE9B,MAAM,QAAQ,GAAG,CACf,IAA8B,EAC9B,MAAyB,EACV,EAAE;IACjB,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IACrC,MAAM,MAAM,GAAkB,EAAE,CAAC;IACjC,IAAI,IAAI,CAAC,UAAU,KAAK,MAAM,CAAC,UAAU;QAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC/D,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI;QAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACrD,IAAI,IAAI,CAAC,IAAI,KA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AC,QAAQ,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,sBAAsB,KAAK,SAAS,EAAE,CAAC;QAC7E,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;IAC/E,CAAC;IACD,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAEnD,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACtF,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,WAAW,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QAC3D,MAAM,IAAI,KAAK,CAAC,YAAY,MAAM,CAAC,IAAI,sCAAsC,CAAC,CAAC;IACjF,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,QAAQ,EAAE,wBAAwB;QAClC,QAAQ,EAAE,MAAM,CAAC,IAAI;QACrB,YAAY,EAAE,IAAI,EAAE,OAAO,IAAI,IAAI;QACnC,MAAM;QACN,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;QAC7B,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;KAC1D,CAAC,CAAC;AACL,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @amalgm/live — the portable realtime SDK for the Amalgm platform.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Portable layers, one rule each:
|
|
5
5
|
*
|
|
6
6
|
* - `contracts/` every wire shape and identity rule, as types + validators
|
|
7
7
|
* - `machines/` the protocol's behavior, as pure state machines
|
|
8
|
-
* - `
|
|
8
|
+
* - `records/` the entity Record, local Outbox, authority, and Inbox laws
|
|
9
9
|
*
|
|
10
10
|
* Start at PURPOSE.md for the axioms; docs/ holds the normative specs.
|
|
11
11
|
*/
|
|
@@ -14,6 +14,7 @@ export * from './machines/index.js';
|
|
|
14
14
|
export * from './entities/index.js';
|
|
15
15
|
export * from './watching/index.js';
|
|
16
16
|
export * from './detection/index.js';
|
|
17
|
+
export * from './records/index.js';
|
|
17
18
|
export * from './registration/index.js';
|
|
18
19
|
export * from './files/index.js';
|
|
19
20
|
export * from './transfer/index.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @amalgm/live — the portable realtime SDK for the Amalgm platform.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Portable layers, one rule each:
|
|
5
5
|
*
|
|
6
6
|
* - `contracts/` every wire shape and identity rule, as types + validators
|
|
7
7
|
* - `machines/` the protocol's behavior, as pure state machines
|
|
8
|
-
* - `
|
|
8
|
+
* - `records/` the entity Record, local Outbox, authority, and Inbox laws
|
|
9
9
|
*
|
|
10
10
|
* Start at PURPOSE.md for the axioms; docs/ holds the normative specs.
|
|
11
11
|
*/
|
|
@@ -14,6 +14,7 @@ export * from './machines/index.js';
|
|
|
14
14
|
export * from './entities/index.js';
|
|
15
15
|
export * from './watching/index.js';
|
|
16
16
|
export * from './detection/index.js';
|
|
17
|
+
export * from './records/index.js';
|
|
17
18
|
export * from './registration/index.js';
|
|
18
19
|
export * from './files/index.js';
|
|
19
20
|
export * from './transfer/index.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC"}
|
package/dist/machines/index.d.ts
CHANGED
|
@@ -4,9 +4,7 @@
|
|
|
4
4
|
* data — the host performs the fetches, timers, and writes. Nothing in
|
|
5
5
|
* here opens a socket, reads a clock, or touches a disk.
|
|
6
6
|
*/
|
|
7
|
-
export * from './ordering.js';
|
|
8
7
|
export * from './bootstrap.js';
|
|
9
|
-
export * from './journal.js';
|
|
10
8
|
export * from './presence.js';
|
|
11
9
|
export * from './arbitration.js';
|
|
12
10
|
export * from './chunks.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/machines/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/machines/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC"}
|
package/dist/machines/index.js
CHANGED
|
@@ -4,9 +4,7 @@
|
|
|
4
4
|
* data — the host performs the fetches, timers, and writes. Nothing in
|
|
5
5
|
* here opens a socket, reads a clock, or touches a disk.
|
|
6
6
|
*/
|
|
7
|
-
export * from './ordering.js';
|
|
8
7
|
export * from './bootstrap.js';
|
|
9
|
-
export * from './journal.js';
|
|
10
8
|
export * from './presence.js';
|
|
11
9
|
export * from './arbitration.js';
|
|
12
10
|
export * from './chunks.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/machines/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/machines/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Pure acceptance decision used by a transactional cloud adapter. */
|
|
2
|
+
import type { AcceptedEntityRecord, LocalEntityRecord } from './contracts.js';
|
|
3
|
+
export type AuthorityAcceptance = {
|
|
4
|
+
readonly kind: 'duplicate';
|
|
5
|
+
readonly record: AcceptedEntityRecord;
|
|
6
|
+
} | {
|
|
7
|
+
readonly kind: 'append';
|
|
8
|
+
readonly record: AcceptedEntityRecord;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Permission and cargo existence are effects proved by the cloud adapter
|
|
12
|
+
* before calling this decision. `headSequence` is locked for this entity UUID
|
|
13
|
+
* only. `existing` is the row found by the entity mutation identity.
|
|
14
|
+
*/
|
|
15
|
+
export declare function acceptEntityRecord(input: {
|
|
16
|
+
readonly submitted: LocalEntityRecord;
|
|
17
|
+
readonly existing: AcceptedEntityRecord | null;
|
|
18
|
+
readonly headSequence: number;
|
|
19
|
+
readonly actorId: string;
|
|
20
|
+
readonly originDeviceId: string;
|
|
21
|
+
readonly acceptedAt: number;
|
|
22
|
+
}): AuthorityAcceptance;
|
|
23
|
+
//# sourceMappingURL=authority.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authority.d.ts","sourceRoot":"","sources":["../../src/records/authority.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAGtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAE9E,MAAM,MAAM,mBAAmB,GAC3B;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAA;CAAE,GACrE;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAA;CAAE,CAAC;AAEvE;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE;IACxC,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC;IACtC,QAAQ,CAAC,QAAQ,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAC/C,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B,GAAG,mBAAmB,CAyBtB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** Pure acceptance decision used by a transactional cloud adapter. */
|
|
2
|
+
import { encodeEntityRecord } from './codec.js';
|
|
3
|
+
/**
|
|
4
|
+
* Permission and cargo existence are effects proved by the cloud adapter
|
|
5
|
+
* before calling this decision. `headSequence` is locked for this entity UUID
|
|
6
|
+
* only. `existing` is the row found by the entity mutation identity.
|
|
7
|
+
*/
|
|
8
|
+
export function acceptEntityRecord(input) {
|
|
9
|
+
if (input.existing !== null) {
|
|
10
|
+
const { globalSequence: _globalSequence, actorId: _actorId, originDeviceId: _originDeviceId, acceptedAt: _acceptedAt, ...existingLocal } = input.existing;
|
|
11
|
+
if (encodeEntityRecord(existingLocal) !== encodeEntityRecord(input.submitted)) {
|
|
12
|
+
throw new Error('mutationId was already accepted with different record bytes');
|
|
13
|
+
}
|
|
14
|
+
return Object.freeze({ kind: 'duplicate', record: input.existing });
|
|
15
|
+
}
|
|
16
|
+
if (!Number.isSafeInteger(input.headSequence) || input.headSequence < 0) {
|
|
17
|
+
throw new Error('entity head sequence must be a non-negative safe integer');
|
|
18
|
+
}
|
|
19
|
+
const record = Object.freeze({
|
|
20
|
+
...input.submitted,
|
|
21
|
+
globalSequence: input.headSequence + 1,
|
|
22
|
+
actorId: input.actorId,
|
|
23
|
+
originDeviceId: input.originDeviceId,
|
|
24
|
+
acceptedAt: input.acceptedAt,
|
|
25
|
+
});
|
|
26
|
+
return Object.freeze({ kind: 'append', record });
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=authority.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authority.js","sourceRoot":"","sources":["../../src/records/authority.ts"],"names":[],"mappings":"AAAA,sEAAsE;AAEtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAOhD;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAOlC;IACC,IAAI,KAAK,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;QAC5B,MAAM,EACJ,cAAc,EAAE,eAAe,EAC/B,OAAO,EAAE,QAAQ,EACjB,cAAc,EAAE,eAAe,EAC/B,UAAU,EAAE,WAAW,EACvB,GAAG,aAAa,EACjB,GAAG,KAAK,CAAC,QAAQ,CAAC;QACnB,IAAI,kBAAkB,CAAC,aAAa,CAAC,KAAK,kBAAkB,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;YAC9E,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;QACjF,CAAC;QACD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;IACtE,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,KAAK,CAAC,YAAY,GAAG,CAAC,EAAE,CAAC;QACxE,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;IAC9E,CAAC;IACD,MAAM,MAAM,GAAyB,MAAM,CAAC,MAAM,CAAC;QACjD,GAAG,KAAK,CAAC,SAAS;QAClB,cAAc,EAAE,KAAK,CAAC,YAAY,GAAG,CAAC;QACtC,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,UAAU,EAAE,KAAK,CAAC,UAAU;KAC7B,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** JSON codec for records whose exact replay may contain Uint8Array spans. */
|
|
2
|
+
import { type AcceptedEntityRecord, type LocalEntityRecord } from './contracts.js';
|
|
3
|
+
export declare const encodeEntityRecord: (record: LocalEntityRecord | AcceptedEntityRecord) => string;
|
|
4
|
+
export declare function decodeLocalEntityRecord(encoded: string): LocalEntityRecord;
|
|
5
|
+
export declare function decodeAcceptedEntityRecord(encoded: string): AcceptedEntityRecord;
|
|
6
|
+
//# sourceMappingURL=codec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../src/records/codec.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAG9E,OAAO,EAGL,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACvB,MAAM,gBAAgB,CAAC;AAyBxB,eAAO,MAAM,kBAAkB,GAAI,QAAQ,iBAAiB,GAAG,oBAAoB,KAAG,MACjD,CAAC;AAEtC,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,iBAAiB,CAK1E;AAED,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,GAAG,oBAAoB,CAKhF"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/** JSON codec for records whose exact replay may contain Uint8Array spans. */
|
|
2
|
+
import { base64ToBytes, bytesToBase64 } from '../entities/bytes.js';
|
|
3
|
+
import { checkAcceptedEntityRecord, checkLocalEntityRecord, } from './contracts.js';
|
|
4
|
+
const BYTES = '$amalgmBytesBase64';
|
|
5
|
+
const encodeValue = (value) => {
|
|
6
|
+
if (value instanceof Uint8Array)
|
|
7
|
+
return { [BYTES]: bytesToBase64(value) };
|
|
8
|
+
if (Array.isArray(value))
|
|
9
|
+
return value.map(encodeValue);
|
|
10
|
+
if (value !== null && typeof value === 'object') {
|
|
11
|
+
return Object.fromEntries(Object.entries(value).map(([key, child]) => [key, encodeValue(child)]));
|
|
12
|
+
}
|
|
13
|
+
return value;
|
|
14
|
+
};
|
|
15
|
+
const decodeValue = (value) => {
|
|
16
|
+
if (Array.isArray(value))
|
|
17
|
+
return value.map(decodeValue);
|
|
18
|
+
if (value !== null && typeof value === 'object') {
|
|
19
|
+
const entries = Object.entries(value);
|
|
20
|
+
if (entries.length === 1 && entries[0][0] === BYTES && typeof entries[0][1] === 'string') {
|
|
21
|
+
return base64ToBytes(entries[0][1]);
|
|
22
|
+
}
|
|
23
|
+
return Object.fromEntries(entries.map(([key, child]) => [key, decodeValue(child)]));
|
|
24
|
+
}
|
|
25
|
+
return value;
|
|
26
|
+
};
|
|
27
|
+
export const encodeEntityRecord = (record) => JSON.stringify(encodeValue(record));
|
|
28
|
+
export function decodeLocalEntityRecord(encoded) {
|
|
29
|
+
const value = decodeValue(JSON.parse(encoded));
|
|
30
|
+
const checked = checkLocalEntityRecord(value);
|
|
31
|
+
if (!checked.ok)
|
|
32
|
+
throw new Error(checked.error);
|
|
33
|
+
return checked.value;
|
|
34
|
+
}
|
|
35
|
+
export function decodeAcceptedEntityRecord(encoded) {
|
|
36
|
+
const value = decodeValue(JSON.parse(encoded));
|
|
37
|
+
const checked = checkAcceptedEntityRecord(value);
|
|
38
|
+
if (!checked.ok)
|
|
39
|
+
throw new Error(checked.error);
|
|
40
|
+
return checked.value;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=codec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codec.js","sourceRoot":"","sources":["../../src/records/codec.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAE9E,OAAO,EAAE,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O,aAAa,CAAC,OAAO,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QACvC,CAAC;QACD,OAAO,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACtF,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,MAAgD,EAAU,EAAE,CAC7F,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;AAEtC,MAAM,UAAU,uBAAuB,CAAC,OAAe;IACrD,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAC/C,MAAM,OAAO,GAAG,sBAAsB,CAAC,KAAK,CAAC,CAAC;IAC9C,IAAI,CAAC,OAAO,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAChD,OAAO,OAAO,CAAC,KAAK,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,OAAe;IACxD,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAC/C,MAAM,OAAO,GAAG,yBAAyB,CAAC,KAAK,CAAC,CAAC;IACjD,IAAI,CAAC,OAAO,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAChD,OAAO,OAAO,CAAC,KAAK,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The exact entity record carried from local Record to cloud acceptance.
|
|
3
|
+
*
|
|
4
|
+
* The entity UUID is the channel. `globalSequence` exists only after the
|
|
5
|
+
* authority accepts the record and is dense independently on that UUID.
|
|
6
|
+
*/
|
|
7
|
+
import { type DetectedChangeProposal } from '../detection/record-proposal.js';
|
|
8
|
+
import { type Checked } from '../contracts/validate.js';
|
|
9
|
+
export declare const ENTITY_RECORD_CONTRACT = "amalgm.entity-record@1";
|
|
10
|
+
export interface LocalEntityRecord {
|
|
11
|
+
readonly contract: typeof ENTITY_RECORD_CONTRACT;
|
|
12
|
+
/** Stable for every retry of this one logical change. */
|
|
13
|
+
readonly mutationId: string;
|
|
14
|
+
/** Authentication/cargo namespace; never an ordering scope. */
|
|
15
|
+
readonly authorityId: string;
|
|
16
|
+
/** Permanent entity UUID and realtime channel id. */
|
|
17
|
+
readonly entityId: string;
|
|
18
|
+
/** Exact state Detect read. Historical lineage, never CAS. */
|
|
19
|
+
readonly basedOnState: string | null;
|
|
20
|
+
/** Complete state this record produces. */
|
|
21
|
+
readonly resultState: string;
|
|
22
|
+
/** Last official sequence for this entity known at Record time. */
|
|
23
|
+
readonly lastSeenGlobalSequence: number;
|
|
24
|
+
readonly change: DetectedChangeProposal;
|
|
25
|
+
readonly createdAt: number;
|
|
26
|
+
}
|
|
27
|
+
export interface AcceptedEntityRecord extends LocalEntityRecord {
|
|
28
|
+
/** Dense and monotonic only within `entityId`. */
|
|
29
|
+
readonly globalSequence: number;
|
|
30
|
+
/** Server-derived from the authenticated connection. */
|
|
31
|
+
readonly actorId: string;
|
|
32
|
+
/** Server-derived from the authenticated machine tunnel. */
|
|
33
|
+
readonly originDeviceId: string;
|
|
34
|
+
readonly acceptedAt: number;
|
|
35
|
+
}
|
|
36
|
+
export declare function checkLocalEntityRecord(value: unknown): Checked<LocalEntityRecord>;
|
|
37
|
+
export declare function checkAcceptedEntityRecord(value: unknown): Checked<AcceptedEntityRecord>;
|
|
38
|
+
export declare const entityMutationKey: (record: Pick<LocalEntityRecord, "entityId" | "mutationId">) => string;
|
|
39
|
+
export declare function createLocalEntityRecord(input: {
|
|
40
|
+
readonly mutationId: string;
|
|
41
|
+
readonly authorityId: string;
|
|
42
|
+
readonly lastSeenGlobalSequence: number;
|
|
43
|
+
readonly change: DetectedChangeProposal;
|
|
44
|
+
readonly createdAt: number;
|
|
45
|
+
}): LocalEntityRecord;
|
|
46
|
+
//# sourceMappingURL=contracts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../src/records/contracts.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,KAAK,OAAO,EAA+C,MAAM,0BAA0B,CAAC;AAErG,eAAO,MAAM,sBAAsB,2BAA2B,CAAC;AAE/D,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,QAAQ,EAAE,OAAO,sBAAsB,CAAC;IACjD,yDAAyD;IACzD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,+DAA+D;IAC/D,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,qDAAqD;IACrD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,8DAA8D;IAC9D,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,2CAA2C;IAC3C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,mEAAmE;IACnE,QAAQ,CAAC,sBAAsB,EAAE,MAAM,CAAC;IACxC,QAAQ,CAAC,MAAM,EAAE,sBAAsB,CAAC;IACxC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,oBAAqB,SAAQ,iBAAiB;IAC7D,kDAAkD;IAClD,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,wDAAwD;IACxD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,4DAA4D;IAC5D,QAAQ,CAAC,cAAc,EAAE,MAAM,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