-
Notifications
You must be signed in to change notification settings - Fork 4
Add findings to the report #80
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
naftali-g
wants to merge
1
commit into
master
Choose a base branch
from
naftali/findings-report
base: master
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.
Open
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,40 @@ | ||
| """Run-scoped capture of per-rule counterexample analysis. | ||
|
|
||
| The autoprove prover tool already runs an LLM analysis of every violated rule during the run | ||
| (``TrivialFanoutCexHandler`` -> ``analyze_cex_raw``); that text is otherwise consumed only as agent | ||
| feedback and discarded. This in-memory, run-scoped store captures it keyed by rule name | ||
| (last-write-wins across prover iterations) so the report phase can reshape the *final* iteration's | ||
| analysis into a finding without re-reasoning about the counterexample. | ||
|
|
||
| In-memory is sufficient: the report phase runs in the same process as formalization within | ||
| ``composer.pipeline.core.run_pipeline``. A ``BaseStore``-backed variant (cf. | ||
| ``composer.prover.report_store``) would be the resume-safe upgrade. | ||
| """ | ||
| from dataclasses import dataclass | ||
|
|
||
|
|
||
| @dataclass(frozen=True) | ||
| class CexAnalysis: | ||
| """One rule's captured counterexample analysis: the root-cause / fix explanation and, when | ||
| available, the counterexample call-trace dump it was derived from.""" | ||
| analysis: str | ||
| counterexample: str | None = None | ||
|
|
||
|
|
||
| class CexAnalysisStore: | ||
| """In-memory ``{rule name -> CexAnalysis}``, last-write-wins. Written by the prover tool's | ||
| callbacks as analysis completes each iteration; read by the report's findings synthesizer. | ||
|
|
||
| A violated rule that remains violated to the end was analyzed on the final prover run, so | ||
| last-write-wins holds its final-iteration analysis; a rule fixed before the end is GOOD in the | ||
| report and its (stale) analysis is simply never looked up.""" | ||
|
|
||
| def __init__(self) -> None: | ||
| self._by_rule: dict[str, CexAnalysis] = {} | ||
|
|
||
| def record(self, rule_name: str, analysis: str, counterexample: str | None = None) -> None: | ||
| """Store one rule's analysis under ``rule_name``.""" | ||
| self._by_rule[rule_name] = CexAnalysis(analysis=analysis, counterexample=counterexample) | ||
|
|
||
| def get(self, rule_name: str) -> CexAnalysis | None: | ||
| return self._by_rule.get(rule_name) | ||
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 |
|---|---|---|
|
|
@@ -101,6 +101,25 @@ async def __call__(self, input: ReportComponentInput[R], /) -> dict[RuleName, Ve | |
| ... | ||
|
|
||
|
|
||
| @dataclass(frozen=True) | ||
| class RuleEvidence: | ||
| """Backend-supplied raw material for synthesizing a finding from a violated rule. | ||
|
|
||
| ``analysis`` is the backend's pre-computed root-cause / fix explanation for the violation | ||
| (prover: the ``analyze_cex_raw`` output captured during the run); ``counterexample`` is a concrete | ||
| failing trace excerpt (prover: the rule's ``cex_dump``). Both optional — a finding degrades to | ||
| property/group text when absent.""" | ||
| analysis: str | None = None | ||
| counterexample: str | None = None | ||
|
|
||
|
|
||
| class EvidenceFetcher(Protocol): | ||
| """Backend hook: given a violated rule's run link + name, return its `RuleEvidence` (or ``None`` | ||
| when the backend has none). Prover reads the run-scoped CEX-analysis capture; foundry has none.""" | ||
| async def __call__(self, link: str | None, rule_name: str, /) -> "RuleEvidence | None": | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. absolutely no reason to quote this type annotation. a little curious you have the "positional only" marker here but I'm not mad about it. |
||
| ... | ||
|
|
||
|
|
||
| async def collect[R: ReportableResult]( | ||
| inputs: list[ReportComponentInput[R]], | ||
| *, | ||
|
|
||
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.
I strongly suspect we'll someday want to use the agentic handler for the cex in autoprover, so make sure we're not baking in an assumption about always using the TrivialFanoutCexHandler here.
That said, why not use the
BaseStoreversion? seems like we'd want to save this sort of thing?