mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-05 14:35:17 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The chat catalog eval `teams.configure-team` checks that chat gets an installed team ready member by member > - Its setup installs Product Engineering, removes the QA member's account, and requires a real probe split: QA missing an account, the senior coder ready > - The QA probe returned a generic `opencode_hello_probe_failed` error, so the setup stopped with "probes do not establish the required missing-versus-ready account split" > - The cause is a product classification gap: OpenRouter answers an empty key with HTTP 401 "Missing Authentication header", which the OpenCode probe did not treat as authentication (fixed in #20878, cherry-picked here) > - This pull request makes the setup blocker name each member's observed readiness, and replaces reply keyword checks with structural checks > - The benefit is that the eval can reach the chat journey and grades it without matching words ## Linked Issues or Issue Description Refs #20878 **What happened** `teams.configure-team` failed in setup. The QA member's probe was `fail` with `opencode_hello_probe_failed`. The senior coder passed. The setup error did not say which member was in which state. **Expected behavior** The QA member's probe reports the missing-authentication check, so the split forms and the chat journey runs. When the split does not form, the setup error names each member's observed status and checks. **Steps to reproduce** 1. Run `chat-features.runner-opencode.local.teams.configure-team` on master. 2. Read `snapshots/chat-catalog-team-initial-probes.json`. 3. QA shows `fail` with `opencode_hello_probe_failed:error`; the setup stops. ## What Changed - Cherry-pick of #20878: the OpenCode probe classifies a provider 401 as `opencode_hello_probe_auth_required`. - The setup blocker now lists each member as `name (expected missing account | expected ready | other member): status [non-info checks]`. - Grader: remove the member-name substring check and the "team is ready" regex. Identification is the rendered link to the missing member's own page, which the case already required. The followup is graded by a non-empty reply from its own succeeded run, not by the words "ready/configured/verified/account". Fresh per-member probes, preserved working configuration and revisions, and the attributed repair stay unchanged. - Calibration: reworded and non-English valid followups pass; missing handoff, empty followup, and failed followup run fail. A setup test with the recorded failure shape checks the new error text. - `oracleVersion` bumped to `paperclip.chat-catalog.team-configure.v3`; `parse.ts` added to `sourceFiles`. ## Verification - `pnpm exec vitest run --config tests/runner-e2e/vitest.config.ts tests/runner-e2e/chat-catalog-domains/external-team-configure.test.ts tests/runner-e2e/chat-catalog-domains/external-team-configure-prerequisite.test.ts tests/runner-e2e/chat-runtime-profile.test.ts tests/runner-e2e/chat-catalog-contract.test.ts tests/runner-e2e/chat-catalog-consistency.test.ts` passes. - `node tests/runner-e2e/source-sdk-public-inputs.mjs <HEAD> --check` reports no change. - `node --test tests/runner-e2e/chat-full-catalog-testops-manifest.test.mjs` passes. - The paid run `chat-features.runner-opencode.local.teams.configure-team` is still to run. ## Risks - The removed "team is ready" regex failed open. A false whole-team claim in the reply now needs human reading of the transcript. The structural checks still reject a missing handoff, a missing repair, and any member that fails its fresh probe. ## Model Used - Anthropic Claude Opus 5.5 (`claude-opus-5-5`), tool use and code execution in Claude Code. ## 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>
111 lines
11 KiB
TypeScript
111 lines
11 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { createHash } from "node:crypto";
|
|
import { teamBindingCandidate, teamConfigureExternalCases, type TeamBindingApproval } from "./external-team-configure.js";
|
|
function valid() {
|
|
return { scenarioId: "teams.configure-team", origin: "http://fixture.invalid", companyId: "company", leadId: "ceo", connections: [], profiles: [], secrets: [], endpoints: [], interactions: [], tasks: [], projects: [], goals: [], comments: [], documents: [], revisions: [], humanQueries: [], links: [],
|
|
reply: "QA has been configured and each team member is ready.", phaseReplies: [{ runId: "initial", body: "QA needs the eligible account; open QA configuration." }, { runId: "verified", body: "QA and the senior coder are now configured and ready." }], runs: [{ id: "initial", status: "succeeded" }, { id: "verified", status: "succeeded" }],
|
|
activity: [{ id: "repair", action: "agent.updated", actorType: "user", entityId: "qa", agentId: null as string | null }], state: {
|
|
installedFromCatalog: true, missingId: "qa", workingId: "coder", expectedMembers: 2, memberIdsBefore: ["coder", "qa"], workingRevisionIdsBefore: ["revision"], workingRevisionIdsAfter: ["revision"],
|
|
initialProbes: [{ agentId: "qa", status: "fail", testedAt: "2026-10-26T10:00:00Z", checks: [{ code: "codex_auth", level: "error" }] }, { agentId: "coder", status: "pass", testedAt: "2026-10-26T10:00:00Z", checks: [] }],
|
|
afterProbes: [{ agentId: "qa", status: "pass", testedAt: "2026-10-26T10:05:01Z", checks: [] }, { agentId: "coder", status: "pass", testedAt: "2026-10-26T10:05:02Z", checks: [] }],
|
|
repairVerifiedAfter: Date.parse("2026-10-26T10:05:00Z"), initialHandoffSupported: true, repairConfirmed: true, repairChannel: "human-board-configuration", workingHashBefore: "same-config", workingHashAfter: "same-config", memberIdsPreserved: true, initialRunId: "initial", preVerificationRunIds: ["initial"],
|
|
} };
|
|
}
|
|
describe("installed team per-member readiness oracle", () => {
|
|
const definition = teamConfigureExternalCases[0]!;
|
|
it("accepts real missing-account diagnosis, human repair and fresh separate readiness checks", () => { expect(definition.grade(valid()).passed).toBe(true); });
|
|
it("accepts the exact OpenCode missing-auth warning without treating the member as ready", () => {
|
|
const o = valid(); o.state.initialProbes[0]!.status = "warn"; o.state.initialProbes[0]!.checks = [{ code: "opencode_hello_probe_auth_required", level: "warn" }];
|
|
expect(definition.grade(o).passed).toBe(true);
|
|
o.state.afterProbes[0]!.status = "warn";
|
|
expect(definition.grade(o).passed).toBe(false);
|
|
});
|
|
it("also accepts an actually attributed eligible agent configuration repair", () => { const o = valid(); o.state.repairChannel = "agent-configuration"; o.activity[0]!.actorType = "agent"; o.activity[0]!.agentId = "ceo"; expect(definition.grade(o).passed).toBe(true); });
|
|
it("rejects stale/member-substituted readiness, unrelated config edits and premature success", () => {
|
|
for (const change of [
|
|
(o: ReturnType<typeof valid>) => { o.state.afterProbes[0]!.testedAt = "2026-10-26T09:00:00Z"; },
|
|
(o: ReturnType<typeof valid>) => { o.state.afterProbes[0]!.status = "fail"; },
|
|
(o: ReturnType<typeof valid>) => { o.state.afterProbes[0]!.agentId = "coder"; },
|
|
(o: ReturnType<typeof valid>) => { o.state.initialProbes[0]!.agentId = "other-member"; },
|
|
(o: ReturnType<typeof valid>) => { o.state.workingHashAfter = "changed-working-account"; },
|
|
(o: ReturnType<typeof valid>) => { o.state.workingRevisionIdsAfter = ["masked-env-change"]; },
|
|
(o: ReturnType<typeof valid>) => { o.state.initialHandoffSupported = false; },
|
|
(o: ReturnType<typeof valid>) => { o.phaseReplies[1]!.body = " "; },
|
|
(o: ReturnType<typeof valid>) => { o.runs[1]!.status = "failed"; },
|
|
(o: ReturnType<typeof valid>) => { o.phaseReplies[1]!.runId = "initial"; },
|
|
]) { const o = valid(); change(o); expect(definition.grade(o).passed).toBe(false); }
|
|
});
|
|
it("grades the followup structurally, not by its wording", () => {
|
|
for (const body of ["Both QA and the senior coder pass their own checks now.", "Fertig: alle Mitglieder bestehen ihre Prüfung."]) {
|
|
const o = valid(); o.phaseReplies[1]!.body = body; o.reply = body; expect(definition.grade(o).passed).toBe(true);
|
|
}
|
|
});
|
|
it("missing observations cannot pass", () => { expect(definition.grade(undefined).passed).toBe(false); expect(definition.grade({ reply: "Everyone is ready." }).passed).toBe(false); });
|
|
});
|
|
|
|
const cardPayload = { version: 1, prompt: "Bind?", secretProposal: { version: 1, proposalId: "proposal", sourceSecretLabel: "OpenRouter", configPath: "env.OPENROUTER_API_KEY", targetAgentId: "qa", targetAgentName: "QA", justification: "x", expiresAt: "2026-12-01T00:00:00Z" } };
|
|
function card(overrides: Record<string, unknown> = {}) {
|
|
return { id: "card", companyId: "company", issueId: "source", kind: "request_confirmation", status: "pending", sourceRunId: "initial", createdByAgentId: "ceo", createdByUserId: null, addresseeAgentId: null,
|
|
resolvedByUserId: null as string | null, resolvedByAgentId: null as string | null, requestedResolverPolicy: "human_only", effectiveResolverPolicy: "human_only", idempotencyKey: "secret-proposal:proposal", payload: structuredClone(cardPayload), ...overrides };
|
|
}
|
|
function proposal(overrides: Record<string, unknown> = {}) {
|
|
return { id: "proposal", companyId: "company", kind: "binding", status: "pending", secretId: "openrouter-secret", secretProposalId: null, targetType: "agent", target: { id: "qa" },
|
|
configPath: "env.OPENROUTER_API_KEY", originRunId: "initial", proposedBy: { id: "ceo" }, ...overrides };
|
|
}
|
|
function candidate(cards: unknown[], proposals: unknown[]) {
|
|
return teamBindingCandidate({ interactions: cards as never, proposals: proposals as never, companyId: "company", issueId: "source", leadId: "ceo", initialRunId: "initial", missingId: "qa",
|
|
eligible: [{ configPath: "env.OPENROUTER_API_KEY", secretId: "openrouter-secret" }] });
|
|
}
|
|
const hash = (value: unknown) => createHash("sha256").update(JSON.stringify(value)).digest("hex");
|
|
function bindingValid() {
|
|
const o = valid(), marker: TeamBindingApproval = { interactionId: "card", proposalId: "proposal", configPath: "env.OPENROUTER_API_KEY", secretId: "openrouter-secret", targetAgentId: "qa", payloadHash: hash(cardPayload) };
|
|
return { ...o, activity: [] as typeof o.activity, interactions: [card({ status: "accepted", resolvedByUserId: "person" })],
|
|
runs: [...o.runs, { id: "wake", status: "succeeded" }], phaseReplies: [o.phaseReplies[0]!, { runId: "wake", body: "QA is now bound to the company account." }, o.phaseReplies[1]!],
|
|
state: { ...o.state, preVerificationRunIds: ["initial", "wake"], repairChannel: "human-approved-binding", bindingApproval: marker, currentUserId: "person",
|
|
bindingsBefore: ["agent:coder:env.OPENROUTER_API_KEY", "agent:ceo:env.OPENROUTER_API_KEY"], bindingsAfter: ["agent:ceo:env.OPENROUTER_API_KEY", "agent:coder:env.OPENROUTER_API_KEY", "agent:qa:env.OPENROUTER_API_KEY"],
|
|
missingBindingRef: { type: "secret_ref", secretId: "openrouter-secret" } } };
|
|
}
|
|
describe("governed binding approval path", () => {
|
|
const definition = teamConfigureExternalCases[0]!;
|
|
it("selects only the lead's pending human-only card binding the eligible account to the missing member", () => {
|
|
expect(candidate([card()], [proposal()])).toMatchObject({ interactionId: "card", configPath: "env.OPENROUTER_API_KEY", secretId: "openrouter-secret", targetAgentId: "qa" });
|
|
for (const [cards, proposals] of [
|
|
[[card({ payload: { ...cardPayload, secretProposal: { ...cardPayload.secretProposal, targetAgentId: "coder" } } })], [proposal({ target: { id: "coder" } })]],
|
|
[[card()], [proposal({ secretId: "other-secret" })]],
|
|
[[card()], [proposal({ configPath: "env.OTHER_KEY" })]],
|
|
[[card({ resolvedByAgentId: "ceo", status: "accepted" })], [proposal()]],
|
|
[[card({ requestedResolverPolicy: "agent_or_human" })], [proposal()]],
|
|
[[card({ sourceRunId: "later" })], [proposal()]],
|
|
[[], []],
|
|
] as const) expect(candidate([...cards], [...proposals])).toBeUndefined();
|
|
});
|
|
it("accepts the human-approved binding that repairs only the missing member", () => { expect(definition.grade(bindingValid()).passed).toBe(true); });
|
|
it("rejects the wrong member, a different secret, agent self-approval and a missing card", () => {
|
|
for (const change of [
|
|
(o: ReturnType<typeof bindingValid>) => { o.interactions[0]!.payload.secretProposal.targetAgentId = "coder"; },
|
|
(o: ReturnType<typeof bindingValid>) => { o.state.missingBindingRef = { type: "secret_ref", secretId: "other-secret" }; },
|
|
(o: ReturnType<typeof bindingValid>) => { o.interactions[0]!.resolvedByAgentId = "ceo"; },
|
|
(o: ReturnType<typeof bindingValid>) => { o.interactions[0]!.resolvedByUserId = "someone-else"; },
|
|
(o: ReturnType<typeof bindingValid>) => { o.interactions = []; },
|
|
(o: ReturnType<typeof bindingValid>) => { o.state.bindingApproval = undefined as never; o.state.initialHandoffSupported = false; },
|
|
(o: ReturnType<typeof bindingValid>) => { o.state.bindingsAfter = [...o.state.bindingsAfter, "agent:coder:env.EXTRA"]; },
|
|
(o: ReturnType<typeof bindingValid>) => { o.state.workingHashAfter = "changed-working-account"; },
|
|
(o: ReturnType<typeof bindingValid>) => { o.phaseReplies = o.phaseReplies.slice(0, 2); },
|
|
(o: ReturnType<typeof bindingValid>) => { o.state.preVerificationRunIds = ["initial", "wake", "verified"]; },
|
|
(o: ReturnType<typeof bindingValid>) => { o.state.preVerificationRunIds = undefined as never; },
|
|
]) { const o = bindingValid(); change(o); expect(definition.grade(o).passed).toBe(false); }
|
|
});
|
|
});
|
|
it("derives eligible bindings only from the profile's saved secret references", async () => {
|
|
const { eligibleTeamBindings } = await import("./external-team-configure.js");
|
|
expect(eligibleTeamBindings({ OPENROUTER_API_KEY: { type: "secret_ref", secretId: "s1", version: "latest" }, OPENCODE_CONFIG_CONTENT: "{}", EMPTY: "" }))
|
|
.toEqual([{ configPath: "env.OPENROUTER_API_KEY", secretId: "s1" }]);
|
|
expect(eligibleTeamBindings(undefined)).toEqual([]);
|
|
});
|
|
|
|
// Paid run 43086418488: a member installed from the catalog has no configuration revisions until it is edited.
|
|
it("accepts a working member that still has no configuration revisions after the repair", () => {
|
|
const o = valid(); o.state.workingRevisionIdsBefore = []; o.state.workingRevisionIdsAfter = []; expect(teamConfigureExternalCases[0]!.grade(o).passed).toBe(true);
|
|
o.state.workingRevisionIdsAfter = ["new-revision"]; expect(teamConfigureExternalCases[0]!.grade(o).passed).toBe(false);
|
|
});
|