← Back to Pull requests

cmd/limactl: remove subdirectories in factory-reset #5899

Open
unknown opened this pull request with 229 lines diff across 2 files
View on GitHub
unknown unknown commented on Nov 27, 2026 12:58 UTC
Author

What This PR Changes

uses os.RemoveAll instead of os.Remove in factoryResetAction (cmd/limactl/factory-reset.go) so non-empty instance subdirectories (swtpm/, sock/, cidata/) are cleaned up during limactl factory-reset, while still preserving lima-version, protected, vz-identifier, and .yaml/.yml files.

added a regression test in cmd/limactl/factory-reset_test.go.

Linked Issue (Required in most cases)

N/A (small fix: 1 line in cmd/limactl/factory-reset.go + unit test in cmd/limactl/factory-reset_test.go)

How I Tested This

environment: Linux Mint 22.3 (x86_64), upstream/master (35e17bd8)

go test -v ./cmd/limactl -run TestFactoryResetRemovesSubdirectories
# fails before the fix (remove .../swtpm: directory not empty), passes after

go test -race ./cmd/limactl/...
# ok  github.com/lima-vm/lima/v2/cmd/limactl  1.920s

GOOS=windows go test -c ./cmd/limactl/... -o /dev/null
golangci-lint run ./cmd/limactl/...
# 0 issues.
make ltag editorconfig-checker nobin
make

<img width="866" height="559" alt="image" src="https://github.com/user-attachments/assets/34d2e6a8-68b8-4965-96a8-def8d238582c" />

verified with real limactl factory-reset (LIMA_HOME=$(mktemp -d), instance with populated swtpm/, sock/, cidata/ subdirs):

  • before (35e17bd8): logged ERRO[0000] remove .../cidata: directory not empty, .../sock: directory not empty, .../swtpm: directory not empty, leaving all three directories behind.

  • after (bdb062b0): removed cidata, sock, and swtpm with zero errors while keeping cloud-config.yaml, lima-version, and lima.yaml.
  • not tested: macOS (vz / vz-aux / vz-efi — GOOS=darwin requires macOS vz cgo SDK) and Windows wsl2 VM runs.

    AI Usage

    Assisted-by: Antigravity

    Diff: 229 lines (+171 / -58) across 2 files Reviewer: AkihiroSuda Review duration: 2402m
    All Vouch review confidence checks passed
    Residual risk 0.20 = Change Risk (0.37) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.37 · 229 lines diff across 2 files
    0.37
    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%
    46%
    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
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.325
    Real PR Conversation Timeline
    1 comments
    "Review active on #5899"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.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: 37.0% (MEDIUM) · Higher = larger blast radius
    37.0%
    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: 46.7% · Lower = rushed or shallow review
    46.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: 19.7% · Safe to merge
    19.7%
    Repository