pumuki 6.3.7

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 (744) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +370 -0
  3. package/VERSION +1 -0
  4. package/assets/Hook_01.png +0 -0
  5. package/assets/Hook_02.png +0 -0
  6. package/assets/ai-start.png +0 -0
  7. package/assets/ai_gate.png +0 -0
  8. package/assets/ast_intelligence_01.png +0 -0
  9. package/assets/ast_intelligence_01.svg +40 -0
  10. package/assets/ast_intelligence_02.png +0 -0
  11. package/assets/ast_intelligence_02.svg +39 -0
  12. package/assets/ast_intelligence_03.png +0 -0
  13. package/assets/ast_intelligence_03.svg +55 -0
  14. package/assets/ast_intelligence_04.png +0 -0
  15. package/assets/ast_intelligence_04.svg +39 -0
  16. package/assets/ast_intelligence_05.png +0 -0
  17. package/assets/ast_intelligence_05.svg +45 -0
  18. package/assets/logo.png +0 -0
  19. package/assets/logo_banner.svg +29 -0
  20. package/assets/pre-flight-check.png +0 -0
  21. package/bin/_run-ts-entry.js +46 -0
  22. package/bin/pumuki-ci.js +5 -0
  23. package/bin/pumuki-framework.js +5 -0
  24. package/bin/pumuki-mcp-evidence.js +5 -0
  25. package/bin/pumuki-pre-commit.js +5 -0
  26. package/bin/pumuki-pre-push.js +5 -0
  27. package/bin/pumuki.js +5 -0
  28. package/core/facts/DependencyFact.test.ts +38 -0
  29. package/core/facts/DependencyFact.ts +6 -0
  30. package/core/facts/Fact.test.ts +74 -0
  31. package/core/facts/Fact.ts +10 -0
  32. package/core/facts/FactSet.test.ts +38 -0
  33. package/core/facts/FactSet.ts +3 -0
  34. package/core/facts/FileChangeFact.test.ts +36 -0
  35. package/core/facts/FileChangeFact.ts +5 -0
  36. package/core/facts/FileContentFact.test.ts +26 -0
  37. package/core/facts/FileContentFact.ts +5 -0
  38. package/core/facts/HeuristicFact.test.ts +34 -0
  39. package/core/facts/HeuristicFact.ts +10 -0
  40. package/core/facts/detectors/browser/index.test.ts +131 -0
  41. package/core/facts/detectors/browser/index.ts +67 -0
  42. package/core/facts/detectors/fs/callbacks.test.ts +73 -0
  43. package/core/facts/detectors/fs/callbacks.ts +93 -0
  44. package/core/facts/detectors/fs/promises.test.ts +88 -0
  45. package/core/facts/detectors/fs/promises.ts +75 -0
  46. package/core/facts/detectors/fs/sync.test.ts +48 -0
  47. package/core/facts/detectors/fs/sync.ts +3 -0
  48. package/core/facts/detectors/fs/syncPart1.test.ts +52 -0
  49. package/core/facts/detectors/fs/syncPart1.ts +3 -0
  50. package/core/facts/detectors/fs/syncPart1DirTimes.test.ts +58 -0
  51. package/core/facts/detectors/fs/syncPart1DirTimes.ts +93 -0
  52. package/core/facts/detectors/fs/syncPart1FileOps.test.ts +64 -0
  53. package/core/facts/detectors/fs/syncPart1FileOps.ts +93 -0
  54. package/core/facts/detectors/fs/syncPart1Metadata.test.ts +64 -0
  55. package/core/facts/detectors/fs/syncPart1Metadata.ts +139 -0
  56. package/core/facts/detectors/fs/syncPart2.test.ts +62 -0
  57. package/core/facts/detectors/fs/syncPart2.ts +4 -0
  58. package/core/facts/detectors/fs/syncPart2Core.test.ts +62 -0
  59. package/core/facts/detectors/fs/syncPart2Core.ts +70 -0
  60. package/core/facts/detectors/fs/syncPart2Io.test.ts +62 -0
  61. package/core/facts/detectors/fs/syncPart2Io.ts +70 -0
  62. package/core/facts/detectors/fs/syncPart2Permissions.test.ts +66 -0
  63. package/core/facts/detectors/fs/syncPart2Permissions.ts +93 -0
  64. package/core/facts/detectors/fs/syncPart2Times.test.ts +66 -0
  65. package/core/facts/detectors/fs/syncPart2Times.ts +93 -0
  66. package/core/facts/detectors/fs/syncPart3.test.ts +62 -0
  67. package/core/facts/detectors/fs/syncPart3.ts +3 -0
  68. package/core/facts/detectors/fs/syncPart3DescriptorIo.test.ts +69 -0
  69. package/core/facts/detectors/fs/syncPart3DescriptorIo.ts +93 -0
  70. package/core/facts/detectors/fs/syncPart3Links.test.ts +62 -0
  71. package/core/facts/detectors/fs/syncPart3Links.ts +70 -0
  72. package/core/facts/detectors/fs/syncPart3PathOps.test.ts +72 -0
  73. package/core/facts/detectors/fs/syncPart3PathOps.ts +116 -0
  74. package/core/facts/detectors/process/core.test.ts +147 -0
  75. package/core/facts/detectors/process/core.ts +120 -0
  76. package/core/facts/detectors/process/index.test.ts +61 -0
  77. package/core/facts/detectors/process/index.ts +3 -0
  78. package/core/facts/detectors/process/shell.test.ts +137 -0
  79. package/core/facts/detectors/process/shell.ts +170 -0
  80. package/core/facts/detectors/process/spawn.test.ts +155 -0
  81. package/core/facts/detectors/process/spawn.ts +121 -0
  82. package/core/facts/detectors/security/index.test.ts +382 -0
  83. package/core/facts/detectors/security/index.ts +16 -0
  84. package/core/facts/detectors/security/securityCredentials.test.ts +149 -0
  85. package/core/facts/detectors/security/securityCredentials.ts +192 -0
  86. package/core/facts/detectors/security/securityCrypto.test.ts +122 -0
  87. package/core/facts/detectors/security/securityCrypto.ts +88 -0
  88. package/core/facts/detectors/security/securityJwt.test.ts +187 -0
  89. package/core/facts/detectors/security/securityJwt.ts +134 -0
  90. package/core/facts/detectors/security/securityTls.test.ts +121 -0
  91. package/core/facts/detectors/security/securityTls.ts +88 -0
  92. package/core/facts/detectors/text/android.test.ts +87 -0
  93. package/core/facts/detectors/text/android.ts +38 -0
  94. package/core/facts/detectors/text/ios.test.ts +83 -0
  95. package/core/facts/detectors/text/ios.ts +108 -0
  96. package/core/facts/detectors/text/utils.test.ts +71 -0
  97. package/core/facts/detectors/text/utils.ts +146 -0
  98. package/core/facts/detectors/typescript/index.test.ts +231 -0
  99. package/core/facts/detectors/typescript/index.ts +167 -0
  100. package/core/facts/detectors/utils/astHelpers.test.ts +79 -0
  101. package/core/facts/detectors/utils/astHelpers.ts +33 -0
  102. package/core/facts/detectors/vm/index.test.ts +58 -0
  103. package/core/facts/detectors/vm/index.ts +27 -0
  104. package/core/facts/extractHeuristicFacts.ts +394 -0
  105. package/core/facts/index.test.ts +72 -0
  106. package/core/facts/index.ts +11 -0
  107. package/core/gate/Finding.test.ts +52 -0
  108. package/core/gate/Finding.ts +9 -0
  109. package/core/gate/GateOutcome.test.ts +20 -0
  110. package/core/gate/GateOutcome.ts +1 -0
  111. package/core/gate/GatePolicy.test.ts +28 -0
  112. package/core/gate/GatePolicy.ts +9 -0
  113. package/core/gate/GateStage.test.ts +22 -0
  114. package/core/gate/GateStage.ts +1 -0
  115. package/core/gate/conditionMatches.test.ts +110 -0
  116. package/core/gate/conditionMatches.ts +174 -0
  117. package/core/gate/evaluateGate.test.ts +77 -0
  118. package/core/gate/evaluateGate.ts +23 -0
  119. package/core/gate/evaluateRules.test.ts +106 -0
  120. package/core/gate/evaluateRules.ts +40 -0
  121. package/core/gate/index.test.ts +39 -0
  122. package/core/gate/index.ts +6 -0
  123. package/core/rules/Condition.test.ts +54 -0
  124. package/core/rules/Condition.ts +40 -0
  125. package/core/rules/Consequence.test.ts +25 -0
  126. package/core/rules/Consequence.ts +5 -0
  127. package/core/rules/README.md +6 -0
  128. package/core/rules/RuleDefinition.test.ts +55 -0
  129. package/core/rules/RuleDefinition.ts +20 -0
  130. package/core/rules/RuleSet.test.ts +48 -0
  131. package/core/rules/RuleSet.ts +3 -0
  132. package/core/rules/Severity.test.ts +19 -0
  133. package/core/rules/Severity.ts +12 -0
  134. package/core/rules/index.test.ts +41 -0
  135. package/core/rules/index.ts +7 -0
  136. package/core/rules/mergeRuleSets.ts +53 -0
  137. package/core/rules/presets/androidRuleSet.test.ts +22 -0
  138. package/core/rules/presets/androidRuleSet.ts +62 -0
  139. package/core/rules/presets/astHeuristicsRuleSet.ts +31 -0
  140. package/core/rules/presets/backendRuleSet.test.ts +27 -0
  141. package/core/rules/presets/backendRuleSet.ts +61 -0
  142. package/core/rules/presets/exampleRuleSet.test.ts +25 -0
  143. package/core/rules/presets/exampleRuleSet.ts +34 -0
  144. package/core/rules/presets/frontendRuleSet.test.ts +27 -0
  145. package/core/rules/presets/frontendRuleSet.ts +61 -0
  146. package/core/rules/presets/heuristics/android.ts +58 -0
  147. package/core/rules/presets/heuristics/browser.ts +58 -0
  148. package/core/rules/presets/heuristics/fsCallbacks.ts +9 -0
  149. package/core/rules/presets/heuristics/fsCallbacksFileOperationsRules.ts +400 -0
  150. package/core/rules/presets/heuristics/fsCallbacksMetadataRules.ts +418 -0
  151. package/core/rules/presets/heuristics/fsPromises.ts +9 -0
  152. package/core/rules/presets/heuristics/fsPromisesFileOperations.ts +184 -0
  153. package/core/rules/presets/heuristics/fsPromisesMetadataRules.ts +238 -0
  154. package/core/rules/presets/heuristics/fsSync.ts +13 -0
  155. package/core/rules/presets/heuristics/fsSyncAppendRules.ts +22 -0
  156. package/core/rules/presets/heuristics/fsSyncDescriptorRules.ts +328 -0
  157. package/core/rules/presets/heuristics/fsSyncFileOperationsRules.ts +382 -0
  158. package/core/rules/presets/heuristics/fsSyncPathRules.ts +4 -0
  159. package/core/rules/presets/heuristics/ios.ts +94 -0
  160. package/core/rules/presets/heuristics/process.ts +241 -0
  161. package/core/rules/presets/heuristics/security.ts +13 -0
  162. package/core/rules/presets/heuristics/securityCredentialsRules.ts +80 -0
  163. package/core/rules/presets/heuristics/securityCryptoRules.ts +61 -0
  164. package/core/rules/presets/heuristics/securityJwtRules.ts +61 -0
  165. package/core/rules/presets/heuristics/securityTlsRules.ts +42 -0
  166. package/core/rules/presets/heuristics/typescript.ts +220 -0
  167. package/core/rules/presets/heuristics/vm.ts +23 -0
  168. package/core/rules/presets/index.test.ts +32 -0
  169. package/core/rules/presets/index.ts +8 -0
  170. package/core/rules/presets/iosEnterpriseRuleSet.ts +204 -0
  171. package/core/rules/presets/iosNonNegotiableRuleSet.ts +76 -0
  172. package/core/rules/presets/rulePackVersions.test.ts +21 -0
  173. package/core/rules/presets/rulePackVersions.ts +11 -0
  174. package/core/utils/stableStringify.ts +18 -0
  175. package/docs/API_REFERENCE.md +233 -0
  176. package/docs/ARCHITECTURE.md +190 -0
  177. package/docs/ARCHITECTURE_DETAILED.md +165 -0
  178. package/docs/AST_HEURISTICS_REINTRODUCTION_PLAN.md +88 -0
  179. package/docs/BRANCH_PROTECTION_GUIDE.md +50 -0
  180. package/docs/CODE_STANDARDS.md +73 -0
  181. package/docs/CONFIGURATION.md +132 -0
  182. package/docs/CONTRIBUTING.md +92 -0
  183. package/docs/DEPENDENCIES.md +54 -0
  184. package/docs/HOW_IT_WORKS.md +155 -0
  185. package/docs/INSTALLATION.md +172 -0
  186. package/docs/MCP_AGENT_CONTEXT_CONSUMPTION.md +189 -0
  187. package/docs/MCP_EVIDENCE_CONTEXT_SERVER.md +242 -0
  188. package/docs/MCP_SERVERS.md +114 -0
  189. package/docs/README.md +85 -0
  190. package/docs/REFRACTOR_PROGRESS.md +155 -0
  191. package/docs/RELEASE_NOTES.md +175 -0
  192. package/docs/TESTING.md +101 -0
  193. package/docs/TODO.md +692 -0
  194. package/docs/USAGE.md +259 -0
  195. package/docs/evidence-v2.1.md +49 -0
  196. package/docs/images/README.md +20 -0
  197. package/docs/rule-packs/README.md +45 -0
  198. package/docs/rule-packs/android.md +21 -0
  199. package/docs/rule-packs/backend.md +24 -0
  200. package/docs/rule-packs/frontend.md +22 -0
  201. package/docs/rule-packs/heuristics.md +1304 -0
  202. package/docs/rule-packs/ios.md +22 -0
  203. package/docs/skills-repo-enforcement-migration.md +73 -0
  204. package/docs/validation/README.md +82 -0
  205. package/docs/validation/adapter-hook-runtime-local-report.md +45 -0
  206. package/docs/validation/adapter-hook-runtime-validation.md +82 -0
  207. package/docs/validation/adapter-real-session-report-template.md +63 -0
  208. package/docs/validation/consumer-ci-startup-failure-playbook.md +184 -0
  209. package/docs/validation/consumer-startup-escalation-handoff-latest.md +237 -0
  210. package/docs/validation/enterprise-consumer-isolation-policy.md +45 -0
  211. package/docs/validation/github-support-ticket-template-startup-failure.md +84 -0
  212. package/docs/validation/mock-consumer-integration-runbook.md +89 -0
  213. package/docs/validation/phase5-execution-closure.md +227 -0
  214. package/docs/validation/phase8-external-rollout-pack.md +168 -0
  215. package/docs/validation/phase8-post-billing-reactivation-runbook.md +133 -0
  216. package/docs/validation/skills-rollout-consumer-repositories.md +124 -0
  217. package/index.js +15 -0
  218. package/integrations/config/compileSkillsLock.ts +231 -0
  219. package/integrations/config/heuristics.ts +18 -0
  220. package/integrations/config/loadProjectRules.ts +43 -0
  221. package/integrations/config/projectRules.ts +6 -0
  222. package/integrations/config/projectRulesSchema.ts +85 -0
  223. package/integrations/config/skillsCompilerTemplates.ts +151 -0
  224. package/integrations/config/skillsLock.ts +248 -0
  225. package/integrations/config/skillsPolicy.ts +178 -0
  226. package/integrations/config/skillsRuleSet.ts +188 -0
  227. package/integrations/config/skillsSources.ts +88 -0
  228. package/integrations/evidence/buildEvidence.ts +350 -0
  229. package/integrations/evidence/generateEvidence.ts +14 -0
  230. package/integrations/evidence/humanIntent.ts +115 -0
  231. package/integrations/evidence/readEvidence.ts +47 -0
  232. package/integrations/evidence/schema.ts +97 -0
  233. package/integrations/evidence/writeEvidence.ts +201 -0
  234. package/integrations/gate/stagePolicies.ts +295 -0
  235. package/integrations/git/EvidenceService.ts +111 -0
  236. package/integrations/git/GitService.ts +35 -0
  237. package/integrations/git/baselineRuleSets.ts +58 -0
  238. package/integrations/git/ciAndroid.cli.ts +4 -0
  239. package/integrations/git/ciAndroid.ts +1 -0
  240. package/integrations/git/ciBackend.cli.ts +4 -0
  241. package/integrations/git/ciBackend.ts +1 -0
  242. package/integrations/git/ciFrontend.cli.ts +4 -0
  243. package/integrations/git/ciFrontend.ts +1 -0
  244. package/integrations/git/ciIOS.cli.ts +4 -0
  245. package/integrations/git/ciIOS.ts +1 -0
  246. package/integrations/git/evaluateStagedIOS.ts +127 -0
  247. package/integrations/git/getCommitRangeFacts.ts +28 -0
  248. package/integrations/git/gitDiffUtils.ts +90 -0
  249. package/integrations/git/index.ts +13 -0
  250. package/integrations/git/preCommitAndroid.cli.ts +4 -0
  251. package/integrations/git/preCommitAndroid.ts +1 -0
  252. package/integrations/git/preCommitBackend.cli.ts +4 -0
  253. package/integrations/git/preCommitBackend.ts +1 -0
  254. package/integrations/git/preCommitFrontend.cli.ts +4 -0
  255. package/integrations/git/preCommitFrontend.ts +1 -0
  256. package/integrations/git/preCommitIOS.cli.ts +4 -0
  257. package/integrations/git/preCommitIOS.ts +1 -0
  258. package/integrations/git/prePushAndroid.cli.ts +4 -0
  259. package/integrations/git/prePushAndroid.ts +1 -0
  260. package/integrations/git/prePushBackend.cli.ts +4 -0
  261. package/integrations/git/prePushBackend.ts +1 -0
  262. package/integrations/git/prePushFrontend.cli.ts +4 -0
  263. package/integrations/git/prePushFrontend.ts +1 -0
  264. package/integrations/git/prePushIOS.cli.ts +4 -0
  265. package/integrations/git/prePushIOS.ts +1 -0
  266. package/integrations/git/resolveGitRefs.ts +51 -0
  267. package/integrations/git/runCliCommand.ts +11 -0
  268. package/integrations/git/runPlatformGate.ts +89 -0
  269. package/integrations/git/runPlatformGateEvaluation.ts +82 -0
  270. package/integrations/git/runPlatformGateEvidence.ts +41 -0
  271. package/integrations/git/runPlatformGateFacts.ts +34 -0
  272. package/integrations/git/runPlatformGateOutput.ts +11 -0
  273. package/integrations/git/stageRunners.ts +40 -0
  274. package/integrations/lifecycle/artifacts.ts +26 -0
  275. package/integrations/lifecycle/cli.ts +180 -0
  276. package/integrations/lifecycle/constants.ts +13 -0
  277. package/integrations/lifecycle/consumerPackage.ts +48 -0
  278. package/integrations/lifecycle/doctor.ts +90 -0
  279. package/integrations/lifecycle/gitService.ts +63 -0
  280. package/integrations/lifecycle/hookBlock.ts +93 -0
  281. package/integrations/lifecycle/hookManager.ts +107 -0
  282. package/integrations/lifecycle/index.ts +6 -0
  283. package/integrations/lifecycle/install.ts +44 -0
  284. package/integrations/lifecycle/npmService.ts +21 -0
  285. package/integrations/lifecycle/packageInfo.ts +5 -0
  286. package/integrations/lifecycle/remove.ts +95 -0
  287. package/integrations/lifecycle/state.ts +41 -0
  288. package/integrations/lifecycle/status.ts +30 -0
  289. package/integrations/lifecycle/uninstall.ts +36 -0
  290. package/integrations/lifecycle/update.ts +77 -0
  291. package/integrations/mcp/evidenceContextServer.cli.ts +16 -0
  292. package/integrations/mcp/evidenceContextServer.ts +152 -0
  293. package/integrations/mcp/evidenceFacets.ts +3 -0
  294. package/integrations/mcp/evidenceFacetsBase.ts +94 -0
  295. package/integrations/mcp/evidenceFacetsSnapshot.ts +104 -0
  296. package/integrations/mcp/evidenceFacetsSuppressed.ts +3 -0
  297. package/integrations/mcp/evidenceFacetsSuppressedBase.ts +221 -0
  298. package/integrations/mcp/evidenceFacetsSuppressedRelations.ts +263 -0
  299. package/integrations/mcp/evidenceFacetsSuppressedShare.ts +2 -0
  300. package/integrations/mcp/evidenceFacetsSuppressedShareCore.ts +442 -0
  301. package/integrations/mcp/evidenceFacetsSuppressedShareTriage.ts +487 -0
  302. package/integrations/mcp/evidencePayloadCollections.ts +37 -0
  303. package/integrations/mcp/evidencePayloadCollectionsFindings.ts +64 -0
  304. package/integrations/mcp/evidencePayloadCollectionsLedger.ts +69 -0
  305. package/integrations/mcp/evidencePayloadCollectionsPaging.ts +38 -0
  306. package/integrations/mcp/evidencePayloadCollectionsPlatforms.ts +49 -0
  307. package/integrations/mcp/evidencePayloadCollectionsRulesets.ts +50 -0
  308. package/integrations/mcp/evidencePayloadCollectionsSorters.ts +62 -0
  309. package/integrations/mcp/evidencePayloadConfig.ts +79 -0
  310. package/integrations/mcp/evidencePayloadSummary.ts +144 -0
  311. package/integrations/mcp/evidencePayloadSummarySuppressed.ts +361 -0
  312. package/integrations/mcp/evidencePayloads.ts +8 -0
  313. package/integrations/mcp/index.ts +1 -0
  314. package/integrations/platform/detectAndroid.ts +25 -0
  315. package/integrations/platform/detectBackend.ts +22 -0
  316. package/integrations/platform/detectFrontend.ts +29 -0
  317. package/integrations/platform/detectPlatforms.ts +69 -0
  318. package/package.json +218 -0
  319. package/scripts/adapter-readiness-cli-lib.ts +64 -0
  320. package/scripts/adapter-readiness-contract.ts +46 -0
  321. package/scripts/adapter-readiness-lib.ts +10 -0
  322. package/scripts/adapter-readiness-markdown-lib.ts +41 -0
  323. package/scripts/adapter-readiness-markdown-next-actions-lib.ts +33 -0
  324. package/scripts/adapter-readiness-markdown-sections-lib.ts +78 -0
  325. package/scripts/adapter-readiness-parser-lib.ts +30 -0
  326. package/scripts/adapter-readiness-summary-lib.ts +62 -0
  327. package/scripts/adapter-real-session-analysis-evaluation-lib.ts +49 -0
  328. package/scripts/adapter-real-session-analysis-lib.ts +8 -0
  329. package/scripts/adapter-real-session-analysis-messages-lib.ts +58 -0
  330. package/scripts/adapter-real-session-analysis-signals-lib.ts +59 -0
  331. package/scripts/adapter-real-session-analysis-status-lib.ts +29 -0
  332. package/scripts/adapter-real-session-arg-values-lib.ts +47 -0
  333. package/scripts/adapter-real-session-args-lib.ts +46 -0
  334. package/scripts/adapter-real-session-audit-snapshot-lib.ts +70 -0
  335. package/scripts/adapter-real-session-context-lib.ts +7 -0
  336. package/scripts/adapter-real-session-contract.ts +54 -0
  337. package/scripts/adapter-real-session-fs-lib.ts +36 -0
  338. package/scripts/adapter-real-session-git-lib.ts +13 -0
  339. package/scripts/adapter-real-session-hook-config-lib.ts +24 -0
  340. package/scripts/adapter-real-session-markdown-core-sections-lib.ts +11 -0
  341. package/scripts/adapter-real-session-markdown-lib.ts +25 -0
  342. package/scripts/adapter-real-session-markdown-sections-context-lib.ts +56 -0
  343. package/scripts/adapter-real-session-markdown-sections-evaluation-lib.ts +71 -0
  344. package/scripts/adapter-real-session-markdown-sections-lib.ts +34 -0
  345. package/scripts/adapter-real-session-markdown-snippet-section-lib.ts +44 -0
  346. package/scripts/adapter-real-session-markdown-snippets-lib.ts +19 -0
  347. package/scripts/adapter-real-session-markdown-value-formatters-lib.ts +10 -0
  348. package/scripts/adapter-real-session-report-lib.ts +16 -0
  349. package/scripts/adapter-real-session-status-parser-lib.ts +42 -0
  350. package/scripts/adapter-session-status-args-lib.ts +46 -0
  351. package/scripts/adapter-session-status-audit-latest-lib.ts +22 -0
  352. package/scripts/adapter-session-status-audit-tail-entries-lib.ts +78 -0
  353. package/scripts/adapter-session-status-audit-tail-lib.ts +15 -0
  354. package/scripts/adapter-session-status-command-lib.ts +49 -0
  355. package/scripts/adapter-session-status-contract.ts +55 -0
  356. package/scripts/adapter-session-status-hook-log-filter-lib.ts +38 -0
  357. package/scripts/adapter-session-status-lib.ts +25 -0
  358. package/scripts/adapter-session-status-log-filter-lib.ts +3 -0
  359. package/scripts/adapter-session-status-log-utils-lib.ts +23 -0
  360. package/scripts/adapter-session-status-markdown-lib.ts +65 -0
  361. package/scripts/adapter-session-status-report-lib.ts +21 -0
  362. package/scripts/adapter-session-status-tail-readers-lib.ts +58 -0
  363. package/scripts/adapter-session-status-verdict-lib.ts +43 -0
  364. package/scripts/adapter-session-status-writes-log-filter-lib.ts +25 -0
  365. package/scripts/build-adapter-readiness.ts +51 -0
  366. package/scripts/build-adapter-real-session-report.ts +58 -0
  367. package/scripts/build-adapter-session-status.ts +42 -0
  368. package/scripts/build-consumer-startup-failure-support-bundle.ts +22 -0
  369. package/scripts/build-consumer-startup-triage-arg-flags-lib.ts +26 -0
  370. package/scripts/build-consumer-startup-triage-arg-values-lib.ts +45 -0
  371. package/scripts/build-consumer-startup-triage-args-lib.ts +59 -0
  372. package/scripts/build-consumer-startup-triage-contract.ts +25 -0
  373. package/scripts/build-consumer-startup-triage-runner-lib.ts +59 -0
  374. package/scripts/build-consumer-startup-triage.ts +58 -0
  375. package/scripts/build-consumer-startup-unblock-status.ts +34 -0
  376. package/scripts/build-consumer-support-ticket-draft.ts +32 -0
  377. package/scripts/build-mock-consumer-ab-report.ts +34 -0
  378. package/scripts/build-mock-consumer-startup-triage.ts +71 -0
  379. package/scripts/build-phase5-blockers-readiness.ts +69 -0
  380. package/scripts/build-phase5-execution-closure-status-output-lib.ts +22 -0
  381. package/scripts/build-phase5-execution-closure-status-runner-lib.ts +61 -0
  382. package/scripts/build-phase5-execution-closure-status.ts +35 -0
  383. package/scripts/build-phase5-external-handoff-arg-flags-lib.ts +21 -0
  384. package/scripts/build-phase5-external-handoff-arg-handlers-lib.ts +48 -0
  385. package/scripts/build-phase5-external-handoff-arg-values-lib.ts +59 -0
  386. package/scripts/build-phase5-external-handoff-args-lib.ts +25 -0
  387. package/scripts/build-phase5-external-handoff-contract.ts +39 -0
  388. package/scripts/build-phase5-external-handoff-inputs-lib.ts +86 -0
  389. package/scripts/build-phase5-external-handoff.ts +71 -0
  390. package/scripts/build-phase5-support-portal-payload.sh +67 -0
  391. package/scripts/build-phase8-ready-handoff-summary.sh +66 -0
  392. package/scripts/check-consumer-ci-auth.ts +64 -0
  393. package/scripts/check-package-manifest.ts +54 -0
  394. package/scripts/check-phase5-escalation-ready-to-submit.sh +74 -0
  395. package/scripts/check-phase5-latest-ready-chain.sh +44 -0
  396. package/scripts/check-phase8-loop-guard-coverage.sh +44 -0
  397. package/scripts/check-phase8-loop-guard.sh +81 -0
  398. package/scripts/check-refactor-progress-single-active.sh +25 -0
  399. package/scripts/check-validation-docs-hygiene.ts +42 -0
  400. package/scripts/clean-validation-artifacts-cli-lib.ts +38 -0
  401. package/scripts/clean-validation-artifacts-lib.ts +64 -0
  402. package/scripts/clean-validation-artifacts-output-lib.ts +21 -0
  403. package/scripts/clean-validation-artifacts.ts +42 -0
  404. package/scripts/close-phase5-escalation-submission.sh +81 -0
  405. package/scripts/collect-consumer-ci-artifacts-args-lib.ts +61 -0
  406. package/scripts/collect-consumer-ci-artifacts-contract.ts +54 -0
  407. package/scripts/collect-consumer-ci-artifacts-gh-command-lib.ts +17 -0
  408. package/scripts/collect-consumer-ci-artifacts-gh-fetch-lib.ts +45 -0
  409. package/scripts/collect-consumer-ci-artifacts-gh-lib.ts +5 -0
  410. package/scripts/collect-consumer-ci-artifacts-gh-run-fetch-lib.ts +56 -0
  411. package/scripts/collect-consumer-ci-artifacts-markdown-lib.ts +69 -0
  412. package/scripts/collect-consumer-ci-artifacts.ts +30 -0
  413. package/scripts/compile-skills-lock-args-lib.ts +53 -0
  414. package/scripts/compile-skills-lock-runner-lib.ts +48 -0
  415. package/scripts/compile-skills-lock.ts +9 -0
  416. package/scripts/consumer-ci-auth-check-contract.ts +39 -0
  417. package/scripts/consumer-ci-auth-check-gh-lib.ts +54 -0
  418. package/scripts/consumer-ci-auth-check-lib.ts +15 -0
  419. package/scripts/consumer-ci-auth-check-markdown-header-status-lib.ts +32 -0
  420. package/scripts/consumer-ci-auth-check-markdown-json-lib.ts +19 -0
  421. package/scripts/consumer-ci-auth-check-markdown-lib.ts +30 -0
  422. package/scripts/consumer-ci-auth-check-markdown-remediation-lib.ts +36 -0
  423. package/scripts/consumer-ci-auth-check-markdown-sections-lib.ts +6 -0
  424. package/scripts/consumer-ci-auth-check-parse-lib.ts +65 -0
  425. package/scripts/consumer-startup-failure-support-bundle-lib.ts +58 -0
  426. package/scripts/consumer-startup-triage-command-builders-core-lib.ts +5 -0
  427. package/scripts/consumer-startup-triage-command-builders-core-required-lib.ts +40 -0
  428. package/scripts/consumer-startup-triage-command-builders-lib.ts +10 -0
  429. package/scripts/consumer-startup-triage-command-builders-support-bundle-lib.ts +26 -0
  430. package/scripts/consumer-startup-triage-command-builders-support-followup-lib.ts +53 -0
  431. package/scripts/consumer-startup-triage-command-builders-support-lib.ts +5 -0
  432. package/scripts/consumer-startup-triage-command-builders-workflow-lint-lib.ts +45 -0
  433. package/scripts/consumer-startup-triage-commands-lib.ts +64 -0
  434. package/scripts/consumer-startup-triage-contract.ts +41 -0
  435. package/scripts/consumer-startup-triage-lib.ts +9 -0
  436. package/scripts/consumer-startup-triage-markdown-lib.ts +63 -0
  437. package/scripts/consumer-startup-triage-outputs-lib.ts +19 -0
  438. package/scripts/consumer-startup-unblock-arg-setters-lib.ts +34 -0
  439. package/scripts/consumer-startup-unblock-args-contract.ts +17 -0
  440. package/scripts/consumer-startup-unblock-args-defaults-lib.ts +17 -0
  441. package/scripts/consumer-startup-unblock-args-lib.ts +49 -0
  442. package/scripts/consumer-startup-unblock-auth-lib.ts +16 -0
  443. package/scripts/consumer-startup-unblock-blockers-lib.ts +65 -0
  444. package/scripts/consumer-startup-unblock-cli-lib.ts +10 -0
  445. package/scripts/consumer-startup-unblock-contract.ts +42 -0
  446. package/scripts/consumer-startup-unblock-input-lib.ts +17 -0
  447. package/scripts/consumer-startup-unblock-markdown-lib.ts +47 -0
  448. package/scripts/consumer-startup-unblock-markdown-next-actions-lib.ts +37 -0
  449. package/scripts/consumer-startup-unblock-markdown-sections-lib.ts +53 -0
  450. package/scripts/consumer-startup-unblock-parser-lib.ts +24 -0
  451. package/scripts/consumer-startup-unblock-runner-lib.ts +69 -0
  452. package/scripts/consumer-startup-unblock-status-lib.ts +7 -0
  453. package/scripts/consumer-startup-unblock-summary-lib.ts +54 -0
  454. package/scripts/consumer-support-bundle-args-defaults-lib.ts +11 -0
  455. package/scripts/consumer-support-bundle-args-values-lib.ts +27 -0
  456. package/scripts/consumer-support-bundle-contract.ts +61 -0
  457. package/scripts/consumer-support-bundle-gh-auth-repo-lib.ts +51 -0
  458. package/scripts/consumer-support-bundle-gh-command-lib.ts +63 -0
  459. package/scripts/consumer-support-bundle-gh-diagnostics-collector-lib.ts +66 -0
  460. package/scripts/consumer-support-bundle-gh-diagnostics-fetch-lib.ts +36 -0
  461. package/scripts/consumer-support-bundle-gh-lib.ts +8 -0
  462. package/scripts/consumer-support-bundle-gh-loaders-lib.ts +7 -0
  463. package/scripts/consumer-support-bundle-gh-workflow-runs-lib.ts +30 -0
  464. package/scripts/consumer-support-bundle-markdown-context-lib.ts +49 -0
  465. package/scripts/consumer-support-bundle-markdown-lib.ts +44 -0
  466. package/scripts/consumer-support-bundle-markdown-run-sections-append-lib.ts +47 -0
  467. package/scripts/consumer-support-bundle-markdown-sections-append-lib.ts +51 -0
  468. package/scripts/consumer-support-bundle-markdown-sections-core-lib.ts +67 -0
  469. package/scripts/consumer-support-bundle-markdown-sections-lib.ts +7 -0
  470. package/scripts/consumer-support-bundle-markdown-sections-run-diagnostics-lib.ts +34 -0
  471. package/scripts/consumer-support-bundle-markdown-sections-support-payload-lib.ts +60 -0
  472. package/scripts/consumer-support-bundle-markdown-top-sections-append-lib.ts +55 -0
  473. package/scripts/consumer-support-bundle-markdown-top-sections-lib.ts +51 -0
  474. package/scripts/consumer-support-bundle-runner-lib.ts +49 -0
  475. package/scripts/consumer-support-ticket-cli-arg-setters-lib.ts +30 -0
  476. package/scripts/consumer-support-ticket-cli-contract.ts +14 -0
  477. package/scripts/consumer-support-ticket-cli-defaults-lib.ts +14 -0
  478. package/scripts/consumer-support-ticket-cli-lib.ts +63 -0
  479. package/scripts/consumer-support-ticket-draft-diagnostics-sections-lib.ts +67 -0
  480. package/scripts/consumer-support-ticket-draft-lib.ts +36 -0
  481. package/scripts/consumer-support-ticket-draft-primary-sections-lib.ts +51 -0
  482. package/scripts/consumer-support-ticket-draft-sections-lib.ts +10 -0
  483. package/scripts/consumer-support-ticket-lib.ts +3 -0
  484. package/scripts/consumer-support-ticket-parser-lib.ts +72 -0
  485. package/scripts/consumer-support-ticket-runner-lib.ts +42 -0
  486. package/scripts/consumer-workflow-lint-args-lib.ts +56 -0
  487. package/scripts/consumer-workflow-lint-command-lib.ts +60 -0
  488. package/scripts/consumer-workflow-lint-contract.ts +14 -0
  489. package/scripts/consumer-workflow-lint-markdown-lib.ts +39 -0
  490. package/scripts/consumer-workflow-lint-runner-lib.ts +52 -0
  491. package/scripts/fill-adapter-external-ide-replay-closeout.sh +90 -0
  492. package/scripts/framework-menu-action-contract.ts +17 -0
  493. package/scripts/framework-menu-actions-diagnostics-adapter-lib.ts +31 -0
  494. package/scripts/framework-menu-actions-diagnostics-ci-lib.ts +40 -0
  495. package/scripts/framework-menu-actions-diagnostics-maintenance-lib.ts +22 -0
  496. package/scripts/framework-menu-actions-diagnostics-support-core-lib.ts +40 -0
  497. package/scripts/framework-menu-actions-diagnostics-support-lib.ts +15 -0
  498. package/scripts/framework-menu-actions-diagnostics-support-triage-lib.ts +28 -0
  499. package/scripts/framework-menu-actions-diagnostics.ts +19 -0
  500. package/scripts/framework-menu-actions-gates-ci-lib.ts +30 -0
  501. package/scripts/framework-menu-actions-gates-stage-lib.ts +32 -0
  502. package/scripts/framework-menu-actions-gates-tools-lib.ts +26 -0
  503. package/scripts/framework-menu-actions-gates.ts +17 -0
  504. package/scripts/framework-menu-actions-phase5-exec-lib.ts +32 -0
  505. package/scripts/framework-menu-actions-phase5-exit-lib.ts +16 -0
  506. package/scripts/framework-menu-actions-phase5-reports-lib.ts +49 -0
  507. package/scripts/framework-menu-actions-phase5.ts +17 -0
  508. package/scripts/framework-menu-actions.ts +22 -0
  509. package/scripts/framework-menu-builders-adapter.ts +29 -0
  510. package/scripts/framework-menu-builders-consumer-contract.ts +19 -0
  511. package/scripts/framework-menu-builders-consumer-mock-ab-lib.ts +22 -0
  512. package/scripts/framework-menu-builders-consumer-triage-lib.ts +31 -0
  513. package/scripts/framework-menu-builders-consumer.ts +6 -0
  514. package/scripts/framework-menu-builders-maintenance.ts +24 -0
  515. package/scripts/framework-menu-builders-phase5-blockers-lib.ts +16 -0
  516. package/scripts/framework-menu-builders-phase5-closure-lib.ts +46 -0
  517. package/scripts/framework-menu-builders-phase5-contract.ts +43 -0
  518. package/scripts/framework-menu-builders-phase5-handoff-lib.ts +38 -0
  519. package/scripts/framework-menu-builders-phase5-status-lib.ts +24 -0
  520. package/scripts/framework-menu-builders-phase5.ts +12 -0
  521. package/scripts/framework-menu-builders-shared-lib.ts +3 -0
  522. package/scripts/framework-menu-builders.ts +19 -0
  523. package/scripts/framework-menu-gate-lib.ts +53 -0
  524. package/scripts/framework-menu-prompt-types.ts +12 -0
  525. package/scripts/framework-menu-prompts-adapter.ts +50 -0
  526. package/scripts/framework-menu-prompts-consumer-ci-lib.ts +36 -0
  527. package/scripts/framework-menu-prompts-consumer-contract.ts +46 -0
  528. package/scripts/framework-menu-prompts-consumer-startup-triage-lib.ts +69 -0
  529. package/scripts/framework-menu-prompts-consumer-support-bundle-lib.ts +20 -0
  530. package/scripts/framework-menu-prompts-consumer-support-ticket-lib.ts +27 -0
  531. package/scripts/framework-menu-prompts-consumer-unblock-status-lib.ts +33 -0
  532. package/scripts/framework-menu-prompts-consumer-workflow-lint-lib.ts +27 -0
  533. package/scripts/framework-menu-prompts-consumer.ts +26 -0
  534. package/scripts/framework-menu-prompts-phase5-blockers-lib.ts +24 -0
  535. package/scripts/framework-menu-prompts-phase5-closure-lib.ts +17 -0
  536. package/scripts/framework-menu-prompts-phase5-closure-live-lib.ts +51 -0
  537. package/scripts/framework-menu-prompts-phase5-closure-mock-lib.ts +23 -0
  538. package/scripts/framework-menu-prompts-phase5-closure-shared-lib.ts +24 -0
  539. package/scripts/framework-menu-prompts-phase5-contract.ts +48 -0
  540. package/scripts/framework-menu-prompts-phase5-handoff-lib.ts +54 -0
  541. package/scripts/framework-menu-prompts-phase5-mock-ab-lib.ts +36 -0
  542. package/scripts/framework-menu-prompts-phase5-status-lib.ts +31 -0
  543. package/scripts/framework-menu-prompts-phase5.ts +16 -0
  544. package/scripts/framework-menu-prompts.ts +32 -0
  545. package/scripts/framework-menu-runner-common.ts +13 -0
  546. package/scripts/framework-menu-runner-constants.ts +3 -0
  547. package/scripts/framework-menu-runner-evidence-lib.ts +14 -0
  548. package/scripts/framework-menu-runner-git-lib.ts +13 -0
  549. package/scripts/framework-menu-runner-path-lib.ts +12 -0
  550. package/scripts/framework-menu-runner-process-lib.ts +27 -0
  551. package/scripts/framework-menu-runners-adapter-contract.ts +13 -0
  552. package/scripts/framework-menu-runners-adapter-readiness-lib.ts +20 -0
  553. package/scripts/framework-menu-runners-adapter-real-session-lib.ts +20 -0
  554. package/scripts/framework-menu-runners-adapter-session-lib.ts +19 -0
  555. package/scripts/framework-menu-runners-adapter.ts +9 -0
  556. package/scripts/framework-menu-runners-consumer-artifacts-lib.ts +11 -0
  557. package/scripts/framework-menu-runners-consumer-auth-lib.ts +11 -0
  558. package/scripts/framework-menu-runners-consumer-contract.ts +55 -0
  559. package/scripts/framework-menu-runners-consumer-exec-lib.ts +13 -0
  560. package/scripts/framework-menu-runners-consumer-mock-ab-lib.ts +24 -0
  561. package/scripts/framework-menu-runners-consumer-startup-triage-lib.ts +24 -0
  562. package/scripts/framework-menu-runners-consumer-support-bundle-lib.ts +11 -0
  563. package/scripts/framework-menu-runners-consumer-support-ticket-lib.ts +20 -0
  564. package/scripts/framework-menu-runners-consumer-unblock-lib.ts +22 -0
  565. package/scripts/framework-menu-runners-consumer-workflow-lib.ts +18 -0
  566. package/scripts/framework-menu-runners-consumer.ts +21 -0
  567. package/scripts/framework-menu-runners-phase5-blockers-lib.ts +18 -0
  568. package/scripts/framework-menu-runners-phase5-closure-lib.ts +25 -0
  569. package/scripts/framework-menu-runners-phase5-contract.ts +39 -0
  570. package/scripts/framework-menu-runners-phase5-exec-lib.ts +25 -0
  571. package/scripts/framework-menu-runners-phase5-handoff-lib.ts +25 -0
  572. package/scripts/framework-menu-runners-phase5-status-lib.ts +20 -0
  573. package/scripts/framework-menu-runners-phase5.ts +12 -0
  574. package/scripts/framework-menu-runners-validation-cleanup-lib.ts +31 -0
  575. package/scripts/framework-menu-runners-validation-docs-lib.ts +20 -0
  576. package/scripts/framework-menu-runners-validation-skills-lib.ts +11 -0
  577. package/scripts/framework-menu-runners-validation.ts +4 -0
  578. package/scripts/framework-menu-runners.ts +37 -0
  579. package/scripts/framework-menu-skills-lib.ts +26 -0
  580. package/scripts/framework-menu.cli.ts +3 -0
  581. package/scripts/framework-menu.ts +67 -0
  582. package/scripts/lint-consumer-workflows.ts +29 -0
  583. package/scripts/mark-phase5-escalation-submitted.sh +49 -0
  584. package/scripts/mark-phase8-followup-posted-now.sh +33 -0
  585. package/scripts/mark-phase8-followup-replied-now.sh +52 -0
  586. package/scripts/mark-phase8-support-followup-state.sh +89 -0
  587. package/scripts/mock-consumer-ab-blockers-lib.ts +36 -0
  588. package/scripts/mock-consumer-ab-cli-arg-setters-lib.ts +46 -0
  589. package/scripts/mock-consumer-ab-cli-defaults-lib.ts +19 -0
  590. package/scripts/mock-consumer-ab-cli-lib.ts +46 -0
  591. package/scripts/mock-consumer-ab-contract.ts +30 -0
  592. package/scripts/mock-consumer-ab-evidence-lib.ts +50 -0
  593. package/scripts/mock-consumer-ab-markdown-assertions-lib.ts +24 -0
  594. package/scripts/mock-consumer-ab-markdown-blockers-lib.ts +9 -0
  595. package/scripts/mock-consumer-ab-markdown-contract.ts +16 -0
  596. package/scripts/mock-consumer-ab-markdown-header-inputs-lib.ts +21 -0
  597. package/scripts/mock-consumer-ab-markdown-lib.ts +24 -0
  598. package/scripts/mock-consumer-ab-markdown-next-actions-lib.ts +22 -0
  599. package/scripts/mock-consumer-ab-markdown-sections-lib.ts +21 -0
  600. package/scripts/mock-consumer-ab-report-lib.ts +12 -0
  601. package/scripts/mock-consumer-ab-runner-lib.ts +51 -0
  602. package/scripts/mock-consumer-smoke-contract.ts +14 -0
  603. package/scripts/mock-consumer-smoke-lib.ts +3 -0
  604. package/scripts/mock-consumer-smoke-summary-lib.ts +59 -0
  605. package/scripts/mock-consumer-smoke-verdict-lib.ts +27 -0
  606. package/scripts/mock-consumer-startup-triage-arg-flags-lib.ts +13 -0
  607. package/scripts/mock-consumer-startup-triage-arg-values-lib.ts +35 -0
  608. package/scripts/mock-consumer-startup-triage-cli-contract.ts +7 -0
  609. package/scripts/mock-consumer-startup-triage-cli-lib.ts +56 -0
  610. package/scripts/mock-consumer-startup-triage-lib.ts +2 -0
  611. package/scripts/mock-consumer-startup-triage-markdown-lib.ts +57 -0
  612. package/scripts/mock-consumer-startup-unblock-markdown-lib.ts +38 -0
  613. package/scripts/package-install-smoke-command-lib.ts +67 -0
  614. package/scripts/package-install-smoke-consumer-git-lib.ts +10 -0
  615. package/scripts/package-install-smoke-consumer-git-payload-lib.ts +45 -0
  616. package/scripts/package-install-smoke-consumer-git-repo-lib.ts +49 -0
  617. package/scripts/package-install-smoke-consumer-npm-lib.ts +47 -0
  618. package/scripts/package-install-smoke-consumer-repo-setup-lib.ts +31 -0
  619. package/scripts/package-install-smoke-contract.ts +6 -0
  620. package/scripts/package-install-smoke-execution-lib.ts +73 -0
  621. package/scripts/package-install-smoke-execution-steps-lib.ts +46 -0
  622. package/scripts/package-install-smoke-execution-summary-lib.ts +51 -0
  623. package/scripts/package-install-smoke-file-lib.ts +33 -0
  624. package/scripts/package-install-smoke-fixtures-content-lib.ts +57 -0
  625. package/scripts/package-install-smoke-fixtures-lib.ts +41 -0
  626. package/scripts/package-install-smoke-fixtures-write-lib.ts +14 -0
  627. package/scripts/package-install-smoke-gate-lib.ts +64 -0
  628. package/scripts/package-install-smoke-lib.ts +3 -0
  629. package/scripts/package-install-smoke-lifecycle-lib.ts +91 -0
  630. package/scripts/package-install-smoke-mode-lib.ts +31 -0
  631. package/scripts/package-install-smoke-repo-setup-lib.ts +2 -0
  632. package/scripts/package-install-smoke-runner-common.ts +12 -0
  633. package/scripts/package-install-smoke-tarball-lib.ts +34 -0
  634. package/scripts/package-install-smoke-workspace-contract.ts +11 -0
  635. package/scripts/package-install-smoke-workspace-factory-lib.ts +38 -0
  636. package/scripts/package-install-smoke-workspace-lib.ts +7 -0
  637. package/scripts/package-install-smoke-workspace-report-lib.ts +44 -0
  638. package/scripts/package-install-smoke.ts +7 -0
  639. package/scripts/package-manifest-lib.ts +44 -0
  640. package/scripts/phase5-blockers-contract.ts +36 -0
  641. package/scripts/phase5-blockers-detected-blockers-lib.ts +35 -0
  642. package/scripts/phase5-blockers-markdown-header-inputs-signals-lib.ts +48 -0
  643. package/scripts/phase5-blockers-markdown-lib.ts +51 -0
  644. package/scripts/phase5-blockers-markdown-list-utils-lib.ts +13 -0
  645. package/scripts/phase5-blockers-markdown-next-actions-blocked-lib.ts +46 -0
  646. package/scripts/phase5-blockers-markdown-next-actions-lib.ts +29 -0
  647. package/scripts/phase5-blockers-markdown-next-actions-ready-lib.ts +13 -0
  648. package/scripts/phase5-blockers-markdown-sections-lib.ts +7 -0
  649. package/scripts/phase5-blockers-markdown-static-sections-lib.ts +26 -0
  650. package/scripts/phase5-blockers-missing-inputs-lib.ts +16 -0
  651. package/scripts/phase5-blockers-parser-adapter-lib.ts +44 -0
  652. package/scripts/phase5-blockers-parser-consumer-lib.ts +32 -0
  653. package/scripts/phase5-blockers-parser-lib.ts +2 -0
  654. package/scripts/phase5-blockers-readiness-arg-flags-lib.ts +13 -0
  655. package/scripts/phase5-blockers-readiness-arg-values-lib.ts +27 -0
  656. package/scripts/phase5-blockers-readiness-cli-contract.ts +6 -0
  657. package/scripts/phase5-blockers-readiness-cli-lib.ts +55 -0
  658. package/scripts/phase5-blockers-readiness-input-lib.ts +17 -0
  659. package/scripts/phase5-blockers-readiness-lib.ts +8 -0
  660. package/scripts/phase5-blockers-summary-lib.ts +48 -0
  661. package/scripts/phase5-execution-closure-commands-lib.ts +32 -0
  662. package/scripts/phase5-execution-closure-lib.ts +2 -0
  663. package/scripts/phase5-execution-closure-outputs-lib.ts +25 -0
  664. package/scripts/phase5-execution-closure-plan-adapter-commands-lib.ts +41 -0
  665. package/scripts/phase5-execution-closure-plan-adapter-lib.ts +25 -0
  666. package/scripts/phase5-execution-closure-plan-consumer-lib.ts +5 -0
  667. package/scripts/phase5-execution-closure-plan-consumer-preflight-lib.ts +58 -0
  668. package/scripts/phase5-execution-closure-plan-consumer-triage-lib.ts +62 -0
  669. package/scripts/phase5-execution-closure-plan-contract.ts +42 -0
  670. package/scripts/phase5-execution-closure-plan-lib.ts +7 -0
  671. package/scripts/phase5-execution-closure-plan-phase5-args-lib.ts +52 -0
  672. package/scripts/phase5-execution-closure-plan-phase5-lib.ts +37 -0
  673. package/scripts/phase5-execution-closure-plan-validation-lib.ts +15 -0
  674. package/scripts/phase5-execution-closure-report-contract.ts +22 -0
  675. package/scripts/phase5-execution-closure-report-executions-lib.ts +35 -0
  676. package/scripts/phase5-execution-closure-report-header-lib.ts +38 -0
  677. package/scripts/phase5-execution-closure-report-lib.ts +31 -0
  678. package/scripts/phase5-execution-closure-report-next-actions-lib.ts +19 -0
  679. package/scripts/phase5-execution-closure-report-sections-lib.ts +51 -0
  680. package/scripts/phase5-execution-closure-runner-arg-flags-lib.ts +32 -0
  681. package/scripts/phase5-execution-closure-runner-arg-handlers-lib.ts +33 -0
  682. package/scripts/phase5-execution-closure-runner-arg-value-handlers-lib.ts +62 -0
  683. package/scripts/phase5-execution-closure-runner-arg-values-lib.ts +39 -0
  684. package/scripts/phase5-execution-closure-runner-contract.ts +31 -0
  685. package/scripts/phase5-execution-closure-runner-exec-command-lib.ts +20 -0
  686. package/scripts/phase5-execution-closure-runner-exec-error-lib.ts +32 -0
  687. package/scripts/phase5-execution-closure-runner-exec-lib.ts +35 -0
  688. package/scripts/phase5-execution-closure-runner-lib.ts +8 -0
  689. package/scripts/phase5-execution-closure-runner-mappers-lib.ts +30 -0
  690. package/scripts/phase5-execution-closure-runner-options-normalizer-lib.ts +19 -0
  691. package/scripts/phase5-execution-closure-runner-parse-lib.ts +23 -0
  692. package/scripts/phase5-execution-closure-runner-plan-lib.ts +14 -0
  693. package/scripts/phase5-execution-closure-runner-report-writer-lib.ts +12 -0
  694. package/scripts/phase5-execution-closure-status-arg-flags-lib.ts +13 -0
  695. package/scripts/phase5-execution-closure-status-arg-values-lib.ts +35 -0
  696. package/scripts/phase5-execution-closure-status-blockers-lib.ts +47 -0
  697. package/scripts/phase5-execution-closure-status-cli-contract.ts +24 -0
  698. package/scripts/phase5-execution-closure-status-cli-input-lib.ts +17 -0
  699. package/scripts/phase5-execution-closure-status-cli-lib.ts +10 -0
  700. package/scripts/phase5-execution-closure-status-cli-parse-lib.ts +59 -0
  701. package/scripts/phase5-execution-closure-status-contract.ts +48 -0
  702. package/scripts/phase5-execution-closure-status-lib.ts +8 -0
  703. package/scripts/phase5-execution-closure-status-markdown-lib.ts +22 -0
  704. package/scripts/phase5-execution-closure-status-markdown-list-lib.ts +16 -0
  705. package/scripts/phase5-execution-closure-status-markdown-next-actions-lib.ts +24 -0
  706. package/scripts/phase5-execution-closure-status-markdown-sections-lib.ts +7 -0
  707. package/scripts/phase5-execution-closure-status-markdown-static-sections-lib.ts +58 -0
  708. package/scripts/phase5-execution-closure-status-missing-inputs-lib.ts +19 -0
  709. package/scripts/phase5-execution-closure-status-parser-lib.ts +4 -0
  710. package/scripts/phase5-execution-closure-status-summary-helpers-lib.ts +6 -0
  711. package/scripts/phase5-execution-closure-status-summary-lib.ts +34 -0
  712. package/scripts/phase5-execution-closure-status-verdict-lib.ts +11 -0
  713. package/scripts/phase5-external-handoff-contract.ts +51 -0
  714. package/scripts/phase5-external-handoff-inputs-artifacts-lib.ts +45 -0
  715. package/scripts/phase5-external-handoff-lib.ts +3 -0
  716. package/scripts/phase5-external-handoff-markdown-core-sections-lib.ts +70 -0
  717. package/scripts/phase5-external-handoff-markdown-header-lib.ts +15 -0
  718. package/scripts/phase5-external-handoff-markdown-lib.ts +44 -0
  719. package/scripts/phase5-external-handoff-markdown-list-lib.ts +16 -0
  720. package/scripts/phase5-external-handoff-markdown-list-sections-lib.ts +54 -0
  721. package/scripts/phase5-external-handoff-markdown-next-actions-lib.ts +27 -0
  722. package/scripts/phase5-external-handoff-markdown-sections-append-lib.ts +69 -0
  723. package/scripts/phase5-external-handoff-markdown-sections-lib.ts +12 -0
  724. package/scripts/phase5-external-handoff-summary-helpers-lib.ts +9 -0
  725. package/scripts/phase5-external-handoff-summary-lib.ts +46 -0
  726. package/scripts/phase5-external-handoff-verdict-evaluators-lib.ts +67 -0
  727. package/scripts/prepare-adapter-external-ide-replay-closeout-auto.sh +100 -0
  728. package/scripts/prepare-phase5-escalation-submission.sh +21 -0
  729. package/scripts/refresh-phase5-latest-escalation.sh +94 -0
  730. package/scripts/run-phase5-execution-closure.ts +58 -0
  731. package/scripts/run-phase5-post-support-refresh.sh +25 -0
  732. package/scripts/run-phase8-after-billing-reactivation.sh +31 -0
  733. package/scripts/run-phase8-autopilot.sh +42 -0
  734. package/scripts/run-phase8-close-ready.sh +38 -0
  735. package/scripts/run-phase8-doctor.sh +61 -0
  736. package/scripts/run-phase8-next-step.sh +39 -0
  737. package/scripts/run-phase8-status-pack.sh +35 -0
  738. package/scripts/run-phase8-tick.sh +35 -0
  739. package/scripts/sync-codex-skills.sh +40 -0
  740. package/scripts/sync-phase5-latest-docs.sh +119 -0
  741. package/scripts/validation-docs-hygiene-lib.ts +46 -0
  742. package/skills.lock.json +178 -0
  743. package/skills.sources.json +33 -0
  744. package/tsconfig.json +39 -0
@@ -0,0 +1,52 @@
1
+ import assert from 'node:assert/strict';
2
+ import test from 'node:test';
3
+ import type { Finding } from './Finding';
4
+
5
+ test('Finding conserva campos requeridos y filePath opcional', () => {
6
+ const findingWithPath: Finding = {
7
+ ruleId: 'heuristics.ts.console-log.ast',
8
+ severity: 'WARN',
9
+ code: 'HEURISTICS_CONSOLE_LOG_AST',
10
+ message: 'AST heuristic detected console.log usage.',
11
+ filePath: 'apps/backend/src/main.ts',
12
+ };
13
+ const findingWithoutPath: Finding = {
14
+ ruleId: 'gate.summary',
15
+ severity: 'INFO',
16
+ code: 'GATE_SUMMARY',
17
+ message: 'Gate executed.',
18
+ };
19
+
20
+ assert.equal(findingWithPath.ruleId, 'heuristics.ts.console-log.ast');
21
+ assert.equal(findingWithPath.severity, 'WARN');
22
+ assert.equal(findingWithPath.filePath, 'apps/backend/src/main.ts');
23
+ assert.equal(findingWithoutPath.filePath, undefined);
24
+ });
25
+
26
+ test('Finding permite representar severidades distintas', () => {
27
+ const findings: Finding[] = [
28
+ {
29
+ ruleId: 'rule.info',
30
+ severity: 'INFO',
31
+ code: 'RULE_INFO',
32
+ message: 'Info finding',
33
+ },
34
+ {
35
+ ruleId: 'rule.error',
36
+ severity: 'ERROR',
37
+ code: 'RULE_ERROR',
38
+ message: 'Error finding',
39
+ },
40
+ {
41
+ ruleId: 'rule.critical',
42
+ severity: 'CRITICAL',
43
+ code: 'RULE_CRITICAL',
44
+ message: 'Critical finding',
45
+ },
46
+ ];
47
+
48
+ assert.deepEqual(
49
+ findings.map((finding) => finding.severity),
50
+ ['INFO', 'ERROR', 'CRITICAL']
51
+ );
52
+ });
@@ -0,0 +1,9 @@
1
+ import type { Severity } from '../rules/Severity';
2
+
3
+ export type Finding = {
4
+ ruleId: string;
5
+ severity: Severity;
6
+ code: string;
7
+ message: string;
8
+ filePath?: string;
9
+ };
@@ -0,0 +1,20 @@
1
+ import assert from 'node:assert/strict';
2
+ import test from 'node:test';
3
+ import type { GateOutcome } from './GateOutcome';
4
+
5
+ test('GateOutcome soporta PASS, WARN y BLOCK', () => {
6
+ const passOutcome: GateOutcome = 'PASS';
7
+ const warnOutcome: GateOutcome = 'WARN';
8
+ const blockOutcome: GateOutcome = 'BLOCK';
9
+
10
+ assert.equal(passOutcome, 'PASS');
11
+ assert.equal(warnOutcome, 'WARN');
12
+ assert.equal(blockOutcome, 'BLOCK');
13
+ });
14
+
15
+ test('GateOutcome permite colecciones de outcomes tipados', () => {
16
+ const outcomes: GateOutcome[] = ['PASS', 'WARN', 'BLOCK'];
17
+
18
+ assert.equal(outcomes.length, 3);
19
+ assert.deepEqual(outcomes, ['PASS', 'WARN', 'BLOCK']);
20
+ });
@@ -0,0 +1 @@
1
+ export type GateOutcome = 'PASS' | 'WARN' | 'BLOCK';
@@ -0,0 +1,28 @@
1
+ import assert from 'node:assert/strict';
2
+ import test from 'node:test';
3
+ import type { GatePolicy } from './GatePolicy';
4
+
5
+ test('GatePolicy conserva stage, blockOnOrAbove y warnOnOrAbove', () => {
6
+ const policy: GatePolicy = {
7
+ stage: 'PRE_PUSH',
8
+ blockOnOrAbove: 'ERROR',
9
+ warnOnOrAbove: 'WARN',
10
+ };
11
+
12
+ assert.equal(policy.stage, 'PRE_PUSH');
13
+ assert.equal(policy.blockOnOrAbove, 'ERROR');
14
+ assert.equal(policy.warnOnOrAbove, 'WARN');
15
+ assert.equal(policy.defaultSeverity, undefined);
16
+ });
17
+
18
+ test('GatePolicy permite defaultSeverity opcional', () => {
19
+ const policy: GatePolicy = {
20
+ stage: 'CI',
21
+ blockOnOrAbove: 'ERROR',
22
+ warnOnOrAbove: 'WARN',
23
+ defaultSeverity: 'INFO',
24
+ };
25
+
26
+ assert.equal(policy.stage, 'CI');
27
+ assert.equal(policy.defaultSeverity, 'INFO');
28
+ });
@@ -0,0 +1,9 @@
1
+ import type { Severity } from '../rules/Severity';
2
+ import type { GateStage } from './GateStage';
3
+
4
+ export type GatePolicy = {
5
+ stage: GateStage;
6
+ blockOnOrAbove: Severity;
7
+ warnOnOrAbove: Severity;
8
+ defaultSeverity?: Severity;
9
+ };
@@ -0,0 +1,22 @@
1
+ import assert from 'node:assert/strict';
2
+ import test from 'node:test';
3
+ import type { GateStage } from './GateStage';
4
+
5
+ test('GateStage soporta STAGED, PRE_COMMIT, PRE_PUSH y CI', () => {
6
+ const staged: GateStage = 'STAGED';
7
+ const preCommit: GateStage = 'PRE_COMMIT';
8
+ const prePush: GateStage = 'PRE_PUSH';
9
+ const ci: GateStage = 'CI';
10
+
11
+ assert.equal(staged, 'STAGED');
12
+ assert.equal(preCommit, 'PRE_COMMIT');
13
+ assert.equal(prePush, 'PRE_PUSH');
14
+ assert.equal(ci, 'CI');
15
+ });
16
+
17
+ test('GateStage permite colecciones tipadas de stages', () => {
18
+ const stages: GateStage[] = ['STAGED', 'PRE_COMMIT', 'PRE_PUSH', 'CI'];
19
+
20
+ assert.equal(stages.length, 4);
21
+ assert.deepEqual(stages, ['STAGED', 'PRE_COMMIT', 'PRE_PUSH', 'CI']);
22
+ });
@@ -0,0 +1 @@
1
+ export type GateStage = 'STAGED' | 'PRE_COMMIT' | 'PRE_PUSH' | 'CI';
@@ -0,0 +1,110 @@
1
+ import assert from 'node:assert/strict';
2
+ import test from 'node:test';
3
+ import type { Condition } from '../rules/Condition';
4
+ import { conditionMatches } from './conditionMatches';
5
+
6
+ const facts = [
7
+ {
8
+ kind: 'FileChange',
9
+ path: 'apps/backend/src/main.ts',
10
+ changeType: 'modified',
11
+ source: 'git',
12
+ },
13
+ {
14
+ kind: 'FileContent',
15
+ path: 'apps/backend/src/main.ts',
16
+ content: 'console.log("hello")\nconst token = "abc123";',
17
+ source: 'repo',
18
+ },
19
+ {
20
+ kind: 'Dependency',
21
+ from: 'core/gate/evaluateGate',
22
+ to: 'core/gate/evaluateRules',
23
+ source: 'depcruise',
24
+ },
25
+ {
26
+ kind: 'Heuristic',
27
+ ruleId: 'heuristics.ts.console-log.ast',
28
+ severity: 'WARN',
29
+ code: 'HEURISTICS_CONSOLE_LOG_AST',
30
+ message: 'AST heuristic detected console.log usage.',
31
+ filePath: 'apps/backend/src/main.ts',
32
+ source: 'heuristics:ast',
33
+ },
34
+ ] as const;
35
+
36
+ test('conditionMatches evalua FileChange por prefijo y tipo de cambio', () => {
37
+ const matchingCondition: Condition = {
38
+ kind: 'FileChange',
39
+ where: { pathPrefix: 'apps/backend/', changeType: 'modified' },
40
+ };
41
+ const nonMatchingCondition: Condition = {
42
+ kind: 'FileChange',
43
+ where: { pathPrefix: 'apps/frontend/', changeType: 'modified' },
44
+ };
45
+
46
+ assert.equal(conditionMatches(matchingCondition, facts), true);
47
+ assert.equal(conditionMatches(nonMatchingCondition, facts), false);
48
+ });
49
+
50
+ test('conditionMatches evalua FileContent con contains, regex y scope', () => {
51
+ const condition: Condition = {
52
+ kind: 'FileContent',
53
+ contains: ['console.log', 'token'],
54
+ regex: ['console\\.log\\(', 'token\\s*='],
55
+ };
56
+
57
+ assert.equal(
58
+ conditionMatches(condition, facts, {
59
+ include: ['apps/backend/*'],
60
+ exclude: ['apps/backend/generated/*'],
61
+ }),
62
+ true
63
+ );
64
+ assert.equal(
65
+ conditionMatches(condition, facts, {
66
+ include: ['apps/frontend/*'],
67
+ }),
68
+ false
69
+ );
70
+ });
71
+
72
+ test('conditionMatches evalua Dependency y Heuristic con where', () => {
73
+ const dependencyCondition: Condition = {
74
+ kind: 'Dependency',
75
+ where: { from: 'core/gate/evaluateGate', to: 'core/gate/evaluateRules' },
76
+ };
77
+ const heuristicCondition: Condition = {
78
+ kind: 'Heuristic',
79
+ where: {
80
+ ruleId: 'heuristics.ts.console-log.ast',
81
+ code: 'HEURISTICS_CONSOLE_LOG_AST',
82
+ filePathPrefix: 'apps/backend/',
83
+ },
84
+ };
85
+
86
+ assert.equal(conditionMatches(dependencyCondition, facts), true);
87
+ assert.equal(conditionMatches(heuristicCondition, facts), true);
88
+ });
89
+
90
+ test('conditionMatches soporta condiciones compuestas All, Any y Not', () => {
91
+ const composedCondition: Condition = {
92
+ kind: 'All',
93
+ conditions: [
94
+ { kind: 'FileChange', where: { changeType: 'modified' } },
95
+ {
96
+ kind: 'Any',
97
+ conditions: [
98
+ { kind: 'Dependency', where: { from: 'missing' } },
99
+ { kind: 'Heuristic', where: { code: 'HEURISTICS_CONSOLE_LOG_AST' } },
100
+ ],
101
+ },
102
+ {
103
+ kind: 'Not',
104
+ condition: { kind: 'FileChange', where: { changeType: 'deleted' } },
105
+ },
106
+ ],
107
+ };
108
+
109
+ assert.equal(conditionMatches(composedCondition, facts), true);
110
+ });
@@ -0,0 +1,174 @@
1
+ import type { Condition } from '../rules/Condition';
2
+ import type { RuleDefinition } from '../rules/RuleDefinition';
3
+ import type { Fact } from '../facts/Fact';
4
+ import type { DependencyFact } from '../facts/DependencyFact';
5
+ import type { FileChangeFact } from '../facts/FileChangeFact';
6
+ import type { FileContentFact } from '../facts/FileContentFact';
7
+
8
+ type RuleScope = RuleDefinition['scope'];
9
+
10
+ type FactInput = Fact | FileChangeFact | FileContentFact;
11
+
12
+ type FactMatch = {
13
+ facts: ReadonlyArray<FactInput>;
14
+ scope?: RuleScope;
15
+ };
16
+
17
+ const isFileChangeFact = (fact: FactInput): fact is FileChangeFact =>
18
+ fact.kind === 'FileChange';
19
+
20
+ const isFileContentFact = (fact: FactInput): fact is FileContentFact =>
21
+ fact.kind === 'FileContent';
22
+
23
+ const isDependencyFact = (fact: FactInput): fact is DependencyFact =>
24
+ fact.kind === 'Dependency';
25
+
26
+ const isHeuristicFact = (fact: FactInput): fact is Extract<Fact, { kind: 'Heuristic' }> =>
27
+ fact.kind === 'Heuristic';
28
+
29
+ const extractPrefix = (pattern: string): string => {
30
+ const wildcardIndex = pattern.indexOf('*');
31
+ return wildcardIndex === -1 ? pattern : pattern.slice(0, wildcardIndex);
32
+ };
33
+
34
+ const matchesAnyPrefix = (path: string, patterns: ReadonlyArray<string>): boolean => {
35
+ return patterns.some((pattern) => path.startsWith(extractPrefix(pattern)));
36
+ };
37
+
38
+ const matchesScope = (path: string, scope?: RuleScope): boolean => {
39
+ const include = scope?.include;
40
+ const exclude = scope?.exclude;
41
+ if (exclude && exclude.length > 0 && matchesAnyPrefix(path, exclude)) {
42
+ return false;
43
+ }
44
+ if (!include || include.length === 0) {
45
+ return true;
46
+ }
47
+ return matchesAnyPrefix(path, include);
48
+ };
49
+
50
+ const matchesFileChange = (
51
+ condition: Extract<Condition, { kind: 'FileChange' }>,
52
+ facts: ReadonlyArray<FactInput>
53
+ ): boolean => {
54
+ for (const fact of facts) {
55
+ if (!isFileChangeFact(fact)) {
56
+ continue;
57
+ }
58
+ if (condition.where?.pathPrefix && !fact.path.startsWith(condition.where.pathPrefix)) {
59
+ continue;
60
+ }
61
+ if (condition.where?.changeType && fact.changeType !== condition.where.changeType) {
62
+ continue;
63
+ }
64
+ return true;
65
+ }
66
+ return false;
67
+ };
68
+
69
+ const matchesDependency = (
70
+ condition: Extract<Condition, { kind: 'Dependency' }>,
71
+ facts: ReadonlyArray<FactInput>
72
+ ): boolean => {
73
+ for (const fact of facts) {
74
+ if (!isDependencyFact(fact)) {
75
+ continue;
76
+ }
77
+ if (condition.where?.from && fact.from !== condition.where.from) {
78
+ continue;
79
+ }
80
+ if (condition.where?.to && fact.to !== condition.where.to) {
81
+ continue;
82
+ }
83
+ return true;
84
+ }
85
+ return false;
86
+ };
87
+
88
+ const matchesFileContent = (
89
+ condition: Extract<Condition, { kind: 'FileContent' }>,
90
+ match: FactMatch
91
+ ): boolean => {
92
+ const contains = condition.contains;
93
+ const regex = condition.regex;
94
+
95
+ for (const fact of match.facts) {
96
+ if (!isFileContentFact(fact)) {
97
+ continue;
98
+ }
99
+ if (!matchesScope(fact.path, match.scope)) {
100
+ continue;
101
+ }
102
+ if (contains && contains.length > 0 && !contains.every((token) => fact.content.includes(token))) {
103
+ continue;
104
+ }
105
+ if (regex && regex.length > 0) {
106
+ const matchesAll = regex.every((pattern) => new RegExp(pattern).test(fact.content));
107
+ if (!matchesAll) {
108
+ continue;
109
+ }
110
+ }
111
+ return true;
112
+ }
113
+
114
+ return false;
115
+ };
116
+
117
+ const matchesHeuristic = (
118
+ condition: Extract<Condition, { kind: 'Heuristic' }>,
119
+ facts: ReadonlyArray<FactInput>
120
+ ): boolean => {
121
+ for (const fact of facts) {
122
+ if (!isHeuristicFact(fact)) {
123
+ continue;
124
+ }
125
+ if (condition.where?.ruleId && fact.ruleId !== condition.where.ruleId) {
126
+ continue;
127
+ }
128
+ if (condition.where?.code && fact.code !== condition.where.code) {
129
+ continue;
130
+ }
131
+ if (condition.where?.filePathPrefix) {
132
+ const filePath = fact.filePath ?? '';
133
+ if (!filePath.startsWith(condition.where.filePathPrefix)) {
134
+ continue;
135
+ }
136
+ }
137
+ return true;
138
+ }
139
+ return false;
140
+ };
141
+
142
+ export const conditionMatches = (
143
+ condition: Condition,
144
+ facts: ReadonlyArray<FactInput>,
145
+ scope?: RuleScope
146
+ ): boolean => {
147
+ const match: FactMatch = { facts, scope };
148
+
149
+ if (condition.kind === 'FileChange') {
150
+ return matchesFileChange(condition, facts);
151
+ }
152
+
153
+ if (condition.kind === 'FileContent') {
154
+ return matchesFileContent(condition, match);
155
+ }
156
+
157
+ if (condition.kind === 'Dependency') {
158
+ return matchesDependency(condition, facts);
159
+ }
160
+
161
+ if (condition.kind === 'Heuristic') {
162
+ return matchesHeuristic(condition, facts);
163
+ }
164
+
165
+ if (condition.kind === 'All') {
166
+ return condition.conditions.every((child) => conditionMatches(child, facts, scope));
167
+ }
168
+
169
+ if (condition.kind === 'Any') {
170
+ return condition.conditions.some((child) => conditionMatches(child, facts, scope));
171
+ }
172
+
173
+ return !conditionMatches(condition.condition, facts, scope);
174
+ };
@@ -0,0 +1,77 @@
1
+ import assert from 'node:assert/strict';
2
+ import test from 'node:test';
3
+ import type { Finding } from './Finding';
4
+ import type { GatePolicy } from './GatePolicy';
5
+ import { evaluateGate } from './evaluateGate';
6
+
7
+ const defaultPolicy: GatePolicy = {
8
+ stage: 'CI',
9
+ blockOnOrAbove: 'ERROR',
10
+ warnOnOrAbove: 'WARN',
11
+ };
12
+
13
+ test('evaluateGate devuelve PASS cuando no hay findings', () => {
14
+ const result = evaluateGate([], defaultPolicy);
15
+
16
+ assert.equal(result.outcome, 'PASS');
17
+ assert.deepEqual(result.blocking, []);
18
+ assert.deepEqual(result.warnings, []);
19
+ });
20
+
21
+ test('evaluateGate devuelve WARN cuando hay warnings sin bloqueantes', () => {
22
+ const findings: Finding[] = [
23
+ {
24
+ ruleId: 'rule.warn',
25
+ severity: 'WARN',
26
+ code: 'RULE_WARN',
27
+ message: 'Warn finding',
28
+ },
29
+ {
30
+ ruleId: 'rule.info',
31
+ severity: 'INFO',
32
+ code: 'RULE_INFO',
33
+ message: 'Info finding',
34
+ },
35
+ ];
36
+
37
+ const result = evaluateGate(findings, defaultPolicy);
38
+
39
+ assert.equal(result.outcome, 'WARN');
40
+ assert.equal(result.blocking.length, 0);
41
+ assert.equal(result.warnings.length, 1);
42
+ assert.equal(result.warnings[0]?.ruleId, 'rule.warn');
43
+ });
44
+
45
+ test('evaluateGate devuelve BLOCK cuando existe al menos un finding bloqueante', () => {
46
+ const findings: Finding[] = [
47
+ {
48
+ ruleId: 'rule.error',
49
+ severity: 'ERROR',
50
+ code: 'RULE_ERROR',
51
+ message: 'Error finding',
52
+ },
53
+ {
54
+ ruleId: 'rule.critical',
55
+ severity: 'CRITICAL',
56
+ code: 'RULE_CRITICAL',
57
+ message: 'Critical finding',
58
+ },
59
+ {
60
+ ruleId: 'rule.warn',
61
+ severity: 'WARN',
62
+ code: 'RULE_WARN',
63
+ message: 'Warn finding',
64
+ },
65
+ ];
66
+
67
+ const result = evaluateGate(findings, defaultPolicy);
68
+
69
+ assert.equal(result.outcome, 'BLOCK');
70
+ assert.equal(result.blocking.length, 2);
71
+ assert.deepEqual(
72
+ result.blocking.map((finding) => finding.ruleId),
73
+ ['rule.error', 'rule.critical']
74
+ );
75
+ assert.equal(result.warnings.length, 1);
76
+ assert.equal(result.warnings[0]?.ruleId, 'rule.warn');
77
+ });
@@ -0,0 +1,23 @@
1
+ import type { Finding } from './Finding';
2
+ import type { GateOutcome } from './GateOutcome';
3
+ import type { GatePolicy } from './GatePolicy';
4
+ import { isSeverityAtLeast } from '../rules/Severity';
5
+
6
+ export function evaluateGate(
7
+ findings: Finding[],
8
+ policy: GatePolicy
9
+ ): { outcome: GateOutcome; blocking: Finding[]; warnings: Finding[] } {
10
+ const blocking = findings.filter((finding) =>
11
+ isSeverityAtLeast(finding.severity, policy.blockOnOrAbove)
12
+ );
13
+ const warnings = findings.filter(
14
+ (finding) =>
15
+ !isSeverityAtLeast(finding.severity, policy.blockOnOrAbove) &&
16
+ isSeverityAtLeast(finding.severity, policy.warnOnOrAbove)
17
+ );
18
+
19
+ const outcome: GateOutcome =
20
+ blocking.length > 0 ? 'BLOCK' : warnings.length > 0 ? 'WARN' : 'PASS';
21
+
22
+ return { outcome, blocking, warnings };
23
+ }
@@ -0,0 +1,106 @@
1
+ import assert from 'node:assert/strict';
2
+ import test from 'node:test';
3
+ import type { RuleSet } from '../rules/RuleSet';
4
+ import { evaluateRules } from './evaluateRules';
5
+
6
+ test('evaluateRules genera finding cuando la condicion coincide y usa code explicito', () => {
7
+ const rules: RuleSet = [
8
+ {
9
+ id: 'rule.explicit.code',
10
+ description: 'Detecta cambios en backend',
11
+ severity: 'WARN',
12
+ when: {
13
+ kind: 'FileChange',
14
+ where: { pathPrefix: 'apps/backend/', changeType: 'modified' },
15
+ },
16
+ then: {
17
+ kind: 'Finding',
18
+ message: 'Backend file modified.',
19
+ code: 'BACKEND_FILE_MODIFIED',
20
+ },
21
+ },
22
+ ];
23
+ const facts = [
24
+ {
25
+ kind: 'FileChange',
26
+ path: 'apps/backend/src/main.ts',
27
+ changeType: 'modified',
28
+ source: 'git',
29
+ },
30
+ ] as const;
31
+
32
+ const findings = evaluateRules(rules, facts);
33
+
34
+ assert.equal(findings.length, 1);
35
+ assert.deepEqual(findings[0], {
36
+ ruleId: 'rule.explicit.code',
37
+ severity: 'WARN',
38
+ code: 'BACKEND_FILE_MODIFIED',
39
+ message: 'Backend file modified.',
40
+ });
41
+ });
42
+
43
+ test('evaluateRules usa id de la regla como code cuando no se define en consecuencia', () => {
44
+ const rules: RuleSet = [
45
+ {
46
+ id: 'rule.code.fallback',
47
+ description: 'Detecta dependencia concreta',
48
+ severity: 'ERROR',
49
+ when: {
50
+ kind: 'Dependency',
51
+ where: { from: 'core/gate/evaluateGate', to: 'core/gate/evaluateRules' },
52
+ },
53
+ then: {
54
+ kind: 'Finding',
55
+ message: 'Dependency matched.',
56
+ },
57
+ },
58
+ ];
59
+ const facts = [
60
+ {
61
+ kind: 'Dependency',
62
+ from: 'core/gate/evaluateGate',
63
+ to: 'core/gate/evaluateRules',
64
+ source: 'depcruise',
65
+ },
66
+ ] as const;
67
+
68
+ const findings = evaluateRules(rules, facts);
69
+
70
+ assert.equal(findings.length, 1);
71
+ assert.equal(findings[0]?.code, 'rule.code.fallback');
72
+ assert.equal(findings[0]?.severity, 'ERROR');
73
+ });
74
+
75
+ test('evaluateRules respeta scope y no genera hallazgo cuando no coincide', () => {
76
+ const rules: RuleSet = [
77
+ {
78
+ id: 'rule.scope.filtered',
79
+ description: 'Busca token en backend',
80
+ severity: 'WARN',
81
+ when: {
82
+ kind: 'FileContent',
83
+ contains: ['token'],
84
+ },
85
+ then: {
86
+ kind: 'Finding',
87
+ message: 'Token found.',
88
+ },
89
+ scope: {
90
+ include: ['apps/backend/*'],
91
+ },
92
+ },
93
+ ];
94
+ const facts = [
95
+ {
96
+ kind: 'FileContent',
97
+ path: 'apps/frontend/src/App.tsx',
98
+ content: 'const token = "abc";',
99
+ source: 'repo',
100
+ },
101
+ ] as const;
102
+
103
+ const findings = evaluateRules(rules, facts);
104
+
105
+ assert.deepEqual(findings, []);
106
+ });
@@ -0,0 +1,40 @@
1
+ import type { RuleSet } from '../rules/RuleSet';
2
+ import type { RuleDefinition } from '../rules/RuleDefinition';
3
+ import type { Condition } from '../rules/Condition';
4
+ import type { Consequence } from '../rules/Consequence';
5
+ import type { Fact } from '../facts/Fact';
6
+ import type { FileChangeFact } from '../facts/FileChangeFact';
7
+ import type { FileContentFact } from '../facts/FileContentFact';
8
+ import type { Finding } from './Finding';
9
+ import { conditionMatches } from './conditionMatches';
10
+
11
+ type FactInput = Fact | FileChangeFact | FileContentFact;
12
+
13
+ const toFinding = (rule: RuleDefinition, consequence: Consequence): Finding => {
14
+ return {
15
+ ruleId: rule.id,
16
+ severity: rule.severity,
17
+ code: consequence.code ?? rule.id,
18
+ message: consequence.message,
19
+ };
20
+ };
21
+
22
+ export function evaluateRules(
23
+ rules: RuleSet,
24
+ facts: ReadonlyArray<FactInput>
25
+ ): ReadonlyArray<Finding> {
26
+ const findings: Finding[] = [];
27
+
28
+ for (const rule of rules) {
29
+ const condition: Condition = rule.when;
30
+ const consequence: Consequence = rule.then;
31
+ if (!conditionMatches(condition, facts, rule.scope)) {
32
+ continue;
33
+ }
34
+ if (consequence.kind === 'Finding') {
35
+ findings.push(toFinding(rule, consequence));
36
+ }
37
+ }
38
+
39
+ return findings;
40
+ }