Skip to content

Deduplicate update-entity parser wrappers in pkg/workflow - #51647

Merged
pelikhan merged 4 commits into
mainfrom
copilot/duplicate-code-update-entity-parser-wrapper
Aug 10, 2026
Merged

Deduplicate update-entity parser wrappers in pkg/workflow#51647
pelikhan merged 4 commits into
mainfrom
copilot/duplicate-code-update-entity-parser-wrapper

Conversation

Copilot AI commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

The four update-entity parsers (update-issue, update-discussion, update-pull-request, update-release) share a generic helper, but the helper still had to enumerate every concrete config type to assign the parsed base config, and each parser repeated an identical footer field spec.

The type switch was also silently unsafe: a new entity type that forgot to add a case would parse successfully but drop max, target, and target-repo.

Changes

  • parseUpdateEntityConfigTyped no longer enumerates entity types. UpdateEntityConfig gains a setUpdateEntityConfig method, promoted to every struct embedding it, and the helper is constrained with PT interface { *T; updateEntityConfigSetter }. PT is inferred, so no call site changed. Missing embedding is now a compile error rather than a silent no-op.
  • Shared footer field spec. The identical {Name: "footer", Mode: FieldParsingTemplatableBool, StringDest: &cfg.Footer} in all four parsers is replaced by updateEntityFooterField(&cfg.Footer).
  • Test coverage. TestParseUpdateEntityConfigTypedBaseConfigAssignment asserts max, target, target-repo, and footer are populated for all four entity types. Each subtest builds a fresh config map, since footer pre-processing rewrites the value in place.
// before — helper had to know every entity type
switch v := any(cfg).(type) {
case *UpdateIssuesConfig:
	v.UpdateEntityConfig = *baseConfig
case *UpdateDiscussionsConfig:
	v.UpdateEntityConfig = *baseConfig
// ... one case per entity, easy to forget
}

// after — promoted setter, resolved at compile time
PT(cfg).setUpdateEntityConfig(*baseConfig)

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 35.5 AIC · ⌖ 6.22 AIC · ⊞ 8.5K ·
Comment /souschef to run again

…red footer field spec

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor duplicate update-entity parser wrappers in pkg/workflow Deduplicate update-entity parser wrappers in pkg/workflow Aug 9, 2026
Copilot AI requested a review from pelikhan August 9, 2026 22:16
@github-actions

Copy link
Copy Markdown
Contributor

Triage

  • Category: refactor
  • Risk: low (compile-time safety improvement, adds test)
  • Score: 30/100 (impact 8, urgency 5, quality 17)
  • Recommended action: defer (batch: dedupe-helpers)

Draft, no CI runs yet, 0 reviews. Turns a silent no-op risk into a compile error - good quality improvement. Group with #51649, #51648 for batch review.

Generated by 🔧 PR Triage Agent · auto · 43.1 AIC · ⌖ 1.95 AIC · ⊞ 7.8K ·

@pelikhan
pelikhan marked this pull request as ready for review August 10, 2026 02:07
Copilot AI balanced review requested due to automatic review settings August 10, 2026 02:07
@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

🧠 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 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ failed during design decision gate check.

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Ponytail Reviewer completed successfully!

Lean already. Ship. Reviewed for over-engineering: the generic setter/constraint pattern (PT interface { *T; updateEntityConfigSetter }) replaces an unsafe type switch and is justified by the bug it fixes (silent no-op on missing case); updateEntityFooterField deduplicates 4 identical field specs. No speculative abstractions, dead code, or reinventable stdlib found.

Generated by Ponytail Reviewer for #51647

@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

Warning

Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding.

What happened

The threat detection engine failed to produce results.

Review the workflow run logs for details.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • api.individual.githubcopilot.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "api.individual.githubcopilot.com"

See Network Configuration for more information.

🔎 Code quality review by PR Code Quality Reviewer

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

Refactors update-entity parsing to remove type enumeration and share footer field configuration.

Changes:

  • Assigns base configuration through an embedded, compile-time-constrained setter.
  • Reuses a shared footer field specification.
  • Tests base and footer parsing across all four entity types.
Show a summary per file
File Description
pkg/workflow/update_entity_helpers.go Adds the generic setter constraint and shared footer field helper.
pkg/workflow/update_entity_helpers_test.go Covers base configuration assignment for every entity type.
pkg/workflow/update_issue.go Uses the shared footer field specification.
pkg/workflow/update_discussion.go Uses the shared footer field specification.
pkg/workflow/update_pull_request.go Uses the shared footer field specification.
pkg/workflow/update_release.go Uses the shared footer field specification.

Review details

Tip

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

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

@github-actions github-actions Bot 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.

Skills-Based Review 🧠

Applied /codebase-design — changes approved.

📋 Key Themes & Highlights

Positive Highlights

  • ✅ The PT interface { *T; updateEntityConfigSetter } constraint eliminates the exhaustive type switch and turns missing embeddings into compile errors — exactly right.
  • updateEntityFooterField is a tiny, well-named helper that removes four identical literals without adding indirection.
  • ✅ Test coverage directly exercises all four entity types and confirms the base-config fields (max, target, target-repo, footer) are populated — regression-safe from day one.
  • ✅ Comments on setUpdateEntityConfig and updateEntityConfigSetter explain why the pattern is needed, which is the hard part for future readers of generic Go code.

Minor observation

The PT type parameter is inferred and never appears in the function's parameter list, only in the body as PT(cfg). This is idiomatic but non-obvious; the expanded doc comment added in this PR handles it well.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 · 14 AIC · ⌖ 7.45 AIC · ⊞ 7.1K
Comment /matt to run again

@github-actions github-actions Bot 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.

Clean refactor. The promoted-setter generic constraint and the updateEntityFooterField helper both eliminate duplication correctly. New test coverage is solid.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 12.8 AIC · ⌖ 6.37 AIC · ⊞ 5.4K

@github-actions

Copy link
Copy Markdown
Contributor

🧪 Test Quality Sentinel Report

⚠️ Test Quality Score: 90/100 — Excellent

Analyzed 1 test(s) [4 table-driven subtests]: 1 design, 0 implementation, 0 violation(s).

📊 Metrics (1 test function, 4 subtests)
Metric Value
Analyzed 1 (Go: 1, JS: 0)
✅ Design 1 (100%)
⚠️ Implementation 0 (0%)
Edge/error coverage 1 (100%)
Duplicate clusters 0
Inflation ⚠️ Yes (86 test lines / 29 prod lines ≈ 2.97:1)
🚨 Violations 0
Test File Classification Issues
TestParseUpdateEntityConfigTypedBaseConfigAssignment (×4 subtests) pkg/workflow/update_entity_helpers_test.go:403 design_test / behavioral_contract / high_value Inflation ratio 2.97:1
📋 Test Analysis

TestParseUpdateEntityConfigTypedBaseConfigAssignment — table-driven test covering all four entity parsers (update-issue, update-discussion, update-pull-request, update-release). Each subtest verifies that the shared UpdateEntityConfig base fields (max, target, target-repo, footer) are correctly populated after parsing. This directly enforces the behavioral contract of the deduplication refactor: that the new shared helper correctly propagates base config for every entity type.

  • Design invariant: Verifies user-visible config fields across all entity types — behavioral_contract.
  • Edge coverage: Includes nil-guard (t.Fatal("Expected non-nil config")) and footer non-nil check, giving genuine error-path coverage.
  • Assertion quality: All assertions include descriptive failure messages (t.Errorf("Expected max=3, got %v", ...)). ✅
  • Inflation note: 86 test lines vs 29 production lines (≈2.97:1). This exceeds the 2:1 threshold, but is justified — the test must exercise all 4 entity parsers individually to guard against per-entity regressions.

Verdict

Passed. 0% implementation tests (threshold: 30%). Score: 90/100. Minor: test inflation ratio (2.97:1) exceeds 2:1 threshold but is structurally justified by the 4-entity coverage requirement.

🧪 Test quality analysis by Test Quality Sentinel · sonnet46 · 26.9 AIC · ⌖ 7.77 AIC · ⊞ 7.6K ·
Comment /review to run again

@github-actions github-actions Bot 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.

✅ Test Quality Sentinel: 90/100. 0% implementation tests (threshold: 30%). No violations detected.

… via promoted setter

Documents the decision to eliminate the unsafe type-switch in
parseUpdateEntityConfigTyped and extract the shared footer field spec.
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot Quick triage nudge for this PR.

Please refresh the branch if GitHub can update it cleanly, re-check the current maintainer-facing state on the updated branch, and run the pr-finisher skill before handing this back.

Open items (newest first):

  • no failed checks were listed in the compact candidate snapshot
  • re-confirm there are no unresolved review threads or maintainer-facing follow-ups on the current head

Branch refresh was requested.
Run: https://github.com/github/gh-aw/actions/runs/31350342785

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 35.5 AIC · ⌖ 6.22 AIC · ⊞ 8.5K ·
Comment /souschef to run again

@github-actions

Copy link
Copy Markdown
Contributor

PR Triage

Category: refactor · Risk: low · Priority: medium · Score: 60/100

Score breakdown

  • Impact: 20/50 (removes an unsafe type-switch fallthrough in update-entity parsers; correctness/safety improvement)
  • Urgency: 15/30 (mergeable_state=clean, full CI suite green across all jobs)
  • Quality: 20/20 (0 pending review comments, 3 approvals, full test suite passing)

Recommended action: auto_merge — clean CI, fully approved, low-risk internal safety fix with no open concerns.

Batch: dedupe-helpers

Automated triage via PR Triage Agent.

Generated by 🔧 PR Triage Agent · auto · 45.9 AIC · ⌖ 2.89 AIC · ⊞ 7.8K ·

@pelikhan
pelikhan merged commit 5f12732 into main Aug 10, 2026
30 checks passed
@pelikhan
pelikhan deleted the copilot/duplicate-code-update-entity-parser-wrapper branch August 10, 2026 10:01
@github-actions github-actions Bot mentioned this pull request Aug 10, 2026
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.

[duplicate-code] Duplicate Code: update-entity parser wrappers in pkg/workflow

4 participants