fix/Runner-pipe-code-option · L-261117-ca9158
Merged
LC
9d ago+112+112+012345678901234567890123456789-6-6-0123456789
TL;DR
- The local Pipelex runner refuses a pipe code that is not a pipe reference of the standard's grammar, and passes the code to
pipelex run pipelast, behind--. - A pipe code starting with
-reached thepipelexcommand line as a bare positional and was read as one of its options (-L <dir>,--output-dir …), which matters to any application that forwards an end user's pipe code.
Behaviour changes
PipelexRunner.execute(pipe_code="-L"), or any code outside the grammar → raisesPipelexRunnerErrorbefore the CLI is looked up, anything is written or the CLI runs, on both therun pipepath and therun bundle --pipepath (it used to runpipelex … run pipe -L …).pipelex run pipe <code> [options]→pipelex run pipe [options] -- <code>.
Changes
Runner
mthds/runners/pipelex/runner.py: a pipe-reference pattern built from the standard's "Pipe Reference Syntax" (a bare code, a domain-qualified one, or a package alias followed by a domain and the code, every part[a-z][a-z0-9_]*), checked by_ensure_pipe_refat the top ofexecute; therun pipepositional now goes last, behind--, which pipelex's Typer and Click versions accept (checked with a Typer app of the same shape under pipelex's own environment).- The other positionals the runner builds are its own:
bundle <dir>andvalidate bundle <dir>take the absolute path of the run's temporary directory, and-L,-i,-oand--working-memory-pathare option values, which Click consumes whatever their first character.
Tests
tests/unit/test_pipelex_runner.py: each form of pipe reference reaches the CLI as the last argument behind--; codes outside the grammar, those starting with a dash first, are refused with and withoutfiles, with nothing written and the CLI never run. Cases live inPipeCodeCasesintests/unit/test_data.py.
How it was verified
make agent-check: ruff, pyright (0 errors), mypy (Success: no issues found in 134 source files) and the error-registry check all passed.DO_NOT_TRACK=1 make agent-test:All tests passed.pytest tests/unit/test_pipelex_runner.py:31 passed.
Documentation
docs/runners.md: thePipelexRunnerentry states the pipe-code rule and the--, and now saysexecuteusespipelex run pipewhen given nofilesand thatversionraises until the CLI reports its protocol version, which it already did.CHANGELOG.md: a### Securityentry under[Unreleased].
Not done
- The JS twin of this fix belongs to mthds-js and is tracked there separately.
- mthds-python's own
is_snake_caseis stricter than the standard's[a-z][a-z0-9_]*(it refuses doubled and trailing underscores); the runner follows the standard, and aligning the package is tracked in L-261117-990baf.
Closes L-261117-ca9158
🤖 Generated with Claude Code
https://claude.ai/code/session_019TF9N3aUmciysxinm72XqX
Summary by cubic
Fixes the local PipelexRunner so a pipe code starting with - can no longer be read as a pipelex CLI option. execute now validates pipe_code against the standard's pipe-reference grammar before anything is written or the CLI runs, and pipelex run pipe receives the code last, behind --.
- A valid reference is bare (
answer), domain-qualified (legal.contracts.answer), or package-qualified with its domain (docproc->extraction.extract_text); every part matches[a-z][a-z0-9_]*, and a package alias is always followed by a domain, sodocproc->extract_textis refused. - Codes outside the grammar raise
PipelexRunnerErroron both therun pipeandrun bundle --pipepaths, before the CLI is looked up or anything is written. - Adds unit tests covering every valid reference form and a set of refused codes, with nothing written and the CLI never run.
- Updates
docs/runners.mdand adds aCHANGELOG.mdsecurity entry.