fix(airt): never overwrite hand-patched workflow files on regen (ENG-6813)#56
Merged
Merged
Conversation
…6813) Workflow generation wrote scripts to WORKFLOWS_DIR/<filename> unconditionally, clobbering any existing file at that path — including ones a user had hand-patched after generation. Timestamped names only reduced collisions implicitly (same-second regen still collides). Add _unique_workflow_path(): if the target exists, save as a new versioned file (name_v2.py, name_v3.py, ...) and return the actual name so callers report it. Applied at all five generate_* save sites. Also drops a duplicate METADATA_FILE assignment. Bump capability 1.4.0 -> 1.4.1. Validation: python -m pytest tests/test_attack_runner.py (103 passed, incl. 3 new TestUniqueWorkflowPath cases).
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes ENG-6813.
Summary
Workflow generation wrote each script to
WORKFLOWS_DIR/<filename>with an unconditionalfilepath.write_text(script), clobbering any existing file at that path — including one a user had hand-patched after generation. Timestamped filenames (%Y%m%d_%H%M%S) only reduced collisions implicitly; a same-second regen (or any explicit/non-timestamped name) still silently overwrote prior work.Fix
Add
_unique_workflow_path(filename): if the target already exists, save as a new versioned file (name_v2.py,name_v3.py, …) and return the actual filename so callers (summary +execute_workflownext-step hint) report the real file. Existing files are never touched.Applied at all five
generate_*save sites (single, category sweep, agentic, image, tabular). Also removed a duplicateMETADATA_FILEassignment.Bumps capability
1.4.0→1.4.1.Tests
TestUniqueWorkflowPath(3 cases):_v2, leaves the hand-patched original byte-for-byte intact_vNTest plan
python -m pytest tests/test_attack_runner.py— 103 passed (incl. 3 new)python -c "import ast; ast.parse(...)"— generated module compiles