You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test(evals): migrate the sanitizer and report schemas to scenarios - #199
Finishes what #197 started. sanitizer.test.ts and report-schema.test.ts enumerated a denylist and a regex table — "contains composedPrompt", "includes a pattern for html_script_tag" — and said nothing about what a reader of a published bundle is promised. 113 scenarios in tests/evals/publish-safety.scenario.test.ts now feed the equivalent hostile inputs through the real ArtifactBundleWriter and assert what comes out on disk.
Before
After
sanitizer.test.ts
140
91
report-schema.test.ts
188
112
Scenario cases
12
125
Total
340
328
The count barely moves, and that is the honest result: the enumeration's user-visible form is an equally long table of hostile inputs. What changes is that the tests now fail when a reader is put at risk, rather than when a constant is renamed.
What the scenarios cover
All 24 sensitive field names fed in at once, absent from every written file — value and key.
Eight shapes the allowlist has never seen: nested objects, arrays of objects, arrays of bare strings, prototype-shaped keys, extra keys inside an explanation, inside a dimension score, and inside the closed trajectorySummary allowlist.
30 injection payloads in an explanation — chain-of-thought tags, transcript role markers, prompt delimiters, scorer markers, secrets, and every HTML vector in docs/eval-xss-policy.md — each kept out of every uploadable artifact while the case itself still publishes.
The four allowed explanation sources and seven rejected ones; missing text, missing source, empty text.
The 300-character bound, at the limit and one over.
The score buckets a reader skims, including dry-run → skip.
A case id carrying markup: dropped from the Markdown, carried verbatim in the JSON where the XSS policy puts escaping in the dashboard. Recorded, not endorsed.
The schema versions the website pins, on the report, its suite summaries and all six index files.
Proved by mutation before anything was deleted
Against tests/evals alone:
Mutation
Result
sanitizeCaseResultSummary() returns its input
38 of 113 red
Explanation validation removed from assembleCaseEntry()
42 red
sanitizeMdValue() returns its input verbatim
2 red
sanitizeProvenanceRecord() spreads its input
1 red
The second is #197's lesson repeating. On the first pass it turned exactly one scenario red: without validation the whole report fails schema parsing, so public-report.json is never written and "the payload appears in no public artifact" stays true for the wrong reason. Each payload case now also asserts the case is still published — the graceful degradation the pipeline actually promises — and the same mutation turns 42 red.
packages/ was restored and verified clean after every mutation.
Kept, and why
Each file's docblock says this too.
Kept
Why
assertPublishSafe() / assertJsonPublishSafe()
While the allowlist projection works they never fire, so no written file reveals their behaviour
The manifest schemas' rejection branches
Unreachable from a writer that always stamps the version constant; they guard a future producer, and the website's rejection of a bad version depends on them
Strict-mode rejection of sensitive field names
A layer above the sanitizer, not a duplicate: the scenarios prove nothing sensitive reaches a file, these prove the schema would refuse one that did
A case with an empty caseId costs a run its entire dashboard presence, silently. Public-report assembly fails validation, writeBundle() treats that as non-fatal, and no public-report.json, no Markdown and no index files are written — with an ok result and nothing saying so. Two scenarios pin the behaviour as observed.
Seven exported sanitizer surfaces have no production caller. The runners build explanations through buildPublicExplanation() in langchain-agent-evals.ts and redact with their own patterns. About 60 unit cases cover code nothing calls. Kept and flagged rather than deleted — removing the API is a product decision.
A summary missing dimensionScores makes writeBundle() throw a TypeError instead of returning a typed BundleError, against the neverthrow rule in AGENTS.md. Reachable only by defeating the type system, so no scenario asserts it.
Doc correction
docs/eval-sanitization-and-publish-pipeline.md claimed every index file carries updatedAt. model-comparison-<runId>.json does not — it is regenerated per run and carries runId. Corrected, with a scenario pinning it. Neither normative document is weakened by this change.
Finishes what #197 started. sanitizer.test.ts and report-schema.test.ts
enumerated a denylist and a regex table — "contains composedPrompt",
"includes a pattern for html_script_tag" — and said nothing about what a
reader of a published bundle is promised. 113 scenarios now feed the
equivalent hostile inputs through the real ArtifactBundleWriter and
assert what comes out on disk.
sanitizer.test.ts 140 -> 91
report-schema.test.ts 188 -> 112
scenarios 12 -> 125
total 340 -> 328
The count barely moves, and that is the honest result: the enumeration's
user-visible form is an equally long table. What changes is that the
tests now fail when a reader is put at risk rather than when a constant
is renamed.
What the scenarios cover: every one of the 24 sensitive field names fed
in at once and absent from every written file, value and key; eight
shapes the allowlist has never seen — nested objects, arrays of objects,
prototype-shaped keys, extra keys inside an explanation and inside the
closed trajectory allowlist; 30 injection payloads in an explanation,
each kept out of every uploadable artifact while the case itself still
publishes; the four allowed explanation sources and seven rejected ones;
the 300-character bound at and one over; the score buckets a reader
skims; a case id carrying markup, dropped from the Markdown and carried
verbatim in the JSON where docs/eval-xss-policy.md puts escaping in the
dashboard; and the schema versions the website pins on the report, its
suite summaries and all six indexes.
Proved by mutation before anything was deleted, against tests/evals
alone:
sanitizeCaseResultSummary returns its input 38 of 113 red
explanation validation removed from assembly 42 red
sanitizeMdValue returns its input verbatim 2 red
sanitizeProvenanceRecord spreads its input 1 red
The second one is the lesson again. On the first pass it turned exactly
one scenario red: without validation the whole report fails schema
parsing, so public-report.json is never written and "the payload appears
in no public artifact" stays true for the wrong reason. Each payload
case now also asserts the case is still published — the graceful
degradation the pipeline actually promises — and the same mutation turns
42 red.
Kept, with the reasoning in each file's docblock: assertPublishSafe and
assertJsonPublishSafe, which never fire while the projection works and
so are invisible from outside; the manifest schemas' rejection branches,
unreachable from a writer that always stamps the version constant; and
the strict-mode rejection of sensitive field names, a layer above the
sanitizer rather than a duplicate of it.
Three things turned up while observing rather than transcribing, all
recorded in docs/testing-strategy.md:
- A case with an empty caseId costs a run its entire dashboard
presence, silently. Public-report assembly fails validation,
writeBundle treats that as non-fatal, and no public-report.json, no
Markdown and no index files are written — with an ok result.
- Seven exported sanitizer surfaces have no production caller:
sanitizeScoreRecord, dropUnknownFields, truncateExplanation,
buildExplanation, assertExplanationSafe, REDACTED and
FORBIDDEN_EXPLANATION_SOURCE_DESCRIPTORS. The runners build
explanations through buildPublicExplanation and redact with their
own patterns. About 60 unit cases cover code nothing calls; kept and
flagged, because removing the API is a product decision.
- A summary missing dimensionScores makes writeBundle throw a
TypeError instead of returning a typed BundleError.
docs/eval-sanitization-and-publish-pipeline.md claimed every index file
carries updatedAt; model-comparison-<runId>.json does not, and carries
runId instead. Corrected, with a scenario pinning it.
Refs #183 (task group 14)
Claude-Session: https://claude.ai/code/session_01DisVZW27sd6Pe7uhbjXNve
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Reviewed. Scope is clean — only the two in-scope test files, the scenario file, docs, and the hook's codesight regeneration. No source touched, no other session's files.
I verified the headline defect independently rather than taking it on trust, and it holds. artifact-bundle.ts:1050-1058:
// Assembly failures are non-fatal: public-report.json is omitted when// the bundle has no score files (e.g. empty dry-run with no cases).constreportResult=assemblePublicReportBundle(bundle,runId);if(reportResult.isErr()){// Non-fatal: log-level omission, not a hard error
The comment is what makes it a defect rather than a design: the intent is "no score files, e.g. an empty dry-run", but the branch swallows every assembly failure. A malformed case id therefore costs the run public-report.json, public-report.md and all six index files, and writeBundle() still returns ok with nothing saying so. Good find, and the two scenarios pinning it as observed behaviour are the right call — they document it without asserting it should stay.
One correction: the counts mix two measures
The table compares sourceit( lines for the unit files against runtime cases for the scenarios. A table-driven it.each is one case in the source and many at runtime, and the scenarios lean on tables much harder than the deleted unit tests did — so "340 → 328" is not like-for-like.
Measured consistently:
Before
After
sanitizer.test.ts (source)
140
91
report-schema.test.ts (source)
188
112
Unit total (source)
328
203
Scenarios added (source)
—
26
Scenarios added (runtime)
—
113
So 125 unit cases went and 26 scenario cases arrived, running as 113. The conclusion is unchanged and if anything understated — the reduction is real, it just isn't the point. I'll correct the table in docs/testing-strategy.md before merging; the worktree is currently held by the other session.
Held, not blocked
Merging once the worktree frees up. The three remaining findings are worth their own decisions rather than being folded in here:
Seven exported sanitizer surfaces have no production caller — removing an exported API is a product call, not a test one. Right to flag and keep.
writeBundle() throws instead of returning err on a missing dimensionScores, against the neverthrow rule in AGENTS.md. Only reachable by defeating the types, so leaving it unasserted is defensible.
A case id containing <script> is published verbatim in public-report.json — consistent with eval-xss-policy.md putting case-id escaping in layer 3, and now pinned by a test. Worth deciding separately whether raw markup in the JSON is acceptable given the website consumes it.
The reason will be displayed to describe this comment to others. Learn more.
Copilot review overview
🟡 Changes recommended
The new scenarios contain POSIX-only path handling, an unused schema import remains, and a historical artifact is modified against repository documentation policy.
Get a fresh assessment by requesting another Copilot review.
The migration table compared source it() lines for the unit files against
runtime cases for the scenarios. A table-driven it.each is one case in
the source and many at runtime, and the scenarios lean on tables far
harder than the deleted unit tests did, so the totals were not
like-for-like.
Measured consistently: 328 unit source cases to 203, with 26 scenario
source cases added that run as 113. The conclusion is unchanged and was
if anything understated.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DisVZW27sd6Pe7uhbjXNve
Exercise actual constructor and toString prototype keys
tests/evals/publish-safety.scenario.test.ts:272
This fixture does not exercise the advertised prototype-slot edge case: constructorNote and toStringNote are ordinary unknown names. A projection that mishandles own constructor or toString keys would still pass this scenario. Use the actual keys and assert those key names are absent from the written output.
Add coverage for omitted weightedTotal skip path
tests/evals/publish-safety.scenario.test.ts:624
The migration removed the only coverage for the second documented computeScoreBucket skip path. This test exercises dryRun: true, but computeScoreBucket(undefined, false) is a separate branch (report-schema.ts:290-299) and no scenario now drives an omitted score through the writer, so that behavior could regress unnoticed. Add an omitted-weightedTotal case here and assert the published bucket is skip.
Update agent evals guide for runId freshness exception
This correction leaves docs/agent-evals.md:1150 contradicting it by requiring updatedAt for model-comparison-*.json. Since this change explicitly establishes runId as the freshness exception, update that guide too so dashboard consumers are not given two different contracts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Finishes what #197 started.
sanitizer.test.tsandreport-schema.test.tsenumerated a denylist and a regex table —"contains composedPrompt","includes a pattern for html_script_tag"— and said nothing about what a reader of a published bundle is promised. 113 scenarios intests/evals/publish-safety.scenario.test.tsnow feed the equivalent hostile inputs through the realArtifactBundleWriterand assert what comes out on disk.sanitizer.test.tsreport-schema.test.tsThe count barely moves, and that is the honest result: the enumeration's user-visible form is an equally long table of hostile inputs. What changes is that the tests now fail when a reader is put at risk, rather than when a constant is renamed.
What the scenarios cover
trajectorySummaryallowlist.docs/eval-xss-policy.md— each kept out of every uploadable artifact while the case itself still publishes.skip.Proved by mutation before anything was deleted
Against
tests/evalsalone:sanitizeCaseResultSummary()returns its inputassembleCaseEntry()sanitizeMdValue()returns its input verbatimsanitizeProvenanceRecord()spreads its inputThe second is #197's lesson repeating. On the first pass it turned exactly one scenario red: without validation the whole report fails schema parsing, so
public-report.jsonis never written and "the payload appears in no public artifact" stays true for the wrong reason. Each payload case now also asserts the case is still published — the graceful degradation the pipeline actually promises — and the same mutation turns 42 red.packages/was restored and verified clean after every mutation.Kept, and why
Each file's docblock says this too.
assertPublishSafe()/assertJsonPublishSafe()sanitizeScoreRecord,dropUnknownFields,truncateExplanation,buildExplanation,assertExplanationSafe,REDACTED,FORBIDDEN_EXPLANATION_SOURCE_DESCRIPTORSThree things observing turned up
All recorded in
docs/testing-strategy.md.caseIdcosts a run its entire dashboard presence, silently. Public-report assembly fails validation,writeBundle()treats that as non-fatal, and nopublic-report.json, no Markdown and no index files are written — with anokresult and nothing saying so. Two scenarios pin the behaviour as observed.buildPublicExplanation()inlangchain-agent-evals.tsand redact with their own patterns. About 60 unit cases cover code nothing calls. Kept and flagged rather than deleted — removing the API is a product decision.dimensionScoresmakeswriteBundle()throw aTypeErrorinstead of returning a typedBundleError, against theneverthrowrule inAGENTS.md. Reachable only by defeating the type system, so no scenario asserts it.Doc correction
docs/eval-sanitization-and-publish-pipeline.mdclaimed every index file carriesupdatedAt.model-comparison-<runId>.jsondoes not — it is regenerated per run and carriesrunId. Corrected, with a scenario pinning it. Neither normative document is weakened by this change.Refs #183 (task group 14)
🤖 Generated with Claude Code
https://claude.ai/code/session_01DisVZW27sd6Pe7uhbjXNve