diff --git a/.github/workflows/daily-function-namer.lock.yml b/.github/workflows/daily-function-namer.lock.yml index 99c872ace3c..688d7dcdf48 100644 --- a/.github/workflows/daily-function-namer.lock.yml +++ b/.github/workflows/daily-function-namer.lock.yml @@ -20,14 +20,14 @@ # # For more information: https://github.github.com/gh-aw/introduction/overview/ # -# Analyzes up to 3 Go files daily using Serena to extract function names and suggest renames that improve agent discoverability, using round-robin via cache-memory +# 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 # # Resolved workflow manifest: # Imports: # - shared/mcp/serena-go.md # - shared/reporting.md # -# gh-aw-metadata: {"schema_version":"v3","frontmatter_hash":"1a6466ede70a1acc29fec0024f6f6bb615a33432fc93c08c7eb36bea1bcfa648","strict":true,"agent_id":"claude"} +# gh-aw-metadata: {"schema_version":"v3","frontmatter_hash":"a85f10b6aae5ca037940831669d4eab46429191beb8ffd0ea4dc43d5473e2e41","strict":true,"agent_id":"claude"} name: "Daily Go Function Namer" "on": @@ -617,19 +617,7 @@ jobs: - name: Execute Claude Code CLI id: agentic_execution # Allowed tools (sorted): - # - Bash(cat) - # - Bash(date) - # - Bash(echo) - # - Bash(find pkg -name '*.go' ! -name '*_test.go' -type f | sort) - # - Bash(grep) - # - Bash(head) - # - Bash(ls) - # - Bash(pwd) - # - Bash(sort) - # - Bash(tail) - # - Bash(uniq) - # - Bash(wc) - # - Bash(yq) + # - Bash # - BashOutput # - Edit # - Edit(/tmp/gh-aw/cache-memory/*) @@ -706,7 +694,7 @@ jobs: touch /tmp/gh-aw/agent-step-summary.md # shellcheck disable=SC1003 sudo -E awf --tty --env-all --container-workdir "${GITHUB_WORKSPACE}" --mount "${RUNNER_TEMP}/gh-aw:${RUNNER_TEMP}/gh-aw:ro" --mount "${RUNNER_TEMP}/gh-aw:/host${RUNNER_TEMP}/gh-aw:ro" --allow-domains "*.githubusercontent.com,anthropic.com,api.anthropic.com,api.github.com,api.snapcraft.io,archive.ubuntu.com,azure.archive.ubuntu.com,cdn.playwright.dev,codeload.github.com,crl.geotrust.com,crl.globalsign.com,crl.identrust.com,crl.sectigo.com,crl.thawte.com,crl.usertrust.com,crl.verisign.com,crl3.digicert.com,crl4.digicert.com,crls.ssl.com,files.pythonhosted.org,ghcr.io,github-cloud.githubusercontent.com,github-cloud.s3.amazonaws.com,github.com,host.docker.internal,json-schema.org,json.schemastore.org,keyserver.ubuntu.com,lfs.github.com,objects.githubusercontent.com,ocsp.digicert.com,ocsp.geotrust.com,ocsp.globalsign.com,ocsp.identrust.com,ocsp.sectigo.com,ocsp.ssl.com,ocsp.thawte.com,ocsp.usertrust.com,ocsp.verisign.com,packagecloud.io,packages.cloud.google.com,packages.microsoft.com,playwright.download.prss.microsoft.com,ppa.launchpad.net,pypi.org,raw.githubusercontent.com,registry.npmjs.org,s.symcb.com,s.symcd.com,security.ubuntu.com,sentry.io,statsig.anthropic.com,ts-crl.ws.symantec.com,ts-ocsp.ws.symantec.com,www.googleapis.com" --log-level info --proxy-logs-dir /tmp/gh-aw/sandbox/firewall/logs --enable-host-access --image-tag 0.24.5 --skip-pull --enable-api-proxy \ - -- /bin/bash -c 'export PATH="$(find /opt/hostedtoolcache -maxdepth 4 -type d -name bin 2>/dev/null | tr '\''\n'\'' '\'':'\'')$PATH"; [ -n "$GOROOT" ] && export PATH="$GOROOT/bin:$PATH" || true && claude --print --disable-slash-commands --no-chrome --mcp-config /tmp/gh-aw/mcp-config/mcp-servers.json --allowed-tools '\''Bash(cat),Bash(date),Bash(echo),Bash(find pkg -name '\''\'\'''\''*.go'\''\'\'''\'' ! -name '\''\'\'''\''*_test.go'\''\'\'''\'' -type f | sort),Bash(grep),Bash(head),Bash(ls),Bash(pwd),Bash(sort),Bash(tail),Bash(uniq),Bash(wc),Bash(yq),BashOutput,Edit,Edit(/tmp/gh-aw/cache-memory/*),ExitPlanMode,Glob,Grep,KillBash,LS,MultiEdit,MultiEdit(/tmp/gh-aw/cache-memory/*),NotebookEdit,NotebookRead,Read,Read(/tmp/gh-aw/cache-memory/*),Task,TodoWrite,Write,Write(/tmp/gh-aw/cache-memory/*),mcp__github__download_workflow_run_artifact,mcp__github__get_code_scanning_alert,mcp__github__get_commit,mcp__github__get_dependabot_alert,mcp__github__get_discussion,mcp__github__get_discussion_comments,mcp__github__get_file_contents,mcp__github__get_job_logs,mcp__github__get_label,mcp__github__get_latest_release,mcp__github__get_me,mcp__github__get_notification_details,mcp__github__get_pull_request,mcp__github__get_pull_request_comments,mcp__github__get_pull_request_diff,mcp__github__get_pull_request_files,mcp__github__get_pull_request_review_comments,mcp__github__get_pull_request_reviews,mcp__github__get_pull_request_status,mcp__github__get_release_by_tag,mcp__github__get_secret_scanning_alert,mcp__github__get_tag,mcp__github__get_workflow_run,mcp__github__get_workflow_run_logs,mcp__github__get_workflow_run_usage,mcp__github__issue_read,mcp__github__list_branches,mcp__github__list_code_scanning_alerts,mcp__github__list_commits,mcp__github__list_dependabot_alerts,mcp__github__list_discussion_categories,mcp__github__list_discussions,mcp__github__list_issue_types,mcp__github__list_issues,mcp__github__list_label,mcp__github__list_notifications,mcp__github__list_pull_requests,mcp__github__list_releases,mcp__github__list_secret_scanning_alerts,mcp__github__list_starred_repositories,mcp__github__list_tags,mcp__github__list_workflow_jobs,mcp__github__list_workflow_run_artifacts,mcp__github__list_workflow_runs,mcp__github__list_workflows,mcp__github__pull_request_read,mcp__github__search_code,mcp__github__search_issues,mcp__github__search_orgs,mcp__github__search_pull_requests,mcp__github__search_repositories,mcp__github__search_users'\'' --debug-file /tmp/gh-aw/agent-stdio.log --verbose --permission-mode bypassPermissions --output-format stream-json "$(cat /tmp/gh-aw/aw-prompts/prompt.txt)"${GH_AW_MODEL_AGENT_CLAUDE:+ --model "$GH_AW_MODEL_AGENT_CLAUDE"}' 2>&1 | tee -a /tmp/gh-aw/agent-stdio.log + -- /bin/bash -c 'export PATH="$(find /opt/hostedtoolcache -maxdepth 4 -type d -name bin 2>/dev/null | tr '\''\n'\'' '\'':'\'')$PATH"; [ -n "$GOROOT" ] && export PATH="$GOROOT/bin:$PATH" || true && claude --print --disable-slash-commands --no-chrome --mcp-config /tmp/gh-aw/mcp-config/mcp-servers.json --allowed-tools '\''Bash,BashOutput,Edit,Edit(/tmp/gh-aw/cache-memory/*),ExitPlanMode,Glob,Grep,KillBash,LS,MultiEdit,MultiEdit(/tmp/gh-aw/cache-memory/*),NotebookEdit,NotebookRead,Read,Read(/tmp/gh-aw/cache-memory/*),Task,TodoWrite,Write,Write(/tmp/gh-aw/cache-memory/*),mcp__github__download_workflow_run_artifact,mcp__github__get_code_scanning_alert,mcp__github__get_commit,mcp__github__get_dependabot_alert,mcp__github__get_discussion,mcp__github__get_discussion_comments,mcp__github__get_file_contents,mcp__github__get_job_logs,mcp__github__get_label,mcp__github__get_latest_release,mcp__github__get_me,mcp__github__get_notification_details,mcp__github__get_pull_request,mcp__github__get_pull_request_comments,mcp__github__get_pull_request_diff,mcp__github__get_pull_request_files,mcp__github__get_pull_request_review_comments,mcp__github__get_pull_request_reviews,mcp__github__get_pull_request_status,mcp__github__get_release_by_tag,mcp__github__get_secret_scanning_alert,mcp__github__get_tag,mcp__github__get_workflow_run,mcp__github__get_workflow_run_logs,mcp__github__get_workflow_run_usage,mcp__github__issue_read,mcp__github__list_branches,mcp__github__list_code_scanning_alerts,mcp__github__list_commits,mcp__github__list_dependabot_alerts,mcp__github__list_discussion_categories,mcp__github__list_discussions,mcp__github__list_issue_types,mcp__github__list_issues,mcp__github__list_label,mcp__github__list_notifications,mcp__github__list_pull_requests,mcp__github__list_releases,mcp__github__list_secret_scanning_alerts,mcp__github__list_starred_repositories,mcp__github__list_tags,mcp__github__list_workflow_jobs,mcp__github__list_workflow_run_artifacts,mcp__github__list_workflow_runs,mcp__github__list_workflows,mcp__github__pull_request_read,mcp__github__search_code,mcp__github__search_issues,mcp__github__search_orgs,mcp__github__search_pull_requests,mcp__github__search_repositories,mcp__github__search_users'\'' --debug-file /tmp/gh-aw/agent-stdio.log --verbose --permission-mode bypassPermissions --output-format stream-json "$(cat /tmp/gh-aw/aw-prompts/prompt.txt)"${GH_AW_MODEL_AGENT_CLAUDE:+ --model "$GH_AW_MODEL_AGENT_CLAUDE"}' 2>&1 | tee -a /tmp/gh-aw/agent-stdio.log env: ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} BASH_DEFAULT_TIMEOUT_MS: 60000 @@ -881,7 +869,7 @@ jobs: uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 env: WORKFLOW_NAME: "Daily Go Function Namer" - WORKFLOW_DESCRIPTION: "Analyzes up to 3 Go files daily using Serena to extract function names and suggest renames that improve agent discoverability, using round-robin via cache-memory" + 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" HAS_PATCH: ${{ steps.collect_output.outputs.has_patch }} with: script: | diff --git a/.github/workflows/daily-function-namer.md b/.github/workflows/daily-function-namer.md index 1db8cd23cb9..73950818541 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 up to 3 Go files daily using Serena to extract function names and suggest renames that improve agent discoverability, using round-robin via cache-memory +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 on: schedule: daily workflow_dispatch: @@ -30,8 +30,7 @@ tools: cache-memory: true github: toolsets: [default, issues] - bash: - - "find pkg -name '*.go' ! -name '*_test.go' -type f | sort" + bash: true timeout-minutes: 30 strict: true @@ -43,7 +42,7 @@ You are an AI agent that analyzes Go functions daily to improve their names for ## Mission -Each day, analyze up to **3 Go source files** using round-robin rotation across all non-test Go files in `pkg/`. For each file: +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: 1. Extract all function and method names using Serena 2. Evaluate each name's clarity and intent @@ -57,52 +56,71 @@ Each day, analyze up to **3 Go source files** using round-robin rotation across - **Workspace**: ${{ github.workspace }} - **Cache**: `/tmp/gh-aw/cache-memory/` -## Step 1: Load Round-Robin State from Cache +## Step 1: Compute File Selection with Code -Read the current rotation position from cache: +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: ```bash -cat /tmp/gh-aw/cache-memory/function-namer-state.json +# Load last_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)) + 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}" +echo "total_functions_approx=${TOTAL_FNS}" +echo "--- selected files ---" +printf '%s\n' "${SELECTED[@]}" ``` -Expected format: +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 ---`) -```json -{ - "last_index": 0, - "analyzed_files": [ - {"file": "pkg/workflow/compiler.go", "analyzed_at": "2026-03-12"} - ] -} -``` - -All file paths are relative to the repository root (e.g., `pkg/workflow/compiler.go`), -matching the output of the `find pkg` command in Step 3. - -If the cache file does not exist or is empty, start fresh with `last_index = 0` and an -empty `analyzed_files` list. - -## Step 2: Get All Go Files - -Enumerate all non-test Go source files in sorted order: +Use these values directly for the rest of the workflow. Do **not** re-derive or re-compute them manually. -```bash -find pkg -name '*.go' ! -name '*_test.go' -type f | sort -``` - -Record the total file count for wrap-around calculations. - -## Step 3: Select the Next 3 Files - -Using `last_index` from the cache: - -- Select files at positions `last_index`, `last_index + 1`, `last_index + 2` -- Wrap around using modulo: `index % total_files` -- Example: If there are 50 files and `last_index` is 49, select indices 49, 0, 1 - -The new `last_index` for the next run is `(last_index + 3) % total_files`. - -## Step 4: Activate Serena +## Step 2: Activate Serena Activate the Serena project to enable Go semantic analysis: @@ -111,11 +129,11 @@ Tool: activate_project Args: { "path": "${{ github.workspace }}" } ``` -## Step 5: Analyze Each File with Serena +## Step 3: Analyze Each Selected File with Serena -For each of the 3 selected files, perform a full function name analysis. +For each of the selected files output by Step 1, perform a full function name analysis. -### 5.1 Get All Symbols +### 3.1 Get All Symbols ``` Tool: get_symbols_overview @@ -124,9 +142,9 @@ Args: { "file_path": "" } This returns all functions, methods, and types defined in the file. -### 5.2 Read Function Implementations +### 3.2 Read Function Implementations -For each function identified in 6.1, read enough of the implementation to understand its behavior: +For each function identified in 3.1, read enough of the implementation to understand its behavior: ``` Tool: read_file @@ -139,7 +157,7 @@ For small files you may read the entire file: cat ``` -### 5.3 Evaluate Function Names +### 3.3 Evaluate Function Names For each function, assess its name against these criteria: @@ -156,7 +174,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 -### 5.4 Propose Renames +### 3.4 Propose Renames For each function that would benefit from a clearer name: @@ -180,9 +198,9 @@ 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 6: Update Cache State +## Step 4: Update Cache State -After completing the analysis, save the updated round-robin position. Use a filesystem-safe timestamp format (`YYYY-MM-DD` is fine for daily granularity): +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`): ```bash cat > /tmp/gh-aw/cache-memory/function-namer-state.json << 'CACHE_EOF' @@ -191,41 +209,43 @@ cat > /tmp/gh-aw/cache-memory/function-namer-state.json << 'CACHE_EOF' "analyzed_files": [ , {"file": "pkg/workflow/compiler.go", "analyzed_at": "2026-03-13"}, - {"file": "pkg/workflow/cache.go", "analyzed_at": "2026-03-13"}, - {"file": "pkg/workflow/mcp_renderer.go", "analyzed_at": "2026-03-13"} + {"file": "pkg/workflow/cache.go", "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. + Use relative paths (e.g., `pkg/workflow/compiler.go`) matching the output of the `find pkg` command. Prune `analyzed_files` to the most recent 90 entries to prevent unbounded growth. -## Step 7: Create Issue with Agentic Plan +## Step 5: Create Issue with Agentic Plan -If any rename suggestions were found across the 3 files, create a GitHub issue. +If any rename suggestions were found across the analyzed files, 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 , …, . 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: compiler.go, cache.go, mcp_renderer.go`) **Body**: ```markdown # 🏷️ Go Function Rename Plan -**Files Analyzed**: ``, ``, `` +**Files Analyzed**: ``, ``, … **Analysis Date**: **Round-Robin Position**: files of total +**Function Budget**: functions across files ### Why This Matters @@ -249,9 +269,9 @@ that an agent will find the right function instead of reimplementing existing lo -#### `` +#### `` - + --- @@ -373,5 +393,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 , …, . All analyzed functions already have clear, descriptive names that support agent discoverability."}} ```