Skip to content

chore: reconcile drop-backend-prefix into master (branch divergence) - #172

Merged
getappz merged 2 commits into
masterfrom
chore/reconcile-drop-backend-prefix-into-master
Jul 13, 2026
Merged

chore: reconcile drop-backend-prefix into master (branch divergence)#172
getappz merged 2 commits into
masterfrom
chore/reconcile-drop-backend-prefix-into-master

Conversation

@getappz

@getappz getappz commented Jul 13, 2026

Copy link
Copy Markdown
Owner

master gained its own independent squash-commit for the 4-tool consolidation (133b6dd), separate from the drop-backend-prefix branch line — so PR #169 (merged into drop-backend-prefix) never reached master, and master's later PRs (#170, #171) never reached drop-backend-prefix. The two lines diverged with unique work on each side.

This is a straightforward non-conflicting merge bringing drop-backend-prefix's unique commit (asset versioning + handoff-assigns-items rework) into master. No conflicts — different files/areas touched on each side.

Summary

  • Adds immutable per-entity/filename asset versioning to the backend (asset.rs, db.rs, migration 0003_asset_versioning.sql).
  • MCP handoffs now assign or create backend items and attach content as versioned assets instead of using standalone artifacts.
  • Updates handoff/artifact guidance in mcp_prompts.rs and request/response handling + tests in mcp_server.rs.

Test plan

  • cargo test — 365/365 passing
  • cargo fmt --check — clean
  • cargo clippy --workspace --all-targets -- -D warnings -A unsafe_code -A clippy::pedantic — clean
  • Verified no file/area overlap between the two diverged lines (backend asset/mcp files vs. tool-consolidation files)

Notes for reviewers

  • This is a reconciliation merge, not new feature work — the underlying asset-versioning and item-assignment changes were already reviewed on the source branch prior to divergence.
  • Risk area: mcp_server.rs handoff path now creates/attaches backend items instead of artifacts; /artifact remains available for standalone use but is deprecated for handoffs.
  • Backwards compatibility: additive DB migration (new assets.version column), no destructive schema changes.

getappz added 2 commits July 13, 2026 23:43
…ng send path

Fixes two related gaps: /handoff inbox listed via unscoped artifact_list (leaked across every project); fn handoff send path never touched an item. Now inbox uses item(action=list) (project-scoped), and handoff assigns/creates an item and attaches content as a versioned asset instead of publishing a flat-file artifact. Includes a CodeRabbit-flagged fix: asset filename (and version chain) is keyed on item.id, not the mutable brief/name.
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The backend adds immutable asset versioning per entity and filename. MCP handoffs now assign or create backend items and attach content as versioned assets, with updated request fields, responses, prompts, and tests.

Changes

Versioned asset handoffs

Layer / File(s) Summary
Asset version persistence
crates/agentflare-backend/src/asset.rs, crates/agentflare-backend/src/db.rs, crates/agentflare-backend/src/migrations/...
Adds the assets.version schema field, computes sequential versions during creation, returns versions from queries, and tests filename-specific version chains.
Backend item and asset handoff
src/mcp_server.rs
Changes handoffs to assign or create items, store content in workspace asset storage, create item_attachment assets, and return item and asset identifiers with versions.
Handoff guidance and validation
src/mcp_prompts.rs, src/mcp_server.rs
Updates handoff and artifact guidance for item/asset workflows and rewrites tests for item assignment, attachments, and repeated handoffs.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Agent
  participant HandoffTool
  participant BackendDatabase
  participant AssetStorage
  Agent->>HandoffTool: Submit recipient, content, and optional item_id
  HandoffTool->>BackendDatabase: Assign existing item or create new item
  HandoffTool->>AssetStorage: Store content file when absent
  HandoffTool->>BackendDatabase: Create versioned item_attachment asset
  BackendDatabase-->>HandoffTool: Return item and asset identifiers
  HandoffTool-->>Agent: Return item_id, asset_id, and asset_version
Loading

Possibly related PRs

Suggested labels: enhancement, rust

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title is concise and accurately describes the merge reconciliation between diverged branches.
Description check ✅ Passed The description matches the template with Summary, Test plan, and Notes for reviewers, and it includes the key changes and verification.
✨ 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 chore/reconcile-drop-backend-prefix-into-master

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

🤖 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/asset.rs`:
- Around line 133-138: Update the asset creation flow containing the version
lookup and subsequent INSERT to execute both statements within one SQLite
transaction, matching the transaction pattern used by item::create and
project::create. Ensure the transaction commits only after the versioned asset
insert succeeds and propagates failures without leaving partial state.
🪄 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: c0c4caff-3bf5-45ee-a9e2-0dc18932dbec

📥 Commits

Reviewing files that changed from the base of the PR and between 61a3c9e and 3ea5a69.

📒 Files selected for processing (5)
  • crates/agentflare-backend/src/asset.rs
  • crates/agentflare-backend/src/db.rs
  • crates/agentflare-backend/src/migrations/0003_asset_versioning.sql
  • src/mcp_prompts.rs
  • src/mcp_server.rs

Comment on lines +133 to +138
let version: i64 = conn.query_row(
"SELECT COALESCE(MAX(version), 0) + 1 FROM assets
WHERE entity_type = ?1 AND entity_id = ?2 AND filename = ?3 AND deleted_at IS NULL",
rusqlite::params![input.entity_type, input.entity_id, input.filename],
|r| r.get(0),
)?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Look for concurrent/multi-connection usage of asset::create and any unique index on assets(version).
rg -nP 'asset::create|assets\s*\(.*version' --type=rust -C2
rg -nP 'CREATE\s+(UNIQUE\s+)?INDEX.*assets' -C2 crates/agentflare-backend/src/migrations
rg -nP 'open_db|Connection::open|open_in_memory' --type=rust crates/agentflare-backend/src -C1

Repository: getappz/agentflare

Length of output: 156


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the asset create path and surrounding schema/migrations.
sed -n '1,240p' crates/agentflare-backend/src/asset.rs

printf '\n--- migrations mentioning assets ---\n'
fd -a . crates/agentflare-backend/src/migrations | sort | while read -r f; do
  echo "### $f"
  rg -n "assets|version|UNIQUE|CREATE INDEX|CREATE TABLE" "$f" || true
done

printf '\n--- DB connection / backend access paths ---\n'
rg -n "Connection::open|open_in_memory|with_backend_db|unchecked_transaction|transaction\(" crates/agentflare-backend/src -C 2

Repository: getappz/agentflare

Length of output: 34998


Wrap the version lookup and insert in a transaction. SELECT COALESCE(MAX(version), 0) + 1 and the following INSERT are separate statements, so concurrent connections can assign the same version for the same (entity_type, entity_id, filename) chain. There’s no unique index on (entity_type, entity_id, filename, version) to catch duplicates, and item::create / project::create already use a transaction for this pattern.

🤖 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 `@crates/agentflare-backend/src/asset.rs` around lines 133 - 138, Update the
asset creation flow containing the version lookup and subsequent INSERT to
execute both statements within one SQLite transaction, matching the transaction
pattern used by item::create and project::create. Ensure the transaction commits
only after the versioned asset insert succeeds and propagates failures without
leaving partial state.

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