tribunal-kit 9.2.6 → 9.2.8

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 (836) hide show
  1. package/.agent/ARCHITECTURE.md +4 -4
  2. package/.agent/data/skill_certification_ledger.jsonl +40 -0
  3. package/.agent/data/skill_ontology.json +138 -0
  4. package/.agent/history/architecture-intelligence.html +1487 -401
  5. package/.agent/history/architecture-model.json +16130 -5802
  6. package/.agent/history/architecture-verification.json +6 -6
  7. package/.agent/routing_index.json +656 -1566
  8. package/.agent/rules/GEMINI.md +1 -1
  9. package/.agent/scripts/adaptive_execution.js +704 -0
  10. package/.agent/scripts/architecture_diff.js +60 -17
  11. package/.agent/scripts/architecture_extractor.js +60 -21
  12. package/.agent/scripts/architecture_health.js +58 -21
  13. package/.agent/scripts/architecture_intelligence.js +3100 -0
  14. package/.agent/scripts/architecture_verifier.js +46 -13
  15. package/.agent/scripts/architecture_visualizer.js +1536 -421
  16. package/.agent/scripts/blast_radius_engine.js +64 -24
  17. package/.agent/scripts/capability_evolution.js +555 -0
  18. package/.agent/scripts/concept_extractor.js +240 -0
  19. package/.agent/scripts/consideration_engine.js +284 -0
  20. package/.agent/scripts/context_broker.js +397 -31
  21. package/.agent/scripts/corpus_certification_orchestrator.js +502 -0
  22. package/.agent/scripts/corpus_validation_engine.js +311 -0
  23. package/.agent/scripts/coverage_engine.js +102 -0
  24. package/.agent/scripts/cross_domain_engine.js +1883 -0
  25. package/.agent/scripts/engineering_memory.js +1442 -0
  26. package/.agent/scripts/final_corpus_validation_engine.js +405 -0
  27. package/.agent/scripts/integrity_manifest.js +1 -5
  28. package/.agent/scripts/intent_extractor.js +130 -0
  29. package/.agent/scripts/judgment_engine.js +790 -0
  30. package/.agent/scripts/materiality_engine.js +251 -0
  31. package/.agent/scripts/outcome_engine.js +639 -0
  32. package/.agent/scripts/outcome_optimization_engine.js +1632 -0
  33. package/.agent/scripts/routing_evaluation_engine.js +184 -0
  34. package/.agent/scripts/simulation_engine.js +1478 -0
  35. package/.agent/scripts/skill_behavior_classifier.js +90 -0
  36. package/.agent/scripts/skill_behavior_harness.js +105 -0
  37. package/.agent/scripts/skill_certification_engine.js +586 -0
  38. package/.agent/scripts/skill_contract_engine.js +424 -0
  39. package/.agent/scripts/skill_coverage_expansion_engine.js +505 -0
  40. package/.agent/scripts/skill_evidence_acquisition_engine.js +535 -0
  41. package/.agent/scripts/skill_evidence_engine.js +83 -0
  42. package/.agent/scripts/skill_expectation_engine.js +38 -0
  43. package/.agent/scripts/skill_fixture_engine.js +24 -0
  44. package/.agent/scripts/skill_human_validation.js +32 -0
  45. package/.agent/scripts/skill_intelligence.js +1300 -0
  46. package/.agent/scripts/skill_observation_engine.js +25 -0
  47. package/.agent/scripts/skill_ontology_engine.js +83 -0
  48. package/.agent/scripts/skill_quality_engine.js +343 -0
  49. package/.agent/scripts/skill_reconstruction_engine.js +164 -0
  50. package/.agent/scripts/skill_remediation_engine.js +326 -0
  51. package/.agent/scripts/skill_scenario_engine.js +108 -0
  52. package/.agent/scripts/skill_test_authoring_engine.js +1011 -0
  53. package/.agent/scripts/verification_auditor.js +346 -0
  54. package/.agent/skill-intelligence/taxonomy/engineering-concepts.json +555 -0
  55. package/.agent/skill_topic_map.json +15 -55
  56. package/.agent/skills/12-principles-of-animation/SKILL.md +9 -0
  57. package/.agent/skills/60fps-animation/SKILL.md +14 -0
  58. package/.agent/skills/accessible-animation/SKILL.md +9 -0
  59. package/.agent/skills/adapt/SKILL.md +8 -0
  60. package/.agent/skills/adr-generation/SKILL.md +9 -0
  61. package/.agent/skills/advanced-rag-pipelines/SKILL.md +9 -0
  62. package/.agent/skills/agent-organizer/SKILL.md +8 -0
  63. package/.agent/skills/agent-syscall-guidelines/SKILL.md +10 -0
  64. package/.agent/skills/agentic-patterns/SKILL.md +9 -0
  65. package/.agent/skills/agentic-workflows-2026/SKILL.md +8 -0
  66. package/.agent/skills/agentshield-security/SKILL.md +16 -0
  67. package/.agent/skills/ai-app-hardening/SKILL.md +7 -0
  68. package/.agent/skills/ai-prompt-injection-defense/SKILL.md +9 -0
  69. package/.agent/skills/animation-on-scroll/SKILL.md +9 -0
  70. package/.agent/skills/animation-systems/SKILL.md +8 -0
  71. package/.agent/skills/antfu-conventions/SKILL.md +9 -0
  72. package/.agent/skills/anti-slop-enforcement/SKILL.md +11 -0
  73. package/.agent/skills/api-patterns/SKILL.md +9 -0
  74. package/.agent/skills/api-security-auditor/SKILL.md +10 -0
  75. package/.agent/skills/app-builder/SKILL.md +8 -0
  76. package/.agent/skills/appflow-wireframe/SKILL.md +9 -0
  77. package/.agent/skills/apple-design/SKILL.md +8 -0
  78. package/.agent/skills/architecture/SKILL.md +8 -0
  79. package/.agent/skills/architecture-drift/SKILL.md +9 -0
  80. package/.agent/skills/architecture-intelligence/SKILL.md +17 -0
  81. package/.agent/skills/audit-and-fix/SKILL.md +8 -0
  82. package/.agent/skills/authentication-best-practices/SKILL.md +10 -0
  83. package/.agent/skills/autonomous-execution/SKILL.md +9 -0
  84. package/.agent/skills/backend-alembic/SKILL.md +16 -0
  85. package/.agent/skills/backend-architecture-auditor/SKILL.md +16 -0
  86. package/.agent/skills/backend-mongodb/SKILL.md +10 -0
  87. package/.agent/skills/backend-mysql/SKILL.md +16 -0
  88. package/.agent/skills/backend-performance-auditor/SKILL.md +10 -0
  89. package/.agent/skills/backend-postgresql/SKILL.md +10 -0
  90. package/.agent/skills/backend-redis/SKILL.md +10 -0
  91. package/.agent/skills/backend-security-expert/SKILL.md +10 -0
  92. package/.agent/skills/backend-sqlalchemy/SKILL.md +10 -0
  93. package/.agent/skills/backend-sqlite/SKILL.md +10 -0
  94. package/.agent/skills/backend-testing-auditor/SKILL.md +15 -0
  95. package/.agent/skills/baseline-ui/SKILL.md +8 -0
  96. package/.agent/skills/bash-linux/SKILL.md +9 -0
  97. package/.agent/skills/behavioral-modes/SKILL.md +9 -0
  98. package/.agent/skills/better-colors/SKILL.md +9 -0
  99. package/.agent/skills/better-typography/SKILL.md +9 -0
  100. package/.agent/skills/better-ui/SKILL.md +8 -0
  101. package/.agent/skills/bolder/SKILL.md +8 -0
  102. package/.agent/skills/brainstorming/SKILL.md +8 -0
  103. package/.agent/skills/browser-audit/SKILL.md +9 -0
  104. package/.agent/skills/browser-native-ai/SKILL.md +8 -0
  105. package/.agent/skills/build-primitive/SKILL.md +8 -0
  106. package/.agent/skills/building-native-ui/SKILL.md +7 -0
  107. package/.agent/skills/cicd-pro/SKILL.md +9 -0
  108. package/.agent/skills/clarify/SKILL.md +8 -0
  109. package/.agent/skills/clean-code/SKILL.md +8 -0
  110. package/.agent/skills/cloud-architect/SKILL.md +8 -0
  111. package/.agent/skills/cobejs/SKILL.md +8 -0
  112. package/.agent/skills/code-review-checklist/SKILL.md +9 -0
  113. package/.agent/skills/codebase-design/SKILL.md +14 -0
  114. package/.agent/skills/colorize/SKILL.md +8 -0
  115. package/.agent/skills/compact-landing/SKILL.md +9 -0
  116. package/.agent/skills/company-logos/SKILL.md +9 -0
  117. package/.agent/skills/config-validator/SKILL.md +9 -0
  118. package/.agent/skills/containerization-pro/SKILL.md +9 -0
  119. package/.agent/skills/context-engineering-pro/SKILL.md +10 -0
  120. package/.agent/skills/create-design-md/SKILL.md +7 -0
  121. package/.agent/skills/critique/SKILL.md +8 -0
  122. package/.agent/skills/csharp-developer/SKILL.md +9 -0
  123. package/.agent/skills/data-validation-schemas/SKILL.md +8 -0
  124. package/.agent/skills/database-design/SKILL.md +8 -0
  125. package/.agent/skills/delight/SKILL.md +8 -0
  126. package/.agent/skills/deployment-procedures/SKILL.md +9 -0
  127. package/.agent/skills/design-lab/SKILL.md +8 -0
  128. package/.agent/skills/devops-engineer/SKILL.md +9 -0
  129. package/.agent/skills/devops-incident-responder/SKILL.md +16 -0
  130. package/.agent/skills/diagnosing-bugs/SKILL.md +9 -0
  131. package/.agent/skills/distill/SKILL.md +8 -0
  132. package/.agent/skills/documentation-templates/SKILL.md +9 -0
  133. package/.agent/skills/domain-modeling/SKILL.md +9 -0
  134. package/.agent/skills/duckdb-analytical-sql/SKILL.md +10 -0
  135. package/.agent/skills/edge-ai-mobile/SKILL.md +8 -0
  136. package/.agent/skills/edge-computing/SKILL.md +9 -0
  137. package/.agent/skills/emil-design-eng/SKILL.md +9 -0
  138. package/.agent/skills/error-resilience/SKILL.md +8 -0
  139. package/.agent/skills/expo-router-v4/SKILL.md +9 -0
  140. package/.agent/skills/extract-design-system/SKILL.md +9 -0
  141. package/.agent/skills/fabel-protocol/SKILL.md +9 -0
  142. package/.agent/skills/failure-mode-analysis/SKILL.md +10 -0
  143. package/.agent/skills/fastapi-pro/SKILL.md +9 -0
  144. package/.agent/skills/fixing-accessibility/SKILL.md +9 -0
  145. package/.agent/skills/fixing-metadata/SKILL.md +9 -0
  146. package/.agent/skills/fixing-motion-performance/SKILL.md +9 -0
  147. package/.agent/skills/framer-motion-expert/SKILL.md +9 -0
  148. package/.agent/skills/frontend-design/SKILL.md +7 -0
  149. package/.agent/skills/frontend-security-expert/SKILL.md +9 -0
  150. package/.agent/skills/game-design-expert/SKILL.md +9 -0
  151. package/.agent/skills/game-engineering-expert/SKILL.md +16 -0
  152. package/.agent/skills/generative-ui-expert/SKILL.md +9 -0
  153. package/.agent/skills/geo-fundamentals/SKILL.md +9 -0
  154. package/.agent/skills/git-pro/SKILL.md +9 -0
  155. package/.agent/skills/github-operations/SKILL.md +9 -0
  156. package/.agent/skills/gpt-taste/SKILL.md +9 -0
  157. package/.agent/skills/graph-engineering/SKILL.md +16 -0
  158. package/.agent/skills/gsap-core/SKILL.md +9 -0
  159. package/.agent/skills/gsap-frameworks/SKILL.md +9 -0
  160. package/.agent/skills/gsap-performance/SKILL.md +9 -0
  161. package/.agent/skills/gsap-plugins/SKILL.md +9 -0
  162. package/.agent/skills/gsap-react/SKILL.md +9 -0
  163. package/.agent/skills/gsap-scrolltrigger/SKILL.md +9 -0
  164. package/.agent/skills/gsap-timeline/SKILL.md +9 -0
  165. package/.agent/skills/gsap-utils/SKILL.md +9 -0
  166. package/.agent/skills/harden/SKILL.md +8 -0
  167. package/.agent/skills/harness-protocol/SKILL.md +9 -0
  168. package/.agent/skills/hf-cli/SKILL.md +11 -0
  169. package/.agent/skills/hf-cloud-aws-context-discovery/SKILL.md +10 -0
  170. package/.agent/skills/hf-cloud-python-env-setup/SKILL.md +10 -0
  171. package/.agent/skills/hf-cloud-sagemaker-deployment-planner/SKILL.md +10 -0
  172. package/.agent/skills/hf-cloud-sagemaker-iam-preflight/SKILL.md +10 -0
  173. package/.agent/skills/hf-cloud-sagemaker-production-defaults/SKILL.md +10 -0
  174. package/.agent/skills/hf-cloud-serving-image-selection/SKILL.md +10 -0
  175. package/.agent/skills/hf-mem/SKILL.md +11 -0
  176. package/.agent/skills/huggingface-best/SKILL.md +9 -0
  177. package/.agent/skills/huggingface-community-evals/SKILL.md +11 -0
  178. package/.agent/skills/huggingface-datasets/SKILL.md +10 -0
  179. package/.agent/skills/huggingface-gradio/SKILL.md +10 -0
  180. package/.agent/skills/huggingface-llm-trainer/SKILL.md +10 -0
  181. package/.agent/skills/huggingface-local-models/SKILL.md +10 -0
  182. package/.agent/skills/huggingface-lora-space-builder/SKILL.md +11 -0
  183. package/.agent/skills/huggingface-paper-publisher/SKILL.md +11 -0
  184. package/.agent/skills/huggingface-papers/SKILL.md +11 -0
  185. package/.agent/skills/huggingface-spaces/SKILL.md +10 -0
  186. package/.agent/skills/huggingface-tool-builder/SKILL.md +11 -0
  187. package/.agent/skills/huggingface-trackio/SKILL.md +11 -0
  188. package/.agent/skills/huggingface-vision-trainer/SKILL.md +11 -0
  189. package/.agent/skills/huggingface-zerogpu/SKILL.md +11 -0
  190. package/.agent/skills/human-gate-negotiation/SKILL.md +11 -0
  191. package/.agent/skills/i18n-localization/SKILL.md +9 -0
  192. package/.agent/skills/impeccable/SKILL.md +8 -0
  193. package/.agent/skills/improve-codebase-architecture/SKILL.md +10 -0
  194. package/.agent/skills/improve-ui/SKILL.md +8 -0
  195. package/.agent/skills/intelligent-routing/SKILL.md +9 -0
  196. package/.agent/skills/knowledge-graph/SKILL.md +9 -0
  197. package/.agent/skills/landing-page/SKILL.md +9 -0
  198. package/.agent/skills/lint-and-validate/SKILL.md +9 -0
  199. package/.agent/skills/llm-engineering/SKILL.md +9 -0
  200. package/.agent/skills/local-first/SKILL.md +10 -0
  201. package/.agent/skills/lottie-animation/SKILL.md +9 -0
  202. package/.agent/skills/marquee-loop/SKILL.md +9 -0
  203. package/.agent/skills/masked-reveal/SKILL.md +9 -0
  204. package/.agent/skills/mcp-builder/SKILL.md +9 -0
  205. package/.agent/skills/micro-interaction/SKILL.md +9 -0
  206. package/.agent/skills/mobile-design/SKILL.md +7 -0
  207. package/.agent/skills/monorepo-management/SKILL.md +9 -0
  208. package/.agent/skills/morphing-icons/SKILL.md +9 -0
  209. package/.agent/skills/motion-engineering/SKILL.md +8 -0
  210. package/.agent/skills/nextjs-react-expert/SKILL.md +10 -0
  211. package/.agent/skills/nodejs-best-practices/SKILL.md +16 -0
  212. package/.agent/skills/observability/SKILL.md +8 -0
  213. package/.agent/skills/opentelemetry-observability/SKILL.md +9 -0
  214. package/.agent/skills/page-transition-animation/SKILL.md +10 -0
  215. package/.agent/skills/parallel-agents/SKILL.md +15 -0
  216. package/.agent/skills/performance-profiling/SKILL.md +9 -0
  217. package/.agent/skills/plan-writing/SKILL.md +8 -0
  218. package/.agent/skills/platform-engineer/SKILL.md +9 -0
  219. package/.agent/skills/platform-engineering-opentofu/SKILL.md +10 -0
  220. package/.agent/skills/playwright-ai-e2e/SKILL.md +9 -0
  221. package/.agent/skills/playwright-best-practices/SKILL.md +16 -0
  222. package/.agent/skills/polish/SKILL.md +8 -0
  223. package/.agent/skills/powershell-windows/SKILL.md +9 -0
  224. package/.agent/skills/pricing-page/SKILL.md +9 -0
  225. package/.agent/skills/product-aware-heuristics/SKILL.md +10 -0
  226. package/.agent/skills/progressive-blur/SKILL.md +9 -0
  227. package/.agent/skills/project-idioms/SKILL.md +8 -0
  228. package/.agent/skills/property-based-testing/SKILL.md +9 -0
  229. package/.agent/skills/python-patterns/SKILL.md +9 -0
  230. package/.agent/skills/python-pro/SKILL.md +9 -0
  231. package/.agent/skills/quieter/SKILL.md +8 -0
  232. package/.agent/skills/react-doctor/SKILL.md +9 -0
  233. package/.agent/skills/react-specialist/SKILL.md +9 -0
  234. package/.agent/skills/readme-builder/SKILL.md +9 -0
  235. package/.agent/skills/realtime-patterns/SKILL.md +9 -0
  236. package/.agent/skills/red-team-tactics/SKILL.md +16 -0
  237. package/.agent/skills/redesign-skill/SKILL.md +9 -0
  238. package/.agent/skills/review-animations/SKILL.md +8 -0
  239. package/.agent/skills/rust-pro/SKILL.md +9 -0
  240. package/.agent/skills/semantic-filesystem-navigation/SKILL.md +11 -0
  241. package/.agent/skills/seo-fundamentals/SKILL.md +9 -0
  242. package/.agent/skills/server-management/SKILL.md +8 -0
  243. package/.agent/skills/session-log-interrogation/SKILL.md +11 -0
  244. package/.agent/skills/shadcn-ui-expert/SKILL.md +9 -0
  245. package/.agent/skills/shape/SKILL.md +8 -0
  246. package/.agent/skills/skill-creator/SKILL.md +9 -0
  247. package/.agent/skills/soft-skill/SKILL.md +9 -0
  248. package/.agent/skills/sounds-on-the-web/SKILL.md +9 -0
  249. package/.agent/skills/sql-pro/SKILL.md +9 -0
  250. package/.agent/skills/subagent-driven-development/SKILL.md +11 -0
  251. package/.agent/skills/supabase-postgres-best-practices/SKILL.md +17 -0
  252. package/.agent/skills/svg-animation/SKILL.md +9 -0
  253. package/.agent/skills/swiftui-expert/SKILL.md +9 -0
  254. package/.agent/skills/swiss-design/SKILL.md +8 -0
  255. package/.agent/skills/system-design-pro/SKILL.md +9 -0
  256. package/.agent/skills/systematic-debugging/SKILL.md +14 -0
  257. package/.agent/skills/tailwind-patterns/SKILL.md +9 -0
  258. package/.agent/skills/taste-skill/SKILL.md +9 -0
  259. package/.agent/skills/tdd-workflow/SKILL.md +9 -0
  260. package/.agent/skills/test-result-analyzer/SKILL.md +9 -0
  261. package/.agent/skills/testing-patterns/SKILL.md +8 -0
  262. package/.agent/skills/thermo-nuclear-code-quality-review/SKILL.md +11 -0
  263. package/.agent/skills/thinking-protocol/SKILL.md +10 -0
  264. package/.agent/skills/to-spring-or-not-to-spring/SKILL.md +9 -0
  265. package/.agent/skills/train-sentence-transformers/SKILL.md +10 -0
  266. package/.agent/skills/transformers-js/SKILL.md +8 -0
  267. package/.agent/skills/transitions-dev/SKILL.md +8 -0
  268. package/.agent/skills/trend-researcher/SKILL.md +9 -0
  269. package/.agent/skills/tribunal-instincts-memory/SKILL.md +11 -0
  270. package/.agent/skills/trl-training/SKILL.md +9 -0
  271. package/.agent/skills/typescript-advanced/SKILL.md +9 -0
  272. package/.agent/skills/typeset/SKILL.md +8 -0
  273. package/.agent/skills/ui-reasoning-engine/SKILL.md +9 -0
  274. package/.agent/skills/ui-skill-packs/SKILL.md +9 -0
  275. package/.agent/skills/ui-skills-root/SKILL.md +9 -0
  276. package/.agent/skills/ui-ux-pro-max/SKILL.md +9 -0
  277. package/.agent/skills/ui-ux-researcher/SKILL.md +8 -0
  278. package/.agent/skills/vector-search-pgvector/SKILL.md +10 -0
  279. package/.agent/skills/verification-before-completion/SKILL.md +9 -0
  280. package/.agent/skills/vue-expert/SKILL.md +9 -0
  281. package/.agent/skills/vulnerability-scanner/SKILL.md +9 -0
  282. package/.agent/skills/web-accessibility-auditor/SKILL.md +16 -0
  283. package/.agent/skills/web-design-guidelines/SKILL.md +9 -0
  284. package/.agent/skills/web-quality-audit/SKILL.md +10 -0
  285. package/.agent/skills/webapp-testing/SKILL.md +8 -0
  286. package/.agent/skills/webgpu-performance/SKILL.md +9 -0
  287. package/.agent/skills/whimsy-injector/SKILL.md +9 -0
  288. package/.agent/skills/workflow-optimizer/SKILL.md +9 -0
  289. package/.agent/skills/zero-trust-passkeys/SKILL.md +10 -0
  290. package/.agent/skills_inventory.json +502 -3167
  291. package/.agent/workflows/arch.md +96 -80
  292. package/.agent/workflows/skill-intelligence.md +216 -0
  293. package/.agents/skills/12-principles-of-animation/SKILL.md +9 -0
  294. package/.agents/skills/60fps-animation/SKILL.md +14 -0
  295. package/.agents/skills/accessible-animation/SKILL.md +9 -0
  296. package/.agents/skills/adapt/SKILL.md +8 -0
  297. package/.agents/skills/adr-generation/SKILL.md +9 -0
  298. package/.agents/skills/advanced-rag-pipelines/SKILL.md +9 -0
  299. package/.agents/skills/agent-organizer/SKILL.md +8 -0
  300. package/.agents/skills/agent-syscall-guidelines/SKILL.md +10 -0
  301. package/.agents/skills/agentic-patterns/SKILL.md +9 -0
  302. package/.agents/skills/agentic-workflows-2026/SKILL.md +8 -0
  303. package/.agents/skills/agentshield-security/SKILL.md +16 -0
  304. package/.agents/skills/ai-app-hardening/SKILL.md +7 -0
  305. package/.agents/skills/ai-prompt-injection-defense/SKILL.md +9 -0
  306. package/.agents/skills/animation-on-scroll/SKILL.md +9 -0
  307. package/.agents/skills/animation-systems/SKILL.md +8 -0
  308. package/.agents/skills/antfu-conventions/SKILL.md +9 -0
  309. package/.agents/skills/anti-slop-enforcement/SKILL.md +11 -0
  310. package/.agents/skills/api-patterns/SKILL.md +9 -0
  311. package/.agents/skills/api-security-auditor/SKILL.md +10 -0
  312. package/.agents/skills/app-builder/SKILL.md +8 -0
  313. package/.agents/skills/appflow-wireframe/SKILL.md +9 -0
  314. package/.agents/skills/apple-design/SKILL.md +8 -0
  315. package/.agents/skills/architecture/SKILL.md +8 -0
  316. package/.agents/skills/architecture-drift/SKILL.md +9 -0
  317. package/.agents/skills/architecture-intelligence/SKILL.md +17 -0
  318. package/.agents/skills/audit-and-fix/SKILL.md +8 -0
  319. package/.agents/skills/authentication-best-practices/SKILL.md +10 -0
  320. package/.agents/skills/autonomous-execution/SKILL.md +9 -0
  321. package/.agents/skills/backend-alembic/SKILL.md +16 -0
  322. package/.agents/skills/backend-architecture-auditor/SKILL.md +16 -0
  323. package/.agents/skills/backend-mongodb/SKILL.md +10 -0
  324. package/.agents/skills/backend-mysql/SKILL.md +16 -0
  325. package/.agents/skills/backend-performance-auditor/SKILL.md +10 -0
  326. package/.agents/skills/backend-postgresql/SKILL.md +10 -0
  327. package/.agents/skills/backend-redis/SKILL.md +10 -0
  328. package/.agents/skills/backend-security-expert/SKILL.md +10 -0
  329. package/.agents/skills/backend-sqlalchemy/SKILL.md +10 -0
  330. package/.agents/skills/backend-sqlite/SKILL.md +10 -0
  331. package/.agents/skills/backend-testing-auditor/SKILL.md +15 -0
  332. package/.agents/skills/baseline-ui/SKILL.md +8 -0
  333. package/.agents/skills/bash-linux/SKILL.md +9 -0
  334. package/.agents/skills/behavioral-modes/SKILL.md +9 -0
  335. package/.agents/skills/better-colors/SKILL.md +9 -0
  336. package/.agents/skills/better-typography/SKILL.md +9 -0
  337. package/.agents/skills/better-ui/SKILL.md +8 -0
  338. package/.agents/skills/bolder/SKILL.md +8 -0
  339. package/.agents/skills/brainstorming/SKILL.md +8 -0
  340. package/.agents/skills/browser-audit/SKILL.md +9 -0
  341. package/.agents/skills/browser-native-ai/SKILL.md +8 -0
  342. package/.agents/skills/build-primitive/SKILL.md +8 -0
  343. package/.agents/skills/building-native-ui/SKILL.md +7 -0
  344. package/.agents/skills/cicd-pro/SKILL.md +9 -0
  345. package/.agents/skills/clarify/SKILL.md +8 -0
  346. package/.agents/skills/clean-code/SKILL.md +8 -0
  347. package/.agents/skills/cloud-architect/SKILL.md +8 -0
  348. package/.agents/skills/cobejs/SKILL.md +8 -0
  349. package/.agents/skills/code-review-checklist/SKILL.md +9 -0
  350. package/.agents/skills/codebase-design/SKILL.md +14 -0
  351. package/.agents/skills/colorize/SKILL.md +8 -0
  352. package/.agents/skills/compact-landing/SKILL.md +9 -0
  353. package/.agents/skills/company-logos/SKILL.md +9 -0
  354. package/.agents/skills/config-validator/SKILL.md +9 -0
  355. package/.agents/skills/containerization-pro/SKILL.md +9 -0
  356. package/.agents/skills/context-engineering-pro/SKILL.md +10 -0
  357. package/.agents/skills/create-design-md/SKILL.md +7 -0
  358. package/.agents/skills/critique/SKILL.md +8 -0
  359. package/.agents/skills/csharp-developer/SKILL.md +9 -0
  360. package/.agents/skills/data-validation-schemas/SKILL.md +8 -0
  361. package/.agents/skills/database-design/SKILL.md +8 -0
  362. package/.agents/skills/delight/SKILL.md +8 -0
  363. package/.agents/skills/deployment-procedures/SKILL.md +9 -0
  364. package/.agents/skills/design-lab/SKILL.md +8 -0
  365. package/.agents/skills/devops-engineer/SKILL.md +9 -0
  366. package/.agents/skills/devops-incident-responder/SKILL.md +16 -0
  367. package/.agents/skills/diagnosing-bugs/SKILL.md +9 -0
  368. package/.agents/skills/distill/SKILL.md +8 -0
  369. package/.agents/skills/documentation-templates/SKILL.md +9 -0
  370. package/.agents/skills/domain-modeling/SKILL.md +9 -0
  371. package/.agents/skills/duckdb-analytical-sql/SKILL.md +10 -0
  372. package/.agents/skills/edge-ai-mobile/SKILL.md +8 -0
  373. package/.agents/skills/edge-computing/SKILL.md +9 -0
  374. package/.agents/skills/emil-design-eng/SKILL.md +9 -0
  375. package/.agents/skills/error-resilience/SKILL.md +8 -0
  376. package/.agents/skills/expo-router-v4/SKILL.md +9 -0
  377. package/.agents/skills/extract-design-system/SKILL.md +9 -0
  378. package/.agents/skills/fabel-protocol/SKILL.md +9 -0
  379. package/.agents/skills/failure-mode-analysis/SKILL.md +10 -0
  380. package/.agents/skills/fastapi-pro/SKILL.md +9 -0
  381. package/.agents/skills/fixing-accessibility/SKILL.md +9 -0
  382. package/.agents/skills/fixing-metadata/SKILL.md +9 -0
  383. package/.agents/skills/fixing-motion-performance/SKILL.md +9 -0
  384. package/.agents/skills/framer-motion-expert/SKILL.md +9 -0
  385. package/.agents/skills/frontend-design/SKILL.md +7 -0
  386. package/.agents/skills/frontend-security-expert/SKILL.md +9 -0
  387. package/.agents/skills/game-design-expert/SKILL.md +9 -0
  388. package/.agents/skills/game-engineering-expert/SKILL.md +16 -0
  389. package/.agents/skills/generative-ui-expert/SKILL.md +9 -0
  390. package/.agents/skills/geo-fundamentals/SKILL.md +9 -0
  391. package/.agents/skills/git-pro/SKILL.md +9 -0
  392. package/.agents/skills/github-operations/SKILL.md +9 -0
  393. package/.agents/skills/gpt-taste/SKILL.md +9 -0
  394. package/.agents/skills/graph-engineering/SKILL.md +16 -0
  395. package/.agents/skills/gsap-core/SKILL.md +9 -0
  396. package/.agents/skills/gsap-frameworks/SKILL.md +9 -0
  397. package/.agents/skills/gsap-performance/SKILL.md +9 -0
  398. package/.agents/skills/gsap-plugins/SKILL.md +9 -0
  399. package/.agents/skills/gsap-react/SKILL.md +9 -0
  400. package/.agents/skills/gsap-scrolltrigger/SKILL.md +9 -0
  401. package/.agents/skills/gsap-timeline/SKILL.md +9 -0
  402. package/.agents/skills/gsap-utils/SKILL.md +9 -0
  403. package/.agents/skills/harden/SKILL.md +8 -0
  404. package/.agents/skills/harness-protocol/SKILL.md +9 -0
  405. package/.agents/skills/hf-cli/SKILL.md +11 -0
  406. package/.agents/skills/hf-cloud-aws-context-discovery/SKILL.md +10 -0
  407. package/.agents/skills/hf-cloud-python-env-setup/SKILL.md +10 -0
  408. package/.agents/skills/hf-cloud-sagemaker-deployment-planner/SKILL.md +10 -0
  409. package/.agents/skills/hf-cloud-sagemaker-iam-preflight/SKILL.md +10 -0
  410. package/.agents/skills/hf-cloud-sagemaker-production-defaults/SKILL.md +10 -0
  411. package/.agents/skills/hf-cloud-serving-image-selection/SKILL.md +10 -0
  412. package/.agents/skills/hf-mem/SKILL.md +11 -0
  413. package/.agents/skills/huggingface-best/SKILL.md +9 -0
  414. package/.agents/skills/huggingface-community-evals/SKILL.md +11 -0
  415. package/.agents/skills/huggingface-datasets/SKILL.md +10 -0
  416. package/.agents/skills/huggingface-gradio/SKILL.md +10 -0
  417. package/.agents/skills/huggingface-llm-trainer/SKILL.md +10 -0
  418. package/.agents/skills/huggingface-local-models/SKILL.md +10 -0
  419. package/.agents/skills/huggingface-lora-space-builder/SKILL.md +11 -0
  420. package/.agents/skills/huggingface-paper-publisher/SKILL.md +11 -0
  421. package/.agents/skills/huggingface-papers/SKILL.md +11 -0
  422. package/.agents/skills/huggingface-spaces/SKILL.md +10 -0
  423. package/.agents/skills/huggingface-tool-builder/SKILL.md +11 -0
  424. package/.agents/skills/huggingface-trackio/SKILL.md +11 -0
  425. package/.agents/skills/huggingface-vision-trainer/SKILL.md +11 -0
  426. package/.agents/skills/huggingface-zerogpu/SKILL.md +11 -0
  427. package/.agents/skills/human-gate-negotiation/SKILL.md +11 -0
  428. package/.agents/skills/i18n-localization/SKILL.md +9 -0
  429. package/.agents/skills/impeccable/SKILL.md +8 -0
  430. package/.agents/skills/improve-codebase-architecture/SKILL.md +10 -0
  431. package/.agents/skills/improve-ui/SKILL.md +8 -0
  432. package/.agents/skills/intelligent-routing/SKILL.md +9 -0
  433. package/.agents/skills/knowledge-graph/SKILL.md +9 -0
  434. package/.agents/skills/landing-page/SKILL.md +9 -0
  435. package/.agents/skills/lint-and-validate/SKILL.md +9 -0
  436. package/.agents/skills/llm-engineering/SKILL.md +9 -0
  437. package/.agents/skills/local-first/SKILL.md +10 -0
  438. package/.agents/skills/lottie-animation/SKILL.md +9 -0
  439. package/.agents/skills/marquee-loop/SKILL.md +9 -0
  440. package/.agents/skills/masked-reveal/SKILL.md +9 -0
  441. package/.agents/skills/mcp-builder/SKILL.md +9 -0
  442. package/.agents/skills/micro-interaction/SKILL.md +9 -0
  443. package/.agents/skills/mobile-design/SKILL.md +7 -0
  444. package/.agents/skills/monorepo-management/SKILL.md +9 -0
  445. package/.agents/skills/morphing-icons/SKILL.md +9 -0
  446. package/.agents/skills/motion-engineering/SKILL.md +8 -0
  447. package/.agents/skills/nextjs-react-expert/SKILL.md +10 -0
  448. package/.agents/skills/nodejs-best-practices/SKILL.md +16 -0
  449. package/.agents/skills/observability/SKILL.md +8 -0
  450. package/.agents/skills/opentelemetry-observability/SKILL.md +9 -0
  451. package/.agents/skills/page-transition-animation/SKILL.md +10 -0
  452. package/.agents/skills/parallel-agents/SKILL.md +15 -0
  453. package/.agents/skills/performance-profiling/SKILL.md +9 -0
  454. package/.agents/skills/plan-writing/SKILL.md +8 -0
  455. package/.agents/skills/platform-engineer/SKILL.md +9 -0
  456. package/.agents/skills/platform-engineering-opentofu/SKILL.md +10 -0
  457. package/.agents/skills/playwright-ai-e2e/SKILL.md +9 -0
  458. package/.agents/skills/playwright-best-practices/SKILL.md +16 -0
  459. package/.agents/skills/polish/SKILL.md +8 -0
  460. package/.agents/skills/powershell-windows/SKILL.md +9 -0
  461. package/.agents/skills/pricing-page/SKILL.md +9 -0
  462. package/.agents/skills/product-aware-heuristics/SKILL.md +10 -0
  463. package/.agents/skills/progressive-blur/SKILL.md +9 -0
  464. package/.agents/skills/project-idioms/SKILL.md +8 -0
  465. package/.agents/skills/property-based-testing/SKILL.md +9 -0
  466. package/.agents/skills/python-patterns/SKILL.md +9 -0
  467. package/.agents/skills/python-pro/SKILL.md +9 -0
  468. package/.agents/skills/quieter/SKILL.md +8 -0
  469. package/.agents/skills/react-doctor/SKILL.md +9 -0
  470. package/.agents/skills/react-specialist/SKILL.md +9 -0
  471. package/.agents/skills/readme-builder/SKILL.md +9 -0
  472. package/.agents/skills/realtime-patterns/SKILL.md +9 -0
  473. package/.agents/skills/red-team-tactics/SKILL.md +16 -0
  474. package/.agents/skills/redesign-skill/SKILL.md +9 -0
  475. package/.agents/skills/review-animations/SKILL.md +8 -0
  476. package/.agents/skills/rust-pro/SKILL.md +9 -0
  477. package/.agents/skills/semantic-filesystem-navigation/SKILL.md +11 -0
  478. package/.agents/skills/seo-fundamentals/SKILL.md +9 -0
  479. package/.agents/skills/server-management/SKILL.md +8 -0
  480. package/.agents/skills/session-log-interrogation/SKILL.md +11 -0
  481. package/.agents/skills/shadcn-ui-expert/SKILL.md +9 -0
  482. package/.agents/skills/shape/SKILL.md +8 -0
  483. package/.agents/skills/skill-creator/SKILL.md +9 -0
  484. package/.agents/skills/soft-skill/SKILL.md +9 -0
  485. package/.agents/skills/sounds-on-the-web/SKILL.md +9 -0
  486. package/.agents/skills/sql-pro/SKILL.md +9 -0
  487. package/.agents/skills/subagent-driven-development/SKILL.md +11 -0
  488. package/.agents/skills/supabase-postgres-best-practices/SKILL.md +17 -0
  489. package/.agents/skills/svg-animation/SKILL.md +9 -0
  490. package/.agents/skills/swiftui-expert/SKILL.md +9 -0
  491. package/.agents/skills/swiss-design/SKILL.md +8 -0
  492. package/.agents/skills/system-design-pro/SKILL.md +9 -0
  493. package/.agents/skills/systematic-debugging/SKILL.md +14 -0
  494. package/.agents/skills/tailwind-patterns/SKILL.md +9 -0
  495. package/.agents/skills/taste-skill/SKILL.md +9 -0
  496. package/.agents/skills/tdd-workflow/SKILL.md +9 -0
  497. package/.agents/skills/test-result-analyzer/SKILL.md +9 -0
  498. package/.agents/skills/testing-patterns/SKILL.md +8 -0
  499. package/.agents/skills/thermo-nuclear-code-quality-review/SKILL.md +11 -0
  500. package/.agents/skills/thinking-protocol/SKILL.md +10 -0
  501. package/.agents/skills/to-spring-or-not-to-spring/SKILL.md +9 -0
  502. package/.agents/skills/train-sentence-transformers/SKILL.md +10 -0
  503. package/.agents/skills/transformers-js/SKILL.md +8 -0
  504. package/.agents/skills/transitions-dev/SKILL.md +8 -0
  505. package/.agents/skills/trend-researcher/SKILL.md +9 -0
  506. package/.agents/skills/tribunal-instincts-memory/SKILL.md +11 -0
  507. package/.agents/skills/trl-training/SKILL.md +9 -0
  508. package/.agents/skills/typescript-advanced/SKILL.md +9 -0
  509. package/.agents/skills/typeset/SKILL.md +8 -0
  510. package/.agents/skills/ui-reasoning-engine/SKILL.md +9 -0
  511. package/.agents/skills/ui-skill-packs/SKILL.md +9 -0
  512. package/.agents/skills/ui-skills-root/SKILL.md +9 -0
  513. package/.agents/skills/ui-ux-pro-max/SKILL.md +9 -0
  514. package/.agents/skills/ui-ux-researcher/SKILL.md +8 -0
  515. package/.agents/skills/vector-search-pgvector/SKILL.md +10 -0
  516. package/.agents/skills/verification-before-completion/SKILL.md +9 -0
  517. package/.agents/skills/vue-expert/SKILL.md +9 -0
  518. package/.agents/skills/vulnerability-scanner/SKILL.md +9 -0
  519. package/.agents/skills/web-accessibility-auditor/SKILL.md +16 -0
  520. package/.agents/skills/web-design-guidelines/SKILL.md +9 -0
  521. package/.agents/skills/web-quality-audit/SKILL.md +10 -0
  522. package/.agents/skills/webapp-testing/SKILL.md +8 -0
  523. package/.agents/skills/webgpu-performance/SKILL.md +9 -0
  524. package/.agents/skills/whimsy-injector/SKILL.md +9 -0
  525. package/.agents/skills/workflow-optimizer/SKILL.md +9 -0
  526. package/.agents/skills/zero-trust-passkeys/SKILL.md +10 -0
  527. package/CONTRIBUTING.md +2 -2
  528. package/README.md +25 -25
  529. package/bin/adapter-install.js +1 -1
  530. package/bin/mcp-server.js +249 -0
  531. package/package.json +11 -8
  532. package/plugins/core-plugin.json +1 -1
  533. package/plugins/gemini/extension.json +1 -1
  534. package/skills/12-principles-of-animation/SKILL.md +9 -0
  535. package/skills/60fps-animation/SKILL.md +14 -0
  536. package/skills/accessible-animation/SKILL.md +9 -0
  537. package/skills/adapt/SKILL.md +8 -0
  538. package/skills/adr-generation/SKILL.md +9 -0
  539. package/skills/advanced-rag-pipelines/SKILL.md +9 -0
  540. package/skills/agent-organizer/SKILL.md +8 -0
  541. package/skills/agent-syscall-guidelines/SKILL.md +10 -0
  542. package/skills/agentic-patterns/SKILL.md +9 -0
  543. package/skills/agentic-workflows-2026/SKILL.md +8 -0
  544. package/skills/agentshield-security/SKILL.md +16 -0
  545. package/skills/ai-app-hardening/SKILL.md +7 -0
  546. package/skills/ai-prompt-injection-defense/SKILL.md +9 -0
  547. package/skills/animation-on-scroll/SKILL.md +9 -0
  548. package/skills/animation-systems/SKILL.md +8 -0
  549. package/skills/antfu-conventions/SKILL.md +9 -0
  550. package/skills/anti-slop-enforcement/SKILL.md +11 -0
  551. package/skills/api-patterns/SKILL.md +9 -0
  552. package/skills/api-security-auditor/SKILL.md +10 -0
  553. package/skills/app-builder/SKILL.md +8 -0
  554. package/skills/appflow-wireframe/SKILL.md +9 -0
  555. package/skills/apple-design/SKILL.md +8 -0
  556. package/skills/architecture/SKILL.md +8 -0
  557. package/skills/architecture-drift/SKILL.md +9 -0
  558. package/skills/architecture-intelligence/SKILL.md +17 -0
  559. package/skills/audit-and-fix/SKILL.md +8 -0
  560. package/skills/authentication-best-practices/SKILL.md +10 -0
  561. package/skills/autonomous-execution/SKILL.md +9 -0
  562. package/skills/backend-alembic/SKILL.md +16 -0
  563. package/skills/backend-architecture-auditor/SKILL.md +16 -0
  564. package/skills/backend-mongodb/SKILL.md +10 -0
  565. package/skills/backend-mysql/SKILL.md +16 -0
  566. package/skills/backend-performance-auditor/SKILL.md +10 -0
  567. package/skills/backend-postgresql/SKILL.md +10 -0
  568. package/skills/backend-redis/SKILL.md +10 -0
  569. package/skills/backend-security-expert/SKILL.md +10 -0
  570. package/skills/backend-sqlalchemy/SKILL.md +10 -0
  571. package/skills/backend-sqlite/SKILL.md +10 -0
  572. package/skills/backend-testing-auditor/SKILL.md +15 -0
  573. package/skills/baseline-ui/SKILL.md +8 -0
  574. package/skills/bash-linux/SKILL.md +9 -0
  575. package/skills/behavioral-modes/SKILL.md +9 -0
  576. package/skills/better-colors/SKILL.md +9 -0
  577. package/skills/better-typography/SKILL.md +9 -0
  578. package/skills/better-ui/SKILL.md +8 -0
  579. package/skills/bolder/SKILL.md +8 -0
  580. package/skills/brainstorming/SKILL.md +8 -0
  581. package/skills/browser-audit/SKILL.md +9 -0
  582. package/skills/browser-native-ai/SKILL.md +8 -0
  583. package/skills/build-primitive/SKILL.md +8 -0
  584. package/skills/building-native-ui/SKILL.md +7 -0
  585. package/skills/cicd-pro/SKILL.md +9 -0
  586. package/skills/clarify/SKILL.md +8 -0
  587. package/skills/clean-code/SKILL.md +8 -0
  588. package/skills/cloud-architect/SKILL.md +8 -0
  589. package/skills/cobejs/SKILL.md +8 -0
  590. package/skills/code-review-checklist/SKILL.md +9 -0
  591. package/skills/codebase-design/SKILL.md +14 -0
  592. package/skills/colorize/SKILL.md +8 -0
  593. package/skills/compact-landing/SKILL.md +9 -0
  594. package/skills/company-logos/SKILL.md +9 -0
  595. package/skills/config-validator/SKILL.md +9 -0
  596. package/skills/containerization-pro/SKILL.md +9 -0
  597. package/skills/context-engineering-pro/SKILL.md +10 -0
  598. package/skills/create-design-md/SKILL.md +7 -0
  599. package/skills/critique/SKILL.md +8 -0
  600. package/skills/csharp-developer/SKILL.md +9 -0
  601. package/skills/data-validation-schemas/SKILL.md +8 -0
  602. package/skills/database-design/SKILL.md +8 -0
  603. package/skills/delight/SKILL.md +8 -0
  604. package/skills/deployment-procedures/SKILL.md +9 -0
  605. package/skills/design-lab/SKILL.md +8 -0
  606. package/skills/devops-engineer/SKILL.md +9 -0
  607. package/skills/devops-incident-responder/SKILL.md +16 -0
  608. package/skills/diagnosing-bugs/SKILL.md +9 -0
  609. package/skills/distill/SKILL.md +8 -0
  610. package/skills/documentation-templates/SKILL.md +9 -0
  611. package/skills/domain-modeling/SKILL.md +9 -0
  612. package/skills/duckdb-analytical-sql/SKILL.md +10 -0
  613. package/skills/edge-ai-mobile/SKILL.md +8 -0
  614. package/skills/edge-computing/SKILL.md +9 -0
  615. package/skills/emil-design-eng/SKILL.md +9 -0
  616. package/skills/error-resilience/SKILL.md +8 -0
  617. package/skills/expo-router-v4/SKILL.md +9 -0
  618. package/skills/extract-design-system/SKILL.md +9 -0
  619. package/skills/fabel-protocol/SKILL.md +9 -0
  620. package/skills/failure-mode-analysis/SKILL.md +10 -0
  621. package/skills/fastapi-pro/SKILL.md +9 -0
  622. package/skills/fixing-accessibility/SKILL.md +9 -0
  623. package/skills/fixing-metadata/SKILL.md +9 -0
  624. package/skills/fixing-motion-performance/SKILL.md +9 -0
  625. package/skills/framer-motion-expert/SKILL.md +9 -0
  626. package/skills/frontend-design/SKILL.md +7 -0
  627. package/skills/frontend-security-expert/SKILL.md +9 -0
  628. package/skills/game-design-expert/SKILL.md +9 -0
  629. package/skills/game-engineering-expert/SKILL.md +16 -0
  630. package/skills/generative-ui-expert/SKILL.md +9 -0
  631. package/skills/geo-fundamentals/SKILL.md +9 -0
  632. package/skills/git-pro/SKILL.md +9 -0
  633. package/skills/github-operations/SKILL.md +9 -0
  634. package/skills/gpt-taste/SKILL.md +9 -0
  635. package/skills/graph-engineering/SKILL.md +16 -0
  636. package/skills/gsap-core/SKILL.md +9 -0
  637. package/skills/gsap-frameworks/SKILL.md +9 -0
  638. package/skills/gsap-performance/SKILL.md +9 -0
  639. package/skills/gsap-plugins/SKILL.md +9 -0
  640. package/skills/gsap-react/SKILL.md +9 -0
  641. package/skills/gsap-scrolltrigger/SKILL.md +9 -0
  642. package/skills/gsap-timeline/SKILL.md +9 -0
  643. package/skills/gsap-utils/SKILL.md +9 -0
  644. package/skills/harden/SKILL.md +8 -0
  645. package/skills/harness-protocol/SKILL.md +9 -0
  646. package/skills/hf-cli/SKILL.md +11 -0
  647. package/skills/hf-cloud-aws-context-discovery/SKILL.md +10 -0
  648. package/skills/hf-cloud-python-env-setup/SKILL.md +10 -0
  649. package/skills/hf-cloud-sagemaker-deployment-planner/SKILL.md +10 -0
  650. package/skills/hf-cloud-sagemaker-iam-preflight/SKILL.md +10 -0
  651. package/skills/hf-cloud-sagemaker-production-defaults/SKILL.md +10 -0
  652. package/skills/hf-cloud-serving-image-selection/SKILL.md +10 -0
  653. package/skills/hf-mem/SKILL.md +11 -0
  654. package/skills/huggingface-best/SKILL.md +9 -0
  655. package/skills/huggingface-community-evals/SKILL.md +11 -0
  656. package/skills/huggingface-datasets/SKILL.md +10 -0
  657. package/skills/huggingface-gradio/SKILL.md +10 -0
  658. package/skills/huggingface-llm-trainer/SKILL.md +10 -0
  659. package/skills/huggingface-local-models/SKILL.md +10 -0
  660. package/skills/huggingface-lora-space-builder/SKILL.md +11 -0
  661. package/skills/huggingface-paper-publisher/SKILL.md +11 -0
  662. package/skills/huggingface-papers/SKILL.md +11 -0
  663. package/skills/huggingface-spaces/SKILL.md +10 -0
  664. package/skills/huggingface-tool-builder/SKILL.md +11 -0
  665. package/skills/huggingface-trackio/SKILL.md +11 -0
  666. package/skills/huggingface-vision-trainer/SKILL.md +11 -0
  667. package/skills/huggingface-zerogpu/SKILL.md +11 -0
  668. package/skills/human-gate-negotiation/SKILL.md +11 -0
  669. package/skills/i18n-localization/SKILL.md +9 -0
  670. package/skills/impeccable/SKILL.md +8 -0
  671. package/skills/improve-codebase-architecture/SKILL.md +10 -0
  672. package/skills/improve-ui/SKILL.md +8 -0
  673. package/skills/intelligent-routing/SKILL.md +9 -0
  674. package/skills/knowledge-graph/SKILL.md +9 -0
  675. package/skills/landing-page/SKILL.md +9 -0
  676. package/skills/lint-and-validate/SKILL.md +9 -0
  677. package/skills/llm-engineering/SKILL.md +9 -0
  678. package/skills/local-first/SKILL.md +10 -0
  679. package/skills/lottie-animation/SKILL.md +9 -0
  680. package/skills/marquee-loop/SKILL.md +9 -0
  681. package/skills/masked-reveal/SKILL.md +9 -0
  682. package/skills/mcp-builder/SKILL.md +9 -0
  683. package/skills/micro-interaction/SKILL.md +9 -0
  684. package/skills/mobile-design/SKILL.md +7 -0
  685. package/skills/monorepo-management/SKILL.md +9 -0
  686. package/skills/morphing-icons/SKILL.md +9 -0
  687. package/skills/motion-engineering/SKILL.md +8 -0
  688. package/skills/nextjs-react-expert/SKILL.md +10 -0
  689. package/skills/nodejs-best-practices/SKILL.md +16 -0
  690. package/skills/observability/SKILL.md +8 -0
  691. package/skills/opentelemetry-observability/SKILL.md +9 -0
  692. package/skills/page-transition-animation/SKILL.md +10 -0
  693. package/skills/parallel-agents/SKILL.md +15 -0
  694. package/skills/performance-profiling/SKILL.md +9 -0
  695. package/skills/plan-writing/SKILL.md +8 -0
  696. package/skills/platform-engineer/SKILL.md +9 -0
  697. package/skills/platform-engineering-opentofu/SKILL.md +10 -0
  698. package/skills/playwright-ai-e2e/SKILL.md +9 -0
  699. package/skills/playwright-best-practices/SKILL.md +16 -0
  700. package/skills/polish/SKILL.md +8 -0
  701. package/skills/powershell-windows/SKILL.md +9 -0
  702. package/skills/pricing-page/SKILL.md +9 -0
  703. package/skills/product-aware-heuristics/SKILL.md +10 -0
  704. package/skills/progressive-blur/SKILL.md +9 -0
  705. package/skills/project-idioms/SKILL.md +8 -0
  706. package/skills/property-based-testing/SKILL.md +9 -0
  707. package/skills/python-patterns/SKILL.md +9 -0
  708. package/skills/python-pro/SKILL.md +9 -0
  709. package/skills/quieter/SKILL.md +8 -0
  710. package/skills/react-doctor/SKILL.md +9 -0
  711. package/skills/react-specialist/SKILL.md +9 -0
  712. package/skills/readme-builder/SKILL.md +9 -0
  713. package/skills/realtime-patterns/SKILL.md +9 -0
  714. package/skills/red-team-tactics/SKILL.md +16 -0
  715. package/skills/redesign-skill/SKILL.md +9 -0
  716. package/skills/review-animations/SKILL.md +8 -0
  717. package/skills/rust-pro/SKILL.md +9 -0
  718. package/skills/semantic-filesystem-navigation/SKILL.md +11 -0
  719. package/skills/seo-fundamentals/SKILL.md +9 -0
  720. package/skills/server-management/SKILL.md +8 -0
  721. package/skills/session-log-interrogation/SKILL.md +11 -0
  722. package/skills/shadcn-ui-expert/SKILL.md +9 -0
  723. package/skills/shape/SKILL.md +8 -0
  724. package/skills/skill-creator/SKILL.md +9 -0
  725. package/skills/soft-skill/SKILL.md +9 -0
  726. package/skills/sounds-on-the-web/SKILL.md +9 -0
  727. package/skills/sql-pro/SKILL.md +9 -0
  728. package/skills/subagent-driven-development/SKILL.md +11 -0
  729. package/skills/supabase-postgres-best-practices/SKILL.md +17 -0
  730. package/skills/svg-animation/SKILL.md +9 -0
  731. package/skills/swiftui-expert/SKILL.md +9 -0
  732. package/skills/swiss-design/SKILL.md +8 -0
  733. package/skills/system-design-pro/SKILL.md +9 -0
  734. package/skills/systematic-debugging/SKILL.md +14 -0
  735. package/skills/tailwind-patterns/SKILL.md +9 -0
  736. package/skills/taste-skill/SKILL.md +9 -0
  737. package/skills/tdd-workflow/SKILL.md +9 -0
  738. package/skills/test-result-analyzer/SKILL.md +9 -0
  739. package/skills/testing-patterns/SKILL.md +8 -0
  740. package/skills/thermo-nuclear-code-quality-review/SKILL.md +11 -0
  741. package/skills/thinking-protocol/SKILL.md +10 -0
  742. package/skills/to-spring-or-not-to-spring/SKILL.md +9 -0
  743. package/skills/train-sentence-transformers/SKILL.md +10 -0
  744. package/skills/transformers-js/SKILL.md +8 -0
  745. package/skills/transitions-dev/SKILL.md +8 -0
  746. package/skills/trend-researcher/SKILL.md +9 -0
  747. package/skills/tribunal-instincts-memory/SKILL.md +11 -0
  748. package/skills/trl-training/SKILL.md +9 -0
  749. package/skills/typescript-advanced/SKILL.md +9 -0
  750. package/skills/typeset/SKILL.md +8 -0
  751. package/skills/ui-reasoning-engine/SKILL.md +9 -0
  752. package/skills/ui-skill-packs/SKILL.md +9 -0
  753. package/skills/ui-skills-root/SKILL.md +9 -0
  754. package/skills/ui-ux-pro-max/SKILL.md +9 -0
  755. package/skills/ui-ux-researcher/SKILL.md +8 -0
  756. package/skills/vector-search-pgvector/SKILL.md +10 -0
  757. package/skills/verification-before-completion/SKILL.md +9 -0
  758. package/skills/vue-expert/SKILL.md +9 -0
  759. package/skills/vulnerability-scanner/SKILL.md +9 -0
  760. package/skills/web-accessibility-auditor/SKILL.md +16 -0
  761. package/skills/web-design-guidelines/SKILL.md +9 -0
  762. package/skills/web-quality-audit/SKILL.md +10 -0
  763. package/skills/webapp-testing/SKILL.md +8 -0
  764. package/skills/webgpu-performance/SKILL.md +9 -0
  765. package/skills/whimsy-injector/SKILL.md +9 -0
  766. package/skills/workflow-optimizer/SKILL.md +9 -0
  767. package/skills/zero-trust-passkeys/SKILL.md +10 -0
  768. package/src/browser/index.js +2 -1
  769. package/src/browser/launcher.js +41 -1
  770. package/src/cli.js +21 -1
  771. package/src/commands/arch.js +261 -172
  772. package/src/commands/context.js +27 -8
  773. package/src/commands/init.js +538 -462
  774. package/src/commands/intelligence.js +86 -0
  775. package/src/commands/learn.js +21 -6
  776. package/src/commands/memory.js +10 -1
  777. package/src/commands/native.js +12 -3
  778. package/src/commands/review.js +235 -1
  779. package/src/commands/skill-intelligence.js +1165 -0
  780. package/src/commands/system1.js +562 -312
  781. package/src/context/ranker.js +337 -339
  782. package/src/evaluation/evaluation_runner.js +207 -0
  783. package/src/evaluation/scenario_registry.js +82 -0
  784. package/src/evolution/engine.js +296 -295
  785. package/src/execution/agent_correction_engine.js +76 -0
  786. package/src/execution/controlled_write_service.js +301 -0
  787. package/src/execution/correction_run_engine.js +234 -0
  788. package/src/execution/correction_verifier.js +85 -0
  789. package/src/execution/evidence_aggregator.js +54 -0
  790. package/src/execution/finding_diff_engine.js +59 -0
  791. package/src/execution/index.js +42 -0
  792. package/src/execution/prompt_isolator.js +145 -0
  793. package/src/execution/provider_adapter.js +495 -0
  794. package/src/execution/resolution_certificate.js +53 -0
  795. package/src/execution/resolution_policy.js +70 -0
  796. package/src/execution/review_executor.js +335 -0
  797. package/src/execution/reviewer_registry.js +137 -0
  798. package/src/execution/schemas.js +298 -0
  799. package/src/execution/transaction_manager.js +237 -0
  800. package/src/execution/validation_runner.js +174 -0
  801. package/src/execution/verdict_aggregator.js +181 -0
  802. package/src/execution/write_policy_engine.js +95 -0
  803. package/src/intelligence/adaptive_correction.js +72 -0
  804. package/src/intelligence/adaptive_reviewer_orchestrator.js +123 -0
  805. package/src/intelligence/case_indexer.js +166 -0
  806. package/src/intelligence/case_memory.js +149 -0
  807. package/src/intelligence/case_similarity.js +86 -0
  808. package/src/intelligence/cbr_engine.js +90 -0
  809. package/src/intelligence/evidence_optimization.js +106 -0
  810. package/src/intelligence/failure_intelligence.js +95 -0
  811. package/src/intelligence/governance_drift_detector.js +75 -0
  812. package/src/intelligence/governance_simulator.js +115 -0
  813. package/src/intelligence/human_intelligence.js +46 -0
  814. package/src/intelligence/mcp_tools.js +87 -0
  815. package/src/intelligence/reviewer_performance.js +94 -0
  816. package/src/intelligence/risk_prediction_engine.js +92 -0
  817. package/src/intelligence/token_intelligence.js +73 -0
  818. package/src/synthesis/claim_check_separator.js +294 -271
  819. package/src/system1/browser_intelligence.js +300 -0
  820. package/src/system1/constants.js +49 -0
  821. package/src/system1/decision_engine.js +498 -0
  822. package/src/system1/evidence_engine.js +602 -0
  823. package/src/system1/evolution_pipeline.js +581 -0
  824. package/src/system1/index.d.ts +114 -0
  825. package/src/system1/index.js +102 -0
  826. package/src/system1/reviewer_orchestrator.js +477 -0
  827. package/src/tui/banner.js +26 -47
  828. package/src/tui/index.js +4 -0
  829. package/src/tui/panel.js +55 -0
  830. package/src/tui/progress.js +42 -0
  831. package/src/tui/reviewer-grid.js +9 -10
  832. package/src/tui/theme.js +59 -16
  833. package/src/tui/tree.js +57 -29
  834. package/src/tui/wizard.js +22 -18
  835. package/src/utils/fs.js +27 -0
  836. package/.agent/skills/local-first-architecture/SKILL.md +0 -123
@@ -0,0 +1,1442 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * engineering_memory.js — Tribunal Kit Engineering Memory Engine (Phase 5)
4
+ * =========================================================================
5
+ * Implements the core operating principles:
6
+ * SOLVE ONCE.
7
+ * VERIFY ONCE.
8
+ * LEARN ONCE.
9
+ * REUSE SAFELY.
10
+ * MEMORY MUST EARN TRUST THROUGH EVIDENCE.
11
+ * CURRENT EVIDENCE > STALE MEMORY.
12
+ * MEMORY → HYPOTHESIS → CURRENT EVIDENCE → DECISION.
13
+ * FAILURES ARE KNOWLEDGE.
14
+ * NEGATIVE KNOWLEDGE IS KNOWLEDGE.
15
+ * DO NOT REPEAT VERIFIED FAILURES.
16
+ * DO NOT TRANSFER CONTEXT WITHOUT PROVING APPLICABILITY.
17
+ * DO NOT LET MEMORY OVERRIDE CURRENT EVIDENCE.
18
+ * DO NOT SILENTLY SELF-MODIFY.
19
+ */
20
+
21
+ 'use strict';
22
+
23
+ const fs = require('fs');
24
+ const path = require('path');
25
+ const crypto = require('crypto');
26
+
27
+ // ============================================================================
28
+ // 1. CONSTANTS, ENUMS & TAXONOMIES (SECTIONS 2, 4, 5, 22)
29
+ // ============================================================================
30
+
31
+ const MEMORY_TYPES = {
32
+ PATTERN: 'pattern',
33
+ FAILURE: 'failure',
34
+ DECISION: 'decision',
35
+ VERIFICATION: 'verification',
36
+ ANTI_PATTERN: 'anti_pattern',
37
+ SKILL_PERFORMANCE: 'skill_performance',
38
+ CONCEPT_RELATIONSHIP: 'concept_relationship',
39
+ CAPABILITY_GAP: 'capability_gap',
40
+ };
41
+
42
+ const PROVENANCE_TYPES = {
43
+ VERIFIED_IMPLEMENTATION: 'verified_implementation',
44
+ AUTOMATED_TEST: 'automated_test',
45
+ BENCHMARK: 'benchmark',
46
+ STATIC_ANALYSIS: 'static_analysis',
47
+ SECURITY_FINDING: 'security_finding',
48
+ PRODUCTION_INCIDENT: 'production_incident',
49
+ REPOSITORY_EVIDENCE: 'repository_evidence',
50
+ HUMAN_DECISION: 'human_decision',
51
+ EXTERNAL_DOCUMENTATION: 'external_documentation',
52
+ MODEL_INFERENCE: 'model_inference',
53
+ };
54
+
55
+ const TRUST_STATES = {
56
+ UNVERIFIED: 'UNVERIFIED',
57
+ OBSERVED: 'OBSERVED',
58
+ TESTED: 'TESTED',
59
+ VERIFIED: 'VERIFIED',
60
+ REPEATEDLY_VERIFIED: 'REPEATEDLY_VERIFIED',
61
+ CONTRADICTED: 'CONTRADICTED',
62
+ STALE: 'STALE',
63
+ RETIRED: 'RETIRED',
64
+ };
65
+
66
+ const TRUST_RANKS = {
67
+ RETIRED: 0,
68
+ CONTRADICTED: 0,
69
+ STALE: 1,
70
+ UNVERIFIED: 2,
71
+ OBSERVED: 3,
72
+ TESTED: 4,
73
+ VERIFIED: 5,
74
+ REPEATEDLY_VERIFIED: 6,
75
+ };
76
+
77
+ const MEMORY_SCOPES = {
78
+ GLOBAL: 'global',
79
+ PROJECT: 'project',
80
+ REPOSITORY: 'repository',
81
+ TASK: 'task',
82
+ };
83
+
84
+ // ============================================================================
85
+ // 2. PRIVACY, DATA MINIMIZATION & POISONING DEFENSE (SECTIONS 21 & 23)
86
+ // ============================================================================
87
+
88
+ const SENSITIVE_PATTERNS = [
89
+ /Bearer\s+[A-Za-z0-9_\-\.=:_+/]+/gi,
90
+ /eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}/g, // JWT
91
+ /\bsk-[A-Za-z0-9_-]{10,}\b/gi,
92
+ /\bkey-[A-Za-z0-9_-]{10,}\b/gi,
93
+ /(?:api[\s_-]?key|secret|password|passwd|auth[\s_-]?token|private[\s_-]?key)\s*[:=]\s*['"]?[A-Za-z0-9_\-\.!@#$%^&*]{6,}['"]?/gi,
94
+ /-----BEGIN\s+(?:RSA|EC|DSA|OPENSSH)?\s*PRIVATE\s+KEY-----[\s\S]*?-----END\s+(?:RSA|EC|DSA|OPENSSH)?\s*PRIVATE\s+KEY-----/gi,
95
+ /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/g, // Email PII
96
+ ];
97
+
98
+ const PROMPT_INJECTION_PATTERNS = [
99
+ /<system>[\s\S]*?<\/system>/gi,
100
+ /<script>[\s\S]*?<\/script>/gi,
101
+ /\[INST\][\s\S]*?\[\/INST\]/gi,
102
+ /ignore\s+(?:all\s+)?previous\s+instructions/gi,
103
+ /you\s+are\s+now\s+(?:an?\s+)?unrestricted/gi,
104
+ /override\s+system\s+prompt/gi,
105
+ /bypass\s+all\s+(?:guardrails|governance|verification)/gi,
106
+ ];
107
+
108
+ /**
109
+ * Sanitizes input text to eliminate secrets, PII, and prompt injections.
110
+ * Enforces strict data minimization.
111
+ *
112
+ * @param {string} text
113
+ * @returns {string} Sanitized string
114
+ */
115
+ function sanitizeContentAndEvidence(text) {
116
+ if (typeof text !== 'string') return '';
117
+ let sanitized = text;
118
+
119
+ // Redact secrets and credentials
120
+ for (const pat of SENSITIVE_PATTERNS) {
121
+ sanitized = sanitized.replace(pat, '[REDACTED_SECRET]');
122
+ }
123
+
124
+ // Strip prompt injection payloads
125
+ for (const pat of PROMPT_INJECTION_PATTERNS) {
126
+ sanitized = sanitized.replace(pat, '[BLOCKED_INJECTION_ATTEMPT]');
127
+ }
128
+
129
+ // Bounded length to prevent resource exhaustion / context stuffing
130
+ if (sanitized.length > 2500) {
131
+ sanitized = sanitized.slice(0, 2500) + '... [TRUNCATED]';
132
+ }
133
+
134
+ return sanitized.trim();
135
+ }
136
+
137
+ /**
138
+ * Validates a memory admission candidate for poisoning attempts and evidence gating.
139
+ *
140
+ * @param {Object} memoryRecord
141
+ * @returns {{ valid: boolean, sanitizedRecord: Object, reason: string|null }}
142
+ */
143
+ function validateMemoryAdmission(memoryRecord) {
144
+ if (!memoryRecord || typeof memoryRecord !== 'object') {
145
+ return { valid: false, sanitizedRecord: null, reason: 'Memory record must be an object' };
146
+ }
147
+
148
+ // Check required title / content
149
+ if (!memoryRecord.title || !memoryRecord.content) {
150
+ return { valid: false, sanitizedRecord: null, reason: 'Title and content are required' };
151
+ }
152
+
153
+ // Check for prompt injection attempts in title or content
154
+ const rawText = `${memoryRecord.title} ${memoryRecord.content}`;
155
+ for (const pat of PROMPT_INJECTION_PATTERNS) {
156
+ if (pat.test(rawText)) {
157
+ return {
158
+ valid: false,
159
+ sanitizedRecord: null,
160
+ reason: 'Memory admission rejected: Prompt injection vector detected',
161
+ };
162
+ }
163
+ }
164
+
165
+ // Provenance & Evidence Gating (Section 4 & 21)
166
+ // An unverified model inference cannot enter as VERIFIED or REPEATEDLY_VERIFIED
167
+ const provenance = memoryRecord.provenance || PROVENANCE_TYPES.MODEL_INFERENCE;
168
+ let status = memoryRecord.status || TRUST_STATES.UNVERIFIED;
169
+
170
+ const isEmpiricalProvenance = [
171
+ PROVENANCE_TYPES.AUTOMATED_TEST,
172
+ PROVENANCE_TYPES.BENCHMARK,
173
+ PROVENANCE_TYPES.VERIFIED_IMPLEMENTATION,
174
+ ].includes(provenance);
175
+ const hasEmpiricalEvidence =
176
+ (Array.isArray(memoryRecord.evidence) &&
177
+ memoryRecord.evidence.length > 0 &&
178
+ memoryRecord.evidence.some(e =>
179
+ [
180
+ PROVENANCE_TYPES.AUTOMATED_TEST,
181
+ PROVENANCE_TYPES.BENCHMARK,
182
+ PROVENANCE_TYPES.VERIFIED_IMPLEMENTATION,
183
+ ].includes(e.type || provenance),
184
+ )) ||
185
+ (isEmpiricalProvenance && (!memoryRecord.evidence || memoryRecord.evidence.length === 0));
186
+
187
+ if (
188
+ !hasEmpiricalEvidence &&
189
+ (status === TRUST_STATES.VERIFIED || status === TRUST_STATES.REPEATEDLY_VERIFIED)
190
+ ) {
191
+ // Downgrade to UNVERIFIED or OBSERVED
192
+ status = TRUST_STATES.OBSERVED;
193
+ }
194
+
195
+ // Sanitize content and evidence
196
+ const sanitizedRecord = {
197
+ ...memoryRecord,
198
+ title: sanitizeContentAndEvidence(memoryRecord.title),
199
+ content: sanitizeContentAndEvidence(memoryRecord.content),
200
+ status,
201
+ evidence: (memoryRecord.evidence || []).map(e => ({
202
+ ...e,
203
+ source: sanitizeContentAndEvidence(typeof e === 'string' ? e : e.source || e.detail || ''),
204
+ })),
205
+ };
206
+
207
+ return { valid: true, sanitizedRecord, reason: null };
208
+ }
209
+
210
+ // ============================================================================
211
+ // 3. CANONICAL MEMORY RECORD SCHEMA FACTORY (SECTION 3)
212
+ // ============================================================================
213
+
214
+ /**
215
+ * Creates a normalized memory record conforming to the canonical schema.
216
+ *
217
+ * @param {Object} params
218
+ * @returns {Object} Canonical memory record
219
+ */
220
+ function createMemoryRecord(params = {}) {
221
+ const now = new Date().toISOString();
222
+ const idSeed = `${params.type || 'mem'}_${params.title || ''}_${now}_${Math.random()}`;
223
+ const id =
224
+ params.id || `mem_${crypto.createHash('sha256').update(idSeed).digest('hex').slice(0, 12)}`;
225
+
226
+ const record = {
227
+ id,
228
+ type: params.type || MEMORY_TYPES.PATTERN,
229
+ title: params.title || 'Untitled Memory',
230
+ content: params.content || '',
231
+ concepts: Array.isArray(params.concepts) ? params.concepts : [],
232
+ domains: Array.isArray(params.domains) ? params.domains : [],
233
+ context: {
234
+ technologies: Array.isArray(params.context?.technologies) ? params.context.technologies : [],
235
+ architecture: params.context?.architecture || 'generic',
236
+ scale: params.context?.scale || 'standard',
237
+ workload: params.context?.workload || 'balanced',
238
+ scope: params.context?.scope || MEMORY_SCOPES.GLOBAL,
239
+ project_id: params.context?.project_id || null,
240
+ ...(params.context || {}),
241
+ },
242
+ evidence: Array.isArray(params.evidence) ? params.evidence : [],
243
+ source_task: params.source_task || 'system_initialization',
244
+ source_skill: params.source_skill || 'generic',
245
+ provenance: params.provenance || PROVENANCE_TYPES.VERIFIED_IMPLEMENTATION,
246
+ verification: {
247
+ strategy: params.verification?.strategy || 'Functional verification',
248
+ assertion: params.verification?.assertion || 'test_passes == true',
249
+ verified_at: params.verification?.verified_at || now,
250
+ ...(params.verification || {}),
251
+ },
252
+ confidence: params.confidence || 'HIGH', // HIGH, MEDIUM, LOW
253
+ applicability: {
254
+ applicable_when: Array.isArray(params.applicability?.applicable_when)
255
+ ? params.applicability.applicable_when
256
+ : ['General engineering application'],
257
+ not_applicable_when: Array.isArray(params.applicability?.not_applicable_when)
258
+ ? params.applicability.not_applicable_when
259
+ : [],
260
+ technologies: Array.isArray(params.applicability?.technologies)
261
+ ? params.applicability.technologies
262
+ : [],
263
+ constraints: Array.isArray(params.applicability?.constraints)
264
+ ? params.applicability.constraints
265
+ : [],
266
+ },
267
+ constraints: Array.isArray(params.constraints) ? params.constraints : [],
268
+ created_at: params.created_at || now,
269
+ last_verified_at: params.last_verified_at || now,
270
+ staleness_threshold_days: params.staleness_threshold_days || 180,
271
+ usage_count: params.usage_count || 0,
272
+ successful_usage_count: params.successful_usage_count || 0,
273
+ failed_usage_count: params.failed_usage_count || 0,
274
+ status: params.status || TRUST_STATES.VERIFIED,
275
+ conflicts: Array.isArray(params.conflicts) ? params.conflicts : [],
276
+ };
277
+
278
+ const validation = validateMemoryAdmission(record);
279
+ if (!validation.valid) {
280
+ throw new Error(`Invalid memory record: ${validation.reason}`);
281
+ }
282
+ return validation.sanitizedRecord;
283
+ }
284
+
285
+ // ============================================================================
286
+ // 4. CONTEXTUAL APPLICABILITY & ANTI-FALSE-TRANSFER (SECTION 6 & BENCHMARK 2)
287
+ // ============================================================================
288
+
289
+ /**
290
+ * Validates whether a memory is contextually applicable to a given task and context.
291
+ * Strictly prevents false transfer across disparate technologies or scales.
292
+ *
293
+ * @param {Object} memoryRecord
294
+ * @param {Object} currentContext
295
+ * @returns {{ applicable: boolean, score: number, reasons: string[] }}
296
+ */
297
+ function validateApplicability(memoryRecord, currentContext = {}) {
298
+ const reasons = [];
299
+ let score = 1.0;
300
+
301
+ if (!memoryRecord || !memoryRecord.applicability) {
302
+ return { applicable: true, score: 0.5, reasons: ['Default applicability (unconstrained)'] };
303
+ }
304
+
305
+ // 1. Cross-Project Isolation Check (Section 22 & Benchmark 8)
306
+ const memScope = memoryRecord.context?.scope || MEMORY_SCOPES.GLOBAL;
307
+ if (memScope === MEMORY_SCOPES.PROJECT || memScope === MEMORY_SCOPES.REPOSITORY) {
308
+ const memProjectId = memoryRecord.context?.project_id;
309
+ const currentProjectId = currentContext.project_id || currentContext.projectId;
310
+ if (memProjectId && currentProjectId && memProjectId !== currentProjectId) {
311
+ return {
312
+ applicable: false,
313
+ score: 0.0,
314
+ reasons: [
315
+ `Cross-project isolation boundary: Memory belongs to project '${memProjectId}', current is '${currentProjectId}'`,
316
+ ],
317
+ };
318
+ }
319
+ if (memProjectId && !currentProjectId) {
320
+ return {
321
+ applicable: false,
322
+ score: 0.0,
323
+ reasons: [
324
+ `Cross-project isolation boundary: Memory requires specific project context '${memProjectId}'`,
325
+ ],
326
+ };
327
+ }
328
+ }
329
+
330
+ const taskText = (currentContext.task || currentContext.query || '').toLowerCase();
331
+ const currentTechs = (currentContext.technologies || []).map(t => t.toLowerCase());
332
+ const currentScale = (currentContext.scale || 'standard').toLowerCase();
333
+ const currentWorkload = (currentContext.workload || 'balanced').toLowerCase();
334
+
335
+ // 2. Negative Applicability Triggers ("not_applicable_when")
336
+ const notWhen = memoryRecord.applicability.not_applicable_when || [];
337
+ for (const condition of notWhen) {
338
+ const condLower = condition.toLowerCase();
339
+
340
+ // Check tiny workload / single-node / embedded checks
341
+ if (
342
+ (condLower.includes('tiny workload') ||
343
+ condLower.includes('low traffic') ||
344
+ condLower.includes('small scale')) &&
345
+ (currentScale === 'small' ||
346
+ taskText.includes('small') ||
347
+ taskText.includes('simple cli') ||
348
+ taskText.includes('single user'))
349
+ ) {
350
+ reasons.push(`Violates condition: ${condition}`);
351
+ return { applicable: false, score: 0.0, reasons };
352
+ }
353
+
354
+ // Check zero-staleness / strong freshness requirement
355
+ if (
356
+ (condLower.includes('zero-staleness') ||
357
+ condLower.includes('zero staleness') ||
358
+ condLower.includes('freshness requirement')) &&
359
+ (taskText.includes('zero staleness') ||
360
+ taskText.includes('zero-staleness') ||
361
+ taskText.includes('strict freshness') ||
362
+ taskText.includes('no staleness') ||
363
+ currentContext.strict_freshness)
364
+ ) {
365
+ reasons.push(`Violates condition: ${condition}`);
366
+ return { applicable: false, score: 0.0, reasons };
367
+ }
368
+
369
+ // Check in-memory / local CLI vs shared infrastructure
370
+ if (
371
+ (condLower.includes('no shared cache') ||
372
+ condLower.includes('embedded') ||
373
+ condLower.includes('local cli')) &&
374
+ (currentTechs.includes('sqlite') ||
375
+ taskText.includes('embedded') ||
376
+ taskText.includes('cli tool'))
377
+ ) {
378
+ reasons.push(`Violates condition: ${condition}`);
379
+ return { applicable: false, score: 0.0, reasons };
380
+ }
381
+
382
+ // Check read-only queries vs mutations
383
+ if (
384
+ condLower.includes('read-only') &&
385
+ (taskText.startsWith('read') ||
386
+ taskText.startsWith('get ') ||
387
+ taskText.includes('fetch only'))
388
+ ) {
389
+ reasons.push(`Violates condition: ${condition}`);
390
+ return { applicable: false, score: 0.0, reasons };
391
+ }
392
+ }
393
+
394
+ // 3. Technology Alignment
395
+ const appTechs = (memoryRecord.applicability.technologies || []).map(t => t.toLowerCase());
396
+ if (appTechs.length > 0 && currentTechs.length > 0) {
397
+ const hasTechMatch = currentTechs.some(ct => appTechs.includes(ct));
398
+ if (!hasTechMatch) {
399
+ score *= 0.5;
400
+ reasons.push(
401
+ `Technology divergence: Memory tailored for [${appTechs.join(', ')}], task uses [${currentTechs.join(', ')}]`,
402
+ );
403
+ } else {
404
+ score *= 1.2;
405
+ reasons.push(
406
+ `Technology match confirmed: [${currentTechs.filter(ct => appTechs.includes(ct)).join(', ')}]`,
407
+ );
408
+ }
409
+ }
410
+
411
+ // 4. Positive Applicability Triggers ("applicable_when")
412
+ const appWhen = memoryRecord.applicability.applicable_when || [];
413
+ let positiveMatches = 0;
414
+ for (const condition of appWhen) {
415
+ const cLower = condition.toLowerCase();
416
+ const words = cLower.split(/\s+/).filter(w => w.length > 3);
417
+ const matches = words.filter(w => taskText.includes(w)).length;
418
+ if (matches >= 2 || (words.length <= 2 && matches >= 1)) {
419
+ positiveMatches++;
420
+ }
421
+ }
422
+
423
+ if (
424
+ appWhen.length > 0 &&
425
+ positiveMatches === 0 &&
426
+ !taskText.includes(memoryRecord.title.toLowerCase())
427
+ ) {
428
+ score *= 0.6;
429
+ reasons.push('Weak alignment with positive applicability conditions');
430
+ } else if (positiveMatches > 0) {
431
+ score *= 1.0 + positiveMatches * 0.15;
432
+ reasons.push(`Satisfies ${positiveMatches} positive applicability criteria`);
433
+ }
434
+
435
+ const isApplicable = score >= 0.4;
436
+ return {
437
+ applicable: isApplicable,
438
+ score: Math.min(score, 2.0),
439
+ reasons: reasons.length > 0 ? reasons : ['Applicable under general criteria'],
440
+ };
441
+ }
442
+
443
+ // ============================================================================
444
+ // 5. STALENESS & DECAY EVALUATOR (SECTION 16 & BENCHMARK 5)
445
+ // ============================================================================
446
+
447
+ /**
448
+ * Evaluates whether a memory is stale based on elapsed time or runtime drift.
449
+ *
450
+ * @param {Object} memoryRecord
451
+ * @param {Object} envContext
452
+ * @returns {{ isStale: boolean, ageDays: number, reason: string|null }}
453
+ */
454
+ function evaluateMemoryStaleness(memoryRecord, envContext = {}) {
455
+ if (!memoryRecord) return { isStale: false, ageDays: 0, reason: null };
456
+
457
+ const lastVerified = new Date(
458
+ memoryRecord.last_verified_at || memoryRecord.created_at || Date.now(),
459
+ );
460
+ const now = new Date(envContext.currentDate || Date.now());
461
+ const ageMs = Math.max(0, now.getTime() - lastVerified.getTime());
462
+ const ageDays = Math.floor(ageMs / (1000 * 60 * 60 * 24));
463
+ const thresholdDays = memoryRecord.staleness_threshold_days || 180;
464
+
465
+ // Age-based staleness
466
+ if (ageDays > thresholdDays) {
467
+ return {
468
+ isStale: true,
469
+ ageDays,
470
+ reason: `Memory exceeds staleness threshold (${ageDays} days > ${thresholdDays} days). Requires fresh verification.`,
471
+ };
472
+ }
473
+
474
+ // Framework / Environment Version Drift (e.g. Next.js 12 Pages vs Next.js 14 App Router)
475
+ const memTechVersion = memoryRecord.context?.framework_version;
476
+ const currentTechVersion = envContext.framework_version;
477
+ if (memTechVersion && currentTechVersion && memTechVersion !== currentTechVersion) {
478
+ return {
479
+ isStale: true,
480
+ ageDays,
481
+ reason: `Runtime framework mismatch: Memory verified on v${memTechVersion}, current environment is v${currentTechVersion}`,
482
+ };
483
+ }
484
+
485
+ return { isStale: false, ageDays, reason: null };
486
+ }
487
+
488
+ // ============================================================================
489
+ // 6. MEMORY AS A HYPOTHESIS & CONTRADICTORY EVIDENCE (SECTIONS 8, 9, 24 & BENCHMARK 4)
490
+ // ============================================================================
491
+
492
+ /**
493
+ * Compares a memory hypothesis against current empirical execution evidence.
494
+ * If evidence contradicts the memory, the memory is marked CONTRADICTED, never silently overwritten.
495
+ *
496
+ * @param {Object} memoryRecord
497
+ * @param {Object} currentEvidence
498
+ * @param {Object} currentContext
499
+ * @returns {Object} Evaluation outcome
500
+ */
501
+ function evaluateMemoryHypothesisWithCurrentEvidence(
502
+ memoryRecord,
503
+ currentEvidence = {},
504
+ currentContext = {},
505
+ ) {
506
+ if (!memoryRecord) throw new Error('Memory record required');
507
+
508
+ const now = new Date().toISOString();
509
+ const evaluation = {
510
+ memory_id: memoryRecord.id,
511
+ hypothesis: memoryRecord.title,
512
+ current_evidence_strength: currentEvidence.strength || 'STRONG',
513
+ verified: false,
514
+ contradicted: false,
515
+ decision: 'PROCEED',
516
+ rationale: '',
517
+ };
518
+
519
+ // Check if current test or benchmark failed
520
+ const testResults = currentEvidence.test_results || [];
521
+ const benchmarkResults = currentEvidence.benchmark_results || {};
522
+ const hasFailedTest = testResults.some(t => t.status === 'FAIL' || t.passed === false);
523
+ const hasRegression =
524
+ benchmarkResults.has_regression || benchmarkResults.latency_regression === true;
525
+
526
+ if (hasFailedTest || hasRegression || currentEvidence.contradiction_detected) {
527
+ // Current evidence refutes historical memory!
528
+ memoryRecord.status = TRUST_STATES.CONTRADICTED;
529
+ memoryRecord.failed_usage_count = (memoryRecord.failed_usage_count || 0) + 1;
530
+ memoryRecord.usage_count = (memoryRecord.usage_count || 0) + 1;
531
+ memoryRecord.last_verified_at = now;
532
+
533
+ if (!Array.isArray(memoryRecord.evidence)) memoryRecord.evidence = [];
534
+ memoryRecord.evidence.push({
535
+ type: PROVENANCE_TYPES.BENCHMARK,
536
+ source: `Current empirical execution refuted hypothesis: ${currentEvidence.failure_reason || 'Benchmark regression detected'}`,
537
+ recorded_at: now,
538
+ });
539
+
540
+ evaluation.contradicted = true;
541
+ evaluation.verified = false;
542
+ evaluation.decision = 'REJECT_MEMORY_ADOPT_CURRENT_EVIDENCE';
543
+ evaluation.rationale = `Current empirical evidence contradicts memory '${memoryRecord.title}'. Prioritizing current evidence over historical assumption.`;
544
+ return evaluation;
545
+ }
546
+
547
+ // Current evidence confirms memory!
548
+ memoryRecord.successful_usage_count = (memoryRecord.successful_usage_count || 0) + 1;
549
+ memoryRecord.usage_count = (memoryRecord.usage_count || 0) + 1;
550
+ memoryRecord.last_verified_at = now;
551
+
552
+ if (memoryRecord.successful_usage_count >= 3 && memoryRecord.status === TRUST_STATES.VERIFIED) {
553
+ memoryRecord.status = TRUST_STATES.REPEATEDLY_VERIFIED;
554
+ } else if (
555
+ memoryRecord.status === TRUST_STATES.OBSERVED ||
556
+ memoryRecord.status === TRUST_STATES.UNVERIFIED
557
+ ) {
558
+ memoryRecord.status = TRUST_STATES.VERIFIED;
559
+ }
560
+
561
+ evaluation.verified = true;
562
+ evaluation.contradicted = false;
563
+ evaluation.decision = 'PROMOTE_MEMORY_TO_DECISION';
564
+ evaluation.rationale = `Current empirical evidence corroborated memory '${memoryRecord.title}'. Promoted to active decision.`;
565
+ return evaluation;
566
+ }
567
+
568
+ /**
569
+ * Resolves architectural conflicts by maintaining contextual variants rather than overwriting.
570
+ * (Section 9)
571
+ *
572
+ * @param {EngineeringMemoryStore} store
573
+ * @param {Object} memoryA
574
+ * @param {Object} memoryB
575
+ * @param {string} resolutionExplanation
576
+ * @returns {void}
577
+ */
578
+ function recordConflictResolution(store, memoryA, memoryB, resolutionExplanation) {
579
+ if (!memoryA || !memoryB) return;
580
+
581
+ const conflictRecordA = {
582
+ conflicting_memory_id: memoryB.id,
583
+ conflicting_title: memoryB.title,
584
+ differentiator: resolutionExplanation || 'Contrasting workload or infrastructure requirements',
585
+ recorded_at: new Date().toISOString(),
586
+ };
587
+
588
+ const conflictRecordB = {
589
+ conflicting_memory_id: memoryA.id,
590
+ conflicting_title: memoryA.title,
591
+ differentiator: resolutionExplanation || 'Contrasting workload or infrastructure requirements',
592
+ recorded_at: new Date().toISOString(),
593
+ };
594
+
595
+ memoryA.conflicts = memoryA.conflicts || [];
596
+ memoryA.conflicts.push(conflictRecordA);
597
+
598
+ memoryB.conflicts = memoryB.conflicts || [];
599
+ memoryB.conflicts.push(conflictRecordB);
600
+
601
+ store.update(memoryA);
602
+ store.update(memoryB);
603
+ }
604
+
605
+ // ============================================================================
606
+ // 7. MEMORY GRAPH (SECTION 19)
607
+ // ============================================================================
608
+
609
+ /**
610
+ * Relational engineering graph connecting:
611
+ * CONCEPT → CONSIDERATION → FAILURE → SKILL → VERIFICATION → DECISION → OUTCOME
612
+ */
613
+ class MemoryGraph {
614
+ constructor() {
615
+ this.nodes = new Map(); // id -> { id, type, label, data }
616
+ this.edges = []; // { from, to, relation, weight }
617
+ }
618
+
619
+ addNode(id, type, label, data = {}) {
620
+ this.nodes.set(id, { id, type, label, data });
621
+ }
622
+
623
+ addEdge(from, to, relation, weight = 1.0) {
624
+ this.edges.push({ from, to, relation, weight });
625
+ }
626
+
627
+ getNeighbors(nodeId, relation = null) {
628
+ return this.edges
629
+ .filter(e => e.from === nodeId && (!relation || e.relation === relation))
630
+ .map(e => ({ node: this.nodes.get(e.to), edge: e }));
631
+ }
632
+
633
+ /**
634
+ * Explores the engineering graph starting from active concepts to surface
635
+ * linked failures, required considerations, skills, and verification plans.
636
+ *
637
+ * @param {string[]} conceptIds
638
+ * @returns {Object} Graph traversal results
639
+ */
640
+ traverseFromConcepts(conceptIds = []) {
641
+ const visitedNodes = new Set();
642
+ const failures = [];
643
+ const skills = [];
644
+ const verifications = [];
645
+ const decisions = [];
646
+
647
+ for (const cId of conceptIds) {
648
+ visitedNodes.add(cId);
649
+ const outgoing = this.edges.filter(e => e.from === cId || e.to === cId);
650
+ for (const edge of outgoing) {
651
+ const targetId = edge.from === cId ? edge.to : edge.from;
652
+ if (!visitedNodes.has(targetId)) {
653
+ visitedNodes.add(targetId);
654
+ const node = this.nodes.get(targetId);
655
+ if (node) {
656
+ if (node.type === MEMORY_TYPES.FAILURE || node.type === MEMORY_TYPES.ANTI_PATTERN)
657
+ failures.push(node);
658
+ else if (node.type === 'skill') skills.push(node);
659
+ else if (node.type === MEMORY_TYPES.VERIFICATION) verifications.push(node);
660
+ else if (node.type === MEMORY_TYPES.DECISION) decisions.push(node);
661
+ }
662
+ }
663
+ }
664
+ }
665
+
666
+ return { failures, skills, verifications, decisions };
667
+ }
668
+ }
669
+
670
+ // ============================================================================
671
+ // 8. VERIFICATION STRATEGY SEED & RETRIEVAL (SECTION 12)
672
+ // ============================================================================
673
+
674
+ const SEED_VERIFICATION_STRATEGIES = [
675
+ {
676
+ id: 'ver_idempotency_storm',
677
+ type: MEMORY_TYPES.VERIFICATION,
678
+ title: 'Concurrent Duplicate Request Storm (Idempotency Proof)',
679
+ content:
680
+ 'Dispatches 100 parallel identical requests with identical idempotency keys against target endpoint.',
681
+ concepts: ['idempotency', 'financial-transaction', 'concurrency-control'],
682
+ domains: ['api', 'database'],
683
+ verification: {
684
+ strategy: 'Parallel HTTP storm with identical Idempotency-Key header',
685
+ assertion:
686
+ 'count(database_mutations) === 1 && duplicate_http_responses.every(r => [200, 201, 409].includes(r.status))',
687
+ expected_outcome: 'Exactly one state-changing record committed, zero double charges.',
688
+ },
689
+ provenance: PROVENANCE_TYPES.AUTOMATED_TEST,
690
+ status: TRUST_STATES.REPEATEDLY_VERIFIED,
691
+ confidence: 'HIGH',
692
+ },
693
+ {
694
+ id: 'ver_rate_limit_burst',
695
+ type: MEMORY_TYPES.VERIFICATION,
696
+ title: 'Burst Exceeding Threshold Test (Rate Limiting Proof)',
697
+ content: 'Dispatches N+50 requests within 1-second window against bucket capacity N.',
698
+ concepts: ['rate-limiting', 'ddos-defense', 'traffic-shaping'],
699
+ domains: ['api', 'security'],
700
+ verification: {
701
+ strategy: 'Token bucket exhaustion burst generator',
702
+ assertion:
703
+ 'rejected_requests.status === 429 && rejected_requests.headers["retry-after"] !== undefined',
704
+ expected_outcome:
705
+ 'Deterministic 429 Too Many Requests response with RFC compliant Retry-After.',
706
+ },
707
+ provenance: PROVENANCE_TYPES.AUTOMATED_TEST,
708
+ status: TRUST_STATES.REPEATEDLY_VERIFIED,
709
+ confidence: 'HIGH',
710
+ },
711
+ {
712
+ id: 'ver_failover_fault_injection',
713
+ type: MEMORY_TYPES.VERIFICATION,
714
+ title: 'Dependency Fault Injection (Failover & Resilience Proof)',
715
+ content:
716
+ 'Simulates network partition / timeout on downstream dependency; verifies circuit breaker opens.',
717
+ concepts: ['retry-and-backoff', 'circuit-breaker', 'high-availability'],
718
+ domains: ['distributed-systems', 'backend'],
719
+ verification: {
720
+ strategy: 'Downstream latency & 500 error injection mock',
721
+ assertion:
722
+ 'circuit_state === "OPEN" && fallback_invoked === true && cascade_failure === false',
723
+ expected_outcome:
724
+ 'Graceful fallback response returned within 50ms without exhausting connection threads.',
725
+ },
726
+ provenance: PROVENANCE_TYPES.AUTOMATED_TEST,
727
+ status: TRUST_STATES.REPEATEDLY_VERIFIED,
728
+ confidence: 'HIGH',
729
+ },
730
+ {
731
+ id: 'ver_acid_rollback_mid_operation',
732
+ type: MEMORY_TYPES.VERIFICATION,
733
+ title: 'Atomic Rollback on Error Test (ACID Integrity Proof)',
734
+ content:
735
+ 'Injects unhandled failure immediately before transaction commit after ledger mutation.',
736
+ concepts: ['transaction-integrity', 'database-design'],
737
+ domains: ['database', 'backend'],
738
+ verification: {
739
+ strategy: 'Mid-transaction chaos injection',
740
+ assertion: 'select count(*) from ledger_entries where tx_id = injected_id === 0',
741
+ expected_outcome: 'Zero partial rows committed to database on error.',
742
+ },
743
+ provenance: PROVENANCE_TYPES.AUTOMATED_TEST,
744
+ status: TRUST_STATES.REPEATEDLY_VERIFIED,
745
+ confidence: 'HIGH',
746
+ },
747
+ {
748
+ id: 'ver_ssrf_magic_bytes',
749
+ type: MEMORY_TYPES.VERIFICATION,
750
+ title: 'SSRF & Magic-Byte Boundary Verification',
751
+ content:
752
+ 'Probes file upload endpoint with AWS metadata (169.254.169.254) and spoofed MIME headers.',
753
+ concepts: ['file-upload-and-storage', 'api-security-auditor'],
754
+ domains: ['security', 'api'],
755
+ verification: {
756
+ strategy: 'Blacklist/whitelist metadata probe and binary stream validation',
757
+ assertion: 'private_ip_requests_blocked === true && mime_spoof_rejected === true',
758
+ expected_outcome: 'Immediate 400/403 rejection before disk buffering.',
759
+ },
760
+ provenance: PROVENANCE_TYPES.SECURITY_FINDING,
761
+ status: TRUST_STATES.REPEATEDLY_VERIFIED,
762
+ confidence: 'HIGH',
763
+ },
764
+ ];
765
+
766
+ // ============================================================================
767
+ // 9. NEGATIVE KNOWLEDGE & FAILURE SEEDS (SECTIONS 10 & 11)
768
+ // ============================================================================
769
+
770
+ const SEED_FAILURE_MEMORIES = [
771
+ {
772
+ id: 'fail_process_local_mutex',
773
+ type: MEMORY_TYPES.ANTI_PATTERN,
774
+ title: 'Process-Local Mutex in Multi-Instance Deployment',
775
+ content:
776
+ 'Using in-memory locks (like async-lock or local mutex) fails completely when multiple application replicas run behind a load balancer.',
777
+ concepts: ['concurrency-control', 'distributed-systems'],
778
+ domains: ['backend', 'distributed-systems'],
779
+ context: { architecture: 'multi-instance', scale: 'distributed' },
780
+ evidence: [
781
+ {
782
+ type: PROVENANCE_TYPES.PRODUCTION_INCIDENT,
783
+ source:
784
+ 'Concurrent payment duplicate charges occurred across Pod A and Pod B despite in-memory mutex.',
785
+ },
786
+ ],
787
+ failure: {
788
+ cause:
789
+ 'Process-local memory is isolated across horizontal containers; requests hitting different nodes bypass lock.',
790
+ detection_method: 'Multi-node concurrent integration test',
791
+ impact: 'CRITICAL: Double financial charges, race condition data corruption',
792
+ affected_concepts: ['concurrency-control', 'financial-transaction'],
793
+ fix: 'Use PostgreSQL advisory locks, Redis Redlock, or atomic database uniqueness constraints.',
794
+ verification:
795
+ 'Concurrent requests routed to separate server processes produce exactly one mutation.',
796
+ regression_risk:
797
+ 'High if distributed locking introduces single point of failure or latency overhead.',
798
+ },
799
+ provenance: PROVENANCE_TYPES.PRODUCTION_INCIDENT,
800
+ status: TRUST_STATES.REPEATEDLY_VERIFIED,
801
+ confidence: 'HIGH',
802
+ applicability: {
803
+ applicable_when: [
804
+ 'Multi-node, clustered, or containerized deployments with horizontal scaling',
805
+ ],
806
+ not_applicable_when: ['Strictly single-process standalone CLI applications running locally'],
807
+ },
808
+ },
809
+ {
810
+ id: 'fail_naive_retry_side_effects',
811
+ type: MEMORY_TYPES.FAILURE,
812
+ title: 'Naive HTTP Retry Without Idempotency (Amplification & Duplication)',
813
+ content:
814
+ 'Retrying non-idempotent POST/PATCH mutations on network timeouts multiplies downstream side-effects.',
815
+ concepts: ['retry-and-backoff', 'idempotency', 'financial-transaction'],
816
+ domains: ['api', 'network'],
817
+ failure: {
818
+ cause:
819
+ 'Network timeouts frequently occur on response delivery after server has already processed mutation.',
820
+ detection_method: 'Simulated 504 Gateway Timeout during charge execution',
821
+ impact: 'CRITICAL: Duplicate customer charges and webhook storm',
822
+ affected_concepts: ['retry-and-backoff', 'idempotency'],
823
+ fix: 'Require client-provided Idempotency-Key and enforce unique database constraint.',
824
+ verification: '10 simulated timeout retries yield identical response and single transaction.',
825
+ regression_risk: 'Storage growth of cached idempotency keys.',
826
+ },
827
+ provenance: PROVENANCE_TYPES.AUTOMATED_TEST,
828
+ status: TRUST_STATES.REPEATEDLY_VERIFIED,
829
+ confidence: 'HIGH',
830
+ applicability: {
831
+ applicable_when: ['Network calls invoking state-changing operations'],
832
+ not_applicable_when: ['Idempotent read operations (GET)'],
833
+ },
834
+ },
835
+ {
836
+ id: 'fail_unbounded_cache_staleness',
837
+ type: MEMORY_TYPES.ANTI_PATTERN,
838
+ title: 'Aggressive Shared Caching on Real-Time Critical State',
839
+ content:
840
+ 'Applying Redis cache without explicit invalidation or TTL to rapidly mutating data causes severe staleness violations.',
841
+ concepts: ['caching', 'data-freshness'],
842
+ domains: ['database', 'api'],
843
+ failure: {
844
+ cause: 'Cached reads serve stale price or inventory balance after concurrent update.',
845
+ detection_method: 'Read-after-write consistency audit',
846
+ impact: 'HIGH: Overselling inventory or stale authorization token acceptance',
847
+ affected_concepts: ['caching', 'data-freshness'],
848
+ fix: 'Cache only expensive immutable data, or use transactional write-through with explicit pub/sub invalidation.',
849
+ verification: 'Read immediately following write returns updated entity.',
850
+ regression_risk: 'Cache stampede if invalidation is too aggressive.',
851
+ },
852
+ provenance: PROVENANCE_TYPES.BENCHMARK,
853
+ status: TRUST_STATES.VERIFIED,
854
+ confidence: 'HIGH',
855
+ applicability: {
856
+ applicable_when: ['Shared caching layer (Redis/Memcached) applied to database models'],
857
+ not_applicable_when: ['Static assets, CDN edge caching of versioned files'],
858
+ },
859
+ },
860
+ ];
861
+
862
+ // ============================================================================
863
+ // 10. REUSABLE PATTERN & DECISION SEEDS (SECTIONS 2 & 9)
864
+ // ============================================================================
865
+
866
+ const SEED_PATTERN_MEMORIES = [
867
+ {
868
+ id: 'pat_idempotent_mutation',
869
+ type: MEMORY_TYPES.PATTERN,
870
+ title: 'Idempotency Key & Transactional Boundary Pattern',
871
+ content:
872
+ 'Client-provided unique token stored with status in database transaction ensures at-most-once execution under retry storms.',
873
+ concepts: [
874
+ 'idempotency',
875
+ 'financial-transaction',
876
+ 'transaction-integrity',
877
+ 'concurrency-control',
878
+ ],
879
+ domains: ['api', 'database', 'finance'],
880
+ provenance: PROVENANCE_TYPES.VERIFIED_IMPLEMENTATION,
881
+ status: TRUST_STATES.REPEATEDLY_VERIFIED,
882
+ confidence: 'HIGH',
883
+ context: {
884
+ architecture: 'distributed-services',
885
+ technologies: ['postgresql', 'redis', 'node', 'express'],
886
+ scope: MEMORY_SCOPES.GLOBAL,
887
+ },
888
+ applicability: {
889
+ applicable_when: [
890
+ 'State-changing financial mutation or order creation',
891
+ 'External clients experiencing potential network retries',
892
+ ],
893
+ not_applicable_when: [
894
+ 'Read-only queries',
895
+ 'Simple in-memory CLI scripts without shared database',
896
+ 'Tiny workload where duplicate requests are impossible',
897
+ ],
898
+ technologies: ['postgresql', 'mysql', 'mongodb', 'redis', 'dynamodb'],
899
+ },
900
+ },
901
+ {
902
+ id: 'pat_redis_read_cache',
903
+ type: MEMORY_TYPES.PATTERN,
904
+ title: 'Redis Shared Caching for Expensive Read Computations',
905
+ content:
906
+ 'Caches query results with fixed TTL and key hashing to relieve database read pressure.',
907
+ concepts: ['caching', 'query-optimization', 'latency-budget'],
908
+ domains: ['database', 'performance'],
909
+ provenance: PROVENANCE_TYPES.BENCHMARK,
910
+ status: TRUST_STATES.VERIFIED,
911
+ confidence: 'HIGH',
912
+ context: {
913
+ architecture: 'distributed-cache',
914
+ technologies: ['redis', 'postgresql'],
915
+ scale: 'high-read-volume',
916
+ scope: MEMORY_SCOPES.GLOBAL,
917
+ },
918
+ applicability: {
919
+ applicable_when: [
920
+ 'High read frequency exceeding 1000 QPS',
921
+ 'Repeated expensive computation or complex SQL joins',
922
+ 'Acceptable staleness window (e.g. 5 to 60 seconds)',
923
+ ],
924
+ not_applicable_when: [
925
+ 'Tiny workload or single-instance application',
926
+ 'Strong zero-staleness requirement (financial balances)',
927
+ 'Embedded standalone CLI with no external Redis infrastructure',
928
+ ],
929
+ technologies: ['redis', 'memcached'],
930
+ },
931
+ },
932
+ {
933
+ id: 'dec_postgres_advisory_lock',
934
+ type: MEMORY_TYPES.DECISION,
935
+ title: 'PostgreSQL Advisory Lock for Multi-Instance Entity Serialization',
936
+ content:
937
+ 'PostgreSQL transaction-level advisory lock (pg_advisory_xact_lock) selected because horizontal container replicas rendered local mutexes insufficient.',
938
+ concepts: ['concurrency-control', 'database-design'],
939
+ domains: ['database', 'backend'],
940
+ provenance: PROVENANCE_TYPES.VERIFIED_IMPLEMENTATION,
941
+ status: TRUST_STATES.REPEATEDLY_VERIFIED,
942
+ confidence: 'HIGH',
943
+ context: {
944
+ architecture: 'multi-instance',
945
+ workload: 'high-write-collision',
946
+ technologies: ['postgresql'],
947
+ scope: MEMORY_SCOPES.GLOBAL,
948
+ },
949
+ applicability: {
950
+ applicable_when: [
951
+ 'PostgreSQL database is primary datastore',
952
+ 'High collision probability on entity mutation across horizontal instances',
953
+ ],
954
+ not_applicable_when: [
955
+ 'High-read low-contention workload where optimistic locking is superior',
956
+ 'Non-relational databases (MongoDB, DynamoDB)',
957
+ ],
958
+ technologies: ['postgresql'],
959
+ },
960
+ },
961
+ {
962
+ id: 'dec_optimistic_concurrency_versioning',
963
+ type: MEMORY_TYPES.DECISION,
964
+ title: 'Optimistic Concurrency Control via Version Column',
965
+ content:
966
+ 'Version-based optimistic locking (WHERE id = ? AND version = ?) selected for high-read low-contention workloads to avoid database lock contention.',
967
+ concepts: ['concurrency-control', 'database-design'],
968
+ domains: ['database', 'performance'],
969
+ provenance: PROVENANCE_TYPES.BENCHMARK,
970
+ status: TRUST_STATES.REPEATEDLY_VERIFIED,
971
+ confidence: 'HIGH',
972
+ context: {
973
+ architecture: 'distributed',
974
+ workload: 'high-read-low-contention',
975
+ technologies: ['postgresql', 'mysql'],
976
+ scope: MEMORY_SCOPES.GLOBAL,
977
+ },
978
+ applicability: {
979
+ applicable_when: [
980
+ 'Read-heavy workloads with infrequent concurrent collisions',
981
+ 'Minimizing database row-level lock hold time',
982
+ ],
983
+ not_applicable_when: [
984
+ 'High burst collision rates where retry storm degrades throughput',
985
+ 'Multi-entity cross-table atomic transactions',
986
+ ],
987
+ },
988
+ },
989
+ ];
990
+
991
+ // ============================================================================
992
+ // 11. ENGINEERING MEMORY STORE (SECTION 22: ISOLATION & PERSISTENCE)
993
+ // ============================================================================
994
+
995
+ class EngineeringMemoryStore {
996
+ constructor(options = {}) {
997
+ this.storagePath = options.storagePath || null;
998
+ this.memories = new Map(); // id -> record
999
+ this.graph = new MemoryGraph();
1000
+ this.initSeeds();
1001
+ }
1002
+
1003
+ initSeeds() {
1004
+ const allSeeds = [
1005
+ ...SEED_PATTERN_MEMORIES,
1006
+ ...SEED_FAILURE_MEMORIES,
1007
+ ...SEED_VERIFICATION_STRATEGIES,
1008
+ ];
1009
+
1010
+ for (const s of allSeeds) {
1011
+ const rec = createMemoryRecord(s);
1012
+ this.memories.set(rec.id, rec);
1013
+ this.graph.addNode(rec.id, rec.type, rec.title, rec);
1014
+
1015
+ // Connect concepts to memory in graph
1016
+ for (const c of rec.concepts || []) {
1017
+ this.graph.addNode(c, 'concept', c);
1018
+ this.graph.addEdge(c, rec.id, 'informed_by');
1019
+ }
1020
+ }
1021
+ }
1022
+
1023
+ add(record) {
1024
+ const canonical = createMemoryRecord(record);
1025
+ this.memories.set(canonical.id, canonical);
1026
+ this.graph.addNode(canonical.id, canonical.type, canonical.title, canonical);
1027
+
1028
+ for (const c of canonical.concepts || []) {
1029
+ this.graph.addNode(c, 'concept', c);
1030
+ this.graph.addEdge(c, canonical.id, 'informed_by');
1031
+ }
1032
+ return canonical;
1033
+ }
1034
+
1035
+ update(record) {
1036
+ if (!record || !record.id) return;
1037
+ this.memories.set(record.id, record);
1038
+ this.graph.addNode(record.id, record.type, record.title, record);
1039
+ }
1040
+
1041
+ get(id) {
1042
+ return this.memories.get(id) || null;
1043
+ }
1044
+
1045
+ getAll() {
1046
+ return Array.from(this.memories.values());
1047
+ }
1048
+
1049
+ getByType(type) {
1050
+ return this.getAll().filter(m => m.type === type);
1051
+ }
1052
+
1053
+ clear() {
1054
+ this.memories.clear();
1055
+ this.graph = new MemoryGraph();
1056
+ this.initSeeds();
1057
+ }
1058
+ }
1059
+
1060
+ // Global singleton instance
1061
+ let _globalStoreInstance = null;
1062
+
1063
+ function getEngineeringMemoryStore(options = {}) {
1064
+ if (!_globalStoreInstance) {
1065
+ _globalStoreInstance = new EngineeringMemoryStore(options);
1066
+ }
1067
+ return _globalStoreInstance;
1068
+ }
1069
+
1070
+ // ============================================================================
1071
+ // 12. MULTI-DIMENSIONAL RETRIEVAL & RANKING (SECTION 20)
1072
+ // ============================================================================
1073
+
1074
+ /**
1075
+ * Retrieves relevant engineering memories ranked across 10 dimensions:
1076
+ * Semantic relevance, concept overlap, tech match, architecture match,
1077
+ * constraint match, evidence strength, trust rank, recency, successful reuse,
1078
+ * and contradiction penalty.
1079
+ *
1080
+ * @param {string} taskQuery
1081
+ * @param {Object} context
1082
+ * @param {EngineeringMemoryStore} store
1083
+ * @param {Object} options
1084
+ * @returns {Array<Object>} Ranked retrieved memories
1085
+ */
1086
+ function retrieveRelevantMemories(taskQuery, context = {}, store = null, options = {}) {
1087
+ const memStore = store || getEngineeringMemoryStore();
1088
+ const allMemories = memStore.getAll();
1089
+ const queryTokens = (taskQuery || '')
1090
+ .toLowerCase()
1091
+ .split(/[\s,._\-:;]+/)
1092
+ .filter(w => w.length > 2);
1093
+ const targetConcepts = (context.concepts || []).map(c =>
1094
+ (typeof c === 'string' ? c : c.id || c.name).toLowerCase(),
1095
+ );
1096
+ const targetTechs = (context.technologies || []).map(t => t.toLowerCase());
1097
+
1098
+ const ranked = [];
1099
+
1100
+ for (const mem of allMemories) {
1101
+ // 1. Contextual Applicability Check (Section 6 & Benchmark 2 & Benchmark 8)
1102
+ const applicability = validateApplicability(mem, {
1103
+ task: taskQuery,
1104
+ technologies: targetTechs,
1105
+ project_id: context.project_id || context.projectId,
1106
+ scale: context.scale,
1107
+ strict_freshness: context.strict_freshness,
1108
+ });
1109
+
1110
+ if (!applicability.applicable) {
1111
+ continue; // Strict rejection of non-applicable memories
1112
+ }
1113
+
1114
+ // 2. Staleness Evaluation (Section 16 & Benchmark 5)
1115
+ const staleness = evaluateMemoryStaleness(mem, context);
1116
+ if (staleness.isStale && mem.status !== TRUST_STATES.STALE) {
1117
+ mem.status = TRUST_STATES.STALE;
1118
+ }
1119
+
1120
+ // 3. Multi-Dimensional Score Calculation
1121
+ let score = 0;
1122
+
1123
+ // A. Concept Overlap (weight: 0.30)
1124
+ const memConcepts = (mem.concepts || []).map(c => c.toLowerCase());
1125
+ let conceptMatches = 0;
1126
+ for (const mc of memConcepts) {
1127
+ if (targetConcepts.some(tc => tc.includes(mc) || mc.includes(tc))) {
1128
+ conceptMatches++;
1129
+ }
1130
+ }
1131
+ const conceptScore = memConcepts.length > 0 ? conceptMatches / memConcepts.length : 0;
1132
+ score += conceptScore * 35;
1133
+
1134
+ // B. Semantic Keyword Overlap (weight: 0.25)
1135
+ const memText = `${mem.title} ${mem.content} ${(mem.domains || []).join(' ')}`.toLowerCase();
1136
+ let tokenMatches = 0;
1137
+ for (const qt of queryTokens) {
1138
+ if (memText.includes(qt)) {
1139
+ tokenMatches++;
1140
+ }
1141
+ }
1142
+ const tokenScore = queryTokens.length > 0 ? tokenMatches / queryTokens.length : 0;
1143
+ score += tokenScore * 25;
1144
+
1145
+ // C. Applicability Multiplier (weight: 0.15)
1146
+ score += applicability.score * 15;
1147
+
1148
+ // D. Trust Rank (weight: 0.15)
1149
+ const trustRank = TRUST_RANKS[mem.status] || 1;
1150
+ score += (trustRank / 6.0) * 15;
1151
+
1152
+ // E. Evidence Strength & Successful Reuse (weight: 0.15)
1153
+ const empiricalCount = (mem.evidence || []).filter(e =>
1154
+ [
1155
+ PROVENANCE_TYPES.AUTOMATED_TEST,
1156
+ PROVENANCE_TYPES.BENCHMARK,
1157
+ PROVENANCE_TYPES.VERIFIED_IMPLEMENTATION,
1158
+ ].includes(e.type),
1159
+ ).length;
1160
+ score += Math.min(empiricalCount * 3, 10);
1161
+ score += Math.min((mem.successful_usage_count || 0) * 2, 10);
1162
+
1163
+ // F. Penalties
1164
+ if (mem.status === TRUST_STATES.CONTRADICTED) {
1165
+ score -= 50; // Heavy penalty for contradicted memory
1166
+ }
1167
+ if (mem.status === TRUST_STATES.STALE) {
1168
+ score -= 20; // Staleness penalty
1169
+ }
1170
+
1171
+ if (score >= (options.minScore || 15)) {
1172
+ ranked.push({
1173
+ memory: mem,
1174
+ score: Math.round(score * 10) / 10,
1175
+ applicability_reasons: applicability.reasons,
1176
+ is_stale: staleness.isStale,
1177
+ staleness_reason: staleness.reason,
1178
+ });
1179
+ }
1180
+ }
1181
+
1182
+ // Sort descending by score
1183
+ ranked.sort((a, b) => b.score - a.score);
1184
+ return ranked.map(r => ({
1185
+ ...r.memory,
1186
+ retrieval_score: r.score,
1187
+ applicability_reasons: r.applicability_reasons,
1188
+ is_stale: r.is_stale,
1189
+ staleness_reason: r.staleness_reason,
1190
+ }));
1191
+ }
1192
+
1193
+ // ============================================================================
1194
+ // 13. MEMORY EXTRACTION POST OUTCOME AUDIT (SECTION 5.3)
1195
+ // ============================================================================
1196
+
1197
+ /**
1198
+ * Extracts reusable engineering memory items from completed verified task outcomes.
1199
+ *
1200
+ * @param {string} taskQuery
1201
+ * @param {Object} outcomeContract
1202
+ * @param {Object} outcomeAudit
1203
+ * @param {Object} options
1204
+ * @returns {Array<Object>} Extracted and registered memory items
1205
+ */
1206
+ function extractEngineeringMemory(
1207
+ taskQuery,
1208
+ outcomeContract = {},
1209
+ outcomeAudit = {},
1210
+ options = {},
1211
+ ) {
1212
+ const store = options.store || getEngineeringMemoryStore();
1213
+ const extracted = [];
1214
+ const now = new Date().toISOString();
1215
+
1216
+ // If outcome was verified and complete
1217
+ if (outcomeAudit.complete || outcomeAudit.verified) {
1218
+ for (const mc of outcomeContract.material_considerations || []) {
1219
+ if (
1220
+ mc.category === 'financial-mutation' ||
1221
+ mc.category === 'concurrency' ||
1222
+ mc.title.toLowerCase().includes('idempotenc')
1223
+ ) {
1224
+ const item = store.add({
1225
+ type: MEMORY_TYPES.PATTERN,
1226
+ title: `Verified Pattern: ${mc.title}`,
1227
+ content: `${mc.rationale} Verified under task: ${taskQuery}`,
1228
+ concepts: [mc.category, 'verification-verified'],
1229
+ domains: outcomeContract.quality_dimensions
1230
+ ? Object.keys(outcomeContract.quality_dimensions)
1231
+ : ['backend'],
1232
+ context: {
1233
+ scope: options.scope || MEMORY_SCOPES.GLOBAL,
1234
+ project_id: options.project_id || null,
1235
+ },
1236
+ evidence: [
1237
+ {
1238
+ type: PROVENANCE_TYPES.AUTOMATED_TEST,
1239
+ source: `Outcome audit confirmed 100% material consideration coverage and passing verification.`,
1240
+ recorded_at: now,
1241
+ },
1242
+ ],
1243
+ source_task: taskQuery,
1244
+ status: TRUST_STATES.VERIFIED,
1245
+ confidence: 'HIGH',
1246
+ });
1247
+ extracted.push(item);
1248
+ }
1249
+ }
1250
+ }
1251
+
1252
+ // Extract observed failure mode if tests failed or regressions occurred
1253
+ if (outcomeAudit.failures && outcomeAudit.failures.length > 0) {
1254
+ for (const f of outcomeAudit.failures) {
1255
+ const failItem = store.add({
1256
+ type: MEMORY_TYPES.FAILURE,
1257
+ title: `Observed Failure: ${f.title || f.name || 'Task Failure'}`,
1258
+ content: f.detail || f.error || 'Execution failure detected',
1259
+ concepts: f.concepts || ['execution-failure'],
1260
+ domains: ['reliability'],
1261
+ failure: {
1262
+ cause: f.cause || 'Unknown race or schema violation',
1263
+ detection_method: f.detection_method || 'Unit / Integration test',
1264
+ impact: f.impact || 'Task incompletion',
1265
+ affected_concepts: f.concepts || [],
1266
+ fix: f.fix || 'Apply atomic constraints and error bounds',
1267
+ verification: f.verification || 'Passing test verification',
1268
+ regression_risk: 'Medium',
1269
+ },
1270
+ evidence: [
1271
+ {
1272
+ type: PROVENANCE_TYPES.AUTOMATED_TEST,
1273
+ source: f.error || 'Test suite reported failure',
1274
+ recorded_at: now,
1275
+ },
1276
+ ],
1277
+ source_task: taskQuery,
1278
+ status: TRUST_STATES.VERIFIED,
1279
+ confidence: 'HIGH',
1280
+ });
1281
+ extracted.push(failItem);
1282
+ }
1283
+ }
1284
+
1285
+ return extracted;
1286
+ }
1287
+
1288
+ // ============================================================================
1289
+ // 12. STATE & RECOVERY (PHASE 5)
1290
+ // ============================================================================
1291
+
1292
+ const STATE_STATUS = {
1293
+ RUNNING: 'RUNNING',
1294
+ PAUSED: 'PAUSED',
1295
+ FAILED: 'FAILED',
1296
+ ROLLED_BACK: 'ROLLED_BACK',
1297
+ COMPLETED: 'COMPLETED',
1298
+ };
1299
+
1300
+ class ExecutionStateStore {
1301
+ constructor(storePath) {
1302
+ this.storePath =
1303
+ storePath || path.join(require('os').homedir(), '.tribunal', 'execution_states.json');
1304
+ this.states = new Map();
1305
+ this.load();
1306
+ }
1307
+
1308
+ load() {
1309
+ try {
1310
+ if (fs.existsSync(this.storePath)) {
1311
+ const raw = fs.readFileSync(this.storePath, 'utf8');
1312
+ const parsed = JSON.parse(raw);
1313
+ for (const [taskId, state] of Object.entries(parsed)) {
1314
+ this.states.set(taskId, state);
1315
+ }
1316
+ }
1317
+ } catch (e) {
1318
+ console.warn('Failed to load ExecutionStateStore:', e.message);
1319
+ }
1320
+ }
1321
+
1322
+ save() {
1323
+ try {
1324
+ const dir = path.dirname(this.storePath);
1325
+ if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
1326
+ const serialized = Object.fromEntries(this.states.entries());
1327
+ fs.writeFileSync(this.storePath, JSON.stringify(serialized, null, 2), 'utf8');
1328
+ } catch (e) {
1329
+ console.warn('Failed to save ExecutionStateStore:', e.message);
1330
+ }
1331
+ }
1332
+
1333
+ checkpoint(taskId, executionStep, context, artifacts = []) {
1334
+ const existing = this.states.get(taskId) || {
1335
+ task_id: taskId,
1336
+ history: [],
1337
+ created_at: new Date().toISOString(),
1338
+ };
1339
+
1340
+ const cp = {
1341
+ step: executionStep,
1342
+ context,
1343
+ artifacts,
1344
+ timestamp: new Date().toISOString(),
1345
+ };
1346
+
1347
+ existing.history.push(cp);
1348
+ existing.current_step = executionStep;
1349
+ existing.status = STATE_STATUS.RUNNING;
1350
+ existing.last_updated = cp.timestamp;
1351
+
1352
+ this.states.set(taskId, existing);
1353
+ this.save();
1354
+ return cp;
1355
+ }
1356
+
1357
+ pause(taskId, reason) {
1358
+ const state = this.states.get(taskId);
1359
+ if (!state) throw new Error(`Cannot pause: Task ${taskId} not found.`);
1360
+ state.status = STATE_STATUS.PAUSED;
1361
+ state.pause_reason = reason;
1362
+ state.last_updated = new Date().toISOString();
1363
+ this.save();
1364
+ return state;
1365
+ }
1366
+
1367
+ resume(taskId) {
1368
+ const state = this.states.get(taskId);
1369
+ if (!state) throw new Error(`Cannot resume: Task ${taskId} not found.`);
1370
+ if (state.status === STATE_STATUS.COMPLETED)
1371
+ throw new Error(`Cannot resume: Task ${taskId} is already completed.`);
1372
+
1373
+ state.status = STATE_STATUS.RUNNING;
1374
+ state.last_updated = new Date().toISOString();
1375
+ this.save();
1376
+ return state;
1377
+ }
1378
+
1379
+ rollback(taskId) {
1380
+ const state = this.states.get(taskId);
1381
+ if (!state || state.history.length === 0)
1382
+ throw new Error(`Cannot rollback: No history for Task ${taskId}.`);
1383
+
1384
+ // Remove current step
1385
+ state.history.pop();
1386
+ state.status = STATE_STATUS.ROLLED_BACK;
1387
+
1388
+ const previous = state.history.length > 0 ? state.history[state.history.length - 1] : null;
1389
+ state.current_step = previous ? previous.step : null;
1390
+ state.last_updated = new Date().toISOString();
1391
+ this.save();
1392
+
1393
+ return { state, previous_checkpoint: previous };
1394
+ }
1395
+
1396
+ complete(taskId) {
1397
+ const state = this.states.get(taskId);
1398
+ if (!state) return null;
1399
+ state.status = STATE_STATUS.COMPLETED;
1400
+ state.last_updated = new Date().toISOString();
1401
+ this.save();
1402
+ return state;
1403
+ }
1404
+ }
1405
+
1406
+ let _executionStateStoreInstance = null;
1407
+ function getExecutionStateStore(storePath = null) {
1408
+ if (!_executionStateStoreInstance || storePath) {
1409
+ _executionStateStoreInstance = new ExecutionStateStore(storePath);
1410
+ }
1411
+ return _executionStateStoreInstance;
1412
+ }
1413
+
1414
+ // ============================================================================
1415
+ // EXPORTS
1416
+ // ============================================================================
1417
+
1418
+ module.exports = {
1419
+ MEMORY_TYPES,
1420
+ PROVENANCE_TYPES,
1421
+ TRUST_STATES,
1422
+ TRUST_RANKS,
1423
+ MEMORY_SCOPES,
1424
+ sanitizeContentAndEvidence,
1425
+ validateMemoryAdmission,
1426
+ createMemoryRecord,
1427
+ validateApplicability,
1428
+ evaluateMemoryStaleness,
1429
+ evaluateMemoryHypothesisWithCurrentEvidence,
1430
+ recordConflictResolution,
1431
+ MemoryGraph,
1432
+ SEED_VERIFICATION_STRATEGIES,
1433
+ SEED_FAILURE_MEMORIES,
1434
+ SEED_PATTERN_MEMORIES,
1435
+ EngineeringMemoryStore,
1436
+ getEngineeringMemoryStore,
1437
+ retrieveRelevantMemories,
1438
+ extractEngineeringMemory,
1439
+ ExecutionStateStore,
1440
+ getExecutionStateStore,
1441
+ STATE_STATUS,
1442
+ };