Tutorial
Review your first real Drupal MR in ~15 minutes. Step-by-step, with checkboxes that survive page reload.
Overview
Po skończeniu będziesz miał: działający lokalny stack (Qdrant + Ollama lub RunPod), pierwszy review na realnym Drupal core PR, zrozumienie jakie findings model daje i jak je interpretować.
Live demo
Poniżej embedded preview UI panel z RunPod sandbox. Klik "Show live" żeby uruchomić iframe — DCR UI z 5 modelami + Drupal RAG corpus. Login: admin / test123. (Demo może być offline jeśli pod EXITED.)
Steps
-
Wymagania: Python 3.12+, Docker, ~5 GB free disk dla startu (więcej dla RAG corpus i modeli).
bashgit clone https://github.com/bartek-filipiuk/local-codereviewer.git cd local-codereviewer uv sync --extra indexer --extra serve # Sanity check uv run drupal-codereviewer --help | head -10
-
Qdrant trzyma 1968 chunków Drupal-specific (core docs, contrib, OWASP, security advisories) dla RAG retrieval.
bashmake qdrant-up # Verify (powinno zwrócić JSON z listą collections) curl -s http://localhost:6333/collections
-
Crawluje Drupal core + top contrib modules + api.drupal.org + coding standards + OWASP. Następnie buduje AST graph + ingestuje do Qdrant.
bashmake crawl # ~2-3 GB drupal data make index # AST + RAG indexing # Verify (powinno pokazać ~1967 chunków) make rag-stats
Tip: jeśli chcesz pominąć ten krok i mieć ready-to-go corpus, użyjscripts/restore.shz naszego pre-built backup.tar.gz (32 MB). Pyramidaj o link. -
Pipeline smoke check z mock LLM (no GPU required). Wypisze markdown review syntetycznego XSS PR.
bashmake demo
Powinno wyświetlić finding z
severity=high,category=security,cwe=CWE-79. Jeśli widzisz to — pipeline działa, czas na real LLM. -
Option A — local Ollama (jeśli masz GPU 24+ GB VRAM)
bashollama pull qwen3-coder:30b # 18 GB ollama list curl -sL https://git.drupalcode.org/project/pathauto/-/merge_requests/33.diff > /tmp/example.diff uv run drupal-codereviewer review --diff-file /tmp/example.diff --model qwen3-coder:30b
Option B — RunPod sandbox (no local GPU, ~$0.69/h secure 4090)
Tworzy on-demand 4090 z volume persistent. Patrz runpod/ w repo.
bash# Konfiguracja w runpod/.env (wymaga RUNPOD_API_KEY) cp runpod/.env.example runpod/.env # Edytuj runpod/.env: RUNPOD_API_KEY, UI_PASS, GITLAB_DRUPAL_TOKEN # Deploy + setup (~30 min, w tle pull modeli) bash runpod/setup-pod.sh bash runpod/pull-models.sh # Get public URL bash runpod/start-services.sh
-
Markdown output zawiera findings z TRACE methodology. Przykład real finding (z core MR):
markdown · sample finding### 🔴 HIGH | security | line 446 Potential SQL injection via unescaped table name. TRACE: - Source: $type_name from user-controlled keyword - Sink: db_query("SELECT * FROM $type_name") line 446 - Sanitization: none - Exploit: GET /search?type=users; DROP TABLE -- → SQL injection CWE-89, OWASP A03:2021Severity ladder
- 🔴 CRITICAL / HIGH — block merge, fix przed merge
- 🟡 MEDIUM — review carefully, prawdopodobnie fix
- 🔵 LOW — improvement, opcjonalnie
- ⚪ INFO — info-level, można ignorować
Trust matrix
Model robi DOBRZE: Security findings z TRACE + exploit steps · Drupal idiom violations (missing DI, missing cache metadata, procedural hooks) · Deprecation warnings · Performance issues (nested loops).Model robi GORZEJ: Subjective architectural suggestions ("perhaps use X interface") · Module-specific patterns ("follow pattern from commerce_X") · Cross-PR context (model widzi tylko diff). -
Z UI panel (jeśli używasz RunPod sandbox) — wklej URL PR/MR z GitHub/GitLab/Gitea, model fetch'uje diff sam. Albo z CLI:
bash · CLIcd /path/to/my/drupal/module # Diff aktualnej feature branch vs main uv run drupal-codereviewer review --git-diff main...HEAD --model qwen3-coder:30b # Lub: review konkretnego PR URL (przez UI) # 1. Add GitHub/GitLab/Gitea token w Settings → Tokens # 2. Paste PR URL w /review → "Start review"
-
Dla większych PRs / krytycznych zmian włącz Pass 2.5 — SGCR-style alternative suggestions z RAG verification (3× dłużej ale +5-8pp recall).
bashuv run drupal-codereviewer review --git-diff main...HEAD \ --model qwen3-coder:30b \ --propose-verifyDodaje suggestions typu "consider using EntityFactoryInterface instead of direct instantiation" — tylko te które są zweryfikowane przeciwko real Drupal patterns w RAG (anti-halu guard).
FAQ
Czy mój kod wychodzi gdzieś?
Z lokalną Ollama — nie, wszystko zostaje na maszynie. Z RunPod sandbox — kod idzie do twojej instancji RunPod (która sama hostuje Ollama), ale nie wraca do żadnego cloud API. To on-premise w sensie sieci klienta.
Ile to kosztuje?
Lokalnie z GPU — $0. RunPod community 4090 — ~$0.34/h. Typowy review PR 5-10 min = ~$0.06-0.12. Stop instance między reviewami (volume persists).
Czy zastąpi mojego maintainera?
Nie. Model łapie obvious security + idiom violations. Maintainer dalej robi architectural decisions + business context review. Model jest complementem — różny angle (security/DI/cache vs maintainer style/idioms).
Co jeśli model halluje?
Pass 2.5 (--propose-verify) ma anti-halu guards (RAG verification). Każde finding ma file:line którego można szybko zweryfikować w kodzie.
Czy działa z Drupal 10?
Tak. Pipeline jest version-agnostic. RAG zawiera 11.x docs ale 9.x/10.x code wciąż łapie obvious bugs. Specific 11.1+ patterns (OOP hooks #[Hook]) mogą generate false alarm na D9/D10.
Next steps
- Usage reference — pełen reference dla CLI flags + UI workflow
- Architecture — jak system działa wewnętrznie
- Security — threat model, compliance, audit log