Skip to content

feat(messaging): add local Codex queued session messaging - #6544

Merged
lidge-jun merged 13 commits into
lidge-jun:devfrom
phillipod:feat/codex-local-messaging
Oct 8, 2026
Merged

lidge-jun merged 13 commits into
lidge-jun:devfrom
phillipod:feat/codex-local-messaging

Conversation

@phillipod

@phillipod phillipod commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Relates to #6478. This is the small, local-only Codex slice from the maintainer's staging guidance, not the full cross-machine proposal; #6478 stays open.

  • ocx message sessions [--json] lists threads currently loaded in the existing local Codex app-server, using metadata only. Pagination must be complete; missing, ambiguous, incomplete or unloaded targets fail closed.
  • ocx message send (--thread <uuid> | --name <exact-name>) --stdin [--json] queues one message for an exact loaded session. The command starts no proxy, daemon or app-server, resumes no session and installs no skill.
  • Envelopes carry a generated message ID, explicit request/response/notification kinds, response correlation and reply routes. Sender context comes from CODEX_THREAD_ID and loaded-session metadata and is explicitly marked as unauthenticated.
  • Receipts distinguish not_sent (exit 1), queued (exit 0) and unknown (exit 3). Queued means the daemon acknowledged the submission, not that the recipient processed it. An uncertain submission is never replayed.
  • Stdin, pagination, metadata concurrency and RPC waits share one operation deadline.

Maintainer follow-up (commits 79dd488574, 1666aed0f7) — fixes two findings from an independent security review of 1888b0d98e:

  1. The envelope was passed to a spawned native codex queue --message <text>, so message bodies were visible in ps and, on Linux, to other users through /proc/<pid>/cmdline. Native codex queue has no stdin option. Submission now sends the same experimental thread/queue/add JSON-RPC that native codex queue sends, over the already-open control-socket connection used for discovery and final revalidation. No helper process is spawned, the message never enters argv, and discovery, revalidation and submission share one connection. The native CLI version pin (0.160.0) is no longer needed; the running daemon must support experimental thread/queue/add. An explicit JSON-RPC rejection is not_sent (unsupported_queue / queue_rejected). Timeout, disconnect, cancellation, a malformed reply or a mismatched clientUserMessageId after the request was written is unknown, without retry.
  2. The control socket had no filesystem trust validation. The canonical socket must now be a socket owned by the current user, and every ancestor directory must be owned by the user or root and not group- or other-writable unless it is root-owned and sticky. Anything else fails closed with untrusted_socket.

Remote enrollment, bearer management, SSH/topology, dashboard controls, Claude messaging, permission/delegation policy, isolation, managed skills and idle notifications remain deferred. No global prompt, background listener or timer is added, and nothing on the request core path imports messaging.

Original work by @phillipod.

Verification

Head 1666aed0f7511a0ff19673664bc04d0dedbbab30 (PR commits plus a merge of dev at bbab02ab27, which also clears the stale release-version-line failure the old base hit in CI).

  • bun run typecheck — passed.
  • bun test tests/codex-integration/messaging-local-*.test.ts — 43 pass, 0 fail (macOS). Covers queued success with correlation, each not_sent mapping, unknown after write with exactly one request, no spawned helper, the CLI end to end against a fake Unix daemon, and socket trust rejections and acceptances.
  • Layout, file-size ratchet, structure, skill surface, repo hygiene, CLI capability and core-lab boundary guards — passed. bun run structure:check, bun run skill:surface:check and bun run privacy:scan — passed. bun run test:changed — 1,410 pass, 1 skip.
  • Before the transport change, the original native tests passed on macOS against the Codex 0.160.0 CLI bundled with the desktop app (23 pass). After it, a probe against a real 0.160.0 app-server in an isolated home confirmed request parsing and rejection mapping. A live queued success against a loaded recipient was not exercised.
  • Two independent reviews (security; correctness, protocol fidelity and docs) approved the exact head. The full suite was not run locally; hosted CI covers Linux, macOS and Windows.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • Required local validation passed; commands, results, and any full-suite exception are documented.

  • I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

Summary by CodeRabbit

  • New Features
    • Added ocx message sessions to list already-loaded local Codex sessions.
    • Added ocx message send to queue a request, response, or notification for a selected session using its exact ID or unique name. Provide message text through standard input.
    • Commands use local Unix sockets on Linux and macOS; they do not start a daemon or resume sessions. Receipts distinguish queued, not sent, and unknown outcomes. Unknown submissions are not retried automatically.
  • Documentation
    • Added CLI help and reference documentation describing supported platforms, message limits, selection, and receipt outcomes.

@coderabbitai

coderabbitai Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: lidge-jun/opencodex/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 90e46483-2621-40bc-96a4-f421067e1481
📥 Commits

Reviewing files that changed from the base of the PR and between 1888b0d and 1666aed.

📒 Files selected for processing (20)
  • docs-site/src/content/docs/reference/cli/messaging.md
  • scripts/test-layout/layout.json
  • skills/ocx/references/01_surface_agents-routing.md
  • src/cli/capabilities-agents-routing.ts
  • src/cli/message-command.ts
  • src/cli/message-runtime.ts
  • src/messaging/rpc.ts
  • src/messaging/send.ts
  • src/messaging/socket.ts
  • structure/INDEX.md
  • structure/decisions/ADR-6478-local-messaging-foundation.md
  • structure/decisions/ADR-6479-local-messaging-command.md
  • structure/local-messaging.md
  • structure/manifest.json
  • tests/codex-integration/messaging-local-cli.test.ts
  • tests/codex-integration/messaging-local-lifecycle.test.ts
  • tests/codex-integration/messaging-local-send.test.ts
  • tests/codex-integration/messaging-local-socket.test.ts
  • tests/fixtures/test-layout-expected.json
  • tests/helpers/messaging-local.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.


📝 Walkthrough

Walkthrough

Adds ocx message sessions and ocx message send for local loaded Codex sessions. The commands use validated Linux/macOS Unix sockets, bounded discovery and input, and correlated queue submission. Receipts distinguish not_sent, queued, and unknown; uncertain submissions are not replayed.

Changes

Local Codex messaging

Layer / File(s) Summary
Scope and implementation records
devlog/_plan/261003_codex_local_messaging/*, structure/decisions/ADR-6478-local-messaging-foundation.md, structure/decisions/ADR-6479-local-messaging-command.md
Adds proposal, preparation, implementation, and validation records. The records describe the local-only boundary, inspected Codex contract, transport amendment, checks, and recorded readiness gates.
Local transport and session discovery
src/messaging/types.ts, src/messaging/socket.ts, src/messaging/budget.ts, src/messaging/rpc.ts, src/messaging/discovery.ts, tests/helpers/messaging-local.ts, tests/codex-integration/messaging-local-{socket,lifecycle,discovery}.test.ts, structure/local-messaging.md
Adds thread metadata types, Unix-socket trust checks, bounded RPC and deadline handling, and complete loaded-session discovery with exact selector resolution. Tests cover socket trust, lifecycle, pagination, and selection.
Envelope and queued submission
src/messaging/input.ts, src/messaging/envelope.ts, src/messaging/send.ts, tests/codex-integration/messaging-local-{envelope,send}.test.ts, structure/local-messaging.md
Adds strict bounded stdin reading, message-kind and correlation validation, envelope construction, destination revalidation, and one queue attempt. Receipts report not_sent, queued, or unknown; tests cover privacy, validation, and pre-write and post-write outcomes.
CLI integration and published contract
src/cli/message-*.ts, src/cli/{dispatch.ts,help.ts,registry.ts,capabilities-agents-routing.ts,codex-shim-autorestore.ts}, docs-site/src/content/docs/reference/cli*, skills/ocx/references/*, structure/{INDEX.md,manifest.json,cli-management.md,runtime.md}, scripts/{generate-ocx-skill-surface.ts,test-layout/layout.json}, tests/codex-integration/messaging-local-cli.test.ts, tests/ci-workflows/skill-ocx-generated.test.ts, tests/fixtures/test-layout-expected.json
Wires the command parser and handler into CLI dispatch and usage surfaces. Updates capability references, documentation, structure indexes, and test-layout mappings. CLI tests check usage handling, command outcomes, and receipt contents.

Priority: ⬇️ Low

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant CLI as message-command
  participant Sender as sendLocalMessage
  participant RPC as LocalMessageRpc
  participant AppServer as Codex app-server
  CLI->>Sender: Pass message options, context, and budget
  Sender->>RPC: Connect and initialize
  RPC->>AppServer: Request loaded-thread pages and metadata
  AppServer-->>RPC: Return loaded-thread metadata
  Sender->>RPC: Re-read destination and queue message
  RPC->>AppServer: Send thread/read and thread/queue/add requests
  AppServer-->>RPC: Return metadata and queue response
  RPC-->>Sender: Return queue result
  Sender-->>CLI: Return message receipt
Loading

Merge Risk: ⚪ Minimal · up to 1666a

No confirmed merge-blocking issue remains for local messaging. Validate a queue submission against a real supported daemon during normal acceptance checks.

Architecture Summary

Architecture risk: 🔵 Low · up to 1888b

The change affects 7 systems.

Changed systems: src, tests, structure, devlog, docs-site, scripts, skills

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — src (service) was modified; 18 changed files map to changed impact.
  • observed — tests (service) was modified; 9 changed files map to changed impact.
  • observed — structure (service) was modified; 7 changed files map to changed impact.
  • observed — devlog (service) was modified; 6 changed files map to changed impact.

Before / after behavior

  • observed — Modified behavior in devlog/_plan/261003_codex_local_messaging/000_scope_and_boundary.md: Adds the proposal’s status, preparation baseline, scope direction, and distinction from a separate broader experiment; boundary acceptance remains pending.
  • observed — Modified behavior in devlog/_plan/261003_codex_local_messaging/000_scope_and_boundary.md: Defines included and excluded features, including exact local Codex discovery and queued delivery while excluding remote, Claude, persistent, session-management, retry, and monitoring capabilities.
  • observed — Modified behavior in devlog/_plan/261003_codex_local_messaging/000_scope_and_boundary.md: Specifies an opt-in command boundary that avoids messaging activation during ordinary proxy startup, gives provisional CLI forms, and limits transport to Linux/macOS Unix sockets; Windows is explicitly unsupported. Send requires exactly one selector and rejects unsupported targets or options before transport or child-process work.
  • observed — Modified behavior in devlog/_plan/261003_codex_local_messaging/000_scope_and_boundary.md: Sets bounded loaded-thread discovery and metadata rules, requiring complete discovery before unique-name resolution and treating metadata failures or cursor exhaustion/repetition as incomplete. Requires selected threads to be loaded without resuming them, uses existing Codex home/runtime helpers, includes selection and probing in the overall deadline, and treats CODEX_THREAD_ID as attribution rather than authority.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 96.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 25 functions across 29 files. (9 skipped: 9…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely identifies the main change: adding local Codex queued session messaging. It matches the implementation and stated PR objectives.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · 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

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the enhancement New feature or request label Oct 3, 2026
@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

⏳ DRAFT

  • review readiness checklist open (0/4 boxes ticked).

What to do

  • Tick all four boxes in the PR description once you're done (currently 0/4).

Review readiness checklist

  • ⬜ Required local validation passed; commands, results, and any full-suite exception are documented.
  • ⬜ I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
  • ⬜ I resolved all correct Codex and CodeRabbit findings.
  • ⬜ My PR is ready for review.

0/4 boxes ticked.

Automatic draft conversion failed. Please convert this pull request to a draft manually until every box above is ticked.

@phillipod

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@phillipod
phillipod force-pushed the feat/codex-local-messaging branch from d5cf770 to 0e0eef9 Compare October 3, 2026 22:01
@phillipod

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Ingwannu

Ingwannu commented Oct 4, 2026

Copy link
Copy Markdown
Owner

Scoped offline lifecycle verification at 0e0eef9: bun test tests/codex-integration/messaging-local-lifecycle.test.ts passed 15/15, 0 failures, 1709 assertions, exit 0 on Linux/Bun 1.4.0. This exercises import-time inactivity, command-local literal import inventory, bounded pending RPCs, socket cancellation/deadlines, oversized/invalid frames, output budgets, TERM/KILL cleanup of owned launcher groups, and bounded waiting when detached descendants retain pipes. The detached fixture is test-owned and explicitly cleaned up; this is not proof that the runner terminates an escaped process group, which the owning doc correctly excludes. Work ran sequentially with CPUQuota=75%, MemoryMax=1536M, zero swap and fresh private homes. No real Codex daemon/session/message, native 0.160.0 binary, remote tunnel or live account was used. I read the local ownership doc and the budget/process/test fixture paths; this is not a complete 43-file/native-queue/permission-boundary approval. Required hosted current-head CI and independent full review remain separate.

@phillipod
phillipod force-pushed the feat/codex-local-messaging branch from 0e0eef9 to aa49a10 Compare October 4, 2026 20:32
@phillipod
phillipod marked this pull request as draft October 4, 2026 20:33

@Ingwannu Ingwannu left a comment •

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Read the rebased checkpoint at aa49a10d5bd7e059246441464c6929f75ca12b7a. The messaging runtime and the three message command/argument/runtime modules are byte-identical to the published 0e0eef93 source in direct comparison, so I did not repeat unchanged native tests or present the author's historical results as independent current execution.

The documented distinctions remain important: a queued receipt acknowledges submission, not recipient processing/steering; an unknown outcome must not be replayed; a post-revalidation unload fixture is not proof of real-daemon atomic loaded-target enforcement. Updated checkpoint (2026-10-04 22:45 UTC): the author has now checked all four readiness boxes and GitHub reports Ready at the same aa49a10d5bd7e059246441464c6929f75ca12b7a head. The target/readiness gate completed successfully, but exact-head Cross-platform CI 37232506258 and React Doctor 37232506242 still require workflow-execution authorization (action_required), not successful execution. The latest hygiene rerun is cancelled; an earlier successful same-head hygiene run does not turn that cancelled rerun into a pass. Please keep completed hosted verification, the independent boundary review and sponsorship decisions separate from the author's local attestation. This COMMENTED checkpoint is not an approving review or authorization to execute the fork workflows.

No native daemon/binary was invoked by me, no actual recipient was contacted, and no workflow authorization, sponsorship waiver, scan, author-branch modification or approval was performed.

@github-actions
github-actions Bot marked this pull request as ready for review October 4, 2026 22:44
- Define a provisional command-owned local discovery and queued-delivery boundary against current dev.
- Map reusable experimental responsibilities while excluding remote, Claude, dashboard and root-relay layers.
- Record Codex 0.160.0 schema receipts, unverified contracts and focused acceptance cases.
- Verify privacy, structure ownership, document links, source references and whitespace; runtime tests remain pending.
- Add command-owned Unix metadata RPC, complete loaded-session discovery and exact target resolution without startup activation.
- Bound deadlines, frames, concurrency and helper output; terminate owned launcher process groups on incomplete execution.
- Add isolated regressions and pin native Codex 0.160.0 queue success and lost-acknowledgement interoperability.
- Document ownership, provisional scope and remaining CLI/envelope work; preserve the explicit hold on PR creation.
- Verify 25 changed messaging tests, focused layout/structure/ratchet checks, typecheck, privacy and whitespace.
- Added command-local discovery and exact queued delivery with metadata-derived sender context and correlated peer envelopes.
- Preserved not_sent, queued and unknown outcomes with one native invocation, isolated helper homes and no automatic replay.
- Added bounded stdin, runtime admission, CLI registration, public documentation and owning architecture records.
- Validated 1039 changed tests plus native interoperability, CLI/layout/structure regressions, typecheck, privacy and the documentation build; independent review and full-suite readiness remain pending.
- Recorded the clean refresh onto upstream dev 358b8ff and preservation of the newly integrated test-layout entries.
- Verified 1039 changed tests and 94 explicit source guards, plus typecheck, privacy, structure, generated CLI surface and documentation build.
- Kept full-suite readiness, independent/security review and PR publication authorization explicitly outstanding.
- Cancel pending output readers after forced cleanup without waiting on detached descendants or cancellation hooks.
- Preserve owned process-group termination, unknown submission receipts and no-replay behavior.
- Add timeout, cancellation and overflow regressions; keep upstream-facing documentation confined to the proposed scope.
- Verify 24 focused lifecycle/send/native-queue tests, strict typecheck and structure ownership checks.
- Record the current-dev refresh, bounded pipe cleanup and extraction provenance for the local-only contribution.
- Verify 1040 connected tests and 94 explicit guards, plus native interoperability, typecheck, privacy, structure and the documentation build.
- Document the full-suite resource exception and keep independent review, publication and deployment authority separate.
- Added contract-focused docstrings for local messaging and owned lifecycle helpers.
- Verified peer permission claims remain text-only and post-check native rejection stays unknown without replay or resume.
- Clarified non-atomic target checks and receiving-harness permission enforcement limits.
- Validated 45 focused tests, 1043 changed tests, 110 guards, typecheck, docs build, privacy and structure checks.
- Group local messaging test registrations using the existing layout data style.

- Preserve every mapping and its ordering without changing the size-ratchet policy.

- Verify JSON equivalence and pass all 27 layout and file-size regression tests.
@phillipod
phillipod force-pushed the feat/codex-local-messaging branch from aa49a10 to 1888b0d Compare October 5, 2026 22:00
@phillipod
phillipod marked this pull request as draft October 5, 2026 22:00
@github-actions
github-actions Bot marked this pull request as ready for review October 5, 2026 22:09
@lidge-jun

Copy link
Copy Markdown
Owner

Thanks @phillipod. A maintainer review found two security issues at 1888b0d98e, and I pushed fixes straight to your branch (79dd488574, 1666aed0f7) after merging current dev:

  1. Native codex queue only accepts --message <text>, so the envelope showed up in process arguments (ps, and /proc/<pid>/cmdline for other users on Linux). Submission now sends the same experimental thread/queue/add RPC that native codex queue uses, over the connection already opened for discovery and revalidation. No helper is spawned, and the CLI version pin is gone.
  2. The control socket path is now checked like OpenSSH StrictModes: the socket and every ancestor directory must be owned by the user or root, with no group/other write access unless the directory is root-owned and sticky.

Your contract stays the same: not_sent / queued / unknown, no replay, one operation deadline, opt-in only. The PR description is updated to match.

… under its cap

Bun.Glob yields backslash paths on Windows, so the activation-boundary
inventory compared native separators against POSIX allowlist entries.

Current dev already holds scripts/test-layout/layout.json at 2,000 lines,
which the file-size ratchet reports as NEW_OVERSIZED. Join five single-entry
registration lines onto their neighbours; parsed values and ordering are
unchanged (1,996 lines).
@lidge-jun
lidge-jun merged commit df54552 into lidge-jun:dev Oct 8, 2026
37 checks passed
@lidge-jun lidge-jun mentioned this pull request Oct 8, 2026
3 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants