Files
glenloch-media/.agent/HANDOFF-C2.md
T

96 lines
4.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# SESSION HANDOFF — C2 (Volunteer `/profile/skills` sliders)
**Author:** Tiel-Coder (Ornith variant) · **Date:** 2026-11-18
**For:** the next session. Read this first.
---
## TL;DR — where things stand
- **C1 is committed** (`1b34421`) — Skills composer. Done.
- **C2 is WRITTEN but NOT committed.** All code + migration + build are done and
green. Only pending: commit the C2 files, run the runtime smoke test, update
`.agent/PROGRESS.md`.
- **App is DOWN on :3000** right now — stale `next-server` processes are holding
the port but not listening. Kill them and restart via `/tmp/start_app.sh`.
- **DB migration `0005` (user_skills) IS applied** to Postgres on :5433.
## What C2 delivered (all written, typecheck/lint/test green)
1. `src/db/schema.ts` — new `user_skills` table (11 cols: id, user_id, skill_id,
self_comfort, self_rated_at, verified_level, verified_by, verified_at,
mentor_opt_in, last_served_on, notes). Unique index on (user_id, skill_id).
Added to the `schema` export. Excluded from `relations` (FK cols on a unique
key trip Drizzle 0.45.4 `one()` typing — same as skills/position_skills).
2. `drizzle/0005_keen_lenny_balinger.sql` — migration (APPLIED to :5433).
3. `src/db/userSkills.ts` — data layer: `setSelfComfort(userId, skillId, value)`
(upsert, updates ONLY self_comfort/self_rated_at, NEVER verified_level) and
`getUserSkills(userId)` (join to skills for display).
4. `src/domain/userSkills.ts` — pure `validateSelfComfort(value)` (0–100 int, or
null). No DB imports.
5. `src/domain/userSkills.test.ts` — 5 tests named after behaviors.
6. `src/app/api/dev/user-skills/route.ts` — `GET ?userId=` (list records),
`POST { userId, skillId, selfComfort }` (set slider). dbError maps 23505→409
(dup), 23503→400 (dangling FK).
## C2 core rule (the whole point)
**Two numbers, one truth.** `self_comfort` is the volunteer's signal;
`verified_level` is the gate. Setting a slider MUST NOT move `verified_level`
(or verified_by/verified_at — those are C3's `skill_assessments`). C2 E2E
criterion: *move slider → save → reload shows value; verified level unchanged.*
## Environment (do not forget)
- **App:** `http://localhost:3000` · start: `setsid /tmp/start_app.sh >/tmp/app.log 2>&1 </dev/null &`
(env: DATABASE_URL=postgres://media:media@localhost:5433/media, NEXTAUTH_URL=http://localhost:3000, PORT=3000).
- **DB:** Postgres on **:5433** (NOT 5432). `PGPASSWORD=media psql -h localhost -p 5433 -U media -d media`.
- **Migrate:** `DATABASE_URL="postgres://media:media@localhost:5433/media" pnpm db:migrate`
(drizzle.config reads DATABASE_URL; it's not in the shell env by default).
- **Build:** `pnpm build` (required after schema/route changes).
- **Sudo password:** `Linux1981` (use `echo "Linux1981" | sudo -S <cmd>`).
## CURRENT BLOCKER — app not running
`next-server` processes are stuck (port 3000 not listening, health 000). Kill
them (they respawn oddly; use sudo if plain kill fails):
```
echo "Linux1981" | sudo -S pkill -9 -f next-server
sleep 2
setsid /tmp/start_app.sh >/tmp/app.log 2>&1 </dev/null &
sleep 7
curl -s -o /dev/null -w "%{http_code}\n" http://localhost:3000/api/health # want 200
```
## PENDING (next session)
1. **Restart the app** (see blocker above) — health must be 200.
2. **Runtime smoke test** for C2 (`/tmp/c2.sh` — write it):
- seed a user + a skill (catalog is empty; use existing seed rows or create
a category/vendor/technology/function + skill via /api/dev/catalog).
- `POST /api/dev/user-skills { userId, skillId, selfComfort: 60 }` → 200.
- `GET /api/dev/user-skills?userId=` → self_comfort == 60, verified_level
still "none" (unchanged). **This is the C2 assertion.**
- `POST selfComfort: 101` → 400 (range validation).
- `POST { userId, skillId }` with no selfComfort → 200, self_comfort null.
3. **Commit C2** — `git add -A && git commit -m "C2 — Volunteer profile sliders (self_comfort; verified_level untouched)"`.
4. **Update `.agent/PROGRESS.md`** — append a C1/C2 entry (see B4/C1 format in
the file's history). Mark C2 DONE, set Next: C3.
5. Clean up any test rows you created (leave catalog + user_skills empty for seed).
## Next unit: C3 — Admin skills matrix + verify-level modal
- Depends: C1. Writes `skill_assessments` (append-only) and updates
`verified_level` on `user_skills`.
- E2E: verify writes an assessment row + updates level; audit row exists.
## Git state (for reference)
```
1b34421 C1 — Skills composer (committed)
7877421 B4 — Positions + skills + requirements editor
2a359c2 B3: catalog taxonomy CRUD
```
C2 files are uncommitted (see `git status`). Migration `0005` already applied.