refactor(pedagogy): split dialogue_manager turn.rs into responsibility submodules#320
Merged
Merged
Conversation
…y submodules Behaviour-preserving split of the 746-line per-turn hot path into a directory module, every file under 500 lines: - turn/mod.rs (138) — module doc + the respond_to / respond_to_streaming orchestrator. - turn/prompt.rs (132) — record_child_turn, build_turn_prompt, record_primer_turn. build_turn_prompt is exercised directly by dialogue_manager/tests/turn_tests.rs, so its visibility widens from pub(super) to pub(in crate::dialogue_manager) — same effective reach as before the move (the old pub(super) resolved to dialogue_manager). - turn/stream.rs (137) — StreamOutcome, stream_inference_response (now file-private; its only caller moved with it), run_recovery_loop. - turn/persist.rs (98) — persist_turn + spawn_embedding_task. - turn/spawn_tasks.rs (284) — spawn_classification_task + spawn_post_response_task. All method bodies and doc comments are verbatim relocations; only imports, visibility qualifiers, and the previously parent-relative super:: paths (now crate::dialogue_manager::…) changed. External pub surface identical (respond_to, respond_to_streaming). Zero churn in the test files. Verification: cargo test -p primer-pedagogy 216 passed / 0 failed (identical to pre-split baseline); workspace clippy -D warnings clean; fmt clean; full workspace suite 51 x "test result: ok", 0 failures; pub-surface diff empty. CLAUDE.md: dialogue_manager module-layout note updated + two stale turn.rs path references fixed (stream_inference_response, effective_context_window_turns call site). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Deploying primer with
|
| Latest commit: |
e8c6232
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://368f9aaa.primer-10b.pages.dev |
| Branch Preview URL: | https://refactor-split-dialogue-mana.primer-10b.pages.dev |
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Two findings from the PR #320 review: - StreamOutcome's pub(super) was a carry-over from the flat turn.rs; after the split its only producer (stream_inference_response, file-private) and consumer (run_recovery_loop, returns Result<String>) both live in stream.rs, so plain private is the accurate visibility. - CLAUDE.md's dialogue_manager bullet still told future sessions to use pub(super) for cross-module access unconditionally, but inside turn/ submodules pub(super) resolves to turn, not dialogue_manager; amended with the pub(in crate::dialogue_manager) escape hatch for helpers a top-level sibling or the tests/ files must reach. Verified: cargo test -p primer-pedagogy 216/0, workspace clippy -D warnings clean, fmt clean. Co-Authored-By: Claude Fable 5 <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
Behaviour-preserving split of
primer-pedagogy/src/dialogue_manager/turn.rs(746 lines — the largest un-feature-gated production file after #305/#318) into a directory module, following the same recipe as thewiring.rs(#305) andstate_machine.rs(#318) splits. Every file is under the 500-line guideline:turn/mod.rsrespond_to/respond_to_streamingorchestratorturn/prompt.rsrecord_child_turn,build_turn_prompt,record_primer_turnturn/stream.rsStreamOutcome,stream_inference_response,run_recovery_loopturn/persist.rspersist_turn,spawn_embedding_taskturn/spawn_tasks.rsspawn_classification_task,spawn_post_response_taskAll method bodies and doc comments are verbatim relocations. Only three kinds of mechanical change:
crate::dialogue_manager::…paths instead of the old parent-relativesuper::…(per the established recipe, avoidingsuper::super::chains).build_turn_promptwidens frompub(super)topub(in crate::dialogue_manager): the oldpub(super)resolved todialogue_manager(wheretests/turn_tests.rscalls it directly); after moving one level deeper the explicit path restores the same effective reach.stream_inference_responsenarrows to file-private (its only caller,run_recovery_loop, moved with it). Everything else keepspub(super), now resolving toturn.turn_tests.rs(1178 lines) untouched.CLAUDE.md: the
dialogue_managermodule-layout note now describes theturn/sub-split, and two staleturn.rspath references were fixed (the i18nstream_inference_responsenote and the small-context-budget call-site list). README/ROADMAP need no change (internal refactor; verified no references).Verification
cargo test -p primer-pedagogy: 216 passed / 0 failed — identical to the pre-split baseline recorded before touching anything.turn.rsvs concatenated new submodules, incl.type): empty (respond_to,respond_to_streaming).cargo clippy --workspace --all-targets -- -D warnings: clean.cargo fmt --all -- --check: clean.cargo test --workspace: 51 ×test result: ok, 0 failures (matches the prior session's count).🤖 Generated with Claude Code