Automated tests for the Agent Kaizen harness. Standard-library unittest only—no extra dependencies beyond the pinned runtime in requirements-kaizen.txt. Some tests skip unless optional PDF backends from requirements-docs.txt, sentence-transformers from requirements-pytorch.txt, or explicitly enabled live backends and servers are available.
The outer runner exclusively allocates one AI/work/<run-id>/ root, exports a complete matching KAIZEN_TEST_RUN_ID and absolute KAIZEN_TEST_TEMP_ROOT, and supplies child-only environment overlays for temporary files, caches, bytecode, package managers, fixtures, sockets, databases, journals, installers, benchmarks, and logs. Nested runners validate and inherit that pair. They do not allocate another run or set KAIZEN_REPO_ROOT globally.
Protocol, serialization, ownership, and vector-data tests append immutable rows to regular quoted "tests" tables. Product operations never see those rows. Production DDL, API, transaction, and native F32/F64 behavior uses throwaway tables in one run-owned scratch database; a separate database file is used only when journaling, corruption, locking, recovery, swap, or file ownership is the behavior under test.
Only the outer runner removes the run root. Cleanup is strict: a remaining child, lock, journal, cache, or deletion failure fails the run. Tests invoke sys.executable, so run the canonical wrapper with the shared Kaizen venv that has pyturso installed.
The no-argument default is the fast core lane. It contains deterministic unit, static, schema, and contract tests; it never includes the slow, live, or extension lanes. The current supported release scope is genuine Windows core, platform, and slow; slow remains an explicit manual selection.
# Windows
& "$env:DEVROOT\Python\venvs\kaizen\Scripts\python.exe" tests/run_tests.py# Linux / macOS development evaluation only
"$DEVROOT/Python/venvs/kaizen/bin/python" tests/run_tests.pyList lane ownership without creating test scratch:
& "$env:DEVROOT\Python\venvs\kaizen\Scripts\python.exe" tests/run_tests.py --list-lanesRun the bounded host-contract lane when changing filesystem, process, installer, or loopback behavior:
& "$env:DEVROOT\Python\venvs\kaizen\Scripts\python.exe" tests/run_tests.py --lane platformSubprocess-heavy, concurrency, timeout, benchmark, and integration tests are explicit because they dominate suite runtime. Run the affected module during development, and run the whole slow lane only when the change spans those surfaces or before a release candidate:
& "$env:DEVROOT\Python\venvs\kaizen\Scripts\python.exe" tests/run_tests.py test_session_drive.WriterLeaseConcurrencyTest
& "$env:DEVROOT\Python\venvs\kaizen\Scripts\python.exe" tests/run_tests.py --lane slowProvider/live tests retain their own environment gates and never run implicitly. The canonical runner removes an ambient KAIZEN_RUN_LIVE unless --lane live is selected, including for raw unittest selectors. The extension lane also requires an explicit selection; its Node runner discovers every compiled test instead of maintaining a manual allowlist:
& "$env:DEVROOT\Python\venvs\kaizen\Scripts\python.exe" tests/run_tests.py --lane live
& "$env:DEVROOT\Python\venvs\kaizen\Scripts\python.exe" tests/run_tests.py --lane extensionThe release driver lists and preflights its deterministic gates without running them, executes the current Windows release scope plus explicitly selected development scopes, validates an existing report, and admits live systems only through explicit provider selections:
& "$env:DEVROOT\Python\venvs\kaizen\Scripts\python.exe" tests/release_validation.py --list
& "$env:DEVROOT\Python\venvs\kaizen\Scripts\python.exe" tests/release_validation.py --preflight
& "$env:DEVROOT\Python\venvs\kaizen\Scripts\python.exe" tests/release_validation.py --all-local
& "$env:DEVROOT\Python\venvs\kaizen\Scripts\python.exe" tests/release_validation.py --preflight --include-extension
& "$env:DEVROOT\Python\venvs\kaizen\Scripts\python.exe" tests/release_validation.py --preflight --include-linux
& "$env:DEVROOT\Python\venvs\kaizen\Scripts\python.exe" tests/release_validation.py --check <report.json>Genuine Linux and the extension are IN DEVELOPMENT, not default release blockers. An unselected development scope is INAPPLICABLE; after explicit selection, an unavailable host or missing prerequisite is NOT_RUN with a disposition. --include-linux requires a genuine Linux host; WSL execution is not genuine Linux release evidence.
Network dependency lookup, authentication, downloads, live providers, WSL registration, installer machine changes, and Windows security or Sandbox actions require separate owner approval. An unselected selection-gated external check is INAPPLICABLE; a selected check without its approval or prerequisite is NOT_RUN, not a pass.
GitHub pull requests and pushes automatically run the current Windows core and platform scope. workflow_dispatch exposes run_slow for Windows slow, run_linux for genuine Linux development core/platform (and Linux slow when combined with run_slow), and run_extension for the Windows extension development job. Linux and extension jobs are manual, non-required development evidence until the owner promotes them. The Ubuntu dependency-audit and DCO governance hosts do not establish Linux runtime support. Remote CI exists only after the owner pushes and is not a failed or missing local release gate before that boundary.
CI runs a second job, audit, that scans every pinned dependency set for known advisories; mirror it locally before pushing with pipx run pip-audit --progress-spinner off -r requirements-kaizen.txt -r requirements-docs.txt -r requirements-pytorch.txt — a clean audit run means the job will pass.
This curated map highlights major suites; it is not exhaustive. lane_manifest.py is the authoritative lane inventory; every root test_*.py module must have exactly one owner, and the runner fails closed on an unclassified, overlapping, or missing module.
test_op_coverage.py— the conformance matrix: AST-scans the whole suite and fails if any CLI operation is not exercised by at least one test (ALLOWED_UNTESTEDis empty by design).test_doc_examples.py— executes everykaizen.pycommand example inREADME.md,setup/SETUP.md, andevals/README.mdagainst a scratch database (placeholder IDs threaded between commands), and assertsCLAUDE.md/AGENTS.mdstay byte-identical as whole files.test_bench_smoke.py—tests/bench_kaizen.py --quickruns green into a temp output dir (valid results JSON, perfect retrieval hit rate, semantic skipped, no personal paths) and never rewrites the repo's ownREADME.md/docs/BENCHMARKS.md.test_schema.py—K1is idempotent,K2reports a healthy schema,K3/K6run, plus ARC-067 schema-difference classification (identity-only drift reconciles atK1and never denies a write;K1 --restamp-manifestremains the repair for what K1 cannot reconcile), the typed four-domainK1 --integrityreport, and the deterministic half of K4 restore planning.test_input_hardening.py— the unified repo-only path policy (E1/A2deny outside-repo paths;--allow-externalstores a sanitizedexternal:origin), the UTF-8 decode denial on--*-fileinputs, LIKE wildcard escaping in evidence search, and the PDF ingestion guards (size/pages/encrypted/no-text; pypdf-dependent cases skip when the docs backend is absent).test_search_escaping.py— the sharedtext_search.like_patternhelper plus record-plane escaping: a literal_/%in a query matches literally (not as a wildcard) acrossG3/L5/X3/S2/Q9, the surfaces that route through the sameLIKE ? ESCAPE '\'path as evidence search.test_db_retry.py— retry-vocabulary/backoff unit tests plus a 4-process concurrentK1race regression against one shared data plane.test_learning_ops.py— the full L* lifecycle: adds,L2/L3promotion linkage (source_gotcha_id/source_learning_id), promoted-status transitions,G5updates,L10lineage narratives, denials.test_policy_ops.py—X1–X5round-trips, priority-over-recency ordering (an old critical rule survives the LIMIT window), trigger filtering, retired-rule exclusion.test_quality_ops.py—Q1–Q7,Q9filters, artifact ops,*-fileJSON fallbacks,Q7routing to eval runs/cases.test_report_ops.py—R0session digest (sections, counts, drift signals, limits),R1–R6report files,R4severity/actionability filters and enriched columns,R9/R10windows.test_plan_packet_ops.py—W2–W8: plan revisions, packet round-trips, object-only payload enforcement, revision counting viaK6.test_migration_ops.py—M1–M5: allowlists, dry-run purity (hash-snapshot), stub content, backups + manifest, verify/report.test_irl_ops.py—I1–I5: review/prediction/correction/outcome lifecycle and report files.test_lab_misc_ops.py—O1–O3improvement lab,S4export,E5inspect, and the newer redaction pattern classes.test_integration_chains.py— end-to-end chains across families (GOTCHA→LEARNED→report, task→artifact→verification→digest, trace→score→query, artifact path containment).test_cli_wiring.py—--help/--version, unknown/missing-op denials, ALIASES ↔ README command-table parity, and that every operation reaches a real dispatch branch (OK or a structuredDENIED, neverERROR_UNEXPECTED).test_records.py— create/inspect/query round-trips (GOTCHA, source locks, artifacts, traces), structured denials on missing required fields, and a cleanDENIED_FILE_NOT_FOUNDon a missing--*-file.test_reports.py—R7 --queryregression (no missing-bodycolumn error),R8–R10time-windowed ledger reports (incl. a recent-event inclusion check), andR11topic requiring--query.test_redaction.py— the secret/personal-path/email scanner, plus the trace-write gate denying secrets inenvironment/tags.test_output_validate.py—Q8lists schemas, accepts valid payloads, rejects invalid ones.test_aux.py— the prompt-builder imports cleanly with its external-checker read guarded, plus the repository doc-link contract (every repository-relative path written in tracked prose must resolve).test_vectors.py— Turso-native vector storage + cosine-distance nearest-neighbour search (the engine claim), exercised in a throwaway temp database.test_comfyui.py— the ComfyUI generative-run ops (Y*):Y1 --dry-runrecords aqueuedrun with a deterministic workflow hash + extracted seed/models (no network),Y2/Y3inspect/list, and graceful denials (DENIED_BACKEND_UNAVAILABLEwith no server, missing--path, bad workflow type).test_backends.py— the model-backend ops (B*) + embedding seam, with no live server:B1reports unconfigured/unreachable backends,B2/B3/E4 --semanticdeny cleanly when unconfigured, andE1→E3→E4still chunk + lexically search with no embeddings (graceful degradation). Also unit-tests the HTTP retry classifier (transient vs permanent,Retry-Afterhonoring) and the boundedembed_batchedhelper (ordered batches, count-mismatch denial).test_pytorch.py— the sentence-transformers selection +semanticchunker without the heavy extra installed: the in-process embedder is recognized, the absent extra denies cleanly,neuralis reserved, andsemanticchunking requires a configured backend (absent-extra tests skip if installed).test_comfyui_live.py— the ComfyUI live path against an in-process mock server:Y5reachable,Y1submit→wait→fetch→save→register→completed(output saved + hashed), andY4replay.test_backends_live.py— the model-backend live path against an in-process mock OpenAI server:B1reachable + dimension,E3stores embeddings, thesemanticchunker splits by similarity,E4 --semanticranks by cosine,B2records a model_call trace,B3backfills embeddings.