← Back to Pull requests

refactor(gateway): the create-worker step's tests sit in a sibling file, not in the production module #4318

Open
unknown opened this pull request with 399 lines diff across 4 files
View on GitHub
unknown unknown commented on Oct 23, 2026 11:04 UTC
Author

What

model_gateway/src/workflow/steps/local/create_worker.rs was 2,584 lines, 1,488 of them three inline #[cfg(test)] modules. The largest, tests (1,280 lines), sat between the step's production code and the two small modules after it, and a rename in the production part moved every test line in the diff. The repository keeps such tests as sibling files already (the policies' cache_aware/tests.rs, the KV index's chain_index/tests.rs and token_tree/tests.rs, the worker manager's manager/tests.rs).

That module moves to model_gateway/src/workflow/steps/local/create_worker/tests.rs, the test-sibling form: create_worker.rs keeps #[cfg(test)] mod tests; where the block was, the sibling holds the module's body at the shallower depth. The module path stays create_worker::tests, so every one of its 32 tests keeps its name; no production line changes.

Changes

  • model_gateway/src/workflow/steps/local/create_worker.rs: the module's body (lines 1,098-2,376) replaced by mod tests; -> 1,306 lines. The 1,097 lines before the block and the 209 after it are byte for byte the same.

  • model_gateway/src/workflow/steps/local/create_worker/tests.rs (new, 1,263 lines): the module's body with one level of indentation removed; rustfmt re-joined statements that now fit a line at the shallower depth (26 lines into 12), the only differences; 269 of the 273 lines carrying a string literal are unchanged, the four others now sit on the joined lines of their calls.
  • Test plan

    No behaviour change and no production change; the proof is the test list by name:

  • cargo test -p smg --lib -- --list on the base commit and on this head: 3,674 names before, 3,674 after, identical lists (diff empty).

  • cargo +nightly fmt -p smg -- --check clean; cargo clippy -p smg --all-targets -- -D warnings clean.

  • cargo check --workspace --all-targets.

  • cargo test -p smg --lib -- workflow::steps::local::create_worker::tests (the moved module's tests): 32 passed, 0 failed, 0 ignored. The whole gateway integration suite is not re-run for this change: no production line changes, and the lib test list is the proof the tests are all still there.
  • Owed

    Nothing on an engine. One open pull request of another author changes this file's test module as part of a wider change; its test hunks land in the sibling file after a rebase (a note left on it).

    Notes

    Behaviour and performance unchanged: a test-module move, no production line changes.

    Release note

    Internal: the create-worker step's tests live in a sibling file (create_worker/tests.rs); no change in behaviour.

    Numbers

    | metric | before | after | setup |
    |---|---|---|---|
    | create_worker.rs | 2,584 lines (1,280 of them the moved module) | 1,306 lines | wc -l |
    | create_worker/tests.rs | 0 lines (no file yet) | 1,263 lines | wc -l |
    | gateway lib tests by name (cargo test -p smg --lib -- --list) | 3,674 | 3,674 (the same names) | the two lists, diff empty |
    | the moved module's tests (cargo test -p smg --lib -- workflow::steps::local::create_worker::tests) | same as after (no test added or removed) | 32 passed, 0 failed, 0 ignored | same command on this head |

    Diff: 399 lines (+299 / -100) across 4 files Reviewer: claude[bot] Review duration: 5m
    All Vouch review confidence checks passed
    Residual risk 0.30 = Change Risk (0.43) × (1 − Review Confidence (0.30)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 399 lines diff across 4 files
    0.43
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 50% · Reviewer familiarity: 35%
    29%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.358
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #4318"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 29.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 43.2% (MEDIUM) · Higher = larger blast radius
    43.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 29.8% · Lower = rushed or shallow review
    29.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 30.4% · Safe to merge
    30.4%