Class JobSnapshot
java.lang.Object
ai.redouble.nucleo.harness.JobSnapshot
- All Implemented Interfaces:
Identifiable, Serializable
Immutable snapshot of a job's identity and state at a specific point in time.
Captures job identity (jobId, userId, workflowId), human-readable metadata
(displayName from @DisplayName, description from @ToolDescription),
and state (timestamps, attemptNumber) frozen at a moment in time.
Instances are immutable; use with* methods to create new snapshots.
The description field is extracted reflectively from @ToolDescription
to avoid a compile-time dependency from Nucleo to the tools layer. Use
withDescription(String) to override with a runtime value (e.g., from a
prompt management system).
JSON Serialization:
Included in JobEvent JSON as nested snapshot object.
Fields jobClass, state, description, dependencyJobIds
and metadata excluded via @JsonIgnore.
- Since:
- 0.1 (2025-10-08)
- Author:
- Andrey Santrosyan
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionJobSnapshot(Job<?> job) Creates a new snapshot from a Job with QUEUED state.JobSnapshot(String jobId, String parentJobId, String workflowId, String userId, Class<? extends Job> jobClass, JobType jobType, String displayName, String action, String description, JobState state, int attemptNumber, Instant submittedAt, Instant startedAt, Instant completedAt, List<String> dependencyJobIds, Map<String, Object> metadata) Full constructor for all fields. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringextractAction(Class<? extends Job> jobClass) Extracts action verb from @DisplayName annotation.static StringextractDescription(Class<? extends Job> jobClass) Extracts description from @ToolDescription annotation via reflection.static StringextractDisplayName(Class<? extends Job> jobClass) Extracts human-readable name from @DisplayName annotation or falls back to class simple name.intgetJobId()Gets unique job identifier.Gets parent job ID.getState()Gets workflow owner.Gets workflow identifier (root job's ID).jobClass()jobType()Gets the job type name (simple class name).withAttemptNumber(int attemptNumber) Returns a new snapshot with updated attempt number.withCompletedAt(Instant completedAt) Returns a new snapshot with completed timestamp.withDependencyJobIds(List<String> dependencyJobIds) Returns a new snapshot with dependency job IDs.withDescription(String description) Returns a new snapshot with overridden description.withMetadata(Map<String, Object> metadata) Returns a new snapshot with updated metadata.withStartedAt(Instant startedAt) Returns a new snapshot with started timestamp.Returns a new snapshot with updated state.
-
Constructor Details
-
JobSnapshot
Creates a new snapshot from a Job with QUEUED state. PrefersJob.getDisplayName()if non-null, otherwise falls back to annotation/class name. -
JobSnapshot
public JobSnapshot(String jobId, String parentJobId, String workflowId, String userId, Class<? extends Job> jobClass, JobType jobType, String displayName, String action, String description, JobState state, int attemptNumber, Instant submittedAt, Instant startedAt, Instant completedAt, List<String> dependencyJobIds, Map<String, Object> metadata) Full constructor for all fields.
-
-
Method Details
-
extractDisplayName
-
extractAction
-
extractDescription
Extracts description from @ToolDescription annotation via reflection. Uses reflective annotation lookup to avoid a dependency from Nucleo to the tools layer. Returns null if the annotation is not present or the class is not on the classpath. -
getJobId
Description copied from interface:IdentifiableGets unique job identifier.- Specified by:
getJobIdin interfaceIdentifiable- Returns:
- job ID
-
getParentJobId
Description copied from interface:IdentifiableGets parent job ID.- Specified by:
getParentJobIdin interfaceIdentifiable- Returns:
- parent job ID, or null for root
-
getWorkflowId
Description copied from interface:IdentifiableGets workflow identifier (root job's ID).- Specified by:
getWorkflowIdin interfaceIdentifiable- Returns:
- workflow ID
-
getUserId
Description copied from interface:IdentifiableGets workflow owner.- Specified by:
getUserIdin interfaceIdentifiable- Returns:
- user ID
-
jobClass
-
getJobType
-
getAction
-
getDescription
-
getState
-
getSubmittedAt
-
getStartedAt
-
getCompletedAt
-
dependencyJobIds
-
getMetadata
-
getDisplayName
-
getAttemptNumber
public int getAttemptNumber() -
withState
Returns a new snapshot with updated state. -
withAttemptNumber
Returns a new snapshot with updated attempt number. -
withStartedAt
Returns a new snapshot with started timestamp. -
withCompletedAt
Returns a new snapshot with completed timestamp. -
withDependencyJobIds
Returns a new snapshot with dependency job IDs. -
withDescription
Returns a new snapshot with overridden description. Use when description comes from a runtime source (e.g., prompt management) rather than annotation. -
withMetadata
Returns a new snapshot with updated metadata. -
jobType
Gets the job type name (simple class name).
-