feat(build): lock tool dependencies and keep package code off the network
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
- issue の種類
- 機能追加
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 領域
- build-system, tooling
調査の方向性
Start with pkg/agentkit/config/tool.go, validate.go, pkg/agentkit2llb/agent/convert.go, and pkg/build/instructions.go; trace how package installs and build-context files are handled. Run the Go validation and build-step tests, then go test ./... and make lint. Done means lock files are validated and affect the build cache, installs follow the network and wheel restrictions, caches stay out of the image, and the docs and end-to-end checks cover the specified behavior.
索引モデルが issue の本文から書いたものです。
説明
Depends on #54. #54 installs each stdio tool's package into the image at build time, pinned to an exact version. This issue makes those installs fully locked, safer and faster to rebuild.
Problem
After #54, a tool's own version is pinned, but four gaps remain:
- Dependencies are not pinned. The tool's dependencies are picked fresh every time the install step runs. Two builds of the same file a week apart can contain different dependency code. A bad or compromised dependency release slips in without anyone noticing.
- Downloads are not checked. Nothing confirms that the downloaded files are the ones you expected. A lock file fixes both of these: it lists the exact version of every dependency plus a hash, a fingerprint of each file. The installer can then refuse anything that doesn't match.
- Package code runs with network access. npm packages can run scripts while installing, and Python packages without a prebuilt version (a wheel) run build code. With the network on, that code can download and run more code.
- Every rebuild downloads everything again. There's no download cache between builds.
dalec handles this by downloading dependencies in one step with network access, then building in a separate step with the network off (see dalec's generator_pip.go and the Go and Cargo generators). It also keeps download caches between builds (see dalec's caches docs).
What
1. Optional lock file per tool
The lock file is read from the build context:
tools:
- name: fetch
package:
pypi: mcp-server-fetch==<version>
lockFile: ./tools/fetch/requirements.txt
command: ["mcp-server-fetch"]
- name: everything
package:
npm: "@modelcontextprotocol/server-everything@<version>"
lockFile: ./tools/everything/package-lock.json # package.json must sit next to it
command: ["mcp-server-everything"]
- PyPI: a requirements file with hashes, made with
uv pip compile --generate-hashes. The install refuses any file whose hash doesn't match. - npm: a
package-lock.json, with itspackage.jsonin the same folder. It's installed withnpm ci, which checks every file against the lock file. - Must match. The build fails if the lock file doesn't contain the pinned package at the pinned version.
- Docs. Show the exact commands for creating both kinds of lock file.
2. Package code never runs while the network is on
This applies to every packaged tool, with or without a lock file.
- npm:
- Download and check the files with network on and install scripts turned off:
npm ci --ignore-scripts. - Then run the install scripts in a second step with the network off:
npm rebuild. - A script that needs the network will fail, and the docs should say so.
- Download and check the files with network on and install scripts turned off:
- PyPI:
- Allow only prebuilt wheels (uv's
--no-build). Installing a wheel just unpacks files and runs no package code. - If a package has no wheel, fail with a clear message that names the package.
- Allow only prebuilt wheels (uv's
3. Download cache between builds
- Keep uv's and npm's download caches between builds.
- After a version bump, only what changed gets downloaded.
- The cache must never end up in the image.
Out of scope
- Private package indexes and registries that need credentials. That needs BuildKit build secrets and is still a follow-up.
- A way to allow Python packages that have no wheel. Add it later if people need it.
- Plain binary downloads. That's #43.
Why
- Same file, same tool code. Every build installs the same dependency code, down to the file fingerprint.
- Tampering is caught. The build fails if a download doesn't match.
- Package scripts can't fetch more code during the build.
- Faster rebuilds.
How
Where things are
| File | What it does |
|---|---|
pkg/agentkit/config/tool.go |
ToolPackage from #54. Add LockFile here. |
pkg/agentkit/config/validate.go |
Tool checks, including the package rules from #54. |
pkg/agentkit2llb/agent/convert.go |
The install steps added by #54. |
pkg/build/instructions.go |
contextFileReader.ReadFile reads files from the build context. Instruction files already use it. Read lock files the same way. |
Steps
-
Schema and validation.
- Add
lockFileunderpackage. The path is relative to the build context, and paths that escape it, such as../, are rejected. Check how instruction file paths are handled and do the same. - When building, read the file. For npm, also read the
package.jsonnext to it. - Fail with a clear message if:
- the file is missing;
- the PyPI lock has no
name==versionline for the pinned package (compare names the way PyPI does: case-insensitive, with-,_and.treated the same); - the npm
package.jsondoesn't list the pinned package at the pinned version.
- Pass the file contents into the install step by writing them into an empty filesystem (
llb.Scratch().File(llb.Mkfile(...))). That way the build cache notices when a lock file changes.
- Add
-
PyPI install with a lock file.
uv tool installcan't check hashes, so instead:- create a virtual environment with
uv venv /opt/agentkit-tools/uv/<tool>; - install with
uv pip install --python /opt/agentkit-tools/uv/<tool>/bin/python --require-hashes --no-build -r <lock>; - link the program named in
command[0]from that environment'sbininto/opt/agentkit-tools/bin. Fail if it isn't there.
Without a lock file, keep #54's
uv tool install, but add--no-build. - create a virtual environment with
-
npm install, two steps. Use one folder per tool, for example
/opt/agentkit-tools/npm/<tool>.- Step A, network on:
npm ci --ignore-scripts. - Step B, network off (
llb.Network(llb.NetModeNone)):npm rebuild. - Link the program into
/opt/agentkit-tools/bin.
Without a lock file, use
npm install --ignore-scripts <spec>in step A, then the same step B. - Step A, network on:
-
Download cache. During the install steps, mount uv's cache directory and npm's cache directory as shared persistent caches:
llb.AsPersistentCacheDir("agentkit-uv", llb.CacheMountShared), pointed at withUV_CACHE_DIR;llb.AsPersistentCacheDir("agentkit-npm", llb.CacheMountShared), pointed at withnpm_config_cache.
These mounts never become part of the image.
-
Check the flags against the uv and npm versions in the runtime images (Wolfi
uvandnpm-12, seeruntimes/*/Dockerfile).
Tests
- Go, validation:
- a missing lock file;
- the pinned version not in the lock;
- an npm
package.jsonthat doesn't match; - a path that escapes the build context.
- Go, build steps:
- PyPI steps use
--require-hashesand--no-build; - npm uses two steps, the first with
--ignore-scriptsand the second with network off; - both cache mounts are present;
- the image contents don't include the caches;
- a changed lock file changes the step.
- PyPI steps use
- End to end:
- Add fixtures with real lock files, for example under
test/tool-locks/. - The agent builds and starts with
docker run --network none. - Editing one hash in a lock file makes the build fail.
- A second build after bumping one version reuses cached downloads.
- Add fixtures with real lock files, for example under
- If #61 has landed, add the new install steps to its checks that builds come out the same every time.
Run:
go test ./...
make lint
Docs
docs/agentkitfile.md: add a "Locking tool dependencies" section covering:- how to create each kind of lock file;
- the "package code never runs with network on" rule;
- the wheels-only rule for Python;
- what to do when a package fails because of either rule.
Done when
- Tools with a lock file install exactly the locked files, and a tampered hash fails the build.
- npm install scripts run only with the network off, and Python installs use wheels only.
- Rebuilds after a version bump reuse cached downloads, and no cache ends up in the image.
- Agents with locked tools start with
--network none. - The docs explain how to create lock files and what the new rules mean.
- 主要言語
- Python
- スター
- 7
- フォーク
- 5
- 平均マージ
- 3時間 39分
- マージ済み PR(30日)
- 1
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
orka-agents/agentkit のほかの issue
-
fix(pydantic-ai): CI fails with newest pydantic-ai (unexpected 'history' argument)対応中かも @gambtho が 30 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
orka-agents/agentkit#77 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
orka-agents/agentkit#76 · コメント 3 件 ·
-
area/build area/orka area/runtime blocked enhancement
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
orka-agents/agentkit#69 ·
-
area/build area/orka area/runtime enhancement
難易度 4/5 3〜5日 初心者へのやさしさ 68/100
orka-agents/agentkit#68 ·
-
area/build enhancement testing
難易度 5/5 1週間以上 初心者へのやさしさ 42/100
orka-agents/agentkit#65 ·
orka-agents/agentkit の issue をすべて見る
似ている issue
-
bot-triaged module: correctness (silent) module: fft triage review
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
conda-forge/zarpaint-feedstock#8 · コメント 1 件 · リアクション 1 件 ·
-
plot_prediction colorbar shows a 0-1 range instead of the data range対応中かも @nikhil3495 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
mllam/neural-lam#902 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
didi/helixharness#28 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 1/5 1時間未満 初心者へのやさしさ 62/100
DaoCloud/DaoCloud-docs#7839 ·
メンテナーはふだん 1 日以内に返信