Wire installer to materialise SecurityValidator runtime artefacts (#160)#161
Merged
virtualian merged 1 commit intomainfrom Apr 27, 2026
Merged
Conversation
Closes the regression chain #156 → #157 → #158 → #159 → #160. New `migratePaiRuntime` helper copies `~/.claude/{package.json,bun.lock}` and `~/.claude/PAI/PAISECURITYSYSTEM/` into `~/.pai/`, then runs `bun install` if `node_modules/yaml/` is absent or the manifest was just refreshed. Adds `tryExecAt` (structured cwd, no shell) to `exec.ts`. Tracks `Releases/v4.0.3+/.claude/bun.lock` for reproducible installs (pins yaml@2.8.3). Soft-fails per sub-routine — failures surface via `Tools/verify-security-validator.sh` rather than aborting the install. After this lands, a fresh-machine install passes the verify script PASS=8 FAIL=0 with no manual setup. - New: `Releases/v4.0.3+/.claude/PAI-Install/engine/pai-runtime-migration.ts` - New: `Releases/v4.0.3+/.claude/bun.lock` - Edit: `actions.ts` — invoke from `runRepository` after `migratePerPackCommands`, both fresh-install and upgrade paths - Edit: `exec.ts` — add `tryExecAt` for shell-free subprocess calls
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
Closes #160. Closes the SecurityValidator regression chain
#156 → #157 → #158 → #159 → #160:yamlimport lazy/fail-open (silent no-op was masked).Releases/v4.0.3+/.claude/.~/.pai/automatically at install time.Changes
Releases/v4.0.3+/.claude/PAI-Install/engine/pai-runtime-migration.tsmigratePaiRuntimehelperReleases/v4.0.3+/.claude/PAI-Install/engine/actions.tsrunRepositoryaftermigratePerPackCommandsReleases/v4.0.3+/.claude/PAI-Install/engine/exec.tstryExecAt(structured cwd, no shell)Releases/v4.0.3+/.claude/bun.lockyaml@2.8.3Decisions (recorded in PRD)
~/.pai/is an independent runtime; user-editedpatterns.yamllives alongside the shippedpatterns.example.yamlwithout crossing the~/.claudeboundary.bun.locktracked in repo. Pinsyaml@2.8.3for reproducible installs across machines/dates. ~360 bytes.StepId. The helper extendsrunRepository, mirroring the three existing migrators (memory, skills, commands).Behaviour
package.json+bun.lock, runsbun install, copiesPAI/PAISECURITYSYSTEM/—failed=0,verify-security-validator.shPASS=8 FAIL=0.already-currentfor manifest,skipped-yaml-presentfor install,copiedfor PAISECURITYSYSTEM (cpSync merge semantics — user-editedpatterns.yamlpreserved).bun installeven when yaml marker is present, so the new pin actually lands innode_modules/.verify-security-validator.shis the post-install regression guard.~/.pai/exists as a regular file (corrupted state), aborts the module with a clear diagnostic rather than overwriting user data.Security review (in-PR)
/simplifyflagged a shell-injection vector in the first cut —tryExec(\"cd \\\"\${paiHome}\\\" && bun install\")would have failed on paths containing quotes/dollars/backticks and was injection-prone ifPAI_DIRwere ever attacker-influenced. Fixed by addingtryExecAttoexec.ts(usesexecFileSyncwith structuredcwd, no shell concatenation).Other findings actioned: idempotency hole on yaml major-bump (force install when manifest just changed), missing paiHome-is-directory invariant (clear-diagnostic abort), redundant intermediate
mkdirSync(cpSync recursive: truecreates intermediates — empirically verified).Out of scope
getPaiHomeDir× 3,cpFilter/isIgnored× 3 across migrators) — flagged HIGH severity by /simplify but touches three existing reviewed modules. Tracked separately (issue to be filed).~/.claude/PAI/on a fresh upstream clone (this PR tolerates source-absent gracefully via soft-fail; the upstream gap is Investigate: restructure two-root split to simplify absorbing upstream releases #144 territory).Test plan
bash Tools/verify-security-validator.shpost-install on a fresh machine — expect PASS=8 FAIL=0.already-current/skipped-yaml-presentsummary, no patterns.yaml clobbering.Releases/v4.0.3+/.claude/package.json, regeneratebun.lock, run installer — confirmbun installre-runs and yaml updates in~/.pai/node_modules/yaml/.