You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PR Review — fix: [ENG-2881] tidy oclif client cache after brv update; rename hook to after-update
Read CLAUDE.md and understand repo conventions
Read changed files (hook + tests)
Analyze diff vs origin/main
Review for correctness, security, code quality
Post inline comments for any issues
Post final summary with score
Summary
Clean, well-scoped refactor: renames restart-after-update → after-update (file + tests + package.json hook path), and adds a tidyUpdatePluginClientCache step to the same hook so the oclif plugin-client cache (<dataDir>/client/<version>-<sha>) doesn't accumulate stale version dirs across updates. Existing restart behavior is preserved verbatim — handleRestartAfterUpdate is unchanged.
Strengths
praise: Hook is purely a thin composition over two pure, dependency-injected functions — easy to unit-test, easy to reason about. Matches the project's outside-in / testable style well.
praise: Test coverage is genuinely thorough — symlink semantics (relative, dangling, regular-file-instead-of-symlink), missing root, single active version, and a partial-failure case where one rm throws but the others still proceed. Injectable rmFn for the failure path is a clean touch.
praise: Conservative safety posture — if current can't be resolved to a real candidate, the function returns without deleting anything. That's the right default ("when in doubt, don't delete").
praise: Error handling is appropriately best-effort: readdir/rm failures are logged via logFn and don't throw, so a cache-tidy failure can never break the update command itself.
praise: Conforms to repo conventions — type for DTO shapes, ?? for nullish defaults, no as / any / !, .js import extensions in tests, no console logging from the hook.
Issues / questions
question (correctness):tidyUpdatePluginClientCache runs unconditionally on update, but handleRestartAfterUpdate skips for --autoupdate. That asymmetry is probably intentional (cache cleanup is safe to do for background auto-updates too), but worth confirming and either documenting or aligning. See inline comment.
suggestion (safety): Active-version resolution relies on basename(readlink(...)). Works for today's oclif-plugin-update layout, but a realpath + parent-equals-root check would harden against future plugin layout changes / absolute symlinks. See inline comment.
nit (style): Empty line at top of tidyUpdatePluginClientCache body + deps destructured twice — easy consolidation.
nit (perf, micro):specialCacheEntriesSet can be hoisted to module scope (it's a fixed two-entry set).
nit (test): Prefer fs.mkdtemp over Date.now() + Math.random() for tmp-dir naming.
Correctness notes I did not flag as issues but worth being aware of
On Linux/macOS, deleting the currently-running CLI's own version directory mid-process is fine (open file handles stay valid). On Windows the rm will fail with EBUSY and is silently logged — the orphan dir will be cleaned up on the next update. Acceptable.
Concurrent brv update runs are prevented by oclif-plugin-update's own file locking, so tidy can't race with an active install.
Security
No new attack surface. spawn('brv restart', {shell: true}) is unchanged from main. All filesystem paths are join(root, name) where name comes from readdir(root), so no traversal vector.
Overall score: 4 / 5
Solid, well-tested PR with a small surface area. Drop to addressing the autoupdate semantics question and the resolver hardening would push it to 5/5; the rest are nits.
• Branch: fix/ENG-2881
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
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.
… to after-update.
Summary
Type of change
Scope (select all touched areas)
Linked issues
Root cause (bug fixes only, otherwise write
N/A)Test plan
User-visible changes
List user-visible changes (including defaults, config, or CLI output).
If none, write
None.Evidence
Attach at least one:
Checklist
npm test)npm run lint)npm run typecheck)npm run build)mainRisks and mitigations
List real risks for this PR. If none, write
None.