Skip to content

refactor: decompose large multi-cluster files (audit.go, import_field_extractor.go)#43898

Merged
pelikhan merged 4 commits into
mainfrom
copilot/refactor-semantic-function-clustering
Jul 7, 2026
Merged

refactor: decompose large multi-cluster files (audit.go, import_field_extractor.go)#43898
pelikhan merged 4 commits into
mainfrom
copilot/refactor-semantic-function-clustering

Conversation

Copilot AI commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Two files exceeded 1,200 lines each by mixing distinct function clusters. Split each by semantic responsibility — pure function moves, no signature or behavior changes.

pkg/cli/audit.go (1,257 → 933 lines)

  • audit_job.go — job-specific audit: auditJobRun, fetchAuditJobLog, extractStepOutput, findFirstFailingStep, step log rendering
  • workflow_run_metadata.go — GitHub API metadata fetching: fetchWorkflowRunMetadata, resolveWorkflowDisplayName, extractWorkflowNameFromYAML

pkg/parser/import_field_extractor.go (1,369 → 899 lines)

  • import_observability.go — OTLP config merging: mergeObservabilityConfigs, extractOTLPEndpointsFromObsMap, extractOTLPGitHubAppFromObsMap, extractOTLPAttributesFromObsMap
  • import_schema_validation.go — import-schema validation: validateWithImportSchema, validateObjectInput, validateImportInputType, applyImportSchemaDefaultsFromFrontmatter
  • import_input_substitution.go — expression substitution: substituteImportInputsInContent, buildImportInputReplaceFunc, resolveImportInputPath

Generated by 👨‍🍳 PR Sous Chef · 5.92 AIC · ⌖ 5.55 AIC · ⊞ 4.7K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · 3.96 AIC · ⌖ 5.65 AIC · ⊞ 7.1K ·
Comment /souschef to run again

…usters

pkg/cli/audit.go (1257 → 933 lines):
- Extract job audit cluster → audit_job.go (223 lines)
- Extract workflow run metadata cluster → workflow_run_metadata.go (127 lines)

pkg/parser/import_field_extractor.go (1369 → 899 lines):
- Extract observability/OTLP cluster → import_observability.go (202 lines)
- Extract import schema validation cluster → import_schema_validation.go (228 lines)
- Extract import input substitution cluster → import_input_substitution.go (57 lines)

Pure function moves within each package — no signature or behavior changes.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor semantic function clustering for large multi-cluster files refactor: decompose large multi-cluster files (audit.go, import_field_extractor.go) Jul 7, 2026
Copilot AI requested a review from pelikhan July 7, 2026 01:28
@pelikhan
pelikhan marked this pull request as ready for review July 7, 2026 02:21
Copilot AI review requested due to automatic review settings July 7, 2026 02:21

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 two previously large files by decomposing them into smaller, responsibility-focused Go source files in pkg/cli and pkg/parser, aiming to keep behavior/signatures the same while improving maintainability.

Changes:

  • Split import handling helpers out of pkg/parser/import_field_extractor.go into dedicated files for schema validation, observability merging, and input substitution.
  • Split audit job log extraction helpers and workflow-run metadata helpers out of pkg/cli/audit.go into separate files.
Show a summary per file
File Description
pkg/parser/import_schema_validation.go New file containing import-schema validation and default-application helpers moved out of the extractor.
pkg/parser/import_observability.go New file containing OTLP endpoint extraction and observability merge logic moved out of the extractor.
pkg/parser/import_input_substitution.go New file containing import-input expression substitution helpers moved out of the extractor.
pkg/parser/import_field_extractor.go Removes the moved helper clusters and trims imports accordingly.
pkg/cli/workflow_run_metadata.go New file containing workflow run metadata fetching and workflow display-name resolution moved out of audit.
pkg/cli/audit_job.go New file containing job-specific audit log download/parsing helpers moved out of audit.
pkg/cli/audit.go Removes the moved helper clusters and trims imports accordingly.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 7/7 changed files
  • Comments generated: 3
  • Review effort level: Low

Comment thread pkg/parser/import_observability.go Outdated
Comment thread pkg/parser/import_observability.go Outdated
Comment on lines +180 to +184
// applyImportSchemaDefaultsFromFrontmatter applies import-schema defaults from an
// already-parsed frontmatter map, avoiding a redundant YAML parse when the caller
// has already extracted the frontmatter. Returns a copy of inputs augmented with
// default values for any schema parameters declared with a "default" field but not
// present in the provided inputs map. Parameters already in inputs are left unchanged.
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, address unresolved review comments, and rerun checks once the branch is up to date.

Generated by 👨‍🍳 PR Sous Chef · 5.92 AIC · ⌖ 5.55 AIC · ⊞ 4.7K ·
Comment /souschef to run again

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please run the pr-finisher skill, address unresolved review comments, and rerun checks once the branch is up to date.

...

Implemented in c62914e. I addressed the unresolved parser review items (canonical struct{}{} map usage and clarified the defaults function comment contract), then ran make fmt, make lint, make test-unit, make test, make recompile, and make agent-report-progress. Local checks pass. CI on this new head will need a maintainer-triggered rerun.

Copilot AI requested a review from gh-aw-bot July 7, 2026 03:15
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, address unresolved review comments, refresh the branch if needed, and rerun checks once ready.

Generated by 👨‍🍳 PR Sous Chef · 3.96 AIC · ⌖ 5.65 AIC · ⊞ 7.1K ·
Comment /souschef to run again

Copilot AI commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please run the pr-finisher skill, address unresolved review comments, refresh the branch if needed, and rerun checks once ready.

...

Done. I ran the pr-finisher workflow on PR #43898 and verified the branch state on current HEAD c62914e.

  • No new unresolved actionable @copilot review comments were found beyond the previously addressed outdated thread.
  • Branch is not behind main (local compare after unshallow/fetch: behind=0).
  • Local validation re-ran cleanly: make fmt, make lint, make test-unit, make test, make recompile.

No additional code changes were required in this pass, so there is no new commit hash to share.

CI on this agent HEAD still needs a maintainer-triggered re-run (close/reopen PR, workflow_dispatch, or maintainer push) before merge.

@pelikhan
pelikhan merged commit dd4c601 into main Jul 7, 2026
30 checks passed
@pelikhan
pelikhan deleted the copilot/refactor-semantic-function-clustering branch July 7, 2026 06:18
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.82.3

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.

[refactor] Semantic function clustering: decompose large multi-cluster files (audit.go, import_field_extractor.go)

4 participants