Skip to content

Add Win32 worker factory and broker identity binding#48

Merged
dovvnloading merged 2 commits into
mainfrom
codex/native-worker-runtime
Jul 23, 2026
Merged

Add Win32 worker factory and broker identity binding#48
dovvnloading merged 2 commits into
mainfrom
codex/native-worker-runtime

Conversation

@dovvnloading

@dovvnloading dovvnloading commented Jul 23, 2026

Copy link
Copy Markdown
Owner

Summary

This stage implements the concrete Windows launch and broker-identity controls that PR #47 deliberately left behind:

  • add NativeWin32ProcessFactory, which creates the fixed worker suspended in a unique zero-capability AppContainer
  • verify the worker token is an AppContainer with the expected SID shape
  • apply and query-verify active-process, process/job memory, process/job CPU, kill-on-close, and no-breakaway Job Object limits before resume
  • terminate/reap unassigned or failed workers, close every native handle, and delete disposable AppContainer profiles
  • add NativeBrokerIdentityBinder, which opens the protected named pipe only after the worker PID and AppContainer SID are known
  • pin expected worker PID, worker AppContainer SID, current broker PID, installation principal, and durable job ownership
  • close the broker endpoint automatically if binding or resume fails
  • update launcher/broker/sandbox ADRs and evidence logs with the exact qualified and blocked gates

Why this matters

The launcher now exercises the real construction order:

create suspended -> apply/query Job policy -> bind live PID/AppContainer identity -> resume

There is no subprocess, shell, stdio, weaker-sandbox, or host-process fallback.

Validation

  • local python -m pytest -q242 passed, 1 skipped
  • real Windows suspended AppContainer factory smoke passed using a fixed findstr.exe child
  • real protected named-pipe binder smoke passed with PID/AppContainer ACL binding and clean close
  • python -m ruff check ... — passed
  • python -m compileall -q ... — passed
  • python tools/generate_contracts.py — passed
  • git diff --check — passed

CI correction

The first Quality run failed because Python 3.11 on the GitHub Windows runner does not expose ctypes.wintypes.HRESULT; the local Python 3.14 environment did. The adapter now uses the ABI-correct ctypes.c_long for HRESULT return values. The focused Win32 tests and complete local suite pass after that correction.

Remaining release gate

Provider execution is still intentionally disabled. The signed installed recipe_worker.exe generation and the worker-side native broker client loop still must be wired and run end-to-end through authenticated input/output, watchdog, cancellation, hostile decoder, artifact publication, and cleanup tests. External security review and lifecycle enablement remain required afterward.

The pre-existing Cortex.pyproj edit is intentionally not included.

@dovvnloading

Copy link
Copy Markdown
Owner Author

Quality rerun passed on commit 96cf53a: 242 Python tests passed (1 expected skip), frontend type/lint/unit/build checks passed, launcher-managed bundle verification passed, and the Windows package build passed. The PR remains ready for review. Provider execution is still gated on the signed installed
ecipe_worker.exe generation and worker-side authenticated broker client loop.

@dovvnloading
dovvnloading merged commit 38dcb47 into main Jul 23, 2026
1 check passed
@dovvnloading
dovvnloading deleted the codex/native-worker-runtime branch July 23, 2026 18:44
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.

1 participant