mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-02 02:30:43 +01:00
test(evals): verify historical startup and continuation separately
Bind public conversation mode to the actual run and require each task or chat carrier independently; valid startup cannot conceal missing resumed execution guidance. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
da529b7ec4
commit
7084416945
2 files changed
+74
-11
No files matched your search
@@ -15,8 +15,8 @@ function recording(generation: "legacy" | "native" = "legacy"): StockHarnessEvid
|
||||
bundle: { entryFile: "AGENTS.md", files: [{ path: "AGENTS.md", content: STOCK_HIRE_IDENTITY }] },
|
||||
runIds: ["fresh", "resumed"],
|
||||
invocations: generation === "native" ? [] : [
|
||||
{ runId: "fresh", prompt: "You are agent agent (QA).\nConnection tools:\nUse connections_search.\nCurrent assignment.", promptMetrics: { heartbeatPromptChars: 113 } },
|
||||
{ runId: "resumed", prompt: "Paperclip Resume Delta\nCurrent ordered comments.", promptMetrics: { heartbeatPromptChars: 0 } },
|
||||
{ runId: "fresh", conversationMode: false, prompt: "You are agent agent (QA).\nConnection tools:\nUse connections_search.\nCurrent assignment.", promptMetrics: { heartbeatPromptChars: 113 } },
|
||||
{ runId: "resumed", conversationMode: false, prompt: "## Paperclip Resume Delta\nCurrent ordered comments.", promptMetrics: { heartbeatPromptChars: 0 } },
|
||||
],
|
||||
};
|
||||
}
|
||||
@@ -73,17 +73,41 @@ describe("stock harness Product E2E", () => {
|
||||
const historical = classifyStockInstructionManual(readFileSync(new URL("fixtures/stock-harness/historical-default-agents.md", import.meta.url), "utf8"));
|
||||
const evidence = recording();
|
||||
evidence.bundle.files[0]!.content = historical.content;
|
||||
evidence.invocations[0]!.prompt += "\nExecution contract:";
|
||||
evidence.invocations[0]!.prompt += "\nExecution contract:\nFinal disposition checklist:";
|
||||
evidence.invocations[1]!.prompt += "\nExecution contract: take concrete action\na successful process exit or final response is not sufficient";
|
||||
expect(gradeSourceHarness(evidence, historical).every(check => check.passed)).toBe(true);
|
||||
expect(gradeSourceHarness(evidence, historical)).toContainEqual(expect.objectContaining({ id: "historical-generic-procedures-observed", passed: true }));
|
||||
expect(gradeSourceHarness(evidence, historical)).toContainEqual(expect.objectContaining({ id: "historical-continuation-contract", passed: true }));
|
||||
expect(gradeSourceHarness(evidence, reduced)).toContainEqual(expect.objectContaining({ id: "default-hire-bundle", passed: false }));
|
||||
evidence.invocations[0]!.prompt = "You are agent agent. Connection tools: connections_search";
|
||||
expect(gradeSourceHarness(evidence, historical)).toContainEqual(expect.objectContaining({ id: "historical-generic-procedures-observed", passed: false }));
|
||||
expect(gradeSourceHarness(evidence, historical)).toContainEqual(expect.objectContaining({ id: "historical-startup-contract", passed: false }));
|
||||
const current = readStockInstructionVariant();
|
||||
evidence.bundle.files[0]!.content = current.content;
|
||||
expect(gradeSourceHire(evidence).every(check => check.passed)).toBe(true);
|
||||
});
|
||||
|
||||
it("cannot use valid historical startup to conceal a missing task continuation or misclassified mode", () => {
|
||||
const historical = classifyStockInstructionManual(readFileSync(new URL("fixtures/stock-harness/historical-default-agents.md", import.meta.url), "utf8"));
|
||||
const evidence = recording();
|
||||
evidence.bundle.files[0]!.content = historical.content;
|
||||
evidence.invocations[0]!.prompt += "\nExecution contract:\nFinal disposition checklist:";
|
||||
expect(gradeSourceHarness(evidence, historical)).toContainEqual(expect.objectContaining({ id: "historical-startup-contract", passed: true }));
|
||||
expect(gradeSourceHarness(evidence, historical)).toContainEqual(expect.objectContaining({ id: "historical-continuation-contract", passed: false }));
|
||||
evidence.invocations[1]!.prompt += "\nExecution contract: take concrete action\na successful process exit or final response is not sufficient";
|
||||
delete evidence.invocations[1]!.conversationMode;
|
||||
expect(gradeSourceHarness(evidence, historical)).toContainEqual(expect.objectContaining({ id: "historical-invocation-classification", passed: false }));
|
||||
});
|
||||
|
||||
it("checks historical conversation startup and resume separately without injecting the task contract", () => {
|
||||
const historical = classifyStockInstructionManual(readFileSync(new URL("fixtures/stock-harness/historical-default-agents.md", import.meta.url), "utf8"));
|
||||
const evidence = recording();
|
||||
evidence.bundle.files[0]!.content = historical.content;
|
||||
for (const row of evidence.invocations) row.conversationMode = true;
|
||||
evidence.invocations[0]!.prompt += "\nContinue your Paperclip conversation using the supplied chat mode directive.\nAfter 2 consecutive failures of the same control-plane write";
|
||||
expect(gradeSourceHarness(evidence, historical).every(check => check.passed)).toBe(true);
|
||||
evidence.invocations[1]!.prompt += "\nExecution contract:";
|
||||
expect(gradeSourceHarness(evidence, historical)).toContainEqual(expect.objectContaining({ id: "historical-continuation-contract", passed: false }));
|
||||
});
|
||||
|
||||
it.each([
|
||||
["manual-regrew", (e: StockHarnessEvidence) => { e.bundle.files[0]!.content += "Always comment and delegate."; }, "default-hire-bundle"],
|
||||
["extra-file", (e: StockHarnessEvidence) => { e.bundle.files.push({ path: "HEARTBEAT.md", content: "Do everything again." }); }, "default-hire-bundle"],
|
||||
@@ -113,6 +137,7 @@ describe("stock harness Product E2E", () => {
|
||||
{ eventType: "adapter.invoke", payload: { prompt: "Actual prompt", promptMetrics: { heartbeatPromptChars: 10 } } },
|
||||
{ eventType: "assistant", payload: { prompt: "Model claims about instructions" } },
|
||||
] as T;
|
||||
if (url.endsWith("/heartbeat-runs/run")) return { id: "run", companyId: "company", agentId: "agent", contextSnapshot: { conversationMode: false } } as T;
|
||||
return { budgetMonthlyCents: 1_000 } as T;
|
||||
} };
|
||||
const evidence = await captureStockHarness({ api, companyId: "company", agentId: "agent", generation: "legacy", runIds: ["run"] });
|
||||
@@ -128,6 +153,21 @@ describe("stock harness Product E2E", () => {
|
||||
.rejects.toThrow("Public API unavailable");
|
||||
});
|
||||
|
||||
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: { conversationMode: "unknown" } },
|
||||
])("rejects missing or mismatched public invocation mode attribution %#", async run => {
|
||||
const api = { async get<T>(url: string): Promise<T> {
|
||||
return (url.endsWith("/instructions-bundle") ? { entryFile: "AGENTS.md", files: [] }
|
||||
: url.endsWith("/heartbeat-runs/run") ? run : url.includes("/events?") ? [] : { budgetMonthlyCents: 1000 }) as T;
|
||||
} };
|
||||
await expect(captureStockHarness({ api, companyId: "company", agentId: "agent", generation: "legacy", runIds: ["run"] }))
|
||||
.rejects.toThrow("mode receipt");
|
||||
});
|
||||
|
||||
it("changes the definition hash when the grader digest changes", () => {
|
||||
const suite = runnerMatrix.find(row => row.suite.id === "stock-harness")!.suite;
|
||||
expect(suiteDefinitionHash({ ...suite, definitionMetadata: { ...suite.definitionMetadata, sourceDigest: "changed" } }))
|
||||
|
||||
@@ -45,7 +45,7 @@ export interface StockHarnessEvidence {
|
||||
agentId: string;
|
||||
budgets: { companyMonthlyCents: unknown; agentMonthlyCents: unknown };
|
||||
bundle: { entryFile?: string; files: Array<{ path: string; content: string }> };
|
||||
invocations: Array<{ runId: string; prompt: unknown; promptMetrics?: Record<string, unknown> }>;
|
||||
invocations: Array<{ runId: string; prompt: unknown; promptMetrics?: Record<string, unknown>; conversationMode?: boolean }>;
|
||||
runIds: string[];
|
||||
}
|
||||
|
||||
@@ -79,9 +79,24 @@ export function gradeStockHarness(evidence: StockHarnessEvidence, instructionVar
|
||||
REMOVED_PROCEDURES.every(procedure => !String(row.prompt).includes(procedure))),
|
||||
"Neither startup nor continuation may reintroduce the removed generic manual.");
|
||||
} else {
|
||||
check("historical-generic-procedures-observed", prompts.length > 0 && prompts.some(row =>
|
||||
REMOVED_PROCEDURES.some(procedure => String(row.prompt).includes(procedure))),
|
||||
"Observe the historical instruction carrier separately from the identical task outcome oracle.");
|
||||
const classified = prompts.every(row => typeof row.conversationMode === "boolean" &&
|
||||
typeof row.promptMetrics?.heartbeatPromptChars === "number" &&
|
||||
Number.isFinite(row.promptMetrics.heartbeatPromptChars) && row.promptMetrics.heartbeatPromptChars >= 0);
|
||||
const fresh = prompts.filter(row => Number(row.promptMetrics?.heartbeatPromptChars) > 0);
|
||||
const resumed = prompts.filter(row => row.promptMetrics?.heartbeatPromptChars === 0);
|
||||
check("historical-invocation-classification", prompts.length > 0 && classified,
|
||||
"Every invocation needs public run-scoped conversation mode and explicit template-delivery metrics.");
|
||||
check("historical-startup-contract", classified && fresh.length > 0 && fresh.every(row => row.conversationMode
|
||||
? String(row.prompt).includes("Continue your Paperclip conversation using the supplied chat mode directive.") &&
|
||||
String(row.prompt).includes("After 2 consecutive failures of the same control-plane write")
|
||||
: String(row.prompt).includes("Execution contract:") && String(row.prompt).includes("Final disposition checklist:")),
|
||||
`Check each of ${fresh.length} fresh invocations against its historical task or conversation template.`);
|
||||
check("historical-continuation-contract", classified && resumed.every(row =>
|
||||
String(row.prompt).includes("## Paperclip Resume Delta") && (row.conversationMode
|
||||
? !String(row.prompt).includes("Execution contract:")
|
||||
: String(row.prompt).includes("Execution contract: take concrete action") &&
|
||||
String(row.prompt).includes("a successful process exit or final response is not sufficient"))),
|
||||
`Check all ${resumed.length} observed continuation invocations separately; zero observations do not claim live continuation coverage.`);
|
||||
}
|
||||
const fresh = prompts.filter(row => Number(row.promptMetrics?.heartbeatPromptChars) > 0);
|
||||
check("fresh-default-delivered", fresh.length > 0 && fresh.every(row =>
|
||||
@@ -115,16 +130,24 @@ export async function captureStockHarness(input: {
|
||||
}));
|
||||
const events = await Promise.all(input.runIds.map(async runId => ({
|
||||
runId,
|
||||
run: await input.api.get<{ id: string; companyId: string; agentId: string; contextSnapshot?: { conversationMode?: boolean } }>(
|
||||
`/api/heartbeat-runs/${runId}`,
|
||||
),
|
||||
rows: await input.api.get<Array<{ eventType?: string; payload?: Record<string, unknown> }>>(
|
||||
`/api/heartbeat-runs/${runId}/events?limit=1000`,
|
||||
),
|
||||
})));
|
||||
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"))) {
|
||||
throw new Error("Stock invocation mode receipt is missing or bound to a different run/company/agent.");
|
||||
}
|
||||
return {
|
||||
schema: "paperclip.stock-harness.v1", generation: input.generation,
|
||||
budgets: { companyMonthlyCents: company.budgetMonthlyCents, agentMonthlyCents: agent.budgetMonthlyCents },
|
||||
agentId: input.agentId, bundle: { entryFile: bundle.entryFile, files }, runIds: input.runIds,
|
||||
invocations: events.flatMap(({ runId, rows }) => rows.filter(row => row.eventType === "adapter.invoke")
|
||||
.map(row => ({ runId, prompt: row.payload?.prompt, promptMetrics: row.payload?.promptMetrics as Record<string, unknown> | undefined }))),
|
||||
invocations: events.flatMap(({ runId, rows, run }) => rows.filter(row => row.eventType === "adapter.invoke")
|
||||
.map(row => ({ runId, prompt: row.payload?.prompt, promptMetrics: row.payload?.promptMetrics as Record<string, unknown> | undefined,
|
||||
conversationMode: run.contextSnapshot?.conversationMode === true }))),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user