refactor(gateway): split data-plane files into egress/supervisor/git_gate services
tracker-policy-pr / check-pr (pull_request) Successful in 11s
test / integration-docker (pull_request) Successful in 17s
test / unit (pull_request) Successful in 49s
lint / lint (push) Failing after 2m49s
test / integration-firecracker (pull_request) Successful in 3m35s
test / coverage (pull_request) Successful in 18s
test / publish-infra (pull_request) Has been skipped

Group the gateway's data-plane modules into three service sub-packages
mirroring the host-side trio (bot_bottle.egress / .supervisor / .git_gate):

  gateway/egress/     addon_core, addon, dlp_config, dlp_detectors
  gateway/supervisor/ server            (was supervise_server)
  gateway/git_gate/   render, http_backend

Prefix-stripped filenames now that the package namespaces them; each
sub-package has a thin docstring __init__ (no eager imports, cheap leaf
loads). The two cross-cutting files stay at the gateway root:
policy_resolver (shared per-client lookup) and gateway_init, renamed to
bootstrap now that gateway/ already namespaces it.

Updated all importers (bot_bottle + tests), the in-VM/container `-m`
launch strings, the Dockerfile.gateway addon shim + ENTRYPOINT, and the
five gateway entries in scripts/critical-modules.txt. Full unit suite
green (2243).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-24 17:00:51 -04:00
parent a446551acb
commit ce744a85c4
40 changed files with 113 additions and 90 deletions
+8 -8
View File
@@ -10,7 +10,7 @@ from pathlib import Path
from unittest import mock
from bot_bottle.git_gate import GIT_GATE_TIMEOUT_SECS
from bot_bottle.gateway.git_http_backend import GitHttpHandler, MAX_BODY_BYTES
from bot_bottle.gateway.git_gate.http_backend import GitHttpHandler, MAX_BODY_BYTES
# The git-http backend is resolver-only: every request is attributed to a
@@ -199,7 +199,7 @@ class TestGitHttpBackend(unittest.TestCase):
subprocess.CompletedProcess(["git"], 0, backend_response, b""),
]
with mock.patch(
"bot_bottle.gateway.git_http_backend.subprocess.run",
"bot_bottle.gateway.git_gate.http_backend.subprocess.run",
side_effect=calls,
) as run:
request = urllib.request.Request(
@@ -265,7 +265,7 @@ class TestGitHttpBackend(unittest.TestCase):
subprocess.CompletedProcess(["git"], 0, backend_response, b""),
]
with mock.patch(
"bot_bottle.gateway.git_http_backend.subprocess.run",
"bot_bottle.gateway.git_gate.http_backend.subprocess.run",
side_effect=calls,
) as run:
req = urllib.request.Request(
@@ -309,7 +309,7 @@ class TestGitHttpBackend(unittest.TestCase):
denial = b"git-gate: upstream fetch failed; refusing to serve stale data\n"
with mock.patch(
"bot_bottle.gateway.git_http_backend.subprocess.run",
"bot_bottle.gateway.git_gate.http_backend.subprocess.run",
return_value=subprocess.CompletedProcess(
["hook"], 1, b"", denial,
),
@@ -355,7 +355,7 @@ class TestGitHttpBackend(unittest.TestCase):
self.addCleanup(server.server_close)
with mock.patch(
"bot_bottle.gateway.git_http_backend.subprocess.run",
"bot_bottle.gateway.git_gate.http_backend.subprocess.run",
return_value=subprocess.CompletedProcess(
["hook"], 2, b"", b"",
),
@@ -402,7 +402,7 @@ class TestGitHttpBackend(unittest.TestCase):
self.addCleanup(server.server_close)
with mock.patch(
"bot_bottle.gateway.git_http_backend.subprocess.run",
"bot_bottle.gateway.git_gate.http_backend.subprocess.run",
side_effect=PermissionError(13, "Permission denied"),
):
buf = io.StringIO()
@@ -461,7 +461,7 @@ class TestMalformedStatusHeader(unittest.TestCase):
def _get_with_backend_response(self, cgi_response: bytes) -> int:
with mock.patch(
"bot_bottle.gateway.git_http_backend.subprocess.run",
"bot_bottle.gateway.git_gate.http_backend.subprocess.run",
return_value=mock.Mock(returncode=0, stdout=cgi_response),
):
req = urllib.request.Request(
@@ -545,7 +545,7 @@ class TestContentLengthBounds(unittest.TestCase):
# With a valid Content-Length the handler proceeds into
# git http-backend; that will fail (no real git repo) but the
# status won't be 400 or 413.
with mock.patch("bot_bottle.gateway.git_http_backend.subprocess.run") as run:
with mock.patch("bot_bottle.gateway.git_gate.http_backend.subprocess.run") as run:
run.return_value = mock.Mock(
returncode=0,
stdout=(