Skip to main content
CFDLAcademy
All chapters

Part 2 · The core language · Chapter 9 of 28

Growth, ramps, and guards

You now hold every core tool: schedules place cash, expressions compute it, assumptions and curves feed it, entity fields carry values forward. This chapter adds no new construct. It is the idiom kit — the five patterns that recur in nearly every commercial model, each written in one line, each a claim with finance content worth naming. With these patterns, you assemble a model instead of deriving each part from scratch.

Compounding vs. stepping

Two escalation claims share the same "3% per year" label:

// Smooth: every month is 0.247% dearer than the last. CPI-style drift.
amount = 4000 * pow(1.03, time.t / 12)

// Stepped: flat for twelve months, then 3% on the anniversary. Lease-style.
amount = 4000 * pow(1.03, round_down(time.t / 12, 0))

Most contracts step — rent bumps on anniversaries, wage scales revise annually — while most macro assumptions drift. The two produce the same year-end value and different cash within every year: the smooth version front-loads part of each year's increase, a material amount across a long lease. Read the contract, then write the claim it makes. When the escalation also rounds before compounding, neither one-line form is correct; use chapter 8's field rules.

The ramp

Most activity does not go from zero to full instantly: buildings lease up, plants commission, products launch. The ramp idiom is clamp on a scaled clock:

// Linear lease-up: 0% at period 0, 100% at period 18, flat after.
amount = inputs.stabilized_rent * clamp(time.t / 18.0, 0.0, 1.0)

Read the fraction as "months elapsed over months to stabilize." Variants are one edit each:

  • A delayed ramp starts the clock later: clamp((time.t - 6) / 18.0, 0.0, 1.0) gives nothing for six months, then the increase.
  • A ramp down mirrors it: 1.0 - clamp(...) for a sunset clause or a declining subsidy.
  • An S-curve replaces the straight line when the deal requires a non-linear ramp.

The ramp multiplies a stabilized claim. That keeps two assumptions that a committee discusses separately — how much at full run-rate, and how long to get there — in two visibly separate places.

The guard: active when

A stream can carry a condition that gates its existence, period by period:

version 0.1
model "growth-guards"
time calendar monthly from 2026-01 for 36

entity asset venue : Asset.Real

assume monthly_revenue = 52000
assume breakeven = 40000

stream venue.revenue on entity asset.venue inflow currency USD {
  schedule every month from 2026-01 to 2028-12
  amount = inputs.monthly_revenue * clamp(time.t / 12.0, 0.0, 1.0)
}

stream venue.opex on entity asset.venue outflow currency USD {
  schedule every month from 2026-01 to 2028-12
  amount = 38000
}

// A percentage rent kicker that exists only above the breakeven —
// the guard carries the condition, the amount carries the economics.
// series_sum over a single period reads that period's revenue.
stream venue.percentage_rent on entity asset.venue outflow currency USD {
  schedule every month from 2026-01 to 2028-12
  active when series_sum("venue.revenue", time.t, time.t) > inputs.breakeven
  amount = (series_sum("venue.revenue", time.t, time.t) - inputs.breakeven) * 0.07
}

active when is a boolean expression; in periods where it is false the stream does not occur. You could write the same logic in the amount, as if(cond, x, 0), and the engine would produce the same cash. But the guard states something the if does not: this claim conditionally exists, versus this claim is sometimes zero. A percentage-rent kicker, a covenant-triggered fee, an incentive that switches on — these exist conditionally, and writing the condition as a guard puts it where a reviewer looks for conditions rather than inside arithmetic. The guard also reads another stream. series_sum over the single period time.t is that period's revenue. A wider window makes a rolling test: series_sum("venue.revenue", 0, time.t) is revenue to date, a cumulative trigger. In either form the kicker's trigger and the revenue it is charged on cannot diverge, because there is one revenue stream and everything reads it.

Phase gating

Chapter 2 introduced phases as named spans; the idiom is to put all date logic in them:

// The claim: management fees run during operations. No dates anywhere.
schedule every month from phase_start("operations") to phase_end("operations")

Combined with on phase_enter("…") for one-shots (the demolition cost, the refinancing fee), a well-phased model concentrates every date into the phase declarations at the top. The benefit grows with model size. When construction slips a quarter, a model with no other dates is recomputed from one edited line: the schedules reference the phases, the ramps use phase-relative clocks, and no other line states a date. The capstone's model is built this way from its first chapter, and slipping its timeline deliberately is one of that part's exercises.

Composing the kit

The idioms are designed to combine, because each occupies its own part of the stream structure from chapter 2 — schedule, guard, amount:

stream venue.stabilized_kicker on entity asset.venue inflow currency USD {
  schedule every month from phase_start("operations") to phase_end("operations")
  active when time.t >= 18
  amount = inputs.base_fee * pow(1.03, round_down(time.t / 12, 0)) * clamp((time.t - 6) / 12.0, 0.0, 1.0)
}

Phase gating in the schedule, a maturity guard, and an amount that is stepped escalation times a delayed ramp — four idioms, one stream, still readable aloud clause by clause. This composition, rather than any single pattern, is the skill the chapter teaches. The limit from chapter 5 still applies: when the amount no longer reads aloud clearly, decompose it into separate streams, a field, or a contract, not a longer line.

What can go wrong

A ramp clock in integer time. time.t / 18 and time.t / 18.0 agree here, because arithmetic is decimal throughout. Write the denominator with the decimal point anyway. A reviewer reading 18.0 can see that a fraction was intended, not integer bucketing with round_down. Write for legibility even where the engine accepts either form.

A guard that references what it gates. active when on stream X cannot read X's own series — the condition would gate its own input. The error comes from the evaluation-order rule described in the machinery chapter. Streams evaluate in dependency order, and a stream reading its own output is a cycle, which no evaluation order can satisfy. Chains are allowed to any depth (a fee may read a fee that reads revenue); only a true loop is rejected, and the diagnostic names its path. The model compiles; the engine rejects the run before any figure is published (E5035).

Stepping on the wrong anniversary. round_down(time.t / 12, 0) steps at periods 12, 24, 36 — anniversaries of the model's origin. A lease that bumps each January inside a model that starts in July steps at the wrong month. Phase-relative or date-based conditions fix it; note that "annually" always has a start date, and the model requires you to state it.

Exercises

Exercise

The percentage-rent kicker

Add the landlord's kicker: 7% of revenue above the 40,000 breakeven, only in months where revenue exceeds it.

  1. Put the condition in an active when guard.
  2. Keep the economics in the amount.
  3. Read revenue with a single-period series_sum.

Predict the guard's first true month before you run. Revenue ramps from 0 to 52,000 over twelve months, so solve 52000 × t/12 > 40000 for t.

After the run, check the series. The kicker's first nonzero month is your answer. The amount that month is 7% of the small excess, not 7% of revenue.

Loading exercise…

Then, on your own:

  1. Convert the guarded model's percentage rent from a guard to an if(…, …, 0) amount, confirm identical totals, then convert it back. Write one sentence on which version is easier to review, and why.
  2. Slip the composed example's operations phase by one quarter (edit only the phase line) and predict which streams move before running. A stream that should have moved and did not contains date logic that is not tied to the phase. Repeat this exercise on your own models.