From 74a80c98595f1bb69c89fb354c5607ac6b5ce0a3 Mon Sep 17 00:00:00 2001 From: Rob Hofmann Date: Mon, 9 Nov 2026 22:28:03 +0100 Subject: [PATCH 1/4] Run the pre-push gates on a local checkout when the repository is on a network share Refs #20 --- .../skills/ai-sdlc-gates/sync-manifest.json | 6 +- .claude/skills/ai-sdlc-hooks/SKILL.md | 2 +- .../skills/ai-sdlc-hooks/githooks/pre-push | 45 ++++++++++- .../scripts/PrePushHook.Tests.ps1 | 78 +++++++++++++++++++ CHANGELOG.md | 8 ++ apm.lock.yaml | 16 ++-- .../skills/ai-sdlc-gates/sync-manifest.json | 6 +- core/.apm/skills/ai-sdlc-hooks/SKILL.md | 2 +- .../skills/ai-sdlc-hooks/githooks/pre-push | 45 ++++++++++- .../scripts/PrePushHook.Tests.ps1 | 78 +++++++++++++++++++ core/apm.yml | 2 +- packs/bicep/apm.yml | 2 +- packs/blazor/apm.yml | 2 +- packs/discovery/apm.yml | 2 +- packs/dotnet/apm.yml | 2 +- packs/github-issues/apm.yml | 2 +- packs/github/apm.yml | 2 +- packs/knowledge/apm.yml | 2 +- packs/sonarcloud/apm.yml | 2 +- 19 files changed, 275 insertions(+), 29 deletions(-) diff --git a/.claude/skills/ai-sdlc-gates/sync-manifest.json b/.claude/skills/ai-sdlc-gates/sync-manifest.json index efa5b23..d19940b 100644 --- a/.claude/skills/ai-sdlc-gates/sync-manifest.json +++ b/.claude/skills/ai-sdlc-gates/sync-manifest.json @@ -130,7 +130,7 @@ ".claude/skills/ai-sdlc-hooks/githooks/post-commit": "f18058f9a38efc164e13801d61bb05329a056109", ".claude/skills/ai-sdlc-hooks/githooks/post-merge": "bb373f33abd09294cda55d7fc4499f32672eb372", ".claude/skills/ai-sdlc-hooks/githooks/post-rewrite": "e4c187dffeeaba569901f3424fae476b17c14927", - ".claude/skills/ai-sdlc-hooks/githooks/pre-push": "2e0d36443dbfbff57e4b8bddece5ca4f75fc7992", + ".claude/skills/ai-sdlc-hooks/githooks/pre-push": "63ac41677c2bd605920ee5ba4b5719e60276e154", ".claude/skills/ai-sdlc-hooks/scripts/AiSdlcSetup.ps1": "52ffd325d13cd403e7bfea0de8098c530c129b65", ".claude/skills/ai-sdlc-hooks/scripts/AiSdlcSetup.Tests.ps1": "ef5b30f0811181462d354a61d3e64c19f0c305e2", ".claude/skills/ai-sdlc-hooks/scripts/Deny-AgentMerge.ps1": "535543b86886fcc582912ded5373b0bd3d756356", @@ -156,12 +156,12 @@ ".claude/skills/ai-sdlc-hooks/scripts/Invoke-PostEditCheck.Tests.ps1": "3429e18735428ab387ab58ae276d4195b32e7999", ".claude/skills/ai-sdlc-hooks/scripts/New-AiSdlcUpdatePullRequest.ps1": "b54f90deb751d0b0dbf8ee8fbc3f39b3300b3b3d", ".claude/skills/ai-sdlc-hooks/scripts/New-AiSdlcUpdatePullRequest.Tests.ps1": "77e4b627da13ea9887f3918f66bc5b33dfd91c56", - ".claude/skills/ai-sdlc-hooks/scripts/PrePushHook.Tests.ps1": "b39aacfa62f188fee2455b85f00e259bfe509c87", + ".claude/skills/ai-sdlc-hooks/scripts/PrePushHook.Tests.ps1": "e75c62d107109d55b8d48b9c208c1cf4ea0d5e67", ".claude/skills/ai-sdlc-hooks/scripts/Update-AiSdlc.ps1": "56abaf1de1c17bea94c26e128f8c41e275a74f87", ".claude/skills/ai-sdlc-hooks/scripts/Update-AiSdlc.Tests.ps1": "8db305e438bc7ee404eb5106eacbe5581738f148", ".claude/skills/ai-sdlc-hooks/scripts/WindowsLongPaths.ps1": "fa3d7f509b6f9a1a935178c1eaf0d1566b7afead", ".claude/skills/ai-sdlc-hooks/scripts/WindowsLongPaths.Tests.ps1": "21a220ca2ccc65a56ec427a6e74c5a5dbfbfd4ef", - ".claude/skills/ai-sdlc-hooks/SKILL.md": "a5b99bcdf6bf93721136ee3a3e7075632fdf068d", + ".claude/skills/ai-sdlc-hooks/SKILL.md": "97369efdaee66b9d0e37553a1a70066716faa1f6", ".claude/skills/capture-learning/SKILL.md": "32300ce3189109b0d717f975623e8d7ccec1c821", ".claude/skills/convene-personas/SKILL.md": "449708a02206bec35a83d2f48ca6366c8b78e3a2", ".claude/skills/docs-wiki-conventions/SKILL.md": "0679512fa39815b63da6373ff29bb6eadc52ff24", diff --git a/.claude/skills/ai-sdlc-hooks/SKILL.md b/.claude/skills/ai-sdlc-hooks/SKILL.md index a5b99bc..97369ef 100644 --- a/.claude/skills/ai-sdlc-hooks/SKILL.md +++ b/.claude/skills/ai-sdlc-hooks/SKILL.md @@ -42,7 +42,7 @@ The dotnet pack adds one more: `Deny-StaleGraphQuery.ps1` in `dotnet-code-graph` (`Test-PushReceipt.ps1` in `ai-sdlc-gates`). The pre-flight ran the same gates on that content, and the pull request build still runs them. A push that only deletes refs, or whose commits the remote already has, runs no gate at all. Only the refs of the remote being pushed to count. Both - push hooks judge this with one rule, `Test-PushSendsNothingNew` in `PreflightReceipt.psm1`. It also shows the change-completeness report, which is advisory and never fails the push. Last, it + push hooks judge this with one rule, `Test-PushSendsNothingNew` in `PreflightReceipt.psm1`. It also shows the change-completeness report, which is advisory and never fails the push. When the repository is on a network share and one commit is pushed, the gates run on a local checkout of that commit, which is much faster. Last, it hands the same ref lines on to `git lfs pre-push`, so the LFS objects are uploaded. The other hooks refresh the code graph, and do nothing when the graph tooling is absent. - `githooks/git-lfs-hook` is shared by `pre-push`, `post-checkout`, `post-commit` and `post-merge`. diff --git a/.claude/skills/ai-sdlc-hooks/githooks/pre-push b/.claude/skills/ai-sdlc-hooks/githooks/pre-push index 2e0d364..63ac416 100644 --- a/.claude/skills/ai-sdlc-hooks/githooks/pre-push +++ b/.claude/skills/ai-sdlc-hooks/githooks/pre-push @@ -3,7 +3,8 @@ # before the push, not after a full pipeline cycle. When a passing pre-flight receipt covers the tree of the tip commit # of each pushed ref (Test-PushReceipt.ps1), those gates already passed on that content and do not run again. A push that only # deletes refs, or whose commits the remote already has, runs no gate. Then it hands on to Git LFS, so the LFS objects -# are uploaded. Tool-agnostic: fires on any `git push`, whether +# are uploaded. On a network share the gates run on a local checkout of the pushed commit (see is_network_path). +# Tool-agnostic: fires on any `git push`, whether # from a terminal, Claude Code, or GitHub Copilot, because it is a git hook, not an agent feature. # # Enable once per clone: pwsh .claude/skills/ai-sdlc-hooks/scripts/Initialize-AiSdlc.ps1 @@ -73,6 +74,37 @@ done </dev/null) && rmdir "$dir" && + git -C "$1" worktree add --quiet --detach "$dir" "$2" >/dev/null 2>&1 && { + if [ -f "$dir/.claude/skills/ai-sdlc-gates/scripts/Invoke-LocalGates.ps1" ]; then echo "$dir"; return 0; fi + git -C "$1" worktree remove --force "$dir" >/dev/null 2>&1 + rm -rf "$dir" + } + fi + echo "$1" +} + run_gates() ( repo_root=$(git rev-parse --show-toplevel) runner="$repo_root/.claude/skills/ai-sdlc-gates/scripts/Invoke-LocalGates.ps1" @@ -103,6 +135,15 @@ run_gates() ( echo "pre-push: a passing pre-flight receipt covers the tip commit of each pushed ref, so the blocking gates do not run again." status=0 else + tips=$(printf '%s\n' "$refs" | awk 'NF >= 2 && $2 !~ /^0+$/ { print $2 }' | sort -u) + [ "$(printf '%s\n' "$tips" | grep -c .)" -eq 1 ] || tips= + gate_root=$(gate_root_for "$repo_root" "$tips") + if [ "$gate_root" != "$repo_root" ]; then + trap 'git -C "$repo_root" worktree remove --force "$gate_root" >/dev/null 2>&1; rm -rf "$gate_root"' EXIT + echo "pre-push: the gates run on a local checkout of $tips, because the repository is on a network share." + cd "$gate_root" || return 1 + runner="$gate_root/.claude/skills/ai-sdlc-gates/scripts/Invoke-LocalGates.ps1" + fi echo "pre-push: running blocking CA gates ($runner -BlockingOnly)..." "$PWSH" -NoProfile -File "$runner" -BlockingOnly status=$? @@ -111,7 +152,7 @@ run_gates() ( # Advisory: reports when behaviour moved while its tests or docs stood still. Its gate is Advisory, # so the -BlockingOnly run above leaves it out; this call keeps the report visible on every push, # for every tool, without failing it. - completeness="$repo_root/.claude/skills/ai-sdlc-gates/scripts/Check-ChangeCompleteness.ps1" + completeness="${gate_root:-$repo_root}/.claude/skills/ai-sdlc-gates/scripts/Check-ChangeCompleteness.ps1" if [ -f "$completeness" ]; then "$PWSH" -NoProfile -File "$completeness" || true fi diff --git a/.claude/skills/ai-sdlc-hooks/scripts/PrePushHook.Tests.ps1 b/.claude/skills/ai-sdlc-hooks/scripts/PrePushHook.Tests.ps1 index b39aacf..e75c62d 100644 --- a/.claude/skills/ai-sdlc-hooks/scripts/PrePushHook.Tests.ps1 +++ b/.claude/skills/ai-sdlc-hooks/scripts/PrePushHook.Tests.ps1 @@ -191,6 +191,84 @@ Describe 'The pre-push git hook' { } } + Context 'a repository on a network share, where the gates run on a local checkout of the pushed commit' { + BeforeAll { + $script:NoPwshShare = -not (Get-Command pwsh -ErrorAction SilentlyContinue) + + # The committed runner prints "committed"; the working tree holds an uncommitted copy that prints + # "worktree". So the output shows which copy ran. + function Invoke-PushFromShare { + param([string]$Checkout, [int]$RunnerExit = 0) + $root = Join-Path ([System.IO.Path]::GetTempPath()) ('pre-push-' + [guid]::NewGuid().ToString('n')) + $gates = Join-Path $root '.claude' 'skills' 'ai-sdlc-gates' 'scripts' + New-Item -ItemType Directory -Path $gates -Force | Out-Null + git -C $root init --quiet + git -C $root config user.email probe@example.invalid + git -C $root config user.name probe + $runner = Join-Path $gates 'Invoke-LocalGates.ps1' + Set-Content -LiteralPath $runner -Value "Write-Host 'runner copy=committed'; exit $RunnerExit" + Set-Content -LiteralPath (Join-Path $gates 'Check-ChangeCompleteness.ps1') -Value "Write-Host 'completeness copy=committed'" + git -C $root add . + git -C $root commit --quiet -m one --no-verify + $sha = (git -C $root rev-parse HEAD).Trim() + Set-Content -LiteralPath $runner -Value "Write-Host 'runner copy=worktree'; exit 0" + $saved = $env:AISDLC_GATES_LOCAL_CHECKOUT + Push-Location $root + try { + $env:AISDLC_GATES_LOCAL_CHECKOUT = $Checkout + $output = "refs/heads/1-story $sha refs/heads/1-story $script:Zero`n" | & $script:Sh $script:Hook origin 'https://example.invalid/repo' 2>&1 | Out-String + [pscustomobject]@{ Code = $LASTEXITCODE; Output = $output; Worktrees = @(git -C $root worktree list).Count } + } + finally { + $env:AISDLC_GATES_LOCAL_CHECKOUT = $saved + Pop-Location + Remove-Item -LiteralPath $root -Recurse -Force -ErrorAction SilentlyContinue + } + } + } + + It 'runs the committed gates in a local checkout, and removes the checkout after' -Skip:($script:NoSh -or $script:NoPwshShare) { + $r = Invoke-PushFromShare -Checkout '1' + + $r.Code | Should -Be 0 -Because $r.Output + $r.Output | Should -Match 'local checkout of [0-9a-f]{40}' + $r.Output | Should -Match 'runner copy=committed' + $r.Output | Should -Match 'completeness copy=committed' + $r.Output | Should -Not -Match 'copy=worktree' + $r.Worktrees | Should -Be 1 -Because 'only the main working tree is left' + } + + It 'refuses the push when a gate fails in the checkout, and still removes it' -Skip:($script:NoSh -or $script:NoPwshShare) { + $r = Invoke-PushFromShare -Checkout '1' -RunnerExit 1 + + $r.Code | Should -Be 1 + $r.Output | Should -Match 'blocking gate\(s\) failed' + $r.Worktrees | Should -Be 1 + } + + It 'runs the gates in place when the repository is not on a share' -Skip:($script:NoSh -or $script:NoPwshShare) { + $r = Invoke-PushFromShare -Checkout '' + + $r.Code | Should -Be 0 -Because $r.Output + $r.Output | Should -Match 'runner copy=worktree' + $r.Output | Should -Not -Match 'local checkout' + } + + It 'treats a //host/share root as a network share, and a drive or POSIX path as local' -Skip:$script:NoSh { + $probe = Join-Path ([System.IO.Path]::GetTempPath()) ('net-path-' + [guid]::NewGuid().ToString('n') + '.sh') + try { + $text = Get-Content -LiteralPath $script:Hook -Raw + $function = [regex]::Match($text, '(?ms)^is_network_path\(\) \{.*?^\}').Value + Set-Content -LiteralPath $probe -Value ($function + "`nfor p in //host/share/repo C:/repo /home/repo; do if is_network_path `"`$p`"; then echo `"net `$p`"; else echo `"local `$p`"; fi; done") + $output = & $script:Sh $probe | Out-String + $output | Should -Match 'net //host/share/repo' + $output | Should -Match 'local C:/repo' + $output | Should -Match 'local /home/repo' + } + finally { Remove-Item -LiteralPath $probe -Force -ErrorAction SilentlyContinue } + } + } + Context 'in a tree that has the gates' { BeforeAll { function Invoke-PrePushWithGates { diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b21b0f..b4d1455 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,14 @@ merge is ready to tag, and no second pull request is needed to name the version. Each entry names its issue, as `#42`. +## v1.3.2 - 2026-11-09 + +- On a network share, the pre-push git hook runs the blocking gates on a local checkout of the pushed + commit: a detached git worktree in a temp folder, which it removes after the run (#20). A push of + about 930 files went from 1,425 seconds in the gates to 15. The gates now check the pushed commit + there, not the working tree. It is used only when one commit is pushed. + `AISDLC_GATES_LOCAL_CHECKOUT=1` forces it, and `=0` turns it off. + ## v1.3.1 - 2026-11-09 - The pre-push git hook now reads `git.allowTrunkPush` when `core.hooksPath` is relative, which is how diff --git a/apm.lock.yaml b/apm.lock.yaml index bd7a947..5f57bc8 100644 --- a/apm.lock.yaml +++ b/apm.lock.yaml @@ -331,7 +331,7 @@ dependencies: .claude/skills/ai-sdlc-gates/scripts/gitleaks-rules.json: sha256:6a8a75c5dbcf2378a1c52d046e34ce275aac7ce08a0ae61408d25c18e1e27014 .claude/skills/ai-sdlc-gates/scripts/gitleaks-version.json: sha256:c54acb854f87a1bbdf0e90c670b72b5de3cd37f7e460d82eca599c3c7af23a84 .claude/skills/ai-sdlc-gates/skill-catalog.json: sha256:5537684656bf189a740ba7e9e7050083af05668d00501ce1e9c6909cb8b91203 - .claude/skills/ai-sdlc-gates/sync-manifest.json: sha256:8d40bcba0f9aa58fcb31ef15d25c502479ee04415a69be821f381ea784bcfd1c + .claude/skills/ai-sdlc-gates/sync-manifest.json: sha256:51eb177707092c6d1b8d3fd2663429fb85c9bd5748bed4269f7699985af56d2b .claude/skills/ai-sdlc-handbook/SKILL.md: sha256:548e6b9ad79d3d2afa2f5779835988eeb12c49cda08917c4bbaa9ac0486a47a0 .claude/skills/ai-sdlc-handbook/references/README.md: sha256:654afcaa2b81f560eff93dbdef521b09ced06137a1dbb85d70a4e14ef7502248 .claude/skills/ai-sdlc-handbook/references/artifact-graph.md: sha256:d7ddfe20e5ee6565bcf25f9cef0f578da2a4ab1590033d791b8814d4688fd1f0 @@ -350,7 +350,7 @@ dependencies: .claude/skills/ai-sdlc-handbook/references/personas.md: sha256:7913c3dca6bad93b45624349a12bf976f894eb6ca05c7baa1fa7e3ba802ca69a .claude/skills/ai-sdlc-handbook/references/plan.md: sha256:b632fe2da2369f494ebe2606c4bdc8726eabe3b7615b6ddb0b58fa9b3897a216 .claude/skills/ai-sdlc-handbook/references/skill-usage.md: sha256:9d5414b38d9d6f5bd7dfa9857e8e441bf040b0020f46ac8d3b29b0a476161c61 - .claude/skills/ai-sdlc-hooks/SKILL.md: sha256:2b7cddccaff175fd0ffd44524dfddc2b1894f74c1fbdf91d02659573a25b07f8 + .claude/skills/ai-sdlc-hooks/SKILL.md: sha256:b52458622c91cdf4a706a9a70878bb192e9b9f950c53639c4121ce6c5c51e6e8 .claude/skills/ai-sdlc-hooks/gates.json: sha256:dfc8b0003e930167e0fccc366867f423bc0850f3c69477c0e7119aed710bf902 .claude/skills/ai-sdlc-hooks/githooks/git-lfs-hook: sha256:3265310500749e7181a5625517f94e2efa62d48be987ebc9b0396d38e2eeffa6 .claude/skills/ai-sdlc-hooks/githooks/graphify-refresh: sha256:1bc6c7f181aab3a0fdd34bf8907a4884bea2412a56ebdc77a673707e17c046f3 @@ -358,7 +358,7 @@ dependencies: .claude/skills/ai-sdlc-hooks/githooks/post-commit: sha256:4f73a74133b0272725117fa9d962353abb6ed98d9cf5e731cd212fd5ace23271 .claude/skills/ai-sdlc-hooks/githooks/post-merge: sha256:b9f1f47cd3894406451e00c177912baeed66470b0cc18d581a5461330c7c0868 .claude/skills/ai-sdlc-hooks/githooks/post-rewrite: sha256:b7ee1a97b08a9826678829b6c49457fdc4b5ebd53eaf8cdd70f33d26e61c4a79 - .claude/skills/ai-sdlc-hooks/githooks/pre-push: sha256:be87399d754cfa3f937c5aa0e49e55851260a48c843cc2e5a0fa5de5a33e6584 + .claude/skills/ai-sdlc-hooks/githooks/pre-push: sha256:e3e6a13cdaaa14c10676d6519e0665d31b7c3a401fca7e5d7ce3180db43989cd .claude/skills/ai-sdlc-hooks/scripts/AiSdlcSetup.Tests.ps1: sha256:004bc7f1a68e953c8e657b49e74755b69a14138dfb0db61162ab15420f2b24be .claude/skills/ai-sdlc-hooks/scripts/AiSdlcSetup.ps1: sha256:b3569de6e27c3dcaffbc082311e6882bd722d440e5e855245da2410033202c7e .claude/skills/ai-sdlc-hooks/scripts/Deny-AgentMerge.Tests.ps1: sha256:4c4e1f6b673671125290d78815c72277665a8a618b55fd589f75f3a36e3b80aa @@ -384,7 +384,7 @@ dependencies: .claude/skills/ai-sdlc-hooks/scripts/Invoke-PostEditCheck.ps1: sha256:d60cdd2d341487ded3b9fafe40da49f2adfb1cf8f20cf3f8559ea2e80a5f93c6 .claude/skills/ai-sdlc-hooks/scripts/New-AiSdlcUpdatePullRequest.Tests.ps1: sha256:9c9859767d2534c45e1c72b47f4b5c64aaa16c32c580df3b5d8bc3dce5cdb2c4 .claude/skills/ai-sdlc-hooks/scripts/New-AiSdlcUpdatePullRequest.ps1: sha256:abf763c6cde97dbfc83b25f140e768d66fd9edd3961605b7d058b08a31882875 - .claude/skills/ai-sdlc-hooks/scripts/PrePushHook.Tests.ps1: sha256:06760f922d0a90550923195fe5eacfb65d29d95d9294d2f679ee7aafa068d014 + .claude/skills/ai-sdlc-hooks/scripts/PrePushHook.Tests.ps1: sha256:fd010d9d93bf336525d313bab3ae914cd237c25d33f445de02d0e93a372340fd .claude/skills/ai-sdlc-hooks/scripts/Update-AiSdlc.Tests.ps1: sha256:4f2fe5313c8763f8128ad0e0347da1f2dd485393d20dc5e3a5d75e08aa157ad3 .claude/skills/ai-sdlc-hooks/scripts/Update-AiSdlc.ps1: sha256:0381e47c6b1070c7b230f81f243e25b1a8bfa68b5e8e9ae2ad6e225b0ddb36b6 .claude/skills/ai-sdlc-hooks/scripts/WindowsLongPaths.Tests.ps1: sha256:52f81e945390e61222a2668c8525cb17f17226267e24c52d7792263a07576543 @@ -1551,7 +1551,7 @@ deployments: owners: - ./core active_owner: ./core - content_hash: sha256:8d40bcba0f9aa58fcb31ef15d25c502479ee04415a69be821f381ea784bcfd1c + content_hash: sha256:51eb177707092c6d1b8d3fd2663429fb85c9bd5748bed4269f7699985af56d2b - kind: project-relative target: claude value: .claude/skills/ai-sdlc-handbook @@ -1740,7 +1740,7 @@ deployments: owners: - ./core active_owner: ./core - content_hash: sha256:2b7cddccaff175fd0ffd44524dfddc2b1894f74c1fbdf91d02659573a25b07f8 + content_hash: sha256:b52458622c91cdf4a706a9a70878bb192e9b9f950c53639c4121ce6c5c51e6e8 - kind: project-relative target: claude value: .claude/skills/ai-sdlc-hooks/gates.json @@ -1812,7 +1812,7 @@ deployments: owners: - ./core active_owner: ./core - content_hash: sha256:be87399d754cfa3f937c5aa0e49e55851260a48c843cc2e5a0fa5de5a33e6584 + content_hash: sha256:e3e6a13cdaaa14c10676d6519e0665d31b7c3a401fca7e5d7ce3180db43989cd - kind: project-relative target: claude value: .claude/skills/ai-sdlc-hooks/scripts/AiSdlcSetup.Tests.ps1 @@ -2046,7 +2046,7 @@ deployments: owners: - ./core active_owner: ./core - content_hash: sha256:06760f922d0a90550923195fe5eacfb65d29d95d9294d2f679ee7aafa068d014 + content_hash: sha256:fd010d9d93bf336525d313bab3ae914cd237c25d33f445de02d0e93a372340fd - kind: project-relative target: claude value: .claude/skills/ai-sdlc-hooks/scripts/Update-AiSdlc.Tests.ps1 diff --git a/core/.apm/skills/ai-sdlc-gates/sync-manifest.json b/core/.apm/skills/ai-sdlc-gates/sync-manifest.json index efa5b23..d19940b 100644 --- a/core/.apm/skills/ai-sdlc-gates/sync-manifest.json +++ b/core/.apm/skills/ai-sdlc-gates/sync-manifest.json @@ -130,7 +130,7 @@ ".claude/skills/ai-sdlc-hooks/githooks/post-commit": "f18058f9a38efc164e13801d61bb05329a056109", ".claude/skills/ai-sdlc-hooks/githooks/post-merge": "bb373f33abd09294cda55d7fc4499f32672eb372", ".claude/skills/ai-sdlc-hooks/githooks/post-rewrite": "e4c187dffeeaba569901f3424fae476b17c14927", - ".claude/skills/ai-sdlc-hooks/githooks/pre-push": "2e0d36443dbfbff57e4b8bddece5ca4f75fc7992", + ".claude/skills/ai-sdlc-hooks/githooks/pre-push": "63ac41677c2bd605920ee5ba4b5719e60276e154", ".claude/skills/ai-sdlc-hooks/scripts/AiSdlcSetup.ps1": "52ffd325d13cd403e7bfea0de8098c530c129b65", ".claude/skills/ai-sdlc-hooks/scripts/AiSdlcSetup.Tests.ps1": "ef5b30f0811181462d354a61d3e64c19f0c305e2", ".claude/skills/ai-sdlc-hooks/scripts/Deny-AgentMerge.ps1": "535543b86886fcc582912ded5373b0bd3d756356", @@ -156,12 +156,12 @@ ".claude/skills/ai-sdlc-hooks/scripts/Invoke-PostEditCheck.Tests.ps1": "3429e18735428ab387ab58ae276d4195b32e7999", ".claude/skills/ai-sdlc-hooks/scripts/New-AiSdlcUpdatePullRequest.ps1": "b54f90deb751d0b0dbf8ee8fbc3f39b3300b3b3d", ".claude/skills/ai-sdlc-hooks/scripts/New-AiSdlcUpdatePullRequest.Tests.ps1": "77e4b627da13ea9887f3918f66bc5b33dfd91c56", - ".claude/skills/ai-sdlc-hooks/scripts/PrePushHook.Tests.ps1": "b39aacfa62f188fee2455b85f00e259bfe509c87", + ".claude/skills/ai-sdlc-hooks/scripts/PrePushHook.Tests.ps1": "e75c62d107109d55b8d48b9c208c1cf4ea0d5e67", ".claude/skills/ai-sdlc-hooks/scripts/Update-AiSdlc.ps1": "56abaf1de1c17bea94c26e128f8c41e275a74f87", ".claude/skills/ai-sdlc-hooks/scripts/Update-AiSdlc.Tests.ps1": "8db305e438bc7ee404eb5106eacbe5581738f148", ".claude/skills/ai-sdlc-hooks/scripts/WindowsLongPaths.ps1": "fa3d7f509b6f9a1a935178c1eaf0d1566b7afead", ".claude/skills/ai-sdlc-hooks/scripts/WindowsLongPaths.Tests.ps1": "21a220ca2ccc65a56ec427a6e74c5a5dbfbfd4ef", - ".claude/skills/ai-sdlc-hooks/SKILL.md": "a5b99bcdf6bf93721136ee3a3e7075632fdf068d", + ".claude/skills/ai-sdlc-hooks/SKILL.md": "97369efdaee66b9d0e37553a1a70066716faa1f6", ".claude/skills/capture-learning/SKILL.md": "32300ce3189109b0d717f975623e8d7ccec1c821", ".claude/skills/convene-personas/SKILL.md": "449708a02206bec35a83d2f48ca6366c8b78e3a2", ".claude/skills/docs-wiki-conventions/SKILL.md": "0679512fa39815b63da6373ff29bb6eadc52ff24", diff --git a/core/.apm/skills/ai-sdlc-hooks/SKILL.md b/core/.apm/skills/ai-sdlc-hooks/SKILL.md index a5b99bc..97369ef 100644 --- a/core/.apm/skills/ai-sdlc-hooks/SKILL.md +++ b/core/.apm/skills/ai-sdlc-hooks/SKILL.md @@ -42,7 +42,7 @@ The dotnet pack adds one more: `Deny-StaleGraphQuery.ps1` in `dotnet-code-graph` (`Test-PushReceipt.ps1` in `ai-sdlc-gates`). The pre-flight ran the same gates on that content, and the pull request build still runs them. A push that only deletes refs, or whose commits the remote already has, runs no gate at all. Only the refs of the remote being pushed to count. Both - push hooks judge this with one rule, `Test-PushSendsNothingNew` in `PreflightReceipt.psm1`. It also shows the change-completeness report, which is advisory and never fails the push. Last, it + push hooks judge this with one rule, `Test-PushSendsNothingNew` in `PreflightReceipt.psm1`. It also shows the change-completeness report, which is advisory and never fails the push. When the repository is on a network share and one commit is pushed, the gates run on a local checkout of that commit, which is much faster. Last, it hands the same ref lines on to `git lfs pre-push`, so the LFS objects are uploaded. The other hooks refresh the code graph, and do nothing when the graph tooling is absent. - `githooks/git-lfs-hook` is shared by `pre-push`, `post-checkout`, `post-commit` and `post-merge`. diff --git a/core/.apm/skills/ai-sdlc-hooks/githooks/pre-push b/core/.apm/skills/ai-sdlc-hooks/githooks/pre-push index 2e0d364..63ac416 100755 --- a/core/.apm/skills/ai-sdlc-hooks/githooks/pre-push +++ b/core/.apm/skills/ai-sdlc-hooks/githooks/pre-push @@ -3,7 +3,8 @@ # before the push, not after a full pipeline cycle. When a passing pre-flight receipt covers the tree of the tip commit # of each pushed ref (Test-PushReceipt.ps1), those gates already passed on that content and do not run again. A push that only # deletes refs, or whose commits the remote already has, runs no gate. Then it hands on to Git LFS, so the LFS objects -# are uploaded. Tool-agnostic: fires on any `git push`, whether +# are uploaded. On a network share the gates run on a local checkout of the pushed commit (see is_network_path). +# Tool-agnostic: fires on any `git push`, whether # from a terminal, Claude Code, or GitHub Copilot, because it is a git hook, not an agent feature. # # Enable once per clone: pwsh .claude/skills/ai-sdlc-hooks/scripts/Initialize-AiSdlc.ps1 @@ -73,6 +74,37 @@ done </dev/null) && rmdir "$dir" && + git -C "$1" worktree add --quiet --detach "$dir" "$2" >/dev/null 2>&1 && { + if [ -f "$dir/.claude/skills/ai-sdlc-gates/scripts/Invoke-LocalGates.ps1" ]; then echo "$dir"; return 0; fi + git -C "$1" worktree remove --force "$dir" >/dev/null 2>&1 + rm -rf "$dir" + } + fi + echo "$1" +} + run_gates() ( repo_root=$(git rev-parse --show-toplevel) runner="$repo_root/.claude/skills/ai-sdlc-gates/scripts/Invoke-LocalGates.ps1" @@ -103,6 +135,15 @@ run_gates() ( echo "pre-push: a passing pre-flight receipt covers the tip commit of each pushed ref, so the blocking gates do not run again." status=0 else + tips=$(printf '%s\n' "$refs" | awk 'NF >= 2 && $2 !~ /^0+$/ { print $2 }' | sort -u) + [ "$(printf '%s\n' "$tips" | grep -c .)" -eq 1 ] || tips= + gate_root=$(gate_root_for "$repo_root" "$tips") + if [ "$gate_root" != "$repo_root" ]; then + trap 'git -C "$repo_root" worktree remove --force "$gate_root" >/dev/null 2>&1; rm -rf "$gate_root"' EXIT + echo "pre-push: the gates run on a local checkout of $tips, because the repository is on a network share." + cd "$gate_root" || return 1 + runner="$gate_root/.claude/skills/ai-sdlc-gates/scripts/Invoke-LocalGates.ps1" + fi echo "pre-push: running blocking CA gates ($runner -BlockingOnly)..." "$PWSH" -NoProfile -File "$runner" -BlockingOnly status=$? @@ -111,7 +152,7 @@ run_gates() ( # Advisory: reports when behaviour moved while its tests or docs stood still. Its gate is Advisory, # so the -BlockingOnly run above leaves it out; this call keeps the report visible on every push, # for every tool, without failing it. - completeness="$repo_root/.claude/skills/ai-sdlc-gates/scripts/Check-ChangeCompleteness.ps1" + completeness="${gate_root:-$repo_root}/.claude/skills/ai-sdlc-gates/scripts/Check-ChangeCompleteness.ps1" if [ -f "$completeness" ]; then "$PWSH" -NoProfile -File "$completeness" || true fi diff --git a/core/.apm/skills/ai-sdlc-hooks/scripts/PrePushHook.Tests.ps1 b/core/.apm/skills/ai-sdlc-hooks/scripts/PrePushHook.Tests.ps1 index b39aacf..e75c62d 100644 --- a/core/.apm/skills/ai-sdlc-hooks/scripts/PrePushHook.Tests.ps1 +++ b/core/.apm/skills/ai-sdlc-hooks/scripts/PrePushHook.Tests.ps1 @@ -191,6 +191,84 @@ Describe 'The pre-push git hook' { } } + Context 'a repository on a network share, where the gates run on a local checkout of the pushed commit' { + BeforeAll { + $script:NoPwshShare = -not (Get-Command pwsh -ErrorAction SilentlyContinue) + + # The committed runner prints "committed"; the working tree holds an uncommitted copy that prints + # "worktree". So the output shows which copy ran. + function Invoke-PushFromShare { + param([string]$Checkout, [int]$RunnerExit = 0) + $root = Join-Path ([System.IO.Path]::GetTempPath()) ('pre-push-' + [guid]::NewGuid().ToString('n')) + $gates = Join-Path $root '.claude' 'skills' 'ai-sdlc-gates' 'scripts' + New-Item -ItemType Directory -Path $gates -Force | Out-Null + git -C $root init --quiet + git -C $root config user.email probe@example.invalid + git -C $root config user.name probe + $runner = Join-Path $gates 'Invoke-LocalGates.ps1' + Set-Content -LiteralPath $runner -Value "Write-Host 'runner copy=committed'; exit $RunnerExit" + Set-Content -LiteralPath (Join-Path $gates 'Check-ChangeCompleteness.ps1') -Value "Write-Host 'completeness copy=committed'" + git -C $root add . + git -C $root commit --quiet -m one --no-verify + $sha = (git -C $root rev-parse HEAD).Trim() + Set-Content -LiteralPath $runner -Value "Write-Host 'runner copy=worktree'; exit 0" + $saved = $env:AISDLC_GATES_LOCAL_CHECKOUT + Push-Location $root + try { + $env:AISDLC_GATES_LOCAL_CHECKOUT = $Checkout + $output = "refs/heads/1-story $sha refs/heads/1-story $script:Zero`n" | & $script:Sh $script:Hook origin 'https://example.invalid/repo' 2>&1 | Out-String + [pscustomobject]@{ Code = $LASTEXITCODE; Output = $output; Worktrees = @(git -C $root worktree list).Count } + } + finally { + $env:AISDLC_GATES_LOCAL_CHECKOUT = $saved + Pop-Location + Remove-Item -LiteralPath $root -Recurse -Force -ErrorAction SilentlyContinue + } + } + } + + It 'runs the committed gates in a local checkout, and removes the checkout after' -Skip:($script:NoSh -or $script:NoPwshShare) { + $r = Invoke-PushFromShare -Checkout '1' + + $r.Code | Should -Be 0 -Because $r.Output + $r.Output | Should -Match 'local checkout of [0-9a-f]{40}' + $r.Output | Should -Match 'runner copy=committed' + $r.Output | Should -Match 'completeness copy=committed' + $r.Output | Should -Not -Match 'copy=worktree' + $r.Worktrees | Should -Be 1 -Because 'only the main working tree is left' + } + + It 'refuses the push when a gate fails in the checkout, and still removes it' -Skip:($script:NoSh -or $script:NoPwshShare) { + $r = Invoke-PushFromShare -Checkout '1' -RunnerExit 1 + + $r.Code | Should -Be 1 + $r.Output | Should -Match 'blocking gate\(s\) failed' + $r.Worktrees | Should -Be 1 + } + + It 'runs the gates in place when the repository is not on a share' -Skip:($script:NoSh -or $script:NoPwshShare) { + $r = Invoke-PushFromShare -Checkout '' + + $r.Code | Should -Be 0 -Because $r.Output + $r.Output | Should -Match 'runner copy=worktree' + $r.Output | Should -Not -Match 'local checkout' + } + + It 'treats a //host/share root as a network share, and a drive or POSIX path as local' -Skip:$script:NoSh { + $probe = Join-Path ([System.IO.Path]::GetTempPath()) ('net-path-' + [guid]::NewGuid().ToString('n') + '.sh') + try { + $text = Get-Content -LiteralPath $script:Hook -Raw + $function = [regex]::Match($text, '(?ms)^is_network_path\(\) \{.*?^\}').Value + Set-Content -LiteralPath $probe -Value ($function + "`nfor p in //host/share/repo C:/repo /home/repo; do if is_network_path `"`$p`"; then echo `"net `$p`"; else echo `"local `$p`"; fi; done") + $output = & $script:Sh $probe | Out-String + $output | Should -Match 'net //host/share/repo' + $output | Should -Match 'local C:/repo' + $output | Should -Match 'local /home/repo' + } + finally { Remove-Item -LiteralPath $probe -Force -ErrorAction SilentlyContinue } + } + } + Context 'in a tree that has the gates' { BeforeAll { function Invoke-PrePushWithGates { diff --git a/core/apm.yml b/core/apm.yml index ade8bf9..31e4e15 100644 --- a/core/apm.yml +++ b/core/apm.yml @@ -1,3 +1,3 @@ name: ai-sdlc-core -version: "1.3.1" +version: "1.3.2" description: The AI-SDLC core for every repository - workflow skills, review agents, hooks, core gates and the handbook. diff --git a/packs/bicep/apm.yml b/packs/bicep/apm.yml index b68ad52..f4adc63 100644 --- a/packs/bicep/apm.yml +++ b/packs/bicep/apm.yml @@ -1,3 +1,3 @@ name: ai-sdlc-bicep -version: "1.3.1" +version: "1.3.2" description: The Bicep pack - Bicep conventions for infrastructure templates. diff --git a/packs/blazor/apm.yml b/packs/blazor/apm.yml index 3d1a5bb..4051d28 100644 --- a/packs/blazor/apm.yml +++ b/packs/blazor/apm.yml @@ -1,3 +1,3 @@ name: ai-sdlc-blazor -version: "1.3.1" +version: "1.3.2" description: The Blazor pack - portal UI conventions, component authorization and the Razor gates. diff --git a/packs/discovery/apm.yml b/packs/discovery/apm.yml index 88f959b..5f4be68 100644 --- a/packs/discovery/apm.yml +++ b/packs/discovery/apm.yml @@ -1,3 +1,3 @@ name: ai-sdlc-discovery -version: "1.3.1" +version: "1.3.2" description: The discovery pack - the discovery workflows that write a research summary, a journey map and a hypothesis canvas as markdown files in the repository. diff --git a/packs/dotnet/apm.yml b/packs/dotnet/apm.yml index e7fa5fb..22b28d8 100644 --- a/packs/dotnet/apm.yml +++ b/packs/dotnet/apm.yml @@ -1,3 +1,3 @@ name: ai-sdlc-dotnet -version: "1.3.1" +version: "1.3.2" description: The .NET pack - C# conventions, test-first, the .NET gates and the code graph. diff --git a/packs/github-issues/apm.yml b/packs/github-issues/apm.yml index 0647fa6..9e69908 100644 --- a/packs/github-issues/apm.yml +++ b/packs/github-issues/apm.yml @@ -1,3 +1,3 @@ name: ai-sdlc-github-issues -version: "1.3.1" +version: "1.3.2" description: The GitHub Issues pack - issue conventions and the issue contract gates. diff --git a/packs/github/apm.yml b/packs/github/apm.yml index c09968a..af67ef0 100644 --- a/packs/github/apm.yml +++ b/packs/github/apm.yml @@ -1,3 +1,3 @@ name: ai-sdlc-github -version: "1.3.1" +version: "1.3.2" description: The GitHub pack - pull requests, review threads, pull request delivery metrics and the GitHub Actions workflows. diff --git a/packs/knowledge/apm.yml b/packs/knowledge/apm.yml index dc40d32..10737dc 100644 --- a/packs/knowledge/apm.yml +++ b/packs/knowledge/apm.yml @@ -1,3 +1,3 @@ name: ai-sdlc-knowledge -version: "1.3.1" +version: "1.3.2" description: The knowledge pack - the conventions and the workflow for platform knowledge notes in the knowledge repository. diff --git a/packs/sonarcloud/apm.yml b/packs/sonarcloud/apm.yml index 2350d83..c5779dc 100644 --- a/packs/sonarcloud/apm.yml +++ b/packs/sonarcloud/apm.yml @@ -1,5 +1,5 @@ name: ai-sdlc-sonarcloud -version: "1.3.1" +version: "1.3.2" description: The SonarQube Cloud pack - the SonarQube MCP server for the agent session, and the gate that keeps the token and the organization out of the repository. dependencies: mcp: From 1768c55e81e06e18d30bcf8f9bd78f66c206ca55 Mon Sep 17 00:00:00 2001 From: Rob Hofmann Date: Mon, 9 Nov 2026 22:28:16 +0100 Subject: [PATCH 2/4] Update the lock to v1.3.2 Refs #20 --- apm.lock.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apm.lock.yaml b/apm.lock.yaml index 5f57bc8..5fbe5c8 100644 --- a/apm.lock.yaml +++ b/apm.lock.yaml @@ -3,7 +3,7 @@ apm_version: 0.31.0 dependencies: - repo_url: _local/core name: ai-sdlc-core - version: 1.3.1 + version: 1.3.2 package_type: apm_package deployed_files: - .claude/agents/architect.md @@ -427,7 +427,7 @@ dependencies: local_path: ./core - repo_url: _local/discovery name: ai-sdlc-discovery - version: 1.3.1 + version: 1.3.2 package_type: apm_package deployed_files: - .claude/skills/draw-customer-journey @@ -444,7 +444,7 @@ dependencies: local_path: ./packs/discovery - repo_url: _local/github name: ai-sdlc-github - version: 1.3.1 + version: 1.3.2 package_type: apm_package deployed_files: - .claude/skills/fix-pr-feedback @@ -534,7 +534,7 @@ dependencies: local_path: ./packs/github - repo_url: _local/github-issues name: ai-sdlc-github-issues - version: 1.3.1 + version: 1.3.2 package_type: apm_package deployed_files: - .claude/agents/draft-reviewer.md From e8d2dbf7b515762c5072577c5165928cf4c7dd3e Mon Sep 17 00:00:00 2001 From: Rob Hofmann Date: Mon, 9 Nov 2026 22:32:21 +0100 Subject: [PATCH 3/4] Put the gate checkout in a private temp folder, and clean up on interrupt Refs #20 --- .../skills/ai-sdlc-gates/sync-manifest.json | 2 +- .../skills/ai-sdlc-hooks/githooks/pre-push | 21 ++++++++++++------- apm.lock.yaml | 8 +++---- .../skills/ai-sdlc-gates/sync-manifest.json | 2 +- .../skills/ai-sdlc-hooks/githooks/pre-push | 21 ++++++++++++------- 5 files changed, 34 insertions(+), 20 deletions(-) diff --git a/.claude/skills/ai-sdlc-gates/sync-manifest.json b/.claude/skills/ai-sdlc-gates/sync-manifest.json index d19940b..c0af785 100644 --- a/.claude/skills/ai-sdlc-gates/sync-manifest.json +++ b/.claude/skills/ai-sdlc-gates/sync-manifest.json @@ -130,7 +130,7 @@ ".claude/skills/ai-sdlc-hooks/githooks/post-commit": "f18058f9a38efc164e13801d61bb05329a056109", ".claude/skills/ai-sdlc-hooks/githooks/post-merge": "bb373f33abd09294cda55d7fc4499f32672eb372", ".claude/skills/ai-sdlc-hooks/githooks/post-rewrite": "e4c187dffeeaba569901f3424fae476b17c14927", - ".claude/skills/ai-sdlc-hooks/githooks/pre-push": "63ac41677c2bd605920ee5ba4b5719e60276e154", + ".claude/skills/ai-sdlc-hooks/githooks/pre-push": "73b10f0197b87c9311542cbb93627c116aa28788", ".claude/skills/ai-sdlc-hooks/scripts/AiSdlcSetup.ps1": "52ffd325d13cd403e7bfea0de8098c530c129b65", ".claude/skills/ai-sdlc-hooks/scripts/AiSdlcSetup.Tests.ps1": "ef5b30f0811181462d354a61d3e64c19f0c305e2", ".claude/skills/ai-sdlc-hooks/scripts/Deny-AgentMerge.ps1": "535543b86886fcc582912ded5373b0bd3d756356", diff --git a/.claude/skills/ai-sdlc-hooks/githooks/pre-push b/.claude/skills/ai-sdlc-hooks/githooks/pre-push index 63ac416..73b10f0 100644 --- a/.claude/skills/ai-sdlc-hooks/githooks/pre-push +++ b/.claude/skills/ai-sdlc-hooks/githooks/pre-push @@ -95,12 +95,18 @@ gate_root_for() { if is_network_path "$1"; then want=1; else want=0; fi fi if [ "$want" = 1 ] && [ -n "$2" ]; then - dir=$(mktemp -d 2>/dev/null) && rmdir "$dir" && - git -C "$1" worktree add --quiet --detach "$dir" "$2" >/dev/null 2>&1 && { - if [ -f "$dir/.claude/skills/ai-sdlc-gates/scripts/Invoke-LocalGates.ps1" ]; then echo "$dir"; return 0; fi - git -C "$1" worktree remove --force "$dir" >/dev/null 2>&1 - rm -rf "$dir" - } + # The checkout goes in a subfolder of the private (0700) temp folder, so no other user can put + # anything in its place. + dir=$(mktemp -d 2>/dev/null) || dir= + if [ -n "$dir" ]; then + if git -C "$1" worktree add --quiet --detach "$dir/wt" "$2" >/dev/null 2>&1 && + [ -f "$dir/wt/.claude/skills/ai-sdlc-gates/scripts/Invoke-LocalGates.ps1" ]; then + echo "$dir/wt" + return 0 + fi + git -C "$1" worktree remove --force "$dir/wt" >/dev/null 2>&1 + rm -rf "$dir" + fi fi echo "$1" } @@ -139,7 +145,8 @@ run_gates() ( [ "$(printf '%s\n' "$tips" | grep -c .)" -eq 1 ] || tips= gate_root=$(gate_root_for "$repo_root" "$tips") if [ "$gate_root" != "$repo_root" ]; then - trap 'git -C "$repo_root" worktree remove --force "$gate_root" >/dev/null 2>&1; rm -rf "$gate_root"' EXIT + trap 'git -C "$repo_root" worktree remove --force "$gate_root" >/dev/null 2>&1; rm -rf "$(dirname "$gate_root")"' EXIT + trap 'exit 130' INT TERM echo "pre-push: the gates run on a local checkout of $tips, because the repository is on a network share." cd "$gate_root" || return 1 runner="$gate_root/.claude/skills/ai-sdlc-gates/scripts/Invoke-LocalGates.ps1" diff --git a/apm.lock.yaml b/apm.lock.yaml index 5fbe5c8..da66bbe 100644 --- a/apm.lock.yaml +++ b/apm.lock.yaml @@ -331,7 +331,7 @@ dependencies: .claude/skills/ai-sdlc-gates/scripts/gitleaks-rules.json: sha256:6a8a75c5dbcf2378a1c52d046e34ce275aac7ce08a0ae61408d25c18e1e27014 .claude/skills/ai-sdlc-gates/scripts/gitleaks-version.json: sha256:c54acb854f87a1bbdf0e90c670b72b5de3cd37f7e460d82eca599c3c7af23a84 .claude/skills/ai-sdlc-gates/skill-catalog.json: sha256:5537684656bf189a740ba7e9e7050083af05668d00501ce1e9c6909cb8b91203 - .claude/skills/ai-sdlc-gates/sync-manifest.json: sha256:51eb177707092c6d1b8d3fd2663429fb85c9bd5748bed4269f7699985af56d2b + .claude/skills/ai-sdlc-gates/sync-manifest.json: sha256:fff5affc81314bb5c2391de0f077154e271c558f9eaa59fea0e9b0bfecc02462 .claude/skills/ai-sdlc-handbook/SKILL.md: sha256:548e6b9ad79d3d2afa2f5779835988eeb12c49cda08917c4bbaa9ac0486a47a0 .claude/skills/ai-sdlc-handbook/references/README.md: sha256:654afcaa2b81f560eff93dbdef521b09ced06137a1dbb85d70a4e14ef7502248 .claude/skills/ai-sdlc-handbook/references/artifact-graph.md: sha256:d7ddfe20e5ee6565bcf25f9cef0f578da2a4ab1590033d791b8814d4688fd1f0 @@ -358,7 +358,7 @@ dependencies: .claude/skills/ai-sdlc-hooks/githooks/post-commit: sha256:4f73a74133b0272725117fa9d962353abb6ed98d9cf5e731cd212fd5ace23271 .claude/skills/ai-sdlc-hooks/githooks/post-merge: sha256:b9f1f47cd3894406451e00c177912baeed66470b0cc18d581a5461330c7c0868 .claude/skills/ai-sdlc-hooks/githooks/post-rewrite: sha256:b7ee1a97b08a9826678829b6c49457fdc4b5ebd53eaf8cdd70f33d26e61c4a79 - .claude/skills/ai-sdlc-hooks/githooks/pre-push: sha256:e3e6a13cdaaa14c10676d6519e0665d31b7c3a401fca7e5d7ce3180db43989cd + .claude/skills/ai-sdlc-hooks/githooks/pre-push: sha256:54c273622626f944f1ffc1285c747b42d4c8a56e778aeba5744c971b13a294c6 .claude/skills/ai-sdlc-hooks/scripts/AiSdlcSetup.Tests.ps1: sha256:004bc7f1a68e953c8e657b49e74755b69a14138dfb0db61162ab15420f2b24be .claude/skills/ai-sdlc-hooks/scripts/AiSdlcSetup.ps1: sha256:b3569de6e27c3dcaffbc082311e6882bd722d440e5e855245da2410033202c7e .claude/skills/ai-sdlc-hooks/scripts/Deny-AgentMerge.Tests.ps1: sha256:4c4e1f6b673671125290d78815c72277665a8a618b55fd589f75f3a36e3b80aa @@ -1551,7 +1551,7 @@ deployments: owners: - ./core active_owner: ./core - content_hash: sha256:51eb177707092c6d1b8d3fd2663429fb85c9bd5748bed4269f7699985af56d2b + content_hash: sha256:fff5affc81314bb5c2391de0f077154e271c558f9eaa59fea0e9b0bfecc02462 - kind: project-relative target: claude value: .claude/skills/ai-sdlc-handbook @@ -1812,7 +1812,7 @@ deployments: owners: - ./core active_owner: ./core - content_hash: sha256:e3e6a13cdaaa14c10676d6519e0665d31b7c3a401fca7e5d7ce3180db43989cd + content_hash: sha256:54c273622626f944f1ffc1285c747b42d4c8a56e778aeba5744c971b13a294c6 - kind: project-relative target: claude value: .claude/skills/ai-sdlc-hooks/scripts/AiSdlcSetup.Tests.ps1 diff --git a/core/.apm/skills/ai-sdlc-gates/sync-manifest.json b/core/.apm/skills/ai-sdlc-gates/sync-manifest.json index d19940b..c0af785 100644 --- a/core/.apm/skills/ai-sdlc-gates/sync-manifest.json +++ b/core/.apm/skills/ai-sdlc-gates/sync-manifest.json @@ -130,7 +130,7 @@ ".claude/skills/ai-sdlc-hooks/githooks/post-commit": "f18058f9a38efc164e13801d61bb05329a056109", ".claude/skills/ai-sdlc-hooks/githooks/post-merge": "bb373f33abd09294cda55d7fc4499f32672eb372", ".claude/skills/ai-sdlc-hooks/githooks/post-rewrite": "e4c187dffeeaba569901f3424fae476b17c14927", - ".claude/skills/ai-sdlc-hooks/githooks/pre-push": "63ac41677c2bd605920ee5ba4b5719e60276e154", + ".claude/skills/ai-sdlc-hooks/githooks/pre-push": "73b10f0197b87c9311542cbb93627c116aa28788", ".claude/skills/ai-sdlc-hooks/scripts/AiSdlcSetup.ps1": "52ffd325d13cd403e7bfea0de8098c530c129b65", ".claude/skills/ai-sdlc-hooks/scripts/AiSdlcSetup.Tests.ps1": "ef5b30f0811181462d354a61d3e64c19f0c305e2", ".claude/skills/ai-sdlc-hooks/scripts/Deny-AgentMerge.ps1": "535543b86886fcc582912ded5373b0bd3d756356", diff --git a/core/.apm/skills/ai-sdlc-hooks/githooks/pre-push b/core/.apm/skills/ai-sdlc-hooks/githooks/pre-push index 63ac416..73b10f0 100755 --- a/core/.apm/skills/ai-sdlc-hooks/githooks/pre-push +++ b/core/.apm/skills/ai-sdlc-hooks/githooks/pre-push @@ -95,12 +95,18 @@ gate_root_for() { if is_network_path "$1"; then want=1; else want=0; fi fi if [ "$want" = 1 ] && [ -n "$2" ]; then - dir=$(mktemp -d 2>/dev/null) && rmdir "$dir" && - git -C "$1" worktree add --quiet --detach "$dir" "$2" >/dev/null 2>&1 && { - if [ -f "$dir/.claude/skills/ai-sdlc-gates/scripts/Invoke-LocalGates.ps1" ]; then echo "$dir"; return 0; fi - git -C "$1" worktree remove --force "$dir" >/dev/null 2>&1 - rm -rf "$dir" - } + # The checkout goes in a subfolder of the private (0700) temp folder, so no other user can put + # anything in its place. + dir=$(mktemp -d 2>/dev/null) || dir= + if [ -n "$dir" ]; then + if git -C "$1" worktree add --quiet --detach "$dir/wt" "$2" >/dev/null 2>&1 && + [ -f "$dir/wt/.claude/skills/ai-sdlc-gates/scripts/Invoke-LocalGates.ps1" ]; then + echo "$dir/wt" + return 0 + fi + git -C "$1" worktree remove --force "$dir/wt" >/dev/null 2>&1 + rm -rf "$dir" + fi fi echo "$1" } @@ -139,7 +145,8 @@ run_gates() ( [ "$(printf '%s\n' "$tips" | grep -c .)" -eq 1 ] || tips= gate_root=$(gate_root_for "$repo_root" "$tips") if [ "$gate_root" != "$repo_root" ]; then - trap 'git -C "$repo_root" worktree remove --force "$gate_root" >/dev/null 2>&1; rm -rf "$gate_root"' EXIT + trap 'git -C "$repo_root" worktree remove --force "$gate_root" >/dev/null 2>&1; rm -rf "$(dirname "$gate_root")"' EXIT + trap 'exit 130' INT TERM echo "pre-push: the gates run on a local checkout of $tips, because the repository is on a network share." cd "$gate_root" || return 1 runner="$gate_root/.claude/skills/ai-sdlc-gates/scripts/Invoke-LocalGates.ps1" From 276c38febb4b695ded68eab069abfce59af02308 Mon Sep 17 00:00:00 2001 From: Rob Hofmann Date: Mon, 9 Nov 2026 22:36:18 +0100 Subject: [PATCH 4/4] Shorten the network share sentence in the hooks skill Refs #20 --- .claude/skills/ai-sdlc-gates/sync-manifest.json | 2 +- .claude/skills/ai-sdlc-hooks/SKILL.md | 2 +- apm.lock.yaml | 8 ++++---- core/.apm/skills/ai-sdlc-gates/sync-manifest.json | 2 +- core/.apm/skills/ai-sdlc-hooks/SKILL.md | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.claude/skills/ai-sdlc-gates/sync-manifest.json b/.claude/skills/ai-sdlc-gates/sync-manifest.json index c0af785..e00a756 100644 --- a/.claude/skills/ai-sdlc-gates/sync-manifest.json +++ b/.claude/skills/ai-sdlc-gates/sync-manifest.json @@ -161,7 +161,7 @@ ".claude/skills/ai-sdlc-hooks/scripts/Update-AiSdlc.Tests.ps1": "8db305e438bc7ee404eb5106eacbe5581738f148", ".claude/skills/ai-sdlc-hooks/scripts/WindowsLongPaths.ps1": "fa3d7f509b6f9a1a935178c1eaf0d1566b7afead", ".claude/skills/ai-sdlc-hooks/scripts/WindowsLongPaths.Tests.ps1": "21a220ca2ccc65a56ec427a6e74c5a5dbfbfd4ef", - ".claude/skills/ai-sdlc-hooks/SKILL.md": "97369efdaee66b9d0e37553a1a70066716faa1f6", + ".claude/skills/ai-sdlc-hooks/SKILL.md": "774efd3863941a94682a7c8dcf3573280d173790", ".claude/skills/capture-learning/SKILL.md": "32300ce3189109b0d717f975623e8d7ccec1c821", ".claude/skills/convene-personas/SKILL.md": "449708a02206bec35a83d2f48ca6366c8b78e3a2", ".claude/skills/docs-wiki-conventions/SKILL.md": "0679512fa39815b63da6373ff29bb6eadc52ff24", diff --git a/.claude/skills/ai-sdlc-hooks/SKILL.md b/.claude/skills/ai-sdlc-hooks/SKILL.md index 97369ef..774efd3 100644 --- a/.claude/skills/ai-sdlc-hooks/SKILL.md +++ b/.claude/skills/ai-sdlc-hooks/SKILL.md @@ -42,7 +42,7 @@ The dotnet pack adds one more: `Deny-StaleGraphQuery.ps1` in `dotnet-code-graph` (`Test-PushReceipt.ps1` in `ai-sdlc-gates`). The pre-flight ran the same gates on that content, and the pull request build still runs them. A push that only deletes refs, or whose commits the remote already has, runs no gate at all. Only the refs of the remote being pushed to count. Both - push hooks judge this with one rule, `Test-PushSendsNothingNew` in `PreflightReceipt.psm1`. It also shows the change-completeness report, which is advisory and never fails the push. When the repository is on a network share and one commit is pushed, the gates run on a local checkout of that commit, which is much faster. Last, it + push hooks judge this with one rule, `Test-PushSendsNothingNew` in `PreflightReceipt.psm1`. It also shows the change-completeness report, which is advisory and never fails the push. On a network share, the gates run on a local checkout of the pushed commit, which is much faster. Last, it hands the same ref lines on to `git lfs pre-push`, so the LFS objects are uploaded. The other hooks refresh the code graph, and do nothing when the graph tooling is absent. - `githooks/git-lfs-hook` is shared by `pre-push`, `post-checkout`, `post-commit` and `post-merge`. diff --git a/apm.lock.yaml b/apm.lock.yaml index da66bbe..cb389b3 100644 --- a/apm.lock.yaml +++ b/apm.lock.yaml @@ -331,7 +331,7 @@ dependencies: .claude/skills/ai-sdlc-gates/scripts/gitleaks-rules.json: sha256:6a8a75c5dbcf2378a1c52d046e34ce275aac7ce08a0ae61408d25c18e1e27014 .claude/skills/ai-sdlc-gates/scripts/gitleaks-version.json: sha256:c54acb854f87a1bbdf0e90c670b72b5de3cd37f7e460d82eca599c3c7af23a84 .claude/skills/ai-sdlc-gates/skill-catalog.json: sha256:5537684656bf189a740ba7e9e7050083af05668d00501ce1e9c6909cb8b91203 - .claude/skills/ai-sdlc-gates/sync-manifest.json: sha256:fff5affc81314bb5c2391de0f077154e271c558f9eaa59fea0e9b0bfecc02462 + .claude/skills/ai-sdlc-gates/sync-manifest.json: sha256:547a69750aed8c4ff59aed2ad698dc7e9a52414a2e301ce6a7468a192938960e .claude/skills/ai-sdlc-handbook/SKILL.md: sha256:548e6b9ad79d3d2afa2f5779835988eeb12c49cda08917c4bbaa9ac0486a47a0 .claude/skills/ai-sdlc-handbook/references/README.md: sha256:654afcaa2b81f560eff93dbdef521b09ced06137a1dbb85d70a4e14ef7502248 .claude/skills/ai-sdlc-handbook/references/artifact-graph.md: sha256:d7ddfe20e5ee6565bcf25f9cef0f578da2a4ab1590033d791b8814d4688fd1f0 @@ -350,7 +350,7 @@ dependencies: .claude/skills/ai-sdlc-handbook/references/personas.md: sha256:7913c3dca6bad93b45624349a12bf976f894eb6ca05c7baa1fa7e3ba802ca69a .claude/skills/ai-sdlc-handbook/references/plan.md: sha256:b632fe2da2369f494ebe2606c4bdc8726eabe3b7615b6ddb0b58fa9b3897a216 .claude/skills/ai-sdlc-handbook/references/skill-usage.md: sha256:9d5414b38d9d6f5bd7dfa9857e8e441bf040b0020f46ac8d3b29b0a476161c61 - .claude/skills/ai-sdlc-hooks/SKILL.md: sha256:b52458622c91cdf4a706a9a70878bb192e9b9f950c53639c4121ce6c5c51e6e8 + .claude/skills/ai-sdlc-hooks/SKILL.md: sha256:a48437ae3951181a44fa32032e8f94dec686fe4d4339c84fa8089c60ace4ef89 .claude/skills/ai-sdlc-hooks/gates.json: sha256:dfc8b0003e930167e0fccc366867f423bc0850f3c69477c0e7119aed710bf902 .claude/skills/ai-sdlc-hooks/githooks/git-lfs-hook: sha256:3265310500749e7181a5625517f94e2efa62d48be987ebc9b0396d38e2eeffa6 .claude/skills/ai-sdlc-hooks/githooks/graphify-refresh: sha256:1bc6c7f181aab3a0fdd34bf8907a4884bea2412a56ebdc77a673707e17c046f3 @@ -1551,7 +1551,7 @@ deployments: owners: - ./core active_owner: ./core - content_hash: sha256:fff5affc81314bb5c2391de0f077154e271c558f9eaa59fea0e9b0bfecc02462 + content_hash: sha256:547a69750aed8c4ff59aed2ad698dc7e9a52414a2e301ce6a7468a192938960e - kind: project-relative target: claude value: .claude/skills/ai-sdlc-handbook @@ -1740,7 +1740,7 @@ deployments: owners: - ./core active_owner: ./core - content_hash: sha256:b52458622c91cdf4a706a9a70878bb192e9b9f950c53639c4121ce6c5c51e6e8 + content_hash: sha256:a48437ae3951181a44fa32032e8f94dec686fe4d4339c84fa8089c60ace4ef89 - kind: project-relative target: claude value: .claude/skills/ai-sdlc-hooks/gates.json diff --git a/core/.apm/skills/ai-sdlc-gates/sync-manifest.json b/core/.apm/skills/ai-sdlc-gates/sync-manifest.json index c0af785..e00a756 100644 --- a/core/.apm/skills/ai-sdlc-gates/sync-manifest.json +++ b/core/.apm/skills/ai-sdlc-gates/sync-manifest.json @@ -161,7 +161,7 @@ ".claude/skills/ai-sdlc-hooks/scripts/Update-AiSdlc.Tests.ps1": "8db305e438bc7ee404eb5106eacbe5581738f148", ".claude/skills/ai-sdlc-hooks/scripts/WindowsLongPaths.ps1": "fa3d7f509b6f9a1a935178c1eaf0d1566b7afead", ".claude/skills/ai-sdlc-hooks/scripts/WindowsLongPaths.Tests.ps1": "21a220ca2ccc65a56ec427a6e74c5a5dbfbfd4ef", - ".claude/skills/ai-sdlc-hooks/SKILL.md": "97369efdaee66b9d0e37553a1a70066716faa1f6", + ".claude/skills/ai-sdlc-hooks/SKILL.md": "774efd3863941a94682a7c8dcf3573280d173790", ".claude/skills/capture-learning/SKILL.md": "32300ce3189109b0d717f975623e8d7ccec1c821", ".claude/skills/convene-personas/SKILL.md": "449708a02206bec35a83d2f48ca6366c8b78e3a2", ".claude/skills/docs-wiki-conventions/SKILL.md": "0679512fa39815b63da6373ff29bb6eadc52ff24", diff --git a/core/.apm/skills/ai-sdlc-hooks/SKILL.md b/core/.apm/skills/ai-sdlc-hooks/SKILL.md index 97369ef..774efd3 100644 --- a/core/.apm/skills/ai-sdlc-hooks/SKILL.md +++ b/core/.apm/skills/ai-sdlc-hooks/SKILL.md @@ -42,7 +42,7 @@ The dotnet pack adds one more: `Deny-StaleGraphQuery.ps1` in `dotnet-code-graph` (`Test-PushReceipt.ps1` in `ai-sdlc-gates`). The pre-flight ran the same gates on that content, and the pull request build still runs them. A push that only deletes refs, or whose commits the remote already has, runs no gate at all. Only the refs of the remote being pushed to count. Both - push hooks judge this with one rule, `Test-PushSendsNothingNew` in `PreflightReceipt.psm1`. It also shows the change-completeness report, which is advisory and never fails the push. When the repository is on a network share and one commit is pushed, the gates run on a local checkout of that commit, which is much faster. Last, it + push hooks judge this with one rule, `Test-PushSendsNothingNew` in `PreflightReceipt.psm1`. It also shows the change-completeness report, which is advisory and never fails the push. On a network share, the gates run on a local checkout of the pushed commit, which is much faster. Last, it hands the same ref lines on to `git lfs pre-push`, so the LFS objects are uploaded. The other hooks refresh the code graph, and do nothing when the graph tooling is absent. - `githooks/git-lfs-hook` is shared by `pre-push`, `post-checkout`, `post-commit` and `post-merge`.