2026 bugdire device inventory count growing beyond 50k #2484

Merged
mfreeman451 merged 5 commits from refs/pull/2484/head into main 2025-11-28 00:53:29 +00:00
mfreeman451 commented 2025-11-27 20:07:48 +00:00 (Migrated from github.com)
Owner

Imported from GitHub pull request.

Original GitHub pull request: #2027
Original author: @mfreeman451
Original URL: https://github.com/carverauto/serviceradar/pull/2027
Original created: 2025-11-27T20:07:48Z
Original updated: 2025-11-29T00:43:56Z
Original head: carverauto/serviceradar:2026-bugdire-device-inventory-count-growing-beyond-50k
Original base: main
Original merged: 2025-11-28T00:53:29Z by @mfreeman451

User description

IMPORTANT: Please sign the Developer Certificate of Origin

Thank you for your contribution to ServiceRadar. Please note, when contributing, the developer must include
a DCO sign-off statement indicating the DCO acceptance in one commit message. Here
is an example DCO Signed-off-by line in a commit message:

Signed-off-by: J. Doe <j.doe@domain.com>

Describe your changes

Code checklist before requesting a review

  • I have signed the DCO?
  • The build completes without errors?
  • All tests are passing when running make test?

PR Type

Bug fix, Enhancement


Description

  • Stabilize device inventory at 50k by enforcing single IP per device and bounded IP pool management

  • Implement strong-ID merging across IP churn to prevent duplicate device creation

  • Add cardinality drift detection and promotion blocking when device count exceeds baseline

  • Mark promoted sightings as unavailable until positive probe confirms availability

  • Add identity drift metrics and Prometheus monitoring infrastructure


Diagram Walkthrough

flowchart LR
  A["Device Updates<br/>with Strong IDs"] -->|batch-level tracking| B["DeviceIdentityResolver<br/>ResolveDeviceIDs"]
  B -->|merge across churn| C["Single Device UUID<br/>per Strong ID"]
  C -->|check cardinality| D["blockPromotionForCardinalityDrift"]
  D -->|current > baseline| E["Pause Promotion<br/>Record Metrics"]
  D -->|within tolerance| F["Allow Promotion"]
  F -->|mark unavailable| G["Promoted Sighting<br/>IsAvailable=false"]
  H["Faker IP Shuffle<br/>Bounded Pool"] -->|allocate from pool| I["Fixed 50k IPs<br/>+ Headroom"]
  I -->|no expansion| J["Cardinality Stable"]

File Walkthrough

Relevant files
Enhancement
5 files
main.go
Implement bounded IP pool and strong-ID merge logic           
+240/-64
config.go
Define IdentityDriftConfig structure                                         
+9/-0     
device_identity.go
Add batch-level strong ID assignment tracking                       
+38/-0   
identity_metrics.go
Add cardinality drift metrics and gauges                                 
+77/-0   
registry.go
Implement cardinality drift blocking and availability semantics
+49/-1   
Tests
4 files
main_test.go
Add tests for IP cardinality and strong-ID preservation   
+99/-0   
device_identity_test.go
Add test for strong ID merging across IP churn                     
+56/-1   
identity_reconciliation_test.go
Add test for promoted sighting availability defaults         
+41/-0   
registry_test.go
Add end-to-end tests for cardinality and availability       
+393/-0 
Configuration changes
5 files
config.go
Add identity drift configuration defaults                               
+10/-0   
config.json
Add IP pool and expansion configuration parameters             
+4/-1     
faker.json
Add IP pool and expansion configuration parameters             
+4/-1     
serviceradar-config.yaml
Wire drift config and faker IP pool settings                         
+10/-1   
values.yaml
Add drift baseline and faker IP pool configuration             
+30/-22 
Documentation
8 files
identity_drift_monitoring.md
Document identity drift metrics and Prometheus alerts       
+44/-0   
kv_fix.md
Remove obsolete KV store migration documentation                 
+0/-441 
proposal.md
Add faker guardrails and availability enforcement requirements
+1/-0     
spec.md
Add strong-ID merge, availability, and drift detection requirements
+21/-0   
tasks.md
Add tasks for cardinality clamping and availability fixes
+4/-0     
proposal.md
Add Prometheus monitoring bridge proposal                               
+13/-0   
spec.md
Define Prometheus endpoint and metrics requirements           
+28/-0   
tasks.md
Add Prometheus exporter implementation tasks                         
+8/-0     

Imported from GitHub pull request. Original GitHub pull request: #2027 Original author: @mfreeman451 Original URL: https://github.com/carverauto/serviceradar/pull/2027 Original created: 2025-11-27T20:07:48Z Original updated: 2025-11-29T00:43:56Z Original head: carverauto/serviceradar:2026-bugdire-device-inventory-count-growing-beyond-50k Original base: main Original merged: 2025-11-28T00:53:29Z by @mfreeman451 --- ### **User description** ## IMPORTANT: Please sign the Developer Certificate of Origin Thank you for your contribution to ServiceRadar. Please note, when contributing, the developer must include a [DCO sign-off statement]( https://developercertificate.org/) indicating the DCO acceptance in one commit message. Here is an example DCO Signed-off-by line in a commit message: ``` Signed-off-by: J. Doe <j.doe@domain.com> ``` ## Describe your changes ## Issue ticket number and link ## Code checklist before requesting a review - [ ] I have signed the DCO? - [ ] The build completes without errors? - [ ] All tests are passing when running make test? ___ ### **PR Type** Bug fix, Enhancement ___ ### **Description** - Stabilize device inventory at 50k by enforcing single IP per device and bounded IP pool management - Implement strong-ID merging across IP churn to prevent duplicate device creation - Add cardinality drift detection and promotion blocking when device count exceeds baseline - Mark promoted sightings as unavailable until positive probe confirms availability - Add identity drift metrics and Prometheus monitoring infrastructure ___ ### Diagram Walkthrough ```mermaid flowchart LR A["Device Updates<br/>with Strong IDs"] -->|batch-level tracking| B["DeviceIdentityResolver<br/>ResolveDeviceIDs"] B -->|merge across churn| C["Single Device UUID<br/>per Strong ID"] C -->|check cardinality| D["blockPromotionForCardinalityDrift"] D -->|current > baseline| E["Pause Promotion<br/>Record Metrics"] D -->|within tolerance| F["Allow Promotion"] F -->|mark unavailable| G["Promoted Sighting<br/>IsAvailable=false"] H["Faker IP Shuffle<br/>Bounded Pool"] -->|allocate from pool| I["Fixed 50k IPs<br/>+ Headroom"] I -->|no expansion| J["Cardinality Stable"] ``` <details> <summary><h3> File Walkthrough</h3></summary> <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><details><summary>5 files</summary><table> <tr> <td><strong>main.go</strong><dd><code>Implement bounded IP pool and strong-ID merge logic</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/carverauto/serviceradar/pull/2027/files#diff-f101715b3bafbe3843ac9df0ffa3566fd0278b8f730efa3665557ce98acf6d23">+240/-64</a></td> </tr> <tr> <td><strong>config.go</strong><dd><code>Define IdentityDriftConfig structure</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/carverauto/serviceradar/pull/2027/files#diff-366a7f033cccba511935056e3e5bd509657f2e86213958a84b1d0d3ec606db83">+9/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>device_identity.go</strong><dd><code>Add batch-level strong ID assignment tracking</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/carverauto/serviceradar/pull/2027/files#diff-93615f2e83c891a2500d87cffd7cab7ad255b47f7621ecee79b753d84ab1af4e">+38/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td><strong>identity_metrics.go</strong><dd><code>Add cardinality drift metrics and gauges</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/carverauto/serviceradar/pull/2027/files#diff-fcd2f8364d180b314ea4b2676718fd233a91d0c5ef39daac2681cd9dadf885e1">+77/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td><strong>registry.go</strong><dd><code>Implement cardinality drift blocking and availability semantics</code></dd></td> <td><a href="https://github.com/carverauto/serviceradar/pull/2027/files#diff-cb61d8f79451b9541de4a8cc0811523a68d15452b2f5971c7618ea5b423cf4ec">+49/-1</a>&nbsp; &nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Tests</strong></td><td><details><summary>4 files</summary><table> <tr> <td><strong>main_test.go</strong><dd><code>Add tests for IP cardinality and strong-ID preservation</code>&nbsp; &nbsp; </dd></td> <td><a href="https://github.com/carverauto/serviceradar/pull/2027/files#diff-68ce2c81616afc25546483b905e33b001fabb6130335a36790931599d11dff3f">+99/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td><strong>device_identity_test.go</strong><dd><code>Add test for strong ID merging across IP churn</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/carverauto/serviceradar/pull/2027/files#diff-af686666ccf08b175566323b1044ac383d7a8ce54ffdcbcbd828385df1e032a3">+56/-1</a>&nbsp; &nbsp; </td> </tr> <tr> <td><strong>identity_reconciliation_test.go</strong><dd><code>Add test for promoted sighting availability defaults</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/carverauto/serviceradar/pull/2027/files#diff-88336acaf0fbf8dde7fff7b003101ff0b61dd2884e8294a960cc5aea22dd5f3b">+41/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td><strong>registry_test.go</strong><dd><code>Add end-to-end tests for cardinality and availability</code>&nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/carverauto/serviceradar/pull/2027/files#diff-f010972d104404be52d2a8e6e784cb56e31194f90795a69571a12696bcbdc075">+393/-0</a>&nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Configuration changes</strong></td><td><details><summary>5 files</summary><table> <tr> <td><strong>config.go</strong><dd><code>Add identity drift configuration defaults</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/carverauto/serviceradar/pull/2027/files#diff-a2dcdf3bac7ca59032d52f7a0635b5dbcfcb83a6f07cc45db8f57fba0cc33c30">+10/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td><strong>config.json</strong><dd><code>Add IP pool and expansion configuration parameters</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/carverauto/serviceradar/pull/2027/files#diff-ba43d74440db60b88388f254d9d2babae1d954c875b5571275b28f0a878014f1">+4/-1</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>faker.json</strong><dd><code>Add IP pool and expansion configuration parameters</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/carverauto/serviceradar/pull/2027/files#diff-a377a5efba3af4c8e8798eb1631232f1dea11bf1cd31630c6b88305349c96dca">+4/-1</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>serviceradar-config.yaml</strong><dd><code>Wire drift config and faker IP pool settings</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/carverauto/serviceradar/pull/2027/files#diff-b8c8d2484103b11c396bc60d290c81df63c30a0f81103eceb5852a17e1d2b5e3">+10/-1</a>&nbsp; &nbsp; </td> </tr> <tr> <td><strong>values.yaml</strong><dd><code>Add drift baseline and faker IP pool configuration</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/carverauto/serviceradar/pull/2027/files#diff-d4449c7cb70362554b274f81eae5a4b81a8e81df494282e383d1b7ea3871c452">+30/-22</a>&nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Documentation</strong></td><td><details><summary>8 files</summary><table> <tr> <td><strong>identity_drift_monitoring.md</strong><dd><code>Document identity drift metrics and Prometheus alerts</code>&nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/carverauto/serviceradar/pull/2027/files#diff-963ddfdc868c8777f9004744f5d2c5ec3ce585b81d1c0de2269b9d7a73942a9f">+44/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td><strong>kv_fix.md</strong><dd><code>Remove obsolete KV store migration documentation</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/carverauto/serviceradar/pull/2027/files#diff-c148df157c91809d994e107aff870b5e005fbff5be6a329b34721a2950b70627">+0/-441</a>&nbsp; </td> </tr> <tr> <td><strong>proposal.md</strong><dd><code>Add faker guardrails and availability enforcement requirements</code></dd></td> <td><a href="https://github.com/carverauto/serviceradar/pull/2027/files#diff-f3c3c8d9463a1c6eb3934bb6c516985accb7f58b402a0d5e414ff65c1c732bc3">+1/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>spec.md</strong><dd><code>Add strong-ID merge, availability, and drift detection requirements</code></dd></td> <td><a href="https://github.com/carverauto/serviceradar/pull/2027/files#diff-6e956f86e942a3106c94ea3f1a1bd46210c035e9240be297a488b639449d3e90">+21/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td><strong>tasks.md</strong><dd><code>Add tasks for cardinality clamping and availability fixes</code></dd></td> <td><a href="https://github.com/carverauto/serviceradar/pull/2027/files#diff-7d7c4d6b4718fd5255ec47aa62dee71b5da2c83ff2160164603454379b618181">+4/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>proposal.md</strong><dd><code>Add Prometheus monitoring bridge proposal</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/carverauto/serviceradar/pull/2027/files#diff-81a990985d497493238589e703ea366222940cc604a571ce21bfeca5bfc442e5">+13/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td><strong>spec.md</strong><dd><code>Define Prometheus endpoint and metrics requirements</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/carverauto/serviceradar/pull/2027/files#diff-f5daa5f8f49623f6cec383c2b7197ae8431b51bb217c391dd3f674a380bba00d">+28/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td><strong>tasks.md</strong><dd><code>Add Prometheus exporter implementation tasks</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/carverauto/serviceradar/pull/2027/files#diff-c00044e9668389895df2d518bf418b693b3a12ad3488e2926abbdd71b98644ba">+8/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr></tr></tbody></table> </details> ___
qodo-code-review[bot] commented 2025-11-27 20:08:26 +00:00 (Migrated from github.com)
Author
Owner

Imported GitHub PR comment.

Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/2027#issuecomment-3587168115
Original created: 2025-11-27T20:08:26Z

You are nearing your monthly Qodo Merge usage quota. For more information, please visit here.

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
Input validation risk

Description: The function replacePrimaryIP and related IP pool operations manipulate comma-separated IP
strings without strict validation, which could allow malformed inputs to be persisted or
logged if upstream sources are untrusted; add input validation or structured IP storage to
avoid potential injection/log pollution.
main.go [570-588]

Referred Code
// primaryIP returns the first IP in a comma-separated list.
func primaryIP(ips string) string {
	parts := strings.Split(strings.TrimSpace(ips), ",")
	if len(parts) == 0 {
		return ""
	}
	return strings.TrimSpace(parts[0])
}

// replacePrimaryIP swaps the first IP with the provided value while leaving any tail entries intact.
func replacePrimaryIP(ips, newPrimary string) string {
	if strings.TrimSpace(ips) == "" {
		return strings.TrimSpace(newPrimary)
	}

	parts := strings.Split(ips, ",")
	parts[0] = strings.TrimSpace(newPrimary)
	return strings.Join(parts, ",")
}
Ticket Compliance
🟡
🎫 #2026
🟢 Cap faker/DIRE generated device inventory at 50k and prevent growth beyond that baseline
despite IP churn.
Ensure IP churn simulation does not expand the IP address set and does not create
duplicate devices.
Merge devices across IP changes using strong identifiers so churn does not inflate device
count.
Provide detection and blocking when unified device count exceeds the configured baseline
(cardinality drift).
Add monitoring/metrics to observe identity/device cardinality drift and related gating.
Default promoted sightings to unavailable until a positive probe confirms availability.
Validate in an integrated environment that overall device inventory remains at ~50k under
sustained churn and over time, including after restarts and persistence reuse.
Confirm Prometheus scraping and dashboards/alerts are wired in real deployments and emit
expected drift metrics.
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status:
Audit Logging: New critical actions (promotion blocking via drift and reconciliation decisions) add only
warning/info logs without clear, structured audit records tied to actor/context, which may
be insufficient for audit trail requirements.

Referred Code
func (r *DeviceRegistry) ReconcileSightings(ctx context.Context) error {
	if r.identityCfg == nil || !r.identityCfg.Enabled {
		return nil
	}

	promoCfg := r.identityCfg.Promotion
	if !promoCfg.Enabled && !promoCfg.ShadowMode {
		return nil
	}

	if blocked := r.blockPromotionForCardinalityDrift(ctx); blocked {
		return nil
	}

	now := time.Now()
	cutoff := now.Add(-time.Duration(promoCfg.MinPersistence))
	sightings, err := r.db.ListPromotableSightings(ctx, cutoff)
	if err != nil {
		return fmt.Errorf("list promotable sightings: %w", err)
	}



 ... (clipped 323 lines)

Learn more about managing compliance generic rules or creating your own custom rules

  • Update
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
- Requires Further Human Verification
🏷️ - Compliance label
Imported GitHub PR comment. Original author: @qodo-code-review[bot] Original URL: https://github.com/carverauto/serviceradar/pull/2027#issuecomment-3587168115 Original created: 2025-11-27T20:08:26Z --- _You are nearing your monthly Qodo Merge usage quota. For more information, please visit [here](https://qodo-merge-docs.qodo.ai/installation/qodo_merge/#cloud-users)._ ## PR Compliance Guide 🔍 <!-- https://github.com/carverauto/serviceradar/commit/40a4452364e44495a4d472efc73dade4087ffdcb --> Below is a summary of compliance checks for this PR:<br> <table><tbody><tr><td colspan='2'><strong>Security Compliance</strong></td></tr> <tr><td rowspan=1>⚪</td> <td><details><summary><strong>Input validation risk</strong></summary><br> <b>Description:</b> The function <code>replacePrimaryIP</code> and related IP pool operations manipulate comma-separated IP <br>strings without strict validation, which could allow malformed inputs to be persisted or <br>logged if upstream sources are untrusted; add input validation or structured IP storage to <br>avoid potential injection/log pollution.<br> <strong><a href='https://github.com/carverauto/serviceradar/pull/2027/files#diff-f101715b3bafbe3843ac9df0ffa3566fd0278b8f730efa3665557ce98acf6d23R570-R588'>main.go [570-588]</a></strong><br> <details open><summary>Referred Code</summary> ```go // primaryIP returns the first IP in a comma-separated list. func primaryIP(ips string) string { parts := strings.Split(strings.TrimSpace(ips), ",") if len(parts) == 0 { return "" } return strings.TrimSpace(parts[0]) } // replacePrimaryIP swaps the first IP with the provided value while leaving any tail entries intact. func replacePrimaryIP(ips, newPrimary string) string { if strings.TrimSpace(ips) == "" { return strings.TrimSpace(newPrimary) } parts := strings.Split(ips, ",") parts[0] = strings.TrimSpace(newPrimary) return strings.Join(parts, ",") } ``` </details></details></td></tr> <tr><td colspan='2'><strong>Ticket Compliance</strong></td></tr> <tr><td>🟡</td> <td> <details> <summary>🎫 <a href=https://github.com/carverauto/serviceradar/issues/2026>#2026</a></summary> <table width='100%'><tbody> <tr><td rowspan=6>🟢</td> <td>Cap faker/DIRE generated device inventory at 50k and prevent growth beyond that baseline <br>despite IP churn.</td></tr> <tr><td>Ensure IP churn simulation does not expand the IP address set and does not create <br>duplicate devices.</td></tr> <tr><td>Merge devices across IP changes using strong identifiers so churn does not inflate device <br>count.</td></tr> <tr><td>Provide detection and blocking when unified device count exceeds the configured baseline <br>(cardinality drift).</td></tr> <tr><td>Add monitoring/metrics to observe identity/device cardinality drift and related gating.</td></tr> <tr><td>Default promoted sightings to unavailable until a positive probe confirms availability.</td></tr> <tr><td rowspan=2>⚪</td> <td>Validate in an integrated environment that overall device inventory remains at ~50k under <br>sustained churn and over time, including after restarts and persistence reuse.</td></tr> <tr><td>Confirm Prometheus scraping and dashboards/alerts are wired in real deployments and emit <br>expected drift metrics.</td></tr> </tbody></table> </details> </td></tr> <tr><td colspan='2'><strong>Codebase Duplication Compliance</strong></td></tr> <tr><td>⚪</td><td><details><summary><strong>Codebase context is not defined </strong></summary> Follow the <a href='https://qodo-merge-docs.qodo.ai/core-abilities/rag_context_enrichment/'>guide</a> to enable codebase context checks. </details></td></tr> <tr><td colspan='2'><strong>Custom Compliance</strong></td></tr> <tr><td rowspan=5>🟢</td><td> <details><summary><strong>Generic: Meaningful Naming and Self-Documenting Code</strong></summary><br> **Objective:** Ensure all identifiers clearly express their purpose and intent, making code <br>self-documenting<br> **Status:** Passed<br> > Learn more about managing compliance <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#configuration-options'>generic rules</a> or creating your own <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#custom-compliance'>custom rules</a> </details></td></tr> <tr><td> <details><summary><strong>Generic: Robust Error Handling and Edge Case Management</strong></summary><br> **Objective:** Ensure comprehensive error handling that provides meaningful context and graceful <br>degradation<br> **Status:** Passed<br> > Learn more about managing compliance <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#configuration-options'>generic rules</a> or creating your own <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#custom-compliance'>custom rules</a> </details></td></tr> <tr><td> <details><summary><strong>Generic: Secure Error Handling</strong></summary><br> **Objective:** To prevent the leakage of sensitive system information through error messages while <br>providing sufficient detail for internal debugging.<br> **Status:** Passed<br> > Learn more about managing compliance <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#configuration-options'>generic rules</a> or creating your own <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#custom-compliance'>custom rules</a> </details></td></tr> <tr><td> <details><summary><strong>Generic: Secure Logging Practices</strong></summary><br> **Objective:** To ensure logs are useful for debugging and auditing without exposing sensitive <br>information like PII, PHI, or cardholder data.<br> **Status:** Passed<br> > Learn more about managing compliance <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#configuration-options'>generic rules</a> or creating your own <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#custom-compliance'>custom rules</a> </details></td></tr> <tr><td> <details><summary><strong>Generic: Security-First Input Validation and Data Handling</strong></summary><br> **Objective:** Ensure all data inputs are validated, sanitized, and handled securely to prevent <br>vulnerabilities<br> **Status:** Passed<br> > Learn more about managing compliance <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#configuration-options'>generic rules</a> or creating your own <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#custom-compliance'>custom rules</a> </details></td></tr> <tr><td rowspan=1>⚪</td> <td><details> <summary><strong>Generic: Comprehensive Audit Trails</strong></summary><br> **Objective:** To create a detailed and reliable record of critical system actions for security analysis <br>and compliance.<br> **Status:** <br><a href='https://github.com/carverauto/serviceradar/pull/2027/files#diff-cb61d8f79451b9541de4a8cc0811523a68d15452b2f5971c7618ea5b423cf4ecR515-R858'><strong>Audit Logging</strong></a>: New critical actions (promotion blocking via drift and reconciliation decisions) add only <br>warning/info logs without clear, structured audit records tied to actor/context, which may <br>be insufficient for audit trail requirements.<br> <details open><summary>Referred Code</summary> ```go func (r *DeviceRegistry) ReconcileSightings(ctx context.Context) error { if r.identityCfg == nil || !r.identityCfg.Enabled { return nil } promoCfg := r.identityCfg.Promotion if !promoCfg.Enabled && !promoCfg.ShadowMode { return nil } if blocked := r.blockPromotionForCardinalityDrift(ctx); blocked { return nil } now := time.Now() cutoff := now.Add(-time.Duration(promoCfg.MinPersistence)) sightings, err := r.db.ListPromotableSightings(ctx, cutoff) if err != nil { return fmt.Errorf("list promotable sightings: %w", err) } ... (clipped 323 lines) ``` </details> > Learn more about managing compliance <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#configuration-options'>generic rules</a> or creating your own <a href='https://qodo-merge-docs.qodo.ai/tools/compliance/#custom-compliance'>custom rules</a> </details></td></tr> <tr><td align="center" colspan="2"> - [ ] Update <!-- /compliance --update_compliance=true --> </td></tr></tbody></table> <details><summary>Compliance status legend</summary> 🟢 - Fully Compliant<br> 🟡 - Partial Compliant<br> 🔴 - Not Compliant<br> ⚪ - Requires Further Human Verification<br> 🏷️ - Compliance label<br> </details>
qodo-code-review[bot] commented 2025-11-27 20:09:33 +00:00 (Migrated from github.com)
Author
Owner

Imported GitHub PR comment.

Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/2027#issuecomment-3587170221
Original created: 2025-11-27T20:09:33Z

You are nearing your monthly Qodo Merge usage quota. For more information, please visit here.

PR Code Suggestions

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Retry device selection on IP collision

In reassignIPsFromPool, retry finding a suitable device for a newly allocated IP
if the first randomly selected device is not a valid target. This increases the
effectiveness of the IP shuffle simulation.

cmd/faker/main.go [484-488]

-		oldIP := primaryIP(device.IPAddress)
-		if oldIP == "" || oldIP == newIP {
+		const maxRetries = 10
+		var device *ArmisDevice
+		var oldIP string
+		var found bool
+
+		for j := 0; j < maxRetries; j++ {
+			deviceIndex := randInt(0, n-1)
+			device = &gen.allDevices[deviceIndex]
+			oldIP = primaryIP(device.IPAddress)
+			if oldIP != "" && oldIP != newIP {
+				found = true
+				break
+			}
+		}
+
+		if !found {
 			gen.releaseIP(newIP)
 			continue
 		}
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why: The suggestion correctly identifies that not retrying to find a suitable device for a newIP can make the IP shuffle simulation less effective. Implementing a retry loop is a good improvement to make the simulation more robust, ensuring it is more likely to perform the intended number of IP changes.

Low
Avoid reporting metrics for disabled features

In blockPromotionForCardinalityDrift, avoid recording drift metrics when the
feature is disabled (drift.BaselineDevices <= 0). This prevents misleading
metrics from being reported.

pkg/registry/registry.go [822-825]

-	if drift.BaselineDevices <= 0 {
-		recordIdentityDriftMetrics(0, 0, drift.TolerancePercent, false)
+	if r.db == nil || r.identityCfg == nil || r.identityCfg.Drift.BaselineDevices <= 0 {
 		return false
 	}
 
+	drift := r.identityCfg.Drift
+
  • Apply / Chat
Suggestion importance[1-10]: 5

__

Why: The suggestion correctly points out that recording metrics for a disabled feature can be misleading. Exiting early when drift detection is disabled improves the clarity of monitoring data by ensuring metrics are only reported when the feature is active.

Low
  • Update
Imported GitHub PR comment. Original author: @qodo-code-review[bot] Original URL: https://github.com/carverauto/serviceradar/pull/2027#issuecomment-3587170221 Original created: 2025-11-27T20:09:33Z --- _You are nearing your monthly Qodo Merge usage quota. For more information, please visit [here](https://qodo-merge-docs.qodo.ai/installation/qodo_merge/#cloud-users)._ ## PR Code Suggestions ✨ <!-- 40a4452 --> Explore these optional code suggestions: <table><thead><tr><td><strong>Category</strong></td><td align=left><strong>Suggestion&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </strong></td><td align=center><strong>Impact</strong></td></tr><tbody><tr><td rowspan=2>General</td> <td> <details><summary>Retry device selection on IP collision<!-- not_implemented --></summary> ___ **In <code>reassignIPsFromPool</code>, retry finding a suitable device for a newly allocated IP <br>if the first randomly selected device is not a valid target. This increases the <br>effectiveness of the IP shuffle simulation.** [cmd/faker/main.go [484-488]](https://github.com/carverauto/serviceradar/pull/2027/files#diff-f101715b3bafbe3843ac9df0ffa3566fd0278b8f730efa3665557ce98acf6d23R484-R488) ```diff - oldIP := primaryIP(device.IPAddress) - if oldIP == "" || oldIP == newIP { + const maxRetries = 10 + var device *ArmisDevice + var oldIP string + var found bool + + for j := 0; j < maxRetries; j++ { + deviceIndex := randInt(0, n-1) + device = &gen.allDevices[deviceIndex] + oldIP = primaryIP(device.IPAddress) + if oldIP != "" && oldIP != newIP { + found = true + break + } + } + + if !found { gen.releaseIP(newIP) continue } ``` - [ ] **Apply / Chat** <!-- /improve --apply_suggestion=0 --> <details><summary>Suggestion importance[1-10]: 6</summary> __ Why: The suggestion correctly identifies that not retrying to find a suitable device for a `newIP` can make the IP shuffle simulation less effective. Implementing a retry loop is a good improvement to make the simulation more robust, ensuring it is more likely to perform the intended number of IP changes. </details></details></td><td align=center>Low </td></tr><tr><td> <details><summary>Avoid reporting metrics for disabled features</summary> ___ **In <code>blockPromotionForCardinalityDrift</code>, avoid recording drift metrics when the <br>feature is disabled (<code>drift.BaselineDevices <= 0</code>). This prevents misleading <br>metrics from being reported.** [pkg/registry/registry.go [822-825]](https://github.com/carverauto/serviceradar/pull/2027/files#diff-cb61d8f79451b9541de4a8cc0811523a68d15452b2f5971c7618ea5b423cf4ecR822-R825) ```diff - if drift.BaselineDevices <= 0 { - recordIdentityDriftMetrics(0, 0, drift.TolerancePercent, false) + if r.db == nil || r.identityCfg == nil || r.identityCfg.Drift.BaselineDevices <= 0 { return false } + drift := r.identityCfg.Drift + ``` - [ ] **Apply / Chat** <!-- /improve --apply_suggestion=1 --> <details><summary>Suggestion importance[1-10]: 5</summary> __ Why: The suggestion correctly points out that recording metrics for a disabled feature can be misleading. Exiting early when drift detection is disabled improves the clarity of monitoring data by ensuring metrics are only reported when the feature is active. </details></details></td><td align=center>Low </td></tr> <tr><td align="center" colspan="2"> - [ ] Update <!-- /improve_multi --more_suggestions=true --> </td><td></td></tr></tbody></table>
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
carverauto/serviceradar!2484
No description provided.