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
28 changes: 28 additions & 0 deletions .claude/skills/ai-sdlc-gates/scripts/AiSdlcConfig.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,34 @@ Describe 'AiSdlcConfig' {
@($config.dotnet.Keys) | Should -Not -Contain 'docGeneratorEndpoint'
}

It 'refuses a push to the trunk unless git.allowTrunkPush is the JSON value true' -ForEach @(
@{ Json = $null; Expected = $false }
@{ Json = '{}'; Expected = $false }
@{ Json = '{ "git": { "allowTrunkPush": false } }'; Expected = $false }
@{ Json = '{ "git": { "allowTrunkPush": "true" } }'; Expected = $false }
@{ Json = '{ "git": { "allowTrunkPush": 1 } }'; Expected = $false }
@{ Json = '{ "git": { "allowTrunkPush": true } }'; Expected = $true }
) {
Test-AiSdlcTrunkPushAllowed -RepoRoot (New-ConfigRepo -Json $Json -Git) | Should -Be $Expected
}

It 'reads git.allowTrunkPush from the commit that -Ref names, not from the working tree' {
$root = New-ConfigRepo -Json '{ "git": { "allowTrunkPush": true } }' -Git
git -C $root config user.email probe@example.invalid
git -C $root config user.name probe
git -C $root add aisdlc.json
git -C $root commit --quiet -m on --no-verify
git -C $root update-ref refs/remotes/origin/main HEAD
Set-Content -LiteralPath (Join-Path $root 'aisdlc.json') -Value '{}'
git -C $root commit --quiet -am off --no-verify
git -C $root update-ref refs/remotes/origin/master HEAD
Set-Content -LiteralPath (Join-Path $root 'aisdlc.json') -Value '{ "git": { "allowTrunkPush": true } }'

Test-AiSdlcTrunkPushAllowed -RepoRoot $root -Ref 'refs/remotes/origin/main' | Should -BeTrue
Test-AiSdlcTrunkPushAllowed -RepoRoot $root -Ref 'refs/remotes/origin/master' | Should -BeFalse
Test-AiSdlcTrunkPushAllowed -RepoRoot $root -Ref 'refs/remotes/origin/missing' | Should -BeFalse
}

It 'reads the other repositories whose issues a pull request may name from tracker.acceptedRepositories' {
$config = Get-AiSdlcConfig -RepoRoot (New-ConfigRepo -Json '{ "tracker": { "acceptedRepositories": ["contoso/ai-sdlc"] } }')

Expand Down
30 changes: 29 additions & 1 deletion .claude/skills/ai-sdlc-gates/scripts/AiSdlcConfig.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ $script:Defaults = [ordered]@{
secretScan = [ordered]@{
allowPaths = @()
}
git = [ordered]@{
allowTrunkPush = $false
}
tracker = [ordered]@{
repository = ''
keyPattern = ''
Expand Down Expand Up @@ -270,6 +273,31 @@ function Test-AiSdlcPack {
return @($config.packs) -contains $Name
}

function Test-AiSdlcTrunkPushAllowed {
# True only when aisdlc.json sets git.allowTrunkPush to the JSON value true. A string such as "true"
# does not count, so a typo never opens the trunk. The push hooks still refuse a delete or a force push.
# With -Ref, the file is read from that commit, not from the working tree. The push hooks pass the
# remote-tracking ref of the branch they guard, such as refs/remotes/origin/main, so a change in the
# working tree cannot switch the setting on: it counts only once it is on the remote main branch.
# A missing ref, a missing file or a file that is not valid JSON counts as false.
[CmdletBinding()]
param([string]$RepoRoot, [string]$Ref)

if ($Ref) {
if (-not $RepoRoot) { $RepoRoot = Find-AiSdlcRepoRoot }
$text = git -C $RepoRoot show "$($Ref):$($script:ConfigFileName)" 2>$null
if ($LASTEXITCODE -ne 0 -or -not $text) { return $false }
try { $values = ($text -join "`n") | ConvertFrom-Json -AsHashtable } catch { return $false }
$section = if ($values -is [System.Collections.IDictionary]) { $values['git'] } else { $null }
$value = if ($section -is [System.Collections.IDictionary]) { $section['allowTrunkPush'] } else { $null }
return ($value -is [bool]) -and $value
}

$config = Get-AiSdlcConfig -RepoRoot $RepoRoot
$value = $config.git['allowTrunkPush']
return ($value -is [bool]) -and $value
}

function Get-AiSdlcStoryPattern {
[CmdletBinding()]
param([string]$RepoRoot)
Expand Down Expand Up @@ -383,4 +411,4 @@ function Get-AiSdlcPackage {
}
}

Export-ModuleMember -Function Find-AiSdlcRepoRoot, Get-AiSdlcConfig, Get-AiSdlcPath, Test-AiSdlcPack, Get-AiSdlcStoryPattern, Get-AiSdlcBranchStoryKey, Get-AiSdlcStoryKey, ConvertTo-AiSdlcStoryKey, Get-AiSdlcPackage
Export-ModuleMember -Function Find-AiSdlcRepoRoot, Get-AiSdlcConfig, Get-AiSdlcPath, Test-AiSdlcPack, Test-AiSdlcTrunkPushAllowed,Get-AiSdlcStoryPattern, Get-AiSdlcBranchStoryKey, Get-AiSdlcStoryKey, ConvertTo-AiSdlcStoryKey, Get-AiSdlcPackage
20 changes: 10 additions & 10 deletions .claude/skills/ai-sdlc-gates/sync-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
".claude/skills/ai-sdlc-gates/assets/actions/ai-sdlc-pr/action.yml": "f80ed84d896859668d74cd47bf327a714d383f8a",
".claude/skills/ai-sdlc-gates/assets/agents-core.md": "f7e45643bf0f5447d480b588784b2c599cc7f320",
".claude/skills/ai-sdlc-gates/gates.json": "cf6f5a2d284f0b22f0f4a89292037caed3e53c19",
".claude/skills/ai-sdlc-gates/scripts/AiSdlcConfig.psm1": "afaad1b3853d71d4f1016e2f9f9df4a1ffdbc03d",
".claude/skills/ai-sdlc-gates/scripts/AiSdlcConfig.Tests.ps1": "2ad1609653980ca3bada51c7cd470e4ba6ffcbe9",
".claude/skills/ai-sdlc-gates/scripts/AiSdlcConfig.psm1": "3d3449e30e25d842f355ce74a2150775ab8b3e0d",
".claude/skills/ai-sdlc-gates/scripts/AiSdlcConfig.Tests.ps1": "e5689b5deec495e74dc991786596903d70283263",
".claude/skills/ai-sdlc-gates/scripts/apm-version.json": "fbbd8a51e60e3a7e653a35bc9b959f2bf332ab74",
".claude/skills/ai-sdlc-gates/scripts/Build-DocsIndex.ps1": "64c6d651e638b0fe15d20cde02418e8021a5cdfc",
".claude/skills/ai-sdlc-gates/scripts/Build-DocsIndex.Tests.ps1": "d9ac6b357e1fc4dbf7deacce04ec365b8515e627",
Expand Down Expand Up @@ -114,9 +114,9 @@
".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": "eaabf81a917d8b826f26318bcef7934fbbecbdfa",
".claude/skills/ai-sdlc-handbook/references/layout.md": "b6683bbb25c614a5d0a3f8283d4e46bfa110bcd2",
".claude/skills/ai-sdlc-handbook/references/node-templates.md": "580c9c92c470a6abbaa0145cc3060ff1a11d247c",
".claude/skills/ai-sdlc-handbook/references/orchestration.md": "5b6c8c38a5d17ca59cc38794a7750355c508d262",
".claude/skills/ai-sdlc-handbook/references/orchestration.md": "22373827d6ecd454d93cfb652f76c5204f3215e2",
".claude/skills/ai-sdlc-handbook/references/pattern.md": "f0f2a8cf3dac267cda0fd3783d86bddba5afc7c0",
".claude/skills/ai-sdlc-handbook/references/personas.md": "083c57f3e4e88519a9d42d7e51559c5165faacff",
".claude/skills/ai-sdlc-handbook/references/plan.md": "8c6fde8e741106f8fe625b8b9a4e98b6d5ba912f",
Expand All @@ -130,13 +130,13 @@
".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": "ba5d1df1483ae80b7d6a009aafdb820f3629a2e3",
".claude/skills/ai-sdlc-hooks/githooks/pre-push": "490c81fd333d26cf9f09877fecb369d531710d66",
".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",
".claude/skills/ai-sdlc-hooks/scripts/Deny-AgentMerge.Tests.ps1": "c8dfc8a4f31b6ec89a6d680e936e3563afa62bcb",
".claude/skills/ai-sdlc-hooks/scripts/Deny-IncompletePush.ps1": "e3a58c32a38844707aa0b2f4c14961af3ed2c870",
".claude/skills/ai-sdlc-hooks/scripts/Deny-IncompletePush.Tests.ps1": "c7da2e83782aa42478fc3b416af5926b8bdd376c",
".claude/skills/ai-sdlc-hooks/scripts/Deny-IncompletePush.ps1": "117d527a075a78017b0a199703d84a6807797573",
".claude/skills/ai-sdlc-hooks/scripts/Deny-IncompletePush.Tests.ps1": "73947a2a69aecf0e73a11640a0c21d081d43c4d8",
".claude/skills/ai-sdlc-hooks/scripts/Deny-SharedFileEdit.ps1": "ca703a9e057633e39af161d9e43a042429813acc",
".claude/skills/ai-sdlc-hooks/scripts/Deny-SharedFileEdit.Tests.ps1": "d15bf28d4191b5e2bca8ce59621ad03a1ef6198c",
".claude/skills/ai-sdlc-hooks/scripts/Find-RetiredSkillNames.ps1": "da6172d61799df3f37c5f70a103cddddb5517cb0",
Expand All @@ -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": "10a332050267c363ee019fc1911495b8bc3bfb00",
".claude/skills/ai-sdlc-hooks/scripts/PrePushHook.Tests.ps1": "718248ded3ba695b29d4d7eb59e8f09130cf918c",
".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": "0bb9a972fbf928e359cbdfa24cc5781d43d0ab54",
".claude/skills/ai-sdlc-hooks/SKILL.md": "a5b99bcdf6bf93721136ee3a3e7075632fdf068d",
".claude/skills/capture-learning/SKILL.md": "32300ce3189109b0d717f975623e8d7ccec1c821",
".claude/skills/convene-personas/SKILL.md": "449708a02206bec35a83d2f48ca6366c8b78e3a2",
".claude/skills/docs-wiki-conventions/SKILL.md": "0679512fa39815b63da6373ff29bb6eadc52ff24",
Expand Down Expand Up @@ -399,7 +399,7 @@
".claude/skills/github-pull-requests/scripts/Update-PullRequest.Tests.ps1": "f63886f04b76fdddda7b23dd886586fb04317194",
".claude/skills/github-pull-requests/scripts/Wait-WorkflowRun.ps1": "27fd4ca10468eb3fecd2580f2f1e493fd115ae9d",
".claude/skills/github-pull-requests/scripts/Wait-WorkflowRun.Tests.ps1": "3cf5da073805761e52b2af1ea7399e71584ee342",
".claude/skills/github-pull-requests/SKILL.md": "c2d1d10ae6721687e84a21c5bee71d1332387b76",
".claude/skills/github-pull-requests/SKILL.md": "c42530e8588f05881da325e74a57eb79ae80fe1c",
".claude/skills/write-pipeline/examples/infrastructure/pr.yml": "b3758e9bae5a9c5dec006af329218e2e23244a78",
".claude/skills/write-pipeline/examples/infrastructure/release.yml": "967c35ded6d96c0b881b89a6ef9599960f001719",
".claude/skills/write-pipeline/examples/web-app/build-and-test.yml": "f9155849e3229580d5e91fc8ea257275807cf220",
Expand Down
1 change: 1 addition & 0 deletions .claude/skills/ai-sdlc-handbook/references/layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +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` |
| `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-handbook/references/orchestration.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@ What stays in `.claude/settings.json` is not enforcement:
`Sync-AllowRules.ps1` writes ([layout](layout.md#allow-rules-come-from-the-packages)). A repository
may add its own rules. An allow rule only saves a person from a prompt per command.
- **the push hook** `.claude/skills/ai-sdlc-hooks/scripts/Deny-IncompletePush.ps1`, which both tools run.
It refuses a push to `main` or `master`, including a bare push while on `main`. It also refuses a
It refuses a push to `main` or `master`, including a bare push while on `main`. A repository that
sets `git.allowTrunkPush` in `aisdlc.json` may update `main` with a plain push, never a force
push or a delete. The other checks still run on that push. It also refuses a
push that leaves tests or docs behind, and a push whose commit has no green pre-flight receipt. A push
that sends nothing new needs no receipt. Each pushed ref is a delete, or its commit is already on
the remote it goes to. A release tag is an example. A branch policy on
Expand Down
7 changes: 4 additions & 3 deletions .claude/skills/ai-sdlc-hooks/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ repository root. The git hooks sit in `githooks/`, and `Initialize-AiSdlc.ps1` p

| Event | Script | What it does |
|---|---|---|
| Before a Bash or PowerShell command | `Deny-IncompletePush.ps1` | Refuses a push to `main` or `master`, a push of an unfinished change, and a push of a commit without a green pre-flight receipt. A push that sends nothing new, such as a tag on a commit the remote has or a branch delete, needs no receipt |
| Before a Bash or PowerShell command | `Deny-IncompletePush.ps1` | Refuses a push to `main` or `master` (a plain push may update it when `git.allowTrunkPush` is true), a push of an unfinished change, and a push of a commit without a green pre-flight receipt. A push that sends nothing new, such as a tag on a commit the remote has or a branch delete, needs no receipt |
| Before a Bash or PowerShell command | `Deny-AgentMerge.ps1` | Refuses `gh pr merge` and a `gh api` call to a pull request merge endpoint, so the agent never merges (clause C09). The owner's merge is the approval at Checkpoint Bravo. Like the other hooks, it lets the command through when it cannot judge it |
| Before an edit or write | `Deny-SharedFileEdit.ps1` | Refuses an edit to a file listed in `apm.lock.yaml`, and names its source in AI.SDLC |
| Before an edit or write | `Invoke-CompactSuggestionHook.ps1` | Suggests a compact at a logical boundary when the context window is full |
Expand All @@ -35,7 +35,8 @@ The dotnet pack adds one more: `Deny-StaleGraphQuery.ps1` in `dotnet-code-graph`
## The git hooks and the setup

- `githooks/pre-push` first refuses a push to `main` or `master`, the same rule as
`Deny-IncompletePush.ps1`, so it also holds for GitHub Copilot and a push from a terminal. Then it
`Deny-IncompletePush.ps1`, so it also holds for GitHub Copilot and a push from a terminal. With
`git.allowTrunkPush` it lets a fast-forward of `main` through, never a delete or a force push. Then it
runs the blocking gates, which include the doc-drift check when the dotnet pack is installed. It
skips them when a passing pre-flight receipt covers the tree of the tip commit of each pushed ref
(`Test-PushReceipt.ps1` in `ai-sdlc-gates`). The pre-flight ran the same gates on that content, and
Expand Down Expand Up @@ -90,7 +91,7 @@ The dotnet pack adds one more: `Deny-StaleGraphQuery.ps1` in `dotnet-code-graph`
## When a hook refused a step

- A push to `main` or `master` was refused: push the story branch and open or update its pull
request. A change reaches `main` only through a pull request.
request. A change reaches `main` only through a pull request, unless `git.allowTrunkPush` is set.
- Any other push was refused: run `wrap-up`. It commits the change and ends with the pre-flight on
that commit. Never push with `--no-verify`.
- The push check judges the repository the push targets. A push that names no folder is judged on
Expand Down
Loading
Loading