Skip to content

[DEV] Compile-check generated harnesses before accepting them - #142

Merged
shellygr merged 3 commits into
devfrom
shelly/dev-pr-129
Aug 10, 2026
Merged

[DEV] Compile-check generated harnesses before accepting them#142
shellygr merged 3 commits into
devfrom
shelly/dev-pr-129

Conversation

@shellygr

@shellygr shellygr commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Mirror of #129 onto the dev bleeding-edge branch.

Source branch: shelly/harness-compile-gate. This branch is that head merged forward with dev; #129 itself is untouched and still targets master.

Per the dev branch policy this merges without review once pyright and pytest are green.

shellygr and others added 3 commits August 7, 2026 21:17
The harness generation prompt promises the agent that its harnesses are
type-checked on delivery and that compiler errors come back for repair, but
the check behind that promise never ran: it was gated on `if False`, because
invoking bare `solc` on the harness files cannot resolve a project's
remappings, include paths or compiler settings. A harness that does not
compile is therefore only discovered by AutoSetup, one phase later, where it
is misread as a compilation problem to work around rather than a source error
to repair -- and the run dies with everything downstream of it discarded.

Check them with the project's own build instead: write the candidates to a
scratch directory at the same depth as `certora/harnesses` (so their relative
imports resolve identically) and run `forge build --json` on them, which
reports diagnostics with a severity field and reuses the artifacts the build
phase already produced. Error-severity diagnostics are handed back to the
agent against the paths it knows; the scratch directory does not outlive the
check. Projects with no foundry build, or a forge that never gets as far as a
report, are accepted unchecked as before.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Building the delivered files in a scratch directory inside the live project
checks something subtly different from what the agent produced: the VFS may
hold files it wrote but did not deliver -- a shared base contract the
harnesses import, say -- and those would be missing from the build, failing
harnesses that are in fact correct. It also puts a directory into the project
tree for the duration of the check.

Materialize the VFS instead and build there. The harnesses keep their
`certora/harnesses` paths, so the diagnostics need no rewriting and the
scratch directory, its depth-matching requirement and its cleanup all go
away. Cost on a 353MB / 12k-file project: ~6.5s to materialize, and forge
reuses the copied build cache rather than recompiling the dependency graph.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@shellygr
shellygr merged commit cd62fff into dev Aug 10, 2026
2 checks passed
@shellygr
shellygr deleted the shelly/dev-pr-129 branch August 10, 2026 11:33
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.

1 participant