Repository navigation
fix(windows): stop blocking OpenCode with PowerShell permission checks - #175
Conversation
Code Review SummaryStatus: 1 Issue Found | Recommendation: Address before merge The new deadline headroom is checked before exclusive creation without reintroducing PowerShell. No new critical findings in this increment. The Windows permissions issue remains open: the documentation now describes the behavior, but the access boundary has not changed. Overview
Issue Details (click to expand)CRITICAL
Files Reviewed (12 files)
Static incremental review at Previous Review Summary (commit 0acdc0a)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 0acdc0a)Status: 1 Issue Found | Recommendation: Address before merge Removing synchronous PowerShell from the companion hot path addresses the startup bottleneck without changing the Setup wire format. The remaining blocker is that Windows Setup still accepts paths where the profile's default permissions do not apply. Overview
Issue Details (click to expand)CRITICAL
Files Reviewed (54 files)
Static review only; no project code or tests were run. Reviewed by gpt-6.2-sol · Input: 36 · Output: 5.1K · Cached: 601K |
Fixes #172
Summary
On native Windows the companion blocked OpenCode's event loop for 28 to 43 seconds while loading, because every ownership/ACL check started Windows PowerShell synchronously (1 to 2.4 s each): about 10 to 20 times in
initialize(), once per tool hook and twice per status inspection. The models.dev request then timed out and/api/provideranswered 503 for the life of the process.Decision (by maintainer): the Windows ACL checks are removed everywhere, and Windows relies on the user profile's default per-user permissions, like other per-user applications. No process is started for any permission check, on any platform.
windowsSecurityQuery, PowerShell spawn, ACL cache, private-ACL creation or verification, "permissive/foreign ACL" or "unsafe ancestor" refusal, spawn ceiling, cold-start budget or PowerShell mutex barrier remain, in the companion, the service, setup or shared code.realpath), refusal of symbolic links and junctions (lstat), refusal of hard-linked owned state files, markers, hashes and schema validation. Directories are created with default inheritance. Nothing applies or repairs an ACL.guard(), tool hooks, statusinspect) only re-reads the binding with plain filesystem calls.requirePlatformStoreFence, fresh validation of every mutation, and the step names/journal formats.accounting.securitySpawnsstays on the wire as a constant 0 (the UI validates that exact shape), and the fixed diagnostic codeswindows-security-unavailable,private-permissionsandunsafe-parentstay accepted but are no longer produced, so earlier journals and clients keep working.OpenSpec change
windows-default-permissions(not archived; the release PR does that) modifiesmanaged-companion-deliveryandwindows-setup-responsiveness. Guides updated:docs/setup.md,docs/backend.md,docs/contracts.md,docs/compatibility.md,setup/managed-steps.md,CONTRIBUTING.md,README.md.Removed or changed checks, by file
shared/platform.ts: removedwindowsSecurityQuery,windowsSecurity, the PowerShell scripts and bootstrap, DACL policy script,platformSecurityScope/beginPlatformSecurityScopeand both caches, the spawn counter/launch()/ceiling,windowsDocumentPath.windowsPath(s)now does syntax +lstat+realpathonly;isOwnedis POSIX-only (true on Windows);privatePathson Windows checks "not a link, hard-link count 1";privateDirectorycreates ordinary directories on Windows.shared/binding.ts,managed-binding.ts,store.ts,cleanup.ts,plugin/document.ts,service/setup-controller.ts,service/suggestions.ts,setup/*: removed the scope wrappers and the dead security-error paths; call sites otherwise unchanged.service/request-worker.ts: removed the shared attempt counter and the loopback nonce handshake that only the PowerShell child used; the writer slots themselves are unchanged.shared/managed-steps.ts: removedsecuritySpawnslimit and the spawn allocation table.Tests removed or rewritten, and why
Deleted:
tests/backend/windows-security-query.test.ts: coveredwindowsSecurityQueryitself (environment hygiene, first-query retry, budget charging, shared counter, writer-fence mutex handshake, timeout/exit mapping). The function is gone.tests/backend/windows-spawn-budget.test.ts: counted fake PowerShell launches per managed operation. Replaced by the no-process assertions below.tests/backend/managed-step-prepare-budget.test.ts: a six-launch feasibility measurement and slow-helper deadline cases. The deadline-before-creation behaviour is covered by a new case inmanaged-fresh-store.test.tsandmanaged-migration-steps.test.ts.Rewritten (ACL or launch-count assertions removed, the rest kept):
windows-platform.test.ts(native Windows only): removed private-ACL creation/refusal, ACL cache invalidation, callback/object/audit ACE, PowerShell module bootstrap, ancestor-owner and ancestor-replacement-rights, foreign-owner, public-ACL store and side-file, and unsafe-historical-ancestor cases. Added: default-permission creation with no process, existing owner-only ACL roots keep working and are not modified, an ordinary or widely readable folder is accepted. Hard-link, junction, canonical-path, lifecycle, capture, cleanup and legacy-plugin cases are kept.windows-service.test.ts(native Windows only): removed theempty-delayedjourney, the 2.5 s helper mode of the 1.1.1 migration, injected timeout/private/overrun helper faults and the held-spawn concurrent-health check; every request now asserts zero launches.windows-service-observer.test.tsand the observer/driver/probe fixtures: the observer now counts every child-process launch (not onlypowershell.exe) and no longer injects latency or faults.managed-inspection,managed-migration-steps,managed-step-engine,managed-step-removal,managed-step-upgrade: "at most six launches" tests now assert zero launches on the projected Windows path; "enclosing security scope" assertions and spawn/time exhaustion variants were reduced to the deadline case.managed-step-contract: removed the spawn allocation arithmetic; the deadline ordering assertion stays.managed-step-http,managed-http-worker,managed-request-worker,managed-migration,managed-health: removed cold-query latency, helper timeout, counter andwindows-security-unavailablefault cases.Regression tests (fail first)
tests/backend/windows-no-process.test.ts(commit 1 of this PR, before the fix). On the unmodified code it failed with the number of child-process calls per phase on the simulated Windows path: setup and service 34, companion load 27, one guarded report 12, tool hooks 6, status inspect 6; plus a static check that nothing underplugin/,service/,setup/orshared/importsnode:child_process. After the fix every phase is 0.Judgement calls and risks
STEP_HEADROOM_MS) before the engine publishes an intent and right before an exclusive folder or database creation, so the 17 s deadline cannot land between a creation and its checkpoint. This applies on every platform. The response deadline, the writer slots and uncertain-effect handling are unchanged.requirePlatformStoreFenceare unchanged.windows-security-unavailable,private-permissionsandunsafe-parentstay in the fixed vocabulary and in the Setup UI copy (one string still mentions PowerShell), so old journals and clients render; nothing produces them any more.docs/setup.md).accounting.securitySpawnsis kept as a constant 0 rather than removed, because the UI validates that exact shape.Verification
bun run typecheck,bun run tsc --noEmit -p ui/tsconfig.json,bun run build:all(no generated output tracked): pass.bun run test:allon the pushed head: all portable groups pass.bun run packageandbun run verify:package: pass (the packaged service reports 0 launches).openspec validate windows-default-permissions --strictandopenspec validate --all --strict: pass.44363489894passes (fast Windows set, Linux jobs). A manual dispatch of the workflow on this branch, which runs the full Windows set including the released 1.1.1 migration, passes: run44363501921(13 platform tests and 6 service journeys, none skipped). Every request in those journeys asserts zero child-process launches through an independent observer; the platform suite asserts that roots with an existing owner-only ACL keep working and keep that ACL unchanged.Checklist