Repository navigation
feat(validator): invoke the review engine directly + auto-close after N BLOCKs - #104
Conversation
… N BLOCKs Two coupled changes to the org-wide pr-validator workflow. 1. DIRECT INVOCATION. Replace `charly review --plan "$REVIEW_PLAN_PATH"` with `charly review`. The engine that is welded into the pinned charly release assembles the complete PR context and makes ONE model call — the plan executor (and its `review-plan.yml` that wrapped a single review step) is gone. The old engine also accepts the plain form, so this is safe to land BEFORE the weld. REVIEW_PROMPT_PATH is still exported for a future engine that reads one; the current engine's rulebook is embedded in the plugin (no file read). 2. AUTO-CLOSE after N BLOCKs (AI_REVIEW_AUTO_CLOSE_AFTER, default 5; 0 disables). A PR that keeps collecting BLOCK verdicts — because the author re-pushes without fixing the raised findings — grows its own comment thread, which is exactly what drives the reviewer's context into a runaway. The step counts the PR's own "## Review — BLOCK" verdict comments (no external state), and at the threshold posts a notice telling the author to open a NEW PR with every finding already fixed, then closes the PR. It runs BEFORE the BLOCK gate so the close + notice land before the check fails. R10 coverage (the gate's own harness, .github/tests/validator-gate-harness.py): both branches are asserted by new scenarios — at-threshold (closes + posts the notice) and below-threshold (does not). The harness runs the REAL `run:` bodies against fakes for charly/gh; 238 assertions across 15 scenarios, ALL PASS. Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (fully tested and validated)
[step: review]Review — BLOCKHead SHA: Change class: CI workflow — the validator gate itself — plus its own test harness. This is security machinery (T4). Security screen (T4): the PR rewrites the validator's engine invocation and adds an autonomous PR-closing action to the gate. Both are changes to the machinery that enforces the rulebook, and the body carries no explicit maintainer sign-off for either. Blocks
Comment intake: Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
…rm proof Round 2 — addresses all three findings from the validator BLOCK on the first head. 1. R10/B18 — the auto-close count was WRONG for multi-page threads, and the harness could not catch it. `gh api --paginate ... --jq '[.[]|…]|length'` applies the filter PER PAGE (that is what `--slurp` is for), so a thread with >30 comments yielded several numbers joined by newlines; the numeric guard rejected it and SILENTLY DISABLED auto-close on exactly the long threads the feature exists to bound. Verified live: a per_page=10 request printed `10\n10\n10…`. Fix: `gh api --paginate | jq -s '[.[][] | …] | length'` collects the pages into ONE array first (verified: 53 with and without forced pagination). The harness's fake gh now emits REAL JSON pages and a new `auto-close-multi-page` scenario (5 BLOCKs among 60 others at page size 30) asserts the PR is still closed — it FAILS against the old per-page form. 2. R5/B5 — the new header comment was false and contradicted the body: it claimed "the prompt is EMBEDDED in the plugin, so this workflow passes no plan/prompt path", while the diff still passes REVIEW_PROMPT_PATH. The CURRENTLY-pinned engine DOES read that env (verified: `strings` on the v2026.263.2131 plugin finds REVIEW_PROMPT_PATH, and a live run used it). Corrected both comments to say the pinned engine reads the file, the next (embedded-rulebook) engine ignores it, and the env is removed in the pin-bump that welds it. 3. A2/A3/R10 — the load-bearing "the old engine also accepts the plain form" claim is now PROVEN, not asserted. Ran the PINNED release plugin (v2026.263.2131) with the plain `charly review pr 7 --repo …` form (no --plan): it completed and produced `Verdict: BLOCK` (pasted in the body). Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (fully tested and validated)
[step: review]Review — BLOCKHead SHA: Change class: CI workflow — the validator gate itself — plus its own test harness ( Security screen (T4): the PR rewrites the gate's engine invocation and adds an autonomous PR-closing action to the gate. The gate itself is preserved ( Blocks
Comment intake: one prior comment (id Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
The diff's comments said the embedding release is 'not yet welded' while the body said the pinned release already runs the ONE-call engine. Reconciled: the currently-pinned engine reads REVIEW_PROMPT_PATH and the plain 'charly review --out' form is accepted by BOTH it and the new engine, so the invocation is weld-independent; REVIEW_PROMPT_PATH is the one transitional env, removed when opencharly/charly#626 (plugin-review v2026.264.1425) is welded. Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (fully tested and validated)
validator INCONCLUSIVE — no review verdict was produced (not a BLOCK; no code finding)The gate could not obtain a review verdict on this run, so it produced no code finding. This is not a BLOCK and the PR is not being rejected — but the required check stays RED on purpose: unreviewed code must never merge.
Root cause. The ENGINE sent no generation bound ( Durable remedy.
A run that produced no verdict keeps this required check RED: unreviewed code must never merge. Diagnostics (tail of the review log) |
Audit found the workflow forwarded only 13 of the env knobs the review engines
read. Both the currently-pinned engine (plugin-review v2026.263.1956) and the new
ONE-call engine (v2026.264.1425) read MORE, and the union must be forwarded or an
operator cannot configure them from an org variable:
new engine missing: AI_REVIEW_CONTEXT_MARGIN, _CONTEXT_TOKENS,
_FREQUENCY_PENALTY, _PRESENCE_PENALTY, _PROMPT_EXTRA, _POST_COMMENT,
_STOP, _TEMPERATURE, _TOP_P
pinned engine missing: AI_REVIEW_CONTEXT_MARGIN, _CONTEXT_TOKENS,
_SESSION_ID, _TEMPERATURE
CRITICAL: AI_REVIEW_TEMPERATURE and AI_REVIEW_TOP_P were NOT forwarded, so the
sampling values could not be set (or tuned) from an org variable at all. They are
now forwarded, and the engine's vendor-recommended defaults (temp=1.0,
top_p=0.95) plus the repetition-guard penalties are all org-tunable.
AI_REVIEW_OUT is deliberately NOT forwarded (the step passes --out explicitly).
Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (fully tested and validated)
[step: review]Review — BLOCKHead SHA: Change class: CI workflow (the validator gate itself) + its own test harness — security machinery (T4). Blocks
Comment intake
Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
…cile the comment count - The review step name said 'one model call', which describes the welded embedded-prompt engine, not the engine actually shipping in the org pin. Name the shipping behaviour (assemble context, verdict). - The header said 'ONE PR comment'; a policy auto-close step posts a second, distinct notice. Say 'ONE review comment' and note the separate notice. - The weld PR (charly#626) is merged; reword the REVIEW_PROMPT_PATH note to the pin state rather than the prospective weld.
validator INCONCLUSIVE — no review verdict was produced (not a BLOCK; no code finding)The gate could not obtain a review verdict on this run, so it produced no code finding. This is not a BLOCK and the PR is not being rejected — but the required check stays RED on purpose: unreviewed code must never merge.
Root cause. The ENGINE sent no generation bound ( Durable remedy.
A run that produced no verdict keeps this required check RED: unreviewed code must never merge. Diagnostics (tail of the review log) |
…e; cover it The headline bound $THRESHOLD while the body said $blocks, so a PR with 8 BLOCKs read '## Auto-closed: 5 unanswered BLOCK verdicts' next to 'received **8**' — a false statement emitted by the gate. Bind the headline to $blocks and add the auto-close-over-threshold-count scenario (block_count=8), which FAILS on the old args and passes on the fix. 259 assertions / 17 scenarios. Also correct the ACTIVE-knob inventory to the real org pin (v2026.263.2131 welds [email protected]) and mark the sampling/penalty knobs inert until the pin moves.
validator INCONCLUSIVE — no review verdict was produced (not a BLOCK; no code finding)The gate could not obtain a review verdict on this run, so it produced no code finding. This is not a BLOCK and the PR is not being rejected — but the required check stays RED on purpose: unreviewed code must never merge.
Root cause. The ENGINE sent no generation bound ( Durable remedy.
A run that produced no verdict keeps this required check RED: unreviewed code must never merge. Diagnostics (tail of the review log) |
validator INCONCLUSIVE — no review verdict was produced (not a BLOCK; no code finding)The gate could not obtain a review verdict on this run, so it produced no code finding. This is not a BLOCK and the PR is not being rejected — but the required check stays RED on purpose: unreviewed code must never merge.
Root cause. The ENGINE sent no generation bound ( Durable remedy.
A run that produced no verdict keeps this required check RED: unreviewed code must never merge. Diagnostics (tail of the review log) |
…ured strings The header marked AI_REVIEW_TEMPERATURE INERT, but `strings` on the pinned bundle (v2026.263.2131 -> [email protected]) finds it — it is ACTIVE. Also drop the false pointer 'the evidence is in this PR's body' (the body must carry that strings output, and now does).
validator INCONCLUSIVE — no review verdict was produced (not a BLOCK; no code finding)The gate could not obtain a review verdict on this run, so it produced no code finding. This is not a BLOCK and the PR is not being rejected — but the required check stays RED on purpose: unreviewed code must never merge.
Root cause. The ENGINE sent no generation bound ( Durable remedy.
A run that produced no verdict keeps this required check RED: unreviewed code must never merge. Diagnostics (tail of the review log) |
Summary
Three coupled changes to the org-wide
charly/pr-validatorworkflow.1. Direct engine invocation (drop the
--planexecutor)charly review --plan "$REVIEW_PLAN_PATH"→charly review --out /tmp/review.txt.The plain form is accepted by both the pre-change engine and the embedded-prompt engine, so the invocation is weld-independent: safe to land before the org pin moves. Measured against the pinned engine (see How tested).
REVIEW_PROMPT_PATHis still passed because the charly release in the org pin reads its rulebook from that file; the embedded-prompt engine (welded byopencharly/charly#626, merged) ignores it, so it is vestigial once the orgCHARLY_VERSIONpin moves and is dropped in the same change that bumps the pin.2. Auto-close after N BLOCKs (configurable, default 5)
A PR that keeps collecting
BLOCKverdicts — because the author re-pushes without fixing the findings — grows its own comment thread, which drives the reviewer's context into a runaway. The step counts the PR's own## Review — BLOCKverdict comments and, at the threshold (AI_REVIEW_AUTO_CLOSE_AFTER, default5;0disables), posts a notice telling the author to open a NEW PR with every finding fixed, then closes it. It runs before the BLOCK gate.3. Forward the FULL review-knob surface
The review step forwarded only a subset of the knobs the engine reads, so operator variables for them never reached it. This change forwards the remainder as
${{ vars.X || '' }}(empty = the engine's own default, never a parse of zero). Reachability depends on the welded engine —stringsagainst the pinned bundle (v2026.263.2131→[email protected]) classifies each:AI_REVIEW_TEMPERATUREstringshit)AI_REVIEW_CONTEXT_TOKENS/AI_REVIEW_CONTEXT_MARGINAI_REVIEW_SESSION_IDAI_REVIEW_TOP_Pv2026.265.0505)AI_REVIEW_FREQUENCY_PENALTY/AI_REVIEW_PRESENCE_PENALTYAI_REVIEW_STOPAI_REVIEW_PROMPT_EXTRAAI_REVIEW_POST_COMMENTThe INERT knobs become ACTIVE when the org
CHARLY_VERSIONpin moves to the release welding[email protected](opencharly/charly#626, merged). Forwarding them now is forward-compatible: the engine ignores unknown env.AI_REVIEW_OUTis deliberately not forwarded — the review step owns that path. A defined-empty var is treated as unset by the engine (getenvAnyreturns""and every knob caller guards on non-empty), so|| ''means "no override".How tested
Change 1 — the exact changed invocation against the pinned release
Ran the pinned release plugin (
v2026.263.2131) through the workflow's exact form —charly review --out …, no--plan:So the changed invocation executes on the release in the org pin. (Multi-turn is expected there: that engine still has the tool loop; the embedded-prompt engine welded by #626 makes it ONE call.)
Change 3 — the
stringsreachability classification (real output)Against the org-pin bundle (
v2026.263.2131, downloaded from the release):This is the evidence the header's ACTIVE/INERT inventory cites.
Change 2 — the auto-close branches, and the count fix (the gate's own harness)
The harness caught two real defects during development: (a) the auto-close step was first placed after
Gate (BLOCK)(which exits 1), so absentalways()it would have been skipped forever — it is now before the gate; (b) the auto-close notice rendered the threshold as the headline count instead of the actual$blocks, so a PR with 8 BLOCKs read "Auto-closed: 5 unanswered BLOCK verdicts" beside "received 8". The headline now binds$blocks, and the newauto-close-over-threshold-countscenario (block_count=8) FAILS on the old args and passes on the fix. The harness is wired in via.github/workflows/validator-harness.ymlon every pull_request.The multi-page count (reproduced then fixed)
Rulebook compliance
/charly-internals:git-workflow+/charly-internals:agentsloaded.AI_REVIEW_OUTis deliberately excluded.gh api --paginate(page-correct), not a per-page shortcut; no sleep/retry.REVIEW_PROMPT_PATHnote states the pin state; and the ACTIVE/INERT inventory now matches the measuredstringsoutput (temperature was mis-labelled INERT, corrected to ACTIVE).feat/branch; no force-push; no direct push tomain.validator-harnesspasses (259 assertions / 17 scenarios) on the final tree.N/A — no generated artifact; no binary built by this repo.Change classification
validator-harness(259 assertions) + the pinned-release plain-form run + thestringsreachability classification.analysed on a live system— the changed invocation ran against the pinned release and the harness exercises the real workflow bodies.Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (analysed on a live system)