Skip to content

refactor(mcp): type getReviewFeedbackItem with its producer's return type (#tech-debt) - #1088

Merged
selfcontained merged 1 commit into
mainfrom
debt/type-review-feedback-item-callback
Sep 16, 2026
Merged

selfcontained merged 1 commit into
mainfrom
debt/type-review-feedback-item-callback

Conversation

@selfcontained

Copy link
Copy Markdown
Owner

What

McpRequestContext.getReviewFeedbackItem (apps/server/src/shared/mcp/server.ts) was declared Promise<Record<string, unknown> | null>. Its only producer, getFeedbackItemForAgent (agents/reviews.ts:576, wired via server/mcp-review-handlers.ts:272), returns (ReviewFeedbackItemRecord & { reviewId: number; messages: ReviewThreadMessageRecord[] }) | null. This PR declares that exact type — one declaration, both types already imported (the sibling listReviewFeedback uses them).

Why it's debt

The index-signature type let the consumer read any key as unknown without the compiler knowing the real shape. The sole consumer, dispatch_review_get_feedback (shared/mcp/persona-interaction-tools.ts), only null-checks the item and serialises it (jsonText(item), structuredContent: { item }), registers no outputSchema, and indexes no keys — so narrowing is type-only; no runtime object changes. The test mock in test/persona-interaction-tools.test.ts is cast as never and is unaffected.

Verification

  • pnpm run check green; pnpm run test green (server 187 passed/1 skipped, web 133, extension 9).
  • Compiler probe (consumer side): adding void item.notARealField; in the tool handler → TS2339 with this change; compiles silently on HEAD.
  • Producer side is NOT protected by this change, deliberately: making the handler return { bogus: 1 } still compiles, because routes/mcp.ts types all ~37 mcp* route deps as unknown and hands them over via as Parameters<typeof handleMcpRequest>[3]. Typing just mcpGetReviewFeedbackItem would make it the one typed dep of 37; that whole family is queued as its own backlog entry.
  • Local E2E: git-dependent specs (worktree, base-branch, callable-jobs Cmd+K launch with useWorktree: true) fail on this host because its Homebrew git is missing git-core, so git clone of a local bare repo falls through to the unlicensed Xcode git-upload-pack shim — reproducible outside the suite with a bare git clone. Non-git specs pass (agent-surfaces:680 known flake passed on re-run). Diff emits no JS change; relying on CI E2E.

Next

Next debt run: the 10th since the #1060 audit → a broad audit, including the new routes/mcp.ts unknown route-deps entry.

🤖 Generated with Claude Code

…type (#tech-debt)

McpRequestContext declared the callback as returning
Promise<Record<string, unknown> | null>, while its only producer
(getFeedbackItemForAgent) returns the precise feedback-item record with
reviewId and messages. Declare the precise type so the sole consumer
(dispatch_review_get_feedback) is checked against the real shape.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@selfcontained
selfcontained merged commit 75580af into main Sep 16, 2026
1 of 2 checks passed
@selfcontained
selfcontained deleted the debt/type-review-feedback-item-callback branch September 16, 2026 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant