mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-03 11:47:42 +01:00
## Thinking Path > - Paperclip helps people manage work with AI agents. > - A release must pass onboarding before it reaches nightly. > - Onboarding changes already run source browser tests on PRs. > - The published release smoke used a separate scenario, which could drift from those tests. > - That drift blocked the December 1 nightly after onboarding succeeded. > - This PR fixes the stale welcome assertion and shares the scenario between release smoke and relevant PR E2E runs. ## Linked Issues or Issue Description Refs #23334 and #22259. **What happened?** [The December 1 nightly release](https://github.com/paperclipai/paperclip/actions/runs/46614290688) failed twice at `The onboarding chat must queue the lead's live welcome`. PR #23334 changed the welcome to a saved message and a question card. The greeting endpoint succeeded with `started: true` and `runId: null`, but the release test still required a model run. PR browser tests did not run those release expectations against the changed source. **Expected behavior** Onboarding PRs and changes to their shared dependencies must run the release scenario before merge. Known unrelated leaf-page changes and source-unit-test-only changes can omit the extra case. Shared and unfamiliar source paths must keep coverage. The scenario must check the lead's welcome and all three first-chat choices, with no model run before the user sends a choice or message. A mismatch must fail the required `ci / e2e` check. **Steps to reproduce** 1. Start the Docker onboarding harness with `PAPERCLIPAI_VERSION=2026.1130.0-canary.873300` and its provider verification mock. 2. Run the original release smoke test. 3. Observe successful login, setup, hire, and chat entry, followed by a timeout because the run list stays empty. **Paperclip version or commit** Failed release source: `7ce7d99f8af81ae90f97650ef7a8692a86c63a35`. Published package: `2026.1130.0-canary.873300`. **Deployment mode** The release test uses authenticated private Docker mode. The new PR test uses the existing disposable source E2E instance and provider verification fixture. ## What Changed - Check the saved welcome and the three visible choices, then require an empty agent run list. - Move the complete wizard, hire, and chat assertions into one shared onboarding scenario. Keep sign-in in the authenticated release wrapper. - Add the shared scenario to the normal PR E2E suite. Omit only this extra case when eligible source changes are confined to the Costs or Approvals UI page, source unit tests, and audited prose. Shared components, hooks, libraries, server code, mixed changes, and unfamiliar source paths keep it. The repository rules require `ci / e2e` before merge. - Pass the trusted CI change plan to shard selection and bind it to the checked-out commit. Reuse the existing lightweight source-diff eligibility gate for both Vitest and E2E, with the old Vitest export preserved. Full and shadow CI, broad or deleted inputs, invalid plans, and stale plans keep the case. No extra browser job or matrix is added. - Add release smoke files to the E2E and typecheck task inputs. Test that onboarding changes select E2E and that smoke-only changes select their two owners without forcing unrelated lanes. - Document the shared test command and the source and installation coverage. ## Verification The shared browser scenario is unchanged from `2044ada98e953504af68febe4c196f414d0bb1ae`. The selector review fix is based on master’s hosted-shard speed improvement. Selector and eligibility verification covers `236640e419d1177aafb64f3f7dd1ee49848ee707`. - Reproduced the original nightly timeout locally against the exact published canary. - The extracted release scenario passed against that canary in 22.1 seconds. - The new source E2E passed against PR source and the built UI in 32.3 seconds. - Restored the obsolete model-run assertion temporarily. The new source E2E failed with the same `Expected: > 0 / Received: 0` timeout. Restored the correct assertion. The final source confirmation passed in 31.7 seconds. - `node --test scripts/__tests__/e2e-shard.test.mjs .github/scripts/tests/ci-plan.test.mjs scripts/ci/test-selection-workflow.test.mjs`: all 52 tests passed after rebase. Coverage includes unrelated changes, relevant dependencies, rename paths, full/invalid/stale plans, exact CLI shard partitions, and both hosted shard policies. The unrelated-change and wiring tests failed before the filter was implemented. - Regression selection tests failed on `TaskChatComposer.tsx` and shadow mode before this review fix. They now keep the composer, new-agent runtime configuration, AI connection components, hooks, libraries, and mixed source changes. - The 3 existing source-diff eligibility contract tests passed after extraction into the shared module. - `actionlint .github/workflows/pr-trusted.yml` passed. - `node --test scripts/ci/test-selection-inputs.test.mjs`: 4 tests passed. - The Playwright program and focused source scenario typechecks passed. The test-budget check and `git diff --check` passed. - The default local source bootstrap could not load the macOS embedded PostgreSQL binary because its distribution lacked `libzstd.1.dylib`. Source browser verification used a separate disposable Docker PostgreSQL 16 instance. Linux CI will cover the normal embedded database path. - Earlier [hosted release smoke](https://github.com/paperclipai/paperclip/actions/runs/46776940022) passed both Docker onboarding and Linux background-service onboarding at the first fix commit. The service job first hit npm package propagation and passed on retry after publication completed. - `pnpm verify --explain` requested broader CI coverage because the CI task inputs changed. The focused checks above passed; the required CI jobs will provide broad coverage. - [Final-revision CI](https://github.com/paperclipai/paperclip/actions/runs/46782167000) passed on `236640e419d1177aafb64f3f7dd1ee49848ee707`. Both required aggregates, all 16 browser shards, and all selected typecheck, build, server, Runner, and canary dry-run jobs passed. [Incremental CI qualification](https://github.com/paperclipai/paperclip/actions/runs/46782166749) also passed. - [The new source onboarding case](https://github.com/paperclipai/paperclip/actions/runs/46782167000/job/143123174120) ran on the hosted Linux runner and passed in 20.8 seconds. - [Greptile review](https://github.com/paperclipai/paperclip/pull/23432#issuecomment-7330325410) scored `236640e419d1177aafb64f3f7dd1ee49848ee707` 5/5 and confirmed the shared-dependency finding is fixed. There are no unresolved review threads. ## Risks - This changes test coverage and CI selection. It does not change application behavior, release permissions, or publication rules. - The source case stays on for shared and unfamiliar source changes. It skips only the documented leaf pages and source-unit-test-only edits in eligible plans. Local full E2E still includes it. Extend exclusions only after checking that a path cannot affect onboarding. - The trusted PR workflow is loaded from master. Before merge, the current workflow keeps the full fallback because it does not yet pass the change plan to the shard command. The unit and CLI tests qualify the filtered path; after merge, the new workflow environment activates it. - The source test uses local trusted authentication. The authenticated published-package test remains responsible for login and installation checks. Neither run needs paid model completions. - GitHub master rules require code-owner approval for the protected CI changes. Those review requests are already open. There are no conflicts or unresolved review threads. - A replacement nightly still needs a successful release run after this reaches master. This PR does not bypass qualification or promote beta or stable. ## Model Used OpenAI Codex, `gpt-6.1-sol`, with xhigh reasoning effort, terminal tools, GitHub CLI, and Playwright. The harness does not report the context window size. ## 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 <noreply@paperclip.ing>
121 lines
6.5 KiB
JavaScript
121 lines
6.5 KiB
JavaScript
import { execFileSync } from "node:child_process";
|
|
import { appendFileSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
import { fileURLToPath } from "node:url";
|
|
import path from "node:path";
|
|
import assert from "node:assert/strict";
|
|
import { refineTestPlan, selectionDurations } from "./test-selection-plan.mjs";
|
|
import { activeNightlySuitesForEnv } from "./nightly-only-suites.mjs";
|
|
import { productInputs } from "../../.github/scripts/ci-inputs.mjs";
|
|
import { mergeDiff } from "../../.github/scripts/ci-diff.mjs";
|
|
import { selectProjects } from "./select-projects.mjs";
|
|
import { selectionEligibility } from "./selection-eligibility.mjs";
|
|
|
|
export { selectionEligibility };
|
|
|
|
function runnerInventory(group) {
|
|
const args = group === "serialized" ? ["--mode", "serialized", "--shard-index", "0", "--shard-count", "1"]
|
|
: ["--mode", "general", "--group", group,
|
|
...(group === "general-server-without-chat" ? ["--shard-index", "0", "--shard-count", "1"] : [])];
|
|
const env = { ...process.env, GITHUB_WORKFLOW: "PR", PAPERCLIP_CI_FULL: "1" };
|
|
delete env.PAPERCLIP_CI_TEST_SELECTION;
|
|
return JSON.parse(execFileSync(process.execPath, ["scripts/run-vitest-stable.mjs", ...args, "--dry-run"],
|
|
{ env, encoding: "utf8", maxBuffer: 16 * 1024 * 1024 }));
|
|
}
|
|
|
|
export async function createTestSelection(plan, head, { runnerProfile = process.env.CI_RUNNER_PROFILE || "aws" } = {}) {
|
|
const reason = selectionEligibility(plan);
|
|
if (reason) throw new Error(reason);
|
|
const groups = new Set();
|
|
for (const job of ["general_tests", "verify_serialized_server"]) {
|
|
if (plan.jobs[job].run) for (const entry of plan.jobs[job].matrix.include) groups.add(entry.group ?? "serialized");
|
|
}
|
|
const owners = {}, projects = new Set(), inventories = new Map();
|
|
const inventoryFor = group => {
|
|
if (!inventories.has(group)) inventories.set(group, runnerInventory(group));
|
|
return inventories.get(group);
|
|
};
|
|
for (const group of groups) {
|
|
const inventory = inventoryFor(group);
|
|
if (group === "serialized" || group === "general-server-without-chat" || group === "general-chat") {
|
|
owners[group] = { "@paperclipai/server": group === "serialized"
|
|
? inventory.selectedSerializedSuites
|
|
: group === "general-chat"
|
|
? inventory.selectedChatSuites
|
|
: inventory.selectedGeneralServerSuites };
|
|
projects.add("@paperclipai/server");
|
|
} else {
|
|
owners[group] = Object.fromEntries(inventory.workspaceProjects.map((project) => [project, null]));
|
|
for (const project of inventory.workspaceProjects) projects.add(project);
|
|
}
|
|
}
|
|
const changed = productInputs(plan.changed);
|
|
const graphs = await selectProjects({ projects: [...projects], changed });
|
|
for (const graph of graphs) {
|
|
const { project } = graph;
|
|
console.log(`${project}: ${graph.selected.length}/${graph.inventory.length} files, ${graph.alwaysRun.length} retained conservatively, ${graph.seconds.toFixed(1)}s`);
|
|
for (const owner of Object.values(owners)) if (owner[project] === null) owner[project] = graph.inventory;
|
|
}
|
|
const covered = new Set(graphs.flatMap((graph) => graph.coveredChanges));
|
|
for (const file of changed) assert.ok(covered.has(file), `Change outside the resolved test graphs: ${file}`);
|
|
const server = graphs.find((graph) => graph.project === "@paperclipai/server");
|
|
if (server) {
|
|
const general = inventoryFor("general-server-without-chat");
|
|
const native = inventoryFor("general-server-native-runner");
|
|
const chat = inventoryFor("general-chat");
|
|
assert.deepEqual([...general.selectedGeneralServerSuites, ...general.selectedSerializedSuites,
|
|
...native.selectedGeneralServerSuites, ...chat.selectedChatSuites].sort(),
|
|
server.inventory, "Server inventory must be completely covered by existing lane ownership");
|
|
}
|
|
const excludedSuites = activeNightlySuitesForEnv();
|
|
return { ...refineTestPlan({ plan, head, owners, graphs, durations: selectionDurations(), excludedSuites, runnerProfile }), graphs };
|
|
}
|
|
|
|
async function main() {
|
|
const plan = JSON.parse(process.env.CI_PLAN || "null");
|
|
const output = (key, value) => {
|
|
if (process.env.GITHUB_OUTPUT) appendFileSync(process.env.GITHUB_OUTPUT, `${key}=${value}\n`);
|
|
};
|
|
if (process.argv.includes("--eligible")) {
|
|
const reason = selectionEligibility(plan);
|
|
console.log(reason ?? "Source diff is eligible for graph selection");
|
|
output("enabled", !reason);
|
|
return;
|
|
}
|
|
const directory = ".ci-test-selection";
|
|
mkdirSync(directory, { recursive: true });
|
|
const git = (...args) => execFileSync("git", args, { encoding: "utf8", maxBuffer: 16 * 1024 * 1024 }).trim();
|
|
let result;
|
|
try {
|
|
const head = git("rev-parse", "HEAD");
|
|
assert.equal(head, process.env.GITHUB_SHA, "Selection must describe the tested merge commit");
|
|
assert.ok(plan.diff, "Missing trusted merge diff");
|
|
const local = mergeDiff(head, plan.diff.prHead);
|
|
assert.deepEqual(local.diff, plan.diff, "Selection must use the trusted merge parents");
|
|
assert.deepEqual(local.changed, [...new Set(plan.changed)].sort(), "Local diff disagrees with the trusted routing diff");
|
|
assert.equal(git("status", "--porcelain", "--untracked-files=normal"), "", "Source inputs changed during dependency setup");
|
|
process.env.NODE_ENV = "test";
|
|
process.env.VITEST = "true";
|
|
result = await createTestSelection(plan, head);
|
|
writeFileSync(`${directory}/manifest.json`, JSON.stringify(result.manifest));
|
|
writeFileSync(`${directory}/audit.json`, JSON.stringify(result.graphs, null, 2));
|
|
output("selected", "true");
|
|
} catch (error) {
|
|
console.warn(`Using the complete task plan: ${error.message}`);
|
|
result = { plan: { ...plan, testSelectionFallback: error.message } };
|
|
output("selected", "false");
|
|
}
|
|
writeFileSync(`${directory}/plan.json`, JSON.stringify(result.plan));
|
|
if (process.env.GITHUB_STEP_SUMMARY) {
|
|
const stats = result.plan.testSelection?.stats;
|
|
appendFileSync(process.env.GITHUB_STEP_SUMMARY, stats
|
|
? ["### Vitest test selection", "", "| Lane | Test files | Jobs |", "| --- | ---: | ---: |",
|
|
...stats.map((s) => `| ${s.group} | ${s.selected}/${s.total} | ${s.jobs}/${s.beforeJobs} |`), "",
|
|
"Filesystem/process/opaque consumers are retained. Chat and native Runner lanes keep their existing ownership.", ""].join("\n")
|
|
: `### Vitest test selection\n\nFull task plan: ${result.plan.testSelectionFallback}\n`);
|
|
}
|
|
}
|
|
|
|
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
main().catch((error) => { console.error(error); process.exitCode = 1; });
|
|
}
|