|
| 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 | +==== |
0 commit comments