amalgm 0.1.248 → 0.1.249

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.248",
3
+ "version": "0.1.249",
4
4
  "description": "Amalgm local computer runtime: login, MCP, chat, events, previews, and tunnels.",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,
@@ -267,7 +267,11 @@ function createRegistrationService({
267
267
  const home = await bootstrapUserHome();
268
268
  const expected = new Map();
269
269
  for (const entry of [...home.roots, ...home.exactManaged]) {
270
- expected.set(entry.record.uuid, entry.record);
270
+ // `bootstrapUserHome` returns the public record used by the local
271
+ // registration boundary. The cloud proof must instead compare its
272
+ // complete logical form, including the null payload head carried by
273
+ // containers, with the registry's sync representation.
274
+ expected.set(entry.record.uuid, boundary.current.registry.syncRecord(entry.record.uuid));
271
275
  }
272
276
  const records = boundary.current.registry.syncRecords();
273
277
  if (records.length !== expected.size) {
@@ -147,19 +147,18 @@ async function handleEntityRoutes(ctx) {
147
147
  const service = registrationService();
148
148
  try {
149
149
  const existing = service.entityCloud.replica();
150
- let bootstrapRecords = null;
150
+ let requiresBootstrapProof = existing?.state === 'reconciling-bootstrap';
151
151
  try {
152
152
  const snapshot = JSON.parse(Buffer.from(String(body?.snapshotBase64 || ''), 'base64').toString('utf8'));
153
- if (
154
- existing?.state === 'reconciling-bootstrap'
155
- || (Number(body?.headVersion) === 0 && Array.isArray(snapshot?.records) && snapshot.records.length === 0)
156
- ) {
157
- bootstrapRecords = await service.exactUserHomeCloudRecords();
158
- }
153
+ requiresBootstrapProof ||= Number(body?.headVersion) === 0
154
+ && Array.isArray(snapshot?.records) && snapshot.records.length === 0;
159
155
  } catch {
160
- // install performs the authoritative checksum and shape validation;
161
- // this lookahead only decides whether exact bootstrap proof is needed.
156
+ // Install validates malformed snapshots. This lookahead merely decides
157
+ // whether the legacy empty-resource repair needs its exact local proof.
162
158
  }
159
+ const bootstrapRecords = requiresBootstrapProof
160
+ ? await service.exactUserHomeCloudRecords()
161
+ : null;
163
162
  ctx.sendJson(200, service.entityCloud.install({
164
163
  registry: service.registration.registry,
165
164
  resourceId: body?.resourceId,
@@ -217,6 +217,14 @@ test('user-home bootstrap creates only declared roots and registers them through
217
217
  }
218
218
  }
219
219
 
220
+ const cloudRecords = await service.exactUserHomeCloudRecords();
221
+ assert.equal(cloudRecords.length, 9,
222
+ 'the declared home is the entire graph eligible to repair a legacy empty cloud registry');
223
+ assert.deepEqual(
224
+ new Set(cloudRecords.map((record) => record.uuid)),
225
+ new Set([...bootstrapped.roots, ...bootstrapped.exactManaged].map((entry) => entry.record.uuid)),
226
+ );
227
+
220
228
  const repeat = await service.bootstrapUserHome();
221
229
  assert.deepEqual(
222
230
  repeat.roots.map((entry) => entry.record.uuid),