Repository navigation
fix(wrapper): point the machine-wide wrapper at the installed kit, not at whoever wrote it - #510
Merged
Merged
Conversation
…t at whoever wrote it ~/.kit/bin/kit is what every kit hook in every repo execs, and ensureKitWrapper() baked in process.argv[1]. So one `kit hooks add` run as `node dist/cli.js …` from a development checkout aimed the whole machine's enforcement floor at …/dist/cli.js — a path `npm run build` deletes on its first step. It happened here, and the failure landed in an unrelated repo: PreToolUse:Bash hook error Failed with non-blocking status code: [kit] hook cannot start: kit CLI entrypoint missing: …/kit-public/dist/cli.js The hook died and the session continued UNGATED. Four properties made it worse than a stale path: a repo-local command had a machine-wide effect; a dev build is transient by design; it failed open; and it was silent in both directions. Each is addressed. chooseWrapperEntry() is pure and prefers an INSTALLED kit over a checkout, probing the usual global bin dirs. KIT_WRAPPER_ALLOW_DEV=1 still wins over that preference — an explicit dev pin must not be silently overridden, which the first implementation got wrong until the table test caught it. A checkout with no install to fall back on is written but LOUD: refusing outright would leave the hooks with no wrapper at all, which is worse than a fragile one. The result line now names the entrypoint instead of only saying "refreshed". `kit check`'s git hook floor row also judges the wrapper, since every hook resolves through it: a missing entrypoint fails high (every hook on the machine is dead, and it fails open), an entrypoint inside a git working tree warns (it works until the next build), an unmanaged file at that path is never claimed. KIT_WRAPPER_ALLOW_DEV is registered in `kit config knobs`, marked dangerous, and KIT_TOOL_LATEST_TTL_H is registered too — it had been missing from that surface since it was introduced, which is the same class of gap as the rest of this arc. Closes #509 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
✅ Docker image built successfully
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #509.
What went wrong
~/.kit/bin/kitis what every kit hook in every repo execs. It was written with whatever entrypoint happened to be running:So one
kit hooks addrun asnode dist/cli.js …from a development checkout aimed the whole machine's enforcement floor at…/kit-public/dist/cli.js— a pathnpm run builddeletes on its first step (clean-dist.mjs). It happened here, and the failure landed in an unrelated repo:The hook died and the session continued ungated.
Four properties made it worse than a stale path, and each one is addressed:
kit checknow fails high when the wrapper's entrypoint is missingThe choice, and its one deliberate exception
chooseWrapperEntry()is pure and injectable, so every branch is a table row rather than a machine state:KIT_WRAPPER_ALLOW_DEV=1npm i -g sandstream-kit)null— no wrapper written, rather than a path inventedThe third row is the judgement call: refusing outright would leave the hooks with no wrapper at all, which is worse than a fragile one. So it writes and says so.
The gate reports it
The
git hook floorrow (#496/#497) reported the hook directory; the wrapper is the other half of the same question, since every hook resolves through it.judgeWrapper():Knobs
KIT_WRAPPER_ALLOW_DEVis registered inkit config knobs, marked dangerous.KIT_TOOL_LATEST_TTL_Hwas missing from that surface since it was introduced yesterday and is now registered too — a documented knob thatkit config knobsdoes not list is the same class of gap as the rest of this arc.Tests
src/kit-wrapper-entry.test.ts— 14:chooseWrapperEntrybranches above, including thatallowDevbeats the installed-kit preference (the first implementation had that ordering wrong, caught by the table)pathInWorkingTreefinds a.gitabove a path and says no for an install layoutdescribeWrapper/judgeWrapperagainst real temp homes: absent wrapper → skip; an unmanaged file at that path → skip, never claimed; a missing entrypoint → fail high with the ungated-sessions wording; an entrypoint inside a real.gittree → warn; an installed entrypoint → pass, namedVerification on this machine
The wrapper was regenerated from the installed kit before this change, as the workaround:
and verified by moving the checkout's
dist/aside —~/.kit/bin/kit --versionstill answered. With this change, the same regeneration run from a checkout produces the installed path by default rather than needing the workaround.npm test: 4429 tests, 0 fail, 0 skipped (macOS, non-root)eslint src: 0 errors ·prettier --check "src/**/*.ts"clean ·kit self-audit: 16 rules, 0 fail, 0 warnNot in this change
Failing closed when the wrapper cannot start (issue proposal 5). A broken wrapper blocking every tool call is its own outage, and the useful half — making it loud rather than a single non-blocking line — belongs in the harness contract, not in kit's wrapper.
🤖 Generated with Claude Code