@sentientui/policy 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ var f=Object.defineProperty;var d=Object.getOwnPropertySymbols;var g=Object.prototype.hasOwnProperty,h=Object.prototype.propertyIsEnumerable;var e=(c,a,b)=>a in c?f(c,a,{enumerable:!0,configurable:!0,writable:!0,value:b}):c[a]=b,i=(c,a)=>{for(var b in a||(a={}))g.call(a,b)&&e(c,b,a[b]);if(d)for(var b of d(a))h.call(a,b)&&e(c,b,a[b]);return c};export{i as a};
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- var re=Object.defineProperty;var j=Object.getOwnPropertySymbols;var ne=Object.prototype.hasOwnProperty,te=Object.prototype.propertyIsEnumerable;var z=(e,r,n)=>r in e?re(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n,K=(e,r)=>{for(var n in r||(r={}))ne.call(r,n)&&z(e,n,r[n]);if(j)for(var n of j(r))te.call(r,n)&&z(e,n,r[n]);return e};var _=["buyer","researcher","deal_seeker","browser"],y="unknown",B={buyer:"Buyer",researcher:"Researcher",deal_seeker:"Deal seeker",browser:"Browser",unknown:"Unknown"},V={buyers:"buyer",researchers:"researcher","deal-seekers":"deal_seeker",browsers:"browser",buyer:"buyer",researcher:"researcher",deal_seeker:"deal_seeker",browser:"browser"};function U(e){var n;if(e==null)return y;let r=e.trim().toLowerCase();return(n=V[r])!=null?n:y}var oe=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function g(e,r){return e>>>r|e<<32-r}function G(e){return(e>>>0).toString(16).padStart(8,"0")}function se(e){let r=new TextEncoder().encode(e),n=r.length,o=n*8,s=(n+8>>6)+1<<6,t=new Uint8Array(s);t.set(r),t[n]=128;let a=new DataView(t.buffer);a.setUint32(s-8,Math.floor(o/4294967296),!1),a.setUint32(s-4,o>>>0,!1);let i=1779033703,u=3144134277,f=1013904242,c=2773480762,b=1359893119,m=2600822924,P=528734635,A=1541459225,p=new Uint32Array(64);for(let M=0;M<s;M+=64){for(let l=0;l<16;l++)p[l]=a.getUint32(M+l*4,!1);for(let l=16;l<64;l++){let I=g(p[l-15],7)^g(p[l-15],18)^p[l-15]>>>3,D=g(p[l-2],17)^g(p[l-2],19)^p[l-2]>>>10;p[l]=p[l-16]+I+p[l-7]+D>>>0}let x=i,k=u,v=f,O=c,h=b,R=m,S=P,N=A;for(let l=0;l<64;l++){let I=g(h,6)^g(h,11)^g(h,25),D=h&R^~h&S,H=N+I+D+oe[l]+p[l]>>>0,J=g(x,2)^g(x,13)^g(x,22),Q=x&k^x&v^k&v,ee=J+Q>>>0;N=S,S=R,R=h,h=O+H>>>0,O=v,v=k,k=x,x=H+ee>>>0}i=i+x>>>0,u=u+k>>>0,f=f+v>>>0,c=c+O>>>0,b=b+h>>>0,m=m+R>>>0,P=P+S>>>0,A=A+N>>>0}return G(i)+G(u)}function Y(e){return se(e.join("|"))}var ae={buyer:["pricing","cta","hero","comparison","social_proof","trust","features","faq","navigation","generic"],researcher:["features","comparison","faq","hero","trust","social_proof","pricing","cta","navigation","generic"],deal_seeker:["pricing","comparison","social_proof","trust","cta","hero","features","faq","navigation","generic"],browser:["hero","features","social_proof","pricing","cta","trust","faq","comparison","navigation","generic"]};function q(e,r,n){let o=ae[n];if(!o)return e;let s=o.indexOf("generic"),t=a=>{let i=o.indexOf(a);return i===-1?s:i};return[...e].sort((a,i)=>{var c,b;let u=(c=r.get(a))!=null?c:"generic",f=(b=r.get(i))!=null?b:"generic";return t(u)-t(f)})}function F(e,r,n){let o=new Map;for(let s of[..._,n]){let t=q(e,r,s);o.set(Y(t),t)}return o}function $(e,r){if(e<1)return $(1+e,r)*Math.pow(Math.max(1e-15,r()),1/e);let n=e-1/3,o=1/Math.sqrt(9*n);for(;;){let s,t;do{let i=Math.max(1e-15,r()),u=r();s=Math.sqrt(-2*Math.log(i))*Math.cos(2*Math.PI*u),t=1+o*s}while(t<=0);t=t*t*t;let a=r();if(a<1-.0331*s*s*s*s||Math.log(a)<.5*s*s+n*(1-t+Math.log(t)))return n*t}}function C(e,r,n=Math.random){let o=$(e,n),s=$(r,n),t=o+s;return t<=0?e/(e+r):o/t}function W(e,r=Math.random){if(e.length===0)return null;if(e.length===1)return e[0].arm;let n=e[0],o=C(n.alpha,n.beta,r);for(let s=1;s<e.length;s++){let t=e[s],a=C(t.alpha,t.beta,r);a>o&&(n=t,o=a)}return n.arm}function _e(e,r,n,o,s=Math.random){var f,c;let t=F(e,r,n),a=[];for(let b of t.keys()){let m=o.get(b);a.push({arm:b,alpha:(f=m==null?void 0:m.alpha)!=null?f:1,beta:(c=m==null?void 0:m.beta)!=null?c:1})}let i=W(a,s),u=i?t.get(i):void 0;return u!=null?u:q(e,r,n)}function T(e){return Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("|")}function Z(e){if(e.length===0)return null;let r={};for(let n of e.split("|")){let o=n.indexOf("=");if(o<=0||o!==n.lastIndexOf("=")||o===n.length-1)return null;let s=n.slice(0,o);if(s in r)return null;r[s]=n.slice(o+1)}return r}function we(e,r){return`${e}=${r}`}function ie(e){var n,o,s;if(e.arms)return typeof e.baseline=="string"?e.baseline:(n=e.arms[0])!=null?n:"";if(e.baseline!==void 0&&typeof e.baseline=="object")return T(e.baseline);if(typeof e.baseline=="string")return e.baseline;let r={};for(let[t,a]of Object.entries((o=e.dims)!=null?o:{}))r[t]=(s=a[0])!=null?s:"";return T(r)}function Ee(e){let r=Array.isArray(e.arms),n=e.dims!=null;if(r&&n)return{ok:!1,reason:"declare exactly one of arms or dims (got both)"};if(!r&&!n)return{ok:!1,reason:"declare exactly one of arms or dims (got neither)"};if(r){let t=e.arms;if(t.length<2)return{ok:!1,reason:"arms requires at least 2 entries"};if(t.length>12)return{ok:!1,reason:"arms allows at most 12 entries"};if(new Set(t).size!==t.length)return{ok:!1,reason:"arms must be unique"};if(t.some(a=>a.includes("=")))return{ok:!1,reason:"enumerated arm ids may not contain '=' (reserved for dims encoding)"};if(e.baseline!==void 0){if(typeof e.baseline!="string")return{ok:!1,reason:"baseline for an arms slot must be a string"};if(!t.includes(e.baseline))return{ok:!1,reason:"baseline must be one of the declared arms"}}return{ok:!0}}let o=Object.entries(e.dims);if(o.length<1)return{ok:!1,reason:"dims requires at least 1 dimension"};if(o.length>4)return{ok:!1,reason:"dims allows at most 4 dimensions"};let s=1;for(let[t,a]of o){if(a.length<2)return{ok:!1,reason:`dim "${t}" requires at least 2 values`};if(a.length>6)return{ok:!1,reason:`dim "${t}" allows at most 6 values`};if(new Set(a).size!==a.length)return{ok:!1,reason:`dim "${t}" has duplicate values`};s*=a.length}if(s>64)return{ok:!1,reason:`declared space of ${s} combinations exceeds the 64 maximum`};if(e.baseline!==void 0){if(typeof e.baseline=="string")return{ok:!1,reason:"baseline for a dims slot must be a per-dim record"};let t=e.baseline,a=o.map(([u])=>u).sort(),i=Object.keys(t).sort();if(a.join(" ")!==i.join(" "))return{ok:!1,reason:"baseline must set every declared dim exactly once"};for(let[u,f]of o)if(!f.includes(t[u]))return{ok:!1,reason:`baseline value for dim "${u}" is not declared`}}return{ok:!0}}function Le(e,r){var n,o;return e.dims!=null?(o=(n=Z(r))!=null?n:Z(ie(e)))!=null?o:{}:r}var X=20;function w(e,r,n=20){let o=r.alpha+r.beta;if(o<=0||n<=0)return{alpha:e.alpha,beta:e.beta};let s=r.alpha/o,t=n*o/(o+n);return{alpha:e.alpha+t*s,beta:e.beta+t*(1-s)}}var ue=5;function Oe(e,r){var o,s;let n=null;for(let t of e){if(!r.includes(t.variantId))continue;let a=(o=t.pulls)!=null?o:0,i=a>0?a*t.avgReward/(a+ue):0;(!n||i>n.score)&&(n={variantId:t.variantId,score:i})}return(s=n==null?void 0:n.variantId)!=null?s:null}var d="__all__",E={exposures:0,conversions:0};function L(e){return{alpha:e.conversions+1,beta:Math.max(0,e.exposures-e.conversions)+1}}function De(e,r,n=20){var m,P,A,p;let o=(m=e.segment)!=null?m:E,s=(P=e.global)!=null?P:E,t=L(s),a=w(L(o),t,n);if(!r)return a;let i=(A=e.persona)!=null?A:E,u=(p=e.child)!=null?p:E,f=w(L(i),t,n),c=(o.exposures+1)/(o.exposures+i.exposures+2),b={alpha:c*a.alpha+(1-c)*f.alpha,beta:c*a.beta+(1-c)*f.beta};return w(L(u),b,n)}function Ke(e){var o,s;let r=null,n=-1;for(let t of e){let a=t.segment===d,i=t.persona===d,u=a&&i?3:a||i?2:1;u>n&&(n=u,r=t)}return{valueSum:(o=r==null?void 0:r.valueSum)!=null?o:0,valueCount:(s=r==null?void 0:r.valueCount)!=null?s:0}}function Ve(e,r){return r==="unknown"||r===d||r===""?[{segment:e,persona:d},{segment:d,persona:d}]:[{segment:e,persona:r},{segment:e,persona:d},{segment:d,persona:r},{segment:d,persona:d}]}function le(e){let r=2166136261;for(let n=0;n<e.length;n++)r^=e.charCodeAt(n),r=r+((r<<1)+(r<<4)+(r<<7)+(r<<8)+(r<<24))>>>0;return r}function qe(e,r,n){if(n.length===0)throw new Error("pickDeterministicArm requires at least one arm");let o=[...n].sort();return o[le(`${e}:${r}`)%o.length]}function $e(e){return e>=.3?e<.7?"medium":"high":"low"}var ce=20;function fe(e,r,n=ce){let o=e.valueCount>0?e.valueSum/e.valueCount:0;if(r<=0)return o;if(e.valueCount<=0)return r;let s=e.valueCount/(e.valueCount+n);return s*o+(1-s)*r}function ze(e,r,n=Math.random){if(e.length===0)return null;if(e.length===1)return e[0].arm;let o=null,s=-1/0;for(let t of e){let a=C(t.alpha,t.beta,n)*fe(t,r);a>s&&(o=t,s=a)}return o.arm}var me=/^[a-z0-9][a-z0-9_-]{0,31}$/;function Ye(e){if(typeof e!="string")return null;let r=e.trim().toLowerCase();return r&&me.test(r)?r:null}var pe=["unknown","__all__","buyers","researchers","deal-seekers","browsers"],be=_.map(e=>({key:e,displayName:B[e]})),ge=64;function de(e){var n;let r=new Map;for(let o of e)if(o.status!=="retired"){r.set(o.key,o.key);for(let s of(n=o.aliases)!=null?n:[])pe.includes(s)||r.set(s,o.key)}return r}function Fe(e,r=be){var i,u,f;let n=de(r),o=(i=e.inferredConfidence)!=null?i:0,s,t=(f=(u=e.declared)==null?void 0:u.trim().toLowerCase())!=null?f:"";if(t!==""){let c=n.get(t),b=c===void 0?n.get(U(t)):void 0,m=c!=null?c:b;if(m!==void 0)return{persona:m,source:"declared",confidence:1};s=t.slice(0,ge)}let a=U(e.clusterLabel);return a!==y&&n.has(a)?K({persona:n.get(a),source:"inferred",confidence:o},s!==void 0&&{unrecognizedDeclared:s}):K({persona:y,source:"none",confidence:o},s!==void 0&&{unrecognizedDeclared:s})}function We(e){var n;if(e==null)return y;let r=e.trim().toLowerCase();return r===""?y:(n=V[r])!=null?n:r}export{ae as CLUSTER_PRIORITY,be as DEFAULT_PERSONA_VOCABULARY,ce as EV_SHRINK_K,V as LEGACY_PERSONA_MAP,_ as PERSONAS,B as PERSONA_DISPLAY,me as PERSONA_KEY_RE,d as POOL_ALL,pe as RESERVED_PERSONA_KEYS,X as SHRINKAGE_M,y as UNKNOWN_PERSONA,ue as WEIGHTS_FALLBACK_PRIOR_PULLS,q as applyClusterHeuristic,Ke as broadestValueCell,F as candidateLayouts,T as canonicalArm,U as canonicalPersona,_e as chooseLayout,$e as confidenceBand,We as decisionPersona,le as fnv1a,Y as hashLayout,we as marginalArmKey,Ye as normalizeDeclaredPersona,Z as parseArm,qe as pickDeterministicArm,Oe as pickFromWeights,De as pooledPosterior,L as posteriorOfCounts,Fe as resolvePersona,W as sampleArm,ze as sampleArmEv,C as sampleBeta,fe as shrunkAvgValue,w as shrunkPosterior,ie as slotBaselineArm,Le as slotResultFor,Ee as validateSlotDecl,Ve as weightCellsFor};
1
+ import{a as K}from"./chunk-HBG7RQ56.mjs";var _=["buyer","researcher","deal_seeker","browser"],y="unknown",j={buyer:"Buyer",researcher:"Researcher",deal_seeker:"Deal seeker",browser:"Browser",unknown:"Unknown"},V={buyers:"buyer",researchers:"researcher","deal-seekers":"deal_seeker",browsers:"browser",buyer:"buyer",researcher:"researcher",deal_seeker:"deal_seeker",browser:"browser"};function U(e){var n;if(e==null)return y;let r=e.trim().toLowerCase();return(n=V[r])!=null?n:y}var Q=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function g(e,r){return e>>>r|e<<32-r}function z(e){return(e>>>0).toString(16).padStart(8,"0")}function ee(e){let r=new TextEncoder().encode(e),n=r.length,o=n*8,s=(n+8>>6)+1<<6,t=new Uint8Array(s);t.set(r),t[n]=128;let a=new DataView(t.buffer);a.setUint32(s-8,Math.floor(o/4294967296),!1),a.setUint32(s-4,o>>>0,!1);let i=1779033703,u=3144134277,f=1013904242,c=2773480762,b=1359893119,m=2600822924,P=528734635,A=1541459225,p=new Uint32Array(64);for(let M=0;M<s;M+=64){for(let l=0;l<16;l++)p[l]=a.getUint32(M+l*4,!1);for(let l=16;l<64;l++){let I=g(p[l-15],7)^g(p[l-15],18)^p[l-15]>>>3,D=g(p[l-2],17)^g(p[l-2],19)^p[l-2]>>>10;p[l]=p[l-16]+I+p[l-7]+D>>>0}let x=i,k=u,v=f,O=c,h=b,R=m,S=P,N=A;for(let l=0;l<64;l++){let I=g(h,6)^g(h,11)^g(h,25),D=h&R^~h&S,H=N+I+D+Q[l]+p[l]>>>0,Z=g(x,2)^g(x,13)^g(x,22),X=x&k^x&v^k&v,J=Z+X>>>0;N=S,S=R,R=h,h=O+H>>>0,O=v,v=k,k=x,x=H+J>>>0}i=i+x>>>0,u=u+k>>>0,f=f+v>>>0,c=c+O>>>0,b=b+h>>>0,m=m+R>>>0,P=P+S>>>0,A=A+N>>>0}return z(i)+z(u)}function B(e){return ee(e.join("|"))}var re={buyer:["pricing","cta","hero","comparison","social_proof","trust","features","faq","navigation","generic"],researcher:["features","comparison","faq","hero","trust","social_proof","pricing","cta","navigation","generic"],deal_seeker:["pricing","comparison","social_proof","trust","cta","hero","features","faq","navigation","generic"],browser:["hero","features","social_proof","pricing","cta","trust","faq","comparison","navigation","generic"]};function q(e,r,n){let o=re[n];if(!o)return e;let s=o.indexOf("generic"),t=a=>{let i=o.indexOf(a);return i===-1?s:i};return[...e].sort((a,i)=>{var c,b;let u=(c=r.get(a))!=null?c:"generic",f=(b=r.get(i))!=null?b:"generic";return t(u)-t(f)})}function G(e,r,n){let o=new Map;for(let s of[..._,n]){let t=q(e,r,s);o.set(B(t),t)}return o}function $(e,r){if(e<1)return $(1+e,r)*Math.pow(Math.max(1e-15,r()),1/e);let n=e-1/3,o=1/Math.sqrt(9*n);for(;;){let s,t;do{let i=Math.max(1e-15,r()),u=r();s=Math.sqrt(-2*Math.log(i))*Math.cos(2*Math.PI*u),t=1+o*s}while(t<=0);t=t*t*t;let a=r();if(a<1-.0331*s*s*s*s||Math.log(a)<.5*s*s+n*(1-t+Math.log(t)))return n*t}}function C(e,r,n=Math.random){let o=$(e,n),s=$(r,n),t=o+s;return t<=0?e/(e+r):o/t}function Y(e,r=Math.random){if(e.length===0)return null;if(e.length===1)return e[0].arm;let n=e[0],o=C(n.alpha,n.beta,r);for(let s=1;s<e.length;s++){let t=e[s],a=C(t.alpha,t.beta,r);a>o&&(n=t,o=a)}return n.arm}function Pe(e,r,n,o,s=Math.random){var f,c;let t=G(e,r,n),a=[];for(let b of t.keys()){let m=o.get(b);a.push({arm:b,alpha:(f=m==null?void 0:m.alpha)!=null?f:1,beta:(c=m==null?void 0:m.beta)!=null?c:1})}let i=Y(a,s),u=i?t.get(i):void 0;return u!=null?u:q(e,r,n)}function F(e){return Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("|")}function W(e){if(e.length===0)return null;let r={};for(let n of e.split("|")){let o=n.indexOf("=");if(o<=0||o!==n.lastIndexOf("=")||o===n.length-1)return null;let s=n.slice(0,o);if(s in r)return null;r[s]=n.slice(o+1)}return r}function ke(e,r){return`${e}=${r}`}function ne(e){var n,o,s;if(e.arms)return typeof e.baseline=="string"?e.baseline:(n=e.arms[0])!=null?n:"";if(e.baseline!==void 0&&typeof e.baseline=="object")return F(e.baseline);if(typeof e.baseline=="string")return e.baseline;let r={};for(let[t,a]of Object.entries((o=e.dims)!=null?o:{}))r[t]=(s=a[0])!=null?s:"";return F(r)}function ve(e){let r=Array.isArray(e.arms),n=e.dims!=null;if(r&&n)return{ok:!1,reason:"declare exactly one of arms or dims (got both)"};if(!r&&!n)return{ok:!1,reason:"declare exactly one of arms or dims (got neither)"};if(r){let t=e.arms;if(t.length<2)return{ok:!1,reason:"arms requires at least 2 entries"};if(t.length>12)return{ok:!1,reason:"arms allows at most 12 entries"};if(new Set(t).size!==t.length)return{ok:!1,reason:"arms must be unique"};if(t.some(a=>a.includes("=")))return{ok:!1,reason:"enumerated arm ids may not contain '=' (reserved for dims encoding)"};if(e.baseline!==void 0){if(typeof e.baseline!="string")return{ok:!1,reason:"baseline for an arms slot must be a string"};if(!t.includes(e.baseline))return{ok:!1,reason:"baseline must be one of the declared arms"}}return{ok:!0}}let o=Object.entries(e.dims);if(o.length<1)return{ok:!1,reason:"dims requires at least 1 dimension"};if(o.length>4)return{ok:!1,reason:"dims allows at most 4 dimensions"};let s=1;for(let[t,a]of o){if(a.length<2)return{ok:!1,reason:`dim "${t}" requires at least 2 values`};if(a.length>6)return{ok:!1,reason:`dim "${t}" allows at most 6 values`};if(new Set(a).size!==a.length)return{ok:!1,reason:`dim "${t}" has duplicate values`};s*=a.length}if(s>64)return{ok:!1,reason:`declared space of ${s} combinations exceeds the 64 maximum`};if(e.baseline!==void 0){if(typeof e.baseline=="string")return{ok:!1,reason:"baseline for a dims slot must be a per-dim record"};let t=e.baseline,a=o.map(([u])=>u).sort(),i=Object.keys(t).sort();if(a.join(" ")!==i.join(" "))return{ok:!1,reason:"baseline must set every declared dim exactly once"};for(let[u,f]of o)if(!f.includes(t[u]))return{ok:!1,reason:`baseline value for dim "${u}" is not declared`}}return{ok:!0}}function Re(e,r){var n,o;return e.dims!=null?(o=(n=W(r))!=null?n:W(ne(e)))!=null?o:{}:r}var T=20;function w(e,r,n=20){let o=r.alpha+r.beta;if(o<=0||n<=0)return{alpha:e.alpha,beta:e.beta};let s=r.alpha/o,t=n*o/(o+n);return{alpha:e.alpha+t*s,beta:e.beta+t*(1-s)}}var te=5;function _e(e,r){var o,s;let n=null;for(let t of e){if(!r.includes(t.variantId))continue;let a=(o=t.pulls)!=null?o:0,i=a>0?a*t.avgReward/(a+te):0;(!n||i>n.score)&&(n={variantId:t.variantId,score:i})}return(s=n==null?void 0:n.variantId)!=null?s:null}var d="__all__",E={exposures:0,conversions:0};function L(e){return{alpha:e.conversions+1,beta:Math.max(0,e.exposures-e.conversions)+1}}function Ee(e,r,n=20){var m,P,A,p;let o=(m=e.segment)!=null?m:E,s=(P=e.global)!=null?P:E,t=L(s),a=w(L(o),t,n);if(!r)return a;let i=(A=e.persona)!=null?A:E,u=(p=e.child)!=null?p:E,f=w(L(i),t,n),c=(o.exposures+1)/(o.exposures+i.exposures+2),b={alpha:c*a.alpha+(1-c)*f.alpha,beta:c*a.beta+(1-c)*f.beta};return w(L(u),b,n)}function Le(e){var o,s;let r=null,n=-1;for(let t of e){let a=t.segment===d,i=t.persona===d,u=a&&i?3:a||i?2:1;u>n&&(n=u,r=t)}return{valueSum:(o=r==null?void 0:r.valueSum)!=null?o:0,valueCount:(s=r==null?void 0:r.valueCount)!=null?s:0}}function Me(e,r){return r==="unknown"||r===d||r===""?[{segment:e,persona:d},{segment:d,persona:d}]:[{segment:e,persona:r},{segment:e,persona:d},{segment:d,persona:r},{segment:d,persona:d}]}function oe(e){let r=2166136261;for(let n=0;n<e.length;n++)r^=e.charCodeAt(n),r=r+((r<<1)+(r<<4)+(r<<7)+(r<<8)+(r<<24))>>>0;return r}function Ne(e,r,n){if(n.length===0)throw new Error("pickDeterministicArm requires at least one arm");let o=[...n].sort();return o[oe(`${e}:${r}`)%o.length]}function Ie(e){return e>=.3?e<.7?"medium":"high":"low"}var se=20;function ae(e,r,n=se){let o=e.valueCount>0?e.valueSum/e.valueCount:0;if(r<=0)return o;if(e.valueCount<=0)return r;let s=e.valueCount/(e.valueCount+n);return s*o+(1-s)*r}function Ve(e,r,n=Math.random){if(e.length===0)return null;if(e.length===1)return e[0].arm;let o=null,s=-1/0;for(let t of e){let a=C(t.alpha,t.beta,n)*ae(t,r);a>s&&(o=t,s=a)}return o.arm}var ie=/^[a-z0-9][a-z0-9_-]{0,31}$/;function $e(e){if(typeof e!="string")return null;let r=e.trim().toLowerCase();return r&&ie.test(r)?r:null}var ue=["unknown","__all__","buyers","researchers","deal-seekers","browsers"],le=_.map(e=>({key:e,displayName:j[e]})),ce=64;function fe(e){var n;let r=new Map;for(let o of e)if(o.status!=="retired"){r.set(o.key,o.key);for(let s of(n=o.aliases)!=null?n:[])ue.includes(s)||r.set(s,o.key)}return r}function He(e,r=le){var i,u,f;let n=fe(r),o=(i=e.inferredConfidence)!=null?i:0,s,t=(f=(u=e.declared)==null?void 0:u.trim().toLowerCase())!=null?f:"";if(t!==""){let c=n.get(t),b=c===void 0?n.get(U(t)):void 0,m=c!=null?c:b;if(m!==void 0)return{persona:m,source:"declared",confidence:1};s=t.slice(0,ce)}let a=U(e.clusterLabel);return a!==y&&n.has(a)?K({persona:n.get(a),source:"inferred",confidence:o},s!==void 0&&{unrecognizedDeclared:s}):K({persona:y,source:"none",confidence:o},s!==void 0&&{unrecognizedDeclared:s})}function je(e){var n;if(e==null)return y;let r=e.trim().toLowerCase();return r===""?y:(n=V[r])!=null?n:r}export{re as CLUSTER_PRIORITY,le as DEFAULT_PERSONA_VOCABULARY,se as EV_SHRINK_K,V as LEGACY_PERSONA_MAP,_ as PERSONAS,j as PERSONA_DISPLAY,ie as PERSONA_KEY_RE,d as POOL_ALL,ue as RESERVED_PERSONA_KEYS,T as SHRINKAGE_M,y as UNKNOWN_PERSONA,te as WEIGHTS_FALLBACK_PRIOR_PULLS,q as applyClusterHeuristic,Le as broadestValueCell,G as candidateLayouts,F as canonicalArm,U as canonicalPersona,Pe as chooseLayout,Ie as confidenceBand,je as decisionPersona,oe as fnv1a,B as hashLayout,ke as marginalArmKey,$e as normalizeDeclaredPersona,W as parseArm,Ne as pickDeterministicArm,_e as pickFromWeights,Ee as pooledPosterior,L as posteriorOfCounts,He as resolvePersona,Y as sampleArm,Ve as sampleArmEv,C as sampleBeta,ae as shrunkAvgValue,w as shrunkPosterior,ne as slotBaselineArm,Re as slotResultFor,ve as validateSlotDecl,Me as weightCellsFor};
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Two-layer section vocabulary (spec 2026-09-04).
3
+ *
4
+ * `parent` is the existing 10-value enum. It is the ONLY layer the layout
5
+ * bandit orders on, so the arm space stays bounded however rich `topic` grows —
6
+ * adding `carbon_fibre` buys understanding and zero extra bandit arms. That
7
+ * bound is load-bearing: a low-traffic project cannot support more arms (see
8
+ * the feasibility analysis in the spec), so widening the ordering vocabulary
9
+ * would make the statistics worse, not better.
10
+ *
11
+ * `topic` is the real semantics. The shipped classifier was tuned on SaaS
12
+ * marketing pages and returns `generic` for 8 of 9 sections on a car-body-repair
13
+ * site (measured — see the spec), which is why `services`, `gallery`, `process`
14
+ * and `insurance` exist here at all.
15
+ *
16
+ * `role` is orthogonal to both and describes what a section is FOR:
17
+ * - converter — carries a reward trigger (declared goal, form, tel:, booking)
18
+ * - persuader — no trigger; earns its place through dwell, feeds persona dims
19
+ * - structural — nav/footer/breadcrumb; evidence for neither, and reordering
20
+ * it would visibly damage the page
21
+ * Only converters and persuaders are reorderable; structural sections are pinned.
22
+ *
23
+ * NOTE: `role` here is the topic's DEFAULT. Phase 2b overrides it per section
24
+ * from real evidence (a declared goal's locator resolving inside the section),
25
+ * because a `services` band containing a "Book now" button really is a converter.
26
+ */
27
+ declare const SEMANTIC_PARENTS: readonly ["pricing", "hero", "social_proof", "cta", "features", "faq", "comparison", "trust", "navigation", "generic"];
28
+ type SemanticParent = (typeof SEMANTIC_PARENTS)[number];
29
+ type SectionRole = 'converter' | 'persuader' | 'structural';
30
+ declare const TOPICS: ReadonlyArray<{
31
+ topic: string;
32
+ parent: SemanticParent;
33
+ role: SectionRole;
34
+ }>;
35
+ /** Project a topic onto the parent the bandit orders on. Unknown → 'generic':
36
+ * an unrecognised topic must never hijack an ordering slot — the same reasoning
37
+ * as the off-vocabulary guard in layout-heuristics.ts, where a present-but-
38
+ * unrecognised type yielded indexOf === -1 and sorted ahead of everything. */
39
+ declare function parentOfTopic(topic: string): SemanticParent;
40
+ /** Default role for a topic. Unknown → 'persuader', never 'structural':
41
+ * structural sections are PINNED and never reordered, so defaulting an unknown
42
+ * topic to structural would silently freeze real content in place — failing
43
+ * closed in the direction that does the least harm. */
44
+ declare function roleOfTopic(topic: string): SectionRole;
45
+
46
+ export { SEMANTIC_PARENTS, type SectionRole, type SemanticParent, TOPICS, parentOfTopic, roleOfTopic };
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Two-layer section vocabulary (spec 2026-09-04).
3
+ *
4
+ * `parent` is the existing 10-value enum. It is the ONLY layer the layout
5
+ * bandit orders on, so the arm space stays bounded however rich `topic` grows —
6
+ * adding `carbon_fibre` buys understanding and zero extra bandit arms. That
7
+ * bound is load-bearing: a low-traffic project cannot support more arms (see
8
+ * the feasibility analysis in the spec), so widening the ordering vocabulary
9
+ * would make the statistics worse, not better.
10
+ *
11
+ * `topic` is the real semantics. The shipped classifier was tuned on SaaS
12
+ * marketing pages and returns `generic` for 8 of 9 sections on a car-body-repair
13
+ * site (measured — see the spec), which is why `services`, `gallery`, `process`
14
+ * and `insurance` exist here at all.
15
+ *
16
+ * `role` is orthogonal to both and describes what a section is FOR:
17
+ * - converter — carries a reward trigger (declared goal, form, tel:, booking)
18
+ * - persuader — no trigger; earns its place through dwell, feeds persona dims
19
+ * - structural — nav/footer/breadcrumb; evidence for neither, and reordering
20
+ * it would visibly damage the page
21
+ * Only converters and persuaders are reorderable; structural sections are pinned.
22
+ *
23
+ * NOTE: `role` here is the topic's DEFAULT. Phase 2b overrides it per section
24
+ * from real evidence (a declared goal's locator resolving inside the section),
25
+ * because a `services` band containing a "Book now" button really is a converter.
26
+ */
27
+ declare const SEMANTIC_PARENTS: readonly ["pricing", "hero", "social_proof", "cta", "features", "faq", "comparison", "trust", "navigation", "generic"];
28
+ type SemanticParent = (typeof SEMANTIC_PARENTS)[number];
29
+ type SectionRole = 'converter' | 'persuader' | 'structural';
30
+ declare const TOPICS: ReadonlyArray<{
31
+ topic: string;
32
+ parent: SemanticParent;
33
+ role: SectionRole;
34
+ }>;
35
+ /** Project a topic onto the parent the bandit orders on. Unknown → 'generic':
36
+ * an unrecognised topic must never hijack an ordering slot — the same reasoning
37
+ * as the off-vocabulary guard in layout-heuristics.ts, where a present-but-
38
+ * unrecognised type yielded indexOf === -1 and sorted ahead of everything. */
39
+ declare function parentOfTopic(topic: string): SemanticParent;
40
+ /** Default role for a topic. Unknown → 'persuader', never 'structural':
41
+ * structural sections are PINNED and never reordered, so defaulting an unknown
42
+ * topic to structural would silently freeze real content in place — failing
43
+ * closed in the direction that does the least harm. */
44
+ declare function roleOfTopic(topic: string): SectionRole;
45
+
46
+ export { SEMANTIC_PARENTS, type SectionRole, type SemanticParent, TOPICS, parentOfTopic, roleOfTopic };
@@ -0,0 +1 @@
1
+ "use strict";var a=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var l=(r,e)=>{for(var t in e)a(r,t,{get:e[t],enumerable:!0})},d=(r,e,t,p)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of s(e))!u.call(r,o)&&o!==t&&a(r,o,{get:()=>e[o],enumerable:!(p=i(e,o))||p.enumerable});return r};var f=r=>d(a({},"__esModule",{value:!0}),r);var m={};l(m,{SEMANTIC_PARENTS:()=>g,TOPICS:()=>n,parentOfTopic:()=>v,roleOfTopic:()=>_});module.exports=f(m);var g=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],n=[{topic:"pricing_plans",parent:"pricing",role:"converter"},{topic:"financing",parent:"pricing",role:"persuader"},{topic:"quote",parent:"pricing",role:"converter"},{topic:"hero",parent:"hero",role:"converter"},{topic:"reviews",parent:"social_proof",role:"persuader"},{topic:"testimonials",parent:"social_proof",role:"persuader"},{topic:"case_study",parent:"social_proof",role:"persuader"},{topic:"brands",parent:"social_proof",role:"persuader"},{topic:"awards",parent:"social_proof",role:"persuader"},{topic:"press",parent:"social_proof",role:"persuader"},{topic:"stats",parent:"social_proof",role:"persuader"},{topic:"gallery",parent:"social_proof",role:"persuader"},{topic:"cta",parent:"cta",role:"converter"},{topic:"booking",parent:"cta",role:"converter"},{topic:"contact_form",parent:"cta",role:"converter"},{topic:"newsletter",parent:"cta",role:"converter"},{topic:"hours",parent:"cta",role:"persuader"},{topic:"location",parent:"cta",role:"persuader"},{topic:"services",parent:"features",role:"persuader"},{topic:"features",parent:"features",role:"persuader"},{topic:"process",parent:"features",role:"persuader"},{topic:"capabilities",parent:"features",role:"persuader"},{topic:"specialties",parent:"features",role:"persuader"},{topic:"menu",parent:"features",role:"persuader"},{topic:"inventory",parent:"features",role:"converter"},{topic:"integrations",parent:"features",role:"persuader"},{topic:"faq",parent:"faq",role:"persuader"},{topic:"comparison",parent:"comparison",role:"persuader"},{topic:"insurance",parent:"trust",role:"persuader"},{topic:"warranty",parent:"trust",role:"persuader"},{topic:"certifications",parent:"trust",role:"persuader"},{topic:"security",parent:"trust",role:"persuader"},{topic:"guarantee",parent:"trust",role:"persuader"},{topic:"about",parent:"trust",role:"persuader"},{topic:"team",parent:"trust",role:"persuader"},{topic:"navigation",parent:"navigation",role:"structural"},{topic:"footer",parent:"navigation",role:"structural"},{topic:"breadcrumb",parent:"navigation",role:"structural"},{topic:"cookie_banner",parent:"navigation",role:"structural"},{topic:"generic",parent:"generic",role:"persuader"},{topic:"blog",parent:"generic",role:"persuader"},{topic:"resources",parent:"generic",role:"persuader"},{topic:"careers",parent:"generic",role:"persuader"},{topic:"legal",parent:"generic",role:"persuader"}],c=new Map(n.map(r=>[r.topic,r]));function v(r){var e,t;return(t=(e=c.get(r))==null?void 0:e.parent)!=null?t:"generic"}function _(r){var e,t;return(t=(e=c.get(r))==null?void 0:e.role)!=null?t:"persuader"}0&&(module.exports={SEMANTIC_PARENTS,TOPICS,parentOfTopic,roleOfTopic});
@@ -0,0 +1 @@
1
+ import"./chunk-HBG7RQ56.mjs";var p=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],a=[{topic:"pricing_plans",parent:"pricing",role:"converter"},{topic:"financing",parent:"pricing",role:"persuader"},{topic:"quote",parent:"pricing",role:"converter"},{topic:"hero",parent:"hero",role:"converter"},{topic:"reviews",parent:"social_proof",role:"persuader"},{topic:"testimonials",parent:"social_proof",role:"persuader"},{topic:"case_study",parent:"social_proof",role:"persuader"},{topic:"brands",parent:"social_proof",role:"persuader"},{topic:"awards",parent:"social_proof",role:"persuader"},{topic:"press",parent:"social_proof",role:"persuader"},{topic:"stats",parent:"social_proof",role:"persuader"},{topic:"gallery",parent:"social_proof",role:"persuader"},{topic:"cta",parent:"cta",role:"converter"},{topic:"booking",parent:"cta",role:"converter"},{topic:"contact_form",parent:"cta",role:"converter"},{topic:"newsletter",parent:"cta",role:"converter"},{topic:"hours",parent:"cta",role:"persuader"},{topic:"location",parent:"cta",role:"persuader"},{topic:"services",parent:"features",role:"persuader"},{topic:"features",parent:"features",role:"persuader"},{topic:"process",parent:"features",role:"persuader"},{topic:"capabilities",parent:"features",role:"persuader"},{topic:"specialties",parent:"features",role:"persuader"},{topic:"menu",parent:"features",role:"persuader"},{topic:"inventory",parent:"features",role:"converter"},{topic:"integrations",parent:"features",role:"persuader"},{topic:"faq",parent:"faq",role:"persuader"},{topic:"comparison",parent:"comparison",role:"persuader"},{topic:"insurance",parent:"trust",role:"persuader"},{topic:"warranty",parent:"trust",role:"persuader"},{topic:"certifications",parent:"trust",role:"persuader"},{topic:"security",parent:"trust",role:"persuader"},{topic:"guarantee",parent:"trust",role:"persuader"},{topic:"about",parent:"trust",role:"persuader"},{topic:"team",parent:"trust",role:"persuader"},{topic:"navigation",parent:"navigation",role:"structural"},{topic:"footer",parent:"navigation",role:"structural"},{topic:"breadcrumb",parent:"navigation",role:"structural"},{topic:"cookie_banner",parent:"navigation",role:"structural"},{topic:"generic",parent:"generic",role:"persuader"},{topic:"blog",parent:"generic",role:"persuader"},{topic:"resources",parent:"generic",role:"persuader"},{topic:"careers",parent:"generic",role:"persuader"},{topic:"legal",parent:"generic",role:"persuader"}],o=new Map(a.map(e=>[e.topic,e]));function n(e){var r,t;return(t=(r=o.get(e))==null?void 0:r.parent)!=null?t:"generic"}function c(e){var r,t;return(t=(r=o.get(e))==null?void 0:r.role)!=null?t:"persuader"}export{p as SEMANTIC_PARENTS,a as TOPICS,n as parentOfTopic,c as roleOfTopic};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentientui/policy",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "private": false,
5
5
  "description": "Pure decision-policy functions shared by the SentientUI API and the keyless local engine",
6
6
  "license": "MIT",
@@ -21,6 +21,11 @@
21
21
  "types": "./dist/index.d.ts",
22
22
  "import": "./dist/index.mjs",
23
23
  "require": "./dist/index.js"
24
+ },
25
+ "./taxonomy": {
26
+ "types": "./dist/taxonomy.d.ts",
27
+ "import": "./dist/taxonomy.mjs",
28
+ "require": "./dist/taxonomy.js"
24
29
  }
25
30
  },
26
31
  "files": [