amalgm 0.1.187 → 0.1.188

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "amalgm",
3
- "version": "0.1.187",
3
+ "version": "0.1.188",
4
4
  "description": "Amalgm local computer runtime: login, MCP, chat, events, previews, and tunnels.",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,
@@ -341,7 +341,7 @@ function commitDocMutation(Y, entry, { mutationId, update, bytes }, source) {
341
341
  localResource: entry.resource,
342
342
  sharedResourceId: replica?.resourceId,
343
343
  mutationId,
344
- deviceId: replica ? process.env.AMALGM_DEVICE_ID : null,
344
+ deviceId: replica ? require('../workspace/identity').machineId() : null,
345
345
  authorityEpoch: replica?.authorityEpoch || 0,
346
346
  baseCloudVersion: replica?.appliedVersion || 0,
347
347
  contract: replica?.contract || 'text-yjs@1',
@@ -248,7 +248,7 @@ function acknowledgePromotion(promotionIdInput, acknowledgement, options = {}) {
248
248
  `).run(
249
249
  `resource:${replica.resourceId}`,
250
250
  replica.resourceId,
251
- process.env.AMALGM_DEVICE_ID || null,
251
+ require('../workspace/identity').machineId(),
252
252
  replica.authorityEpoch,
253
253
  replica.snapshotVersion,
254
254
  now,
@@ -8,6 +8,7 @@ const path = require('path');
8
8
 
9
9
  const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'amalgm-shared-replica-test-'));
10
10
  process.env.AMALGM_DIR = path.join(tempRoot, '.amalgm');
11
+ process.env.AMALGM_COMPUTER_ID = 'computer-shared-replica-test';
11
12
  process.env.AMALGM_DEVICE_ID = 'device-shared-replica-test';
12
13
  process.env.AMALGM_EVENT_LOG_PRUNE_INTERVAL_MS = '0';
13
14
 
@@ -142,6 +143,10 @@ test('batched surface edits retain separate IDs/versions and recipient file prec
142
143
  'mut_shared_batch_001',
143
144
  'mut_shared_batch_002',
144
145
  ]);
146
+ assert.deepEqual(claims.map((claim) => claim.envelope.deviceId), [
147
+ process.env.AMALGM_COMPUTER_ID,
148
+ process.env.AMALGM_COMPUTER_ID,
149
+ ]);
145
150
  acknowledgeCloudMutation(resourceId, 'mut_shared_batch_001', {
146
151
  version: 1,
147
152
  committedAt: '2026-07-14T20:00:00.000Z',
@@ -378,7 +383,7 @@ test('edits journaled during the promotion window are re-homed into the outbox',
378
383
  assert.equal(rehomed.sharedResourceId, fenceResourceId);
379
384
  assert.equal(rehomed.authorityEpoch, 1);
380
385
  assert.equal(rehomed.baseCloudVersion, 0);
381
- assert.equal(rehomed.deviceId, process.env.AMALGM_DEVICE_ID);
386
+ assert.equal(rehomed.deviceId, process.env.AMALGM_COMPUTER_ID);
382
387
  const claims = claimCloudMutations().filter((claim) => claim.envelope.resourceId === fenceResourceId);
383
388
  assert.deepEqual(claims.map((claim) => claim.envelope.mutationId), ['mut_during_promotion1']);
384
389
  });
@@ -128,7 +128,8 @@ test('a repo project carries exactly one line per machine, replaced in place', a
128
128
  committedAt: '2026-07-23T00:00:00.000Z',
129
129
  });
130
130
  const sealed = publishWall(repoKey);
131
- assert.equal(sealed.published, true);
131
+ assert.equal(sealed.published, false);
132
+ assert.equal(sealed.reason, 'unchanged');
132
133
  const sealedCard = readWall(repoKey)[0].cards[0];
133
134
  assert.equal(sealedCard.positionMutationId, first.mutationId);
134
135
  assert.equal(sealedCard.positionVersion, 1);
@@ -176,7 +177,7 @@ test('checkpoint transitions append until the next card and carry their official
176
177
  committedAt: '2026-07-23T00:00:02.000Z',
177
178
  });
178
179
  assert.equal(readWall(repoKey)[0].cards[0].checkpoints[0].version, 2);
179
- assert.equal(publishWall(repoKey).published, true);
180
+ assert.equal(publishWall(repoKey).published, false);
180
181
 
181
182
  fs.writeFileSync(file, `${JSON.stringify({
182
183
  ...firstCheckpoint,
@@ -372,7 +372,7 @@ function commitTreeOperation(input, options = {}) {
372
372
  localResource,
373
373
  sharedResourceId: replica?.resourceId,
374
374
  mutationId,
375
- deviceId: replica ? process.env.AMALGM_DEVICE_ID : null,
375
+ deviceId: replica ? require('./identity').machineId() : null,
376
376
  authorityEpoch: replica?.authorityEpoch || 0,
377
377
  baseCloudVersion: replica?.appliedVersion || 0,
378
378
  contract: 'workspace-tree@1',
@@ -249,15 +249,11 @@ function stampBranches(refs, previousBranches, mutationId, resourceId) {
249
249
  && before.mutationId
250
250
  && (validVersion(before.version) || knownMutation(resourceId, before.mutationId));
251
251
  const mutation = reusable ? before.mutationId : mutationId;
252
- const version = reusable
253
- ? (validVersion(before.version) ? before.version : officialVersion(resourceId, mutation))
254
- : null;
255
252
  return {
256
253
  name,
257
254
  oid,
258
255
  ...(observed?.objects ? { objects: observed.objects } : {}),
259
256
  mutationId: mutation,
260
- ...(validVersion(version) ? { version } : {}),
261
257
  };
262
258
  });
263
259
  }
@@ -294,15 +290,8 @@ function stampCards(cards, previousCards, mutationId, project) {
294
290
  && (
295
291
  validVersion(previous.positionVersion)
296
292
  || knownMutation(project.resourceId, previous.positionMutationId)
297
- );
293
+ );
298
294
  const positionMutationId = reusablePosition ? previous.positionMutationId : mutationId;
299
- const positionVersion = reusablePosition
300
- ? (
301
- validVersion(previous.positionVersion)
302
- ? previous.positionVersion
303
- : officialVersion(project.resourceId, positionMutationId)
304
- )
305
- : null;
306
295
  const checkpoint = readCheckpoint(machineId(), project.repoKey);
307
296
  const currentCheckpoint = checkpoint
308
297
  && checkpoint.baseOid === card.head?.oid
@@ -312,12 +301,7 @@ function stampCards(cards, previousCards, mutationId, project) {
312
301
  const sameBase = previous?.head?.oid === card.head?.oid
313
302
  && previous?.head?.branch === card.head?.branch;
314
303
  const history = sameBase && Array.isArray(previous?.checkpoints)
315
- ? previous.checkpoints.map((entry) => {
316
- const version = validVersion(entry.version)
317
- ? entry.version
318
- : officialVersion(project.resourceId, entry.mutationId);
319
- return validVersion(version) ? { ...entry, version } : entry;
320
- })
304
+ ? previous.checkpoints.map(({ version: _version, ...entry }) => entry)
321
305
  : [];
322
306
  const last = history.at(-1);
323
307
  const checkpoints = currentCheckpoint
@@ -328,7 +312,6 @@ function stampCards(cards, previousCards, mutationId, project) {
328
312
  return {
329
313
  ...sharedCard(card),
330
314
  positionMutationId,
331
- ...(validVersion(positionVersion) ? { positionVersion } : {}),
332
315
  branches: stampBranches(
333
316
  card.refs,
334
317
  sameBase ? previous?.branches : [],