-
Notifications
You must be signed in to change notification settings - Fork 4
A tale of two fixes #24
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
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
93d4c4d
fix case of no udts crashing the pipeline
shellygr fe8d7c2
fix autosetup that on second call invokes astextraction, but does not…
shellygr 17953ef
Make summary_resolver importable without certora_cli (lazy find_jar)
shellygr b99a030
Install prover extra in pytest CI instead of deferring find_jar import
shellygr bc24b0d
Update certora_autosetup/setup/summary_resolver.py
shellygr ec34dd2
nit
shellygr 27c54a2
Merge branch 'shelly/autoprover-summaries-fixes' of github.com:Certor…
shellygr 1aedbe6
Merge branch 'master' into shelly/autoprover-summaries-fixes
shellygr 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
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,24 @@ | ||
| """Unit tests for composer.spec.source.summarizer input construction. | ||
|
|
||
| Regression guard: a contract with no user-defined types must not cause an empty | ||
| text content block to be sent to the LLM (Anthropic rejects those with | ||
| "messages: text content blocks must be non-empty"). | ||
| """ | ||
|
|
||
| from composer.spec.source.summarizer import _format_types, _types_input | ||
|
|
||
|
|
||
| def test_format_types_empty(): | ||
| assert _format_types([]) == "" | ||
|
|
||
|
|
||
| def test_types_input_empty_is_omitted(): | ||
| # The bug: an empty udts must yield no input element, never [""]. | ||
| assert _types_input("") == [] | ||
|
|
||
|
|
||
| def test_types_input_nonempty_keeps_preamble(): | ||
| assert _types_input("A struct Foo at the top level: use `Foo`") == [ | ||
| "The following types are available for use in your spec", | ||
| "A struct Foo at the top level: use `Foo`", | ||
| ] |
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,48 @@ | ||
| """Unit tests for ASTExtraction stdout parsing in summary_resolver. | ||
|
|
||
| Regression guard: ASTExtraction.jar (EVMVerifier OutPrinter) prints `Warning:` | ||
| diagnostic lines to stdout before the JSON payload, so a raw json.loads of stdout | ||
| fails at char 0. `_parse_ast_payload` must strip those leading lines and parse the | ||
| JSON that follows. | ||
| """ | ||
|
|
||
| import json | ||
|
|
||
| import pytest | ||
|
|
||
| from certora_autosetup.setup.summary_resolver import _parse_ast_payload | ||
|
|
||
| _AST = {"ast": {"importedMethods": []}} | ||
| _AST_JSON = json.dumps(_AST) | ||
|
|
||
|
|
||
| def test_pure_json_no_warnings(): | ||
| assert _parse_ast_payload(_AST_JSON, 0, "") == _AST | ||
|
|
||
|
|
||
| def test_warning_lines_before_json_are_stripped(): | ||
| stdout = ( | ||
| "Warning: Syntax warning in spec file dummy file:1:1: Registered the contract alias x\n" | ||
| "Warning: Syntax warning in spec file dummy file:2:1: Registered the contract alias y\n" | ||
| + _AST_JSON | ||
| ) | ||
| assert _parse_ast_payload(stdout, 0, "") == _AST | ||
|
|
||
|
|
||
| def test_ast_null_returns_none(): | ||
| assert _parse_ast_payload(json.dumps({"ast": None}), 1, "") is None | ||
|
|
||
|
|
||
| def test_empty_stdout_raises_with_exit_and_stderr(): | ||
| with pytest.raises(RuntimeError, match="produced no JSON.*exit 3.*boom"): | ||
| _parse_ast_payload("", 3, "boom") | ||
|
|
||
|
|
||
| def test_warnings_only_no_json_raises(): | ||
| with pytest.raises(RuntimeError, match="produced no JSON"): | ||
| _parse_ast_payload("Warning: something\n", 0, "") | ||
|
|
||
|
|
||
| def test_non_json_after_stripping_raises_with_context(): | ||
| with pytest.raises(RuntimeError, match="was not JSON after stripping diagnostics"): | ||
| _parse_ast_payload("Warning: w\nnot json at all", 0, "stderr text") |
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 know that sending an empty string as the entire message payload could cause an error, but an empty string in the messages array is a new one. agreed on the fix at the graphcore level, something we can fold into the "invoke" wrappers I've added in Certora/graphcore#21
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.
have you applied this in graphcore#21? it seems not?
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.
not yet, since I didn't want to make this PR rely on a fix that hasn't landed yet. But there's no reason not to do it now anyway...
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.
done