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 > - `tests/runner-e2e` is the paid Product E2E harness and `tests/restart-chaos` is the restart chaos harness > - A README is the first file a person or an agent opens in a directory > - These two READMEs grew to 3,805 and 2,277 lines. Most of each is a catalog with one section per suite or per fault scenario, and almost none of it is ever trimmed > - This pull request splits each README into a runbook and a catalog file > - The benefit is a README that can be read in full, and a clear place for the next suite or scenario note ## Linked Issues or Issue Description Refs #21670 and #21700 (the same cleanup for `doc/DEVELOPING.md` and `doc/DATABASE.md`). **Issue type** Outdated or confusing documentation. **Where is the issue?** `tests/runner-e2e/README.md` and `tests/restart-chaos/README.md` **What's wrong?** In the last 60 days, `tests/runner-e2e/README.md` gained 3,476 lines and lost 182. `tests/restart-chaos/README.md` gained 2,411 and lost 134. The setup, evidence, and CI sections sit between suite notes. The first 225 lines of the runner-e2e README are suite notes with no heading. **Suggested fix** Keep how to run the harness in the README. Move the per-suite and per-scenario sections to a catalog file in the same directory. ## What Changed - `tests/runner-e2e/README.md` is now 767 lines: credentials, local commands, the Daytona image, evidence and cleanup, billing, the dashboard, GitHub Actions, and the report preview. - New `tests/runner-e2e/SUITES.md` (3,055 lines) holds every per-suite section. The two blocks of suite notes that had no heading now have one. - `tests/restart-chaos/README.md` is now 592 lines: run, fault timing, Daytona mode, hosted mode, universal checks, grading notes, pieces, output, and the crash-point suite. - New `tests/restart-chaos/SCENARIOS.md` (1,694 lines) holds every workload and fault scenario section. - All text is moved without wording changes. Nothing is deleted. The only edits are three "(below)" references in the restart-chaos README, which are now links. - Repointed 22 anchor links and 3 plain links in `doc/evals.md` and `maps/feature-map/cases.md`. - Updated seven code comments in `tests/restart-chaos/` that name a moved section, and two skills that list the runner-e2e docs to read. ## Verification - The split script asserts that each source line is kept or moved exactly one time, and checks the first line of each range. - A link check on the four files and on every file that links into them found 0 missing files and 0 missing anchors. - `tests/runner-e2e/daytona-image.test.ts` reads the README for a Docker build recipe. The recipe is still in the README. I did not run that test locally. - `node scripts/check-maps.mjs` passes. - `node --test .github/scripts/tests/*.test.mjs`: 808 pass, 0 fail. - `pnpm verify` was not run. This worktree has no installed dependencies. ## Risks - Low risk. The change is documentation and comments only. - A link to a moved section from outside this repository lands on the top of the README. - The catalog files are still long. This change moves them off the first-read path. It does not prune them. ## Model Used - Claude Fable 5.2 (`claude-fable-5-2`), Claude Code desktop, with tool use. ## 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 - [ ] 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 Fable 5.2 <noreply@anthropic.com>
101 lines
5.8 KiB
TypeScript
101 lines
5.8 KiB
TypeScript
/**
|
||
* `--long-turn-minutes <n>` (15–60): every task's first turn does n minutes of real tool work before its
|
||
* 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
|
||
* session's history, the controller journal, tool receipts and the sandbox's working files.
|
||
*
|
||
* The agent runs one shell command per round, in the foreground, each about 90 s (well short of provider
|
||
* shell-tool timeouts). Each round appends `ROUND <i> <start> <end>` to a log in its working directory and
|
||
* hashes data as it goes. Then it saves the log as the issue document `long-turn` and carries on with the
|
||
* workload. The oracle checks the rounds the agent reported and, from the harness's own observations, that
|
||
* one run of the task ran at least n minutes.
|
||
*/
|
||
import type { OracleArtifacts, OracleResult } from "./types.js";
|
||
import type { WorkloadDefinition } from "./workloads.js";
|
||
|
||
export const LONG_TURN_MINUTES_RANGE: readonly [number, number] = [15, 60];
|
||
/** Seconds of one round (45 ticks of 2 s). */
|
||
export const LONG_TURN_ROUND_SECONDS = 90;
|
||
export const LONG_TURN_DOCUMENT = "long-turn";
|
||
/** Sandbox and host clocks differ, and a round may start a little late: slack on the reported span. */
|
||
const SPAN_SLACK_SECONDS = 60;
|
||
|
||
export function parseLongTurnMinutes(raw: string | undefined): { longTurnMinutes?: number } {
|
||
if (raw === undefined) return {};
|
||
if (!/^[0-9]+$/.test(raw)) throw new Error("--long-turn-minutes takes whole minutes");
|
||
const minutes = Number(raw);
|
||
const [min, max] = LONG_TURN_MINUTES_RANGE;
|
||
if (minutes < min || minutes > max) throw new Error(`--long-turn-minutes must be between ${min} and ${max}`);
|
||
return { longTurnMinutes: minutes };
|
||
}
|
||
|
||
export function longTurnRounds(minutes: number): number {
|
||
return Math.ceil((minutes * 60) / LONG_TURN_ROUND_SECONDS);
|
||
}
|
||
|
||
export const longTurnLog = (nonce: string) => `long-turn-${nonce}.log`;
|
||
|
||
/** One round: ticks of real work (hashing) with a sleep, then one log line with the round's own clock window. */
|
||
export function longTurnCommand(nonce: string, round: number): string {
|
||
const ticks = LONG_TURN_ROUND_SECONDS / 2;
|
||
return `s=$(date +%s); i=0; h=${nonce}; while [ $i -lt ${ticks} ]; do i=$((i+1)); h=$(printf '%s %s' "$h" "$i" | cksum | cut -d' ' -f1); sleep 2; done;`
|
||
+ ` echo "ROUND ${round} $s $(date +%s) $h" >> ${longTurnLog(nonce)}; tail -n 1 ${longTurnLog(nonce)}`;
|
||
}
|
||
|
||
export function longTurnPreamble(nonce: string, minutes: number): string {
|
||
const rounds = longTurnRounds(minutes);
|
||
return [
|
||
`Before anything else in this task, do about ${minutes} minutes of preparation in your working directory, in this same turn.`,
|
||
`Run this shell command ${rounds} times, once per round, as separate tool calls in the foreground, replacing <N> with the round number 1 to ${rounds}`,
|
||
`(each takes about ${LONG_TURN_ROUND_SECONDS} seconds; do not run rounds in the background or in parallel, and do not skip or shorten any):`,
|
||
`\`${longTurnCommand(nonce, 0).replace("ROUND 0 ", "ROUND <N> ")}\``,
|
||
`After the last round, save the full contents of \`${longTurnLog(nonce)}\` as this issue's document with key \`${LONG_TURN_DOCUMENT}\``,
|
||
"(title \"Long turn\"), exactly as the file reads. Then, still in this turn, do the task below.",
|
||
"",
|
||
].join("\n");
|
||
}
|
||
|
||
/** The rounds the agent reported, in order. */
|
||
export function parseLongTurnLog(text: string | null | undefined): Array<{ round: number; start: number; end: number }> {
|
||
return (text ?? "").split(/\r?\n/).flatMap(line => {
|
||
const match = /^\s*ROUND ([0-9]+) ([0-9]{9,11}) ([0-9]{9,11})(?: \S+)?\s*$/.exec(line);
|
||
return match ? [{ round: Number(match[1]), start: Number(match[2]), end: Number(match[3]) }] : [];
|
||
});
|
||
}
|
||
|
||
export function longTurnChecks(minutes: number, artifacts: Pick<OracleArtifacts, "documents" | "runs">): OracleResult["checks"] {
|
||
const rounds = parseLongTurnLog(artifacts.documents[LONG_TURN_DOCUMENT]);
|
||
const wanted = longTurnRounds(minutes);
|
||
const complete = rounds.length >= wanted && rounds.slice(0, wanted).every((entry, index) => entry.round === index + 1
|
||
&& entry.end - entry.start >= LONG_TURN_ROUND_SECONDS - 10);
|
||
const span = rounds.length ? rounds[rounds.length - 1]!.end - rounds[0]!.start : 0;
|
||
// The harness's own evidence: a run of the task that ran for the whole turn.
|
||
const longest = Math.max(0, ...(artifacts.runs ?? []).map(run => {
|
||
const started = Date.parse(run.createdAt ?? ""), finished = Date.parse(run.finishedAt ?? "");
|
||
return Number.isFinite(started) && Number.isFinite(finished) ? (finished - started) / 1000 : 0;
|
||
}));
|
||
return [
|
||
{ name: "long_turn_rounds", ok: complete && span >= minutes * 60 - SPAN_SLACK_SECONDS,
|
||
detail: `rounds=${rounds.length}/${wanted} span=${span}s` },
|
||
{ name: "long_turn_run_observed", ok: longest >= minutes * 60 - SPAN_SLACK_SECONDS, detail: `longest run ${Math.round(longest)}s` },
|
||
];
|
||
}
|
||
|
||
/** The workload with the long turn in front: description, budget, collected documents and oracle. */
|
||
export function withLongTurn(definition: WorkloadDefinition, minutes: number | undefined): WorkloadDefinition {
|
||
if (!minutes) return definition;
|
||
return {
|
||
...definition,
|
||
budgetMs: definition.budgetMs + minutes * 60_000,
|
||
description: (nonce, agents) => `${longTurnPreamble(nonce, minutes)}${definition.description(nonce, agents)}`,
|
||
collect: { ...definition.collect, documents: [...new Set([...definition.collect.documents, LONG_TURN_DOCUMENT])] },
|
||
grade(nonce, artifacts, agents) {
|
||
const base = definition.grade(nonce, artifacts, agents);
|
||
const checks = [...base.checks, ...longTurnChecks(minutes, artifacts)];
|
||
return { verdict: checks.every(check => check.ok) ? "pass" : "fail", checks };
|
||
},
|
||
};
|
||
}
|