@polymorphism-tech/morph-spec 8.33.0 → 8.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (253) hide show
  1. package/CLAUDE.md +22 -2
  2. package/README.md +2 -2
  3. package/bin/morph-spec.js +43 -5
  4. package/claude-plugin.json +1 -1
  5. package/docs/CHEATSHEET.md +5 -4
  6. package/docs/QUICKSTART.md +1 -1
  7. package/framework/CLAUDE.md +2 -2
  8. package/framework/MORPH.md +20 -22
  9. package/framework/agents.json +198 -44
  10. package/framework/ai-pin.json +22 -0
  11. package/framework/commands/morph-media.md +45 -0
  12. package/framework/docs/CLI.md +238 -10
  13. package/framework/evals/proof-rubrics/README.md +76 -0
  14. package/framework/evals/proof-rubrics/eval-de-modelo.md +64 -0
  15. package/framework/evals/proof-rubrics/fiacao.md +54 -0
  16. package/framework/evals/proof-rubrics/guard-cego.md +52 -0
  17. package/framework/evals/proof-rubrics/media-claims.md +109 -0
  18. package/framework/evals/proof-rubrics/mutation-proof.md +77 -0
  19. package/framework/evals/proof-rubrics/observabilidade-genai.md +119 -0
  20. package/framework/evals/proof-rubrics/verde-nao-e-coberto.md +48 -0
  21. package/framework/evals/rubrics/architecture.md +30 -0
  22. package/framework/evals/rubrics/code-quality.md +26 -0
  23. package/framework/evals/rubrics/test-coverage.md +20 -0
  24. package/framework/hooks/README.md +11 -1
  25. package/framework/hooks/claude-code/core/block-destructive-worktree-removal.js +5 -8
  26. package/framework/hooks/claude-code/core/block-raw-worktree-add.js +79 -0
  27. package/framework/hooks/claude-code/core/chain.js +27 -7
  28. package/framework/hooks/claude-code/core/protect-spec-files.js +41 -4
  29. package/framework/hooks/claude-code/core/worktree-context.js +83 -14
  30. package/framework/hooks/claude-code/core/worktree-create.js +206 -0
  31. package/framework/hooks/claude-code/core/worktree-env-inject.js +87 -0
  32. package/framework/hooks/claude-code/core/worktree-remove.js +81 -0
  33. package/framework/hooks/shared/command-tokens.js +23 -0
  34. package/framework/hooks/shared/e2e-check.js +0 -0
  35. package/framework/hooks/shared/git-paths.js +25 -0
  36. package/framework/hooks/shared/hook-response.js +17 -0
  37. package/framework/hooks/shared/morph-cli.js +134 -0
  38. package/framework/rules/ai-agents-standards.md +14 -2
  39. package/framework/rules/infrastructure-standards.md +3 -1
  40. package/framework/schemas/ai-pin.schema.json +97 -0
  41. package/framework/schemas/config.schema.json +107 -0
  42. package/framework/schemas/feature.schema.json +23 -4
  43. package/framework/skills/core/create-umbraco-lp/SKILL.md +1 -1
  44. package/framework/skills/core/migrate-lp-to-umbraco/SKILL.md +1 -1
  45. package/framework/skills/core/morph-apply/SKILL.md +28 -7
  46. package/framework/skills/core/morph-brainstorming/SKILL.md +1 -1
  47. package/framework/skills/core/morph-eval/SKILL.md +1 -1
  48. package/framework/skills/core/morph-hotfix/SKILL.md +2 -2
  49. package/framework/skills/core/morph-implement/SKILL.md +20 -2
  50. package/framework/skills/core/morph-media/SKILL.md +215 -0
  51. package/framework/skills/core/morph-plan/SKILL.md +38 -4
  52. package/framework/skills/core/morph-proposal/SKILL.md +1 -1
  53. package/framework/skills/core/morph-review/SKILL.md +166 -9
  54. package/framework/skills/core/morph-stack-scan/SKILL.md +1 -1
  55. package/framework/skills/core/morph-standards/SKILL.md +1 -1
  56. package/framework/skills/core/morph-uiux/SKILL.md +1 -1
  57. package/framework/standards/PROVENANCE.json +81 -3
  58. package/framework/standards/STANDARDS.json +1504 -830
  59. package/framework/standards/ai-agents/agent-archetypes.md +160 -0
  60. package/framework/standards/ai-agents/agent-session.md +256 -160
  61. package/framework/standards/ai-agents/agent-spec.md +196 -0
  62. package/framework/standards/ai-agents/batching.md +217 -193
  63. package/framework/standards/ai-agents/context-providers.md +261 -188
  64. package/framework/standards/ai-agents/conversational-agent-with-phases.md +239 -0
  65. package/framework/standards/ai-agents/cost-and-budget.md +256 -0
  66. package/framework/standards/ai-agents/durable-workflows-hitl.md +98 -5
  67. package/framework/standards/ai-agents/evals-with-cache.md +289 -0
  68. package/framework/standards/ai-agents/guardrails.md +222 -0
  69. package/framework/standards/ai-agents/llm-runtime-defaults.md +226 -0
  70. package/framework/standards/ai-agents/mcp-server.md +351 -250
  71. package/framework/standards/ai-agents/mcp-tools.md +250 -197
  72. package/framework/standards/ai-agents/media-pipeline.md +352 -0
  73. package/framework/standards/ai-agents/media-video.md +267 -0
  74. package/framework/standards/ai-agents/middleware-patterns.md +241 -207
  75. package/framework/standards/ai-agents/modalities-image-gen.md +422 -173
  76. package/framework/standards/ai-agents/modalities-speech-to-text.md +177 -171
  77. package/framework/standards/ai-agents/modalities-text-to-speech.md +189 -181
  78. package/framework/standards/ai-agents/modalities-vision.md +205 -201
  79. package/framework/standards/ai-agents/multi-agent-patterns.md +211 -155
  80. package/framework/standards/ai-agents/observability-patterns.md +227 -17
  81. package/framework/standards/ai-agents/production.md +260 -231
  82. package/framework/standards/ai-agents/prompt-sources.md +389 -0
  83. package/framework/standards/ai-agents/providers/model-registry.md +293 -158
  84. package/framework/standards/ai-agents/rag-custom-pgvector.md +69 -4
  85. package/framework/standards/ai-agents/service-tier-flex.md +143 -135
  86. package/framework/standards/ai-agents/setup.md +166 -50
  87. package/framework/standards/ai-agents/structured-output.md +280 -249
  88. package/framework/standards/ai-agents/sweet-spot.md +129 -109
  89. package/framework/standards/ai-agents/testing-ai.md +236 -0
  90. package/framework/standards/ai-agents/vector-data-extensions.md +50 -20
  91. package/framework/standards/ai-agents/workflows.md +27 -7
  92. package/framework/standards/frontend/design-system/ai-image-generation.md +12 -0
  93. package/framework/standards/frontend/design-system/ai-video-generation.md +13 -0
  94. package/framework/standards/infrastructure/docker/local-compose-isolation.md +90 -0
  95. package/framework/templates/REGISTRY.json +14 -1
  96. package/framework/templates/code/dotnet/ai-agents/PromptRepository.cs.template +95 -95
  97. package/framework/templates/code/sql/ai-agents/agent-prompts-migration.sql.template +58 -58
  98. package/framework/templates/dotnet/ai-kit/Directory.Build.props +25 -0
  99. package/framework/templates/dotnet/ai-kit/Directory.Packages.props +26 -0
  100. package/framework/templates/dotnet/ai-kit/Morph.AiKit.sln +56 -0
  101. package/framework/templates/dotnet/ai-kit/NuGet.config +12 -0
  102. package/framework/templates/dotnet/ai-kit/README.md +128 -0
  103. package/framework/templates/dotnet/ai-kit/global.json +9 -0
  104. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Agents/AgentApi.cs +65 -0
  105. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Agents/AgentFactory.cs +289 -0
  106. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Agents/AgentFactoryOptions.cs +91 -0
  107. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Agents/AgentSpec.cs +91 -0
  108. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Agents/AgentSpecOptions.cs +181 -0
  109. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/AiKitAssemblyMarker.cs +14 -0
  110. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Conversation/ConversationStore.cs +174 -0
  111. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Conversation/IConversationStore.cs +54 -0
  112. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Conversation/InMemoryConversationStore.cs +75 -0
  113. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/CountingChatClient.cs +71 -0
  114. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalAssertion.cs +246 -0
  115. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalCacheMissException.cs +57 -0
  116. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalCacheOptions.cs +78 -0
  117. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalCacheStamp.cs +225 -0
  118. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalFixture.cs +463 -0
  119. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalMode.cs +32 -0
  120. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalQualityEvaluators.cs +49 -0
  121. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalScenario.cs +214 -0
  122. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/EvalSummary.cs +168 -0
  123. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/OfflineChatClient.cs +142 -0
  124. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Evals/ShortPathResponseCache.cs +349 -0
  125. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/IMediaGenerator.cs +42 -0
  126. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/IMediaProvider.cs +77 -0
  127. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaArtifact.cs +28 -0
  128. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaDisclosure.cs +107 -0
  129. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaGenerator.cs +253 -0
  130. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaIdempotencyKey.cs +103 -0
  131. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaJob.cs +259 -0
  132. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaJobId.cs +21 -0
  133. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaJobState.cs +47 -0
  134. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaPricing.cs +102 -0
  135. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaProvenance.cs +44 -0
  136. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaRequest.cs +192 -0
  137. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaResult.cs +94 -0
  138. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaReview.cs +99 -0
  139. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaSeams.cs +97 -0
  140. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MediaStore.cs +133 -0
  141. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/MorphMedia.cs +93 -0
  142. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/Providers/GoogleImageProvider.cs +112 -0
  143. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/Providers/OpenAIImageProvider.cs +288 -0
  144. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Media/Providers/VeoVideoProvider.cs +158 -0
  145. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Middleware/IUsageCostSink.cs +29 -0
  146. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Middleware/UsageCostMiddleware.cs +208 -0
  147. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Middleware/UsageCostRecord.cs +95 -0
  148. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Morph.AiKit.csproj +38 -0
  149. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Observability/MorphOpenTelemetryExtensions.cs +119 -0
  150. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Observability/MorphTelemetryOptions.cs +82 -0
  151. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Providers/IProviderClientFactory.cs +33 -0
  152. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Providers/ModelAlias.cs +267 -0
  153. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Providers/ModelRegistry.cs +474 -0
  154. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Providers/model-registry.v2.json +87 -0
  155. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Rag/DeltaIngest.cs +169 -0
  156. package/framework/templates/dotnet/ai-kit/src/Morph.AiKit/Rag/DeltaPlan.cs +49 -0
  157. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/AgentFactoryTests.cs +495 -0
  158. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/AgentSpecTests.cs +260 -0
  159. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/ConversationStoreTests.cs +405 -0
  160. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/DeltaIngestTests.cs +379 -0
  161. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Evals/EvalAssertionTests.cs +197 -0
  162. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Evals/EvalCacheMissTests.cs +139 -0
  163. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Evals/EvalCacheStampTests.cs +157 -0
  164. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Evals/EvalFailuresTests.cs +178 -0
  165. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Evals/EvalFixtureTests.cs +153 -0
  166. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Evals/EvalRefreshTests.cs +194 -0
  167. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Evals/EvalWorkspace.cs +86 -0
  168. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Evals/KitEvals.cs +213 -0
  169. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Evals/OfflineChatClientTests.cs +95 -0
  170. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Fakes/FakeChatClient.cs +225 -0
  171. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Fakes/FakeChatClientTests.cs +215 -0
  172. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Fakes/FakeClock.cs +33 -0
  173. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Fakes/FakeMediaProvider.cs +89 -0
  174. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Fakes/FakeProviderClientFactory.cs +55 -0
  175. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Fakes/FakeUsageCostSink.cs +60 -0
  176. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Fakes/InMemoryMediaStore.cs +131 -0
  177. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/MediaAccessibilityTests.cs +133 -0
  178. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/MediaAliasIsNotAnAgentTests.cs +127 -0
  179. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/MediaDisclosureTests.cs +216 -0
  180. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/MediaGeneratorTests.cs +264 -0
  181. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/MediaIdempotencyKeyTests.cs +148 -0
  182. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/MediaJobStateTests.cs +184 -0
  183. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/MediaReviewTests.cs +89 -0
  184. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/MediaStoreTests.cs +98 -0
  185. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/ModelRegistryTests.cs +451 -0
  186. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/Morph.AiKit.Tests.csproj +76 -0
  187. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/SkeletonSmokeTests.cs +33 -0
  188. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/TelemetryTests.cs +261 -0
  189. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/UsageCostMiddlewareTests.cs +374 -0
  190. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/eval-cache/.morph-eval-cache.json +12 -0
  191. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/eval-cache/cache/orcamento.acme.a-resposta-estruturada/1/CF70A7CE27BBD66A/contents.data +13 -0
  192. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/eval-cache/cache/orcamento.acme.a-resposta-estruturada/1/CF70A7CE27BBD66A/entry.json +7 -0
  193. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/eval-cache/cache/triagem.acme.a-saudacao/1/19F631228C6E00BA/contents.data +13 -0
  194. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/eval-cache/cache/triagem.acme.a-saudacao/1/19F631228C6E00BA/entry.json +7 -0
  195. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/eval-cache/cache/triagem.acme.b-escalonamento/1/A24A7C9BDD8239D8/contents.data +13 -0
  196. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/eval-cache/cache/triagem.acme.b-escalonamento/1/A24A7C9BDD8239D8/entry.json +7 -0
  197. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/eval-cache/cache/triagem.globex.a-saudacao/1/E38CD37DF003EDB7/contents.data +13 -0
  198. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/eval-cache/cache/triagem.globex.a-saudacao/1/E38CD37DF003EDB7/entry.json +7 -0
  199. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/eval-datasets/orcamento/acme/a-resposta-estruturada.json +24 -0
  200. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/eval-datasets/triagem/acme/a-saudacao.json +23 -0
  201. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/eval-datasets/triagem/acme/b-escalonamento.json +24 -0
  202. package/framework/templates/dotnet/ai-kit/tests/Morph.AiKit.Tests/eval-datasets/triagem/globex/a-saudacao.json +23 -0
  203. package/framework/templates/infrastructure/docker/docker-compose.template.yml +24 -14
  204. package/package.json +3 -3
  205. package/src/commands/e2e/e2e.js +91 -40
  206. package/src/commands/project/doctor.js +143 -6
  207. package/src/commands/project/env.js +95 -0
  208. package/src/commands/project/update.js +469 -153
  209. package/src/commands/project/worktree.js +274 -53
  210. package/src/commands/state/advance.js +24 -2
  211. package/src/commands/state/approve.js +33 -1
  212. package/src/commands/state/create.js +72 -11
  213. package/src/commands/state/delete.js +8 -0
  214. package/src/commands/state/finish.js +360 -53
  215. package/src/commands/state/gate-check.js +190 -6
  216. package/src/commands/state/score.js +36 -1
  217. package/src/commands/validation/verify.js +134 -25
  218. package/src/core/state/state-manager.js +9 -1
  219. package/src/dashboard/app/pages/HookInspector.jsx +430 -418
  220. package/src/dashboard/scanner/hooks-scanner.js +5 -1
  221. package/src/lib/ai/ai-checks.js +182 -0
  222. package/src/lib/ai/ai-project-scan.js +347 -0
  223. package/src/lib/ai/code-audit.js +181 -0
  224. package/src/lib/ai/comment-stripper.js +184 -0
  225. package/src/lib/ai/pin-drift.js +138 -0
  226. package/src/lib/ai/registry-audit.js +285 -0
  227. package/src/lib/e2e/compose-env.js +55 -14
  228. package/src/lib/e2e/stack-teardown.js +115 -0
  229. package/src/lib/evaluator-report.js +269 -15
  230. package/src/lib/generators/architecture-scanner.js +2 -1
  231. package/src/lib/git/default-branch.js +92 -4
  232. package/src/lib/graph/graphifyignore.js +2 -1
  233. package/src/lib/installers/effects.js +193 -0
  234. package/src/lib/installers/templates-reconcile.js +3 -3
  235. package/src/lib/risk-detector.js +284 -0
  236. package/src/lib/standards/verified-against.js +276 -0
  237. package/src/lib/tasks/eval-node.js +485 -0
  238. package/src/lib/tasks/linux-runner.js +297 -0
  239. package/src/lib/tasks/test-nodes.js +486 -0
  240. package/src/lib/tasks/test-runner.js +431 -37
  241. package/src/lib/validators/verify-runner.js +590 -28
  242. package/src/lib/worktree/dirs.js +32 -0
  243. package/src/lib/worktree/docker-audit.js +287 -0
  244. package/src/lib/worktree/env-allocator.js +69 -11
  245. package/src/lib/worktree/worktree-audit.js +70 -3
  246. package/src/scripts/setup-infra.js +24 -11
  247. package/src/utils/agents-installer.js +18 -8
  248. package/src/utils/claude-md-injector.js +10 -5
  249. package/src/utils/file-copier.js +28 -16
  250. package/src/utils/hooks-installer.js +75 -29
  251. package/src/utils/skills-installer.js +194 -187
  252. package/src/utils/version-checker.js +68 -3
  253. package/framework/standards/ai-agents/prompts-in-db.md +0 -214
@@ -1,231 +1,260 @@
1
- # Microsoft Agent Framework — Production Patterns
2
-
3
- > **Scope:** stacks=["dotnet"]
4
- > **Layer:** 1 (on-keyword)
5
- > **Keywords:** middleware, observability, telemetry, mcp, a2a, caching, anti-hallucination, production agent
6
- > **Read by Claude in:** implement (when wiring middleware/telemetry/MCP into an agent)
7
-
8
- **Verified against:** MAF 1.0 GA. Last-verified: 2026-05-19.
9
-
10
- ---
11
-
12
- ## Middleware Pipeline
13
-
14
- Três tipos de middleware interceptam o comportamento do agent em camadas distintas:
15
-
16
- | Tipo | Intercepts | Use Case |
17
- |------|-----------|----------|
18
- | **Agent Run** | Invocação completa do agent | Logging, auth, rate limiting |
19
- | **Function Calling** | Chamadas individuais de tools | Error handling, validação, auditoria |
20
- | **IChatClient** | Chamadas brutas ao LLM | Telemetry, caching, content filtering |
21
-
22
- O **tratamento canônico** de middleware — código dos 3 níveis, registro via `.AsBuilder().Use(...)`,
23
- e os patterns de telemetria, resilência (retry + rate-limit) e anti-hallucination — está em
24
- **`ai-agents-middleware-patterns`**. Não duplicado aqui.
25
-
26
- > Em produção: registre `ResilientToolMiddleware` (ou equivalente) em qualquer agent que chame
27
- > APIs externas, e um middleware de telemetria no `IChatClient`. Ver `ai-agents-middleware-patterns`
28
- > para o código e a decision tree de qual nível usar.
29
-
30
- ---
31
-
32
- ## A2A Protocol (Agent-to-Agent)
33
-
34
- Exponha agents como serviços web interoperáveis via protocolo A2A padronizado.
35
-
36
- **Package (GA):**
37
-
38
- ```xml
39
- <PackageReference Include="Microsoft.Agents.AI.A2A" Version="1.0.*" />
40
- ```
41
-
42
- ### Expor um agent via A2A
43
-
44
- ```csharp
45
- // Program.cs
46
- using Microsoft.Agents.AI;
47
- using Microsoft.Agents.AI.A2A;
48
- using Microsoft.Extensions.AI;
49
-
50
- var builder = WebApplication.CreateBuilder(args);
51
-
52
- // Registrar agent via Model Registry
53
- IChatClient chatClient = /* from ModelRegistry singleton */;
54
- builder.Services.AddSingleton(chatClient);
55
-
56
- builder.AddAIAgent("math", instructions: "You are a math expert.");
57
- builder.AddAIAgent("history", instructions: "You are a history expert.");
58
-
59
- var app = builder.Build();
60
-
61
- app.MapA2A("math", path: "/a2a/math", agentCard: new()
62
- {
63
- Name = "Math Agent",
64
- Description = "Expert in mathematics and calculations.",
65
- Version = "1.0"
66
- });
67
-
68
- app.MapA2A("history", path: "/a2a/history", agentCard: new()
69
- {
70
- Name = "History Agent",
71
- Description = "Expert in world history.",
72
- Version = "1.0"
73
- });
74
-
75
- app.Run();
76
- ```
77
-
78
- ### Consumir um agent A2A remoto
79
-
80
- ```csharp
81
- using Microsoft.Agents.AI.A2A;
82
-
83
- // Wrap a remote A2A endpoint as a local AIAgent
84
- AIAgent remoteAgent = new A2AClient(new Uri("https://agents.example.com/a2a/math"))
85
- .AsAIAgent();
86
-
87
- var response = await remoteAgent.RunAsync("What is the integral of x^2?");
88
- ```
89
-
90
- ### Agent Card Discovery
91
-
92
- ```
93
- GET /a2a/math/v1/card → metadata (name, description, capabilities)
94
- POST /a2a/math/v1/message:stream → send message, get streaming response
95
- ```
96
-
97
- | Feature A2A | Descrição |
98
- |-------------|-----------|
99
- | Agent Discovery | Agent Cards com metadados padronizados |
100
- | Cross-Framework | Agent .NET pode conversar com agent Python |
101
- | Context Persistence | `contextId` mantém conversa entre mensagens |
102
- | Streaming | Server-Sent Events para respostas em tempo real |
103
-
104
- ---
105
-
106
- ## MCP Integration (Model Context Protocol)
107
-
108
- Agents MAF podem consumir tools de **MCP servers externos** (GitHub, filesystem, Postgres,
109
- servidores internos) e expor capacidades do projeto **como** um MCP server.
110
-
111
- Esses dois casos têm tratamento canônico em standards dedicados — **não duplicado aqui**:
112
-
113
- | Caso | Standard |
114
- |------|----------|
115
- | Agente MAF consome um MCP server externo | `ai-agents-mcp-tools` (`McpClientFactory.CreateAsync`, transports, `await using`) |
116
- | Projeto expõe capacidades como MCP server | `ai-agents-mcp-server` (`[McpServerTool]`, `AddMcpServer`, stdio/HTTP) |
117
-
118
- > Em produção, lembre: MCP client sempre com `await using` (dispose do transporte); MCP server
119
- > exposto via HTTP exige autenticação. Detalhes nos standards acima.
120
-
121
- ---
122
-
123
- ## Caching Patterns
124
-
125
- ### Semantic Caching (Redis)
126
-
127
- Cache de respostas LLM por similaridade semântica — evita inferências repetidas.
128
-
129
- > **Illustrative pseudo-code** — the exact Redis vector-search calls depend on your Redis client. For a complete, working semantic-search implementation see `ai-agents-rag-custom-pgvector` (Onda 2). The point of this section is the *pattern*: embed the query, vector-search a cache, return on a similarity hit.
130
-
131
- ```csharp
132
- public async Task<string?> GetCachedResponseAsync(string question)
133
- {
134
- var questionEmbedding = await _embedding.GenerateAsync(question);
135
-
136
- // pseudo-code: perform a KNN vector search against the cache index
137
- var (similarityScore, cachedResponse) = await VectorSearchCacheAsync(
138
- "idx:semantic_cache", questionEmbedding);
139
-
140
- if (similarityScore >= 0.95) // cosine similarity: higher = more similar
141
- return cachedResponse;
142
-
143
- return null; // cache miss
144
- }
145
- ```
146
-
147
- **Cost savings:** embedding ~$0.0001/1K tokens vs inferência ~$0.01-0.03/1K tokens = **100-300x savings**.
148
-
149
- ### Hybrid Cache (L1 + L2)
150
-
151
- ```csharp
152
- builder.Services.AddHybridCache(options =>
153
- {
154
- options.DefaultEntryOptions = new HybridCacheEntryOptions
155
- {
156
- Expiration = TimeSpan.FromMinutes(10),
157
- LocalCacheExpiration = TimeSpan.FromMinutes(1)
158
- };
159
- });
160
-
161
- // Uso num tool
162
- [Description("Gets weather for a location")]
163
- public async Task<WeatherResponse> GetWeatherAsync(
164
- string location, string date, CancellationToken ct)
165
- {
166
- return await _cache.GetOrCreateAsync(
167
- $"weather:{location}:{date}",
168
- async token => await FetchFromApiAsync(location, date, token),
169
- cancellationToken: ct);
170
- }
171
- ```
172
-
173
- | Level | Location | Speed | Scope |
174
- |-------|----------|-------|-------|
175
- | L1 | Process memory | Fastest | Per instance |
176
- | L2 | Redis | Very fast | Distributed |
177
-
178
- ---
179
-
180
- ## Observability / OpenTelemetry
181
-
182
- Setup, enrichment (span attributes, correlation IDs, structured logging) e o workflow de investigação/análise de logs em produção têm **tratamento canônico** em **`ai-agents-observability-patterns`**. Não duplicado aqui.
183
-
184
- > Em produção: source name sempre `AgentOpenTelemetryConsts.DefaultSourceName`; `EnableSensitiveTelemetryData = false` fora de dev/staging. Ver `ai-agents-observability-patterns` para o setup completo, o que preencher em cada span/log, e o workflow de investigação quando um incidente for reportado.
185
-
186
- ---
187
-
188
- ## Security Checklist (verifiable by morph-eval)
189
-
190
- - [ ] API keys nunca em `appsettings.json` no repositório — bind de environment variables ou secret store
191
- - [ ] Variáveis de provider (`OpenAI__ApiKey`, `Google__ApiKey`, `Anthropic__ApiKey`) em env vars / Docker secrets
192
- - [ ] Input validation middleware registrado em agents públicos (PII detection, injection prevention)
193
- - [ ] Output filtering / guardrails para conteúdo prejudicial
194
- - [ ] Rate limiting middleware em agents expostos publicamente
195
- - [ ] Endpoints A2A protegidos com autenticação
196
- - [ ] Structured output usado para respostas — evita parsing de texto livre
197
- - [ ] OpenTelemetry com `AgentOpenTelemetryConsts.DefaultSourceName` configurado
198
-
199
- ---
200
-
201
- ## Production Checklist (verifiable by morph-eval)
202
-
203
- - [ ] `Microsoft.Agents.AI` 1.0.* no `.csproj`; nenhum pacote `Experimental.*` ou SK
204
- - [ ] Middleware registrado via `.AsBuilder().Use(...)` antes de `Build()`
205
- - [ ] `ResilientToolMiddleware` (ou equivalente) em agents que chamam APIs externas
206
- - [ ] Semantic cache configurado se o agent recebe queries repetitivas
207
- - [ ] OpenTelemetry source = `AgentOpenTelemetryConsts.DefaultSourceName`
208
- - [ ] Dados sensíveis de telemetry desabilitados em produção (`EnableSensitiveTelemetryData = false`)
209
- - [ ] A2A endpoints com `MapA2A` protegidos por auth se expostos na internet
210
- - [ ] MCP client `await using` para dispose correto do transporte
211
-
212
- ---
213
-
214
- ## References
215
-
216
- - `ai-agents-setup` — pacotes, DI, quick start
217
- - `ai-agents-sweet-spot` — decisão de arquitetura antes de middleware
218
- - `ai-agents-providers-model-registry` — Model Registry para `_modelRegistry.GetChatClient(...)`
219
- - `ai-agents-middleware-patterns` — **tratamento canônico** de middleware (código dos 3 níveis, telemetria, resilência, anti-hallucination)
220
- - `ai-agents-observability-patterns` — **tratamento canônico** de observability (setup OpenTelemetry, enrichment de spans/logs, workflow de investigação)
221
- - `ai-agents-mcp-tools` — agente MAF consumindo MCP servers externos
222
- - `ai-agents-mcp-server` — projeto expondo capacidades como MCP server
223
- - `ai-agents-rag-custom-pgvector` — implementação completa de busca semântica (referida em Caching)
224
- - [Agent Middleware](https://learn.microsoft.com/agent-framework/user-guide/agents/agent-middleware)
225
- - [A2A Integration](https://learn.microsoft.com/agent-framework/user-guide/hosting/agent-to-agent-integration)
226
- - [Using MCP Tools](https://learn.microsoft.com/agent-framework/user-guide/model-context-protocol/using-mcp-tools)
227
- - [MCP C# SDK](https://github.com/modelcontextprotocol/csharp-sdk)
228
-
229
- ---
230
-
231
- *MORPH-SPEC by Polymorphism Tech — ai-agents/production.md v2.1 (2026-05-19)*
1
+ # Microsoft Agent Framework — Production Patterns
2
+
3
+ > **Scope:** stacks=["dotnet"]
4
+ > **Layer:** 1 (on-keyword)
5
+ > **Keywords:** middleware, observability, telemetry, mcp, a2a, caching, anti-hallucination, production agent
6
+ > **Read by Claude in:** implement (when wiring middleware/telemetry/MCP into an agent)
7
+
8
+ **Verified against:** Microsoft.Agents.AI 1.20.0 (ai-pin 2026-09-08) + Microsoft.Agents.AI.Hosting `1.20.0-preview.260831.1` e Microsoft.Agents.AI.A2A `1.20.0-preview.260831.1` (**fora do pin**; versões apuradas no nuget.org em 2026-09-08). **Verificação documental**, sem cláusula `provado por` — este standard é panorama, e cada tema tem dono canônico noutro standard. Os nomes de isolamento multi-tenant foram **medidos por reflexão sobre `Microsoft.Agents.AI.Hosting`** em 2026-09-08. Last-verified: 2026-09-08.
9
+
10
+ ---
11
+
12
+ ## Middleware Pipeline
13
+
14
+ Três tipos de middleware interceptam o comportamento do agent em camadas distintas:
15
+
16
+ | Tipo | Intercepts | Use Case |
17
+ |------|-----------|----------|
18
+ | **Agent Run** | Invocação completa do agent | Logging, auth, rate limiting |
19
+ | **Function Calling** | Chamadas individuais de tools | Error handling, validação, auditoria |
20
+ | **IChatClient** | Chamadas brutas ao LLM | Telemetry, caching, content filtering |
21
+
22
+ O **tratamento canônico** de middleware — código dos 3 níveis, registro via `.AsBuilder().Use(...)`,
23
+ e os patterns de telemetria, resilência (retry + rate-limit) e anti-hallucination — está em
24
+ **`ai-agents-middleware-patterns`**. Não duplicado aqui.
25
+
26
+ > Em produção: registre `ResilientToolMiddleware` (ou equivalente) em qualquer agent que chame
27
+ > APIs externas, e um middleware de telemetria no `IChatClient`. Ver `ai-agents-middleware-patterns`
28
+ > para o código e a decision tree de qual nível usar.
29
+
30
+ ---
31
+
32
+ ## A2A Protocol (Agent-to-Agent)
33
+
34
+ Exponha agents como serviços web interoperáveis via protocolo A2A padronizado.
35
+
36
+ **Package — PRERELEASE, e fora do `ai-pin.json`:**
37
+
38
+ ```xml
39
+ <!-- Apurado no nuget.org em 2026-09-08: não há versão estável de Microsoft.Agents.AI.A2A. -->
40
+ <PackageReference Include="Microsoft.Agents.AI.A2A" Version="1.20.0-preview.260831.1" />
41
+ ```
42
+
43
+ > **Correção de 2026-09-08:** a versão anterior deste standard rotulava o A2A como **GA** com faixa `1.0.*`. Nenhuma das duas coisas se sustenta: o pacote nunca teve versão estável, e faixa flutuante num SDK de cadência semanal é o defeito que `ai-agents-setup` §1 proíbe.
44
+
45
+ ### Expor um agent via A2A
46
+
47
+ ```csharp
48
+ // Program.cs
49
+ using Microsoft.Agents.AI;
50
+ using Microsoft.Agents.AI.A2A;
51
+ using Microsoft.Extensions.AI;
52
+
53
+ var builder = WebApplication.CreateBuilder(args);
54
+
55
+ // Registrar agent via Model Registry
56
+ IChatClient chatClient = /* from ModelRegistry singleton */;
57
+ builder.Services.AddSingleton(chatClient);
58
+
59
+ builder.AddAIAgent("math", instructions: "You are a math expert.");
60
+ builder.AddAIAgent("history", instructions: "You are a history expert.");
61
+
62
+ var app = builder.Build();
63
+
64
+ app.MapA2A("math", path: "/a2a/math", agentCard: new()
65
+ {
66
+ Name = "Math Agent",
67
+ Description = "Expert in mathematics and calculations.",
68
+ Version = "1.0"
69
+ });
70
+
71
+ app.MapA2A("history", path: "/a2a/history", agentCard: new()
72
+ {
73
+ Name = "History Agent",
74
+ Description = "Expert in world history.",
75
+ Version = "1.0"
76
+ });
77
+
78
+ app.Run();
79
+ ```
80
+
81
+ ### Consumir um agent A2A remoto
82
+
83
+ ```csharp
84
+ using Microsoft.Agents.AI.A2A;
85
+
86
+ // Wrap a remote A2A endpoint as a local AIAgent
87
+ AIAgent remoteAgent = new A2AClient(new Uri("https://agents.example.com/a2a/math"))
88
+ .AsAIAgent();
89
+
90
+ var response = await remoteAgent.RunAsync("What is the integral of x^2?");
91
+ ```
92
+
93
+ ### Agent Card Discovery
94
+
95
+ ```
96
+ GET /a2a/math/v1/card → metadata (name, description, capabilities)
97
+ POST /a2a/math/v1/message:stream → send message, get streaming response
98
+ ```
99
+
100
+ | Feature A2A | Descrição |
101
+ |-------------|-----------|
102
+ | Agent Discovery | Agent Cards com metadados padronizados |
103
+ | Cross-Framework | Agent .NET pode conversar com agent Python |
104
+ | Context Persistence | `contextId` mantém conversa entre mensagens |
105
+ | Streaming | Server-Sent Events para respostas em tempo real |
106
+
107
+ ---
108
+
109
+ ## MCP Integration (Model Context Protocol)
110
+
111
+ Agents MAF podem consumir tools de **MCP servers externos** (GitHub, filesystem, Postgres,
112
+ servidores internos) e expor capacidades do projeto **como** um MCP server.
113
+
114
+ Esses dois casos têm tratamento canônico em standards dedicados — **não duplicado aqui**:
115
+
116
+ | Caso | Standard |
117
+ |------|----------|
118
+ | Agente MAF consome um MCP server externo | `ai-agents-mcp-tools` (`McpClientFactory.CreateAsync`, transports, `await using`) |
119
+ | Projeto expõe capacidades como MCP server | `ai-agents-mcp-server` (`[McpServerTool]`, `AddMcpServer`, stdio/HTTP) |
120
+
121
+ > Em produção, lembre: MCP client sempre com `await using` (dispose do transporte); MCP server
122
+ > exposto via HTTP exige autenticação. Detalhes nos standards acima.
123
+
124
+ ---
125
+
126
+ ## Caching Patterns
127
+
128
+ ### Semantic Caching (Redis)
129
+
130
+ Cache de respostas LLM por similaridade semântica — evita inferências repetidas.
131
+
132
+ > **Illustrative pseudo-code** — the exact Redis vector-search calls depend on your Redis client. For a complete, working semantic-search implementation see `ai-agents-rag-custom-pgvector` (Onda 2). The point of this section is the *pattern*: embed the query, vector-search a cache, return on a similarity hit.
133
+
134
+ ```csharp
135
+ public async Task<string?> GetCachedResponseAsync(string question)
136
+ {
137
+ var questionEmbedding = await _embedding.GenerateAsync(question);
138
+
139
+ // pseudo-code: perform a KNN vector search against the cache index
140
+ var (similarityScore, cachedResponse) = await VectorSearchCacheAsync(
141
+ "idx:semantic_cache", questionEmbedding);
142
+
143
+ if (similarityScore >= 0.95) // cosine similarity: higher = more similar
144
+ return cachedResponse;
145
+
146
+ return null; // cache miss
147
+ }
148
+ ```
149
+
150
+ **Cost savings:** embedding ~$0.0001/1K tokens vs inferência ~$0.01-0.03/1K tokens = **100-300x savings**.
151
+
152
+ ### Hybrid Cache (L1 + L2)
153
+
154
+ ```csharp
155
+ builder.Services.AddHybridCache(options =>
156
+ {
157
+ options.DefaultEntryOptions = new HybridCacheEntryOptions
158
+ {
159
+ Expiration = TimeSpan.FromMinutes(10),
160
+ LocalCacheExpiration = TimeSpan.FromMinutes(1)
161
+ };
162
+ });
163
+
164
+ // Uso num tool
165
+ [Description("Gets weather for a location")]
166
+ public async Task<WeatherResponse> GetWeatherAsync(
167
+ string location, string date, CancellationToken ct)
168
+ {
169
+ return await _cache.GetOrCreateAsync(
170
+ $"weather:{location}:{date}",
171
+ async token => await FetchFromApiAsync(location, date, token),
172
+ cancellationToken: ct);
173
+ }
174
+ ```
175
+
176
+ | Level | Location | Speed | Scope |
177
+ |-------|----------|-------|-------|
178
+ | L1 | Process memory | Fastest | Per instance |
179
+ | L2 | Redis | Very fast | Distributed |
180
+
181
+ ---
182
+
183
+ ## Observability / OpenTelemetry
184
+
185
+ Setup, enrichment (span attributes, correlation IDs, structured logging) e o workflow de investigação/análise de logs em produção têm **tratamento canônico** em **`ai-agents-observability-patterns`**. Não duplicado aqui.
186
+
187
+ > Em produção: `AddSource` das **duas** fontes — `Experimental.Microsoft.Agents.AI` e `Experimental.Microsoft.Extensions.AI` — e `EnableSensitiveData = false` fora de dev/staging. (Correção de 2026-09-08: `AgentOpenTelemetryConsts` e `EnableSensitiveTelemetryData` **não existem** no pin; medido.) Ver `ai-agents-observability-patterns` para o setup completo, o que preencher em cada span/log, e o workflow de investigação quando um incidente for reportado.
188
+
189
+ ---
190
+
191
+ ## Isolamento multi-tenant — renomeado em 1.18
192
+
193
+ Um agente registrado como singleton atende todos os tenants. O que separa um do outro não é o agente: é a **chave de isolamento** que decide de qual balde vem a sessão.
194
+
195
+ Na **1.18** (2026-08-18) essa superfície foi renomeada. Nomes atuais, medidos por reflexão sobre `Microsoft.Agents.AI.Hosting` (pacote `1.20.0-preview.260831.1`) em 2026-09-08:
196
+
197
+ | Tipo | Papel |
198
+ |---|---|
199
+ | `Microsoft.Agents.AI.Hosting.AgentIsolationKeyProvider` | Produz a chave de isolamento do request corrente |
200
+ | `Microsoft.Agents.AI.Hosting.IsolationKeyScopedAgentSessionStore` | O `AgentSessionStore` que aplica a chave; tem `IsolationKeyScopedAgentSessionStoreOptions` |
201
+ | `UseClaimsBasedAgentIsolation()` (ASP.NET Core) | Deriva a chave das claims do usuário autenticado |
202
+
203
+ **Duas advertências que valem mais que os nomes:**
204
+
205
+ 1. **O pacote é prerelease.** `Microsoft.Agents.AI.Hosting` não tem versão estável (apurado 2026-09-08). Isolamento multi-tenant por esse caminho é adoção de preview — registre em `decisions.md`.
206
+ 2. **A chave vem da credencial, nunca do payload.** Uma chave derivada de algo que o cliente envia é uma chave que o cliente escolhe. `UseClaimsBasedAgentIsolation()` existe exatamente para não deixar essa decisão passar pelo corpo do request.
207
+
208
+ ### Invocação concorrente de tools é opt-in desde 1.18
209
+
210
+ `FunctionInvokingChatClient.AllowConcurrentInvocation` (exposto como `ChatClientAgentOptions.AllowConcurrentInvocation`) tem default **`false`**: numa volta com várias chamadas de tool, elas rodam **em sequência**. Ligar a concorrência é decisão explícita — e só é segura se **todas** as tools daquele agente forem thread-safe. Um `DbContext` do EF Core **não** é: duas tools concorrentes sobre o mesmo `DbContext` scoped produzem `InvalidOperationException` intermitente sob carga, que é o pior formato possível de bug.
211
+
212
+ ---
213
+
214
+ ## Security Checklist (verifiable by morph-eval)
215
+
216
+ - [ ] API keys nunca em `appsettings.json` no repositório — bind de environment variables ou secret store
217
+ - [ ] Variáveis de provider (`OpenAI__ApiKey`, `Google__ApiKey`, `Anthropic__ApiKey`) em env vars / Docker secrets
218
+ - [ ] Input validation middleware registrado em agents públicos (PII detection, injection prevention)
219
+ - [ ] Output filtering / guardrails para conteúdo prejudicial
220
+ - [ ] Rate limiting middleware em agents expostos publicamente
221
+ - [ ] Endpoints A2A protegidos com autenticação
222
+ - [ ] Structured output usado para respostas — evita parsing de texto livre
223
+ - [ ] OpenTelemetry com `AddSource` das duas fontes `Experimental.Microsoft.*` configurado
224
+ - [ ] Multi-tenant: a chave de isolamento vem da credencial (claims), nunca do payload do request
225
+
226
+ ---
227
+
228
+ ## Production Checklist (verifiable by morph-eval)
229
+
230
+ - [ ] `Microsoft.Agents.AI` **1.20.0** (versão exata, do `ai-pin.json`) no `.csproj`; nenhum pacote SK de orquestração
231
+ - [ ] Nenhum `PackageReference` de SDK de IA com faixa flutuante; pacote fora do pin com versão exata + data de apuração
232
+ - [ ] `AllowConcurrentInvocation` continua `false`, ou todas as tools do agente são comprovadamente thread-safe
233
+ - [ ] Middleware registrado via `.AsBuilder().Use(...)` antes de `Build()`
234
+ - [ ] `ResilientToolMiddleware` (ou equivalente) em agents que chamam APIs externas
235
+ - [ ] Semantic cache configurado se o agent recebe queries repetitivas
236
+ - [ ] OpenTelemetry source = `Experimental.Microsoft.Agents.AI` **e** `Experimental.Microsoft.Extensions.AI`
237
+ - [ ] Dados sensíveis de telemetry desabilitados em produção (`EnableSensitiveData = false`)
238
+ - [ ] A2A endpoints com `MapA2A` protegidos por auth se expostos na internet
239
+ - [ ] MCP client `await using` para dispose correto do transporte
240
+
241
+ ---
242
+
243
+ ## References
244
+
245
+ - `ai-agents-setup` — pacotes, DI, quick start
246
+ - `ai-agents-sweet-spot` — decisão de arquitetura antes de middleware
247
+ - `ai-agents-providers-model-registry` — Model Registry para `_modelRegistry.GetChatClient(...)`
248
+ - `ai-agents-middleware-patterns` — **tratamento canônico** de middleware (código dos 3 níveis, telemetria, resilência, anti-hallucination)
249
+ - `ai-agents-observability-patterns` — **tratamento canônico** de observability (setup OpenTelemetry, enrichment de spans/logs, workflow de investigação)
250
+ - `ai-agents-mcp-tools` — agente MAF consumindo MCP servers externos
251
+ - `ai-agents-mcp-server` — projeto expondo capacidades como MCP server
252
+ - `ai-agents-rag-custom-pgvector` — implementação completa de busca semântica (referida em Caching)
253
+ - [Agent Middleware](https://learn.microsoft.com/agent-framework/user-guide/agents/agent-middleware)
254
+ - [A2A Integration](https://learn.microsoft.com/agent-framework/user-guide/hosting/agent-to-agent-integration)
255
+ - [Using MCP Tools](https://learn.microsoft.com/agent-framework/user-guide/model-context-protocol/using-mcp-tools)
256
+ - [MCP C# SDK](https://github.com/modelcontextprotocol/csharp-sdk)
257
+
258
+ ---
259
+
260
+ *MORPH-SPEC by Polymorphism Tech — ai-agents/production.md v3.0 (2026-09-08)*