Support asks for the third time this month. A customer entered WELCOME10 with a kettle in the cart, then added a mug, and the 10 % only came off the kettle. Is that a bug or is it intended? The ticket from last time says "known issue" and nothing else. A developer reads the code again, explains it again in the chat, and the explanation is gone by next month.
FACET keeps a short, checkable description of each feature, called a record, next to your code; a record lists the behaviour the feature promises as scenarios. By the end of this guide the known bug is written down once, at the exact behaviour it affects: what the code does, why that is not what anybody wants, how it was confirmed and which ticket tracks the fix. npx facet deviations lists every such entry for support, and the record never presents the bug as a promise.
The commands below use the example shop from “One answer instead of three”, which already has a record for discount codes. In your own project, take the known issue support asks about most.
Step 1Pin down what the code really does
Before writing anything down, confirm the behaviour with a test. It describes what happens today, not what should happen. Save this as tests/discount-added-items.test.ts:
import assert from "node:assert/strict";import { test } from "node:test";import { addItem, emptyCart } from "../src/checkout/cart.ts";import { redeemDiscountCode } from "../src/checkout/discount.ts";test("a percent code keeps the discount computed when it was entered", () => { const withKettle = redeemDiscountCode( addItem(emptyCart(), { sku: "KETTLE", unitPriceCents: 5900, quantity: 1 }), "WELCOME10", new Date("2026-10-01T12:00:00Z"), ); const withMug = addItem(withKettle, { sku: "MUG", unitPriceCents: 1290, quantity: 1 }); assert.equal(withKettle.discountCents, 590); assert.equal(withMug.discountCents, 590);});
Run it:
node --test tests/discount-added-items.test.ts


The test passes, so the customer is right: 10 % of 59.00 EUR is 5.90 EUR, and the discount stays at 5.90 EUR after a 12.90 EUR mug joins the cart. In src/checkout/discount.ts, redeemDiscountCode computes the amount once and stores it on the cart. addItem in src/checkout/cart.ts copies that amount and never computes it again.
Step 2Write the bug down next to the behaviour it affects
Open docs/facets/features/checkout/discounts/redeem-code.yaml and add a scenario at the end of contract.scenarios:
contract: scenarios: # the four scenarios already in the record stay here - id: percent-discount-ignores-items-added-later statement: | Given a cart with a 59.00 EUR kettle and the code WELCOME10 (10 %) When the customer adds a 12.90 EUR mug afterwards Then the discount stays at 5.90 EUR and does not cover the mug deviation: reason: | redeemDiscountCode computes the discount once, from the subtotal at that moment, and stores the amount on the cart. addItem copies the cart with that amount and never computes it again, so a percent code only covers the items that were in the cart when it was entered. confirmed_by: test tracked_as: SHOP-412
Then name the new test under verification.unit_tests, below the existing entry:
verification: unit_tests: - id: tests/discount.test.ts proves: [expired-code-is-refused, last-day-ends-in-utc, minimum-order-value, one-code-per-order] - id: tests/discount-added-items.test.ts proves: [percent-discount-ignores-items-added-later]
- The scenario states what the code does. Its
idnames the observed behaviour (…-ignores-items-added-later), never the expected one. Anyone who reads only the id in a list or a diff still gets the truth. deviationmarks it as unintended. Without that block the same scenario would read as a promise.reasonexplains in terms of the code why it is a bug, so the next person can check the claim instead of trusting it.confirmed_bysays how it was confirmed:test,code-revieworruntime.tracked_aspoints at the ticket where the fix is decided. Usenullwhen nothing tracks it yet.
There is no field for the behaviour the shop should have. That belongs in the ticket, or in a planned record (step 5), so nobody mistakes a wish for a promise.
Step 3Give support the list of known bugs
npx facet deviations


That is the answer to the support question, with the reason and the ticket. For a support tool or a dashboard, the same list comes as JSON with feature, scenario, file path, reason, confirmed_by and tracked_as:
npx facet deviations --json
Step 4Check that the record still passes
npx facet lint


Writing a bug down never fails the check, so nobody is tempted to leave it out to get a green build. The remaining warning is about other test files no record names yet.
Commit the record and the test together:
git add docs/facets/features/checkout/discounts/redeem-code.yaml tests/discount-added-items.test.tsgit commit -m "Write down that percent codes ignore items added later (SHOP-412)"
Step 5Once the fix is decided, let the check remind you to remove the entry
When the team decides that a percent code should cover the whole cart, write that decision as a planned record. Save this as docs/facets/features/checkout/discounts/recalculate-on-change.yaml:
schema_version: "0.1"id: checkout/discounts/recalculate-on-changelifecycle: plannedintent: summary: A percent code always covers the whole cart, also items added after the code was entered.contract: scenarios: - id: percent-code-covers-items-added-later statement: | Given a cart with a 59.00 EUR kettle and the code WELCOME10 (10 %) When the customer adds a 12.90 EUR mug afterwards Then the discount is 7.19 EUR, 10 % of the new subtotallineage: owner: team: checkout created_at: "2026-11-22"
In redeem-code.yaml, replace tracked_as: SHOP-412 with the id of that record, tracked_as: checkout/discounts/recalculate-on-change, and list the deviations again:
npx facet deviations


FACET follows a record id in tracked_as; a ticket number it leaves alone. When the fix ships and that record becomes active, npx facet lint warns: declares a deviation tracked as "checkout/discounts/recalculate-on-change", which is now active. That is the moment to delete the scenario with the deviation, so only the promise of the new record remains. Once the discount covers the mug, the test from step 1 fails as well; delete it in the same change.
Step 6If the check says something else
deviation: missing property 'reason': every DeviationA deviation marks a scenario whose current behaviour is known not to be what anybody wants, such as a confirmed bug, with the reason and how it was confirmed. The record then does not present that behaviour as a promise.In the glossary needs a reason. Write which function does what, as in step 2.deviation/confirmed_by: value must be one of 'code-review', 'test', 'runtime': use one of these three words. Who reported it (support, a customer) belongs in the ticket.contract scenario(s) with no verification prooffor the planned record: expected until the fix has a test that the record names underverification.value is not allowed in this context, with a line number: the YAML around that line is indented wrongly, usually thedeviation:line. Indent it exactly likestatement:above it.
For more on what a feature should do versus what it does, read “It’s done.” Does it do what we wanted?