diff --git a/.github/workflows/public_platform-tests-claude-investigate-and-fix.yaml b/.github/workflows/public_platform-tests-claude-investigate-and-fix.yaml index 36ccee3..0e88aa7 100644 --- a/.github/workflows/public_platform-tests-claude-investigate-and-fix.yaml +++ b/.github/workflows/public_platform-tests-claude-investigate-and-fix.yaml @@ -1,25 +1,16 @@ -name: 'Platform tests: Claude failure investigation and fix' +name: 'Platform tests: Claude failure investigation' # Notion page docs: https://app.notion.com/p/apify/374f39950a2280d99c89f27fc9fb49c5 -# Reusable workflow that uses Claude Code to investigate a failing E2E platform test and -# attempt an automated fix. +# Reusable workflow that uses Claude Code to investigate a failing E2E platform test. # -# Two-phase execution: -# 1. investigate: Claude reviews test logs, recent workflow history, and existing issues, -# then opens a GitHub issue with its findings. Skips silently if a duplicate exists. -# On success, adds a "claude" label to the issue for visibility. -# 2. fix: Runs only when investigate created a new issue. Claude reads the issue, -# implements a fix, and opens a PR. On success, adds a "claude:done" label to the issue. +# 1. A first check works out what broke and whether open issues already cover it, and updates the recurrence +# comment on each covering issue. If they cover everything, the job stops there. +# 2. Otherwise the main model investigates what isn't covered and opens an issue with its findings. # # With `humanize_duty` set, a new issue also records the developer who rewrites it in plain language: the # next individual user on the `*` rule of the repo's CODEOWNERS, in turn. `label` labels the issue -# `needs-humanize:`. It runs in its own job, one at a time per repo, so it never holds up the investigate -# or fix phase. -# -# Note: this workflow is intended to be called from a scheduled workflow. Scheduled runs use -# GITHUB_TOKEN with reduced permissions that cannot trigger other workflow runs. For this reason -# the PR phase is chained as a direct job dependency rather than relying on a label-based trigger. +# `needs-humanize:`. It runs in its own job, one at a time per repo, so it never holds up the investigation. # # Example usage: # @@ -49,13 +40,18 @@ on: model: required: false type: string - default: sonnet - description: Claude model to use for investigation and fix + default: opus + description: Claude model to use for the investigation effort: required: false type: string default: '' - description: Claude effort level (low, medium, high, xhigh, max) to use for investigation and fix. Uses the Claude Code default when empty. + description: Claude effort level (low, medium, high, xhigh, max) to use for the investigation. Uses the Claude Code default when empty. + dedupe_model: + required: false + type: string + default: sonnet + description: Claude model that checks whether open issues already cover the failing tests, before the investigation max_flakiness_runs: required: false type: number @@ -65,9 +61,9 @@ on: required: false type: string default: | - Investigate the failing E2E platform test and open a GitHub issue documenting your findings. Start by reviewing the test logs, error messages, and recent workflow run history to determine the root cause. + Investigate the failing E2E platform test and open a GitHub issue documenting your findings. - Use available tools to check previous workflow runs, git history, and existing GitHub issues to gather context and avoid creating duplicate issues. For deeper context, + Start by reviewing the test logs, error messages, and recent workflow run history to determine the root cause. Use available tools to check previous workflow runs, git history, and existing GitHub issues to gather context and avoid creating duplicate issues. For deeper context, use tools to investigate the run on Apify platform, review its logs, datasets, key-value stores. Look specifically for debug traces, not just the top-level error: @@ -83,9 +79,9 @@ on: - Body, section 1 ("## Summary"): one line stating what's broken plus its impact, in plain language a PM can understand at a glance — no jargon, internal field names, or stack traces (e.g. "Scraping product detail pages fails when a listing has no reviews"). - If you measured flakiness, a "## Flakiness" section right after the Summary, as the `measure-flakiness` skill describes. - An "## Impact" section under the Flakiness section (or under the Summary if there's none), as the `assess-impact` skill describes. - - A `---` divider, then section 2 ("## Details"): the engineering bug report — root cause, relevant log lines, links to the failing run, and any other internals an engineer needs. If a single item/request failed among otherwise-good ones, show or link that specific one (e.g. the dataset item index/id, or its matching debug snapshot) rather than just describing the run as failed. + - A `---` divider, then section 2 ("## Details"): the engineering bug report — root cause, relevant log lines, links to the failing run, and any other internals an engineer needs. State the root cause and the error messages it produces, so later runs can recognize the same failure. If a single item/request failed among otherwise-good ones, show or link that specific one (e.g. the dataset item index/id, or its matching debug snapshot) rather than just describing the run as failed. - If you create a new issue, you MUST write its issue number (just the number, nothing else) to $GITHUB_WORKSPACE/issue-number.txt as the very last thing you do. If you skip creating one because a duplicate already exists, do not create the file. + If you create a new issue, you MUST write its issue number (just the number, nothing else) to $GITHUB_WORKSPACE/issue-number.txt as the very last thing you do. If you skip creating one because a duplicate already exists, do not create the file, and add the duplicate's number on its own line to $GITHUB_WORKSPACE/duplicate-of.txt. description: Prompt given to Claude for the investigation phase. Override to customize how issues are investigated, titled, and described. priority_prompt: required: false @@ -120,9 +116,6 @@ on: re-running it to measure how often the failure happens. Runs are private to the account that started them, so pass the token the tests ran the Actor with: its `testTokenEnvVar` from apify-test-tools.config.json, which is its `tokenEnvVar` unless the config names another. - NPM_TOKEN: - required: false - description: Read-only token for installing private npm packages before Claude runs. REDASH_API_KEY: required: false description: Redash API key for measuring the failure's impact — affected runs, high-touch customers and revenue — from Snowflake. @@ -134,7 +127,7 @@ jobs: investigate: runs-on: ubuntu-latest permissions: - contents: write + contents: read pull-requests: read issues: write actions: read @@ -150,9 +143,127 @@ jobs: echo "agent-skills-token=${{ secrets.AGENT_SKILLS_INTERNAL_GITHUB_TOKEN != '' }}" >> "$GITHUB_OUTPUT" echo "redash-api-key=${{ secrets.REDASH_API_KEY != '' }}" >> "$GITHUB_OUTPUT" + - name: Download the test report + continue-on-error: true + uses: actions/download-artifact@v5 + with: + name: vitest-results + path: vitest-results + + # The `tools` query parameter below selects which tools the Apify MCP server + # exposes: reading an Actor run — its status, exit code, storage ids and log — and + # reading that run's dataset items and its key-value store keys and records, e.g. + # INPUT, OUTPUT and error snapshots. WARN: the server adds `abort-actor-run` on top + # even when not listed here, see https://github.com/apify/apify-mcp-server + # `--disallowedTools` removes the Redash MCP server's tools that change Redash: creating, + # editing, sharing or deleting queries, visualizations, dashboards, widgets, alerts and snippets. + - name: Configure the MCP servers + id: mcp + env: + MCP_CONFIG: '{"mcpServers":{"apify":{"type":"http","url":"https://mcp.apify.com/?tools=get-actor-run,get-actor-run-log,get-dataset-list,get-dataset,get-dataset-items,get-key-value-store-list,get-key-value-store,get-key-value-store-keys,get-key-value-store-record","headers":{"Authorization":"Bearer ${TESTER_APIFY_TOKEN}"}},"redash":{"type":"stdio","command":"${{ runner.temp }}/redash-mcp/node_modules/.bin/redash-mcp","env":{"REDASH_URL":"https://charts.apify.com/","REDASH_API_KEY":"${REDASH_API_KEY}"}}}}' + run: | + { + echo "config=$MCP_CONFIG" + echo "dedupe-config=$(jq -c 'del(.mcpServers.redash)' <<< "$MCP_CONFIG")" + echo 'disallowed-tools=mcp__redash__create_query,mcp__redash__update_query,mcp__redash__update_query_parameters,mcp__redash__archive_query,mcp__redash__fork_query,mcp__redash__add_query_favorite,mcp__redash__remove_query_favorite,mcp__redash__create_visualization,mcp__redash__update_visualization,mcp__redash__update_chart_visualization,mcp__redash__delete_visualization,mcp__redash__create_dashboard,mcp__redash__update_dashboard,mcp__redash__update_dashboard_parameters,mcp__redash__archive_dashboard,mcp__redash__fork_dashboard,mcp__redash__share_dashboard,mcp__redash__unshare_dashboard,mcp__redash__add_dashboard_favorite,mcp__redash__remove_dashboard_favorite,mcp__redash__create_alert,mcp__redash__update_alert,mcp__redash__delete_alert,mcp__redash__mute_alert,mcp__redash__add_alert_subscription,mcp__redash__remove_alert_subscription,mcp__redash__create_widget,mcp__redash__update_widget,mcp__redash__update_widget_layout,mcp__redash__update_dashboard_layout,mcp__redash__update_widget_parameter_mappings,mcp__redash__delete_widget,mcp__redash__create_query_snippet,mcp__redash__update_query_snippet,mcp__redash__delete_query_snippet' + } >> "$GITHUB_OUTPUT" + + - name: Check for existing issues + id: dedupe + if: hashFiles('vitest-results/test-report.json') != '' + continue-on-error: true + uses: anthropics/claude-code-action@8251c103ac8c1d761882c86aba1412c7f583c844 # v1.0.213 + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TESTER_APIFY_TOKEN: ${{ secrets.TESTER_APIFY_TOKEN }} + with: + prompt: | + E2E platform tests failed in workflow run ${{ github.run_id }} of this repo. Its test report is at $GITHUB_WORKSPACE/vitest-results/test-report.json: it lists each test with its status and failure messages, plus any errors outside the tests. + + The tests overlap a lot, so one bug usually fails several of them. Work out what actually broke, the distinct root causes behind these failures, and whether an open issue in this repo already covers each one. List the open issues with `gh issue list --state open --limit 200 --json number,title,body,labels`, focusing on those labeled `claude`, and read any you need in full with `gh issue view`. An issue covers a failure when it describes the same root cause, no matter which tests it mentions. If the failure messages aren't enough to tell, look at the failing Actor runs with the Apify tools. When unsure, treat the failure as not covered: a missed duplicate costs one investigation, a wrong match hides a bug. + + Don't investigate further and don't change anything on GitHub. Write your answer to $GITHUB_WORKSPACE/dedupe.json as `{"issues": [], "uncovered": ""}`. + github_token: ${{ secrets.GITHUB_TOKEN }} + anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} + claude_args: | + --model ${{ inputs.dedupe_model }} + --mcp-config '${{ steps.mcp.outputs.dedupe-config }}' + --allowedTools "Bash(gh run view:*),Bash(gh issue list:*),Bash(gh issue view:*),Read,Write,mcp__apify" + + - name: Upload dedupe Claude output (for debugging) + if: always() && steps.dedupe.outcome != 'skipped' + uses: actions/upload-artifact@v6 + with: + name: claude-output-dedupe + path: /home/runner/work/_temp/claude-execution-output.json + + # Reads the check's answer: + # + # 1. Everything covered: skip the investigation. + # 2. Part covered: tell the main model which part, so it investigates only the rest. + # 3. No usable answer: investigate everything. + - name: Decide whether to investigate + id: duplicates + if: ${{ !cancelled() }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + answer="$GITHUB_WORKSPACE/dedupe.json" + issues='[]' + uncovered='no answer from the check' + if jq -e '(.issues | type == "array") and (.uncovered | type == "string")' "$answer" > /dev/null 2>&1; then + issues=$(jq -c '[.issues[] | select(type == "number" and . > 0 and floor == .)] | unique' "$answer") || issues='[]' + uncovered=$(jq -r '.uncovered' "$answer") + fi + + # Filter out invalid issue numbers. The agent could have made a mistake. + open=$(gh issue list --repo "$GITHUB_REPOSITORY" --state open --limit 1000 --json number --jq 'map(.number)') || { + echo "::warning::Could not list the open issues" + open='[]' + } + dropped=$(jq -c --argjson open "$open" 'map(select(IN($open[]) | not))' <<< "$issues") + issues=$(jq -c --argjson open "$open" 'map(select(IN($open[])))' <<< "$issues") + if [ "$(jq length <<< "$dropped")" -gt 0 ]; then + dropped_refs=$(jq -r 'map("#\(.)") | join(", ")' <<< "$dropped") + echo "::warning::The check matched the failure to $dropped_refs, which aren't open issues" + uncovered="${uncovered:+$uncovered }Also what the check matched to $dropped_refs, which aren't open issues." + fi + refs=$(jq -r 'map("#\(.)") | join(", ")' <<< "$issues") + + if [ "$(jq length <<< "$issues")" -gt 0 ]; then + jq -r '.[]' <<< "$issues" > "$GITHUB_WORKSPACE/duplicate-of.txt" + fi + if [ "$(jq length <<< "$issues")" -gt 0 ] && [ -z "$(tr -d '[:space:]' <<< "$uncovered")" ]; then + echo "all-duplicates=true" >> "$GITHUB_OUTPUT" + echo "Open issues $refs already cover the failure, skipping the investigation" + exit 0 + fi + + echo "all-duplicates=false" >> "$GITHUB_OUTPUT" + echo "Covered by: ${refs:-none}. Not covered: $uncovered" + if [ "$(jq length <<< "$issues")" -gt 0 ]; then + delimiter="EOF_$(openssl rand -hex 8)" + { + echo "note<<$delimiter" + echo "A first check found that open issues $refs already cover part of this failure. Read them and investigate only what they don't explain." + echo "$delimiter" + } >> "$GITHUB_OUTPUT" + fi + + - uses: actions/setup-node@v6 + if: steps.duplicates.outputs.all-duplicates != 'true' && steps.optional-secrets.outputs.redash-api-key == 'true' + with: + node-version: 24 + + - name: Install Redash MCP server + if: steps.duplicates.outputs.all-duplicates != 'true' && steps.optional-secrets.outputs.redash-api-key == 'true' + continue-on-error: true + working-directory: ${{ runner.temp }} + run: npm install --prefix redash-mcp --ignore-scripts --no-audit --no-fund @suthio/redash-mcp@0.1.0 + - name: Checkout internal agent skills id: agent-skills-internal - if: steps.optional-secrets.outputs.agent-skills-token == 'true' + if: steps.duplicates.outputs.all-duplicates != 'true' && steps.optional-secrets.outputs.agent-skills-token == 'true' continue-on-error: true uses: actions/checkout@v5 with: @@ -164,19 +275,9 @@ jobs: skills/redash-analyst persist-credentials: false - - uses: actions/setup-node@v6 - if: steps.optional-secrets.outputs.redash-api-key == 'true' - with: - node-version: 24 - - - name: Install Redash MCP server - if: steps.optional-secrets.outputs.redash-api-key == 'true' - continue-on-error: true - working-directory: ${{ runner.temp }} - run: npm install --prefix redash-mcp --ignore-scripts --no-audit --no-fund @suthio/redash-mcp@0.1.0 - - name: Run Claude Code id: claude + if: steps.duplicates.outputs.all-duplicates != 'true' uses: anthropics/claude-code-action@8251c103ac8c1d761882c86aba1412c7f583c844 # v1.0.213 env: TESTER_APIFY_TOKEN: ${{ secrets.TESTER_APIFY_TOKEN }} @@ -186,6 +287,8 @@ jobs: prompt: | The failing E2E platform test ran in workflow run ${{ github.run_id }} of this repo. + ${{ steps.duplicates.outputs.note }} + ${{ inputs.investigate_prompt }} ${{ inputs.priority_prompt }} @@ -197,22 +300,15 @@ jobs: plugins: | platform-tests-investigate-and-fix@apify-test-tools ${{ steps.agent-skills-internal.outcome == 'success' && 'redash-analyst@apify-agent-skills-internal' || '' }} - # The `tools` query parameter below selects which tools the Apify MCP server - # exposes: reading an Actor run — its status, exit code, storage ids and log — and - # reading that run's dataset items and its key-value store keys and records, e.g. - # INPUT, OUTPUT and error snapshots. WARN: the server adds `abort-actor-run` on top - # even when not listed here, see https://github.com/apify/apify-mcp-server - # `--disallowedTools` removes the Redash MCP server's tools that change Redash: creating, - # editing, sharing or deleting queries, visualizations, dashboards, widgets, alerts and snippets. claude_args: | - --mcp-config '{"mcpServers":{"apify":{"type":"http","url":"https://mcp.apify.com/?tools=get-actor-run,get-actor-run-log,get-dataset-list,get-dataset,get-dataset-items,get-key-value-store-list,get-key-value-store,get-key-value-store-keys,get-key-value-store-record","headers":{"Authorization":"Bearer ${TESTER_APIFY_TOKEN}"}},"redash":{"type":"stdio","command":"${{ runner.temp }}/redash-mcp/node_modules/.bin/redash-mcp","env":{"REDASH_URL":"https://charts.apify.com/","REDASH_API_KEY":"${REDASH_API_KEY}"}}}}' - --disallowedTools mcp__redash__create_query,mcp__redash__update_query,mcp__redash__update_query_parameters,mcp__redash__archive_query,mcp__redash__fork_query,mcp__redash__add_query_favorite,mcp__redash__remove_query_favorite,mcp__redash__create_visualization,mcp__redash__update_visualization,mcp__redash__update_chart_visualization,mcp__redash__delete_visualization,mcp__redash__create_dashboard,mcp__redash__update_dashboard,mcp__redash__update_dashboard_parameters,mcp__redash__archive_dashboard,mcp__redash__fork_dashboard,mcp__redash__share_dashboard,mcp__redash__unshare_dashboard,mcp__redash__add_dashboard_favorite,mcp__redash__remove_dashboard_favorite,mcp__redash__create_alert,mcp__redash__update_alert,mcp__redash__delete_alert,mcp__redash__mute_alert,mcp__redash__add_alert_subscription,mcp__redash__remove_alert_subscription,mcp__redash__create_widget,mcp__redash__update_widget,mcp__redash__update_widget_layout,mcp__redash__update_dashboard_layout,mcp__redash__update_widget_parameter_mappings,mcp__redash__delete_widget,mcp__redash__create_query_snippet,mcp__redash__update_query_snippet,mcp__redash__delete_query_snippet + --mcp-config '${{ steps.mcp.outputs.config }}' + --disallowedTools ${{ steps.mcp.outputs.disallowed-tools }} --model ${{ inputs.model }} ${{ inputs.effort && format('--effort {0}', inputs.effort) || '' }} --dangerously-skip-permissions - name: Upload Claude output (for debugging) - if: always() + if: always() && steps.claude.outcome != 'skipped' uses: actions/upload-artifact@v6 with: name: claude-output-investigate @@ -232,9 +328,8 @@ jobs: echo "No issue created (duplicate skipped)" fi - # Adds the "claude" label for visibility. Normally this would trigger the claude.yaml - # workflow, but scheduled runs lack the permissions to trigger other workflows, so the - # PR phase is driven by the fix job dependency instead. + # Adds the "claude" label for visibility. Scheduled runs lack the permissions to trigger other + # workflows, so this doesn't start the Claude workflow on the issue. - name: Add Claude label to issue if: steps.issue.outputs.number != '' uses: actions/github-script@v7 @@ -259,6 +354,99 @@ jobs: labels: ["claude"], }); + # Records this run on each existing issue Claude found covering the failure, in one comment per issue + # that later runs update in place. The comment looks like this on GitHub: + # + # ### Failed again in later runs + # + # Platform tests failed on this issue **5** times since this comment was added. Last seen 2026-11-10 14:03 UTC. + # + # Most recent 5 runs: + # - 2026-11-10 14:03 UTC: [Platform tests (hourly)]() + # - 2026-11-10 13:03 UTC: [Platform tests (hourly)]() + # - ... + # + # Editing a comment doesn't notify the issue's subscribers, so a test failing every hour doesn't flood them. + # Note: two runs updating the same comment at once can lose one of the counts. + - name: Record the failure on existing issues + if: ${{ !cancelled() }} + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + # Source: claude + script: | + const fs = require('fs'); + const MARKER = ''))); + } catch { + core.warning(`Could not parse the recurrence comment on #${issueNumber}, starting over`); + } + } + state.count += 1; + state.runs = [run, ...state.runs].slice(0, MAX_RUNS); + + const body = [ + `${MARKER} ${JSON.stringify(state)} -->`, + '### Failed again in later runs', + '', + `Platform tests failed on this issue **${state.count}** ${state.count === 1 ? 'time' : 'times'} since this comment was added. Last seen ${formatDate(run.at)}.`, + '', + `Most recent ${state.runs.length === 1 ? 'run' : `${state.runs.length} runs`}:`, + ...state.runs.map((r) => `- ${formatDate(r.at)}: [${r.workflow}](${r.url})`), + ].join('\n'); + + if (existing) { + await github.rest.issues.updateComment({ owner, repo, comment_id: existing.id, body }); + } else { + await github.rest.issues.createComment({ owner, repo, issue_number: issueNumber, body }); + } + console.log(`Recorded the failure on #${issueNumber} (${state.count} so far)`); + } catch (error) { + core.warning(`Could not record the failure on #${issueNumber}: ${error.message}`); + } + } + humanize-duty: needs: investigate if: inputs.humanize_duty != '' && needs.investigate.outputs.issue_number != '' @@ -278,60 +466,3 @@ jobs: with: duty: ${{ inputs.humanize_duty }} issue-number: ${{ needs.investigate.outputs.issue_number }} - - fix: - needs: investigate - if: needs.investigate.outputs.issue_number != '' - runs-on: ubuntu-latest - permissions: - contents: write - pull-requests: write - issues: write - id-token: write - actions: read - steps: - - name: Setup repository and dependencies - # `$/` loads the action from this repo at the commit this workflow was called at, so a caller - # pinned to a SHA or a branch gets that commit's action and CLI, not whatever the major tag is on. - uses: $/.github/actions/checkout-restore-dependencies - with: - npm-token: ${{ secrets.NPM_TOKEN }} - - - name: Run Claude Code - id: claude - uses: anthropics/claude-code-action@8251c103ac8c1d761882c86aba1412c7f583c844 # v1.0.213 - with: - anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} - use_commit_signing: true - prompt: 'Open a pull request to address GitHub issue #${{ needs.investigate.outputs.issue_number }}. Use `gh issue view ${{ needs.investigate.outputs.issue_number }}` to read the issue details first, then implement the fix and create a PR.' - claude_args: | - --model ${{ inputs.model }} - ${{ inputs.effort && format('--effort {0}', inputs.effort) || '' }} - --dangerously-skip-permissions - - - name: Upload Claude output (for debugging) - if: always() - uses: actions/upload-artifact@v6 - with: - name: claude-output-fix - path: /home/runner/work/_temp/claude-execution-output.json - - # Adds "claude:done" to the issue to signal that a fix PR was opened. Pure status - # tracking — does not trigger any further automation. - - name: Mark issue as processed by Claude - if: steps.claude.conclusion == 'success' - uses: actions/github-script@v7 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - try { - await github.rest.issues.addLabels({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: parseInt('${{ needs.investigate.outputs.issue_number }}'), - labels: ['claude:done'] - }); - console.log('Label claude:done added to issue.'); - } catch (e) { - console.log('Label claude:done does not exist. Skipping.'); - } diff --git a/docs/workflows.md b/docs/workflows.md index c5b2d8e..d92cfed 100644 --- a/docs/workflows.md +++ b/docs/workflows.md @@ -19,15 +19,15 @@ Always reference them at the `@workflows-v0` major tag, never at `@master` — s They only run on GitHub Actions. On another CI platform, build the same steps with the [CLI](cli.md); each workflow The build, release and test workflows below list the CLI commands they run. -| Workflow | Typical trigger | What it does | -| ---------------------------------------------------------------------------------------------------------------- | ----------------------------------- | -------------------------------------------------------------------------------- | -| [`public_pr-build-test.yaml`](#public_pr-build-testyaml) | `pull_request` | Builds the Actors a PR changes into `0.99` and tests them, plus static checks | -| [`public_push-build-latest.yaml`](#public_push-build-latestyaml) | `push` to `master` | Builds the changed Actors into their default version and announces the release | -| [`public_platform-tests.yaml`](#public_platform-testsyaml) | `schedule` | Runs platform tests against the released builds and reports results to Slack | -| [`public_review.yaml`](#public_reviewyaml) | `pull_request` (labeled) | Claude reviews the PR against the shared guidelines | -| [`public_claude.yaml`](#public_claudeyaml) | issue and PR comments, issue labels | Claude acts on `@claude` mentions | -| [`public_stale-issues.yaml`](#public_stale-issuesyaml) | `schedule` | Warns owners of inactive issues, then closes them a month later | -| [`public_platform-tests-claude-investigate-and-fix.yaml`](#public_platform-tests-claude-investigate-and-fixyaml) | after a failed platform test job | Claude investigates a failing platform test, opens an issue, and tries to fix it | +| Workflow | Typical trigger | What it does | +| ---------------------------------------------------------------------------------------------------------------- | ----------------------------------- | ------------------------------------------------------------------------------ | +| [`public_pr-build-test.yaml`](#public_pr-build-testyaml) | `pull_request` | Builds the Actors a PR changes into `0.99` and tests them, plus static checks | +| [`public_push-build-latest.yaml`](#public_push-build-latestyaml) | `push` to `master` | Builds the changed Actors into their default version and announces the release | +| [`public_platform-tests.yaml`](#public_platform-testsyaml) | `schedule` | Runs platform tests against the released builds and reports results to Slack | +| [`public_review.yaml`](#public_reviewyaml) | `pull_request` (labeled) | Claude reviews the PR against the shared guidelines | +| [`public_claude.yaml`](#public_claudeyaml) | issue and PR comments, issue labels | Claude acts on `@claude` mentions | +| [`public_stale-issues.yaml`](#public_stale-issuesyaml) | `schedule` | Warns owners of inactive issues, then closes them a month later | +| [`public_platform-tests-claude-investigate-and-fix.yaml`](#public_platform-tests-claude-investigate-and-fixyaml) | after a failed platform test job | Claude investigates a failing platform test and opens an issue | All of them run on `ubuntu-latest` with Node.js 24. The ones that need the repo's dependencies install them with `npm ci`, or with pnpm when the repo has a `pnpm-lock.yaml` and no `package-lock.json`. @@ -311,21 +311,26 @@ jobs: ## `public_platform-tests-claude-investigate-and-fix.yaml` -Optional. Call it after a failed platform test job. It runs in two phases: +Optional. Call it after a failed platform test job. It runs in two stages: -1. **investigate** — Claude reviews the test logs, recent workflow runs and existing issues, and investigates the - failing run on the Apify platform (its log, dataset and key-value store). It opens a GitHub issue with its - findings and labels it `claude`, or does nothing if a matching issue already exists. -2. **fix** — runs only when the first phase opened an issue. Claude implements a fix, opens a PR, and labels the - issue `claude:done`. +1. **Deduplication** — a first check, on Sonnet by default, reads the failing tests from the run's test report, works + out what actually broke, and checks whether open issues already cover it. The tests overlap a lot, so it judges by + root cause, not by test. It can read the failing runs on the Apify platform, but has no Redash access, and on + GitHub it can only read issues. A match counts only if it is an open issue. Each covering issue gets the run + recorded in one comment that keeps a count and links to the latest runs, updated in place so subscribers aren't + notified every time. If open issues cover everything, the job stops here, so a known bug isn't investigated in full + on every scheduled run. +2. **Investigation** — otherwise the main model investigates what isn't covered: the test logs, recent workflow runs, + and the failing run on the Apify platform (its log, dataset and key-value store). It opens a GitHub issue with its + findings and labels it `claude`. -Scheduled runs use a `GITHUB_TOKEN` that cannot trigger other workflows, so the fix phase is a direct job -dependency rather than a label-triggered run of `public_claude.yaml`. +If the deduplication can't give an answer, e.g. the run has no test report or the model fails, the investigation runs. | Input | Type | Default | Description | | -------------------- | ------ | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `model` | string | `sonnet` | Claude model for both phases | +| `model` | string | `opus` | Claude model for the investigation | | `effort` | string | `''` | Claude effort level (`low`, `medium`, `high`, `xhigh`, `max`). Empty uses the Claude Code default | +| `dedupe_model` | string | `sonnet` | Claude model that checks whether open issues already cover the failing tests, before the investigation | | `max_flakiness_runs` | number | `200` | The most times Claude may re-run the failing Actor run to measure how often the failure happens | | `investigate_prompt` | string | (built in) | Prompt for the investigation phase. Override to change how issues are investigated, titled and described | | `priority_prompt` | string | (built in) | Prompt for setting a new issue's Priority field from its impact and flakiness. Override to change how priority is judged, e.g. to set revenue thresholds | @@ -343,7 +348,7 @@ Without CODEOWNERS or any individual user on its `*` rule, the job logs a warnin `label` is the only supported value for now. Any other value fails the job that records the duty, and leaves the investigate and fix phases alone. -Secrets: `ANTHROPIC_API_KEY`, `TESTER_APIFY_TOKEN`, and optionally `NPM_TOKEN`, `REDASH_API_KEY` and `AGENT_SKILLS_INTERNAL_GITHUB_TOKEN`. +Secrets: `ANTHROPIC_API_KEY`, `TESTER_APIFY_TOKEN`, and optionally `REDASH_API_KEY` and `AGENT_SKILLS_INTERNAL_GITHUB_TOKEN`. Runs are private to the account that started them, so `TESTER_APIFY_TOKEN` here must be the token the tests ran the failing Actor with: its `testTokenEnvVar`, which is its `tokenEnvVar` unless the config names another.