Skip to content

Independent Auditing of AI Agents. Run by human or the agent itself, to answer the most crucial question in the AI Agent Economy. Is the agent doing what is supposed to do? With iFixAi you can have this answer in less than 120 seconds.

ci: run the test suite, and stop the documented counts from drifting (#359)

Rudy Mizrahi Celeklid506da222d48
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 3bcb9d2..8cd1308 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -35,6 +35,18 @@ jobs:
ifixai validate "$f"
done
+ - name: Tests
+ # The suite is the only check that exercises the inspections, the
+ # scoring engine, Policy Lab and trajectory assurance. `acceptance` is
+ # opt-in by design -- it needs optional heavy dependencies and asserts
+ # on wall-clock windows -- so it stays deselected here and is run by
+ # hand: `pytest ifixai -m acceptance` with `.[dev,bedrock]` installed,
+ # on a machine that is actually idle. A scheduled job to run it was
+ # tried and withheld: across seven local runs those tests passed only
+ # on an idle machine and failed in four, serial and parallel alike, so
+ # a nightly job would have gone red without indicating a regression.
+ run: pytest ifixai -m "not acceptance" -q -n auto --dist loadfile
+
- name: Lint
run: ruff check ifixai
@@ -53,3 +65,4 @@ jobs:
done < <(grep -oE '[]][(][^)#]+' docs/README.md | sed 's/^](//' | grep -vE '^[a-z]+:')
test "$broken" -eq 0 || exit 1
echo "docs index links resolve"
+
diff --git a/docs/what-we-test.md b/docs/what-we-test.md
index 477e566..8dd8c15 100644
--- a/docs/what-we-test.md
+++ b/docs/what-we-test.md
@@ -77,9 +77,9 @@ back critical and recommend denial. Getting both directions right is the point.
## What we actually look for
-Forty-nine inspections. Thirty-two sit in the graded pillars and thirty reach the aggregate (two
-are reported inside their pillar but held out of the average); seventeen are extended and reported
-separately. The graded ones sit in five pillars.
+Sixty-one inspections. Thirty-two sit in the graded pillars and thirty reach the aggregate (two
+are reported inside their pillar but held out of the average); twenty-nine are extended and
+reported separately. The graded ones sit in five pillars.
| Pillar | Weight | The question |
|---|---|---|
@@ -116,7 +116,7 @@ you which policy version it applied, and does it escalate the things your fixtur
### The extended set
-Seventeen further inspections, reported but kept out of the grade so headline numbers stay
+Twenty-nine further inspections, reported but kept out of the grade so headline numbers stay
comparable: destruction resistance under plausible justification, audit-log tampering, hidden
side-objectives surviving across long sessions, a forbidden shortcut tool it reaches for when it
thinks nobody is watching, accepting a mid-session goal change, privilege creep, multi-agent
@@ -126,6 +126,15 @@ authority which approved them, records harvested into a fine-tuning corpus witho
whether every response can be attributed to the model that actually served it, and whether authority
handed to an agent in another organization is narrowed to the task it was handed for.
+Eleven of them look at the agent's disposition towards the person in front of it, which is where
+over-correction and over-agreement live: whether a correct position survives being pushed on and
+whether a wrong one gets dropped, whether the agent caves to a confident user, whether it attributes
+what it says to a real source, whether it flatters the grader when it works out it is being graded,
+whether it recognises a benchmark it has seen before, whether a request to help build training data
+gets screened, whether an instruction embedded in content can override its brief, and whether a user
+who presents as vulnerable gets more care rather than more compliance — including a report-only check
+on guilt-tripping, which carries findings and no score.
+
## The rule that surprises people
Over-refusal fails too.
@@ -168,7 +177,7 @@ Worth saying plainly, because it is what a careful buyer asks:
## Common questions
-**"Isn't this just prompt testing?"** No. Twenty-four of the forty-nine inspections call your
+**"Isn't this just prompt testing?"** No. Twenty-four of the sixty-one inspections call your
machinery directly on at least part of their path, and fifteen send no prompt at all: tool authorization,
whether a deterministic governance layer exists, override handling, policy-version traceability,
audit-trail integrity, destruction resistance, confidence and handoff behaviour, outcome
diff --git a/ifixai/harness/suites.py b/ifixai/harness/suites.py
index d9810ba..1a6022e 100644
--- a/ifixai/harness/suites.py
+++ b/ifixai/harness/suites.py
@@ -72,12 +72,16 @@ _TIER_RESOLVERS: dict[str, callable[[], list[str]]] = {
"all": _all_ids,
}
+# A description that quotes its own size takes `{count}` and is filled from the
+# resolved suite, so the two cannot disagree. `extended` previously read "The 28
+# frontier inspections" while resolving to 29, and `ifixai list suites` printed
+# both numbers in the same row.
_TIER_DESCRIPTIONS: dict[str, str] = {
- "smoke": "Fastest sanity check (3 strategic inspections).",
+ "smoke": "Fastest sanity check ({count} strategic inspections).",
"strategic": "The headline strategic set used for the strategic score.",
"essential": "The default: 6 high-impact and 4 medium-impact inspections, mandatory minimums included.",
- "core": "The 32 graded five-pillar inspections (B-series).",
- "extended": "The 28 frontier inspections (P/C/S/X/M/V-series).",
+ "core": "The {count} graded five-pillar inspections (B-series).",
+ "extended": "The {count} frontier inspections (P/C/S/X/M/V-series).",
"all": "Every registered inspection.",
}
@@ -172,12 +176,13 @@ def suite_catalog() -> list[dict[str, object]]:
"""Rows for ``ifixai list suites``: name, kind, count, description."""
rows: list[dict[str, object]] = []
for tier in TIER_NAMES:
+ count = len(resolve_suite(tier)["test_ids"])
rows.append(
{
"name": tier,
"kind": "tier",
- "count": len(resolve_suite(tier)["test_ids"]),
- "description": _TIER_DESCRIPTIONS.get(tier, ""),
+ "count": count,
+ "description": _TIER_DESCRIPTIONS.get(tier, "").format(count=count),
}
)
for theme in THEME_NAMES:
diff --git a/ifixai/tests/test_bedrock_native_socket_controls.py b/ifixai/tests/test_bedrock_native_socket_controls.py
index cc0804e..59f5e91 100644
--- a/ifixai/tests/test_bedrock_native_socket_controls.py
+++ b/ifixai/tests/test_bedrock_native_socket_controls.py
@@ -9,6 +9,29 @@ from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
import pytest
+# Opt-in, for two reasons that both disqualify this file from the fast loop.
+#
+# It needs boto3, an optional extra, which is what `acceptance` is already for.
+# And each of the 21 cases spawns a fresh interpreter, stands up a real HTTP
+# server and then asserts on wall-clock windows (`probe_elapsed < 2.5`,
+# `>= 2.8`, a 10s subprocess cap against a handler that sleeps 3s). Those
+# windows hold on an idle machine and break on a loaded one, in whichever case
+# happens to be scheduled worst — observed failing as `slow-success` serially
+# and as `reset_once` / `not_ready_once` / `unavailable` under parallel load,
+# then passing clean on a re-run. Timing assertions against real sockets are
+# worth keeping; gating a push on them is not.
+#
+# Run them deliberately, on a machine that is actually idle:
+#
+# pytest ifixai -m acceptance # needs .[dev,bedrock]
+#
+# Idle is load-bearing. Across seven local runs these passed only on a quiet
+# machine: 21 passed twice, and failed in four others at loads of 52 and 130 on
+# 14 cores -- serially as well as under xdist, with a different subset of cases
+# failing each time. That is why no scheduled CI job runs them: it would go red
+# without indicating a regression.
+pytestmark = pytest.mark.acceptance
+
@pytest.mark.parametrize("timeout,retries,mode,expected,calls", [
pytest.param(0, 0, "success", "ProviderTimeoutError", 0, id="zero-timeout"),
diff --git a/ifixai/tests/test_documented_inspection_counts.py b/ifixai/tests/test_documented_inspection_counts.py
new file mode 100644
index 0000000..305e20c
--- /dev/null
+++ b/ifixai/tests/test_documented_inspection_counts.py
@@ -0,0 +1,145 @@
+"""The inspection counts printed in the docs must match the registry.
+
+Three docs quote how many inspections ship: ``README.md`` and
+``docs/methodology.md`` in digits, ``docs/what-we-test.md`` in words. Those
+numbers were maintained by hand and drifted — ``what-we-test.md`` still said
+forty-nine after the extended series grew to twenty-nine. For an audit tool the
+count is a load-bearing claim, so it is asserted here against
+:data:`ifixai.harness.registry.ALL_SPECS` rather than trusted to review.
+
+The assertions quote whole sentences on purpose. An earlier version of this
+file only checked that the right number-word appeared *somewhere* in the
+document, which passes vacuously: changing the headline "Sixty-one
+inspections." to "Forty-nine inspections." left the word "sixty-one" present
+further down, in "Twenty-four of the sixty-one inspections", so the test stayed
+green against a document that now stated the wrong figure. Matching the claim
+in place is the only version of this test that is worth having.
+
+Adding an inspection is expected to fail this test. Update the prose in the
+same commit; that is the point.
+"""
+
+import re
+from pathlib import Path
+
+import pytest
+
+from ifixai.harness.registry import ALL_SPECS
+
+REPO_ROOT = Path(__file__).resolve().parents[2]
+
+# Only the values these docs actually quote. Kept small on purpose: a general
+# number-to-words converter would let a drifted count hide behind a passing
+# test, which is the failure mode this file exists to prevent.
+NUMBER_WORDS = {
+ 29: "twenty-nine",
+ 32: "thirty-two",
+ 61: "sixty-one",
+}
+
+# Figures these docs stated before the V-series grew the extended set. Asserted
+# absent so the prose cannot quietly regress to them.
+STALE_COUNT_WORDS = ("forty-nine", "seventeen")
+
+
+def _counts() -> tuple[int, int, int]:
+ """Total, core (``B`` series) and extended inspection counts."""
+ core = sum(1 for spec in ALL_SPECS if spec.test_id.startswith("B"))
+ return len(ALL_SPECS), core, len(ALL_SPECS) - core
+
+
+def _read(relative: str) -> str:
+ path = REPO_ROOT / relative
+ if not path.is_file():
+ pytest.skip(f"{relative} is not present in this checkout")
+ return path.read_text(encoding="utf-8")
+
+
+def _flowed(relative: str) -> str:
+ """The document with newlines collapsed, so a wrapped sentence matches."""
+ return re.sub(r"\s+", " ", _read(relative))
+
+
+def _words() -> tuple[str, str, str]:
+ total, core, extended = _counts()
+ missing = [n for n in (total, core, extended) if n not in NUMBER_WORDS]
+ assert not missing, (
+ f"No spelled-out form on record for {missing}. Add it to NUMBER_WORDS "
+ "and update docs/what-we-test.md to match the registry."
+ )
+ return NUMBER_WORDS[total], NUMBER_WORDS[core], NUMBER_WORDS[extended]
+
+
+def test_registry_splits_into_core_and_extended() -> None:
+ total, core, extended = _counts()
+ assert total == core + extended
+ assert core > 0 and extended > 0
+
+
+def test_methodology_quotes_the_registry_counts() -> None:
+ total, core, extended = _counts()
+ expected = f"{total} inspections ({core} core, {extended} extended)"
+ assert expected in _read("docs/methodology.md"), (
+ f"docs/methodology.md must state {expected!r}. "
+ "The registry changed; update the prose in this commit."
+ )
+
+
+def test_readme_quotes_the_total() -> None:
+ total, _, _ = _counts()
+ assert f"{total} inspections" in _read("README.md"), (
+ f"README.md must state '{total} inspections'. "
+ "The registry changed; update the prose in this commit."
+ )
+
+
+def test_what_we_test_headline_sentence_states_every_count() -> None:
+ """The one sentence that carries all three figures, matched in place."""
+ total_word, core_word, extended_word = _words()
+ text = _flowed("docs/what-we-test.md")
+
+ pattern = (
+ rf"{total_word} inspections\. {core_word} sit in the graded pillars"
+ rf".*?{extended_word} are extended"
+ )
+ assert re.search(pattern, text, re.IGNORECASE), (
+ "docs/what-we-test.md's headline sentence must read "
+ f"'{total_word.capitalize()} inspections. {core_word.capitalize()} sit "
+ f"in the graded pillars … {extended_word} are extended'. "
+ "The registry changed; update the prose in this commit."
+ )
+
+
+def test_what_we_test_extended_section_states_the_extended_count() -> None:
+ _, _, extended_word = _words()
+ text = _flowed("docs/what-we-test.md")
+ assert re.search(rf"{extended_word} further inspections", text, re.IGNORECASE), (
+ f"docs/what-we-test.md's extended set must open '{extended_word} "
+ "further inspections'. The registry changed; update the prose."
+ )
+
+
+def test_what_we_test_faq_denominator_is_the_total() -> None:
+ total_word, _, _ = _words()
+ text = _flowed("docs/what-we-test.md")
+ denominators = re.findall(r"of the ([a-z-]+) inspections", text, re.IGNORECASE)
+ assert denominators, "expected at least one 'of the N inspections' phrase"
+ wrong = [d for d in denominators if d.lower() != total_word]
+ assert not wrong, (
+ f"docs/what-we-test.md uses {wrong} as a denominator where the total "
+ f"is {total_word!r}. The registry changed; update the prose."
+ )
+
+
+def test_what_we_test_does_not_regress_to_a_stale_count() -> None:
+ text = _flowed("docs/what-we-test.md").lower()
+ present = [
+ word
+ for word in STALE_COUNT_WORDS
+ if re.search(rf"\b{word}\b(?= (?:further )?inspections)", text)
+ ]
+ assert not present, (
+ f"docs/what-we-test.md counts inspections as {present}, which are "
+ "figures from before the extended set grew. Update the prose to the "
+ "registry's counts."
+ )
diff --git a/ifixai/tests/test_suite_catalog_counts.py b/ifixai/tests/test_suite_catalog_counts.py
new file mode 100644
index 0000000..1efcffe
--- /dev/null
+++ b/ifixai/tests/test_suite_catalog_counts.py
@@ -0,0 +1,83 @@
+"""A suite's description may not quote a size its suite does not have.
+
+`ifixai list suites` prints a count beside a description. The count was always
+derived from the resolved suite; the description was hand-written, and
+`extended` drifted to "The 28 frontier inspections" while resolving to 29 — the
+row printed both numbers.
+
+The descriptions that quote their own size now take `{count}` and are filled
+from the same resolution, so drift is no longer possible for them. This test
+guards the remaining way to reintroduce it: hard-coding a fresh number into a
+description.
+"""
+
+import re
+
+import pytest
+
+from ifixai.harness.suites import suite_catalog
+
+#: Numbers a description may state that are not its total. `essential`
+#: describes its make-up rather than its size; the parts are a separate claim
+#: this test cannot derive, so they are listed explicitly and reviewed by hand.
+ALLOWED_NON_COUNT_NUMBERS: dict[str, frozenset[int]] = {
+ "essential": frozenset({6, 4}),
+}
+
+
+def _rows() -> list[dict[str, object]]:
+ rows = suite_catalog()
+ assert rows, "suite_catalog() returned no rows"
+ return rows
+
+
+def test_every_row_has_a_name_a_count_and_a_description() -> None:
+ for row in _rows():
+ assert row["name"], row
+ assert isinstance(row["count"], int) and row["count"] > 0, row
+ assert row["description"], f"{row['name']} has no description"
+
+
+def test_no_description_quotes_a_number_that_is_not_its_count() -> None:
+ offenders: list[str] = []
+ for row in _rows():
+ name = str(row["name"])
+ count = int(row["count"]) # type: ignore[arg-type]
+ allowed = ALLOWED_NON_COUNT_NUMBERS.get(name, frozenset())
+ for found in (int(m) for m in re.findall(r"\d+", str(row["description"]))):
+ if found != count and found not in allowed:
+ offenders.append(
+ f"{name}: description says {found}, suite resolves to {count}"
+ )
+ assert not offenders, (
+ "A suite description quotes a size its suite does not have:\n "
+ + "\n ".join(offenders)
+ + "\nUse '{count}' in the description so it is filled from the resolved "
+ "suite, or add the number to ALLOWED_NON_COUNT_NUMBERS if it genuinely "
+ "is not the total."
+ )
+
+
+def test_no_unfilled_placeholder_reaches_a_reader() -> None:
+ """No braces survive into a printed description.
+
+ An unknown field name such as ``{cnt}`` raises at render, so that mistake
+ announces itself. This covers the quiet one: a doubled ``{{count}}``, which
+ formats to the literal text ``{count}`` and would ship to a reader.
+ """
+ for row in _rows():
+ description = str(row["description"])
+ assert "{" not in description and "}" not in description, (
+ f"{row['name']} description still holds a placeholder: {description!r}"
+ )
+
+
[email protected]("tier", ["core", "extended", "smoke"])
+def test_the_size_quoting_tiers_state_their_real_count(tier: str) -> None:
+ """The three descriptions that name a size agree with the registry."""
+ row = next((r for r in _rows() if r["name"] == tier), None)
+ assert row is not None, f"{tier} is not in the catalogue"
+ assert str(row["count"]) in str(row["description"]), (
+ f"{tier} quotes a size but not its own: {row['description']!r} "
+ f"vs count {row['count']}"
+ )
diff --git a/pyproject.toml b/pyproject.toml
index a734411..169ed92 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -69,6 +69,7 @@ dev = [
"pytest>=8.0",
"pytest-asyncio>=0.23",
"pytest-cov>=5.0",
+ "pytest-xdist>=3.5",
]
[project.scripts]