Propagate curator task ids through service events

This commit is contained in:
Sai-karthik
2026-06-19 22:22:51 +00:00
parent 20c18583db
commit abeefc221b

View File

@@ -62,6 +62,13 @@ function missionFromRequest(req: Request, body?: JsonObject): Record<string, unk
};
}
function curatorTaskIdFromRequest(req: Request, body?: JsonObject) {
const fromBody = body ? getString((body as Record<string, unknown>).curatorTaskId) : undefined;
if (fromBody) return fromBody;
const url = new URL(req.url);
return getString(url.searchParams.get("curatorTaskId"));
}
function stripMissionFromBody(body: JsonObject): JsonObject {
if (!("mission" in body)) return body;
const { mission: _mission, ...rest } = body;
@@ -181,6 +188,7 @@ async function proxyResumeRequest(req: Request, rest: string, userId: string) {
correlation: {
resumeId: getString(responseObj.resume_id ?? responseObj.resumeId ?? responseObj.id) ?? getString(requestJson.resume_id ?? requestJson.resumeId),
externalId: getString(responseObj.resume_id ?? responseObj.resumeId ?? responseObj.id) ?? getString(requestJson.resume_id ?? requestJson.resumeId),
taskId: curatorTaskIdFromRequest(req, requestJson),
},
mission,
}).catch((err) => log.warn({ err, path: normalizedRest }, "failed to record resume gateway event"));
@@ -573,7 +581,7 @@ export function serviceRoutes() {
source: "interview-service",
type: "interview.configured",
payload: { request: payload, result: resultObj },
correlation: { sessionId: getSessionId(resultObj), requestId: getString(body.request_id) },
correlation: { sessionId: getSessionId(resultObj), requestId: getString(body.request_id), taskId: curatorTaskIdFromRequest(c.req.raw, body) },
mission,
}).catch((err) => log.warn({ err }, "failed to record interview configured event"));
return c.json(result);
@@ -598,7 +606,7 @@ export function serviceRoutes() {
source: "interview-service",
type: eventTypeForReview("interview", resultObj),
payload: resultObj,
correlation: { sessionId },
correlation: { sessionId, taskId: curatorTaskIdFromRequest(c.req.raw) },
}).catch((err) => log.warn({ err }, "failed to record interview review event"));
return c.json(result);
});
@@ -634,7 +642,7 @@ export function serviceRoutes() {
source: "roleplay-service",
type: "roleplay.configured",
payload: { request: payload, result: resultObj },
correlation: { sessionId: getSessionId(resultObj), requestId: getString(body.request_id) },
correlation: { sessionId: getSessionId(resultObj), requestId: getString(body.request_id), taskId: curatorTaskIdFromRequest(c.req.raw, body) },
mission,
}).catch((err) => log.warn({ err }, "failed to record roleplay configured event"));
return c.json(result);
@@ -659,7 +667,7 @@ export function serviceRoutes() {
source: "roleplay-service",
type: eventTypeForReview("roleplay", resultObj),
payload: resultObj,
correlation: { sessionId },
correlation: { sessionId, taskId: curatorTaskIdFromRequest(c.req.raw) },
}).catch((err) => log.warn({ err }, "failed to record roleplay review event"));
return c.json(result);
});