Skip to content

fix(tooling): preserve Git hook choices during install - #139461

Merged
steipete merged 1 commit into
mainfrom
codex/fix-prepare-hook-ownership
Sep 5, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/fix-prepare-hook-ownership

Conversation

@steipete

@steipete steipete commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Closes #139449.

What Problem This Solves

Fixes an issue where contributors running dependency installation would have an existing Git hook choice replaced, or a linked checkout would change shared hook settings for its siblings. Private worktree overrides could hide that shared change even while setup reported success.

Why This Change Was Made

Prepare now reads Git's effective core.hooksPath and preserves an existing selection, including inherited and explicitly empty values. Only Git's missing-key result permits initialization, using --worktree so Git owns scope selection. Configuration errors keep the existing nonfatal warning; setup does not retry with a shared write or enable the worktree-config extension.

The command closure replaces two passthrough helpers. Tooling +19/−34 (net −15), tests +207/−18 (net +189), docs +9/−2 (net +7). The existing package lifecycle entrypoint and hook implementation remain unchanged.

User Impact

Installation respects configured hook choices and avoids changing sibling-checkout settings. A fresh single checkout still gets the repository hook. An unconfigured repository with multiple worktrees needs owner-enabled extensions.worktreeConfig for automatic setup; otherwise Git warns and installation continues with hook settings unchanged. The contributor guide explains this existing Git configuration mechanism.

Maintainer disposition of ClawSweeper's P1 merge risk: retain the documented safe skip, its recommended option. This deliberately affects only automatic initialization when no hook path is configured and Git cannot provide private worktree scope. Existing configured paths and fresh single checkouts retain their supported behavior. Falling back to a shared write would recreate the reported sibling mutation; automatically enabling the extension would make a broader Git configuration change. The warning and linked owner-controlled setup instructions make the non-initialization visible and actionable. This disposition resolves the requested decision without a code change.

Evidence

  • Seven real-Git ownership regressions fail against the previous helper. The same permanent test file passes all 15 cases after repair, covering a true single checkout, local/global/empty settings, linked initialization, refusal without private configuration, and shared writes masked by private overrides. A later three-brace style correction preserves all assertions; the final file also passes 15/15.
  • The 17-stage changed-check plan is satisfied: 16 stages passed initially, then the sole test-lint failure was fixed and targeted lint, three-file formatting and all 15 tests passed. This includes script lint and root test typechecking. Independent peer and both managed review passes are clean.
  • Git 2.54's actual config implementation and real-Git scope controls confirm the single-checkout, private-worktree and shared-config refusal branches. Fixtures use isolated configuration and synthetic values; no hook executable runs. No actual Windows or complete package-manager lifecycle execution is claimed, and read-before-write is not atomic against concurrent configuration changes.

The unscoped write dates to 6b83d82 and was preserved by the cross-platform extraction in d21abb8; current main and stable v2026.9.2 contain the same helper. Draft #114287 overlaps these files for a separate optional publication feature and retains the unscoped write. This PR does not incorporate that proposal. Exact-head CI passed 78 jobs (16 skipped). ClawSweeper's completed review found no correctness or security issue and requested the maintainer decision recorded above.

Read the effective hooks path before initializing an unset selection in worktree scope. Preserve inherited and empty settings; let Git refuse shared initialization instead of changing sibling checkout configuration.

Fixes #139449. Seven real-Git regression cases fail before the repair; the final 15-case suite and scoped checks pass. Tooling net -15 LOC.
@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: M maintainer Maintainer-authored PR labels Sep 5, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 5, 2026
@clawsweeper

clawsweeper Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 5, 2026, 6:29 PM ET / 22:29 UTC.

ClawSweeper review

What this changes

Preserve existing Git hook selections during dependency installation, initialize unset selections in worktree scope, and document and test the resulting behavior.

Merge readiness

⛔ Blocked before merge - 1 item remains

This remains a useful, focused repair: current main and the latest release still overwrite hook selections. No introduced correctness defect was found, and the related publication-preflight proposal addresses different behavior.

Priority: P2
Reviewed head: 6574126e1a8592fd03faf0e58d89f7114d102abb

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with meaningful real-Git coverage and clearly documented behavior limits.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The supplied MEMBER author status exempts this PR from the external-contributor gate. The body reports actual helper execution against isolated Git repositories with preserved settings and safe refusal after repair; Windows and complete package-manager lifecycle execution are explicitly unclaimed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied MEMBER author status exempts this PR from the external-contributor gate. The body reports actual helper execution against isolated Git repositories with preserved settings and safe refusal after repair; Windows and complete package-manager lifecycle execution are explicitly unclaimed.
Evidence reviewed 7 items Current main still contains the defect: The preparation helper unconditionally writes core.hooksPath without reading the effective selection or requesting worktree scope.
Latest release remains affected: The helper at v2026.9.2 contains the same unconditional, unscoped configuration write.
Repair and integration boundary: The introduced helper preserves successful configuration reads, initializes only on missing-key status, and retains nonfatal error handling. package.json:1799 invokes this helper through the unchanged prepare entrypoint. The verified test-merge comparison preserves this focused change.
Findings None None.
Security None None.

How this fits together

Source installations invoke a preparation script that configures Git’s local commit hook. That script connects package installation to Git configuration, which determines which hook later runs during commits.

flowchart TD
  A[Dependency installation] --> B[Hook preparation]
  B --> C{Source checkout available?}
  C -->|No| D[Skip setup]
  C -->|Yes| E{Hook selection exists?}
  E -->|Yes| F[Preserve selection]
  E -->|No| G[Ask Git for worktree write]
  G --> H[Configure hook or warn without fallback]
Loading

Before merge

  • Resolve merge risk (P1) - An unconfigured repository with multiple worktrees will now skip automatic hook setup until its owner enables worktree configuration; installation continues with a warning. This intentional behavior is documented and covered by the supplied real-Git scenarios.
Agent review details

Security

None.

PR surface

Tests +189, Docs +7, Other -15. Total +181 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 207 18 +189
Docs 1 9 2 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 1 19 34 -15
Total 3 235 54 +181

Review metrics

Metric Value Why it matters
Ownership scenarios 8 real-Git scenarios Coverage checks configuration bytes as well as effective values, catching shared writes hidden by private overrides.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #139449
Summary: This PR is the candidate repair for the linked configuration-ownership bug.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Retain the documented safe skip (recommended)
    Accept the explicitly described multi-worktree setup change, supported by fresh-checkout and existing-configuration coverage.

Technical review

Best possible solution:

Keep Git responsible for configuration scope, preserve existing selections, and retain the documented warning when safe initialization requires owner-enabled worktree configuration.

Do we have a high-confidence way to reproduce the issue?

Yes: current main’s unconditional Git configuration write establishes the mechanism, and the linked report supplies real-Git before/after observations. This review did not execute the reproduction.

Is this the best way to solve the issue?

Yes: the patch repairs the existing preparation owner using Git’s native lookup and scope rules, without introducing a competing configuration mechanism.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 40ebdadcafa6.

Labels

Label changes:

  • add P2: The repair prevents installation from overwriting contributor hook settings, with a bounded developer-tooling impact.
  • add merge-risk: 🚨 compatibility: Automatic hook initialization now warns and skips in unconfigured multi-worktree repositories without private configuration.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied MEMBER author status exempts this PR from the external-contributor gate. The body reports actual helper execution against isolated Git repositories with preserved settings and safe refusal after repair; Windows and complete package-manager lifecycle execution are explicitly unclaimed.

Label justifications:

  • P2: The repair prevents installation from overwriting contributor hook settings, with a bounded developer-tooling impact.
  • merge-risk: 🚨 compatibility: Automatic hook initialization now warns and skips in unconfigured multi-worktree repositories without private configuration.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied MEMBER author status exempts this PR from the external-contributor gate. The body reports actual helper execution against isolated Git repositories with preserved settings and safe refusal after repair; Windows and complete package-manager lifecycle execution are explicitly unclaimed.

Evidence

What I checked:

  • Current main still contains the defect: The preparation helper unconditionally writes core.hooksPath without reading the effective selection or requesting worktree scope. (scripts/prepare-git-hooks.mjs:53, 40ebdadcafa6)
  • Latest release remains affected: The helper at v2026.9.2 contains the same unconditional, unscoped configuration write. (scripts/prepare-git-hooks.mjs:53, 3928bad9badf)
  • Repair and integration boundary: The introduced helper preserves successful configuration reads, initializes only on missing-key status, and retains nonfatal error handling. package.json:1799 invokes this helper through the unchanged prepare entrypoint. The verified test-merge comparison preserves this focused change. (scripts/prepare-git-hooks.mjs:35, 6574126e1a85)
  • Git dependency contract verified: The patch directly executes Git configuration commands. Git’s get_value returns status 1 when no value exists; its worktree configuration branch selects private configuration, refuses multiple worktrees without the extension, or uses repository configuration for a singleton. Inspected Git v2.54.0 source, especially lines 571 and 897–912. (builtin/config.c:897)
  • Behavioral regression coverage: Read the complete test file. Eight real-Git ownership scenarios inspect effective selections and unchanged configuration bytes, including singleton initialization, local/global/empty selections, private initialization, refusal, and masked shared writes. The captured PR body reports seven before-fix failures and 15 passing final cases; this read-only review did not execute them. (test/scripts/prepare-git-hooks.test.ts:125, 6574126e1a85)
  • Related work and supplied proof: The captured body links the concrete configuration-ownership report at [Bug]: package prepare replaces configured Git hook paths and changes shared worktree config #139449. The supplied context for chore: add opt-in local publication preflight #114287 describes a separate optional publication preflight, not a replacement repair. Source snapshot identity: 21757ff2409bb199a41be2287d92b43e57018b5f2b7a0f9137c0c8fea71982d4. (6574126e1a85)

Likely related people:

  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit 98bb259 into main Sep 5, 2026
145 checks passed
@steipete
steipete deleted the codex/fix-prepare-hook-ownership branch September 5, 2026 23:02
@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 5, 2026
* origin/main: (95 commits)
  perf(build): avoid unrelated gateway artifact scans (#127757)
  fix(update): deliver terminal progress after long updates (#139289)
  fix(ui): show session hover cards for local chat URLs (#139384)
  perf(ui): reuse unchanged transcript key snapshots (#139400)
  fix(ui): make subagent sessions view-only (#139381)
  fix: open agent state on SQLite builds without extensions (#139487)
  perf(skills): detach cached metadata from source strings (#139478)
  fix(ui): show primary user in multi-agent profile hero (#136736)
  perf(sessions): stop decoding the session row four times per SQLite entry patch (#136361)
  refactor(exec): share package-manager option scans (#139482)
  fix(ci): authorize frozen mobile release candidates (#139441)
  fix: avoid session deletion slowdown in large session stores (#139467)
  perf(gateway): reuse node invocation idle timers (#139354)
  fix(auth): preserve selected profiles across plugin scopes (#139413)
  fix(discord): retain voice input until transcription completes (#139484)
  fix(agents): name Gateway storage failures in run-failure copy (#139409)
  fix: keep subagent checks responsive in large session stores (#139450)
  fix(memory): index notes when optional embeddings cannot start (#139463)
  fix: refresh pending approvals when reopening chat (#139457)
  fix(tooling): preserve Git hook choices during install (#139461)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 6, 2026
Read the effective hooks path before initializing an unset selection in worktree scope. Preserve inherited and empty settings; let Git refuse shared initialization instead of changing sibling checkout configuration.

Fixes openclaw#139449. Seven real-Git regression cases fail before the repair; the final 15-case suite and scoped checks pass. Tooling net -15 LOC.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: package prepare replaces configured Git hook paths and changes shared worktree config

1 participant