← Back to Pull requests

types: select services with a single copy of the project #1001

Open
unknown opened this pull request with 275 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 20, 2026 13:27 UTC
Author

What this PR does, in one sentence

It makes Project.WithSelectedServices copy the project once, instead of once per service it leaves out.

Context

Selecting services disabled each unselected service through WithServicesDisabled, which deep copies the whole project. For a project of n services of which k are selected, that is n-k full copies: the cost grows with the square of the model, and every compose up web on a large project pays it. On a model of 300 services (environment, labels, volumes, a healthcheck, a depends_on chain), selecting one service takes 290 ms and allocates 484 MB. The WithSelectedServices load option goes through the same method, so it does not avoid the cost.

What the PR brings

  • The unselected services are moved to DisabledServices in a single pass over one copy. On the same model, selecting one service takes 1.3 ms and 2.2 MB; a full LoadProject with one targeted service drops from 1063 MB to 581 MB.

  • WithSelectedJob, which disabled every service one by one for a job with no service dependency, now does it in a single WithServicesDisabled call.

  • Guardrails: same result for the selected services (they keep only the dependencies that are part of the selection), the original project is still left unchanged, and DisabledServices stays nil when nothing is disabled. One difference: the depends_on of the disabled services is now left as declared. The former loop pruned them depending on the iteration order of a map, so they were not deterministic.
  • The tests check the contract (original untouched, no shared state with the copy, nothing disabled when everything is selected) and that the allocations grow linearly with the number of services; the latter fail on the previous implementation.

    This follows the erooM law promoted by Tristan Nitot (_Effort Radicalement Organisé d'Optimisation en Masse_: optimize software by a factor of two every two years, by finding the components that consume the most resources and optimizing them). Profiling found the component here: selecting one service of a 300-service model goes from 484 MB to 2.2 MB allocated.

    🤖 Generated with Claude Code

    Diff: 275 lines (+206 / -69) across 3 files Reviewer: glours Review duration: 18259m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.40) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 275 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    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
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.336
    Real PR Conversation Timeline
    1 comments
    "Review active on #1001"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% 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: 39.6% (MEDIUM) · Higher = larger blast radius
    39.6%
    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: 46.7% · Lower = rushed or shallow review
    46.7%
    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: 21.1% · Safe to merge
    21.1%