What the route declares
Placement, delivery, cache policy and budgets are declared per route — and every one of them is checked against what the compiler inferred.
Goal
Write a declaration that contradicts what the compiler saw, and read the refusal — then write the one that agrees and see it accepted without changing a line of the fragment.
You have now declared three things without noticing: that a slot streams, where it runs, and what it may spend. A route declaration is the whole list, and its rule is simple — you may declare anything the compiler cannot infer, and nothing it can.
1 · Declare a cache class it can disprove
body: { fragment: 'today', load: … },+ cache: { class: 'public', ttl: '5m' },
The fragment reads cookie:currency, which you added two steps ago. A public entry for a page that varies per reader would put one person’s prices in another person’s cache, so the build stops:
$ npx weft build E_PRIVATE_AS_PUBLIC routes/index.data.ts declares cache.class public fragments/today reads cookie:currency a public policy on a fragment classified private would put one user of the site in another one of their caches
The message names the read that refused you rather than the rule you broke, which is the difference between a refusal you can act on and one you have to go and look up.
2 · Declare what it cannot see instead
export default defineRoute({
head: { title: 'Shop' },
cache: { ttl: '5m' }, // how long — it cannot know your data
slots: {
body: { fragment: 'today', load: … },
feed: { fragment: 'feed', stream: true, run: 'isolate' },
},
})The class stays derived and the TTL is yours, because how long a value stays true is a fact about your business and not about your code. What a route declares is the full list, each with the reason it is on the declarable side of the line.