Selection filters on kinds, types and phases — and selectForInjection finally carries them
Make the three axes filterable, and open the seam that has kept every existing filter unreachable.
listForInjection already models the pattern: AND "categories" && ARRAY[…]::text[], omitted entirely when nothing is supplied. Copy that shape for kinds, types and phases — three independent clauses, each omitted when its axis is not asked for, so a lesson unconstrained on an axis matches every query on it.
The seam is the point. SelectForInjectionInput is { aiProjectId, queryText, phase, limit } and both planner call sites go through it, so no planning selection has ever narrowed on anything but mistakeTypes. Add the three axes to that input and pass them down.
mistakeTypes is untouched and keeps its job: it answers which consumer (onboarding_planning / regular_planning / coding / planning_craft), and the 2026-06-20 decision that a planner reads its own bucket plus planning_craft still stands. The new axes answer which card, underneath it.
captureMistake currently writes no axes at all. Give it the three, recorded when its caller supplies them.
Acceptance criteria
listForInjectionaccepts optionalkinds,typesandphasesand applies one overlap clause per axis, each omitted when that axis is empty.- The three axes are independent: a query naming only
typesdoes not constrainkindsorphases. SelectForInjectionInputcarries all three and passes them through unchanged.captureMistakepersists supplied axes and writes empty sets when none are given.- A call supplying no axes returns the same rows in the same order as today, asserted against the existing selection test.
mistakeTypesbehaviour is unchanged, asserted.pnpm typecheckclean; the lesson suites pass.
Context refs
motir-aisrc/repositories/lessonRepository.ts— the&&overlap clause and its omit-when-empty behaviour, the pattern to follow.motir-aisrc/services/lessonService.ts—SelectForInjectionInput,selectForInjection,captureMistake, and the comment recording the phase-bucket-plus-craft decision.motir-aitests/lessonInjection.test.ts.- MOTIR-3299 — the columns and vocabularies this reads.