← Back to Pull requests

fix(hooks): mark a pre-sourcing Trunk chain as outdated #31

Open
unknown opened this pull request with 432 lines diff across 5 files
View on GitHub
unknown unknown commented on Nov 10, 2026 23:57 UTC
Author

Fork-only PR so the review bots can run on the exact head that would go on upstream cli pull request 3051 (plain text on purpose, so nothing links there). Nothing is opened or updated upstream from this. Base is fork branch base-main-1ffd771ed, which equals upstream main 1ffd771ed.

This is Soph's requested follow-up on that pull request: existing installs should pick up the new Trunk chain without the user running entire enable again.

What it does

hookStateIn treated an already-chained hook as Current because it carries Entire's marker, so ReinstallGitHooks left the pre-sourcing chain in place. After an upgrade, Trunk still saw the callback <hook>.pre-entire and exited 2 on every commit and push.

When a hook carries Entire's marker, chains to <hook>.pre-entire, does not contain the sourcing branch (shellQuote(trunkHookCallback)), and that backup contains the trunkHookCallback line as a whole line (the same match the chain's grep -qxF uses), it now reports Outdated. EnsureSetup then rewrites the chain on the next agent turn.

The check is Trunk-specific and only reads the backup for hooks that already chain. A broad "any old-format chain is Outdated" check would rewrite a hook that carries Entire's marker without a backup, and would discard lines users added.

The new test plants the pre-sourcing chain with Trunk's launcher as the backup, asserts CheckGitHookState reports Outdated, runs ReinstallGitHooks, and checks that pre-push reaches Trunk as pre-push. Extra cases pin that a non-Trunk backup, a callback mentioned only in a comment, and the current chain stay Current, and that a backup that is a symlink to Trunk's launcher still reads Outdated.

Commits: ffc689652 (source the launcher under the hook's own name), aaeb04aa9 (run it with /bin/bash --norc), f750a98b4 (mark the old chain Outdated), f6540dc4c (bound the backup read; skip FIFO/device targets), d27e8edda (bound the in-root read too; move the FIFO test behind a unix build tag so Windows compiles).

Checks on head d27e8edda (Go 1.27.3, git 2.47.3)

  • TestReinstallGitHooks_Pre3051TrunkChainIsOutdated and the "symlinked Trunk launcher" case fail before the Outdated check (CheckGitHookState was Current) and pass after it.

  • The FIFO-backup case hung for the full 2s timeout before the bounded read and now returns Current immediately.

  • go build ./..., go vet ./..., gofmt -l -s of the changed files: clean.

  • go test ./cmd/entire/cli/strategy/ -run 'Hook|Trunk|GitHook|Reinstall|Chain' passes, including with -race.

  • go test ./cmd/entire/cli/ -run 'Hook|Doctor' passes.

  • go test -tags=integration ./cmd/entire/cli/integration_test/ -run 'Hook|Chain|Overwrite|LocalDev' passes.

  • golangci-lint run ./... (v2.15.0) reports 0 issues.

  • The complexity gate reports no new or worsened function over 30.

  • Windows go vet and go test -c of the strategy package succeed.
  • The full strategy package also has two pre-existing reftable failures on this box (TestLocalRefReads_ReftableProcessCount, TestReplacedCommits_ReftableRepository): git refs migrate exits 255 with "migrating reflogs is not supported yet" on git 2.47.3. They fail the same way without this change.

    The commits have no Entire-Checkpoint trailer. The first commit's message still contains the original closing keyword from when the upstream pull request was opened; this follow-up commit does not add another.

    Diff: 432 lines (+324 / -108) across 5 files Reviewer: greptile-apps[bot] Review duration: 15m
    All Vouch review confidence checks passed
    Residual risk 0.26 = Change Risk (0.45) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 432 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: 100% · Reviewer familiarity: 35%
    42%
    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.363
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #31"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% 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.2% (MEDIUM) · Higher = larger blast radius
    45.2%
    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: 43.0% · Lower = rushed or shallow review
    43.0%
    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: 25.8% · Safe to merge
    25.8%
    Repository