Promote on detection

Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
Émile Ré
2026-05-26 16:01:01 +02:00
parent ceb98740a5
commit 27a9f83825
6 changed files with 194 additions and 4 deletions

View File

@@ -2207,6 +2207,26 @@ func (s *Service) reportDetectedTracker(
if err == nil {
patternID = &matchedPattern.ID
*matchedPatternIDs = append(*matchedPatternIDs, matchedPattern.ID)
// A glob (or exact) pattern already covers this
// identifier, so no new exact pattern will be created
// and the merge/adoption loops in
// patternAnalysisHandler.Process will never see this
// detection. Promote the matched pattern's source here
// if the incoming detection carries a stronger signal,
// otherwise a pattern that started life as PRE_EXISTING
// (or EXTENSION) never advances even when subsequent
// SCRIPT-source detections confirm it as a real page
// tracker — last_matched_at would move forward but
// source would stay stale. shouldPromoteSource is a
// no-op when info.Source is nil or weaker, so storage
// items without a source and weaker re-detections cost
// nothing.
if shouldPromoteSource(matchedPattern.Source, info.Source) {
if err := matchedPattern.PromoteSource(ctx, tx, scope, *info.Source, now); err != nil {
return fmt.Errorf("cannot promote source on matched tracker pattern %q: %w", matchedPattern.Pattern, err)
}
}
} else {
newPattern := &coredata.TrackerPattern{
ID: gid.New(scope.GetTenantID(), coredata.TrackerPatternEntityType),