Skip to content

microskills: read a wrapper's own options before the command it runs - #239

Open
KVR Vishnu (VISHNU0906) wants to merge 1 commit into
microsoft:mainfrom
VISHNU0906:fix/observe-wrapper-options
Open

KVR Vishnu (VISHNU0906) wants to merge 1 commit into
microsoft:mainfrom
VISHNU0906:fix/observe-wrapper-options

Conversation

@VISHNU0906

Copy link
Copy Markdown
Contributor

Hi Saksham Uboweja (@SakshamUboweja), this is the micro-skills side of #237.

classify_command in microskills/observe.py drops a wrapper in front of a command, but only the wrapper's name. When the wrapper had options of its own, the first option became the "command", so the run was not observed at all:

  • env -u CURSOR_AGENT python -m pytest, nice -n 10 pytest, sudo -u bob pytest, time -o t.txt pytest and timeout -s KILL 60 pytest gave no observation
  • so a working nice -n 10 python -m pytest after a failed bare pytest never counted as evidence for the form repair fact

Now it goes past each wrapper's options, using the same table as _WRAPPERS in loopguard/shell_edits.py (value-taking options, clusters like -Eu bob, attached values like -n5, --, and timeout's duration). I kept a copy in observe.py instead of importing it, since the mechanisms don't import each other. Happy to move it somewhere shared if you'd rather.

An env that changes the environment (-u, -i, -, -C, -S) now sets o.env, the same way env VAR=1 already does, so a form that only worked with env -u VAR in front isn't named as the working form.

Tests: two new tests in tests/test_envfacts.py, one on classify_command and one through EnvFactsDistiller (a wrapped repair forms the fact, an env -u one is not named). Both fail with observe.py from main. python -m pytest tests experiments/tests passes on Python 3.10 and 3.13, and scripts/dead_code.py output is the same as on main.

classify_command dropped only the wrapper's name, so in `env -u VAR python -m pytest`,
`nice -n 10 pytest` or `sudo -u bob pytest` the first option became the command and
the run was not observed. Go past each wrapper's options (the same table loopguard's
shell_edits uses), and mark an `env` that changes the environment as typed with an
assignment.

Signed-off-by: KVR Vishnu <46535652+VISHNU0906@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant