← Back to Pull requests

Add wt.sh to papercuts: squash-merge-aware done + one worktree per session (R-GIT-01 c) #33

Open
unknown opened this pull request with 439 lines diff across 5 files
View on GitHub
unknown unknown commented on Nov 02, 2026 13:08 UTC
Author

Why


Mike ruling 2026-11-02: the git worktree helper wt.sh (until now only at /home/box/shared/git-worktree/wt.sh, not in any repo) belongs in papercuts, next to R-GIT-01 "Fleet git hygiene".

What


  • scripts/wt.sh (matches scripts/papercut), copied from the box and then changed:

  • - Squash-merge fix: before done keeps a worktree for "unpushed commits", it asks gh pr list --head <branch> --state merged. A merged PR (squash, rebase, or merge) counts as done, so the worktree is removed and the local branch is deleted. If gh is missing or errors, the old ancestry-only behavior applies.
    - R-GIT-01(c): one worktree per session. Session = $WT_SESSION if set, else sid-<unix session id> of the caller. get records the claim in $WT_ROOT/sessions/<session>.wt. A second get for a different repo or branch is refused while the claimed worktree exists. Re-getting the same repo+branch returns the existing path. done releases the claim, and a claim whose worktree is gone is cleared automatically. New wt.sh session subcommand prints the claim.
    - Header documents the rules, including never running pull --rebase --autostash (wt.sh never does).
  • tests/wt_test.sh: runs against a local bare origin with a stubbed gh. Covers the per-session claim and refusal, reuse, release on done, keeping an unmerged worktree, removing a squash-merged one, and the absence of autostash. Wired into CI.

  • Docs: SKILL.md and skills/papercuts/SKILL.md (kept in parity) G-c, the kaizen skill, and the REQUIREMENTS R-GIT-01 row now point to scripts/wt.sh and define "session".
  • Follow-up after merge (not done here)


    /home/box/shared/git-worktree/wt.sh is untouched. After merge it should become a symlink to, or a thin wrapper execing, this repo's scripts/wt.sh, so there is one copy.

    Verification


    bash tests/wt_test.sh passes locally. CI runs it.

    <!-- CURSOR_SUMMARY -->
    ---

    [!NOTE]

    Medium Risk

    New shared git workflow tooling can leave or remove worktrees incorrectly if gh/fetch behavior diverges from reality, though CI behavior tests and conservative KEEP paths limit blast radius.

    > Overview

    Adds scripts/wt.sh as the in-repo canonical fleet worktree helper (R-GIT-01 G-c), replacing informal references to a box-only wt.sh. It uses shared bare clones under WT_ROOT, exposes get / done / list / session, and enforces one worktree per session via $WT_ROOT/sessions/<session>.wt (session = $WT_SESSION or Unix SID): re-get of the same repo+branch reuses the path; a second branch/repo in the same session is refused until done.

    > done now treats squash/rebase merges as finished work: if local commits are not on origin but gh reports a merged PR for the branch, it still removes the worktree and deletes the local branch; dirty or truly unpushed/unmerged trees are kept.

    > tests/wt_test.sh exercises per-session claims, reuse, release, KEEP vs squash-merged removal, and no autostash; CI adds bash -n scripts/wt.sh and runs those tests. REQUIREMENTS R-GIT-01, papercuts G-c (root + skills/papercuts/SKILL.md), and papercuts-kaizen now point at scripts/wt.sh and document session semantics.

    > <sup>Reviewed by Cursor Bugbot for commit a536d813cdabf438dba79902a105ea95b4d2b8de. Bugbot is set up for automated code reviews on this repo. Configure here.</sup>

    <!-- /CURSOR_SUMMARY -->

    Diff: 439 lines (+329 / -110) across 5 files Reviewer: claude[bot] Review duration: 10m
    All Vouch review confidence checks passed
    Residual risk 0.25 = Change Risk (0.45) × (1 − Review Confidence (0.45)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 439 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 95% · Reviewer familiarity: 35%
    45%
    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.364
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #33"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 45.5% 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: 45.3% (MEDIUM) · Higher = larger blast radius
    45.3%
    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: 45.5% · Lower = rushed or shallow review
    45.5%
    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: 24.7% · Safe to merge
    24.7%