diff --git a/.github/workflows/daily-function-namer.lock.yml b/.github/workflows/daily-function-namer.lock.yml index 9420cf253ec..bab9efe7339 100644 --- a/.github/workflows/daily-function-namer.lock.yml +++ b/.github/workflows/daily-function-namer.lock.yml @@ -1,4 +1,4 @@ -# gh-aw-metadata: {"schema_version":"v3","frontmatter_hash":"e794fc73524932edc2c34e2dc4f908fe6bf3cd373d985d08a5739d2b39bc6372","strict":true,"agent_id":"claude"} +# gh-aw-metadata: {"schema_version":"v3","frontmatter_hash":"cf0bcd99e4073ea1a5db640e635e6ec21c31ac21bb06e2bbc5147173b3725549","strict":true,"agent_id":"claude"} # gh-aw-manifest: {"version":1,"secrets":["ANTHROPIC_API_KEY","GH_AW_GITHUB_MCP_SERVER_TOKEN","GH_AW_GITHUB_TOKEN","GH_AW_OTEL_ENDPOINT","GH_AW_OTEL_HEADERS","GITHUB_TOKEN"],"actions":[{"repo":"actions/cache/restore","sha":"27d5ce7f107fe9357f9df03efb73ab90386fccae","version":"v5.0.5"},{"repo":"actions/cache/save","sha":"27d5ce7f107fe9357f9df03efb73ab90386fccae","version":"v5.0.5"},{"repo":"actions/checkout","sha":"de0fac2e4500dabe0009e67214ff5f5447ce83dd","version":"v6.0.2"},{"repo":"actions/download-artifact","sha":"3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c","version":"v8.0.1"},{"repo":"actions/github-script","sha":"373c709c69115d41ff229c7e5df9f8788daa9553","version":"v9"},{"repo":"actions/setup-node","sha":"53b83947a5a98c8d113130e565377fae1a50d02f","version":"v6.3.0"},{"repo":"actions/upload-artifact","sha":"043fb46d1a93c77aae656e7c1c64a875d1fc6a0a","version":"v7.0.1"}],"containers":[{"image":"ghcr.io/github/gh-aw-firewall/agent:0.25.20","digest":"sha256:9161f2415a3306a344aca34dd671ee69f122317e0a512e66dc64c94b9c508682","pinned_image":"ghcr.io/github/gh-aw-firewall/agent:0.25.20@sha256:9161f2415a3306a344aca34dd671ee69f122317e0a512e66dc64c94b9c508682"},{"image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.25.20","digest":"sha256:6971639e381e82e45134bcd333181f456df3a52cd6f818a3e3d6de068ff91519","pinned_image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.25.20@sha256:6971639e381e82e45134bcd333181f456df3a52cd6f818a3e3d6de068ff91519"},{"image":"ghcr.io/github/gh-aw-firewall/squid:0.25.20","digest":"sha256:5411d903f73ee597e6a084971c2adef3eb0bd405910df3ed7bf5e3d6bd58a236","pinned_image":"ghcr.io/github/gh-aw-firewall/squid:0.25.20@sha256:5411d903f73ee597e6a084971c2adef3eb0bd405910df3ed7bf5e3d6bd58a236"},{"image":"ghcr.io/github/gh-aw-mcpg:v0.2.19","digest":"sha256:44d4d8de7e6c37aaea484eba489940c52df6a0b54078ddcbc9327592d5b3c3dd","pinned_image":"ghcr.io/github/gh-aw-mcpg:v0.2.19@sha256:44d4d8de7e6c37aaea484eba489940c52df6a0b54078ddcbc9327592d5b3c3dd"},{"image":"ghcr.io/github/github-mcp-server:v0.32.0","digest":"sha256:2763823c63bcca718ce53850a1d7fcf2f501ec84028394f1b63ce7e9f4f9be28","pinned_image":"ghcr.io/github/github-mcp-server:v0.32.0@sha256:2763823c63bcca718ce53850a1d7fcf2f501ec84028394f1b63ce7e9f4f9be28"},{"image":"ghcr.io/github/serena-mcp-server:latest","digest":"sha256:bf343399e3725c45528f531a230f3a04521d4cdef29f9a5af6282ff0d3c393c5","pinned_image":"ghcr.io/github/serena-mcp-server:latest@sha256:bf343399e3725c45528f531a230f3a04521d4cdef29f9a5af6282ff0d3c393c5"},{"image":"node:lts-alpine","digest":"sha256:01743339035a5c3c11a373cd7c83aeab6ed1457b55da6a69e014a95ac4e4700b","pinned_image":"node:lts-alpine@sha256:01743339035a5c3c11a373cd7c83aeab6ed1457b55da6a69e014a95ac4e4700b"}]} # ___ _ _ # / _ \ | | (_) @@ -22,7 +22,7 @@ # # For more information: https://github.github.com/gh-aw/introduction/overview/ # -# Analyzes Go files daily using Serena to extract function names and suggest renames that improve agent discoverability, using round-robin via cache-memory with a dynamic function budget +# Analyzes one entire Go package per day using Serena to extract function names and suggest renames that improve agent discoverability, using round-robin over package directories via cache-memory # # Resolved workflow manifest: # Imports: @@ -180,15 +180,15 @@ jobs: run: | bash "${RUNNER_TEMP}/gh-aw/actions/create_prompt_first.sh" { - cat << 'GH_AW_PROMPT_bbaf0a41abe69941_EOF' + cat << 'GH_AW_PROMPT_fd7e942f71b80d9f_EOF' - GH_AW_PROMPT_bbaf0a41abe69941_EOF + GH_AW_PROMPT_fd7e942f71b80d9f_EOF cat "${RUNNER_TEMP}/gh-aw/prompts/xpia.md" cat "${RUNNER_TEMP}/gh-aw/prompts/temp_folder_prompt.md" cat "${RUNNER_TEMP}/gh-aw/prompts/markdown.md" cat "${RUNNER_TEMP}/gh-aw/prompts/cache_memory_prompt.md" cat "${RUNNER_TEMP}/gh-aw/prompts/safe_outputs_prompt.md" - cat << 'GH_AW_PROMPT_bbaf0a41abe69941_EOF' + cat << 'GH_AW_PROMPT_fd7e942f71b80d9f_EOF' Tools: create_issue, missing_tool, missing_data, noop @@ -220,9 +220,9 @@ jobs: {{/if}} - GH_AW_PROMPT_bbaf0a41abe69941_EOF + GH_AW_PROMPT_fd7e942f71b80d9f_EOF cat "${RUNNER_TEMP}/gh-aw/prompts/github_mcp_tools_with_safeoutputs_prompt.md" - cat << 'GH_AW_PROMPT_bbaf0a41abe69941_EOF' + cat << 'GH_AW_PROMPT_fd7e942f71b80d9f_EOF' ## Serena Code Analysis @@ -259,7 +259,7 @@ jobs: {{#runtime-import .github/workflows/shared/mcp/serena-go.md}} {{#runtime-import .github/workflows/shared/observability-otlp.md}} {{#runtime-import .github/workflows/daily-function-namer.md}} - GH_AW_PROMPT_bbaf0a41abe69941_EOF + GH_AW_PROMPT_fd7e942f71b80d9f_EOF } > "$GH_AW_PROMPT" - name: Interpolate variables and render templates uses: actions/github-script@373c709c69115d41ff229c7e5df9f8788daa9553 # v9 @@ -462,9 +462,9 @@ jobs: mkdir -p "${RUNNER_TEMP}/gh-aw/safeoutputs" mkdir -p /tmp/gh-aw/safeoutputs mkdir -p /tmp/gh-aw/mcp-logs/safeoutputs - cat > "${RUNNER_TEMP}/gh-aw/safeoutputs/config.json" << 'GH_AW_SAFE_OUTPUTS_CONFIG_b78f75d0195a967a_EOF' + cat > "${RUNNER_TEMP}/gh-aw/safeoutputs/config.json" << 'GH_AW_SAFE_OUTPUTS_CONFIG_8aa116dac43f3d06_EOF' {"create_issue":{"close_older_issues":true,"expires":168,"labels":["refactoring","code-quality","automated-analysis","cookie"],"max":1,"title_prefix":"[function-namer] "},"create_report_incomplete_issue":{},"missing_data":{},"missing_tool":{},"noop":{"max":1,"report-as-issue":"true"},"report_incomplete":{}} - GH_AW_SAFE_OUTPUTS_CONFIG_b78f75d0195a967a_EOF + GH_AW_SAFE_OUTPUTS_CONFIG_8aa116dac43f3d06_EOF - name: Write Safe Outputs Tools env: GH_AW_TOOLS_META_JSON: | @@ -658,7 +658,7 @@ jobs: export GH_AW_ENGINE="claude" export MCP_GATEWAY_DOCKER_COMMAND='docker run -i --rm --network host -v /var/run/docker.sock:/var/run/docker.sock -e MCP_GATEWAY_PORT -e MCP_GATEWAY_DOMAIN -e MCP_GATEWAY_API_KEY -e MCP_GATEWAY_PAYLOAD_DIR -e MCP_GATEWAY_PAYLOAD_SIZE_THRESHOLD -e DEBUG -e MCP_GATEWAY_LOG_DIR -e GH_AW_MCP_LOG_DIR -e GH_AW_SAFE_OUTPUTS -e GH_AW_SAFE_OUTPUTS_CONFIG_PATH -e GH_AW_SAFE_OUTPUTS_TOOLS_PATH -e GH_AW_ASSETS_BRANCH -e GH_AW_ASSETS_MAX_SIZE_KB -e GH_AW_ASSETS_ALLOWED_EXTS -e DEFAULT_BRANCH -e GITHUB_MCP_SERVER_TOKEN -e GITHUB_MCP_GUARD_MIN_INTEGRITY -e GITHUB_MCP_GUARD_REPOS -e GITHUB_REPOSITORY -e GITHUB_SERVER_URL -e GITHUB_SHA -e GITHUB_WORKSPACE -e GITHUB_TOKEN -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RUN_ATTEMPT -e GITHUB_JOB -e GITHUB_ACTION -e GITHUB_EVENT_NAME -e GITHUB_EVENT_PATH -e GITHUB_ACTOR -e GITHUB_ACTOR_ID -e GITHUB_TRIGGERING_ACTOR -e GITHUB_WORKFLOW -e GITHUB_WORKFLOW_REF -e GITHUB_WORKFLOW_SHA -e GITHUB_REF -e GITHUB_REF_NAME -e GITHUB_REF_TYPE -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GH_AW_SAFE_OUTPUTS_PORT -e GH_AW_SAFE_OUTPUTS_API_KEY -e GITHUB_AW_OTEL_TRACE_ID -e GITHUB_AW_OTEL_PARENT_SPAN_ID -v /tmp/gh-aw/mcp-payloads:/tmp/gh-aw/mcp-payloads:rw -v /opt:/opt:ro -v /tmp:/tmp:rw -v '"${GITHUB_WORKSPACE}"':'"${GITHUB_WORKSPACE}"':rw ghcr.io/github/gh-aw-mcpg:v0.2.19' - cat << GH_AW_MCP_CONFIG_8c2d9b448c03b00c_EOF | bash "${RUNNER_TEMP}/gh-aw/actions/start_mcp_gateway.sh" + cat << GH_AW_MCP_CONFIG_e30fe7016587f8f9_EOF | bash "${RUNNER_TEMP}/gh-aw/actions/start_mcp_gateway.sh" { "mcpServers": { "github": { @@ -730,7 +730,7 @@ jobs: } } } - GH_AW_MCP_CONFIG_8c2d9b448c03b00c_EOF + GH_AW_MCP_CONFIG_e30fe7016587f8f9_EOF - name: Download activation artifact uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: @@ -1236,7 +1236,7 @@ jobs: uses: actions/github-script@373c709c69115d41ff229c7e5df9f8788daa9553 # v9 env: WORKFLOW_NAME: "Daily Go Function Namer" - WORKFLOW_DESCRIPTION: "Analyzes Go files daily using Serena to extract function names and suggest renames that improve agent discoverability, using round-robin via cache-memory with a dynamic function budget" + WORKFLOW_DESCRIPTION: "Analyzes one entire Go package per day using Serena to extract function names and suggest renames that improve agent discoverability, using round-robin over package directories via cache-memory" HAS_PATCH: ${{ needs.agent.outputs.has_patch }} with: script: | diff --git a/.github/workflows/daily-function-namer.md b/.github/workflows/daily-function-namer.md index 1fa7995b6e3..6386933004a 100644 --- a/.github/workflows/daily-function-namer.md +++ b/.github/workflows/daily-function-namer.md @@ -1,6 +1,6 @@ --- name: Daily Go Function Namer -description: Analyzes Go files daily using Serena to extract function names and suggest renames that improve agent discoverability, using round-robin via cache-memory with a dynamic function budget +description: Analyzes one entire Go package per day using Serena to extract function names and suggest renames that improve agent discoverability, using round-robin over package directories via cache-memory on: schedule: daily workflow_dispatch: @@ -43,12 +43,13 @@ You are an AI agent that analyzes Go functions daily to improve their names for ## Mission -Each day, analyze up to **6 Go source files** using round-robin rotation across all non-test Go files in `pkg/`, driven by a **dynamic function budget** of 25 functions per run. For each file: +Each day, analyze **one entire Go package** using round-robin rotation across all package directories in `pkg/`. For each package: -1. Extract all function and method names using Serena -2. Evaluate each name's clarity and intent -3. Suggest renames that are clearer and more intuitive for agents -4. Create a GitHub issue with a concrete agentic implementation plan +1. Enumerate all functions in the package with a fast `grep` sweep +2. Activate Serena for deeper semantic analysis of functions that need it +3. Evaluate each name's clarity and intent +4. Suggest renames that are clearer and more intuitive for agents +5. Create a GitHub issue with a concrete agentic implementation plan ## Context @@ -57,71 +58,74 @@ Each day, analyze up to **6 Go source files** using round-robin rotation across - **Workspace**: ${{ github.workspace }} - **Cache**: `/tmp/gh-aw/cache-memory/` -## Step 1: Compute File Selection with Code +## Step 1: Compute Package Selection with Code -Run this script to load the round-robin state, enumerate all Go files, and compute which files to analyze this run using the dynamic function budget: +Run this script to load the round-robin state, enumerate all Go package directories, and compute which package to analyze this run: ```bash -# Load last_index from cache (default 0 if cache absent/empty) +# Load last_package_index from cache (default 0 if cache absent/empty) LAST_INDEX=$(python3 -c " import sys, json, os p = '/tmp/gh-aw/cache-memory/function-namer-state.json' if os.path.exists(p): try: d = json.load(open(p)) - print(d.get('last_index', 0)) + print(d.get('last_package_index', 0)) except Exception: print(0) else: print(0) ") -# Enumerate all non-test Go source files in sorted order -mapfile -t ALL_FILES < <(find pkg -name '*.go' ! -name '*_test.go' -type f | sort) -TOTAL=${#ALL_FILES[@]} - -echo "total_files=${TOTAL}" -echo "last_index=${LAST_INDEX}" - -# Greedy selection: up to 8 candidates, budget=25 functions, cap=6 files -SELECTED=() -TOTAL_FNS=0 -BUDGET=25 -CAP=6 - -for i in $(seq 0 7); do - if [ ${#SELECTED[@]} -ge $CAP ]; then - break - fi - idx=$(( (LAST_INDEX + i) % TOTAL )) - f="${ALL_FILES[$idx]}" - COUNT=$(grep -c "^func " "$f" 2>/dev/null || echo 0) - SELECTED+=("$f") - TOTAL_FNS=$((TOTAL_FNS + COUNT)) - if [ $TOTAL_FNS -ge $BUDGET ]; then - break - fi -done - -SELECTED_COUNT=${#SELECTED[@]} -NEW_INDEX=$(( (LAST_INDEX + SELECTED_COUNT) % TOTAL )) - -echo "selected_count=${SELECTED_COUNT}" -echo "new_last_index=${NEW_INDEX}" +# Enumerate all unique package directories containing non-test Go files +mapfile -t ALL_PKGS < <(find pkg -name '*.go' ! -name '*_test.go' -type f | xargs -I{} dirname {} | sort -u) +TOTAL=${#ALL_PKGS[@]} + +echo "total_packages=${TOTAL}" +echo "last_package_index=${LAST_INDEX}" + +# Pick the next package in round-robin order +PKG_DIR="${ALL_PKGS[$(( LAST_INDEX % TOTAL ))]}" +NEW_INDEX=$(( (LAST_INDEX + 1) % TOTAL )) + +# Collect all non-test Go files in the selected package +mapfile -t PKG_FILES < <(find "$PKG_DIR" -maxdepth 1 -name '*.go' ! -name '*_test.go' -type f | sort) +FILE_COUNT=${#PKG_FILES[@]} +if [ "$FILE_COUNT" -gt 0 ]; then + TOTAL_FNS=$(grep -hc "^func " "${PKG_FILES[@]}" 2>/dev/null | awk '{s+=$1} END {print s+0}') +else + TOTAL_FNS=0 +fi + +echo "selected_package=${PKG_DIR}" +echo "file_count=${FILE_COUNT}" +echo "new_last_package_index=${NEW_INDEX}" echo "total_functions_approx=${TOTAL_FNS}" echo "--- selected files ---" -printf '%s\n' "${SELECTED[@]}" +printf '%s\n' "${PKG_FILES[@]}" ``` The script outputs: -- `selected_count` — number of files to analyze this run (1–6) -- `new_last_index` — value to write back to cache after the run -- `total_functions_approx` — estimated function count across selected files -- The list of selected file paths (one per line, after `--- selected files ---`) +- `selected_package` — the package directory to analyze this run +- `file_count` — number of Go files in the selected package +- `new_last_package_index` — value to write back to cache after the run +- `total_functions_approx` — total function count across the package files +- The list of package file paths (one per line, after `--- selected files ---`) Use these values directly for the rest of the workflow. Do **not** re-derive or re-compute them manually. -## Step 2: Activate Serena +## Step 2: Enumerate All Functions in the Package + +Before invoking Serena, run a fast `grep` sweep across all files in the selected package to build a complete function inventory. This minimizes Serena tool calls by giving you the full picture upfront: + +```bash +# Fast enumeration — one pass over all package files +grep -n "^func " "${PKG_FILES[@]}" | awk -F: '{printf "%-50s line %-5s %s\n", $1, $2, $3}' +``` + +This produces a list of every function/method definition with its file and line number. Use this inventory to decide which functions need deeper Serena analysis. + +## Step 3: Activate Serena Activate the Serena project to enable Go semantic analysis: @@ -130,11 +134,11 @@ Tool: activate_project Args: { "path": "${{ github.workspace }}" } ``` -## Step 3: Analyze Each Selected File with Serena +## Step 4: Analyze Each File in the Package with Serena -For each of the selected files output by Step 1, perform a full function name analysis. +For each of the files in the selected package (output by Step 1), perform a full function name analysis. Use the function inventory from Step 2 to guide which functions need deeper Serena investigation. -### 3.1 Get All Symbols +### 4.1 Get All Symbols ``` Tool: get_symbols_overview @@ -143,9 +147,9 @@ Args: { "file_path": "" } This returns all functions, methods, and types defined in the file. -### 3.2 Read Function Implementations +### 4.2 Read Function Implementations -For each function identified in 3.1, read enough of the implementation to understand its behavior: +For each function identified in 4.1, read enough of the implementation to understand its behavior: ``` Tool: read_file @@ -158,7 +162,7 @@ For small files you may read the entire file: cat ``` -### 3.3 Evaluate Function Names +### 4.3 Evaluate Function Names For each function, assess its name against these criteria: @@ -175,7 +179,7 @@ For each function, assess its name against these criteria: - Constructors following Go convention: `NewCompiler()`, `NewMCPConfig()` - Short unexported names used as closures or immediately-invoked helpers -### 3.4 Propose Renames +### 4.4 Propose Renames For each function that would benefit from a clearer name: @@ -199,60 +203,61 @@ Args: { "symbol_name": "", "file_path": "pkg/..." } **Only suggest renames where the improvement is clear and meaningful.** Quality over quantity — two well-justified suggestions are better than ten marginal ones. -## Step 4: Update Cache State +## Step 5: Update Cache State -After completing the analysis, save the updated round-robin position. Use the `new_last_index` value from Step 1 and a filesystem-safe timestamp (`YYYY-MM-DD`): +After completing the analysis, save the updated round-robin position. Use the `new_last_package_index` value from Step 1 and a filesystem-safe timestamp (`YYYY-MM-DD`): ```bash cat > /tmp/gh-aw/cache-memory/function-namer-state.json << 'CACHE_EOF' { - "last_index": , - "analyzed_files": [ - , - {"file": "pkg/workflow/compiler.go", "analyzed_at": "2026-03-13"}, - {"file": "pkg/workflow/cache.go", "analyzed_at": "2026-03-13"} + "last_package_index": , + "analyzed_packages": [ + , + {"package": "pkg/workflow", "analyzed_at": "2026-03-13"} ] } CACHE_EOF ``` -Where `` is the `new_last_index` value output by Step 1, and the `analyzed_files` list contains one entry per file actually analyzed. +Where `` is the `new_last_package_index` value output by Step 1, and the `analyzed_packages` list contains one entry per package actually analyzed. -Use relative paths (e.g., `pkg/workflow/compiler.go`) matching the output of the `find pkg` command. +Use relative paths (e.g., `pkg/workflow`) matching the output of the `find pkg` command. -Prune `analyzed_files` to the most recent 90 entries to prevent unbounded growth. +Prune `analyzed_packages` to the most recent 30 entries to prevent unbounded growth. -## Step 5: Create Issue with Agentic Plan +## Step 6: Create Issue with Agentic Plan -If any rename suggestions were found across the analyzed files, create a GitHub issue. +If any rename suggestions were found across the analyzed package, create a GitHub issue. If **no improvements were found**, emit `noop` and exit: ```json -{"noop": {"message": "No rename suggestions found for , …, . All analyzed functions have clear, descriptive names."}} +{"noop": {"message": "No rename suggestions found for package . All analyzed functions have clear, descriptive names."}} ``` Otherwise, create an issue with this structure: --- -**Title**: `Go function rename plan: , , …` (e.g., `Go function rename plan: compiler.go, cache.go, mcp_renderer.go`) +**Title**: `Go function rename plan: ` (e.g., `Go function rename plan: pkg/workflow`) **Body**: ```markdown # 🏷️ Go Function Rename Plan -**Files Analyzed**: ``, ``, … +**Package Analyzed**: `` **Analysis Date**: -**Round-Robin Position**: files of total -**Function Budget**: functions across files +**Round-Robin Position**: package of total packages +**Functions Analyzed**: functions across files ### Why This Matters When AI coding agents search for functions to complete a task, they rely on function names to understand what code does. Clear, descriptive names increase the likelihood that an agent will find the right function instead of reimplementing existing logic. +Functions in the same package also call each other, so reviewing them together gives +better context for rename decisions. ### Rename Suggestions @@ -272,7 +277,7 @@ that an agent will find the right function instead of reimplementing existing lo #### `` - + --- @@ -394,5 +399,5 @@ Only include a rename suggestion if you are confident it would measurably improv **Important**: If no action is needed after completing your analysis, you **MUST** call the `noop` safe-output tool. Failing to call any safe-output tool is the most common cause of workflow failures. ```json -{"noop": {"message": "No rename suggestions found for , …, . All analyzed functions already have clear, descriptive names that support agent discoverability."}} +{"noop": {"message": "No rename suggestions found for package . All analyzed functions already have clear, descriptive names that support agent discoverability."}} ```