Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 125 additions & 4 deletions .github/workflows/koru-code-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ jobs:
name: koru / code-review
if: github.event_name == 'workflow_dispatch' || github.event.pull_request.draft == false
runs-on: ubuntu-latest
timeout-minutes: 20
timeout-minutes: 10
env:
KORU_VERSION: '0.1.444'
VALLM_VERSION: '0.1.94'
REVIEW_MODEL: openrouter/deepseek/deepseek-v4-pro
REVIEW_MODEL: openrouter/google/gemini-3.1-pro-preview
VALLM_REVIEW_MAX_TOKENS: '8192'
VALLM_REVIEW_TIMEOUT_SECONDS: '420'
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
BASE_SHA: ${{ inputs.base_sha || github.event.pull_request.base.sha }}
HEAD_SHA: ${{ inputs.head_sha || github.event.pull_request.head.sha }}
Expand Down Expand Up @@ -105,6 +107,40 @@ jobs:
shell: bash
run: |
set -euo pipefail
compat_dir="$RUNNER_TEMP/vallm-compat"
mkdir -p "$compat_dir"
cat > "$compat_dir/sitecustomize.py" <<'PY'
"""Pinned compatibility boundary for Vallm 0.1.94."""

from __future__ import annotations

import os

import litellm
import tree_sitter_language_pack


_original_completion = litellm.completion
_original_get_parser = tree_sitter_language_pack.get_parser


def _bounded_completion(*args, **kwargs):
kwargs["max_tokens"] = int(os.environ["VALLM_REVIEW_MAX_TOKENS"])
kwargs["timeout"] = float(os.environ["VALLM_REVIEW_TIMEOUT_SECONDS"])
# Provider HTTP errors, including 404, must fail immediately.
kwargs["num_retries"] = 0
return _original_completion(*args, **kwargs)


def _normalized_get_parser(language):
if isinstance(language, str):
language = language.lower()
return _original_get_parser(language)


litellm.completion = _bounded_completion
tree_sitter_language_pack.get_parser = _normalized_get_parser
PY
command_path="$RUNNER_TEMP/koru-review-command"
cat > "$command_path" <<'BASH'
#!/usr/bin/env bash
Expand All @@ -118,12 +154,97 @@ jobs:
export VALLM_LLM_PROVIDER=litellm
export VALLM_LLM_MODEL="$REVIEW_MODEL"
export VALLM_LLM_BASE_URL=https://openrouter.ai/api/v1
vallm batch "${files[@]}" \
--semantic --security --regression \
export PYTHONPATH="${VALLM_COMPAT_DIR}${PYTHONPATH:+:${PYTHONPATH}}"
set +e
timeout --signal=TERM "${VALLM_REVIEW_TIMEOUT_SECONDS}s" \
vallm batch "${files[@]}" \
--semantic --security \
--model "$REVIEW_MODEL" \
--format json --output .koru-review/vallm --show-issues
vallm_exit="$?"
set -e
if [[ "$vallm_exit" == '124' || "$vallm_exit" == '137' ]]; then
printf '{"summary":{"total_files":%s,"passed":0,"failed":%s,"success_rate":0.0},"files":[],"failed_files":[{"error":"review timed out after %s seconds"}]}\n' \
"${#files[@]}" "${#files[@]}" "$VALLM_REVIEW_TIMEOUT_SECONDS" \
> .koru-review/vallm/validation.json
exit "$vallm_exit"
fi
if [[ ! -f .koru-review/vallm/validation.json ]]; then
echo "KORU-REVIEW-003: Vallm exited ${vallm_exit} without a report." >&2
exit 1
fi
python - "$vallm_exit" <<'PY'
from __future__ import annotations

import json
from pathlib import Path
import sys


report_path = Path(".koru-review/vallm/validation.json")
report = json.loads(report_path.read_text(encoding="utf-8"))
expected_paths = {
line.strip()
for line in Path(".koru-review/files.txt").read_text(encoding="utf-8").splitlines()
if line.strip()
}
files = report.get("files") if isinstance(report.get("files"), list) else []
reviewed_paths = {
item.get("path") for item in files if isinstance(item, dict) and item.get("path")
}
failed_files = []
passed = 0
for item in files:
if not isinstance(item, dict):
failed_files.append({"error": "malformed Vallm file result"})
continue
issues = item.get("issues") if isinstance(item.get("issues"), list) else []
blocking = []
advisory = []
for issue in issues:
if not isinstance(issue, dict):
blocking.append({"rule": "report.malformed", "severity": "error"})
continue
rule = str(issue.get("rule", ""))
severity = str(issue.get("severity", "")).lower()
if rule == "semantic.llm_judge" and severity in {"info", "warning"}:
advisory.append(issue)
else:
blocking.append(issue)
item["blocking_issues_count"] = len(blocking)
item["advisory_issues_count"] = len(advisory)
if item.get("verdict") == "pass" and not blocking:
passed += 1
else:
failed_files.append({
"path": item.get("path"),
"error": f"blocking verdict/findings: {len(blocking)}",
})
missing_paths = sorted(expected_paths - reviewed_paths)
failed_files.extend({"path": path, "error": "missing Vallm result"} for path in missing_paths)
unexpected_paths = sorted(reviewed_paths - expected_paths)
failed_files.extend({"path": path, "error": "unexpected Vallm result"} for path in unexpected_paths)
total = len(expected_paths)
failed = total - passed
report["summary"] = {
"total_files": total,
"passed": passed,
"failed": failed,
"success_rate": passed / total if total else 1.0,
}
report["failed_files"] = failed_files
report["policy"] = {
"semanticInfoAndWarnings": "advisory when file verdict is pass",
"allOtherFindings": "blocking",
"providerErrors": "blocking without retry",
"originalVallmExitCode": int(sys.argv[1]),
}
report_path.write_text(json.dumps(report, indent=2) + "\n", encoding="utf-8")
raise SystemExit(0 if failed == 0 and not failed_files else 1)
PY
BASH
chmod 0700 "$command_path"
printf 'VALLM_COMPAT_DIR=%s\n' "$compat_dir" >> "$GITHUB_ENV"
printf 'KORU_REVIEW_COMMAND=%s\n' "$command_path" >> "$GITHUB_ENV"

- name: Run one bounded Koru review round
Expand Down
85 changes: 81 additions & 4 deletions project/ticket-018/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,35 @@ The user requested automated code review through Koru. The implementation will
add a read-only GitHub check named `koru / code-review`, run for pull requests
and explicit historical-review dispatches. It will pin Koru 0.1.444 and Vallm
0.1.94, select only changed supported source files, and let Koru execute one
bounded Vallm review round. The review combines deterministic syntax,
complexity and security checks with an OpenRouter semantic judge supplied by
the existing organization-level `OPENROUTER_API_KEY` secret.
bounded Vallm review round. The review runs deterministic complexity and
security checks, attempts Vallm syntax analysis, and uses an OpenRouter
semantic judge supplied by the existing organization-level
`OPENROUTER_API_KEY` secret.

The semantic judge is `google/gemini-3.1-pro-preview`, selected from the current
live `llm-code-benchmark/v1` report because it is the only compared model that
qualified for both repair and validation (repair 1.000, validation 0.929,
security 1.000 and availability 100%). Vallm's Python-oriented `--regression`
mode is intentionally not used for TypeScript: the separate required `verify`
job owns TypeScript compilation and the repository's 335-test regression
suite. Koru remains the read-only semantic, complexity and security review
boundary. Vallm still attempts syntax analysis, but 0.1.94 passes the uppercase
language enum `TYPESCRIPT` to a parser that accepts lowercase `typescript`.
The workflow now applies a pinned lowercase compatibility boundary before
parsing and still blocks if any `syntax.unsupported` finding remains.

The repaired execution budget is explicit and layered. GitHub terminates the
whole job after 10 minutes; Vallm and its LiteLLM request are bounded to 420
seconds so report construction, artifact upload and attestation retain roughly
three minutes of the job budget after an active-review timeout (less the setup
time already consumed). Responses are capped at 8192 tokens. LiteLLM retries are
disabled, therefore provider HTTP errors such as 401, 402, 403 or 404 fail
immediately rather than consuming the timeout. A pinned compatibility boundary
lowercases Vallm 0.1.94's language ID before tree-sitter parsing. Semantic
`info` and `warning` findings remain in the attested report as advisory when
Vallm's file-level verdict is `pass`; semantic errors and every syntax,
complexity, security, provider, malformed/missing-result or timeout finding
remain blocking.

The workflow will never use `pull_request_target`, check out untrusted code
with a write-capable token, modify source, auto-fix, commit, push or submit a
Expand Down Expand Up @@ -148,7 +174,7 @@ agent self-approved.
- [x] AC-20: Koru 0.1.444 runs exactly one read-only Vallm 0.1.94 review round
over changed supported source files; auto-fix, commit, push and mutable
dependency versions are absent.
- [x] AC-21: Deterministic syntax/complexity/security checks and semantic
- [ ] AC-21: Deterministic syntax/complexity/security checks and semantic
LLM-as-judge review fail closed on findings, missing credentials,
malformed output or provider failure, with no secret value in logs.
- [x] AC-22: The structured report records repository, base/head SHA, selected
Expand Down Expand Up @@ -234,6 +260,57 @@ remain historical evidence, not evidence for AC-11..AC-17.
artifact upload and attestation still succeeded. The attested report digest
is `sha256:fa0f4d0c1f780bb8d21f56ca74d8ae901e184fb4996f9e84832a87846adfc1d8`.
No credential value appears in the workflow output.
- Pull request #3 exposed that the original Koru configuration had drifted from
the current benchmark winner. Run `30712589077` still used
`openrouter/deepseek/deepseek-v4-pro`; Vallm also attempted `pytest` for the
TypeScript diff and the semantic request failed with OpenRouter 401 `User not
found`. The workflow now uses the qualified Gemini model and delegates
regression to the already passing required `verify` job. The 401 cannot be
repaired in repository code: a trusted repository or organization owner must
rotate the `OPENROUTER_API_KEY` Actions secret and rerun the exact commit.
- Pull request #4 run `30712853708` passed the read-only Koru gate for commit
`a4eb0f9`. Its attested `t2c.koru-code-review/v1` report records
`openrouter/google/gemini-3.1-pro-preview` and an empty supported-source set,
so no provider request or cost occurred. This proves the deployed workflow
configuration and no-source path; it does not supersede the required live
rerun after secret rotation.
- Workflow dispatch `30713017811` then exercised that workflow against the
exact two-file TypeScript diff from pull request #3. The report records the
Gemini judge and no longer contains a regression/`pytest` error. It rejects
fail-closed because OpenRouter still returns 401 `User not found`; it also
retains Vallm 0.1.94's `TYPESCRIPT` parser warning. Report construction,
artifact upload and provenance attestation passed. AC-21 therefore remains
open until the secret is rotated and the upstream parser defect is fixed or
replaced with equivalent deterministic Koru-job evidence.
- The user subsequently authorized repository-secret rotation. A fresh
repository-level `OPENROUTER_API_KEY` was written through `gh` stdin on
2026-08-01 without exposing its value; it takes precedence over the stale
organization secret only for `semcod/todo2code`. Dispatch `30714664770`
proves the credential and increased provider limit now work: Gemini reviewed
both TypeScript files with no provider error. Both file-level verdicts are
`pass`, but Koru correctly remains non-passing under the current fail-on-any-
finding policy because Vallm emits its known uppercase-language parser
warning plus advisory whole-file findings unrelated to the model-default
diff. The remaining AC-21 blockers are review context/parser policy, not the
GitHub credential.
- The timeout/policy repair bounds the complete job to 10 minutes and the
active review to 420 seconds, caps output at 8192 tokens, disables retries
(including 404), normalizes the Vallm TypeScript language ID and separates
advisory semantic warnings from blocking deterministic/provider/semantic
errors without removing any finding from the attested JSON.
- Repaired workflow dispatch `30746421293` reviewed the exact pull request #3
range `2e87205..6b79527` with Gemini in 1 minute 24 seconds. Its attested
report selects `src/config/env.ts` and `test/config-env.test.ts`, records 2/2
passed, no failed files, no parser/provider finding and exit 0. All five
whole-file semantic observations remain visible as advisory; the policy
records Vallm's original exit 2 before deterministic normalization.
- A follow-up exact-stack LiteLLM probe used a local HTTP endpoint: HTTP 404
produced `NotFoundError` after about 705 ms with exactly one request and the
8192-token ceiling intact. A slow endpoint with a 0.5-second probe ceiling
produced `Timeout` after about 799 ms with exactly one request. Fresh local
`npm run verify` and Docker `e2e-core` pass; Docker `e2e-full` still stops at
the separately attributed stale Rust lock with `cargo fetch --locked` exit
101, without any ticket-018 change to the SDK.
- Repository ruleset `20186914` is staged with no bypass actors and
`current_user_can_bypass: never`. It targets the default branch, requires a
pull request, dismisses stale review evidence, rejects deletion/force-push,
Expand Down
Loading
Loading