Repository navigation
test(evals): migrate reporting and publishing to scenarios - #203
Conversation
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
|
Warning Review limit reachedNext included review available in 39 minutes. View limit detailsLimit 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. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (11)
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. Comment |
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
|
Reviewed. I verified the XSS finding independently and it holds — I have fixed it rather than keeping it pinned (f979721). The precedent you cited — #201 and the verbatim Changed:
Everything else in this PR stands as reported. Two things I want to highlight because they are easy to lose:
Merging once CI is green on the fix. |
There was a problem hiding this comment.
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
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)), |
| 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`, | ||
| ]); | ||
| }); |
| 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}`, | ||
| ]); |
There was a problem hiding this comment.
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
Open (6)
Use platform-independent path basename extraction Restore scenarios for run-artifact upload failures Update stale handoff claim about sanitized suite lists · New Remove stale claim that suite lists remain unescaped · New Reconcile PR description with fixed renderer behavior · New Test remote sequencing through the real bundle writer
| - **`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` |
| - **`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(", ")}`, |
…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>



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(...)andit.each(...)counted once each):report-markdown.test.tsdashboard-indexes.test.tsgithub-contents-publisher.test.tstests/evals/reporting.scenario.test.tsThe 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 byArtifactBundleWriter({ 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,modelIdandexplanation.text.writeBundle({ generateIndexes: true }),or
DashboardIndexWriter.rebuildFromRuns()where a scenario needs rundirectories no single write produces. Newest-first manifests pointing at
runs/v1/<runId>/, oldest-first suite and scenario histories, the ten-runcaps, model-comparison ordering,
partial/skipaggregation, rebuilddeterminism, and unreadable or wrong-version runs being skipped rather than
failing the rebuild.
GitHubContentsPublisheroverits injected
fetch. Which paths get a PUT and which do not, run artifactsalways 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
Authorizationheader, and no request whatsoever without a token or for adry 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.jsongoing up in the same call — so a payload that neverarrived cannot pass for one that was blocked.
What was kept, and why
dashboard-indexes.test.tskeeps 19 cases, with the reasons in its docblock:validateDashboardManifestCompatibility,validateSuiteHistoryCompatibility,validateLatestSnapshotCompatibility,validateScenarioHistoryCompatibilitygenerateDashboardIndexes([])rebuildFromRuns()returns early on an empty run set, so this error branch is unreachable from outsidevalidatePublicReportBundleCompatibilitywent with the rest: it is the onevalidator 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 threeindex-name patterns) are all visible in the request URLs a publish issues, so
the scenarios read them there.
INDEX_ARTIFACT_ALLOWLISTis a deprecated aliaswhose three cases were its only callers.
Mutations
29 mutations run against
tests/evals/reporting.scenario.test.tsalone,with all 293 deleted unit cases already gone. 28 caught:
sanitizeMdValue()returns its input verbatimisMarkdownSafe()always says yesscript_tagpattern dropped from the renderer's listpassyeslatest.jsonpoints at the oldest runruns/<runId>/rather thanruns/v1/raw/filter dropped from the publisherpackages/was restored and verified clean after each one.Defects found
1.
public-report.mdrenders the run's suite list unescaped — an XSS holethe policy does not allow.
renderPublicReportBundle()interpolatesbundle.runSummary.suitesstraightinto the document:
while the
### Suite:heading for the same value goes throughsanitizeMdValue(). A suite named<script>alert(1)</script>is blanked inthe heading and reproduced verbatim in the header line.
docs/eval-xss-policy.mdstates that no channel of this renderer can produce a
<script>tag inpublic-report.md.It survived because all eight malicious-suite unit cases set
suiteSummaries[].suiteand leftrunSummary.suitesat its clean default — sothe 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 fromEVAL_SUITE_REGISTRYrather thanmodel output, so it is not currently attacker-reachable, and the fix is one
sanitizeMdValue()call.docs/eval-xss-policy.mdnow carries a Known gapsection 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
ResultsRepoPublisheris handed every path infilesWritten:while the run's own
bundle-index.jsondeclares only the last three public.What actually keeps the score file off the results repository is
GitHubContentsPublisher's ownRUN_ARTIFACT_ALLOWLIST, applied insidepublishFiles()— not the caller. A different publisher implementationwould 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()stripsraw/-prefixed names and then appliesRUN_ARTIFACT_ALLOWLIST, which rejects every one of them anyway. Removing thefirst 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 mutationtable 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 forwhoever takes the next file, including two traps this one cost time on.
tests/README.md— documentstests/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