fix(quality): drop overflow Tier 2 companions instead of a doomed cluster - #214
Merged
Merged
Conversation
…ster _attach_companions_to_clusters() (PR #213) spilled a companion past MAX_FILES_PER_CLUSTER_PR into a brand-new <key>-also-included-N cluster that inherited the base cluster's target_findings. A companion-only cluster never contains a file that clears that finding, so clear_evidence_simulation_ok() refused it unconditionally, every run. Confirmed live on pulse-agent right after this pass deployed: container-also-included-1/-2 were refused on both subsequent Scans, each wasting a full validation pass and logging a misleading "refused"/"could not converge" warning, even though the real container fix PR still shipped underneath the noise. The existing unit test only asserted the overflow cluster's shape, never ran it through the clear-evidence gate with real non-clearing companion content. Overflow companions with no same-layer room are now dropped, same as a companion with no same-layer cluster at all. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause
The user ran Scan on
pulse-agentand the run appeared to produce nothing new — same reused PR (PulseSRE/pulse-agent#2), surrounded almost entirely by WARNING-severity "refused"/"could not converge" events.Investigation (Postgres
events/deliveries, live pod logs,occluster access) traced this to a real regression in PR #213 (_attach_companions_to_clusters()), deployed to the cluster at2026-07-29T19:51:16Z— squarely between two consecutive Scans on the same app, the first of which (19:41Z, pre-deploy) showed none of this behavior and the next two (20:16Z/20:21Z, post-deploy) both did.partition_by_finding_cluster()'s Tier 2 "companion" rescue attaches extra generated files to an existing same-layer Tier 1 fix cluster. When every same-layer cluster was already atMAX_FILES_PER_CLUSTER_PR, the overflow path spilled the leftover companions into a brand-new<key>-also-included-Ncluster that inherited the base cluster'starget_findings— e.g.container/dockerfile_pin. But that new cluster's only files are companions, which by definition never clear that finding.clear_evidence_simulation_ok()downstream therefore refused it unconditionally, every single time:This never blocked the real fix (the Tier 1
containercluster still delivered and updated PR #2 fine), but it wasted a full validation pass and logged confusing "refused" warnings on every Scan, making a successful run look like a failure. The existing test (test_companion_overflow_spills_into_a_new_chunk) only asserted the overflow cluster's shape — it never ran that cluster through the clear-evidence gate with real, non-clearing companion content, which is exactly why the local suite (mocks/fixtures) missed this and it only surfaced against live pulse-agent data.Fix
Overflow companions with no same-layer room left are now dropped, exactly like a companion whose layer matches no Tier 1 cluster at all — never spun into a new cluster that's mathematically guaranteed to fail its own gate.
Testing
test_companion_overflow_is_dropped_not_spilled_into_a_doomed_cluster,test_companion_overflow_cluster_would_have_failed_clear_evidence, andtest_pulse_agent_container_incident_reproduction(uses the realcontainer/containerfile/otel_setup.py-shaped data from the live incident).git stash) and pass with the fix.3518 passed, 454 skipped(no regressions).CHANGELOG.md,docs/release-notes.md, andREADME.mdper repo convention.Not merging — opening for review per usual process.
Made with Cursor