Skip to content

A deployment without the repository-job sandbox can index repositories its platform admins add - #912

Merged
zlareb1 merged 6 commits into
mainfrom
pufit/code-self-service-platform-admins
Nov 18, 2026
Merged

zlareb1 merged 6 commits into
mainfrom
pufit/code-self-service-platform-admins

Conversation

@pufit

@pufit pufit commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • New Feature

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):

A deployment that cannot run the repository-job sandbox can index repositories its platform admins add with code.repo.add. LOOM_CODE_SELF_SERVICE_PLATFORM_ADMIN_ONLY leaves code.repo.remote_branches, code.repo.add and code.repo.add_branch to platform admins, and LOOM_CODE_SELF_SERVICE_GIT_UNSANDBOXED then runs such a repository's clone and fetches as plain processes while its compiler tiers stay skipped. Both default to off.

Why

Without the repository-job sandbox, code.repo.remote_branches, code.repo.add and code.repo.add_branch answer SANDBOX_UNAVAILABLE, and a repository added earlier is neither cloned nor fetched: its remote is a host the adder chose, and a plain-process job has no egress proxy to vet that host. The default Kubernetes pod security does not grant the user namespaces bubblewrap needs, so such a deployment indexes only what its operator lists in LOOM_CODE_REPOS_JSON, and every new repository is a configuration change and a rollout.

Two facts allow a narrower rule. The git jobs between the add and a ready index (ls-remote, the bare clone, fetches) run no repository code: a clone transfers objects and refs, the mirror is bare, and git reads no system or global configuration. What the sandbox adds for them is the address check, a filesystem view and HOME of their own, and resource limits (CPU, memory, file size, processes). The address check matters most, because any org member may name the remote.

This change adds two settings:

  • LOOM_CODE_SELF_SERVICE_PLATFORM_ADMIN_ONLY leaves the three ops that start a remote job or add an index to platform admins. The handler checks it after the self-service switch and before the sandbox probe and any remote job. The role counts on a flat token used by its own subject: a scoped token (ns_roles) is refused as on the admin routes, and so is a trusted caller acting for another subject (X-Loom-On-Behalf-Of), whose role is not that subject's. A call without a principal passes only with auth off, when no transport asks for a token and there is no caller to refuse. With auth on it is refused like any caller that is not a platform admin: an MCP endpoint in open mode takes a call that sends no bearer, and that call reaches the handler without a principal.
  • LOOM_CODE_SELF_SERVICE_GIT_UNSANDBOXED lifts the SANDBOX_UNAVAILABLE refusal of those ops and lets the ingest pass and history reads clone and fetch a self-registered entry with a network remote. Loom refuses to load it in three cases: without the first setting, since whoever names a remote picks what the server connects to; with auth off (LOOM_AUTH_REQUIRED=false or LOOM_IDENTITY_PROVIDER=single-user), where the platform-admin rule passes a call without a principal, and with LOOM_MCP_AUTH_MODE=open, where such a call arrives with auth on: the rule refuses it, and the setting still needs every caller authenticated; and together with LOOM_CODE_SANDBOX_REQUIRED, under which no job runs as a plain process.

The waiver is a keyword, git_only, that the two git callers pass to compiler_tier.unsandboxed_skip. The compiler-tier pass and loom code scip-full ask without it and keep their skip, so no tier of such an entry runs: every tier's jobs reach the network (package installs, go mod download, submodules), and the C/C++ tier runs the repository's build.

Alternatives and what each costs:

  • Declaring the three ops with required_role=PLATFORM_ADMIN. An Operation is fixed at import, so the role could not follow a setting, and every deployment would lose member self-service.
  • Lifting the network skip for every job of a self-registered entry. It is one line, and it would run the static tiers' dependency installs unsandboxed.
  • Skipping every tier of every self-registered entry without the sandbox. It would take the static tiers from entries on a local mirror, which keep them.
  • A capability field on code.repos so the dashboard follows the settings. It is a wire change with both SDK regenerations; the page keeps reading /v1/health in this change.

Scope and risk

  • Touches server/settings (two fields, one load check), server/code/app/repo_admin.py (one helper, one call in each of the three handlers, the waiver in _require_sandbox), compiler_tier.unsandboxed_skip and its callers in ingest_pass.py and bootstrap.py, the repo_jobs_unsandboxed message, four documentation pages and the generated references.
  • Leaves alone: run_job and the sandbox, the egress proxy, the compiler-tier call sites, operator entries, self-registered entries on a local mirror (static tiers and no C/C++ tier), code.repo.remove, code.repo.set_access and code.repo.set_source (namespace admin gate), and the dashboard.
  • With the waiver on, git connects to the host and port a platform admin names, and to a host that one redirects to, with nothing vetting the address. Private and link-local addresses are reachable, and an ssh remote runs ssh with the server's HOME. The load check ties this to the platform-admin rule, and the operations guide states it.
  • A plain git job also runs without the sandbox's CPU, memory, file-size and process limits. A large or hostile remote is bounded by the clone and fetch timeouts and by the disk, on the worker and on every serving process that mirrors it.
  • The waiver resumes the git jobs of entries that members added before the platform-admin rule was set: code.repo.set_access rewrites a registry row's created_by, so the code cannot tell who named a remote. The operations guide says what to review before turning it on.
  • Every serving process fetches mirrors for history reads, so with the waiver on the web processes connect to the remotes too, not only the worker.
  • Auth: the first setting adds a refusal and removes none. The second removes a refusal only where the first is set. With auth off a call without a principal passes the platform-admin rule, as it passes every other gate. With auth on such a call is refused: over MCP in open mode a call that sends no bearer has no principal, and no other gate stops it. The waiver loads in neither mode; the first setting alone loads in both.
  • The dashboard reads neither setting. Where /v1/health reports repo_jobs_unsandboxed it offers no add, to platform admins included, so they call the op; elsewhere a member still sees the button and gets the refusal sentence.
  • No stored data, schema, concurrency or tenant-isolation change.

Compatibility, rollout and rollback

  • Wire: no op or field added, changed or removed, and no new error code. With LOOM_CODE_SELF_SERVICE_PLATFORM_ADMIN_ONLY=true the three ops answer AUTH_INSUFFICIENT (403) to a caller that is not a platform admin, a call without a principal included where auth is on; with LOOM_CODE_SELF_SERVICE_GIT_UNSANDBOXED=true they stop answering SANDBOX_UNAVAILABLE. A compiler-tier pass names a new skip reason for such an entry, and the repo_jobs_unsandboxed warning has a second wording; its code and severity are unchanged.
  • Settings: two new booleans, default false, read at start. No default changes. Load refuses the waiver without the first setting, with auth off or MCP in open mode, and with LOOM_CODE_SANDBOX_REQUIRED; each message names the settings involved.
  • Operator steps: none for a deployment that sets neither. To use it: first review the entries members added earlier, which keep the remotes their adders named and are fetched the same way (the active rows of loom.code_repos whose row_kind is not access), and have those a platform admin would not add removed with code.repo.remove. Then set both, with auth required and MCP not in open mode, leave LOOM_CODE_SANDBOX_REQUIRED off, restart, and add repositories with code.repo.add using a platform admin's token.
  • Rolling upgrade: a build that does not know the settings logs and ignores them, so its processes keep refusing the add and skipping the entry until they are replaced.
  • Rollback: reverting keeps the registry rows added meanwhile. Without the sandbox they are skipped again and resume when the sandbox returns. No migration; the generated references and the defaults snapshot revert with the code.

Tests

New and changed unit tests, each naming the rule it proves:

  • tests/unit/test_code_repo_self_service.py: with LOOM_CODE_SELF_SERVICE_PLATFORM_ADMIN_ONLY a member gets AUTH_INSUFFICIENT, with the setting named, from each of the three ops, before the sandbox probe and before any remote job, and nothing is registered. A platform admin runs all three. A scoped token, a trusted caller acting for a subject and an org admin are refused. With auth off (LOOM_AUTH_REQUIRED=false, and single-user) a call without a principal runs the three ops. With auth on and MCP in open mode, an MCP call that sends no bearer gets AUTH_INSUFFICIENT from each of the three tools, before the sandbox probe and any remote job. With LOOM_CODE_SELF_SERVICE_GIT_UNSANDBOXED and no sandbox the three ops pass, the registry rows are written, and each call still probes off the event loop. With auth off the handler has no caller to refuse on that path either: the add reaches the remote the request names and registers the entry, which is the case the load check closes.
  • tests/unit/test_repo_job_sandbox.py: the waiver keeps a self-registered network entry in the ingest pass and lets a history read through, while a compiler tier and the build tier keep their skips, an entry on a local mirror behaves as without the setting, and the required sandbox still refuses every entry. The load refusals: without the platform-admin rule, with auth off, with single-user, with MCP open and with the required sandbox; the pair loads with auth on, and with MCP discovery_only. The health warning keeps its severity and fix and changes its sentence.
  • tests/unit/test_code_compiler_tier_runner.py: with the waiver on and no sandbox, each of the four compiler-tier workers runs nothing for a self-registered network entry and names the new reason.
  • tests/unit/test_mirrors.py: without the sandbox a history read starts no clone of such an entry, and starts it with the waiver.

What ran, and what it showed:

  • LOOM_ENV_FILE= .venv/bin/python -m pytest -q tests/unit/test_code_repo_self_service.py tests/unit/test_code_repo_remote_branches.py tests/unit/test_repo_job_sandbox.py tests/unit/test_code_compiler_tier_runner.py tests/unit/test_mirrors.py tests/unit/test_health_error_text.py: 215 passed, 1 skipped (test_the_relay_is_given_the_live_idle_timeout, Linux only).
  • The settings, test-inventory, generated-reference, layering, health, doc-link and public-copy tests: 792 passed.
  • make lint and make typecheck pass. ruff format --check, Biome, Prettier and Taplo pass; shfmt was not installed on the development host, and no shell file changed.
  • pytest tests/unit -q -n auto on the development host (macOS), run on the first commit, before the two later fixes for calls without a principal and their tests: 38,686 passed; 1,222 failed and 13 errors. 1,234 of those are the same test ids that fail there on the base commit: the code-parse child process exits 1 on that host, and the local clickhouse binary refuses a setting the SQL-backed tests send. The other one is a linear-time timing test that failed on a loaded machine and passes when run again. No failing test is in a file this change touches. pytest bench -q: 251 passed. CI's run is the reference.
  • Not run locally: the real-bubblewrap suites (LOOM_TEST_REQUIRE_SANDBOX=1 .venv/bin/python -m pytest tests/unit/test_repo_job_sandbox.py tests/unit/test_repo_job_sandbox_hostile.py -q), which this diff owes because it touches compiler_tier.py and tests/unit/test_repo_job_sandbox.py. They need a Linux host where bubblewrap can create namespaces, so CI's repository-job sandbox (real bubblewrap) job is their first run. The integration suite and the Docker smoke jobs also run in CI.
  • No test runs a real git against a network remote. The plain-process run itself is run_job's existing fallback, which test_a_required_sandbox_refuses_the_job_instead_of_running_it_plain covers; the new tests prove which callers reach it.

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: the order of the handler's checks against the transport gate for each of the three ops; that the compiler-tier pass and loom code scip-full call unsandboxed_skip unchanged; every documentation sentence against the code path it names; the regenerated diff, which holds the two settings and nothing else.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • make format-check, make lint, make typecheck and make test-unit pass; the integration suite passes if server behaviour changed. (make lint and make typecheck pass; the format checks pass but shfmt, which was not installed; make test-unit and the integration suite: see Tests.)
  • Generated files are regenerated in this PR, not by hand: the SDK op tables, docs/reference/configuration.md and the docs/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). (The configuration reference, the status table, the settings schema, the settings template and the defaults snapshot change; no op changed.)
  • A new migration is additive and numbered after the latest on main; no merged migration is edited. (No migration.)
  • A behaviour change to any file a plugin ships (hooks/, lib/, bin/, skills/, .mcp.json, the Codex plugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version. (No plugin file changed.)
  • The frontend builds (npm --prefix frontend run build) and its tests pass, if frontend/ changed. (Unchanged.)
  • Docs under docs/ describe the system as it now is, and this description names any operator steps and wire changes.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers; the history goes in this description (tests/unit/test_public_copy.py).
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.

🤖 Generated with Claude Code

…s its platform admins add

Without the sandbox, code.repo.add refuses and an entry it added is not fetched:
the clone talks to a host the adder chose, and a plain process has no egress proxy
to vet it. A deployment whose pods cannot create user namespaces therefore indexes
only what its operator lists in LOOM_CODE_REPOS_JSON.

LOOM_CODE_SELF_SERVICE_PLATFORM_ADMIN_ONLY leaves code.repo.remote_branches,
code.repo.add and code.repo.add_branch to platform admins: the role counts on a
flat token used by its own subject, and the check runs before the sandbox probe
and before any remote job. LOOM_CODE_SELF_SERVICE_GIT_UNSANDBOXED then lifts the
SANDBOX_UNAVAILABLE refusal of those ops and lets the ingest pass and history
reads clone and fetch such an entry as plain processes.

The waiver is a keyword the two git callers pass to unsandboxed_skip. A compiler
tier asks without it and keeps skipping the entry, since its dependency installs
and module downloads would run without the proxy too. The setting is refused at
load without the platform-admin rule, because whoever names a remote picks what
the server connects to, and together with LOOM_CODE_SANDBOX_REQUIRED, under which
no job runs as a plain process. Health keeps repo_jobs_unsandboxed as a warning
and says what the setting changes.

Both settings default to off, so a deployment that sets neither keeps these refusals.

Signed-off-by: pufit <[email protected]>
…principal

A request without a principal passes the platform-admin rule: with auth off, and
over MCP in open mode for a call that sends no bearer. With
LOOM_CODE_SELF_SERVICE_GIT_UNSANDBOXED on, such a request names the host the
server's git connects to, the one choice the setting leaves to platform admins.
Load refuses the setting in those modes, beside its refusal without the
platform-admin rule. The handler is unchanged: it has no caller to refuse.

The operations guide says that the setting also resumes the git jobs of entries
members added before the platform-admin rule was set, and what to review before
turning it on.

The load test drops assertions that read values nothing had set.

Signed-off-by: pufit <[email protected]>
@zlareb1 zlareb1 self-assigned this Nov 18, 2026

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No findings in the platform-admin gate, settings load refusals, git-only callers, compiler-tier exclusions or rolling-upgrade behavior. The 219 focused authorization, sandbox-policy, mirror, health and settings tests pass locally, with one Linux-only skip; the four generated-reference checks pass. CI must finish, including the real sandbox suite. Real network remotes were not exercised locally.

…t a principal where auth is on

LOOM_CODE_SELF_SERVICE_PLATFORM_ADMIN_ONLY passed every call that carried no
principal. That is the rule with auth off, where no transport asks for a token.
It also let an MCP endpoint in open mode, on a deployment whose auth is on, add
repositories for a caller that sent no bearer: such a call reaches the handler
without a principal.

The rule passes a call without a principal only where auth is off
(auth_actually_required), which is when the MCP transport runs open as well.
Where auth is on the call is refused like any caller that is not a platform
admin.

LOOM_CODE_SELF_SERVICE_GIT_UNSANDBOXED still does not load with MCP in open
mode. Its message and the guide state the rule as it is: the handler refuses
such a call, and the setting needs every caller authenticated.

Signed-off-by: pufit <[email protected]>
docs/reference/status.md conflicted on its count of boolean settings that load
false. It is main's file regenerated by scripts/codegen/docs_reference.py, so it
counts main's new setting and the two of this branch.

Signed-off-by: pufit <[email protected]>

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No findings in the updated platform-admin gate or its callers. The gate refuses a call without a principal when authentication is required, before any sandbox probe or remote job; auth-off behavior remains explicit. All 180 focused repository, sandbox-policy, compiler-tier and settings tests pass locally, with one Linux-only skip. CI must finish before merge; real network remotes were not exercised locally.

@zlareb1
zlareb1 merged commit 2f9eaf8 into main Nov 18, 2026
49 checks passed
@zlareb1 zlareb1 mentioned this pull request Nov 18, 2026
6 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants