refactor: remove workspace revision state

This commit is contained in:
2026-08-10 20:54:40 +02:00
parent 512b0261b1
commit f102629cee
8 changed files with 292 additions and 314 deletions
+13 -16
View File
@@ -38,13 +38,13 @@ 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`, state: "operational",
snapshotPath: `/data/workspace-registry/snapshots/${"e".repeat(40)}/default.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`, state: "operational",
snapshotPath: `/data/workspace-registry/snapshots/${"e".repeat(40)}/${id}.yaml`,
},
})),
};
@@ -306,8 +306,8 @@ test("retention scans a removed workspace's retained snapshot", async () => {
const activeSnapshot = "/registry/snapshots/a/other.yaml";
const removedSnapshot = "/registry/snapshots/e/removed.yaml";
const listRetainedSnapshots = vi.fn(async () => [
{ id: "other", commit: "a".repeat(40), state: "operational", snapshotPath: activeSnapshot },
{ id: "removed", commit: removedRevision, state: "operational", snapshotPath: removedSnapshot },
{ id: "other", commit: "a".repeat(40), snapshotPath: activeSnapshot },
{ id: "removed", commit: removedRevision, snapshotPath: removedSnapshot },
]);
const app = buildApp(loadConfig({ AUTH_MODE: "upstream", THT_HARNESS_DIR: "../harness" }), {
thtRunner: {
@@ -318,7 +318,7 @@ test("retention scans a removed workspace's retained snapshot", async () => {
}),
} as any,
workspaceRegistry: {
list: async () => [{ id: "other", commit: "a".repeat(40), state: "operational", snapshotPath: activeSnapshot }],
list: async () => [{ id: "other", commit: "a".repeat(40), snapshotPath: activeSnapshot }],
listRetainedSnapshots,
reconcileSnapshotRetention: retained,
} as any,
@@ -472,7 +472,7 @@ test("creates a session from the active immutable workspace revision", async ()
},
revision: {
id: "psd-clinical", commit: "a".repeat(40), blob: "b".repeat(40),
snapshotPath: "/data/workspace-registry/snapshots/abc/psd-clinical.yaml", state: "operational",
snapshotPath: "/data/workspace-registry/snapshots/abc/psd-clinical.yaml",
},
})),
} as any,
@@ -524,7 +524,6 @@ test("rejects an SSH-only workspace before persisting or starting a session", as
revision: {
id: "ssh-workspace", commit: "a".repeat(40), blob: "b".repeat(40),
snapshotPath: `/data/workspace-registry/snapshots/${"a".repeat(40)}/ssh-workspace.yaml`,
state: "operational",
},
abort,
markPersisted,
@@ -552,7 +551,6 @@ test("hands a revision lease to retention only after the session manifest is dur
revision: {
id: "leased", commit: "a".repeat(40), blob: "b".repeat(40),
snapshotPath: `/data/workspace-registry/snapshots/${"a".repeat(40)}/leased.yaml`,
state: "operational",
},
markPersisted,
abort,
@@ -590,7 +588,7 @@ test("creates a session from the configured default workspace revision when work
workspace: { llm_policy: { allowed: ["zai/glm-5.2"] } },
revision: {
id, commit: "c".repeat(40), blob: "d".repeat(40),
snapshotPath: `/data/workspace-registry/snapshots/${"c".repeat(40)}/${id}.yaml`, state: "operational",
snapshotPath: `/data/workspace-registry/snapshots/${"c".repeat(40)}/${id}.yaml`,
},
})),
};
@@ -676,11 +674,11 @@ test("session lifecycle locates a B session when installation default is A", asy
workspaceRegistry: {
read: async (id: string) => ({
workspace: { llm_policy: { allowed: ["zai/glm-5.2"] } },
revision: { id, commit: "b".repeat(40), blob: "d".repeat(40), snapshotPath: bPath, state: "operational" },
revision: { id, commit: "b".repeat(40), blob: "d".repeat(40), snapshotPath: bPath },
}),
list: async () => [
{ id: "a-workspace", commit: "a".repeat(40), blob: "a".repeat(40), snapshotPath: aPath, state: "operational" },
{ id: "b-workspace", commit: "b".repeat(40), blob: "b".repeat(40), snapshotPath: bPath, state: "operational" },
{ 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 },
],
readPinned: vi.fn(async (id: string, revision: string) => {
expect([id, revision]).toEqual(["b-workspace", "c".repeat(40)]);
@@ -956,7 +954,7 @@ test("POST /sessions/:id/resume uses the manifest's retained workspace revision"
workspace: operationalWorkspace("psd-clinical"),
revision: {
id: "psd-clinical", commit: "a".repeat(40), blob: "b".repeat(40),
snapshotPath: "/data/workspace-registry/snapshots/aaaaaaaa/psd-clinical.yaml", state: "operational",
snapshotPath: "/data/workspace-registry/snapshots/aaaaaaaa/psd-clinical.yaml",
},
})),
} as any,
@@ -1072,7 +1070,7 @@ test("a pruned pin blocks Resume but not active or mutation lifecycle routes", a
} as any,
workspaceRegistry: {
list: async () => [{
id: "b-workspace", commit: "a".repeat(40), blob: "a".repeat(40), snapshotPath: activePath, state: "operational",
id: "b-workspace", commit: "a".repeat(40), blob: "a".repeat(40), snapshotPath: activePath,
}],
readPinned,
} as any,
@@ -2299,7 +2297,7 @@ test("rename authorizes and mutates through the same registry snapshot", async (
} as any,
workspaceRegistry: {
list: async () => [{
id: "tenant-a", commit: "a".repeat(40), blob: "b".repeat(40), snapshotPath: tenantPath, state: "operational",
id: "tenant-a", commit: "a".repeat(40), blob: "b".repeat(40), snapshotPath: tenantPath,
}],
} as any,
});
@@ -2861,7 +2859,6 @@ test.each([
const revision = {
id: "psd-clinical", commit: "a".repeat(40), blob: "b".repeat(40),
snapshotPath: `/data/workspace-registry/snapshots/${"a".repeat(40)}/psd-clinical.yaml`,
state: "operational" as const,
};
try {