diff --git a/CLAUDE.global.md b/CLAUDE.global.md index 5db6d62..6f6cc2d 100644 --- a/CLAUDE.global.md +++ b/CLAUDE.global.md @@ -172,8 +172,10 @@ protected base but commit in place on a working branch, never finishing memory-only `chore/*` they created this run), so they branch to `chore/*` via the aiguillage, not the hook allowlist. Deterministic backstops behind the doctrine: the pre-commit hook (blocks -code commits on main/develop; exempts the `.claude/{memory,tasks,audits, -deploy}/` allowlist, `.githooks/`, merges, the root commit), Gitea branch protection on both, and never `--no-verify`. +code commits on main/develop; exempts the +`.claude/{memory,tasks,audits,deploy}/` allowlist, `.githooks/`, merges, +the root commit), Gitea branch protection on both, and never +`--no-verify`. Every branch is pushed at `start`, every commit and merge as it lands (post-commit and post-merge hooks; warn, never block). A branch is deleted only by `finish` or `delete`, local and `origin/` copy alike: never diff --git a/lib/gitflow-aiguillage.md b/lib/gitflow-aiguillage.md index 8f94d61..035073c 100644 --- a/lib/gitflow-aiguillage.md +++ b/lib/gitflow-aiguillage.md @@ -32,9 +32,9 @@ doc reconciliation & curation skills (+ `/refactor`), run OUTSIDE an assistance `/bugfix` `/hotfix` `/ship-feature` a working branch already exists (this check returns WORKING) and the memory commit rides it. The aiguillage only fires when such a skill is invoked directly on `main`/`develop` — i.e. memory IS the work, -with no code branch to follow. That is the leak it closes: the `.claude/` allowlist hook exemption -still lets a *manual* memory commit through on a protected base, but a -skill-driven one now branches to `chore/*` first. +with no code branch to follow. That is the leak it closes: the `.claude/` +allowlist hook exemption still lets a *manual* memory commit through on a protected +base, but a skill-driven one now branches to `chore/*` first. **Integration is human-gated by default** — these flows commit, they do not merge. EXCEPTION: `/capitalize` + `/close` auto-persist their memory-only commit (finish → develop; the lib pushes develop in auto-push mode only) diff --git a/lib/gitflow-test.sh b/lib/gitflow-test.sh index 644de1d..1620f8b 100644 --- a/lib/gitflow-test.sh +++ b/lib/gitflow-test.sh @@ -13,14 +13,14 @@ HERE="$(cd "$(dirname "$0")" && pwd)" # shellcheck source=/dev/null source "$HERE/gitflow.sh" -WORK="$(mktemp -d)"; trap 'rm -rf "$WORK"' EXIT +WORK="$(mktemp -d)" || exit 1; trap 'rm -rf "$WORK"' EXIT PASS=0; FAIL=0 ok() { PASS=$((PASS+1)); printf ' ok %s\n' "$1"; } no() { FAIL=$((FAIL+1)); printf ' FAIL %s\n' "$1"; } chk() { if eval "$2"; then ok "$1"; else no "$1 [ $2 ]"; fi; } -newrepo() { local d="$WORK/$1"; rm -rf "$d"; mkdir -p "$d"; cd "$d" || return 1; git init -q; \ - git config user.email t@t; git config user.name t; \ - git config core.hooksPath /dev/null; } # hooks off during setup +newrepo() { local d="$WORK/$1"; rm -rf "$d"; mkdir -p "$d"; cd "$d" || exit 1; git init -q && \ + git config user.email t@t && git config user.name t && \ + git config core.hooksPath /dev/null || exit 1; } # hooks off during setup hookon() { git config --unset core.hooksPath 2>/dev/null || true; } # use repo default .githooks echo "T1 — pure predicates" diff --git a/lib/memory.sh b/lib/memory.sh index 8cf7689..4076cba 100755 --- a/lib/memory.sh +++ b/lib/memory.sh @@ -428,7 +428,7 @@ _mem_add_locked() { # _mem_path_safe() { # → path, ./-prefixed when awk would take it for # a `var=value` assignment operand and read stdin instead - if [[ "$1" =~ ^[A-Za-z_][A-Za-z0-9_]*= ]]; then echo "./$1"; else echo "$1"; fi + if [[ "$1" =~ ^[A-Za-z_][A-Za-z0-9_]*= ]]; then printf '%s\n' "./$1"; else printf '%s\n' "$1"; fi } memory_add() { # <body-file> <status> <supersedes> diff --git a/lib/tests/cc.test.sh b/lib/tests/cc.test.sh index f24027f..d19b47d 100644 --- a/lib/tests/cc.test.sh +++ b/lib/tests/cc.test.sh @@ -35,7 +35,7 @@ cat > "$FX/bin/claude" <<'EOT' EOT chmod +x "$FX/bin/"* # shellcheck source=lib/tests/claude-stub.sh -. "$ROOT/lib/tests/claude-stub.sh" +. "$ROOT/lib/tests/claude-stub.sh" || exit 1 for c in claude systemd-run dtach; do PATH="$FX/bin:$PATH" stub_first_or_die "$c" "$FX/bin/$c" done diff --git a/lib/tests/claude-stub.test.sh b/lib/tests/claude-stub.test.sh index 65c0813..780751e 100644 --- a/lib/tests/claude-stub.test.sh +++ b/lib/tests/claude-stub.test.sh @@ -2,7 +2,6 @@ # lib/tests/claude-stub.test.sh # Regression for BLK-043 residuals: claude_stub_install must fail closed # (never leave the real claude CLI first on PATH) and survive a relative dir. -# shellcheck disable=SC1090,SC2329 # HELPER override; chmod shadow is called by the helper set -u ROOT="$(cd "$(dirname "$0")/../.." && pwd)" HELPER="${CLAUDE_STUB_LIB:-$ROOT/lib/tests/claude-stub.sh}" @@ -17,8 +16,11 @@ check() { if [ "$2" = "$3" ]; then pass=$((pass+1)); else fail=$((fail+1)); mkdir -p "$WORK/a/work" "$WORK/a/fake" printf '#!/bin/sh\ntouch "%s"\n' "$WORK/a/sentinel" >"$WORK/a/fake/claude" chmod +x "$WORK/a/fake/claude" -err=$( ( chmod() { :; }; PATH="$WORK/a/fake:$PATH" - . "$HELPER"; claude_stub_install "$WORK/a/work" ) 2>&1 >/dev/null ) +mkdir -p "$WORK/a/noop" +printf '#!/bin/sh\nexit 0\n' >"$WORK/a/noop/chmod" +/usr/bin/chmod +x "$WORK/a/noop/chmod" +err=$( PATH="$WORK/a/noop:$WORK/a/fake:$PATH" bash -c \ + '. "$1"; claude_stub_install "$2"' _ "$HELPER" "$WORK/a/work" 2>&1 >/dev/null ) rc=$? check Ta-rc "$rc" 1 case "$err" in *"claude stub not first on PATH"*) m=yes ;; *) m=no ;; esac @@ -27,12 +29,14 @@ check Ta-sentinel-absent "$([ -e "$WORK/a/sentinel" ] && echo yes || echo no)" n # (b) relative dir: the stub still resolves after a cd elsewhere. mkdir -p "$WORK/b/rel" +# shellcheck source=lib/tests/claude-stub.sh got=$( cd "$WORK/b" && . "$HELPER" && claude_stub_install rel \ && cd / && command -v claude ) check Tb-relative-resolves "$got" "$WORK/b/rel/stub/claude" # (c) happy path mkdir -p "$WORK/c" +# shellcheck source=lib/tests/claude-stub.sh out=$( . "$HELPER"; claude_stub_install "$WORK/c" && claude_stub_calls ) check Tc-happy "$out" 0 diff --git a/lib/tests/detect-plan.test.sh b/lib/tests/detect-plan.test.sh index 1ab4b13..82a8be0 100644 --- a/lib/tests/detect-plan.test.sh +++ b/lib/tests/detect-plan.test.sh @@ -14,7 +14,7 @@ check() { if [ "$2" = "$3" ]; then pass=$((pass+1)); else fail=$((fail+1)); # Stub claude: logs every call, never starts a session; fails closed. # shellcheck source=lib/tests/claude-stub.sh -. "$ROOT/lib/tests/claude-stub.sh" +. "$ROOT/lib/tests/claude-stub.sh" || exit 1 claude_stub_install "$WORK" # detect_plan, no .claude.json: pro, no claude call. diff --git a/lib/tests/graphify-gate.test.sh b/lib/tests/graphify-gate.test.sh index c06acb8..8bf87f5 100644 --- a/lib/tests/graphify-gate.test.sh +++ b/lib/tests/graphify-gate.test.sh @@ -4,7 +4,8 @@ set -u LIB="$(cd "$(dirname "$0")/../.." && pwd)/lib/graphify-gate.sh" WORK="$(mktemp -d)" || exit 1; trap 'rm -rf "$WORK"' EXIT pass=0; fail=0 -. "$(dirname "$0")/claude-stub.sh" +# shellcheck source=lib/tests/claude-stub.sh +. "$(dirname "$0")/claude-stub.sh" || exit 1 mkdir -p "$WORK/cs" || exit 1 claude_stub_install "$WORK/cs" check() { if [ "$2" = "$3" ]; then pass=$((pass+1)); else fail=$((fail+1)); diff --git a/lib/tests/memory.test.sh b/lib/tests/memory.test.sh index d25dbb7..6b462f7 100755 --- a/lib/tests/memory.test.sh +++ b/lib/tests/memory.test.sh @@ -689,7 +689,7 @@ done # Stub work dir outside $FIX: the fixture repo's `git add -A` must not # commit the stub. Installed here so earlier cases see the repo unceilinged. # shellcheck source=lib/tests/claude-stub.sh -. "$ROOT/lib/tests/claude-stub.sh" +. "$ROOT/lib/tests/claude-stub.sh" || exit 1 CSW=$(mktemp -d) || exit 1; trap 'rm -rf "$FIX" "$CSW"' EXIT claude_stub_install "$CSW" banner() { (cd "$1" && SESSION_START_OFFLINE=1 bash "$ROOT/hooks/session-start.sh" \ @@ -722,9 +722,10 @@ check T19-assign-body-heading-rc "$?/$(cksum < .claude/memory/learnings.md)" "2/ printf 'clean-eq-body\n' > 'x=1.md' bash "$MEM" add learning --title eq --body-file x=1.md </dev/null >/dev/null 2>&1 check T19b-assign-body-written "$(grep -c '^clean-eq-body$' .claude/memory/learnings.md)" 1 -mkdir 'a=b' && printf '# Decisions\n\n## BDR-001 - legacy\n' > 'a=b/decisions.md' +mkdir 'a=b' +printf -- '---\nformat: 2\ntype: decisions_registry\nentry_prefix: BDR\n---\n\n# D\n\n## BDR-001 - bad\n' > 'a=b/decisions.md' err=$(bash "$MEM" check 'a=b' 2>&1 >/dev/null </dev/null) -check T19c-assign-dir-read "$(printf '%s\n' "$err" | grep -c '^memory: v1: ./a=b/decisions.md$')" 1 +check T19c-assign-dir-read "$(printf '%s\n' "$err" | grep -c '^memory: ./a=b/decisions.md:9: heading shape: ## BDR-001 - bad$')" 1 check no-claude-calls "$(claude_stub_calls)" 0 echo "PASS=$pass FAIL=$fail" diff --git a/lib/tests/push-guard.test.sh b/lib/tests/push-guard.test.sh index 833e71e..50c0bb8 100644 --- a/lib/tests/push-guard.test.sh +++ b/lib/tests/push-guard.test.sh @@ -353,7 +353,7 @@ check T43b-clearance "$(grep -c "does not clear it: the user types \`! git push\ # ── session banner ── # shellcheck source=lib/tests/claude-stub.sh -. "$ROOT/lib/tests/claude-stub.sh" +. "$ROOT/lib/tests/claude-stub.sh" || exit 1 mkdir -p "$WORK/cs" || exit 1 claude_stub_install "$WORK/cs" banner() { # banner <dir> diff --git a/lib/tests/session-digest.test.sh b/lib/tests/session-digest.test.sh index 5b566ba..ceb2c0a 100644 --- a/lib/tests/session-digest.test.sh +++ b/lib/tests/session-digest.test.sh @@ -13,7 +13,7 @@ check() { if [ "$2" = "$3" ]; then pass=$((pass+1)); else fail=$((fail+1)); # Stub claude (BLK-043): a hook run that calls the CLI logs a line here # instead of starting a session that re-runs this hook. # shellcheck source=lib/tests/claude-stub.sh -. "$ROOT/lib/tests/claude-stub.sh" +. "$ROOT/lib/tests/claude-stub.sh" || exit 1 claude_stub_install "$WORK" # mkproj <name> -> path with an empty memory dir