Facet
DeutschInstall
Team & product

Document known bugs with FACET, so support stops asking “bug or intended?”

Confirm a known bug with a test, write it down at the ScenarioA scenario is one behaviour a feature promises, written in a record as Given/When/Then steps. Each scenario has an id that tests and other records can refer to.Read more here it affects with its reason and ticket, and give support one command that lists every known bug without the FACET recordA FACET record is a short, checkable description of one feature, kept as a YAML file next to the code. It states why the feature exists, the behaviour it promises as scenarios, and the tests that check it.In the glossary ever promising one.

  • 8 min read
  • 6 steps
  • npmVitest
  • Your coding agent

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:

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:

sh
  • node --test tests/discount-added-items.test.ts
Terminal output of node --test tests/discount-added-items.test.ts: 1 test, 1 passed, 0 failed.Terminal output of node --test tests/discount-added-items.test.ts: 1 test, 1 passed, 0 failed.
The test passes: the discount stays at 5.90 EUR after the mug is added.

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:

yaml
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:

yaml
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 id names 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.
  • deviation marks it as unintended. Without that block the same scenario would read as a promise.
  • reason explains in terms of the code why it is a bug, so the next person can check the claim instead of trusting it.
  • confirmed_by says how it was confirmed: test, code-review or runtime.
  • tracked_as points at the ticket where the fix is decided. Use null when 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

sh
  • npx facet deviations
Terminal output of npx facet deviations: checkout/discounts/redeem-code, scenario percent-discount-ignores-items-added-later, with why, confirmed: test, tracked as: SHOP-412; 1 declared deviation across 1 feature.Terminal output of npx facet deviations: checkout/discounts/redeem-code, scenario percent-discount-ignores-items-added-later, with why, confirmed: test, tracked as: SHOP-412; 1 declared deviation across 1 feature.
Each known bug with its reason, its evidence and its ticket.

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:

sh
  • npx facet deviations --json

Step 4Check that the record still passes

sh
  • npx facet lint
Terminal output of npx facet lint: 1 record and 1 anchor checked, 0 errors and 1 warning about two test files no record names, invoice.test.ts and refund.test.ts.Terminal output of npx facet lint: 1 record and 1 anchor checked, 0 errors and 1 warning about two test files no record names, invoice.test.ts and refund.test.ts.
A written-down bug does not fail the check: 0 errors.

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:

sh
  • git add docs/facets/features/checkout/discounts/redeem-code.yaml tests/discount-added-items.test.ts
  • git 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:

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:

sh
  • npx facet deviations
Terminal output of npx facet deviations: the same entry, now with tracked as: checkout/discounts/recalculate-on-change.Terminal output of npx facet deviations: the same entry, now with tracked as: checkout/discounts/recalculate-on-change.
The known bug now points at the record that will replace it.

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 proof for the planned record: expected until the fix has a test that the record names under verification.
  • value is not allowed in this context, with a line number: the YAML around that line is indented wrongly, usually the deviation: line. Indent it exactly like statement: above it.

For more on what a feature should do versus what it does, read “It’s done.” Does it do what we wanted?

Sources