← Back to Pull requests

build: move code format to a GH workflow, emit rich errors #20822

Merged
DHowett merged 4 files (61 lines) on Oct 19, 2026 21:44 UTC
View on GitHub
DHowett DHowett commented on Oct 19, 2026 19:02 UTC
Author

This allows us to emit GitHub-native error messages which will appear in the Files view. See screenshots below.

Diff: 61 lines (+34 / -27) across 4 files Reviewer: lhecker Review duration: 161m
All Vouch review confidence checks passed
Residual risk 0.04 = Change Risk (0.32) × (1 − Review Confidence (0.89)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.32 · 61 lines diff across 4 files
0.32
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.86 · 5 substantive comment(s)
0.86
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
88%
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.247
Real PR Conversation Timeline
12 items
DHowett DHowett commented on Oct 19, 2026 19:28 UTC
Author
lhecker lhecker commented on code on Oct 19, 2026 20:12 UTC
Code Review
.github/workflows/health.yml:1
@@ -0,0 +1,27 @@
+name: Code Health
+
+on:
+  push:
+    branches:
+      - "**"
+    tags-ignore:
+      - "**"

Is it really necessary to run linters/ci on dev branches? I'd only run it on PRs personally.

lhecker lhecker commented on code on Oct 19, 2026 20:13 UTC
Code Review
.github/workflows/health.yml:1
@@ -0,0 +1,27 @@
+name: Code Health
+
+on:
+  push:
+    branches:
+      - "**"
+    tags-ignore:
+      - "**"
+  pull_request:
+    branches:
+      - "**"
+    types:
+      - "opened"
+      - "reopened"
+      - "synchronize"
+
+permissions: {}
+
+jobs:
+  format:
+    name: Check Formatting
+    runs-on: windows-2025-vs2026
+    steps:
+      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+        with: { fetch-depth: 1 }

I didn't know this was a thing.
But the good news is, it's the default since v4!

lhecker lhecker commented on code on Oct 19, 2026 20:20 UTC
Code Review
build/scripts/Invoke-FormattingCheck.ps1:1
@@ -13,7 +13,14 @@ function Invoke-CheckBadCodeFormatting() {
     if ($LASTEXITCODE -eq 1) {
 
         # Write the list of files that need updating to the log
-        git diff-index --name-only HEAD
+        git diff-index --name-only HEAD | ForEach-Object {
+            $line = 1
+            $diffHeader = & git diff -U0 HEAD -- "$_" | Select-String "^@@" | Select -First 1 -Expand Line
+            If ($diffHeader -Match "\+(\d+)") {
+                $line = [int]$Matches[1]
+            }
+            Write-Host ("::error file={0},line={1},title=Format::{0} is improperly formatted" -f ($_, $line))

Should it really be per hunk?

And I think this needs core.quotePath=false. And perhaps it would be more efficient to avoid N git diff calls here?

$file = $null
git -c core.quotePath=false diff --no-color -U0 HEAD | ForEach-Object {
    if ($_ -cmatch '^\+\+\+ b/(.*)$') {
        $file = $Matches[1]
    }
    elseif ($null -ne $file -and $_ -cmatch '^@@ .* \+(\d+)') {
        $line = [int]$Matches[1]
        Write-Host ("::error file={0},line={1},title=Format::{0} is improperly formatted" -f ($file, $line))
        $file = $null
    }
}

This could misidentify lines containing +++ b/... but... eh?

DHowett DHowett commented on code on Oct 19, 2026 20:32 UTC
Code Review
.github/workflows/health.yml:1
@@ -0,0 +1,27 @@
+name: Code Health
+
+on:
+  push:
+    branches:
+      - "**"
+    tags-ignore:
+      - "**"

probably not, no

DHowett DHowett commented on code on Oct 19, 2026 20:32 UTC
Code Review
.github/workflows/health.yml:1
@@ -0,0 +1,27 @@
+name: Code Health
+
+on:
+  push:
+    branches:
+      - "**"
+    tags-ignore:
+      - "**"
+  pull_request:
+    branches:
+      - "**"
+    types:
+      - "opened"
+      - "reopened"
+      - "synchronize"
+
+permissions: {}
+
+jobs:
+  format:
+    name: Check Formatting
+    runs-on: windows-2025-vs2026
+    steps:
+      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+        with: { fetch-depth: 1 }

good to know!

DHowett DHowett commented on code on Oct 19, 2026 20:33 UTC
Code Review
build/scripts/Invoke-FormattingCheck.ps1:1
@@ -13,7 +13,14 @@ function Invoke-CheckBadCodeFormatting() {
     if ($LASTEXITCODE -eq 1) {
 
         # Write the list of files that need updating to the log
-        git diff-index --name-only HEAD
+        git diff-index --name-only HEAD | ForEach-Object {
+            $line = 1
+            $diffHeader = & git diff -U0 HEAD -- "$_" | Select-String "^@@" | Select -First 1 -Expand Line
+            If ($diffHeader -Match "\+(\d+)") {
+                $line = [int]$Matches[1]
+            }
+            Write-Host ("::error file={0},line={1},title=Format::{0} is improperly formatted" -f ($_, $line))

why does it need core.quotePath=false?

I am not very bothered by N git diff calls; this is a CI script and if it exhibits pathological behavior oh well? :P

DHowett DHowett commented on code on Oct 19, 2026 20:35 UTC
Code Review
build/scripts/Invoke-FormattingCheck.ps1:1
@@ -13,7 +13,14 @@ function Invoke-CheckBadCodeFormatting() {
     if ($LASTEXITCODE -eq 1) {
 
         # Write the list of files that need updating to the log
-        git diff-index --name-only HEAD
+        git diff-index --name-only HEAD | ForEach-Object {
+            $line = 1
+            $diffHeader = & git diff -U0 HEAD -- "$_" | Select-String "^@@" | Select -First 1 -Expand Line
+            If ($diffHeader -Match "\+(\d+)") {
+                $line = [int]$Matches[1]
+            }
+            Write-Host ("::error file={0},line={1},title=Format::{0} is improperly formatted" -f ($_, $line))

Commands that output paths (e.g. ls-files, diff), will quote "unusual" characters in the pathname

(do we have those?)

lhecker lhecker commented on code on Oct 19, 2026 20:42 UTC
Code Review
build/scripts/Invoke-FormattingCheck.ps1:1
@@ -13,7 +13,14 @@ function Invoke-CheckBadCodeFormatting() {
     if ($LASTEXITCODE -eq 1) {
 
         # Write the list of files that need updating to the log
-        git diff-index --name-only HEAD
+        git diff-index --name-only HEAD | ForEach-Object {
+            $line = 1
+            $diffHeader = & git diff -U0 HEAD -- "$_" | Select-String "^@@" | Select -First 1 -Expand Line
+            If ($diffHeader -Match "\+(\d+)") {
+                $line = [int]$Matches[1]
+            }
+            Write-Host ("::error file={0},line={1},title=Format::{0} is improperly formatted" -f ($_, $line))

Non-ASCII is considered unusual in this context AFAICS.

I think we currently have no Unicode paths, but if we ever do, then a file named "中文.txt" would look like this:

> git diff -U0 HEAD
diff --git "a/\344\270\255\346\226\207.txt" "b/\344\270\255\346\226\207.txt"
new file mode 100644
...

> git -c core.quotePath=false diff -U0 HEAD
diff --git a/中文.txt b/中文.txt
new file mode 100644
...

Technically you want unescaped UTF8 here, so I think it'd be a good fit.

DHowett DHowett commented on code on Oct 19, 2026 20:42 UTC
Code Review
build/scripts/Invoke-FormattingCheck.ps1:1
@@ -13,7 +13,14 @@ function Invoke-CheckBadCodeFormatting() {
     if ($LASTEXITCODE -eq 1) {
 
         # Write the list of files that need updating to the log
-        git diff-index --name-only HEAD
+        git diff-index --name-only HEAD | ForEach-Object {
+            $line = 1
+            $diffHeader = & git diff -U0 HEAD -- "$_" | Select-String "^@@" | Select -First 1 -Expand Line
+            If ($diffHeader -Match "\+(\d+)") {
+                $line = [int]$Matches[1]
+            }
+            Write-Host ("::error file={0},line={1},title=Format::{0} is improperly formatted" -f ($_, $line))

Should it really be per hunk?

FWIW, it was not per hunk ;P

lhecker lhecker approved these changes on Oct 19, 2026 21:03 UTC
Approved Reviewer

Approved these changes.

Reviewers
Assignees
DHowett DHowett
Labels
risk: low confidence: 88.8% 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: 32.1% (LOW) · Higher = larger blast radius
32.1%
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: 88.8% · Lower = rushed or shallow review
88.8%
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: 3.6% · Safe to merge
3.6%