/smg:mapfrom smg
Provides a live crate map of the SMG Rust gateway codebase, including invariants, area tables, and review checklists. Use before multi-file changes to understand code layout and constraints.
Ships in smg. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
SMG is a Rust gateway in front of LLM engines (SGLang, vLLM, TensorRT-LLM, TokenSpeed, MLX) and cloud providers (OpenAI, Anthropic, Gemini, xAI). It owns worker lifecycle, routing, admission, tenancy, parsing of model output, chat-history storage, MCP tooling and observability behind OpenAI-, Anthropic- and Gemini-compatible APIs. Workers attach over HTTP, gRPC, or same-host ZMQ.
Generated from the checkout you are in, so it cannot go stale:
!bash "${CLAUDE_PLUGIN_ROOT}/scripts/map_live.sh"
If the command shows instead of its output, run scripts/map_live.sh <any dir inside SMG> from the guide checkout.
crates/protocols holds the API types every consumer reads; a field only one crate writes belongs in model_gateway, never there. Library crates live under crates/.to_router_config builds RouterConfig through the hand-written builder in config/builder.rs; to_server_config returns a ServerConfig literal that carries the whole RouterConfig nested (both conversions are in cli/configure.rs). The listener settings live on RouterConfig alone: ServerConfig holds no second copy of them. A new top-level ServerConfig field gets a default in ServerConfig::minimal and a value in every full literal (to_server_config, bindings/python/src/lib.rs). Validation in config/validation.rs runs inside RouterConfigBuilder::build() for the CLI and Python alike; Python mirrors the chain in lib.rs and router_args.py.server.rs) → WASM OnRequest → auth → tenant resolution → admission (priority scheduler or ConcurrencyLimitLayer, chosen once by AdmissionMode::from_config) → routers/gateway.rs picks the family router → HTTP proxy, or the gRPC/ZMQ Mode-parameterized pipeline (routers/grpc/pipeline.rs), or a provider router in crates/external_router → WASM OnResponse. Middleware order is the reverse of the route_layer calls in server.rs. Non-routing handlers live in model_gateway/src/endpoints/.crates/service_discovery/ emit DiscoveredWorkers. One reconciler diffs them (labels smg.ai/discovery-*) against its host's registry, and the host's job queue takes what a pass finds to register and to remove. The gateway is that host (model_gateway/src/discovery_host.rs), and its jobs are Job::AddWorker / Job::RemoveWorker. Registration is a step DAG: the detection, creation and removal steps are in crates/worker/src/workflow/, the gateway's own steps under model_gateway/src/workflow/steps/. A provider's value is a typed field of DiscoveredWorker that its fingerprint() names, and the reconciler writes it onto the worker spec as a field or as a label. ZMQ workers skip the probes and stay Pending until WorkerConnected.crates/symphony) is the default parser: one format table per model family, typed events. --parser legacy selects crates/tool_parser and crates/reasoning_parser; a model outside Symphony's registry falls back to them. New model support is a Symphony table.crates/grpc_client), same-host ZMQ (crates/engine_zmq_client wire + crates/engine_zmq_adapter translation, surfaced as BackendClient::Zmq). gRPC and ZMQ share the pipeline. A cross-cutting feature supports all three or rejects loudly at registration.smg:craft.--grand-central off, the default, places a request by the classic policies in model_gateway/src/policies/. With on, the gateway's own Grand Central engine (crates/grand_central) places it under a policy spec. The placement functions in model_gateway/src/routers/common/placement.rs ask one or the other, and CI runs the gateway's integration shards each way.| Area | Go to | Recipe |
|---|---|---|
| Config and CLI | model_gateway/src/config/, model_gateway/src/main.rs, model_gateway/src/cli/: flag groups in cli/mod.rs (CliArgs flattens RoutingArgs, WorkerArgs, DiscoveryArgs, ServingArgs, ModelArgs, IntegrationArgs), the two conversions in cli/configure.rs, value parsers in cli/, RouterConfig types, builder and validation | recipes/config-plumbing.md |
| Protocol types | crates/protocols/: shared OpenAI, Anthropic and Gemini API types for every consumer; vendor profiles under src/profile/ | recipes/protocols-profile.md |
| App wiring and server | model_gateway/src/app_context.rs, model_gateway/src/server.rs, model_gateway/src/server/, model_gateway/src/lib.rs, model_gateway/src/version.rs: AppContext construction, the axum router and middleware stacks, TLS, connection limits, auth posture, health probes (server/health.rs); the crate root with the allocator (lib.rs) | recipes/http-endpoint.md |
| Routing policies | model_gateway/src/policies/: load-balancing policies, factory and registry; cache-aware selection pipeline in cost/ | recipes/routing-policy.md |
| Grand Central (policy engine) | crates/grand_central/, examples/grand-central/, model_gateway/src/config/policy_document.rs, model_gateway/src/routers/common/place_request.rs, model_gateway/src/routers/common/placement.rs: the engine that places a request under --grand-central on: the policy spec and its validator, the stock stages and presets, the plugin hosts, the store and the standalone controller; the gateway maps its routing settings onto a spec in config/policy_document.rs, states a request to the engine in routers/common/place_request.rs and asks the engine or the classic policies in routers/common/placement.rs | recipes/grand-central-stage.md |
| Routers and dispatch | model_gateway/src/routers/: the gateway front (gateway.rs), factory, HTTP proxy router, the Mode-parameterized gRPC pipeline, external-router mounting, shared dispatch in common/ | recipes/http-endpoint.md |
| Non-routing endpoints | model_gateway/src/endpoints/: tokenize/detokenize, parse, conversations, stored responses, model inventory | recipes/http-endpoint.md |
| Control plane documents and worker service | model_gateway/src/admin/: a configuration held in force with its revision and ETag, the body, query and path extractors of the management endpoints with the control plane's error envelope, and the worker service between the worker endpoints and the registry | recipes/http-endpoint.md |
| Admission | model_gateway/src/middleware/scheduler/, model_gateway/src/middleware/concurrency.rs, model_gateway/src/middleware/token_bucket.rs: priority scheduler (classes, queues, slots, preemption) and the legacy concurrency cap | recipes/scheduler-feature.md |
| Per-tenant rate limiting | model_gateway/src/rate_limit/, model_gateway/src/routers/grpc/common/stages/rate_limit.rs: token and request budgets per tenant, reserve/settle in the gRPC pipeline | recipes/rate-limit-feature.md |
| Tenancy and serving auth | model_gateway/src/tenant/, model_gateway/src/middleware/tenant_resolution.rs, model_gateway/src/middleware/auth.rs, model_gateway/src/secrets.rs: tenant identity, per-request resolution, serving-path API keys; the keys reloaded from their files while the gateway runs (secrets.rs) | recipes/tenancy-feature.md |
| Control-plane auth | crates/auth/: JWT/OIDC and API keys for the control plane, roles, audit | recipes/auth-feature.md |
| Service discovery | crates/service_discovery/, model_gateway/src/discovery_host.rs: kubernetes, consul, file and slurm providers behind one reconciler, each a Cargo feature of the crate; the gateway is the host (discovery_host.rs) | recipes/discovery-provider.md |
| Workers and registration | crates/worker/, model_gateway/src/workflow/: the worker crate: wire types, registry, health, load, circuit breaking, the KV event collector, the detection, creation and removal steps; the gateway's own registration steps and job queue | recipes/discovery-feature.md |
| Workflow engine | crates/workflow/: the wfaas step engine the registration DAG runs on | none yet (read the code; smg:learn afterwards) |
| Symphony (default parser) | crates/symphony/: format tables, registry and checkpoint groups, call-syntax assemblers, grammars, API adapters | recipes/symphony-format.md |
| Legacy parsers | crates/tool_parser/, crates/reasoning_parser/, crates/response_template/: per-model tool and reasoning parsers for --parser legacy; the HF response-template port | recipes/tool-parser.md |
| Tokenizer | crates/tokenizer/, model_gateway/src/workflow/tokenizer_registration.rs, model_gateway/src/endpoints/tokenize/: HF and tiktoken backends, chat templates and native renderers, stop/EOS decoding, encode cache; gateway-side registration per worker | recipes/tokenizer.md |
| KV-cache index | crates/kv_index/, crates/radix_tree/, model_gateway/src/policies/kv_index/: radix trees for routing-side prefix matching, the event-driven chain index, the generic prefix core; the gateway's event monitor and index backend under policies/kv_index/ | recipes/kv-index-feature.md |
| gRPC engine clients | crates/grpc_client/, crates/worker/proto/, model_gateway/src/routers/grpc/client.rs: per-engine gRPC clients and protos, with the common messages in crates/worker/proto/; the GrpcClient enum | recipes/grpc-backend.md |
| ZMQ direct backend | crates/engine_zmq_client/, crates/engine_zmq_adapter/, model_gateway/src/routers/grpc/zmq_client.rs, model_gateway/src/routers/grpc/backend_client.rs: same-host ipc:// wire, the per-engine adapter, the gateway seam | recipes/zmq-backend.md |
| Engine servicers | crates/engine_servicer/, grpc_servicer/: the Rust and Python servicers that serve each engine's gRPC proto on the engine node | recipes/engine-servicer.md |
| Third-party provider routers | crates/external_router/, model_gateway/src/routers/external.rs, model_gateway/src/routers/provider_support.rs: OpenAI, Anthropic, Gemini and xAI routers and the shared glue (SSE, retry, MCP utils, realtime) | recipes/provider-api.md |
| MCP | crates/mcp/: MCP client: inventory, approval policy, transports | recipes/mcp-feature.md |
| Storage | crates/data_connector/: conversation and response storage backends, migrations, hooks, bounds | recipes/storage-backend.md |
| Multimodal | crates/multimodal/, crates/mm_rdma/, model_gateway/src/routers/grpc/multimodal/: vision and audio processors, model specs, media fetching; gateway planning and the capability matrix | recipes/multimodal-feature.md |
| WASM plugins | crates/wasm/, examples/wasm/, model_gateway/src/wasm/, model_gateway/src/middleware/wasm.rs: the WASM host, the WIT world, middleware guests | recipes/wasm-plugin.md |
| Mesh HA | crates/mesh/, model_gateway/src/mesh/: SWIM gossip, CRDT namespaces, gateway wiring | recipes/mesh-feature.md |
| Observability | model_gateway/src/observability/, model_gateway/src/middleware/metrics.rs, model_gateway/src/middleware/logging.rs: metrics, OTel tracing, structured logging, runtime self-metrics | recipes/observability-feature.md |
| RL control plane | crates/rl/, model_gateway/src/rl_adapter.rs: worker discovery, engine-route passthrough and fan-out; inert unless --enable-rl; its glue to the gateway's registry is rl_adapter.rs | none yet (read the code; smg:learn afterwards) |
| Bindings | bindings/: Python PyO3 Router and launcher, servicer bindings, Go SDK | recipes/bindings-update.md |
| Generated clients | clients/: the OpenAPI spec and Python/Java clients generated from protocol types; the Rust client | recipes/protocols-profile.md |
| E2E harness and CI | e2e_test/, scripts/, .github/workflows/: e2e suites, fixtures and launchers, CI tooling and workflows | recipes/e2e-lane.md |
| Mock workers and test harness | crates/mock_worker/, model_gateway/test_harness/: mock HTTP/gRPC/ZMQ workers and the in-process app builders every wire feature needs an arm in | none yet (read the code; smg:learn afterwards) |
| Gateway perf bed | crates/gateway_perf/: the gateway's cost per request, base against head, on the CPU mock bed: the gateway-perf driver behind the make perf-* targets, which applies the verdict rule of scripts/bench_gate.py | none yet (read the code; smg:learn afterwards) |
| Helm chart | deploy/: the chart; its arguments are pinned to RouterArgs by a bindings test | recipes/config-plumbing.md |
cargo +nightly fmt --all · cargo clippy -p <package> --all-targets --all-features -- -D warnings (the crates you touched; drop --all-features without system OpenCV; CI lints the whole workspace) · cargo test -p <package> · make python-dev after config, protocol or binding changes · bash "${CLAUDE_PLUGIN_ROOT}/scripts/gate.sh" for the whole pre-PR gate, scoped the same way.
smg:implement to build with a recipe · smg:craft before writing non-trivial code · smg:review-pr · smg:contribute to ship · smg:learn when this map is wrong. Deeper notes (subsystem types, CI lanes, policy eligibility, tokenizer registration, ZMQ constraints, e2e markers): reference.md in this directory.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub smg-project/smg-dev-guide --plugin smg8 skills in this plugin
/add-modelAdd support for a new checkpoint or model family to SMG end to end. Use for "support model X", "the engine added model Y", "which models did the engine release lately", a new Symphony group row, a new media family, or new conformance rows. Decides what the checkpoint owes (a Symphony row or table, a media family, token-parity and processor-parity rows in the conformance repository) and walks one recipe per part, each step with a file, a verify command and the silent trap./contributeShip a change to the SMG repository. Use before committing, pushing or opening a PR, and when asked "am I ready to submit". Runs the whole pre-PR gate as one command (fmt, clippy, tests, pre-commit, Python/Go lanes, Cargo.lock, vocabulary, branch/commit rules) and names what CI will still run./craftOther plugins' skills for the same job