Re-trigger mapping when a tracker source is promoted

A tracker pattern's source ratchets PRE_EXISTING -> EXTENSION -> SCRIPT
as stronger detections arrive, but that promotion was never reflected
back to the mapping pipeline. The detection that promotes the source
also brings a fresh initiator domain that matchByDomain and
matchBySiblingOrigin can use, and an EXTENSION -> SCRIPT promotion lifts
the creationAllowed gate that blocks org third-party creation. Yet the
pattern's mapping_requested_at was already cleared after its first pass,
so the worker never revisited it.

Re-arm mapping_requested_at via SetMappingRequested at each
source-promotion site (reportDetectedTracker plus the glob-merge and
adoption paths in the pattern-analysis worker). Update's SET clause does
not cover mapping_requested_at, so assigning the field before Update
would be a silent no-op; SetMappingRequested only writes when the column
is NULL, keeping already-queued patterns from being double-enqueued.

Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
Émile Ré
2026-05-29 01:29:40 +02:00
parent 8c10997681
commit 62aa4a2dc4
3 changed files with 23 additions and 3 deletions

View File

@@ -208,6 +208,13 @@ func (h *patternAnalysisHandler) Process(ctx context.Context, banner coredata.Co
if err := globPattern.Update(ctx, tx, scope); err != nil {
return fmt.Errorf("cannot promote source on glob pattern %q: %w", key.template, err)
}
// A stronger source can unblock mapping (e.g.
// EXTENSION->SCRIPT lifts the creationAllowed
// gate), so re-arm mapping on the existing glob.
if err := globPattern.SetMappingRequested(ctx, tx); err != nil {
return fmt.Errorf("cannot request mapping after source promotion on glob pattern %q: %w", key.template, err)
}
}
}
@@ -798,6 +805,13 @@ func (h *patternAnalysisHandler) adoptUncategorisedPatterns(
if err := match.Update(ctx, tx, scope); err != nil {
return false, fmt.Errorf("cannot promote source on glob pattern %q: %w", match.Pattern, err)
}
// A stronger source can unblock mapping (e.g.
// EXTENSION->SCRIPT lifts the creationAllowed gate), so
// re-arm mapping on the adopted glob.
if err := match.SetMappingRequested(ctx, tx); err != nil {
return false, fmt.Errorf("cannot request mapping after source promotion on glob pattern %q: %w", match.Pattern, err)
}
}
if err := ep.Delete(ctx, tx, scope); err != nil {