Skip to content

[purelock] Lock down firstForbiddenCharInParamValue, validateGCPWIFEngineAuth, hasPullRequestTargetTrigger with pure-function test suites - #52890

Merged
pelikhan merged 2 commits into
mainfrom
purelock/lock-down-batch-1786798264-00db604368092ef7
Aug 15, 2026
Merged

pelikhan merged 2 commits into
mainfrom
purelock/lock-down-batch-1786798264-00db604368092ef7

Conversation

@github-actions

@github-actions github-actions Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR adds three new pure-function unit test files that exercise hasPullRequestTargetTrigger (pkg/cli), validateGCPWIFEngineAuth (pkg/workflow), and firstForbiddenCharInParamValue (pkg/workflow). Each suite uses table-driven tests with t.Parallel() to cover edge cases (nil inputs, empty collections, type variants, whitespace handling, and forbidden-character detection) that were previously under-tested. A follow-up commit removes redundant loop variable copies introduced during the initial test authoring.

Change Classification

  • Type: test
  • Scope: pkg/cli, pkg/workflow
  • Breaking: No

Key Changes

File Change Impact
pkg/cli/codemod_pull_request_target_trigger_test.go New table-driven test suite for hasPullRequestTargetTrigger, covering nil/empty on key, map[string]any, []any, []string, and plain string forms with whitespace and type-mismatch cases Increases coverage for pull_request_target trigger detection used in codemod logic
pkg/workflow/compiler_validators_gcp_wif_test.go New table-driven test suite for validateGCPWIFEngineAuth, covering nil workflow/engine/auth config, non-GCP/non-oidc auth, complete config, and each combination of missing required GCP WIF fields Increases coverage for GCP Workload Identity Federation auth validation error messages
pkg/workflow/model_identifier_param_value_test.go New table-driven test suite for firstForbiddenCharInParamValue, covering allowed characters (letters, digits, _, ., -), forbidden characters (space, /, ?, unicode), and first-occurrence behavior Increases coverage for model identifier parameter value validation

Impact Assessment

  • No production code was modified; changes are additive test files only.
  • No downstream impact identified.

Commits

a23c80a36 test: remove redundant loop variable copies
60ea272fe test: add pure-function test suites for 3 low-coverage functions
```> Generated by [PR Description Updater](https://github.com/github/gh-aw/actions/runs/31888587650) for #52890 · auto · 56.9 AIC · ⌖ 6.41 AIC · ⊞ 7.5K · [◷](https://github.com/search?q=repo%3Agithub%2Fgh-aw+%22gh-aw-workflow-call-id%3A+github%2Fgh-aw%2Fpr-description-caveman%22&type=pullrequests)

<!-- gh-aw-agentic-workflow: PR Description Updater, engine: copilot, model: auto, id: 31888587650, workflow_id: pr-description-caveman, run: https://github.com/github/gh-aw/actions/runs/31888587650 -->

Locks down firstForbiddenCharInParamValue, validateGCPWIFEngineAuth, and
hasPullRequestTargetTrigger with table-driven testify suites.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor Author

✅ Great work on the PureLock test suite additions! This PR adds comprehensive test coverage for three pure functions with detailed specifications for each:

  • firstForbiddenCharInParamValue: 15 table-driven subtests covering character validation (empty string, allowed chars, forbidden ASCII/Unicode).
  • validateGCPWIFEngineAuth: 10 subtests covering nil checks, type validation, and field presence across auth config paths.
  • hasPullRequestTargetTrigger: 16 subtests covering all YAML-decoded shapes (map[string]any, []any, []string, string) and edge cases.

The changes are focused (test files only), well-documented, and pass validation (gofmt, go vet, go test -race). Code coverage improvements are incremental but meaningful (functions moved from partial/zero coverage to 100%).

This PR is ready for review and appears aligned with the project's testing and quality standards.

Generated by ✅ Contribution Check · auto · 53.5 AIC · ⌖ 4.72 AIC · ⊞ 9.1K · ◷

@pelikhan
pelikhan marked this pull request as ready for review August 15, 2026 13:37
Copilot AI balanced review requested due to automatic review settings August 15, 2026 13:37
@pelikhan

Copy link
Copy Markdown
Collaborator

@github-actions

github-actions Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Ponytail Reviewer completed successfully!

Ponytail review: PR only adds table-driven testify test files with no abstractions, dependencies, or dead code to cut. Lean already. Ship.

Generated by Ponytail Reviewer for #52890

@github-actions

github-actions Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ PR Code Quality Reviewer completed the code quality review.

Reviewed PR #52890 locally; no actionable review comments because the changes only add focused table-driven tests for existing pure functions and I found no correctness, maintainability, or coverage regressions in the added test code.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Design Decision Gate 🏗️ completed the design decision gate check.

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Test Quality Sentinel completed test quality analysis.

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor Author

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pure-function test suites look correct and well-structured. Good coverage of nil/edge cases, whitespace handling, and partial-field combinations. No issues found.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 14 AIC · ⌖ 9.83 AIC · ⊞ 5.6K

@github-actions

Copy link
Copy Markdown
Contributor Author

ADR Gate: Verified ✓

Status: Implementation aligns with ADR-52295.

Evidence of alignment
ADR-52295 commitment This PR
Use PureLock to auto-generate table-driven test suites ✅ PR generated by PureLock (run 31884894501)
Target zero-/low-coverage pure functions ✅ Covers firstForbiddenCharInParamValue (0%→100%), validateGCPWIFEngineAuth (33%→100%), hasPullRequestTargetTrigger (40%→100%)
One file per function or closely related group ✅ Three new *_test.go files, each targeting a single function
Use testify/assert for assertions ✅ All three test files import testify/assert; compiler_validators_gcp_wif_test.go also uses testify/require
Enumerate edge cases (nil, empty, mixed types, unsupported scalars) ✅ Covers nil workflow data, nil configs, non-string slice entries, unsupported types, Unicode characters

Minor scope note: ADR-52295's Decision section references pkg/workflow/ specifically (reflecting its original context), but the underlying principle — PureLock-driven coverage of pure functions — naturally extends to other packages. This PR covers both pkg/workflow/ and pkg/cli/, which is an expected broadening, not a contradiction.

No action required from the author. This PR may merge when other checks pass.

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · sonnet46 · 49.6 AIC · ⌖ 24.1 AIC · ⊞ 9K · ◷
Comment /review to run again

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds focused table-driven tests that lock down three pure helper and validation functions.

Changes:

  • Tests allowed and forbidden model-parameter characters.
  • Tests GCP WIF authentication validation branches and errors.
  • Tests supported pull_request_target frontmatter representations.
Show a summary per file
File Description
pkg/workflow/model_identifier_param_value_test.go Covers parameter-value character validation.
pkg/workflow/compiler_validators_gcp_wif_test.go Covers GCP WIF authentication validation.
pkg/cli/codemod_pull_request_target_trigger_test.go Covers trigger detection across frontmatter shapes.

Review details

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Balanced

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skills-Based Review 🧠

Applied /tdd — changes are test-only additions. Overall solid; two minor observations flagged as inline comments.

📋 Key Themes & Highlights

Positive Highlights

  • ✅ Comprehensive table-driven tests with parallel subtests on all three functions
  • ✅ Clear Arrange/Act/Assert structure; test names read as specifications
  • ✅ Good boundary and nil-path coverage (nil workflow, nil engine config, nil auth)
  • ✅ Whitespace-trimming and non-string slice-entry cases for hasPullRequestTargetTrigger
  • ✅ Each missing-field combination covered for validateGCPWIFEngineAuth

Minor Issues (inline)

  1. tt := tt in Go 1.26.5 — dead code; loop-variable capture has been automatic since Go 1.22. Appears in all three test files.
  2. Hard-coded error message prefix in compiler_validators_gcp_wif_test.go — ties tests to phrasing rather than behaviour.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 · 27.2 AIC · ⌖ 8.03 AIC · ⊞ 7.7K
Comment /matt to run again

}

for _, tt := range tests {
tt := tt

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/tdd] tt := tt is unnecessary in Go 1.22+ (this module uses Go 1.26.5) — loop-variable capture is automatic.

Removing it keeps the test idiomatic and avoids confusion for future contributors.

💡 Suggested change

Delete the tt := tt line in all three test files. The parallel subtests will still work correctly.

@copilot please address this.

require.Error(t, err)
assert.Contains(t, err.Error(), tt.errContains)
assert.Contains(t, err.Error(), "engine.auth with provider=gcp requires the following fields")
} else {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/tdd] The errContains assertion hard-codes the exact error message format ("engine.auth with provider=gcp requires the following fields"). If the production error message is ever reworded, this test silently regresses.

Consider extracting the expected prefix to a package-level constant or using a sentinel error type so tests remain coupled to behaviour, not phrasing.

💡 Suggested approach

If validateGCPWIFEngineAuth returns a typed error, assert errors.As rather than Contains. Alternatively, define:

const gcpWIFErrPrefix = "engine.auth with provider=gcp requires the following fields"

and reference it in both production code and tests.

@copilot please address this.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Test Quality Sentinel: 100/100. 0% implementation tests (threshold: 30%). Three pure-function test suites, 42 subtests, zero violations.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

@copilot fix https://github.com/github/gh-aw/actions/runs/31885809679/job/95016207423

Fixed in a23c80a by removing the redundant Go 1.22 loop-variable copies that caused copyloopvar failures in lint-go.

Copilot AI requested a review from pelikhan August 15, 2026 13:55
@pelikhan
pelikhan merged commit 341fbed into main Aug 15, 2026
@pelikhan
pelikhan deleted the purelock/lock-down-batch-1786798264-00db604368092ef7 branch August 15, 2026 13:57
@github-actions

Copy link
Copy Markdown
Contributor Author

🎉 This pull request is included in a new release.

Release: v0.86.3

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants