Publish curated ITWorx-ModelForge source from 990401737f96c8d46a9f7b0d84994516cadcb6a0
This commit is contained in:
1 parent
7082ab955a
commit
848f0d8f8a
434 files changed
+67298
-4315
No files matched your search
@@ -28,8 +28,10 @@ from modelforge_api.domain.release import (
|
||||
TARGET_SCHEMA_REVISION,
|
||||
Compatibility,
|
||||
SemanticVersion,
|
||||
_canonicalize_packaged_version,
|
||||
agent_protocol_compatibility,
|
||||
build_identity,
|
||||
release_channel_for,
|
||||
schema_compatibility,
|
||||
upgrade_required,
|
||||
)
|
||||
@@ -44,9 +46,6 @@ from modelforge_api.settings import Settings
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- one version
|
||||
|
||||
|
||||
def test_the_version_file_is_the_single_source_of_truth() -> None:
|
||||
declared = (ROOT / "VERSION").read_text("utf-8").strip()
|
||||
assert declared == PRODUCT_VERSION
|
||||
@@ -58,8 +57,6 @@ def test_the_version_file_is_the_single_source_of_truth() -> None:
|
||||
["backend/pyproject.toml", "node-agent/pyproject.toml", "runtime-worker/pyproject.toml"],
|
||||
)
|
||||
def test_every_python_manifest_matches_the_version_file(manifest: str) -> None:
|
||||
"""Four independent copies of the version is three chances to publish a wrong one."""
|
||||
|
||||
data = tomllib.loads((ROOT / manifest).read_text("utf-8"))
|
||||
assert data["project"]["version"] == PRODUCT_VERSION, (
|
||||
f"{manifest} declares {data['project']['version']!r}, VERSION says {PRODUCT_VERSION!r}"
|
||||
@@ -85,40 +82,76 @@ def test_every_component_module_matches_the_version_file(module: str) -> None:
|
||||
assert match.group(1) == PRODUCT_VERSION
|
||||
|
||||
|
||||
def test_the_release_version_is_semantic_and_not_a_prerelease() -> None:
|
||||
def test_the_release_version_is_the_explicit_rc_prerelease() -> None:
|
||||
parsed = SemanticVersion.parse(PRODUCT_VERSION)
|
||||
assert not parsed.is_prerelease
|
||||
assert parsed.is_prerelease
|
||||
assert parsed.prerelease == "rc.1"
|
||||
assert RELEASE_CHANNEL == "rc"
|
||||
assert parsed.major >= 1, "a v1 release cannot carry a 0.x major"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("bad", ["1.0", "1.0.0.0", "v1.0.0", "one.0.0", ""])
|
||||
def test_release_channel_is_derived_from_a_semantic_version() -> None:
|
||||
assert release_channel_for("1.3.0") == "stable"
|
||||
assert release_channel_for("1.3.0-rc.2") == "rc"
|
||||
assert release_channel_for("1.3.0-rc.preview") == "prerelease"
|
||||
assert release_channel_for("1.3.0-preview.2") == "prerelease"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("metadata_version", "expected"),
|
||||
[
|
||||
("1.3.0", "1.3.0"),
|
||||
("1.3.0rc1", "1.3.0-rc.1"),
|
||||
("1.3.0rc01", "1.3.0rc01"),
|
||||
("1.3.0a1", "1.3.0a1"),
|
||||
],
|
||||
)
|
||||
def test_installed_package_metadata_only_canonicalizes_numbered_rc_semver(
|
||||
metadata_version: str, expected: str
|
||||
) -> None:
|
||||
assert _canonicalize_packaged_version(metadata_version) == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize("bad", ["1.0", "1.0.0.0", "v1.0.0", "one.0.0", "1.0.0-", ""])
|
||||
def test_a_malformed_version_is_refused(bad: str) -> None:
|
||||
with pytest.raises(ValueError):
|
||||
SemanticVersion.parse(bad)
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- compatibility
|
||||
|
||||
|
||||
def test_the_target_schema_revision_is_supported() -> None:
|
||||
assert TARGET_SCHEMA_REVISION == "20260830_0024"
|
||||
assert TARGET_SCHEMA_REVISION == "20260924_0039"
|
||||
assert TARGET_SCHEMA_REVISION in SUPPORTED_SCHEMA_REVISIONS
|
||||
assert schema_compatibility(TARGET_SCHEMA_REVISION) is Compatibility.COMPATIBLE
|
||||
assert "20260827_0021" in SUPPORTED_UPGRADE_SOURCE_SCHEMA_REVISIONS
|
||||
assert "20260828_0022" in SUPPORTED_UPGRADE_SOURCE_SCHEMA_REVISIONS
|
||||
assert "20260923_0037" in SUPPORTED_UPGRADE_SOURCE_SCHEMA_REVISIONS
|
||||
assert "20260827_0021" not in SUPPORTED_SCHEMA_REVISIONS
|
||||
assert "20260923_0037" not in SUPPORTED_SCHEMA_REVISIONS
|
||||
|
||||
|
||||
def test_the_rc_schema_has_one_explicit_direct_upgrade_contract() -> None:
|
||||
# The version bump is a later release tranche. This schema tranche must already describe every
|
||||
# accepted source honestly so an intermediate protected merge cannot migrate the wrong target.
|
||||
assert PRODUCT_VERSION == "1.2.2"
|
||||
assert PRODUCT_VERSION == "1.3.0-rc.1"
|
||||
assert MINIMUM_UPGRADE_SOURCE == "v1.0.0"
|
||||
assert SUPPORTED_UPGRADE_SOURCE_SCHEMA_REVISIONS == (
|
||||
"20260827_0021",
|
||||
"20260828_0022",
|
||||
"20260830_0023",
|
||||
"20260830_0024",
|
||||
"20260907_0025",
|
||||
"20260908_0026",
|
||||
"20260908_0027",
|
||||
"20260908_0028",
|
||||
"20260909_0029",
|
||||
"20260909_0030",
|
||||
"20260909_0031",
|
||||
"20260909_0032",
|
||||
"20260909_0033",
|
||||
"20260910_0034",
|
||||
"20260911_0035",
|
||||
"20260923_0036",
|
||||
"20260923_0037",
|
||||
"20260924_0038",
|
||||
"20260924_0039",
|
||||
)
|
||||
|
||||
|
||||
@@ -137,7 +170,19 @@ def test_v1_1_documents_the_destructive_downgrade_boundary_truthfully() -> None:
|
||||
@pytest.mark.parametrize(
|
||||
("revision", "expected"),
|
||||
[
|
||||
("20260830_0024", Compatibility.COMPATIBLE),
|
||||
("20260923_0036", Compatibility.TOO_OLD),
|
||||
("20260923_0037", Compatibility.TOO_OLD),
|
||||
("20260924_0038", Compatibility.TOO_OLD),
|
||||
("20260924_0039", Compatibility.COMPATIBLE),
|
||||
("20260911_0035", Compatibility.TOO_OLD),
|
||||
("20260910_0034", Compatibility.TOO_OLD),
|
||||
("20260909_0033", Compatibility.TOO_OLD),
|
||||
("20260909_0032", Compatibility.TOO_OLD),
|
||||
("20260908_0028", Compatibility.TOO_OLD),
|
||||
("20260908_0027", Compatibility.TOO_OLD),
|
||||
("20260908_0026", Compatibility.TOO_OLD),
|
||||
("20260907_0025", Compatibility.TOO_OLD),
|
||||
("20260830_0024", Compatibility.TOO_OLD),
|
||||
("20260830_0023", Compatibility.TOO_OLD),
|
||||
("20260828_0022", Compatibility.TOO_OLD),
|
||||
("20260827_0021", Compatibility.TOO_OLD),
|
||||
@@ -182,9 +227,6 @@ def test_the_declared_protocol_matches_the_wire_constant() -> None:
|
||||
assert AGENT_PROTOCOL_VERSION == CURRENT_AGENT_PROTOCOL_VERSION
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- build identity
|
||||
|
||||
|
||||
def test_build_identity_reports_absent_values_as_null_rather_than_guessing() -> None:
|
||||
identity = build_identity()
|
||||
assert identity.version == PRODUCT_VERSION
|
||||
@@ -197,8 +239,6 @@ def test_build_identity_reports_absent_values_as_null_rather_than_guessing() ->
|
||||
|
||||
@pytest.mark.parametrize("placeholder", ["", " ", "unknown", "UNKNOWN", "none", "null"])
|
||||
def test_an_unsubstituted_build_argument_is_not_reported_as_a_fact(placeholder: str) -> None:
|
||||
"""A Dockerfile ARG that was never passed must not become a claimed commit."""
|
||||
|
||||
identity = build_identity(source_commit=placeholder, image_digest=placeholder)
|
||||
assert identity.source_commit is None
|
||||
assert identity.image_digest is None
|
||||
@@ -211,9 +251,6 @@ def test_build_identity_carries_a_real_commit_when_given_one() -> None:
|
||||
assert "source_commit" in identity.as_dict()
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- configuration
|
||||
|
||||
|
||||
def _production(**overrides: object) -> Settings:
|
||||
base: dict[str, object] = {
|
||||
"env": "production",
|
||||
@@ -342,8 +379,6 @@ def test_production_refuses_to_start_while_development_defaults_survive(tmp_path
|
||||
|
||||
|
||||
def test_development_reports_the_same_problems_without_refusing_to_start(tmp_path: Path) -> None:
|
||||
"""A developer with no backup key should still be able to run the API — and be told."""
|
||||
|
||||
settings = Settings(
|
||||
env="development",
|
||||
operator_api_key=None,
|
||||
@@ -352,7 +387,7 @@ def test_development_reports_the_same_problems_without_refusing_to_start(tmp_pat
|
||||
backup_root=tmp_path,
|
||||
)
|
||||
report = enforce_startup(settings)
|
||||
assert report.ok or report.problems is not None # never raises outside production
|
||||
assert report.ok or report.problems is not None
|
||||
|
||||
|
||||
def test_the_minimum_postgres_major_is_stated() -> None:
|
||||
@@ -360,12 +395,6 @@ def test_the_minimum_postgres_major_is_stated() -> None:
|
||||
|
||||
|
||||
def test_the_node_agent_pins_the_control_plane_at_the_product_version() -> None:
|
||||
"""They ship as one product, so a stale pin makes the agent image unbuildable at release time.
|
||||
|
||||
Found exactly that way: bumping the product version to 1.0.0 left this at 0.1.0 and the Node
|
||||
Agent image failed to resolve its dependencies during the fresh-install rehearsal.
|
||||
"""
|
||||
|
||||
data = tomllib.loads((ROOT / "node-agent" / "pyproject.toml").read_text("utf-8"))
|
||||
pins = [
|
||||
dependency
|
||||
|
||||
Reference in new issue
Block a user