Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions .github/workflows/self-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Self-tests

on:
push:
branches: [main]
pull_request:

permissions:
contents: read

jobs:
self-tests:
# The owner runs on Windows and the self-tests take both the Windows and the
# POSIX paths, so each is proved on its own runner.
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
env:
BENCHMARK_TEMPLATES: ${{ github.workspace }}/solid-ai-templates
steps:
- uses: actions/checkout@v4
with:
path: solid-ai-benchmark

# The benchmark carries no templates, so every self-test names a clone of
# them. A self-test makes no model call, so it needs no secret.
- uses: actions/checkout@v4
with:
repository: solid-ai-dev/solid-ai-templates
path: solid-ai-templates
# The arms are built from registered tags, such as the baseline's
# v2.90.0, so the clone needs its full history and tags.
fetch-depth: 0

# The interpreter every scored trial runs under.
- uses: actions/setup-python@v5
with:
python-version: "3.12"

# The self-tests commit in scratch workspaces, which needs an identity.
- name: Configure git
run: |
git config --global user.name "CI"
git config --global user.email "ci@example.invalid"

# The self-tests build a trial's command line, which resolves the agent CLIs
# on PATH, but never launch one. Stubs that refuse to run stand in for them,
# so no model can be called.
- name: Put stub agent CLIs on PATH
run: |
stubs="$RUNNER_TEMP/stub-cli"
mkdir -p "$stubs"
for cli in claude codex; do
printf '#!/bin/sh\necho "%s is a CI stub" >&2\nexit 1\n' "$cli" \
> "$stubs/$cli"
chmod +x "$stubs/$cli"
printf '@echo %s is a CI stub 1>&2\r\n@exit /b 1\r\n' "$cli" \
> "$stubs/$cli.cmd"
done
echo "$stubs" >> "$GITHUB_PATH"

- name: Install pyflakes
run: python -m pip install --disable-pip-version-check pyflakes

- name: Run every self-test
working-directory: solid-ai-benchmark
run: |
set -e
for module in harness generate_arm score judge report archive reuse \
security control/control; do
echo "::group::$module"
python "tests/efficacy/$module.py" --self-test
echo "::endgroup::"
done

- name: Pyflakes
working-directory: solid-ai-benchmark
run: python -m pyflakes tests
24 changes: 12 additions & 12 deletions tests/efficacy/harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -1850,7 +1850,7 @@ def outcome_checks():
classify(status, result)[0] == expected)
for label, status, result, expected in ENDINGS]

scratch = os.path.join(os.environ.get("TEMP", "."),
scratch = os.path.join(tempfile.gettempdir(),
"efficacy-void-self-test")
shutil.rmtree(scratch, ignore_errors=True)
workspace = os.path.join(scratch, "none-1")
Expand Down Expand Up @@ -2065,7 +2065,7 @@ def change_checks():
"`caps`", "/invoices/preview"))),
]

scratch = os.path.join(os.environ.get("TEMP", "."),
scratch = os.path.join(tempfile.gettempdir(),
"efficacy-change-self-test")
remove_tree(scratch)
build = os.path.join(scratch, "A1")
Expand Down Expand Up @@ -2127,7 +2127,7 @@ def dry_run_checks():
the run record offering it. The generator is a stand-in on `PATH` and the
home a scratch one, so no real CLI or credential is reached.
"""
scratch = os.path.join(os.environ.get("TEMP", "."),
scratch = os.path.join(tempfile.gettempdir(),
"efficacy-dry-run-self-test")
remove_tree(scratch)
root = os.path.join(scratch, "root")
Expand Down Expand Up @@ -2211,7 +2211,7 @@ def dry_run_checks():

def credential_checks():
"""A trial's Git cannot borrow a credential the machine stores."""
scratch = os.path.join(os.environ.get("TEMP", "."),
scratch = os.path.join(tempfile.gettempdir(),
"efficacy-credential-self-test")
remove_tree(scratch)
os.makedirs(scratch)
Expand Down Expand Up @@ -2245,7 +2245,7 @@ def answers(env):

def process_checks():
"""A process running from a trial's directory is stopped, and no other."""
scratch = os.path.join(os.environ.get("TEMP", "."),
scratch = os.path.join(tempfile.gettempdir(),
"efficacy-process-self-test")
owned = os.path.join(scratch, "none-1")
neighbour = os.path.join(scratch, "none-10")
Expand Down Expand Up @@ -2313,7 +2313,7 @@ def claimed_pid(path):

def claim_checks():
"""A live run refuses a second; an ended or reused one is taken over."""
scratch = os.path.join(os.environ.get("TEMP", "."),
scratch = os.path.join(tempfile.gettempdir(),
"efficacy-claim-self-test")
remove_tree(scratch)
live = planted_run("judge.py")
Expand Down Expand Up @@ -2389,7 +2389,7 @@ def claim_refusal_check(tool, main, root, *extra):

def leftover_checks():
"""A temp entry a trial made and named moves to its own; nothing else."""
scratch = os.path.join(os.environ.get("TEMP", "."),
scratch = os.path.join(tempfile.gettempdir(),
"efficacy-leftover-self-test")
remove_tree(scratch)
shared = os.path.join(scratch, "shared")
Expand Down Expand Up @@ -2434,7 +2434,7 @@ def leftover_checks():

def reach_checks():
"""A tool call fetching the templates is flagged; reading them is not."""
scratch = os.path.join(os.environ.get("TEMP", "."),
scratch = os.path.join(tempfile.gettempdir(),
"efficacy-reach-self-test")
remove_tree(scratch)
home = os.path.join(scratch, "home")
Expand Down Expand Up @@ -2493,7 +2493,7 @@ def reach_checks():
def outside_checks():
"""A call into another part of the run is flagged; the trial's own
workspace and temporary directory are not."""
scratch = os.path.join(os.environ.get("TEMP", "."),
scratch = os.path.join(tempfile.gettempdir(),
"efficacy-outside-self-test")
remove_tree(scratch)
root = os.path.abspath(os.path.join(scratch, "run"))
Expand Down Expand Up @@ -2602,7 +2602,7 @@ def alive(pid):
def hang_checks():
"""A CLI that lingers after its result, or never answers, is ended with
everything under it, and what it printed is kept."""
scratch = os.path.join(os.environ.get("TEMP", "."),
scratch = os.path.join(tempfile.gettempdir(),
"efficacy-hang-self-test")
remove_tree(scratch)
os.makedirs(scratch)
Expand Down Expand Up @@ -2637,7 +2637,7 @@ def hang_checks():
def credential_link_checks():
"""The scratch home reads the account's live credentials, and gets them
back before a trial where they went missing."""
scratch = os.path.join(os.environ.get("TEMP", "."),
scratch = os.path.join(tempfile.gettempdir(),
"efficacy-credential-link-self-test")
remove_tree(scratch)
real = os.path.join(os.path.expanduser("~"), CREDENTIALS)
Expand All @@ -2663,7 +2663,7 @@ def vendor_checks():
if templates_root(required=False) is None:
return [("a templates source is set in %s, so the vendoring can be "
"proved" % TEMPLATES_ENV, False)]
scratch = os.path.join(os.environ.get("TEMP", "."),
scratch = os.path.join(tempfile.gettempdir(),
"efficacy-vendor-self-test")
remove_tree(scratch)
workspace = os.path.join(scratch, "hybrid-1")
Expand Down
3 changes: 2 additions & 1 deletion tests/efficacy/judge.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import re
import shutil
import sys
import tempfile

sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

Expand Down Expand Up @@ -1325,7 +1326,7 @@ def claim_checks(scratch):
def self_test():
"""Prove a bundle is blind and carries its tree's own specification,
labels continue, the judge launches, and a live run refuses a second."""
scratch = os.path.join(os.environ.get("TEMP", "."),
scratch = os.path.join(tempfile.gettempdir(),
"efficacy-judge-self-test")
shutil.rmtree(scratch, ignore_errors=True)
os.makedirs(scratch)
Expand Down
14 changes: 7 additions & 7 deletions tests/efficacy/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -2543,7 +2543,7 @@ def parse_args(argv):

def reach_checks():
"""The report names a trial whose scan hit, and no other."""
scratch = os.path.join(os.environ.get("TEMP", "."),
scratch = os.path.join(tempfile.gettempdir(),
"efficacy-report-reach-self-test")
shutil.rmtree(scratch, ignore_errors=True)
os.makedirs(scratch)
Expand Down Expand Up @@ -2578,7 +2578,7 @@ def reach_checks():

def lost_checks():
"""A voided trial is listed whether or not a run record names it."""
scratch = os.path.join(os.environ.get("TEMP", "."),
scratch = os.path.join(tempfile.gettempdir(),
"efficacy-report-lost-self-test")
shutil.rmtree(scratch, ignore_errors=True)
recorded = os.path.join(scratch, "void", "A1-2026-09-15T10-00-00")
Expand Down Expand Up @@ -2627,7 +2627,7 @@ def lost_checks():
def rescan_checks():
"""A record scanned under an earlier rule is read again from its
transcript."""
scratch = os.path.join(os.environ.get("TEMP", "."),
scratch = os.path.join(tempfile.gettempdir(),
"efficacy-report-rescan-self-test")
shutil.rmtree(scratch, ignore_errors=True)
workspace = os.path.join(scratch, "none-2")
Expand Down Expand Up @@ -2756,7 +2756,7 @@ def escalation_checks(seed):
checks.append(("a K = 3 run is assessed on its own vector",
state == "assessed", state))

scratch = os.path.join(os.environ.get("TEMP", "."),
scratch = os.path.join(tempfile.gettempdir(),
"efficacy-report-escalation-self-test")
shutil.rmtree(scratch, ignore_errors=True)
os.makedirs(scratch)
Expand Down Expand Up @@ -2815,7 +2815,7 @@ def posthoc_checks(seed):
posthoc_owed(trials) and not posthoc_owed(probed),
(posthoc_owed(trials), posthoc_owed(probed))))

scratch = os.path.join(os.environ.get("TEMP", "."),
scratch = os.path.join(tempfile.gettempdir(),
"efficacy-report-posthoc-self-test")
shutil.rmtree(scratch, ignore_errors=True)
os.makedirs(scratch)
Expand Down Expand Up @@ -2867,7 +2867,7 @@ def rendered(trials, seed, withdrawn):
results = contrasts(table, seed, crossed_labels(trials))
before = results["change_success"]["full-none"]["verdict"]
withdraw(withdrawn, table, results)
scratch = os.path.join(os.environ.get("TEMP", "."),
scratch = os.path.join(tempfile.gettempdir(),
"efficacy-report-withdrawal-render")
shutil.rmtree(scratch, ignore_errors=True)
os.makedirs(scratch)
Expand All @@ -2891,7 +2891,7 @@ def section_rows(text, heading, label):
def withdrawal_checks(seed):
"""A withdrawn metric prints only its withdrawal, and only on runs graded
by the revision it was withdrawn for."""
scratch = os.path.join(os.environ.get("TEMP", "."),
scratch = os.path.join(tempfile.gettempdir(),
"efficacy-report-withdrawal-self-test")
shutil.rmtree(scratch, ignore_errors=True)
os.makedirs(scratch)
Expand Down
3 changes: 2 additions & 1 deletion tests/efficacy/reuse.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import os
import shutil
import sys
import tempfile

sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

Expand Down Expand Up @@ -260,7 +261,7 @@ def plant_source(scratch):
def self_test():
"""Prove a reuse copies the chosen arms' trials, and only those, under
the words, and refuses to offer a trial twice."""
scratch = os.path.join(os.environ.get("TEMP", "."),
scratch = os.path.join(tempfile.gettempdir(),
"efficacy-reuse-self-test")
remove_tree(scratch)
source = plant_source(scratch)
Expand Down
3 changes: 2 additions & 1 deletion tests/efficacy/score.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import subprocess
import sys
import tarfile
import tempfile

sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

Expand Down Expand Up @@ -1664,7 +1665,7 @@ def self_test():
missing with a reason. Any that comes back zero is a scorer reporting a
clean trial it never read.
"""
scratch = os.path.join(os.environ.get("TEMP", "."), "efficacy-self-test")
scratch = os.path.join(tempfile.gettempdir(), "efficacy-self-test")
remove_tree(scratch)
os.makedirs(scratch)
checks = (run_record_checks(scratch) + churn_checks(scratch)
Expand Down
Loading