fix(tests): gate round, fail-closed sources and gitflow-test mktemp
gitflow-test aborts on a failed mktemp or newrepo before its reset --hard; helper sources exit on failure; no lint suppression left; T19c reads a real registry; doctrine rewrapped.
This commit is contained in:
1 parent
c5bd0f8312
commit
7ca6b18f08
11 files changed
+29
-21
No files matched your search
+4
-2
@@ -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/*`
|
memory-only `chore/*` they created this run), so they branch to `chore/*`
|
||||||
via the aiguillage, not the hook allowlist.
|
via the aiguillage, not the hook allowlist.
|
||||||
Deterministic backstops behind the doctrine: the pre-commit hook (blocks
|
Deterministic backstops behind the doctrine: the pre-commit hook (blocks
|
||||||
code commits on main/develop; exempts the `.claude/{memory,tasks,audits,
|
code commits on main/develop; exempts the
|
||||||
deploy}/` allowlist, `.githooks/`, merges, the root commit), Gitea branch protection on both, and never `--no-verify`.
|
`.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
|
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
|
(post-commit and post-merge hooks; warn, never block). A branch is deleted
|
||||||
only by `finish` or `delete`, local and `origin/` copy alike: never
|
only by `finish` or `delete`, local and `origin/` copy alike: never
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ doc reconciliation & curation skills (+ `/refactor`), run OUTSIDE an assistance
|
|||||||
`/bugfix` `/hotfix` `/ship-feature` a working branch already exists (this check
|
`/bugfix` `/hotfix` `/ship-feature` a working branch already exists (this check
|
||||||
returns WORKING) and the memory commit rides it. The aiguillage only fires when
|
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,
|
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
|
with no code branch to follow. That is the leak it closes: the `.claude/`
|
||||||
still lets a *manual* memory commit through on a protected base, but a
|
allowlist hook exemption still lets a *manual* memory commit through on a protected
|
||||||
skill-driven one now branches to `chore/*` first.
|
base, but a skill-driven one now branches to `chore/*` first.
|
||||||
|
|
||||||
**Integration is human-gated by default** — these flows commit, they do not merge.
|
**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)
|
EXCEPTION: `/capitalize` + `/close` auto-persist their memory-only commit (finish → develop; the lib pushes develop in auto-push mode only)
|
||||||
|
|||||||
+4
-4
@@ -13,14 +13,14 @@ HERE="$(cd "$(dirname "$0")" && pwd)"
|
|||||||
# shellcheck source=/dev/null
|
# shellcheck source=/dev/null
|
||||||
source "$HERE/gitflow.sh"
|
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
|
PASS=0; FAIL=0
|
||||||
ok() { PASS=$((PASS+1)); printf ' ok %s\n' "$1"; }
|
ok() { PASS=$((PASS+1)); printf ' ok %s\n' "$1"; }
|
||||||
no() { FAIL=$((FAIL+1)); printf ' FAIL %s\n' "$1"; }
|
no() { FAIL=$((FAIL+1)); printf ' FAIL %s\n' "$1"; }
|
||||||
chk() { if eval "$2"; then ok "$1"; else no "$1 [ $2 ]"; fi; }
|
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; \
|
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 user.email t@t && git config user.name t && \
|
||||||
git config core.hooksPath /dev/null; } # hooks off during setup
|
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
|
hookon() { git config --unset core.hooksPath 2>/dev/null || true; } # use repo default .githooks
|
||||||
|
|
||||||
echo "T1 — pure predicates"
|
echo "T1 — pure predicates"
|
||||||
|
|||||||
+1
-1
@@ -428,7 +428,7 @@ _mem_add_locked() { # <file> <PREFIX> <entry-file> <supersedes>
|
|||||||
|
|
||||||
_mem_path_safe() { # <path> → path, ./-prefixed when awk would take it for
|
_mem_path_safe() { # <path> → path, ./-prefixed when awk would take it for
|
||||||
# a `var=value` assignment operand and read stdin instead
|
# 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() { # <kind> <title> <body-file> <status> <supersedes>
|
memory_add() { # <kind> <title> <body-file> <status> <supersedes>
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ cat > "$FX/bin/claude" <<'EOT'
|
|||||||
EOT
|
EOT
|
||||||
chmod +x "$FX/bin/"*
|
chmod +x "$FX/bin/"*
|
||||||
# shellcheck source=lib/tests/claude-stub.sh
|
# 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
|
for c in claude systemd-run dtach; do
|
||||||
PATH="$FX/bin:$PATH" stub_first_or_die "$c" "$FX/bin/$c"
|
PATH="$FX/bin:$PATH" stub_first_or_die "$c" "$FX/bin/$c"
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
# lib/tests/claude-stub.test.sh
|
# lib/tests/claude-stub.test.sh
|
||||||
# Regression for BLK-043 residuals: claude_stub_install must fail closed
|
# 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.
|
# (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
|
set -u
|
||||||
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||||
HELPER="${CLAUDE_STUB_LIB:-$ROOT/lib/tests/claude-stub.sh}"
|
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"
|
mkdir -p "$WORK/a/work" "$WORK/a/fake"
|
||||||
printf '#!/bin/sh\ntouch "%s"\n' "$WORK/a/sentinel" >"$WORK/a/fake/claude"
|
printf '#!/bin/sh\ntouch "%s"\n' "$WORK/a/sentinel" >"$WORK/a/fake/claude"
|
||||||
chmod +x "$WORK/a/fake/claude"
|
chmod +x "$WORK/a/fake/claude"
|
||||||
err=$( ( chmod() { :; }; PATH="$WORK/a/fake:$PATH"
|
mkdir -p "$WORK/a/noop"
|
||||||
. "$HELPER"; claude_stub_install "$WORK/a/work" ) 2>&1 >/dev/null )
|
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=$?
|
rc=$?
|
||||||
check Ta-rc "$rc" 1
|
check Ta-rc "$rc" 1
|
||||||
case "$err" in *"claude stub not first on PATH"*) m=yes ;; *) m=no ;; esac
|
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.
|
# (b) relative dir: the stub still resolves after a cd elsewhere.
|
||||||
mkdir -p "$WORK/b/rel"
|
mkdir -p "$WORK/b/rel"
|
||||||
|
# shellcheck source=lib/tests/claude-stub.sh
|
||||||
got=$( cd "$WORK/b" && . "$HELPER" && claude_stub_install rel \
|
got=$( cd "$WORK/b" && . "$HELPER" && claude_stub_install rel \
|
||||||
&& cd / && command -v claude )
|
&& cd / && command -v claude )
|
||||||
check Tb-relative-resolves "$got" "$WORK/b/rel/stub/claude"
|
check Tb-relative-resolves "$got" "$WORK/b/rel/stub/claude"
|
||||||
|
|
||||||
# (c) happy path
|
# (c) happy path
|
||||||
mkdir -p "$WORK/c"
|
mkdir -p "$WORK/c"
|
||||||
|
# shellcheck source=lib/tests/claude-stub.sh
|
||||||
out=$( . "$HELPER"; claude_stub_install "$WORK/c" && claude_stub_calls )
|
out=$( . "$HELPER"; claude_stub_install "$WORK/c" && claude_stub_calls )
|
||||||
check Tc-happy "$out" 0
|
check Tc-happy "$out" 0
|
||||||
|
|
||||||
|
|||||||
@@ -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.
|
# Stub claude: logs every call, never starts a session; fails closed.
|
||||||
# shellcheck source=lib/tests/claude-stub.sh
|
# 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"
|
claude_stub_install "$WORK"
|
||||||
|
|
||||||
# detect_plan, no .claude.json: pro, no claude call.
|
# detect_plan, no .claude.json: pro, no claude call.
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ set -u
|
|||||||
LIB="$(cd "$(dirname "$0")/../.." && pwd)/lib/graphify-gate.sh"
|
LIB="$(cd "$(dirname "$0")/../.." && pwd)/lib/graphify-gate.sh"
|
||||||
WORK="$(mktemp -d)" || exit 1; trap 'rm -rf "$WORK"' EXIT
|
WORK="$(mktemp -d)" || exit 1; trap 'rm -rf "$WORK"' EXIT
|
||||||
pass=0; fail=0
|
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
|
mkdir -p "$WORK/cs" || exit 1
|
||||||
claude_stub_install "$WORK/cs"
|
claude_stub_install "$WORK/cs"
|
||||||
check() { if [ "$2" = "$3" ]; then pass=$((pass+1)); else fail=$((fail+1));
|
check() { if [ "$2" = "$3" ]; then pass=$((pass+1)); else fail=$((fail+1));
|
||||||
|
|||||||
@@ -689,7 +689,7 @@ done
|
|||||||
# Stub work dir outside $FIX: the fixture repo's `git add -A` must not
|
# 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.
|
# commit the stub. Installed here so earlier cases see the repo unceilinged.
|
||||||
# shellcheck source=lib/tests/claude-stub.sh
|
# 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
|
CSW=$(mktemp -d) || exit 1; trap 'rm -rf "$FIX" "$CSW"' EXIT
|
||||||
claude_stub_install "$CSW"
|
claude_stub_install "$CSW"
|
||||||
banner() { (cd "$1" && SESSION_START_OFFLINE=1 bash "$ROOT/hooks/session-start.sh" \
|
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'
|
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
|
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
|
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)
|
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
|
check no-claude-calls "$(claude_stub_calls)" 0
|
||||||
echo "PASS=$pass FAIL=$fail"
|
echo "PASS=$pass FAIL=$fail"
|
||||||
|
|||||||
@@ -353,7 +353,7 @@ check T43b-clearance "$(grep -c "does not clear it: the user types \`! git push\
|
|||||||
|
|
||||||
# ── session banner ──
|
# ── session banner ──
|
||||||
# shellcheck source=lib/tests/claude-stub.sh
|
# 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
|
mkdir -p "$WORK/cs" || exit 1
|
||||||
claude_stub_install "$WORK/cs"
|
claude_stub_install "$WORK/cs"
|
||||||
banner() { # banner <dir>
|
banner() { # banner <dir>
|
||||||
|
|||||||
@@ -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
|
# 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.
|
# instead of starting a session that re-runs this hook.
|
||||||
# shellcheck source=lib/tests/claude-stub.sh
|
# 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"
|
claude_stub_install "$WORK"
|
||||||
|
|
||||||
# mkproj <name> -> path with an empty memory dir
|
# mkproj <name> -> path with an empty memory dir
|
||||||
|
|||||||
Reference in new issue
Block a user