Forms
Write or change a form definition: fields, tables, applicability, checks, references, support level and form revisions.
Every CRA, Alberta and Québec form TaxPilot knows is a FormDef object. Each release has 256 of them across 14 jurisdictions (federal, every province and territory, Alberta and Québec). The same definition drives calculation, the on-screen form, the PDF print plan, the e-file data set and the Supported forms page.
The FormDef shape
Defined in packages/t2/src/engine/defs.ts:
Fields
A FieldDef has an id (form.line, such as t2.300), form, section, line, label, type (amount, bool, text, date, number, choice) and kind (input, calc or carryforward). A calc field has deps and a calc(ctx) that returns a Value, a Cents amount or null for blank. Useful options:
formula: the text printed beside the line. Keep it in step with the calc.overridable: lets a user override the calculated value with a reason.required:trueor a function, so review lists the input as missing only where it applies.suggestandderive: a suggested or defaulted value with a note explaining where it came from.validate,choices,help,refs,drillTo,showIf,hidden,noPrint.
Inside calc, applies and checks, the Ctx gives you amt(id), val(id), bool(id), text(id), num(id), rows(tableId) and meta (the corporation, the return's period, days and daysSplit). Helpers in src/forms/helpers.ts include sumOf, least, sumColumn, need, isCcpc, ref, amt, na, blocked and unknown.
A small example
Schedule 44 (src/forms/2026/s44.ts) has one input table and no calculation. Its applicability reads two T2 questions:
applies: (c) => {
const q = c.bool("t2.163")
if (q === true) return { status: "required", reason: "T2 line 163 is Yes: …" }
if (q === false || c.bool("t2.162") === false) return { status: "not-required", reason: "T2 line 162 or 163 is No." }
return { status: "unknown", reason: "Answer T2 lines 162 and 163." }
},Note the three outcomes. An unanswered question gives unknown with the question to answer, never a guess.
Add a form
- Write the definition in
src/forms/2026/.Copy the CRA PDF's line numbers and labels exactly. Use parameters for every rate or limit, and alimitationsentry for anything you leave out. - Register it in
FORMS_2026insrc/forms/2026/index.ts.Releases build from that list.FORMS_2026_1insrc/forms/revisions/2026.tsis derived from it. - Add its sources and catalogue entry.Sources go in the release's parameter file or
src/rules/2026.ts(SRC). Rebuild the catalogue withpnpm --filter @workspace/t2 catalogueif the form is new to it. - Test it.Add engine tests for the calculation and its boundary dates. Every new form also gets a Playwright test in
apps/web/e2e(seee2e/forms.spec.tsande2e/form-cases.ts). - Re-record the hashes and generated docs.Run
pnpm --filter @workspace/t2 calc-hash, then the engine tests (which refreshsrc/catalogue/verification.json), thenpnpm --filter @workspace/t2 report.
Support levels on Supported forms
coverage() in src/coverage.ts derives each form's status from code and test evidence only. It's never set by hand. The app's Supported forms page labels them:
When CRA revises a form
If CRA moves, relabels or drops a line without changing the calculation, don't edit the base form. Write a FormRevision (src/forms/revise.ts) and build the release's forms with reviseForm. The revision maps field ids to new lines, labels, formulas, sections or columns, adds new questions in addFields, and gives the revised PDF in pdf. The revised form shares every calc function with its base by reference, so results can't change (test/form-revision.test.ts).
Saved inputs and locked versions use field ids. A renumbered CRA line is a revision's lines mapping, or a filing spec's lines mapping for the e-file line.
Related
- The tax engineUnderstand how a return is evaluated: the registry, the dependency graph, value types, parameters and diagnostics.
- Rules releasesLearn what a rules release contains, how a return picks one, how releases are published and frozen, and how returns move between them.
- TestingRun the engine, web and Playwright suites, know what each covers, and add the right tests for a change without overloading your machine.