fix(v1.4.1): pristine validation imports + smoke-test preflight - #67
Merged
Brian Krabach (bkrabach) merged 1 commit intoApr 25, 2026
Merged
Conversation
v1.4.0 shipped to PyPI broken: clean `pip install amplifier-core==1.4.0` followed by `amplifier` startup raised `ModuleNotFoundError: No module named 'pytest'` because validators transitively pulled pytest as a runtime dep through `validation/structural/__init__.py`. The 5 type validators imported `check_on_session_ready` from `.structural` instead of `.base`, and `structural/__init__.py` eagerly loads test base classes that `import pytest` at module top level. Fix: - Move `check_on_session_ready()` from `validation/structural/__init__.py` to `validation/base.py` (function only depends on stdlib + `ValidationCheck`) - Update 5 validator files to import from `.base` instead of `.structural` - Keep re-export in `validation/structural/__init__.py` for backward compat Smoke-test gap fix: - The v1.4.0 e2e-smoke-test.sh missed this because Step 4 `uv tool install git+microsoft/amplifier@main` pulls pytest as a transitive into the venv, masking the missing runtime declaration. Added Step 1b: pristine-import preflight that installs ONLY the wheel into a bare python:3.12-slim and imports the production code paths. Catches this class of bug in <30s before any polluted CLI install runs. Regression test: - Added `tests/test_pristine_validation_imports.py` (3 tests, subprocess + `sys.modules['pytest'] = None` poisoning). Runs in any Python CI without needing docker; would have caught v1.4.0 deterministically. Documentation: - Added incident #5 (v1.4.0) row to `context/release-mandate.md` Incident History. Verification: - 34/34 targeted tests pass - Full e2e-smoke-test.sh passed end-to-end with new preflight step - pristine-import sanity confirmed locally with `sys.modules['pytest'] = None` 🤖 Generated with [Amplifier](https://github.com/microsoft/amplifier) Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
Brian Krabach (bkrabach)
deleted the
fix/v1.4.1-pristine-validation-imports
branch
April 25, 2026 10:00
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Incident response — v1.4.0 broken on PyPI
What broke in v1.4.0
A clean
pip install amplifier-core==1.4.0followed byamplifierstartup raises:Reproduced in pristine docker
python:3.12-slim. Import chain:pytestis not declared as a runtime dep (it's a dev/test dep). The 5 type validators importedcheck_on_session_readyfrom.structural, dragging in the test base classes thatimport pytestat module top level. The author's PR #63 commit message claimedcheck_on_session_readylived invalidation/base.py— it didn't.Why the smoke test missed it
e2e-smoke-test.shStep 4 (uv tool install git+microsoft/amplifier@main) pulls pytest as a transitive dep into the test venv. That venv pollution masked the missing runtime declaration — the smoke test environment was never actually pristine. A clean end-userpip install amplifier-coredoesn't get that pollution and fails.What this PR does
Fix the import (production code)
validation/base.pycheck_on_session_ready()function +import inspect+Anyvalidation/structural/__init__.pyfrom ..base import check_on_session_readyfor backward compatvalidation/{hook,tool,orchestrator,provider,context}.pyfrom .structural→from .baseAdd a regression test
tests/test_pristine_validation_imports.py— 3 tests using subprocess +sys.modules['pytest'] = Nonepoisoning to verify validators,check_on_session_readyfrom base, and_session_initimport path all work without pytest. Runs in <1s in any Python CI without needing docker. Would have caught v1.4.0 deterministically.Tighten the smoke test (gate fix)
scripts/e2e-smoke-test.sh— new Step 1b: pristine-import preflight that mounts the freshly built wheel into a barepython:3.12-slimand imports the production code paths. Runs before any polluted CLI install. Catches the v1.4.0 class of bug in ~10s.Bump version
pyproject.toml,crates/amplifier-core/Cargo.toml,bindings/python/Cargo.toml→1.4.1(atomic viascripts/bump_version.py).Document the incident
Added row #5 to the Incident History table in
context/release-mandate.md.Verification
Targeted tests:
Pristine-import sanity (without docker):
Full E2E smoke test (
SMOKE_TIMEOUT=360 ./scripts/e2e-smoke-test.sh):Pre-merge gate compliance (per
context/release-mandate.md)[tool.uv.sources]git overrides ✅Follow-ups (separate tickets, not blocking)
git+microsoft/amplifier@main's dep closure declares pytest as a non-optional dep — that misdeclaration was the root upstream cause of the smoke-test gap.__getattr__lazy loading invalidation/structural/__init__.pyso the package can be imported without pulling in test classes by default — defense-in-depth so future contributors can't reintroduce this class of bug by adding another non-test helper next tocheck_on_session_ready.