Files
PaperClipAI/packages/paperclip-runner/src/eval/workflow-catalog.ts
T
Dotta 5458940a6e feat(runner): add offline evaluation tooling (#12653)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Paperclip Runner needs repeatable evaluation contracts.
> - Evaluation code must stay separate from provider launch and
production orchestration.
> - Offline fixtures need stable compatibility, scoring, traceability,
and report rules.
> - Published Runner consumers need only the supported evaluation
contract surface.
> - This pull request adds offline evaluation tooling and a
workspace-private matrix kernel.
> - The benefit is deterministic evaluation without credentials or paid
provider calls.

## Linked Issues or Issue Description

Refs #11297

This pull request extracts the offline evaluation unit from the earlier
aggregate Runner work.

## What Changed

- Add a workspace-private, provider-neutral evaluation matrix kernel.
- Add the public `@paperclipai/paperclip-runner/evals` compatibility and
native execution contracts.
- Add fail-closed runnerd artifact and protocol compatibility checks.
- Add deterministic workflow catalogs, scoring, traceability, and report
generation.
- Add sanitized Codex, OpenCode, and ACPX fixtures.
- Add package-boundary and clean-consumer checks.
- Add the eval package manifest to the Docker dependency stage.
- Add the generated protocol fixture digest without changing the
lockfile.

## Verification

GitHub Actions must run:

- Runner TypeScript and Rust type checks.
- Runner unit and protocol tests.
- Evaluation kernel tests.
- Workflow traceability checks.
- Clean-consumer and package-boundary checks.
- Repository test, type-check, build, policy, and security gates.

No local test command was run. The repository owner requested
GitHub-only verification.

## Risks

This is a large greenfield review surface with 51 files. The code does
not launch a live provider or load credentials. Package and protocol
drift fail closed. The workspace lockfile remains under the existing
CI-owned process.

## Model Used

OpenAI Codex with the GPT-5 agent model. The work used high reasoning,
repository inspection, tool use, and parallel code review.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [ ] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge
2026-09-01 05:19:47 -05:00

231 lines
10 KiB
TypeScript

import {
RUNNER_WORKFLOW_EVAL_CASE_SCHEMA,
RUNNER_WORKFLOW_IDS,
assertRunnerWorkflowEvalCase,
type RunnerWorkflowEvalCase,
} from "./workflow-contracts.js";
const ALL_PROVIDERS = ["codex", "opencode", "acpx"] as const;
function workflow(input: Omit<RunnerWorkflowEvalCase, "schema" | "version">): RunnerWorkflowEvalCase {
const value: RunnerWorkflowEvalCase = {
schema: RUNNER_WORKFLOW_EVAL_CASE_SCHEMA,
version: 1,
...input,
};
assertRunnerWorkflowEvalCase(value);
return Object.freeze(value);
}
/** The twelve deterministic workflows distilled from the stress findings. */
export const RUNNER_WORKFLOW_CATALOG: readonly RunnerWorkflowEvalCase[] = Object.freeze([
workflow({
id: "final-response",
title: "Preserve one substantive final response",
tags: ["response", "resolver", "long-output"],
providers: [...ALL_PROVIDERS], steps: [{ kind: "run_start", taskMode: "ask" }],
assertions: {
issueStatus: "done", runStatus: "succeeded", semanticDisposition: "done", maxRuns: 1,
commentCount: 1, responseSource: "final_agent_message",
orderedMarkers: ["commentary", "activity", "final"],
requiredPrpEventTypes: ["run.result.accepted", "run.presentation.resolved", "run.terminal"],
forbiddenPrpEventTypes: ["run.presentation.placeholder"],
requiredOperationIds: ["finish_task"],
},
}),
workflow({
id: "rich-activity",
title: "Render structured provider activity through settlement",
tags: ["activity", "tools", "search"],
providers: [...ALL_PROVIDERS], steps: [{ kind: "run_start", taskMode: "execute" }],
assertions: {
issueStatus: "done", runStatus: "succeeded", semanticDisposition: "done",
orderedMarkers: ["commentary", "research", "tool", "file", "test", "final"],
requiredPrpEventTypes: ["research.completed", "tool.execution.completed", "run.terminal"],
requiredActivityFamilies: ["research", "tool_execution"],
requiredOperationIds: ["report_progress", "finish_task"],
},
}),
workflow({
id: "verification-policy",
title: "Resolve unavailable and externally required verification",
tags: ["verification", "caveat", "review"],
providers: [...ALL_PROVIDERS], steps: [{ kind: "run_start", taskMode: "execute" }],
assertions: {
issueStatus: "done", runStatus: "succeeded", semanticDisposition: "done", recoveryOwner: "none",
commentCount: 1, requiredPrpEventTypes: ["run.result.accepted", "run.terminal"],
requiredOperationIds: ["finish_task"],
},
}),
workflow({
id: "governed-interaction",
title: "Park and resume governed interactions",
tags: ["interaction", "wait", "continuation"],
providers: [...ALL_PROVIDERS],
steps: [
{ kind: "run_start", taskMode: "ask" },
{ kind: "interaction_response", interaction: "questions" },
{ kind: "interaction_response", interaction: "suggest_tasks" },
{ kind: "interaction_response", interaction: "checkbox" },
{ kind: "interaction_response", interaction: "item_verdicts", partial: true },
{ kind: "interaction_response", interaction: "item_verdicts" },
],
assertions: {
issueStatus: "done", runStatus: "succeeded", semanticDisposition: "done", maxRuns: 3,
commentCount: 1, orderedMarkers: ["question", "answer", "continuation", "final"],
requiredPrpEventTypes: ["interaction.requested", "run.result.accepted", "run.terminal"],
forbiddenPrpEventTypes: ["run.presentation.placeholder"],
requiredOperationIds: ["request_human_input", "finish_task"],
},
}),
workflow({
id: "steering-causality",
title: "Keep queued and active steering causally ordered",
tags: ["steering", "ordering", "idempotency"],
providers: [...ALL_PROVIDERS],
steps: [
{ kind: "run_start", taskMode: "execute" },
{ kind: "steer", delivery: "queued" },
{ kind: "steer", delivery: "active_turn", duplicate: true },
],
assertions: {
issueStatus: "done", runStatus: "succeeded", semanticDisposition: "done", maxRuns: 2,
orderedMarkers: ["pre-steer", "steering", "post-steer", "final"],
requiredPrpEventTypes: ["turn.steering.acknowledged", "run.terminal"],
requiredOperationIds: ["finish_task"],
},
}),
workflow({
id: "planning-lifecycle",
title: "Reject, revise, accept, and execute a cohesive plan on the source",
tags: ["plan", "same-issue", "approval"],
providers: [...ALL_PROVIDERS],
steps: [
{ kind: "run_start", taskMode: "plan" },
{ kind: "review_decision", decision: "reject" },
{ kind: "review_decision", decision: "approve" },
],
assertions: {
issueStatus: "done", runStatus: "succeeded", semanticDisposition: "done", maxRuns: 4,
orderedMarkers: ["plan-v1", "rejection", "plan-v2", "acceptance", "same-issue", "parent-final"],
requiredPrpEventTypes: ["plan.updated", "run.result.accepted", "run.terminal"],
requiredOperationIds: ["write_document", "request_human_input", "finish_task"],
},
}),
workflow({
id: "review-lifecycle",
title: "Reject narrowly and approve human completion review",
tags: ["review", "ownership", "narrow-repair"],
providers: [...ALL_PROVIDERS],
steps: [
{ kind: "run_start", taskMode: "execute" },
{ kind: "review_decision", decision: "reject" },
{ kind: "review_decision", decision: "approve" },
],
assertions: {
issueStatus: "done", runStatus: "succeeded", semanticDisposition: "needs_review", recoveryOwner: "human", maxRuns: 2,
orderedMarkers: ["review", "rejection", "verification-only", "replacement-review", "approval"],
requiredPrpEventTypes: ["run.result.accepted", "interaction.requested", "run.terminal"],
requiredOperationIds: ["request_human_input", "finish_task"],
},
}),
workflow({
id: "delegation-return",
title: "Decompose an accepted plan for a justified independent boundary",
tags: ["plan", "delegation", "dependency", "cross-provider"],
providers: [...ALL_PROVIDERS],
steps: [
{ kind: "run_start", taskMode: "plan" },
{ kind: "review_decision", decision: "approve" },
{ kind: "child_completion", childProvider: "opencode" },
],
assertions: {
issueStatus: "done", runStatus: "succeeded", semanticDisposition: "done", maxRuns: 2,
orderedMarkers: ["child-result", "parent-wake", "parent-final"],
requiredPrpEventTypes: ["delegation.completed", "run.result.accepted", "run.terminal"],
forbiddenPrpEventTypes: ["delegation.duplicate_wake"],
requiredOperationIds: ["write_document", "request_human_input", "create_task", "set_dependencies", "finish_task"],
},
}),
workflow({
id: "completion-robustness",
title: "Normalize completion and bound missing-result recovery",
tags: ["completion", "schema", "exhaustion"],
providers: [...ALL_PROVIDERS], steps: [{ kind: "run_start", taskMode: "execute" }],
assertions: {
issueStatus: "done", runStatus: "succeeded", semanticDisposition: "done", maxAttempts: 3, maxRuns: 1, recoveryOwner: "none",
commentCount: 1, responseSource: "semantic_result_summary",
requiredPrpEventTypes: ["run.result.accepted", "run.terminal"], forbiddenPrpEventTypes: ["run.presentation.placeholder"],
requiredOperationIds: ["finish_task"],
},
}),
workflow({
id: "restart-recovery",
title: "Recover once without stale finalizer authority",
tags: ["restart", "checkpoint", "authority"],
providers: [...ALL_PROVIDERS],
steps: [
{ kind: "run_start", taskMode: "execute" },
{ kind: "process_restart", phase: "provider_turn" },
{ kind: "process_restart", phase: "finalization" },
],
assertions: {
issueStatus: "done", runStatus: "succeeded", semanticDisposition: "done", maxAttempts: 2, maxRuns: 1,
requiredPrpEventTypes: ["run.result.accepted", "run.terminal"],
forbiddenPrpEventTypes: ["native_finalization_superseded_mutation"],
requiredOperationIds: ["report_progress", "finish_task"],
},
}),
workflow({
id: "cancellation-permissions",
title: "Normalize cancellation and scoped permissions",
tags: ["cancellation", "permission", "interruption"],
providers: [...ALL_PROVIDERS],
steps: [
{ kind: "run_start", taskMode: "execute" },
{ kind: "permission_decision", decision: "accept_for_session" },
{ kind: "cancel", actor: "operator" },
],
assertions: {
issueStatus: "cancelled", runStatus: "cancelled", maxRuns: 1, commentCount: 0, responseSource: "none",
orderedMarkers: ["permission", "activity", "stopped"],
requiredPrpEventTypes: ["runtime_request.resolved", "run.terminal"],
forbiddenPrpEventTypes: ["provider.notice.false_abort_failure"],
requiredOperationIds: [],
},
}),
workflow({
id: "trace-lineage",
title: "Correlate provider frames through PRP and presentation",
tags: ["trace", "lineage", "redaction"],
providers: [...ALL_PROVIDERS], steps: [{ kind: "run_start", taskMode: "execute" }],
assertions: {
issueStatus: "done", runStatus: "succeeded", semanticDisposition: "done",
requiredPrpEventTypes: ["item.started", "run.result.proposed", "item.completed", "run.presentation.resolved", "run.terminal"],
trace: {
capture: "on", digestVerified: true, ordered: true,
dispositions: ["mapped", "generic", "ignored", "rejected", "operator_only"],
lineage: ["one_to_one", "one_to_many", "many_to_one"],
},
requiredOperationIds: ["finish_task"],
},
}),
]);
export function runnerWorkflowCase(id: string): RunnerWorkflowEvalCase {
const found = RUNNER_WORKFLOW_CATALOG.find((candidate) => candidate.id === id);
if (!found) throw new Error(`unknown Runner workflow eval case: ${id}`);
return found;
}
export function assertRunnerWorkflowCatalog(): void {
const ids = RUNNER_WORKFLOW_CATALOG.map((entry) => entry.id);
if (ids.length !== RUNNER_WORKFLOW_IDS.length || new Set(ids).size !== RUNNER_WORKFLOW_IDS.length) {
throw new Error(`Runner workflow catalog must contain ${RUNNER_WORKFLOW_IDS.length} unique cases`);
}
for (const id of RUNNER_WORKFLOW_IDS) {
if (!ids.includes(id)) throw new Error(`Runner workflow catalog is missing ${id}`);
}
RUNNER_WORKFLOW_CATALOG.forEach(assertRunnerWorkflowEvalCase);
}