adobe / adobe/spacecat-audit-worker

Make llmo-customer-analysis brand-presence reanalysis batch-aware

Open
#2,933 0 comments 0 reactions 1 assignee Claimed by @rainer-friederich View on GitHub
Dominant language
JavaScript
Stars
14
Forks
15
Avg merge
1d 21m
Merged PRs (30d)
58

Description

## Problem

`llmo-customer-analysis` calls `drsClient.triggerBrandDetection(siteId)` whenever topics, categories, or entities differ between LLMO configuration versions.

That operation is batch-specific reanalysis. DRS requires an existing brand-presence collection `batch_id`, but the audit worker supplies none. The call is also made during first onboarding, when no historical batch exists and the handler has already created and immediately triggered a fresh weekly brand-presence schedule.

This causes customer analysis to fail after prompts have been stored and fresh brand-presence collection has already started successfully.

## Required behavior

The handler must distinguish first collection, fresh collection, and historical reanalysis:

- **First onboarding:** create and immediately trigger the canonical brand-presence schedule. Do not call the historical reanalysis endpoint.
- **Configuration changes requiring fresh provider answers:** trigger a fresh run of the existing schedule.
- **Configuration changes requiring analysis of existing provider answers:** select a real completed brand-presence batch for the site and pass its ID explicitly to `triggerBrandDetection`.

A prompt-generation job ID must never be used as a brand-presence batch ID because it has no DRS brand-presence tracking file.

## Acceptance criteria

- First onboarding does not call `triggerBrandDetection`.
- First onboarding still creates and immediately triggers the canonical weekly brand-presence schedule.
- Later topic/category/entity changes either provide a verified completed batch ID for reanalysis or use an explicitly defined fresh/deferred path.
- Missing batch state does not turn an otherwise successful first onboarding into a failed audit.
- Tests cover first onboarding, later config changes with a usable batch, and later config changes without a usable batch.
- Tests assert the exact `batchId` passed to the shared DRS client.
- The geo-brand-presence migration documentation reflects the implemented collection-versus-reanalysis behavior.
- The implementation uses the corrected shared-client contract tracked at:

https://github.com/adobe/spacecat-shared/issues/1906

## Production evidence

On 2026-09-01, prompt generation stored 50 active prompts and the newly created weekly brand-presence schedule completed its first run. `llmo-customer-analysis` nevertheless failed because it called `POST /sites/{siteId}/brand-detection` without `batch_id` and received HTTP 400.

The affected customer was recovered operationally by rerunning customer analysis as a no-change comparison after the fresh schedule completed. The caller defect remains applicable to other onboarding and configuration-change runs.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.