Review the whole surface
By the end of this lesson you will have a cockpit section in REVIEW.md with the four lenses applied to the composed product, a second reader's findings in notes/review-cockpit.md, and every finding you call real turned into a failing test before its fix — the cross-user request and the hidden panel among them.
Build a Screener's four lenses, run on a composed product. Composition creates failures that no individual tool had, so this is a genuinely different pass rather than a repeat.
Leaks — now with someone else's data
The proxy was reviewed twice already. What is new is the store.
Every read and write is scoped by the authenticated user. The vulnerability is one missing WHERE user_id = ?, and it will not show up in any manual test, because you are always testing as yourself.
So test it as the other person: create two users, save a layout as one, request it as the other, and assert 404 rather than 403. A 403 confirms the document exists, which is itself a leak.
Also check what the layout export contains. It is a file people will share, and if config ever held anything sensitive it is now in someone's downloads folder.
Cost — the union, priced
One number: dataNeeds unioned across visible panels, priced by the table from Build Your First Tool.
Then the questions that only apply to a cockpit: does switching layouts refetch symbols already cached? Does selecting a symbol trigger a refresh of panels that did not change? Does a hidden or removed panel still contribute to dataNeeds? That last one is the classic — a panel scrolled out of view quietly costing calls every refresh.
Measure the union against the meter. If they disagree, something is fetching outside the data layer, and that is the architecture breaking.
Lies — one clock, one label
All of Build a Screener's lenses still apply to every numeric column. What composition adds is time.
The header must show the oldest timestamp across panels, not the newest and not the fetch time. Each panel shows its own age. And a stale panel says so rather than looking identical to a fresh one — a cockpit where you cannot tell which parts are current is a cockpit that will eventually mislead you at the worst moment.
Failure — one panel, not the page
From the previous unit: five states per panel, five error kinds, an error boundary each. Verify by breaking things deliberately rather than by reading the code.
New here: what happens when the store is unreachable? The cockpit should still render from whatever it has and say the layout could not be saved. A dashboard that shows nothing because a save failed has confused two concerns.
The licence line, again, because a dashboard invites it
Same terms: personal use. A cockpit is the most shareable-looking thing in this track — it is one screen, it looks like a product, and the temptation to put it behind a public URL for friends is real.
A tool you run for yourself is personal use. A hosted dashboard serving other people from your key is a different conversation, and the licence page in this lesson's sources is where it starts.
Try it now
Run all four lenses and write the findings in REVIEW.md before reading them back. Then hand the file and your data layer to your assistant and ask which of the four lenses your checklist is weakest on. Its answer is usually right, and it is the cheapest way to improve a checklist.
The prompt
Write your own findings into REVIEW.md first. Then start a fresh session, so the reviewer did not build what it reads, and paste:
Review the dashboard as a whole against REVIEW.md: src/lib/store.ts and
its route, src/lib/market-store.ts, src/lib/panels.ts, the Cockpit and
src/lib/rules.ts. For each of the four lenses list findings with file
and line, then tell me which lens my checklist is weakest on. Check in
particular that a request for another user's layouts document answers
404 and not 403, that a panel taken out of the layout adds nothing to the union of needs, that
switching layouts refetches nothing already cached, and that the cockpit
still draws when the store cannot be reached. Fix nothing. Save the
review to notes/review-cockpit.md, and make no request.
Then, for each finding you mark real, ask for the failing test first and the fix second, a commit each. A good review names files and lines; one that says the code "looks solid" has not read it.
Check it yourself
notes/review-cockpit.mdexists, and every finding in it names a file and a line.- A test asks for the layouts document as a second user and expects 404, and it passes. Unless you added a sign-in, that second user exists only in the test.
- Ask the agent to take one panel out of the default layout, one whose symbols no other panel needs, and reload with the Network tab open: those symbols are no longer requested.
- Block the store's route in the browser's developer tools and rename a panel: the cockpit keeps drawing and says the layout could not be saved.
git log --onelineshows each real finding as a test commit followed by a fix commit.
Compare with ours
// tests/store-scope.test.ts: test as the other person, because you always test as yourself
// The route now asks as user 2. Ours returns an object for its optional sign-in;
// if your user.ts returns a plain number, mock it as () => 2.
vi.mock("@/lib/user", () => ({ currentUser: async () => ({ id: 2, assumed: false }) }));
it("does not reveal that another user's layouts exist", async () => {
putDoc(1, "layouts", { morning: DEFAULT_LAYOUT }, 0); // saved by the owner, user 1
const res = await GET(new Request("http://localhost/api/store/layouts"),
{ params: Promise.resolve({ key: "layouts" }) });
expect(res.status).toBe(404); // a 403 would confirm the document is there
});
The full state at the end of this unit is on the starter's branch ref/build-a-dashboard/u3.

Checkpoint
git status # REVIEW.md and notes/review-cockpit.md, and no .env file
git add -A
git commit -m "Review the cockpit whole: four lenses, findings filed before any fix"
The fixes are already in, each as its own pair of commits: the failing test, then the change. Then answer this lesson's questions.