# The kitchen sink One shop. One `db/schema.lite`. As much of FrontierJS as a single coherent app can carry — and a place to break things without a real domain fighting back. This is deliberately **not** a gallery of feature demos. The framework's claim is one mental model across three realms, and a tabbed showcase of disconnected snippets would prove the opposite. Every feature here is earned by the domain: orders have states, so there is a state machine; customers have staff-only notes, so there is field-level access; refunds need authority, so there is a gate ladder. ```bash fli dev # both, after checking the ports and the database ``` Open and sign in from the header. `bun run stop` when you are done; `bun run dev` is the same pair without the preflights, and the two halves still run on their own: ```bash bun run api # terminal 1 — Junction + Litestone on :8110 # DEVTOOLS=1 bun run api adds the console on :5503 bun run web # terminal 2 — Sierra + Vite on :8010 ``` **Two processes — both are required.** Vite serves the UI and proxies `/api` and `/ws` to the API; with the API down every one of those is a 502 and the app says so rather than rendering plausible empty tables. **Start them through `fli dev` when you can.** A port that is already answering is the failure worth catching: `bun --watch` prints EADDRINUSE and keeps watching, so the process stays alive and nothing that waits on it ever returns, and a stale API still holds the old database open — including one `bun run reset` has already deleted, so the reset appears to do nothing while every request is answered by the ghost. | | | | --- | --- | | `fli dev` | both realms, after the port and database preflights | | `bun run dev` | both realms, no preflight | | `bun run stop` | stop whichever of them is running | | `bun run api` | the API realm | | `bun run web` | the UI realm | | `bun run verify` | drive the app in headless Chrome and assert what happened (both servers must be up) | | `bun run verify:ui` | drive the kit's behavioral components — tabs, menus, a dialog, a palette — the preferences that change what every other screen shows, and a refund a person performs by clicking — 35 assertions | | `bun run verify:live` | open a watcher tab that never acts, change rows from outside it, and assert what crossed the socket — 14 assertions | | `bun run verify:jobs` | the deferred-work realm over HTTP, no browser — the courier booked off the request, the outbox, the abandoned-basket sweep, and the RETENTION pass the schema declares, which plants a row older than the window and asks whether the job can tell it from today's — 12 assertions | | `bun run verify:notify` | the outbound boundary: mail at a real server, and who can see what — 9 assertions | | `bun run verify:stripe` | a REAL vendor over the same boundary: form-encoded bodies, a bearer key, a pinned API version and Stripe's own `t=…,v1=…` webhook scheme. Its negative control is the feature — the same connector against a target with `encoding` removed is refused by name. Plus a decline that is a domain answer rather than a retry, a major-unit amount refused before anything reaches the wire, and a webhook secret ROTATION, where two signatures ride one header. Starts and stops its own API and Stripe on the test ports — 12 assertions | | `bun run verify:pay` | money: an HMAC-signed conduit target the provider VERIFIES, and a signed webhook that drives the order state machine with no session anywhere — plus the four separate ways a webhook is refused, and the fifth that is a redelivery. Then refunds: the only @gate(5) move in the app, a partial that must not move the order, an idempotency key on the one call where a retry costs real money, and the shelf coming back out of the ledger — 22 assertions | | `bun run verify:catalog` | the catalog end to end — a `File` column's bytes reaching an `` that decoded, the variant grid, an aggregated price range, and **a photograph somebody uploads**: chosen in a real file input, submitted through a form that names no field, refused for a stranger and refused for a type `@accept` does not admit — 35 assertions. Starts and stops both servers itself | | `bun run verify:money` | **what a basket costs, and why**: `subtotal − discount + shipping + tax = total`, with one owner for the arithmetic and every screen rendering it rather than re-deriving it. Its two headline assertions exist nowhere else — a code that takes a basket back under the free-delivery threshold, so applying a discount puts the shipping charge back; and two checkouts of a one-redemption code in flight at once. It also proves the five `@@check` constraints — the rules that read a SECOND column of the same row, so none of them can be a field validator — at both boundaries, which for three of the five is only the Data one, because the columns they read are `@system` and no request can reach them. **Since the ledger landed it reads the same sale twice** — off the order and out of the BOOKS — and the five accounts reconstruct the receipt rather than merely agreeing with it, because the identity rearranged IS debits equal credits. Two refusals nowhere else: staff may read the books and neither restate nor delete an entry — 108 assertions. Starts and stops both servers itself | | `bun run verify:cart` | a **stranger** fills a basket and buys: a token-scoped row policy, a claim on a caller with no session, a per-call header crossing a WebSocket frame, and the itemized order the basket becomes — 32 assertions. Starts and stops both servers itself | | `bun run dev:widgets` | the widgets surface live, on :8210 — how a widget is WRITTEN | | `bun run build:widgets` | → `widgets/dist/embeds/BuyButton.js`, one self-contained script | | `bun run serve:widgets` | the widget ORIGIN on :8310, with the CORS and cache headers it deploys with | | `bun run verify:widget` | the buy button on a page the shop does not own: four origins, a real preflight, shadow isolation against hostile CSS, the one-time code that hands a basket between them, and what a shopper is told when they arrive with a spent one — 37 assertions. Starts and stops everything itself | | `bun run verify:account` | a SHOPPER, not staff: the ledger answering 401 to a stranger and one order to the person who asks for all of them, a sign-in island on the static storefront, a session on the storefront's own origin, and a brand-new account that can see none of the shop — 18 assertions. Needs `build:site` | | `bun run build:extension` | → `extension/dist/chrome/` — a manifest, a service worker, a popup and a content script | | `bun run verify:extension` | the shop in a browser toolbar: an extension loaded into a throwaway profile, a harbor holding the only connection, a Mesa popup signing in through `/auth/login`, an order paid elsewhere arriving with nothing refreshing, a transition run from the toolbar, and a content script on the shop's own prerendered storefront — 13 assertions. Needs `build:site`; starts everything else itself | | `bun run verify:tenants` | many shops: a second one created for the run, its own catalog, its own staff, and a token from one that is not a session at the other, and the fourth thing a shop is — its own NAME and from-address, which are not rows — 26 assertions. The API must be up | | `bun run verify:stock` | the shelf: a hold moving AVAILABLE and not ON HAND, a second shopper refused by name, a shopper's own hold not counting against them, an expiry that is in the read rather than in a cron, and the ledger every stock write is paired with — 41 assertions. Starts and stops both servers itself | | `bun run build:site` | the PUBLIC site: prerender `site/src/routes/` to `site/dist/` | | `bun run verify:site` | serve that build and prove its islands come alive in a real browser, including a price MOVED in the database after the build and a search that asks the shop — 39 assertions | | `bun run email:preview` | render the transactional emails to files you can open | | `bun run build` | production build to `web/dist/client/` | | `bun run verify:build` | build, then drive **the built app** with the same 37 assertions (needs `bun run api`) | | `bun run preview` | serve `web/dist/client/` on :8011 with `/api` `/ws` proxied — `vite preview` carries no proxy | | `bun run db:seed` | put the demo catalog, customers, orders and users in. **Run this first** | | `bun run reset` | delete the database and seed it again | **Seeding is a step, not something a boot does for you.** It used to be awaited at module scope in `app.ts`, which meant every import of the app wrote to the database — including `junction app`, whose job is to describe the app without acting on it. A second run adds only what is missing, so repeating it is safe, and an API started against an empty database says so rather than serving empty lists that read as a broken query. Sign in as **`sam@shop.test`** (level 4) or **`alex@shop.test`** (level 5), both with password `correct-horse-battery`. **`kit@shop.test`** is the same password at level 7 — the platform's operator, and the only person who may reset somebody's lost second factor. The buttons in the header do it for you. --- ## Layout The standard FrontierJS layout at full size — one directory per realm, the schema above both of its consumers, configuration in `config/`: ``` example/ ├── db/ ← Data realm — Litestone │ ├── schema.lite ← the seed. Read by api/ and by web/'s build │ └── seed.ts ← `bun run db:seed`. A script; nothing imports it ├── api/ ← API realm — Junction + auth │ ├── index.ts ← the entry. Starts the app and assembles nothing │ ├── config/ ← junction.config.js, incl. where the services are │ └── src/ │ ├── app.ts ← the construction site. Exported unstarted │ ├── domain/shop/ │ │ ├── inventory.ts ← the ONE owner of the shelf: holds, availability, the ledger │ │ ├── cart-grant.ts ← a header → a grant row → the basket's own id │ │ └── settle.ts ← the ONE owner of "this order has been paid for" │ ├── domain/billing/ ← the renewal and dunning jobs, a subscription's transitions │ ├── domain/payroll/ ← pay runs, arrears, banded rates, effective dating │ ├── core/ │ │ ├── db.ts ← the client, the gate plugin, autoMigrate │ │ └── gate.ts ← the ONE place a session becomes a number │ ├── providers/psp/ │ │ ├── index.ts ← the payment provider: the target out, the verifier in │ │ └── sink.ts ← that provider, standing in for a real one. :8112 │ └── services/ └── web/ ← UI realm — Sierra + Mesa. The Vite root ├── index.html ├── config/ ← vite.config.js lives HERE, not at the root ├── public/ ├── test/ │ └── verify.mjs ← drives a real browser; see "Verified" below └── src/ ├── main.js App.mesa datetime.js displays.js ├── components/ ← every .mesa file that is not a route or resource ├── lib/ ← every module that is not a route, resource or component ├── stores/ ← state only the browser has: the basket, the preferences ├── resources/ ← .mesa files (invariant 18): data in ``` Three things here are not true anywhere else in this app: - **CORS is real.** The SPA is served by Vite, which proxies `/api`, so every call it makes is same-origin and no preflight ever happens. A widget is a guest: it needs `x-cart-token` past a preflight, which works because the app declares that header once under `http.callHeaders` and both the CORS allow-list and the WebSocket frame merge read it. And `origins: ['*']` is the right answer, because **CORS is not an access control** — it stops a page reading a response the browser attached credentials to, and this app attaches none. - **One call, not three.** An embed's budget is round trips on a page it does not own, so `product-variants.embed` answers the product, the price, the photograph and what may be SOLD (available, not on hand) in one request, addressed by the SKU a merchant pastes. - **The basket cannot be shared, so it is handed over.** `localStorage` is per origin: a basket started on somebody's blog is invisible to the shop's own site and no amount of wanting changes that. Sending the shopper to checkout is handing a capability across an origin — and the token must not be what travels, because a URL goes into history, into `Referer` and into every log on the way. So `carts.handoff` mints a **one-time code**, the link carries it in the FRAGMENT (never sent to a server), and `carts.redeem` exchanges it for the token and clears it in the same transaction that read it. Worth one basket, for two minutes, once. `bun run verify:widget` stands up four origins — the API, the shop, the widget origin and a host page — and proves all of it in a real browser, including that the host page's `button { background: red !important }` does not reach in and that the widget's own font does not come from the host's ``. **An abandoned checkout is a schedule in the schema.** `Order` declares `@@commitment(abandon, on: createdAt + 14d)`, and junction's `commitments()` sweeps every shop once a minute and abandons each order still `pending` at its due time. No job file names it. A cron you can only observe through `nextRuns()` is a schedule, not a behavior, so `verify:jobs` ages one order in the shop's file and runs the sweep now: ```bash curl -X POST localhost:8110/api/jobs/run/commitment-sweep -d '{}' ``` That route did not exist until this app needed it. --- ## Verified **Every drive checks the process it is about to test is the one this tree describes.** `web/test/lib/preflight.mjs` asks reachability and freshness together — `/health`'s `uptime` against the newest mtime under `api/` and `db/` — because a port that answers is not evidence the right process is on it: `bun run api` spawns a child, so killing the wrapper leaves the app holding its ports and the next start exits `EADDRINUSE` into a log nobody reads. A drive run against that process reports on code that is not in the tree, and it is wrong in both directions (`FJS-740`). Nothing in this file is asserted from reading the source. `bun run verify` drives the app in headless Chrome — navigating, signing in, typing into fields and leaving them, filling the form, submitting, deleting, signing out — and asserts what a real browser ended up showing. The sibling drives add the rest — the kit's behavioral components, declared value sets, real-time from a second client, deferred work, the outbound boundary, the prerendered public site, the catalog's photographs, a stranger buying something, the shelf that stranger bought it off, a buy button on a page the shop does not own, and the recurring half: a cycle renewing on a moved clock, a change mid-cycle asserted as sums, and a provider's answer driving a state machine. Last run: ``` all 56 assertions passed (dev AND the production build, 0 console errors) all 35 assertions passed bun run verify:ui all 14 assertions passed bun run verify:values all 17 assertions passed bun run verify:live all 12 assertions passed bun run verify:jobs all 9 assertions passed bun run verify:notify all 22 assertions passed bun run verify:pay all 45 assertions passed bun run verify:site (the built static site, and the price list) 35 passed, 0 failed bun run verify:catalog 32 passed, 0 failed bun run verify:cart 108 passed, 0 failed bun run verify:money (the discount, the delivery, the tax and the books) 41 passed, 0 failed bun run verify:stock 37 passed, 0 failed bun run verify:widget 26 passed, 0 failed bun run verify:tenants (a second shop, its own file) 13 passed, 0 failed bun run verify:extension (loaded into a browser profile) 27 passed, 0 failed bun run verify:account (a shopper, on the static site) 38 passed, 0 failed bun run verify:revisions (taking a row back, and two people editing one) all 23 assertions passed bun run verify:billing (a cycle crossed on a clock the drive stands at) all 21 assertions passed bun run verify:proration (a change mid-cycle, asserted as sums) all 58 assertions passed bun run verify:employment (what was true on the 12th, and the bands) all 41 assertions passed bun run verify:payrun (one period, everybody, two documents) all 33 assertions passed bun run verify:batch (interrupted, resumed, nobody paid twice) all 56 assertions passed bun run verify:retro (a backdated raise, three closed periods) all 62 assertions passed bun run verify:payroll (the console — one audience, in a browser) all 28 assertions passed bun run verify:collect (one call out, one signed event back — and the whole cycle through the queue) 904 assertions, twenty-six drives, against one FLEET — twenty-five of them against the flagship shop, and one that makes a second. ``` `verify:site` is the one with no application in it. `site/dist/catalog/ index.html` is a file with the whole catalog already in it and one module script; the drive asserts that a crawler sees every product, that nothing gated is in the file, that typing in the search box filters rows **after** the island mounts, that the below-the-fold island's chunk is not fetched until it is scrolled to, and that it then asks the running API what can be sold today. `verify:live` is the one that watches a client which did **not** make the change — a signed-out tab on `/orders/`, while node changes rows over HTTP: ``` watcher.sawCreate appeared: true ← no reload, no session watcher.sawPay status: paid ← a custom ACTION, the case that was broken watcher.movesRegraded ship refund cancel ← the record was replaced, not a cell patched watcher.sawDelete left: true watcher.events orders created · orders pay · orders removed ``` Including, in the browser: ``` customers.headersAnon ['Name', 'Email'] ← notes absent customers.headersAdmin ['Name', 'Email', 'Notes'] ← same page, same code form.controls reference:text status:select total:number note:text customer:select form.statusOptions pending paid shipped refunded cancelled form.customerOptions Acme Corp, Globex signedIn.badge alex@shop.test · level 5 ← graded by the server stored.record { reference: 'ORD-CDP-1', total: 42.5, note: null, status: 'pending' } live.noErrorWhileTyping { reference: null, customer: null } ← 2 chars, untouched elsewhere live.errorOnLeave reference must be at least 3 characters ← and ONLY reference live.clearsOnInput null ← on the keystroke that fixes it live.untypedStaysQuiet null ← tabbed through, never typed live.submitRevealsRelation Please select a customer from the list ← @required, from db/schema.lite moves.anon ORD-1001 pending pay(disabled) cancel(disabled) ← a move is an update moves.user ORD-1002 paid ship refund(disabled) cancel ← @gate(5) on refund alone moves.admin ORD-1002 paid ship refund cancel moves.admin ORD-1003 shipped — ← nothing leaves shipped moves.afterPay before ['pay','cancel'] → after ['ship','refund','cancel'] moves.illegalStatus { status: 409, name: 'Conflict' } ← was 500 ``` and the API, for the same field and the same rule: ``` POST /api/orders {"reference":"ORD-M1"} → 400 customerId: Please select a customer from the list POST /api/orders {"reference":"X",…} → 400 reference: A reference is 3 to 20 characters, like ORD-1001 POST /api/orders {"total":-1,…} → 400 total: total must be at least 0 ← nothing authored ``` That last line is three separate claims at once: `@upper` uppercased the reference, `coerce` made `42.5` a number rather than the string the DOM handed back, and the blank note stored as NULL. And over HTTP, against the same running pair: ``` GET /api/orders → 200 3 seeded rows, public read POST /api/orders (anon) → 401 @@gate wants 4 to create POST /api/orders (user) → 201 DELETE /api/orders/1 (user) → 403 "Order.delete" requires level 5, user has level 4 DELETE /api/orders/1 (admin) → 200 POST {"status":"gold"} → 400 status must be one of: pending, paid, … POST {"reference":"X"} → 400 reference must be at least 3 characters POST {"price":-5} → 400 price must be at least 0 GET /api/customers (anon) → no `notes` key at all GET /api/customers (admin) → "notes":"Net-30. Always disputes shipping." PATCH /api/orders/3 shipped → pending → 500 Cannot transition order.status from 'shipped' to 'pending' ``` `bun run build` emits the bundle and the post-build artifacts (robots.txt, sitemap.xml with 5 URLs) to `web/dist/client/`, resolving the schema at `../db/schema.lite`. The one line above that is **wrong and known to be wrong** is the last: an illegal state transition is a client error and comes back 500. See below. --- ## Found by building this An example is only worth having if it can fail. Nine things this one settled, eight the day it grew a job queue, an outbound boundary and a watcher tab that never acts, five more the day its markup moved onto `@frontierjs/ui`, eight more from the screens built to use the components a render test cannot reach, four the day its order form was rewritten onto `
`, three the day its public page grew an island, one the day somebody clicked ⌘K, and one the day a job was asked who had sent it, one the day a custom method was asked what it accepts, three the day one column grew a declared list, eight the day it grew a shop — a catalog with photographs, a basket a stranger can buy from, and a currency toggle — three the day the shop grew a warehouse, four the day one of its buttons moved onto somebody else's page, two the day its orders learned to say what was in them and its storefront learned to ask, three the day the shop moved into a browser toolbar, three the day its customers got accounts, two the day its orders learned to carry a discount, a delivery charge and a tax, three the day a row could be taken back, three the day what the schema DECLARES was asked whether it holds, three the day somebody uploaded a photograph and then opened the storefront in dev, three more the day somebody looked at the storefront and said it was ugly, and three the day it turned out you could not buy anything on it, three the day its checkout link grew a credential of its own, three the day its money stopped being a Float, seven the day it learned to bill somebody every month — on a schedule, at a price with a lifetime, on three surfaces — two the day it learned to STOP billing them, two the day it learned to charge somebody who is not there, two the day a bank asked to speak to them, six the day somebody asked whether it had user management, and three the day a shop tried to declare one of its own columns through the API instead of the client, and three the day its invoice ledger stopped naming its own columns, and one the day it declared its first conditional required: | | | | --- | --- | | **Password reset minted a token and emailed nobody, and the route said 200 either way.** | `requestPasswordReset` mints; SENDING is `onPasswordResetRequested`, a callback the app supplies — and this app supplied none, with a comment in `api/src/app.ts` saying so. The failure is silent by construction: the endpoint answers 200 whatever happens, deliberately, so as never to reveal whether an address is registered. So *reset works* and *reset mints a row nobody will ever see* are the same response, and nothing short of reading the outbox can tell them apart. Measured: `POST /api/auth/password-reset/request` → 200, outbox empty. Found because a created account can only get in through a link, and the link had nowhere to go | | **`ctx.result` inside a hook is the ENVELOPE, so an `afterCommit` read `undefined` and the invitation silently never went out.** | A service result is `{ kind, object, data }` until the transport unwraps it, so `ctx.result.email` is `undefined` — no error, no warning, and the account is made either way. The hook fired, the mailer was configured, the reset route worked when called directly, and the invitation still never arrived. `resultData()` is exported for exactly this and the fix is one call; what cost the time is that every part in isolation was correct | | **The one column separating a shopper from a member of staff was written by the seed and by no person, ever.** | `db/user.lite` declared `isStaff Boolean @allow(write, auth().isAdmin)` the day tenancy landed, and across five surfaces, twenty-six drives and 904 assertions nothing had a screen for it. The app demonstrated the gate ladder on every page and administered it nowhere: the only thing that changed who you were was two hardcoded palette entries. What the missing screen was hiding is that auth ships `User` reading at USER(4) with NO read policy — right for an app whose only people are its staff, and wrong here, because a shopper who registers on the public storefront grades USER(4) too. **The shipped default handed every shopper the entire roster**, and no test could see it because nothing ever asked (`FJS-624`) | | **Every tool that reads `db/schema.lite` reads a different schema from the one the app runs.** | An app appends a package's fragments in memory — `authSchemaFragments()` — so a file scan cannot see `User`, `Session` or `Credential`. Two readers, failing opposite ways, which is why neither had been noticed. `fli check` reported a correct `users.service.ts` as naming a model that does not exist, which is a rule people baseline. `fli admin:generate` generated a whole admin panel with **no Users screen in it**, silently, which is the one screen an admin panel is most about. Fixed for both with one owner; the half that cannot take that fix is the sharper one — `db/access.snapshot.md`, the artifact whose whole job is *who may do what*, does not mention the identity model at all (`FJS-625`, `FJS-626`) | | **Nothing in this repo had ever executed a generator, and opening its output found three defects in ninety minutes.** | A service name is a FILENAME — junction autoloads the directory, so the app serves `shipping-methods` and the generator derived `shippingMethods`: five screens calling a URL that does not exist, each a 404 with the page rendering normally around it. A model with no service was generated and then warned about, which is the wrong half. And filtering those out of the targets was not enough — the nav is built from the full list on purpose, so the panel went on advertising two sections that had never been written. All three are invisible to reading and obvious to one page load (`FJS-372`, `FJS-625`) | | **A job dispatched under an id built from a row id could never run again for that row — and the row id is reused.** | The collection was `dispatch(collect, …, { id: 'collect:' + invoiceId })`. A dispatch id is the jobs table's PRIMARY KEY, so a taken one is a no-op **for all time**: once `collect:56` exists, invoice 56 can never be presented again — and a soft decline leaves an invoice issued and owed, so *presented again* is the ordinary case. `unique` is the option that means what the line meant, because it frees itself at a terminal state. The key cannot be built from a row id under either, since SQLite reuses a rowid once the row is gone, and that is what made it visible: the drive's own cleanup deletes invoices, so the fourth run collided with the first — three green runs, then two assertions failing with the renewal visibly having worked (`FJS-609`) | | **A migration that BLOCKED a column reported success, and the app then ran against a table missing a column its own seed declares.** | SQLite cannot add a `NOT NULL` column with no default, so `autoMigrate` refused — and answered `{ state: 'migrated' }` with the reason inside a SQL comment nobody reads. Every write of that column was then stripped by mass-assignment protection, so a required field read back `undefined` and the failure surfaced three steps downstream as a 500 about a collision. Deliberately blocked whether or not the table holds rows: migrating an empty one and refusing a populated one migrates on every developer's machine and blocks at the deploy (`FJS-604`) | | **…and `@default(now())` on a new column threw `near "(": syntax error` out of `autoMigrate` at boot, naming nothing.** | `ALTER TABLE ADD COLUMN` takes a CONSTANT default and `CREATE TABLE` takes an expression, so the same declaration is fine on a fresh database and fatal on a populated one — which is every developer's machine against every deployed one. An expression default forces a table rebuild now, and *is this an expression* is a literal test rather than a `startsWith('(')` guess, because SQLite's own pristine read drops the parentheses (`FJS-605`) | | **A `slot="actions"` child wrapped in `{#if}` turned the generated field list off, and the form rendered with no controls in it.** | `` decides whether to generate from `auto ?? !$slots.default`, and `slot=` is an attribute on an ELEMENT — so an `{#if}` around one puts the BLOCK in the default slot and the caller is read as having written the form themselves. Every field disappears, the form still submits, and the page looks like a component that failed to load. Found on the one screen where a person types money, where it failed as *no `[name="price"]`* rather than as anything about forms (`FJS-607`) | | **Two job handlers declared `{ attempts: n }`, which is not an option.** | The name is `maxAttempts`. Nothing rejects an unknown key at runtime, so the retry ladder those files meant to set was never set and the default quietly stood in for it. Invisible to every test — the default is what they were asking for — and visible to `fli typecheck` the moment the app was typechecked at all, which is the argument for running it on an APP and not only on the packages | | **A derived column moves when a CHILD row is written, and nothing announces the parent.** | `Plan.currentPrice` is `@from(PlanVersion, max: price, where: effectiveTo == null)`. Repricing writes a `PlanVersion`, so the `Plan` row does not move, so no broadcast names it — and the tile on the screen that just made the change held the old price. A live store cannot help: there is no event. The screen that made the change is the one place that knows to re-read, which is what `record().refresh()` is for | | **A `Map` that is mutated is not a `Map` that was assigned.** | `held.set(id, n)` on a rendered Map left every subscriber count reading 0 — which looks exactly like a plan nobody is subscribed to, on the screen whose whole point is that repricing moves nobody. The same shape as `arr.push()`, on a count rather than on a list, and the fix is the one this repo already uses in its islands: count into a local and assign once | | **`@@unique` takes no predicate, so the constraint effective dating is built on cannot be declared.** | A plan's price is a row with a window, and *at most one OPEN window per plan* is the rule that makes `currentPrice` answerable at all. `@@index([cols], where: …)` exists and emits a partial index; `@@unique` has no counterpart. The near miss is what makes it worth filing rather than working around: `@@unique([planId, effectiveTo])` is refused BY NAME because two NULLs never compare equal, and the refusal offers `nullsDistinct: true` — which is the correct declaration of the exact opposite, *these rows are deliberately unconstrained*. SQLite writes `CREATE UNIQUE INDEX … WHERE` and litestone already parsed, validated and emitted that predicate for the non-unique case. **Fixed** (`FJS-603`) — `@@unique([planId], where: effectiveTo == null)`, one word over two node kinds, and this app declares three of them. It did not reach every instance at once: `PaymentMethod.isDefault` wants the same declaration and collided with the model's own `@@index([customerId])`, because an index was named for its columns alone. Fixed too (`FJS-614`) — a partial unique takes `uniq__`, so the lookup and the constraint are two names over one column list, and this app now declares four | | **A price typed into a generated form was stored at a hundredth of itself, and every screen agreed.** | `@money(USD)` stores CENTS, so `Order.total` reaches the browser as an integer and the control table gave it what it is: a number spinner stepping by one. Staff raising a telephone order for forty-two dollars would have charged forty-two cents, with the list, the receipt and the payment provider all consistent about it. The fix is the extension point the docs already described — `registerControl` off `x-money`, `registerFormControl` onto the kit's `Input`, with the conversion in `props` — and writing it turned up why nobody had: `x-money` and `x-scale` were not carried onto a field rule, so the only way to resolve that control was a column name ending in `Cents` (`FJS-582`) | | **The shop in the toolbar printed a pound sign on a dollar amount, at a hundredth of it, for its whole life.** | `extension/src/dock/App.mesa` had ``£${(pennies / 100).toFixed(2)}`` against a column holding dollars, so an $87.00 order read `£0.87`. `verify:extension` watches the order arrive, move and leave the queue and never reads the figure — 13/13 throughout. Two hand-rolled conversions in one line, which is what one owner of *cents → what a person reads* removes (`FJS-581`) | | **A `@@check` that says what it means could not be written until the columns were integers.** | The receipt identity was `abs(total - (subtotal - discount + shipping + tax)) < 0.005` — a tolerance, because two binary floats need one to agree that they are equal, and `verify:money` asserted that a thousandth of drift was ACCEPTED. In cents it is `total = subtotal - discount + shipping + tax` and the nearest wrong answer, one cent, is refused like any other. The drive asserts that instead | | **A checkout link carried an order id and nothing else, and the leak was the DIFFERENCE between two answers.** | A hosted checkout is reached with no session, so `payments.start` had nobody to grade and read the order as the shop for whatever id arrived. The money could never be redirected and the row could never be read — but the reply carried the order's total and the refusal named its status, so counting from 1 was an existence, amount and status oracle over the whole ledger. Neither half is visible from either code path alone: the read is correct, the answer is correct, and the pair is the hole (`FJS-497`) | | **`@guarded` plus a generated `@default()` made a model uncreatable by anybody but the system.** | The obvious fix above was a stored credential column, exactly like `Cart.handoffCode`. It could not be created: litestone merged its own `@default(nanoid())` into the payload and then graded the guard against what it merged, so the column refused its own stamp — a server-minted secret nobody may read or write, which is precisely what the pairing is for, could not be expressed at all, `@secret` included. The refusal now grades what the CALLER sent, and the pairing works. The checkout code is still derived rather than stored, for its own reasons — a link that must keep working while the order is payable has no lifecycle to hold, and no column means nothing to strip from a read (`FJS-565`, `FJS-497`) | | **An app migrated its live database to a schema file edited after it booted, on an ordinary `curl`.** | The API had been up since the previous day and correctly answered 405 to a method added that morning — it holds the old code. The tenant database had the morning's column, added minutes earlier by a health check. `openShop()` runs `autoMigrate` on first open per process, and the schema it migrates TO is read later than the schema the app is serving, so the database moves ahead of the code with nothing saying so and the next boot inherits a migration it never ran (`FJS-566`) | | **An island in a LAYOUT hangs `vite build`, with no error and no output.** | The storefront's header wanted a basket count, which on a prerendered page can only be an island. `_module.mesa` is composed into every route, and a marker inside it stops the prerender dead on the first one: the client bundle finishes and prints its chunk table, then nothing, forever. It reads as a compiler that crashed rather than a build that will never end, and every diagnosis costs a full build cycle. The same island on a page is fine (`FJS-549`) | | **…and so does importing `@frontierjs/sierra/resource` into a prerendered island.** | Narrowed from the above by stubbing one import at a time. That module is the SPA's client singleton — the obvious thing to reach for when three islands need to share one client, and nothing says no. The basket store takes its client now rather than importing one, which is what lets the same 390 lines run behind the console and behind the storefront instead of being copied (`FJS-550`) | | **A drive's own regex replaced every letter `s` with a space, and it looked exactly like a rendering bug.** | A CDP probe is carried to the browser inside a template literal, and `\s` is not an escape JavaScript knows — so `.replace(/\s+/g, ' ')` arrives as `.replace(/s+/g, ' ')`. `Basket (1 item)` came back as `Ba ket (1 item)`, survived removing the em dash and collapsing the markup to a single expression, and was two edits away from being filed against Mesa | | **The public storefront shipped with no gap, no border and no radius, and every drive was green.** | Thirteen of the fifteen tokens its style blocks read were invented — a Tailwind-shaped `--space-4`, `--radius`, `--border` against the ladder `@frontierjs/css` actually ships (`--space-2xl`, `--card-radius`, `--rule`). An undefined custom property is invalid at computed-value time, so the browser drops the **declaration** rather than the value: no gap, not a wrong gap. Nothing says so — the stylesheet is in the bundle and every selector matches — and `verify:site` passed 39/39 throughout, because a drive asserts what a page SAYS. A second layer under it was invented class names: `.list` for `.rows divided`, `.input` for `.field`, `.button` for `.btn`. `fli check`'s `css-token-undefined` is the guard, reading the token table off whatever CSS the app installs (`FJS-545`) | | **Three drives passed exactly once per database, and two of them had never been run twice.** | `verify:ui` and `verify:pay` create orders under fixed `@unique` references and clean up with a DELETE — which SOFT-deletes, and a soft-deleted row keeps its `@unique` values, so the reference is still held by a row no ordinary read returns. The second run's create is a 409 nobody checks, an undefined order id, and thirty assertions against `/orders/undefined`. `FJS-530` had already found and fixed this exact shape in `verify:notify`; nothing was looking for the others (`FJS-546`) | | **Two drives asserted a fact in the tick a different fact arrived.** | `verify:site` waited for the catalog island by element identity, and the node is captured after the navigation returns — so on a warm cache the island has already mounted and the comparison can never become true. One run in six. `verify:ui` read the refund's event trail in the render the refunded amount appeared, which is one render early, and failed saying the refund wrote half of what it writes. Both only reachable once the drives could run twice (`FJS-547`) | | **`vite dev` on the storefront ran the build-time loader in the browser.** | A `render: static` route's `load()` runs in Node and reads this app's own database, and the client route table kept its import — so the dev router called it, got `Module "fs" has been externalized`, swallowed the throw into a warning, and drew an empty shop. Vite followed the same import into the browser graph and reported eight un-analyzable dynamic imports out of the migration engine and the service autoloader, which reads as a broken install. The rule is per ROUTE now: a prerendered route's loader is build-time by definition and is not shipped to the browser at all, and Sierra says once per route why the page is empty. `FJS-543`. | | **No browser had ever uploaded a file to a Junction app.** | A multipart boundary is case-sensitive — RFC 2046 says so about this parameter by name — and `parseBody` lowercased the whole `content-type` header before reading it out. Chrome sends `----WebKitFormBoundary…`; lowercased it matches nothing in the body, so no part is found, `ctx.data` is empty, and the create answers **`Request body is required` about a request that plainly has one**. What kept it alive is that everything else generates a lowercase-hex boundary: curl, undici, and Bun's own `new Request({ body: form })` — which is what junction's existing multipart test used, and that test asserted the body's TYPE and never its contents. It took a real file input in a real browser, which is a thing only this drive does. `FJS-542`. | | **`get(id)` ran no plugin read hook, so a photograph was a URL in a list and a JSON blob on the page beside it.** | `findFirst`, `findMany` and `findManyAndCount` all end with `plugins.afterRead(...)`; `findUnique` did not, on either path — while calling `beforeRead`, which made the gap look like plugin support rather than half of it. `ExternalRefPlugin` resolves a stored file reference into a public URL in that hook, so the same column answered two different shapes depending on which read asked, and an edit form was handed the storage handle instead of the photograph. A `@@trail` model was also recording reads through every path but the most common one. Neither is visible unless the two reads are compared, which is what the drive does now. `FJS-541`. | | **The retention sweep killed the API on the first night it actually removed a row — and the request that caused it answered 201.** | `database audit { … retention 90d }` was a declaration nothing had ever run twice until it got a job (`FJS-521`), and a job nothing had ever driven until this drive. A jsonl table keeps a companion index of byte offsets; a compaction rewrites the file, so it deletes that index and says it is *rebuilt lazily*. Nothing rebuilt it — the driver caches the handle for ever, and SQLite marks a connection readonly once its file is unlinked underneath, so the next append threw out of the audit path. **Which is fire-and-forget and deferred a tick**, so the write that triggered it had already answered: `POST /api/discounts` → 201, then no API, and nothing in the request log. Not a race but a CLOCK — the sweep removes nothing until the oldest row is past the window, so it fires the first night a deployment's retention period elapses, at 04:00. Latent for as long as the driver has had an index, and invisible to litestone's own jsonl retention test, which compacts and never writes again. `FJS-540`. | | **The seeder could not reseed once a drive had removed a row, and the error named a table.** | Six models declare `@@softDelete`, so a drive deleting a seeded order over HTTP HIDES it — and a hidden row keeps its `@unique` values by design, because `restore()` has to be able to bring it back. `db/seed.ts` looked for its rows with a plain `findFirst`, which excludes them, so it neither found `ORD-1001` nor might create one: `SoftDeletedUniqueError: Order: a soft-deleted row still holds reference = "ORD-1001"`, which is the Data boundary being exactly right and is not a sentence anybody running `bun run db:seed` can act on. **`bun run reset` is what hid it** — it deletes the database file first, so the path everybody runs by hand never saw it, while the five drives that reseed as their own first act all failed at once, under a node stack trace naming the seeder rather than the constraint. A regression from the `@@softDelete` work against the property this app had already paid for once: the seeder restores what a drive consumes (`FJS-080`). Once removal is something the schema can express, RESTORING the row is what that property means. `FJS-538`. | | **A retention probe measured the check that skips the sweep.** | `database audit { … retention 90d }` is a policy the seed states, and proving it needed a row older than the window — so the drive appended one and the job reported `done` having removed nothing. Not a bug: `compactJsonl` reads the FIRST line and returns if it is inside the window, because an append-only log is oldest-first and this runs on every boot over a file that grows for the life of the deployment. The right optimization, and it makes the obvious test measure the pre-check rather than the sweep — a job that looks broken while being correct, which is the same silence `FJS-521` was filed about wearing the other face. A log that has genuinely aged has its old rows at the TOP, which is what the drive plants now. | | **A soft-deleted parent's children had two fates and needed three.** | `@@softDelete(cascade)` stamps them, `@hardDelete` on the relation field destroys them, and *the child stays live on purpose* could be produced but not SAID — it is what a plain `@@softDelete` already does, and the parser warns about it, because forgetting the cascade and meaning it look identical from the outside. `Order.customerId` is `onDelete: Cascade`, so removing a customer DESTROYED every order they had ever placed; cascading the soft delete instead would only have hidden them. An order is what the revenue is made of, so neither is what a shop means, and the only way to stop the warning was to stop being right. `orders Order[] @keep` says it now, the warning names all three ways out, and it covers the whole subtree beneath that child — if the order survives, its lines survive with it. | | **`` was a 403 about a column that is not on the screen.** | `@system`, `@generated`, `@from` and `@version` reach the browser as `readOnly`, and two things read that already: a generated form does not offer the control, and `make()` does not seed the value. Neither covers an EDIT form — it is handed a row the SERVER wrote, carrying every column the caller could read, and writes the whole record back. The Data boundary then refuses `@system` **by name**, correctly, so the customers screen showed *`Customer.userId` is @system…* under a form whose every visible control had been filled in legitimately. Unreachable from the create path, which is why nothing here had seen it: a create starts from `make()`, and `make()` skips exactly these columns. `stripReadOnly` runs first in the resource's write pipeline now — with a KEEP list rather than a blanket drop, because `@version` is marked read-only and is the one the server requires back. `FJS-526`. | | **`bun run reset` reseeded the shop and left the job queue.** | The queue is a separate SQLite file, so a `courier-book` row enqueued by an earlier run survived the reseed that deleted the staff member it recorded, and retried forever with *no such principal*. Caravan's `unique` is a lock on work still owed and a `pending` row holds it, so the key was held against every later `ship` of that order and the dispatch became a silent no-op. What that reads as is the reason it is worth writing down: `verify:jobs` fails `job.wroteTracking` while `job.record` **passes**, because the row the drive finds is the previous run's — evidence for a framework bug that is not there. `FJS-527`. | | **A `readOnly` column with a default made its model uncreatable through any service.** | Junction's validator fills a default in for any absent key, and it carried one for every property — including the ones Litestone marks `readOnly` because the caller may not write them. So `POST /api/discounts` with a perfectly ordinary body reached the Data boundary carrying `redemptions`, which is `@system` and therefore refused BY NAME: **403 quoting a column the request did not contain**, with nothing the caller could do about it — naming it in `system: [...]` is the opposite of what was meant, and there was nothing to omit. The sibling rule had been fixed and stopped one line short: `mode === 'update'` already dropped every default, for the same reason a patch must not invent values. Found by declaring one column on one new model. `FJS-504`. | | **A `$:` watch on a value with no depth switched that variable's reactivity off, silently — twice, in this app.** | The discount box's Apply button is disabled while the code box is empty. It stayed disabled: the box filled, `bind:value` wrote through, and nothing re-rendered. The bare `$: a` form is the DEEP-watch opt-in — it changes the variable's accessor from a signal read to a proxy read — and a primitive cannot be proxied, so every read compiled to a plain local and the render effect subscribed to nothing. Value right, screen stale, no error and nothing in the console. A sweep of all 313 components found the second one in this same app and it was live: `$: (handoffError)` on the basket screen meant a spent or expired checkout link showed a shopper **nothing at all** — the API refusal had a drive and the screen had none. Refused at compile now, because the declaration is redundant rather than merely broken: a local `let` is already a signal. `FJS-505`. | | **The shop's customers and orders were public.** | `GET /api/orders` with no token answered every order; `GET /api/customers` answered every name and email. Six models carried `@@gate(0.4.4.5)` and four of them are catalog, where read-at-0 is correct and load-bearing — the prerendered storefront reads them with no session. `Customer`, `Order` and `OrderLine` are not catalog. `api/src/core/gate.ts` documented the opposite in its own ladder. Found looking for somewhere to put a buyer's identity, which is the thing that makes *whose order is this* answerable at all. `FJS-498`. | | **No browser on another origin could sign in to a Junction app.** | `cors()` patches the router's registration methods, so it reaches routes registered after it — and every raw route a plugin mounts is registered during `configure()`, long before the `cors` start phase. Services were fine; `/auth/login` was not. The preflight answers 204, the POST answers 200 and creates the session, and the browser discards the response: what the page sees is `Failed to fetch`. It could only be found by putting a sign-in on an origin that is not the API's, which is what a static storefront is. `FJS-496`. | | **A row policy cannot reach through a relation.** | `@@allow(read, order.userId == auth().id)` is a parse error at the dot. There is no other form — a policy compares columns on its own model, and `@from` crosses a relation only to aggregate. So *the lines of my own orders* is a denormalized column, and this shop now carries the same id in three places, written in one transaction because nothing in the schema can keep them together. Stated in `OrderLine`'s own header rather than hidden. `FJS-499`. | | **jetty could not talk to a real Junction, and had not been able to since it was written.** | `default-adapter.js` says *placeholder*, and the gap is wider than that word: its envelope is `{ kind: 'call' }` and Junction's is `service_call`. So every jetty app in existence spoke to a mock. Writing `extension/` is what made that a blocker rather than a note — the harbor here holds the only connection in the surface, and there was nothing for it to hold. The adapter is over `@frontierjs/junction/client`, which is the client Sierra already uses, so the transport, the token and the reconnect have one implementation. Two spellings had to be settled: jetty's `url` field is written `wss://` and the client wants an http origin (handed one over unchanged it builds `wsss://` and a socket that never opens), and SIGN-IN is not a service — Junction has no service called `auth`, so the pseudo-service the placeholder invented would shadow the methods of an app that has one. `FJS-279`. | | **A row that has left the list stays in it.** | The dock loads `{ status: 'paid' }` and ships one; the order comes back on the channel as `orders ship` and jetty's store upserts whatever arrives, so the despatch queue keeps showing an order that has gone. Sierra had exactly this and answered it with `matchesQuery` — `true` upsert, `false` REMOVE, `null` *undecidable, reload*, because there is no other event for a row leaving a filter — and that function is pure but lives where jetty may not import it. Same shape as `FJS-059`, whose answer was to move the pure halves into `@frontierjs/toolbelt`. The dock filters on render and says so. `FJS-493`. | | **`fli make:extension` gave every app port 8400.** | Which is dev/ext/project-0 — right for a fresh scaffold and wrong for every app that has a number, so two apps' extensions could not have their dev servers up at once and jetty's reload push would reach whichever bound first. `make:widget` beside it already derived the port; this one had the literal. Found because `example` is project 1 and its extension should be 8410. | | **`++n` on a reactive variable evaluated to `undefined`, and `n++` compiled to `++n`.** | The storefront's search box guards against an out-of-order answer the ordinary way: `const mine = ++inflight`, and drop the response if a newer keystroke has taken a newer ticket. `mine` was `undefined`, so `mine !== inflight` was true for every response and **every answer the shop gave was discarded** — an empty list, no error, and a box that reads as a server that is not replying. Two defects in one emit: `$$runtime.set` returned nothing, so the whole expression was undefined (`n += 1` and `--n` too), and prefix and postfix compiled to the same string, so `n++` would have answered the new value once it answered one at all. It survived because all five tests on the pair asserted the emitted TEXT, and both things wrong with it are only visible in a value. `FJS-485`. | | **A Vite hash with a hyphen in it was not recognized as a hash.** | `site/serve.js` decides which files may be cached forever with a pattern over the name. The hash is base64url and may contain `-`, and one that does — `island-CatalogList-C_TQPJ-f.js`, which this site's own build emitted — was read as unhashed and served `must-revalidate`. Quiet, and on the files a site is mostly made of. It only surfaced because `verify:site` grades the FIRST `.js` in the assets directory and directory order changes when the files do, so which asset it checked was luck. The same pattern was written twice, in the site server and the widget server, and both copies had it. `FJS-484`. | | **A caller with no session could not hold a claim, so a guest basket had nowhere to live.** | `Cart` says who owns it in the schema — `@@allow(read, token == auth().cartToken)` — and `createApp({ principal })` was the only seam that could put `cartToken` on a principal, and it ran only for a caller who already had one. Extending it was easy; the part worth knowing is what it must NOT do. `sessionGateLevel` grades any object handed to it, and a claims-only principal sets no standing flag while leaving `verifiedAt`/`activatedAt` **undefined — silence, not null** — so promoting the claim to a session would have graded every anonymous shopper USER(4), in every app that adopted a resolver. `ctx.user` stays null and the claims reach the Data client alone. | | **An app could not send a caller-varied header over the socket at all.** | The workspace had needed one since it was written, so it was built as one hardcoded name on each side, with a comment explaining that merging a client-supplied header map wholesale would let a frame carry its own `Authorization`. Right reasoning, one name too narrow: it is an allow-list. A basket token is the second case and it is the harder one, because it comes into existence *after* the socket is already up. Undeclared, the shop worked until the WebSocket connected and then every basket call answered 404 — with nothing anywhere reporting it, because a policy filters rather than refuses. `FJS-428`. | | **A CRUD method written on a base service was dropped on the floor.** | `carts` writes its own `get`, which assembles a basket with its lines, its count and its total. The service builder spread the generated row-by-id over it and never called the author's, so the basket screen rendered empty against a 200. Not an error at any layer — a plausible wrong SHAPE, which is the worst way for it to fail. `FJS-426`. | | **A minified widget lost every stylesheet it imported.** | `widgetCssPlugin` deletes Vite's emitted `style.css` and swaps its text into the entry at a placeholder, so a widget ships as one file. The matcher knew `"` and `'` — its own comment names the class — and **esbuild writes backticks when it minifies**, which is the default and what every app ships. The asset was deleted, the swap missed, and the widget carried the literal `@sierra-widget-css` into its shadow root as its stylesheet. Only IMPORTED css was hit, because a widget's own scoped `