amalgm 0.1.239 → 0.1.241

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 (87) hide show
  1. package/lib/shared-realtime-tunnel.js +18 -4
  2. package/package.json +1 -1
  3. package/runtime/scripts/amalgm-mcp/browser/cookie-jar.js +68 -20
  4. package/runtime/scripts/amalgm-mcp/project-context/store.js +87 -19
  5. package/runtime/scripts/amalgm-mcp/server/routes/state.js +13 -0
  6. package/runtime/scripts/amalgm-mcp/state/attachments.js +40 -12
  7. package/runtime/scripts/amalgm-mcp/state/db.js +216 -17
  8. package/runtime/scripts/amalgm-mcp/state/doc-disk.js +550 -0
  9. package/runtime/scripts/amalgm-mcp/state/docs.js +1101 -301
  10. package/runtime/scripts/amalgm-mcp/state/mutation-contracts.js +99 -0
  11. package/runtime/scripts/amalgm-mcp/state/mutations.js +507 -130
  12. package/runtime/scripts/amalgm-mcp/state/promotions.js +21 -1
  13. package/runtime/scripts/amalgm-mcp/state/replicas.js +134 -13
  14. package/runtime/scripts/amalgm-mcp/state/shared-rest.js +14 -8
  15. package/runtime/scripts/amalgm-mcp/tests/browser-cookie-cloud.test.js +193 -0
  16. package/runtime/scripts/amalgm-mcp/tests/code-project-stream.test.js +313 -94
  17. package/runtime/scripts/amalgm-mcp/tests/fixtures/code-project-stream-v2.json +1 -0
  18. package/runtime/scripts/amalgm-mcp/tests/project-context.test.js +32 -17
  19. package/runtime/scripts/amalgm-mcp/tests/shared-tunnel-rehydration.test.js +84 -0
  20. package/runtime/scripts/amalgm-mcp/tests/state-docs.test.js +376 -13
  21. package/runtime/scripts/amalgm-mcp/tests/state-mutations.test.js +309 -0
  22. package/runtime/scripts/amalgm-mcp/tests/state-shared-replica.test.js +758 -30
  23. package/runtime/scripts/amalgm-mcp/tests/workspace-cards-store.test.js +72 -3
  24. package/runtime/scripts/amalgm-mcp/tests/workspace-cards.test.js +33 -6
  25. package/runtime/scripts/amalgm-mcp/tests/workspace-checkpoint-reducer.test.js +27 -0
  26. package/runtime/scripts/amalgm-mcp/tests/workspace-checkpoint.test.js +334 -191
  27. package/runtime/scripts/amalgm-mcp/tests/workspace-durable.test.js +24 -0
  28. package/runtime/scripts/amalgm-mcp/tests/workspace-local-intent.test.js +1999 -0
  29. package/runtime/scripts/amalgm-mcp/tests/workspace-native-file-transaction.test.js +364 -0
  30. package/runtime/scripts/amalgm-mcp/tests/workspace-object-tunnel.test.js +98 -4
  31. package/runtime/scripts/amalgm-mcp/tests/workspace-objects.test.js +156 -8
  32. package/runtime/scripts/amalgm-mcp/tests/workspace-provenance.test.js +185 -0
  33. package/runtime/scripts/amalgm-mcp/tests/workspace-publication-invariants.test.js +174 -269
  34. package/runtime/scripts/amalgm-mcp/tests/workspace-reducer-liveness.test.js +26 -0
  35. package/runtime/scripts/amalgm-mcp/tests/workspace-reducer.test.js +2060 -407
  36. package/runtime/scripts/amalgm-mcp/tests/workspace-sync-stats.test.js +119 -0
  37. package/runtime/scripts/amalgm-mcp/tests/workspace-transition.test.js +1446 -0
  38. package/runtime/scripts/amalgm-mcp/tests/workspace-tree-cloud.test.js +5319 -3
  39. package/runtime/scripts/amalgm-mcp/tests/workspace-tree-core.test.js +191 -1
  40. package/runtime/scripts/amalgm-mcp/tests/workspace-tree-store.test.js +3140 -17
  41. package/runtime/scripts/amalgm-mcp/tests/workspace-wall.test.js +135 -637
  42. package/runtime/scripts/amalgm-mcp/workspace/access-store.js +5 -1
  43. package/runtime/scripts/amalgm-mcp/workspace/card.js +7 -7
  44. package/runtime/scripts/amalgm-mcp/workspace/cards.js +36 -12
  45. package/runtime/scripts/amalgm-mcp/workspace/checkpoint.js +436 -173
  46. package/runtime/scripts/amalgm-mcp/workspace/content.js +32 -0
  47. package/runtime/scripts/amalgm-mcp/workspace/durable.js +45 -0
  48. package/runtime/scripts/amalgm-mcp/workspace/git.js +391 -37
  49. package/runtime/scripts/amalgm-mcp/workspace/intent.js +535 -0
  50. package/runtime/scripts/amalgm-mcp/workspace/merge.js +89 -6
  51. package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/BUILD.md +31 -0
  52. package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/bin/darwin-arm64/amalgm-file-transaction +0 -0
  53. package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/bin/linux-x64/amalgm-file-transaction +0 -0
  54. package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/build.mjs +72 -0
  55. package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/client.js +165 -0
  56. package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/go.mod +5 -0
  57. package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/go.sum +2 -0
  58. package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/main.go +2201 -0
  59. package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/manifest.json +19 -0
  60. package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/move_darwin.go +18 -0
  61. package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/move_linux.go +18 -0
  62. package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/process_darwin.go +33 -0
  63. package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/process_linux.go +47 -0
  64. package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/verify.mjs +43 -0
  65. package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/writers_darwin.go +114 -0
  66. package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/writers_linux.go +84 -0
  67. package/runtime/scripts/amalgm-mcp/workspace/objects.js +185 -55
  68. package/runtime/scripts/amalgm-mcp/workspace/project-stream.js +616 -168
  69. package/runtime/scripts/amalgm-mcp/workspace/provenance.js +240 -0
  70. package/runtime/scripts/amalgm-mcp/workspace/reducer.js +1979 -570
  71. package/runtime/scripts/amalgm-mcp/workspace/rest.js +49 -28
  72. package/runtime/scripts/amalgm-mcp/workspace/store.js +77 -4
  73. package/runtime/scripts/amalgm-mcp/workspace/sync-stats.js +240 -0
  74. package/runtime/scripts/amalgm-mcp/workspace/transition.js +1729 -192
  75. package/runtime/scripts/amalgm-mcp/workspace/tree/floor.js +100 -0
  76. package/runtime/scripts/amalgm-mcp/workspace/tree/inclusion.js +7 -1
  77. package/runtime/scripts/amalgm-mcp/workspace/tree/local-state.js +73 -61
  78. package/runtime/scripts/amalgm-mcp/workspace/tree/observation-holds.js +127 -0
  79. package/runtime/scripts/amalgm-mcp/workspace/tree/path-state.js +12 -0
  80. package/runtime/scripts/amalgm-mcp/workspace/tree/reducer.js +51 -6
  81. package/runtime/scripts/amalgm-mcp/workspace/tree/root-binding.js +125 -0
  82. package/runtime/scripts/amalgm-mcp/workspace/tree/snapshot.js +79 -8
  83. package/runtime/scripts/amalgm-mcp/workspace/tree/symlinks.js +76 -0
  84. package/runtime/scripts/amalgm-mcp/workspace/tree-cloud.js +3480 -165
  85. package/runtime/scripts/amalgm-mcp/workspace/tree-materialization.js +3766 -0
  86. package/runtime/scripts/amalgm-mcp/workspace/tree-store.js +899 -71
  87. package/runtime/scripts/amalgm-mcp/workspace/wall.js +352 -497
@@ -0,0 +1,119 @@
1
+ 'use strict';
2
+
3
+ const assert = require('node:assert/strict');
4
+ const test = require('node:test');
5
+ const {
6
+ autoUpdateDisabled,
7
+ digest,
8
+ folderFor,
9
+ pendingIntentValue,
10
+ syncFingerprintFiles,
11
+ verificationFor,
12
+ } = require('../workspace/sync-stats')._test;
13
+
14
+ test('snapshot digest is content-derived rather than key-order-derived', () => {
15
+ assert.equal(
16
+ digest({ version: 7, records: [{ machine: 'm', cards: [] }] }),
17
+ digest({ records: [{ cards: [], machine: 'm' }], version: 7 }),
18
+ );
19
+ });
20
+
21
+ test('registered folder UUID and exact path identify the listening checkout', () => {
22
+ const project = { repoKey: 'repo', path: '/code/repo' };
23
+ const cards = [{
24
+ kind: 'primary',
25
+ path: '/wrong',
26
+ repo: { remote: 'repo' },
27
+ }];
28
+ const workspaces = [{ id: 'folder-uuid', path: '/code/repo' }];
29
+ assert.deepEqual(folderFor(project, cards, workspaces), {
30
+ card: cards[0],
31
+ folderPath: '/code/repo',
32
+ folderUuid: 'folder-uuid',
33
+ });
34
+ });
35
+
36
+ test('verification exposes one pending intent and named waits without hidden branches', () => {
37
+ const pendingIntent = {
38
+ baseThrough: 4,
39
+ semanticDigest: 'intent',
40
+ mutationId: null,
41
+ terminalCode: null,
42
+ };
43
+ const value = verificationFor({
44
+ verificationContract: 'verified-repo-state@1',
45
+ appliedThrough: 4,
46
+ materialized: false,
47
+ targetDigest: 'target',
48
+ expectedPhysicalDigest: 'expected',
49
+ observedPhysicalDigest: 'observed',
50
+ }, {
51
+ state: 'waiting',
52
+ reason: 'physical-state-mismatch',
53
+ }, pendingIntent);
54
+ assert.equal(value.appliedThrough, 4);
55
+ assert.equal(value.materialized, false);
56
+ assert.equal(value.pendingIntent, pendingIntent);
57
+ assert.equal(Object.hasOwn(value, 'pendingCard'), false);
58
+ assert.equal(Object.hasOwn(value, 'pendingRefs'), false);
59
+ assert.equal(Object.hasOwn(value, 'pendingCheckpoint'), false);
60
+ assert.deepEqual(value.waiting, [
61
+ { state: 'waiting', reason: 'physical-state-mismatch' },
62
+ ]);
63
+ });
64
+
65
+ test('verification keeps the open successor visible after its predecessor is numbered', () => {
66
+ assert.deepEqual(pendingIntentValue({
67
+ base: { through: 4 },
68
+ semanticDigest: 'predecessor',
69
+ publication: { mutationId: 'mutation-a' },
70
+ terminal: null,
71
+ successor: {
72
+ predecessorSemanticDigest: 'predecessor',
73
+ semanticDigest: 'successor',
74
+ terminal: null,
75
+ },
76
+ }, false), {
77
+ baseThrough: 4,
78
+ semanticDigest: 'predecessor',
79
+ mutationId: 'mutation-a',
80
+ terminalCode: null,
81
+ successor: {
82
+ predecessorSemanticDigest: 'predecessor',
83
+ semanticDigest: 'successor',
84
+ mutationId: null,
85
+ terminalCode: null,
86
+ },
87
+ });
88
+ });
89
+
90
+ test('auto-update state reflects only the runtime launch policy', () => {
91
+ assert.equal(autoUpdateDisabled({ AMALGM_DISABLE_AUTO_UPDATE: '1' }), true);
92
+ assert.equal(autoUpdateDisabled({ AMALGM_AUTO_UPDATE: 'off' }), true);
93
+ assert.equal(autoUpdateDisabled({ AMALGM_AUTO_UPDATE: '1' }), false);
94
+ });
95
+
96
+ test('the sync fingerprint follows the complete state and workspace trees', () => {
97
+ for (const file of [
98
+ 'state/doc-disk.js',
99
+ 'state/docs.js',
100
+ 'workspace/native-file-transaction/client.js',
101
+ 'workspace/native-file-transaction/main.go',
102
+ 'workspace/native-file-transaction/manifest.json',
103
+ 'workspace/transition.js',
104
+ ]) {
105
+ assert.ok(syncFingerprintFiles.includes(file), `${file} must be release-bound`);
106
+ }
107
+ assert.ok(
108
+ syncFingerprintFiles.some((file) => (
109
+ file === 'workspace/native-file-transaction/bin/darwin-arm64/amalgm-file-transaction'
110
+ )),
111
+ 'the Darwin helper must be release-bound',
112
+ );
113
+ assert.ok(
114
+ syncFingerprintFiles.some((file) => (
115
+ file === 'workspace/native-file-transaction/bin/linux-x64/amalgm-file-transaction'
116
+ )),
117
+ 'the Linux helper must be release-bound',
118
+ );
119
+ });