refactor workspace registry addressed API

This commit is contained in:
2026-08-11 21:46:01 +02:00
parent 1cc0b50446
commit e2fecf9953
10 changed files with 582 additions and 432 deletions
+20 -18
View File
@@ -36,16 +36,17 @@ function operationalWorkspace(id = "default") {
}
const defaultWorkspaceRegistry = {
list: vi.fn(async () => [{
id: "default", commit: "e".repeat(40), blob: "f".repeat(40),
snapshotPath: `/data/workspace-registry/snapshots/${"e".repeat(40)}/default.yaml`,
ensureBootstrapAddressed: vi.fn(async () => ({
kind: "already_active", snapshot: { schemaVersion: 1, commit: "e".repeat(40), manifestSha256: "a".repeat(64), workspaces: [{ workspaceId: "default", revision: "e".repeat(40), descriptorBlob: "f".repeat(40), manifestSha256: "b".repeat(64) }],
}})),
listRetainedSnapshots: vi.fn(async () => [{
id: "default", commit: "e".repeat(40), blob: "f".repeat(40), snapshotPath: `/data/workspace-registry/snapshots/${"e".repeat(40)}/default.yaml`,
}]),
readPinned: vi.fn(async (id: string, commit: string) => ({
workspace: operationalWorkspace(id), workspaceConfigPath: `/data/workspace-registry/snapshots/${commit}/${id}.yaml`,
})),
read: vi.fn(async (id: string) => ({
workspace: operationalWorkspace(id),
revision: {
id, commit: "e".repeat(40), blob: "f".repeat(40),
snapshotPath: `/data/workspace-registry/snapshots/${"e".repeat(40)}/${id}.yaml`,
},
workspace: operationalWorkspace(id), revision: { id, commit: "e".repeat(40), blob: "f".repeat(40), snapshotPath: `/data/workspace-registry/snapshots/${"e".repeat(40)}/${id}.yaml` },
})),
};
@@ -58,6 +59,8 @@ function buildApp(config: Parameters<typeof buildRealApp>[0], deps: Record<strin
...deps,
...(thtRunner ? { thtRunner } : {}),
workspaceRegistry: { ...defaultWorkspaceRegistry, ...(deps.workspaceRegistry as object | undefined) },
workspaceRegistryRecoveryIdentity: () => ({ operation: "registry_bootstrap", requestSha256: "c".repeat(64), installationIdentitySha256: "d".repeat(64), repositoryIdentitySha256: "e".repeat(64), remoteRefIdentitySha256: "f".repeat(64) }),
reconcileSnapshotRetention: (deps.reconcileSnapshotRetention as ((refs: readonly string[]) => Promise<void>) | undefined) ?? (async () => {}),
} as any);
}
@@ -288,7 +291,8 @@ test("an administrator session listing retains revisions referenced by resumable
{ id: "archived", status: "closed", archived: true, workspace_revision: "c".repeat(40) },
] }),
} as any,
workspaceRegistry: { reconcileSnapshotRetention: retained } as any,
reconcileSnapshotRetention: retained,
workspaceRegistry: {} as any,
});
const response = await app.inject({
@@ -317,11 +321,8 @@ test("retention scans a removed workspace's retained snapshot", async () => {
: [],
}),
} as any,
workspaceRegistry: {
list: async () => [{ id: "other", commit: "a".repeat(40), snapshotPath: activeSnapshot }],
listRetainedSnapshots,
reconcileSnapshotRetention: retained,
} as any,
reconcileSnapshotRetention: retained,
workspaceRegistry: { listRetainedSnapshots } as any,
});
const response = await app.inject({
@@ -342,7 +343,8 @@ test("the single local installation listing reconciles its resumable workspace p
thtRunner: {
sessionList: async () => [{ id: "open", status: "closed", archived: false, workspace_revision: retainedRevision }],
} as any,
workspaceRegistry: { reconcileSnapshotRetention: retained } as any,
reconcileSnapshotRetention: retained,
workspaceRegistry: {} as any,
});
const response = await app.inject({ method: "GET", url: "/sessions" });
@@ -676,7 +678,7 @@ test("session lifecycle locates a B session when installation default is A", asy
workspace: { llm_policy: { allowed: ["zai/glm-5.2"] } },
revision: { id, commit: "b".repeat(40), blob: "d".repeat(40), snapshotPath: bPath },
}),
list: async () => [
listRetainedSnapshots: async () => [
{ id: "a-workspace", commit: "a".repeat(40), blob: "a".repeat(40), snapshotPath: aPath },
{ id: "b-workspace", commit: "b".repeat(40), blob: "b".repeat(40), snapshotPath: bPath },
],
@@ -1069,7 +1071,7 @@ test("a pruned pin blocks Resume but not active or mutation lifecycle routes", a
},
} as any,
workspaceRegistry: {
list: async () => [{
listRetainedSnapshots: async () => [{
id: "b-workspace", commit: "a".repeat(40), blob: "a".repeat(40), snapshotPath: activePath,
}],
readPinned,
@@ -2296,7 +2298,7 @@ test("rename authorizes and mutates through the same registry snapshot", async (
}),
} as any,
workspaceRegistry: {
list: async () => [{
listRetainedSnapshots: async () => [{
id: "tenant-a", commit: "a".repeat(40), blob: "b".repeat(40), snapshotPath: tenantPath,
}],
} as any,