feat(fase2a): MAF version-guard (test-tidsvakt, dist-metadata) + pin agent-framework-core<2 (S2.5)
This commit is contained in:
parent
0a227a103b
commit
73c24fc69a
3 changed files with 67 additions and 2 deletions
|
|
@ -9,7 +9,7 @@ dependencies = [
|
|||
# og `[all]` trekker inn de fortsatt-beta integrasjonene (azure-ai-search/cosmos/ollama/…) som
|
||||
# tvinger pre-releases og drar med en ALPHA pydantic. Offisiell guide: installer kun det du trenger.
|
||||
# Beta-integrasjoner legges til per-fase (med snevert pre-release-scope) når de faktisk trengs.
|
||||
"agent-framework-core>=1.9.0", # kjerne (GA)
|
||||
"agent-framework-core>=1.9.0,<2", # kjerne (GA) — to-sidig pin (S2.5): major-bump krever re-verifisering av privat-API-premissene (test_maf_version_guard)
|
||||
"agent-framework-foundry>=1.8.2", # Azure/Foundry-profil: FoundryChatClient (GA)
|
||||
"agent-framework-openai>=1.8.2", # OpenAI + OpenAI-kompatible lokale endpoints (GA) → lokal profil
|
||||
# Promotert dev→core i Fase 2 (MVP-runtime, ikke lenger spike-only):
|
||||
|
|
|
|||
65
tests/test_maf_version_guard.py
Normal file
65
tests/test_maf_version_guard.py
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
"""S2.5 MAF version-guard — a TEST-TIME tripwire + a two-sided install pin.
|
||||
|
||||
The offline simulation depends on MAF's PRIVATE API (the ``_inner_get_response`` keyword-only
|
||||
signature + ``_build_response_stream`` construction — see ``conftest`` / ``simulation``'s scripted
|
||||
client). A major ``agent-framework-core`` bump could change those without notice. This is NOT a
|
||||
runtime guard (an un-wired ``src`` helper would be green-but-dead); it is a test-time tripwire
|
||||
against the installed distribution PLUS a two-sided pin in ``pyproject.toml`` (install-time).
|
||||
|
||||
Critical: the guard reads the DISTRIBUTION version via
|
||||
``importlib.metadata.version("agent-framework-core")`` (verified ``1.9.0``), NOT
|
||||
``agent_framework.__version__`` (verified ``0.0.0`` placeholder — reading that would make the guard
|
||||
permanently RED / meaningless). Modelled on ``test_smoke``'s version-assert + ``test_portfolio``'s
|
||||
grep-pin.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib.metadata
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
_DIST = "agent-framework-core"
|
||||
|
||||
|
||||
def assert_supported_maf_version(version_str: str) -> None:
|
||||
"""Raise ``ValueError`` when ``version_str`` is outside the supported ``>=1.9.0,<2`` range, naming
|
||||
the private-API premises to re-verify before a bump. Pure string parse — no import side effects,
|
||||
so a fake version can be passed directly (the RED-proof) without touching the real install."""
|
||||
parts = version_str.split(".")
|
||||
major = int(parts[0])
|
||||
minor = int(parts[1]) if len(parts) > 1 else 0
|
||||
if not (major == 1 and minor >= 9):
|
||||
raise ValueError(
|
||||
f"{_DIST} {version_str} is outside the supported range >=1.9.0,<2. Before bumping, "
|
||||
"re-verify the private-API premises the offline sim relies on: the _inner_get_response "
|
||||
"keyword-only signature (messages/options/stream) and the _build_response_stream "
|
||||
"construction. Update the pin in pyproject.toml once confirmed."
|
||||
)
|
||||
|
||||
|
||||
def test_installed_maf_version_is_supported() -> None:
|
||||
"""T-2.5d: the real installed distribution (verified 1.9.0) passes the guard — read from
|
||||
``importlib.metadata.version``, NOT ``agent_framework.__version__`` (a 0.0.0 placeholder)."""
|
||||
assert_supported_maf_version(importlib.metadata.version(_DIST))
|
||||
|
||||
|
||||
def test_guard_rejects_future_major() -> None:
|
||||
"""T-2.5d: a future major (``2.0.0``) trips the guard with the actionable upgrade message —
|
||||
RED-proof without touching the real install."""
|
||||
with pytest.raises(ValueError, match="private-API premises"):
|
||||
assert_supported_maf_version("2.0.0")
|
||||
|
||||
|
||||
def test_guard_rejects_too_old_minor() -> None:
|
||||
"""T-2.5d: a pre-1.9 minor (``1.8.0``) also trips the guard (the pin is two-sided)."""
|
||||
with pytest.raises(ValueError, match="private-API premises"):
|
||||
assert_supported_maf_version("1.8.0")
|
||||
|
||||
|
||||
def test_pyproject_pins_agent_framework_core_below_2() -> None:
|
||||
"""T-2.5d: ``pyproject.toml`` pins ``agent-framework-core>=1.9.0,<2`` — the install-time half of
|
||||
the guard (the test above is the test-time half)."""
|
||||
pyproject = (Path(__file__).resolve().parents[1] / "pyproject.toml").read_text(encoding="utf-8")
|
||||
assert "agent-framework-core>=1.9.0,<2" in pyproject
|
||||
2
uv.lock
generated
2
uv.lock
generated
|
|
@ -1435,7 +1435,7 @@ dev = [
|
|||
|
||||
[package.metadata]
|
||||
requires-dist = [
|
||||
{ name = "agent-framework-core", specifier = ">=1.9.0" },
|
||||
{ name = "agent-framework-core", specifier = ">=1.9.0,<2" },
|
||||
{ name = "agent-framework-foundry", specifier = ">=1.8.2" },
|
||||
{ name = "agent-framework-openai", specifier = ">=1.8.2" },
|
||||
{ name = "agent-framework-orchestrations", specifier = ">=1.0.0" },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue