Files
2026-11-20 04:07:02 +00:00

61 lines
3.3 KiB
Markdown

# D9 Auto-Fill — Completed (superseded by PROGRESS.md)
**Status:** DONE 2026-11-18. D10 (publish/unpublish) is also DONE. Next unit: **E1 — outbox**.
The canonical record is `.agent/PROGRESS.md` (D9 + D10 sections); this file keeps only the
resolution notes so the next agent does not chase already-fixed bugs.
## What was actually wrong (the handoff's two bugs)
### 1. `written` < `proposals.length`
Not a counting bug. `computeAutoFill` selected "open seats" by `slots.status = 'open'`, but
nothing maintains that column — D8 writes `assignments` only. The seed's confirmed Audio seat
still read `open`, was re-proposed, and `applyAutoFill` correctly skipped it (the seat already
had an active assignment).
**Fix:** an open seat is now ``slots.status = 'open' AND NOT EXISTS (active assignment)``
(correlated `EXISTS` over `proposed`/`confirmed`/`completed`). Proposals no longer include filled
seats, so `written === proposals.length` and a second apply proposes nothing.
### 2. `firstInstanceId()` 401 in the volunteer test
The helper called the coordinator-gated `/api/dev/schedule/instances` route *after* signing in as
a volunteer.
**Fix:** the id is resolved once in `beforeAll` under the admin session; the shared helper now
lives in `e2e/dev.ts` and both suites import it.
## Other defects found while reviewing the D9 code
- **Monthly cap was dead code.** `monthlyServiceCount` was resolved in the data layer but never
read, so rule 7 never applied (the walk started every volunteer at 0). `walkCount` is now
seeded from each candidate's existing monthly count; the two monthly-cap tests were rewritten
so they actually fail without the fix (they previously passed by tie-break accident).
- **Timezone-dependent date math.** `isoLocal()` used local `getFullYear/getMonth/getDate` on
`occurs_on` (a UTC-midnight `date` column) — the D7 day-shift trap. Now UTC calendar date;
`last_served_on` is used as its stored `YYYY-MM-DD` string.
- **`serviceName` was always null** in the instances helper route (`title_override` only). It now
joins `services`, falls back to the template name, orders by `(occurs_on, starts_at)`, and
returns `status`.
- Removed the `as never` cast on blackout rows (explicit mapping) and the always-true
`adminApproved: verifiedLevel != null` in the mentor-ready input.
## Verification (all green)
- `tsc --noEmit` ✓ · `eslint .` ✓ · `vitest run` ✓ (**199** total) · `next build` ✓
- Playwright **12/12** on a freshly built `next start`:
`assign-mutations` (2), `auto-fill` (2), `publish` (2), `schedule-grid` (2), `shell`+health (4)
- Seed change: the second Sunday is seeded `draft` so the publish flow has a week to publish; the
grid still opens on the published first week.
## Running locally (this shell has no `pnpm`)
```bash
DATABASE_URL="postgres://media:media@localhost:5433/media" NEXTAUTH_SECRET="e2e-secret-for-shell-tests" \
./node_modules/.bin/next build
DATABASE_URL="postgres://media:media@localhost:5433/media" NEXTAUTH_SECRET="e2e-secret-for-shell-tests" \
AUTO_ACTIVATE_NEW_USERS=true PORT=3000 ./node_modules/.bin/next start &
./node_modules/.bin/playwright test # reuses the running server
```
Free port 3000 by PID from `ss -ltnp | grep :3000` — killing by the process *name* also kills the
agent's own UI host (see `.agent/PROGRESS.md` C2 session blocker).