Skip to content

pipeio_run env resolution bug: _resolve_snakemake_cmd() finds snakemake on PAT

Goal

(promoted from note)

Context

(see source note)

Prompt

Fix the issue described in /storage2/arash/projects/projio/docs/log/issue/issue-arash-20260414-030010-945964.md. Read it first, then implement the proposed fix.

Acceptance Criteria

  • [ ]

Result

Completed in 222.6s (1 steps, model: sonnet)

Session: faa60403-e4a2-4807-8e44-3951be37da68 Result note: /storage2/arash/worklog/workflow/captures/20260414-030426-82a155/note.md

Output

456 tests pass. The fix is clean.

**Summary of changes:**

**`src/projio/mcp/pipeio.py`**
- Added `_resolve_default_env_name()` — reads `code.envs.default` from the project config, returns just the env name string (e.g. `"cogpy"`), or `None` on any error.
- Modified `_resolve_snakemake_cmd()` — inserted step 2.5 between the Makefile variable check (step 2) and the PATH search (step 3). When `code.envs.default` is set, it calls `_conda_run_cmd(default_env, "snakemake")` immediately, bypassing the PATH search that was incorrectly finding `snakemake` in the MCP server's `rag` env.

**`tests/test_mcp_pipeio.py`**
- Added `_resolve_default_env_name` to imports.
- Updated `test_finds_snakemake_on_path`, `test_falls_back_to_bare_snakemake`, and `test_returns_list` to mock `_resolve_default_env_name → None` so they don't accidentally hit step 2.5.
- Added `test_uses_config_default_env` — verifies step 2.5 works when `code.envs.default = "cogpy"`.
- Added `test_config_default_env_skips_path_snakemake` — verifies the `rag` env is never used when `cogpy` is configured.
- Added `TestResolveDefaultEnvName` with 3 tests for the new helper.

## Next Steps

1. Update the pixecog project's `.projio/config.yml` to set `code.envs.default: cogpy` so `pipeio_run` picks up the right snakemake immediately.
2. Investigate why `SNAKEMAKE := conda run -n cogpy snakemake` in the flow's Makefile wasn't being picked up — `resolve_makefile_vars()` only reads the root Makefile, not flow-specific ones in `code/pipelines/*/Makefile`.
3. Apply the same `_resolve_default_env_name` guard to `pipeio_dag_export` and `pipeio_flow_report` (lines 1433 and 1466), which currently also call `_resolve_snakemake_cmd()` without arguments and would have the same wrong-env bug.