Add tracker description enrichment worker
Tracker descriptions were only filled on the agent-identification path, so patterns resolved by domain, sibling, or fallback stayed without one, and empty mapping upserts could clobber a researched description on the shared catalog row. Move description ownership to a dedicated, global common-pattern enrichment worker. New catalog rows are queued on insert; the worker researches a compliance-grade description with web search, records it on the common pattern, and fans it out to every linked tracker pattern. The mapping worker no longer generates descriptions and only propagates an already-enriched one at link time. Rename TrackerMappingConfig to TrackerAgentsConfig since the mapping and enrichment agents now share it. Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
@@ -313,7 +313,7 @@ func (impl *Implm) Run(
|
||||
return err
|
||||
}
|
||||
|
||||
trackerMappingCfg, thirdPartyDisambiguationCfg, err := impl.buildTrackerMappingConfig(l, tp, r)
|
||||
trackerAgentsCfg, thirdPartyDisambiguationCfg, err := impl.buildTrackerAgentsConfig(l, tp, r)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -725,7 +725,7 @@ func (impl *Implm) Run(
|
||||
},
|
||||
)
|
||||
|
||||
trackerMappingWorker := cookiebanner.NewTrackerMappingWorker(pgClient, l, trackerMappingCfg, thirdPartyDisambiguationCfg)
|
||||
trackerMappingWorker := cookiebanner.NewTrackerMappingWorker(pgClient, l, trackerAgentsCfg, thirdPartyDisambiguationCfg)
|
||||
trackerMappingWorkerCtx, stopTrackerMappingWorker := context.WithCancel(context.Background())
|
||||
|
||||
wg.Go(
|
||||
@@ -736,6 +736,26 @@ func (impl *Implm) Run(
|
||||
},
|
||||
)
|
||||
|
||||
// The common-pattern enrichment worker needs an LLM client (it
|
||||
// researches descriptions via the agent), so it is only started when
|
||||
// the tracker agents are configured.
|
||||
stopCommonPatternEnrichmentWorker := func() {}
|
||||
|
||||
if trackerAgentsCfg.LLMClient != nil {
|
||||
commonPatternEnrichmentWorker := cookiebanner.NewCommonPatternEnrichmentWorker(pgClient, l, trackerAgentsCfg)
|
||||
|
||||
var commonPatternEnrichmentWorkerCtx context.Context
|
||||
commonPatternEnrichmentWorkerCtx, stopCommonPatternEnrichmentWorker = context.WithCancel(context.Background())
|
||||
|
||||
wg.Go(
|
||||
func() {
|
||||
if err := commonPatternEnrichmentWorker.Run(commonPatternEnrichmentWorkerCtx); err != nil {
|
||||
cancel(fmt.Errorf("common pattern enrichment worker crashed: %w", err))
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
mailingListWorker := mailman.NewMailingListWorker(mailmanService, pgClient, l.Named("mailing-list-worker"))
|
||||
mailingListWorkerCtx, stopMailingListWorker := context.WithCancel(context.Background())
|
||||
|
||||
@@ -805,6 +825,7 @@ func (impl *Implm) Run(
|
||||
stopESignService()
|
||||
stopTrackerPatternAnalysisWorker()
|
||||
stopTrackerMappingWorker()
|
||||
stopCommonPatternEnrichmentWorker()
|
||||
stopMailingListWorker()
|
||||
stopEvidenceDescriptionWorker()
|
||||
stopDocumentPDFWorker()
|
||||
|
||||
@@ -24,25 +24,26 @@ import (
|
||||
"go.probo.inc/probo/pkg/thirdparty"
|
||||
)
|
||||
|
||||
// buildTrackerMappingConfig wires the tracker-mapping agent (catalog
|
||||
// identification) and the third-party disambiguation agent that the
|
||||
// tracker-mapping worker uses to promote patterns to org ThirdParties.
|
||||
// Both are opt-in: deployments that do not set
|
||||
// `llm.tracker-mapping.provider` get zero configs (nil LLM client) so
|
||||
// the worker runs without agent fallback.
|
||||
// buildTrackerAgentsConfig wires the tracker agents that share one LLM
|
||||
// client and model: the tracker-mapping agent (catalog identification),
|
||||
// the common-pattern enrichment agent (description research), and the
|
||||
// third-party disambiguation agent that the tracker-mapping worker uses
|
||||
// to promote patterns to org ThirdParties. All are opt-in: deployments
|
||||
// that do not set `llm.tracker-mapping.provider` get zero configs (nil
|
||||
// LLM client) so the workers run without agent fallback.
|
||||
//
|
||||
// Both agents are sourced from the same `tracker-mapping` config slot
|
||||
// The agents are sourced from the same `tracker-mapping` config slot
|
||||
// because they share the LLM client, model, and lifecycle. The
|
||||
// disambiguation agent has no Firecrawl/DB tools, so its config
|
||||
// surface is narrower and it lives in the cross-domain pkg/thirdparty
|
||||
// package.
|
||||
func (impl *Implm) buildTrackerMappingConfig(
|
||||
func (impl *Implm) buildTrackerAgentsConfig(
|
||||
l *log.Logger,
|
||||
tp trace.TracerProvider,
|
||||
r prometheus.Registerer,
|
||||
) (cookiebanner.TrackerMappingConfig, thirdparty.DisambiguationConfig, error) {
|
||||
) (cookiebanner.TrackerAgentsConfig, thirdparty.DisambiguationConfig, error) {
|
||||
if impl.cfg.Agents.TrackerMapping.Provider == "" {
|
||||
return cookiebanner.TrackerMappingConfig{}, thirdparty.DisambiguationConfig{}, nil
|
||||
return cookiebanner.TrackerAgentsConfig{}, thirdparty.DisambiguationConfig{}, nil
|
||||
}
|
||||
|
||||
agentCfg, llmClient, err := impl.resolveAgentClient(
|
||||
@@ -53,10 +54,10 @@ func (impl *Implm) buildTrackerMappingConfig(
|
||||
r,
|
||||
)
|
||||
if err != nil {
|
||||
return cookiebanner.TrackerMappingConfig{}, thirdparty.DisambiguationConfig{}, fmt.Errorf("cannot resolve tracker mapping agent client: %w", err)
|
||||
return cookiebanner.TrackerAgentsConfig{}, thirdparty.DisambiguationConfig{}, fmt.Errorf("cannot resolve tracker mapping agent client: %w", err)
|
||||
}
|
||||
|
||||
mappingCfg := cookiebanner.TrackerMappingConfig{
|
||||
trackerAgentsCfg := cookiebanner.TrackerAgentsConfig{
|
||||
LLMClient: llmClient,
|
||||
Model: agentCfg.ModelName,
|
||||
FirecrawlAPIKey: impl.cfg.Agents.Tools.FirecrawlAPIKey,
|
||||
@@ -67,5 +68,5 @@ func (impl *Implm) buildTrackerMappingConfig(
|
||||
Model: agentCfg.ModelName,
|
||||
}
|
||||
|
||||
return mappingCfg, disambiguationCfg, nil
|
||||
return trackerAgentsCfg, disambiguationCfg, nil
|
||||
}
|
||||
Reference in New Issue
Block a user