refactor(pedagogy): split prompt_builder.rs into responsibility submodules#321
Merged
Conversation
…dules The 708-line prompt_builder.rs (production code only — tests already live in the prompt_builder/tests.rs sibling) becomes a directory module, all files < 500 lines and behaviour-preserving: - mod.rs (74) — module doc + the process-wide cached english_pack() (private, shared by all submodules via super::english_pack()) + a flat `pub use` re-export facade (15-symbol pub surface unchanged). - system_prompt.rs (297) — the build_system_prompt_* family + the shared assemble_system_prompt core + truncate_passages + days_since. - prompt.rs (151) — build_messages + the build_prompt_* family (which call the sibling build_system_prompt_* via the super:: re-exports). - intent.rs (252) — decide_intent* (the Socratic brain) + extract_active_concepts + the opener/assertion classifiers. The pre-existing tests.rs is untouched: it reaches english_pack (kept in mod.rs) plus the private is_factual_question / is_factual_question_with_pack intent helpers and the Passage type via `use super::*`. mod.rs carries three #[cfg(test)]-gated `use` re-imports (matching what the pre-split flat file leaked into module scope) so the test file needs no edit. Verification: pub-surface diff empty (15 symbols, incl. `type` in the regex); primer-pedagogy 216/216 (baseline match); workspace clippy -D warnings clean; fmt --check clean; full workspace test 51 ok / 0 failed. CLAUDE.md: prompt_builder bullet rewritten for the directory-module split. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Deploying primer with
|
| Latest commit: |
585dc16
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://c9fbda27.primer-10b.pages.dev |
| Branch Preview URL: | https://refactor-split-prompt-builde.primer-10b.pages.dev |
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Owner
Author
Code reviewFound 1 issue:
Lines 81 to 83 in 7c1c16a Otherwise this is a clean, behavior-preserving split: the 15-symbol public surface, 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
The CLAUDE.md prompt_builder bullet cited PR #322, but this work is PR #321. Every other reference in the branch (NEXT_SESSION.md, the handoff doc) already says #321, matching the correct self-citation pattern of sibling split PRs #304/#305. Co-Authored-By: Claude Opus 4.8 (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
Splits the 708-line
primer-pedagogy/src/prompt_builder.rsinto a directory module split by responsibility — behaviour-preserving, all files < 500 lines. Tests already lived in theprompt_builder/tests.rssibling (untouched), so the 708 lines were pure production code.prompt_builder/mod.rsenglish_pack()(private, shared) + flatpub usefaçadeprompt_builder/system_prompt.rsbuild_system_prompt_*family +assemble_system_promptcore +truncate_passages+days_sinceprompt_builder/prompt.rsbuild_messages+build_prompt_*familyprompt_builder/intent.rsdecide_intent*(the Socratic brain) +extract_active_concepts+ opener/assertion classifiersVisibility notes
english_pack()stays inmod.rs(all three submodules reach it viasuper::english_pack(); a test child ofmod.rssees it too).build_prompt_*functions call the siblingbuild_system_prompt_*via thesuper::re-exports.tests.rsreachesenglish_pack, the privateis_factual_question/is_factual_question_with_packintent helpers, and thePassagetype by their bare names viause super::*.mod.rscarries three#[cfg(test)]-gatedusere-imports — matching what the pre-split flat file leaked into module scope — so the test file needs zero edits.Verification
pub (struct|enum|fn|const|async fn|trait|type), old flat file vs new submodules).cargo test -p primer-pedagogy→ 216 passed / 0 failed (baseline match).cargo clippy --workspace --all-targets -- -D warningsclean.cargo fmt --all -- --checkclean.cargo test --workspace→ 51 ×test result: ok, 0 failed.Internal refactor, no runtime behaviour change.
🤖 Generated with Claude Code