@wafertools/wafermap 0.35.0 → 0.35.1

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.
Files changed (60) hide show
  1. package/AGENTS.md +7 -1
  2. package/CHANGELOG.md +129 -0
  3. package/README.md +6 -3
  4. package/dist/packages/canvas-adapter/charts/boxplot.js +1 -1
  5. package/dist/packages/canvas-adapter/charts/capability.js +1 -1
  6. package/dist/packages/canvas-adapter/charts/histogram.js +1 -1
  7. package/dist/packages/canvas-adapter/renderWaferGallery.js +1 -1
  8. package/dist/packages/canvas-adapter/renderWaferMap.d.ts +14 -1
  9. package/dist/packages/canvas-adapter/renderWaferMap.js +1 -1
  10. package/dist/packages/canvas-adapter/summaryPanel.d.ts +31 -8
  11. package/dist/packages/canvas-adapter/summaryPanel.js +4 -2
  12. package/dist/packages/canvas-adapter/summaryToggle.d.ts +11 -0
  13. package/dist/packages/canvas-adapter/summaryToggle.js +1 -0
  14. package/dist/packages/canvas-adapter/toolbar.d.ts +8 -0
  15. package/dist/packages/canvas-adapter/toolbar.js +2 -2
  16. package/dist/packages/canvas-adapter/userGuideHtml.d.ts +1 -1
  17. package/dist/packages/canvas-adapter/userGuideHtml.js +37 -21
  18. package/dist/packages/canvas-adapter/version.d.ts +2 -2
  19. package/dist/packages/canvas-adapter/version.js +1 -1
  20. package/dist/packages/canvas-adapter/warnings.js +1 -1
  21. package/dist/packages/core/classify.d.ts +5 -0
  22. package/dist/packages/core/classify.js +1 -1
  23. package/dist/packages/core/dieTable.d.ts +26 -0
  24. package/dist/packages/core/dieTable.js +1 -1
  25. package/dist/packages/core/passBins.d.ts +6 -0
  26. package/dist/packages/core/passBins.js +1 -1
  27. package/dist/packages/renderer/buildView.js +1 -1
  28. package/dist/packages/renderer/buildWaferMap.d.ts +32 -1
  29. package/dist/packages/renderer/buildWaferMap.js +1 -1
  30. package/dist/packages/renderer/spec.d.ts +4 -0
  31. package/dist/packages/renderer/spec.js +1 -1
  32. package/dist/packages/renderer/valueFilter.d.ts +55 -0
  33. package/dist/packages/renderer/valueFilter.js +1 -0
  34. package/dist/packages/stats/analyzeWaferLot.js +1 -1
  35. package/dist/packages/stats/analyzeWaferMap.d.ts +44 -3
  36. package/dist/packages/stats/analyzeWaferMap.js +1 -1
  37. package/dist/packages/stats/capability.d.ts +5 -0
  38. package/dist/packages/stats/capability.js +1 -1
  39. package/dist/packages/stats/clusterDetection.js +1 -1
  40. package/dist/packages/stats/connectedComponents.d.ts +19 -0
  41. package/dist/packages/stats/connectedComponents.js +1 -1
  42. package/dist/packages/stats/lotPattern.js +1 -1
  43. package/dist/packages/stats/math.d.ts +25 -3
  44. package/dist/packages/stats/math.js +1 -1
  45. package/dist/packages/stats/patternClassification.d.ts +44 -18
  46. package/dist/packages/stats/patternClassification.js +1 -1
  47. package/dist/packages/stats/plotData.d.ts +11 -0
  48. package/dist/packages/stats/plotData.js +1 -1
  49. package/dist/packages/stats/regions.d.ts +6 -0
  50. package/dist/packages/stats/regions.js +1 -1
  51. package/dist/packages/stats/renderSummaryReport.js +33 -33
  52. package/dist/packages/stats/reportHtml.d.ts +7 -6
  53. package/dist/packages/stats/reportHtml.js +39 -37
  54. package/dist/packages/stats/synthesis.d.ts +44 -17
  55. package/dist/packages/stats/synthesis.js +1 -1
  56. package/dist/packages/stats/types.d.ts +12 -0
  57. package/llms.txt +2 -2
  58. package/package.json +1 -1
  59. package/dist/packages/canvas-adapter/summaryRail.d.ts +0 -7
  60. package/dist/packages/canvas-adapter/summaryRail.js +0 -1
@@ -1,67 +1,67 @@
1
- import{waferDisplayLabel as _}from"../core/waferLabel.js";import{binPassSets as Re,binPassSetsByWafer as We,mergeBinDefs as Q,resolveBinColors as Ne,resolveBinColorsByWafer as Ie}from"../renderer/binColors.js";import{commonPassBins as Me,itemPassBins as M,passBinsLabel as Le}from"../core/passBins.js";import{itemRingCount as Ee}from"../core/ringCount.js";import{isParametricTest as ke,isBuiltMap as V}from"../renderer/buildWaferMap.js";import{buildRingRegions as U,buildQuadrantRegions as K,buildRegionYieldData as He}from"./regions.js";import{openHtmlReport as je}from"./renderFindingsReport.js";import{analyzeWaferLot as Ae}from"./analyzeWaferLot.js";import{computeFunctionalYield as qe,analyzeWaferMap as ze}from"./analyzeWaferMap.js";import{mergeTestDefs as Ge}from"./mergeTestDefs.js";import{buildFacetTable as Oe,facetValueOf as _e,FACET_NONE_VALUE as Qe}from"./facets.js";import{visibleFindings as L}from"./filterFindings.js";import{buildYieldDataCombined as Ve}from"./yield.js";import{describeWaferPopulation as J,populationLabel as Ue}from"./population.js";import{buildTestPassRateData as Ke,hasJudgeableTests as Je,poolFunctionalYield as Xe}from"./testPassRate.js";import{buildCapabilityData as Ze}from"./capability.js";import{buildSynthesis as et}from"./synthesis.js";import{binBreakdownRows as tt,binBreakdownTitle as nt,binCountsFrom as st,pooledBinCounts as at,totalOf as it}from"./binRows.js";import{MEAN_WAFER_YIELD_LABEL as ot,shortfallLegend as E}from"./presentation.js";import{regionYieldRows as X,waferYieldRows as rt}from"./yieldRows.js";import{describeValues as lt}from"./math.js";import{fmt as C}from"../renderer/fmt.js";import{getDieKey as ct,isPositionedDie as dt,diePassStatus as Z}from"../core/dies.js";import{testValue as ut}from"../core/dieTable.js";import{findingsTableHtml as ee,synthesisSectionHtml as ft,LIVE_FINDINGS_SCRIPT as k,barCell as R,deltaCell as H,withSectionNav as te,renderMetadataSection as ne,renderMetricGrid as se,renderSection as D,renderTable as P,reportStyles as j}from"./reportHtml.js";import{escHtml as S}from"../core/utils.js";function ae(t,a){return a===0?"\u2014":`${(t/a*100).toFixed(1)}%`}function mt(t){if(!t)return"";const a=t.lot??t.lotId,i=t.wafer??t.waferId,n=[a,i].filter(Boolean).map(String);return n.length?` \u2014 ${n.map(S).join(" \xB7 ")}`:""}function ie(t,a,i,n,r){if(!t.size)return"";const e=tt(t,a,n).map(c=>{const s=c.passing?"muted-row":"",d=m=>({html:S(m),className:s});return[d(String(c.bin)),d(c.name??"\u2014"),d(String(c.count)),R(c.percent,`${c.percent.toFixed(1)}%`,s,r?.get(c.bin))]});return D(nt(i,it(t)),P(["Bin","Name","Dies","Share"],e,{className:"compact"}))}function pt(t,a,i,n,r,e){const c=Re(t,r);return["hard","soft"].map(s=>ie(st(t,s,s==="hard"?n.hard:n.soft),s==="hard"?a:i,s,c[s],e[s])).join(`
2
- `)}function oe(t,a,i,n){const r=new Set(n),e=new Map(i.map(o=>[ct(o),o]));if(!i.some(o=>o.hbin!=null||o.sbin!=null)||!a.length)return"";const s=[];for(const o of a){let p=0,g=0;for(const b of o.dieKeys){const w=e.get(b);if(!w||w.partial||w.edgeExcluded)continue;const y=Z(w,r);y!==void 0&&(g++,y&&p++)}g&&s.push({label:o.label,pass:p,total:g})}if(!s.length)return"";const{rows:d}=X(s.map(o=>({key:o.label,label:o.label,n:o.total,passDies:o.pass,yieldPercent:o.pass/o.total*100}))),m=d.map(o=>[S(o.label),String(o.passDies),String(o.n),R(o.yieldPercent,ae(o.passDies,o.n)),H(o.delta)]);return D(t,P(["Region","Pass","Total","Yield","vs wafer"],m,{className:"compact"})+`<p class="report-legend">${E("the wafer")}</p>`)}function gt(t,a){const i=new Float64Array(t.length);let n=0;for(const g of t){const b=ut(g,a);b!==void 0&&Number.isFinite(b)&&(i[n++]=b)}if(n===0)return;const{count:r,min:e,mean:c,max:s,q1:d,median:m,q3:o,stddev:p}=lt(i.subarray(0,n));return{testNumber:a,count:r,min:e,mean:c,max:s,q1:d,median:m,q3:o,stddev:p}}function re(t,a,i,n,r){if(!a.length)return"";const e=t.filter(l=>!l.partial&&!l.edgeExcluded),c=new Map((i??[]).map(l=>[l.testNumber,l])),s=new Map((n??[]).map(l=>[l.testNumber,l.yieldPercent])),d=[];for(const l of a.filter(ke)){const u=c.get(l.testNumber)??gt(e,l.testNumber);u&&d.push({name:l.name,unit:l.unit||void 0,stats:u,limitYield:s.get(l.testNumber)})}if(!d.length)return"";const m=l=>d.every(u=>u.stats[l]!==void 0),o=m("q1")&&m("median")&&m("q3"),p=m("stddev"),g=d.some(l=>l.limitYield!==void 0&&l.limitYield!==null),b=(l,u)=>l===void 0?"\u2014":C(l,u),w=["Test","N","Min",...o?["Q1","Median"]:[],"Mean",...o?["Q3"]:[],"Max",...p?["StdDev"]:[],...g?["Limit yield"]:[]],y=d.map(({name:l,unit:u,stats:h,limitYield:$})=>[S(l),{html:String(h.count),className:"numeric"},b(h.min,u),...o?[b(h.q1,u),b(h.median,u)]:[],b(h.mean,u),...o?[b(h.q3,u)]:[],b(h.max,u),...p?[b(h.stddev,u)]:[],...g?[$==null?"\u2014":`${$.toFixed(1)}%`]:[]]);return D("Test Values",P(w,y,{className:"compact"})+`<p class="report-legend">${p?"StdDev is the sample standard deviation (n\u22121). ":""}${r??""}</p>`)}function le(t,a,i){const n=i??qe(t,a);if(!n?.length)return"";const r=n.map(e=>[S(e.label),String(e.totalDies),String(e.passDies),String(e.failDies),e.passRatePercent!==null?`${e.passRatePercent.toFixed(1)}%`:"\u2014"]);return D("Functional Tests",P(["Test","N","Pass","Fail","Pass Rate"],r,{className:"compact"}))}function ce(t,a){const i=Ze(t,a);if(!i.length)return"";const n=e=>e===null?"\u2014":e.toFixed(2),r=i.map(e=>[S(e.label),e.hasSpec?e.limitBasis==="spec"?`LSL ${C(e.lsl,e.unit)} \u2013 USL ${C(e.usl,e.unit)}`:`Lo limit ${C(e.lsl,e.unit)} \u2013 Hi limit ${C(e.usl,e.unit)}`:"\u2014",C(e.mean,e.unit),n(e.cp),n(e.cpk),n(e.pp),n(e.ppk)]);return D("Process Capability",P(["Test","Limits","Mean","Cp","Cpk","Pp","Ppk"],r,{className:"compact"}))}function de(t,a,i="",n=!1){const r=L(t);return r.length?D("Findings",ee(r,a,i,n)):""}function ue(t,a,i=""){const n=new Set(L(t.findings).map(r=>r.id));return ft(et(t,{passBins:a?[...a]:void 0}),n,i)}export function renderSummaryReportHtml(t,a={}){const{wafer:i,dies:n,yieldSummary:r,dataCoverage:e,hbinDefs:c,sbinDefs:s,testDefs:d=[],statsSummary:m,passBins:o,ringCount:p}=t,g=t.binColors??Ne(n,{passBins:o,hbinDefs:c,sbinDefs:s}),b=i.metadata,w=mt(b),y=a.title??`Wafer Summary${w}`,l=new Date().toLocaleString(),u=n.filter(dt),h=U(u,i,p),$=K(u,i,p),v=[{label:"Total dies",value:String(r.totalDies)},{label:"Filled dies",value:String(e.filledDies),hint:`${ae(e.filledDies,e.totalDies)} fill`},{label:"Pass dies",value:String(r.passDies)},{label:"Fail dies",value:String(r.failDies)},...r.partialDies>0?[{label:"Partial",value:String(r.partialDies)}]:[],...r.yieldPercent!==null?[{label:`Yield (pass: ${Le([o])})`,value:`${r.yieldPercent.toFixed(1)}%`}]:[],...r.edgeExcludedDies>0?[{label:"Edge excluded (outer zone)",value:String(r.edgeExcludedDies)}]:[]],x=[ne([{metadata:i.metadata}]),D("Summary",[se(v)].filter(Boolean).join(`
3
- `)),m?ue(m,o):"",pt(n,c,s,{hard:m?.stats.hardBinCounts,soft:m?.stats.softBinCounts},o,g),oe("Ring Yield",h,n,o),oe("Quadrant Yield",$,n,o),re(n,d,m?.stats.perTestStats,m?.stats.testSpecYield),le(n,d,m?.stats.functionalYield),ce([{dies:n}],d),m?de(m.findings,void 0,"",t.live):""].filter(Boolean).join(`
1
+ import{waferDisplayLabel as I}from"../core/waferLabel.js";import{binPassSets as Le,binPassSetsByWafer as Ie,mergeBinDefs as X,resolveBinColors as Ee,resolveBinColorsByWafer as ke}from"../renderer/binColors.js";import{commonPassBins as He,itemPassBins as E,passBinsLabel as Ae}from"../core/passBins.js";import{itemRingCount as je}from"../core/ringCount.js";import{isParametricTest as k,isBuiltMap as Z}from"../renderer/buildWaferMap.js";import{buildRingRegions as ee,buildQuadrantRegions as te,buildRegionYieldData as Ge}from"./regions.js";import{openHtmlReport as qe}from"./renderFindingsReport.js";import{analyzeWaferLot as ze}from"./analyzeWaferLot.js";import{computeFunctionalYield as Oe,analyzeWaferMap as _e}from"./analyzeWaferMap.js";import{mergeTestDefs as Qe}from"./mergeTestDefs.js";import{buildFacetTable as Ve,facetValueOf as Ue,FACET_NONE_VALUE as Ke}from"./facets.js";import{visibleFindings as H}from"./filterFindings.js";import{buildYieldDataCombined as Je}from"./yield.js";import{describeWaferPopulation as ne,populationLabel as Xe}from"./population.js";import{buildTestPassRateData as Ze,hasJudgeableTests as et,poolFunctionalYield as tt}from"./testPassRate.js";import{buildCapabilityData as nt}from"./capability.js";import{buildSynthesis as st}from"./synthesis.js";import{binBreakdownRows as at,binBreakdownTitle as it,binCountsFrom as ot,pooledBinCounts as rt,totalOf as lt}from"./binRows.js";import{MEAN_WAFER_YIELD_LABEL as ct,shortfallLegend as A}from"./presentation.js";import{regionYieldRows as se,waferYieldRows as dt}from"./yieldRows.js";import{describeValues as ut}from"./math.js";import{fmt as Y}from"../renderer/fmt.js";import{getDieKey as ft,isPositionedDie as mt,diePassStatus as ae}from"../core/dies.js";import{excludedCounts as pt,testValue as gt}from"../core/dieTable.js";import{limitSetName as ht}from"../renderer/valueFilter.js";import{findingsTableHtml as ie,findingAnchor as bt,synthesisSectionHtml as yt,LIVE_FINDINGS_SCRIPT as j,barCell as R,deltaCell as G,withSectionNav as oe,renderMetadataSection as re,renderMetricGrid as le,renderSection as D,renderTable as P,reportStyles as q}from"./reportHtml.js";import{escHtml as $}from"../core/utils.js";function ce(e,a){return a===0?"\u2014":`${(e/a*100).toFixed(1)}%`}function St(e){if(!e)return"";const a=e.lot??e.lotId,i=e.wafer??e.waferId,n=[a,i].filter(Boolean).map(String);return n.length?` \u2014 ${n.map($).join(" \xB7 ")}`:""}function de(e,a,i,n,r){if(!e.size)return"";const t=at(e,a,n).map(s=>{const c=s.passing?"muted-row":"",l=d=>({html:$(d),className:c});return[l(String(s.bin)),l(s.name??"\u2014"),l(String(s.count)),R(s.percent,`${s.percent.toFixed(1)}%`,c,r?.get(s.bin))]});return D(it(i,lt(e)),P(["Bin","Name","Dies","Share"],t,{className:"compact"}))}function wt(e,a,i,n,r,t){const s=Le(e,r);return["hard","soft"].map(c=>de(ot(e,c,c==="hard"?n.hard:n.soft),c==="hard"?a:i,c,s[c],t[c])).join(`
2
+ `)}function ue(e,a,i,n){const r=new Set(n),t=new Map(i.map(o=>[ft(o),o]));if(!i.some(o=>o.hbin!=null||o.sbin!=null)||!a.length)return"";const c=[];for(const o of a){let b=0,y=0;for(const S of o.dieKeys){const v=t.get(S);if(!v||v.partial||v.edgeExcluded)continue;const h=ae(v,r);h!==void 0&&(y++,h&&b++)}y&&c.push({label:o.label,pass:b,total:y})}if(!c.length)return"";const{rows:l}=se(c.map(o=>({key:o.label,label:o.label,n:o.total,passDies:o.pass,yieldPercent:o.pass/o.total*100}))),d=l.map(o=>[$(o.label),String(o.passDies),String(o.n),R(o.yieldPercent,ce(o.passDies,o.n)),G(o.delta)]);return D(e,P(["Region","Pass","Total","Yield","vs wafer"],d,{className:"compact"})+`<p class="report-legend">${A("the wafer")}</p>`)}function $t(e,a){const i=new Float64Array(e.length);let n=0;for(const y of e){const S=gt(y,a);S!==void 0&&Number.isFinite(S)&&(i[n++]=S)}if(n===0)return;const{count:r,min:t,mean:s,max:c,q1:l,median:d,q3:o,stddev:b}=ut(i.subarray(0,n));return{testNumber:a,count:r,min:t,mean:s,max:c,q1:l,median:d,q3:o,stddev:b}}function fe(e,a,i,n,r,t){if(!a.length)return"";const s=e.filter(u=>!u.partial&&!u.edgeExcluded),c=new Map((i??[]).map(u=>[u.testNumber,u])),l=new Map((n??[]).map(u=>[u.testNumber,u.yieldPercent])),d=[];for(const u of a.filter(k)){const f=c.get(u.testNumber)??$t(s,u.testNumber);f&&d.push({name:u.name,unit:u.unit||void 0,stats:f,limitYield:l.get(u.testNumber)})}if(!d.length)return"";const o=u=>d.every(f=>f.stats[u]!==void 0),b=o("q1")&&o("median")&&o("q3"),y=o("stddev"),S=d.some(u=>u.limitYield!==void 0&&u.limitYield!==null),v=(u,f)=>u===void 0?"\u2014":Y(u,f),h=pt(s),m=h?`${[...h.counts.values()].reduce((u,f)=>u+f,0).toLocaleString("en-GB")} values outside the ${ht(h.by)} are excluded (not in N): `+[...h.counts].map(([u,f])=>`${a.find(w=>w.testNumber===u)?.name??`test ${u}`} ${f.toLocaleString("en-GB")}`).join(", ")+". ":"",g=["Test","N","Min",...b?["Q1","Median"]:[],"Mean",...b?["Q3"]:[],"Max",...y?["StdDev"]:[],...S?["Limit yield"]:[]],x=d.map(({name:u,unit:f,stats:w,limitYield:F})=>[$(u),{html:String(w.count),className:"numeric"},v(w.min,f),...b?[v(w.q1,f),v(w.median,f)]:[],v(w.mean,f),...b?[v(w.q3,f)]:[],v(w.max,f),...y?[v(w.stddev,f)]:[],...S?[F==null?"\u2014":`${F.toFixed(1)}%`]:[]]);return D("Test Values",P(g,x,{className:"compact"})+`<p class="report-legend">${y?"StdDev is the sample standard deviation (n\u22121). ":""}${m}${r??""}</p>`,"",t)}function me(e,a,i,n){const r=i??Oe(e,a);if(!r?.length)return"";const t=r.map(s=>[$(s.label),String(s.totalDies),String(s.passDies),String(s.failDies),s.passRatePercent!==null?`${s.passRatePercent.toFixed(1)}%`:"\u2014"]);return D("Functional Tests",P(["Test","N","Pass","Fail","Pass Rate"],t,{className:"compact"}),"",n)}function pe(e,a){const i=nt(e,a);if(!i.length)return"";const n=t=>t===null?"\u2014":t.toFixed(2),r=i.map(t=>[$(t.label),t.hasSpec?t.limitBasis==="spec"?`LSL ${Y(t.lsl,t.unit)} \u2013 USL ${Y(t.usl,t.unit)}`:`Lo limit ${Y(t.lsl,t.unit)} \u2013 Hi limit ${Y(t.usl,t.unit)}`:"\u2014",Y(t.mean,t.unit),n(t.cp),n(t.cpk),n(t.pp),n(t.ppk)]);return D("Process Capability",P(["Test","Limits","Mean","Cp","Cpk","Pp","Ppk"],r,{className:"compact"}))}function ge(e,a,i="",n=!1){const r=H(e);return r.length?D("Findings",ie(r,a,i,n)):""}const z=e=>`report-tests-${e}`,O=e=>`report-functional-${e}`;function he(e,a,i,n){const r=new Set(H(e.findings).map(s=>s.id)),t=s=>s.kind==="finding"?r.has(s.id)?bt(s.id,i):void 0:n.get(s.testNumber);return yt(st(e,{passBins:a?[...a]:void 0}),t)}function be(e,a,i,n){const r=new Map;for(const t of e)(k(t)?i:n)&&r.set(t.testNumber,k(t)?z(a):O(a));return r}export function renderSummaryReportHtml(e,a={}){const{wafer:i,dies:n,yieldSummary:r,dataCoverage:t,hbinDefs:s,sbinDefs:c,testDefs:l=[],statsSummary:d,passBins:o,ringCount:b}=e,y=e.binColors??Ee(n,{passBins:o,hbinDefs:s,sbinDefs:c}),S=i.metadata,v=St(S),h=a.title??`Wafer Summary${v}`,m=new Date().toLocaleString(),g=n.filter(mt),x=ee(g,i,b),u=te(g,i,b),f=[{label:"Total dies",value:String(r.totalDies)},{label:"Filled dies",value:String(t.filledDies),hint:`${ce(t.filledDies,t.totalDies)} fill`},{label:"Pass dies",value:String(r.passDies)},{label:"Fail dies",value:String(r.failDies)},...r.partialDies>0?[{label:"Partial",value:String(r.partialDies)}]:[],...r.yieldPercent!==null?[{label:`Yield (pass: ${Ae([o])})`,value:`${r.yieldPercent.toFixed(1)}%`}]:[],...r.edgeExcludedDies>0?[{label:"Edge excluded (outer zone)",value:String(r.edgeExcludedDies)}]:[]],w=fe(n,l,d?.stats.perTestStats,d?.stats.testSpecYield,void 0,z("")),F=me(n,l,d?.stats.functionalYield,O("")),B=[re([{metadata:i.metadata}]),D("Summary",[le(f)].filter(Boolean).join(`
3
+ `)),d?he(d,o,"",be(l,"",!!w,!!F)):"",wt(n,s,c,{hard:d?.stats.hardBinCounts,soft:d?.stats.softBinCounts},o,y),ue("Ring Yield",x,n,o),ue("Quadrant Yield",u,n,o),w,F,pe([{dies:n}],l),d?ge(d.findings,void 0,"",e.live):""].filter(Boolean).join(`
4
4
  `);return`<!DOCTYPE html>
5
5
  <html lang="en">
6
6
  <head>
7
7
  <meta charset="UTF-8">
8
- <title>${S(y)}</title>
8
+ <title>${$(h)}</title>
9
9
  <style>
10
- ${j()}
10
+ ${q()}
11
11
  </style>
12
12
  </head>
13
13
  <body>
14
14
  <main class="report">
15
15
  <header class="report-header">
16
- <h1>${S(y)}</h1>
17
- <p class="report-subtitle">Generated ${S(l)}</p>
16
+ <h1>${$(h)}</h1>
17
+ <p class="report-subtitle">Generated ${$(m)}</p>
18
18
  </header>
19
- ${te(x)}
20
- <p class="footer">Generated ${S(l)}</p>
19
+ ${oe(B)}
20
+ <p class="footer">Generated ${$(m)}</p>
21
21
  </main>
22
- ${t.live?k:""}
22
+ ${e.live?j:""}
23
23
  </body>
24
- </html>`}function ht(t,a){const i=t.perWafer.flatMap(e=>{const c=e.summary.stats.yieldPercent;return c===null?[]:[{waferIndex:e.waferIndex,yieldPercent:c}]}),n=new Map(rt(i).rows.map(e=>[e.waferIndex,e])),r=t.perWafer.map(e=>{const c=S(_(a[e.waferIndex],e.waferIndex)),s=n.get(e.waferIndex);return s?[s.outlier?`${c} \xB7 ${s.outlier} outlier`:c,R(s.yieldPercent,`${s.yieldPercent.toFixed(1)}%`),H(s.delta)]:[c,"N/A",""]});return P(["Wafer","Yield","vs lot median"],r,{className:"compact"})+`<p class="report-legend">${E("the lot median")}</p>`}function bt(t){const a=[];for(const e of t.perWafer){const c=L(e.summary.findings);if(!c.length)continue;const s=e.summary.wafer?.waferId??`Wafer ${e.waferIndex+1}`;a.push(`<h3 class="report-subheading">${S(s)}</h3>`+ee(c))}if(!a.length)return"";const i=a.length,n=t.perWafer.length,r=`<p class="report-note">${i} of ${n} wafer${n===1?"":"s"} have per-wafer findings; the rest had none.</p>`;return D("Findings by Wafer",r+a.join(`
25
- `))}const yt=3;function St(t,a,i){const n=t.map(d=>({metadata:d.wafer?.metadata})),r=Oe(n,{facetableOnly:!0}).filter(d=>d.splittable);if(!r.length)return"";const e=r.slice(0,yt),c=[];for(const d of e){const m=new Map;t.forEach((l,u)=>{const h=_e(l.wafer?.metadata,d.key)??Qe;(m.get(h)??m.set(h,[]).get(h)).push(u)});const o=[...m.entries()].map(([l,u])=>({key:l,items:u.map(h=>t[h])}));if(o.length<2)continue;const p=o.map(l=>[S(l.key),S(l.items.map(u=>u.label).join(", "))]),g=Ve(o.map(l=>({key:l.key,items:l.items.map(u=>({label:u.label,dies:u.dies,passBins:M(u,i)}))}))).map(l=>[S(l.label),String(l.itemCount),`${l.percent.toFixed(1)}%`]),b=[P([d.label,"Wafers"],p,{className:"compact"}),P([d.label,"Wafers","Yield"],g,{className:"compact"})],w=t.flatMap(l=>l.dies??[]);let y=0;for(const l of["spec","testFlag","functional"]){if(!Je(a,l,w))continue;const u=Ke(o.map(v=>({key:v.key,items:v.items.map(x=>({dies:x.dies,testSpecYield:x.statsSummary?.stats.testSpecYield,functionalYield:x.statsSummary?.stats.functionalYield}))})),a,l);if(!u.rows.length)continue;const h=u.rows.map(v=>[S(v.label),...v.byGroup.map(x=>x.passRatePercent===null?"\u2014":`${x.passRatePercent.toFixed(1)}%`),v.overall.passRatePercent===null?"\u2014":`${v.overall.passRatePercent.toFixed(1)}%`]),$=l==="spec"?"Pass rate \xB7 test limits":l==="testFlag"?"Pass rate \xB7 tester flag":"Pass rate \xB7 functional";u.disagreementDies&&(y=u.disagreementDies),b.push(`<h4 class="report-subheading">${S($)}</h4>`+P(["Test",...u.groups,"All"],h,{className:"compact"}))}y&&b.push(`<p class="report-note">${y.toLocaleString()} dies judged differently by limits and tester flag.</p>`),c.push(`<h3 class="report-subheading">${S(d.label)}</h3>${b.join(`
26
- `)}`)}if(!c.length)return"";const s=r.length>e.length?`<p class="report-note">${r.length-e.length} further splittable field(s) not shown.</p>`:"";return D("Split Comparison",c.join(`
27
- `)+s)}function wt(t,a,i,n,r,e){const c=We(r);return["hard","soft"].map(s=>ie(at(n,t,s),s==="hard"?a:i,s,c[s],e[s])).join(`
28
- `)}function fe(t,a,i,n,r,e){const c=He(i,n,r,d=>e[d],a);if(!c.length)return"";const s=X(c).rows.map(d=>[S(d.label),R(d.yieldPercent,`${d.yieldPercent.toFixed(1)}%`),H(d.delta)]);return D(t,P(["Region","Yield","vs lot"],s,{className:"compact"})+`<p class="report-legend">${E("the lot")}</p>`)}function $t(t,a,i,n){let r;if(i?.length&&i.every(e=>e.stats.perTestStats!==void 0)){const e=new Map;for(const c of i)for(const s of c.stats.perTestStats??[]){const d=e.get(s.testNumber)??{n:0,sum:0,min:1/0,max:-1/0,parts:[]};d.n+=s.count,d.sum+=s.mean*s.count,d.min=Math.min(d.min,s.min),d.max=Math.max(d.max,s.max),d.parts.push({n:s.count,mean:s.mean,sd:s.stddev}),e.set(s.testNumber,d)}r=[...e.entries()].map(([c,s])=>{const d=s.sum/s.n,m=s.parts.every(p=>p.sd!==void 0),o=m&&s.n>1?s.parts.reduce((p,g)=>p+Math.max(0,g.n-1)*g.sd**2+g.n*(g.mean-d)**2,0)/(s.n-1):m?0:void 0;return{testNumber:c,count:s.n,min:s.min,max:s.max,mean:d,...o!==void 0?{stddev:Math.sqrt(o)}:{}}})}return re(t,a,r,n,r?"Quartiles are not shown for a lot: they cannot be combined from each wafer\u2019s own.":void 0)}function vt(t,a,i){const n=Xe(i);return le(t,a,n)}const A=["lot","product","testProgram","temperature"];function xt(t){const a=new Map(A.map(e=>[e,new Set]));for(const e of t)for(const c of A){const s=e.wafer?.metadata?.[c];s!=null&&s!==""&&a.get(c).add(String(s))}const i=A.filter(e=>a.get(e).size>1);if(i.length===0)return[{label:"",items:t,varying:i}];const n=new Map,r=[];for(const e of t){const c=i.map(s=>String(e.wafer?.metadata?.[s]??"(none)")).join(" \xB7 ");n.has(c)||(n.set(c,[]),r.push(c)),n.get(c).push(e)}return r.map(e=>({label:e,items:n.get(e),varying:i}))}function me(t,a,i,n,r,e,c,s,d="",m=!1){const o=Ae(t.map(f=>f.source??f),{perWaferSummaries:t.map(f=>f.statsSummary),...c}),p=[],g=[],b=[],w=[];for(const f of t){const T=f.dies??[];f.wafer&&(p.push(f.wafer),b.push(T),w.push(M(f,r)));for(const F of T)g.push(F)}const y=t.map(f=>({dies:f.dies??[],passBins:M(f,r)})),l=s??Ie(y,{hbinDefs:a,sbinDefs:i}).colors,u=g.some(f=>f.hbin!=null),h=g.some(f=>f.sbin!=null),$=u||h,v=o.perWafer.map(f=>f.summary.stats.yieldPercent).filter(f=>f!==null),x=v.length?v.reduce((f,T)=>f+T,0)/v.length:null;let q=0,B=0,Y=0,W=0,N=0;for(const f of y){const T=new Set(f.passBins);for(const F of f.dies){if(q++,F.edgeExcluded&&W++,F.partial&&N++,F.partial||F.edgeExcluded)continue;const O=Z(F,T);O!==void 0&&(B++,O&&Y++)}}const ge=B-Y,z=B>0?Y/B*100:null,he=[{label:"Wafers",value:String(o.stats.waferCount)},{label:"Total dies",value:String(q)},...$?[{label:"Good dies",value:String(Y)},{label:"Bad dies",value:String(ge)}]:[],...W>0?[{label:"Edge excluded",value:String(W)}]:[],...N>0?[{label:"Partial dies",value:String(N)}]:[],...x!==null?[{label:ot,value:`${x.toFixed(1)}%`}]:[],...z!==null?[{label:"Total yield",value:`${z.toFixed(1)}%`}]:[]],be=J(o.perWafer.map(f=>f.summary.wafer)),ye=D(be.lotId!==void 0?"Lot Summary":"Summary",se(he)),Se=ne(t.map(f=>({metadata:f.wafer?.metadata}))),we=D("Per-Wafer Yield",ht(o,t)),G=e??Ee(t[0]),$e=St(t,n,r),I=o.perWafer.map(f=>f.summary),ve=$?wt(g,a,i,I,y,l):"",xe=$&&p.length?fe("Ring Yield (All Wafers)",U,b,p,G,w):"",De=$&&p.length?fe("Quadrant Yield (All Wafers)",K,b,p,G,w):"",Pe=n.length?$t(g,n,I,o.stats.testSpecYield):"",Fe=n.length?vt(g,n,I):"",Te=n.length?ce(t,n):"",Ce=o.findings.length?de(o.findings,o.stats.waferCount,d,m):"",Be=bt(o),Ye=[ye,ue(o,Me(y.map(f=>f.passBins)),d),Se,we,$e,ve,xe,De,Pe,Fe,Te,Ce,Be].filter(Boolean).join(`
29
- `);return{lotSummary:o,sections:Ye}}function pe(t,a,i,n=""){return`<main class="report">
24
+ </html>`}function vt(e,a){const i=e.perWafer.flatMap(t=>{const s=t.summary.stats.yieldPercent;return s===null?[]:[{waferIndex:t.waferIndex,yieldPercent:s}]}),n=new Map(dt(i).rows.map(t=>[t.waferIndex,t])),r=e.perWafer.map(t=>{const s=$(I(a[t.waferIndex],t.waferIndex)),c=n.get(t.waferIndex);return c?[c.outlier?`${s} \xB7 ${c.outlier} outlier`:s,R(c.yieldPercent,`${c.yieldPercent.toFixed(1)}%`),G(c.delta)]:[s,"N/A",""]});return P(["Wafer","Yield","vs lot median"],r,{className:"compact"})+`<p class="report-legend">${A("the lot median")}</p>`}function xt(e){const a=[];for(const t of e.perWafer){const s=H(t.summary.findings);if(!s.length)continue;const c=I({wafer:{metadata:t.summary.wafer}},t.waferIndex);a.push(`<h3 class="report-subheading">${$(c)}</h3>`+ie(s))}if(!a.length)return"";const i=a.length,n=e.perWafer.length,r=`<p class="report-note">${i} of ${n} wafer${n===1?"":"s"} have per-wafer findings; the rest had none.</p>`;return D("Findings by Wafer",r+a.join(`
25
+ `))}const Dt=3;function Pt(e,a,i){const n=e.map(l=>({metadata:l.wafer?.metadata})),r=Ve(n,{facetableOnly:!0}).filter(l=>l.splittable);if(!r.length)return"";const t=r.slice(0,Dt),s=[];for(const l of t){const d=new Map;e.forEach((m,g)=>{const x=Ue(m.wafer?.metadata,l.key)??Ke;(d.get(x)??d.set(x,[]).get(x)).push(g)});const o=[...d.entries()].map(([m,g])=>({key:m,items:g.map(x=>e[x])}));if(o.length<2)continue;const b=o.map(m=>[$(m.key),$(m.items.map(g=>g.label).join(", "))]),y=Je(o.map(m=>({key:m.key,items:m.items.map(g=>({label:g.label,dies:g.dies,passBins:E(g,i)}))}))).map(m=>[$(m.label),String(m.itemCount),`${m.percent.toFixed(1)}%`]),S=[P([l.label,"Wafers"],b,{className:"compact"}),P([l.label,"Wafers","Yield"],y,{className:"compact"})],v=e.flatMap(m=>m.dies??[]);let h=0;for(const m of["spec","testFlag","functional"]){if(!et(a,m,v))continue;const g=Ze(o.map(f=>({key:f.key,items:f.items.map(w=>({dies:w.dies,testSpecYield:w.statsSummary?.stats.testSpecYield,functionalYield:w.statsSummary?.stats.functionalYield}))})),a,m);if(!g.rows.length)continue;const x=g.rows.map(f=>[$(f.label),...f.byGroup.map(w=>w.passRatePercent===null?"\u2014":`${w.passRatePercent.toFixed(1)}%`),f.overall.passRatePercent===null?"\u2014":`${f.overall.passRatePercent.toFixed(1)}%`]),u=m==="spec"?"Pass rate \xB7 test limits":m==="testFlag"?"Pass rate \xB7 tester flag":"Pass rate \xB7 functional";g.disagreementDies&&(h=g.disagreementDies),S.push(`<h4 class="report-subheading">${$(u)}</h4>`+P(["Test",...g.groups,"All"],x,{className:"compact"}))}h&&S.push(`<p class="report-note">${h.toLocaleString()} dies judged differently by limits and tester flag.</p>`),s.push(`<h3 class="report-subheading">${$(l.label)}</h3>${S.join(`
26
+ `)}`)}if(!s.length)return"";const c=r.length>t.length?`<p class="report-note">${r.length-t.length} further splittable field(s) not shown.</p>`:"";return D("Split Comparison",s.join(`
27
+ `)+c)}function Ft(e,a,i,n,r,t){const s=Ie(r);return["hard","soft"].map(c=>de(rt(n,e,c),c==="hard"?a:i,c,s[c],t[c])).join(`
28
+ `)}function ye(e,a,i,n,r,t){const s=Ge(i,n,r,l=>t[l],a);if(!s.length)return"";const c=se(s).rows.map(l=>[$(l.label),R(l.yieldPercent,`${l.yieldPercent.toFixed(1)}%`),G(l.delta)]);return D(e,P(["Region","Yield","vs lot"],c,{className:"compact"})+`<p class="report-legend">${A("the lot")}</p>`)}function Tt(e,a,i,n,r){let t;if(i?.length&&i.every(s=>s.stats.perTestStats!==void 0)){const s=new Map;for(const c of i)for(const l of c.stats.perTestStats??[]){const d=s.get(l.testNumber)??{n:0,sum:0,min:1/0,max:-1/0,parts:[]};d.n+=l.count,d.sum+=l.mean*l.count,d.min=Math.min(d.min,l.min),d.max=Math.max(d.max,l.max),d.parts.push({n:l.count,mean:l.mean,sd:l.stddev}),s.set(l.testNumber,d)}t=[...s.entries()].map(([c,l])=>{const d=l.sum/l.n,o=l.parts.every(y=>y.sd!==void 0),b=o&&l.n>1?l.parts.reduce((y,S)=>y+Math.max(0,S.n-1)*S.sd**2+S.n*(S.mean-d)**2,0)/(l.n-1):o?0:void 0;return{testNumber:c,count:l.n,min:l.min,max:l.max,mean:d,...b!==void 0?{stddev:Math.sqrt(b)}:{}}})}return fe(e,a,t,n,t?"Quartiles are not shown for a lot: they cannot be combined from each wafer\u2019s own.":void 0,r)}function Bt(e,a,i,n){const r=tt(i);return me(e,a,r,n)}const _=["lot","product","testProgram","temperature"];function Ct(e){const a=new Map(_.map(t=>[t,new Set]));for(const t of e)for(const s of _){const c=t.wafer?.metadata?.[s];c!=null&&c!==""&&a.get(s).add(String(c))}const i=_.filter(t=>a.get(t).size>1);if(i.length===0)return[{label:"",items:e,varying:i}];const n=new Map,r=[];for(const t of e){const s=i.map(c=>String(t.wafer?.metadata?.[c]??"(none)")).join(" \xB7 ");n.has(s)||(n.set(s,[]),r.push(s)),n.get(s).push(t)}return r.map(t=>({label:t,items:n.get(t),varying:i}))}function Se(e,a,i,n,r,t,s,c,l="",d=!1){const o=ze(e.map(p=>p.source??p),{perWaferSummaries:e.map(p=>p.statsSummary),...s}),b=[],y=[],S=[],v=[];for(const p of e){const C=p.dies??[];p.wafer&&(b.push(p.wafer),S.push(C),v.push(E(p,r)));for(const T of C)y.push(T)}const h=e.map(p=>({dies:p.dies??[],passBins:E(p,r)})),m=c??ke(h,{hbinDefs:a,sbinDefs:i}).colors,g=y.some(p=>p.hbin!=null),x=y.some(p=>p.sbin!=null),u=g||x,f=o.perWafer.map(p=>p.summary.stats.yieldPercent).filter(p=>p!==null),w=f.length?f.reduce((p,C)=>p+C,0)/f.length:null;let F=0,B=0,N=0,M=0,W=0;for(const p of h){const C=new Set(p.passBins);for(const T of p.dies){if(F++,T.edgeExcluded&&M++,T.partial&&W++,T.partial||T.edgeExcluded)continue;const J=ae(T,C);J!==void 0&&(B++,J&&N++)}}const $e=B-N,Q=B>0?N/B*100:null,ve=[{label:"Wafers",value:String(o.stats.waferCount)},{label:"Total dies",value:String(F)},...u?[{label:"Good dies",value:String(N)},{label:"Bad dies",value:String($e)}]:[],...M>0?[{label:"Edge excluded",value:String(M)}]:[],...W>0?[{label:"Partial dies",value:String(W)}]:[],...w!==null?[{label:ct,value:`${w.toFixed(1)}%`}]:[],...Q!==null?[{label:"Total yield",value:`${Q.toFixed(1)}%`}]:[]],xe=ne(o.perWafer.map(p=>p.summary.wafer)),De=D(xe.lotId!==void 0?"Lot Summary":"Summary",le(ve)),Pe=re(e.map(p=>({metadata:p.wafer?.metadata}))),Fe=D("Per-Wafer Yield",vt(o,e)),V=t??je(e[0]),Te=Pt(e,n,r),L=o.perWafer.map(p=>p.summary),Be=u?Ft(y,a,i,L,h,m):"",Ce=u&&b.length?ye("Ring Yield (All Wafers)",ee,S,b,V,v):"",Ye=u&&b.length?ye("Quadrant Yield (All Wafers)",te,S,b,V,v):"",U=n.length?Tt(y,n,L,o.stats.testSpecYield,z(l)):"",K=n.length?Bt(y,n,L,O(l)):"",Ne=n.length?pe(e,n):"",Re=o.findings.length?ge(o.findings,o.stats.waferCount,l,d):"",Me=xt(o),We=[De,he(o,He(h.map(p=>p.passBins)),l,be(n,l,!!U,!!K)),Pe,Fe,Te,Be,Ce,Ye,U,K,Ne,Re,Me].filter(Boolean).join(`
29
+ `);return{lotSummary:o,sections:We}}function we(e,a,i,n=""){return`<main class="report">
30
30
  <header class="report-header">
31
- <h1>${S(t)}</h1>
32
- <p class="report-subtitle">Generated ${S(i)}</p>
31
+ <h1>${$(e)}</h1>
32
+ <p class="report-subtitle">Generated ${$(i)}</p>
33
33
  </header>
34
- ${te(a,n)}
35
- <p class="footer">Generated ${S(i)}</p>
36
- </main>`}export function renderLotSummaryReportHtml(t,a={}){const{items:i,hbinDefs:n,sbinDefs:r,testDefs:e=[],passBins:c,ringCount:s,analyzeOptions:d}=t,m=new Date().toLocaleString(),o=xt(i);if(o.length===1){const{lotSummary:y,sections:l}=me(o[0].items,n,r,e,c,s,d,t.binColors,"",t.live),u=J(y.perWafer.map($=>$.summary.wafer)),h=a.title??(u.lotId!==void 0?`Lot Summary \u2014 ${u.lotId}`:`Summary \u2014 ${Ue(u)}`);return`<!DOCTYPE html>
34
+ ${oe(a,n)}
35
+ <p class="footer">Generated ${$(i)}</p>
36
+ </main>`}export function renderLotSummaryReportHtml(e,a={}){const{items:i,hbinDefs:n,sbinDefs:r,testDefs:t=[],passBins:s,ringCount:c,analyzeOptions:l}=e,d=new Date().toLocaleString(),o=Ct(i);if(o.length===1){const{lotSummary:h,sections:m}=Se(o[0].items,n,r,t,s,c,l,e.binColors,"",e.live),g=ne(h.perWafer.map(u=>u.summary.wafer)),x=a.title??(g.lotId!==void 0?`Lot Summary \u2014 ${g.lotId}`:`Summary \u2014 ${Xe(g)}`);return`<!DOCTYPE html>
37
37
  <html lang="en">
38
38
  <head>
39
39
  <meta charset="UTF-8">
40
- <title>${S(h)}</title>
40
+ <title>${$(x)}</title>
41
41
  <style>
42
- ${j()}
42
+ ${q()}
43
43
  </style>
44
44
  </head>
45
45
  <body>
46
- ${pe(h,l,m)}
47
- ${t.live?k:""}
46
+ ${we(x,m,d)}
47
+ ${e.live?j:""}
48
48
  </body>
49
- </html>`}const p=a.title??"Summary",g=o.map((y,l)=>{const u=`g${l+1}-`,{lotSummary:h,sections:$}=me(y.items,n,r,e,c,s,d,t.binColors,u,t.live),v=y.varying.includes("lot")?void 0:h.lot?.lot??h.lot?.lotId,x=v?`${y.label} \xB7 Lot ${String(v)}`:y.label;return pe(`${p} \u2014 ${x}`,$,m,u)}),b=`<p style="max-width:1080px;margin:0 auto 8px;padding:8px 12px;background:var(--report-surface);border:1px solid var(--report-line);border-radius:4px;font-size:12px;color:var(--report-muted);">This load spans ${o.length} groups by identity \u2014 shown separately below so stats are never pooled across them.</p>`,w=g.map((y,l)=>`${l===0?"":'<hr style="max-width:1080px;margin:32px auto 0;border:none;border-top:3px solid var(--report-line-strong);">'}
50
- ${y}`).join(`
49
+ </html>`}const b=a.title??"Summary",y=o.map((h,m)=>{const g=`g${m+1}-`,{lotSummary:x,sections:u}=Se(h.items,n,r,t,s,c,l,e.binColors,g,e.live),f=h.varying.includes("lot")?void 0:x.lot?.lot??x.lot?.lotId,w=f?`${h.label} \xB7 Lot ${String(f)}`:h.label;return we(`${b} \u2014 ${w}`,u,d,g)}),S=`<p style="max-width:1080px;margin:0 auto 8px;padding:8px 12px;background:var(--report-surface);border:1px solid var(--report-line);border-radius:4px;font-size:12px;color:var(--report-muted);">This load spans ${o.length} groups by identity \u2014 shown separately below so stats are never pooled across them.</p>`,v=y.map((h,m)=>`${m===0?"":'<hr style="max-width:1080px;margin:32px auto 0;border:none;border-top:3px solid var(--report-line-strong);">'}
50
+ ${h}`).join(`
51
51
  `);return`<!DOCTYPE html>
52
52
  <html lang="en">
53
53
  <head>
54
54
  <meta charset="UTF-8">
55
- <title>${S(p)}</title>
55
+ <title>${$(b)}</title>
56
56
  <style>
57
- ${j()}
57
+ ${q()}
58
58
  </style>
59
59
  </head>
60
60
  <body>
61
61
  <div class="report" style="padding-top:24px;">
62
- ${b}
62
+ ${S}
63
63
  </div>
64
- ${w}
65
- ${t.live?k:""}
64
+ ${v}
65
+ ${e.live?j:""}
66
66
  </body>
67
- </html>`}export{je as openHtmlReport};export function renderWaferReportHtml(t,a,i={}){return renderSummaryReportHtml({wafer:t.wafer,dies:t.dies,yieldSummary:t.yield,dataCoverage:t.dataCoverage,hbinDefs:t.hbinDefs,sbinDefs:t.sbinDefs,testDefs:t.testDefs,statsSummary:a??t.statsSummary??(V(t)?ze(t):void 0),passBins:[...t.passBins],ringCount:t.ringCount,binColors:i.binColors,live:i.live},i)}export function renderLotReportHtml(t,a={}){const i=Q(t.map(e=>e.hbinDefs)),n=Q(t.map(e=>e.sbinDefs)),r=t.some(e=>e.testDefs?.length)?Ge([...t]).defs:void 0;return renderLotSummaryReportHtml({items:t.map((e,c)=>({label:_(e,c),wafer:e.wafer,dies:e.dies,passBins:[...e.passBins],statsSummary:e.statsSummary,source:V(e)?e:void 0})),hbinDefs:i.length?i:void 0,sbinDefs:n.length?n:void 0,testDefs:r,ringCount:t[0]?.ringCount,analyzeOptions:a.analyzeOptions,binColors:a.binColors,live:a.live},{title:a.title})}
67
+ </html>`}export{qe as openHtmlReport};export function renderWaferReportHtml(e,a,i={}){return renderSummaryReportHtml({wafer:e.wafer,dies:e.dies,yieldSummary:e.yield,dataCoverage:e.dataCoverage,hbinDefs:e.hbinDefs,sbinDefs:e.sbinDefs,testDefs:e.testDefs,statsSummary:a??e.statsSummary??(Z(e)?_e(e):void 0),passBins:[...e.passBins],ringCount:e.ringCount,binColors:i.binColors,live:i.live},i)}export function renderLotReportHtml(e,a={}){const i=X(e.map(t=>t.hbinDefs)),n=X(e.map(t=>t.sbinDefs)),r=e.some(t=>t.testDefs?.length)?Qe([...e]).defs:void 0;return renderLotSummaryReportHtml({items:e.map((t,s)=>({label:I(t,s),wafer:t.wafer,dies:t.dies,passBins:[...t.passBins],statsSummary:t.statsSummary,source:Z(t)?t:void 0})),hbinDefs:i.length?i:void 0,sbinDefs:n.length?n:void 0,testDefs:r,ringCount:e[0]?.ringCount,analyzeOptions:a.analyzeOptions,binColors:a.binColors,live:a.live},{title:a.title})}
@@ -1,5 +1,5 @@
1
1
  import type { StatsFinding, StatsSeverity } from './types.js';
2
- import { type Synthesis } from './synthesis.js';
2
+ import { type Synthesis, type SynthesisTarget } from './synthesis.js';
3
3
  import { type MeterTier } from './presentation.js';
4
4
  export type { MeterTier };
5
5
  import { type FacetItem } from './facets.js';
@@ -8,7 +8,7 @@ export interface MetricItem {
8
8
  value: string;
9
9
  hint?: string;
10
10
  }
11
- export declare function renderSection(title: string, body: string, className?: string): string;
11
+ export declare function renderSection(title: string, body: string, className?: string, id?: string): string;
12
12
  export declare function renderDefinitionList(entries: Array<{
13
13
  label: string;
14
14
  value: string;
@@ -99,11 +99,12 @@ export declare function findingAnchor(id: string, scope?: string): string;
99
99
  */
100
100
  export declare function findingsTableHtml(findings: StatsFinding[], totalWafers?: number, anchorScope?: string, live?: boolean): string;
101
101
  /**
102
- * The synthesis as a section: the headline, the loss items each linked to the finding rows that
103
- * carry their figures, and what was compared. A part links only when its row is on the page
104
- * (`anchorIds`), so a sentence never points at nothing.
102
+ * The synthesis as a section: the headline, the items, and what was compared. Every item links to its
103
+ * evidence the same way — the lead by a "See" line naming its target and its parts, each further item and
104
+ * Watch line by its own text — wherever `anchorFor` finds that evidence on the page, so a link never points
105
+ * at nothing and no item is linked only because of where its figures came from.
105
106
  */
106
- export declare function synthesisSectionHtml(synthesis: Synthesis, anchorIds: ReadonlySet<string>, scope?: string): string;
107
+ export declare function synthesisSectionHtml(synthesis: Synthesis, anchorFor: (target: SynthesisTarget) => string | undefined): string;
107
108
  /**
108
109
  * For a report shown inside the app (the panel's modal): a click on a finding's row tells the page that
109
110
  * holds the report, which selects that finding on the map. Inert when the report is opened on its own
@@ -1,28 +1,28 @@
1
- import{SYNTHESIS_SMALLER_HEADING as f,synthesisRowShare as u}from"./synthesis.js";import{formatFindingTooltip as x}from"./findingText.js";import{arrangeFindings as v}from"./filterFindings.js";import{SEVERITY_MARK as h,METER_DOTS as $,filledDots as w,impactWord as y,impactShortWord as k,shortfallColor as g,shortfallStep as S,formatPoints as z,barPercent as M}from"./presentation.js";import{fmt as b,plainBinTerms as j}from"../renderer/fmt.js";import{buildFacetTable as T,attributeLabel as F}from"./facets.js";import{escHtml as a}from"../core/utils.js";import{derivedKeyText as N,derivedFields as A}from"../renderer/testLabel.js";export function renderSection(t,e,r=""){return`<section class="${["report-section",r].filter(Boolean).join(" ")}">
2
- <h2>${a(t)}</h2>
3
- ${e}
4
- </section>`}export function renderDefinitionList(t,e="meta-list"){if(!t.length)return"";const r=t.map(o=>`<div class="definition-item"><dt>${a(o.label)}</dt><dd>${a(o.value)}</dd></div>`).join(`
5
- `);return`<dl class="${e}">
6
- ${r}
7
- </dl>`}export function buildMetadataRows(t){return T(t,{facetableOnly:t.length>1}).map(r=>({label:F(r.key),value:r.values.map(o=>o.value).join(", ")}))}export function renderMetadataSection(t){const e=buildMetadataRows(t);return e.length?renderSection("Wafer Info",renderDefinitionList(e)):""}export function renderMetricGrid(t){return t.length?`<dl class="metric-grid">
8
- ${t.map(r=>`<div class="metric">
9
- <dt>${a(r.label)}</dt>
10
- <dd>${a(r.value)}</dd>
11
- ${r.hint?`<span class="metric-hint">${a(r.hint)}</span>`:""}
1
+ import{SYNTHESIS_ALSO_HEADING as f,synthesisRowShare as x}from"./synthesis.js";import{formatFindingTooltip as v}from"./findingText.js";import{arrangeFindings as $}from"./filterFindings.js";import{SEVERITY_MARK as b,METER_DOTS as w,filledDots as y,impactWord as k,impactShortWord as S,shortfallColor as h,shortfallStep as z,formatPoints as j,barPercent as M}from"./presentation.js";import{fmt as u,plainBinTerms as T}from"../renderer/fmt.js";import{buildFacetTable as F,attributeLabel as N}from"./facets.js";import{escHtml as o}from"../core/utils.js";import{derivedKeyText as A,derivedFields as D}from"../renderer/testLabel.js";export function renderSection(t,r,e="",a){return`<section class="${["report-section",e].filter(Boolean).join(" ")}"${a?` id="${o(a)}"`:""}>
2
+ <h2>${o(t)}</h2>
3
+ ${r}
4
+ </section>`}export function renderDefinitionList(t,r="meta-list"){if(!t.length)return"";const e=t.map(a=>`<div class="definition-item"><dt>${o(a.label)}</dt><dd>${o(a.value)}</dd></div>`).join(`
5
+ `);return`<dl class="${r}">
6
+ ${e}
7
+ </dl>`}export function buildMetadataRows(t){return F(t,{facetableOnly:t.length>1}).map(e=>({label:N(e.key),value:e.values.map(a=>a.value).join(", ")}))}export function renderMetadataSection(t){const r=buildMetadataRows(t);return r.length?renderSection("Wafer Info",renderDefinitionList(r)):""}export function renderMetricGrid(t){return t.length?`<dl class="metric-grid">
8
+ ${t.map(e=>`<div class="metric">
9
+ <dt>${o(e.label)}</dt>
10
+ <dd>${o(e.value)}</dd>
11
+ ${e.hint?`<span class="metric-hint">${o(e.hint)}</span>`:""}
12
12
  </div>`).join(`
13
13
  `)}
14
- </dl>`:""}export function renderTable(t,e,r={}){if(!e.length)return`<p class="no-data">${a(r.emptyMessage??"No data")}</p>`;const o=["report-table",r.className].filter(Boolean).join(" "),s=t.map(n=>`<th>${a(n)}</th>`).join(""),m=n=>typeof n=="string"?`<td>${n}</td>`:`<td${n.className?` class="${n.className}"`:""}>${n.html}</td>`,l=e.map(n=>`<tr>${n.map(m).join("")}</tr>`).join(`
15
- `);return`<table class="${o}">
16
- <thead><tr>${s}</tr></thead>
17
- <tbody>${l}</tbody>
18
- </table>`}export function renderMeter(t,e){const r=w(t);return`<span class="meter"><span class="meter-dots" aria-hidden="true">${"\u25CF".repeat(r)}${"\u25CB".repeat($-r)}</span><span class="meter-word">${a(e)}</span></span>`}export function renderSeverityMeter(t){const{tier:e,word:r}=h[t];return renderMeter(e,r)}export const severityTier=t=>h[t].tier;export function barCell(t,e,r="",o){const s=o?`;background:${a(o)}`:"";return{html:`<span class="cellbar"><i style="width:${M(t).toFixed(1)}%${s}"></i><span>${a(e)}</span></span>`,className:["barcell",r].filter(Boolean).join(" ")}}export function deltaCell(t){const e=S(t);return{html:a(z(t)),className:["numeric",e?`low-${e}`:""].filter(Boolean).join(" ")}}export function withSectionNav(t,e=""){const r=[];let o=0;const s=t.replace(/<section class="(report-section[^"]*)">(\s*<h2>)(.*?)(<\/h2>)/g,(l,n,i,p,d)=>{const c=`sec-${e}${++o}`;return r.push({id:c,title:p}),`<section class="${n}" id="${c}">${i}${p}${d}`});return r.length<4?t:`<nav class="report-toc" aria-label="Sections">${r.map(l=>`<a href="#${l.id}">${l.title}</a>`).join("")}</nav>
19
- ${s}`}export function formatFindingDelta(t){const e=t.effect.absoluteDelta??0,r=e>0?"+":e<0?"\u2212":"";if(t.variable.kind==="yield"||t.variable.kind==="hardBin"||t.variable.kind==="softBin")return`${r}${Math.abs(e*100).toFixed(1)} pp`;if(t.variable.kind==="test"){if(t.effect.relativeDelta!==void 0&&Number.isFinite(t.effect.relativeDelta)){const o=Math.abs(t.effect.relativeDelta*100).toFixed(1);return`${r}${o}%`}return`${r}${b(Math.abs(e),t.variable.unit)}`}return`${r}${b(Math.abs(e),t.variable.unit)}`}export function derivedFindingsKeyHtml(t){const e=N(t.map(r=>({label:r.variable.label,...A(r.variable)})));return e?`<p class="report-note">${a(e)}</p>`:""}export function findingAnchor(t,e=""){return`finding-${e}`+t.replace(/[^A-Za-z0-9]/g,r=>`_${r.charCodeAt(0).toString(16)}_`)}export function findingsTableHtml(t,e,r,o=!1){const s=v(t),m=[...s.patterns.flatMap(i=>[{f:i.finding,nested:!1},...i.children.map(p=>({f:p,nested:!0}))]),...s.groups.flatMap(i=>i.findings.map(p=>({f:p,nested:!1})))],l=m.length?m.map(({f:i,nested:p})=>`<tr class="tier-${severityTier(i.severity)}${p?" nested":""}${o?" live":""}"${r!==void 0?` id="${findingAnchor(i.id,r)}"`:""}${o?` data-finding="${a(i.id)}"`:""} title="${a(x(i))}${o?`
14
+ </dl>`:""}export function renderTable(t,r,e={}){if(!r.length)return`<p class="no-data">${o(e.emptyMessage??"No data")}</p>`;const a=["report-table",e.className].filter(Boolean).join(" "),l=t.map(s=>`<th>${o(s)}</th>`).join(""),c=s=>typeof s=="string"?`<td>${s}</td>`:`<td${s.className?` class="${s.className}"`:""}>${s.html}</td>`,p=r.map(s=>`<tr>${s.map(c).join("")}</tr>`).join(`
15
+ `);return`<table class="${a}">
16
+ <thead><tr>${l}</tr></thead>
17
+ <tbody>${p}</tbody>
18
+ </table>`}export function renderMeter(t,r){const e=y(t);return`<span class="meter"><span class="meter-dots" aria-hidden="true">${"\u25CF".repeat(e)}${"\u25CB".repeat(w-e)}</span><span class="meter-word">${o(r)}</span></span>`}export function renderSeverityMeter(t){const{tier:r,word:e}=b[t];return renderMeter(r,e)}export const severityTier=t=>b[t].tier;export function barCell(t,r,e="",a){const l=a?`;background:${o(a)}`:"";return{html:`<span class="cellbar"><i style="width:${M(t).toFixed(1)}%${l}"></i><span>${o(r)}</span></span>`,className:["barcell",e].filter(Boolean).join(" ")}}export function deltaCell(t){const r=z(t);return{html:o(j(t)),className:["numeric",r?`low-${r}`:""].filter(Boolean).join(" ")}}export function withSectionNav(t,r=""){const e=[];let a=0;const l=t.replace(/<section class="(report-section[^"]*)"(?: id="([^"]*)")?>(\s*<h2>)(.*?)(<\/h2>)/g,(p,s,i,d,n,g)=>{++a;const m=i??`sec-${r}${a}`;return e.push({id:m,title:n}),`<section class="${s}" id="${m}">${d}${n}${g}`});return e.length<4?t:`<nav class="report-toc" aria-label="Sections">${e.map(p=>`<a href="#${p.id}">${p.title}</a>`).join("")}</nav>
19
+ ${l}`}export function formatFindingDelta(t){const r=t.effect.absoluteDelta??0,e=r>0?"+":r<0?"\u2212":"";if(t.variable.kind==="yield"||t.variable.kind==="hardBin"||t.variable.kind==="softBin")return`${e}${Math.abs(r*100).toFixed(1)} pp`;if(t.variable.kind==="test"){if(t.effect.relativeDelta!==void 0&&Number.isFinite(t.effect.relativeDelta)){const a=Math.abs(t.effect.relativeDelta*100).toFixed(1);return`${e}${a}%`}return`${e}${u(Math.abs(r),t.variable.unit)}`}return`${e}${u(Math.abs(r),t.variable.unit)}`}export function derivedFindingsKeyHtml(t){const r=A(t.map(e=>({label:e.variable.label,...D(e.variable)})));return r?`<p class="report-note">${o(r)}</p>`:""}export function findingAnchor(t,r=""){return`finding-${r}`+t.replace(/[^A-Za-z0-9]/g,e=>`_${e.charCodeAt(0).toString(16)}_`)}export function findingsTableHtml(t,r,e,a=!1){const l=$(t),c=[...l.patterns.flatMap(i=>[{f:i.finding,nested:!1},...i.children.map(d=>({f:d,nested:!0}))]),...l.groups.flatMap(i=>i.findings.map(d=>({f:d,nested:!1})))],p=c.length?c.map(({f:i,nested:d})=>`<tr class="tier-${severityTier(i.severity)}${d?" nested":""}${a?" live":""}"${e!==void 0?` id="${findingAnchor(i.id,e)}"`:""}${a?` data-finding="${o(i.id)}"`:""} title="${o(v(i))}${a?`
20
20
  Click to show it on the map`:""}">
21
21
  <td class="tight">${renderSeverityMeter(i.severity)}</td>
22
- <td class="tight">${a(i.comparison.left)}</td>
23
- <td>${a(j(i.variable.label))}</td>
24
- <td class="numeric">${a(formatFindingDelta(i))}</td>
25
- <td class="numeric">${a(formatFindingCoverage(i,e))}</td>
22
+ <td class="tight">${o(i.comparison.left)}</td>
23
+ <td>${o(T(i.variable.label))}</td>
24
+ <td class="numeric">${o(formatFindingDelta(i))}</td>
25
+ <td class="numeric">${o(formatFindingCoverage(i,r))}</td>
26
26
  </tr>`).join(`
27
27
  `):'<tr><td colspan="5" class="no-data">No significant findings</td></tr>';return`<table class="report-table findings-table compact">
28
28
  <thead>
@@ -31,33 +31,34 @@ Click to show it on the map`:""}">
31
31
  <th>Region</th>
32
32
  <th>Metric</th>
33
33
  <th class="numeric">Delta</th>
34
- <th class="numeric">${e!==void 0?"Wafers":"N (region/rest)"}</th>
34
+ <th class="numeric">${r!==void 0?"Wafers":"N (region/rest)"}</th>
35
35
  </tr>
36
36
  </thead>
37
37
  <tbody>
38
- ${l}
38
+ ${p}
39
39
  </tbody>
40
- </table>${derivedFindingsKeyHtml(t)}`}export function synthesisSectionHtml(t,e,r=""){const o=d=>d.map(c=>c.target&&e.has(c.target.id)?`<a href="#${findingAnchor(c.target.id,r)}">${a(c.text)}</a>`:a(c.text)).join(""),[s,...m]=t.items,l=[...m,...t.also?.items??[]],n=t.also?.more??0,i=s?`<ol class="synthesis-items">
41
- <li class="tier-${s.impact}">${renderMeter(s.impact,y(s.impact))}<span>${o(s.parts)}</span></li>
42
- </ol>`:`<p class="synthesis-none">${a(t.nothing??"Nothing stands out.")}</p>`,p=l.length?`<p class="synthesis-smaller">${a(f)}</p>
40
+ </table>${derivedFindingsKeyHtml(t)}`}export function synthesisSectionHtml(t,r){const e=(n,g)=>{const m=r(g);return m?`<a href="#${o(m)}">${o(n)}</a>`:o(n)},[a,...l]=t.items,c=[...l,...t.also?.items??[]],p=t.also?.more??0,s=a?[e(a.subject,a.target),...a.chips.map(n=>e(n.label,n.target))]:[],i=a?`<ol class="synthesis-items">
41
+ <li class="tier-${a.impact}">${renderMeter(a.impact,k(a.impact))}<span>${o(a.text)}<span class="synthesis-see">See: ${s.join(" \xB7 ")}</span></span></li>
42
+ </ol>`:`<p class="synthesis-none">${o(t.nothing??"Nothing stands out.")}</p>`,d=c.length?`<p class="synthesis-smaller">${o(f)}</p>
43
43
  <ul class="synthesis-more">
44
- ${l.map(d=>`<li>${renderMeter(d.impact,k(d.impact))}<span>${o([d.brief])}</span><span class="synthesis-share">${a(u(d))}</span></li>`).join(`
45
- `)}${n?`
46
- <li class="synthesis-rest"><span></span><span>and ${n} more</span><span></span></li>`:""}
44
+ ${c.map(n=>`<li>${renderMeter(n.impact,S(n.impact))}<span>${e(n.brief,n.target)}</span><span class="synthesis-share">${o(x(n))}</span></li>`).join(`
45
+ `)}${p?`
46
+ <li class="synthesis-rest"><span></span><span>and ${p} more</span><span></span></li>`:""}
47
47
  </ul>`:"";return renderSection("What stands out",`<p class="synthesis-headline">${o(t.headline)}</p>
48
48
  ${i}
49
- ${p}
50
- ${t.watch?`<ul class="synthesis-watch">${t.watch.map(d=>`<li><strong>Watch</strong> ${o(d.parts)}</li>`).join("")}</ul>`:""}
51
- <p class="synthesis-checked">${a(t.checked)}</p>`,"synthesis")}export const LIVE_FINDINGS_SCRIPT=`<script>
49
+ ${d}
50
+ ${t.watch?`<ul class="synthesis-watch">${t.watch.map(n=>`<li><strong>Watch</strong> ${e(n.text,n.target)}</li>`).join("")}</ul>`:""}
51
+ <p class="synthesis-checked">${o(t.checked)}</p>`,"synthesis")}export const LIVE_FINDINGS_SCRIPT=`<script>
52
52
  document.addEventListener('click', function (e) {
53
53
  var row = e.target.closest && e.target.closest('[data-finding]');
54
54
  if (row && window.parent !== window) window.parent.postMessage({ wmapFinding: row.getAttribute('data-finding') }, '*');
55
55
  });
56
- <\/script>`;export function formatFindingCoverage(t,e){return e!==void 0?`${t.stats.sampleSizeLeft}/${e}`:`${t.stats.sampleSizeLeft}/${t.stats.sampleSizeRight}`}export function reportStyles(){return`
56
+ <\/script>`;export function formatFindingCoverage(t,r){return r!==void 0?`${t.stats.sampleSizeLeft}/${r}`:`${t.stats.sampleSizeLeft}/${t.stats.sampleSizeRight}`}export function reportStyles(){return`
57
57
  :root {
58
58
  --report-font: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
59
59
  --report-text: #1f2328;
60
60
  --report-muted: #5c6570;
61
+ --report-link: #0b5cad;
61
62
  --report-subtle: #7a828d;
62
63
  --report-line: #d8dee6;
63
64
  --report-line-strong: #c7ced8;
@@ -71,9 +72,9 @@ document.addEventListener('click', function (e) {
71
72
  --report-tier-medium-edge: #a8741a;
72
73
  --report-tier-low-bg: #edf2f7;
73
74
  --report-tier-low-edge: #5f7f9f;
74
- --report-low-1: ${g(1)};
75
- --report-low-2: ${g(2)};
76
- --report-low-3: ${g(3)};
75
+ --report-low-1: ${h(1)};
76
+ --report-low-2: ${h(2)};
77
+ --report-low-3: ${h(3)};
77
78
  --report-bar: #9db8d3;
78
79
  }
79
80
 
@@ -145,7 +146,8 @@ document.addEventListener('click', function (e) {
145
146
  .synthesis-watch li { margin: 0 0 3px; }
146
147
  .synthesis-watch strong { margin-right: 6px; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--report-muted); }
147
148
  .synthesis-checked, .synthesis-none { color: var(--report-muted); margin: 0; }
148
- .synthesis a { color: inherit; text-decoration: underline dotted; }
149
+ .synthesis a { color: var(--report-link); text-decoration: underline; text-underline-offset: 2px; }
150
+ .synthesis-see { display: block; margin-top: 4px; color: var(--report-muted); }
149
151
 
150
152
  .report-subheading {
151
153
  margin: 14px 0 6px;
@@ -1,14 +1,25 @@
1
1
  import type { LotStatsSummary, StatsSeverity, StatsSummary } from './types.js';
2
- /** What a sentence fragment points at, so a surface can link it to its evidence. */
3
- export interface SynthesisTarget {
2
+ /**
3
+ * What an item shows when it is chosen: a finding (its dies, as the findings list shows them), or a test
4
+ * (its values, with the dies it fails). Every item and every Watch line has one, so a surface can make
5
+ * every row act the same way rather than linking only the items that happen to rest on a finding.
6
+ */
7
+ export type SynthesisTarget = {
4
8
  kind: 'finding';
5
9
  id: string;
6
- }
7
- /** A run of text, optionally linked. Structured, not a string, so the panel can make
8
- * links and the report can make anchors from the same sentence. */
9
- export interface SynthesisPart {
10
- text: string;
11
- target?: SynthesisTarget;
10
+ } | {
11
+ kind: 'test';
12
+ testNumber: number;
13
+ };
14
+ /** One part of an item that can be shown on its own: a fail bin in its region, the pattern, a test on the same dies. */
15
+ export interface SynthesisChip {
16
+ label: string;
17
+ target: SynthesisTarget;
18
+ /** Set for a bin, so a surface can draw the bin's legend colour beside it. */
19
+ bin?: {
20
+ kind: 'hardBin' | 'softBin';
21
+ bin: number;
22
+ };
12
23
  }
13
24
  /** How much of the lot an item costs, in three steps. Drawn as a meter, never as colour alone. */
14
25
  export type ImpactTier = 'high' | 'medium' | 'low';
@@ -20,11 +31,20 @@ export interface SynthesisItem {
20
31
  /** Estimated dies lost to this item (pass-rate shortfall × dies in the region). */
21
32
  diesLost: number;
22
33
  severity: StatsSeverity;
23
- parts: SynthesisPart[];
34
+ /** The item as a sentence. Plain text: what the item shows is `target`, and its parts are `chips`. */
35
+ text: string;
36
+ /** The item in a few words, for the compact list: `Ring 2: hard bin 4 (Short), 62 dies`. */
37
+ brief: string;
38
+ /** What `target` is, as a reader names it: `Ring 4 (edge)`, `W06`, `IP3_DBM`. */
39
+ subject: string;
40
+ /** What choosing the item shows: the finding whose dies it counts, or the test it is about. */
41
+ target: SynthesisTarget;
42
+ /** Its parts that can be shown alone, in the order the sentence names them. Empty for a single-part item. */
43
+ chips: SynthesisChip[];
24
44
  /** The leading finding, then the others that stand on the same dies. */
25
45
  findingIds: string[];
26
- /** The item in a few words, for the compact list: `Ring 2: hard bin 4 (Short), 62 dies`. */
27
- brief: SynthesisPart;
46
+ /** Tests the item names: its own test, or tests whose failing dies lie mostly on its dies. */
47
+ testNumbers: number[];
28
48
  }
29
49
  /**
30
50
  * A signal that costs no dies of its own yet but predicts loss: a trend across the wafers, or a test whose
@@ -32,11 +52,12 @@ export interface SynthesisItem {
32
52
  * Ppk of 0.9 with no failures does not belong on the same axis as 400 failing dies.
33
53
  */
34
54
  export interface SynthesisWatch {
35
- parts: SynthesisPart[];
55
+ text: string;
56
+ target: SynthesisTarget;
36
57
  findingIds: string[];
37
58
  }
38
59
  export interface Synthesis {
39
- headline: SynthesisPart[];
60
+ headline: string;
40
61
  items: SynthesisItem[];
41
62
  /**
42
63
  * Items that clear the floor but not the cap, so nothing material goes unmentioned: the ones named
@@ -62,15 +83,21 @@ export interface SynthesisContext {
62
83
  */
63
84
  passBins?: readonly number[];
64
85
  }
86
+ /**
87
+ * The summary a synthesis is written from. A lot of one wafer is that wafer: the lot's own findings need
88
+ * a signal to recur on two wafers, so on one they are always empty and the lot would read as clean while
89
+ * its only wafer is not. Surfaces resolve an item's finding ids against this summary's findings.
90
+ */
91
+ export declare function synthesisSource(summary: StatsSummary | LotStatsSummary): StatsSummary | LotStatsSummary;
65
92
  /**
66
93
  * The synthesis for a wafer or a lot: a headline, up to three loss items ranked by dies
67
94
  * lost, and a line saying what was compared.
68
95
  */
69
- export declare function buildSynthesis(summary: StatsSummary | LotStatsSummary, ctx?: SynthesisContext): Synthesis;
70
- /** The heading over the compact list of smaller items: the floor is the same one that admits an item at all. */
71
- export declare const SYNTHESIS_SMALLER_HEADING: string;
96
+ export declare function buildSynthesis(input: StatsSummary | LotStatsSummary, ctx?: SynthesisContext): Synthesis;
97
+ /** The heading over the compact list of further items: the floor is the same one that admits an item at all. */
98
+ export declare const SYNTHESIS_ALSO_HEADING: string;
72
99
  /** A compact-list row: the item in a few words, then its share of the analysed dies. Plain text. */
73
100
  export declare const synthesisRowShare: (it: SynthesisItem) => string;
74
- /** A synthesis as plain text, one line per part, for tests and for any surface that is not HTML. */
101
+ /** A synthesis as plain text, one line per item, for tests and for any surface that is not HTML. */
75
102
  export declare function synthesisText(s: Synthesis): string;
76
103
  //# sourceMappingURL=synthesis.d.ts.map
@@ -1,2 +1,2 @@
1
- import{maxOf as C,minOf as P}from"../core/utils.js";import{passBinsLabel as T}from"../core/passBins.js";import{DRIFT_MIN_WAFERS as Y}from"./lotDrift.js";import{plainBinTerms as q}from"../renderer/fmt.js";const G=2,N=1,O=3,W=5,H=.01,X=.02,U=.04,V=.15,J=.4,Q=.5,Z=.1,ee=2,te=new Set(["ring","quadrant","sector","reticle-position","test-site","cluster","edge-arc"]);function ie(e){const n=e.highlight;return"dieKeysByWafer"in n&&n.dieKeysByWafer?Object.values(n.dieKeysByWafer).reduce((i,a)=>i+a.length,0):"dieKeys"in n&&n.dieKeys&&n.dieKeys.length>0?n.dieKeys.length:e.level==="lot"?void 0:e.stats.sampleSizeLeft}function ne(e){const n=e.highlight,i=new Set;if("dieKeysByWafer"in n&&n.dieKeysByWafer)for(const[a,l]of Object.entries(n.dieKeysByWafer))for(const t of l)i.add(`${a}:${t}`);else if("dieKeys"in n&&n.dieKeys)for(const a of n.dieKeys)i.add(a);return i}const h=e=>Math.abs(e.effect.absoluteDelta??0),y=e=>h(e)*(ie(e)??0),I=e=>(e*100).toFixed(1),L=e=>{const n=e.variable.label.replace(/ \(same dies\)$/,"").replace(/^HBin and SBin (\d+)/,"HBin $1").replace(/^(HBin \d+(?: \([^)]*\))?) and SBin .*$/,"$1");return q(n)},g=e=>Math.round(e).toLocaleString("en-GB"),v=(e,n,i=`${n}s`)=>`${e} ${e===1?n:i}`;function M(e){const n=e.comparison.left;return e.comparison.family==="quadrant"&&!/quadrant/i.test(n)?`${n} quadrant`:n}function se(e){const n=e.map((t,s)=>s),i=t=>n[t]===t?t:n[t]=i(n[t]),a=e.map(ne);for(let t=0;t<e.length;t++)for(let s=t+1;s<e.length;s++){const o=a[t].size<=a[s].size?a[t]:a[s],$=o===a[t]?a[s]:a[t];if(o.size===0)continue;let f=0;for(const c of o)$.has(c)&&f++;f>=Q*o.size&&(n[i(t)]=i(s))}const l=new Map;return e.forEach((t,s)=>{const o=i(s);(l.get(o)??l.set(o,[]).get(o)).push(s)}),[...l.values()]}const oe=e=>e.variable.kind==="hardBin"||e.variable.kind==="softBin",F=(e,n)=>e.level===n.level&&e.comparison.family===n.comparison.family&&e.comparison.left===n.comparison.left;function ae(e,n,i){if(!i)return[];const a=t=>n.filter(s=>s.variable.kind===t&&F(s,e)&&s.effect.direction==="higher"&&!(t==="hardBin"&&i.includes(s.variable.bin??NaN)));return(a("hardBin").length>0?a("hardBin"):a("softBin")).filter(t=>t!==e).sort((t,s)=>h(s)-h(t))}function re(e,n,i,a){const l=e.filter(d=>d.variable.kind==="yield"),t=[...l.length>0?l:e].sort((d,p)=>y(p)-y(d))[0],s=e.filter(d=>d!==t),o=[],$=t.level==="lot"&&"waferIndices"in t.highlight?t.highlight.waferIndices?.length:void 0,f=$!==void 0&&i?` on ${$}/${i} wafers`:"",c=oe(t),w=(d,p)=>({text:d,target:{kind:"finding",id:p.id}});o.push(w(M(t),t)),o.push({text:c?"":`: pass rate ${I(h(t))} points below the rest of the wafer${f}`}),c&&o.push({text:": "},w(L(t),t),{text:` ${I(h(t))} points higher than the rest of the wafer${f}`});const b=ae(t,n,a).map(d=>({f:d,share:h(d)/(h(t)||1)})).filter(d=>c||d.share>=Z).slice(0,ee);if(c)for(const{f:d}of b)o.push({text:", "},w(L(d),d),{text:` ${I(h(d))} points higher`});else if(b.length>0){const d=b[0].share>.5&&b[0].share<=1?"mostly ":"";b.forEach(({f:p,share:x},B)=>{const m=x<=1;B===0?o.push({text:`; ${m?d:""}`}):o.push({text:", "}),o.push(w(L(p),p)),o.push({text:B===0?m?` accounts for ${I(h(p))} of those points`:` is ${I(h(p))} points higher`:m?` for ${I(h(p))}`:` ${I(h(p))} points higher`})})}o.push({text:` \u2014 about ${g(y(t))} dies lost`});const S=[...new Set(s.filter(d=>!F(d,t)).map(M))];S.length>0&&o.push({text:` (also seen as ${S.join(", ")})`});const _=c?L(t):"pass rate";return{impact:"low",shareOfDies:0,diesLost:y(t),severity:t.severity,parts:o,findingIds:[t.id,...s.map(d=>d.id)],brief:{text:`${M(t)}: ${_}, ${g(y(t))} dies`,target:{kind:"finding",id:t.id}}}}function le(e,n){return e>=U||n>=J?"high":e>=X||n>=V?"medium":"low"}function de(e){const n=i=>i.stats.yieldPercent==null?0:i.stats.analyzedDies*(1-i.stats.yieldPercent/100);return e.level==="wafer"?n(e):e.perWafer.reduce((i,a)=>i+n(a.summary),0)}function fe(e){return e.level==="wafer"?e.stats.analyzedDies:e.perWafer.reduce((n,i)=>n+i.summary.stats.analyzedDies,0)}const K=e=>e.id.startsWith("inter-wafer:yield:");function ce(e){const n=[];for(const i of e.findings){if(!K(i)||i.effect.direction!=="lower")continue;const a="waferIndices"in i.highlight?i.highlight.waferIndices?.[0]:void 0,l=a===void 0?void 0:e.perWafer.find(t=>t.waferIndex===a)?.summary.stats.analyzedDies;l!==void 0&&n.push({impact:"low",shareOfDies:0,diesLost:h(i)*l,severity:i.severity,parts:[{text:i.summary.replace(/ percentage points lower than the lot median$/," points below the lot median"),target:{kind:"finding",id:i.id}},{text:` \u2014 about ${g(h(i)*l)} dies lost`}],findingIds:[i.id],brief:{text:`${i.comparison.left}: yield, ${g(h(i)*l)} dies`,target:{kind:"finding",id:i.id}}})}return n}function he(e,n){const i=e.stats,a=[],l=(t,s,o,$,f,c)=>{if(o<=0||$<=0)return;n.add(t);const w=o/$*100;a.push({impact:"low",shareOfDies:0,diesLost:o,severity:"info",parts:[{text:s},{text:` ${f} on ${g(o)} of ${g($)} dies (${w.toFixed(1)}%)`}],findingIds:[],brief:{text:`${s}: ${g(o)} dies ${c}`}})};for(const t of i.testSpecYield??[]){const s=t.failLowDies+t.failHighDies,o=t.failHighDies===0?"is below its low limit":t.failLowDies===0?"is above its high limit":`is outside its limits (${g(t.failLowDies)} low, ${g(t.failHighDies)} high)`;l(t.testNumber,t.label,s,t.totalDies,o,"outside limits")}for(const t of i.functionalYield??[])l(t.testNumber,t.label,t.failDies,t.totalDies,"fails","fail");return a}function pe(e,n){const i=[],a={unusual:0,notable:1,info:2},l=e.findings.filter(s=>s.id.startsWith("drift:")).sort((s,o)=>a[s.severity]-a[o.severity]||(s.stats.adjustedPValue??1)-(o.stats.adjustedPValue??1));for(const s of l){const o=s.variable.label;i.push({parts:[{text:o,target:{kind:"finding",id:s.id}},{text:s.summary.slice(o.length)}],findingIds:[s.id]})}const t=(e.stats.capability??[]).filter(s=>s.hasSpec&&s.ppk!==null&&s.ppk!==void 0&&s.ppk<N&&!n.has(s.testNumber)).sort((s,o)=>(s.ppk??0)-(o.ppk??0));for(const s of t)i.push({parts:[{text:`${s.label} has Ppk ${s.ppk.toFixed(2)} against its limits (below ${N.toFixed(1)})`}],findingIds:[]});return i.slice(0,G)}function ue(e,n){const i=n.passBins&&n.passBins.length>0?`; pass ${T([n.passBins])}`:"";if(e.level==="wafer"){const f=e.stats.yieldPercent;return f==null?[{text:`${g(e.stats.totalDies)} dies, no bin data to judge yield by.`}]:[{text:`Yield ${f.toFixed(1)}% (${g(e.stats.totalDies)} dies${i}).`}]}const a=e.lotYieldSeries.map(f=>f.yieldPercent).filter(f=>typeof f=="number");if(a.length===0)return[{text:`${v(e.stats.waferCount,"wafer")}, no bin data to judge yield by.`}];const l=a.reduce((f,c)=>f+c,0)/a.length,t=e.perWafer.reduce((f,c)=>f+c.summary.stats.totalDies,0),[s,o]=[P(a).toFixed(1),C(a).toFixed(1)],$=s!==o?`, range ${s}\u2013${o}%`:"";return[{text:`Yield ${l.toFixed(1)}% (mean of ${v(a.length,"wafer")}, ${g(t)} dies${i})${$}.`}]}function ge(e,n){const i=[],a=e.level==="wafer"?e.stats.testsConsidered.length:new Set(e.perWafer.flatMap(o=>o.summary.stats.testsConsidered)).size,l=e.level==="wafer"?e.stats.hardBinsConsidered.length:new Set(e.perWafer.flatMap(o=>o.summary.stats.hardBinsConsidered)).size;if(a>0&&i.push(v(a,"test")),l>0&&i.push(v(l,"hard bin")),i.push("the ring, quadrant and sector regions"),e.level==="lot"&&e.stats.waferCount>=3){const o=e.findings.filter(K);i.push(o.length===0?"wafer-to-wafer yield (no outlier wafers)":`wafer-to-wafer yield (${v(o.length,"outlier wafer")})`),e.stats.waferCount>=Y&&i.push("the yield trend across the wafers (input order)")}const t=e.findings.filter(o=>!n.has(o.id)).length,s=t>0?` ${v(t,"smaller finding")} not listed above.`:" Nothing else was found.";return`Compared: ${i.join(", ")}.${s}`}export function buildSynthesis(e,n={}){const i=e.findings,a=e.level==="lot"?e.stats.waferCount:void 0,l=n.passBins,t=new Map(i.map(r=>[r.id,r])),s=r=>l!==void 0&&(r.variable.kind==="hardBin"?!l.includes(r.variable.bin??NaN):r.variable.kind==="softBin"),o=i.filter(r=>te.has(r.comparison.family)&&y(r)>0&&(r.variable.kind==="yield"&&r.effect.direction==="lower"||s(r)&&r.effect.direction==="higher")),f=o.some(r=>r.variable.kind==="hardBin")?o.filter(r=>r.variable.kind!=="softBin"):o,c=[],w=new Set;for(const r of se(f))c.push(re(r.map(u=>f[u]),i,a,l));for(const r of i.filter(u=>u.variable.kind==="spatialPattern")){const u=new Set((r.relatedIds??[]).filter(k=>t.has(k))),D=c.find(k=>k.findingIds.some(z=>u.has(z)));if(!D)continue;const A=r.level==="lot"&&"waferIndices"in r.highlight?r.highlight.waferIndices?.length:void 0,j=A!==void 0&&a?` on ${A}/${a} wafers`:"";D.parts.unshift({text:`${r.variable.label} pattern${j}. `,target:{kind:"finding",id:r.id}}),D.findingIds.unshift(r.id,...[...u].filter(k=>!D.findingIds.includes(k)))}e.level==="lot"&&c.push(...ce(e));const b=new Set;c.push(...he(e,b));const S=fe(e),_=de(e),d=c.filter(r=>S>0&&r.diesLost/S>=H);for(const r of d)r.shareOfDies=r.diesLost/S,r.impact=le(r.diesLost/S,_>0?r.diesLost/_:0);d.sort((r,u)=>u.diesLost-r.diesLost);const p=d.slice(0,O),x=d.slice(O);for(const r of[...p,...x])for(const u of r.findingIds)w.add(u);const B=x.length>0?{items:x.slice(0,W),more:Math.max(0,x.length-W)}:void 0,m=pe(e,b);for(const r of m)for(const u of r.findingIds)w.add(u);const R=e.level==="lot"?"region, fail bin or wafer":"region or fail bin",E=p.length===0?`Nothing stands out: no ${R} costs as much as ${I(H)} yield points.`:void 0;return{headline:ue(e,n),items:p,...B?{also:B}:{},...m.length?{watch:m}:{},...E?{nothing:E}:{},checked:ge(e,w)}}export const SYNTHESIS_SMALLER_HEADING=`Smaller, each costing at least ${(H*100).toFixed(0)}% of the dies`,synthesisRowShare=e=>`${(e.shareOfDies*100).toFixed(1)}%`;export function synthesisText(e){const n=i=>i.map(a=>a.text).join("");return[n(e.headline),...e.nothing?[e.nothing]:[],...e.items.map((i,a)=>`${a+1}. ${n(i.parts)}`),...e.also?[`${SYNTHESIS_SMALLER_HEADING}: ${e.also.items.map(i=>`${i.brief.text} (${synthesisRowShare(i)})`).join("; ")}${e.also.more?`; and ${e.also.more} more`:""}.`]:[],...e.watch?e.watch.map(i=>`Watch: ${n(i.parts)}`):[],e.checked].join(`
1
+ import{maxOf as ee,minOf as te}from"../core/utils.js";import{isPassBin as se,passBinsLabel as ie}from"../core/passBins.js";import{DRIFT_MIN_WAFERS as ne}from"./lotDrift.js";import{plainBinTerms as oe}from"../renderer/fmt.js";const ae=2,T=1,Y=3,q=5,D=.01,re=.02,le=.04,de=.15,ce=.4,fe=.5,he=.1,ue=2,pe=new Set(["ring","quadrant","sector","reticle-position","test-site","cluster","edge-arc"]);function ge(e){const i=e.highlight;return"dieKeysByWafer"in i&&i.dieKeysByWafer?Object.values(i.dieKeysByWafer).reduce((s,o)=>s+o.length,0):"dieKeys"in i&&i.dieKeys&&i.dieKeys.length>0?i.dieKeys.length:e.level==="lot"?void 0:e.stats.sampleSizeLeft}function X(e){const i=e.highlight,s=new Set;if("dieKeysByWafer"in i&&i.dieKeysByWafer)for(const[o,l]of Object.entries(i.dieKeysByWafer))for(const t of l)s.add(`${o}:${t}`);else if("dieKeys"in i&&i.dieKeys)for(const o of i.dieKeys)s.add(o);return s}const $=e=>Math.abs(e.effect.absoluteDelta??0),_=e=>$(e)*(ge(e)??0),v=e=>(e*100).toFixed(1),x=e=>{const i=e.variable.label.replace(/ \(same dies\)$/,"").replace(/^HBin and SBin (\d+)/,"HBin $1").replace(/^(HBin \d+(?: \([^)]*\))?) and SBin .*$/,"$1");return oe(i)},p=e=>Math.round(e).toLocaleString("en-GB"),k=(e,i,s=`${i}s`)=>`${p(e)} ${e===1?i:s}`;function F(e){const i=e.comparison.left;return e.comparison.family==="quadrant"&&!/quadrant/i.test(i)?`${i} quadrant`:i}function $e(e){const i=e.map((t,r)=>r),s=t=>i[t]===t?t:i[t]=s(i[t]),o=e.map(X);for(let t=0;t<e.length;t++)for(let r=t+1;r<e.length;r++){const n=o[t].size<=o[r].size?o[t]:o[r],d=n===o[t]?o[r]:o[t];if(n.size===0)continue;let c=0;for(const h of n)d.has(h)&&c++;c>=fe*n.size&&(i[s(t)]=s(r))}const l=new Map;return e.forEach((t,r)=>{const n=s(r);(l.get(n)??l.set(n,[]).get(n)).push(r)}),[...l.values()]}const G=e=>e.variable.kind==="hardBin"||e.variable.kind==="softBin",P=(e,i)=>e.level===i.level&&e.comparison.family===i.comparison.family&&e.comparison.left===i.comparison.left;function me(e,i,s){const o=t=>i.filter(r=>r.variable.kind===t&&P(r,e)&&r.effect.direction==="higher"&&s(r));return(o("hardBin").length>0?o("hardBin"):o("softBin")).filter(t=>t!==e).sort((t,r)=>$(r)-$(t))}const we={ring:"rings",quadrant:"quadrants",sector:"sectors","edge-arc":"edge arcs",cluster:"clusters","reticle-position":"reticle positions","test-site":"test sites"},be=2;function ye(e){const i=new Map;for(const o of e){const l=o.comparison.family;(i.get(l)??i.set(l,new Set).get(l)).add(F(o))}const s=[];for(const[o,l]of i)l.size<=be?s.push(...l):s.push(`${l.size} ${we[o]??o}`);return s.join(", ")}const Se=e=>e.charAt(0).toUpperCase()+e.slice(1),E=e=>({kind:"finding",id:e.id}),Ie=e=>({label:Se(x(e)),target:E(e),...e.variable.bin!==void 0&&(e.variable.kind==="hardBin"||e.variable.kind==="softBin")?{bin:{kind:e.variable.kind,bin:e.variable.bin}}:{}});function ve(e,i,s,o){const l=[...e].sort((f,y)=>_(y)-_(f))[0],t=e.find(f=>o.isPassRate(f)&&P(f,l))??l,r=e.filter(f=>f!==t),n=t.level==="lot"&&"waferIndices"in t.highlight?t.highlight.waferIndices?.length:void 0,d=n!==void 0&&s?` on ${n}/${s} wafers`:"",c=!o.isPassRate(t),h=t.comparison.family==="sector"?"the other sectors":"the rest of the wafer";let m=c?`${F(t)}: ${x(t)} ${v($(t))} points higher than ${h}${d}`:`${F(t)}: pass rate ${v($(t))} points below ${h}${d}`;const u=me(t,i,o.isFailBin).map(f=>({f,share:$(f)/($(t)||1)})).filter(f=>c||f.share>=he).slice(0,ue);if(c)for(const{f}of u)m+=`, ${x(f)} ${v($(f))} points higher`;else if(u.length>0){const f=u.reduce((I,B)=>I+B.share,0)<=1.000000001,y=f&&u[0].share>.5?"mostly ":"";u.forEach(({f:I},B)=>{m+=B===0?`; ${f?y:""}`:", ",m+=x(I)+(B===0?f?` accounts for ${v($(I))} of those points`:` is ${v($(I))} points higher`:f?` for ${v($(I))}`:` ${v($(I))} points higher`)})}m+=` \u2014 about ${p(_(t))} dies lost`;const g=r.filter(f=>!P(f,t));g.length>0&&(m+=` (also seen as ${ye(g)})`);const b=c?x(t):"pass rate";return{impact:"low",shareOfDies:0,diesLost:_(t),severity:t.severity,text:m,brief:`${F(t)}: ${b}, ${p(_(t))} dies`,subject:F(t),target:E(t),chips:[...c?[t]:[],...u.map(({f})=>f)].map(Ie),findingIds:[t.id,...r.map(f=>f.id)],testNumbers:[]}}function ke(e,i){return e>=le||i>=ce?"high":e>=re||i>=de?"medium":"low"}function Be(e){const i=s=>s.stats.yieldPercent==null?0:s.stats.analyzedDies*(1-s.stats.yieldPercent/100);return e.level==="wafer"?i(e):e.perWafer.reduce((s,o)=>s+i(o.summary),0)}function De(e){return e.level==="wafer"?e.stats.analyzedDies:e.perWafer.reduce((i,s)=>i+s.summary.stats.analyzedDies,0)}const U=e=>e.id.startsWith("inter-wafer:yield:");function _e(e){const i=[];for(const s of e.findings){if(!U(s)||s.effect.direction!=="lower")continue;const o="waferIndices"in s.highlight?s.highlight.waferIndices?.[0]:void 0,l=o===void 0?void 0:e.perWafer.find(t=>t.waferIndex===o)?.summary.stats.analyzedDies;l!==void 0&&i.push({impact:"low",shareOfDies:0,diesLost:$(s)*l,severity:s.severity,text:`${s.summary.replace(/ percentage points lower than the lot median$/," points below the lot median")} \u2014 about ${p($(s)*l)} dies lost`,brief:`${s.comparison.left}: yield, ${p($(s)*l)} dies`,subject:s.comparison.left,target:E(s),chips:[],findingIds:[s.id],testNumbers:[]})}return i}function Me(e,i){if(e.level==="wafer"){const t=e.stats.testFailures?.[i];return t?{keys:new Set(t.dieKeys),lost:t.lostDies}:void 0}const s=new Set;let o=0,l=!1;for(const t of e.perWafer){const r=t.summary.stats.testFailures?.[i];if(r){l=!0,o+=r.lostDies;for(const n of r.dieKeys)s.add(`${t.waferIndex}:${n}`)}}return l?{keys:s,lost:o}:void 0}function Ae(e,i){const s=e.stats,o=[],l=(t,r,n,d,c,h,m=c)=>{if(n<=0||d<=0)return;i.add(t);const u=Me(e,t),g=u?Math.min(u.lost,n):n,b=n-g,f=n/d*100;o.push({testNumber:t,label:r,verb:c,plainVerb:m,failDies:n,passingDies:b,keys:u?.keys,item:{impact:"low",shareOfDies:0,diesLost:g,severity:"info",text:`${r} ${c} on ${p(n)} of ${p(d)} dies (${f.toFixed(1)}%)`+(b>0?`; ${p(b)} of them are binned as passing, so about ${p(g)} dies lost`:""),brief:b>0?`${r}: ${h}, ${p(g)} dies lost`:`${r}: ${p(n)} dies ${h}`,subject:r,target:{kind:"test",testNumber:t},chips:[],findingIds:[],testNumbers:[t]}})};for(const t of s.testSpecYield??[]){const r=t.failHighDies===0?"is below its low limit":t.failLowDies===0?"is above its high limit":`is outside its limits (${p(t.failLowDies)} low, ${p(t.failHighDies)} high)`;l(t.testNumber,t.label,t.failLowDies+t.failHighDies,t.totalDies,r,"outside limits",t.failLowDies>0&&t.failHighDies>0?"is outside its limits":r)}for(const t of s.functionalYield??[])l(t.testNumber,t.label,t.failDies,t.totalDies,"fails","fail");return o}const Le=.5,xe=2,Fe=2;function Ee(e,i,s,o){const l=[],t=new Map;for(const r of e){const n=r.keys;if(o>0&&r.failDies/o<D){l.push(r);continue}let d;if(n&&n.size>0&&o>0)for(const h of i){const m=s.get(h);if(!m||m.size===0)continue;let u=0;for(const b of n)m.has(b)&&u++;const g=u/n.size;g>=Le&&g>=xe*(m.size/o)&&(!d||u>d.inside)&&(d={item:h,inside:u})}if(!d){l.push(r);continue}const c=t.get(d.item)??0;if(c<Fe){const h=d.inside===r.failDies?"all":p(d.inside);d.item.text+=`. ${r.label} ${r.verb} on ${k(r.failDies,"die")}, ${h} of them in ${d.item.subject}`,t.set(d.item,c+1)}d.item.chips.push({label:r.label,target:r.item.target}),d.item.testNumbers.push(r.testNumber)}return l}function He(e,i,s){const o=[],l={unusual:0,notable:1,info:2},t=e.findings.filter(n=>n.id.startsWith("drift:")).sort((n,d)=>l[n.severity]-l[d.severity]||(n.stats.adjustedPValue??1)-(d.stats.adjustedPValue??1));for(const n of t)o.push({text:n.summary,target:E(n),findingIds:[n.id]});for(const n of[...s].sort((d,c)=>c.passingDies-d.passingDies))o.push({text:`${n.label} ${n.plainVerb} on ${p(n.passingDies)} dies binned as passing`,target:n.item.target,findingIds:[]});const r=(e.stats.capability??[]).filter(n=>n.hasSpec&&n.ppk!==null&&n.ppk!==void 0&&n.ppk<T&&!i.has(n.testNumber)).sort((n,d)=>(n.ppk??0)-(d.ppk??0));for(const n of r)o.push({text:`${n.label} has Ppk ${n.ppk.toFixed(2)} against its limits (below ${T.toFixed(1)})`,target:{kind:"test",testNumber:n.testNumber},findingIds:[]});return o.slice(0,ae)}function Ne(e,i){const s=i.passBins&&i.passBins.length>0?`; pass ${ie([i.passBins])}`:"";if(e.level==="wafer"){const c=e.stats.yieldPercent;return c==null?`${p(e.stats.totalDies)} dies, no bin data to judge yield by.`:`Yield ${c.toFixed(1)}% (${p(e.stats.totalDies)} dies${s}).`}const o=e.lotYieldSeries.map(c=>c.yieldPercent).filter(c=>typeof c=="number");if(o.length===0)return`${k(e.stats.waferCount,"wafer")}, no bin data to judge yield by.`;const l=o.reduce((c,h)=>c+h,0)/o.length,t=e.perWafer.reduce((c,h)=>c+h.summary.stats.totalDies,0),[r,n]=[te(o).toFixed(1),ee(o).toFixed(1)],d=r!==n?`, range ${r}\u2013${n}%`:"";return`Yield ${l.toFixed(1)}% (mean of ${k(o.length,"wafer")}, ${p(t)} dies${s})${d}.`}function We(e,i){const s=[],o=e.level==="wafer"?e.stats.testsConsidered.length:new Set(e.perWafer.flatMap(n=>n.summary.stats.testsConsidered)).size,l=e.level==="wafer"?e.stats.hardBinsConsidered.length:new Set(e.perWafer.flatMap(n=>n.summary.stats.hardBinsConsidered)).size;if(o>0&&s.push(k(o,"test")),l>0&&s.push(k(l,"hard bin")),s.push("the ring, quadrant and sector regions"),e.level==="lot"&&e.stats.waferCount>=3){const n=e.findings.filter(U);s.push(n.length===0?"wafer-to-wafer yield (no outlier wafers)":`wafer-to-wafer yield (${k(n.length,"outlier wafer")})`),e.stats.waferCount>=ne&&s.push("the yield trend across the wafers (input order)")}const t=e.findings.filter(n=>!i.has(n.id)).length,r=t>0?` ${k(t,"smaller finding")} not listed above.`:" Nothing else was found.";return`Compared: ${s.join(", ")}.${r}`}export function synthesisSource(e){return e.level==="lot"&&e.perWafer.length===1?e.perWafer[0].summary:e}export function buildSynthesis(e,i={}){const s=synthesisSource(e),o=s.findings,l=s.level==="lot"?s.stats.waferCount:void 0,t=i.passBins,r=new Map(o.map(a=>[a.id,a])),n=(s.level==="wafer"?[s]:s.perWafer.map(a=>a.summary)).every(a=>(a.stats.hardBinsConsidered??[]).length===0),d=a=>t!==void 0&&G(a)&&se(a.variable.kind,a.variable.bin??NaN,t,!n),c={isPassRate:a=>a.variable.kind==="yield"||t?.length===1&&d(a),isFailBin:a=>t!==void 0&&G(a)&&!d(a)},h=o.filter(a=>pe.has(a.comparison.family)&&_(a)>0&&(c.isPassRate(a)&&a.effect.direction==="lower"||c.isFailBin(a)&&a.effect.direction==="higher")),u=h.some(a=>a.variable.kind==="hardBin")?h.filter(a=>a.variable.kind!=="softBin"):h,g=[],b=new Map,f=new Set;for(const a of $e(u)){const w=a.map(A=>u[A]),S=ve(w,o,l,c);g.push(S);const W=S.target.kind==="finding"?S.target.id:void 0;b.set(S,X(w.find(A=>A.id===W)??w[0]))}for(const a of o.filter(w=>w.variable.kind==="spatialPattern")){const w=new Set((a.relatedIds??[]).filter(L=>r.has(L))),S=g.find(L=>L.findingIds.some(Z=>w.has(Z)));if(!S)continue;const W=a.level==="lot"&&"waferIndices"in a.highlight?a.highlight.waferIndices?.length:void 0,A=W!==void 0&&l?` on ${W}/${l} wafers`:"";S.text=`${a.variable.label} pattern${A}. ${S.text}`,S.chips.unshift({label:`${a.variable.label} pattern`,target:E(a)}),S.findingIds.unshift(a.id,...[...w].filter(L=>!S.findingIds.includes(L)))}const y=De(s),I=new Set,B=Ae(s,I),V=Ee(B,[...g],b,y);s.level==="lot"&&g.push(..._e(s)),g.push(...V.map(a=>a.item));const z=Be(s),H=g.filter(a=>y>0&&a.diesLost/y>=D);for(const a of H)a.shareOfDies=a.diesLost/y,a.impact=ke(a.diesLost/y,z>0?a.diesLost/z:0);H.sort((a,w)=>w.diesLost-a.diesLost);const M=H.slice(0,Y),N=H.slice(Y);for(const a of[...M,...N])for(const w of a.findingIds)f.add(w);const K=N.length>0?{items:N.slice(0,q),more:Math.max(0,N.length-q)}:void 0,J=M[0]?.target.kind==="test"?M[0].target.testNumber:void 0,Q=B.filter(a=>a.testNumber!==J&&y>0&&a.passingDies/y>=D),O=He(s,I,Q);for(const a of O)for(const w of a.findingIds)f.add(w);const j=s.level==="lot"?"region, fail bin or wafer":"region or fail bin",R=o.filter(a=>a.severity==="unusual"&&!f.has(a.id)).length,C=M.length===0?R>0?`No ${j} costs as much as ${v(D)} yield points, though ${k(R,"finding")} below ${R===1?"is":"are"} marked unusual.`:`Nothing stands out: no ${j} costs as much as ${v(D)} yield points.`:void 0;return{headline:Ne(s,i),items:M,...K?{also:K}:{},...O.length?{watch:O}:{},...C?{nothing:C}:{},checked:We(s,f)}}export const SYNTHESIS_ALSO_HEADING=`Also, each costing at least ${(D*100).toFixed(0)}% of the dies`,synthesisRowShare=e=>`${(e.shareOfDies*100).toFixed(1)}%`;export function synthesisText(e){return[e.headline,...e.nothing?[e.nothing]:[],...e.items.map((i,s)=>`${s+1}. ${i.text}`),...e.also?[`${SYNTHESIS_ALSO_HEADING}: ${e.also.items.map(i=>`${i.brief} (${synthesisRowShare(i)})`).join("; ")}${e.also.more?`; and ${e.also.more} more`:""}.`]:[],...e.watch?e.watch.map(i=>`Watch: ${i.text}`):[],e.checked].join(`
2
2
  `)}
@@ -251,6 +251,18 @@ export interface StatsSummary {
251
251
  /** `(passDies / totalDies) × 100` in [0, 100], or `null` when no dies had this test. */
252
252
  yieldPercent: number | null;
253
253
  }>;
254
+ /**
255
+ * The dies each test fails, by test number: outside its limits for a parametric test (the dies
256
+ * `testSpecYield` counts in `failLowDies + failHighDies`), failing for a functional test
257
+ * (`functionalYield`'s `failDies`). `dieKeys` are `getDieKey` strings; `lostDies` is how many of
258
+ * them also fail the wafer's yield (not in a pass bin, or with no bin to judge by), so a test's
259
+ * failures on dies binned as passing are told apart from the yield it costs. Only tests with a
260
+ * failing die are present.
261
+ */
262
+ testFailures?: Record<number, {
263
+ dieKeys: string[];
264
+ lostDies: number;
265
+ }>;
254
266
  /**
255
267
  * Per-test pass rate for each functional (`testType: 'F'`) test — "functional
256
268
  * yield" in fab terms. Verdicts are read via `getTestPassStatus` (recorded