Skip to content

Add portable workbook inspection and royalty conformance - #1325

Merged
sidneyswift merged 6 commits into
mainfrom
codex/ingestion-royalty-conformance
Dec 4, 2026
Merged

sidneyswift merged 6 commits into
mainfrom
codex/ingestion-royalty-conformance

Conversation

@sidneyswift

@sidneyswift sidneyswift commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Expose a portable workbook inspector with bounded row samples, physical coordinates and clipping indicators. Use the same XLSX reader as the Recoup processing core.
  • Exercise independently authored synthetic royalties across two detail sheets and a summary. Preserve exact amounts and identifiers, verify replay and hold details assigned to the wrong account.

Part of #1319 and recoupable/mono#819. Hosted qualification continues under #1320.

Verification

  • 142 local ingestion tests passed, with six database integration cases skipped.
  • Strict ingestion core type check and focused lint passed.
  • A clean Node consumer installed and exercised the development tarball.

Summary by cubic

Adds portable workbook inspection for surveying XLSX layout before drafting ingestion mappings, plus conformance tests and a hosted qualification mode for synthetic royalty statements.

  • inspectIngestionWorkbook() samples up to five nonempty rows per sheet with physical row numbers and clipping markers on cells over 200 code points, reusing the same XLSX reader as the ingestion pipeline. Unsampled sheets keep their inventory entry and report a sheet issue instead of failing.
  • Tests reconcile two detail tabs to a summary total, verify deterministic replay, and hold a misassigned account even when the total still balances.
  • A new royalty qualification mode posts the synthetic statement to a hosted deployment over HTTP and MCP, reconciling both detail tabs and comparing completion receipts and gold records.
  • Storage reads treat NoSuchKey responses — direct or wrapped in a legacy Supabase error response — as a missing object and no longer fail, while denied or unavailable reads still raise an error.

Written for commit 78a727d. Summary will update on new commits.

View guided diff Turn on auto-fix

@vercel

vercel Bot commented Dec 4, 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 Dec 4, 2026 8:34pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Dec 4, 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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-04T01:52:20.643938Z 2c22aaf PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2c22aaf066

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@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.

All reported issues were addressed across 4 files

Architecture diagram
sequenceDiagram
    participant Client as External Consumer
    participant Inspector as inspectIngestionWorkbook()
    participant XLSX as openIngestionWorkbook()
    participant Config as ingestionContractSchema
    participant Pipeline as runIngestionPipeline()
    participant Records as Silver/Gold Records
    participant Controls as Control Checks

    Note over Client,Controls: Portable workbook inspection and royalty conformance flow

    Client->>Inspector: inspectIngestionWorkbook(bytes)
    Inspector->>Inspector: Validate size (INGESTION_MAX_BYTES)
    alt Size invalid
        Inspector-->>Client: throw FILE_SIZE_INVALID
    end
    Inspector->>XLSX: open bytes (options: "2")
    XLSX-->>Inspector: workbook with sheetNames + rowsFor()
    Inspector->>Inspector: Validate sheet count (1-100) + uniqueness
    alt Sheet coverage invalid
        Inspector-->>Client: throw SHEET_COVERAGE_MISMATCH
    end

    loop Each sheet
        Inspector->>XLSX: rowsFor(name)
        XLSX-->>Inspector: Row stream (number + cells)
        Inspector->>Inspector: Collect up to 5 nonempty rows
        Inspector->>Inspector: Clip cell strings to 200 chars + mark clipped
    end
    Inspector-->>Client: Sheet inventory + row samples (physical coords)

    Client->>Config: Parse contract (fields, roles, checks)
    Config-->>Client: Validated contract

    Client->>Pipeline: runIngestionPipeline(bytes, "xlsx", contract)
    Pipeline->>XLSX: Read workbook synchronously
    XLSX-->>Pipeline: Raw rows per sheet

    alt Happy path (roles + checks pass)
        Pipeline->>Pipeline: Map data sheets (Digital, Physical)
        Pipeline->>Records: Build silver records with source coords
        Pipeline->>Pipeline: Check Summary control cell B2 vs mapped total
        Controls-->>Pipeline: passed: true, actual: "100"
        Pipeline->>Records: Build gold records
        Pipeline-->>Client: status: "ready" + records + controls
    else Misassigned account (row identity broken)
        Pipeline->>Pipeline: Map data sheets with constant account "002"
        Pipeline->>Records: Build silver records (ignored Account column)
        Pipeline->>Pipeline: Check Summary control vs constant account
        Controls-->>Pipeline: passed: false (reconciliation fails)
        Pipeline->>Pipeline: Hold gold layer
        Pipeline-->>Client: status: "held" + gold: null
    end

    Note over Client,Pipeline: Replay safety: re-running pipeline yields identical result
Loading

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

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.

All reported issues were addressed across 8 files (changes from recent commits).

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

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

Comment thread scripts/ingestion-qualification/run.mjs Resolved
Comment thread packages/ingestion/README.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.

All reported issues were addressed across 6 files (changes from recent commits).

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

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

Comment thread lib/ingestion/__tests__/storage.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.

0 issues found across 1 file (changes from recent commits).

Confidence score: 5/5

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

Auto-approved: Adds a bounded workbook inspection helper with tests/docs, a storage fix treating NoSuchKey reads as missing, and dev-only royalty qualification scripts; no production behavior or exposure expands.

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

@sidneyswift
sidneyswift merged commit 5967aed into main Dec 4, 2026
11 checks passed

This branch was successfully deployed

1 active deployment
Preview — 78a727d7 Deployed Dec 4, 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