Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

test(minikube): verify real builder provenance across partial builds

Alfredo Lopez406d3e4a55a9
diff --git a/scripts/e2e/approved-tools-image-proof.test.mjs b/scripts/e2e/approved-tools-image-proof.test.mjs
index 630e969c5..4a5870804 100644
--- a/scripts/e2e/approved-tools-image-proof.test.mjs
+++ b/scripts/e2e/approved-tools-image-proof.test.mjs
@@ -5,10 +5,10 @@
// runs a command, touches the filesystem, or reaches a cluster, and every
// digest is generated, not copied.
//
-// This is NOT the end-to-end coverage for the acquisition contract. The hermetic
-// builder test -- which runs scripts/minikube/build-images.sh against fake
-// runtime binaries and proves the carry-across-partial-runs behaviour -- is
-// still owed, and its absence is the open gap for this change.
+// Real-builder coverage lives in scripts/tests/test-minikube-docker-cli-env.sh:
+// sequential partial builds, both derived-image bindings, stale/missing images,
+// profile mismatch, malformed prior JSON, and preservation of a good manifest
+// when late inventory queries fail. Neither suite certifies a live deployment.
import assert from 'node:assert/strict'
import { createHash } from 'node:crypto'
import test from 'node:test'
diff --git a/scripts/tests/test-minikube-docker-cli-env.sh b/scripts/tests/test-minikube-docker-cli-env.sh
index 5f7550cbe..d718e8a29 100755
--- a/scripts/tests/test-minikube-docker-cli-env.sh
+++ b/scripts/tests/test-minikube-docker-cli-env.sh
@@ -163,6 +163,31 @@ case "$operation_mode" in
;;
esac
+case "${1:-}" in
+ build|images|inspect)
+ # Optional daemon inventory for sequential manifest tests. The other
+ # cases retain their existing stateless failure-injection behavior.
+ if [[ -n "${FAKE_DOCKER_IMAGE_STATE:-}" ]]; then
+ node - "$FAKE_DOCKER_IMAGE_STATE" "$@" <<'NODE'
+const fs = require('node:fs')
+const crypto = require('node:crypto')
+const [file, operation, ...args] = process.argv.slice(2)
+const images = JSON.parse(fs.readFileSync(file, 'utf8'))
+const ref = operation === 'build' ? args[args.indexOf('-t') + 1] : args.at(-1)
+if (operation === 'build') {
+ images[ref] = 'sha256:' + crypto.createHash('sha256').update(ref).digest('hex')
+ fs.writeFileSync(file, JSON.stringify(images))
+} else if (images[ref]) {
+ process.stdout.write(images[ref] + '\n')
+} else if (operation === 'inspect') {
+ process.exit(1)
+}
+NODE
+ exit $?
+ fi
+ ;;
+esac
+
case "${1:-}" in
images)
if [[ -n "${FAKE_DOCKER_IMAGES_PRESENT_MATCH:-}" \
@@ -432,6 +457,149 @@ assert_real_build_script_isolated() {
fi
}
+assert_sequential_build_manifest_provenance() {
+ local fixture="$TMP_DIR/provenance-repo/repo" output="$TMP_DIR/provenance.out"
+ local state="$TMP_DIR/image-state.json" baseline="$TMP_DIR/provenance-baseline.json"
+ local manifest revision_before revision_after selector scenario operation status
+ prepare_fixture_repo "$fixture"
+ manifest="$fixture/deploy/minikube/.image-manifest.json"
+ mkdir -p "$fixture/codex-llm-proxy"
+ printf '{}\n' >"$state"
+ revision_before="$(git -C "$fixture" rev-parse HEAD)"
+
+ for selector in codex-llm-proxy codex-approved-tools-proxy-e2e \
+ workflow-custom-sdk-e2e codex-approved-tools-workflow-e2e; do
+ if ! FAKE_DOCKER_IMAGE_STATE="$state" MINIKUBE_PRELOAD_BASE_IMAGES=false \
+ bash "$fixture/scripts/minikube/build-images.sh" "--only=$selector" \
+ >"$output" 2>&1; then
+ fail "sequential provenance setup failed for $selector: $(tail -20 "$output")"
+ return
+ fi
+ done
+ git -C "$fixture" commit --allow-empty -qm 'next fixture revision'
+ revision_after="$(git -C "$fixture" rev-parse HEAD)"
+ if ! FAKE_DOCKER_IMAGE_STATE="$state" MINIKUBE_PRELOAD_BASE_IMAGES=false \
+ bash "$fixture/scripts/minikube/build-images.sh" --only=codex-approved-tools-mcp-e2e \
+ >"$output" 2>&1; then
+ fail "sequential provenance follow-up failed: $(tail -20 "$output")"
+ return
+ fi
+ if node - "$manifest" "$revision_before" "$revision_after" <<'NODE'
+const assert = require('node:assert/strict')
+const fs = require('node:fs')
+const [file, before, after] = process.argv.slice(2)
+const m = JSON.parse(fs.readFileSync(file, 'utf8'))
+const base = 'clerum/codex-llm-proxy:test'
+const derived = 'clerum/codex-approved-tools-proxy-e2e:test'
+const newest = 'clerum/codex-approved-tools-mcp-e2e:test'
+assert.notEqual(before, after)
+assert.equal(m.gitHead, after)
+assert.equal(m.sourceRevisions[base], before)
+assert.equal(m.sourceRevisions[derived], before)
+assert.equal(m.sourceRevisions[newest], after)
+assert.match(m.images[derived], /^sha256:[0-9a-f]{64}$/)
+assert.deepEqual(m.derivedFrom[derived], { ref: base, id: m.images[base] })
+const workflowBase = 'clerum/workflow-custom-sdk-e2e:test'
+const workflowDerived = 'clerum/workflow-custom-sdk-e2e:approved-tools-test'
+assert.equal(m.sourceRevisions[workflowBase], before)
+assert.equal(m.sourceRevisions[workflowDerived], before)
+assert.match(m.images[workflowDerived], /^sha256:[0-9a-f]{64}$/)
+assert.deepEqual(m.derivedFrom[workflowDerived], { ref: workflowBase, id: m.images[workflowBase] })
+NODE
+ then
+ pass "five sequential --only builds preserve prior revisions and both exact derived-base bindings"
+ else
+ fail "sequential --only builds lost or restamped prior provenance"
+ return
+ fi
+ cp "$manifest" "$baseline"
+ cp "$state" "$TMP_DIR/image-state-baseline.json"
+
+ # A late failure while carrying a previously built fixture must leave the
+ # entire last good manifest intact, even after the new image was built.
+ for operation in 'images -q' 'inspect --format={{.Id}}'; do
+ cp "$baseline" "$manifest"
+ cp "$TMP_DIR/image-state-baseline.json" "$state"
+ status=0
+ FAKE_DOCKER_IMAGE_STATE="$state" MINIKUBE_PRELOAD_BASE_IMAGES=false \
+ FAKE_DOCKER_MODE=exit FAKE_DOCKER_EXIT_CODE=41 \
+ FAKE_DOCKER_MATCH="$operation clerum/codex-approved-tools-proxy-e2e:test" \
+ bash "$fixture/scripts/minikube/build-images.sh" --only=control-api \
+ >"$output" 2>&1 || status=$?
+ if [[ "$status" -eq 41 ]] && cmp -s "$baseline" "$manifest" \
+ && grep -Fq 'exitCode=41' "$output"; then
+ pass "manifest $operation failure preserves status and prior manifest bytes"
+ else
+ fail "manifest $operation failure changed prior manifest or status (status=$status)"
+ fi
+ done
+
+ for scenario in replaced missing profile-mismatch changed-base changed-workflow-base malformed; do
+ cp "$baseline" "$manifest"
+ cp "$TMP_DIR/image-state-baseline.json" "$state"
+ node - "$manifest" "$state" "$scenario" <<'NODE'
+const fs = require('node:fs')
+const [manifest, state, scenario] = process.argv.slice(2)
+const m = JSON.parse(fs.readFileSync(manifest, 'utf8'))
+const images = JSON.parse(fs.readFileSync(state, 'utf8'))
+const derived = 'clerum/codex-approved-tools-proxy-e2e:test'
+if (scenario === 'replaced') images[derived] = 'sha256:' + 'a'.repeat(64)
+if (scenario === 'missing') delete images[derived]
+if (scenario === 'profile-mismatch') m.profile = 'another-fixture-profile'
+if (scenario === 'changed-base') images['clerum/codex-llm-proxy:test'] = 'sha256:' + 'b'.repeat(64)
+if (scenario === 'changed-workflow-base') images['clerum/workflow-custom-sdk-e2e:test'] = 'sha256:' + 'c'.repeat(64)
+fs.writeFileSync(manifest, scenario === 'malformed' ? '{' : JSON.stringify(m))
+fs.writeFileSync(state, JSON.stringify(images))
+NODE
+ if ! FAKE_DOCKER_IMAGE_STATE="$state" MINIKUBE_PRELOAD_BASE_IMAGES=false \
+ bash "$fixture/scripts/minikube/build-images.sh" --only=control-api \
+ >"$output" 2>&1; then
+ fail "provenance $scenario build failed: $(tail -20 "$output")"
+ continue
+ fi
+ if node - "$manifest" "$scenario" "$revision_before" "$revision_after" <<'NODE'
+const assert = require('node:assert/strict')
+const fs = require('node:fs')
+const [file, scenario, before, after] = process.argv.slice(2)
+const m = JSON.parse(fs.readFileSync(file, 'utf8'))
+const base = 'clerum/codex-llm-proxy:test'
+const derived = 'clerum/codex-approved-tools-proxy-e2e:test'
+const workflowBase = 'clerum/workflow-custom-sdk-e2e:test'
+const workflowDerived = 'clerum/workflow-custom-sdk-e2e:approved-tools-test'
+assert.equal(m.sourceRevisions['clerum/control-api:test'], after)
+if (scenario === 'changed-workflow-base') {
+ assert.equal(m.derivedFrom?.[workflowDerived], undefined)
+ assert.match(m.images[workflowDerived], /^sha256:[0-9a-f]{64}$/)
+ assert.equal(m.sourceRevisions[workflowDerived], before)
+ assert.equal(m.sourceRevisions[workflowBase], undefined)
+ assert.deepEqual(m.derivedFrom[derived], { ref: base, id: m.images[base] })
+} else if (scenario === 'changed-base') {
+ assert.equal(m.derivedFrom?.[derived], undefined)
+ assert.match(m.images[derived], /^sha256:[0-9a-f]{64}$/)
+ assert.equal(m.sourceRevisions[derived], before)
+ assert.equal(m.sourceRevisions[base], undefined)
+} else {
+ assert.equal(m.derivedFrom?.[derived], undefined)
+ assert.equal(m.images[derived], undefined)
+ assert.equal(m.sourceRevisions[derived], undefined)
+}
+if (scenario === 'profile-mismatch' || scenario === 'malformed') {
+ assert.equal(m.sourceRevisions[base], undefined)
+ assert.equal(m.images['clerum/codex-approved-tools-mcp-e2e:test'], undefined)
+ assert.equal(m.images[workflowDerived], undefined)
+ assert.equal(m.sourceRevisions[workflowBase], undefined)
+ assert.equal(m.sourceRevisions[workflowDerived], undefined)
+ assert.equal(m.derivedFrom?.[workflowDerived], undefined)
+}
+NODE
+ then
+ pass "sequential manifest rejects stale provenance: $scenario"
+ else
+ fail "sequential manifest retained stale provenance: $scenario"
+ fi
+ done
+}
+
assert_public_pulls_are_isolated() {
local fixture="$TMP_DIR/public-repo/repo" output="$TMP_DIR/public.out"
prepare_fixture_repo "$fixture"
@@ -976,6 +1144,7 @@ assert_endpoint_resolution_and_context_precedence
assert_config_only_rootless_context
assert_all_original_docker_env_is_restored
assert_real_build_script_isolated
+assert_sequential_build_manifest_provenance
assert_public_pulls_are_isolated
assert_local_image_operations_preserve_status
assert_local_minikube_load_timeout_kills_descendants