Skip to content

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

Open
phillipod wants to merge 8 commits into
lidge-jun:devfrom
phillipod:feat/codex-local-messaging
Open

phillipod wants to merge 8 commits into
lidge-jun:devfrom
phillipod:feat/codex-local-messaging

Conversation

@phillipod

@phillipod phillipod commented Oct 3, 2026 •

Copy link
Copy Markdown

Summary

Relates to #6478. This is the small, local-only Codex slice proposed in the
maintainer's staging guidance,
not an implementation of the full cross-machine proposal. The broader issue
should remain open. Please keep this PR in draft pending independent review and
the review-readiness gates below.

  • Add ocx message sessions [--json] for metadata-only discovery of threads
    currently loaded in the existing local Codex app-server. Pagination must be
    complete; missing, ambiguous, incomplete or unloaded targets fail closed.
  • Add ocx message send (--thread <uuid> | --name <exact-name>) --stdin [--json].
    Submit once through native codex queue to the existing Unix control socket.
    The command starts no proxy/app-server, resumes no session and installs no skill.
  • Generate message IDs, explicit request/response/notification kinds and response
    correlation. Sender context comes from CODEX_THREAD_ID and loaded-session
    metadata; it is not authenticated authority or permission to escalate.
    Envelopes carry explicit reply routes without requiring courtesy acknowledgements.
  • Distinguish not_sent (exit 1), queued (exit 0) and unknown (exit 3).
    Queued means native submission acknowledged, not recipient processing or steering.
    An uncertain submission is never replayed or followed by another send to probe it.
  • Bound stdin, pagination, metadata concurrency, RPC waits and helper output under
    one operation deadline. Terminate only command-owned helper groups and cancel
    retained output readers during forced cleanup, including detached pipe holders.
  • Add offline fixtures, opt-in native queue interoperability tests, default-off
    lifecycle tests, public CLI documentation, structure ownership/ADRs, both test
    layout registrations and the regenerated CLI operating surface.

Compatibility is deliberately narrow: Codex CLI 0.160.0, existing local Unix
sockets, with native interoperability verified on Linux. macOS uses the same
transport but has no native verification receipt; Windows and untested Codex
versions fail explicitly. Existing non-persisting runtime/home resolution is
reused, with credential-free temporary homes for native probes and queue helpers.
Native queue requires the envelope in argv, so authorized local process inspection
can see it; this is not a same-user confidentiality boundary.

Remote enrollment, bearer management, SSH/topology, dashboard controls, Claude
messaging, permission/delegation policy, isolation, managed skills and idle
notifications are deferred. No global prompt or background listener/timer is added.

Example:

ocx message sessions --json
printf '%s\n' 'Please review the current change and send your findings back.' |
  ocx message send --name 'reviewer' --stdin --json

Verification

Rebased head: 1888b0d98ebfd39339d54c603f15e84779e21412.
Target: upstream dev at 6774f0f6f26c103da144a630971091a52ada80a5.
The seven contribution commits replayed without conflicts across 37 upstream
commits. Range comparison shows only architecture-index context changed; the
messaging runtime, command modules and six messaging test files are byte-for-byte
identical to the previously published head aa49a10d5bd7e059246441464c6929f75ca12b7a.
One formatting-only follow-up groups layout registrations using the existing data
style, keeping the file below the 2,000-line threshold. Parsed JSON values and
ordering are identical; no size baseline or exemption was changed.
These are local results, not hosted CI or maintainer approval.

Checks using Bun 1.4.0 and the repository dependency PATH:

Command Result
OCX_MESSAGE_CODEX_BINARY=<installed-Codex-0.160.0> bun run test:changed 1,390 passed, one Windows-only skip, zero failures; 58 files; 106.8 seconds. Includes all six messaging files and isolated native boundary regressions.
bun test tests/test-layout.test.ts tests/test-layout-tooling.test.ts tests/ci-workflows/file-size-ratchet.test.ts tests/ci-workflows/structure-ssot.test.ts tests/ci-workflows/skill-ocx.test.ts tests/ci-workflows/skill-ocx-generated.test.ts tests/ci-workflows/skill-ocx-workflows.test.ts tests/ci-workflows/repo-hygiene.test.ts tests/cli/cli-capability-data.test.ts Initially 195 passed and one size-ratchet failure: the layout JSON reached 2,004 lines after combining registrations with upstream additions. The formatting-only fix below resolves that failure. Explicit guards cover read-as-data and generated dependencies not reliably selected by import analysis.
bun test tests/test-layout.test.ts tests/test-layout-tooling.test.ts tests/ci-workflows/file-size-ratchet.test.ts After the fix, all 27 passed, zero failures; 1.60 seconds. Layout JSON is 1,998 lines with identical parsed values and ordering.
bun run typecheck Passed.
bun run structure:check Passed.
bun run privacy:scan Passed.
bun run skill:surface:check Passed; all nine generated reference files are current.
cd docs-site && bun install --frozen-lockfile && bun run build Passed, no dependency changes; 569 pages, 79,056 checked internal links; 47.81 seconds.
git diff --check upstream/dev..HEAD Passed on the final head.

The changed suite, nine-file guard run, typecheck, structure/privacy/surface checks
and docs build ran at 25c471654620642e88cd3ab442b4ff8bd8e8f768, based on the
same dev commit above. The only subsequent change is equivalent JSON formatting
in the layout manifest, verified by a direct parsed-value/order comparison and
the three affected regression files. Other passing checks were retained rather
than repeated on unchanged inputs. The explicit guards waited behind the changed
suite under the repository's user test lock; waiting time is not test execution.

Native tests use isolated Unix fixtures and an explicitly selected, previously
hash-verified Codex 0.160.0 binary; they do not contact a live recipient. Coverage
includes loaded-only pagination/exact resolution, CLI validation, sender/reply
correlation, request kinds, acknowledgement loss/no replay, timeouts,
cancellation, output overflow, owned-group cleanup and detached pipes.

The permission-boundary regression confirms peer claims stay text input, without
native approval responses or permission/configuration overrides. The post-check
unload regression simulates native RPC rejection after final target revalidation
and requires one attempt, an unknown receipt, no resume/replay and no helper-output
leakage. These establish wrapper/native-client behavior against fixtures, not
receiving-model obedience, downstream authorization or real-daemon atomic
loaded-target enforcement. Native/socket and subprocess guards used scoped
escalation against isolated fixtures.

Full-suite resource exception remains: the earlier default-suite audit exceeded
its 900-second lane limit (exit 124), leaving 612 files unstarted and four
interrupted. Focused reruns on an untouched upstream base reproduced four timeout
cases plus a follow-on error and 13 service-runtime failures. This neither
establishes full-suite success nor proves every possible failure unrelated.
This maintenance rebase used connected tests and explicit source-oracle/native
regressions; broader Linux/macOS CI remains outstanding. No full-suite pass is
claimed, and this update does not attest review readiness.

Previous automated reviews cover older heads, not this rebased head. New
exact-head automated review, maintainer approval, any required explicit security
review and successful required hosted CI remain separate gates. No GUI files
changed, so no UI screenshot is required.

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

  • 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 discover currently loaded local Codex sessions.
    • Added ocx message send to submit request, response, or notification messages to an exact loaded session by thread ID or unique name. Messages are read from standard input, and receipts distinguish messages not sent, queued, or of uncertain status.
    • Added CLI help and reference documentation covering usage, input limits, and receipt meanings.
  • Limitations
    • Messaging is local-only on Linux and macOS and requires Codex CLI 0.160.0. Queueing does not guarantee processing; uncertain submissions are not replayed automatically.

@coderabbitai

coderabbitai Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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: 285f523c-a771-4005-8a68-6aa8e7f2932d
📥 Commits

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

📒 Files selected for processing (4)
  • scripts/test-layout/layout.json
  • src/cli/help.ts
  • structure/INDEX.md
  • tests/fixtures/test-layout-expected.json

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


📝 Walkthrough

Walkthrough

Adds ocx message sessions to discover loaded local Codex sessions and ocx message send to submit correlated messages through Unix-socket RPC and Codex’s native queue command. The change adds bounded inputs and operations, explicit receipt states, CLI integration, tests, and documentation.

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 evidence, reported checks, limitations, and remaining review 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/codex-integration/messaging-local-discovery.test.ts, tests/codex-integration/messaging-local-lifecycle.test.ts, tests/helpers/messaging-local.ts
Adds local Unix-socket addressing, bounded metadata RPC, operation deadlines, loaded-session pagination, and exact thread or unique-name selection. Tests cover discovery, validation, resource lifecycle, and RPC limits.
Envelope and queued submission
src/messaging/input.ts, src/messaging/envelope.ts, src/messaging/native.ts, src/messaging/process.ts, src/messaging/send.ts, tests/codex-integration/messaging-local-envelope.test.ts, tests/codex-integration/messaging-local-send.test.ts, tests/codex-integration/messaging-local-native-queue.test.ts, tests/codex-integration/messaging-local-lifecycle.test.ts
Adds bounded UTF-8 input, message envelopes, native runtime checks, and one queue attempt. Successful native exit returns queued; pre-submission failures return not_sent; uncertain post-invocation outcomes return unknown and are not replayed.
CLI integration and published contract
src/cli/message-args.ts, src/cli/message-command.ts, src/cli/message-runtime.ts, src/cli/dispatch.ts, src/cli/registry.ts, src/cli/help.ts, src/cli/capabilities-agents-routing.ts, src/cli/codex-shim-autorestore.ts, docs-site/src/content/docs/reference/cli*, structure/local-messaging.md, structure/INDEX.md, structure/manifest.json, structure/cli-management.md, structure/runtime.md, skills/ocx/references/*, scripts/generate-ocx-skill-surface.ts, scripts/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
Registers and documents the sessions and send commands. The references describe platform and runtime limits, input and receipt contracts, and excluded behavior. Integration checks cover command dispatch, invalid usage, shim auto-restore behavior, and local discovery and sending.

Priority: ➖ Normal

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

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant CLI as message-command
  participant RPC as LocalMessageRpc
  participant Queue as Codex queue CLI
  participant App as Codex app-server
  CLI->>RPC: Discover loaded sessions and resolve destination
  CLI->>Queue: Check runtime version and queue support
  CLI->>RPC: Re-read selected thread metadata
  CLI->>Queue: Submit one message envelope
  Queue->>App: Send queue/add request
  App-->>Queue: Return queue result
  Queue-->>CLI: Return submission result
Loading

Merge Risk: ⚪ Minimal · up to 1888b

The selected changes improve local messaging discoverability and keep its test and documentation indexes consistent; no concrete regression was found. Reported hosted CI and broader platform checks remain outstanding validation follow-ups.

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 95.83% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 24 functions across 28 files. (3 skipped: 3…
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 describes the main change: adding local Codex queued session messaging.
✨ 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

✅ READY

  • all PR quality gates passed; the review readiness checklist is complete.

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.

✅ 4/4 boxes ticked.

This pull request has been marked Ready for Review.
The review-ready label marks this PR as ready; review automation runs independently.
Maintainers notified: @lidge-jun @Ingwannu

@phillipod

Copy link
Copy Markdown
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
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

This branch has not been deployed

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

Labels

enhancement New feature or request review-ready

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants