workspai 0.77.0 → 0.79.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.
- package/contracts/create-planner-capabilities.v1.json +27 -3
- package/contracts/runtime-command-surface.v1.json +2 -0
- package/contracts/workspace-intelligence-architecture.v1.json +2 -0
- package/dist/analyze-SKOIUD6F.js +1 -0
- package/dist/autopilot-release-MDMVMU67.js +1 -0
- package/dist/{chunk-UP3UWAJV.js → chunk-2ZVE7VE2.js} +1 -1
- package/dist/{chunk-47UR6ZH4.js → chunk-3O344BX3.js} +1 -1
- package/dist/{chunk-IDETNYCF.js → chunk-4H3VNKOJ.js} +1 -1
- package/dist/{chunk-LUPKDFQ3.js → chunk-7EMG3C3H.js} +2 -2
- package/dist/{chunk-O3TVVQ6X.js → chunk-7HV4U2OV.js} +1 -1
- package/dist/{chunk-DWKCFHHL.js → chunk-7MIOAM4A.js} +1 -1
- package/dist/{chunk-E7WJ2QX7.js → chunk-7SN4V3RC.js} +1 -1
- package/dist/{chunk-X5XFT5UZ.js → chunk-BGUCDG5N.js} +1 -1
- package/dist/{chunk-IAXRGH4Q.js → chunk-CJBDYDVC.js} +1 -1
- package/dist/{chunk-UTIK3K3M.js → chunk-EPFEUMYF.js} +1 -1
- package/dist/{chunk-4CXV3PPV.js → chunk-ETTZXKAS.js} +1 -1
- package/dist/{chunk-V6HVDVKJ.js → chunk-FVG5FBA4.js} +5 -5
- package/dist/{chunk-J2MPBSQJ.js → chunk-GUCZOQUS.js} +1 -1
- package/dist/{chunk-SC43A6LH.js → chunk-H24MEOML.js} +50 -50
- package/dist/{chunk-ZIWWE4BQ.js → chunk-HXTNPR3M.js} +1 -1
- package/dist/chunk-ICPL4WNK.js +2 -0
- package/dist/{chunk-475GQJ2D.js → chunk-KRTVIBPC.js} +1 -1
- package/dist/{chunk-GLBFY7AB.js → chunk-KTOKU6HQ.js} +2 -2
- package/dist/{chunk-QCX6BO2M.js → chunk-MNZAJ6PP.js} +1 -1
- package/dist/chunk-O4TZKLEC.js +1 -0
- package/dist/{chunk-HRVHQBTA.js → chunk-R7R5FX4B.js} +1 -1
- package/dist/chunk-RQXZF7BZ.js +1 -0
- package/dist/{chunk-UNEK3VVR.js → chunk-RRZQPFFR.js} +2171 -109
- package/dist/{chunk-3EPR3D5Q.js → chunk-SKHRUHXO.js} +1 -1
- package/dist/{chunk-WC2K5QFI.js → chunk-SV7X5LJW.js} +1 -1
- package/dist/{chunk-TGNPMOM6.js → chunk-TQW2SZHH.js} +1 -1
- package/dist/{chunk-JVZA35OL.js → chunk-U5WP4HDH.js} +1 -1
- package/dist/{chunk-223SWPTL.js → chunk-VT4WPXTO.js} +1 -1
- package/dist/chunk-WU5M6UP7.js +2 -0
- package/dist/{chunk-3EMAC3MF.js → chunk-ZDLF77IS.js} +1 -1
- package/dist/{chunk-3SQIV3F4.js → chunk-ZONAHZBG.js} +1 -1
- package/dist/{create-YPAZJYCE.js → create-M3TWRHV6.js} +1 -1
- package/dist/{doctor-W5PXJ5FL.js → doctor-FF3WLJSP.js} +1 -1
- package/dist/{goal-lifecycle-5R55CA7H.js → goal-lifecycle-O4MYYTRU.js} +1 -1
- package/dist/{goal-pack-IS6GGJPH.js → goal-pack-NUDKANPM.js} +1 -1
- package/dist/index.js +92 -91
- package/dist/{pipeline-LW3SW2WT.js → pipeline-V5P2FX2P.js} +1 -1
- package/dist/{project-agent-entry-5TYKK5IV.js → project-agent-entry-6O7FKWSL.js} +1 -1
- package/dist/{project-intelligence-lens-TEOSTKNU.js → project-intelligence-lens-OQTZ4K7L.js} +1 -1
- package/dist/{project-test-coverage-T4TIWGKN.js → project-test-coverage-EJ3MBSZ3.js} +1 -1
- package/dist/{proof-carrying-change-2TKRADCW.js → proof-carrying-change-GV37YLDQ.js} +1 -1
- package/dist/{verified-goal-RN4TOV34.js → verified-goal-VB7IOTNO.js} +1 -1
- package/dist/{workspace-A33YMF2N.js → workspace-AXU6ODER.js} +1 -1
- package/dist/{workspace-agent-sync-VCA4G4DT.js → workspace-agent-sync-6427FNME.js} +1 -1
- package/dist/{workspace-context-YBWLSKR6.js → workspace-context-VVZARI5K.js} +1 -1
- package/dist/{workspace-contract-3QUZDBMM.js → workspace-contract-N2BJCAJ7.js} +1 -1
- package/dist/{workspace-explain-NXYRAQFI.js → workspace-explain-5WKK6ENK.js} +1 -1
- package/dist/{workspace-foundation-DZ52PECX.js → workspace-foundation-GYL3D7TW.js} +1 -1
- package/dist/{workspace-graph-stream-4VT46HZ7.js → workspace-graph-stream-26ME2JJS.js} +1 -1
- package/dist/{workspace-intelligence-FKYQQDJ6.js → workspace-intelligence-ZTET7JHS.js} +1 -1
- package/dist/{workspace-intelligence-runner-3K2JZH6Q.js → workspace-intelligence-runner-2EJ7GXG5.js} +1 -1
- package/dist/{workspace-knowledge-graph-CPBKNXQI.js → workspace-knowledge-graph-4RSZTEFJ.js} +1 -1
- package/dist/workspace-knowledge-graph-snapshot-UTJHALST.js +1 -0
- package/dist/{workspace-mcp-serve-UXPKX7K6.js → workspace-mcp-serve-BSA6Q4EB.js} +1 -1
- package/dist/{workspace-model-POCPMNRT.js → workspace-model-LBICKRVI.js} +1 -1
- package/dist/{workspace-onboarding-KLG3GG7S.js → workspace-onboarding-NH4WFJ5N.js} +1 -1
- package/dist/{workspace-registry-summary-M4WMFDQ4.js → workspace-registry-summary-3PXZENLC.js} +1 -1
- package/dist/{workspace-repair-engine-2VGN42QD.js → workspace-repair-engine-ODTFFM6O.js} +1 -1
- package/dist/workspace-run-VDQ6BYLS.js +1 -0
- package/dist/{workspace-verify-PLAKTF3J.js → workspace-verify-UQWAFGNQ.js} +1 -1
- package/dist/{workspace-watch-VNU4KVYN.js → workspace-watch-BKIZQ2SM.js} +1 -1
- package/docs/agent-framework-adapters.md +88 -32
- package/docs/ci-workflows.md +10 -7
- package/docs/commands-reference.md +13 -9
- package/docs/create-planner-capabilities.md +1 -1
- package/docs/creating-workspaces-and-projects.md +24 -20
- package/docs/doctor-command.md +5 -3
- package/docs/model-gateways.md +23 -23
- package/docs/native-kit-baselines.md +2 -2
- package/package.json +4 -1
- package/scripts/enterprise-package-smoke.mjs +50 -0
- package/dist/analyze-TJM66CPF.js +0 -1
- package/dist/autopilot-release-C7Q4OTPY.js +0 -1
- package/dist/chunk-5KXOV7W4.js +0 -1
- package/dist/chunk-IHWS3ALP.js +0 -2
- package/dist/chunk-N7DOKE7V.js +0 -2
- package/dist/chunk-SEZTSMRR.js +0 -1
- package/dist/workspace-knowledge-graph-snapshot-67XDXUOT.js +0 -1
- package/dist/workspace-run-5YQR7GEZ.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-FIK343LI.js';import {c as c$1}from'./chunk-
|
|
1
|
+
import {a as a$1}from'./chunk-FIK343LI.js';import {c as c$1}from'./chunk-7MIOAM4A.js';import {l,q}from'./chunk-4H3VNKOJ.js';import {f,h as h$2,g}from'./chunk-ZONAHZBG.js';import {a as a$3}from'./chunk-ETTZXKAS.js';import {i,h as h$1,d,b as b$1,a as a$2,c as c$2,k as k$1}from'./chunk-BLEIUQL6.js';import {b as b$3}from'./chunk-VN2MKTQO.js';import {a}from'./chunk-AFIFZTOY.js';import {a as a$4}from'./chunk-XWKGZRHN.js';import {c,d as d$1}from'./chunk-EWZZUQBR.js';import {b as b$2}from'./chunk-25AWHAB5.js';import {h,i as i$1,m,k,n,o,g as g$1,l as l$1,j as j$1,s,e,f as f$1}from'./chunk-ODK4LCEL.js';import {a as a$5}from'./chunk-FB7SCXAZ.js';import {randomUUID,createHash}from'crypto';import b from'path';import z from'fs-extra';var nt=new Set(["committed","rejected","aborted","superseded"]);function u(e,t){if(!e)throw new Error(`Decision protocol violation: ${t}`)}function st(e){return [...new Set(e)].sort()}function We(e,t){return t.digestCanonical(e.effects.map(a=>({id:a.id,status:a.status,key:a.idempotencyKey})))}function Me(e,t,a){u(!e.some(r=>r.id===t),`${a} receipt '${t}' already exists`);}function it(e,t){Me(e.effects,t.id,"effect");let a=e.effects.find(r=>r.idempotencyKey===t.idempotencyKey);return u(!a,`effect idempotency key '${t.idempotencyKey}' was already recorded by '${a?.id}'`),[...e.effects,t]}function ot(e,t,a){return Me(e.verifications,t.id,"verification"),u(t.target.effectHeadDigest===We(e,a),`verification '${t.id}' does not bind the current effect head`),[...e.verifications,t]}function ct(e){return e.requiredCriteria.every(t=>{let a=e.verifications.filter(r=>r.criterionId===t);return a.length>0&&a.at(-1)?.status==="passed"})}function dt(e$1,t,a){if(t.kind==="created"){u(e$1===null,"created must be the first event");let y=t.payload.references?.[0];u(y,"created must bind an intent artifact");let p=t.payload.references?.filter(k=>k.role==="success-criterion").map(k=>k.artifact)??[];return {schemaVersion:e,id:t.transactionId,purpose:"proof-carrying-change",createdAt:t.occurredAt,updatedAt:t.occurredAt,state:"draft",generation:1,eventCount:t.sequence,eventHeadDigest:t.digest,intent:y,requiredCriteria:st(p),scope:null,evidence:[],plans:[],authorization:null,effects:[],verifications:[],blockers:[]}}u(e$1,`${t.kind} cannot occur before created`),u(!nt.has(e$1.state),`${t.kind} cannot follow terminal state ${e$1.state}`);let r=e$1.state,n=e$1.scope,s=e$1.evidence,d=e$1.plans,f=e$1.authorization,l=e$1.effects,o=e$1.verifications,c=e$1.blockers,h=e$1.terminalReason;switch(t.kind){case "scope-bound":u(e$1.state==="draft"||e$1.state==="scoped","scope-bound requires draft or scoped state"),u(t.payload.scope,"scope-bound requires scope"),n=t.payload.scope,r="scoped";break;case "evidence-attached":u(e$1.state==="scoped"||e$1.state==="evidence-ready","evidence-attached requires scoped state"),u((t.payload.references?.length??0)>0,"evidence-attached requires references"),s=[...s,...t.payload.references??[]],r="evidence-ready";break;case "plan-attached":u(e$1.state==="evidence-ready","plan-attached requires evidence-ready state"),u((t.payload.references?.length??0)>0,"plan-attached requires references"),d=[...d,...t.payload.references??[]];break;case "authorized":u(e$1.state==="evidence-ready","authorization requires evidence-ready state"),u(t.payload.authorization,"authorized requires a bounded authorization grant"),f=t.payload.authorization,r="authorized";break;case "effect-requested":u(e$1.state==="authorized"||e$1.state==="executing","effect-requested requires authorization"),r="executing";break;case "effect-recorded":u(e$1.state==="authorized"||e$1.state==="executing","effect-recorded requires authorization"),u(t.payload.effect,"effect-recorded requires a receipt"),u(f?.effectClasses.includes(t.payload.effect.effectClass),`effect class '${t.payload.effect.effectClass}' is outside the authorization grant`),l=it(e$1,t.payload.effect),r=t.payload.effect.status==="succeeded"?"executing":"blocked",t.payload.effect.status!=="succeeded"&&(c=[...c,{code:t.payload.effect.status==="uncertain"?"decision.effect.uncertain":"decision.effect.failed",actionable:true,details:t.payload.effect.summary}]);break;case "effect-uncertain":u(e$1.state==="authorized"||e$1.state==="executing","effect-uncertain requires an active execution"),r="blocked",c=[...c,t.payload.blocker??{code:"decision.effect.uncertain",actionable:true}];break;case "verification-started":u(e$1.state==="authorized"||e$1.state==="executing","verification-started requires authorized or executing state"),r="verifying";break;case "verification-recorded":{u(e$1.state==="verifying","verification-recorded requires verifying state"),u(t.payload.verification,"verification-recorded requires a receipt"),o=ot(e$1,t.payload.verification,a),r=t.payload.verification.status==="failed"?"blocked":t.payload.verification.status==="inconclusive"?"awaiting-human":"verifying";break}case "human-required":r="awaiting-human";break;case "blocked":u(t.payload.blocker,"blocked requires a structured blocker"),c=[...c,t.payload.blocker],r="blocked";break;case "resumed":u(e$1.state==="blocked"||e$1.state==="awaiting-human","resumed requires a paused state"),u(t.payload.resumeTo,"resumed requires an explicit target state"),r=t.payload.resumeTo,c=[];break;case "committed":u(e$1.state==="verifying","commit requires verifying state"),u(ct(e$1),"every required criterion needs a latest passing receipt"),u(!e$1.effects.some(y=>y.status!=="succeeded"),"all effects must be certainly successful"),r="committed",h=t.payload.reason??t.payload.summary;break;case "rejected":case "aborted":case "superseded":r=t.kind,h=t.payload.reason??t.payload.summary;break;default:throw new Error(`Decision protocol violation: unsupported event ${t.kind}`)}return {...e$1,updatedAt:t.occurredAt,state:r,generation:e$1.generation+1,eventCount:t.sequence,eventHeadDigest:t.digest,scope:n,evidence:s,plans:d,authorization:f,effects:l,verifications:o,blockers:c,...h?{terminalReason:h}:{}}}function Be(e,t,a,r){let n=(t?.sequence??0)+1,s={schemaVersion:f$1,transactionId:e,sequence:n,kind:a.kind,occurredAt:a.occurredAt,actor:a.actor,previousEventDigest:t?.digest??null,payload:a.payload};return {...s,digest:r.digestCanonical(s)}}function ee(e,t){u(e.length>0,"at least one event is required");let a=null,r=null;for(let n of e){u(n.schemaVersion===f$1,`unsupported event schema ${n.schemaVersion}`),u(n.sequence===(r?.sequence??0)+1,`event sequence ${n.sequence} is not contiguous`),u(n.previousEventDigest===(r?.digest??null),`event ${n.sequence} has an invalid previous digest`);let{digest:s,...d}=n;u(n.digest===t.digestCanonical(d),`event ${n.sequence} digest is invalid`),u(!r||n.transactionId===r.transactionId,"events cross transaction boundaries"),a=dt(a,n,t),r=n;}return a}function he(e,t,a){return {schemaVersion:g$1,transactionId:e.id,generatedAt:t,generation:e.generation,eventCount:e.eventCount,eventHeadDigest:e.eventHeadDigest,state:e.state,transactionDigest:a.digestCanonical(e)}}function te(e,t){return We(e,t)}var M={digestCanonical:c};function ft(e){let t=e.trim();if(!/^change-[a-z0-9][a-z0-9-]{7,95}$/.test(t))throw new Error(`Invalid decision transaction id: ${e}`);return t}function L(e){let a=`.workspai/decisions/${ft(e)}`;return {directory:a,transaction:`${a}/transaction.json`,checkpoint:`${a}/checkpoint.json`,events:`${a}/events.jsonl`,lock:`${a}.lock`}}function gt(e,t){return e.split(/\r?\n/).filter(r=>r.trim().length>0).map((r,n)=>{try{return JSON.parse(r)}catch(s){throw new Error(`Decision event log is corrupt at ${t}:${n+1}: ${s.message}`)}})}async function Le(e,t){let a=L(t),r=await b$1(e,a.events);return r?gt(await z.readFile(r,"utf8"),r):[]}function Ue(e,t){let a=L(t);return {directory:a$2(e,a.directory),transaction:a$2(e,a.transaction),checkpoint:a$2(e,a.checkpoint),events:a$2(e,a.events)}}async function ht(e,t,a$1,r){let n=L(t.id),s=he(t,r,M);for(let[d,f]of a$1.entries())a(f,"contracts/workspace-intelligence/decision-event.v1.json",`Decision event ${d+1}`);return b$3(n.transaction,t),b$3(n.checkpoint,s),await k$1(e,n.events,`${a$1.map(d=>JSON.stringify(d)).join(`
|
|
2
2
|
`)}
|
|
3
3
|
`),await h$1(e,n.transaction,t),await h$1(e,n.checkpoint,s),{transaction:t,checkpoint:s,events:a$1,paths:Ue(e,t.id)}}async function Fe(e){let t=L(e.transactionId),a=a$2(e.workspacePath,t.lock);return a$4(a,async()=>{let r=await Le(e.workspacePath,e.transactionId),n=r.at(-1)??null;if((n?.digest??null)!==e.expectedHeadDigest)throw new Error(`Decision transaction head changed: expected ${e.expectedHeadDigest??"<empty>"}, observed ${n?.digest??"<empty>"}`);r.length>0&&ee(r,M);let s=Be(e.transactionId,n,e.event,M),d=[...r,s],f=ee(d,M);return ht(e.workspacePath,f,d,e.event.occurredAt)},{purpose:`decision:${e.transactionId}`,timeoutMs:3e4,staleMs:6e4})}async function Je(e,t){let a=await Le(e,t);if(a.length===0)throw new Error(`Decision transaction not found: ${t}`);let r=ee(a,M),n=he(r,r.updatedAt,M);return {transaction:r,checkpoint:n,events:a,paths:Ue(e,t)}}function U(e){return L(e).directory}var me={digestCanonical:c},ut="workspai.deleted-artifact-tombstone.v1";function mt(e){let t=e.trim();if(!/^change-[a-z0-9][a-z0-9-]{7,95}$/.test(t))throw new Error(`Invalid proof-carrying change id: ${e}`);return t}function V(e){let a=`.workspai/changes/${mt(e)}`;return {directory:a,lease:`${a}/lease.json`,prediction:`${a}/predicted-overlay.json`,actualOverlay:`${a}/actual-overlay.json`,surprises:`${a}/architecture-surprises.json`,workspaceVerification:`${a}/verification/workspace-verify.json`,capsule:`${a}/capsule.json`,privateBaselineGraph:`${a}/private/baseline-graph.json`}}function wt(e,t){return {kind:e,id:t}}function T(e){return {role:e.role,artifact:e.artifact,schemaVersion:e.schemaVersion,digest:{algorithm:"sha256",semantics:e.semantics??"canonical-json-v1",value:e.value}}}async function A(e,t){let a=await b$1(e,t);return a?await z.readJson(a):null}async function Qe(e,t){let a=await d(e,v(t));return !a||!(await z.stat(a).catch(()=>null))?.isFile()?null:createHash("sha256").update(await z.readFile(a)).digest("hex")}async function yt(e,t){let a=new Map;await Promise.all(t.proofs.map(async n=>{let s=v(n.artifact),d=a.get(s);d||(d=Qe(e,s),a.set(s,d)),await d;}));let r=Object.fromEntries((await Promise.all([...a.entries()].map(async([n,s])=>[n,await s]))).filter(n=>typeof n[1]=="string"));return {...t,pccArtifactContentHashes:r}}async function vt(e){let a=(await A(e,s.workspaceContract.artifactPath))?.workspace?.name;if(typeof a=="string"&&a.trim())return a.trim();let r=await A(e,".workspai/workspace.json"),n=r?.workspace_name??r?.name;return typeof n=="string"&&n.trim()?n.trim():b.basename(e)}async function F(e,t){let a=await c$2(e,t.artifact);if(!a)return false;if(t.digest.semantics==="raw-bytes-v1"){let s=await z.readFile(a);return createHash("sha256").update(s).digest("hex")===t.digest.value}let r=await z.readJson(a).catch(()=>null);return r?(t.digest.semantics==="workspace-model-structural-v1"?d$1(r):c(r))===t.digest.value:false}function Ze(e){return c({schemaVersion:ut,artifact:v(e),deleted:true})}function kt(e){let t=v(e.artifact);if(!t||t==="."||t===".."||t.startsWith("../"))throw new Error(`Deleted artifact identity must be a contained relative path: ${e.artifact}`);return {artifact:t,observedAt:e.observedAt??new Date().toISOString(),digest:{algorithm:"sha256",semantics:"deletion-tombstone-v1",value:Ze(t)}}}async function et(e,t){if(t.digest.algorithm!=="sha256"||t.digest.semantics!=="deletion-tombstone-v1"||t.digest.value!==Ze(t.artifact))return false;let a=await d(e,t.artifact);return a!==null&&!await z.pathExists(a)}async function Pt(e,t){let a=await A(e,V(t).lease);if(!a||a.schemaVersion!==h)throw new Error(`Architecture lease is missing or unsupported for ${t}.`);if(a.changeId!==t)throw new Error(`Architecture lease binding failed for ${t}.`);return a}async function J(e){let t=await a$3(e);if(t.status==="miss")throw new Error(`A current canonical Model and Graph are required (${t.reason}). Run workspai workspace intelligence run --for-agent generic --strict --json.`);return t}function Ct(e,t,a){return c({modelHash:e,graphHash:t,inputHash:a})}function Y(e){let t=d$1(e.model),a=c(e.graph),r=e.graph.source.inputs?.hash;if(!r)throw new Error("The canonical Graph has no live input fingerprint.");return {modelHash:t,graphHash:a,inputHash:r,generation:Ct(t,a,r)}}async function we(e,t){let a=await J(e),r=Y(a);if(r.generation!==t.generation)throw new Error(`Architecture lease ${t.changeId} is stale. Expected generation ${t.generation}, observed ${r.generation}. Abort or begin a new change from current evidence.`);return a}function C(e,t,a,r,n=new Date().toISOString()){return {kind:e,payload:t,occurredAt:n,actor:wt(a,r)}}async function I(e,t,a,r){return Fe({workspacePath:e,transactionId:a,expectedHeadDigest:t?.transaction.eventHeadDigest??null,event:r})}function D(e,t,a){return `${e}\0${t}\0${a}`}var tt="agent-framework-change-plan",It=new Set(["init","test","build"]);function At(e){if(!e.record.transaction.plans.some(n=>n.role===tt))return false;let a=new Set(e.lease.scope.projects),r=e.verify.steps.filter(n=>{if(n.scope!=="project"||!n.project||!a.has(n.project))return false;let s=n.id.split(".").at(-1);return s!==void 0&&It.has(s)});return r.some(n=>n.status==="fail")?false:r.length===0||r.some(n=>n.status==="missing")}function bt(e){let t=[];for(let[a,r]of [["entity",e.entities],["relation",e.relations],["proof",e.proofs]])t.push(...r.added.map(n=>({operation:"add",targetKind:a,targetId:n.id}))),t.push(...r.removed.map(n=>({operation:"remove",targetKind:a,targetId:n.id}))),t.push(...r.changed.map(n=>({operation:"change",targetKind:a,targetId:n.id})));return t.push(...e.changedArtifacts.map(a=>({operation:"change",targetKind:"artifact",targetId:a}))),t.sort((a,r)=>D(a.operation,a.targetKind,a.targetId).localeCompare(D(r.operation,r.targetKind,r.targetId)))}function Et(e,t){let a=new Set(t.filter(o=>o.targetKind==="artifact").map(o=>v(o.targetId)));if(a.size===0)return new Set;let r=new Set,n=new Set,s=(o,c)=>{a.has(v(c.artifact))&&(n.add(c.id),r.add(D(o,"proof",c.id)));};e.proofs.added.forEach(o=>s("add",o)),e.proofs.removed.forEach(o=>s("remove",o)),e.proofs.changed.forEach(o=>{let c=o.after??o.before;c&&s("change",c);});let d=new Set,f=(o,c)=>{c.proofIds.some(h=>n.has(h))&&(d.add(c.id),r.add(D(o,"entity",c.id)));};e.entities.added.forEach(o=>f("add",o)),e.entities.removed.forEach(o=>f("remove",o)),e.entities.changed.forEach(o=>{let c=o.after??o.before;c&&f("change",c);});let l=(o,c)=>{!c.proofIds.some(h=>n.has(h))&&!d.has(c.from)&&!d.has(c.to)||r.add(D(o,"relation",c.id));};return e.relations.added.forEach(o=>l("add",o)),e.relations.removed.forEach(o=>l("remove",o)),e.relations.changed.forEach(o=>{let c=o.after??o.before;c&&l("change",c);}),r}function Dt(e){let t=e.prediction?.operations.map(c=>({operation:c.operation,targetKind:c.targetKind,targetId:c.targetId}))??[],a=bt(e.actual),r=new Set(t.map(c=>D(c.operation,c.targetKind,c.targetId))),n=new Set(a.map(c=>D(c.operation,c.targetKind,c.targetId))),s=Et(e.actual,t),d=a.filter(c=>r.has(D(c.operation,c.targetKind,c.targetId))||s.has(D(c.operation,c.targetKind,c.targetId))),f=a.filter(c=>!r.has(D(c.operation,c.targetKind,c.targetId))&&!s.has(D(c.operation,c.targetKind,c.targetId))),l=t.filter(c=>!n.has(D(c.operation,c.targetKind,c.targetId))),o=e.prediction?f.length===0&&l.length===0&&s.size===0?"exact":f.length===0?"within-expectation":"surprising":"no-prediction";return {schemaVersion:j$1,changeId:e.changeId,generatedAt:e.generatedAt,prediction:e.predictionReference,actual:e.actualReference,matched:d,unpredicted:f,missing:l,summary:{predicted:t.length,actual:a.length,matched:d.length,unpredicted:f.length,missing:l.length,verdict:o}}}async function pe(e){let t=await A(e.workspacePath,e.relativePath);return t?T({role:e.role,artifact:e.relativePath,schemaVersion:e.schemaVersion,value:c(t)}):null}function Rt(e){let{integrity:t,...a}=e;return a}async function ye(e){let t=V(e.lease.changeId),[a,r,n]=await Promise.all([pe({workspacePath:e.workspacePath,relativePath:t.prediction,role:"prediction",schemaVersion:i$1}),pe({workspacePath:e.workspacePath,relativePath:t.actualOverlay,role:"actual-architecture-overlay",schemaVersion:a$5}),pe({workspacePath:e.workspacePath,relativePath:t.surprises,role:"architecture-surprises",schemaVersion:j$1})]),s=T({role:"decision-transaction",artifact:`${U(e.lease.changeId)}/transaction.json`,schemaVersion:e.record.transaction.schemaVersion,value:c(e.record.transaction)}),d=e.record.transaction.effects.flatMap(g=>g.artifacts),f=e.record.transaction.effects.flatMap(g=>g.deletedArtifacts??[]),l=e.record.transaction.verifications.flatMap(g=>g.artifacts),o=await A(e.workspacePath,t.actualOverlay),c$1=o?!ue(o):false,h=[{id:"intent-bound",status:"passed",summary:"The transaction is hash-bound to its immutable Goal Pack."},{id:"baseline-pinned",status:"passed",summary:"The architecture lease pins exact Model, Graph, and live-input identities."},{id:"effects-receipted",status:e.record.transaction.effects.length>0&&e.record.transaction.effects.every(g=>g.status==="succeeded")||e.record.transaction.effects.length===0&&c$1?"passed":e.record.transaction.effects.length===0?"pending":"failed",summary:e.record.transaction.effects.length===0&&c$1?"Fresh Graph observation proves this was a no-effect change.":`${e.record.transaction.effects.length} typed effect receipt(s) are bound to the transaction ledger.`},{id:"architecture-reobserved",status:r?"passed":"pending",summary:r?"The actual architecture delta was derived from a fresh canonical Graph.":"No post-effect architecture overlay has been observed yet."},{id:"independently-verified",status:e.record.transaction.state==="committed"?"passed":e.record.transaction.verifications.some(g=>g.status==="failed")?"failed":"pending",summary:`${e.record.transaction.verifications.length} independent verification receipt(s) are recorded.`}],y=await A(e.workspacePath,t.surprises),p=[...e.record.transaction.effects.length===0&&o&&ue(o)?["No typed effect receipt explains the observed architecture generation."]:[],...y?.summary.unpredicted?[`${y.summary.unpredicted} actual architecture operation(s) were not predicted.`]:[],...e.record.transaction.blockers.map(g=>g.details??g.code)],k$1=e.record.transaction.state==="committed"?"sealed":e.record.transaction.state==="aborted"?"aborted":e.record.transaction.state==="blocked"||e.record.transaction.state==="awaiting-human"?"blocked":e.record.transaction.state==="verifying"&&e.record.transaction.verifications.some(g=>g.status==="passed")?"verified":"open",i={schemaVersion:k,changeId:e.lease.changeId,goalId:e.lease.goalId,generatedAt:e.record.transaction.updatedAt,status:k$1,workspace:e.lease.workspace,scope:e.lease.scope,decision:{transaction:s,eventHeadDigest:e.record.transaction.eventHeadDigest,effectHeadDigest:te(e.record.transaction,me),state:e.record.transaction.state,generation:e.record.transaction.generation},intent:e.record.transaction.intent,baseline:e.lease.baseline,prediction:a,actualOverlay:r,surpriseReport:n,effects:d,deletedArtifacts:f,verification:l,assurances:h,remainingUncertainty:[...new Set(p)]};return {...i,integrity:{algorithm:"sha256",semantics:"canonical-json-v1",capsuleDigest:c(i)}}}async function O(e,t,a){let r=await ye({workspacePath:e,lease:t,record:a});return await h$1(e,V(t.changeId).capsule,r),r}function j(e){let t=V(e.lease.changeId),a$1={schemaVersion:l$1,operation:e.operation,changeId:e.lease.changeId,state:e.record.transaction.state,capsule:e.capsule,artifacts:{lease:t.lease,prediction:e.capsule.prediction?.artifact??null,actualOverlay:e.capsule.actualOverlay?.artifact??null,surpriseReport:e.capsule.surpriseReport?.artifact??null,transaction:`${U(e.lease.changeId)}/transaction.json`,events:`${U(e.lease.changeId)}/events.jsonl`,capsule:t.capsule},nextActions:e.nextActions};return a(a$1,"contracts/workspace-intelligence/change-operation-result.v1.json","Proof-Carrying Change operation result"),b$2({kind:"operation.completed",status:e.record.transaction.state==="blocked"||e.record.transaction.state==="awaiting-human"?"blocked":e.record.transaction.state==="aborted"?"cancelled":"succeeded",component:"proof-carrying-change",correlationId:e.lease.changeId,message:`${e.operation}: ${e.record.transaction.state}`,evidenceBindings:[{kind:"artifact",ref:t.capsule,role:"output",provenance:"authoritative"},{kind:"artifact",ref:`${U(e.lease.changeId)}/transaction.json`,role:"subject",provenance:"authoritative"}],attributes:{operation:e.operation,changeId:e.lease.changeId,goalId:e.lease.goalId,decisionState:e.record.transaction.state,assurancePassed:e.capsule.assurances.filter(r=>r.status==="passed").length,assuranceTotal:e.capsule.assurances.length}}),a$1}async function R(e,t){let a=await Pt(e,t),r=await Je(e,t);return {lease:a,record:r}}async function da(e){let t=b.resolve(e.workspacePath),a=await l({workspacePath:t,goalId:e.goalId,validateBindings:true}),r=a.goalPack;if(!r||!a.active)throw new Error("No active Goal Pack is available, or the named Goal is not active.");if(r.state!=="ready-to-plan")throw new Error(`Goal ${r.id} cannot begin a change while its state is ${r.state}.`);let n=await J(t),s=Y(n);if(s.modelHash!==r.sourceBinding.model.hash||(r.sourceBinding.graph.inputHash?s.inputHash!==r.sourceBinding.graph.inputHash:s.graphHash!==r.sourceBinding.graph.hash))throw new Error(`Goal ${r.id} is no longer bound to the current architecture generation.`);let d=`change-${r.intent.category}-${randomUUID().replace(/-/g,"").slice(0,16)}`,f=V(d),l$1=new Date().toISOString(),o=await yt(t,n.graph),c$1=c(o),h$1={schemaVersion:h,changeId:d,goalId:r.id,createdAt:l$1,workspace:r.workspace,scope:{kind:r.scope.kind,projects:[...r.scope.projects]},baseline:{model:T({role:"baseline-model",artifact:r.sourceBinding.model.artifact,schemaVersion:r.sourceBinding.model.schemaVersion,value:r.sourceBinding.model.hash,semantics:"workspace-model-structural-v1"}),graph:{...T({role:"baseline-graph",artifact:r.sourceBinding.graph.artifact,schemaVersion:r.sourceBinding.graph.schemaVersion,value:s.graphHash}),inputHash:s.inputHash}},generation:s.generation,semantics:"optimistic-generation-guard",privateMaterialization:{artifact:f.privateBaselineGraph,role:"hash-bound-baseline-cache",portable:false,authoritative:false,digest:{algorithm:"sha256",semantics:"canonical-json-v1",value:c$1}}};await i(t,f.lease,[{relativePath:f.privateBaselineGraph,payload:o},{relativePath:f.lease,payload:h$1}]);let y=e.actorKind??"cli",p=e.actorId??"workspai-change",k=T({role:"intent",artifact:a.active.goalPack,schemaVersion:r.schemaVersion,value:c(r)}),i$1=r.successCriteria.map(E=>T({role:"success-criterion",artifact:E.id,schemaVersion:"workspai.goal-success-criterion.v1",value:c(E)})),g=await I(t,null,d,C("created",{summary:`Begin proof-carrying change for ${r.id}.`,references:[k,...i$1]},y,p,l$1));g=await I(t,g,d,C("scope-bound",{summary:"Bind immutable Goal scope.",scope:h$1.scope},y,p)),g=await I(t,g,d,C("evidence-attached",{summary:"Attach exact architecture generation and lease.",references:[h$1.baseline.model,{role:h$1.baseline.graph.role,artifact:h$1.baseline.graph.artifact,schemaVersion:h$1.baseline.graph.schemaVersion,digest:h$1.baseline.graph.digest},T({role:"architecture-lease",artifact:f.lease,schemaVersion:h$1.schemaVersion,value:c(h$1)})]},y,p)),await q({workspacePath:t,goalId:r.id,changeId:d});let P=await O(t,h$1,g);return j({operation:"begin",lease:h$1,record:g,capsule:P,nextActions:[`workspai change predict --change ${d} --file <prediction.json> --json`,`workspai change authorize --change ${d} --effects filesystem,command --json`]})}async function la(e){let{lease:t,record:a}=await R(e.workspacePath,e.changeId);if(await we(e.workspacePath,t),a.transaction.state!=="evidence-ready")throw new Error(`Prediction requires evidence-ready state, observed ${a.transaction.state}.`);let r={...e.prediction,schemaVersion:i$1,changeId:e.changeId,goalId:t.goalId,baselineGeneration:t.generation,nonCanonical:true,proofEligible:false,operations:[...e.prediction.operations].sort((f,l)=>D(f.operation,f.targetKind,f.targetId).localeCompare(D(l.operation,l.targetKind,l.targetId)))};await h$1(e.workspacePath,V(e.changeId).prediction,r);let n=T({role:"noncanonical-prediction",artifact:V(e.changeId).prediction,schemaVersion:r.schemaVersion,value:c(r)}),s=await I(e.workspacePath,a,e.changeId,C("plan-attached",{summary:"Attach an explicitly noncanonical architecture prediction.",references:[n]},e.actorKind??"agent",e.actorId??"workspai-agent")),d=await O(e.workspacePath,t,s);return j({operation:"predict",lease:t,record:s,capsule:d,nextActions:[`workspai change authorize --change ${e.changeId} --effects filesystem,command --json`]})}async function fa(e){let{lease:t,record:a$1}=await R(e.workspacePath,e.changeId);if(await we(e.workspacePath,t),a$1.transaction.state!=="evidence-ready")throw new Error(`Plan attachment requires evidence-ready state, observed ${a$1.transaction.state}.`);let r=e.role.trim().toLowerCase();if(!/^[a-z0-9](?:[a-z0-9.-]{0,62}[a-z0-9])?$/.test(r))throw new Error(`Invalid proof-carrying plan role: ${e.role}`);if(!e.schemaVersion.trim())throw new Error("Plan schema version is required.");let n=e.contractPath.replace(/\\/g,"/");if(!n.startsWith("contracts/")||n.split("/").some(l=>l===".."||l==="."))throw new Error(`Plan contract path must resolve inside the published contract root: ${e.contractPath}`);if(!e.payload||typeof e.payload!="object"||e.payload.schemaVersion!==e.schemaVersion)throw new Error("Plan payload schema version does not match its PCC reference.");a(e.payload,n,`${r} plan`);let s=c(e.payload),d=`${V(e.changeId).directory}/plans/${r}-${s}.json`;await h$1(e.workspacePath,d,e.payload);let f=await I(e.workspacePath,a$1,e.changeId,C("plan-attached",{summary:`Attach ${r} execution plan.`,references:[T({role:r,artifact:d,schemaVersion:e.schemaVersion,value:s})]},e.actorKind??"cli",e.actorId??"workspai-plan"));return await O(e.workspacePath,t,f),{changeId:e.changeId,state:f.transaction.state,artifact:d,digest:s}}async function ga(e){let{lease:t,record:a}=await R(e.workspacePath,e.changeId);if(await we(e.workspacePath,t),e.effectClasses.length===0)throw new Error("Authorization requires at least one effect class.");let r=await I(e.workspacePath,a,e.changeId,C("authorized",{summary:`Authorize bounded effect classes: ${e.effectClasses.join(", ")}.`,authorization:{grantedBy:e.grantedBy,grant:"bounded-effects",effectClasses:[...new Set(e.effectClasses)].sort()}},e.actorKind??"human",e.grantedBy)),n=await O(e.workspacePath,t,r);return j({operation:"authorize",lease:t,record:r,capsule:n,nextActions:[`workspai change effect record --change ${e.changeId} --file <effect-receipt.json> --json`,`workspai change verify --change ${e.changeId} --json`]})}async function ha(e){let{lease:t,record:a}=await R(e.workspacePath,e.changeId);if(a.transaction.state!=="blocked"&&a.transaction.state!=="awaiting-human")throw new Error(`Resume requires blocked or awaiting-human state, observed ${a.transaction.state}.`);let r=await I(e.workspacePath,a,e.changeId,C("resumed",{summary:e.reason,reason:e.reason,resumeTo:e.resumeTo},"human",e.actorId)),n=await O(e.workspacePath,t,r);return j({operation:"resume",lease:t,record:r,capsule:n,nextActions:e.resumeTo==="verifying"?[`workspai change verification record --change ${e.changeId} --file <verification-receipt.json> --json`]:[`workspai change effect record --change ${e.changeId} --file <effect-receipt.json> --json`]})}async function pa(e){let{lease:t,record:a}=await R(e.workspacePath,e.changeId),r=new Set(e.receipt.artifacts.map(f=>v(f.artifact))),n=(e.receipt.deletedArtifacts??[]).map(f=>v(f.artifact));if(new Set(n).size!==n.length)throw new Error("Effect receipt contains duplicate deleted-artifact identities.");if(n.some(f=>r.has(f)))throw new Error("An effect artifact cannot be both present and deleted in one receipt.");if(n.length>0&&e.receipt.status!=="succeeded")throw new Error("Only a succeeded effect may carry deleted-artifact tombstones.");for(let f of e.receipt.artifacts)if(!await F(e.workspacePath,f))throw new Error(`Effect artifact is missing or corrupt: ${f.artifact}`);for(let f of e.receipt.deletedArtifacts??[])if(!await et(e.workspacePath,f))throw new Error(`Deleted effect artifact is present, outside the governed scope, or has an invalid tombstone: ${f.artifact}`);let s=await I(e.workspacePath,a,e.changeId,C("effect-recorded",{summary:e.receipt.summary,effect:e.receipt},e.actorKind??"agent",e.actorId??"workspai-agent")),d=await O(e.workspacePath,t,s);return j({operation:"effect-record",lease:t,record:s,capsule:d,nextActions:s.transaction.state==="blocked"?[`workspai change status --change ${e.changeId} --json`]:[`workspai change verify --change ${e.changeId} --json`]})}async function ua(e){let t=b.resolve(e.workspacePath),{lease:a,record:r}=await R(t,e.changeId);if(!r.transaction.requiredCriteria.includes(e.receipt.criterionId))throw new Error(`Verification criterion '${e.receipt.criterionId}' is outside the immutable Goal contract.`);let n=await J(t),s=V(e.changeId),[d,f]=await Promise.all([A(t,s.actualOverlay),A(t,s.surprises)]),l=r.transaction.verifications.some(i=>i.criterionId==="workspace-verify"&&i.status==="passed");if(!d||!f||!l)throw new Error("Domain verification can be admitted only after change verify re-observes the Graph and records a passing Workspace Verify receipt.");let o=Y(n),c=te(r.transaction,me);if(e.receipt.target.modelHash!==o.modelHash||e.receipt.target.graphHash!==o.graphHash||e.receipt.target.effectHeadDigest!==c)throw new Error("Verification receipt does not target the current Model, Graph, and effect head.");for(let i of e.receipt.artifacts)if(!await F(t,i))throw new Error(`Verification artifact is missing or corrupt: ${i.artifact}`);let h=e.actorKind??"ci",y=e.actorId??"workspai-verifier",p=r;if(p.transaction.state==="blocked"){if(!p.transaction.blockers.every(g=>g.code==="change.verification.criteria_missing"))throw new Error("The change is blocked by a condition that a verification receipt cannot resume.");p=await I(t,p,e.changeId,C("resumed",{summary:"Resume to admit a missing verification receipt.",resumeTo:"verifying"},h,y));}else if(p.transaction.state!=="verifying")throw new Error(`Verification receipt requires verifying or criteria-blocked state; observed ${p.transaction.state}.`);p=await I(t,p,e.changeId,C("verification-recorded",{summary:e.receipt.summary,verification:e.receipt},h,y)),p.transaction.state==="verifying"&&p.transaction.requiredCriteria.every(g=>p.transaction.verifications.filter(E=>E.criterionId===g).at(-1)?.status==="passed")&&(p=await I(t,p,e.changeId,C("committed",{summary:"Seal the independently verified proof-carrying change."},h,y)));let k=await O(t,a,p);return j({operation:"verification-record",lease:a,record:p,capsule:k,nextActions:p.transaction.state==="committed"?[`workspai change capsule validate --change ${e.changeId} --json`]:[`workspai change status --change ${e.changeId} --json`]})}function ae(e,t,a,r="verification"){return T({role:r,artifact:e,schemaVersion:t,value:c(a)})}function ue(e){return e.summary.entityAdds+e.summary.entityRemovals+e.summary.entityChanges+e.summary.relationAdds+e.summary.relationRemovals+e.summary.relationChanges+e.summary.proofAdds+e.summary.proofRemovals+e.summary.proofChanges>0}function v(e){return e.replace(/\\/g,"/").replace(/^\.\//,"")}function $t(e){if(e.scope.kind==="workspace")return e.overlay;let t=new Set(e.scope.projects),a=i=>!!(i.projectId&&t.has(i.projectId)),r={added:e.overlay.entities.added.filter(a),removed:e.overlay.entities.removed.filter(a),changed:e.overlay.entities.changed.filter(i=>a(i.after??i.before??{}))},n=i=>e.scopedEntityIds.has(i.from)||e.scopedEntityIds.has(i.to),s={added:e.overlay.relations.added.filter(n),removed:e.overlay.relations.removed.filter(n),changed:e.overlay.relations.changed.filter(i=>{let g=i.after??i.before;return !!(g&&n(g))})},d=new Set([...r.added.flatMap(i=>i.proofIds),...r.removed.flatMap(i=>i.proofIds),...r.changed.flatMap(i=>[...i.before?.proofIds??[],...i.after?.proofIds??[]]),...s.added.flatMap(i=>i.proofIds),...s.removed.flatMap(i=>i.proofIds),...s.changed.flatMap(i=>[...i.before?.proofIds??[],...i.after?.proofIds??[]])]),f=i=>{let g=v(i);return e.projectPrefixes.includes(".")?true:e.projectPrefixes.some(P=>g===P||g.startsWith(`${P}/`))},l=i=>d.has(i.id)||f(i.artifact),o={added:e.overlay.proofs.added.filter(l),removed:e.overlay.proofs.removed.filter(l),changed:e.overlay.proofs.changed.filter(i=>{let g=i.after??i.before;return !!(g&&l(g))})},c=e.overlay.impactedEntityIds.filter(i=>e.scopedEntityIds.has(i)),h=e.overlay.changedArtifacts.filter(f),y=r.removed.length+s.removed.length+o.removed.length,p=y+r.added.length+r.changed.length+s.added.length+s.changed.length+o.added.length+o.changed.length,k=p===0?"none":y>0||c.length>=10?"high":c.length>=5||p>=5?"medium":"low";return {...e.overlay,entities:r,relations:s,proofs:o,impactedEntityIds:c,changedArtifacts:h,summary:{entityAdds:r.added.length,entityRemovals:r.removed.length,entityChanges:r.changed.length,relationAdds:s.added.length,relationRemovals:s.removed.length,relationChanges:s.changed.length,proofAdds:o.added.length,proofRemovals:o.removed.length,proofChanges:o.changed.length,impactedEntities:c.length,changedArtifacts:h.length,risk:k}}}function Ye(e){let t=b.normalize(b.resolve(e));return process.platform==="win32"?t.toLowerCase():t}async function St(e){let t=new Set(e.receiptedArtifacts.map(v)),a=new Set;for(let n of t){let s=await d(e.workspacePath,n);s&&a.add(Ye(s));}let r=[];for(let n of e.changedArtifacts){let s=v(n);if(t.has(s))continue;let d$1=await d(e.workspacePath,s);d$1&&a.has(Ye(d$1))||r.push(n);}return r}function Vt(e){let t=v(e.artifact);return e.receiptedArtifacts.has(t)||e.scope.kind==="workspace"||e.projectPrefixes.includes(".")?true:e.projectPrefixes.some(a=>t===a||t.startsWith(`${a}/`))}async function xt(e){let t=v(e.artifact),a=f=>{let l=f.proofs.filter(o=>v(o.artifact)===t);return l.length===0?[]:l.some(o=>!o.contentHash)?null:[...new Set(l.map(o=>o.contentHash))].sort()},r=a(e.baseline),n=a(e.head),s=await Qe(e.workspacePath,t),d=e.baseline.pccArtifactContentHashes?.[t];return d?s===null||s!==d:r&&r.length>0?s===null||!r.includes(s):r&&r.length===0?s!==null||!!n?.length:r===null||n===null?true:c(r)!==c(n)}async function ma(e){let t=b.resolve(e.workspacePath),{lease:a,record:r}=await R(t,e.changeId);if(r.transaction.state!=="authorized"&&r.transaction.state!=="executing")throw new Error(`Verification requires authorized or executing state, observed ${r.transaction.state}.`);e.refresh!==false&&await c$1({workspacePath:t,strict:false,agent:"generic"});let n=await J(t),s=await A(t,a.privateMaterialization.artifact);if(!s||c(s)!==a.privateMaterialization.digest.value)throw new Error(`The hash-bound baseline materialization is missing or corrupt for ${e.changeId}.`);let d=new Date().toISOString(),f$1=n.model.projects.filter(w=>a.scope.projects.includes(w.name)).map(w=>v(w.path).replace(/\/$/u,"")).filter(Boolean),l=$t({overlay:a$1(s,n.graph,new Date(d)),scope:a.scope,projectPrefixes:f$1,scopedEntityIds:new Set([...s.entities,...n.graph.entities].filter(w=>w.projectId&&a.scope.projects.includes(w.projectId)).map(w=>w.id))}),o=V(e.changeId);await h$1(t,o.actualOverlay,l);let c$2=ae(o.actualOverlay,l.schemaVersion,l,"actual-architecture-overlay"),h=await A(t,o.prediction),y=h?ae(o.prediction,h.schemaVersion,h,"noncanonical-prediction"):null,p=Dt({changeId:e.changeId,generatedAt:d,prediction:h,predictionReference:y,actual:l,actualReference:c$2});await h$1(t,o.surprises,p);let k=ae(o.surprises,p.schemaVersion,p,"architecture-surprises"),i=r,g$1=e.actorKind??"cli",P=e.actorId??"workspai-change-verify";if(ue(l)&&i.transaction.effects.length===0){i=await I(t,i,e.changeId,C("blocked",{summary:"Observed architecture change has no typed effect receipt.",blocker:{code:"change.effect_receipt.missing",actionable:true,details:"Record the actual mutation effect before verification can claim causality."}},g$1,P));let w=await O(t,a,i);return j({operation:"verify",lease:a,record:i,capsule:w,nextActions:[`workspai change resume --change ${e.changeId} --to authorized --reason "Record missing effect receipt" --json`]})}let E=i.transaction.effects.filter(w=>w.status==="succeeded").flatMap(w=>[...w.artifacts.map(x=>x.artifact),...(w.deletedArtifacts??[]).map(x=>x.artifact)]),G=new Set(E.map(v)),$=(await Promise.all(l.changedArtifacts.map(async w=>({artifact:w,contentChanged:await xt({workspacePath:t,artifact:w,baseline:s,head:n.graph})})))).filter(({artifact:w,contentChanged:x})=>x&&Vt({artifact:w,scope:a.scope,projectPrefixes:f$1,receiptedArtifacts:G})).map(({artifact:w})=>w),S=await St({workspacePath:t,changedArtifacts:$,receiptedArtifacts:E});if(S.length>0){i=await I(t,i,e.changeId,C("blocked",{summary:"Observed architecture artifacts are not covered by typed effect receipts.",blocker:{code:"change.effect_receipt.coverage_missing",actionable:true,details:`Uncovered artifacts: ${S.slice(0,20).join(", ")}`}},g$1,P));let w=await O(t,a,i);return j({operation:"verify",lease:a,record:i,capsule:w,nextActions:[`workspai change resume --change ${e.changeId} --to authorized --reason "Cover observed artifacts" --json`]})}let K=await f({workspacePath:t});if(!h$2(K,{strict:e.strict===true}).passed&&At({record:i,lease:a,verify:K})){await g(K,t);let w=await O(t,a,i),x=a.scope.projects[0];return j({operation:"verify",lease:a,record:i,capsule:w,nextActions:[...x?[`workspai workspace run init --workspace ${JSON.stringify(t)} --scope ${JSON.stringify(x)} --json`,`workspai workspace run test --workspace ${JSON.stringify(t)} --scope ${JSON.stringify(x)} --json`,`workspai workspace run build --workspace ${JSON.stringify(t)} --scope ${JSON.stringify(x)} --json`]:[],`workspai change verify --change ${e.changeId} --json`]})}i=await I(t,i,e.changeId,C("verification-started",{summary:"Begin independent post-effect verification."},g$1,P));let X=await g(K,t),ke=b.relative(t,X).split(b.sep).join("/"),re=await A(t,ke);if(!re)throw new Error(`Workspace Verify evidence was not persisted at ${ke}.`);await h$1(t,o.workspaceVerification,re);let Q=await A(t,o.workspaceVerification);if(!Q)throw new Error(`Change-scoped Workspace Verify evidence was not persisted at ${o.workspaceVerification}.`);let N=h$2(re,{strict:e.strict===true}),Pe=Y(n),Ce={id:`verify-workspace-${c({generatedAt:d,verify:Q,gate:N}).slice(0,16)}`,criterionId:"workspace-verify",status:N.passed?"passed":"failed",summary:N.passed?`Workspace Verify passed in ${N.mode} mode.`:`Workspace Verify blocked in ${N.mode} mode: ${N.reasons.join("; ")}`,target:{modelHash:Pe.modelHash,graphHash:Pe.graphHash,effectHeadDigest:te(i.transaction,me)},artifacts:[ae(o.workspaceVerification,Q.schemaVersion,Q),c$2,k],observedAt:d};if(i=await I(t,i,e.changeId,C("verification-recorded",{summary:Ce.summary,verification:Ce},g$1,P)),i.transaction.state==="verifying"){let w=i.transaction.requiredCriteria.filter(x=>i.transaction.verifications.filter(rt=>rt.criterionId===x).at(-1)?.status!=="passed");w.length>0?i=await I(t,i,e.changeId,C("blocked",{summary:"Required outcome verification is incomplete.",blocker:{code:"change.verification.criteria_missing",actionable:true,details:`Missing passing receipts: ${w.join(", ")}`}},g$1,P)):i=await I(t,i,e.changeId,C("committed",{summary:"Seal the independently verified proof-carrying change."},g$1,P));}let at=await O(t,a,i);return j({operation:"verify",lease:a,record:i,capsule:at,nextActions:i.transaction.state==="committed"?[`workspai change capsule validate --change ${e.changeId} --json`]:[`workspai change status --change ${e.changeId} --json`]})}async function wa(e){let{lease:t,record:a}=await R(e.workspacePath,e.changeId),r=await ye({workspacePath:e.workspacePath,lease:t,record:a});return j({operation:e.operation??"status",lease:t,record:a,capsule:r,nextActions:a.transaction.state==="evidence-ready"?[`workspai change authorize --change ${e.changeId} --effects filesystem,command --json`]:a.transaction.state==="authorized"||a.transaction.state==="executing"?[`workspai change verify --change ${e.changeId} --json`]:[]})}async function ya(e){let t=b.resolve(e.workspacePath),a$1=await b$1(t,".workspai/changes","directory"),n=(a$1?await z.readdir(a$1,{withFileTypes:true}):[]).filter(l=>l.isDirectory()&&/^change-[a-z0-9][a-z0-9-]{7,95}$/.test(l.name)).map(l=>l.name).sort(),s=[],d=null;for(let l of n)try{let{lease:o,record:c}=await R(t,l);d??=o.workspace.name;let h=await ye({workspacePath:t,lease:o,record:c}),y=await ve({workspacePath:t,changeId:l}),p=c.transaction.blockers.map(i=>i.details??i.code),k=h.status==="blocked"?h.assurances.filter(i=>i.status==="failed").map(i=>`${i.id}: ${i.summary}`):[];s.push({changeId:l,goalId:o.goalId,state:c.transaction.state,status:h.status,createdAt:c.transaction.createdAt,updatedAt:c.transaction.updatedAt,scope:o.scope,assurance:{passed:h.assurances.filter(i=>i.status==="passed").length,total:h.assurances.length},blockers:[...new Set([...p,...k])],capsuleArtifact:V(l).capsule,valid:y.valid,errors:y.errors});}catch(o){s.push({changeId:l,goalId:null,state:null,status:"invalid",createdAt:null,updatedAt:null,scope:null,assurance:{passed:0,total:5},blockers:[],capsuleArtifact:V(l).capsule,valid:false,errors:[o instanceof Error?o.message:String(o)]});}s.sort((l,o)=>(o.updatedAt??"").localeCompare(l.updatedAt??"")||l.changeId.localeCompare(o.changeId));let f={schemaVersion:m,generatedAt:new Date().toISOString(),workspace:{name:d??await vt(t)},changes:s,summary:{total:s.length,open:s.filter(l=>l.status==="open"||l.status==="verified").length,blocked:s.filter(l=>l.status==="blocked").length,sealed:s.filter(l=>l.status==="sealed").length,aborted:s.filter(l=>l.status==="aborted").length,invalid:s.filter(l=>!l.valid).length}};return a(f,"contracts/workspace-intelligence/proof-carrying-change-list.v1.json","Proof-Carrying Change list"),f}async function va(e){let{lease:t,record:a}=await R(e.workspacePath,e.changeId),r=await I(e.workspacePath,a,e.changeId,C("aborted",{summary:e.reason,reason:e.reason},"human",e.actorId)),n=await O(e.workspacePath,t,r);return j({operation:"abort",lease:t,record:r,capsule:n,nextActions:[]})}async function ve(e){let t=V(e.changeId),a$1=await A(e.workspacePath,t.capsule);if(!a$1)throw new Error(`Proof-carrying change capsule not found: ${e.changeId}`);let r=[];a$1.schemaVersion!==k&&r.push(`Unsupported capsule schema: ${a$1.schemaVersion}`),a$1.changeId!==e.changeId&&r.push("Capsule change binding does not match."),c(Rt(a$1))!==a$1.integrity.capsuleDigest&&r.push("Capsule integrity digest does not match its canonical content.");let{lease:n$1,record:s}=await R(e.workspacePath,e.changeId),d=s.transaction.evidence.find(o=>o.role==="architecture-lease");(!d||d.digest.value!==c(n$1))&&r.push("Architecture lease does not match the decision-ledger evidence binding."),(n$1.goalId!==a$1.goalId||n$1.generation!==c({modelHash:n$1.baseline.model.digest.value,graphHash:n$1.baseline.graph.digest.value,inputHash:n$1.baseline.graph.inputHash}))&&r.push("Architecture lease identity or generation binding is invalid."),s.transaction.eventHeadDigest!==a$1.decision.eventHeadDigest&&r.push("Capsule does not bind the current decision event head."),c(s.transaction)!==a$1.decision.transaction.digest.value&&r.push("Decision transaction projection digest does not match the capsule.");let f=await A(e.workspacePath,n$1.privateMaterialization.artifact);(!f||c(f)!==n$1.privateMaterialization.digest.value)&&r.push("Hash-bound baseline materialization is missing or corrupt.");for(let o of [a$1.intent,a$1.decision.transaction,a$1.prediction,a$1.actualOverlay,a$1.surpriseReport,...a$1.effects,...a$1.verification].filter(c=>!!c))await F(e.workspacePath,o)||r.push(`Referenced artifact is missing or corrupt: ${o.artifact}`);for(let o of a$1.deletedArtifacts??[])await et(e.workspacePath,o)||r.push(`Deleted artifact tombstone is invalid or the artifact exists again: ${o.artifact}`);let l={schemaVersion:n,changeId:e.changeId,validatedAt:new Date().toISOString(),valid:r.length===0,errors:r,capsule:a$1};return a(l,"contracts/workspace-intelligence/proof-carrying-change-capsule-validation.v1.json","Proof-Carrying Change capsule validation"),l}async function ka(e){let t=await ve(e);if(!t.valid)throw new Error(`Cannot export an invalid capsule: ${t.errors.join("; ")}`);let a$1=b.resolve(e.workspacePath),r=b.resolve(a$1,e.outputPath),n=b.relative(a$1,r);if(n===".."||n.startsWith(`..${b.sep}`)||b.isAbsolute(n))throw new Error("Capsule export path must remain inside the workspace.");let s=n.split(b.sep).join("/"),d=await h$1(a$1,s,t.capsule),f={schemaVersion:o,changeId:e.changeId,outputPath:d,validation:t};return a(f,"contracts/workspace-intelligence/proof-carrying-change-capsule-export.v1.json","Proof-Carrying Change capsule export"),f}function Pa(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Prediction input must be a JSON object.");let t=e;if(!Array.isArray(t.operations)||!Array.isArray(t.assumptions))throw new Error("Prediction input requires operations[] and assumptions[].");let a=new Set(["add","remove","change"]),r=new Set(["entity","relation","proof","artifact"]),n=new Set(["high","medium","low"]);for(let d of t.operations)if(!d||!a.has(d.operation)||!r.has(d.targetKind)||typeof d.targetId!="string"||d.targetId.trim().length===0||typeof d.rationale!="string"||!n.has(d.confidence))throw new Error("Prediction contains an invalid operation.");let s=t.predictedRisk;if(!s||!["none","low","medium","high"].includes(s))throw new Error("Prediction requires predictedRisk: none, low, medium, or high.");return {schemaVersion:i$1,changeId:t.changeId??"change-placeholder",goalId:t.goalId??"goal-placeholder",generatedAt:t.generatedAt??new Date().toISOString(),baselineGeneration:t.baselineGeneration??"pending-binding",nonCanonical:true,proofEligible:false,operations:t.operations,assumptions:t.assumptions.filter(d=>typeof d=="string"),predictedRisk:s}}function Ca(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Effect receipt input must be a JSON object.");let t=e;if(typeof t.id!="string"||!["filesystem","command","configuration","dependency","external"].includes(String(t.effectClass))||!["succeeded","failed","uncertain"].includes(String(t.status))||typeof t.summary!="string"||typeof t.observedAt!="string"||typeof t.idempotencyKey!="string"||!Array.isArray(t.artifacts))throw new Error("Effect receipt is missing required typed fields.");if(t.deletedArtifacts!==void 0&&(!Array.isArray(t.deletedArtifacts)||t.deletedArtifacts.some(r=>!r||typeof r.artifact!="string"||r.observedAt!==void 0&&typeof r.observedAt!="string"||r.digest!==void 0&&(r.digest.algorithm!=="sha256"||r.digest.semantics!=="deletion-tombstone-v1"||typeof r.digest.value!="string"))))throw new Error("Effect receipt contains an invalid deleted-artifact tombstone.");let a=t;return {...a,...a.deletedArtifacts?{deletedArtifacts:a.deletedArtifacts.map(r=>r.digest?r:kt({artifact:r.artifact,observedAt:r.observedAt??a.observedAt}))}:{}}}function Ia(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Verification receipt input must be a JSON object.");let t=e;if(typeof t.id!="string"||typeof t.criterionId!="string"||!["passed","failed","inconclusive"].includes(String(t.status))||typeof t.summary!="string"||typeof t.observedAt!="string"||!t.target||typeof t.target.modelHash!="string"||typeof t.target.graphHash!="string"||typeof t.target.effectHeadDigest!="string"||!Array.isArray(t.artifacts))throw new Error("Verification receipt is missing required typed fields.");return t}function Aa(e,t){return e.decision.eventHeadDigest===t.eventHeadDigest&&e.decision.transaction.digest.value===c(t)}async function ba(e){let{lease:t,record:a}=await R(e.workspacePath,e.changeId);if(t.goalId!==e.goalId)throw new Error(`Proof-carrying change ${e.changeId} is not bound to Goal ${e.goalId}.`);let r=new Set(["authorized","executing","verifying"]),n=a.transaction.state==="blocked"&&a.transaction.blockers.length>0&&a.transaction.blockers.every(i=>i.code==="change.verification.criteria_missing");if(!r.has(a.transaction.state)&&!n)throw new Error(`Proof-carrying change ${e.changeId} is not an applied scaffold pending verification.`);let s=a.transaction.effects.filter(i=>i.effectClass==="filesystem");if(s.length===0)throw new Error(`Proof-carrying change ${e.changeId} has no succeeded filesystem effect receipt.`);if(s.some(i=>i.status!=="succeeded"||i.artifacts.length===0))throw new Error(`Proof-carrying change ${e.changeId} has incomplete or unsuccessful filesystem effects.`);for(let i of s)for(let g of i.artifacts)if(!await F(e.workspacePath,g))throw new Error(`Proof-carrying change ${e.changeId} no longer matches effect artifact ${g.artifact}.`);let d=a.transaction.plans.find(i=>i.role===tt);if(d){let i=await A(e.workspacePath,d.artifact);if(!i||c(i)!==d.digest.value)throw new Error(`Proof-carrying change ${e.changeId} has a missing or corrupt agent framework plan.`);let g=i.target,P=typeof g?.artifactPrefix=="string"?v(g.artifactPrefix).replace(/\/$/u,""):"",E=Array.isArray(i.files)?i.files.flatMap(S=>{if(!S||typeof S!="object")return [];let K=S.path;if(typeof K!="string")return [];let X=v(K);return [P?`${P}/${X}`:X]}):[],G=new Set(s.flatMap(S=>S.artifacts.map(K=>v(K.artifact)))),$=E.filter(S=>!G.has(S));if(E.length===0||$.length>0)throw new Error(`Proof-carrying change ${e.changeId} has a partial filesystem effect receipt.`)}let f=await J(e.workspacePath),l=Y(f),o=await A(e.workspacePath,t.privateMaterialization.artifact);if(!o||c(o)!==t.privateMaterialization.digest.value)throw new Error(`Proof-carrying change ${e.changeId} has a missing or corrupt architecture baseline.`);let c$1=a$1(o,f.graph),h=new Set,y=await b$1(e.workspacePath,".workspai/changes","directory"),p=y?await z.readdir(y,{withFileTypes:true}):[];for(let i of p){if(!i.isDirectory()||!/^change-[a-z0-9][a-z0-9-]{7,95}$/.test(i.name))continue;let g=await R(e.workspacePath,i.name).catch(()=>null);if(!g||g.record.transaction.createdAt<t.createdAt)continue;let P=g.record.transaction.effects.filter($=>$.effectClass==="filesystem"&&$.status==="succeeded");if(P.length===0)continue;for(let $ of P)for(let S of $.artifacts)await F(e.workspacePath,S)&&h.add(v(S.artifact));let E=g.record.transaction.plans.find($=>$.role==="noncanonical-prediction");if(!E)continue;let G=await A(e.workspacePath,E.artifact);if(!(!G||c(G)!==E.digest.value))for(let $ of G.operations)$.targetKind==="artifact"&&h.add(v($.targetId));}let k=c$1.changedArtifacts.map(v).filter(i=>!h.has(i));if(k.length>0)throw new Error(`Proof-carrying change ${e.changeId} does not explain current architecture artifacts: ${k.slice(0,3).join(", ")}.`);return {modelHash:l.modelHash,graphHash:l.graphHash}}async function Ea(e){let t=await ve({workspacePath:e.workspacePath,changeId:e.changeId});if(!t.valid)throw new Error(`Proof-carrying change ${e.changeId} failed capsule validation.`);let{lease:a,record:r}=await R(e.workspacePath,e.changeId);if(a.goalId!==e.goalId||r.transaction.state!=="committed"||t.capsule.status!=="sealed")throw new Error(`Proof-carrying change ${e.changeId} is not a sealed change for ${e.goalId}.`);let n=[...r.transaction.verifications].reverse().find(s=>s.status==="passed");if(!n)throw new Error(`Proof-carrying change ${e.changeId} has no passing verification receipt.`);return {modelHash:n.target.modelHash,graphHash:n.target.graphHash}}
|
|
4
4
|
export{Je as a,kt as b,da as c,la as d,fa as e,ga as f,ha as g,pa as h,ua as i,St as j,ma as k,wa as l,ya as m,va as n,ve as o,ka as p,Pa as q,Ca as r,Ia as s,Aa as t,ba as u,Ea as v};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {b as b$1,c,d as d$1}from'./chunk-UP3UWAJV.js';import {a as a$3}from'./chunk-X7FYEKLI.js';import {c as c$2}from'./chunk-P5LI5DL3.js';import {c as c$1,d as d$4}from'./chunk-N4B2M44I.js';import {a as a$1,b as b$2}from'./chunk-PYCJWW4B.js';import {p as p$1,a,o,g as g$1,d as d$3,f}from'./chunk-3EPR3D5Q.js';import {r,n,d as d$5}from'./chunk-SEZTSMRR.js';import {d as d$2}from'./chunk-IHWS3ALP.js';import {g,h as h$1}from'./chunk-BLEIUQL6.js';import {a as a$2}from'./chunk-AFIFZTOY.js';import {d}from'./chunk-EWZZUQBR.js';import {q,p,t,r as r$1,s}from'./chunk-ODK4LCEL.js';import k from'path';import w from'fs-extra';var fe="rapidkit-blocker-resolution-v1";function pe(e){let t=e.blockers.map(s=>s.trim()).filter(Boolean).slice(0,12),r=e.stderrTail?.trim().slice(-400)??"";return d$5({blockers:t,exitCode:e.exitCode??null,stderrTail:r})}function we(e){let t=e.trim().toLowerCase();return t?t.includes("missing evidence")||t.includes(": missing")||t.includes("artifact missing")||t.includes("not found on disk")?"artifact-missing":t.includes("policy.")||t.includes("contract")?"config-fixable":t.includes("impact")||t.includes("untracked")||t.includes("grounding")?"semantic-attention":t.includes("failed")||t.includes("blocked")||t.includes(": fail")?"command-failed-repeat":"config-fixable":"unresolvable-without-human"}function ge(e){let t=we(e.reason),r=pe({blockers:[e.reason]}),s=t==="artifact-missing"?[{actionKind:"run-once",detail:e.sourceCommand?`Run the source command once: ${e.sourceCommand}`:"Run the mapped workspace intelligence command once to generate the missing artifact.",...e.sourceCommand?{}:{studioActionId:"run-analyze"}}]:t==="semantic-attention"?[{actionKind:"commit-files",detail:"Review workspace-level grounding files (AGENTS.md, agent-sync outputs) and commit or refresh the impact baseline."},{actionKind:"refresh-baseline",detail:"Refresh snapshot + diff + impact before re-running verify."}]:[{actionKind:"edit-file",detail:"Apply the smallest safe file or policy fix for this blocker before re-running verification.",studioActionId:"fix-lens"}];return {schemaVersion:fe,blockerId:e.blockerId,sourceCommand:e.sourceCommand,sourceArtifact:e.sourceArtifact,resolutionClass:t,blockerSignature:r,commandRetryHint:t==="artifact-missing"?e.sourceCommand?`Run the source command once: ${e.sourceCommand}, then verify.`:"Run the source command once, then verify.":"Do not re-run the same failing command; fix the source issue first, then verify.",fixHints:s,verifyCommand:e.verifyCommand,verifyArtifact:e.verifyArtifact}}function Re(e){let t=e.toLowerCase();return t.includes("stale")||t.includes("missing evidence")||t.includes("no projects")||t.includes("projects.empty")||t.includes("projects discovered")||t.includes("projects.missing")||t.includes("not yet run")||t.includes("doctor-last-run")||t.includes("doctor-project-last-run")||t.includes("doctor-remediation-plan-last-run")||t.includes("doctor-fix-result-last-run")||t.includes("pipeline-last-run")||t.includes("release-readiness")||t.includes("analyze-last-run")||t.includes("analyze reported")||t.includes("analyze verdict")||t.includes("analyze needs attention")||t.includes("toolchain.lock")||t.includes("not pinned")||t.includes("readiness:")||t.includes("env:")||t.includes("workspace-run-last")||t.includes("pre-project")||t.includes("before adding projects")||t.includes("workspace.projects.missing")||t.includes("no backend projects")||t.includes("index.json")||t.includes("workspace-intelligence-history")||t.includes("validation warning")||t.includes("workspace model validation")||t.includes("workspace.marker")||t.includes("no project roots")||t.includes("no infrastructure services")||t.includes("infra/overrides")||t.includes("infra dependencies")||t.includes("contract verify")||t.includes("contract inspect")||t.includes("publish verify evidence")}function Ce(e){return e.length===0||e.every(t=>Re(t))}function me(e){return e.projectCount>0||e.policyErrorCount>0?{verdict:e.verdict,exitCode:e.exitCode}:e.verdict==="blocked"&&Ce(e.blockingReasons)?{verdict:"needs-attention",exitCode:1}:{verdict:e.verdict,exitCode:e.exitCode}}function st(e,t){let r=t&&t!=="ready"?` (${t.replace(/-/g," ")})`:"";return e===0?`Workspace scaffold ready${r} \u2014 add your first project to continue.`:`Workspace scaffold${r}: ${e} pre-project signal(s) \u2014 add your first project to continue.`}var ye=q.verify,G=p.verify;function je(e,t){return k.isAbsolute(t)?t:k.join(e,t)}async function ke(e){let t=await w.readJson(e);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace impact input is not a JSON object: ${e}`);let r=t;if(r.schemaVersion!==f)throw new Error(`Unsupported workspace impact schema: ${String(r.schemaVersion)}`);a$2(t,"contracts/workspace-intelligence/workspace-impact.v1.json",`Workspace impact ${e}`);let s=r;a$2(s.diff,"contracts/workspace-intelligence/workspace-model-diff.v1.json",`Embedded workspace diff in ${e}`);let i=[];s.summary.affectedProjects!==s.affectedProjects.length&&i.push("summary.affectedProjects does not match affectedProjects.length"),s.summary.workspaceItems!==s.workspaceImpact.length&&i.push("summary.workspaceItems does not match workspaceImpact.length"),s.summary.recommendedCommands!==s.verificationPlan.length&&i.push("summary.recommendedCommands does not match verificationPlan.length"),s.summary.blastRadius.directlyAffected!==s.affectedProjects.length&&i.push("blastRadius.directlyAffected does not match affectedProjects.length"),s.summary.blastRadius.transitivelyAffected!==s.transitiveImpact.length&&i.push("blastRadius.transitivelyAffected does not match transitiveImpact.length");let a=s.transitiveImpact.reduce((l,d)=>Math.max(l,d.distance??0),0);s.summary.blastRadius.maxDistance!==a&&i.push("blastRadius.maxDistance does not match transitive impact distances");let g=n(s.diff.currentModel)?.edges.length??0;if(s.summary.blastRadius.graphEdges!==g&&i.push("blastRadius.graphEdges does not match the embedded model graph"),s.summary.changed!==s.diff.summary.changed&&i.push("summary.changed does not match embedded diff summary"),s.fromRef!==s.diff.fromRef&&i.push("fromRef does not match embedded diff fromRef"),s.workspace.name!==s.diff.currentModel.workspace.name&&i.push("workspace.name does not match the embedded model"),s.diff.toHash!==d(s.diff.currentModel)&&i.push("embedded diff current-model hash does not match toHash"),i.length>0)throw new Error(`Workspace impact semantic integrity failed: ${i.join("; ")} (${e})`);return s}function Ae(e){let t=new Set,r=[];for(let s of e){let i=`${s.scope}:${s.project??""}:${s.display}`;t.has(i)||(t.add(i),r.push(s));}return r}function Se(e,t){if(!e||e==="workspace")return true;let r=(e.startsWith("project:")?e.slice(8):e).trim().toLowerCase();return t.scope==="workspace"?true:(t.project??"").trim().toLowerCase()===r}function Ee(e,t){if(e.id==="workspace.doctor")return k.join(t,p.doctor);if(e.id==="workspace.contract.verify")return k.join(t,p.contractVerify);if(e.id==="workspace.readiness")return k.join(t,p.readiness);if(e.id==="workspace.analyze")return k.join(t,".workspai","reports","analyze-last-run.json");if(e.id==="workspace.pipeline")return k.join(t,".workspai","reports","pipeline-last-run.json");if(e.id==="workspace.doctor-fix")return k.join(t,".workspai","reports","doctor-fix-result-last-run.json");if(e.id.startsWith("project.")&&e.id.includes("."))return k.join(t,".workspai","reports","workspace-run-last.json")}function h(e){return !e||typeof e!="object"||Array.isArray(e)?null:e}function We(e){if(!c$1(e,"workspace"))return {status:"fail",message:"Doctor evidence contract is missing or unsupported."};try{d$4(e);}catch(s){return {status:"fail",message:`Doctor evidence semantic validation failed: ${s instanceof Error?s.message:String(s)}`}}let t=a$3(e);return t.hasSystemErrors||t.blockingFindings>0?{status:"fail",message:`Doctor evidence reports ${t.blockingFindings} canonical blocking finding(s).`}:t.advisoryFindings+t.unknownFindings+t.contradictionCount+t.missingDiagnosisProjects>0||t.staleEvidence||t.unknownFreshness||t.minimumDiagnosisCompleteness<100?{status:"warn",message:`Doctor evidence needs attention (${t.advisoryFindings} advisory, ${t.unknownFindings} unknown, ${t.contradictionCount} contradictory; ${t.minimumDiagnosisCompleteness}% complete).`}:{status:"pass",message:"Canonical Doctor evidence is complete, fresh, and healthy."}}function Pe(e){let t=typeof e.overallStatus=="string"?e.overallStatus:"unknown";return t==="fail"?{status:"fail",message:"Release readiness evidence reports blocking failures."}:t==="warn"?{status:"warn",message:"Release readiness evidence reports warnings."}:t==="pass"?{status:"pass",message:"Release readiness evidence passed."}:{status:"warn",message:`Release readiness evidence status is ${t}.`}}function xe(e){let t=typeof e.status=="string"?e.status:"unknown";return t==="failed"||t==="fail"?{status:"fail",message:"Workspace contract verify evidence failed."}:t==="passed"||t==="pass"?{status:"pass",message:"Workspace contract verify evidence passed."}:{status:"warn",message:`Workspace contract verify evidence status is ${t}.`}}function Ie(e){let t=h(e.summary),r=typeof t?.verdict=="string"?t.verdict:void 0;return r==="blocked"?{status:"fail",message:"Analyze evidence reports blocking findings."}:r==="needs-attention"?{status:"warn",message:"Analyze evidence reports warnings."}:{status:"pass",message:"Analyze evidence is ready."}}function Ve(e){let t=e.schemaVersion===s.doctorFixResult.schemaVersion?e:e.fixResult;if(!t||typeof t!="object"||Array.isArray(t))return {status:"skipped",message:"Doctor fix result not present; run doctor workspace --fix --json to record fixes."};let r=t,s$1=Array.isArray(r.remainingBlockers)?r.remainingBlockers:[];if(s$1.length>0)return {status:"fail",message:`Doctor fix result reports ${s$1.length} remaining blocker(s).`};let i=Array.isArray(r.appliedFixes)?r.appliedFixes:[];return i.length===0?{status:"pass",message:"Doctor fix result recorded with no remaining blockers."}:{status:"pass",message:`Doctor fix result recorded ${i.length} applied fix(es) with no remaining blockers.`}}async function $e(e,t$1){let r=await g(e,t.doctorRemediationPlan);if(!r)return false;try{let s=h(await w.readJson(r));if(!s||(Array.isArray(s.steps)?s.steps:[]).length>0)return false;let a=typeof s.generatedAt=="string"?s.generatedAt:void 0;if(!a||!t$1)return true;let g=Date.parse(a),l=Date.parse(t$1);return !Number.isFinite(g)||!Number.isFinite(l)?true:g>=l}catch{return false}}function Fe(e){return e.id.endsWith(".init")?"init":e.id.endsWith(".test")?"test":e.id.endsWith(".build")?"build":e.id.endsWith(".start")?"start":null}function Oe(e){let t=h(e.summary),r=typeof t?.verdict=="string"?t.verdict:void 0;return r==="blocked"?{status:"fail",message:"Pipeline evidence is blocked."}:r==="needs-attention"?{status:"warn",message:"Pipeline evidence needs attention."}:r==="ready"?{status:"pass",message:"Pipeline evidence is ready."}:{status:"warn",message:"Pipeline evidence status is unknown."}}function De(e,t,r){let s=h(e.projectStages)??h(h(e.enterpriseControls)?.projectStages);if(!s)return null;let i=t.replace(/\\/g,"/").toLowerCase(),a=Object.entries(s).filter(([d,y])=>{let c=d.replace(/\\/g,"/").toLowerCase(),n=h(y),o=h(n?.[r]),p=typeof o?.projectName=="string"?o.projectName.toLowerCase():"",f=typeof o?.relativePath=="string"?o.relativePath.replace(/\\/g,"/").toLowerCase():"";return c===i||p===i||f===i});if(a.length>1)return "ambiguous";let g=h(a[0]?.[1]),l=h(g?.[r]);return l?{generatedAt:typeof l.generatedAt=="string"?l.generatedAt:void 0,status:typeof l.status=="string"?l.status:void 0}:null}function Be(e,t,r){let s=Fe(t),i=c$2(e,s??void 0);if(!i)return {status:"missing",message:"Workspace run evidence is missing or unreadable."};let a=i.stage;if(s&&a!==s)return {status:"missing",message:`Workspace run evidence is for stage "${a}", expected "${s}".`};let g=Array.isArray(i.projects)?i.projects:[],l=t.project?.toLowerCase();if(!l)return {status:"missing",message:"Project-scoped workspace run evidence is missing a project identifier."};let d=g.filter(c=>{let n=h(c);if(!n)return false;let o=typeof n.projectName=="string"?n.projectName.toLowerCase():"",p=["projectPath","relativePath","path"].map(f=>n[f]).filter(f=>typeof f=="string"&&f.trim().length>0).map(f=>f.replace(/\\/g,"/").toLowerCase());return o===l||p.some(f=>f===l)});if(d.length>1)return {status:"fail",message:`Workspace run evidence is ambiguous for project ${t.project}.`};let y=d[0];if(y){let c=b(i.generatedAt,r,`Workspace run evidence for ${t.project??t.id}`);if(c)return {status:"fail",message:c};let n=h(y),o=typeof n?.status=="string"?n.status:"unknown";if(o==="failed"||o==="blocked")return {status:"fail",message:`Workspace run evidence ${o} for ${t.project}.`};if(o==="passed")return {status:"pass",message:`Workspace run evidence passed for ${t.project}.`};if(o==="skipped"){let p=De(e,l,s??i.stage);if(p==="ambiguous")return {status:"fail",message:`Workspace run history is ambiguous for project ${t.project}.`};if(p){let f=b(p.generatedAt,r,`Workspace run evidence for ${t.project??t.id}`);if(f)return {status:"fail",message:f};if(p.status==="passed")return {status:"pass",message:`Workspace run evidence passed for ${t.project} from keyed project/stage history.`};if(p.status==="failed"||p.status==="blocked")return {status:"fail",message:`Workspace run evidence ${p.status} for ${t.project}.`}}return {status:"warn",message:`Workspace run evidence skipped for ${t.project}.`}}return {status:"warn",message:`Workspace run evidence status is ${o} for ${t.project}.`}}return {status:"missing",message:`Workspace run evidence does not include project ${t.project}.`}}function b(e,t,r){if(!t)return null;if(typeof e!="string"||e.trim().length===0)return `${r} is stale: missing generatedAt timestamp (required after impact ${t}).`;let s=Date.parse(e),i=Date.parse(t);return Number.isFinite(s)?Number.isFinite(i)&&s<i?`${r} is stale: generated at ${e}, before impact ${t}.`:null:`${r} is stale: invalid generatedAt timestamp (required after impact ${t}).`}function _e(e){if(e.id==="workspace.doctor")return r$1.doctor;if(e.id==="workspace.readiness")return r$1.readiness;if(e.id==="workspace.contract.verify")return r$1.contractVerify;if(e.id==="workspace.analyze")return r$1.analyze;if(e.id==="workspace.pipeline")return "contracts/pipeline-last-run.v1.json"}async function Ne(e,t,r,s$1){let i=Ee(e,t),a=i?k.relative(t,i).split(k.sep).join("/"):void 0;if(e.id==="workspace.contract.verify"&&!r)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"skipped",required:e.required,message:"Workspace contract is not present; contract verify skipped."};let g$1=i?await g(t,a??""):null;if(!i||!g$1)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"missing",required:e.required,evidencePath:a,message:a?`Missing evidence report: ${a}`:"No evidence mapping exists for this command."};let l;try{l=await w.readJson(g$1);}catch(n){return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"fail",required:e.required,evidencePath:a,message:`Evidence report is unreadable JSON: ${n instanceof Error?n.message:String(n)}`}}let d=h(l);if(!d)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"fail",required:e.required,evidencePath:a,message:"Evidence report is not a JSON object."};let y=_e(e);if(y)try{a$2(d,y,`${e.label} evidence`);}catch(n){return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"fail",required:e.required,evidencePath:a,message:`Evidence report is invalid: ${n instanceof Error?n.message:String(n)}`}}let c;if(e.id==="workspace.doctor"){let n=b(d.generatedAt,s$1,"Doctor evidence");n?c={status:"fail",message:n}:c=We(d);}else if(e.id==="workspace.readiness"){let n=b(d.generatedAt,s$1,"Release readiness evidence");n?c={status:"fail",message:n}:c=Pe(d);}else if(e.id==="workspace.contract.verify"){let n=b(d.generatedAt,s$1,"Workspace contract verify evidence");n?c={status:"fail",message:n}:c=xe(d);}else if(e.id==="workspace.analyze"){let n=b(d.generatedAt,s$1,"Analyze evidence");n?c={status:"fail",message:n}:c=Ie(d);}else if(e.id==="workspace.pipeline"){let n=b(d.generatedAt,s$1,"Pipeline evidence");n?c={status:"fail",message:n}:c=Oe(d);}else if(e.id==="workspace.doctor-fix"){let n=d.schemaVersion===s.doctorFixResult.schemaVersion?d:d.fixResult,o=h(n),p=typeof o?.generatedAt=="string"?o.generatedAt:void 0,f=b(p,s$1,"Doctor fix result");f?c={status:"fail",message:f}:await $e(t,p)?c={status:"skipped",message:"No current doctor remediation steps are pending."}:c=Ve(d);}else if(e.id.startsWith("project."))c=Be(d,e,s$1);else {let n=b(d.generatedAt,s$1,"Evidence report");n?c={status:"fail",message:n}:c={status:"pass",message:"Evidence report is present."};}return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:c.status,required:e.required,evidencePath:a,message:c.message}}function He(e,t={blockingReasons:[],needsAttention:false}){let r=e.filter(n=>n.status==="pass").length,s=e.filter(n=>n.status==="warn").length,i=e.filter(n=>n.status==="fail").length,a=e.filter(n=>n.status==="missing").length,g=e.filter(n=>n.status==="skipped").length,l=e.filter(n=>n.required&&(n.status==="fail"||n.status==="missing")).map(n=>`${n.id}: ${n.message}`),d=e.filter(n=>n.required&&n.status==="missing").length,y="ready",c=0;return l.length>0||t.blockingReasons.length>0?(y="blocked",c=2):(s>0||e.some(n=>!n.required&&n.status==="fail")||d>0||t.needsAttention)&&(y="needs-attention",c=1),{verdict:y,exitCode:c,stepsPassed:r,stepsWarn:s,stepsFailed:i,stepsMissing:a,stepsSkipped:g}}function Me(e,t){let r=P(e.affectedProjects.map(o=>o.project?.name).filter(o=>typeof o=="string")),s=new Set(r.map(o=>o.toLowerCase())),i=P(e.transitiveImpact.map(o=>o.project?.name).filter(o=>typeof o=="string").filter(o=>!s.has(o.toLowerCase()))),a=new Map;for(let o of t){if(o.scope!=="project"||!o.project)continue;let p=o.project.toLowerCase(),f=a.get(p)??[];f.push(o),a.set(p,f);}let g=[],l=[],d=[],y=[],c=false,n=(o,p)=>{let f=a.get(o.toLowerCase())??[];if(f.length===0){d.push(o);return}let x=f.filter(m=>m.status==="fail"),R=x.filter(m=>m.required),I=f.filter(m=>m.status==="missing"),A=I.filter(m=>m.required),V=f.some(m=>m.status==="pass"||m.status==="warn");if(R.length>0){l.push(o),y.push(`graph.subgraph.${o}: ${p} has failed verification evidence (${R.map(m=>m.id).join(", ")}).`);return}if(x.length>0){l.push(o),c=true;return}if(A.length>0){l.push(o),y.push(`graph.subgraph.${o}: ${p} has missing required verification evidence (${A.map(m=>m.id).join(", ")}).`);return}if(I.length>0){l.push(o),c=true;return}if(V){g.push(o);return}d.push(o);};for(let o of r)n(o,"directly-changed");for(let o of i)n(o,"transitive dependent");return {subgraph:{totalProjects:r.length+i.length,directlyChanged:r,transitiveDependents:i,covered:P(g),uncovered:P(l),unverifiable:P(d)},blockingReasons:y,needsAttention:c}}function P(e){return [...new Set(e)].sort((t,r)=>t.localeCompare(r))}async function Te(e){let t=k.resolve(e.workspacePath);if(e.fromImpactPath){let a=je(t,e.fromImpactPath);return {impact:await ke(a),fromImpactRef:k.relative(t,a).split(k.sep).join("/"),impactFromDisk:true}}let r$1=k.join(t,g$1);if(await w.pathExists(r$1))return {impact:await ke(r$1),fromImpactRef:g$1,impactFromDisk:true};let s=k.join(t,d$3);if(await w.pathExists(s))return {impact:await p$1({workspacePath:t,fromPath:d$3,scope:e.scope,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now}),fromImpactRef:d$3,impactFromDisk:false};let i=await r({workspacePath:t,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now});return {impact:{schemaVersion:f,generatedAt:(e.now??new Date).toISOString(),fromRef:"baseline",diffRef:p.diff,workspace:{name:i.workspace.name,profile:i.workspace.profile,type:i.workspace.type},summary:{changed:false,risk:"none",affectedProjects:0,workspaceItems:0,recommendedCommands:0,blastRadius:{directlyAffected:0,transitivelyAffected:0,maxDistance:0,graphEdges:n(i)?.edges.length??0}},affectedProjects:[],transitiveImpact:[],criticalPathHotspots:[],workspaceImpact:[],verificationPlan:[],agentBrief:{headline:"Baseline workspace verify run.",bullets:["No impact report or snapshot was available; baseline gates were evaluated."],unsafeAssumptions:["Do not claim runtime verification passed unless evidence exists."]},diff:{schemaVersion:q.diff,generatedAt:(e.now??new Date).toISOString(),fromRef:"baseline",toRef:p.model,fromHash:"baseline",toHash:"baseline",summary:{changed:false,addedProjects:0,removedProjects:0,changedProjects:0,workspaceChanges:0,validationChanges:0,gitChangedFiles:0},git:{available:false,dirty:false,changedFiles:0,untrackedFiles:0,deletedFiles:0},changes:[],currentModel:i}},impactFromDisk:false}}function Le(e,t){if(t)return e.generatedAt}async function wt(e){let t=k.resolve(e.workspacePath),{impact:r$1,fromImpactRef:s,impactFromDisk:i}=await Te(e),a$2=r$1.diff.currentModel,g=i?await r({workspacePath:t,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now}):a$2,l=[];if(i){let u=await p$1({workspacePath:t,fromPath:r$1.diff.fromRef,diff:r$1.diff,scope:e.scope,now:e.now}),E=[r$1.affectedProjects,r$1.transitiveImpact,r$1.verificationPlan],j=[u.affectedProjects,u.transitiveImpact,u.verificationPlan];JSON.stringify(E)!==JSON.stringify(j)&&l.push("workspace.impact: Persisted impact semantics do not match the impact re-derived from the embedded diff. Regenerate diff and impact.");}i&&d(g)!==r$1.diff.toHash&&l.push("workspace.impact: Impact evidence is stale because the current workspace model no longer matches the embedded model. Regenerate diff and impact.");let d$2=r$1.diff.git;if(i&&d$2?.available){let u=a(t,{ref:d$2.ref}),E=r$1.diff.changes.filter(v=>v.type.startsWith("git.")).map(v=>`${v.type}:${v.target.replace(/^git:/,"")}`).sort(),j=[...u.changedFiles.map(v=>`git.file.changed:${v}`),...u.untrackedFiles.map(v=>`git.untracked:${v}`),...u.deletedFiles.map(v=>`git.deleted:${v}`)].sort();(!u.available||u.commit!==d$2.commit||JSON.stringify(j)!==JSON.stringify(E))&&l.push("workspace.impact: Impact evidence is stale because Git changes no longer match the diff observation. Regenerate diff and impact.");}let y=Le(r$1,i),c$1=Ae([...o(),...r$1.verificationPlan]).filter(u=>Se(e.scope,u)),n$1=[];for(let u of c$1)n$1.push(await Ne(u,t,a$2.contracts.exists===true,y));let o$1=Me(r$1,n$1),p=a$1(n(a$2)??{nodes:[],edges:[]}),f=b$1(a$2),x=await ze(t),R=c(f,x?.freshness?.projectHashes),I={verdict:R.verdict,baseline:R.baseline,changed:R.changed,added:R.added,removed:R.removed,projectHashes:d$1(f)},A=b$2(p),V=a$2.policies?.mode??"warn",m=await qe(a$2,t),B=Ke(V,m),S=He(n$1,{blockingReasons:[...o$1.blockingReasons,...A,...B.blockingReasons,...l],needsAttention:o$1.needsAttention||B.needsAttention}),he=n$1.filter(u=>u.status==="missing"&&u.evidencePath).map(u=>u.evidencePath),_=[...n$1.filter(u=>u.required&&(u.status==="fail"||u.status==="missing")).map(u=>`${u.id}: ${u.message}`),...o$1.blockingReasons,...A,...B.blockingReasons,...l],ve=m.filter(u=>u.severity==="error").length,be=a$2.summary?.projectCount??a$2.projects.length,U=me({projectCount:be,verdict:S.verdict,exitCode:S.exitCode,blockingReasons:_,policyErrorCount:ve});S.verdict=U.verdict,S.exitCode=U.exitCode;let Y=Array.from(new Set(_.map(u=>u.trim()).filter(Boolean))).slice(0,12).map((u,E)=>{let j=n$1.find(v=>u.startsWith(`${v.id}:`));return ge({reason:u,blockerId:`blocker-${E+1}`,sourceCommand:j?.command.display,sourceArtifact:j?.evidencePath,verifyCommand:"npx workspai workspace verify --from-impact .workspai/reports/workspace-impact-last-run.json --json",verifyArtifact:G})});return {schemaVersion:ye,generatedAt:(e.now??new Date).toISOString(),workspacePath:t,mode:"evidence",fromImpactRef:s,scope:e.scope,impact:{changed:r$1.summary.changed,risk:r$1.summary.risk,affectedProjects:r$1.summary.affectedProjects,recommendedCommands:r$1.summary.recommendedCommands},summary:S,steps:n$1,missingEvidence:he,blockingReasons:_,...Y.length>0?{resolutionHints:Y}:{},verificationPlan:c$1,affectedSubgraph:o$1.subgraph,graphIntegrity:p,freshness:I,policyMode:V,policyViolations:m}}async function qe(e,t){let r=[];for(let i of e.validation?.issues??[])r.push({source:"model",severity:i.severity,code:i.code,message:i.message,target:i.target});let s=await g(t,p.contractVerify);try{if(s&&await w.pathExists(s)){let i=await w.readJson(s);if(Array.isArray(i.violations))for(let a of i.violations)typeof a=="string"&&a.trim().length>0&&r.push({source:"contract",severity:"error",code:"contract.violation",message:a});}}catch{}return r.sort((i,a)=>i.source!==a.source?i.source.localeCompare(a.source):i.code!==a.code?i.code.localeCompare(a.code):i.message.localeCompare(a.message))}function Ke(e,t){let r=t.filter(s=>s.severity==="error");return e==="enforce"&&r.length>0?{blockingReasons:r.map(s=>`policy.${s.code}: ${s.message}`),needsAttention:false}:{blockingReasons:[],needsAttention:r.length>0}}async function ze(e){let t=k.join(e,G);try{if(!await w.pathExists(t))return null;let r=await w.readJson(t);return r&&r.schemaVersion===ye?r:null}catch{return null}}async function Rt(e,t){return h$1(t,G,d$2(e))}function Je(e,t){let r=t?.strict?"strict":"default",s=[];if(e.summary.verdict==="blocked")return s.push(...e.blockingReasons),s.length===0&&s.push("verify verdict is blocked."),{passed:false,mode:r,exitCode:2,reasons:s};if(r==="strict"){if(e.summary.verdict!=="ready"&&s.push(`verify verdict is ${e.summary.verdict} (strict requires ready).`),e.freshness.verdict==="stale"){let i=[...e.freshness.changed,...e.freshness.added].slice(0,5);s.push(`freshness is stale${i.length>0?`: ${i.join(", ")}`:""} (strict requires fresh).`);}if(s.length>0)return {passed:false,mode:r,exitCode:1,reasons:s}}return {passed:true,mode:r,exitCode:0,reasons:s}}function Ct(e,t){return Je(e,t).exitCode}export{fe as a,st as b,ye as c,G as d,Me as e,wt as f,Rt as g,Je as h,Ct as i};
|
|
1
|
+
import {b as b$1,c,d as d$1}from'./chunk-2ZVE7VE2.js';import {a as a$3}from'./chunk-X7FYEKLI.js';import {c as c$2}from'./chunk-P5LI5DL3.js';import {c as c$1,d as d$4}from'./chunk-N4B2M44I.js';import {a as a$1,b as b$2}from'./chunk-PYCJWW4B.js';import {p as p$1,a,o,g as g$1,d as d$3,f}from'./chunk-SKHRUHXO.js';import {r,n,d as d$5}from'./chunk-O4TZKLEC.js';import {d as d$2}from'./chunk-WU5M6UP7.js';import {g,h as h$1}from'./chunk-BLEIUQL6.js';import {a as a$2}from'./chunk-AFIFZTOY.js';import {d}from'./chunk-EWZZUQBR.js';import {q,p,t,r as r$1,s}from'./chunk-ODK4LCEL.js';import k from'path';import w from'fs-extra';var fe="rapidkit-blocker-resolution-v1";function pe(e){let t=e.blockers.map(s=>s.trim()).filter(Boolean).slice(0,12),r=e.stderrTail?.trim().slice(-400)??"";return d$5({blockers:t,exitCode:e.exitCode??null,stderrTail:r})}function we(e){let t=e.trim().toLowerCase();return t?t.includes("missing evidence")||t.includes(": missing")||t.includes("artifact missing")||t.includes("not found on disk")?"artifact-missing":t.includes("policy.")||t.includes("contract")?"config-fixable":t.includes("impact")||t.includes("untracked")||t.includes("grounding")?"semantic-attention":t.includes("failed")||t.includes("blocked")||t.includes(": fail")?"command-failed-repeat":"config-fixable":"unresolvable-without-human"}function ge(e){let t=we(e.reason),r=pe({blockers:[e.reason]}),s=t==="artifact-missing"?[{actionKind:"run-once",detail:e.sourceCommand?`Run the source command once: ${e.sourceCommand}`:"Run the mapped workspace intelligence command once to generate the missing artifact.",...e.sourceCommand?{}:{studioActionId:"run-analyze"}}]:t==="semantic-attention"?[{actionKind:"commit-files",detail:"Review workspace-level grounding files (AGENTS.md, agent-sync outputs) and commit or refresh the impact baseline."},{actionKind:"refresh-baseline",detail:"Refresh snapshot + diff + impact before re-running verify."}]:[{actionKind:"edit-file",detail:"Apply the smallest safe file or policy fix for this blocker before re-running verification.",studioActionId:"fix-lens"}];return {schemaVersion:fe,blockerId:e.blockerId,sourceCommand:e.sourceCommand,sourceArtifact:e.sourceArtifact,resolutionClass:t,blockerSignature:r,commandRetryHint:t==="artifact-missing"?e.sourceCommand?`Run the source command once: ${e.sourceCommand}, then verify.`:"Run the source command once, then verify.":"Do not re-run the same failing command; fix the source issue first, then verify.",fixHints:s,verifyCommand:e.verifyCommand,verifyArtifact:e.verifyArtifact}}function Re(e){let t=e.toLowerCase();return t.includes("stale")||t.includes("missing evidence")||t.includes("no projects")||t.includes("projects.empty")||t.includes("projects discovered")||t.includes("projects.missing")||t.includes("not yet run")||t.includes("doctor-last-run")||t.includes("doctor-project-last-run")||t.includes("doctor-remediation-plan-last-run")||t.includes("doctor-fix-result-last-run")||t.includes("pipeline-last-run")||t.includes("release-readiness")||t.includes("analyze-last-run")||t.includes("analyze reported")||t.includes("analyze verdict")||t.includes("analyze needs attention")||t.includes("toolchain.lock")||t.includes("not pinned")||t.includes("readiness:")||t.includes("env:")||t.includes("workspace-run-last")||t.includes("pre-project")||t.includes("before adding projects")||t.includes("workspace.projects.missing")||t.includes("no backend projects")||t.includes("index.json")||t.includes("workspace-intelligence-history")||t.includes("validation warning")||t.includes("workspace model validation")||t.includes("workspace.marker")||t.includes("no project roots")||t.includes("no infrastructure services")||t.includes("infra/overrides")||t.includes("infra dependencies")||t.includes("contract verify")||t.includes("contract inspect")||t.includes("publish verify evidence")}function Ce(e){return e.length===0||e.every(t=>Re(t))}function me(e){return e.projectCount>0||e.policyErrorCount>0?{verdict:e.verdict,exitCode:e.exitCode}:e.verdict==="blocked"&&Ce(e.blockingReasons)?{verdict:"needs-attention",exitCode:1}:{verdict:e.verdict,exitCode:e.exitCode}}function st(e,t){let r=t&&t!=="ready"?` (${t.replace(/-/g," ")})`:"";return e===0?`Workspace scaffold ready${r} \u2014 add your first project to continue.`:`Workspace scaffold${r}: ${e} pre-project signal(s) \u2014 add your first project to continue.`}var ye=q.verify,G=p.verify;function je(e,t){return k.isAbsolute(t)?t:k.join(e,t)}async function ke(e){let t=await w.readJson(e);if(!t||typeof t!="object"||Array.isArray(t))throw new Error(`Workspace impact input is not a JSON object: ${e}`);let r=t;if(r.schemaVersion!==f)throw new Error(`Unsupported workspace impact schema: ${String(r.schemaVersion)}`);a$2(t,"contracts/workspace-intelligence/workspace-impact.v1.json",`Workspace impact ${e}`);let s=r;a$2(s.diff,"contracts/workspace-intelligence/workspace-model-diff.v1.json",`Embedded workspace diff in ${e}`);let i=[];s.summary.affectedProjects!==s.affectedProjects.length&&i.push("summary.affectedProjects does not match affectedProjects.length"),s.summary.workspaceItems!==s.workspaceImpact.length&&i.push("summary.workspaceItems does not match workspaceImpact.length"),s.summary.recommendedCommands!==s.verificationPlan.length&&i.push("summary.recommendedCommands does not match verificationPlan.length"),s.summary.blastRadius.directlyAffected!==s.affectedProjects.length&&i.push("blastRadius.directlyAffected does not match affectedProjects.length"),s.summary.blastRadius.transitivelyAffected!==s.transitiveImpact.length&&i.push("blastRadius.transitivelyAffected does not match transitiveImpact.length");let a=s.transitiveImpact.reduce((l,d)=>Math.max(l,d.distance??0),0);s.summary.blastRadius.maxDistance!==a&&i.push("blastRadius.maxDistance does not match transitive impact distances");let g=n(s.diff.currentModel)?.edges.length??0;if(s.summary.blastRadius.graphEdges!==g&&i.push("blastRadius.graphEdges does not match the embedded model graph"),s.summary.changed!==s.diff.summary.changed&&i.push("summary.changed does not match embedded diff summary"),s.fromRef!==s.diff.fromRef&&i.push("fromRef does not match embedded diff fromRef"),s.workspace.name!==s.diff.currentModel.workspace.name&&i.push("workspace.name does not match the embedded model"),s.diff.toHash!==d(s.diff.currentModel)&&i.push("embedded diff current-model hash does not match toHash"),i.length>0)throw new Error(`Workspace impact semantic integrity failed: ${i.join("; ")} (${e})`);return s}function Ae(e){let t=new Set,r=[];for(let s of e){let i=`${s.scope}:${s.project??""}:${s.display}`;t.has(i)||(t.add(i),r.push(s));}return r}function Se(e,t){if(!e||e==="workspace")return true;let r=(e.startsWith("project:")?e.slice(8):e).trim().toLowerCase();return t.scope==="workspace"?true:(t.project??"").trim().toLowerCase()===r}function Ee(e,t){if(e.id==="workspace.doctor")return k.join(t,p.doctor);if(e.id==="workspace.contract.verify")return k.join(t,p.contractVerify);if(e.id==="workspace.readiness")return k.join(t,p.readiness);if(e.id==="workspace.analyze")return k.join(t,".workspai","reports","analyze-last-run.json");if(e.id==="workspace.pipeline")return k.join(t,".workspai","reports","pipeline-last-run.json");if(e.id==="workspace.doctor-fix")return k.join(t,".workspai","reports","doctor-fix-result-last-run.json");if(e.id.startsWith("project.")&&e.id.includes("."))return k.join(t,".workspai","reports","workspace-run-last.json")}function h(e){return !e||typeof e!="object"||Array.isArray(e)?null:e}function We(e){if(!c$1(e,"workspace"))return {status:"fail",message:"Doctor evidence contract is missing or unsupported."};try{d$4(e);}catch(s){return {status:"fail",message:`Doctor evidence semantic validation failed: ${s instanceof Error?s.message:String(s)}`}}let t=a$3(e);return t.hasSystemErrors||t.blockingFindings>0?{status:"fail",message:`Doctor evidence reports ${t.blockingFindings} canonical blocking finding(s).`}:t.advisoryFindings+t.unknownFindings+t.contradictionCount+t.missingDiagnosisProjects>0||t.staleEvidence||t.unknownFreshness||t.minimumDiagnosisCompleteness<100?{status:"warn",message:`Doctor evidence needs attention (${t.advisoryFindings} advisory, ${t.unknownFindings} unknown, ${t.contradictionCount} contradictory; ${t.minimumDiagnosisCompleteness}% complete).`}:{status:"pass",message:"Canonical Doctor evidence is complete, fresh, and healthy."}}function Pe(e){let t=typeof e.overallStatus=="string"?e.overallStatus:"unknown";return t==="fail"?{status:"fail",message:"Release readiness evidence reports blocking failures."}:t==="warn"?{status:"warn",message:"Release readiness evidence reports warnings."}:t==="pass"?{status:"pass",message:"Release readiness evidence passed."}:{status:"warn",message:`Release readiness evidence status is ${t}.`}}function xe(e){let t=typeof e.status=="string"?e.status:"unknown";return t==="failed"||t==="fail"?{status:"fail",message:"Workspace contract verify evidence failed."}:t==="passed"||t==="pass"?{status:"pass",message:"Workspace contract verify evidence passed."}:{status:"warn",message:`Workspace contract verify evidence status is ${t}.`}}function Ie(e){let t=h(e.summary),r=typeof t?.verdict=="string"?t.verdict:void 0;return r==="blocked"?{status:"fail",message:"Analyze evidence reports blocking findings."}:r==="needs-attention"?{status:"warn",message:"Analyze evidence reports warnings."}:{status:"pass",message:"Analyze evidence is ready."}}function Ve(e){let t=e.schemaVersion===s.doctorFixResult.schemaVersion?e:e.fixResult;if(!t||typeof t!="object"||Array.isArray(t))return {status:"skipped",message:"Doctor fix result not present; run doctor workspace --fix --json to record fixes."};let r=t,s$1=Array.isArray(r.remainingBlockers)?r.remainingBlockers:[];if(s$1.length>0)return {status:"fail",message:`Doctor fix result reports ${s$1.length} remaining blocker(s).`};let i=Array.isArray(r.appliedFixes)?r.appliedFixes:[];return i.length===0?{status:"pass",message:"Doctor fix result recorded with no remaining blockers."}:{status:"pass",message:`Doctor fix result recorded ${i.length} applied fix(es) with no remaining blockers.`}}async function $e(e,t$1){let r=await g(e,t.doctorRemediationPlan);if(!r)return false;try{let s=h(await w.readJson(r));if(!s||(Array.isArray(s.steps)?s.steps:[]).length>0)return false;let a=typeof s.generatedAt=="string"?s.generatedAt:void 0;if(!a||!t$1)return true;let g=Date.parse(a),l=Date.parse(t$1);return !Number.isFinite(g)||!Number.isFinite(l)?true:g>=l}catch{return false}}function Fe(e){return e.id.endsWith(".init")?"init":e.id.endsWith(".test")?"test":e.id.endsWith(".build")?"build":e.id.endsWith(".start")?"start":null}function Oe(e){let t=h(e.summary),r=typeof t?.verdict=="string"?t.verdict:void 0;return r==="blocked"?{status:"fail",message:"Pipeline evidence is blocked."}:r==="needs-attention"?{status:"warn",message:"Pipeline evidence needs attention."}:r==="ready"?{status:"pass",message:"Pipeline evidence is ready."}:{status:"warn",message:"Pipeline evidence status is unknown."}}function De(e,t,r){let s=h(e.projectStages)??h(h(e.enterpriseControls)?.projectStages);if(!s)return null;let i=t.replace(/\\/g,"/").toLowerCase(),a=Object.entries(s).filter(([d,y])=>{let c=d.replace(/\\/g,"/").toLowerCase(),n=h(y),o=h(n?.[r]),p=typeof o?.projectName=="string"?o.projectName.toLowerCase():"",f=typeof o?.relativePath=="string"?o.relativePath.replace(/\\/g,"/").toLowerCase():"";return c===i||p===i||f===i});if(a.length>1)return "ambiguous";let g=h(a[0]?.[1]),l=h(g?.[r]);return l?{generatedAt:typeof l.generatedAt=="string"?l.generatedAt:void 0,status:typeof l.status=="string"?l.status:void 0}:null}function Be(e,t,r){let s=Fe(t),i=c$2(e,s??void 0);if(!i)return {status:"missing",message:"Workspace run evidence is missing or unreadable."};let a=i.stage;if(s&&a!==s)return {status:"missing",message:`Workspace run evidence is for stage "${a}", expected "${s}".`};let g=Array.isArray(i.projects)?i.projects:[],l=t.project?.toLowerCase();if(!l)return {status:"missing",message:"Project-scoped workspace run evidence is missing a project identifier."};let d=g.filter(c=>{let n=h(c);if(!n)return false;let o=typeof n.projectName=="string"?n.projectName.toLowerCase():"",p=["projectPath","relativePath","path"].map(f=>n[f]).filter(f=>typeof f=="string"&&f.trim().length>0).map(f=>f.replace(/\\/g,"/").toLowerCase());return o===l||p.some(f=>f===l)});if(d.length>1)return {status:"fail",message:`Workspace run evidence is ambiguous for project ${t.project}.`};let y=d[0];if(y){let c=b(i.generatedAt,r,`Workspace run evidence for ${t.project??t.id}`);if(c)return {status:"fail",message:c};let n=h(y),o=typeof n?.status=="string"?n.status:"unknown";if(o==="failed"||o==="blocked")return {status:"fail",message:`Workspace run evidence ${o} for ${t.project}.`};if(o==="passed")return {status:"pass",message:`Workspace run evidence passed for ${t.project}.`};if(o==="skipped"){let p=De(e,l,s??i.stage);if(p==="ambiguous")return {status:"fail",message:`Workspace run history is ambiguous for project ${t.project}.`};if(p){let f=b(p.generatedAt,r,`Workspace run evidence for ${t.project??t.id}`);if(f)return {status:"fail",message:f};if(p.status==="passed")return {status:"pass",message:`Workspace run evidence passed for ${t.project} from keyed project/stage history.`};if(p.status==="failed"||p.status==="blocked")return {status:"fail",message:`Workspace run evidence ${p.status} for ${t.project}.`}}return {status:"warn",message:`Workspace run evidence skipped for ${t.project}.`}}return {status:"warn",message:`Workspace run evidence status is ${o} for ${t.project}.`}}return {status:"missing",message:`Workspace run evidence does not include project ${t.project}.`}}function b(e,t,r){if(!t)return null;if(typeof e!="string"||e.trim().length===0)return `${r} is stale: missing generatedAt timestamp (required after impact ${t}).`;let s=Date.parse(e),i=Date.parse(t);return Number.isFinite(s)?Number.isFinite(i)&&s<i?`${r} is stale: generated at ${e}, before impact ${t}.`:null:`${r} is stale: invalid generatedAt timestamp (required after impact ${t}).`}function _e(e){if(e.id==="workspace.doctor")return r$1.doctor;if(e.id==="workspace.readiness")return r$1.readiness;if(e.id==="workspace.contract.verify")return r$1.contractVerify;if(e.id==="workspace.analyze")return r$1.analyze;if(e.id==="workspace.pipeline")return "contracts/pipeline-last-run.v1.json"}async function Ne(e,t,r,s$1){let i=Ee(e,t),a=i?k.relative(t,i).split(k.sep).join("/"):void 0;if(e.id==="workspace.contract.verify"&&!r)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"skipped",required:e.required,message:"Workspace contract is not present; contract verify skipped."};let g$1=i?await g(t,a??""):null;if(!i||!g$1)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"missing",required:e.required,evidencePath:a,message:a?`Missing evidence report: ${a}`:"No evidence mapping exists for this command."};let l;try{l=await w.readJson(g$1);}catch(n){return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"fail",required:e.required,evidencePath:a,message:`Evidence report is unreadable JSON: ${n instanceof Error?n.message:String(n)}`}}let d=h(l);if(!d)return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"fail",required:e.required,evidencePath:a,message:"Evidence report is not a JSON object."};let y=_e(e);if(y)try{a$2(d,y,`${e.label} evidence`);}catch(n){return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:"fail",required:e.required,evidencePath:a,message:`Evidence report is invalid: ${n instanceof Error?n.message:String(n)}`}}let c;if(e.id==="workspace.doctor"){let n=b(d.generatedAt,s$1,"Doctor evidence");n?c={status:"fail",message:n}:c=We(d);}else if(e.id==="workspace.readiness"){let n=b(d.generatedAt,s$1,"Release readiness evidence");n?c={status:"fail",message:n}:c=Pe(d);}else if(e.id==="workspace.contract.verify"){let n=b(d.generatedAt,s$1,"Workspace contract verify evidence");n?c={status:"fail",message:n}:c=xe(d);}else if(e.id==="workspace.analyze"){let n=b(d.generatedAt,s$1,"Analyze evidence");n?c={status:"fail",message:n}:c=Ie(d);}else if(e.id==="workspace.pipeline"){let n=b(d.generatedAt,s$1,"Pipeline evidence");n?c={status:"fail",message:n}:c=Oe(d);}else if(e.id==="workspace.doctor-fix"){let n=d.schemaVersion===s.doctorFixResult.schemaVersion?d:d.fixResult,o=h(n),p=typeof o?.generatedAt=="string"?o.generatedAt:void 0,f=b(p,s$1,"Doctor fix result");f?c={status:"fail",message:f}:await $e(t,p)?c={status:"skipped",message:"No current doctor remediation steps are pending."}:c=Ve(d);}else if(e.id.startsWith("project."))c=Be(d,e,s$1);else {let n=b(d.generatedAt,s$1,"Evidence report");n?c={status:"fail",message:n}:c={status:"pass",message:"Evidence report is present."};}return {id:e.id,label:e.label,scope:e.scope,project:e.project,command:e,status:c.status,required:e.required,evidencePath:a,message:c.message}}function He(e,t={blockingReasons:[],needsAttention:false}){let r=e.filter(n=>n.status==="pass").length,s=e.filter(n=>n.status==="warn").length,i=e.filter(n=>n.status==="fail").length,a=e.filter(n=>n.status==="missing").length,g=e.filter(n=>n.status==="skipped").length,l=e.filter(n=>n.required&&(n.status==="fail"||n.status==="missing")).map(n=>`${n.id}: ${n.message}`),d=e.filter(n=>n.required&&n.status==="missing").length,y="ready",c=0;return l.length>0||t.blockingReasons.length>0?(y="blocked",c=2):(s>0||e.some(n=>!n.required&&n.status==="fail")||d>0||t.needsAttention)&&(y="needs-attention",c=1),{verdict:y,exitCode:c,stepsPassed:r,stepsWarn:s,stepsFailed:i,stepsMissing:a,stepsSkipped:g}}function Me(e,t){let r=P(e.affectedProjects.map(o=>o.project?.name).filter(o=>typeof o=="string")),s=new Set(r.map(o=>o.toLowerCase())),i=P(e.transitiveImpact.map(o=>o.project?.name).filter(o=>typeof o=="string").filter(o=>!s.has(o.toLowerCase()))),a=new Map;for(let o of t){if(o.scope!=="project"||!o.project)continue;let p=o.project.toLowerCase(),f=a.get(p)??[];f.push(o),a.set(p,f);}let g=[],l=[],d=[],y=[],c=false,n=(o,p)=>{let f=a.get(o.toLowerCase())??[];if(f.length===0){d.push(o);return}let x=f.filter(m=>m.status==="fail"),R=x.filter(m=>m.required),I=f.filter(m=>m.status==="missing"),A=I.filter(m=>m.required),V=f.some(m=>m.status==="pass"||m.status==="warn");if(R.length>0){l.push(o),y.push(`graph.subgraph.${o}: ${p} has failed verification evidence (${R.map(m=>m.id).join(", ")}).`);return}if(x.length>0){l.push(o),c=true;return}if(A.length>0){l.push(o),y.push(`graph.subgraph.${o}: ${p} has missing required verification evidence (${A.map(m=>m.id).join(", ")}).`);return}if(I.length>0){l.push(o),c=true;return}if(V){g.push(o);return}d.push(o);};for(let o of r)n(o,"directly-changed");for(let o of i)n(o,"transitive dependent");return {subgraph:{totalProjects:r.length+i.length,directlyChanged:r,transitiveDependents:i,covered:P(g),uncovered:P(l),unverifiable:P(d)},blockingReasons:y,needsAttention:c}}function P(e){return [...new Set(e)].sort((t,r)=>t.localeCompare(r))}async function Te(e){let t=k.resolve(e.workspacePath);if(e.fromImpactPath){let a=je(t,e.fromImpactPath);return {impact:await ke(a),fromImpactRef:k.relative(t,a).split(k.sep).join("/"),impactFromDisk:true}}let r$1=k.join(t,g$1);if(await w.pathExists(r$1))return {impact:await ke(r$1),fromImpactRef:g$1,impactFromDisk:true};let s=k.join(t,d$3);if(await w.pathExists(s))return {impact:await p$1({workspacePath:t,fromPath:d$3,scope:e.scope,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now}),fromImpactRef:d$3,impactFromDisk:false};let i=await r({workspacePath:t,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now});return {impact:{schemaVersion:f,generatedAt:(e.now??new Date).toISOString(),fromRef:"baseline",diffRef:p.diff,workspace:{name:i.workspace.name,profile:i.workspace.profile,type:i.workspace.type},summary:{changed:false,risk:"none",affectedProjects:0,workspaceItems:0,recommendedCommands:0,blastRadius:{directlyAffected:0,transitivelyAffected:0,maxDistance:0,graphEdges:n(i)?.edges.length??0}},affectedProjects:[],transitiveImpact:[],criticalPathHotspots:[],workspaceImpact:[],verificationPlan:[],agentBrief:{headline:"Baseline workspace verify run.",bullets:["No impact report or snapshot was available; baseline gates were evaluated."],unsafeAssumptions:["Do not claim runtime verification passed unless evidence exists."]},diff:{schemaVersion:q.diff,generatedAt:(e.now??new Date).toISOString(),fromRef:"baseline",toRef:p.model,fromHash:"baseline",toHash:"baseline",summary:{changed:false,addedProjects:0,removedProjects:0,changedProjects:0,workspaceChanges:0,validationChanges:0,gitChangedFiles:0},git:{available:false,dirty:false,changedFiles:0,untrackedFiles:0,deletedFiles:0},changes:[],currentModel:i}},impactFromDisk:false}}function Le(e,t){if(t)return e.generatedAt}async function wt(e){let t=k.resolve(e.workspacePath),{impact:r$1,fromImpactRef:s,impactFromDisk:i}=await Te(e),a$2=r$1.diff.currentModel,g=i?await r({workspacePath:t,includeAbsolutePaths:e.includeAbsolutePaths,includeEvidence:e.includeEvidence,observableScanDepth:e.observableScanDepth,now:e.now}):a$2,l=[];if(i){let u=await p$1({workspacePath:t,fromPath:r$1.diff.fromRef,diff:r$1.diff,scope:e.scope,now:e.now}),E=[r$1.affectedProjects,r$1.transitiveImpact,r$1.verificationPlan],j=[u.affectedProjects,u.transitiveImpact,u.verificationPlan];JSON.stringify(E)!==JSON.stringify(j)&&l.push("workspace.impact: Persisted impact semantics do not match the impact re-derived from the embedded diff. Regenerate diff and impact.");}i&&d(g)!==r$1.diff.toHash&&l.push("workspace.impact: Impact evidence is stale because the current workspace model no longer matches the embedded model. Regenerate diff and impact.");let d$2=r$1.diff.git;if(i&&d$2?.available){let u=a(t,{ref:d$2.ref}),E=r$1.diff.changes.filter(v=>v.type.startsWith("git.")).map(v=>`${v.type}:${v.target.replace(/^git:/,"")}`).sort(),j=[...u.changedFiles.map(v=>`git.file.changed:${v}`),...u.untrackedFiles.map(v=>`git.untracked:${v}`),...u.deletedFiles.map(v=>`git.deleted:${v}`)].sort();(!u.available||u.commit!==d$2.commit||JSON.stringify(j)!==JSON.stringify(E))&&l.push("workspace.impact: Impact evidence is stale because Git changes no longer match the diff observation. Regenerate diff and impact.");}let y=Le(r$1,i),c$1=Ae([...o(),...r$1.verificationPlan]).filter(u=>Se(e.scope,u)),n$1=[];for(let u of c$1)n$1.push(await Ne(u,t,a$2.contracts.exists===true,y));let o$1=Me(r$1,n$1),p=a$1(n(a$2)??{nodes:[],edges:[]}),f=b$1(a$2),x=await ze(t),R=c(f,x?.freshness?.projectHashes),I={verdict:R.verdict,baseline:R.baseline,changed:R.changed,added:R.added,removed:R.removed,projectHashes:d$1(f)},A=b$2(p),V=a$2.policies?.mode??"warn",m=await qe(a$2,t),B=Ke(V,m),S=He(n$1,{blockingReasons:[...o$1.blockingReasons,...A,...B.blockingReasons,...l],needsAttention:o$1.needsAttention||B.needsAttention}),he=n$1.filter(u=>u.status==="missing"&&u.evidencePath).map(u=>u.evidencePath),_=[...n$1.filter(u=>u.required&&(u.status==="fail"||u.status==="missing")).map(u=>`${u.id}: ${u.message}`),...o$1.blockingReasons,...A,...B.blockingReasons,...l],ve=m.filter(u=>u.severity==="error").length,be=a$2.summary?.projectCount??a$2.projects.length,U=me({projectCount:be,verdict:S.verdict,exitCode:S.exitCode,blockingReasons:_,policyErrorCount:ve});S.verdict=U.verdict,S.exitCode=U.exitCode;let Y=Array.from(new Set(_.map(u=>u.trim()).filter(Boolean))).slice(0,12).map((u,E)=>{let j=n$1.find(v=>u.startsWith(`${v.id}:`));return ge({reason:u,blockerId:`blocker-${E+1}`,sourceCommand:j?.command.display,sourceArtifact:j?.evidencePath,verifyCommand:"npx workspai workspace verify --from-impact .workspai/reports/workspace-impact-last-run.json --json",verifyArtifact:G})});return {schemaVersion:ye,generatedAt:(e.now??new Date).toISOString(),workspacePath:t,mode:"evidence",fromImpactRef:s,scope:e.scope,impact:{changed:r$1.summary.changed,risk:r$1.summary.risk,affectedProjects:r$1.summary.affectedProjects,recommendedCommands:r$1.summary.recommendedCommands},summary:S,steps:n$1,missingEvidence:he,blockingReasons:_,...Y.length>0?{resolutionHints:Y}:{},verificationPlan:c$1,affectedSubgraph:o$1.subgraph,graphIntegrity:p,freshness:I,policyMode:V,policyViolations:m}}async function qe(e,t){let r=[];for(let i of e.validation?.issues??[])r.push({source:"model",severity:i.severity,code:i.code,message:i.message,target:i.target});let s=await g(t,p.contractVerify);try{if(s&&await w.pathExists(s)){let i=await w.readJson(s);if(Array.isArray(i.violations))for(let a of i.violations)typeof a=="string"&&a.trim().length>0&&r.push({source:"contract",severity:"error",code:"contract.violation",message:a});}}catch{}return r.sort((i,a)=>i.source!==a.source?i.source.localeCompare(a.source):i.code!==a.code?i.code.localeCompare(a.code):i.message.localeCompare(a.message))}function Ke(e,t){let r=t.filter(s=>s.severity==="error");return e==="enforce"&&r.length>0?{blockingReasons:r.map(s=>`policy.${s.code}: ${s.message}`),needsAttention:false}:{blockingReasons:[],needsAttention:r.length>0}}async function ze(e){let t=k.join(e,G);try{if(!await w.pathExists(t))return null;let r=await w.readJson(t);return r&&r.schemaVersion===ye?r:null}catch{return null}}async function Rt(e,t){return h$1(t,G,d$2(e))}function Je(e,t){let r=t?.strict?"strict":"default",s=[];if(e.summary.verdict==="blocked")return s.push(...e.blockingReasons),s.length===0&&s.push("verify verdict is blocked."),{passed:false,mode:r,exitCode:2,reasons:s};if(r==="strict"){if(e.summary.verdict!=="ready"&&s.push(`verify verdict is ${e.summary.verdict} (strict requires ready).`),e.freshness.verdict==="stale"){let i=[...e.freshness.changed,...e.freshness.added].slice(0,5);s.push(`freshness is stale${i.length>0?`: ${i.join(", ")}`:""} (strict requires fresh).`);}if(s.length>0)return {passed:false,mode:r,exitCode:1,reasons:s}}return {passed:true,mode:r,exitCode:0,reasons:s}}function Ct(e,t){return Je(e,t).exitCode}export{fe as a,st as b,ye as c,G as d,Me as e,wt as f,Rt as g,Je as h,Ct as i};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{b as buildWorkspaceManifest,f as createProject,a as initializeStandaloneGitRepository,g as registerWorkspaceAtPath,d as resolvePythonFreeFallbackProfile,c as syncWorkspaceFoundationFiles,e as writeWorkspaceLauncher}from'./chunk-
|
|
1
|
+
export{b as buildWorkspaceManifest,f as createProject,a as initializeStandaloneGitRepository,g as registerWorkspaceAtPath,d as resolvePythonFreeFallbackProfile,c as syncWorkspaceFoundationFiles,e as writeWorkspaceLauncher}from'./chunk-FVG5FBA4.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{d as DOCTOR_WORKSPACE_REPORT_PATH,r as applyEnvKeyAddFix,n as applyFileAppendFix,o as applyFileCopyFix,m as applyFileCreateFix,q as applyJsonEditFix,s as applyMakefileTargetFix,l as applyPackageScriptFix,j as assertOperationPathInsideProject,k as assertOperationPathInsideProjectResolved,i as buildRepairOperationIdentity,u as computeDoctorFixAwareExitCode,t as computeDoctorGateExitCode,p as decodeJsonPointerSegment,h as parseInternalRepairCommand,g as parsePackageScriptFix,f as pythonPackageListProvesDependencies,e as resolveDoctorPolicyProfile,v as runDoctor}from'./chunk-
|
|
1
|
+
export{d as DOCTOR_WORKSPACE_REPORT_PATH,r as applyEnvKeyAddFix,n as applyFileAppendFix,o as applyFileCopyFix,m as applyFileCreateFix,q as applyJsonEditFix,s as applyMakefileTargetFix,l as applyPackageScriptFix,j as assertOperationPathInsideProject,k as assertOperationPathInsideProjectResolved,i as buildRepairOperationIdentity,u as computeDoctorFixAwareExitCode,t as computeDoctorGateExitCode,p as decodeJsonPointerSegment,h as parseInternalRepairCommand,g as parsePackageScriptFix,f as pythonPackageListProvesDependencies,e as resolveDoctorPolicyProfile,v as runDoctor}from'./chunk-H24MEOML.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{f as GOAL_INDEX_PATH,e as GOAL_INDEX_SCHEMA_VERSION,k as buildGoalLifecycleResult,l as inspectGoalLifecycle,q as linkGoalChangeTransaction,p as linkGoalRepairTransaction,n as prepareGoalVerification,m as transitionGoalLifecycle,o as verifyGoalLifecycle}from'./chunk-
|
|
1
|
+
export{f as GOAL_INDEX_PATH,e as GOAL_INDEX_SCHEMA_VERSION,k as buildGoalLifecycleResult,l as inspectGoalLifecycle,q as linkGoalChangeTransaction,p as linkGoalRepairTransaction,n as prepareGoalVerification,m as transitionGoalLifecycle,o as verifyGoalLifecycle}from'./chunk-4H3VNKOJ.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{a as planGoalPack}from'./chunk-
|
|
1
|
+
export{a as planGoalPack}from'./chunk-BGUCDG5N.js';export{b as GOAL_AGENT_HANDOFF_SCHEMA_VERSION,f as GOAL_INDEX_PATH,e as GOAL_INDEX_SCHEMA_VERSION,g as GOAL_LIFECYCLE_RESULT_SCHEMA_VERSION,d as GOAL_PACK_LAST_RUN_PATH,a as GOAL_PACK_SCHEMA_VERSION,c as GOAL_PLAN_RESULT_SCHEMA_VERSION}from'./chunk-4H3VNKOJ.js';
|