fix(pi): point pi at config dir via PI_CODING_AGENT_DIR instead of redirecting HOME - #243
fix(pi): point pi at config dir via PI_CODING_AGENT_DIR instead of redirecting HOME#243dgokeeffe wants to merge 2 commits into
Conversation
…directing HOME Pi honors the PI_CODING_AGENT_DIR env var to resolve its config directory (~/.pi/agent), so redirecting /Users/david.okeeffe to APP_DIR/pi-home was unnecessary. The HOME redirect broke macOS keychain default resolution under ucode: the Security framework looks for the login keychain under the redirected HOME, finds none, and security default-keychain returns 'A default keychain could not be found'. As a result gh auth, the git credential helper, and any keychain-backed tool failed inside pi. Setting PI_CODING_AGENT_DIR to the existing PI_CONFIG_DIR preserves config isolation (models.json/settings.json/sessions still land under APP_DIR/pi-home/.pi/agent) while leaving /Users/david.okeeffe as the user's real home, so the login keychain stays discoverable. Tests: the two pi e2e sites monkeypatched PI_UCODE_HOME/PI_CONFIG_PATH to redirect pi at a tmp home. They now also patch PI_CONFIG_DIR (read by build_runtime_env) and PI_SETTINGS_PATH/PI_SETTINGS_BACKUP_PATH (previously masked because the HOME redirect made pi read settings from the un-patched real APP_DIR path).
650cbc6 to
fa12598
Compare
|
Rebased onto current main and tightened after review: the test now explicitly proves HOME is preserved, stale HOME-based comments/docstrings were updated, and focused validation is 42 passed / 29 workspace-gated skips with Ruff clean. A maintainer CI approval/review is now the remaining gate. |
|
Rebased on current The remaining blocker is outside my control. Because these are fork PRs, every CI run has ended in @asujithan @rohita5l — could one of you approve the workflow runs? I'd suggest starting with this PR: it's the smallest of the four (+17 / −7, 4 files). It stops One heads-up on the Happy to take the other three (#223, #239, #217) one at a time after this one lands. |
Issue
Closes #291.
This PR's current head (
45db26a) and the current-origin/mainvalidation candidate (88d759c) have the same stable patch ID (eaa6fe487b9f968de6ff0da5fb1abc83b962bdcf). The focused/full evidence below was rerun from the rebased candidate without rewriting this existing PR branch.Unit 01 — Pi config-dir/keychain fix
Objective and user-visible behavior
Keep Pi models, settings, sessions, MCP, and skills under ucode's private Pi directory without changing the process
HOME. On macOS, subprocesses therefore keep login-keychain and credential-helper resolution.Candidate:
review/pi-config-keychain(88d759c), existing PR #243, compared with currentorigin/main.Exact scope
Production:
src/ucode/agents/pi.py.Tests:
tests/test_agent_pi.py,tests/test_e2e.py,tests/test_e2e_user_agent.py.Non-goals: model routing, context metadata, MLflow proxying, cache retention, managed config, MCP/skills behavior changes.
Before / after reproduction
Focused validation:
Full suite:
uv run --frozen pytest -q # 1 failed, 1658 passed, 36 skippedOnly
TestClaudeUserAgent::test_user_agent_arrives_at_gatewayfailed; integrateddevreproduces that installed-Claude capture failure. Pi's capture test passes here, providing direct regression evidence for home isolation.Live evidence
No Databricks serving behavior changes. The focused Pi installed-agent capture test validates the launched environment locally without logging credentials.
Impact map
PI_CODING_AGENT_DIRpoints at the existing private config root; realHOMEis preserved.Rollback and residual risk
Rollback by reverting
88d759c; this restores HOME redirection and its macOS keychain breakage. Residual risk is limited to older Pi releases that might ignorePI_CODING_AGENT_DIR; current installed Pi behavior is covered by the focused launch test.Hygiene
git diff --check origin/main..88d759cpasses. Four-file range; nouv.lock, generated files, credentials,.pi-subagents/, orgoal.md; no merge markers or unresolved index entries.