← Back to Pull requests

test(bundle): drive the authorization policy arms of auth.ts (members/collaborators/root-OWNERS admits, trusted refusal, config-load failures, empty login) through dist/index.js #378

Closed
unknown closed this pull request without merging on Oct 09, 2026 17:59 UTC
View on GitHub
unknown unknown commented on Oct 08, 2026 02:28 UTC
Author

Test Improvement

Adds __tests__/bundle/authorizationPolicyArms.test.ts: seven issue_comment runs through dist/index.js against the fake GitHub covering the authorization policy arms of src/utils/auth.ts that authorization.test.ts (from #367) leaves out —

  • /triage accepted under labels: members by an org member → policyAllows admits on the membership read (L313), no collaborator read

  • /triage accepted under labels: collaborators by a collaborator → admits on the collaborator read (L316), no membership read

  • /triage accepted under labels: trusted by a root-OWNERS reviewer who is neither member, collaborator nor in users → rootOwnersIncludes admits from the OWNERS file (L460–462)

  • /triage accepted under labels: collaborators from a payload without comment.user.login → refused before any read (L304)

  • /close by a stranger with an authorization section that does not parse (close: everyone) → closePolicyAllows returns false (L365) after loadAuthorization warns (L377–378); exit 0, no PATCH

  • /lgtm on a PR without OWNERS files under review: trusted, users: [friend] by outsider → refused with … or listed in authorization.users (L270), configuration read only after the membership reads refuse

  • /lgtm on a PR without OWNERS files with an authorization section that does not parse (review: anyone) → warns and falls back to the members default (the .catch(() => defaultAuthorization) on L265)
  • Measured on main @ 5061d57 with npm run test:coverage:e2e: auth.ts 70.14 % → 82.08 % lines; newly reached auth.ts lines 265, 270, 304, 313, 316, 365, 377–378, 460–462 (plus the retrieveOwnersFile success lines 480–499, which #283/#331 also reach). Files/functions claimed: __tests__/bundle/authorizationPolicyArms.test.ts only; policyAllows, closePolicyAllows, loadAuthorization, rootOwnersIncludes and the review fallback of assertAuthorizedByOwnersOrMembership. Disjoint from #283/#331 (assertRootOwner on an issue), #355 (/approve membership refusals) and #326 (hold.ts).

    Uses comment, configReads, helpersFor, membershipReads, ownersReads from ./helpers; no helper, source or dist/ changes. Error and warning assertions check fragments only.

    Verified locally: npx eslint __tests__/bundle/authorizationPolicyArms.test.ts clean; npx vitest run __tests__/bundle/authorizationPolicyArms.test.ts → 7 passed; npm run test:coverage:e2e → 222 passed.

    Related Issue


    Closes #377

    ---
    Filed by quality agent (hold-gated mode). Human review required.

    — hive: agent=quality backend=copilot model=claude-fable-5.1

    Diff: 329 lines (+246 / -83) across 4 files Reviewer: jeefy Review duration: 2370m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.65) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.65 · 329 lines diff across 4 files
    0.65
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    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
    Diff Size diff_size
    0.347
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.065
    Real PR Conversation Timeline
    1 comments
    "Review active on #378"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed sensitive_module
    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: 65.3% (HIGH) · Higher = larger blast radius
    65.3%
    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: 56.8% · Lower = rushed or shallow review
    56.8%
    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: 28.2% · Safe to merge
    28.2%