Skip to content

kit hooks add context-check installs a gate that cannot fail when [context] is absent — no warning, wrong test hint, and no git-hook row in kit status #497

Closed

Description

@sandstream

The gap

kit hooks add context-check installs a pre-push gate that cannot fail when [context] is absent from .kit.toml, says nothing about it at install time, and prints a hint belonging to a different hook. Nothing in kit status reports git-hook state at all, so neither "no gate" nor "a gate that checks nothing" is visible where an operator would look.

context-check is described as: "Block a push when the live CLI context (account/project) does not match .kit.toml [context]. Stops pushes to the wrong org/project." With no [context] block there is nothing to match, and kit context check correctly exits 0 with an informational note — which makes the installed hook a permanent pass.

Measured (6.6.5, macOS, non-root, throwaway repo)

$ git init -q . && printf '[tools]\nnode = "22"\n' > .kit.toml && git add -A && git commit -qm init

$ kit hooks add context-check --non-interactive
kit hooks add context-check  (git pre-push)
──────────────────────────────────────────────────
  ✓ pre-push  installed  1 command(s)

Test by staging a file with a fake credential (e.g. sk_test_AAAAAAAAAAAAAAAAAAAA) and
running git commit — the commit should be blocked.

Two defects visible in that output alone:

  1. No warning that [context] is missing, i.e. that the gate it just installed will never block anything.
  2. The hint is the wrong hook's. Staging a credential and committing has nothing to do with a pre-push context check — that is secret-scan's test recipe, printed verbatim here (and for post-pull-audit too).

Then the gate itself:

$ printf 'refs/heads/main a refs/heads/main b\n' | .git/hooks/pre-push origin file:///tmp/x
$ echo $?
0                     # passes, with no [context] to check

And nothing surfaces it:

$ kit status | grep -iE "hook|context"
  ○ memory hooks  not installed  → run `kit memory install`

kit status reports memory hooks and never git hooks — so a repo with no pre-commit gate, and a repo whose installed pre-push gate is unarmed, both read identically: silent.

Why this matters more than its size

README calls git hooks "the agent-agnostic enforcement floor" — the one that fires in any agent or none. An operator who runs kit hooks add context-check has stated an intent ("stop pushes to the wrong org"), gets a green ✓ installed, and is now less safe than they believe, because the check has no declaration to compare against. Same family as:

The pattern: the mechanism works, and the reader is the weak link.

Proposed

  1. kit hooks add context-check must refuse or warn loudly when [context] is absent — and point at kit context check, which already prints a ready-to-paste block from the live snapshot (that empty-state hint is good; it is just unreachable unless you already know to run it). "Installed" for a gate that cannot fail is a false green.
  2. Per-hook test hints. The install line should tell you how to exercise that hook — a mismatched remote for context-check, a merge for post-pull-audit — instead of secret-scan's recipe for all three.
  3. A git-hook row in kit status / kit check, listing which of the built-in hooks are installed and whether each is armed (context-check installed + no [context] ⇒ warn). Today the only hook row is memory hooks.
  4. Optional but cheap: kit context check exiting 0 with no declaration is right for a read-only command, but the hook path could treat "no declaration" as didNotRun rather than pass, matching kit's rule that coverage which could not run is unknown, not clean.

Related

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions