# Checks

> Turn your architecture and compliance rules into checks that every pull request is graded against.

Every team has rules about its code: handlers never touch the database
directly, personal data never reaches a log line, crypto lives in one place.
Most of them live in a wiki page or in one senior engineer's head, and they
are enforced only when a reviewer happens to notice. **Checks** turn those
rules into something Abstraction enforces for you, on every pull request and
across the whole codebase, with the evidence to show for it.

## What a check is

A **check** is a named rule about your code that Abstraction evaluates
automatically. Each check holds one or more **steps**. A step is a single rule
of one type, with its own severity, and all of a check's steps report under the
check's name.

Checks run in two places, so they catch a rule being broken and tell you where
it already is:

- **PR reviews** — checks run against the pull request when it is reviewed.
  Results appear in the report's **Checks** section and as a GitHub check run
  on the pull request, and failed checks are counted on the card in the PR
  Reviews list, so a violation is visible before anyone approves.
- **Workspace updates** — when the workspace is rebuilt from its tracked
  branches, checks run against the whole codebase. Results appear on the
  **Checks** page, so you can watch how the codebase stands against your rules
  over time, and prove it when someone asks.

Each step chooses where it runs with **Runs on**: **Everywhere**, **PR diffs**,
or **Workspace updates**. Some step types only make sense in one of the two;
the editor tells you when a step's type narrows the choice.

## Step types

### Rules

When you add a step you pick one of two rule types. These are the steps that
pass or fail.

- **AQL Query** — an assertion written in AQL, Abstraction's query language
  over the analyzed code graph: functions and the roles they play, the data
  their parameters and variables carry, and the calls between them. Because it
  runs on the graph rather than on text, it reasons about what code reaches,
  not just what it mentions. The step fails when the assertion doesn't hold,
  and the result shows the failing assertion together with counter-examples,
  the concrete code that violated it. Runs on PR diffs and workspace updates.
- **Agent Check** — an LLM agent that answers a custom question about the
  changes, for rules AQL can't express. You write the question and pick a model
  and a thinking effort. Because it judges a change, it runs on PR diffs only.

Two example rules show the shape. This one, trimmed from the ready-made
Entrypoint security check, requires every request handler to reach an
authorization check:

```aql
let handlers = functions()
  .filterRole(Role.HTTPHandler, Role.RPCHandler);
duringCallsTo(handlers)
  .assertCalls(functions().filterRole(Role.AuthCheck));
```

This one keeps personal data out of logs:

```aql
let pii = parameters().filterTag(Tag.Name, Tag.Email, Tag.Phone);
duringCallsTo(functions().filterHasParam(pii))
  .assertNeverCalls(functions().filterRole(Role.Logger));
```

### Built-in review steps

The review report itself is written by steps of the built-in **System**
check, which is on for every workspace and maintained by Abstraction. You
can't add these step types to your own checks. They don't pass or fail, so
severity doesn't apply to them.

- **Diff Summary** — the report's overview: stats, impact, verdict, and change
  summary.
- **Logic Review** — a per-function review of every changed function in the
  diff.
- **Agent Review** — an agentic gate that verifies the logic review's findings
  and filters out false positives.

## Severity

A step that reports a verdict has a severity, which decides what a failure
means for the pull request:

- **Error** — a failing step fails the GitHub check run.
- **Warning** — the failure is reported and the check run ends neutral, so it
  doesn't block a merge.
- **Info** — the failure is noted in the review and never affects the check
  run.

## Scope

A check's **Scope** applies to every step in it and decides which pull requests
it runs on. Leave it empty to run on every change, or narrow it with any
combination of:

- **Paths** — up to 10 folders or files. The check runs only when the pull
  request changed a matching file.
- **File types** — Go, Python, TypeScript, and so on.
- **Entity tags** — the check runs only when the change touched a definition
  holding a variable tagged with one of the selected tags, such as Email,
  Password, or Payment card.
- **Function roles** — the check runs only when the change touched a function
  carrying one of the selected roles, such as HTTP handler, Database writer, or
  Auth check.

The **Scope preview** beside the editor shows which of the workspace's files
the path and file-type filters currently match. Scope gates pull requests
only; on a workspace update the check always runs.

## The Checks page

Select **Checks** in the sidebar. The **Overview** shows the outcome of the
latest workspace update or check run: which checks pass, which need attention,
how many findings each produced, and what is new since the previous update.
The packages with the most findings are listed so you can see where the rules
are being broken. Workspace admins and editors are also offered the ready-made checks the
workspace hasn't turned on yet (see below).

Select a check in the sidebar to open it. You see its steps and scope, its
latest results with every finding, and a history strip with one bar per
workspace update that ran it, so a check that keeps drifting is easy to spot.
From here a workspace admin or editor can edit or delete the check, or select **Run now**
to evaluate it against the workspace's current analysis. A run like this
returns results straight away without recording them; an Agent Check step
judges the codebase as it stands, since there is no diff. The **Run all
checks** button on the Overview lets an admin or editor run every check that runs on
workspace updates, either without recording or recording the results in
history. Any finding, or the check itself, can be handed to Astrid with **Ask
Astrid**.

## Add a check

You need to be a workspace admin or editor. Open **Checks** and select **New check**:

1. Give the check a **name**, for example "No credentials in code".
2. Set its **Scope**, or leave it empty.
3. Select **Add step**, pick a type, and fill in its settings — the AQL query,
   or the agent's question, model, and thinking effort.
4. Set the step's **Severity** and **Runs on**. Optionally give it a **step
   name** and a **comment** explaining why the rule exists; the comment is shown
   to teammates alongside the result.
5. Add more steps if the rule has several parts, then select **Create
   check**.

The check is enabled as soon as it is saved. Use its switch to turn it off
without deleting it.

## Ready-made checks

You don't have to start from a blank page. Abstraction ships a growing library
of ready-made checks built on the same analysis, covering the rules most teams
want enforced but rarely get around to automating. A few examples:

- **GDPR compliance** — personal data is never sent to third parties, no
  shadow copies of it are written to files or events, and special-category
  data is encrypted before it is persisted.
- **Entrypoint security** — every HTTP, RPC, and GraphQL handler reaches an
  authorization check, and HTTP handlers sanitize input before deserializing
  it.
- **Test isolation** — nothing reachable from a program entrypoint calls test
  or benchmark code.

There are more, and the library is updated continuously as new analysis
capabilities land. Suggested checks appear on the Overview until you turn one
on with a single click; from then on it is copied into your workspace and is
yours to edit like any other.

## Ask Astrid to write a check

You don't have to write AQL yourself. In the [Assistant](https://docs.abstraction.dev/web/assistant.md),
describe the rule you want enforced in plain language, such as "handlers must
never call the database directly". Astrid reads the codebase, drafts the check,
and shows it as a proposal card. You can adjust every field before approving
it, and nothing is saved until you do. Astrid can also list your existing
checks and propose edits to or deletion of one. Going from "we should really
enforce this" to an enforced rule takes one conversation.

## Results on GitHub

Each check reports as its own GitHub check run on the pull request, named
after the check and the workspace, alongside the overall review run. For a
workspace called Payments with a check called No PII in logs, the pull request
shows:

- `Abstraction Review · Payments` — the review itself
- `Abstraction · No PII in logs · Payments` — the check

A check with no findings passes. A failing step with **Warning** severity
leaves the run neutral, and one with **Error** severity fails it. Add a check
to your branch protection and the rule becomes a merge requirement, not a
review suggestion. A check whose scope didn't match the pull request is
reported as skipped. A completed check run links back to the report's Checks
section, where you can also re-run a single check on the review.

## Manage checks from your agent

The [MCP server](https://docs.abstraction.dev/mcp/setup.md) exposes the same checks to coding agents.
Any workspace member's agent can list checks and read the latest results,
including what is new since the previous update, and each check's history. A
workspace admin's or editor's agent can also try a check definition against the
current analysis before saving it, create, update, enable, or delete checks, and
run every check that runs on workspace updates, optionally recording the
results.

## Next steps

- [Reviews on GitHub](https://docs.abstraction.dev/code-review/github.md)
- [Reviewing pull requests in the web app](https://docs.abstraction.dev/web/reviewing-pull-requests.md)
- [Chatting with Astrid](https://docs.abstraction.dev/web/assistant.md)
