Skip to content

Commit fb6eaab

Browse files
committed
feat(evals): add approved evaluation workflow and TLA model
1 parent 6df2566 commit fb6eaab

13 files changed

Lines changed: 557 additions & 0 deletions

‎.github/workflows/agent-evals.yml‎

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Coding task evaluations
2+
3+
# First stage of #2085. Candidate results only. No baseline promotion or publishing.
4+
# Trust boundaries: docs/architecture/tla/EvalWorkflow.tla.
5+
on:
6+
workflow_dispatch:
7+
# Temporary live validation before merge. Remove this trigger before merging.
8+
push:
9+
branches: [issue/2085]
10+
11+
permissions:
12+
contents: read
13+
14+
concurrency:
15+
group: agent-evals
16+
cancel-in-progress: false
17+
18+
jobs:
19+
evaluate:
20+
# Remove the branch exception after the approved validation run.
21+
if: (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main') || (github.event_name == 'push' && github.ref == 'refs/heads/issue/2085')
22+
runs-on: ubuntu-24.04
23+
timeout-minutes: 120
24+
environment: final-vscode-review-smoke
25+
steps:
26+
- name: Checkout exact approved revision
27+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
28+
with:
29+
ref: ${{ github.sha }}
30+
persist-credentials: false
31+
32+
- name: Setup Node.js and pnpm
33+
uses: ./.github/actions/setup-node-pnpm
34+
with:
35+
install-args: "--frozen-lockfile"
36+
37+
- name: Install display dependencies
38+
timeout-minutes: 5
39+
run: sudo apt-get update && sudo apt-get install -y xvfb libasound2t64
40+
41+
- name: Prepare trust policy
42+
env:
43+
CANDIDATE_SHA: ${{ github.sha }}
44+
TRUST_FILE: ${{ runner.temp }}/agent-evals-trust.json
45+
run: |
46+
set -euo pipefail
47+
docker info > /dev/null
48+
node --import tsx --input-type=module -e '
49+
import { safeWriteJson } from "./src/utils/safeWriteJson.ts";
50+
const sha = process.env.CANDIDATE_SHA;
51+
if (!/^[0-9a-f]{40}$/.test(sha ?? "")) throw new Error("Invalid candidate SHA");
52+
await safeWriteJson(process.env.TRUST_FILE, { version: 1, approvedCommits: [sha] });
53+
'
54+
55+
# The side builds its own isolated worktree. Do not build a second copy here.
56+
- name: Evaluate candidate
57+
id: candidate
58+
timeout-minutes: 105
59+
env:
60+
SOLHEIM_API_KEY: ${{ secrets.FINAL_SMOKE_OPENAI_API_KEY }}
61+
CODING_EVALS_SIDE: candidate
62+
CANDIDATE_SHA: ${{ github.sha }}
63+
TRUST_FILE: ${{ runner.temp }}/agent-evals-trust.json
64+
EVAL_OUT: ${{ runner.temp }}/agent-evals
65+
run: |
66+
set -euo pipefail
67+
test "$(git rev-parse HEAD)" = "$CANDIDATE_SHA"
68+
test -z "$(git status --porcelain --untracked-files=all)"
69+
xvfb-run -a -s "-screen 0 1280x720x24 -nolisten tcp" \
70+
pnpm coding-evals:side --reps 3 --trust-file "$TRUST_FILE" --out "$EVAL_OUT"
71+
72+
- name: Write candidate summary
73+
if: ${{ !cancelled() && (steps.candidate.outcome == 'success' || steps.candidate.outcome == 'failure') }}
74+
env:
75+
CANDIDATE_SHA: ${{ github.sha }}
76+
EVAL_OUT: ${{ runner.temp }}/agent-evals
77+
run: bash scripts/agent-evals-summary.sh
78+
79+
- name: Upload candidate results and traces
80+
if: ${{ !cancelled() && (steps.candidate.outcome == 'success' || steps.candidate.outcome == 'failure') }}
81+
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
82+
with:
83+
name: agent-evals-${{ github.sha }}-${{ github.run_id }}-${{ github.run_attempt }}
84+
path: |
85+
${{ runner.temp }}/agent-evals/side-results.json
86+
${{ runner.temp }}/agent-evals/candidate-report.md
87+
${{ runner.temp }}/agent-evals/artifacts
88+
if-no-files-found: error
89+
retention-days: 90

‎.github/workflows/code-qa.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ jobs:
126126
run: pnpm solheim-smoke:check-types
127127
- name: Test agent evals units
128128
run: pnpm test:agent-evals:unit
129+
- name: Validate coding evaluation workflow
130+
run: node --test scripts/agent-evals-workflow.test.mjs
129131
- name: Check agent evals types
130132
run: pnpm agent-evals:check-types
131133
- name: Model-check task lifecycle protocols

‎docs/architecture/tla/EvalWorkflow.NoApproval.cfg‎

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎docs/architecture/tla/EvalWorkflow.NoCandidate.cfg‎

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎docs/architecture/tla/EvalWorkflow.NoHead.cfg‎

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎docs/architecture/tla/EvalWorkflow.NoReport.cfg‎

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎docs/architecture/tla/EvalWorkflow.NoTrigger.cfg‎

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎docs/architecture/tla/EvalWorkflow.cfg‎

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
---- MODULE EvalWorkflow ----
2+
\* Source: agent-evals.yml dispatch, evaluate.if, and environment approval.
3+
\* Sink: Evaluate candidate starts coding-evals:side with the provider key.
4+
\* Source: side-results.json and checkout HEAD after the candidate run.
5+
\* Sink: agent-evals-summary.sh publishes candidate-report.md and the summary.
6+
\* Failure: an unapproved event or ref can reach the provider job.
7+
\* Failure: provider execution starts with a different commit or dirty tree.
8+
\* Failure: incomplete or foreign results become an accepted summary.
9+
\* Invariants: SecretsAuthorized, ExecutionTrusted, and SummaryBound.
10+
\* Expect: current guards hold. Each removed guard violates an invariant.
11+
\* Stance: implementation was read before these first invariants were written.
12+
\* Scope: GitHub environment approval and side output validation are oracles.
13+
\* Scope: payload kinds stand for valid JSON inputs and a missing result file.
14+
\* Scope: artifact retention, cancellation, and hosted scheduling are outside the model.
15+
\* Assumption: the named environment requires approval for main and issue/2085.
16+
\* Limit: this model cannot inspect repository environment settings.
17+
\* Limit: no local actor changes the tree between a shell guard and execution.
18+
\* The isolated side runner checks its own worktree outside this model.
19+
\* Property tests: scripts/agent-evals-workflow.test.mjs.
20+
\* Review ratchet: 0 covered, 0 added, 0 gap. No review findings received.
21+
\* Result: EvalWorkflow.cfg passes in 1760 distinct states. No new bug was found.
22+
\* Controls: NoTrigger and NoApproval violate SecretsAuthorized.
23+
\* Controls: NoCandidate violates ExecutionTrusted. NoHead and NoReport violate SummaryBound.
24+
\* Replay: temporary workflow and shell guard removal fails the corresponding code tests.
25+
\* Replay: NoApproval removes the environment declaration, not a hosted reviewer setting.
26+
\* No live credential was used. No false alarm was found in the bounded code tests.
27+
\* Gate before simplification: all six TLC configs and 23 code tests give the expected results.
28+
\* Cost: about 8 agent minutes. Each TLC config completes in under 2 seconds.
29+
\* Run: TLA_JAR=<jar> docs/architecture/tla/check.sh EvalWorkflow.
30+
\* Run code tests: node --test scripts/agent-evals-workflow.test.mjs.
31+
\* A model check covers this model. It does not prove the workflow correct.
32+
\* Change: remove duplicate preparation checks. Keep the guard at provider execution.
33+
\* Change: allow approved push runs on issue/2085 until live validation finishes.
34+
\* Failure: another branch, main push, or a pull request reaches the provider job.
35+
\* Expect: SecretsAuthorized covers the explicit branch exception. No new bug is expected.
36+
\* Scope: one commit SHA is approved per run. Later branch pushes need new approval.
37+
\* Remove the temporary trigger, branch rule, and model exception before merging.
38+
\* Result after simplification: base passes in 2752 states. All five controls still fail.
39+
\* Replay: each removed guard still fails the real workflow or summary code tests.
40+
\* Gate: all 24 workflow tests and the evaluation type check pass. No new bug was found.
41+
\* Gate: all 419 offline evaluation tests pass outside the child-process sandbox.
42+
\* Cost: about 6 more agent minutes, including branch setup and model replay.
43+
EXTENDS Naturals
44+
45+
CONSTANTS Inputs, CheckTrigger, CheckApproval, CheckCandidate, CheckReport, CheckHead
46+
VARIABLES input, stage
47+
vars == <<input, stage>>
48+
49+
AllowedTrigger == (input.event = "workflow_dispatch" /\ input.ref = "main")
50+
\/ (input.event = "push" /\ input.ref = "issue/2085")
51+
CandidateMatches == input.startMatches /\ input.clean
52+
PayloadComplete == input.payload = "complete"
53+
54+
Init == /\ input \in Inputs
55+
/\ stage = "dispatch"
56+
57+
Dispatch == /\ stage = "dispatch"
58+
/\ stage' = IF ~CheckTrigger \/ AllowedTrigger THEN "waiting" ELSE "skipped"
59+
/\ UNCHANGED input
60+
61+
\* The GitHub environment is external. Denied approval never starts the job.
62+
Authorize == /\ stage = "waiting"
63+
/\ stage' = IF ~CheckApproval \/ input.approved THEN "ready" ELSE "denied"
64+
/\ UNCHANGED input
65+
66+
\* The shell gets the credential before it checks HEAD and the working tree.
67+
Execute == /\ stage = "ready"
68+
/\ stage' = IF ~CheckCandidate \/ CandidateMatches THEN "running" ELSE "guardRejected"
69+
/\ UNCHANGED input
70+
71+
\* Completion can leave no marker, invalid results, or a complete candidate.
72+
Finish == /\ stage = "running"
73+
/\ stage' = "result"
74+
/\ UNCHANGED input
75+
76+
Summarize == /\ stage = "result"
77+
/\ stage' = IF (~CheckHead \/ input.endMatches) /\ (~CheckReport \/ PayloadComplete)
78+
THEN "accepted" ELSE "summaryRejected"
79+
/\ UNCHANGED input
80+
81+
Next == Dispatch \/ Authorize \/ Execute \/ Finish \/ Summarize
82+
Spec == Init /\ [][Next]_vars
83+
84+
\* An invalid candidate can receive the step environment, but cannot execute.
85+
SecretsAvailable == stage \in {"ready", "guardRejected", "running", "result", "accepted", "summaryRejected"}
86+
ExecutionStarted == stage \in {"running", "result", "accepted", "summaryRejected"}
87+
SecretsAuthorized == SecretsAvailable => (AllowedTrigger /\ input.approved)
88+
ExecutionTrusted == ExecutionStarted => CandidateMatches
89+
SummaryBound == stage = "accepted" => (PayloadComplete /\ input.endMatches)
90+
====
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---- MODULE EvalWorkflowMC ----
2+
\* One run covers trigger, approval, checkout changes, and result publication.
3+
EXTENDS EvalWorkflow
4+
Enabled == TRUE
5+
Disabled == FALSE
6+
MCInputs == [event : {"workflow_dispatch", "pull_request", "push"},
7+
ref : {"main", "issue/2085", "other"},
8+
approved : BOOLEAN,
9+
startMatches : BOOLEAN,
10+
clean : BOOLEAN,
11+
endMatches : BOOLEAN,
12+
payload : {"complete", "missing", "wrongCommit", "wrongSide", "wrongSuite",
13+
"missingKeys", "duplicateKeys", "unknownOutcome"}]
14+
====

0 commit comments

Comments
 (0)