Appearance
ADR-2198: Self-Hosted CI Runner and Trunk-Based Branching Lifecycle
- Status: Accepted
- Date: 2026-08-22
- Authors: @fderuiter
- Deciders: @fderuiter
1. Context & Problem Statement
As Cadence Clinical progresses through its pre-production engineering lifecycle, maintaining dual integration branches (dev and main) introduced synchronization drift, duplicate CI execution overhead, and ambiguous pull request targets. Furthermore, running comprehensive multi-engine integration test suites (PostgreSQL, Neo4j, Redis, ClamAV) on standard public cloud runners incurred significant startup latency and consumable compute costs.
Transitioning the repository to private visibility enables the safe deployment of a dedicated, high-performance local macOS CI/CD runner (Apple Silicon Mac Mini), while establishing a future-proof, linear Trunk-Based Development workflow.
This decision maps to system reliability and operational requirements under PRD-SYS-001.
2. Decision Drivers & Constraints
- Security & Sandboxing: GitHub strictly discourages self-hosted runners on public repositories due to untrusted pull request execution risks. Private repository isolation is mandatory before deploying a local machine as a runner.
- Trunk Cleanliness & Linear Auditability: GxP clinical software traceability (21 CFR Part 11) requires a clean, bisectable, and immutable commit history on the primary branch.
- Resource Optimization & Runner Throughput: As a single physical host, the Mac Mini runner must maximize test throughput, eliminate container boot latency, and avoid pipeline queue congestion caused by rapid iterative commits.
- Process Resilience & Hands-Off Maintenance: The runner must operate headless as a system daemon that survives macOS reboots without manual terminal management.
3. Options Considered
Option 1: Dual-Trunk GitFlow (dev + main) with Ephemeral Cloud Runners
- Overview: Maintain
devas the daily integration branch andmainas the release mirror, running builds on cloud-hosted runners (ubuntu-latest). - Pros:
- Standard GitHub-managed cloud infrastructure.
- Cons:
- ❌ Pre-production branch drift between
devandmain. - ❌ 30-60s cold-start overhead per job provisioning dependencies.
- ❌ Higher cloud resource consumption and rate limits.
- ❌ Pre-production branch drift between
Option 2: Private Repository + Trunk-Based Development (main) + Dedicated macOS launchd Self-Hosted Runner (Selected)
- Overview: Standardize on Trunk-Based Development with
mainas the sole protected trunk. Deploy a dedicated Mac Mini runner usinglaunchdbackground services, host-native toolpaths (uv,pnpm), persistent test service daemons, and PR-scopedcancel-in-progresstriggers. - Pros:
- ✅ Zero Branch Drift: All feature branches (
feat/*,fix/*) branch from and squash-merge intomain. - ✅ Instant CI Startup: Host-native
uvandpnpmexecution eliminates runner setup overhead. - ✅ High-Throughput Isolation: Cadence's existing worker-suffix database isolation (
_{run_uid}_{worker_id}) runs against persistent local daemons without container restarts. - ✅ Queue Protection:
cancel-in-progresson pull requests terminates obsolete runs immediately upon new pushes.
- ✅ Zero Branch Drift: All feature branches (
- Cons:
- ❌ Requires initial local runner installation and Homebrew/Docker daemon management.
4. Decision Outcome
- Chosen Option: Option 2
- Justification: Option 2 provides sub-second CI startup velocity, eliminates branch management friction in pre-production, guarantees complete security via private repository boundaries, and produces an immaculate, linear commit history on
main.
5. Consequences & Trade-offs
- Positive:
- Immediate feedback cycles on pull requests (<2 minutes full verification).
- Eliminates duplicate merge overhead between
devandmain. - Secure execution environment gated behind private GitHub repository permissions.
- Clean, bisectable linear git history on
main.
- Negative:
- Requires maintaining the Mac Mini host environment (e.g. keeping Homebrew packages, Docker daemons, and Node/Python runtimes up to date).
- Mitigation:
- Use
launchdservice management for automated daemon recovery. - Implement workspace artifact sweeps (
git clean -ffdx -e .venv -e node_modules) before each job run.
- Use
6. Implementation & Verification
- Branch Topology:
- Retire
devbranch after merging active features intomain. - Set
mainas default branch on GitHub. - Enforce branch protection: require PR, require CI status checks, require squash-and-merge with linear history.
- Retire
- Runner Provisioning:
- Configure GitHub Runner on macOS under
launchdbackground service (svc.sh installandsvc.sh start). - Label runner:
self-hosted, macOS.
- Configure GitHub Runner on macOS under
- Workflow Pipeline:
- Update
.github/workflows/ci.ymljobs to specifyruns-on: [self-hosted, macOS]. - Configure PR concurrency:
concurrency.cancel-in-progress: true.
- Update
- Verification Plan:
- Validate ADR compliance via
uv run python scripts/validate_adrs.py. - Test runner connectivity by triggering a test workflow on a feature branch PR.
- Validate ADR compliance via