From 87eb58f56b697cc46a14c02f8f7ea0f9a36885a5 Mon Sep 17 00:00:00 2001 From: Seongho Bae Date: Wed, 12 Aug 2026 08:22:35 +0900 Subject: [PATCH 1/7] test(security): reproduce connection-count subclass retention --- .../test_connection_pool_count_value_types.py | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 tests/test_connection_pool_count_value_types.py diff --git a/tests/test_connection_pool_count_value_types.py b/tests/test_connection_pool_count_value_types.py new file mode 100644 index 00000000..e1a5a456 --- /dev/null +++ b/tests/test_connection_pool_count_value_types.py @@ -0,0 +1,41 @@ +"""Security contracts for exact connection-pool count value types.""" + +from __future__ import annotations + +import pytest + +from egressweave import EgressConnectionPoolPolicy + + +class _ConnectionCountSubclass(int): + """Represent an unreviewed integer subclass crossing trusted configuration.""" + + +@pytest.mark.parametrize( + "field_name", + ["max_connections", "max_keepalive_connections"], +) +def test_connection_pool_policy_rejects_integer_subclasses(field_name: str) -> None: + """Reject non-exact integers before retaining finite pool-capacity values.""" + with pytest.raises(TypeError, match=field_name): + EgressConnectionPoolPolicy( + **{field_name: _ConnectionCountSubclass(1)} # type: ignore[arg-type] + ) + + +def test_connection_pool_policy_keeps_reviewed_count_input_forms() -> None: + """Continue accepting exact integers and reviewed ASCII decimal strings.""" + exact_integer = EgressConnectionPoolPolicy( + max_connections=8, + max_keepalive_connections=2, + ) + decimal_string = EgressConnectionPoolPolicy( + max_connections="8", + max_keepalive_connections="2", + ) + + assert type(exact_integer.max_connections) is int + assert type(exact_integer.max_keepalive_connections) is int + assert decimal_string == exact_integer + assert type(decimal_string.max_connections) is int + assert type(decimal_string.max_keepalive_connections) is int From 4003f81f0f92474ef5900c2c24ce06d101b6a0ab Mon Sep 17 00:00:00 2001 From: Seongho Bae Date: Wed, 12 Aug 2026 08:24:19 +0900 Subject: [PATCH 2/7] fix(security): require exact connection-count integers --- src/egressweave/connection_pool_policy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/egressweave/connection_pool_policy.py b/src/egressweave/connection_pool_policy.py index f372dc79..fc1ba0d7 100644 --- a/src/egressweave/connection_pool_policy.py +++ b/src/egressweave/connection_pool_policy.py @@ -22,7 +22,7 @@ def _normalize_connection_count( """Return one exact ASCII-compatible connection-count limit.""" if isinstance(value, bool): raise TypeError(f"{field_name} must be an integer or ASCII decimal string") - if isinstance(value, int): + if type(value) is int: normalized = value elif isinstance(value, str): if not value or not value.isascii() or not value.isdecimal(): @@ -96,7 +96,7 @@ def __post_init__(self) -> None: object.__setattr__( self, "keepalive_expiry_seconds", - keepalive_expiry_seconds, + max_keepalive_connections, ) def as_dict(self) -> dict[str, int | float]: From 4dc6c927137f65ff827317503be475685b57a637 Mon Sep 17 00:00:00 2001 From: Seongho Bae Date: Wed, 12 Aug 2026 08:24:51 +0900 Subject: [PATCH 3/7] fix: preserve keepalive expiry normalization --- src/egressweave/connection_pool_policy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/egressweave/connection_pool_policy.py b/src/egressweave/connection_pool_policy.py index fc1ba0d7..93574602 100644 --- a/src/egressweave/connection_pool_policy.py +++ b/src/egressweave/connection_pool_policy.py @@ -96,7 +96,7 @@ def __post_init__(self) -> None: object.__setattr__( self, "keepalive_expiry_seconds", - max_keepalive_connections, + keepalive_expiry_seconds, ) def as_dict(self) -> dict[str, int | float]: From de10498b5229a7af5293fe34ec779cd39f6ef7e9 Mon Sep 17 00:00:00 2001 From: Seongho Bae Date: Wed, 12 Aug 2026 08:26:36 +0900 Subject: [PATCH 4/7] test(docs): require connection-count integrity guidance --- ...nnection_pool_count_value_documentation.py | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tests/test_connection_pool_count_value_documentation.py diff --git a/tests/test_connection_pool_count_value_documentation.py b/tests/test_connection_pool_count_value_documentation.py new file mode 100644 index 00000000..fa38af49 --- /dev/null +++ b/tests/test_connection_pool_count_value_documentation.py @@ -0,0 +1,27 @@ +"""Documentation contracts for exact connection-pool count value types.""" + +from __future__ import annotations + +from pathlib import Path + +REPOSITORY_ROOT = Path(__file__).resolve().parents[1] +POOL_GUIDE_PATH = ( + REPOSITORY_ROOT / "docs" / "research" / "connection-pool-resource-limits.md" +) +CHANGELOG_PATH = REPOSITORY_ROOT / "CHANGELOG.md" + + +def test_connection_pool_guide_documents_exact_builtin_count_values() -> None: + """Keep operator guidance aligned with the primitive-value integrity boundary.""" + guide = POOL_GUIDE_PATH.read_text(encoding="utf-8") + + assert "Count fields accept only exact built-in integers" in guide + assert "integer subclasses are rejected" in guide + assert "does not make EgressWeave a Python sandbox" in guide + + +def test_changelog_records_connection_count_value_sealing() -> None: + """Record the pre-1.0 primitive-value tightening in release history.""" + changelog = CHANGELOG_PATH.read_text(encoding="utf-8") + + assert "Reject non-exact integer subclasses in connection-pool count fields" in changelog From aa6b79261b511915325c813d0ac8e1c581760e2b Mon Sep 17 00:00:00 2001 From: Seongho Bae Date: Wed, 12 Aug 2026 08:52:55 +0900 Subject: [PATCH 5/7] docs: document exact connection-count values --- docs/research/connection-pool-resource-limits.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/research/connection-pool-resource-limits.md b/docs/research/connection-pool-resource-limits.md index 88471aa5..38f22894 100644 --- a/docs/research/connection-pool-resource-limits.md +++ b/docs/research/connection-pool-resource-limits.md @@ -18,6 +18,13 @@ an exact `EgressConnectionPoolPolicy` with different documented field values instead. This boundary does not claim EgressWeave sandboxes arbitrary Python code already executing inside the embedding process. +Count fields accept only exact built-in integers when callers use the integer +form; the reviewed ASCII decimal-string form remains supported and normalizes to +exact integers, while integer subclasses are rejected before finite pool-capacity +values are retained. This supported configuration-integrity boundary does not +make EgressWeave a Python sandbox for arbitrary code already running in the host +process. + `max_connections` must be a positive integer or ASCII decimal string. `max_keepalive_connections` may be zero to retain no idle connections but must not exceed total capacity. `keepalive_expiry_seconds` must be a finite From 28aa3c857d7ae1b4c940ca40584fa49fa5ecd6ea Mon Sep 17 00:00:00 2001 From: Seongho Bae Date: Wed, 12 Aug 2026 08:54:49 +0900 Subject: [PATCH 6/7] docs: record exact connection-count sealing --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6350558..6dedeb6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -71,6 +71,11 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). disable the recurring loop. ### Security +- Reject non-exact integer subclasses in connection-pool count fields before + finite capacity is retained. Exact built-in integers and reviewed ASCII + decimal strings remain supported and normalize to built-in integers; callers + using custom integer subclasses must convert them deliberately before trusted + policy construction. - Require the request timeout policy to use the exact `EgressTimeoutPolicy` type during trusted construction. Timeout-policy subclasses are rejected before transport dispatch can dynamically invoke an overridden `as_httpcore_timeout()`, From 826db8d549ee34d04c387bf538fb0ebfbbe7cfb3 Mon Sep 17 00:00:00 2001 From: Seongho Bae Date: Wed, 12 Aug 2026 08:57:54 +0900 Subject: [PATCH 7/7] docs: preserve exact sandbox contract phrase --- docs/research/connection-pool-resource-limits.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/research/connection-pool-resource-limits.md b/docs/research/connection-pool-resource-limits.md index 38f22894..0a825f0b 100644 --- a/docs/research/connection-pool-resource-limits.md +++ b/docs/research/connection-pool-resource-limits.md @@ -21,9 +21,9 @@ code already executing inside the embedding process. Count fields accept only exact built-in integers when callers use the integer form; the reviewed ASCII decimal-string form remains supported and normalizes to exact integers, while integer subclasses are rejected before finite pool-capacity -values are retained. This supported configuration-integrity boundary does not -make EgressWeave a Python sandbox for arbitrary code already running in the host -process. +values are retained. This supported configuration-integrity boundary +does not make EgressWeave a Python sandbox for arbitrary code already running in +the host process. `max_connections` must be a positive integer or ASCII decimal string. `max_keepalive_connections` may be zero to retain no idle connections but must