Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
5f3f779
fix(review): gate the recovered incremental anchor on the model that …
wenshao Aug 14, 2026
cb366f5
fix(review): certify the ledger anchor with the runtime model identity
wenshao Aug 15, 2026
4938c6b
fix(review): pin the posted marker's model wiring and tighten the anc…
qwen-code-dev-bot Aug 15, 2026
79acdfd
Merge origin/main into fix/review-anchor-model-gate
qwen-code-dev-bot Aug 15, 2026
7b7fa1e
fix(review): shed the anchor pair first and pin the round-3 findings
qwen-code-dev-bot Aug 15, 2026
c16d871
fix(review): scope the identity-channel claims and pin the branch-1 gate
qwen-code-dev-bot Aug 15, 2026
37923d4
fix(review): shed the dead anchor tie-break and pin the reprieve clauses
qwen-code-dev-bot Aug 15, 2026
0791c2f
Merge branch 'main' into fix/review-anchor-model-gate
qwen-code-dev-bot Aug 16, 2026
cc5d36e
Merge remote-tracking branch 'origin/main' into fix/review-anchor-mod…
qwen-code-dev-bot Aug 16, 2026
5e0e625
Merge branch 'main' into fix/review-anchor-model-gate
wenshao Aug 16, 2026
cc7a514
fix(review): stamp the round's model at capture, qualify it by provider
wenshao Aug 16, 2026
06c07ac
docs(review): correct the absent-stamp and model-cap notes
wenshao Aug 16, 2026
73dbd4d
Merge branch 'main' into fix/review-anchor-model-gate
qwen-code-dev-bot Aug 16, 2026
59d25be
Merge branch 'main' into fix/review-anchor-model-gate
wenshao Aug 17, 2026
e862d00
style(review): prettier the reapplied round-model helper
wenshao Aug 17, 2026
148ba9a
fix(review): rule the same-model gate in the CLI, key the identity pe…
wenshao Aug 17, 2026
f01c75b
Merge branch 'main' into fix/review-anchor-model-gate
wenshao Aug 17, 2026
bb66bce
Merge branch 'main' into fix/review-anchor-model-gate
wenshao Aug 17, 2026
a3de5af
fix(review): make the blanked identity fall back, and drop the anchor…
wenshao Aug 17, 2026
ef2e5f3
fix(review): rule the anchor verdict on the sha the side file actuall…
wenshao Aug 18, 2026
4112877
fix(review): move the last identity comparison out of prompt text
wenshao Aug 18, 2026
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
10 changes: 5 additions & 5 deletions docs/users/configuration/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ Settings are organized into categories. Most settings should be placed within th

#### review

| Setting | Type | Description | Default |
| -------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| `review.attribution` | boolean | Append the attribution footer naming the model and CLI version (e.g. `_— qwen3-coder via Qwen Code /review (v0.21.2)_`) to review bodies and inline comments posted by `/review`. Disable to post reviews without AI attribution. With the footer off, presubmit duplicate detection still recognizes earlier posts by the same GitHub account, but footer-less posts from other accounts escape it. | `true` |
| `review.effort` | enum | Default effort for `/review` when `--effort` is not given: `"low"`, `"medium"`, `"high"`, or `"auto"` (the built-in rule: high for PRs, medium for local changes). An explicit `--effort` wins; an effective `--comment` still forces high and `--fix` still floors at medium. | `"auto"` |
| `review.comment` | boolean | Treat every PR `/review` as if `--comment` was passed: findings are posted to the pull request without the flag. The post still binds to the PR named in the invocation. Enable only if you always want reviews published. | `false` |
| Setting | Type | Description | Default |
| -------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| `review.attribution` | boolean | Append the attribution footer naming the model and CLI version (e.g. `_— qwen3-coder via Qwen Code /review (v0.21.2)_`) to review bodies and inline comments posted by `/review`. Disable to post reviews without AI attribution. With the footer off, presubmit duplicate detection still recognizes earlier posts by the same GitHub account, but footer-less posts from other accounts escape it. Disabling it also withholds the model from the machine-ledger marker embedded in the review body, so in a fresh environment (CI, another clone — anywhere without a review cache) the incremental anchor recovered from the last posted review fails the same-model check and the re-review falls back to full-range. | `true` |
| `review.effort` | enum | Default effort for `/review` when `--effort` is not given: `"low"`, `"medium"`, `"high"`, or `"auto"` (the built-in rule: high for PRs, medium for local changes). An explicit `--effort` wins; an effective `--comment` still forces high and `--fix` still floors at medium. | `"auto"` |
| `review.comment` | boolean | Treat every PR `/review` as if `--comment` was passed: findings are posted to the pull request without the flag. The post still binds to the PR named in the invocation. Enable only if you always want reviews published. | `false` |

These settings are read from operator scopes only (User, System, and SystemDefaults); values in a workspace `.qwen/settings.json` are ignored, so a repository cannot set review policy for its reviewers.

Expand Down
2 changes: 1 addition & 1 deletion docs/users/features/code-review.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ Or, after running `/review 123`, type `post comments` to publish findings withou
- Where the fix is a single localized edit, a ` ```suggestion ` block you can apply in one click
- For Approve/Request changes verdicts: a review summary with the verdict
- For Comment verdict with all inline comments posted: no separate summary (inline comments are sufficient)
- Model and CLI version attribution footer on each comment (e.g., _— qwen3-coder via Qwen Code /review (v0.21.2)_); set `review.attribution` to `false` in your user or system `settings.json` (the workspace `.qwen/settings.json` is ignored for `review.*` settings) to post without it
- Model and CLI version attribution footer on each comment (e.g., _— qwen3-coder via Qwen Code /review (v0.21.2)_); set `review.attribution` to `false` in your user or system `settings.json` (the workspace `.qwen/settings.json` is ignored for `review.*` settings) to post without it — note this also withholds the model from the review's machine-ledger marker, so in fresh environments (no review cache) the recovered incremental anchor fails the same-model check and the re-review falls back to full-range

**What stays terminal-only:**

Expand Down
189 changes: 189 additions & 0 deletions packages/cli/src/commands/review/compose-review.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1763,6 +1763,67 @@ describe('composeReviewCommand handler (the CLI glue)', () => {
}
});

it('injects the session model into the marker — QWEN_CODE_MODEL reaches the anchor (wiring)', async () => {
// The certifying identity must be the model the session ACTUALLY runs —
// Config publishes it per session, the shell tool injects it into this
// subprocess — not the id the state JSON typed. Dropping the runtime
// argument from the handler's composeReview call leaves the pure-function
// tests green while the posted anchor is certified by the typed id again.
const dir = mkdtempSync(join(tmpdir(), 'compose-runtime-model-'));
const inputPath = join(dir, 'compose.json');
const commentsPath = join(dir, 'comments.json');
const outPath = join(dir, 'composed.json');
writeFileSync(
inputPath,
JSON.stringify({
modelId: 'typed-by-the-model',
planPath: coveredPlan(['verify', 'reverse-audit'], {
prNumber: 8255,
fetchedSha: 'deadbeef00112233',
}),
}),
'utf8',
);
writeFileSync(
commentsPath,
JSON.stringify([
{ path: 'a.ts', line: 3, body: '**[Suggestion]** prefer x' },
]),
'utf8',
);
// The handler strips `env` off the state JSON, so coverage resolves the
// fixture transcripts from the process environment.
const prevDir = process.env['QWEN_CODE_PROJECT_DIR'];
const prevSession = process.env['QWEN_CODE_SESSION_ID'];
const prevModel = process.env['QWEN_CODE_MODEL'];
process.env['QWEN_CODE_PROJECT_DIR'] = ENV['QWEN_CODE_PROJECT_DIR'];
process.env['QWEN_CODE_SESSION_ID'] = ENV['QWEN_CODE_SESSION_ID'];
process.env['QWEN_CODE_MODEL'] = 'the-session-model';
try {
await runComposeReviewCommand({
input: inputPath,
comments: commentsPath,
out: outPath,
});
const written = JSON.parse(
readFileSync(outPath, 'utf8'),
) as ComposeReviewResult;
const ledger = parseLedger(written.body)!;
expect(ledger.sha).toBe('deadbeef00112233');
expect(ledger.model).toBe('the-session-model');
} finally {
for (const [key, prev] of [
['QWEN_CODE_PROJECT_DIR', prevDir],
['QWEN_CODE_SESSION_ID', prevSession],
['QWEN_CODE_MODEL', prevModel],
] as const) {
if (prev === undefined) delete process.env[key];
else process.env[key] = prev;
}
rmSync(dir, { recursive: true, force: true });
}
});

it('pins the persisted footer to the inherited startup version, not the resolved one', async () => {
// Same pin as `submit`: a shared runner rewrites installs under running
// processes, so the version resolved at compose time can disagree with
Expand Down Expand Up @@ -4333,6 +4394,134 @@ describe('the ledger marker reaches the POSTED body', () => {
expect(parseLedger(r.body)?.sha).toBe('deadbeef00112233');
});

it('the anchor carries its model — the same-model contract survives recovery', () => {
// The cache pairs `lastCommitSha` with `lastModelId`, and Step 1 refuses
// the incremental shortcut across models — but the marker's anchor rode
// bare, so a cross-model round that recovered it from the posted body
// scoped `sha..HEAD` past code the current model never reviewed. The
// model that certified the range now travels beside it.
const r = composeReview({
planPath: coveredPlan(['verify', 'reverse-audit'], {
prNumber: 8255,
fetchedSha: 'deadbeef00112233',
}),
env: ENV,
modelId: MODEL,
criticalsInline: 0,
suggestionsInline: 0,
draftedComments: [
{ path: 'src/a.ts', line: 3, body: '**[Suggestion]** untested' },
],
});
const ledger = parseLedger(r.body)!;
expect(ledger.sha).toBe('deadbeef00112233');
expect(ledger.model).toBe(MODEL);
});

it('attribution off: the marker withholds the model WITH the footer', () => {
// `review.attribution` is "whether the posted review names its model".
// The footer is the visible half; the marker rides the same posted body,
// so a model id inside it publishes exactly what the setting removes —
// readable through the API and the raw-body edit view — on a write this
// module calls public and irreversible. Withheld, the anchor degrades to
// the skill's specified fail-safe: absent model → mismatch → full-range.
const r = composeReview(
{
planPath: coveredPlan(['verify', 'reverse-audit'], {
prNumber: 8255,
fetchedSha: 'deadbeef00112233',
}),
env: ENV,
modelId: MODEL,
criticalsInline: 0,
suggestionsInline: 0,
draftedComments: [
{ path: 'src/a.ts', line: 3, body: '**[Suggestion]** untested' },
],
},
'unknown',
false,
);
const ledger = parseLedger(r.body)!;
expect(ledger.sha).toBe('deadbeef00112233');
expect(ledger.model).toBeUndefined();
expect(r.body).not.toContain(MODEL);
});

it('attribution off, modelId absent: the marker SURVIVES — only the model is withheld', () => {
// Attribution off skips the `modelId is required` validation, so a state
// JSON without the field is legal on a clean round. A marker path that
// threw on it would drop the WHOLE marker, not just the model: the round
// counter resets (the next round re-issues ids the PR already carries)
// and the findings work list is lost. Measured: deleting the typeof guard
// survived the suite, so this pins the branch by name.
const r = composeReview(
{
planPath: coveredPlan(['verify', 'reverse-audit'], {
prNumber: 8255,
fetchedSha: 'deadbeef00112233',
}),
env: ENV,
modelId: undefined as unknown as string,
criticalsInline: 0,
suggestionsInline: 0,
draftedComments: [
{ path: 'src/a.ts', line: 3, body: '**[Suggestion]** untested' },
],
},
'unknown',
false,
);
const ledger = parseLedger(r.body)!;
expect(ledger.sha).toBe('deadbeef00112233');
expect(ledger.model).toBeUndefined();
});

it('the anchor carries the RUNTIME identity — injected at the CLI boundary, never typed by the model', () => {
// The certifying model used to be `input.modelId` — a field of the
// model-written state JSON. A review running under one model could type
// another's id, and the posted anchor would certify the range to a model
// that never reviewed it: a later run of that model accepts `sha..HEAD`
// and skips the earlier code. The boundaries now inject the identity the
// session ACTUALLY runs (Config publishes QWEN_CODE_MODEL); the typed
// field is only the fallback for runs no session published.
const r = composeReview(
{
planPath: coveredPlan(['verify', 'reverse-audit'], {
prNumber: 8255,
fetchedSha: 'deadbeef00112233',
}),
env: ENV,
modelId: 'typed-by-the-model',
criticalsInline: 0,
suggestionsInline: 0,
draftedComments: [
{ path: 'src/a.ts', line: 3, body: '**[Suggestion]** untested' },
],
},
'unknown',
true,
'the-session-model',
);
const ledger = parseLedger(r.body)!;
expect(ledger.sha).toBe('deadbeef00112233');
expect(ledger.model).toBe('the-session-model');
});

it('withholds the model WITH the sha on a capped round — it qualifies the anchor, nothing else', () => {
const r = composeReview({
planPath: plan({ fetchedSha: 'deadbeef00112233' }),
modelId: 'm',
criticalsInline: 0,
suggestionsInline: 0,
draftedComments: [{ path: 'a.ts', body: '**[Critical]** boom' }],
});
expect(r.cappedBy.length).toBeGreaterThan(0);
const ledger = parseLedger(r.body)!;
expect(ledger.sha).toBeUndefined();
expect(ledger.model).toBeUndefined();
});

it('withholds the sha when the module ITSELF caps the round', () => {
// The four input fields are not the only fail-closed signals: cappedBy is
// computed in this module from conditions with no input channel at all
Expand Down
Loading
Loading