Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
4943b1c
feat: add governed local runner selection
kyle-sexton Jul 10, 2026
3de6b58
feat: add local runner canary conformance
kyle-sexton Jul 10, 2026
bb76239
fix: bind canary routing to reviewed selector
kyle-sexton Jul 10, 2026
9272726
feat: add bootstrappable runner canary seed
kyle-sexton Jul 10, 2026
113eb6f
fix: require canonical canary origin
kyle-sexton Jul 10, 2026
1e176cd
ci: pin hosted runner generations
kyle-sexton Jul 10, 2026
7e3e1ba
feat: add shared Pulumi deployment guard
kyle-sexton Jul 10, 2026
764a372
fix: enforce hosted workflow boundaries
kyle-sexton Jul 10, 2026
93c12f3
fix: make selector gates reproducible in CI
kyle-sexton Jul 10, 2026
9596686
fix: constrain hosted fallback labels
kyle-sexton Jul 10, 2026
b99eb6a
Merge branch 'main' into codex/local-runner-selector
kyle-sexton Jul 11, 2026
9efa3eb
fix: accept omitted runner ephemeral field
kyle-sexton Jul 11, 2026
d948779
fix: enforce runner label namespace integrity
kyle-sexton Jul 11, 2026
9d49985
fix: pin canary to corrected selector
kyle-sexton Jul 11, 2026
257f584
fix: normalize selector inventory identity
kyle-sexton Jul 11, 2026
2dfd2c9
fix: repin canary to normalized selector
kyle-sexton Jul 11, 2026
66e3e97
fix: enforce Linux runner OS namespace
kyle-sexton Jul 11, 2026
ca3c19c
fix: prove canary Linux runtime identity
kyle-sexton Jul 11, 2026
467979c
fix: pin canonical canary chain
kyle-sexton Jul 11, 2026
bef20c9
docs: cite official runner context values
kyle-sexton Jul 11, 2026
c34f0aa
docs: complete selector contamination contract
kyle-sexton Jul 11, 2026
4e2fe88
feat: add production runner HA proof
kyle-sexton Jul 11, 2026
faa53f9
feat: pin production HA proof caller
kyle-sexton Jul 11, 2026
fdf0e6e
fix: harden production HA proof reruns
kyle-sexton Jul 11, 2026
da4bec8
fix: repin production HA proof caller
kyle-sexton Jul 11, 2026
68b9f40
fix: wire governed canary cache epoch (#76)
kyle-sexton Jul 11, 2026
3fa4a44
fix: pin ShellCheck for Actionlint parity (#77)
kyle-sexton Jul 11, 2026
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
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ indent_size = 2
# Shell
[*.{sh,bash}]
indent_size = 2
switch_case_indent = true

# Windows batch — cmd.exe requires CRLF.
[*.{cmd,bat}]
Expand Down
25 changes: 23 additions & 2 deletions .github/actions/actionlint/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ inputs:
SHA-256 of the linux_amd64 .tar.gz release asset for `version`. Change
together with `version`.
default: 8aca8db96f1b94770f1b0d72b6dddcb1ebb8123cb3712530b08cc387b349a3d8
shellcheck-version:
description: >-
Exact ShellCheck version used by actionlint for embedded bash/sh `run:`
scripts. Kept in lockstep with the standalone ShellCheck action.
default: 0.11.0
shellcheck-sha256:
description: >-
SHA-256 of ShellCheck's linux x86_64 release archive for
`shellcheck-version`. Change together with that version.
default: b7af85e41cc99489dcc21d66c6d5f3685138f06d34651e6d34b42ec6d54fe6f6

runs:
using: composite
Expand All @@ -36,6 +46,15 @@ runs:
ARCHIVE_MEMBER: actionlint
run: bash "$GITHUB_ACTION_PATH/../_shared/install-release.sh"

- name: Install ShellCheck for embedded scripts
shell: bash
env:
URL: https://github.com/koalaman/shellcheck/releases/download/v${{ inputs.shellcheck-version }}/shellcheck-v${{ inputs.shellcheck-version }}.linux.x86_64.tar.gz
SHA256: ${{ inputs.shellcheck-sha256 }}
BIN: shellcheck
ARCHIVE_MEMBER: shellcheck-v${{ inputs.shellcheck-version }}/shellcheck
run: bash "$GITHUB_ACTION_PATH/../_shared/install-release.sh"

- name: Lint workflows
shell: bash
env:
Expand All @@ -44,8 +63,10 @@ runs:
COLOR: ${{ inputs.color }}
run: |
set -euo pipefail
# shellcheck/pyflakes are auto-detected on PATH (ubuntu-latest ships
# shellcheck), so embedded run: scripts are linted too.
# ShellCheck is installed above instead of relying on a runner image, so
# embedded bash/sh `run:` scripts receive identical checks on hosted and
# self-hosted workers. Pyflakes remains actionlint's optional PATH-based
# integration; neither supported runner contract preinstalls it.
args=()
if [[ "$COLOR" == "true" ]]; then args+=(-color); fi
if [[ -n "${CONFIG_FILE// }" ]]; then args+=(-config-file "$CONFIG_FILE"); fi
Expand Down
12 changes: 12 additions & 0 deletions .github/actions/actionlint/fixtures/shellcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: intentional-actionlint-shellcheck-fixture

on: push

jobs:
fixture:
runs-on: ubuntu-24.04
steps:
- name: Intentional unquoted expansion
env:
FIXTURE_VALUE: two words
run: printf '%s\n' $FIXTURE_VALUE
134 changes: 33 additions & 101 deletions .github/actions/powershell/Invoke-Pssa.ps1
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#Requires -Version 7.4
<#
.SYNOPSIS
Run PSScriptAnalyzer over PowerShell files with per-file subprocess isolation.
Run PSScriptAnalyzer over PowerShell files with fail-closed error handling.

.DESCRIPTION
Lints .ps1/.psm1 files against a PSScriptAnalyzerSettings.psd1 ruleset. Each
file is analyzed in a fresh pwsh subprocess to sidestep an intermittent
NullReferenceException in PSScriptAnalyzer's CommandInfoCache that surfaces
when many files are analyzed in one process (PSScriptAnalyzer issue #1708).
Lints .ps1/.psm1 files exactly once against a
PSScriptAnalyzerSettings.psd1 ruleset. Findings and analyzer/engine errors
are separate failure classes; neither is retried or suppressed.

With no -Path, discovery is git-tracked: only *.ps1/*.psm1 files tracked by
git are analyzed, so ignored or generated scripts in a dirty tree are never
Expand All @@ -27,7 +26,7 @@
next to this script.

.PARAMETER AnalyzerVersion
Required minimum PSScriptAnalyzer version. Default 1.25.0, which resolves an
Required exact PSScriptAnalyzer version. Default 1.25.0, which resolves an
Import-Module assembly-version mismatch on newer pwsh 7.4.x
(PSScriptAnalyzer issue #2106 / PR #2107).

Expand All @@ -45,24 +44,13 @@
or no files to analyze when -FailOnNoFiles is not set.
Exit 1: findings present (printed to the host), or no files found when
-FailOnNoFiles is set.
Exit 2: configuration error, a non-transient analysis failure, or the
transient PSScriptAnalyzer #1708 race that reproduced on every retry.
Exit 2: configuration or analyzer/engine failure.

.NOTES
PSScriptAnalyzer #1708: the UseCorrectCasing rule reads CommandInfo.Parameters
off the pipeline thread, hitting an intermittent PowerShell runspace-affinity
crash. It is unfixed upstream through 1.25.0 and is intra-rule, so per-file
subprocess isolation cannot fully clear it. The race surfaces under several
exception types — NullReferenceException, InvalidOperationException, and (when
the crashed runspace loses its core cmdlets) CommandNotFoundException, i.e.
"The term 'Get-Command' is not recognized". So each per-file child keys on the
FullyQualifiedErrorId ('RULE_ERROR*'), not the exception type: a rule that
throws is always a tooling crash, never a real finding, so any RULE_ERROR is
classified exit 3 and the parent retries it on a fresh subprocess up to a
bounded count, then hard-fails — never masking it. Findings
(success stream) and crashes (error stream) are disjoint, so the retry can
never reclassify or drop a real finding; non-rule errors (parse, bad settings)
carry a different FullyQualifiedErrorId and fail fast.
Upstream issue #1708 makes PSUseCorrectCasing intermittently crash the
analyzer. Policy owners should leave that rule disabled until an official
release fixes it. This runner treats every rule/engine error as a failed
analysis instead of maintaining a second retry implementation.
#>
[CmdletBinding()]
param(
Expand Down Expand Up @@ -105,10 +93,10 @@ function Test-PathExcluded {
# Self-skip when the analyzer is unavailable (a contributor box without it).
# CI is the authoritative gate; a missing analyzer must not hard-fail local hooks.
$module = Get-Module -ListAvailable -Name PSScriptAnalyzer |
Where-Object { $_.Version -ge [version]$AnalyzerVersion } |
Where-Object { $_.Version -eq [version]$AnalyzerVersion } |
Select-Object -First 1
if (-not $module) {
Write-Warning "PSScriptAnalyzer >= $AnalyzerVersion not installed — skipping (CI is the authoritative gate)."
Write-Warning "PSScriptAnalyzer $AnalyzerVersion not installed — skipping (CI is the authoritative gate)."
exit 0
}

Expand Down Expand Up @@ -176,93 +164,37 @@ if ($files.Count -eq 0) {
}

$findingCount = 0
# Bounded retry for the transient #1708 race (see .NOTES). The race is
# intermittent and intra-rule; a fresh subprocess almost always clears it. Only
# the exact transient signature (child exit 3) is retried — real failures fail
# fast, and exhausting the budget hard-fails so a persistent crash is exposed.
# Retries cost nothing unless a crash actually occurs. The measured per-attempt
# rate on a cmdlet-heavy file is ~12%, so 8 attempts leave a < 1-in-a-million
# residual even at a pessimistic CI rate, while a deterministic crash still fails.
$maxAttempts = 8
# If a runner enables the PSNativeCommandUseErrorActionPreference experimental
# feature, a non-zero child exit would throw under ErrorActionPreference=Stop
# before $LASTEXITCODE is read. Opt out so the exit code is always captured.
$PSNativeCommandUseErrorActionPreference = $false
foreach ($file in $files) {
$env:PSSA_FILE = $file
$env:PSSA_SETTINGS = $Settings
$env:PSSA_VERSION = $AnalyzerVersion
$output = $null
$childExit = -1
for ($attempt = 1; $attempt -le $maxAttempts; $attempt++) {
# Single-quoted here-string: variables expand in the child from its
# inherited environment, not here. The child classifies its own outcome
# off the error stream: 0 clean, 1 findings, 2 real error, 3 transient.
$output = pwsh -NoProfile -NonInteractive -Command @'
try {
Import-Module PSScriptAnalyzer -MinimumVersion $env:PSSA_VERSION -ErrorAction Stop
} catch {
[Console]::Error.WriteLine("Import-Module failed: $($_.Exception.Message)")
exit 2
}
$errs = $null
$params = @{
Path = $env:PSSA_FILE
Settings = $env:PSSA_SETTINGS
ErrorVariable = 'errs'
ErrorAction = 'SilentlyContinue'
}
try {
$findings = Invoke-ScriptAnalyzer @params
} catch [System.NullReferenceException] {
[Console]::Error.WriteLine($_.Exception.ToString())
exit 3
Import-Module PSScriptAnalyzer -RequiredVersion $AnalyzerVersion -ErrorAction Stop
} catch {
[Console]::Error.WriteLine($_.Exception.ToString())
Write-Error "Import-Module failed: $($_.Exception.Message)" -ErrorAction Continue
exit 2
}
# A rule that throws surfaces as a non-terminating ErrorRecord with
# FullyQualifiedErrorId 'RULE_ERROR'. A rule throwing is ALWAYS a tooling crash,
# never a real finding (findings are on the success stream, below), so every
# RULE_ERROR is treated as the transient #1708-family race and retried. The race
# surfaces under several exception types (NullReference/InvalidOperation, and
# CommandNotFound - "Get-Command is not recognized" - when the crashed runspace
# loses its core cmdlets), so keying on RULE_ERROR* rather than the exception type
# catches every manifestation. Any other error record (parse error, bad settings,
# ...) carries a different FullyQualifiedErrorId and is a real failure that fails fast.
$transient = @($errs | Where-Object { $_.FullyQualifiedErrorId -like 'RULE_ERROR*' })
$real = @($errs | Where-Object { $transient -notcontains $_ })
if ($real.Count -gt 0) {
$real | ForEach-Object { [Console]::Error.WriteLine($_.ToString()) }
exit 2
}
# A transient crash means the analysis was incomplete (the crashed rule did not
# run), so discard any partial findings and signal a retry rather than trust them.
if ($transient.Count -gt 0) {
[Console]::Error.WriteLine($transient[0].Exception.ToString())
exit 3
}
$findings | ForEach-Object { '{0}:{1}:{2} {3} [{4}]' -f $_.ScriptName, $_.Line, $_.Column, $_.Message, $_.RuleName }
if (@($findings).Count -gt 0) { exit 1 } else { exit 0 }
'@
$childExit = $LASTEXITCODE
if ($childExit -ne 3) { break }
Write-Warning "PSSA #1708 transient race on ${file} (attempt $attempt/$maxAttempts); retrying."

foreach ($file in $files) {
$analysisErrors = @()
$params = @{
Path = $file
Settings = $Settings
ErrorVariable = 'analysisErrors'
ErrorAction = 'SilentlyContinue'
}
if ($childExit -eq 3) {
$msg = 'PSScriptAnalyzer: the transient #1708 race reproduced on all ' +
"$maxAttempts attempts for ${file} (stack above); failing rather than masking it."
Write-Error $msg -ErrorAction Continue
try {
$findings = @(Invoke-ScriptAnalyzer @params)
} catch {
Write-Error "PSScriptAnalyzer failed for ${file}: $($_.Exception.Message)" -ErrorAction Continue
exit 2
}
if ($childExit -ne 0 -and $childExit -ne 1) {
Write-Error "PSSA subprocess failed for ${file} (exit $childExit; see stack above)." -ErrorAction Continue
if ($analysisErrors) {
$analysisErrors | ForEach-Object {
Write-Output "PSScriptAnalyzer error for ${file}: $($_.Exception.Message)"
}
exit 2
}
if ($output) {
$output | ForEach-Object { Write-Output $_ }
$findingCount += @($output).Count
$findings | ForEach-Object {
Write-Output ('{0}:{1}:{2} {3} [{4}]' -f $_.ScriptName, $_.Line, $_.Column, $_.Message, $_.RuleName)
}
$findingCount += $findings.Count
}

if ($findingCount -gt 0) {
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/powershell/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: powershell
description: Analyze PowerShell with PSScriptAnalyzer via the bundled per-file runner.
description: Analyze PowerShell exactly once per file with fail-closed PSScriptAnalyzer handling.

inputs:
paths:
Expand Down
55 changes: 55 additions & 0 deletions .github/actions/pulumi-deploy-guard/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Pulumi deployment guard

This composite action is the single pre-apply implementation shared by both
GitHub IaC repositories. Call it only after installing an exact Pulumi CLI and
exchanging the protected GitHub OIDC token, and before minting the broad GitHub
governance App token.

It fails closed unless:

- exactly one Pulumi issuer matches GitHub's token issuer;
- the complete set of personal-token `allow` policies exactly equals the
versioned bundled contract, including every claim and an empty
`authorizedPermissions` array;
- every requested operational resource URN appears zero or one time in a valid
stack export.

Contract v2 uses GitHub's immutable owner/repository-ID subject and additional
exact claims for the private repository, owner ID, actor ID, protected
environment, main ref, manual event, first run attempt, hosted runner, and
reserved workflow name. Pulumi treats `*`, `?`, and `.` as pattern operators,
so the validator rejects all three from every rule value. The workflow claim is
a GitHub workflow **name**, not a file identity; each caller must reserve
`github-iac-production-deploy-v1` exclusively for `.github/workflows/deploy.yml`
and enforce that uniqueness in its repository tests.

Existing operational resources are emitted as newline-delimited refresh targets.
Absent resources are the explicit first-apply path and must be created with a
reviewed hosted-only default. Duplicate state, malformed responses, wildcard or
extra policies, unknown contracts, API failures, and authentication failures all
stop the apply. The action never prints tokens or requests plaintext stack
secrets; its temporary state export is deleted on exit.

Immutable-subject cutover is deliberately two-sided and fail-closed:

1. Add the new v2 Pulumi allow policies while the legacy policies still work.
2. Opt both GitHub IaC repositories into GitHub immutable subjects through the
official REST setting (the current Pulumi GitHub provider cannot express it).
3. Prove a production-name token exchanges successfully and the hosted
near-match canary token is rejected.
4. Remove every legacy allow policy.
5. Run this guard; it blocks applies during overlap because the complete live
personal allow set must exactly equal the reviewed v2 contract.

This ordering follows GitHub's requirement to update cloud trust before changing
the emitted subject. Static matcher tests are supporting evidence, not a
replacement for the paired live positive/negative exchange.

The companion reusable version-drift workflow intentionally checks out the
caller to read its `.pulumi.version`. Its behavioral-tested implementation is
generated inline from the canonical `ci-workflows` script, so no caller-owned
copy or relative called-repository path is required.

The contract is based on [GitHub's documented OIDC claims](https://docs.github.com/en/actions/reference/security/oidc),
[Pulumi OIDC issuer policies](https://www.pulumi.com/docs/administration/access-identity/oidc-issuers/),
and Pulumi's read-only [`stack export`](https://www.pulumi.com/docs/iac/cli/commands/pulumi_stack_export/).
43 changes: 43 additions & 0 deletions .github/actions/pulumi-deploy-guard/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Pulumi deployment guard
description: Verify the exact Pulumi OIDC policy and inventory operational state before a protected apply.

inputs:
policy-contract:
description: Versioned bundled OIDC allow-policy contract name.
required: true
stack-name:
description: Fully qualified Pulumi organization/project/stack name.
required: true
operational-resource-urns-json:
description: JSON array of exact operational resource URNs whose live values must be adopted.
required: true

outputs:
existing-count:
description: Number of requested operational resources already present in stack state.
value: ${{ steps.guard.outputs.existing-count }}
missing-count:
description: Number of requested operational resources absent on this first apply.
value: ${{ steps.guard.outputs.missing-count }}
existing-targets:
description: Newline-delimited existing URNs suitable for pulumi/actions target.
value: ${{ steps.guard.outputs.existing-targets }}
existing-urns-json:
description: JSON array of requested URNs present exactly once.
value: ${{ steps.guard.outputs.existing-urns-json }}
missing-urns-json:
description: JSON array of requested URNs absent from state.
value: ${{ steps.guard.outputs.missing-urns-json }}

runs:
using: composite
steps:
- name: Verify OIDC policy and operational resource state
id: guard
shell: bash
env:
ACTION_PATH: ${{ github.action_path }}
OPERATIONAL_RESOURCE_URNS_JSON: ${{ inputs.operational-resource-urns-json }}
POLICY_CONTRACT: ${{ inputs.policy-contract }}
STACK_NAME: ${{ inputs.stack-name }}
run: bash "$ACTION_PATH/guard.sh"
Loading