← Back to Pull requests

fix(skills): survive read-only installed dirs in hub install/uninstall #139904

Open
unknown opened this pull request with 479 lines diff across 5 files
View on GitHub
unknown unknown commented on Oct 16, 2026 13:34 UTC
Author

What does this PR do?

hermes skills update aborted the whole run with PermissionError when an installed skill directory was read-only (r-xr-xr-x — restored backups, mode-preserving copies, Nix/deb-sourced trees): the plain shutil.rmtree in install_from_quarantine() raised, and every skill queued after the failing one was skipped. uninstall_skill() crashed the same way.

This adds a small _rmtree_force() helper in tools/skills_hub_install.py: on unlink failure it makes the failing path and its parent writable (owner rwx) and retries, mirroring the bundled-sync precedent skills_sync._rmtree_writable (#34860, #34972). It is not imported from skills_sync because that helper's scope guard resolves the root through the sync module's own globals, which the hub paths do not share. Both hub call sites already validate their target with _resolve_lock_install_path() / _check_install_target() before deleting, so the helper adds no scope guard of its own.

Related Issue

Fixes #139890

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • Changes Made

  • tools/skills_hub_install.py: new _rmtree_force() (chmod-and-retry rmtree); install_from_quarantine() and uninstall_skill() now use it instead of bare shutil.rmtree.

  • tests/tools/test_skills_hub_readonly_install.py (new): regression test. Kept in its own topical file because test_skills_hub.py is over the FILE_LINES target (2186 on main) and may only go down.
  • How to Test

    1. On main, create an installed skill copy with read-only modes (chmod 555 dir, chmod 444 files) and run hermes skills update — Observed result: PermissionError from install_from_quarantine(), subsequent skills skipped.
    2. With this branch: python -m pytest tests/tools/test_skills_hub_readonly_install.py -q — 1 passed. Reverting only tools/skills_hub_install.py to main makes it fail with PermissionError (fail-first verified).
    3. Full related suites: python -m pytest tests/tools/test_skills_hub.py tests/tools/test_skills_sync.py tests/hermes_cli/test_skills_hub.py tests/tools/test_pr_6656_regressions.py tests/tools/test_skills_hub_readonly_install.py -q — 173 passed, 1 skipped.
    4. python scripts/check --only ruff --only health --base upstream/main — ok (0 blocking, 0 advisory).

    Checklist

    Code

  • I've read the Contributing Guide

  • My commit messages follow Conventional Commits

  • I searched for existing PRs to make sure this isn't a duplicate

  • My PR contains only changes related to this fix/feature (no unrelated commits)

  • I've run pytest tests/ -q and all tests pass. I ran the affected files, not the full suite.

  • python scripts/check passes (the blocking lint and code-health checks CI runs)

  • I've added tests for my changes

  • I've tested on my platform: macOS 15 (arm64)
  • Documentation & Housekeeping

  • I've updated relevant documentation — N/A (internal deletion detail, docstring on the helper)

  • I've updated cli-config.yaml.example if I added/changed config keys — N/A

  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — N/A

  • I've considered cross-platform impact: os.chmod clears the Windows read-only attribute for S_IRWXU, and the retry only widens what the already-validated target may do. Verified on macOS; the read-only-dir mechanism is POSIX-specific, Windows takes the plain-success path.

  • I've updated tool descriptions/schemas if I changed tool behavior — N/A
  • The fix and test are adapted from the patch attached to #139890 by @hermes-jeffrolc (co-authored on the fix commit).

    Diff: 479 lines (+359 / -120) across 5 files Reviewer: PRATHAMESH75 Review duration: 69781m
    All Vouch review confidence checks passed
    Residual risk 0.29 = Change Risk (0.53) × (1 − Review Confidence (0.45)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.53 · 479 lines diff across 5 files
    0.53
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    44%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.369
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #139904"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 44.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52.8% (MEDIUM) · Higher = larger blast radius
    52.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 44.7% · Lower = rushed or shallow review
    44.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 29.2% · Safe to merge
    29.2%