Repository navigation
feat(decision-brief): wire the decision-brief stage (Mary → ideas/<slug>/brief.md at Ripe) #2369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e12ed76
feat(decision-brief): wire the decision-brief stage (Mary → ideas/<sl…
don-petry 0de3bb9
fix(decision-brief): address the Codex + CodeRabbit review findings
don-petry 939616e
fix(decision-brief): render the PR body file list one file per line
don-petry 343c6d4
fix(decision-brief): keep the org PAT out of the job-level env
don-petry a3fd1d3
fix(decision-brief): isolate the gate and PR from the model step; NOT…
don-petry 10551b4
fix(decision-brief): address the remaining Codex findings on 343c6d4e
don-petry 9b28543
fix(decision-brief): close four provenance-gate gaps from the Codex r…
don-petry 661a7a8
fix(decision-brief): address the Codex review of 9b28543e (11 findings)
don-petry File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,168 @@ | ||
| # Reusable Decision Brief — fleet dispatch workflow. | ||
| # Single source of truth for the org: the dispatch logic lives here. Repo-level | ||
| # decision-brief.yml files are thin caller stubs | ||
| # (standards/workflows/decision-brief.yml in this repo until it is promoted to | ||
| # combsmith/.github/standards/workflows/). | ||
| # | ||
| # Two signals from the CALLER repo reach the CENTRAL decision-brief workflow in | ||
| # combsmith/.github-private, which runs Mary (the BMAD Analyst) there with the | ||
| # caller as `target_repo` — the brief PR is opened in the caller: | ||
| # - `needs-brief` added to an Ideas Discussion -> one brief for that idea | ||
| # - the caller's schedule / manual dispatch -> sweep: one brief per idea | ||
| # idea-triage ranked "Ripe" in the caller's Idea Promotion Queue that has no | ||
| # brief yet (capped per sweep) | ||
| # | ||
| # It does NOT draft inline: the vendored BMAD frameworks and the provenance | ||
| # guard live centrally, and claude-code-action aborts on `discussion` event | ||
| # contexts ("Unsupported event type: discussion"). The `needs-brief` label stays | ||
| # the human request; the dispatch is an invisible bridge (same pattern as | ||
| # initiative-planner-reusable.yml / idea-triage-reusable.yml in combsmith/.github). | ||
| # | ||
| # IMPORTANT — the dispatch requires a PAT, not GITHUB_TOKEN: | ||
| # GitHub does not start new workflow runs from a workflow_dispatch fired with | ||
| # the default GITHUB_TOKEN (loop prevention). The dispatch MUST use a PAT with | ||
| # workflow scope (GH_PAT_DON_PETRY, or the legacy GH_PAT_WORKFLOWS). | ||
| # | ||
| # Requires (org secrets): GH_PAT_DON_PETRY (or GH_PAT_WORKFLOWS). | ||
| name: Decision Brief — Fleet Dispatch (Reusable) | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| central_repo: | ||
| description: "owner/repo hosting the central decision-brief.yml workflow." | ||
| required: false | ||
| default: "combsmith/.github-private" | ||
| type: string | ||
| central_ref: | ||
| # Must match the channel the caller's `uses:` pins (the dev-lead | ||
| # stub's `agent_ref` convention): `gh workflow run` without --ref runs | ||
| # the central workflow and its tooling from the DEFAULT branch, which | ||
| # would defeat the release isolation the channel tag exists for. | ||
| description: "Ref (channel tag or branch) of central_repo to run the central workflow at. Keep it equal to the channel this reusable is pinned at." | ||
| required: false | ||
| default: "decision-brief/v1-stable" | ||
| type: string | ||
| discussion: | ||
| description: "Ideas Discussion number to brief (manual dispatch from the caller). Empty on label/schedule events." | ||
| required: false | ||
| default: "" | ||
| type: string | ||
| label: | ||
| description: "Discussion label that requests a brief." | ||
| required: false | ||
| default: "needs-brief" | ||
| type: string | ||
| max_briefs: | ||
| description: "Sweep cap: how many Ripe ideas one sweep may dispatch briefs for." | ||
| required: false | ||
| default: "3" | ||
| type: string | ||
| secrets: | ||
| GH_PAT_DON_PETRY: | ||
| description: "Canonical org PAT — preferred over GH_PAT_WORKFLOWS when present" | ||
| required: false | ||
| GH_PAT_WORKFLOWS: | ||
| description: "Classic PAT with repo + workflow scope used to dispatch the central decision-brief (GITHUB_TOKEN cannot start a workflow_dispatch run)." | ||
| required: false | ||
|
|
||
| permissions: {} # no default permissions; each job grants only what it needs | ||
|
|
||
| jobs: | ||
| dispatch: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 5 | ||
| permissions: {} | ||
| # Fire on: the configured label added to a Discussion; a schedule or manual | ||
| # dispatch of the caller (sweep, or a single idea when `discussion` is set). | ||
| # Any other caller event is ignored. | ||
| if: >- | ||
| (github.event_name == 'discussion' && github.event.action == 'labeled' && github.event.label.name == inputs.label) || | ||
| github.event_name == 'schedule' || | ||
| github.event_name == 'workflow_dispatch' | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GH_PAT_DON_PETRY || secrets.GH_PAT_WORKFLOWS }} | ||
| CENTRAL_REPO: ${{ inputs.central_repo }} | ||
| CENTRAL_REF: ${{ inputs.central_ref }} | ||
| TARGET_REPO: ${{ github.repository }} | ||
| steps: | ||
| - name: Guard — PAT present, ref well-formed | ||
| run: | | ||
| if [ -z "${GH_TOKEN}" ]; then | ||
| echo "::error::GH_PAT_DON_PETRY (or legacy GH_PAT_WORKFLOWS) is required — a workflow_dispatch fired with GITHUB_TOKEN will not start a run." | ||
| exit 1 | ||
| fi | ||
| if ! [[ "${CENTRAL_REF}" =~ ^[A-Za-z0-9][A-Za-z0-9._/-]*$ ]]; then | ||
| echo "::error::central_ref must be a branch or tag name, got: '${CENTRAL_REF}'" | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Guard — trusted actor | ||
| id: trust | ||
| # Only admin/write collaborators may spend brief budget by labelling a | ||
| # Discussion. The discussion `labeled` payload carries no | ||
| # author_association, so query the collaborator permission API. | ||
| # Schedule and manual dispatch are trusted by construction. | ||
| env: | ||
| REPO: ${{ github.repository }} | ||
| ACTOR: ${{ github.event.sender.login || github.actor }} | ||
| EVENT: ${{ github.event_name }} | ||
| run: | | ||
| if [ "$EVENT" != "discussion" ]; then | ||
| echo "trusted=true" >> "$GITHUB_OUTPUT" | ||
| exit 0 | ||
| fi | ||
| # A failed lookup is an API error, not an untrusted actor: fail the | ||
| # bridge loudly so the requested brief is visibly retriable instead of | ||
| # silently stranded behind an already-applied label. | ||
| if ! PERM=$(gh api "repos/${REPO}/collaborators/${ACTOR}/permission" --jq '.permission'); then | ||
| echo "::error::could not read @${ACTOR}'s permission on ${REPO} — not dispatching; re-apply the label or dispatch by hand once the API recovers" | ||
| exit 1 | ||
| fi | ||
| case "$PERM" in | ||
| admin|maintain|write) | ||
| echo "Actor @${ACTOR} has permission ${PERM} — trusted." | ||
| echo "trusted=true" >> "$GITHUB_OUTPUT" | ||
| ;; | ||
| *) | ||
| echo "::warning::Actor @${ACTOR} has permission ${PERM} — not trusted; not dispatching the brief." | ||
| echo "trusted=false" >> "$GITHUB_OUTPUT" | ||
| ;; | ||
| esac | ||
|
|
||
| - name: Dispatch central decision-brief for this repo | ||
| if: steps.trust.outputs.trusted == 'true' | ||
| env: | ||
| EVENT: ${{ github.event_name }} | ||
| # The label event carries the Discussion number; a manual dispatch may | ||
| # pass one through `discussion`; a schedule never has one (sweep). | ||
| DISCUSSION_NUMBER: ${{ github.event.discussion.number || inputs.discussion }} | ||
| MAX_BRIEFS: ${{ inputs.max_briefs }} | ||
| run: | | ||
| if [ -n "${DISCUSSION_NUMBER}" ]; then | ||
| # Validate the discussion number before it reaches the gh command line. | ||
| if ! [[ "${DISCUSSION_NUMBER}" =~ ^[1-9][0-9]*$ ]]; then | ||
| echo "::error::discussion number must be a positive integer, got: '${DISCUSSION_NUMBER}'" | ||
| exit 1 | ||
| fi | ||
| echo "${EVENT} on ${TARGET_REPO} discussion #${DISCUSSION_NUMBER} → dispatching central decision-brief in ${CENTRAL_REPO}@${CENTRAL_REF}." | ||
| gh workflow run decision-brief.yml \ | ||
| --repo "${CENTRAL_REPO}" --ref "${CENTRAL_REF}" \ | ||
| -f discussion="${DISCUSSION_NUMBER}" \ | ||
| -f target_repo="${TARGET_REPO}" \ | ||
| -f dry_run=false | ||
| echo "Dispatched decision-brief.yml (discussion=${DISCUSSION_NUMBER}, target_repo=${TARGET_REPO}, dry_run=false)." | ||
| else | ||
| echo "${EVENT} on ${TARGET_REPO} → dispatching central decision-brief SWEEP (Ripe ideas without a brief) in ${CENTRAL_REPO}@${CENTRAL_REF}." | ||
| if ! [[ "${MAX_BRIEFS}" =~ ^[0-9]+$ ]]; then | ||
| echo "::error::max_briefs must be an integer, got: '${MAX_BRIEFS}'" | ||
| exit 1 | ||
| fi | ||
| gh workflow run decision-brief.yml \ | ||
| --repo "${CENTRAL_REPO}" --ref "${CENTRAL_REF}" \ | ||
| -f from_queue=true \ | ||
| -f max_briefs="${MAX_BRIEFS}" \ | ||
| -f target_repo="${TARGET_REPO}" \ | ||
| -f dry_run=false | ||
|
don-petry marked this conversation as resolved.
don-petry marked this conversation as resolved.
|
||
| echo "Dispatched decision-brief.yml (from_queue=true, max_briefs=${MAX_BRIEFS}, target_repo=${TARGET_REPO}, dry_run=false)." | ||
| fi | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.