skip to content

Would you publish prebuilt generated stubs from a contract repository, or have each consuming team generate from the IDL at build time?

level: principalimportance: should knowfreq 33%

answer

  1. uniformity against team autonomy
  2. who owns the generation inputs
  3. one pipeline per ecosystem is real work
  4. divergent generators, same claimed version
  5. hybrid: publish for the majority targets

basics

~20 s

It is a trade between uniformity and autonomy. Publishing stubs centralises the generator version and spares consumers a toolchain, at the cost of the contract repository owning a build pipeline per ecosystem; consumer-side generation reverses both.

solid answer

~50 s

Publishing prebuilt stubs gives one generator version, one review and one place to see who depends on what; consumers need no toolchain and cannot hand-edit what they did not build. The price is that the contract repository must own, release and support a pipeline for every ecosystem it serves, which makes it a bottleneck and makes adding a target a change to a shared repository. Consumer-side generation gives each team its own generation options and upgrade timing and keeps the contract repository publishing only the contract, but generator versions and options then diverge, so consumers can differ subtly while claiming the same contract version. I would choose by the number of ecosystems, how uniform the generated semantics must be, and whether a platform team exists to own the pipelines — and in either case publish the contract itself as a first-class versioned artefact.

go deeper

for a junior

Know that generated stubs can either arrive as a dependency built by a central team or be produced by your own build from the contract file.

for a middle

Explain the mechanics of each path — where generation runs, which inputs are pinned, and what a consumer must install in each case.

for a senior

Argue the operational consequences: bottlenecks and release coupling on one side, divergent generator versions and inconsistent semantics on the other, and what you would measure.

for a principal

Make the call for a specific organisation, name the hybrid, state the failure mode of your choice, and fix the properties you refuse to trade away.

## What is actually being decided Both models agree that the contract is the source of truth and that stubs are generated from it. What is being decided is **where generation runs and who owns its inputs** — and, through that, whether uniformity or team autonomy is the property the organisation optimises for. It is a genuine judgment call: both models are in wide use and neither is a mistake. ## Central publication of stub artefacts **What it buys** - One generator version and one set of options, so every consumer's generated semantics match. - No toolchain requirement on consumers: a team adds a dependency and is finished. - A single place to see who depends on which contract version, because dependency resolution is the record. - Hand-editing is structurally impossible; consumers never hold the generated source. - One review of the generated diff when the generator is upgraded, rather than N discoveries. **What it costs** - The contract repository must own a build and release pipeline **per ecosystem** it supports, including the packaging conventions of each — real, recurring work. - It becomes a bottleneck: adding an ecosystem, or changing a generation option for one consumer, is a change to a repository several teams share. - Its release cadence couples teams. A consumer that needs a fix waits on the contract repository's release. - The owning team must carry expertise in ecosystems it does not otherwise use. ## Consumer-side generation **What it buys** - The contract repository publishes exactly one thing: the contract. Its scope stays small and its expertise stays narrow. - Each team controls generation options, output layout and the timing of a generator upgrade. - Adding a new ecosystem costs the contract repository nothing. **What it costs** - Generator versions and options diverge, so two consumers can behave differently while claiming the same contract version — the hardest class of inconsistency to diagnose. - Every consuming team needs the toolchain in its build, which is a per-team cost paid repeatedly. - There is no single registry of who is on which contract version; you must ask. - A generator upgrade's consequences are discovered N times independently. ## How to decide | Factor | Leans central publication | Leans consumer-side generation | |---|---|---| | Number of ecosystems | few and stable | many, or changing often | | Required uniformity of semantics | high (money, regulated records) | moderate | | Platform capacity | a team exists to own pipelines | no such team | | Contract change rate | low to moderate | high, with impatient consumers | | Auditability requirement | must answer "who is on what" from records | can answer by asking | | Consumer maturity | uneven across teams | uniformly strong build practice | A defensible answer in an interview names the hybrid, because most organisations land there: **publish for the two or three ecosystems that carry most consumers, and support consumer-side generation for the long tail**, while keeping generation reproducible and the generator version pinned in both paths. The properties worth refusing to trade away are the same in either model — the contract is published as a versioned artefact in its own right, every stub carries the contract and generator versions it was built from, and generation is reproducible from those two inputs alone. ## The failure mode of each, stated plainly Central publication fails as a **queue**: the contract team becomes the constraint, consumers route around it by generating locally anyway, and now you have both models with none of the guarantees of either. Consumer-side generation fails as **divergence**: an incident where one consumer's behaviour differs from another's and the first hour goes to establishing which generator built which service. An interviewer at this level is listening for whether you can state the failure mode of the option you chose, and what you would watch to see it arriving — queue time on contract releases in the first case, a census of generator versions across consumers in the second.

  • Which properties should hold in either model?
    Three. The contract is published as a versioned, immutable artefact of its own, independent of any stub. Every stub records the contract version and generator version it was built from. Generation is reproducible from those two inputs, so anyone can rebuild a stub and get the same bytes. Those are what make either model auditable; the distribution choice sits on top.
  • How would you notice centrally published stubs becoming a bottleneck?
    Watch the time from a merged contract change to an available artefact per ecosystem, and the number of consumers building stubs locally despite the published ones. Rising queue time with local generation appearing is the signature: teams have started routing around the pipeline, so you now carry the cost of central publication without its uniformity guarantee.
  • Does publishing stubs centrally mean a consumer cannot pin an older contract version?
    No — pinning is the normal case and is easier here, since published artefacts are immutable and versioned. What central publication constrains is the generator version and the generation options, not which contract version a consumer chooses to depend on.

saying these in an interview costs you the question

  • Presents one model as correct without naming its failure mode
  • Ignores the per-ecosystem pipeline cost of central publication
  • Assumes identical contract versions imply identical generated semantics
  • Forgets to publish the contract itself as a versioned artefact
  • Treats generator upgrades as invisible maintenance in either model