Skip to content

feat: Red Flag DD workflow, unified file_id, and document-file linking#834

Merged
larryro merged 4 commits into
mainfrom
feat/red-flag-dd-workflow
Mar 23, 2026
Merged

feat: Red Flag DD workflow, unified file_id, and document-file linking#834
larryro merged 4 commits into
mainfrom
feat/red-flag-dd-workflow

Conversation

@larryro
Copy link
Copy Markdown
Collaborator

@larryro larryro commented Mar 23, 2026

Summary

  • Red Flag DD workflow: Add a new red-flag-dd.json workflow example that uses the structured DOCX round-trip pattern (RAG index → extract → batch LLM → apply modifications) for due diligence report generation from VDR documents. Reorganize examples/workflows/ by renaming contract-generation/ to docx-generation/.
  • Unified file_id across RAG API: Rename document_id to file_id throughout the RAG service (API, database, platform callers, tests) for consistent naming. Add runtime migration helper and extract shared result parsing into parse_search_results with source filename annotations.
  • Link fileMetadata to documents: Add documentId field to fileMetadata schema establishing bidirectional file↔document linking, with schema changes, mutation updates, backfill migration, and OneDrive import propagation.
  • Cross-thread human input status: Fix chat sidebar to show "awaiting input" instead of "running" when a workflow is paused for human input on a sub-thread.
  • File ID in RAG search results: Include FileID annotation in formatted search output so agents can reference specific files.

Test plan

  • New tests for fileMetadata mutations and document upload flows
  • Updated document_retrieve_tool tests for file_id naming
  • New find_document_by_file_id tests
  • Updated RAG service tests (test_rag_service, test_search_service, test_indexing_service) for file_id
  • format_search_results tests updated for file_id annotation
  • Output validation step tests updated
  • Manual: verify Red Flag DD workflow end-to-end
  • Manual: verify chat sidebar shows correct status for cross-thread human input

Summary by CodeRabbit

  • New Features

    • Introduced "Red Flag DD Report" workflow enabling automated document generation with knowledge base integration and LLM-powered analysis.
    • Enhanced chat status indicators to display when a workflow is paused awaiting user input.
  • Improvements

    • Refined document identification and tracking mechanisms across the system.

larryro added 4 commits March 22, 2026 21:43
…on examples

Rename examples/workflows/contract-generation/ to docx-generation/ and add
a new red-flag-dd.json workflow that reuses the same structured DOCX
round-trip pattern (RAG index → extract → batch LLM → apply modifications)
with DD-specific prompts for due diligence report generation from VDR documents.
Unify naming to use file_id consistently in the RAG service API,
database schema, platform callers, and tests. Adds a runtime migration
helper (ensure_file_id_column) for existing databases. Extracts shared
RAG result parsing into parse_search_results and adds source filename
annotations to formatted search results.
…uman input status

Add documentId field to fileMetadata schema to establish a bidirectional
link between files and documents. This includes schema changes, mutation
updates, a backfill migration, and new linkDocumentToFile internal
mutation. OneDrive import flows now propagate documentId through the
pipeline.

Fix chat sidebar to show "awaiting input" (yellow dot) instead of
"running" (spinner) when a workflow is paused for human input on a
sub-thread, by cross-referencing execution IDs across approvals.

Add tests for fileMetadata mutations and document upload flows.
Add FileID annotation to RAG search result output so agents can
reference specific files. Update parser regex to handle the new
annotation and add tests for file_id formatting.
Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@larryro larryro merged commit 7966de8 into main Mar 23, 2026
16 of 17 checks passed
@larryro larryro deleted the feat/red-flag-dd-workflow branch March 23, 2026 04:02
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 23, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR unifies identifiers across the RAG, Convex platform, and database layers by systematically replacing document_id/document_ids with file_id/file_ids throughout API models, database schemas, service implementations, and client code. It adds file metadata linking to associate uploaded files with created documents via a new fileMetadata schema field and linkDocumentToFile internal mutation. A shared RAG result parsing utility (parseRagResults) is introduced to extract normalized relevance scores and matched content blocks. The chat sidebar logic is updated to detect workflow execution pauses by cross-referencing human input approvals. A new DOCX generation workflow definition (red-flag-dd.json) is added to support templated report generation with RAG-backed content replacement and track changes.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • #833: Performs identical document_id → file_id identifier unification across RAG APIs, Convex agent document helpers, and workflow document actions.
  • #794: Modifies RAG search tool payload structure and file-ID resolution logic with overlapping changes to file identifier propagation.
  • #722: Adds DOCX-generation and contract-comparison workflows with extensive overlapping code-level changes to RAG identifier migration, file metadata, and search schema.
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 44.94% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the three main objectives: introducing a Red Flag DD workflow, unifying the file_id naming across the RAG service, and implementing document-file linking.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 feat/red-flag-dd-workflow

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

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