fix: bootstrap registry on first workspace list

This commit is contained in:
2026-08-05 16:49:56 +02:00
parent b93f13e39e
commit 840db9bd4f
3 changed files with 49 additions and 0 deletions
+6
View File
@@ -155,6 +155,12 @@ export class WorkspaceRegistry {
}
async list(): Promise<WorkspaceRevision[]> {
const active = await this.tryActiveState();
if (active) return active.revisions;
// A clean installation has no active snapshot until the first registry operation. Keep
// this lazy so health/startup remain available when Git is temporarily unreachable, while
// still refusing corrupted existing state (tryActiveState throws instead of returning none).
await this.bootstrap();
return (await this.activeState()).revisions;
}
+15
View File
@@ -254,6 +254,21 @@ test("bootstraps a checkout and activates a validated immutable snapshot", async
});
});
test("first list lazily bootstraps a clean registry", async () => {
const remote = await fixture();
const root = join(remote.root, "registry");
const registry = new WorkspaceRegistry(config(root, remote.remote));
await expect(registry.list()).resolves.toEqual([
expect.objectContaining({
id: "psd-clinical",
commit: remote.initialCommit,
state: "operational",
}),
]);
expect(existsSync(join(root, "state", "active.json"))).toBe(true);
});
test("publishes create, update, and delete with the configured Git author identity", async () => {
const remote = await fixture();
const registry = new WorkspaceRegistry(config(join(remote.root, "registry"), remote.remote, {