Split git_gate.py into render / provision / control modules #309

Merged
didericis-claude merged 1 commits from decompose-git-gate into main 2026-06-26 21:19:51 -04:00
Collaborator

Closes #303.

Summary

git_gate.py (699 LOC) mixed three responsibilities. Split into focused modules, re-exporting from git_gate so all 19 importers are unchanged (same pattern as #291):

  • git_gate_render.py — pure host-side rendering: the GIT_GATE_* constants, GitGateUpstream, gitconfig / known-hosts rendering, and the entrypoint / pre-receive / access-hook script builders.
  • git_gate_provision.py — the gitea deploy-key lifecycle (_provision_dynamic_key / revoke_git_gate_provisioned_keys / _resolve_identity_file).
  • git_gate.py — the GitGate ABC + GitGatePlan, now 169 LOC, re-exporting all moved names via __all__.

Notes

  • Host-side only (not in Dockerfile.sidecars), so no flat-import shim needed.
  • One test patched the internal _provision_dynamic_key lookup (bot_bottle.git_gate.…); repointed to bot_bottle.git_gate_provision.… where _resolve_identity_file now resolves it. Public API unchanged.
  • Added git_gate_render.py + git_gate_provision.py to scripts/critical-modules.txt — the decompose moves security code (gitconfig-injection validation, deploy-key lifecycle) out of the measured git_gate.py, so the single-source-of-truth list must follow it or the core metric silently shrinks. Critical aggregate stays 95% (git_gate 100%, render 100%, provision 97%).

Full suite (1476) passes; pyright clean; pylint 9.87.

Closes #303. ## Summary `git_gate.py` (699 LOC) mixed three responsibilities. Split into focused modules, re-exporting from `git_gate` so all 19 importers are unchanged (same pattern as #291): - **`git_gate_render.py`** — pure host-side rendering: the `GIT_GATE_*` constants, `GitGateUpstream`, gitconfig / known-hosts rendering, and the entrypoint / pre-receive / access-hook script builders. - **`git_gate_provision.py`** — the gitea deploy-key lifecycle (`_provision_dynamic_key` / `revoke_git_gate_provisioned_keys` / `_resolve_identity_file`). - **`git_gate.py`** — the `GitGate` ABC + `GitGatePlan`, now **169 LOC**, re-exporting all moved names via `__all__`. ## Notes - **Host-side only** (not in `Dockerfile.sidecars`), so no flat-import shim needed. - One test patched the *internal* `_provision_dynamic_key` lookup (`bot_bottle.git_gate.…`); repointed to `bot_bottle.git_gate_provision.…` where `_resolve_identity_file` now resolves it. Public API unchanged. - **Added `git_gate_render.py` + `git_gate_provision.py` to `scripts/critical-modules.txt`** — the decompose moves security code (gitconfig-injection validation, deploy-key lifecycle) out of the measured `git_gate.py`, so the single-source-of-truth list must follow it or the core metric silently shrinks. Critical aggregate stays **95%** (git_gate 100%, render 100%, provision 97%). Full suite (1476) passes; pyright clean; pylint 9.87.
didericis-claude added 1 commit 2026-06-26 20:50:12 -04:00
refactor(git-gate): split git_gate.py into render / provision / control
lint / lint (push) Successful in 2m22s
test / unit (pull_request) Successful in 58s
test / integration (pull_request) Successful in 22s
test / coverage (pull_request) Successful in 1m11s
06ba9b2a40
git_gate.py (699 LOC) mixed three responsibilities. Split into:

- git_gate_render.py — pure host-side rendering: the gate constants,
  GitGateUpstream, gitconfig/known-hosts rendering, and the entrypoint /
  pre-receive / access-hook script builders.
- git_gate_provision.py — the gitea deploy-key lifecycle
  (_provision_dynamic_key / revoke / _resolve_identity_file).
- git_gate.py — the GitGate ABC + GitGatePlan, now 169 LOC, re-exporting
  all moved names (see __all__) so the 19 importers are unchanged.

Host-side only (not flat-bundled), so no sidecar import shim. The one
test that patched the internal `_provision_dynamic_key` lookup is
repointed to its new module (public API unchanged). The two new modules
are added to scripts/critical-modules.txt so the decompose doesn't move
security code out of the measured core — critical aggregate stays 95%
(git_gate 100%, render 100%, provision 97%).

Closes #303

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NkwFXLFff9PYPy4wgVBJp9
didericis-claude merged commit 33fe8d2c7a into main 2026-06-26 21:19:51 -04:00
didericis-claude deleted branch decompose-git-gate 2026-06-26 21:19:55 -04:00
Sign in to join this conversation.