refactor(mcp): type getReviewFeedbackItem with its producer's return type (#tech-debt) - #1088
Merged
Merged
Conversation
…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>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
McpRequestContext.getReviewFeedbackItem(apps/server/src/shared/mcp/server.ts) was declaredPromise<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 siblinglistReviewFeedbackuses them).Why it's debt
The index-signature type let the consumer read any key as
unknownwithout 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 nooutputSchema, and indexes no keys — so narrowing is type-only; no runtime object changes. The test mock in test/persona-interaction-tools.test.ts is castas neverand is unaffected.Verification
pnpm run checkgreen;pnpm run testgreen (server 187 passed/1 skipped, web 133, extension 9).void item.notARealField;in the tool handler → TS2339 with this change; compiles silently on HEAD.{ bogus: 1 }still compiles, becauseroutes/mcp.tstypes all ~37mcp*route deps asunknownand hands them over viaas Parameters<typeof handleMcpRequest>[3]. Typing justmcpGetReviewFeedbackItemwould make it the one typed dep of 37; that whole family is queued as its own backlog entry.useWorktree: true) fail on this host because its Homebrew git is missinggit-core, sogit cloneof a local bare repo falls through to the unlicensed Xcodegit-upload-packshim — reproducible outside the suite with a baregit 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.tsunknownroute-deps entry.🤖 Generated with Claude Code