test: command hints, discover-and-add-mcps, sql.analyze success semantics#440
test: command hints, discover-and-add-mcps, sql.analyze success semantics#440anandgupta42 wants to merge 1 commit intomainfrom
Conversation
…tics Guard against AI-5975 regression (sql.analyze success:false on issues) and verify the new discover-and-add-mcps builtin command (#409) is registered. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> https://claude.ai/code/session_01BUHCukhUhWNtR82r8iedHG
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review.
Tip: disable this comment in your organization's Code Review settings.
📝 WalkthroughWalkthroughThree new test files have been added to validate SQL analyzer output shapes via Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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 `@packages/opencode/test/altimate/sql-analyze-format.test.ts`:
- Around line 72-83: The test "successful result has all required properties"
currently only checks the shape of SqlAnalyzeResult returned by
Dispatcher.call("sql.analyze") but doesn't assert the success path; update the
test to explicitly assert that result.success is true (e.g.,
expect(result.success).toBe(true)) after the call so the test actually enforces
a successful result rather than merely the response shape; keep the existing
shape checks for result.issues and result.confidence_factors.
🪄 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: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 0f53220e-b69c-4a7f-8f1b-a9f6127aa113
📒 Files selected for processing (3)
packages/opencode/test/altimate/sql-analyze-format.test.tspackages/opencode/test/command/hints-discover-mcps.test.tspackages/opencode/test/fixture/fixture.ts
| test("successful result has all required properties", async () => { | ||
| const result = await Dispatcher.call("sql.analyze", { | ||
| sql: "SELECT 1 LIMIT 1", | ||
| }) as SqlAnalyzeResult | ||
| expect(result).toHaveProperty("success") | ||
| expect(result).toHaveProperty("issues") | ||
| expect(result).toHaveProperty("issue_count") | ||
| expect(result).toHaveProperty("confidence") | ||
| expect(result).toHaveProperty("confidence_factors") | ||
| expect(Array.isArray(result.issues)).toBe(true) | ||
| expect(Array.isArray(result.confidence_factors)).toBe(true) | ||
| }) |
There was a problem hiding this comment.
Assert success-path explicitly in the “successful result” test.
The current assertions validate shape only; the failure path also has the same top-level shape. Add an explicit success assertion so this test enforces what its name promises.
✅ Suggested patch
test("successful result has all required properties", async () => {
const result = await Dispatcher.call("sql.analyze", {
sql: "SELECT 1 LIMIT 1",
}) as SqlAnalyzeResult
+ expect(result.success).toBe(true)
+ expect(result.error).toBeUndefined()
expect(result).toHaveProperty("success")
expect(result).toHaveProperty("issues")
expect(result).toHaveProperty("issue_count")
expect(result).toHaveProperty("confidence")
expect(result).toHaveProperty("confidence_factors")
expect(Array.isArray(result.issues)).toBe(true)
expect(Array.isArray(result.confidence_factors)).toBe(true)
})📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| test("successful result has all required properties", async () => { | |
| const result = await Dispatcher.call("sql.analyze", { | |
| sql: "SELECT 1 LIMIT 1", | |
| }) as SqlAnalyzeResult | |
| expect(result).toHaveProperty("success") | |
| expect(result).toHaveProperty("issues") | |
| expect(result).toHaveProperty("issue_count") | |
| expect(result).toHaveProperty("confidence") | |
| expect(result).toHaveProperty("confidence_factors") | |
| expect(Array.isArray(result.issues)).toBe(true) | |
| expect(Array.isArray(result.confidence_factors)).toBe(true) | |
| }) | |
| test("successful result has all required properties", async () => { | |
| const result = await Dispatcher.call("sql.analyze", { | |
| sql: "SELECT 1 LIMIT 1", | |
| }) as SqlAnalyzeResult | |
| expect(result.success).toBe(true) | |
| expect(result.error).toBeUndefined() | |
| expect(result).toHaveProperty("success") | |
| expect(result).toHaveProperty("issues") | |
| expect(result).toHaveProperty("issue_count") | |
| expect(result).toHaveProperty("confidence") | |
| expect(result).toHaveProperty("confidence_factors") | |
| expect(Array.isArray(result.issues)).toBe(true) | |
| expect(Array.isArray(result.confidence_factors)).toBe(true) | |
| }) |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/opencode/test/altimate/sql-analyze-format.test.ts` around lines 72 -
83, The test "successful result has all required properties" currently only
checks the shape of SqlAnalyzeResult returned by Dispatcher.call("sql.analyze")
but doesn't assert the success path; update the test to explicitly assert that
result.success is true (e.g., expect(result.success).toBe(true)) after the call
so the test actually enforces a successful result rather than merely the
response shape; keep the existing shape checks for result.issues and
result.confidence_factors.
Summary
What does this PR do?
1.
Command.hints()—src/command/index.ts(6 new tests)This pure function extracts
$1,$2,$ARGUMENTSplaceholders from command templates and is used by the TUI to display argument hints. Zero tests existed. New coverage includes:$10sorts before$2— the actual contract)$ARGUMENTSextraction, combined numbered +$ARGUMENTSextraction$0as a valid placeholder2.
discover-and-add-mcpsbuiltin command —src/command/index.ts(5 new tests)PR #409 shipped this as a builtin command (previously only existed as a project-level
.opencode/command/file). Zero tests verified it was registered. New coverage includes:Command.Default.DISCOVER_MCPSconstant is setCommand.list()andCommand.get()mcp_discovertool3.
sql.analyzeDispatcher method —src/altimate/native/sql/register.ts(5 new tests)The AI-5975 fix changed success semantics: finding lint/semantic/safety issues IS a successful analysis (
success: true). Previously it returnedsuccess: falsewhen issues were found, causing ~4,000 false "unknown error" telemetry entries per day. New coverage includes:success: trueissue_countmatchesissuesarray length (with non-vacuous guard)lint,semantic,safetyInfrastructure fix: Added
git config commit.gpgsign falsetotest/fixture/fixture.tstmpdir helper to prevent git signing failures in CI/Codespace environments.Type of change
Issue for this PR
N/A — proactive test coverage
How did you verify your code works?
Checklist
https://claude.ai/code/session_01BUHCukhUhWNtR82r8iedHG
Summary by CodeRabbit
Release Notes