Skip to content

Change Risk

llms.txt lists every page for an agent
Optional: hand this page to your coding agentThe steps work by hand too.
Show the whole prompt
Read https://intentius.io/chant/guide/change-risk/.
Add a `ci.risk` block to this repository's `chant.workspace.json` with the threshold and questions I give, and a `holds.risk` to the stage gates I name in `.chant/pipeline.ts`.
Open a pull request. Explain in its description that the settings take effect once the pull request is merged, because they are read at base.
Never deploy to a real cloud account or shared environment, approve (`chant approve`), merge, or cut a release (`chant release cut --yes`).

chant rates each change set from 0 to 1 and keeps the reasons behind the number. Over a threshold the rating asks for more approvals. A plan then needs an approval of its own digest, and a stage’s wave waits for a second approver or a named role when its gate asks for one. Under the threshold every gate works as before, and a low rating passes no gate.

Set ci.risk in the workspace declaration and merge it. pr-plan and pr-apply read it at base, so a pull request cannot raise its own threshold or drop a question.

{
"ci": {
"risk": {
"approveAbove": 0.6,
"questions": [
{ "id": "customer-data", "text": "Does this change touch where customer data is stored?", "weight": 0.8, "approveAbove": 0.5 },
{ "id": "network", "text": "Does it change who can reach the service over the network?", "weight": 0.5 }
]
}
}
}

The plan note shows the record with each reason that counted. The report carries it as risk, and the change set stored for the gate keeps it. A gate policy reads it as input.risk.

A plan over approveAbove needs an approval of its own digest, as a policy hold asks. So does a plan with an answer over its question’s approveAbove. A green commit’s plan then does not apply under the approvals of the merges it carries.

Each reason gives a value from 0 to 1 and has a weight. The score is the chance that at least one reason bites:

score = 1 - (1 - weight1 * value1) * (1 - weight2 * value2) * ...

A reason only raises the score. The same facts always give the same score, and the weights are fixed in CHANGE_RISK_WEIGHTS (packages/core/src/change-risk.ts).

A reason that counts things turns its count into a value as 1 - 2^(-n / half): half things give 0.5, and more approach 1.

ReasonWhat it countsWeighthalf
destroysresources the change set deletes0.71
replacementsresources it replaces0.51
disruption.destroyreplacements that delete the old resource first, so a window has nothing there0.61
disruption.rollingupdates that roll a workload0.22
disruption.unknownupdates and replacements no lexicon could classify0.32
sql.destructivedestructive sql migration classes, from the new migration files and the engine’s own classes0.71
membersmembers changed beyond the first0.22
environmentsenvironments reached beyond the first0.31
dependentsgraph nodes that read a changed node and are not changed themselves0.34
reviewthe review agent’s level: low 0, medium 0.5, high 1, and 0.5 when there is no review0.5
agent.<step>the level an agent step of the stage answers in its answer’s risk: low 0, medium 0.5, high 1. Read at that stage’s gate; a step whose answer names no level adds nothing0.5
question.<id>the review’s answer to a question, from 0 to 1, and 1 when there is no answerthe question’s weight

Each lexicon’s classifier gives the disruption classes; the terraform and pulumi lexicons both classify (lifecycle). The dependents come from the member’s chant graph --format ir. A graph read that fails is logged, and then no dependents count. The review reason appears once the job has looked for the pull request’s review.

The level is low under 0.3, medium from 0.3 and high from 0.6.

A change set that deletes one resource and replaces one, in one member and one environment, scores 1 - (1 - 0.35) * (1 - 0.25), which is 0.5125, medium.

The review agent reads ci.risk.questions from chant.workspace.json on the base branch and asks the model each one. The model ends with one answer <id>: <number> line per question, and the note’s result line records the answers. Each answer then counts as a reason with its question’s weight.

An answer reads unknown if the model gave none or its command failed, or if the job found no review on the pull request. It also reads unknown for every question once the change set is larger than the prompt carries, since the model never saw all of it.

unknown counts as 1 and is above every question’s approveAbove. The other reasons count as usual.

A stage’s gate takes holds.risk in .chant/pipeline.ts, as an Op waves spec does. The wave rates its runs’ change sets together with the engine’s destructive classes and the stage’s environment. Its decision keeps the record, and each run’s policy reads it as input.risk.

{
name: "prod",
waves: [{ name: "prod", runs: [{ target: "prod-eu" }, { target: "prod-us" }] }],
gate: {
policy: "on-destructive",
holds: { risk: { approveAbove: 0.4, quorum: [{ count: 2 }, { count: 1, roles: ["sre"] }] } },
},
}

Over approveAbove the wave waits for an approval whatever its gate’s policy says. Its gate also takes the quorum rules on top of its own. Here that means two approvers, one of whom holds sre in .chant/trust.json at base. Under the threshold the wave’s gate stays the stage’s. A run whose plan gave no change set holds the wave too. The holds are read at base with the rest of the wave’s rules. The pull request’s review answers the questions, so holds.risk takes only approveAbove and quorum.

A later stage takes a release through chant components promote --release, which plans nothing, so the rating travels with the release:

  1. Each wave of the first stage that rates its change set under holds.risk writes the record beside its release records, in _releases/risk/<commit>.jsonl on chant/lifecycle. Set holds.risk on the first stage, or in the pipeline’s defaults, for the merge to rate the change.
  2. chant release cut reads the records of the commit it cuts, keeps the newest per wave, and writes them on the cut line as the release’s risk. With several waves, the release’s rating is 1 - (1 - s1) * (1 - s2) * ..., so each wave can only raise it.
  3. At promote, each gate whose stage sets holds.risk reads that rating under its own approveAbove. Over it, the gate takes the stage’s quorum rules on top of its own, and a gate whose policy is never waits for an approval. The promote prints the stage’s reading either way.
{ name: "dev", waves: [/* ... */], gate: { policy: "never", holds: { risk: {} } } },
{ name: "staging", waves: [/* ... */], gate: { policy: "never", holds: { risk: { approveAbove: 0.6 } } } },
{ name: "prod", waves: [/* ... */], gate: { holds: { risk: { approveAbove: 0.3, quorum: [{ count: 2, roles: ["sre"] }] } } } },

Here dev rates each merge and asks for nothing more, staging waits for one approval above 0.6, and prod takes two sre approvers above 0.3. A gate that read a rating counts people’s approvals only, and a permit that reads it counts only from a person .chant/trust.json at base proves.

The first stage must rate with holds.risk, of its own or from defaults, for a release to carry a rating. A pipeline where a later stage reads holds.risk and the first stage rates nothing does not fold: the build names the later stage. A release with no record has no rating, and each stage’s gate works as before. That covers a release cut before chant carried the rating.

The pull request’s plan note shows how each later stage reads the plan’s rating: the stage, its approveAbove, and what the gate asks for there. chant workspace status shows each cut’s rating, and --json gives it as risk on each entry of releaseCuts, with each later stage’s reading under stages.

An Op’s gate step with approval.risk gets the record as context.changeRisk when its plan names a step that returned a change set (terraformPlan, composeChangeSet), the same step context.plan comes from. Cedar has no decimals, so the score is percent, from 0 to 100:

gate("ship", {
plan: plan.out.planDigest,
approval: {
policy: gatePolicy("ship", {
lowRisk: new Policy({ effect: "permit", action: { eq: PASS_GATE_ACTION }, when: ["context.changeRisk.percent < 30"] }),
}),
mode: "enforce",
risk: { approveAbove: 0.6, quorum: [{ count: 2 }] },
},
});

context.changeRisk holds percent, level, over and reasons, the ids of the reasons that counted. The cedar lexicon’s gateCedarSchema() declares it, so validateGatePolicy checks a rule against it.

A permit that reads the rating passes the gate only from a human whose approval .chant/trust.json at base proves with a seal. An agent’s permit counts for nothing, whatever the policy says. chant treats a gate as reading the rating if it sets approval.risk or its policy names changeRisk. Above approveAbove, the Op gate’s rules grow by the quorum list.

The rating never lets a plan apply with nobody approving it. Every risk setting refuses allow_unattended and approveBelow, and the rating never reaches a product’s unattended-apply setting. A low rating passes no gate: under the threshold a plan needs its approval as before, and a release promoted into a later stage needs its stage gate’s approval as before.

Without any of ci.risk, holds.risk and approval.risk, chant makes no record.

chant