name: bonedigger lifecycle # bonedigger now scopes to ujust-report intake, confirm-based priority escalation, # and the bonedigger-specific agent donation fast-track. # During the clanker-queue migration, the workflow dual-writes the legacy labels # and the new clanker-queue/* namespace so callers can move without losing state. on: workflow_call: inputs: brand_name: description: 'Retained for backward compatibility; ignored by the slim workflow' type: string default: 'Bluefin' brand_emoji: description: 'Retained for backward compatibility; ignored by the slim workflow' type: string default: '🦖' pipeline_marker: description: 'Retained for backward compatibility; ignored by the slim workflow' type: string default: '' permissions: issues: write contents: read env: DONATION_WORKFLOW_MARKER: 'Workflow: Agent Donation' jobs: on-issue-opened: if: github.event_name == 'issues' && github.event.action == 'opened' runs-on: ubuntu-24.04 concurrency: group: bonedigger-issue-${{ github.repository }}-${{ github.event.issue.number }} cancel-in-progress: false steps: - name: Detect bonedigger flows id: detect env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} ISSUE_URL: ${{ github.event.issue.html_url }} run: | DATA=$(gh issue view "$ISSUE_URL" --json body,labels) ISSUE_BODY=$(printf '%s' "$DATA" | jq -r '.body // ""') WORKFLOW="standard" FLOW_LABEL="" IS_UJUST_REPORT=false if printf '%s\n' "$ISSUE_BODY" | grep -Fq "$DONATION_WORKFLOW_MARKER"; then WORKFLOW="agent_donation" FLOW_LABEL="flow/project-report" if printf '%s\n' "$ISSUE_BODY" | grep -Eq 'https://[^[:space:])>]+/pull/[0-9]+'; then FLOW_LABEL="flow/pr-review" elif printf '%s\n' "$ISSUE_BODY" | grep -Eq 'https://[^[:space:])>]+/issues/[0-9]+'; then FLOW_LABEL="flow/issue-review" fi fi if printf '%s' "$DATA" | jq -e '.labels[]? | select(.name == "source:ujust-report")' >/dev/null \ || printf '%s\n' "$ISSUE_BODY" | grep -Eqi '^### ujust report gist url$'; then IS_UJUST_REPORT=true fi { echo "workflow=$WORKFLOW" echo "flow_label=$FLOW_LABEL" echo "is_ujust_report=$IS_UJUST_REPORT" } >> "$GITHUB_OUTPUT" - name: Fast-track donated agent work if: steps.detect.outputs.workflow == 'agent_donation' env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} ISSUE_URL: ${{ github.event.issue.html_url }} FLOW_LABEL: ${{ steps.detect.outputs.flow_label }} run: | ARGS=( --add-label "status/approved" --add-label "status/queued" --add-label "clanker-queue/ready" --add-label "flow/agent-donation" ) if [ -n "$FLOW_LABEL" ]; then ARGS+=(--add-label "$FLOW_LABEL") fi gh issue edit "$ISSUE_URL" "${ARGS[@]}" - name: Seed clanker queue triage labels for ujust report issues if: steps.detect.outputs.workflow != 'agent_donation' && steps.detect.outputs.is_ujust_report == 'true' env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} ISSUE_URL: ${{ github.event.issue.html_url }} run: | gh issue edit "$ISSUE_URL" \ --add-label "status/triage" \ --add-label "clanker-queue/triage" - name: Sync priority labels for ujust report issues if: steps.detect.outputs.workflow != 'agent_donation' && steps.detect.outputs.is_ujust_report == 'true' env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} ISSUE_NUMBER: ${{ github.event.issue.number }} ISSUE_URL: ${{ github.event.issue.html_url }} run: | DATA=$(gh issue view "$ISSUE_URL" --json comments) CONFIRMS=$(printf '%s' "$DATA" | jq -r --arg issue_number "$ISSUE_NUMBER" '[.comments[].body // "" | select(test("(?i)^[[:space:]]*ujust confirm[[:space:]]+" + $issue_number + "([[:space:][:punct:]]|$)"))] | length') if [ "$CONFIRMS" -ge 5 ]; then gh issue edit "$ISSUE_URL" \ --add-label "priority/p0" \ --add-label "clanker-queue/p0" 2>/dev/null || true gh issue edit "$ISSUE_URL" \ --remove-label "priority/p1" \ --remove-label "clanker-queue/p1" 2>/dev/null || true elif [ "$CONFIRMS" -ge 3 ]; then gh issue edit "$ISSUE_URL" \ --add-label "priority/p1" \ --add-label "clanker-queue/p1" 2>/dev/null || true fi on-issue-comment: if: >- github.event_name == 'issue_comment' && github.event.action == 'created' && github.event.issue.pull_request == null runs-on: ubuntu-24.04 concurrency: group: bonedigger-issue-${{ github.repository }}-${{ github.event.issue.number }} cancel-in-progress: false steps: - name: Sync priority labels from confirm count env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} COMMENT_BODY: ${{ github.event.comment.body }} ISSUE_NUMBER: ${{ github.event.issue.number }} ISSUE_URL: ${{ github.event.issue.html_url }} run: | CONFIRM_TARGET=$(printf '%s\n' "$COMMENT_BODY" | sed -nE 's/^[[:space:]]*[Uu][Jj][Uu][Ss][Tt][[:space:]]+[Cc][Oo][Nn][Ff][Ii][Rr][Mm][[:space:]]+([0-9]+).*$/\1/p' | head -1) if [ -z "$CONFIRM_TARGET" ] || [ "$CONFIRM_TARGET" != "$ISSUE_NUMBER" ]; then echo "Ignoring confirm comment for issue '$CONFIRM_TARGET' on issue '$ISSUE_NUMBER'." exit 0 fi DATA=$(gh issue view "$ISSUE_URL" --json comments) CONFIRMS=$(printf '%s' "$DATA" | jq -r --arg issue_number "$ISSUE_NUMBER" '[.comments[].body // "" | select(test("(?i)^[[:space:]]*ujust confirm[[:space:]]+" + $issue_number + "([[:space:][:punct:]]|$)"))] | length') if [ "$CONFIRMS" -ge 5 ]; then gh issue edit "$ISSUE_URL" \ --add-label "priority/p0" \ --add-label "clanker-queue/p0" 2>/dev/null || true gh issue edit "$ISSUE_URL" \ --remove-label "priority/p1" \ --remove-label "clanker-queue/p1" 2>/dev/null || true elif [ "$CONFIRMS" -ge 3 ]; then gh issue edit "$ISSUE_URL" \ --add-label "priority/p1" \ --add-label "clanker-queue/p1" 2>/dev/null || true fi