157157 "changed" ,
158158 "integrity" ,
159159]
160+ HealthScope = Literal ["repository" ]
161+ SummaryFocus = Literal ["repository" , "production" , "changed_paths" ]
160162
161163_LEGACY_CACHE_PATH = Path ("~/.cache/codeclone/cache.json" ).expanduser ()
162164_REPORT_DUMMY_PATH = Path (".cache/codeclone/report.json" )
165+ _HEALTH_SCOPE_REPOSITORY : Final [HealthScope ] = "repository"
166+ _FOCUS_REPOSITORY : Final [SummaryFocus ] = "repository"
167+ _FOCUS_PRODUCTION : Final [SummaryFocus ] = "production"
168+ _FOCUS_CHANGED_PATHS : Final [SummaryFocus ] = "changed_paths"
163169_MCP_CONFIG_KEYS = frozenset (
164170 {
165171 "min_loc" ,
@@ -1662,11 +1668,20 @@ def get_production_triage(
16621668 ]
16631669 payload : dict [str , object ] = {
16641670 "run_id" : self ._short_run_id (record .run_id ),
1671+ "focus" : _FOCUS_PRODUCTION ,
1672+ "health_scope" : _HEALTH_SCOPE_REPOSITORY ,
16651673 "health" : dict (self ._summary_health_payload (summary )),
16661674 "cache" : dict (self ._as_mapping (summary .get ("cache" ))),
16671675 "findings" : {
16681676 "total" : len (findings ),
16691677 "by_source_kind" : findings_breakdown ,
1678+ "new_by_source_kind" : dict (
1679+ self ._as_mapping (
1680+ self ._as_mapping (summary .get ("findings" )).get (
1681+ "new_by_source_kind"
1682+ )
1683+ )
1684+ ),
16701685 "outside_focus" : len (findings )
16711686 - findings_breakdown [SOURCE_KIND_PRODUCTION ],
16721687 },
@@ -3228,13 +3243,19 @@ def _build_changed_projection(
32283243 known_count = sum (
32293244 1 for item in items if str (item .get ("novelty" , "" )) == "known"
32303245 )
3246+ new_by_source_kind = self ._source_kind_breakdown (
3247+ item .get ("source_kind" )
3248+ for item in items
3249+ if str (item .get ("novelty" , "" )) == "new"
3250+ )
32313251 health_delta = self ._summary_health_delta (record .summary )
32323252 return {
32333253 "run_id" : self ._short_run_id (record .run_id ),
32343254 "changed_paths" : list (record .changed_paths ),
32353255 "total" : len (items ),
32363256 "new" : new_count ,
32373257 "known" : known_count ,
3258+ "new_by_source_kind" : new_by_source_kind ,
32383259 "items" : items ,
32393260 "health" : dict (self ._summary_health_payload (record .summary )),
32403261 "health_delta" : health_delta ,
@@ -3260,6 +3281,8 @@ def _changed_analysis_payload(
32603281 )
32613282 return {
32623283 "run_id" : self ._short_run_id (record .run_id ),
3284+ "focus" : _FOCUS_CHANGED_PATHS ,
3285+ "health_scope" : _HEALTH_SCOPE_REPOSITORY ,
32633286 "changed_files" : len (record .changed_paths ),
32643287 "health" : health_payload ,
32653288 "analysis_profile" : self ._summary_analysis_profile_payload (record .summary ),
@@ -3270,6 +3293,9 @@ def _changed_analysis_payload(
32703293 ),
32713294 "verdict" : str (changed_projection .get ("verdict" , "stable" )),
32723295 "new_findings" : _as_int (changed_projection .get ("new" , 0 ), 0 ),
3296+ "new_by_source_kind" : dict (
3297+ self ._as_mapping (changed_projection .get ("new_by_source_kind" ))
3298+ ),
32733299 "resolved_findings" : 0 ,
32743300 "changed_findings" : [],
32753301 }
@@ -4003,6 +4029,8 @@ def _summary_payload(
40034029 and not summary .get ("baseline" )
40044030 ):
40054031 return {
4032+ "focus" : _FOCUS_REPOSITORY ,
4033+ "health_scope" : _HEALTH_SCOPE_REPOSITORY ,
40064034 "inventory" : self ._summary_inventory_payload (inventory ),
40074035 "health" : self ._summary_health_payload (summary ),
40084036 }
@@ -4011,6 +4039,8 @@ def _summary_payload(
40114039 )
40124040 payload : dict [str , object ] = {
40134041 "run_id" : self ._short_run_id (resolved_run_id ) if resolved_run_id else "" ,
4042+ "focus" : _FOCUS_REPOSITORY ,
4043+ "health_scope" : _HEALTH_SCOPE_REPOSITORY ,
40144044 "version" : str (summary .get ("codeclone_version" , __version__ )),
40154045 "schema" : str (summary .get ("report_schema_version" , REPORT_SCHEMA_VERSION )),
40164046 "mode" : str (summary .get ("analysis_mode" , "" )),
@@ -4149,6 +4179,7 @@ def _summary_findings_payload(
41494179 "known" : 0 ,
41504180 "by_family" : {},
41514181 "production" : 0 ,
4182+ "new_by_source_kind" : self ._source_kind_breakdown (()),
41524183 }
41534184 findings = self ._base_findings (record )
41544185 by_family : dict [str , int ] = {
@@ -4160,6 +4191,11 @@ def _summary_findings_payload(
41604191 new_count = 0
41614192 known_count = 0
41624193 production_count = 0
4194+ new_by_source_kind = self ._source_kind_breakdown (
4195+ self ._finding_source_kind (finding )
4196+ for finding in findings
4197+ if str (finding .get ("novelty" , "" )).strip () == "new"
4198+ )
41634199 for finding in findings :
41644200 family = str (finding .get ("family" , "" )).strip ()
41654201 family_key = "clones" if family == FAMILY_CLONE else family
@@ -4177,6 +4213,7 @@ def _summary_findings_payload(
41774213 "known" : known_count ,
41784214 "by_family" : {key : value for key , value in by_family .items () if value > 0 },
41794215 "production" : production_count ,
4216+ "new_by_source_kind" : new_by_source_kind ,
41804217 }
41814218
41824219 def _summary_diff_payload (
0 commit comments