fix(points): welcome check-in awards +10; add Sessions view, AI connection test, silent reload
The front-desk check-in set checked_in and printed badges but awarded nothing, so the +10 depended on which check-in a person happened to get. Every award path was reviewed: - welcome_checkin awards +10 (category checkin) on a genuine first check-in and returns points + points_awarded; checkin_attendee and preview_welcome_checkin return points_awarded too. - set_registration_checked_in(false) deleted all checkin points while keeping the checkins rows, and switching back on awarded nothing -- one mistaken toggle destroyed those points permanently. ON now recomputes from the rows that still exist and awards only the shortfall: reversible, still unfarmable. - The staff/Admin/@appe.at exclusion stays (product decision) but is no longer silent: three-way points sheets in the scanner, "no points" with a tooltip in Registrations, and the Contacts points modal refuses to apply rather than letting adjust_points (void) no-op quietly. Also in this change: - admin silent refresh (5s poll + 500ms after writes) across all data views; Registrations patches in place so rows never slide under the cursor - Settings "Validate AI connection" via a new sidecar POST /llm-test verdict endpoint (never leaks the key, distinguishes "no usage block" from "off") - new Sessions view between Schedule and Activity: speakers, attendance, ratings, attendee filter, and one button that summarises every session with feedback (one request each, concurrency 3, UI blocked until all settle) - provider requests disable thinking through one shared body builder sending both reasoning_effort:"none" and chat_template_kwargs.enable_thinking SQL: 113 / 57 / 24 assertions (set_registration_checked_in section 3 was rewritten, it asserted the bug). Sidecar 34 unit tests. Full e2e 202 passed, 0 failed. Migration applied locally only -- not deployed.
This commit is contained in:
1 parent
96e4e6a6ea
commit
fdb6045966
35 files changed
+2778
-154
No files matched your search
@@ -45,6 +45,55 @@ an existing `@appe.at` contact). They return `Cache-Control: no-store`.
|
||||
| `GET /sidecar/llm-settings` | Read redacted configuration. |
|
||||
| `PUT /sidecar/llm-settings` | Save `{ endpoint, model, api_key? }`. |
|
||||
| `POST /sidecar/feedback-summary` | Generate `{ scope: "event", event_id }` or `{ scope: "session", event_id, session_id }`. |
|
||||
| `POST /sidecar/llm-test` | Make one real chat request with the **stored** settings and return a verdict. |
|
||||
|
||||
### Connection validation (`POST /sidecar/llm-test`)
|
||||
|
||||
Always answers **`200 OK` with a verdict** (only the auth layer returns 401/403,
|
||||
and 405 for `GET`), because the reason a connection fails is the useful part:
|
||||
|
||||
```json
|
||||
{"ok":true,"model":"Qwen3.8","endpoint":"https://ai.lago.dev/v1/chat/completions",
|
||||
"latency_ms":412,"reasoning_disabled":true,"reasoning_tokens":0,"content":"OK",
|
||||
"warning":null,"error":null}
|
||||
```
|
||||
|
||||
- `reasoning_tokens` is the provider's own
|
||||
`usage.completion_tokens_details.reasoning_tokens`, or **`null` when the
|
||||
provider sent no `usage` block**. `null` is not "off"; `reasoning_disabled` is
|
||||
`true` only when it is exactly `0`.
|
||||
- `ok` answers "would generating a summary work?" — transport, auth and parsing
|
||||
all fine. A working connection whose provider still reports reasoning tokens is
|
||||
therefore `ok: true` with `reasoning_disabled: false` and a `warning`, so the
|
||||
honest signal about cost stays separate from the pass/fail answer. The Admin UI
|
||||
colours that case amber, not green.
|
||||
- It never writes to the database, and the API key never appears in any field:
|
||||
provider error text is flattened, truncated to 300 characters and the stored key
|
||||
is replaced with `[redacted]` (a provider that echoes the Authorization header
|
||||
in its own error body is covered by a test).
|
||||
- An endpoint that fails the SSRF/DNS guard is reported **without ever contacting
|
||||
it**.
|
||||
|
||||
### Disabling model thinking
|
||||
|
||||
Both requests (summaries and the test) are built by one helper,
|
||||
`buildChatCompletionsBody`, so they cannot drift apart. It sends
|
||||
`stream: false`, `reasoning_effort: "none"` **and**
|
||||
`chat_template_kwargs: { enable_thinking: false }`. Measured against the
|
||||
`ai.lago.dev` gateway (Bifrost → vLLM) serving `Qwen3.8`:
|
||||
|
||||
- Either field alone takes reasoning tokens from ~235 to `0`, about **3.5×
|
||||
faster**. Both are sent because they cover different OpenAI-compatible
|
||||
gateways and each silently drops the other; they agree, so the precedence rule
|
||||
never matters.
|
||||
- `thinking: { type: "disabled" }` (the Anthropic-style spelling) is **silently
|
||||
ignored** by this endpoint and still cost ~235 reasoning tokens, so it is
|
||||
deliberately not used.
|
||||
- `max_tokens` is accepted and ignored, so it is not sent.
|
||||
- **A `200 OK` proves nothing**: this endpoint ignores unknown fields entirely.
|
||||
Only `usage.completion_tokens_details.reasoning_tokens === 0` is evidence.
|
||||
Reasoning *levels* are validated though — `reasoning_effort: "banana"` is an
|
||||
HTTP 400 `unsupported_value`, which is how the field was confirmed to be live.
|
||||
|
||||
The sidecar checks that the event exists and that a selected session belongs to
|
||||
it. It reads all feedback in ordered 500-row pages, selecting only `rating` and
|
||||
|
||||
+46
-7
@@ -26,6 +26,7 @@ Source of truth:
|
||||
|
||||
| Action | Points | Awarded to |
|
||||
|---|---|---|
|
||||
| **Welcome (front-desk) check-in**, first time only | **+10** | the attendee |
|
||||
| Checked into a session (by staff) | **+10** | the attendee |
|
||||
| Connection accepted | **+5 each** | both people |
|
||||
| Connection accepted **with a shared talk** | **+`talk_networking_bonus` each** (per event, default 2, `0` = off) | both people (category `talk_networking`) |
|
||||
@@ -38,8 +39,31 @@ contacts (`is_admin` or `@appe.at`) always have zero points and never rank,
|
||||
including when checked in, leaving feedback, accepting connections or receiving
|
||||
manual adjustments. Existing audit history is retained when a role changes.
|
||||
|
||||
**That exclusion is deliberate and stays — but it is no longer silent.** It used
|
||||
to be invisible: a staff test check-in produced a bare `0` and looked like a
|
||||
broken feature. `_points_eligible` is now consulted by the callers that report
|
||||
outcomes, so every surface says why:
|
||||
|
||||
- `checkin_attendee` / `welcome_checkin` / `preview_welcome_checkin` return
|
||||
`points_awarded`, and the scanner renders "Checked in · staff earn no points"
|
||||
instead of claiming "+10 pts · now 0".
|
||||
- The admin Registrations table shows "— no points" with a tooltip on the rows
|
||||
the predicate excludes (`canEarnPoints` in
|
||||
[../frontend/admin-app.md](../frontend/admin-app.md) mirrors the SQL exactly),
|
||||
and the Contacts points modal refuses to apply an adjustment to such a contact
|
||||
rather than letting `adjust_points` (which returns `void`) no-op quietly.
|
||||
|
||||
## Internal helpers
|
||||
|
||||
### `_points_eligible(p_event_id, p_contact_email)` → `boolean`
|
||||
The single source of truth for "may this person earn points": the contact must
|
||||
have a registration in **that event**, with `registrations.type <> 'staff'`,
|
||||
`contacts.is_admin = false` and an email not ending in `@appe.at`. `_award_points`
|
||||
uses it as a gate, and the outcome-reporting RPCs use it to tell the UI whether an
|
||||
award actually happened — both halves read the same predicate, so a screen can
|
||||
never promise points the database would refuse. There is no second copy of the
|
||||
rule anywhere else; the admin app's client-side mirror is commented to that effect.
|
||||
|
||||
### `_award_points(p_event_id, p_contact_email, p_delta, p_category)`
|
||||
The shared award path first locks the registration and checks eligibility. Missing
|
||||
registrations, staff and Admin contacts receive no award or new audit entry.
|
||||
@@ -119,7 +143,7 @@ Accepts an **incoming** request.
|
||||
### `reject_connection(p_connection_id)` → `connections`
|
||||
Same guards as accept, but sets `status = 'rejected'`. No points.
|
||||
|
||||
### `checkin_attendee(p_session_id, p_attendee_qr)` → `(checkin_id, attendee_email, attendee_name, points, already)`
|
||||
### `checkin_attendee(p_session_id, p_attendee_qr)` → `(checkin_id, attendee_email, attendee_name, points, already, points_awarded)`
|
||||
Staff checks an attendee into a session.
|
||||
- **Role check:** `is_staff_or_admin()` (i.e. `is_admin()`) or it raises
|
||||
`staff or admin only`.
|
||||
@@ -139,7 +163,10 @@ Staff checks an attendee into a session.
|
||||
nothing returning id` — if no row was inserted, the attendee was **already
|
||||
checked in**: sets `already = true` and awards **no points**.
|
||||
- Otherwise awards **+10** to the attendee (category `checkin`).
|
||||
- Returns the attendee's current total points.
|
||||
- Returns the attendee's current total points, and `points_awarded` — whether
|
||||
that +10 actually landed. It is `false` for someone `_points_eligible`
|
||||
excludes, which is the only reason a fresh check-in pays nothing. Without it
|
||||
the scanner had to render "+10 pts · now 0" for a staff badge scan.
|
||||
|
||||
> **Implementation note:** the "already checked in" case is detected via the
|
||||
> `ON CONFLICT ... DO NOTHING returning id` (a `NULL` id means no-op), and the
|
||||
@@ -147,14 +174,22 @@ Staff checks an attendee into a session.
|
||||
> `return query` inside an `if` block would *not* terminate the function and would
|
||||
> double-award.
|
||||
|
||||
### `welcome_checkin(p_attendee_qr)` → `(attendee_email, attendee_name, already)`
|
||||
### `welcome_checkin(p_attendee_qr)` → `(attendee_email, attendee_name, already, points, points_awarded)`
|
||||
Staff **welcome** check-in: marks an attendee present at the **event** (distinct
|
||||
from `checkin_attendee`, which checks someone into a specific session).
|
||||
- **Role check:** `is_staff_or_admin()` or it raises `staff or admin only`.
|
||||
- Resolves the attendee by `qr_token` for the active event.
|
||||
- Sets `registrations.checked_in = true` (no points — that's the session
|
||||
check-in's job).
|
||||
- `already` is `true` if the attendee was already checked in to the event.
|
||||
- Sets `registrations.checked_in = true` and, on a **first** check-in, awards
|
||||
**+10** (category `checkin`) through `_points_eligible` + `_award_points`. The
|
||||
front desk is a real check-in, so it pays the same as a session scan; before
|
||||
this it paid nothing, which made "check me in" award different amounts
|
||||
depending on *which* check-in a person got. It is once-per-person because the
|
||||
`checked_in` flag already is, so repeating a welcome cannot farm points.
|
||||
- `already` is `true` if the attendee was already checked in to the event; in
|
||||
that case nothing is awarded and `points` is the unchanged total.
|
||||
- `points_awarded` says whether the +10 landed (false for excluded staff/Admin),
|
||||
so the result sheet can say "Checked in · staff earn no points" rather than
|
||||
claiming points that were never written.
|
||||
- On a **first** check-in (and only when the event has a badge layout), enqueues
|
||||
`events.badge_copies` identical `badge_print` jobs in the same transaction — the
|
||||
Pi worker prints exactly one label per job, so N jobs = N labels (see
|
||||
@@ -162,7 +197,7 @@ from `checkin_attendee`, which checks someone into a specific session).
|
||||
so a bad row can never flood the queue. A re-check-in (`already`) enqueues
|
||||
nothing. Manual reprint (`enqueue_badge_print`) still prints **one** label.
|
||||
|
||||
### `preview_welcome_checkin(p_attendee_qr)` → `(attendee_email, attendee_name, already, will_print, copies)`
|
||||
### `preview_welcome_checkin(p_attendee_qr)` → `(attendee_email, attendee_name, already, will_print, copies, points_awarded)`
|
||||
Read-only preview shown by the staff scanner **before** a welcome check-in is
|
||||
committed, so the confirmation popup can name the attendee and be honest about
|
||||
printing.
|
||||
@@ -178,6 +213,10 @@ printing.
|
||||
uses it to say "print their badge 3 times" instead of a fixed "this person's
|
||||
label", so it can never over- or under-promise.
|
||||
- Checks nobody in and enqueues nothing; it is a pure lookup.
|
||||
- `points_awarded` predicts the confirm's outcome — `true` only for a genuine
|
||||
first check-in by someone `_points_eligible`. The popup uses it to promise
|
||||
"Checking in awards +10 points" only when it is true, and to say "This person
|
||||
does not earn points (staff or organiser)" otherwise.
|
||||
|
||||
### `merge_tickets(p_source_id, p_target_id)` -> `jsonb`
|
||||
|
||||
|
||||
+83
-6
@@ -6,10 +6,8 @@ SQL suite **combined with the migration** in one transaction (the migration is
|
||||
database):
|
||||
|
||||
```sh
|
||||
(echo 'begin;'; \
|
||||
cat supabase/migrations/20261019110000_front_desk_gate_and_badge_copies.sql; \
|
||||
sed '/^begin;$/d' supabase/tests/badge_print_tests.sql) \
|
||||
| docker exec -i supabase_db_Convivo psql -X -U postgres -d postgres -v ON_ERROR_STOP=1
|
||||
docker exec -i supabase_db_Convivo psql -X -U postgres -d postgres \
|
||||
-v ON_ERROR_STOP=1 < supabase/tests/badge_print_tests.sql
|
||||
docker exec -i supabase_db_Convivo psql -X -U postgres -d postgres \
|
||||
-v ON_ERROR_STOP=1 < supabase/tests/set_registration_checked_in_tests.sql
|
||||
CONVIVO_BASE_URL=http://127.0.0.1:3000 npm test --prefix e2e -- front-desk-gate.spec.ts --project=chromium
|
||||
@@ -17,6 +15,26 @@ CONVIVO_BASE_URL=http://127.0.0.1:3000 npm test --prefix e2e -- welcome-badge-co
|
||||
CONVIVO_ADMIN_URL=http://127.0.0.1:3001 npm test --prefix e2e -- registration-checkin-toggle.spec.ts --project=chromium
|
||||
```
|
||||
|
||||
> **Replaying an older migration is no longer possible for these functions.**
|
||||
> `20261019160000_welcome_points_and_toggle_restore.sql` **drops and re-creates**
|
||||
> `checkin_attendee`, `welcome_checkin`, `set_registration_checked_in` and
|
||||
> `preview_welcome_checkin` with wider return types, and Postgres refuses
|
||||
> `create or replace` across a row-type change. So `cat`-ing the 20261019110000
|
||||
> migration onto the suite now fails with
|
||||
> `cannot change return type of existing function … Use DROP FUNCTION
|
||||
> checkin_attendee(uuid,text) first` — that error is the guard working, not a
|
||||
> broken suite. Run the suite against the live database (as above), or chain the
|
||||
> **newest** migration instead:
|
||||
>
|
||||
> ```sh
|
||||
> (echo 'begin;'; \
|
||||
> cat supabase/migrations/20261019160000_welcome_points_and_toggle_restore.sql; \
|
||||
> sed '/^begin;$/d' supabase/tests/badge_print_tests.sql) \
|
||||
> | docker exec -i supabase_db_Convivo psql -X -U postgres -d postgres -v ON_ERROR_STOP=1
|
||||
> ```
|
||||
>
|
||||
> That chain still reports **113 assertions**.
|
||||
|
||||
The SQL fixture is rollback-only: **113 assertions** — six of them added with the
|
||||
gate and the copies (the badge-print suite owns both functions) — cover the gate
|
||||
refusing a session check-in for an attendee with no front-desk check-in
|
||||
@@ -27,8 +45,10 @@ queue to one so the rest of the run is unaffected, plus
|
||||
would print, `3` after the event is changed. The pre-existing "session check-in
|
||||
records / enqueues nothing" case now flips `checked_in` on first, because the
|
||||
gate makes it a precondition.
|
||||
`set_registration_checked_in_tests.sql` (**15 assertions**) covers the admin
|
||||
toggle that grants and revokes the same flag, with its points accounting.
|
||||
`set_registration_checked_in_tests.sql` (**24 assertions**, was 15) covers the
|
||||
admin toggle that grants and revokes the same flag, with its points accounting —
|
||||
see [Points Correctness Regression](#points-correctness-regression) for what the
|
||||
extra nine assert.
|
||||
|
||||
`front-desk-gate.spec.ts` and `welcome-badge-copies.spec.ts` are real-browser
|
||||
suites against the local stack (real Auth + PostgREST + pgmq): they provision a
|
||||
@@ -45,6 +65,63 @@ Settings copies picker saving and reloading.
|
||||
|
||||
See [release record](../releases/2026-10-19.md) for the bug this started with.
|
||||
|
||||
# Points Correctness Regression
|
||||
|
||||
After applying `20261019160000_welcome_points_and_toggle_restore.sql`:
|
||||
|
||||
```sh
|
||||
docker exec -i supabase_db_Convivo psql -X -U postgres -d postgres \
|
||||
-v ON_ERROR_STOP=1 < supabase/tests/leaderboard_tests.sql # 57 assertions
|
||||
docker exec -i supabase_db_Convivo psql -X -U postgres -d postgres \
|
||||
-v ON_ERROR_STOP=1 < supabase/tests/set_registration_checked_in_tests.sql # 24
|
||||
docker exec -i supabase_db_Convivo psql -X -U postgres -d postgres \
|
||||
-v ON_ERROR_STOP=1 < supabase/tests/badge_print_tests.sql # 113
|
||||
CONVIVO_BASE_URL=http://127.0.0.1:3000 npm test --prefix e2e -- checkin-points.spec.ts --project=chromium
|
||||
CONVIVO_ADMIN_URL=http://127.0.0.1:3001 npm test --prefix e2e -- registration-checkin-toggle.spec.ts sessions-view.spec.ts --project=chromium
|
||||
```
|
||||
|
||||
`leaderboard_tests.sql` grew from 47 to **57 assertions**: the front-desk
|
||||
(welcome) check-in now awards **+10** like a session scan, so it asserts the
|
||||
first welcome pays out and lands on the registration, a second welcome pays
|
||||
nothing, welcome-then-session totals 20, and — for each excluded identity (staff
|
||||
pass, Admin contact, `@appe.at`) — that a welcome still checks the person in while
|
||||
awarding **nothing** (`points_awarded = false`, `points = 0`). The excluded-identity
|
||||
loop ends on a non-admin JWT, so the suite restores the admin claims afterwards;
|
||||
without that the tail assertions silently run as the wrong person.
|
||||
|
||||
`set_registration_checked_in_tests.sql` grew from 15 to **24 assertions**, and its
|
||||
third section was **rewritten because it encoded the bug**: it used to assert
|
||||
"points unchanged after re-check-in". It now seeds two real `checkins` rows and
|
||||
asserts the toggle ON re-awards exactly what those rows justify (30), that a
|
||||
second ON adds 0, that an off→on round trip restores 30 both times, and that a
|
||||
staff contact's toggle removes 0 and adds 0.
|
||||
|
||||
`checkin-points.spec.ts` is the end-to-end proof against the **real** database,
|
||||
which is what the original complaint needed (the scanner appeared not to award
|
||||
the +10):
|
||||
|
||||
- **CONV-PTS-001** the welcome check-in pays +10, the confirm sheet promises it
|
||||
*before* the write, the result sheet says `+10 pts · now 10`, the registration
|
||||
reads 10, and `points_log` holds a `checkin=10` row.
|
||||
- **CONV-PTS-002** a second welcome says "No extra points" and stays at 10; the
|
||||
following session scan takes the total to 20.
|
||||
- **CONV-PTS-003** a staff pass still checks in, but the sheets say "does not
|
||||
earn points" / "staff earn no points", the score stays 0 and **no `points_log`
|
||||
row is written** — the exclusion, made visible.
|
||||
- **CONV-PTS-004** drives `set_registration_checked_in` through the real RPC
|
||||
(psql has to supply `request.jwt.claims` because `is_admin()` reads
|
||||
`auth.jwt()`): off removes 20, on restores 20, and a third click adds 0 — no
|
||||
farming.
|
||||
|
||||
`sessions-view.spec.ts` (8 tests) covers the new Sessions view against mocked
|
||||
APIs: nav order Schedule → **Sessions** → Activity, per-session speaker chips and
|
||||
check-in counts, the attendee filter narrowing to that person's sessions and
|
||||
highlighting them in the roster, **one request per session that has feedback**
|
||||
(none for a session without any), the blocking overlay with its `done / total`
|
||||
counter and disabled controls, a partial failure reporting which session failed
|
||||
while the others still land, the stale-summary flag, and the disabled button when
|
||||
the LLM is unconfigured or nothing has feedback.
|
||||
|
||||
# Badge Print Queue Regression
|
||||
|
||||
After applying `20261018170000_badge_print_queue`, run the SQL suite **combined
|
||||
|
||||
Reference in new issue
Block a user