amalgm 0.1.238 → 0.1.240
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/lib/shared-realtime-tunnel.js +22 -14
- package/package.json +1 -1
- package/runtime/scripts/amalgm-mcp/browser/cookie-jar.js +68 -20
- package/runtime/scripts/amalgm-mcp/project-context/store.js +87 -19
- package/runtime/scripts/amalgm-mcp/state/attachments.js +40 -12
- package/runtime/scripts/amalgm-mcp/state/db.js +216 -17
- package/runtime/scripts/amalgm-mcp/state/doc-disk.js +550 -0
- package/runtime/scripts/amalgm-mcp/state/docs.js +1101 -301
- package/runtime/scripts/amalgm-mcp/state/mutation-contracts.js +99 -0
- package/runtime/scripts/amalgm-mcp/state/mutations.js +507 -130
- package/runtime/scripts/amalgm-mcp/state/promotions.js +21 -1
- package/runtime/scripts/amalgm-mcp/state/replicas.js +134 -13
- package/runtime/scripts/amalgm-mcp/state/shared-rest.js +14 -8
- package/runtime/scripts/amalgm-mcp/tests/browser-cookie-cloud.test.js +193 -0
- package/runtime/scripts/amalgm-mcp/tests/code-project-stream.test.js +313 -94
- package/runtime/scripts/amalgm-mcp/tests/fixtures/code-project-stream-v2.json +1 -0
- package/runtime/scripts/amalgm-mcp/tests/project-context.test.js +32 -17
- package/runtime/scripts/amalgm-mcp/tests/shared-tunnel-rehydration.test.js +84 -0
- package/runtime/scripts/amalgm-mcp/tests/state-docs.test.js +376 -13
- package/runtime/scripts/amalgm-mcp/tests/state-mutations.test.js +309 -0
- package/runtime/scripts/amalgm-mcp/tests/state-shared-replica.test.js +758 -30
- package/runtime/scripts/amalgm-mcp/tests/workspace-cards-store.test.js +72 -3
- package/runtime/scripts/amalgm-mcp/tests/workspace-cards.test.js +33 -6
- package/runtime/scripts/amalgm-mcp/tests/workspace-checkpoint-reducer.test.js +27 -0
- package/runtime/scripts/amalgm-mcp/tests/workspace-checkpoint.test.js +334 -191
- package/runtime/scripts/amalgm-mcp/tests/workspace-durable.test.js +24 -0
- package/runtime/scripts/amalgm-mcp/tests/workspace-local-intent.test.js +1999 -0
- package/runtime/scripts/amalgm-mcp/tests/workspace-native-file-transaction.test.js +364 -0
- package/runtime/scripts/amalgm-mcp/tests/workspace-object-tunnel.test.js +81 -3
- package/runtime/scripts/amalgm-mcp/tests/workspace-objects.test.js +114 -8
- package/runtime/scripts/amalgm-mcp/tests/workspace-provenance.test.js +185 -0
- package/runtime/scripts/amalgm-mcp/tests/workspace-publication-invariants.test.js +174 -269
- package/runtime/scripts/amalgm-mcp/tests/workspace-reducer-liveness.test.js +26 -0
- package/runtime/scripts/amalgm-mcp/tests/workspace-reducer.test.js +2060 -407
- package/runtime/scripts/amalgm-mcp/tests/workspace-sync-stats.test.js +119 -0
- package/runtime/scripts/amalgm-mcp/tests/workspace-transition.test.js +1446 -0
- package/runtime/scripts/amalgm-mcp/tests/workspace-tree-cloud.test.js +5319 -3
- package/runtime/scripts/amalgm-mcp/tests/workspace-tree-core.test.js +191 -1
- package/runtime/scripts/amalgm-mcp/tests/workspace-tree-store.test.js +3140 -17
- package/runtime/scripts/amalgm-mcp/tests/workspace-wall.test.js +135 -637
- package/runtime/scripts/amalgm-mcp/workspace/access-store.js +5 -1
- package/runtime/scripts/amalgm-mcp/workspace/card.js +7 -7
- package/runtime/scripts/amalgm-mcp/workspace/cards.js +36 -12
- package/runtime/scripts/amalgm-mcp/workspace/checkpoint.js +436 -173
- package/runtime/scripts/amalgm-mcp/workspace/content.js +32 -0
- package/runtime/scripts/amalgm-mcp/workspace/durable.js +45 -0
- package/runtime/scripts/amalgm-mcp/workspace/git.js +391 -37
- package/runtime/scripts/amalgm-mcp/workspace/intent.js +535 -0
- package/runtime/scripts/amalgm-mcp/workspace/merge.js +89 -6
- package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/BUILD.md +31 -0
- package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/bin/darwin-arm64/amalgm-file-transaction +0 -0
- package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/bin/linux-x64/amalgm-file-transaction +0 -0
- package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/build.mjs +72 -0
- package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/client.js +165 -0
- package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/go.mod +5 -0
- package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/go.sum +2 -0
- package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/main.go +2201 -0
- package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/manifest.json +19 -0
- package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/move_darwin.go +18 -0
- package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/move_linux.go +18 -0
- package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/process_darwin.go +33 -0
- package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/process_linux.go +47 -0
- package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/verify.mjs +43 -0
- package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/writers_darwin.go +114 -0
- package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/writers_linux.go +84 -0
- package/runtime/scripts/amalgm-mcp/workspace/objects.js +119 -54
- package/runtime/scripts/amalgm-mcp/workspace/project-stream.js +616 -168
- package/runtime/scripts/amalgm-mcp/workspace/provenance.js +240 -0
- package/runtime/scripts/amalgm-mcp/workspace/reducer.js +1979 -570
- package/runtime/scripts/amalgm-mcp/workspace/rest.js +49 -28
- package/runtime/scripts/amalgm-mcp/workspace/store.js +77 -4
- package/runtime/scripts/amalgm-mcp/workspace/sync-stats.js +240 -0
- package/runtime/scripts/amalgm-mcp/workspace/transition.js +1729 -192
- package/runtime/scripts/amalgm-mcp/workspace/tree/floor.js +100 -0
- package/runtime/scripts/amalgm-mcp/workspace/tree/inclusion.js +7 -1
- package/runtime/scripts/amalgm-mcp/workspace/tree/local-state.js +73 -61
- package/runtime/scripts/amalgm-mcp/workspace/tree/observation-holds.js +127 -0
- package/runtime/scripts/amalgm-mcp/workspace/tree/path-state.js +12 -0
- package/runtime/scripts/amalgm-mcp/workspace/tree/reducer.js +51 -6
- package/runtime/scripts/amalgm-mcp/workspace/tree/root-binding.js +125 -0
- package/runtime/scripts/amalgm-mcp/workspace/tree/snapshot.js +79 -8
- package/runtime/scripts/amalgm-mcp/workspace/tree/symlinks.js +76 -0
- package/runtime/scripts/amalgm-mcp/workspace/tree-cloud.js +3480 -165
- package/runtime/scripts/amalgm-mcp/workspace/tree-materialization.js +3766 -0
- package/runtime/scripts/amalgm-mcp/workspace/tree-store.js +899 -71
- package/runtime/scripts/amalgm-mcp/workspace/wall.js +352 -497
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The complete provenance transition relation for managed repo bytes.
|
|
5
|
+
*
|
|
6
|
+
* This is deliberately data, not a second reconciler. Runtime code may name
|
|
7
|
+
* one of these transitions, and tests exhaust the whole relation.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const CLASS = Object.freeze({
|
|
11
|
+
OFFICIAL: 'officially-applied',
|
|
12
|
+
INTENT: 'journaled-local-intent',
|
|
13
|
+
UNKNOWN: 'unknown-provenance',
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const STATE = Object.freeze({
|
|
17
|
+
OFFICIAL: CLASS.OFFICIAL,
|
|
18
|
+
UNKNOWN: CLASS.UNKNOWN,
|
|
19
|
+
CAPTURED: `${CLASS.INTENT}:captured`,
|
|
20
|
+
RESERVED: `${CLASS.INTENT}:reserved`,
|
|
21
|
+
NUMBERED: `${CLASS.INTENT}:numbered`,
|
|
22
|
+
FOLDED: `${CLASS.INTENT}:folded`,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const ACTION = Object.freeze({
|
|
26
|
+
SAVE: 'save',
|
|
27
|
+
VERIFY: 'verify',
|
|
28
|
+
CAPTURE: 'capture',
|
|
29
|
+
RESERVE: 'reserve',
|
|
30
|
+
RETRY: 'retry',
|
|
31
|
+
NUMBER: 'number',
|
|
32
|
+
FOLD: 'fold',
|
|
33
|
+
APPLY: 'apply',
|
|
34
|
+
SNAPSHOT: 'snapshot',
|
|
35
|
+
COMPACT: 'compact',
|
|
36
|
+
PRUNE: 'prune',
|
|
37
|
+
RECOVER: 'recover',
|
|
38
|
+
OBSERVE_UNKNOWN: 'observe-unknown',
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const allStates = Object.freeze(Object.values(STATE));
|
|
42
|
+
|
|
43
|
+
function transition(from, action, to, facts) {
|
|
44
|
+
return Object.freeze({
|
|
45
|
+
from,
|
|
46
|
+
action,
|
|
47
|
+
to,
|
|
48
|
+
facts: Object.freeze(facts),
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const transitions = [
|
|
53
|
+
transition(STATE.OFFICIAL, ACTION.SAVE, STATE.UNKNOWN, [
|
|
54
|
+
'previous-provenance-preserved',
|
|
55
|
+
]),
|
|
56
|
+
...[
|
|
57
|
+
STATE.CAPTURED,
|
|
58
|
+
STATE.RESERVED,
|
|
59
|
+
STATE.NUMBERED,
|
|
60
|
+
STATE.FOLDED,
|
|
61
|
+
].map((from) => transition(from, ACTION.SAVE, STATE.UNKNOWN, [
|
|
62
|
+
'previous-provenance-preserved',
|
|
63
|
+
])),
|
|
64
|
+
transition(STATE.UNKNOWN, ACTION.OBSERVE_UNKNOWN, STATE.UNKNOWN, [
|
|
65
|
+
'exact-physical-observation',
|
|
66
|
+
]),
|
|
67
|
+
transition(STATE.UNKNOWN, ACTION.VERIFY, STATE.OFFICIAL, [
|
|
68
|
+
'official-target',
|
|
69
|
+
'physical-verification',
|
|
70
|
+
'applied-cursor',
|
|
71
|
+
]),
|
|
72
|
+
transition(STATE.UNKNOWN, ACTION.CAPTURE, STATE.CAPTURED, [
|
|
73
|
+
'verified-base',
|
|
74
|
+
'exact-local-state',
|
|
75
|
+
'physical-digest',
|
|
76
|
+
'intent-record',
|
|
77
|
+
]),
|
|
78
|
+
transition(STATE.CAPTURED, ACTION.RESERVE, STATE.RESERVED, [
|
|
79
|
+
'intent-record',
|
|
80
|
+
'publication-id',
|
|
81
|
+
]),
|
|
82
|
+
transition(STATE.RESERVED, ACTION.RESERVE, STATE.RESERVED, [
|
|
83
|
+
'same-publication-id',
|
|
84
|
+
'same-envelope',
|
|
85
|
+
]),
|
|
86
|
+
transition(STATE.RESERVED, ACTION.RETRY, STATE.RESERVED, [
|
|
87
|
+
'same-publication-id',
|
|
88
|
+
'same-envelope',
|
|
89
|
+
]),
|
|
90
|
+
transition(STATE.RESERVED, ACTION.NUMBER, STATE.NUMBERED, [
|
|
91
|
+
'publication-id',
|
|
92
|
+
'official-version',
|
|
93
|
+
'server-receipt',
|
|
94
|
+
]),
|
|
95
|
+
transition(STATE.NUMBERED, ACTION.NUMBER, STATE.NUMBERED, [
|
|
96
|
+
'same-publication-id',
|
|
97
|
+
'same-official-version',
|
|
98
|
+
]),
|
|
99
|
+
transition(STATE.NUMBERED, ACTION.FOLD, STATE.FOLDED, [
|
|
100
|
+
'predecessor-folded',
|
|
101
|
+
'official-event',
|
|
102
|
+
'official-snapshot',
|
|
103
|
+
]),
|
|
104
|
+
transition(STATE.FOLDED, ACTION.FOLD, STATE.FOLDED, [
|
|
105
|
+
'same-official-version',
|
|
106
|
+
'official-snapshot',
|
|
107
|
+
]),
|
|
108
|
+
transition(STATE.FOLDED, ACTION.APPLY, STATE.OFFICIAL, [
|
|
109
|
+
'official-target',
|
|
110
|
+
'apply-wal',
|
|
111
|
+
'physical-verification',
|
|
112
|
+
'applied-cursor',
|
|
113
|
+
'intent-retired',
|
|
114
|
+
]),
|
|
115
|
+
transition(STATE.OFFICIAL, ACTION.APPLY, STATE.OFFICIAL, [
|
|
116
|
+
'contiguous-official-target',
|
|
117
|
+
'apply-wal',
|
|
118
|
+
'physical-verification',
|
|
119
|
+
'applied-cursor',
|
|
120
|
+
]),
|
|
121
|
+
...[
|
|
122
|
+
STATE.CAPTURED,
|
|
123
|
+
STATE.RESERVED,
|
|
124
|
+
STATE.NUMBERED,
|
|
125
|
+
].map((state) => transition(state, ACTION.APPLY, state, [
|
|
126
|
+
'contiguous-official-target',
|
|
127
|
+
'apply-wal',
|
|
128
|
+
'pending-intent-preserved',
|
|
129
|
+
'physical-verification',
|
|
130
|
+
'applied-cursor',
|
|
131
|
+
])),
|
|
132
|
+
transition(STATE.OFFICIAL, ACTION.SNAPSHOT, STATE.OFFICIAL, [
|
|
133
|
+
'verified-snapshot',
|
|
134
|
+
'apply-wal',
|
|
135
|
+
'physical-verification',
|
|
136
|
+
'applied-cursor',
|
|
137
|
+
]),
|
|
138
|
+
transition(STATE.UNKNOWN, ACTION.SNAPSHOT, STATE.OFFICIAL, [
|
|
139
|
+
'empty-path',
|
|
140
|
+
'verified-snapshot',
|
|
141
|
+
'apply-wal',
|
|
142
|
+
'physical-verification',
|
|
143
|
+
'applied-cursor',
|
|
144
|
+
]),
|
|
145
|
+
transition(STATE.UNKNOWN, ACTION.SNAPSHOT, STATE.UNKNOWN, [
|
|
146
|
+
'unknown-bytes-preserved',
|
|
147
|
+
]),
|
|
148
|
+
...[
|
|
149
|
+
STATE.CAPTURED,
|
|
150
|
+
STATE.RESERVED,
|
|
151
|
+
].map((state) => transition(state, ACTION.SNAPSHOT, state, [
|
|
152
|
+
'verified-snapshot',
|
|
153
|
+
'apply-wal',
|
|
154
|
+
'pending-intent-preserved',
|
|
155
|
+
'physical-verification',
|
|
156
|
+
'applied-cursor',
|
|
157
|
+
])),
|
|
158
|
+
...[
|
|
159
|
+
STATE.NUMBERED,
|
|
160
|
+
STATE.FOLDED,
|
|
161
|
+
].map((state) => transition(state, ACTION.SNAPSHOT, STATE.OFFICIAL, [
|
|
162
|
+
'numbered-event-in-snapshot',
|
|
163
|
+
'verified-snapshot',
|
|
164
|
+
'apply-wal',
|
|
165
|
+
'physical-verification',
|
|
166
|
+
'applied-cursor',
|
|
167
|
+
'intent-retired',
|
|
168
|
+
])),
|
|
169
|
+
transition(STATE.OFFICIAL, ACTION.COMPACT, STATE.OFFICIAL, [
|
|
170
|
+
'retained-server-receipt',
|
|
171
|
+
'verified-server-snapshot',
|
|
172
|
+
]),
|
|
173
|
+
transition(STATE.FOLDED, ACTION.PRUNE, STATE.FOLDED, [
|
|
174
|
+
'official-fold',
|
|
175
|
+
'durable-folded-intent',
|
|
176
|
+
]),
|
|
177
|
+
transition(STATE.OFFICIAL, ACTION.PRUNE, STATE.OFFICIAL, [
|
|
178
|
+
'official-fold',
|
|
179
|
+
'physical-verification',
|
|
180
|
+
'applied-cursor',
|
|
181
|
+
]),
|
|
182
|
+
...allStates.map((state) => transition(state, ACTION.RECOVER, state, [
|
|
183
|
+
'durable-provenance-record',
|
|
184
|
+
'apply-wal-before-destructive-write',
|
|
185
|
+
])),
|
|
186
|
+
...[
|
|
187
|
+
STATE.OFFICIAL,
|
|
188
|
+
STATE.CAPTURED,
|
|
189
|
+
STATE.RESERVED,
|
|
190
|
+
STATE.NUMBERED,
|
|
191
|
+
STATE.FOLDED,
|
|
192
|
+
].map((state) => transition(state, ACTION.RECOVER, STATE.UNKNOWN, [
|
|
193
|
+
'apply-wal',
|
|
194
|
+
'exact-third-value-observation',
|
|
195
|
+
'previous-provenance-preserved',
|
|
196
|
+
])),
|
|
197
|
+
];
|
|
198
|
+
|
|
199
|
+
const TRANSITIONS = Object.freeze(transitions);
|
|
200
|
+
const transitionByKey = new Map(
|
|
201
|
+
TRANSITIONS.map((entry) => [`${entry.from}\u0000${entry.action}\u0000${entry.to}`, entry]),
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
function provenanceClass(state) {
|
|
205
|
+
if (state === STATE.OFFICIAL) return CLASS.OFFICIAL;
|
|
206
|
+
if (state === STATE.UNKNOWN) return CLASS.UNKNOWN;
|
|
207
|
+
if (typeof state === 'string' && state.startsWith(`${CLASS.INTENT}:`)) {
|
|
208
|
+
return CLASS.INTENT;
|
|
209
|
+
}
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function publicationState(publication) {
|
|
214
|
+
if (!publication) return STATE.CAPTURED;
|
|
215
|
+
if (publication.foldedAt != null) return STATE.FOLDED;
|
|
216
|
+
if (publication.numberedVersion != null) return STATE.NUMBERED;
|
|
217
|
+
return STATE.RESERVED;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function requireTransition(from, action, to, availableFacts = []) {
|
|
221
|
+
const entry = transitionByKey.get(`${from}\u0000${action}\u0000${to}`);
|
|
222
|
+
if (!entry) throw new Error(`illegal provenance transition: ${from} --${action}--> ${to}`);
|
|
223
|
+
const available = new Set(availableFacts);
|
|
224
|
+
const missing = entry.facts.filter((fact) => !available.has(fact));
|
|
225
|
+
if (missing.length > 0) {
|
|
226
|
+
throw new Error(`provenance transition ${action} is missing: ${missing.join(', ')}`);
|
|
227
|
+
}
|
|
228
|
+
return entry;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
module.exports = {
|
|
232
|
+
ACTION,
|
|
233
|
+
CLASS,
|
|
234
|
+
STATE,
|
|
235
|
+
TRANSITIONS,
|
|
236
|
+
allStates,
|
|
237
|
+
provenanceClass,
|
|
238
|
+
publicationState,
|
|
239
|
+
requireTransition,
|
|
240
|
+
};
|