← Back to Pull requests

feat(initiatives): add M2M beneficiaries endpoint for Reimbursement Service #507

Open
unknown opened this pull request with 309 lines diff across 3 files
View on GitHub
unknown unknown commented on Nov 30, 2026 14:14 UTC
Author

Summary

  • New M2M route: GET /crowdfunding/initiatives/{id}/beneficiaries, guarded by access:manage (same as owner-info). Returns {"data":[{"email":"..."}]}: the distinct, lower-cased, trimmed emails of the initiative's current beneficiaries. Blank and NULL emails are dropped.

  • Responses: an initiative with no beneficiaries returns {"data":[]}. An unknown id returns 404, and so does a non-UUID id, which never reaches the DB. No status filter is applied, matching owner-info. Cache-Control: private, no-store and Vary: Authorization, since the response is PII.

  • Heimdall: the path is added to the existing services rule in ruleset.yaml, so it gets the same services-team openfga_check and access:manage JWT as owner-info/published-list. Without it the route would fall through to default_rule (deny_all in staging/prod).

  • Docs: route tables in docs/architecture.md, docs/authentication-architecture.md (new §3.1 entry) and backend/docs/rewrite/04-target-architecture.md, plus the route lists in the chart comments.
  • Why

    The Reimbursement Service holds back an expense report, and asks Finance to review it manually, when the submitter isn't a beneficiary of a tagged initiative. It currently decides that from its own Elasticsearch cache, which drifts from the real beneficiary list. One example is report R00EzjNPrgjB, which was flagged for a Jenkins beneficiary. This endpoint lets RS ask Crowdfunding directly. The RS side is linuxfoundation/reimbursement-service (PR linked from there).

    initiative_beneficiaries rows are the current set: create, update and mentorship sync replace them wholesale, and there is no pending/removed status, so no extra filtering is needed.

    Testing

  • Handler tests: data shape, empty array, 404 (unknown and non-UUID), 500, no-cache headers.

  • Service tests: mapping, not-found passthrough, non-UUID short-circuit (the repo is never called).

  • DB integration test: case/whitespace duplicates collapse, blank/NULL emails dropped, an empty initiative returns an empty non-nil slice, an unknown id returns ErrInitiativeNotFound.

  • go test -race -count=1 -p 1 ./... passes against a migrated Postgres. make license-check passes. make lint reports only the 6 existing findings on main, none in changed files.

  • helm template with heimdall.enabled=true renders /crowdfunding/initiatives/:id/beneficiaries under rule:lfx:lfx-crowdfunding-backend:services.
  • Diff: 309 lines (+231 / -78) across 3 files Reviewer: greptile-apps[bot] Review duration: 10m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.40) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 309 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.343
    Real PR Conversation Timeline
    1 comments
    "Review active on #507"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 40.2% (MEDIUM) · Higher = larger blast radius
    40.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 21.4% · Safe to merge
    21.4%