Where to Change Code
Where to Change Code
Section titled “Where to Change Code”Use this page as a maintainer routing map. It points common change requests to the source owners, validation paths, and documentation that should move with the code.
Change routing map
Section titled “Change routing map”Runtime settingStart in `src/config.rs`; update `config.example.toml`, wiring in `src/main.rs` or `src/lib.rs`, user docs, reference docs, and config-loading tests.
Inbound protocol parsingStart in `src/ingress/` and `src/protocol/`; keep request protocol detection path-based and normalize before routing.
Route matchingStart in `src/routing/`; preserve strict `request_protocol` guard behavior and avoid silent fallthrough for mismatched explicit guards.
Provider request behaviorStart in `src/provider/*/request`; keep model rewrite, projection, and serialization provider-owned.
Provider transportStart in `src/provider/*/transport`; keep auth headers, upstream URL construction, and HTTP send behavior outside pure translation.
Protocol conversionStart in `src/translation/`; keep request/response/stream conversions pure at the carrier boundary.
Streaming semanticsStart in SSE scanner, streaming translation modules, and provider response observers; preserve terminal events, Unicode safety, and tool-call stall handling.
Client-facing errorsStart in `src/error/`; keep stable compact error projection and safe preserved upstream headers.
Capture/loggingStart in `src/observe/`; keep logs compact, structured, body-safe, and phase names aligned with reference docs.
Task checklist
Section titled “Task checklist”- 1
Add or change a runtime config field
Goal: Keep runtime configuration centered on
config.tomland its tracked example.Do- Update
src/config.rs. - Add a concise example/comment to
config.example.toml. - Wire through startup/runtime state only where needed.
- Update
using/configurationandreference/configuration. - Add or adjust config loading/default tests.
Verify:
just site checkand relevant Rust config tests agree with the new default and docs. - Update
- 2
Add a protocol conversion path
Goal: Preserve explicit pair-oriented translation.
Do- Add request conversion only if inbound → provider request behavior is supported.
- Add non-streaming response conversion if provider → inbound response behavior is supported.
- Add streaming conversion separately; do not assume non-streaming support implies stream support.
- Update compatibility docs and behavior tests.
Verify: Unsupported pairs fail explicitly; supported pairs have behavior coverage for payloads and stream terminal semantics.
- 3
Fix a streaming regression
Goal: Preserve bytes, event order, terminal detection, and semantic timeouts.
Do- Reproduce with the smallest stream fixture.
- Identify whether the failure is carrier, SSE event semantics, protocol conversion, or client-facing reconstruction.
- Add coverage for terminal events, incomplete tool streams, stalled tool-call arguments, or Unicode chunk boundaries as appropriate.
Verify: Targeted streaming tests pass before broader e2e validation.
- 4
Change error rendering
Goal: Keep errors compact, stable, safe, and useful.
Do- Map internal errors to stable client-facing types.
- Preserve useful safe upstream headers such as
Retry-After. - Avoid leaking private bodies, auth headers, API keys, or private prompts.
- Update reference error types and behavior contracts.
Verify: HTTP and SSE error behavior are both covered when stream state matters.
Source ownership table
Section titled “Source ownership table”| If you are changing | Primary source area | Also check |
|---|---|---|
| CLI flags | src/cli/ | README.md, README_CN.md, reference/cli |
| Generated app-directory defaults | src/paths.rs, config loading code | config.example.toml, config tests |
| Route protocol guards | src/routing/ | reference/route-matching, proxy e2e route tests |
| Provider model rewrite | src/provider/*/request | Provider setup docs and compatibility matrix |
| Anthropic wire structs | src/protocol/anthropic/ | SDK alignment docs and conversion tests |
| OpenAI Responses wire behavior | src/protocol/openai/responses/ | Responses protocol docs and conversion tests |
| Capture phase names | src/observe/ and flow locals | reference/capture-phases, docs checker phase coverage |
| Docs IA or bilingual pages | site/src/content/docs/ | tools/check_docs_i18n.py, developer/docs-maintenance |
Validation order
Section titled “Validation order”Prefer the smallest validation that covers the changed boundary, then move outward. For documentation-only work, run just site check. For runtime behavior, use the project validation guidance in AGENTS.md and the relevant test recipes.