Package dev.dokimos.server.service
Class TraceEvalJobTransactions
java.lang.Object
dev.dokimos.server.service.TraceEvalJobTransactions
The transactional steps of the trace eval worker, each in its own committed transaction so the worker
can make the LLM HTTP call between them without holding a database transaction open. Splitting these
out of the worker also makes
REQUIRES_NEW boundaries effective, since self-invocation would
otherwise bypass the proxy. Mirrors JudgeJobTransactions.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA claimed job paired with the span text snapshots the worker scores after the transaction closes. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclaimNextJob(int maxAttempts) Claims the oldest pending job below the retry ceiling: locks its row, marks it CLAIMED, stamps the claim time, and increments the attempt count.voidmarkSucceeded(UUID jobId, double score, boolean success, String reason) Marks a job SUCCEEDED and records its score.voidrecordFailure(UUID jobId, String error, boolean retryable, int maxAttempts) Records a failure.intrecoverStaleClaims(Instant cutoff) Returns jobs orphaned by a crashed worker (claimed before the cutoff and never finished) to PENDING so the next poll can reclaim them.
-
Constructor Details
-
TraceEvalJobTransactions
-
-
Method Details
-
recoverStaleClaims
Returns jobs orphaned by a crashed worker (claimed before the cutoff and never finished) to PENDING so the next poll can reclaim them. The attempt count is left as-is, so the retry ceiling still bounds reclaims.- Parameters:
cutoff- jobs claimed before this instant are requeued- Returns:
- the number of jobs requeued
-
claimNextJob
@Transactional(propagation=REQUIRES_NEW) public Optional<TraceEvalJobTransactions.ClaimedJob> claimNextJob(int maxAttempts) Claims the oldest pending job below the retry ceiling: locks its row, marks it CLAIMED, stamps the claim time, and increments the attempt count. Commits before returning so the lock is not held during the HTTP work that follows. The connection and span are initialized while the session is open since the worker reads them after the transaction closes.- Parameters:
maxAttempts- the retry ceiling- Returns:
- a snapshot of the claimed job, or empty if none is available
-
markSucceeded
@Transactional(propagation=REQUIRES_NEW) public void markSucceeded(UUID jobId, double score, boolean success, String reason) Marks a job SUCCEEDED and records its score.- Parameters:
jobId- the job that finished scoringscore- the numeric scoresuccess- the pass/fail decisionreason- the judge's reasoning
-
recordFailure
@Transactional(propagation=REQUIRES_NEW) public void recordFailure(UUID jobId, String error, boolean retryable, int maxAttempts) Records a failure. When the failure is retryable and the attempt ceiling has not been reached, the job is returned to PENDING for a later poll; otherwise it is marked FAILED.- Parameters:
jobId- the job that failederror- the error message to recordretryable- whether the failure is worth retryingmaxAttempts- the retry ceiling
-