strix icon indicating copy to clipboard operation
strix copied to clipboard

feat(cli): --run-name for deterministic, resumable run dirs

Open seanturner83 opened this issue 4 months ago • 2 comments

What

Adds a --run-name flag 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:

  • Resuming across a credential / wall-clock boundary — e.g. assume a fresh cloud token every ~50 min, kill Strix, strix --resume <name>. That needs the name pinned up front.
  • 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 (find | head -1), which is fragile when a stale dir is present.

Behaviour

  • Precedence: --run-name > --resume > auto-generate. Absent flag = today's behaviour, unchanged.
  • Consistency: when both --run-name and --resume are 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.
  • Safety: the name is validated as a single filesystem-safe path segment (no /, no .., not ./..), since run_dir_for() joins it straight onto strix_runs/.

Tests

tests/test_cli_run_name.py (9, via parse_arguments() + monkeypatched argv, matching test_cli_target_list.py): accepts a single segment, defaults to None, rejects traversal (a/b, ../escape, /abs) and ./.., rejects a --run-name/--resume conflict. ruff clean.

🤖 Generated with Claude Code

seanturner83 avatar Jul 16 '26 21:07 seanturner83

Greptile Summary

This PR adds deterministic names for scan run directories. The main changes are:

  • Adds the --run-name CLI option.
  • Validates names as single path segments.
  • Enforces agreement between --run-name and --resume.
  • Adds argument-parsing tests for valid and invalid names.

Confidence Score: 4/5

The deterministic fresh-run path can overwrite and mix state in an existing run directory.

  • A repeated --run-name enters fresh-run initialization rather than resume handling.
  • Existing metadata is replaced while stale artifacts can remain.
  • Name parsing and resume-conflict validation otherwise follow the described behavior.

strix/interface/main.py

Important Files Changed

Filename Overview
strix/interface/main.py Adds run-name parsing, validation, conflict handling, and precedence, but allows fresh runs to reuse existing run directories.
tests/test_cli_run_name.py Covers parsing, traversal rejection, dot segments, defaults, and resume conflicts, but not existing-directory collisions.
Prompt To Fix All With AI
Fix 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

greptile-apps avatar Jul 16 '26 21:07 greptile-apps

Good catch — fixed in the latest push. A fresh (non-resume) --run-name that names an existing run dir is now rejected in parse_arguments() with a message pointing at --resume (the fresh path would rewrite run.json but leave the prior run's findings/state, mixing artifacts). Auto-generated names are collision-free so this only guards an explicit name. Added tests for both the existing-dir rejection and the new-dir accept.

seanturner83 avatar Jul 16 '26 21:07 seanturner83