Skip to content

[test-gap] validate-diff: signature changes (parameter removal) are not covered — only body changes are tested #20

Description

@Anand-rahul

Problem

Every existing validate-diff spec uses a diff that modifies a function body (a comment update, a code addition). The change-process pipeline detects function names from added lines regardless of whether the body or the signature changed — but no spec verifies signature detection specifically.

A broken pipeline that only fires when the function body changes would pass the entire current validate-diff suite.

Root Cause Detail

parseUnifiedDiff strips the leading + from added lines. goFuncRE and goMethodRE then match the bare declaration. For a parameter-removal diff:

-func DeleteRecord(id string, optFinalizer func(data any) error) error {
+func DeleteRecord(id string) error {

The added line func DeleteRecord(id string) error { is what the pipeline processes. goFuncRE = ^\s*func\s+([A-Z][A-Za-z0-9_]*)\s*\( matches DeleteRecordLookupByQualifiedNameSuffix("DeleteRecord") → finds the scoped entity → fires flow_unreviewed.

Critical: both goFuncRE and goMethodRE require an uppercase first letter. Private functions (lowercase) are never extracted by the pipeline. A spec targeting a private function as the api-break target produces 0 findings and passes for the wrong reason.

What Is Missing

T3.2 — Signature-change detection

tests/e2e/specs/validate-diff/api-break-parameter-removal-emits-finding.yaml

Uses the go-module-multi-receiver fixture. demo.api-break.diff removes the optFinalizer parameter from server.DeleteRecord (uppercase D — extractable by goFuncRE). DeleteRecord is scoped under DeleteAPIFlow.

Steps:

  1. parameter_removal_emits_flow_unreviewed — asserts flow_unreviewed, server.DeleteRecord, DeleteAPIFlow in output
  2. private_func_change_produces_no_findingdemo.unscoped.diff touches handleRequest (lowercase h, never extracted by pipeline) → asserts "0 findings". Catches a pipeline that incorrectly case-folds names before matching.

Status

Spec implemented and passing on impl/phase2.

References

  • internal/change_process/pipeline.go lines 1062–1063 — goFuncRE, goMethodRE
  • internal/change_process/pipeline.go lines 1015–1040 — parseUnifiedDiff (strips leading +)
  • tests/e2e/specs/validate-diff/api-break-parameter-removal-emits-finding.yaml

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions