Repository navigation
Review selection engine - #30
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
📝 WalkthroughWalkthroughAdds a new Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as CLI Handler
participant Parser as Arg Parser
participant ReviewCompare as ReviewCompare Module
participant Graph as Knowledge Graph Loader
participant PrImpact as PR Impact Analyzer
participant Runner as External Runner
participant Disk as File System
CLI->>Parser: parseReviewCompareArgs(args)
Parser-->>CLI: ReviewCompareCliOptions
CLI->>ReviewCompare: runReviewCompareCommand(input)
ReviewCompare->>Graph: load graph.json
Graph-->>ReviewCompare: KnowledgeGraph
ReviewCompare->>PrImpact: analyzePrImpact(mode=verbose)
PrImpact-->>ReviewCompare: verbose result
ReviewCompare->>Disk: write verbose prompt file
ReviewCompare->>PrImpact: compactPrImpactResult(verbose)
PrImpact-->>ReviewCompare: compact result
ReviewCompare->>Disk: write compact prompt file
ReviewCompare->>Disk: write initial report.json
ReviewCompare->>Runner: exec verbose prompt (template)
Runner-->>ReviewCompare: stdout/stderr, exit code
ReviewCompare->>Disk: write verbose answer + update report
ReviewCompare->>Runner: exec compact prompt (template)
Runner-->>ReviewCompare: stdout/stderr, exit code
ReviewCompare->>Disk: write compact answer + update report
ReviewCompare-->>CLI: return formatted summary (tokens, reduction, path)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Review rate limit: 9/10 reviews remaining, refill in 6 minutes. Comment |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
src/infrastructure/review-compare.ts (1)
166-193: ⚡ Quick winConsider adding a timeout to prevent indefinite hangs.
The
defaultRunnerspawns external commands without a timeout. If the executed command hangs, this will block indefinitely. Consider adding a timeout mechanism similar to howgitDiffPatchinpr-impact.tsusestimeout: 10_000.Proposed approach using AbortController
async function defaultRunner(execution: ReviewCompareExecution): Promise<ReviewCompareRunnerResult> { const startedAt = Date.now() + const timeoutMs = 300_000 // 5 minutes + const controller = new AbortController() + const timeout = setTimeout(() => controller.abort(), timeoutMs) + return await new Promise<ReviewCompareRunnerResult>((resolveExecution, rejectExecution) => { const command = process.platform === 'win32' ? { file: 'powershell.exe', args: ['-NoProfile', '-Command', execution.command] } : { file: '/bin/sh', args: ['-lc', execution.command] } - const child = spawn(command.file, command.args, { shell: false, stdio: ['ignore', 'pipe', 'pipe'] }) + const child = spawn(command.file, command.args, { + shell: false, + stdio: ['ignore', 'pipe', 'pipe'], + signal: controller.signal, + }) // ... rest of implementation child.on('close', (code) => { + clearTimeout(timeout) resolveExecution({🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/infrastructure/review-compare.ts` around lines 166 - 193, The defaultRunner currently spawns commands (spawn call in defaultRunner) with no timeout; add a timeout mechanism (e.g., accept a timeout in ReviewCompareExecution or use a hard default) and use an AbortController or a setTimeout to kill the child process when exceeded: start a timer when the child is spawned, on timeout call child.kill() (or send SIGKILL), clear the timer on normal close, and ensure you rejectExecution (or resolveExecution with a specific exitCode like 124) and include elapsedMs, stdout, and stderr; also remove/cleanup listeners to avoid leaks and handle the child.on('error') path consistently.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/cli/parser.ts`:
- Around line 854-862: The --budget '=' and separate-arg branches accept any
positive integer and don't enforce the shared maximum; after parsing with
parsePositiveDecimalInteger in both the argument === '--budget' and
argument.startsWith('--budget=') paths, clamp the resulting budget to
MAX_TOKEN_BUDGET (or validate and throw if above) before assigning to the budget
variable so the parsed value cannot exceed the shared MAX_TOKEN_BUDGET; update
the code around parsePositiveDecimalInteger, the budget assignment, and
reference MAX_TOKEN_BUDGET, budget, and the '--budget' handling logic to ensure
both branches behave identically.
In `@src/runtime/risk-map.ts`:
- Around line 122-127: The compareRankedRisks comparator currently orders by
hotspot_count and dependent_count before score, which lets lower-score items
outrank higher-impact ones; update compareRankedRisks so it compares right.score
- left.score first, then hotspot_count (right.hotspot_count -
left.hotspot_count), then dependent_count (right.dependent_count -
left.dependent_count), and finally fall back to label localeCompare for ties so
the "Highest risk" list is driven primarily by total risk score.
In `@src/runtime/stdio/tools.ts`:
- Around line 206-207: The current logic flips the default to compact when
callers send no flags; change it so the legacy full `pr_impact` payload is
returned unless the caller explicitly requests compact mode. Update the
determination of useVerbosePrImpact (used with id, prResult,
compactPrImpactResult, helpers.ok, helpers.textToolResult) to default to true
and only set to false when toolArguments.compact === true (optionally still
allow toolArguments.verbose === true to force verbose), so existing clients keep
fields like changed_nodes and affected_files unless they opt into compact.
---
Nitpick comments:
In `@src/infrastructure/review-compare.ts`:
- Around line 166-193: The defaultRunner currently spawns commands (spawn call
in defaultRunner) with no timeout; add a timeout mechanism (e.g., accept a
timeout in ReviewCompareExecution or use a hard default) and use an
AbortController or a setTimeout to kill the child process when exceeded: start a
timer when the child is spawned, on timeout call child.kill() (or send SIGKILL),
clear the timer on normal close, and ensure you rejectExecution (or
resolveExecution with a specific exitCode like 124) and include elapsedMs,
stdout, and stderr; also remove/cleanup listeners to avoid leaks and handle the
child.on('error') path consistently.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: e641d346-64ca-4eff-af75-7627b3df632b
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (19)
CHANGELOG.mdpackage.jsonsrc/cli/main.tssrc/cli/parser.tssrc/infrastructure/hooks.tssrc/infrastructure/review-compare.tssrc/runtime/pr-impact.tssrc/runtime/retrieve.tssrc/runtime/risk-map.tssrc/runtime/stdio/definitions.tssrc/runtime/stdio/tools.tssrc/shared/git.tssrc/shared/security.tssrc/shared/source-location.tstests/unit/cli.test.tstests/unit/pr-impact.test.tstests/unit/review-compare.test.tstests/unit/source-location.test.tstests/unit/stdio-pr-impact.test.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@README.md`:
- Line 140: Replace the phrase "multi-project real repos" with a clearer wording
in the README line that mentions external graph paths and output directories;
update the sentence to use either "real multi-project repositories" or
"real-world multi-project repos" (choose one) so the line reading about
"Supports external graph paths and output directories inside the target graph
workspace's own `graphify-out/`" is more readable and user-facing.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: fe2b4875-9bbe-4478-94b9-11b40d666a56
📒 Files selected for processing (4)
README.mddocs/proof-workflows.mdexamples/mcp-tool-examples.mdexamples/why-graphify.md
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/cli/parser.ts`:
- Around line 256-258: The function validateReviewCompareOutputDir currently
bypasses validateGraphOutputPath for absolute paths; change its logic so both
absolute and relative outputDir values are passed through
validateGraphOutputPath (i.e., always call validateGraphOutputPath for
confinement) while still resolving absolute paths where needed; update the
validateReviewCompareOutputDir implementation and any other similar helper(s)
(see the other occurrence referenced) to ensure the --output-dir for
review-compare is confined to the same graphify-out/ validation as other flows.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 018cd989-0971-4c15-a7f0-719f042c8b56
📒 Files selected for processing (5)
README.mdsrc/cli/parser.tssrc/runtime/risk-map.tstests/unit/cli.test.tstests/unit/risk-map.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- tests/unit/cli.test.ts
Summary
Testing
npm run test:runnpm run typechecknpm run buildnpm pack --dry-run(if packaging or install behavior changed)Checklist
Related issues
Summary by CodeRabbit