refactor(gateway): move the data-plane daemons into a bot_bottle.gateway package
test / integration-docker (pull_request) Successful in 11s
test / unit (pull_request) Successful in 43s
lint / lint (push) Successful in 56s
test / integration-firecracker (pull_request) Successful in 3m19s
test / coverage (pull_request) Successful in 19s
test / publish-infra (pull_request) Has been skipped
tracker-policy-pr / check-pr (pull_request) Successful in 7s
test / integration-docker (pull_request) Successful in 11s
test / unit (pull_request) Successful in 43s
lint / lint (push) Successful in 56s
test / integration-firecracker (pull_request) Successful in 3m19s
test / coverage (pull_request) Successful in 19s
test / publish-infra (pull_request) Has been skipped
tracker-policy-pr / check-pr (pull_request) Successful in 7s
Separate the gateway (data plane) from the orchestrator (control plane) at the
module level. The gateway runtime files move out of the package root — and the
backend-neutral Gateway lifecycle ABC + GATEWAY_* constants move out of
orchestrator/ — into a new bot_bottle/gateway/ package:
gateway/__init__.py (was orchestrator/gateway.py: Gateway ABC + consts
+ rotate_gateway_ca)
gateway/gateway_init.py (the PID-1 daemon supervisor)
gateway/egress_addon.py, egress_addon_core.py, egress_dlp_config.py,
dlp_detectors.py (the egress mitmproxy daemon)
gateway/git_http_backend.py (the git-http daemon)
gateway/git_gate_render.py (the git-gate pre-receive rendering)
gateway/supervise_server.py (the supervise MCP daemon)
gateway/policy_resolver.py (the data-plane control-plane RPC client)
orchestrator/ now holds only control-plane files. The shared plan/types/auth
layer (egress.py=EgressPlan, git_gate.py=GitGatePlan, supervise.py,
supervise_types.py, control_auth.py) and the launch-time git-gate provisioning
helpers stay at root, so orchestrator/ and backend/ still own them.
Because these daemons are invoked as `python3 -m bot_bottle.<name>`, loaded flat
by mitmproxy, and referenced in Dockerfile.gateway, the move updates more than
Python imports: the `-m` invocations (firecracker/macOS infra scripts), the
Dockerfile.gateway addon shim + ENTRYPOINT, gateway_init's _DAEMONS module
paths, and the git-gate CGI heredocs all now point at bot_bottle.gateway.*.
No behavior change; full unit suite green (2251).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+11
-11
@@ -344,7 +344,7 @@ class TestRenderRoutes(unittest.TestCase):
|
||||
self.assertEqual([], parse_yaml_subset(rendered)["routes"])
|
||||
|
||||
def test_round_trip_through_addon_core(self):
|
||||
from bot_bottle.egress_addon_core import load_config
|
||||
from bot_bottle.gateway.egress_addon_core import load_config
|
||||
b = _bottle([
|
||||
{"host": "api.github.com",
|
||||
"auth": {"scheme": "Bearer", "token_ref": "GH_PAT"},
|
||||
@@ -363,7 +363,7 @@ class TestRenderRoutes(unittest.TestCase):
|
||||
self.assertEqual("", addon_routes[2].auth_scheme)
|
||||
|
||||
def test_dlp_round_trips(self):
|
||||
from bot_bottle.egress_addon_core import load_config
|
||||
from bot_bottle.gateway.egress_addon_core import load_config
|
||||
b = _bottle([{"host": "x.example", "dlp": {
|
||||
"outbound_detectors": ["token_patterns"],
|
||||
"inbound_detectors": False,
|
||||
@@ -375,7 +375,7 @@ class TestRenderRoutes(unittest.TestCase):
|
||||
self.assertEqual((), addon_routes[0].inbound_detectors)
|
||||
|
||||
def test_outbound_on_match_round_trips(self):
|
||||
from bot_bottle.egress_addon_core import load_config
|
||||
from bot_bottle.gateway.egress_addon_core import load_config
|
||||
b = _bottle([{"host": "logs.example", "dlp": {
|
||||
"outbound_on_match": "redact",
|
||||
}}])
|
||||
@@ -392,7 +392,7 @@ class TestRenderRoutes(unittest.TestCase):
|
||||
self.assertNotIn("outbound_on_match", rendered)
|
||||
|
||||
def test_git_fetch_policy_round_trips(self):
|
||||
from bot_bottle.egress_addon_core import load_config
|
||||
from bot_bottle.gateway.egress_addon_core import load_config
|
||||
b = _bottle([{"host": "github.com", "git": {"fetch": True}}])
|
||||
routes = egress_routes_for_bottle(b)
|
||||
rendered = egress_render_routes(routes)
|
||||
@@ -405,7 +405,7 @@ class TestRenderRoutes(unittest.TestCase):
|
||||
it, but the renderer in between dropped it — so the flag never reached
|
||||
the proxy and registry pulls kept failing with "unauthorized" while
|
||||
the config looked correct everywhere it was inspected."""
|
||||
from bot_bottle.egress_addon_core import load_config
|
||||
from bot_bottle.gateway.egress_addon_core import load_config
|
||||
b = _bottle([{"host": "registry-1.docker.io", "preserve_auth": True}])
|
||||
routes = egress_routes_for_bottle(b)
|
||||
rendered = egress_render_routes(routes)
|
||||
@@ -416,7 +416,7 @@ class TestRenderRoutes(unittest.TestCase):
|
||||
b = _bottle([{"host": "x.example"}])
|
||||
rendered = egress_render_routes(egress_routes_for_bottle(b))
|
||||
self.assertNotIn("preserve_auth", rendered)
|
||||
from bot_bottle.egress_addon_core import load_config
|
||||
from bot_bottle.gateway.egress_addon_core import load_config
|
||||
self.assertFalse(load_config(rendered).routes[0].preserve_auth)
|
||||
|
||||
def test_log_zero_omitted_from_render(self):
|
||||
@@ -434,7 +434,7 @@ class TestRenderRoutes(unittest.TestCase):
|
||||
self.assertTrue(rendered.startswith(f"log: {level}\n"))
|
||||
|
||||
def test_log_level_round_trips_to_addon_core(self):
|
||||
from bot_bottle.egress_addon_core import load_config, LOG_FULL
|
||||
from bot_bottle.gateway.egress_addon_core import load_config, LOG_FULL
|
||||
b = _bottle([{"host": "x.example"}])
|
||||
routes = egress_routes_for_bottle(b)
|
||||
rendered = egress_render_routes(routes, log=LOG_FULL)
|
||||
@@ -444,7 +444,7 @@ class TestRenderRoutes(unittest.TestCase):
|
||||
|
||||
def test_log_via_manifest_flows_to_render(self):
|
||||
from bot_bottle.manifest import ManifestIndex
|
||||
from bot_bottle.egress_addon_core import load_config, LOG_BLOCKS
|
||||
from bot_bottle.gateway.egress_addon_core import load_config, LOG_BLOCKS
|
||||
m = ManifestIndex.from_json_obj({
|
||||
"bottles": {"dev": {"egress": {
|
||||
"log": 1,
|
||||
@@ -512,7 +512,7 @@ class TestRenderRoutesEscaping(unittest.TestCase):
|
||||
self.assertEqual('Bear"er', parsed[0]["inspect"]["auth_scheme"])
|
||||
|
||||
def test_path_value_with_double_quote_round_trips(self):
|
||||
from bot_bottle.egress_addon_core import PathMatch, MatchEntry
|
||||
from bot_bottle.gateway.egress_addon_core import PathMatch, MatchEntry
|
||||
routes = (EgressRoute(
|
||||
host="api.example",
|
||||
matches=(MatchEntry(paths=(PathMatch(type="prefix", value='/v1/"quoted"/'),)),),
|
||||
@@ -521,7 +521,7 @@ class TestRenderRoutesEscaping(unittest.TestCase):
|
||||
self.assertEqual('/v1/"quoted"/', parsed[0]["inspect"]["matches"][0]["paths"][0]["value"])
|
||||
|
||||
def test_header_value_with_double_quote_round_trips(self):
|
||||
from bot_bottle.egress_addon_core import HeaderMatch, MatchEntry
|
||||
from bot_bottle.gateway.egress_addon_core import HeaderMatch, MatchEntry
|
||||
routes = (EgressRoute(
|
||||
host="api.example",
|
||||
matches=(MatchEntry(headers=(HeaderMatch(name="x-h", value='val"ue'),)),),
|
||||
@@ -598,7 +598,7 @@ class TestCanaryGeneration(unittest.TestCase):
|
||||
self.assertNotEqual(plan_a.canary, plan_b.canary)
|
||||
|
||||
def test_canary_detected_by_scan_known_secrets(self):
|
||||
from bot_bottle.dlp_detectors import scan_known_secrets
|
||||
from bot_bottle.gateway.dlp_detectors import scan_known_secrets
|
||||
|
||||
plan = self._make_plan()
|
||||
env = {plan.canary_env: plan.canary}
|
||||
|
||||
Reference in New Issue
Block a user