amalgm 0.1.239 → 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 +6 -1
- 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 +8 -4
- 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
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
|
|
11
11
|
const { decryptJson, encryptJson } = require('../browser/auth-vault');
|
|
12
12
|
|
|
13
|
+
const CODE_PROJECT_CONTRACT = 'code-project-stream@2';
|
|
13
14
|
const COOKIE_CONTRACT = 'browser-cookie-jar@1';
|
|
15
|
+
const WORKSPACE_TREE_CONTRACT = 'workspace-tree@1';
|
|
14
16
|
const PROTECTED_KIND = 'amalgm.encrypted-json@1';
|
|
15
17
|
|
|
16
18
|
function isSensitiveContract(contract) {
|
|
@@ -47,10 +49,107 @@ function diagnosticOperation(contract, operation) {
|
|
|
47
49
|
};
|
|
48
50
|
}
|
|
49
51
|
|
|
52
|
+
/**
|
|
53
|
+
* A numbered code publication may leave the generic journal only after the
|
|
54
|
+
* canonical code-project snapshot carries at least that contiguous number.
|
|
55
|
+
*/
|
|
56
|
+
function codeProjectOrderIsDurable(row, options = {}) {
|
|
57
|
+
const database = options.database;
|
|
58
|
+
const version = Number(row.official_cloud_version);
|
|
59
|
+
if (
|
|
60
|
+
!database
|
|
61
|
+
|| !row.shared_resource_id
|
|
62
|
+
|| !Number.isSafeInteger(version)
|
|
63
|
+
|| version < 1
|
|
64
|
+
) return false;
|
|
65
|
+
|
|
66
|
+
const cache = options.snapshotCache;
|
|
67
|
+
let snapshot = cache?.get(row.shared_resource_id);
|
|
68
|
+
if (snapshot === undefined) {
|
|
69
|
+
const replica = database.prepare(`
|
|
70
|
+
SELECT local_path, applied_version
|
|
71
|
+
FROM shared_resource_replicas
|
|
72
|
+
WHERE resource_id = ?
|
|
73
|
+
`).get(row.shared_resource_id);
|
|
74
|
+
try {
|
|
75
|
+
snapshot = (
|
|
76
|
+
replica?.local_path
|
|
77
|
+
&& Number.isSafeInteger(Number(replica.applied_version))
|
|
78
|
+
) ? require('../workspace/project-stream').readSnapshot(
|
|
79
|
+
replica.local_path,
|
|
80
|
+
row.shared_resource_id,
|
|
81
|
+
) : null;
|
|
82
|
+
if (snapshot && snapshot.version !== Number(replica.applied_version)) {
|
|
83
|
+
snapshot = null;
|
|
84
|
+
}
|
|
85
|
+
} catch {
|
|
86
|
+
snapshot = null;
|
|
87
|
+
}
|
|
88
|
+
cache?.set(row.shared_resource_id, snapshot);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (
|
|
92
|
+
!snapshot
|
|
93
|
+
|| snapshot.version < version
|
|
94
|
+
) return false;
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* A local code outbox row may leave only after another durable local fact can
|
|
100
|
+
* finish recovery: either the folded intent still names it, or the verified
|
|
101
|
+
* physical repo has already advanced through it.
|
|
102
|
+
*/
|
|
103
|
+
function codeProjectLocalRecoveryIsDurable(row) {
|
|
104
|
+
if (row.mutation_origin !== 'local') return true;
|
|
105
|
+
const project = require('../workspace/wall').projectForResource(row.shared_resource_id);
|
|
106
|
+
if (!project) return false;
|
|
107
|
+
const intent = require('../workspace/intent').readIntent(project);
|
|
108
|
+
if (
|
|
109
|
+
intent?.publication?.mutationId === row.mutation_id
|
|
110
|
+
&& intent.publication.numberedVersion === Number(row.official_cloud_version)
|
|
111
|
+
&& typeof intent.publication.foldedAt === 'string'
|
|
112
|
+
) return true;
|
|
113
|
+
const state = require('../workspace/reducer').readRepoState(
|
|
114
|
+
project.repoKey,
|
|
115
|
+
project.resourceId,
|
|
116
|
+
);
|
|
117
|
+
return state?.materialized === true
|
|
118
|
+
&& Number.isSafeInteger(state.appliedThrough)
|
|
119
|
+
&& state.appliedThrough >= Number(row.official_cloud_version);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function mutationMayPrune(row, options = {}) {
|
|
123
|
+
if (row.contract !== CODE_PROJECT_CONTRACT) return true;
|
|
124
|
+
return codeProjectOrderIsDurable(row, options)
|
|
125
|
+
&& codeProjectLocalRecoveryIsDurable(row);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function mutationNeedsOfficialMaterialization(contract) {
|
|
129
|
+
return contract === CODE_PROJECT_CONTRACT;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Some locally materialized contracts still need their own numbered echo to
|
|
134
|
+
* move the official floor. They may not let generic acknowledgement logic
|
|
135
|
+
* mark the row projected or advance the cursor merely because local bytes
|
|
136
|
+
* already resemble the event.
|
|
137
|
+
*/
|
|
138
|
+
function mutationNeedsOrderedEcho(contract) {
|
|
139
|
+
return contract === CODE_PROJECT_CONTRACT || contract === WORKSPACE_TREE_CONTRACT;
|
|
140
|
+
}
|
|
141
|
+
|
|
50
142
|
module.exports = {
|
|
143
|
+
CODE_PROJECT_CONTRACT,
|
|
51
144
|
COOKIE_CONTRACT,
|
|
145
|
+
WORKSPACE_TREE_CONTRACT,
|
|
146
|
+
codeProjectLocalRecoveryIsDurable,
|
|
147
|
+
codeProjectOrderIsDurable,
|
|
52
148
|
diagnosticOperation,
|
|
53
149
|
isSensitiveContract,
|
|
150
|
+
mutationMayPrune,
|
|
151
|
+
mutationNeedsOfficialMaterialization,
|
|
152
|
+
mutationNeedsOrderedEcho,
|
|
54
153
|
protectOperation,
|
|
55
154
|
revealOperation,
|
|
56
155
|
};
|