# Handoff — Task 3: Northline Workshops signup site repair (revision 2)

The first submission is preserved unchanged in `output_original_submission/` (site, evidence and handoff).
All results below were obtained on the revision-2 files in `output/site/` unless marked "round 1".

## Change log (revision 2 vs first submission)

| # | Review finding | Correction |
|---|---|---|
| 1 | `index.html` had `maxlength="120"` on Name and `maxlength="254"` on Email. The brief sets no length limit, the limit was not disclosed in the handoff, and a long but valid name would have been silently truncated. | Both `maxlength` attributes removed. |
| 2 | `calculateTotal()` still priced out-of-range values when called directly (e.g. 9 seats), although the UI never did so. | `calculateTotalCents()`/`calculateTotal()` now throw `RangeError` unless seats is a whole number 1–8. Verified in the browser (section C). |
| 3 | Page-wiring variables `status` and `total` were top-level `const`s sharing names with `window.status` and element-ID globals. No error occurred in the test browser, but it is an avoidable cross-browser risk. | DOM wiring moved into a function scope and renamed (`statusEl`, `totalEl`). Pure functions (`parseSeats`, `calculateTotal`, `calculateTotalCents`, `formatCad`) remain global as in the original. |
| 4 | After an invalid submit, "Signup not sent…" stayed on screen while the visitor corrected the fields. | The error summary clears on the next edit; field errors clear per field. Verified (section B). |
| 5 | Handoff overstated the original's behaviour: it said a fractional seat value could reach the server. The original form used native validation with `step="1"`, and I never submitted the original form, so that was an untested and probably wrong claim. | Claim removed; statements about the original site are now limited to what I observed or can read in its code (section "Defects"). |
| 6 | Handoff listed the server-400 message, the network-failure message, seats 4–7 and non-numeric input as untested. | Now tested with a stubbed `fetch` and a function-level harness (section C); remaining gaps restated precisely. |
| 7 | Original-site baseline at 1280 px had not been checked. | Checked: the original overflowed only at 390 px, not at 1280 px. |

`style.css` and `server.py` are unchanged from the first submission. No calculation in the first submission was wrong; all four brief examples were re-verified.

## Deliverables

| File | Status |
|---|---|
| `output/site/index.html` | changed vs input: attributes and empty error placeholders only; visible text identical |
| `output/site/style.css` | changed vs input: responsive layout, error and focus states |
| `output/site/app.js` | changed vs input: endpoint, calculator, validation, messages |
| `output/site/server.py` | byte-identical to `site/server.py` (SHA-256 prefix `319965872ca2` on both) |
| `output/evidence/review_browser_test_submissions.jsonl` | records the test server stored during revision-2 browser runs |
| `output/evidence/browser_test_submissions.jsonl` | same, from round 1 |
| `output/evidence/server_check.py` | static + server-handler checks (run from the workspace root) |
| `output/evidence/build_harness.py` | builds the throwaway test copies used in section C |
| `output_original_submission/` | first submission, preserved |

Run: `cd output/site && python3 server.py`, open http://127.0.0.1:8765 (`PORT` overrides) — `inputs/brief.md`.
Input files in `site/` are unmodified (hashes re-checked after all tests; no `submissions.jsonl` was created there).

## Defects in the supplied site and fixes

| # | Defect | Basis | Fix |
|---|---|---|---|
| 1 | Form posted to `/api/lead`; `site/server.py` `do_POST` only accepts `/api/leads`, so no signup could be stored | Code reading; handler check returns 404 for `/api/lead` | Posts to `/api/leads` |
| 2 | `calculateTotal` returned `subtotal * discount * 1.12` | Observed: original page shows `CAD 0.00` for 1 seat; original function returns 0.00, 0.00, 80.64, 215.04 for 1, 2, 3, 8 seats | (subtotal − 10% discount at 3+ seats) × 1.12, in integer cents (`inputs/brief.md`, calculator sentence) |
| 3 | Calculator did not reject invalid seat counts | Observed: original function returns 0 for 0, −1 and 1.5 and 241.92… for 9 | Only whole numbers 1–8 accepted; otherwise `CAD —` and "Enter a whole number of seats from 1 to 8." |
| 4 | Horizontal overflow on mobile from `.shell{width:1120px}` and a fixed two-column grid | Observed: original `overflow: true` at 390 px (false at 1280 px) | Fluid shell with `max-width:1120px`; one column at ≤760 px; smaller heading/padding; 48 px minimum control height |
| 5 | Error feedback depended on native browser validation plus one generic message; a whitespace-only name passes `required` | Code reading only (original form not submitted by me) | Form is `novalidate`; JS checks name (non-blank after trim), email (same pattern as the server) and seats before sending; per-field messages and a status line; nothing is sent when invalid; the server's own error text is shown if it rejects |

Also: name and email are trimmed before sending; the button is disabled while sending; name and email are cleared after success; `autocomplete`, `aria-invalid`, `aria-describedby` and a visible focus outline were added.

Preserved: title "Northline Workshops", all page text (tag-stripped text compared programmatically: identical), colours `#152a45`, `#e78136`, `#edf1f5`. No framework, dependency, external URL or tracking.

## Checks actually performed (revision 2)

### A. Layout — browser tool (reports text, control state and an overflow flag; no screenshots)

| Site | 390 px | 1280 px |
|---|---|---|
| original `site/` | overflow **true** | overflow false |
| `output/site` | overflow false in all 9 runs | overflow false in all 8 runs |

Every run reported `errors: []`.

### B. Calculator and form on `output/site` — browser tool with its test server (original `POST /api/leads` behaviour)

Calculator
| Seats entered | Width | Displayed | Brief |
|---|---|---|---|
| 1 (default) | 390, 1280 | CAD 268.80 | 268.80 |
| 2 | 1280 | CAD 537.60 | 537.60 |
| 3 | 390 | CAD 725.76 | 725.76 |
| 8 | 1280 | CAD 1935.36 | 1935.36 |
| blank | 1280 | `CAD —` + seats error | reject |
| 0 | 1280 | `CAD —` + seats error | reject |
| −1 | 390 | `CAD —` + seats error | reject |
| 1.5 | 390 | `CAD —` + seats error | reject |
| 9 | 1280 | `CAD —` + seats error | reject |

Round 1 ran the same nine cases at the opposite widths on the first-submission files with the same results.

Submissions
| Case | Width | Visible result | Stored |
|---|---|---|---|
| Review Mobile / review-mobile@example.test / 8 | 390 | "Thanks! Your workshop request is saved. 8 seats, CAD 1935.36 including tax." | yes |
| "  Review Desktop  " / review-desktop@example.test / 2 | 1280 | "Thanks! … 2 seats, CAD 537.60 including tax." | yes, name stored trimmed |
| Empty submit, then Recovered User / recovered@example.test / 3, submit, reload | 390 | Clean page after reload (success text not captured because of the reload) | yes |
| Empty form | 1280 | "Enter your name.", "Enter a valid email address…", "Signup not sent…" | no |
| Email `bad@example` | 390 | Email error + "Signup not sent…" | no |
| Seats 0 | 1280 | Seats error + "Signup not sent…" | no |
| Seats blank | 390 | Seats error + "Signup not sent…" | no |
| Empty submit, then type a name | 390 | Name error and "Signup not sent…" cleared; email error still shown | no |

The test server's `submissions.jsonl` afterwards held exactly the three valid records (`output/evidence/review_browser_test_submissions.jsonl`) and nothing from the six invalid submit attempts. I moved it out of `output/site/` so the delivered site carries no test data.

Round 1 (first-submission files): three valid signups stored, four invalid ones not stored (`output/evidence/browser_test_submissions.jsonl`). The record named "Server Reject" there is an ordinary valid signup, not a rejection test.

### C. Throwaway harness copies under `work/` (built by `build_harness.py`; not part of the delivered site)

- **Function results, delivered `app.js`, in the browser:** `calculateTotal` 1→268.80, 2→537.60, 3→725.76, 4→967.68, 5→1209.60, 6→1451.52, 7→1693.44, 8→1935.36; 0, −1, 1.5, 9 and NaN throw `RangeError`. `parseSeats` returns null for `""`, `"0"`, `"-1"`, `"1.5"`, `"9"`, `"abc"`, `"1e0"`, `"3.0"` and 3, 3, 1, 8 for `" 3 "`, `"03"`, `"1"`, `"8"`. `formatCad(193536)` → `CAD 1935.36`.
- **Server rejection path (stubbed `fetch` returning 400 with the server's error JSON), 390 px:** "Signup failed. Check name, email and seats (1-8)."; entered values kept.
- **Network failure path (stubbed `fetch` that rejects), 390 px:** "Signup failed. We could not reach the server. Please try again."; entered values kept.

### D. Python checks (`server_check.py`, exit code 0, re-run on revision 2)

- `server.py` identical to input; page text unchanged; title and palette present; no external URLs; old `/api/lead` endpoint absent.
- Independent Python calculation of the pricing rule: 268.80, 537.60, 725.76, 1935.36.
- Supplied `Handler` run in-process on a throwaway copy (fake socket, no network): two valid payloads → 201 and one record each; `/api/lead` → 404; blank name, bad email, seats 0, 9 and 1.5 → 400; no record for any of the six non-201 cases.

## Limitations

1. **No visual inspection.** Colours, spacing, label legibility and tap-target size are set in CSS but were not viewed; the tool gives no screenshots.
2. **`python3 server.py` was not run over a real socket by me.** The sandbox refuses socket binds from Python. Storage was confirmed through the browser tool's test server, and the supplied handler logic in-process.
3. **Stubbed, not real:** the 400 and network-failure messages were triggered with a replaced `fetch`, because client validation mirrors the server and I found no input that passes one and fails the other.
4. **Not tested:** typing non-numeric text or 4–7 into the Seats field (covered at function level only), keyboard-only and screen-reader use, browsers other than the tool's.
5. **Privacy risk in the supplied server, left unchanged.** `server.py` serves its whole directory and writes `submissions.jsonl` there, so by reading the code `GET /submissions.jsonl` would return stored names and emails (not confirmed over HTTP, see 2). It binds to 127.0.0.1 only. Needs a decision before any non-local use.
6. The server does not de-duplicate repeat submissions.

## Assumptions

- `03` is accepted as 3; `1e0`, `3.0` and anything not made only of digits is rejected as not a whole number.
- "Reject" for a direct `calculateTotal()` call with an invalid count means throwing `RangeError`; the brief does not specify the mechanism.
- Adding error messages and the seat/total summary after the original success sentence is within "keep the existing content".

## Estimated human time to finish

About 15–20 minutes (an estimate, not a measurement): run `python3 server.py` locally, view the page at phone and desktop widths, submit one valid and one invalid signup, and decide on limitation 5.
