Skip to content

feat(codex): add dormant live execution teleport controller - #1605

Draft
khaliqgant wants to merge 13 commits into
mainfrom
review/agentbox-teleport-0823
Draft

feat(codex): add dormant live execution teleport controller#1605
khaliqgant wants to merge 13 commits into
mainfrom
review/agentbox-teleport-0823

Conversation

@khaliqgant

@khaliqgant khaliqgant commented Aug 23, 2026

Copy link
Copy Markdown
Member

Outcome

Adds the dormant Relay half of AgentWorkforce/cloud#3121 and #3133: Relay owns a long-lived local Codex app-server/thread, while one command (relay codex teleport) queues Cloud execution for the next concrete turn/start boundary.

This PR must remain draft and must not merge before the matching Cloud control-plane/WSS bridge contract and cross-repo product E2E are green.

Contract implemented

  • relay codex run owns the local app-server and thread; plain already-running Codex sessions are not adopted.
  • Local generated experimental schema must expose environment/add and environment/status with the expected no-header EnvironmentAddParams shape, or startup fails before Cloud login.
  • relay codex teleport sends an idempotent request for the exact persisted generation over a mode-0600 local Unix socket.
  • A mid-turn request remains queued until the following turn boundary.
  • Cloud prewarm/acquire/revoke is provider-neutral. Relay accepts only a WSS bridge and rejects raw provider URLs, provider credentials, signed provider previews, and error prose that could echo an opaque token.
  • Acquire must include a sealed, genuinely converged hash/cursor proof. Relay independently rejects manifest/file/byte/conflict-digest drift, behind or cross-namespace cursors, pending writeback, unhealthy outbox, or ephemeral staging paths.
  • The first Cloud turn includes the environment; later turns exercise Codex stickiness.
  • Rollback and controller restart revoke the exact generation, create a fresh app-server, initialize it, and thread/resume the same thread locally. Resume failure is persisted as recovery_failed and blocks new turns.
  • Plain Git/unmanaged cwd fails closed unless an explicit Cloud-verifiable convergence receipt is supplied. State and bridge tickets are mode 0600 and public status excludes both receipt and exec-server URL.
  • Shutdown revokes the generation so prewarm or remote resources do not leak.

Evidence

  • npx vitest run packages/cli/src/cli/bootstrap.test.ts packages/cloud/src/live-teleport.test.ts packages/cli/src/cli/lib/codex-app-server.test.ts packages/cli/src/cli/lib/codex-live-controller.test.ts packages/cli/src/cli/commands/codex.test.ts
    • 5 files, 44 tests passed
  • npm run build:core
    • passed
  • npm run build:cloud && npm run build:cli
    • passed after the final convergence seam changes
  • npx eslint packages/cli/src/cli/commands/codex.ts packages/cli/src/cli/lib/codex-app-server.ts packages/cli/src/cli/lib/codex-live-controller.ts
    • passed
  • Real local capability fail-closed probe against Codex 0.144.5: exit 1 with environment/add + environment/status unsupported, before Cloud login; no schema temp directory remained.
  • Full npx vitest run: 2,200 passed, 25 skipped, one unrelated existing failure remains in packages/cli/src/cli/lib/broker-lifecycle.test.ts. That test expects text Reflex log lines while current main writes structured JSON; the failure reproduces in isolation.

UNPROVEN / merge blockers

  • The route names in this branch are /api/v1/live-teleports/prewarm, /acquire, and /revoke. They must be consolidated with the Cloud implementation rather than accepted by description.
  • The exact environment/status runtime response shape is experimental and needs the pinned supported Codex version matrix plus product-path proof.
  • No deployed Cloud WSS upgrade/text/binary/close/revocation proof is supplied by this Relay PR.
  • No actual Relay command -> Cloud -> E2B and Daytona turn -> sticky second turn -> revoke/destroy -> same-thread local-resume E2E exists yet.
  • Relayfile mount recognition is the source classification only. Cloud acquire remains responsible for producing the sealed #3125-equivalent proof; a marker is never accepted as convergence.

Related durable design/proof: AgentWorkforce/cloud#3121, AgentWorkforce/cloud#3133.

Review in cubic

@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

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.

@khaliqgant

Copy link
Copy Markdown
Member Author

Cross-repo verdict: RED / not composable at 0262242 with Cloud #3137 at 42379df67. The local turn-boundary scheduling is coherent, but the Cloud lifecycle routes do not exist; checkpoint/seal is not invoked; restart can resume local after unconfirmed revoke; first remote-turn failure is committed too early; and arbitrary wss URLs can cross the provider-neutral boundary. Full findings and binding E2B+Daytona harness: https://github.com/AgentWorkforce/cloud/pull/3133#issuecomment-5386684275. Do not merge at this head.

@khaliqgant

Copy link
Copy Markdown
Member Author

Exact-head review update: the queued-teleport recovery blocker is fixed at 14fb2770b7a05f9ec1f75c9d74ec463745d3eadb.

The command now distinguishes explicit normal completion from terminal/error unwind. Failed/interrupted recovered turns render and durably ACK their evidence, then close with cancellation disabled; any consumed prewarm identity is fenced while the accepted request and its expected generation are atomically rebased for restart. The file-backed 3×3 prewarm/outcome matrix exercises the production shutdown helper and proves no acquire before ACK, one new-generation prewarm, and exactly one acquire.

Gates at this exact head:

  • fresh adversarial exact-head review: GREEN
  • six teleport surfaces: 221/221 tests
  • full monorepo typecheck: pass
  • diff/format checks: pass
  • Veto diff review: PASS (code 97/100; security and secrets clean; no decision drift)

This PR remains dormant/draft pending dependency-ordered Relayfile + Cloud composition and the real E2B/Daytona product proofs.

@khaliqgant

Copy link
Copy Markdown
Member Author

Exact-head repair gate for c96255b: local review and Veto are GREEN; CI is still running and this PR remains draft.

Verified independently:

  • Teleport enables only from the exact ambient raw value true captured before dotenv. Workspace .env, casing, whitespace, truthy aliases, and later process environment mutation cannot enable it.
  • The immutable switch is passed through the production defaults seam and exposed in public JSON and human status.
  • A fresh disabled run preserves the local controller, thread, and turn while making zero Cloud auth/API, capability, Relayfile lifecycle, prewarm/status/acquire/revoke, or environment/add calls.
  • Persisted remote recovery remains fail-closed until Cloud reports a terminal revoked or expired state; only then are the mount and same thread restored, with no rewarm.
  • Fresh review: no substantive findings. Focused 144 tests and typecheck pass.
  • Exact origin/main...HEAD Veto: code 97, security 98, secrets clean.

Hold: do not merge or enable this path until exact CI is green, Cloud has the repaired sandbox and Relayfile dependencies composed, and the same-thread E2B plus Daytona failure matrix passes.

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