|
| 1 | +name: Queue filing |
| 2 | + |
| 3 | +# The dashboard's 📥 `queue-intake` / 📑 `queue-cite` buttons open prefilled |
| 4 | +# issues; this workflow has Claude file the named paper — bibliography entry, |
| 5 | +# wiki sources section (minimal for cite, full stub for intake, the human's |
| 6 | +# notes folded in), DONE-mark on the queue line — and opens a reviewable PR |
| 7 | +# that closes the issue. Merge stays human. |
| 8 | +# |
| 9 | +# Trigger is `labeled` only: GitHub fires it both for labels applied at |
| 10 | +# creation (the dashboard path) and for labels added later, and using it alone |
| 11 | +# avoids the double-run an `opened`+`labeled` pair would cause. Only |
| 12 | +# owner/member/collaborator-authored issues act (public repo — same gate as |
| 13 | +# queue_actions.yml), and only triage+ users can apply labels at all. |
| 14 | +# |
| 15 | +# The PR is created with the runner's GITHUB_TOKEN, so `pull_request` |
| 16 | +# workflows (validate.yml) do NOT run on it — `make validate` + pytest run |
| 17 | +# here as the gate instead, before anything is pushed. |
| 18 | +# |
| 19 | +# Claude runs with tools scoped to workspace edits plus arXiv lookups; the |
| 20 | +# deterministic steps below stage explicit paths only — never `git add -A`. |
| 21 | + |
| 22 | +on: |
| 23 | + issues: |
| 24 | + types: [labeled] |
| 25 | + |
| 26 | +# contents: write → push the filing branch; pull-requests/issues: write → the |
| 27 | +# PR + failure comment; id-token: write → claude-code-action's OIDC startup |
| 28 | +# (same requirement as PyAutoMind's arxiv_papers.yml). |
| 29 | +permissions: |
| 30 | + contents: write |
| 31 | + pull-requests: write |
| 32 | + issues: write |
| 33 | + id-token: write |
| 34 | + |
| 35 | +concurrency: |
| 36 | + group: queue-filing-${{ github.event.issue.number }} |
| 37 | + cancel-in-progress: false |
| 38 | + |
| 39 | +jobs: |
| 40 | + file-paper: |
| 41 | + if: >- |
| 42 | + contains(fromJSON('["queue-intake", "queue-cite"]'), |
| 43 | + github.event.label.name) && |
| 44 | + contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), |
| 45 | + github.event.issue.author_association) |
| 46 | + runs-on: ubuntu-latest |
| 47 | + env: |
| 48 | + GH_TOKEN: ${{ github.token }} |
| 49 | + # gh needs explicit repo context in the pre-checkout secret-guard step. |
| 50 | + GH_REPO: ${{ github.repository }} |
| 51 | + ISSUE: ${{ github.event.issue.number }} |
| 52 | + steps: |
| 53 | + - name: Require the Claude OAuth token |
| 54 | + env: |
| 55 | + TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} |
| 56 | + run: | |
| 57 | + if [ -z "$TOKEN" ]; then |
| 58 | + echo "::error::CLAUDE_CODE_OAUTH_TOKEN is not set on this repo — add it under Settings → Secrets and variables → Actions to enable queue filing." |
| 59 | + gh issue comment "$ISSUE" --body \ |
| 60 | + "Queue filing is not enabled yet: the CLAUDE_CODE_OAUTH_TOKEN secret is missing on this repo (Settings → Secrets and variables → Actions). File this paper from a Claude Code session instead, or add the secret and re-apply the label." |
| 61 | + exit 1 |
| 62 | + fi |
| 63 | +
|
| 64 | + - uses: actions/checkout@v4 |
| 65 | + |
| 66 | + - name: Stash the request for Claude |
| 67 | + env: |
| 68 | + # env, never inline interpolation — issue text is untrusted input. |
| 69 | + ISSUE_BODY: ${{ github.event.issue.body }} |
| 70 | + LABEL: ${{ github.event.label.name }} |
| 71 | + run: | |
| 72 | + printf '%s' "$ISSUE_BODY" > /tmp/issue_body.txt |
| 73 | + printf '%s' "$LABEL" > /tmp/issue_label.txt |
| 74 | +
|
| 75 | + - name: File the paper with Claude |
| 76 | + uses: anthropics/claude-code-action@v1 |
| 77 | + with: |
| 78 | + # Claude subscription OAuth token — NOT an API key (the org pattern |
| 79 | + # from PyAutoMind arxiv_papers.yml / morning_status.yml). |
| 80 | + claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} |
| 81 | + # Default-hidden output masks real failures — surface everything. |
| 82 | + show_full_output: true |
| 83 | + # Workspace edits + the repo's own gates + arXiv metadata lookups. |
| 84 | + # No git/gh: the deterministic steps below own branch/commit/PR. |
| 85 | + claude_args: '--allowedTools "Read,Glob,Grep,Edit,Write,Bash(make:*),Bash(python:*),Bash(python3:*),WebFetch(domain:arxiv.org),WebFetch(domain:export.arxiv.org)"' |
| 86 | + prompt: | |
| 87 | + You are filing one paper into this PyAutoMemory checkout. |
| 88 | +
|
| 89 | + Read /tmp/issue_body.txt (a dashboard queue request). Extract: |
| 90 | + - `section:` — the reading-queue section header, |
| 91 | + - `line:` — the exact reading-queue.md line (title, possibly |
| 92 | + with a trailing ` — <arXiv id or URL>` ref), |
| 93 | + - `notes:` — the human's free-text notes; treat as absent if it |
| 94 | + still holds the "(optional — replace this…)" placeholder. |
| 95 | + Read /tmp/issue_label.txt: `queue-intake` (full filing) or |
| 96 | + `queue-cite` (minimal, citeable-only). |
| 97 | +
|
| 98 | + Follow this repo's documented workflow — bibliography/README.md |
| 99 | + "Adding a paper" and wiki/CLAUDE.md's schema: |
| 100 | +
|
| 101 | + 1. Identify the paper. Use the arXiv ref if the line has one; |
| 102 | + otherwise search arXiv by title (WebFetch against arxiv.org / |
| 103 | + export.arxiv.org only). Get authoritative metadata: authors, |
| 104 | + year, arXiv id, journal if published. |
| 105 | + 2. Add the canonical BibTeX entry to the bibliography (the single |
| 106 | + canonical .bib file per bibliography/README.md). Follow the |
| 107 | + README's key convention exactly. |
| 108 | + 3. Wiki sources page: pick the sub-wiki whose domain matches the |
| 109 | + section (e.g. "Strong Lensing" → wiki/lensing/); check the |
| 110 | + sub-wiki index if unsure. In the matching sources/*.md page: |
| 111 | + - queue-cite → add a MINIMAL section: heading, the |
| 112 | + `**Canonical BibTeX key:**` marker with the new key, and the |
| 113 | + human's notes (lightly cleaned up) — nothing deeper. |
| 114 | + - queue-intake → add a full stub section per wiki/CLAUDE.md, |
| 115 | + folding the notes into the summary. |
| 116 | + 4. reading-queue.md: prefix the exact `line:` inside its |
| 117 | + `## section` with `DONE <today's date> — ` (never delete it). |
| 118 | + 5. Run `make validate` and `python -m pytest tests/ -q`; fix your |
| 119 | + own filing mistakes until both are green. |
| 120 | +
|
| 121 | + Touch ONLY bibliography/, wiki/, and reading-queue.md. Do not |
| 122 | + commit — the workflow handles git. If the paper cannot be |
| 123 | + identified confidently, write the reason to /tmp/filing_error.txt |
| 124 | + and stop without editing anything. |
| 125 | +
|
| 126 | + - name: Abort cleanly if Claude could not identify the paper |
| 127 | + run: | |
| 128 | + if [ -f /tmp/filing_error.txt ]; then |
| 129 | + gh issue comment "$ISSUE" --body-file /tmp/filing_error.txt |
| 130 | + echo "::error::filing aborted — reason posted to the issue" |
| 131 | + exit 1 |
| 132 | + fi |
| 133 | +
|
| 134 | + - name: Gate the filing (validate + tests) |
| 135 | + run: | |
| 136 | + make validate |
| 137 | + python -m pytest tests/ -q |
| 138 | +
|
| 139 | + - name: Branch, commit, push, open the PR (explicit paths only) |
| 140 | + run: | |
| 141 | + git config user.name "github-actions[bot]" |
| 142 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 143 | + branch="queue-filing/issue-${ISSUE}" |
| 144 | + git checkout -b "$branch" |
| 145 | + git add bibliography/ wiki/ reading-queue.md |
| 146 | + if git diff --cached --quiet; then |
| 147 | + echo "::error::Claude produced no changes"; exit 1 |
| 148 | + fi |
| 149 | + git commit -m "queue: file paper from #${ISSUE}" |
| 150 | + git push -u origin "$branch" |
| 151 | + { |
| 152 | + echo "Files the paper requested in #${ISSUE} (label: $(cat /tmp/issue_label.txt))." |
| 153 | + echo |
| 154 | + echo "Rendered by claude-code-action from the issue's section/line/notes;" |
| 155 | + echo "\`make validate\` + \`pytest tests/\` ran green in the filing workflow" |
| 156 | + echo "(GITHUB_TOKEN-created PRs do not trigger validate.yml)." |
| 157 | + echo |
| 158 | + echo "Closes #${ISSUE}." |
| 159 | + } > /tmp/pr_body.md |
| 160 | + gh pr create --base main --head "$branch" \ |
| 161 | + --title "queue filing: paper from #${ISSUE}" \ |
| 162 | + --body-file /tmp/pr_body.md |
| 163 | + gh issue comment "$ISSUE" --body \ |
| 164 | + "Filing PR opened: $(gh pr view "$branch" --json url --jq .url). Review and merge to complete the intake." |
| 165 | +
|
| 166 | + - name: Report failure on the issue |
| 167 | + if: failure() |
| 168 | + run: | |
| 169 | + gh issue comment "$ISSUE" --body \ |
| 170 | + "Queue filing failed — see the workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}. The issue stays open; file manually from a Claude Code session if needed." || true |
0 commit comments