Skip to content

feat(foreman): flag a GO that changes no functional production code#1024

Open
Defilan wants to merge 1 commit into
defilantech:mainfrom
Defilan:fix/no-functional-change-advisory
Open

feat(foreman): flag a GO that changes no functional production code#1024
Defilan wants to merge 1 commit into
defilantech:mainfrom
Defilan:fix/no-functional-change-advisory

Conversation

@Defilan

@Defilan Defilan commented Jul 9, 2026

Copy link
Copy Markdown
Member

What

A non-blocking coder-gate advisory that records noFunctionalChange: true when a GO's committed diff is docs / comments / tests only.

Why

A GO that changes no production code produces a hollow GATE-PASS: the bite check has nothing to revert (vacuous), and prose — Go comments or docs — can claim behavior that isn't implemented. Dogfooding #850 exposed this: a bug-labeled issue ("hostpath PVC blocked on tainted GPU nodes") produced a docs + comment-only change whose comment claimed "the operator surfaces a clear warning when a PVC source is used on a tainted node" — with no warning code in the diff. It GATE-PASSed and looked like a fix.

How

Runs after repo.Commit (same after-commit requirement as the grounding rail, so base...HEAD reflects the committed diff). functionalChangeInDiff walks the changed files: docs (.md, etc.), tests (_test.go), and comment-only .go edits are non-functional; a .go file with a real added/removed code line is functional. diffHasCodeLine is a line heuristic (not a Go parser) — a changed line counts as code unless it is blank or a comment. Degrades open (assumes functional) on any git error.

Records noFunctionalChange: true on the terminal result and logs it. Non-blocking — never changes the verdict; it surfaces a docs/comment-only "fix" for the reviewer/human to judge (a docs-only change to a code bug is a red flag; to a docs issue, it's fine). The semantic half — prose claiming an unimplemented feature — remains a reviewer concern; this removes the misleading clean pass.

Testing

  • TestDiffHasCodeLine: comment-only / blank / block-comment / header lines → not code; real added or removed logic → code.
  • TestFunctionalChangeInDiff (injected runner): docs-only, tests-only, comment-only .go, docs+comment-only → false; real code change → true; git error → true (degrade open).
  • Full pkg/foreman/agent package passes.

Checklist

  • Fixes #1022
  • Non-blocking; records + logs only
  • Degrades open on git error
  • AI assistance disclosed below

Assisted-by: Claude Code (identified the gate gap while reviewing Foreman output, wrote the advisory + tests; human-reviewed and DCO-signed by the maintainer).

A GO whose committed diff is docs/comments/tests only produces a hollow
GATE-PASS: the bite check has no production code to revert, so it is vacuous,
and prose (docs or Go comments) can claim behavior that is not implemented.
On defilantech#850 a bug-labeled issue produced a docs + comment-only change whose
comment claimed "the operator surfaces a clear warning" with no warning code
in the diff, and it GATE-PASSed.

Add a non-blocking advisory that runs after repo.Commit (same placement as
the grounding rail): if the committed diff (base...HEAD) has no functional
production change, record noFunctionalChange=true on the terminal result and
log it. functionalChangeInDiff treats docs, tests, and comment-only .go edits
as non-functional (diffHasCodeLine is a line heuristic, not a Go parser);
degrades open on any git error. Records-and-logs only; never changes the
verdict, leaving the call to the reviewer/human.

Fixes defilantech#1022

Signed-off-by: Christopher Maher <chris@mahercode.io>
@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.23404% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/foreman/agent/no_functional_change_gate.go 86.95% 3 Missing and 3 partials ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant