Repository navigation
feat(review): report findings to clients as a typed contract #9794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 11 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
6c13ef1
feat(review): report findings to clients as a typed contract
wenshao c367689
fix(i18n): cover report_findings in tool display-name maps
wenshao c4a3c4f
test(cli): pin ToolMessage routing for findings_list displays
wenshao 27464e1
fix(review): address automatic-review round 1 on the findings contract
wenshao e58061d
Merge remote-tracking branch 'origin/main' into feat/report-findings-…
qwen-code-ci-bot 75fef65
test(core): pin code-unit file/id sort order in report_findings
qwen-code-ci-bot dd07bdf
Merge remote-tracking branch 'origin/main' into feat/report-findings-…
qwen-code-ci-bot 6440c42
Merge remote-tracking branch 'origin/main' into feat/report-findings-…
wenshao f7fcd44
Merge remote-tracking branch 'origin/main' into feat/report-findings-…
wenshao 0080eeb
Merge remote-tracking branch 'origin/main' into feat/report-findings-…
qwen-code-ci-bot fd41284
Merge branch 'feat/report-findings-typed-contract' of https://github.…
qwen-code-dev-bot 01e5f2b
fix(review): close report_findings contract gaps from review round 5 …
qwen-code-dev-bot 26033e0
fix(review): implement report_findings replacement semantics and clos…
qwen-code-dev-bot dec4a7c
Merge branch 'main' into feat/report-findings-typed-contract
wenshao 6e242c3
fix(cli): close findings_list boundary bypass and restore superseded …
qwen-code-dev-bot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # Report Findings Typed Contract | ||
|
|
||
| ## Context | ||
|
|
||
| `/review` already canonicalizes its findings as data twice: `qwen review | ||
| findings` writes the typed artifact under `.qwen/tmp/`, and Step 8's | ||
| `save-artifact` + `record_artifact` publish a durable copy the Web Shell | ||
| renders (`CodeReviewArtifactDetail`). But both are files registered after the | ||
| fact. Every client rendering the session live — the terminal UI, the Web Shell | ||
| transcript, ACP hosts, the daemon TUI — receives only the Markdown | ||
| restatement of the same list, and after `--fix` (or a later `fix these | ||
| issues`) nothing in-band tells a client which findings are now closed. | ||
|
|
||
| ## Design | ||
|
|
||
| A new core tool, `report_findings`, is the in-band half of the contract: one | ||
| call with `{level, findings[]}`, rendered by host UIs as a per-finding list. | ||
| Field names and enum spellings match the findings artifact exactly (`id`, | ||
| `severity`, `confidence`, `source`, `file`/`line`, `summary`, `shortSummary`, | ||
| `failureScenario`, `category`, `outcome`, `outcomeNote`), so the model copies | ||
| values out of the artifact instead of translating them. The tool sorts by | ||
| severity → confidence → location, derives and compresses `shortSummary` to 60 | ||
| characters, rejects control characters and duplicate ids, and — mirroring | ||
| `review findings --outcomes` — refuses a call where some findings carry an | ||
| `outcome` and others do not. It persists nothing and decides no verdict; the | ||
| result is a `findings_list` structured `returnDisplay`. | ||
|
|
||
| The finding enums now live in core (`tools/report-findings.ts`); | ||
| `packages/cli/src/commands/review/findings.ts` re-exports them under its historical | ||
| names. The Web Shell renderer keeps its deliberate browser-side copy. | ||
|
|
||
| The `/review` skill calls the tool once after writing the findings artifact | ||
| (Step 6; low effort reports its unverified list with `level: "low"`), and | ||
| again after `--fix` with every finding carrying its outcome — a rule that | ||
| outlives Step 6B: any later in-session disposition change records outcomes | ||
| into the artifact and re-issues the call. The call is UI delivery: a failure | ||
| is disclosed and never alters artifacts or the verdict. | ||
|
|
||
| Rendering: the TUI gets a `FindingsDisplay` row list (severity color, id, | ||
| `file:line`, short summary, confidence marker, outcome badge); the daemon TUI | ||
| adapter passes `findings_list` through; history/recording compaction truncates | ||
| only the free-text fields. | ||
|
|
||
| ## Verification | ||
|
|
||
| - Core tool unit tests: sorting, shortSummary derivation/compression, empty | ||
| list, outcome counting, partial-outcome refusal, duplicate ids, control | ||
| characters, schema violations, trimming. | ||
| - Compaction test: free-text fields truncate, typed fields survive. | ||
| - `FindingsDisplay` ink render tests: rows, outcomes with skip reason, empty | ||
| state. | ||
| - Existing `findings.ts`, `save-artifact`, ToolMessage, daemon adapter, | ||
| config-registration, SKILL parity and review-digest suites stay green. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2026 Qwen Team | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import { render } from 'ink-testing-library'; | ||
| import { describe, expect, it } from 'vitest'; | ||
| import type { FindingsResultDisplay } from '@qwen-code/qwen-code-core'; | ||
| import { FindingsDisplay } from './FindingsDisplay.js'; | ||
|
|
||
| function display( | ||
| overrides: Partial<FindingsResultDisplay> = {}, | ||
| ): FindingsResultDisplay { | ||
| return { | ||
| type: 'findings_list', | ||
| level: 'high', | ||
| findings: [ | ||
| { | ||
| id: 'R1-1', | ||
| severity: 'Critical', | ||
| confidence: 'high', | ||
| file: 'src/foo.ts', | ||
| line: 42, | ||
| // shortSummary deliberately differs from summary: the row must render | ||
| // the compact label, and a fixture where the two coincide would keep | ||
| // every test green if FindingRow regressed to rendering `summary`. | ||
| summary: | ||
| 'the provider returns the wrong value on every cold-cache lookup', | ||
| shortSummary: 'cold-cache wrong return', | ||
| failureScenario: 'first call after start returns undefined', | ||
| }, | ||
| { | ||
| severity: 'Suggestion', | ||
| confidence: 'low', | ||
| file: 'src/bar.ts', | ||
| summary: 'the helper is duplicated between bar.ts and baz.ts', | ||
| shortSummary: 'duplicated helper', | ||
| failureScenario: 'two copies drift', | ||
| }, | ||
| ], | ||
| ...overrides, | ||
| }; | ||
| } | ||
|
|
||
| describe('<FindingsDisplay />', () => { | ||
| it('renders one row per finding with severity, id, location and label', () => { | ||
| const { lastFrame } = render(<FindingsDisplay data={display()} />); | ||
| const frame = lastFrame()!; | ||
| expect(frame).toContain('Critical'); | ||
| expect(frame).toContain('R1-1'); | ||
| expect(frame).toContain('src/foo.ts:42'); | ||
| expect(frame).toContain('cold-cache wrong return'); | ||
| expect(frame).toContain('Suggestion'); | ||
| expect(frame).toContain('src/bar.ts'); | ||
| expect(frame).toContain('(low confidence)'); | ||
| // The row renders shortSummary, never the full summary. | ||
| expect(frame.replace(/\s+/g, ' ')).not.toContain( | ||
| 'wrong value on every cold-cache lookup', | ||
| ); | ||
| }); | ||
|
|
||
| it('renders outcomes with the skip reason', () => { | ||
| const data = display(); | ||
| data.findings = data.findings.map((finding, index) => | ||
| index === 0 | ||
| ? { ...finding, outcome: 'fixed' as const } | ||
| : { | ||
| ...finding, | ||
| outcome: 'skipped' as const, | ||
| outcomeNote: 'fix would change intended behaviour', | ||
| }, | ||
| ); | ||
| const { lastFrame } = render(<FindingsDisplay data={data} />); | ||
| const frame = lastFrame()!.replace(/\s+/g, ' '); | ||
| expect(frame).toContain('(fixed)'); | ||
| expect(frame).toContain('(skipped: fix would change intended behaviour)'); | ||
| }); | ||
|
|
||
| it('renders an explicit empty state', () => { | ||
| const { lastFrame } = render( | ||
| <FindingsDisplay data={display({ findings: [] })} />, | ||
| ); | ||
| expect(lastFrame()).toContain('No findings.'); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2026 Qwen Team | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import type React from 'react'; | ||
| import { Box, Text } from 'ink'; | ||
| import type { | ||
| FindingsResultDisplay, | ||
| ReportedFinding, | ||
| } from '@qwen-code/qwen-code-core'; | ||
| import { Colors } from '../colors.js'; | ||
| import { ICON } from '../constants.js'; | ||
|
|
||
| interface FindingsDisplayProps { | ||
| data: FindingsResultDisplay; | ||
| } | ||
|
|
||
| const SEVERITY_COLORS: Record<ReportedFinding['severity'], () => string> = { | ||
| Critical: () => Colors.AccentRed, | ||
| Suggestion: () => Colors.AccentYellow, | ||
| 'Nice to have': () => Colors.Gray, | ||
| }; | ||
|
|
||
| const OUTCOME_LABELS: Record< | ||
| NonNullable<ReportedFinding['outcome']>, | ||
| string | ||
| > = { | ||
| fixed: 'fixed', | ||
| skipped: 'skipped', | ||
| no_change_needed: 'no change needed', | ||
| }; | ||
|
|
||
| export const FindingsDisplay: React.FC<FindingsDisplayProps> = ({ data }) => { | ||
| if (data.findings.length === 0) { | ||
| return ( | ||
| <Box> | ||
| <Text color={Colors.Gray}>No findings.</Text> | ||
| </Box> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <Box flexDirection="column"> | ||
| {data.findings.map((finding, index) => ( | ||
| <FindingRow | ||
| key={finding.id ?? `${finding.file}:${finding.line ?? ''}:${index}`} | ||
| finding={finding} | ||
| /> | ||
| ))} | ||
| </Box> | ||
| ); | ||
| }; | ||
|
|
||
| const FindingRow: React.FC<{ finding: ReportedFinding }> = ({ finding }) => { | ||
| const severityColor = SEVERITY_COLORS[finding.severity](); | ||
| const resolved = | ||
| finding.outcome === 'fixed' || finding.outcome === 'no_change_needed'; | ||
| const icon = | ||
| finding.outcome === undefined | ||
| ? ICON.CIRCLE_FILLED | ||
| : resolved | ||
| ? ICON.CHECK | ||
| : ICON.CIRCLE_EMPTY; | ||
| const where = `${finding.file}${finding.line !== undefined ? `:${finding.line}` : ''}`; | ||
|
|
||
| return ( | ||
| <Box flexDirection="row" minHeight={1}> | ||
| <Box width={3} flexShrink={0}> | ||
| <Text color={resolved ? Colors.AccentGreen : severityColor}> | ||
| {icon} | ||
| </Text> | ||
| </Box> | ||
| <Box flexGrow={1}> | ||
| <Text wrap="wrap"> | ||
| <Text color={severityColor} bold={finding.severity === 'Critical'}> | ||
| {finding.severity} | ||
| </Text> | ||
| <Text color={Colors.Gray}>{finding.id ? ` ${finding.id}` : ''} </Text> | ||
| <Text color={Colors.AccentCyan}>{where}</Text> | ||
| <Text color={Colors.Foreground} strikethrough={resolved}> | ||
| {' '} | ||
| {finding.shortSummary} | ||
| </Text> | ||
| {finding.confidence === 'low' && ( | ||
| <Text color={Colors.Gray}> (low confidence)</Text> | ||
| )} | ||
| {finding.outcome && ( | ||
| <Text color={resolved ? Colors.AccentGreen : Colors.AccentYellow}> | ||
| {' '} | ||
| ({OUTCOME_LABELS[finding.outcome]} | ||
| {finding.outcome === 'skipped' && finding.outcomeNote | ||
|
qwen-code-dev-bot marked this conversation as resolved.
Resolved
|
||
| ? `: ${finding.outcomeNote}` | ||
| : ''} | ||
| ) | ||
| </Text> | ||
| )} | ||
| </Text> | ||
| </Box> | ||
| </Box> | ||
| ); | ||
| }; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.