fix/Runner-pipe-code-option · L-261117-ca9158

Merged
LC
9d ago
+112-6

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 pipe last, behind --.
  • A pipe code starting with - reached the pipelex command 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 → raises PipelexRunnerError before the CLI is looked up, anything is written or the CLI runs, on both the run pipe path and the run bundle --pipe path (it used to run pipelex … 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_ref at the top of execute; the run pipe positional 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> and validate bundle <dir> take the absolute path of the run's temporary directory, and -L, -i, -o and --working-memory-path are 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 without files, with nothing written and the CLI never run. Cases live in PipeCodeCases in tests/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: the PipelexRunner entry states the pipe-code rule and the --, and now says execute uses pipelex run pipe when given no files and that version raises until the CLI reports its protocol version, which it already did.
  • CHANGELOG.md: a ### Security entry 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_case is 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, so docproc->extract_text is refused.
  • Codes outside the grammar raise PipelexRunnerError on both the run pipe and run bundle --pipe paths, 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.md and adds a CHANGELOG.md security entry.