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
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:
1 parent
9a339db85e
commit
f80ade25f6
9 files changed
+416
-90
No files matched your search
+26
-7
@@ -99,8 +99,11 @@ test('the state carries the training, the body and a week of health, as numbers'
|
||||
assert.equal(s.training.sets_by_body_part_28d.shoulders, 1);
|
||||
assert.equal(s.training.sets_by_body_part_7d.back, 1, 'and the week view is its own count');
|
||||
// e1 was trained three times and its top set was 60 kg every time: that is a stall, and it goes
|
||||
// out as the library's name rather than as an id a model cannot read.
|
||||
assert.deepEqual(s.training.stalled_exercises, ['barbell bench press']);
|
||||
// out as a *decision the app can act on* — the library id, with the name beside it so the model
|
||||
// reads words rather than a key.
|
||||
assert.deepEqual(s.training.stalled, [
|
||||
{ id: 'e1', name: 'barbell bench press', sessions: 3, last_top: 60, body_part: 'chest' }
|
||||
]);
|
||||
assert.equal(s.training.recent_sessions.at(-1).days_ago, 1);
|
||||
assert.equal(s.training.recent_sessions.at(-1).avg_rpe, 10);
|
||||
assert.equal(s.training.recent_sessions.at(-1).minutes, 58);
|
||||
@@ -129,8 +132,11 @@ test('nothing that identifies the person leaves the instance', () => {
|
||||
const json = JSON.stringify(state());
|
||||
assert.equal(json.includes('Push'), false, 'no workout titles');
|
||||
assert.equal(json.includes('Pull'), false);
|
||||
assert.equal(json.includes('"e1"'), false, 'no exercise ids — a stalled exercise goes by name');
|
||||
assert.equal(json.includes('barbell bench press'), true, 'and that name is the library\'s, not a personal one');
|
||||
// Exercise ids DO go out, and only for the stalled ones: a judgment about which exercise to change
|
||||
// has to name something the app can edit, and a library id is a row in a public dataset rather than
|
||||
// an identifier of a person. The names travel with them so the model reads words.
|
||||
assert.equal(json.includes('"e1"'), true, 'a stalled exercise is named by the id the plan uses');
|
||||
assert.equal(json.includes('barbell bench press'), true, 'and by the library\'s own name');
|
||||
assert.equal(json.includes('r1'), false, 'no routine ids');
|
||||
assert.equal(json.includes('u_'), false);
|
||||
// The body parts and metric names that DO go are the vocabulary of the questions, not identity.
|
||||
@@ -157,6 +163,13 @@ test('the questions are built from what this profile actually has', () => {
|
||||
assert.deepEqual(Object.keys(q.deload.criteria), ['true', 'false']);
|
||||
// Only body parts that were trained get an option, plus the honest "nothing stands out".
|
||||
assert.deepEqual(Object.keys(q.limiter.criteria).sort(), ['back', 'chest', 'none', 'shoulders']);
|
||||
// Selection: one question per stalled exercise, keyed by the id the plan can act on, and a
|
||||
// direction for the week's volume once there is enough history to have an opinion.
|
||||
assert.deepEqual(Object.keys(q.exercise_e1.criteria).sort(), ['drop', 'keep', 'reduce', 'swap']);
|
||||
assert.match(q.exercise_e1.instructions, /barbell bench press/);
|
||||
assert.match(q.exercise_e1.instructions, /60/);
|
||||
assert.equal(q.volume.type, 'score');
|
||||
assert.equal(q.volume.criteria.length, 5);
|
||||
// Every metric in the state is a choice, and no metric that is not.
|
||||
assert.equal(Object.keys(q.attention.criteria).includes('step_count'), true);
|
||||
assert.equal(Object.keys(q.attention.criteria).includes('resting_heart_rate'), true);
|
||||
@@ -166,6 +179,8 @@ test('the questions are built from what this profile actually has', () => {
|
||||
// A profile with no training gets no limiter question at all: a choice with no options can only
|
||||
// be answered wrong.
|
||||
const empty = buildQuestions(buildState({ S: {}, vitals: null, now: NOW }));
|
||||
assert.equal(empty.volume, undefined, 'no sessions, no opinion about volume');
|
||||
assert.equal(Object.keys(empty).some(k => k.startsWith('exercise_')), false, 'and nothing stalled to ask about');
|
||||
assert.equal(empty.limiter, undefined);
|
||||
assert.deepEqual(Object.keys(empty.attention.criteria), ['none']);
|
||||
});
|
||||
@@ -216,9 +231,13 @@ test('a question the gateway did not answer is null, and the others still land',
|
||||
assert.equal(answers.deload.p, 0.8);
|
||||
assert.equal(answers.limiter, null);
|
||||
assert.equal(answers.attention, null);
|
||||
// A body that is not an object at all loses every answer rather than throwing in the route.
|
||||
assert.deepEqual(Object.values(parseAnswers(null, questions)), [null, null, null, null]);
|
||||
assert.deepEqual(Object.values(parseAnswers('nope', questions)), [null, null, null, null]);
|
||||
// A body that is not an object at all loses every answer rather than throwing in the route — one
|
||||
// null per question asked, however many that is.
|
||||
const asked = Object.keys(questions).length;
|
||||
assert.equal(asked, 6, 'readiness, deload, attention, limiter, volume and one per stalled exercise (e1)');
|
||||
assert.deepEqual(Object.keys(questions), ['readiness', 'deload', 'attention', 'volume', 'exercise_e1', 'limiter']);
|
||||
assert.deepEqual(Object.values(parseAnswers(null, questions)), new Array(asked).fill(null));
|
||||
assert.deepEqual(Object.values(parseAnswers('nope', questions)), new Array(asked).fill(null));
|
||||
});
|
||||
|
||||
/* ---------- what is stored, and what makes it stale ---------- */
|
||||
|
||||
Reference in new issue
Block a user