Skip to content

fix(insights): preserve revenue currency through publication - #740

Merged
izadoesdev merged 3 commits into
stagingfrom
codex/insights-revenue-signal-context
Sep 6, 2026
Merged

fix(insights): preserve revenue currency through publication#740
izadoesdev merged 3 commits into
stagingfrom
codex/insights-revenue-signal-context

Conversation

@izadoesdev

@izadoesdev izadoesdev commented Sep 6, 2026

Copy link
Copy Markdown
Member

Native revenue detections lost their currency and became generic website signals. Swapping unchanged USD/EUR result rows could fabricate a revenue change, while the traffic publication guard hid a successfully verified gross-revenue decline.

Match canonical currency rows across both windows, retain revenue:USD-style identities through preparation and rechecks, and let successful structured gross-revenue evidence satisfy publication for that exact revenue subject. Missing currency rows and legacy unscoped rechecks remain inconclusive. The signal context now states that a snapshot alone is not publication evidence, avoiding conflict with the general snapshot-reuse instruction.

The eval suite now runs the real detector and signal preparation with synthetic reads and records that setup alongside every observable model step. All 51 fresh runs / 171 steps were manually reviewed, including intermediate variants. On the final source head, nine matched native cases change verified-decline publication from 0/3 to 3/3 and keep stale/unavailable findings private 6/6. Turns fall 38 → 29, corrections 7 → 0, and input tokens 313,452 → 228,875. Summed model-run time was 136.8s → 91.2s; the small synthetic sample does not establish production latency. Manual review still rejects one final summary for implying that refunds reduced gross revenue; two unavailable runs add unnecessary discovery. Earlier attribution controls omit depth or exceed the word target. These are retained quality failures, not a claim of product readiness.

Review corrections restrict the exemption to product_outcome for the exact scoped currency, reject legacy unscoped revenue, type the recorded setup, flatten scenario metadata conditionals, and run detector setup only in the standalone eval process. Static fixture imports do not execute detection.

Validation: root lint, all 33 type-check/build tasks, and 378 insights tests pass; the pre-push hook also passed all 27 monorepo test/build tasks. Regression cases cover row order, two independent currencies, currency-preserving remeasurement, missing/invalid identity, and publication rejection for wrong subjects, wrong currency, refund-only selections, snapshot prose and unrelated finding categories.

Scope: investigation revenue detection/publication and its evaluation coverage. Based on merged #737; no outstanding dependency or overlapping open product PR. No schema, new agent, lifecycle, notification or deployment changes. Remaining limitations: independent refund/attribution detection with stable gross, absent-currency measurement, and semantic usefulness beyond these synthetic cases. AI-assisted implementation and review under maintainer authorization.

@vercel

vercel Bot commented Sep 6, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated
databuddy-status Ready Ready Preview Sep 6, 2026 10:04pm UTC
2 Skipped Deployments
Project Deployment Actions Updated
dashboard Skipped Skipped Sep 6, 2026 10:04pm UTC
documentation Skipped Skipped Sep 6, 2026 10:04pm UTC

@unkey-deploy

unkey-deploy Bot commented Sep 6, 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 6, 2026 10:04pm

@coderabbitai

coderabbitai Bot commented Sep 6, 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: Team

Run ID: 6074ee07-d727-4a79-b22d-7fde2817e419

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.

@greptile-apps

greptile-apps Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR preserves currency-scoped revenue identities across detection, signal preparation, remeasurement, and publication validation, while expanding detector, investigation-flow, and quality-evaluation coverage.

  • Matches current and previous revenue rows by canonical currency.
  • Remeasures revenue using currency-filtered queries and treats missing rows as inconclusive.
  • Allows successful structured gross-revenue evidence to satisfy website publication validation.
  • Adds native detector-backed revenue evaluation scenarios and trace setup records.
  • One publication condition still permits legacy unscoped revenue subjects to publish currency-specific evidence.

Confidence Score: 4/5

The PR is not yet safe to merge because legacy unscoped revenue subjects can publish evidence for an arbitrary currency, and the explicit repository requirements must also be satisfied.

Currency preservation and remeasurement are coherent, but the publication bypass treats bare revenue as matching every currency and the new test codifies that behavior; the evaluation additions also introduce confirmed rule violations.

Files Needing Attention: apps/insights/src/agent.ts, apps/insights/src/investigation-flow.test.ts, apps/insights/src/evals/quality.ts

Important Files Changed

Filename Overview
apps/insights/src/agent.ts Adds a structured-revenue exception to the website publication guard, but also accepts legacy unscoped revenue subjects.
apps/insights/src/detection.ts Introduces canonical per-currency detection and exact currency-filtered remeasurement with intentional inconclusive handling for missing rows.
apps/insights/src/evals/quality.ts Adds detector-backed native revenue scenarios and setup tracing, with several explicit repository-style violations.
apps/insights/src/detection.test.ts Covers row ordering, separate currencies, exact remeasurement, invalid identities, and missing currency rows.
apps/insights/src/investigation-flow.test.ts Exercises publication subject and field binding but codifies acceptance of an unscoped revenue key.
apps/insights/src/evals/README.md Documents the native revenue evaluation scenarios, evidence requirements, and stated limitations.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[revenue_overview current and previous rows] --> B[Match canonical currencies]
    B --> C[DetectedSignal subjectKey revenue:CURRENCY]
    C --> D[prepareInvestigation preserves signalKey]
    D --> E[Currency-filtered remeasurement]
    E --> F[Structured total_revenue evidence]
    F --> G{Signal key matches evidence currency?}
    G -->|Scoped key| H[Permit product-loss publication]
    G -->|Legacy unscoped key| I[Currently also permitted]
    G -->|Wrong currency or subject| J[Reject publication]
Loading

Reviews (1): Last reviewed commit: "fix(insights): preserve revenue currency..." | Re-trigger Greptile

Comment thread apps/insights/src/agent.ts Outdated
Comment thread apps/insights/src/evals/quality.ts Outdated
Comment thread apps/insights/src/evals/quality.ts
Comment thread apps/insights/src/evals/quality.ts Outdated

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

2 issues found and verified against the latest diff

Confidence score: 3/5

  • In apps/insights/src/agent.ts, native revenue signals classified as measurement_coverage or user_experience can bypass the website guard even when structured gross-revenue rows do not prove collection or implementation, weakening signal validation; require collection/implementation evidence before applying the exemption.
  • In apps/insights/src/evals/quality.ts, module loading now runs the real detector and can throw when no synthetic revenue signal is found, so importing qualityCases may break evaluation or test tooling; move detection into an explicit execution path or otherwise avoid throwing during import.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/insights/src/agent.ts">

<violation number="1" location="apps/insights/src/agent.ts:992">
P2: When a native revenue signal is classified as `measurement_coverage` or `user_experience`, this exemption bypasses the website guard even though structured gross-revenue rows are not collection/implementation evidence or a downstream experience measurement. Restrict the exemption to `product_outcome` findings, or add equivalent classification validation before skipping the guard.</violation>
</file>

<file name="apps/insights/src/evals/quality.ts">

<violation number="1" location="apps/insights/src/evals/quality.ts:1424">
P2: The real detector now runs as a top-level side effect at module load: importing quality.ts to reuse `qualityCases` executes `detectSignals` and throws (`if (!revenueSignal) throw`) if the synthetic revenue signal is not emitted, and `prepareInvestigation` runs before any case executes. This couples module import to detector execution and makes any non-main consumer (e.g., a test importing `qualityCases`) fail at import time rather than at evaluation. Compute these once per run and guard them, or document that the module is not safely importable.</violation>
</file>

Shadow auto-approve: would not auto-approve because issues were found.

Re-trigger cubic

Comment thread apps/insights/src/agent.ts Outdated
Comment thread apps/insights/src/evals/quality.ts Outdated

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

Shadow auto-approve: would require human review.

Re-trigger cubic

@izadoesdev
izadoesdev merged commit 6647c9f into staging Sep 6, 2026
19 checks passed
@izadoesdev
izadoesdev deleted the codex/insights-revenue-signal-context branch September 6, 2026 22:09
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