Decide when an agent may merge a dependency upgrade
Your task
An agent keeps your dependencies current: it opens one upgrade pull request per package and runs the checks. Then it has to decide whether to merge alone, wait for a person, or stop.
Write classify_dependency_upgrade(current_version, next_version, coverage_percent, touches_sensitive_area, has_breaking_note, checks_passed): the rule your agent follows for each upgrade.
current_version,next_version(str): versions writtenmajor.minor.patchin whole numbers, for example"1.4.2".coverage_percent(int, 0 to 100): test coverage of the code that imports the package.touches_sensitive_area(bool): the package is used for auth, crypto, serialization or build tooling.has_breaking_note(bool): the release notes announce a breaking change.checks_passed(bool): tests, type checks and the canary (a small trial deploy) all passed.
It returns "auto_merge", "needs_human" or "blocked". Apply these rules in order. The first one that matches decides:
next_versionis not newer thancurrent_version(the same, or a downgrade):"blocked". Compare the 3 parts as numbers, left to right, so10.2.10is newer than10.2.3.checks_passedis false:"blocked".touches_sensitive_areaorhas_breaking_note:"needs_human".- The major or minor number changed:
"needs_human". Only a patch bump can merge alone. coverage_percentbelow 80:"needs_human".- Otherwise:
"auto_merge".
Then, in a sentence or two: why should coverage, and not just a green run, decide what merges alone?
Examples
classify_dependency_upgrade(current_version: str, next_version: str, coverage_percent: int, touches_sensitive_area: bool, has_breaking_note: bool, checks_passed: bool) -> strExample 1
Input
classify_dependency_upgrade("1.4.2", "1.4.3", 92, False, False, True)Output
"auto_merge"Example 2
Input
classify_dependency_upgrade("1.4.2", "1.5.0", 92, False, False, True)Output
"needs_human"Example 3
Input
classify_dependency_upgrade("2.0.1", "2.0.2", 95, False, False, False)Output
"blocked"