Skip to content

Commit e9dfeba

Browse files
drandyhaasclaude
andcommitted
redo_stress_test: add --workdir; warn when a cwd isn't remapped (overwrite hazard)
A manifest records each command's `# cwd=` (the original run dir). redo remaps it along with the args, but if the recorded cwd prefix isn't covered by --remap (easy to get wrong -- the manifest's cwd may differ from the dir you think you're replaying), the command silently runs in the ORIGINAL run dir, overwriting its boards and breaking the chain into a fresh dir (the next step can't find the intermediate it expects -> degenerate replay). --workdir DIR forces every command into one directory regardless of the recorded cwd, so relative outputs chain correctly into a fresh dir -- the foolproof way to replay. Also warn when --remap is given but a command's cwd isn't covered by it. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent d7a9bc5 commit e9dfeba

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

tests/stress/redo_stress_test.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ def main():
6969
ap.add_argument("manifest", help="Path to redo_commands.sh manifest")
7070
ap.add_argument("--remap", action="append", default=[],
7171
help="OLD:NEW path-prefix rewrite applied to every argument (repeatable)")
72+
ap.add_argument("--workdir", metavar="DIR",
73+
help="Run EVERY command in DIR (created if needed), ignoring each "
74+
"command's recorded `# cwd=`. Use this to replay into a fresh "
75+
"directory: the manifest's relative output paths then chain "
76+
"correctly inside DIR. Without it, a command runs in its recorded "
77+
"cwd -- which silently OVERWRITES the original run's boards if "
78+
"that cwd isn't covered by --remap. The source board (absolute "
79+
"path) still resolves either way.")
7280
ap.add_argument("--skip-checks", action="store_true",
7381
help="Skip check_*.py commands (they do not mutate the board)")
7482
ap.add_argument("--dry-run", action="store_true", help="Print the plan, run nothing")
@@ -88,6 +96,9 @@ def main():
8896
remaps.append((old, new))
8997
os.makedirs(new, exist_ok=True)
9098

99+
if args.workdir:
100+
os.makedirs(args.workdir, exist_ok=True)
101+
91102
cmds = parse_manifest(args.manifest)
92103
if not cmds:
93104
print(f"No commands found in {args.manifest}")
@@ -102,7 +113,16 @@ def main():
102113
t0 = time.time()
103114
for i, (cwd, argv) in enumerate(cmds, 1):
104115
argv = apply_remaps(argv, remaps)
105-
cwd = apply_remaps([cwd], remaps)[0] if cwd else None
116+
# --workdir forces every command into one directory (chains relative outputs
117+
# correctly); otherwise use the command's recorded cwd, remapped.
118+
if args.workdir:
119+
cwd = args.workdir
120+
else:
121+
remapped = apply_remaps([cwd], remaps)[0] if cwd else None
122+
if remaps and cwd and remapped == cwd:
123+
print(f" WARNING: cwd {cwd} not covered by --remap; this command will "
124+
f"run in (and may overwrite) the original run dir. Use --workdir.")
125+
cwd = remapped
106126
if args.skip_checks and is_check_cmd(argv):
107127
print(f"[{i}/{len(cmds)}] skip check: {' '.join(map(shlex.quote, argv[:3]))} ...")
108128
continue

0 commit comments

Comments
 (0)