fix(pi): preserve runtime dependencies in profile snapshots - #334
Open
thimpeng wants to merge 2 commits into
Open
fix(pi): preserve runtime dependencies in profile snapshots#334thimpeng wants to merge 2 commits into
thimpeng wants to merge 2 commits into
Conversation
Follow-up bug fix for PR SeemSeam#328, which introduced shared Pi profile asset snapshots. Local, Git, and direct package snapshots could lose npm-hoisted or pnpm-linked runtime dependencies after being copied into the isolated cache, causing valid extensions such as pi-accounts and pi-antigravity to fail at startup. Normalize package-style snapshots into a self-contained production dependency closure without network installs or lifecycle scripts. Verify cache bytes, modes, symlinks, concurrent publication, and missing or malformed dependency failures before publishing settings. Tests: 265 focused Pi, projected-asset, Codex, and Copilot profile tests passed on upstream main; Python byte compilation and diff checks passed; a real current-profile PI_OFFLINE=1 pi --help smoke test exited 0 without extension load errors.
Add committed regression coverage for scoped package placement, absent optional dependencies, and bundled dependencies identified during the GLM-5.3 review. Skip the executable circular-dependency probe when Node.js is unavailable so non-Node test hosts report the environment limitation instead of failing collection. Tests: 268 focused Pi, projected-asset, Codex, and Copilot profile tests passed; targeted boundary tests passed 4/4; py_compile and git diff --check passed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This is a follow-up bug fix for #328, which introduced shared Pi profile-asset snapshots. After that PR was merged, valid local Pi packages could be copied into the isolated CCB cache without the runtime dependency topology they resolved from in the source workspace.
The observed startup failures were:
pi-accountscould not resolveproper-lockfile, which npm had hoisted outside the copied package directory.pi-antigravityloadedeffect, buteffectcould not resolve its pnpm-linked transitive dependencyfast-checkafter snapshot isolation.Both packages declared their dependencies correctly. The regression was in CCB snapshot materialization, and the same defect class could affect other local, Git, or direct Pi package directories whose effective production dependency closure extends beyond the selected directory.
Root cause
PR #328 copied package directories into a content-addressed cache as standalone trees. That preserved package files but not dependencies resolved through npm workspace hoisting or pnpm store symlinks. Pi then loaded the copied snapshot as the new authority, where Node resolution could no longer reach those external dependencies.
Fix
node_moduleslookup, covering npm hoisting and pnpm-linked package roots.dependenciesresponsibility.Compatibility and impact
The fix retains the shared projected-asset API used by Codex and Copilot. Existing call signatures remain compatible; package normalization is limited to package-style Pi snapshot sources. npm-managed Pi packages continue to use the shared complete npm tree.
No global CCB installation, config reload, or endpoint restart is part of this PR.
Verification
All verification below was run on final commit
bb148731, directly above upstreammaincommit2dc46cf:PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 python -m pytest -q test/test_native_cli_providers.py test/test_projected_assets.py test/test_copilot_home.py test/test_provider_profiles.pygit diff --check: passed.PI_OFFLINE=1 pi --help: exited 0 without missing-module or extension-load errors.Regression coverage includes npm-hoisted and pnpm-linked transitive dependencies, circular loading through Node, cache tampering, executable and directory modes, source drift, scoped and bundled packages, absent optional dependencies, unsafe symlinks, and concurrent cache publication.
Independent review
GLM-5.3/highgate on final HEAD: ACCEPT, no blocker or major findings.Non-blocking follow-ups noted during review include measuring warm-cache hashing cost, considering a bound for ancestor dependency lookup, reducing duplicate closure copies in very large graphs, tightening a few package-name edge cases, and adding more optional-dependency variants. These do not affect the observed regression or the correctness of this fix.
Commits
821bd540— production fixbb148731— review follow-up tests and Node availability guardChecklist
mainat review and submission timeRelated: #328