mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-27 11:20:42 +01:00
fix(runtime): retain unmatched active services
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
0c0a450d88
commit
5339977206
3 files changed
+55
-1
No files matched your search
@@ -2599,6 +2599,13 @@ describeEmbeddedPostgres("executionWorkspaceService.getCloseReadiness", () => {
|
||||
providerRef: worktreePath,
|
||||
branchName: "feature/recorded",
|
||||
baseRef: "main",
|
||||
metadata: {
|
||||
config: {
|
||||
workspaceRuntime: {
|
||||
services: [{ name: "renamed-web", command: "pnpm renamed-dev" }],
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
await db.insert(workspaceRuntimeServices).values({
|
||||
id: runtimeServiceId,
|
||||
|
||||
@@ -91,6 +91,45 @@ describe("selectConfiguredRuntimeServiceRows", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it("retains unmatched active rows as reconciliation safety evidence", () => {
|
||||
const configuredWeb = runtimeServiceRow({
|
||||
serviceName: "web",
|
||||
command: "pnpm dev",
|
||||
});
|
||||
const removedActiveWorker = runtimeServiceRow({
|
||||
serviceName: "worker",
|
||||
command: "pnpm worker",
|
||||
status: "running",
|
||||
healthStatus: "healthy",
|
||||
});
|
||||
const removedStoppedJob = runtimeServiceRow({
|
||||
serviceName: "job",
|
||||
command: "pnpm job",
|
||||
status: "stopped",
|
||||
});
|
||||
|
||||
const selected = selectConfiguredRuntimeServiceRows(
|
||||
[removedActiveWorker, removedStoppedJob, configuredWeb],
|
||||
{ services: [{ name: "web", command: "pnpm dev" }] },
|
||||
"stopped",
|
||||
);
|
||||
|
||||
expect(selected).toEqual([
|
||||
expect.objectContaining({
|
||||
id: configuredWeb.id,
|
||||
configIndex: 0,
|
||||
desiredState: "stopped",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: removedActiveWorker.id,
|
||||
configIndex: null,
|
||||
workspaceCommandId: null,
|
||||
desiredState: null,
|
||||
status: "running",
|
||||
}),
|
||||
]);
|
||||
});
|
||||
|
||||
it("matches configured services only to rows with the configured reuse scope", () => {
|
||||
const staleProjectScopedWorker = runtimeServiceRow({
|
||||
serviceName: "worker",
|
||||
|
||||
@@ -9,6 +9,11 @@ import { and, desc, eq, inArray } from "drizzle-orm";
|
||||
|
||||
type WorkspaceRuntimeServiceRow = typeof workspaceRuntimeServices.$inferSelect;
|
||||
type RuntimeServiceReadDb = Pick<Db, "select">;
|
||||
const ACTIVE_RUNTIME_SERVICE_STATUSES = new Set<WorkspaceRuntimeServiceRow["status"]>([
|
||||
"provisioning",
|
||||
"starting",
|
||||
"running",
|
||||
]);
|
||||
|
||||
function runtimeServiceIdentityKey(row: WorkspaceRuntimeServiceRow) {
|
||||
if (row.reuseKey) return row.reuseKey;
|
||||
@@ -77,7 +82,10 @@ export function selectConfiguredRuntimeServiceRows(
|
||||
availableRows.splice(availableRows.indexOf(matchedRow), 1);
|
||||
}
|
||||
|
||||
return selectedRows;
|
||||
return [
|
||||
...selectedRows,
|
||||
...availableRows.filter((row) => ACTIVE_RUNTIME_SERVICE_STATUSES.has(row.status)),
|
||||
];
|
||||
}
|
||||
|
||||
export async function listCurrentRuntimeServicesForProjectWorkspaces(
|
||||
|
||||
Reference in new issue
Block a user