Skip to content

Split src/mcp_server.rs (7249 lines, 3.6x over its own frozen LOC-gate ceiling) - #254

Closed
getappz wants to merge 1 commit into
masterfrom
task/168
Closed

Split src/mcp_server.rs (7249 lines, 3.6x over its own frozen LOC-gate ceiling)#254
getappz wants to merge 1 commit into
masterfrom
task/168

Conversation

@getappz

@getappz getappz commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Auto-opened on item done for 019f735d-f4d2-7a62-a960-3f9689391714.

Summary by CodeRabbit

  • New Features
    • Added MCP actions for artifact publishing, versioning, search, diffs, and deletion.
    • Added asset attachment, retrieval, listing, and deletion with text and binary support.
    • Added claim, comment, handoff, memory, review, and GitHub workflow operations.
    • Added comprehensive validation, ownership checks, workspace scoping, and informative JSON responses.
  • Bug Fixes
    • Improved handling of conflicts, duplicate files, stale claims, unsafe filenames, and oversized content.
    • Enhanced item filtering, grooming, health reporting, and worktree isolation.

Splits the file that grew to 3.6x over its own LOC-gate frozen ceiling
into 13 sibling files under src/mcp_server/, following the delegation
pattern item.rs already established (each MCP tool method's body moves
to a pub fn in its own file; the #[tool_router]-tagged impl block in
mcp_server.rs keeps only thin one-line dispatchers, so the router
macro's exactly_one_tool_router_block_exists invariant still holds).

- types.rs: request/response structs + small shared helpers (856 lines)
- artifact.rs, asset.rs, claim.rs, comment.rs, flare_git.rs, handoff.rs,
  memory_tool.rs, review.rs: one file per tool's method body
- tests/: the former ~3580-line monolithic test module, split by domain
  into mod.rs (shared harness + misc tests), item_tests.rs,
  asset_tests.rs, artifact_tests.rs, action_tests.rs -- all under the
  1500-line limit for new files

Widely-shared helpers used across many tools (with_backend_db,
resolve_project, claim_db, resolve_repo_or_err, run_git, etc.) stay in
mcp_server.rs itself rather than being assigned to one tool's file.

Verified: all 619 tests pass (confirmed identical test-name set before
and after via diff, after catching and fixing one dropped #[test]
attribute at a file-split boundary); cargo clippy with CI's exact flags
clean (aside from the pre-existing Windows-only agent_launch.rs import,
tracked as #169); scripts/loc-gate.sh passes clean, no allowlist bump
needed; .githooks/pre-commit's staged-file LOC check now passes without
--no-verify.

mcp_server.rs remains on the LOC gate's frozen allowlist at 1521 lines
(down from 7249) -- under the 2000 ceiling but not yet under the 1500
line ordinarily required to drop off the allowlist entirely; the
remaining content is mostly cross-tool shared infrastructure that
doesn't cleanly belong to any single tool's file.
@getappz

getappz commented Jul 18, 2026

Copy link
Copy Markdown
Owner Author

Duplicate of #253, which already merged this branch's changes (0dd1c5a). Auto-opened by the item-done automation after the PR was already created and merged manually — closing, nothing further to merge here.

@getappz getappz closed this Jul 18, 2026
@getappz
getappz deleted the task/168 branch July 18, 2026 13:35
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 98f96bc0-1edb-4d3d-a2ad-53a6f5f1e94b

📥 Commits

Reviewing files that changed from the base of the PR and between 0dd1c5a and 083fc3a.

📒 Files selected for processing (15)
  • src/mcp_server.rs
  • src/mcp_server/artifact.rs
  • src/mcp_server/asset.rs
  • src/mcp_server/claim.rs
  • src/mcp_server/comment.rs
  • src/mcp_server/flare_git.rs
  • src/mcp_server/handoff.rs
  • src/mcp_server/memory_tool.rs
  • src/mcp_server/review.rs
  • src/mcp_server/tests/action_tests.rs
  • src/mcp_server/tests/artifact_tests.rs
  • src/mcp_server/tests/asset_tests.rs
  • src/mcp_server/tests/item_tests.rs
  • src/mcp_server/tests/mod.rs
  • src/mcp_server/types.rs

📝 Walkthrough

Walkthrough

Adds shared MCP request/response models and implements artifact, asset, handoff, claim, comment, memory, review, and GitHub action handlers. Expands integration coverage for storage, validation, item workflows, routing, schemas, and resource behavior.

Changes

MCP contracts and utilities

Layer / File(s) Summary
Shared request models and helpers
src/mcp_server/types.rs
Adds request/response schemas, artifact URL routing, backend error mapping, claim TTL handling, and encoding helpers.

Artifact, asset, and handoff flows

Layer / File(s) Summary
Artifact lifecycle
src/mcp_server/artifact.rs
Adds publish, list, get, diff, search, and delete actions with validation, versioning, filtering, snippets, and generated URLs.
Asset storage and retrieval
src/mcp_server/asset.rs
Adds scoped attachment storage, deduplication, inline text or Base64 responses, soft deletion, and path and size validation.
Handoff attachments
src/mcp_server/handoff.rs
Creates or updates assigned items and stores versioned item attachments with sender, recipient, and thread metadata.

Coordination and external operations

Layer / File(s) Summary
Claims, comments, memory, and reviews
src/mcp_server/claim.rs, src/mcp_server/comment.rs, src/mcp_server/memory_tool.rs, src/mcp_server/review.rs
Adds action dispatch for claim lifecycle, guarded comment CRUD, memory operations, and review submission, consensus, recording, and scoring.
GitHub operations
src/mcp_server/flare_git.rs
Adds repository resolution and dispatch for pull requests, issues, releases, workflow runs, and workflow dispatch.

Integration validation

Layer / File(s) Summary
MCP action and storage tests
src/mcp_server/tests/action_tests.rs, src/mcp_server/tests/artifact_tests.rs, src/mcp_server/tests/asset_tests.rs
Covers comments, labels, artifacts, handoffs, assets, encoding, deduplication, versioning, filtering, and invalid actions.
Item and routing tests
src/mcp_server/tests/item_tests.rs, src/mcp_server/tests/mod.rs
Covers item lifecycle, grooming, standup and health projections, workspace resolution, resource routing, schemas, skills, tools, and test harness wiring.

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related PRs

Suggested labels: rust

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch task/168

Comment @coderabbitai help to get the list of available commands.

getappz added a commit that referenced this pull request Jul 21, 2026
)

* fix(search): rename max_results->num_results for rivalsearch; sanitize store FTS query

- search_web: rivalsearch web_search expects num_results, not max_results
  (#253)
- search_store: sanitize query via flare_search_kit::fts_query to prevent
  FTS5 column-name parsing errors like 'no such column: ctx' (#254)

Agentflare-Agent: 1
Agentflare-Branch: fix/search-web-store-bugs

* fix(search): avoid unsanitized FTS5 fallback in store search

fts_query() returns None only when the sanitized query has no tokens
(e.g. quote-only input). The unwrap_or_else fallback was resubmitting
the raw, unsanitized query to FTS5 MATCH in that case, undermining the
sanitization it was meant to guarantee. Return an empty result set
instead.

Agentflare-Agent: claude-code_2-1-216_agent
Agentflare-Branch: fix/search-web-store-bugs

* fix(search): clamp web search limit to rivalsearch's num_results bound

rivalsearch web_search rejects num_results outside 1..=20 (schema
validation). An unclamped limit (e.g. the default max of 50 used
elsewhere, or a caller-supplied value) failed the whole search call
instead of returning a truncated result set.

Agentflare-Agent: claude-code_2-1-216_agent
Agentflare-Branch: fix/search-web-store-bugs
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