Skip to content

fix(hooks): stdin-JSON input contract + behavioral CI tests · docs(spec): v2 consent-first draft#5

Merged
nfeuer merged 3 commits into
mainfrom
claude/package-differentiation-analysis-pqwpe9
Jul 6, 2026
Merged

fix(hooks): stdin-JSON input contract + behavioral CI tests · docs(spec): v2 consent-first draft#5
nfeuer merged 3 commits into
mainfrom
claude/package-differentiation-analysis-pqwpe9

Conversation

@nfeuer

@nfeuer nfeuer commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Summary

Two things ride on this branch (single-designated-branch session):

1. Fixes — the P0s from the five-persona friction test. The headline: the enforcement layer likely never fired — all three file-guard hooks keyed off $CLAUDE_FILE_PATH (not a documented hook variable) and every uncertainty path exited 0 silently.

  • Hook input contract fixed: require-worktree.sh + new protect-credential-files.sh and autoformat.sh (inline settings logic promoted to scripts) parse the tool input from stdin JSON — jq when available, sed fallback, legacy env var last. Unresolvable input is reported on stderr, never silent. kit.yaml added to the on-main exemption list.
  • secret-scan-diff.sh: push/PR detection moved into the script (a parse failure now scans anyway instead of silently skipping); trunk branch resolved from kit.yaml trunk_branchorigin/HEADmain/master instead of hardcoded main.
  • settings.template.json: all inline hook commands replaced with script calls — removes the jq-or-silently-dead inline secret-scan trigger and the terminal ; true that kit-doctor itself flags.
  • kit-ci: new behavioral test job. Hooks must block (exit 2) on main edits, .env edits, and leaked-secret pushes; must allow worktree edits, exempt files, and non-push commands; and must still block with a broken jq. 11 checks — green in this PR's CI run.
  • kit-update: version-bump regex could never match (stray ]) and printed success anyway — fixed; a no-op rewrite now errors.
  • pre-pr step 13: dangling spec-check reference → the spec-drift-checker agent with an explicit N/A condition.
  • prune-merged-worktrees: default recency guard 30 → 120 min.
  • Removed committed templates/__pycache__; gitignored .claude/scratch/; docs/followups.md created with the remaining persona findings as PT1–PT11.
  • kit_version 1.3.0 → 1.3.1.

2. Draft v2 design spec (SPEC.md) — under adversarial review. The consent-first direction: priced skill catalog (cost/protects/requires frontmatter), per-gate mode map (off|suggest|enforce), three-act init interview with install-time pruning, two-phase pre-pr, chaining in place of the 1% rule, earned enforcement with a CI-side ratchet backstop, substrate ledger, stack tiers. Two reviewer agents (design-coherence/persona-fidelity + implementability) are attacking it now; their findings land as follow-up commits on this PR before merge.

Spec citation

  • Establishes the spec: SPEC.md §1–§13 (draft). Fixes restore behavior the README already claimed.

What was tested

  • All 11 behavioral hook checks pass locally and in this PR's CI run.
  • kit-ci static checks pass: YAML parses, settings.template.json valid JSON, bash -n clean on all six hooks.
  • Coverage ratchet: N/A

Risk and rollback

Risk: low-medium — hook behavior changes are the point; the new CI job proves blocking works. Legacy $CLAUDE_FILE_PATH still honored as fallback. SPEC.md is documentation only.

Rollback: revert the PR.

Docs

  • README hooks tree updated; bootstrap formatter note updated; SPEC.md added
  • Changelog entry — generated at next release
  • Design directions tracked in docs/followups.md (PT1–PT11) + SPEC.md

Follow-ups

  • New follow-ups: PT1–PT11 in docs/followups.md (created the kit's live log)
  • Existing follow-ups closed: none

🤖 Generated with Claude Code

https://claude.ai/code/session_01LxEwyqF1KjEPpQKqM5tSrv

claude added 2 commits July 6, 2026 16:48
…I tests

Five-persona friction testing found the enforcement layer likely never
fired: all three file-guard hooks keyed off $CLAUDE_FILE_PATH, which is
not a documented hook variable, and every uncertainty path exited 0
silently. Fixes:

- require-worktree.sh, new protect-credential-files.sh and autoformat.sh:
  parse tool input from stdin JSON (jq, sed fallback, legacy env var
  last); unresolvable input is reported on stderr, never silent.
  kit.yaml added to the on-main exemption list.
- secret-scan-diff.sh: push/PR detection moved into the script (parse
  failure scans anyway instead of silently skipping); trunk branch read
  from kit.yaml trunk_branch -> origin/HEAD -> main/master instead of
  hardcoded main.
- settings.template.json: all inline hook logic replaced with script
  calls; removes the jq-or-silently-dead inline command and the
  terminal '; true' kit-doctor itself flags.
- kit-ci: new behavioral test job — hooks must BLOCK (exit 2) on main
  edits, .env edits, and leaked-secret pushes, and must allow worktree
  edits, exemptions, and non-push commands, including with jq broken.
  All 11 checks verified locally.
- kit-update: version-bump regex could never match (stray ']') and
  printed success anyway — fixed, and no-op rewrites now error.
- pre-pr step 13: dangling 'spec-check' skill reference -> the
  spec-drift-checker agent, with an explicit N/A condition.
- prune-merged-worktrees: default recency guard 30 -> 120 min so live
  sessions waiting on CI/review don't get pruned by a sibling session.
- Remove committed templates/__pycache__; gitignore .claude/scratch/.
- docs/followups.md: remaining persona-test findings filed as PT1-PT11.
- kit_version 1.3.0 -> 1.3.1

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LxEwyqF1KjEPpQKqM5tSrv
…iew)

Canonical spec for the v2 direction: priced skill catalog (cost/protects/
requires metadata), per-gate mode map (off|suggest|enforce), three-act
init interview with install-time pruning, two-phase pre-pr, chaining in
place of the 1% rule, earned enforcement with a CI-side ratchet backstop,
substrate ledger, and explicit stack tiers. Cites the PT1-PT11 persona
findings. Draft — review findings will land as follow-up commits.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LxEwyqF1KjEPpQKqM5tSrv
@nfeuer nfeuer changed the title fix(hooks): stdin-JSON input contract, no silent no-ops, behavioral CI tests fix(hooks): stdin-JSON input contract + behavioral CI tests · docs(spec): v2 consent-first draft Jul 6, 2026
… reviews

Blockers fixed: prototype default map keeps deterministic-protective and
CI-backed gates enforced at every strictness level (v1 migration claim now
true); doctrine reconciliation (README positioning, PROFILE/pre-pr
security-review reclassification) scheduled in the same release as the
mode map; unattended-session consent defined (run enforce, skip-and-log
suggest, pre-consent via kit.yaml); suggestions gain a MUST-surface
obligation so the suggest tier can't silently collapse to off.

Majors: llm-app preset re-enforces prompt-regression/eval (target-persona
overshoot); ratchet-up counts CI-side findings so avoidance can't suppress
it; ratchet-down proposes quieter-before-off, never off for CI-backed
gates, counters in a git-ignored per-clone ledger with defined record
format and windows; mode resolution materialized at init (skills read one
key, no per-skill precedence); full gate-key enumeration; hook mode/parse
contract; gates.triggers glob map; declined: consumers enumerated
(dispatcher, kit-update, /kit-menu); catalog generator + kit-ci drift
check; PT10 hash manifest and Tier-0 de-Python pulled into v2.0-alpha/
v2.0a; substrate dialects pinned; PT5/PT9 restored as §11; PT8 explicitly
deferred; v2.0 split into a/b to avoid a ~50-file big-bang.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LxEwyqF1KjEPpQKqM5tSrv
@nfeuer
nfeuer merged commit 6c2c391 into main Jul 6, 2026
2 checks passed
@nfeuer
nfeuer deleted the claude/package-differentiation-analysis-pqwpe9 branch July 6, 2026 19:45
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