dic-workflow-kit 1.1.1 → 1.1.3

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.
@@ -1,10 +1,18 @@
1
1
  #!/usr/bin/env node
2
- import{cp as A,mkdir as w,readFile as y,readdir as g,writeFile as E}from"node:fs/promises";import{homedir as f}from"node:os";import{dirname as x,join as n,resolve as m}from"node:path";import{fileURLToPath as N}from"node:url";var h="dic-workflow-kit",p=m(x(N(import.meta.url)),".."),j=new Map([["codex","codex"],["claude","claude-code"],["claude-code","claude-code"],["opencode","opencode"],["mimo","mimo-code"],["mimocode","mimo-code"],["mimo-code","mimo-code"]]),L=[".codex-plugin","adapters","agents","schemas","skills","INSTRUCTION.md"];function u(e,o,t){let r=e[o+1];if(!r)throw new Error(`${t} requires a value`);return r}function C(e){let o=e[0]??"help",t="codex",r="user",c,a,s=process.cwd(),d=!1;for(let i=1;i<e.length;i+=1){let l=e[i];if(l==="--host"){let k=u(e,i,l).toLowerCase();if(t=j.get(k),!t)throw new Error(`unsupported host: ${k}; expected codex, claude-code, opencode, or mimo-code`);i+=1}else if(l==="--scope"){if(r=u(e,i,l).toLowerCase(),!["user","project"].includes(r))throw new Error("--scope must be user or project");i+=1}else if(l==="--install-root")c=m(u(e,i,l)),i+=1;else if(l==="--project-root")s=m(u(e,i,l)),i+=1;else if(l==="--marketplace-root")a=m(u(e,i,l)),i+=1;else if(l==="--dry-run")d=!0;else throw new Error(`unknown argument: ${l}`)}if(t!=="codex"&&a)throw new Error("--marketplace-root is only valid for --host codex");if(t==="codex"&&r==="project")throw new Error("Codex plugin installation supports user scope only");return{command:o,host:t,scope:r,installRoot:c,marketplaceRoot:a,projectRoot:s,dryRun:d}}function O({host:e,scope:o,projectRoot:t}){if(o==="project"){let r={"claude-code":".claude",opencode:".opencode","mimo-code":".mimocode"}[e];return n(t,r)}return e==="claude-code"?n(f(),".claude"):e==="opencode"?n(process.env.XDG_CONFIG_HOME||n(f(),".config"),"opencode"):e==="mimo-code"?process.env.MIMOCODE_HOME?m(process.env.MIMOCODE_HOME):process.platform==="win32"&&process.env.LOCALAPPDATA?n(process.env.LOCALAPPDATA,"mimocode"):n(process.env.XDG_CONFIG_HOME||n(f(),".config"),"mimocode"):n(f(),".agents","plugins")}async function v(e){try{let o=JSON.parse(await y(e,"utf8"));if(!o||typeof o!="object"||Array.isArray(o))throw new Error("marketplace.json must contain an object");if(!Array.isArray(o.plugins))throw new Error("marketplace.json must contain a plugins array");return o}catch(o){if(o?.code!=="ENOENT")throw o;return{name:"personal",interface:{displayName:"Personal"},plugins:[]}}}function S(){return{name:h,source:{source:"local",path:`./plugins/${h}`},policy:{installation:"AVAILABLE",authentication:"ON_INSTALL"},category:"Developer Tools"}}async function T(e){let o=e.marketplaceRoot||e.installRoot||O(e),t=n(o,"marketplace.json"),r=n(o,"plugins",h),c=await v(t),a=S(),s=c.plugins.findIndex(d=>d?.name===h);if(s>=0?c.plugins[s]=a:c.plugins.push(a),!e.dryRun){await w(r,{recursive:!0});for(let d of L)await A(n(p,d),n(r,d),{recursive:!0,force:!0});await w(o,{recursive:!0}),await E(t,`${JSON.stringify(c,null,2)}
3
- `,"utf8")}R({...e,root:r,skillsRoot:n(r,"skills"),agentsRoot:n(r,"agents"),extra:`MARKETPLACE: ${t}`})}function I(e,o){let t=e.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n/);if(!t)return e;let r=o==="claude-code"?new Set(["name","description","tools","disallowedTools","model","permissionMode","skills","memory","background","isolation"]):new Set(["name","description","mode","model","temperature","top_p","tools","permission","steps","hidden","color"]);return`---
4
- ${t[1].split(/\r?\n/).filter(a=>{let s=a.match(/^([A-Za-z][A-Za-z0-9_-]*):/)?.[1];return!s||r.has(s)}).join(`
2
+ import{createHash as Be}from"node:crypto";import{mkdir as ce,lstat as ye,readFile as q,readdir as Ge,rename as me,rm as B,rmdir as St,stat as Je,writeFile as le}from"node:fs/promises";import{homedir as V}from"node:os";import{dirname as M,isAbsolute as Ye,join as w,relative as ze,resolve as E,sep as vt}from"node:path";import{fileURLToPath as At}from"node:url";import{createHash as Ne}from"node:crypto";import{appendFile as lt,readFile as ne,realpath as Pe,stat as dt}from"node:fs/promises";import{isAbsolute as pt,relative as ut,resolve as Y}from"node:path";var ft=new Map([["workflow-intake",new Set(["IntakeDesignSource"])],["spec-reader",new Set(["IntakeDesignSource"])],["contract-oracle",new Set(["ConfirmObligation"])],["impl-inspector",new Set(["ObserveImplementation","OpenGap"])],["repair-planner",new Set(["ProposeRepair"])],["final-reviewer",new Set(["ApproveRepair","CloseGap","MarkBlocked","SupersedeSource"])],["code-repairer",new Set(["ApplyRepair"])],["validation-runner",new Set(["RunValidation","AttachEvidence"])]]),$e=new Map([["IntakeDesignSource",new Set(["Project","DesignSource","Change"])],["ConfirmObligation",new Set(["Requirement","Scenario"])],["ObserveImplementation",new Set(["Requirement","Scenario"])],["OpenGap",new Set(["Requirement","Scenario"])],["ProposeRepair",new Set(["Gap"])],["ApproveRepair",new Set(["RepairAction"])],["ApplyRepair",new Set(["RepairAction"])],["RunValidation",new Set(["Requirement","Scenario","RepairAction"])],["AttachEvidence",new Set(["Validation"])],["CloseGap",new Set(["Gap"])],["MarkBlocked",new Set(["Gap","RepairAction","Validation"])],["SupersedeSource",new Set(["DesignSource","Change","Requirement","Scenario"])]]),ht=new Set(["ApplyRepair","RunValidation","AttachEvidence","ObserveImplementation","CloseGap","MarkBlocked","SupersedeSource"]),yt=new Map([["IntakeDesignSource",{objectTypes:new Set(["DesignSource","Change"]),linkTypes:new Set(["CONTAINS"]),lifecycle:new Set(["draft","active"])}],["ConfirmObligation",{objectTypes:new Set,linkTypes:new Set,lifecycle:new Set(["confirmed"])}],["OpenGap",{objectTypes:new Set(["Gap"]),linkTypes:new Set(["VIOLATES"]),lifecycle:new Set}],["ObserveImplementation",{objectTypes:new Set(["ImplementationUnit"]),linkTypes:new Set(["IMPLEMENTED_BY"]),lifecycle:new Set}],["ProposeRepair",{objectTypes:new Set(["RepairAction"]),linkTypes:new Set(["RESOLVES"]),lifecycle:new Set}],["ApproveRepair",{objectTypes:new Set,linkTypes:new Set,lifecycle:new Set(["approved"])}],["ApplyRepair",{objectTypes:new Set(["ImplementationUnit"]),linkTypes:new Set(["IMPLEMENTED_BY"]),lifecycle:new Set(["in_progress","resolved"])}],["RunValidation",{objectTypes:new Set(["Validation"]),linkTypes:new Set(["VERIFIED_BY"]),lifecycle:new Set}],["AttachEvidence",{objectTypes:new Set(["Evidence"]),linkTypes:new Set(["PRODUCES"]),lifecycle:new Set}],["CloseGap",{objectTypes:new Set,linkTypes:new Set,lifecycle:new Set(["resolved"])}],["MarkBlocked",{objectTypes:new Set,linkTypes:new Set,lifecycle:new Set(["blocked"])}],["SupersedeSource",{objectTypes:new Set(["DesignSource","Change","Requirement","Scenario"]),linkTypes:new Set(["SUPERSEDES"]),lifecycle:new Set(["superseded"])}]]);function N(e,t,n,i,o=[]){return{id:e,status:t===null?"NOT_APPLICABLE":t?"PASS":"FAIL",severity:n,message:i,objectIds:[...new Set(o)].sort()}}function C(e){return Array.isArray(e)?e.map(C):e&&typeof e=="object"?Object.fromEntries(Object.keys(e).sort().map(t=>[t,C(e[t])])):e}function ue(e){let t=Object.fromEntries(Object.entries(e??{}).filter(([n])=>!["snapshotRevision","invariantResults"].includes(n)));return Ne("sha256").update(JSON.stringify(C(t))).digest("hex")}function mt(e,t){let n=Array.isArray(e?.objects)?e.objects:[],i=Array.isArray(e?.links)?e.links:[],o=new Map(n.map(l=>[l.id,l])),a=new Set,c=[...t];for(;c.length>0;){let l=c.pop(),p=o.get(l);if(p){if(["Requirement","Scenario"].includes(p.type)){if(a.has(l))continue;if(a.add(l),p.type==="Scenario")for(let s of i)s.type==="REFINES"&&s.from===l&&c.push(s.to)}else if(p.type==="RepairAction"){let s=new Set(i.filter(r=>r.type==="RESOLVES"&&r.from===l).map(r=>r.to));for(let r of i)r.type==="VIOLATES"&&s.has(r.from)&&c.push(r.to)}}}return a}function Ce(e,t){let n=Array.isArray(e?.objects)?e.objects:[],i=Array.isArray(e?.links)?e.links:[],o=new Map(n.map(l=>[l.id,l])),a=mt(e,t),c=new Set;for(let l of i)if(a.has(l.from)&&["DERIVED_FROM","IMPLEMENTED_BY"].includes(l.type)){let p=o.get(l.to);["DesignSource","ImplementationUnit"].includes(p?.type)&&c.add(l.to)}return[...c].sort().map(l=>({objectId:l,contentHash:o.get(l)?.provenance?.contentHash??""}))}function z(e){let t=Array.isArray(e?.objects)?e.objects:[],n=Array.isArray(e?.links)?e.links:[];return t.filter(o=>o.type==="Validation").map(o=>{let a=n.filter(I=>I.type==="VERIFIED_BY"&&I.to===o.id).map(I=>I.from),c=a.length>0,l=Ce(e,a),p=Array.isArray(o.properties?.inputs)?o.properties.inputs:[],s=new Map,r=[];for(let I of p)s.has(I?.objectId)?r.push(I?.objectId):s.set(I?.objectId,I?.contentHash);let d=l.filter(I=>!s.has(I.objectId)).map(I=>I.objectId),m=l.filter(I=>s.has(I.objectId)&&s.get(I.objectId)!==I.contentHash).map(I=>I.objectId),h=typeof o.properties?.executedAt!="string"||Number.isNaN(Date.parse(o.properties.executedAt)),S="CURRENT";return r.length>0||h?S="INVALID":m.length>0?S="STALE":d.length>0&&(S="INCOMPLETE"),{id:o.id,required:c,status:S,targetIds:[...new Set(a)].sort(),requiredInputIds:l.map(I=>I.objectId),missingInputIds:d,staleInputIds:m,duplicateInputIds:r}})}function oe(e,t=""){let n=Array.isArray(e?.objects)?e.objects:[],i=Array.isArray(e?.links)?e.links:[],o=n.map(u=>u.id),a=new Map(n.map(u=>[u.id,u])),c=new Set(o),l=[...new Set(o.filter((u,L)=>o.indexOf(u)!==L))],p=[N("ontology.snapshot.schema",e?.schema==="dic.ontology-snapshot.v1","blocking","Ontology snapshot must declare dic.ontology-snapshot.v1."),N("ontology.snapshot.revision",e?.snapshotRevision?e.snapshotRevision===ue(e):null,"blocking","Snapshot revision must match its canonical semantic content."),N("ontology.object-ids.unique",l.length===0,"blocking","Every ontology object must have a unique stable ID.",l)],s=i.filter(u=>!c.has(u.from)||!c.has(u.to)).map(u=>u.id);p.push(N("ontology.links.resolve",s.length===0,"blocking","Every link endpoint must resolve to an object in the snapshot.",s));let r=new Map([["CONTAINS",[new Set(["Project"]),null]],["PROPOSES",[new Set(["Change"]),new Set(["Requirement","Scenario"])]],["DERIVED_FROM",[new Set(["Requirement","Scenario"]),new Set(["DesignSource"])]],["REFINES",[new Set(["Scenario"]),new Set(["Requirement"])]],["IMPLEMENTED_BY",[new Set(["Requirement","Scenario"]),new Set(["ImplementationUnit"])]],["VERIFIED_BY",[new Set(["Requirement","Scenario","RepairAction"]),new Set(["Validation"])]],["VIOLATES",[new Set(["Gap"]),new Set(["Requirement","Scenario"])]],["RESOLVES",[new Set(["RepairAction"]),new Set(["Gap"])]],["PRODUCES",[new Set(["Validation","AgentRun"]),new Set(["Evidence"])]],["SUPPORTS",[new Set(["Evidence"]),new Set(["Decision"])]],["CONTRADICTS",[new Set(["Evidence"]),new Set(["Decision"])]],["REMAINS_AFTER",[new Set(["Risk"]),new Set(["RepairAction"])]]]),d=[];for(let u of i){let L=a.get(u.from),de=a.get(u.to);if(!L||!de)continue;let pe=!1;if(u.type==="SUPERSEDES")pe=L.type===de.type;else{let ee=r.get(u.type);pe=!!(ee&&ee[0].has(L.type)&&(ee[1]===null||ee[1].has(de.type)))}pe||d.push(u.id)}p.push(N("ontology.links.type-compatible",d.length===0,"blocking","Every link must satisfy its object-type domain and range contract.",d));let m=n.filter(u=>["Requirement","Scenario"].includes(u.type)&&["confirmed","active"].includes(u.lifecycle)),h=new Set(i.filter(u=>u.type==="DERIVED_FROM").map(u=>u.from)),S=m.filter(u=>!h.has(u.id)).map(u=>u.id);p.push(N("obligation.active.has-source",S.length===0,"blocking","Every active obligation must link to a source-backed design object.",S));let I=new Set(i.filter(u=>u.type==="REFINES").map(u=>u.from)),v=m.filter(u=>u.type==="Scenario"&&!I.has(u.id)).map(u=>u.id);p.push(N("scenario.active.refines-requirement",v.length===0,"blocking","Every active scenario must refine a requirement.",v));let y=n.filter(u=>u.type==="Gap"&&u.lifecycle==="resolved"),f=new Map(i.filter(u=>u.type==="RESOLVES").map(u=>[u.to,u.from])),k=new Set(n.filter(u=>u.type==="Validation"&&["active","confirmed","resolved"].includes(u.lifecycle)&&u.properties?.status==="PASS").map(u=>u.id)),P=i.filter(u=>u.type==="VERIFIED_BY"),A=new Set(P.filter(u=>k.has(u.to)).map(u=>u.from)),g=y.filter(u=>{let L=f.get(u.id);return!L||!A.has(L)}).map(u=>u.id);p.push(N("gap.resolved.has-verified-repair",g.length===0,"blocking","Every resolved gap must have a resolving repair action with validation.",g));let b=t.toUpperCase()==="PASS";p.push(N("pass.obligations.nonempty",b?m.length>0:null,"blocking","PASS requires at least one active, source-backed obligation."));let D=new Set(n.filter(u=>u.type==="ImplementationUnit"&&["active","confirmed","resolved"].includes(u.lifecycle)).map(u=>u.id)),Ae=i.filter(u=>u.type==="IMPLEMENTED_BY"),at=new Set(Ae.filter(u=>D.has(u.to)).map(u=>u.from)),Ie=Ae.filter(u=>!D.has(u.to)).map(u=>u.to);p.push(N("pass.implementations.current",b?Ie.length===0:null,"blocking","PASS requires every referenced ImplementationUnit to have a current lifecycle.",b?Ie:[]));let ke=m.filter(u=>u.type==="Requirement"&&!at.has(u.id)).map(u=>u.id);p.push(N("pass.requirements.implemented",b?ke.length===0:null,"blocking","PASS requires every active requirement to have an implementation disposition.",b?ke:[]));let Ee=m.filter(u=>!A.has(u.id)).map(u=>u.id);p.push(N("pass.obligations.verified",b?Ee.length===0:null,"blocking","PASS requires every active obligation to link to validation evidence.",b?Ee:[]));let be=P.filter(u=>!k.has(u.to)).map(u=>u.to);p.push(N("pass.validations.successful",b?be.length===0:null,"blocking","PASS requires every referenced Validation to be active and successful.",b?be:[]));let Re=z(e).filter(u=>u.required&&u.status!=="CURRENT").map(u=>u.id);p.push(N("pass.validations.inputs-current",b?Re.length===0:null,"blocking","PASS requires every referenced Validation to bind the current design and implementation content hashes.",b?Re:[]));let rt=new Set(P.filter(u=>k.has(u.to)).map(u=>u.to)),ct=new Set(i.filter(u=>u.type==="PRODUCES").map(u=>u.from)),je=[...rt].filter(u=>!ct.has(u));p.push(N("pass.validations.have-evidence",b?je.length===0:null,"blocking","PASS requires every referenced validation to produce durable evidence.",b?je:[]));let Oe=n.filter(u=>u.type==="Gap"&&!["resolved","rejected","superseded"].includes(u.lifecycle)&&u.properties?.severity==="blocking").map(u=>u.id);return p.push(N("pass.gaps.no-open-blocking",b?Oe.length===0:null,"blocking","PASS is forbidden while a blocking gap remains open.",b?Oe:[])),p}function G(e){return String(e??"").trim().toLowerCase()}function J(e,t){let n=ut(Y(t),Y(e));return n===""||!n.startsWith("..")&&!pt(n)}async function ie(e,t,n){let i=Y(e,t);if(!J(i,e))return{status:"OUTSIDE_PROJECT",actual:""};try{let[o,a]=await Promise.all([Pe(e),Pe(i)]);if(!J(a,o))return{status:"OUTSIDE_PROJECT",actual:""};if(!(await dt(a)).isFile())return{status:"INVALID",actual:""};let c=H(await ne(a));return{status:c===n?"UNCHANGED":"CHANGED",actual:c}}catch(o){if(o?.code==="ENOENT")return{status:"MISSING",actual:""};throw o}}function gt(e,t){let n=[],i=e?.parameters?.ontologyPatch;if(e?.status!=="completed")return i&&n.push("ontologyPatch is materialized only by a completed action"),n;if(!i||typeof i!="object"||Array.isArray(i))return["completed action requires parameters.ontologyPatch"];let o=Array.isArray(i.addObjects)?i.addObjects:[],a=Array.isArray(i.addLinks)?i.addLinks:[],c=Array.isArray(i.lifecycleTransitions)?i.lifecycleTransitions:[];o.length+a.length+c.length===0&&n.push("completed action ontologyPatch must contain at least one effect");let l=yt.get(e.type);if(!l)return[...n,`no ontology patch rule for ${e.type}`];let p=new Map((Array.isArray(t?.objects)?t.objects:[]).map(f=>[f.id,f])),s=new Map;for(let f of o){if(!f?.id||!f?.type){n.push("added ontology object requires id and type");continue}if(l.objectTypes.has(f.type)||n.push(`${e.type} cannot add object type ${f.type}`),(p.has(f.id)||s.has(f.id))&&n.push(`added ontology object ID already exists: ${f.id}`),G(f?.provenance?.createdBy)!==G(e.actor)&&n.push(`added object provenance actor mismatch: ${f.id}`),["AttachEvidence","ApplyRepair","ObserveImplementation"].includes(e.type)&&["Evidence","ImplementationUnit"].includes(f.type)){let k=f.type;(typeof f?.properties?.path!="string"||!f.properties.path)&&n.push(`${k} requires a project-relative artifact path: ${f.id}`),/^[a-f0-9]{64}$/u.test(f?.provenance?.contentHash??"")||n.push(`${k} requires a SHA-256 provenance contentHash: ${f.id}`),f?.interfaces?.includes("ContentAddressed")||n.push(`${k} requires the ContentAddressed interface: ${f.id}`)}s.set(f.id,f)}if(e.type==="RunValidation"){let f=Ce(t,e.targets);for(let k of s.values()){if(k.type!=="Validation")continue;["PASS","FAIL","BLOCKED"].includes(k.properties?.status)||n.push(`Validation requires status PASS, FAIL, or BLOCKED: ${k.id}`),(typeof k.properties?.executedAt!="string"||Number.isNaN(Date.parse(k.properties.executedAt)))&&n.push(`Validation requires a valid executedAt timestamp: ${k.id}`);let P=k.properties?.inputs;if(!Array.isArray(P)){n.push(`Validation requires an inputs array: ${k.id}`);continue}let A=P.map(g=>g?.objectId);new Set(A).size!==A.length&&n.push(`Validation inputs must use unique objectId values: ${k.id}`);for(let g of P)(typeof g?.objectId!="string"||!/^[a-f0-9]{64}$/u.test(g?.contentHash??""))&&n.push(`Validation input requires objectId and SHA-256 contentHash: ${k.id}`);if(k.properties?.status==="PASS"){let g=new Map(P.map(D=>[D?.objectId,D?.contentHash])),b=f.filter(D=>g.get(D.objectId)!==D.contentHash);b.length>0&&n.push(`PASS Validation must bind current design and implementation inputs: ${k.id} (${b.map(D=>D.objectId).join(", ")})`)}}}let r=new Set((Array.isArray(t?.links)?t.links:[]).map(f=>f.id)),d=new Set,m=new Set([...p.keys(),...s.keys()]),h=Array.isArray(t?.links)?t.links:[],S=new Set(e.targets),I=new Set(h.filter(f=>f.type==="RESOLVES"&&S.has(f.from)).map(f=>f.to)),v=new Set(h.filter(f=>f.type==="VIOLATES"&&I.has(f.from)).map(f=>f.to));for(let f of a){if(!f?.id||!f?.type){n.push("added ontology link requires id and type");continue}l.linkTypes.has(f.type)||n.push(`${e.type} cannot add link type ${f.type}`),(r.has(f.id)||d.has(f.id))&&n.push(`added ontology link ID already exists: ${f.id}`),(!m.has(f.from)||!m.has(f.to))&&n.push(`added ontology link endpoint does not resolve: ${f.id}`),G(f?.provenance?.createdBy)!==G(e.actor)&&n.push(`added link provenance actor mismatch: ${f.id}`);let k=s.get(f.from)?.type,P=s.get(f.to)?.type;e.type==="OpenGap"&&(k!=="Gap"||!S.has(f.to))?n.push(`OpenGap VIOLATES must connect a new Gap to an action target: ${f.id}`):e.type==="ObserveImplementation"&&(!S.has(f.from)||P!=="ImplementationUnit")?n.push(`ObserveImplementation IMPLEMENTED_BY must connect a target obligation to a new ImplementationUnit: ${f.id}`):e.type==="ProposeRepair"&&(k!=="RepairAction"||!S.has(f.to))?n.push(`ProposeRepair RESOLVES must connect a new RepairAction to a target Gap: ${f.id}`):e.type==="ApplyRepair"&&(!v.has(f.from)||P!=="ImplementationUnit")?n.push(`ApplyRepair IMPLEMENTED_BY is outside the targeted repair obligation: ${f.id}`):e.type==="RunValidation"&&(!S.has(f.from)||P!=="Validation")?n.push(`RunValidation VERIFIED_BY must connect a target to a new Validation: ${f.id}`):e.type==="AttachEvidence"&&(!S.has(f.from)||P!=="Evidence")?n.push(`AttachEvidence PRODUCES must connect a target Validation to new Evidence: ${f.id}`):e.type==="SupersedeSource"&&!S.has(f.to)&&n.push(`SupersedeSource SUPERSEDES must point to an action target: ${f.id}`),d.add(f.id)}for(let f of c)e.targets.includes(f?.objectId)||n.push(`lifecycle transition is outside action targets: ${f?.objectId}`),p.has(f?.objectId)?p.get(f.objectId)?.lifecycle===f?.to&&n.push(`lifecycle transition is a no-op: ${f.objectId}`):n.push(`lifecycle transition target does not resolve: ${f?.objectId}`),l.lifecycle.has(f?.to)||n.push(`${e.type} cannot transition lifecycle to ${f?.to}`);let y={IntakeDesignSource:[1,0,0],ConfirmObligation:[0,0,1],ObserveImplementation:[1,1,0],OpenGap:[1,1,0],ProposeRepair:[1,1,0],ApproveRepair:[0,0,1],ApplyRepair:[1,1,0],RunValidation:[1,1,0],AttachEvidence:[1,1,0],CloseGap:[0,0,1],MarkBlocked:[0,0,1],SupersedeSource:[0,0,1]}[e.type];return(o.length<y[0]||a.length<y[1]||c.length<y[2])&&n.push(`${e.type} ontologyPatch is missing its required semantic effects`),n}function fe(e,t,n,i){let o=[];e?.schema!=="dic.ontology-action.v1"&&o.push("action schema must be dic.ontology-action.v1"),/^act-[a-zA-Z0-9._:-]+$/u.test(e?.id??"")||o.push("action ID must use the act- stable-ID format"),e?.expectedSnapshotRevision!==void 0&&e.expectedSnapshotRevision!==t?.snapshotRevision&&o.push("action expectedSnapshotRevision does not match the current snapshot"),$e.has(e?.type)||o.push(`unsupported action type: ${e?.type??"<missing>"}`),["proposed","approved","in_progress","completed","rejected","blocked","rolled_back"].includes(e?.status)||o.push(`unsupported action status: ${e?.status??"<missing>"}`);let a=G(e?.actor);ft.get(a)?.has(e?.type)||o.push(`actor ${e?.actor??"<missing>"} cannot perform ${e?.type??"<missing>"}`);let l=new Map((Array.isArray(t?.objects)?t.objects:[]).map(s=>[s.id,s]));if(!Array.isArray(e?.targets)||e.targets.length===0)o.push("action must target at least one ontology object");else{new Set(e.targets).size!==e.targets.length&&o.push("action targets must be unique");let s=$e.get(e.type);for(let r of e.targets){let d=l.get(r);d?s?.has(d.type)||o.push(`${e.type} cannot target ${d.type}: ${r}`):o.push(`target does not resolve: ${r}`)}}let p=["completed","blocked","rolled_back"].includes(e?.status);if(e?.status==="completed")for(let[s,r]of[["preconditions","precondition"],["postconditions","postcondition"]])(!Array.isArray(e?.[s])||e[s].length===0||e[s].some(d=>d.status!=="PASS"))&&o.push(`terminal action requires every ${r} to PASS`);else e?.status==="rolled_back"?(!Array.isArray(e?.postconditions)||e.postconditions.length===0||e.postconditions.some(s=>s.status!=="PASS"))&&o.push("rolled_back action requires verified rollback postconditions"):e?.status==="blocked"&&([...Array.isArray(e?.preconditions)?e.preconditions:[],...Array.isArray(e?.postconditions)?e.postconditions:[]].some(r=>r.status!=="PASS")||o.push("blocked action must identify a failed or pending condition"));if(p&&ht.has(e.type)&&(!Array.isArray(e.evidence)||e.evidence.length===0)&&o.push(`${e.type} requires durable evidence before terminal status`),e?.type==="ApplyRepair")if(!Array.isArray(e.allowedPaths)||e.allowedPaths.length===0)o.push("ApplyRepair requires a non-empty allowedPaths scope");else{let s=Array.isArray(n?.protectedPaths)?n.protectedPaths:[];for(let r of e.allowedPaths){let d=Y(i,r);if(!J(d,i)){o.push(`allowed path escapes project root: ${r}`);continue}for(let m of s){let h=Y(i,m);(J(d,h)||J(h,d))&&o.push(`allowed path overlaps protected design source: ${r}`)}}}return o.push(...gt(e,t)),o}async function Te(e,t){if(!["AttachEvidence","ApplyRepair","ObserveImplementation"].includes(e?.type)||e?.status!=="completed")return[];let n=(e?.parameters?.ontologyPatch?.addObjects??[]).filter(o=>["Evidence","ImplementationUnit"].includes(o?.type)),i=[];for(let o of n){let a=o?.properties?.path,c=o?.provenance?.contentHash;if(!a||!c)continue;let l=await ie(t,a,c);l.status==="OUTSIDE_PROJECT"?i.push(`${o.type} artifact escapes project root: ${o.id}`):l.status==="MISSING"?i.push(`${o.type} artifact is missing: ${o.id}`):l.status==="INVALID"?i.push(`${o.type} artifact is not a regular file: ${o.id}`):l.status==="CHANGED"&&i.push(`${o.type} artifact hash mismatch: ${o.id}`)}return i}async function j(e){return JSON.parse(await ne(e,"utf8"))}function te(e){let t=Object.fromEntries(Object.entries(e??{}).filter(([n])=>n!=="recordHash"));return H(JSON.stringify(C(t)))}function _(e){let t=[],n="0".repeat(64),i=!1,o=new Map;for(let[a,c]of e.entries()){let l=a+1,p=JSON.stringify(c?.action),s=H(p);if(c?.schema==="dic.ontology-action-record.v1")i&&t.push(`legacy ledger record follows v2 record at line ${l}`),c.sha256!==s&&t.push(`action ledger hash mismatch at line ${l}`),n=te(c);else if(c?.schema==="dic.ontology-action-record.v2"){i=!0,c.sequence!==l&&t.push(`action ledger sequence mismatch at line ${l}`),c.previousHash!==n&&t.push(`action ledger chain mismatch at line ${l}`),c.actionHash!==s&&t.push(`action ledger action hash mismatch at line ${l}`);let d=te(c);c.recordHash!==d&&t.push(`action ledger record hash mismatch at line ${l}`),n=d}else{t.push(`unsupported action ledger schema at line ${l}`);continue}let r=o.get(c.action?.id);r&&r!==s&&t.push(`action ledger ID collision: ${c.action.id}`),o.set(c.action?.id,s)}return{valid:t.length===0,errors:t,headHash:n,recordCount:e.length}}async function xe(e,t,{dryRun:n=!1,baseSnapshotRevision:i="",appliedActionIds:o=[]}={}){let a=[];try{a=(await ne(e,"utf8")).split(/\r?\n/u).filter(Boolean).map(h=>JSON.parse(h))}catch(h){if(h?.code!=="ENOENT")throw h}let c=_(a);if(!c.valid)throw new Error(c.errors.join("; "));let l=JSON.stringify(t),p=H(l),s=a.find(h=>h.action?.id===t.id);if(s){if((s.actionHash??s.sha256)!==p)throw new Error(`action ID collision with different payload: ${t.id}`);return{recorded:!1,duplicate:!0,sha256:p,actionHash:p,recordHash:s.recordHash??te(s),ledgerHeadHash:c.headHash}}let r=new Set(o),d=a.map(h=>h.action?.id).filter(h=>h&&!r.has(h));if(d.length>0)throw new Error(`ledger has unapplied action(s): ${d.join(", ")}; run ontology-reconcile before recording another action`);if(!/^[a-f0-9]{64}$/u.test(i))throw new Error("recording an action requires a canonical base snapshot revision");let m={schema:"dic.ontology-action-record.v2",sequence:a.length+1,recordedAt:new Date().toISOString(),previousHash:c.headHash,baseSnapshotRevision:i,actionHash:p,action:t};return m.recordHash=te(m),n||await lt(e,`${JSON.stringify(m)}
3
+ `,"utf8"),{recorded:!n,duplicate:!1,dryRun:n,sha256:p,actionHash:p,recordHash:m.recordHash,ledgerHeadHash:m.recordHash,sequence:m.sequence,baseSnapshotRevision:i}}function he(e){return e.split(/\r?\n/u).filter(Boolean).map((t,n)=>{try{return JSON.parse(t)}catch{throw new Error(`invalid action ledger JSON at line ${n+1}`)}})}async function se(e){try{let t=he(await ne(e,"utf8")),n=_(t);if(!n.valid)throw new Error(n.errors.join("; "));return t}catch(t){if(t?.code==="ENOENT")return[];throw t}}function ae(e,t,n,i){let o=_(t);if(!o.valid)throw new Error(o.errors.join("; "));let a=structuredClone(e);a.appliedActionIds=Array.isArray(a.appliedActionIds)?[...a.appliedActionIds]:[];let c=new Set(a.appliedActionIds),l=new Map,p=0,s=0;for(let d of t){let m=JSON.stringify(d.action),h=H(m),S=l.get(d.action?.id);if(S&&S!==h)throw new Error(`action ledger ID collision: ${d.action.id}`);if(l.set(d.action?.id,h),c.has(d.action.id)){s+=1;continue}if(d.schema==="dic.ontology-action-record.v2"&&d.baseSnapshotRevision!==a.snapshotRevision)throw new Error(`action ${d.action.id} was recorded against snapshot ${d.baseSnapshotRevision}, current revision is ${a.snapshotRevision}`);let I=fe(d.action,a,n,i);if(I.length>0)throw new Error(`action ${d.action.id} cannot be materialized: ${I.join("; ")}`);let v=d.action.parameters.ontologyPatch;a.objects.push(...structuredClone(v.addObjects??[])),a.links.push(...structuredClone(v.addLinks??[]));let y=new Map(a.objects.map(f=>[f.id,f]));for(let f of v.lifecycleTransitions??[])y.get(f.objectId).lifecycle=f.to;a.appliedActionIds.push(d.action.id),c.add(d.action.id),a.snapshotRevision=ue(a),p+=1}a.snapshotRevision=ue(a),a.invariantResults=oe(a);let r=a.invariantResults.filter(d=>d.status==="FAIL"&&d.severity==="blocking");if(r.length>0)throw new Error(`reconciled ontology violates structural invariants: ${r.map(d=>d.id).join(", ")}`);return{snapshot:a,applied:p,skipped:s,total:t.length}}function U(e,t,n=""){let i=Array.isArray(e?.objects)?e.objects:[],o=Array.isArray(e?.links)?e.links:[],a=new Map(i.map(c=>[c.id,c]));if(t==="uncovered"){let c=new Set(i.filter(r=>r.type==="ImplementationUnit"&&["active","confirmed","resolved"].includes(r.lifecycle)).map(r=>r.id)),l=new Set(o.filter(r=>r.type==="IMPLEMENTED_BY"&&c.has(r.to)).map(r=>r.from)),p=new Set(i.filter(r=>r.type==="Validation"&&["active","confirmed","resolved"].includes(r.lifecycle)&&r.properties?.status==="PASS").map(r=>r.id)),s=new Set(o.filter(r=>r.type==="VERIFIED_BY"&&p.has(r.to)).map(r=>r.from));return i.filter(r=>["Requirement","Scenario"].includes(r.type)&&["active","confirmed"].includes(r.lifecycle)&&(!l.has(r.id)||!s.has(r.id))).map(r=>({id:r.id,type:r.type,lifecycle:r.lifecycle,missingImplementation:r.type==="Requirement"&&!l.has(r.id),missingValidation:!s.has(r.id)}))}if(t==="gaps")return i.filter(c=>c.type==="Gap"&&!["resolved","rejected","superseded"].includes(c.lifecycle));if(t==="unevidenced"){let c=new Set(o.filter(l=>l.type==="PRODUCES").map(l=>l.from));return i.filter(l=>l.type==="Validation"&&!c.has(l.id))}if(t==="impact"){if(!n||!a.has(n))throw new Error("impact query requires --id resolving to an ontology object");let c=new Set(["PROPOSES","DERIVED_FROM","REFINES","IMPLEMENTED_BY","VERIFIED_BY","VIOLATES","RESOLVES","PRODUCES","SUPERSEDES"]),l=new Map;for(let r of o.filter(d=>c.has(d.type)))l.has(r.from)||l.set(r.from,[]),l.has(r.to)||l.set(r.to,[]),l.get(r.from).push({id:r.to,link:r}),l.get(r.to).push({id:r.from,link:r});let p=[{id:n,depth:0}],s=new Map([[n,{depth:0,via:null}]]);for(;p.length>0;){let r=p.shift();if(!(r.depth>=4))for(let d of l.get(r.id)??[])s.has(d.id)||(s.set(d.id,{depth:r.depth+1,via:d.link.type}),p.push({id:d.id,depth:r.depth+1}))}return[...s.entries()].map(([r,d])=>({id:r,type:a.get(r)?.type,lifecycle:a.get(r)?.lifecycle,...d}))}throw new Error(`unsupported ontology query: ${t}`)}async function K(e,t){let n=(Array.isArray(e?.objects)?e.objects:[]).filter(o=>o.type==="DesignSource"),i=[];for(let o of n){let a=o?.provenance?.contentHash??"",c=o?.properties?.path??o?.provenance?.source;if(!c||!a){i.push({id:o.id,path:c??"",status:"UNTRACKED",expected:a,actual:""});continue}let l=await ie(t,c,a);i.push({id:o.id,path:c,status:l.status,expected:a,actual:l.actual})}return i}async function W(e,t){let n=Array.isArray(e?.objects)?e.objects:[],i=Array.isArray(e?.links)?e.links:[],o=new Map(n.map(s=>[s.id,s])),a=new Set(n.filter(s=>s.type==="Validation"&&["active","confirmed","resolved"].includes(s.lifecycle)).map(s=>s.id)),c=new Set(i.filter(s=>s.type==="PRODUCES"&&a.has(s.from)&&o.get(s.to)?.type==="Evidence").map(s=>s.to)),l=n.filter(s=>s.type==="Evidence"),p=[];for(let s of l){let r=s?.provenance?.contentHash??"",d=s?.properties?.path??"",m=c.has(s.id);if(!d||!r){p.push({id:s.id,path:d,required:m,status:"UNTRACKED",expected:r,actual:""});continue}if(m&&!["active","confirmed","resolved"].includes(s.lifecycle)){p.push({id:s.id,path:d,required:m,status:"INACTIVE",expected:r,actual:""});continue}let h=await ie(t,d,r);p.push({id:s.id,path:d,required:m,status:h.status,expected:r,actual:h.actual})}return p}async function X(e,t){let n=Array.isArray(e?.objects)?e.objects:[],i=Array.isArray(e?.links)?e.links:[],o=new Map(n.map(s=>[s.id,s])),a=new Set(n.filter(s=>["Requirement","Scenario"].includes(s.type)&&["active","confirmed"].includes(s.lifecycle)).map(s=>s.id)),c=new Set(i.filter(s=>s.type==="IMPLEMENTED_BY"&&a.has(s.from)&&o.get(s.to)?.type==="ImplementationUnit").map(s=>s.to)),l=n.filter(s=>s.type==="ImplementationUnit"),p=[];for(let s of l){let r=s?.provenance?.contentHash??"",d=s?.properties?.path??"",m=c.has(s.id);if(!d||!r){p.push({id:s.id,path:d,required:m,status:"UNTRACKED",expected:r,actual:""});continue}if(m&&!["active","confirmed","resolved"].includes(s.lifecycle)){p.push({id:s.id,path:d,required:m,status:"INACTIVE",expected:r,actual:""});continue}let h=await ie(t,d,r);p.push({id:s.id,path:d,required:m,status:h.status,expected:r,actual:h.actual})}return p}function wt(e,t){let n=t.filter(p=>p.status!=="UNCHANGED"),i=new Map;for(let p of n)for(let s of U(e,"impact",p.id)){let r=i.get(s.id);(!r||s.depth<r.depth)&&i.set(s.id,{...s,changedSourceIds:r?.changedSourceIds??[]}),i.get(s.id).changedSourceIds.push(p.id)}let o=[...i.values()].map(p=>({...p,changedSourceIds:[...new Set(p.changedSourceIds)].sort()})).sort((p,s)=>p.depth-s.depth||p.id.localeCompare(s.id)),a=new Set(o.map(p=>p.type)),c=[],l=(p,s)=>{c.some(r=>r.stage===p)||c.push({stage:p,reason:s})};return n.length>0&&(l("workflow-intake","Refresh changed or missing design-source revisions."),l("spec-reader","Re-read the changed authoritative source neighborhood."),l("contract-oracle","Reconfirm affected obligations and lifecycle.")),["Requirement","Scenario"].some(p=>a.has(p))&&(l("flow-auditor","Re-evaluate affected behavioral and lifecycle flows."),l("impl-inspector","Recheck implementation mappings for affected obligations.")),["ImplementationUnit","Gap","RepairAction"].some(p=>a.has(p))&&(l("repair-planner","Replan only impacted gaps and repair actions."),l("code-repairer","Execute approved impacted repair slices only.")),["Validation","Evidence"].some(p=>a.has(p))&&l("validation-runner","Refresh invalidated validation and evidence."),n.length>0&&l("final-reviewer","Recompute invariants after incremental reconciliation."),{clean:n.length===0,changedSources:n,impactedObjects:o,recommendedStages:c}}function qe(e,t,n,i){let o=wt(e,t),a=n.filter(r=>r.required&&r.status!=="UNCHANGED"),c=i.filter(r=>r.required&&r.status!=="UNCHANGED"),l=new Map(o.impactedObjects.map(r=>[r.id,{...r,integrityIssueIds:[]}]));for(let r of[...a,...c])for(let d of U(e,"impact",r.id)){let m=l.get(d.id);(!m||d.depth<m.depth)&&l.set(d.id,{...d,changedSourceIds:m?.changedSourceIds??[],integrityIssueIds:m?.integrityIssueIds??[]}),l.get(d.id).integrityIssueIds.push(r.id)}let p=o.recommendedStages.map(r=>({...r})),s=(r,d)=>{p.some(m=>m.stage===r)||p.push({stage:r,reason:d})};return a.length>0&&(s("impl-inspector","Reinspect drifted implementation files and refresh or challenge their mappings."),s("validation-runner","Rerun validations affected by implementation drift.")),c.length>0&&s("validation-runner","Regenerate missing or drifted content-addressed Evidence artifacts."),(a.length>0||c.length>0)&&s("final-reviewer","Recompute gates and Attestation after integrity recovery."),{...o,clean:o.clean&&a.length===0&&c.length===0,implementationIssues:a,evidenceIssues:c,impactedObjects:[...l.values()].map(r=>({...r,changedSourceIds:[...new Set(r.changedSourceIds??[])].sort(),integrityIssueIds:[...new Set(r.integrityIssueIds??[])].sort()})).sort((r,d)=>r.depth-d.depth||r.id.localeCompare(d.id)),recommendedStages:p}}function De(e,t){let n=Array.isArray(e?.objects)?e.objects:[],i=Array.isArray(e?.links)?e.links:[],o=new Map(n.map(h=>[h.id,h])),a=o.get(t);if(!a)throw new Error(`ontology object does not resolve: ${t}`);let c=h=>({id:h.id,type:h.type,lifecycle:h.lifecycle,title:h.properties?.title??"",path:h.properties?.path??"",status:h.properties?.status??"",sourceLocator:h.provenance?.sourceLocator??"",sourceRevision:h.provenance?.sourceRevision??"",createdBy:h.provenance?.createdBy??""}),l=[];for(let h of i)h.from===t&&o.has(h.to)?l.push({direction:"outgoing",type:h.type,object:c(o.get(h.to)),linkId:h.id}):h.to===t&&o.has(h.from)&&l.push({direction:"incoming",type:h.type,object:c(o.get(h.from)),linkId:h.id});l.sort((h,S)=>h.type.localeCompare(S.type)||h.object.id.localeCompare(S.object.id));let p=new Set(["DesignSource","ImplementationUnit","Gap","RepairAction","Validation","Evidence","Decision","Risk"]),s=new Map;for(let h of i)s.has(h.from)||s.set(h.from,[]),s.has(h.to)||s.set(h.to,[]),s.get(h.from).push({id:h.to,type:h.type,direction:"outgoing"}),s.get(h.to).push({id:h.from,type:h.type,direction:"incoming"});let r=[{id:t,objects:[t],links:[]}],d=new Map([[t,0]]),m=[];for(;r.length>0;){let h=r.shift();if(!(h.links.length>=4))for(let S of s.get(h.id)??[]){if(h.objects.includes(S.id))continue;let I=[...h.objects,S.id],v=[...h.links,{type:S.type,direction:S.direction}],y=o.get(S.id);if(!y)continue;p.has(y.type)&&m.push({target:c(y),objectIds:I,links:v});let f=v.length;(d.get(S.id)??Number.POSITIVE_INFINITY)>f&&(d.set(S.id,f),r.push({id:S.id,objects:I,links:v}))}}return m.sort((h,S)=>h.links.length-S.links.length||h.target.type.localeCompare(S.target.type)||h.target.id.localeCompare(S.target.id)),{object:c(a),properties:a.properties??{},provenance:a.provenance??{},interfaces:a.interfaces??[],relations:l,evidenceChains:m}}function H(e){return Ne("sha256").update(e).digest("hex")}function Le(e){let t=Object.fromEntries(Object.entries(e??{}).filter(([n])=>!["attestationId","contentHash"].includes(n)));return H(JSON.stringify(C(t)))}function He(e){return z(e).filter(t=>t.required).map(t=>({id:t.id,status:t.status,targetIds:t.targetIds,requiredInputIds:t.requiredInputIds,missingInputIds:t.missingInputIds,staleInputIds:t.staleInputIds}))}function Ve({snapshot:e,ledgerText:t,ledgerHeadHash:n,status:i,summary:o,sourceDrift:a,evidenceIntegrity:c,implementationIntegrity:l,invariants:p,createdAt:s=new Date().toISOString()}){let r={schema:"dic.ontology-attestation.v1",attestationId:"",contentHash:"",version:e.version,status:i,final:!0,summary:o,createdAt:s,snapshot:{snapshotId:e.snapshotId,snapshotRevision:e.snapshotRevision},ledger:{sha256:H(t),actionCount:t.split(/\r?\n/u).filter(Boolean).length,headHash:n},sources:a.map(d=>({id:d.id,path:d.path,status:d.status,contentHash:d.actual||d.expected||""})),evidence:c.filter(d=>d.required).map(d=>({id:d.id,path:d.path,status:d.status,contentHash:d.actual||d.expected||""})),implementations:l.filter(d=>d.required).map(d=>({id:d.id,path:d.path,status:d.status,contentHash:d.actual||d.expected||""})),validationCausality:He(e),invariants:p};return r.contentHash=Le(r),r.attestationId=`att-${r.contentHash.slice(0,16)}`,r}function Me({attestation:e,snapshot:t,ledgerText:n,ledgerHeadHash:i,sourceDrift:o,evidenceIntegrity:a,implementationIntegrity:c,invariants:l,expectedContentHash:p=""}){let s=[],r=Le(e);e?.schema!=="dic.ontology-attestation.v1"&&s.push("unsupported ontology attestation schema"),["PASS","PARTIAL","BLOCKED","FAIL"].includes(e?.status)||s.push("unsupported ontology attestation status"),e?.final!==!0&&s.push("ontology attestation is not final"),(typeof e?.summary!="string"||!e.summary.trim())&&s.push("ontology attestation summary is empty"),(typeof e?.createdAt!="string"||Number.isNaN(Date.parse(e.createdAt)))&&s.push("ontology attestation timestamp is invalid"),e?.contentHash!==r&&s.push("attestation content hash mismatch"),p&&e?.contentHash!==p&&s.push("attestation content hash does not match the external anchor"),e?.attestationId!==`att-${r.slice(0,16)}`&&s.push("attestation ID does not match its content hash"),(e?.snapshot?.snapshotId!==t?.snapshotId||e?.snapshot?.snapshotRevision!==t?.snapshotRevision)&&s.push("attestation snapshot identity or revision is stale"),e?.version!==t?.version&&s.push("attestation version does not match the snapshot"),e?.ledger?.sha256!==H(n)&&s.push("attestation action ledger hash is stale"),e?.ledger?.headHash!==i&&s.push("attestation action ledger head is stale");let d=n.split(/\r?\n/u).filter(Boolean).length;e?.ledger?.actionCount!==d&&s.push("attestation action count is stale");let m=o.map(v=>({id:v.id,path:v.path,status:v.status,contentHash:v.actual||v.expected||""}));JSON.stringify(C(e?.sources??[]))!==JSON.stringify(C(m))&&s.push("attested source inventory is stale");let h=a.filter(v=>v.required).map(v=>({id:v.id,path:v.path,status:v.status,contentHash:v.actual||v.expected||""}));JSON.stringify(C(e?.evidence??[]))!==JSON.stringify(C(h))&&s.push("attested Evidence artifact inventory is stale");let S=c.filter(v=>v.required).map(v=>({id:v.id,path:v.path,status:v.status,contentHash:v.actual||v.expected||""}));JSON.stringify(C(e?.implementations??[]))!==JSON.stringify(C(S))&&s.push("attested ImplementationUnit artifact inventory is stale"),JSON.stringify(C(e?.validationCausality??[]))!==JSON.stringify(C(He(t)))&&s.push("attested Validation input causality is stale"),JSON.stringify(C(e?.invariants??[]))!==JSON.stringify(C(l))&&s.push("attested invariant results are stale");let I=l.filter(v=>v.status==="FAIL"&&v.severity==="blocking");return I.length>0&&s.push(`current ontology gate fails: ${I.map(v=>v.id).join(", ")}`),{valid:s.length===0,errors:s,attestationId:e?.attestationId??"",status:e?.status??""}}function R(e){return String(e??"").replace(/\|/gu,"\\|").replace(/\r?\n/gu," ")}function Ue(e,t,n,i,o=""){let a=Array.isArray(e?.objects)?e.objects:[],c=Array.isArray(e?.links)?e.links:[],l=new Map;for(let y of a)l.set(y.type,(l.get(y.type)??0)+1);let p=U(e,"uncovered"),s=U(e,"gaps"),r=U(e,"unevidenced"),d=z(e),m=oe(e,o),h=t.filter(y=>y.status!=="UNCHANGED");m.push({id:"pass.sources.no-drift",status:o==="PASS"?h.length===0?"PASS":"FAIL":"NOT_APPLICABLE",severity:"blocking",message:"PASS requires every tracked design source to match its recorded revision.",objectIds:o==="PASS"?h.map(y=>y.id):[]});let S=i.filter(y=>y.required&&y.status!=="UNCHANGED");m.push({id:"pass.implementation.artifacts-current",status:o==="PASS"?S.length===0?"PASS":"FAIL":"NOT_APPLICABLE",severity:"blocking",message:"PASS requires every required ImplementationUnit artifact to exist and match its recorded SHA-256 hash.",objectIds:o==="PASS"?S.map(y=>y.id):[]});let I=n.filter(y=>y.required&&y.status!=="UNCHANGED");return m.push({id:"pass.evidence.artifacts-current",status:o==="PASS"?I.length===0?"PASS":"FAIL":"NOT_APPLICABLE",severity:"blocking",message:"PASS requires every required Evidence artifact to exist and match its recorded SHA-256 hash.",objectIds:o==="PASS"?I.map(y=>y.id):[]}),["# DIC Ontology Report","",`- Snapshot: \`${e.snapshotId}\``,`- Revision: \`${e.snapshotRevision||"unversioned"}\``,`- Requested gate: ${o||"STRUCTURAL"}`,`- Objects / links: ${a.length} / ${c.length}`,`- Uncovered obligations: ${p.length}`,`- Open gaps: ${s.length}`,`- Unevidenced validations: ${r.length}`,"","## Object Inventory","","| Type | Count |","| --- | ---: |",...[...l.entries()].sort(([y],[f])=>y.localeCompare(f)).map(([y,f])=>`| ${R(y)} | ${f} |`),"","## Gate Invariants","","| Status | Severity | Invariant | Affected |","| --- | --- | --- | ---: |",...m.map(y=>`| ${y.status} | ${y.severity} | ${R(y.id)} | ${y.objectIds.length} |`),"","## Design Sources","","| Status | Object | Path |","| --- | --- | --- |",...t.map(y=>`| ${y.status} | \`${R(y.id)}\` | \`${R(y.path)}\` |`),"","## Uncovered Obligations","","| Object | Type | Missing implementation | Missing validation |","| --- | --- | --- | --- |",...p.map(y=>`| \`${R(y.id)}\` | ${y.type} | ${y.missingImplementation} | ${y.missingValidation} |`),"","## Evidence Artifacts","","| Status | Required | Object | Path |","| --- | --- | --- | --- |",...n.map(y=>`| ${y.status} | ${y.required} | \`${R(y.id)}\` | \`${R(y.path)}\` |`),"","## Validation Causality","","| Status | Required | Validation | Targets | Required inputs | Missing | Stale |","| --- | --- | --- | --- | --- | --- | --- |",...d.map(y=>`| ${y.status} | ${y.required} | \`${R(y.id)}\` | ${R(y.targetIds.join(", "))} | ${R(y.requiredInputIds.join(", "))} | ${R(y.missingInputIds.join(", "))} | ${R(y.staleInputIds.join(", "))} |`),"","## Implementation Artifacts","","| Status | Required | Object | Path |","| --- | --- | --- | --- |",...i.map(y=>`| ${y.status} | ${y.required} | \`${R(y.id)}\` | \`${R(y.path)}\` |`),"","## Open Gaps","","| Object | Lifecycle | Severity | Title |","| --- | --- | --- | --- |",...s.map(y=>`| \`${R(y.id)}\` | ${y.lifecycle} | ${R(y.properties?.severity)} | ${R(y.properties?.title)} |`),"","## Unevidenced Validations","","| Object | Lifecycle | Status |","| --- | --- | --- |",...r.map(y=>`| \`${R(y.id)}\` | ${y.lifecycle} | ${R(y.properties?.status)} |`),"","_Generated from ontology state; edit the ontology through authorized actions, then regenerate this view._",""].join(`
4
+ `)}var F="dic-workflow-kit",_e=".dic-workflow-kit-install.json",Z=E(M(At(import.meta.url)),".."),It=new Map([["codex","codex"],["claude","claude-code"],["claude-code","claude-code"],["opencode","opencode"],["mimo","mimo-code"],["mimocode","mimo-code"],["mimo-code","mimo-code"],["bitfun","bitfun"]]),kt=[".codex-plugin","adapters","agents","schemas","skills","INSTRUCTION.md"];function $(e,t,n){let i=e[t+1];if(!i)throw new Error(`${n} requires a value`);return i}function Et(e){let t=e[0]??"help",n="codex",i="user",o,a,c=process.cwd(),l=!1,p=!1,s=!1,r,d,m,h,S="",I="",v="",y="",f,k,P="";for(let A=1;A<e.length;A+=1){let g=e[A];if(g==="--host"){let b=$(e,A,g).toLowerCase();if(n=It.get(b),!n)throw new Error(`unsupported host: ${b}; expected codex, claude-code, opencode, mimo-code, or bitfun`);A+=1}else if(g==="--scope"){if(i=$(e,A,g).toLowerCase(),!["user","project"].includes(i))throw new Error("--scope must be user or project");A+=1}else if(g==="--install-root")o=E($(e,A,g)),A+=1;else if(g==="--project-root")c=E($(e,A,g)),A+=1;else if(g==="--root")c=E($(e,A,g)),A+=1;else if(g==="--snapshot")r=E($(e,A,g)),A+=1;else if(g==="--action")d=E($(e,A,g)),A+=1;else if(g==="--profile")m=E($(e,A,g)),A+=1;else if(g==="--ledger")h=E($(e,A,g)),A+=1;else if(g==="--status"){if(S=$(e,A,g).toUpperCase(),!["PASS","PARTIAL","BLOCKED","FAIL"].includes(S))throw new Error("--status must be PASS, PARTIAL, BLOCKED, or FAIL");A+=1}else if(g==="--query"){if(I=$(e,A,g).toLowerCase(),!["uncovered","gaps","unevidenced","impact"].includes(I))throw new Error("--query must be uncovered, gaps, unevidenced, or impact");A+=1}else if(g==="--id")v=$(e,A,g),A+=1;else if(g==="--summary")y=$(e,A,g),A+=1;else if(g==="--output")f=E($(e,A,g)),A+=1;else if(g==="--attestation")k=E($(e,A,g)),A+=1;else if(g==="--expected-hash"){if(P=$(e,A,g).toLowerCase(),!/^[a-f0-9]{64}$/u.test(P))throw new Error("--expected-hash must be a 64-character SHA-256 digest");A+=1}else if(g==="--marketplace-root")a=E($(e,A,g)),A+=1;else if(g==="--dry-run")l=!0;else if(g==="--force")p=!0;else if(g==="--json")s=!0;else throw new Error(`unknown argument: ${g}`)}if(n!=="codex"&&a)throw new Error("--marketplace-root is only valid for --host codex");if(n==="codex"&&i==="project")throw new Error("Codex plugin installation supports user scope only");return{command:t,host:n,scope:i,installRoot:o,marketplaceRoot:a,projectRoot:c,dryRun:l,force:p,json:s,snapshot:r,action:d,profile:m,ledger:h,status:S,query:I,id:v,summary:y,output:f,attestation:k,expectedHash:P}}function Ke({host:e,scope:t,projectRoot:n}){if(t==="project"){let i={"claude-code":".claude",opencode:".opencode","mimo-code":".mimocode",bitfun:".bitfun"}[e];return w(n,i)}if(e==="claude-code")return w(V(),".claude");if(e==="opencode")return w(process.env.XDG_CONFIG_HOME||w(V(),".config"),"opencode");if(e==="mimo-code")return process.env.MIMOCODE_HOME?E(process.env.MIMOCODE_HOME):process.platform==="win32"&&process.env.LOCALAPPDATA?w(process.env.LOCALAPPDATA,"mimocode"):w(process.env.XDG_CONFIG_HOME||w(V(),".config"),"mimocode");if(e==="bitfun")throw new Error("BitFun user scope uses separate platform-native Skills and agents roots");return w(V(),".agents","plugins")}function bt(){let e,t;if(process.platform==="win32"){let n=process.env.APPDATA||w(V(),"AppData","Roaming");e=w(n,"BitFun","skills"),t=w(process.env.BITFUN_USER_ROOT?E(process.env.BITFUN_USER_ROOT):w(n,"bitfun"),"agents")}else if(process.platform==="darwin"){let n=w(V(),"Library","Application Support");e=w(n,"BitFun","skills"),t=w(process.env.BITFUN_USER_ROOT?E(process.env.BITFUN_USER_ROOT):w(n,"bitfun"),"agents")}else e=w(process.env.XDG_DATA_HOME||w(V(),".local","share"),"BitFun","skills"),t=w(process.env.BITFUN_USER_ROOT?E(process.env.BITFUN_USER_ROOT):w(process.env.XDG_CONFIG_HOME||w(V(),".config"),"bitfun"),"agents");return{skillsRoot:e,agentsRoot:t}}function Rt(e){if(e.installRoot)return{root:e.installRoot,skillsRoot:w(e.installRoot,"skills"),agentsRoot:w(e.installRoot,"agents")};if(e.host==="bitfun"&&e.scope==="user"){let n=bt();return{root:M(n.skillsRoot),...n}}let t=Ke(e);return{root:t,skillsRoot:w(t,"skills"),agentsRoot:w(t,"agents")}}function We(e){if(e.host==="codex"){let n=e.marketplaceRoot||e.installRoot||Ke(e),i=w(n,"plugins",F);return{root:i,skillsRoot:w(i,"skills"),agentsRoot:w(i,"agents"),manifestPath:w(i,_e),marketplaceRoot:n,marketplacePath:w(n,"marketplace.json")}}let t=Rt(e);return{...t,manifestPath:w(t.root,_e)}}async function Q(e){try{return await Je(e),!0}catch(t){if(t?.code==="ENOENT")return!1;throw t}}function re(e){return Be("sha256").update(e).digest("hex")}async function Xe(e){return re(await q(e))}async function jt(){return JSON.parse(await q(w(Z,"package.json"),"utf8"))}async function ge(e,t){let n=`${e}.${process.pid}.tmp`;await ce(M(e),{recursive:!0}),await le(n,`${JSON.stringify(t,null,2)}
5
+ `,"utf8"),await B(e,{force:!0}),await me(n,e)}async function Ze(e,t){try{return JSON.parse(await q(e,"utf8"))}catch(n){if(n?.code==="ENOENT"&&t!==void 0)return t;throw n}}async function we(e){let t=await Ze(e,{name:"personal",interface:{displayName:"Personal"},plugins:[]});if(!t||typeof t!="object"||Array.isArray(t))throw new Error("marketplace.json must contain an object");if(!Array.isArray(t.plugins))throw new Error("marketplace.json must contain a plugins array");return t}function Ot(){return{name:F,source:{source:"local",path:`./plugins/${F}`},policy:{installation:"AVAILABLE",authentication:"ON_INSTALL"},category:"Developer Tools"}}function Pt(e,t){let n=e.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n/);if(!n)return e;if(t==="bitfun"){let a=n[1],c=a.match(/^name:\s*(.+)$/m)?.[1]?.trim(),l=a.match(/^description:\s*(.+)$/m)?.[1]?.trim();if(!c||!l)throw new Error("BitFun Subagent requires name and description");let p=["code-repairer","validation-runner"].includes(c),s=["LS","Read","Glob","Grep","Skill"];return p&&s.push("Write","Edit","ExecCommand"),["---","schema_version: 1","kind: subagent",`id: ${c}`,`name: ${c}`,`description: ${l}`,`readonly: ${p?"false":"true"}`,"tools:",...s.map(r=>` - ${r}`),"---",e.slice(n[0].length)].join(`
6
+ `)}let i=t==="claude-code"?new Set(["name","description","tools","disallowedTools","model","permissionMode","skills","memory","background","isolation"]):new Set(["name","description","mode","model","temperature","top_p","tools","permission","steps","hidden","color"]);return`---
7
+ ${n[1].split(/\r?\n/).filter(a=>{let c=a.match(/^([A-Za-z][A-Za-z0-9_-]*):/)?.[1];return!c||i.has(c)}).join(`
5
8
  `)}
6
9
  ---
7
- ${e.slice(t[0].length)}`}async function $(e){let o=e.installRoot||O(e),t=n(o,"skills"),r=n(o,"agents"),c=await g(n(p,"skills")),a=(await g(n(p,"agents"))).filter(s=>s.endsWith(".md"));if(!e.dryRun){await w(t,{recursive:!0});for(let s of c)await A(n(p,"skills",s),n(t,s),{recursive:!0,force:!0});await w(r,{recursive:!0});for(let s of a){let d=await y(n(p,"agents",s),"utf8");await E(n(r,s),I(d,e.host),"utf8")}}R({...e,root:o,skillsRoot:t,agentsRoot:r})}function R({host:e,scope:o,root:t,skillsRoot:r,agentsRoot:c,dryRun:a,extra:s}){process.stdout.write([a?"DRY_RUN: true":"INSTALLED: true",`HOST: ${e}`,`SCOPE: ${o}`,`ROOT: ${t}`,`SKILLS: ${r}`,`SUBAGENTS: ${c}`,s,""].filter(d=>d!==void 0).join(`
8
- `))}async function P(e){e.host==="codex"?await T(e):await $(e)}function _(){process.stdout.write(["DIC Workflow Kit multi-host installer","","Usage:"," dic-workflow-kit install [--host <host>] [--scope user|project]"," [--project-root <path>] [--install-root <path>]"," [--marketplace-root <path>] [--dry-run]","","Hosts:"," codex (default), claude-code, opencode, mimo-code","","Examples:"," dic-workflow-kit install"," dic-workflow-kit install --host claude-code"," dic-workflow-kit install --host opencode --scope project"," dic-workflow-kit install --host mimo-code --scope project","","--marketplace-root is a backward-compatible Codex-only option.","--install-root overrides the resolved host configuration directory.",""].join(`
9
- `))}try{let e=C(process.argv.slice(2));if(e.command==="install")await P(e);else if(e.command==="help"||e.command==="--help")_();else throw new Error(`unknown command: ${e.command}`)}catch(e){process.stderr.write(`ERROR: ${e.message}
10
+ ${e.slice(n[0].length)}`}async function Qe(e){let t=[],n=await Ge(e,{withFileTypes:!0});for(let i of n){let o=w(e,i.name);i.isDirectory()?t.push(...await Qe(o)):i.isFile()&&t.push(o)}return t.sort()}async function Fe(e,t,n){if((await Je(e)).isFile()){let c=await q(e);return[{source:n,destination:t,content:c,sha256:re(c)}]}let o=await Qe(e),a=[];for(let c of o){let l=ze(e,c),p=await q(c);a.push({source:w(n,l),destination:w(t,l),content:p,sha256:re(p)})}return a}async function $t(e,t){if(e.host==="codex"){let o=[];for(let a of kt)o.push(...await Fe(w(Z,a),w(t.root,a),a));return o}let n=await Fe(w(Z,"skills"),t.skillsRoot,"skills"),i=(await Ge(w(Z,"agents"))).filter(o=>o.endsWith(".md"));for(let o of i.sort()){let a=w(Z,"agents",o),c=Buffer.from(Pt(await q(a,"utf8"),e.host),"utf8");n.push({source:w("agents",o),destination:w(t.agentsRoot,o),content:c,sha256:re(c)})}return n}async function et(e,t=!1){let n=await Ze(e,null);if(!n){if(t)throw new Error(`installation manifest not found: ${e}`);return null}if(n.schemaVersion!==1||!Array.isArray(n.files)||typeof n.host!="string")throw new Error(`invalid installation manifest: ${e}`);return n}function Se(e,t){let n=ze(E(t),E(e));return n===""||n!==".."&&!n.startsWith(`..${vt}`)&&!Ye(n)}function tt(e,t){if(!(t.marketplacePath?[t.root]:[t.skillsRoot,t.agentsRoot]).some(i=>Se(e,i)))throw new Error(`manifest path escapes managed roots: ${e}`)}async function Nt(e,t){if(!Se(e.destination,t.skillsRoot)||!e.source.endsWith("SKILL.md"))return!1;let n=await q(e.destination,"utf8"),i=e.source.split(/[\\/]/).at(-2);return new RegExp(`^name:\\s*${i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}$`,"m").test(n)&&/^(?: )?version:\s*\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/m.test(n)}async function Ct(e,t,n,i){let o=new Map((t?.files??[]).map(c=>[E(c.path),c.sha256])),a=[];for(let c of e){if(!await Q(c.destination))continue;let l=await ye(c.destination);if(l.isSymbolicLink()){a.push(c.destination);continue}if(!l.isFile())throw new Error(`installation target is not a regular file: ${c.destination}`);let p=await Xe(c.destination);p===c.sha256||o.get(E(c.destination))===p||n.host==="codex"||await Nt(c,i)||a.push(c.destination)}return a}async function Tt(e,t){for(let n of e)await ce(M(n.destination),{recursive:!0}),t&&await Q(n.destination)&&(await ye(n.destination)).isSymbolicLink()&&await B(n.destination,{force:!0}),await le(n.destination,n.content)}async function xt(e){let t=await we(e.marketplacePath),n=Ot(),i=t.plugins.findIndex(o=>o?.name===F);i>=0?t.plugins[i]=n:t.plugins.push(n),await ge(e.marketplacePath,t)}async function qt(e){if(!await Q(e.marketplacePath))return;let t=await we(e.marketplacePath);t.plugins=t.plugins.filter(n=>n?.name!==F),await ge(e.marketplacePath,t)}function O(e,t){if(e.json){process.stdout.write(`${JSON.stringify(t,null,2)}
11
+ `);return}process.stdout.write(`${Object.entries(t).map(([n,i])=>{let o=i!==null&&typeof i=="object"?JSON.stringify(i):i;return`${n.replace(/([a-z])([A-Z])/g,"$1_$2").toUpperCase()}: ${o}`}).join(`
12
+ `)}
13
+ `)}async function Dt(e){let t=We(e),n=await $t(e,t),i=await et(t.manifestPath),o=await Ct(n,i,e,t);if(o.length>0&&!e.force)throw new Error(`installation would overwrite ${o.length} unmanaged or modified file(s): ${o.join(", ")}; rerun with --force only after reviewing them`);let a=await jt(),c={schemaVersion:1,packageName:a.name,packageVersion:a.version,host:e.host,scope:e.scope,installedAt:new Date().toISOString(),root:t.root,skillsRoot:t.skillsRoot,agentsRoot:t.agentsRoot,marketplacePath:t.marketplacePath,files:n.map(l=>({source:l.source,path:l.destination,sha256:l.sha256}))};e.dryRun||(await Tt(n,e.force),e.host==="codex"&&await xt(t),await ge(t.manifestPath,c)),O(e,{installed:!e.dryRun,dryRun:e.dryRun,host:e.host,scope:e.scope,version:a.version,root:t.root,skills:t.skillsRoot,subagents:t.agentsRoot,manifest:t.manifestPath,managedFiles:n.length,forcedConflicts:e.force?o.length:0,...t.marketplacePath?{marketplace:t.marketplacePath}:{}})}async function nt(e){let t=We(e),n=await et(t.manifestPath,!0);if(n.host!==e.host||n.scope!==e.scope)throw new Error(`manifest target mismatch: found ${n.host}/${n.scope}, requested ${e.host}/${e.scope}`);let i=[],o=[];for(let c of n.files)if(tt(c.path,t),!await Q(c.path))i.push(c.path);else{let l=await ye(c.path);(!l.isFile()||l.isSymbolicLink()||await Xe(c.path)!==c.sha256)&&o.push(c.path)}let a=!0;return e.host==="codex"&&(await Q(t.marketplacePath)?a=(await we(t.marketplacePath)).plugins.some(l=>l?.name===F&&l?.source?.path===`./plugins/${F}`):a=!1),{context:t,manifest:n,missing:i,modified:o,registrationHealthy:a,healthy:i.length===0&&o.length===0&&a}}async function Lt(e){let t=await nt(e);O(e,{healthy:t.healthy,host:e.host,scope:e.scope,version:t.manifest.packageVersion,manifest:t.context.manifestPath,managedFiles:t.manifest.files.length,missingFiles:t.missing,modifiedFiles:t.modified,registrationHealthy:t.registrationHealthy}),t.healthy||(process.exitCode=1)}async function Ht(e,t){let n=new Set;for(let i of e){let o=M(i);for(;t.some(a=>Se(o,a))&&!t.some(a=>E(a)===E(o));)n.add(o),o=M(o)}for(let i of[...n].sort((o,a)=>a.length-o.length))try{await St(i)}catch(o){if(!["ENOENT","ENOTEMPTY","EEXIST"].includes(o?.code))throw o}}async function Vt(e){let t=await nt(e);if(t.modified.length>0&&!e.force)throw new Error(`refusing to remove ${t.modified.length} modified managed file(s): ${t.modified.join(", ")}; rerun with --force only if those edits may be discarded`);if(!e.dryRun){for(let n of t.manifest.files)tt(n.path,t.context),await B(n.path,{force:!0});e.host==="codex"&&await qt(t.context),await B(t.context.manifestPath,{force:!0}),await Ht(t.manifest.files.map(n=>n.path),[t.context.skillsRoot,t.context.agentsRoot,t.context.root])}O(e,{uninstalled:!e.dryRun,dryRun:e.dryRun,host:e.host,scope:e.scope,version:t.manifest.packageVersion,manifest:t.context.manifestPath,removedFiles:t.manifest.files.length,forcedModifiedFiles:e.force?t.modified.length:0})}function T(e){return{snapshot:e.snapshot??w(e.projectRoot,"reports","ontology-snapshot.json"),action:e.action,profile:e.profile??w(e.projectRoot,"reports","project-profile.json"),ledger:e.ledger??w(e.projectRoot,"reports","ontology-actions.jsonl"),attestation:e.attestation??w(e.projectRoot,"reports","ontology-attestation.json"),report:e.output??w(e.projectRoot,"reports","ontology-report.md")}}function x(e,t){let n=e?.projectRoot;return typeof n!="string"||!n?t:Ye(n)?E(n):E(t,n)}async function Mt(e){let t=T(e),n=await j(t.snapshot),i=await ve(n,e.status,e.projectRoot);O(e,{valid:i.failures.length===0,requestedStatus:e.status||"STRUCTURAL",snapshot:t.snapshot,failures:i.failures.map(o=>o.id),sourceDrift:i.sourceDrift,evidenceIntegrity:i.evidenceIntegrity,implementationIntegrity:i.implementationIntegrity,results:i.results}),i.failures.length>0&&(process.exitCode=1)}async function ve(e,t,n){let i=x(e,n),o=oe(e,t),a=await K(e,i),[c,l]=await Promise.all([W(e,i),X(e,i)]),p=a.filter(d=>d.status!=="UNCHANGED");o.push({id:"pass.sources.no-drift",status:t==="PASS"?p.length===0?"PASS":"FAIL":"NOT_APPLICABLE",severity:"blocking",message:"PASS requires every tracked design source to match its recorded revision.",objectIds:t==="PASS"?p.map(d=>d.id).sort():[]});let s=c.filter(d=>d.required&&d.status!=="UNCHANGED");o.push({id:"pass.evidence.artifacts-current",status:t==="PASS"?s.length===0?"PASS":"FAIL":"NOT_APPLICABLE",severity:"blocking",message:"PASS requires every required Evidence artifact to exist and match its recorded SHA-256 hash.",objectIds:t==="PASS"?s.map(d=>d.id).sort():[]});let r=l.filter(d=>d.required&&d.status!=="UNCHANGED");return o.push({id:"pass.implementation.artifacts-current",status:t==="PASS"?r.length===0?"PASS":"FAIL":"NOT_APPLICABLE",severity:"blocking",message:"PASS requires every required ImplementationUnit artifact to exist and match its recorded SHA-256 hash.",objectIds:t==="PASS"?r.map(d=>d.id).sort():[]}),{results:o,sourceDrift:a,evidenceIntegrity:c,implementationIntegrity:l,failures:o.filter(d=>d.status==="FAIL")}}async function ot(e){let t=T(e);if(!t.action)throw new Error("--action is required");let[n,i,o]=await Promise.all([j(t.action),j(t.snapshot),j(t.profile)]),a=fe(n,i,o,x(i,e.projectRoot));return a.push(...await Te(n,x(i,e.projectRoot))),{paths:t,action:n,snapshot:i,errors:a}}async function Ut(e){let t=await ot(e);O(e,{valid:t.errors.length===0,action:t.paths.action,actionId:t.action.id,actionType:t.action.type,errors:t.errors}),t.errors.length>0&&(process.exitCode=1)}async function _t(e){let t=await ot(e);if(t.errors.length>0)throw new Error(`action rejected: ${t.errors.join("; ")}`);e.dryRun||await ce(M(t.paths.ledger),{recursive:!0});let n=await xe(t.paths.ledger,t.action,{dryRun:e.dryRun,baseSnapshotRevision:t.snapshot.snapshotRevision,appliedActionIds:t.snapshot.appliedActionIds??[]});O(e,{...n,actionId:t.action.id,actionType:t.action.type,ledger:t.paths.ledger})}async function Ft(e){let t=T(e),[n,i,o]=await Promise.all([q(t.snapshot,"utf8"),j(t.profile),se(t.ledger)]),a=JSON.parse(n),c=ae(a,o,i,x(a,e.projectRoot));if(!e.dryRun&&c.applied>0){let l=`${t.snapshot}.tmp-${process.pid}`;try{if(await le(l,`${JSON.stringify(c.snapshot,null,2)}
14
+ `,"utf8"),await q(t.snapshot,"utf8")!==n)throw new Error("ontology snapshot changed during reconciliation; rerun against the latest revision");await me(l,t.snapshot)}catch(p){throw await B(l,{force:!0}),p}}O(e,{reconciled:!e.dryRun,dryRun:e.dryRun,snapshot:t.snapshot,ledger:t.ledger,appliedActions:c.applied,skippedActions:c.skipped,totalActions:c.total})}async function Bt(e){let t=T(e),n=await q(t.ledger,"utf8"),i=he(n),o=_(i);O(e,{valid:o.valid,ledger:t.ledger,records:o.recordCount,legacyRecords:i.filter(a=>a.schema==="dic.ontology-action-record.v1").length,chainedRecords:i.filter(a=>a.schema==="dic.ontology-action-record.v2").length,headHash:o.headHash,fileSha256:Be("sha256").update(n).digest("hex"),errors:o.errors}),o.valid||(process.exitCode=1)}async function Gt(e){let t=T(e),n=await j(t.snapshot),i=await W(n,x(n,e.projectRoot)),o=i.filter(a=>a.required&&a.status!=="UNCHANGED");O(e,{valid:o.length===0,requiredArtifacts:i.filter(a=>a.required).length,invalidArtifacts:o.map(a=>a.id),evidence:i}),o.length>0&&(process.exitCode=1)}async function Jt(e){let t=T(e),n=await j(t.snapshot),i=z(n),o=i.filter(a=>a.required&&a.status!=="CURRENT");O(e,{valid:o.length===0,requiredValidations:i.filter(a=>a.required).length,invalidValidations:o.map(a=>a.id),validations:i}),o.length>0&&(process.exitCode=1)}async function Yt(e){let t=T(e),n=await j(t.snapshot),i=await X(n,x(n,e.projectRoot)),o=i.filter(a=>a.required&&a.status!=="UNCHANGED");O(e,{valid:o.length===0,requiredArtifacts:i.filter(a=>a.required).length,invalidArtifacts:o.map(a=>a.id),implementations:i}),o.length>0&&(process.exitCode=1)}async function zt(e){if(!e.query)throw new Error("--query is required");let t=T(e),n=await j(t.snapshot),i=U(n,e.query,e.id);O(e,{query:e.query,startId:e.id||"",count:i.length,matches:i})}async function Kt(e){let t=T(e),n=await j(t.snapshot),i=await K(n,x(n,e.projectRoot)),o=i.filter(a=>a.status!=="UNCHANGED");O(e,{clean:o.length===0,trackedSources:i.filter(a=>a.status!=="UNTRACKED").length,driftedSources:o.length,sources:i}),o.length>0&&(process.exitCode=1)}async function Wt(e){let t=T(e),n=await j(t.snapshot),i=x(n,e.projectRoot),[o,a,c]=await Promise.all([K(n,i),X(n,i),W(n,i)]),l=qe(n,o,a,c);O(e,l)}async function Xt(e){if(!e.id)throw new Error("--id is required");let t=T(e),n=await j(t.snapshot);O(e,De(n,e.id))}function it(e,t){let n=new Set(t.map(o=>o.action?.id)),i=(e.appliedActionIds??[]).filter(o=>!n.has(o));if(i.length>0)throw new Error(`snapshot references actions missing from the ledger: ${i.join(", ")}`)}async function st(e,t){await ce(M(e),{recursive:!0});let n=`${e}.tmp-${process.pid}`;try{await le(n,t,"utf8"),await me(n,e)}catch(i){throw await B(n,{force:!0}),i}}async function Zt(e){if(!e.status)throw new Error("--status is required");if(!e.summary.trim())throw new Error("--summary is required");let t=T(e),[n,i,o,a]=await Promise.all([j(t.snapshot),j(t.profile),se(t.ledger),q(t.ledger,"utf8")]);it(n,o);let c=ae(n,o,i,x(n,e.projectRoot));if(c.applied>0)throw new Error(`${c.applied} recorded action(s) are not materialized; run ontology-reconcile first`);let l=await ve(n,e.status,e.projectRoot);if(l.results.find(r=>r.id==="ontology.snapshot.revision")?.status!=="PASS")throw new Error("attestation requires a canonical snapshotRevision; initialize or reconcile the snapshot first");if(l.failures.length>0)throw new Error(`attestation rejected by ontology gate: ${l.failures.map(r=>r.id).join(", ")}`);let s=Ve({snapshot:n,ledgerText:a,ledgerHeadHash:_(o).headHash,status:e.status,summary:e.summary.trim(),sourceDrift:l.sourceDrift,evidenceIntegrity:l.evidenceIntegrity,implementationIntegrity:l.implementationIntegrity,invariants:l.results});e.dryRun||await st(t.attestation,`${JSON.stringify(s,null,2)}
15
+ `),O(e,{created:!e.dryRun,dryRun:e.dryRun,attestation:t.attestation,attestationId:s.attestationId,contentHash:s.contentHash,status:s.status,snapshotRevision:s.snapshot.snapshotRevision,ledgerSha256:s.ledger.sha256,ledgerHeadHash:s.ledger.headHash})}async function Qt(e){let t=T(e),[n,i,o,a,c]=await Promise.all([j(t.attestation),j(t.snapshot),j(t.profile),se(t.ledger),q(t.ledger,"utf8")]);it(i,a);let l=ae(i,a,o,x(i,e.projectRoot));if(l.applied>0)throw new Error(`${l.applied} recorded action(s) are not materialized; attestation is stale`);let p=await ve(i,n.status,e.projectRoot),s=Me({attestation:n,snapshot:i,ledgerText:c,ledgerHeadHash:_(a).headHash,sourceDrift:p.sourceDrift,evidenceIntegrity:p.evidenceIntegrity,implementationIntegrity:p.implementationIntegrity,invariants:p.results,expectedContentHash:e.expectedHash});O(e,{...s,attestation:t.attestation}),s.valid||(process.exitCode=1)}async function en(e){let t=T(e),n=await j(t.snapshot),[i,o,a]=await Promise.all([K(n,x(n,e.projectRoot)),W(n,x(n,e.projectRoot)),X(n,x(n,e.projectRoot))]),c=Ue(n,i,o,a,e.status);e.dryRun||await st(t.report,c),O(e,{created:!e.dryRun,dryRun:e.dryRun,report:t.report,bytes:Buffer.byteLength(c),requestedStatus:e.status||"STRUCTURAL"})}function tn(){process.stdout.write(["DIC Workflow Kit installer and ontology runtime","","Usage:"," dic-workflow-kit <install|doctor|uninstall> [options]"," dic-workflow-kit ontology-check [--root <project>] [--status PASS]"," dic-workflow-kit ontology-reconcile [--root <project>] [--dry-run]"," dic-workflow-kit ontology-ledger-check [--root <project>]"," dic-workflow-kit ontology-evidence-check [--root <project>]"," dic-workflow-kit ontology-validation-check [--root <project>]"," dic-workflow-kit ontology-implementation-check [--root <project>]"," dic-workflow-kit ontology-query --query <name> [--id <object-id>]"," dic-workflow-kit ontology-drift [--root <project>]"," dic-workflow-kit ontology-plan [--root <project>]"," dic-workflow-kit ontology-explain --id <object-id>"," dic-workflow-kit ontology-report [--root <project>] [--status PASS]"," dic-workflow-kit ontology-attest --status <status> --summary <text>"," dic-workflow-kit ontology-attestation-check [--root <project>]"," dic-workflow-kit action-check --action <file> [--root <project>]"," dic-workflow-kit action-record --action <file> [--root <project>]","","Options:"," --host <host> Target host"," --scope user|project Installation scope"," --project-root <path> Repository root for project scope"," --root <path> Project/evidence root for ontology commands"," --snapshot <path> Override ontology snapshot path"," --profile <path> Override project profile path"," --action <path> Action request JSON"," --ledger <path> Override append-only action ledger path"," --status <status> Activate a terminal ontology gate"," --query <name> uncovered, gaps, unevidenced, or impact"," --id <object-id> Start object for an impact query"," --summary <text> Final attestation summary"," --output <path> Override generated report path"," --attestation <path> Override attestation artifact path"," --expected-hash <sha256> Require an externally anchored attestation hash"," --install-root <path> Override resolved host root"," --marketplace-root <path> Codex personal marketplace root"," --dry-run Preview without writing"," --force Overwrite/remove reviewed conflicts"," --json Emit machine-readable output","","Hosts:"," codex (default), claude-code, opencode, mimo-code, bitfun","","Examples:"," dic-workflow-kit install"," dic-workflow-kit doctor --host bitfun --scope project"," dic-workflow-kit uninstall --host opencode --scope project"," dic-workflow-kit ontology-check --root . --status PASS"," dic-workflow-kit ontology-reconcile --root ."," dic-workflow-kit ontology-ledger-check --root . --json"," dic-workflow-kit ontology-evidence-check --root . --json"," dic-workflow-kit ontology-validation-check --root . --json"," dic-workflow-kit ontology-implementation-check --root . --json"," dic-workflow-kit ontology-query --root . --query uncovered"," dic-workflow-kit ontology-drift --root ."," dic-workflow-kit ontology-plan --root . --json"," dic-workflow-kit ontology-explain --root . --id obl-example --json"," dic-workflow-kit ontology-report --root . --status PASS"," dic-workflow-kit ontology-attest --root . --status PASS --summary verified"," dic-workflow-kit ontology-attestation-check --root ."," dic-workflow-kit action-record --root . --action repair-action.json","","--marketplace-root is a backward-compatible Codex-only option.",""].join(`
16
+ `))}try{let e=Et(process.argv.slice(2));if(e.command==="install")await Dt(e);else if(e.command==="doctor")await Lt(e);else if(e.command==="uninstall")await Vt(e);else if(e.command==="ontology-check")await Mt(e);else if(e.command==="ontology-reconcile")await Ft(e);else if(e.command==="ontology-ledger-check")await Bt(e);else if(e.command==="ontology-evidence-check")await Gt(e);else if(e.command==="ontology-validation-check")await Jt(e);else if(e.command==="ontology-implementation-check")await Yt(e);else if(e.command==="ontology-query")await zt(e);else if(e.command==="ontology-drift")await Kt(e);else if(e.command==="ontology-plan")await Wt(e);else if(e.command==="ontology-explain")await Xt(e);else if(e.command==="ontology-report")await en(e);else if(e.command==="ontology-attest")await Zt(e);else if(e.command==="ontology-attestation-check")await Qt(e);else if(e.command==="action-check")await Ut(e);else if(e.command==="action-record")await _t(e);else if(e.command==="help"||e.command==="--help")tn();else throw new Error(`unknown command: ${e.command}`)}catch(e){process.argv.slice(2).includes("--json")?process.stderr.write(`${JSON.stringify({ok:!1,error:e.message},null,2)}
17
+ `):process.stderr.write(`ERROR: ${e.message}
10
18
  `),process.exitCode=1}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dic-workflow-kit",
3
- "version": "1.1.1",
4
- "description": "Install DIC Workflow Kit Skills and Subagents for Codex, Claude Code, OpenCode, and MiMo Code.",
3
+ "version": "1.1.3",
4
+ "description": "Install DIC Workflow Kit Skills and Subagents for Codex, Claude Code, OpenCode, MiMo Code, and BitFun.",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "dic-workflow-kit": "dist/dic-workflow-kit.mjs"
@@ -22,6 +22,7 @@
22
22
  "claude-code",
23
23
  "opencode",
24
24
  "mimo-code",
25
+ "bitfun",
25
26
  "plugin",
26
27
  "skills",
27
28
  "subagents",
@@ -12,7 +12,25 @@
12
12
  "artifacts": { "type": "array", "items": { "type": "string" } },
13
13
  "validation": { "type": "array", "items": { "type": "object" } },
14
14
  "changedFiles": { "type": "array", "items": { "type": "string" } },
15
- "residualRisks": { "type": "array", "items": { "type": "string" } }
15
+ "residualRisks": { "type": "array", "items": { "type": "string" } },
16
+ "ontologyAttestation": {
17
+ "type": ["string", "null"],
18
+ "description": "Path to the content-addressed ontology attestation when one was produced."
19
+ },
20
+ "ontologyInvariants": {
21
+ "type": "array",
22
+ "items": {
23
+ "type": "object",
24
+ "required": ["id", "status", "severity", "message", "objectIds"],
25
+ "properties": {
26
+ "id": { "type": "string" },
27
+ "status": { "enum": ["PASS", "FAIL", "NOT_APPLICABLE"] },
28
+ "severity": { "enum": ["info", "warning", "blocking"] },
29
+ "message": { "type": "string" },
30
+ "objectIds": { "type": "array", "items": { "type": "string" } }
31
+ }
32
+ }
33
+ }
16
34
  },
17
35
  "additionalProperties": true
18
36
  }
@@ -0,0 +1,62 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://dicworkflowkit.local/schemas/ontology-action-record.schema.json",
4
+ "title": "DIC Ontology Action Ledger Record",
5
+ "description": "One immutable entry in reports/ontology-actions.jsonl.",
6
+ "oneOf": [
7
+ { "$ref": "#/$defs/legacyRecord" },
8
+ { "$ref": "#/$defs/chainedRecord" }
9
+ ],
10
+ "$defs": {
11
+ "legacyRecord": {
12
+ "type": "object",
13
+ "required": ["schema", "recordedAt", "sha256", "action"],
14
+ "properties": {
15
+ "schema": { "const": "dic.ontology-action-record.v1" },
16
+ "recordedAt": { "type": "string", "format": "date-time" },
17
+ "sha256": {
18
+ "type": "string",
19
+ "pattern": "^[a-f0-9]{64}$"
20
+ },
21
+ "action": { "$ref": "ontology-action.schema.json" }
22
+ },
23
+ "additionalProperties": false
24
+ },
25
+ "chainedRecord": {
26
+ "type": "object",
27
+ "required": [
28
+ "schema",
29
+ "sequence",
30
+ "recordedAt",
31
+ "previousHash",
32
+ "baseSnapshotRevision",
33
+ "actionHash",
34
+ "recordHash",
35
+ "action"
36
+ ],
37
+ "properties": {
38
+ "schema": { "const": "dic.ontology-action-record.v2" },
39
+ "sequence": { "type": "integer", "minimum": 1 },
40
+ "recordedAt": { "type": "string", "format": "date-time" },
41
+ "previousHash": {
42
+ "type": "string",
43
+ "pattern": "^[a-f0-9]{64}$"
44
+ },
45
+ "baseSnapshotRevision": {
46
+ "type": "string",
47
+ "pattern": "^[a-f0-9]{64}$"
48
+ },
49
+ "actionHash": {
50
+ "type": "string",
51
+ "pattern": "^[a-f0-9]{64}$"
52
+ },
53
+ "recordHash": {
54
+ "type": "string",
55
+ "pattern": "^[a-f0-9]{64}$"
56
+ },
57
+ "action": { "$ref": "ontology-action.schema.json" }
58
+ },
59
+ "additionalProperties": false
60
+ }
61
+ }
62
+ }
@@ -0,0 +1,110 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://dicworkflowkit.local/schemas/ontology-action.schema.json",
4
+ "title": "DIC Ontology Action",
5
+ "description": "Auditable request to change ontology or repository state.",
6
+ "type": "object",
7
+ "required": [
8
+ "schema",
9
+ "id",
10
+ "type",
11
+ "actor",
12
+ "status",
13
+ "targets",
14
+ "preconditions",
15
+ "postconditions",
16
+ "evidence"
17
+ ],
18
+ "properties": {
19
+ "schema": { "const": "dic.ontology-action.v1" },
20
+ "id": {
21
+ "type": "string",
22
+ "pattern": "^act-[a-zA-Z0-9._:-]+$"
23
+ },
24
+ "type": {
25
+ "enum": [
26
+ "IntakeDesignSource",
27
+ "ConfirmObligation",
28
+ "ObserveImplementation",
29
+ "OpenGap",
30
+ "ProposeRepair",
31
+ "ApproveRepair",
32
+ "ApplyRepair",
33
+ "RunValidation",
34
+ "AttachEvidence",
35
+ "CloseGap",
36
+ "MarkBlocked",
37
+ "SupersedeSource"
38
+ ]
39
+ },
40
+ "actor": { "type": "string", "minLength": 1 },
41
+ "expectedSnapshotRevision": {
42
+ "type": "string",
43
+ "pattern": "^[a-f0-9]{64}$",
44
+ "description": "Optional optimistic-concurrency precondition for authored actions."
45
+ },
46
+ "status": {
47
+ "enum": [
48
+ "proposed",
49
+ "approved",
50
+ "in_progress",
51
+ "completed",
52
+ "rejected",
53
+ "blocked",
54
+ "rolled_back"
55
+ ]
56
+ },
57
+ "targets": {
58
+ "type": "array",
59
+ "items": { "type": "string" },
60
+ "minItems": 1,
61
+ "uniqueItems": true
62
+ },
63
+ "parameters": {
64
+ "type": "object",
65
+ "properties": {
66
+ "ontologyPatch": {
67
+ "$ref": "ontology-patch.schema.json"
68
+ }
69
+ },
70
+ "additionalProperties": true
71
+ },
72
+ "preconditions": {
73
+ "type": "array",
74
+ "items": { "$ref": "#/$defs/condition" }
75
+ },
76
+ "postconditions": {
77
+ "type": "array",
78
+ "items": { "$ref": "#/$defs/condition" }
79
+ },
80
+ "allowedPaths": {
81
+ "type": "array",
82
+ "items": { "type": "string" },
83
+ "uniqueItems": true
84
+ },
85
+ "evidence": {
86
+ "type": "array",
87
+ "items": { "type": "string" },
88
+ "uniqueItems": true
89
+ },
90
+ "rollback": {
91
+ "type": ["string", "null"]
92
+ }
93
+ },
94
+ "$defs": {
95
+ "condition": {
96
+ "type": "object",
97
+ "required": ["description", "status"],
98
+ "properties": {
99
+ "description": { "type": "string", "minLength": 1 },
100
+ "status": { "enum": ["PENDING", "PASS", "FAIL"] },
101
+ "evidence": {
102
+ "type": "array",
103
+ "items": { "type": "string" }
104
+ }
105
+ },
106
+ "additionalProperties": false
107
+ }
108
+ },
109
+ "additionalProperties": false
110
+ }
@@ -0,0 +1,187 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://dicworkflowkit.local/schemas/ontology-attestation.schema.json",
4
+ "title": "DIC Ontology Attestation",
5
+ "description": "Content-addressed final decision bound to ontology, ledger, sources, and invariants.",
6
+ "type": "object",
7
+ "required": [
8
+ "schema",
9
+ "attestationId",
10
+ "contentHash",
11
+ "version",
12
+ "status",
13
+ "final",
14
+ "summary",
15
+ "createdAt",
16
+ "snapshot",
17
+ "ledger",
18
+ "sources",
19
+ "evidence",
20
+ "implementations",
21
+ "validationCausality",
22
+ "invariants"
23
+ ],
24
+ "properties": {
25
+ "schema": { "const": "dic.ontology-attestation.v1" },
26
+ "attestationId": {
27
+ "type": "string",
28
+ "pattern": "^att-[a-f0-9]{16}$"
29
+ },
30
+ "contentHash": {
31
+ "type": "string",
32
+ "pattern": "^[a-f0-9]{64}$"
33
+ },
34
+ "version": { "type": "string" },
35
+ "status": { "enum": ["PASS", "PARTIAL", "BLOCKED", "FAIL"] },
36
+ "final": { "const": true },
37
+ "summary": { "type": "string", "minLength": 1 },
38
+ "createdAt": { "type": "string", "format": "date-time" },
39
+ "snapshot": {
40
+ "type": "object",
41
+ "required": ["snapshotId", "snapshotRevision"],
42
+ "properties": {
43
+ "snapshotId": { "type": "string" },
44
+ "snapshotRevision": {
45
+ "type": "string",
46
+ "pattern": "^[a-f0-9]{64}$"
47
+ }
48
+ },
49
+ "additionalProperties": false
50
+ },
51
+ "ledger": {
52
+ "type": "object",
53
+ "required": ["sha256", "actionCount", "headHash"],
54
+ "properties": {
55
+ "sha256": {
56
+ "type": "string",
57
+ "pattern": "^[a-f0-9]{64}$"
58
+ },
59
+ "actionCount": { "type": "integer", "minimum": 0 },
60
+ "headHash": {
61
+ "type": "string",
62
+ "pattern": "^[a-f0-9]{64}$"
63
+ }
64
+ },
65
+ "additionalProperties": false
66
+ },
67
+ "sources": {
68
+ "type": "array",
69
+ "items": {
70
+ "type": "object",
71
+ "required": ["id", "path", "status", "contentHash"],
72
+ "properties": {
73
+ "id": { "type": "string" },
74
+ "path": { "type": "string" },
75
+ "status": {
76
+ "enum": [
77
+ "UNCHANGED",
78
+ "CHANGED",
79
+ "MISSING",
80
+ "UNTRACKED",
81
+ "OUTSIDE_PROJECT",
82
+ "INVALID"
83
+ ]
84
+ },
85
+ "contentHash": { "type": "string" }
86
+ },
87
+ "additionalProperties": false
88
+ }
89
+ },
90
+ "evidence": {
91
+ "type": "array",
92
+ "items": {
93
+ "type": "object",
94
+ "required": ["id", "path", "status", "contentHash"],
95
+ "properties": {
96
+ "id": { "type": "string" },
97
+ "path": { "type": "string" },
98
+ "status": {
99
+ "enum": [
100
+ "UNCHANGED",
101
+ "CHANGED",
102
+ "MISSING",
103
+ "UNTRACKED",
104
+ "OUTSIDE_PROJECT",
105
+ "INACTIVE",
106
+ "INVALID"
107
+ ]
108
+ },
109
+ "contentHash": { "type": "string" }
110
+ },
111
+ "additionalProperties": false
112
+ }
113
+ },
114
+ "implementations": {
115
+ "type": "array",
116
+ "items": {
117
+ "type": "object",
118
+ "required": ["id", "path", "status", "contentHash"],
119
+ "properties": {
120
+ "id": { "type": "string" },
121
+ "path": { "type": "string" },
122
+ "status": {
123
+ "enum": [
124
+ "UNCHANGED",
125
+ "CHANGED",
126
+ "MISSING",
127
+ "UNTRACKED",
128
+ "OUTSIDE_PROJECT",
129
+ "INACTIVE",
130
+ "INVALID"
131
+ ]
132
+ },
133
+ "contentHash": { "type": "string" }
134
+ },
135
+ "additionalProperties": false
136
+ }
137
+ },
138
+ "validationCausality": {
139
+ "type": "array",
140
+ "items": {
141
+ "type": "object",
142
+ "required": [
143
+ "id",
144
+ "status",
145
+ "targetIds",
146
+ "requiredInputIds",
147
+ "missingInputIds",
148
+ "staleInputIds"
149
+ ],
150
+ "properties": {
151
+ "id": { "type": "string" },
152
+ "status": {
153
+ "enum": ["CURRENT", "INCOMPLETE", "STALE", "INVALID"]
154
+ },
155
+ "targetIds": {
156
+ "type": "array",
157
+ "items": { "type": "string" },
158
+ "uniqueItems": true
159
+ },
160
+ "requiredInputIds": {
161
+ "type": "array",
162
+ "items": { "type": "string" },
163
+ "uniqueItems": true
164
+ },
165
+ "missingInputIds": {
166
+ "type": "array",
167
+ "items": { "type": "string" },
168
+ "uniqueItems": true
169
+ },
170
+ "staleInputIds": {
171
+ "type": "array",
172
+ "items": { "type": "string" },
173
+ "uniqueItems": true
174
+ }
175
+ },
176
+ "additionalProperties": false
177
+ }
178
+ },
179
+ "invariants": {
180
+ "type": "array",
181
+ "items": {
182
+ "$ref": "ontology-snapshot.schema.json#/$defs/invariantResult"
183
+ }
184
+ }
185
+ },
186
+ "additionalProperties": false
187
+ }