A customer writes to support: the discount code worked in the iPhone app at ten in the evening, on its last day, but the web shop refused it at the same moment. Support asks the web team, who say the code expires at the end of its last day in UTC, fixed in August. The iOS team says the code expires at midnight, as it always has. Both teams are right about their own app, and nobody wrote down that the two differ.
FACET keeps a short, checkable description of each feature, called a record, next to your code and tells you when code and description 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 one record describes discount codes for both apps, says where they behave differently, and marks the iOS behaviour as a 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. facet lint then checks that each app the record names really has code for the feature. The FACET feature behind it is VariantA variant is an independently deployable place where a feature can exist or not, such as a web app and an iOS app. One record then has its own lifecycle state per variant.In the glossary: one record, its own LifecycleThe lifecycle is a record's state: planned (not implemented yet), active (implemented, an anchor is required), deprecated (being phased out) or sunset (removed).In the glossary per app, such as active or planned, and 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 that apply to only one of them.
The commands below use a small example shop written in TypeScript, set up as in “One answer instead of three”. Its repository also holds an iPhone app in ios/. In your own project, use the folders of your clients, or of an old system and its rewrite.
Step 1Find the difference in the code
Put the two places next to each other. The web shop:
grep -n -A2 'expiresOn}T23' src/checkout/discount.ts
grep -n -A2 'expiresOn}T23' src/checkout/discount.ts20: return now.getTime() > Date.parse(`${code.expiresOn}T23:59:59.999Z`);21-}22-
The iPhone app:
grep -n 'midnight\|timeZone\|endOfLastDay' ios/Shop/Checkout/DiscountCode.swift
grep -n 'midnight\|timeZone\|endOfLastDay' ios/Shop/Checkout/DiscountCode.swift18: // The last day ends at midnight on the phone's own clock.21: formatter.timeZone = .current23: let endOfLastDay = Calendar.current.date(byAdding: .day, value: 1, to: lastDay) else { throw RedeemError.expired }24: if now >= endOfLastDay { throw RedeemError.expired }
The web shop ends the last day at 23:59:59 UTC. The app ends it at midnight in the phone's time zone. For a customer in New York that is four or five hours later. Same feature, same intent, different rule.
Step 2Tell FACET which folder is which app
Save this as docs/facets/variants.yaml:
schema_version: "0.1"variants: web: paths: ["src/**"] description: The web shop and its API. ios: paths: ["ios/**"] description: The iPhone app.
Each variant is a place where a feature can exist or not exist. paths decides which files belong to it. Code that several apps share goes under a shared: block with its own paths; the example has none.
Run the check:
npx facet lint
Nothing changes yet: 0 error(s). The record still has a single lifecycle, and the only 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 sits in src/.
Step 3Describe the feature once, for both apps
A second record for the iPhone app would copy the intent and every scenario, and the two copies would drift apart. Instead, change the existing record docs/facets/features/checkout/discounts/redeem-code.yaml:
schema_version: "0.1"id: checkout/discounts/redeem-codevariants: web: lifecycle: active ios: lifecycle: activeintent: summary: A customer enters a discount code in the cart and gets its discount, or a reason why not.contract: scenarios: - id: expired-code-is-refused variants: [web] statement: | Given the code SPRING5, whose last day is 2026-05-31 When a customer redeems it after 23:59:59 UTC on that day Then the shop refuses it with E2002 and the cart keeps its price - id: last-day-ends-in-utc variants: [web] statement: | Given a code whose last day is today When a customer redeems it at 23:30 UTC, in any time zone Then the discount is applied - id: last-day-ends-at-local-midnight variants: [ios] statement: | Given a code whose last day is 2026-05-31 When a customer in New York redeems it in the app at 22:00 local time on that day Then the app applies the discount, although it is already 02:00 UTC on 2026-06-01 deviation: reason: ios/Shop/Checkout/DiscountCode.swift ends the last day at midnight in the phone's time zone; the web shop ends it at 23:59:59 UTC since the fix of 2026-08. confirmed_by: code-review tracked_as: null - id: minimum-order-value variants: [web] statement: | Given a code with a minimum order value When the cart subtotal is below that value Then the shop refuses the code with E2003 - id: one-code-per-order variants: [web] statement: | Given a cart that already has a code When the customer enters a second code Then the shop refuses it with E2004verification: unit_tests: - id: tests/discount.test.ts proves: [expired-code-is-refused, last-day-ends-in-utc, minimum-order-value, one-code-per-order]lineage: owner: team: checkout created_at: "2026-11-22"
variantsreplaceslifecycle: the feature isactivein both apps. A record has one or the other, never both. An app that does not have the feature is left out.variants: [web]on a scenario says it holds only in the web shop. A scenario without it holds in every app the feature exists in.deviationmarks the iOS scenario as behaviour nobody intends, with the evidence. The scenario says what the app does today, so nobody mistakes it for the rule. Settracked_asto the ticket once one exists.
Step 4Let the check ask for the iOS code
npx facet lint


The anchor in src/ proves the web shop has the feature. It proves nothing about the app. Add the anchor to the Swift file, directly above the function's comment in ios/Shop/Checkout/DiscountCode.swift:
// @facet: checkout/discounts/redeem-code// @facet-role: primary/// Checks a code in the app before the cart is sent, so the customer sees the/// discount without a round trip.func redeemDiscountCode(_ input: String, from codes: [DiscountCode], now: Date = Date()) throws -> DiscountCode {
The comment is the same in every language that uses //. FACET knows which app the file belongs to from its path, not from the comment.
Step 5Check both apps and commit
npx facet lint


The warning about last-day-ends-at-local-midnight is honest: no test checks the iOS behaviour yet. Commit the map, the record and the anchor:
git add docs/facets/variants.yaml docs/facets/features/checkout/discounts/redeem-code.yaml ios/Shop/Checkout/DiscountCode.swiftgit commit -m "Describe discount codes on web and iOS, with the iOS difference"
The next time support asks why the app accepted a code, the answer is one scenario in one file. When the iOS team aligns the app with the web shop, they remove variants: [web] from last-day-ends-in-utc and delete the deviation scenario in the same pull request.
Step 6If the check says something else
anchored file belongs to no declared variant and no shared path: a new folder carries an anchor, for example a new Android app. Add it tovariants.yamlas its own variant, or undershared:if several apps use it.record declares variant "iphone", which is not in the variant map: the record uses a name thatvariants.yamldoes not declare. Use the names from the map exactly.is anchored on variant "ios", which the record does not declare: an app has code for the feature, but the record does not list that app. Add it undervariantswith its lifecycle.(document root): 'not' failed: the record has bothlifecycleandvariants. Delete the top-levellifecycleline.is active on "ios" with no anchor there: no file under aniospath carries the anchor. Put it in code only that app has, or set that variant toplannedwhile the app does not have the feature yet.
For more on teams that build the same product in different places, read Your release was green. Ours is broken now.