← Back to Pull requests

comp/core/workloadmeta: forget the SBOMs of removed images #57709

Open
0intro opened this pull request with 184 lines diff across 7 files
View on GitHub
0intro 0intro commented on Oct 07, 2026 11:15 UTC
Author

The remote SBOM collector publishes the image SBOMs it enriches with
runtime usage under its own source, and CRI-O publishes the SBOMs of its
images under the trivy source. When the runtime removed an image, both
entities stayed for the life of the core agent. A pull of the same image
then brought the old enriched SBOM back before any container ran, and
its status kept containerd, docker and CRI-O from scanning the image
again. The entities also piled up with image churn.

Unset the image entity of the remote SBOM collector once the runtime
source unsets the image, and in CRI-O unset the trivy entity with the
runtime one.

Diff: 184 lines (+162 / -22) across 7 files Reviewer: frank-spano Review duration: 17440m
All Vouch review confidence checks passed
Residual risk 0.07 = Change Risk (0.43) × (1 − Review Confidence (0.85)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 184 lines diff across 7 files
0.43
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.79 · 5 substantive comment(s)
0.79
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
84%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.312
Real PR Conversation Timeline
15 items
github-actions[bot] github-actions[bot] commented on code on Oct 07, 2026 11:17 UTC
Code Review
comp/core/workloadmeta/collectors/internal/remote/sbomcollector/sbom_collector_test.go:1
@@ -467,3 +475,35 @@ func TestHandleResyncNotifiesEvents(t *testing.T) {
 
 	assert.Equal(t, events, store.notified)
 }
+
+// TestForgetRemovedImages checks that the image entity of the collector goes
+// once the runtime removes the image, so that a pull of the same image starts
+// from the SBOM of its new scan.
+func TestForgetRemovedImages(t *testing.T) {
+	store := fxutil.Test[workloadmetamock.Mock](t, fx.Options(
+		fx.Provide(func() log.Component { return logmock.New(t) }),
+		fx.Provide(func() config.Component { return config.NewMock(t) }),
+		fx.Supply(context.Background()),
+		workloadmetafxmock.MockModule(workloadmeta.NewParams()),
+	))
+
+	ctx, cancel := context.WithCancel(context.Background())
+	defer cancel()
+	forgetRemovedImages(ctx, store)
+
+	image := seedImageSBOM(t, "sha256:abc", workloadmeta.Success, component("bash", "5.1"))
+	store.Notify([]workloadmeta.CollectorEvent{
+		{Type: workloadmeta.EventTypeSet, Source: workloadmeta.SourceRuntime, Entity: image},
+		{Type: workloadmeta.EventTypeSet, Source: workloadmeta.SourceRemoteSBOMCollector, Entity: image},
+	})
+	store.Notify([]workloadmeta.CollectorEvent{{
+		Type:   workloadmeta.EventTypeUnset,
+		Source: workloadmeta.SourceRuntime,
+		Entity: &workloadmeta.ContainerImageMetadata{EntityID: image.EntityID},
+	}})
+
+	assert.Eventually(t, func() bool {
+		_, err := store.GetImage(image.ID)
+		return err != nil
+	}, 10*time.Second, 10*time.Millisecond, "the image entity of the collector outlived the image")

[P2] Replace wall-clock polling with deterministic synchronization. assert.Eventually waits on a real ticker for background cleanup, making this new test timing-dependent and potentially adding ten seconds on failure. Use testing/synctest with a suitable fake, or explicitly signal cleanup completion, and assert the resulting store state once the work has finished.

github-actions[bot] github-actions[bot] commented on Oct 07, 2026 11:17 UTC
Reviewer

AI review by Codex (OpenAI) - workflow run

The patch is incorrect: the new cleanup test introduces wall-clock polling, contrary to the repository’s testing requirements. Static review found no other actionable regressions; tests were not run.

datadog-prod-us1-5[bot] datadog-prod-us1-5[bot] commented on Oct 07, 2026 11:30 UTC
Bot

🎯 Code Coverage (<a target='_blank' href='https://app.datadoghq.com/ci/code-coverage/github.com%2Fdatadog%2Fdatadog-agent/pull-requests/57709'>details</a>)<br>• <strong><span title="Percentage of modified executable lines covered by tests in this PR">Patch Coverage</span></strong>: 69.39%<br>• <strong><span title="Percentage of all executable lines covered by tests in the entire codebase">Overall Coverage</span></strong>: 58.90% <span title="Change in overall coverage compared to the base branch">(+0.00%)</span><br>

<sub>
This comment will be updated automatically if new data arrives. <br />
🔗 Commit SHA: 56a5874 | <a href="https://docs.datadoghq.com/integrations/guide/source-code-integration/#pr-comments">Docs</a> | Give us <a href="https://dd.enterprise.slack.com/archives/C07E3U2QRMM">feedback</a>!
</sub>

dd-octo-sts[bot] dd-octo-sts[bot] commented on Oct 07, 2026 11:55 UTC
Bot

Files inventory check summary

File checks results against ancestor 7f663ee2:

Results for datadog-agent_7.86.0~devel.git.525.56a5874.pipeline.145173011-1_amd64.deb:


No change detected

Results for datadog-iot-agent_7.86.0~devel.git.525.56a5874.pipeline.145173011-1_amd64.deb:


No change detected

dd-octo-sts[bot] dd-octo-sts[bot] commented on Oct 07, 2026 12:02 UTC
Bot

Static quality checks

✅ Please find below the results from static quality gates
Comparison made with ancestor 7f663ee22d542c8d312698275d461520b9c9087d
📊 Static Quality Gates Dashboard
🔗 SQG Job

<details open>
<summary>Successful checks</summary>

Info

||Quality gate|Change|Size (prev → curr → max)|
|--|--|--|--|
|✅|agent_deb_amd64|+4.0 KiB (0.00% increase, -0.03% of buffer)|748.626 → 748.630 → 760.600|
|✅|agent_deb_amd64_fips|+8.0 KiB (0.00% increase, -0.06% of buffer)|681.266 → 681.274 → 693.640|
|✅|agent_rpm_amd64|+4.0 KiB (0.00% increase, -0.03% of buffer)|748.610 → 748.613 → 760.580|
|✅|agent_rpm_amd64_fips|+8.0 KiB (0.00% increase, -0.06% of buffer)|681.250 → 681.258 → 693.620|
|✅|agent_rpm_arm64|+4.0 KiB (0.00% increase, -0.03% of buffer)|719.068 → 719.072 → 731.150|
|✅|agent_rpm_arm64_fips|+4.0 KiB (0.00% increase, -0.03% of buffer)|657.296 → 657.300 → 669.800|
|✅|agent_suse_amd64|+4.0 KiB (0.00% increase, -0.03% of buffer)|748.610 → 748.613 → 760.580|
|✅|agent_suse_amd64_fips|+8.0 KiB (0.00% increase, -0.06% of buffer)|681.250 → 681.258 → 693.620|
|✅|agent_suse_arm64|+4.0 KiB (0.00% increase, -0.03% of buffer)|719.068 → 719.072 → 731.150|
|✅|agent_suse_arm64_fips|+4.0 KiB (0.00% increase, -0.03% of buffer)|657.296 → 657.300 → 669.800|
|✅|docker_agent_amd64|+4.0 KiB (0.00% increase, -0.03% of buffer)|804.737 → 804.741 → 816.790|
|✅|docker_agent_arm64|+4.0 KiB (0.00% increase, -0.03% of buffer)|799.877 → 799.881 → 812.020|
|✅|docker_agent_jmx_amd64|+4.0 KiB (0.00% increase, -0.03% of buffer)|995.607 → 995.611 → 1007.660|
|✅|docker_agent_jmx_arm64|+4.0 KiB (0.00% increase, -0.03% of buffer)|979.527 → 979.531 → 991.670|

</details>
<details>
<summary>19 successful checks with minimal change (&lt; 2 KiB)</summary>

||Quality gate|Current Size|
|--|--|--|
|✅|agent_heroku_amd64|311.489 MiB|
|✅|agent_msi|650.633 MiB|
|✅|docker_cws_instrumentation_amd64|7.447 MiB|
|✅|docker_cws_instrumentation_arm64|6.877 MiB|
|✅|docker_dogstatsd_amd64|40.074 MiB|
|✅|docker_dogstatsd_arm64|38.136 MiB|
|✅|docker_host_profiler_amd64|309.011 MiB|
|✅|docker_host_profiler_arm64|320.078 MiB|
|✅|dogstatsd_deb_amd64|30.817 MiB|
|✅|dogstatsd_deb_arm64|28.763 MiB|
|✅|dogstatsd_rpm_amd64|30.817 MiB|
|✅|dogstatsd_suse_amd64|30.817 MiB|
|✅|iot_agent_deb_amd64|47.570 MiB|
|✅|iot_agent_deb_arm64|44.017 MiB|
|✅|iot_agent_deb_armhf|44.830 MiB|
|✅|iot_agent_rpm_amd64|47.571 MiB|
|✅|iot_agent_suse_amd64|47.569 MiB|
|✅|docker_cluster_agent_amd64|211.746 MiB|
|✅|docker_cluster_agent_arm64|224.672 MiB|

</details>

cit-pr-commenter-54b7da[bot] cit-pr-commenter-54b7da[bot] commented on Oct 07, 2026 12:34 UTC
Bot

Regression Detector

Regression Detector Results

Metrics dashboard
Target profiles
Job ID: 65432957-cd1c-4fe0-8839-876bbbe26834

Baseline: 49f90fcecbc54618f1e4a5ce050d2b419e4d46cc
Comparison: 56a5874a89986f048de7137c68fdd22feff3456d
[Diff](49f90fcecbc54618f1e4a5ce050d2b419e4d46cc...56a5874a89986f048de7137c68fdd22feff3456d)

Optimization Goals: ✅ No significant changes detected

<details>
<summary><h2>
Fine details of change detection per experiment
</h2></summary>

| perf | experiment | goal | Δ mean % | Δ mean % CI | trials | links |
|------|---------------------------------------------|--------------------|----------|----------------|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ➖ | quality_gate_logs | % cpu utilization | +0.63 | [-0.25, +1.51] | 1 | Logs bounds checks dashboard |
| ➖ | quality_gate_private_action_runner | memory utilization | +0.56 | [+0.44, +0.69] | 1 | Logs bounds checks dashboard |
| ➖ | quality_gate_security_mean_fs_load | memory utilization | +0.28 | [+0.25, +0.32] | 1 | Logs bounds checks dashboard |
| ➖ | quality_gate_security_idle | memory utilization | +0.20 | [+0.17, +0.24] | 1 | Logs bounds checks dashboard |
| ➖ | dsd_uds_10mb_3k_timestamped_contexts_cpu | % cpu utilization | +0.19 | [-0.07, +0.44] | 1 | Logs |
| ➖ | quality_gate_security_no_fs_load | memory utilization | -0.01 | [-0.07, +0.05] | 1 | Logs bounds checks dashboard |
| ➖ | dsd_uds_10mb_3k_timestamped_contexts_memory | memory utilization | -0.06 | [-0.28, +0.15] | 1 | Logs |
| ➖ | quality_gate_idle_all_features | memory utilization | -0.18 | [-0.26, -0.11] | 1 | Logs bounds checks dashboard |
| ➖ | python_openmetrics | % cpu utilization | -0.18 | [-0.86, +0.49] | 1 | Logs bounds checks dashboard |
| ➖ | dsd_uds_client_drop_detector_cpu | % cpu utilization | -0.19 | [-0.73, +0.35] | 1 | Logs |
| ➖ | quality_gate_idle | memory utilization | -0.27 | [-0.31, -0.23] | 1 | Logs bounds checks dashboard |
| ➖ | quality_gate_metrics_logs | memory utilization | -0.32 | [-0.54, -0.10] | 1 | Logs bounds checks dashboard |
</details>

<details>
<summary><h2>
Bounds Checks: ✅ Passed
</h2></summary>

| perf | experiment | bounds_check_name | replicates_passed | observed_value | links |
|------|------------------------------------|-----------------------|-------------------|-----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ✅ | python_openmetrics | checks_execution_time | 10/10 | 70.82 ≤ 100 | bounds checks dashboard |
| ✅ | python_openmetrics | cpu_usage | 10/10 | 1336.33 ≤ 1500 | bounds checks dashboard |
| ✅ | python_openmetrics | memory_usage | 10/10 | 4.31GiB ≤ 4.75GiB | bounds checks dashboard |
| ✅ | quality_gate_idle | intake_connections | 10/10 | 4 ≤ 5 | bounds checks dashboard |
| ✅ | quality_gate_idle | memory_usage | 10/10 | 176.19MiB ≤ 181MiB | bounds checks dashboard |
| ✅ | quality_gate_idle | total_bytes_received | 10/10 | 760.91KiB ≤ 819.20KiB | bounds checks dashboard |
| ✅ | quality_gate_idle_all_features | intake_connections | 10/10 | 2 ≤ 5 | bounds checks dashboard |
| ✅ | quality_gate_idle_all_features | memory_usage | 10/10 | 475.75MiB ≤ 542MiB | bounds checks dashboard |
| ✅ | quality_gate_idle_all_features | total_bytes_received | 10/10 | 1.14MiB ≤ 1.25MiB | bounds checks dashboard |
| ✅ | quality_gate_logs | intake_connections | 10/10 | 18 ≤ 40 | bounds checks dashboard |
| ✅ | quality_gate_logs | memory_usage | 10/10 | 221.85MiB ≤ 228MiB | bounds checks dashboard |
| ✅ | quality_gate_logs | missed_bytes | 10/10 | 0B = 0B | bounds checks dashboard |
| ✅ | quality_gate_logs | total_bytes_received | 10/10 | 263.89MiB ≤ 292MiB | bounds checks dashboard |
| ✅ | quality_gate_metrics_logs | cpu_usage | 10/10 | 353.55 ≤ 2000 | bounds checks dashboard |
| ✅ | quality_gate_metrics_logs | intake_connections | 10/10 | 20 ≤ 40 | bounds checks dashboard |
| ✅ | quality_gate_metrics_logs | memory_usage | 10/10 | 408.33MiB ≤ 455MiB | bounds checks dashboard |
| ✅ | quality_gate_metrics_logs | missed_bytes | 10/10 | 0B = 0B | bounds checks dashboard |
| ✅ | quality_gate_metrics_logs | total_bytes_received | 10/10 | 0.95GiB ≤ 1.04GiB | bounds checks dashboard |
| ✅ | quality_gate_private_action_runner | memory_usage | 10/10 | 74.09MiB ≤ 77MiB | bounds checks dashboard |
| ✅ | quality_gate_security_idle | cpu_usage | 10/10 | 27.84 ≤ 100 | bounds checks dashboard |
| ✅ | quality_gate_security_idle | memory_usage | 10/10 | 322.05MiB ≤ 357MiB | bounds checks dashboard |
| ✅ | quality_gate_security_mean_fs_load | cpu_usage | 10/10 | 39.55 ≤ 200 | bounds checks dashboard |
| ✅ | quality_gate_security_mean_fs_load | memory_usage | 10/10 | 307.14MiB ≤ 337MiB | bounds checks dashboard |
| ✅ | quality_gate_security_no_fs_load | cpu_usage | 10/10 | 21.51 ≤ 100 | bounds checks dashboard |
| ✅ | quality_gate_security_no_fs_load | memory_usage | 10/10 | 317.46MiB ≤ 348MiB | bounds checks dashboard |
</details>

<details>
<summary><h2>
Explanation
</h2></summary>

Confidence level: 90.00%
Effect size tolerance: |Δ mean %| ≥ 5.00%

Performance changes are noted in the perf column of each table:

✅ = significantly better comparison variant performance
❌ = significantly worse comparison variant performance
➖ = no significant change in performance

A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".

For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:

1. Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.

2. Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate*, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.

3. Its configuration does not mark it "erratic".
</details>

CI Pass/Fail Decision

✅ Passed. All Quality Gates passed.

  • quality_gate_private_action_runner, bounds check memory_usage: 10/10 replicas passed. Gate passed.

  • quality_gate_security_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.

  • quality_gate_security_idle, bounds check cpu_usage: 10/10 replicas passed. Gate passed.

  • quality_gate_idle_all_features, bounds check memory_usage: 10/10 replicas passed. Gate passed.

  • quality_gate_idle_all_features, bounds check intake_connections: 10/10 replicas passed. Gate passed.

  • quality_gate_idle_all_features, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.

  • quality_gate_metrics_logs, bounds check cpu_usage: 10/10 replicas passed. Gate passed.

  • quality_gate_metrics_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.

  • quality_gate_metrics_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.

  • quality_gate_metrics_logs, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.

  • quality_gate_metrics_logs, bounds check missed_bytes: 10/10 replicas passed. Gate passed.

  • quality_gate_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.

  • quality_gate_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.

  • quality_gate_logs, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.

  • quality_gate_logs, bounds check missed_bytes: 10/10 replicas passed. Gate passed.

  • quality_gate_security_no_fs_load, bounds check memory_usage: 10/10 replicas passed. Gate passed.

  • quality_gate_security_no_fs_load, bounds check cpu_usage: 10/10 replicas passed. Gate passed.

  • quality_gate_security_mean_fs_load, bounds check memory_usage: 10/10 replicas passed. Gate passed.

  • quality_gate_security_mean_fs_load, bounds check cpu_usage: 10/10 replicas passed. Gate passed.

  • quality_gate_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.

  • quality_gate_idle, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.

  • quality_gate_idle, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • 0intro 0intro commented on code on Oct 07, 2026 12:35 UTC
    Code Review
    comp/core/workloadmeta/collectors/internal/remote/sbomcollector/sbom_collector_test.go:1
    @@ -467,3 +475,35 @@ func TestHandleResyncNotifiesEvents(t *testing.T) {
     
     	assert.Equal(t, events, store.notified)
     }
    +
    +// TestForgetRemovedImages checks that the image entity of the collector goes
    +// once the runtime removes the image, so that a pull of the same image starts
    +// from the SBOM of its new scan.
    +func TestForgetRemovedImages(t *testing.T) {
    +	store := fxutil.Test[workloadmetamock.Mock](t, fx.Options(
    +		fx.Provide(func() log.Component { return logmock.New(t) }),
    +		fx.Provide(func() config.Component { return config.NewMock(t) }),
    +		fx.Supply(context.Background()),
    +		workloadmetafxmock.MockModule(workloadmeta.NewParams()),
    +	))
    +
    +	ctx, cancel := context.WithCancel(context.Background())
    +	defer cancel()
    +	forgetRemovedImages(ctx, store)
    +
    +	image := seedImageSBOM(t, "sha256:abc", workloadmeta.Success, component("bash", "5.1"))
    +	store.Notify([]workloadmeta.CollectorEvent{
    +		{Type: workloadmeta.EventTypeSet, Source: workloadmeta.SourceRuntime, Entity: image},
    +		{Type: workloadmeta.EventTypeSet, Source: workloadmeta.SourceRemoteSBOMCollector, Entity: image},
    +	})
    +	store.Notify([]workloadmeta.CollectorEvent{{
    +		Type:   workloadmeta.EventTypeUnset,
    +		Source: workloadmeta.SourceRuntime,
    +		Entity: &workloadmeta.ContainerImageMetadata{EntityID: image.EntityID},
    +	}})
    +
    +	assert.Eventually(t, func() bool {
    +		_, err := store.GetImage(image.ID)
    +		return err != nil
    +	}, 10*time.Second, 10*time.Millisecond, "the image entity of the collector outlived the image")

    Done in 378e44f8783. The test subscribes to the unset events of the collector's source and waits for the one of the image, which the cleanup sends, then checks the store. It passes in 0.02 s. The 10 s timer only bounds a failure.

    github-actions[bot] github-actions[bot] commented on code on Oct 07, 2026 14:04 UTC
    Code Review
    comp/core/workloadmeta/collectors/internal/remote/sbomcollector/sbom_collector.go:1
    @@ -187,16 +187,71 @@ func workloadmetaEventFromSBOMEventSet(store workloadmeta.Component, event *sbom
     	}, nil
     }
     
    +// collector merges the reports of system-probe into image SBOMs, and forgets
    +// them once the runtime removes their image.
    +type collector struct {
    +	*remote.GenericCollector
    +}
    +
    +// Start starts the stream of reports and the watch of removed images
    +func (c *collector) Start(ctx context.Context, store workloadmeta.Component) error {
    +	if err := c.GenericCollector.Start(ctx, store); err != nil {
    +		return err
    +	}
    +	forgetRemovedImages(ctx, store)
    +	return nil
    +}
    +
    +// forgetRemovedImages unsets the image entities of this collector once the
    +// runtime removes their image.
    +func forgetRemovedImages(ctx context.Context, store workloadmeta.Component) {
    +	filter := workloadmeta.NewFilterBuilder().
    +		AddKind(workloadmeta.KindContainerImageMetadata).
    +		SetSource(workloadmeta.SourceRuntime).
    +		SetEventType(workloadmeta.EventTypeUnset).
    +		Build()
    +	ch := store.Subscribe(collectorID, workloadmeta.NormalPriority, filter)
    +
    +	go func() {
    +		defer store.Unsubscribe(ch)
    +		for {
    +			select {
    +			case <-ctx.Done():
    +				return
    +			case bundle, ok := <-ch:
    +				if !ok {
    +					return
    +				}
    +				bundle.Acknowledge()
    +				if len(bundle.Events) == 0 {
    +					continue
    +				}
    +				events := make([]workloadmeta.CollectorEvent, 0, len(bundle.Events))
    +				for _, ev := range bundle.Events {
    +					events = append(events, workloadmeta.CollectorEvent{
    +						Type:   workloadmeta.EventTypeUnset,
    +						Source: workloadmeta.SourceRemoteSBOMCollector,
    +						Entity: &workloadmeta.ContainerImageMetadata{EntityID: ev.Entity.GetID()},
    +					})
    +				}
    +				store.Notify(events)

    [P2] Order cleanup with image removal and subsequent updates

    This unconditional unset runs asynchronously after acknowledging the runtime deletion. If the same image ID is pulled again and the remote stream publishes a fresh enriched SBOM before this goroutine queues its cleanup, the delayed unset deletes that fresh SBOM. The runtime image remains, but its new runtime usage is lost until another report arrives. Apply cleanup atomically with the runtime unset, or use generation-aware ordering so a deletion cannot remove a later update; add a regression test that interleaves removal, re-creation, and enrichment.

    github-actions[bot] github-actions[bot] commented on Oct 07, 2026 14:04 UTC
    Reviewer

    AI review by Codex (OpenAI) - workflow run

    patch is incorrect: the asynchronous cleanup can delete a newly published SBOM when an image is removed and quickly re-created. The added test covers only deletion without concurrent updates.

    0intro 0intro commented on code on Oct 07, 2026 14:07 UTC
    Code Review
    comp/core/workloadmeta/collectors/internal/remote/sbomcollector/sbom_collector.go:1
    @@ -187,16 +187,71 @@ func workloadmetaEventFromSBOMEventSet(store workloadmeta.Component, event *sbom
     	}, nil
     }
     
    +// collector merges the reports of system-probe into image SBOMs, and forgets
    +// them once the runtime removes their image.
    +type collector struct {
    +	*remote.GenericCollector
    +}
    +
    +// Start starts the stream of reports and the watch of removed images
    +func (c *collector) Start(ctx context.Context, store workloadmeta.Component) error {
    +	if err := c.GenericCollector.Start(ctx, store); err != nil {
    +		return err
    +	}
    +	forgetRemovedImages(ctx, store)
    +	return nil
    +}
    +
    +// forgetRemovedImages unsets the image entities of this collector once the
    +// runtime removes their image.
    +func forgetRemovedImages(ctx context.Context, store workloadmeta.Component) {
    +	filter := workloadmeta.NewFilterBuilder().
    +		AddKind(workloadmeta.KindContainerImageMetadata).
    +		SetSource(workloadmeta.SourceRuntime).
    +		SetEventType(workloadmeta.EventTypeUnset).
    +		Build()
    +	ch := store.Subscribe(collectorID, workloadmeta.NormalPriority, filter)
    +
    +	go func() {
    +		defer store.Unsubscribe(ch)
    +		for {
    +			select {
    +			case <-ctx.Done():
    +				return
    +			case bundle, ok := <-ch:
    +				if !ok {
    +					return
    +				}
    +				bundle.Acknowledge()
    +				if len(bundle.Events) == 0 {
    +					continue
    +				}
    +				events := make([]workloadmeta.CollectorEvent, 0, len(bundle.Events))
    +				for _, ev := range bundle.Events {
    +					events = append(events, workloadmeta.CollectorEvent{
    +						Type:   workloadmeta.EventTypeUnset,
    +						Source: workloadmeta.SourceRemoteSBOMCollector,
    +						Entity: &workloadmeta.ContainerImageMetadata{EntityID: ev.Entity.GetID()},
    +					})
    +				}
    +				store.Notify(events)

    The cleanup is queued as soon as the store delivers the runtime unset, within milliseconds. A fresh enriched SBOM takes a new pull, a Trivy scan reaching Success and a merged report, seconds to minutes later, so it lands after the cleanup. A report that merges inside that window lands on the entity of the removed image and goes with it, and the next report of a container of the pulled image merges again. I would keep the ordering as it is.

    frank-spano frank-spano approved these changes on Oct 07, 2026 14:20 UTC
    Approved Reviewer

    Approved these changes.

    sarrazaghbib-dev sarrazaghbib-dev approved these changes on Oct 19, 2026 12:56 UTC
    Approved Reviewer

    Approved these changes.

    0intro 0intro commented on Oct 19, 2026 13:28 UTC
    Author

    /merge

    gh-worker-devflow-routing-ef8351[bot] gh-worker-devflow-routing-ef8351[bot] commented on Oct 19, 2026 13:28 UTC
    Bot

    <!-- "FeedbackWorkflowId":"ed2a8a1e-36ad-4a0e-a89e-9b34816445c8_36" -->
    View all feedbacks in Devflow UI.

    2026-10-19 13:28:37 UTC :information_source: Start processing command /merge
    Use /merge -c to cancel this operation!

    ---
    2026-10-19 13:28:42 UTC :information_source: MergeQueue: pull request added to the queue

    The expected merge time in main is approximately 2h (p90).

    Use /merge -c to cancel this operation!

    ---
    <div align="right">

    :hourglass_flowing_sand: Building merge commit 0886b70d14 in pipeline 1081367623011917264...

    </div>

    Reviewers
    Assignees
    0intro 0intro
    Labels
    risk: low confidence: 84.9% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 43% (MEDIUM) · Higher = larger blast radius
    43%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 84.9% · Lower = rushed or shallow review
    84.9%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 6.5% · Safe to merge
    6.5%