Skip to content

docs(workers): audit and fix worker setup, service discovery, external providers, HA - #1159

Merged
slin1237 merged 1 commit into
mainfrom
docs/audit-team-2-workers
Apr 15, 2026
Merged

slin1237 merged 1 commit into
mainfrom
docs/audit-team-2-workers

Conversation

@slin1237

@slin1237 slin1237 commented Apr 15, 2026 •

Copy link
Copy Markdown
Member

Description

Problem

Documentation for worker setup, service discovery, external cloud
provider routing, and high-availability mesh may be out of date,
incorrect, or missing content relative to the current codebase. Many
of the claims in these pages (defaults, flag names, headers, example
JSON responses, label-selector syntax, bootstrap semantics) were
never mechanically checked against source after recent refactors.

Solution

Systematic audit of the following doc files against source code,
verifying every CLI flag default, endpoint path, request/response
field, header format, bootstrap recipe, and example command, then
fixing discrepancies in place while preserving the surrounding style:

  • docs/getting-started/multiple-workers.md
  • docs/getting-started/service-discovery.md
  • docs/getting-started/external-providers.md
  • docs/concepts/architecture/service-discovery.md
  • docs/concepts/architecture/high-availability.md

Scoped to six doc files in total (including docs/getting-started/ grpc-workers.md, which was audited and found accurate — left
untouched). Every change cites a file:line reference in
model_gateway/, crates/protocols/, crates/mesh/, or
crates/mesh/src/proto/gossip.proto. Writer phase performed
inventory, verify, discover, and fix; Tech Lead phase independently
re-verified every change against cited source code, with an explicit
second review round to resolve three blocking items before shipping.

Changes

  • Verified ~110 claims across 6 doc files
  • Fixed 18 inaccuracies across 5 touched doc files
  • Updated 4 outdated items (runtime enum coverage including mlx,
    worker states table matching the WorkerStatus enum, discovery
    metrics table, service-discovery registration flow /model_info
    with documented /get_model_info 404 fallback)
  • Documented 11 previously undocumented features (mesh bootstrap
    semantics, --mesh-advertise-host requirement on unspecified bind
    addresses, connection mode auto-probing during registration, the
    NodeStatus enum discriminant format used in /ha/status
    responses, and other small surfaces)
  • Removed non-existent sections: Environment Variables blocks in
    service-discovery.md and high-availability.md (no service
    discovery or mesh CLI arg reads env vars), fabricated
    containerPort: 3001 / name: admin in a K8s example, stale
    /mesh/cluster/status sync endpoints admonition, and the
    non-existent --service-discovery-protocol row
  • Corrected the /ha/status cluster status JSON example in
    concepts/architecture/high-availability.md to match the actual
    observable format emitted by the mesh status handler. status is
    produced by format!("{:?}", node.status) where node.status is
    the prost-generated i32, so Debug on i32 emits the decimal
    discriminant ("1" for ALIVE) rather than the enum name. Also
    added the full discriminant mapping
    (0 INIT / 1 ALIVE / 2 SUSPECTED / 3 DOWN / 4 LEAVING).
  • Switched the PD --prefill-selector / --decode-selector examples
    in both service-discovery pages from broken quoted comma-separated
    form to the working space-separated key=value form, since
    parse_selector splits each element at the first = and the clap
    args use num_args = 0.. for multi-value support.
  • Switched the --mesh-peer-urls examples in three-node, five-node,
    and StatefulSet K8s configurations to a single bootstrap peer, and
    added an explanatory admonition documenting that only the first
    entry is used as the bootstrap peer with the rest learned via
    gossip.

Test Plan

  • Each fix cites a source code reference (file:line) in the commit
    message body and in the audit worksheet.
  • mkdocs build --strict --clean --quiet runs cleanly on the PR tree.
  • Two independent review rounds by the Tech Lead agent against cited
    source code, with a Round 1 punch list covering the three blocking
    items listed above and a Round 2 re-verification resolving them.
  • No source code (Rust, Python bindings, Cargo, Makefile, GitHub
    workflows) was modified.
  • Internal doc links in the touched files still resolve under
    mkdocs --strict.
Checklist
  • Documentation updated
  • (Optional) Please join us on Slack #sig-smg to discuss, review, and merge PRs

Summary by CodeRabbit

  • Documentation
    • Updated HA mesh configuration guidance: default server names, bootstrap semantics, and simplified Kubernetes examples.
    • Clarified API response formats with numeric status discriminants and aggregated node counts.
    • Simplified service discovery: removed environment variables, updated CLI selector syntax to space-separated format, and auto-probed connection modes.
    • Updated external provider authentication requirements for Anthropic and Google Gemini.
    • Revised worker lifecycle states and Cloud API Workers setup instructions with flexible authentication options.

…l providers, HA

Systematic audit of worker setup, service discovery, external provider
routing, and high availability documentation against
model_gateway/src/worker/, service_discovery.rs, routers/{openai,
anthropic,gemini}/, config/types.rs ConnectionMode/ProviderType,
crates/mesh/, routers/mesh/handlers.rs, and the worker-/discovery-/
mesh-related CLI flags in main.rs. Writer phase performed inventory,
verify, discover, and fix; Tech Lead phase independently re-verified
every change against cited source code before shipping.

- Inventoried ~110 verifiable claims across 6 doc files (5 touched,
  grpc-workers.md verified as accurate and left untouched)
- Fixed 18 inaccuracies: Anthropic/Gemini header formats, Gemini auth,
  fan-out model discovery semantics (returns first non-empty vs
  "aggregates across all"), service-discovery defaults
  (--service-discovery-port 8000 -> 80, --service-discovery-namespace
  default -> all namespaces), removed non-existent
  --service-discovery-protocol flag, PD prefill/decode selector
  examples switched from broken comma-separated to working
  space-separated key=value form (parse_selector splits on first `=`
  per element), removed non-existent set-based selector examples,
  --backend openai for cloud providers claim, Cloud API BYOK header
  flow, POST /workers runtime default (sglang -> auto-detect /
  Unspecified), mesh peer urls "only first entry is used" bootstrap
  semantics, /get_model_info -> /model_info (with documented 404
  fallback), worker states table (Registering/Ready/Unhealthy/Draining
  -> Pending/Ready/NotReady/Failed matching WorkerStatus enum), admin
  verify URL port 3001 -> 30000, and the /ha/status cluster status
  JSON example (field order, stores object shape, status discriminant)
- Updated 4 outdated items: RuntimeType enum coverage (added mlx),
  worker states table, discovery metrics table (added
  smg_discovery_sync_duration_seconds), and service discovery
  registration flow endpoint path
- Documented 11 previously undocumented features: --mesh-server-name
  auto-naming format, --mesh-peer-urls first-entry semantics,
  --mesh-advertise-host requirement when bind address is unspecified,
  auto connection mode probing during registration, NodeStatus enum
  discriminant mapping in /ha/status responses, and others
- Removed non-existent sections: Environment Variables blocks in
  service-discovery and high-availability (no service discovery or
  mesh CLI arg reads env vars), fabricated containerPort: 3001 / name:
  admin in K8s examples, and stale /mesh/cluster/status sync endpoints
- Round 1 Tech Lead punch list resolved:
  * Cluster status JSON example in high-availability.md corrected to
    match the actual observable format produced by the mesh status
    handler. status is format!("{:?}", node.status) where
    node.status is prost-generated i32 (not the NodeStatus enum
    itself), so Debug on i32 emits the decimal discriminant "1" for
    ALIVE (routers/mesh/handlers.rs:75, crates/mesh/src/proto/
    gossip.proto:11-17). Documented the full discriminant mapping
    0 INIT / 1 ALIVE / 2 SUSPECTED / 3 DOWN / 4 LEAVING.
  * PD selector example in getting-started/service-discovery.md
    corrected to the space-separated form accepted by parse_selector
    (main.rs:793-803) and the clap num_args = 0.. attribute on
    prefill_selector / decode_selector (main.rs:262-267).
  * Same PD selector fix applied to concepts/architecture/
    service-discovery.md so both service discovery pages show the
    working form.

The audit worksheet is kept as worktree-local scratch under
docs/_audit/ and is deliberately not committed to avoid polluting the
rendered mkdocs site.

Refs: .claude/plans/2026-04-15-docs-audit-workflow.md (Team 2)
Signed-off-by: Simo Lin <linsimo.mark@gmail.com>
@slin1237
slin1237 requested a review from CatherineSue as a code owner April 15, 2026 19:26
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Apr 15, 2026
@coderabbitai

coderabbitai Bot commented Apr 15, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Documentation updates reflecting configuration and API behavior changes across the system. Updates cover HA mesh defaults and peer URL semantics, service discovery namespace/port defaults and label selector syntax, external provider authentication headers and model aggregation, worker authentication methods and runtime options, and worker lifecycle state definitions.

Changes

Cohort / File(s) Summary
HA Mesh Configuration
docs/concepts/architecture/high-availability.md
Updated default --mesh-server-name format to Mesh_<4 random chars>, clarified that only first --mesh-peer-urls entry bootstraps the cluster, added requirement for --mesh-advertise-host when binding to 0.0.0.0, and updated HA API response format to use numeric status discriminants and aggregated store counts instead of detailed store breakdowns.
Service Discovery Guidance
docs/concepts/architecture/service-discovery.md, docs/getting-started/service-discovery.md
Removed environment variable documentation (SMG_SERVICE_DISCOVERY, etc.), changed label selector syntax from comma-separated to space-separated key=value pairs, updated worker endpoint from /get_model_info to /model_info with fallback, introduced new worker lifecycle states (Pending, NotReady, Failed), and changed service discovery defaults for namespace and port.
External Provider Integration
docs/getting-started/external-providers.md
Updated Anthropic to require both x-api-key and anthropic-version headers, changed Google Gemini from Authorization: Bearer to x-goog-api-key, and modified model aggregation to return first non-empty inventory instead of aggregating from all providers.
Worker Configuration
docs/getting-started/multiple-workers.md
Changed authentication from environment variable API keys to caller-supplied Authorization header (BYOK) or worker record storage, switched --backend from OpenAI-specific to generic with auto-detection, and updated runtime field default from sglang to (auto-detect) with expanded options including mlx.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

  • #786: Modifies the same HA mesh and external provider documentation covering --mesh-server-name, --mesh-peer-urls semantics, and provider header/aggregation behavior.
  • #1154: Updates PD/service discovery selector syntax from comma-quoted to space-separated key=value format alongside this PR.
  • #972: Helm chart changes that correspond to the documented mesh deployment patterns, StatefulSet configuration, and peer URL behavior changes reflected in this documentation.

Suggested labels

documentation

Suggested reviewers

  • CatherineSue

Poem

🐰 ✨ Mesh meshes kindly with new clarity,
Service discovery dances in space-separated harmony,
Providers authenticate with shiny new headers,
Workers find their way through clearer pathways,
Documentation springs forth, fresh and merry! 🌱

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main documentation audit and fixes across multiple systems (worker setup, service discovery, external providers, HA).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/audit-team-2-workers

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the documentation for high availability and service discovery to reflect recent architectural changes. Key updates include clarifications on mesh bootstrap behavior, the transition to space-separated label selectors, and the renaming of worker states and management API endpoints. One review comment identifies a technical inaccuracy regarding the default port for service discovery, which should be reverted to 8000 to align with the source code implementation.

| `--service-discovery-port` | `8000` | Port to use for worker connections |
| `--service-discovery-protocol` | `http` | Protocol: `http` or `grpc` |
| `--service-discovery-namespace` | (all namespaces) | Kubernetes namespace to watch |
| `--service-discovery-port` | `80` | Port to use for worker connections |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The default value for --service-discovery-port appears to be 8000, not 80. The source code in model_gateway/src/service_discovery.rs defines the default as 8000 in the ServiceDiscoveryConfig::default() implementation. This change seems to introduce an inaccuracy.

Suggested change
| `--service-discovery-port` | `80` | Port to use for worker connections |
| --service-discovery-port | 8000 | Port to use for worker connections |
References
  1. In documentation for technical values, use literal values (slugs) to ensure accuracy and copy-paste friendliness.
  2. During documentation audits, focus on fixing inaccuracies in existing documentation.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/concepts/architecture/high-availability.md`:
- Around line 137-139: The note title is ambiguous about --mesh-host; change it
to explicitly say "when --mesh-host is set to an unspecified bind address" to
match the body. Update the note header that currently reads
"`--mesh-advertise-host` is required when `--mesh-host` is unspecified" to
something like "`--mesh-advertise-host` is required when `--mesh-host` is set to
an unspecified bind address (e.g., 0.0.0.0)`" so the wording aligns with the
body explanation referencing the flags --mesh-host and --mesh-advertise-host.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 320d0223-e83d-467c-b660-133f62b9152e

📥 Commits

Reviewing files that changed from the base of the PR and between 8ce6568 and f97fd55.

📒 Files selected for processing (5)
  • docs/concepts/architecture/high-availability.md
  • docs/concepts/architecture/service-discovery.md
  • docs/getting-started/external-providers.md
  • docs/getting-started/multiple-workers.md
  • docs/getting-started/service-discovery.md

Comment on lines +137 to +139
!!! note "`--mesh-advertise-host` is required when `--mesh-host` is unspecified"
If `--mesh-host` is set to an unspecified bind address (for example `0.0.0.0`), the gateway refuses to start unless `--mesh-advertise-host` is set to a routable node IP. This prevents other peers from trying to dial an unroutable address.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Clarify the note title wording.

The note title says "is required when --mesh-host is unspecified" which could be misread as "when the flag is not provided." The body text correctly explains "set to an unspecified bind address (for example 0.0.0.0)".

Consider rewording the title to match the body's precision:

📝 Suggested title rewording
-!!! note "`--mesh-advertise-host` is required when `--mesh-host` is unspecified"
+!!! note "`--mesh-advertise-host` is required when `--mesh-host` is an unspecified address"
     If `--mesh-host` is set to an unspecified bind address (for example `0.0.0.0`), the gateway refuses to start unless `--mesh-advertise-host` is set to a routable node IP. This prevents other peers from trying to dial an unroutable address.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
!!! note "`--mesh-advertise-host` is required when `--mesh-host` is unspecified"
If `--mesh-host` is set to an unspecified bind address (for example `0.0.0.0`), the gateway refuses to start unless `--mesh-advertise-host` is set to a routable node IP. This prevents other peers from trying to dial an unroutable address.
!!! note "`--mesh-advertise-host` is required when `--mesh-host` is an unspecified address"
If `--mesh-host` is set to an unspecified bind address (for example `0.0.0.0`), the gateway refuses to start unless `--mesh-advertise-host` is set to a routable node IP. This prevents other peers from trying to dial an unroutable address.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/concepts/architecture/high-availability.md` around lines 137 - 139, The
note title is ambiguous about --mesh-host; change it to explicitly say "when
--mesh-host is set to an unspecified bind address" to match the body. Update the
note header that currently reads "`--mesh-advertise-host` is required when
`--mesh-host` is unspecified" to something like "`--mesh-advertise-host` is
required when `--mesh-host` is set to an unspecified bind address (e.g.,
0.0.0.0)`" so the wording aligns with the body explanation referencing the flags
--mesh-host and --mesh-advertise-host.

@slin1237
slin1237 merged commit 0355a53 into main Apr 15, 2026
12 checks passed
@slin1237
slin1237 deleted the docs/audit-team-2-workers branch April 15, 2026 19:40
DavidBellamy added a commit to LLM360/smg that referenced this pull request May 5, 2026
Patches 9 files (golang gRPC converter, chat protocol builders,
gRPC harmony/regular processor/streaming paths, header_utils) to apply
the agentic-rl runtime modifications statically. Note: smg's primary
distribution is the patched wheel built by .github/workflows/build-smg-wheel.yml
and published as a GH Release; this prod branch is a parallel git artifact
of the same patched source for direct consumption.

Source: LLM360/RL360 patches/agentic-rl/smg.patch
        @ f34aa3b166c0a2466df9b38fd5f8be9ff78e2dae
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant