Skip to content
bezmoradiPublic

About

Behavior checks for code that AI coding agents change: YAML specifications in a protected folder, run by a trusted CI job against the built app, with a semantic diff that flags weakened checks. Go CLI with drivers for HTTP, WebSocket, browser, CLI, PostgreSQL, Redis, DynamoDB, SQS, SES, Docker and OpenTelemetry, HTTP fakes, and your own drivers.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Proctor

Every Proctor release keeps working as published. A new minor release may rename or remove a command, flag, configuration key, specification field or rule, a patch release breaks nothing, and older releases get no fixes. Your project names the release series it's written for (requires.proctor: "0.12"), or the lowest release of it with every feature it uses ("0.12.2"), and a release of another series, or an earlier one, refuses it, so a new release changes nothing for you until you install it and make the edits its release notes list (Requirements).

Proctor checks that an application still does what people agreed it should do, and refuses to report a pass when the agreement itself was quietly changed. It is for codebases where AI coding agents change the code, the tests and the test configuration in the same pull request.

  • The expected behavior lives in YAML specifications under a protected folder, and people approve changes to them through code-owner review.
  • A trusted CI job runs every listed scenario against the application built from the tested commit and records what it checked. Proctor approves nothing; GitHub's branch protection does, using Proctor's check and report as evidence.
  • Static integrity checks and a semantic diff of protected changes list weakenings first.
  • Official drivers:
    • Web and APIs: HTTP (with streams and binary, large and file bodies), gRPC (unary and streaming calls checked against your .proto files), WebSocket, a headless browser, and Model Context Protocol (MCP) servers.
    • Databases, read-only: PostgreSQL, MySQL and MariaDB, MongoDB, SQLite, Apache Cassandra, and Redis (with Pub/Sub).
    • Messaging: Kafka (producing, receiving without a consumer group, and reading a consumer group's lag) and RabbitMQ (publishing, subscribing to what is published, and reading a queue's depth).
    • AWS: DynamoDB, SQS, SES, and Lambda handlers running locally under the Runtime Interface Emulator.
    • Programs and files: command-line programs, one-shot jobs of Docker Compose services run in the image the binding pins, files (read-only, never following a link), Docker (read-only), and native desktop applications in an X11 session.
    • Telemetry and sign-in: OpenTelemetry and time-based one-time codes (TOTP).
    • Fakes: one fake driver reads what the application sent to proctor-sim, the local simulator for HTTP, WebSocket, gRPC, OpenID Connect, mail (SMTP and IMAP) and SES services, to a fake you write yourself in any language, or to a program it starts, through proctor-spy; proctor-sim otel receives its OpenTelemetry.
  • Your own drivers, in any language, can live in your repository.
  • Exact JSON assertions, text matchers, time-based checks with per-step timeouts, and tables whose rows run one step or several and can cover every combination, every pair or every value of declared dimensions.
  • The application-log check, approved transcripts, approved logs, mutation testing, and local runs split across several copies of the environment at once.
  • proctor version --features tells a wrapper what a build supports, and the release that brought each feature.

How it works

  • Protected inputs. The specifications, proctor.yaml and the files they name live under proctor/. That folder, .github/, .gitattributes, .gitmodules, .lfsconfig, CODEOWNERS and any protected_paths are protected inputs: a change to them needs a code owner's approval, and proctor diff lists it with weakenings, such as a removed assertion or an added waiver, first.
  • Local mode, for development: proctor validate checks the specifications without contacting the application, and proctor run starts the application with your environment scripts under environment in proctor.yaml, runs the specifications against it and stops it, on several instances at once with --instances N, or against one kept up between runs with proctor env up. Every local RESULT: line says local, non-authoritative.
  • Authoritative mode, for the trusted CI job: proctor run --authoritative reads every protected input from the tested commit, verifies the job's GitHub Actions identity, lists every protected change as "approval required", can start the environment with the base commit's scripts, and with the tested commit's only once a code owner approved its head (--base-environment), and writes the JSON report and job summary that the required check and the reviewers rely on. See Authoritative mode.

The cheap way out, caught

An agent told to make a failing run pass can change the specifications instead of the application. Each shortcut below was made in a scratch repository, and the right column is what proctor diff printed for it. Every change under proctor/ needs a code owner's approval, weakening or not; weakenings are listed first. Coding agents shows the agent the same lines before it pushes.

Shortcut What proctor diff lists
Remove an assertion assertion_removed (1 assertion(s) lost): equal $.body.role is no longer asserted
Loosen equal to present assertion_weakened: equal $.body.error became present $.body.error
Delete the read that checks an act, and waive the check step_removed (3 assertion(s) lost) and rule_waived: EXE-07 waived: <reason>
Move a check into setup step_moved_to_setup (2 assertion(s) lost)
Give a step a longer timeout step_timeout_longer: timeout 9s added
Let a read retry until it passes time_check_changed: (none) became eventually within 60s every 1s
Delete a scenario scenario_removed (2 assertion(s) lost)
Add a scenario that waives its checks rule_waived: the scenario is added with EXE-07 waived and rule_waived: … with EXE-09 waived
Point a step at a fake driver_changed: do http.request became sim.request
Expect what the application now returns USR-002 read equal $.status: 404 -> 500, a changed expectation, not a weakening
Edit an approved transcript approved transcript proctor/approved/users/USR-002.transcript.yaml: … 2 lines changed (-1 +1), a changed expectation
Change the binding the up script writes modified proctor/env/up.sh approval required, a protected change

Leaving a specification out of the manifest isn't in the table, because validate and run refuse it before anything runs (INT-05).

Install

curl -fsSL https://github.com/bezmoradi/proctor/releases/latest/download/install.sh | sh

The script runs on linux and darwin, amd64 and arm64, checks the archive's SHA-256, and installs proctor, its drivers, the simulators, proctor-sandbox and proctor-spy into ~/.local/bin. Installation covers verifying the script first, other folders, updating, pinning a release in CI and requires.

Quick start

With Proctor installed, from your application's repository root:

proctor init

It writes a starting proctor/ folder with five files and prints the next steps, with links to the CI setup and to instructions for coding agents. It reads no Git and contacts nothing. It refuses (exit 3) when any of the five files exists, when proctor/ or a folder in it is a symbolic link or not a folder, and when run below a Git repository's root; it writes nothing when it fails (exit 2). In a folder named my-api:

# proctor/proctor.yaml
project: my-api
manifest: manifest.yaml
requires:
  proctor: "0.12"   # the lowest release with every feature these files use, in the series of the proctor that ran init
drivers:
  http: { official: http }
identities:
  anonymous: { type: none }
environment:
  up: env/up.sh
  down: env/down.sh
# proctor/manifest.yaml
specifications:
  - id: health
    path: specs/health.yaml
# proctor/specs/health.yaml
scenarios:
  - id: HLT-001
    name: The application answers its health check
    steps:
      - id: ready
        do: http.request
        identity: anonymous
        with:
          method: GET
          path: /readyz
        expect:
          equal:
            $.status: 200
            $.body.status: ok

The scenario claims that GET /readyz answers 200 with the JSON body {"status": "ok"}. Change that claim to what your application's health endpoint answers: a 2xx step must claim what the response holds (EXE-03), and the run fails until the claim matches. proctor run runs the environment's up script before the scenarios and its down script after them. The up that init writes starts nothing: it writes the binding, which tells Proctor where the application runs, and down does nothing. proctor/env/up.sh:

#!/bin/sh
set -eu
cat >"$PROCTOR_INSTANCE_DIR/binding.yaml" <<'EOF'
environment: local
drivers:
  http:
    base_url: http://127.0.0.1:8080
    user_agent: proctor-local/0
    ready_path: /readyz
EOF

--project, --base-url and --ready-path set project, base_url, and both ready_path and the scenario's path. Then, from the repository root, with the application running at that address:

proctor validate
proctor run

When you'd rather have each run start and stop the application, make up.sh start it before it writes the binding and down.sh stop it; Environments shows a pair that does, and a CI job starts the environment from the same scripts.

validate needs neither the application nor Git: in a folder that isn't in a Git repository it reads the files as they are and says not a Git repository: the folder was read as it is ("git": false with --json); with --commit it needs Git, and so does every other command that reads the repository. The run waits for /readyz (set ready_path to your application's health endpoint), executes every listed scenario and prints RESULT: PASSED (exit 0, local, non-authoritative) when they all pass, which for the starting scenario holds once its claim matches what your health endpoint answers. Add --json for the machine-readable report. When one doesn't, Reading a failed run says what to read first and what to change.

To see Proctor working before you adopt it, follow examples/sample/README.md. It starts a users API with PostgreSQL, Kafka and OpenTelemetry in Docker Compose, checks it with official drivers, breaks one agreed behavior to show the failing scenario, and runs the mutants. CI runs it on every pull request.

Next, say what the application does. This specification creates a user and reads it back; list it in the manifest as - { id: users, path: specs/users.yaml }:

# proctor/specs/users.yaml
scenarios:
  - id: USR-001
    name: A created user can be read back
    steps:
      - id: create
        do: http.request
        identity: anonymous
        with:
          method: POST
          path: /api/v1/users
          body: { name: "Ada ${run.id}" }
        expect:
          equal:
            $.status: 201
            $.body.message: Created user successfully
        save: { user_id: $.body.data }
      - id: read
        do: http.request
        identity: anonymous
        with:
          method: GET
          path: "/api/v1/users/${user_id}"
        expect:
          equal:
            $.status: 200
            $.body.data.id: "${user_id}"
            $.body.data.name: "Ada ${run.id}"

For CI, see Authoritative mode and examples/github/.

Documentation

docs/README.md lists every page:

  • Concepts: the vocabulary and the model behind the checks.
  • Installation: how to install, verify, update and pin a release.
  • examples/sample/: a users API checked end to end, to see Proctor working.
  • Writing specifications: scenarios, tables, cleanup, invariants, fixtures and the log check.
  • Reading a failed run: what to read first when a run doesn't pass, and what to change.
  • Approved transcripts and logs: approve a scenario's story or log once, and compare later runs with it.
  • Environments: writing prepare, up and down in plain shell, one pair for your machine and CI.
  • Parallel instances: one run split across several copies of the environment.
  • Mutation testing: how to check that the specifications catch the defects you declare.
  • Repository drivers: your own driver, in any language, kept in the repository and run from the base commit in authoritative mode.
  • Coding agents: instructions to paste into AGENTS.md or CLAUDE.md, warn an agent of a weakening before it pushes, and teach agents Proctor with the plugin's skill.
  • Authoritative mode: the trusted CI job, and how GitHub must be configured for it.
  • examples/github/: the reference workflows, CODEOWNERS file, environment scripts and branch protection settings, which CI runs against a small application.
  • Commands: every command, flag and default.
  • Configuration: proctor.yaml, the binding and the environment variables.
  • Specification format: validation rules, matchers, paths, references and state checks.
  • Drivers: every official driver and simulator in one line, with a page per family for its operations and limits.
  • Driver protocol: the messages a driver in any language answers on stdin and stdout, the version handshake and what Proctor does with each answer.
  • Features: every feature proctor version --features lists.
  • Rules: every rule ID a message can name, such as EXE-14, and what it refuses.
  • Reports and exit codes: exit codes, result reasons and what each JSON report holds.
  • proctor diff: every kind of change it lists, and which ones are weakenings.
  • Security model: what Proctor enforces and assumes, and what it reads, writes and sends.
  • Architecture: how a run flows, the packages and the repository's layout.
  • Development: working on Proctor itself: building, the self-check and releasing.

Author

This project is maintained by Bez Moradi.

License

Proctor is licensed under MIT.

About

Behavior checks for code that AI coding agents change: YAML specifications in a protected folder, run by a trusted CI job against the built app, with a semantic diff that flags weakened checks. Go CLI with drivers for HTTP, WebSocket, browser, CLI, PostgreSQL, Redis, DynamoDB, SQS, SES, Docker and OpenTelemetry, HTTP fakes, and your own drivers.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages