Skip to content

test(evals): migrate reporting and publishing to scenarios - #203

Merged
pgermishuys merged 2 commits into
mainfrom
test/evals-reporting-migration
Sep 21, 2026
Merged

pgermishuys merged 2 commits into
mainfrom
test/evals-reporting-migration

Conversation

@pgermishuys

Copy link
Copy Markdown
Contributor

Migrates the eval reporting and publishing surface from white-box unit
tests to black-box scenarios, continuing the work in #197, #199 and #200.

Related issue: #183 (task group 14). Touches the area of #201 but does
not change its behaviour — see below.

Counts, in one measure

Source cases throughout (it(...) and it.each(...) counted once each):

Before After
report-markdown.test.ts 114 0 — deleted
dashboard-indexes.test.ts 104 19
github-contents-publisher.test.ts 75 0 — deleted
Unit total 293 19
tests/evals/reporting.scenario.test.ts — 59

The 59 scenarios run as 113 cases at runtime; that number is not comparable
with the source counts above and is quoted separately.

What the scenarios assert

Three black boxes, each entered only through a seam a real caller has:

  • public-report.md — written by ArtifactBundleWriter({ writeMarkdown: true }),
    never by calling the renderer. Headings, verdicts, counts, suite list, score
    bands, the dry-run banner, the empty-suite placeholder, pipe escaping, and a
    nine-payload injection table against caseId, modelId and
    explanation.text.
  • The dashboard indexes — written by writeBundle({ generateIndexes: true }),
    or DashboardIndexWriter.rebuildFromRuns() where a scenario needs run
    directories no single write produces. Newest-first manifests pointing at
    runs/v1/<runId>/, oldest-first suite and scenario histories, the ten-run
    caps, model-comparison ordering, partial/skip aggregation, rebuild
    determinism, and unreadable or wrong-version runs being skipped rather than
    failing the rebuild.
  • The HTTP traffic of a publish — the real GitHubContentsPublisher over
    its injected fetch. Which paths get a PUT and which do not, run artifacts
    always before indexes, no PUT at all for a run artifact that already exists
    remotely, index updates carrying the remote blob SHA, the token only in the
    Authorization header, and no request whatsoever without a token or for a
    dry run.

Every absence assertion is paired with a positive twin — a dropped payload is
asserted alongside the case still being published, and a rejected file name
alongside latest.json going up in the same call — so a payload that never
arrived cannot pass for one that was blocked.

What was kept, and why

dashboard-indexes.test.ts keeps 19 cases, with the reasons in its docblock:

Kept Why
validateDashboardManifestCompatibility, validateSuiteHistoryCompatibility, validateLatestSnapshotCompatibility, validateScenarioHistoryCompatibility Consumer-side guards with no production caller. Weave writes these files and never reads one back, so no written artifact reveals their behaviour
generateDashboardIndexes([]) rebuildFromRuns() returns early on an empty run set, so this error branch is unreachable from outside

validatePublicReportBundleCompatibility went with the rest: it is the one
validator with a production caller, and its whole visible effect — an
unreadable run left out of the indexes — is asserted against the manifest.

The publisher's constants (TARGET_REPO, RUN_ARTIFACT_ALLOWLIST, the three
index-name patterns) are all visible in the request URLs a publish issues, so
the scenarios read them there. INDEX_ARTIFACT_ALLOWLIST is a deprecated alias
whose three cases were its only callers.

Mutations

29 mutations run against tests/evals/reporting.scenario.test.ts alone,
with all 293 deleted unit cases already gone. 28 caught:

Mutation Result
sanitizeMdValue() returns its input verbatim 21 red
isMarkdownSafe() always says yes 19 red
The script_tag pattern dropped from the renderer's list 3 red
Pipe escaping dropped, injection checking kept 2 red
Every score band renders as pass 2 red
The passed column always reads yes 1 red
The dry-run banner dropped 1 red
The empty-suite placeholder dropped 1 red
The full git SHA printed instead of the short one 1 red
The manifest lists runs oldest-first 2 red
Suite history written newest-first 4 red
The recent-runs index stops capping at ten 1 red
Scenario history keeps the oldest ten instead of the newest 1 red
A scenario the models disagree on reported as passing 1 red
An unreadable run report indexed anyway 1 red
latest.json points at the oldest run 1 red
Model comparison stops sorting by model id 2 red
The manifest points at runs/<runId>/ rather than runs/v1/ 1 red
The run-artifact allowlist dropped from the publisher 11 red
An existing run artifact overwritten instead of refused 2 red
Index updates stop carrying the remote blob SHA 1 red
The index allowlist accepts every name 7 red
The token appended to the request URL as well 31 red
Remote run IDs returned whatever their prefix 1 red
A missing token no longer blocks a publish 4 red
Index files uploaded before run artifacts 5 red
A failed index upload fails the whole publish 1 red
A dry-run bundle allowed through to the remote 1 red
The raw/ filter dropped from the publisher 0 red — a finding, see below

packages/ was restored and verified clean after each one.

Defects found

1. public-report.md renders the run's suite list unescaped — an XSS hole
the policy does not allow.

renderPublicReportBundle() interpolates bundle.runSummary.suites straight
into the document:

lines.push(`**Suites**: ${bundle.runSummary.suites.join(", ")}`);

while the ### Suite: heading for the same value goes through
sanitizeMdValue(). A suite named <script>alert(1)</script> is blanked in
the heading and reproduced verbatim in the header line. docs/eval-xss-policy.md
states that no channel of this renderer can produce a <script> tag in
public-report.md.

It survived because all eight malicious-suite unit cases set
suiteSummaries[].suite and left runSummary.suites at its clean default — so
the unescaped line was never once exercised. Same vacuity trap the strategy
doc warns about, this time hiding a real hole.

Pinned as observed rather than fixed, following the precedent for #201 and the
caseId-verbatim case. Suite names come from EVAL_SUITE_REGISTRY rather than
model output, so it is not currently attacker-reachable, and the fix is one
sanitizeMdValue() call. docs/eval-xss-policy.md now carries a Known gap
section that restates the requirement and points at the scenario; fixing the
renderer turns that scenario red, which is the intended signal.

2. Issue #201, pinned at the seam — and narrower than it looks.

A ResultsRepoPublisher is handed every path in filesWritten:

["run-summary.json", "score-loom-routing.json", "prompt-hashes.json",
 "provenance-manifest.json", "public-report.json", "public-report.md",
 "bundle-index.json"]

while the run's own bundle-index.json declares only the last three public.
What actually keeps the score file off the results repository is
GitHubContentsPublisher's own RUN_ARTIFACT_ALLOWLIST, applied inside
publishFiles() — not the caller. A different publisher implementation
would upload all seven. Both halves are now asserted: what the publisher
receives, and what gets a PUT. No behaviour changed here.

3. The publisher's raw/ filter cannot change an outcome.

publishFiles() strips raw/-prefixed names and then applies
RUN_ARTIFACT_ALLOWLIST, which rejects every one of them anyway. Removing the
first filter turns no scenario red. Harmless, but it reads as load-bearing —
the second finding of that shape after computeRunIdPrefix()'s "unknown"
branch.

Docs

  • docs/testing-strategy.md — the migration table, what stayed, the mutation
    table and the three findings.
  • docs/eval-xss-policy.md — the coverage table now points at the scenarios,
    and the new Known gap section records finding 1 without weakening the
    policy.
  • docs/eval-sanitization-and-publish-pipeline.md, docs/agent-evals.md —
    pointers to the deleted test files replaced.
  • docs/artifacts/cli-evals-migration-handoff.md — status and findings for
    whoever takes the next file, including two traps this one cost time on.
  • tests/README.md — documents tests/evals/, which had no entry.

Verification

bun run test (5,642 pass), bunx tsc --noEmit, bunx biome check tests/,
bun run lint, bun run docs:check-links, bun run verify:test-coverage —
all green. Pre-commit hooks ran; no --no-verify.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DisVZW27sd6Pe7uhbjXNve

The three files covering what a reader of tryweave.io eventually sees —
report-markdown, dashboard-indexes and github-contents-publisher — carried 293
unit cases, almost all of them asserting something observable in a rendered
report, an index file, or the HTTP request a publish issues. Those promises now
live in tests/evals/reporting.scenario.test.ts as 59 scenarios (113 at runtime),
and 19 unit cases remain for what nothing written reveals.

The scenarios enter only through seams a real caller has: ArtifactBundleWriter
for the Markdown report and the indexes, DashboardIndexWriter.rebuildFromRuns()
where a scenario needs run directories no single write produces, and the real
GitHubContentsPublisher over its injected fetch — so every request a publish
would make is asserted without a network.

They cover the promises this area exists to keep: a rendered report drops
hostile markup while still listing the case, a pipe cannot break a table, an
index lists the runs that exist and no others, histories are capped and ordered,
a run the dashboard cannot read is skipped rather than failing the rebuild, a
run artifact is created and never overwritten, index files are updated in place
with the remote blob SHA, run artifacts always upload before indexes, and the
token appears only in the Authorization header.

What stayed, in dashboard-indexes.test.ts: the four validate*Compatibility
functions, which are the consumer side of a contract Weave only ever writes and
so have no production caller, and generateDashboardIndexes([]), whose error
branch rebuildFromRuns() returns before reaching.

Each deletion was proved rather than assumed: 29 mutations were run against the
new scenarios alone, with every deleted unit case already gone. 28 were caught;
the 29th is a finding, not a gap.

Writing against observed behaviour turned up three things, recorded in
docs/artifacts/cli-evals-migration-handoff.md and docs/testing-strategy.md:

- public-report.md renders the run's suite list unescaped. The **Suites**:
  header interpolates runSummary.suites directly while the ### Suite: heading
  for the same value is sanitized, so a suite named <script>alert(1)</script>
  reaches the file verbatim — a hole in layer 2 of docs/eval-xss-policy.md. It
  survived because every malicious-suite unit case set suiteSummaries[].suite
  and left runSummary.suites clean, so the line was never exercised. Pinned as
  observed, not fixed; the policy doc now carries a Known gap section. Suite
  names come from EVAL_SUITE_REGISTRY rather than model output, which bounds
  the exposure.
- Issue #201, pinned at the seam. A ResultsRepoPublisher is handed every path
  in filesWritten, score file included, while bundle-index.json declares only
  three files public. What keeps the score file off the remote is
  GitHubContentsPublisher's own RUN_ARTIFACT_ALLOWLIST, not the caller — a
  different publisher would upload all seven. Both halves are asserted.
- The publisher's raw/ filter cannot change an outcome: the allowlist behind it
  rejects those names anyway, so removing it turns no scenario red.

Refs #183 (task group 14).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DisVZW27sd6Pe7uhbjXNve
Copilot AI lite review requested due to automatic review settings September 21, 2026 06:26
@coderabbitai

coderabbitai Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 39 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 79e6671b-2184-4c19-b7a6-0d49a1bb8fe5

📥 Commits

Reviewing files that changed from the base of the PR and between 41bd811 and f979721.

⛔ Files ignored due to path filters (2)
  • .codesight/CODESIGHT.md is excluded by !.codesight/**
  • .codesight/graph.md is excluded by !.codesight/**
📒 Files selected for processing (11)
  • docs/agent-evals.md
  • docs/artifacts/cli-evals-migration-handoff.md
  • docs/eval-sanitization-and-publish-pipeline.md
  • docs/eval-xss-policy.md
  • docs/testing-strategy.md
  • packages/cli/src/evals/__tests__/dashboard-indexes.test.ts
  • packages/cli/src/evals/__tests__/github-contents-publisher.test.ts
  • packages/cli/src/evals/__tests__/report-markdown.test.ts
  • packages/cli/src/evals/report-markdown.ts
  • tests/README.md
  • tests/evals/reporting.scenario.test.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

renderPublicReportBundle() sanitized the "### Suite:" heading but
interpolated runSummary.suites straight into the run header line, so a
suite name containing <script> reached public-report.md verbatim. The
same value, two renderings, one of them unescaped.

docs/eval-xss-policy.md states the requirement unconditionally: no
channel of this renderer may produce a script tag in the output. This was
a hole in that layer, not an allowance, so it is fixed rather than
documented as a known gap.

The scenario that found it now asserts the guarantee instead of pinning
the hole; reverting the renderer turns it red.

Worth recording how it survived. Every malicious-suite case in the unit
tests set suiteSummaries[].suite and left runSummary.suites clean, so the
unescaped line was never once exercised — the tests meant to cover the
renderer could not see it. Exposure was bounded, since suite names come
from the repo-owned EVAL_SUITE_REGISTRY rather than model output, but
bounded is not closed.

Refs #183 (task group 14)

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DisVZW27sd6Pe7uhbjXNve
@pgermishuys

Copy link
Copy Markdown
Contributor Author

Reviewed. I verified the XSS finding independently and it holds — report-markdown.ts:280 escapes the suite name via escapeMdCell, and line 341 renders the same value raw. Good catch, and the explanation of why it survived is the valuable part: every malicious-suite unit case set suiteSummaries[].suite and left runSummary.suites clean, so the unescaped line was never once exercised.

I have fixed it rather than keeping it pinned (f979721). The precedent you cited — #201 and the verbatim caseId — does not extend here. Those are product questions: should score files be published, should a case id be escaped at layer 3 rather than layer 1. This is not a question. eval-xss-policy.md states the requirement unconditionally, the identical value is escaped two lines away, and the fix is one call. A security policy carrying a documented "Known gap" when the fix is unambiguous is worse than the gap.

Changed:

  • report-markdown.ts — the suite list is escaped the way the heading already was.
  • The scenario now asserts the guarantee rather than the hole. Reverting the renderer turns it red; I checked.
  • eval-xss-policy.md — "Known gap" replaced with a record of the closed hole, keeping your explanation of how it hid, since that is the part worth remembering.

Everything else in this PR stands as reported. Two things I want to highlight because they are easy to lose:

  • Your Published score files carry explanations the public report blocks #201 refinement is more precise than the original finding. What keeps score files off the results repository is GitHubContentsPublisher's own RUN_ARTIFACT_ALLOWLIST, not the caller — so a different publisher implementation would upload all seven paths. I will add that to the issue.
  • The raw/ filter that cannot change an outcome is the second dead-branch of that shape, after computeRunIdPrefix()'s "unknown" case. Two is a pattern worth watching for in the remaining areas.

Merging once CI is green on the fix.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Critical Windows path handling and moderate run-artifact failure-coverage issues remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity · 1 Medium severity · 1 Low severity

Open (3)
What changed in this PR

Migrates eval reporting, dashboard indexing, and publishing coverage to black-box scenarios.

Changes:

  • Adds 59 scenarios covering reports, indexes, and publishing.
  • Removes superseded renderer and publisher unit tests.
  • Updates testing, security, pipeline, and generated metadata documentation.
File Summary
tests/​README.md Documents the eval scenario bucket and conventions.
tests/​evals/​reporting.scenario.test.ts Adds scenarios; critical Windows path handling and moderate run-artifact failure coverage remain, with nits on direct readRemoteRunIds() assertions.
packages/​cli/​src/​evals/​__tests__/​report-markdown.test.ts Removes superseded renderer tests.
packages/​cli/​src/​evals/​__tests__/​github-contents-publisher.test.ts Removes superseded publisher tests.
docs/​testing-strategy.md Records migration coverage, mutations, and findings.
docs/​eval-xss-policy.md Updates sanitization coverage and documents the known suite-list gap.
docs/​eval-sanitization-and-publish-pipeline.md Updates references; clarify deliberate scenario disk I/O.
docs/​artifacts/​cli-evals-migration-handoff.md Adds handoff details; revert this edit per documentation policy.
docs/​agent-evals.md Updates testing references.
.codesight/​graph.md Updates generated import metadata.
.codesight/​CODESIGHT.md Updates generated scan metadata.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

).publish({
bundle: written.bundle,
localBundleDir: written.bundleDir,
fileNames: written.filesWritten.map((p) => p.slice(p.lastIndexOf("/") + 1)),
Comment on lines +1097 to +1110
describe("a run artifact with this name already exists in the results repository", () => {
it("issues no PUT for it, so a published score can never be rewritten", async () => {
await withBundleRoot(async (root) => {
const runId = "abc123d-2026-01-15-001";
const { calls, fetchImpl } = recordingFetch([
`runs/v1/${runId}/public-report.json`,
]);
await writeThenPublish(root, calls, fetchImpl);

expect(uploaded(calls)).toEqual([]);
expect(calls.map((c) => `${c.method} ${c.path}`)).toEqual([
`GET runs/v1/${runId}/public-report.json`,
]);
});
Comment on lines +1483 to +1509
describe("a rerun asks the results repository which runs it already holds", () => {
it("reports the runs sharing this commit and day, and ignores every other prefix", async () => {
const calls: string[] = [];
const publisher = new GitHubContentsPublisher(async (request) => {
calls.push(
`${request.method} ${request.url} auth=${request.headers.get("Authorization")}`,
);
return manifestResponse({
runs: [
{ runId: "abc123d-2026-01-15-001" },
{ runId: "abc123d-2026-01-15-002" },
{ runId: "abc123d-2026-01-14-001" },
{ runId: "ffffff0-2026-01-15-001" },
{ notARun: true },
],
});
});

const ids = await publisher.readRemoteRunIds("abc123d-2026-01-15", TOKEN);

expect(ids._unsafeUnwrap()).toEqual([
"abc123d-2026-01-15-001",
"abc123d-2026-01-15-002",
]);
expect(calls).toEqual([
`GET ${API_PREFIX}indexes/v1/dashboard-manifest.json auth=Bearer ${TOKEN}`,
]);
Copilot AI review requested due to automatic review settings September 21, 2026 06:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unresolved moderate findings cover Windows paths, publish failures, helper-level assertions, and branch verification; related stale claims also need correction.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity · 1 Medium severity · 4 Low severity

Open (6)

Comment on lines +174 to +178
- **`public-report.md` renders the run's suite list unescaped.** The
`**Suites**:` header line interpolates `runSummary.suites` straight into the
document, while the `### Suite:` heading for the same value goes through
`sanitizeMdValue()`. A suite named `<script>alert(1)</script>` reaches the
file verbatim. Every malicious-suite unit case set `suiteSummaries[].suite`
Comment thread docs/testing-strategy.md
Comment on lines +450 to +454
- **`public-report.md` renders the run's suite list unescaped.**
`renderPublicReportBundle()` interpolates `bundle.runSummary.suites` without
`sanitizeMdValue()`, so a suite name containing `<script>` reaches the
document verbatim while the `### Suite:` heading for the same value is
blanked. [`docs/eval-xss-policy.md`](eval-xss-policy.md) allows no such
);
lines.push(`**Suites**: ${bundle.runSummary.suites.join(", ")}`);
lines.push(
`**Suites**: ${bundle.runSummary.suites.map(escapeMdCell).join(", ")}`,
@pgermishuys
pgermishuys merged commit 0997c04 into main Sep 21, 2026
7 checks passed
@pgermishuys
pgermishuys deleted the test/evals-reporting-migration branch September 21, 2026 06:43
pgermishuys added a commit that referenced this pull request Sep 21, 2026
…206)

InMemoryTapestryRunner extended TapestryExecutionRunner and overrode
run() with ~140 lines of its own, including a verbatim copy of
normalizeDelegationChain() named normalizeDelegationChainForTest. Its two
tests asserted that copy, so they described a product that need not
exist.

The proof: replacing the real condition with if (false), which disables
alternate-delegate normalization outright, leaves all 32 unit tests green
— including the one named "normalizes accepted alternate shuttle variants
back to the canonical expected delegate".

What replaces them is a scenario against the real runner. The premise
that kept the double — that a delegation chain "has no observable form,
because in production the judge is an LLM" — was false. The judge is
stubbed at the scenario seam, so judgeCalls shows exactly what the runner
asked it to score, and the runner serialises the chain into that input
itself, after normalizing it. Four scenarios cover the transform, and
the third is the contrast that keeps the second honest: the same answer
and the same expected chain, with only accepted_alternates removed.

Both directions are mutation-proved. if (true) turns the contrast
scenario red; if (false) turns the normalization scenario red; each is
caught by exactly one.

This was the last instance in the repo. #203 and #204 removed seven
others while migrating their areas. The remaining test subclasses
(SymlinkFileSystem, FailingProbes, Mock/FailingOpenCodeAdapter) override
a collaborator rather than the unit under test, which is the legitimate
use and stays.

Recorded as finding 11 in docs/testing-strategy.md, with the rule it
gives us: a double may stand in for a dependency, never for the unit
under test.

Refs #183 (task group 14), #205


Claude-Session: https://claude.ai/code/session_01DisVZW27sd6Pe7uhbjXNve

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants