From 4a533beee35cb9c3e81a7c9b84103c145aeb7178 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Fri, 18 Sep 2026 06:42:55 +0300 Subject: [PATCH] =?UTF-8?q?ci:=20=F0=9F=90=9B=20the=20image=20proof=20asse?= =?UTF-8?q?rted=20a=20refusal=20through=20pipefail?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The suite-skip path exposed a latent defect one step after the gate: "Prove the default image is API-only and refuses `local` cleanly" ended with docker run --rm … "$img" python -m src.service.preflight 2>&1 \ | grep -q 'provision_local_stack.sh' under `set -euo pipefail`, and the refusal it asserts on exits 2 by design (src/service/preflight.py: main() returns 2, enforce() raises SystemExit(2)). pipefail therefore handed that 2 back as the STEP's own status: job 35303767476 died at exit 2 with the expected line sitting in the log, while the two checks before it (torch absent, api path green) had passed. Not introduced by the gate commit: the shape and the exit 2 both came from 1d40da1 (2026-09-17 20:52), which post-dates the last green run (15f1244, 16:48) — the Test-step hang had been masking it ever since. The assertions are now explicit and separable: the output goes to $local_out, the exit code to $local_rc; `local` must exit non-zero AND its message must name the provisioning script; the api path must exit 0; torch must be absent inside the image. Swept the workflow for the same shape — the only other pipelines in steps that survive the suite skip are `docker save | gzip` and `tar | ssh`, where a non-zero producer MUST fail the step (kept as-is, deliberately), and no surviving step touches the runner's pip environment (every `python` there runs inside `docker run "$img"`), so the skip cannot leave a half-provisioned environment. Proven locally without an engine: the pre-fix step bytes extracted from the YAML reproduce the failure (exit 2) against a stubbed docker whose refusal mirrors preflight's real text, and the post-fix bytes are green on the intended path and non-zero on three mutated stubs (message without the script name; local path exiting 0 anyway; torch present in the image). Local-Gate: ebec10c92d0a3f8f23b464d0743940bc3680df9b (1387 passed, 31s) --- .github/workflows/main.yml | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6490c2e..ebc5f9b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -229,29 +229,52 @@ jobs: docker build -f Containerfile -t localhost/hezarfen_rag:$GITHUB_SHA . # VARSAYILAN İMGE KÜÇÜK MÜ (kullanıcı kararı 2026-09-17): yerel yığın - # (torch/FlagEmbedding/ağırlıklar) İMAJA GİRMEZ; yerel yol bir EKLENTİ + # (torch/FlagEmbedding/ağırlıklar) İMAĞA GİRMEZ; yerel yol bir EKLENTİ # VOLUME'u ile açılır (deploy/provision_local_stack.sh). Bu iddialar # imajın kendisinde ölçülür (runner'da torch KURULU, yani runner'da # ölçmek yanıltıcı olurdu). + # Every assertion here is an EXIT CODE or a CAPTURED STRING, never a + # pipeline's status: a refusal is *supposed* to exit non-zero + # (src/service/preflight.py -> `return 2` / `SystemExit(2)`), so the old + # `docker run … 2>&1 | grep -q …` under `set -o pipefail` handed that 2 + # back as the STEP's own status and killed a check that had actually + # passed (job 35303767476, exit 2, with the expected line in the log). + # Capturing first keeps the two facts separable — the message is asserted + # on $local_out, the code on $local_rc. - name: Prove the default image is API-only and refuses `local` cleanly run: | set -euo pipefail img=localhost/hezarfen_rag:$GITHUB_SHA + # 1. torch must be ABSENT inside the image: `python -c` exits 1 when it + # is present, and that non-zero code IS the assertion. docker run --rm "$img" python -c "import importlib.util, sys; sys.exit(1 if importlib.util.find_spec('torch') else 0)" common=(--env RAG_ALLOW_UNCALIBRATED_ABSTAIN=1 --env LLM_API_KEY=ci) + + # 2. the shipped default (api) must come up green: exit 0 is the assertion. docker run --rm "${common[@]}" \ --env RAG_EMBED_PROVIDER=api --env RAG_EMBED_API_BASE=https://ornek/v1 \ --env RAG_EMBED_MODEL=m --env RAG_EMBED_API_KEY=k \ --env RAG_RERANK_PROVIDER=api --env RAG_RERANK_API_URL=https://ornek/rerank \ --env RAG_RERANK_MODEL=m --env RAG_RERANK_API_KEY=k \ "$img" python -m src.service.preflight - if docker run --rm "${common[@]}" --env RAG_EMBED_PROVIDER=local \ - --env RAG_RERANK_PROVIDER=local "$img" python -m src.service.preflight; then - echo "local secimi kucuk imgede GECMEMELIYDI" >&2; exit 1 + + # 3. `local` must REFUSE — asserted twice, and neither assertion can be + # fooled by the other: the code must be non-zero, the message must + # name the provisioning script. + local_env=(--env RAG_EMBED_PROVIDER=local --env RAG_RERANK_PROVIDER=local) + local_rc=0 + local_out=$(docker run --rm "${common[@]}" "${local_env[@]}" "$img" \ + python -m src.service.preflight 2>&1) || local_rc=$? + printf '%s\n' "$local_out" + if [ "$local_rc" -eq 0 ]; then + echo "local secimi kucuk imgede GECMEMELIYDI (exit 0)" >&2 + exit 1 + fi + if ! printf '%s\n' "$local_out" | grep -q 'provision_local_stack.sh'; then + echo "ret metni saglama betigini adiyla soylemiyor (exit $local_rc)" >&2 + exit 1 fi - docker run --rm "${common[@]}" --env RAG_EMBED_PROVIDER=local \ - --env RAG_RERANK_PROVIDER=local "$img" python -m src.service.preflight 2>&1 \ - | grep -q 'provision_local_stack.sh' + echo "kucuk imge dogrulandi: torch yok; api yolu yesil; local yolu exit $local_rc ile ret + ret metni saglama betigini adiyla soyluyor" - name: Stage the release bundle run: |