-
Notifications
You must be signed in to change notification settings - Fork 7
Pass exclude_rules through the plugin-facing prover runner #236
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
Merged
+91
−2
Merged
Changes from all commits
Commits
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
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
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,84 @@ | ||
| """``WrappedProverRunner`` is the ``ProverRunner`` handed to plugins through | ||
| ``CVLAuthorState``: one ad-hoc prover run that stages the spec and conf into the | ||
| working directory, forwards to ``run_prover``, and cleans up. | ||
|
|
||
| The prover core is mocked at ``composer.spec.source.author.run_prover``; the conf | ||
| the runner staged is read back from the path it passed on. | ||
| """ | ||
| from pathlib import Path | ||
|
|
||
| import pytest | ||
|
|
||
| from composer.prover.core import CexHandler, ProverCallbacks, ProverOptions, ProverReport | ||
| from composer.spec.source.author import WrappedProverRunner | ||
|
|
||
| from .conftest import conf_of_prover_call | ||
|
|
||
|
|
||
| class _NoCex(CexHandler): | ||
| """The mocked prover never reports a violation, so this is never reached.""" | ||
|
|
||
| async def analyze(self, all_results, tool_call_id, callbacks, report_dir) -> str: | ||
| raise AssertionError("no violation was reported") | ||
|
|
||
|
|
||
| def _runner() -> WrappedProverRunner: | ||
| return WrappedProverRunner( | ||
| config={"files": ["src/Foo.sol"]}, | ||
| prover_options=ProverOptions(), | ||
| main_contract="Foo", | ||
| ) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def staged_confs(monkeypatch) -> list[dict]: | ||
| """Every conf the runner handed to ``run_prover``, in call order.""" | ||
| confs: list[dict] = [] | ||
|
|
||
| async def fake_run_prover(folder: Path, args: list[str], *_rest, **_kw) -> ProverReport: | ||
| confs.append(conf_of_prover_call(folder, args)) | ||
| return ProverReport( | ||
| result_str="ok", link="local://test", raw_rule_status={}, certora_run_stdout="" | ||
| ) | ||
|
|
||
| monkeypatch.setattr("composer.spec.source.author.run_prover", fake_run_prover) | ||
| return confs | ||
|
|
||
|
|
||
| async def _run(tmp_path: Path, **selection) -> ProverReport | str: | ||
| return await _runner().run( | ||
| curr_spec="rule a { assert true; }", | ||
| working_dir=str(tmp_path), | ||
| cex_handler=_NoCex(), | ||
| callbacks=ProverCallbacks(), | ||
| tool_call_id="tc", | ||
| **selection, | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| class TestWrappedProverRunner: | ||
| async def test_runs_with_a_rule_selection(self, tmp_path, staged_confs): | ||
| # The shape every plugin call has (dz-strategy's ``lemma_prover`` included): | ||
| # a rule list and nothing about exclusions. | ||
| await _run(tmp_path, rules=["a"]) | ||
| [conf] = staged_confs | ||
| assert conf["rule"] == ["a"] | ||
| assert "exclude_rule" not in conf | ||
|
|
||
| async def test_runs_with_no_selection(self, tmp_path, staged_confs): | ||
| await _run(tmp_path) | ||
| [conf] = staged_confs | ||
| assert "rule" not in conf | ||
| assert "exclude_rule" not in conf | ||
|
|
||
| async def test_exclusions_reach_the_conf(self, tmp_path, staged_confs): | ||
| await _run(tmp_path, exclude_rules=["b"]) | ||
| [conf] = staged_confs | ||
| assert conf["exclude_rule"] == ["b"] | ||
| assert "rule" not in conf | ||
|
|
||
| async def test_per_run_config_overrides_reach_the_conf(self, tmp_path, staged_confs): | ||
| await _run(tmp_path, rules=["a"], compilation_steps_only=True) | ||
| [conf] = staged_confs | ||
| assert conf["compilation_steps_only"] is True |
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.
I was going to ask why the typechecker didn't help us here. Answer:
**configmeans that the typechecker just sort of assumes that any required kwargs that aren't provided explicitly come through that**config. that's disappointing and the only way to fix it is to change the calling convention which is a "whole thing".sigh. Alright then.