Skip to content

fix(startup): skip unused native Codex ownership probes - #7184

Merged
lidge-jun merged 5 commits into
devfrom
fix/windows-start-latency
Oct 16, 2026
Merged

lidge-jun merged 5 commits into
devfrom
fix/windows-start-latency

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Oct 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Skip the two native-Codex service-manager ownership inspections and native-main preparation when the existing Codex startup intent gate is closed (Codex OFF, a sibling, or a hub without local integration). These inspections run synchronous Windows Task Scheduler/service children before the CLI can publish its runtime record, even though the disabled lifecycle cannot consume their answers.
  • Enabled startup retains both separate ownership decisions, including the fresh second Task Scheduler listing needed to detect a concurrent installer. Required ACL hardening, live-owner discovery and all startup deadlines remain unchanged.
  • Add a live-server regression proving that Codex OFF performs zero ownership inspections or native-manager preparations and still serves health. Update the existing scheduler race fixture to exercise enabled startup; it preserves the raw first/second verdict and query-count assertions while keeping unrelated catalog writes outside that fixture.

This addresses demonstrated unnecessary readiness-path work while investigating the 45-second owner-start failure in Windows 9/9, run 38699763674. Six Windows fresh-process/home timing samples are recorded below. They do not establish that the full reported timeout is resolved; the claim remains limited to removing unnecessary probes. The separate DPAPI implementation in #7181 is not included or duplicated.

Verification

Current validation head: e9fe0737818763db4f3778ee087235b6b7300b8b, after merging origin/dev at 947b9b6ab6f259eae060c576dbc368a58d54a487. No additional runtime changes were made for this validation.

  • Linux (ssh lidge, Bun 1.4.3): ~/bin/ocx-lane-ci2.sh e9fe0737818763db4f3778ee087235b6b7300b8b h2-7184-linux — full suite, 450s; typecheck exit 0, test exit 1. ~/bin/ocx-lane-cmp.sh h2-7184-linux dev-7a42860 reports 49,339 pass / 29 fail / 147 skip, versus baseline 49,138 / 30 / 146, 0 new failure identities. The exact typecheck diagnostic sets are both empty. The additional skip is the Windows-only Windows never resolves a captured remote candidate case added on dev since the baseline (tests/cli/cli-codex-cli-update-boundary.test.ts:18). The Codex-OFF zero-probe test and enabled-startup fresh-listing race pass in this run. This is baseline comparison evidence, not an all-green suite.
  • Windows (ssh mini, Bun 1.4.3): OCX_LANE_SLOTS=3 ~/bin/ocx-lane-ci2.sh e9fe0737818763db4f3778ee087235b6b7300b8b h2-7184-win — full suite completed in 2,104s, typecheck exit 0, test exit 1. ~/bin/ocx-lane-cmp.sh h2-7184-win dev-7a42860 reports 48,625 pass / 81 fail / 821 skip, versus baseline 48,436 / 81 / 809, with 7 new failure identities and 7 baseline identities now passing/absent. The exact typecheck diagnostic sets are both empty. These seven identities are differences against the older baseline, not attribution to this PR; the current-dev comparison below supersedes that interpretation. Both the Codex-OFF zero-probe regression (840.75ms) and enabled-startup fresh-listing race (390.65ms) passed. The +12 skips are accounted for by nine additional Unix-only cases (four CLI-provenance, two FIFO-boundary, two UID-scanning and one npm-config case) plus the Unix shutdown fixture expanding three cases into six; these changes are inherited from dev since the pinned baseline, not new skips in this PR's delta. The initial task stopped at that comparison; the coordinator subsequently authorized the focused current-dev comparison below. No source fixes were made.
  • Windows cold-start samples: 3 fresh process/home starts each for dev 947b9b6ab6 and PR e9fe073781, measured from spawning bun run src/cli/index.ts start --port <unused port> to HTTP 200 /healthz with status: ok, service: opencodex, and the spawned PID. Codex/Grok/Desktop integration and Claude interception were explicitly OFF, with isolated HOME/USERPROFILE/CODEX_HOME/OPENCODEX_HOME. Dev: 2.876 / 2.388 / 2.346 s; PR: 2.364 / 2.318 / 2.292 s. Each process was terminated afterward; follow-up checks confirmed all six PIDs exited and ports closed (52934, 53062, 53199, 53305, 53419, 53531; never 10100). The middle pair ran PR-first to reduce order bias. These samples share a machine with the full suite and do not flush OS caches; the small, noisy difference is not reliable evidence of a general Windows speedup or resolution of the reported 45-second timeout. The PR claim is limited to removes unnecessary probes.
  • Security disposition: source review finds no new ownership authority from skipping the probes; enabled startup retains both independent inspections and fresh second scheduler listing, with foreign/unknown fencing and the existing owner/write locks. The coordinator will post the detailed disposition; maintainer acceptance remains separate.
  • Hosted PR CI: current-head run 38916693509, pull_request, attempt 1 — SUCCESS, exact head e9fe0737818763db4f3778ee087235b6b7300b8b. All four Ubuntu test shards, aggregate ci, gates (including typecheck/privacy), structure, storage policy, API usage, keyring, Docker and npm-global smoke passed. Catalog async contracts, React Doctor and PR policy checks also passed. Windows/macOS matrix legs were policy-skipped; Windows validation is the separate mini run above.
  • git diff --check passed; working tree is clean. No local test suite was run; full-suite evidence is from the requested remote hosts.

Apples-to-apples Windows follow-up (coordinator-authorized):

Fetched dev tip d93965b0245d11eb8e3cab0b188cad5d83ca81ea; compared it with PR head e9fe0737818763db4f3778ee087235b6b7300b8b. Ran all five explicitly supplied paths (the packet said six but listed five): codex-composed-acceptance.test.ts, claude-picker-windows.test.ts, sibling-home-client-sync.test.ts, server-management-auth.test.ts, and codex-cli-update-plan.test.ts. Their source bytes are identical at both revisions. Both revisions used ocx-lane-ci2.sh, Bun 1.4.3, OCX_LANE_SLOTS=3, OCX_TEST_NO_QUEUE=1, and the same file arguments. The runs were serial: dev1, head1, head2, dev2.

Label Revision Pass / fail / skip Reported errors Typecheck Seconds
h2-dev-tip-7 d93965b024 141 / 5 / 2 1 exit 0 159
h2-dev-tip-7-r2 d93965b024 141 / 5 / 2 1 exit 0 158
h2-head-7 e9fe073781 141 / 5 / 2 1 exit 0 161
h2-head-7-r2 e9fe073781 140 / 7 / 2 1 exit 0 175

No reproducible head-only named-test failure was observed. All four test commands still exit 1. Every run reported CLI watchdog: ocx ensure. Head repeat 2 additionally hit a management-origin fixture teardown timeout and an unnamed cleanup-hook timeout; the named test passed on head repeat 1 and both dev runs. This intermittent result remains recorded rather than excused as passing. Focused results do not reproduce all full-suite interactions; they do refute attribution of the original seven identities solely from their absence in dev-7a42860. No fixes or further reruns were performed.

Each cell below is run 1 / run 2:

Test identity Current dev PR head
WP13 #1802: /api/sync applies on-disk config FAIL / FAIL FAIL / FAIL
Picker: desktop-integration change FAIL / FAIL FAIL / FAIL
Picker: gateway-mode change PASS / PASS PASS / PASS
Picker: preference change FAIL / FAIL FAIL / FAIL
Lone custom-home startup sync FAIL / FAIL FAIL / FAIL
Context bearer reaches body validation PASS / PASS PASS / PASS
Isolated npm preserves operator HOME PASS / PASS PASS / PASS
Additional shared failure: WP13 A-reduced OFF preservation FAIL / FAIL FAIL / FAIL
Additional intermittent case: management browser origins match request origin PASS / PASS PASS / FAIL (teardown hook)
Unnamed cleanup-hook result absent / absent absent / FAIL

Earlier implementation evidence (before this merge) included the regression red/green proof, focused lifecycle/probe tests, test:changed, structure/privacy checks. Current-head results above supersede the earlier profiling dispatch as validation evidence.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed. (structure/runtime.md documents the activation gate.)
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults. (Ownership gating warrants maintainer review; enabled startup keeps both fresh checks.)

@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: Repository: lidge-jun/opencodex/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: c916e6d8-d2aa-4f1c-aba7-83af8528e84b
📥 Commits

Reviewing files that changed from the base of the PR and between 947b9b6 and e9fe073.

📒 Files selected for processing: 7
  • scripts/test-layout/layout.json
  • src/server/index.ts
  • structure/runtime.md
  • tests/codex-integration/bearer-admission-routed-provider.test.ts
  • tests/codex-integration/codex-service-manager-probe-hardening.test.ts
  • tests/fixtures/test-layout-expected.json
  • tests/server/server-startup-codex-off.test.ts
+------------------------------------------------+
| PENDU: Prompt Engineered Nifty Debugging Unit. |
+------------------------------------------------+
  \
   \     /)/)
        ( '')
        /  |
      o(___)
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@lidge-jun

Copy link
Copy Markdown
Owner Author

Being carried into #7215 with your authorship preserved; this PR will be closed when the bundle lands.

lidge-jun pushed a commit that referenced this pull request Oct 16, 2026
Carried from #7184.

Co-authored-by: GOAT <goat@localhost>
@lidge-jun

Copy link
Copy Markdown
Owner Author

Held out of #7215 after remote validation: with the native ownership probes skipped, startup returns sooner and on Windows the config-dir ACL hardening can still hold the test home at teardown, so tests/codex-integration/bearer-admission-routed-provider.test.ts fails with EBUSY and cascades (33 failures in the union full run on mini; 1 of 2 isolated runs). The same union without this change passes that file 3/3. Switching that file's teardown to removeTreeAfterBackgroundWork alone made it worse (5 s test timeouts), so the fix needs a deliberate look.

lidge-jun added a commit that referenced this pull request Oct 16, 2026
…remote-list RFC (#7186, #7203, #6157) (#7215)

Carried from #7186, #7203, #6157 (one commit per source PR, original authors preserved). #7154 and #7184 held out.

Remote exact-head validation (hosted GitHub Actions stalled; local tests not run by maintainer rule): union candidate codex/prr-integ-6 (368006f, tree 27fdc37) on mini (Windows) and lidge (Linux), typecheck + full suite, compared with base-dev 4ae4936 on each host.

Co-authored-by: Epinephrine <luvs01@hanmail.net>
Co-authored-by: luvs01 <27862058+luvs01@users.noreply.github.com>
@lidge-jun

Copy link
Copy Markdown
Owner Author

Correction to my earlier note: the bearer-admission EBUSY / spend-ledger teardown failure on Windows also appeared in later union runs that did not contain this change (integ-8 and integ-9), and the file passes 4/4 in isolation on both dev and the union. So it is an intermittent Windows teardown race in that test, not caused by #7184. This PR was held out of #7215 on a wrong attribution; it can land on its own merits.

… settle teardown

Each case starts a real server. On Windows the config-dir ACL hardening can exceed the
5 s default and still hold the home at teardown, which then cascades into spend-ledger
owner conflicts. Use SERVER_BUDGET_MS for the file and removeTreeAfterBackgroundWork.
@lidge-jun

Copy link
Copy Markdown
Owner Author

Maintainer security disposition before landing (head e9fe073): no ownership bypass. With the startup gate closed, skipped probes yield null. Cache writes require an explicit owned verdict, manager preparation is skipped, and startup selects the existing no-op lifecycle with homeId null, so a skipped probe never turns foreign or unknown ownership into authority. Later sync keeps the persisted-intent checks and write admission. With local Codex integration enabled, both ownership inspections still run (the second one fresh). The scheduler-race regression and the Codex-OFF zero-probe regression pass on Linux and Windows.

Validation: the lidge full suite shows 0 new failures against the dev baseline. On mini, the focused files were compared twice each at dev d93965b and this head: 5 failures reproduce identically on both (mini environment, and they pass in hosted Windows CI), with no failure reproducible only on the head. Windows cold-start samples were dev 2.88/2.39/2.35s and head 2.36/2.32/2.29s, which is too noisy for a speedup claim, so the claim stays "removes unnecessary probes". Hosted PR CI is green on the exact head.

@lidge-jun
lidge-jun marked this pull request as ready for review October 16, 2026 15:32
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner October 16, 2026 15:32
@lidge-jun
lidge-jun merged commit 520865e into dev Oct 16, 2026
46 checks passed
@lidge-jun
lidge-jun deleted the fix/windows-start-latency branch October 16, 2026 15:32
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T15:36:40.856273Z e9fe073 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e9fe073781

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/server/index.ts
Comment on lines +270 to +275
const startupCacheOwnership = shouldSyncCodexOnStart(config) ? inspectStartupOwnership(
deps,
startupOwnershipHomes,
startupOwnershipStatePaths,
startupWindowsTaskListingCache,
);
) : null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Update the mapped ownership-probe contract

For Codex-OFF, sibling, or hub-without-local-integration starts, this branch now skips the first ownership probe and the analogous branch below skips the second, but structure/ops/service-and-sidecars.md:109-113 still states that every proxy startup asks twice and that the second query is mandatory. Update that mapped architecture document to scope the two-probe contract to enabled startup so it does not contradict the runtime.

AGENTS.md reference: src/AGENTS.md:L11-L11

Useful? React with 👍 / 👎.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant