fix(mcp-server): social-fast-coordinator-pipeline — stage_transition used non-existent currentStage field

FastingSessionDoc has stages: unknown[] not currentStage: string.
- Replace currentStage cast with hasStages check (session.stages.length > 0)
- Fix protocolId extraction to use direct field (session?.protocolId)
- Report currentStage derived from stages.length as 'stage_N' indicator
This commit is contained in:
saravanakumardb1 2026-03-05 18:13:28 -08:00
parent 64e1263fc0
commit 1da3394caf

View File

@ -83,9 +83,10 @@ async function notifyMembers(
});
}
// If session has a current stage, fire stage_transition milestone push
const stage = (session as unknown as Record<string, unknown>)?.['currentStage'];
if (stage && typeof stage === 'string') {
// If session has stage entries (fast is progressing), fire stage_transition milestone push
const hasStages =
session !== null && Array.isArray(session.stages) && session.stages.length > 0;
if (hasStages) {
try {
await nomgapPushFire({ type: 'stage_transition', userId }, opts);
results.push({ userId, type: 'stage_transition', outcome: 'fired' });
@ -128,9 +129,10 @@ async function sendWeeklyDigestAndReport(
const fired = notifications.filter(n => n.outcome === 'fired').length;
const failed = notifications.filter(n => n.outcome === 'failed').length;
const stage =
((session as unknown as Record<string, unknown>)?.['currentStage'] as string | null) ?? null;
const protocolId =
((session as unknown as Record<string, unknown>)?.['protocolId'] as string | null) ?? null;
session && Array.isArray(session.stages) && session.stages.length > 0
? `stage_${session.stages.length}`
: null;
const protocolId = session?.protocolId ?? null;
const summary =
memberUserIds.length === 0