A pull request changes one comparison in the discount code: < becomes <=. The diff is one character, the tests are green, two people approve it. Nobody opens the description of the discount rules two folders away, which still says that a cart at exactly the minimum order value gets the discount. From the next release on, support answers customers with a rule the shop no longer follows.
FACET keeps a short, checkable description of each feature, called a record, next to your code, linked to it by a comment in the code, and tells you when the two DriftDrift is when code changes and the record describing it does not follow, so the two no longer match. facet drift lists the features whose anchored code changed since a chosen baseline.In the glossary apart. By the end of this guide a reviewer gets the list of documented features a branch touches with one command, and sees at a glance whether their records changed too. facet drift --baseline main names every feature whose code changed on the branch. The LintLint is FACET's check that records and code still point at each other: every record matches its schema, every anchor names an existing record, and every active record has an anchor. It runs locally and in CI on every pull request.In the glossary check that facet init added to the repository keeps failing pull requests whose records and code no longer point at each other.
The commands below use a small example shop written in TypeScript, set up as in One answer instead of three, on a local branch. On your own repository, run them on the branch of the pull request you review.
Step 1See what every pull request already checks
facet init wrote .github/workflows/facet-lint.yml. It runs on every pull request. Its trigger and its one step, with the comments left out:
on: pull_request: workflow_dispatch:# … run: | set -euo pipefail dispatcher=tools/facet-lint/facet [ -f "$dispatcher" ] || dispatcher=bin/facet sh "$dispatcher" --root "$GITHUB_WORKSPACE" lint
tools/facet-lint/facet is a small script, also written by init. It pins the FACET version that init came from (FACET_VERSION), downloads that release from GitHub, checks it against the release's checksums and runs it. Run the same command on your machine, from the project root:
sh tools/facet-lint/facet --root . lint
It ends with 1 record(s), 1 anchor(s) checked — 0 error(s), 1 warning(s) and exit code 0. This is exactly what the pull request runs, so a result you see here is the result the check reports there.
Step 2Make a change that only touches code
Create a branch and make the change from the introduction. In src/checkout/discount.ts, change the minimum-order comparison from total < code.minSubtotal to total <= code.minSubtotal:
if (code.minSubtotal !== undefined && total <= code.minSubtotal) throw new ShopError("E2003");git switch -c equal-minimum-is-refusedgit commit -am "Refuse a code when the subtotal equals the minimum"
Run the pull request check again:
sh tools/facet-lint/facet --root . lint
It still passes with 0 errors. The AnchorAn anchor is a comment in the source code, starting with @facet:, that names the record the code belongs to. FACET reads these comments to know where each feature is implemented.In the glossary is still there and the record is still valid; lint checks links, not behaviour.
Step 3List the features this branch changes
Ask which documented features had their code changed on the branch, compared with main:
npx facet drift --baseline main
Then check whether any record changed on the branch:
git diff --stat main -- docs/facets


Together, the two answers are the review comment: this branch changes how discount codes are redeemed, and docs/facets/features/checkout/discounts/redeem-code.yaml did not change. The reviewer opens that record and reads 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 minimum-order-value: "When the cart subtotal is below that value, then the shop refuses the code". The code now also refuses a subtotal equal to the minimum.
Step 4Update the record in the same pull request
If the change is intended, the author updates the scenario in redeem-code.yaml on the same branch:
- id: minimum-order-value statement: | Given a code with a minimum order value When the cart subtotal is at or below that value Then the shop refuses the code with E2003
git commit -am "Record: a subtotal equal to the minimum is refused"git diff --stat main -- docs/facets
git diff --stat main -- docs/facetsdocs/facets/features/checkout/discounts/redeem-code.yaml | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)
npx facet drift --baseline main still names the feature afterwards. Against a baseline you name, drift lists every feature whose code the branch changed, whether or not its record moved too; it does not decide whether the new wording is right. That stays the reviewer's call, now with the record and the code change side by side in the same pull request.
Step 5See what makes the pull request check fail
The check fails when records and code stop pointing at each other. A common way is a cleanup that removes "unused" comments. Delete the two // @facet: lines above redeemDiscountCode in src/checkout/discount.ts, then run the pull request check:
sh tools/facet-lint/facet --root . lint


The command exits with 1, so the workflow step fails and the pull request shows a failed FACET Lint check. Undo the experiment:
git checkout -- src/checkout/discount.ts
Step 6If the commands say something else
drift could not be determined: baseline origin/main does not resolve to a commit: the revision does not exist in this clone. Use a branch you have locally, such asmain, or fetch the target branch first.active record "…" has no @facet: anchor in source: the code that implements an active record lost its@facet:comment, or the file was deleted. Put the anchor on the code's new home, or setlifecycle: plannedif the feature is gone for now.lost a primary implementation reference: a warning that comes with the error above. It names the file that used to carry the anchor.No drift found, but you expected a feature: the changed file carries no@facet:anchor. Drift only knows features that have a record and an anchor.
For more on descriptions that fall behind the code, read The help article says 14 days. The code says 30..