Fix the license screen for AI-written pull requests
Your task
You maintain an Apache-2.0 command line tool, and a contributor opened a pull request with a module an AI agent generated. A model can reproduce licensed code with no attribution, and GPL code inside your project would break the license your enterprise users depend on. So every pull request now goes through a license scan before it merges.
An assistant wrote screen_ai_contribution(matched_licenses, match_scores, has_attestation, threshold), which turns the scan report into a verdict. It is in the editor. It has a bug. Find it and fix it.
Input and output:
matched_licensesandmatch_scores: each license the scanner matched, and how strong the match is as a percent, at the same index.has_attestation: the contributor signed that they have the right to contribute the code under your license.threshold: a match counts only when its score is at least this.- Return one verdict:
reject_copyleft,manual_review,needs_attribution,needs_attestationoraccept.
Rules the tests check:
- If the two lists differ in length, return
manual_review. - Ignore matches that score below
threshold. - Uppercase the ASCII letters of each license id, then sort it into a family:
- copyleft: it starts with
AGPL,LGPL,GPLorSSPL - permissive: it starts with
MIT,BSD,ISC,APACHEorZLIB - unknown: anything else
- copyleft: it starts with
- Return the first of these that applies:
- Any counted match is copyleft:
reject_copyleft. - Any counted match is unknown:
manual_review. - Any counted match is permissive:
needs_attribution. - There is no attestation:
needs_attestation. - Otherwise:
accept.
- Any counted match is copyleft:
Examples
screen_ai_contribution(matched_licenses: list[str], match_scores: list[int], has_attestation: bool, threshold: int) -> strExample 1
Input
screen_ai_contribution(["MIT", "BSD-3-Clause"], [92, 40], True, 80)Output
"needs_attribution"Example 2
Input
screen_ai_contribution(["GPL-3.0"], [85], True, 80)Output
"reject_copyleft"