Skip to content

Free, open source blog writer for Claude Code. Researches current sources, writes answer-first posts for Google and AI answers, has an independent reviewer score each one out of 100 and ships only after five delivery gates. 32 skills, 30 /blog commands, 5 agents. Active development at AI-Marketing-Hub/claude-blog; public releases ship here.

test(install): account for PowerShell startup cache

Agrici Daniel39c1cc4f03c1
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4ca6972..b10610e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -46,7 +46,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Require shipped, hash-checked Brain excerpt artifacts with source and review
provenance, while separating excerpt integrity from full-capture review.
- Handle normal Git stderr correctly on PowerShell 5.1, select exactly one Git
- executable when PATH contains duplicates, isolate disposable host caches,
+ executable when PATH contains duplicates, account for the exact PowerShell
+ startup-cache file while protecting the rest of the disposable profile,
avoid binary pipelines in legacy Windows fixtures, and preserve Bash 3.2
standalone uninstall.
diff --git a/docs/AUDIT-FOLLOWUP-2026-10-07.md b/docs/AUDIT-FOLLOWUP-2026-10-07.md
index 5e63071..7e5c649 100644
--- a/docs/AUDIT-FOLLOWUP-2026-10-07.md
+++ b/docs/AUDIT-FOLLOWUP-2026-10-07.md
@@ -117,12 +117,14 @@ replace binary pipelines with an owned archive file, keep uninstall argument
arrays nonempty and declare the exact offline authentication-test dependency.
A subsequent native run exposed multiple Git executable results being treated
as one path. The resolver now selects exactly the first application, with a
-duplicate-PATH regression. Disposable PowerShell host caches stay outside the
-profile under test, and both the complete profile and `.claude` receive
-independent preservation assertions with safe diagnostics. The prior
-PowerShell 7 snapshot failure did not identify a changed path, so the cache
-explanation remains an inference. Failed CI logs, fixture setup failures and
-the original independent review remain in the evidence pack beside reruns. A further independent
+duplicate-PATH regression. Native Windows PowerShell 5.1 then passed. The
+PowerShell 7 diagnostics identified its own noninteractive startup-cache file
+inside the disposable profile. Environment overrides did not relocate that
+file. The fixture records this exact host-owned file separately and compares
+every other profile file plus all of `.claude` without exclusions. Negative
+probes reject a sibling cache file and a `.claude` mutation. Failed CI logs,
+fixture setup failures and the original independent review remain in the
+evidence pack beside reruns. A further independent
adversarial pass reproduced transparent author decoys and split-file excerpt
budgets. Both reproductions now fail, with regressions for computed visibility,
independent byline agreement, unused excerpt text and active-source bindings.
diff --git a/tests/test_windows_installer_ownership.py b/tests/test_windows_installer_ownership.py
index 7457443..8222d77 100644
--- a/tests/test_windows_installer_ownership.py
+++ b/tests/test_windows_installer_ownership.py
@@ -126,20 +126,33 @@ def test_native_smoke_avoids_pre_74_binary_pipelines() -> None:
assert 'Join-Path $RunRoot ("baseline-" + $Baseline + ".tar")' in smoke
-def test_native_smoke_covers_duplicate_git_resolution_and_host_state_isolation() -> None:
+def test_native_smoke_covers_duplicate_git_resolution_and_exact_host_cache_lane() -> None:
smoke = _read(SMOKE)
assert 'Write-Host "SCENARIO: duplicate Git application resolution"' in smoke
assert "Import-InstallerFunction $downloadedBootstrap \"Resolve-ClaudeBlogGitApplication\"" in smoke
assert '@(Get-Command git -CommandType Application -All)' in smoke
assert '@($resolvedGit).Count -eq 1' in smoke
assert '"resolver selects first application in PATH"' in smoke
- assert '$env:LOCALAPPDATA = $hostState' in smoke
- assert '$env:APPDATA = $hostState' in smoke
- assert '$env:XDG_CACHE_HOME = $hostState' in smoke
+ assert '$env:LOCALAPPDATA = $hostState' not in smoke
+ assert '$env:APPDATA = $hostState' not in smoke
+ assert '$env:XDG_CACHE_HOME = $hostState' not in smoke
assert '$env:POWERSHELL_TELEMETRY_OPTOUT = "1"' in smoke
assert "Compare-Object" not in _function(smoke, "Assert-SnapshotEqual")
assert '"failed clone does not mutate .claude"' in smoke
- assert "Assert-SnapshotEqual $failureProfileBefore $failureProfileAfter" in smoke
+ assert '$PowerShellStartupCacheRelativePath = "\\AppData\\Local\\Microsoft\\PowerShell\\StartupProfileData-NonInteractive"' in smoke
+ cache_comparison = _function(smoke, "Assert-SnapshotEqualExceptPowerShellStartupCache")
+ assert "-eq $PowerShellStartupCacheRelativePath" in cache_comparison
+ assert "-ne $PowerShellStartupCacheRelativePath" in cache_comparison
+ assert "-like" not in cache_comparison
+ assert "-match" not in cache_comparison
+ assert "StartsWith" not in cache_comparison
+ assert "Assert-SnapshotEqual ($beforeProtectedEntries" in cache_comparison
+ assert 'Write-Host "PowerShell startup-cache lane evidence (relative path and SHA-256 only):"' in cache_comparison
+ assert 'Write-Host "SCENARIO: exact PowerShell startup-cache allowance"' in smoke
+ assert 'Assert-SnapshotEqualExceptPowerShellStartupCache "" ""' in smoke
+ assert "StartupProfileData-Interactive=" in smoke
+ assert '"\\.claude\\unexpected.txt="' in smoke
+ assert "Assert-SnapshotEqualExceptPowerShellStartupCache $failureProfileBefore $failureProfileAfter" in smoke
def test_pip_log_uses_owned_full_guid_root_and_is_retained_on_failure() -> None:
diff --git a/tests/windows/windows_installer_ownership_smoke.ps1 b/tests/windows/windows_installer_ownership_smoke.ps1
index fbdb3c2..1de50f2 100644
--- a/tests/windows/windows_installer_ownership_smoke.ps1
+++ b/tests/windows/windows_installer_ownership_smoke.ps1
@@ -7,6 +7,7 @@ $ErrorActionPreference = "Stop"
$Baseline = "2500d4c765034864cede2bf215d00ccd4d7d6fb8"
$Helper = Join-Path $RepositoryRoot "scripts/windows_installer_ownership.ps1"
$LegacyInventory = Join-Path $RepositoryRoot "data/legacy-install-ownership.json"
+$PowerShellStartupCacheRelativePath = "\AppData\Local\Microsoft\PowerShell\StartupProfileData-NonInteractive"
. $Helper
function Assert-True($Value, $Message) { if (-not $Value) { throw "ASSERTION FAILED: $Message" } }
@@ -28,6 +29,27 @@ function Assert-SnapshotEqual($Before, $After, $Message) {
}
throw "ASSERTION FAILED: $Message"
}
+function Get-SnapshotEntryPath($Entry) {
+ $separator = $Entry.LastIndexOf('=')
+ if ($separator -lt 0) { return $Entry }
+ return $Entry.Substring(0, $separator)
+}
+function Assert-SnapshotEqualExceptPowerShellStartupCache($Before, $After, $Message) {
+ $beforeEntries = @($Before -split "`n" | Where-Object { $_ })
+ $afterEntries = @($After -split "`n" | Where-Object { $_ })
+ $beforeCacheEntries = @($beforeEntries | Where-Object { (Get-SnapshotEntryPath $_) -eq $PowerShellStartupCacheRelativePath })
+ $afterCacheEntries = @($afterEntries | Where-Object { (Get-SnapshotEntryPath $_) -eq $PowerShellStartupCacheRelativePath })
+ Assert-True ($beforeCacheEntries.Count -le 1) "startup-cache snapshot contains at most one exact entry before bootstrap"
+ Assert-True ($afterCacheEntries.Count -le 1) "startup-cache snapshot contains at most one exact entry after bootstrap"
+
+ Write-Host "PowerShell startup-cache lane evidence (relative path and SHA-256 only):"
+ Write-Host (" before: {0}" -f $(if ($beforeCacheEntries.Count) { $beforeCacheEntries[0] } else { "<absent>" }))
+ Write-Host (" after: {0}" -f $(if ($afterCacheEntries.Count) { $afterCacheEntries[0] } else { "<absent>" }))
+
+ $beforeProtectedEntries = @($beforeEntries | Where-Object { (Get-SnapshotEntryPath $_) -ne $PowerShellStartupCacheRelativePath })
+ $afterProtectedEntries = @($afterEntries | Where-Object { (Get-SnapshotEntryPath $_) -ne $PowerShellStartupCacheRelativePath })
+ Assert-SnapshotEqual ($beforeProtectedEntries -join "`n") ($afterProtectedEntries -join "`n") $Message
+}
function Import-InstallerFunction($Script, $Name) {
$tokens = $null
$errors = $null
@@ -55,23 +77,13 @@ function Invoke-DownloadedBootstrap($Script, $Profile, $Url, $Ref, $Identifier)
$oldUrl = $env:CLAUDE_BLOG_URL
$oldRef = $env:CLAUDE_BLOG_REF
$oldIdentifier = $env:CLAUDE_BLOG_TEST_BOOTSTRAP_GUID
- $oldLocalAppData = $env:LOCALAPPDATA
- $oldAppData = $env:APPDATA
- $oldXdgCacheHome = $env:XDG_CACHE_HOME
$oldTelemetryOptOut = $env:POWERSHELL_TELEMETRY_OPTOUT
- $hostState = Join-Path (Split-Path -Parent $Profile) ("powershell-host-state-" + $Identifier)
- New-Item -ItemType Directory -Path $hostState | Out-Null
try {
$env:USERPROFILE = $Profile
$env:CLAUDE_BLOG_URL = $Url
$env:CLAUDE_BLOG_REF = $Ref
$env:CLAUDE_BLOG_TEST_BOOTSTRAP_GUID = $Identifier
- # PowerShell 7 writes startup and telemetry caches at process launch.
- # Keep that host state outside the profile whose installer immutability
- # this scenario verifies.
- $env:LOCALAPPDATA = $hostState
- $env:APPDATA = $hostState
- $env:XDG_CACHE_HOME = $hostState
+ # Avoid telemetry writes while testing the installer's filesystem ownership.
$env:POWERSHELL_TELEMETRY_OPTOUT = "1"
$hostExecutable = (Get-Process -Id $PID).Path
$process = Start-Process -FilePath $hostExecutable -ArgumentList @("-NoProfile", "-File", ('"' + $Script + '"')) -NoNewWindow -Wait -PassThru
@@ -81,9 +93,6 @@ function Invoke-DownloadedBootstrap($Script, $Profile, $Url, $Ref, $Identifier)
if ($null -eq $oldUrl) { Remove-Item Env:CLAUDE_BLOG_URL -ErrorAction SilentlyContinue } else { $env:CLAUDE_BLOG_URL = $oldUrl }
if ($null -eq $oldRef) { Remove-Item Env:CLAUDE_BLOG_REF -ErrorAction SilentlyContinue } else { $env:CLAUDE_BLOG_REF = $oldRef }
if ($null -eq $oldIdentifier) { Remove-Item Env:CLAUDE_BLOG_TEST_BOOTSTRAP_GUID -ErrorAction SilentlyContinue } else { $env:CLAUDE_BLOG_TEST_BOOTSTRAP_GUID = $oldIdentifier }
- if ($null -eq $oldLocalAppData) { Remove-Item Env:LOCALAPPDATA -ErrorAction SilentlyContinue } else { $env:LOCALAPPDATA = $oldLocalAppData }
- if ($null -eq $oldAppData) { Remove-Item Env:APPDATA -ErrorAction SilentlyContinue } else { $env:APPDATA = $oldAppData }
- if ($null -eq $oldXdgCacheHome) { Remove-Item Env:XDG_CACHE_HOME -ErrorAction SilentlyContinue } else { $env:XDG_CACHE_HOME = $oldXdgCacheHome }
if ($null -eq $oldTelemetryOptOut) { Remove-Item Env:POWERSHELL_TELEMETRY_OPTOUT -ErrorAction SilentlyContinue } else { $env:POWERSHELL_TELEMETRY_OPTOUT = $oldTelemetryOptOut }
}
}
@@ -159,6 +168,19 @@ $target = Join-Path $env:USERPROFILE "selected-ref-ran.txt"
$env:PATH = $oldPath
}
+ Write-Host "SCENARIO: exact PowerShell startup-cache allowance"
+ $startupCacheEntry = $PowerShellStartupCacheRelativePath + "=" + ("a" * 64)
+ Assert-SnapshotEqualExceptPowerShellStartupCache "" "" "empty snapshots remain equal"
+ Assert-SnapshotEqualExceptPowerShellStartupCache "" $startupCacheEntry "exact PowerShell startup cache is allowed"
+ Assert-Throws {
+ $siblingEntry = "\AppData\Local\Microsoft\PowerShell\StartupProfileData-Interactive=" + ("b" * 64)
+ Assert-SnapshotEqualExceptPowerShellStartupCache "" ($startupCacheEntry + "`n" + $siblingEntry) "PowerShell cache sibling must remain protected"
+ } "PowerShell cache sibling mutation"
+ Assert-Throws {
+ $claudeEntry = "\.claude\unexpected.txt=" + ("c" * 64)
+ Assert-SnapshotEqualExceptPowerShellStartupCache "" ($startupCacheEntry + "`n" + $claudeEntry) ".claude must remain protected"
+ } ".claude mutation"
+
Write-Host "SCENARIO: bootstrap creation collision preservation"
$collisionIdentifier = [Guid]::NewGuid().ToString("N")
$collisionRoot = Join-Path ([System.IO.Path]::GetTempPath()) ("claude-blog-install-" + $collisionIdentifier)
@@ -189,7 +211,7 @@ $target = Join-Path $env:USERPROFILE "selected-ref-ran.txt"
$failureProfileAfter = Snapshot $failureProfile
$failureClaudeAfter = Snapshot (ClaudeRoot $failureProfile)
Assert-SnapshotEqual $failureClaudeBefore $failureClaudeAfter "failed clone does not mutate .claude"
- Assert-SnapshotEqual $failureProfileBefore $failureProfileAfter "failed clone does not mutate profile"
+ Assert-SnapshotEqualExceptPowerShellStartupCache $failureProfileBefore $failureProfileAfter "failed clone mutates profile outside exact PowerShell startup cache"
Write-Host "SCENARIO: selected ref installer handoff"
$bootstrapProfile = New-Profile $RunRoot "selected-ref-profile"