mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-25 16:14:26 +01:00
Merge master and renumber GitHub App setup migration
This commit is contained in:
commit
cf48352c85
79 files changed
+5008
-227
No files matched your search
@@ -37,13 +37,19 @@ provider, or tell the model not to retry. The approval and second-provider
|
||||
prompts remain identical to the original stories. The historical
|
||||
everyday-workflows cases and their original grades remain unchanged.
|
||||
|
||||
Each cell allows one attempt, expects two provider turns, retains a twelve-run
|
||||
Each cell allows one attempt and expects two provider turns (three for choosing
|
||||
Arcade and then granting tool access). Each retains a twelve-run
|
||||
maximum and twelve-minute deadline, and verifies 1,000-cent company and agent
|
||||
hard stops through public records before task creation. All actual runs,
|
||||
usage/cost gaps, controller retries and cleanup must remain in the report.
|
||||
No real third-party mutation occurs. The external-provider decline includes
|
||||
the same deterministic installed Arcade gateway as the positive control, so its
|
||||
zero-call assertion has an actual counter rather than a missing-fixture default.
|
||||
the same deterministic company Arcade gateway as the positive control, with
|
||||
no agent install or allowed tool at task creation. Public effective-access
|
||||
readback verifies that precondition. The positive case selects Arcade, then
|
||||
approves its separate scoped access card through the browser. Only that grant
|
||||
permits the single HubSpot call. Decline has a real zero-call counter.
|
||||
The browser matches the task route and visible identifier, so agent title
|
||||
changes cannot invalidate the checkpoint.
|
||||
|
||||
The new decline oracle requires the saved decision, exactly one interaction,
|
||||
unchanged connection identities, and an explanation after the decision from a
|
||||
@@ -60,7 +66,8 @@ Use the existing report publisher and retained artifact boundary. The suite
|
||||
definition digest includes its prompts, flow, graders, fixture setup and browser
|
||||
submission code. Compare frozen sources under identical fixture/model/budget
|
||||
controls before using it to qualify a production instruction change. See
|
||||
[the connection audit](../../doc/plans/2026-10-06-native-connection-guidance.md).
|
||||
[the connection audit](../../doc/plans/2026-10-06-native-connection-guidance.md) and
|
||||
[the preserved baseline failures and repair](../../doc/plans/2026-10-07-native-connection-baseline-repair.md).
|
||||
|
||||
## Native procedure guidance comparison (explicit only)
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ export async function setupAggregatorFixture(
|
||||
companyId: string,
|
||||
agentId: string,
|
||||
marker: string,
|
||||
requireAccessApproval = false,
|
||||
) {
|
||||
const provider = await startReviewProvider(
|
||||
`Contacts: Ada Fixture. Verification code: ${marker}`,
|
||||
@@ -44,17 +45,26 @@ export async function setupAggregatorFixture(
|
||||
...connected.actions.canMakeChanges,
|
||||
].map((action: any) => action.catalogEntryId),
|
||||
askFirstCatalogEntryIds: [],
|
||||
access: { agentIds: [agentId] },
|
||||
access: { agentIds: requireAccessApproval ? [] : [agentId] },
|
||||
},
|
||||
);
|
||||
const installed = await api.request.put(
|
||||
`/api/tool-connections/${connected.connectionId}/installs`,
|
||||
{ data: { installs: [{ targetType: "agent", targetId: agentId }] } },
|
||||
{ data: { installs: requireAccessApproval ? [] : [{ targetType: "agent", targetId: agentId }] } },
|
||||
);
|
||||
if (!installed.ok())
|
||||
throw new Error("Could not install the aggregator fixture");
|
||||
const effective = await api.get<any>(`/api/companies/${companyId}/tools/profiles/effective/agents/${agentId}`);
|
||||
if (requireAccessApproval && (effective.installedConnections.some((c: any) => c.id === connected.connectionId)
|
||||
|| effective.allowedTools.some((tool: any) => tool.connectionId === connected.connectionId))) {
|
||||
throw new Error("Provider-choice fixture unexpectedly grants tool access before the user's decision");
|
||||
}
|
||||
return {
|
||||
...provider,
|
||||
connectionId: connected.connectionId as string,
|
||||
catalogEntryIds: [...connected.actions.readOnly, ...connected.actions.canMakeChanges].map((action: any) => action.catalogEntryId as string),
|
||||
initialAccess: { installed: effective.installedConnections.some((c: any) => c.id === connected.connectionId),
|
||||
allowedToolIds: effective.allowedTools.filter((tool: any) => tool.connectionId === connected.connectionId).map((tool: any) => tool.id) },
|
||||
invocationCount: () =>
|
||||
provider.captures.filter((call) => call.method === "tools/call").length,
|
||||
};
|
||||
|
||||
@@ -19,6 +19,7 @@ export const connectionGuidanceTasks = cases.map(id => {
|
||||
if (!original) throw new Error("Missing original connection story: " + id);
|
||||
return {
|
||||
...original,
|
||||
expectedRunCount: id === "provider-second" ? 3 : original.expectedRunCount,
|
||||
automaticRetryPolicy: "single_attempt" as const,
|
||||
buildPrompt: (nonce: string) => connectionGuidanceDeclinePrompts[id] ?? original.buildPrompt(nonce),
|
||||
};
|
||||
@@ -26,7 +27,7 @@ export const connectionGuidanceTasks = cases.map(id => {
|
||||
|
||||
export function connectionGuidanceDefinitionDigest() {
|
||||
const files = [
|
||||
"connection-guidance-cases.ts", "connection-guidance-evidence.ts",
|
||||
"connection-guidance-cases.ts", "connection-guidance-evidence.ts", "continuation-screenshot.ts",
|
||||
"everyday-cases.ts", "everyday-flow.ts", "everyday-decisions.ts",
|
||||
"everyday-observations.ts", "everyday-delivery.ts",
|
||||
"connection-routing-evidence.ts", "connection-reviews.ts", "aggregator-fixture.ts",
|
||||
|
||||
@@ -40,7 +40,7 @@ export function gradeConnectionGuidanceDecline(input: {
|
||||
Boolean(reply.createdByRunId) && run.id === reply.createdByRunId && run.agentId === input.leadAgentId && run.nativeIssueId === input.issueId &&
|
||||
run.status === "succeeded" && Date.parse(run.finishedAt ?? "") >= resolvedAt));
|
||||
const explainsUnavailable = (text: string) =>
|
||||
/declin|not now|could(?:n.t| not)|cannot|can.t|unable|unavailable|not (?:connect|retriev)|without (?:access|connect)/i.test(text);
|
||||
/declin|not now|could(?:n.t| not)|cannot|can.t|unable|unavailable|not (?:connect|retriev)|without (?:access|connect)|\b(?:is|are)n['’]t\s+(?:connect|retriev|available)/i.test(text);
|
||||
return [
|
||||
{ id: "guidance-decline-decision", passed: validDecision && input.decisions.length === 1,
|
||||
detail: "Exactly one correctly typed, resolved decline belongs to the selected decision." },
|
||||
|
||||
@@ -14,7 +14,7 @@ describe("neutral connection guidance selection", () => {
|
||||
expect(row.environment.id).toBe("local");
|
||||
expect(row.task.automaticRetryPolicy).toBe("single_attempt");
|
||||
expect(row.task.attemptTimeoutMs.local).toBe(720_000);
|
||||
expect(row.task.expectedRunCount).toBe(2);
|
||||
expect(row.task.expectedRunCount).toBe(row.task.id === "provider-second" ? 3 : 2);
|
||||
}
|
||||
for (const args of [["--all"], ["--profile", "runner-opencode"]]) {
|
||||
expect(selectRunnerExecutions(parseRunnerSelectors(args), runnerMatrix).some(row => row.suite.id === CONNECTION_GUIDANCE_SUITE)).toBe(false);
|
||||
@@ -54,6 +54,16 @@ describe("neutral decline evidence", () => {
|
||||
expect(passes({ ...valid, caseId, decisions: [{ ...valid.decisions[0], kind, status: "rejected" }] })).toBe(true);
|
||||
}
|
||||
});
|
||||
it("recognizes unavailable-connection contractions without accepting positive or unrelated claims", () => {
|
||||
for (const body of [
|
||||
"HubSpot isn't connected because you chose None for now.",
|
||||
"HubSpot isn’t connected after the provider decision.",
|
||||
"The pages aren't retrievable after the connection decision.",
|
||||
]) expect(passes({ ...valid, replies: [{ ...valid.replies[0], body }] })).toBe(true);
|
||||
for (const body of ["HubSpot is connected.", "HubSpot isn't disconnected.", "HubSpot isn't slow.", "Contacts are available."]) {
|
||||
expect(passes({ ...valid, replies: [{ ...valid.replies[0], body }] })).toBe(false);
|
||||
}
|
||||
});
|
||||
it("rejects missing, stale, unattributed, wrong-agent, or unsuccessful explanations", () => {
|
||||
for (const input of [
|
||||
{ ...valid, replies: [] },
|
||||
@@ -88,3 +98,33 @@ describe("neutral decline evidence", () => {
|
||||
]) expect(passes(input)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
import { requireProviderAccessCard, gradeProviderOutcome } from "./connection-routing-evidence.js";
|
||||
const access = { id: "access", kind: "connection_intent", status: "pending", payload: {
|
||||
serviceSlug: "arcade", requestingAgentId: "lead", upstreamService: { slug: "hubspot", selectionInteractionId: "choice" },
|
||||
accessRequest: { connectionId: "connection", tools: [{ catalogEntryId: "tool", toolName: "Hubspot_ListContacts", permission: "allowed" }] },
|
||||
} };
|
||||
const accessInput = { rows: [{ id: "choice", kind: "ask_user_questions", status: "answered" }, access],
|
||||
decisionId: "choice", connectionId: "connection", agentId: "lead", catalogEntryIds: ["tool"], calls: 0 };
|
||||
it("requires the exact scoped access card and rejects early calls, swapped identities and duplicates", () => {
|
||||
expect(requireProviderAccessCard(accessInput)).toBe(access);
|
||||
for (const input of [
|
||||
{ ...accessInput, rows: [] }, { ...accessInput, calls: 1 }, { ...accessInput, catalogEntryIds: [] },
|
||||
{ ...accessInput, connectionId: "other" }, { ...accessInput, agentId: "other" }, { ...accessInput, decisionId: "other" },
|
||||
{ ...accessInput, rows: [...accessInput.rows, access] },
|
||||
{ ...accessInput, rows: [accessInput.rows[0], { ...access, status: "accepted" }] },
|
||||
{ ...accessInput, rows: [accessInput.rows[0], { ...access, payload: { ...access.payload, upstreamService: { slug: "hubspot", selectionInteractionId: "other" } } }] },
|
||||
]) expect(() => requireProviderAccessCard(input)).toThrow();
|
||||
});
|
||||
it("requires the real accepted access result without allowing repeated provider questions", () => {
|
||||
const choice = { id: "choice", kind: "ask_user_questions", status: "answered", result: { answers: [{ questionId: "connection-provider:hubspot", optionIds: ["via:arcade:hubspot"] }] } };
|
||||
const granted = { ...access, status: "accepted", result: { outcome: "connected", connectionId: "connection" } };
|
||||
const input = { rows: [choice, granted], decisionId: "choice", selected: "via:arcade:hubspot", calls: 1,
|
||||
response: "Ada Fixture MARKER", marker: "MARKER", sameConnections: true, accessDecision: { id: "access", connectionId: "connection" } };
|
||||
expect(gradeProviderOutcome(input).every(c => c.passed)).toBe(true);
|
||||
for (const bad of [{ ...input, rows: [choice] }, { ...input, rows: [choice, granted, choice] },
|
||||
{ ...input, rows: [choice, { ...granted, status: "pending" }] }, { ...input, accessDecision: { id: "access", connectionId: "other" } },
|
||||
{ ...input, calls: 0 }, { ...input, calls: 2 }, { ...input, response: "Done" }])
|
||||
expect(gradeProviderOutcome(bad).every(c => c.passed)).toBe(false);
|
||||
});
|
||||
@@ -43,6 +43,7 @@ export function gradeProviderOutcome(input: {
|
||||
response: string;
|
||||
marker: string;
|
||||
sameConnections: boolean;
|
||||
accessDecision?: { id: string; connectionId: string };
|
||||
}) {
|
||||
const decision = input.rows.find((row) => row.id === input.decisionId);
|
||||
const selected = decision?.result?.answers?.find(
|
||||
@@ -58,8 +59,12 @@ export function gradeProviderOutcome(input: {
|
||||
},
|
||||
{
|
||||
id: "provider-no-extra-setup",
|
||||
passed: input.rows.length === 1 && input.sameConnections,
|
||||
detail: "No replacement question or unnecessary connection was created.",
|
||||
passed: input.sameConnections && (input.accessDecision
|
||||
? input.rows.length === 2 && input.rows.some(row => row.id === input.accessDecision!.id
|
||||
&& row.kind === "connection_intent" && row.status === "accepted"
|
||||
&& row.result?.outcome === "connected" && row.result?.connectionId === input.accessDecision!.connectionId)
|
||||
: input.rows.length === 1),
|
||||
detail: "Only the selected provider and, when needed, its separate approved access card were used; no connection was replaced.",
|
||||
},
|
||||
{
|
||||
id: "provider-use-matches-choice",
|
||||
@@ -72,3 +77,26 @@ export function gradeProviderOutcome(input: {
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** The provider preference is not an app/tool grant. Require the separate, scoped access card. */
|
||||
export function requireProviderAccessCard(input: {
|
||||
rows: Array<{ id: string; kind: string; status: string; payload?: any }>;
|
||||
decisionId: string; connectionId: string; agentId: string; catalogEntryIds: string[]; calls: number;
|
||||
}) {
|
||||
const cards = input.rows.filter(row => row.id !== input.decisionId);
|
||||
const card = cards[0];
|
||||
const payload = card?.payload;
|
||||
const tools = payload?.accessRequest?.tools;
|
||||
if (input.calls !== 0 || input.rows.length !== 2 || cards.length !== 1 || card?.kind !== "connection_intent"
|
||||
|| card.status !== "pending" || payload?.serviceSlug !== "arcade"
|
||||
|| payload.requestingAgentId !== input.agentId
|
||||
|| payload.upstreamService?.selectionInteractionId !== input.decisionId
|
||||
|| payload.upstreamService?.slug !== "hubspot"
|
||||
|| payload.accessRequest?.connectionId !== input.connectionId
|
||||
|| !Array.isArray(tools) || tools.length !== 1 || tools[0].toolName !== "Hubspot_ListContacts"
|
||||
|| tools[0].permission !== "allowed" || input.catalogEntryIds.length !== 1
|
||||
|| tools[0].catalogEntryId !== input.catalogEntryIds[0]) {
|
||||
throw new Error("Expected one scoped Arcade access card after the saved provider choice, before any provider call");
|
||||
}
|
||||
return card;
|
||||
}
|
||||
@@ -13,6 +13,15 @@ export async function captureLoadedContinuation(
|
||||
await capture();
|
||||
}
|
||||
|
||||
/** A task title is mutable while an agent runs. Match the route and visible stable identifier. */
|
||||
export async function waitForTaskIdentity(page: Page, taskPath: string, identifier: string, timeout = 30_000) {
|
||||
await expect(page).toHaveURL(url => url.pathname === taskPath, { timeout });
|
||||
const currentIdentifier = page.getByRole("navigation", { name: "breadcrumb" })
|
||||
.locator('[aria-current="page"] [data-slot="task-title-identifier"]');
|
||||
await expect(currentIdentifier).toBeVisible({ timeout });
|
||||
await expect(currentIdentifier).toHaveText(identifier, { timeout });
|
||||
}
|
||||
|
||||
/** Wait for the persisted task projection before taking a browser screenshot. */
|
||||
export async function waitForTaskChatRendered(
|
||||
page: Page,
|
||||
|
||||
@@ -17,10 +17,10 @@ import type { LiveFixtureValues } from "./live-fixtures.js";
|
||||
import type { MatrixExecution } from "./types.js";
|
||||
import { submitTaskReply } from "./user-actions.js";
|
||||
import { createTaskFromPromptThroughUi } from "./plan-task-ui.js";
|
||||
import { waitForTaskChatRendered } from "./continuation-screenshot.js";
|
||||
import { waitForTaskChatRendered, waitForTaskIdentity } from "./continuation-screenshot.js";
|
||||
import { hasPersistedSource, isSavedSourceCheckpoint } from "./everyday-interruption.js";
|
||||
import { setupAggregatorFixture } from "./aggregator-fixture.js";
|
||||
import { gradeProviderChoice, gradeProviderOutcome } from "./connection-routing-evidence.js";
|
||||
import { gradeProviderChoice, gradeProviderOutcome, requireProviderAccessCard } from "./connection-routing-evidence.js";
|
||||
import { setupConnectionReview } from "./connection-reviews.js";
|
||||
import {
|
||||
pendingStoryDecision,
|
||||
@@ -41,6 +41,7 @@ import {
|
||||
storyReviewContinuationTimeoutDetail,
|
||||
storyHasStrandedBlockedLeaf,
|
||||
storyHasDurableAgentReviewContinuation,
|
||||
storyHasDurableServiceContinuation,
|
||||
storyIssueHasBlockedTimelineBefore,
|
||||
storyIssueHasUnresolvedDependency,
|
||||
storyRunReportsDependencyBlock,
|
||||
@@ -172,6 +173,7 @@ export async function runEverydayFlow(input: Input) {
|
||||
let decisionId: string | undefined;
|
||||
let decisionResolvedAt: string | undefined;
|
||||
let initialConnections: string[] = [];
|
||||
let providerAccessDecision: { id: string; connectionId: string } | undefined;
|
||||
let stoppedWorkspace: Record<string, string> | undefined;
|
||||
let settledAgentReply: Row | undefined;
|
||||
let reviewHandoffBoundary: {
|
||||
@@ -245,11 +247,11 @@ export async function runEverydayFlow(input: Input) {
|
||||
`/${prefix}/issues/${issue.identifier ?? issue.id}`;
|
||||
async function openTask(issue: StoryIssue) {
|
||||
await page.goto(taskUrl(issue), { waitUntil: "domcontentloaded" });
|
||||
await waitForTaskIdentity(page, taskUrl(issue), issue.identifier ?? issue.id);
|
||||
if (providerChoice || nativeProviderCase) {
|
||||
await expect(page.locator('[data-testid="task-chat-thread"], [data-testid="thread-root"]').first()).toBeVisible({timeout:30_000});
|
||||
await expect(page.getByRole("heading", {name:String(issue.title),exact:true})).toBeVisible();
|
||||
await expect(page.getByTestId("issue-chat-skeleton")).toHaveCount(0);
|
||||
} else await waitForTaskChatRendered(page, String(issue.title));
|
||||
} else await waitForTaskChatRendered(page);
|
||||
}
|
||||
async function openParent() {
|
||||
await openTask(parent!);
|
||||
@@ -303,11 +305,12 @@ export async function runEverydayFlow(input: Input) {
|
||||
const settledState = await pollUntil({
|
||||
label: `everyday ${caseId} settled`,
|
||||
deadlineAt: input.deadlineAt,
|
||||
timeoutDetail: (state) => state &&
|
||||
timeoutDetail: (state) => state && (
|
||||
storyReviewContinuationTimeoutDetail(
|
||||
state.issues, parent?.id ?? "", fixtures.agent.id, state.runs,
|
||||
observableAgentIds(state),
|
||||
),
|
||||
) ?? (storyHasDurableServiceContinuation(state.issues, parent?.id ?? "", fixtures.agent.id, state.runs)
|
||||
? "task is Blocked without an active continuation after executed service approval" : undefined)),
|
||||
intervalMs: 1000,
|
||||
load: refresh,
|
||||
accept: (state) =>
|
||||
@@ -345,7 +348,8 @@ export async function runEverydayFlow(input: Input) {
|
||||
parent?.id ?? "",
|
||||
fixtures.agent.id,
|
||||
state.runs,
|
||||
)
|
||||
) &&
|
||||
!storyHasDurableServiceContinuation(state.issues, parent?.id ?? "", fixtures.agent.id, state.runs)
|
||||
)
|
||||
return "task is Blocked without an active continuation";
|
||||
if (
|
||||
@@ -667,9 +671,14 @@ export async function runEverydayFlow(input: Input) {
|
||||
authenticated: true,
|
||||
});
|
||||
if (providerChoice || nativeProviderCase || (execution.suite.id === CONNECTION_GUIDANCE_SUITE && Boolean(review))) {
|
||||
if (caseId === "provider-second" || (execution.suite.id === CONNECTION_GUIDANCE_SUITE && caseId === "provider-decline")) aggregatorFixture = await setupAggregatorFixture(api, fixtures.company.id, fixtures.agent.id, `CONTACTS_${nonce}`);
|
||||
if (caseId === "provider-second" || (execution.suite.id === CONNECTION_GUIDANCE_SUITE && caseId === "provider-decline")) aggregatorFixture = await setupAggregatorFixture(api, fixtures.company.id, fixtures.agent.id, `CONTACTS_${nonce}`, execution.suite.id === CONNECTION_GUIDANCE_SUITE);
|
||||
const state = await api.get<{connections:Row[]}>(`/api/companies/${fixtures.company.id}/tools/connections`);
|
||||
initialConnections = state.connections.map(c=>c.id);
|
||||
if (aggregatorFixture && execution.suite.id === CONNECTION_GUIDANCE_SUITE) {
|
||||
await input.evidence("provider-initial-access.json", aggregatorFixture.initialAccess);
|
||||
check("provider-not-installed-before-choice", !aggregatorFixture.initialAccess.installed && aggregatorFixture.initialAccess.allowedToolIds.length === 0,
|
||||
"The company connection is configured, but this agent has no installed or allowed HubSpot tool before the decision.");
|
||||
}
|
||||
}
|
||||
if (agentmailSetup) await api.patch("/api/instance/settings/experimental", { enableChatConnectors: true });
|
||||
if (decliningConnection) {
|
||||
@@ -928,6 +937,37 @@ export async function runEverydayFlow(input: Input) {
|
||||
accept:rows=>rows.some(row=>row.id===decisionId && row.status==="answered"),
|
||||
});
|
||||
note("provider-choice-submitted", {interactionId:decisionId, selected:caseId === "provider-decline" ? "none" : "via:arcade:hubspot"});
|
||||
if (execution.suite.id === CONNECTION_GUIDANCE_SUITE && caseId === "provider-second") {
|
||||
const rows = await pollUntil({
|
||||
label: "selected Arcade access request", deadlineAt: input.deadlineAt,
|
||||
load: async () => ({
|
||||
rows: await api.get<Row[]>(`/api/issues/${parent!.id}/interactions`),
|
||||
issue: await api.get<StoryIssue>(`/api/issues/${parent!.id}`),
|
||||
calls: aggregatorFixture!.invocationCount(),
|
||||
runs: await api.get<StoryRun[]>(`/api/issues/${parent!.id}/runs`),
|
||||
}),
|
||||
accept: state => state.rows.some(row => row.id !== decisionId && row.status === "pending"),
|
||||
reject: state => state.calls > 0 ? "Provider ran before tool-access approval"
|
||||
: state.runs.some(run => ["failed", "timed_out"].includes(run.status)) ? "Agent failed before tool-access approval"
|
||||
: ["done", "blocked", "cancelled"].includes(state.issue.status) ? "Task ended without the required access request" : undefined,
|
||||
});
|
||||
const card = requireProviderAccessCard({ rows: rows.rows as any, decisionId: decisionId!, connectionId: aggregatorFixture!.connectionId,
|
||||
agentId: fixtures.agent.id, catalogEntryIds: aggregatorFixture!.catalogEntryIds, calls: rows.calls });
|
||||
providerAccessDecision = { id: card.id, connectionId: aggregatorFixture!.connectionId };
|
||||
await openParent();
|
||||
const accessCard = page.getByTestId("connection-intent-access-request");
|
||||
await expect(accessCard).toHaveCount(1);
|
||||
await expect(accessCard.getByText("Hubspot_ListContacts", { exact: true })).toBeVisible();
|
||||
await input.capture("provider-access", "Separate HubSpot tool-access approval", "provider-access.png");
|
||||
check("no-call-before-provider-access", aggregatorFixture!.invocationCount() === 0, "Selecting a provider alone did not expose or execute its tool.");
|
||||
await accessCard.getByRole("button", { name: "Grant access", exact: true }).click();
|
||||
await pollUntil({ label: "Arcade access grant saved", deadlineAt: input.deadlineAt,
|
||||
load: () => api.get<Row[]>(`/api/issues/${parent!.id}/interactions`),
|
||||
accept: rows => rows.some(row => row.id === card.id && row.status === "accepted"
|
||||
&& row.result?.connectionId === aggregatorFixture!.connectionId),
|
||||
});
|
||||
note("provider-access-granted", { interactionId: card.id, connectionId: aggregatorFixture!.connectionId });
|
||||
}
|
||||
}
|
||||
if (review || decliningConnection) {
|
||||
const interactions = await pollUntil({
|
||||
@@ -1127,7 +1167,7 @@ export async function runEverydayFlow(input: Input) {
|
||||
if (providerChoice) {
|
||||
const issue = ev.issues.find(i=>i.id===parent!.id)!;
|
||||
const state = await api.get<{connections:Row[]}>(`/api/companies/${fixtures.company.id}/tools/connections`);
|
||||
ev.checks.push(...gradeProviderOutcome({rows:issue.interactions as any, decisionId:decisionId!,
|
||||
ev.checks.push(...gradeProviderOutcome({rows:issue.interactions as any, decisionId:decisionId!, accessDecision:providerAccessDecision,
|
||||
selected:caseId === "provider-decline" ? "none" : "via:arcade:hubspot", calls:aggregatorFixture?.invocationCount() ?? 0,
|
||||
response: (issue.comments ?? []).filter((c:Row)=>c.authorAgentId).map((c:Row)=>c.body).join("\n"), marker:`CONTACTS_${nonce}`,
|
||||
sameConnections:isDeepStrictEqual(state.connections.map(c=>c.id).sort(), initialConnections.sort()),
|
||||
@@ -1546,7 +1586,10 @@ export async function runEverydayFlow(input: Input) {
|
||||
"No completion confirmation or unanswered interaction remains.",
|
||||
);
|
||||
if (providerChoice || nativeProviderCase) await openParent();
|
||||
else await waitForTaskChatRendered(page, String(parent!.title));
|
||||
else {
|
||||
await waitForTaskIdentity(page, taskUrl(parent!), parent!.identifier ?? parent!.id);
|
||||
await waitForTaskChatRendered(page);
|
||||
}
|
||||
const latestAgentComment = ev.issues
|
||||
.find((i) => i.id === parent!.id)
|
||||
?.comments?.filter((c: Row) => c.authorAgentId)
|
||||
|
||||
@@ -37,6 +37,8 @@ export interface StoryActivityRecord {
|
||||
createdAt?: string;
|
||||
}
|
||||
export interface StoryInteraction {
|
||||
sourceRunId?: string | null;
|
||||
createdByAgentId?: string | null;
|
||||
id?: string;
|
||||
kind?: string;
|
||||
issueId?: string | null;
|
||||
@@ -443,6 +445,32 @@ export function storyHasDurableAgentReviewContinuation(
|
||||
);
|
||||
}
|
||||
|
||||
/** An executed approval may enqueue its wake just after run finalization.
|
||||
* Wait within the original deadline only for this task/run's recorded response.
|
||||
* Once a follow-up run has consumed it, a new blocker is a real failure.
|
||||
*/
|
||||
export function storyHasDurableServiceContinuation(issues: StoryIssue[], parentId: string, agentId: string, runs: StoryRun[]): boolean {
|
||||
const issue = issues.find(i => i.id === parentId);
|
||||
if (issue?.status !== "blocked" || issue.assigneeAgentId !== agentId) return false;
|
||||
return issue.interactions?.some(interaction => {
|
||||
const source = runs.find(run => run.id === interaction.sourceRunId);
|
||||
const action = interaction.payload?.toolAction as Record<string, unknown> | undefined;
|
||||
const result = interaction.result?.toolAction as Record<string, unknown> | undefined;
|
||||
if (interaction.issueId !== parentId || interaction.createdByAgentId !== agentId ||
|
||||
interaction.kind !== "request_confirmation" || interaction.continuationPolicy !== "wake_assignee" ||
|
||||
interaction.status !== "accepted" || interaction.result?.outcome !== "accepted" ||
|
||||
action?.version !== 1 || typeof action.actionRequestId !== "string" || result?.status !== "executed" ||
|
||||
source?.agentId !== agentId || source.companyId !== issue.companyId || source.status !== "succeeded" ||
|
||||
!(Date.parse(source.finishedAt ?? "") >= Date.parse(interaction.resolvedAt ?? ""))) return false;
|
||||
return !runs.some(run => {
|
||||
const input = run.runnerProfileJson?.nativeExecutionInput as
|
||||
{ interactionResponses?: Array<{ interactionId?: string }> } | undefined;
|
||||
return run.id !== source.id && run.agentId === agentId &&
|
||||
input?.interactionResponses?.some(response => response.interactionId === interaction.id);
|
||||
});
|
||||
}) ?? false;
|
||||
}
|
||||
|
||||
/** Timeout evidence requires a stranded leaf with durable accepted-review evidence. */
|
||||
export function storyReviewContinuationTimeoutDetail(
|
||||
issues: StoryIssue[],
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
import { captureLoadedContinuation } from "./continuation-screenshot.js";
|
||||
import { captureLoadedContinuation, waitForTaskIdentity, waitForTaskChatRendered } from "./continuation-screenshot.js";
|
||||
|
||||
const shell = (busy: boolean, title = "Continuation example") => `
|
||||
<main data-testid="task-chat-thread"><div aria-busy="${busy}">
|
||||
@@ -31,3 +31,19 @@ for (const state of ["app-loader", "history-loader", "wrong-task"] as const) {
|
||||
expect(captures).toBe(0);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
test("mutable titles do not change task identity, but wrong routes and identifiers fail", async ({ page }) => {
|
||||
await page.route("https://fixture.invalid/**", route => route.fulfill({ contentType: "text/html",
|
||||
body: `<nav aria-label="breadcrumb"><span aria-current="page"><span>Renamed task</span><span data-slot="task-title-identifier">RUN-1</span></span></nav>${shell(false, "Renamed task")}` }));
|
||||
await page.goto("https://fixture.invalid/RUN/issues/RUN-1");
|
||||
await waitForTaskIdentity(page, "/RUN/issues/RUN-1", "RUN-1", 500);
|
||||
await waitForTaskChatRendered(page, undefined, 500);
|
||||
for (const [route, identifier] of [["/RUN/issues/RUN-2", "RUN-1"], ["/RUN/issues/RUN-1", "RUN-2"], ["/RUN/issues/RUN-1", "RUN"]]) {
|
||||
await expect(waitForTaskIdentity(page, route, identifier, 150)).rejects.toThrow();
|
||||
}
|
||||
await expect(waitForTaskChatRendered(page, "Original task title", 150)).rejects.toThrow();
|
||||
// An identifier in the mutable title or outside the breadcrumb is not identity.
|
||||
await page.setContent(`<nav aria-label="breadcrumb"><span aria-current="page"><span>RUN-1 renamed task</span><span data-slot="task-title-identifier">RUN-2</span></span></nav><span data-slot="task-title-identifier">RUN-1</span>${shell(false)}`);
|
||||
await expect(waitForTaskIdentity(page, "/RUN/issues/RUN-1", "RUN-1", 150)).rejects.toThrow();
|
||||
});
|
||||
@@ -1,7 +1,7 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { pollUntil } from "./api.js";
|
||||
import { classifyFailure } from "./failure-classifier.js";
|
||||
import { storyHasDurableAgentReviewContinuation, storyHasStrandedBlockedLeaf, storyReviewContinuationTimeoutDetail, type StoryIssue } from "./everyday-observations.js";
|
||||
import { storyHasDurableServiceContinuation, storyHasDurableAgentReviewContinuation, storyHasStrandedBlockedLeaf, storyReviewContinuationTimeoutDetail, type StoryIssue } from "./everyday-observations.js";
|
||||
|
||||
describe("workflow timeout classification", () => {
|
||||
it("does not classify observed task data as an infrastructure error", async () => {
|
||||
@@ -145,3 +145,40 @@ describe("review continuation deadline", () => {
|
||||
} finally { vi.useRealTimers(); }
|
||||
});
|
||||
});
|
||||
|
||||
describe("approved service continuation deadline", () => {
|
||||
it.each([true, false])("keeps the original deadline for a delayed dispatch (arrives: %s)", async arrives => {
|
||||
vi.useFakeTimers();
|
||||
try {
|
||||
const start = Date.now();
|
||||
const issues: StoryIssue[] = [{ id: "task", companyId: "company", title: "Briefing", status: "blocked", assigneeAgentId: "agent", interactions: [{
|
||||
id: "approval", issueId: "task", sourceRunId: "first", createdByAgentId: "agent", kind: "request_confirmation", status: "accepted", continuationPolicy: "wake_assignee",
|
||||
resolvedAt: new Date(start - 1000).toISOString(), payload: { toolAction: { version: 1, actionRequestId: "action" } }, result: { outcome: "accepted", toolAction: { status: "executed" } },
|
||||
}] }];
|
||||
const runs = [{ id: "first", companyId: "company", agentId: "agent", status: "succeeded", finishedAt: new Date(start).toISOString() }];
|
||||
const caught = pollUntil({ label: "service continuation", deadlineAt: start + 30_000, intervalMs: 1000,
|
||||
load: async () => { if (arrives && Date.now() >= start + 20_000) issues[0]!.status = "done"; return { issues, runs }; },
|
||||
accept: state => state.issues[0]!.status === "done",
|
||||
reject: state => storyHasStrandedBlockedLeaf(state.issues, "agent") && !storyHasDurableServiceContinuation(state.issues, "task", "agent", state.runs) ? "stranded" : undefined,
|
||||
timeoutDetail: state => state && storyHasDurableServiceContinuation(state.issues, "task", "agent", state.runs) ? "missing service continuation" : undefined,
|
||||
}).catch((error: unknown) => error);
|
||||
await vi.advanceTimersByTimeAsync(30_001);
|
||||
const result = await caught;
|
||||
if (arrives) expect(result).toEqual({ issues, runs });
|
||||
else { expect((result as Error).message).toContain("missing service continuation"); expect(classifyFailure(result)).toBe("candidate_failure"); }
|
||||
} finally { vi.useRealTimers(); }
|
||||
});
|
||||
it("waits for dispatch only until the same response has been consumed", () => {
|
||||
const issues: StoryIssue[] = [{ id: "task", companyId: "company", title: "Briefing", status: "blocked", assigneeAgentId: "agent", interactions: [{
|
||||
id: "approval", issueId: "task", sourceRunId: "first", createdByAgentId: "agent", kind: "request_confirmation", status: "accepted", continuationPolicy: "wake_assignee",
|
||||
resolvedAt: "2026-10-07T05:37:19Z", payload: { toolAction: { version: 1, actionRequestId: "action" } }, result: { outcome: "accepted", toolAction: { status: "executed" } },
|
||||
}] }];
|
||||
const runs = [{ id: "first", companyId: "company", agentId: "agent", status: "succeeded", finishedAt: "2026-10-07T05:37:28Z" }];
|
||||
expect(storyHasDurableServiceContinuation(issues, "task", "agent", runs)).toBe(true);
|
||||
expect(storyHasDurableServiceContinuation(issues, "task", "other", runs)).toBe(false);
|
||||
const continued = [...runs, { id: "next", companyId: "company", agentId: "agent", status: "succeeded", runnerProfileJson: { nativeExecutionInput: { interactionResponses: [{ interactionId: "approval" }] } } }];
|
||||
expect(storyHasDurableServiceContinuation(issues, "task", "agent", continued)).toBe(false);
|
||||
issues[0]!.interactions![0]!.result = { outcome: "accepted", toolAction: { status: "failed" } };
|
||||
expect(storyHasDurableServiceContinuation(issues, "task", "agent", runs)).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user