feat: add resume header to workflow.log showing previous workflow ID and checkpoint

This commit is contained in:
ajmallesh
2026-02-16 17:21:12 -08:00
parent bb89d6f458
commit 9074149778
4 changed files with 60 additions and 4 deletions
+14
View File
@@ -288,4 +288,18 @@ export class AuditSession {
unlock(); unlock();
} }
} }
/**
* Log resume header to workflow.log
* Call this when a workflow is resuming to add a visual separator
*/
async logResumeHeader(resumeInfo: {
previousWorkflowId: string;
newWorkflowId: string;
checkpointHash: string;
completedAgents: string[];
}): Promise<void> {
await this.ensureInitialized();
await this.workflowLogger.logResumeHeader(resumeInfo);
}
} }
+28
View File
@@ -87,6 +87,34 @@ export class WorkflowLogger {
return this.logStream.write(header); return this.logStream.write(header);
} }
/**
* Write resume header to log file when workflow is resumed
*/
async logResumeHeader(resumeInfo: {
previousWorkflowId: string;
newWorkflowId: string;
checkpointHash: string;
completedAgents: string[];
}): Promise<void> {
await this.ensureInitialized();
const header = [
``,
`================================================================================`,
`RESUMED`,
`================================================================================`,
`Previous Workflow ID: ${resumeInfo.previousWorkflowId}`,
`New Workflow ID: ${resumeInfo.newWorkflowId}`,
`Resumed At: ${formatTimestamp()}`,
`Checkpoint: ${resumeInfo.checkpointHash}`,
`Completed: ${resumeInfo.completedAgents.length} agents (${resumeInfo.completedAgents.join(', ')})`,
`================================================================================`,
``,
].join('\n');
return this.logStream.write(header);
}
/** /**
* Format timestamp for log line (local time, human readable) * Format timestamp for log line (local time, human readable)
*/ */
+14 -2
View File
@@ -485,17 +485,29 @@ export async function restoreGitCheckpoint(
} }
/** /**
* Record a resume attempt in session.json. * Record a resume attempt in session.json and write resume header to workflow.log.
*/ */
export async function recordResumeAttempt( export async function recordResumeAttempt(
input: ActivityInput, input: ActivityInput,
terminatedWorkflows: string[], terminatedWorkflows: string[],
checkpointHash: string checkpointHash: string,
previousWorkflowId: string,
completedAgents: string[]
): Promise<void> { ): Promise<void> {
const sessionMetadata = buildSessionMetadata(input); const sessionMetadata = buildSessionMetadata(input);
const auditSession = new AuditSession(sessionMetadata); const auditSession = new AuditSession(sessionMetadata);
await auditSession.initialize(); await auditSession.initialize();
// Update session.json with resume attempt
await auditSession.addResumeAttempt(input.workflowId, terminatedWorkflows, checkpointHash); await auditSession.addResumeAttempt(input.workflowId, terminatedWorkflows, checkpointHash);
// Write resume header to workflow.log
await auditSession.logResumeHeader({
previousWorkflowId,
newWorkflowId: input.workflowId,
checkpointHash,
completedAgents,
});
} }
// === Phase Transition Activities === // === Phase Transition Activities ===
+4 -2
View File
@@ -178,11 +178,13 @@ export async function pentestPipelineWorkflow(
return state; return state;
} }
// Record resume attempt in session.json // Record resume attempt in session.json and write resume header to workflow.log
await a.recordResumeAttempt( await a.recordResumeAttempt(
activityInput, activityInput,
input.terminatedWorkflows || [], input.terminatedWorkflows || [],
resumeState.checkpointHash resumeState.checkpointHash,
resumeState.originalWorkflowId,
resumeState.completedAgents
); );
log.info('Resume state loaded and workspace restored'); log.info('Resume state loaded and workspace restored');