[Feature]: atomic ocx update command with daemon drain, schema validation, and multi-client sync
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 32/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- bun, typescript
Research direction
Start with command registration and option parsing in src/cli/dispatch.ts and src/cli/registry.ts, then trace daemon lifecycle code in src/server/index.ts and src/service.ts. Read the catalog synchronization paths in src/integrations/catalog-refresh.ts and src/codex/catalog/sync.ts; done means the new update flow validates before changes, coordinates drain and client refresh, restarts the daemon, and confirms /readyz is ready.
Written by the indexing model from the issue text.
Description
Problem to solve
When operators or automated agent harnesses upgrade OpenCodex via npm install -g @bitkyc08/opencodex@latest:
- Active In-Flight Runtime Rejection (
packageTreeIntegrity503): The running Bun proxy process detects filesystem changes under its active package directory (src/server/index.ts:1088packageTreeIntegrity.status()), immediately throwing503 Server_error: OpenCodex package files changed while this proxy was running; restart OpenCodex before retrying.on all/v1/*,/healthz, and/readyzendpoints. - Desynchronized Client State: The upgrade updates the package files but does not coordinate the dependent client topology:
- On-disk
opencodex-catalog.jsonand client models caches (models_cache.json) lag behind the new binary until an explicit sync command runs. - Long-lived Codex CLI
app-serverprocesses retain outdated protocol handles and stale catalog state. - Exported client targets (e.g.
~/.commandcode/providers.jsonvia PR #3833) do not automatically converge on the new version's schema or models.
- On-disk
- Manual and Error-Prone Orchestration: Operators and automation scripts are forced to compose external wrapper shell scripts (stopping the service, updating via npm, validating JSON schema, invoking
ocx sync --restart-codex, and polling/readyz). If any step is executed out of sequence or by a non-interactive runner, the deployment remains in an unready 503 or deadlocked state.
Proposed solution
Implement a first-class, atomic CLI command:
ocx update [version] [--channel <stable|preview>] [--restart-codex] [--dry-run] [--json]
Architecture & Lifecycle Stages:
- Pre-flight Schema & Readiness Guard:
- Execute internal
config validatein memory against active configuration before initiating download or termination. If configuration is invalid, abort immediately without altering running processes or files.
- Execute internal
- Managed Daemon Drain & Teardown:
- Detect whether
opencodex-proxyis running as a systemd user unit, launchd daemon, or standalone background process. - Signal a graceful drain barrier (
DRAINstate) to complete active turns while rejecting new ingress withRetry-After. - Terminate the listener cleanly before filesystem mutation begins, eliminating the
packageTreeIntegrityrace condition entirely.
- Detect whether
- Transactional Package Upgrade:
- Execute package acquisition via standard global npm/bun registry resolvers to the target version (defaulting to latest published tag on the current channel).
- Post-Install Client & Process Convergence:
- Execute internal catalog regeneration (
sync-cache) atomically with lock acquisition. - Terminate stale
app-serverchild processes cleanly usingafterCatalogWriteHandleAppServers. - Trigger
catalog-refreshacross all registered client exports (mcode,pi,raycast, andcommandcode).
- Execute internal catalog regeneration (
- Verified Service Bootstrap & Health Handshake:
- Restart the daemon/unit.
- Poll local loopback
/readyzwith bounded timeout until HTTP 200{"status":"ready"}is observed before yielding control back to the terminal. - Output structured JSON status when
--jsonis specified.
Alternatives considered
- External wrapper shell scripts (
apply-fix.sh/ cron / wrapper CLIs): Currently used in production deployments as a local workaround. Highly brittle across platforms (Linux systemd vs macOS launchd vs Windows services) and leaves non-expert users and agent harnesses vulnerable to runtime desyncs. - In-process auto-reload on package tree change: Attempting to hot-reload ES modules inside the running Bun process. Rejected due to state corruption risks in SQLite/memory caches, active WebSocket handles, and crypto sessions.
Additional context
- Upstream files involved:
src/cli/dispatch.tsandsrc/cli/registry.ts(CLI command registration and option parsing)src/server/index.ts(packageTreeIntegritycheck and graceful drain coordination)src/service.ts(daemon management across platforms)src/integrations/catalog-refresh.tsandsrc/codex/catalog/sync.ts(multi-client synchronization)
- Dominant language
- TypeScript
- Stars
- 16.9k
- Forks
- 1.3k
- Avg merge
- 7h 34m
- Merged PRs (30d)
- 667
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from lidge-jun/opencodex
-
Transient OAuth login failure persists in getLoginStatus and masks active account in dashboardMay be free again A pull request for this issue was closed without being merged. Openaccount-pool bug gui
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
lidge-jun/opencodex#7378 · 2 comments ·
Maintainers usually reply within 1 day
-
account-pool enhancement needs-design proxy
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
lidge-jun/opencodex#6737 · 1 comment ·
Maintainers usually reply within 1 day
-
fix(google-antigravity): discoverAntigravityProject fails with missing_project when project is not auto-discovered, rejecting valid tokensPossibly taken @yobushka claimed this today. Openaccount-pool bug
Difficulty 3/5 1-2 days Newbie friendliness 35/100
lidge-jun/opencodex#7382 · 2 comments ·
Maintainers usually reply within 1 day
-
account-pool bug needs-design provider proxy
Difficulty 4/5 3-5 days Newbie friendliness 42/100
lidge-jun/opencodex#7380 · 3 comments ·
Maintainers usually reply within 1 day
-
account-pool bug
Difficulty 4/5 3-5 days Newbie friendliness 48/100
lidge-jun/opencodex#7377 · 2 comments ·
Maintainers usually reply within 1 day
All issues in lidge-jun/opencodex
Similar issues
-
check:failed streams:edit
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
iptv-org/iptv#55901 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 2 days
-
package:ios ships XCFrameworks with absolute symlinks, which SwiftPM refuses to extractPossibly taken @cusnirvladislav claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
callstackincubator/rock#740 ·
-
S: triage
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 2 days
-
area:workflow bug ready-for-human
Difficulty 1/5 Under an hour Newbie friendliness 78/100
fil-donadoni/tolaria#6108 ·
Maintainers usually reply within 1 day