refactor(test): remove test support orphaned by the nightly soak prune (#23142)

## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - The server test tree under `server/src/__tests__/` keeps suites,
fixtures, and helper modules that support them.
> - The nightly soak prune in #22831 removed 483 soak suites, but eleven
of their support files stayed behind.
> - These files have no importer left. No test selects them. They never
run, but every contributor still reads, compiles, and typechecks them.
> - This pull request deletes the eleven orphaned support files. Each
one is proven unreferenced.
> - The benefit is 531 fewer lines of dead test support, and a test tree
that holds only live code.

## Linked Issues or Issue Description

No public issue exists for this cleanup. The problem is described here.

**What existing behavior does this improve?**
Test suite maintainability and typecheck scope of
`server/src/__tests__/` after the nightly soak prune (#22831).

**Subsystem affected**
server/ — REST API & orchestration services

**Current behavior**
Eleven test-support files under `server/src/__tests__/helpers/` and
`server/src/__tests__/fixtures/` have zero importers since the prune in
#22831 removed every suite that used them. They match no vitest include
pattern, so they never execute.

**Proposed behavior**
Delete the eleven dead files. Keep every live fixture and helper. Add no
new code.

## What Changed

- Deleted five orphaned helpers: `file-delivery-daytona.ts`,
`native-question-owner.mjs`, `observer-replay-report.ts`,
`recovery-population.ts`, and `maintenance/idle-work-capture-probe.ts`.
- Deleted six orphaned fixtures: `daytona-worker-lifecycle-sdk.mjs`,
`online-workspace-e2d-protocol.mjs`, its
`online-workspace-e2d-protocol.provenance.json` build receipt,
`sandbox-creation-receiver.ts`, `plugin-worker-deadline.cjs`, and
`plugin-worker-idle.cjs`.
- Deleted 531 test/support LOC. No production code, no test entry
points, and no assertions were removed.

## Verification

- Repo-wide reference scan: each of the eleven file stems was searched
across every source, manifest, workflow, tsconfig, and doc file in the
repository. Zero references exist. The scan also covers spawn patterns,
because plugin-worker and other fixtures are referenced by exact file
name everywhere they are used.
- Selection check: `server/vitest.config.ts` selects only
`src/**/*.test.ts` and `scripts/**/*.test.mjs`. None of the eleven files
matches, so no run loses a suite.
- `pnpm verify` reported the eleven deleted paths and asked for the
required CI lanes (`typecheck_release_registry`, `general_tests`,
`verify_paperclip_runner`, `build`, `verify_serialized_server`,
`e2e_shards`), as designed for source deletions. Required CI will cover
them.
- Focused local run: `pnpm --filter @paperclipai/server exec vitest run
src/services/issue-continuation-summary.test.ts` — 2/2 tests passed.
- Kept siblings verified live: `idle-work-capture.ts`,
`blocker-stall-fixture.ts` (benchmark consumer), and
`tool-profile-matching-fixture.ts` (documented benchmark) are referenced
and were not touched.

## Risks

- Low risk. Each deleted file had no importer, so no behavior or
coverage can change. If a future suite needs one of these helpers, it is
in git history.

## Model Used

- GLM (model id `openrouter/z-ai/glm-5.3`), driving a Paperclip
test-gardening agent: tool use, shell execution, repository-wide
reference scans, and local vitest runs. Assisted by no other model.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` /
`Closes: #` / `Refs #` OR (b) described the issue in-PR following the
relevant issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] All Paperclip CI gates are green
- [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge



Co-Authored-By: Paperclip <Paperclip-Paperclip@users.noreply.github.com>

Co-authored-by: Paperclip <noreply@paperclip.ing>
This commit is contained in:
authored and GitHub committed 2026-11-30 19:33:22 +00:00
1 parent 79b61962c9
commit 1847abcd91
11 files changed
-531

No files matched your search

@@ -1,59 +0,0 @@
import { createRequire } from "node:module";
import type { CommandManagedRuntimeRunner } from "@paperclipai/adapter-utils/command-managed-runtime";
import { shellQuote } from "@paperclipai/adapter-utils/ssh";
import { openDaytonaDuplexChannelSession, type DaytonaPtyProcess } from "../../../../packages/plugins/sandbox-providers/daytona/src/duplex-command-stream.js";
/** Opt-in live fixture; uses an isolated sandbox and never reuses a user's lease. */
export async function startFileDeliveryDaytona() {
const require = createRequire(new URL("../../../../packages/plugins/sandbox-providers/daytona/package.json", import.meta.url));
const { Daytona } = require("@daytonaio/sdk");
const sandbox: {
id: string;
process: DaytonaPtyProcess & { executeCommand(command: string, cwd?: string, env?: Record<string, string>, timeout?: number): Promise<{ exitCode: number; result: string }> };
delete(): Promise<void>;
} = await new Daytona({ apiKey: process.env.DAYTONA_API_KEY }).create({
language: "typescript", autoStopInterval: 10,
labels: { "paperclip-test": "gus-file-delivery" },
});
const workspace = "/home/daytona/gus-file-delivery";
// Capture stdout/stderr separately: SDK result text otherwise combines them.
const executeSource = `
const {spawn} = require('node:child_process');
const input = JSON.parse(process.argv[1]);
const child = spawn(input.command, input.args || [], {
cwd: input.cwd, env: {...process.env, ...input.env}, timeout: input.timeoutMs || 30000
});
const stdout = [], stderr = [];
child.stdout.on('data', chunk => stdout.push(chunk));
child.stderr.on('data', chunk => stderr.push(chunk));
child.on('error', error => stderr.push(Buffer.from(error.message)));
child.on('close', (exitCode, signal) => process.stdout.write(JSON.stringify({
exitCode, signal, timedOut: signal === 'SIGTERM', pid: null,
startedAt: new Date().toISOString(),
stdout: Buffer.concat(stdout).toString(), stderr: Buffer.concat(stderr).toString()
})));
child.stdin.on('error', error => { if (error.code !== 'EPIPE') stderr.push(Buffer.from(error.message)); });
child.stdin.end(input.stdin || '');
`;
const runner: CommandManagedRuntimeRunner = {
execute: async input => {
const command = `node --input-type=commonjs -e ${shellQuote(executeSource)} ${shellQuote(JSON.stringify(input))}`;
const result = await sandbox.process.executeCommand(command, undefined, undefined, Math.ceil((input.timeoutMs ?? 30000) / 1000) + 10);
if (result.exitCode !== 0) throw new Error(`Daytona test command transport failed (exit ${result.exitCode})`);
return JSON.parse(result.result);
},
openDuplexChannel: async ({ command }) => {
const session = await openDaytonaDuplexChannelSession(sandbox.process, command);
return {
write: bytes => session.write(bytes), onData: listener => session.onData(listener),
onExit: listener => { void session.wait().then(listener); },
stop: () => session.kill(), close: () => session.close(),
};
},
};
try {
const setup = await runner.execute({ command: "bash", args: ["-lc", `mkdir -p ${shellQuote(workspace)} && command -v node && command -v curl && command -v jq`], timeoutMs: 30000 });
if (setup.exitCode !== 0) throw new Error("Daytona test image requires node, curl, and jq");
return { workspace, runner, close: () => sandbox.delete() };
} catch (error) { await sandbox.delete(); throw error; }
}
@@ -1,50 +0,0 @@
import assert from 'node:assert/strict';
import { installMaintenanceIdleWorkCapture } from './idle-work-capture.js';
// Isolated Node/TS-loader identity probe. Never imports app/index or opens a DB.
const original = await import('../../../services/task-admission.js');
const before = process.argv[2] === 'unhandled' ? undefined : original.beginIdleTrackedWork();
const capture = await installMaintenanceIdleWorkCapture();
try {
const observed = await import('../../../services/task-admission.js');
assert.equal(observed.idleWorkSnapshot, original.idleWorkSnapshot);
if (process.argv[2] === 'unhandled') {
const reason = new Error('original unhandled tracked rejection');
let listener!: (reason: unknown, promise: Promise<unknown>) => void;
let timer: ReturnType<typeof setTimeout> | undefined;
const event = new Promise<{ reason: unknown; promise: Promise<unknown> }>((resolve, reject) => {
listener = (reason, promise) => resolve({ reason, promise });
process.once('unhandledRejection', listener);
timer = setTimeout(() => reject(new Error('Original tracked rejection did not reach unhandledRejection')), 1500);
});
try {
// Deliberately never await or attach a handler to this original promise.
const tracked = observed.trackIdleWork(Promise.reject(reason));
const unhandled = await event;
assert.equal(unhandled.promise, tracked);
assert.equal(unhandled.reason, reason);
assert.equal(original.idleWorkSnapshot().active, 0);
assert.equal(capture.snapshot().observedActive, 0);
console.log(JSON.stringify({ unhandledOriginalPromise: true, unhandledOriginalReason: true, finalActive: 0 }));
} finally {
if (timer) clearTimeout(timer);
process.removeListener('unhandledRejection', listener);
}
} else {
assert.equal(observed.idleWorkSnapshot().active, 1); // Existing state was not reset.
assert.equal(capture.snapshot().observedActive, 0); // The pre-install path is explicitly missing.
before!();
const finish = observed.beginIdleTrackedWork();
assert.equal(original.idleWorkSnapshot().active, 1);
finish(); finish();
assert.equal(original.idleWorkSnapshot().active, 0);
assert.equal(await observed.trackIdleWork(Promise.resolve('original-result')), 'original-result');
assert.equal(original.idleWorkSnapshot().active, 0);
const result = capture.summary();
assert(result.snapshot.missingPaths > 0);
console.log(JSON.stringify({ identity: true, originalStatePreserved: true, finalActive: original.idleWorkSnapshot().active, missingPathsExplicit: result.snapshot.missingPaths }));
}
} finally {
before?.();
capture.dispose();
}
@@ -1,93 +0,0 @@
// Separate process: only the provider command sink is simulated.
import { createDb } from "@paperclipai/db";
import { createDeliveryWorkCoordinator } from "../../services/delivery-work-coordinator.ts";
import { deploymentNotifications } from "../../services/deployment-notifications.ts";
import { questionResponseDeliveryService, registerQuestionResponseDeliveryWork } from "../../services/question-response-delivery.ts";
import { deliverNativeQuestionResponse, registerNativeQuestionCommandTarget } from "../../services/native-runtime/native-question-bridge.ts";
let db,
coordinator,
bridge,
worker,
release,
sweeps = 0,
inspections = 0;
process.on("message", async message => {
try {
if (message.type === "init") {
db = createDb(message.url);
coordinator = createDeliveryWorkCoordinator({
owner: db,
canRun: () => true,
onError: () => process.send({
type: "error"
})
});
bridge = deploymentNotifications(db, coordinator, {
directDatabaseUrl: message.url
});
await bridge.ready();
release = registerNativeQuestionCommandTarget({
binding: message.binding,
queueCommand: (type, payload, commandId) => {
process.send({
type: "command",
commandType: type,
requestId: commandId,
payload,
commandId
});
return {
commandId,
controllerSeq: 1
};
}
});
process.send({
type: "ready"
});
} else if (message.type === "start-worker") {
const service = questionResponseDeliveryService(db, {
heartbeat: {
wakeup: async () => {
throw new Error("unexpected fallback");
}
},
resolveNativeQuestion: interaction => deliverNativeQuestionResponse(db, interaction)
});
worker = registerQuestionResponseDeliveryWork(coordinator, {
sweepPending: () => {
sweeps++;
return service.sweepPending();
},
hasPending: () => {
inspections++;
return service.hasPending();
}
});
await worker.ready;
process.send({
type: "worker-ready"
});
} else if (message.type === "snapshot") {
process.send({
type: "snapshot",
requestId: message.requestId,
sweeps,
inspections
});
} else if (message.type === "stop") {
release?.();
await worker?.stop();
await bridge?.stop();
await coordinator?.stop();
await db?.$client.end({
timeout: 1
});
process.exit(0);
}
} catch {
process.send({
type: "error"
});
}
});
@@ -1,65 +0,0 @@
// Test evidence only. Keep observation load beside timing and query counts.
export interface ObserverLoad {
activeViewers: { start: number; end: number; min: number; max: number };
activeSubscribers: { start: number; end: number; min: number; max: number };
diagnosticSubscribers: number;
transport: "authenticated_websocket";
polling: {
applicability: "applicable" | "not_applicable";
reason: "scheduled_log_reads" | "push_only" | "no_viewers";
cadenceMs: number | null;
firstBatchDelayAfterWorkMs: number;
completedBatches: number;
offsetsMs: number[][];
};
}
export interface ObserverReplayMeasurement {
id: string;
fixture: string;
zeroViewerControlId: string;
observers: ObserverLoad;
interval: { startedAt: string; finishedAt: string; wallMs: number; workMs: number };
queries: { persistence: number; viewerDelivery: number; polling: number; visibilityProof: number; total: number };
correctness: {
committedEvents: number;
durableEvents: number;
duplicateReceipts: number;
deliveriesPerViewer: number[];
durableOutput: boolean;
orderedEvents: boolean;
duplicateReplay: boolean;
safeViewerPayloads: boolean;
};
}
export function compareObserverReplays(
baseline: ObserverReplayMeasurement,
candidate: ObserverReplayMeasurement,
axis: "implementation" | "observation_load" = "implementation",
) {
const differences: string[] = [];
if (baseline.fixture !== candidate.fixture) differences.push("fixture");
for (const field of ["activeViewers", "activeSubscribers", "diagnosticSubscribers", "transport"] as const) {
if (JSON.stringify(baseline.observers[field]) !== JSON.stringify(candidate.observers[field])) differences.push(field);
}
// Actual offsets describe scheduling jitter. Compare the configured cadence,
// not the number of reads accumulated in differently sized timing windows.
if (baseline.observers.polling.cadenceMs !== candidate.observers.polling.cadenceMs ||
baseline.observers.polling.firstBatchDelayAfterWorkMs !== candidate.observers.polling.firstBatchDelayAfterWorkMs ||
baseline.observers.polling.applicability !== candidate.observers.polling.applicability) differences.push("polling");
const stable = [baseline, candidate].every(({ observers }) =>
[observers.activeViewers, observers.activeSubscribers].every(count =>
count.start === count.end && count.start === count.min && count.start === count.max));
if (!stable) differences.push("observer_churn");
const status = differences.length === 0 ? "matched"
: axis === "observation_load" && stable && !differences.includes("fixture") ? "observation_experiment"
: "unmatched";
return {
baselineId: baseline.id, candidateId: candidate.id, axis, status, differences,
// Never attribute a performance ratio to a confounded implementation pair.
timingBasis: "interval.workMs",
wallTimeRatio: status === "matched" && baseline.interval.workMs > 0
? candidate.interval.workMs / baseline.interval.workMs : null,
};
}
@@ -1,56 +0,0 @@
import { agents, heartbeatRuns, issueRecoveryActions, issues, type Db } from "@paperclipai/db";
const HOUR = 60 * 60_000;
export type RecoveryPopulation = {
agentIds: string[];
pausedAgentId: string;
terminatedAgentId: string;
inReview: string[];
inProgress: string[];
todo: string[];
withRecoveryAction: string[];
terminated: string[];
};
export async function seedRecoveryPopulation(db: Db, companyId: string, counts: {
agents: number; inReview: number; inProgress?: number; todo?: number; recoveryActions?: number; terminated?: number;
/** False keeps every agent from starting a run, for suites that fake timers. */
wakeOnDemand?: boolean;
}): Promise<RecoveryPopulation> {
const config = { adapterType: "process", adapterConfig: { command: process.execPath, args: ["-e", "0"], cwd: process.cwd() },
runtimeConfig: { heartbeat: { enabled: false, intervalSec: 0, wakeOnDemand: counts.wakeOnDemand ?? true } }, role: "engineer" };
const [ceo] = await db.insert(agents).values({ ...config, companyId, name: "Chief", status: "idle" }).returning({ id: agents.id });
const managers = await db.insert(agents).values(Array.from({ length: 6 }, (_, index) => ({ ...config, companyId,
name: `Manager ${index}`, status: "idle", reportsTo: ceo!.id }))).returning({ id: agents.id });
const workers = await db.insert(agents).values(Array.from({ length: Math.max(1, counts.agents - 9) }, (_, index) => ({ ...config,
companyId, name: `Worker ${index}`, status: "idle", reportsTo: managers[index % managers.length]!.id }))).returning({ id: agents.id });
const [paused] = await db.insert(agents).values({ ...config, companyId, name: "Paused worker", status: "paused",
lifecycleHolds: ["manual"], reportsTo: managers[0]!.id }).returning({ id: agents.id });
const [terminatedAgent] = await db.insert(agents).values({ ...config, companyId, name: "Former worker", status: "terminated",
reportsTo: managers[1]!.id }).returning({ id: agents.id });
const workerIds = workers.map(row => row.id);
const finishedAt = new Date(Date.now() - HOUR);
const insertTasks = async (count: number, values: (index: number) => Partial<typeof issues.$inferInsert>) => count === 0 ? []
: (await db.insert(issues).values(Array.from({ length: count }, (_, index) => ({ companyId, title: `Task ${index}`,
...values(index) }))).returning({ id: issues.id, assigneeAgentId: issues.assigneeAgentId })).map(row => row);
const reviews = await insertTasks(counts.inReview, index => ({ status: "in_review",
assigneeAgentId: workerIds[index % workerIds.length] }));
if (reviews.length) await db.insert(heartbeatRuns).values(reviews.map(task => ({ companyId, agentId: task.assigneeAgentId!,
status: "succeeded", runtimeMode: "native", startedAt: finishedAt, finishedAt, contextSnapshot: { issueId: task.id } })));
const progressing = await insertTasks(counts.inProgress ?? 0, () => ({ status: "in_progress", assigneeAgentId: paused!.id }));
if (progressing.length) await db.insert(heartbeatRuns).values(progressing.map(task => ({ companyId, agentId: paused!.id,
status: "cancelled", errorCode: "agent_paused", startedAt: finishedAt, finishedAt, contextSnapshot: { issueId: task.id } })));
const todo = await insertTasks(counts.todo ?? 0, () => ({ status: "todo", assigneeAgentId: paused!.id }));
const terminated = await insertTasks(counts.terminated ?? 0, () => ({ status: "todo", assigneeAgentId: terminatedAgent!.id }));
const withAction = reviews.slice(0, counts.recoveryActions ?? 0);
if (withAction.length) await db.insert(issueRecoveryActions).values(withAction.map((task, index) => ({ companyId,
sourceIssueId: task.id, kind: "missing_disposition", status: "active", ownerType: "agent", ownerAgentId: task.assigneeAgentId,
cause: "seeded", fingerprint: `seeded-${index}`, nextAction: "seeded" })));
return { agentIds: [ceo!.id, ...managers.map(row => row.id), ...workerIds, paused!.id, terminatedAgent!.id],
pausedAgentId: paused!.id, terminatedAgentId: terminatedAgent!.id,
inReview: reviews.map(row => row.id), inProgress: progressing.map(row => row.id), todo: todo.map(row => row.id),
withRecoveryAction: withAction.map(row => row.id), terminated: terminated.map(row => row.id) };
}