arkaik 0.12.0 → 0.14.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.
@@ -10,9 +10,9 @@
10
10
  *
11
11
  * Usage: node validate-bundle.js <path-to-bundle.json>
12
12
  */
13
- "use strict";var H=require("node:fs"),te=require("node:path");var de=["flow","view","data-model","api-endpoint","acceptance","decision"],ne=["idea","discovery","backlog","development","releasing","live","archived"],ie=["web","ios","android"],me=["composes","calls","displays","queries","covers","supersedes","generates","impacts"],Me={composes:[["flow","view"],["flow","flow"],["view","flow"],["view","view"]],calls:[["view","api-endpoint"],["flow","api-endpoint"],["api-endpoint","api-endpoint"],["api-endpoint","view"]],displays:[["view","data-model"]],queries:[["api-endpoint","data-model"]],covers:[["acceptance","view"],["acceptance","flow"]],supersedes:[["decision","decision"]],generates:[["decision","acceptance"]],impacts:[["decision","flow"],["decision","view"],["decision","data-model"],["decision","api-endpoint"]]};var ce=["saves-time","simplifies","makes-money","reduces-risk","organizes","integrates","connects","reduces-effort","avoids-hassles","reduces-cost","quality","variety","sensory-appeal","informs","reduces-anxiety","rewards-me","nostalgia","design-aesthetics","badge-value","wellness","therapeutic-value","fun-entertainment","attractiveness","provides-access","provides-hope","self-actualization","motivation","heirloom","affiliation-belonging","self-transcendence"],Pe={"saves-time":"functional",simplifies:"functional","makes-money":"functional","reduces-risk":"functional",organizes:"functional",integrates:"functional",connects:"functional","reduces-effort":"functional","avoids-hassles":"functional","reduces-cost":"functional",quality:"functional",variety:"functional","sensory-appeal":"functional",informs:"functional","reduces-anxiety":"emotional","rewards-me":"emotional",nostalgia:"emotional","design-aesthetics":"emotional","badge-value":"emotional",wellness:"emotional","therapeutic-value":"emotional","fun-entertainment":"emotional",attractiveness:"emotional","provides-access":"emotional","provides-hope":"life-changing","self-actualization":"life-changing",motivation:"life-changing",heirloom:"life-changing","affiliation-belonging":"life-changing","self-transcendence":"social-impact"};var Ne={flow:"F-",view:"V-","data-model":"DM-","api-endpoint":"API-",acceptance:"AC-",decision:"DEC-"};var ut=["proposed","approved","enacted","rejected","deprecated","superseded"];function De(e){switch(e){case"proposed":return"discovery";case"approved":return"backlog";case"enacted":return"live";case"rejected":case"deprecated":case"superseded":return"archived"}}function Te(e){let d=e.metadata?.decision_status;return ut.includes(d)?d:"proposed"}var ye={prioritized:"backlog",blocked:"development"};function he(e){return ne.includes(e)?e:ye[e]}var Pt={...ye},Nt={backlog:"idea",...ye};function Oe(e){let d=new Map;for(let t of e){if(t.type!=="screenshot.recorded"&&t.type!=="screenshot.removed"||typeof t.node_id!="string"||typeof t.platform!="string")continue;let r=d.get(t.node_id);r||(r=new Map,d.set(t.node_id,r)),r.set(t.platform,t.type==="screenshot.removed"?null:t)}return d}function Fe(e){let d=t=>typeof t=="string"?t:"";return[...e].sort((t,r)=>{let u=d(t.ts),y=d(r.ts);if(u<y)return-1;if(u>y)return 1;let S=d(t.id),x=d(r.id);return S<x?-1:S>x?1:0})}function we(e){let d=[],t=[];return e.split(/\r?\n/).forEach((u,y)=>{let S=y+1;if(u.trim()==="")return;let x;try{x=JSON.parse(u)}catch(G){t.push({line:S,rule:"journal-line-parse",message:`Line ${S}: not valid JSON \u2014 ${G.message}`,severity:"error"});return}if(typeof x!="object"||x===null||Array.isArray(x)){t.push({line:S,rule:"journal-line-shape",message:`Line ${S}: each journal line must be a single JSON event object.`,severity:"error"});return}let M=x,I=[];if(typeof M.id!="string"&&I.push("id"),typeof M.ts!="string"&&I.push("ts"),typeof M.type!="string"&&I.push("type"),I.length>0){t.push({line:S,rule:"journal-line-shape",message:`Line ${S}: event is missing required envelope field(s): ${I.join(", ")}.`,severity:"error"});return}d.push(M)}),{events:d,findings:t}}var ft={"node.updated":["node_id"],"node.status_changed":["node_id"],"decision.status_changed":["node_id"],"node.deleted":["node_id"],"edge.added":["source_id","target_id"],"ref.added":["node_id"],"ref.removed":["node_id"],"ref.status_changed":["node_id"],"screenshot.recorded":["node_id"],"screenshot.removed":["node_id"],"idea.proposed":["node_id"],"request.filed":["node_id"]};function Le(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function pt(e,d){return e===d?!0:typeof d!="string"?!1:e==="backlog"&&d==="idea"?!0:(he(e)??e)===(he(d)??d)}function Ce(e){let d=[],t=e.journal;if(t===void 0)return d;if(!Array.isArray(t))return d.push({path:"journal",rule:"journal-shape",message:"journal must be an array of events when present.",severity:"error"}),d;if(t.length===0)return d;let r=i=>typeof i=="string"?i:void 0,u=Array.isArray(e.nodes)?e.nodes:[],y=Array.isArray(e.edges)?e.edges:[],S=new Map,x=new Map;for(let i of u){let c=r(i?.id);if(c!==void 0){S.set(c,i.status);let _=i.metadata,h=_&&typeof _=="object"&&!Array.isArray(_)?_.decision_status:void 0;x.set(c,h??"proposed")}}let M=new Set;for(let i of y){let c=r(i?.id);c!==void 0&&M.add(c)}let I=[];t.forEach((i,c)=>{let _=`journal[${c}]`;if(typeof i!="object"||i===null||Array.isArray(i)){d.push({path:_,rule:"journal-event-shape",message:`journal[${c}]: each event must be a JSON object.`,severity:"error"});return}let h=i,$=[];if(r(h.id)===void 0&&$.push("id"),r(h.ts)===void 0&&$.push("ts"),r(h.type)===void 0&&$.push("type"),$.length>0){d.push({path:_,rule:"journal-event-envelope",message:`journal[${c}]: event is missing required envelope field(s): ${$.join(", ")}.`,severity:"error"});return}I.push({ev:h,index:c})});let G=new Set(S.keys()),R=new Set(M),C=new Set;for(let{ev:i}of I)if(i.type==="node.created"){let c=r(i.node_id);c&&G.add(c)}else if(i.type==="edge.added"){let c=r(i.edge_id);c&&R.add(c)}else if(i.type==="journal.baseline"&&Array.isArray(i.node_ids))for(let c of i.node_ids){let _=r(c);_&&(C.add(_),G.add(_))}let W=Fe(I.map(i=>i.ev)),q=new Set,K=new Map,s=new Map;for(let i of W)if(i.type==="node.created"){let c=r(i.node_id);c&&q.add(c)}else if(i.type==="node.status_changed"){let c=r(i.node_id);if(c&&i.platform===void 0){let _=r(i.to);_!==void 0&&K.set(c,_)}}else if(i.type==="decision.status_changed"){let c=r(i.node_id);if(c){let _=r(i.to);_!==void 0&&s.set(c,_)}}for(let{ev:i,index:c}of I){let _=ft[i.type];if(_)for(let h of _){let $=r(i[h]);$!==void 0&&!G.has($)&&d.push({path:`journal[${c}].${h}`,rule:"journal-dangling-node-ref",message:`journal[${c}] (${i.type}): references node "${$}" that never existed in the snapshot or journal.`,severity:"error"})}if(i.type==="deliverable.shipped"&&Array.isArray(i.node_ids)&&i.node_ids.forEach((h,$)=>{let E=r(h);E!==void 0&&!G.has(E)&&d.push({path:`journal[${c}].node_ids[${$}]`,rule:"journal-dangling-node-ref",message:`journal[${c}] (${i.type}): references node "${E}" that never existed in the snapshot or journal.`,severity:"error"})}),i.type==="edge.removed"){let h=r(i.edge_id);h!==void 0&&!R.has(h)&&d.push({path:`journal[${c}].edge_id`,rule:"journal-dangling-edge-ref",message:`journal[${c}] (edge.removed): references edge "${h}" that never existed in the snapshot or journal.`,severity:"error"})}}for(let[i,c]of S){!q.has(i)&&!C.has(i)&&d.push({path:"journal",rule:"journal-missing-node-created",message:`Node "${i}" is present in the snapshot but has no node.created event in the journal.`,severity:"error"});let _=K.get(i);_!==void 0&&!pt(_,c)&&d.push({path:"journal",rule:"journal-status-mismatch",message:`Node "${i}": journal's last node.status_changed.to "${_}" disagrees with snapshot status "${String(c)}".`,severity:"error"})}for(let[i,c]of s){if(!x.has(i))continue;let _=x.get(i)??"proposed";c!==_&&d.push({path:"journal",rule:"journal-decision-status-mismatch",message:`Node "${i}": journal's last decision.status_changed.to "${c}" disagrees with snapshot decision_status "${String(_)}".`,severity:"error"})}let D=Oe(W);return u.forEach((i,c)=>{let _=r(i?.id);if(_===void 0)return;let h=Le(i.metadata)?i.metadata:{},$=Le(h.platformScreenshots)?h.platformScreenshots:{},E=D.get(_),Y=new Set([...Object.keys($),...E?E.keys():[]]);for(let U of Y){let T=E?.get(U);if(T===void 0)continue;let Q=typeof $[U]=="string"?$[U]:void 0,j,X;if(T===null)X=Q===void 0,j="it was removed";else if(T.form==="data")X=Q!==void 0,j="a data URI was recorded";else{let Z=r(T.url);X=Q===Z,j=Z===void 0?"an unknown value was recorded":`"${Z}" was recorded`}X||d.push({path:`nodes[${c}].metadata.platformScreenshots.${U}`,rule:"screenshot-untracked",message:`Node "${_}": platformScreenshots.${U} is ${Q===void 0?"empty":`"${Q}"`} but the journal's last screenshot event says ${j} \u2014 write screenshots through record_screenshot, not update_node.`,severity:"warning"})}}),d}var We=["flow","view","acceptance"];function Je(e){let d=e?.metadata?.products;if(!Array.isArray(d))return[];let t=new Set,r=[];for(let u of d){if(typeof u!="object"||u===null||Array.isArray(u))continue;let y=u;typeof y.id!="string"||y.id.trim()===""||t.has(y.id)||(t.add(y.id),r.push(y))}return r}var Ve=["rings","bars"],Ge=["chips","rows"],qe=["status","species"];var gt=["journey","system","screens"];function Ue(e){return gt.includes(e)}var le="cross-surface";var _e=["human","agent","rule"],Ke=["human","agent"];var Be="weighing.assessment.recorded",Qe="weighing.set.saved";function mt(e,d,t){return`${e}\0${d}\0${t}`}function ze(e){let d=typeof e?.scorer?.kind=="string"?e.scorer.kind:"";return`${mt(String(e?.matrix),String(e?.subject),String(e?.criterion))}\0${d}`}var yt=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function He(e){return yt(e)&&typeof e.matrix=="string"&&typeof e.subject=="string"&&typeof e.criterion=="string"}function ue(e){let d=e.lastIndexOf("@");return d===-1?{id:e,major:void 0}:{id:e.slice(0,d),major:e.slice(d+1)}}function se(e){let d=/^(\d+)(?:\.|$)/.exec(e);return d?d[1]:void 0}function ve(e){if(typeof e=="object"&&e!==null&&!Object.isFrozen(e)){Object.freeze(e);for(let d of Object.values(e))ve(d)}return e}var Ze="value-contribution",ht="1.0.0",wt="value",re="positioning",_t={3:"Core. The promise exists for this; take it away and the value goes.",2:"Supports clearly. The user would notice it missing.",1:"Touches. A side effect of the promise, not its purpose.",0:"Unrelated: weighed and found to have nothing to do with it. (No row means nobody has weighed it yet.)","-1":"Small friction. It costs this value a little.","-2":"Works against it. The user notices the cost.","-3":"Costs it at its core. The user feels the opposite."},Ye={functional:"Functional",emotional:"Emotional","life-changing":"Life-changing","social-impact":"Social impact"},Se={"saves-time":{name:"Saves time",definition:"Completes the user's task in less time."},simplifies:{name:"Simplifies",definition:"Reduces steps, choices, or cognitive load."},"makes-money":{name:"Makes money",definition:"Helps the user earn."},"reduces-risk":{name:"Reduces risk",definition:"Protects against loss, error, or uncertainty."},organizes:{name:"Organizes",definition:"Brings order to the user's things or life."},integrates:{name:"Integrates",definition:"Ties different tools or parts of life together."},connects:{name:"Connects",definition:"Brings the user together with other people."},"reduces-effort":{name:"Reduces effort",definition:"Same outcome, less work."},"avoids-hassles":{name:"Avoids hassles",definition:"Prevents friction and annoyance before it happens."},"reduces-cost":{name:"Reduces cost",definition:"Saves the user money."},quality:{name:"Quality",definition:"Superior craft or performance the user can feel."},variety:{name:"Variety",definition:"Meaningful choice and breadth."},"sensory-appeal":{name:"Sensory appeal",definition:"Looks, sounds, or feels good in the moment."},informs:{name:"Informs",definition:"Tells the user something they want to know."},"reduces-anxiety":{name:"Reduces anxiety",definition:"Calms; makes the user feel safe."},"rewards-me":{name:"Rewards me",definition:"Tangible perks for engagement."},nostalgia:{name:"Nostalgia",definition:"Positive memory of the past."},"design-aesthetics":{name:"Design / aesthetics",definition:"Beauty as an experienced value, beyond function."},"badge-value":{name:"Badge value",definition:"Signals identity or status to others."},wellness:{name:"Wellness",definition:"Improves physical or mental well-being."},"therapeutic-value":{name:"Therapeutic value",definition:"Actively supports emotional processing or healing."},"fun-entertainment":{name:"Fun / entertainment",definition:"Enjoyable, playful, delightful."},attractiveness:{name:"Attractiveness",definition:"Makes the user feel attractive."},"provides-access":{name:"Provides access",definition:"Grants entry to something otherwise out of reach."},"provides-hope":{name:"Provides hope",definition:"Reason to believe things can improve."},"self-actualization":{name:"Self-actualization",definition:"Helps the user become who they want to be."},motivation:{name:"Motivation",definition:"Energizes the user toward their goals."},heirloom:{name:"Heirloom",definition:"Something worth passing on across time."},"affiliation-belonging":{name:"Affiliation & belonging",definition:"Makes the user part of a group that matters."},"self-transcendence":{name:"Self-transcendence",definition:"Helps beyond the user themselves."}},et={min:-3,max:3,anchors:{..._t}},St=ve({id:Ze,version:ht,title:"Elements of value",subject:"acceptance",scale:et,groups:Object.keys(Ye).map(e=>({id:e,title:Ye[e]})),criteria:ce.map(e=>({id:e,group:Pe[e],name:Se[e].name,question:`Does this promise serve, or cost, "${Se[e].name}"?`,definition:Se[e].definition}))}),vt=ve({id:wt,title:"Value",set:`${Ze}@1`,subjects:{kind:"query",species:"acceptance"},positioning:re,status:"active"}),be=[St],$e=[vt],ee=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function bt(e){let d=e.criteria.filter(t=>ee(t)&&typeof t.id=="string");return d.length===e.criteria.length?e:{...e,criteria:d}}function ke(e){return ee(e)&&typeof e.id=="string"&&typeof e.version=="string"&&Array.isArray(e.criteria)&&(ee(e.scale)||e.role==="positioning")}function xe(e){if(!ee(e)||typeof e.id!="string"||typeof e.set!="string"||!ee(e.subjects))return!1;let{kind:d,species:t,items:r}=e.subjects;return d==="query"&&typeof t=="string"||d==="list"&&Array.isArray(r)}function Xe(e){return ee(e)&&typeof e.min=="number"&&typeof e.max=="number"&&ee(e.anchors)}function tt(e,d){if(Xe(e.scale))return e.scale;let t=typeof e.extends=="string"&&d!==void 0?fe(d,e.extends):void 0;return t!==void 0&&Xe(t.scale)?t.scale:et}function nt(e){let d=[...be],t=[...$e],r=[],u=y=>ee(y)?{...typeof y.id=="string"?{id:y.id}:{},...typeof y.role=="string"?{role:y.role}:{}}:{};return(Array.isArray(e?.sets)?e.sets:[]).forEach((y,S)=>{ke(y)&&!d.some(x=>x.id===y.id)?d.push(bt(y)):r.push({kind:"set",...u(y),index:S})}),(Array.isArray(e?.matrices)?e.matrices:[]).forEach((y,S)=>{xe(y)&&!t.some(x=>x.id===y.id)?t.push(y):r.push({kind:"matrix",...u(y),index:S})}),{sets:d,matrices:t,skipped:r}}function fe(e,d){let{id:t,major:r}=ue(d),u=e.sets.find(y=>y.id===t);if(u!==void 0)return r===void 0||se(u.version)===r?u:void 0}var z=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function it(e,d,t){let r=[],u=(y,S,x)=>r.push({path:y,rule:S,message:x});if(e!=null&&!z(e)&&u("weighing","weighing-section-shape","The weighing section is not an object \u2014 it is ignored"),z(e)){for(let s of["sets","matrices","assessments"])e[s]!==void 0&&!Array.isArray(e[s])&&u(`weighing.${s}`,"weighing-section-shape",`weighing.${s} is not an array \u2014 it is ignored`);let y=Array.isArray(e.sets)?e.sets:[],S=Array.isArray(e.matrices)?e.matrices:[],x=Array.isArray(e.assessments)?e.assessments:[],M=nt(e),I=(s,D,i,c)=>{let _=fe(M,s);if(_!==void 0)return _;let h=M.sets.find($=>$.id===ue(s).id);h!==void 0?u(D,"weighing-set-ref-major",`${i} names ${s}, but "${h.id}" is at ${h.version} \u2014 levels are comparable only within a major, so the ref resolves to nothing`):u(D,c,`${i} names set "${s}", which is neither built in nor in this section`)},G=new Set(M.matrices.map(s=>s.positioning).filter(s=>typeof s=="string")),R=(s,D,i)=>{i.status!==void 0&&i.status!=="draft"&&i.status!=="active"&&u(`${s}.status`,"weighing-set-status",`${D}: status ${JSON.stringify(i.status)} is not "draft" or "active" \u2014 it is read as a draft, which feeds no roll-up`)},C=s=>z(s)&&Object.values(s).every(D=>typeof D=="string"),W=new Set;y.forEach((s,D)=>{let i=`weighing.sets[${D}]`;if(!z(s)){u(i,"weighing-set-shape","A set is not an object \u2014 it is ignored");return}let c=`Set "${String(s.id)}"`,_=ke(s);if(_||u(i,"weighing-set-shape",`${c} needs a string id and version, a criteria array and a scale object (a positioning may leave the scale out) \u2014 it is ignored`),typeof s.id=="string"&&(be.some(h=>h.id===s.id)?u(`${i}.id`,"weighing-pinned-set-redefined",`${c} is built in and pinned by version \u2014 the project's copy is ignored`):_&&(W.has(s.id)&&u(`${i}.id`,"weighing-duplicate-set",`Duplicate set id "${s.id}" \u2014 the first well-formed one wins, this one is ignored`),W.add(s.id))),R(i,c,s),z(s.scale)){let h=s.scale;(typeof h.min!="number"||typeof h.max!="number"||!C(h.anchors))&&u(`${i}.scale`,"weighing-scale-shape",`${c}: a scale needs a numeric min and max and an anchors object of strings`)}if(Array.isArray(s.criteria)&&s.criteria.forEach((h,$)=>{let E=`${i}.criteria[${$}]`;(!z(h)||typeof h.id!="string"||h.anchors!==void 0&&!C(h.anchors))&&u(E,"weighing-criterion-shape",`${c}: criterion ${$} needs a string id, and its anchors (if any) must be an object of strings`)}),s.role==="positioning"&&!(typeof s.id=="string"&&G.has(s.id))?u(`${i}.id`,"weighing-positioning-id",`A positioning set must have the id "${re}" (the one a matrix points at) \u2014 "${String(s.id)}" would never be applied`):s.role!=="positioning"&&s.id===re&&u(`${i}.role`,"weighing-positioning-id",`Set "${re}" is where a matrix looks for its positioning, but its role is ${JSON.stringify(s.role)}, not "positioning" \u2014 it would never be applied`),s.role==="positioning"){let h=typeof s.extends=="string"?I(s.extends,`${i}.extends`,`Positioning "${String(s.id)}"`,"weighing-positioning-unknown-ruler"):void 0;typeof s.extends!="string"?u(`${i}.extends`,"weighing-positioning-unknown-ruler",`Positioning "${String(s.id)}" does not say which set it re-weights \u2014 set extends to e.g. value-contribution@1`):h!==void 0&&h.role==="positioning"&&u(`${i}.extends`,"weighing-positioning-unknown-ruler",`Positioning "${String(s.id)}" extends "${s.extends}", which is itself a positioning \u2014 it must extend a criteria set such as value-contribution@1`);let $=new Set(h!==void 0&&h.role!=="positioning"?h.criteria.map(E=>E?.id):[]);(Array.isArray(s.criteria)?s.criteria:[]).forEach((E,Y)=>{if(!z(E))return;let U=`${i}.criteria[${Y}]`;$.size>0&&typeof E.id=="string"&&!$.has(E.id)&&u(`${U}.id`,"weighing-positioning-unknown-element",`Positioning names "${E.id}", which is not in ${String(s.extends)}`),E.weight!==void 0&&(typeof E.weight!="number"||!(E.weight>0))&&u(`${U}.weight`,"weighing-positioning-weight",`Positioning weight for "${String(E.id)}" must be a number above 0 \u2014 leave the element out to leave it unpositioned`)})}});let q=new Set;S.forEach((s,D)=>{let i=`weighing.matrices[${D}]`;if(!z(s)){u(i,"weighing-matrix-shape","A matrix is not an object \u2014 it is ignored");return}let c=`Matrix "${String(s.id)}"`,_=xe(s);_||u(i,"weighing-matrix-shape",`${c} needs a string id, a set ref and a subjects object of kind query or list \u2014 it is ignored`),typeof s.id=="string"&&($e.some(h=>h.id===s.id)?u(`${i}.id`,"weighing-pinned-matrix-redefined",`${c} is built in \u2014 the project's copy is ignored`):_&&(q.has(s.id)&&u(`${i}.id`,"weighing-duplicate-matrix",`Duplicate matrix id "${s.id}" \u2014 the first well-formed one wins, this one is ignored`),q.add(s.id))),R(i,c,s),_&&I(s.set,`${i}.set`,c,"weighing-unknown-set")});let K=new Set;x.forEach((s,D)=>{let i=`weighing.assessments[${D}]`,c=`Assessment ${D}`;if(!He(s)){u(i,"weighing-assessment-shape",`${c}: not an object with a string matrix, subject and criterion \u2014 it cannot be addressed, so every reader skips it`);return}(typeof s.ts!="string"||Number.isNaN(Date.parse(s.ts)))&&u(`${i}.ts`,"weighing-assessment-ts",`${c}: ts must be an ISO 8601 string \u2014 without it "latest wins" cannot order this row`);let _=M.matrices.find(j=>j.id===s.matrix);_===void 0&&u(`${i}.matrix`,"weighing-unknown-matrix",`${c}: matrix "${s.matrix}" is not defined`);let h=_===void 0?void 0:fe(M,_.set),$=h?.criteria.find(j=>j?.id===s.criterion);h!==void 0&&$===void 0&&u(`${i}.criterion`,"weighing-unknown-criterion",`${c}: criterion "${s.criterion}" is not in set "${h.id}"`),$!==void 0&&typeof $.superseded_by=="string"&&$.superseded_by!==""&&u(`${i}.criterion`,"weighing-retired-criterion",`${c}: criterion "${$.id}" is retired \u2014 superseded by "${$.superseded_by}"`);let E=h===void 0?void 0:tt(h,M),Y=typeof E?.min=="number"?E.min:-3,U=typeof E?.max=="number"?E.max:3;(typeof s.level!="number"||!Number.isInteger(s.level)||s.level<Y||s.level>U)&&u(`${i}.level`,"weighing-level-range",`${c}: level must be an integer ${Y}..${U} (a blank cell is the absence of the row; 0 means weighed and unrelated)`),[0,1,2,3].includes(s.confidence)||u(`${i}.confidence`,"weighing-confidence-range",`${c}: confidence must be 0, 1, 2 or 3`);let T=z(s.scorer)?s.scorer:void 0;if(T===void 0||typeof T.kind!="string"||typeof T.id!="string"||T.id===""?u(`${i}.scorer`,"weighing-scorer-missing",`${c}: no scorer with a string kind and id \u2014 human, agent and rule levels become indistinguishable, and the row can win no cell`):_e.includes(T.kind)?Ke.includes(T.kind)||u(`${i}.scorer.kind`,"weighing-rule-stored",`${c}: scorer kind "${T.kind}" is never stored \u2014 a seeding rule is computed on read`):u(`${i}.scorer.kind`,"weighing-scorer-kind",`${c}: scorer kind "${T.kind}" is not one of ${_e.join(", ")} \u2014 it ranks below every other scorer`),_?.subjects.kind==="query"){let j=d.get(s.subject);j===void 0?u(`${i}.subject`,"weighing-unknown-subject",`${c}: subject "${s.subject}" is not a node in this bundle`):j!==_.subjects.species&&u(`${i}.subject`,"weighing-subject-species",`${c}: subject "${s.subject}" is a ${j}, and matrix "${_.id}" judges ${String(_.subjects.species)} nodes`)}if(s.evidence!==void 0&&typeof s.evidence!="string"?u(`${i}.evidence`,"weighing-evidence-type",`${c}: evidence must be a markdown string`):(s.confidence===2||s.confidence===3)&&(s.evidence===void 0||s.evidence.trim()==="")&&u(`${i}.evidence`,"weighing-no-evidence",`${c}: confidence ${String(s.confidence)} claims evidence and cites none`),s.refs!==void 0&&!(Array.isArray(s.refs)&&s.refs.every(j=>typeof j=="string"))&&u(`${i}.refs`,"weighing-refs-type",`${c}: refs must be an array of id strings`),s.basis!==void 0&&!(z(s.basis)&&["fingerprint","commit","set_version"].every(j=>s.basis[j]===void 0||typeof s.basis[j]=="string"))&&u(`${i}.basis`,"weighing-basis-shape",`${c}: basis must be an object whose fingerprint, commit and set_version are strings`),T!==void 0&&typeof T.kind=="string"){let j=ze(s);K.has(j)&&u(i,"weighing-duplicate-assessment",`${c}: a second ${T.kind} score for the same cell \u2014 the section stores latest-per-scorer-kind, so this cell is ambiguous`),K.add(j)}let Q=z(s.basis)&&typeof s.basis.set_version=="string"?s.basis.set_version:void 0;h!==void 0&&Q!==void 0&&se(Q)!==se(h.version)&&u(`${i}.basis.set_version`,"weighing-set-major",`${c}: scored against ${h.id} ${Q}, and the set is now ${h.version} \u2014 levels are comparable only within a major`)})}return t.forEach((y,S)=>{if(!z(y))return;let x=typeof y.type=="string"?y.type:"";x!==Be&&x!==Qe||(typeof y.actor!="string"||y.actor.trim()==="")&&u(`journal[${S}].actor`,"weighing-event-no-actor",`Journal event ${S}: ${x} has no actor \u2014 human, agent and CI scores become indistinguishable`)}),r}var $t=["beta","monitoring","deprecated"],st=["compact","large"],rt=2*1024*1024;function kt(e){let d=e.indexOf(",");if(d===-1)return 0;let t=e.slice(d+1),r=t.endsWith("==")?2:t.endsWith("=")?1:0;return Math.floor(t.length*3/4)-r}function ot(e){return typeof e=="string"&&!Number.isNaN(Date.parse(e))}function at(e){let d=[],t=(n,l,o)=>d.push({path:n,rule:l,message:o,severity:"error"}),r=(n,l,o)=>d.push({path:n,rule:l,message:o,severity:"warning"}),u=()=>{let n=d.filter(o=>o.severity==="error"),l=d.filter(o=>o.severity==="warning");return{valid:n.length===0,findings:d,errors:n,warnings:l}};if(typeof e!="object"||e===null||Array.isArray(e))return t("","bundle-shape","Bundle must be an object with project, nodes, and edges."),u();let y=e,S=y.project,x=y.nodes,M=y.edges;if(!S||!x||!M)return t("","bundle-shape","Missing top-level keys (project, nodes, edges)."),u();if(!Array.isArray(x))return t("nodes","bundle-shape","nodes must be an array."),u();if(!Array.isArray(M))return t("edges","bundle-shape","edges must be an array."),u();let I=x,G=M,R=new Map,C=new Set;S.id||t("project.id","project-id-required","project.id is missing"),(typeof S.title!="string"||!S.title.trim())&&t("project.title","title-non-empty","project.title is missing or empty"),S.created_at||t("project.created_at","timestamp-required","project.created_at is missing"),S.updated_at||t("project.updated_at","timestamp-required","project.updated_at is missing"),S.created_at&&!ot(S.created_at)&&r("project.created_at","iso-timestamp","project.created_at is not a valid ISO 8601 timestamp"),S.updated_at&&!ot(S.updated_at)&&r("project.updated_at","iso-timestamp","project.updated_at is not a valid ISO 8601 timestamp");let W=S.metadata;W&&W.view_card_variant!==void 0&&!st.includes(W.view_card_variant)&&t("project.metadata.view_card_variant","view-card-variant",`project.metadata.view_card_variant must be one of ${st.join(", ")} (import rejects other values)`),I.forEach((n,l)=>{let o=`nodes[${l}]`,a=n.id;C.has(a)&&t(`${o}.id`,"duplicate-node-id",`Duplicate node ID: ${a}`),C.add(a),R.set(a,n),(typeof n.title!="string"||!n.title.trim())&&t(`${o}.title`,"title-non-empty",`Node ${a}: title is missing or empty`);let p=n.species,f=Ne[p];f&&!(typeof a=="string"&&a.startsWith(f))&&t(`${o}.id`,"species-prefix",`Node ${a}: species "${p}" should have prefix "${f}"`),de.includes(p)||t(`${o}.species`,"valid-species",`Node ${a}: invalid species "${p}"`),n.project_id!==S.id&&t(`${o}.project_id`,"project-id-match",`Node ${a}: project_id "${n.project_id}" does not match project.id "${S.id}"`),ne.includes(n.status)||t(`${o}.status`,"valid-status",`Node ${a}: invalid status "${n.status}"`);let m=n.platforms;if(!m||m.length===0)p!=="decision"&&t(`${o}.platforms`,"platforms-non-empty",`Node ${a}: platforms array is empty or missing`);else for(let g of m)ie.includes(g)||t(`${o}.platforms`,"valid-platform",`Node ${a}: invalid platform "${g}"`);let w=n.metadata||{};w.stage!==void 0&&!$t.includes(w.stage)&&t(`${o}.metadata.stage`,"valid-stage",`Node ${a}: invalid metadata.stage "${w.stage}"`);let A=w.platformNotes;if(A)for(let g of Object.keys(A))ie.includes(g)||t(`${o}.metadata.platformNotes`,"valid-platform",`Node ${a}: platformNotes has invalid platform "${g}"`);let P=w.platformStatuses;if(P)for(let[g,v]of Object.entries(P))ie.includes(g)?Array.isArray(m)&&!m.includes(g)&&r(`${o}.metadata.platformStatuses`,"platform-statuses-subset",`Node ${a}: platformStatuses covers platform "${g}" not in node.platforms`):t(`${o}.metadata.platformStatuses`,"valid-platform",`Node ${a}: platformStatuses has invalid platform "${g}"`),ne.includes(v)||t(`${o}.metadata.platformStatuses`,"valid-status",`Node ${a}: platformStatuses has invalid status "${v}" for platform "${g}"`);let O=w.platformScreenshots;if(O){for(let[g,v]of Object.entries(O))if(typeof v=="string"&&v.startsWith("data:")){let L=kt(v);L>rt&&r(`${o}.metadata.platformScreenshots`,"screenshot-data-uri-size",`Node ${a}: platformScreenshots.${g} is a ${(L/(1024*1024)).toFixed(1)}MB data URI, above the ${rt/(1024*1024)}MB guidance (docs/spec/bundle-format.md \xA7 Asset Values) \u2014 consider a relative path or hosted URL instead`)}}let F=w.gherkin,B=w.values;if(p==="acceptance"?((typeof F!="string"||!F.trim())&&r(`${o}.metadata.gherkin`,"acceptance-gherkin-missing",`Acceptance ${a}: metadata.gherkin is missing or empty (one Given/When/Then scenario expected)`),(!Array.isArray(B)||B.length===0)&&r(`${o}.metadata.values`,"acceptance-values-missing",`Acceptance ${a}: metadata.values is missing or empty (assign 1-3 value elements)`)):(F!==void 0&&r(`${o}.metadata.gherkin`,"gherkin-species",`Node ${a}: metadata.gherkin is only meaningful on acceptance nodes`),B!==void 0&&r(`${o}.metadata.values`,"values-species",`Node ${a}: metadata.values is only meaningful on acceptance nodes`)),Array.isArray(B))for(let g of B)ce.includes(g)||t(`${o}.metadata.values`,"valid-value",`Node ${a}: invalid value element "${g}"`);let b=w.refs;if(Array.isArray(b)){let g=new Set;b.forEach((v,L)=>{let N=v??{},J=`${o}.metadata.refs[${L}]`,V=N.id;typeof V!="string"||!V.trim()?t(`${J}.id`,"ref-id-required",`Node ${a}: ref is missing an id`):g.has(V)?t(`${J}.id`,"duplicate-ref-id",`Node ${a}: duplicate ref id "${V}"`):g.add(V),(typeof N.url!="string"||!N.url.trim())&&t(`${J}.url`,"ref-url-required",`Node ${a}: ref "${V}" is missing a url`),N.status_mapped!==void 0&&!ne.includes(N.status_mapped)&&t(`${J}.status_mapped`,"valid-status",`Node ${a}: ref "${V}" has invalid status_mapped "${N.status_mapped}"`)})}if(w.decision_status!==void 0&&p!=="decision"&&r(`${o}.metadata.decision_status`,"decision-status-wrong-species",`decision_status is meaningful on decision nodes only; "${a}" is a ${p}.`),p==="decision"){let g=Te({metadata:n.metadata}),v=De(g);n.status!==v&&r(`${o}.status`,"decision-lifecycle-mismatch",`Decision "${a}" is ${g}, whose lifecycle status should be "${v}", but status is "${n.status}" (spec \xA72).`)}if(p==="flow"){let g=w.playlist;!n.metadata||!g||!g.entries?t(`${o}.metadata.playlist`,"flow-playlist-required",`Flow ${a}: missing metadata.playlist.entries`):g.entries.length===0&&r(`${o}.metadata.playlist`,"flow-playlist-empty",`Flow ${a}: playlist is empty`)}});let q=S.root_node_id;q&&!C.has(q)&&t("project.root_node_id","root-node-exists",`project.root_node_id "${q}" does not reference an existing node`);let K=(n,l,o)=>{if(typeof n!="object"||n===null||Array.isArray(n))return;let a=n,p=[["flow_platforms",Ve],["view_platforms",Ge],["minimap_color",qe]];for(let[f,m]of p){let w=a[f];w!==void 0&&(typeof w!="string"||!m.includes(w))&&r(`${l}.${f}`,"map-unknown-display",`${o} sets ${f} to "${String(w)}"; expected one of ${m.join(", ")} (renderers fall back to the default)`)}a.images!==void 0&&typeof a.images!="boolean"&&r(`${l}.images`,"map-unknown-display",`${o} sets images to a non-boolean value (renderers fall back to the default)`)},s=W?.map_display;if(typeof s=="object"&&s!==null&&!Array.isArray(s))for(let[n,l]of Object.entries(s))K(l,`project.metadata.map_display.${n}`,`Map "${n}"`);let D=W?.maps;if(Array.isArray(D)){let n=new Set;D.forEach((l,o)=>{if(typeof l!="object"||l===null||Array.isArray(l))return;let a=l,p=`project.metadata.maps[${o}]`,f=typeof a.id=="string"?a.id:void 0;f!==void 0&&(n.has(f)&&r(`${p}.id`,"map-duplicate-id",`Duplicate map id "${f}"`),n.add(f),Ue(f)&&r(`${p}.id`,"map-shadows-built-in",`Map id "${f}" shadows a built-in map and will be ignored`));let m=a.root_node_id;typeof m=="string"&&!C.has(m)&&r(`${p}.root_node_id`,"map-unknown-root",`Map "${f??o}" anchors on "${m}" which does not reference an existing node`),Array.isArray(a.species)&&a.species.forEach((w,A)=>{typeof w=="string"&&!de.includes(w)&&r(`${p}.species[${A}]`,"map-unknown-species",`Map "${f??o}" filters on unknown species "${w}"`)}),Array.isArray(a.edge_types)&&a.edge_types.forEach((w,A)=>{typeof w=="string"&&!me.includes(w)&&r(`${p}.edge_types[${A}]`,"map-unknown-edge-type",`Map "${f??o}" filters on unknown edge type "${w}"`)}),K(a.display,`${p}.display`,`Map "${f??o}"`)})}let i=W?.products,c=new Set;if(Array.isArray(i)){let n=new Set;i.forEach((l,o)=>{if(typeof l!="object"||l===null||Array.isArray(l))return;let a=l,p=`project.metadata.products[${o}]`,f=typeof a.id=="string"?a.id:void 0;f!==void 0&&(n.has(f)?r(`${p}.id`,"product-duplicate-id",`Duplicate product id "${f}" \u2014 the first wins`):(n.add(f),f.trim()!==""&&c.add(f)),/^[a-z0-9]+(-[a-z0-9]+)*$/.test(f)||r(`${p}.id`,"product-invalid-id",`Product id "${f}" is not kebab-case`))})}let _=c.size>0,h=new Map;for(let n of G){if(n.edge_type!=="covers")continue;let l=typeof n.source_id=="string"?n.source_id:void 0,o=typeof n.target_id=="string"?n.target_id:void 0;if(l===void 0||o===void 0)continue;let a=h.get(l)??[];a.push(o),h.set(l,a)}let $=new Map;if(_)for(let n of Je({metadata:W}))$.set(n.id,new Set(Array.isArray(n.platforms)?n.platforms:[]));let E=new Map,Y=new Map;if(I.forEach((n,l)=>{let o=typeof n.id=="string"?n.id:`#${l}`,a=n.species,p=`nodes[${l}]`;Y.set(o,l);let f=n.metadata??{},m=typeof f.product=="string"?f.product:void 0,w=a!==void 0&&We.includes(a);if(m!==void 0&&!w){let O=de.includes(a)?`${a} membership is derived from consumers and must not be stored`:"metadata.product is only meaningful on flow, view, and acceptance nodes";r(`${p}.metadata.product`,"product-membership-wrong-species",`Node ${o}: ${O}`);return}if(!w)return;if(m===void 0){if(!_)return;a==="acceptance"?h.has(o)||r(`${p}.metadata.product`,"acceptance-product-unassigned",`Acceptance ${o} covers nothing and names no product \u2014 it will show only under "All products"`):r(`${p}.metadata.product`,"unassigned-membership",`Node ${o}: no product membership \u2014 it will show only under "All products"`);return}if(E.set(o,m),!c.has(m)){r(`${p}.metadata.product`,"product-unknown-reference",`Node ${o}: product "${m}" is not declared on the project`);return}let A=$.get(m),P=Array.isArray(n.platforms)?n.platforms:[];if(A)for(let O of P)typeof O=="string"&&!A.has(O)&&r(`${p}.platforms`,"product-platform-not-in-menu",`Node ${o}: platform "${O}" is not in product "${m}"'s menu`)}),_)for(let[n,l]of h){let o=Y.get(n);if(o===void 0)continue;let a=new Set(l.map(p=>E.get(p)).filter(p=>!!p));a.size>1&&r(`nodes[${o}].metadata.product`,"acceptance-covers-span-products",`Acceptance ${n} covers anchors in ${[...a].sort().join(" and ")} \u2014 statuses may conflate products`)}let U=new Set,T=new Set,Q=new Set;G.forEach((n,l)=>{let o=`edges[${l}]`,a=n.id,p=n.source_id,f=n.target_id,m=n.edge_type;U.has(a)&&t(`${o}.id`,"duplicate-edge-id",`Duplicate edge ID: ${a}`),U.add(a);let w=`e-${p}-${f}`;a!==w&&r(`${o}.id`,"edge-id-convention",`Edge ${a}: id does not match convention "${w}" (stale after a rename?)`);let A=`${p}->${f}:${m}`;T.has(A)&&r(`${o}`,"duplicate-edge-relationship",`Duplicate edge relationship: ${A}`),T.add(A),n.project_id!==S.id&&t(`${o}.project_id`,"project-id-match",`Edge ${a}: project_id does not match project.id`),C.has(p)||t(`${o}.source_id`,"dangling-edge",`Edge ${a}: source_id "${p}" not found in nodes`),C.has(f)||t(`${o}.target_id`,"dangling-edge",`Edge ${a}: target_id "${f}" not found in nodes`),me.includes(m)||t(`${o}.edge_type`,"valid-edge-type",`Edge ${a}: invalid edge_type "${m}"`);let P=R.get(p),O=R.get(f),F=Me[m];P&&O&&F&&(F.some(([b,k])=>b===P.species&&k===O.species)||t(`${o}.edge_type`,"edge-semantics",`Edge ${a}: "${m}" not valid from ${P.species} to ${O.species}`)),m==="composes"&&Q.add(`${p}->${f}`)});let j=["view","flow","condition","junction"],X=(n,l,o,a=0)=>{if(!(a>50)){if(!Array.isArray(n)){t(o,"playlist-entry-shape",`Flow ${l}: ${o} must be an array of playlist entries`);return}n.forEach((p,f)=>{let m=`${o}[${f}]`;if(typeof p!="object"||p===null||Array.isArray(p)){t(m,"playlist-entry-shape",`Flow ${l}: ${m} must be a playlist entry object`);return}let w=p,A=w.type;if(typeof A!="string"||!j.includes(A)){t(`${m}.type`,"playlist-entry-shape",`Flow ${l}: ${m}.type must be one of ${j.join(", ")} (got ${JSON.stringify(A)})`);return}if(A==="view")typeof w.view_id!="string"&&t(`${m}.view_id`,"playlist-entry-shape",`Flow ${l}: ${m} is a view entry with no view_id string`);else if(A==="flow")typeof w.flow_id!="string"&&t(`${m}.flow_id`,"playlist-entry-shape",`Flow ${l}: ${m} is a flow entry with no flow_id string`);else if(A==="condition"){typeof w.label!="string"&&t(`${m}.label`,"playlist-entry-shape",`Flow ${l}: ${m} is a condition with no label string`);for(let P of["if_true","if_false"])Array.isArray(w[P])?X(w[P],l,`${m}.${P}`,a+1):t(`${m}.${P}`,"playlist-entry-shape",`Flow ${l}: ${m}.${P} must be an array of playlist entries (both branches are required, use [] for an empty one)`)}else{if(typeof w.label!="string"&&t(`${m}.label`,"playlist-entry-shape",`Flow ${l}: ${m} is a junction with no label string`),!Array.isArray(w.cases)){t(`${m}.cases`,"playlist-entry-shape",`Flow ${l}: ${m}.cases must be an array of junction cases`);return}w.cases.forEach((P,O)=>{let F=`${m}.cases[${O}]`;if(typeof P!="object"||P===null||Array.isArray(P)){t(F,"playlist-entry-shape",`Flow ${l}: ${F} must be a junction case object`);return}let B=P;typeof B.label!="string"&&t(`${F}.label`,"playlist-entry-shape",`Flow ${l}: ${F} has no label string`),Array.isArray(B.entries)?X(B.entries,l,`${F}.entries`,a+1):t(`${F}.entries`,"playlist-entry-shape",`Flow ${l}: ${F}.entries must be an array of playlist entries \u2014 a junction case holds its own entries, not a bare view_id/flow_id`)})}})}};I.forEach((n,l)=>{let o=n.metadata;n.species==="flow"&&o?.playlist?.entries&&X(o.playlist.entries,n.id,`nodes[${l}].metadata.playlist.entries`)});let Z=(n,l,o,a=0)=>{if(a>50)return t(o,"playlist-depth",`Flow ${l}: playlist nesting too deep (possible cycle)`),[];let p=[];if(!Array.isArray(n))return p;for(let f of n)if(!(typeof f!="object"||f===null)){if(f.type==="view")C.has(f.view_id)||t(o,"playlist-ref-exists",`Flow ${l}: playlist references non-existent view "${f.view_id}"`),p.push(f.view_id);else if(f.type==="flow")C.has(f.flow_id)||t(o,"playlist-ref-exists",`Flow ${l}: playlist references non-existent flow "${f.flow_id}"`),f.flow_id===l&&t(o,"playlist-self-cycle",`Flow ${l}: playlist contains itself (direct cycle)`),p.push(f.flow_id);else if(f.type==="condition")f.if_true&&p.push(...Z(f.if_true,l,o,a+1)),f.if_false&&p.push(...Z(f.if_false,l,o,a+1));else if(f.type==="junction"&&f.cases)for(let m of f.cases)p.push(...Z(m.entries||[],l,o,a+1))}return p};I.forEach((n,l)=>{let o=n.metadata;if(n.species==="flow"&&o?.playlist?.entries){let a=`nodes[${l}].metadata.playlist`,p=n.id,f=Z(o.playlist.entries,p,a);for(let m of f)Q.has(`${p}->${m}`)||t(a,"playlist-composes-coherence",`Flow ${p}: playlist references "${m}" but no composes edge exists`)}});let pe=new Map,Ee=new Map;I.forEach((n,l)=>{let o=n.metadata;if(n.species==="flow"&&o?.playlist?.entries){let a=n.id,p=[],f=m=>{if(Array.isArray(m)){for(let w of m)if(!(typeof w!="object"||w===null)&&(w.type==="flow"&&p.push(w.flow_id),w.type==="condition"&&(w.if_true&&f(w.if_true),w.if_false&&f(w.if_false)),w.type==="junction"&&w.cases))for(let A of w.cases)f(A.entries||[])}};f(o.playlist.entries),pe.set(a,p),Ee.set(a,`nodes[${l}].metadata.playlist`)}});let Ae=new Set,ge=new Set,Ie=n=>{if(ge.has(n))return!0;if(Ae.has(n))return!1;Ae.add(n),ge.add(n);for(let l of pe.get(n)||[])if(Ie(l))return t(Ee.get(n)??"","flow-cycle",`Cycle detected: flow "${n}" -> "${l}"`),!0;return ge.delete(n),!1};for(let n of pe.keys())Ie(n);let ae=y.quality;if(typeof ae=="object"&&ae!==null&&!Array.isArray(ae)){let n=ae,l=Array.isArray(n.assessments)?n.assessments:[],o=Array.isArray(n.findings)?n.findings:[],a=typeof n.profile=="object"&&n.profile!==null?n.profile:void 0,p=new Set;Array.isArray(a?.surfaces)&&a.surfaces.forEach((b,k)=>{if(typeof b!="object"||b===null||Array.isArray(b))return;let g=b,v=typeof g.id=="string"?g.id:void 0;v===void 0||v.trim()===""||(p.has(v)&&r(`quality.profile.surfaces[${k}].id`,"quality-duplicate-surface",`Duplicate surface id "${v}" \u2014 the first wins`),p.add(v))}),p.size===0&&(l.length>0||o.length>0)&&r("quality.profile.surfaces","quality-no-surfaces","Quality data is stored but the profile declares no surfaces \u2014 the matrix falls back to the surfaces the assessments name");let f=typeof n.library=="object"&&n.library!==null?n.library:void 0,m=new Set,w=new Map;if(Array.isArray(f?.criteria))for(let b of f.criteria){if(typeof b!="object"||b===null)continue;let k=b;typeof k.id=="string"&&(m.add(k.id),typeof k.superseded_by=="string"&&k.superseded_by!==""&&w.set(k.id,k.superseded_by))}else(l.length>0||o.length>0)&&r("quality.library","quality-library-missing","No criteria pack is embedded \u2014 criterion ids cannot be resolved to domains or weights; the matrix uses a synthesized library");(typeof n.framework_version!="string"||n.framework_version==="")&&r("quality.framework_version","quality-framework-version-missing","Quality section has no framework_version \u2014 scores are not comparable across audits without one");let A=(b,k,g)=>{let v=typeof b.criterion_id=="string"?b.criterion_id:void 0;v!==void 0&&m.size>0&&!m.has(v)&&r(`${k}.criterion_id`,"quality-unknown-criterion",`${g}: criterion "${v}" is not in the pinned library`);let L=v!==void 0?w.get(v):void 0;L!==void 0&&r(`${k}.criterion_id`,"quality-retired-criterion",`${g}: criterion "${v}" is retired \u2014 superseded by "${L}"`);let N=typeof b.surface=="string"?b.surface:void 0;N!==void 0&&N!==le&&p.size>0&&!p.has(N)&&r(`${k}.surface`,"quality-unknown-surface",`${g}: surface "${N}" is not declared in the profile`)},P=new Set;l.forEach((b,k)=>{if(typeof b!="object"||b===null||Array.isArray(b))return;let g=b,v=`quality.assessments[${k}]`,L=`Assessment ${k}`;A(g,v,L);let N=g.level;(typeof N!="number"||!Number.isInteger(N)||N<0||N>4)&&r(`${v}.level`,"quality-level-range",`${L}: level must be an integer 0-4 (N/A is the absence of the row, not a level)`),g.surface===le&&r(`${v}.surface`,"quality-cross-surface-assessment",`${L}: "${le}" is a findings-only lens \u2014 it carries no matrix column, so this score would render nowhere`),(typeof g.evidence!="string"||g.evidence.trim()==="")&&r(`${v}.evidence`,"quality-assessment-no-evidence",`${L}: scored with no evidence \u2014 a score without a citation is an opinion, not an assessment`);let J=typeof g.criterion_id=="string"?g.criterion_id:void 0,V=typeof g.surface=="string"?g.surface:void 0;if(J!==void 0&&V!==void 0){let je=`${J}\0${V}`;P.has(je)&&r(`${v}`,"quality-duplicate-assessment",`${L}: a second score for (${J} x ${V}) \u2014 the section stores latest-per-cell, so this cell is ambiguous`),P.add(je)}});let O=new Set;o.forEach((b,k)=>{if(typeof b!="object"||b===null||Array.isArray(b))return;let g=b,v=`quality.findings[${k}]`,L=`Finding ${k}`;A(g,v,L);let N=typeof g.id=="string"?g.id:void 0;N!==void 0&&(O.has(N)&&r(`${v}.id`,"quality-duplicate-finding-id",`Duplicate finding id "${N}"`),O.add(N));for(let J of["impact","likelihood"]){let V=g[J];(typeof V!="number"||!Number.isInteger(V)||V<1||V>5)&&r(`${v}.${J}`,"quality-risk-range",`${L}: ${J} must be an integer 1-5 \u2014 severity is derived from impact x likelihood`)}for(let J of["severity","priority"])J in g&&r(`${v}.${J}`,"quality-derived-field-stored",`${L}: ${J} is derived from impact, likelihood and cost \u2014 storing it lets it drift from the numbers behind it`);g.status==="accepted-risk"&&(typeof g.detail!="string"||g.detail.trim()==="")&&r(`${v}.detail`,"quality-accepted-risk-no-note",`${L}: accepted-risk with no note \u2014 an accepted risk is a decision and reads like one`)});let F=new Set,B=Array.isArray(y.journal)?y.journal:[];B.forEach(b=>{if(typeof b!="object"||b===null)return;let k=b;k.type==="quality.finding.opened"&&typeof k.finding_id=="string"&&F.add(k.finding_id)}),B.forEach((b,k)=>{if(typeof b!="object"||b===null)return;let g=b,v=typeof g.type=="string"?g.type:"";v.startsWith("quality.")&&((typeof g.actor!="string"||g.actor.trim()==="")&&r(`journal[${k}].actor`,"quality-event-no-actor",`Journal event ${k}: ${v} has no actor \u2014 human, agent and CI scores become indistinguishable`),v==="quality.finding.resolved"&&typeof g.finding_id=="string"&&!F.has(g.finding_id)&&!O.has(g.finding_id)&&r(`journal[${k}].finding_id`,"quality-resolved-never-opened",`Journal event ${k}: resolves finding "${g.finding_id}", which no quality.finding.opened event or stored finding ever declared`),v==="quality.finding.accepted"&&typeof g.finding_id=="string"&&!F.has(g.finding_id)&&!O.has(g.finding_id)&&r(`journal[${k}].finding_id`,"quality-accepted-never-opened",`Journal event ${k}: accepts finding "${g.finding_id}", which no quality.finding.opened event or stored finding ever declared`))})}let ct=y.weighing,lt=Array.isArray(y.journal)?y.journal:[],Re=new Map;for(let[n,l]of R)Re.set(n,String(l.species));for(let n of it(ct,Re,lt))r(n.path,n.rule,n.message);for(let n of Ce(y))d.push(n);return u()}var dt="journal.jsonl",xt="journal";function Et(e){let d=(0,te.join)(e,xt);return(0,H.existsSync)(d)?(0,H.readdirSync)(d).filter(t=>t.startsWith("archive-")&&t.endsWith(".jsonl")).sort().map(t=>(0,te.join)(d,t)):[]}function oe(e,d){return e.filter(t=>t?.species===d).length}function At(){let e=process.argv[2];e||(console.error("Usage: node validate-bundle.js <path-to-bundle.json>"),process.exit(1)),(0,H.existsSync)(e)||(console.error(`File not found: ${e}`),process.exit(1));let d;try{d=JSON.parse((0,H.readFileSync)(e,"utf8"))}catch(R){console.error(`FATAL: Cannot parse JSON \u2014 ${R.message}`),process.exit(1)}let t=d;(typeof t!="object"||t===null||!t.project||!t.nodes||!t.edges)&&(console.error("FATAL: Missing top-level keys (project, nodes, edges)."),process.exit(1));let r=[],u=!1,y=[];if(t.journal===void 0){let R=(0,te.dirname)(e),C=(0,te.join)(R,dt),W=[];if((0,H.existsSync)(C)){let{events:q,findings:K}=we((0,H.readFileSync)(C,"utf8"));for(let s of K)r.push(s.message);u=!0,W.push(...q)}for(let q of Et(R)){let K=(0,te.basename)(q),{events:s,findings:D}=we((0,H.readFileSync)(q,"utf8"));for(let i of D)r.push(`${K} \u2014 ${i.message}`);y.push(K),W.push(...s)}(u||y.length>0)&&(t.journal=W)}let S=Array.isArray(t.nodes)?t.nodes:[],x=Array.isArray(t.edges)?t.edges:[],M=Array.isArray(t.journal)?t.journal:[],I=at(d);if(console.log(`
13
+ "use strict";var z=require("node:fs"),te=require("node:path");var ue=["flow","view","data-model","api-endpoint","acceptance","decision"],ne=["idea","discovery","backlog","development","releasing","live","archived"],re=["web","ios","android"],ye=["composes","calls","displays","queries","covers","supersedes","generates","impacts"],Te={composes:[["flow","view"],["flow","flow"],["view","flow"],["view","view"]],calls:[["view","api-endpoint"],["flow","api-endpoint"],["api-endpoint","api-endpoint"],["api-endpoint","view"]],displays:[["view","data-model"]],queries:[["api-endpoint","data-model"]],covers:[["acceptance","view"],["acceptance","flow"]],supersedes:[["decision","decision"]],generates:[["decision","acceptance"]],impacts:[["decision","flow"],["decision","view"],["decision","data-model"],["decision","api-endpoint"]]};var oe=["saves-time","simplifies","makes-money","reduces-risk","organizes","integrates","connects","reduces-effort","avoids-hassles","reduces-cost","quality","variety","sensory-appeal","informs","reduces-anxiety","rewards-me","nostalgia","design-aesthetics","badge-value","wellness","therapeutic-value","fun-entertainment","attractiveness","provides-access","provides-hope","self-actualization","motivation","heirloom","affiliation-belonging","self-transcendence"],we={"saves-time":"functional",simplifies:"functional","makes-money":"functional","reduces-risk":"functional",organizes:"functional",integrates:"functional",connects:"functional","reduces-effort":"functional","avoids-hassles":"functional","reduces-cost":"functional",quality:"functional",variety:"functional","sensory-appeal":"functional",informs:"functional","reduces-anxiety":"emotional","rewards-me":"emotional",nostalgia:"emotional","design-aesthetics":"emotional","badge-value":"emotional",wellness:"emotional","therapeutic-value":"emotional","fun-entertainment":"emotional",attractiveness:"emotional","provides-access":"emotional","provides-hope":"life-changing","self-actualization":"life-changing",motivation:"life-changing",heirloom:"life-changing","affiliation-belonging":"life-changing","self-transcendence":"social-impact"};var De={flow:"F-",view:"V-","data-model":"DM-","api-endpoint":"API-",acceptance:"AC-",decision:"DEC-"};var ht=["proposed","approved","enacted","rejected","deprecated","superseded"];function Oe(e){switch(e){case"proposed":return"discovery";case"approved":return"backlog";case"enacted":return"live";case"rejected":case"deprecated":case"superseded":return"archived"}}function Ce(e){let o=e.metadata?.decision_status;return ht.includes(o)?o:"proposed"}var ve={prioritized:"backlog",blocked:"development"};function be(e){return ne.includes(e)?e:ve[e]}var Vt={...ve},Ut={backlog:"idea",...ve};function Le(e){let o=new Map;for(let t of e){if(t.type!=="screenshot.recorded"&&t.type!=="screenshot.removed"||typeof t.node_id!="string"||typeof t.platform!="string")continue;let r=o.get(t.node_id);r||(r=new Map,o.set(t.node_id,r)),r.set(t.platform,t.type==="screenshot.removed"?null:t)}return o}function Fe(e){let o=t=>typeof t=="string"?t:"";return[...e].sort((t,r)=>{let l=o(t.ts),m=o(r.ts);if(l<m)return-1;if(l>m)return 1;let b=o(t.id),E=o(r.id);return b<E?-1:b>E?1:0})}function Se(e){let o=[],t=[];return e.split(/\r?\n/).forEach((l,m)=>{let b=m+1;if(l.trim()==="")return;let E;try{E=JSON.parse(l)}catch(U){t.push({line:b,rule:"journal-line-parse",message:`Line ${b}: not valid JSON \u2014 ${U.message}`,severity:"error"});return}if(typeof E!="object"||E===null||Array.isArray(E)){t.push({line:b,rule:"journal-line-shape",message:`Line ${b}: each journal line must be a single JSON event object.`,severity:"error"});return}let R=E,j=[];if(typeof R.id!="string"&&j.push("id"),typeof R.ts!="string"&&j.push("ts"),typeof R.type!="string"&&j.push("type"),j.length>0){t.push({line:b,rule:"journal-line-shape",message:`Line ${b}: event is missing required envelope field(s): ${j.join(", ")}.`,severity:"error"});return}o.push(R)}),{events:o,findings:t}}var yt={"node.updated":["node_id"],"node.status_changed":["node_id"],"decision.status_changed":["node_id"],"node.deleted":["node_id"],"edge.added":["source_id","target_id"],"ref.added":["node_id"],"ref.removed":["node_id"],"ref.status_changed":["node_id"],"screenshot.recorded":["node_id"],"screenshot.removed":["node_id"],"idea.proposed":["node_id"],"request.filed":["node_id"]};function We(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function wt(e,o){return e===o?!0:typeof o!="string"?!1:e==="backlog"&&o==="idea"?!0:(be(e)??e)===(be(o)??o)}function Ge(e){let o=[],t=e.journal;if(t===void 0)return o;if(!Array.isArray(t))return o.push({path:"journal",rule:"journal-shape",message:"journal must be an array of events when present.",severity:"error"}),o;if(t.length===0)return o;let r=i=>typeof i=="string"?i:void 0,l=Array.isArray(e.nodes)?e.nodes:[],m=Array.isArray(e.edges)?e.edges:[],b=new Map,E=new Map;for(let i of l){let c=r(i?.id);if(c!==void 0){b.set(c,i.status);let v=i.metadata,h=v&&typeof v=="object"&&!Array.isArray(v)?v.decision_status:void 0;E.set(c,h??"proposed")}}let R=new Set;for(let i of m){let c=r(i?.id);c!==void 0&&R.add(c)}let j=[];t.forEach((i,c)=>{let v=`journal[${c}]`;if(typeof i!="object"||i===null||Array.isArray(i)){o.push({path:v,rule:"journal-event-shape",message:`journal[${c}]: each event must be a JSON object.`,severity:"error"});return}let h=i,$=[];if(r(h.id)===void 0&&$.push("id"),r(h.ts)===void 0&&$.push("ts"),r(h.type)===void 0&&$.push("type"),$.length>0){o.push({path:v,rule:"journal-event-envelope",message:`journal[${c}]: event is missing required envelope field(s): ${$.join(", ")}.`,severity:"error"});return}j.push({ev:h,index:c})});let U=new Set(b.keys()),M=new Set(R),F=new Set;for(let{ev:i}of j)if(i.type==="node.created"){let c=r(i.node_id);c&&U.add(c)}else if(i.type==="edge.added"){let c=r(i.edge_id);c&&M.add(c)}else if(i.type==="journal.baseline"&&Array.isArray(i.node_ids))for(let c of i.node_ids){let v=r(c);v&&(F.add(v),U.add(v))}let W=Fe(j.map(i=>i.ev)),J=new Set,B=new Map,n=new Map;for(let i of W)if(i.type==="node.created"){let c=r(i.node_id);c&&J.add(c)}else if(i.type==="node.status_changed"){let c=r(i.node_id);if(c&&i.platform===void 0){let v=r(i.to);v!==void 0&&B.set(c,v)}}else if(i.type==="decision.status_changed"){let c=r(i.node_id);if(c){let v=r(i.to);v!==void 0&&n.set(c,v)}}for(let{ev:i,index:c}of j){let v=yt[i.type];if(v)for(let h of v){let $=r(i[h]);$!==void 0&&!U.has($)&&o.push({path:`journal[${c}].${h}`,rule:"journal-dangling-node-ref",message:`journal[${c}] (${i.type}): references node "${$}" that never existed in the snapshot or journal.`,severity:"error"})}if(i.type==="deliverable.shipped"&&Array.isArray(i.node_ids)&&i.node_ids.forEach((h,$)=>{let x=r(h);x!==void 0&&!U.has(x)&&o.push({path:`journal[${c}].node_ids[${$}]`,rule:"journal-dangling-node-ref",message:`journal[${c}] (${i.type}): references node "${x}" that never existed in the snapshot or journal.`,severity:"error"})}),i.type==="edge.removed"){let h=r(i.edge_id);h!==void 0&&!M.has(h)&&o.push({path:`journal[${c}].edge_id`,rule:"journal-dangling-edge-ref",message:`journal[${c}] (edge.removed): references edge "${h}" that never existed in the snapshot or journal.`,severity:"error"})}}for(let[i,c]of b){!J.has(i)&&!F.has(i)&&o.push({path:"journal",rule:"journal-missing-node-created",message:`Node "${i}" is present in the snapshot but has no node.created event in the journal.`,severity:"error"});let v=B.get(i);v!==void 0&&!wt(v,c)&&o.push({path:"journal",rule:"journal-status-mismatch",message:`Node "${i}": journal's last node.status_changed.to "${v}" disagrees with snapshot status "${String(c)}".`,severity:"error"})}for(let[i,c]of n){if(!E.has(i))continue;let v=E.get(i)??"proposed";c!==v&&o.push({path:"journal",rule:"journal-decision-status-mismatch",message:`Node "${i}": journal's last decision.status_changed.to "${c}" disagrees with snapshot decision_status "${String(v)}".`,severity:"error"})}let T=Le(W);return l.forEach((i,c)=>{let v=r(i?.id);if(v===void 0)return;let h=We(i.metadata)?i.metadata:{},$=We(h.platformScreenshots)?h.platformScreenshots:{},x=T.get(v),Y=new Set([...Object.keys($),...x?x.keys():[]]);for(let q of Y){let D=x?.get(q);if(D===void 0)continue;let Q=typeof $[q]=="string"?$[q]:void 0,A,X;if(D===null)X=Q===void 0,A="it was removed";else if(D.form==="data")X=Q!==void 0,A="a data URI was recorded";else{let Z=r(D.url);X=Q===Z,A=Z===void 0?"an unknown value was recorded":`"${Z}" was recorded`}X||o.push({path:`nodes[${c}].metadata.platformScreenshots.${q}`,rule:"screenshot-untracked",message:`Node "${v}": platformScreenshots.${q} is ${Q===void 0?"empty":`"${Q}"`} but the journal's last screenshot event says ${A} \u2014 write screenshots through record_screenshot, not update_node.`,severity:"warning"})}}),o}var Ve=["flow","view","acceptance"];function Ue(e){let o=e?.metadata?.products;if(!Array.isArray(o))return[];let t=new Set,r=[];for(let l of o){if(typeof l!="object"||l===null||Array.isArray(l))continue;let m=l;typeof m.id!="string"||m.id.trim()===""||t.has(m.id)||(t.add(m.id),r.push(m))}return r}var Je=["rings","bars"],qe=["chips","rows"],Be=["status","species"];var vt=["journey","system","screens"];function Ke(e){return vt.includes(e)}var pe="cross-surface";var bt={"saves-time":{"-3":"Takes hours out of the person's life.","-2":"Costs the person time on tasks they do regularly in this domain.","-1":"Costs the person a little time on one task inside the product.",1:"Saves a little time on one task inside the product.",2:"Saves time on tasks the person does regularly in this domain.",3:"Gives the person back hours of their life, the way online banking replaced trips to the bank."},simplifies:{"-3":"Makes a part of the person's life confusing or hard to manage.","-2":"Makes a whole task in this domain clearly more complicated.","-1":"Adds a step or a choice inside the product.",1:"Removes a step or a choice inside the product.",2:"Makes a whole task in this domain clearly simpler.",3:"Makes a complicated part of the person's life simple, the way a single search box replaced browsing directories."},"makes-money":{"-3":"Costs the person a meaningful part of their income.","-2":"Cuts a regular way the person earns in this domain.","-1":"Makes earning slightly harder or costs the person a little income.",1:"Helps the person earn a little, or makes earning slightly easier.",2:"Gives the person a regular way to earn in this domain.",3:"Provides a meaningful part of the person's income."},"reduces-risk":{"-3":"Exposes the person to a major loss in their life.","-2":"Exposes the person to a serious loss or error in this domain.","-1":"Exposes the person to a small mistake or loss inside the product.",1:"Guards against a small mistake or loss inside the product.",2:"Protects against a serious loss or error in this domain.",3:"Protects against a major loss in the person's life, the way insurance or a full backup does."},organizes:{"-3":"Brings disorder to a large part of the person's life.","-2":"Makes things in this domain hard to keep in order or to find.","-1":"Leaves a few things in disorder inside the product.",1:"Keeps a few things in order inside the product.",2:"Keeps everything in this domain in order and easy to find.",3:"Brings order to a large part of the person's life, the way a calendar does."},integrates:{"-3":"Pulls separate parts of the person's life further apart.","-2":"Splits apart the several tools the person uses in this domain.","-1":"Cuts the product off from one other tool the person uses.",1:"Connects the product to one other tool the person uses.",2:"Ties together the several tools the person uses in this domain.",3:"Makes separate parts of the person's life work together as one."},connects:{"-3":"Separates the person from the people who matter most in their life.","-2":"Makes it harder to build or keep relationships in this domain.","-1":"Gets in the way of reaching someone through the product.",1:"Lets the person reach someone through the product.",2:"Helps the person build and keep relationships in this domain.",3:"Brings the person together with the people who matter most in their life."},"reduces-effort":{"-3":"Puts a heavy burden of work on the person's life.","-2":"Adds repetitive work to a task the person does regularly in this domain.","-1":"Adds a little effort to one task inside the product.",1:"Saves a little effort on one task inside the product.",2:"Takes the repetitive work out of a task the person does regularly in this domain.",3:"Lifts a heavy burden of work off the person's life."},"avoids-hassles":{"-3":"Brings a whole kind of annoyance into the person's life.","-2":"Adds an annoyance that keeps coming back in this domain.","-1":"Adds a small annoyance inside the product.",1:"Avoids a small annoyance inside the product.",2:"Avoids an annoyance that keeps coming back in this domain.",3:"Takes a whole kind of annoyance out of the person's life, the way a GPS ended getting lost."},"reduces-cost":{"-3":"Costs the person a significant amount of money over their life.","-2":"Costs the person money regularly in this domain.","-1":"Costs the person a little money on one purchase.",1:"Saves the person a little money on one purchase.",2:"Saves the person money regularly in this domain.",3:"Saves the person a significant amount of money over their life."},quality:{"-3":"Craft so poor the person would call it the worst they have used.","-2":"The product does its job in this domain clearly worse than the usual alternatives.","-1":"Something inside the product works noticeably badly.",1:"Something inside the product works noticeably well.",2:"The product does its job in this domain clearly better than the usual alternatives.",3:"Craft so good the person would call it the best they have used."},variety:{"-3":"Closes off a breadth of choice the person had elsewhere.","-2":"Narrows the choice in this domain.","-1":"Removes a few meaningful options inside the product.",1:"Offers a few meaningful options inside the product.",2:"Offers a wide and meaningful choice in this domain.",3:"Opens a breadth of choice the person could not get anywhere else."},"sensory-appeal":{"-3":"A sensory experience the person avoids.","-2":"The product looks, sounds or feels bad and the person dislikes using it.","-1":"An unpleasant detail the person notices in the moment.",1:"A pleasant detail the person notices in the moment.",2:"The product looks, sounds or feels good and the person enjoys using it.",3:"A sensory experience the person seeks out for its own sake."},informs:{"-3":"Misleads the person deeply about the service area or domain.","-2":"Confuses the person about the service area or domain.","-1":"Hides from the person something about the service that they want to know.",1:"Informs the person about the service.",2:"Informs the person about the service area or domain.",3:"Informs the person deeply and efficiently about the service area or domain."},"reduces-anxiety":{"-3":"Gives the person a lasting worry in their life.","-2":"Stirs up a worry the person has in this domain.","-1":"Adds a small worry inside the product.",1:"Removes a small worry inside the product.",2:"Calms a worry the person has in this domain.",3:"Takes a lasting worry out of the person's life."},"rewards-me":{"-3":"Takes away rewards the person values as much as the product itself.","-2":"Takes away perks the person regularly values.","-1":"Takes away a small perk the person had.",1:"Gives the person a small perk for engaging.",2:"Gives the person regular perks they value.",3:"Gives the person rewards they value as much as the product itself."},nostalgia:{"-3":"Destroys a cherished memory for good.","-2":"Loses or overwrites a good memory of the past.","-1":"Puts a pleasant memory at slight risk.",1:"Faintly recalls a pleasant memory of the past.",2:"Clearly brings back a good memory of the past.",3:"Brings back a cherished past in a vivid and deeply felt way."},"design-aesthetics":{"-3":"Ugliness the person would be embarrassed to show to others.","-2":"A design the person finds ugly.","-1":"A displeasing design detail.",1:"A pleasing design detail.",2:"A design the person finds beautiful.",3:"Beauty the person would show to others and that shapes how they feel about it."},"badge-value":{"-3":"Signals something the person does not want the people who matter to them to see.","-2":"Clearly signals a low identity or status in a community.","-1":"Gives a mild negative signal about the person to others.",1:"Gives a mild signal about the person to others.",2:"Clearly signals the person's identity or status in a community.",3:"Signals who the person is to the people who matter to them."},wellness:{"-3":"Lastingly harms the person's physical or mental well-being.","-2":"Noticeably worsens how the person feels over time.","-1":"Slightly worsens how the person feels, in the moment.",1:"Slightly improves how the person feels, in the moment.",2:"Noticeably improves how the person feels over time.",3:"Lastingly improves the person's physical or mental well-being."},"therapeutic-value":{"-3":"Deepens something that hurts the person.","-2":"Makes a difficult feeling harder for the person to work through.","-1":"Reopens a small emotional sore.",1:"Gives a small moment of emotional relief.",2:"Helps the person work through a difficult feeling.",3:"Supports real healing of something that hurts the person."},"fun-entertainment":{"-3":"So joyless that the person avoids it and warns others.","-2":"Boring or tedious to use.","-1":"A dull moment.",1:"A light moment of enjoyment.",2:"Genuinely enjoyable to use.",3:"Delight the person would seek out and tell others about."},attractiveness:{"-3":"Changes how unattractive the person feels in general.","-2":"Clearly makes the person feel less attractive.","-1":"Makes the person feel slightly worse about how they look.",1:"Makes the person feel slightly better about how they look.",2:"Clearly makes the person feel more attractive.",3:"Changes how attractive the person feels in general."},"provides-access":{"-3":"Shuts the person out of something that matters in their life.","-2":"Cuts the person off from a service or from people in this domain that they could otherwise reach.","-1":"Puts a feature inside the product behind a barrier or closes it off.",1:"Opens a feature inside the product.",2:"Gives access to a service or to people in this domain that the person could not easily reach.",3:"Gives access to something that matters in the person's life and that they could not get otherwise."},"provides-hope":{"-3":"Leaves the person believing their life cannot get better.","-2":"Gives the person a reason to doubt that things in this domain can improve.","-1":"Plants a small doubt.",1:"Gives a small reason for optimism.",2:"Gives a real reason to believe things in this domain can improve.",3:"Gives a lasting belief that the person's life can get better."},"self-actualization":{"-3":"Pushes the person away from who they want to be.","-2":"Clear drift away from who the person wants to be.","-1":"A small step away from who the person wants to be.",1:"A small step toward who the person wants to be.",2:"Clear progress toward who the person wants to be.",3:"Helps the person become who they want to be."},motivation:{"-3":"Drains the person's drive toward goals that matter in their life.","-2":"Saps the person's energy toward a goal in this domain.","-1":"A small drag on the person's drive.",1:"A small nudge to act.",2:"Energizes the person toward a goal in this domain.",3:"Sustains the person's drive toward goals that matter in their life."},heirloom:{"-3":"Loses something meaningful that was meant to be passed on across time.","-2":"Lets something meaningful be lost within years.","-1":"Puts something worth keeping at slight risk.",1:"Keeps something worth keeping for a while.",2:"Preserves something meaningful for years.",3:"Holds something meaningful enough to be passed on to others across time."},"affiliation-belonging":{"-3":"Cuts the person off from a group that matters deeply to who they are.","-2":"Leaves the person out of a group in this domain.","-1":"A feeling of being slightly left out of something small.",1:"A feeling of being part of something small.",2:"Makes the person part of a group in this domain.",3:"Makes the person part of a group that matters deeply to who they are."},"self-transcendence":{"-3":"Works against something larger than the person themselves.","-2":"Harms others in a meaningful way.","-1":"Does a small harm to others.",1:"Does a small good for others.",2:"Helps others in a meaningful way.",3:"Contributes to something larger than the person themselves."}},Qe=Object.freeze(Object.fromEntries(Object.entries(bt).map(([e,o])=>[e,Object.freeze(o)])));var _e=["human","agent","rule"],He=["human","agent"];var ze=["p_serves","p_costs"];function Ye(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1}var Xe="weighing.assessment.recorded",Ze="weighing.set.saved";function St(e,o,t){return`${e}\0${o}\0${t}`}function et(e){let o=typeof e?.scorer?.kind=="string"?e.scorer.kind:"";return`${St(String(e?.matrix),String(e?.subject),String(e?.criterion))}\0${o}`}var _t=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function tt(e){return _t(e)&&typeof e.matrix=="string"&&typeof e.subject=="string"&&typeof e.criterion=="string"}function ae(e){let o=e.lastIndexOf("@");return o===-1?{id:e,major:void 0}:{id:e.slice(0,o),major:e.slice(o+1)}}function ie(e){let o=/^(\d+)(?:\.|$)/.exec(e);return o?o[1]:void 0}function fe(e){if(typeof e=="object"&&e!==null&&!Object.isFrozen(e)){Object.freeze(e);for(let o of Object.values(e))fe(o)}return e}var $e="value-contribution",$t="2.0.0",kt="1.0.0",Et="value",de="positioning",xt={3:"Life-wide. It gives the person this well beyond the product and its domain, in their life.",2:"Across the domain. The person gets this in the whole area the product belongs to, not only inside it.",1:"Within the product. A real contribution, felt while using it.",0:"Unrelated: weighed and found to have nothing to do with it. (No row means nobody has weighed it yet.)","-1":"Within the product. A small cost, felt while using it.","-2":"Across the domain. The person notices the loss of this in the whole area the product belongs to.","-3":"Life-wide. It leaves the person with the opposite of this in their life."},At={3:"Core. The promise exists for this; take it away and the value goes.",2:"Supports clearly. The user would notice it missing.",1:"Touches. A side effect of the promise, not its purpose.",0:"Unrelated: weighed and found to have nothing to do with it. (No row means nobody has weighed it yet.)","-1":"Small friction. It costs this value a little.","-2":"Works against it. The user notices the cost.","-3":"Costs it at its core. The user feels the opposite."},nt={functional:"Functional",emotional:"Emotional","life-changing":"Life-changing","social-impact":"Social impact"},se={"saves-time":{name:"Saves time",definition:"Completes the user's task in less time."},simplifies:{name:"Simplifies",definition:"Reduces steps, choices, or cognitive load."},"makes-money":{name:"Makes money",definition:"Helps the user earn."},"reduces-risk":{name:"Reduces risk",definition:"Protects against loss, error, or uncertainty."},organizes:{name:"Organizes",definition:"Brings order to the user's things or life."},integrates:{name:"Integrates",definition:"Ties different tools or parts of life together."},connects:{name:"Connects",definition:"Brings the user together with other people."},"reduces-effort":{name:"Reduces effort",definition:"Same outcome, less work."},"avoids-hassles":{name:"Avoids hassles",definition:"Prevents friction and annoyance before it happens."},"reduces-cost":{name:"Reduces cost",definition:"Saves the user money."},quality:{name:"Quality",definition:"Superior craft or performance the user can feel."},variety:{name:"Variety",definition:"Meaningful choice and breadth."},"sensory-appeal":{name:"Sensory appeal",definition:"Looks, sounds, or feels good in the moment."},informs:{name:"Informs",definition:"Tells the user something they want to know."},"reduces-anxiety":{name:"Reduces anxiety",definition:"Calms; makes the user feel safe."},"rewards-me":{name:"Rewards me",definition:"Tangible perks for engagement."},nostalgia:{name:"Nostalgia",definition:"Positive memory of the past."},"design-aesthetics":{name:"Design / aesthetics",definition:"Beauty as an experienced value, beyond function."},"badge-value":{name:"Badge value",definition:"Signals identity or status to others."},wellness:{name:"Wellness",definition:"Improves physical or mental well-being."},"therapeutic-value":{name:"Therapeutic value",definition:"Actively supports emotional processing or healing."},"fun-entertainment":{name:"Fun / entertainment",definition:"Enjoyable, playful, delightful."},attractiveness:{name:"Attractiveness",definition:"Makes the user feel attractive."},"provides-access":{name:"Provides access",definition:"Grants entry to something otherwise out of reach."},"provides-hope":{name:"Provides hope",definition:"Reason to believe things can improve."},"self-actualization":{name:"Self-actualization",definition:"Helps the user become who they want to be."},motivation:{name:"Motivation",definition:"Energizes the user toward their goals."},heirloom:{name:"Heirloom",definition:"Something worth passing on across time."},"affiliation-belonging":{name:"Affiliation & belonging",definition:"Makes the user part of a group that matters."},"self-transcendence":{name:"Self-transcendence",definition:"Helps beyond the user themselves."}},st={min:-3,max:3,anchors:{...xt}},rt=Object.keys(nt).map(e=>({id:e,title:nt[e]}));function It(e){return e==="informs"?"Is what this promise mainly gives the person information, rather than an ability, a shortcut, a protection or a feeling? Or does it keep them from knowing something? And how far into their life does it reach?":`Does this promise serve, or cost, "${se[e].name}" for the person? And how far into their life does it reach: within the product, across its domain, or life-wide?`}var Rt=fe({id:$e,version:$t,title:"Elements of value",subject:"acceptance",scale:st,groups:rt,criteria:oe.map(e=>({id:e,group:we[e],name:se[e].name,question:It(e),definition:se[e].definition,anchors:{...Qe[e]}}))}),jt=fe({id:$e,version:kt,title:"Elements of value",subject:"acceptance",scale:{min:-3,max:3,anchors:{...At}},groups:rt,criteria:oe.map(e=>({id:e,group:we[e],name:se[e].name,question:`Does this promise serve, or cost, "${se[e].name}"?`,definition:se[e].definition}))}),Mt=fe({id:Et,title:"Value",set:`${$e}@2`,subjects:{kind:"query",species:"acceptance"},positioning:de,status:"active"}),ke=[Rt,jt],Ee=[Mt],ee=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function Pt(e){let o=e.criteria.filter(t=>ee(t)&&typeof t.id=="string");return o.length===e.criteria.length?e:{...e,criteria:o}}function xe(e){return ee(e)&&typeof e.id=="string"&&typeof e.version=="string"&&Array.isArray(e.criteria)&&(ee(e.scale)||e.role==="positioning")}function Ae(e){if(!ee(e)||typeof e.id!="string"||typeof e.set!="string"||!ee(e.subjects))return!1;let{kind:o,species:t,items:r}=e.subjects;return o==="query"&&typeof t=="string"||o==="list"&&Array.isArray(r)}function it(e){return ee(e)&&typeof e.min=="number"&&typeof e.max=="number"&&ee(e.anchors)}function ot(e,o){if(it(e.scale))return e.scale;let t=typeof e.extends=="string"&&o!==void 0?ge(o,e.extends):void 0;return t!==void 0&&it(t.scale)?t.scale:st}function at(e){let o=[...ke],t=[...Ee],r=[],l=m=>ee(m)?{...typeof m.id=="string"?{id:m.id}:{},...typeof m.role=="string"?{role:m.role}:{}}:{};return(Array.isArray(e?.sets)?e.sets:[]).forEach((m,b)=>{xe(m)&&!o.some(E=>E.id===m.id)?o.push(Pt(m)):r.push({kind:"set",...l(m),index:b})}),(Array.isArray(e?.matrices)?e.matrices:[]).forEach((m,b)=>{Ae(m)&&!t.some(E=>E.id===m.id)?t.push(m):r.push({kind:"matrix",...l(m),index:b})}),{sets:o,matrices:t,skipped:r}}function ge(e,o){let{id:t,major:r}=ae(o);return e.sets.find(l=>l.id===t&&(r===void 0||ie(l.version)===r))}function Ie(e,o){let{id:t,major:r}=ae(o),l=e.sets.find(b=>b.id===t);if(l===void 0||r===void 0)return!1;let m=Number(ie(l.version));return Number.isFinite(m)&&Number(r)<m}var H=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function dt(e,o,t){let r=[],l=(m,b,E)=>r.push({path:m,rule:b,message:E});if(e!=null&&!H(e)&&l("weighing","weighing-section-shape","The weighing section is not an object \u2014 it is ignored"),H(e)){for(let n of["sets","matrices","assessments"])e[n]!==void 0&&!Array.isArray(e[n])&&l(`weighing.${n}`,"weighing-section-shape",`weighing.${n} is not an array \u2014 it is ignored`);let m=Array.isArray(e.sets)?e.sets:[],b=Array.isArray(e.matrices)?e.matrices:[],E=Array.isArray(e.assessments)?e.assessments:[],R=at(e),j=(n,T,i,c)=>{let v=ge(R,n);if(v!==void 0)return v;let h=R.sets.find($=>$.id===ae(n).id);h!==void 0?l(T,"weighing-set-ref-major",`${i} names ${n}, but "${h.id}" is at ${h.version} \u2014 levels are comparable only within a major, so the ref resolves to nothing`):l(T,c,`${i} names set "${n}", which is neither built in nor in this section`)},U=new Set(R.matrices.map(n=>n.positioning).filter(n=>typeof n=="string")),M=(n,T,i)=>{i.status!==void 0&&i.status!=="draft"&&i.status!=="active"&&l(`${n}.status`,"weighing-set-status",`${T}: status ${JSON.stringify(i.status)} is not "draft" or "active" \u2014 it is read as a draft, which feeds no roll-up`)},F=n=>H(n)&&Object.values(n).every(T=>typeof T=="string"),W=new Set;m.forEach((n,T)=>{let i=`weighing.sets[${T}]`;if(!H(n)){l(i,"weighing-set-shape","A set is not an object \u2014 it is ignored");return}let c=`Set "${String(n.id)}"`,v=xe(n);if(v||l(i,"weighing-set-shape",`${c} needs a string id and version, a criteria array and a scale object (a positioning may leave the scale out) \u2014 it is ignored`),typeof n.id=="string"&&(ke.some(h=>h.id===n.id)?l(`${i}.id`,"weighing-pinned-set-redefined",`${c} is built in and pinned by version \u2014 the project's copy is ignored`):v&&(W.has(n.id)&&l(`${i}.id`,"weighing-duplicate-set",`Duplicate set id "${n.id}" \u2014 the first well-formed one wins, this one is ignored`),W.add(n.id))),M(i,c,n),H(n.scale)){let h=n.scale;(typeof h.min!="number"||typeof h.max!="number"||!F(h.anchors))&&l(`${i}.scale`,"weighing-scale-shape",`${c}: a scale needs a numeric min and max and an anchors object of strings`)}if(Array.isArray(n.criteria)&&n.criteria.forEach((h,$)=>{let x=`${i}.criteria[${$}]`;(!H(h)||typeof h.id!="string"||h.anchors!==void 0&&!F(h.anchors))&&l(x,"weighing-criterion-shape",`${c}: criterion ${$} needs a string id, and its anchors (if any) must be an object of strings`)}),n.role==="positioning"&&!(typeof n.id=="string"&&U.has(n.id))?l(`${i}.id`,"weighing-positioning-id",`A positioning set must have the id "${de}" (the one a matrix points at) \u2014 "${String(n.id)}" would never be applied`):n.role!=="positioning"&&n.id===de&&l(`${i}.role`,"weighing-positioning-id",`Set "${de}" is where a matrix looks for its positioning, but its role is ${JSON.stringify(n.role)}, not "positioning" \u2014 it would never be applied`),n.role==="positioning"){let h=typeof n.extends=="string"?j(n.extends,`${i}.extends`,`Positioning "${String(n.id)}"`,"weighing-positioning-unknown-ruler"):void 0;typeof n.extends!="string"?l(`${i}.extends`,"weighing-positioning-unknown-ruler",`Positioning "${String(n.id)}" does not say which set it re-weights \u2014 set extends to e.g. value-contribution@2`):h!==void 0&&h.role==="positioning"?l(`${i}.extends`,"weighing-positioning-unknown-ruler",`Positioning "${String(n.id)}" extends "${n.extends}", which is itself a positioning \u2014 it must extend a criteria set such as value-contribution@2`):h!==void 0&&Ie(R,n.extends)&&l(`${i}.extends`,"weighing-positioning-old-ruler",`Positioning "${String(n.id)}" extends ${n.extends}, an older ruler \u2014 its weights still apply, but read its level descriptions against ${h.id}'s current major and save it again`);let $=new Set(h!==void 0&&h.role!=="positioning"?h.criteria.map(x=>x?.id):[]);(Array.isArray(n.criteria)?n.criteria:[]).forEach((x,Y)=>{if(!H(x))return;let q=`${i}.criteria[${Y}]`;$.size>0&&typeof x.id=="string"&&!$.has(x.id)&&l(`${q}.id`,"weighing-positioning-unknown-element",`Positioning names "${x.id}", which is not in ${String(n.extends)}`),x.weight!==void 0&&(typeof x.weight!="number"||!(x.weight>0))&&l(`${q}.weight`,"weighing-positioning-weight",`Positioning weight for "${String(x.id)}" must be a number above 0 \u2014 leave the element out to leave it unpositioned`)})}});let J=new Set;b.forEach((n,T)=>{let i=`weighing.matrices[${T}]`;if(!H(n)){l(i,"weighing-matrix-shape","A matrix is not an object \u2014 it is ignored");return}let c=`Matrix "${String(n.id)}"`,v=Ae(n);v||l(i,"weighing-matrix-shape",`${c} needs a string id, a set ref and a subjects object of kind query or list \u2014 it is ignored`),typeof n.id=="string"&&(Ee.some(h=>h.id===n.id)?l(`${i}.id`,"weighing-pinned-matrix-redefined",`${c} is built in \u2014 the project's copy is ignored`):v&&(J.has(n.id)&&l(`${i}.id`,"weighing-duplicate-matrix",`Duplicate matrix id "${n.id}" \u2014 the first well-formed one wins, this one is ignored`),J.add(n.id))),M(i,c,n),v&&j(n.set,`${i}.set`,c,"weighing-unknown-set")!==void 0&&Ie(R,n.set)&&l(`${i}.set`,"weighing-matrix-old-ruler",`${c} reads ${n.set}, an older ruler \u2014 its levels still read, but nothing new can be scored on it; point it at the current major`)});let B=new Set;E.forEach((n,T)=>{let i=`weighing.assessments[${T}]`,c=`Assessment ${T}`;if(!tt(n)){l(i,"weighing-assessment-shape",`${c}: not an object with a string matrix, subject and criterion \u2014 it cannot be addressed, so every reader skips it`);return}(typeof n.ts!="string"||Number.isNaN(Date.parse(n.ts)))&&l(`${i}.ts`,"weighing-assessment-ts",`${c}: ts must be an ISO 8601 string \u2014 without it "latest wins" cannot order this row`);let v=R.matrices.find(A=>A.id===n.matrix);v===void 0&&l(`${i}.matrix`,"weighing-unknown-matrix",`${c}: matrix "${n.matrix}" is not defined`);let h=v===void 0?void 0:ge(R,v.set),$=h?.criteria.find(A=>A?.id===n.criterion);h!==void 0&&$===void 0&&l(`${i}.criterion`,"weighing-unknown-criterion",`${c}: criterion "${n.criterion}" is not in set "${h.id}"`),$!==void 0&&typeof $.superseded_by=="string"&&$.superseded_by!==""&&l(`${i}.criterion`,"weighing-retired-criterion",`${c}: criterion "${$.id}" is retired \u2014 superseded by "${$.superseded_by}"`);let x=h===void 0?void 0:ot(h,R),Y=typeof x?.min=="number"?x.min:-3,q=typeof x?.max=="number"?x.max:3;(typeof n.level!="number"||!Number.isInteger(n.level)||n.level<Y||n.level>q)&&l(`${i}.level`,"weighing-level-range",`${c}: level must be an integer ${Y}..${q} (a blank cell is the absence of the row; 0 means weighed and unrelated)`),[0,1,2,3].includes(n.confidence)||l(`${i}.confidence`,"weighing-confidence-range",`${c}: confidence must be 0, 1, 2 or 3`);let D=H(n.scorer)?n.scorer:void 0;if(D===void 0||typeof D.kind!="string"||typeof D.id!="string"||D.id===""?l(`${i}.scorer`,"weighing-scorer-missing",`${c}: no scorer with a string kind and id \u2014 human, agent and rule levels become indistinguishable, and the row can win no cell`):_e.includes(D.kind)?He.includes(D.kind)||l(`${i}.scorer.kind`,"weighing-rule-stored",`${c}: scorer kind "${D.kind}" is never stored \u2014 a seeding rule is computed on read`):l(`${i}.scorer.kind`,"weighing-scorer-kind",`${c}: scorer kind "${D.kind}" is not one of ${_e.join(", ")} \u2014 it ranks below every other scorer`),v?.subjects.kind==="query"){let A=o.get(n.subject);A===void 0?l(`${i}.subject`,"weighing-unknown-subject",`${c}: subject "${n.subject}" is not a node in this bundle`):A!==v.subjects.species&&l(`${i}.subject`,"weighing-subject-species",`${c}: subject "${n.subject}" is a ${A}, and matrix "${v.id}" judges ${String(v.subjects.species)} nodes`)}n.evidence!==void 0&&typeof n.evidence!="string"?l(`${i}.evidence`,"weighing-evidence-type",`${c}: evidence must be a markdown string`):(n.confidence===2||n.confidence===3)&&(n.evidence===void 0||n.evidence.trim()==="")&&l(`${i}.evidence`,"weighing-no-evidence",`${c}: confidence ${String(n.confidence)} claims evidence and cites none`);for(let A of ze)n[A]!==void 0&&!Ye(n[A])&&l(`${i}.${A}`,"weighing-probability-shape",`${c}: ${A} must be a number from 0 to 1 \u2014 it is ignored`);if(n.refs!==void 0&&!(Array.isArray(n.refs)&&n.refs.every(A=>typeof A=="string"))&&l(`${i}.refs`,"weighing-refs-type",`${c}: refs must be an array of id strings`),n.basis!==void 0&&!(H(n.basis)&&["fingerprint","commit","set_version"].every(A=>n.basis[A]===void 0||typeof n.basis[A]=="string"))&&l(`${i}.basis`,"weighing-basis-shape",`${c}: basis must be an object whose fingerprint, commit and set_version are strings`),D!==void 0&&typeof D.kind=="string"){let A=et(n);B.has(A)&&l(i,"weighing-duplicate-assessment",`${c}: a second ${D.kind} score for the same cell \u2014 the section stores latest-per-scorer-kind, so this cell is ambiguous`),B.add(A)}let Q=H(n.basis)&&typeof n.basis.set_version=="string"?n.basis.set_version:void 0;h!==void 0&&Q!==void 0&&ie(Q)!==ie(h.version)&&l(`${i}.basis.set_version`,"weighing-set-major",`${c}: scored against ${h.id} ${Q}, and the set is now ${h.version} \u2014 levels are comparable only within a major`)})}return t.forEach((m,b)=>{if(!H(m))return;let E=typeof m.type=="string"?m.type:"";E!==Xe&&E!==Ze||(typeof m.actor!="string"||m.actor.trim()==="")&&l(`journal[${b}].actor`,"weighing-event-no-actor",`Journal event ${b}: ${E} has no actor \u2014 human, agent and CI scores become indistinguishable`)}),r}var Nt=["beta","monitoring","deprecated"],ct=["compact","large"],lt=2*1024*1024;function Tt(e){let o=e.indexOf(",");if(o===-1)return 0;let t=e.slice(o+1),r=t.endsWith("==")?2:t.endsWith("=")?1:0;return Math.floor(t.length*3/4)-r}function ut(e){return typeof e=="string"&&!Number.isNaN(Date.parse(e))}function pt(e){let o=[],t=(s,u,a)=>o.push({path:s,rule:u,message:a,severity:"error"}),r=(s,u,a)=>o.push({path:s,rule:u,message:a,severity:"warning"}),l=()=>{let s=o.filter(a=>a.severity==="error"),u=o.filter(a=>a.severity==="warning");return{valid:s.length===0,findings:o,errors:s,warnings:u}};if(typeof e!="object"||e===null||Array.isArray(e))return t("","bundle-shape","Bundle must be an object with project, nodes, and edges."),l();let m=e,b=m.project,E=m.nodes,R=m.edges;if(!b||!E||!R)return t("","bundle-shape","Missing top-level keys (project, nodes, edges)."),l();if(!Array.isArray(E))return t("nodes","bundle-shape","nodes must be an array."),l();if(!Array.isArray(R))return t("edges","bundle-shape","edges must be an array."),l();let j=E,U=R,M=new Map,F=new Set;b.id||t("project.id","project-id-required","project.id is missing"),(typeof b.title!="string"||!b.title.trim())&&t("project.title","title-non-empty","project.title is missing or empty"),b.created_at||t("project.created_at","timestamp-required","project.created_at is missing"),b.updated_at||t("project.updated_at","timestamp-required","project.updated_at is missing"),b.created_at&&!ut(b.created_at)&&r("project.created_at","iso-timestamp","project.created_at is not a valid ISO 8601 timestamp"),b.updated_at&&!ut(b.updated_at)&&r("project.updated_at","iso-timestamp","project.updated_at is not a valid ISO 8601 timestamp");let W=b.metadata;W&&W.view_card_variant!==void 0&&!ct.includes(W.view_card_variant)&&t("project.metadata.view_card_variant","view-card-variant",`project.metadata.view_card_variant must be one of ${ct.join(", ")} (import rejects other values)`),j.forEach((s,u)=>{let a=`nodes[${u}]`,d=s.id;F.has(d)&&t(`${a}.id`,"duplicate-node-id",`Duplicate node ID: ${d}`),F.add(d),M.set(d,s),(typeof s.title!="string"||!s.title.trim())&&t(`${a}.title`,"title-non-empty",`Node ${d}: title is missing or empty`);let f=s.species,p=De[f];p&&!(typeof d=="string"&&d.startsWith(p))&&t(`${a}.id`,"species-prefix",`Node ${d}: species "${f}" should have prefix "${p}"`),ue.includes(f)||t(`${a}.species`,"valid-species",`Node ${d}: invalid species "${f}"`),s.project_id!==b.id&&t(`${a}.project_id`,"project-id-match",`Node ${d}: project_id "${s.project_id}" does not match project.id "${b.id}"`),ne.includes(s.status)||t(`${a}.status`,"valid-status",`Node ${d}: invalid status "${s.status}"`);let y=s.platforms;if(!y||y.length===0)f!=="decision"&&t(`${a}.platforms`,"platforms-non-empty",`Node ${d}: platforms array is empty or missing`);else for(let g of y)re.includes(g)||t(`${a}.platforms`,"valid-platform",`Node ${d}: invalid platform "${g}"`);let w=s.metadata||{};w.stage!==void 0&&!Nt.includes(w.stage)&&t(`${a}.metadata.stage`,"valid-stage",`Node ${d}: invalid metadata.stage "${w.stage}"`);let I=w.platformNotes;if(I)for(let g of Object.keys(I))re.includes(g)||t(`${a}.metadata.platformNotes`,"valid-platform",`Node ${d}: platformNotes has invalid platform "${g}"`);let P=w.platformStatuses;if(P)for(let[g,S]of Object.entries(P))re.includes(g)?Array.isArray(y)&&!y.includes(g)&&r(`${a}.metadata.platformStatuses`,"platform-statuses-subset",`Node ${d}: platformStatuses covers platform "${g}" not in node.platforms`):t(`${a}.metadata.platformStatuses`,"valid-platform",`Node ${d}: platformStatuses has invalid platform "${g}"`),ne.includes(S)||t(`${a}.metadata.platformStatuses`,"valid-status",`Node ${d}: platformStatuses has invalid status "${S}" for platform "${g}"`);let O=w.platformScreenshots;if(O){for(let[g,S]of Object.entries(O))if(typeof S=="string"&&S.startsWith("data:")){let L=Tt(S);L>lt&&r(`${a}.metadata.platformScreenshots`,"screenshot-data-uri-size",`Node ${d}: platformScreenshots.${g} is a ${(L/(1024*1024)).toFixed(1)}MB data URI, above the ${lt/(1024*1024)}MB guidance (docs/spec/bundle-format.md \xA7 Asset Values) \u2014 consider a relative path or hosted URL instead`)}}let C=w.gherkin,K=w.values;if(f==="acceptance"?((typeof C!="string"||!C.trim())&&r(`${a}.metadata.gherkin`,"acceptance-gherkin-missing",`Acceptance ${d}: metadata.gherkin is missing or empty (one Given/When/Then scenario expected)`),(!Array.isArray(K)||K.length===0)&&r(`${a}.metadata.values`,"acceptance-values-missing",`Acceptance ${d}: metadata.values is missing or empty (assign 1-3 value elements)`)):(C!==void 0&&r(`${a}.metadata.gherkin`,"gherkin-species",`Node ${d}: metadata.gherkin is only meaningful on acceptance nodes`),K!==void 0&&r(`${a}.metadata.values`,"values-species",`Node ${d}: metadata.values is only meaningful on acceptance nodes`)),Array.isArray(K))for(let g of K)oe.includes(g)||t(`${a}.metadata.values`,"valid-value",`Node ${d}: invalid value element "${g}"`);let _=w.refs;if(Array.isArray(_)){let g=new Set;_.forEach((S,L)=>{let N=S??{},G=`${a}.metadata.refs[${L}]`,V=N.id;typeof V!="string"||!V.trim()?t(`${G}.id`,"ref-id-required",`Node ${d}: ref is missing an id`):g.has(V)?t(`${G}.id`,"duplicate-ref-id",`Node ${d}: duplicate ref id "${V}"`):g.add(V),(typeof N.url!="string"||!N.url.trim())&&t(`${G}.url`,"ref-url-required",`Node ${d}: ref "${V}" is missing a url`),N.status_mapped!==void 0&&!ne.includes(N.status_mapped)&&t(`${G}.status_mapped`,"valid-status",`Node ${d}: ref "${V}" has invalid status_mapped "${N.status_mapped}"`)})}if(w.decision_status!==void 0&&f!=="decision"&&r(`${a}.metadata.decision_status`,"decision-status-wrong-species",`decision_status is meaningful on decision nodes only; "${d}" is a ${f}.`),f==="decision"){let g=Ce({metadata:s.metadata}),S=Oe(g);s.status!==S&&r(`${a}.status`,"decision-lifecycle-mismatch",`Decision "${d}" is ${g}, whose lifecycle status should be "${S}", but status is "${s.status}" (spec \xA72).`)}if(f==="flow"){let g=w.playlist;!s.metadata||!g||!g.entries?t(`${a}.metadata.playlist`,"flow-playlist-required",`Flow ${d}: missing metadata.playlist.entries`):g.entries.length===0&&r(`${a}.metadata.playlist`,"flow-playlist-empty",`Flow ${d}: playlist is empty`)}});let J=b.root_node_id;J&&!F.has(J)&&t("project.root_node_id","root-node-exists",`project.root_node_id "${J}" does not reference an existing node`);let B=(s,u,a)=>{if(typeof s!="object"||s===null||Array.isArray(s))return;let d=s,f=[["flow_platforms",Je],["view_platforms",qe],["minimap_color",Be]];for(let[p,y]of f){let w=d[p];w!==void 0&&(typeof w!="string"||!y.includes(w))&&r(`${u}.${p}`,"map-unknown-display",`${a} sets ${p} to "${String(w)}"; expected one of ${y.join(", ")} (renderers fall back to the default)`)}d.images!==void 0&&typeof d.images!="boolean"&&r(`${u}.images`,"map-unknown-display",`${a} sets images to a non-boolean value (renderers fall back to the default)`)},n=W?.map_display;if(typeof n=="object"&&n!==null&&!Array.isArray(n))for(let[s,u]of Object.entries(n))B(u,`project.metadata.map_display.${s}`,`Map "${s}"`);let T=W?.maps;if(Array.isArray(T)){let s=new Set;T.forEach((u,a)=>{if(typeof u!="object"||u===null||Array.isArray(u))return;let d=u,f=`project.metadata.maps[${a}]`,p=typeof d.id=="string"?d.id:void 0;p!==void 0&&(s.has(p)&&r(`${f}.id`,"map-duplicate-id",`Duplicate map id "${p}"`),s.add(p),Ke(p)&&r(`${f}.id`,"map-shadows-built-in",`Map id "${p}" shadows a built-in map and will be ignored`));let y=d.root_node_id;typeof y=="string"&&!F.has(y)&&r(`${f}.root_node_id`,"map-unknown-root",`Map "${p??a}" anchors on "${y}" which does not reference an existing node`),Array.isArray(d.species)&&d.species.forEach((w,I)=>{typeof w=="string"&&!ue.includes(w)&&r(`${f}.species[${I}]`,"map-unknown-species",`Map "${p??a}" filters on unknown species "${w}"`)}),Array.isArray(d.edge_types)&&d.edge_types.forEach((w,I)=>{typeof w=="string"&&!ye.includes(w)&&r(`${f}.edge_types[${I}]`,"map-unknown-edge-type",`Map "${p??a}" filters on unknown edge type "${w}"`)}),B(d.display,`${f}.display`,`Map "${p??a}"`)})}let i=W?.products,c=new Set;if(Array.isArray(i)){let s=new Set;i.forEach((u,a)=>{if(typeof u!="object"||u===null||Array.isArray(u))return;let d=u,f=`project.metadata.products[${a}]`,p=typeof d.id=="string"?d.id:void 0;p!==void 0&&(s.has(p)?r(`${f}.id`,"product-duplicate-id",`Duplicate product id "${p}" \u2014 the first wins`):(s.add(p),p.trim()!==""&&c.add(p)),/^[a-z0-9]+(-[a-z0-9]+)*$/.test(p)||r(`${f}.id`,"product-invalid-id",`Product id "${p}" is not kebab-case`))})}let v=c.size>0,h=new Map;for(let s of U){if(s.edge_type!=="covers")continue;let u=typeof s.source_id=="string"?s.source_id:void 0,a=typeof s.target_id=="string"?s.target_id:void 0;if(u===void 0||a===void 0)continue;let d=h.get(u)??[];d.push(a),h.set(u,d)}let $=new Map;if(v)for(let s of Ue({metadata:W}))$.set(s.id,new Set(Array.isArray(s.platforms)?s.platforms:[]));let x=new Map,Y=new Map;if(j.forEach((s,u)=>{let a=typeof s.id=="string"?s.id:`#${u}`,d=s.species,f=`nodes[${u}]`;Y.set(a,u);let p=s.metadata??{},y=typeof p.product=="string"?p.product:void 0,w=d!==void 0&&Ve.includes(d);if(y!==void 0&&!w){let O=ue.includes(d)?`${d} membership is derived from consumers and must not be stored`:"metadata.product is only meaningful on flow, view, and acceptance nodes";r(`${f}.metadata.product`,"product-membership-wrong-species",`Node ${a}: ${O}`);return}if(!w)return;if(y===void 0){if(!v)return;d==="acceptance"?h.has(a)||r(`${f}.metadata.product`,"acceptance-product-unassigned",`Acceptance ${a} covers nothing and names no product \u2014 it will show only under "All products"`):r(`${f}.metadata.product`,"unassigned-membership",`Node ${a}: no product membership \u2014 it will show only under "All products"`);return}if(x.set(a,y),!c.has(y)){r(`${f}.metadata.product`,"product-unknown-reference",`Node ${a}: product "${y}" is not declared on the project`);return}let I=$.get(y),P=Array.isArray(s.platforms)?s.platforms:[];if(I)for(let O of P)typeof O=="string"&&!I.has(O)&&r(`${f}.platforms`,"product-platform-not-in-menu",`Node ${a}: platform "${O}" is not in product "${y}"'s menu`)}),v)for(let[s,u]of h){let a=Y.get(s);if(a===void 0)continue;let d=new Set(u.map(f=>x.get(f)).filter(f=>!!f));d.size>1&&r(`nodes[${a}].metadata.product`,"acceptance-covers-span-products",`Acceptance ${s} covers anchors in ${[...d].sort().join(" and ")} \u2014 statuses may conflate products`)}let q=new Set,D=new Set,Q=new Set;U.forEach((s,u)=>{let a=`edges[${u}]`,d=s.id,f=s.source_id,p=s.target_id,y=s.edge_type;q.has(d)&&t(`${a}.id`,"duplicate-edge-id",`Duplicate edge ID: ${d}`),q.add(d);let w=`e-${f}-${p}`;d!==w&&r(`${a}.id`,"edge-id-convention",`Edge ${d}: id does not match convention "${w}" (stale after a rename?)`);let I=`${f}->${p}:${y}`;D.has(I)&&r(`${a}`,"duplicate-edge-relationship",`Duplicate edge relationship: ${I}`),D.add(I),s.project_id!==b.id&&t(`${a}.project_id`,"project-id-match",`Edge ${d}: project_id does not match project.id`),F.has(f)||t(`${a}.source_id`,"dangling-edge",`Edge ${d}: source_id "${f}" not found in nodes`),F.has(p)||t(`${a}.target_id`,"dangling-edge",`Edge ${d}: target_id "${p}" not found in nodes`),ye.includes(y)||t(`${a}.edge_type`,"valid-edge-type",`Edge ${d}: invalid edge_type "${y}"`);let P=M.get(f),O=M.get(p),C=Te[y];P&&O&&C&&(C.some(([_,k])=>_===P.species&&k===O.species)||t(`${a}.edge_type`,"edge-semantics",`Edge ${d}: "${y}" not valid from ${P.species} to ${O.species}`)),y==="composes"&&Q.add(`${f}->${p}`)});let A=["view","flow","condition","junction"],X=(s,u,a,d=0)=>{if(!(d>50)){if(!Array.isArray(s)){t(a,"playlist-entry-shape",`Flow ${u}: ${a} must be an array of playlist entries`);return}s.forEach((f,p)=>{let y=`${a}[${p}]`;if(typeof f!="object"||f===null||Array.isArray(f)){t(y,"playlist-entry-shape",`Flow ${u}: ${y} must be a playlist entry object`);return}let w=f,I=w.type;if(typeof I!="string"||!A.includes(I)){t(`${y}.type`,"playlist-entry-shape",`Flow ${u}: ${y}.type must be one of ${A.join(", ")} (got ${JSON.stringify(I)})`);return}if(I==="view")typeof w.view_id!="string"&&t(`${y}.view_id`,"playlist-entry-shape",`Flow ${u}: ${y} is a view entry with no view_id string`);else if(I==="flow")typeof w.flow_id!="string"&&t(`${y}.flow_id`,"playlist-entry-shape",`Flow ${u}: ${y} is a flow entry with no flow_id string`);else if(I==="condition"){typeof w.label!="string"&&t(`${y}.label`,"playlist-entry-shape",`Flow ${u}: ${y} is a condition with no label string`);for(let P of["if_true","if_false"])Array.isArray(w[P])?X(w[P],u,`${y}.${P}`,d+1):t(`${y}.${P}`,"playlist-entry-shape",`Flow ${u}: ${y}.${P} must be an array of playlist entries (both branches are required, use [] for an empty one)`)}else{if(typeof w.label!="string"&&t(`${y}.label`,"playlist-entry-shape",`Flow ${u}: ${y} is a junction with no label string`),!Array.isArray(w.cases)){t(`${y}.cases`,"playlist-entry-shape",`Flow ${u}: ${y}.cases must be an array of junction cases`);return}w.cases.forEach((P,O)=>{let C=`${y}.cases[${O}]`;if(typeof P!="object"||P===null||Array.isArray(P)){t(C,"playlist-entry-shape",`Flow ${u}: ${C} must be a junction case object`);return}let K=P;typeof K.label!="string"&&t(`${C}.label`,"playlist-entry-shape",`Flow ${u}: ${C} has no label string`),Array.isArray(K.entries)?X(K.entries,u,`${C}.entries`,d+1):t(`${C}.entries`,"playlist-entry-shape",`Flow ${u}: ${C}.entries must be an array of playlist entries \u2014 a junction case holds its own entries, not a bare view_id/flow_id`)})}})}};j.forEach((s,u)=>{let a=s.metadata;s.species==="flow"&&a?.playlist?.entries&&X(a.playlist.entries,s.id,`nodes[${u}].metadata.playlist.entries`)});let Z=(s,u,a,d=0)=>{if(d>50)return t(a,"playlist-depth",`Flow ${u}: playlist nesting too deep (possible cycle)`),[];let f=[];if(!Array.isArray(s))return f;for(let p of s)if(!(typeof p!="object"||p===null)){if(p.type==="view")F.has(p.view_id)||t(a,"playlist-ref-exists",`Flow ${u}: playlist references non-existent view "${p.view_id}"`),f.push(p.view_id);else if(p.type==="flow")F.has(p.flow_id)||t(a,"playlist-ref-exists",`Flow ${u}: playlist references non-existent flow "${p.flow_id}"`),p.flow_id===u&&t(a,"playlist-self-cycle",`Flow ${u}: playlist contains itself (direct cycle)`),f.push(p.flow_id);else if(p.type==="condition")p.if_true&&f.push(...Z(p.if_true,u,a,d+1)),p.if_false&&f.push(...Z(p.if_false,u,a,d+1));else if(p.type==="junction"&&p.cases)for(let y of p.cases)f.push(...Z(y.entries||[],u,a,d+1))}return f};j.forEach((s,u)=>{let a=s.metadata;if(s.species==="flow"&&a?.playlist?.entries){let d=`nodes[${u}].metadata.playlist`,f=s.id,p=Z(a.playlist.entries,f,d);for(let y of p)Q.has(`${f}->${y}`)||t(d,"playlist-composes-coherence",`Flow ${f}: playlist references "${y}" but no composes edge exists`)}});let me=new Map,Re=new Map;j.forEach((s,u)=>{let a=s.metadata;if(s.species==="flow"&&a?.playlist?.entries){let d=s.id,f=[],p=y=>{if(Array.isArray(y)){for(let w of y)if(!(typeof w!="object"||w===null)&&(w.type==="flow"&&f.push(w.flow_id),w.type==="condition"&&(w.if_true&&p(w.if_true),w.if_false&&p(w.if_false)),w.type==="junction"&&w.cases))for(let I of w.cases)p(I.entries||[])}};p(a.playlist.entries),me.set(d,f),Re.set(d,`nodes[${u}].metadata.playlist`)}});let je=new Set,he=new Set,Me=s=>{if(he.has(s))return!0;if(je.has(s))return!1;je.add(s),he.add(s);for(let u of me.get(s)||[])if(Me(u))return t(Re.get(s)??"","flow-cycle",`Cycle detected: flow "${s}" -> "${u}"`),!0;return he.delete(s),!1};for(let s of me.keys())Me(s);let le=m.quality;if(typeof le=="object"&&le!==null&&!Array.isArray(le)){let s=le,u=Array.isArray(s.assessments)?s.assessments:[],a=Array.isArray(s.findings)?s.findings:[],d=typeof s.profile=="object"&&s.profile!==null?s.profile:void 0,f=new Set;Array.isArray(d?.surfaces)&&d.surfaces.forEach((_,k)=>{if(typeof _!="object"||_===null||Array.isArray(_))return;let g=_,S=typeof g.id=="string"?g.id:void 0;S===void 0||S.trim()===""||(f.has(S)&&r(`quality.profile.surfaces[${k}].id`,"quality-duplicate-surface",`Duplicate surface id "${S}" \u2014 the first wins`),f.add(S))}),f.size===0&&(u.length>0||a.length>0)&&r("quality.profile.surfaces","quality-no-surfaces","Quality data is stored but the profile declares no surfaces \u2014 the matrix falls back to the surfaces the assessments name");let p=typeof s.library=="object"&&s.library!==null?s.library:void 0,y=new Set,w=new Map;if(Array.isArray(p?.criteria))for(let _ of p.criteria){if(typeof _!="object"||_===null)continue;let k=_;typeof k.id=="string"&&(y.add(k.id),typeof k.superseded_by=="string"&&k.superseded_by!==""&&w.set(k.id,k.superseded_by))}else(u.length>0||a.length>0)&&r("quality.library","quality-library-missing","No criteria pack is embedded \u2014 criterion ids cannot be resolved to domains or weights; the matrix uses a synthesized library");(typeof s.framework_version!="string"||s.framework_version==="")&&r("quality.framework_version","quality-framework-version-missing","Quality section has no framework_version \u2014 scores are not comparable across audits without one");let I=(_,k,g)=>{let S=typeof _.criterion_id=="string"?_.criterion_id:void 0;S!==void 0&&y.size>0&&!y.has(S)&&r(`${k}.criterion_id`,"quality-unknown-criterion",`${g}: criterion "${S}" is not in the pinned library`);let L=S!==void 0?w.get(S):void 0;L!==void 0&&r(`${k}.criterion_id`,"quality-retired-criterion",`${g}: criterion "${S}" is retired \u2014 superseded by "${L}"`);let N=typeof _.surface=="string"?_.surface:void 0;N!==void 0&&N!==pe&&f.size>0&&!f.has(N)&&r(`${k}.surface`,"quality-unknown-surface",`${g}: surface "${N}" is not declared in the profile`)},P=new Set;u.forEach((_,k)=>{if(typeof _!="object"||_===null||Array.isArray(_))return;let g=_,S=`quality.assessments[${k}]`,L=`Assessment ${k}`;I(g,S,L);let N=g.level;(typeof N!="number"||!Number.isInteger(N)||N<0||N>4)&&r(`${S}.level`,"quality-level-range",`${L}: level must be an integer 0-4 (N/A is the absence of the row, not a level)`),g.surface===pe&&r(`${S}.surface`,"quality-cross-surface-assessment",`${L}: "${pe}" is a findings-only lens \u2014 it carries no matrix column, so this score would render nowhere`),(typeof g.evidence!="string"||g.evidence.trim()==="")&&r(`${S}.evidence`,"quality-assessment-no-evidence",`${L}: scored with no evidence \u2014 a score without a citation is an opinion, not an assessment`);let G=typeof g.criterion_id=="string"?g.criterion_id:void 0,V=typeof g.surface=="string"?g.surface:void 0;if(G!==void 0&&V!==void 0){let Ne=`${G}\0${V}`;P.has(Ne)&&r(`${S}`,"quality-duplicate-assessment",`${L}: a second score for (${G} x ${V}) \u2014 the section stores latest-per-cell, so this cell is ambiguous`),P.add(Ne)}});let O=new Set;a.forEach((_,k)=>{if(typeof _!="object"||_===null||Array.isArray(_))return;let g=_,S=`quality.findings[${k}]`,L=`Finding ${k}`;I(g,S,L);let N=typeof g.id=="string"?g.id:void 0;N!==void 0&&(O.has(N)&&r(`${S}.id`,"quality-duplicate-finding-id",`Duplicate finding id "${N}"`),O.add(N));for(let G of["impact","likelihood"]){let V=g[G];(typeof V!="number"||!Number.isInteger(V)||V<1||V>5)&&r(`${S}.${G}`,"quality-risk-range",`${L}: ${G} must be an integer 1-5 \u2014 severity is derived from impact x likelihood`)}for(let G of["severity","priority"])G in g&&r(`${S}.${G}`,"quality-derived-field-stored",`${L}: ${G} is derived from impact, likelihood and cost \u2014 storing it lets it drift from the numbers behind it`);g.status==="accepted-risk"&&(typeof g.detail!="string"||g.detail.trim()==="")&&r(`${S}.detail`,"quality-accepted-risk-no-note",`${L}: accepted-risk with no note \u2014 an accepted risk is a decision and reads like one`)});let C=new Set,K=Array.isArray(m.journal)?m.journal:[];K.forEach(_=>{if(typeof _!="object"||_===null)return;let k=_;k.type==="quality.finding.opened"&&typeof k.finding_id=="string"&&C.add(k.finding_id)}),K.forEach((_,k)=>{if(typeof _!="object"||_===null)return;let g=_,S=typeof g.type=="string"?g.type:"";S.startsWith("quality.")&&((typeof g.actor!="string"||g.actor.trim()==="")&&r(`journal[${k}].actor`,"quality-event-no-actor",`Journal event ${k}: ${S} has no actor \u2014 human, agent and CI scores become indistinguishable`),S==="quality.finding.resolved"&&typeof g.finding_id=="string"&&!C.has(g.finding_id)&&!O.has(g.finding_id)&&r(`journal[${k}].finding_id`,"quality-resolved-never-opened",`Journal event ${k}: resolves finding "${g.finding_id}", which no quality.finding.opened event or stored finding ever declared`),S==="quality.finding.accepted"&&typeof g.finding_id=="string"&&!C.has(g.finding_id)&&!O.has(g.finding_id)&&r(`journal[${k}].finding_id`,"quality-accepted-never-opened",`Journal event ${k}: accepts finding "${g.finding_id}", which no quality.finding.opened event or stored finding ever declared`))})}let gt=m.weighing,mt=Array.isArray(m.journal)?m.journal:[],Pe=new Map;for(let[s,u]of M)Pe.set(s,String(u.species));for(let s of dt(gt,Pe,mt))r(s.path,s.rule,s.message);for(let s of Ge(m))o.push(s);return l()}var ft="journal.jsonl",Dt="journal";function Ot(e){let o=(0,te.join)(e,Dt);return(0,z.existsSync)(o)?(0,z.readdirSync)(o).filter(t=>t.startsWith("archive-")&&t.endsWith(".jsonl")).sort().map(t=>(0,te.join)(o,t)):[]}function ce(e,o){return e.filter(t=>t?.species===o).length}function Ct(){let e=process.argv[2];e||(console.error("Usage: node validate-bundle.js <path-to-bundle.json>"),process.exit(1)),(0,z.existsSync)(e)||(console.error(`File not found: ${e}`),process.exit(1));let o;try{o=JSON.parse((0,z.readFileSync)(e,"utf8"))}catch(M){console.error(`FATAL: Cannot parse JSON \u2014 ${M.message}`),process.exit(1)}let t=o;(typeof t!="object"||t===null||!t.project||!t.nodes||!t.edges)&&(console.error("FATAL: Missing top-level keys (project, nodes, edges)."),process.exit(1));let r=[],l=!1,m=[];if(t.journal===void 0){let M=(0,te.dirname)(e),F=(0,te.join)(M,ft),W=[];if((0,z.existsSync)(F)){let{events:J,findings:B}=Se((0,z.readFileSync)(F,"utf8"));for(let n of B)r.push(n.message);l=!0,W.push(...J)}for(let J of Ot(M)){let B=(0,te.basename)(J),{events:n,findings:T}=Se((0,z.readFileSync)(J,"utf8"));for(let i of T)r.push(`${B} \u2014 ${i.message}`);m.push(B),W.push(...n)}(l||m.length>0)&&(t.journal=W)}let b=Array.isArray(t.nodes)?t.nodes:[],E=Array.isArray(t.edges)?t.edges:[],R=Array.isArray(t.journal)?t.journal:[],j=pt(o);if(console.log(`
14
14
  Arkaik Bundle Validation`),console.log(` =======================
15
- `),console.log(` Nodes: ${S.length} (${oe(S,"view")} views, ${oe(S,"flow")} flows, ${oe(S,"data-model")} data-models, ${oe(S,"api-endpoint")} api-endpoints, ${oe(S,"acceptance")} acceptances)`),console.log(` Edges: ${x.length}`),u||y.length>0){let R=[...u?[`${dt} sidecar`]:[],...y.length>0?[`${y.length} archive(s)`]:[]].join(" + ");console.log(` Journal: ${M.length} event(s) from ${R}`)}else M.length>0&&console.log(` Journal: ${M.length} embedded event(s)`);console.log(""),I.warnings.length>0&&(console.log(` Warnings: ${I.warnings.length}`),I.warnings.forEach(R=>console.log(` WARN: ${R.message}`)),console.log(""));let G=[...r,...I.errors.map(R=>R.message)];G.length===0&&(console.log(` Result: VALID
16
- `),process.exit(0)),console.log(` Errors: ${G.length}`),G.forEach(R=>console.log(` ERROR: ${R}`)),console.log(`
15
+ `),console.log(` Nodes: ${b.length} (${ce(b,"view")} views, ${ce(b,"flow")} flows, ${ce(b,"data-model")} data-models, ${ce(b,"api-endpoint")} api-endpoints, ${ce(b,"acceptance")} acceptances)`),console.log(` Edges: ${E.length}`),l||m.length>0){let M=[...l?[`${ft} sidecar`]:[],...m.length>0?[`${m.length} archive(s)`]:[]].join(" + ");console.log(` Journal: ${R.length} event(s) from ${M}`)}else R.length>0&&console.log(` Journal: ${R.length} embedded event(s)`);console.log(""),j.warnings.length>0&&(console.log(` Warnings: ${j.warnings.length}`),j.warnings.forEach(M=>console.log(` WARN: ${M.message}`)),console.log(""));let U=[...r,...j.errors.map(M=>M.message)];U.length===0&&(console.log(` Result: VALID
16
+ `),process.exit(0)),console.log(` Errors: ${U.length}`),U.forEach(M=>console.log(` ERROR: ${M}`)),console.log(`
17
17
  Result: INVALID
18
- `),process.exit(1)}At();
18
+ `),process.exit(1)}Ct();