ADR 0385: A portable recipe keeps its amounts and units as written, and a mix of measuring systems is a warning
- Status: Accepted
- Date: 2026-11-08
- Parent epic: #385
- Stories: #397 (task DIST5.1.2), #398
- Amends: ADR 0334
Context#
Epic #385 asks for "unit portability" in a recipe that leaves the site. ADR 0333 settled that ingredient lines travel as written, and ADR 0334 that the check reads and never rewrites. Neither said what portability means or checked units at all. A check found the following problems:
- A recipe whose lines are partly metric and partly US ("500 g flour", "1 cup milk") travels unchanged, so a cook who uses one system has to convert the rest, and nothing tells the author.
- ADR 0334 says amounts are read "with the scaler's forms", but the check had its own reader. It refused
500-1,000 gas a backwards range, missed1,000-500 g, and passed1.2.3 cupsand½½ cup, which the reader's scaler (findQuantityinweb/components/ob-quantity.js) reads as nothing and as½. - The
Recipenode, the exportedrecipe.jsonandcredit.txtnamed the site author even when the post's credit file names someone else, while theBlogPostingon the same page named the credited author. - A post whose
canonicalnames another page got a ready recipe export, Hacker News and Reddit kits and a Product Hunt launch kit. Each one carried this site's address as the original. Only the recipe package refused it.
Decision#
- Portability means the amount and the unit travel exactly as written. open.blog never converts a unit, never rounds an amount and never adds a second measure. A recipe app, a directory and a reader all get the author's own words.
- A mix of measuring systems is a warning,
mixed-unit-systems. It is reported on the first ingredient whose amount is in the other system, and the export goes ahead with nothing changed. It is reported once per recipe. A line's system comes from the unit right after its leading amount:- Metric is exactly what the scaler counts as metric (its
METRICwords:g,kg,ml,l,grams,litresand so on). - US or imperial means cups, ounces, pounds, pints, quarts, gallons and
fl. - Teaspoons and tablespoons count as neither, because cooks use them everywhere.
- A line that gives both systems, such as
12 oz / 340 gor1 cup (240 ml), counts as neither, because any cook can follow it.
- Metric is exactly what the scaler counts as metric (its
- No unknown-unit check.
2 glorpscannot be told apart from2 eggswithout a word list, and a word list would warn about ordinary ingredients. - The check reads amounts with the scaler's own grammar.
recipe_checknow copiesfindQuantity'sLEADINGpattern andparseAmount, including the order in which the pattern tries each form, digit grouping (1,000) and all fifteen fraction signs. A line the scaler reads no amount from, but which starts with a number, isunreadable-quantity. A second fraction sign right after the amount (½½) is alsounreadable-quantity, because the scaler would read only the first one. The cases intests/fixtures/recipe-quantities.jsonrun through both readers:tests/web/quantity.test.mjschecks the scaler andcrates/openblog-core/tests/recipe_quantities.rschecks the check. - Every recipe output credits the post's credited authors. The
Recipenode,recipe.jsonandcredit.txtname the authors in the post's credit file, in credit order and as theBlogPostingnames them. A post without a credit file still credits the site author.no-authornow means that neither exists. - Another canonical page blocks every path that hands out the address.
Post::canonical_elsewhereis the one check. The recipe package, which had it first, now calls it too.- The recipe export reports
canonical-elsewhereas an error, so it writes nothing. - The Hacker News, Reddit and Product Hunt kits carry a blocking
canonical-elsewherenotice and no submit link.
- The recipe export reports
- Text in a recipe section outside its list is a warning,
unlisted-text. This covers a loose paragraph under "Ingredients", for example. The page shows that text, but the recipe data cannot carry it. A photo's description (its alt text) is not counted: it describes the picture, not the recipe. - Private records and packages stay out of the published folders.
community.stateFile,syndication.stateFile,syndication.approvalFileandsyndication.pinterest.stateFileare refused when they lie inside the static, themes, web or output folder, because the next build would publish them. So is a recipe package's--out, whether written relative to the project or as a full path. Each folder is read the way the build reads it, so one configured outside the project ("static": "../shared-static") or by a full path counts too. The private.openblogfolder is never published.
Considered options#
- Convert units, or add the other system's measure. Rejected, as in ADR 0333: a conversion is an invented fact. A cup of flour has no single weight.
- Make a mix of systems an error. Rejected: many good recipes mix systems, and the author may still want the file. The warning says what a reader will meet.
- Keep the check's own amount reader and add the missing forms. Rejected: two readers that are meant to be the same will drift apart again. Shared cases that run through both catch a difference the day it appears.
Consequences#
- An exported recipe's amounts are the ones a reader of the page can scale. A recipe with
500-1,000 gcan now be exported. - Admin's preview shows the three new codes (
canonical-elsewhere,mixed-unit-systemsandunlisted-text) in plain words, like the others. - A site that had put a state file in a published folder now gets an error naming the setting, and nothing is written.