Skip to content

Wire Claude structured sessions through agentSession.* - #13578

Closed
brennanb2025 wants to merge 5 commits into
brennanb2025/claude-structuredfrom
brennanb2025/claude-structured-runtime
Closed

brennanb2025 wants to merge 5 commits into
brennanb2025/claude-structuredfrom
brennanb2025/claude-structured-runtime

Conversation

@brennanb2025

Copy link
Copy Markdown
Contributor

Summary

  • Translate Claude stream-json messages, tool activity, thinking, permissions, and questions into the shared durable journal, keyed by claude:(sessionId, uuid) where the provider supplies a message identity.
  • Route Claude and Codex through the same structured-session host, lease, journal, 60 ms coalescer, and agentSession.* RPC surface.
  • Add an end-to-end proof covering deterministic create, send acknowledgement, streaming, permission response, interrupt, and takeover resume from the persisted Claude chain head.

Trace: agentSession.create resolves a provider-aware attach intent, the shared host reserves and proves the lease through the routed adapter, Claude events enter the shared journal sink, and subscribers receive the same snapshot/batch protocol as Codex. During takeover, graceful close records the last observed Claude leaf at the new reservation fence before the launch resolver selects the resume head.

Screenshots

No visual change.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test — 49,048 passed and 99 skipped; 5 environment-sensitive existing failures remain in the root-directory guard fixtures (3) and inherited Git-config expectations in relay agent-exec tests (2).
  • pnpm build
  • Added focused translator, provider-handle transition, create-intent, and full agentSession.* integration coverage.
  • mobile/pnpm lint
  • mobile/pnpm typecheck
  • mobile/pnpm test — 3,451 passed, 3 skipped.
  • Cross-version structured-session wire test — 8 passed.

AI Review Report

Reviewed identity stability, final-snapshot replacement, tool row lifecycle, prompt CAS routing, cancellation tombstones, lease fencing, close/resume ordering, restart readability, router fallback behavior, and mixed-version wire behavior. The review found max-lines pressure in existing host/store modules and an adapter fallback regression; the implementation extracted narrow domain modules and restored the Codex-only fallback, with the affected suite passing afterward.

Cross-platform review covered macOS, Linux, and Windows paths and process seams, WSL/SSH refusal behavior, folder-workspace locations, runtime-only path resolution, and the absence of shortcut, label, shell-launch, or Electron UI changes. No new platform-specific command construction or native dependency was added.

Security Audit

The slice keeps the existing installed Claude CLI and managed CLAUDE_CONFIG_DIR account lane; it adds no dependency, API-key flow, credential capture, or secret-bearing journal field. Provider payloads use the shared journal limits, mutations retain the shared fingerprint/ledger/fence admission path, and permission replies resolve only through the durable item-to-live-prompt binding.

The subscription-auth policy remains parked and is not implemented around here: the runtime inherits the user CLI login established by the adapter stack, and API-key product policy requires a separate decision. Auth failures continue through the adapter refusal/diagnostic path without exposing credential values.

Notes

This is PR 2 stacked on #13569. PR 3 will add capability-gated, opt-in mobile Claude selection and option-picker wiring; Claude remains never-default until that client gate lands.

The stack was verified against the current brennanb2025/codex-structured-mobile-write tip before opening. After the Codex stack lands, retarget #13569 to its landing branch first, then retarget this PR to the landed #13569 head so this diff remains translation/runtime/integration-only.

@brennanb2025
brennanb2025 force-pushed the brennanb2025/claude-structured-runtime branch from 7fd839a to 0ee46a3 Compare August 10, 2026 11:26
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Superseded: this stack part is fully contained in the consolidated big PR (#13438 for Codex, #13584 for Claude) per the two-big-PRs plan. History and review evidence preserved on this PR.

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