Repository navigation
test(evals): open the evals bucket with the publish-safety promise - #197
Conversation
Starts the cli/evals migration — 2,584 cases, about 46% of the suite — with the harness the rest of it needs and the promise the whole sanitization pipeline exists to keep: a published bundle never contains a prompt, a transcript or any other sensitive field. tests/support/evals.ts drives ArtifactBundleWriter end to end. Unlike the adapter bucket it writes to a real directory, because the writer owns its I/O; it is a per-test temp dir under the OS temp root, removed afterwards. Twelve scenarios: the bundle a reader gets, traceability back to a commit, the leak promise per sensitive field, immutability across two runs from one commit, byte-identical output for identical input, and failures being published rather than hidden. One lesson worth the whole exercise, now recorded in the strategy doc. The first version of the leak scenarios put markers in a case result's rawArtifact field and passed twelve out of twelve. They were vacuous: bundle assembly only reads caseResult.summary, so rawArtifact had no path to the output — nothing needed stripping, and a deliberately broken sanitizer passed all twelve. Moving the markers onto the summary made the same scenarios fail six ways against that mutation. An absence assertion passes both when the guard works and when the value never arrived, so a new scenario is not trusted until it has been watched go red. No unit tests are deleted here. Removing sanitizer.test.ts's 140 cases needs the hostile inputs they cover represented as scenarios first; this lands the foundation that work builds on. 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 33 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 (3)
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 |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Moderate findings remain in test coverage, assertions, test taxonomy, and Bun-compatible filesystem handling.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 2
Open (2)
What changed in this PR
Adds end-to-end eval bundle publishing scenarios covering sanitization, provenance, immutability, determinism, and failure reporting.
Changes:
- Adds shared eval fixtures and temporary bundle helpers.
- Adds 12 published-bundle scenarios.
- Documents mutation-testing guidance.
- Updates generated Codesight metadata.
| File | Summary |
|---|---|
tests/support/evals.ts |
Adds eval fixtures and bundle helpers; findings remain regarding direct Node fs usage and incomplete sensitive-field markers. |
tests/evals/published-bundle.scenario.test.ts |
Adds publication scenarios; findings remain around test taxonomy, sensitive-field and Markdown coverage, complete output comparison, immutability, and failure assertions. |
docs/testing-strategy.md |
Documents vacuous-test detection; the new eval bucket and I/O boundary require explicit contract documentation. |
.codesight/coverage.md |
Updates generated test-count metadata. |
.codesight/CODESIGHT.md |
Updates generated scan metadata. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| const first = await publish(root); | ||
| const second = await publish(root); | ||
|
|
||
| expect(second.runId).not.toBe(first.runId); | ||
| }); |
| */ | ||
|
|
||
| import { expect } from "bun:test"; | ||
| import { mkdtemp, rm } from "node:fs/promises"; |
) * test(evals): migrate the sanitizer and report schemas to scenarios 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> * docs: count the sanitizer migration in one measure 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 --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com>

Part of #183 — task group 14. Opens the
cli/evalsmigration: 2,584 cases, ~46% of the suite.This lands the harness the rest of that work needs, plus the promise the entire sanitization pipeline exists to keep.
The promise
A published bundle never contains a prompt, a transcript, or any other sensitive field. That is what
docs/eval-sanitization-and-publish-pipeline.mdanddocs/eval-xss-policy.mdassert in prose; these are its executable form.Twelve scenarios: the bundle a reader actually gets, traceability back to a commit, the leak promise per sensitive field, immutability across two runs from one commit, byte-identical output for identical input, and failures being published rather than quietly dropped.
tests/support/evals.tsdrivesArtifactBundleWriterend to end. Unlike the adapter bucket it writes to a real directory, because the writer owns its I/O — a per-test temp dir under the OS temp root, removed afterwards. Never the developer's config or working tree.The lesson, and why it is in the strategy doc
The first version of these scenarios passed twelve out of twelve while testing nothing.
I put the sensitive markers in a case result's
rawArtifactfield. Bundle assembly only ever readscaseResult.summary, sorawArtifacthad no path to the output — nothing needed stripping, and a deliberately broken sanitizer still passed all twelve.Moving the markers onto the summary made the same scenarios fail six ways against that same mutation:
An absence assertion passes both when the guard works and when the value never arrived. So: a new scenario is not trusted until it has been watched go red. That is now a rule in
docs/testing-strategy.md, and it applies to every remaining area.What this PR does not do
No unit tests are deleted.
sanitizer.test.ts's 140 cases cover hostile inputs — nesting, unknown fields, edge shapes — that these twelve do not yet represent. The sanitizer is a security boundary; deleting its cases before the scenarios cover the same ground would be the reckless version of "delete when subsumed". That work builds on this foundation.Verification
bun run test: 6,092 across 194 files, 0 failbun run typecheck,bun run lint,bun run verify:test-coverage,bun run docs:check-links: pass🤖 Generated with Claude Code
https://claude.ai/code/session_01DisVZW27sd6Pe7uhbjXNve