Skip to content

On Windows most daemon test rigs wait on a real PowerShell ACL read at every daemon start #1932

Done

Description

@V3RON

`startDaemon` builds `PowerShellDirectoryAccessReader` when `options.directoryAccess` is not passed (`src/daemon/main.ts:233-234`). On win32, `prepareDataDirectory` (`src/daemon/connection-host.ts:70`) awaits its `read`, a `powershell.exe` run with a 10 s limit (`src/ports/directory-access.ts:22`), before the daemon serves. `src/daemon/test-main.ts:48-49` passes a `FakeDirectoryAccessReader` for this reason ("on Windows the real reader would start PowerShell for every test daemon"); `src/daemon/gateway-fleet.e2e.test.ts` and `src/daemon/main-agent-device.test.ts` do too.

These rigs and files call `startDaemon` without it (`grep -L directoryAccess` over the files that call `startDaemon(`), among them:

  • `src/agent-device/test-gateway.ts:201,256`
  • `src/daemon/test-relay-support.ts`, `src/daemon/test-optional-modules.ts`
  • `src/daemon/main-update.test.ts`, `src/daemon/optional-modules-start.test.ts`, `src/daemon/main-stop.test.ts`, `src/daemon/main.test.ts`, `src/daemon/gateway-modules.test.ts`, `src/agent-device/local-profile.test.ts`, and the `*.e2e.test.ts` files under `src/daemon/`

Each of their daemon starts on the Windows unit job waits on PowerShell. Two of them have open 20 s timeout issues on that job: #1913 (`main-update.test.ts`) and #1914 (`optional-modules-start.test.ts`). The agent-device worker rig (`src/agent-device/test-support.ts`) is #1912 and is not part of this issue.

Found while triaging #1912.

Written by an agent.

Activity

  1. added
    bug:new
    on Nov 28, 2026
  2. self-assigned this
    on Nov 28, 2026
  3. V3RON commented on Nov 28, 2026

    @V3RON
    ContributorAuthor

    Reproduction

    Confirmed, and wider than listed: 67 starts in 24 files, including startGateway in src/daemon/test-main.ts:199 (its start passes a fake), main-leasing.test.ts, main-state-db.test.ts and main-host-load.test.ts. On bug/1932-repro, the host-load guard from #1887 now checks a list of options. The file is renamed to src/daemon/test-daemons-host-readers.test.ts. Its new case, "daemons started by tests under src/ > pass directoryAccess, so none builds the production adapter that reads this host", fails. The hostLoadProbe case still passes.

    pnpm exec vitest run --project unit src/daemon/test-daemons-host-readers.test.ts
    AssertionError: expected [ …(67) ] to deeply equal []
     ❯ src/daemon/test-daemons-host-readers.test.ts:116:21
    +   "src/agent-device/local-profile.test.ts:100",
    +   "src/agent-device/test-gateway.ts:201",
    +   "src/daemon/test-main.ts:199",
    +   ... (64 more)
    

    Root cause

    Defect in the test rigs, not in production. src/daemon/main.ts:234 falls back to new PowerShellDirectoryAccessReader(baseProcessRunner) when a start does not pass directoryAccess. On win32, prepareDataDirectory (src/daemon/connection-host.ts:70) waits for that powershell.exe run (10 s limit, src/ports/directory-access.ts:22) before the daemon serves. Only test-main.ts's start, gateway-fleet.e2e.test.ts:169 and main-agent-device.test.ts:134 pass a fake. Every other test start pays for the PowerShell run.

    Simplest fix

    Do what #1887 did for hostLoadProbe. Add directoryAccess: new FakeDirectoryAccessReader({ user: "S-1-5-21-1-2-3-1001", entries: [] }) to each start the guard lists, next to its hostLoadProbe. Tried, then discarded:

    24 files changed, 85 insertions(+), 22 deletions(-)
    vitest run --project unit src/daemon/test-daemons-host-readers.test.ts: 2 passed
    pnpm test:changed: 61 files, 781 passed; pnpm typecheck: clean
    

    Alternatives rejected

    • vi.mock the reader in the unit setup file: it breaks src/ports/directory-access.test.ts, and it hides which reader each start uses.
    • Skip the reader in startDaemon under tests: production code would then know about tests.
    • Fix only the rigs the issue names: the guard finds 67 starts, so the next file without the fake would wait on PowerShell again.

    Risk

    Fast track

    • Defect: yes
    • Fix tried: yes
    • Nothing public added or broken: yes
    • No ADR or rule changed: yes
    • One fix: yes

    Written by an agent.

  4. removed their assignment
    on Nov 28, 2026
  5. added
    bug:ready
    fast-track
    and removed
    bug:new
    on Nov 28, 2026
  6. self-assigned this
    on Nov 28, 2026
  7. V3RON commented on Nov 28, 2026

    @V3RON
    ContributorAuthor

    Handoff

    Done: PR #1935 passes directoryAccess: fakeDirectoryAccess() at every test daemon start under src/, so no test daemon runs powershell.exe on Windows. A guard test (src/daemon/test-daemons-host-readers.test.ts) fails on any start without it. Review round 1 and a CI fix-check found nothing blocking. The PR is ready.

    Not done: merge.

    Findings: one nonblocking note (the guard scanner misses an aliased or dynamically imported startDaemon), posted on the PR.

    Blocked on: fast-track: #1932 held: PR #1935 changes 26 files, over 8. The maintainer merges the PR, or removes fast-track.

    Written by an agent.

  8. added
    bug:blocked
    and removed
    bug:ready
    on Nov 28, 2026
  9. removed their assignment
    on Nov 28, 2026
  10. V3RON commented on Nov 28, 2026

    @V3RON
    ContributorAuthor

    Delivery run

    Merged: none
    Parked: #1932 — PR #1935 held by the fast track (26 files, over 8)
    Waiting: none
    Decided: none

    Written by an agent.

  11. removed
    fast-track
    on Nov 30, 2026
  12. added a commit that references this issue on Nov 30, 2026
    9457a80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug:blocked

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions