mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-03 03:36:57 +01:00
fix(runner): persist native process ownership
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
78291feeb5
commit
cceda34670
12 files changed
+182
-18
No files matched your search
@@ -4,12 +4,13 @@ import type { NativeExecutionInputV1 } from "@paperclipai/paperclip-runner";
|
||||
|
||||
const state = vi.hoisted(() => ({
|
||||
execute: vi.fn(),
|
||||
createBackend: vi.fn(() => ({ kind: "test" })),
|
||||
cancel: vi.fn(),
|
||||
release: null as null | (() => void),
|
||||
}));
|
||||
|
||||
vi.mock("@paperclipai/paperclip-runner", () => ({
|
||||
createCodexNativeSessionBackend: vi.fn(() => ({ kind: "test" })),
|
||||
createCodexNativeSessionBackend: state.createBackend,
|
||||
executeNativeSession: state.execute,
|
||||
}));
|
||||
|
||||
@@ -141,3 +142,46 @@ describe("native session bounded recovery", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("native process ownership", () => {
|
||||
it("forwards the app-server PID and process group through the production backend seam", async () => {
|
||||
const processMetadata = {
|
||||
pid: 42_001,
|
||||
processGroupId: 42_001,
|
||||
startedAt: "2026-08-18T18:00:00.000Z",
|
||||
};
|
||||
const onSpawn = vi.fn(async () => undefined);
|
||||
state.createBackend.mockClear();
|
||||
state.execute.mockReset().mockImplementation(async (options) => {
|
||||
await options.backend.onSpawn(processMetadata);
|
||||
return {
|
||||
result: { summary: "completed" },
|
||||
terminal: { runTerminalState: "succeeded" },
|
||||
turnId: "turn",
|
||||
normalizedSessionId: "session",
|
||||
providerSessionId: null,
|
||||
driverKind: "test",
|
||||
driverVersion: "1",
|
||||
nativeEventCount: 1,
|
||||
highestContiguousSourceSeq: 1,
|
||||
};
|
||||
});
|
||||
state.createBackend.mockImplementationOnce((_input, options) => ({
|
||||
kind: "test",
|
||||
onSpawn: options.onSpawn,
|
||||
}));
|
||||
|
||||
await executePaperclipNativeSession({
|
||||
db: leaseDb(),
|
||||
execution,
|
||||
runnerInstanceId: "runner",
|
||||
onSpawn,
|
||||
});
|
||||
|
||||
expect(state.createBackend).toHaveBeenCalledWith(execution, {
|
||||
runnerInstanceId: "runner",
|
||||
onSpawn,
|
||||
});
|
||||
expect(onSpawn).toHaveBeenCalledWith(processMetadata);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user