Files
aiturk-hermes-ide/apps/desktop/assets/codex-bridge/karar_sor.py
T
yilsemandClaude Opus 5.5 7c4ef18df0 feat(codex-bridge): decision-model stages, Dify rules and beta.39
Owner request, 14 October 2026: use the decision model (Jev / Celeris) at
several stages, let Dify supply the rules, code it without new bugs.
Every new stage is switched on in Settings > Kademeli Gecis and starts
disabled, so the upgrade changes no behaviour by itself.

- Settings schema 2 (Python and TypeScript validate the same rules); a
  schema 1 file is filled from the defaults. Default chain is now
  Katman-1 -> Katman-2 -> Katman-3 with Katman-3, Chat-Model and
  bekci-sesli-bekci always passing (owner decision of the same day).
- watchModels: the Bekci correction channel follows a settings list
  instead of the hard-coded Sesli-Hizli-Zeki.
- prefilter: a predicted refusal starts the step at the chosen layer.
- autoRoute: virtual "Otomatik" model; one decision per user turn picks
  the combo, tool steps of the same turn keep it.
- finishCheck: an answer that stops early goes back to the same model once.
- A layer whose window cannot hold the request is skipped.
- policy: stage rules from a Dify workflow (karar_politikasi.py), fetched
  in the background, validated, last good copy kept; turns never wait.
- karar_sor.py: verifierCheck for the dynamic-workflow acceptance step.
- Bridge version 19, IDE 1.0.0-beta.39.

Tests: 299 bridge tests, 36 electron tests; live run on a side bridge
(port 8797) with Celeris and the AITURK gateway for every stage.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 07:48:33 +03:00

59 lines
2.7 KiB
Python

"""One decision-model question from the command line (14 Oct 2026).
Used by the Codex dynamic-workflow acceptance step (verifierCheck): before a reviewer's "kabul" is accepted,
the decision model is asked whether the approval cites concrete evidence. Reads the IDE's own Kademeli Geçiş
settings and key; nothing is written.
python karar_sor.py dogrulayici < {"user_request": "...", "assistant_reply": "..."}
Prints JSON {"enabled": bool, "kanitsiz": bool|null, "puan": float|null, "neden": str}. Exit 0 also when the
stage is off or the model cannot be reached; the caller decides what an unanswered check means.
"""
import json
import os
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent))
import jev_denetim # noqa: E402
import jev_settings # noqa: E402
SINIR = 20000
def dogrulayici(veri, anahtar=None, gonder=None):
s = jev_settings.read()[0]
v = s['verifierCheck']
if not (s['enabled'] and v['enabled']):
return {'enabled': False, 'kanitsiz': None, 'puan': None, 'neden': 'kapali'}
durum = {'user_request': str(veri.get('user_request') or '')[:SINIR], 'assistant_reply': str(veri.get('assistant_reply') or '')[:SINIR]}
ek = {'gonder': gonder} if gonder else {}
puan = jev_denetim.sorular(durum, {'kanitsiz': v['question']}, jev_denetim.anahtar() if anahtar is None else anahtar, 15, **ek)
if puan is None:
return {'enabled': True, 'kanitsiz': None, 'puan': None, 'neden': 'karar modeline sorulamadi'}
return {'enabled': True, 'kanitsiz': puan['kanitsiz'] >= v['threshold'], 'puan': round(puan['kanitsiz'], 3), 'neden': ''}
def main(argv=None, stdin=None, out=None):
argv = sys.argv[1:] if argv is None else argv
stdin, out = stdin or sys.stdin, out or sys.stdout
soru = [a for i, a in enumerate(argv) if a != '--home' and (i == 0 or argv[i - 1] != '--home')]
if soru != ['dogrulayici']:
print('kullanim: python karar_sor.py dogrulayici < {"user_request": ..., "assistant_reply": ...}', file=sys.stderr)
return 2
try:
veri = json.load(stdin)
sonuc = dogrulayici(veri if isinstance(veri, dict) else {})
except Exception as e:
sonuc = {'enabled': None, 'kanitsiz': None, 'puan': None, 'neden': f'{type(e).__name__}: {e}'[:300]}
out.write(json.dumps(sonuc, ensure_ascii=False))
return 0
if __name__ == '__main__':
# Installed copy: the settings live in the user's bridge home, not next to this file.
if '--home' not in sys.argv and not os.environ.get('AITURK_CODEX_BRIDGE_HOME'):
os.environ['AITURK_CODEX_BRIDGE_HOME'] = str(Path(os.environ.get('LOCALAPPDATA', '')) / 'TurkServis' / 'AITURK-IDE' / 'codex-bridge')
sys.exit(main())