Skip to content

feat(agent): add durable QuickBooks OAuth refresh - #231

Draft
MennaAhmed2024 wants to merge 1 commit into
trycompai:mainfrom
MennaAhmed2024:feat/quickbooks-oauth-refresh
Draft

MennaAhmed2024 wants to merge 1 commit into
trycompai:mainfrom
MennaAhmed2024:feat/quickbooks-oauth-refresh

Conversation

@MennaAhmed2024

@MennaAhmed2024 MennaAhmed2024 commented Sep 21, 2026 •

Copy link
Copy Markdown

Summary

Add durable QuickBooks OAuth refresh, realm-bound reads, and human-approved estimate drafts.

Closes #228

Problem

Issue #228 references a static-token integration. No QuickBooks implementation exists on the current upstream branches.
This PR adds the required agent integration rather than replacing a nonexistent client.

Solution

Persist encrypted tokens in PostgreSQL. Serialize refreshes with a row lock and commit rotated credentials before replaying requests.
A 401 permits one refresh and one replay. Refresh failures stop the replay.

Bind requests to the enrolled realm and environment. Restrict reads to customer, item, and estimate IDs.
Require human approval for every estimate. Deny scheduled creation and preserve request IDs across retries.
Estimates remain Pending and unsent.

Keep the integration disabled by default. Add an owner enrollment command and Intuit/Vercel setup instructions.
Enrollment checks owner membership and the QuickBooks company before storing credentials.

Validation

  • bun run check-types: passes across all 13 tasks.
  • bun run lint: passes, with existing repository warnings.
  • bun run lint:slop: passes.
  • Migrations apply successfully to an isolated PostgreSQL 18 test database.
  • 45 focused tests pass, including concurrent refresh, rollback, credential encryption, realm checks, and approval policies.
  • The full repository test suite is running. Results will be added here.

Deployment boundary

Production remains disabled. The owner must complete live OAuth enrollment, sandbox verification, and production sign-off.
No live Intuit requests or external accounting writes were performed during development.

Intuit rotation and PostgreSQL cannot share a transaction. A crash between them requires token recovery or owner re-enrollment.
The setup guide documents this recovery path.


Summary by cubic

Adds a QuickBooks integration to the agent with durable OAuth refresh, realm-bound reads, and human-approved estimate drafts. Closes issue #228; no QuickBooks integration existed upstream, so this is net-new rather than a replacement.

Behavior

  • Stores the token pair encrypted in a new quickBooksConnection table, with a row lock serializing concurrent refreshes across instances.
  • A 401 triggers exactly one refresh and one replay; refresh, parse, or save failures stop the replay without further retries.
  • Reads accept only known customer, item, and estimate IDs and are bound to the enrolled realm and environment.
  • Every estimate draft requires human approval, stays Pending and unsent, and never emails or invoices.

Migration and rollout

  • Requires a new Prisma migration and the QUICKBOOKS_ENCRYPTION_KEY environment variable; losing or changing it forces owner re-enrollment.
  • Disabled by default; the owner must run the enrollment script and complete sandbox verification before enabling production.
  • Intuit token rotation and PostgreSQL can't share a transaction, so a crash between them requires token recovery or re-enrollment.

Written for commit cbb786d. Summary will update on new commits.

Review in cubic

@vercel

vercel Bot commented Sep 21, 2026

Copy link
Copy Markdown

@mennademrdash is attempting to deploy a commit to the Comp AI - PoC Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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.

2 participants