From 022a6505ae5e7d5879a4a59c3583b8305e2d0d22 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Fri, 31 Jul 2026 20:25:24 -0700 Subject: [PATCH] Precompute clang-tidy diagnostics in build-warning-fixer and add issue-context diff handoff (#10336) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This updates the `build-warning-fixer` agentic workflow to front-load compilation/diagnostic collection before agent execution, reducing repeated setup work in agent mode. It also improves issue-triggered runs by requiring explicit git diff output so follow-on PR authoring has directly usable patches. - **Pre-agent compile + diagnostics collection** - Added workflow `steps` in `build-warning-fixer.md` to run checkout, tool install, CMake configure/build, and diagnostic extraction before the agent prompt executes. - Persisted structured artifacts under `/tmp/gh-aw/agent/`: - `prebuild-status.txt` - `clang-tidy-configure.log` - `clang-tidy-build.log` - `clang-tidy-diagnostics.txt` - **Prompt flow changed to consume prebuilt context** - Reworked task instructions from “build first” to “inspect prebuild outputs first.” - Kept rebuild/fix loop for validated, conservative edits after code changes. - **Issue-context PR handoff improvement** - Added explicit instruction for issue-dispatched runs (`aw_context.item_type == "issue"`) to include: - `git diff --stat` - full `git diff` in fenced `diff` output - This makes proposed changes directly transferable into PR creation. - **Workflow metadata refresh** - Updated checkout action reference to `actions/checkout@v7.0.1`. - Recompiled `build-warning-fixer.lock.yml` to reflect source workflow updates. ```yaml - name: Prebuild and collect clang diagnostics run: | CC=clang CXX=clang++ cmake -GNinja -S . -B build \ -DCMAKE_BUILD_TYPE=Debug \ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ -DCMAKE_CXX_CLANG_TIDY=clang-tidy \ 2>&1 | tee /tmp/gh-aw/agent/clang-tidy-configure.log cmake --build build --target shell test-z3 -k 0 \ 2>&1 | tee /tmp/gh-aw/agent/clang-tidy-build.log grep -nE 'warning:|error:|clang-tidy' /tmp/gh-aw/agent/clang-tidy-build.log \ > /tmp/gh-aw/agent/clang-tidy-diagnostics.txt || true ``` --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- .../workflows/build-warning-fixer.lock.yml | 25 ++--- .github/workflows/build-warning-fixer.md | 100 ++++++++++++------ 2 files changed, 76 insertions(+), 49 deletions(-) diff --git a/.github/workflows/build-warning-fixer.lock.yml b/.github/workflows/build-warning-fixer.lock.yml index 8e2e9b725b..1dee724943 100644 --- a/.github/workflows/build-warning-fixer.lock.yml +++ b/.github/workflows/build-warning-fixer.lock.yml @@ -1,4 +1,4 @@ -# gh-aw-metadata: {"schema_version":"v4","frontmatter_hash":"c65096f8348ac1ac5c1314ec367754e2d60976068118951cd31a640508c4eeaa","body_hash":"459dd7fdb2ee5a282dc3a85286a93073c174486bb276b542bd13dc12373423f0","compiler_version":"v0.83.4","strict":true,"agent_id":"copilot","engine_versions":{"copilot":"1.0.75"}} +# gh-aw-metadata: {"schema_version":"v4","frontmatter_hash":"1b50e68f9e9b814e39eacdf32639ccd137eb7dce7f0a13296ee1d364d08ab089","body_hash":"4dedf9a2b5bbadc75aa0ca83c86c53aad28f55bb414b599cbdffae0ed428f910","compiler_version":"v0.83.4","strict":true,"agent_id":"copilot","engine_versions":{"copilot":"1.0.75"}} # gh-aw-manifest: {"version":1,"secrets":["COPILOT_GITHUB_TOKEN","GH_AW_CI_TRIGGER_TOKEN","GH_AW_GITHUB_MCP_SERVER_TOKEN","GH_AW_GITHUB_TOKEN","GITHUB_TOKEN"],"actions":[{"repo":"actions/cache/restore","sha":"55cc8345863c7cc4c66a329aec7e433d2d1c52a9","version":"v6.1.0"},{"repo":"actions/cache/save","sha":"55cc8345863c7cc4c66a329aec7e433d2d1c52a9","version":"v6.1.0"},{"repo":"actions/checkout","sha":"3d3c42e5aac5ba805825da76410c181273ba90b1","version":"v7.0.1"},{"repo":"actions/download-artifact","sha":"3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c","version":"v8.0.1"},{"repo":"actions/github-script","sha":"3a2844b7e9c422d3c10d287c895573f7108da1b3","version":"v9.0.0"},{"repo":"actions/setup-node","sha":"820762786026740c76f36085b0efc47a31fe5020","version":"v7.0.0"},{"repo":"actions/upload-artifact","sha":"043fb46d1a93c77aae656e7c1c64a875d1fc6a0a","version":"v7.0.1"},{"repo":"github/gh-aw-actions/setup","sha":"v0.83.4","version":"v0.83.4"}],"containers":[{"image":"ghcr.io/github/gh-aw-firewall/agent:0.27.42","digest":"sha256:26a8af4e5566485b02f52af59ee03803ae798271a9619d4767e94d07806deb9b","pinned_image":"ghcr.io/github/gh-aw-firewall/agent:0.27.42@sha256:26a8af4e5566485b02f52af59ee03803ae798271a9619d4767e94d07806deb9b"},{"image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.27.42","digest":"sha256:944f2686c9ab9bec338fd14b662461662f77cd12cd0ea8a3e7cb8c0987cd1607","pinned_image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.27.42@sha256:944f2686c9ab9bec338fd14b662461662f77cd12cd0ea8a3e7cb8c0987cd1607"},{"image":"ghcr.io/github/gh-aw-firewall/squid:0.27.42","digest":"sha256:42dfeb649c680a8558cd5423dbc530b653a69413e35ffbe5e71da5d48c94bdf0","pinned_image":"ghcr.io/github/gh-aw-firewall/squid:0.27.42@sha256:42dfeb649c680a8558cd5423dbc530b653a69413e35ffbe5e71da5d48c94bdf0"},{"image":"ghcr.io/github/gh-aw-mcpg:v0.4.6","digest":"sha256:fecabec51bbc41f2ad61076d6bcd9a36ef23b142e672a444e054d37fc29de93c","pinned_image":"ghcr.io/github/gh-aw-mcpg:v0.4.6@sha256:fecabec51bbc41f2ad61076d6bcd9a36ef23b142e672a444e054d37fc29de93c"},{"image":"ghcr.io/github/gh-aw-node","digest":"sha256:a8082161d7dceda14b68f32eb39d0eaa96b825d07f5895b096afab9d9e0c7748","pinned_image":"ghcr.io/github/gh-aw-node@sha256:a8082161d7dceda14b68f32eb39d0eaa96b825d07f5895b096afab9d9e0c7748"},{"image":"ghcr.io/github/github-mcp-server:v1.7.0","digest":"sha256:c491ffdf6f4c85cb5397021bc655edb8ab825c6f5f568e7597d77a1bd7c4d308","pinned_image":"ghcr.io/github/github-mcp-server:v1.7.0@sha256:c491ffdf6f4c85cb5397021bc655edb8ab825c6f5f568e7597d77a1bd7c4d308"}]} # This file was automatically generated by gh-aw (v0.83.4). DO NOT EDIT. To debug this workflow, load the skill at https://github.com/github/gh-aw/blob/main/debug.md # @@ -302,17 +302,6 @@ jobs: cat << 'GH_AW_PROMPT_a12b000ae128b391_EOF' {{#runtime-import .github/workflows/build-warning-fixer.md}} - - ## Runtime guardrail - - The full `clang-tidy` build of both `shell` and `test-z3` is too large for this workflow's practical runtime budget. - This guardrail overrides the broader rebuild instructions above when they would keep you waiting on a long build. - - - Use `cmake --build build --target shell -- -k 0 2>&1 | tee /tmp/gh-aw/agent/clang-tidy-build.log` for initial diagnostic collection. - - Do **not** wait for the full `shell` build to finish before deciding what to do. - - Monitor `/tmp/gh-aw/agent/clang-tidy-build.log` and stop once you have enough diagnostics for one small, high-confidence fix, or after 15 minutes, whichever comes first. - - If you still do not have a safe, validated fix inside that budget, call `noop` with the diagnostics you found instead of continuing to wait. - - After a localized fix, rebuild `shell` and run a quick manual check such as `./build/z3 --version`; only build and run `test-z3` when the test binary is already available or can be built quickly within the remaining time budget. GH_AW_PROMPT_a12b000ae128b391_EOF } > "$GH_AW_PROMPT" - name: Interpolate variables and render templates @@ -460,10 +449,6 @@ jobs: echo "GH_AW_SAFE_OUTPUTS_CONFIG_PATH=${RUNNER_TEMP}/gh-aw/safeoutputs/config.json" echo "GH_AW_SAFE_OUTPUTS_TOOLS_PATH=${RUNNER_TEMP}/gh-aw/safeoutputs/tools.json" } >> "$GITHUB_OUTPUT" - - name: Checkout repository - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - name: Create gh-aw temp directory run: bash "${RUNNER_TEMP}/gh-aw/actions/create_gh_aw_tmp_dir.sh" - name: Configure gh CLI for GitHub Enterprise @@ -475,6 +460,14 @@ jobs: with: name: activation path: /tmp/gh-aw + - name: Checkout repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - name: Prebuild and collect clang diagnostics + run: "set -o pipefail\nmkdir -p /tmp/gh-aw/agent\n\nsudo apt-get update -y\nsudo apt-get install -y clang clang-tidy cmake ninja-build python3\n\nrm -rf build\n\nconfigure_status=0\nbuild_status=0\n\nCC=clang CXX=clang++ cmake -GNinja -S . -B build \\\n -DCMAKE_BUILD_TYPE=Debug \\\n -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \\\n -DCMAKE_CXX_CLANG_TIDY=clang-tidy \\\n 2>&1 | tee /tmp/gh-aw/agent/clang-tidy-configure.log || configure_status=$?\n\nif [ \"$configure_status\" -eq 0 ]; then\n cmake --build build --target shell test-z3 -k 0 \\\n 2>&1 | tee /tmp/gh-aw/agent/clang-tidy-build.log || build_status=$?\nelse\n printf 'configure failed; build skipped\\n' | tee /tmp/gh-aw/agent/clang-tidy-build.log\n build_status=125\nfi\n\ngrep -nE 'warning:|error:|clang-tidy' /tmp/gh-aw/agent/clang-tidy-build.log \\\n > /tmp/gh-aw/agent/clang-tidy-diagnostics.txt || true\n\n{\n echo \"configure_status=$configure_status\"\n echo \"build_status=$build_status\"\n} > /tmp/gh-aw/agent/prebuild-status.txt\n" + shell: bash + - name: Configure Git credentials env: GITHUB_REPOSITORY: ${{ github.repository }} diff --git a/.github/workflows/build-warning-fixer.md b/.github/workflows/build-warning-fixer.md index a269821609..83213e4f18 100644 --- a/.github/workflows/build-warning-fixer.md +++ b/.github/workflows/build-warning-fixer.md @@ -30,56 +30,79 @@ tools: bash: [":*"] timeout-minutes: 90 strict: true + +steps: + - name: Checkout repository + uses: actions/checkout@v7.0.1 + with: + persist-credentials: false + + - name: Prebuild and collect clang diagnostics + shell: bash + run: | + set -o pipefail + mkdir -p /tmp/gh-aw/agent + + sudo apt-get update -y + sudo apt-get install -y clang clang-tidy cmake ninja-build python3 + + rm -rf build + + configure_status=0 + build_status=0 + + CC=clang CXX=clang++ cmake -GNinja -S . -B build \ + -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ + -DCMAKE_CXX_CLANG_TIDY=clang-tidy \ + 2>&1 | tee /tmp/gh-aw/agent/clang-tidy-configure.log || configure_status=$? + + if [ "$configure_status" -eq 0 ]; then + cmake --build build --target shell test-z3 -k 0 \ + 2>&1 | tee /tmp/gh-aw/agent/clang-tidy-build.log || build_status=$? + else + printf 'configure failed; build skipped\n' | tee /tmp/gh-aw/agent/clang-tidy-build.log + build_status=125 + fi + + grep -nE 'warning:|error:|clang-tidy' /tmp/gh-aw/agent/clang-tidy-build.log \ + > /tmp/gh-aw/agent/clang-tidy-diagnostics.txt || true + + { + echo "configure_status=$configure_status" + echo "build_status=$build_status" + } > /tmp/gh-aw/agent/prebuild-status.txt --- # Clang-Tidy Warning Fixer -You are an AI agent that compiles Z3 with clang-tidy, reviews the resulting warnings and errors, and creates a pull request with conservative fixes when you can do so safely. +You are an AI agent that uses pre-collected clang-tidy diagnostics, reviews warnings and errors, and creates a pull request with conservative fixes when you can do so safely. ## Current Context - **Repository**: ${{ github.repository }} - **Workflow**: ${{ github.workflow }} - **Workspace**: ${{ github.workspace }} +- **Prebuild status file**: `/tmp/gh-aw/agent/prebuild-status.txt` +- **Prebuild configure log**: `/tmp/gh-aw/agent/clang-tidy-configure.log` +- **Prebuild build log**: `/tmp/gh-aw/agent/clang-tidy-build.log` +- **Prebuild diagnostics list**: `/tmp/gh-aw/agent/clang-tidy-diagnostics.txt` ## Your Task -### 1. Build Z3 with clang-tidy enabled +### 1. Review prebuild results before taking action -Use the repository's CMake + Ninja workflow and build Z3 directly with Clang. +This workflow already ran a prebuild with clang-tidy before agent mode. Start by inspecting: +- `/tmp/gh-aw/agent/prebuild-status.txt` +- `/tmp/gh-aw/agent/clang-tidy-configure.log` +- `/tmp/gh-aw/agent/clang-tidy-build.log` +- `/tmp/gh-aw/agent/clang-tidy-diagnostics.txt` -1. Install the required tools: - -```bash -sudo apt-get update -y -sudo apt-get install -y clang clang-tidy cmake ninja-build python3 -clang --version -clang-tidy --version -ninja --version -``` - -2. Start from a clean build directory and configure with clang/clang++: - -```bash -rm -rf build -CC=clang CXX=clang++ cmake -GNinja -S . -B build \ - -DCMAKE_BUILD_TYPE=Debug \ - -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ - -DCMAKE_CXX_CLANG_TIDY=clang-tidy \ - 2>&1 | tee /tmp/gh-aw/agent/clang-tidy-configure.log -``` - -3. Build the main Z3 shell and unit test binary while capturing logs: - -```bash -cmake --build build --target shell test-z3 -k 0 2>&1 | tee /tmp/gh-aw/agent/clang-tidy-build.log -``` - -4. If configuration fails, inspect `/tmp/gh-aw/agent/clang-tidy-configure.log` and call `noop` with a clear summary unless you can make an obvious, local, semantics-preserving fix. +If prebuild configuration failed, inspect the configure log and call `noop` with a clear summary unless you can make an obvious, local, semantics-preserving fix. ### 2. Extract actionable diagnostics -Analyze `/tmp/gh-aw/agent/clang-tidy-build.log` and focus on diagnostics that clang-tidy or clang emitted during this workflow run. +Analyze `/tmp/gh-aw/agent/clang-tidy-diagnostics.txt` and `/tmp/gh-aw/agent/clang-tidy-build.log`, focusing on diagnostics emitted during this workflow run. Use commands like: @@ -139,7 +162,18 @@ cmake --build build --target shell test-z3 -k 0 2>&1 | tee /tmp/gh-aw/agent/clan If the rebuilt logs still contain actionable warnings, you may fix another small set if you remain confident. Otherwise stop. -### 6. Create the pull request +### 6. Provide git diff details for GitHub issue contexts + +When this workflow is dispatched from a GitHub issue context (for example via `aw_context` with `item_type == "issue"`), always include patch details to make PR creation easy: + +```bash +git diff --stat +git diff +``` + +If changes were made, include the full unified diff in your final response in a fenced `diff` block. + +### 7. Create the pull request If you made safe fixes, create a pull request using `create-pull-request`.