workspai 0.75.2 → 0.76.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.
Files changed (113) hide show
  1. package/contracts/agent-framework-capabilities.v1.json +2 -2
  2. package/contracts/cli-runtime-command-inventory.v1.snapshot.json +12 -0
  3. package/contracts/create-planner-capabilities.v1.json +24 -0
  4. package/contracts/extension-cli-compatibility.v1.json +4 -2
  5. package/contracts/published-contract-catalog.v1.json +10 -0
  6. package/contracts/runtime-command-surface.v1.json +3 -1
  7. package/contracts/workspace-intelligence/agent-framework-admission-candidate.v2.json +217 -0
  8. package/contracts/workspace-intelligence/agent-framework-conformance-report.v2.json +274 -0
  9. package/contracts/workspace-intelligence-architecture.v1.json +5 -3
  10. package/dist/analyze-QVRVJB7I.js +1 -0
  11. package/dist/autopilot-release-DOGIETAT.js +1 -0
  12. package/dist/capabilities-command-FYBUVHZ7.js +1 -0
  13. package/dist/{chunk-ADHX7D3F.js → chunk-23CNBYIW.js} +1 -1
  14. package/dist/{chunk-IKBE3HOH.js → chunk-2I2A55RE.js} +1 -1
  15. package/dist/{chunk-4JXJRIJM.js → chunk-4BBFEHPL.js} +1 -1
  16. package/dist/{chunk-VHMDWRDG.js → chunk-4BPZJR4Z.js} +4 -4
  17. package/dist/{chunk-KDVNRNDU.js → chunk-4MXKXHLW.js} +1 -1
  18. package/dist/{chunk-JKAAKE4Z.js → chunk-4R44E7HN.js} +1 -1
  19. package/dist/chunk-5S6IZ6PY.js +2 -0
  20. package/dist/chunk-6BO4QHKA.js +1 -0
  21. package/dist/{chunk-VWBWDDU2.js → chunk-AGI46TSQ.js} +1 -1
  22. package/dist/{chunk-GDOO2YZW.js → chunk-BZLDCASY.js} +1 -1
  23. package/dist/{chunk-OA2YJN22.js → chunk-DWDYLKVW.js} +1 -1
  24. package/dist/{chunk-P36TACKN.js → chunk-FBF767WP.js} +1 -1
  25. package/dist/{chunk-PFAGXI3G.js → chunk-FD2ZGGCQ.js} +1 -1
  26. package/dist/chunk-H4YHIOCT.js +7 -0
  27. package/dist/{chunk-ZI54C2AO.js → chunk-HRGIHWYH.js} +1 -1
  28. package/dist/{chunk-LFY7KTPD.js → chunk-IKNWNGLY.js} +1 -1
  29. package/dist/{chunk-ZGVODK5C.js → chunk-KO4DM2AV.js} +1 -1
  30. package/dist/{chunk-FNVWDXK2.js → chunk-KW35SWG6.js} +5 -5
  31. package/dist/{chunk-EP7SUMAX.js → chunk-L6VNI4DN.js} +1 -1
  32. package/dist/chunk-NSC4VWV2.js +1 -0
  33. package/dist/chunk-P5LI5DL3.js +1 -0
  34. package/dist/chunk-PSQPKK6H.js +97 -0
  35. package/dist/chunk-PUH3TSPC.js +1 -0
  36. package/dist/chunk-QFDTKOYS.js +2649 -0
  37. package/dist/chunk-QIPW3G2H.js +1 -0
  38. package/dist/chunk-QVFIR64T.js +10 -0
  39. package/dist/{chunk-FZWLWFR4.js → chunk-R3Z4LY3O.js} +1 -1
  40. package/dist/chunk-RKFTUIZ4.js +4 -0
  41. package/dist/{chunk-COOVCORC.js → chunk-SVO2GGTV.js} +1 -1
  42. package/dist/{chunk-5K4O3TAW.js → chunk-TFFNHWXY.js} +1 -1
  43. package/dist/chunk-TJ3MDZMC.js +6 -0
  44. package/dist/{chunk-WXUCAVFT.js → chunk-UOTOJJI4.js} +8 -8
  45. package/dist/chunk-VODNLROY.js +1 -0
  46. package/dist/{chunk-WHBKKJ7L.js → chunk-X7MDTBX5.js} +1 -1
  47. package/dist/chunk-YLLCZMKP.js +2 -0
  48. package/dist/{chunk-K52IQX3J.js → chunk-Z2M2XCIB.js} +1 -1
  49. package/dist/{chunk-DTNOF3MP.js → chunk-ZXQC36NJ.js} +1 -1
  50. package/dist/{create-ZFSFWAW3.js → create-ZRUQ3KNZ.js} +1 -1
  51. package/dist/{doctor-4KL4XUCS.js → doctor-7V7LJLHX.js} +1 -1
  52. package/dist/{goal-lifecycle-EXQZD7IA.js → goal-lifecycle-EM4DUJCR.js} +1 -1
  53. package/dist/{goal-pack-DKJU2DEP.js → goal-pack-YMWZHAH6.js} +1 -1
  54. package/dist/index.d.ts +12 -6
  55. package/dist/index.js +251 -250
  56. package/dist/{pipeline-4GVAOCEN.js → pipeline-6MBH3MU2.js} +1 -1
  57. package/dist/platform-capabilities-RWOWND5Q.js +1 -0
  58. package/dist/{project-agent-entry-7QKNEEXP.js → project-agent-entry-ZXAE2MAJ.js} +1 -1
  59. package/dist/{project-intelligence-lens-IHRYCLNU.js → project-intelligence-lens-NBTPOK2R.js} +1 -1
  60. package/dist/{project-test-coverage-3P5FH6E5.js → project-test-coverage-HOZC72EK.js} +1 -1
  61. package/dist/proof-carrying-change-WJFAKK3C.js +1 -0
  62. package/dist/{pythonRapidkitExec-UMFLDIYR.js → pythonRapidkitExec-S35OEIEF.js} +1 -1
  63. package/dist/{verified-goal-XI4RQESU.js → verified-goal-B7EX2PBE.js} +1 -1
  64. package/dist/{workspace-EYXAKMVI.js → workspace-EBPYCSEM.js} +1 -1
  65. package/dist/{workspace-agent-sync-SN55KT6N.js → workspace-agent-sync-Y4F6FBBC.js} +1 -1
  66. package/dist/{workspace-context-PW6ESEHH.js → workspace-context-Y7F7GJCQ.js} +1 -1
  67. package/dist/{workspace-contract-FPLFL4G3.js → workspace-contract-XJMWMVQE.js} +1 -1
  68. package/dist/{workspace-explain-TVQ5IF5D.js → workspace-explain-T2J5ZLY7.js} +1 -1
  69. package/dist/{workspace-foundation-DWIJPZRH.js → workspace-foundation-2UP6IMTH.js} +1 -1
  70. package/dist/{workspace-graph-stream-RUTNWLQB.js → workspace-graph-stream-MZVL3OCX.js} +1 -1
  71. package/dist/{workspace-intelligence-4CA2CSPZ.js → workspace-intelligence-FZRQIFFM.js} +1 -1
  72. package/dist/{workspace-intelligence-runner-VM5SXXAT.js → workspace-intelligence-runner-IXT62JG7.js} +1 -1
  73. package/dist/{workspace-knowledge-graph-JXN2ZOAF.js → workspace-knowledge-graph-EFC4TUDZ.js} +1 -1
  74. package/dist/workspace-knowledge-graph-snapshot-QIMF7TCF.js +1 -0
  75. package/dist/{workspace-mcp-serve-4WN4CSD7.js → workspace-mcp-serve-C42UUU7W.js} +1 -1
  76. package/dist/{workspace-model-D4IECQML.js → workspace-model-72SJ6WXT.js} +1 -1
  77. package/dist/{workspace-onboarding-6XWDKLM5.js → workspace-onboarding-TFDAIHTS.js} +1 -1
  78. package/dist/{workspace-registry-summary-Y3ET36NH.js → workspace-registry-summary-ZNTXSUI4.js} +1 -1
  79. package/dist/{workspace-repair-engine-HBUXRHDY.js → workspace-repair-engine-542TAL3Z.js} +1 -1
  80. package/dist/workspace-run-NAPJYNSZ.js +1 -0
  81. package/dist/{workspace-verify-OOAZ3NMZ.js → workspace-verify-UXKENOQU.js} +1 -1
  82. package/dist/{workspace-watch-BNM5B6HU.js → workspace-watch-DV5AHLOK.js} +1 -1
  83. package/docs/README.md +2 -2
  84. package/docs/agent-framework-adapters.md +164 -39
  85. package/docs/ci-workflows.md +29 -22
  86. package/docs/commands-reference.md +17 -8
  87. package/docs/creating-workspaces-and-projects.md +4 -2
  88. package/docs/doctor-command.md +6 -4
  89. package/docs/native-kit-baselines.md +2 -1
  90. package/docs/workspace-run.md +3 -1
  91. package/package.json +3 -1
  92. package/scripts/enterprise-package-smoke.mjs +98 -5
  93. package/dist/analyze-6UEBC5OJ.js +0 -1
  94. package/dist/autopilot-release-H5TO6NYY.js +0 -1
  95. package/dist/capabilities-command-VK3LQLP2.js +0 -1
  96. package/dist/chunk-3N27P3KO.js +0 -7
  97. package/dist/chunk-3RNWBFRP.js +0 -4
  98. package/dist/chunk-66O62XNJ.js +0 -97
  99. package/dist/chunk-7NKM6EHE.js +0 -7
  100. package/dist/chunk-BR6QIYQS.js +0 -1
  101. package/dist/chunk-DFREJHG7.js +0 -1
  102. package/dist/chunk-E42IFQFR.js +0 -6
  103. package/dist/chunk-EWD6QTAM.js +0 -2
  104. package/dist/chunk-G5UCEXP6.js +0 -1
  105. package/dist/chunk-LARREYZN.js +0 -1
  106. package/dist/chunk-RGNCL5OB.js +0 -1
  107. package/dist/chunk-SZHRPELL.js +0 -1
  108. package/dist/chunk-VXFIMEC6.js +0 -2
  109. package/dist/chunk-X7OI24LO.js +0 -418
  110. package/dist/platform-capabilities-DB4BZPTD.js +0 -1
  111. package/dist/proof-carrying-change-O37XUPIZ.js +0 -1
  112. package/dist/workspace-knowledge-graph-snapshot-KBNUXA64.js +0 -1
  113. package/dist/workspace-run-VN7KV4BU.js +0 -1
@@ -0,0 +1 @@
1
+ import {b as b$1,c,d as d$1}from'./chunk-2I2A55RE.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-BZLDCASY.js';import {r,n,d as d$5}from'./chunk-VODNLROY.js';import {d as d$2}from'./chunk-YLLCZMKP.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};