Skip to content

docs(codex): pivot first-class-integration design to CLI-native channels - #1427

Merged
namastex888 merged 1 commit into
devfrom
docs/codex-channels-pivot
Apr 27, 2026
Merged

namastex888 merged 1 commit into
devfrom
docs/codex-channels-pivot

Conversation

@namastex888

Copy link
Copy Markdown
Contributor

Summary

Rewrites .genie/brainstorms/codex-first-class-integration/DESIGN.md to reflect the settled architectural framing from the 2026-04-27 codex+channels brainstorm. Supersedes the morning version that proposed an @openai/codex-sdk driver — Felipe rejected the SDK-primary path in favor of CLI-native primitives.

Key shifts

  • CLI-first: Claude Code never loads MCP servers as plugins.
  • Channels semantics yes, transport no: adopt the structured envelope (<channel source="X" meta_k=v>body</channel>); reject the MCP wire.
  • Genie owns the channel-server role externally: external integrations (omni/whatsapp, telegram, webhook, discord) live as genie subcommands. They write to the same native inbox file (~/.claude/teams/<team>/inboxes/<agent>.json) and the same PG mailbox that peer agents use.
  • No tmux send-keys for runtime delivery: spawn-time send-keys (terminal init, cd + launch, TUI keybindings) stays; mid-turn injection is migrated to native paths.
  • Codex hook bridge is the receive pipe: PR feat(codex): hook bridge — codex events route through 'genie hook dispatch' #1424 (already shipped in 4.260427.9) wires ~/.codex/config.toml to genie hook dispatch. The missing handler (PR B in the ladder) reads PG mailbox on UserPromptSubmit and returns additionalContext.

PR ladder captured in the design

PR Goal Depends on
A Channel-shaped envelope on mailbox.send + NativeInboxMessage; genie inbox list source rendering none
B Codex UserPromptSubmit handler reads PG mailbox, returns additionalContext A
C Migrate claude-code.ts:deliver (omni→claude) from tmux send-keys to native inbox + source='whatsapp' A
D Migrate claude-code.ts:injectNudge from tmux send-keys to native inbox + source='system' A
E Remove protocol-router.ts:injectToTmuxPane after metric confirms zero traffic A–D
F+ First external channel adapter as genie subcommand (later, optional) A–D

PR A is in-flight on feat/channel-envelope-inbox in parallel with this docs PR.

Empirical proof preserved in the doc

The 2026-04-27 hookbridge-test session demonstrated end-to-end native delivery (genie send → PG mailbox → codex inbox-list → genie send pong reply) with zero tmux send-keys and zero MCP. The doc cites it as the validation that the substrate already works for source='agent'; PRs A–F generalize that to all source kinds.

Test plan

This is docs-only.

  • No code changed; CI lint should pass without behavior tests.
  • Linter (scripts/wishes-lint.ts) accepts _No brainstorm — direct wish_ stub for any wish that won't have a brainstorm; this PR doesn't change the linter, only refreshes a brainstorm.
  • DESIGN.md preserved at the same path the prior version occupied; supersedes-note in the doc itself flags the rewrite.

🤖 Generated with Claude Code

… channels

Rewrites .genie/brainstorms/codex-first-class-integration/DESIGN.md to
reflect Felipe's settled directives from the 2026-04-27 brainstorm:

- CLI-first culture; Claude Code does not load MCP servers as plugins.
- Channels SEMANTICS yes (envelope), MCP TRANSPORT no.
- Genie absorbs the channel-server role externally; external integrations
  (telegram, webhook, discord, omni/whatsapp) live as genie subcommands or
  external processes, never as Claude plugins.
- No tmux send-keys for runtime delivery (spawn-time init still legitimate).
- Single substrate, multiple sources attribute via structured envelope:
    <channel source="X" from="Y" k="v">body</channel>
- Codex hook bridge (PR #1424) is the codex receive pipe; PR B in the ladder
  fills the missing UserPromptSubmit handler.

Captures the full PR ladder A through F, the empirical proof of native
delivery (hookbridge-test session), and the migration path for in-flight
codex agents.

Supersedes the morning-2026-04-27 SDK-driven version of the same file.
@coderabbitai

coderabbitai Bot commented Apr 27, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 357aa31d-a0e8-4520-8565-217aa33afda3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/codex-channels-pivot

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 and usage tips.

@namastex888
namastex888 merged commit 569ba8b into dev Apr 27, 2026
10 checks passed

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a design for integrating Codex into Genie using CLI-native channels and a hook-based delivery substrate, replacing legacy tmux-based methods. The proposed architecture utilizes a structured XML-like envelope for message attribution across different sources and outlines a multi-wave implementation plan. Feedback on the design suggests updating the delivery diagrams to reflect signature changes, implementing body escaping for the channel envelope to prevent parsing breakages, and ensuring that pending messages are not marked as read if a delivery hook times out.

│ → Claude Code reads on next turn via SendMessage tool │
│ │
│ PATH 2 — codex recipients: │
│ mailbox.send(repo, from, to, body) │

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The diagram for PATH 2 shows the legacy mailbox.send signature. It should be updated to include the source and meta parameters introduced in PR A to maintain consistency with the architectural changes described later in the document.

Suggested change
│ mailbox.send(repo, from, to, body) │
│ mailbox.send(repo, from, to, body, {source, meta}) │


| Decision | Rationale |
|----------|-----------|
| **Channel envelope** = `<channel source="X" from="Y" k="v">body</channel>` rendered into the message text on delivery | Captures provenance without schema churn for downstream consumers. Claude/codex agents see human-readable XML-ish text and can choose to react to specific sources. Round-trippable for debugging. |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The proposed XML-like envelope lacks a specification for escaping the body content. Without escaping (e.g., using CDATA or entity encoding), a message body containing the string will break the envelope structure and potentially confuse the agent's parser. Consider adding a note about escaping the body.

Suggested change
| **Channel envelope** = `<channel source="X" from="Y" k="v">body</channel>` rendered into the message text on delivery | Captures provenance without schema churn for downstream consumers. Claude/codex agents see human-readable XML-ish text and can choose to react to specific sources. Round-trippable for debugging. |
| **Channel envelope** = <channel source="X" from="Y" k="v">body</channel> (with body escaped) rendered into the message text on delivery | Captures provenance without schema churn for downstream consumers. Claude/codex agents see human-readable XML-ish text and can choose to react to specific sources. Round-trippable for debugging. |

| Risk | Severity | Mitigation |
|------|----------|------------|
| Channel envelope breaks downstream parsers that assume plain text | Low | Source defaults to `'agent'` → plain body; envelope only wraps when source is set explicitly. Existing peer-agent traffic is untouched. |
| Codex hook can timeout if mailbox query is slow | Low | Hook timeout is 15s (PR #1424). PG queries on `mailbox WHERE to_worker = X AND read = false` are sub-millisecond. Still: budget the hook to ≤500ms; bail with empty additionalContext on timeout. |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

In the timeout mitigation for the Codex hook, it is important to clarify that if the handler bails and returns an empty additionalContext, the pending messages must not be marked as read. This ensures they are preserved for the next turn rather than being lost.

Suggested change
| Codex hook can timeout if mailbox query is slow | Low | Hook timeout is 15s (PR #1424). PG queries on `mailbox WHERE to_worker = X AND read = false` are sub-millisecond. Still: budget the hook to ≤500ms; bail with empty additionalContext on timeout. |
| Codex hook can timeout if mailbox query is slow | Low | Hook timeout is 15s (PR #1424). PG queries on mailbox WHERE to_worker = X AND read = false are sub-millisecond. Still: budget the hook to ≤500ms; bail with empty additionalContext on timeout (do not mark messages as read). |

namastex888 added a commit that referenced this pull request Apr 28, 2026
… channels (#1427)

Rewrites .genie/brainstorms/codex-first-class-integration/DESIGN.md to
reflect Felipe's settled directives from the 2026-04-27 brainstorm:

- CLI-first culture; Claude Code does not load MCP servers as plugins.
- Channels SEMANTICS yes (envelope), MCP TRANSPORT no.
- Genie absorbs the channel-server role externally; external integrations
  (telegram, webhook, discord, omni/whatsapp) live as genie subcommands or
  external processes, never as Claude plugins.
- No tmux send-keys for runtime delivery (spawn-time init still legitimate).
- Single substrate, multiple sources attribute via structured envelope:
    <channel source="X" from="Y" k="v">body</channel>
- Codex hook bridge (PR #1424) is the codex receive pipe; PR B in the ladder
  fills the missing UserPromptSubmit handler.

Captures the full PR ladder A through F, the empirical proof of native
delivery (hookbridge-test session), and the migration path for in-flight
codex agents.

Supersedes the morning-2026-04-27 SDK-driven version of the same file.
@automagik-genie
automagik-genie deleted the docs/codex-channels-pivot branch September 25, 2026 04:52
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