Pecauva
Pecauva is an AI research workspace for finance teams. Analysts upload reports, prospectuses, and disclosures into a project, ask questions across them, compare answers document by document, and turn the findings into files and compliance-reviewed drafts.
I built it end to end: the Next.js app, the agents service, the ingestion pipeline, retrieval, the research matrix, sandboxed artifact generation, and the review workflow.
One rule shaped the system: every answer has to point back to a document. Retrieval never leaves the project, each matrix cell answers from one file, and N/A is a valid answer.

Project overview
The dossier view gives one project-scoped place to move into research, drafts, playbooks, results, and compliance review.
System - Two services, one data plane
Everything runs on Cloudflare except the database, the model, and the sandbox. The web Worker owns auth, organizations, and the interface. A private agents Worker, reachable only through a service binding, does the slow work in durable Workflows, so uploads, research runs, and playbooks resume after a failure instead of starting over.
Files go straight from the browser to R2 through a presigned URL. The agents Worker then starts an ingestion workflow: convert to markdown with Workers AI, chunk, embed with OpenAI, upsert into Vectorize, and wait until the vectors are searchable before marking the document ready.
Ingestion - From file to searchable chunks
A document is only useful once it can be found in pieces. Each upload goes through the same four stages, and its status is visible in the project the whole way.
The workflow loads the file from R2 and converts it to markdown with Workers AI. Very large Word files go through a streaming extractor instead, so the Worker stays inside its memory limit.
Research matrix - One question, every document
A single blended answer hides which file said what. In the matrix, each question is a column, each document is a row, and each cell is answered from that document alone. If the file doesn't say, the cell says N/A instead of borrowing from another one.
Each question is embedded once and reused for every document. Cells then run in batches of five, each as its own durable step with two retries. A cell that still fails is recorded as failed, and the run keeps going.
Illustrative data and timings. Scheduling, job IDs, and statuses follow the real pipeline.

Research panel
The research ledger in the product: one question answered per uploaded document, with sources.
Project agent - Chat that cites its sources
The agent searches only the active project's namespace and keeps the five strongest chunks. When a question names documents or asks for an overview, results are spread across files, at most two from each, so one long file can't drown out the rest. Overview questions also pull each document's opening chunks.
Every answer is saved with its citations: the document, chunk, and a short snippet.

Project agent
Answers grounded in the uploaded documents, with sources attached.
Playbooks - Code in a sandbox, not in the prompt
A playbook is a set of metrics that each produce a file. Asking a model to write a spreadsheet directly is unreliable, so it writes Python instead, and the code runs in an isolated sandbox.
- retrieve24 chunks for the metric
- writemodel writes Python for /tmp/output.{csv,pdf,xlsx}
- checkpy_compile before anything runs
- runE2B sandbox, 120 s timeout
- repairup to 3 rounds, each fed the stderr
- storefile to R2, sandbox always killed
If the sandbox is unavailable, CSV metrics fall back to a text answer. PDF and XLSX metrics fail with a specific error code rather than a broken file.
Compliance - A review with a paper trail
Drafts go through review before they can be exported. An AI pass checks the draft against the organization's policies and raises up to three findings. A person with the compliance role makes the decision, and every resubmission starts a new review cycle.
- cycle 1queuedreviewdecisionpending
- cycle 2queuedreviewdecisionpending
Stack
Next.js 16 and React 19 on a Worker through OpenNext. Hono and Cloudflare Workflows for agents. Workers AI for document conversion, Vectorize for vectors, R2 for files, OpenAI for generation and embeddings, Postgres on Neon with Drizzle, E2B for sandboxes, and Better Auth with organizations and roles.
Pecauva is still in testing, so this case study covers design, architecture, and implementation rather than adoption numbers.
What mattered most
Grounding over fluency. A finance team can work with an answer that says N/A and points to the right file. It can't work with a confident answer it has to verify from scratch.