# Handoff — Northline workshop signup site repair (Task 3), revision 2

## Deliverables
- `output/site/` — repaired site, ready to run: `index.html`, `style.css`, `app.js`, `server.py`. To run: `cd output/site && python3 server.py`, then open http://127.0.0.1:8765. `PORT` can override the port (inputs/brief.md). The folder starts with no `submissions.jsonl`; the server creates it on the first valid signup.
- `output/checks/server_check.py` — checks the server handler and the price formula in-process. It exits with code 1 if any case fails.
- `output/checks/cleanup.py` — moves a test `submissions.jsonl` out of `site/` into `checks/` without overwriting earlier files.
- `output/checks/preserve_v1.py` — the script that made the preserved copy of the first submission.
- `output/checks/browser_test_submissions.jsonl` — records created by the first-round browser tests.
- `output/checks/browser_test_submissions_1.jsonl` — records created by the revision-round browser tests.
- `output/original_submission_v1/` — the first submission, unchanged (site, handoff, checks).
- The raw inputs (`site/`, `inputs/`, `COMMON.md`, `PROMPT.md`) were not modified.

## Change log (revision 2, compared with `original_submission_v1/`)
1. **`app.js`, network errors:** before, a failed connection would have shown the browser's raw error text (for example "Failed to fetch"). Now network failures show "Signup failed: could not reach the server. Please try again.", and server rejections show the server's message. The success path is unchanged. Validation, price logic and route are unchanged.
2. **`style.css`, labels:** I removed the `font-weight:bold` I had added to labels, so they look as they did in the original. Everything else in the CSS is the same as v1.
3. **`server_check.py`:** it now checks expected status codes and record counts and exits with code 1 on failure. It shows the response body and no longer crashes if the raw `site/` folder is missing. Hand arithmetic for the price examples is now included.
4. **`cleanup.py`:** it now uses numbered evidence files so it never overwrites earlier evidence.
5. **`handoff.md`:**
   - Things that were only reviewed in code, not run, are now marked as such: the code that displays a server 400 error, the network-error message and the focus outline.
   - Added the revision-round browser evidence.
   - The page's email rule is now explained against the browser's own email check.

Review checks that found **no correction needed**:
- Price arithmetic: 240×1.12 = 268.80, 480×1.12 = 537.60, 720×0.9×1.12 = 725.76, 1920×0.9×1.12 = 1935.36. These match inputs/brief.md, and the browser showed the same values.
- The route `/api/leads` matches `site/server.py`.
- `server.py` is identical to the original (checked with `filecmp`).
- The title and text are preserved. The colours #152a45, #e78136 and #edf1f5 are unchanged.
- No external URLs, libraries or tracking appear in the site files.

## Defects found in the original `site/` and fixes
| # | Defect | Fix |
|---|---|---|
| 1 | `calculateTotal` returned `subtotal * discount * 1.12`, so 1 seat showed **CAD 0.00** (seen in the browser at 390 px). | `subtotal * (1 - discount) * 1.12`, rounded to cents, shown as `CAD x.xx`. The 10% discount applies at 3+ seats, before tax. |
| 2 | `fetch('/api/lead')`, but the server only accepts `/api/leads`, so every signup failed and nothing was saved. | Now posts to `/api/leads`. |
| 3 | The calculator priced blank or 0 (`Number('')` is 0), fractions and 9+. | `parseSeats()` accepts only a whole number from 1 to 8. Anything else shows "Enter a whole number of seats from 1 to 8." and sets `aria-invalid`. |
| 4 | The browser's native checks accepted a name of spaces (the browser tool reported `valid: true` for "   ") and `a@b` (also `valid: true`), while the server rejects both. | The form uses `novalidate`, and JS checks name (trimmed), email (same pattern as `server.py`) and seats. A visible error appears and nothing is sent. The button is disabled while a request is in progress. On success it shows "Thanks! Your workshop request is saved." and resets the form. |
| 5 | Horizontal overflow at 390 px (`width:1120px`, fixed 2-column grid). The browser tool reported `overflow: true`. | `width:100%; max-width:1120px` with `minmax(0,…)` grid columns. Below 760 px it uses one column with smaller padding and a 30 px h1. Inputs and buttons are at least 48 px tall, and a focus outline was added. |
| 6 | No `<head>` tags. | Added `<head>` tags, plus `name`/`autocomplete` attributes and `inputmode="numeric"`. |

## Checks actually performed
### A. Browser tool (trusted server running the original POST /api/leads; fresh browser per call; text output only)
- **Original `site/` at 390 px:** showed `CAD 0.00` for 1 seat, with `overflow: true`.
- **Calculator:**

| Seats | Width | Shown | Expected |
|---|---|---|---|
| 1 (default) | 1280 and 390 | CAD 268.80 | 268.80 |
| 2 | 390 (v1), 1280 (rev) | CAD 537.60 | 537.60 |
| 3 | 390 (v1 and rev) | CAD 725.76 | 725.76 |
| 8 | 1280 (v1 and rev), 390 (rev) | CAD 1935.36 | 1935.36 |
| blank, 0, -1, 9 | 390 (v1); 9 again in rev | "Enter a whole number of seats from 1 to 8." | reject |
| 2.5 | 1280 (v1) | same message | reject |

- **Form, first round (v1 `app.js`):**
  - Ada Tester / ada@example.test / 3 at 1280: success message.
  - Mo Bile / mo@example.test / 1 at 390: success message.
  - Spaces / not-an-email / 9 at 390: all three errors shown.
  - Frac Tion / frac@example.test / 2.5 at 1280: seats error shown.
  - Resulting `submissions.jsonl`: exactly the 2 valid records (now `checks/browser_test_submissions.jsonl`).
- **Form, revision round (revised `app.js`):**
  - Rev Desk / a@b / 2 at 1280: "Enter a valid email address."
  - Blank name / blank.name@example.test / 8 at 390: "Enter your name."
  - Rev Desk / a@b, then corrected to rev.desk@example.test / 2, at 1280: final state shows the success message. Only the final state is visible in this tool.
  - Rev Mobile / rev.mobile@example.test / 8 at 390: success message.
  - Resulting `submissions.jsonl`: exactly the 2 valid records (Rev Desk, 2 seats; Rev Mobile, 8 seats), now `checks/browser_test_submissions_1.jsonl`.
  - After the label CSS revert: a 9-seat invalid submit at 390 showed all errors, and 8 seats at 1280 showed CAD 1935.36. No new record was created.
- **Overflow:** `overflow: false` on every `output/site` call at 390 and 1280 px, including with error text showing. No JS errors were reported by the tool on any call.

### B. `python output/checks/server_check.py` (run after the revision, exit code 0, `FAILURES: 0`)
The sandbox blocks network sockets, so the script calls the unmodified `server.py` handler directly, using a temporary copy. Results:
- 201 for a valid signup, which added 1 record.
- 404 for `/api/lead`.
- 400 with `{"error":"Check name, email and seats (1-8)."}` for a name of spaces, a bad email, 0 seats, 9 seats and 2.5 seats. Each added 0 records.
- The Python version of the price formula matches all four examples in the brief.

## Limitations / assumptions
- I did not run `python3 server.py` over a real socket or open it at 127.0.0.1:8765 myself, because sockets are blocked in my sandbox. The end-to-end checks used the browser tool's trusted server.
- There are no screenshots. Colours, spacing and readability were not checked visually, and "usable controls" is inferred from the CSS and from fill/click actions succeeding.
- Not run, only reviewed in code: the display of the server's 400 message (the page's checks match the server's rules, so the UI can't trigger it), the network-error message, the focus outline and keyboard-only use.
- Assumption: "plausible email" means the server's regex `[^@\s]+@[^@\s]+\.[^@\s]+`.
- Assumption: the form resets after a successful signup, so the total goes back to 1 seat (CAD 268.80).
- Only tested at 390 and 1280 px, in one browser engine.

## Estimated human time to finish
About 15–25 minutes (estimate, not measured): run the server locally, do a visual check at desktop and mobile sizes in a real browser, try one keyboard-only signup and one with the server stopped, then confirm `submissions.jsonl` is empty or absent before going live.
