From 87e76100330f9d6cf036bbb3a1c32c3ef40e2278 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 3 May 2026 20:08:10 +0000 Subject: [PATCH 1/2] fix: on cache miss, pick random starting item instead of always first Update three workflows that use cache-memory with round-robin rotation so that a cold start (absent or empty cache) selects a random position in the list rather than always starting at the same fixed item: - daily-function-namer: output -1 sentinel when cache is missing, then resolve to $(( RANDOM % TOTAL )) after package list is built - daily-caveman-optimizer: instruct agent to use $(( RANDOM % total_files )) for the initial index on cold start - slide-deck-maintainer: use shuf -n1 to randomly pick the first category instead of always beginning with 'documentation' Agent-Logs-Url: https://github.com/github/gh-aw/sessions/e7394ac9-64c9-4b1b-beab-c53cab5e68ca Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- .github/workflows/daily-caveman-optimizer.md | 4 ++-- .github/workflows/daily-function-namer.md | 14 ++++++++++---- .github/workflows/slide-deck-maintainer.md | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/workflows/daily-caveman-optimizer.md b/.github/workflows/daily-caveman-optimizer.md index db8fc579ca8..1fcc2804040 100644 --- a/.github/workflows/daily-caveman-optimizer.md +++ b/.github/workflows/daily-caveman-optimizer.md @@ -118,8 +118,8 @@ Expected format: } ``` -- If the file does not exist, start at index 0. -- If the queue in cache differs from the current file list (files added/removed), rebuild the queue from the current sorted list and reset index to 0. +- If the file does not exist, count the total number of files in the sorted list and pick a **random** starting index with `$(( RANDOM % total_files ))`. This avoids always processing the same files first when the cache is cold. +- If the queue in cache differs from the current file list (files added/removed), rebuild the queue from the current sorted list and reset the index to 0. - Pick the **next 5 files** starting from `last_processed_index + 1` (wrapping around if needed). This is your **batch** for this run. ## Step 3: Analyze and Optimize Each File diff --git a/.github/workflows/daily-function-namer.md b/.github/workflows/daily-function-namer.md index 1c5d1389320..e2fa7a801e2 100644 --- a/.github/workflows/daily-function-namer.md +++ b/.github/workflows/daily-function-namer.md @@ -67,24 +67,30 @@ Each day, analyze **one entire Go package** using round-robin rotation across al 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_package_index from cache (default 0 if cache absent/empty) +# Load last_package_index from cache (-1 sentinel means cache is absent/empty — pick randomly later) 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_package_index', 0)) + print(d.get('last_package_index', -1)) except Exception: - print(0) + print(-1) else: - print(0) + print(-1) ") # 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[@]} +# On cache miss, start at a random position so repeated cold starts don't always hit the same package +if [ "$LAST_INDEX" -eq -1 ]; then + LAST_INDEX=$(( RANDOM % TOTAL )) + echo "cache_miss=true (random start at index ${LAST_INDEX})" +fi + echo "total_packages=${TOTAL}" echo "last_package_index=${LAST_INDEX}" diff --git a/.github/workflows/slide-deck-maintainer.md b/.github/workflows/slide-deck-maintainer.md index 913e941d62e..d91c5368219 100644 --- a/.github/workflows/slide-deck-maintainer.md +++ b/.github/workflows/slide-deck-maintainer.md @@ -164,7 +164,7 @@ else fi ``` -**If the file does NOT exist** (first run or cold cache): start with category `documentation`. +**If the file does NOT exist** (first run or cold cache): randomly pick a starting category using `shuf -n1 -e source-code agentic-workflows documentation` (or equivalent) so that repeated cold starts don't always begin with the same category. **If the file exists**, read it and extract `last_category` to determine the next category using round-robin: - `source-code` → next is `agentic-workflows` From 726b0402d7a954b3fb972ccf589679f993973165 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 3 May 2026 20:09:32 +0000 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20address=20code=20review=20=E2=80=94?= =?UTF-8?q?=20guard=20TOTAL=3D0=20and=20clarify=20variable=20name?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Agent-Logs-Url: https://github.com/github/gh-aw/sessions/e7394ac9-64c9-4b1b-beab-c53cab5e68ca Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- .github/workflows/daily-caveman-optimizer.md | 2 +- .github/workflows/daily-function-namer.md | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/daily-caveman-optimizer.md b/.github/workflows/daily-caveman-optimizer.md index 1fcc2804040..e6751b0fa60 100644 --- a/.github/workflows/daily-caveman-optimizer.md +++ b/.github/workflows/daily-caveman-optimizer.md @@ -118,7 +118,7 @@ Expected format: } ``` -- If the file does not exist, count the total number of files in the sorted list and pick a **random** starting index with `$(( RANDOM % total_files ))`. This avoids always processing the same files first when the cache is cold. +- If the file does not exist, count the total number of files in the sorted list (`TOTAL=$(...)`) and pick a **random** starting index with `$(( RANDOM % TOTAL ))`. This avoids always processing the same files first when the cache is cold. - If the queue in cache differs from the current file list (files added/removed), rebuild the queue from the current sorted list and reset the index to 0. - Pick the **next 5 files** starting from `last_processed_index + 1` (wrapping around if needed). This is your **batch** for this run. diff --git a/.github/workflows/daily-function-namer.md b/.github/workflows/daily-function-namer.md index e2fa7a801e2..c77c128c182 100644 --- a/.github/workflows/daily-function-namer.md +++ b/.github/workflows/daily-function-namer.md @@ -85,6 +85,11 @@ else: mapfile -t ALL_PKGS < <(find pkg -name '*.go' ! -name '*_test.go' -type f | xargs -I{} dirname {} | sort -u) TOTAL=${#ALL_PKGS[@]} +if [ "$TOTAL" -eq 0 ]; then + echo "ERROR: no Go packages found in pkg/" >&2 + exit 1 +fi + # On cache miss, start at a random position so repeated cold starts don't always hit the same package if [ "$LAST_INDEX" -eq -1 ]; then LAST_INDEX=$(( RANDOM % TOTAL ))