Skip to content

feat: add evidence-first contributor trust action - #1

Open
Neroxsh wants to merge 5 commits into
Open-Source-Bazaar:mainfrom
Neroxsh:feat/evidence-first-report
Open

feat: add evidence-first contributor trust action#1
Neroxsh wants to merge 5 commits into
Open-Source-Bazaar:mainfrom
Neroxsh:feat/evidence-first-report

Conversation

@Neroxsh

@Neroxsh Neroxsh commented Jul 18, 2026

Copy link
Copy Markdown

Summary

Add a reusable JavaScript GitHub Action that builds an evidence-first contributor trust report for pull requests, issues, and issue comments.

  • Reads public GitHub profile, account age, recent public activity, public Issue/PR history, and earlier PRs in the current organization.
  • Optionally asks GitHub Models for a second opinion grounded only in the collected evidence.
  • Creates or updates one idempotent report comment and applies needs-contributor-review for medium/high risk.
  • Never blocks an account automatically; maintainers keep the final decision.
  • Uses no third-party runtime dependencies and never checks out or executes external PR code.
  • Exposes author, risk level, score, and a machine-readable JSON report as outputs.

Related task: Open-Source-Bazaar/Open-Source-Bazaar.github.io#89

Verification

  • node --test: 5 tests passed.
  • node --check dist/index.mjs: passed.
  • node --check src/analyze.mjs: passed.
  • Read-only smoke test against the real GitHub API: passed.
  • git diff --check: passed.

AI usage

Codex assisted with research, implementation, and testing. API permissions, external-PR safety boundaries, idempotent label/comment behavior, and score thresholds were reviewed, and the submitted result remains the contributor's responsibility.

Summary by CodeRabbit

  • New Features
    • Added the Contributor Detection GitHub Action with configurable AI review, optional commenting, and high-risk failure behavior.
    • Introduced organization-blocking controls and a new blocked output (along with author, risk-level, risk-score, and report-json).
  • Documentation
    • Expanded README with detailed usage, required permissions, safety boundaries, and output descriptions.
  • Bug Fixes
    • Improved review label retention/clearing and refined automated contributor blocking behavior.
  • Tests
    • Added unit tests covering scoring, AI confidence gating, blocking decisions, and label handling.
  • Chores
    • Added a CI “Test” workflow and updated build artifact ignore rules.

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: dcf26926-a149-439d-b7b0-3f5d13101bee

📥 Commits

Reviewing files that changed from the base of the PR and between 99b23cd and 6504b51.

⛔ Files ignored due to path filters (1)
  • dist/index.mjs is excluded by !**/dist/**
📒 Files selected for processing (4)
  • README.md
  • action.yml
  • src/analyze.mjs
  • test/analyze.test.mjs
🚧 Files skipped from review as they are similar to previous changes (2)
  • README.md
  • test/analyze.test.mjs

📝 Walkthrough

Walkthrough

Adds a Node 24 GitHub Action definition, contributor risk scoring and enforcement policies, AI-review merging, label retention logic, documentation, project metadata, unit tests, a pull request fixture, and CI execution for pushes and pull requests.

Changes

Contributor trust action

Layer / File(s) Summary
Action contract and runtime
action.yml, package.json, .gitignore, README.md, .github/workflows/test.yml
Defines action inputs, outputs, Node 24 execution, project metadata, distribution tracking, usage instructions, output documentation, and automated test execution.
Contributor scoring and enforcement
src/analyze.mjs
Scores contributors using profile and activity signals, bypasses scoring for trusted associations, builds report facts, merges confidence-gated AI adjustments, retains review labels, and determines high-confidence automated-account blocking.
Analysis validation and fixtures
test/analyze.test.mjs, test/fixtures/pull_request.json
Tests scoring, trusted and bot-like cases, AI-review confidence handling, blocking policy, review-label retention, and adds a pull request fixture.

Estimated code review effort: 3 (Moderate) | ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding an evidence-first contributor trust GitHub Action.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/test.yml:
- Line 14: Update the actions/checkout step to disable credential persistence by
setting its persist-credentials input to false. Keep the existing checkout
action and workflow behavior unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e05a42ad-76e1-4204-b288-ffa81c3e95ed

📥 Commits

Reviewing files that changed from the base of the PR and between f3465cc and 262b8b5.

⛔ Files ignored due to path filters (1)
  • dist/index.mjs is excluded by !**/dist/**
📒 Files selected for processing (8)
  • .github/workflows/test.yml
  • .gitignore
  • README.md
  • action.yml
  • package.json
  • src/analyze.mjs
  • test/analyze.test.mjs
  • test/fixtures/pull_request.json

Comment thread .github/workflows/test.yml
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- uses: actions/checkout@v6
- uses: actions/checkout@v7

每个 action 都升级到最新版。

Comment thread README.md

on:
issues:
types: [opened]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
types: [opened]
types:
- opened

尽量不用 JSON 兼容语法,而用 YAML 原生风格,阅读起来更清晰。

Comment thread action.yml
Comment on lines +6 to +11
github-token:
description: GitHub token with read access and permission to comment or label.
required: true
organization-token:
description: Optional organization token with Blocking users write permission.
required: false

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

两个 token 合成一个吧,具体权限高低由用户自己传。

Comment thread action.yml
block-high-confidence-automation:
description: Block high-confidence automated user accounts when an organization token is provided.
required: false
default: 'false'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
default: 'false'
default: false

布尔值用原生类型,不要用字符串。

Comment thread action.yml
Comment on lines +28 to +31
fail-on-high-risk:
description: Fail the workflow when the report is high risk.
required: false
default: 'false'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

高风险不是应该报告吗?为什么要失败?

Comment thread package.json
Comment on lines +5 to +12
"type": "module",
"license": "LGPL-2.1-only",
"scripts": {
"test": "node --test"
},
"engines": {
"node": ">=24"
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"type": "module",
"license": "LGPL-2.1-only",
"scripts": {
"test": "node --test"
},
"engines": {
"node": ">=24"
}
"license": "LGPL-2.1-only",
"type": "module",
"engines": {
"node": ">=24"
},
"scripts": {
"test": "node --test"
}

Comment thread src/analyze.mjs
Comment on lines +3 to +5
function clamp(value, minimum, maximum) {
return Math.min(maximum, Math.max(minimum, value));
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
function clamp(value, minimum, maximum) {
return Math.min(maximum, Math.max(minimum, value));
}
const clamp = (value, minimum, maximum) => Math.min(maximum, Math.max(minimum, value));

返回语句前没有其它语句的时候,直接简化为箭头函数表达式。

Comment thread src/analyze.mjs
Comment on lines +88 to +89
score = clamp(score, 0, 100);
return {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
score = clamp(score, 0, 100);
return {
score = clamp(score, 0, 100);
return {

逻辑代码和返回语句之间也要留有必要空格。

Comment thread src/analyze.mjs
Comment on lines +120 to +121
if (!body.includes('<!-- contributor-trust:') || body.includes(ownMarker)) return false;
return /\*\*@[\w-]+:\s+(?:MEDIUM|HIGH)\s+\(\d+\/100\)\*\*/.test(body);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!body.includes('<!-- contributor-trust:') || body.includes(ownMarker)) return false;
return /\*\*@[\w-]+:\s+(?:MEDIUM|HIGH)\s+\(\d+\/100\)\*\*/.test(body);
return body.includes('<!-- contributor-trust:')
&& !body.includes(ownMarker)
&& /\*\*@[\w-]+:\s+(?:MEDIUM|HIGH)\s+\(\d+\/100\)\*\*/.test(body);

Comment thread test/analyze.test.mjs

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

测试文件改成 TypeScript 之后可以用 tsx 来执行。

@github-project-automation github-project-automation Bot moved this from Todo to In Progress in 开源项目 Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants