Files
PaperClipAI/tests/runner-e2e/catalog-overview.test.ts
T
DottaandPaperclip 99d27fd5e7 feat(evals): add a metadata overview for the chat catalog (#18194)
## Thinking Path

> - Paperclip is a control plane for AI agents that do work.
> - Its evaluation reports separate recorded results from source
coverage.
> - A case without a main baseline measurement can still have a
candidate run.
> - A normal campaign card treats an expected execution without a result
as missing evidence.
> - Catalog planning data must not create those cards or change a
recorded grade.
> - This change adds a typed metadata view to the existing Evals
dashboard.
> - Readers can compare main outcomes, candidate execution, allowances
and source review separately.

## Linked Issues or Issue Description

**What existing behavior does this improve?**

The existing Evals dashboard can show a campaign's retained results. It
cannot show the full chat catalog as metadata without synthetic result
entries.

**Current behavior**

An unused initial, an unknown allowance and a completed candidate run
can all lack a main baseline result. Showing them as missing campaign
artifacts hides these differences.

**Proposed behavior**

Add one validated metadata view in the existing renderer. Show one row
per frozen scenario, separate execution and main outcome columns,
filters, and the public request and expected outcome from static YAML.
Keep normal campaign cards unchanged.

**Reason and benefit**

Readers can see which cases ran, which have no main measurement, and
which still need preparation. Source review and candidate outcomes
cannot add baseline pass credit.

**Breaking changes**

None to existing campaign inputs or outputs. The new metadata mode uses
its own strict schema and requires a new private output directory.

No matching open or closed PR or issue was found in the duplicate
search.

## What Changed

- Add a strict display-only catalog schema with closed enums and fixed
catalog scope.
- Validate the 244 row identities against static YAML without importing
executable case callbacks.
- Show main results, recorded execution, allowances and source review in
separate columns.
- Add search and filters, passing examples, qualification notes and
expandable public test descriptions.
- Add one dated immutable snapshot link in the existing shared report
navigation. This does not change history data or update an
already-published page.
- Add a private metadata preview command to the existing dashboard
owner. Keep existing campaign generation on its current path.
- Keep allowance certainty independent of measurements and allow an
optional later candidate outcome alongside a main outcome, without
changing main counters.
- Add focused pure, JSDOM and file-loader checks. Document the metadata
command.

## Verification

- The owning `catalog-overview.test.ts` Vitest suite passes all fourteen
tests under the focused source configuration. The
valid-main/unknown-allowance and main-fail/later-candidate-pass controls
fail against the old renderer and pass with this repair. The
never-run/unknown-allowance control fails against e8686bf and passes
with the restored consistency guard.
- Scoped TypeScript verification of the changed source and its imports
has no diagnostics.
- The tests cover closed schema fields, duplicate and invented IDs,
candidate/main separation, filters, HTML escaping, private output mode,
existing output refusal, symlink and oversized input refusal, static
descriptions, and the normal campaign branch. Ceiling values below,
equal to and above the target are covered. Unsupported navigation is
hidden only in metadata mode.
- The source was independently reviewed. Actual generated DOM validation
also checked 244 rows and all public descriptions.
- No visual browser verification or live product journey is claimed. No
credentials, private projection, generated report or evidence files are
included in this PR.
- Repo-wide builds were not run locally for this report-only slice.
Normal remote CI passed on repair head `f813c18`, with 55 successful
checks, two skipped checks and one neutral review check. Required `ci /
verify` and `ci / e2e` both passed. Current-head Greptile is 5/5 and no
review threads remain open. The e8686bf normal CI had an initial failed
attempt and a successful failed-only replay. Both are retained; that
replay does not substitute for current-head verification.
- The first f813c18 CI attempt passed 373 tests in serialized server
shard 4/9 but failed one existing scheduled-retry test: its intermediate
cancellation count was 29 rather than 20. The actual CI-tested test,
route, worker, scheduler and DB-fixture source matches prior passing CI.
The one failed-only replay passed all 374 tests in that shard on the
unchanged head. The first failure remains recorded; no assertion or
timeout changed.
- Rendering the authenticated existing projection through both old and
new generators produces byte-identical HTML and both assets. The
already-published dated snapshot is unchanged.

## Risks

The view depends on an authenticated metadata projection. Shape
validation does not qualify source or execution. The view preserves
unknown states and keeps candidate outcomes outside main qualification.
The preview command does not publish reports or alter history. Existing
campaign result behavior remains separate. Shared navigation gains one
dated link. Existing published pages need a separate conditional
activation; this PR does not upload or rewrite them.

## Model Used

OpenAI GPT-6 through Codex, with source editing, tool use and pure/JSDOM
checks. The exact serving model ID and context-window size are not
exposed to this worker.

## 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>
2026-10-29 16:05:12 -05:00

152 lines
13 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { readFileSync, readdirSync } from "node:fs";
import { createRequire } from "node:module";
const { JSDOM } = createRequire(new URL("../../server/package.json", import.meta.url))("jsdom") as typeof import("../../server/node_modules/@types/jsdom/index.js");
import { mkdtemp, writeFile, stat, rm, readFile, symlink } from "node:fs/promises";
import path from "node:path";
import os from "node:os";
import { regenerateCatalogOverview } from "./dashboard-regenerate.js";
import { parseCatalogOverview, type CatalogOverview } from "./catalog-overview.js";
import { renderRunnerE2EDashboard } from "./dashboard.js";
function fixture(): CatalogOverview {
const catalog = new URL("./chat-scenarios/", import.meta.url);
const ids = readdirSync(catalog).filter(name => name.endsWith(".yaml")).flatMap(name => [...readFileSync(new URL(name,catalog),"utf8").matchAll(/^ - id: ([a-z0-9.-]+)$/gm)].map(match => match[1]!));
const example = ids.indexOf("projects.create-project"); [ids[0],ids[example]]=[ids[example]!,ids[0]!];
const rows: CatalogOverview["rows"] = ids.map((scenarioId,i)=>({scenarioId, mainOutcome:i<25?"passed":i<169?"failed":"unmeasured",allowance:i<102?"exhausted":i>=169&&i<218?"unused-initial":i===243?"unknown":"final-available",sourceReadiness:"not-assessed",executionRecord:i<169?"main-measured":i<218?"never-run":i===243?"unknown":"candidate-measured"}));
return { schema:"paperclip.catalog-overview/v2", asOf:"2026-10-29T17:54:00Z", definitions:{lazy:242,legacy:2,featureAreas:35,capabilities:191,declaredGaps:5}, accounting:{mainMeasurements:215,retainedRawResults:295,closedSlots:296,exhaustedFinals:102,theoreticalMainCeiling:152}, rows };
}
function page(data: CatalogOverview) {
return renderRunnerE2EDashboard({title:"Catalog",generatedAt:data.asOf,expected:[],catalog:[],entries:[],catalogOverview:data});
}
describe("display-only catalog overview", () => {
it("requires the fixed scope and rejects private carrier fields rather than serializing them", () => {
const data=fixture();
expect(parseCatalogOverview(data).rows).toHaveLength(244);
expect(() => parseCatalogOverview({...data,privatePath:"/private/hidden"})).toThrow("Unexpected");
expect(() => parseCatalogOverview({...data,rows:data.rows.map((r,i)=>i? r : {...r,errorBody:"secret"})})).toThrow("Unexpected");
expect(() => parseCatalogOverview({...data,definitions:{...data.definitions,legacy:0}})).toThrow("Frozen");
});
it("rejects duplicate rows, invalid IDs/states, impossible counts and mixed real results", () => {
const data=fixture();
expect(() => parseCatalogOverview({...data,rows:[...data.rows.slice(1),data.rows[1]]})).toThrow("Duplicate");
expect(() => parseCatalogOverview({...data,rows:data.rows.map((r,i)=>i?r:{...r,scenarioId:'<img src=x onerror=alert(1)>'})})).toThrow("Invalid public");
expect(() => parseCatalogOverview({...data,rows:data.rows.map((r,i)=>i?r:{...r,mainOutcome:'candidate-pass'})})).toThrow("Invalid");
expect(() => parseCatalogOverview({...data,accounting:{...data.accounting,mainMeasurements:2}})).toThrow("Inconsistent");
expect(() => renderRunnerE2EDashboard({title:"mixed",generatedAt:data.asOf,expected:["real-case"],catalog:[],entries:[],catalogOverview:data})).toThrow("cannot be mixed");
});
it("renders metadata counts and scopes without fake result cards or evidence links", () => {
const data=fixture(); const doc=new JSDOM(page(data)).window.document;
expect(doc.querySelectorAll('[data-catalog-row]')).toHaveLength(244);
expect(doc.querySelectorAll('[data-report-case]')).toHaveLength(0);
expect(doc.querySelector('[data-report-scope]')?.getAttribute('data-report-scope')).toBe('global');
const text=doc.querySelector('main')!.textContent!;
for(const value of ['25','144','75','49 unused initials','295 retained results','296 closed ordinal slots','102 exhausted finals','152/244','242 lazy definitions plus 2 implemented legacy']) expect(text).toContain(value);
expect(text).toContain('Fully native auxiliary setup and complete usage qualification are not established');
expect(text).not.toContain('No result artifact was uploaded');
expect(text).not.toContain('2 unimplemented');
expect(doc.querySelectorAll('a[href*="create-project"]')).toHaveLength(1);
expect(doc.querySelectorAll('img[src], a[href*="artifact"], a[href*="private/"]')).toHaveLength(0);
expect(doc.querySelectorAll('[data-catalog-row][data-allowance="unused-initial"]')).toHaveLength(49);
});
it("separates candidate failures from unmeasured main and exposes only supplied public descriptions", () => {
const data=fixture(); data.rows[218]!.executionRecord="candidate-failed";
const id=data.rows[218]!.scenarioId;
const html=renderRunnerE2EDashboard({title:"Catalog",generatedAt:data.asOf,expected:[],catalog:[],entries:[],catalogOverview:data,catalogOverviewDescriptions:new Map([[id,{query:'Explain <this> & that',expectedOutcome:'A saved public outcome'}]])});
const doc=new JSDOM(html).window.document,row=doc.getElementById('catalog-'+id)!;
expect(row.textContent).toContain('No main measurement');
expect(row.textContent).toContain('Candidate run: FAIL');
expect(row.querySelector('details')!.textContent).toContain('Explain <this> & that');
expect(html).toContain('Explain &lt;this&gt; &amp; that');
expect(doc.querySelector('[data-execution-scope]')!.textContent).toContain('25 cases measured outside main · 49 never run · 1');
expect(() => parseCatalogOverview({...data,rows:data.rows.map((r,i)=>i===218?{...r,executionRecord:'never-run'}:r)})).toThrow('Inconsistent recorded');
});
it("preserves a valid main outcome when its allowance is unknown", () => {
const data=fixture(); data.rows[0]!.allowance="unknown";
expect(parseCatalogOverview(data).accounting.exhaustedFinals).toBe(102);
const doc=new JSDOM(page(data)).window.document,row=doc.getElementById('catalog-'+data.rows[0]!.scenarioId)!;
expect(row.textContent).toContain('Recorded pass');
expect(row.textContent).toContain('Main measurement recorded');
expect(row.textContent).toContain('Allowance unknown');
expect(row.textContent).toContain('Recover ordinal evidence');
expect(doc.querySelector('.summary')!.textContent).toContain('25Recorded feature-work passes');
expect(() => parseCatalogOverview({...data,accounting:{...data.accounting,exhaustedFinals:104}})).toThrow('Inconsistent catalog accounting');
});
it("rejects unknown allowance when execution is positively known never-run", () => {
const data=fixture(); data.rows[169]!.allowance="unknown";
expect(() => parseCatalogOverview(data)).toThrow('Inconsistent recorded execution scope');
});
it("shows a later candidate pass without promoting the recorded main failure", () => {
const data=fixture(); data.rows[25]!.latestCandidateOutcome="passed";
const doc=new JSDOM(page(data)).window.document,row=doc.getElementById('catalog-'+data.rows[25]!.scenarioId)!;
expect(row.getAttribute('data-outcome')).toBe('failed');
expect(row.textContent).toContain('Recorded fail');
expect(row.textContent).toContain('Main measurement recorded · Latest candidate run: PASS');
expect(doc.querySelector('.summary')!.textContent).toContain('25Recorded feature-work passes144Latest main failures75Without a main measurement');
expect(doc.querySelector('[data-execution-scope]')!.textContent).toContain('26 cases measured outside main');
expect(doc.querySelectorAll('[data-report-case]')).toHaveLength(0);
expect(parseCatalogOverview(data).rows[25]!.mainOutcome).toBe('failed');
expect(() => parseCatalogOverview({...data,rows:data.rows.map((r,i)=>i===25?{...r,latestCandidateOutcome:'made-up'}:r)})).toThrow('Invalid catalog overview state');
expect(() => parseCatalogOverview({...fixture(),rows:fixture().rows.map((r,i)=>i===169?{...r,latestCandidateOutcome:'passed'}:r)})).toThrow('Inconsistent recorded');
});
it.each([[152,"below"],[196,"equal to"],[200,"above"]] as const)("compares a ceiling of %i accurately", (ceiling, comparison) => {
const data=fixture(); data.accounting.theoreticalMainCeiling=ceiling;
expect(new JSDOM(page(data)).window.document.querySelector('main')!.textContent).toContain(`${ceiling}/244, ${comparison} the 196-case target`);
});
it("filters and resets actual DOM rows without treating unused initials as failures", () => {
const dom=new JSDOM(page(fixture()),{runScripts:'dangerously',pretendToBeVisual:true});
const doc=dom.window.document;
for (const selector of ['[data-nav-view="attention"]','.report-global-nav a[href$="?view=history"]','.report-breadcrumbs']) expect(dom.window.getComputedStyle(doc.querySelector(selector)!).display).toBe('none');
expect(dom.window.getComputedStyle(doc.querySelector('[data-nav-view="overview"]')!).display).not.toBe('none');
const select=doc.querySelector<HTMLSelectElement>('[data-catalog-outcome]')!;select.value='unmeasured';select.dispatchEvent(new dom.window.Event('input'));
expect([...doc.querySelectorAll<HTMLElement>('[data-catalog-row]')].filter(r=>!r.hidden)).toHaveLength(75);
const allowance=doc.querySelector<HTMLSelectElement>('[data-catalog-allowance]')!;allowance.value='unknown';allowance.dispatchEvent(new dom.window.Event('input'));
expect(doc.querySelector('[data-catalog-count]')!.textContent).toBe('1 of 244 scenarios');
doc.querySelector<HTMLButtonElement>('[data-catalog-reset]')!.click();
expect([...doc.querySelectorAll<HTMLElement>('[data-catalog-row]')].filter(r=>!r.hidden)).toHaveLength(244);
const search=doc.querySelector<HTMLInputElement>('[data-catalog-query]')!;search.value='create project';search.dispatchEvent(new dom.window.Event('input'));
expect(doc.querySelector('[data-catalog-count]')!.textContent).toBe('1 of 244 scenarios');
dom.window.close();
});
it("loads only bounded display metadata and refuses existing outputs and symlink inputs", async () => {
const dir=await mkdtemp(path.join(os.tmpdir(),'catalog-overview-test-'));
try {
const metadata=path.join(dir,'display.json'); await writeFile(metadata,JSON.stringify(fixture()));
const output=path.join(dir,'preview');
await regenerateCatalogOverview({metadataFile:metadata,outputDirectory:output});
expect((await stat(output)).mode & 0o777).toBe(0o700);
expect((await stat(path.join(output,'index.html'))).mode & 0o777).toBe(0o600);
expect(await readFile(path.join(output,'index.html'),'utf8')).toContain('All 244 scenarios');
expect(await readFile(path.join(output,'index.html'),'utf8')).toContain('What this test asks');
await expect(regenerateCatalogOverview({metadataFile:metadata,outputDirectory:output})).rejects.toThrow();
await writeFile(metadata,JSON.stringify({...fixture(),rows:fixture().rows.map((r,i)=>i?r:{...r,scenarioId:'projects.invented-scenario'})}));
await expect(regenerateCatalogOverview({metadataFile:metadata,outputDirectory:path.join(dir,'invented-out')})).rejects.toThrow('frozen scenario IDs');
const link=path.join(dir,'link.json'); await symlink(metadata,link);
await expect(regenerateCatalogOverview({metadataFile:link,outputDirectory:path.join(dir,'link-out')})).rejects.toThrow();
await writeFile(metadata,' '.repeat(256*1024+1));
await expect(regenerateCatalogOverview({metadataFile:metadata,outputDirectory:path.join(dir,'big-out')})).rejects.toThrow('bounded');
} finally { await rm(dir,{recursive:true,force:true}); }
});
it("links the dated immutable snapshot from real campaign and metadata navigation", () => {
const data=fixture();
const ordinary=renderRunnerE2EDashboard({title:"Campaign",generatedAt:data.asOf,expected:[],catalog:[],entries:[]});
for (const html of [ordinary,page(data)]) {
const dom=new JSDOM(html),link=dom.window.document.querySelector<HTMLAnchorElement>('[data-nav-catalog]')!;
expect(link.textContent).toContain('Chat catalog · Oct 29');
expect(link.href).toBe('https://d1p6rlowie26tp.cloudfront.net/runner-e2e/campaigns/chat-catalog-overview-20261029-175400z/');
expect(dom.window.getComputedStyle(link).display).not.toBe('none');
expect(dom.window.document.querySelectorAll('[data-nav-catalog]')).toHaveLength(1);
dom.window.close();
}
});
it("keeps the normal campaign branch and its missing-result behavior", () => {
const normal=renderRunnerE2EDashboard({title:'Existing campaign',generatedAt:'2026-10-29T17:54:00Z',expected:[],catalog:[],entries:[]});
expect(normal).toContain('aria-label="Campaign summary"');
expect(normal).not.toContain('data-catalog-overview>');
expect(normal).toContain('data-report-scope="campaign"');
const window=new JSDOM(normal).window;
expect(window.getComputedStyle(window.document.querySelector('[data-nav-view="attention"]')!).display).not.toBe('none');
});
});