Skip to content

Commit 2816520

Browse files
vvillait88claude
andauthored
test: lock public-surface barrel exports (#30)
## Summary Locks every public helper's documented import path so a future barrel-export gap fails CI. The trigger was a Node-side gap on `loadUCPSigningKeyFromEnv` during the recent helper lift: the function was defined in `src/identity/ucp-jwks.ts` but never re-exported from `src/index.ts`. The helper's own test imported from the module path so the gap stayed invisible until a consumer tried importing from the documented top-level barrel. Python's barrel was correct the first time around, but the same gap could hit any future helper. These tests give us a single-failure signal in CI whenever a helper lands in a submodule and is forgotten in the `__init__.py` re-export. ## What's covered - `agentscore_commerce.identity` → `hash_operator_token`, `load_ucp_signing_key_from_env`, `LoadUCPSigningKeyOptions` - `agentscore_commerce.payment` → `detect_rail_from_headers`, `zero_amount_carve_out`, `usd_to_atomic`, `classify_orchestration_error`, `classify_x402_settle_result`, `extract_payment_signer`, `read_x402_payment_header` Each test asserts the barrel-imported symbol is the same object as the module-level one (`barrel.foo is module.foo`), so a future barrel rewrite that re-binds rather than re-exports also fails. ## Test plan - [x] `uv run pytest tests/test_public_surface.py` — 5 passed - [x] Full suite still green - [x] `uv run ruff check` + `uv run ty check` clean Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 7a9b43c commit 2816520

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

tests/test_public_surface.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
"""Public-API surface tests.
2+
3+
Locks the documented public surface so a future helper that lands in a module
4+
but is forgotten in the submodule barrel re-export
5+
(``agentscore_commerce.<submodule>.__init__``) fails CI. Mirrors the node-commerce
6+
sibling at ``node-commerce/tests/public-surface.test.ts``.
7+
8+
The trigger was a Node-side gap on ``loadUCPSigningKeyFromEnv`` during the TEC-302
9+
lift-up: the helper was defined in ``src/identity/ucp-jwks.ts`` but never
10+
re-exported from ``src/index.ts``. Python had the helper barrel-exported correctly
11+
the first time, but the same gap could hit any future helper; assert every
12+
TEC-302 lift-up entry is importable from its documented path.
13+
"""
14+
15+
from __future__ import annotations
16+
17+
18+
def test_identity_barrel_exports_hash_operator_token() -> None:
19+
"""``hash_operator_token`` is importable from ``agentscore_commerce.identity``."""
20+
from agentscore_commerce import identity as barrel
21+
from agentscore_commerce.identity import tokens as module
22+
23+
assert barrel.hash_operator_token is module.hash_operator_token
24+
25+
26+
def test_identity_barrel_exports_ucp_env_loader() -> None:
27+
"""``load_ucp_signing_key_from_env`` + ``LoadUCPSigningKeyOptions`` reachable from the identity barrel."""
28+
from agentscore_commerce import identity as barrel
29+
from agentscore_commerce.identity import ucp_jwks as module
30+
31+
assert barrel.load_ucp_signing_key_from_env is module.load_ucp_signing_key_from_env
32+
assert barrel.LoadUCPSigningKeyOptions is module.LoadUCPSigningKeyOptions
33+
34+
35+
def test_payment_barrel_exports_detect_rail_zero_settle_usd_to_atomic() -> None:
36+
from agentscore_commerce.payment import (
37+
detect_rail_from_headers,
38+
usd_to_atomic,
39+
zero_amount_carve_out,
40+
)
41+
42+
assert callable(detect_rail_from_headers)
43+
assert callable(zero_amount_carve_out)
44+
assert callable(usd_to_atomic)
45+
46+
47+
def test_payment_barrel_exports_classify_helpers() -> None:
48+
from agentscore_commerce.payment import classify_orchestration_error, classify_x402_settle_result
49+
50+
assert callable(classify_orchestration_error)
51+
assert callable(classify_x402_settle_result)
52+
53+
54+
def test_payment_barrel_exports_signer_helpers() -> None:
55+
from agentscore_commerce.payment import extract_payment_signer, read_x402_payment_header
56+
57+
assert callable(extract_payment_signer)
58+
assert callable(read_x402_payment_header)

0 commit comments

Comments
 (0)