mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-01 09:39:53 +01:00
Consolidate native completion constraints with matched eval gates
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
2a8a99e4a5
commit
20f26bad15
16 files changed
+456
-18
No files matched your search
@@ -424,6 +424,8 @@ pnpm test:e2e:runner -- --id agent-chat-hardening.runner-codex.local.stop-startu
|
||||
|
||||
The independent, explicit-only `native-completion` suite qualifies native finish/block descriptions on unchanged master defaults. It preserves the original assigned-skill document journey and pairs it with whole-task blocking across three native profiles, with enforced single attempts. See [NATIVE-COMPLETION.md](NATIVE-COMPLETION.md) for admission, provenance and limits.
|
||||
|
||||
The separate, explicit-only `native-instruction-consolidation` suite reuses those original tasks and strict graders to compare completion constraints on the production defaults at `2a8a99e4a5f69aa803b3f10b982f583e75a87042`. It declares six local cells: document completion and whole-task blocking on native Codex, ACPX Claude, and OpenCode. Each cell allows one attempt and applies a 1,000-cent company and agent budget hard stop. Its source gate rejects dirty, mixed, unknown, or unrelated source changes before credentials load. A provider-free fixture captures the complete Paperclip instruction/tool/message projection at the scripted runnerd RPC boundary on start and resume for native input v4 and v5. That capture measures bytes; it does not measure vendor-owned prompts, tokens, billing, or model behavior. See the [comparison plan](../../doc/plans/2026-10-03-native-completion-consolidation.md) for exact scope and live qualification limits. Existing `native-completion` results do not qualify this new reduction.
|
||||
|
||||
`context-integrity` is an explicit-only local suite with two bounded cases across
|
||||
ten listed legacy/native profiles (20 cells). Six cells are pending-prerequisite
|
||||
profiles and are listed for discovery but rejected before provider credentials are
|
||||
|
||||
@@ -136,10 +136,10 @@ describe("runner E2E catalog", () => {
|
||||
expect(localIntegrityTasks).toHaveLength(2);
|
||||
expect(openRouterBreadthTasks).toHaveLength(3);
|
||||
expect(runnerSuites.map((suite) => suite.expectedMatrixSize)).toEqual([
|
||||
6, 30, 3, 16, 16, 2, 6, 8, 46, 23, 50, 6, 20, 26, 52, 28, 18, 2, 6, 6, 12, 10, 48, 16, 10, 2, 1, 1,
|
||||
6, 30, 3, 16, 16, 2, 6, 8, 46, 23, 50, 6, 6, 20, 26, 52, 28, 18, 2, 6, 6, 12, 10, 48, 16, 10, 2, 1, 1,
|
||||
]);
|
||||
expect(validateRunnerCatalog()).toHaveLength(470);
|
||||
expect(new Set(runnerMatrix.map((entry) => entry.id)).size).toBe(470);
|
||||
expect(validateRunnerCatalog()).toHaveLength(476);
|
||||
expect(new Set(runnerMatrix.map((entry) => entry.id)).size).toBe(476);
|
||||
expect(
|
||||
runnerMatrix.filter((entry) => entry.suite.id === "core-compatibility"),
|
||||
).toHaveLength(48);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { nativeCompletionTasks, nativeCompletionDefinitionDigest } from "./native-completion-cases.js";
|
||||
import { NATIVE_INSTRUCTION_SUITE, NATIVE_INSTRUCTION_BASE_SHA, nativeInstructionDefinitionDigest } from "./native-instruction-consolidation.js";
|
||||
import { nativeCompletionProfile, NATIVE_COMPLETION_BUDGET_CENTS } from "./native-completion-defaults.js";
|
||||
import { chatConfirmationTasks } from "./chat-cases.js";
|
||||
import { hiringTemplateTasks, hiringTemplateProfile, hiringTemplateDefinitionDigest } from "./hiring-template-cases.js";
|
||||
@@ -1197,6 +1198,17 @@ export const runnerSuites: readonly RunnerSuiteFixture[] = [
|
||||
.map(task => `everyday-workflows.${profile.id}.daytona.${task.id}`))],
|
||||
definitionMetadata: { version: 4, instructions: "production", grading: "outcome-and-invariants", scheduling: "explicit-only" },
|
||||
},
|
||||
{
|
||||
id: NATIVE_INSTRUCTION_SUITE, label: "Native completion instruction consolidation", manualOnly: true,
|
||||
description: "Matched production-default durable-document and concrete-blocker checks for the completion constraint reduction.",
|
||||
groups: ["native", "local"],
|
||||
profiles: runnerProfiles.filter(profile => ["runner-codex", "runner-acpx-claude", "runner-opencode"].includes(profile.id)).map(nativeCompletionProfile),
|
||||
environments: [localEnvironment], tasks: nativeCompletionTasks, expectedMatrixSize: 6,
|
||||
definitionMetadata: { version: 1, fixtureDigest: nativeInstructionDefinitionDigest(), baseSha: NATIVE_INSTRUCTION_BASE_SHA,
|
||||
instructions: "production-default", maximumAttemptsPerCell: 1, automaticRetryPolicy: "single_attempt",
|
||||
budgetMonthlyCents: NATIVE_COMPLETION_BUDGET_CENTS, scheduling: "explicit-only",
|
||||
grading: "original-assigned-skill-and-strict-native-completion", },
|
||||
},
|
||||
{
|
||||
id: "native-completion", label: "Native completion guidance", manualOnly: true,
|
||||
description: "Production-default assigned-skill document completion and concrete whole-task blocking, with independent native result/final ordering.",
|
||||
|
||||
@@ -52,6 +52,7 @@ import {
|
||||
} from "./types.js";
|
||||
import { assertRunnerE2EPrerequisites } from "./prerequisites.js";
|
||||
import { assertNativeCompletionSelection, prepareNativeCompletionPreflight, NATIVE_COMPLETION_PREFLIGHT_ENV } from "./native-completion-admission.js";
|
||||
import { assertNativeInstructionSelection, prepareNativeInstructionPreflight, NATIVE_INSTRUCTION_PREFLIGHT_ENV, NATIVE_INSTRUCTION_SUITE } from "./native-instruction-consolidation.js";
|
||||
import { prepareStockHarnessPreflight, STOCK_PREFLIGHT_ENV } from "./stock-harness-admission.js";
|
||||
|
||||
import {
|
||||
@@ -1086,6 +1087,7 @@ async function main() {
|
||||
// profiles remain discoverable, but cannot reach a provider.
|
||||
assertRunnerE2EPrerequisites(executions);
|
||||
assertNativeCompletionSelection(executions);
|
||||
assertNativeInstructionSelection(executions);
|
||||
const campaignId = cleanId(
|
||||
process.env.PAPERCLIP_E2E_CAMPAIGN_ID ??
|
||||
`local-${new Date().toISOString().replace(/[:.]/g, "-")}`,
|
||||
@@ -1095,6 +1097,9 @@ async function main() {
|
||||
if (executions.some(execution => execution.suite.id === "native-completion")) {
|
||||
process.env[NATIVE_COMPLETION_PREFLIGHT_ENV] = prepareNativeCompletionPreflight(summaryDir);
|
||||
}
|
||||
if (executions.some(execution => execution.suite.id === NATIVE_INSTRUCTION_SUITE)) {
|
||||
process.env[NATIVE_INSTRUCTION_PREFLIGHT_ENV] = prepareNativeInstructionPreflight(summaryDir);
|
||||
}
|
||||
if (executions.some(execution => execution.suite.id === "stock-harness")) {
|
||||
process.env[STOCK_PREFLIGHT_ENV] = prepareStockHarnessPreflight(summaryDir);
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ export async function setupLiveFixtures(input: {
|
||||
return api.post<CompanyRecord>("/api/companies", {
|
||||
name: `Runner E2E ${execution.id} ${input.executionNonce}`,
|
||||
description: "Ephemeral paid full-stack runner acceptance fixture",
|
||||
budgetMonthlyCents: execution.suite.id === "native-completion" ? NATIVE_COMPLETION_BUDGET_CENTS
|
||||
budgetMonthlyCents: ["native-completion", "native-instruction-consolidation"].includes(execution.suite.id) ? NATIVE_COMPLETION_BUDGET_CENTS
|
||||
: execution.suite.id === "task-titles" ? TASK_TITLE_BUDGET_CENTS
|
||||
: execution.suite.id === "stock-harness" ? 1_000 : 0,
|
||||
});
|
||||
|
||||
@@ -40,12 +40,12 @@ export interface NativeDefaultReceipt {
|
||||
budgets: { company: unknown; agent: unknown };
|
||||
}
|
||||
|
||||
export function gradeNativeDefault(receipt: NativeDefaultReceipt) {
|
||||
export function gradeNativeDefault(receipt: NativeDefaultReceipt, expectedDefaultSha256 = NATIVE_MASTER_DEFAULT_SHA256) {
|
||||
const checks = [
|
||||
{ id: "production-default-bundle", passed: receipt.entryFile === "AGENTS.md"
|
||||
&& receipt.files.length === 1 && receipt.files[0]?.path === "AGENTS.md"
|
||||
&& receipt.files[0]?.sha256 === NATIVE_MASTER_DEFAULT_SHA256,
|
||||
detail: "The served public hire bundle is the unchanged master default, with no QA or reduced-manual injection." },
|
||||
&& receipt.files[0]?.sha256 === expectedDefaultSha256,
|
||||
detail: "The served public hire bundle matches the declared production default, with no fixture instruction injection." },
|
||||
{ id: "bounded-company-and-agent", passed: receipt.budgets.company === NATIVE_COMPLETION_BUDGET_CENTS
|
||||
&& receipt.budgets.agent === NATIVE_COMPLETION_BUDGET_CENTS,
|
||||
detail: "Both public budgets enforce the declared 1,000-cent hard stop." },
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
import { execFileSync } from "node:child_process";
|
||||
import { createHash } from "node:crypto";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { runnerSuites, buildRunnerMatrix } from "./catalog.js";
|
||||
import { gradeNativeDefault, NATIVE_MASTER_DEFAULT_SHA256 } from "./native-completion-defaults.js";
|
||||
import { nativeCompletionTasks } from "./native-completion-cases.js";
|
||||
import { assertNativeInstructionSelection, nativeInstructionVariant, validateNativeInstructionMeasurement, NATIVE_INSTRUCTION_BASE_SHA, NATIVE_INSTRUCTION_DEFAULT_SHA256, NATIVE_INSTRUCTION_SUITE, NATIVE_INSTRUCTION_VARIANTS } from "./native-instruction-consolidation.js";
|
||||
|
||||
describe("native instruction comparison admission", () => {
|
||||
it("accepts each complete source variant and rejects a mixed variant", () => {
|
||||
const files = Object.keys(NATIVE_INSTRUCTION_VARIANTS.baseline);
|
||||
const baseline = new Map(files.map(file => [file, execFileSync("git", ["show", `${NATIVE_INSTRUCTION_BASE_SHA}:${file}`])]));
|
||||
expect(nativeInstructionVariant(file => baseline.get(file)!)).toBe("baseline");
|
||||
const candidate = new Map(files.map(file => [file, readFileSync(new URL(`../../${file}`, import.meta.url))]));
|
||||
const currentVariant = nativeInstructionVariant(file => candidate.get(file)!);
|
||||
expect(["baseline", "candidate"]).toContain(currentVariant);
|
||||
candidate.set(files[0]!, currentVariant === "candidate" ? baseline.get(files[0]!)! : Buffer.from("unknown source"));
|
||||
expect(() => nativeInstructionVariant(file => candidate.get(file)!)).toThrow("Mixed or unknown");
|
||||
baseline.set(files[0]!, Buffer.from("unknown source"));
|
||||
expect(() => nativeInstructionVariant(file => baseline.get(file)!)).toThrow("Mixed or unknown");
|
||||
});
|
||||
|
||||
it("declares six explicit single-attempt cells with the original task prompts and oracle", () => {
|
||||
const suite = runnerSuites.find(value => value.id === NATIVE_INSTRUCTION_SUITE)!;
|
||||
expect(suite.tasks).toEqual(nativeCompletionTasks);
|
||||
expect(suite.manualOnly).toBe(true);
|
||||
expect(suite.environments.map(value => value.id)).toEqual(["local"]);
|
||||
const executions = buildRunnerMatrix([suite]);
|
||||
expect(executions).toHaveLength(6);
|
||||
expect(() => assertNativeInstructionSelection(executions)).not.toThrow();
|
||||
for (const execution of executions) {
|
||||
expect(execution.task.expectedRunCount).toBe(1);
|
||||
expect(execution.task.automaticRetryPolicy).toBe("single_attempt");
|
||||
expect(() => assertNativeInstructionSelection([{ ...execution, environment: { ...execution.environment, id: "daytona" } }])).toThrow();
|
||||
expect(() => assertNativeInstructionSelection([{ ...execution, task: { ...execution.task, automaticRetryPolicy: undefined } }])).toThrow();
|
||||
}
|
||||
});
|
||||
|
||||
it("uses the new common production default without qualifying old default evidence", () => {
|
||||
const receipt = { schema: "paperclip.native-completion-default.v1" as const, companyId: "company", agentId: "agent", entryFile: "AGENTS.md",
|
||||
files: [{ path: "AGENTS.md", sha256: NATIVE_INSTRUCTION_DEFAULT_SHA256, bytes: 40 }], budgets: { company: 1000, agent: 1000 } };
|
||||
expect(gradeNativeDefault(receipt, NATIVE_INSTRUCTION_DEFAULT_SHA256).passed).toBe(true);
|
||||
expect(gradeNativeDefault(receipt).passed).toBe(false);
|
||||
receipt.files[0]!.sha256 = NATIVE_MASTER_DEFAULT_SHA256;
|
||||
expect(gradeNativeDefault(receipt, NATIVE_INSTRUCTION_DEFAULT_SHA256).passed).toBe(false);
|
||||
receipt.files[0]!.sha256 = NATIVE_INSTRUCTION_DEFAULT_SHA256;
|
||||
receipt.budgets.company = 0;
|
||||
expect(gradeNativeDefault(receipt, NATIVE_INSTRUCTION_DEFAULT_SHA256).passed).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects duplicate or incomplete capture, dirty or paid source, and stale fixture evidence", () => {
|
||||
const measurement = {
|
||||
schema: "paperclip.native-instruction-measurement.v1", sourceSha: "frozen", sourceDirty: false, providerCalls: 0,
|
||||
fixtureSha256: createHash("sha256").update(readFileSync(new URL("../../packages/paperclip-runner/src/backends/native-instruction-measurement.test.ts", import.meta.url))).digest("hex"),
|
||||
sourceHashes: Object.fromEntries(Object.entries(NATIVE_INSTRUCTION_VARIANTS.baseline).map(([file, digest]) => [file.split('/').at(-1)!, digest])),
|
||||
receipts: ['codex', 'acpx', 'opencode'].flatMap(provider => ['v4', 'v5'].flatMap(schema => ['start', 'resume'].map(phase => ({ provider, schema, phase })))),
|
||||
};
|
||||
const source = { sourceSha: "frozen", variant: "baseline" };
|
||||
expect(() => validateNativeInstructionMeasurement(measurement, source)).not.toThrow();
|
||||
for (const invalid of [
|
||||
{ ...measurement, receipts: measurement.receipts.slice(1) },
|
||||
{ ...measurement, receipts: measurement.receipts.map(() => measurement.receipts[0]!) },
|
||||
{ ...measurement, sourceDirty: true }, { ...measurement, providerCalls: 1 },
|
||||
{ ...measurement, sourceSha: "other" }, { ...measurement, fixtureSha256: "stale" },
|
||||
{ ...measurement, sourceHashes: { ...measurement.sourceHashes, "runtime-context.ts": "wrong" } },
|
||||
]) expect(() => validateNativeInstructionMeasurement(invalid, source)).toThrow();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,128 @@
|
||||
import { createHash } from "node:crypto";
|
||||
import { execFileSync } from "node:child_process";
|
||||
import { readFileSync, writeFileSync } from "node:fs";
|
||||
import { join, resolve } from "node:path";
|
||||
import type { MatrixExecution } from "./types.js";
|
||||
import { nativeCompletionDefinitionDigest } from "./native-completion-cases.js";
|
||||
|
||||
export const NATIVE_INSTRUCTION_SUITE = "native-instruction-consolidation";
|
||||
export const NATIVE_INSTRUCTION_BASE_SHA = "2a8a99e4a5f69aa803b3f10b982f583e75a87042";
|
||||
export const NATIVE_INSTRUCTION_DEFAULT_SHA256 = "c6318bf7e425cc0dd7acd4ff2905dab5c46ffddedef979afdf06720c82f6e95a";
|
||||
export const NATIVE_INSTRUCTION_PREFLIGHT_ENV = "PAPERCLIP_NATIVE_INSTRUCTION_PREFLIGHT";
|
||||
const root = resolve(import.meta.dirname, "../..");
|
||||
const hash = (bytes: Buffer | string) => createHash("sha256").update(bytes).digest("hex");
|
||||
export const NATIVE_INSTRUCTION_VARIANTS = {
|
||||
baseline: {
|
||||
"packages/paperclip-runner/src/backends/runtime-context.ts": "e7c46e81cc9c93f9a4f805b5091ef08c59ea70c62f208cfda70d6edeed363898",
|
||||
"packages/paperclip-runner/src/backends/codex-native-backend.ts": "f276d436391c9e2f0a7e58ce1302b5c9f1a39ac01c148be257f9d455515a31b9",
|
||||
"packages/paperclip-runner/src/backends/opencode-native-backend.ts": "d54ddde3a3fdffcda3490d813d27b3b4891448e11cd05f61f9bb4b292d9fd6c2",
|
||||
},
|
||||
candidate: {
|
||||
"packages/paperclip-runner/src/backends/runtime-context.ts": "cae9075fac25f168972c2be4ddb58052ef2940554458e2757d88a5d0e39805c2",
|
||||
"packages/paperclip-runner/src/backends/codex-native-backend.ts": "affecc515a623e0dfeb338f553ea53ebb7d18baa3d13e4395d17b21000dbee93",
|
||||
"packages/paperclip-runner/src/backends/opencode-native-backend.ts": "d5dc4cc2c06b37d22be47c9f15f828c06b439d8241a8d34498ca4339273eed96",
|
||||
},
|
||||
} as const;
|
||||
|
||||
// These are common comparison setup, not additional production changes.
|
||||
const comparisonFiles = new Set([
|
||||
...Object.keys(NATIVE_INSTRUCTION_VARIANTS.baseline),
|
||||
"packages/paperclip-runner/src/backends/runtime-context.test.ts",
|
||||
"packages/paperclip-runner/src/backends/native-instruction-measurement.test.ts",
|
||||
"tests/runner-e2e/native-instruction-consolidation.ts",
|
||||
"tests/runner-e2e/native-instruction-consolidation.test.ts",
|
||||
"tests/runner-e2e/native-completion-defaults.ts",
|
||||
"tests/runner-e2e/native-completion-defaults.test.ts",
|
||||
"tests/runner-e2e/catalog.ts", "tests/runner-e2e/catalog.test.ts", "tests/runner-e2e/launch.ts",
|
||||
"tests/runner-e2e/runner.spec.ts", "tests/runner-e2e/live-fixtures.ts",
|
||||
"tests/runner-e2e/README.md", "doc/evals.md",
|
||||
"doc/plans/2026-10-03-native-completion-consolidation.md",
|
||||
]);
|
||||
const git = (...args: string[]) => execFileSync("git", args, { cwd: root, encoding: "utf8" }).trim();
|
||||
|
||||
export function nativeInstructionVariant(read = (file: string) => readFileSync(join(root, file))) {
|
||||
const matches = Object.entries(NATIVE_INSTRUCTION_VARIANTS).filter(([, files]) =>
|
||||
Object.entries(files).every(([file, digest]) => hash(read(file)) === digest));
|
||||
if (matches.length !== 1) throw new Error("Mixed or unknown native instruction source");
|
||||
return matches[0]![0];
|
||||
}
|
||||
|
||||
export function nativeInstructionDefinitionDigest() {
|
||||
return hash(nativeCompletionDefinitionDigest() + hash(readFileSync(new URL(import.meta.url)))
|
||||
+ hash(readFileSync(join(root, "packages/paperclip-runner/src/backends/native-instruction-measurement.test.ts"))));
|
||||
}
|
||||
|
||||
export function assertNativeInstructionSelection(executions: readonly MatrixExecution[]) {
|
||||
for (const execution of executions.filter(value => value.suite.id === NATIVE_INSTRUCTION_SUITE)) {
|
||||
if (!['runner-codex', 'runner-acpx-claude', 'runner-opencode'].includes(execution.profile.id)
|
||||
|| execution.profile.generation !== "native" || execution.environment.id !== "local"
|
||||
|| execution.profile.qualificationCandidate !== undefined || execution.task.expectedRunCount !== 1
|
||||
|| (execution.task.minimumExpectedRunCount !== undefined && execution.task.minimumExpectedRunCount !== 1)
|
||||
|| !['assigned-skill-explicit-invocation', 'native-blocked-report'].includes(execution.task.id)
|
||||
|| execution.task.automaticRetryPolicy !== "single_attempt"
|
||||
|| execution.id !== `${NATIVE_INSTRUCTION_SUITE}.${execution.profile.id}.local.${execution.task.id}`
|
||||
|| execution.suite.manualOnly !== true || execution.suite.expectedMatrixSize !== 6
|
||||
|| execution.suite.tasks.length !== 2
|
||||
|| !['assigned-skill-explicit-invocation', 'native-blocked-report'].every(id =>
|
||||
execution.suite.tasks.filter(task => task.id === id && task.expectedRunCount === 1
|
||||
&& task.automaticRetryPolicy === "single_attempt").length === 1)) {
|
||||
throw new Error("Native instruction comparison requires the declared local single-attempt cells");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function sourceReceipt() {
|
||||
const sourceSha = git("rev-parse", "HEAD");
|
||||
const requestedSource = process.env.PAPERCLIP_RUNNER_E2E_SOURCE_SHA?.trim();
|
||||
if (requestedSource && requestedSource !== sourceSha) throw new Error("Native instruction source differs from requested immutable revision");
|
||||
if (git("status", "--porcelain", "--untracked-files=normal")) throw new Error("Native instruction comparison requires clean committed source");
|
||||
// Do not silently relax shallow history or admit unrelated production edits.
|
||||
git("merge-base", "--is-ancestor", NATIVE_INSTRUCTION_BASE_SHA, sourceSha);
|
||||
const changed = git("diff", "--name-only", NATIVE_INSTRUCTION_BASE_SHA, sourceSha).split("\n").filter(Boolean);
|
||||
if (changed.some(file => !comparisonFiles.has(file))) throw new Error("Native instruction comparison contains unrelated source changes");
|
||||
return { sourceSha, variant: nativeInstructionVariant(), fixtureDigest: nativeInstructionDefinitionDigest() };
|
||||
}
|
||||
|
||||
export function validateNativeInstructionMeasurement(measurement: {
|
||||
schema: string; sourceSha: string; sourceDirty: boolean; providerCalls: number; fixtureSha256: string;
|
||||
sourceHashes: Record<string, string>; receipts: Array<{ provider: string; schema: string; phase: string }>;
|
||||
}, source: { sourceSha: string; variant: string }) {
|
||||
const expected = ['codex', 'acpx', 'opencode'].flatMap(provider => ['v4', 'v5'].flatMap(schema =>
|
||||
['start', 'resume'].map(phase => `${provider}/${schema}/${phase}`))).sort();
|
||||
const actual = measurement.receipts.map(value => `${value.provider}/${value.schema}/${value.phase}`).sort();
|
||||
const files = NATIVE_INSTRUCTION_VARIANTS[source.variant as keyof typeof NATIVE_INSTRUCTION_VARIANTS];
|
||||
if (measurement.schema !== "paperclip.native-instruction-measurement.v1"
|
||||
|| measurement.sourceSha !== source.sourceSha || measurement.sourceDirty !== false || measurement.providerCalls !== 0
|
||||
|| measurement.fixtureSha256 !== hash(readFileSync(join(root, "packages/paperclip-runner/src/backends/native-instruction-measurement.test.ts")))
|
||||
|| JSON.stringify(actual) !== JSON.stringify(expected) || !files
|
||||
|| Object.entries(files).some(([file, digest]) => measurement.sourceHashes[file.split('/').at(-1)!] !== digest))
|
||||
throw new Error("Invalid or incomplete native instruction measurement");
|
||||
}
|
||||
|
||||
export function prepareNativeInstructionPreflight(directory: string) {
|
||||
const source = sourceReceipt();
|
||||
const measurementPath = join(directory, "native-instruction-measurement.json");
|
||||
execFileSync(process.execPath, [join(root, "node_modules/vitest/vitest.mjs"), "run", "src/backends/native-instruction-measurement.test.ts"], {
|
||||
cwd: join(root, "packages/paperclip-runner"), timeout: 60_000,
|
||||
env: { PATH: process.env.PATH, PAPERCLIP_NATIVE_INSTRUCTION_REPORT: measurementPath }, stdio: "inherit",
|
||||
});
|
||||
const measurement = JSON.parse(readFileSync(measurementPath, "utf8"));
|
||||
validateNativeInstructionMeasurement(measurement, source);
|
||||
const output = join(directory, "native-instruction-preflight.json");
|
||||
writeFileSync(output, `${JSON.stringify({ schema: "paperclip.native-instruction-preflight.v1", ...source,
|
||||
measurementPath, measurementSha256: hash(readFileSync(measurementPath)) }, null, 2)}\n`);
|
||||
return output;
|
||||
}
|
||||
|
||||
export function verifyNativeInstructionPreflight(path: string | undefined) {
|
||||
if (!path) throw new Error("Missing native instruction source admission");
|
||||
const receipt = JSON.parse(readFileSync(path, "utf8"));
|
||||
const source = sourceReceipt();
|
||||
if (receipt.schema !== "paperclip.native-instruction-preflight.v1"
|
||||
|| receipt.sourceSha !== source.sourceSha || receipt.variant !== source.variant
|
||||
|| receipt.fixtureDigest !== source.fixtureDigest
|
||||
|| receipt.measurementSha256 !== hash(readFileSync(receipt.measurementPath)))
|
||||
throw new Error("Stale or mismatched native instruction source admission");
|
||||
validateNativeInstructionMeasurement(JSON.parse(readFileSync(receipt.measurementPath, "utf8")), source);
|
||||
return receipt;
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { assertNativeCompletionSelection, NATIVE_COMPLETION_PREFLIGHT_ENV, verifyNativeCompletionPreflight } from "./native-completion-admission.js";
|
||||
import { assertNativeInstructionSelection, verifyNativeInstructionPreflight, NATIVE_INSTRUCTION_PREFLIGHT_ENV, NATIVE_INSTRUCTION_SUITE, NATIVE_INSTRUCTION_DEFAULT_SHA256 } from "./native-instruction-consolidation.js";
|
||||
import { captureNativeDefault, gradeNativeDefault, nativeCompletionWorkspaceDigest } from "./native-completion-defaults.js";
|
||||
import { gradeNativeCompletion } from "./native-completion-scoring.js";
|
||||
import { assertNativeBlockerReply } from "./native-blocker-visible.js";
|
||||
@@ -562,6 +563,10 @@ for (const execution of executions) {
|
||||
assertNativeCompletionSelection([execution]);
|
||||
verifyNativeCompletionPreflight(process.env[NATIVE_COMPLETION_PREFLIGHT_ENV]);
|
||||
}
|
||||
if (execution.suite.id === NATIVE_INSTRUCTION_SUITE) {
|
||||
assertNativeInstructionSelection([execution]);
|
||||
verifyNativeInstructionPreflight(process.env[NATIVE_INSTRUCTION_PREFLIGHT_ENV]);
|
||||
}
|
||||
const credentials = credentialValues();
|
||||
const secrets = normalizedSecrets(Object.values(credentials));
|
||||
const api = new RunnerApi(request);
|
||||
@@ -859,9 +864,9 @@ for (const execution of executions) {
|
||||
daytonaImage: process.env.PAPERCLIP_E2E_DAYTONA_IMAGE,
|
||||
});
|
||||
|
||||
if (execution.suite.id === "native-completion") {
|
||||
if (["native-completion", NATIVE_INSTRUCTION_SUITE].includes(execution.suite.id)) {
|
||||
const receipt = await captureNativeDefault({ api, agentId: fixtures.agent.id, companyId: fixtures.company.id });
|
||||
const grade = gradeNativeDefault(receipt);
|
||||
const grade = gradeNativeDefault(receipt, execution.suite.id === NATIVE_INSTRUCTION_SUITE ? NATIVE_INSTRUCTION_DEFAULT_SHA256 : undefined);
|
||||
await writeSanitizedJson(snapshotsDir, "native-default-before-execution.json", { receipt, grade }, secrets);
|
||||
if (!grade.passed) throw new Error("Native production-default hire admission failed before execution");
|
||||
const [issues, agents, workspaceDigest] = await Promise.all([
|
||||
@@ -2615,7 +2620,7 @@ for (const execution of executions) {
|
||||
await expect(proofLink).toHaveAttribute("href", `/api/attachments/${downloadedResponseProof!.attachmentId}/content`);
|
||||
} else if (execution.suite.id === "task-titles") {
|
||||
await expect(visibleAgentReplies.filter({ hasText: marker }).last()).toBeVisible({ timeout: 30_000 });
|
||||
} else if (execution.suite.id === "native-completion" && execution.task.id === "native-blocked-report") {
|
||||
} else if (["native-completion", NATIVE_INSTRUCTION_SUITE].includes(execution.suite.id) && execution.task.id === "native-blocked-report") {
|
||||
await assertNativeBlockerReply(visibleAgentReplies, marker);
|
||||
} else if (execution.task.flow === "warm_three_turn") {
|
||||
// Prove the persisted user-facing response is visible, independently
|
||||
@@ -2676,7 +2681,7 @@ for (const execution of executions) {
|
||||
);
|
||||
}
|
||||
}
|
||||
if (execution.suite.id === "native-completion") {
|
||||
if (["native-completion", NATIVE_INSTRUCTION_SUITE].includes(execution.suite.id)) {
|
||||
if (!issue || !nativeInitial) throw new Error("Missing native qualification issue or pre-execution receipt");
|
||||
const [currentIssue, companyRuns, issues, agents, comments, documents, interactions, workspaceDigest] = await Promise.all([
|
||||
api.get<IssueRecord>(`/api/issues/${issue.id}`),
|
||||
|
||||
Reference in new issue
Block a user