Add locked shell environment + centralized shell dialect guard for Bash tool#281
Open
mmprotest wants to merge 22 commits into
Open
Add locked shell environment + centralized shell dialect guard for Bash tool#281mmprotest wants to merge 22 commits into
mmprotest wants to merge 22 commits into
Conversation
…command-classification Tighten Windows cmd command guard and add short shell reminder
…covery-loop-in-runner Bounded recovery loop for hard verification failures
…avior-and-validation-checks
…-based-completion-gating Gate completion on active-solution validation and restrict full rewrites during recovery
…or-primary-execution-target Pin recovery flow to a primary execution target
…-gate-for-failures Add recovery gate: require direct validation of primary target before new executable artifacts are used
…ion-on-hard-failure Arm live recovery on primary hard failures and block immediate sibling-target pivots
…d-detached-launch-in-cmd Block unsafe Windows cmd detached-launch patterns and ignore errored validation artifacts
…ol-flow-for-long-tasks Align live target/recovery control path with evidence-based execution contracts
…ts-for-runner-capability Align live validation refresh, recovery context, and primary target contract seeding
d4c9f61 to
a0654ac
Compare
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.
Motivation
Description
Runnersession viadetect_shell_environment(...)and store it onRunner._shell_environment, capturingos_family,shell_family,shell_exe, andcwd.shell_environmenttoSessionStateand injecting it whenSessionStateis written (state_runtime._with_shell_environment).runtime_state={"shell_environment": ...}fromexecute_tool_with_lifecycle(...)intoexecute_tool(...)and_run_bash(...)so the guard runs centrally prior to subprocess invocation.villani_code/shells.pyprovidingShellEnvironment,ShellCommandDecision,detect_shell_environment(...), andclassify_and_rewrite_command(...)implementing simple token-based classification (allowed | needs_rewrite | blocked) and the minimal rewrite table:rm <args>->del /q <args>;grep pattern file->findstr /n /c:"pattern" file;tail -n N file->powershell -NoProfile -Command "Get-Content 'file' -Tail N".grep pattern file->Select-String -Pattern "pattern" file;tail -n N file->Get-Content file -Tail N._run_bash(...)(intools.py) so blocked commands are not executed and needs-rewrite commands are executed after rewrite;_run_bash(...)now returns structured results including classification and uses the rewritten command for execution.json.dumps(..., separators=(",",":"))) containingshell_family,classification=blocked,offending_pattern,short_reason, and optionalsuggested_equivalent.Testing
tests/test_shell_command_guard.pycovering: env detection returns ashell_family; cmdrmrewrite; cmdgreprewrite; cmdtailrewrite; cmd heredoc is blocked; powershellgreprewrite; bash-native command allowed; blocked commands return compact structured feedback.python -m py_compileon the modified modules; compilation succeeded.pytest -q tests/test_shell_command_guard.py tests/test_villani_control_loop_fixes.py; all tests passed:30 passed in 1.47s.Codex Task