Skip to content

fix(runner): hide Windows background bridge consoles - #175

Open
realmroot[bot] wants to merge 1 commit into
mainfrom
fix/windows-hide-background-probes
Open

realmroot[bot] wants to merge 1 commit into
mainfrom
fix/windows-hide-background-probes

Conversation

@realmroot

@realmroot realmroot Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • add opt-in Windows background launch semantics for non-interactive Node probes and inventory/usage bridge children
  • hide background probe consoles with CREATE_NO_WINDOW/HideWindow while preserving Job Object cleanup
  • keep normal runtime session launches on processtree.Start, so existing visible-session CTRL_BREAK then Job Object cancellation semantics remain unchanged

Fixes #172.

Cancellation Semantics

  • Start is unchanged for interactive/runtime session work: it keeps CREATE_NEW_PROCESS_GROUP, does not set CREATE_NO_WINDOW, and Stop still attempts GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, pid) before Job Object termination.
  • StartBackground is only for hidden, non-interactive probes/bridge inventory children. Because CREATE_NO_WINDOW children do not share the caller console, Stop does not claim graceful CTRL_BREAK delivery for them; it cleans the process tree through the Windows Job Object.
  • Node executable probes are short direct exec.CommandContext(node, -p, process.execPath) commands with hidden window attributes.

Verification

Already-passing broader checks were reused after the resource spike observation; final local checks were bounded and sequential.

Actual local OS tests/checks on this darwin host:

  • rtk go test -p=1 ./internal/sys/processtree ./internal/runtime from cmd/enbor-runner (62 passed in 2 packages)
  • rtk git diff --check
  • rtk gofmt -l cmd/enbor-runner/internal/sys/processtree/process_windows_test.go

Windows compile/link checks on this host:

  • rtk env GOOS=windows GOARCH=amd64 go test -c -o /tmp/enbor-processtree.test.exe ./internal/sys/processtree
  • rtk env GOOS=windows GOARCH=amd64 go test -c -o /tmp/enbor-runtime.test.exe ./internal/runtime

Windows behavior test added for CI/native Windows execution:

  • TestStopCloseTerminatesBackgroundWindowsProcessTree starts a hidden background root process, waits for a ready file and descendant PID, opens a descendant process handle before cleanup, calls Stop(0) and Close(), then asserts both the root process and descendant handle exit. The child is bounded (ping -n 30) and there is no recursive spawn.

Windows Reviewer Journey

  1. On Windows, build the runner:
    cd cmd/enbor-runner
    go build -o $env:TEMP\enbor-runner.exe .
  2. Run the native Windows process-tree proof:
    go test ./internal/sys/processtree -run "TestStartBackground|TestStopAttemptsCtrlBreakOnlyForVisibleWindowsProcesses|TestStopCloseTerminatesBackgroundWindowsProcessTree" -v
    Expected: the background process-tree test reports descendant readiness, then passes by observing both root and descendant termination after Stop/Close.
  3. Run the foreground runner with an existing valid runner config/account:
    & $env:TEMP\enbor-runner.exe run --api-server <api-server> --project-id <project-id> --environment-id <environment-id> --state-dir $env:TEMP\enbor-runner-state --work-dir $env:TEMP\enbor-runner-work --max-concurrent 1
    Startup triggers runtime usage and inventory refreshes, which exercise the Node executable probe and hidden inventory/usage bridge child path. Leave the runner idle past the usage refresh interval to exercise periodic usage collection.
  4. While watching the Windows desktop, trigger a CLI-backed session assigned to this runner from the Enbor console/API, then cancel/close it. Expected behavior: inventory/usage/probe activity should not flash extra console windows; normal live session cancellation remains on the old visible Start path and is not hidden by this PR.

Limits

  • The automated tests verify Windows process flags, background-vs-visible cancellation strategy, and Job Object descendant cleanup.
  • CI/native Windows can execute the Windows process-tree test.
  • Interactive visual GUI/no-window observation is a manual reviewer journey; it was not performed on this darwin host and should not be inferred solely from CI status.
  • No change to the deferred HOME/toolchain behavior from Self-hosted Runner loses Volta configuration when tools use Session HOME #171.

🤖 Created by Ravi Shah via Realmroot

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 13, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
any-managed-agents 67979d7 Sep 13 2026, 01:46 PM

@realmroot
realmroot Bot force-pushed the fix/windows-hide-background-probes branch from 90bfe5e to 8cb6294 Compare September 13, 2026 13:35
@realmroot

realmroot Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up for the Windows cancellation review:

  • Confirmed from Microsoft docs that GenerateConsoleCtrlEvent only reaches process groups sharing the caller console, so hidden CREATE_NO_WINDOW children should not be treated as graceful CTRL_BREAK recipients.
  • Kept Bridge.Run on non-background processtree.Start, preserving the existing visible runtime cancellation path: CTRL_BREAK attempt first, then Job Object termination.
  • Added explicit Process.background semantics on Windows: StartBackground hides the console and documents that cleanup is forceful through the Job Object; Stop skips GenerateConsoleCtrlEvent for those hidden children.
  • Added tests for visible vs background Stop behavior, in addition to the launch flag and Job Object cleanup coverage.

Fresh verification after the update:

  • rtk go test ./... from cmd/enbor-runner (651 passed in 23 packages)
  • rtk env GOOS=windows GOARCH=amd64 go test -c -o /tmp/enbor-runtime.test.exe ./internal/runtime
  • rtk env GOOS=windows GOARCH=amd64 go test -c -o /tmp/enbor-processtree.test.exe ./internal/sys/processtree
  • rtk env GOOS=windows GOARCH=amd64 go build ./...
  • rtk git diff --check

Local host is still non-Windows, so live Windows GUI/process execution remains delegated to Windows CI.


🤖 Created by Ravi Shah via Realmroot

@realmroot
realmroot Bot force-pushed the fix/windows-hide-background-probes branch from 8cb6294 to 67979d7 Compare September 13, 2026 13:45
@realmroot

realmroot Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor Author

Rejection follow-up addressed on final SHA 67979d7d299865169c0d8b76ec3284860337c130.

What changed after review rejection:

  • Replaced the weak immediate-stop background test with TestStopCloseTerminatesBackgroundWindowsProcessTree.
  • The test now starts a hidden background root process, waits for a readiness file, captures and opens a descendant PID/handle before cleanup, calls Stop(0) and Close(), then independently asserts root process exit and descendant handle exit.
  • The child is bounded (ping -n 30) and there is no recursive/unbounded spawn.

Bounded local verification, run sequentially after the process-spike observation:

  • rtk go test -p=1 ./internal/sys/processtree ./internal/runtime from cmd/enbor-runner: 62 passed in 2 packages
  • rtk env GOOS=windows GOARCH=amd64 go test -c -o /tmp/enbor-processtree.test.exe ./internal/sys/processtree
  • rtk env GOOS=windows GOARCH=amd64 go test -c -o /tmp/enbor-runtime.test.exe ./internal/runtime
  • rtk git diff --check

Affected Windows CI on final SHA:

  • Enbor Runner (windows-latest) passed in run 34760719103, including Run Windows Enbor Runner tests and Smoke Windows Enbor Runner binary.

The PR body now includes the concrete Windows reviewer journey and explicitly distinguishes automated OS/process tests from unperformed interactive GUI/no-window observation.


🤖 Created by Ravi Shah via Realmroot

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: runner heartbeat spawns node.exe with a visible flashing console window every ~20-30s

0 participants