Merge origin/master runtime service extraction

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip committed 2026-10-12 10:43:34 -05:00
commit e7d07f00a3
9 files changed
+405 -168

No files matched your search

+3
View File
@@ -34,4 +34,7 @@ state survives reload. Source edits remain intact and ignored private files are
not copied. The worker also verifies that persisted task context contains the
assignment, the full and compact prompt variants, and the description revision.
Screenshots and failure traces go to `test-results/workspace-bootstrap`.
The successful worker also requests a real ephemeral runtime service over HTTP.
The browser checks its persisted URL and readiness notice, then verifies that
the listener stops after run cleanup.
Stop test-drive with Ctrl-C. Its disposable data directory remains for inspection.
@@ -81,6 +81,12 @@ for (const persistent of [false, true]) {
expect(completedRun.lastOutputSeq).toBeGreaterThan(0);
expect(completedRun.lastOutputBytes).toBe(completedRun.logBytes);
expect(completedLog.content).toContain("Workspace recovery verification complete.");
const [runtimeService] = completedRun.contextSnapshot.paperclipRuntimeServices;
expect(runtimeService).toMatchObject({ serviceName: "fixture-web", companyId: fixture.companyId, provider: "local_process" });
const comments = await api(`/issues/${task.id}/comments`);
expect(comments.some((comment: { body: string }) => comment.body.includes("## Workspace Ready") && comment.body.includes(runtimeService.url))).toBe(true);
// Run status precedes final cleanup; wait for the owned ephemeral listener to stop.
await expect.poll(async () => fetch(runtimeService.url, { signal: AbortSignal.timeout(2_000) }).then(() => true, () => false)).toBe(false);
expect(await readFile(path.join(fixture.source, "README.md"), "utf8")).toBe("Existing uncommitted work\n");
}
await page.reload();
@@ -0,0 +1,5 @@
import { createServer } from "node:http";
createServer((_request, response) => {
response.end("workspace runtime service ready");
}).listen(Number(process.env.PORT), "127.0.0.1");
+6 -1
View File
@@ -32,7 +32,12 @@ export async function seedWorkspaceBootstrap(base, persistent = false) {
await api(`/projects/${project.id}/workspaces`, "POST", { name: "Source copy", cwd: source, repoUrl: pathToFileURL(source).href, isPrimary: false });
const agent = await api(`/companies/${company.id}/agents`, "POST", {
name: `${persistent ? "Persistent failure worker" : "Recovery worker"} ${suffix}`, role: "engineer", adapterType: "process",
adapterConfig: { command: process.execPath, args: [path.resolve(import.meta.dirname, "worker.mjs")], cwd: source },
adapterConfig: { command: process.execPath, args: [path.resolve(import.meta.dirname, "worker.mjs")], cwd: source,
workspaceRuntime: { services: [{ name: "fixture-web", lifecycle: "ephemeral", stopPolicy: { type: "on_run_finish" },
command: `${JSON.stringify(process.execPath)} ${JSON.stringify(path.resolve(import.meta.dirname, "runtime-service.mjs"))}`,
port: { type: "auto" }, readiness: { type: "http", urlTemplate: "http://127.0.0.1:{{port}}", timeoutSec: 10, intervalMs: 100 },
}] },
},
runtimeConfig: { heartbeat: { enabled: false, wakeOnDemand: true } },
});
return { base, companyId: company.id, prefix: company.issuePrefix, projectId: project.id, agentId: agent.id, agentName: agent.name, projectName: project.name, source };
+5
View File
@@ -14,6 +14,11 @@ const api = async (route, method = "GET", body) => {
};
const run = await api(`/heartbeat-runs/${env.PAPERCLIP_RUN_ID}`);
assert.equal(run.contextSnapshot.paperclipEnvironment.driver, "local");
const services = run.contextSnapshot.paperclipRuntimeServices;
assert.equal(services.length, 1);
assert.equal(services[0].serviceName, "fixture-web");
assert.equal(run.contextSnapshot.paperclipRuntimePrimaryUrl, services[0].url);
assert.equal(await fetch(services[0].url).then(response => response.text()), "workspace runtime service ready");
const issueId = run.contextSnapshot.issueId;
const issue = await api(`/issues/${issueId}`);
assert.equal(run.contextSnapshot.paperclipIssue.id, issue.id);