Skip to main content

A CI Gate Without an LLM

Why This Matters

Everything so far happened in a chat: the plan was approved, the tests were generated and verified, the heals were checked. But the chat is not where the decision is made. The decision is made when code is merged and released, by a pipeline, and nothing stops a developer from editing a generated test by hand, merging a test whose plan was never approved, or pushing a test that was never verified.

The CI gate closes that gap. npx selenium-ai-agent gate reads the plans, the manifest and the test files, and fails the build when a test is not what was approved and verified. It uses no LLM: no tokens, no network to an AI, the same answer every time. Then --run runs the suite as plain test code. This is guardrail 7 from lesson 4.

What you will learn

  • What the gate checks, per test
  • Real gate output under explore, guided and strict
  • What makes it fail: an unverified test, a hand edit, a changed plan, a draft plan
  • A GitHub Actions workflow with the gate
  • Why the gate has no AI in it

What the gate checks

For every test in .test-manifest.json:

CheckFails when
filethe test is listed but not on disk
planthe linked plan is gone, or not approved (a draft, changes requested, no status); or no plan is linked
spec lockthe plan changed since the test was written (guided: warning, strict: failure)
contentthe file changed since the generator or healer last wrote it (guided: warning, strict: failure)
verifiedthe profile requires verification and the test was never verified, was verified with fewer runs than the profile needs, or changed since
selenium rulesthe file has a rule error (lesson 13) (explore: warning)
locked locators(strict only) the file uses a locator outside the locked set (lesson 12)

The levels depend on the profile. Under explore almost everything is a warning: the gate informs but doesn’t block.

The gate at work

A small project with three tests from an approved plan:

  • test_add_from_grid.py: generated and verified with 3 runs and 3 mutants.
  • test_out_of_stock.py: generated, never verified.
  • test_totals_two_products.py: generated and verified, then edited by hand: someone changed the expected tax from $60.90 to $60.89 to make a red build green.

Real output, under each profile.

explore: informs, passes.

$ npx selenium-ai-agent gate --profile=explore
Selenium AI Agent gate — profile: explore

PASS  tests/cart/test_add_from_grid.py
PASS  tests/cart/test_out_of_stock.py
WARN  tests/checkout/test_totals_two_products.py
      WARN content: changed outside the agent since it was last written: review the change, then verify the test again

3 test(s): 2 pass, 1 warn, 0 fail — gate passed

guided: the unverified test and the hand edit fail the build.

$ npx selenium-ai-agent gate --profile=guided
Selenium AI Agent gate — profile: guided

PASS  tests/cart/test_add_from_grid.py
FAIL  tests/cart/test_out_of_stock.py
      FAIL verified: never verified: run verify_test_stability
FAIL  tests/checkout/test_totals_two_products.py
      WARN content: changed outside the agent since it was last written: review the change, then verify the test again
      FAIL verified: the file changed since it was verified: run verify_test_stability again

3 test(s): 1 pass, 0 warn, 2 fail — gate FAILED

The hand edit itself is a warning under guided (people may edit tests), but the edited test is no longer verified, and that fails.

strict: every gap fails, including a test that was verified with fewer runs than strict asks.

$ npx selenium-ai-agent gate --profile=strict
Selenium AI Agent gate — profile: strict

FAIL  tests/cart/test_add_from_grid.py
      FAIL verified: verified with 3 runs, the profile needs 5
FAIL  tests/cart/test_out_of_stock.py
      FAIL verified: never verified: run verify_test_stability
FAIL  tests/checkout/test_totals_two_products.py
      FAIL content: changed outside the agent since it was last written: review the change, then verify the test again
      FAIL verified: the file changed since it was verified: run verify_test_stability again

3 test(s): 0 pass, 0 warn, 3 fail — gate FAILED

The exit code is 1 when the gate fails, so any CI system stops the pipeline.

A changed plan, and a draft plan

Someone changes the expected total in scenario 1.1 of the plan, after the tests were written:

$ npx selenium-ai-agent gate --profile=strict
FAIL  tests/cart/test_add_from_grid.py
      FAIL spec lock: the plan changed since the test was written: regenerate the test from the approved plan
      ...
FAIL  tests/cart/test_out_of_stock.py
      FAIL spec lock: the plan changed since the test was written: regenerate the test from the approved plan

Notice that every test from the plan is flagged, also test_out_of_stock.py, whose scenario didn’t change. The spec lock hashes the whole plan: a changed plan means its tests are re-checked against it. Under guided these lines are warnings.

And when the plan is reopened for review (a draft again):

$ npx selenium-ai-agent gate --profile=guided
FAIL  tests/cart/test_add_from_grid.py
      FAIL plan: shopping-cart-and-checkout.md is draft

The gate in GitHub Actions

# .github/workflows/e2e.yml
name: E2E tests
on: [pull_request, push]

jobs:
  e2e:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with: { python-version: "3.12" }
      - uses: actions/setup-node@v4
        with: { node-version: "20" }
      - run: pip install -r requirements.txt     # selenium, pytest
      - name: Gate and run (no LLM)
        run: npx selenium-ai-agent gate --run --profile=strict
        env:
          HEADLESS: "1"                            # the seed adds --headless=new
      - uses: actions/upload-artifact@v4
        if: always()
        with:
          name: e2e-reports
          path: reports/

--run first runs the gate; only when it passes does it run the suite with the manifest’s run command (pytest -v --junitxml=reports/junit.xml for the shop) and exit with the suite’s exit code. GitHub’s Ubuntu runners have Chrome installed, and Selenium Manager fetches the matching driver.

A few practical points:

  • Commit what the gate reads: specs/, the tests, .test-manifest.json, .selenium-agent.json, and locators.json and selector-hints.json if you use them. The manifest holds the hashes the gate compares with.
  • Profile in CI. --profile=strict in the pipeline while the team works under guided locally is a common setup: developers get warnings early, the main branch gets the strict check.
  • Fresh checkouts. The manifest stores absolute paths from the machine the tests were generated on; the gate reads them relative to where the manifest is now, so a CI checkout in another folder (or on another OS) works. Use 3.9.1 or later: 3.9.0 reported every test as missing in a fresh checkout.
  • --json prints the report as JSON, for a dashboard or a pull-request comment.

Why no AI in the gate

It would be easy to let an AI review the tests in CI. Selenium AI Agent deliberately doesn’t:

  • Determinism. A gate that says pass today and fail tomorrow on the same commit is worse than no gate. Hashes, rule patterns and run results give the same answer every time.
  • No way to talk it round. An AI reviewer can be persuaded by a comment in the code (“this assertion was approved by the PO”). A hash comparison can’t.
  • Cost and access. No tokens per build, no API keys in the pipeline, no test data sent to a model.
  • Accountability. When the gate fails, the reason is a fact: never verified, changed outside the agent, plan is draft. The fix is a human action: verify, review, approve.

The AI does its work earlier, in the chat, where a person is present. The pipeline only checks that the result is what that person approved.

Exercise

In your project (with the tests from earlier lessons):

  1. Run npx selenium-ai-agent gate under your current profile. Which tests pass, which don’t, and why?
  2. Edit one generated test by hand (change a comment). Run the gate under guided and under strict. What is the difference?
  3. Verify that test again with verify_test_stability. Run the gate under guided. Is it green now? And under strict?
Show suggested answer
  1. Tests that were verified under the current profile’s run count pass; tests never verified fail under guided and strict; under explore the gate passes with warnings.
  2. Under guided the edit is a warning (content: changed outside the agent), but the test fails on verified: the file changed since it was verified. Under strict both are failures.
  3. After verifying, verified is ok again (a new hash is stored). Under guided the test passes, possibly with the content warning: the agent did not write this version, so the gate keeps telling you it was edited by hand until the generator or healer writes the file again. Under strict the content check still fails: in strict, only the agent writes tests. Regenerate it, or let the healer write the change, and verify.

Exam-style questions

Quiz

1. Why does the CI gate use no LLM?

  • A. LLMs can’t read test files
  • B. So the result is deterministic, can’t be argued with, and needs no tokens or API keys in the pipeline
  • C. Because CI machines have no internet
  • D. Because the gate runs before the tests
Show answer
B.
Quiz

2. Under guided, a test was edited by hand after it was verified. What does the gate report?

  • A. Nothing: hand edits are allowed
  • B. A warning for the edit, and a failure because the test is no longer verified
  • C. A failure for the edit only
  • D. It deletes the test
Show answer
B.
Quiz

3. One scenario in a plan is changed. Under strict, which tests does the gate flag with the spec lock?

  • A. Only the test of the changed scenario
  • B. Every test generated from that plan, because the whole plan is hashed
  • C. None until the plan is approved again
  • D. All tests in the project
Show answer
B.