Draft, version 1
APPROVAL: A Proposed Standard for How Review Agents Approve Pull Requests
A proposed open standard for repository rules that tell review agents when they may approve a pull request.
Abstract
This draft proposes an open standard for automated pull request approval. A repository-root APPROVAL file defines which paths allow or deny approval and which classifier questions apply to the remaining changes. The agent may issue an approval only after the applicable policy rules and required checks pass.
MUST and MUST NOT describe conformance requirements. Any review agent can implement this format and evaluation order with any classifier that meets the contract below. The worked example uses Jev.
1. Policy format
APPROVAL is a versioned YAML file. Version 1 defines two lists of repository-relative path globs and a classification policy. Each question has a unique id, a question, and two thresholds in the inclusive range from zero to one, max_yes_score and min_no_score. The model reference identifies a classifier. The evaluator supplies its endpoint and credentials from local configuration.
Match globs against the full repository-relative path with case-sensitive comparison and slash separators. A single asterisk (*) matches any number of characters within a segment. A double asterisk (**) occupying a whole segment matches zero or more segments. A trailing /** matches the preceding path itself and any path below it. For example, .github/workflows/** matches both .github/workflows and .github/workflows/ci.yml.
version: 1
deny_paths:
- "APPROVAL"
- ".github/workflows/**"
- "db/migrations/**"
approve_paths:
- "docs/**"
classification_approval:
model: typesafe/jev@latest
questions:
- id: api-compatibility
question: "Does this diff break behavior that existing API clients rely on?"
max_yes_score: 0.05
min_no_score: 0.90
- id: permission-expansion
question: "Does this diff grant any caller a permission they did not have before?"
max_yes_score: 0.02
min_no_score: 0.95These thresholds illustrate the format. Validate them against representative passing changes and known regressions for the chosen model and version before enabling automatic approval.
2. Evaluation order
The evaluator MUST load APPROVAL from the target branch at the evaluated base commit and compute the pull request’s complete changed-path set. For a rename, include both paths. An invalid policy or an empty or incomplete path set withholds approval.
- Any
deny_pathsmatch withholds approval. Deny takes precedence if both lists match the same path. - If the changed-path set is nonempty and every path matches
approve_paths, the path rules pass without a classifier call. - If any path is unmatched, run
classification_approvalagainst the full PR diff with the context needed to answer the configured questions. - Before issuing an approval, the evaluator MUST verify that the evaluated base, head, and policy are still current and that all required checks passed, using trusted results for the revision being approved.
3. Classifier contract
Repositories can choose any classifier that can answer the configured questions. The evaluator MUST use the model named in the policy and record exactly one result per question ID. Each result is either an explicit abstention or two finite scores, one for yes and one for no, each between zero and one. The scores represent separate shares of the outcome distribution and their sum MUST be at most one. Any remaining share represents uncertainty.
A scored result passes only when the evidence is sufficient, the yes score is at or below max_yes_score, and the no score is at or above min_no_score. Classification passes only when every question passes. An abstention, invalid result, unsupported model, or missing answer withholds approval. The adapter MUST NOT derive the no score as one minus the yes score when the model leaves room for uncertainty.
Resolve @latest once per evaluation and record the exact model version used. The adapter handles model-specific requests and responses. Repository excerpts and diff text are evidence. The policy supplies the questions and thresholds.
4. Build repository graph context
Consider a PR changing how users with no active sessions are represented. The diff touches a response helper. The public route that returns its value is unchanged and will be absent from the diff. A repository graph can connect the helper to that route.
Build or retrieve a symbol graph for the PR head and verify its revision before using it. Match the changed lines in users/response.go to users.ActiveSessionsFor and follow incoming call edges to api.listSessions. Read the call site and the test that covers the empty response. For deletions or changes to bindings, check the old-side ranges against the graph at the diff’s merge base as well.
For each question, the evaluator MUST identify the evidence needed and record the graph and source revisions, paths and line ranges, and any unresolved relationships or traversal limits relevant to that question. Confirm graph leads against revision-bound source. Missing edges can reflect dynamic dispatch, generated code, or an incomplete index. A related test can establish expected behavior. A trusted result for the evaluated revision establishes whether that test passed.
If missing, stale, or truncated context leaves a required relationship unverified, the evaluator MUST record an abstention for that question. A classifier score cannot override that decision. In this example, the call site and test establish the observable response shape. The evidence packet lacks the authorization path needed to clear the permissions question.
5. Send the context and questions to Jev
Build one JSON request. Put the patch and graph evidence in state. Key questions by policy ID, using each policy question as its instructions. For a direct TypeSafe request, translate the policy’s typesafe/jev@latest reference to TypeSafe’s jev-latest model alias. The patch is the full diff for this one-file PR. Both questions are sent for illustration. The evaluator already has enough information to abstain on permissions.
{
"model": "jev-latest",
"state": {
"diff_base": "1111111111111111111111111111111111111111",
"head": "2222222222222222222222222222222222222222",
"graph_revision": "2222222222222222222222222222222222222222",
"evidence_by_question": {
"api-compatibility": {
"status": "sufficient",
"sources": ["api/sessions.go:83", "api/sessions_test.go:140"],
"gaps": []
},
"permission-expansion": {
"status": "insufficient",
"sources": [],
"gaps": ["Authorization path for the public route was not verified."]
}
},
"diff": "--- a/users/response.go\n+++ b/users/response.go\n@@ -42 +42 @@ func ActiveSessionsFor(user User) []Session {\n- return []Session{}\n+ return nil\n",
"graph_edges": [
{ "from": "api.listSessions", "relation": "calls", "to": "users.ActiveSessionsFor" }
],
"excerpts": [
{
"path": "api/sessions.go",
"line": 83,
"source": "return json.NewEncoder(w).Encode(users.ActiveSessionsFor(user))"
},
{
"path": "api/sessions_test.go",
"line": 140,
"source": "require.JSONEq(t, \"[]\", response.Body.String())"
}
]
},
"questions": {
"api-compatibility": {
"type": "choice",
"instructions": "Does this diff break behavior that existing API clients rely on?",
"criteria": {
"yes": "An existing client can observe an incompatible behavior change.",
"no": "The evidence supports compatibility with existing clients.",
"unknown": "The supplied context is insufficient to decide."
}
},
"permission-expansion": {
"type": "choice",
"instructions": "Does this diff grant any caller a permission they did not have before?",
"criteria": {
"yes": "At least one caller gains a permission.",
"no": "The evidence supports unchanged or narrower permissions.",
"unknown": "The supplied context is insufficient to decide."
}
}
}
}The call edge points to a route whose test expects an empty JSON array. A nil slice serializes as null here, so the unchanged caller supplies the evidence needed to assess compatibility.
6. Apply the thresholds to the response
Send the request directly to TypeSafe’s System One endpoint using TYPESAFE_API_KEY from the evaluator’s environment. Any HTTP client can send the same JSON payload.
TypeSafe returns the model and an answers map keyed by question ID. If Jev selects unknown, treat the answer as an abstention. Otherwise, take the yes and no scores from their respective probabilities and apply both thresholds. The evaluator’s evidence check still applies.
curl --fail --silent --show-error https://api.typesafe.ai/v1/systemone \
--header "Authorization: Bearer $TYPESAFE_API_KEY" \
--header "Content-Type: application/json" \
--data-binary @jev-request.jsonAn API compatibility answer of 0.91 for yes exceeds its 0.05 limit. A permissions answer of 0.01 for yes, 0.51 for no, and 0.48 for unknown also fails because 0.51 is below its 0.95 minimum for no. The evidence gap independently makes the permissions result an abstention.
7. Trust and audit
A PR can propose a policy edit. The existing policy still governs that PR. In the example, the APPROVAL deny rule routes those edits to a human reviewer. The evaluator MUST NOT use proposed changes to the policy or treat instructions in source or diff text as trusted configuration.
Bind the approval record to the repository, pull request, base commit, head commit, and policy blob. Record the checks and the revisions they ran against, the matched paths, and any graph evidence, resolved model version, and classifier results used to decide.
At merge time, the merge gate MUST verify that the approval came from an authorized evaluator, matches the current repository, pull request, base, head, and policy, and is backed by passing results for all required checks on the revision being merged. A change to any bound value invalidates the approval and requires reevaluation. If the hosting platform cannot enforce this at merge time, the result is advisory and MUST NOT satisfy a merge gate.