Skip to content

fix: vent tag union + flare-docs fetch-outcome observability - #338

Merged
getappz merged 4 commits into
masterfrom
task/332
Jul 26, 2026
Merged

fix: vent tag union + flare-docs fetch-outcome observability#338
getappz merged 4 commits into
masterfrom
task/332

Conversation

@getappz

@getappz getappz commented Jul 26, 2026

Copy link
Copy Markdown
Owner

Summary

  • consolidate_core now unions each line's tags into its topic group instead of overwriting with the last line seen for that topic within a batch.
  • agentflare_backend::vent::upsert now merges incoming tags with what's already stored (union + dedupe) instead of unconditionally replacing the tags column.
  • fetch_and_store/store_fetched now return a FetchOutcome (crate-overview doc, flattened, plus items_indexed/items_error) instead of a bare Document, so a per-item indexing failure is visible to the CLI and MCP response instead of only reaching an eprintln! on the server's own stderr.

Net effect (vent): a later consolidation run with no tags (or a different subset) on a recurring topic can no longer silently erase tags a prior run had already persisted for that topic_key. Flagged by CodeRabbit on #331, deferred as a follow-up (needs coordinated CLI + backend changes). Fixes #332.

Net effect (flare-docs): discovered while manually verifying that flare_docs search actually returns per-item results — a stale/broken installed binary was silently indexing 0 per-item docs for every crate but one, with zero observable signal through the MCP tool. Fixes #340.

Test plan

  • cargo test -p agentflare-backend vent:: (new upsert_unions_tags_instead_of_replacing)
  • cargo test --bin agentflare vent:: (new same_topic_lines_union_tags_within_one_batch, later_untagged_consolidation_does_not_erase_prior_tags)
  • cargo test -p flare-docs (26 passed, incl. updated fetch_and_store tests asserting items_indexed/items_error)
  • cargo test --bin agentflare flare_docs (5 passed)
  • cargo clippy clean on touched crates; cargo fmt applied
  • cargo build --workspace --all-features
  • Manually verified against real docs.rs: refreshed tokio/anyhow/itoa, confirmed search returns real per-item hits (e.g. docsrs/tokio/latest/item/tokio::task::blocking::spawn_blocking)

Summary by CodeRabbit

  • Bug Fixes
    • Tags are now preserved and merged across repeated entries for the same topic.
    • Duplicate tags are removed while maintaining their original order.
    • Untagged updates no longer erase tags saved from earlier entries.
    • Tag handling is consistent within a single consolidation batch and across separate updates.
  • Improvements
    • Documentation fetching now reports per-item indexing results, including item-level error details, without failing the overall operation.
    • The CLI now prints this richer fetch outcome and surfaces item indexing failures more clearly.

consolidate_core now unions each line's tags into its topic group instead
of overwriting with the last line's tags. agentflare_backend::vent::upsert
now merges incoming tags with what's already stored (union + dedupe)
instead of unconditionally replacing the tags column, so a later
consolidation run with no/different tags can't silently erase tags a
prior run already persisted for the same topic_key.

Fixes #332.
@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Vent consolidation and backend upsert now preserve tags by unioning and deduplicating them across same-topic lines and repeated writes. Rustdoc fetching now returns structured indexing outcomes, which are propagated through CLI and MCP callers.

Changes

Vent tag union preservation

Layer / File(s) Summary
Consolidation tag accumulation
src/vent/consolidate.rs
Same-topic lines accumulate unique tags during consolidation, with tests covering multiple tagged lines and later untagged runs.
Persistent tag merging
crates/agentflare-backend/src/vent.rs
Existing tags are loaded during upsert, merged with incoming tags, and persisted without duplicates; repeated-upsert behavior is tested.

Rustdoc fetch outcomes

Layer / File(s) Summary
Fetch outcome contract and indexing reporting
crates/flare-docs/src/rustdoc.rs
FetchOutcome returns overview data with per-item indexing counts and structured errors while preserving successful overview storage.
Fetch outcome caller integration
src/cli/docs.rs, src/mcp_server/flare_docs.rs
CLI output reports indexing errors, and MCP serialization now includes the complete fetch outcome.

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

Sequence Diagram(s)

sequenceDiagram
  participant CliOrMcp
  participant rustdoc_fetch
  participant ItemIndexer
  CliOrMcp->>rustdoc_fetch: request fetch and store
  rustdoc_fetch->>ItemIndexer: index fetched items
  ItemIndexer-->>rustdoc_fetch: return count or error
  rustdoc_fetch-->>CliOrMcp: return FetchOutcome
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The flare-docs and CLI/MCP observability changes are not covered by linked issue #332 and appear out of scope here. Either link the flare-docs work to its own issue or split it into a separate PR focused on #332.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The vent tag union changes and tests satisfy #332’s requirements for batch and persisted tag merging.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title is concise and accurately highlights the main changes: vent tag union and flare-docs fetch-outcome observability.
Description check ✅ Passed The PR description covers the required summary and test plan and is mostly complete, though the reviewers' notes section is omitted.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch task/332

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: 2

🤖 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 `@crates/agentflare-backend/src/vent.rs`:
- Around line 56-62: Make the existing-vent read, merge via merge_tags_json, and
UPDATE in the upsert flow atomic by wrapping them in an immediate write
transaction. Ensure concurrent writers cannot read the same old_tags_json and
overwrite each other’s merged tags, while preserving the current update
behavior.

In `@src/vent/consolidate.rs`:
- Around line 93-97: The tag canonicalization currently skips duplicates present
in initial input arrays. In src/vent/consolidate.rs lines 93-97, initialize
grouped tags empty and let the existing loop deduplicate every line; in
crates/agentflare-backend/src/vent.rs lines 101-109, rebuild tags from both JSON
arrays into an empty vector and use the canonical result for new-row inserts.
Add an initial duplicate tag and assert exact insertion order without sorting in
src/vent/consolidate.rs lines 362-380, and cover duplicate tags on the first
upsert with serialized-order assertions in crates/agentflare-backend/src/vent.rs
lines 201-257.
🪄 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: 145d3f8f-92a9-4620-a1a2-407dc59fb312

📥 Commits

Reviewing files that changed from the base of the PR and between 0db24b2 and f31aefb.

📒 Files selected for processing (2)
  • crates/agentflare-backend/src/vent.rs
  • src/vent/consolidate.rs

Comment thread crates/agentflare-backend/src/vent.rs
Comment thread src/vent/consolidate.rs
…them

fetch_and_store/store_fetched now return a FetchOutcome (crate-overview
doc, flattened, plus items_indexed and items_error) instead of a bare
Document. Previously a per-item indexing failure only reached an
eprintln! on the MCP server's own stderr -- invisible to the CLI, the
MCP tool response, and tests alike, so a refresh could silently index
zero items while reporting success.

Fixes #340.
@getappz getappz changed the title fix: vent tag union across consolidation batches and runs fix: vent tag union + flare-docs fetch-outcome observability Jul 26, 2026

@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: 2

🤖 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 `@crates/flare-docs/src/rustdoc.rs`:
- Around line 145-149: Remove the library-level eprintln from the per-item
indexing error branch in rustdoc.rs, while preserving the returned (0,
Some(msg)) outcome. In src/cli/docs.rs lines 79-81, retain the CLI-facing
items_error diagnostic; no direct change is required there.

In `@src/cli/docs.rs`:
- Around line 77-82: The fresh-fetch branches must return the same JSON shape as
cache-hit branches without inventing cache-hit telemetry. In
src/cli/docs.rs#L77-L82, update the DocsCmd::Get success output to match the
cached response contract; apply the equivalent change in
src/mcp_server/flare_docs.rs#L119-L122 for the MCP get handler, keeping both
paths document-only or using one shared response envelope consistently.
🪄 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: 2ec45637-e192-4b57-9391-86914af6fe5c

📥 Commits

Reviewing files that changed from the base of the PR and between f31aefb and 6d66c96.

📒 Files selected for processing (3)
  • crates/flare-docs/src/rustdoc.rs
  • src/cli/docs.rs
  • src/mcp_server/flare_docs.rs

Comment thread crates/flare-docs/src/rustdoc.rs Outdated
Comment thread src/cli/docs.rs
getappz added 2 commits July 26, 2026 13:28
- agentflare_backend::vent::upsert: wrap the read-merge-write of tags in an
  IMMEDIATE transaction so concurrent upserts for the same topic_key can't
  race and clobber each other's merged tag set. Also canonicalize
  (dedup) tags on first insert, not just on merge with an existing row.
- consolidate_core: seed each topic group's tags empty instead of from the
  first line's raw (possibly internally-duplicated) tags array, so the
  existing per-line dedup loop covers every line uniformly.
- flare-docs: drop the library-level eprintln! for per-item indexing
  failures now that FetchOutcome carries items_error to every caller;
  the CLI already prints its own diagnostic from that field.
- cli/docs.rs and mcp_server/flare_docs.rs: DocsCmd::Get / the "get"
  MCP action now return only the document on a cache-miss fetch, matching
  the cache-hit response shape, instead of the full FetchOutcome (with
  items_indexed/items_error) that only "refresh" asks for.

Adds regression tests for the duplicate-tag dedup fix in both
consolidate.rs and vent.rs.
@getappz
getappz merged commit d8f5165 into master Jul 26, 2026
15 checks passed
@getappz
getappz deleted the task/332 branch July 26, 2026 08: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

1 participant