feat(cli): --run-name for deterministic, resumable run dirs#792
feat(cli): --run-name for deterministic, resumable run dirs#792seanturner83 wants to merge 2 commits into
Conversation
generate_run_name() always auto-derives the run dir name, so a fresh scan's dir
is unpredictable and a caller that needs to know it *before* the scan starts has
no way to key it. That blocks CI/automation patterns:
- resuming a scan across a credential / wall-clock boundary (assume a fresh
token every ~50min, kill Strix, `strix --resume <name>`), which needs the
name pinned up front, and
- restoring prior run state into a known dir before invoking Strix.
Today the only workaround is to scan strix_runs/ for the newest dir after the
first iteration, which is fragile when a stale dir is present.
Add --run-name: force ./strix_runs/<RUN_NAME>/ instead of generating. Precedence
is --run-name > --resume > auto; when both --run-name and --resume are passed
they must name the same dir (else we'd resume one run and persist to another) —
enforced, not silently resolved. The name is validated as a single
filesystem-safe path segment (no '/', no '..') since run_dir_for() joins it
straight onto strix_runs/. Absent flag = today's behaviour, unchanged.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Greptile SummaryThis PR adds deterministic names for scan run directories. The main changes are:
Confidence Score: 4/5The deterministic fresh-run path can overwrite and mix state in an existing run directory.
strix/interface/main.py Important Files Changed
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
strix/interface/main.py:901
**Existing Run Directory Is Reused**
When a fresh invocation passes a name already present under `strix_runs`, this selection enters the `not args.resume` path. `_persist_run_record()` then replaces the prior `run.json`, while old vulnerability and state files can remain, so repeated use of a deterministic name can destroy metadata and mix artifacts from separate scans. The fresh path should reject an existing run directory and require `--resume`, or explicitly replace the directory as one unit.
Reviews (1): Last reviewed commit: "feat(cli): --run-name for deterministic,..." | Re-trigger Greptile |
| # dir); else --resume reuses the prior run's name; else auto-generate. The | ||
| # --run-name/--resume consistency check above guarantees the first two agree | ||
| # when both are set, so this collapses cleanly. | ||
| args.run_name = args.run_name or args.resume or generate_run_name(args.targets_info) |
There was a problem hiding this comment.
Existing Run Directory Is Reused
When a fresh invocation passes a name already present under strix_runs, this selection enters the not args.resume path. _persist_run_record() then replaces the prior run.json, while old vulnerability and state files can remain, so repeated use of a deterministic name can destroy metadata and mix artifacts from separate scans. The fresh path should reject an existing run directory and require --resume, or explicitly replace the directory as one unit.
Prompt To Fix With AI
This is a comment left during a code review.
Path: strix/interface/main.py
Line: 901
Comment:
**Existing Run Directory Is Reused**
When a fresh invocation passes a name already present under `strix_runs`, this selection enters the `not args.resume` path. `_persist_run_record()` then replaces the prior `run.json`, while old vulnerability and state files can remain, so repeated use of a deterministic name can destroy metadata and mix artifacts from separate scans. The fresh path should reject an existing run directory and require `--resume`, or explicitly replace the directory as one unit.
How can I resolve this? If you propose a fix, please make it concise.Greptile P1: a fresh (non-resume) --run-name naming an existing run dir enters the not-args.resume path, where _persist_run_record() rewrites run.json but leaves the prior run's vulnerability/state files in place — mixing artifacts from two scans. Guard it in parse_arguments(): a non-resume --run-name whose run_dir_for() already exists is rejected with a message pointing at --resume (auto-generated names are collision-free, so this only bites an explicit name). +2 tests (existing dir rejected, new dir accepted). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Good catch — fixed in the latest push. A fresh (non-resume) |
What
Adds a
--run-nameflag that forces the run directory name (./strix_runs/<RUN_NAME>/) instead of auto-generating one.Why
generate_run_name()always auto-derives the run dir name, so a fresh scan's dir is unpredictable. A caller that needs to know the run dir before the scan starts has no way to key it — which blocks CI/automation patterns:strix --resume <name>. That needs the name pinned up front.Today the only workaround is to scan
strix_runs/for the newest dir after the first iteration (find | head -1), which is fragile when a stale dir is present.Behaviour
--run-name>--resume> auto-generate. Absent flag = today's behaviour, unchanged.--run-nameand--resumeare given they must name the same dir — otherwise we'd resume one run and persist to another. Enforced with a clear error, not silently resolved./, no.., not./..), sincerun_dir_for()joins it straight ontostrix_runs/.Tests
tests/test_cli_run_name.py(9, viaparse_arguments()+ monkeypatched argv, matchingtest_cli_target_list.py): accepts a single segment, defaults to None, rejects traversal (a/b,../escape,/abs) and./.., rejects a--run-name/--resumeconflict.ruffclean.🤖 Generated with Claude Code