Framework for evaluating LLM based tools for Ada/SPARK use cases.
Warning
Safety Notice
During generation, LLM-based tools execute with broad system permissions and currently with no sandboxing. Likewise, during evaluation, generated code is compiled and run. Either phase may execute arbitrary code on your machine.
- Run only in disposable environments (containers, VMs, or clean cloud instances) with no important data, credentials, or network access to sensitive resources.
- Only use tools you trust for the generation phase.
To get started with this project, you will either need a setup that supports Dev Containers, such as VS Code with the Dev Containers extension, or you can set up your environment manually. To do this you will need the following tools installed on your system:
You will also need an Ada toolchain and GNATprove installed on your system, which can be obtained through Alire.
The recommended way to set up an Ada/SPARK toolchain is via Alire. More information on installing Alire can be found here.
Once you have Alire installed, you can install the toolchain and GNATprove with
alr install gnat_native gprbuild gnatprove gnatformatBy default, this will install the tools in ~/.alire/bin/, which you must ensure is in your PATH. Alternative installation locations can be specified with alr install's --prefix option.
ada-eval locates SPARKlib beside the gnatprove executable on PATH. For builds,
proofs and generation tools, it sets GPR_PROJECT_PATH to the project directories
needed for the run, including that SPARKlib installation.
Do this when you first clone the project. Use uv to install python dependencies (this will automatically create a virtual environment):
uv syncBy default, uv will create a virtual environment named .venv in your project. If you're using VS Code, you can use Python: Select Interpreter to select Python from the virtual environment generated by uv. This will enable code navigation.
If you don't use VS Code, you use the standard source .venv/bin/activate or equivalent to activate the virtual environment.
Alternatively, you can run commands in the project's virtual environment without activating it by running uv run ... (e.g., uv run pytest).
At a high level, the project is structured as follows:
.
├── data # Data directory containing various datasets
│ ├── base # Base data directory
│ │ ├── compacted # Single jsonl files derived from `expanded` (not version controlled)
│ │ └── expanded # The base datasets
│ ├── evaluated # Datasets that contain generated completions and corresponding evaluation results
│ └── generated # Datasets that contain generated completions
├── src # Source code for ada-eval
├── tests # Tests for ada-eval
├── tools # Tools used by ada-eval during generation
├── Makefile # Contains various commands for convenience
├── pyproject.toml # Defines project dependencies and configuration
├── README.md # This file
└── uv.lock # Lock file for dependencies managed by uvTo format your code, run:
make formatTo run linter/type checker, run:
make checkTo run the testsuite run:
make testTo add a new Python dependency using uv, run
uv add <package-name>
uv syncFor more info see docs.
The project has a simple CLI, as well as a makefile that contains some useful commands for your convenience.
You can see the CLI options by running:
uv run ada-eval --helpIf you look at the make target generate-spark-claude, you will see an example of how to generate completions for our existing challenges, using Claude Code.
make generate-spark-claudeIn data/base/expanded, you will find directories that each represent a dataset, which contain a number of samples (challenges/problems). The sample will have a different structure depending on the type of the dataset. Currently we only have SPARK datasets, though there is some support for Explain and Ada datasets too.
The general idea of each of these types are:
- Ada: Will require the modification of some Ada code to solve the challenge/problem
- SPARK: Will require the modification of some SPARK code to solve the challenge/problem. This could include adding new SPARK contracts, modifying existing ones, or changing the implementation to satisfy the given challenge.
- Proof samples use GNATprove to check the solution. They omit the
tests/project, which lets them use imported subprograms without linkable bodies. The"editable_path"field identifies the single file a solution can edit. - Explain: Contains some Ada/SPARK code and a question about it. The goal is to generate an explanation of the code that answers the question.
The rough structure of a SPARK sample is as follows:
example_sample
├── base # The project for the challenge. This will be duplicated somewhere for a tool to attempt to modify to solve the challenge
│ ├── main.gpr
│ └── src
├── comments.md # Comments about the sample for humans to better understand it
├── other.json # Contains additional metadata for the sample. For SPARK samples, this will include the name of the subprogram of interest, and the relative path to the file that contains its specification.
├── prompt.md # The prompt that is provided to the tool to specify the challenge/problem
├── proof_harness # Optional. A project, withheld from the tool, whose postconditions state what the solution's contracts must imply
│ ├── harness.gpr
│ └── src
├── solution # A solution to the challenge/problem. For SPARK samples, this will be a project that can be built, passes the tests, and gnatprove is happy with.
│ ├── main.gpr
│ ├── main.adc
│ └── src
└── tests # Unit tests supplement GNATprove for SPARK samples.
├── src
└── tests.gpr- Create a new directory in
data/base/expanded/your_dataset_of_choicewith the name of the sample. - Add the following:
-
base/: A project that contains the code that needs to be modified to solve the challenge/problem -
solution/contains the complete reference solution. The evaluator takes the build and proof settings (*.gprand*.adc) from this project when evaluating generated solutions. The evaluation result lists any project files the tool changed. Itsmain.gprmust setfor Object_Dir use "obj";, as the proof evaluator reads GNATprove results and object files fromobj. -
tests/applies to SPARK samples. Build the test executable attests/bin/testsand have it return zero exactly when all tests pass. -
proof_harness/: Optional. A project thatwiths the solution'smain.gprand wraps the subprogram of interest in a subprogram with the same inputs and outputs, whose postcondition states the properties the solution's contracts must imply. Name the wrapperProof_Harness.Check_<subprogram_name>(for example,Proof_Harness.Check_Max_Array). It is withheld from the tool, and it must prove against the canonical solution. The wrapper must have a postcondition check, and the harness must have nopragma Assume, non-SPARK entities, or GNATprove warnings. -
comments.md: if the challenge isn't obvious, consider including a more detailed description of the challenge/problem in this file -
prompt.md: A prompt that describes the challenge/problem. This will be provided to the tool to generate a solution. -
other.json: A file that contains additional metadata about the sample. For SPARK samples, this should look like:{ "location": { "path": "src/relative/path/to/file.ads", // Should be relative to the base/solution directory of the sample "subprogram_name": "Name_Of_Subprogram" // The name of the subprogram that is the focus of the challenge/problem }, "required_checks": [ { "rule": "VC_POSTCONDITION", // Rule name of a check that must be proved "entity_name": "Integer_Utils.Increment" // Optional name of the entity the check must be attached to }, ... ], "expected_non_spark_entities": [ // One entry per expected non-SPARK entity "Integer_Utils.Helper" ], "prove_whole_project": true, // Analyse every unit "editable_path": "src/integer_utils-increment.adb" // Editable subunit for a proof sample }By default, ada-eval passes the basename of
location.pathto GNATprove to analyse that unit and its transitive dependencies. Setprove_whole_projectto include every unit. Use this option for a generic when its instantiations supply the proof context.The
"required_checks"list is optional, and unnecessary for most samples, since the proof and/or tests will simply fail unless the problem is solved. However, for checks like postconditions, a desperate agent may "fix" the proof failure by simply removing or relaxing the condition. When no proof harness covers the property, arequired_checkcan catch a removed postcondition, but it cannot detect a weaker one. A proof harness (see above) checks the property's meaning through the solution's visible contract, so a separate postcondition check is unnecessary when the harness already covers it. An optional"src_pattern"regex may pin the text of a flow aspect such asDepends, which has a single correct form.check-datasetsrejects one on aVC_*rule, since matching text pins a contract's wording and not its meaning. The"src_pattern"must match starting from the location reported bygnatprove(rungnatproveon the solution with--report=allfor an output which includes the line and column numbers of these locations).If a sample intentionally uses entities outside SPARK, record their names in
expected_non_spark_entities. Common examples are imported stubs without bodies and bodies markedSPARK_Mode => Off. Runmake evaluate-canonicaland copy the names fromcanonical_evaluation_resultsundernon_spark_entities. Keep one entry per entity, including repeated names for overloads. The proof evaluator flags any additional non-SPARK entities in the sample's sources.check-datasetsrequires the recorded list to match the canonical result.The canonical solution must discharge every check. The evaluator rejects justifications using
pragma Annotate (GNATprove, False_Positive, ...)orIntentional. It also rejects entities markedSkip_ProoforSkip_Flow_And_Proof.GNATprove relies on the contracts of entities listed in
expected_non_spark_entitieswhen proving their callers. For example, changing an imported stub's postcondition fromX > 0toX > 1lets a caller assume a stronger guarantee than the stub originally promised.A sample that lists such entities must therefore set
editable_pathand declare them outside that file. A solution then cannot edit their contracts.For a proof sample, set
editable_pathto the subunit containing the target body. If an enclosing subprogram proves a contractless target by inlining it, use the enclosing body. Name the editable file in the prompt and tell the model which edits it may make.The evaluator takes every other file from the canonical solution. In the editable file, a submission may add, change or remove loop invariants, loop variants, assertions and ghost code. Compiling without proof material must yield the same object code as the base. The evaluator also accepts the canonical object code, since a base can use a
nullstatement where the canonical file has proof material.During dataset validation,
baseandsolutionmay differ only in the editable subunit. Its base may containLoop_Variantpragmas and must be free of other assertions and of declarations for expected non-SPARK entities. The checker also inserts an infinite loop into each editable procedure. The loop must fail proof or change the object code. A ghost procedure emits no executable code, so it must be required to terminate, for example withAlways_Terminates.
-
- Verify that the solution builds, proves, etc. by running
to populate
make evaluate-canonical
other.jsonand thento verify everything is correct.make check-datasets
To generate new completions for one or multiple datasets, you can use the generate command of the CLI. For example, to generate completions for all datasets using Claude Code, you can run:
uv run ada-eval generate --tool shell_script --tool-config-file tools/configs/claude_code_no_mcp.jsonThis also available via the shortcut make generate-spark-claude.
Currently you have to specify the type of tool you want to use, and the configuration file for that tool. The configuration files provide a place for modifying settings. Currently there are only shell tools, and the only values are used to specify where the script is located, and how long it should be allowed to run for.
This interface is not final.
Note
Currently no sandboxing is implemented. This means that LLM based tools may attempt to and succeed in circumventing the benchmark by discovering solutions elsewhere on the filesystem.
To evaluate completions that were generated as described in the previous section, you can run
uv run ada-eval evaluatewhich will run all available evaluations on the generations in data/generated/, and save the results to data/evaluated/.
For more options, such as specifying which evaluations are run, see the output of
uv run ada-eval evaluate --helpTo print a summary of the results, run
uv run ada-eval reportFiltering options etc. can likewise be found via the --help switch.
The combination of both of these commands is available via the shortcut make evaluate.
This interface is not final.
Check generation and evaluation for one sample with a tool configuration:
make smoke-test CONFIG=tools/configs/claude_agent_haiku.jsonThe command first evaluates the canonical solution to check the Ada/SPARK toolchain. It then generates and evaluates a solution with the configured tool, stopping at the first failure. By default, every evaluation of the generated solution must pass.
Set ALLOW_UNSOLVED=1 to allow failing evaluation results
for that solution, such as when checking a dummy tool. This does not change the
tool's prompt or configuration: the canonical solution must still pass, tool
generation must succeed, and every evaluation must finish without an error or
timeout.
Use SAMPLE=<dataset>/<sample> to select another sample.
Results are saved under data/smoke-test/<config path>/. The config path is
relative to tools/configs/, with its extension removed; configs outside that
directory use only their filename stem. Use --output-dir with
uv run ada-eval smoke-test to choose another output directory. Previous results
are replaced only after the config, toolchain, sample, and canonical checks pass.
An existing output directory
must contain only generated/ and evaluated/ directories of valid dataset files
and the smoke test's .gitignore; unexpected files or symlinks cause the command
to fail without clearing anything.
To inspect the evaluated results from this example:
uv run ada-eval report --dataset-dirs data/smoke-test/claude_agent_haiku/evaluatedSome evaluation problems are adapted from the MultiPL-E dataset. See THIRD_PARTY_LICENSES.md for license details.