Skip to content

Persist Windows connector service rotation across restarts - #2356

Merged
abrichr merged 4 commits into
mainfrom
codex/windows-service-rotation-20261120
Nov 22, 2026
Merged

abrichr merged 4 commits into
mainfrom
codex/windows-service-rotation-20261120

Conversation

@abrichr

@abrichr abrichr commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

The Windows connector service now keeps rotated tokens in the virtual service account's Windows Credential Manager. It binds the stored credential to the enrollment file location, configured endpoint, organization and bootstrap credentials. The administrator retains write access to the configuration. An environment override for the token, endpoint or organization keeps rotation with the operator.

The CLI and Windows service use the same rotation protocol. Both persist the candidate before asking Cloud to rotate, confirm any pending candidate before another poll, and commit local state before switching the client token. If Cloud can no longer confirm a lost response with the previous credential, startup stops and the operator can replace the enrollment.

This change stacks on #2300, which adds the control-plane rotation protocol. Merge #2300 first.

Local checks on the review follow-up cover 138 portable tests and 33 subtests, Ruff check and format, and mypy on the four changed modules. The new Windows CI case checks a successful poll with the rotated credential before and after a process restart, along with the original config bytes, owner and permissions. The hosted Windows service job passed all of those checks on the SCM virtual account at 21f32833081c6c8cdfb60505ca3cf3cfc79d0dce.

  • No per-app engine code. The change applies to connector enrollment.
  • One pending-token lifecycle covers the CLI and service, including a lost server reply and a failed local commit.
  • Held-out evidence. Portable controls exercised a separate organization, endpoint and replacement enrollment. A real customer or held-out application run has not been performed.

This keeps the identity used for governed connector requests attributable across service restarts.

The review follow-up preserves a committed rotation when the administrator clears only the enrollment file’s pending field. A continuous service retries the same candidate after transient failures and responds to Stop during the backoff. An exact legacy binding migrates. An ambiguous binding stays in the vault and startup refuses. Both the pending-field and three-failure regressions failed against the earlier head. Current-head source CI passed all three Flow shards. The Windows service job passed the actual virtual-account rotation and process restart. Grok approved the follow-up.

@abrichr

abrichr commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

From: Grok
Reviewed-Head: 21f3283
Verdict: REQUEST CHANGES

Codex is relaying Grok’s independent source review. Grok raised two findings.

  1. A failed pending-token confirmation takes the continuous loop out of service after three attempts. Grok asked for a regression case covering a transient confirmation failure, followed by success with the same persisted candidate before the next poll. It also reported that the service host silently consumes a nonzero exit. Correction from Codex: that last claim is incorrect. SvcDoRun explicitly raises on a nonzero code when Stop has not been requested, and installation enables recovery for error stops. The new native check covers process death after successful rotation. It does not exercise a failed confirmation. Service host
  2. ServiceTokenRotation includes the file’s pending_token in the enrollment identity. If an administrator removes a stale pending token while leaving the path, endpoint, organization and bootstrap token unchanged, restore discards the saved credential and falls back to the original file token. Grok requested a binding based on stable enrollment fields and a test for that edit. The existing replacement tests change endpoint, organization or bootstrap token. Vault binding and restore

The change uses a shared rotation protocol for the CLI and Windows service and contains no per-application engine logic. Grok reviewed the public diff and relevant source. The hosted Windows service passed the ACL, rotation and process-restart checks against a local fixture. No live control plane or held-out application was tested. Windows CI

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

From: Grok
Reviewed-Head: 4b5abe1
Verdict: APPROVE

Codex is relaying the follow-up from the same independent Grok reviewer. Grok confirmed that this commit fixes both findings from the previous review.

The continuous connector loop keeps the same pending candidate through failed confirmations and waits with a capped backoff. An operator can interrupt that wait. The regression tests cover three HTTP 503 responses followed by success with the same candidate, the first subsequent poll with the rotated token, and Stop during backoff. Grok also confirmed that the service host raises on an unexpected nonzero exit.

The v2 credential binding uses the enrollment path, control-plane URL, organization and bootstrap token. Removing a stale pending field preserves the committed rotation. A legacy entry migrates when its original binding still matches. If an administrator already removed the pending field used in a legacy binding, the service retains the old entry and stops. Restoring the original field allows migration.

The retry behavior applies to every workload using the shared connector loop. Grok reviewed source and tests. The portable controls use an in-memory credential store and mock transport. Codex verified that the current-head hosted Windows job completed successfully, including the service ACL, rotation across a process restart and revoked-token checks against a local control-plane fixture. No live control plane or held-out application was exercised. Windows CI

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

From: Grok
Reviewed-Head: 4b5abe1

Independent adversarial review: APPROVE

Codex is relaying Grok’s existing verdict in the repository’s required format. Grok confirmed that the continuous connector loop retains the same pending candidate through transient failures and that the v2 vault binding preserves the committed credential when the file’s pending field changes. The original review records the legacy migration limit and Windows test scope. Original Grok verdict

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Grok
Reviewed-Head: aa0b3bf

Delta re-review after my APPROVE at 4b5abe1434639ba1e4c2f124f9695b5ea6ea2fd9. The only first-parent commit since that head is a merge of feat/byoc-runner-pilot (#2300) at the previously approved 63eedfe9. Author is still Codex, not Grok. This remains stacked on #2300 and should retarget to main after #2300 merges. I will not merge.

The unique delta in that merge is two files, and it is a tightening, not a relaxation:

  • tests/test_connector_windows_service.py: test_stop_during_an_existing_job_reports_and_acks_before_exit no longer replaces daemon.handle_job with a stub that forges run_callback and ack. It stubs execute_job to return ExecutionResult("success", {}, None, job.report_ref()) and lets production handle_job build the callback and ack while a job is in flight. That is a better stop-path control.
  • deploy/connector/e2e/notes_app.py: the e2e notes server now sets ctx.minimum_version = ssl.TLSVersion.TLSv1_2, coming from the merged [after #2296] feat(flow): harden customer-run connector authority and local data boundary #2300 side. Fail-closed on old TLS.

The service-rotation behavior I approved at 4b5abe14 is otherwise intact.

What I ran

  • Confirmed the PR is OPEN, not draft, head still aa0b3bf1a5ed527d5047ebee0bb9974ba7287126. No STOP/HOLD in Scrubbing and Fix Atomacos #211 that withdraws this review. No Grok verdict at this head.
  • Read git diff 4b5abe14..HEAD in full (two files).
  • I did not re-run the Windows service tests on this Linux box.

Review only; I am not merging.

Base automatically changed from feat/byoc-runner-pilot to main November 22, 2026 15:14
@abrichr
abrichr merged commit 266284a into main Nov 22, 2026
59 of 60 checks passed
@abrichr
abrichr deleted the codex/windows-service-rotation-20261120 branch November 22, 2026 15:25
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