name: Garbage Collector on: schedule: - cron: '0 6 * * *' # 06:00 UTC daily workflow_dispatch: inputs: dry_run: description: 'Dry run — report findings only, open no PRs or Issues (recommended for first 3–5 days)' required: false default: 'true' type: choice options: ['true', 'false'] days_branch: description: 'Days before a branch is considered stale' required: false default: '90' days_comment: description: 'Days before a TODO/FIXME comment is flagged' required: false default: '180' concurrency: group: garbage-collector cancel-in-progress: true permissions: contents: write pull-requests: write issues: write id-token: write jobs: collect: runs-on: ubuntu-latest timeout-minutes: 15 env: GH_TOKEN: ${{ secrets.GC_BOT_TOKEN }} DRY_RUN: ${{ github.event.inputs.dry_run || 'false' }} DAYS_BRANCH: ${{ github.event.inputs.days_branch || '90' }} DAYS_COMMENT: ${{ github.event.inputs.days_comment || '180' }} steps: - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 # full history required for git blame and branch age token: ${{ secrets.GC_BOT_TOKEN }} # PAT so pushed branches trigger CI - name: Configure git user run: | git config user.name 'WorldWideView GC Bot' git config user.email 'gc-bot@users.noreply.github.com' - name: Setup pnpm uses: pnpm/action-setup@v4 - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '22' cache: 'pnpm' - name: Install dependencies run: pnpm install --frozen-lockfile - name: Run deterministic scan run: | node scripts/gc-scan.mjs \ --out gc-findings.json \ --days-branch=${{ env.DAYS_BRANCH }} \ --days-comment=${{ env.DAYS_COMMENT }} - name: Upload findings artifact uses: actions/upload-artifact@v4 with: name: gc-findings-${{ github.run_id }} path: gc-findings.json retention-days: 30 - name: Run Garbage Collector agent uses: anthropics/claude-code-action@v1 with: claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} show_full_output: true prompt: | You are the WorldWideView Garbage Collector agent running headless in GitHub Actions. Read `.agents/rules/garbage-collection.md` for your charter and all guard rails. Read `gc-findings.json` for the pre-scanned findings produced by `scripts/gc-scan.mjs`. The DRY_RUN environment variable is: ${{ env.DRY_RUN }} ## If DRY_RUN is "true": Do NOT create any PRs or Issues. Instead, find or create the tracking Issue titled "[gc-bot] Daily Scan Reports" (label: gc-bot) in the silvertakana/worldwideview repository using the gh CLI: # Find existing tracking issue gh issue list --repo silvertakana/worldwideview --label gc-bot --search "[gc-bot] Daily Scan Reports" --json number,title # If it exists, add a comment: gh issue comment --repo silvertakana/worldwideview --body "..." # If it doesn't exist, create it: gh issue create --repo silvertakana/worldwideview --title "[gc-bot] Daily Scan Reports" --label gc-bot --body "..." The comment body must list every finding with: tier, file, line, description. Include the run ID (${{ github.run_id }}) and timestamp at the top. ## If DRY_RUN is "false": Execute the full sweep procedure described in `.claude/agents/garbage-collector.md`. Create Tier A draft PRs and Tier B Issues per the guard rails in `.agents/rules/garbage-collection.md`. Do not scan the codebase yourself. Work only from gc-findings.json. claude_args: '--model claude-haiku-4-5-20251001 --allowedTools Bash,Read,Edit,Write,Grep,Glob'