Skip to content

feat: ingest and query organization datasets in Recoup - #1240

Merged
sidneyswift merged 5 commits into
mainfrom
codex/org-ingestion
Nov 10, 2026
Merged

sidneyswift merged 5 commits into
mainfrom
codex/org-ingestion

Conversation

@sidneyswift

@sidneyswift sidneyswift commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Organization imports can now land in Recoup's existing database: original and processing files remain private, while validated gold becomes queryable as organization-owned dataset/import records. External client database delivery stays optional.

  • Organization creates register an import and return dataset_id; passing that ID on later creates adds an immutable import version.
  • Workers atomically store ready gold and its completion receipt through the guarded database gateway. Held/rejected results retain metadata without gold rows; lost acknowledgements and completion-marker failures remain retryable.
  • Add authenticated HTTP/MCP datasets, imports and paginated records reads with organization scope, explicit import versions and per-operation limits. GET remains read-only.
  • Replaying a completed private import can repair its shared catalog entry after integrity-checking saved gold. No per-org databases, schemas or new client credentials are required.

Depends on Database PR #133. Apply that migration to the existing Recoup project before deploying/enabling this consumer. INGESTION_ENABLED remains off pending hosted qualification.

Validation on 98fba08d: every CI check passes, including the full API regression suite, production/contract/workflow compiler checks, lint, formatting and OAuth compatibility. The ingestion job passes 107 tests on each of PostgreSQL 15 and 17; the optional joined test is skipped in that ordinary CI job and passes separately against the real migrations in the local database harness. The database harness passes twelve SQL cases plus that joined API lifecycle on PostgreSQL 17, covering exact values, acknowledgement-loss recovery, versioned imports, cross-org denial, revocation and bounded pagination. Hosted PR-preview metadata confirms the table grants, guarded RPC and page-budget correction. Vercel preview builds successfully; preview and production HTTP checks return the expected disabled 404 with private/no-store headers.

Review: missing/corrupt saved gold, invalid UTF-8, malformed completion metadata, exact redaction, denied unit membership and explicit membership fixture columns are covered. Addressed review threads have been resolved. The remaining operation-processor refactoring suggestion is retained for human review. Inline record payloads have a 2 MiB budget; oversized records remain stored and require a future large-object export path.

No production migration, intake activation or new client database was performed. See lib/ingestion/CATALOG.md for operations, shared ownership, limits, validation boundaries and rollout order.

@vercel

vercel Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
api Ready Ready Preview Nov 9, 2026 11:57pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@cubic-dev-ai cubic-dev-ai 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.

Review completed against the latest diff

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread lib/ingestion/schemas.ts Resolved
Comment thread lib/ingestion/__tests__/catalog.test.ts Resolved
Comment thread lib/ingestion/CATALOG.md Resolved

@cubic-dev-ai cubic-dev-ai 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.

1 issue found and verified against the latest diff

Confidence score: 4/5

  • processIngestionOperation.ts is already 175 lines, and adding catalog reads makes the dispatcher harder to maintain. Extract the catalog logic into a focused helper.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="lib/ingestion/processIngestionOperation.ts">

<violation number="1" location="lib/ingestion/processIngestionOperation.ts:22">
P2: Custom agent: **Enforce Clear Code Style and Maintainability Practices**

`processIngestionOperation.ts` is now 175 lines, and this dispatch adds catalog reads to the already over-limit operation processor. Extract catalog-query handling or other operation flows into focused modules to bring the file under the 100-line cap.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

if ((await deps.authorize(actor, args.organization_id)) !== scope)
throw new Error("Scope changed");
};
if (args.action === "datasets" || args.action === "imports" || args.action === "records") {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: Custom agent: Enforce Clear Code Style and Maintainability Practices

processIngestionOperation.ts is now 175 lines, and this dispatch adds catalog reads to the already over-limit operation processor. Extract catalog-query handling or other operation flows into focused modules to bring the file under the 100-line cap.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At lib/ingestion/processIngestionOperation.ts, line 22:

<comment>`processIngestionOperation.ts` is now 175 lines, and this dispatch adds catalog reads to the already over-limit operation processor. Extract catalog-query handling or other operation flows into focused modules to bring the file under the 100-line cap.</comment>

<file context>
@@ -19,6 +19,12 @@ export async function processIngestionOperation(
     if ((await deps.authorize(actor, args.organization_id)) !== scope)
       throw new Error("Scope changed");
   };
+  if (args.action === "datasets" || args.action === "imports" || args.action === "records") {
+    const { action, organization_id: _organization, ...query } = args;
+    const result = await deps.catalog(actor, scope.split("/")[1], action, query);
</file context>

Comment thread lib/ingestion/__tests__/catalog.test.ts Resolved

@cubic-dev-ai cubic-dev-ai 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.

1 existing issue remains and no new issues found across 15 files (changes from recent commits).

Confidence score: 4/5

  • lib/ingestion/processIngestionOperation.ts is 180 lines and processIngestionOperation still handles several distinct flows, making it harder to maintain. Split the flows into focused helpers or modules and keep the file below the 100-line limit.

Requires human review: Auto-approval blocked because this review re-detected 1 unresolved issue already reported by Cubic.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread lib/ingestion/CATALOG.md Resolved

@cubic-dev-ai cubic-dev-ai 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.

0 issues found across 4 files (changes from recent commits).

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Requires human review: Auto-approval blocked by 6 unresolved issues from previous reviews.

View guided diff | Turn on auto-fix | Re-trigger cubic

@cubic-dev-ai cubic-dev-ai 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.

0 issues found across 3 files (changes from recent commits).

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Requires human review: Auto-approval blocked by 1 unresolved issue from previous reviews.

View guided diff | Turn on auto-fix | Re-trigger cubic

@sidneyswift
sidneyswift merged commit d4c703b into main Nov 10, 2026
9 checks passed

This branch was successfully deployed

1 active deployment
Preview — 98fba08d Deployed Nov 9, 2026 by vercel[bot]
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