Repository navigation
Network git of the code index can go through an operator's forward proxy, with an identity per repository - #933
Merged
Merged
Conversation
A deployment that lets its pods reach git remotes only through a forward proxy had no way to tell Loom: every repository job builds its environment from scratch, so no proxy variable or git config reaches git. LOOM_CODE_GIT_PROXY_URL names the proxy, LOOM_CODE_GIT_PROXY_TOKEN_FILE a file with its password, LOOM_CODE_GIT_PROXY_CA_FILE the bundle git verifies TLS with through it, and LOOM_CODE_GIT_PROXY_IDENTITY the user of an entry that names none. An entry can present its own identity, so the proxy can decide per repository: git_proxy_identity is a field of an operator entry, a column of loom.code_repos (migration 111), and a field of code.repo.add and code.repo.remote_branches that only a platform admin may set. code.repo.add_branch inherits it under the same rule. The proxy and its credentials are added in the plain-process branch of run_job, for jobs the git helpers mark as git talking to a network remote: a mirror's clone, fetch and ls-remote, the add's ls-remote and a checkout's submodule update. The password is read from its file for each job and lives in that child's environment only, so no argv, stored git config, build harness or sandboxed job sees it, and run_job masks it in what git says. http.proxyAuthMethod=basic makes git send the credentials on its first CONNECT. While the proxy is set git never connects directly. A job is refused with a fixed reason when the password file gives no token, no identity is named, the remote is not https, or the host runs the sandbox, whose egress proxy is not chained through this one; /v1/health reports the last case as repo_git_proxy_sandboxed. Tier health reads a 403 or 407 from the proxy, and Loom's own refusal, as kind egress with a fix that names the proxy. Signed-off-by: pufit <[email protected]>
…ntact A clone and the ls-remote before an add show a fixed reason in place of git's words, so a proxy that refused them read "git clone failed (exit 128)" and "git ls-remote failed": kind unknown on the fetch tier, with the proxy's answer in the log only. That is where a wrong token audience or an identity the proxy does not know shows first. Both now say "the operator's git proxy (LOOM_CODE_GIT_PROXY_URL) refused the connection" with the status the proxy answered, which the fetch tier reads as kind egress with the fix a refused fetch gets. The guide says three things it left out: where the proxy is used repository jobs are plain processes, so a compiler tier's build can read the token file; sandbox.required: false alone does not keep the sandbox off; and an http:// proxy URL carries the identity and the token in clear. Two tests with the real git cover what the suite asserted only as a config key: git trusts the remote through the proxy by the CA bundle and by no other, and the clone a submodule update starts goes through the proxy, an ssh submodule being a refused transport. The test of a sandboxed harness proved nothing and is gone. Removed as not needed: the once-only log of a token-file failure, the size bound on the token file, the emptied NO_PROXY variables (auth_env copies none) and the test of the add's audit row. Signed-off-by: pufit <[email protected]>
Signed-off-by: pufit <[email protected]>
Signed-off-by: pufit <[email protected]>
main added 111_connected_accounts.sql while this branch was open, so two files held number 111. The file that adds loom.code_repos.git_proxy_identity moves to the next free number; its content is unchanged. Signed-off-by: pufit <[email protected]>
Signed-off-by: pufit <[email protected]>
Signed-off-by: pufit <[email protected]>
…rule main gained LOOM_CODE_SELF_SERVICE_PLATFORM_ADMIN_ONLY while this branch was open, with the rule this branch wrote for git_proxy_identity: the role counts on a flat token used by its own subject, and a call without a principal passes only where auth is off. Both gates now ask one function, _is_platform_admin. Each keeps its own refusal sentence, and the identity gate applies whether or not the setting is on. A test double main added takes the proxy_identity keyword the remote reads now pass, and the tests of the identity gate use the platform-admin principal the module already builds: the merge left two helpers of one name, the later of which replaced the earlier for every test. The guides say how the two changes meet. The proxy is used where repository jobs are plain processes, and there code.repo.add needs LOOM_CODE_SELF_SERVICE_GIT_UNSANDBOXED; its git then goes through the proxy under the entry's identity. Signed-off-by: pufit <[email protected]>
Signed-off-by: pufit <[email protected]>
Signed-off-by: pufit <[email protected]>
The section on self-registered repositories without the sandbox says that nothing vets where their git jobs connect. With LOOM_CODE_GIT_PROXY_URL those jobs connect to the operator's proxy alone, and an ssh remote is refused. The section now says so and points at the proxy's own section; the rules for loading LOOM_CODE_SELF_SERVICE_GIT_UNSANDBOXED are as they were. Signed-off-by: pufit <[email protected]>
Signed-off-by: pufit <[email protected]>
The analyzer corpus issues schemas/schema.sql as one statement, so the shape it lists for the dump changes whenever the dump does. Migration 112 added loom.code_repos.git_proxy_identity to the dump, and tests/analyzer/shapes.txt still listed the shape of the dump before it: the corpus test reported one shape new and one gone. The file is regenerated with python -m tests.analyzer.corpus --write. That one entry is its whole diff. Signed-off-by: pufit <[email protected]>
zlareb1
approved these changes
Nov 19, 2026
zlareb1
left a comment
Member
There was a problem hiding this comment.
No findings. Checked proxy authentication and credential redaction, TLS, submodule transports, admin authorization, repository identity propagation and schema compatibility. Exact-head tests: 761 passed, one Linux-only skip. Combined with the current base: 441 tests and nine generator checks pass. CI covers the live integration, mixed-version and Linux sandbox paths.
7 of 9 tasks
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.
Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
The code index's network git (clone, fetch,
ls-remote, submodule update) can go through an operator's forward proxy:LOOM_CODE_GIT_PROXY_URL, withLOOM_CODE_GIT_PROXY_TOKEN_FILE,LOOM_CODE_GIT_PROXY_CA_FILEandLOOM_CODE_GIT_PROXY_IDENTITY. A repository entry can present its owngit_proxy_identityto the proxy;code.repo.addandcode.repo.remote_branchestake the field from a platform admin only.Why
A deployment whose pods reach git hosts only through a forward proxy cannot run the code index today. Every repository job builds git's environment from scratch (
auth_env) and reads no system or global git config, so no proxy variable and nohttp.proxyreaches git, and nothing in Loom sets one.Such a proxy usually decides per caller what a request may reach and which credential it gets. One identity for the whole deployment is not enough for that, so an entry can name its own.
Design, with the alternatives and what each costs:
sandbox.run_job, for jobs the git helpers mark as git talking to a network remote (remote_access,compiler_tier.git(network=True)). The password is read from its file there, for that one job, into a copy of the environment.auth_envwas the other candidate: build harnesses copy its git settings (git_config_env), so repository build code would get the password. The caller'senvwas the third: it is handed to the sandbox as it is, where repository code runs.http.proxycarries the user and password, each percent-encoded whole, andhttp.proxyAuthMethod=basicmakes git send them on its firstCONNECT. Without the second setting git's HTTP library sends a bareCONNECTfirst and waits for a407, so every job would start with a request the proxy refuses. The cost is that only Basic is offered; git has no way to send another proxy header.https://. Git's proxy setting carries no ssh, so the job also getsprotocol.ssh.allow=never, and an ssh submodule fails as a refused transport instead of connecting directly. A deployment that set a proxy to control egress must not find Loom going around it./v1/healthandloom doctorreportrepo_git_proxy_sandboxed. The cost: a host uses the proxy or the sandbox, not both.code.repo.addis open to every member of an org unlessLOOM_CODE_SELF_SERVICE_PLATFORM_ADMIN_ONLYis set. So only a platform admin may name one incode.repo.addorcode.repo.remote_branches, or add a branch of an index that carries one, which inherits it, whatever that setting says. The rule is the one that setting applies: a flat platform-admin token used by its own subject, and a call without a principal only where auth is off. Both gates ask one function,_is_platform_admin, and each keeps its own refusal sentence. Any other caller getsAUTH_INSUFFICIENT.egresswith a fix that names the proxy and says what a407means. A clone and thels-remotebefore an add show a fixed reason in place of git's words (those can name host paths and the remote), so they name the proxy themselves:the operator's git proxy (LOOM_CODE_GIT_PROXY_URL) refused the connection (407), with the status the proxy answered. The fetch tier reads that sentence as the same kind with the same fix. Without it, an entry's first contact, where a wrong token or an unknown identity shows first, would readgit clone failed (exit 128).run_jobmasks the password in what git says (stderr, and stdout unless the caller parses it) as the file holds it, percent-encoded and in theProxy-Authorizationheader's base64 form, so the three callers that surface git output (GitError, the clone's log line, a compiler tier's error) need no change. Stdout that a caller parses (ls-remote) is the remote's refs and is left as it is: git writes none of its own words there, and masking a ref that happens to spell a weak password would corrupt the listing.go mod downloadrun repository code, so they get neither the proxy nor its password. Loom's HTTP clients do not read these settings either.Scope and risk
Touches the code index only:
server/code/app/index/(the newgit_proxy.py,sandbox.py,gitrepo.py,bootstrap.py,pass_fetch.py,mirrors.py,repo_registry.py,compiler_tier.py), the repository handlers and wire models, the entry configuration, tier health, one health problem, four settings and one registry column. 52 files, +2154 −113: about 630 lines of server code (a third of it the identity threaded through some 20 call sites), 1,270 of tests, 175 of hand-written documentation, the rest generated._require_platform_admin, the gate ofLOOM_CODE_SELF_SERVICE_PLATFORM_ADMIN_ONLY, now reads the predicate the identity gate reads. What it admits, what it refuses and its message are unchanged, and its tests pass as they were.With
LOOM_CODE_GIT_PROXY_URLunset nothing changes: no job gets a new setting in its environment, and the newnetwork_gitjob option is ignored.What could break:
code.repo.add_branchnow refuses a maintainer who is not a platform admin when the source index carries an identity.loom.code_repos. An access change and a removal copy the row whole, so they keep the value; a removed row reads it empty, like the token.LOOM_CODE_GIT_FETCH_TIMEOUT_S, an hour by default).http://proxy URL carries the identity and the token in clear on every job. The guide says so and asks for a trusted path or anhttps://URL.Left alone: Loom's HTTP clients (the GitHub API, issuer keys, document sources), the sandbox's egress proxy, and the Helm chart, which takes the settings through
envand the mounts throughextraVolumes.Compatibility, rollout and rollback
code.repo.addandcode.repo.remote_branchesgain the optional fieldgit_proxy_identity(letters, digits and. _ ~ @ -, at most 128; default''), refused withAUTH_INSUFFICIENTunless the caller is a platform admin.code.repo.add_branchrefuses withAUTH_INSUFFICIENTfor a caller who is not a platform admin when the source index carries an identity. A build before this one ignores the field and names it inignored_args, so a client sends it only once every pod runs this build. No default changes.LOOM_CODE_GIT_PROXY_URLand, as needed, the token file, the CA bundle and the default identity on every pod, web pods included, since each keeps its own mirrors. Keep the repository-job sandbox off on those pods. Therecode.repo.addworks only withLOOM_CODE_SELF_SERVICE_GIT_UNSANDBOXEDand the platform-admin rule it needs; an entry inLOOM_CODE_REPOS_JSONneeds neither. Migration112_code_repo_git_proxy_identity.sqlis additive; a pod of the previous build reads the table by column name and copies a row whole, so it keeps working during the roll.Tests
New unit tests (
tests/unit/test_code_git_proxy.py,test_code_git_proxy_wire.py,test_code_git_proxy_settings.py; 39, 9 and 21 cases) and additions to the existing files for the handlers, the configured entries, tier health and the sandbox:http.proxywith the identity and the encoded password,http.proxyAuthMethod=basic,http.sslCAInfoandprotocol.ssh.allow=never; its argv and the caller's mapping are unchanged. The entry's identity wins over the default. The file is read again for the next job. Git on a local mirror, a harness with network access and a local command get nothing.ssh://remote, a host with the sandbox) raises before any process starts, and each caller reports it in its own shape:GitError, the clone's reason, the add'sREMOTE_REFUSED, a tier'sToolOutputError.ls-remotethat the proxy refused name the proxy and its status, for both phrasings git's HTTP library has for a refusedCONNECT, with403and with407; the fetch tier gives the clone the kind and the fix it gives a refused fetch.gitbinary against a forward proxy the test starts on a loopback port:CONNECT <host>:443withProxy-Authorization: Basicthat decodes toidentity:password, the repository's own token is not in it, no argument of the git process holds the password, the error text does not either, and the mirror's stored config names no proxy (for a403and a407answer);ls-remotethat the proxy refuses come back with the named reason and the status;git submodule updateon a checkout whose.gitmodulesnames another host: the clone git starts goes to the proxy with the credentials, and an ssh submodule makes no request and fails as a refused transport;ls-remoteoutput is left alone.server/passes the entry's identity (an AST scan), each helper hands it torun_job, branches of one mirror share a fetch only under one identity, and a host round fetches as its first entry.code.repo.add,code.repo.remote_branchesandcode.repo.add_branch: a platform admin's identity is stored and every remote read is made under it; a member, an org admin, a scoped token and an admin acting for someone else are refused before any remote job or write.tests/integration/test_code_repo_row_kind.pygains a test that writes a row with the identity, reads it back through the registry, changes its access and removes it.What I ran locally (macOS, Python 3.12), on the branch merged with
main:make lintandmake typecheck: pass.ruff format --check .,prettier --check "**/*.{md,yml,yaml}"andbiome format .: clean.--check(sdk_py_gen,sdk_py_client_gen,sdk_py_admin_gen,sdk_ts_gen,agent_plugin_sync,settings_reference,settings_schema,settings_example,docs_reference,op_reach_census): current. Each generator and the settings-defaults snapshot update, run again after the last merge ofmain, change nothing.pytest tests/unit -n 8 -p randomlyandpytest bench: the unit run fails on this machine only in tests that need Linux resource limits or a newerclickhousebinary than it has (1235 test ids in 132 files), and exactly those ids fail onmainthere;benchpasses (251). The last commit adds one paragraph to a guide: after it the 188 unit test files that readdocs/were run again, with no other failure.tests/integration/test_code_repo_row_kind.pyagainst a private ClickHouse migrated from empty through migration 112: 5 passed.pytest tests/analyzer -q(the statement corpus) against a private ClickHouse migrated the same way: 12 passed, none skipped.tests/analyzer/shapes.txtis regenerated withpython -m tests.analyzer.corpus --write; its diff is the one entry of the schema dump, whose shape changes with the new column.loom code initfor an operator entry with the proxy set, in its own process, against a forward proxy on a loopback port: the proxy receivedCONNECT <host>:443with the entry's identity and the token, the clone was refused, and the command's output did not hold the token.Not run locally, CI runs them:
tests/unit/test_repo_job_sandbox_hostile.py, real bubblewrap): needs Linux.make test-mixed-version: needs Docker.make schema-checkon the release CI pins.schemas/schema.sqlwas not made bymake schema-dump: no ClickHouse of that release was at hand, so the one-line change toloom.code_reposis the block a dump of an older release printed after every migration ran from empty. That dump differs from the committed file elsewhere only in what the older release prints differently, and none of that is in this change. CI'sschema-checkdecides: if it is red, the diff it prints is applied as it stands.make format-checkas a whole (noshfmthere; no shell or TOML file changed),make test-unit-covand the rest of the integration suite.AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated (an agent wrote most of the diff): Claude Code. Checked by running, not by reading alone: with the real
gitbinary against a forward proxy on a loopback port, that the firstCONNECTcarries the identity and the password, that the repository token stays inside the tunnel, that the remote is trusted by the CA bundle and by no other, that a submodule's clone goes through the proxy while an ssh submodule is refused, and that no git argument, error text, log line or stored config holds the password; every migration from empty through 112 on a ClickHouse server, and the registry statements against it; the unit suite's failures on the build machine against the same run onmain. A second agent reviewed the diff, then the fixes its review asked for and the merges ofmain, and repeated the experiments with a proxy of its own on the merged tree.I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make format-check,make lint,make typecheckandmake test-unitpass; the integration suite passes if server behaviour changed.docs/reference/configuration.mdand thedocs/reference/tables (python scripts/codegen/docs_reference.py), the reach manifest,schemas/schema.sql(make schema-dump) and the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py).main; no merged migration is edited.hooks/,lib/,bin/,skills/,.mcp.json, the Codexplugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.npm --prefix frontend run build) and its tests pass, iffrontend/changed.docs/describe the system as it now is, and this description names any operator steps and wire changes.tests/unit/test_public_copy.py).git commit -s), as CONTRIBUTING.md asks.🤖 Generated with Claude Code