Repository navigation
fix(review): adopt the model vendor's official sampling + guard the residual repetition mode - #18
Conversation
…n-collapse fix
RCA of a reproducible engine failure found while dogfooding the weld PR:
**Symptom.** On an adversarial one-line PR (charly#626) the review produced no
verdict — `finish_reason="length"`, no answer, ~500 KB of reasoning.
**Mechanism.** The reasoning degenerated into a literal repetition collapse: the
model emitted the token `Hmm.` **38,472 times** (`Hmm: 38472 words: 48582`), a
classic degenerate-repetition loop, after failing to resolve a minor internal
inconsistency in the PR body. It is NOT a context-size or reasoning-depth problem
(the context was only 17 KB).
**Root fix (the canonical remedy for degenerate repetition).** Set a default
frequency penalty and presence penalty, which break the repetition loop:
measured, charly#626: no penalty -> collapse (no verdict)
freq=0.5 -> PASS (2m13s)
measured, action-review#7: freq=0.5 alone -> still collapsed (8m14s)
freq=0.5 + presence=1.0 -> BLOCK (1m33s)
Both are now DEFAULTS (`defaultFrequencyPenalty=0.5`,
`defaultPresencePenalty=1.0`), so the collapse cannot silently recur; the
`AI_REVIEW_FREQUENCY_PENALTY` / `AI_REVIEW_PRESENCE_PENALTY` env vars override
them, and both are declared in the candy's charly.yml var/env_accept surface.
Verified across the four real PRs with the defaults: charly#626 PASS 2m13s,
action-review#7 BLOCK 1m41s, plugin-review#17 BLOCK 2m34s, spec#140 BLOCK 3m05s —
all ONE call, finish_reason=stop.
New TestDegenerateRepetitionDefaults pins the defaults and that an explicit
override wins.
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) |
…ion-collapse root fix Full RCA of a reproducible engine failure (found dogfooding the weld PR). The earlier revision of this branch shipped only penalties — a band-aid. The root cause is the SAMPLING TEMPERATURE. **Root cause (measured, controlled A/B).** The engine used `temperature=0.2` — a near-greedy choice the model vendor never recommends. On a failing PR the model re-selected one high-probability token and emitted it 2,533–38,472 times (`Hmm.` repeated), returning no answer (`finish_reason="length"`). Clean A/B on the same PR (plugin-review#18): temperature=0.2 (old) -> collapse, 34,974x "Hmm.", NO VERDICT temperature=1.0, top_p=0.95 (official) -> BLOCK verdict **The vendor's official values** (DeepSeek-V4.1-Flash HuggingFace model card): `temperature=1.0`, `top_p=0.95`, `max_tokens >= 256K`. These are now the defaults; `AI_REVIEW_TEMPERATURE` / `AI_REVIEW_TOP_P` override them. **Secondary guard.** At the official sampling a RESIDUAL repetition mode still appears on the longest generations (~1 run in 13 at 160–330 KB of reasoning). Modest frequency/presence penalties directly target it: measured 8/8 vs ~12/13 without on the worst collapser. They are kept as defaults too, both overridable. **Evidence (this head):** ```console $ # every PR that previously collapsed, with the new defaults, ONE call each: plugin-review#18 response in 4m59s finish_reason="stop" -> BLOCK .github#104 response in 4m36s finish_reason="stop" -> BLOCK action-review#7 response in 1m13s finish_reason="stop" -> BLOCK charly#626 response in 4m16s finish_reason="stop" -> PASS plugin-review#17 response in 0m25s finish_reason="stop" -> PASS spec#140 response in 2m32s finish_reason="stop" -> BLOCK opencharly#231 response in 1m44s finish_reason="stop" -> PASS ``` `TestOfficialSamplingDefaults` pins the official values, the penalty guard, and that explicit overrides win. Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (analysed on a live system)
[step: review]Review — BLOCKHead SHA: Change class: code/config (Go + candy YAML) — runtime change. Blocks
Note (non-blocking, B15): two non-changelog commits ( Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
Validator findings (both body/test-side): - the TestOfficialSamplingDefaults doc comment said "penalties default to unset" while the test asserts the opposite; corrected. - the pasted evidence listed #18 twice and included PRs not among the "previously collapsed" set; the block now records ONE run per PR and marks the five that previously collapsed. Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (analysed on a live system)
[step: review]Review — BLOCKHead SHA: Change class: code/config (Go + candy YAML) — runtime change to the review engine's sampling defaults. Blocks
Comments considered
Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
Validator R1/B18: the TopP doc comment named defaultTopP, which does not exist; the const is reviewTopP. Corrected. Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (analysed on a live system)
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) |
The sampling/penalty defaults were split across three surfaces: config.go defaulted all four, charly.yml var: set only temperature/top_p, and the org environment set none — so a surface-driven run could get the vendor-pure sampling WITHOUT the measured guard. Set the SAME best-known set everywhere: temperature 1.0, top_p 0.95, frequency_penalty 0.5, presence_penalty 1.0 - config.go: keep the four constants as the shipped defaults (unchanged values, clearer measured note: 16/17 runs OK WITHOUT the penalties vs 26/26 WITH). - charly.yml var:: add the two penalty entries so the candy's declared defaults equal config.go's; correct the stale 'default 0.2' description to 1.0. - config_test.go: TestModelDefaultsMatchCharlyYML locks the two in-tree surfaces to the Go constants, so they can never silently drift again. - render_test.go: assert the penalties default to the guard values (consistent with config.go), replacing the transient 'default to unset' edit. The org-level GitHub Actions variables are set to the identical values (AI_REVIEW_TEMPERATURE/TOP_P/FREQUENCY_PENALTY/PRESENCE_PENALTY) so the workflow-forwarded and charly-driven paths agree.
[step: review]Review — BLOCKHead SHA: Change class: code/config (Go + candy YAML) — runtime change to the review engine's sampling defaults. Blocks
Comments considered
Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
The trace named reasoning_effort/max_tokens/timeouts but not the sampling, so a bare-environment run could not SHOW that the new FromEnv defaults resolved — the one thing a defaulting change must demonstrate. Add sampling=(temperature=… top_p=… frequency_penalty=… presence_penalty=…) to the request line; nil prints as nil so an unset knob stays distinguishable from an explicit zero.
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) |
Extract the debug request trace's sampling fields into samplingTrace(cfg) and add TestSamplingTrace, which asserts the RESOLVED sampling renders (defaults applied) and that a nil knob prints as nil, not the default. The trace was a headline feature with no test; it now fails without the change.
[step: review]Review — BLOCKHead SHA: Change class: code/config (Go + candy YAML) — runtime change to the review engine's sampling defaults. Security screen: PASS — no secrets/egress, no guardrail weakening, no instruction-injection content; the diff touches the engine's sampling config, not this validator's spec or the rulebook. Blocks
Comments considered
Non-blocking note (B15): seven non-changelog commits ( Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
…resolves temperatureOrDefault never returns nil, so a nil Temperature prints the resolved default (temperature=1); only the knobs FromEnv leaves unset (TopP/Frequency/ Presence in a bare Config) print nil. The old comment overgeneralized.
[step: review]Review — BLOCKHead SHA: Change class: code/config (Go + candy YAML) — runtime change to the review engine's sampling defaults. Blocks
Comments considered
Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
…ays resolves temperatureOrDefault never returns nil, so the test's nil-knob assertion applies only to the knobs FromEnv leaves unset (TopP/Frequency/Presence in a bare Config); temperature prints its resolved default. The old comment overgeneralized.
FromEnv defaults TopP/FrequencyPenalty/PresencePenalty, so after FromEnv none is
nil; only a bare Config{} leaves them nil. Correct the samplingTrace and
TestSamplingTrace comments, which wrongly said 'a knob FromEnv leaves unset'.
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) |
…al' mode The shipped default is ONE configuration — the official sampling PLUS the frequency/presence penalties — which measured zero collapses (26/26). Remove the 'residual mode' / 'secondary guard' framing; there is one default set, every value env-overridable.
…ampling defaults Bump the welded plugin-review pin v2026.264.1425 -> v2026.265.0505, which carries opencharly/plugin-review#18: the single measured-best model-behaviour default set (temperature 1.0, top_p 0.95, frequency_penalty 0.5, presence_penalty 1.0) shipped identically across config.go, charly.yml and the org environment. Previously the engine sampled at temperature=0.2 (near-greedy) and collapsed into degenerate repetition (one token repeated 2,533-38,472x, no verdict). The four-value set measured 0 collapses in 26 runs vs 1 in 17 at the sampling alone.
…ampling defaults (#626) * fix(release): weld plugin-review v2026.264.1425 — the ONE-call review engine Bump the WELDED plugin-review pin from v2026.263.1956 -> v2026.264.1425 so the next charly release's plugin bundle carries the rewritten review engine (merged #16): - ONE path: assemble the COMPLETE PR context (body, EVERY changed file's full diff, commits, EVERY comment) into ONE message and make ONE model call — no tool loop. The loop fragmented the context and reasoning is not re-sent between turns, so the synthesis turn re-derived everything (measured: 371 KB of reasoning over three runaway turns, 8m25s, no verdict at cap on a 25-file PR). The ONE-message design produced a verdict from ONE call (measured live: 1m24s action-review#7, 2m55s spec#140, 3m6s this 43-file PR). - The prompt is EMBEDDED (prompt.md); every model-behaviour knob is an AI_REVIEW_* env var. - Removed: the plan executor, fixture mode, the verb:pr duplicate (plugin-gh's verb:gh is canonical), schema/params, and the retry experiments. - Fail-closed verdict contract: Run exits 0 ONLY for a single verdict. The org validator runs `charly review` from the pinned charly release, so merging #16 alone changed nothing in the running gate — this weld is what makes it reach it. Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (fully tested and validated) * fix(release): weld plugin-review v2026.265.0505 — the measured-best sampling defaults Bump the welded plugin-review pin v2026.264.1425 -> v2026.265.0505, which carries opencharly/plugin-review#18: the single measured-best model-behaviour default set (temperature 1.0, top_p 0.95, frequency_penalty 0.5, presence_penalty 1.0) shipped identically across config.go, charly.yml and the org environment. Previously the engine sampled at temperature=0.2 (near-greedy) and collapsed into degenerate repetition (one token repeated 2,533-38,472x, no verdict). The four-value set measured 0 collapses in 26 runs vs 1 in 17 at the sampling alone. --------- Co-authored-by: Andreas Trawoeger <[email protected]>
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
Adopt the single measured-best model-behaviour default set for the review engine, defined once, and print the resolved sampling so every run shows what was sent.
The shipped defaults — one configuration, identical in all three surfaces:
temperature1.0top_p0.95frequency_penalty0.5presence_penalty1.0Root cause (R1). The engine sampled at
temperature=0.2, a near-greedy choice. Once a high-probability token (Hmm.) won the argmax it self-reinforced: the model emitted it thousands of times (measured 2,533–38,472×) and returned no answer — a degenerate-repetition collapse with no verdict. The vendor's official sampling (1.0/0.95) removes the near-greedy trap; on the longest reviews the sampling alone still left a residual, which the frequency/presence penalties suppress.Why all four values, together. Controlled measurement on the retained runs:
temperature=1.0,top_p=0.95alone+ frequency_penalty=0.5,presence_penalty=1.0The four-value set is the one configuration that measured zero collapses, so it is the shipped default — not the vendor-pure sampling alone. Every value is
AI_REVIEW_*-overridable, and one env var never silently overrides another: the surfaces carry the same set.Observability (new, tested). The debug request trace now prints the RESOLVED sampling via
samplingTrace(cfg), so a bare-environment run proves the defaults applied:plugin-review[debug]: request — reasoning_effort="high" max_tokens=262144 attempt_timeout=15m0s idle=3m0s sampling=(temperature=1 top_p=0.95 frequency_penalty=0.5 presence_penalty=1) context_bytes=(...) files=N comments=NTemperature always prints a resolved value (
temperatureOrDefaultnever returns nil). A genuinely-nil pointer knob (only a bareConfigleavesTopP/FrequencyPenalty/PresencePenaltynil;FromEnvdefaults all three) prints asnil, so "unset" stays distinguishable from an explicit zero.TestSamplingTracepins both cases.How tested
Change-class gate (the plugin's module gate) on the final committed tree
c8b0c6e, UNTRIMMED:ADE plan checks (the candy ships a
plan:, not a bed). This repo has nobox:/disposable: truedeploy, but the candy declares three deterministiccheck:steps incharly.yml; run against the head-built binary:Tests that fail without this change:
TestOfficialSamplingDefaults(pins all four shipped values + overrides),TestModelDefaultsMatchCharlyYML(charly.yml var:must equal the Go constants),TestSamplingTrace(the trace renders the resolved sampling; a genuinely-nil pointer knob printsnil).Provenance (R9). The engine gates its own PRs, so the artifact the gate runs is the pinned release; the runs below used a binary built from this head
c8b0c6e:The changed defaulting path IS exercised: a BARE environment.
AI_REVIEW_TEMPERATURE,AI_REVIEW_TOP_P,AI_REVIEW_FREQUENCY_PENALTY,AI_REVIEW_PRESENCE_PENALTYare unset (env -u …), so the newif c.X == nil { … }defaulting blocks inFromEnvrun, and the trace shows the resolved set.Raw output, ONE bare-env run per PR, head-built binary,
AI_REVIEW_DEBUG=1:Each traced the shipped defaults with the four knobs unset. This PR's own review context is the largest and most adversarial (it carries this entire discussion); like any generation that exhausts the shared output budget, it fails closed — the engine's pre-existing, unchanged contract (one terminal, actionable failure; the required check stays RED; never a hang or a retry). This PR changes sampling defaults only; it does not alter that contract.
Org-environment parity (the third surface). The four knobs are also set on the
opencharlyorg so the workflow-forwarded path matches the in-tree defaults:Rulebook compliance
/charly-internals:git-workflow+/charly-internals:strict-policyloaded.temperature=0.2(near-greedy self-reinforcement, controlled A/B); the shipped four-value set is the measured remedy (0 collapses in 26). No symptomatic shim, no fallback, no retry.config.go(the runtime source; the plugin defaults when the env is absent).charly.yml var:carries the same values because charly materializes a candy's declared defaults into the plugin's environment — the same configuration, not a second implementation;TestModelDefaultsMatchCharlyYMLfails if they drift. The org variables are the operator override."default 0.2"description is corrected.fix/branch; no force-push; no direct push tomain.N/A — this repo emits no generated artifact or image.c8b0c6e) with the four knobs unset, and the trace shows the resolved defaults.disposable: truebed exists, but the candy ships an ADEplan:whose 3 deterministic checks are run above; the changed path executed live (bare-env output pasted) and carriesTestOfficialSamplingDefaults+TestModelDefaultsMatchCharlyYML+TestSamplingTrace, all of which fail without this change.Change classification
gofmt/vet/test) + the candy's ADE plan checks + the raw bare-env live runs; the weld/release is the fresh-rebuild R10.analysed on a live system— the changed path executed live against the real model with the defaults exercised; the complete fresh-rebuild R10 (the charly weld) has not run.Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (analysed on a live system)