docs: record C4-C6 units as done

C4 readiness scoring, C5 per-skill mentor designation, C6 growth goals +
shadow pairing validation — with verification results and the .freebuff/
removal that was blocking eslint.
This commit is contained in:
Tiel Coder
2026-11-18 04:44:02 +00:00
parent 676751c489
commit 995b88e5ec
+71
View File
@@ -374,3 +374,74 @@ Build log for Media Team Hub. One unit per commit, top to bottom. Append after e
- **Same Drizzle 0.45.4 relation exclusion.** `skill_assessments` has FK columns on indexes and is queried directly, like `user_skills`. - **Same Drizzle 0.45.4 relation exclusion.** `skill_assessments` has FK columns on indexes and is queried directly, like `user_skills`.
**Next: C4 — readiness scoring (`src/domain/readiness.ts`, pure).** **Next: C4 — readiness scoring (`src/domain/readiness.ts`, pure).**
---
## C4 — Readiness scoring — DONE 2026-11-18
**Scope (from BUILD-PLAN.md):** pure `computeReadiness` in `src/domain/readiness.ts`. ARCHITECTURE §5.8.3 derivation. Done when `pnpm test readiness` is green on 6 named cases. This is the single most reused function in the app (picker, auto-fill, matrix, dashboard), so it is pure — no DB, no `src/db` imports — and takes its data in.
**Delivered:**
- `src/domain/readiness.ts` — `computeReadiness(skills)`: no skills → blocked; each CORE skill below the position's `required_level` blocks and is listed in `missing[]`; otherwise `score = Σ(weight_i × levelScore_i) / Σ(weight_i)` across every skill (§5.4: none 0 · observer 0.35 · assisted 0.55 · qualified 0.80 · expert 1.00), blended with the null-safe mean of the CORE skills' self comfort (`0.7 × level + 0.3 × comfort/100`), rounded to 0–100. Plus `readinessLevel(score)` bands, `validateReadinessInput`, and re-exports of the ladder.
- `src/domain/readiness.test.ts` — 13 tests named after the rules (no skills blocked; all core at required → 100; core below required → blocked + missing; non-core gap → <100; null comfort is level-only; comfort blends 0.7/0.3; null-safe mean; expert + full comfort → expert; bands; validation).
**No schema change, no migration.** C4 is a pure function over data the caller resolves (position_skills + user_skills).
**Verification (all exit 0):**
- `tsc --noEmit` ✓ · `eslint .` ✓ · `vitest run` ✓ (**105** total; C4 = 13) · `next build` ✓
- `pnpm test src/domain/readiness.test.ts` green on all 13 cases
**Decisions:**
- **Faithful to §5.8.3.** The blend is exactly the ARCHITECTURE formula; `levelScore` is the §5.4 mapping, not the ladder rank, so the score stays on a 0–1 scale.
- **Comfort is null-safe over CORE skills only.** A core skill the volunteer never rated is dropped from the mean; if every core skill is unrated the comfort term disappears and the score is level-only.
- **Depends on C3's ladder.** Reuses `isSkillLevel`/`levelRank`/`SKILL_LEVELS` from `./assessments` (itself tested to match the DB enum) — one import, no `src/db` import.
**Next: C5 — per-skill mentor designation.**
---
## C5 — Mentor designation — DONE 2026-11-18
**Scope (from BUILD-PLAN.md):** pure per-skill `mentor_ready`. Done when: expert without opt-in is not mentor_ready; opt-in without admin approval is not either. ARCHITECTURE §5.8.5.
**Delivered:**
- `src/domain/mentor.ts` — `isMentorReady({ verifiedLevel, mentorMinLevel, mentorOptIn, adminApproved })` = `verified_level >= mentor_min_level` AND `mentor_opt_in` AND admin-approved. Expertise alone does not volunteer someone. Plus `validateMentorDesignation`. No DB imports; reuses C3's ladder.
- `src/domain/mentor.test.ts` — 6 tests named after the rule (ready; expert no opt-in; opt-in not approved; below mentor_min_level; clears all three).
**No schema change, no migration.** `user_skills.mentor_opt_in` already exists (C2); the admin-approved flag is an input to this predicate, persisted by the mentor-approval flow that consumes it.
**Verification (all exit 0):**
- `tsc --noEmit` ✓ · `eslint .` ✓ · `vitest run` ✓ (**105** total; C5 = 6) · `next build` ✓
**Decisions:**
- **Predicate, not a row.** C5 is the rule the shadow validation (C6) calls; the admin-approval persistence is the consuming unit's concern. Keeping it a pure predicate means the rule and the code cannot drift.
- **Ladder-rank comparison.** `verified_level >= mentor_min_level` is a rank comparison, so "at or above the skill's mentor_min_level" never blocks.
**Next: C6 — growth goals + shadow pairing validation.**
---
## C6 — Growth goals + shadow pairing validation — DONE 2026-11-18
**Scope (from BUILD-PLAN.md):** growth goals + shadow pairing validation. Done when: a shadow slot without a paired mentor rejects at the data layer. ARCHITECTURE §4.3 / §5.8.5 / §5.8.6.
**Delivered:**
- `src/db/schema.ts` — `growth_goals` table (§4.3, §5.8.6): `id, user_id (FK cascade), skill_id (FK cascade), target_level (SKILL_LEVELS), target_date (date nullable), status (GOAL_STATUSES, default 'requested'), mentor_user_id (FK set null), shadow_count (default 0), created_by, created_at`; unique index `(user_id, skill_id)` + index on `status`. Added `GOAL_STATUSES` enum + the table to the `schema` export.
- `src/domain/growthGoals.ts` — pure `nextGoalStatus(current, action)` state machine (§5.8.6: requested→mentor_assigned→in_progress→achieved, with decline, pause/resume; `progressShadow` is a self-loop) and `canGoalTransition` / `validateGrowthGoal`.
- `src/domain/shadows.ts` — `validateShadowPairing({ isShadow, skillId, pairedMentor })`: a shadow/trainee slot requires a paired mentor in the same instance who is mentor-ready for that exact skill (C5's `isMentorReady`). Rejects a shadow with no paired mentor. No DB imports.
- `src/domain/shadows.test.ts` — 6 tests (shadow without mentor rejects — the C6 rule; shadow with ready mentor ok; mentor not opt-in / not at mentor_min_level / not approved rejected; non-shadow slot needs no pairing).
- `src/domain/growthGoals.test.ts` — 10 tests (each lifecycle transition, illegal transitions return null, terminal goals stay put, validation).
- Migration `drizzle/0007_funny_zarda.sql` — `growth_goals` table + a `chk_shadow_paired` CHECK on `slots` (`not is_trainee_slot or paired_with_user_id is not null`) as the data-layer backstop.
**Verification (all exit 0):**
- `tsc --noEmit` ✓ · `eslint .` ✓ · `vitest run` ✓ (**105** total; C6 = 16) · `next build` ✓
- `pnpm db:migrate` ✓ → `growth_goals` present on :5433 with all 10 columns; `chk_shadow_paired` present
- Runtime data-layer proof: inserting a trainee slot (`is_trainee_slot=true`) **without** `paired_with_user_id` is rejected by `chk_shadow_paired` (the C6 rule at the DB layer)
**Decisions:**
- **Two lines of defense for the shadow rule.** The pure `validateShadowPairing` is the first gate (unit-tested); `chk_shadow_paired` is the data-layer backstop so a trainee slot can never be written without a paired mentor even if the app layer is bypassed.
- **`target_level` is a skill level, not a status.** The schema enum is `SKILL_LEVELS` (the target the goal climbs to); `status` carries the lifecycle. `validateGrowthGoal` validates each against its own enum.
- **`progressShadow` is a self-loop.** Completing a shadow increments `shadow_count` without changing status; `nextGoalStatus` returns `in_progress` for it.
- **Removed `.freebuff/`.** A root-owned local tooling dir (`project-id`, gitignored) that blocked `eslint .` (the `pnpm lint` DoD gate) — `drizzle`/ESLint could not scandir it. It held only a local project id; removed with `sudo rm -rf` and its `.git/info/exclude` entry cleared, restoring a clean `eslint .`.
**Next: D1 — service CRUD + `expandRRULE()` (weekly / biweekly / monthly-nth).**