Repository navigation
feat(render): diagnose added patch application - #433
Nan Liu (liunan-ms) wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Active analyzer defects can silently accept unapplied patches and falsely reject valid components in strict mode because function declarations, macro state, helper overrides, and diff hunk boundaries are mishandled.
4 open issues
What changed in this PR
Adds static diagnostics for overlay-added patches during source preparation and rendering, partially addressing #408, #409, and #423 without inserting application commands or changing strip levels.
Changes:
- Shares final-spec patch analysis across both editors to identify missing selection, uncertain application, and likely strip mismatches.
- Adds render JSON
patchWarningsand the--patch-warnings=warn|errorpolicy. - Updates regression coverage, CLI snapshots, user documentation, and both agent-guidance variants.
| File | Description |
|---|---|
scenario/component_render_test.go |
Tests warning JSON and strict rendering behavior. |
scenario/clismoke_test.go |
Adds render-help snapshot coverage. |
scenario/__snapshots__/TestSnapshots_component_render_help_stdout_1.snap |
Records render help and warning policy. |
scenario/__snapshots__/TestSnapshots_component_render_help_stderr_1.snap |
Records help startup logging. |
scenario/__snapshots__/TestSnapshots_component_render_help_1.snap.json |
Records successful help exit status. |
internal/rpm/spec/patch_application.go |
Implements shared lexical patch-application analysis. |
internal/rpm/spec/patch_application_test.go |
Covers selection, macros, execution hazards, and paths. |
internal/app/azldev/core/sources/sourceprep.go |
Invokes diagnostics after overlays and adds a reporting callback. |
internal/app/azldev/core/sources/patch_application.go |
Reads final patch contents and reports diagnostics. |
internal/app/azldev/core/sources/patch_application_internal_test.go |
Tests final-overlay analysis and reporting. |
internal/app/azldev/cmds/component/render.go |
Adds warning policy and preserves diagnostics in results. |
internal/app/azldev/cmds/component/render_test.go |
Tests flag registration and policy validation. |
internal/app/azldev/cmds/component/render_patch_warnings_internal_test.go |
Tests JSON, strict rejection, freshness checks, and failures. |
internal/app/azldev/agentskill/content/withoutlockfile/overlays.md.tmpl |
Documents diagnostics for lockfile-free workflows. |
internal/app/azldev/agentskill/content/overlays.md.tmpl |
Documents diagnostics for default workflows. |
internal/app/azldev/agentskill/agentskill_test.go |
Checks diagnostic guidance in both modes. |
docs/user/reference/config/overlays.md |
Explains analysis limits and strict rendering policy. |
docs/user/reference/cli/azldev_component_render.md |
Updates generated render command reference. |
Review effort: Balanced
1b0b9a8 to
15aca51
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved parsing issues falsely reject valid patch applications and allow patches running in a subshell’s changed directory to pass strict checks without a diagnostic.
3 open issues
4 resolved since last review
Review effort: Balanced
15aca51 to
ee0aba3
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The scanner misses assignment- and builtin-prefixed commands that can skip or misdirect patch application even under strict rendering, while misclassified backslashes can also cause valid components to be rejected.
2 open issues
3 resolved since last review
Review effort: Balanced
ee0aba3 to
4241451
Compare
There was a problem hiding this comment.
🟡 Changes recommended
A critical control-flow gap ignores ! exit 0, allowing an unreachable %patch0 -p1 to pass without diagnostics even in strict mode; both editors need a fix and regression coverage.
1 open issue
2 resolved since last review
Review effort: Balanced
4241451 to
3ac5bc7
Compare
Check final specs for supported unconditional application of overlay-added patches and report selection uncertainty or likely strip mismatches. Expose patchWarnings in render JSON and add a strict warning policy, with regression tests and updated user and agent documentation.
There was a problem hiding this comment.
🟡 Changes recommended
Critical parsing and backend-state gaps suppress diagnostics for missing or unreachable patch applications and incorrect strip levels, including under strict policy.
4 open issues
1 resolved since last review
Review effort: Balanced


Why this is needed
patch-addcopies a patch and registers aPatchN:tag or%patchlistentry, but registration alone does not establish that preparation applies it. A package can build without the intended downstream fix, or fail later because the patchpaths and strip level do not agree.
Related open issues:
added patches can be silently skipped in specs with hand-written
%patchsequences. This PR makes missing recognized application visible during rendering.
bare
%autosetupcan use an incompatible strip level for subdirectory patches.This PR reports likely path/strip mismatches before the build.
proposed strip-aware application and final-render diagnostics. This PR implements
the diagnostic portion using a deliberately narrower static-analysis contract.
These are related/partially addressed issues, not automatic-closing references:
this PR does not implement a
stripconfiguration field, insert application commands, or rewrite existing preparation commands.Changes
%patchforms,%autopatch,%autosetup, and supported%forgeautosetup/%goprepbehavior, including disabled patching and ranges.patchWarningsin render JSON and add--patch-warnings=warn|error.Decision flow
For each supplied overlay-added patch:
%prep. Repeated, conditional, augmented (%prep -a/%prep -p), or malformed preparation remains unverified.-N, wrapper defaults, explicit selections, inclusive ranges, backend, and strip options.-nwithout evaluating them.Ordinary preamble macros, unrelated generated definitions, and opaque surrounding commands do not veto an otherwise understood selection. Conditional commands and their side effects are skipped. Duplicate application is deliberately not detected. Loaded macro files and macro expressions are not evaluated.
Rendering policy
--patch-warnings=warn--patch-warnings=error--fail-on-errorcontrols whether component failures cause a nonzero invocation exit. Successful components retain their output when another component fails.--check-onlyretains its existing freshness/drift semantics.Validation
Automated checks
The following commands passed during implementation/review:
mage fix all- passed.mage unit- passed, including both-editor selection/numbering/helper regressionsand render JSON/default/strict-policy tests.
mage check all- passed.mage docs- passed; CLI reference regenerated.TESTING_DISABLE_NETWORK_TESTS=1 mage scenarioUpdate- passed; snapshots updated.TESTING_DISABLE_NETWORK_TESTS=1 mage all- passed: build, unit tests,formatting/lint, static analysis, licenses, offline scenarios, and docs/schema.
Rendered 56 components with patch-add overlays
3 patch warnings:
fido-device-onboardpin-libcryptsetup-rs-0.13.2.patch(Patch1001)python-blivetbb696202-fix-cpe-2.3-version-parsing.patch(Patch104)%autosetupuses additional archive extraction (-b1), outside the modeled setup flow.uv0001-use-python314-tests.patch(Patch4)%prep -ais intentionally unsupported; implicit build-system preparation is not modeled.A separate negative check intentionally removed the application overlay for
golang-github-gorilla-sessions: the patch remained declared, while bare%goprepandcpsupplied no recognized application. Rendering correctly returnedstatus: "ok"with a missing-unconditional-selection warning under default policy.