mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-03 17:51:58 +01:00
## Thinking Path > - Paperclip manages AI agents and preserves their work history. > - Product E2E cases use TestOps plans to select real AWS evaluations. > - The full chat catalog now includes the former smoke and completion-pilot cases. > - The two old bootstrap workflows can recreate their smaller plans after deletion. > - This pull request removes those workflows and stops their plan-creation functions before API access. > - The full-catalog workflow keeps its shared clients, evidence rules, case identities, and measured results. ## Linked Issues or Issue Description Refs #18542, #18516. The user requested removal of the duplicate smoke and completion-pilot plans and investigation of their recreation paths. Both old workflows accepted manual dispatch only. Their bootstrap operations created plans by name when the plans were absent. They had no schedules in their workflow definitions. The old workflow records were disabled before plan removal. An existing pilot execution was allowed to finish successfully. This change does not cancel executions or delete cases, results, launches, or private evidence. ## What Changed - Remove `chat-feature-testops.yml` and `chat-completion-testops.yml`. - Make the former singleton plan creator reject every call before API reads or mutation markers. - Reject pilot bootstrap before API access. Keep the full-catalog branch and its integration validation. - Remove tests that require the retired workflow files. Keep shared helper and full-catalog controls. Run the trusted-checkout boundary test against the active catalog workflow. - Replace old setup instructions with retirement guidance and the active full-catalog route. The master sync preserves the incoming typed launch-search fix from #18620, including both regression tests. The only conflict was the retired pilot documentation. Its search-format note remains as a retained-helper contract. ## Verification - Two new retirement controls fail against the parent code because it reaches an API or mutation marker. Both pass after the change. - Six owning Node suites after the master sync: 146 passed (144 before the sync). Shared contract: 22 passed. Catalog and retained export controls: 12 passed. Focused workflow and release controls: 7 passed. - Two modified API modules pass Node syntax checks. `git diff --check` passes. - The pure workflow-security file has the same four failures and 13 passes on both the untouched parent and this branch. Two assertions expect eight trusted bootstrap steps where master now has nine. Two lists omit the already-shipped catalog workflow. This change does not repair or relax those unrelated assertions. - A broader release-test invocation had 73 passes and 20 sandbox failures from blocked mock HTTP listeners or npm permissions. Its focused affected workflow control passes. A standard Vitest setup attempt stopped on a missing `acpx/runtime` bundle dependency before tests. No local app, database, provider, or native runtime was qualified. - Current-head PR CI passes: 48 successful jobs and one skipped job, including both required checks. Greptile is 5/5. Independent source review passes. No new model run is needed for this retirement. ## Risks - Existing integrations that point at either retired workflow will stop dispatching. This is the requested behavior; use the full catalog instead. - Historical evidence readers still use shared helpers. Those helpers remain, including the transport and official-context parser used by the active catalog. - Workflow removal is a repository change. TestOps plan deletion and disabling obsolete executors are separate service actions. Neither action should delete shared cases or measurements. ## Model Used OpenAI `gpt-6.1-sol` through Codex, with source editing, shell tools, and independent source review. The context-window size is not asserted. ## 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>
123 lines
8.2 KiB
JavaScript
123 lines
8.2 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { execFileSync } from 'node:child_process';
|
|
import { mkdir, mkdtemp, readFile, realpath, rm, writeFile } from 'node:fs/promises';
|
|
import os from 'node:os';
|
|
import path from 'node:path';
|
|
import { parse } from 'yaml';
|
|
import { admitDispatch, cases, targetSha, validateSelection, evidencePolicy } from './chat-completion-testops-contract.mjs';
|
|
import { actualContext } from './chat-completion-testops-cli.mjs';
|
|
|
|
function fixture() {
|
|
const env = { GITHUB_ACTIONS: 'true', GITHUB_EVENT_NAME: 'workflow_dispatch', GITHUB_REPOSITORY: 'paperclipai/paperclip',
|
|
GITHUB_REF: 'refs/heads/master', GITHUB_WORKFLOW_REF: 'paperclipai/paperclip/.github/workflows/chat-completion-testops.yml@refs/heads/master',
|
|
GITHUB_SHA: 'a'.repeat(40), GITHUB_RUN_ID: '123', GITHUB_RUN_ATTEMPT: '1', GITHUB_ACTOR_ID: '42', TESTOPS_ALLOWED_ACTOR_IDS: '[42]' };
|
|
const event = { repository: { full_name: 'paperclipai/paperclip', private: false, default_branch: 'master' },
|
|
ref: env.GITHUB_REF, sender: { id: 42 }, inputs: { ALLURE_JOB_RUN_ID: '77' } };
|
|
const context = admitDispatch(env, event, 42);
|
|
const selection = { schema: 'paperclip.chat-completion-testops-selection/v1', ...context, projectId: 1,
|
|
allureJobRunId: '77', planId: 10, jobId: 11, launchId: 12, cases: cases.map((row, index) => ({ ...row, caseId: 100 + index })) };
|
|
return { env, event, context, selection };
|
|
}
|
|
|
|
test('actual TestOps selection can execute the three exact cases or a genuine subset', () => {
|
|
const f = fixture(); assert.equal(validateSelection(f.selection, f.context, '77').length, 3);
|
|
f.selection.cases = [f.selection.cases[2]];
|
|
const policy = evidencePolicy(f.selection, f.context, '77');
|
|
assert.deepEqual(policy.approvals[0].executionIds, [cases[2].executionId]);
|
|
assert.equal(policy.approvals[0].targetSha, targetSha);
|
|
});
|
|
|
|
for (const kind of ['foreign-workflow', 'candidate-ref', 'replay', 'unlisted-trigger', 'foreign-repo', 'extra-source-input', 'missing-jobrun']) {
|
|
test(`rejects ${kind} before any service or provider credential`, () => {
|
|
const f = fixture(); let trigger = 42;
|
|
if (kind === 'foreign-workflow') f.env.GITHUB_WORKFLOW_REF = f.env.GITHUB_WORKFLOW_REF.replace('chat-completion', 'chat-feature');
|
|
if (kind === 'candidate-ref') f.env.GITHUB_REF = 'refs/heads/codex/candidate';
|
|
if (kind === 'replay') f.env.GITHUB_RUN_ATTEMPT = '2';
|
|
if (kind === 'unlisted-trigger') trigger = 99;
|
|
if (kind === 'foreign-repo') f.event.repository.full_name = 'foreign/paperclip';
|
|
if (kind === 'extra-source-input') f.event.inputs.targetSha = 'b'.repeat(40);
|
|
if (kind === 'missing-jobrun') delete f.event.inputs.ALLURE_JOB_RUN_ID;
|
|
assert.throws(() => admitDispatch(f.env, f.event, trigger));
|
|
});
|
|
}
|
|
|
|
for (const kind of ['foreign-case', 'duplicate', 'wrong-fullname', 'foreign-source', 'wrong-run', 'wrong-jobrun', 'duplicate-case-id']) {
|
|
test(`refuses evidence authority for ${kind}`, () => {
|
|
const f = fixture();
|
|
if (kind === 'foreign-case') f.selection.cases[0].executionId = 'chat-features.runner-opencode.local.tasks.delete';
|
|
if (kind === 'duplicate') f.selection.cases.push(f.selection.cases[0]);
|
|
if (kind === 'wrong-fullname') f.selection.cases[0].fullName = cases[1].fullName;
|
|
if (kind === 'foreign-source') f.selection.targetSha = 'b'.repeat(40);
|
|
if (kind === 'wrong-run') f.selection.runId = '456';
|
|
if (kind === 'wrong-jobrun') f.selection.allureJobRunId = '78';
|
|
if (kind === 'duplicate-case-id') f.selection.cases[1].caseId = f.selection.cases[0].caseId;
|
|
assert.throws(() => evidencePolicy(f.selection, f.context, '77'));
|
|
});
|
|
}
|
|
|
|
test('bootstrap and the fenced plan launcher cannot carry a TestOps execution identity', () => {
|
|
const f = fixture(); f.event.inputs = { operation: 'bootstrap' };
|
|
assert.equal(admitDispatch(f.env, f.event, 42).operation, 'bootstrap');
|
|
f.event.inputs.operation = 'launch-plan'; assert.equal(admitDispatch(f.env, f.event, 42).operation, 'launch-plan');
|
|
f.event.inputs.ALLURE_JOB_RUN_ID = '77'; assert.throws(() => admitDispatch(f.env, f.event, 42));
|
|
});
|
|
|
|
for (const value of ['00077', '9007199254740992', '12345678901234567']) {
|
|
test(`dispatch rejects unsafe job identity ${value}`, () => {
|
|
const f = fixture(); f.event.inputs.ALLURE_JOB_RUN_ID = value; assert.throws(() => admitDispatch(f.env, f.event, 42));
|
|
});
|
|
}
|
|
test('dispatch preserves the maximum safe TestOps job identity', () => {
|
|
const f = fixture(); f.event.inputs.ALLURE_JOB_RUN_ID = '9007199254740991';
|
|
assert.equal(admitDispatch(f.env, f.event, 42).operation, 'evaluate');
|
|
});
|
|
|
|
test('the executable guard binds the actual original GitHub run before service or provider access', async () => {
|
|
const root = await realpath(await mkdtemp(path.join(os.tmpdir(), 'testops-context-')));
|
|
try {
|
|
const f = fixture(), eventPath = path.join(root, 'event.json'); await writeFile(eventPath, JSON.stringify(f.event));
|
|
const env = { ...f.env, GITHUB_EVENT_PATH: eventPath, GH_TOKEN: 'synthetic-gh-token', GITHUB_RUN_NUMBER: '5' };
|
|
const run = { id: 123, run_attempt: 1, run_number: 5, workflow_id: 99, head_sha: env.GITHUB_SHA, head_branch: 'master',
|
|
event: 'workflow_dispatch', path: '.github/workflows/chat-completion-testops.yml', repository: { full_name: 'paperclipai/paperclip', private: false },
|
|
actor: { id: 42 }, triggering_actor: { id: 42 } };
|
|
let calls = 0;
|
|
const exec = async (program, args) => {
|
|
calls++; assert.equal(program, 'gh'); assert.deepEqual(args, ['api', 'repos/paperclipai/paperclip/actions/runs/123']);
|
|
return { stdout: JSON.stringify(run) };
|
|
};
|
|
assert.equal((await actualContext(env, exec)).workflowId, 99); assert.equal(calls, 1);
|
|
for (const field of ['head_sha', 'path', 'head_branch', 'run_attempt', 'run_number', 'workflow_id']) {
|
|
const other = { ...run, [field]: typeof run[field] === 'number' ? run[field] + 1 : 'wrong' };
|
|
if (field === 'workflow_id') other[field] = 0;
|
|
await assert.rejects(actualContext(env, async () => ({ stdout: JSON.stringify(other) })));
|
|
}
|
|
await assert.rejects(actualContext({ ...env, GITHUB_RUN_ID: '../other' }, () => assert.fail('no request before numeric admission')));
|
|
} finally { await rm(root, { recursive: true, force: true }); }
|
|
});
|
|
|
|
test('target checkout cannot populate or overwrite the trusted helper path', async () => {
|
|
const definition = parse(await readFile(new URL('../../.github/workflows/chat-catalog-testops.yml', import.meta.url), 'utf8'));
|
|
const root = await realpath(await mkdtemp(path.join(os.tmpdir(), 'testops-checkout-boundary-')));
|
|
try {
|
|
const git = (...args) => execFileSync('git', ['-c', 'core.hooksPath=/dev/null', '-c', 'commit.gpgsign=false', ...args], { cwd: root, stdio: 'pipe' });
|
|
git('init'); await writeFile(path.join(root, 'fixture.txt'), 'normal target'); git('add', '.');
|
|
git('-c', 'user.name=Fixture', '-c', 'user.email=fixture@example.invalid', 'commit', '-m', 'normal target');
|
|
for (const job of [definition.jobs.build, definition.jobs.chat]) {
|
|
const target = job.steps.findIndex(step => step.with?.ref === '${{ needs.authorize.outputs.target_sha }}');
|
|
const boundary = job.steps.findIndex(step => step.id === 'target_boundary');
|
|
const trusted = job.steps.findIndex(step => step.with?.path === '.testops-trusted');
|
|
assert.ok(target >= 0 && boundary > target && trusted > boundary, 'Reject reserved target paths, then check out trusted main last');
|
|
assert.notEqual(job.steps[target].with.clean, false);
|
|
execFileSync('bash', ['-euo', 'pipefail', '-c', job.steps[boundary].run], { cwd: root, stdio: 'pipe' });
|
|
}
|
|
await mkdir(path.join(root, '.testops-trusted'));
|
|
await writeFile(path.join(root, '.testops-trusted', 'helper.js'), 'candidate-controlled helper'); git('add', '.testops-trusted');
|
|
git('-c', 'user.name=Fixture', '-c', 'user.email=fixture@example.invalid', 'commit', '-m', 'reserved path in target');
|
|
for (const job of [definition.jobs.build, definition.jobs.chat]) {
|
|
const guard = job.steps.find(step => step.id === 'target_boundary');
|
|
assert.throws(() => execFileSync('bash', ['-euo', 'pipefail', '-c', guard.run], { cwd: root, stdio: 'pipe' }));
|
|
}
|
|
} finally { await rm(root, { recursive: true, force: true }); }
|
|
});
|