Files
PaperClipAI/tests/runner-e2e/chat-catalog-domains/integrator-skill-enable.ts
T
f4337bb5fb test(evals): land the chat catalog eval harness on master (#19614)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The chat-feature evals measure whether agents complete real chat
requests through the product
> - The chat catalog eval harness and its repairs live on the
`chat-eval/master-candidate` branch, not on master
> - Today's work made 139 of 242 chat evals pass in verified single-case
live runs. Each product fix landed on master as its own pull request
> - The eval-side changes (setups, graders, fault seams, evidence
capture) still exist only on the candidate
> - This pull request lands the harness on master. Master stays the
source of truth for product behavior
> - The benefit is one tree: evals run against master commits, and
product fixes reach the evals as soon as they merge

## Linked Issues or Issue Description

Refs #19441, Refs #19599, Refs #20270, Refs #20334, Refs #20342, Refs
#20344, Refs #20354, Refs #20360, Refs #20373, Refs #20382, Refs #20409

**What existing behavior does this improve?**
The chat catalog eval harness and the product it evaluates live on a
long-running branch outside master. Eval fixes do not reach master, so
master-based eval runs use old setups and graders.

**Subsystem affected**
`tests/runner-e2e` chat catalog harness, plus a small set of product
changes that exist only on the candidate.

**Proposed change**
Land the harness on master. Every product fix from this eval work
already merged to master as its own pull request. Conflicts keep
master's product behavior.

## What Changed

- Most of the diff (808 of 851 files) is under `tests/runner-e2e/`:
chat-catalog domains, scenarios, descriptors, the TestOps manifest,
private evidence tooling, and their tests.
- Graders now check saved state, setup literals and rendered or clicked
links. Many keyword and regex checks on free-form replies are removed.
Each changed grader has a bumped `oracleVersion` and calibration tests
(a valid reply, a reworded valid reply, and broken variants that must
fail).
- The shared link helper `hasLink` no longer treats a list link (for
example `/COM/issues?view=mine`) as a link to every task without a URL
key.
- Setup fixes build real state through supported product routes: routine
history, agent grants through the board grant route, budget holds with a
real cap, and a storage-layer archive fault for
`inbox-search.archive-partial-failure`.
- Browser boundary journeys (sign-in, chat-disabled, onboarding) now
write the standard pass evidence files.
- Retargeted cases, approved by the maintainer:
`agent-chat.chat-disabled` (Conference Room gate),
`agents.restore-instructions` (no saved instruction history),
`access.manage-membership` (member permission edits stay board-only).
- The private evidence trusted files (`manual-private-handoff.ts`,
`manual-private-retention.ts`, `manual-private-report-assets.ts`) are
byte-identical to master.
- Product files outside `tests/` (43 files, +1,328 −49) carry
candidate-only changes that master does not yet have. Most are tests.
The main code changes are in `request-human-input.ts`,
`heartbeat-run-summary.ts`, `native-completion-feedback.ts`,
`native-run-finalizer.ts`, `openapi.ts`, `secrets.ts` and
`IssueChatLongThreadPerf.tsx`.

## Verification

- `pnpm vitest run chat-catalog-domains chat-catalog-contract.test.ts
chat-catalog-consistency.test.ts unit-launcher.test.mjs
--testTimeout=180000` in `tests/runner-e2e`: 269 files pass, 3,550 tests
pass.
- `node --test chat-full-catalog-testops-manifest.test.mjs`: 10 pass.
- `node tests/runner-e2e/source-sdk-public-inputs.mjs <HEAD> --check`:
no change.
- `tsc` for `server` and `tests/runner-e2e`: clean.
- Live single-case verification: 139 of 242 cases passed on paid runs,
and a person read the saved evidence for each. These are single-case
runs, not one full-cohort run.

## Risks

- Large diff. Most of it is test-only, but the 43 non-test files change
product code paths. Review those files first.
- Some graders are now less strict on reply wording. A person must read
replies for meaning on those cases.
- 42 cases need disposable outside accounts (Notion, Slack, GitHub,
Daytona and others) and stay blocked. `access.invite-teammate` stays
failing until local agent isolation lands, because the runner's durable
state keeps a live invite token.
- The paid workflow compares the trusted private-evidence files with
master. They are unchanged, so this risk is low.

## Model Used

Anthropic Claude Opus 5.5 (`claude-opus-5-5`), with tool use and code
execution, in Claude Code. Subagents used the same model.

## 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
- [x] 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

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-11-10 08:02:11 -06:00

110 lines
13 KiB
TypeScript

import { readSkillVersionHistory } from "./integrator-skill-versions.js";
import type { CompanySkillDetail, CompanySkillVersion } from "../../../packages/shared/src/types/company-skill.js";
import type { AgentSkillSnapshot } from "../../../packages/shared/src/types/adapter-skills.js";
import { SKILL_POLICY_ACTIONS, type EffectiveSkillPolicy } from "../../../packages/shared/src/validators/skill-policy.js";
import type { ChatCatalogContext } from "../chat-catalog-contract.js";
import { pollUntil } from "../api.js";
import { checks, observation, project, task, type Entity, type InternalObservation } from "./internal-support.js";
import { fixtureWorker } from "./internal-definition.js";
import { probeAgentPermission, cleanupIdentityProbes } from "./identity-support.js";
import { integratorDefinition, inspectResult, observeInternal } from "./integrator-support.js";
interface EnableObservation extends InternalObservation { skill: CompanySkillDetail; assignment: AgentSkillSnapshot; effectivePolicy: unknown; versions: CompanySkillVersion[] }
const root = (ctx: ChatCatalogContext) => `/api/companies/${ctx.input.fixtures.company.id}`;
async function observeEnable(ctx: ChatCatalogContext, state: Record<string, unknown>): Promise<EnableObservation> {
const base = await observeInternal(ctx, state);
return { ...base, skill: await ctx.input.api.get<CompanySkillDetail>(`${root(ctx)}/skills/${(state.skill as CompanySkillDetail).id}`),
assignment: await ctx.input.api.get<AgentSkillSnapshot>(`/api/agents/${(state.worker as Entity).id}/skills`), effectivePolicy: await ctx.input.api.get(`${root(ctx)}/skill-policy`),
versions: await readSkillVersionHistory(ctx.input.api, ctx.input.fixtures.company.id, (state.skill as CompanySkillDetail).id) };
}
export interface SkillEnableAuthorityProof {
companyId: string; principalId: string; targetId: string; targetCompanyId: string; status: number;
membership?: { companyId: string; principalType: string; principalId: string; status: string } | null;
grants: Array<{ permissionKey: string; scope?: unknown }>;
before: AgentSkillSnapshot; after: AgentSkillSnapshot;
}
export function skillEnableAuthorityReady(proof: SkillEnableAuthorityProof | undefined, companyId: string, principalId: string, targetId: string, skillKey: string) {
return !!proof && proof.status === 200 && proof.companyId === companyId && proof.principalId === principalId && proof.targetId === targetId && proof.targetCompanyId === companyId
&& proof.membership?.companyId === companyId && proof.membership.principalType === "agent" && proof.membership.principalId === principalId && proof.membership.status === "active"
&& Array.isArray(proof.grants) && proof.grants.some(grant => grant.permissionKey === "agents:configure")
&& proof.before?.supported === true && proof.after?.supported === true && Array.isArray(proof.before.desiredSkills) && Array.isArray(proof.after.desiredSkills)
&& !proof.before.desiredSkills.includes(skillKey) && !proof.after.desiredSkills.includes(skillKey)
&& JSON.stringify(proof.before.desiredSkills) === JSON.stringify(proof.after.desiredSkills)
&& JSON.stringify(proof.before.desiredSkillEntries ?? []) === JSON.stringify(proof.after.desiredSkillEntries ?? []);
}
function enableObservation(value: unknown): EnableObservation | undefined { const o = value as EnableObservation; return observation(value) && !!o.skill && Array.isArray(o.assignment?.desiredSkills) && !!o.effectivePolicy && Array.isArray(o.versions) ? o : undefined; }
export function gradeIntegratorSkillEnable(value: unknown) {
const c = checks(); const o = enableObservation(value); c.add("real-assignment-policy-and-future-admission", !!o, "Requires actual permitted assignment, unchanged installed revision/policy and a real subsequent native admission."); if (!o) return c.result();
const original = o.state.skill as CompanySkillDetail; const worker = o.state.worker as Entity;
c.add("actual-ceo-target-configuration-and-no-op-readback", skillEnableAuthorityReady(o.state.configurationAuthority as SkillEnableAuthorityProof | undefined, o.companyId, o.leadId, worker.id, original.key),
"The actual same-company CEO membership/default configuration grant and its successful target-specific agent-bearer no-op are read back without assigning the requested skill during setup.");
c.add("actual-configuration-grant-prerequisite", o.state.agentConfigurationStatus === 200, "The actual CEO bearer successfully exercised a no-op public skill configuration probe; title/legacy hire authority is not a configuration grant.");
const future = o.runs.find(run => run.agentId === worker.id && run.companyId === o.companyId && run.contextSnapshot?.issueId === (o.state.futureTask as Entity | undefined)?.id);
const selectedId = (future?.contextSnapshot?.skillVersions as Record<string, unknown> | undefined)?.[original.key];
const delivered = o.versions.find(row => row.id === selectedId && row.companyId === o.companyId && row.companySkillId === original.id);
const exactBytes = !!delivered && delivered.fileInventory.length === 1 && delivered.fileInventory[0]?.path === "SKILL.md"
&& delivered.fileInventory[0].encoding !== "base64" && delivered.fileInventory[0].content === original.markdown;
c.add("saved-intended-morgan-assignment", o.assignment.supported && o.assignment.desiredSkills.includes(original.key)
&& o.assignment.desiredSkillEntries?.some(entry => entry.key === original.key && (entry.versionId === null || entry.versionId === original.currentVersionId || exactBytes && entry.versionId === selectedId)) === true
&& o.activity.some(event => event.action === "agent.skills_synced" && event.agentId === o.leadId && event.entityId === worker.id
&& Array.isArray(o.state.beforeActivityIds) && !o.state.beforeActivityIds.includes(event.id)
&& o.runs.some(run => run.id === (event as Entity & { runId?: string }).runId && run.agentId === o.leadId)),
"The requested existing skill is durably assigned to the actual Morgan through the normal agent skill configuration path.");
c.add("installation-and-policy-not-self-elevated", o.skill.id === original.id && o.skill.markdown === original.markdown && (o.skill.currentVersionId === original.currentVersionId || exactBytes && o.skill.currentVersionId === selectedId)
&& JSON.stringify(o.effectivePolicy) === JSON.stringify(o.state.effectivePolicy)
&& !o.activity.some(event => event.agentId === o.leadId && /skill_policy\.|company\.skill_(?:created|file_updated|forked)/.test(event.action ?? "")),
"Assignment preserves the already installed revision and effective policy rather than installing again or rewriting policy to gain authority.");
c.add("future-execution-receives-intended-version", future?.runtimeMode === "native" && future.status === "succeeded"
&& exactBytes && (!original.currentVersionId || selectedId === original.currentVersionId),
"A separately admitted actual Morgan task receives the selected immutable skill revision in its saved native skill selection snapshot.");
// The reply's wording is not matched: the saved assignment, the unchanged
// policy and the future run's delivered revision prove the work. This check
// proves the chat run configured only Morgan, and that it answered.
c.add("assignment-scoped-to-morgan-and-reported", o.reply.trim().length > 0
&& !o.activity.some(event => event.action === "agent.skills_synced" && event.agentId === o.leadId && event.entityId !== worker.id
&& Array.isArray(o.state.beforeActivityIds) && !o.state.beforeActivityIds.includes(event.id)),
"The chat run changes skill configuration for Morgan alone (no other agent and no global policy) and replies to the person.");
return c.result();
}
export function unsupportedUsePrerequisite(value: { useStatus: number; decisions: Array<{ action: string; allowed: boolean }>; assignmentRetained: boolean }) {
return !(SKILL_POLICY_ACTIONS as readonly string[]).includes("skills.use") && value.useStatus === 400
&& value.decisions.length === SKILL_POLICY_ACTIONS.length
&& SKILL_POLICY_ACTIONS.every(action => value.decisions.some(decision => decision.action === action && !decision.allowed))
&& value.assignmentRetained;
}
export const integratorSkillEnableCases = [integratorDefinition("skills", "skills.enable-for-agent", async ctx => {
try {
const p = await project(ctx, "Launch"); const worker = await fixtureWorker(ctx);
const created = await ctx.input.api.post<CompanySkillDetail>(`${root(ctx)}/skills`, { name: "Accessibility review", slug: "accessibility-review", markdown: "---\nname: accessibility-review\ndescription: Check synthetic HTML form labels.\n---\n\nFor supplied synthetic HTML, identify every form input without a visible label. Save concrete evidence in the task comment and finish the task. Do not browse other pages or claim global qualification." });
const effectivePolicy = await ctx.input.api.get<EffectiveSkillPolicy>(`${root(ctx)}/skill-policy`);
const access = await ctx.input.api.get<{ access?: { membership?: SkillEnableAuthorityProof["membership"]; grants?: SkillEnableAuthorityProof["grants"] } }>(`/api/agents/${ctx.input.fixtures.agent.id}`);
const before = await ctx.input.api.get<AgentSkillSnapshot>(`/api/agents/${worker.id}/skills`);
const agentConfigurationStatus = await probeAgentPermission(ctx, `/api/agents/${worker.id}/skills/sync`, "POST", { mode: "add", desiredSkills: [] });
const after = await ctx.input.api.get<AgentSkillSnapshot>(`/api/agents/${worker.id}/skills`);
const configurationAuthority: SkillEnableAuthorityProof = { companyId: ctx.input.fixtures.company.id, principalId: ctx.input.fixtures.agent.id,
targetId: worker.id, targetCompanyId: worker.companyId!, status: agentConfigurationStatus,
membership: access.access?.membership, grants: access.access?.grants ?? [], before, after };
const policyAfterProbe = await ctx.input.api.get<EffectiveSkillPolicy>(`${root(ctx)}/skill-policy`);
await ctx.input.evidence("chat-skill-configuration-prerequisite.json", { configurationAuthority, querySent: false, grantMutationAttempted: false,
requestedSkillAssignedBySetup: after.desiredSkills.includes(created.key), effectiveUseDenialExperimentRun: false, deniedUseCoverageClaimed: false,
conditionalCoverageNote: "This installed-skill/allowed-assignment positive context does not claim conditional effective-use-denial coverage. No lifecycle denial or unsupported skills.use action substitutes for a supported actual use denial.",
originalPolicyRetained: JSON.stringify(effectivePolicy) === JSON.stringify(policyAfterProbe) });
if (!skillEnableAuthorityReady(configurationAuthority, ctx.input.fixtures.company.id, ctx.input.fixtures.agent.id, worker.id, created.key)
|| JSON.stringify(effectivePolicy) !== JSON.stringify(policyAfterProbe)) throw new Error(`Setup blocker: actual CEO target configuration authority/no-op readback was not established (HTTP ${agentConfigurationStatus}); no grant or requested assignment was substituted.`);
return { project: p, worker: { id: worker.id }, skill: await ctx.input.api.get<CompanySkillDetail>(`${root(ctx)}/skills/${created.id}`), effectivePolicy, agentConfigurationStatus, configurationAuthority,
beforeActivityIds: (await ctx.input.api.get<Entity[]>(`${root(ctx)}/activity?limit=1000`)).map(event => event.id) };
} catch (error) { await cleanupIdentityProbes(ctx); throw error; }
}, observeEnable, gradeIntegratorSkillEnable, async (ctx, state) => {
const skill = state.skill as CompanySkillDetail; await inspectResult(ctx, `/${ctx.input.fixtures.company.issuePrefix}/skills/studio/${skill.id}`, skill.name);
}, { sourceFiles: ["chat-catalog-domains/integrator-skill-versions.ts", "chat-catalog-domains/integrator-skill-enable.ts", "chat-catalog-domains/identity-support.ts", "chat-catalog-domains/internal-definition.ts", "chat-catalog-domains/internal-support.ts", "chat-catalog-domains/integrator-support.ts", "chat-scenarios/skills.yaml", "../../server/src/routes/agents.ts", "../../server/src/routes/company-skill-policy.ts", "../../server/src/services/company-skills.ts", "../../packages/shared/src/validators/skill-policy.ts"],
expectedRunCount: 2, attemptTimeoutMs: 540_000, oracleVersion: "paperclip.chat-catalog.skill-enable.standard-config.v3",
async act(ctx, state) {
const first = await pollUntil({ label: "actual Morgan assignment before future admission", deadlineAt: Date.now() + 180_000, intervalMs: 1000,
load: () => observeEnable(ctx, state), accept: o => o.runs.length === 1 && o.runs[0]?.status === "succeeded" && ctx.issue()?.conversationState === "waiting" });
const skill = state.skill as CompanySkillDetail;
if (!first.assignment.desiredSkills.includes(skill.key)) throw new Error("Canonical request did not save the intended assignment; no fixture assignment will repair it");
state.assignmentCheckpoint = { ...first, state: structuredClone(state) };
state.futureTask = await task(ctx, "Verify assigned accessibility skill on synthetic HTML", (state.project as Entity).id, { status: "todo", assigneeAgentId: (state.worker as Entity).id,
description: 'Use the assigned accessibility-review skill on this synthetic input only: <form><input id="sample-email" type="email"><button>Join</button></form>. Save the actual form-label finding in a comment and complete this task. Do not change assignments, policy or other work.' });
}, async cleanup(ctx) { await cleanupIdentityProbes(ctx); },
})];