Squashes the arc's work into one commit; the workflow-file edit it originally carried is excluded (see the end of this message). ## Lane 1 — Workbench recorded a proved answer as ungrounded With deduction_serving_enabled ratified ON (ADR-0256), workbench/api.py's live chat route builds a bare ChatRuntime(), so the deduction composer decides Workbench turns and stamps grounding_source="deduction" — but _coerce_grounding_source carried a hand-copied whitelist of the six pre-arc labels and silently rewrote anything else to "none". The runtime comment reasoned this was inert because "REPL turns do not flow through Workbench's CognitivePipelineRecord path". True, and irrelevant: the traffic flows the other way. Stale since 2026-07-24. Scope is one field. workbench/api.py:818 prefers TurnEvent.epistemic_state, which read epistemic_state_needed — honest. So the UNregistered path degraded honestly while the hand-copied whitelist asserted a falsehood; a second copy of a closed enum was worse than no copy. Hence registration AND derivation: GROUNDING_SOURCES exposes the Literal's members, and the coercion reads it. workbench-ui badges/tokens/snapshot follow; enumCoverage.test.ts forces atomicity. ## Lane 2 — the ratification ceremony The discovery loop was instrumented but not closed. teaching/ratification.py turns a reviewed decision into a chain record, a corpus commit, and a receipt. Its design turns on one observation: _ratified_rows DROPS unadmissible rows silently — correct when serving, a trap when ratifying, because the file grows, the commit lands, and the band count does not move. So the ceremony refuses to call an append a ratification until it has re-read the curriculum through the real loader and seen the chain arrive; a non-admitted append is rolled back. Validation is a pre-flight courtesy, admission is the proof. Arena queue entry and ledger reseal are deliberately NOT performed (bridge rule 1); the receipt names them. Front door: `core proposal-queue ratify`, a sibling of `review` rather than a flag on it. ## Lane 3 — structural closures - ADR-0263 gains rule 5: absence policy is DECLARED in CAPABILITY_LEDGERS, not passed at the call site. An AST-matched test fails if a serving path passes missing_ok again. - Deductive suite added WHOLE to the pre-push gate: 285 tests in 29s against smoke's 216 in 62s, so no coverage trade was needed. - Smoke/CI parity assertion made bidirectional. It was one-directional, and had drifted. - test_prior_surface_deduction_binding.py pins correction binding on the deduction path. The review's diagnosis did NOT reproduce — hash_surface moves in lockstep — so it pins what is there. Mutation-checked. - Domain-keyed ADR index over 312 flat-numbered files, explicitly partial. - Arc-close brief template, plus this arc's own brief filled in against it. ## Lanes 4 and 5 — two premises falsified by measurement, one of them mine Math 4.2: baseline reproduced (correct=5 wrong=0 refused=495); all four named cases traced to one seam with each gap isolated by one-variable probes. Then the number that changes the recommendation: the gap blocking case 0000 affects 1 case in 500, the 'than' gap blocking 0001 affects 2. ADR-0251's prohibition on per-case growth now rests on a count. No reader change made. CGA: versor_condition is 0.22% of a turn, not the "~10x proof latency" I claimed — that multiplied an isolated microbenchmark by a call count and compared it to a single verdict's latency. The real cost is geometric_product at 33,986 calls/turn (~73%) via cga_inner in search paths. The obvious closed form is NOT bit-exact (954/4000 in f32); backend.vault_recall's serial fold IS (3000/3000, worst-rel 0) and is the correct target. cargo test could not run — static.crates.io is denied by the sandbox network policy — so the Rust parity question stays open and the typestate lane is carried forward, not shipped uncompiled. ## Not landed: three lines owed to .github/workflows/smoke.yml The CI smoke gate is narrower than the local one — test_pack_draft_serve_boundary.py (ADR-0253 INV-33) has been local-only, unseen because the parity pin checked one direction. The edit was authored and rejected at push for lacking the `workflow` OAuth scope, so it is recorded as a named, dated PENDING_IN_CI exception rather than dropped: the assertion still fires on any new divergence, and a second guard fires once the three land. [Verification]: pre-push gates all green — smoke 236 passed, warmed_session 10 passed, deductive 285 passed. Ratification 14, ADR index 5, CLI suites 10. Grounding/epistemic sweep 741 passed 1 skipped. workbench-ui 598 passed across 73 files, tsc -b clean. capability index 11 passed, digest unchanged. Math holdout correct=5 wrong=0 refused=495. Committed chain corpora byte-unchanged after the tests that write to them. Environment caveat: the repo pins requires-python ==3.12.13, which uv cannot fetch for linux-x86_64, so `uv sync --locked` fails. All Python runs used a scratch venv on 3.12.11 with declared deps — not the locked universe, not the full ~12k suite. The pin was left untouched. Re-run on a 3.12.13 host before treating this as merge evidence. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FduW6Krm3PPQv3P5iwBYtx
266 lines
9.3 KiB
Python
266 lines
9.3 KiB
Python
"""CLI tests for curated pytest suite aliases."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import tomllib
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from core import cli_rust
|
|
from core import cli
|
|
|
|
|
|
def test_pyproject_installs_core_console_script_under_uv() -> None:
|
|
pyproject = Path(__file__).resolve().parents[1] / "pyproject.toml"
|
|
data = tomllib.loads(pyproject.read_text(encoding="utf-8"))
|
|
|
|
assert data["project"]["scripts"]["core"] == "core.cli:main"
|
|
assert data["tool"]["uv"]["package"] is True
|
|
package_includes = data["tool"]["setuptools"]["packages"]["find"]["include"]
|
|
expected_runtime_packages = {
|
|
"benchmarks*",
|
|
"calibration*",
|
|
"core_ingest*",
|
|
"demos*",
|
|
"engine_state*",
|
|
"evals*",
|
|
"packs*",
|
|
"scripts*",
|
|
"teaching*",
|
|
}
|
|
assert expected_runtime_packages.issubset(package_includes)
|
|
|
|
|
|
def test_core_test_lists_curated_suites(capsys) -> None:
|
|
rc = cli.main(["test", "--list-suites"])
|
|
|
|
captured = capsys.readouterr()
|
|
assert rc == 0
|
|
assert "fast" in captured.out.splitlines()
|
|
assert "smoke" in captured.out.splitlines()
|
|
assert "cognition" in captured.out.splitlines()
|
|
assert "teaching" in captured.out.splitlines()
|
|
assert "packs" in captured.out.splitlines()
|
|
assert "deductive" in captured.out.splitlines()
|
|
assert "full" in captured.out.splitlines()
|
|
|
|
|
|
def test_cli_smoke_suite_covers_ci_smoke_gate() -> None:
|
|
"""Local-first parity pin: the CLI ``smoke`` suite must cover every test
|
|
path the CI smoke gate (.github/workflows/smoke.yml) runs.
|
|
|
|
AGENTS.md makes ``core test --suite smoke`` the mandatory pre-push gate;
|
|
if the CI yaml gains a path the CLI tuple lacks, the local gate silently
|
|
narrows and regressions clear it — this pin makes that divergence loud.
|
|
"""
|
|
from core.cli_test import TEST_SUITES
|
|
|
|
root = Path(__file__).resolve().parents[1]
|
|
workflow = (root / ".github/workflows/smoke.yml").read_text(encoding="utf-8")
|
|
|
|
ci_paths: set[str] = set()
|
|
for token in workflow.split():
|
|
token = token.strip("\\\"'")
|
|
if not token.startswith("tests/"):
|
|
continue
|
|
if "*" in token:
|
|
matches = sorted(root.glob(token))
|
|
assert matches, f"CI smoke glob {token!r} matches no files"
|
|
ci_paths.update(str(m.relative_to(root)) for m in matches)
|
|
else:
|
|
ci_paths.add(token)
|
|
|
|
assert ci_paths, "no tests/ paths parsed from smoke.yml — pin needs updating"
|
|
local_paths = set(TEST_SUITES["smoke"])
|
|
|
|
missing_locally = ci_paths - local_paths
|
|
assert not missing_locally, (
|
|
"CLI smoke suite is narrower than the CI smoke gate; add to "
|
|
f"core/cli_test.py TEST_SUITES['smoke']: {sorted(missing_locally)}"
|
|
)
|
|
|
|
# The other direction, which this pin did not check until 2026-07-25 and
|
|
# which had in fact drifted: tests/test_pack_draft_serve_boundary.py sat in
|
|
# the local gate and not in smoke.yml. The list's own comment promises the
|
|
# two are *equal* ("so the local-first pre-push gate equals the CI gate
|
|
# rather than silently narrowing it"), and a one-directional assertion can
|
|
# only ever hold half of that. A file only the local gate runs is a file
|
|
# whose regression is invisible to anyone reading a green CI badge.
|
|
#
|
|
# PENDING_IN_CI is a named, dated exception list, not a suppression. These
|
|
# three are already in the local gate and belong in smoke.yml; the edit was
|
|
# authored and could not be pushed from the authoring session, whose
|
|
# credential lacked the `workflow` OAuth scope. Anyone with that scope
|
|
# closes this by adding the three lines and emptying this tuple. The
|
|
# assertion below still fires on any NEW divergence, which is the
|
|
# protection that was missing entirely before.
|
|
PENDING_IN_CI = (
|
|
"tests/test_pack_draft_serve_boundary.py",
|
|
"tests/test_prior_surface_deduction_binding.py",
|
|
"tests/test_workbench_deduction_provenance.py",
|
|
)
|
|
missing_in_ci = local_paths - ci_paths - set(PENDING_IN_CI)
|
|
assert not missing_in_ci, (
|
|
"CI smoke gate is narrower than the CLI smoke suite; add to "
|
|
f".github/workflows/smoke.yml: {sorted(missing_in_ci)}"
|
|
)
|
|
stale_exceptions = set(PENDING_IN_CI) & ci_paths
|
|
assert not stale_exceptions, (
|
|
"these are in smoke.yml now — drop them from PENDING_IN_CI: "
|
|
f"{sorted(stale_exceptions)}"
|
|
)
|
|
|
|
|
|
def test_core_test_suite_expands_to_expected_pytest_paths(monkeypatch) -> None:
|
|
calls: list[tuple[str, ...]] = []
|
|
|
|
def fake_run(*args: str, check: bool = False, cwd=None) -> int:
|
|
calls.append(args)
|
|
return 0
|
|
|
|
monkeypatch.setattr(cli, "_run", fake_run)
|
|
|
|
rc = cli.main(["test", "--suite", "cognition", "-q"])
|
|
|
|
assert rc == 0
|
|
assert calls
|
|
command = calls[0]
|
|
assert command[:3] == (cli.sys.executable, "-m", "pytest")
|
|
assert "tests/test_intent_proposition_graph.py" in command
|
|
assert "tests/test_cognitive_turn_pipeline.py" in command
|
|
assert "tests/test_articulation_realizer_v2.py" in command
|
|
assert "-q" in command
|
|
|
|
|
|
def test_core_test_fast_suite_expands_to_iteration_lane(monkeypatch) -> None:
|
|
calls: list[tuple[str, ...]] = []
|
|
|
|
def fake_run(*args: str, check: bool = False, cwd=None) -> int:
|
|
calls.append(args)
|
|
return 0
|
|
|
|
monkeypatch.setattr(cli, "_run", fake_run)
|
|
|
|
rc = cli.main(["test", "--suite", "fast", "-q"])
|
|
|
|
assert rc == 0
|
|
command = calls[0]
|
|
assert "tests/test_cli_test_suites.py" in command
|
|
assert "tests/test_runtime_config.py" in command
|
|
assert "tests/test_core_semantic_seed_pack.py" in command
|
|
assert "tests/test_cognitive_eval_harness.py" in command
|
|
assert "tests/" not in command
|
|
|
|
|
|
def test_core_test_deductive_suite_expands_to_entailment_lane(monkeypatch) -> None:
|
|
"""Contains-style, not exact-tuple: the ``deductive`` suite has grown
|
|
across the deduction-serve/curriculum-serve arcs (v1 through v6-EX,
|
|
curriculum, the ratified-ledger bridge, the vocab-trigger instrument) and
|
|
keeps growing with each new band — an exact-tuple pin here would go stale
|
|
every time, which is exactly what happened before this fix (a pinned
|
|
single-file tuple, silently wrong once the suite reached 12+ files, red
|
|
outside every real gate — the same leaky-gate class the smoke-suite
|
|
coverage pin above exists to prevent)."""
|
|
calls: list[tuple[str, ...]] = []
|
|
|
|
def fake_run(*args: str, check: bool = False, cwd=None) -> int:
|
|
calls.append(args)
|
|
return 0
|
|
|
|
monkeypatch.setattr(cli, "_run", fake_run)
|
|
|
|
rc = cli.main(["test", "--suite", "deductive", "-q"])
|
|
|
|
assert rc == 0
|
|
command = calls[0]
|
|
assert command[:3] == (cli.sys.executable, "-m", "pytest")
|
|
assert "tests/test_deductive_logic_entail.py" in command
|
|
assert "tests/test_deduction_serve_lane.py" in command
|
|
assert "tests/test_curriculum_serve.py" in command
|
|
assert "-q" in command
|
|
|
|
|
|
def test_core_test_suite_accepts_pytest_flags_without_separator(monkeypatch) -> None:
|
|
calls: list[tuple[str, ...]] = []
|
|
|
|
def fake_run(*args: str, check: bool = False, cwd=None) -> int:
|
|
calls.append(args)
|
|
return 0
|
|
|
|
monkeypatch.setattr(cli, "_run", fake_run)
|
|
|
|
rc = cli.main(["test", "--suite", "packs", "-q"])
|
|
|
|
assert rc == 0
|
|
# Assert against the live suite definition rather than re-hardcoding the
|
|
# (growing) packs file list: the contract under test is that a curated
|
|
# suite expands to its files followed by the forwarded "-q", with no "--"
|
|
# separator needed.
|
|
# Assert against the runtime suite map (core.cli_test.TEST_SUITES), which
|
|
# cli.cmd_test actually expands. core.cli._TEST_SUITES is a re-export of
|
|
# the same object — do not pin a second stale list.
|
|
from core.cli_test import TEST_SUITES
|
|
|
|
assert calls[0] == (
|
|
cli.sys.executable,
|
|
"-m",
|
|
"pytest",
|
|
*TEST_SUITES["packs"],
|
|
"-q",
|
|
)
|
|
|
|
|
|
def test_core_test_passthrough_still_accepts_arbitrary_pytest_args(monkeypatch) -> None:
|
|
calls: list[tuple[str, ...]] = []
|
|
|
|
def fake_run(*args: str, check: bool = False, cwd=None) -> int:
|
|
calls.append(args)
|
|
return 0
|
|
|
|
monkeypatch.setattr(cli, "_run", fake_run)
|
|
|
|
rc = cli.main(["test", "--", "tests/test_core_semantic_seed_pack.py", "-q"])
|
|
|
|
assert rc == 0
|
|
assert calls[0] == (
|
|
cli.sys.executable,
|
|
"-m",
|
|
"pytest",
|
|
"tests/test_core_semantic_seed_pack.py",
|
|
"-q",
|
|
)
|
|
|
|
|
|
def test_core_rust_test_sets_pyo3_forward_compat(monkeypatch) -> None:
|
|
calls: list[tuple[tuple[str, ...], object, dict[str, str] | None]] = []
|
|
|
|
def fake_which(name: str) -> str | None:
|
|
return "/usr/bin/cargo" if name == "cargo" else None
|
|
|
|
def fake_run(
|
|
*args: str,
|
|
check: bool = False,
|
|
cwd=None,
|
|
env: dict[str, str] | None = None,
|
|
) -> int:
|
|
calls.append((args, cwd, env))
|
|
return 0
|
|
|
|
monkeypatch.setattr(cli_rust.shutil, "which", fake_which)
|
|
monkeypatch.setattr(cli, "_run", fake_run)
|
|
|
|
rc = cli.main(["rust", "test"])
|
|
|
|
assert rc == 0
|
|
assert len(calls) == 1
|
|
args, cwd, env = calls[0]
|
|
assert args == ("cargo", "test", "--release")
|
|
assert cwd == cli_rust.CORE_RS_DIR
|
|
assert env is not None
|
|
assert env["PYO3_USE_ABI3_FORWARD_COMPATIBILITY"] == "1"
|
|
|
|
|
|
def test_non_test_commands_still_reject_unknown_args() -> None:
|
|
with pytest.raises(SystemExit):
|
|
cli.main(["pack", "list", "-q"])
|