feat(insights): discover hidden commercial and conversion changes - #742
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Team Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
Greptile SummaryThis PR expands insight discovery and validation across commercial and funnel-source changes:
Confidence Score: 4/5The 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
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]
Reviews (1): Last reviewed commit: "feat(insights): discover hidden commerci..." | Re-trigger Greptile |
There was a problem hiding this comment.
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
Shadow auto-approve: would not auto-approve because issues were found.
Re-trigger cubic
1699d81 to
c808ef4
Compare
|
The latest updates on your projects. Learn more about Unkey Deploy
|
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.