@amalgm/live 0.2.27 → 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.
Files changed (194) hide show
  1. package/PURPOSE.md +38 -25
  2. package/README.md +1 -2
  3. package/dist/contracts/index.d.ts +0 -1
  4. package/dist/contracts/index.d.ts.map +1 -1
  5. package/dist/contracts/index.js +0 -1
  6. package/dist/contracts/index.js.map +1 -1
  7. package/dist/detection/record-proposal.d.ts +3 -2
  8. package/dist/detection/record-proposal.d.ts.map +1 -1
  9. package/dist/detection/record-proposal.js +9 -7
  10. package/dist/detection/record-proposal.js.map +1 -1
  11. package/dist/index.d.ts +3 -2
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +3 -2
  14. package/dist/index.js.map +1 -1
  15. package/dist/machines/index.d.ts +0 -2
  16. package/dist/machines/index.d.ts.map +1 -1
  17. package/dist/machines/index.js +0 -2
  18. package/dist/machines/index.js.map +1 -1
  19. package/dist/records/authority.d.ts +23 -0
  20. package/dist/records/authority.d.ts.map +1 -0
  21. package/dist/records/authority.js +28 -0
  22. package/dist/records/authority.js.map +1 -0
  23. package/dist/records/codec.d.ts +6 -0
  24. package/dist/records/codec.d.ts.map +1 -0
  25. package/dist/records/codec.js +42 -0
  26. package/dist/records/codec.js.map +1 -0
  27. package/dist/records/contracts.d.ts +46 -0
  28. package/dist/records/contracts.d.ts.map +1 -0
  29. package/dist/records/contracts.js +114 -0
  30. package/dist/records/contracts.js.map +1 -0
  31. package/dist/records/inbox.d.ts +18 -0
  32. package/dist/records/inbox.d.ts.map +1 -0
  33. package/dist/records/inbox.js +34 -0
  34. package/dist/records/inbox.js.map +1 -0
  35. package/dist/records/index.d.ts +7 -0
  36. package/dist/records/index.d.ts.map +1 -0
  37. package/dist/records/index.js +7 -0
  38. package/dist/records/index.js.map +1 -0
  39. package/dist/records/outbox.d.ts +20 -0
  40. package/dist/records/outbox.d.ts.map +1 -0
  41. package/dist/records/outbox.js +44 -0
  42. package/dist/records/outbox.js.map +1 -0
  43. package/dist/registration/user-ground.d.ts +4 -4
  44. package/dist/registration/user-ground.d.ts.map +1 -1
  45. package/dist/registration/user-ground.js +8 -3
  46. package/dist/registration/user-ground.js.map +1 -1
  47. package/dist-cjs/contracts/binding.js +26 -0
  48. package/dist-cjs/contracts/binding.js.map +1 -0
  49. package/dist-cjs/contracts/content.js +99 -0
  50. package/dist-cjs/contracts/content.js.map +1 -0
  51. package/dist-cjs/contracts/docs.js +56 -0
  52. package/dist-cjs/contracts/docs.js.map +1 -0
  53. package/dist-cjs/contracts/events.js +44 -0
  54. package/dist-cjs/contracts/events.js.map +1 -0
  55. package/dist-cjs/contracts/frames/gateway.js +39 -0
  56. package/dist-cjs/contracts/frames/gateway.js.map +1 -0
  57. package/dist-cjs/contracts/frames/stream.js +20 -0
  58. package/dist-cjs/contracts/frames/stream.js.map +1 -0
  59. package/dist-cjs/contracts/frames/tunnel.js +60 -0
  60. package/dist-cjs/contracts/frames/tunnel.js.map +1 -0
  61. package/dist-cjs/contracts/index.js +34 -0
  62. package/dist-cjs/contracts/index.js.map +1 -0
  63. package/dist-cjs/contracts/presence.js +38 -0
  64. package/dist-cjs/contracts/presence.js.map +1 -0
  65. package/dist-cjs/contracts/resources.js +114 -0
  66. package/dist-cjs/contracts/resources.js.map +1 -0
  67. package/dist-cjs/contracts/snapshot.js +31 -0
  68. package/dist-cjs/contracts/snapshot.js.map +1 -0
  69. package/dist-cjs/contracts/validate.js +34 -0
  70. package/dist-cjs/contracts/validate.js.map +1 -0
  71. package/dist-cjs/detection/adapter-contract.js +168 -0
  72. package/dist-cjs/detection/adapter-contract.js.map +1 -0
  73. package/dist-cjs/detection/batch.js +71 -0
  74. package/dist-cjs/detection/batch.js.map +1 -0
  75. package/dist-cjs/detection/classify.js +48 -0
  76. package/dist-cjs/detection/classify.js.map +1 -0
  77. package/dist-cjs/detection/content.js +122 -0
  78. package/dist-cjs/detection/content.js.map +1 -0
  79. package/dist-cjs/detection/continuity.js +88 -0
  80. package/dist-cjs/detection/continuity.js.map +1 -0
  81. package/dist-cjs/detection/diff.js +193 -0
  82. package/dist-cjs/detection/diff.js.map +1 -0
  83. package/dist-cjs/detection/echo.js +25 -0
  84. package/dist-cjs/detection/echo.js.map +1 -0
  85. package/dist-cjs/detection/enrollment.js +189 -0
  86. package/dist-cjs/detection/enrollment.js.map +1 -0
  87. package/dist-cjs/detection/index.js +57 -0
  88. package/dist-cjs/detection/index.js.map +1 -0
  89. package/dist-cjs/detection/record-proposal.js +170 -0
  90. package/dist-cjs/detection/record-proposal.js.map +1 -0
  91. package/dist-cjs/detection/refusal.js +44 -0
  92. package/dist-cjs/detection/refusal.js.map +1 -0
  93. package/dist-cjs/detection/repository.js +67 -0
  94. package/dist-cjs/detection/repository.js.map +1 -0
  95. package/dist-cjs/detection/territory.js +82 -0
  96. package/dist-cjs/detection/territory.js.map +1 -0
  97. package/dist-cjs/detection/watch-boundary.js +51 -0
  98. package/dist-cjs/detection/watch-boundary.js.map +1 -0
  99. package/dist-cjs/entities/bytes.js +92 -0
  100. package/dist-cjs/entities/bytes.js.map +1 -0
  101. package/dist-cjs/entities/cloud.js +171 -0
  102. package/dist-cjs/entities/cloud.js.map +1 -0
  103. package/dist-cjs/entities/index.js +39 -0
  104. package/dist-cjs/entities/index.js.map +1 -0
  105. package/dist-cjs/entities/moves.js +85 -0
  106. package/dist-cjs/entities/moves.js.map +1 -0
  107. package/dist-cjs/entities/repo-states.js +256 -0
  108. package/dist-cjs/entities/repo-states.js.map +1 -0
  109. package/dist-cjs/entities/rules.js +216 -0
  110. package/dist-cjs/entities/rules.js.map +1 -0
  111. package/dist-cjs/entities/types.js +44 -0
  112. package/dist-cjs/entities/types.js.map +1 -0
  113. package/dist-cjs/files/commands.js +120 -0
  114. package/dist-cjs/files/commands.js.map +1 -0
  115. package/dist-cjs/files/index.js +19 -0
  116. package/dist-cjs/files/index.js.map +1 -0
  117. package/dist-cjs/index.js +39 -0
  118. package/dist-cjs/index.js.map +1 -0
  119. package/dist-cjs/machines/arbitration.js +41 -0
  120. package/dist-cjs/machines/arbitration.js.map +1 -0
  121. package/dist-cjs/machines/backoff.js +38 -0
  122. package/dist-cjs/machines/backoff.js.map +1 -0
  123. package/dist-cjs/machines/bootstrap.js +110 -0
  124. package/dist-cjs/machines/bootstrap.js.map +1 -0
  125. package/dist-cjs/machines/chunks.js +72 -0
  126. package/dist-cjs/machines/chunks.js.map +1 -0
  127. package/dist-cjs/machines/index.js +28 -0
  128. package/dist-cjs/machines/index.js.map +1 -0
  129. package/dist-cjs/machines/presence.js +53 -0
  130. package/dist-cjs/machines/presence.js.map +1 -0
  131. package/dist-cjs/merge/index.js +25 -0
  132. package/dist-cjs/merge/index.js.map +1 -0
  133. package/dist-cjs/merge/merge3.js +191 -0
  134. package/dist-cjs/merge/merge3.js.map +1 -0
  135. package/dist-cjs/package.json +1 -0
  136. package/dist-cjs/records/authority.js +31 -0
  137. package/dist-cjs/records/authority.js.map +1 -0
  138. package/dist-cjs/records/codec.js +48 -0
  139. package/dist-cjs/records/codec.js.map +1 -0
  140. package/dist-cjs/records/contracts.js +121 -0
  141. package/dist-cjs/records/contracts.js.map +1 -0
  142. package/dist-cjs/records/inbox.js +37 -0
  143. package/dist-cjs/records/inbox.js.map +1 -0
  144. package/dist-cjs/records/index.js +23 -0
  145. package/dist-cjs/records/index.js.map +1 -0
  146. package/dist-cjs/records/outbox.js +48 -0
  147. package/dist-cjs/records/outbox.js.map +1 -0
  148. package/dist-cjs/registration/index.js +19 -0
  149. package/dist-cjs/registration/index.js.map +1 -0
  150. package/dist-cjs/registration/user-ground.js +183 -0
  151. package/dist-cjs/registration/user-ground.js.map +1 -0
  152. package/dist-cjs/transfer/artifacts.js +75 -0
  153. package/dist-cjs/transfer/artifacts.js.map +1 -0
  154. package/dist-cjs/transfer/batches.js +44 -0
  155. package/dist-cjs/transfer/batches.js.map +1 -0
  156. package/dist-cjs/transfer/download.js +88 -0
  157. package/dist-cjs/transfer/download.js.map +1 -0
  158. package/dist-cjs/transfer/index.js +21 -0
  159. package/dist-cjs/transfer/index.js.map +1 -0
  160. package/dist-cjs/transfer/parallel.js +35 -0
  161. package/dist-cjs/transfer/parallel.js.map +1 -0
  162. package/dist-cjs/transfer/upload.js +161 -0
  163. package/dist-cjs/transfer/upload.js.map +1 -0
  164. package/dist-cjs/watching/coverage.js +54 -0
  165. package/dist-cjs/watching/coverage.js.map +1 -0
  166. package/dist-cjs/watching/index.js +24 -0
  167. package/dist-cjs/watching/index.js.map +1 -0
  168. package/dist-cjs/watching/suspicion.js +105 -0
  169. package/dist-cjs/watching/suspicion.js.map +1 -0
  170. package/dist-cjs/workspace/api.js +66 -0
  171. package/dist-cjs/workspace/api.js.map +1 -0
  172. package/dist-cjs/workspace/identity.js +32 -0
  173. package/dist-cjs/workspace/identity.js.map +1 -0
  174. package/dist-cjs/workspace/index.js +14 -0
  175. package/dist-cjs/workspace/index.js.map +1 -0
  176. package/dist-cjs/workspace/memory-store.js +21 -0
  177. package/dist-cjs/workspace/memory-store.js.map +1 -0
  178. package/dist-cjs/workspace/registry.js +98 -0
  179. package/dist-cjs/workspace/registry.js.map +1 -0
  180. package/dist-cjs/workspace/types.js +3 -0
  181. package/dist-cjs/workspace/types.js.map +1 -0
  182. package/package.json +30 -8
  183. package/dist/contracts/mutation.d.ts +0 -51
  184. package/dist/contracts/mutation.d.ts.map +0 -1
  185. package/dist/contracts/mutation.js +0 -55
  186. package/dist/contracts/mutation.js.map +0 -1
  187. package/dist/machines/journal.d.ts +0 -63
  188. package/dist/machines/journal.d.ts.map +0 -1
  189. package/dist/machines/journal.js +0 -71
  190. package/dist/machines/journal.js.map +0 -1
  191. package/dist/machines/ordering.d.ts +0 -53
  192. package/dist/machines/ordering.d.ts.map +0 -1
  193. package/dist/machines/ordering.js +0 -87
  194. package/dist/machines/ordering.js.map +0 -1
@@ -0,0 +1,256 @@
1
+ "use strict";
2
+ /**
3
+ * Portable repository state and binary transport.
4
+ *
5
+ * Git object bytes remain a native PACK stream. Amalgm metadata is a short
6
+ * UTF-8 JSON header followed by raw checkpoint cargo; no byte field is ever
7
+ * base64 encoded. Successive transports name their parent and carry an
8
+ * identity-map delta, so one new commit never embeds old repository history
9
+ * or the unchanged per-path identity map again.
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.deriveStateId = exports.REPOSITORY_TRANSPORT_CONTRACT = void 0;
13
+ exports.repositoryIdentityHash = repositoryIdentityHash;
14
+ exports.planRepositoryIdentity = planRepositoryIdentity;
15
+ exports.applyRepositoryIdentity = applyRepositoryIdentity;
16
+ exports.encodeRepositoryTransport = encodeRepositoryTransport;
17
+ exports.repositoryTransportMetadataBytes = repositoryTransportMetadataBytes;
18
+ exports.inspectRepositoryTransport = inspectRepositoryTransport;
19
+ exports.decodeRepositoryTransport = decodeRepositoryTransport;
20
+ exports.repositoryTransportSizes = repositoryTransportSizes;
21
+ exports.deriveCardId = deriveCardId;
22
+ exports.deriveCheckpointId = deriveCheckpointId;
23
+ const bytes_js_1 = require("./bytes.js");
24
+ exports.REPOSITORY_TRANSPORT_CONTRACT = 'amalgm.repo-transport.v2';
25
+ const MAGIC = (0, bytes_js_1.utf8Encode)('AMGREPO2');
26
+ const HEADER_BYTES = MAGIC.byteLength + 4;
27
+ const sortedIdentity = (identity) => [...identity].sort((left, right) => left.path < right.path ? -1 : left.path > right.path ? 1 : 0);
28
+ function repositoryIdentityHash(identity, sha256Hex) {
29
+ return sha256Hex(JSON.stringify(sortedIdentity(identity)));
30
+ }
31
+ /** Derive the smallest path-keyed change from one identity map to the next. */
32
+ function planRepositoryIdentity(current, previous, sha256Hex) {
33
+ const next = sortedIdentity(current);
34
+ if (new Set(next.map((entry) => entry.path)).size !== next.length) {
35
+ throw new Error('repository identity map has duplicate paths');
36
+ }
37
+ if (previous === null) {
38
+ return {
39
+ identityHash: repositoryIdentityHash(next, sha256Hex),
40
+ identityDelta: { reset: true, upsert: next, remove: [] },
41
+ };
42
+ }
43
+ const prior = new Map(previous.map((entry) => [entry.path, entry]));
44
+ const currentPaths = new Set(next.map((entry) => entry.path));
45
+ const upsert = next.filter((entry) => {
46
+ const old = prior.get(entry.path);
47
+ return old === undefined || old.uuid !== entry.uuid || old.type !== entry.type
48
+ || (old.payloadVersion ?? null) !== (entry.payloadVersion ?? null);
49
+ });
50
+ const remove = [...prior.keys()].filter((path) => !currentPaths.has(path)).sort();
51
+ return {
52
+ identityHash: repositoryIdentityHash(next, sha256Hex),
53
+ identityDelta: { reset: false, upsert, remove },
54
+ };
55
+ }
56
+ /** Apply and verify one identity-map chain node. */
57
+ function applyRepositoryIdentity(previous, transport, sha256Hex) {
58
+ if (transport.identityDelta.reset !== (previous === null)) {
59
+ throw new Error('repository identity delta has the wrong chain boundary');
60
+ }
61
+ const entries = new Map((previous ?? []).map((entry) => [entry.path, entry]));
62
+ for (const path of transport.identityDelta.remove)
63
+ entries.delete(path);
64
+ for (const entry of transport.identityDelta.upsert)
65
+ entries.set(entry.path, entry);
66
+ const result = sortedIdentity([...entries.values()]);
67
+ if (repositoryIdentityHash(result, sha256Hex) !== transport.identityHash) {
68
+ throw new Error('repository identity delta does not produce its declared map');
69
+ }
70
+ return result;
71
+ }
72
+ const descriptor = (bytes) => ({ bytes: bytes.byteLength });
73
+ /** Encode metadata followed by raw Git/checkpoint bytes. */
74
+ function encodeRepositoryTransport(state, input) {
75
+ const header = {
76
+ contract: exports.REPOSITORY_TRANSPORT_CONTRACT,
77
+ stateId: state.stateId,
78
+ cardId: state.cardId,
79
+ checkpointId: state.checkpointId,
80
+ parentTransportVersion: input.parentTransportVersion,
81
+ identityHash: input.identityHash,
82
+ identityDelta: input.identityDelta,
83
+ card: state.card,
84
+ pack: state.pack ? { sha256: state.pack.sha256, bytes: state.pack.bytes.byteLength } : null,
85
+ checkpoint: {
86
+ baseCommit: state.checkpoint.baseCommit,
87
+ branch: state.checkpoint.branch,
88
+ stagedPatch: descriptor(state.checkpoint.stagedPatch),
89
+ unstagedPatch: descriptor(state.checkpoint.unstagedPatch),
90
+ untracked: state.checkpoint.untracked.map((file) => ({
91
+ path: file.path,
92
+ mode: file.mode,
93
+ sha256: file.sha256,
94
+ ...(file.reused === undefined ? {} : { reused: file.reused }),
95
+ content: file.content === null ? null : descriptor(file.content),
96
+ })),
97
+ },
98
+ };
99
+ const metadata = (0, bytes_js_1.utf8Encode)(JSON.stringify(header));
100
+ if (metadata.byteLength > 0xffff_ffff)
101
+ throw new Error('repository transport metadata is too large');
102
+ const cargo = [
103
+ ...(state.pack ? [state.pack.bytes] : []),
104
+ state.checkpoint.stagedPatch,
105
+ state.checkpoint.unstagedPatch,
106
+ ...state.checkpoint.untracked.flatMap((file) => file.content === null ? [] : [file.content]),
107
+ ];
108
+ const cargoBytes = cargo.reduce((total, bytes) => total + bytes.byteLength, 0);
109
+ const output = new Uint8Array(HEADER_BYTES + metadata.byteLength + cargoBytes);
110
+ output.set(MAGIC, 0);
111
+ new DataView(output.buffer).setUint32(MAGIC.byteLength, metadata.byteLength, false);
112
+ output.set(metadata, HEADER_BYTES);
113
+ let cursor = HEADER_BYTES + metadata.byteLength;
114
+ for (const bytes of cargo) {
115
+ output.set(bytes, cursor);
116
+ cursor += bytes.byteLength;
117
+ }
118
+ return output;
119
+ }
120
+ const byteCount = (value, label) => {
121
+ if (!Number.isSafeInteger(value) || value < 0) {
122
+ throw new Error(`repository transport has invalid ${label} byte count`);
123
+ }
124
+ return value;
125
+ };
126
+ /** Number of leading bytes needed to decode metadata without reading cargo. */
127
+ function repositoryTransportMetadataBytes(prefix) {
128
+ if (prefix.byteLength < HEADER_BYTES
129
+ || MAGIC.some((value, index) => prefix[index] !== value)) {
130
+ throw new Error('repository transport has an invalid binary header');
131
+ }
132
+ const metadataBytes = new DataView(prefix.buffer, prefix.byteOffset, prefix.byteLength)
133
+ .getUint32(MAGIC.byteLength, false);
134
+ const total = HEADER_BYTES + metadataBytes;
135
+ if (!Number.isSafeInteger(total))
136
+ throw new Error('repository transport metadata is too large');
137
+ return total;
138
+ }
139
+ /** Decode the small JSON header into seekable cargo ranges. */
140
+ function inspectRepositoryTransport(metadata, totalBytes) {
141
+ const metadataBytes = repositoryTransportMetadataBytes(metadata);
142
+ if (metadata.byteLength < metadataBytes)
143
+ throw new Error('repository transport metadata is truncated');
144
+ if (!Number.isSafeInteger(totalBytes) || totalBytes < metadataBytes) {
145
+ throw new Error('repository transport total byte count is invalid');
146
+ }
147
+ const header = JSON.parse((0, bytes_js_1.utf8Decode)(metadata.subarray(HEADER_BYTES, metadataBytes)));
148
+ if (header.contract !== exports.REPOSITORY_TRANSPORT_CONTRACT) {
149
+ throw new Error('repository transport contract is unsupported');
150
+ }
151
+ let cursor = metadataBytes;
152
+ const range = (count, label) => {
153
+ const bytes = byteCount(count, label);
154
+ const result = { offset: cursor, bytes };
155
+ cursor += bytes;
156
+ if (!Number.isSafeInteger(cursor) || cursor > totalBytes) {
157
+ throw new Error(`repository transport ${label} is truncated`);
158
+ }
159
+ return result;
160
+ };
161
+ const pack = header.pack === null ? null : {
162
+ sha256: header.pack.sha256,
163
+ range: range(header.pack.bytes, 'Git pack'),
164
+ };
165
+ const stagedPatch = range(header.checkpoint.stagedPatch.bytes, 'staged patch');
166
+ const unstagedPatch = range(header.checkpoint.unstagedPatch.bytes, 'unstaged patch');
167
+ const untracked = header.checkpoint.untracked.map((file) => ({
168
+ ...file,
169
+ content: file.content === null ? null : range(file.content.bytes, `untracked file ${file.path}`),
170
+ }));
171
+ if (cursor !== totalBytes)
172
+ throw new Error('repository transport has trailing cargo');
173
+ return {
174
+ stateId: header.stateId,
175
+ cardId: header.cardId,
176
+ checkpointId: header.checkpointId,
177
+ parentTransportVersion: header.parentTransportVersion,
178
+ identityHash: header.identityHash,
179
+ identityDelta: header.identityDelta,
180
+ card: header.card,
181
+ pack,
182
+ checkpoint: {
183
+ baseCommit: header.checkpoint.baseCommit,
184
+ branch: header.checkpoint.branch,
185
+ stagedPatch,
186
+ unstagedPatch,
187
+ untracked,
188
+ },
189
+ metadataBytes,
190
+ totalBytes,
191
+ };
192
+ }
193
+ /** Decode the binary envelope without interpreting Git's native pack bytes. */
194
+ function decodeRepositoryTransport(bytes) {
195
+ const layout = inspectRepositoryTransport(bytes, bytes.byteLength);
196
+ const take = (range) => bytes.slice(range.offset, range.offset + range.bytes);
197
+ return {
198
+ stateId: layout.stateId,
199
+ cardId: layout.cardId,
200
+ checkpointId: layout.checkpointId,
201
+ parentTransportVersion: layout.parentTransportVersion,
202
+ identityHash: layout.identityHash,
203
+ identityDelta: layout.identityDelta,
204
+ card: layout.card,
205
+ pack: layout.pack === null ? null : {
206
+ sha256: layout.pack.sha256,
207
+ bytes: take(layout.pack.range),
208
+ },
209
+ checkpoint: {
210
+ baseCommit: layout.checkpoint.baseCommit,
211
+ branch: layout.checkpoint.branch,
212
+ stagedPatch: take(layout.checkpoint.stagedPatch),
213
+ unstagedPatch: take(layout.checkpoint.unstagedPatch),
214
+ untracked: layout.checkpoint.untracked.map((file) => ({
215
+ ...file,
216
+ content: file.content === null ? null : take(file.content),
217
+ })),
218
+ },
219
+ };
220
+ }
221
+ /** Separate Git work from Amalgm metadata/checkpoint overhead in benchmarks. */
222
+ function repositoryTransportSizes(bytes) {
223
+ const transport = decodeRepositoryTransport(bytes);
224
+ const metadataBytes = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength)
225
+ .getUint32(MAGIC.byteLength, false) + HEADER_BYTES;
226
+ const gitPackBytes = transport.pack?.bytes.byteLength ?? 0;
227
+ return {
228
+ totalBytes: bytes.byteLength,
229
+ metadataBytes,
230
+ gitPackBytes,
231
+ checkpointBytes: bytes.byteLength - metadataBytes - gitPackBytes,
232
+ };
233
+ }
234
+ /** Card identity from the ledger only. Remotes and transport data are absent. */
235
+ function deriveCardId(card, sha256Hex) {
236
+ return sha256Hex(JSON.stringify({
237
+ version: card.version,
238
+ head: card.head,
239
+ branches: card.branches,
240
+ tags: card.tags,
241
+ }));
242
+ }
243
+ /** Checkpoint identity from its hashes, never duplicated byte encodings. */
244
+ function deriveCheckpointId(checkpoint, sha256Hex) {
245
+ return sha256Hex(JSON.stringify({
246
+ baseCommit: checkpoint.baseCommit,
247
+ stagedPatch: sha256Hex(checkpoint.stagedPatch),
248
+ unstagedPatch: sha256Hex(checkpoint.unstagedPatch),
249
+ untracked: checkpoint.untracked.map((file) => ({
250
+ path: file.path, mode: file.mode, sha256: file.sha256,
251
+ })),
252
+ }));
253
+ }
254
+ const deriveStateId = (cardId, checkpointId, sha256Hex) => sha256Hex(cardId + checkpointId);
255
+ exports.deriveStateId = deriveStateId;
256
+ //# sourceMappingURL=repo-states.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repo-states.js","sourceRoot":"","sources":["../../src/entities/repo-states.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAwJH,wDAKC;AAGD,wDA2BC;AAGD,0DAgBC;AAKD,8DA+CC;AAUD,4EAUC;AAGD,gEAuDC;AAGD,8DA2BC;AAGD,4DAgBC;AAGD,oCAUC;AAGD,gDAYC;AA1ZD,yCAAoD;AAEvC,QAAA,6BAA6B,GAAG,0BAA0B,CAAC;AAExE,MAAM,KAAK,GAAG,IAAA,qBAAU,EAAC,UAAU,CAAC,CAAC;AACrC,MAAM,YAAY,GAAG,KAAK,CAAC,UAAU,GAAG,CAAC,CAAC;AA6I1C,MAAM,cAAc,GAAG,CAAC,QAAsC,EAAuB,EAAE,CACrF,CAAC,GAAG,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAEpG,SAAgB,sBAAsB,CACpC,QAAsC,EACtC,SAAoB;IAEpB,OAAO,SAAS,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,CAAC,UAAU;QACjC,WAAW,EAAE,SAAS,CAAC,UAAU,CAAC,WAAW,CAAC;QAC9C,aAAa,EAAE,SAAS,CAAC,UAAU,CAAC,aAAa,CAAC;QAClD,SAAS,EAAE,UAAU,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YAC7C,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM;SACtD,CAAC,CAAC;KACJ,CAAC,CAAC,CAAC;AACN,CAAC;AAEM,MAAM,aAAa,GAAG,CAAC,MAAc,EAAE,YAAoB,EAAE,SAAoB,EAAU,EAAE,CAClG,SAAS,CAAC,MAAM,GAAG,YAAY,CAAC,CAAC;AADtB,QAAA,aAAa,iBACS"}
@@ -0,0 +1,216 @@
1
+ "use strict";
2
+ /**
3
+ * The registry's pure rule surface — the laws of the entity model (engine
4
+ * docs/entity-model.md) with every store lookup behind the injected
5
+ * {@link EntityReadPort} and every hash behind {@link Sha256Hex}:
6
+ *
7
+ * - the ratified version formula: version = hash(type, parentUUID, name,
8
+ * status, adapterPayloadVersion) — DERIVED, never stored;
9
+ * - container payloads as sorted active direct membership;
10
+ * - lifecycle inheritance DOWN the ancestor chain as derived effective
11
+ * status (deleted > trashed > own stored status);
12
+ * - one active owner per (parentUUID, name) slot; only containers hold
13
+ * active children; the parent graph is acyclic;
14
+ * - what an attestation may say (leaf ground attests bytes; membership and
15
+ * reference identity are never observed);
16
+ * - the record / syncRecord shapes and the cloud-record normalizer.
17
+ *
18
+ * Refusal messages are ported verbatim from the engine registry — they are
19
+ * the ratified refusal text its exams pin.
20
+ */
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.mustGet = mustGet;
23
+ exports.attestable = attestable;
24
+ exports.canonicalVersion = canonicalVersion;
25
+ exports.validName = validName;
26
+ exports.mintOrValidateUuid = mintOrValidateUuid;
27
+ exports.ancestorsOf = ancestorsOf;
28
+ exports.effectiveStatusOf = effectiveStatusOf;
29
+ exports.membershipHash = membershipHash;
30
+ exports.entityRecordOf = entityRecordOf;
31
+ exports.syncRecordOf = syncRecordOf;
32
+ exports.normalizeCloudRecord = normalizeCloudRecord;
33
+ exports.sameLogicalRecord = sameLogicalRecord;
34
+ exports.requireActiveContainerParent = requireActiveContainerParent;
35
+ exports.requireFreeSlot = requireFreeSlot;
36
+ const types_js_1 = require("./types.js");
37
+ /** The row a UUID must name; absence is the caller's bug, said plainly. */
38
+ function mustGet(uuid, byUuid) {
39
+ const row = byUuid(uuid);
40
+ if (!row)
41
+ throw new Error(`no entity ${uuid}`);
42
+ return row;
43
+ }
44
+ /**
45
+ * What an attestation may say — asked of both the type a record wears now
46
+ * and the type its new bytes claim, because an attestation may carry a
47
+ * record across leaf kinds (a pointer replaced by bytes) and both ends
48
+ * must be ground an observation can speak for.
49
+ */
50
+ function attestable(type) {
51
+ if (types_js_1.DERIVED_PAYLOAD.has(type)) {
52
+ throw new Error(`${type} payload is derived membership, never attested`);
53
+ }
54
+ if (type === 'reference') {
55
+ throw new Error('a reference\'s payload is the target\'s identity, set by the deliberate act that created it — never an attestation; the rendered symlink is derived state, not evidence');
56
+ }
57
+ if (!types_js_1.TYPES.has(type))
58
+ throw new Error(`unknown entity type ${JSON.stringify(type)}`);
59
+ }
60
+ /** The ratified formula: version = hash(type, parentUUID, name, status, payloadVersion). */
61
+ function canonicalVersion({ type, parentUUID = null, name, status, payloadVersion = null }, sha256Hex) {
62
+ return sha256Hex(JSON.stringify([type, parentUUID, name, status, payloadVersion]));
63
+ }
64
+ /** A name is one non-empty path segment: never '', '.', '..', a '/' or NUL. */
65
+ function validName(name) {
66
+ if (typeof name !== 'string' || name === '' || name === '.' || name === '..'
67
+ || name.includes('/') || name.includes('\0')) {
68
+ throw new Error(`invalid entity name ${JSON.stringify(name)}: a name is one non-empty path segment`);
69
+ }
70
+ }
71
+ /** A UUID may arrive only through a trusted identity binding (for example
72
+ * a cloud user-home bootstrap). The registry still owns the actual insert:
73
+ * accepting a caller-supplied UUID is not accepting a caller-supplied
74
+ * record, parent, status, or version. */
75
+ function mintOrValidateUuid(uuid, ports) {
76
+ if (uuid === undefined || uuid === null)
77
+ return ports.mintUuid();
78
+ if (typeof uuid !== 'string' || !types_js_1.UUID_PATTERN.test(uuid)) {
79
+ throw new Error(`entity identity must be a UUID, got ${JSON.stringify(uuid)}`);
80
+ }
81
+ if (ports.byUuid(uuid))
82
+ throw new Error(`entity identity ${uuid} is already registered`);
83
+ return uuid.toLowerCase();
84
+ }
85
+ /** Ancestor uuids from the given parent up to the root. */
86
+ function ancestorsOf(parentUuid, byUuid) {
87
+ const chain = [];
88
+ const seen = new Set();
89
+ let cursor = parentUuid;
90
+ while (cursor !== null) {
91
+ if (seen.has(cursor))
92
+ throw new Error(`registry corrupt: parent cycle at ${cursor}`);
93
+ seen.add(cursor);
94
+ chain.push(cursor);
95
+ cursor = mustGet(cursor, byUuid).parentUuid;
96
+ }
97
+ return chain;
98
+ }
99
+ /** Lifecycle inherits down: deleted if any ancestor is deleted, trashed if
100
+ * any is trashed, otherwise the entity's own stored status — one flip on a
101
+ * folder, no descendant record rewritten. */
102
+ function effectiveStatusOf(row, byUuid) {
103
+ const statuses = [row.status, ...ancestorsOf(row.parentUuid, byUuid)
104
+ .map((uuid) => mustGet(uuid, byUuid).status)];
105
+ if (statuses.includes('deleted'))
106
+ return 'deleted';
107
+ if (statuses.includes('trashed'))
108
+ return 'trashed';
109
+ return row.status;
110
+ }
111
+ const byUuidOrder = (left, right) => (left < right ? -1 : left > right ? 1 : 0);
112
+ /**
113
+ * Container payload: the sorted active direct membership (childUUID, name).
114
+ * Children are sorted here by uuid, codepoint order — the same order the
115
+ * engine's `ORDER BY uuid` (BINARY collation over lowercase-hex uuids)
116
+ * produces — so the hash input is byte-identical however the port returns
117
+ * them. Membership counts direct children by their STORED status, never
118
+ * effective status: effective-status membership would ripple a version
119
+ * change through the entire subtree and defeat the one-flip lifecycle.
120
+ */
121
+ function membershipHash(activeChildren, sha256Hex) {
122
+ const pairs = [...activeChildren]
123
+ .sort((left, right) => byUuidOrder(left.uuid, right.uuid))
124
+ .map((child) => [child.uuid, child.name]);
125
+ return sha256Hex(JSON.stringify(pairs));
126
+ }
127
+ const payloadFor = (row, ports) => (types_js_1.DERIVED_PAYLOAD.has(row.type) ? ports.membershipHashOf(row.uuid) : row.payloadVersion);
128
+ /** The public record: exactly the six ratified fields, version derived. */
129
+ function entityRecordOf(row, ports) {
130
+ return {
131
+ uuid: row.uuid,
132
+ type: row.type,
133
+ parentUUID: row.parentUuid,
134
+ name: row.name,
135
+ version: canonicalVersion({
136
+ type: row.type, parentUUID: row.parentUuid, name: row.name,
137
+ status: row.status, payloadVersion: payloadFor(row, ports),
138
+ }, ports.sha256Hex),
139
+ status: row.status,
140
+ };
141
+ }
142
+ /** The cloud form contains identity and the content/head token, never an
143
+ * address, watcher, inode, or SQLite bytes. `payloadVersion` is the
144
+ * unambiguous current head for leaf types; containers derive theirs from
145
+ * membership and retain null here; a repo.git retains its immutable
146
+ * Card/Checkpoint head. */
147
+ function syncRecordOf(row, ports) {
148
+ return {
149
+ ...entityRecordOf(row, ports),
150
+ payloadVersion: row.payloadVersion,
151
+ };
152
+ }
153
+ /** Validate and normalize a record arriving from the cloud: six fields plus
154
+ * payloadVersion, UUIDs lowercased, root laws enforced. */
155
+ function normalizeCloudRecord(value) {
156
+ const record = value;
157
+ if (!record || typeof record !== 'object'
158
+ || typeof record.uuid !== 'string' || !types_js_1.UUID_PATTERN.test(record.uuid)
159
+ || typeof record.type !== 'string' || !types_js_1.TYPES.has(record.type)
160
+ || (record.parentUUID !== null && (typeof record.parentUUID !== 'string' || !types_js_1.UUID_PATTERN.test(record.parentUUID)))
161
+ || typeof record.name !== 'string'
162
+ || !['active', 'trashed', 'deleted'].includes(record.status)
163
+ || (record.payloadVersion !== null && typeof record.payloadVersion !== 'string')
164
+ || typeof record.version !== 'string' || !/^[0-9a-f]{64}$/i.test(record.version)) {
165
+ throw new Error('cloud entity operation has an invalid record');
166
+ }
167
+ validName(record.name);
168
+ if (record.parentUUID === null && !types_js_1.ROOT_TYPES.has(record.type)) {
169
+ throw new Error(`cloud entity ${record.uuid} is not a valid tree root`);
170
+ }
171
+ if (record.parentUUID !== null && record.type === 'workspace') {
172
+ throw new Error('cloud entity workspace is the root type only');
173
+ }
174
+ return {
175
+ uuid: record.uuid.toLowerCase(),
176
+ type: record.type,
177
+ parentUuid: record.parentUUID === null ? null : record.parentUUID.toLowerCase(),
178
+ name: record.name,
179
+ status: record.status,
180
+ payloadVersion: record.payloadVersion,
181
+ expectedVersion: record.version.toLowerCase(),
182
+ };
183
+ }
184
+ /** Equality over the five stored facts plus payload — everything the
185
+ * version fingerprints except the fingerprint itself. */
186
+ function sameLogicalRecord(left, right) {
187
+ return left.uuid === right.uuid
188
+ && left.type === right.type
189
+ && left.parentUuid === right.parentUuid
190
+ && left.name === right.name
191
+ && left.status === right.status
192
+ && left.payloadVersion === right.payloadVersion;
193
+ }
194
+ /** Only containers — workspace, folder, repo.git — hold active children,
195
+ * and only while effectively active themselves. */
196
+ function requireActiveContainerParent(parentUuid, port) {
197
+ const parent = mustGet(parentUuid, port.byUuid.bind(port));
198
+ if (!types_js_1.CONTAINERS.has(parent.type)) {
199
+ throw new Error(`only containers hold active children: ${parentUuid} is ${parent.type}, not workspace/folder/repo.git`);
200
+ }
201
+ if (effectiveStatusOf(parent, port.byUuid.bind(port)) !== 'active') {
202
+ throw new Error(`parent ${parentUuid} is not effectively active — restore it before putting entities under it`);
203
+ }
204
+ return parent;
205
+ }
206
+ /** One active owner per (parentUUID, name) slot. Parentless records are
207
+ * exempt: a top-level tree is placed by its machine binding, never by name. */
208
+ function requireFreeSlot(parentUuid, name, port, forUuid = null) {
209
+ if (parentUuid === null)
210
+ return; // top level: address places a tree, never its name
211
+ const occupant = port.activeChildByName(parentUuid, name);
212
+ if (occupant && occupant.uuid !== forUuid) {
213
+ throw new Error(`slot taken: active entity ${occupant.uuid} already owns (${parentUuid}, ${name}) — move or trash it first`);
214
+ }
215
+ }
216
+ //# sourceMappingURL=rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rules.js","sourceRoot":"","sources":["../../src/entities/rules.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;AASH,0BAIC;AAQD,gCAQC;AAWD,4CAKC;AAGD,8BAKC;AAYD,gDAOC;AAGD,kCAWC;AAKD,8CASC;AAcD,wCAQC;AAaD,wCAYC;AAOD,oCAKC;AAgBD,oDA+BC;AAID,8CAUC;AAID,oEASC;AAID,0CAWC;AAtPD,yCAIoB;AAEpB,2EAA2E;AAC3E,SAAgB,OAAO,CAAC,IAAY,EAAE,MAAgC;IACpE,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IACzB,IAAI,CAAC,GAAG;QAAE,MAAM,IAAI,KAAK,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC;IAC/C,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;GAKG;AACH,SAAgB,UAAU,CAAC,IAAY;IACrC,IAAI,0BAAe,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,gDAAgD,CAAC,CAAC;IAC3E,CAAC;IACD,IAAI,IAAI,KAAK,WAAW,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,yKAAyK,CAAC,CAAC;IAC7L,CAAC;IACD,IAAI,CAAC,gBAAK,CAAC,GAAG,CAAC,IAAI,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,uBAAuB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACvF,CAAC;AAUD,4FAA4F;AAC5F,SAAgB,gBAAgB,CAC9B,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI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AC,yCAAyC,UAAU,OAAO,MAAM,CAAC,IAAI,iCAAiC,CAAC,CAAC;IAC1H,CAAC;IACD,IAAI,iBAAiB,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,QAAQ,EAAE,CAAC;QACnE,MAAM,IAAI,KAAK,CAAC,UAAU,UAAU,0EAA0E,CAAC,CAAC;IAClH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;+EAC+E;AAC/E,SAAgB,eAAe,CAC7B,UAAyB,EACzB,IAAY,EACZ,IAAoB,EACpB,UAAyB,IAAI;IAE7B,IAAI,UAAU,KAAK,IAAI;QAAE,OAAO,CAAC,mDAAmD;IACpF,MAAM,QAAQ,GAAG,IAAI,CAAC,iBAAiB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IAC1D,IAAI,QAAQ,IAAI,QAAQ,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CAAC,6BAA6B,QAAQ,CAAC,IAAI,kBAAkB,UAAU,KAAK,IAAI,4BAA4B,CAAC,CAAC;IAC/H,CAAC;AACH,CAAC"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ /**
3
+ * The entity alphabet and the six-field universal record — the value
4
+ * vocabulary of the entity model (engine docs/entity-model.md, "The entity
5
+ * record"). Every enrolled entity, of every type, is exactly six fields:
6
+ * UUID, type, parentUUID, name, version, status. Paths are derived from the
7
+ * parentUUID + name chain and are never identity; version is derived on
8
+ * read, never stored.
9
+ *
10
+ * The alphabet is PHYSICAL kinds only. Constructs — agents, apps,
11
+ * automations, tools, skills — are folder-and-file ground with a known
12
+ * structure, their meaning layered ABOVE the physical type, never encoded
13
+ * as one.
14
+ *
15
+ * This module also names the two ports the pure rules receive instead of a
16
+ * database or node:crypto: a read port over the host's identity store, and
17
+ * a SHA-256 hex function.
18
+ */
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.UUID_PATTERN = exports.isEntityType = exports.ENTITY_TYPES = exports.DERIVED_PAYLOAD = exports.ROOT_TYPES = exports.CONTAINERS = exports.TYPES = void 0;
21
+ const ALPHABET = [
22
+ 'workspace', 'folder', 'repo.git', 'file.text', 'file.binary',
23
+ 'link', 'reference',
24
+ ];
25
+ exports.TYPES = new Set(ALPHABET);
26
+ /** Only containers hold active children. */
27
+ exports.CONTAINERS = new Set(['workspace', 'folder', 'repo.git']);
28
+ /** The types a parentless record (a tree root) may wear. `folder` is
29
+ * deliberately absent: a folder inside no workspace is not a thing amalgm
30
+ * registers. `reference` is absent too — a managed pointer is always
31
+ * created inside a tree. */
32
+ exports.ROOT_TYPES = new Set(['workspace', 'repo.git', 'file.text', 'file.binary', 'link']);
33
+ /** Types whose payload IS their membership: derived from the records
34
+ * beneath them, so no observation may attest one. */
35
+ exports.DERIVED_PAYLOAD = new Set(['workspace', 'folder']);
36
+ /** The one entity alphabet, published sorted for the layers that map onto
37
+ * it — read from here, never restated, so it cannot drift. */
38
+ exports.ENTITY_TYPES = Object.freeze([...ALPHABET].sort());
39
+ const isEntityType = (value) => typeof value === 'string' && exports.TYPES.has(value);
40
+ exports.isEntityType = isEntityType;
41
+ /** RFC-4122 UUID shape (versions 1–8), the permanent identity and realtime
42
+ * channel of every enrolled entity. */
43
+ exports.UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
44
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/entities/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;AAiBH,MAAM,QAAQ,GAA0B;IACtC,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa;IAC7D,MAAM,EAAE,WAAW;CACpB,CAAC;AAEW,QAAA,KAAK,GAAwB,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;AAE5D,4CAA4C;AAC/B,QAAA,UAAU,GAAwB,IAAI,GAAG,CACpD,CAAC,WAAW,EAAE,QAAQ,EAAE,UAAU,CAA2B,CAC9D,CAAC;AAEF;;;4BAG4B;AACf,QAAA,UAAU,GAAwB,IAAI,GAAG,CACpD,CAAC,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,CAAwB,CACrF,CAAC;AAEF;qDACqD;AACxC,QAAA,eAAe,GAAwB,IAAI,GAAG,CACzD,CAAC,WAAW,EAAE,QAAQ,CAAwB,CAC/C,CAAC;AAEF;8DAC8D;AACjD,QAAA,YAAY,GAA0B,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AAEhF,MAAM,YAAY,GAAG,CAAC,KAAc,EAAuB,EAAE,CAClE,OAAO,KAAK,KAAK,QAAQ,IAAI,aAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AADnC,QAAA,YAAY,gBACuB;AAEhD;uCACuC;AAC1B,QAAA,YAAY,GACvB,4EAA4E,CAAC"}