Repository navigation
feat(windows): add verified CLI installer with recoverable upgrades - #1
ThunderKhan wants to merge 21 commits into
Conversation
| - name: Run validator and recovery fixtures | ||
| shell: pwsh | ||
| env: | ||
| TEST_ENGINE: ${{ matrix.engine }} |
There was a problem hiding this comment.
Warning · Windows CI skips real upgrades and forced-termination recovery
Both PowerShell jobs only parse the real integration suites. The offline upgrade and locking fixtures replace the production version check with digest checks.
Both jobs can pass even if the installer rejects an official executable or fails recovery after a forced stop that the offline fixtures do not reproduce.
Run both real integration suites in a separate Windows CI job for both PowerShell editions.
There was a problem hiding this comment.
Still present in this version: Proofline found the issue again. Proofline's finding in this version: Windows installer CI misses incompatible release archives. View review
| function Get-ProoflineUpdatedUserPath([string]$Current, [string]$Directory) { | ||
| if ($null -eq $Current) { $Current = '' } | ||
| $normalized = $Directory.TrimEnd([char[]]@('\', '/')) | ||
| foreach ($entry in ($Current -split ';')) { |
There was a problem hiding this comment.
Warning · Installer skips adding Proofline to a non-expandable User PATH
Duplicate detection expands entries even for REG_SZ, where Windows treats %VARIABLE% literally. If expansion matches the install directory, the installer skips the registry write.
The installer reports that Proofline is on PATH, but a new terminal may not find it.
Pass the registry kind to duplicate detection and expand entries only for REG_EXPAND_SZ.
There was a problem hiding this comment.
Still present in this version: Proofline found the issue again. Proofline's finding in this version: Expandable user PATH can point outside the install directory. View review
There was a problem hiding this comment.
Still present in this version: Proofline found the issue again. Proofline's finding in this version: Installer reports a PATH update that points to the wrong directory. View review
| function Get-ProoflineUpdatedUserPath([string]$Current, [string]$Directory) { | ||
| if ($null -eq $Current) { $Current = '' } | ||
| $normalized = $Directory.TrimEnd([char[]]@('\', '/')) | ||
| foreach ($entry in ($Current -split ';')) { |
There was a problem hiding this comment.
Warning · Installer skips adding its directory to a literal user PATH
Duplicate detection expands variable references in REG_SZ entries, so a literal entry can falsely match the install directory.
The installer reports the directory is already on PATH and skips adding it, leaving proofline undiscoverable by name unless another entry provides it.
Pass the registry kind to duplicate detection and expand entries only for REG_EXPAND_SZ.
There was a problem hiding this comment.
Still present in this version: Proofline found the issue again. Proofline's finding in this version: Windows PATH guidance omits the append limit and silent edit loss. View review
| elseif ($Checkpoint -eq 'after-switch' -or $Checkpoint -eq 'corrupt-after-switch') { | ||
| $target = ' Invoke-ProoflineReplaceWithRetry $stage $destination $paths.api $hash $oldReceipt.sha256' + | ||
| "`n" + ' if (' | ||
| $damage = if ($Checkpoint -eq 'corrupt-after-switch') { |
There was a problem hiding this comment.
Warning · after-switch passes without a persisted checking state
after-switch checks that the journal exists, not that it contains postcheck: checking. Recovery rolls back whether that state is present or missing.
The test still passes if the installer delays writing checking until after publication and the forced stop.
Read the on-disk journal before launching recovery and assert postcheck is checking at both switch checkpoints.
Details
Moving the write below the destination digest guard preserves the exact replacement-plus-if instrumentation anchor and still allows uninterrupted upgrades to record passed.
Also at:
scripts/test_install_interruption_real_windows.ps1lines 347 to 348
There was a problem hiding this comment.
Still present in this version: Proofline found the issue again. Proofline's finding in this version: Upgrade tests miss dropped version subprocess failures. View review
| elseif ($Checkpoint -eq 'after-switch' -or $Checkpoint -eq 'corrupt-after-switch') { | ||
| $target = ' Invoke-ProoflineReplaceWithRetry $stage $destination $paths.api $hash $oldReceipt.sha256' + | ||
| "`n" + ' if (' | ||
| $damage = if ($Checkpoint -eq 'corrupt-after-switch') { |
There was a problem hiding this comment.
Warning · Windows interruption tests miss premature receipt publication
First-install and upgrade checkpoints skip the interval between persisting passed and publishing the receipt; offline fixtures construct that state directly.
An extra receipt write after the executable check but before passed would leave every existing checkpoint and assertion passing.
Stop workers immediately after persisting passed, assert the receipt is absent or still names the old release, then verify recovery finalizes the install.
There was a problem hiding this comment.
Still present in this version: Proofline found the issue again. Proofline's finding in this version: Interruption tests miss recovery with competing postcheck journals. View review
There was a problem hiding this comment.
Still present in this version: Proofline found the issue again. Proofline's finding in this version: Passed interruption tests miss a missing journal backup. View review
| $original = Get-RawUserPath | ||
| $directory = Join-Path $env:RUNNER_TEMP ('proofline-path-ci-' + [guid]::NewGuid().ToString('N')) | ||
| $token = '%PROOFLINE_CI_TEST_ROOT%\bin' | ||
| $seed = if ([string]::IsNullOrEmpty($original.value)) { $token } |
There was a problem hiding this comment.
Serious · The Windows CI test can erase a concurrent user PATH edit
Seeding overwrites Path from an unchecked snapshot, and cleanup restores or deletes it after a non-atomic ownership check.
An unrelated edit to Path can be lost even when it matches neither test value.
Run the persistence test under a dedicated disposable Windows user profile so it cannot overwrite another user's Path.
Details
The workflow invokes the default check mode. An edit between the snapshot and seeding is overwritten before cleanup can observe it, so cleanup can pass after restoring the older value. Separately, an edit after the cleanup read can be overwritten by the restore or deletion. Rereading immediately before each mutation would narrow the race but would not make the operation atomic.
There was a problem hiding this comment.
Still present in this version: Proofline found the issue again. Proofline's finding in this version: Windows PATH test can erase a concurrent PATH edit. View review
There was a problem hiding this comment.
Still present in this version: Proofline found the issue again. Proofline's finding in this version: CI fixture can erase a concurrent installer’s User PATH update. View review
| if (-not [IO.File]::Exists($Path)) { | ||
| Write-ProoflineAtomicRecord $Path $record | ||
| } | ||
| else { |
There was a problem hiding this comment.
Serious · A locked but matching receipt blocks upgrade recovery
Rollback and pre-switch recovery replace the old receipt even when it already matches the verified executable.
A reader that denies delete sharing makes recovery abort before clearing the journal, blocking installer retries while the handle remains open.
Reuse the passed branch’s matching-receipt check in both old-version recovery paths and skip replacement when the version and hash match.
Also at:
install.ps1lines 776 to 778
There was a problem hiding this comment.
Still present in this version: Proofline found the issue again. Proofline's finding in this version: A corrupt receipt blocks recovery of a verified upgrade. View review
| $result = if ($Current.TrimEnd(';') -eq '') { $Directory } else { $Current.TrimEnd(';') + ';' + $Directory } | ||
| if ($result.Length -gt 30000) { throw 'User PATH is too long; add the directory manually.' } | ||
| return $result |
There was a problem hiding this comment.
Serious · Concurrent Windows installs can silently lose a user PATH entry
Add-ProoflineUserPath checks freshness separately from writing, so two installers can both pass the check and write updates based on the same snapshot.
The last write silently discards the other installer's PATH entry.
Lock the entire read–modify–write sequence per user, and document that editors outside the lock can still race.
| $fresh.kind -ne $previous.kind -or $fresh.exists -ne $previous.exists) { | ||
| throw 'User PATH changed concurrently; retry the installer or add the directory manually.' | ||
| } | ||
| $key.SetValue('Path', $result, $previous.kind) |
There was a problem hiding this comment.
Serious · Concurrent installs can erase a user PATH edit
The freshness check and SetValue are separate, so an edit made between them is overwritten by the earlier snapshot.
A concurrent installer can report success even though its directory is missing from the saved Path.
Hold a shared per-user lock across the full read–modify–write for installer runs, and document that other editors are not synchronized.
Details
The archive-install lock is released before the default PATH update, so it does not serialize even two installer runs.
There was a problem hiding this comment.
Still present in this version: Proofline found the issue again. Proofline's finding in this version: Windows installers in different sessions can lose a PATH update. View review
| foreach ($path in @($root, $case)) { | ||
| if (-not [IO.Directory]::Exists($path) -or | ||
| (([IO.File]::GetAttributes($path) -band [IO.FileAttributes]::ReparsePoint) -ne 0)) { | ||
| throw 'Interruption test sandbox directory does not exist or is a reparse point.' |
There was a problem hiding this comment.
Warning · Worker can load an installer script outside its test sandbox
Worker checks the installer copy’s path spelling and existence, but does not reject a file reparse point before dot-sourcing it.
The interruption test can run a different script instead of the driver-generated installer.
Reject reparse points on the installer copy and dot-source the validated absolute path.
Details
The normal driver generates its own installer copy; no examined caller supplies a reparse point. The missing check is in the Windows test worker, not the production installer.
There was a problem hiding this comment.
Still present in this version: Proofline found the issue again. Proofline's finding in this version: A mismatched holder can delete the test marker. View review
| elseif ($Checkpoint -eq 'fresh-after-move') { | ||
| $target = ' [IO.File]::Move($stage, $destination)' + | ||
| "`n" + ' if (' | ||
| $replacement = ' [IO.File]::Move($stage, $destination)' + |
There was a problem hiding this comment.
Warning · First-install interruption test misses a late checking write
fresh-after-move checks that the journal exists but does not require postcheck: checking. Recovery quarantines the executable whether that field is missing or set to checking.
The scenario can pass even if proofline.exe is published before checking is persisted.
Assert that the on-disk journal contains postcheck: checking at fresh-after-move, before starting recovery.
| } | ||
| . $InstallerCopy | ||
| if ($Mode -eq 'Recover') { | ||
| Invoke-ProoflinePendingRepair $CaseDir |
There was a problem hiding this comment.
Warning · Interruption tests miss regressions in repair before download
The recovery worker calls Invoke-ProoflinePendingRepair directly, bypassing the installer entry point and its download ordering.
Every interruption scenario can pass even if the installer leaves a pending transaction unrepaired when a download fails.
Invoke Invoke-ProoflineInstaller with the interrupted directory and a downloader that always fails, then assert recovery completed despite the download error.
There was a problem hiding this comment.
Still present in this version: Proofline found the issue again. Proofline's finding in this version: Windows CI can pass with latest-release installation broken. View review
| $pendingPath = Pending 'journal-backup-only' | ||
| Set-ProoflinePendingPostcheck $pendingPath 'checking' | ||
| Set-ProoflinePendingPostcheck $pendingPath 'passed' | ||
| [IO.File]::Copy($pendingPath, $pendingPath + '.postcheck.bak', $false) |
There was a problem hiding this comment.
Warning · Journal-backup test misses interrupted upgrade rollback
The fixture copies a completed passed journal, but File.Replace backs up the previous checking journal when persisting passed.
The test still passes if recovery skips orphaned checking backups, leaving the new executable active instead of restoring the previous release.
Move the checking journal to .postcheck.bak, then assert recovery restores the old executable and receipt and clears the backup.
There was a problem hiding this comment.
Still present in this version: Proofline found the issue again. Proofline's finding in this version: Passed checkpoints miss stale journal precedence. View review
| - name: Install and upgrade pinned official releases | ||
| shell: pwsh | ||
| env: | ||
| TEST_ENGINE: ${{ matrix.engine }} |
There was a problem hiding this comment.
Warning · Interruption CI misses repair before downloads
The interruption harness calls Invoke-ProoflinePendingRepair directly, so its assertions still pass if the installer removes the pre-download repair call or moves it after downloads.
CI can pass even though rerunning the installer during a download failure leaves the interrupted upgrade unrepaired.
Rerun install.ps1 with a pending upgrade and a forced download failure, then assert the executable and receipt are restored and the journal is cleared.
| foreach ($path in $paths.Values) { Assert-ProoflineNoReparse $path } | ||
| $activeHash = $null | ||
| if ([IO.File]::Exists($destination)) { $activeHash = Get-ProoflineSha256 $destination } | ||
|
|
There was a problem hiding this comment.
Warning · A brief file lock can leave a rejected upgrade installed
After a failed postcheck, rollback attempts File.Replace only once and aborts on a transient sharing violation.
The rejected executable remains at proofline.exe while the receipt still describes the previous release.
Reuse the bounded replacement retry for rollback, checking both file hashes and confirming the backup path is absent before retrying.
There was a problem hiding this comment.
Still present in this version: Proofline found the issue again. Proofline's finding in this version: A brief file lock can leave an unchecked upgrade installed. View review
| function Assert-ProoflineExeVersion([string]$Path, [string]$Version) { | ||
| # Run only checksum-verified images; bound both process termination | ||
| # and redirected output collection so descendants cannot hang the check. | ||
| $startInfo = [Diagnostics.ProcessStartInfo]::new() |
There was a problem hiding this comment.
Warning · Version checks can execute unverified bytes
The installer launches the stage after closing its exclusive write handle, and launches the installed image after a separate hash read. Neither check protects the verified file through process creation.
A concurrent file change can cause the installer to execute bytes that were never verified.
Hash each executable while preventing writes and replacement, and keep that protection in place through process creation.
Also at:
install.ps1lines 1032 to 1036install.ps1lines 1064 to 1067
There was a problem hiding this comment.
Still present in this version: Proofline found the issue again. Proofline's finding in this version: Offline version checks accept a mismatched expected digest. View review
| # The normal tar smoke test alone does not reject extra members. | ||
| . ./install.ps1 | ||
| $archivePath = 'artifacts/proofline-x86_64-pc-windows-msvc.tar.gz' | ||
| $binary = Get-ProoflineTarExecutable ([IO.File]::ReadAllBytes((Resolve-Path $archivePath).Path)) |
There was a problem hiding this comment.
Warning · Compatibility gate does not check the published Windows archive
The new installer assertion checks the archive built by Checks, but Release rebuilds and uploads a separate archive without running that assertion on it.
A release-only packaging regression can ship a Windows archive the installer rejects even when the gate passes.
Run Get-ProoflineTarExecutable on the release matrix’s Windows archive before uploading it.
There was a problem hiding this comment.
Still present in this version: Proofline found the issue again. Proofline's finding in this version: Windows package gates can miss archives PowerShell 5.1 rejects. View review
| - run: python scripts/archive.py x86_64-pc-windows-msvc | ||
| - shell: pwsh | ||
| run: | | ||
| # Reject a packaged archive that the proposed installer cannot read. |
There was a problem hiding this comment.
Warning · Windows CI can pass an archive the installer rejects as too large
The compatibility check calls the tar parser directly, bypassing the installer’s 64 MiB compressed-size limit.
An otherwise valid Windows archive can pass CI but fail to install.
Check the compressed file length against MaxArchiveBytes before reading and parsing it.
| $result = if ($Current.TrimEnd(';') -eq '') { $Directory } else { $Current.TrimEnd(';') + ';' + $Directory } | ||
| if ($result.Length -gt 30000) { throw 'User PATH is too long; add the directory manually.' } | ||
| return $result | ||
| } |
There was a problem hiding this comment.
Serious · Concurrent installs in different Windows sessions can lose a PATH entry
The per-SID Local\ mutex is session-scoped, but User PATH is shared across sessions. Two installers can both pass the freshness check before either writes.
Both installers can report success while the last write drops the other install directory from User PATH.
Hold a cross-session per-SID lock from the initial registry read through the write.
There was a problem hiding this comment.
Still present in this version: Proofline found the issue again. Proofline's finding in this version: Manual PATH fallback can leave Proofline undiscoverable. View review
| [IO.File]::Replace($temporary, $Pending, $backup) | ||
| $updated = Read-ProoflinePending $Pending | ||
| if ($updated.id -cne $record.id -or $updated.postcheck -cne $State) { | ||
| throw 'Could not verify the persisted upgrade postcheck state.' |
There was a problem hiding this comment.
Warning · A locked journal backup blocks upgrade rollback
Recovery aborts if it cannot delete .postcheck.bak, even after validating the canonical journal.
A failed installed version check can leave the rejected proofline.exe in place instead of restoring the previous version.
Continue recovery from the valid journal when backup deletion fails, and retain the canonical journal until the backup is removed.
There was a problem hiding this comment.
Still present in this version: Proofline found the issue again. Proofline's finding in this version: An invalid pending journal blocks recovery despite a valid backup. View review
| function Assert-ProoflinePathTree([string]$Directory) { | ||
| # A pre-existing reparse-point ancestor can redirect writes outside the | ||
| # requested directory. Check all existing ancestors and refuse such paths. | ||
| $cursor = [IO.DirectoryInfo]::new($Directory) |
There was a problem hiding this comment.
Warning · A concurrent directory change can redirect install and repair writes
The installer checks ancestors by name, then re-resolves the path to open its lock. A junction introduced between those operations can redirect the lock without tripping the leaf checks.
Installation or recovery can modify files outside the directory that was checked.
Validate and pin the directory chain before opening the lock, then perform managed operations relative to the pinned directory.
Details
Both paths are reached by normal script invocation. Pre-download repair also requires a pending journal or its backup. The exclusive lock protects the file it opened, not the identity of the directory inspected by the ancestor walk.
Also at:
install.ps1lines 897 to 910
| $binary = Get-ProoflineTarExecutable ([IO.File]::ReadAllBytes($archiveFile)) | ||
| if ($binary.Length -le 0) { throw 'PR-built Windows archive contains no supported Proofline executable.' } | ||
| Write-Host "Installer-compatible PR-built Windows archive validated ($($binary.Length) bytes)." | ||
| tar -xzf artifacts/proofline-x86_64-pc-windows-msvc.tar.gz -C artifacts |
There was a problem hiding this comment.
Warning · Windows PR smoke tests can miss installer extraction regressions
The PR gate checks only the length of $binary, then smoke-tests a separate tar extraction without comparing the bytes.
An installer parser regression that returns different nonempty bytes can pass the PR gate.
Smoke-test the installer parser’s output or compare its SHA-256 with the smoke-tested executable.
Details
The current single-member packager does not demonstrate a mismatch. The release gate already compares the installer payload hash with the tested build.
| pull_request: | ||
| paths: | ||
| - 'install.ps1' | ||
| - 'scripts/test_install*windows.ps1' |
There was a problem hiding this comment.
Warning · Release-only PRs skip the Windows installer matrix
The installer workflow’s PR path filter omits .github/workflows/release.yml, which controls Windows archive validation and checksum generation.
PRs changing only release packaging skip installer tests on both PowerShell editions; regular CI checks its own archive instead.
Add .github/workflows/release.yml to the installer workflow’s PR path filter.
Details
The matrix uses fixtures and pinned official releases. Widening the trigger runs that suite, but does not validate the PR’s release archive or manifest end to end.
| $target = ' Assert-ProoflineExeVersion $stage $ReleaseVersion' + | ||
| "`n`n" + ' if ($null -eq $oldReceipt) {' | ||
| $replacement = ' Assert-ProoflineExeVersion $stage $ReleaseVersion' + |
There was a problem hiding this comment.
Warning · Windows interruption tests abort at fresh-after-stage
The fresh-after-stage injector omits $hash from its exact-match anchor, but the installer passes it to Assert-ProoflineExeVersion.
On either PowerShell engine, reaching this checkpoint fails CI before its worker starts and skips the three remaining checkpoints.
Include $hash in both the anchor and the replacement so the injected copy preserves the validation call.
| if ($Mode -eq 'Hold') { | ||
| if ([string]::IsNullOrWhiteSpace($CaseDir)) { throw 'Holder needs CaseDir.' } | ||
| $folder = [IO.Path]::GetFullPath($CaseDir) | ||
| $marker = Join-Path $folder '.proofline-test-only' |
There was a problem hiding this comment.
Warning · Rejected lock holder can delete the valid test marker
Hold renames the marker before validation and deletes it in finally if reading or restoring it fails.
The matching holder can no longer claim the original marker, so the test can fail before exercising installer locking.
Delete only validated claims; restore rejected claims without overwriting a replacement, and preserve the claimed file if restoration fails.
Details
An ordinary mismatch restores the marker successfully. The driver supplies only the matching token and does not exercise the rejected-claim path.
There was a problem hiding this comment.
Still present in this version: Proofline found the issue again. Proofline's finding in this version: Holder deletes the marker before refusing an invalid sandbox. View review
| $lock = [IO.Path]::Combine($directory, '.proofline-install.lock') | ||
| foreach ($path in @($destination, $receipt, $pending, $lock)) { | ||
| Assert-ProoflineNoReparse $path | ||
| } |
There was a problem hiding this comment.
Warning · Windows lock tests miss loss of installer exclusivity
Both tests use a fixture-held FileShare.None lock, which rejects the contender even if Install-ProoflineArchive switches to FileShare.ReadWrite.
Both tests would still pass even though two installers could acquire the same lock simultaneously.
Pause one installer after it acquires the production lock, then assert that a second installer is refused before releasing the first.
There was a problem hiding this comment.
Still present in this version: Proofline found the issue again. Proofline's finding in this version: Contention test misses temporary staging before lock acquisition. View review
| function Assert-ProoflinePathTree([string]$Directory) { | ||
| # A pre-existing reparse-point ancestor can redirect writes outside the | ||
| # requested directory. Check all existing ancestors and refuse such paths. | ||
| $cursor = [IO.DirectoryInfo]::new($Directory) |
There was a problem hiding this comment.
Warning · Installer can write outside the directory it validated
The ancestor walk retains no directory handles. If an ancestor changes to a reparse point before lock acquisition, both install and repair resolve the lock and transaction files in the redirected tree.
The installer can create files or recover a transaction in a different directory than the one it checked.
Validate and retain stable directory handles, and bind all transaction operations to those identities.
Also at:
install.ps1lines 907 to 920
| python3 scripts/archive.py "$TARGET" | ||
| - name: Validate exact Windows release archive with installer rules | ||
| if: matrix.target == 'x86_64-pc-windows-msvc' | ||
| shell: pwsh |
There was a problem hiding this comment.
Warning · Archive gate can pass packages Windows PowerShell 5.1 rejects
The package gates validate with pwsh only, whose gzip decoder can read a tar stream split across gzip members that Windows PowerShell 5.1 sees as truncated.
A packaging regression can pass validation but prevent installation on Windows PowerShell 5.1.
Validate the exact packaged archive under both PowerShell engines before upload.
Details
The current packager writes a single gzip member, so this is a regression-detection gap, not a failure of today's artifact. The two-engine fixture workflow does not consume the newly built archive.
Also at:
.github/workflows/ci.ymllines 40 to 52
| $script:smokeCount = 0 | ||
| $script:failInstalledPostcheckPath = $null | ||
| $script:failInstalledPostcheckVersion = '0.5.2' | ||
| function Assert-ProoflineExeVersion([string]$Path, [string]$Version) { |
There was a problem hiding this comment.
Warning · Offline install tests miss missing or incorrect version-check digests
The offline Assert-ProoflineExeVersion substitutes a fixture digest instead of checking the caller’s SHA-256 argument.
The offline cases still pass if the staged, fresh-install, or upgrade check receives a missing or incorrect digest.
Have both test doubles require ExpectedSha256 and compare it with the fixture digest before simulating any postcheck failure.
Details
The clean-upgrade case first installs the old fixture, then upgrades it, reaching all three calls. Its file and receipt assertions do not observe the third argument. The real interruption test separately checks the staged call’s exact text at scripts/test_install_interruption_real_windows.ps1:296–316; that does not close the gap in the offline doubles.
Also at:
scripts/test_install_concurrency_windows.ps1lines 119 to 132
| Check 'missing canonical postcheck journal restores validated backup before recovery' { | ||
| $dir = PrepareOld 'journal-backup-only' | ||
| [void](MakePending $dir) | ||
| $pendingPath = Pending 'journal-backup-only' |
There was a problem hiding this comment.
Warning · Recovery tests miss rollback caused by a stale journal backup
The recovery fixtures never pair a canonical passed journal with a stale checking backup for the same upgrade.
The tests could pass even if recovery chose the stale backup and rolled back a verified upgrade.
Keep a checking backup beside the passed journal and assert that repair retains the new executable and finalizes its receipt.
There was a problem hiding this comment.
Still present in this version: Proofline found the issue again. Proofline's finding in this version: Interruption tests miss a missing postcheck journal backup. View review
| Check 'repeat upgrade is idempotent' { | ||
| $dir = PrepareOld 'repeat' | ||
| [void](Install-ProoflineArchive $script:newArchive $script:newSums '0.5.2' $dir) | ||
| $before = $script:smokeCount |
There was a problem hiding this comment.
Warning · Windows repeat-install tests miss byte-identical rewrites
The offline and real-release repeat cases check final contents, not whether the matching executable and receipt were left untouched.
Both tests still pass if a same-version install rewrites either file with identical bytes without invoking the version checker.
Hold both files open with read sharing only during the repeat install and require it to succeed.
| if (-not [IO.File]::Exists($Path)) { return $null } | ||
| if (([IO.FileInfo]$Path).Length -gt 4096) { throw 'Pending transaction is too large.' } | ||
| $record = ConvertFrom-Json -InputObject ([IO.File]::ReadAllText($Path)) | ||
| if ($null -eq $record) { throw 'Pending transaction is empty.' } |
There was a problem hiding this comment.
Serious · Malformed upgrade journal blocks verified rollback
Recovery reads the backup only when the canonical journal is missing, so a parse or validation error bypasses a valid checking backup.
Installer retries exit before downloading or restoring the previous release, even when a matching executable copy exists.
Keep a valid canonical journal authoritative; if it is malformed, preserve it and validate the backup before attempting digest-verified rollback.
| public static SafeFileHandle Open(string path) { | ||
| // SYNCHRONIZE | FILE_READ_ATTRIBUTES | FILE_LIST_DIRECTORY: | ||
| // list-directory access makes the no-FILE_SHARE_DELETE lock effective. | ||
| // BACKUP_SEMANTICS permits directory handles; OPEN_REPARSE_POINT ensures |
There was a problem hiding this comment.
Warning · Installer writes can escape the validated directory
Directory pins block renames but allow in-place reparse changes after validation. The installer then resolves absolute paths again.
The lock, journal, and executable can be created outside the requested install directory.
Open and move transaction files relative to the validated directory handle without following reparse points.
Details
The race requires a concurrent writer with permission to modify reparse metadata on the empty directory. The rename test does not cover in-place metadata changes. The repair path has the same path-resolution gap if its journal lookup resolves through a changed directory.
Also at:
install.ps1lines 991 to 1000
| function Read-ProoflinePending([string]$Path) { | ||
| if (-not [IO.File]::Exists($Path)) { return $null } | ||
| if (([IO.FileInfo]$Path).Length -gt 4096) { throw 'Pending transaction is too large.' } | ||
| $record = ConvertFrom-Json -InputObject ([IO.File]::ReadAllText($Path)) |
There was a problem hiding this comment.
Warning · Malformed pending journal blocks rollback despite a valid backup
Restore-ProoflinePendingBackup only reads the backup when the canonical journal is absent; a parse or validation error in an existing journal escapes first.
Installer retries abort without restoring the previous verified executable.
On canonical validation failure, validate the backup, preserve the malformed journal for diagnosis, and resume digest-checked recovery from the backup.
There was a problem hiding this comment.
Still present in this version: Proofline found the issue again. Proofline's finding in this version: A journal sharing violation can roll back a verified upgrade. View review
| if ($archiveLength -le 0 -or $archiveLength -gt $script:MaxArchiveBytes) { | ||
| throw "Packaged Windows archive violates installer compressed-size limit: $archiveLength bytes." | ||
| } | ||
| $payload = Get-ProoflineTarExecutable ([IO.File]::ReadAllBytes($archive)) |
There was a problem hiding this comment.
Warning · Replacing the archive during validation can exhaust memory
The package checker checks file metadata, then reopens the path with ReadAllBytes, so a concurrent replacement can bypass the 64 MiB compressed-size limit.
Validation can fail from memory exhaustion instead of reporting an oversized archive.
Open the archive once and enforce the compressed-size limit while reading that stream.
Details
The CI and release workflows invoke the checker after packaging; neither shows a concurrent writer. The parser limits decompressed output only, after the compressed bytes have already been allocated.
| - name: Run validator and recovery fixtures | ||
| shell: pwsh | ||
| env: | ||
| TEST_ENGINE: ${{ matrix.engine }} |
There was a problem hiding this comment.
Warning · Installer integration jobs run despite syntax validation failures
Only offline-validation runs the syntax preflight; neither integration job waits for it.
A syntax error in the interruption test can still let the upgrade job install two releases before encountering the error. The workflow still fails.
Make both integration jobs depend on a dedicated syntax job that checks both PowerShell editions.
| throw "PowerShell syntax validation failed for $path." | ||
| } | ||
| } | ||
| Write-Host "PowerShell syntax validation: PASS ($($paths.Count) scripts parsed)." |
There was a problem hiding this comment.
Warning · Windows syntax check can pass with malformed generated installers
The syntax gate parses the driver’s source, not the PowerShell emitted by its checkpoint templates, and the driver launches workers without parsing the generated copies.
A malformed template can pass the syntax job and surface only as a worker failure before the checkpoint.
Parse each generated copy with the selected PowerShell engine before launching its worker, and report any parser diagnostics directly.
| . $validatedCopy | ||
| if ($Mode -eq 'Recover') { | ||
| Invoke-ProoflinePendingRepair $CaseDir | ||
| Write-Output 'RECOVERY_COMPLETED' |
There was a problem hiding this comment.
Warning · Interruption tests miss rollback when the latest lookup fails
The interruption suite calls repair directly, so moving repair after /cli/latest but before archive downloads would leave it green.
An unpinned retry could fail its lookup and leave the unchecked replacement active without a test failure.
Restart install.ps1 without -Version after the switch checkpoint, fail /cli/latest deterministically, and assert the specific error, nonzero exit, restored executable and receipt, and cleared journal.
Details
The offline unpinned case starts clean and returns a successful latest pointer. The pending-upgrade outage case pins the version, so it still repairs before its first archive request under the proposed regression.
| Check 'latest release invocation uses pinned offline archive and passes installer postchecks' { | ||
| $dir = Join-Path $root 'latest-release-entrypoint' | ||
| $realDownload = (Get-Item Function:\Get-ProoflineOfficialBytes).ScriptBlock | ||
| try { |
There was a problem hiding this comment.
Warning · Offline tests miss rollback blocked by latest-version lookup
The outage fixture pins the version, and the unpinned fixture has no pending upgrade and returns a successful /cli/latest response.
Both tests still pass if release selection moves before repair, leaving interrupted upgrades unrepaired when /cli/latest fails.
Add an unpinned outage case that fails /cli/latest and verifies the old executable and receipt are restored and the journal is cleared.
| Write-ProoflineReceipt $Path $Version $Hash | ||
| } | ||
|
|
||
| function Read-ProoflineReceipt([string]$Path) { |
There was a problem hiding this comment.
Serious · A malformed receipt blocks recovery of a verified upgrade
Even when the journal says passed and the installed digest matches, recovery aborts on a malformed receipt before it can rewrite it.
Installer retries exit without finalizing the upgrade.
Rebuild invalid receipt contents from verified journal data, while still surfacing access and sharing errors.
Details
The same parse-before-repair failure affects first-install recovery when the postcheck is already recorded as passed, and both rollback paths that call Ensure-ProoflineReceipt after verifying the old executable digest. Keep the no-rewrite fast path for a valid matching receipt.
Also at:
install.ps1lines 584 to 588install.ps1lines 901 to 904install.ps1lines 950 to 952install.ps1lines 992 to 998
| $realWrite = (Get-Item Function:\Write-ProoflineReceipt).ScriptBlock | ||
| try { | ||
| Set-Item Function:\Write-ProoflineReceipt -Value { throw 'Simulated receipt replacement lock.' } |
There was a problem hiding this comment.
Warning · Receipt tests miss backup deletion when validation fails
The failure fixture replaces Write-ProoflineReceipt with a throwing stub, while the direct replacement test checks only successful cleanup.
Both tests would still pass if the writer deleted the previous receipt backup when validation throws after replacement.
Run the real writer, inject a failure in Assert-ProoflineRecord after replacement, and verify that the backup contains the original receipt.
| Check 'only sharing/lock HRESULTs are retryable' { | ||
| $sharing = [IO.IOException]::new('temporarily held', -2147024864) | ||
| $lock = [IO.IOException]::new('range locked', -2147024863) | ||
| $denied = [UnauthorizedAccessException]::new('denied') |
There was a problem hiding this comment.
Warning · Windows tests miss a regression in executable replacement retries
The HRESULT test calls only the classifier, and the rollback fixture locks the journal backup rather than the executable. Neither makes File.Replace fail transiently.
Both tests would pass if Invoke-ProoflineReplaceWithRetry rethrew the first sharing violation.
Add a test that forces the first replacement to fail with a sharing violation, releases the lock before the retry, and asserts that replacement succeeds.
| Check 'corrupt active restored from verified previous copy' { | ||
| $dir = PrepareOld 'rollback' | ||
| $paths = MakePending $dir | ||
| [IO.File]::WriteAllText((Active 'rollback'), 'BROKEN', [Text.Encoding]::ASCII) |
There was a problem hiding this comment.
Warning · Recovery tests miss executable corruption after postcheck passes
The fixtures test corrupt bytes and a passed journal separately, never together.
Removing the active digest comparison would leave the tests green even if recovery published the new receipt for corrupted bytes.
Persist passed, corrupt the active executable before recovery, and assert that recovery restores the previous executable and receipt.
Also at:
scripts/test_install_interruption_real_windows.ps1lines 274 to 289
| foreach ($line in ($manifest -split "`n")) { | ||
| $line = $line.TrimEnd("`r") | ||
| if ($line.Length -eq 0) { continue } | ||
| if ($line -cnotmatch '\A([0-9a-fA-F]{64}) [ *](proofline-[a-zA-Z0-9_.-]+\.tar\.gz)\z') { |
There was a problem hiding this comment.
Warning · Manifest test passes without filename validation
The SHA256SUMS-malformed fixture uses a valid filename with an invalid digest, and Must-Throw accepts the digest rejection.
The test stays green if filename restrictions are removed while digest validation remains.
Add a separate fixture with a correct Windows entry and a second row containing a valid digest but an invalid filename.
| (destination / "symlink.tar.gz").write_bytes( | ||
| pack(("proofline.exe", b"", tarfile.SYMTYPE)) | ||
| ) | ||
| (destination / "not-pe.tar.gz").write_bytes( |
There was a problem hiding this comment.
Warning · The archive test passes without the MZ check
not-pe.tar.gz has both invalid MZ magic and an out-of-range PE offset, and Must-Throw accepts either rejection.
Removing the MZ check leaves the test green because the offset check still throws.
Corrupt only the MZ bytes in the otherwise valid fixture and assert the MZ-specific error.
| elseif ($Checkpoint -eq 'fresh-after-receipt') { | ||
| $target = ' Write-ProoflineReceipt $receipt $ReleaseVersion $hash' + | ||
| "`n" + ' Clear-ProoflineJournalBackup $pending' | ||
| $replacement = ' Write-ProoflineReceipt $receipt $ReleaseVersion $hash' + |
There was a problem hiding this comment.
Warning · First-install recovery test misses rewrites of a valid receipt
fresh-after-receipt runs repair without holding the published receipt open and checks only its final contents, so replacing it with an equivalent receipt still passes.
The test misses a regression that can block recovery when a reader denies delete sharing.
Hold the receipt open with FileShare.Read during repair and require successful journal cleanup.
Summary
Adds a secure Windows PowerShell installer for the Proofline CLI, supporting verified installations, recoverable upgrades, and automatic rollback after failed or interrupted updates.
This PR is opened in
khan-dev-labs/clito run Proofline's code review as part of my Software Engineering Intern application.Implementation
Testing
Verification
Review focus
Please review the transaction recovery logic, executable verification, rollback behavior, filesystem safety, and handling of interrupted or partially completed upgrades.
In particular, assess whether the persistent
checkingandpassedpostcheck states correctly prevent an unverified upgraded executable from being finalized after a failure.