Skip to content

cli: install git→kai import hooks by default; milestone bridge stays opt-in#37

Merged
jschatz1 merged 2 commits into
mainfrom
bridge/default-auto-import
Jul 11, 2026
Merged

cli: install git→kai import hooks by default; milestone bridge stays opt-in#37
jschatz1 merged 2 commits into
mainfrom
bridge/default-auto-import

Conversation

@jschatz1

Copy link
Copy Markdown
Member

Answers "should we default to git bridge?" by splitting the two directions the bridge bundled behind one opt-in:

git→kai import: now default ON

The post-commit/merge/checkout/rewrite hooks (importing commits as snapshots) install on plain kai init, gated by new config bridge.auto_import (default true; false both skips installation and makes kai bridge import a no-op).

Why this is the right default:

  • This direction never writes to git — it only keeps the graph current. With drift now surfaced everywhere (v0.35.0), every non-kai commit produces stale-suspect annotations the user must clear by hand; default hooks make those effectively never appear.
  • Precedent: init has always installed pre-commit/pre-push unconditionally.
  • It's safe now because of the drift machinery: the hook import runs in a backgrounded subshell, so git commit latency is unchanged (measured: bare commit 30ms; with kai hooks ~0.77s, all of it the pre-existing pre-commit hook — the import adds ~a fork). A lost import self-heals via the watch daemon or inline catch-up.
  • post-rewrite buffers stdin before backgrounding (git closes the pipe when the hook exits).
  • Hook version bumped v5→v6 so kai doctor --fix rolls existing installs forward.

kai→git milestones: stays opt-in

kai init --git-bridge keeps its sentinel and now means only this direction. Kai must not author commits in the user's git history by default.

Also fixed: test suite was creating real repos on kaicontext.com

The runInit tests never set --no-remote, so a logged-in developer's local go test ./cmd/kai/ silently signed up temp-dir-named repos (e.g. jschatz1/001) and pushed to them on every full run. All init tests now force initNoRemote.

Verified

Plain kai init --no-remote installs all four import hooks; kai bridge status reports the milestone direction disabled; commit latency measured unchanged; a plain git commit converges the graph in the background within seconds. New tests pin the default-on/opt-out gating, the backgrounding, and the stdin buffering. Full cmd/kai + internal/config suites green.

🤖 Generated with Claude Code

jschatz1 added 2 commits July 11, 2026 14:40
…opt-in

The bridge bundled two directions behind one opt-in. Split them:

- git→kai (post-commit/merge/checkout/rewrite hooks importing commits
  as snapshots) is now on by default, gated by bridge.auto_import
  (default true). This direction never writes to git; it is what keeps
  the graph from drifting, and without it every non-kai commit now
  surfaces staleness annotations the user must clear by hand. Precedent
  already existed: init installs pre-commit/pre-push unconditionally.
- kai→git (milestones become commits) keeps the bridge-enabled sentinel
  and stays opt-in via kai init --git-bridge — kai must not author
  commits in the user's history by default.

The hook imports now run in a backgrounded subshell so git returns
immediately (measured: the import adds ~0 to commit latency; a lost
import self-heals via the watch daemon or inline catch-up, which is
what makes defaulting this on safe now). post-rewrite buffers stdin
before backgrounding — git closes the pipe when the hook exits. Hook
version bumped to v6 so doctor --fix rolls existing installs forward.

Also: init tests now force --no-remote — a logged-in developer running
the suite was silently signing up temp-dir-named repos on
kaicontext.com on every full test run.
@kaicontext

kaicontext Bot commented Jul 11, 2026

Copy link
Copy Markdown

🔍 Kai review

Note

Reviewing this change… The verification result will appear here shortly.

@jschatz1 jschatz1 merged commit 5550694 into main Jul 11, 2026
5 checks passed
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.

1 participant