Repository navigation
feat(evals): add coding-task evaluation framework (#2084) #2154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
edelauna
wants to merge
31
commits into
main
Choose a base branch
from
issue/2084
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+12,406
−44
Open
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
4d54c33
feat(evals): add coding-task evaluation framework (#2084)
edelauna 5456f17
fix(evals): secure coding comparisons and correct grading and cost ac…
edelauna 2faf841
fix(evals): enforce trust checks and reliable comparison cleanup and …
edelauna 92506ac
fix(evals): pass test fixture paths as arguments instead of embedding…
edelauna 3dc9f7d
fix(evals): enforce isolated grading and safe interruption and result…
edelauna e2a6f6c
fix(agent-evals): reject dirty checkouts and clear stale grader digests
edelauna 8cb4bec
fix(agent-evals): prevent child startup after interruption and preser…
edelauna 5e601fa
fix(agent-evals): detect dirty checkouts despite Git settings that hi…
edelauna 3721cf8
fix(agent-evals): isolate side builds and invalidate stale results be…
edelauna afe27e0
fix(evals): wait for preparation cleanup after repeated interrupts
edelauna 8f9c78e
fix(evals): address review feedback on isolation, cleanup, and reports
edelauna c142e2d
fix(evals): address review feedback on isolation, cleanup, and reports
edelauna 64e28b6
fix(evals): close review gaps in cleanup and run accounting
edelauna 7fff071
fix(evals): bind grader images and isolate host caches
edelauna 5b88062
fix(evals): clean up partial side publication on failure
edelauna 26193b7
fix(agent-evals): prevent credential leaks to grading subprocesses
edelauna 189167f
fix(evals): probe container engines and preserve Docker endpoint sett…
edelauna 6b5ff22
fix(evals): qualify grader image and test output permissions
edelauna 541efb3
fix(evals): address review feedback and failing CI assertions
edelauna a2909dd
fix(evals): reuse verified private VS Code cache and preserve proxy s…
edelauna 0350c54
fix(evals): disable host commands and lock comparison output
edelauna 8fcb7a0
test(evals): verify disabled commands are blocked at dispatch
edelauna 2d184dc
fix(evals): harden grading results and lock standalone side output
edelauna 308be64
fix(evals): isolate grader assertions and protect output ownership
edelauna 81f7742
fix(agent-evals): verify trusted tests and share comparison output locks
edelauna 570313a
fix(evals): reject comparison outputs inside managed artifacts trees
edelauna 2d56347
fix(evals): validate comparison scratch paths before worktree setup
edelauna 56dfbba
fix(evals): address grading and comparison review findings
edelauna cb89a50
fix(evals): handle closed IPC and empty visible test files
edelauna 4e46e6d
fix(evals): stop coding sides when their parent disconnects
edelauna a3a7dd2
refactor(evals): share output publication protocol with TLA+ spec
edelauna File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| # Evaluation output publication | ||
|
|
||
| The coding evaluation feature has two output owners. A side owns its run | ||
| artifacts and `side-results.json`. A comparison owns its JSON report, Markdown | ||
| report, and `comparison-report.complete`. Each owner must hold its output lock | ||
| through execution, publication, rollback, and final cleanup. | ||
|
|
||
| The common publication protocol is in | ||
| [`publishGeneration`](../../scripts/agent-evals/publication.ts). The model is | ||
| [`EvalPublication.tla`](tla/EvalPublication.tla). The model checks the protocol, | ||
| not the file system or the evaluation feature as a whole. | ||
|
|
||
| ## Failures and invariants | ||
|
|
||
| | Failure | Invariant | Code boundary | | ||
| | --------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ------------------------------------------------- | | ||
| | A marker exists before the data writes finish. | Commit runs after all data steps. | `publishGeneration` calls `commit` after `steps`. | | ||
| | An interrupt arrives during a write, but publication returns success. | Check interruption before work and after each awaited step, including commit. | `publishGeneration` calls `check`. | | ||
| | A write fails after it changes the output, and a marker remains. | On failure, attempt rollback before returning or throwing. | `publishGeneration` calls `rollback`. | | ||
| | Rollback fails, but the call reports a clean stop. | Cleanup failure throws and retains both causes. | `AggregateError` in `publishGeneration`. | | ||
|
|
||
| The side adapter is `executeSideFlow`. Its data steps create artifact | ||
| directories, write run records, and build pinned results. Its commit writes | ||
| `side-results.json`. Its rollback attempts both result and artifact removal. | ||
|
|
||
| The comparison adapter is `publishComparisonReport`. It invalidates the old | ||
| marker before publication. Its data steps write JSON and Markdown. Its commit | ||
| writes the completion marker. Its rollback attempts all three removals. | ||
|
|
||
| The adapters keep their existing return contracts. A side returns | ||
| `completed: false` after a clean interruption. Comparison publication throws | ||
| on interruption; `executeComparisonFlow` maps the observed signal to the | ||
| comparison outcome after cleanup. | ||
|
|
||
| ## Model boundary | ||
|
|
||
| The model starts after old output is invalidated and the output lock is held. | ||
| One data write represents the bounded sequence of data steps. The next write | ||
| represents commit. A write can fail at any point. A signal can arrive before, | ||
| between, or after writes, until the function returns. | ||
|
|
||
| Atomic writes and cleanup are oracles. A failed rollback can leave a marker, | ||
| but it must throw. The model does not claim that an interrupt removes a marker | ||
| before cleanup completes. Process crashes can also leave files. Readers must | ||
| keep using the existing generation validation rules. | ||
|
|
||
| Output lock acquisition, trust approval, credential isolation, child process | ||
| termination, grading, and telemetry are separate contracts. Their existing | ||
| tests still apply. This extraction does not model or change those contracts. | ||
|
|
||
| ## Manual gate | ||
|
|
||
| Use the TLC command in [the spec policy](tla/AGENTS.md). Run these configs: | ||
|
|
||
| - `EvalPublication.cfg`: must pass. | ||
| - `EvalPublication.NoInterrupt.cfg`: must fail `SafeReturn`. | ||
| - `EvalPublication.EarlyCommit.cfg`: must fail `MarkerLast`. | ||
|
|
||
| Run `node --import tsx --test scripts/agent-evals/publication.test.ts`. | ||
| The property test enumerates generation sizes from one to four writes, every | ||
| interruption boundary, and every write-failure boundary. It also checks failed | ||
| rollback. Removing interruption checks or moving commit before the data steps | ||
| must make the property test fail. | ||
|
|
||
| Run `pnpm test:agent-evals:unit` and `pnpm agent-evals:check-types` after adapter | ||
| changes. Tests that use child process IPC need an environment that permits it. | ||
|
|
||
| For each later review finding, add the thread reference and its covered, | ||
| added, or gap result to the spec header, as the spec policy requires. Extend | ||
| this model only for publication failures. Use a separate subsystem model for | ||
| other contracts. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| CONSTANTS CheckInterrupt = TRUE | ||
| CommitLast = FALSE | ||
| SPECIFICATION Spec | ||
| INVARIANTS MarkerLast SafeReturn | ||
| CHECK_DEADLOCK FALSE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| CONSTANT CheckInterrupt = FALSE | ||
| CONSTANT CommitLast = TRUE | ||
| SPECIFICATION Spec | ||
| INVARIANTS MarkerLast SafeReturn | ||
| CHECK_DEADLOCK FALSE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| CONSTANT CheckInterrupt = TRUE | ||
| CONSTANT CommitLast = TRUE | ||
| SPECIFICATION Spec | ||
| INVARIANTS MarkerLast SafeReturn | ||
| CHECK_DEADLOCK FALSE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| ---- MODULE EvalPublication ---- | ||
| \* Source: executeSideFlow and publishComparisonReport start publication. | ||
| \* Sink: publishGeneration writes commit after data, then returns completion. | ||
| \* Failure: a failed or interrupted call returns a completion marker. | ||
| \* Failure: a completion marker exists before all data writes finish. | ||
| \* Invariants: SafeReturn and MarkerLast prevent these failures. | ||
| \* Expect: guards hold; removed interruption checks fail SafeReturn. | ||
| \* Scope: atomic writes and cleanup are oracles. Cleanup can fail and throw. | ||
| \* Scope: the caller owns the output lock. Crashes and lock loss are excluded. | ||
| \* Result: fixed passes in 25 states. No new protocol bug was found. | ||
| \* Sabotage: NoInterrupt fails SafeReturn; EarlyCommit fails MarkerLast. | ||
| \* Replay: both code mutations fail publication.test.ts; restored code passes. | ||
| \* Property: publication.test.ts checks 68 bounded schedules and cleanup failure. | ||
| \* Gate: 391 eval tests, eval type check, and shared ESLint pass. | ||
| \* Lint: src ESLint excludes scripts. Shared ESLint checks the changed code. | ||
| \* Suppression counts did not change. No suppression was added. | ||
| \* Refactor: comparison rollback errors now retain both failure causes. | ||
| \* This error-reporting change is a code finding, not a TLC finding. | ||
| \* Cost: about 8 agent minutes. Each TLC run took less than one second. | ||
| \* Run all EvalPublication configs and the property test on each fix commit. | ||
| \* Review: 0 covered, 0 added, 0 gap. No review threads read for this spec. | ||
| \* A model check checks this model. It does not prove the code correct. | ||
| EXTENDS Naturals | ||
| CONSTANTS CheckInterrupt, CommitLast | ||
| VARIABLES phase, written, interrupted, marker, result | ||
| vars == <<phase, written, interrupted, marker, result>> | ||
| Init == /\ phase = "writing" /\ written = 0 /\ interrupted = FALSE | ||
| /\ marker = FALSE /\ result = "pending" | ||
| Interrupt == /\ ~interrupted /\ result = "pending" | ||
| /\ interrupted' = TRUE | ||
| /\ UNCHANGED <<phase, written, marker, result>> | ||
| Write == /\ phase = "writing" /\ written < 2 | ||
| /\ ~(CheckInterrupt /\ interrupted) | ||
| /\ written' = written + 1 | ||
| /\ marker' = (IF CommitLast THEN written = 1 ELSE TRUE) | ||
| /\ UNCHANGED <<phase, interrupted, result>> | ||
| Fail == /\ phase = "writing" /\ phase' = "rollback" | ||
| /\ UNCHANGED <<written, interrupted, marker, result>> | ||
| Stop == /\ phase = "writing" /\ CheckInterrupt /\ interrupted | ||
| /\ phase' = "rollback" | ||
| /\ UNCHANGED <<written, interrupted, marker, result>> | ||
| Complete == /\ phase = "writing" /\ written = 2 | ||
| /\ ~(CheckInterrupt /\ interrupted) | ||
| /\ phase' = "done" /\ result' = "completed" | ||
| /\ UNCHANGED <<written, interrupted, marker>> | ||
| Rollback == /\ phase = "rollback" /\ phase' = "done" | ||
| /\ marker' = FALSE /\ result' = "failed" | ||
| /\ UNCHANGED <<written, interrupted>> | ||
| \* Failed cleanup throws. The marker can remain, but success cannot return. | ||
| CleanupFailure == /\ phase = "rollback" /\ phase' = "done" | ||
| /\ result' = "cleanupFailed" | ||
| /\ UNCHANGED <<written, interrupted, marker>> | ||
| Next == Interrupt \/ Write \/ Fail \/ Stop \/ Complete \/ Rollback \/ CleanupFailure | ||
| Spec == Init /\ [][Next]_vars | ||
| MarkerLast == marker => written = 2 | ||
| SafeReturn == /\ (result = "completed" => ~interrupted /\ marker) | ||
| /\ (result = "failed" => ~marker) | ||
| ==== | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
Repository: Zoo-Code-Org/Zoo-Code
Length of output: 8709
Script executed:
Repository: Zoo-Code-Org/Zoo-Code
Length of output: 2329
Move the negative-control toggles out of
EvalPublication.tlainto anMCmodule.CheckInterruptandCommitLastselect the deliberate protocol failures that the variant configs run. The spec declares them and gates actions on them (lines 33, 35, 39, 43). TheEvalPublication*.cfgfiles set them withCONSTANT X = TRUE/FALSE. NoEvalPublicationMC.tlaexists.AGENTS.mdrequires model-checking settings to live in anMCmodule, so the spec must stay free of them.Follow the
CommandApprovalDisplaypattern. Keep theCONSTANTSdeclaration in the spec. Add anEvalPublicationMC.tlathatEXTENDS EvalPublicationand sets the variant values. Update theEvalPublication*.cfgfiles and the manual TLC commands in the spec header to use the MC module.