Repository navigation
fix(tests): close live tunnel and refuse GATEWAY_URL in hermetic runs - #766
Merged
Merged
Conversation
lahlfors
force-pushed
the
fix/residency-lock
branch
from
November 15, 2026 18:39
67dfb9d to
ad29f85
Compare
scripts/staging_lifecycle.sh opened the staging kubectl port-forward tunnel during Phase 3 pre-Lula custody seeding (and again before Phase 4) without closing it before Phase 4's us_fed, eu_ecb, and apac_mas hermetic regional posture suites, while tests/conftest.py defaulted GATEWAY_URL to http://localhost:8080 in every session. Any hermetic or region-marked test reading GATEWAY_URL could therefore hit live staging and record synthetic traffic in the deployed evidence chain and Lula counts. - Stop Phase 3's port-forward when Lula validation finishes, run ensure_no_staging_port_forward and pass env -u GATEWAY_URL before Phase 4's three hermetic regional suites, and start the port-forward only afterward (before live data-residency, live Langfuse isolation, and Phase 5 live sweeps). - Add tests/fixtures/gateway_url_guard.py and wire it into tests/conftest.py so hermetic sessions stop defaulting GATEWAY_URL, refuse to start when GATEWAY_URL is exported, and assert "GATEWAY_URL" not in os.environ before and after every hermetic test; live sessions (--run-integration, --run-live-external, --run-partner-integration, --run-e2e) keep the localhost:8080 default. - Add unit and subprocess contract tests in tests/unit/test_gateway_url_guard.py and port-forward / GATEWAY_URL isolation tests in tests/infrastructure/test_staging_lifecycle.py.
lahlfors
force-pushed
the
fix/gate-w-tunnel-ordering
branch
from
November 15, 2026 18:53
cdb9c77 to
63af3d0
Compare
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.
Summary
Stacked on #765 (
fix/residency-lock-> #764fix/region-resolver-> #762 -> #761 -> #760 -> #759).scripts/staging_lifecycle.shpreviously opened the stagingkubectl port-forwardtunnel during Phase 3 pre-Lula custody seeding (and again ahead of Phase 4) without closing it before Phase 4'sus_fed,eu_ecb, andapac_mashermetic posture suites, whiletests/conftest.pydefaultedGATEWAY_URLtohttp://localhost:8080in every test session. The hermetic regional suites were therefore hermetic only because no selected test happened to readGATEWAY_URL; any hermetic test that did would hit live staging onlocalhost:8080and land unmarked synthetic traffic in the deployed evidence chain and Lula counts.Changes
scripts/staging_lifecycle.sh):ensure_no_staging_port_forward(tearing down even a pre-existing external tunnel under--skip-lula) and passenv -u GATEWAY_URLinrun_hermetic_region_pytestbefore executing theus_fed,eu_ecb, andapac_mashermetic posture suites.start_staging_port_forwardonly after the three hermetic regional suites complete—immediately before live data-residency (test_data_residency.py --run-integration), live Langfuse posture isolation (verify_langfuse_posture.py --posture staging), and Phase 5 live sweeps (also starting at Phase 5 entry when--skip-postureis passed).GATEWAY_URLguard (tests/fixtures/gateway_url_guard.py,tests/conftest.py):GATEWAY_URL="http://localhost:8080"atconftest.pyimport time and in hermeticpytest_configuresessions; populate thehttp://localhost:8080default only when a live-run flag (--run-integration,--run-live-external,--run-partner-integration,--run-e2e) is active.pytest.ExitCode.USAGE_ERROR) whenGATEWAY_URLis exported in the environment."GATEWAY_URL" not in os.environbefore and after every hermetic test via theassert_hermetic_gateway_url_unsetautouse fixture, failing closed and cleaning up if a test mutatesos.environ["GATEWAY_URL"]withoutmonkeypatch.setenv.tests/unit/test_gateway_url_guard.py.GATEWAY_URLordering/isolation tests across default,--skip-lula, and--skip-posturepaths intests/infrastructure/test_staging_lifecycle.py.tests/README.md,docs/EVALUATOR_GUIDE.md,docs/operations/GKE_TEST_RUNBOOK.md, andCHANGELOG.md.Verification
uv run pytest tests/unit/test_gateway_url_guard.py tests/test_dotenv_guard.py tests/test_deployment_region.py tests/infrastructure/test_staging_lifecycle.py -n 0 -q:113 passeduv run pytest tests/ -m "us_fed or eu_ecb or apac_mas" -n auto --dist loadscope --no-cov -q:76 passed, 32 skippedmake test-fast(uv run pytest tests/ -m "local or unit" -n auto --dist loadscope --no-cov -p no:langsmith -q):10,849 passed, 75 skipped, 6 subtests passeduv run bandit -r src/ scripts/ -c pyproject.toml -ll -ii:0 issues(135,986lines scanned:src/107,976lines,scripts/28,010lines)scripts/check_import_boundaries.py,scripts/check_domain_literals.py,scripts/check_vendor_brands.py,scripts/check_poam_lula_divergence.py,scripts/check_doc_references.py,scripts/check_project_id_hygiene.py): passed