Repository navigation
Refuse agac clean and reset_workflow --full during a run - #1711
Merged
Merged
Conversation
LockDefaults.SIMPLE_LOCK_TIMEOUT_SECONDS had no reader. Every portalocker lock in the code is in the run tracker, and each one uses the atomic timeout. The internal defaults page described a shared/read lock that does not exist. Remove the constant, the tests that pinned its value, and its docs row.
Nothing above SQLite stopped a second `agac run` of a workflow. Two runs started half a second apart both did all the work, and in batch mode both submitted a batch job, which doubles the spend with a real vendor. `agac run` and `agac retry` now hold an advisory, non-blocking, exclusive file lock beside the workflow's database for the whole command. They take it before the workflow loads, because `--fresh` clears the store inside the load; a later lock would wipe the first run's rows before refusing. A second run exits 1 and names the holder's pid. The operating system releases the lock when the holder exits or is killed, so no stale lock can remain and no bypass flag is needed. Read-only commands, `retry --dry-run` and `retry --filter` do not take the lock.
--filter goes to RetryFilterCommand before RetryCommand.execute, so it never took the run lock #1696 adds. It rewrites dispositions, checkpoint rows, stored target rows, the status file and the retry manifest. During a run or retry of the same workflow, the run's next status save could drop its change, or the retry could put its snapshot back over the filter. RetryFilterCommand.execute now holds hold_run_lock for the whole command, taken before the store is opened, as RetryCommand does. A dry run writes nothing and still reads past the lock. Closes #1698 Signed-off-by: Muizz Lateef <Lateefmuizz@gmail.com>
agac clean --all deleted agent_io/store/ while a run was in progress. With #1696 the run lock lives in that folder, so the lock file went with it and a second agac run then passed the lock check. clean also deleted the live database and the run's staging inputs. reset_workflow.py --full deleted store/ the same way. The Cleaner now holds the workflow's run lock, in every mode, before it confirms or deletes anything, and exits with RunInProgressError while a run or retry holds it. With no store folder there is no lock to take, and none is created. reset_workflow.py --full holds the same lock: through agac's own module where the framework imports, else the same flock from plain python. The run.md sentence asking users not to clean during a run now says clean refuses. Closes #1699 Signed-off-by: Muizz Lateef <Lateefmuizz@gmail.com>
…-lock Signed-off-by: Muizz Lateef <Lateefmuizz@gmail.com> # Conflicts: # agent_actions/cli/_MANIFEST.md # docs.agent-actions/docs/reference/cli/retry.md # tests/integration/test_a_second_run_of_a_workflow_is_refused.py
… issue-1699-clean-run-lock Signed-off-by: Muizz Lateef <Lateefmuizz@gmail.com>
…lock Signed-off-by: Muizz Lateef <Lateefmuizz@gmail.com> # Conflicts: # tests/integration/test_a_second_run_of_a_workflow_is_refused.py
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Closes #1699. Now based on main, which has #1713 (#1698) merged. Main is merged in, so this PR shows only the #1699 change.
Problem
agac clean --alldeletedagent_io/store/while a run was in progress. With #1696 the run lock lives in that folder, so the lock file went with it and a secondagac runthen passed the lock check.cleanalso deleted the live database and the run's staging inputs.reset_workflow.py --fulldeletedstore/the same way.Change
Cleaner: holds the workflow's run lock in every mode (default,--target,--all) before it confirms or deletes anything. It exits withRunInProgressErrorwhile a run or retry holds the lock, and that error is no longer wrapped as "Cleaning failed". With no store folder there is no lock to take, and none is created.reset_workflow.py --full: holds the same lock, through agac's ownhold_run_lockwhere the framework imports, else the sameflockfrom plainpython3(the documented invocation). The soft reset is unchanged.cli/run.mddrops "do not run it during a run" and sayscleanrefuses.cli/utilities.mdsays so in thecleansection. The realtime manifest is updated.Verification
test_a_second_run_of_a_workflow_is_refused.py:test_a_clean_is_refused_while_another_holds_the_workflow[source|target|all]: asserts the lock file, staging, source, target and stored rows all survive;test_a_clean_runs_once_no_run_holds_the_workflow.test_reset_workflow_full_stays_full.py::TestARunInProgress: refused with and without the framework importable, and runs once the lock is released. The 2 refusal tests fail without the change.tests/unit/skillsgive 883 passed.