# Handoff: Northline workshop signup site repair (revised after self-review)

The repaired site is in `output/site/`. Signups save through the supplied server, the calculator matches all four examples in the brief, and the page does not overflow at 390 px or 1280 px.

The review found no defect in the site files, so `output/site/` is byte-identical to the first submission. It did find two inaccurate statements and one imprecise citation in the first handoff; they are corrected here and listed in the change log at the end. The first submission is preserved unchanged in `output/original_submission/`.

Run the site as the brief describes: `cd output/site && python3 server.py`, then open http://127.0.0.1:8765 (`PORT` overrides the port). I could not start it that way myself, because the sandbox blocks opening sockets. Page checks went through the provided browser tool and its trusted `/api/leads` server instead.

All requirements cited below come from `inputs/brief.md` (single heading: "Workshop site acceptance brief"); the brief has no sub-headings, so I quote the sentence label, such as "Required:" or "Calculator:".

## What was wrong and what changed

| # | Defect in `site/` | Fix in `output/site/` | Requirement in `inputs/brief.md` |
|---|---|---|---|
| 1 | `app.js` posted to `/api/lead`; `server.py` only accepts `/api/leads`, so every signup got a 404. | `app.js` posts to `/api/leads`. | "The server accepts POST /api/leads…" |
| 2 | `calculateTotal` multiplied the subtotal by the discount rate, giving CAD 0.00 for 1–2 seats and CAD 80.64 for 3. | Total is subtotal, less 10% for 3+ seats, plus 12% tax after the discount, computed in whole cents and shown with two decimals. | "Calculator:" |
| 3 | Blank, 0, negative, fractional or 9+ seats still produced a total, with no explanation on the page. | Seats must be a whole number 1–8. Otherwise the total shows "—" and "Enter a whole number of seats from 1 to 8." appears under the field. | "reject blank, 0, negative, fractional or 9+ seats" |
| 4 | The page had no visible validation of its own. A whitespace-only name and an email like `cy@example` both pass the browser's built-in checks, so they would have been posted and left to the server to reject. | `app.js` checks name, email (same pattern as `server.py`) and seats before posting. Invalid input shows a message per field plus "Signup not sent…", and nothing is posted. Name and email are trimmed. | "Required:" and "Invalid submissions must show an error and not create a record." |
| 5 | `.shell{width:1120px}` with a fixed two-column grid overflowed at 390 px. | `style.css` uses `max-width:1120px` and a single column at 760 px and below. | "Layout must avoid horizontal overflow at 390 px and 1280 px…" |
| 6 | No styling for errors, success or keyboard focus. | Added error and success styles, an orange focus outline, bold labels and 48 px minimum control height. | "readable labels and usable controls" |

- **Unchanged:** `server.py` is a byte-identical copy. The title and all visible page text are identical to the input (compared programmatically), and the four original colours are all still in use. The original `site/` was not written to.
- **Colours added:** error states use three red tones (`#b3261e`, `#8c1d18`, `#fdecea`) and the success box a pale orange tint (`#fdf1e7`). The reds are outside the dark-blue/orange palette and appear only when an error is shown. If the owner wants errors kept strictly in-palette, that is a three-line change in `style.css`.
- **Added to `index.html`:** `name`, `autocomplete`, `inputmode` and `aria-describedby` attributes, plus three empty error slots under the fields.
- **Not added:** frameworks, dependencies, external URLs or tracking (no `http(s)://` reference in the delivered HTML, CSS or JS).

## Checks performed

### Before the fix (original `site/`)
- **390 px load:** overflow was reported and the total read "CAD 0.00".
- **1280 px valid submit (Ada Test, 3 seats):** the page showed "Signup failed. Please check your details and try again." and a total of "CAD 80.64".

### Layout (repaired site)
- **390 px and 1280 px:** no horizontal overflow on any load or interaction listed below; all original text and the Name, Email and Seats labels were present.
- **Not seen:** the browser tool returns text, control state and an overflow flag, not screenshots. I did not visually confirm colours, spacing or tap-target size.

### Calculator (typed into the Seats field)

| Seats | Width | Displayed | Expected | Source of expected value |
|---|---|---|---|---|
| 1 | 390 and 1280 | CAD 268.80 | 268.80 | brief example |
| 2 | 1280 | CAD 537.60 | 537.60 | brief example |
| 3 | 1280 | CAD 725.76 | 725.76 | brief example |
| 8 | 390 | CAD 1935.36 | 1935.36 | brief example |
| 4 | 390 | CAD 967.68 | 967.68 | my calculation from the brief's rule |
| 5 | 1280 | CAD 1209.60 | 1209.60 | my calculation from the brief's rule |
| 6 | 390 | CAD 1451.52 | 1451.52 | my calculation from the brief's rule |
| 7 | 1280 | CAD 1693.44 | 1693.44 | my calculation from the brief's rule |

- **Rejected entries:** blank and 0 (at 390 px) and -2, 2.5 and 9 (at 1280 px) each showed "—" and the seats message.
- **"1.0":** also rejected (390 px); see Assumptions.
- **Recovery and reload:** typing 9, then 3, then reloading (390 px) left no error and showed CAD 268.80 for the default 1 seat.

### Form submissions through the browser tool's trusted server

| Width | Name / email / seats | Result on page |
|---|---|---|
| 1280 | Ada Test / ada@example.test / 3 | "Thanks! Your workshop request is saved. 3 seats, CAD 725.76." |
| 390 | Ben Test / ben@example.test / 1 | "Thanks! Your workshop request is saved. 1 seat, CAD 268.80." |
| 390 | Cy Test / `bad` / 2, then corrected to cy@example.test / 8 and resubmitted | "Thanks! Your workshop request is saved. 8 seats, CAD 1935.36." after the correction |
| 390 | all blank / 1 | "Enter your name.", "Enter a valid email address, like name@example.test." and "Signup not sent. Please fix the highlighted fields and try again." |
| 1280 | three spaces / cy@example.test / 2 | "Enter your name." and "Signup not sent…" |
| 390 | Cy Test / not-an-email / 2 | email message and "Signup not sent…" |
| 1280 | Cy Test / cy@example / 2 | email message and "Signup not sent…" |
| 390 | Cy Test / cy@example.test / 9 | seats message and "Signup not sent…" |
| 1280 | Cy Test / cy@example.test / 2.5 | seats message and "Signup not sent…" |
| 390 | Cy Test / cy@example.test / 0 | seats message and "Signup not sent…" |

After these runs the trusted server had written exactly three records to `output/site/submissions.jsonl`, one per successful submission and none for the eight invalid attempts:

```
{"name":"Ada Test","email":"ada@example.test","seats":3}
{"name":"Ben Test","email":"ben@example.test","seats":1}
{"name":"Cy Test","email":"cy@example.test","seats":8}
```

I moved that file to `output/evidence/submissions_from_browser_checks.jsonl` so the delivered site starts with no test records. The server recreates `submissions.jsonl` on the first successful signup.

### Server-error and network-error messages (added in review)
Client validation stops invalid input before it is posted, so these two branches of `app.js` cannot be reached from the delivered page. I exercised them with two harness copies in `output/evidence/`. Each uses the delivered `app.js` and `style.css` unmodified; only `index.html` gains an inline script that overrides `fetch`.

| Harness | What the override does | Width | Result on page | Record created |
|---|---|---|---|---|
| `harness_400` | replaces the request body with an invalid payload, so the trusted server answers 400 | 390 | "Signup failed. Check name, email and seats (1-8)." | none |
| `harness_net` | makes `fetch` reject, as a dropped connection would | 1280 | "Signup failed. We could not reach the server. Please try again." | none |

These are harness results, not behaviour observed on the delivered page.

### Server handler, in-process
`output/evidence/server_handler_check.py` drives the `Handler` class from the delivered `server.py` with a fake socket and a temporary copy of the site. This is not a real HTTP run.
- **Static files:** `index.html`, `style.css` and `app.js` were each served with 200 and matched the delivered files.
- **Old endpoint:** POST `/api/lead` returned 404 and wrote no record.
- **Valid payloads:** two POSTs to `/api/leads` returned 201 and added one record each.
- **Invalid payloads:** blank name, bad email, and seats of 0, 9, 2.5 and -1 each returned 400 and added no record.

### Static checks (added in review)
`output/evidence/review_static_checks.py` confirmed the following; run it from the workspace root.
- **Visible text:** identical between `site/index.html` and `output/site/index.html` once tags are stripped.
- **Colours:** all four input colours are still present; four were added (listed above).
- **Endpoint:** the only `fetch` target in `app.js` is `/api/leads`.
- **Site files:** all four files in `output/site/` have the same hashes as in `output/original_submission/site/`.

## Assumptions
- **Form after success:** the fields are not cleared, as in the original, so the total panel still matches the confirmation. A second click after the confirmation would therefore store a second record; the brief does not address duplicates.
- **Seats format:** only plain digits are accepted, so "1.0" and "1e0" are rejected. The brief says "integer seats 1–8" and does not say how to treat "1.0".
- **Amount format:** no thousands separator, matching the brief's "1935.36".
- **New wording:** the error messages and the seats/total suffix on the success message are new text; the brief did not supply any.

## Limitations
- **No real HTTP run of `python3 server.py`:** the sandbox refused to bind a socket (PermissionError).
- **No visual check:** appearance on a real phone or desktop browser is unconfirmed, including the added red error styling.
- **Widths:** the browser tool offers only 390 px and 1280 px, so widths in between were not checked.
- **Double-click guard:** the button is disabled while a request is in flight, but I did not exercise this.
- **No JavaScript unit tests:** Node is not installed, so the pricing functions were checked only through the page.
- **One browser engine:** only the provided browser tool was used.

## Change log (review pass)
1. **Corrected a wrong claim about colours.** The first handoff said the new error and success styles stayed "within the existing dark-blue/orange palette". The error styles use red tones. The CSS is unchanged; the handoff now states this and flags it as an owner decision.
2. **Corrected the description of defect 4.** The first handoff said bad names and emails were "only rejected by the server with a generic message". In the original site nothing reached the server's validation because of the wrong endpoint; the row now says so.
3. **Tightened citations.** The first handoff cited `inputs/brief.md`, "Calculator" as if it were a section heading. Each fix now quotes the brief sentence it answers.
4. **Added checks.** Seats 4–7, "1.0", recovery and reload, the server-400 and network-failure messages (via harness), and the static comparisons above. The 400 and network branches are removed from the limitations and replaced by the harness caveat.
5. **Added to assumptions and limitations.** The duplicate-record consequence of not clearing the form, and the untested intermediate widths.
6. **No change to `output/site/`.** No defect was found in the code; the checks above and in the first pass are the basis for that.

## Files
- `output/site/index.html`
- `output/site/style.css`
- `output/site/app.js`
- `output/site/server.py`
- `output/handoff.md`
- `output/evidence/submissions_from_browser_checks.jsonl`
- `output/evidence/server_handler_check.py`
- `output/evidence/review_static_checks.py`
- `output/evidence/harness_400/` and `output/evidence/harness_net/` (`index.html`, `app.js`, `style.css` each)
- `output/original_submission/` (first submission: `site/`, `evidence/`, `handoff.md`)

Estimated human time to finish: about 10–15 minutes (an estimate, not measured), to run `python3 server.py`, look at the page on a phone-width and a desktop browser, and decide on the error colours.
