# インフラ構成図

## 全体アーキテクチャ

```mermaid
graph TB
    subgraph "ソースコード管理"
        GH[GitHub<br/>dotnet/fsharp]
    end

    subgraph "CI/CDプラットフォーム"
        subgraph "Azure DevOps"
            ADP_Public[Azure Pipelines<br/>Public Project]
            ADP_Internal[Azure Pipelines<br/>Internal Project]
        end
        GHA[GitHub Actions]
    end

    subgraph "ビルドエージェントプール"
        subgraph "Windows Agents"
            W_INT[NetCore1ESPool-Internal<br/>windows.vs2026preview.scout.amd64]
            W_SVC[NetCore1ESPool-Svc-Internal<br/>windows.vs2026preview.scout.amd64]
            W_PUB[DncEngPublicBuildPool<br/>windows.vs2026preview.scout.amd64.open]
        end
        subgraph "Linux Agents"
            L_PUB[DncEngPublicBuildPool<br/>build.azurelinux.3.amd64.open]
        end
        subgraph "macOS Agents"
            M_VM[VMイメージ<br/>macos-latest]
        end
    end

    subgraph "アーティファクト管理"
        ADA[Azure DevOps Artifacts]
        VSTS[VSTS Drop Service]
        DEVDIV[DevDiv Artifacts]
    end

    subgraph "配布先"
        NUGET[NuGet Feeds<br/>dotnet5-11, dotnet-public]
        VS[Visual Studio<br/>Insertion]
    end

    subgraph "セキュリティ・品質"
        CODEQL[CodeQL]
        BINSKIM[BinSkim]
        TSA[TSA]
        HELIX[Helix<br/>分散テスト]
    end

    GH -->|トリガー| ADP_Public
    GH -->|トリガー| ADP_Internal
    GH -->|ワークフロー| GHA

    ADP_Public --> W_PUB
    ADP_Public --> L_PUB
    ADP_Public --> M_VM

    ADP_Internal --> W_INT
    ADP_Internal --> W_SVC

    W_INT --> ADA
    W_SVC --> ADA
    W_PUB --> ADA
    L_PUB --> ADA
    M_VM --> ADA

    W_INT --> VSTS
    W_SVC --> DEVDIV

    ADA --> NUGET
    DEVDIV --> VS

    ADP_Internal --> CODEQL
    ADP_Internal --> BINSKIM
    ADP_Internal --> TSA
    ADP_Public --> HELIX
```

## ビルドパイプラインフロー

```mermaid
flowchart LR
    subgraph "トリガー"
        PUSH[Push to main/release/*]
        PR[Pull Request]
    end

    subgraph "ビルドステージ"
        BUILD_FULL[Full_Signed Build<br/>Windows]
        BUILD_PR[PR Builds<br/>Windows/Linux/macOS]
        SOURCE[Source Build<br/>Linux Container]
    end

    subgraph "テストステージ"
        TEST_CORE[CoreCLR Tests]
        TEST_DESKTOP[Desktop Tests]
        TEST_VS[VS Integration Tests]
        TEST_E2E[E2E Tests]
        TEST_BENCH[Benchmarks]
        TEST_AOT[AOT/Trimming Tests]
    end

    subgraph "公開ステージ"
        SIGN[Code Signing<br/>MicroBuild]
        SDL[SDL Validation]
        PUBLISH[Publish Artifacts]
    end

    subgraph "統合ステージ"
        VSINS[VS Insertion]
        NUGET_PUB[NuGet Publish]
    end

    PUSH --> BUILD_FULL
    PR --> BUILD_PR

    BUILD_FULL --> SIGN
    BUILD_FULL --> SOURCE
    BUILD_PR --> TEST_CORE
    BUILD_PR --> TEST_DESKTOP
    BUILD_PR --> TEST_VS
    BUILD_PR --> TEST_E2E
    BUILD_PR --> TEST_BENCH
    BUILD_PR --> TEST_AOT

    SIGN --> SDL
    SDL --> PUBLISH
    PUBLISH --> VSINS
    PUBLISH --> NUGET_PUB
```

## エージェントプール選択ロジック

```mermaid
flowchart TD
    START[ビルド開始] --> CHECK_BRANCH{ブランチタイプ?}

    CHECK_BRANCH -->|release/*| SVC_POOL[NetCore1ESPool-Svc-Internal]
    CHECK_BRANCH -->|main/feature/*| CHECK_PROJECT{プロジェクト?}

    CHECK_PROJECT -->|public| PUBLIC_POOL[DncEngPublicBuildPool]
    CHECK_PROJECT -->|internal| INT_POOL[NetCore1ESPool-Internal]

    SVC_POOL --> QUEUE_SVC[サービシングキュー]
    PUBLIC_POOL --> QUEUE_PUB[パブリックキュー]
    INT_POOL --> QUEUE_INT[内部キュー]
```

## NuGetフィード構成

```mermaid
graph LR
    subgraph "パッケージソース"
        DOTNET_ENG[dotnet-eng]
        DOTNET_TOOLS[dotnet-tools]
        DOTNET5[dotnet5]
        DOTNET6[dotnet6]
        DOTNET7[dotnet7]
        DOTNET8[dotnet8]
        DOTNET9[dotnet9]
        DOTNET10[dotnet10]
        DOTNET11[dotnet11]
        DOTNET_PUB[dotnet-public]
        VSSDK[vssdk]
        VS_IMPL[vs-impl]
    end

    subgraph "トランスポートフィード"
        TRANS8[dotnet8-transport]
        TRANS9[dotnet9-transport]
        TRANS10[dotnet10-transport]
        TRANS11[dotnet11-transport]
    end

    subgraph "成果物"
        FCS[FSharp.Compiler.Service]
        FCORE[FSharp.Core]
    end

    DOTNET7 --> FCS
    DOTNET8 --> FCS
    DOTNET10 --> FCORE

    TRANS10 --> FCORE
```

## マルチプラットフォームテスト構成

```mermaid
graph TB
    subgraph "Windows テスト"
        W_CORECLR[CoreCLR Tests]
        W_DESKTOP[Desktop Tests<br/>4並列]
        W_VS[VS Integration Tests]
        W_DETERMINISM[Determinism Tests]
        W_FORMAT[Format Check]
        W_AOT[AOT/Trimming Tests]
    end

    subgraph "Linux テスト"
        L_CORECLR[CoreCLR Tests]
        L_FORMAT[Format Check]
        L_PKG[Package Version Check]
    end

    subgraph "macOS テスト"
        M_CORECLR[CoreCLR Tests]
    end

    subgraph "テスト結果"
        XUNIT[XUnit Results]
        ARTIFACTS[Test Artifacts]
        LOGS[Test Logs]
    end

    W_CORECLR --> XUNIT
    W_DESKTOP --> XUNIT
    W_VS --> XUNIT
    L_CORECLR --> XUNIT
    M_CORECLR --> XUNIT

    W_CORECLR --> ARTIFACTS
    W_DESKTOP --> ARTIFACTS
    L_CORECLR --> LOGS
    M_CORECLR --> LOGS
```

## セキュリティスキャン構成

```mermaid
graph TD
    subgraph "SDL Validation"
        POLICHECK[PoliCheck<br/>ポリシーチェック]
        CREDSCAN[CredScan<br/>認証情報スキャン]
        BINSKIM[BinSkim<br/>バイナリ分析]
        CODEQL[CodeQL<br/>静的分析]
    end

    subgraph "TSA統合"
        TSA_CONFIG[TSAConfig.gdntsa]
        TSA_REPORT[セキュリティレポート]
    end

    subgraph "除外設定"
        POLICHECK_EX[policheck_exclusions.xml]
    end

    POLICHECK --> TSA_REPORT
    CREDSCAN --> TSA_REPORT
    BINSKIM --> TSA_REPORT
    CODEQL --> TSA_REPORT

    POLICHECK_EX --> POLICHECK
    TSA_CONFIG --> TSA_REPORT
```

## VS Insertion フロー

```mermaid
sequenceDiagram
    participant BUILD as ビルドパイプライン
    participant DARC as DARC (publish_using_darc)
    participant INSERT as VS Insertionジョブ
    participant VSDROP as VS Drop Service
    participant VS as Visual Studio

    BUILD->>BUILD: Full_Signed ビルド完了
    BUILD->>DARC: アーティファクト公開
    DARC->>INSERT: ステージ開始トリガー
    INSERT->>INSERT: VSSetupアーティファクトダウンロード
    INSERT->>INSERT: default.config バージョン取得
    INSERT->>INSERT: AssemblyVersions.tt バージョン取得
    INSERT->>VSDROP: ペイロードアップロード
    INSERT->>VS: Insertionプルリクエスト作成

    alt autoComplete = true
        VS->>VS: 自動マージ
    else autoComplete = false
        VS->>VS: 手動レビュー待ち
    end
```
