Skip to content

Split pkg/parser/import_field_extractor.go into focused files by concern - #54378

Closed
pelikhan with Copilot wants to merge 4 commits into
mainfrom
copilot/deep-report-split-oversized-go-files
Closed

Split pkg/parser/import_field_extractor.go into focused files by concern#54378
pelikhan with Copilot wants to merge 4 commits into
mainfrom
copilot/deep-report-split-oversized-go-files

Conversation

Copilot AI commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

A DeepReport monolithic-file analysis flagged pkg/parser/import_field_extractor.go (1048 LOC, 51 functions) as a high-value refactor target, along with pkg/cli/add_package_manifest.go. The latter had already been split down to 130 LOC in an earlier change, so this PR addresses the remaining file.

Changes

  • Split import_field_extractor.go into 5 files along existing logical boundaries (already reflected in function names/doc comments), with no behavior change:
    • import_field_extractor.go — core importAccumulator struct, constructor, and main extraction pipeline (extractAllImportFields, prepareFrontmatter, result building)
    • import_field_extractor_engine.go — engine config and scalar/builder-based fields (max-turns, mcp-servers, safe-outputs, sandbox mounts, etc.)
    • import_field_extractor_activation.go — activation/auth fields (bots, skip-roles/bots, github-token, github-app, checkout)
    • import_field_extractor_steps.go — step/job/env/labels/cache/features/run-install-scripts/observability extraction
    • import_field_extractor_models.gomodels field normalization (aliases, allow/block policies, cost overlays)

All functions were moved verbatim with per-file import lists trimmed to only what each file uses; no logic was altered.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Split oversized Go files in pkg/cli and pkg/parser Split pkg/parser/import_field_extractor.go into focused files by concern Aug 21, 2026
Copilot AI requested a review from pelikhan August 21, 2026 00:00
@github-actions

Copy link
Copy Markdown
Contributor

🔍 PR Triage

Category: refactor · Risk: low · Priority: low

Score: 38/100 (impact 20/50 + urgency 8/30 + quality 10/20)

Recommended action: defer

Draft, large mechanical file split (682/641), no CI yet. Low urgency.

Automated triage — run 32432526976

Generated by 🔧 PR Triage Agent · auto · 63.7 AIC · ⌖ 4.49 AIC · ⊞ 8.3K ·

@pelikhan
pelikhan marked this pull request as ready for review August 21, 2026 00:41
Copilot AI balanced review requested due to automatic review settings August 21, 2026 00:41

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

Splits the remaining oversized parser extractor into focused modules without changing behavior, addressing #54064.

Changes:

  • Separates engine, activation, step/job, and model extraction concerns.
  • Retains the core accumulator and extraction pipeline in the original file.
Show a summary per file
File Description
pkg/parser/import_field_extractor.go Retains core accumulation and pipeline logic.
pkg/parser/import_field_extractor_engine.go Houses engine and configuration extraction.
pkg/parser/import_field_extractor_activation.go Houses activation and authentication extraction.
pkg/parser/import_field_extractor_steps.go Houses step, job, environment, and feature extraction.
pkg/parser/import_field_extractor_models.go Houses model normalization and policy extraction.

Review details

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

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

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot Quick triage nudge for PR #54378.

  • This PR is still waiting on a maintainer-facing finish pass.
  • Please run the pr-finisher skill and leave a concise handoff that covers validation status, merge readiness, and any remaining human actions.
  • If branch refresh is available, take it as part of that finish pass.

Run: https://github.com/github/gh-aw/actions/runs/32434686968

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 20.3 AIC · ⌖ 6.12 AIC · ⊞ 5.5K ·
Comment /souschef to run again

Copilot AI commented Aug 21, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Quick triage nudge for PR #54378.

  • This PR is still waiting on a maintainer-facing finish pass....

Finish pass complete at 7a8474c.

  • ✅ Reviews — no unresolved review threads on this PR.
  • ✅ Checks (local) — make fmt, make lint, make test-unit, make test, and make recompile all passed locally.
  • ⏳ Checks (CI) — required copilot check run is still in progress (32435174988); latest completed PR check is successful. No CI failures to triage from the current snapshot.
  • ❌ Mergeable (yet) — PR is currently blocked by required checks (not behind base branch, so no branch refresh action was available).

Actions taken: completed full triage + local validation; no code changes were needed.

Still needed (human): let required checks finish/re-trigger as needed, then merge once checks are green.

Copilot AI requested a review from gh-aw-bot August 21, 2026 01:20
@github-actions

github-actions Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

No test files were added or modified in this PR. Test Quality Sentinel skipped.

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Aug 21, 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 21, 2026

Copy link
Copy Markdown
Contributor

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

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Ponytail Reviewer completed successfully!

Lean already. Ship. Pure mechanical split of a 1048-line file into 5 files along existing logical boundaries; functions moved verbatim with only import lists trimmed. No new abstractions, no reinvented stdlib, no added dependencies, no logic changes.

Generated by Ponytail Reviewer for #54378

@github-actions

github-actions Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

@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.

This is a clean, pure refactoring PR that splits import_field_extractor.go into four focused files by concern:

  • import_field_extractor_activation.go — bots, skip-roles, skip-bots, ambient-folders, GitHub token/app, checkout
  • import_field_extractor_engine.go — engine config and MCP settings
  • import_field_extractor_models.go — model policy, providers, costs
  • import_field_extractor_steps.go — steps, jobs, env, labels, cache, features, observability

No behavioral changes detected. The split follows existing file-naming conventions in the package, and the package-level doc comment pattern is consistent with other files.

mergeJSONStringListField (defined in the activation file, reused in steps) and parseStringSliceField (defined in models, referenced by engine) are both correct cross-file usages within the same package.

LGTM.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 38.7 AIC · ⌖ 8.84 AIC · ⊞ 5.7K

@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 — this is a pure refactor with no behaviour changes. The split is clean and well-motivated; two minor helper-placement issues worth fixing.

📋 Key Themes & Highlights

Key Themes

  • Helper function homing: mergeJSONStringListField (activation file) and parseStringSliceField (models file) are both called across file boundaries. Utilities shared by multiple themed files belong in the core file or a dedicated helpers file, not in whichever themed file happened to define them first.

Positive Highlights

  • ✅ The five-way split follows the existing logical groupings already expressed in the original function names — minimal cognitive overhead.
  • ✅ Each file has a focused file-level doc comment that accurately describes its scope.
  • ✅ No logic changes — a pure mechanical split is the right approach for a file this large.
  • ✅ Per-file import lists are trimmed correctly to only what each file needs.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 · 43.8 AIC · ⌖ 10 AIC · ⊞ 7.8K
Comment /matt to run again

})
}

func mergeJSONStringListField(

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.

[/codebase-design] mergeJSONStringListField is a general-purpose helper but lives in the activation-themed file, while _steps.go also calls it — the file boundary and the function's home are mismatched.

💡 Suggestion

Move mergeJSONStringListField (and, for symmetry, parseStringSliceField from _models.go) into import_field_extractor.go or a small new import_field_extractor_helpers.go. Keeping shared utilities in a themed file is a navigation trap: future contributors hunting for mergeJSONStringListField will have no obvious reason to look in the activation file.

@copilot please address this.

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.

Addressed in dbf93fb: moved mergeJSONStringListField into new shared pkg/parser/import_field_extractor_helpers.go so it is no longer housed in the activation-focused file.

return sanitizedProviders, true
}

func parseStringSliceField(value any, keepEmpty bool) []string {

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.

[/codebase-design] parseStringSliceField is a generic slice-parsing utility that lives in _models.go but is also called from _engine.go — same cross-file coupling issue as mergeJSONStringListField.

💡 Suggestion

Co-locate both generic helpers (mergeJSONStringListField, parseStringSliceField) in the core import_field_extractor.go or a new import_field_extractor_helpers.go. This gives callers a single predictable home for shared utilities and keeps themed files purely concern-specific.

@copilot please address this.

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.

Addressed in dbf93fb: moved parseStringSliceField into new shared pkg/parser/import_field_extractor_helpers.go alongside the other cross-file helper.

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

reviewed_at: 2026-08-21T00:00:00Z
review_event: COMMENT
top_themes:
  - refactor-only split with no behavioral delta found
  - parser package tests passed
files_reviewed:
  - pkg/parser/import_field_extractor.go
  - pkg/parser/import_field_extractor_activation.go
  - pkg/parser/import_field_extractor_engine.go
  - pkg/parser/import_field_extractor_models.go
  - pkg/parser/import_field_extractor_steps.go
comment_count: 0

Note

This comment is managed by comment memory.

It stores persistent context for this thread in the code block at the top of this comment.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · gpt54 · 4.5 AIC · ⌖ 6.83 AIC · ⊞ 7K ·
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.

Verdict

No blocking issues found in the changed lines.

Review notes

This is a mechanical file split of the parser import-field extractor. I checked the moved helpers against the remaining orchestrator, verified the package still builds/tests, and did not find a behavioral delta in the changed lines.

🔎 Code quality review by PR Code Quality Reviewer · gpt54 · 4.5 AIC · ⌖ 6.83 AIC · ⊞ 7K
Comment /review to run again

@github-actions

Copy link
Copy Markdown
Contributor

🏗️ Design Decision Gate — ADR Required

This PR makes significant changes to core business logic (682 new lines in pkg/parser/) but did not have a linked Architecture Decision Record (ADR).

📄 Draft ADR committed: docs/adr/54378-split-import-field-extractor-by-concern.md — review and complete it before merging.

🔒 This PR cannot merge until an ADR is linked in the PR body.

📋 What to do next
  1. Review the draft ADR committed to your branch — it was generated from the PR diff
  2. Complete the missing sections — add context the AI couldn't infer, refine the decision rationale, and list real alternatives you considered
  3. Commit the finalized ADR to docs/adr/ on your branch
  4. Reference the ADR in this PR body by adding a line such as:

    ADR: ADR-54378: Split import_field_extractor.go into Concern-Focused Files

Once an ADR is linked in the PR body, this gate will re-run and verify the implementation matches the decision.

❓ Why ADRs Matter

"AI made me procrastinate on key design decisions. Because refactoring was cheap, I could always say 'I'll deal with this later.' Deferring decisions corroded my ability to think clearly."

ADRs create a searchable, permanent record of why the codebase looks the way it does. Future contributors (and your future self) will thank you.

📋 Michael Nygard ADR Format Reference

An ADR must contain these four sections to be considered complete:

  • Context — What is the problem? What forces are at play?
  • Decision — What did you decide? Why?
  • Alternatives Considered — What else could have been done?
  • Consequences — What are the trade-offs (positive and negative)?

All ADRs are stored in docs/adr/ as Markdown files numbered by PR number (e.g., 54378-split-import-field-extractor-by-concern.md for PR #54378).

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · sonnet46 · 117.9 AIC · ⌖ 28.8 AIC · ⊞ 9.2K ·
Comment /review to run again

@github-actions

Copy link
Copy Markdown
Contributor

PR Triage

  • Category: refactor
  • Risk: medium
  • Priority score: 45/100 (impact 25 + urgency 5 + quality 15)
  • Recommended action: batch_review
  • Batch: refactor-cleanup-cluster
  • CI: no checks reported

Generated by 🔧 PR Triage Agent · auto · 79.3 AIC · ⌖ 6.15 AIC · ⊞ 8.3K ·

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot Quick triage nudge for PR #54378.

  • This PR is still blocked, and the thread history shows at least one unresolved change request about helper placement plus an ADR gate requiring the ADR to be completed and linked in the PR body.
  • Please address the remaining blocking feedback newest first, make sure the ADR requirement is satisfied, and then run the pr-finisher skill with a concise maintainer handoff covering validation status, merge readiness, and any remaining human action.
  • I skipped branch refresh because this PR is currently blocked, and I could not complete local formatting in this sandbox due toolchain limits.

Run: https://github.com/github/gh-aw/actions/runs/32471825475

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 29.1 AIC · ⌖ 8.2 AIC · ⊞ 6.9K ·
Comment /souschef to run again

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
@pelikhan pelikhan closed this Aug 21, 2026

Copilot AI commented Aug 21, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Quick triage nudge for PR #54378.

  • This PR is still blocked, and the thread history shows at least one unresolved change request about helper placement plus an ADR gate requiring the ADR to...

Addressed in dbf93fb.

  • Moved shared helpers into pkg/parser/import_field_extractor_helpers.go (mergeJSONStringListField, parseStringSliceField) and removed cross-concern helper placement from themed files.
  • Finalized ADR draft status in docs/adr/54378-split-import-field-extractor-by-concern.md.
  • Also fixed prior failing lint-go CI root cause from run 32433605533 by making the three importer error messages actionable/constructive.

Validation run locally on this branch: make fmt, make lint, make test-unit, make test, make recompile all pass.

Maintainer handoff:

  • Reviews: addressed; the two prior helper-placement threads are now outdated with replies.
  • Checks: CI on dbf93fb is not yet verified from this agent run and must be re-triggered by a maintainer.
  • Merge readiness: still blocked until required checks run on latest HEAD; current PR body also still needs the ADR link line.
  • Remaining human action: add ADR link to PR body and re-trigger CI (close/reopen, workflow_dispatch, or maintainer push), then merge when checks are green.

Copilot stopped work on behalf of gh-aw-bot due to an error August 21, 2026 10:52
@github-actions
github-actions Bot deleted the copilot/deep-report-split-oversized-go-files branch August 29, 2026 02:03
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.

[deep-report] Split oversized pkg/cli/add_package_manifest.go (1330 LOC) and pkg/parser/import_field_extractor.go (1045 LOC)

4 participants