← Back to Pull requests

test(bundle): drive the issue-side OWNERS fallback and the membership probes' 500 arms through dist/index.js #331

Closed
unknown closed this pull request without merging on Oct 09, 2026 01:28 UTC
View on GitHub
unknown unknown commented on Oct 05, 2026 17:50 UTC
Author

Test Improvement

Adds __tests__/bundle/rootOwnersFallback.test.ts, a bundle (end-to-end) suite that drives src/utils/auth.ts's issue-side assertAuthorizedByOwnersOrMembership arm through dist/index.js against the fake GitHub. On an issue (not a pull request) the plugin reads the root OWNERS file via retrieveOwnersFile → assertRootOwner and falls back to org membership / collaborator status when it is absent; no existing bundle test reached that arm (the only /lgtm on an issue is refused as the author before authorization runs).

Five tests, /lgtm by a non-author on issue #1 unless noted:

| route | expected |
|---|---|
| root OWNERS 404, org-membership read 500, collaborator 204 | ::warning::encountered unexpected error: status=500, message=boom, lgtm applied, then the post-command config reads |
| root OWNERS 404, org and collaborator both 404 | refused Codertocat is not a org member or collaborator, exit 1, no label write |
| root OWNERS 500 | refused error checking for an OWNERS file at the root of the repository: HttpError: boom, no membership read |
| root OWNERS is a directory (contents API lists it without content) | refused invalid OWNERS file returned from GitHub API, no membership read |
| /unassign @octocat by a non-member whose issue-comments read 500s | ::warning::encountered unexpected error checking issue comments: status=500, message=boom, no DELETE …/assignees |

Each test also asserts the exact request sequence (contents/OWNERS → orgs/…/members → collaborators/… → write/comment → config reads via expectCommandThenConfig).

Measured with npm run test:coverage:e2e on main @ 3fc21f2: auth.ts end-to-end 63.1 % → 81.55 % lines (62.85 → 80.95 % stmts, 53.12 → 71.87 % branches, 78.57 → 92.85 % funcs). auth.ts:257, 61, 64, 135-139, 349-350, 353, 358-359 go from 0 hits to covered. All files: 77.9 → 78.7 % lines, 6 files / 147 tests.

Disjoint from the held PRs: #283 (ownersAuth.test.ts) covers the root-OWNERS-present arms (auth.ts:277-288, 362-364) and the PR-side no OWNERS file covers arm (321-322); #306 covers checkCollaborator's 500 arm (98, 101). Those lines are not asserted here. Files touched: __tests__/bundle/rootOwnersFallback.test.ts only (new); src/, dist/, vitest.config.mjs and .github/ unchanged.

Verified locally: npx vitest run __tests__/bundle/rootOwnersFallback.test.ts (5 passed), npx eslint __tests__/bundle/rootOwnersFallback.test.ts clean.

Related Issue


Closes #330

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

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

Diff: 333 lines (+249 / -84) across 4 files Reviewer: jeefy Review duration: 4778m
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.42 · 333 lines diff across 4 files
0.42
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%
60%
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.348
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #331"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% 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: 42.1% (MEDIUM) · Higher = larger blast radius
42.1%
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: 60.5% · Lower = rushed or shallow review
60.5%
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: 16.7% · Safe to merge
16.7%