docs: mark C2 done and document the pi-web kill trap

Records the corrected app start procedure so a future session does not
kill its own host process when the app looks stuck.
This commit is contained in:
Tiel Coder
2026-11-18 04:14:10 +00:00
parent a77f47d5bd
commit a915e4236c
2 changed files with 81 additions and 79 deletions
+42 -78
View File
@@ -1,95 +1,59 @@
# SESSION HANDOFF — C2 (Volunteer `/profile/skills` sliders)
**Author:** Tiel-Coder (Ornith variant) · **Date:** 2026-11-18
**For:** the next session. Read this first.
**Date:** 2026-11-18 · **Status:** C2 DONE and committed.
---
## TL;DR — where things stand
## TL;DR
- **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.
- **C1 committed** (`1b34421`) — Skills composer.
- **C2 committed** — `user_skills` table, slider API, validation; 55 unit tests
green, 18-check runtime smoke green, migration `0005` applied to :5433.
- **App runs on :3000.** Next unit: **C3 — admin skills matrix + verify modal.**
## What C2 delivered (all written, typecheck/lint/test green)
## ⚠️ Do not blanket-kill `next-server`
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).
Previous sessions chased a "stuck build" by running
`pkill -9 -f next-server`. That process is **pi-web, the agent's own UI host**
(`node …/pi-web`, cwd `…/node_modules/@agegr/pi-web`, Next v16.3.8, port 30141).
Killing it ends the session, and its supervisor respawns it with a new PID — which
looks like "next-server keeps coming back". The project is Next 15.5.29; its app
is identified by **port 3000**, not by process name.
## 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):
To free a port, resolve the PID through the port and only kill that:
```
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
ss -ltnp | grep ':3000'
```
## PENDING (next session)
## Running the app (this sandbox)
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)
`pnpm` is not on PATH here; use the local binaries.
```
1b34421 C1 — Skills composer (committed)
7877421 B4 — Positions + skills + requirements editor
2a359c2 B3: catalog taxonomy CRUD
DATABASE_URL="postgres://media:media@localhost:5433/media" \
NEXTAUTH_URL="http://localhost:3000" NEXTAUTH_SECRET="dev-secret" \
AUTO_ACTIVATE_NEW_USERS="true" PORT=3000 \
./node_modules/.bin/next start # run as a background/detached process
```
C2 files are uncommitted (see `git status`). Migration `0005` already applied.
Ready in <1s; `curl localhost:3000/api/health` → 200.
- **DB:** Postgres on **:5433** (docker), not 5432.
`PGPASSWORD=media psql -h localhost -p 5433 -U media -d media`
- **Migrate:** `DATABASE_URL="postgres://media:media@localhost:5433/media" ./node_modules/.bin/drizzle-kit migrate`
- **Checks:** `./node_modules/.bin/{tsc --noEmit | eslint . | vitest run | next build}`
- No sudo needed for any of the above. `/tmp/start_app.sh` no longer exists.
## What C2 guarantees
Two numbers, one truth: `self_comfort` (volunteer's slider, 0–100 int or null)
is the signal; `verified_level` is the gate. `setSelfComfort` updates only
`self_comfort`/`self_rated_at` on conflict, so moving a slider can never move a
verified level or its audit columns (C3 owns those).
## Next: C3 — Admin skills matrix + verify-level modal
- Writes `skill_assessments` (append-only) and updates `verified_level` on
`user_skills` (+ `verified_by`/`verified_at`).
- E2E: verify writes an assessment row + updates the level; audit row exists.