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:
+42
-78
@@ -1,95 +1,59 @@
|
|||||||
# SESSION HANDOFF — C2 (Volunteer `/profile/skills` sliders)
|
# SESSION HANDOFF — C2 (Volunteer `/profile/skills` sliders)
|
||||||
|
|
||||||
**Author:** Tiel-Coder (Ornith variant) · **Date:** 2026-11-18
|
**Date:** 2026-11-18 · **Status:** C2 DONE and committed.
|
||||||
**For:** the next session. Read this first.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## TL;DR — where things stand
|
## TL;DR
|
||||||
|
|
||||||
- **C1 is committed** (`1b34421`) — Skills composer. Done.
|
- **C1 committed** (`1b34421`) — Skills composer.
|
||||||
- **C2 is WRITTEN but NOT committed.** All code + migration + build are done and
|
- **C2 committed** — `user_skills` table, slider API, validation; 55 unit tests
|
||||||
green. Only pending: commit the C2 files, run the runtime smoke test, update
|
green, 18-check runtime smoke green, migration `0005` applied to :5433.
|
||||||
`.agent/PROGRESS.md`.
|
- **App runs on :3000.** Next unit: **C3 — admin skills matrix + verify modal.**
|
||||||
- **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)
|
## ⚠️ Do not blanket-kill `next-server`
|
||||||
|
|
||||||
1. `src/db/schema.ts` — new `user_skills` table (11 cols: id, user_id, skill_id,
|
Previous sessions chased a "stuck build" by running
|
||||||
self_comfort, self_rated_at, verified_level, verified_by, verified_at,
|
`pkill -9 -f next-server`. That process is **pi-web, the agent's own UI host**
|
||||||
mentor_opt_in, last_served_on, notes). Unique index on (user_id, skill_id).
|
(`node …/pi-web`, cwd `…/node_modules/@agegr/pi-web`, Next v16.3.8, port 30141).
|
||||||
Added to the `schema` export. Excluded from `relations` (FK cols on a unique
|
Killing it ends the session, and its supervisor respawns it with a new PID — which
|
||||||
key trip Drizzle 0.45.4 `one()` typing — same as skills/position_skills).
|
looks like "next-server keeps coming back". The project is Next 15.5.29; its app
|
||||||
2. `drizzle/0005_keen_lenny_balinger.sql` — migration (APPLIED to :5433).
|
is identified by **port 3000**, not by process name.
|
||||||
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)
|
To free a port, resolve the PID through the port and only kill that:
|
||||||
|
|
||||||
**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
|
ss -ltnp | grep ':3000'
|
||||||
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)
|
## Running the app (this sandbox)
|
||||||
|
|
||||||
1. **Restart the app** (see blocker above) — health must be 200.
|
`pnpm` is not on PATH here; use the local binaries.
|
||||||
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)
|
DATABASE_URL="postgres://media:media@localhost:5433/media" \
|
||||||
7877421 B4 — Positions + skills + requirements editor
|
NEXTAUTH_URL="http://localhost:3000" NEXTAUTH_SECRET="dev-secret" \
|
||||||
2a359c2 B3: catalog taxonomy CRUD
|
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.
|
||||||
|
|||||||
+39
-1
@@ -297,4 +297,42 @@ Build log for Media Team Hub. One unit per commit, top to bottom. Append after e
|
|||||||
- **Composer endpoint returns a preview, writes nothing.** `POST /api/dev/skills/compose` returns `{ name, dedupeKey }` so the UI prefills the form; the edit-then-submit flow keeps slug + dedupe_key generation server-authoritative in `POST /api/dev/skills`.
|
- **Composer endpoint returns a preview, writes nothing.** `POST /api/dev/skills/compose` returns `{ name, dedupeKey }` so the UI prefills the form; the edit-then-submit flow keeps slug + dedupe_key generation server-authoritative in `POST /api/dev/skills`.
|
||||||
- **No skill/position seed yet.** Per ARCHITECTURE the only seeded artifact is `seed/catalog.json` (later unit). Tables start empty; this unit is the composition layer other units (C2 sliders, C3 matrix) consume.
|
- **No skill/position seed yet.** Per ARCHITECTURE the only seeded artifact is `seed/catalog.json` (later unit). Tables start empty; this unit is the composition layer other units (C2 sliders, C3 matrix) consume.
|
||||||
|
|
||||||
**Next: C2 — volunteer `/profile/skills` sliders (self_comfort) with verified chip.****
|
**Next: C2 — volunteer `/profile/skills` sliders (self_comfort) with verified chip.**
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## C2 — Volunteer profile sliders (self_comfort; verified_level untouched) — DONE 2026-11-18
|
||||||
|
|
||||||
|
**Scope (from BUILD-PLAN.md):** `/profile/skills` sliders — a volunteer rates their own comfort per skill. Governing rule: **two numbers, one truth** — `self_comfort` is the volunteer's signal, `verified_level` is the gate. A slider save must never move `verified_level`, `verified_by`, or `verified_at` (those belong to C3's assessments).
|
||||||
|
|
||||||
|
**Delivered:**
|
||||||
|
- `src/db/schema.ts` — `user_skills` table (ARCHITECTURE §4.3): `id, user_id (FK users, cascade), skill_id (FK skills, cascade), self_comfort (int, nullable), self_rated_at, verified_level (enum, default 'none'), verified_by, verified_at, mentor_opt_in, last_served_on, notes`. Unique index `(user_id, skill_id)`; index on `skill_id`. Excluded from `relations` (FK columns on a unique key trip Drizzle 0.45.4 typing — same as skills/position_skills).
|
||||||
|
- `src/db/userSkills.ts` — `setSelfComfort(userId, skillId, value)` upserts on `(user_id, skill_id)` and writes **only** `self_comfort`/`self_rated_at`; on insert it seeds `verified_level: 'none'`. `getUserSkills(userId)` joins `skills` for display (name/slug), ordered by name.
|
||||||
|
- `src/domain/userSkills.ts` — pure `validateSelfComfort(value)`: null (not yet rated) allowed; otherwise an integer 0–100. No DB imports.
|
||||||
|
- `src/domain/userSkills.test.ts` — 5 tests named after the behaviors.
|
||||||
|
- `src/app/api/dev/user-skills/route.ts` — `GET ?userId=` (records + skill name), `POST { userId, skillId, selfComfort }` (slider save; absent/null clears to "not rated"). Constraint mapping: 23505 → 409 (duplicate record), 23503 → 400 (dangling user/skill).
|
||||||
|
- Migration `drizzle/0005_keen_lenny_balinger.sql`.
|
||||||
|
|
||||||
|
**Verification (all exit 0):**
|
||||||
|
- `tsc --noEmit` ✓ · `eslint .` ✓ · `vitest run` ✓ (**55** total, +5 for C2) · `next build` ✓
|
||||||
|
- `pnpm db:migrate` ✓ → `user_skills` present on :5433 with all 11 columns
|
||||||
|
- Runtime smoke against live app + Postgres on :5433 (`/tmp/c2.sh`, **18 checks**):
|
||||||
|
- save slider 60 → 200, persisted; `verified_level` = `none` ✓
|
||||||
|
- set an existing `verified_level='verified'` + `verified_at`, then move slider to 85 → comfort updated, **verified level and `verified_at` unchanged** (the C2 rule) ✓
|
||||||
|
- 101 and 60.5 → 400 (range/integer validation) ✓
|
||||||
|
- POST with no `selfComfort` → 200, cleared to null ✓
|
||||||
|
- dangling user/skill id → 400 (not 500) ✓
|
||||||
|
- test rows cleaned up (catalog + `user_skills` back to 0)
|
||||||
|
|
||||||
|
**Session blocker — root cause + fix (recorded for future reference):**
|
||||||
|
- **Reported** as "build/restart keeps killing the session" and "stale `next-server` won't die".
|
||||||
|
- **Root cause:** the process being killed (`pkill -9 -f next-server`) was **pi-web — the agent's own UI host** (`node …/pi-web`, cwd `…/node_modules/@agegr/pi-web`, Next **v16.3.8**, port 30141). The project is Next **15.5.29**, and nothing from it was listening on :3000. Killing pi-web terminated the session; its supervisor respawned it with a new PID, which looked like "next-server keeps respawning". The build was never hanging — `next build` finishes in ~30s.
|
||||||
|
- **Also:** `pnpm` is not on PATH for this shell, and `/tmp/start_app.sh` did not exist (fresh `/tmp`). Use `./node_modules/.bin/{next,tsc,vitest,eslint}` directly.
|
||||||
|
- **Fix:** never blanket-kill `next-server`. Start the project app as a background process on :3000 (`DATABASE_URL=postgres://media:media@localhost:5433/media PORT=3000 ./node_modules/.bin/next start`); it reaches `Ready` in <1s and `/api/health` returns 200. If a port must be freed, find the PID via `ss -ltnp | grep :3000`, never by process name.
|
||||||
|
|
||||||
|
**Decisions:**
|
||||||
|
- **Slider writes are narrow by construction.** `setSelfComfort`'s `onConflictDoUpdate` sets only `selfComfort`/`selfRatedAt`; the verified columns are not in the update set at all, so the rule holds without a read-then-write race.
|
||||||
|
- **Null is the "not rated" state**, not 0. Omitting `selfComfort` clears the rating and its timestamp — it never invents a 0% score.
|
||||||
|
- **Unique (user, skill), not a history table.** C2 keeps one current self-rating per pair; the append-only history for verification lives in C3's `skill_assessments`.
|
||||||
|
|
||||||
|
**Next: C3 — admin skills matrix + verify-level modal.**
|
||||||
|
|||||||
Reference in New Issue
Block a user