Skip to content

refactor(core): own primary request preparation - #5300

Draft
Hmbown wants to merge 1 commit into
mainfrom
codex/v096-core-request-boundary-91bca01a
Draft

refactor(core): own primary request preparation#5300
Hmbown wants to merge 1 commit into
mainfrom
codex/v096-core-request-boundary-91bca01a

Conversation

@Hmbown

@Hmbown Hmbown commented Aug 8, 2026

Copy link
Copy Markdown
Owner

What changed

  • Replaces the unused synthetic ChatRequest scaffold in codewhale-core with the production MessageRequest DTO family previously owned by the TUI crate.
  • Adds one pure prepare_primary_turn_request constructor for provider-neutral primary-turn defaults.
  • Routes both the production streaming turn loop and /preview-request through that constructor.
  • Preserves the historical crate::models::* paths through compatibility re-exports, avoiding a flag-day migration.
  • Enables serde_json/preserve_order in core and covers a deliberately non-alphabetic nested schema.
  • Adds a raw Wiremock capture proving the core-prepared DeepSeek body is byte-identical to the body sent by the real production transport.
  • Removes the stale claim that the current headless helper already dispatches byte-identical model requests; that dispatch extraction is still future v0.9.5: extract the engine into crates/core + Thread/Session split #5261 work.

Why

The real request contract and defaulting lived in the TUI while crates/core/src/request.rs contained an unused parallel model. That made the proposed headless/app-server boundary fictional and allowed production and preview construction to drift.

This is the smallest production slice that gives core real ownership without dragging provider routing, secret handling, HTTP transport, or response decoding across the boundary prematurely.

Impact

There is no intended user-visible behavior change. Existing TUI consumers retain their type paths, while future headless/runtime work can depend on the actual provider-neutral request contract in core.

Evidence

  • cargo fmt --all -- --check
  • Core tests: 72/72
  • Core request tests: 2/2
  • Raw production transport parity: 1/1
  • Historical TUI/core type identity: 1/1
  • Existing Chat/Anthropic/Responses dialect seams: 8/8
  • Preview-versus-first-wire route tests: 6/6
  • cargo clippy --workspace --all-targets --locked -- -D warnings
  • Runtime contract budget: 55/55 exact
  • Source structure: 685,146 / 685,165 owned Rust lines; largest module 17,671 / 17,680
  • Co-author credit and diff checks: pass

Only the existing macOS linker __eh_frame warning appeared. Full workspace tests and release builds were not run for this focused slice.

Follow-up boundary

Raw transport capture currently covers the DeepSeek Chat path. Anthropic Messages and OpenAI Responses raw capture, then provider-specific shaping/dispatch ownership, remain later #5261 slices.

Refs #5261

No-Issue: #5261 remains open because this is one verified extraction slice, not the full engine migration.

Move the production MessageRequest DTO closure into codewhale-core while preserving the historical TUI path through compatibility re-exports.

Route both the streaming turn loop and read-only preview through one pure primary-turn constructor, and prove its prepared body matches bytes sent by the production transport.

Provider-specific dialect shaping and HTTP transport remain in the TUI for the next extraction slice.

Agent assistance: implemented and independently reviewed with CodeWhale sub-agents.

Refs #5261
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