Skip to workflow content
Vora
← Workflow library

Client Reporting

Separate supplied cohort rate and mix changes

Separate algebraic segment-rate and segment-composition changes in a client’s two-period lead or pilot reporting packet.

Experimental native example · local preview · revision 1

WORKFLOW PREVIEW

See how it works

2 nodes · 1 connections

Use + and − to zoom, F to fit. Press Enter on a node to inspect it.

Private preview. These tested drafts are available for inspection. Adding them to a Vora workspace is still being tested.

What you need

  • Authorized supplied facts matching the closed contract.
  • Declared completeness, identity and unit assumptions reviewed by an agency operator.
Follow the workflow step by step
  1. Supplied agency data

    Receive the explicitly supplied manual input packet.

  2. Separate supplied cohort rate and mix changes

    Separate algebraic segment-rate and segment-composition changes in a client’s two-period lead or pilot reporting packet.

Setup and review

  • Download the workflow JSON from this page and inspect its inputs schema and Code node.
  • Prepare a synthetic packet matching the input schema. Keep unknown values explicit and report completeness honestly.
  • Review the on-page literal example before running your own supplied-data case.
  • Inspect every unknown, tie, missing reference or bounded status before taking a downstream action.

Inspect every node

Expand a node to inspect its complete settings. Review the runtime and adoption evidence before installing it.

Supplied agency data · wfManualTrigger
{
  "label": "Supplied agency data"
}
Separate supplied cohort rate and mix changes · code
{
  "code": "\nfunction fail(reason){throw new Error('input: '+reason);}\nfunction check(schema,value,where){\n if(value===null){if(schema.type==='null'||Array.isArray(schema.type)&&schema.type.includes('null'))return;fail(where+' wrong_type');}\n const type=Array.isArray(schema.type)?schema.type[0]:schema.type;\n if(type==='object'){\n  if(!value||typeof value!=='object'||Array.isArray(value))fail(where+' wrong_type');\n  for(const name of Object.keys(value))if(!Object.hasOwn(schema.properties,name))fail(where+' unknown_field');\n  for(const name of schema.required)if(!Object.hasOwn(value,name))fail(where+' missing_field');\n  for(const [name,shape]of Object.entries(schema.properties))check(shape,value[name],where+'.'+name);\n }else if(type==='array'){\n  if(!Array.isArray(value)||value.length>schema.maxItems)fail(where+' array_bound');\n  for(const item of value)check(schema.items,item,where+'[]');\n }else if(type==='string'){if(typeof value!=='string'||value.length>schema.maxLength)fail(where+' string_bound');}\n else if(type==='integer'){if(!Number.isSafeInteger(value)||value<schema.minimum||value>schema.maximum)fail(where+' integer_bound');}\n else if(type==='boolean'){if(typeof value!=='boolean')fail(where+' wrong_type');}\n else fail(where+' unsupported_type');\n}\nfunction id(value){if(typeof value!=='string'||!value||value.trim()!==value)fail('noncanonical_identity');return value;}\nfunction unique(values,reason){if(new Set(values).size!==values.length)fail(reason);}\nfunction safeAdd(a,b){if(a>Number.MAX_SAFE_INTEGER-b)fail('unsafe_sum');return a+b;}\nfunction day(value){if(!/^\\d{4}-\\d{2}-\\d{2}$/.test(value))fail('invalid_calendar_day');const ms=Date.parse(value+'T00:00:00Z');if(!Number.isFinite(ms)||new Date(ms).toISOString().slice(0,10)!==value)fail('invalid_calendar_day');return ms;}\nfunction refKey(ref){id(ref.assetId);if(ref.version<1)fail('positive_version_required');return JSON.stringify([ref.assetId,ref.version]);}\nfunction refValue(key){const pair=JSON.parse(key);return {assetId:pair[0],version:pair[1]};}\nfunction sortedRefs(keys){return [...keys].sort().map(refValue);}\n\nfunction lexIds(a,b){for(let i=0;i<Math.min(a.length,b.length);i++){if(a[i]<b[i])return -1;if(a[i]>b[i])return 1;}return a.length-b.length;}\nfunction maxSubset(rows,idField,feasible){let best=-1,ids=[],ties=0;for(let mask=0;mask<2**rows.length;mask++){const chosen=rows.filter((_,i)=>mask&(1<<i));if(!feasible(chosen))continue;const value=chosen.reduce((n,r)=>n+r.valuePoints,0),current=chosen.map(r=>r[idField]).sort();if(value>best){best=value;ids=current;ties=1;}else if(value===best){ties++;if(lexIds(current,ids)<0)ids=current;}}return {ids,value:best,ties};}\nfunction rat(n,d){if(d===0n)fail('zero_denominator');if(d<0n){n=-n;d=-d;}let a=n<0n?-n:n,b=d;while(b){const next=a%b;a=b;b=next;}return [n/a,d/a];}\nfunction ratAdd(a,b){return rat(a[0]*b[1]+b[0]*a[1],a[1]*b[1]);}\nfunction ratSub(a,b){return rat(a[0]*b[1]-b[0]*a[1],a[1]*b[1]);}\nfunction ratMul(a,b){return rat(a[0]*b[0],a[1]*b[1]);}\nfunction ratText(a){return a[0].toString()+'/'+a[1].toString();}\n\n\ncheck({\"type\":\"object\",\"properties\":{\"scopeId\":{\"type\":\"string\",\"maxLength\":128},\"selectionComplete\":{\"type\":[\"boolean\",\"null\"]},\"segments\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"segmentId\":{\"type\":\"string\",\"maxLength\":128},\"beforeSuccesses\":{\"type\":[\"integer\",\"null\"],\"minimum\":0,\"maximum\":1000000},\"beforeTrials\":{\"type\":[\"integer\",\"null\"],\"minimum\":0,\"maximum\":1000000},\"afterSuccesses\":{\"type\":[\"integer\",\"null\"],\"minimum\":0,\"maximum\":1000000},\"afterTrials\":{\"type\":[\"integer\",\"null\"],\"minimum\":0,\"maximum\":1000000}},\"required\":[\"segmentId\",\"beforeSuccesses\",\"beforeTrials\",\"afterSuccesses\",\"afterTrials\"],\"additionalProperties\":false},\"maxItems\":20}},\"required\":[\"scopeId\",\"selectionComplete\",\"segments\"],\"additionalProperties\":false},context.input,\"input\");\nconst result=(function mixture(x){\n id(x.scopeId);unique(x.segments.map(s=>id(s.segmentId)),'duplicate_segment_id');\n for(const s of x.segments)for(const period of ['before','after'])if(s[period+'Successes']!==null&&s[period+'Trials']!==null&&s[period+'Successes']>s[period+'Trials'])fail('success_exceeds_trials');\n const unknown=x.segments.filter(s=>[s.beforeSuccesses,s.beforeTrials,s.afterSuccesses,s.afterTrials].includes(null)||s.beforeTrials===0||s.afterTrials===0).map(s=>s.segmentId).sort(),base={beforeRate:null,afterRate:null,rateChange:null,mixChange:null,totalChange:null,aggregateDirection:null,allSegmentDirection:null,directionReversal:null,unknownSegmentIds:unknown};\n if(!x.segments.length)return {status:'empty_supplied_segments',...base};\n if(x.selectionComplete!==true||unknown.length)return {status:'unknown',...base};\n const nb=BigInt(x.segments.reduce((n,s)=>n+s.beforeTrials,0)),na=BigInt(x.segments.reduce((n,s)=>n+s.afterTrials,0)),sb=BigInt(x.segments.reduce((n,s)=>n+s.beforeSuccesses,0)),sa=BigInt(x.segments.reduce((n,s)=>n+s.afterSuccesses,0)),before=rat(sb,nb),after=rat(sa,na);let rate=rat(0n,1n),mix=rat(0n,1n);const signs=[];\n for(const s of x.segments){const rb=rat(BigInt(s.beforeSuccesses),BigInt(s.beforeTrials)),ra=rat(BigInt(s.afterSuccesses),BigInt(s.afterTrials)),wb=rat(BigInt(s.beforeTrials),nb),wa=rat(BigInt(s.afterTrials),na),delta=ratSub(ra,rb);signs.push(delta[0]>0n?'improved':delta[0]<0n?'declined':'stable');rate=ratAdd(rate,ratMul(ratMul(ratAdd(wa,wb),rat(1n,2n)),delta));mix=ratAdd(mix,ratMul(ratMul(ratAdd(ra,rb),rat(1n,2n)),ratSub(wa,wb)));}\n const total=ratSub(after,before),aggregate=total[0]>0n?'improved':total[0]<0n?'declined':'stable',all=signs.every(s=>s===signs[0])?signs[0]:'mixed',reversal=(all==='improved'&&aggregate==='declined')||(all==='declined'&&aggregate==='improved');\n return {status:'decomposition_within_supplied_segments',...base,beforeRate:ratText(before),afterRate:ratText(after),rateChange:ratText(rate),mixChange:ratText(mix),totalChange:ratText(total),aggregateDirection:aggregate,allSegmentDirection:all,directionReversal:reversal};\n})(context.input);\ncheck({\"type\":\"object\",\"properties\":{\"status\":{\"type\":\"string\",\"maxLength\":128},\"beforeRate\":{\"type\":[\"string\",\"null\"],\"maxLength\":256},\"afterRate\":{\"type\":[\"string\",\"null\"],\"maxLength\":256},\"rateChange\":{\"type\":[\"string\",\"null\"],\"maxLength\":256},\"mixChange\":{\"type\":[\"string\",\"null\"],\"maxLength\":256},\"totalChange\":{\"type\":[\"string\",\"null\"],\"maxLength\":256},\"aggregateDirection\":{\"type\":[\"string\",\"null\"],\"maxLength\":128},\"allSegmentDirection\":{\"type\":[\"string\",\"null\"],\"maxLength\":128},\"directionReversal\":{\"type\":[\"boolean\",\"null\"]},\"unknownSegmentIds\":{\"type\":\"array\",\"items\":{\"type\":\"string\",\"maxLength\":128},\"maxItems\":100}},\"required\":[\"status\",\"beforeRate\",\"afterRate\",\"rateChange\",\"mixChange\",\"totalChange\",\"aggregateDirection\",\"allSegmentDirection\",\"directionReversal\",\"unknownSegmentIds\"],\"additionalProperties\":false},result,\"output\");\nreturn result;",
  "label": "Separate supplied cohort rate and mix changes",
  "memoryLimit": 16,
  "outputVar": "result",
  "timeout": 1000
}
Input and output contracts

Input

{
  "type": "object",
  "properties": {
    "scopeId": {
      "type": "string",
      "maxLength": 128
    },
    "selectionComplete": {
      "type": [
        "boolean",
        "null"
      ]
    },
    "segments": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "segmentId": {
            "type": "string",
            "maxLength": 128
          },
          "beforeSuccesses": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "maximum": 1000000
          },
          "beforeTrials": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "maximum": 1000000
          },
          "afterSuccesses": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "maximum": 1000000
          },
          "afterTrials": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "maximum": 1000000
          }
        },
        "required": [
          "segmentId",
          "beforeSuccesses",
          "beforeTrials",
          "afterSuccesses",
          "afterTrials"
        ],
        "additionalProperties": false
      },
      "maxItems": 20
    }
  },
  "required": [
    "scopeId",
    "selectionComplete",
    "segments"
  ],
  "additionalProperties": false
}

Output

{
  "type": "object",
  "properties": {
    "status": {
      "type": "string",
      "maxLength": 128
    },
    "beforeRate": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 256
    },
    "afterRate": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 256
    },
    "rateChange": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 256
    },
    "mixChange": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 256
    },
    "totalChange": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 256
    },
    "aggregateDirection": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 128
    },
    "allSegmentDirection": {
      "type": [
        "string",
        "null"
      ],
      "maxLength": 128
    },
    "directionReversal": {
      "type": [
        "boolean",
        "null"
      ]
    },
    "unknownSegmentIds": {
      "type": "array",
      "items": {
        "type": "string",
        "maxLength": 128
      },
      "maxItems": 100
    }
  },
  "required": [
    "status",
    "beforeRate",
    "afterRate",
    "rateChange",
    "mixChange",
    "totalChange",
    "aggregateDirection",
    "allSegmentDirection",
    "directionReversal",
    "unknownSegmentIds"
  ],
  "additionalProperties": false
}

Choose an output for this job

This business workflow also has 15 delivery formats. Compare their inputs, output examples and limits.

Compare implementations for this job

Example input and result

These examples use synthetic data.

Input

{
  "scopeId": "client-A",
  "selectionComplete": true,
  "segments": [
    {
      "segmentId": "a",
      "beforeSuccesses": 10,
      "beforeTrials": 100,
      "afterSuccesses": 20,
      "afterTrials": 100
    },
    {
      "segmentId": "b",
      "beforeSuccesses": 40,
      "beforeTrials": 100,
      "afterSuccesses": 20,
      "afterTrials": 100
    }
  ]
}

Expected result

{
  "status": "decomposition_within_supplied_segments",
  "beforeRate": "1/4",
  "afterRate": "1/5",
  "rateChange": "-1/20",
  "mixChange": "0/1",
  "totalChange": "-1/20",
  "aggregateDirection": "declined",
  "allSegmentDirection": "mixed",
  "directionReversal": false,
  "unknownSegmentIds": []
}

Success means: Separate algebraic segment-rate and segment-composition changes in a client’s two-period lead or pilot reporting packet.

When something goes wrong

  • Correct malformed facts and rerun. Incomplete or unknown facts remain uncertain; do not fabricate a resolution.

Limits and costs

  • Exact rational arithmetic on supplied two-period successes/trials. Positive denominators needed per cell; unknown/zero denominators or incomplete selection prevents decomposition. Components are algebraic, not causal attribution. Rational outputs are reduced signed numerator/positive denominator strings. An overall client conversion rate can fall while every segment improves. The operation compares two supplied periods using exact reduced fractions. For each segment it separates mean-weight times rate change from mean-rate times weight change, then sums both components. They add exactly to the aggregate change. These are algebraic components, not estimates of causal contribution.
  • No paid model calls or metered third-party operations are declared in this pure graph. Vora plan availability, compute and quotas still apply; pricing has not been verified by this batch.

USE IN VORA

Separate supplied cohort rate and mix changes

Review this workflow’s steps and required inputs. Get access to Vora before setting it up in your workspace.

Workspace installation is being connected. This page lets you inspect the workflow; it does not create or run one.

Required input fields
{
  "type": "object",
  "properties": {
    "scopeId": {
      "type": "string",
      "maxLength": 128
    },
    "selectionComplete": {
      "type": [
        "boolean",
        "null"
      ]
    },
    "segments": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "segmentId": {
            "type": "string",
            "maxLength": 128
          },
          "beforeSuccesses": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "maximum": 1000000
          },
          "beforeTrials": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "maximum": 1000000
          },
          "afterSuccesses": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "maximum": 1000000
          },
          "afterTrials": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "maximum": 1000000
          }
        },
        "required": [
          "segmentId",
          "beforeSuccesses",
          "beforeTrials",
          "afterSuccesses",
          "afterTrials"
        ],
        "additionalProperties": false
      },
      "maxItems": 20
    }
  },
  "required": [
    "scopeId",
    "selectionComplete",
    "segments"
  ],
  "additionalProperties": false
}