Skip to content

[Phase 2] Fetch consumer references + assemble the DOWNSTREAM_IMPACT context block #751

Description

@github-actions

Story

As a pr-review maintainer,
I want a step that takes the mapped impacted consumers, fetches their referencing workflow files via GH_PAT, and assembles a size-capped DOWNSTREAM_IMPACT block to a file,
so that the triage/deep tiers can consume a ready-made, bounded downstream-impact context the same way they consume advisory-bot feedback.

Acceptance Criteria

  1. Given the impact object from Story 2, the step fetches, for each impacted consumer, the workflow file(s) that reference the impacted surface using gh + GH_PAT, and writes a human-readable DOWNSTREAM_IMPACT block to a file path exported as DOWNSTREAM_IMPACT_FILE.
  2. When no surfaces are impacted, the block is the literal (none) (no fetches performed).
  3. Degrades gracefully: a consumer repo that is private/unreadable or a missing token scope yields (none) for that entry (or an explicit unreadable note) and never fails the cascade — exit status stays 0.
  4. Fetch volume is bounded: only exact-matched consumers are fetched, capped at a configurable max repo count per PR, and the assembled block is truncated to a size cap (mirroring the 8 KB ADVISORY_BOT_FEEDBACK cap).
  5. A bats test stubs gh to cover: impacted-with-readable-consumer, impacted-with-unreadable-consumer (-> graceful), and no-impact (-> (none), zero fetches). shellcheck passes.

Tasks / Subtasks

Dev Notes

  • Mirror the ADVISORY_BOT_FEEDBACK_FILE lifecycle in scripts/review-one-pr.sh (~lines 570–575): write a capped block to a file under /tmp/cascade/, export the path for downstream tiers, rm -f stale copies first.
  • Cap discipline matches the existing advisory cap (~8 KB) so huge consumer sets cannot blow up the prompt — see the 'Cap total size' note around scripts/review-one-pr.sh:534.
  • Use GH_PAT via gh exactly as the rest of pr-review does; do not add a new secret. Read-only gh api GET calls on consumer .github/workflows/* paths; no enumeration beyond the exact-matched consumer set.
  • Graceful degradation is a hard requirement: the cascade must never fail because a consumer repo is private or the token lacks a scope — follow the rate-limit/error-handling philosophy already in review-one-pr.sh (degrade, log ::warning::, continue).
  • Stub gh in bats the way existing tests do (PATH shim / function override) — see tests/test_ci_status.bats for the pattern.

Project Structure Notes

Extends scripts/lib/downstream-impact.sh with the I/O assembler; adds a bats test. Still no prompt wiring (Story 4).

References

  • scripts/review-one-pr.sh#ADVISORY_BOT_FEEDBACK_FILE
  • scripts/review-one-pr.sh#cap-total-size
  • .github/workflows/pr-review.yml#GH_PAT
  • tests/test_ci_status.bats#gh-stub

Likely target surface

  • scripts/lib/
  • tests/

Story prepared by the BMAD Scrum Master (Bob) for epic #748. Status: ready-for-dev.

Metadata

Metadata

Assignees

No one assigned

    Labels

    dev-leadFor dev-lead agent pickupinitiativeEpic / initiative tracking issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions