Skip to content

feat(hooks): managed git hooks keep the index fresh on commit/checkout/merge - #113

Merged
tachyon-beep merged 1 commit into
release/1.5.0from
feat/managed-git-hooks
Aug 7, 2026
Merged

feat(hooks): managed git hooks keep the index fresh on commit/checkout/merge#113
tachyon-beep merged 1 commit into
release/1.5.0from
feat/managed-git-hooks

Conversation

@tachyon-beep

Copy link
Copy Markdown
Collaborator

Summary

Closes the mid-session index-drift gap (design ratified in-session): the SessionStart hook already spawns a single-shot detached analyze when the index is stale, but commits/branch switches/merges mid-session drifted until the next session start. This adds warpline-pattern managed git hooks that trigger the same machinery at the moment drift is born.

What's in it

  • loomweave hook git-sync --path . — snapshot → should_trigger_background_analyze (refresh-not-bootstrap: present-but-stale only) → existing detached, advisory-lock-deduped analyze spawn. Silent, exit 0 always.
  • GIT_* env stripping in spawn_detached_analyze — git hooks export GIT_DIR/GIT_INDEX_FILE/GIT_WORK_TREE; inheriting them would repoint the analyze's own git invocations (clarion-9202f4acec family). Also applied to the hooks_dir resolution probe.
  • git_hooks module — managed block (timeout 30, || true, never blocks git) merged into post-commit/post-checkout/post-merge at git rev-parse --git-path hooks (honours core.hooksPath; linked worktrees share hooks while --path . keeps per-worktree stores correct). Cede discipline throughout: foreign bytes preserved verbatim, block inserted before a trailing exit line (warpline's post-commit ends exit 0 — appending would be dead code), stale block replaced in place, unbalanced markers refused, byte-for-byte no-op when current.
  • Install + doctor wiringinstall --hooks installs them (graceful note when not a git repo); both doctor surfaces report hook.git_sync with Present/Stale/Missing/NoGitDir. Missing/stale is a warning, not a gate-failing problem — it's a freshness enrichment, and projects installed before git init must not start failing doctor.

Testing

  • 7 unit tests: fresh install (executable, shebang, block), insert-before-trailing-exit with warpline-block byte preservation, append for git-lfs-style hooks, byte-for-byte idempotent reinstall, stale-block in-place replacement, unbalanced-marker refusal, non-git no-op.
  • 1 doctor integration test: warning → --fix → fixed → ok lifecycle.
  • Full floor green: fmt, clippy -D warnings, build, nextest 2323, doc -D warnings, deny.

Closes clarion-1d688cdddd.

🤖 Generated with Claude Code

…t/merge

The SessionStart hook already heals a stale index with a single-shot
detached background analyze, but drift born mid-session (commits, branch
switches, merges) waited for the next session start. Close that gap:

- New `loomweave hook git-sync --path .`: loads the snapshot and, only for
  a present-but-stale index (refresh, not bootstrap), spawns the existing
  detached lock-deduped analyze. Silent, always exits 0 — safe under
  `|| true`; a hook must never block git.
- `spawn_detached_analyze` now strips GIT_* env from the child: git hooks
  export GIT_DIR/GIT_INDEX_FILE/GIT_WORK_TREE, which would repoint or
  poison the analyze's own git invocations (clarion-9202f4acec family).
- New git_hooks module installs a managed block (fail-soft: `timeout 30`
  + `|| true`) into post-commit/post-checkout/post-merge under
  `git rev-parse --git-path hooks` (honours core.hooksPath and linked
  worktrees; `--path .` keeps per-worktree stores correct). Merge follows
  the cede discipline: foreign content byte-for-byte preserved, block
  inserted before a trailing `exit` line (warpline's post-commit ends
  `exit 0`), stale blocks replaced in place, unbalanced markers refused.
- Wired into `install --hooks` and both doctor surfaces as `hook.git_sync`
  with Present/Stale/Missing/NoGitDir classification; missing/stale is a
  WARNING (freshness enrichment, not a correctness gate) and --fix repairs.

Closes clarion-1d688cdddd.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 7, 2026 23:03
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@tachyon-beep
tachyon-beep merged commit a1c380f into release/1.5.0 Aug 7, 2026
5 of 6 checks passed
@tachyon-beep
tachyon-beep deleted the feat/managed-git-hooks branch August 7, 2026 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants