fix(worktree): the npm-install log moves into the worktree's own gitdir - #1464
Conversation
|
ⓘ Qodo reviews are paused because your trial has ended. Ask your workspace admin to add credits to resume reviews. Manage billing |
ApprovabilityVerdict: Approved af1bfea This change relocates npm-install logs from a shared temp directory to the worktree's own gitdir, simplifying security handling while keeping the same install behavior. The change is self-contained, includes comprehensive tests, and reduces code complexity. No code changes detected at You can customize Macroscope's approvability policy. Learn more. |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates npm install logging for worktrees to use a per-worktree gitdir log file, and adds coverage to ensure logs are retained/cleared appropriately.
Changes:
- Move npm install logging from a shared
${TMPDIR}directory to<gitdir>/npm-install.logper worktree. - Extend shell test coverage to validate log retention on failure and log cleanup on success.
- Update documentation and size ratchet baseline to reflect the new behavior/size.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tools/size-ratchet-baseline.tsv | Updates the recorded size baseline for the worktree script after the logging change. |
| skills/worktree/tests/worktree_js_dependency_install.sh | Adds assertions and helpers to check that install logs are removed on success and retained on failure. |
| skills/worktree/scripts/worktree | Changes npm install logging location to the worktree’s gitdir and cleans it up on success. |
| skills/worktree/README.md | Documents the new npm install log location and behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c9f9e3eb0f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "Codex (@codex) review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".
Dismissing prior approval to re-evaluate 0784ea4
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (4)
skills/worktree/scripts/worktree:1803
umask 077is set before runningnpm install, which will also affect permissions of everything npm creates (e.g.,node_modules, caches, generated scripts). If the intent is only to makenpm-install.logowner-only, capture the prior umask, set077just for log-file creation, then restore the original umask before invokingnpm install.
umask 077
log=""
if gitdir="$(git rev-parse --absolute-git-dir 2>/dev/null)" &&
[ -n "$gitdir" ] && [ -d "$gitdir" ] &&
rm -f -- "$gitdir/npm-install.log" 2>/dev/null &&
: >"$gitdir/npm-install.log" 2>/dev/null; then
log="$gitdir/npm-install.log"
fi
if [ -n "$log" ]; then
if npm install --no-audit --no-fund >"$log" 2>&1; then
rm -f -- "$log"
fi
skills/worktree/tests/worktree_js_dependency_install.sh:269
- With
set -e, a failinginstall_log_pathinside command substitution can terminate the test script beforebadruns (depending on Bash’serrexitbehavior). To keep failures reported viabadinstead of aborting the harness, resolve the path into a variable with an explicit fallback (e.g.,log=$(install_log_path ... || echo '<unresolved>')) and pass that variable tobad.
bad "clean install clears its log" "$(install_log_path "$WT_NPM") still exists"
skills/worktree/tests/worktree_js_dependency_install.sh:285
- With
set -e, a failinginstall_log_pathinside command substitution can terminate the test script beforebadruns (depending on Bash’serrexitbehavior). To keep failures reported viabadinstead of aborting the harness, resolve the path into a variable with an explicit fallback (e.g.,log=$(install_log_path ... || echo '<unresolved>')) and pass that variable tobad.
bad "failed install log" "$(install_log_path "$WT_FAIL") missing, empty, or truncated"
skills/worktree/scripts/worktree:1796
- The
rm -ffollowed by: > fileis redundant for truncation/creation. If you primarily want to validate writability up-front, consider collapsing this to a single truncation/create operation (and keep any explicit existence/permission checks you need), which simplifies the control flow and reduces filesystem ops.
rm -f -- "$gitdir/npm-install.log" 2>/dev/null &&
: >"$gitdir/npm-install.log" 2>/dev/null; then
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0784ea4fda
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "Codex (@codex) review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".
|
Merge queue ejected this PR ( Ejecting merge-group run: not identified Failing job(s): No same-named check comparison available for the PR head. Automated by merge-queue-ejection-alert (VST-196). This alert never re-arms auto-merge. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (1)
skills/worktree/tests/worktree_js_dependency_install.sh:270
wait_for_install_log_removalreturns success immediately if the log file does not exist, which can produce a false positive (the test can pass before the background install ever creates/removes the log). To make this deterministic, first wait for the log to be created (or for some positive signal that install started), then assert it gets removed; alternatively, gate the removal check on having observed the log at least once during the wait window.
WT_NPM="$ROOT/.worktrees/repo/issue-npm"
if wait_for_install_log_removal "$WT_NPM"; then
ok "a clean install leaves no npm-install.log behind"
else
bad "clean install clears its log" "$(install_log_path "$WT_NPM") still exists"
fi
Dismissing prior approval to re-evaluate af1bfea
|
Merge queue ejected this PR ( Ejecting merge-group run: not identified Failing job(s): No same-named check comparison available for the PR head. Automated by merge-queue-ejection-alert (VST-196). This alert never re-arms auto-merge. |
Completes the PR #1451 review follow-up by deleting the shared-/tmp attack surface outright. The predictable `${TMPDIR:-/tmp}/worktree-npm-install-<uid>` scheme was raceable on a shared machine: another local user could pre-plant a symlink on the log file, and the directory's -L/-d/-O/chmod check sequence was non-atomic no matter how it was ordered. The log now lands at `<gitdir>/npm-install.log`. Each linked worktree has its own gitdir under the main checkout's `.git/worktrees/<name>/`, which is per-worktree and owner-controlled by construction — no shared directory, no predictable leaf, and no hardening dance to get wrong. An unresolvable or unwritable gitdir runs the install unlogged rather than failing, as before; the detached std fds, the flags, and the delete-on-success behaviour are unchanged. Two pins added: a failed install leaves its full output at that path, and a clean one leaves nothing behind. Claude-Session: https://claude.ai/code/session_01EwxSRv8oy1NxoQm66WKa4J
…oudly on an unresolved gitdir Claude-Session: https://claude.ai/code/session_01EwxSRv8oy1NxoQm66WKa4J
af1bfea to
5cef82d
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (2)
skills/worktree/tests/worktree_js_dependency_install.sh:269
- This test runs with
set -e, andinstall_log_pathis called inside command substitution in the failure-message path. Ifinstall_log_pathitself fails (e.g., gitdir can’t be resolved),errexitcan terminate the entire test early, skipping the intendedbadreporting and final PASS/FAIL summary. Prefer computing the path with an error-tolerant assignment before theif(or guard the substitution with|| true/ a fallback string) so failures are reported viabadrather than aborting the script.
bad "clean install clears its log" "$(install_log_path "$WT_NPM") still exists"
skills/worktree/tests/worktree_js_dependency_install.sh:285
- This test runs with
set -e, andinstall_log_pathis called inside command substitution in the failure-message path. Ifinstall_log_pathitself fails (e.g., gitdir can’t be resolved),errexitcan terminate the entire test early, skipping the intendedbadreporting and final PASS/FAIL summary. Prefer computing the path with an error-tolerant assignment before theif(or guard the substitution with|| true/ a fallback string) so failures are reported viabadrather than aborting the script.
bad "failed install log" "$(install_log_path "$WT_FAIL") missing, empty, or truncated"
The npm-install log moves into the worktree's own gitdir
Completes the follow-up promised on PR #1451's review threads: two reviewers showed the
${TMPDIR:-/tmp}/worktree-npm-install-$(id -u)scheme kept a raceable shared-tmp surface (log-file symlink pre-plant; non-atomic-L/-d/-O/chmod sequences on the directory). Rather than another hardening rung, the surface is deleted: the failed-install log now lives at<gitdir>/npm-install.log— each linked worktree's private gitdir under the main checkout's.git/worktrees/<name>/, owner-controlled and per-worktree by construction. No shared directory, no predictable/tmpleaf, no check-then-use window.: >so a bad path falls through instead of aborting before npm runs).$(create)gets EOF immediately),rm -f -- "$log"on success, failed install keeps its full log.Tests
14/14 green (the 12-pin dependency-install suite + 2 new pins: a failed install leaves its log at the gitdir path; a successful one leaves none). Both new pins have verified must-fail controls: forcing gitdir resolution empty fails the log pin, removing the success-path
rmfails the cleanup pin. Fulltools/validate-changedchain exits 0.https://claude.ai/code/session_01EwxSRv8oy1NxoQm66WKa4J