amalgm 0.1.202 → 0.1.204
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
|
@@ -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 });
|
|
@@ -23,6 +23,7 @@ fs.writeFileSync(
|
|
|
23
23
|
);
|
|
24
24
|
|
|
25
25
|
const { closeLocalDb } = require('../state/db');
|
|
26
|
+
const { appendStateEvent } = require('../state/events');
|
|
26
27
|
const { acknowledgeCloudMutation } = require('../state/mutations');
|
|
27
28
|
const { registerReplica } = require('../state/replicas');
|
|
28
29
|
const { openDoc, getDocText, writeDocText } = require('../state/docs');
|
|
@@ -546,6 +547,20 @@ test('project stats name every project resource, binding, and publish counter',
|
|
|
546
547
|
assert.ok(stats.paths.includes(project.file));
|
|
547
548
|
});
|
|
548
549
|
|
|
550
|
+
test('ready repo objects wake the card publisher', async () => {
|
|
551
|
+
startWallService();
|
|
552
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
553
|
+
const before = wallStats();
|
|
554
|
+
appendStateEvent({ resource: 'repo-objects', op: 'update', id: 'ready-bundle' });
|
|
555
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
556
|
+
stopWallService();
|
|
557
|
+
const after = wallStats();
|
|
558
|
+
assert.ok(
|
|
559
|
+
after.publishes + after.publishSkips
|
|
560
|
+
> before.publishes + before.publishSkips,
|
|
561
|
+
);
|
|
562
|
+
});
|
|
563
|
+
|
|
549
564
|
test('a restarted wall publishes once even when the project is already attached', async () => {
|
|
550
565
|
const before = wallStats();
|
|
551
566
|
startWallService();
|
|
@@ -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(
|
|
611
|
+
() => hydrateRepo(project, plan),
|
|
607
612
|
);
|
|
608
613
|
service.repos.set(repoKey, {
|
|
609
614
|
repoKey,
|
|
610
|
-
path:
|
|
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:
|
|
667
|
+
path: repoPath,
|
|
662
668
|
state: 'error',
|
|
663
669
|
reason: error.message,
|
|
664
670
|
at: new Date().toISOString(),
|
|
665
671
|
});
|
|
666
|
-
console.warn(`[WorkspaceReducer] ${
|
|
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,
|