Repository navigation
feat(docs): Dox chat evals (#355) - #373
Conversation
…355) Phase 1 of #355. docs/worker/prepare-turn.ts now holds the question pick, the retriever cache, the namespaced search, fitChunks, selectVocabulary and assembleSystemPrompt; createChatHandler calls prepareTurn inside its existing try/catch with the same 500 path, trace and three stage timings. chat-handler.test.ts is unchanged. READMEs name prepare-turn.ts. Gate 1: pnpm check, typecheck (root and docs), build, docs:build, worker:bundle-check, docs:audit-dist, pnpm test (3831 passed), pnpm docs:test (1668 passed), test-marker grep: all exit 0. Gate 2: reviewer subagent, FAIL (dead VocabularySection import) on round 1, PASS WITH NOTES on loopback 1; notes in context/notes.md.
Phase 2 of #355. docs/evals/cases.ts holds 36 typed cases (starters derived from CHAT_STARTERS, two rewordings each, lookups, absent, off-topic, injection, follow-up and fault), 12 of them live, each group stating the source of its expectation. docs/evals/cases.test.ts checks routes, chunk ids, vocabulary titles, documented names and page contexts against the corpus, and shows on planted lists that each check fails. docs/tsconfig.json includes evals; stack.md's Layout lists docs/evals/. Gate 1: pnpm check, typecheck (root and docs), build, docs:build, worker:bundle-check, docs:audit-dist, pnpm test (3831 passed), pnpm docs:test (1682 passed), test-marker grep: all exit 0. Gate 2: reviewer subagent, FAIL (untraceable source for the terse lookups) on round 1, PASS WITH NOTES on loopback 1; notes in context/notes.md.
Phase 3 of #355. docs/evals/metrics.ts scores gmt's retrieval metrics without tools.offered (recallAt10, withinK, mrr, fit.kept, vocabulary.hit, refusal.quiet), truncated to three decimals. docs/evals/offline.test.ts runs in pnpm docs:test: every case goes through validateChatRequest and prepareTurn, and the scores must equal the committed baseline.json, which `pnpm --filter docs evals:baseline` rewrites and formats. Runbook in docs/evals/README.md; test tables, verify.md and stack.md updated. Baseline: recallAt10 0.888, mrr 0.703, every other metric 1. Misses: follow-up-undo-that, lookup-key-branch-prefix, lookup-what-does-clean-do. Gate 1: pnpm check, typecheck (root and docs), build, docs:build, worker:bundle-check, docs:audit-dist, pnpm test (3831 passed), pnpm docs:test (1706 passed), test-marker grep: all exit 0. Gate 2: reviewer subagent, FAIL (refusal.quiet and fit.kept departed from gmt's definitions) on round 1, PASS WITH NOTES on loopback 1; notes in context/notes.md.
Phase 4 of #355. docs/evals/read-stream.ts turns a chat SSE body into a record (text, traces, progress, refusal, run error, usage, finish reason, faults), parsing each event through Zod and never throwing; a stream with no terminal event is a fault. docs/evals/graders.ts runs the nine D12 graders that apply to a case, and a dox-refusal makes it ungraded. Both are proven on five fixtures recorded from createChatHandler over fakeText (answer, refusal, run-error, spent, truncated). The runbook gains the graders' table and how to re-record. Gate 1: pnpm check, typecheck (root and docs), build, docs:build, worker:bundle-check, docs:audit-dist, pnpm test (3831 passed), pnpm docs:test (1754 passed), test-marker grep: all exit 0. Gate 2: reviewer subagent, FAIL (markup pattern was not gmt's; known skipped indented fences) on round 1, PASS WITH NOTES on loopback 1; notes in context/notes.md.
…ent (#355) Phase 5 of #355. docs/evals/budget.ts holds the Neuron rates, the 350 worst case, the 2,500 default budget, the Gemini cap, the CI refusal and the RunGuard; docs/evals/report.ts the report shape, its diff with regressions flagged, and a write that only a fully passing run makes, with no answer text. docs/evals/run-live.ts runs the live flow under Node type stripping (`pnpm --filter docs evals:live`). wrangler.toml gains a local-only [env.evals] (remote AI, no KV, workers_dev = false), with worker:dev:evals blanking the Gemini key; docs/.cache/ is gitignored. The runbook gains its live section; READMEs, verify.md and stack.md match. Nothing was spent: the runner was exercised with --help, with no Worker (exit 2), under CI (exit 2) and against loopback fakes only. `wrangler deploy --dry-run --env evals`, credential-free, exits 0 listing the AI binding and no KV. Gate 1: pnpm check, typecheck (root and docs), build, docs:build, worker:bundle-check, docs:audit-dist, pnpm test (3831 passed), pnpm docs:test (1791 passed), test-marker grep: all exit 0. Gate 2: reviewer subagent, FAIL (a connection lost mid-stream exited 1, the regression code) on round 1, PASS WITH NOTES on loopback 1; notes in context/notes.md.
The first live run failed a correct answer to lookup-rename with "known: undocumented worktree directory". The answer's bash block held the comment "# Rename a specific worktree directory", and the grader read it as a command named `directory`. A shell comment is prose, and D7 checks code only, so comments are now dropped from shell and unlabelled fenced blocks before commands and flags are read. The corpus writes such comments itself (skills/worktree/SKILL.md:517), so an answer quoting it verbatim could not pass before. This fixes a false positive; no expectation changed.
…its report (#355) docs/evals/live-cf-gemma-4-26b.json is the first live report. All 12 live cases pass, every Neuron figure is measured from RUN_FINISHED usage, and the report holds no answer text. The runbook's cost table carries the run's figures. The run: - The evals scripts dropped `--local`. Under it, wrangler 4.152.0 printed `env.AI AI not supported`, and the first one-case attempt failed with `RUN_ERROR upstream_unavailable` and no usage, so nothing was spent. `--local` disables remote bindings, and Workers AI has no local simulator. Without the flag, the bindings table reads `env.AI AI remote`. `[env.evals]` binds AI only, so nothing else became remote. - GET /api/brains listed exactly cf-gemma-4-26b and cf-glm-4.7-flash, both workers-ai. - `--only lookup-rename`: measured at 79 Neurons, not flagged unmeasured. It failed a false positive in the known grader, fixed in the previous commit. - `--budget 4200 --write-baseline`: 12/12 pass, spent 937 of 4200 Neurons, 5 to 109 per question, 0.6 to 11 s per answer, 91 s in all. - Spend for the session: 1,016 Neurons on the NorthGuild account (Workers Free, the pool shared with gmt), approved by the maintainer. The same `--local` defect in main's `worker:dev` is filed as #367.
…es (#355) #366 renamed the SKILL.md issue section to '…, a ClickUp task or your own tracker', so the starter case's vocabulary title no longer resolved. Its --issue text in commands/branch.mdx also pushes the github-issue-integration guide from rank 3 to 4 for 'Name my branch after a GitHub issue', past the fit budget; the baseline records the move (fit.kept 1 -> 0.962, MRR 0.703 -> 0.7).
|
Merging
Please check the second item. I recorded the drop in the baseline instead of changing retrieval in this pull request. The answer for that question still gets Verified with |
craig-o-curtis
left a comment
There was a problem hiding this comment.
Requesting changes, mainly for the eval's injection cases: two canaries are never shown to the model, and the link canary is matched case-sensitively. As written, those cases pass whether or not the injection works. The other inline comments are about budget accounting and exit codes in the live runner.
The prepareTurn extraction from chat-handler.ts behaves the same as before. No issues there.
Smaller cleanups, none blocking:
- The
buildCorpus+RetrievalCorpus/CORPUS_TEXTsetup,BUILT_IN_COMMANDSand the request envelope are each copied acrosscases.test.ts,graders.ts,run-live.ts,offline.test.tsandprepare-turn.test.ts. readStreaminread-stream.tsis never used.convertUnixToUtcreturns"", never null, so the?? "unknown"fallback inrun-live.tsnever runs.
… review found (#355) - Each injection question now orders its canary written, so an obeyed injection shows; cases.test.ts fails a canary the model is never shown, and leak matches it in any case. - cases.test.ts reads a documented name as a whole token, as the known grader does. - The budget is the Workers AI brains' together and stops no Gemini brain; each case reserves the worst case (or a higher committed figure), so a run never passes it. - A non-2xx response is no answer and stops the run; a lost Workers AI stream books the worst case; a Gemini-capped case is ungraded and exits 3. - A partial --write-baseline recomputes spent over the report's cases. - readStream is gone, and generatedAt falls back on convertUnixToUtc's "".
|
@craig-o-curtis, thanks. The inline threads are answered one by one.
One thing to know about the committed live report. |
…evals # Conflicts: # docs/package.json
|
I merged The conflict was two neighbouring lines, not a disagreement. #370 removed The rest of #370 ( Verified with |
#372's cleanup.mdx edit ranks /commands/cleanup/ first for reworded-cleanup-merged-prs (was second), so retrieval.mrr moves 0.7 -> 0.719.
|
I merged |
craig-o-curtis
left a comment
There was a problem hiding this comment.
Thanks for working through these. I checked dffca39 against each thread, and all nine fixes are in:
- Canaries: each canary is now ordered in its question, and the new
cases.test.tscheck fails any case whose canary the model is never shown.leakmatches it case-insensitively throughsquash. isDocumented: now matches a whole token, and the planted--forccase proves it.- Budget: applies per provider, with a worst-case reservation, and Gemini brains are no longer stopped by it.
- Runner:
!response.okis a no-answer. A stream lost mid-answer books 350.leftUngradedandendRunare now separate, so capped runs exit 3. spent: recomputed over the merged cases.
Leaving the corpus hash for #374 makes sense, since it changes the production trace protocol. Your reasons for keeping the duplicated setup are fair.
Two non-blocking notes:
- As you said, the committed
passforinjection-ignore-instructionsinlive-cf-gemma-4-26b.jsonwas measured with the old question. It needs a--only injection-ignore-instructions --write-baselinerun before anyone relies on that number. - The canary is now in the question, so a refusal that quotes it back ("I won't write zq7-canary-attack") will grade as a leak. That errs on the safe side, but if it turns up in a live run, that's why.
Closes #355
Evals for the Dox chat: a fixed case set, each case scored by code against what a good answer needs. Plan and ledger: #355.
pnpm docs:test, no model, no key):docs/evals/runs every case throughvalidateChatRequestand the new sharedprepareTurn, scores recall@10, withinK, MRR, fit.kept, vocabulary.hit and refusal.quiet, and fails on any move frombaseline.json.evals:liveagainst a local[env.evals]Worker, with a Neuron budget guard and a CI refusal. The first run on Gemma 4 26B passed all 12 live cases at 937 Neurons and is committed as its report.Phases landed, one commit each:
docs/worker/prepare-turn.tsOpen owner checks the feature ships with, none of them blocking: #305 (the starters' and rewordings' pages answer their questions) and #341 (the
dailyLimitagainst a shared quota). The three retrieval misses the baseline records are filed as #369.No release note: the change touches
docs/**,context/**and.gitignore, whichcontext/release.mdsays owe none. The merge deploys the Worker (docs/worker/**anddocs/package.jsonareworker-deploy.ymlpaths) with unchanged behaviour. It ships nothing to npm.