@@ -155,9 +155,30 @@ def _print_histogram(hist, scored, hard_flags, wrote_cache) -> None:
155155 print ("\n cache: wrote full Tier 0 scores to data/_verify/state/scores.jsonl" )
156156
157157
158+ def _band_bar (green : int , yellow : int , red : int , width : int = 12 ) -> str :
159+ """Proportional colored-square bar: 🟩 green · 🟨 yellow · 🟥 red, summing to width."""
160+ tot = green + yellow + red
161+ if tot == 0 :
162+ return "—"
163+ cells = {"🟩" : green , "🟨" : yellow , "🟥" : red }
164+ counts = {k : round (width * v / tot ) for k , v in cells .items ()}
165+ # Reconcile rounding so the bar is exactly `width` wide.
166+ while sum (counts .values ()) > width :
167+ counts [max (counts , key = counts .get )] -= 1
168+ while sum (counts .values ()) < width :
169+ # give the slack to the largest non-zero raw bucket
170+ counts [max (cells , key = cells .get )] += 1
171+ # Don't let a non-zero band vanish to 0 cells.
172+ for k in cells :
173+ if cells [k ] > 0 and counts [k ] == 0 :
174+ counts [k ] = 1
175+ counts [max (counts , key = counts .get )] -= 1
176+ return "🟩" * counts ["🟩" ] + "🟨" * counts ["🟨" ] + "🟥" * counts ["🟥" ]
177+
178+
158179def _print_markdown (hist , scored , hard_flags ) -> None :
159- """GitHub-flavored markdown table — readable in PR comments (mirrors the
160- TechEngineBot validation-stats style) ."""
180+ """Readable PR-comment report: a Mermaid pie of the overall band split (GitHub
181+ renders it natively) + a per-category table with a proportional colored bar ."""
161182 if scored == 0 :
162183 print ("_No records scored._" )
163184 return
@@ -170,17 +191,29 @@ def _print_markdown(hist, scored, hard_flags) -> None:
170191 tot = sum (c .values ())
171192 totals .update (c )
172193 gpct = 100 * c ["green" ] / tot if tot else 0.0
194+ bar = _band_bar (c ["green" ], c ["yellow" ], c ["red" ])
173195 rows .append (
174- f"| { cat } | { tot } | { c ['green' ]} | { c ['yellow' ]} | { c ['red' ]} | { gpct :.1f} % |"
196+ f"| { cat } | { bar } | { tot } | { c ['green' ]} | { c ['yellow' ]} | { c ['red' ]} | { gpct :.1f} % |"
175197 )
176198 gtot = sum (totals .values ()) or 1
177199 print (f"**{ scored } record(s) scored.**\n " )
178- print ("| Category | Total | 🟢 Green | 🟡 Yellow | 🔴 Red | Green % |" )
179- print ("| --- | ---: | ---: | ---: | ---: | ---: |" )
200+
201+ # Overall distribution as a Mermaid pie (rendered by GitHub).
202+ print ("```mermaid" )
203+ print ("pie showData" )
204+ print (' title Verification bands — all records' )
205+ print (f' "Green" : { totals ["green" ]} ' )
206+ print (f' "Yellow" : { totals ["yellow" ]} ' )
207+ print (f' "Red" : { totals ["red" ]} ' )
208+ print ("```\n " )
209+
210+ print ("| Category | Distribution | Total | 🟢 | 🟡 | 🔴 | 🟢 % |" )
211+ print ("| --- | :-- | ---: | ---: | ---: | ---: | ---: |" )
180212 for r in rows :
181213 print (r )
182214 print (
183- f"| **All** | **{ sum (totals .values ())} ** | **{ totals ['green' ]} ** | "
215+ f"| **All** | { _band_bar (totals ['green' ], totals ['yellow' ], totals ['red' ])} | "
216+ f"**{ sum (totals .values ())} ** | **{ totals ['green' ]} ** | "
184217 f"**{ totals ['yellow' ]} ** | **{ totals ['red' ]} ** | "
185218 f"**{ 100 * totals ['green' ]/ gtot :.1f} %** |"
186219 )
0 commit comments