test(build): check that the same Agentkitfile always produces the same build
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 68/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- docker, go
- Ambito
- build-system, testing
Direzione di ricerca
Start with pkg/agentkit2llb/agent/convert.go, pkg/agentkit2llb/agent/image.go, and pkg/agentkit/abi/render.go, then read dalec's determinism_test.go for the reusable-helper example. Build a map-heavy fixture and check repeated Agentkit2LLB definitions, NewImageConfig JSON, and abi.Render bytes; run the listed Go tests and make lint. Done means all three outputs are byte-identical across runs and any differences found are fixed.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
BuildKit only reuses cached work when a build step is byte-for-byte the same as last time. In Go, looping over a map visits the keys in a random order. If any code builds a build step, the image settings or /agent/agent.yaml by looping over a map, two builds of the same Agentkitfile can come out different.
When that happens:
- The cache misses. Rebuilds redo work for no reason.
- Identical input, different images. The same file produces images with different digests.
- The config digest changes. Orka (ACP mode) and the
agentsessionsprofile pin the SHA-256 of the exact/agent/agent.yamlbytes. If the file's order changed between builds, that digest would change too. - #55 breaks. It promises that the same file always produces the same manifest.
This kind of bug is silent: every build still succeeds.
The risk is small today, because the build is just "runtime image + /agent/agent.yaml". But new features add more build output that comes from maps: install steps with env vars (#54), test steps (#57) and manifest attestations (#55).
dalec guards against this with determinism_test.go. It builds the same thing many times and checks that the results are identical.
What
Add tests that build the same agent many times and require byte-identical results for:
- the build steps: the marshaled BuildKit definition from
Agentkit2LLB; - the image settings from
NewImageConfig(labels, env, ports); - the
/agent/agent.yamlbytes fromabi.Render.
Fix any differences the tests find, usually by sorting keys before looping. Make the helper easy to reuse, so #54, #55 and #57 can add their own output to these checks.
Out of scope
- Reproducing builds across different machines or BuildKit versions.
- Changing what the build produces.
Why
- Reliable caching makes rebuilds faster.
- The same file gives the same image, which matters for signing, attestations (#55) and the pinned config digest.
- It catches a whole class of silent bugs before new features add more map-driven output.
How
Where things are
| File | What it does |
|---|---|
pkg/agentkit2llb/agent/convert.go |
Agentkit2LLB() returns the build state and image settings. |
pkg/agentkit2llb/agent/image.go |
NewImageConfig() builds the labels map and env list. |
pkg/agentkit/abi/render.go |
Render() writes /agent/agent.yaml. copyMap (around line 246) copies brokered tool parameters, which are nested maps. |
pkg/agentkit/effective/agent.go |
Turns the config into the build-ready agent, the input to all of the above. |
dalec determinism_test.go |
The helper to copy: requireDeterministicLLB. |
Steps
- Write a reusable helper, for example
requireDeterministic(t, build func() []byte).- It calls
build25 times and requires every result to equal the first. - A single repeat would miss random ordering about half the time when a map has only two keys. Running many times makes a miss very unlikely, and each run is cheap.
- Put it where tests in other packages can use it, for example a small
internal/testutilpackage.
- It calls
- For build steps, rebuild the state from scratch on every run, call
Marshal(ctx), and compare only.Def.Metadatacontains per-build noise such as progress-group IDs. Dalec's test explains why. - Use a fixture with lots of map entries, so random order is very likely to show:
- at least 12
metadata.labels; - several tools with
envlists andheaders; - a brokered tool with nested
parameters; - context providers;
- several
enventries.
- at least 12
- Add the three checks: the build definition, the image settings marshaled to JSON, and the
abi.Renderoutput. - Fix any differences by sorting keys before looping. Add a short comment wherever ordering matters.
- Point future work at the helper. Leave a comment on #54, #55 and #57 saying their new output should be added to these checks.
Tests
The new tests are the deliverable. Run them several times so a flaky pass is unlikely:
go test ./pkg/... -run Determin -count=5
go test ./...
make lint
Done when
- The checks cover the build definition, the image settings and the
/agent/agent.yamlbytes, using a map-heavy fixture. - They pass reliably, and any differences they found are fixed.
- The helper is easy for #54, #55 and #57 to reuse.
- Lingua principale
- Python
- Stelle
- 7
- Fork
- 5
- Merge medio
- 3h 39m
- PR unite (30g)
- 1
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di orka-agents/agentkit
-
fix(pydantic-ai): CI fails with newest pydantic-ai (unexpected 'history' argument)Forse già presa @gambtho l’ha presa 30 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
orka-agents/agentkit#77 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
orka-agents/agentkit#76 · 3 commenti ·
-
area/build area/orka area/runtime blocked enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
orka-agents/agentkit#69 ·
-
area/build area/orka area/runtime enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 68/100
orka-agents/agentkit#68 ·
-
area/build enhancement testing
Difficoltà 5/5 Più di una settimana Idoneità per principianti 42/100
orka-agents/agentkit#65 ·
Tutte le issue di orka-agents/agentkit
Issue simili
-
【文档错误】创建镜像空间步骤中的截图标注与文字描述不一致Apertaenhancement
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
DaoCloud/DaoCloud-docs#7839 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
sav-oss-org/ptusa_main#1610 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
bug status/accepted type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
microsoft/apm#4925 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
sagemathinc/sagebrush#1701 ·
I maintainer di solito rispondono entro 1 giorno