Skip to content

feat(insights): discover hidden commercial and conversion changes - #742

Merged
izadoesdev merged 5 commits into
stagingfrom
codex/insights-breakthrough-detection
Sep 7, 2026
Merged

feat(insights): discover hidden commercial and conversion changes#742
izadoesdev merged 5 commits into
stagingfrom
codex/insights-breakthrough-detection

Conversation

@izadoesdev

@izadoesdev izadoesdev commented Sep 6, 2026

Copy link
Copy Markdown
Member

Flat gross revenue and flat configured funnel totals prevented useful investigations from starting. Discovery now independently selects currency-scoped refund and attribution changes, probes stable funnels for opposing source changes, and allows material positive conversion changes. A typed machine-selected objective carries the question into the existing agent without pretending to be human context or citable evidence.

On ten frozen warehouse-shaped worlds, the real detector/planner/preparation path changes commercial selection from zero to two subjects, opposing-source selection from zero to two, and positive activation from zero to one. Missing, sparse, small-movement, null and stable-currency controls remain quiet. Fresh automatic model runs with corrected native signed refunds retain the separate refund/attribution risks; source runs retain the decline hidden by a flat total. This establishes synthetic capability, not paying-customer coverage or pricing readiness. Earlier positive-refund fixtures are explicitly invalid for native signed-contract reachability.

Source discovery uses at most six concurrent reads for the first three eligible stable funnels, under one deadline. Cancellation reaches the native ClickHouse client. Optional breakdown failures preserve valid core findings; core failures and parent cancellation retain their fatal behavior. Commercial discovery reuses existing revenue reads. Later funnels can remain unprobed, and scheduled/manual portfolio limits stay two/five.

Independent review caught and fixed snapshot-only attribution publication and false referrer recovery from whole-funnel counts. Attribution publication requires native currency-specific proof. Aggregate referrer checks are rejected; historical ones remain inconclusive. Source-domain groups now use the existing referrer breakdown tool: the new cohort selector no longer accepts ambiguous raw referrer values, while saved-definition filters are unchanged. Native funnel/goal tools accept an explicit null cohort and normalize it to no additional filter at the RPC boundary.

Fresh integration testing retained an invalid source fixture, a corrected-fixture quality failure, and a weak follow-up in the audit. The weak run invented a nonmatching UTM filter and lost source context. With explicit null support, two further runs used four valid unfiltered reads in parallel, retained paid 40% → 20%, direct 10% → 22.5%, and unchanged overall 220/1,000, finishing in two turns at 50/52 words instead of three turns with failed reads. One still omitted dates. Earlier reviewed attribution gathered valid facts but failed on a corrective gateway request; it is retained as a failure, not a successful output. No broad latency or actionability claim is made.

Native contract review caught a release blocker: Stripe refunds and revenue_overview use negative amounts. The detector now compares refund magnitudes, preserves negative/integer count validation, and treats invalid optional fields as unknown without suppressing the independent finding. Same-count material refund increases are eligible; the sample, 2%-of-gross and 30% relative-change gates remain. Invalid gross totals remain inconclusive rather than becoming zero. Permanent controls cover signed numeric strings, worsening/improving/flat rechecks, exact identity, independent missing fields and same-count amount changes. Fresh signed refund and attribution runs both completed (44/30 words, three/four turns); attribution required a headline correction, so this is not a universal turn reduction.

Validation: root lint, all 33 workspace typecheck/build tasks, and all 27 root test/build tasks pass; the insights suite has 423 passing tests. Five direct cohort tool tests verify native filter forwarding, authorization, rejected selectors and explicit null/omission schema and RPC semantics. Independent review separately exercised 108 permanent control-flow scenarios plus an abort cleanup control. Nine earlier isolated ClickHouse tests support the merged native cohort measurement; native server resource reclamation and final production deployment remain unmeasured. A nonisolated ad-hoc cross-package test failure is retained; normal isolated repository suites pass. The runtime diff adds 429 net lines for new detection/capability boundaries; this is not a code-size reduction.

Scope: automatic investigation reachability, source measurement usability, and publication/verification boundaries. No database schema, notification, model or new agent architecture. Based on staging after merged #741; no unmerged dependency or remaining ownership overlap. AI-assisted maintainer contribution.

Nonblocking review dispositions: malformed extra commercial-key suffixes remain rejected by the existing full-key check at the generation boundary; no canonical producer exists, so parser tightening is deferred. The broad referrer-key substring guard also remains a scoped hardening follow-up. Attribution publication reports measured coverage and decision safety, not a proven tracking defect or lost sales. Native cancellation, sequential probes, signed refunds and same-count amount selection are fixed; frozen expected dates and narrowed unknown error boundaries are intentional.

@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 7, 2026 12:41am UTC
2 Skipped Deployments
Project Deployment Actions Updated
dashboard Skipped Skipped Sep 7, 2026 12:41am UTC
documentation Skipped Skipped Sep 7, 2026 12:41am UTC

@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: 1862c388-e540-4a59-9009-76599efe4769

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.

@izadoesdev
izadoesdev marked this pull request as ready for review September 6, 2026 23:42
@greptile-apps

greptile-apps Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR expands insight discovery and validation across commercial and funnel-source changes:

  • Detects currency-scoped refund and attribution-coverage movements independently of gross revenue.
  • Probes a bounded selection of stable funnels for opposing referrer conversion changes.
  • Carries machine-selected investigation objectives through planning into the agent.
  • Tightens attribution publication evidence and prevents aggregate verification of referrer-specific findings.
  • Adds integration and boundary coverage for discovery, cancellation, remeasurement, and publication behavior.

Confidence Score: 4/5

The behavioral changes appear sound, but the explicit repository requirements concerning awaited loops and prohibited types must be satisfied before merging.

No blocking correctness failure was found in commercial discovery, referrer selection, or publication validation; the remaining concerns are uncancelled background referrer queries and two concrete repository-rule violations.

Files Needing Attention: apps/insights/src/funnel-detection.ts

Important Files Changed

Filename Overview
apps/insights/src/detection.ts Adds validated, currency-scoped refund and attribution-rate discovery and corresponding remeasurement support.
apps/insights/src/funnel-detection.ts Adds bounded referrer discovery and diagnostics, but does not propagate cancellation into native reads and introduces two repository-rule violations.
apps/insights/src/agent.ts Propagates diagnostic objectives and strengthens native attribution evidence and referrer verification boundaries.
apps/insights/src/investigation.ts Makes commercial, referrer, and material positive conversion changes eligible for investigation.
apps/insights/src/generation.ts Carries machine-selected investigation objectives through candidate planning to agent execution.
apps/insights/src/coverage-planner.ts Gives each referrer-specific subject an independent portfolio coverage group.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Revenue and funnel measurements] --> B{Discovery}
  B --> C[Refund amount signal]
  B --> D[Attribution coverage signal]
  B --> E[Stable funnel]
  E --> F[Bounded referrer probes]
  F --> G[Declining source candidate]
  F --> H[Improving source candidate]
  C --> I[Candidate planning]
  D --> I
  G --> I
  H --> I
  I --> J[Prepared investigation objective]
  J --> K[Insight agent]
  K --> L{Publication validation}
  L -->|Attribution| M[Require exact native revenue evidence]
  L -->|Referrer action| N[Reject aggregate verification check]
  L -->|Valid outcome| O[Publish or resolve]
Loading

Reviews (1): Last reviewed commit: "feat(insights): discover hidden commerci..." | Re-trigger Greptile

Comment thread apps/insights/src/funnel-detection.ts
Comment thread apps/insights/src/funnel-detection.ts Outdated
Comment thread apps/insights/src/funnel-detection.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.

All reported issues were addressed across 11 files

Architecture diagram
sequenceDiagram
    participant Detector as Detection Engine
    participant Revenue as Revenue Overview Read
    participant Funnel as Funnel Analytics
    participant Referrer as Referrer Breakdown Read
    participant Planner as Coverage Planner
    participant Agent as Insight Agent
    participant Validator as Outcome Validator
    participant Generator as Generation Boundary

    Note over Detector,Revenue: NEW: Independent Commercial Discovery
    Detector->>Revenue: revenue_overview read (both windows)
    Revenue-->>Detector: currency rows with refund + attribution fields
    Detector->>Detector: commercialSignals() - parse/normalize
    alt Flat gross but refunds moved (>=5 count, >=30% delta, >=2% of revenue)
        Detector->>Detector: NEW: refund_amount signal + investigationObjective
    end
    alt Attribution coverage shifted >=15 points
        Detector->>Detector: NEW: attribution_rate signal + investigationObjective
    end

    Note over Detector,Funnel: NEW: Source Discovery on Stable Funnels
    Detector->>Funnel: Detect standard funnel signals
    Funnel-->>Detector: Stable aggregate (no funnel signal)
    Detector->>Detector: Select up to 3 eligible unchanged funnels
    loop For each eligible funnel (max 3)
        Detector->>Referrer: by-referrer read (current + previous windows)
        Referrer-->>Detector: source cohorts
        Detector->>Detector: Compare per-source completion rates
        alt Source decline found
            Detector->>Detector: NEW: referrer signal (negative)
        end
        alt Source improvement found (>=10pt, >=30% delta)
            Detector->>Detector: NEW: referrer signal (positive)
        end
    end
    alt Optional probe fails (non-abort)
        Detector->>Detector: Record failedProbes, continue core generation
    else Parent abort
        Detector->>Detector: Propagate abort, no further probes
    end

    Detector->>Planner: Signals with investigationObjective
    Planner->>Planner: Group with NEW: referrer subject keys

    Planner->>Agent: Candidate (signal + investigationObjective)
    Agent->>Agent: Include objective as diagnostic intent
    Note over Agent: NEW: objective is machine-selected,<br/>not citable evidence

    alt Refund signal
        Agent->>Validator: Verify native refund_amount + refund_count evidence
        Validator-->>Agent: CHANGED: currency-matched proof required
    else Attribution signal
        Agent->>Validator: Verify native attributed_revenue + total_revenue
        alt Missing or wrong-currency native evidence
            Validator-->>Agent: NEW: Reject "Attribution findings require native..."
        else Valid proof
            Validator-->>Agent: Accept as measurement_coverage
        end
    else Referrer signal
        Agent->>Validator: NEW: Check for referrer verification
        alt Agent proposes aggregate funnel check
            Validator-->>Agent: Reject (cannot verify source population)
        end
        Validator-->>Agent: Mark inconclusive (legacy checks)
    end

    Agent-->>Generator: Completed investigation
    Generator->>Generator: NEW: Preserve investigationObjective for reruns
Loading

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

Re-trigger cubic

Comment thread apps/insights/src/detection.ts Outdated
Comment thread apps/insights/src/detection.ts
Comment thread apps/insights/src/agent.ts
Comment thread apps/insights/src/funnel-detection.ts
Comment thread apps/insights/src/detection.ts Outdated
Comment thread apps/insights/src/coverage-planner.ts
Comment thread apps/insights/src/generation-sources.test.ts
@unkey-deploy

unkey-deploy Bot commented Sep 7, 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 7, 2026 12:41am

@vercel
vercel Bot temporarily deployed to Preview – dashboard September 7, 2026 00:41 Inactive
@vercel
vercel Bot temporarily deployed to Preview – documentation September 7, 2026 00:41 Inactive
@izadoesdev
izadoesdev merged commit aece41d into staging Sep 7, 2026
20 checks passed
@izadoesdev
izadoesdev deleted the codex/insights-breakthrough-detection branch September 7, 2026 01:02
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