Jev decide y el modelo escribe: el juicio entra en el trabajo del Coach, y juzga la selección
Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s

Recordado como "para mejorar las decisiones en la selección de entrenamiento debe usar Jev y ChatGPT
combinado". La combinación estaba a medias por dos razones, y las dos se cierran acá.

**El juicio no estaba cuando se escribía el plan.** Viajaba al payload sólo si alguien lo había pedido
en Salud hacía menos de seis horas; en la práctica, muchas veces no estaba. Ahora un trabajo del Coach
—crear o revisar— **pide su propio juicio** cuando no hay uno fresco (`insightForCoach` en
`api/insights.js`), con el mismo cupo que gasta el botón de Salud, así que lo automático no puede
costar más que lo manual. Un debrief queda afuera: un veredicto de disposición no habla de una sesión.
Y si el proveedor falla, si la instancia no tiene clave o si el cupo se agotó, el trabajo sigue
exactamente como antes — el juicio es contexto, nunca una dependencia, y hay tests para los tres casos.

**Las preguntas no cubrían la selección.** Jev juzgaba disposición, descarga, limitante y métrica a
vigilar; nada sobre *qué cambiar*. Ahora, además de `volume` (hacia dónde va la carga de la semana,
cuando hay historia suficiente para tener opinión), recibe **una pregunta por ejercicio estancado**:
`keep`, `reduce`, `swap` o `drop`, con la clave del id de la biblioteca y el nombre en la rúbrica —
así la respuesta es algo con lo que el plan se puede editar y el modelo lee palabras, no una clave.
Los ids de ejercicios pasan a viajar en el estado, y sólo ellos: un id de biblioteca es una fila de un
dataset público, no un identificador de persona, y el test de privacidad lo dice ahora en esos
términos.

Hay una sola forma de producir un juicio: `runInsight` en `api/insights.js`, que usan la ruta de Salud
y el trabajo del Coach. Antes esa lógica vivía dentro de la ruta, con sus helpers duplicados en
`server.js`; ahora la ruta es una envoltura fina y no hay dos maneras de pedir, cobrar o guardar.

En el prompt del escritor quedó dicho con precisión qué es un `swap`: **una propuesta a considerar**,
no una decisión a aplicar. Si la evidencia que el propio modelo ve dice que el ejercicio está bien,
puede decir por qué y dejarlo; el cambio que envíe tiene que cumplir el esquema y nombrar un id real.

Tests: seis del runner y de la regla de cuándo preguntar (contra un gateway de mentira, sin levantar
servidor), más los de las preguntas nuevas. API 276 en verde, frontend 1705.
This commit is contained in:
dsantillan committed 2026-09-23 19:11:39 -04:00
1 parent 9a339db85e
commit f80ade25f6
9 files changed
+416 -90

No files matched your search

+44 -2
View File
@@ -115,6 +115,11 @@ const METRIC_GLOSS = {
/** Preference order for the state, best first: the metrics a readiness judgment actually reads. */
const METRIC_ORDER = Object.keys(METRIC_GLOSS);
const MAX_METRICS = 8;
/* How many stalled exercises the judgment is asked about in one request. Jev answers many questions
in one call, and each of these is one choice with four options — six is enough to cover a plan,
and beyond it the answers stop being decisions anybody reads. */
const MAX_STALLS = 6;
/** The body parts the library uses (`bp` in library-data.js), glossed for the choice question. */
const BODY_PARTS = {
chest: 'chest and pressing muscles',
@@ -241,7 +246,12 @@ function trainingPart(S, { now, bodyPartOf, nameOf }) {
for (const [id, list] of byEx) {
if (list.length < 3) continue;
const tops = list.slice(-3).map(en => Math.max(...(en.sets || []).filter(s => s.done).map(s => Number(s.w) || 0)));
if (tops[0] === tops[1] && tops[1] === tops[2] && tops[2] > 0) stalled.push(id);
if (tops[0] === tops[1] && tops[1] === tops[2] && tops[2] > 0) {
// The id travels with the name, and only here: a decision about *which exercise to change*
// has to name the exercise the app can act on, and a library id identifies an exercise in a
// public dataset rather than a person. The name goes beside it so the model reads words.
stalled.push({ id, name: nameOf(id) || null, sessions: list.length, last_top: tops[2], body_part: bodyPartOf(id) || null });
}
}
return {
window_days: 28,
@@ -250,7 +260,7 @@ function trainingPart(S, { now, bodyPartOf, nameOf }) {
planned_days_per_week: Object.keys(S.week || {}).filter(k => (S.week[k] || []).length).length,
sets_by_body_part_28d: sets(workouts, 28),
sets_by_body_part_7d: sets(workouts, 7),
stalled_exercises: stalled.slice(0, 8).map(nameOf).filter(Boolean),
stalled: stalled.slice(0, MAX_STALLS).filter(e => e.name),
recent_sessions: recent.map(detail)
};
}
@@ -390,6 +400,38 @@ export function buildQuestions(state) {
criteria: attentionOptions
}
};
// How the week should move, when there is enough history to have an opinion about it.
if ((state.training?.sessions || 0) >= 4) {
q.volume = {
type: 'score',
instructions: 'Given the sessions, the effort logged and how recovery looks, which way should this week\'s training volume go?',
criteria: [
'cut it back a lot — this is a week to recover, not to add',
'ease off slightly',
'keep it where it is',
'build it up slightly',
'build it up a lot — the body is clearly handling it'
]
};
}
// Selection, which is the half a plan cannot get from numbers alone: what to do about an exercise
// that has stopped moving. One question per stalled exercise, keyed by its library id so the answer
// comes back as something the plan can be edited with — the name rides in the rubric, so the model
// is still reading words.
for (const ex of state.training?.stalled || []) {
q[`exercise_${ex.id}`] = {
type: 'choice',
instructions: `"${ex.name}" has stopped progressing: ${ex.sessions} sessions in the window, the last three at the same top set of ${ex.last_top}. What should change about it?`,
criteria: {
keep: 'leave the prescription exactly as it is',
reduce: 'keep the exercise but take volume or load off it',
swap: 'replace it with a different exercise for the same body part',
drop: 'take it out of the plan for now'
}
};
}
// A choice with no real options is a question that can only be answered wrong, so the limiter
// one only exists when the profile has trained something we can name.
if (parts.length) {