forge
Explore
Log in

Don't you dare go Hollow

Main.yml ile otomatik VPS dagitimi (push->main), bes katman korundu

Browse files at this commit

c146aa67438bed04c1d2c2d14dbd3c285133ecfeAhmet Kaan GümüşParent: 98b2423
  • ci
    • main.yml ile otomatik VPS dagitimi (push->main), bes katman korundu
Show full message
ci: main.yml ile otomatik VPS dagitimi (push->main), bes katman korundu

Katmanli CI aynen duruyor; push'ta main.yml icinde kosar ve deploy'u kapilar,
main disi dallar/PR'lar ci.yml'de kalir (ayni kapi iki kez kosmaz).
deploy/ altinda systemd unit'i ve sunucu env sablonu eklendi.
Bu sirada olcmeyen/kirik uc kapai duzeltildi: compose zorunlu sir listesi
(ZEKA_PG_DSN eksikti), sira bagimli HEZARFEN_NET probe'u ve ci-yerel.sh
katman 2'nin boru hattinda exit durumunu yutup yesil basmasi.
.github/workflows/ci.ymlmodified+28 -5
@@ -14,9 +14,22 @@
14 14
15 name: CI15 name: CI
16 16
17+# TETIKLEYICILER -- main push'u BURADA DEGIL `main.yml`'de kosar.
18+#
19+# Push'ta ayni kapi iki kez kosmasin diye main dali buradan DISLANIR:
20+#
21+# * `main` push'u -> `main.yml` (ayni bes katman + Build and test + Deploy);
22+# * diger dallara push ve TUM pull_request'ler -> burasi (asagidaki
23+# katmanlarin tamami);
24+# * elle kosum -> burasi.
25+#
26+# Katmanlar iki dosyada ayri ayri durur cunku `main.yml`'de her push'ta kosar
27+# ve deploy'u kapilar; burasi ise dala/PR'a hizli geri bildirim verir. Ikisinin
28+# komutlari AYNIDIR (tek dogruluk kaynagi: scripts/ci-yerel.sh); birini
29+# degistirirken digerini de degistirin.
17 on:30 on:
18 push:31 push:
19- branches: ["**"]32+ branches-ignore: ["main"]
20 pull_request:33 pull_request:
21 workflow_dispatch:34 workflow_dispatch:
22 35
@@ -152,19 +165,29 @@ jobs:
152 # Iki yonlu denetim: (1) zorunlu env YOKKEN `config` PATLAMALI,165 # Iki yonlu denetim: (1) zorunlu env YOKKEN `config` PATLAMALI,
153 # (2) VARKEN gecerli bir yapilandirma uretmeli. Yalnizca ikincisini166 # (2) VARKEN gecerli bir yapilandirma uretmeli. Yalnizca ikincisini
154 # denetlemek, `${VAR:?}` yerine `${VAR:-}` yazilmasini yakalamaz.167 # denetlemek, `${VAR:?}` yerine `${VAR:-}` yazilmasini yakalamaz.
168+ #
169+ # ZORUNLU SIRLAR LISTESI compose.yaml'IN KENDISINDEN OKUNUR: ucuncu
170+ # sir `ZEKA_PG_DSN` (compose.yaml:82) eklendiginde bu adim ve yerel
171+ # esdegeri `scripts/ci-compose.sh` iki sirla kalmis, adim "sirlar
172+ # verilse bile patliyor" diyerek KIRMIZI kalmisti. Liste artik tamdir;
173+ # compose.yaml'a sir eklerken burayi da guncelleyin (ve
174+ # scripts/ci-compose.sh'i; yerel esdeger AYNI kapi olmali).
155 working-directory: service175 working-directory: service
156 run: |176 run: |
157 echo "--- zorunlu env eksikken patlamali ---"177 echo "--- zorunlu env eksikken patlamali ---"
158- if docker compose config >/dev/null 2>&1; then178+ if env -u AI_SHARED_TOKEN -u DEEPSEEK_API_KEY -u ZEKA_PG_DSN \
159- echo "HATA: AI_SHARED_TOKEN/DEEPSEEK_API_KEY olmadan gecti;"179+ docker compose config >/dev/null 2>&1; then
180+ echo "HATA: zorunlu sirlar olmadan gecti;"
160 echo " zorunlu sirlar \${VAR:?} bicimini kaybetmis olabilir."181 echo " zorunlu sirlar \${VAR:?} bicimini kaybetmis olabilir."
161 exit 1182 exit 1
162 fi183 fi
163 echo "ok: zorunlu env olmadan reddedildi"184 echo "ok: zorunlu env olmadan reddedildi"
164 echo "--- zorunlu env varken gecerli olmali ---"185 echo "--- zorunlu env varken gecerli olmali ---"
165- AI_SHARED_TOKEN=ci-sahte DEEPSEEK_API_KEY=ci-sahte docker compose config186+ AI_SHARED_TOKEN=ci-sahte DEEPSEEK_API_KEY=ci-sahte \
187+ ZEKA_PG_DSN=postgres://ci:ci@127.0.0.1:5432/ci docker compose config
166 echo "--- port ACILMAMALI (disa arama servisi) ---"188 echo "--- port ACILMAMALI (disa arama servisi) ---"
167- if AI_SHARED_TOKEN=ci-sahte DEEPSEEK_API_KEY=ci-sahte docker compose config \189+ if AI_SHARED_TOKEN=ci-sahte DEEPSEEK_API_KEY=ci-sahte \
190+ ZEKA_PG_DSN=postgres://ci:ci@127.0.0.1:5432/ci docker compose config \
168 | grep -qE '^\s+ports:'; then191 | grep -qE '^\s+ports:'; then
169 echo "HATA: compose port aciyor; ZEKA backend'e dial-out eder, port ACMAZ."192 echo "HATA: compose port aciyor; ZEKA backend'e dial-out eder, port ACMAZ."
170 exit 1193 exit 1
.github/workflows/main.ymladded+611 -0
@@ -0,0 +1,611 @@
1+# VPS deploy -- ZEKA kopru servisi. Sekil, ailedeki Celebi/RAG deploy'uyla
2+# AYNI (hata toparlama ucuz olsun):
3+#
4+# Katman 1..5 -- ci.yml'deki BES katmanin KENDISI; push'ta burada kosar.
5+# Komutlar oradakiyle birebir aynidir (tek dogruluk
6+# kaynagi: scripts/ci-yerel.sh).
7+# Build and test -- bes katman yesilse imaji derler ve kosunun artefaktini
8+# (imaj tarball'i + compose.yaml + systemd unit'i + tag)
9+# yukler. Ad BILEREK "Build and test": workflow_dispatch
10+# yolu en yeni yesil kosuyu tam bu ISIN ADIYLA arar
11+# (`gh run view ... select(.name=="Build and test")`).
12+# Deploy -- SSH: kapasite on kontrolu, imaji yukle, deploy sahipli
13+# stack.env'in HEZARFEN_TAG'ini ona cevir, compose.yaml +
14+# unit'i kur, stack'i yeniden baslat, servisin KENDI
15+# saglik betigiyle dogrula, olmazsa onceki tag'e don,
16+# ardindan bagimsiz dogrulama.
17+#
18+# KATMANLAR NEDEN AYRI ISLER -- gerekce ci.yml'in basindan aynen:
19+# "Katmanlar bilincli olarak AYRI islerdir, tek bir dev is degil: bir kosucu
20+# konteyner derleyemiyorsa testler yine de kosar, ve sozlesme denetimi
21+# kirildiginda 'testler gecti ama sozlesme kaldi' bilgisi tek bakista
22+# gorunur."
23+# Push'ta ayni kapi IKI KEZ kosmasin diye ci.yml'in push tetikleyicisi main
24+# dalini DISLAR (bkz. ci.yml `on:`): main push'u boylece tam olarak bir kez
25+# kosar; diger dallar ve PR'lar katmanlari ci.yml'den alir.
26+#
27+# YESIL BIR MAIN PUSH'U OTOMATIK DAGITIR (Celebi'nin sekli; RAG'da dagitim
28+# bilerek elleydi cunku orada ~4,5 GB model ve GPU'suz makinede gecmeyen bir
29+# urun kapisi var -- ZEKA hafif bir koprudur, o gerekce burada yok).
30+#
31+# Elle yeniden dagitim -- Actions -> Run workflow, ya da:
32+# gh workflow run main.yml --ref main
33+# Bu yol suiti TEKRAR kosmaz: "Build and test" isi yesil olan en yeni kosunun
34+# artefaktini dagitir (asagidaki "Find the newest green build" adimi).
35+#
36+# Bir seferlik on kosullar (workflow'un erisimi disinda):
37+# * repo secret'lari SSH_PRIVATE_KEY / SSH_HOST / SSH_USER -- backend ve
38+# frontend deploy'unun kullandigi uc isim;
39+# * sunucuda `loginctl enable-linger <user>` (kullanici unit'leri icin);
40+# * sunucuda podman + bir compose saglayici (deploy ikisini de kontrol eder);
41+# * operatorun ~/hezarfen_zeka/hezarfen_zeka.env dosyasi (0600; sablon:
42+# deploy/hezarfen_zeka.env.example). Deploy onu ASLA olusturmaz, yazmaz;
43+# yalniz varligini kontrol eder ve iznini 0600'e ceker;
44+# * backend tarafi acik olmali: hezarfen_backend.env icinde
45+# AI_QUIC_ADDR=0.0.0.0:8090 ve AI_SHARED_TOKEN bu koprununkiyle AYNI.
46+# Bu bir KAPI DEGILDIR -- asagida gerekcesiyle yazilidir.
47+
48+name: VPS deploy
49+
50+on:
51+ push:
52+ branches:
53+ - main
54+ # Elle yeniden deploy kapisi -- yukaridaki baslik yorumuna bakin.
55+ workflow_dispatch:
56+
57+# Deploy serilestirmesi workflow'da degil deploy isinde: yeni bir push, ucustaki
58+# VPS degisimine dokunmadan bayat katman/Build kosularini iptal edebilmeli.
59+permissions:
60+ contents: read
61+ # workflow_dispatch yolu `gh run list/view` ile en yeni yesil kosuyu arar ve o
62+ # kosunun artefaktini indirir; ikisi de Actions API'sidir ve YAZMA GEREKMEZ.
63+ actions: read
64+
65+env:
66+ # systemd kullanici unit'i. Bkz. deploy/hezarfen_zeka_compose.service.
67+ SERVICE: hezarfen_zeka_compose
68+ # Deploy, SSH kullanicisinin home'u altindaki bu alt dizinde yasar ($HOME
69+ # sunucuda cozulur).
70+ DEPLOY_SUBDIR: hezarfen_zeka
71+ # Operatorun ayar dosyasi; deploy yalniz varligini kontrol eder, yazmaz.
72+ ENV_FILE_NAME: hezarfen_zeka.env
73+ # compose.yaml'daki `container_name` (bkz. service/compose.yaml:11).
74+ CONTAINER_NAME: hezarfen-zeka-bridge
75+ # Saglik kapisinin on kosulu: backend'in HTTP sertifika ucu. Backend'in host
76+ # loopback portu (README: `127.0.0.1:7656:7656`).
77+ CERT_PATH: /ai/certificate
78+ BACKEND_HTTP_PORT: "7656"
79+
80+jobs:
81+ # =========================================================================
82+ # KATMAN 1..5 -- ci.yml'deki bes katman. Adlar, adim metinleri ve komutlar
83+ # oradan BIREBIR tasindi; burada degisen tek sey `if` ve `concurrency`:
84+ # dispatch bu suiti tekrar odemez (bkz. dosya basi).
85+ # =========================================================================
86+ sozdizimi:
87+ name: "Katman 1 -- sozdizimi (her .py ayristirilabiliyor mu)"
88+ if: github.event_name == 'push'
89+ concurrency:
90+ group: ci-${{ github.workflow }}-${{ github.ref }}-sozdizimi
91+ cancel-in-progress: true
92+ runs-on: ubuntu-latest
93+ steps:
94+ - uses: actions/checkout@v4
95+ - uses: actions/setup-python@v5
96+ with:
97+ python-version: "3.13"
98+ - name: "Butun kaynaklar ayristirilabiliyor mu"
99+ # Testlerden ONCE kosar: bozuk bir dosya, testlerin toplanmasini
100+ # engelleyip anlamsiz bir toplama hatasi uretir. Burada hangi dosya
101+ # ve hangi satir oldugu tek satirda gorunur.
102+ run: |
103+ python -m compileall -q -x '(__pycache__|\.venv|venv)' \
104+ service/src service/tests scripts
105+
106+ # =========================================================================
107+ testler:
108+ name: "Katman 2 -- birim testleri (saf unittest, bagimliliksiz)"
109+ if: github.event_name == 'push'
110+ concurrency:
111+ group: ci-${{ github.workflow }}-${{ github.ref }}-testler
112+ cancel-in-progress: true
113+ runs-on: ubuntu-latest
114+ steps:
115+ - uses: actions/checkout@v4
116+ - uses: actions/setup-python@v5
117+ with:
118+ python-version: "3.13"
119+ - name: "python -m unittest discover"
120+ # BAGIMLILIK KURULMAZ. Bu kasitli: test paketi saf `unittest`
121+ # kullanir ve `requirements.txt` gerektirmez. Boylece bu is,
122+ # bagimlilik cozumleme sorunlarindan BAGIMSIZ olarak kirmizi/yesil
123+ # bilgisi verir; ag kesintisi testleri dusuremez.
124+ #
125+ # `aioquic` gerektiren canli kopru testleri kendiliginden ATLANIR
126+ # (tests/test_bridge_live.py basindaki SkipTest). Onlari acikca
127+ # kosturan is ayri dosyada: `istege-bagli-testler.yml`.
128+ working-directory: service
129+ run: python -m unittest discover -s tests -t . -v
130+
131+ # =========================================================================
132+ sozlesme:
133+ name: "Katman 3 -- sozlesme (model<->fiyat, yol<->izin listesi)"
134+ if: github.event_name == 'push'
135+ concurrency:
136+ group: ci-${{ github.workflow }}-${{ github.ref }}-sozlesme
137+ cancel-in-progress: true
138+ runs-on: ubuntu-latest
139+ steps:
140+ - uses: actions/checkout@v4
141+ - uses: actions/setup-python@v5
142+ with:
143+ python-version: "3.13"
144+ - name: "Sozlesme denetimi"
145+ # BU DENETIM BU PROJEDE IKI KEZ SESSIZ KUSUR YAKALARDI:
146+ #
147+ # 1. Model adi uyusmazligi. `cost_usd()` bilinmeyen bir model adi
148+ # gorunce hata vermez, sessizce EN PAHALI tarifeye duser
149+ # (provider.py:124-125). Butce raporu yanlis cikar, hicbir test
150+ # kirilmaz.
151+ #
152+ # 2. Izin listesi sapmasi. `protocol.py:AI_API_ALLOWLIST`,
153+ # backend'in `constant.rs:656-676` listesinin ELLE tutulan
154+ # kopyasidir. Ayristiklarinda cagri `path_not_allowed` ile tele
155+ # cikmadan reddedilir; testler de ayni kopyayi dogruladigi icin
156+ # yesil kalir.
157+ #
158+ # NOT: GitHub kosucusunda backend deposu YOKTUR, bu yuzden gercek
159+ # `constant.rs` karsilastirmasi burada ATLANIR ve betik bunu bir
160+ # "not" olarak basar (hata degil). Depo ici pinli anlik goruntuye
161+ # (tests/test_protocol.py:BACKEND_SNAPSHOT) karsi denetim yine kosar.
162+ # Gercek karsilastirma yerelde yapilir:
163+ # HEZARFEN_BACKEND=/yol/hezarfen_backend-main python scripts/ci-sozlesme.py
164+ run: python scripts/ci-sozlesme.py
165+
166+ # =========================================================================
167+ sirlar:
168+ name: "Katman 4 -- sir taramasi (sizmis API anahtari)"
169+ if: github.event_name == 'push'
170+ concurrency:
171+ group: ci-${{ github.workflow }}-${{ github.ref }}-sirlar
172+ cancel-in-progress: true
173+ runs-on: ubuntu-latest
174+ steps:
175+ - uses: actions/checkout@v4
176+ - uses: actions/setup-python@v5
177+ with:
178+ python-version: "3.13"
179+ - name: "Sir taramasi"
180+ # `.env` `.gitignore` icinde, ama bu yalnizca YENI dosyalari korur:
181+ # `git add -f` ile ya da `.gitignore`'dan once eklenmis bir dosya
182+ # izlenmeye devam eder. Tarayici `sk-` / `sk_` desenlerini, ozel
183+ # anahtar govdelerini ve yapilandirma dosyalarina gomulmus duz
184+ # degerleri arar; ayrica compose'daki zorunlu sirlarin `${VAR:?}`
185+ # bicimini korudugunu dogrular.
186+ #
187+ # Bulunan deger ASLA tam basilmaz -- yoksa CI kaydinin kendisi sir
188+ # sizdiran yer olurdu.
189+ run: python scripts/ci-sir-tara.py
190+
191+ # =========================================================================
192+ konteyner:
193+ name: "Katman 5 -- konteyner (derleniyor VE kosuyor mu)"
194+ if: github.event_name == 'push'
195+ concurrency:
196+ group: ci-${{ github.workflow }}-${{ github.ref }}-konteyner
197+ cancel-in-progress: true
198+ runs-on: ubuntu-latest
199+ steps:
200+ - uses: actions/checkout@v4
201+
202+ - name: "Imaji derle"
203+ # Taban imaj digest'e pinlidir (Containerfile:15); bu is ayni zamanda
204+ # o digest'in hala cekilebildigini de dogrular.
205+ working-directory: service
206+ run: podman build -t hezarfen-zeka:ci -f Containerfile .
207+
208+ - name: "Imaj boyutu"
209+ run: podman images --format '{{.Repository}}:{{.Tag}} {{.Size}}' hezarfen-zeka:ci
210+
211+ - name: "Kosu kaniti -- kap cikmiyor, non-root, saglik kontrolu olcuyor"
212+ # DERLENDI, KOSTU DEMEK DEGILDIR. Denetimde kardes servis RAG'in
213+ # konteynerinin hic ayaga kalkmadigi bulundu: komut bir metin basip
214+ # cikiyor ve `restart: unless-stopped` ile sonsuz crash-loop
215+ # uretiyordu. Bu adim farki olcer:
216+ # - kap 50 sn sonra hala kosuyor mu,
217+ # - backend YOKKEN cikmak yerine USTEL geri cekilmeyle yeniden
218+ # deniyor mu (bekleme suresi buyuyor mu),
219+ # - surec non-root mu (uid 10002),
220+ # - saglik kontrolu kopru yasarken geciyor VE kopru yokken
221+ # kaliyor mu (her zaman 0 donen bir kontrol hicbir sey kanitlamaz).
222+ run: bash scripts/ci-konteyner-kanit.sh podman hezarfen-zeka:ci
223+
224+ - name: "compose.yaml gecerli mi ve zorunlu sirlar zorunlu mu"
225+ # Iki yonlu denetim: (1) zorunlu env YOKKEN `config` PATLAMALI,
226+ # (2) VARKEN gecerli bir yapilandirma uretmeli. Yalnizca ikincisini
227+ # denetlemek, `${VAR:?}` yerine `${VAR:-}` yazilmasini yakalamaz.
228+ #
229+ # ZORUNLU SIRLAR LISTESI compose.yaml'IN KENDISINDEN OKUNUR: ucuncu
230+ # sir `ZEKA_PG_DSN` (compose.yaml:82) eklendiginde bu adim ve yerel
231+ # esdegeri `scripts/ci-compose.sh` iki sirla kalmis, adim "sirlar
232+ # verilse bile patliyor" diyerek KIRMIZI kalmisti. Liste artik tamdir;
233+ # compose.yaml'a sir eklerken burayi da guncelleyin (ve
234+ # scripts/ci-compose.sh'i; yerel esdeger AYNI kapi olmali).
235+ working-directory: service
236+ run: |
237+ echo "--- zorunlu env eksikken patlamali ---"
238+ if env -u AI_SHARED_TOKEN -u DEEPSEEK_API_KEY -u ZEKA_PG_DSN \
239+ docker compose config >/dev/null 2>&1; then
240+ echo "HATA: zorunlu sirlar olmadan gecti;"
241+ echo " zorunlu sirlar \${VAR:?} bicimini kaybetmis olabilir."
242+ exit 1
243+ fi
244+ echo "ok: zorunlu env olmadan reddedildi"
245+ echo "--- zorunlu env varken gecerli olmali ---"
246+ AI_SHARED_TOKEN=ci-sahte DEEPSEEK_API_KEY=ci-sahte \
247+ ZEKA_PG_DSN=postgres://ci:ci@127.0.0.1:5432/ci docker compose config
248+ echo "--- port ACILMAMALI (disa arama servisi) ---"
249+ if AI_SHARED_TOKEN=ci-sahte DEEPSEEK_API_KEY=ci-sahte \
250+ ZEKA_PG_DSN=postgres://ci:ci@127.0.0.1:5432/ci docker compose config \
251+ | grep -qE '^\s+ports:'; then
252+ echo "HATA: compose port aciyor; ZEKA backend'e dial-out eder, port ACMAZ."
253+ exit 1
254+ fi
255+ echo "ok: hicbir port yayimlanmiyor"
256+
257+ # =========================================================================
258+ build:
259+ name: Build and test
260+ # Push'ta kosar. Dispatch, suiti tekrar odemek yerine en yeni yesil
261+ # artefakti kullanir (bkz. deploy'un "Find the newest green build" adimi).
262+ if: github.event_name == 'push'
263+ # BES KATMANIN HEPSI yesil olmadan artefakt uretilmez: bozuk bir build
264+ # sunucuya ASLA ulasmamali. Suiti burada TEKRAR kosmuyoruz -- `needs:`
265+ # zinciri Katman 2'yi zaten sart kostu; bu isin ekledigi sey, ayni agactan
266+ # uretilen SURUM paketidir.
267+ needs: [sozdizimi, testler, sozlesme, sirlar, konteyner]
268+ concurrency:
269+ group: ci-${{ github.workflow }}-${{ github.ref }}-build
270+ cancel-in-progress: true
271+ runs-on: ubuntu-24.04
272+ steps:
273+ - name: Checkout
274+ uses: actions/checkout@v4
275+
276+ - name: Build the image
277+ # Laptop ve CI ayni Containerfile'i kullanir: ayri bir CI ikizi yok.
278+ # Baglam `service/` -- Containerfile oradadir.
279+ working-directory: service
280+ run: |
281+ set -euo pipefail
282+ podman build -t localhost/hezarfen-zeka:$GITHUB_SHA -f Containerfile .
283+
284+ - name: Stage the release bundle
285+ # Sunucuda kurulacak her sey burada olmali; eksik parca burada,
286+ # sunucuda degil, patlar.
287+ run: |
288+ set -euo pipefail
289+ mkdir -p stage
290+ podman save localhost/hezarfen-zeka:$GITHUB_SHA | gzip > stage/hezarfen_zeka.tar.gz
291+ cp service/compose.yaml stage/compose.yaml
292+ cp deploy/hezarfen_zeka_compose.service stage/
293+ echo -n "$GITHUB_SHA" > stage/tag
294+ test -f stage/hezarfen_zeka.tar.gz
295+ test -f stage/compose.yaml
296+ test -f stage/hezarfen_zeka_compose.service
297+ test -f stage/tag
298+ ls -lh stage
299+
300+ # Deploy isi (ve elle yeniden deploy) bunu tuketir. 30 gun, dispatch
301+ # kapisinin geri uzanma penceresidir.
302+ - name: Upload the release
303+ uses: actions/upload-artifact@v4
304+ with:
305+ name: release
306+ path: stage
307+ retention-days: 30
308+
309+ # =========================================================================
310+ deploy:
311+ name: Deploy
312+ # Zincirin tamami kapi olur: build'in `needs` listesi bes katmani kapsar,
313+ # yani `needs: [build]` "bes katman + imaj yesil" demektir.
314+ needs: [build]
315+ concurrency:
316+ group: deploy
317+ cancel-in-progress: false
318+ # Push: yalniz Build and test yesilse. Dispatch: iki CI isi bilerek
319+ # atlanir (if'lerine bakin) ve `always()` bu atlamanin bu kapidan
320+ # gecmesini saglar.
321+ if: >-
322+ always() &&
323+ ((github.event_name == 'push' && needs.build.result == 'success') ||
324+ (github.event_name == 'workflow_dispatch' && needs.build.result == 'skipped'))
325+ runs-on: ubuntu-24.04
326+ steps:
327+ # Push deploy'u bu kosunun urettigi ve kapiladigi surumu alir.
328+ - name: Fetch this run's release
329+ if: github.event_name == 'push'
330+ uses: actions/download-artifact@v4
331+ with:
332+ name: release
333+ path: stage
334+
335+ # Elle yeniden deploy, BUILD isi yesil olan en yeni kosuyu alir -- en
336+ # yeni tamamen yesil kosuyu degil: bir kosu saglik kapisinda dusmus
337+ # olabilir ama build'i tam da geri almak istedigimiz surumdur.
338+ - name: Find the newest green build
339+ if: github.event_name == 'workflow_dispatch'
340+ env:
341+ GH_TOKEN: ${{ github.token }}
342+ run: |
343+ set -euo pipefail
344+ run_id=""
345+ for rid in $(gh run list --workflow main.yml --branch main --event push --limit 15 --json databaseId --jq '.[].databaseId'); do
346+ if [ "$(gh run view "$rid" --json jobs --jq '.jobs[] | select(.name=="Build and test") | .conclusion')" = "success" ]; then
347+ run_id=$rid
348+ break
349+ fi
350+ done
351+ if [ -z "$run_id" ]; then
352+ echo 'no run on main has a green Build-and-test job (or its artifact has expired)' >&2
353+ exit 1
354+ fi
355+ echo "redeploying the release from run $run_id"
356+ echo "run_id=$run_id" >> "$GITHUB_ENV"
357+
358+ - name: Fetch the green release
359+ if: github.event_name == 'workflow_dispatch'
360+ uses: actions/download-artifact@v4
361+ with:
362+ name: release
363+ path: stage
364+ run-id: ${{ env.run_id }}
365+ github-token: ${{ github.token }}
366+
367+ # Dispatch yolu gunler oncesine ait bir artefakt indirebilir; sunucuya
368+ # dokunmadan once paketin butun oldugunu yeniden kontrol et.
369+ - name: Check the release is complete
370+ run: |
371+ set -euo pipefail
372+ test -f stage/hezarfen_zeka.tar.gz
373+ test -f stage/compose.yaml
374+ test -f stage/hezarfen_zeka_compose.service
375+ test -f stage/tag
376+
377+ - name: Install SSH keys
378+ run: |
379+ mkdir -p ~/.ssh
380+ echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa
381+ ssh-keyscan -H ${{ secrets.SSH_HOST }} > ~/.ssh/known_hosts
382+
383+ - name: Upload the release
384+ run: |
385+ set -euo pipefail
386+ ssh_target="${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}"
387+
388+ # Sunucunun login shell'i bash degil, ssh bu betigi ona verirdi;
389+ # `bash -s` betigi stdin'den alir, login shell yalniz tek duz komut
390+ # gorur.
391+ ssh "$ssh_target" "bash -se -- '$DEPLOY_SUBDIR'" <<'REMOTE'
392+ set -euo pipefail
393+ case "$1" in
394+ ''|/*|*..*)
395+ echo "Refusing a broad deploy subdirectory: '$1'" >&2
396+ exit 1
397+ ;;
398+ esac
399+ deploy_path=$HOME/$1
400+ # Bu dizin operatorun hezarfen_zeka.env dosyasini, compose
401+ # dosyalarini ve tag dosyalarini tutar; hicbiri toptan silinmez.
402+ mkdir -p -- "$deploy_path"
403+ REMOTE
404+ # stdin paketi tasiyor, betik tasiyamaz; cikarma yine bash -c ile
405+ # cunku login shell bash degil ve $HOME'u genisletmez. Sunucuya
406+ # yalnizca dort deploy dosyasi kurulur.
407+ tar -C stage -czf - hezarfen_zeka.tar.gz compose.yaml hezarfen_zeka_compose.service tag | ssh "$ssh_target" "bash -c 'exec tar -xzf - -C \"\$HOME/\$1\"' -- '$DEPLOY_SUBDIR'"
408+
409+ - name: Load the image and restart the bridge
410+ run: |
411+ set -euo pipefail
412+ ssh_target="${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}"
413+
414+ # bash -s, yukaridakiyle ayni sebeple: login shell bu betigi asla
415+ # gormemeli.
416+ ssh "$ssh_target" "bash -se -- '$DEPLOY_SUBDIR' '$SERVICE' '$ENV_FILE_NAME' '$CONTAINER_NAME' '$CERT_PATH' '$BACKEND_HTTP_PORT'" <<'REMOTE'
417+ set -euo pipefail
418+ deploy_path=$HOME/$1
419+ service=$2
420+ env_file=$deploy_path/$3
421+ container=$4
422+ cert_path=$5
423+ backend_http_port=$6
424+ export XDG_RUNTIME_DIR=/run/user/$(id -u)
425+ # compose.yaml calisma dizininden cozulur: unit'in ExecStart'i
426+ # WorkingDirectory tasir ama rollback'in compose up'i ve ilk
427+ # deploy'un down'i tam buradan kosar.
428+ cd -- "$deploy_path"
429+
430+ # Hicbir sey oynamadan once oku: ayar dosyasi operatorun, sunucuda,
431+ # elle bir kez yazilir (anahtarlar icin bkz.
432+ # deploy/hezarfen_zeka.env.example). Deploy onu ASLA olusturmaz,
433+ # ezmez.
434+ if [ ! -f "$env_file" ]; then
435+ echo "missing $env_file -- create it (0600) from deploy/hezarfen_zeka.env.example" >&2
436+ exit 1
437+ fi
438+ chmod 0600 -- "$env_file"
439+
440+ # KAPASITE ON KONTROLU -- aile deseni (RAG'in ayni adimi 12 GB / 20 GB
441+ # esikleri kullaniyor; orada ~4,5 GB model + birkac GB RSS var ve
442+ # GPU'suz makinede urun kapisi gecmiyor). ZEKA hafiftir: olculen imaj
443+ # 152 MB (docs/DAGITIM.md), calisma zamani tek bir Python sureci,
444+ # model yok. Esikler bu yuzden olculenin ~10 katidir: pay birakip
445+ # gereksiz reddetmemek icin. Yetersizse OOM ile canli stack'i
446+ # dusurmek yerine burada, NEDENIYLE reddedilir.
447+ avail_mb=$(awk '/MemAvailable/ {print int($2/1024)}' /proc/meminfo)
448+ disk_gb=$(df -BG --output=avail "$deploy_path" | tail -1 | tr -dc '0-9')
449+ if [ "$avail_mb" -lt 512 ] || [ "$disk_gb" -lt 2 ]; then
450+ echo "refusing to deploy: ${avail_mb} MB RAM available (need >= 512) and ${disk_gb} GB disk (need >= 2)." >&2
451+ echo 'ZEKA is light (152 MB image, one Python process, no models) but a host without headroom will not get it; free space or deploy elsewhere.' >&2
452+ exit 1
453+ fi
454+
455+ # Rootless podman + compose saglayici; uc adim sonra ciplak
456+ # command-not-found yerine cozumu soyle.
457+ command -v podman >/dev/null || {
458+ echo "podman not found -- install podman and a compose provider (e.g. dnf install podman podman-compose)" >&2
459+ exit 1
460+ }
461+ podman compose version >/dev/null 2>&1 || {
462+ echo "'podman compose' unavailable -- install a compose provider (podman-compose or docker-compose)" >&2
463+ exit 1
464+ }
465+
466+ # ON KOSUL, KAPI DEGIL: backend'in kopru dinleyicisi acik mi
467+ # (AI_QUIC_ADDR=0.0.0.0:8090) -- sertifika ucu bunun kanitidir.
468+ # Celebi bunu KAPI yapar; ZEKA'da bilerek UYARIDIR, cunku kopru
469+ # backend yokken CIKMAZ: ustel geri cekilmeyle bekler ve backend
470+ # duzeltilince kendiliginden kaydolur
471+ # (src/bridge.py::run_forever, docs/DAGITIM.md "Servis ne yapar").
472+ # Backend bakimda diye ZEKA'nin dagitimini reddetmek, servisin kendi
473+ # sozlesmesinden DAHA SIKI bir sart koymak olurdu -- yani urunun
474+ # tanimadigi bir "kayit" kapisi.
475+ served_cert=$(curl -fsS "http://127.0.0.1:${backend_http_port}${cert_path}" 2>/dev/null) || true
476+ case "$served_cert" in
477+ *certificate_pem*) echo "ok: backend sertifikayi sunuyor (kopru kayit olabilir)" ;;
478+ *)
479+ echo "UYARI: backend ${cert_path} sertifika dondurmedi -- AI koprusu kapali olabilir (hezarfen_backend.env icinde AI_QUIC_ADDR=0.0.0.0:8090). Kopru baglanana kadar bekleyecek; bu TASARIM GEREGI bir bekleme halidir, ariza degil." >&2
480+ ;;
481+ esac
482+
483+ # BU build'in imajini yukle ve build'in damgaladigi tag'i oku
484+ # (build zamani ile deploy zamani neyin gittiginde anlasmali).
485+ gunzip -c "$deploy_path/hezarfen_zeka.tar.gz" | podman load
486+ tag=$(cat -- "$deploy_path/tag")
487+
488+ # Tag rotasyonu: previous_tag geri donus hedefidir (ilk deploy'da
489+ # yok); current_tag su an calismasi gerekeni kaydeder.
490+ if [ -f "$deploy_path/current_tag" ]; then
491+ cp -- "$deploy_path/current_tag" "$deploy_path/previous_tag"
492+ fi
493+ printf '%s\n' "$tag" > "$deploy_path/current_tag"
494+
495+ # stack.env deploy sahipli (operatorun ayar dosyasindan farkli):
496+ # yalniz imaj tag'ini tasir ve --env-file sirasi HEZARFEN_TAG'de onu
497+ # kazanan yapar (compose.yaml: `localhost/hezarfen-zeka:${HEZARFEN_TAG:-current}`).
498+ printf 'HEZARFEN_TAG=%s\n' "$tag" > "$deploy_path/stack.env"
499+
500+ chmod 0644 -- "$deploy_path/compose.yaml" "$deploy_path/hezarfen_zeka_compose.service"
501+ # Imaj tarball'i yalniz tasiyiciydi; imaj artik podman deposunda.
502+ rm -f -- "$deploy_path/hezarfen_zeka.tar.gz"
503+
504+ compose_up() {
505+ podman compose --env-file "$env_file" --env-file "$deploy_path/stack.env" up -d --no-build
506+ }
507+ rollback() {
508+ if [ -f "$deploy_path/previous_tag" ]; then
509+ prev=$(cat -- "$deploy_path/previous_tag")
510+ printf 'HEZARFEN_TAG=%s\n' "$prev" > "$deploy_path/stack.env"
511+ printf '%s\n' "$prev" > "$deploy_path/current_tag"
512+ compose_up
513+ echo "rolled back to $prev" >&2
514+ else
515+ # Ilk deploy: geri donulecek bir sey yok, yari ayakta stack'i
516+ # durdur. Duz down -- `-v` YOK: zeka-fixtures isimli volume
517+ # stop'ta yasamali.
518+ podman compose --env-file "$env_file" --env-file "$deploy_path/stack.env" down
519+ echo 'first deploy failed; stack stopped, volumes kept' >&2
520+ fi
521+ }
522+
523+ # Unit surumuyle birlikte gelir: yeni kurulmus bir kutuda ilk
524+ # deploy'a kadar unit yoktur ve degisen unit onu gerektiren compose
525+ # ile iner.
526+ mkdir -p -- "$HOME/.config/systemd/user"
527+ install -m 0644 -- "$deploy_path/hezarfen_zeka_compose.service" "$HOME/.config/systemd/user/$service.service"
528+ systemctl --user daemon-reload
529+
530+ # Unit RemainAfterExit'li bir oneshot: aktif (exited) unit'te `start`
531+ # no-op olurdu -- her deploy ExecStart'i yeniden kosmak icin restart
532+ # eder. Dusen bir restart (kotu interpolasyon, saglayici aksakligi)
533+ # yine de asagidaki saglik kapisina ulasmali: karari o verir.
534+ systemctl --user enable -- "$service"
535+ systemctl --user restart "$service" || true
536+
537+ # SAGLIK KAPISI -- SERVISIN KENDI betigi. `scripts/saglik.py`
538+ # konteynerde her 30 saniyede kosan kontrolun TA KENDISIDIR; portu
539+ # olmayan bir serviste disaridan yoklanacak bir ucu yoktur.
540+ #
541+ # NE ARAR: kopru surecinin YASADIGINI (zombi degil). NE ARAMAZ:
542+ # backend'e KAYITLI oldugunu -- bu KASITLIDIR ve compose.yaml'daki
543+ # `healthcheck` blogunun gerekcesidir: hazir olma sarti aransaydi
544+ # backend'in her yeniden dagitimi ZEKA'yi `unhealthy` isaretler ve
545+ # restart politikasi kacinmaya calistigimiz crash-loop'u geri
546+ # getirirdi. Deploy da bir kayit kapisi UYDURMAZ; uyduracagi kapi
547+ # servisin kendi tanimindan daha siki olurdu.
548+ #
549+ # 60 deneme: yorumlayici + aioquic import'u ve kap acilisi icin
550+ # comert.
551+ ready_ok=0
552+ for _ in $(seq 1 60); do
553+ if podman exec "$container" python scripts/saglik.py >/dev/null 2>&1; then
554+ ready_ok=1
555+ break
556+ fi
557+ sleep 1
558+ done
559+ if [ "$ready_ok" -ne 1 ]; then
560+ echo "the health script never passed ('src.bridge' process is not alive); rolling back" >&2
561+ podman logs --tail 30 "$container" >&2 || true
562+ rollback
563+ exit 1
564+ fi
565+
566+ # Eski bir stack de saglikli olabilir; calisan konteyner BU build'in
567+ # imaji olmali, yoksa geri donulur.
568+ image=$(podman inspect -f '{{.Config.Image}}' "$container")
569+ case "$image" in
570+ *"$tag"*) ;;
571+ *)
572+ echo "the health gate passed, but the container runs '$image' -- not this build ($tag); rolling back" >&2
573+ rollback
574+ exit 1
575+ ;;
576+ esac
577+ echo 'hezarfen_zeka_compose is up'
578+ REMOTE
579+
580+ # Bagimsiz son kontrol: cevap veren konteyner hala guncel tag'in olmali
581+ # ve kopru yasiyor olmali -- servisin KENDI saglik betigiyle, yeniden.
582+ - name: Verify the bridge is alive
583+ run: |
584+ set -euo pipefail
585+ ssh_target="${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}"
586+ ssh "$ssh_target" "bash -se -- '$DEPLOY_SUBDIR' '$CONTAINER_NAME'" <<'REMOTE'
587+ set -euo pipefail
588+ deploy_path=$HOME/$1
589+ container=$2
590+ export XDG_RUNTIME_DIR=/run/user/$(id -u)
591+ cd -- "$deploy_path"
592+ tag=$(cat -- "$deploy_path/current_tag")
593+ image=$(podman inspect -f '{{.Config.Image}}' "$container")
594+ case "$image" in
595+ *"$tag"*) ;;
596+ *)
597+ echo "container runs '$image', not the current tag '$tag'" >&2
598+ exit 1
599+ ;;
600+ esac
601+ status=$(podman inspect -f '{{.State.Status}}' "$container")
602+ [ "$status" = "running" ] || { echo "container status is '$status', not running" >&2; exit 1; }
603+ podman exec "$container" python scripts/saglik.py || {
604+ echo "the bridge process is not alive (scripts/saglik.py failed)" >&2
605+ exit 1
606+ }
607+ echo 'bridge alive, container is this build'
608+ REMOTE
609+
610+ - name: Cleaning
611+ run: rm -rf ~/.ssh
Makefilemodified+1 -1
@@ -61,7 +61,7 @@ compose: ## compose.yaml gecerli mi; zorunlu sirlar zorunlu mu; port acik mi
61 61
62 # --- gunluk kullanim -------------------------------------------------------62 # --- gunluk kullanim -------------------------------------------------------
63 63
64-kos: ## Servisi compose ile kaldir (zorunlu: AI_SHARED_TOKEN, DEEPSEEK_API_KEY)64+kos: ## Servisi compose ile kaldir (zorunlu: AI_SHARED_TOKEN, ZEKA_PG_DSN, DEEPSEEK_API_KEY)
65 cd service && $(MOTOR) compose up -d65 cd service && $(MOTOR) compose up -d
66 66
67 loglar: ## Servis gunluklerini izle67 loglar: ## Servis gunluklerini izle
README.mdmodified+61 -0
@@ -297,3 +297,64 @@ günler sonra boş bir tablo yerine.
297 297
298 DSN hiçbir yerde loglanmaz; `pg_client._describe()` yalnız host/port/veritabanı298 DSN hiçbir yerde loglanmaz; `pg_client._describe()` yalnız host/port/veritabanı
299 döndürür, kullanıcı adı ve parola asla.299 döndürür, kullanıcı adı ve parola asla.
300+
301+---
302+
303+## 11. Dağıtım — VPS, yeşil push'ta otomatik
304+
305+`.github/workflows/main.yml` — ailedeki Çelebi deploy'uyla **aynı şekil**:
306+
307+```
308+Katman 1..5 (paralel) -> Build and test -> Deploy (SSH, health gate, tag rollback)
309+```
310+
311+| İş | Ne yapar |
312+|---|---|
313+| **Katman 1..5** | `ci.yml`'deki beş katmanın kendisi; komutlar birebir aynı. Hepsi yeşil olmadan imaj üretilmez. |
314+| **Build and test** | İmajı bu koşunun SHA'sıyla derler (`localhost/hezarfen-zeka:$GITHUB_SHA`), imaj tarball'ı + `compose.yaml` + systemd unit'i + `tag` dosyasını `release` artefaktı olarak yükler (30 gün). |
315+| **Deploy** | SSH: kapasite ön kontrolü → imajı yükle → `stack.env`'in `HEZARFEN_TAG`'ini bu SHA'ya çevir → compose + unit'i kur → `systemctl --user restart` → **servisin kendi sağlık betiğiyle** doğrula → olmazsa önceki tag'e dön → bağımsız son doğrulama. |
316+
317+**Yeşil bir `main` push'u servisi otomatik dağıtır.** Elle yeniden dağıtım
318+(süiti tekrar koşmadan, en yeni yeşil build'i):
319+
320+```bash
321+gh workflow run main.yml --ref main
322+```
323+
324+`main` dalına push yalnızca `main.yml`'de koşar; **diğer dallar ve pull
325+request'ler** beş katmanı `ci.yml`'den alır (aynı kapı iki kez koşmaz).
326+
327+### Ön koşullar (bir kez, depo/sunucu dışında yapılır)
328+
329+1. **Repo secret'ları** — backend ve frontend deploy'unun kullandığı üç isim:
330+ `SSH_PRIVATE_KEY`, `SSH_HOST`, `SSH_USER`.
331+2. **Sunucuda `loginctl enable-linger <kullanıcı>`** — kullanıcı unit'i için.
332+3. **Sunucuda podman + bir compose sağlayıcı** (`podman compose version`).
333+4. **Operatörün ayar dosyası** — deploy onu **oluşturmaz, yazmaz**, yalnız
334+ varlığını kontrol eder ve izni 0600'e çeker:
335+
336+ ```bash
337+ mkdir -p ~/hezarfen_zeka
338+ cp deploy/hezarfen_zeka.env.example ~/hezarfen_zeka/hezarfen_zeka.env
339+ # AI_SHARED_TOKEN / ZEKA_PG_DSN / DEEPSEEK_API_KEY zorunlu
340+ chmod 0600 ~/hezarfen_zeka/hezarfen_zeka.env
341+ ```
342+
343+5. **Backend tarafı açık olmalı**: `hezarfen_backend.env` içinde
344+ `AI_QUIC_ADDR=0.0.0.0:8090` ve `AI_SHARED_TOKEN` bu köprününkiyle **aynı**.
345+ Bu bir **kapı değildir**: ZEKA backend yokken çıkmaz, bekler ve backend
346+ düzeltilince kendiliğinden kaydolur (bkz. `docs/DAGITIM.md`). Deploy bunu
347+ yalnız **uyarı** olarak bildirir — kayıt şartı aransaydı ZEKA'nın kendi
348+ tanımından daha sıkı bir kapı uydurmuş olurduk.
349+
350+### Kapı, rollback ve kapsam
351+
352+- **Sağlık kapısı = `scripts/saglik.py`**, konteynerde. Ölçtüğü şey köprü
353+ sürecinin **yaşaması**; backend'e *kayıtlı* olduğunu ölçmez — bu bilinçli
354+ (backend'in her yeniden dağıtımı ZEKA'yı `unhealthy` işaretlemesin diye).
355+- **Kapasite ön kontrolü**: ≥ 512 MB boşta RAM ve ≥ 2 GB disk; yetmezse
356+ **nedeniyle birlikte reddeder** (ölçülen: imaj 152 MB, model yok).
357+- **Rollback**: `previous_tag`'e döner; ilk dağıtımda geri dönülecek imaj
358+ yoksa stack durdurulur (`down`, `-v` **yok** — `zeka-fixtures` volume'u kalır).
359+- **Manuel yol duruyor**: `cd service && podman compose up -d` (bkz. §7) —
360+ deploy'a ihtiyaç duymadan tek makinede kaldırmak için değişen bir şey yok.
deploy/hezarfen_zeka.env.exampleadded+115 -0
@@ -0,0 +1,115 @@
1+# hezarfen_zeka.env -- ZEKA koprusunun SUNUCU ayarlari.
2+#
3+# Sunucuda TEK SEFERLIK, elle:
4+# mkdir -p ~/hezarfen_zeka
5+# cp deploy/hezarfen_zeka.env.example ~/hezarfen_zeka/hezarfen_zeka.env
6+# <degerleri doldur>
7+# chmod 0600 ~/hezarfen_zeka/hezarfen_zeka.env
8+#
9+# Hicbir otomasyon bu dosyayi OLUSTURMAZ, EZMEZ, YUKLEMEZ -- operatorun malidir;
10+# deploy yalnizca varligini kontrol eder ve iznini 0600'e ceker, compose yalniz
11+# okur (`--env-file`). Satirlar duz KEY=value: tirnak yok, `export` yok, satir
12+# sonu yorumu yok. Yerel gelistirme icin esdegeri `service/.env.example`'dir.
13+#
14+# Degerler konteyner BASLARKEN okunur: degisiklikten sonra yeniden olustur
15+# podman compose --env-file hezarfen_zeka.env --env-file stack.env up -d
16+# ya da
17+# systemctl --user restart hezarfen_zeka_compose
18+#
19+# Uc sir ZORUNLUDUR (`${VAR:?}`): bos birakilirsa `compose up` DAHA BASLAMADAN
20+# durur -- adressiz/anahtarsiz bir kopru ayaga kalkip hicbir sey yazmadan
21+# "calisiyor" gorunurdu ve hata gunler sonra bos bir tablo olarak cikardi.
22+
23+# ============================================================================
24+# ZORUNLU
25+# ============================================================================
26+
27+# Backend ile AYNI sir. Kopru kaydi bununla yapilir; hezarfen_backend.env
28+# icindeki AI_SHARED_TOKEN ile BIREBIR ayni olmali (iki tarafi birlikte
29+# degistirin; yalniz birini degistirmek kaydi `unauthorized` ile dusurur ve
30+# kopru bekler).
31+AI_SHARED_TOKEN=
32+
33+# ZEKA ciktilarini yazacagi veritabani. OKULUN kendi veritabanidir; ayri bir
34+# ZEKA veritabani YOKTUR. Adi okulun uuid'sinden turer (`tenant.rs:112`), slug'dan
35+# DEGIL:
36+# hezarfen_control_school_0193000000007000800000000000de70
37+# Parola tasir: dosya 0600, DSN hicbir yere loglanmaz.
38+ZEKA_PG_DSN=
39+
40+# Segment hattinin LLM saglayicisi. Kopru bu anahtari OKUMAZ; yalnizca
41+# `src/segment/` okur (oncelik: DEEPSEEK_API_KEY -> LLM_API_KEY ->
42+# SEGMENT_API_KEY). Yine de zorunlu tutuluyor: anahtarsiz bir servis ayaga
43+# kalkar, segment hatti kosuldugunda patlardi. Hatayi dagitim anina cekiyoruz.
44+# (Yalnizca kopruyu kosturan bir dagitimda bilincli olarak sahte bir deger
45+# verilebilir; segment o zaman hata verir, kopru calisir.)
46+DEEPSEEK_API_KEY=
47+
48+# ============================================================================
49+# KOPRU
50+# ============================================================================
51+
52+# Backend'in QUIC dinleyicisi (konteyner aginda). Backend tarafinda
53+# AI_QUIC_ADDR=0.0.0.0:8090 OLMALI -- 127.0.0.1 yaziliysa backend yalniz kendi
54+# konteyner loopback'ine baglanir ve HICBIR servis dial-in edemez.
55+AI_BRIDGE_HOST=hezarfen-backend
56+AI_BRIDGE_PORT=8090
57+
58+# Sertifikanin cekildigi HTTP koku. Varsayilan backend konteynerinin kendi
59+# adresi; backend'in yayimlanan host portu ise 127.0.0.1:7656'dir.
60+AI_BACKEND_URL=http://hezarfen-backend:8080
61+AI_TLS_SERVER_NAME=localhost
62+AI_SERVICE_NAME=zeka
63+
64+# Sertifika parmak izi pinlemesi -- BACKEND SERTIFIKASI DUZ HTTP ILE CEKILDIGI
65+# icin tek basina pinlemek yetmez: araya giren biri kendi sertifikasini
66+# pinletebilir. BOS BIRAKILIRSA TOFU (her acilista uyari olarak loglanir;
67+# sessiz bir varsayilan degildir). Uretimde doldurun -- 64 hex karakter, iki
68+# nokta ayraclari atilir. Sunucuda:
69+# curl -s http://127.0.0.1:7656/ai/certificate | python -c 'import json,sys; print(json.load(sys.stdin)["fingerprint_sha256"])'
70+AI_TLS_FINGERPRINT=
71+
72+AI_MAX_CONCURRENT=4
73+AI_RECONNECT_SECS=3
74+AI_RECONNECT_MAX_SECS=120
75+
76+# ============================================================================
77+# KAPSAM
78+# ============================================================================
79+#
80+# Backend'de okul ve kullanici LISTELEME yolu yok (izin listesi
81+# `constant.rs:641-661`), bu yuzden kapsam BURADAN verilir -- donem ortasi
82+# kayit olan ogrenci gorunmez, ayrilan silinmez.
83+# Bkz. service/docs/BACKEND-GEREKSINIMLERI.md madde 3.
84+ZEKA_SCHOOLS=hezarfen-demo
85+ZEKA_STUDENT_SOURCE=config
86+ZEKA_STUDENTS=
87+ZEKA_STUDENT_FILE=
88+
89+# ============================================================================
90+# ZAMANLAMA
91+# ============================================================================
92+# 0 = periyodik kosu kapali, yalnizca istek uzerine.
93+ZEKA_REFRESH_INTERVAL_SECS=3600
94+ZEKA_REFRESH_JITTER_SECS=60
95+ZEKA_REFRESH_BATCH=25
96+
97+# ============================================================================
98+# AG / LOG
99+# ============================================================================
100+# Backend'in compose agi. Dagitimdan dagitima degisebilir (parametrik).
101+HEZARFEN_NET=hezarfen_backend_default
102+
103+# debug | info | warn | error
104+LOG_LEVEL=info
105+
106+# ============================================================================
107+# SURUM ETIKETI
108+# ============================================================================
109+# BURADAN OKUNMAZ: HEZARFEN_TAG yalnizca compose interpolasyonudur ve deploy'un
110+# sahip oldugu stack.env icinde tasinir (ikinci `--env-file`, cakisan anahtarda
111+# o kazanir). Elle kostururken varsayilan `current`'tir; imaj sunucuda VAR
112+# olmali:
113+# podman compose up -d --build # burada derle
114+# podman load -i hezarfen_zeka.tar.gz
115+#HEZARFEN_TAG=current
deploy/hezarfen_zeka_compose.serviceadded+48 -0
@@ -0,0 +1,48 @@
1+# systemd KULLANICI unit'i: ZEKA koprusunu podman compose ile calistirir.
2+# %h/hezarfen_zeka icinde beklenen dosyalar:
3+# compose.yaml bu repodan (deploy artefaktindan gelir)
4+# hezarfen_zeka.env 0600, deploy/hezarfen_zeka.env.example'dan
5+# ELLE yazilir -- otomasyon olusturmaz/ezmez
6+# stack.env deploy sahipli; HEZARFEN_TAG tasir
7+#
8+# Unit `--no-build` ile baslar, yani imaj sunucuda zaten olmali:
9+# podman compose build # burada derle
10+# podman load -i image.tar # ya da hazir imaji yukle (deploy bunu yapar)
11+#
12+# KAPASITE: ZEKA hafiftir -- olculen imaj 152 MB (docs/DAGITIM.md), model
13+# dosyasi yok, calisma zamani tek bir Python sureci (kopru). Dagitim yine de
14+# yer oldugunu olcer (main.yml "KAPASITE ON KONTROLU": >= 512 MB RAM,
15+# >= 2 GB disk) ve yetmezse nedeniyle birlikte reddeder.
16+#
17+# HEZARFEN_TAG compose.yaml'da `${HEZARFEN_TAG:-current}` olarak gecir; bu
18+# unit'te SONRAKI --env-file kazanir: once operatorun ayar dosyasi, sonra
19+# deploy sahipli stack.env.
20+#
21+# Dis ag (`hezarfen_backend_default`) backend compose'u tarafindan kurulur;
22+# yoksa once olusturun: podman network create hezarfen_backend_default
23+#
24+# Sadece ortam degiskeni degistiginde yeniden baslatma (ExecStart'i yeniden
25+# kosar, ortami degisen konteynerı yeniden olusturur):
26+# systemctl --user restart hezarfen_zeka_compose
27+
28+[Unit]
29+Description=Hezarfen ZEKA bridge (student analysis + recommendations over the school database)
30+After=network-online.target
31+Wants=network-online.target
32+
33+[Service]
34+Type=oneshot
35+RemainAfterExit=yes
36+WorkingDirectory=%h/hezarfen_zeka
37+# Sonraki --env-file cakisan anahtarda kazanir: once operatorun ayar dosyasi,
38+# sonra deploy sahipli stack.env (HEZARFEN_TAG).
39+ExecStart=/usr/bin/podman compose --env-file %h/hezarfen_zeka/hezarfen_zeka.env --env-file %h/hezarfen_zeka/stack.env up -d --no-build
40+# Env dosyalari BURADA DA verilir: compose her komutta dosyayi COZER ve ZEKA
41+# compose.yaml'inda uc sir `${VAR:?}` bicimindedir; env'siz bir `down`
42+# "required variable ... is missing a value" ile duser ve kap DURMAZ.
43+# `-v` yok: zeka-fixtures isimli volume stop'ta yasamali.
44+ExecStop=/usr/bin/podman compose --env-file %h/hezarfen_zeka/hezarfen_zeka.env --env-file %h/hezarfen_zeka/stack.env down
45+TimeoutStartSec=180
46+
47+[Install]
48+WantedBy=default.target
scripts/ci-compose.shmodified+19 -6
@@ -4,7 +4,8 @@
4 # Uc sey denetlenir ve UCU DE cift yonludur; yalnizca "gecerli mi" diye4 # Uc sey denetlenir ve UCU DE cift yonludur; yalnizca "gecerli mi" diye
5 # sormak, asil kusurlari kacirir:5 # sormak, asil kusurlari kacirir:
6 #6 #
7-# 1. Zorunlu sirlar gercekten zorunlu mu?7+# 1. Zorunlu sirlar gercekten zorunlu mu? (AI_SHARED_TOKEN, DEEPSEEK_API_KEY,
8+# ZEKA_PG_DSN -- tam liste compose.yaml'da.)
8 # `${VAR:?}` yerine `${VAR:-}` yazilirsa compose yine gecerli olur ama9 # `${VAR:?}` yerine `${VAR:-}` yazilirsa compose yine gecerli olur ama
9 # servis bos bir token'la ayaga kalkar ve backend'e kaydolamaz. Bu10 # servis bos bir token'la ayaga kalkar ve backend'e kaydolamaz. Bu
10 # yuzden env YOKKEN `config`in PATLAMASINI da sinariz.11 # yuzden env YOKKEN `config`in PATLAMASINI da sinariz.
@@ -38,14 +39,21 @@ gec() { echo " [ok] $1"; }
38 kal() { echo " [HATA] $1"; HATA=1; }39 kal() { echo " [HATA] $1"; HATA=1; }
39 40
40 # --- 1a. zorunlu env EKSIKKEN patlamali -----------------------------------41 # --- 1a. zorunlu env EKSIKKEN patlamali -----------------------------------
41-if env -u AI_SHARED_TOKEN -u DEEPSEEK_API_KEY "${COMPOSE[@]}" config >/dev/null 2>&1; then42+# ZORUNLU SIRLAR LISTESI compose.yaml'DAN OKUNUR -- su an uctur
43+# (AI_SHARED_TOKEN, DEEPSEEK_API_KEY, ZEKA_PG_DSN). Ucuncusu eklendiginde bu
44+# betik ve `ci.yml`'in konteyner katmani iki sirla kalmis, ikisi de "sirlar
45+# verilse bile patliyor" diyerek KIRMIZI kalmisti. Sir eklerseniz bu listeyi
46+# ve ci.yml/main.yml adimini BIRLIKTE guncelleyin.
47+if env -u AI_SHARED_TOKEN -u DEEPSEEK_API_KEY -u ZEKA_PG_DSN \
48+ "${COMPOSE[@]}" config >/dev/null 2>&1; then
42 kal "zorunlu sirlar olmadan gecti -- \${VAR:?} yerine \${VAR:-} yazilmis olabilir"49 kal "zorunlu sirlar olmadan gecti -- \${VAR:?} yerine \${VAR:-} yazilmis olabilir"
43 else50 else
44- gec "zorunlu sirlar olmadan REDDEDILDI (AI_SHARED_TOKEN / DEEPSEEK_API_KEY)"51+ gec "zorunlu sirlar olmadan REDDEDILDI (AI_SHARED_TOKEN / DEEPSEEK_API_KEY / ZEKA_PG_DSN)"
45 fi52 fi
46 53
47 # --- 1b. zorunlu env VARKEN gecerli olmali --------------------------------54 # --- 1b. zorunlu env VARKEN gecerli olmali --------------------------------
48-CIKTI="$(AI_SHARED_TOKEN=ci-sahte DEEPSEEK_API_KEY=ci-sahte "${COMPOSE[@]}" config 2>&1)"55+ZORUNLU_ENV=(AI_SHARED_TOKEN=ci-sahte DEEPSEEK_API_KEY=ci-sahte ZEKA_PG_DSN=postgres://ci:ci@127.0.0.1:5432/ci)
56+CIKTI="$(env "${ZORUNLU_ENV[@]}" "${COMPOSE[@]}" config 2>&1)"
49 if [ $? -ne 0 ]; then57 if [ $? -ne 0 ]; then
50 kal "zorunlu sirlar verildiginde bile config basarisiz:"58 kal "zorunlu sirlar verildiginde bile config basarisiz:"
51 echo "$CIKTI" | tail -1059 echo "$CIKTI" | tail -10
@@ -63,8 +71,13 @@ fi
63 # --- 3. ag adi parametrik mi ----------------------------------------------71 # --- 3. ag adi parametrik mi ----------------------------------------------
64 if grep -q 'name: ${HEZARFEN_NET:-' compose.yaml; then72 if grep -q 'name: ${HEZARFEN_NET:-' compose.yaml; then
65 gec "dis ag adi parametrik: \${HEZARFEN_NET:-hezarfen_backend_default}"73 gec "dis ag adi parametrik: \${HEZARFEN_NET:-hezarfen_backend_default}"
66- OZEL="$(HEZARFEN_NET=baska_ag AI_SHARED_TOKEN=x DEEPSEEK_API_KEY=x "${COMPOSE[@]}" config 2>/dev/null | grep -A2 '^networks:' | grep 'name:')"74+ # SIRA BAGIMSIZ arama: `networks:` blogunda anahtar sirasi saglayiciya gore
67- if echo "$OZEL" | grep -q 'baska_ag'; then75+ # degisir (podman-compose `external`i `name`den ONCE basar). Ilk surum
76+ # `grep -A2 '^networks:'` ile pencere aciyordu ve ad satirini kacirip HATA
77+ # veriyordu -- probe'un kendisi yanlisti, yapilandirma degil.
78+ OZEL="$(env HEZARFEN_NET=baska_ag "${ZORUNLU_ENV[@]}" "${COMPOSE[@]}" config 2>/dev/null \
79+ | grep -E '^[[:space:]]+name:[[:space:]]*baska_ag[[:space:]]*$' | head -1)"
80+ if [ -n "$OZEL" ]; then
68 gec "HEZARFEN_NET gecersiz kilinabiliyor (test: baska_ag ->$OZEL)"81 gec "HEZARFEN_NET gecersiz kilinabiliyor (test: baska_ag ->$OZEL)"
69 else82 else
70 kal "HEZARFEN_NET gecersiz kilinamadi; parametre ise yaramiyor"83 kal "HEZARFEN_NET gecersiz kilinamadi; parametre ise yaramiyor"
scripts/ci-sir-tara.pymodified+7 -2
@@ -66,7 +66,8 @@ DESENLER: list[tuple[str, re.Pattern[str], str]] = [
66 r"""(?x)66 r"""(?x)
67 ^\s*(?:export\s+)?67 ^\s*(?:export\s+)?
68 (DEEPSEEK_API_KEY|LLM_API_KEY|SEGMENT_API_KEY|AI_SHARED_TOKEN68 (DEEPSEEK_API_KEY|LLM_API_KEY|SEGMENT_API_KEY|AI_SHARED_TOKEN
69- |ZEKA_DB_PASSWORD|[A-Z0-9_]*(?:API_KEY|SECRET|PASSWORD|TOKEN))69+ |ZEKA_DB_PASSWORD|ZEKA_PG_DSN
70+ |[A-Z0-9_]*(?:API_KEY|SECRET|PASSWORD|TOKEN))
70 \s*[:=]\s*71 \s*[:=]\s*
71 (?!\$) # ${VAR} interpolasyonu degil72 (?!\$) # ${VAR} interpolasyonu degil
72 ["']?([^\s"'#]{12,})["']?\s*$73 ["']?([^\s"'#]{12,})["']?\s*$
@@ -240,10 +241,14 @@ def main() -> int:
240 # --- compose sirlarinin bicimi ------------------------------------------241 # --- compose sirlarinin bicimi ------------------------------------------
241 # Zorunlu sirlar `${VAR:?...}` ile gelmeli; duz deger ya da `:-varsayilan`242 # Zorunlu sirlar `${VAR:?...}` ile gelmeli; duz deger ya da `:-varsayilan`
242 # bir sirri dosyaya gomer.243 # bir sirri dosyaya gomer.
244+ #
245+ # LISTE compose.yaml'DAN OKUNUR: `ZEKA_PG_DSN` ucuncu sir olarak
246+ # eklendiginde burasi ve `scripts/ci-compose.sh` iki sirla kalmisti.
247+ # DSN bir parola tasir -- duz deger yazilabilseydi sir dosyaya girerdi.
243 compose = KOK / "service" / "compose.yaml"248 compose = KOK / "service" / "compose.yaml"
244 if compose.exists():249 if compose.exists():
245 icerik = io.open(compose, encoding="utf-8").read()250 icerik = io.open(compose, encoding="utf-8").read()
246- for degisken in ("AI_SHARED_TOKEN", "DEEPSEEK_API_KEY"):251+ for degisken in ("AI_SHARED_TOKEN", "DEEPSEEK_API_KEY", "ZEKA_PG_DSN"):
247 satirlar = [s for s in icerik.splitlines() if s.strip().startswith(degisken + ":")]252 satirlar = [s for s in icerik.splitlines() if s.strip().startswith(degisken + ":")]
248 if not satirlar:253 if not satirlar:
249 uyarilar.append(f"compose.yaml icinde {degisken} tanimli degil")254 uyarilar.append(f"compose.yaml icinde {degisken} tanimli degil")
scripts/ci-yerel.shmodified+7 -1
@@ -63,7 +63,13 @@ kosu "sozdizimi" "$PYTHON" -m compileall -q -x '(__pycache__|\.venv|venv)' \
63 katman "2/5 testler" \63 katman "2/5 testler" \
64 "375+ birim testi; saf unittest, HICBIR bagimlilik gerektirmez"64 "375+ birim testi; saf unittest, HICBIR bagimlilik gerektirmez"
65 # `-t .` onemli: test kokunu servise sabitler, `src.` import'lari boylece cozulur.65 # `-t .` onemli: test kokunu servise sabitler, `src.` import'lari boylece cozulur.
66-kosu "birim testleri" bash -c "cd '$SERVIS' && '$PYTHON' -m unittest discover -s tests -t . -v 2>&1 | tail -20"66+#
67+# `set -o pipefail` ICERIDE: `bash -c` yeni bir kabuk acar ve dis script'in
68+# `pipefail` secenegi oraya GECMEZ. Onsuz boru hattinin cikis durumu `tail`in
69+# durumudur -- yani 686 testten 3'u patlarken bile bu satir GECTI basardi
70+# (olculdu: `Ran 686 tests ... FAILED`, katman yine yesil). Yesil gorunen ama
71+# olcmeyen kapi, kapi degildir.
72+kosu "birim testleri" bash -c "set -o pipefail; cd '$SERVIS' && '$PYTHON' -m unittest discover -s tests -t . -v 2>&1 | tail -20"
67 73
68 if [ "$HIZLI" -eq 1 ]; then74 if [ "$HIZLI" -eq 1 ]; then
69 echo ""75 echo ""
service/compose.yamlmodified+6 -1
@@ -7,7 +7,12 @@ services:
7 build:7 build:
8 context: .8 context: .
9 dockerfile: Containerfile9 dockerfile: Containerfile
10- image: localhost/hezarfen-zeka:current10+ # HEZARFEN_TAG deploy tarafindan yazilan stack.env'den gelir (--env-file
11+ # sirasi onu kazanan yapar). Yerelde/elle `up` icin varsayilan `current`:
12+ # yani `podman compose up -d --build` yine calisiyor. Sabit bir `:current`
13+ # yazilsaydi deploy yeni imaji yukleyip ESKI imaji kosmaya devam ederdi --
14+ # tag rotasyonu ve geri donus (previous_tag) bu satira baglidir.
15+ image: localhost/hezarfen-zeka:${HEZARFEN_TAG:-current}
11 container_name: hezarfen-zeka-bridge16 container_name: hezarfen-zeka-bridge
12 init: true17 init: true
13 command: ["python", "-m", "src.bridge"]18 command: ["python", "-m", "src.bridge"]
service/docs/DAGITIM.mdmodified+77 -11
@@ -286,7 +286,11 @@ kullanildigi durum icin bir yedektir.
286 Katmanli. Her katman ayri bir istir; bir katman kirmiziya dondugunde neyin286 Katmanli. Her katman ayri bir istir; bir katman kirmiziya dondugunde neyin
287 bozuldugu is listesinden okunur.287 bozuldugu is listesinden okunur.
288 288
289-### `.github/workflows/ci.yml` -- her degisiklikte289+### `.github/workflows/ci.yml` -- pull request'ler ve `main` DIŞINDAKİ dallar
290+
291+`main`'e push burada **koşmaz**: aynı beş katman `main.yml` içinde koşar ve
292+deploy'u kapılar (bkz. bir sonraki başlık). Böylece push başına aynı kapı iki
293+kez koşmaz; PR'lar ve dal push'ları tam katmanlı süiti buradan alır.
290 294
291 | Katman | Ne denetler |295 | Katman | Ne denetler |
292 |---|---|296 |---|---|
@@ -296,6 +300,44 @@ bozuldugu is listesinden okunur.
296 | **4 -- sir taramasi** | `sk-` / `sk_` desenleri, ozel anahtar govdeleri, AWS anahtarlari, yapilandirma dosyalarina gomulmus duz degerler; compose sirlarinin `${VAR:?}` bicimini korudugu. |300 | **4 -- sir taramasi** | `sk-` / `sk_` desenleri, ozel anahtar govdeleri, AWS anahtarlari, yapilandirma dosyalarina gomulmus duz degerler; compose sirlarinin `${VAR:?}` bicimini korudugu. |
297 | **5 -- konteyner** | Imaj derleniyor **ve kosuyor** mu; non-root mu; saglik kontrolu gercekten olcuyor mu; `compose config` gecerli mi ve port acilmiyor mu. |301 | **5 -- konteyner** | Imaj derleniyor **ve kosuyor** mu; non-root mu; saglik kontrolu gercekten olcuyor mu; `compose config` gecerli mi ve port acilmiyor mu. |
298 302
303+### `.github/workflows/main.yml` -- `main` push'u, otomatik dağıtım
304+
305+Ailedeki Çelebi deploy'uyla aynı şekil; is grafiği:
306+
307+```
308+Katman 1..5 (paralel) -> Build and test -> Deploy (SSH)
309+```
310+
311+| İş | Tetik | Neyi kanıtlar / ne yapar |
312+|---|---|---|
313+| `sozdizimi`, `testler`, `sozlesme`, `sirlar`, `konteyner` | push (`main`) | `ci.yml`'deki beş katmanın **aynısı** (Komutlar birebir; tek doğruluk kaynağı `scripts/ci-yerel.sh`). Beşi de yeşil olmadan imaj üretilmez. |
314+| `build` (adı **Build and test**) | push, beş katmanı `needs` ile bekler | İmajı `localhost/hezarfen-zeka:$GITHUB_SHA` olarak derler; imaj tarball'ı (`podman save`), `service/compose.yaml`, `deploy/hezarfen_zeka_compose.service` ve `tag` dosyasını `release` artefaktı olarak yükler (30 gün). Eksik parça burada — sunucuda değil — patlar. |
315+| `deploy` | push'ta yalnız `Build and test` yeşilse; `workflow_dispatch`'te en yeni yeşil build'in artefaktıyla | SSH ile: kapasite ön kontrolü (≥ 512 MB RAM, ≥ 2 GB disk) → operatörün `~/hezarfen_zeka/hezarfen_zeka.env` dosyasını kontrol (0600'e çeker, **yazmaz**) → imajı `podman load` → tag rotasyonu (`current_tag`→`previous_tag`) → `stack.env`'e `HEZARFEN_TAG` → unit kurulumu + `daemon-reload` + `enable` + `restart` → **`scripts/saglik.py` ile sağlık kapısı** (60 sn) → konteynerin imajı bu tag mi → olmazsa önceki tag'e dön (ilk dağıtımda `down`, `-v` yok) → bağımsız son doğrulama → `rm -rf ~/.ssh`. |
316+
317+**Yeşil bir `main` push'u otomatik dağıtır.** Elle yeniden dağıtım (süiti tekrar
318+koşmadan): `gh workflow run main.yml --ref main`.
319+
320+Kapı hakkında dürüst not: **sağlık kapısı köprü sürecinin yaşadığını ölçer**,
321+backend'e *kayıtlı* olduğunu ölçmez — `scripts/saglik.py`'nin ta kendisi
322+kullanılır ve nedeni orada yazılıdır (kayıt şartı aransaydı backend'in her
323+yeniden dağıtımı ZEKA'yı `unhealthy` işaretler ve crash-loop üretirdi). Backend
324+sertifika ucu deploy'da yalnızca **uyarı** olarak kontrol edilir; Celebi'deki
325+gibi bir ön kapı değildir, çünkü ZEKA'nın backend yokken beklemesi tasarım
326+gereğidir.
327+
328+Bir seferlik ön koşullar:
329+
330+1. Repo secret'ları `SSH_PRIVATE_KEY` / `SSH_HOST` / `SSH_USER`.
331+2. Sunucuda `loginctl enable-linger <kullanıcı>`.
332+3. Sunucuda `podman` + bir compose sağlayıcı.
333+4. Operatörün `~/hezarfen_zeka/hezarfen_zeka.env` dosyası (0600; şablon
334+ `deploy/hezarfen_zeka.env.example`, zorunlu üç sır: `AI_SHARED_TOKEN`,
335+ `ZEKA_PG_DSN`, `DEEPSEEK_API_KEY`).
336+5. Sunucuda `hezarfen_backend_default` ağı (backend compose'u kurar) ve
337+ backend tarafında `AI_QUIC_ADDR=0.0.0.0:8090`.
338+
339+Manuel yol değişmedi: `cd service && podman compose up -d` (§3).
340+
299 ### `.github/workflows/istege-bagli-testler.yml` -- elle tetiklenir341 ### `.github/workflows/istege-bagli-testler.yml` -- elle tetiklenir
300 342
301 Her degisiklikte **kosmaz**. `aioquic` kurar ya da bir veritabani kaldirir;343 Her degisiklikte **kosmaz**. `aioquic` kurar ya da bir veritabani kaldirir;
@@ -416,6 +458,23 @@ KATMAN 5/5 konteyner+compose -> GECTI
416 BUTUN KATMANLAR GECTI458 BUTUN KATMANLAR GECTI
417 ```459 ```
418 460
461+> **Bu kayit 519 testlik hale aittir; durum o gunden beri degisti.** Bugun 686
462+> test var ve **ucu temiz bir kopyada KIRMIZI** cunku depoda **olmayan**
463+> uretilmis tohum artefaktlarini istiyorlar (`work/` ve `seed/*.surql`
464+> `.gitignore`'da; tohum depoda degil, yalnizca ureticisi var):
465+>
466+> ```
467+> ERROR tests.test_segment_pipeline.TestRealDataLoaders.test_items_enriched_yuklenir
468+> ERROR tests.test_segment_validate.TestGoldSet.test_gercek_veride_741_pozitif
469+> FAIL tests.test_segment_pipeline.TestRealDataLoaders.test_cevaplar_surql_dosyasindan_okunur
470+> ```
471+>
472+> Yani Katman 2 GitHub kosucusunda da kirmizidir ve deploy fail-closed
473+> davranip **hic dagitmaz**. Tohumu uretmeden bu katman yesile donmez; iki yol
474+> var: (a) bu uc test de diger 120 ortam bagimli test gibi eksik artefaktta
475+> `SkipTest` ile atlar, (b) tohum artefaktlari kosuya verilir. Bu bir CI/deploy
476+> isi degil, test verisi isidir.
477+
419 ---478 ---
420 479
421 ## Kanitlanmayanlar480 ## Kanitlanmayanlar
@@ -453,40 +512,47 @@ Durustluk bolumu. Asagidakiler **kosturulmadi** ya da **dogrulanamadi**;
453 512
454 ### Kanitlanmayan -- CI513 ### Kanitlanmayan -- CI
455 514
456-7. **GitHub Actions is akislari GitHub'da hic kosmadi.** Depo bir git deposu515+7. **GitHub Actions is akislari GitHub'da hic kosmadi.** Depo artik bir git
457- bile degil. YAML el ile yazildi; `actions/checkout@v4`,516+ deposu (origin: `Hezarfen-Co/hezarfen_zeka`), ama hicbir is akisi gercek bir
517+ kosucuda **kosturulmadi**. YAML el ile yazildi; `actions/checkout@v4`,
458 `actions/setup-python@v5` ve kosucudaki `podman` varliginin gercek bir518 `actions/setup-python@v5` ve kosucudaki `podman` varliginin gercek bir
459 kosucuda dogrulanmasi **yapilmadi**. Kosturulmus olan, ayni komutlari519 kosucuda dogrulanmasi **yapilmadi**. Kosturulmus olan, ayni komutlari
460 cagiran `scripts/ci-yerel.sh`'dir.520 cagiran `scripts/ci-yerel.sh`'dir.
461 521
462-8. **`docker compose` yolu.** `ci.yml` icindeki compose adimi522+8. **`main.yml` deploy zinciri hic kosturulmadi.** SSH, `podman load`, unit
523+ kurulumu, saglik kapisi, tag rotasyonu ve rollback yollari **okundu ve yerel
524+ olarak kismen dogrulandi** (compose interpolasyonu, kapasite aritmetigi,
525+ sağlık betiginin konteynerde iki yonlu davranisi), ama gercek bir sunucuya
526+ karsi **hic kosmadi**. Ilk gercek kosu bu maddeleri kapatacaktir.
527+
528+9. **`docker compose` yolu.** `ci.yml` icindeki compose adimi
463 `docker compose` cagirir; yerelde `podman compose` zaten docker-compose'a529 `docker compose` cagirir; yerelde `podman compose` zaten docker-compose'a
464 devrettigi icin **ayni ikili** kosturuldu, ama GitHub kosucusundaki530 devrettigi icin **ayni ikili** kosturuldu, ama GitHub kosucusundaki
465 surumle **dogrulanmadi**.531 surumle **dogrulanmadi**.
466 532
467-9. **Makefile.** Bu makinede `make` **kurulu degil**; hicbir hedef533+10. **Makefile.** Bu makinede `make` **kurulu degil**; hicbir hedef
468 kosturulamadi. Hedefler `scripts/` betiklerini cagiran ince sarmalayicilar534 kosturulamadi. Hedefler `scripts/` betiklerini cagiran ince sarmalayicilar
469 olsa da, Makefile'in kendisi **sinanmamistir**. Guvenilir yol dogrudan535 olsa da, Makefile'in kendisi **sinanmamistir**. Guvenilir yol dogrudan
470 `bash scripts/ci-yerel.sh` kullanmaktir.536 `bash scripts/ci-yerel.sh` kullanmaktir.
471 537
472-10. **`istege-bagli-testler.yml` isleri.** Ne `kopru-canli` ne `veritabani`538+11. **`istege-bagli-testler.yml` isleri.** Ne `kopru-canli` ne `veritabani`
473 isi kosturuldu. `tests/test_bridge_live.py` yerelde `aioquic` kurulu539 isi kosturuldu. `tests/test_bridge_live.py` yerelde `aioquic` kurulu
474 olmadigi icin **atlandi**; canli kopru testlerinin gectigi540 olmadigi icin **atlandi**; canli kopru testlerinin gectigi
475 **gorulmedi**.541 **gorulmedi**.
476 542
477-11. *(Bu madde kapatildi -- negatif sinama yapildi, bkz. asagisi.)*543+12. *(Bu madde kapatildi -- negatif sinama yapildi, bkz. asagisi.)*
478 544
479 ### Kanitlanmayan -- guvenlik545 ### Kanitlanmayan -- guvenlik
480 546
481-12. **Fiyat tablosunun dogrulugu.** `PRICING_VERIFIED = False`. Fiyatlar547+13. **Fiyat tablosunun dogrulugu.** `PRICING_VERIFIED = False`. Fiyatlar
482 `2026-08-28` tarihli ve saglayicinin dokumantasyonuna karsi elle548 `2026-08-28` tarihli ve saglayicinin dokumantasyonuna karsi elle
483 **dogrulanmamistir**. Butce hesaplari bu tabloya dayanir.549 **dogrulanmamistir**. Butce hesaplari bu tabloya dayanir.
484 550
485-13. **Sir taramasinin kapsami.** Tarayici `.gitignore` tarafindan korunan551+14. **Sir taramasinin kapsami.** Tarayici `.gitignore` tarafindan korunan
486 dosyalari **atlar** (ve `.env` ailesinin gercekten korundugunu ayrica552 dosyalari **atlar** (ve `.env` ailesinin gercekten korundugunu ayrica
487- denetler). Depo bir git deposu olmadigi icin `git check-ignore` yerine553+ denetler). `git check-ignore` hala kullanilmaz; yerine
488 `.gitignore` desenleri **elle** yorumlanir; karmasik desenlerde (negasyon554 `.gitignore` desenleri **elle** yorumlanir; karmasik desenlerde (negasyon
489 `!`, dizin-koku `/` ayrimi) git ile birebir ayni davranmayabilir.555 `!`, dizin-koku `/` ayrimi) git ile birebir ayni davranmayabilir.
490 556
491-14. **Gecmis tarama yok.** Tarayici yalnizca **calisma agacini** okur. Git557+15. **Gecmis tarama yok.** Tarayici yalnizca **calisma agacini** okur. Git
492 gecmisine bir zamanlar islenmis bir anahtar bulunamaz.558 gecmisine bir zamanlar islenmis bir anahtar bulunamaz.