Skip to content

test(evals): record the sandbox ref in evidence and warn on runner/ref mismatch - #4769

Merged
yomgui merged 4 commits into
devfrom
e2e/eval-ref-mismatch-guard
Sep 11, 2026
Merged

yomgui merged 4 commits into
devfrom
e2e/eval-ref-mismatch-guard

Conversation

@yomgui

@yomgui yomgui commented Sep 10, 2026

Copy link
Copy Markdown
Member

Root cause

Triage reports/e2e-red-2026-09-09/triage.md → "Not clusters → Evidence attribution bug" and "Order of work #7". Under --daytona the spec files execute from the runner's local checkout while the sandbox checks out and builds OPENWORK_EVAL_REF (default dev). Nothing compared the two, and test-run.json only recorded the runner's gitSha/branch, so a spec could be judged against product from another commit and the evidence bundle would still name the wrong one (PR #4741's false red; every bundle in the Sep 9 lane recorded ea1e9546e / feat/api-quality-spectral while the sandbox built 61b41901c).

What changed

  • Evidence (@openwork/test-evidence, @openwork/test-artifacts): test-run.json records sandboxRef (the ref the sandbox built) next to the runner gitSha under Daytona placement; it survives parse/judge/publish and shows in the evidence header and PR markdown (SHA <runner> · sandbox ref <ref> · engine v1). Local placement omits it.
  • Shared ref resolution (@openwork/env/eval-ref): daytonaPlacement / resolveEvalRef / resolveSandboxRef; resolvePlace now uses them instead of its private copy.
  • Runner guard (evals/bin/evals.mjs): resolves the sandbox ref the way the provisioning gate does (immutable shas as-is, branches via git ls-remote origin), appends ref=<ref>[@<sha>] to the placement: line, and prints a stderr warning: when it differs from HEAD. --strict-ref or OPENWORK_EVAL_STRICT_REF=1 fails before any sandbox is provisioned. The summary JSON gains sandboxRef, sandboxSha, refMismatch.
  • CI: daytona-e2e.yml passes --strict-ref (it checks out the same sha it pins as OPENWORK_EVAL_REF).
  • README paragraph on the guard and the evidence fields.

Proof

Unit (node --test): evals/bin/evals.test.mjs 22/22, packages/env/test/eval-ref.test.ts 2/2, packages/test-evidence/test/test-evidence.test.ts 6/6, packages/test-artifacts/test/* green.

Daytona, single spec, at dbcc8b731 (the last commit 6cb38fdec is README-only):

  1. Deliberate mismatch — OPENWORK_EVAL_REF=634df629a919db504e27d0f00962dc772344e42a pnpm evals:e2e app-smoke --daytona
    selection: engine=legacy surface=legacy case=all; placement: daytona (--daytona) ref=634df629a919db504e27d0f00962dc772344e42a [RUNNER/REF MISMATCH]
    warning: runner HEAD dbcc8b731 (e2e/eval-ref-mismatch-guard) differs from the ref the Daytona sandbox builds: 634df629a919db504e27d0f00962dc772344e42a. Specs run from this checkout while the sandbox builds that ref, so the verdict would judge another commit's product (test-run.json records both as gitSha and sandboxRef). Push this branch and export OPENWORK_EVAL_REF=$(git rev-parse HEAD). Pass --strict-ref to fail instead of warning.
    [openwork/testkit] ==> source verified 634df629a919db504e27d0f00962dc772344e42a
    
    1 passed / 0 failed / 0 skipped; summary "sandboxRef":"634df629a…","refMismatch":true; test-run.json: gitSha: dbcc8b731f8a…, sandboxRef: 634df629a919…, branch: e2e/eval-ref-mismatch-guard.
  2. Aligned — OPENWORK_EVAL_REF=$(git rev-parse HEAD) pnpm evals:e2e app-smoke --daytona
    selection: engine=legacy surface=legacy case=all; placement: daytona (--daytona) ref=dbcc8b731f8afa26e8d8d66fd16b095fa86d01bc
    [openwork/testkit] ==> source verified dbcc8b731f8afa26e8d8d66fd16b095fa86d01bc
    
    1 passed / 0 failed / 0 skipped; no warning; "refMismatch":false; test-run.json gitSha == sandboxRef == dbcc8b731….
  3. Strict, no sandbox provisioned — OPENWORK_EVAL_REF=634df629a… pnpm evals:e2e app-smoke --daytona --strict-ref → placement line with [RUNNER/REF MISMATCH], Error: runner HEAD dbcc8b731 … differs …, exit 1. Same with OPENWORK_EVAL_STRICT_REF=1 and the default dev ref (resolved via ls-remote to 4c74cb9c5, which had already moved past the local origin/dev).

Both sandboxes were deleted by the harness; none left behind.

Noticed, not touched

  • git ls-remote showed remote dev at 4c74cb9c5 while local origin/dev was 634df629a — the exact staleness the guard is for; local rev-parse origin/dev would have missed it.
  • publish-pr.ts still refuses stale evidence by comparing only gitSha to the PR head; with sandboxRef present it could also refuse when sandboxRef is a sha that differs from the head.
  • The OPENWORK_EVAL_REF || GITHUB_SHA || "dev" fallback is still duplicated in evals/runner/prepare-stack.ts and evals/worlds/first-run.ts (×2); they could use resolveEvalRef.
  • A dirty runner working tree (uncommitted product edits) is a sibling trap the guard does not cover; only HEAD is compared.
  • Pre-existing on clean origin/dev @ 634df629a: packages/labs/test/mock-google.test.ts "attributes drafts to one mailbox" fails (deep-equal on extra draftId/messageId/mime); spec-boundary-ratchet (opencode-v2-provider-hot-inject.test.ts) and spec-channel-ratchet (workspace-new-task-hit-target.e2e.test.ts 3 → 6) exit 1; pnpm --dir evals typecheck reports errors only in unbuilt sibling packages.

Specs execute from the runner checkout while the sandbox builds
OPENWORK_EVAL_REF, so evidence that only names the runner gitSha can
attribute a verdict to the wrong product commit. Record sandboxRef next
to gitSha under Daytona placement, keep it through parse/judge/publish,
and show it in the evidence header.
…ox ref

Under --daytona the specs run from the runner checkout while the sandbox
builds OPENWORK_EVAL_REF (default dev). evals.mjs now resolves that ref
against origin, prints it in the placement line, warns on stderr when it
differs from HEAD, and fails instead with --strict-ref or
OPENWORK_EVAL_STRICT_REF=1. The Daytona CI lane opts into the strict
mode since it checks out the same sha it pins.
@vercel

vercel Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
openwork-app Ready Ready Preview Sep 10, 2026 4:20pm UTC
openwork-den Ready Ready Preview Sep 10, 2026 4:20pm UTC
2 Skipped Deployments
Project Deployment Actions Updated
openwork-diagnostics Ignored Ignored Preview Sep 10, 2026 4:20pm UTC
openwork-landing Ignored Ignored Preview Sep 10, 2026 4:20pm UTC

@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Passed · 10/10 tests · 15/15 assertions · 5 images

Commit 997d80830e916a9ef0cb83cc5901cfec42347af4 · selected evidence

Open review report

@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Warden review summary — Clear

Native findings: 0. Blocking policy matches before consolidation: 0. Full finding text remains in Warden's native checks and review threads. This comment retains only native IDs, severity, skill attribution, and safe locations. Analysis run

Reported trigger coverage (not proof of complete repository or context coverage): diff-security-review (183427 ms), confidentiality-review (179940 ms).

Blockers

  • None.

Advisories

  • None.

Needs recheck

  • None.

Observed review-thread metrics

  • Unique observed run attempts in retained window: 2
  • Distinct heads in retained window: 2
  • Current unresolved Warden threads: 0 of 0 observed
  • Observed resolved/unresolved transitions in retained snapshots: 0 / 0
  • First observed resolved/unresolved (state at first collection, not event time): 0 / 0
  • Precision: unavailable (no adjudications; no TP/FP values are inferred)
  • Observation window: 2/20 run attempts retained; truncated: false
  • Transition snapshot: 0/0 current attributed threads retained (limit 500); truncated: false

Thread states are read-only collection snapshots. These metrics are neither lifetime totals nor exact resolution times, and this summary is not clearance authority.

@yomgui

yomgui commented Sep 10, 2026

Copy link
Copy Markdown
Member Author

Resync with dev — merge commit 997d80830e916a9ef0cb83cc5901cfec42347af4

origin/dev (6909f4ea0) merged into e2e/eval-ref-mismatch-guard as a merge commit (no rebase, no force-push). PR is MERGEABLE again.

Conflict resolved

  • evals/bin/evals.mjs — run(): kept this PR's ref-alignment placement: … ref=<ref>[@<sha>] [RUNNER/REF MISMATCH] label, warning: line and --strict-ref throw and dev's new per-world contract: lines (test(evals): declare web-first worlds and provision resources lazily #4762). Order: selection: line → contract: lines → ref warning/throw, so the strict guard still fails before any sandbox is provisioned.

Proof at the merge sha

  • Unit: node --test bin/evals.test.mjs packages/env/test/*.test.ts packages/test-evidence/test/*.test.ts packages/test-artifacts/test/* → 90 passed / 0 failed / 0 skipped.
  • Daytona: OPENWORK_EVAL_REF=997d80830e916a9ef0cb83cc5901cfec42347af4 pnpm evals:e2e app-smoke --daytona
    selection: engine=legacy surface=legacy case=all; placement: daytona (--daytona) ref=997d80830e916a9ef0cb83cc5901cfec42347af4
    contract: app-smoke.e2e.test.ts:5 test: resources=unknown; legacy; lazy provision only
    [openwork/testkit] ==> source verified 997d80830e916a9ef0cb83cc5901cfec42347af4
    
    1 passed / 0 failed / 0 skipped; summary "sandboxRef":"997d80830…","sandboxSha":"997d80830…","refMismatch":false, no warning: line. Sandbox openwork-connector-app-smoke-20260910-161919-… deleted by the harness.

@yomgui
yomgui merged commit 0a29be3 into dev Sep 11, 2026
30 checks passed

This branch was successfully deployed

2 active deployments
Preview – openwork-den — 997d8083 Deployed Sep 10, 2026 by vercel[bot]
Preview – openwork-app — 997d8083 Deployed Sep 10, 2026 by vercel[bot]
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