Skip to content

Community review page for the cannabis decision trail (draft) - #128

Draft
noneck wants to merge 3 commits into
v2from
feature/community-review-page
Draft

noneck wants to merge 3 commits into
v2from
feature/community-review-page

Conversation

@noneck

@noneck noneck commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

What

A standalone page at /review/ where volunteers check what a computer read from New York State's Cannabis Control Board PDFs. They see one small picture of the page at a time, with the row outlined in red, plus the value we read. They answer Matches, Doesn't match or Can't tell, and can optionally type what the page shows and add a note. The work is tracked in BetaNYC's workspace.

  • Lives in site/static/review/ (plain HTML, CSS and JS, copied into the build as-is). The map, the pipeline and the SvelteKit app are unchanged. I built with and without the folder: every page is identical except SvelteKit's per-build version stamp. Nothing links to the page yet.
  • 253 items in 25 batches of about 20; each item is in two batches. 4.1 MB of WebP crops cut from the State's own PDFs. Business information only, as the State publishes it. E-mail addresses and phone numbers inside a picture are blacked out (13 of them, all the OCM letterhead footer).
  • Answers are saved per batch in localStorage. Contact fields are optional and never stored. Answers are suggestions; staff decide.
  • Sending is off: ENDPOINT = "" in review-core.js. The page offers "Download my answers", a JSON file in the intake request shape (schema: betanyc-data-issue/1, tool: slam, kind: review-answer). Once the endpoint exists, setting ENDPOINT makes it POST with no credentials.

Security

  • Meta CSP: default-src 'self'; img-src 'self' data:; connect-src 'self' https://www.beta.nyc; script-src 'self'; style-src 'self'; object-src 'none'; base-uri 'none'; form-action 'none'. data: is only there for the empty favicon.
  • No analytics, fonts or third-party scripts. The e2e test fails on any request to another host or any CSP error.
  • All DOM is built with textContent and attributes. A unit test fails on innerHTML, outerHTML, insertAdjacentHTML, document.write, inline scripts, handlers or styles.
  • ?batch= is checked against batches.json. Image paths must match img/<id>.webp, PDF links must be https, and those links use rel="noopener noreferrer". A hidden honeypot field is included. The page is noindex with no-referrer.

Security review fixes (second commit)

  • Sent state: after a 201 the batch is marked sent in localStorage. Send disappears and the page shows "Thanks — your answers for this batch were sent" with a link to start another batch. "Send again" appears only after an answer actually changes.
  • 429: the wait comes from Retry-After (seconds or an HTTP date). Without that header the page says "about an hour", the endpoint's limit window, and never "a few minutes". The endpoint must send Access-Control-Expose-Headers: Retry-After, or a cross-origin page cannot read the header and always falls back to an hour.
  • Framing: a meta CSP cannot set frame-ancestors, and GitHub Pages cannot send the header. So review.js hides every control and shows a message when window.top !== window.self. This is best effort; the README says so.

Contract amendment 2026-11-08 (third commit)

  • client_id: made once per browser with crypto.randomUUID() (fallback: 32 hex characters from crypto.getRandomValues), kept in localStorage (slam-review:client-id), and sent in every request body and the downloaded file, right after credit_ok. It is never shown. It identifies a browser, not a person.
  • page_url is always https://slam.beta.nyc/review/?batch=<id>, which meets the amended rule (allowed origin followed by /).

Tests run (locally, Node 26.13)

  • npm test: 187 pass, 0 fail (13 in tests/communityReview.test.js)
  • npm run check: 0 errors, 0 warnings
  • npm run build: OK
  • npm run test:a11y: 62 passed, 16 skipped (desktop-only keyboard tests on phone sizes). With the endpoint mocked through Playwright routes: send once, reload, Send again after a change, 429 with and without Retry-After, and a framed page. New e2e/review.spec.js runs axe on the intro, item, larger-image and finish screens at all three sizes, a keyboard-only pass, a check of the downloaded file's exact shape, reload persistence, and a bad ?batch=.

Needs before it goes live: a place to send answers (the endpoint), and a decision on linking to the page.

🤖 Generated with Claude Code

marvin and others added 3 commits November 8, 2026 22:22
A standalone page at /review/ (site/static/review/, copied into the build
as-is; the map, pipeline and SvelteKit app are unchanged). Volunteers see
one picture of a State PDF page at a time with the value a computer read,
and answer Matches / Doesn't match / Can't tell, with optional "what the
page shows" and a note. Answers are saved per batch in localStorage and
downloaded as a JSON file in the shape of BetaNYC's data-issue intake
request; sending stays off until ENDPOINT is set.

CSP allows only this site's files plus https://www.beta.nyc for sending;
no analytics or third-party scripts; DOM built with textContent only;
?batch= checked against batches.json. 253 items, 25 batches, 4.1 MB of
WebP crops with e-mail addresses and phone numbers blacked out.

Tests: tests/communityReview.test.js, e2e/review.spec.js (axe, keyboard,
download, no foreign requests).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- After a 201 the batch is marked sent in localStorage. Send disappears,
  a plain "Thanks — your answers for this batch were sent" shows with a
  link to another batch, and "Send again" appears only after an answer
  changes (compared by a fingerprint of the normalized answers).
- On 429 the wait comes from Retry-After (seconds or HTTP date). Without
  it the page says about an hour, the endpoint's limit window. The
  endpoint must expose Retry-After to cross-origin pages.
- A meta CSP cannot set frame-ancestors, so review.js hides every
  control and shows a message when window.top !== window.self. The
  limitation is noted in the README.
- Tests: unit tests for canSend/answersFingerprint/retryAfterMessage;
  e2e with the endpoint mocked (send once, reload, Send again, 429 with
  and without Retry-After, framed page).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The page makes a client_id once per browser with crypto.randomUUID()
(fallback: 16 random bytes from crypto.getRandomValues as 32 hex chars),
keeps it in localStorage and sends it in every request body and the
downloaded file. It is never shown. Triage keeps only a browser's latest
answers per batch. A stored value that fails the pattern is replaced.

Tests: getClientId unit tests (reuse, fallback, tampered value, storage
off); key order in the body; e2e exact shape, same id across sends and a
reload, and the id absent from the page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
noneck added a commit that referenced this pull request Nov 13, 2026
…131)

* What's changed: WHATS-CHANGED.md since 2018, a /whats-changed/ page, CI check

Adopts the BetaNYC What's changed standard (betanyc-ai-workspace#1646, epic #1637).

- WHATS-CHANGED.md: 24 entries from the record (v1 change log in main's README,
  commits, gh-pages deploys, issues and PRs; v2 PRs dated by when their deploy finished,
  New York time). History begins 2018-07-11. One correction (2020-08-10: licenses drawn
  in the wrong place for about 12 minutes; dates missing for about half an hour).
- scripts/whats_changed.py v1.2.1, copied unchanged from the workspace.
- site: /whats-changed/ route renders the generated fragment with {@html} under its own
  h1; prerender = true, csr = false. The built page carries exactly one <script>, the
  fragment's filter script, and it runs (Playwright). The address search needs the
  SvelteKit client, so the layout leaves it out on this page instead of showing a dead
  control. Footer link on every page, with data-sveltekit-reload.
- `npm run whats-changed` (also prebuild) writes site/src/lib/whats-changed.html.
- e2e: the page joins pages.js (axe and phone width at all three sizes); new
  whats-changed.spec.js (h1, landmarks, <time>, no-client script, keyboard filter and
  live region, JS off, 44px targets, 320px, footer link on every page, Back).
- CI (v2-site-a11y.yml): full-history checkout, `check --base-ref`, `render --check`.
- README: points to the file and the page.

Merges cleanly with open drafts #123 and #128 (git merge-tree).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* What's changed QA round 1: module 1.2.3, 500-foot correction, data-driven tests

- scripts/whats_changed.py v1.2.3 copied unchanged; fragment re-rendered (filter now
  shows only Site, Data and Corrections only).
- New correction 2026-11-05: 500-foot counts on 499 address pages were off, mostly by
  1 to 3 (PR #98); removed from the LAMP feature entry.
- 2020-08-10 correction advice reworded (4:12 to 4:44 pm, from commit timestamps).
- e2e/whats-changed.spec.js: counts from `whats_changed.py json`; a dated <time> per
  dated entry, not one per entry; checkbox count from the tags in use; filter checks
  skip when the module omits the filter; the csr check always runs; skip link in the
  44px check.
- app.css: skip link at least 44px tall.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore: shared What's changed module 1.2.4

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Header nav wraps at 320px (Linux CI overflow on PR #131)

On GitHub's Linux runner the What's changed page measured 325px wide at 320px. The
overflow was the site header's nav ("Districts About Glossary Rules"), not the page
fragment: it is a non-wrapping flex row, and wider Linux fonts push "Rules" past the
edge. The nav now wraps (flex-wrap, min-width: 0). Every page shares the header.

The 320px test now also measures with a wide font (Verdana / DejaVu Sans), so it fails on
macOS without this fix (323 > 320) and passes with it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant