Repository navigation
The document extractor ships as its own image, beside the server in compose and Helm - #194
Merged
Merged
Conversation
zlareb1
force-pushed
the
feat/extractor-image
branch
2 times, most recently
from
November 3, 2026 15:27
d711b91 to
f4534a2
Compare
…ompose and Helm Related: #157 Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…tstrap and release job follow review Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…from distances, and keep docs in step Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…he io_uring probe to a host that allows it Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…er-service token map stays open in the chart Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…o gets the token Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…t the installer keeps both images Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… the environment reference name what it keeps Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ibed, label the extractor image as its own, and list its gates Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…cs and dev-setup skill name the extractor where they list the stack Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…upgrades page and threat model describe the stack Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…gers, skill row and reflowed docs say what is checked Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…writable through /proc Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ndition, and loom up's help names the extractor Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…st probes every call the filter refuses Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…tor image setting among the quickstart's non-settings Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… socket test probes process_vm_writev Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…, and the stack's test file is formatted Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…server's token line follows its ClickHouse block Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… change interrupts extraction while both sides roll Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…maries name the one-at-a-time condition Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
… an operator's own wins Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ler keeps an operator's URL and the README pins the image Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…the token note counts every Loom Deployment Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…nned Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…s both, and the release doc covers both images Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…ents and a help-text wrap Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…e gets a host baseline, and the bootstrap fills its token in one pass Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…es, and say what the socket filter covers Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
…rmat check fails on Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
zlareb1
force-pushed
the
feat/extractor-image
branch
from
November 3, 2026 16:51
af7e462 to
5d3be76
Compare
6 tasks done
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.
Related: #157
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 document extractor service ships as its own image,
ghcr.io/clickhouse/loom-extractor, and runs beside the server: as theextractorservice of the Compose stack (on by default, with a token the installer generates) and asextractor.enabledin the Helm chart, in both cases holding no credential but its token. Each extraction now runs under a seccomp filter under which it can make no socket, so an extraction a hostile file takes over reaches nothing, the Loom server on the same network included, while extractions run one at a time (the default).Why
The server sends originals to a separate extractor service and parses none itself (
docs/architecture/document-extraction.md); the service and its wire contract landed in the previous step of the related issue, but nothing built, released or ran it. This adds the image and runs it where Loom runs, with the isolation the design asks for: least privilege, bounded resources, and no way out, so a parser taken over by a hostile file holds nothing worth taking and can send it nowhere.Scope and risk
extractor/Dockerfile, built from the repository root): the package and its dependencies from a newextractor/uv.lock(uv sync --locked, hashes checked) into/opt/venv, owned by root; the service runs as uid 10001, which owns nothing in the image, so no file on a child'ssys.pathis writable to the child. No package beyond the base image's; the same pinnedpython:3.12-slimdigest as the server's image. Listens on 8790;/healthzhealthcheck. The lock holds the root lock's versions of every package both name (a test pins this), so the image runs what the unit tests ran.extractor/loom_extractor/child.py,no_sockets): an internal Compose network has no route out but lets its members reach each other, andloomlistens on 7777 there (unauthenticated in a default single-user install). So each child, after no-new-privileges and before it reads the source, installs a seccomp filter (no privilege needed) that makessocket,socketpairandio_uring_setupfail with EPERM, and so doptrace,process_vm_readv/process_vm_writevandpidfd_getfd, the direct ways into another process. A concurrent sibling (only withLOOM_EXTRACTOR_CONCURRENCYabove 1; the default is 1) stays writable through/proc/<pid>/memuntil it makes itself non-dumpable, so a taken-over child could still patch one before it filters itself; the docs say so, as they already said such a child could read a sibling's source then. Installing the filter before exec would close that window and needs an exec wrapper (the service is threaded, so notpreexec_fn); it is left for a follow-up. On x86_64 the x32 syscall range is refused too, and a process of another architecture is killed by the filter. The service refuses to start, and a child to extract, on an architecture with no filter (x86_64 and aarch64 are the image's). This holds wherever the service runs, Helm and a bare install included; the service's own process (which runs no parser) is not filtered.compose.yaml): anextractorservice atLOOM_VERSION(LOOM_EXTRACTOR_IMAGE_REPOSITORYnames another image; it is inNON_SETTINGS_ENV, so the server does not warn about it), on a network of its own that isinternal: true(no route out) and that onlyloomshares; no published port, noenv_file(it gets one variable, its token),read_only,cap_drop: [ALL],no-new-privileges, and a memory, CPU and process bound. The server getsLOOM_DOCUMENT_EXTRACTOR_URLfrom.envandLOOM_DOCUMENT_EXTRACTOR_TOKENthrough the same interpolation as the extractor's, so a shell export cannot split them.make devbuilds it from the checkout. The stacks that bring their own ClickHouse (dev/docker-compose.cloud.yml,dev/docker-compose.replicas.yml, the blue/green colours) are left as they are and say in the deployment guide to point the two settings at an extractor the operator runs; until then the server reports every format unavailable (it fails closed).deploy/standalone/env.examplecarries the URL and a token placeholder;install.shwrites a fresh 48-hex-character token per install and adds a token, and the URL unless one is there, to an.envfrom before this change (a rerun keeps an existing token);LOOM_EXTRACTOR_IMAGE_REPOSITORYis one of the settings the installer keeps.loom up/make bootstrapwrite a token into a new.envfrom.env.example, and add one to an existing.envthat has none (or an empty one), once.extractor.enabled, off by default): a Deployment (2 replicas, one extraction each), a Service and a NetworkPolicy, rendered whatevernetworkPolicy.enabledsays, that admits the release's Loom pods on 8790 and allows no egress. The pods read one key of the release Secret (LOOM_DOCUMENT_EXTRACTOR_TOKEN, fromsecrets.extractorTokenorsecrets.existingSecret), mount no service-account token, disable service links, and run as uid 10001 with a read-only root filesystem, every capability dropped and theRuntimeDefaultseccomp profile. Their pod template carrieschecksum/secret(loom.secretChecksum, which now hashes the token too), so a newsecrets.extractorTokenrestarts the Loom and the extractor pods together. They carry anamelabel of their own: with the chart's shared selector labels, the web pods' NetworkPolicy (which allows egress to 443 anywhere) and the web Service would select them too. WithnetworkPolicy.enabled, the Loom pods' policy allows egress to them. The Loom pods getLOOM_DOCUMENT_EXTRACTOR_URLunlessenvorextraEnvsets one. The chart refuses an enabled extractor without a token, a token under 16 characters, the token insecrets.extra,env,extraEnvorsettingsFile(any of those would reach the Loom pods alone, and every format would read as unavailable;LOOM_DOCUMENT_EXTRACTOR_TOKENS_JSONstays open for an operator's own routed services), andextractor.envsetting the token, host or port.dockerjob becomes a two-entry matrix (the server's image, with its build cache scope unchanged, and the extractor's), so each builds amd64 and arm64 (the extractor's image with its own OCI title and description; the server's keeps the repository's) with provenance and an SBOM, pushes by digest and fails on a critical fixed CVE (Trivy, both architectures); adocker-tagjob then tags both imagesX.Y.Z,X.Yandlatest, and tags neither until both have scanned (a failure in that job can leave one tagged; re-running it tags both, from the scans' artifacts, which also name each image and its pin); the released-quickstart smoke and the GitHub Release wait fordocker-tag. A package GitHub creates on its first push is private, so the release process now says to makeloom-extractorpublic once (an install pulls it without signing in; until then the released quickstart fails to pull it).docker-smoke.ymlbuilds the extractor image beside the server's and runs on changes underextractor/and tocompose.yaml(no CI job runs the dev overlay;test_compose_extractor_service.pychecks its extractor entries).docker_quickstart_smoke.pytakes--extractor-image(tagged as--image, since compose runs both atLOOM_VERSION) and, in the installed stack, runsscripts/gates/docker_extractor_smoke.pyinside theloomcontainer (the server's own client reaches the service at its configured URL with its token, lists the five formats and reads a TOML extraction back through the contract's checks) and, inside the extractor container, checks that a plain connection out fails withENETUNREACHorEHOSTUNREACH(or times out), and that one made under the child's filter toloom:7777fails withEPERM.scripts/gates/helm_extractor_isolation.pyrenders the chart (both overlays, the workers and network policies on) and checks that no Service, NetworkPolicy, PDB or Deployment of Loom's selects the extractor's pods, that their policy admits only Loom's pods and has no egress rule, that they read the one Secret key and noenvFrom, that a new token changes every Deployment's pod template (on the kind overlay; the EKS overlay's Secret is the operator's), and that the Loom pods gethttp://loom-extractor:8790by default and anenvorextraEnvURL instead; the CI Helm job runs it.Nothing calls the client yet; ingestion (the next step) does. Server code changes: the bootstrap's token,
loom uprecreating the extractor withloomon a running stack, and oneNON_SETTINGS_ENVentry; extractor code: the socket filter.Compatibility, rollout and rollback
LOOM_EXTRACTOR_IMAGE_REPOSITORYis a compose variable)..env); adocker compose upon an.envwithout the token starts the server as before, and the extractor container (restart: unless-stopped) restarts in a loop, logging each time that it needsLOOM_EXTRACTOR_TOKEN.make dev,make dev-cloudandloom uprun the bootstrap first, which adds a token to a clone's older.env;loom upon a stack already running recreates the extractor withloom(never ClickHouse), so a stack started before this change gains it. Helm: nothing untilextractor.enabled: truewithsecrets.extractorToken. Each side holds one token, so changingsecrets.extractorTokeninterrupts extraction until the Loom Deployments (web, and workers when enabled) and the extractor's finish rolling (the Kubernetes guide says so); accepting a previous token, asLOOM_JWT_SECRET_PREVIOUSdoes, is a follow-up.envorextraEnvnamingLOOM_DOCUMENT_EXTRACTOR_URLkeeps the chart from setting it (the URL is a secret setting, so the settings file cannot hold it)..envkeeps the two lines, which the server reads harmlessly.Tests
EPERM; to1.1.1.1:443,ENETUNREACH. Under the filter, pipes, file reads and importing sqlglot work.docker build -f extractor/Dockerfile ., then the image run with--read-only --cap-drop ALL --security-opt no-new-privileges: healthy;/v1/capabilitieslists the five formats; TOML and SQL extracted; inside it, uid 10001,CapPrm0, the root filesystem read-only and the package owned by root. 221 MB.scripts/gates/docker_quickstart_smoke.pywith images built from this branch: the installed stack came up with the extractor healthy,extractor: reached, declared five formats, extraction checked, the extractor's connection out failed (Network is unreachable), and every compiler-indexing check passed; the run then stopped at the dashboard provider step for want of the browser-test dependencies on this machine (ERR_MODULE_NOT_FOUND), which the CI job installs first. The script removed its stack.helm lint --strictandhelm template | kubeconform -stricton both overlays with every optional object on, the extractor included (EKS overlay 24 objects, kind 30), and each refusal above checked; the CI job runs both.tests/unit/test_compose_extractor_service.py(the service holds only its token, has noenv_file, port or volume, is on the internal network onlyloomshares, runs read-only with no capabilities and bounded; the dev stack builds it and points the server at it);test_install_script.py(a new install's URL and 48-character token, no placeholder left; an upgrade from before the service gets both, a rerun keeps the token, an upgrade keeps an operator's ownLOOM_DOCUMENT_EXTRACTOR_URL);test_cli_up.py(the bootstrap's token, an older.envgiven one once, andloom upon a running stack recreating the extractor withloom);test_stack_bundle.py(the bundle's compose names the extractor image, the template the token placeholder);test_distribution_licenses.py(the image carries the licence files);test_docker_quickstart_smoke.py(an extractor image of another tag refused; both workflows build or pull it and pass it; the release'sdocker-tagstep, run against two scans' artifacts and a stubdocker, tags both and prints both pins, and with one scan missing tags neither);test_extractor_service.py(a child can make no IPv4, IPv6 or Unix socket nor a socket pair, andio_uring_setup,ptrace,process_vm_readv,process_vm_writev,pidfd_getfdand, on x86_64, an x32-numbered call get EPERM, each of those syscall probes, the x32 one included, against an unfiltered baseline so a host that refuses one itself does not pass the test; the test fails withpidfd_getfdremoved from the filter; another architecture refuses to extract; the image's lock and the root lock agree on every shared package);test_compose_extractor_service.pyruns the Helm isolation check wherehelmis installed, runs the quickstart's extractor probe against the reference service in process, and checks thatloomand the extractor read the token from one interpolation;test_stock_env_matches_docs.pylistsLOOM_EXTRACTOR_IMAGE_REPOSITORYamong the quickstart's non-settings. The isolation check was confirmed to fail when the extractor's pods carry the shared selector labels (the web NetworkPolicy then selects them).make format-check,make lint, the mypy gate: pass.pytest tests/unit: CI'spytest unit + coveragepassed on the branch before its last rebase (the local full run was stopped by the host for memory); the CLI snapshot, extractor, compose, bootstrap, installer, quickstart, env-docs, doc-link and chunking tests pass on the rebased head (513). CI's Quickstart (amd64 and arm64), N-1/N, sandbox and frontend jobs passed; its integration job's two failures (tests/integration/same_key/test_retirement_ch.py, acapkeyword) were onmaintoo and are fixed there by The same-key retirement tests' conflict-check double accepts the keyword the bulk write passes #227, which this branch now includes.docs/features/knowledge.md, whichmain's format check fails on after knowledge.search's lexical leg scores each chunk's title and section path with its text #206; it is not part of this change otherwise.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.
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).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