amalgm 0.1.201 → 0.1.203

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.201",
3
+ "version": "0.1.203",
4
4
  "description": "Amalgm local computer runtime: login, MCP, chat, events, previews, and tunnels.",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,
@@ -28,6 +28,7 @@ const {
28
28
  hydrateRepo,
29
29
  localCardMayMaterialize,
30
30
  materializeRepo,
31
+ pathForRepo,
31
32
  readRepoState,
32
33
  reduceCheckpoint,
33
34
  reduceWall,
@@ -48,6 +49,11 @@ test('a materialized baseline can follow the rail without publishing an echo', (
48
49
  }), false);
49
50
  });
50
51
 
52
+ test('a hydration failure still has a project path before a local card exists', () => {
53
+ assert.equal(pathForRepo(undefined, { path: '/projects/fresh' }), '/projects/fresh');
54
+ assert.equal(pathForRepo({ path: '/projects/local' }, { path: '/projects/fresh' }), '/projects/local');
55
+ });
56
+
51
57
  test.after(() => {
52
58
  closeLocalDb();
53
59
  fs.rmSync(tempRoot, { recursive: true, force: true });
@@ -326,6 +326,15 @@ test('side branches keep one rail operation while the checked-out card advances'
326
326
 
327
327
  await run(repo, 'branch', branch);
328
328
  await refreshRepoCards();
329
+ const beforeMaterialization = getDocText(project.file);
330
+ const blocked = await require('../workspace/reducer').withMaterialization(
331
+ repoKey,
332
+ async () => publishWall(repoKey),
333
+ );
334
+ assert.equal(blocked.published, false);
335
+ assert.equal(blocked.reason, 'repo-materializing');
336
+ assert.equal(getDocText(project.file), beforeMaterialization);
337
+
329
338
  const created = publishWall(repoKey);
330
339
  assert.equal(created.published, true);
331
340
  let card = readWall(repoKey)[0].cards[0];
@@ -583,6 +583,10 @@ function localCardMayMaterialize(publishedCard, publication) {
583
583
  return Boolean(publishedCard) || publication?.reason === 'shared-state-covered';
584
584
  }
585
585
 
586
+ function pathForRepo(localCard, project) {
587
+ return localCard?.path || project?.path || null;
588
+ }
589
+
586
590
  async function runReducer() {
587
591
  service.counters.passes += 1;
588
592
  const startedAt = Date.now();
@@ -598,16 +602,17 @@ async function runReducer() {
598
602
  let moved = false;
599
603
  for (const [repoKey, plan] of plans) {
600
604
  let local = locals.get(repoKey);
605
+ const project = wall.projectForRepo(repoKey);
601
606
  if (!plan.card) continue;
602
607
  try {
603
608
  if (!local?.head?.oid) {
604
609
  const hydrated = await withMaterialization(
605
610
  repoKey,
606
- () => hydrateRepo(wall.projectForRepo(repoKey), plan),
611
+ () => hydrateRepo(project, plan),
607
612
  );
608
613
  service.repos.set(repoKey, {
609
614
  repoKey,
610
- path: wall.projectForRepo(repoKey)?.path || local?.path || null,
615
+ path: pathForRepo(local, project),
611
616
  ...hydrated,
612
617
  at: new Date().toISOString(),
613
618
  });
@@ -655,15 +660,16 @@ async function runReducer() {
655
660
  service.counters.materialized += 1;
656
661
  }
657
662
  } catch (error) {
663
+ const repoPath = pathForRepo(local, project);
658
664
  service.counters.failures += 1;
659
665
  service.repos.set(repoKey, {
660
666
  repoKey,
661
- path: local.path,
667
+ path: repoPath,
662
668
  state: 'error',
663
669
  reason: error.message,
664
670
  at: new Date().toISOString(),
665
671
  });
666
- console.warn(`[WorkspaceReducer] ${local.path}:`, error.message);
672
+ console.warn(`[WorkspaceReducer] ${repoPath || repoKey}:`, error.message);
667
673
  }
668
674
  }
669
675
  service.lastPass = { at: new Date().toISOString(), durationMs: Date.now() - startedAt, moved };
@@ -741,6 +747,7 @@ module.exports = {
741
747
  isMaterializing,
742
748
  localCardMayMaterialize,
743
749
  materializeRepo,
750
+ pathForRepo,
744
751
  readRepoState,
745
752
  reduceCheckpoint,
746
753
  reduceNow,
@@ -473,6 +473,10 @@ function publishProject(project, rawCards) {
473
473
  service.counters.publishSkips += 1;
474
474
  return { published: false, reason: 'project-not-bound', repoKey: project.repoKey };
475
475
  }
476
+ if (require('./reducer').isMaterializing(project.repoKey)) {
477
+ service.counters.publishSkips += 1;
478
+ return { published: false, reason: 'repo-materializing', repoKey: project.repoKey };
479
+ }
476
480
  const docs = require('../state/docs');
477
481
  let current = docs.getDocText(project.file);
478
482
  let previous = null;