Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .claude/skills/ai-sdlc-gates/sync-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
".claude/skills/ai-sdlc-handbook/references/docs-wiki.md": "038477c9b704a5b545decfe5e3f3f9970d8d1f9d",
".claude/skills/ai-sdlc-handbook/references/first-story.md": "be899eb395dafb2d704b8f0cb46bac1fb5e593c8",
".claude/skills/ai-sdlc-handbook/references/language.md": "ca703edeb9e07e28e32a39fbcc9116b64db444d8",
".claude/skills/ai-sdlc-handbook/references/layout.md": "b6683bbb25c614a5d0a3f8283d4e46bfa110bcd2",
".claude/skills/ai-sdlc-handbook/references/layout.md": "69e6a7345ca838eb224aa1bc6e093f3699c9a28c",
".claude/skills/ai-sdlc-handbook/references/node-templates.md": "580c9c92c470a6abbaa0145cc3060ff1a11d247c",
".claude/skills/ai-sdlc-handbook/references/orchestration.md": "22373827d6ecd454d93cfb652f76c5204f3215e2",
".claude/skills/ai-sdlc-handbook/references/pattern.md": "f0f2a8cf3dac267cda0fd3783d86bddba5afc7c0",
Expand All @@ -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": "490c81fd333d26cf9f09877fecb369d531710d66",
".claude/skills/ai-sdlc-hooks/githooks/pre-push": "2e0d36443dbfbff57e4b8bddece5ca4f75fc7992",
".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",
Expand All @@ -156,7 +156,7 @@
".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": "718248ded3ba695b29d4d7eb59e8f09130cf918c",
".claude/skills/ai-sdlc-hooks/scripts/PrePushHook.Tests.ps1": "b39aacfa62f188fee2455b85f00e259bfe509c87",
".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",
Expand Down Expand Up @@ -425,8 +425,8 @@
".claude/skills/check-pr-contract/scripts/Check-PrStoryContract.Tests.ps1": "0ede5de0d5b3075c6c77ade9889e8b221fbf5d2e",
".claude/skills/check-pr-contract/scripts/Check-StoryBackEdges.ps1": "bf4281ad4dfaf0409954ca163e306fee4458de76",
".claude/skills/check-pr-contract/scripts/Check-StoryBackEdges.Tests.ps1": "8c022a6a71e2890486ded5461c31531acfeb2350",
".claude/skills/check-pr-contract/scripts/Invoke-IssuePreflight.ps1": "21dd90b6929fe9129e537b7c609cb4a0afc996c7",
".claude/skills/check-pr-contract/scripts/Invoke-IssuePreflight.Tests.ps1": "a0cda3adda6acb74bcc30cdbe5126891e9d68e10",
".claude/skills/check-pr-contract/scripts/Invoke-IssuePreflight.ps1": "8c88138ef4cccf10cfe293b48ceaad2fead4cf71",
".claude/skills/check-pr-contract/scripts/Invoke-IssuePreflight.Tests.ps1": "8a16f579a336c64db5fbcb21dd1f0ff814a87549",
".claude/skills/check-pr-contract/SKILL.md": "5d8173088d1434642bfe734ae8afbf201c8ec8b1",
".claude/skills/fix-bug/SKILL.md": "9928171978b34ac58a94fd076e2202f3fe53a997",
".claude/skills/github-issue-conventions/SKILL.md": "6a24729d513512df9399c9fc8570685f9369253d",
Expand Down
2 changes: 1 addition & 1 deletion .claude/skills/ai-sdlc-handbook/references/layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ installs. `AiSdlcConfig.psm1` takes each dependency whose path ends in `packs/<n
| `paths.preflightReceipts` | Where the pre-flight writes its receipts. The setup makes git ignore a folder outside `temp/` too, with a rule from the root such as `/out/`. | `temp/preflight` |
| `paths.sourceExtensions` / `paths.sourceDocMap` | The source files the change check watches, and the docs each source folder maps to | none |
| `secretScan.allowPaths` | Regular expressions on file paths that the secret scan skips: files that hold secrets on purpose, because the application needs them there. The pre-flight, the C03 gate and a new baseline all skip them. A skipped path is never scanned, so use the narrowest pattern that works, such as `^\.runtime/`. The repository decides what it skips. The scan only refuses a pattern with a quote or a control character, or one that is not a valid regular expression. | none |
| `git.allowTrunkPush` | `true` lets this repository update `main` or `master` with a plain push, without a pull request. It fits a repository whose changes are tested on the running system before they are committed. Both push hooks still refuse a delete and a force push of `main`, and the blocking gates still run. Only the JSON value `true` counts, and only in `aisdlc.json` of the commit that is the tip of the remote `main` branch, so the change that turns it on goes through a pull request first. | `false` |
| `git.allowTrunkPush` | `true` lets this repository update `main` or `master` with a plain push, without a pull request. It fits a repository whose changes are tested on the running system before they are committed. Both push hooks still refuse a delete and a force push of `main`, and the blocking gates still run. Only the JSON value `true` counts, and only in `aisdlc.json` of the commit that is the tip of the remote `main` branch, so the change that turns it on goes through a pull request first. On `main`, the pre-flight then skips the issue-contract row, because such a change has no story. | `false` |
| `paths.bicepRoot` | The folder whose subfolders are the Bicep building blocks, for the `bicep` pack | `building-blocks` |
| `paths.platformKnowledge` | The folder of the platform knowledge notes, for the `knowledge` pack | `docs/platform-knowledge` |
| `paths.knowledgeRoot` | The clone of the knowledge repository, next to this repository. `walk-substrate` and `guide-me` read it when it is there; CI never reads it | `../Knowledge` |
Expand Down
4 changes: 3 additions & 1 deletion .claude/skills/ai-sdlc-hooks/githooks/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@
# learns that commit from the remote while it pushes and passes it on stdin as <remote sha>, so neither
# an edit in the working tree nor a local ref can switch the setting on. A new branch (zero sha) or a tip
# that is not in this clone counts as off. $1 is that remote sha.
# core.hooksPath is relative, so $0 and the module path can be relative to the repository root, where git
# starts the hook. Import-Module reads a bare relative path as a module name, so the path is resolved first.
trunk_push_allowed() {
is_zero_sha "$1" && return 1
git cat-file -e "$1^{commit}" 2>/dev/null || return 1
command -v pwsh >/dev/null 2>&1 || return 1
module="$(dirname "$0")/../../ai-sdlc-gates/scripts/AiSdlcConfig.psm1"
[ -f "$module" ] || return 1
AISDLC_CONFIG_MODULE="$module" AISDLC_REPO_ROOT="$(git rev-parse --show-toplevel)" AISDLC_REF="$1" pwsh -NoProfile -NonInteractive -Command 'try { Import-Module $env:AISDLC_CONFIG_MODULE -Force; if (Test-AiSdlcTrunkPushAllowed -RepoRoot $env:AISDLC_REPO_ROOT -Ref $env:AISDLC_REF) { exit 0 } } catch { }; exit 1' >/dev/null 2>&1
AISDLC_CONFIG_MODULE="$module" AISDLC_REPO_ROOT="$(git rev-parse --show-toplevel)" AISDLC_REF="$1" pwsh -NoProfile -NonInteractive -Command 'try { Import-Module (Resolve-Path -LiteralPath $env:AISDLC_CONFIG_MODULE).ProviderPath -Force; if (Test-AiSdlcTrunkPushAllowed -RepoRoot $env:AISDLC_REPO_ROOT -Ref $env:AISDLC_REF) { exit 0 } } catch { }; exit 1' >/dev/null 2>&1
}

is_zero_sha() {
Expand Down
35 changes: 35 additions & 0 deletions .claude/skills/ai-sdlc-hooks/scripts/PrePushHook.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,41 @@ Describe 'The pre-push git hook' {
$r.Code | Should -Be 1
$r.Output | Should -Match 'a push to main is refused'
}

# Initialize-AiSdlc.ps1 sets a relative core.hooksPath, so git starts the hook with a relative $0.
# This test runs a real git push through that setup, not the hook through an absolute path.
It 'reads the setting through the relative core.hooksPath of a real git push, when it is <Name>' -Skip:($script:NoSh -or $script:NoPwshHere) -ForEach @(
@{ Name = 'on'; Json = '{ "git": { "allowTrunkPush": true } }'; Code = 0; Expect = 'allows this fast-forward of main' }
@{ Name = 'off'; Json = '{}'; Code = 1; Expect = 'a push to main is refused' }
) {
$root = Join-Path ([System.IO.Path]::GetTempPath()) ('pre-push-' + [guid]::NewGuid().ToString('n'))
$remote = "$root-remote.git"
try {
git init --quiet --bare --initial-branch main $remote
git -C (Split-Path $remote) init --quiet --initial-branch main $root
git -C $root config user.email probe@example.invalid
git -C $root config user.name probe
Set-Content -LiteralPath (Join-Path $root 'aisdlc.json') -Value $Json
git -C $root add aisdlc.json
git -C $root commit --quiet -m one --no-verify
git -C $root remote add origin $remote
git -C $root push --quiet --no-verify origin main 2>$null

$hooks = Join-Path $root '.claude' 'skills' 'ai-sdlc-hooks' 'githooks'
$gates = Join-Path $root '.claude' 'skills' 'ai-sdlc-gates' 'scripts'
New-Item -ItemType Directory -Path $hooks, $gates -Force | Out-Null
Copy-Item -Path (Join-Path $PSScriptRoot '..' 'githooks' '*') -Destination $hooks
Copy-Item -LiteralPath (Join-Path $PSScriptRoot '..' '..' 'ai-sdlc-gates' 'scripts' 'AiSdlcConfig.psm1') -Destination $gates
if (-not $IsWindows) { chmod +x (Get-ChildItem -LiteralPath $hooks).FullName }
git -C $root config core.hooksPath '.claude/skills/ai-sdlc-hooks/githooks'
git -C $root commit --quiet --allow-empty -m two --no-verify

$output = git -C $root push origin main 2>&1 | Out-String
$LASTEXITCODE | Should -Be $Code -Because $output
$output | Should -Match $Expect
}
finally { Remove-Item -LiteralPath $root, $remote -Recurse -Force -ErrorAction SilentlyContinue }
}
}

It 'never falls back to Windows PowerShell, which cannot run a gate that needs PowerShell 7' {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,27 @@ Describe 'Invoke-IssuePreflight' {
$rows[0].Detail | Should -Match 'title or body'
}

It 'returns a SKIP row on main when git.allowTrunkPush is on, and a FAIL row when it is off' {
git -C $script:Repo checkout -q -B main 2>$null
$rows = @(& $script:ScriptUnderTest -RepoRoot $script:Repo -GhCommand $script:NoGh 6>$null)
$rows[0].Status | Should -Be 'FAIL'

$config = Join-Path $script:Repo 'aisdlc.json'
$saved = Get-Content -LiteralPath $config -Raw
try {
Set-Content -LiteralPath $config -Value '{ "tracker": { "repository": "contoso/portal" }, "git": { "allowTrunkPush": true } }'
$rows = @(& $script:ScriptUnderTest -RepoRoot $script:Repo -GhCommand $script:NoGh 6>$null)
$rows.Count | Should -Be 1
$rows[0].Status | Should -Be 'SKIP'
$rows[0].Detail | Should -Match 'git.allowTrunkPush'

git -C $script:Repo checkout -q -B feature/no-key 2>$null
$rows = @(& $script:ScriptUnderTest -RepoRoot $script:Repo -GhCommand $script:NoGh 6>$null)
$rows[0].Status | Should -Be 'FAIL' -Because 'the setting only covers main and master'
}
finally { Set-Content -LiteralPath $config -Value $saved -NoNewline }
}

It 'returns NEEDS-GH for a branch that names a story key' {
git -C $script:Repo checkout -q -B 1234-a-change 2>$null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
story key (42-short-name, or the bare number 42 of a bug branch) is a FAIL row, so the pre-flight
writes no receipt, with or without gh. Set PR_STORY_KEY to name the key of a branch that cannot
carry it. Outside a git repository there is no branch, and this step is left out.
On main or master in a repository that sets git.allowTrunkPush, the row is SKIP: a change there has
no story or pull request on purpose.

When gh is installed and signed in (`gh auth status` succeeds), it runs Check-PrStoryContract.ps1
for the current branch and the changed files. Without it, it says what is needed; the same check
Expand Down Expand Up @@ -54,7 +56,11 @@ Write-Host "Issue contract (gh; the same check runs from the run-preflight skill
$branch = [string](git -C $RepoRoot rev-parse --abbrev-ref HEAD 2>$null)
# The story key needs no GitHub read, so a branch without one fails before the gh check. The branch rule
# is the one Check-PrStoryContract.ps1 uses, so both forms agree on what a key is.
if ($branch -and -not ($env:PR_STORY_KEY -or (Get-AiSdlcBranchStoryKey -Branch $branch))) {
# A repository that sets git.allowTrunkPush changes main or master directly, with no story or pull request.
if ($branch -in 'main', 'master' -and -not $env:PR_STORY_KEY -and (Test-AiSdlcTrunkPushAllowed -RepoRoot $RepoRoot)) {
[pscustomobject]@{ Check = 'IssueContract (story + ADR)'; Status = 'SKIP'; Detail = "branch '$branch' is the main branch, and git.allowTrunkPush in aisdlc.json lets a change go there without a story or pull request" }
}
elseif ($branch -and -not ($env:PR_STORY_KEY -or (Get-AiSdlcBranchStoryKey -Branch $branch))) {
[pscustomobject]@{ Check = 'IssueContract (story + ADR)'; Status = 'FAIL'; Detail = "branch '$branch' names no story key, and the pre-flight has no pull request title or body to read; start the branch name with the issue number (42-short-name), or set PR_STORY_KEY to the key" }
}
elseif (Test-GhReady) {
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.1 - 2026-11-09

- The pre-push git hook now reads `git.allowTrunkPush` when `core.hooksPath` is relative, which is how
`Initialize-AiSdlc.ps1` sets it (#18). Before, the hook could not load the config module, so it refused
every push to `main`. A new test runs a real `git push` through that setup.
- On `main` or `master` in a repository that sets `git.allowTrunkPush`, the pre-flight issue-contract row
is SKIP, not FAIL, because a change there has no story or pull request (#18).

## v1.3.0 - 2026-11-09

- A repository can set `git.allowTrunkPush` to `true` in `aisdlc.json` to update `main` or `master`
Expand Down
Loading
Loading