Skip to content

fix: v1.6.0 verification bugs — opencode filePath guard hole, search web/store arms - #287

Merged
getappz merged 5 commits into
masterfrom
fix/v160-verification-bugs
Jul 21, 2026
Merged

fix: v1.6.0 verification bugs — opencode filePath guard hole, search web/store arms#287
getappz merged 5 commits into
masterfrom
fix/v160-verification-bugs

Conversation

@getappz

@getappz getappz commented Jul 21, 2026

Copy link
Copy Markdown
Owner

Fixes three bugs found while live-verifying the v1.6.0 release (agentflare work items #252, #253, #254 — item tracker numbers, not GitHub issues).

1. Branch guard: opencode native edits on master were unguarded (item #252, high)

hook_redirect.rs only read file_path/path from tool_input, but opencode native tools send camelCase filePath (forwarded raw by branch-guard.js). Since #283 removed the host-cwd fallback, the target repo resolved to None and the guard silently allowed default-branch edits from opencode. Both lookup sites now include filePath.

Verified live with the debug binary: camelCase payload on a master-checkout file now denies; non-repo file still allows; snake_case unchanged. Two regression tests added (pure classify + temp-git-repo integration test asserting the deny).

2. Search web arm always errored (item #253)

The web arm forwarded max_results to rivalsearch web_search, whose schema takes num_results (1..=20) — every call failed schema validation. Now sends num_results clamped to 1..=20, with extract_content/follow_links off (crawl defaults are too heavy for a search-arm result list).

3. Search store arm returned 0 despite matching artifacts (item #254)

Artifacts live in the artifacts store, not agentflare-store docs (and asset docs carry empty FTS content — bytes are in blobs), so the store arm could never match what its description promises. The artifact substring scan is extracted into a shared artifact_search_hits helper (the artifact tool search action now delegates to it, −42 duplicated lines) and the store arm folds matches in as an artifact group. Integration test: publish → store search finds it.

Verification

  • cargo fmt --check clean
  • cargo clippy --workspace --all-features -- -D warnings: only the two pre-existing Windows-local dead-code errors in daemon_autostart.rs (unix-cfg-only helpers, present on master, untouched here)
  • cargo test --workspace: 695 passed / 0 failed in the main crate, all other suites green

Summary by CodeRabbit

  • New Features

    • Store searches now include matching artifacts in a dedicated results group.
    • Artifact searches match names, descriptions, and content, with direct links and contextual snippets for content matches.
    • Web searches now return up to 20 results with streamlined content retrieval.
    • File redirects and branch protection now recognize camelCase filePath payloads.
  • Bug Fixes

    • Improved artifact and repository detection for tool calls using filePath.

getappz added 2 commits July 21, 2026 15:39
Agentflare-Agent: claude-code_2-1-216_harness
Agentflare-Branch: fix/v160-verification-bugs
…nto store arm

Agentflare-Agent: claude-code_2-1-216_harness
Agentflare-Branch: fix/v160-verification-bugs
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@getappz, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 34 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 7b3b7780-b96a-4cb4-8a7e-01457b7a4a56

📥 Commits

Reviewing files that changed from the base of the PR and between 1a8567f and 31b61ef.

📒 Files selected for processing (2)
  • src/mcp_server/artifact.rs
  • src/mcp_server/search.rs
📝 Walkthrough

Walkthrough

The change adds filePath support to redirect and branch-guard logic, extracts artifact matching into a shared helper, includes artifact hits in store search results, updates web-search parameters, and adds redirect and artifact-search tests.

Changes

Hook redirect compatibility

Layer / File(s) Summary
CamelCase file-path redirect guards
src/hook_redirect.rs
Write and Edit handling now reads filePath for spec redirect classification and target repository resolution, with regression tests covering redirect and deny decisions.

MCP search aggregation

Layer / File(s) Summary
Shared artifact search helper
src/mcp_server/artifact.rs
The artifact search action delegates case-insensitive matching, URL construction, session filtering, and content snippet generation to artifact_search_hits.
Artifact results in store search
src/mcp_server/search.rs, src/mcp_server/tests/search_tests.rs
Store search adds limited artifact matches under groups["artifact"], validated by an integration-style test.
Web search request parameters
src/mcp_server/search.rs
Web searches use clamped num_results values and disable content extraction and link following.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant search_store
  participant artifact_search_hits
  participant ArtifactStore
  Client->>search_store: submit search query
  search_store->>artifact_search_hits: search query
  artifact_search_hits->>ArtifactStore: list artifacts
  ArtifactStore-->>artifact_search_hits: artifact records
  artifact_search_hits-->>search_store: matched artifact hits
  search_store-->>Client: grouped results with artifact matches
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main fixes: opencode filePath guard, search web/store changes, and it is specific to the changeset.
Description check ✅ Passed The description covers the summary, why the fixes were needed, and verification, but it omits the template's explicit test plan and reviewer notes sections.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/v160-verification-bugs

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.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/hook_redirect.rs (1)

125-131: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consolidate path extraction and handle non-string values robustly.

The current or_else chain on Value::get will stop checking fallbacks if an earlier key exists but its value is not a string (e.g., {"file_path": null, "filePath": "src/main.rs"}). In that scenario, get yields Some(&Value::Null), bypassing the or_else blocks, and the subsequent as_str yields None.

Using an array and find_map is both more robust against hallucinated inputs and removes the duplication. You can introduce a helper like fn extract_target_path<'a>(v: &'a Value) -> Option<&'a str> { ["file_path", "path", "filePath"].into_iter().find_map(|k| v.get(k)?.as_str()) } and apply it across these sites:

  • src/hook_redirect.rs#L125-L131: Replace the inline or_else chain with .and_then(extract_target_path)?.
  • src/hook_redirect.rs#L161-L164: Replace the inline or_else chain with extract_target_path(ti) (which then cleanly chains into .map(Path::new)).
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/hook_redirect.rs` around lines 125 - 131, Consolidate target-path
extraction in src/hook_redirect.rs at lines 125-131 and 161-164 by adding an
extract_target_path helper that checks file_path, path, and filePath with
find_map and only accepts string values. Replace the anchor’s inline chain with
and_then(extract_target_path)? and the sibling’s chain with
extract_target_path(ti), preserving its existing Path::new mapping.
src/mcp_server/artifact.rs (1)

135-144: 🚀 Performance & Scalability | 🔵 Trivial | ⚖️ Poor tradeoff

Potential N+1 I/O issue during artifact search.

Calling store.get(&summary.id) inside the store.list() loop introduces an N+1 query pattern. If store.get performs disk I/O or network requests, this will scale poorly as the number of artifacts grows.

Consider batching these fetches or implementing a dedicated full-text search (FTS) method directly in the ArtifactStore layer if performance degrades in the future.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/mcp_server/artifact.rs` around lines 135 - 144, Update the artifact
search flow around the store.list loop to avoid calling store.get for every
summary. Prefer a batch retrieval or dedicated full-text search operation in
ArtifactStore that evaluates content together with name and description, while
preserving the existing matching and result behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/mcp_server/artifact.rs`:
- Around line 145-159: Update the snippet logic in the content search path to
cache the lowercased content, use that same string for both find and slicing,
and return the snippet from those matching lowercase bytes. Preserve the
existing 40-byte context and character-boundary adjustments while avoiding
repeated allocation and mismatched indices against the original content.

---

Nitpick comments:
In `@src/hook_redirect.rs`:
- Around line 125-131: Consolidate target-path extraction in
src/hook_redirect.rs at lines 125-131 and 161-164 by adding an
extract_target_path helper that checks file_path, path, and filePath with
find_map and only accepts string values. Replace the anchor’s inline chain with
and_then(extract_target_path)? and the sibling’s chain with
extract_target_path(ti), preserving its existing Path::new mapping.

In `@src/mcp_server/artifact.rs`:
- Around line 135-144: Update the artifact search flow around the store.list
loop to avoid calling store.get for every summary. Prefer a batch retrieval or
dedicated full-text search operation in ArtifactStore that evaluates content
together with name and description, while preserving the existing matching and
result behavior.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: c5f66919-90eb-4e44-88f3-c9b3eb162147

📥 Commits

Reviewing files that changed from the base of the PR and between f398c43 and 1a8567f.

📒 Files selected for processing (4)
  • src/hook_redirect.rs
  • src/mcp_server/artifact.rs
  • src/mcp_server/search.rs
  • src/mcp_server/tests/search_tests.rs

Comment thread src/mcp_server/artifact.rs Outdated
getappz added 2 commits July 21, 2026 18:05
Keeps master's num_results clamp (limit is already clamped at
assignment) plus this branch's extract_content/follow_links: false
flags for the web search arm.

Agentflare-Agent: claude-code_2-1-216_agent
Agentflare-Branch: fix/v160-verification-bugs
content.to_lowercase().find() returns a byte offset into the lowercased
string, then used it to slice the original content — if lowercasing
changes a character's byte length (some Unicode case-folding), the
offset no longer lines up with the original string. Cache the
lowercased string and slice from it instead of the original.

Agentflare-Agent: claude-code_2-1-216_agent
Agentflare-Branch: fix/v160-verification-bugs
@getappz
getappz enabled auto-merge (squash) July 21, 2026 12:36
@getappz
getappz merged commit 63a22d6 into master Jul 21, 2026
15 of 16 checks passed
@getappz
getappz deleted the fix/v160-verification-bugs branch July 21, 2026 12:50
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