mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-04 12:50:37 +01:00
Merge commit '8cd2d6a73d2097253dd329f55b637e12b20361c6' into codex/photon-managed-lock-policy
* commit '8cd2d6a73d2097253dd329f55b637e12b20361c6': docs(skills): add aggregate-bound, lost-runner, and bug-class lessons to fix-failed-paperclip-run (#21745) fix(comments): keep saved authorization cards from blocking replies (#21744) fix(server): wake a delivery task unscoped when it cannot apply settled hints (#21686) refactor: split the runner-e2e and restart-chaos READMEs into a runbook and a catalog (#21743)
This commit is contained in:
commit
6386390f05
23 files changed
+5216
-4965
No files matched your search
@@ -17,7 +17,8 @@ workspace roots such as `~/paperclipai/paperclip`; verify the selected root
|
||||
contains `tests/runner-e2e` and `packages/paperclip-runner`. Run commands from
|
||||
that repository root. The copied skill may live outside the checkout.
|
||||
Read `doc/evals.md`, then the authoritative
|
||||
`tests/runner-e2e/README.md`, `FIXTURES.md`, `SECURITY.md`, and
|
||||
`tests/runner-e2e/README.md`, the suite's section in `SUITES.md`,
|
||||
`FIXTURES.md`, `SECURITY.md`, and
|
||||
`EVERYDAY-WORKFLOWS.md` for the selected area. Inspect the nearest existing
|
||||
catalog entry, case, harness flow, matcher, evidence writer, and report test
|
||||
before changing anything. Keep the user journey on production browser/API
|
||||
|
||||
@@ -132,6 +132,9 @@ the evidence requires. Avoid historical string allowlists, swallowed errors,
|
||||
unbounded retries, or relaxing an integrity check to accommodate malformed input.
|
||||
Preserve the requested model, trust, isolation, and performance behavior unless a
|
||||
change or explicit fallback policy is part of the assignment.
|
||||
A repair that makes recovery start more runs must state its worst-case starts per
|
||||
hour across the company during an outage (provider refusing, crash loop, deploy)
|
||||
and what bounds them; per-task caps do not bound the aggregate.
|
||||
|
||||
Before implementation, state the behavioral rule and the strongest plausible
|
||||
second-order failure. Trace callers, downstream consumers, persisted state, and
|
||||
@@ -207,6 +210,11 @@ address review and CI failures, and inspect required checks and review on the
|
||||
current head SHA. Pending, skipped, and passing are distinct. Retry a failed check
|
||||
only with a reason; retain its evidence and fix repeatable failures. Resolve
|
||||
companion repository/artifact changes needed by the fix and state their ordering.
|
||||
A job whose log shows the runner shut down or lost communication is lost
|
||||
infrastructure: re-run it. A cancellation without that evidence may be deliberate. A test failing in a file the PR does not touch gets one re-run; if it
|
||||
repeats, check master and tell the test's owner. When review finds one instance of
|
||||
a bug class, enumerate and test every entry point or counter of that class before
|
||||
pushing again.
|
||||
|
||||
The PR must explain the causal defect, behavioral change, failing-before/passing-
|
||||
after evidence, safety regressions, actual acceptance environment, and limitations.
|
||||
|
||||
@@ -28,7 +28,8 @@ mock control plane. Authoritative details are in
|
||||
|
||||
Choose **Product E2E Evals** for real browser/server/database/runner/provider
|
||||
workflows, including local and Daytona environments. Read
|
||||
`tests/runner-e2e/README.md`, then `FIXTURES.md`, `SECURITY.md`, or
|
||||
`tests/runner-e2e/README.md`, then the suite's section in `SUITES.md`,
|
||||
`FIXTURES.md`, `SECURITY.md`, or
|
||||
`EVERYDAY-WORKFLOWS.md` as relevant. Everyday Workflows remain Product E2E
|
||||
even when imported into Evalbook. “Headless” is a browser mode, not a family.
|
||||
|
||||
|
||||
+24
-24
@@ -26,14 +26,14 @@ Selection fails closed until TestOps-assigned identities are committed; see the
|
||||
|
||||
The explicit deployment-targeted [saved agent instructions journey](../tests/runner-e2e/product-journeys/AGENT-SETTINGS.md) checks an owned agent’s ordinary UI save, persisted instruction bytes, one current-run output, and restoration. The task request omits its instruction-only reference. It reuses the existing Product E2E target and report path; local controls do not establish a staging pass.
|
||||
|
||||
The explicit-only [verified API artifact transfer](../tests/runner-e2e/README.md#verified-api-artifact-transfer)
|
||||
The explicit-only [verified API artifact transfer](../tests/runner-e2e/SUITES.md#verified-api-artifact-transfer)
|
||||
cell checks a native Codex agent on Daytona installing an authorized saved API
|
||||
response and delivering unchanged bytes. The oracle binds the source capture,
|
||||
tool completion and independent attachment download, including the complete
|
||||
388131-byte synthetic description. Registration and oracle calibration are
|
||||
separate from live provider qualification.
|
||||
|
||||
The explicit-only [Kimi Code qualification suite](../tests/runner-e2e/README.md#kimi-code-qualification)
|
||||
The explicit-only [Kimi Code qualification suite](../tests/runner-e2e/SUITES.md#kimi-code-qualification)
|
||||
registers twenty candidate cells across local and Daytona. It reuses the
|
||||
browser, semantic interaction, file/artifact, Stop and continuation oracles with
|
||||
scoped candidate admission and an encrypted Code credential. Registration does
|
||||
@@ -77,7 +77,7 @@ existing campaigns. Private Cloud bundles are rejected. The output contains
|
||||
only index HTML and history/pointer JSON; it does not upload evidence or change
|
||||
retained campaign bundles.
|
||||
|
||||
The explicit-only [Cursor Cloud native cells](../tests/runner-e2e/README.md)
|
||||
The explicit-only [Cursor Cloud native cells](../tests/runner-e2e/SUITES.md)
|
||||
cover task/artifact delivery, same-agent follow-up, active-run UI Stop and
|
||||
semantic Plan revision/approval from a local controller. They require explicit
|
||||
model/repository/key and a callback-only
|
||||
@@ -100,7 +100,7 @@ from master. Registration, known gaps and private prerequisites remain distinct
|
||||
from measured results. This lane does not qualify the current master app or reset
|
||||
earlier campaign accounting.
|
||||
|
||||
The explicit-only [Daytona restart continuity journey](../tests/runner-e2e/README.md)
|
||||
The explicit-only [Daytona restart continuity journey](../tests/runner-e2e/SUITES.md)
|
||||
extends the existing native restart oracle to a 300-second controller outage
|
||||
and another replacement after completion, using the recorded Claude and Codex
|
||||
models in disposable development fixtures.
|
||||
@@ -125,7 +125,7 @@ native API mutation receipt. It does not qualify named-tool selection. Its provi
|
||||
usage and cleanup. Registration and local calibration do not establish a fresh
|
||||
Cloud pass or inclusion in a recurring selection.
|
||||
|
||||
The explicit-only [necessary free-text question journey](../tests/runner-e2e/README.md#necessary-free-text-question)
|
||||
The explicit-only [necessary free-text question journey](../tests/runner-e2e/SUITES.md#necessary-free-text-question)
|
||||
checks one essential input, the rendered prompt and context, the real answer,
|
||||
one bound continuation, and an exact saved confirmation. Its four development
|
||||
cells use the recorded Codex and Claude models. Registration and calibration do
|
||||
@@ -149,7 +149,7 @@ It requires a fresh owned agent with no prior work runs and uses three provider
|
||||
Cloud fleet operations and trusted CI remain private. Local eval gateway qualification
|
||||
does not qualify Cloud routes, and these selections stay outside `--all`.
|
||||
|
||||
The explicit [onboarding approval-history journey](../tests/runner-e2e/README.md#first-task-onboarding)
|
||||
The explicit [onboarding approval-history journey](../tests/runner-e2e/SUITES.md#first-task-onboarding)
|
||||
continues an interview through partial plan acceptance, approved hiring, and a
|
||||
separate execution confirmation. It requires the assigned child's real execution,
|
||||
saved output, unchanged approved scope, and reload persistence. Deterministic
|
||||
@@ -158,7 +158,7 @@ require an explicit paid selection and a recorded live result.
|
||||
|
||||
The deployment-targeted [saved skill journey](../tests/runner-e2e/product-journeys/saved-skill-use.md) checks one company skill assigned by key, its exact admitted immutable version, a bound native source read/load, and a run-authored saved result from skill-only inputs. It uses the reusable Product journey target and remains unqualified until a real target run passes.
|
||||
|
||||
The explicit-only [case handoff workflow](../tests/runner-e2e/README.md#persistent-case-handoffs-explicit-only)
|
||||
The explicit-only [case handoff workflow](../tests/runner-e2e/SUITES.md#persistent-case-handoffs-explicit-only)
|
||||
contains arithmetic and receipt smoke cells for a same-task round trip among three native agents using real case/task
|
||||
APIs, saved documents, handoff receipts, and browser readback. Receipt smoke has
|
||||
an explicit terminal handoff to `done` on its fourth run, proving case closure
|
||||
@@ -241,15 +241,15 @@ not an eval category.
|
||||
The explicit Product E2E `completion-updates` suite compares onboarding and
|
||||
idle, busy, multiple-task, and restart Agent Chat handoffs on native Claude/Codex. It separates mechanical
|
||||
completion delivery/result access from semantic review of the retained answer;
|
||||
see the [probe contract](../tests/runner-e2e/README.md#completion-update-probes-explicit-only).
|
||||
see the [probe contract](../tests/runner-e2e/SUITES.md#completion-update-probes-explicit-only).
|
||||
|
||||
The explicit-only [task-titles suite](../tests/runner-e2e/README.md#automatic-task-titles)
|
||||
The explicit-only [task-titles suite](../tests/runner-e2e/SUITES.md#automatic-task-titles)
|
||||
checks that production guidance causes a real native agent to name prompt-only
|
||||
standard/Ask tasks early, while preserving user-supplied titles. Its oracle
|
||||
correlates browser creation, native tool receipts, durable titles, audit ownership,
|
||||
and the reloaded task UI; fixture prompts contain no naming instructions.
|
||||
|
||||
The explicit-only [native connection guidance suite](../tests/runner-e2e/README.md#native-connection-guidance-explicit-only)
|
||||
The explicit-only [native connection guidance suite](../tests/runner-e2e/SUITES.md#native-connection-guidance-explicit-only)
|
||||
adds neutral decline prompts, same-task run-attributed explanations, and measured
|
||||
no-use controls across three native local profiles. Its fifteen configured cells
|
||||
are preparation for future matched instruction comparisons, not a live result.
|
||||
@@ -311,11 +311,11 @@ real APIs, drives Chromium, and invokes the selected local or Daytona runner.
|
||||
|
||||
The explicit-only `agent-chat-hardening` Product E2E suite covers native chat
|
||||
recovery, hiring, status evidence, and review handoff on local and selected warm
|
||||
Daytona paths. Its [fixture contract](../tests/runner-e2e/README.md) distinguishes
|
||||
Daytona paths. Its [fixture contract](../tests/runner-e2e/SUITES.md) distinguishes
|
||||
startup cancellation from active response cancellation and HTTP send replay
|
||||
from ambiguous provider action recovery. Select it explicitly; `--all` excludes it.
|
||||
|
||||
The explicit-only [production hiring templates suite](../tests/runner-e2e/README.md#production-hiring-templates)
|
||||
The explicit-only [production hiring templates suite](../tests/runner-e2e/SUITES.md#production-hiring-templates)
|
||||
adds two local native Codex/Claude cells. It exercises API-created production
|
||||
CEO defaults, an explicitly requested hiring skill/reference read, a permanent
|
||||
coder hire, independently computed saved JSON fixtures and worker reuse.
|
||||
@@ -351,9 +351,9 @@ The explicit-only `grok-qualification` and `grok-subscription-qualification`
|
||||
Product suites exercise Grok Build with API and company subscription
|
||||
authentication respectively. Keep their results separate; the subscription
|
||||
fixture seeds an explicitly supplied login and does not qualify interactive
|
||||
login. See the [Grok fixture contract](../tests/runner-e2e/README.md#grok-build-qualification).
|
||||
login. See the [Grok fixture contract](../tests/runner-e2e/SUITES.md#grok-build-qualification).
|
||||
|
||||
The explicit [Direct blocker guidance suite](../tests/runner-e2e/README.md#direct-blocker-guidance)
|
||||
The explicit [Direct blocker guidance suite](../tests/runner-e2e/SUITES.md#direct-blocker-guidance)
|
||||
checks the legacy coordination skill against human authority, missing hiring
|
||||
permission, and requester scope decisions through saved browser interactions.
|
||||
|
||||
@@ -439,7 +439,7 @@ analytical label.
|
||||
## Evidence, provenance, and history
|
||||
|
||||
Polling latency is an interval rather than an exact first-detection time. The
|
||||
[Product E2E timing contract](../tests/runner-e2e/README.md#latency-observation-bounds)
|
||||
[Product E2E timing contract](../tests/runner-e2e/SUITES.md#latency-observation-bounds)
|
||||
keeps last-absent/first-present bounds, resolution, strict or inclusive targets,
|
||||
and pass/fail/inconclusive timing verdicts alongside the unchanged workflow grade.
|
||||
|
||||
@@ -627,15 +627,15 @@ a newer rendering of the same campaign.
|
||||
Remaining native chat boundaries are in the explicit-only
|
||||
`agent-chat-qualification` suite: active task reassignment, user Retry after
|
||||
verified worker process loss, and multi-turn answers grounded in actual task
|
||||
records. See the [workflow and qualification limits](../tests/runner-e2e/README.md#remaining-native-agent-chat-qualification).
|
||||
records. See the [workflow and qualification limits](../tests/runner-e2e/SUITES.md#remaining-native-agent-chat-qualification).
|
||||
The 26 native `first-task` cells inspect the production wizard's saved native
|
||||
default on qualified targets, without an API runner switch. The 26 Legacy cells
|
||||
use an API-configured inactive setup record and resume it in the wizard, as
|
||||
described in the [first-task setup contract](../tests/runner-e2e/README.md#first-task-onboarding).
|
||||
described in the [first-task setup contract](../tests/runner-e2e/SUITES.md#first-task-onboarding).
|
||||
Live results and semantic answer reviews must accompany
|
||||
any qualification claim; catalog presence alone is not a pass.
|
||||
|
||||
The explicit-only [native question/resume qualification](../tests/runner-e2e/README.md#task-continuation)
|
||||
The explicit-only [native question/resume qualification](../tests/runner-e2e/SUITES.md#task-continuation)
|
||||
separates a completed two-answer user journey from semantic-tool documentation
|
||||
qualification. It verifies the exact provider-pause or native response-wake
|
||||
binding for each answer and preserves prior grades when the definition changes.
|
||||
@@ -664,11 +664,11 @@ downloaded proof on local native/legacy Codex and native Daytona. See the
|
||||
|
||||
The explicit-only Product E2E `api-response-reading` suite verifies retrieval of
|
||||
large saved API responses on local and Daytona native Codex runs. See the
|
||||
[Runner E2E guide](../tests/runner-e2e/README.md#bounded-api-response-reading).
|
||||
[Runner E2E guide](../tests/runner-e2e/SUITES.md#bounded-api-response-reading).
|
||||
|
||||
The explicit-only Product E2E `extended-harnesses` suite covers pending Cursor,
|
||||
Copilot and Pi ACP profiles on local and Daytona. See the
|
||||
[fixture admission, credentials and budget contract](../tests/runner-e2e/README.md#extended-acp-harnesses-explicit-only).
|
||||
[fixture admission, credentials and budget contract](../tests/runner-e2e/SUITES.md#extended-acp-harnesses-explicit-only).
|
||||
The private Runner Evals campaign of the same name provides complementary
|
||||
semantic protocol cases; catalog membership is not live qualification.
|
||||
|
||||
@@ -679,19 +679,19 @@ source/pack provenance and complete persisted evidence are required.
|
||||
The explicit-only Product E2E `confirmation-replies` suite tests conversational
|
||||
approval and rejection, persisted message provenance, approval before execution,
|
||||
ambiguous proposals, and the existing card-click path with native Claude/Codex.
|
||||
See the [suite contract](../tests/runner-e2e/README.md#conversational-confirmation-replies-explicit-only).
|
||||
See the [suite contract](../tests/runner-e2e/SUITES.md#conversational-confirmation-replies-explicit-only).
|
||||
|
||||
Hiring notification accounting now also requires exact completed action attribution. Missing native/provider ID mapping is uncomparable evidence; it must not be reported as a model task regression or waived through name/order matching. The fixture waits for both known completion callbacks and settled bracketed observations, including the gap before pending outbox work becomes a wake. Strict action replay and original machine verdicts are retained separately.
|
||||
|
||||
The explicit-only [planning guidance utility comparison](../tests/runner-e2e/PLAN-TASK-GUIDANCE.md) measures task decomposition and handoffs with current, short, and disabled skills.
|
||||
|
||||
The explicit-only [task-workspaces Product E2E suite](../tests/runner-e2e/README.md#projectless-task-workspaces-explicit-only)
|
||||
The explicit-only [task-workspaces Product E2E suite](../tests/runner-e2e/SUITES.md#projectless-task-workspaces-explicit-only)
|
||||
covers projectless task files, deferred repository acquisition, controller restart
|
||||
and nested Git/dirty-file persistence on legacy local, native local and native
|
||||
Daytona OpenCode. Its three configured cells use independent filesystem, public
|
||||
API and download oracles; no live qualification is implied by fixture registration.
|
||||
|
||||
The explicit-only [feedback persistence case](../tests/runner-e2e/README.md#feedback-persistence-explicit-only)
|
||||
The explicit-only [feedback persistence case](../tests/runner-e2e/SUITES.md#feedback-persistence-explicit-only)
|
||||
checks real native complaint/suggestion submissions and retained bodies with
|
||||
run-attributed tool receipts on local and Daytona execution. Its four native
|
||||
Claude/Codex cells are explicit-only. Remote registrations remain unqualified
|
||||
@@ -699,7 +699,7 @@ until retained live attempts prove them. It uses the normal Product E2E report
|
||||
and keeps synthetic feedback distinct from actionable product findings.
|
||||
# Legacy workspace preservation
|
||||
|
||||
The explicit [legacy workspace migration Product E2E suites](../tests/runner-e2e/README.md#legacy-workspace-migration)
|
||||
The explicit [legacy workspace migration Product E2E suites](../tests/runner-e2e/SUITES.md#legacy-workspace-migration)
|
||||
verify a retained session through the production offline migration and an empty
|
||||
replacement controller. They complement the rolling deployment suites and do
|
||||
not claim uninterrupted service during initial enrollment.
|
||||
@@ -117,7 +117,7 @@ Three agents use four bounded runs to save, review, and correct a tiny case rece
|
||||
on the same task. Two API-seeded passive cases exercise read-only list filters;
|
||||
the browser reads the saved document, its revisions and handoff history. The
|
||||
independent oracle checks actual native document reads and revision attribution.
|
||||
See [fixture and limits](../../tests/runner-e2e/README.md#persistent-case-handoffs-explicit-only).
|
||||
See [fixture and limits](../../tests/runner-e2e/SUITES.md#persistent-case-handoffs-explicit-only).
|
||||
|
||||
## Gotchas
|
||||
|
||||
|
||||
@@ -472,6 +472,22 @@ describe("database work scope identity", () => {
|
||||
} finally { await other.close(); }
|
||||
});
|
||||
|
||||
it("scopes an unhinted signal alongside a hinted one to the hinted set, locally and in another process", async () => {
|
||||
const other = receiving(["alongside"]);
|
||||
const local: Array<string[] | null> = [];
|
||||
const stop = subscribeDatabaseWork(db, "alongside", (event, hints) => { if (event === "settled") local.push(hints ? [...hints] : null); });
|
||||
try {
|
||||
const result = await run(root => root.transaction(async tx => {
|
||||
await signalDatabaseWork(tx, "alongside");
|
||||
await signalDatabaseWork(tx, "alongside", "company-1");
|
||||
}));
|
||||
expect(local).toEqual([["company-1"]]);
|
||||
expect(result.payloads.map(payload => JSON.parse(payload).hints)).toEqual([["company-1"]]);
|
||||
other.deliver(result.payloads);
|
||||
expect(other.wakes).toEqual([["alongside", ["company-1"]]]);
|
||||
} finally { stop(); await other.close(); }
|
||||
});
|
||||
|
||||
it("splits many hints into payloads an older receiver still reads, within the per-topic byte cap", async () => {
|
||||
const hints = Array.from({ length: 80 }, (_, index) => JSON.stringify({ companyId: `company-${String(index).padStart(4, "0")}` }));
|
||||
const other = receiving(["many"]);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { installDatabaseWorkSignals } from "../../../packages/db/src/work-signals.js";
|
||||
import { installDatabaseWorkSignals, publishDatabaseWorkSettled } from "../../../packages/db/src/work-signals.js";
|
||||
import { createDeliveryWorkCoordinator } from "../services/delivery-work-coordinator.js";
|
||||
import { notifyDeliveryWork, DELIVERY_QUEUES } from "../services/delivery-work-notifications.js";
|
||||
import { beginIdleTrackedWork, idleWorkSnapshot, isIdleTaskDrainActive, readTaskDrain, startTaskDrain, stopTaskDrain } from "../services/task-admission.js";
|
||||
@@ -399,3 +399,67 @@ it("invalidates owner reconciliation synchronously before awaiting an active sto
|
||||
finish(); await worker.ready; await stopping;
|
||||
expect(stopped).toBe(true);
|
||||
});
|
||||
|
||||
describe("settled hints a task cannot apply", () => {
|
||||
function settledFixture(onSettled: (hints?: ReadonlySet<string>) => void) {
|
||||
const s = setup();
|
||||
const t = { ...task(), onSettled: vi.fn(onSettled) };
|
||||
const worker = s.coordinator.register(DELIVERY_QUEUES.feedback, t);
|
||||
return { s, t, worker };
|
||||
}
|
||||
const received = (mock: ReturnType<typeof vi.fn>) => mock.mock.calls.map(([hints]) => hints === undefined ? null : [...hints as ReadonlySet<string>]);
|
||||
|
||||
it("still wakes the task, unscoped, and logs a warning when it rejects a hint", async () => {
|
||||
const warn = vi.spyOn(process, "emitWarning").mockImplementation(() => {});
|
||||
try {
|
||||
const { s, t, worker } = settledFixture(hints => {
|
||||
if (hints && [...hints].some(hint => !hint.startsWith("company:"))) throw new Error("unknown hint shape");
|
||||
});
|
||||
await worker.ready;
|
||||
t.run.mockClear();
|
||||
publishDatabaseWorkSettled(s.owner, DELIVERY_QUEUES.feedback, "{\"newShape\":1}");
|
||||
await vi.advanceTimersByTimeAsync(1);
|
||||
expect(received(t.onSettled)).toEqual([["{\"newShape\":1}"], null]);
|
||||
expect(t.run).toHaveBeenCalledOnce();
|
||||
expect(warn).toHaveBeenCalledOnce();
|
||||
expect(String(warn.mock.calls[0]![0])).toContain(`Delivery settlement could not be applied for ${DELIVERY_QUEUES.feedback}`);
|
||||
expect(s.onError).not.toHaveBeenCalled();
|
||||
} finally { warn.mockRestore(); }
|
||||
});
|
||||
|
||||
it("wakes the task once without retrying when even the unscoped settlement throws", async () => {
|
||||
const warn = vi.spyOn(process, "emitWarning").mockImplementation(() => {});
|
||||
try {
|
||||
const { s, t, worker } = settledFixture(() => { throw new Error("broken"); });
|
||||
await worker.ready;
|
||||
t.run.mockClear();
|
||||
publishDatabaseWorkSettled(s.owner, DELIVERY_QUEUES.feedback, "company:1");
|
||||
await vi.advanceTimersByTimeAsync(1);
|
||||
expect(received(t.onSettled)).toEqual([["company:1"], null]);
|
||||
expect(t.run).toHaveBeenCalledOnce();
|
||||
expect(warn).toHaveBeenCalledTimes(2);
|
||||
t.onSettled.mockClear(); warn.mockClear();
|
||||
publishDatabaseWorkSettled(s.owner, DELIVERY_QUEUES.feedback);
|
||||
await vi.advanceTimersByTimeAsync(1);
|
||||
expect(received(t.onSettled)).toEqual([null]);
|
||||
expect(t.run).toHaveBeenCalledTimes(2);
|
||||
expect(warn).toHaveBeenCalledOnce();
|
||||
await vi.advanceTimersByTimeAsync(60_000);
|
||||
expect(t.run).toHaveBeenCalledTimes(2);
|
||||
} finally { warn.mockRestore(); }
|
||||
});
|
||||
|
||||
it("passes recognised hints through once, without a warning", async () => {
|
||||
const warn = vi.spyOn(process, "emitWarning").mockImplementation(() => {});
|
||||
try {
|
||||
const { s, t, worker } = settledFixture(() => {});
|
||||
await worker.ready;
|
||||
t.run.mockClear();
|
||||
publishDatabaseWorkSettled(s.owner, DELIVERY_QUEUES.feedback, "company:1");
|
||||
await vi.advanceTimersByTimeAsync(1);
|
||||
expect(received(t.onSettled)).toEqual([["company:1"]]);
|
||||
expect(t.run).toHaveBeenCalledOnce();
|
||||
expect(warn).not.toHaveBeenCalled();
|
||||
} finally { warn.mockRestore(); }
|
||||
});
|
||||
});
|
||||
@@ -3478,6 +3478,88 @@ describeEmbeddedPostgres("issueThreadInteractionService", () => {
|
||||
expect(listed[0]?.status).toBe("cancelled");
|
||||
});
|
||||
|
||||
it("reads an old authorization target and saves follow-up comments without resolving the request", async () => {
|
||||
const { companyId, issueId } = await seedConfirmationIssue("Saved authorization target");
|
||||
const key = `connection:https://mcp.example.test/${"connection/".repeat(25)}:user:local-board`;
|
||||
const [card] = await db.insert(issueThreadInteractions).values({
|
||||
companyId, issueId, kind: "request_confirmation", status: "pending",
|
||||
continuationPolicy: "wake_assignee", requestedResolverPolicy: "human_only",
|
||||
effectiveResolverPolicy: "human_only", createdByUserId: "local-board",
|
||||
payload: { version: 1, prompt: "Connect your account to continue",
|
||||
target: { type: "custom", key, label: "Personal connection ".repeat(10), href: "/apps/example/permissions" } },
|
||||
}).returning();
|
||||
|
||||
expect((await interactionsSvc.listForIssue(issueId))[0]).toMatchObject({
|
||||
id: card.id, status: "pending", effectiveResolverPolicy: "human_only",
|
||||
payload: { target: { key } },
|
||||
});
|
||||
for (const body of ["How do I connect it?", "Please explain the next step."]) {
|
||||
const saved = await issuesSvc.addComment(issueId, body, { userId: "local-board" }, {
|
||||
clientRequestId: randomUUID(),
|
||||
});
|
||||
expect(await db.select().from(issueComments).where(eq(issueComments.id, saved.id)))
|
||||
.toMatchObject([{ body }]);
|
||||
}
|
||||
// Reconstruct the reader as a reload would. A comment never supplies consent.
|
||||
expect((await issueThreadInteractionService(db).listForIssue(issueId))[0]).toMatchObject({
|
||||
id: card.id, status: "pending", result: null, payload: { target: { key } },
|
||||
});
|
||||
await expect(interactionsSvc.create({ id: issueId, companyId }, {
|
||||
kind: "request_confirmation", payload: { version: 1, prompt: "New request",
|
||||
target: { type: "custom", key } },
|
||||
}, { userId: "local-board" })).rejects.toThrow();
|
||||
await expect(interactionsSvc.acceptInteraction({ id: issueId, companyId: randomUUID(), projectId: null, goalId: null }, card.id, {}, { userId: "local-board" }))
|
||||
.rejects.toMatchObject({ status: 404 });
|
||||
});
|
||||
|
||||
it.each([
|
||||
{ type: "custom", key: "" },
|
||||
{ type: "custom", key: "authorization", href: "javascript:alert(1)" },
|
||||
{ type: "issue_document", key: "plan", revisionId: "invalid" },
|
||||
] as const)("keeps invalid stored target structure protected: %j", async target => {
|
||||
const { companyId, issueId } = await seedConfirmationIssue("Invalid target structure");
|
||||
const [card] = await db.insert(issueThreadInteractions).values({
|
||||
companyId, issueId, kind: "request_confirmation", status: "pending",
|
||||
continuationPolicy: "none", createdByUserId: "local-board",
|
||||
payload: { version: 1, prompt: "Review this request", target },
|
||||
}).returning();
|
||||
await expect(interactionsSvc.listForIssue(issueId)).rejects.toThrow();
|
||||
await expect(interactionsSvc.acceptInteraction({ id: issueId, companyId, projectId: null, goalId: null }, card.id, {}, { userId: "local-board" }))
|
||||
.rejects.toThrow();
|
||||
await expect(issuesSvc.addComment(issueId, "This request needs repair", { userId: "local-board" }))
|
||||
.resolves.toMatchObject({ body: "This request needs repair" });
|
||||
expect((await db.select().from(issueThreadInteractions).where(eq(issueThreadInteractions.id, card.id)))[0])
|
||||
.toMatchObject({ status: "pending", result: null });
|
||||
});
|
||||
|
||||
it.each(["request_confirmation", "ask_user_questions"] as const)(
|
||||
"keeps a malformed %s pending while saving a comment and superseding a valid sibling", async kind => {
|
||||
const { companyId, issueId } = await seedConfirmationIssue("Malformed saved request");
|
||||
const [malformed] = await db.insert(issueThreadInteractions).values({
|
||||
companyId, issueId, kind, status: "pending", continuationPolicy: "wake_assignee",
|
||||
createdByUserId: "local-board",
|
||||
payload: sql`${JSON.stringify({ version: 1, prompt: null, supersedeOnUserComment: true })}::jsonb`,
|
||||
}).returning();
|
||||
const [valid] = await db.insert(issueThreadInteractions).values({
|
||||
companyId, issueId, kind: "request_confirmation", status: "pending",
|
||||
continuationPolicy: "none", createdByUserId: "local-board",
|
||||
payload: { version: 1, prompt: "An optional question", supersedeOnUserComment: true },
|
||||
createdAt: new Date(Date.now() - 1000),
|
||||
}).returning();
|
||||
const saved = await issuesSvc.addComment(issueId, "I need help with this request", { userId: "local-board" });
|
||||
expect((await db.select().from(issueComments).where(eq(issueComments.id, saved.id)))[0].body)
|
||||
.toBe("I need help with this request");
|
||||
expect((await db.select().from(issueThreadInteractions).where(eq(issueThreadInteractions.id, malformed.id)))[0])
|
||||
.toMatchObject({ status: "pending", result: null });
|
||||
expect((await db.select().from(issueThreadInteractions).where(eq(issueThreadInteractions.id, valid.id)))[0])
|
||||
.toMatchObject({ status: "expired", result: { outcome: "superseded_by_comment", commentId: saved.id } });
|
||||
await expect(interactionsSvc.expireRequestConfirmationsSupersededByHistoricalComments({ id: issueId, companyId }))
|
||||
.resolves.toEqual([]);
|
||||
await expect(interactionsSvc.acceptInteraction({ id: issueId, companyId, projectId: null, goalId: null }, malformed.id, {}, { userId: "local-board" }))
|
||||
.rejects.toThrow();
|
||||
},
|
||||
);
|
||||
|
||||
it("derives legacy pending interactions as expired on closed issues without mutating the GET", async () => {
|
||||
const { companyId, issueId } = await seedConfirmationIssue("Legacy pending interaction on closed issue");
|
||||
const created = await interactionsSvc.create({ id: issueId, companyId }, {
|
||||
|
||||
@@ -7,6 +7,7 @@ import { join } from "node:path";
|
||||
import express from "express";
|
||||
import { and, eq, sql } from "drizzle-orm";
|
||||
import type { LiveEvent } from "@paperclipai/shared";
|
||||
import { requestConfirmationPayloadSchema } from "@paperclipai/shared";
|
||||
import { subscribeCompanyLiveEvents } from "../services/live-events.js";
|
||||
import { assignedToolName as nativeAssignedToolName } from "../services/native-runtime/assigned-mcp-tools.js";
|
||||
import request from "supertest";
|
||||
@@ -2824,7 +2825,11 @@ rl.on("line", (line) => {
|
||||
}
|
||||
});
|
||||
|
||||
it("starts with another user's personal app and requests authorization only when used", async () => {
|
||||
it.each([
|
||||
{ longIdentity: false, existing: false },
|
||||
{ longIdentity: true, existing: false },
|
||||
{ longIdentity: true, existing: true },
|
||||
])("requests another user's personal authorization only when used (long: $longIdentity, existing: $existing)", async ({ longIdentity, existing }) => {
|
||||
const originalApiUrl = process.env.PAPERCLIP_API_URL;
|
||||
process.env.PAPERCLIP_API_URL = "http://paperclip.example.test";
|
||||
const company = await createCompany(db);
|
||||
@@ -2849,6 +2854,7 @@ rl.on("line", (line) => {
|
||||
// may be unable to authenticate even though this user's grant is valid.
|
||||
// The cached catalog must remain visible so grant resolution can happen.
|
||||
await db.update(toolConnections).set({
|
||||
...(longIdentity ? { uid: `https://mcp.example.test/${"connection/".repeat(25)}`, name: "Personal connection ".repeat(10) } : {}),
|
||||
credentialPolicy: "per_user",
|
||||
healthStatus: "error",
|
||||
healthMessage: "This app needs you to sign in.",
|
||||
@@ -2882,7 +2888,7 @@ rl.on("line", (line) => {
|
||||
const call = () => request(app).post(endpoint).set("authorization", `Bearer ${runtime[0]!.token}`)
|
||||
.send({ jsonrpc: "2.0", id: "call", method: "tools/call", params: { name: tool.name, arguments: {} } });
|
||||
|
||||
await db.insert(issueThreadInteractions).values({
|
||||
if (existing) await db.insert(issueThreadInteractions).values({
|
||||
companyId: company.id,
|
||||
issueId: issue.id,
|
||||
kind: "request_confirmation",
|
||||
@@ -2913,10 +2919,14 @@ rl.on("line", (line) => {
|
||||
effectiveResolverPolicy: "human_only",
|
||||
addresseeUserId: "carol",
|
||||
});
|
||||
expect(interaction!.payload).toMatchObject({
|
||||
prompt: `Connect your ${connection.name} account to continue`,
|
||||
target: { key: `connection:${connection.uid}:user:carol` },
|
||||
});
|
||||
const payload = requestConfirmationPayloadSchema.parse(interaction!.payload);
|
||||
expect(payload.target?.type).toBe("custom");
|
||||
expect(payload.target && "key" in payload.target && payload.target.key.length).toBeLessThanOrEqual(120);
|
||||
// A repeated refused call refreshes the same request, with a stable target.
|
||||
await call().expect(409);
|
||||
const cards = await db.select().from(issueThreadInteractions).where(eq(issueThreadInteractions.issueId, issue.id));
|
||||
expect(cards).toHaveLength(1);
|
||||
expect(cards[0].payload).toEqual(interaction!.payload);
|
||||
|
||||
await db.insert(connectionGrants).values({
|
||||
companyId: company.id,
|
||||
|
||||
@@ -121,6 +121,12 @@ export function createDeliveryWorkCoordinator(input: {
|
||||
dirty = true;
|
||||
if (!running) schedule(task.coalesceMs ?? 0);
|
||||
}
|
||||
function applySettled(hints?: ReadonlySet<string>) {
|
||||
for (const attempt of hints === undefined ? [undefined] : [hints, undefined]) {
|
||||
try { task.onSettled?.(attempt); return; }
|
||||
catch (error) { process.emitWarning(`Delivery settlement could not be applied for ${queue}: ${String(error)}`); }
|
||||
}
|
||||
}
|
||||
const unsubscribe = subscribeDatabaseWork(input.owner, queue, (event, hints) => {
|
||||
if (workerStopped) return;
|
||||
if (databaseWorkPending(input.owner, queue)) {
|
||||
@@ -129,7 +135,7 @@ export function createDeliveryWorkCoordinator(input: {
|
||||
// replaces this deadline with an immediate wake on the normal path.
|
||||
if (!running) schedule(task.retryMs);
|
||||
}
|
||||
if (event === "settled") { task.onSettled?.(hints); wake(); }
|
||||
if (event === "settled") { applySettled(hints); wake(); }
|
||||
});
|
||||
const worker = { wake, async stop() {
|
||||
workerStopped = true;
|
||||
|
||||
@@ -107,6 +107,9 @@ import {
|
||||
requestCheckboxConfirmationPayloadSchema,
|
||||
requestCheckboxConfirmationResultSchema,
|
||||
requestConfirmationPayloadSchema,
|
||||
requestConfirmationCustomTargetSchema,
|
||||
requestConfirmationIssueAttachmentTargetSchema,
|
||||
requestConfirmationIssueDocumentTargetSchema,
|
||||
requestConfirmationResultSchema,
|
||||
requestItemVerdictsPayloadSchema,
|
||||
requestItemVerdictsResultSchema,
|
||||
@@ -117,6 +120,7 @@ import {
|
||||
withdrawIssueThreadInteractionSchema,
|
||||
} from "@paperclipai/shared";
|
||||
import { z } from "zod";
|
||||
import { logger } from "../middleware/logger.js";
|
||||
import { conflict, forbidden, notFound, unprocessable } from "../errors.js";
|
||||
import { getTelemetryClient } from "../telemetry.js";
|
||||
import { authorizationService } from "./authorization.js";
|
||||
@@ -703,6 +707,21 @@ function parseStoredInteractionResult<S extends z.ZodTypeAny>(
|
||||
return null;
|
||||
}
|
||||
|
||||
// Older internal writers persisted custom identity and display text without the
|
||||
// input length limits. Read those exact values across upgrades; never truncate
|
||||
// an identity or relax target types, URLs, revisions, or resolution authority.
|
||||
// New writes still use the strict shared payload schema.
|
||||
const storedRequestConfirmationPayloadSchema = requestConfirmationPayloadSchema.extend({
|
||||
target: z.discriminatedUnion("type", [
|
||||
requestConfirmationIssueDocumentTargetSchema,
|
||||
requestConfirmationIssueAttachmentTargetSchema,
|
||||
requestConfirmationCustomTargetSchema.extend({
|
||||
key: z.string().trim().min(1),
|
||||
label: z.string().trim().min(1).nullable().optional(),
|
||||
}),
|
||||
]).nullable().optional(),
|
||||
});
|
||||
|
||||
function hydrateInteraction(
|
||||
row: IssueThreadInteractionRow,
|
||||
): IssueThreadInteraction {
|
||||
@@ -774,7 +793,7 @@ function hydrateInteraction(
|
||||
),
|
||||
} satisfies AskUserQuestionsInteraction;
|
||||
case "request_confirmation": {
|
||||
const payload = requestConfirmationPayloadSchema.parse(row.payload);
|
||||
const payload = storedRequestConfirmationPayloadSchema.parse(row.payload);
|
||||
return {
|
||||
...base,
|
||||
kind: "request_confirmation",
|
||||
@@ -824,6 +843,23 @@ function hydrateInteraction(
|
||||
}
|
||||
}
|
||||
|
||||
function interactionForCommentSupersession(row: IssueThreadInteractionRow) {
|
||||
try {
|
||||
return hydrateInteraction(row) as UserCommentSupersedableInteraction;
|
||||
} catch (error) {
|
||||
if (!(error instanceof z.ZodError)) throw error;
|
||||
// The comment is useful even when a saved request cannot be decoded. Keep
|
||||
// that gate pending, refuse its normal resolution, and report only schema
|
||||
// locations, never payload/credential values. Valid siblings still expire.
|
||||
logger.warn({
|
||||
companyId: row.companyId, issueId: row.issueId, interactionId: row.id,
|
||||
kind: row.kind,
|
||||
validationIssues: error.issues.map(issue => ({ code: issue.code, path: issue.path })),
|
||||
}, "Saved interaction is invalid; leaving it pending while saving a comment");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async function touchIssue(db: IssueTouchDb, issueId: string, companyId: string) {
|
||||
await db.transaction(async tx => {
|
||||
await notifyStatusCardIssueChange(tx, companyId);
|
||||
@@ -4962,10 +4998,9 @@ export function issueThreadInteractionService(
|
||||
const superseded = rows.filter((row) => {
|
||||
if (row.kind === "ask_user_questions" && scope?.conversationAgentId && scope.conversationUserId) return false;
|
||||
if (!isUserCommentSupersedableKind(row.kind)) return false;
|
||||
const interaction = hydrateInteraction(
|
||||
row,
|
||||
) as UserCommentSupersedableInteraction;
|
||||
const interaction = interactionForCommentSupersession(row);
|
||||
return (
|
||||
interaction !== null &&
|
||||
shouldSupersedeInteractionOnUserComment(interaction) &&
|
||||
isCommentAtOrAfterInteraction({
|
||||
commentCreatedAt: comment.createdAt,
|
||||
@@ -5071,9 +5106,8 @@ export function issueThreadInteractionService(
|
||||
>();
|
||||
for (const row of rows) {
|
||||
if (!isUserCommentSupersedableKind(row.kind)) continue;
|
||||
const interaction = hydrateInteraction(
|
||||
row,
|
||||
) as UserCommentSupersedableInteraction;
|
||||
const interaction = interactionForCommentSupersession(row);
|
||||
if (!interaction) continue;
|
||||
if (!shouldSupersedeInteractionOnUserComment(interaction)) continue;
|
||||
|
||||
const supersedingComment = comments.find((comment) =>
|
||||
|
||||
@@ -75,6 +75,7 @@ import {
|
||||
} from "./mcp-tasks.js";
|
||||
import { logger } from "../middleware/logger.js";
|
||||
import { getAppDefinitionForApplicationKey, isConnectorFeatureEnabled } from "@paperclipai/shared";
|
||||
import { requestConfirmationPayloadSchema } from "@paperclipai/shared";
|
||||
import { instanceSettingsService } from "./instance-settings.js";
|
||||
import { redactSensitiveText } from "../redaction.js";
|
||||
import { spawn } from "node:child_process";
|
||||
@@ -4797,7 +4798,7 @@ export function createToolGatewayService(
|
||||
.limit(1);
|
||||
const href = `/${company?.issuePrefix ?? ""}/apps/${connection.id}/permissions`;
|
||||
const idempotencyKey = `connection-authorization:${connection.id}:${userId}`;
|
||||
const payload = {
|
||||
const payload = requestConfirmationPayloadSchema.parse({
|
||||
version: 1 as const,
|
||||
prompt:
|
||||
grantKind === "organization"
|
||||
@@ -4814,12 +4815,12 @@ export function createToolGatewayService(
|
||||
: "This run needs your personal authorization. Paperclip will not use another user's identity.",
|
||||
target: {
|
||||
type: "custom" as const,
|
||||
key: `connection:${connection.uid}:user:${userId}`,
|
||||
key: `connection-authorization:${createHash("sha256").update(idempotencyKey).digest("hex")}`,
|
||||
revisionId: connection.updatedAt.toISOString(),
|
||||
label: `Connect ${connection.name}`,
|
||||
label: `Connect ${connection.name}`.slice(0, 120),
|
||||
href,
|
||||
},
|
||||
};
|
||||
});
|
||||
const [existing] = await db
|
||||
.select({ id: issueThreadInteractions.id })
|
||||
.from(issueThreadInteractions)
|
||||
|
||||
+167
-1852
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Config and aged-state fault waves (CF1–CF3). See config-faults.ts for the
|
||||
* oracle and README.md ("Config faults") for usage.
|
||||
* oracle and SCENARIOS.md ("Config faults") for usage.
|
||||
*
|
||||
* node cli/node_modules/tsx/dist/cli.mjs tests/restart-chaos/config-wave.ts \
|
||||
* --faults CF1,CF3 --adapters codex --tasks 4 --concurrency 1 --restarts K1,K2 --seed 61
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Environment-provider fault waves (EP1). See env-provider-faults.ts for the
|
||||
* oracle and README.md ("Environment-provider faults") for usage.
|
||||
* oracle and SCENARIOS.md ("Environment-provider faults") for usage.
|
||||
*
|
||||
* node cli/node_modules/tsx/dist/cli.mjs tests/restart-chaos/env-provider-wave.ts \
|
||||
* --fault EP1 --adapters codex --tasks 2 --seed 71
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* `--long-turn-minutes <n>` (15–60): every task's first turn does n minutes of real tool work before its
|
||||
* workload, for any cell (README "Long turn").
|
||||
* workload, for any cell (SCENARIOS.md "Long turn").
|
||||
*
|
||||
* The staging failures of 2026-11-11 followed turns of 14–43 minutes, while every chaos workload finishes in
|
||||
* a few minutes. A long turn grows what the run holds when its fault or next wake arrives: the provider
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* MS1–MS3: two control planes on one database (README "Two servers, one database").
|
||||
* MS1–MS3: two control planes on one database (SCENARIOS.md "Two servers, one database").
|
||||
*
|
||||
* Hosted Cloud deploys by rolling overlap: a new server B starts on the same database while the old
|
||||
* server A still serves, then A drains (doc/plans/2026-10-31-zero-downtime-web-deploys.md: 5 s overlap,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* `--fail-recovery-step <step>[:<nth>]`: fail the Nth attempt of one recovery step once (README "Fail the Nth
|
||||
* `--fail-recovery-step <step>[:<nth>]`: fail the Nth attempt of one recovery step once (SCENARIOS.md "Fail the Nth
|
||||
* recovery step").
|
||||
*
|
||||
* Every other fault hits the control plane once and then lets recovery run. On staging the first fault was
|
||||
|
||||
@@ -54,7 +54,7 @@ export function parseK15HoldSeconds(options: { faults: readonly string[] }, raw:
|
||||
export const K15_OVERLAP_SECONDS_RANGE: readonly [number, number] = [5, 600];
|
||||
|
||||
/**
|
||||
* The staging deploy shape (README "Redeploy without a volume, with overlap"):
|
||||
* The staging deploy shape (SCENARIOS.md "Redeploy without a volume, with overlap"):
|
||||
*
|
||||
* - `--k15-overlap-seconds <n>` or `<min>-<max>`: a K15 boots the next deploy generation beside the old server,
|
||||
* switches traffic (the wave's stable port) to it once it is ready, keeps the old server running for the seeded
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* W2, W2Q, W2C: the same task woken again right after a run of it finished (README "Re-wake after success").
|
||||
* W2, W2Q, W2C: the same task woken again right after a run of it finished (SCENARIOS.md "Re-wake after success").
|
||||
*
|
||||
* On staging, 20 of 25 failures in one 8-hour window happened with no restart at all. Ten or more runs of
|
||||
* one agent ran at once on reused (warm) sandboxes, and 30–60 s after a long run of a task succeeded, an
|
||||
|
||||
+22
-3060
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user