Repository navigation
fix(snapshot): survive cold PowerShell starts in Windows staging gates - #123633
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
6eea4ee to
9e13580
Compare
|
Codex review: needs maintainer review before merge. Reviewed August 14, 2026, 9:41 AM ET / 13:41 UTC. ClawSweeper reviewWhat this changesThe PR centralizes encoded Windows PowerShell launches for snapshot, private SQLite-directory, and private plan-file security gates, extends their cold-start timeout to 60 seconds, and preserves sanitized failure causes. Regression provenancePossible regression — probable (failure trace; reviewed change). No predecessor PR is attributed. Merge readinessKeep this protected maintainer PR open for the explicit timeout tradeoff and exact-head Windows validation. Current main still has the three 10-second fail-closed launches; no discrete patch defect was found in the shared, sanitized replacement. Priority: P1 Review scores
Verification
How this fits togetherWindows snapshot and secret-plan operations use PowerShell to establish or verify private ACLs before handling local data. A successful gate permits the operation; a failed gate stops it with a diagnostic. flowchart LR
A[Snapshot or plan request] --> B[Private ACL security gate]
B --> C[Encoded PowerShell launch]
C --> D{Gate succeeds?}
D -->|Yes| E[Secure file operation]
D -->|No| F[Sanitized failure diagnostic]
Decision needed
Why: This is an intentional security-gate availability tradeoff; source review can confirm the preserved fail-closed behavior but cannot choose the acceptable operator wait budget. Before merge
Agent review detailsSecurityNone. PR surfaceSource +35, Tests +73. Total +108 across 7 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain one shared sanitized launcher and the 60-second fail-closed bound once a maintainer accepts that availability tradeoff and current-head Windows lanes confirm both successful cold starts and continued ACL rejection. Do we have a high-confidence way to reproduce the issue? No high-confidence on-demand reproduction is available because the cold-start condition depends on runner cache and load. Current main's three 10-second launch sites plus the supplied timeout trace make the owner path source-reproducible. Is this the best way to solve the issue? Yes, subject to the timeout decision: the three owners duplicated the same encoded-launch, timeout, and sanitization policy, while the fail-open LAN route probe remains deliberately separate. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 5523f8a334c9. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
CI run 31775262530, checks-windows-node-test-1 attempt 1, showed the fail-closed ACL probe timing out during PowerShell first-use module preparation. Centralize encoded one-shot spawning, budget 60 seconds for cold starts, and preserve the underlying probe failure as the error cause.
check-lint-core-2 flagged preserve-caught-error at the private plan file catch; retaining the raw error would re-leak the -EncodedCommand argv the sanitization contract strips, so the suppression is intentional (same idiom as setup-inference-activate.ts).
checks-windows-node-test-2 (run 31804325922) hit the same cold-start flake class this PR fixes: the codepage-proof test spawns real powershell.exe bounded at 3s, which a cold runner cannot meet. Production keeps its fail-open 3s route-hint probe; only the test's real-spawn verification uses the shared cold-spawn budget.
5600df3 to
fb3143e
Compare
|
All actionable findings addressed at the current head; per-item disposition:
|
|
Merged via squash.
|
openclaw#123633) * fix(snapshot): survive cold PowerShell starts in Windows staging gates CI run 31775262530, checks-windows-node-test-1 attempt 1, showed the fail-closed ACL probe timing out during PowerShell first-use module preparation. Centralize encoded one-shot spawning, budget 60 seconds for cold starts, and preserve the underlying probe failure as the error cause. * fix(snapshot): sanitize PowerShell failure causes in Windows staging gates * fix(secrets): explain the sanitized plan-file failure cause suppression check-lint-core-2 flagged preserve-caught-error at the private plan file catch; retaining the raw error would re-leak the -EncodedCommand argv the sanitization contract strips, so the suppression is intentional (same idiom as setup-inference-activate.ts). * test(lint): register the private-plan-file suppression in the inventory * test(infra): give the LAN-host real PowerShell spawn a cold-start budget checks-windows-node-test-2 (run 31804325922) hit the same cold-start flake class this PR fixes: the codepage-proof test spawns real powershell.exe bounded at 3s, which a cold runner cannot meet. Production keeps its fail-open 3s route-hint probe; only the test's real-spawn verification uses the shared cold-spawn budget.
What Problem This Solves
src/snapshot/local-repository.windows.test.ts > "verifies and cleans staging when the SQLite path exceeds MAX_PATH"failed flakily on PR #123509 (run 31775262530,checks-windows-node-test-1, attempt 1, ~11.1s) with an unrelated diff, then passed on rerun. The failure wasUnable to verify private Windows ACL for SQLite staging: ...fromassertTrustedWindowsStagingPath— and the job log contains a PowerShell CLIXML progress recordPreparing modules for first use.Root cause: the fail-closed Windows ACL probe (
runEncodedWindowsPowerShell) bounded itspowershell.exe -EncodedCommandspawn at 10 s. Cold first-use PowerShell module analysis / NGEN compilation on a loaded runner exceeds 10 s, execa kills the child, and the barecatch {}discarded the timeout error — so the failure surfaced with no cause at all. This is a production bug, not just a CI flake: a slow user machine hits the same fail-closed error during snapshot create/verify. The identical 10 s bound (and duplicated encoded-spawn plumbing) existed in two sibling fail-closed owners:createPrivateSqliteDirectory(which compiles C# viaAdd-Type— the slowest cold path) andcreatePrivateWindowsPlanFile.Why This Change Was Made
src/infra/windows-powershell-spawn.tsowns the shared invariant:WINDOWS_POWERSHELL_COLD_SPAWN_TIMEOUT_MS = 60_000(the bound exists only to stop true hangs; fail-closed gates must out-wait cold starts) andbuildEncodedPowerShellArgs()(canonical-NoLogo -NoProfile -NonInteractive -EncodedCommandargv + utf16le/base64 encoding, previously copy-pasted in three files).src/snapshot/local-repository.ts,src/infra/sqlite-private-directory.ts, andsrc/secrets/private-plan-file.tsnow share both; ACL/creation logic is byte-identical otherwise.assertTrustedWindowsStagingPathnow preserves the underlying spawn error ascause— the same diagnostics-loss class already fixed in the sibling by fix(sqlite): preserve Windows private-directory diagnostics #123023; without it this flake was undiagnosable from CI output.src/daemon/schtasks-runtime.ts(5 s fail-open best-effort probe →"unknown", a different contract) andsrc/cli/completion-cli.test-support.ts(interactive test host).User Impact
Windows snapshot create/verify/restore, private SQLite staging directory creation, and private plan file creation no longer fail closed when PowerShell needs a cold start on a slow or loaded machine; when the probe does fail, the error now carries the underlying cause.
Evidence
Failing CI: run 31775262530 (
checks-windows-node-test-1, attempt 1) on refactor(computer-use): one canonical wire contract + node-host provider seam #123509 — 11103 ms ≈ setup + the 10 s timeout, with thePreparing modules for first use.CLIXML record; attempt 2 passed unchanged.Regression test
src/snapshot/local-repository.windows-acl-probe.test.ts(mock pattern from fix(sqlite): preserve Windows private-directory diagnostics #123023) fails pre-fix on both counts — pre-fix output:expected undefined to be Error: Command timed out after 60000 milliseconds(cause discarded) andtimeoutMs: 10_000— and passes post-fix.Focused local proof (trusted worktree):
node scripts/run-vitest.mjsonlocal-repository.windows-acl-probe.test.ts(1 passed),local-repository.test.ts(65 passed, 1 skipped),sqlite-private-directory.test.ts(3 passed),private-plan-file.test.ts(1 passed);pnpm format+git diff --checkclean.Remote check backends (Blacksmith/Crabbox) were unreachable at proof time; per repo fallback policy,
pnpm tsgoandscripts/run-oxlint.mjson the changed files ran locally: both clean.Real-Windows validation rides this PR's
checks-windows-node-testlanes, which executelocal-repository.windows.test.tsonwindows-latest.Production LOC +55/−50 (net +5, the new shared module's comment lines); test +44/−0.
Exact-flake reproduction on demand is infeasible (depends on the runner image's PowerShell module-analysis cache state and load); the captured failing run is the reproduction evidence.
Unrelated red
main:build-artifactsfails on latestmain(run 31797901898, a 5-byte Control UI startup-JS budget overrun from fix(ui): autosave acks wipe open add-entry drafts and in-progress JSON text #123502) and therefore on every PR merge-ref build including this one. Dedicated fix: fix(ci): record startup JS growth in the Control UI budget baseline #123639. All other lanes on this PR are unaffected.