Repository navigation
docs(architecture): name the gateway module in the src/ module table - #427
Merged
Merged
Conversation
Section 3 lists nine modules, and gateway.rs is not one of them -- the whole document does not contain the string once. It is declared in src/main.rs:19 and is the largest production module in the tree (3136 lines; protocol.rs 2141, sse.rs 2709, billing.rs 931), and it holds the six handlers a request actually lands in: chat_completions, anthropic_messages, responses, models, plans and v1_models. Its own module doc opens with "网关兼容端点(architecture §6 API 一览)", so it treats this document as its map. The omission is visible from inside the document, twice over: - Section 4 walks one call step by step -- endpoint, auth, balance pre-check, key routing, upstream, settle -- and every step but the first has a row in section 3 (auth.rs, billing.rs, router.rs, sse.rs). The module that receives the request is the one missing. - The routes/ row names the platform APIs it serves and does not include the three gateway endpoints, which are registered in src/routes/mod.rs and handled in gateway.rs. One row added, next to routes/ (the two are the parallel HTTP layers: platform API versus model calls). The other production modules that the document never names -- config.rs, main.rs, i18n_pack.rs -- are left alone: section 4's flow does not pass through them, so this reading does not cover them. Tests: cargo test 579 passed / 0 failed; cargo fmt --check and cargo clippy --all-targets clean. No gate reads docs/architecture.md, so this change is unguarded by design -- the axis' standing rule is to correct the data, not to pin one wording.
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
docs/architecture.md§3 ("模块(src/)") lists nine modules andgateway.rsis not one of them — the whole document does not contain the string once (grep -i gateway→ 0 hits).What was left out is the largest production module in the tree and the place a request actually lands:
src/main.rs:19—mod gateway;(not one of the#[cfg(test)]gate modules)protocol.rs2141,sse.rs2709,billing.rs931chat_completions:863,anthropic_messages:878,responses:893,models:916,plans:932,v1_models:962//! 网关兼容端点(architecture §6 API 一览)Why this is an omission, not a different way of summarising
Two readings inside the same document say so:
auth.rs,billing.rs,router.rs,sse.rs. The module that receives the request is the single one missing, so a reader following §4 intosrc/has nowhere to go for step one.routes/row enumerates the API surface it serves ("认证 / 钱包 / 交易 / 仪表盘 / 共享 / 管理 / 运营者 API") and does not include the three gateway endpoints — which exist insrc/routes/mod.rs's router but are handled ingateway.rs. That is a gap in the enumeration, not a scope decision.Changes
routes/— the two are the parallel HTTP layers (platform API versus model calls), and keeping them adjacent preserves the table's existing grouping (infrastructure first, HTTP last)The wording follows the modules' actual division of labour rather than restating §4:
router.rschooses the key,protocol.rs/sse.rsdo the cross-protocol conversion,billing.rsprices and settles, and this row says thatgateway.rsis the entry point that ties them together.Deliberately not touched:
config.rs,main.rsandi18n_pack.rsare also production modules the document never names (grep -c→ 0 each), but §4's flow does not pass through them, so this reading does not cover them. One defect per change.Tests
cargo test— 579 passed / 0 failedcargo fmt --check— cleancargo clippy --all-targets— cleandocs/architecture.md. Everyinclude_str!target in the tree isREADME.md,README.en.md,CHANGELOG.md,ui/README.md,ui/index.html,ui/js/*.js,ui/css/style.css,config/config.example.toml,Cargo.toml,Dockerfile,docker-compose.yml,.dockerignore, anddocs/prototype/aitokenpool-console.html(the prototype, not this document). So the change is unguarded by design — this repository's standing rule for prose assertions is to correct the data rather than pin one wording in a gate.Checklist
docs/)docs(architecture): ...)