amalgm 0.1.245 → 0.1.246

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 (157) hide show
  1. package/README.md +12 -0
  2. package/lib/cli.js +146 -8
  3. package/lib/layout.js +89 -4
  4. package/lib/shared-realtime-tunnel.js +384 -43
  5. package/lib/supervisor.js +0 -3
  6. package/package.json +2 -2
  7. package/runtime/scripts/amalgm-mcp/adapters/contract.js +197 -0
  8. package/runtime/scripts/amalgm-mcp/adapters/filesystem.js +135 -0
  9. package/runtime/scripts/amalgm-mcp/adapters/git.js +84 -0
  10. package/runtime/scripts/amalgm-mcp/adapters/index.js +43 -0
  11. package/runtime/scripts/amalgm-mcp/adapters/reference.js +31 -0
  12. package/runtime/scripts/amalgm-mcp/adapters/truth.js +19 -0
  13. package/runtime/scripts/amalgm-mcp/browser/cookie-jar.js +20 -68
  14. package/runtime/scripts/amalgm-mcp/index.js +4 -0
  15. package/runtime/scripts/amalgm-mcp/lib/layout.js +89 -4
  16. package/runtime/scripts/amalgm-mcp/observer/README.md +259 -0
  17. package/runtime/scripts/amalgm-mcp/observer/apply.js +150 -0
  18. package/runtime/scripts/amalgm-mcp/observer/continuity.js +111 -0
  19. package/runtime/scripts/amalgm-mcp/observer/edges.js +111 -0
  20. package/runtime/scripts/amalgm-mcp/observer/index.js +1146 -0
  21. package/runtime/scripts/amalgm-mcp/observer/scan.js +387 -0
  22. package/runtime/scripts/amalgm-mcp/observer/store.js +262 -0
  23. package/runtime/scripts/amalgm-mcp/observer/verify.js +200 -0
  24. package/runtime/scripts/amalgm-mcp/observer/watch.js +62 -0
  25. package/runtime/scripts/amalgm-mcp/project-context/store.js +19 -87
  26. package/runtime/scripts/amalgm-mcp/registration/classify.js +33 -0
  27. package/runtime/scripts/amalgm-mcp/registration/entity-cloud.js +456 -0
  28. package/runtime/scripts/amalgm-mcp/registration/entity-content.js +345 -0
  29. package/runtime/scripts/amalgm-mcp/registration/index.js +752 -0
  30. package/runtime/scripts/amalgm-mcp/registration/refusal.js +42 -0
  31. package/runtime/scripts/amalgm-mcp/registration/repo-followers.js +127 -0
  32. package/runtime/scripts/amalgm-mcp/registration/repo-states.js +109 -0
  33. package/runtime/scripts/amalgm-mcp/registration/service.js +310 -0
  34. package/runtime/scripts/amalgm-mcp/registration/tree.js +178 -0
  35. package/runtime/scripts/amalgm-mcp/registry/evidence.js +826 -0
  36. package/runtime/scripts/amalgm-mcp/registry/index.js +666 -0
  37. package/runtime/scripts/amalgm-mcp/registry/store.js +290 -0
  38. package/runtime/scripts/amalgm-mcp/repocard/README.md +103 -0
  39. package/runtime/scripts/amalgm-mcp/repocard/apply.js +111 -0
  40. package/runtime/scripts/amalgm-mcp/repocard/capture-worker.js +94 -0
  41. package/runtime/scripts/amalgm-mcp/repocard/capture.js +149 -0
  42. package/runtime/scripts/amalgm-mcp/repocard/follow.js +310 -0
  43. package/runtime/scripts/amalgm-mcp/repocard/git.js +48 -0
  44. package/runtime/scripts/amalgm-mcp/repocard/index.js +48 -0
  45. package/runtime/scripts/amalgm-mcp/server/local-service-router.js +2 -0
  46. package/runtime/scripts/amalgm-mcp/server/routes/entities.js +287 -0
  47. package/runtime/scripts/amalgm-mcp/server/routes/state.js +0 -13
  48. package/runtime/scripts/amalgm-mcp/state/attachments.js +11 -45
  49. package/runtime/scripts/amalgm-mcp/state/db.js +46 -215
  50. package/runtime/scripts/amalgm-mcp/state/docs.js +301 -1101
  51. package/runtime/scripts/amalgm-mcp/state/mutation-contracts.js +0 -99
  52. package/runtime/scripts/amalgm-mcp/state/mutations.js +130 -507
  53. package/runtime/scripts/amalgm-mcp/state/promotions.js +1 -21
  54. package/runtime/scripts/amalgm-mcp/state/replicas.js +13 -134
  55. package/runtime/scripts/amalgm-mcp/state/shared-rest.js +3 -46
  56. package/runtime/scripts/amalgm-mcp/tests/adapters.test.js +379 -0
  57. package/runtime/scripts/amalgm-mcp/tests/browser-cookie-cloud.test.js +0 -193
  58. package/runtime/scripts/amalgm-mcp/tests/doorbell.matrix.life.test.js +449 -0
  59. package/runtime/scripts/amalgm-mcp/tests/doorbell.matrix.rig.js +107 -0
  60. package/runtime/scripts/amalgm-mcp/tests/doorbell.matrix.watch.test.js +213 -0
  61. package/runtime/scripts/amalgm-mcp/tests/entity-oracle/adapter.js +72 -0
  62. package/runtime/scripts/amalgm-mcp/tests/entity-oracle/assert.js +497 -0
  63. package/runtime/scripts/amalgm-mcp/tests/entity-oracle/bind.js +91 -0
  64. package/runtime/scripts/amalgm-mcp/tests/entity-oracle/graph.js +1031 -0
  65. package/runtime/scripts/amalgm-mcp/tests/entity-oracle/ledger.js +234 -0
  66. package/runtime/scripts/amalgm-mcp/tests/entity-oracle/referee.js +118 -0
  67. package/runtime/scripts/amalgm-mcp/tests/entity.oracle.test.js +1365 -0
  68. package/runtime/scripts/amalgm-mcp/tests/entity.registry.test.js +967 -0
  69. package/runtime/scripts/amalgm-mcp/tests/entity.rig.js +239 -0
  70. package/runtime/scripts/amalgm-mcp/tests/entity.storm.test.js +486 -0
  71. package/runtime/scripts/amalgm-mcp/tests/fake-watch.js +35 -0
  72. package/runtime/scripts/amalgm-mcp/tests/observer.links.test.js +289 -0
  73. package/runtime/scripts/amalgm-mcp/tests/observer.rig.js +103 -0
  74. package/runtime/scripts/amalgm-mcp/tests/observer.roots.test.js +505 -0
  75. package/runtime/scripts/amalgm-mcp/tests/observer.storm.test.js +389 -0
  76. package/runtime/scripts/amalgm-mcp/tests/observer.territory.test.js +845 -0
  77. package/runtime/scripts/amalgm-mcp/tests/observer.test.js +657 -0
  78. package/runtime/scripts/amalgm-mcp/tests/project-context.test.js +17 -32
  79. package/runtime/scripts/amalgm-mcp/tests/registration.service.test.js +256 -0
  80. package/runtime/scripts/amalgm-mcp/tests/registration.test.js +931 -0
  81. package/runtime/scripts/amalgm-mcp/tests/repocard.storm.test.js +284 -0
  82. package/runtime/scripts/amalgm-mcp/tests/repocard.test.js +371 -0
  83. package/runtime/scripts/amalgm-mcp/tests/repofollow.storm.test.js +435 -0
  84. package/runtime/scripts/amalgm-mcp/tests/repofollow.test.js +675 -0
  85. package/runtime/scripts/amalgm-mcp/tests/shared-tunnel-rehydration.test.js +0 -84
  86. package/runtime/scripts/amalgm-mcp/tests/state-docs.test.js +13 -376
  87. package/runtime/scripts/amalgm-mcp/tests/state-mutations.test.js +0 -309
  88. package/runtime/scripts/amalgm-mcp/tests/state-shared-replica.test.js +30 -758
  89. package/runtime/scripts/amalgm-mcp/tests/workspace-cards-store.test.js +3 -72
  90. package/runtime/scripts/amalgm-mcp/tests/workspace-cards.test.js +1 -89
  91. package/runtime/scripts/amalgm-mcp/tests/workspace-checkpoint-reducer.test.js +24 -55
  92. package/runtime/scripts/amalgm-mcp/tests/workspace-checkpoint.test.js +141 -424
  93. package/runtime/scripts/amalgm-mcp/tests/workspace-object-tunnel.test.js +3 -171
  94. package/runtime/scripts/amalgm-mcp/tests/workspace-objects.test.js +7 -220
  95. package/runtime/scripts/amalgm-mcp/tests/workspace-publication-invariants.test.js +236 -179
  96. package/runtime/scripts/amalgm-mcp/tests/workspace-reducer.test.js +326 -2228
  97. package/runtime/scripts/amalgm-mcp/tests/workspace-tree-cloud.test.js +3 -5319
  98. package/runtime/scripts/amalgm-mcp/tests/workspace-tree-core.test.js +1 -191
  99. package/runtime/scripts/amalgm-mcp/tests/workspace-tree-store.test.js +17 -3140
  100. package/runtime/scripts/amalgm-mcp/tests/workspace-wall.test.js +740 -137
  101. package/runtime/scripts/amalgm-mcp/workspace/access-store.js +1 -5
  102. package/runtime/scripts/amalgm-mcp/workspace/card.js +11 -35
  103. package/runtime/scripts/amalgm-mcp/workspace/cards.js +14 -39
  104. package/runtime/scripts/amalgm-mcp/workspace/checkpoint.js +147 -587
  105. package/runtime/scripts/amalgm-mcp/workspace/git.js +34 -406
  106. package/runtime/scripts/amalgm-mcp/workspace/merge.js +181 -102
  107. package/runtime/scripts/amalgm-mcp/workspace/objects.js +56 -221
  108. package/runtime/scripts/amalgm-mcp/workspace/reducer.js +538 -1964
  109. package/runtime/scripts/amalgm-mcp/workspace/rest.js +28 -49
  110. package/runtime/scripts/amalgm-mcp/workspace/store.js +4 -77
  111. package/runtime/scripts/amalgm-mcp/workspace/transition.js +192 -1734
  112. package/runtime/scripts/amalgm-mcp/workspace/tree/inclusion.js +1 -7
  113. package/runtime/scripts/amalgm-mcp/workspace/tree/local-state.js +61 -73
  114. package/runtime/scripts/amalgm-mcp/workspace/tree/reducer.js +6 -51
  115. package/runtime/scripts/amalgm-mcp/workspace/tree/snapshot.js +8 -79
  116. package/runtime/scripts/amalgm-mcp/workspace/tree-cloud.js +146 -3461
  117. package/runtime/scripts/amalgm-mcp/workspace/tree-store.js +71 -899
  118. package/runtime/scripts/amalgm-mcp/workspace/wall.js +538 -370
  119. package/runtime/scripts/local-gateway.js +1 -0
  120. package/runtime/scripts/amalgm-mcp/state/doc-disk.js +0 -550
  121. package/runtime/scripts/amalgm-mcp/tests/code-project-stream.test.js +0 -399
  122. package/runtime/scripts/amalgm-mcp/tests/fixtures/code-project-stream-v2.json +0 -1
  123. package/runtime/scripts/amalgm-mcp/tests/workspace-durable.test.js +0 -24
  124. package/runtime/scripts/amalgm-mcp/tests/workspace-local-intent.test.js +0 -1999
  125. package/runtime/scripts/amalgm-mcp/tests/workspace-native-file-transaction.test.js +0 -364
  126. package/runtime/scripts/amalgm-mcp/tests/workspace-provenance.test.js +0 -185
  127. package/runtime/scripts/amalgm-mcp/tests/workspace-reducer-liveness.test.js +0 -26
  128. package/runtime/scripts/amalgm-mcp/tests/workspace-sync-stats.test.js +0 -119
  129. package/runtime/scripts/amalgm-mcp/tests/workspace-transition.test.js +0 -1446
  130. package/runtime/scripts/amalgm-mcp/workspace/content.js +0 -32
  131. package/runtime/scripts/amalgm-mcp/workspace/durable.js +0 -45
  132. package/runtime/scripts/amalgm-mcp/workspace/intent.js +0 -535
  133. package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/BUILD.md +0 -31
  134. package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/bin/darwin-arm64/amalgm-file-transaction +0 -0
  135. package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/bin/linux-x64/amalgm-file-transaction +0 -0
  136. package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/build.mjs +0 -72
  137. package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/client.js +0 -165
  138. package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/go.mod +0 -5
  139. package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/go.sum +0 -2
  140. package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/main.go +0 -2201
  141. package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/manifest.json +0 -19
  142. package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/move_darwin.go +0 -18
  143. package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/move_linux.go +0 -18
  144. package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/process_darwin.go +0 -33
  145. package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/process_linux.go +0 -47
  146. package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/verify.mjs +0 -43
  147. package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/writers_darwin.go +0 -114
  148. package/runtime/scripts/amalgm-mcp/workspace/native-file-transaction/writers_linux.go +0 -84
  149. package/runtime/scripts/amalgm-mcp/workspace/project-stream.js +0 -771
  150. package/runtime/scripts/amalgm-mcp/workspace/provenance.js +0 -240
  151. package/runtime/scripts/amalgm-mcp/workspace/sync-stats.js +0 -240
  152. package/runtime/scripts/amalgm-mcp/workspace/tree/floor.js +0 -100
  153. package/runtime/scripts/amalgm-mcp/workspace/tree/observation-holds.js +0 -127
  154. package/runtime/scripts/amalgm-mcp/workspace/tree/path-state.js +0 -12
  155. package/runtime/scripts/amalgm-mcp/workspace/tree/root-binding.js +0 -125
  156. package/runtime/scripts/amalgm-mcp/workspace/tree/symlinks.js +0 -76
  157. package/runtime/scripts/amalgm-mcp/workspace/tree-materialization.js +0 -3766
@@ -1,72 +0,0 @@
1
- import crypto from 'node:crypto';
2
- import fs from 'node:fs';
3
- import path from 'node:path';
4
- import { spawnSync } from 'node:child_process';
5
- import { fileURLToPath } from 'node:url';
6
-
7
- const root = path.dirname(fileURLToPath(import.meta.url));
8
- const sources = fs.readdirSync(root)
9
- .filter((name) => name.endsWith('.go') || name === 'go.mod' || name === 'go.sum')
10
- .sort();
11
- const platforms = [
12
- { directory: 'darwin-arm64', goos: 'darwin', goarch: 'arm64', cgo: '1' },
13
- { directory: 'linux-x64', goos: 'linux', goarch: 'amd64', cgo: '0' },
14
- ];
15
-
16
- function digestFiles(names) {
17
- const hash = crypto.createHash('sha256');
18
- for (const name of names) {
19
- hash.update(name);
20
- hash.update('\0');
21
- hash.update(fs.readFileSync(path.join(root, name)));
22
- hash.update('\0');
23
- }
24
- return hash.digest('hex');
25
- }
26
-
27
- function run(command, args, env = {}) {
28
- const result = spawnSync(command, args, {
29
- cwd: root,
30
- env: { ...process.env, ...env },
31
- stdio: 'inherit',
32
- });
33
- if (result.error) throw result.error;
34
- if (result.status !== 0) {
35
- throw new Error(`${command} exited ${result.status}`);
36
- }
37
- }
38
-
39
- run('go', ['test', './...']);
40
- const binaries = {};
41
- for (const platform of platforms) {
42
- const directory = path.join(root, 'bin', platform.directory);
43
- fs.mkdirSync(directory, { recursive: true });
44
- const output = path.join(directory, 'amalgm-file-transaction');
45
- run('go', [
46
- 'build',
47
- '-trimpath',
48
- '-ldflags=-s -w',
49
- '-o',
50
- output,
51
- '.',
52
- ], {
53
- GOOS: platform.goos,
54
- GOARCH: platform.goarch,
55
- CGO_ENABLED: platform.cgo,
56
- });
57
- fs.chmodSync(output, 0o755);
58
- binaries[platform.directory] = crypto
59
- .createHash('sha256')
60
- .update(fs.readFileSync(output))
61
- .digest('hex');
62
- }
63
-
64
- fs.writeFileSync(
65
- path.join(root, 'manifest.json'),
66
- `${JSON.stringify({
67
- contract: 'amalgm-native-file-transaction-build@1',
68
- sourceSha256: digestFiles(sources),
69
- sources,
70
- binaries,
71
- }, null, 2)}\n`,
72
- );
@@ -1,165 +0,0 @@
1
- 'use strict';
2
-
3
- const fs = require('fs');
4
- const path = require('path');
5
- const { execFileSync } = require('child_process');
6
-
7
- function executable() {
8
- const platform = `${process.platform}-${process.arch}`;
9
- if (!['darwin-arm64', 'linux-x64'].includes(platform)) {
10
- throw new Error(`native file transactions do not support ${platform}`);
11
- }
12
- const file = path.join(
13
- __dirname,
14
- 'bin',
15
- platform,
16
- 'amalgm-file-transaction',
17
- );
18
- if (!fs.existsSync(file)) {
19
- throw new Error(`native file transaction helper is missing for ${platform}`);
20
- }
21
- return file;
22
- }
23
-
24
- function run(transaction, action, content = null, testHooks = {}) {
25
- const target = transaction.target == null
26
- ? null
27
- : {
28
- ...transaction.target,
29
- ...(content === null ? {} : { content: content.toString('base64') }),
30
- };
31
- let stdout;
32
- try {
33
- stdout = execFileSync(executable(), [], {
34
- input: JSON.stringify({
35
- action,
36
- ...(transaction.backend ? { backend: transaction.backend } : {}),
37
- ...(transaction.pid ? { pid: transaction.pid } : {}),
38
- ...(transaction.root ? {
39
- root: transaction.root,
40
- rootDev: transaction.rootDev,
41
- rootIno: transaction.rootIno,
42
- ...(transaction.source ? { source: transaction.source } : {}),
43
- ...(transaction.sourceIdentity
44
- ? { sourceIdentity: transaction.sourceIdentity }
45
- : {}),
46
- ...(transaction.sourceParentIdentity
47
- ? { sourceParentIdentity: transaction.sourceParentIdentity }
48
- : {}),
49
- ...(transaction.targetParentIdentity
50
- ? { targetParentIdentity: transaction.targetParentIdentity }
51
- : {}),
52
- path: transaction.path,
53
- id: transaction.id,
54
- operation: transaction.operation,
55
- expected: transaction.expected,
56
- target,
57
- } : {}),
58
- ...(testHooks.pauseAfterParentOpen > 0
59
- ? { testPauseAfterParentOpenMillis: testHooks.pauseAfterParentOpen }
60
- : {}),
61
- ...(testHooks.pauseAfterExtraction > 0
62
- ? { testPauseAfterExtractionMillis: testHooks.pauseAfterExtraction }
63
- : {}),
64
- ...(testHooks.pauseBeforeInstall > 0
65
- ? { testPauseBeforeInstallMillis: testHooks.pauseBeforeInstall }
66
- : {}),
67
- ...(testHooks.pauseAfterTreeMove > 0
68
- ? { testPauseAfterTreeMoveMillis: testHooks.pauseAfterTreeMove }
69
- : {}),
70
- ...(testHooks.crashAfterExtraction === true
71
- ? { testCrashAfterExtraction: true }
72
- : {}),
73
- ...(testHooks.crashBeforeInstall === true
74
- ? { testCrashBeforeInstall: true }
75
- : {}),
76
- ...(testHooks.crashAfterInstall === true
77
- ? { testCrashAfterInstall: true }
78
- : {}),
79
- ...(testHooks.crashAfterTreeMove === true
80
- ? { testCrashAfterTreeMove: true }
81
- : {}),
82
- }),
83
- encoding: 'utf8',
84
- maxBuffer: action === 'observe' ? 32 * 1024 * 1024 : 1024 * 1024,
85
- timeout: transaction.backend === 'process-identity' ? 5_000 : 30_000,
86
- });
87
- } catch (error) {
88
- const detail = String(error.stdout || error.stderr || error.message).trim();
89
- throw new Error(`native file transaction failed: ${detail}`);
90
- }
91
- let result;
92
- try {
93
- result = JSON.parse(stdout);
94
- } catch (error) {
95
- throw new Error(`native file transaction returned invalid output: ${error.message}`);
96
- }
97
- if (![
98
- 'applied',
99
- 'changed',
100
- 'pending',
101
- 'crossed',
102
- 'not-crossed',
103
- 'released',
104
- 'guarded',
105
- 'identified',
106
- 'exited',
107
- 'observed',
108
- ].includes(result?.status)) {
109
- throw new Error(`native file transaction returned ${result?.status || 'no status'}`);
110
- }
111
- return result;
112
- }
113
-
114
- function observe(transaction, testHooks = {}) {
115
- return run({
116
- root: transaction.root,
117
- rootDev: transaction.rootDev,
118
- rootIno: transaction.rootIno,
119
- path: transaction.path,
120
- target: null,
121
- }, 'observe', null, testHooks);
122
- }
123
-
124
- function processLifetime(pid) {
125
- try {
126
- const result = run({
127
- backend: 'process-identity',
128
- pid,
129
- target: null,
130
- }, 'identity');
131
- if (result.status === 'exited') return { live: false, identity: null };
132
- if (result.status === 'identified' && typeof result.identity === 'string') {
133
- return { live: true, identity: result.identity };
134
- }
135
- return null;
136
- } catch {
137
- return null;
138
- }
139
- }
140
-
141
- function moveNoReplace(transaction, testHooks = {}) {
142
- return run({
143
- backend: 'tree-rename',
144
- root: transaction.root,
145
- rootDev: transaction.rootDev,
146
- rootIno: transaction.rootIno,
147
- source: transaction.source,
148
- sourceIdentity: transaction.sourceIdentity,
149
- sourceParentIdentity: transaction.sourceParentIdentity,
150
- targetParentIdentity: transaction.targetParentIdentity,
151
- path: transaction.path,
152
- id: transaction.id,
153
- operation: transaction.operation,
154
- expected: null,
155
- target: null,
156
- }, 'move', null, testHooks);
157
- }
158
-
159
- module.exports = {
160
- executable,
161
- moveNoReplace,
162
- observe,
163
- processLifetime,
164
- run,
165
- };
@@ -1,5 +0,0 @@
1
- module amalgm.ai/native-file-transaction
2
-
3
- go 1.25.0
4
-
5
- require golang.org/x/sys v0.42.0
@@ -1,2 +0,0 @@
1
- golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo=
2
- golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=