Coverage for evaluation/verification_matrix.py: 100%
45 statements
« prev ^ index » next coverage.py v7.17.3, created at 2026-11-22 12:55 +0000
« prev ^ index » next coverage.py v7.17.3, created at 2026-11-22 12:55 +0000
1"""Every way this project can be verified, in one table (V6.6.4): `aq verify`, and `development/verification.md` generated from it.
3A surface is a command that proves something, with the host it runs on, what it costs and where its evidence lands. The table is data, so a test can hold it to the repository: every CI job,
4every workflow, every Lean smoke and every formal target has a row, and a row that names an `aq` command names one that exists. Adding a way to test the project without adding its row fails
5`tests/test_verification_matrix.py`. The `--quick` set is what a 4 GB machine can run between edits; the rest says where it belongs.
7Pure data and one small runner; stdlib only.
8"""
10# ruff: noqa: E501 (a table: one surface per line, so it reads and diffs row by row)
11from __future__ import annotations
13import json
14import subprocess
15import sys
16import time
17from collections.abc import Callable, Mapping, Sequence
18from dataclasses import dataclass, field
19from pathlib import Path
21HOSTS = ("PC", "Codespace", "DinD Codespace", "CI", "GitHub", "owner")
24@dataclass(frozen=True)
25class Surface:
26 id: str
27 command: str
28 proves: str
29 host: tuple[str, ...]
30 time: str
31 evidence: str
32 required: str # when it must have passed: "every change", "every commit", "a phase", "a release", "on demand"
33 quick: bool = False
34 argv: tuple[str, ...] = field(default_factory=tuple) # what `aq verify --quick` runs; empty for a surface that does not run on the PC
37def _s(id, command, proves, host, time, evidence, required, argv=None):
38 return Surface(id, command, proves, tuple(host), time, evidence, required, bool(argv), tuple(argv or ()))
41PY = sys.executable
42SURFACES: tuple[Surface, ...] = (
43 # --- code style and compatibility
44 _s("ruff", "ruff check .", "style and the obvious errors", ["PC", "CI"], "10 s", "stdout", "every change", [PY, "-m", "ruff", "check", "."]),
45 _s("vermin", "vermin -t=3.10- --no-tips --violations -q <first-party>", "no source needs more than Python 3.10 (#326)", ["PC", "CI"], "5 s", "stdout; CI python-compat", "every commit"),
46 _s("doctor", "aq doctor", "this machine can run the project: Python, the editable install, the hook, git, gh, Docker, RAM, config.json", ["PC"], "5 s", "stdout (--json)", "a phase"),
47 _s("hook", "aq check", "the pre-commit hook's gates (secrets, library gate, inventory, pins, ruff on staged files, coverage of changed modules) without a commit", ["PC"], "1-20 min", "stdout", "every commit"),
48 _s("docs_links", "aq docs links", "every relative link and heading anchor in the README, docs/, development/ and the sub-readmes resolves", ["PC", "CI"], "5 s", "stdout", "every change", [PY, "-m", "aq_cli", "docs", "links"]),
49 _s("ci_status", "aq ci status --watch", "every workflow of the pushed commit finished green (exit 3 while running)", ["GitHub"], "20-40 min", "GitHub Actions; aq ci logs <run>", "every push"),
50 # --- the suite
51 _s("suite", "aq test", "the whole offline suite, then the doc facts", ["Codespace", "CI"], "4-6 min (PC: out of memory)", "stdout, coverage-report/coverage.xml", "every commit"),
52 _s("buckets", "aq test --<bucket>", "each of 17 subsystems is self-contained", ["PC", "CI"], "1-2 min each", "stdout", "every commit"),
53 _s("guards", "pytest tests/test_ci_workflows.py tests/test_docs_facts.py tests/test_aether_quant_coverage.py ...", "workflows, docs facts, the library gate, packaging, help surface", ["PC", "CI"], "30 s", "stdout; CI fast-guards", "every change", [PY, "-m", "pytest", "-q", "-p", "no:cacheprovider", "tests/test_ci_workflows.py", "tests/test_docs_facts.py", "tests/test_aether_quant_coverage.py", "tests/test_module_has_test.py", "tests/test_formal_no_sorry.py", "tests/test_verification_matrix.py"]),
54 _s("clean_checkout", "scripts/clean_checkout_test.ps1 or scripts/codespace_verify.ps1 -Start", "no test depends on a gitignored file; every CI job once, before the push", ["Codespace"], "40-60 min", "/tmp/aq_verify/status, <stage>.log", "a phase"),
55 # --- the installed models (V6.6.9, #382)
56 _s("artifact_pins", "python scripts/check_artifact_pins.py", "the installed model files are the pinned set: a rewritten scaler can't pass for the one the models were fitted with", ["PC", "CI"], "1 s", "stdout; every suite run (tests/conftest.py)", "every change", [PY, "scripts/check_artifact_pins.py"]),
57 _s("model_book_decide", "python scripts/model_book_decide.py --session <D> --out <csv>", "the model book's daily decision: refused on a changed model file, stale closes or stale scores, equal to the verification row on a session both cover", ["PC"], "2 min", "the csv; forward/decisions.jsonl", "a decision"),
58 # --- the library
59 _s("library_gate", "python scripts/library_gate.py", "a public function is in aether_quant or explained; the backlog only shrinks", ["PC", "CI"], "1 s", "stdout; pre-commit hook", "every commit", [PY, "scripts/library_gate.py"]),
60 _s("formal_inventory", "python scripts/formal_inventory.py", "every public function of the trading and research paths is proved in Lean, excluded with a reason, or in a backlog that only shrinks", ["PC", "CI"], "2 s", "stdout; pre-commit hook", "every commit", [PY, "scripts/formal_inventory.py"]),
61 _s("api_pin", "aq test --meta (tests/test_aether_quant_api.py)", "every export resolves to the real function; the import stays light; the public surface only changes on purpose", ["PC", "CI"], "1 min", "tests/data/aether_quant_api.json", "every commit"),
62 _s("quickstart", "tests/test_aether_quant_quickstart.py", "the library works from an uninstalled checkout, examples included", ["PC", "CI"], "1 min", "stdout", "every commit"),
63 _s("wheel_smoke", "python scripts/wheel_smoke.py (built wheel, outside the checkout)", "every shipped module imports, every aq subcommand has --help, one real call into each library module", ["Codespace", "CI"], "2 min", "stdout; CI wheel-smoke", "a release"),
64 # --- proofs
65 _s("prove", "aq prove", "the Lean 4 specs build (Mathlib)", ["Codespace", "CI"], "5 min (Mathlib cached)", "stdout; CI formal.yml", "every change to formal/ or a modelled file"),
66 _s("prove_sorry", "aq prove --check-sorry", "no sorry or admit in any spec", ["PC", "CI"], "1 s", "stdout; tests/test_formal_no_sorry.py", "every commit", [PY, "aq_cli.py", "prove", "--check-sorry"]),
67 _s("axioms", "python scripts/check_axioms.py", "every theorem rests on the three standard axioms, but two named native_decide findings", ["Codespace", "CI"], "2 min", "stdout; CI formal.yml", "every change to formal/"),
68 _s("differential", "aq test --formal", "the Python functions equal the Lean models on thousands of computed cases (37 targets)", ["PC", "CI"], "1 min", "aether_quant/_formal_cases/*.json", "every commit"),
69 # --- other kinds of test
70 _s("properties", "pytest tests/test_v664_properties.py", "invariants of the order gate, admission, session, shares, weight caps, hash chain and JSON safety hold for every input (hypothesis, derandomized)", ["PC", "CI"], "2 min", "stdout", "every commit"),
71 _s("mutation", "python scripts/mutation_check.py --out ml/evaluation/v664/mutation.json", "the tests of seven safety and ledger modules notice a changed comparison, operator or constant", ["Codespace"], "1-2 h", "ml/evaluation/v664/mutation.json", "a phase"),
72 _s("on_data", "pytest tests/test_main_on_data_target_weights.py", "on_data() on the shipped path places the orders the pure rebalance function says, across a week", ["PC", "CI"], "10 s", "stdout", "every change to main.py"),
73 _s("module_has_test", "pytest tests/test_module_has_test.py", "every shipped module has its own test file or is on the frozen list", ["PC", "CI"], "5 s", "stdout", "every commit", [PY, "-m", "pytest", "-q", "-p", "no:cacheprovider", "tests/test_module_has_test.py"]),
74 # --- docs, secrets, dependencies, images
75 _s("docs_sync", "aq docs sync --check", "every number quoted in a doc is a current fact", ["PC", "CI"], "10 s", "stdout", "every commit", [PY, "aq_cli.py", "docs", "sync", "--check"]),
76 _s("secrets", "aq secrets-check", "no secret in a tracked file", ["PC", "CI"], "2 s", "stdout; pre-commit hook", "every commit", [PY, "aq_cli.py", "secrets-check"]),
77 _s("readme_freshness", "python scripts/readme_freshness.py --since <date>", "the README's generated blocks are newer than their inputs", ["PC"], "10 s", "stdout", "a phase"),
78 # --- the engine
79 _s("lean_backtest", "aq backtest", "a real Lean backtest of the shipped book (the owner runs it)", ["owner"], "1 h+", "backtests/<run>/log.txt", "a material change to the book"),
80 _s("lean_runs", "scripts/codespace_lean_run.ps1 -Create/-Push/-Run/-Pull -Delete", "frozen run configs on a DinD Codespace, engine log read for completion (rule 7)", ["DinD Codespace"], "2 min per 3 years", "backtests/<run>/", "a change to the book"),
81 _s("lean_smoke:option_structures", "bash scripts/lean_smoke/run.sh option_structures", "all 43 option structures fill in Lean's engine on its sample chain", ["DinD Codespace"], "30 s", "backtests/smoke_option_structures", "a phase"),
82 _s("lean_smoke:futures_margin", "bash scripts/lean_smoke/run.sh futures_margin", "futures margin calls main.py makes return a number", ["DinD Codespace"], "30 s", "backtests/smoke_futures_margin", "a phase"),
83 _s("lean_smoke:exception_scope", "bash scripts/lean_smoke/run.sh exception_scope", "Lean's star import shadows Exception, which main.py corrects (#276)", ["DinD Codespace"], "30 s", "backtests/smoke_exception_scope", "on demand"),
84 _s("lean_smoke:main_option_order", "bash scripts/lean_smoke/run_main_option_order.sh", "main.py's own multi-leg order fills on the sample chain", ["DinD Codespace"], "2 min", "backtests/smoke_main_option_order", "a phase"),
85 _s("lean_smoke:main_option_scenarios", "bash scripts/lean_smoke/run_main_option_scenarios.sh <scale|all43|arb|assign>", "scale-down, rotation, every structure, the arbitrage router and the assignment sweep through main.py", ["DinD Codespace"], "2 min each", "ml/evaluation/v664/lean_smoke_option_*.jsonl", "a phase"),
86 _s("lean_smoke:live_plumbing", "bash scripts/lean_smoke/live_plumbing.sh", "main.py runs in Lean's live-paper mode on PaperBrokerage and fake ticks with no login or key, survives Redis then Postgres stopping under it, restarts, and the audit chain verifies", ["DinD Codespace"], "10 min", "ml/evaluation/v664/live_plumbing.json", "a phase"),
87 _s("engine_check", "scripts/codespace_engine_check.sh", "the pinned engine image runs a teardown-clean algorithm", ["DinD Codespace"], "5 min", "/tmp/aq_lean/engine_status", "on demand"),
88 # --- evaluation audits
89 _s("lean_report", "aq evaluate --lean-report --backtest-dir <run>", "statistics, alpha proof, attribution and every run-folder tool for a pinned run (rule 8)", ["PC"], "2 min", "ml/evaluation/*.json, README blocks", "every new pin"),
90 _s("reconcile_features", "aq evaluate --reconcile-features --symbol <X>", "a backtest's feature snapshot equals the dataset's row (rule 12)", ["PC"], "1 min", "ml/evaluation/feature_reconciliation.json", "a change to features"),
91 _s("paper_check", "aq evaluate --paper-check --backtest-dir <run> --reference-dir <pin>", "a paper run sits inside the frozen bands of the pinned run", ["PC"], "10 s", "ml/evaluation/paper_check.json", "a paper period"),
92 _s("forward_ledger", "aq evaluate --forward-ledger; aq cycle status", "the forward chains are intact and current", ["PC", "GitHub"], "5 s", "forward/*.jsonl on the forward-ledger branch", "every session"),
93 _s("research_round", "aq cycle research score|placebo|gate|pbo|report --round <file>", "a pre-registered round, rule file hashed in the vault before any score", ["PC", "Codespace"], "5 min - 2 h", "ml/evaluation/<phase>/", "a research round"),
94 # --- services and field tests
95 _s("audit_verify", "aq audit-log --verify", "the audit chain in Postgres is intact (a real database; #339)", ["Codespace"], "5 s", "stdout", "a phase"),
96 _s("paper_readiness", "aq paper-readiness", "the paper-readiness checklist against real services", ["Codespace"], "5 s", "visualization/grafana/paper_readiness_report.json", "a phase"),
97 _s("field_test_services", "python scripts/field_test_services.py (scripts/field_services.sh up)", "audit events flow Redis to Postgres, a tampered row is found, each service restarts underneath a running pipeline", ["Codespace"], "2 min", "ml/evaluation/v664/field_test_services.json", "a phase"),
98 _s("lean_smoke:field_test", "python scripts/lean_smoke/field_test.py", "main.py on Lean's paper brokerage places and fills an order, an injected drift breaches reconciliation, an injected shock trips the kill switch and flattens the book, a restart resumes, Redis and Postgres outages pass, two accounts run apart, the audit chain verifies", ["PC", "Codespace"], "1 h", "ml/evaluation/field_test/<date>/report.json", "a phase; a change to the safety path"),
99 _s("live_readiness", "aq live-readiness", "every paper-to-live condition, measured; unknown counts as fail", ["PC"], "10 s", "visualization/grafana/live_readiness.json, docs/live/paper-to-live.md", "a phase; before any live capital"),
100 _s("lite_install", "pytest tests/test_lite_install.py (a clean venv with the built wheel: aq hello --offline)", "the base install (numpy, pandas) imports every facade and runs aq hello", ["PC", "CI"], "1 min", "ml/evaluation/v665/lite_install.json", "every commit"),
101 _s("hello", "aq hello [--offline]", "the five-minute start downloads keyless data, backtests the shipped rule and reports", ["PC"], "30-60 s", "stdout, --json", "a release"),
102 _s("type_completeness", "python scripts/type_completeness.py", "every export of aether_quant is fully annotated; the floor only rises", ["PC", "CI"], "20 s", "ml/evaluation/v665/type_completeness.json", "every commit"),
103 _s("docs_site", "python scripts/build_docs.py && mkdocs build --strict", "the docs site builds with no warning, every facade has a reference page", ["PC", "CI"], "1 min", "site/", "every change to docs/ or a public docstring"),
104 _s("notebooks", "python scripts/build_notebooks.py --check --execute", "the four tutorials match their sources and run clean", ["PC", "CI"], "5 min", "notebooks/*.ipynb", "every change to notebooks/ or the library"),
105 _s("dashboard_image", "docker build --target dashboard -t aether-quant-dashboard . && docker run -p 8080:8000", "the light dashboard image builds, serves the UI and answers /api/health in demo mode", ["PC", "CI"], "5 min", "ml/evaluation/v665/dashboard.json", "every change to Dockerfile, webui/ or monitoring/"),
106 _s("bandit", "bandit -r <shipped packages> -lll -c pyproject.toml", "no high-severity static finding in shipped code", ["PC", "CI"], "1 min", "stdout", "every commit"),
107 # --- CI jobs (one row each; the table is held to ci.yml)
108 _s("coverage", "aq test --coverage", "every tracked module at 100%, one group at a time", ["PC", "Codespace"], "1-2 h on the PC", "coverage-report/coverage.json", "every commit"),
109 _s("coverage_changed", "aq test --coverage --changed", "every module changed since HEAD at 100% under the tests that name it (the pre-commit hook)", ["PC", "CI"], "1-5 min", "stdout; coverage-report/.coverage.changed", "every commit", [PY, "aq_cli.py", "test", "--coverage", "--changed"]),
110 _s("scorecard_pins", "python scripts/scorecard_pins.py", "every install in a workflow, Dockerfile or shell script is pinned by hash, as the OpenSSF Scorecard reads it", ["PC", "CI"], "1 s", "stdout; pre-commit hook; CI fast-guards", "every commit", [PY, "scripts/scorecard_pins.py"]),
111 _s("ci:python-tests", "CI: ubuntu and windows, coverage gate 100% of every tracked module", "the suite on both platforms, and the JUnit report behind the test badge", ["CI"], "6 min", "GitHub Actions", "every push"),
112 _s("ci:python-lint", "CI: ruff and py_compile main.py", "lint and syntax", ["CI"], "1 min", "GitHub Actions", "every push"),
113 _s("ci:dependency-audit", "CI: pip-audit", "no known-vulnerable pinned dependency", ["CI"], "3 min", "GitHub Actions", "every push"),
114 _s("ci:webui-tests", "CI: tsc, oxlint (jsx-a11y), vitest with coverage, build, npm audit", "the dashboard builds, its tests pass and no runtime dependency has a high advisory", ["CI"], "2 min", "GitHub Actions", "every push"),
115 _s("ci:cli-smoke", "CI: aq --help, config get, secrets-check", "the CLI starts from a clean install", ["CI"], "1 min", "GitHub Actions", "every push"),
116 _s("ci:workflows-lint", "CI: actionlint", "workflow syntax", ["CI"], "10 s", "GitHub Actions", "every push"),
117 _s("ci:fast-guards", "CI: guard tests", "registration, help surface, workflows, packaging, docs, library gate", ["CI"], "1 min", "GitHub Actions", "every push"),
118 _s("ci:subsystem-matrix", "CI: aq test --<bucket> for each of 15 buckets", "each bucket stands alone", ["CI"], "2 min each", "GitHub Actions", "every push"),
119 _s("ci:wheel-smoke", "CI: build and install the wheel outside the checkout", "the package works installed", ["CI"], "1 min", "GitHub Actions", "every push"),
120 _s("ci:python-compat", "CI: byte-compile and vermin on Python 3.10", "the floor in requires-python holds", ["CI"], "1 min", "GitHub Actions", "every push"),
121 _s("ci:docker-checks", "CI: hadolint, compose config, dashboard build and smoke, trivy", "the Dockerfiles lint, the compose files parse, the dashboard image serves and has no fixable critical CVE", ["CI"], "6 min", "GitHub Actions", "every push"),
122 _s("ci:lite-install", "CI: the wheel in a clean venv with no extras", "the light install imports every facade and runs aq hello --offline", ["CI"], "2 min", "GitHub Actions", "every push"),
123 _s("ci:typecheck", "CI: scripts/type_completeness.py (pyright advisory)", "the public API stays fully annotated", ["CI"], "1 min", "GitHub Actions", "every push"),
124 _s("ci:docs", "CI: mkdocs build --strict", "the docs site builds", ["CI"], "2 min", "GitHub Actions (site artifact)", "every push"),
125 _s("ci:notebooks", "CI: build_notebooks.py --check --execute", "the tutorials run", ["CI"], "6 min", "GitHub Actions", "every push"),
126 _s("ci:bandit", "CI: bandit -lll", "no high-severity static finding", ["CI"], "1 min", "GitHub Actions", "every push"),
127 _s("ci:cpp-sanitizers", "CI: cpp_inference_ext under ASan and UBSan", "the C++ kernel has no memory error or undefined behaviour; a canary overflow aborts first", ["CI"], "5 min", "GitHub Actions", "every push"),
128 _s("ci:parity-smoke", "CI: parity tests and feature_parity_audit --synthetic-only", "live and offline compute the same features", ["CI"], "1 min", "GitHub Actions", "every push"),
129 _s("ci:lowmem-proof", "CI: scripts/lowmem_proof.py --rows 280000 --budget-gb 2.6", "the model stack trains in 2.6 GB under --memory-profile low", ["CI"], "15-30 min", "GitHub Actions", "every push"),
130 _s("ci:secret-scan", "CI: gitleaks (blocking on the tree, advisory on history)", "no secret in a tracked file", ["CI"], "10 s", "GitHub Actions", "every push"),
131 # --- the other workflows
132 _s("wf:formal", ".github/workflows/formal.yml", "the proofs, the sorry scan, regenerated cases and axioms on spec changes and monthly", ["GitHub"], "10 min", "GitHub Actions", "every change to formal/"),
133 _s("wf:forward-ledger", ".github/workflows/forward-ledger.yml", "one hash-chained forward row a session for the frozen rule", ["GitHub"], "30 s", "branch forward-ledger", "every session"),
134 _s("wf:research-cycle", ".github/workflows/research-cycle.yml", "one row per tracked generation and the allocation a session", ["GitHub"], "30 s", "branch forward-ledger", "every session"),
135 _s("wf:model-cycle", ".github/workflows/model-cycle.yml", "the pipeline on the sample and the example models, one row a week", ["GitHub"], "10-20 min", "branch forward-ledger", "every week"),
136 _s("wf:keepalive", ".github/workflows/keepalive.yml", "the schedules stay enabled", ["GitHub"], "10 s", "GitHub Actions", "monthly"),
137 _s("wf:release", ".github/workflows/release.yml", "the tagged commit's suite, PyPI and both images with SBOMs and provenance (the tag is the owner's)", ["GitHub", "owner"], "20 min", "GitHub Actions", "a release"),
138 _s("wf:codeql", ".github/workflows/codeql.yml", "CodeQL over Python, TypeScript and the workflows", ["GitHub"], "10 min", "GitHub code scanning", "every push to main; weekly"),
139 _s("wf:fuzz", ".github/workflows/fuzz.yml", "Atheris over the eight fuzz targets, two minutes each", ["GitHub"], "5 min", "GitHub Actions (crash inputs as artifacts)", "every change to a target; weekly"),
140 _s("wf:scorecard", ".github/workflows/scorecard.yml", "the OpenSSF Scorecard of the repository", ["GitHub"], "2 min", "GitHub code scanning, scorecard.dev", "every push to main; weekly"),
141 _s("wf:pages", ".github/workflows/pages.yml", "the docs, coverage HTML and the coverage badge on GitHub Pages", ["GitHub"], "3 min", "https://leon1706-lol.github.io/Aether-quant/", "every green CI on main"),
142 _s("wf:ci", ".github/workflows/ci.yml", "the jobs above", ["GitHub"], "6 min", "GitHub Actions", "every push"),
143)
146def by_id() -> dict[str, Surface]:
147 return {surface.id: surface for surface in SURFACES}
150def quick_set() -> list[Surface]:
151 return [surface for surface in SURFACES if surface.quick]
154def markdown() -> str:
155 """The table `development/verification.md` carries between its markers."""
156 lines = ["| Surface | Command | What it proves | Host | Time | Evidence | When |", "|---|---|---|---|---|---|---|"]
157 for surface in SURFACES:
158 lines.append(
159 f"| `{surface.id}` | `{surface.command}` | {surface.proves} | {', '.join(surface.host)} | {surface.time} | {surface.evidence} | {surface.required} |"
160 )
161 return "\n".join(lines)
164def run_quick(root: Path, *, runner: Callable = subprocess.run, emit: Callable[[str], None] = print) -> list[dict]:
165 """Runs the PC-safe surfaces one after another and reports each: id, exit code, seconds, the last lines of output."""
166 results = []
167 for surface in quick_set():
168 started = time.time()
169 result = runner(list(surface.argv), cwd=str(root), capture_output=True, text=True)
170 text = ((result.stdout or "") + (result.stderr or "")).strip().splitlines()
171 results.append({"id": surface.id, "exit": result.returncode, "seconds": round(time.time() - started, 1), "tail": text[-3:]})
172 emit(f"{'ok ' if result.returncode == 0 else 'FAIL'} {surface.id} ({results[-1]['seconds']} s)")
173 return results
176def record(path: Path, results: Sequence[Mapping]) -> None:
177 Path(path).parent.mkdir(parents=True, exist_ok=True)
178 Path(path).write_text(json.dumps({"surfaces": len(SURFACES), "quick_run": list(results), "all_quick_passed": all(item["exit"] == 0 for item in results)}, indent=1), encoding="utf-8", newline="\n")