Versioned parameters
Read and edit a release's parameter file: entries, versions that apply by date, enactments, citations and what loadParams rejects.
Every rate, limit, threshold and law-dependent date lives in a JSON file per release, packages/t2/src/rules/params/<id>.json, with its source and its statute citation. Each release file has 169 parameters. The code only declares which parameters exist and what kind each is. Changing a value is a data change; adding a parameter is a code change, because a form has to read it.
The file
ParamFile in src/rules/params.ts:
A plain entry
"FED.sbd": {
"kind": "rate",
"value": "19/100",
"label": "19%",
"src": "t2",
"cite": "T2 page 4, line 430: \"× 19%\".",
"law": "ITA 125(1.1)(c)"
}kindis one ofrate,money,int,factor,dateormoneyByYear, and must matchSCHEMA.- A rate is
"num/den"with a printedlabel. Money is a dollar string such as"500000"or"1234.56". srcis a key intosources.citeis where CRA prints the value.lawis the provision that sets it. Parts are separated by;. Federal parts look likeITA 125(1.1)(c)orITR 2900(4); provincial parts use a code fromPROVINCIAL_STATUTES(ON TA,AB CTA,QC TA, …).enacted(optional) records the Act that set a value that doesn't change inside any year of the release.
lawLinks(law) splits a citation into parts with the URL of each section on laws-lois (federal) or the statute (provincial). It throws on anything that isn't a recognisable citation.
A versioned entry
When the law changed a value, the entry has versions instead of value. The return's period picks one. Each ParamVersion has:
For example, FED.taxableCapitalDivisor has two versions: $11,250 for tax years beginning before 2022-04-07, and $90,000 from then (S.C. 2022, c. 19, s. 21, assent 2022-12-15). Use describeApplies(applies) to print a range in words, such as "tax years beginning on or after 2022-04-07".
Mid-year changes
Provincial rates and limits that change on a calendar date use on: "days" with prorate: "taxYearDays". A rate read through PROV.x is day-weighted over the year's actual days. A form that must compute each period separately reads paramSegments(group, key), as Schedule 5 and the Ontario OSBD lines do.
What loadParams rejects
loadParams(file) validates the whole file before anything is evaluated, and checkVersions validates each set of versions. A release won't load if:
- a parameter is missing, extra or of the wrong kind, a value doesn't parse, a rate has no label, or a source key is unknown;
- a citation is empty or
lawLinkscan't read it; - two versions overlap (unless one
supersedesthe other or is a proposal), or versions mix differentonvalues; - a days-based version doesn't say
prorate: "taxYearDays"; - a version has no
meta, ormeta.approvallacksauthority,byorat; - an enacted version has no
enacted.byandurl, or a proposed one has noproposal; - a
testOnlyversion is in a shipping release.
An enacted version may omit assent in exactly two forms. Pre-existing law: enacted.by reads "<section> as it read from YYYY-MM-DD to YYYY-MM-DD" and url is that point-in-time consolidation (…-YYYYMMDD.html). Unread Act: enacted.by says UNVERIFIED. An assent date is never inferred.
How forms read parameters
Forms import the group views from src/rules/params.ts (FED, ON, PROV, SRED, MISC, CCA_RATES, …) and read FED.sbd as a plain property. The view resolves against the release being evaluated, because evaluate runs inside withParams(registry.params). Two releases can share form code with different values, and Evaluation.rules.params records which version each evaluation used.
Change a value
pnpm --filter @workspace/t2 release new 2026.1 2026.2 # copies params/2026.1.json to params/2026.2.json
# edit values, cite and law in params/2026.2.json; register the release in src/repo.ts as the command prints
pnpm --filter @workspace/t2 release diff 2026.1 2026.2 # markdown: parameter changes + sample-return deltas
pnpm --filter @workspace/t2 testNever edit a published release's file: its hash is frozen. While a release is still a draft you may edit it in place, but the same rules apply: write a change in law as a new version, and keep the old one, because returns for earlier periods still need it. The full reference is docs/rules-engine.md.
Related
- Rules releasesLearn what a rules release contains, how a return picks one, how releases are published and frozen, and how returns move between them.
- Taking in ITA amendmentsDetect a change to the Income Tax Act, a provincial statute or a CRA form, and ship it safely as a new rules release.
- The tax engineUnderstand how a return is evaluated: the registry, the dependency graph, value types, parameters and diagnostics.