mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-08 21:03:51 +02:00
Reject malformed stock-harness context snapshots
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
7084416945
commit
de0965984f
2 files changed
+15
-1
No files matched your search
@@ -153,11 +153,24 @@ describe("stock harness Product E2E", () => {
|
||||
.rejects.toThrow("Public API unavailable");
|
||||
});
|
||||
|
||||
it("normalizes an omitted conversationMode only from a complete scoped task snapshot", async () => {
|
||||
const api = { async get<T>(url: string): Promise<T> {
|
||||
return (url.endsWith("/instructions-bundle") ? { entryFile: "AGENTS.md", files: [] }
|
||||
: url.endsWith("/heartbeat-runs/run") ? { id: "run", companyId: "company", agentId: "agent", contextSnapshot: { taskId: "task", issueId: "task" } }
|
||||
: url.includes("/events?") ? [{ eventType: "adapter.invoke", payload: { prompt: "Task context", promptMetrics: { heartbeatPromptChars: 1 } } }]
|
||||
: { budgetMonthlyCents: 1000 }) as T;
|
||||
} };
|
||||
const result = await captureStockHarness({ api, companyId: "company", agentId: "agent", generation: "legacy", runIds: ["run"] });
|
||||
expect(result.invocations[0]?.conversationMode).toBe(false);
|
||||
});
|
||||
|
||||
it.each([
|
||||
{ id: "other", companyId: "company", agentId: "agent", contextSnapshot: {} },
|
||||
{ id: "run", companyId: "other", agentId: "agent", contextSnapshot: {} },
|
||||
{ id: "run", companyId: "company", agentId: "other", contextSnapshot: {} },
|
||||
{ id: "run", companyId: "company", agentId: "agent" },
|
||||
{ id: "run", companyId: "company", agentId: "agent", contextSnapshot: "invalid" },
|
||||
{ id: "run", companyId: "company", agentId: "agent", contextSnapshot: [] },
|
||||
{ id: "run", companyId: "company", agentId: "agent", contextSnapshot: { conversationMode: "unknown" } },
|
||||
])("rejects missing or mismatched public invocation mode attribution %#", async run => {
|
||||
const api = { async get<T>(url: string): Promise<T> {
|
||||
|
||||
@@ -138,7 +138,8 @@ export async function captureStockHarness(input: {
|
||||
),
|
||||
})));
|
||||
if (events.some(({ runId, run }) => run.id !== runId || run.companyId !== input.companyId || run.agentId !== input.agentId ||
|
||||
!run.contextSnapshot || (run.contextSnapshot.conversationMode !== undefined && typeof run.contextSnapshot.conversationMode !== "boolean"))) {
|
||||
!run.contextSnapshot || typeof run.contextSnapshot !== "object" || Array.isArray(run.contextSnapshot) ||
|
||||
(run.contextSnapshot.conversationMode !== undefined && typeof run.contextSnapshot.conversationMode !== "boolean"))) {
|
||||
throw new Error("Stock invocation mode receipt is missing or bound to a different run/company/agent.");
|
||||
}
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user