# Coaching data source skill — enablement

*What this source is good for and worked compositions a reader can run as written. Each composition names its pins (the dictionary
sections it depends on), the query, today's answer and how it goes wrong. Meanings and columns: `DICTIONARY.md`. Run a query with
`sqlite3 <store> "<sql>"`; the stores are named in DICTIONARY §10. A reader with the skill and an API key starts at Composition 0:
the production read API serves the same rows (DICTIONARY §10.10 names the route of each store), so a composition's SQL becomes a filter
over the rows a route returns. Each composition gives its SQL (the reference stores) and **Over the API**, the same filter over the read API's rows. Answers below are as of
2026-10-19 unless dated otherwise (compositions 4–6, 8 and 8b were last measured on 2026-10-09); re-run them rather than quoting them.
Coach findings and the couldn't-run ending stop after early October (DICTIONARY trap 26): compositions 4 and 5 cover earlier weeks only. Names are allowed in answers (ruling 2026-10-23): the reader routes serve ids, and names come from TimeBack or the platform.
Scope (DICTIONARY §0): everything from 2026-08-12; session counts (compositions 2, 3, 7) count every coaching session; student measures
(compositions 1, 4, 5, 6, 8) count academic coaching only.*

## Capabilities — the questions this source answers
| Someone asks… | Compose |
|---|---|
| "Which students needed coaching yesterday and didn't get it?" | ledger, `needed_coaching_not_reached` on the last judged day (1) |
| "Are we hitting 200 completed sessions a day?" | sessions, `ending_final` = completed per school day (2) |
| "What's the no-show rate this month?" | sessions, `ending_final` (3) |
| "Is coaching working?" | outcomes (session level) and the matched comparison (program level) (4) |
| "What blocks students in Math?" | sessions, `blocker` on completed academic sessions (5) |
| "Who keeps coming back?" | sessions, completed academic sessions per student over 20 school days (6) |
| "Are coaches missing sessions?" | sessions, `ending_final` = coach_no_show (7) |
| "How long do students wait for a session?" | sessions, `wait_school_days` where trusted (8) |
| "What happened to one student in one subject?" | ledger row → its sessions → its outcome (9) |

Route away: open slots, booking demand and lead time are the coaching platform's own metrics (DICTIONARY §9); a student's learning-risk
categories are the Academic Support skill's; lesson-level detail is the TimeBack skill's.

## Composition 0 — Read the source through the read API (no reference stores)
**Question.** What does the served source say — the night it was built, the headlines, a week's sessions, a judged day's ledger — for a
reader who holds only the documents and an API key, or TimeBack credentials with admin access?
**Pins.** DICTIONARY §10.10 (the read API: routes, parameters, shapes, paging, errors) · §10.1, §10.2, §10.4 (every column) · §10.7 (every
figure) · §17 (freshness). Credentials, kept in `~/.claude/coaching-api.env`: `COACHING_API_URL` and either the key issued per person
(`COACHING_API_KEY`, header `x-api-key`) or, with TimeBack admin access, `TIMEBACK_CLIENT_ID` / `TIMEBACK_CLIENT_SECRET` (routes under
`/timeback`, Basic auth; the API gets and refreshes the TimeBack token).
```
B=$COACHING_API_URL; H="x-api-key: $COACHING_API_KEY"
curl -s "$B/health"                                                     # no key: {"status":"ok", ...}
curl -s "$B/runs" -H "$H"                                               # every load: as_of, source_commit, full_run_at, steps (quote them)
curl -s "$B/headlines" -H "$H"                                          # the four headlines (§10.7 headlines)
curl -s "$B/sessions?from=<monday>&to=<sunday>&limit=2000" -H "$H"      # §10.1 rows; follow next_cursor until null
curl -s "$B/ledger?day=<day>" -H "$H"                                   # §10.2 rows of one judged day
curl -s "$B/outcomes?from=<day>&to=<day>&limit=2000" -H "$H"            # §10.4 rows by session day
curl -s "$B/datasets/sessions_weekly" -H "$H"                           # any §10.7 dataset; /datasets/outcome_matched is §10.5

# with TimeBack admin access instead: the same routes under /timeback, your TimeBack client ID and secret (or -H "Authorization: Bearer <token>")
B=$COACHING_API_URL/timeback; A=(-u "$TIMEBACK_CLIENT_ID:$TIMEBACK_CLIENT_SECRET")
curl -s "$B/runs" "${A[@]}"                                             # as above; /health stays at $COACHING_API_URL/health
curl -s "$B/people?limit=2000" "${A[@]}"                                # the drill-down rows with student and coach names
curl -s "$B/sessions/<session_id>" "${A[@]}"                            # one session in full, with its Meet transcript
```
Compose: completed sessions in a week = rows of `/sessions` in the week with `ending_final` = completed (every session type), and they
equal that week's `completed` in `/datasets/sessions_weekly`; the students judged on a day = `/ledger?day=` rows with `in_reach_school` = 1 and
`coached_next_day_what` set, and they equal that day's students in `/datasets/reach_outcomes`; outcome results per week = `/outcomes` rows by
`week` and `result`, equal to `/datasets/outcome_weekly`. `datasource/smoke.py` runs these three recounts.
**Failure modes.** (1) Reading one page as the whole list: follow `next_cursor` to null. (2) Quoting a figure without its night: name `as_of`
and `full_run_at` from `/runs`, and a step's own `at` when a step ran later (§17). (3) Expecting names on key routes, or the Meet store, QC
or the platform store on the wire: names are served to TimeBack admins only (`/timeback`), the stores not at all (§10.10). (4) Keeping `session_rows.k` across nights: the keys are random per export. (5) A TimeBack 401 or 403: an expired token (get a new
one, or use the client ID and secret) or credentials without TimeBack admin access.

## Composition 1 — Who needed coaching on a day and didn't get it?
**Pins.** DICTIONARY §10.2 category 1 (first day of an unproductive-time episode, FastMath and Vocabulary excluded; NO academic session
offered in the subject that day or the next school day: a cancelled session isn't an offer, a no-show is, and goes to the no-show category;
judged only once the next school day has ended; every school). "Reached" here means OFFERED a session. For the dashboard's Reach section — coached by the next school day (a COMPLETED session,
physical private schools only) — use `coached_next_day` with `in_reach_school = 1`.
```sql
-- store: truthfinder/data/ledger.sqlite
select subject, count(*) from ledger where day = '2026-10-07' and needed_coaching_not_reached = 1 group by 1 order by 2 desc;
select count(*) from ledger where day = '2026-10-07' and needed_coaching_not_reached = 0;   -- offered a session
select sum(coached_next_day), count(*) from ledger where day = '2026-10-07' and in_reach_school = 1 and coached_next_day is not null; -- coached by the next school day
```
**Over the API.** `GET /ledger?day=2026-10-07` → rows with `needed_coaching_not_reached` = 1, by `subject`; = 0 for offered; `in_reach_school` = 1 and `coached_next_day` not NULL for coached (sum of `coached_next_day` over the count).
**Answer (2026-10-07).** 168 student-subjects had no session offered by the end of Oct 8: Reading 80, Math 47, Language 22, Writing 13,
Science 6; 4 were offered one. At physical private schools, 1 of 70 got coached (completed a session) by the end of Oct 8.
**Failure modes.** (1) Yesterday's day is NULL until today ends: ask for the last day with any 0 or 1. (2) It counts student-subjects; a
student struggling in two subjects counts twice; use `count(distinct student_key)` for students. (3) A row whose student had a session in
another subject still fires: category 1 is per subject by definition. (4) "Not reached" (category 1) and "coached by the next school day"
(the Reach section) differ on purpose: category 1 covers every school and counts any offered session; coached by the next school day counts
completed sessions at physical private schools only.

## Composition 2 — Completed sessions a day against the target
**Pins.** DICTIONARY §4 (completed = `ending_final` completed), §0 scope (a session count: every coaching session type). Target: 200
completed sessions a school day (brainlift, capacity plan).
```sql
-- store: datasources/sessions/data/sessions.sqlite
select session_date, count(*) from sessions
 where ending_final = 'completed' and session_date between '2026-09-28' and '2026-10-02' group by 1;
```
**Over the API.** `GET /datasets/sessions_weekly` (`completed` per week ÷ the week's school days), or `GET /sessions?from=&to=` (follow `next_cursor`) counting `ending_final` = completed.
**Answer (week of 2026-09-28).** 356 completed in five school days (80, 71, 66, 76, 63): about 71 a day, a third of the target. From
2026-10-05 couldn't-run sessions count as completed (trap 26), so later weeks read slightly high against earlier ones.
**Failure modes.** (1) The current week reads low until coaches and Meet catch up: the dashboard headline shows this week so far (completed school days only); for a settled figure, use the last full week. (2) Use `ending_final`, never
`ending_recorded` (DICTIONARY trap 17). (3) It counts every coaching session type, as the target does; `session_type = 'academic'`
alone answers a different question.

## Composition 3 — No-show rate for a period
**Pins.** DICTIONARY §4: no-show rate = no-shows ÷ (no-shows + completed), where no-shows are `no_show` and `no_show_unconfirmed`;
coach no-shows, short sessions and cancellations are in neither part; every coaching session type.
```sql
select sum(ending_final in ('no_show','no_show_unconfirmed')), sum(ending_final in ('no_show','no_show_unconfirmed','completed')),
       round(100.0 * sum(ending_final in ('no_show','no_show_unconfirmed'))
             / sum(ending_final in ('no_show','no_show_unconfirmed','completed')))
  from sessions where session_date between '2026-10-01' and '2026-10-08';
```
**Over the API.** `GET /sessions?from=&to=` → `ending_final` in (no_show, no_show_unconfirmed) over those plus `ending_final` = completed; the weekly series is `GET /datasets/sessions_weekly` (`no_show_rate`).
**Answer (October 1–8).** 244 of 693: 35%.
**Failure modes.** (1) Before 2026-09-08 there are no Meet records and the platform's own no-shows stand, which are inflated (trap 17).
(2) A student's no-show predicts the next: compute it per student in order of `scheduled_at` if asked.

## Composition 4 — Is coaching working?
**Pins.** DICTIONARY §7 (two questions, kept apart: did the session leave the student better on their own; does coaching add value), §10.4, §10.5.
**Did sessions leave students better on their own?**
```sql
-- store: truthfinder/data/outcome.sqlite
select count(*), sum(result in ('unblocked','unblocked_still_unproductive')) from outcomes
 where result in ('unblocked','unblocked_still_unproductive','not_unblocked');
select subject, round(100.0 * avg(result in ('unblocked','unblocked_still_unproductive'))) from outcomes
 where result in ('unblocked','unblocked_still_unproductive','not_unblocked') group by 1;
```
**Over the API.** `GET /outcomes?from=&to=` → counts by `result`; the rate is (unblocked + unblocked_still_unproductive) ÷ (those + not_unblocked); the matched comparison is `GET /datasets/outcome_matched` (`body`).
**Answer.** 236 of 457 judged sessions (52%), sessions from 2026-08-12 to 09-24: Science 61%, Reading 58%, Language 53%, Math 45%, Vocabulary 25%;
141 already passing, 460 too little work and 511 not yet judged are outside the rate.
**Does coaching add value?** Read `truthfinder/data/outcome_matched.json`, fields `all` and `pace.all`.
**Answer.** Against similar uncoached students, first-try pass rate −1.3 points (95% interval −3.2 to +0.6, 447 sessions); minutes per XP
−2.0% (−6.4 to +2.5). In Language, 20.2% fewer minutes per XP (−29.6 to −10.6) but 5.2 points fewer first-try passes.
**Failure modes.** (1) Quoting 52% as coaching's effect: it includes recovery that would have happened anyway. (2) Quoting the matched
comparison as causal. (3) Including already passing or too little work in the rate.

## Composition 5 — What blocks students in a subject?
**Pins.** DICTIONARY §5 (four blockers; couldn't run and unclear are non-answers), §10.1 `blocker`.
```sql
select blocker, count(*) from sessions
 where session_type = 'academic' and ending_final = 'completed' and subject = 'Math'
   and session_date >= '2026-08-12' and blocker in ('no coaching need','motivation failure','app guidance failure','curriculum failure')
 group by 1 order by 2 desc;
```
**Over the API.** `GET /sessions?from=&to=` → `session_type` = academic, `ending_final` = completed, the subject, `blocker` one of the four findings, counted by `blocker`; `GET /datasets/subject_findings` is the year-to-date view.
**Answer (Math, 2026-08-12 on).** app guidance failure 142, curriculum failure 140, no coaching need 95, motivation failure 20.
**Failure modes.** (1) Using `blocker_dropdown` (the coach's dropdown) instead of `blocker`. (2) Counting sessions with no description
(`blocker` NULL) as no coaching need.

## Composition 6 — Heavy users and growing dependence
**Pins.** DICTIONARY §10.7 (heavy users: 5+ completed academic sessions in the last 20 school days).
```sql
with c as (select student_id, count(*) n from sessions
  where session_type = 'academic' and ending_final = 'completed' and student_id is not null
    and session_date between '2026-09-11' and '2026-10-08' group by 1)
select sum(n >= 5), sum(case when n >= 5 then n end), sum(n), count(*) from c;
```
**Over the API.** `GET /sessions?from=&to=` (the last 20 school days) → completed academic sessions per `student_id`; `GET /datasets/dependence_weekly` and `GET /datasets/heavy_users_profile` serve the dashboard's figures.
**Answer (20 school days to 2026-10-08).** 27 heavy users with 181 of 969 completed academic sessions (19%); 551 students coached.
**Failure modes.** (1) Twenty school days are weekdays here (DICTIONARY trap 22). (2) Students without an id are left out.

## Composition 7 — Coach no-shows
**Pins.** DICTIONARY §4 (coach no-show as the data sees it: the student in the coach's Meet room, the coach never there), §0 scope (a
session count: every coaching session type), trap 19.
```sql
select count(*), count(distinct coach_key) from sessions where ending_final = 'coach_no_show';
```
**Over the API.** `GET /sessions?from=&to=` → `ending_final` = coach_no_show (and `ending_recorded` = unmarked for trap 15's context).
**Answer.** 13 sessions across 7 coaches, 2026-09-09 to 10-14.
**Failure modes.** (1) A coach no-show is visible only when the student joins the coach's own meeting; sessions with no meeting found stay
`unmarked` or keep the platform's ending. (2) Never report per coach in a shared figure (`coach_key` is a hash, kept internal).

## Composition 8 — How long students wait
**Pins.** DICTIONARY §2 (trusted booking time), §10.1 `wait_school_days`, trap 13.
```sql
select count(*), sum(wait_school_days > 1) from sessions
 where session_type = 'academic' and booked_at_trusted = 1 and session_date between '2026-09-28' and '2026-10-02';
```
**Over the API.** `GET /sessions?from=&to=` → `session_type` = academic, `booked_at_trusted` = 1, `wait_school_days`; weekly: `GET /datasets/wait_weekly`.
**Answer (week of 2026-09-28).** 378 academic sessions with a trusted booking time: median wait 5 school days; 274 (72%) waited more than one.
**Failure modes.** (1) Waiting exists only where the booking time is real (`booked_at_trusted` = 1): from 2026-09-07 for OpenCal and
2026-09-16 for Calendly; earlier weeks have no wait. (2) The platform's own `createdAt` for imports and coach-entered sessions is when the
row entered the platform, often after the session; the store keeps it out (`booked_at` NULL), so don't rebuild a wait from the platform.

## Composition 8b — Of the students who asked, how many got a session by the next school day?
**Pins.** DICTIONARY §2 (next-day coaching), §10.1 `wait_school_days`, §10.9 (`platform.sqlite` table `no_slot`, not shipped; a pack
reader takes the no-slot attempts from `requests_weekly`, column `no_slot`, §10.7).
```sql
-- requests by the week the student asked (US Central); add the week's no-slot attempts (requests_weekly.no_slot, or platform.sqlite no_slot)
select count(*), sum(wait_school_days <= 1) from sessions
 where session_type = 'academic' and booked_at_trusted = 1
   and date(datetime(booked_at, '-5 hours')) between '2026-09-28' and '2026-10-04';
```
**Over the API.** `GET /datasets/requests_weekly` (and `requests_outcomes`, `requests_by_group`); requests are the trusted-booking academic rows of `GET /sessions` plus the dataset's `no_slot` attempts (no student id on those).
**Answer (requests made in the week of 2026-09-28).** 351 requests (349 booked, 2 no-slot attempts); 107 (30%) got a session scheduled for
the same or the next school day: 59 coached, 30 no-shows, 8 cancelled, 2 together under 5 minutes, 3 couldn't run or coach absent, 5 not
yet held. 89 waited 2–5 school days and 153 longer. The week of Sep 21: 12%.
**Failure modes.** (1) Group by when the student asked, not by the session date. (2) A no-show still got a session: the measure is what the
service offered. (3) No-slot attempts carry no student id; count them, don't join them.

## Composition 9 — One student and subject, end to end
**Pins.** DICTIONARY §10.2 (`session_ids`), §10.1, §10.4.
```sql
select day, lead, owners, session_ids from ledger where student_key = '<id>' and subject = '<subject>' order by day;
select session_date, ending_final, blocker, blocker_sub from sessions where session_id in (<ids>);
select result, pre_rate, post_rate, pace_change_pct from outcomes where session_id in (<ids>);
```
**Over the API.** `GET /sessions?from=&to=` filtered to the `student_id` and subject; `GET /ledger?day=` for each of its days (`student_key` = the TimeBack id); `GET /outcomes?from=&to=` filtered to the `student_id`.
**Failure modes.** The rows carry the student's id only; a name never leaves the machine (DICTIONARY §12).
