mirror of
https://github.com/Z3Prover/z3
synced 2026-01-25 03:24:01 +00:00
Fix code-conventions-analyzer to create issues instead of pull requests (#8311)
* Initial plan * Fix code-conventions-analyzer to create issues instead of pull requests Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
This commit is contained in:
parent
726b80965e
commit
1d022fa591
2 changed files with 116 additions and 161 deletions
215
.github/workflows/code-conventions-analyzer.lock.yml
generated
vendored
215
.github/workflows/code-conventions-analyzer.lock.yml
generated
vendored
|
|
@ -153,10 +153,50 @@ jobs:
|
|||
mkdir -p /tmp/gh-aw/safeoutputs
|
||||
mkdir -p /tmp/gh-aw/mcp-logs/safeoutputs
|
||||
cat > /opt/gh-aw/safeoutputs/config.json << 'EOF'
|
||||
{"create_discussion":{"max":1},"create_missing_tool_issue":{"max":1,"title_prefix":"[missing tool]"},"create_pull_request":{},"missing_data":{},"missing_tool":{},"noop":{"max":1}}
|
||||
{"create_discussion":{"max":1},"create_issue":{"max":1},"create_missing_tool_issue":{"max":1,"title_prefix":"[missing tool]"},"missing_data":{},"missing_tool":{},"noop":{"max":1}}
|
||||
EOF
|
||||
cat > /opt/gh-aw/safeoutputs/tools.json << 'EOF'
|
||||
[
|
||||
{
|
||||
"description": "Create a new GitHub issue for tracking bugs, feature requests, or tasks. Use this for actionable work items that need assignment, labeling, and status tracking. For reports, announcements, or status updates that don't require task tracking, use create_discussion instead. CONSTRAINTS: Maximum 1 issue(s) can be created. Title will be prefixed with \"[Conventions] \". Labels [code-quality automated] will be automatically added.",
|
||||
"inputSchema": {
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"body": {
|
||||
"description": "Detailed issue description in Markdown. Do NOT repeat the title as a heading since it already appears as the issue's h1. Include context, reproduction steps, or acceptance criteria as appropriate.",
|
||||
"type": "string"
|
||||
},
|
||||
"labels": {
|
||||
"description": "Labels to categorize the issue (e.g., 'bug', 'enhancement'). Labels must exist in the repository.",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"parent": {
|
||||
"description": "Parent issue number for creating sub-issues. This is the numeric ID from the GitHub URL (e.g., 42 in github.com/owner/repo/issues/42). Can also be a temporary_id (e.g., 'aw_abc123def456') from a previously created issue in the same workflow run.",
|
||||
"type": [
|
||||
"number",
|
||||
"string"
|
||||
]
|
||||
},
|
||||
"temporary_id": {
|
||||
"description": "Unique temporary identifier for referencing this issue before it's created. Format: 'aw_' followed by 12 hex characters (e.g., 'aw_abc123def456'). Use '#aw_ID' in body text to reference other issues by their temporary_id; these are replaced with actual issue numbers after creation.",
|
||||
"type": "string"
|
||||
},
|
||||
"title": {
|
||||
"description": "Concise issue title summarizing the bug, feature, or task. The title appears as the main heading, so keep it brief and descriptive.",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"title",
|
||||
"body"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"name": "create_issue"
|
||||
},
|
||||
{
|
||||
"description": "Create a GitHub discussion for announcements, Q\u0026A, reports, status updates, or community conversations. Use this for content that benefits from threaded replies, doesn't require task tracking, or serves as documentation. For actionable work items that need assignment and status tracking, use create_issue instead. CONSTRAINTS: Maximum 1 discussion(s) can be created. Title will be prefixed with \"Code Conventions Analysis\". Discussions will be created in category \"Agentic Workflows\".",
|
||||
"inputSchema": {
|
||||
|
|
@ -183,39 +223,6 @@ jobs:
|
|||
},
|
||||
"name": "create_discussion"
|
||||
},
|
||||
{
|
||||
"description": "Create a new GitHub pull request to propose code changes. Use this after making file edits to submit them for review and merging. The PR will be created from the current branch with your committed changes. For code review comments on an existing PR, use create_pull_request_review_comment instead. CONSTRAINTS: Maximum 1 pull request(s) can be created. Title will be prefixed with \"[Conventions] \". Labels [code-quality automated] will be automatically added. PRs will be created as drafts.",
|
||||
"inputSchema": {
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"body": {
|
||||
"description": "Detailed PR description in Markdown. Include what changes were made, why, testing notes, and any breaking changes. Do NOT repeat the title as a heading.",
|
||||
"type": "string"
|
||||
},
|
||||
"branch": {
|
||||
"description": "Source branch name containing the changes. If omitted, uses the current working branch.",
|
||||
"type": "string"
|
||||
},
|
||||
"labels": {
|
||||
"description": "Labels to categorize the PR (e.g., 'enhancement', 'bugfix'). Labels must exist in the repository.",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"title": {
|
||||
"description": "Concise PR title describing the changes. Follow repository conventions (e.g., conventional commits). The title appears as the main heading.",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"title",
|
||||
"body"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"name": "create_pull_request"
|
||||
},
|
||||
{
|
||||
"description": "Report that a tool or capability needed to complete the task is not available, or share any information you deem important about missing functionality or limitations. Use this when you cannot accomplish what was requested because the required functionality is missing or access is restricted.",
|
||||
"inputSchema": {
|
||||
|
|
@ -315,7 +322,7 @@ jobs:
|
|||
}
|
||||
}
|
||||
},
|
||||
"create_pull_request": {
|
||||
"create_issue": {
|
||||
"defaultMax": 1,
|
||||
"fields": {
|
||||
"body": {
|
||||
|
|
@ -324,18 +331,22 @@ jobs:
|
|||
"sanitize": true,
|
||||
"maxLength": 65000
|
||||
},
|
||||
"branch": {
|
||||
"required": true,
|
||||
"type": "string",
|
||||
"sanitize": true,
|
||||
"maxLength": 256
|
||||
},
|
||||
"labels": {
|
||||
"type": "array",
|
||||
"itemType": "string",
|
||||
"itemSanitize": true,
|
||||
"itemMaxLength": 128
|
||||
},
|
||||
"parent": {
|
||||
"issueOrPRNumber": true
|
||||
},
|
||||
"repo": {
|
||||
"type": "string",
|
||||
"maxLength": 256
|
||||
},
|
||||
"temporary_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"title": {
|
||||
"required": true,
|
||||
"type": "string",
|
||||
|
|
@ -569,7 +580,7 @@ jobs:
|
|||
<instructions>
|
||||
To create or modify GitHub resources (issues, discussions, pull requests, etc.), you MUST call the appropriate safe output tool. Simply writing content will NOT work - the workflow requires actual tool calls.
|
||||
|
||||
**Available tools**: create_discussion, create_pull_request, missing_tool, noop
|
||||
**Available tools**: create_discussion, create_issue, missing_tool, noop
|
||||
|
||||
**Critical**: Tool calls write structured data that downstream jobs process. Without tool calls, follow-up actions will be skipped.
|
||||
</instructions>
|
||||
|
|
@ -613,14 +624,14 @@ jobs:
|
|||
|
||||
## Your Task
|
||||
|
||||
**PRIMARY FOCUS: Create Pull Requests for std::optional Refactoring**
|
||||
**PRIMARY FOCUS: Create Issues for std::optional Refactoring**
|
||||
|
||||
Your primary task is to identify and **directly implement** refactorings that replace pointer-based optional patterns with `std::optional<T>`. This workflow will:
|
||||
|
||||
1. **Find std::optional opportunities** - Functions returning null pointers to indicate absence or using output parameters
|
||||
2. **Implement the refactoring** - Use the `edit` tool to make actual code changes
|
||||
3. **Create pull requests** - Automatically create a PR with your changes for std::optional improvements
|
||||
4. **Create discussions for other findings** - For other code quality issues, create discussions (not PRs)
|
||||
3. **Create issues** - Automatically create an issue with your changes for std::optional improvements
|
||||
4. **Create discussions for other findings** - For other code quality issues, create discussions (not issues)
|
||||
|
||||
**Focus Areas for std::optional Refactoring:**
|
||||
- Functions returning `nullptr` to indicate "no value"
|
||||
|
|
@ -628,13 +639,13 @@ jobs:
|
|||
- Boolean return + output parameter patterns (e.g., `bool get_value(T* out)`)
|
||||
- APIs that would benefit from explicit optional semantics
|
||||
|
||||
**SECONDARY FOCUS: Create Pull Requests for Tuple Pattern (Structured Bindings) Refactoring**
|
||||
**SECONDARY FOCUS: Create Issues for Tuple Pattern (Structured Bindings) Refactoring**
|
||||
|
||||
Your secondary task is to identify and implement refactorings that use C++17 structured bindings instead of accessing `.first` and `.second`:
|
||||
|
||||
1. **Find tuple/pair access patterns** - Code accessing `.first` and `.second` members
|
||||
2. **Implement the refactoring** - Replace with structured bindings for clearer code
|
||||
3. **Create pull requests** - Automatically create a PR with your changes for tuple pattern improvements
|
||||
3. **Create issues** - Automatically create an issue with your changes for tuple pattern improvements
|
||||
|
||||
**Focus Areas for Tuple Pattern Refactoring:**
|
||||
- Variables that access both `.first` and `.second` multiple times
|
||||
|
|
@ -653,13 +664,13 @@ jobs:
|
|||
return g(a, b);
|
||||
```
|
||||
|
||||
**TERTIARY FOCUS: Create Pull Requests for initializer_list Refactoring**
|
||||
**TERTIARY FOCUS: Create Issues for initializer_list Refactoring**
|
||||
|
||||
Your tertiary task is to identify and implement refactorings that use `std::initializer_list<T>` instead of array pointer + size parameters:
|
||||
|
||||
1. **Find array + size parameter patterns** - Functions taking `(unsigned sz, T* args)` or similar
|
||||
2. **Implement the refactoring** - Replace with `std::initializer_list<T>` for cleaner APIs
|
||||
3. **Create pull requests** - Automatically create a PR with your changes for initializer_list improvements
|
||||
3. **Create issues** - Automatically create an issue with your changes for initializer_list improvements
|
||||
|
||||
**Focus Areas for initializer_list Refactoring:**
|
||||
- Functions with `unsigned sz/size/num, T* const* args` parameter pairs
|
||||
|
|
@ -777,9 +788,9 @@ jobs:
|
|||
- Check that the refactoring is complete
|
||||
- Ensure no compilation errors would occur
|
||||
|
||||
### Step C: Create the Pull Request
|
||||
### Step C: Create the Issue
|
||||
|
||||
Use the `output.create-pull-request` tool to create a PR with:
|
||||
Use the `output.create-issue` tool to create an issue with:
|
||||
- **Title**: "Refactor [function_name] to use std::optional"
|
||||
- **Description**:
|
||||
- Explain what was changed
|
||||
|
|
@ -787,7 +798,7 @@ jobs:
|
|||
- List all modified files
|
||||
- Note any caveats or considerations
|
||||
|
||||
**Example PR description:**
|
||||
**Example issue description:**
|
||||
```markdown
|
||||
# Refactor to use std::optional
|
||||
|
||||
|
|
@ -894,9 +905,9 @@ jobs:
|
|||
- Check that the refactoring is complete
|
||||
- Ensure no compilation errors would occur
|
||||
|
||||
### Step C: Create the Pull Request
|
||||
### Step C: Create the Issue
|
||||
|
||||
Use the `output.create-pull-request` tool to create a PR with:
|
||||
Use the `output.create-issue` tool to create an issue with:
|
||||
- **Title**: "Refactor [function_name] to use std::initializer_list"
|
||||
- **Description**:
|
||||
- Explain what was changed
|
||||
|
|
@ -904,7 +915,7 @@ jobs:
|
|||
- List all modified files
|
||||
- Note any caveats or considerations
|
||||
|
||||
**Example PR description:**
|
||||
**Example issue description:**
|
||||
```markdown
|
||||
# Refactor to use std::initializer_list
|
||||
|
||||
|
|
@ -1111,12 +1122,12 @@ jobs:
|
|||
**Optional Value Patterns:**
|
||||
- **PRIMARY TASK**: Functions returning null + using output parameters
|
||||
- **ACTION**: Replace with `std::optional<T>` return values using the refactoring workflow above
|
||||
- **RESULT**: Create a pull request with the actual code changes (see "Workflow for std::optional Refactoring")
|
||||
- **RESULT**: Create an issue with the actual code changes (see "Workflow for std::optional Refactoring")
|
||||
|
||||
**Tuple/Pair Access Patterns:**
|
||||
- **SECONDARY TASK**: Code accessing `.first` and `.second` on pairs/tuples
|
||||
- **ACTION**: Replace with C++17 structured bindings for cleaner, more readable code
|
||||
- **RESULT**: Create a pull request with the actual code changes
|
||||
- **RESULT**: Create an issue with the actual code changes
|
||||
- **Example**:
|
||||
```cpp
|
||||
// Before
|
||||
|
|
@ -1207,9 +1218,9 @@ jobs:
|
|||
|
||||
## Deliverables
|
||||
|
||||
### PRIMARY: Pull Request for std::optional Refactoring
|
||||
### PRIMARY: Issue for std::optional Refactoring
|
||||
|
||||
If you implement std::optional refactoring (following the workflow above), create a pull request using `output.create-pull-request` with:
|
||||
If you implement std::optional refactoring (following the workflow above), create an issue using `output.create-issue` with:
|
||||
- Clear title indicating what was refactored
|
||||
- Description of changes and benefits
|
||||
- List of modified files and functions
|
||||
|
|
@ -1441,7 +1452,7 @@ jobs:
|
|||
- **Incorrect std::move**: [Move from const, unnecessary moves]
|
||||
- **Return Value Optimization**: [Places where RVO is blocked]
|
||||
|
||||
### 4.8 Optional Value Pattern Modernization - **IMPLEMENT AS PULL REQUEST**
|
||||
### 4.8 Optional Value Pattern Modernization - **IMPLEMENT AS ISSUE**
|
||||
|
||||
**This is the PRIMARY focus area - implement these changes directly:**
|
||||
|
||||
|
|
@ -1450,14 +1461,14 @@ jobs:
|
|||
- **Action**: Use the "Workflow for std::optional Refactoring" section above to:
|
||||
1. Find candidate functions
|
||||
2. Refactor using the `edit` tool
|
||||
3. Create a pull request with your changes
|
||||
3. Create an issue with your changes
|
||||
- **API Improvements**: Specific function signatures to update
|
||||
PROMPT_EOF
|
||||
cat << 'PROMPT_EOF' >> "$GH_AW_PROMPT"
|
||||
- **API Improvements**: Specific function signatures to update
|
||||
- **Examples**: File:line references with before/after code
|
||||
- **Output**: Pull request (not just discussion)
|
||||
- **Output**: Issue (not just discussion)
|
||||
|
||||
### 4.9 Tuple Pattern (Structured Bindings) Modernization - **IMPLEMENT AS PULL REQUEST**
|
||||
### 4.9 Tuple Pattern (Structured Bindings) Modernization - **IMPLEMENT AS ISSUE**
|
||||
|
||||
**This is a SECONDARY focus area - implement these changes directly:**
|
||||
|
||||
|
|
@ -1472,7 +1483,7 @@ jobs:
|
|||
1. Search for patterns using `.first` and `.second`
|
||||
2. Identify cases where intermediate variable can be eliminated
|
||||
3. Refactor to use structured bindings
|
||||
4. Create a pull request with changes
|
||||
4. Create an issue with changes
|
||||
- **Example Pattern**:
|
||||
```cpp
|
||||
// Before: Using .first and .second
|
||||
|
|
@ -1514,7 +1525,7 @@ jobs:
|
|||
- Call `.first` and `.second` on the same variable multiple times
|
||||
- Create intermediate variables just to access pair members
|
||||
- Have sequential uses of both `.first` and `.second`
|
||||
- **Output**: Pull request with refactored code
|
||||
- **Output**: Issue with refactored code
|
||||
|
||||
### 4.10 Exception String Construction
|
||||
- **Current**: [stringstream usage for building exception messages]
|
||||
|
|
@ -1528,7 +1539,7 @@ jobs:
|
|||
- **Type Safety**: [How span improves API safety]
|
||||
- **Examples**: [Function signatures to update]
|
||||
|
||||
### 4.12 Array Parameter Modernization (std::initializer_list) - **IMPLEMENT AS PULL REQUEST**
|
||||
### 4.12 Array Parameter Modernization (std::initializer_list) - **IMPLEMENT AS ISSUE**
|
||||
|
||||
**This is a TERTIARY focus area - implement these changes directly:**
|
||||
|
||||
|
|
@ -1543,7 +1554,7 @@ jobs:
|
|||
1. Search for functions with `unsigned sz/size/num` + pointer parameters
|
||||
2. Identify functions where call sites use temporary arrays of constant size
|
||||
3. Refactor to use `std::initializer_list<T> const&`
|
||||
4. Create a pull request with changes
|
||||
4. Create an issue with changes
|
||||
- **Example Pattern**:
|
||||
```cpp
|
||||
// Before: Array + size parameters
|
||||
|
|
@ -1577,7 +1588,7 @@ jobs:
|
|||
- Have small, compile-time known array sizes
|
||||
- Are internal APIs (not part of public C interface)
|
||||
- Would benefit from simpler call syntax
|
||||
- **Output**: Pull request with refactored code
|
||||
- **Output**: Issue with refactored code
|
||||
- **Note**: Only apply to internal C++ APIs, not to public C API functions that need C compatibility
|
||||
|
||||
### 4.13 Increment Operator Patterns
|
||||
|
|
@ -1898,14 +1909,14 @@ jobs:
|
|||
- Use `bash` only for safe operations (git, grep patterns)
|
||||
- **For std::optional refactoring**: Use the `edit` tool to modify files directly
|
||||
- **For other findings**: Create discussions only (no code modifications)
|
||||
- All code changes for std::optional will be reviewed through the PR process
|
||||
- All code changes for std::optional will be reviewed through the issue process
|
||||
|
||||
## Output Requirements
|
||||
|
||||
**Two types of outputs:**
|
||||
|
||||
1. **Pull Request** (for std::optional refactoring):
|
||||
- Use `output.create-pull-request` to create a PR
|
||||
1. **Issue** (for std::optional refactoring):
|
||||
- Use `output.create-issue` to create an issue
|
||||
- Include clear title and description
|
||||
- List all modified files
|
||||
- Explain the refactoring and its benefits
|
||||
|
|
@ -1915,8 +1926,6 @@ jobs:
|
|||
- Use the structured format above
|
||||
- Include specific file references for all examples
|
||||
- Provide actionable recommendations
|
||||
PROMPT_EOF
|
||||
cat << 'PROMPT_EOF' >> "$GH_AW_PROMPT"
|
||||
- Previous discussions created by this workflow will be automatically closed (using `close-older-discussions: true`)
|
||||
|
||||
PROMPT_EOF
|
||||
|
|
@ -1977,17 +1986,9 @@ jobs:
|
|||
# --allow-tool shell(clang-format --version)
|
||||
# --allow-tool shell(date)
|
||||
# --allow-tool shell(echo)
|
||||
# --allow-tool shell(git add:*)
|
||||
# --allow-tool shell(git branch:*)
|
||||
# --allow-tool shell(git checkout:*)
|
||||
# --allow-tool shell(git commit:*)
|
||||
# --allow-tool shell(git diff:*)
|
||||
# --allow-tool shell(git log:*)
|
||||
# --allow-tool shell(git merge:*)
|
||||
# --allow-tool shell(git rm:*)
|
||||
# --allow-tool shell(git show:*)
|
||||
# --allow-tool shell(git status)
|
||||
# --allow-tool shell(git switch:*)
|
||||
# --allow-tool shell(grep)
|
||||
# --allow-tool shell(head)
|
||||
# --allow-tool shell(ls)
|
||||
|
|
@ -2002,7 +2003,7 @@ jobs:
|
|||
run: |
|
||||
set -o pipefail
|
||||
sudo -E awf --env-all --container-workdir "${GITHUB_WORKSPACE}" --mount /tmp:/tmp:rw --mount "${GITHUB_WORKSPACE}:${GITHUB_WORKSPACE}:rw" --mount /usr/bin/date:/usr/bin/date:ro --mount /usr/bin/gh:/usr/bin/gh:ro --mount /usr/bin/yq:/usr/bin/yq:ro --mount /usr/local/bin/copilot:/usr/local/bin/copilot:ro --mount /home/runner/.copilot:/home/runner/.copilot:rw --mount /opt/gh-aw:/opt/gh-aw:ro --allow-domains api.business.githubcopilot.com,api.enterprise.githubcopilot.com,api.github.com,api.githubcopilot.com,api.individual.githubcopilot.com,github.com,host.docker.internal,raw.githubusercontent.com,registry.npmjs.org --log-level info --proxy-logs-dir /tmp/gh-aw/sandbox/firewall/logs --enable-host-access --image-tag 0.10.0 \
|
||||
-- /usr/local/bin/copilot --add-dir /tmp/gh-aw/ --log-level all --log-dir /tmp/gh-aw/sandbox/agent/logs/ --add-dir "${GITHUB_WORKSPACE}" --disable-builtin-mcps --allow-tool github --allow-tool safeoutputs --allow-tool 'shell(cat)' --allow-tool 'shell(clang-format --version)' --allow-tool 'shell(date)' --allow-tool 'shell(echo)' --allow-tool 'shell(git add:*)' --allow-tool 'shell(git branch:*)' --allow-tool 'shell(git checkout:*)' --allow-tool 'shell(git commit:*)' --allow-tool 'shell(git diff:*)' --allow-tool 'shell(git log:*)' --allow-tool 'shell(git merge:*)' --allow-tool 'shell(git rm:*)' --allow-tool 'shell(git show:*)' --allow-tool 'shell(git status)' --allow-tool 'shell(git switch:*)' --allow-tool 'shell(grep)' --allow-tool 'shell(head)' --allow-tool 'shell(ls)' --allow-tool 'shell(pwd)' --allow-tool 'shell(sort)' --allow-tool 'shell(tail)' --allow-tool 'shell(uniq)' --allow-tool 'shell(wc)' --allow-tool 'shell(yq)' --allow-tool write --add-dir /tmp/gh-aw/cache-memory/ --allow-all-paths --share /tmp/gh-aw/sandbox/agent/logs/conversation.md --prompt "$(cat /tmp/gh-aw/aw-prompts/prompt.txt)"${GH_AW_MODEL_AGENT_COPILOT:+ --model "$GH_AW_MODEL_AGENT_COPILOT"} \
|
||||
-- /usr/local/bin/copilot --add-dir /tmp/gh-aw/ --log-level all --log-dir /tmp/gh-aw/sandbox/agent/logs/ --add-dir "${GITHUB_WORKSPACE}" --disable-builtin-mcps --allow-tool github --allow-tool safeoutputs --allow-tool 'shell(cat)' --allow-tool 'shell(clang-format --version)' --allow-tool 'shell(date)' --allow-tool 'shell(echo)' --allow-tool 'shell(git diff:*)' --allow-tool 'shell(git log:*)' --allow-tool 'shell(git show:*)' --allow-tool 'shell(grep)' --allow-tool 'shell(head)' --allow-tool 'shell(ls)' --allow-tool 'shell(pwd)' --allow-tool 'shell(sort)' --allow-tool 'shell(tail)' --allow-tool 'shell(uniq)' --allow-tool 'shell(wc)' --allow-tool 'shell(yq)' --allow-tool write --add-dir /tmp/gh-aw/cache-memory/ --allow-all-paths --share /tmp/gh-aw/sandbox/agent/logs/conversation.md --prompt "$(cat /tmp/gh-aw/aw-prompts/prompt.txt)"${GH_AW_MODEL_AGENT_COPILOT:+ --model "$GH_AW_MODEL_AGENT_COPILOT"} \
|
||||
2>&1 | tee /tmp/gh-aw/agent-stdio.log
|
||||
env:
|
||||
COPILOT_AGENT_RUNNER_TYPE: STANDALONE
|
||||
|
|
@ -2141,7 +2142,6 @@ jobs:
|
|||
/tmp/gh-aw/mcp-logs/
|
||||
/tmp/gh-aw/sandbox/firewall/logs/
|
||||
/tmp/gh-aw/agent-stdio.log
|
||||
/tmp/gh-aw/aw.patch
|
||||
if-no-files-found: ignore
|
||||
|
||||
conclusion:
|
||||
|
|
@ -2234,21 +2234,6 @@ jobs:
|
|||
setupGlobals(core, github, context, exec, io);
|
||||
const { main } = require('/opt/gh-aw/actions/handle_agent_failure.cjs');
|
||||
await main();
|
||||
- name: Handle Create Pull Request Error
|
||||
id: handle_create_pr_error
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
||||
env:
|
||||
GH_AW_AGENT_OUTPUT: ${{ env.GH_AW_AGENT_OUTPUT }}
|
||||
CREATE_PR_ERROR_MESSAGE: ${{ needs.create_pull_request.outputs.error_message }}
|
||||
GH_AW_WORKFLOW_NAME: "Code Conventions Analyzer"
|
||||
GH_AW_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
||||
with:
|
||||
github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
const { setupGlobals } = require('/opt/gh-aw/actions/setup_globals.cjs');
|
||||
setupGlobals(core, github, context, exec, io);
|
||||
const { main } = require('/opt/gh-aw/actions/handle_create_pr_error.cjs');
|
||||
await main();
|
||||
- name: Update reaction comment with completion status
|
||||
id: conclusion
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
||||
|
|
@ -2413,16 +2398,14 @@ jobs:
|
|||
|
||||
safe_outputs:
|
||||
needs:
|
||||
- activation
|
||||
- agent
|
||||
- detection
|
||||
if: ((!cancelled()) && (needs.agent.result != 'skipped')) && (needs.detection.outputs.success == 'true')
|
||||
runs-on: ubuntu-slim
|
||||
permissions:
|
||||
contents: write
|
||||
contents: read
|
||||
discussions: write
|
||||
issues: write
|
||||
pull-requests: write
|
||||
timeout-minutes: 15
|
||||
env:
|
||||
GH_AW_ENGINE_ID: "copilot"
|
||||
|
|
@ -2447,38 +2430,12 @@ jobs:
|
|||
mkdir -p /tmp/gh-aw/safeoutputs/
|
||||
find "/tmp/gh-aw/safeoutputs/" -type f -print
|
||||
echo "GH_AW_AGENT_OUTPUT=/tmp/gh-aw/safeoutputs/agent_output.json" >> "$GITHUB_ENV"
|
||||
- name: Download patch artifact
|
||||
continue-on-error: true
|
||||
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
|
||||
with:
|
||||
name: agent-artifacts
|
||||
path: /tmp/gh-aw/
|
||||
- name: Checkout repository
|
||||
if: ((!cancelled()) && (needs.agent.result != 'skipped')) && (contains(needs.agent.outputs.output_types, 'create_pull_request'))
|
||||
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
|
||||
with:
|
||||
token: ${{ github.token }}
|
||||
persist-credentials: false
|
||||
fetch-depth: 1
|
||||
- name: Configure Git credentials
|
||||
if: ((!cancelled()) && (needs.agent.result != 'skipped')) && (contains(needs.agent.outputs.output_types, 'create_pull_request'))
|
||||
env:
|
||||
REPO_NAME: ${{ github.repository }}
|
||||
SERVER_URL: ${{ github.server_url }}
|
||||
GIT_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git config --global user.name "github-actions[bot]"
|
||||
# Re-authenticate git with GitHub token
|
||||
SERVER_URL_STRIPPED="${SERVER_URL#https://}"
|
||||
git remote set-url origin "https://x-access-token:${GIT_TOKEN}@${SERVER_URL_STRIPPED}/${REPO_NAME}.git"
|
||||
echo "Git configured with standard GitHub Actions identity"
|
||||
- name: Process Safe Outputs
|
||||
id: process_safe_outputs
|
||||
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
||||
env:
|
||||
GH_AW_AGENT_OUTPUT: ${{ env.GH_AW_AGENT_OUTPUT }}
|
||||
GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG: "{\"create_discussion\":{\"category\":\"Agentic Workflows\",\"close_older_discussions\":true,\"expires\":168,\"max\":1,\"title_prefix\":\"Code Conventions Analysis\"},\"create_pull_request\":{\"base_branch\":\"${{ github.ref_name }}\",\"draft\":true,\"if_no_changes\":\"ignore\",\"labels\":[\"code-quality\",\"automated\"],\"max\":1,\"max_patch_size\":1024,\"title_prefix\":\"[Conventions] \"},\"missing_data\":{},\"missing_tool\":{}}"
|
||||
GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG: "{\"create_discussion\":{\"category\":\"Agentic Workflows\",\"close_older_discussions\":true,\"expires\":168,\"max\":1,\"title_prefix\":\"Code Conventions Analysis\"},\"create_issue\":{\"labels\":[\"code-quality\",\"automated\"],\"max\":1,\"title_prefix\":\"[Conventions] \"},\"missing_data\":{},\"missing_tool\":{}}"
|
||||
with:
|
||||
github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
|
|
|
|||
62
.github/workflows/code-conventions-analyzer.md
vendored
62
.github/workflows/code-conventions-analyzer.md
vendored
|
|
@ -17,11 +17,9 @@ tools:
|
|||
- "git diff:*"
|
||||
- "git show:*"
|
||||
safe-outputs:
|
||||
create-pull-request:
|
||||
create-issue:
|
||||
title-prefix: "[Conventions] "
|
||||
labels: [code-quality, automated]
|
||||
draft: true
|
||||
if-no-changes: ignore
|
||||
create-discussion:
|
||||
title-prefix: "Code Conventions Analysis"
|
||||
category: "Agentic Workflows"
|
||||
|
|
@ -38,14 +36,14 @@ You are an expert C++ code quality analyst specializing in the Z3 theorem prover
|
|||
|
||||
## Your Task
|
||||
|
||||
**PRIMARY FOCUS: Create Pull Requests for std::optional Refactoring**
|
||||
**PRIMARY FOCUS: Create Issues for std::optional Refactoring**
|
||||
|
||||
Your primary task is to identify and **directly implement** refactorings that replace pointer-based optional patterns with `std::optional<T>`. This workflow will:
|
||||
|
||||
1. **Find std::optional opportunities** - Functions returning null pointers to indicate absence or using output parameters
|
||||
2. **Implement the refactoring** - Use the `edit` tool to make actual code changes
|
||||
3. **Create pull requests** - Automatically create a PR with your changes for std::optional improvements
|
||||
4. **Create discussions for other findings** - For other code quality issues, create discussions (not PRs)
|
||||
3. **Create issues** - Automatically create an issue with your changes for std::optional improvements
|
||||
4. **Create discussions for other findings** - For other code quality issues, create discussions (not issues)
|
||||
|
||||
**Focus Areas for std::optional Refactoring:**
|
||||
- Functions returning `nullptr` to indicate "no value"
|
||||
|
|
@ -53,13 +51,13 @@ Your primary task is to identify and **directly implement** refactorings that re
|
|||
- Boolean return + output parameter patterns (e.g., `bool get_value(T* out)`)
|
||||
- APIs that would benefit from explicit optional semantics
|
||||
|
||||
**SECONDARY FOCUS: Create Pull Requests for Tuple Pattern (Structured Bindings) Refactoring**
|
||||
**SECONDARY FOCUS: Create Issues for Tuple Pattern (Structured Bindings) Refactoring**
|
||||
|
||||
Your secondary task is to identify and implement refactorings that use C++17 structured bindings instead of accessing `.first` and `.second`:
|
||||
|
||||
1. **Find tuple/pair access patterns** - Code accessing `.first` and `.second` members
|
||||
2. **Implement the refactoring** - Replace with structured bindings for clearer code
|
||||
3. **Create pull requests** - Automatically create a PR with your changes for tuple pattern improvements
|
||||
3. **Create issues** - Automatically create an issue with your changes for tuple pattern improvements
|
||||
|
||||
**Focus Areas for Tuple Pattern Refactoring:**
|
||||
- Variables that access both `.first` and `.second` multiple times
|
||||
|
|
@ -78,13 +76,13 @@ auto [a, b] = f(y);
|
|||
return g(a, b);
|
||||
```
|
||||
|
||||
**TERTIARY FOCUS: Create Pull Requests for initializer_list Refactoring**
|
||||
**TERTIARY FOCUS: Create Issues for initializer_list Refactoring**
|
||||
|
||||
Your tertiary task is to identify and implement refactorings that use `std::initializer_list<T>` instead of array pointer + size parameters:
|
||||
|
||||
1. **Find array + size parameter patterns** - Functions taking `(unsigned sz, T* args)` or similar
|
||||
2. **Implement the refactoring** - Replace with `std::initializer_list<T>` for cleaner APIs
|
||||
3. **Create pull requests** - Automatically create a PR with your changes for initializer_list improvements
|
||||
3. **Create issues** - Automatically create an issue with your changes for initializer_list improvements
|
||||
|
||||
**Focus Areas for initializer_list Refactoring:**
|
||||
- Functions with `unsigned sz/size/num, T* const* args` parameter pairs
|
||||
|
|
@ -202,9 +200,9 @@ For each selected function:
|
|||
- Check that the refactoring is complete
|
||||
- Ensure no compilation errors would occur
|
||||
|
||||
### Step C: Create the Pull Request
|
||||
### Step C: Create the Issue
|
||||
|
||||
Use the `output.create-pull-request` tool to create a PR with:
|
||||
Use the `output.create-issue` tool to create an issue with:
|
||||
- **Title**: "Refactor [function_name] to use std::optional"
|
||||
- **Description**:
|
||||
- Explain what was changed
|
||||
|
|
@ -212,7 +210,7 @@ Use the `output.create-pull-request` tool to create a PR with:
|
|||
- List all modified files
|
||||
- Note any caveats or considerations
|
||||
|
||||
**Example PR description:**
|
||||
**Example issue description:**
|
||||
```markdown
|
||||
# Refactor to use std::optional
|
||||
|
||||
|
|
@ -319,9 +317,9 @@ For each selected function:
|
|||
- Check that the refactoring is complete
|
||||
- Ensure no compilation errors would occur
|
||||
|
||||
### Step C: Create the Pull Request
|
||||
### Step C: Create the Issue
|
||||
|
||||
Use the `output.create-pull-request` tool to create a PR with:
|
||||
Use the `output.create-issue` tool to create an issue with:
|
||||
- **Title**: "Refactor [function_name] to use std::initializer_list"
|
||||
- **Description**:
|
||||
- Explain what was changed
|
||||
|
|
@ -329,7 +327,7 @@ Use the `output.create-pull-request` tool to create a PR with:
|
|||
- List all modified files
|
||||
- Note any caveats or considerations
|
||||
|
||||
**Example PR description:**
|
||||
**Example issue description:**
|
||||
```markdown
|
||||
# Refactor to use std::initializer_list
|
||||
|
||||
|
|
@ -534,12 +532,12 @@ Identify opportunities specific to Z3's architecture and coding patterns:
|
|||
**Optional Value Patterns:**
|
||||
- **PRIMARY TASK**: Functions returning null + using output parameters
|
||||
- **ACTION**: Replace with `std::optional<T>` return values using the refactoring workflow above
|
||||
- **RESULT**: Create a pull request with the actual code changes (see "Workflow for std::optional Refactoring")
|
||||
- **RESULT**: Create an issue with the actual code changes (see "Workflow for std::optional Refactoring")
|
||||
|
||||
**Tuple/Pair Access Patterns:**
|
||||
- **SECONDARY TASK**: Code accessing `.first` and `.second` on pairs/tuples
|
||||
- **ACTION**: Replace with C++17 structured bindings for cleaner, more readable code
|
||||
- **RESULT**: Create a pull request with the actual code changes
|
||||
- **RESULT**: Create an issue with the actual code changes
|
||||
- **Example**:
|
||||
```cpp
|
||||
// Before
|
||||
|
|
@ -630,9 +628,9 @@ Identify opportunities specific to Z3's architecture and coding patterns:
|
|||
|
||||
## Deliverables
|
||||
|
||||
### PRIMARY: Pull Request for std::optional Refactoring
|
||||
### PRIMARY: Issue for std::optional Refactoring
|
||||
|
||||
If you implement std::optional refactoring (following the workflow above), create a pull request using `output.create-pull-request` with:
|
||||
If you implement std::optional refactoring (following the workflow above), create an issue using `output.create-issue` with:
|
||||
- Clear title indicating what was refactored
|
||||
- Description of changes and benefits
|
||||
- List of modified files and functions
|
||||
|
|
@ -864,7 +862,7 @@ For each opportunity, provide:
|
|||
- **Incorrect std::move**: [Move from const, unnecessary moves]
|
||||
- **Return Value Optimization**: [Places where RVO is blocked]
|
||||
|
||||
### 4.8 Optional Value Pattern Modernization - **IMPLEMENT AS PULL REQUEST**
|
||||
### 4.8 Optional Value Pattern Modernization - **IMPLEMENT AS ISSUE**
|
||||
|
||||
**This is the PRIMARY focus area - implement these changes directly:**
|
||||
|
||||
|
|
@ -873,12 +871,12 @@ For each opportunity, provide:
|
|||
- **Action**: Use the "Workflow for std::optional Refactoring" section above to:
|
||||
1. Find candidate functions
|
||||
2. Refactor using the `edit` tool
|
||||
3. Create a pull request with your changes
|
||||
3. Create an issue with your changes
|
||||
- **API Improvements**: Specific function signatures to update
|
||||
- **Examples**: File:line references with before/after code
|
||||
- **Output**: Pull request (not just discussion)
|
||||
- **Output**: Issue (not just discussion)
|
||||
|
||||
### 4.9 Tuple Pattern (Structured Bindings) Modernization - **IMPLEMENT AS PULL REQUEST**
|
||||
### 4.9 Tuple Pattern (Structured Bindings) Modernization - **IMPLEMENT AS ISSUE**
|
||||
|
||||
**This is a SECONDARY focus area - implement these changes directly:**
|
||||
|
||||
|
|
@ -893,7 +891,7 @@ For each opportunity, provide:
|
|||
1. Search for patterns using `.first` and `.second`
|
||||
2. Identify cases where intermediate variable can be eliminated
|
||||
3. Refactor to use structured bindings
|
||||
4. Create a pull request with changes
|
||||
4. Create an issue with changes
|
||||
- **Example Pattern**:
|
||||
```cpp
|
||||
// Before: Using .first and .second
|
||||
|
|
@ -935,7 +933,7 @@ For each opportunity, provide:
|
|||
- Call `.first` and `.second` on the same variable multiple times
|
||||
- Create intermediate variables just to access pair members
|
||||
- Have sequential uses of both `.first` and `.second`
|
||||
- **Output**: Pull request with refactored code
|
||||
- **Output**: Issue with refactored code
|
||||
|
||||
### 4.10 Exception String Construction
|
||||
- **Current**: [stringstream usage for building exception messages]
|
||||
|
|
@ -949,7 +947,7 @@ For each opportunity, provide:
|
|||
- **Type Safety**: [How span improves API safety]
|
||||
- **Examples**: [Function signatures to update]
|
||||
|
||||
### 4.12 Array Parameter Modernization (std::initializer_list) - **IMPLEMENT AS PULL REQUEST**
|
||||
### 4.12 Array Parameter Modernization (std::initializer_list) - **IMPLEMENT AS ISSUE**
|
||||
|
||||
**This is a TERTIARY focus area - implement these changes directly:**
|
||||
|
||||
|
|
@ -964,7 +962,7 @@ For each opportunity, provide:
|
|||
1. Search for functions with `unsigned sz/size/num` + pointer parameters
|
||||
2. Identify functions where call sites use temporary arrays of constant size
|
||||
3. Refactor to use `std::initializer_list<T> const&`
|
||||
4. Create a pull request with changes
|
||||
4. Create an issue with changes
|
||||
- **Example Pattern**:
|
||||
```cpp
|
||||
// Before: Array + size parameters
|
||||
|
|
@ -998,7 +996,7 @@ For each opportunity, provide:
|
|||
- Have small, compile-time known array sizes
|
||||
- Are internal APIs (not part of public C interface)
|
||||
- Would benefit from simpler call syntax
|
||||
- **Output**: Pull request with refactored code
|
||||
- **Output**: Issue with refactored code
|
||||
- **Note**: Only apply to internal C++ APIs, not to public C API functions that need C compatibility
|
||||
|
||||
### 4.13 Increment Operator Patterns
|
||||
|
|
@ -1319,14 +1317,14 @@ grep pattern: "<<\s*\".*\"\s*<<\s*\".*\"" glob: "src/**/*.cpp"
|
|||
- Use `bash` only for safe operations (git, grep patterns)
|
||||
- **For std::optional refactoring**: Use the `edit` tool to modify files directly
|
||||
- **For other findings**: Create discussions only (no code modifications)
|
||||
- All code changes for std::optional will be reviewed through the PR process
|
||||
- All code changes for std::optional will be reviewed through the issue process
|
||||
|
||||
## Output Requirements
|
||||
|
||||
**Two types of outputs:**
|
||||
|
||||
1. **Pull Request** (for std::optional refactoring):
|
||||
- Use `output.create-pull-request` to create a PR
|
||||
1. **Issue** (for std::optional refactoring):
|
||||
- Use `output.create-issue` to create an issue
|
||||
- Include clear title and description
|
||||
- List all modified files
|
||||
- Explain the refactoring and its benefits
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue