Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .codesight/CODESIGHT.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

> 0 routes | 0 models | 0 components | 200 lib files | 25 env vars | 7 middleware | 1 events | 0% test coverage
> **Token savings:** this file is ~18,200 tokens. Without it, AI exploration would cost ~66,400 tokens. **Saves ~48,200 tokens per conversation.**
> **Last scanned:** 2026-09-20 20:09 — re-run after significant changes
> **Last scanned:** 2026-09-20 20:32 — re-run after significant changes

---

Expand Down Expand Up @@ -979,12 +979,12 @@

## Most Imported Files (change these carefully)

- `packages/cli/src/evals/types.ts` — imported by **48** files
- `packages/cli/src/evals/types.ts` — imported by **49** files
- `packages/cli/src/io/terminal.ts` — imported by **22** files
- `packages/cli/src/theme/colors.ts` — imported by **22** files
- `packages/cli/src/fs/file-system.ts` — imported by **20** files
- `packages/cli/src/evals/openrouter-client.ts` — imported by **20** files
- `packages/cli/src/evals/report-schema.ts` — imported by **18** files
- `packages/cli/src/evals/report-schema.ts` — imported by **19** files
- `packages/adapters/opencode2/src/sdk-types.ts` — imported by **16** files
- `packages/engine/src/runtime/types.ts` — imported by **16** files
- `packages/cli/src/args.ts` — imported by **15** files
Expand All @@ -1002,12 +1002,12 @@

## Import Map (who imports what)

- `packages/cli/src/evals/types.ts` ← `packages/cli/src/evals/__tests__/case-loader.test.ts`, `packages/cli/src/evals/__tests__/case-loader.test.ts`, `packages/cli/src/evals/__tests__/dashboard-indexes.test.ts`, `packages/cli/src/evals/__tests__/github-contents-publisher.test.ts`, `packages/cli/src/evals/__tests__/input-validation.test.ts` +43 more
- `packages/cli/src/evals/types.ts` ← `packages/cli/src/evals/__tests__/case-loader.test.ts`, `packages/cli/src/evals/__tests__/case-loader.test.ts`, `packages/cli/src/evals/__tests__/dashboard-indexes.test.ts`, `packages/cli/src/evals/__tests__/github-contents-publisher.test.ts`, `packages/cli/src/evals/__tests__/input-validation.test.ts` +44 more
- `packages/cli/src/io/terminal.ts` ← `packages/cli/src/__tests__/routing.test.ts`, `packages/cli/src/cli.ts`, `packages/cli/src/commands/__tests__/config-validation-errors.test.ts`, `packages/cli/src/commands/__tests__/eval.test.ts`, `packages/cli/src/commands/__tests__/init.test.ts` +17 more
- `packages/cli/src/theme/colors.ts` ← `packages/cli/src/__tests__/theme.test.ts`, `packages/cli/src/cli.ts`, `packages/cli/src/commands/__tests__/config-validation-errors.test.ts`, `packages/cli/src/commands/__tests__/eval.test.ts`, `packages/cli/src/commands/__tests__/init.test.ts` +17 more
- `packages/cli/src/fs/file-system.ts` ← `packages/cli/src/__tests__/file-system.test.ts`, `packages/cli/src/cli.ts`, `packages/cli/src/commands/__tests__/init.test.ts`, `packages/cli/src/commands/__tests__/legacy-upgrade-regression.test.ts`, `packages/cli/src/commands/__tests__/migrate-conversion.test.ts` +15 more
- `packages/cli/src/evals/openrouter-client.ts` ← `packages/cli/src/evals/__tests__/loom-routing-runner.test.ts`, `packages/cli/src/evals/__tests__/loom-routing-runner.trajectory.test.ts`, `packages/cli/src/evals/__tests__/pattern-planning-runner.test.ts`, `packages/cli/src/evals/__tests__/runner.test.ts`, `packages/cli/src/evals/__tests__/shuttle-execution-runner.test.ts` +15 more
- `packages/cli/src/evals/report-schema.ts` ← `packages/cli/src/evals/__tests__/artifact-bundle.test.ts`, `packages/cli/src/evals/__tests__/artifact-bundle.test.ts`, `packages/cli/src/evals/__tests__/artifact-bundle.test.ts`, `packages/cli/src/evals/__tests__/artifact-bundle.test.ts`, `packages/cli/src/evals/__tests__/artifact-bundle.test.ts` +13 more
- `packages/cli/src/evals/report-schema.ts` ← `packages/cli/src/evals/__tests__/artifact-bundle.test.ts`, `packages/cli/src/evals/__tests__/artifact-bundle.test.ts`, `packages/cli/src/evals/__tests__/artifact-bundle.test.ts`, `packages/cli/src/evals/__tests__/artifact-bundle.test.ts`, `packages/cli/src/evals/__tests__/artifact-bundle.test.ts` +14 more
- `packages/adapters/opencode2/src/sdk-types.ts` ← `packages/adapters/opencode2/src/__tests__/reconcile-agent.test.ts`, `packages/adapters/opencode2/src/adapter.ts`, `packages/adapters/opencode2/src/errors.ts`, `packages/adapters/opencode2/src/plugin.ts`, `packages/adapters/opencode2/src/reconcile-agent.ts` +11 more
- `packages/engine/src/runtime/types.ts` ← `packages/engine/src/__tests__/runtime-command-operations.test.ts`, `packages/engine/src/__tests__/status-control.test.ts`, `packages/engine/src/__tests__/status-control.test.ts`, `packages/engine/src/__tests__/status-control.test.ts`, `packages/engine/src/__tests__/status-control.test.ts` +11 more
- `packages/cli/src/args.ts` ← `packages/cli/src/__tests__/args.test.ts`, `packages/cli/src/cli.ts`, `packages/cli/src/commands/__tests__/config-validation-errors.test.ts`, `packages/cli/src/commands/__tests__/eval.test.ts`, `packages/cli/src/commands/__tests__/init.test.ts` +10 more
Expand All @@ -1024,7 +1024,7 @@
# Test Coverage

> **0%** of routes and models are covered by tests
> 203 test files found
> 204 test files found

---

Expand Down
2 changes: 1 addition & 1 deletion .codesight/coverage.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Test Coverage

> **0%** of routes and models are covered by tests
> 203 test files found
> 204 test files found
8 changes: 4 additions & 4 deletions .codesight/graph.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

## Most Imported Files (change these carefully)

- `packages/cli/src/evals/types.ts` — imported by **48** files
- `packages/cli/src/evals/types.ts` — imported by **49** files
- `packages/cli/src/io/terminal.ts` — imported by **22** files
- `packages/cli/src/theme/colors.ts` — imported by **22** files
- `packages/cli/src/fs/file-system.ts` — imported by **20** files
- `packages/cli/src/evals/openrouter-client.ts` — imported by **20** files
- `packages/cli/src/evals/report-schema.ts` — imported by **18** files
- `packages/cli/src/evals/report-schema.ts` — imported by **19** files
- `packages/adapters/opencode2/src/sdk-types.ts` — imported by **16** files
- `packages/engine/src/runtime/types.ts` — imported by **16** files
- `packages/cli/src/args.ts` — imported by **15** files
Expand All @@ -25,12 +25,12 @@

## Import Map (who imports what)

- `packages/cli/src/evals/types.ts` ← `packages/cli/src/evals/__tests__/case-loader.test.ts`, `packages/cli/src/evals/__tests__/case-loader.test.ts`, `packages/cli/src/evals/__tests__/dashboard-indexes.test.ts`, `packages/cli/src/evals/__tests__/github-contents-publisher.test.ts`, `packages/cli/src/evals/__tests__/input-validation.test.ts` +43 more
- `packages/cli/src/evals/types.ts` ← `packages/cli/src/evals/__tests__/case-loader.test.ts`, `packages/cli/src/evals/__tests__/case-loader.test.ts`, `packages/cli/src/evals/__tests__/dashboard-indexes.test.ts`, `packages/cli/src/evals/__tests__/github-contents-publisher.test.ts`, `packages/cli/src/evals/__tests__/input-validation.test.ts` +44 more
- `packages/cli/src/io/terminal.ts` ← `packages/cli/src/__tests__/routing.test.ts`, `packages/cli/src/cli.ts`, `packages/cli/src/commands/__tests__/config-validation-errors.test.ts`, `packages/cli/src/commands/__tests__/eval.test.ts`, `packages/cli/src/commands/__tests__/init.test.ts` +17 more
- `packages/cli/src/theme/colors.ts` ← `packages/cli/src/__tests__/theme.test.ts`, `packages/cli/src/cli.ts`, `packages/cli/src/commands/__tests__/config-validation-errors.test.ts`, `packages/cli/src/commands/__tests__/eval.test.ts`, `packages/cli/src/commands/__tests__/init.test.ts` +17 more
- `packages/cli/src/fs/file-system.ts` ← `packages/cli/src/__tests__/file-system.test.ts`, `packages/cli/src/cli.ts`, `packages/cli/src/commands/__tests__/init.test.ts`, `packages/cli/src/commands/__tests__/legacy-upgrade-regression.test.ts`, `packages/cli/src/commands/__tests__/migrate-conversion.test.ts` +15 more
- `packages/cli/src/evals/openrouter-client.ts` ← `packages/cli/src/evals/__tests__/loom-routing-runner.test.ts`, `packages/cli/src/evals/__tests__/loom-routing-runner.trajectory.test.ts`, `packages/cli/src/evals/__tests__/pattern-planning-runner.test.ts`, `packages/cli/src/evals/__tests__/runner.test.ts`, `packages/cli/src/evals/__tests__/shuttle-execution-runner.test.ts` +15 more
- `packages/cli/src/evals/report-schema.ts` ← `packages/cli/src/evals/__tests__/artifact-bundle.test.ts`, `packages/cli/src/evals/__tests__/artifact-bundle.test.ts`, `packages/cli/src/evals/__tests__/artifact-bundle.test.ts`, `packages/cli/src/evals/__tests__/artifact-bundle.test.ts`, `packages/cli/src/evals/__tests__/artifact-bundle.test.ts` +13 more
- `packages/cli/src/evals/report-schema.ts` ← `packages/cli/src/evals/__tests__/artifact-bundle.test.ts`, `packages/cli/src/evals/__tests__/artifact-bundle.test.ts`, `packages/cli/src/evals/__tests__/artifact-bundle.test.ts`, `packages/cli/src/evals/__tests__/artifact-bundle.test.ts`, `packages/cli/src/evals/__tests__/artifact-bundle.test.ts` +14 more
- `packages/adapters/opencode2/src/sdk-types.ts` ← `packages/adapters/opencode2/src/__tests__/reconcile-agent.test.ts`, `packages/adapters/opencode2/src/adapter.ts`, `packages/adapters/opencode2/src/errors.ts`, `packages/adapters/opencode2/src/plugin.ts`, `packages/adapters/opencode2/src/reconcile-agent.ts` +11 more
- `packages/engine/src/runtime/types.ts` ← `packages/engine/src/__tests__/runtime-command-operations.test.ts`, `packages/engine/src/__tests__/status-control.test.ts`, `packages/engine/src/__tests__/status-control.test.ts`, `packages/engine/src/__tests__/status-control.test.ts`, `packages/engine/src/__tests__/status-control.test.ts` +11 more
- `packages/cli/src/args.ts` ← `packages/cli/src/__tests__/args.test.ts`, `packages/cli/src/cli.ts`, `packages/cli/src/commands/__tests__/config-validation-errors.test.ts`, `packages/cli/src/commands/__tests__/eval.test.ts`, `packages/cli/src/commands/__tests__/init.test.ts` +10 more
Expand Down
30 changes: 26 additions & 4 deletions docs/artifacts/cli-evals-migration-handoff.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ Largest files, by case count:

| Cases | File | First read |
| --- | --- | --- |
| 188 | `report-schema.test.ts` | mostly *"includes a pattern for X"* — enumerating a constant |
| 188 | `report-schema.test.ts` | **migrated** — 188 → 112 (task group 14) |
| 169 | `loom-routing-runner.test.ts` | runner behaviour; mixed |
| 161 | `artifact-bundle.test.ts` | bundle writing; largely observable |
| 153 | `langchain-agent-evals.test.ts` | judge adapter; mixed |
| 140 | `sanitizer.test.ts` | *"contains X"* against a denylist |
| 140 | `sanitizer.test.ts` | **migrated** — 140 → 91 (task group 14) |
Comment on lines +48 to +52
| 114 | `report-markdown.test.ts` | rendering; observable |

The observable promises are far fewer than the case count suggests, and they
Expand Down Expand Up @@ -81,9 +81,9 @@ are worth stating plainly before writing anything:
and the loader fills it from the matrix; a list restating the defaults is
rejected. Tests written against the old shape will mislead.

## Two findings this work has already produced
## Findings this work has already produced

Both came from writing scenarios against observed behaviour, and both are the
All came from writing scenarios against observed behaviour, and they are the
argument for doing the rest:

- **`{{{delegation.section}}}` does not exist** and has not since ADR 0001, yet
Expand All @@ -92,6 +92,28 @@ argument for doing the rest:
a working agent on `sonnet`, because the list is filtered against what the
adapter knows the harness can run (#195). Intended, but undocumented and
worth a product decision.
- **An empty `caseId` makes a whole run vanish from the dashboard, silently.**
Public-report assembly fails validation and `writeBundle()` treats that as
non-fatal, so no `public-report.json`, no Markdown, no indexes — and an `ok`
result (task group 14).
- **Seven exported sanitizer surfaces have no production caller** and are
reached only from tests (task group 14). See the strategy doc.

## Notes for whoever takes the next file

- **Score files are local, public artifacts are uploaded.** Only
`bundle-index.json`, `public-report.json` and `public-report.md` are in
`RUN_ARTIFACT_ALLOWLIST`. `score-<suite>.json` *does* carry explanation text
that the public report drops, so "no published file contains X" must say
which files it means.
- **Absence assertions need a positive twin.** Dropping the whole report also
satisfies "the payload appears nowhere". Assert the case is still published
alongside it, or the scenario passes for the wrong reason.
- **Index files are not reproducible.** They stamp `new Date()` into
`updatedAt`; only the run artifacts are byte-identical across runs.
- [`tests/support/evals.ts`](../../tests/support/evals.ts) is the shared harness;
[`tests/evals/publish-safety.scenario.test.ts`](../../tests/evals/publish-safety.scenario.test.ts)
is the worked example for a hostile-input table.

## Still open elsewhere

Expand Down
8 changes: 7 additions & 1 deletion docs/eval-sanitization-and-publish-pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -357,12 +357,18 @@ Immutable run artifacts under `runs/v1/<runId>/` are written **once and never ov
| `latest.json` | `LATEST_SNAPSHOT_SCHEMA_VERSION` | `updatedAt` |
| `last-N-runs.json` | `LAST_N_RUNS_SCHEMA_VERSION` | `updatedAt` |
| `suite-history-<suite>.json` (`SuiteHistoryManifest`) | `SUITE_HISTORY_SCHEMA_VERSION` | `updatedAt` |
| `model-comparison-<runId>.json` (`ModelComparisonManifest`) | `MODEL_COMPARISON_SCHEMA_VERSION` | `updatedAt` |
| `model-comparison-<runId>.json` (`ModelComparisonManifest`) | `MODEL_COMPARISON_SCHEMA_VERSION` | `runId` (no `updatedAt`) |

Mutable index artifacts MUST be re-fetched on every dashboard load (or after a TTL). Consumers MUST:

1. Reject any index where `schemaVersion` does not match the expected version constant.
2. Compare `updatedAt` against a freshness threshold and re-fetch when stale.
`model-comparison-<runId>.json` is the exception: it is regenerated per run
rather than accumulated across runs, so it carries `runId` and no
`updatedAt`. Judge its freshness from the run it names.

[`tests/evals/publish-safety.scenario.test.ts`](../tests/evals/publish-safety.scenario.test.ts)
pins both properties against the files the writer really produces.

Use the typed validators in `dashboard-indexes.ts` for these checks:
- `validateDashboardManifestCompatibility()` — returns `ok(parsed)` or `err(DashboardIndexError)` with `SchemaVersionMismatch` or `IndexParseError` variant
Expand Down
67 changes: 67 additions & 0 deletions docs/testing-strategy.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,34 @@ internal branches. What stays is what a user cannot observe from outside:
| `model-resolution.test.ts` | Pins the adapter↔engine `ModelResolutionInput` contract, which no generated file reveals. Its three cases pinning the adapter's model *constant* were deleted — those are observable |
| `bootstrap.test.ts` | Integrity of a shipped asset. Closer to a repo guard than a unit test |

The same rule applied to the evals sanitizer and report schemas:

Counts need one measure to be comparable. 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 unit tests did, so the two are quoted separately rather than
summed:

| | Before | After |
| --- | --- | --- |
| `sanitizer.test.ts` (source cases) | 140 | 91 |
| `report-schema.test.ts` (source cases) | 188 | 112 |
| **Unit total (source cases)** | **328** | **203** |
| Scenarios added (source cases) | — | 26 |
| Scenarios added (cases at runtime) | — | 113 |

125 unit cases went and 26 scenario cases arrived, running as 113. The
reduction is real, but it is not the point: the deleted ones were an enumeration
(`"contains composedPrompt"`, `"includes a pattern for html_script_tag"`) whose
user-visible form is an equally long table of hostile inputs fed through the
real bundle writer. The gain is not fewer tests but tests that fail when a
reader is put at risk, rather than when a constant is renamed. What stayed:

| Kept | Why |
| --- | --- |
| `assertPublishSafe()` / `assertJsonPublishSafe()` | The publish-mode guards. While the allowlist projection works they never fire, so no written file reveals their behaviour |
| The manifest schemas' rejection branches | The writer always passes the version constant, so a wrong `schemaVersion` is unreachable from outside; the branches guard a future producer |
| `sanitizeScoreRecord`, `dropUnknownFields`, `truncateExplanation`, `buildExplanation`, `assertExplanationSafe`, `REDACTED`, `FORBIDDEN_EXPLANATION_SOURCE_DESCRIPTORS` | Exported API with **no production caller** — see the finding below |

**Prove the deletion rather than asserting it.** Before deleting, break the
source and confirm the scenarios fail. For this pilot:

Expand All @@ -278,6 +306,24 @@ source and confirm the scenarios fail. For this pilot:
All four were caught by `tests/adapters` alone, with every deleted unit test
already gone.

The evals sanitizer migration repeated the exercise against `tests/evals`
alone:

| Mutation | Result |
| --- | --- |
| `sanitizeCaseResultSummary()` returns its input | 38 of 113 scenarios red |
| Explanation validation removed from `assembleCaseEntry()` | 42 red |
| `sanitizeMdValue()` returns its input verbatim | 2 red |
| `sanitizeProvenanceRecord()` spreads its input | 1 red |

The second mutation is the one worth reading twice. On the first pass it
turned **one** scenario red, because dropping validation makes
`PublicReportBundleSchema` reject the whole report, so `public-report.json` is
never written and *"the payload appears in no public artifact"* stays true. An
absence assertion was passing for the wrong reason again. 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.

### A scenario can pass without testing anything

The evals bucket produced the sharpest lesson so far, and every migration
Expand Down Expand Up @@ -308,6 +354,27 @@ dropped silently and resolution falls through to `DEFAULT_FALLBACK_MODEL`. A
typo in `models` yields a working agent on the wrong model rather than an error.
The scenario now records that.

The evals migration turned up three more:

- **A case with an empty `caseId` costs the run its dashboard presence,
silently.** `PublicReportBundle` assembly fails validation, and
`writeBundle()` treats that failure as non-fatal: `public-report.json`,
`public-report.md` and every dashboard index are skipped, and the result is
still `ok`. Nothing in the write result says the run will never appear.
- **Seven exported sanitizer surfaces have no production caller.**
`sanitizeScoreRecord()`, `dropUnknownFields()`, `truncateExplanation()`,
`buildExplanation()`, `assertExplanationSafe()`, `REDACTED` and
`FORBIDDEN_EXPLANATION_SOURCE_DESCRIPTORS` are reached only from tests — the
runners build explanations through `buildPublicExplanation()` in
`langchain-agent-evals.ts` and redact with their own patterns. Roughly 60
unit cases cover code nothing calls. They were kept and flagged rather than
deleted, because the decision is a product one.
- **A malformed summary throws instead of returning `err`.** A `CaseResult`
whose `summary` omits `dimensionScores` makes `writeBundle()` raise a
`TypeError` rather than a typed `BundleError`, against the `neverthrow` rule
in `AGENTS.md`. Reachable only by defeating the type system, so no scenario
asserts it.

## What the buckets found

Writing scenarios against real behaviour surfaced documentation that described
Expand Down
Loading
Loading