Repository navigation
Split parser import field extraction into focused modules - #76898
Conversation
Co-authored-by: gh-aw-bot <[email protected]>
Co-authored-by: gh-aw-bot <[email protected]>
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality SentinelOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ PR Specification Reviewer completed successfully! PR Specification ReviewerOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅
|
|
✅ Ponytail Reviewer completed successfully!
|
This comment has been minimized.
This comment has been minimized.
|
✅ PR Code Quality Reviewer completed the code quality review.
|
There was a problem hiding this comment.
What this change does: It splits import field extraction across focused files and adds a JSON decoding helper.
Should fix
-
Remove the redundant JSON helper (
pkg/parser/import_extract_helpers.go:10)- What this is: The helper decodes each imported JSON value and checks for trailing content.
- Problem:
json.Unmarshalalready accepts trailing whitespace and rejects extra or malformed content, so the helper and its tests duplicate standard library behavior. - Fix: Restore
json.Unmarshalat the six callers and remove the helper and its tests. - If we skip it: There is extra parsing code and a test suite to maintain.
Verdict: Ship.
Lean: -46 lines possible.
Generated by ✂️ Ponytail Reviewer for #76898 · codex · routed: gpt61 medium · ~7 AIC · ⌖ ~1 AIC · ⊞ 181
Comment /ponytail to run again
| "strings" | ||
| ) | ||
|
|
||
| func unmarshalJSONFromString(content string, target any) error { |
There was a problem hiding this comment.
Should fix: Restore json.Unmarshal([]byte(content), target) at these six callers and remove this helper and its tests: json.Unmarshal already accepts trailing whitespace and rejects extra or malformed content, so the second decode duplicates existing behavior. (~46 lines saved.)
There was a problem hiding this comment.
Replaced the local decoder with the existing jsonutil.UnmarshalString at all six call sites and removed the duplicate helper/tests. It avoids string-to-byte copies while retaining whole-document validation. Commit: 5f73b853.
There was a problem hiding this comment.
Reviewed the changed parser files; no actionable correctness, performance, or security issues found in the diff. The specialist pass was unavailable due to its file-access restriction, so this verdict is based on the independent static review.
Review scope
The change is a responsibility split of the existing import extractor plus strict trailing-JSON validation tests. No behavioral regression was identifiable from the changed lines.
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~2 AIC · ⌖ ~1 AIC · ⊞ 1.6K
Comment /review to run again
🏗️ Design Decision Gate — ADR RequiredThis PR makes significant changes to core business logic (>100 new lines in 📄 Draft ADR committed:
📋 What to do next
Once an ADR is linked in the PR body, this gate will re-run and verify the implementation matches the decision. ❓ Why ADRs MatterADRs 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 ReferenceAn ADR must contain these four sections to be considered complete:
All ADRs are stored in
|
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are blocking the workflow import refactor.
No open issues 🎉
What changed in this PR
Refactors workflow import processing in pkg/parser into focused modules, addressing #76861 without changing public APIs.
Changes:
- Splits the 1,190-line extractor into six responsibility-focused files, each under 300 lines.
- Adds shared string-based JSON decoding that preserves rejection of trailing content.
- Adds tests for trailing whitespace, additional JSON values, and malformed trailing content.
| File | Description |
|---|---|
pkg/parser/import_field_extractor.go |
Removes the monolithic implementation after redistribution. |
pkg/parser/import_extract_steps.go |
Groups step, job, environment, and feature extraction. |
pkg/parser/import_extract_models.go |
Isolates model aliases, policies, and pricing normalization. |
pkg/parser/import_extract_helpers.go |
Adds shared strict JSON decoding from strings. |
pkg/parser/import_extract_helpers_test.go |
Tests JSON trailing-content handling. |
pkg/parser/import_extract_frontmatter.go |
Houses import orchestration and frontmatter processing. |
pkg/parser/import_extract_engine.go |
Groups engine and configuration extraction. |
pkg/parser/import_extract_activation.go |
Groups activation, authentication, and list merging. |
pkg/parser/import_accumulator.go |
Houses accumulated state and result construction. |
Review effort: Balanced (auto)
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /codebase-design and /improve-codebase-architecture. The file split is sound: I rebuilt the deleted 1,190-line file from the diff and every line maps to a new file, with only the six JSON call sites changed. go build, go vet, gofmt, the new helper test, and the full pkg/parser suite all pass.
Requesting changes for three items:
- Redundant helper:
unmarshalJSONFromStringadds no behaviour.json.Unmarshalalready rejects trailing values, and the helper is about 15–20% slower with more allocations. - Stale doc references: the copied package comment in
import_accumulator.goand the file map inimport_processor.gostill refer to the deleted file.
📋 Key Themes & Highlights
Key Themes
- Pure refactor, verified: the split preserves logic line for line.
- Redundant abstraction: the new JSON helper duplicates stdlib behaviour.
- Stale references: two comments still point at
import_field_extractor.go.
Positive Highlights
- ✅ Each new module is focused and under 300 lines.
- ✅ The new helper test covers the trailing-content cases.
@copilot please address the review comments above.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~10 AIC · ⌖ ~2 AIC · ⊞ 6.6K
Comment /matt to run again
| "strings" | ||
| ) | ||
|
|
||
| func unmarshalJSONFromString(content string, target any) error { |
There was a problem hiding this comment.
[/codebase-design] The trailing-content check is redundant: json.Unmarshal already rejects trailing values (checked for {} {}, {} invalid and {} null). This helper is slower and allocates more than the call it replaces, and it decodes into target before rejecting, so partial output can remain on error.
💡 Suggested change
Revert the six call sites to json.Unmarshal([]byte(content), &target) and delete this helper. The PR description says the helper is needed to reject trailing JSON, but json.Unmarshal already does that.
@copilot please address this.
There was a problem hiding this comment.
Replaced the local decoder with the existing jsonutil.UnmarshalString at all six call sites and removed the duplicate helper/tests. It avoids string-to-byte copies while retaining whole-document validation. Commit: 5f73b853.
| @@ -0,0 +1,214 @@ | |||
| // Package parser provides functions for parsing and processing workflow markdown files. | |||
There was a problem hiding this comment.
[/codebase-design] This copies the package doc from the deleted import_field_extractor.go, which duplicates pkg/parser/doc.go. The comment directly above package parser (lines 3-4) now reads as a package doc but does not start with "Package parser".
💡 Suggested change
Drop line 1. Keep the file description as a plain comment, separated from package parser by a blank line.
@copilot please address this.
There was a problem hiding this comment.
Removed the duplicate package documentation comment, leaving the file-specific description as a regular comment. Commit: 643119f3.
|
🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:
Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering. Structured data{
"completed_task": 0,
"head": "c97da5537ceb4a2f7b089f851e9d59b65910e8e0",
"kind": "requested",
"schema_version": "1",
"state": "cb2289b8cc197637ea5ce619f3fe5bd024e0b1ea366e8ad243e844cbf8fa73a2",
"work": [
"26d5e90fefb41544c408a26ad72e3de4f6753d1dbd63552d294217982c2c05da",
"8d4751f603158c0cd5c153f9d22b0be9e480e605a0260724bbb7301422ca631a",
"cc98ca1e5d5e6aab04391fdd0992c7c3f33dcf1157a87a57316156a7ef370f11"
],
"workflow": "pr-sous-chef"
}
|
Co-authored-by: gh-aw-bot <[email protected]>
Co-authored-by: gh-aw-bot <[email protected]>
|
🎉 This pull request is included in a new release. Release: |
pkg/parser/import_field_extractor.gohad grown to 1,190 lines, mixing import orchestration, configuration extraction, activation merging, model normalization, and result building.