fix(persona,#1409): force turn-execute through Rust registry#1417
Merged
joelteply merged 2 commits intoMay 18, 2026
Merged
Conversation
joelteply
added a commit
that referenced
this pull request
May 18, 2026
…mpt -> inference (#1409) (#1415) * feat(persona): Lane D — Rust persona/turn-execute chains drain -> prompt -> inference (#1409) Adds the `persona/turn-execute` command in CognitionModule that executes a full persona turn in ONE Rust hop: drain inbox -> wrap in PersonaTurnFrame -> derive ResponsePrompt (lazy) -> build InferenceRequest (prompt_text path) -> dispatch `inference/llm/request` via the global command_executor (routes to InferenceLlmModule registered in PR-5 #1404) -> bundle replayRecord + inferenceResponse -> persist replay record (v2 schema with response_prompt captured from #1412) Files changed: * src/persona/turn_frame.rs: new `ResponsePrompt::to_prompt_text` helper that flattens system_prompt + chat messages into a single deterministic plain-text prompt for adapter-based engines (LlamaCppAdapter, cloud adapters). Format: "<system>\n\nrole: content\nrole: content\n..." Empty system_prompt produces no leading paragraph; lowercase role matches the on-the-wire PromptRole serde format. * src/modules/cognition.rs: new `persona/turn-execute` command. Inputs: - persona_id (required) - window_ms (default 80), max_items (default 16) - composition_artifact_id (default Uuid::nil()) - max_tokens (default 512), max_duration_ms (default 10_000) Returns: { "replayRecord": PersonaTurnFrameReplayRecord | null, "inferenceResponse": InferenceResponse | null } Empty drain returns the null pair (no-op, not Err). Missing persona returns typed Err per Joel's never-swallow rule. Tests (+9, all green): * persona::turn_frame (6 new, total 18): - to_prompt_text_renders_each_message_as_role_colon_content - to_prompt_text_prepends_system_prompt_when_present - to_prompt_text_skips_empty_system_prompt - to_prompt_text_handles_mixed_roles_in_order - to_prompt_text_handles_no_messages - to_prompt_text_empty_prompt_returns_empty_string * modules::cognition::turn_execute_tests (3 new): - turn_execute_persona_not_found_returns_typed_error - turn_execute_empty_drain_returns_null_bundle - turn_execute_bad_max_items_returns_typed_error The dispatch-success path (drain -> dispatch -> inference response) runs through `command_executor::executor()` which is only initialized at runtime startup (ipc/mod.rs). Tests that exercise the executor live in the integration suite; unit-tests here cover the param-parse + short-circuit + persona-not-found paths. Builds atop #1412 (v2 schema with response_prompt) and #1404 (InferenceLlmModule runtime registration). Closes alpha card #1409. Why one command: the TS persona loop previously executed each stage with its own IPC round-trip (drain, then build prompt, then call inference) — 3 round-trips per turn, prompt-building lived in TS. Lane D pulls all three into the substrate so (a) the prompt is built in Rust where the turn-frame lives, (b) the production replay record carries the exact prompt that fed inference, (c) the persona turn becomes one observable unit on the bus. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(persona,#1409): force turn-execute through Rust registry (#1417) * fix(persona,#1409): force turn-execute through Rust registry * fix(runtime,#1409): use unlimited concurrency contract for cognition --------- Co-authored-by: Test <test@test.com> --------- Co-authored-by: Test <test@test.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Validation
Note
This still proves Rust turn assembly/routing, not real model inference. The next gate must wire InferenceLlmModule with a real adapter and replay a prod-shaped turn through an actual model.