# Daybreak: stale-response debugging lab

A small runnable exercise for Tutorial 7. **The starter deliberately contains a stale-response bug.** It uses deterministic fictional responses, not a model. No API key, provider, prior application, knowledge base documents, Task Board tickets or history-mining plugin are required. Node.js 22 or later is sufficient for the local server and tests; there are no package dependencies to install.

The dark Reading canvas visual direction is adapted from the supplied Daybreak design example. This is a separate teaching application, not the earlier static mockup or a production news agent.

## Get a writable local copy

Download [the complete starter ZIP](../stale-briefing-demo.zip) and extract it into a new empty folder. Preserve any existing work: do not overwrite an existing website or demo folder. The ZIP contains a `stale-briefing-demo/` directory. Alternatively, [manifest.json](./manifest.json) lists every source file with its SHA-256 for individual downloads. Relative download URLs resolve against this README's URL.

The [hosted preview](./index.html) lets you reproduce the bug immediately, but your agent must edit a downloaded local copy to fix it. Do not edit the marketing/docs server or the user's original mockup files.

From the extracted directory:

```sh
node serve.mjs
```

The server binds only to loopback, chooses a free port and prints its actual URL. Open that URL. Stop it with Ctrl-C. It serves only this demo folder and uses no remote resources or storage.

In a separate terminal, from the same directory:

```sh
node --test regression.test.mjs
```

**Expected starter result: 11 tests, 3 pass and 8 fail.** The failures show desired behavior that this exercise intentionally violates. Preserve the initial output as the before-fix evidence. Do not change tests to accept stale output, and do not call the tutorial complete because the bug reproduced.

## Reproduce before fixing

1. Select **A · Library notice**, keep **Local**, and click **Generate briefing**. Request 1 waits in Response controls.
2. Select **B · Station notice**. The current source now describes a platform opening November 18; the prior display is cleared.
3. Click **Finish request 1**. The buggy starter displays the old library answer (November 12) and library citation under the new current source.
4. Open the citation and compare it with Current article. Record what you actually observed.

No fast clicking is needed. Finish/Fail controls resolve real pending JavaScript promises in the order you choose. They simulate delivery, not AI reasoning. Reset exercise reloads the page and clears the in-memory session.

## Fix and verify

Investigate `controller.mjs`: input changes clear completed output, but old requests still commit later. Fix only the downloaded exercise or an explicitly selected application. Keep the interface and fixtures intact. Preserve passing current-request behavior while ensuring old responses cannot publish an answer, citation, relevance, error or loading cleanup.

Run the regression suite before and after your correction. It exercises source, topic and question changes, both A/B completion orders, obsolete errors and cleanup, same-input retries, A → B → A, and current success/error behavior. All 11 desired-behavior tests should pass after the correction. Inspect intermediate observed states; a stale answer that flashes briefly still fails.

Repeat the browser reproduction after the correction. Also start A, switch to B, start B, then finish A while B is still waiting: old output must stay hidden and B must still show loading. Finish B and verify the station answer and citation. Repeat with B finishing before A and with an old failure. Check at desktop and mobile widths.

If browser access or Node is unavailable, report the missing check honestly. A source-code review or walkthrough is not an executed verification. A green fixture test says nothing about model quality, provider behavior, real news or customer demand.

## Capture the lesson

Write your own `fix-notes.md` with the observed failure, root cause, exact changes, before/after command results, browser checks and remaining limitations. Keep source and fix revision identifiers if available; no private paths, credentials or raw session transcripts.

Then draft `.mined-skills/stale-news-summary-review/SKILL.md` from this debugging session, clearly labeled as a lesson from a simulated-response exercise. Refine it into a method for asynchronous interfaces, with conditions for use, decision rules and verification. Try an independent topic-change case and a static article where asynchronous request checks do not apply. A draft is not uploaded or installed until the user explicitly asks.

If an existing website already has a verified episode, use that real evidence instead. Do not deliberately introduce this bug into an existing app just to follow the tutorial. If no bug is reproducible there, use this isolated exercise. Fictional fix notes can still support a notes-only walkthrough, labeled as such.

## Files

- `index.html`, `demo.css`, `app.mjs`: the visible exercise and deterministic response controls.
- `controller.mjs`: the intentionally buggy state controller to repair.
- `fixtures.mjs`: two fictional sources and deterministic answer rules.
- `regression.test.mjs`: desired-behavior tests, intentionally failing on the starter.
- `serve.mjs`: a dependency-free local server.
- `fonts/Geist.woff2`, `fonts/OFL.txt`: self-hosted font and its license.
- `manifest.json`: downloadable file list and checksums.

No solved implementation is included. The hosted starter remains buggy for the next learner.
