Repository navigation
fix(devtools): resolve repo root from cwd, not hard-pin (#1209) - #1239
Conversation
Problem: The `devtools` CLI wrapper (`devtoolsCli` in flake.nix) required POLYLOGUE_REPO_ROOT to be set and dispatched against it unconditionally. The devshell exports POLYLOGUE_REPO_ROOT="$PWD" once on entry, then inherits it into every subshell — including ones cd'd into a worktree. Result: `devtools verify --quick` run from a worktree silently validated the main checkout, producing misleading green results (originally observed during PR #1191 and filed as #1193). The audit goal of #1209 is to ensure no CLI wrapper carries the same hard-pin pattern. Solution: - Move the wrapper body to `nix/devtools-wrapper.sh` so the same script is both installed by Nix (via `writeShellScriptBin` + readFile) and unit-testable directly without building the flake. - Resolve the checkout from the caller's cwd via `git rev-parse --show-toplevel`, validated by the presence of `devtools/__main__.py`. POLYLOGUE_REPO_ROOT remains as a documented fallback for callers outside any git checkout. Both paths are validated; a stale env var no longer wins over a real cwd. - `polylogue`, `polylogued`, and `polylogue-mcp` are installed Python console scripts with no path baking — audited and confirmed. - No `/realm/project/polylogue` literal exists in flake.nix or nix/ (only in test fixtures and one docstring example, both unrelated). Verification: - `python -m pytest tests/unit/devtools/test_cli_wrapper.py` — 6 passed - `python -m devtools verify --quick` — exit 0 Closes #1209 Closes #1193
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
The
devtoolsCLI shell wrapper requiredPOLYLOGUE_REPO_ROOTand dispatched against it unconditionally. The devshell exports that variable once at entry and it is then inherited by every subshell — including ones cd'd into a worktree — sodevtools verify --quickrun from a worktree silently validated the main checkout. This PR makes the wrapper worktree-aware and audits the other CLI wrappers (polylogue,polylogued,polylogue-mcp) for the same anti-pattern.Problem
devtools verify --quickfrom an isolated worktree, got false-positive green, and the pre-push hook (which also callsdevtools verify --quick) had the same blind spot.Solution
nix/devtools-wrapper.shso the same shell script is read into the NixwriteShellScriptBin(viabuiltins.readFile) and exercised by unit tests directly — no Nix build required for the regression test.git rev-parse --show-toplevelfrom the caller's cwd, validated by the presence ofdevtools/__main__.py. This is the normal path and makes the wrapper worktree-aware.POLYLOGUE_REPO_ROOT, only when set and pointing at a real checkout. Documented fallback for tarball / non-git extraction cases.polylogue,polylogued,polylogue-mcpare Python console-script entry points ([project.scripts]inpyproject.toml) — no path baking, they import the installed package.flake.nixpostFixupwraps them withwrapProgramthat only scrubs PYTHON* env vars — no path pin.nix/module.nix(NixOS module) sets onlyPOLYLOGUE_CONFIG; no checkout path./realm/project/polylogueliteral exists anywhere inflake.nixornix/(only in a docstring example and test fixtures, both unrelated to the install surface).test_repo_wrapper_script_has_no_hardcoded_paths, which keeps the script free of/realm/project/polylogueand free of any "POLYLOGUE_REPO_ROOT is not set" hard requirement.The
POLYLOGUE_REPO_ROOT="$PWD"export in the devshellshellHookis retained because it still serves as the documented fallback for tooling that wants an explicit hint; it is no longer load-bearing fordevtoolsworktree dispatch.Verification
The new tests cover: cwd resolution, cwd-wins-over-env (the #1193 scenario), env-fallback outside git, invalid env-var ignored, no-checkout error path, and the static no-hardcoded-paths guard.
Closes #1209
Closes #1193