update see calss

This commit is contained in:
2026-08-23 22:03:57 +02:00
parent f3d4fb56ed
commit 8983cfc8a1
32 changed files with 1884 additions and 22 deletions
+14 -2
View File
@@ -9,6 +9,7 @@ import (
"strings"
"time"
"github.com/descrybe/descrybe-v2/apps/api/internal/aiaudit"
"github.com/descrybe/descrybe-v2/apps/api/internal/aiprompts"
"github.com/descrybe/descrybe-v2/apps/api/internal/billing"
"github.com/descrybe/descrybe-v2/apps/api/internal/catalog"
@@ -588,15 +589,23 @@ func (p *Pipeline) RetryJob(ctx context.Context, companyID, id uuid.UUID) (Job,
// Terminal job statuses (completed/cancelled/failed) are no-ops — RetryJob requeues work.
func (p *Pipeline) ProcessJob(ctx context.Context, jobID uuid.UUID) error {
var companyID uuid.UUID
var jobUserID *uuid.UUID
var status, processingType string
var alreadyProcessed int
err := p.Pool.QueryRow(ctx, `
SELECT company_id, status, processing_type, processed_products
SELECT company_id, user_id, status, processing_type, processed_products
FROM processing_jobs WHERE id = $1`, jobID).
Scan(&companyID, &status, &processingType, &alreadyProcessed)
Scan(&companyID, &jobUserID, &status, &processingType, &alreadyProcessed)
if err != nil {
return err
}
// Tag every LLM call this job makes so the admin AI inspector can group them
// by tenant, job and the user who started it (internal/aiaudit).
auditCall := aiaudit.CallContext{CompanyID: companyID, JobID: jobID, Role: aiaudit.RoleProcessing}
if jobUserID != nil {
auditCall.UserID = *jobUserID
}
ctx = aiaudit.WithCall(ctx, auditCall)
if !IsProcessableJobStatus(status) {
log.Printf("processing: skip job=%s status=%s reason=not_processable", jobID, status)
return nil
@@ -1439,6 +1448,9 @@ func (p *Pipeline) processOne(ctx context.Context, companyID, jobID uuid.UUID, i
if it == nil {
return false, 0, StepResult{}, fmt.Errorf("processing: nil job item")
}
// Narrow the job-level audit tag to this product so captured prompts are
// addressable per item, not just per job.
ctx = aiaudit.WithCall(ctx, aiaudit.CallContext{RawProductID: it.RawID})
gtin := it.gtin
mappedBytes := it.mappedBytes
rawBytes := it.rawBytes