feat: expose executor job observability
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import crypto from 'node:crypto';
|
||||
import {
|
||||
Annotation,
|
||||
END,
|
||||
@@ -35,6 +36,22 @@ const ShadowState = Annotation.Root({
|
||||
}),
|
||||
});
|
||||
|
||||
function executorIdentityForRun(runId) {
|
||||
const normalizedRunId = String(runId ?? '').trim();
|
||||
const jobId = `${normalizedRunId}:executor-preview`;
|
||||
if (/^[a-zA-Z0-9:_-]+$/.test(normalizedRunId) && jobId.length <= 128) {
|
||||
return {
|
||||
jobId,
|
||||
idempotencyKey: `${normalizedRunId}:build_plan:v1`,
|
||||
};
|
||||
}
|
||||
const digest = crypto.createHash('sha256').update(normalizedRunId).digest('hex');
|
||||
return {
|
||||
jobId: `run_${digest}:executor-preview`,
|
||||
idempotencyKey: `run_${digest}:build_plan:v1`,
|
||||
};
|
||||
}
|
||||
|
||||
function eventFor(state, type, data = null) {
|
||||
return buildRunEvent({
|
||||
runId: state.spec.runId,
|
||||
@@ -70,9 +87,10 @@ function validateNode(state) {
|
||||
async function planNode(state, executorGateway) {
|
||||
const taskType = String(state.spec.input?.taskType ?? '').trim() || 'code-change';
|
||||
const instruction = String(state.spec.input?.instruction ?? '');
|
||||
const executorIdentity = executorIdentityForRun(state.spec.runId);
|
||||
const executorJob = await executorGateway.createJob({
|
||||
jobId: `${state.spec.runId}:executor-preview`,
|
||||
idempotencyKey: `${state.spec.runId}:build_plan:v1`,
|
||||
jobId: executorIdentity.jobId,
|
||||
idempotencyKey: executorIdentity.idempotencyKey,
|
||||
executor: 'goosed',
|
||||
task: {
|
||||
type: taskType,
|
||||
@@ -162,6 +180,7 @@ export function createCodeRunShadowGraph({ checkpointer, executorGateway } = {})
|
||||
|
||||
export const codeRunShadowGraphInternals = {
|
||||
ShadowState,
|
||||
executorIdentityForRun,
|
||||
eventFor,
|
||||
validateNode,
|
||||
planNode,
|
||||
|
||||
Reference in New Issue
Block a user