refactor(llm-access-store): extract pure leaf helpers from postgres.rs (PR-A)#14
Conversation
Move the pure free-function leaf layer out of the ~10k-line postgres.rs into five focused submodules, leaving the stateful PostgresControlRepository God-object (inherent + 16 trait impls) and all types in mod.rs for a follow-up domain split (PR-B). - json: optional-field JSON readers/writers + the deserialize helper - decode: PgRow -> record/admin-view row decoders - codex_routing: route quota scoring + cached auth-error derivation - proxy_support: admin<->provider proxy transforms + legacy JSON cleanup - cache_convert: control-record <-> request-cache value conversions Behavior-preserving structural move: identical top-level item inventory, same 10 tests. Moved fns become `pub` only where referenced cross-region; all types + the sqlx wrapper stay in mod.rs, so submodules read ancestor-privates with zero pub(super)/pub(crate) bumps. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
/gemini review |
|
@codex review |
There was a problem hiding this comment.
Code Review
This pull request refactors llm-access-store/src/postgres.rs by extracting numerous helper functions into smaller, domain-specific submodules: cache_convert, codex_routing, decode, json, and proxy_support. This change significantly improves code organization, readability, and maintainability. There are no review comments provided for this pull request, and the refactoring appears to be clean and correct.
There was a problem hiding this comment.
Code Review
This pull request refactors the postgres module by extracting various helper functions from the large postgres.rs file into several dedicated submodules: cache_convert, codex_routing, decode, json, and proxy_support. This significantly improves code organization and maintainability. There are no review comments, and I have no feedback to provide.
|
Codex Review: Didn't find any major issues. Nice work! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
What
First of two PRs splitting the ~10.3k-line
llm-access-store/src/postgres.rs. This PR-A extracts only the pure free-function leaf layer into five focused submodules; the statefulPostgresControlRepositoryGod-object (4.8k-line inherent impl + 16 trait impls) and all types stay inmod.rsfor the follow-up domain split (PR-B).postgres.rsis structurally unlike prior split targets (request.rs/cache_sim.rs/stream.rs/converter.rs/store.rs): its public God-object's inherent impl is a dense internal call-mesh, so splitting it by domain forces ~50 methods topub(super). To keep each review small and de-risk incrementally, that work is deferred to PR-B. This PR-A is the zero-judgment, zero-pub(super)part.New submodules (
postgres/)jsondecode_optional_jsonhelperdecodePgRow→ record / admin-view row decoderscodex_routingproxy_supportcache_convertmod.rs: 10336 → 9342 lines (1053 moved out).Why zero visibility bumps
All types and the sqlx wrapper (
PgRow/SqlxClient/SqlxTransaction) stay inmod.rs. Rust descendants can read ancestor-private items, so the moved submodules access them viause super::{...}with no field/method visibility changes. Moved free fns becomepubonly where referenced from a different region (mod-remaining / tests / a sibling submodule) — 45 becamepub, 10 stayed private, the one private struct (CodexRouteQuotaScore) moved with its only callers.Behavior-preserving
Structural move only — function bodies are byte-identical.
#[test]/#[tokio::test](the one pure unit test,aggregate_usage_rollup_deltas_merges_events, stays inmod.rsbecause its struct stays there too).Verification
cargo clippy -p llm-access-store --all-targets -- -D warnings→ cleancargo test -p llm-access-store→ 67 passedcargo build -p llm-access(reverse dep) → okrustfmton the 6 changed files only🤖 Generated with Claude Code