Skip to content

refactor(core): split consts.rs into per-area submodules#322

Merged
hherb merged 2 commits into
mainfrom
refactor/split-consts
Jul 3, 2026
Merged

refactor(core): split consts.rs into per-area submodules#322
hherb merged 2 commits into
mainfrom
refactor/split-consts

Conversation

@hherb

@hherb hherb commented Jul 3, 2026

Copy link
Copy Markdown
Owner

What

Splits the 562-line primer-core/src/consts.rs into a directory module, one file per feature area — the recommended next pick from the production-split lane (lowest-risk mechanical split: 12 already-pub mod blocks, no feature gates).

All resulting files are well under 500 lines (largest is speech.rs at 199):

file lines
consts/mod.rs 25
consts/speech.rs 199
consts/retrieval.rs 100
consts/router.rs 46
consts/{vocab,prompt_budget}.rs 32
consts/{inference,retry,pedagogy,reasoning,qnn,learner,break_suggest}.rs 12–23

consts/mod.rs declares one pub mod per area (retry, vocab, break_suggest, pedagogy, prompt_budget, retrieval, speech, learner, reasoning, inference, router, qnn) + #[cfg(test)] mod tests;. Each consts/<area>.rs owns that area's constants; speech.rs keeps its nested macos26 + android submodules.

Behaviour-preserving

  • External primer_core::consts::<area>::<NAME> paths are unchanged (each area was already a pub mod).
  • The sibling consts/tests.rs is untouched — it reaches super::inference / super::router by name, which remain valid after the split.
  • Only doc change: the CLAUDE.md primer-core consts bullet notes the directory split.

Verification

  • Pub surface byte-identical: 77 symbols before and after (grep -oE 'pub (struct|enum|fn|const|async fn|trait|type|mod) …').
  • primer-core tests: 176/176 (matches the pre-split baseline exactly).
  • Workspace clippy --all-targets -- -D warnings: clean.
  • cargo fmt --all -- --check: clean (zero changes to the new files).
  • Full cargo test --workspace: 51 × test result: ok, 0 FAILED.

Pure refactor, no runtime behaviour change.

🤖 Generated with Claude Code

The 562-line primer-core/src/consts.rs became a directory module,
one file per feature area, all files well under 500 lines:

- consts/mod.rs (25) declares `pub mod` per area (retry, vocab,
  break_suggest, pedagogy, prompt_budget, retrieval, speech, learner,
  reasoning, inference, router, qnn) + `#[cfg(test)] mod tests;`.
- consts/<area>.rs holds that area's constants. speech.rs keeps its
  nested `macos26` + `android` submodules.

Behaviour-preserving: external `primer_core::consts::<area>::<NAME>`
paths are unchanged; the sibling `consts/tests.rs` is untouched (it
reaches `super::inference` / `super::router` by name, still valid).

Verification: pub surface byte-identical (77 symbols before/after);
primer-core 176/176 (baseline match); workspace clippy -D warnings
clean; fmt --check clean; full workspace `cargo test` 51 ok / 0 failed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 3, 2026

Copy link
Copy Markdown

Deploying primer with  Cloudflare Pages  Cloudflare Pages

Latest commit: 66c8800
Status: ✅  Deploy successful!
Preview URL: https://9174b9c7.primer-10b.pages.dev
Branch Preview URL: https://refactor-split-consts.primer-10b.pages.dev

View logs

Update NEXT_SESSION.md with what shipped this session (consts.rs split),
the recommended next production split (primer-storage/src/schema.rs),
carried owner/hardware-gated work, and the exact resume commands. Freeze
an identical timestamped copy under docs/handoffs/.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@hherb hherb merged commit 713f431 into main Jul 3, 2026
11 checks passed
@hherb hherb deleted the refactor/split-consts branch July 3, 2026 06:29
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