Skip to content

feat(check): run recording replays in PR checks, report replay and latency results, and label runs - #117

Open
scott-lowe-vapi wants to merge 1 commit into
mainfrom
scottlowe/test-291-gitops-run-recording-replays-in-pr-checks
Open

scott-lowe-vapi wants to merge 1 commit into
mainfrom
scottlowe/test-291-gitops-run-recording-replays-in-pr-checks

Conversation

@scott-lowe-vapi

Copy link
Copy Markdown
Contributor

Fixes the known bugs from TEST-291 in one PR, instead of the six planned there. It ports the engine changes from the gitops-sims-demos repository, which ran on prod, and fixes three bugs found in that code along the way.

What changes

Verdict (src/sim-result.ts, shared by npm run sim and npm run check)

  • A recording replay's result is in results.transcriptEvaluation, with results.evaluations empty. A passing replay was reported "incomplete" (exit 3), and a failing one showed "(no evaluation detail)". It now counts as scored when a required metric was measured or a key value is required. A failure lists each failing metric (expected vs actual) and each required key value that wasn't exact.
  • Required latency budgets (results.latencyEvaluations) that are over their threshold, or weren't measured, are listed.
  • Fixed from the demo code: over chat, the platform returns a skipped budget as passed: false, isSkipped: true. Skipped budgets are no longer listed as failures, which matches the platform's pass rule.
  • Fixed from the demo code: a measured, required, non-skipped latency budget counts as scored, so a scenario whose only evaluations are latency budgets no longer reads "incomplete".
  • Fixed from the demo code: an item that failed with no detail shows its failureReason, for example a recording that couldn't be fetched.

Replays in PR checks (src/check-payload.ts, src/check-mocks.ts, src/check-run.ts)

  • POST /eval/simulation/run rejects an inline transcriptReplay, on purpose (simulationRunTranscriptReplayValidate). A check now sends a replay scenario by its saved UUID, and the target is still built from the branch. The build fails over chat, with a runOrg, or when the scenario hasn't been deployed.
  • New: before a live run, the check GETs each saved replay scenario. If the file's transcriptReplay, evaluations, latencyExpectations or toolMocks differ from the saved copy, the check stops with an error and sends nothing. The demo only warned on every replay, so a PR that edited an answer key was judged on the old copy. The comparison ignores keys the platform adds, so a key removed from the file isn't caught (noted in improvements.md).
  • Tool safety holds: the platform answers a replay's tool calls with its own mock, and the target's servers still point at the dead URL.

Run labels (src/check-config.ts, src/check-build.ts, workflow)

  • A check can set an optional label. It's written on every simulation entry, with VAPI_CHECK_LABEL_CONTEXT appended (PR #N in CI, manual run for a dispatch), so the dashboard's runs table shows e.g. Background noise (voice) · PR #2 instead of "API run". When items share a name, the report names them by scenario and personality.
  • The workflow value is quoted. Unquoted, YAML cuts it at #. A new workflow test asserts the parsed value, and fails if the quotes are removed.

Validate: a stock personality's UUID (a0000000-…-00000000000N) no longer warns reference-by-uuid. The stock-ID regex now lives in one place, resource-parse.ts.

Docs: PR checks (label, replays, the stale-copy rule, the replay rollout), simulations learnings (replay result shapes, hosting a recording, writing the answer key in the transcriber's style, latency budgets, caller background noise), every backgroundSound bed in the resource reference, VAPI_CHECK_LABEL_CONTEXT in configuration, and improvements.md entries 45–46.

Not included

  • Push with several file paths (ticket item 4): not reproduced. config.ts keeps every path (a probe with three paths returned all three in applyFilter.filePaths), and filterResourcesByPaths loops over all of them. The "would update 1" count was likely unchanged or new files. It needs a reproduction before a fix.

Testing

  • npm run build, npm test (784 pass, 1 skipped because it runs only in CI), and npx biome check on the changed files.
  • New tests cover the three verdict fixes, the stale and missing saved replays (local HTTP stub), replayDifferences, the stock-personality exemption, and the quoted workflow value. The demo repo's tests were ported unchanged.
  • Not run: a live npm run check against a scratch org. The ticket's acceptance step (the demo's harbor-replays and harbor-latency checks on a clone of this branch) still needs a run that uses minutes.

🤖 Generated with Claude Code

…tency results, and label runs

- sim: the verdict reads results.transcriptEvaluation and
  results.latencyEvaluations. A replay or latency budget counts as scored,
  failures list the metric, inexact required key values and budgets over
  threshold, skipped (chat) budgets are ignored as on the platform, and an
  item with no detail shows its failureReason. Shared by npm run sim and
  the PR check.
- check: a transcriptReplay scenario is sent by its saved UUID (the run API
  rejects inline replays), voice and own org only. Before a live run the
  check reads each saved replay scenario and stops, sending nothing, when
  the branch's replay settings differ from it.
- check: an optional per-check label names every entry, with
  VAPI_CHECK_LABEL_CONTEXT appended (PR #N in CI), so the dashboard's runs
  table stops showing "API run".
- validate: stock personality UUIDs no longer warn reference-by-uuid.
- docs: replays, latency budgets, caller background noise and every
  backgroundSound bed.

Refs TEST-291

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copy link
Copy Markdown
Contributor Author

@roshan-vapi roshan-vapi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: one blocking issue that #118 does not change. In sim-result.ts, a measured latency budget now turns "all required judges skipped" into a pass (inline, with a probe result). The other inline comments are non-blocking.

I checked this PR against #118, which sits on top of it in the stack. #118 sends replays inline, and that fixes these replay-by-UUID findings. They only matter if #117 lands without #118:

  • The saved copy's targetOverrides and hooks skip walkObject and the strict mocks.
  • The stale-copy comparison misses targetOverrides and hooks. It is also one-way for nested keys, so dropping required from a key value or a budget is not caught.
  • The check-mocks guard accepts any scenarioId-only entry.
  • entry.scenarioId!.

Not inline:

  • A replay scenario in a shared suite makes the build fail for every chat check (and, with #118, every squad check) that uses that suite. Skip it with a warning, or document the rule in pr-checks.md.
  • promotion.yml doesn't set VAPI_CHECK_LABEL_CONTEXT, so a labelled check run by the promotion gate gets no context.
  • docs/learnings/simulations.md: the replay example hosts drug-names.wav at a public raw URL. Add a note: synthetic or de-identified audio only, and no tokens in recordingUrl.
  • Missing tests: skipped judges plus a measured latency budget, and a failed item whose failureReason comes with transcript detail.

Method: 10 Claude review passes (correctness, tests, silent failures, types, comments, simplification, completeness, security, adversarial, Greg-style) plus 1 Codex pass, de-duplicated. I verified the latency finding with a probe against head 90a6863.

Comment thread src/sim-result.ts
Comment on lines +170 to +175
(item.results?.latencyEvaluations ?? []).some(
(latency) =>
latency.required !== false &&
latency.isSkipped !== true &&
typeof latency.actualMs === "number",
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This OR lets a passing latency budget score an item by itself. I probed simRunVerdict at head: every required judge isSkipped plus one measured budget now returns passed. Without the budget, the same item returns incomplete. A budget says nothing about whether the conversation was right. Count latency only when the item has no required judge or replay metric, and add that test.

Comment thread src/sim-result.ts
item: itemLabel(item),
item: label,
evaluation: "(no evaluation detail)",
...(item.failureReason ? { reason: item.failureReason } : {}),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

failureReason shows only when there is no other detail. If a recording fetch fails and the platform still returns WER with actualValue: null, passed: false, the row reads wer ... null and the real reason is dropped. That is the case the PR body says this fixes. Attach reason: item.failureReason whenever it is set.

Comment thread src/sim-result.ts
// runLabelBuild), so name those items by scenario and personality instead.
export function simRunItemLabels(items: SimRunItem[]): Map<string, string> {
const names = new Set(items.map((item) => item.metadata?.simulation?.name));
const shared = items.length > 1 && names.size === 1;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: shared is inferred from equal names, so it also fires without a label. Examples: npm run sim with iterations > 1, or a check with one simulation. Those rows now read scenario (personality), and two items with the same scenario and personality can't be told apart. Pass an explicit labelled flag from the caller instead.

Comment thread src/check-config.ts
Comment on lines +219 to +220
value.trim() === "" ||
value.length > MAX_LABEL

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the length check runs before the trim, so a padded label that trims to 60 or fewer characters is still rejected.

Suggested change
value.trim() === "" ||
value.length > MAX_LABEL
value.trim() === "" ||
value.trim().length > MAX_LABEL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants