Repository navigation
fix: isolate sequential hook execution state - #243
Open
priyanshuuu777 wants to merge 3 commits into
Open
priyanshuuu777 wants to merge 3 commits into
priyanshuuu777 wants to merge 3 commits into
Conversation
Author
|
Hi @xmnlab, could you take a look at this PR when you get a chance? |
Contributor
|
thanks @priyanshuuu777 i am reviewin this right now |
This branch has not been deployed
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.
This PR fixes state corruption during sequential hook execution in Makim.
Previously,
_run_hooks()created a single copiedMakiminstance and reused it across hook iterations. Each hook was executed through_execute_hook(), which calledrun()directly on that shared instance.Since
Makim.run()invokes_change_task()and updates task-scoped execution state, executing the first hook could mutate the instance subsequently used by other hooks. As a result, later hooks could resolve variables and environment values from the previous hook's scope instead of the parent task's scope.This could lead to incorrect conditional evaluation, unexpected environment-variable leakage, and subsequent hooks being skipped or executed with incorrect context.
This change isolates each hook execution by creating a dedicated deep copy of the hook runner inside
_execute_hook(). Mutations performed byrun()are therefore confined to that individual execution, preserving the state used by the hook-processing loop and exception-handling path.Changes made
deepcopy(makim_hook)for each hook execution in_execute_hook().How to test these changes
Run the complete test suite:
Run linting:
Verify formatting:
Run static type checking:
Run the security scan:
Regression verification:
The newly added regression tests were also executed against an untouched baseline worktree (
48e09d4).9 failed, 2 passed25 passedThe failures on the baseline demonstrate the affected behavior, while the patched implementation passes the complete test suite.
Smoke testing:
20/20 macOS-applicable smoke-test targets from the project's main workflow passed, including
run-hooks,failure-hook,vars-env,validate-conditionals,scheduler, andignore-error-option.Linux-only Docker-dependent smoke tests were not executed in the macOS environment.
Pull Request checklists
This PR is a:
About this PR:
Author's checklist:
Additional information
Baseline reproduction:
The issue was reproduced on the original
mainimplementation before applying the fix.The failure was not limited to hook output: subsequent hook executions could observe mutated task and group context, affecting scoped variables, environment values, and conditional evaluation.
Implementation scope:
The fix is intentionally localized to
_execute_hook()and does not introduce a new public API, dependency, or configuration option.CLI verification:
The same demonstration configuration was executed against the baseline and patched implementations.
No frontend or unrelated UI changes were introduced, as this is a CLI execution-state issue.