feat(resume): opt-in grounded retraction of fixed findings
Problem
On --resume, prior findings are rehydrated so the cumulative report/SARIF carries forward across runs. That set is append-only today: if a later resumed run sees a finding has been fixed, there's no way to drop it. The resolved finding re-emits into every subsequent SARIF forever — a scanner alert (e.g. GHAS) that can never auto-resolve (fail-closed).
This matters when resume is driven as a PR-lifecycle loop (rescan on each push): the cumulative finding set needs to shrink as fixes land, not just grow.
What this adds (opt-in, default off)
-
ReportState.retract_vulnerability_report(id, reason)— the inverse ofadd_vulnerability_report: drops the report, deletes its stale per-finding MD, and letssave_run_data()rewrite CSV/JSON/SARIF from the reduced set. Idempotent. -
retract_vulnerability_reporttool — exposed on the root agent only on a resumed run and only whenSTRIX_RESUME_RETRACTis set. Default OFF: with the flag unset, resume behaves exactly as today (append-only) — this PR is a no-op for existing users until they opt in. -
Groundedness guard — before dropping, the tool re-verifies against the live
/workspacetree (via an injected sandbox reader) that the vulnerable sink is actually gone. If a finding'sfix_beforesink is still present verbatim → REFUSE; if no reader is wired → REFUSE (fail-safe). A confident-but-wrong agent cannot silently drop a real finding.
Prerequisite bugfix: id stability under removal (ungated)
add_vulnerability_report allocated ids as vuln-{len(reports)+1}. That's only correct while the set is append-only — once a report can be removed, length-based ids recycle: retract vuln-0002 from [0001,0002,0003] and the next add computes len+1 = 3 → vuln-0003, colliding with a live id (overwriting its MD) and letting a retracted id later re-emit under a different finding (SARIF fingerprint collision).
Fixed by allocating from the max ordinal ever seen (including retracted ids retained in _saved_vuln_ids), so ids stay monotonic and stable under removal. This is a no-op for append-only runs (max-seen == len there), so it doesn't change existing behaviour — it just makes retraction safe.
Why this shape
The retraction capability lives in strix (report state + a resume-gated tool), not in the SDK — it's specific to how strix manages a cumulative, resumable finding set. Kept fully behind an env flag so it lands dormant and opt-in.
Tests
tests/test_retract_vulnerability.py (9 tests): retract removal / idempotency / reason-required / MD-deletion, id stability under removal, and the guard's refuse-without-reader / refuse-when-sink-present / allow-when-gone / allow-when-nothing-verifiable paths. Existing report + state tests unchanged (46 pass). ruff clean.
Greptile Summary
This PR adds opt-in retraction of fixed findings during resumed scans. The main changes are:
- A resume-only root-agent tool for retracting findings.
- Source-tree checks before a finding is removed.
- Report-state removal and artifact rewriting.
- Max-based vulnerability ID allocation.
- Tests for basic retraction and guard behavior.
Confidence Score: 4/5
The retraction path can remove live findings, and report IDs can be reused after a later resume.
- Missing verification data currently permits deletion.
- Failed or misdirected reads are treated as confirmed file absence.
- Reader state is shared across scan lifecycles.
- The ID high-water mark is not persisted.
strix/tools/reporting/retract_tool.py, strix/core/runner.py, strix/report/state.py
Security Review
The retraction guard can remove live security findings without valid source verification when fix_before is absent, workspace reads fail, or shared reader state points at another scan.
Important Files Changed
| Filename | Overview |
|---|---|
| strix/tools/reporting/retract_tool.py | Adds the retraction tool and guard, but missing sink data and process-global reader state can produce incorrect retractions. |
| strix/core/runner.py | Injects the sandbox reader, but failed or misdirected reads are reported as confirmed file absence. |
| strix/report/state.py | Adds report removal and max-based allocation, but the ID high-water mark does not survive rehydration. |
| strix/agents/factory.py | Adds default-off, resume-only registration of the root retraction tool. |
| strix/config/settings.py | Adds the default-off environment setting for resume retraction. |
| tests/test_retract_vulnerability.py | Covers basic retraction but omits cross-process ID reuse, failed reads, and shared-reader cases. |
Prompt To Fix All With AI
Fix the following 4 code review issues. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 4
strix/tools/reporting/retract_tool.py:78-79
**Missing Sink Bypasses Verification**
`fix_before` is optional in existing reports, but this branch allows retraction when no location contains it. A resumed finding without `fix_before` can therefore be removed without reading the current source, even when the vulnerability is still present.
### Issue 2 of 4
strix/core/runner.py:262-275
**Read Failures Become Missing Files**
The reader returns `None` after every candidate path fails, and the guard treats `None` as proof that the sink is gone. A changed or omitted `workspace_subdir`, a permission failure, or another nonzero `cat` result can therefore approve retraction while the vulnerable file still exists elsewhere in the workspace.
### Issue 3 of 4
strix/tools/reporting/retract_tool.py:46-52
**Reader State Crosses Scan Boundaries**
This single module-level reader is shared by every scan in the process and is never reset. Concurrent resumed scans can overwrite it and verify a finding against another scan's sandbox, while a later scan can retain a reader bound to an old session, producing an incorrect retraction decision.
### Issue 4 of 4
strix/report/state.py:224-229
**Retracted Maximum ID Is Reused**
The “ever seen” IDs exist only in memory and hydration rebuilds `_saved_vuln_ids` from live reports. If `vuln-0003` is the highest ID and is retracted, the next process loads only `0001` and `0002`, so this allocator issues `vuln-0003` again and breaks the promised stable report and SARIF identity.
Reviews (1): Last reviewed commit: "feat(resume): opt-in grounded retraction..." | Re-trigger Greptile
Thanks @greptile-apps — this was a genuinely useful pass. Addressed in 986c974:
Issue 4 (retracted max ID reused after resume) — real bug, fixed. You're right: _saved_vuln_ids is rebuilt only from live reports on rehydration, so a retracted top id was lost and reused in a fresh process. The high-water mark now persists in run_record["max_vuln_ordinal"] (restored by hydrate_from_run_dir), verified across a process boundary.
Issue 3 (reader crosses scan boundaries) — fixed. The reader is reset to None in the run's finally block, and lifted out of the scan body into a module-level _make_workspace_file_reader (also makes it testable).
Issues 1 & 2 (missing sink / failed read → retraction allowed) — reworked, but by design rather than as a hard block. These flagged a real tension, and the resolution is a deliberate trust-model choice worth stating explicitly:
Strix trusts the LLM to find a vulnerability, so it trusts the LLM's judgement that one is fixed. The guard therefore never vetoes the agent — a hard refuse would swing into the opposite failure: stubbornly keeping a genuinely-fixed finding the guard just can't re-locate (moved/renamed file, a finding with no structured fix_before, a transient read failure), leaving an alert that can never resolve. Instead the guard returns a 3-way verdict recorded on the result:
gone→grounded=true(fix independently corroborated),present→grounded=false+ loud warning (contradicts the claim, but the agent may have legitimately re-reasoned — line now unreachable/guarded — so it's flagged, not blocked),inconclusive→grounded=false(no sink / unreadable — honoured on the agent's word).
The reader change from Issue 2 still matters for honesty here: it now returns None only on confirmed absence and raises on a failed/ambiguous read, so "couldn't read" is scored inconclusive, never mistaken for gone. And a mistaken retraction is self-correcting — findings are re-derived on every scan, so anything wrongly dropped re-appears next run. The whole feature is opt-in (STRIX_RESUME_RETRACT, default off).
Documented the behaviour + trust model in docs/usage/cli.mdx (Resuming a scan → Retracting fixed findings) and docs/advanced/configuration.mdx.
60 tests pass (14 retract + 46 existing), ruff clean.
The rework in 986c974 is well-executed. All four original issues are resolved, and the trust-model rationale is clearly documented at both the code and docs level. A few observations on the final shape:
Trust model (Issues 1 & 2) — the framing is correct. The 3-way verdict with GUARD_PRESENT logging a warning but not blocking is the right call. The old hard-refuse was a false safety — a static fix_before substring match doesn't capture "line is now unreachable/behind a guard" and would have caused permanent false-stuck alerts exactly as described. The reader correctly raising on ambiguous reads (vs. returning None) is the key fix that makes inconclusive honest.
One minor audit-log gap worth considering: GUARD_PRESENT and GUARD_INCONCLUSIVE both write grounded=False to the result, so downstream tooling (e.g. log aggregation, SARIF annotation) can't distinguish "guard actively contradicted the claim" from "couldn't verify". If you ever want that signal for audit trails or alerting, a third value like grounded="contradicted" would make that split explicit without changing any behavior. Not a blocker — just a future niceness.
ID high-water persistence (Issue 4) — correct. run_record["max_vuln_ordinal"] surviving through run.json → hydrate_from_run_dir → _next_vuln_ordinal properly closes the process-boundary gap. The max(persisted, live reports, saved_ids) formulation is also resilient to a stale or missing record.
Reader hygiene (Issue 3) — clean. Lifting _make_workspace_file_reader to module level and clearing in the finally block prevents both the cross-scan contamination and the leaked-session risks. The _reader: list[...] pattern to avoid global is a nice touch.
Overall this is solid — the feature is opt-in, fail-safe by default, self-correcting by design, and now correctly auditable. Happy to approve from a review standpoint.