Skip to content

Three-Branch Strategy

The three-branch strategy gives upstream changes a controlled path into the fork. Each branch is a checkpoint, so a failure stops at the stage where it happened while synchronization continues.

Branch Architecture

graph TD
    A[Upstream Repository] --> B[fork_upstream<br/>Filtered Shared Code]
    B --> C[fork_integration<br/>Staging]  
    C --> D[main<br/>Production]

    E[Local Development] --> F[Feature Branches]
    F --> D

    style A fill:#e1f5fe,stroke:#01579b,stroke-width:2px
    style B fill:#fff3e0,stroke:#e65100,stroke-width:2px
    style C fill:#fce4ec,stroke:#c2185b,stroke-width:2px
    style D fill:#e8f5e9,stroke:#1b5e20,stroke-width:2px
    style E fill:#f3e5f5,stroke:#4a148c,stroke-width:2px
    style F fill:#f3e5f5,stroke:#4a148c,stroke-width:2px

Branch Purposes

  • main - Production Branch


    Stable production branch containing successfully integrated changes

    • Required PR reviews and status checks
    • Shared and fork-owned Azure code
    • Upstream updates arrive through validated release PRs from fork_integration
    • Local feature and hotfix branches also merge through reviewed PRs
  • fork_upstream - Generated Upstream Tree


    Deterministic upstream-owned tree generated from the upstream tip

    • Keeps shared core, acceptance-test, test-core, POM, documentation, and license content
    • Excludes provider source, core-plus, devops/, non-Azure tests, and upstream CI files
    • Injects POM references to Azure modules that exist only on the fork-owned branches
    • Halts when new shared content is not classified
    • Filtered from its first generation: initialization generates the branch through the engine, so the fork never carries a verbatim mirror and the Azure trees never enter the merge base
  • fork_integration - Integration Workspace


    Where conflicts are resolved and the combined tree is validated

    • Relaxed protection so conflict resolution can push directly
    • Combines generated shared code with fork-owned Azure provider and test source
    • Automated merges from fork_upstream with conflict resolution
    • Azure POM version stamping plus core,azure build and test validation

Process Flow

Synchronize

sequenceDiagram
    participant U as Upstream Repo
    participant FU as fork_upstream
    participant S as Sync Workflow
    participant F as Upstream Filter
    participant H as Human Reviewer

    S->>U: Fetch latest changes
    S->>S: Check existing sync PRs and upstream SHA
    S->>F: Generate and verify provider-less tree

    alt New upstream changes, no existing PR
        S->>FU: Create sync branch containing generated tree
        activate FU
        S->>S: Compose PR body from upstream commit range
        S->>S: Create new sync PR and issue
        S->>H: Notify human reviewer
    else Upstream advanced, existing PR open
        S->>FU: Update existing sync branch (force push)
        S->>S: Update PR title and description
        S->>S: Add progress comment to existing issue
        S->>H: Update notification on existing issue
    else Duplicate detected (same upstream SHA)
        S->>S: Keep existing PR and issue unchanged
    else No changes detected
        S->>S: Exit - no action needed
    end

    opt Human approval received
        H->>H: Review and approve
        H->>FU: Merge sync branch into fork_upstream
        S->>S: Update issue and PR state
        S->>S: Cleanup completed sync artifacts
        deactivate FU
    end

Sync State Management

The synchronization process tracks the upstream SHA, active PR, and issue state to prevent duplicates. Before creating or updating a sync branch, the upstream filter classifies the upstream tip and halts on unknown shared content. When upstream advances while a PR is open, the existing branch is regenerated and updated.

Integrate

sequenceDiagram
    participant M as main
    participant FU as fork_upstream
    participant FI as fork_integration
    participant C as Cascade Workflow
    participant H as Human Reviewer

    C->>M: Check for local changes
    M->>FI: Merge main → fork_integration
    activate FI
    C->>FU: Check for upstream updates
    FU->>FI: Merge fork_upstream → fork_integration
    C->>FI: Assert Azure trees and stamp POM versions
    C->>FI: Build and test core,azure
    C->>C: Create main PR

    alt Validation Conflicts/Failures
        C->>C: Create conflict resolution issue
        C->>H: Notify about conflicts
        H->>FI: Push conflict resolution to fork_integration
    end

    C->>FI: Run validation suite
    C->>H: Notify human reviewer
    H->>H: Review and approve
    FI->>M: Merge to main
    deactivate FI

Release

sequenceDiagram
    participant M as main
    participant R as Release Workflow
    participant H as Human Reviewer
    participant DR as Downstream Repo

    M->>R: Push to main triggers release
    R->>R: Analyze commits for version bump
    R->>M: Create release branch with CHANGELOG.md
    activate M
    R->>H: Create release PR
    R->>M: Run validation suite
    H->>H: Review and approve
    H->>M: Merge release branch into main
    deactivate M
    R->>R: Create release & tags

    alt Downstream Consumption
        DR->>M: Pull desired release tag
    end

A downstream repository does not have to stop at pulling release tags. It can be a customer-tier fork running this same three-branch machinery in mirror mode: fork_upstream becomes a verbatim mirror of this repository's main, the cascade integrates it with the downstream's local work, and contribution PRs flow back through the fork network. See Fork Tiers and ADR-039.

Safety Mechanisms

Branch Protection Rules

Protection Setting main fork_upstream fork_integration
Required Reviews 1 minimum Not required Not required
Status Checks CodeQL, Validation Summary Not required Not required
Up-to-date Branch Required Not enforced Not enforced
Force Push Blocked Allowed Allowed
Expected Writers Reviewed PRs Sync automation Cascade and cleanup automation

Quality Gates

Integration Validation

✓ Build Verification: core,azure compilation and dependency resolution ✓ Test Execution: Unit tests plus compile-only validation of the separate Azure testing reactor ✓ Container Validation: Canonical Dockerfile build on branches that contain the Azure JAR ✓ Security Scanning: CodeQL reports through its separate workflow

Production Validation

⚠️ Human Review: a reviewer approves every PR to main
⚠️ Release Notes: Release Please records the change in the changelog

Workflow Benefits

  • Conflict Isolation


    Merge conflicts are resolved in the dedicated fork_integration branch, preventing disruption to the stable main branch during resolution.

  • Clear Change Attribution


    Clear separation between generated upstream-owned shared code and fork-owned Azure implementation changes.

  • Multi-Stage Validation


    Review and validation at each stage catch problems before they reach main.

  • Upstream Tracking


    Reproducible filtered commits retain upstream history and record the upstream SHA and filter revision.

  • Rollback Capability


    A bad integration can be reverted on main without losing the upstream sync state.

Operational Patterns

Daily Synchronization Cycle

Automated Processing:

Step 1: Check Upstream - Daily automated check for new upstream changes
Step 2: Filter Transform - Regenerate and verify the upstream-owned tree Step 3: Sync Review - Review and merge the filtered PR to fork_upstream Step 4: Cascade - Merge into integration, stamp Azure POMs, and run validation

Human Intervention Points:

Step 1: Sync Review - Merge the sync PR into fork_upstream
Step 2: Conflict Resolution - Resolve on fork_integration when the cascade merge fails
Step 3: Production Approval - Approve the release PR to main
Step 4: Release - Merge the Release Please PR when the version is ready

Release Strategy

The cascade opens its PR to main from a temporary release/upstream-YYYYMMDD-HHMMSS branch, which is deleted after merge, so fork_integration itself is never the PR head.