Designing a Commit-to-Car Release Pipeline with Graph-Based Builds
System DesignModel answerLast updated
Design the path from a monorepo push to software running on customer vehicles, then explain how the build system chooses and orders the targets to build and test.
You are designing release infrastructure for an automaker. A developer pushes a change to the company's single large repository. Some time later, software containing that change is running on the onboard computers of cars owned by customers.
Part 1: Push to fleet. Describe the full journey. Cover how the change is checked and built, where outputs are kept, how a release is put together, and how it reaches and is installed on vehicles. For each stage, state what might fail and which gate prevents a faulty change from advancing.
Your answer should address:
- Checks before merge, and a CI pipeline that yields reproducible, traceable artifacts
- Artifact storage, signing, and provenance tying every installed binary to its originating commit
- A staged rollout with health gates, the ability to pause, and rollback
- Secure delivery and safe installation inside the vehicle
Part 2: What to build. The repository holds many projects, so one commit must not trigger a rebuild and retest of everything. How does the system determine which targets need building and testing for a given commit, and in what order should they run?
Your answer should address:
- How dependencies between targets are declared and modeled
- Finding every affected target, including indirectly affected ones
- An ordering that honors dependencies while using parallelism and caching
- Situations where analysis based on changed files is incorrect or unsafe
Before designing, state the clarifying questions you would ask (single image vs. per-computer components, number of hardware variants, commit volume, safety qualification needs, in-vehicle install constraints such as parked-only and power loss, and how vehicles reach the backend, including long-offline cars) and the assumptions you adopt.
Hints
Hint 1
Think of one immutable artifact that is built once and then promoted through every environment; each stage adds evidence (tests, signatures) rather than rebuilding.
Hint 2
On the vehicle, assume power can fail at any moment: use an A/B partition scheme with verification before commit and an automatic fall-back to the previous known-good slot.
Hint 3
Model the build as a directed acyclic graph of targets. Affected targets are the reverse-transitive closure of the changed targets; ordering is a topological sort with caching keyed by input hashes.
Hint 4
File-diff analysis misses changes that are not in the file graph: toolchain versions, build flags, generated code, config, data files, and dynamically loaded dependencies.
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
Assumptions
- Software ships as separately versioned components (e.g., infotainment, driver assistance, body control) grouped into a signed release manifest for each hardware variant.
- Hundreds to thousands of commits per day; pre-merge checks should finish in roughly 10-20 minutes.
- Safety-relevant components need extra qualification and sign-off.
- Cars install only when parked and sufficiently charged, and may stay offline for weeks.
Part 1: Push to fleet
1. Pre-merge. Changes go through code review and a merge queue. The queue tests the change rebased on the current head, so the main branch stays green. Gates: required reviewers (code owners, with extra ones for safety code), static analysis, linters, unit tests, and only the targets affected by the change (see Part 2). Failure blocks the merge.
2. Main-branch CI build. A hermetic build (pinned toolchain in a container, no network access, fixed inputs) produces binaries. Reproducibility matters: the same commit should yield bit-identical output, or at least verifiably equivalent output. Run broader tests: integration tests, and simulation or software-in-the-loop tests of control logic. Common failure: flaky tests. Quarantine and track them rather than retrying blindly.
3. Artifact storage and provenance. Push artifacts to an immutable, content-addressed registry. Each carries metadata: commit SHA, build ID, toolchain digest, dependency hashes, test results, and an SBOM. A build service, not a developer machine, signs the artifact, and the signing key lives in an HSM. Provenance (SLSA-style attestations) lets any installed binary be traced to its source commit, and prevents a tampered artifact from being promoted.
4. Release assembly. A release candidate is a manifest listing exact component versions and hashes, per hardware variant, with compatibility constraints (a component requires a minimum version of another). Promotion uses the same artifacts, never a rebuild. Gates become progressively more realistic:
- Hardware-in-the-loop benches
- Test vehicles and an internal employee fleet
- For safety-critical parts: formal sign-off, traceability to requirements, regulatory checks
5. Staged rollout. Rollout proceeds in cohorts, e.g. internal 0.1%, then 1%, 5%, 25%, 100%, with a soak time at each step. Gates are automated health metrics compared with a control group: install success rate, boot-loop and crash rates, fault codes, connectivity, battery drain. Breaching a threshold pauses the rollout automatically. Cohorts are chosen to cover hardware variants and regions. A kill switch halts distribution quickly, and the manifest can be revoked. Rollback means pointing targeted cars back at the previous manifest, with the rule that a version older than a security floor is never installed.
6. Delivery. Cars poll (or are nudged by push notification) for an eligible manifest. Downloads go through a CDN over TLS, are resumable, and may be delta-compressed. The vehicle verifies the manifest signature, the artifact hashes, and rollback-protection counters before installing, so a compromised network or CDN cannot inject code. Cars offline for a long time get the latest eligible release, and the manifest's compatibility rules cover skipped intermediate versions.
7. Installation. Preconditions: parked, adequate battery or charger connected, no active driving mode. Use an A/B partition scheme: write the new image to the inactive slot, verify it, then flip the boot pointer. On first boot, a health check must pass and confirm the slot ("commit"). If it fails or a watchdog trips, the bootloader falls back to the old slot automatically. Power loss during the write leaves the active slot untouched. Multi-computer updates are coordinated so the car never ends up in an incompatible mixed-version state; if one computer fails, the set rolls back together. Telemetry reports the result to the backend.
Part 2: Deciding what to build
Declare dependencies explicitly. Each target (library, binary, test) declares its inputs and direct dependencies in build files (as in Bazel or Buck). The system models this as a DAG. Explicit declaration, enforced by sandboxing so undeclared inputs are inaccessible, keeps the graph truthful.
Find affected targets.
- Diff the commit to get changed files.
- Map files to owning targets.
- Compute the reverse transitive closure: every target that depends directly or indirectly on a changed target. A breadth-first search over reverse edges does this in O(V+E).
- Run tests only for affected test targets. Library tests are relevant if the library or anything beneath it changed.
A cleaner alternative is to hash each target's inputs (sources, dependency hashes, flags, toolchain). Targets whose hash differs from a cached result are affected, which also gives correct caching for free.
Order. Topologically sort the affected subgraph; targets with no unbuilt dependencies run in parallel across a worker pool. A remote cache keyed by input hash means unchanged targets are fetched rather than rebuilt, and remote execution spreads the work. Prioritize the critical path and fast-failing tests first. Cycles are rejected at analysis time.
When file-based analysis is wrong.
- Changes to the toolchain, compiler flags, or global build configuration affect every target.
- Generated code, code generators, and schema or protobuf changes whose outputs are not listed as inputs.
- Data files, configs, or calibration parameters loaded at runtime that are not declared as dependencies.
- Dynamic loading, reflection, or runtime plugin discovery that hides edges.
- File moves or deletions, and changes to the build files themselves, which change the graph.
- Cross-language or external dependencies, such as an updated third-party version.
Mitigations: treat build-file and toolchain changes as "build everything", enforce hermetic sandboxes, periodically run a full build and test on main to catch missed edges, and fail closed when unsure.
Trade-offs and common mistakes
- Rebuilding per stage instead of promoting one artifact breaks traceability.
- Skipping the soak time or relying only on crash metrics misses slow-burn issues.
- Trusting TLS alone without signed manifests and rollback protection.
- Non-atomic install, so power loss bricks the car.
- Over-trusting affected-target analysis without a periodic full build as a safety net.
- Stricter gating slows velocity; balance it by making cheap gates run early and expensive ones (HIL, vehicle fleets) run on release candidates rather than every commit.