Skip to content

feat(billing): include monthly investigations with Autumn-only billing - #788

Merged
izadoesdev merged 39 commits into
stagingfrom
codex/investigation-monthly-allowances
Sep 14, 2026
Merged

feat(billing): include monthly investigations with Autumn-only billing#788
izadoesdev merged 39 commits into
stagingfrom
codex/investigation-monthly-allowances

Conversation

@izadoesdev

@izadoesdev izadoesdev commented Sep 13, 2026

Copy link
Copy Markdown
Member

Business and Scale currently show zero investigations alongside credit grants. Give Business 100 investigations/month for $299 and Scale 500/month for $799, with $1 per completed investigation above the allowance. Included events remain 2M and 10M respectively.

Restore the older visible public comparison table and dashboard card layout. Pricing pages, calculator, API, structured data, Markdown, billing, and investigation prompts share the same terms. Remove duplicate explanations, zero-allowance rows, unsupported introductory pricing, and credit purchase/top-up controls for accounts with included chat. Disabled settings collapse fully; pending buttons retain their width and accessible label. Legacy attached plans and purchased balances retain their actual Autumn terms.

Autumn owns investigation billing. Native check-with-lock reserves a unit; completion confirms it and failed/incomplete work releases it. Remove the staging Postgres charge table, accepted-price field, and custom billing recovery loop. The immutable 23-hour hold remains inside Autumn's default idempotency window; saved results never create replacement charges. Missing or expired holds are neutral, so uncertain recovery can leave work free. Existing product job checkpoints and maintenance handle recovery without storing financial state.

The final review found that a delivered prepared result could swallow a settlement error and stop retries. Both worker completion and the existing maintenance finalizer now require settlement first. Generation saves its ordinary completed product checkpoint before propagating a settlement outage, allowing maintenance to recover even after the final worker attempt. Partial portfolios and model failures retain their previous handling.

Validation:

  • Fresh root lint, all 33 type/build tasks, and all 27 test tasks pass on the rebased source. Insights integration: 96 cases pass; the preceding API integration run passed 23 cases. Tests use an isolated empty Postgres database, local Redis, the installed Autumn SDK, and a stateful synthetic transport; no live customer was charged.
  • The new worker regression fails on the prior implementation and passes with the fix. Nonfinal retry and final-attempt maintenance recovery confirm the original hold with one model call, one reservation, one delivery, and no token debit.
  • Desktop and 390px public-page checks show aligned button frames, working keyboard table scrolling, and no page overflow. The actual dashboard component was also visually checked with sample native Autumn plans and compiled CSS. Authenticated live-customer checkout remains unverified.
  • Native pricing tests and previous Dashboard Playwright, service health, CodeQL, and preview checks passed. Final-head CI passed, including Dashboard Playwright. Greptile reviewed cb97d20 at 5/5 with no remaining actionable findings; all review pages were re-read and both threads were resolved before merge.

Economics: 12 earlier real Luna episodes averaged $0.00531 in model charges using synthetic backing services. This does not measure total operating cost. A conservative planning reserve of $0.25 per investigation allocates $25 on Business and $125 on Scale; subscription revenue must also cover chat, analytics, infrastructure, fees, and support. At 10M events and 500 investigations, Business totals $939 versus Scale's $799.

Scope: investigation billing, included chat, and presentation. No unmerged dependency. AI-assisted implementation and review under the maintainer workflow.

Production promotion #789 remains a draft. Live Autumn Business/Scale still have legacy v1 terms as of September 14; this PR does not sync live plans, activate customers, or mutate production databases. Release compatible code before replacing live credit entitlements. Live invoice/reset behavior remains unverified.

@vercel

vercel Bot commented Sep 13, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated
dashboard Ready Ready Preview Sep 14, 2026 12:35pm UTC
databuddy-status Ready Ready Preview Sep 14, 2026 12:35pm UTC
documentation Ready Ready Preview Sep 14, 2026 12:35pm UTC

@coderabbitai

coderabbitai Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 0949bfd5-1edb-4c57-8af5-a0d946d3f4da

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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

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

@unkey-deploy

unkey-deploy Bot commented Sep 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Unkey Deploy

Name Status Preview Inspect Updated (UTC)
links (preview) Ready Visit Preview Inspect Sep 14, 2026 12:35pm

@greptile-apps

greptile-apps Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR moves investigation billing fully onto Autumn while introducing monthly investigation allowances and overage terms for Business and Scale. It also aligns billing controls, chat entitlements, pricing surfaces, documentation, and structured data with those terms.

  • Business includes 100 investigations per month and Scale includes 500, with additional completed investigations billed at $1 each.
  • Native Autumn reservations are confirmed after successful completion and released for incomplete work without storing separate financial state in Postgres.
  • Worker and maintenance recovery now settle prepared results before marking their jobs successful.
  • Included-chat accounts use the native databunny_chat entitlement and no longer expose legacy credit purchase controls.
  • Pricing and billing interfaces restore the comparison layout, collapse disabled settings, and preserve loading and pending-control accessibility.

Confidence Score: 5/5

The PR appears safe to merge; the previously reported settlement-retry defect is fixed and no new actionable issue remains.

Settlement failures no longer allow a delivered prepared result to be checkpointed as successful before billing confirmation. Worker retries and maintenance recovery both confirm the original Autumn reservation before finalization, while the persisted prepared result prevents repeated model execution or delivery. The earlier loading-layout thread and settlement thread were manually resolved.

Important Files Changed

Filename Overview
apps/insights/src/generation.ts Persists the completed prepared result before propagating a native settlement outage, enabling replay without repeating generation.
apps/insights/src/jobs.ts Requires settlement of a recovered prepared result before checkpointing worker success and preserves retryable failure bookkeeping otherwise.
apps/insights/src/recovery.ts Requires native settlement before maintenance finalization and keeps prepared failed items eligible for later recovery.
apps/insights/src/investigation-billing.ts Implements Autumn-owned reservation, confirmation, and release using stable product identities.
apps/dashboard/app/(main)/billing/components/billing-controls-card.tsx Adapts billing controls to included chat and investigation-unit overage limits while fully unmounting disabled details.
apps/dashboard/app/(main)/billing/components/investigation-topup-card.tsx Separates monthly, prepaid, and additional investigation usage and preserves structural loading placeholders.
packages/shared/src/billing.ts Centralizes the investigation allowances, overage terms, and native included-chat entitlement semantics.
packages/ai/src/ai/tools/discover-query-types.ts Returns full query contracts for matches outside a requested category while retaining compact unfiltered browsing.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Investigation requested] --> B[Validate explicit analysis consent]
    B --> C[Autumn check with lock]
    C -->|Denied| D[Reject before model execution]
    C -->|Reserved| E[Generate investigation]
    E -->|Incomplete or failed| F[Release reservation]
    E -->|Readable result completed| G[Persist prepared result and effects]
    G --> H[Confirm original Autumn reservation]
    H -->|Success| I[Checkpoint job as succeeded]
    H -->|Temporary failure| J[Keep job queued or failed with prepared result]
    J --> K[Worker retry or maintenance finalizer]
    K --> H
Loading

Reviews (5): Last reviewed commit: "fix(insights): retry native settlement b..." | Re-trigger Greptile

Comment thread apps/dashboard/app/(main)/billing/components/investigation-topup-card.tsx Outdated
@izadoesdev

Copy link
Copy Markdown
Member Author

@greptileai Please review final head f355c18. The loading placeholder finding is fixed and resolved; the final follow-up also removes an unconfigured introductory price and shortens investigation terms.

@izadoesdev

Copy link
Copy Markdown
Member Author

@greptileai Please review final head 875f665. The additional change preserves cancellation and native prices for existing active, past-due, and scheduled paid add-ons while hiding new credit offers. The earlier layout and native-price findings remain fixed. All local required checks and the added synthetic browser scenarios pass.

@izadoesdev

Copy link
Copy Markdown
Member Author

@greptileai Please review final head cb97d20 before staging merge. The settlement failure finding is fixed in generation, worker completion, and the existing maintenance finalizer. The actual-worker regression fails on the old behavior and passes on both nonfinal and final attempts with one original reservation/model/delivery. Fresh root lint, 33 type/build tasks, 27 test tasks and 96 Insights integration cases pass. The branch is rebased onto current staging, including #783. Please check the first-run outage and prepared-replay paths as well as the remaining native Autumn billing flow.

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