@salesforce/afv-skills 1.37.0 → 1.38.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 (247) hide show
  1. package/package.json +1 -1
  2. package/skills/agentforce-generate/README.md +20 -3
  3. package/skills/agentforce-generate/SKILL.md +253 -440
  4. package/skills/agentforce-generate/assets/agent-spec-template.md +6 -2
  5. package/skills/agentforce-generate/assets/agents/order-service.agent +16 -12
  6. package/skills/agentforce-generate/assets/agents/production-faq.agent +4 -4
  7. package/skills/agentforce-generate/assets/agents/router-first.agent +5 -5
  8. package/skills/agentforce-generate/assets/agents/template-single-subagent.agent +4 -4
  9. package/skills/agentforce-generate/assets/agents/verification-gate.agent +8 -6
  10. package/skills/agentforce-generate/assets/agents/voice-knowledge-grounded.agent +9 -9
  11. package/skills/agentforce-generate/assets/agents/voice-service-agent.agent +7 -7
  12. package/skills/agentforce-generate/assets/patterns/README.md +3 -3
  13. package/skills/agentforce-generate/assets/patterns/action-callbacks.agent +5 -5
  14. package/skills/agentforce-generate/assets/patterns/advanced-input-bindings.agent +6 -8
  15. package/skills/agentforce-generate/assets/patterns/bidirectional-routing.agent +11 -13
  16. package/skills/agentforce-generate/assets/patterns/critical-input-collection.agent +11 -16
  17. package/skills/agentforce-generate/assets/patterns/lifecycle-events.agent +2 -3
  18. package/skills/agentforce-generate/assets/patterns/llm-controlled-actions.agent +6 -7
  19. package/skills/agentforce-generate/assets/patterns/open-gate-routing.agent +3 -3
  20. package/skills/agentforce-generate/assets/patterns/prompt-template-action.agent +14 -19
  21. package/skills/agentforce-generate/assets/patterns/system-instruction-overrides.agent +11 -20
  22. package/skills/agentforce-generate/references/actions-reference.md +2 -2
  23. package/skills/agentforce-generate/references/agent-audit-and-repair.md +135 -0
  24. package/skills/agentforce-generate/references/agent-audit-candidate-verification.md +160 -0
  25. package/skills/agentforce-generate/references/agent-audit-diagnostic-catalog.md +156 -0
  26. package/skills/agentforce-generate/references/agent-audit-diagnostics-actions-state.md +176 -0
  27. package/skills/agentforce-generate/references/agent-audit-diagnostics-architecture-evaluation.md +68 -0
  28. package/skills/agentforce-generate/references/agent-audit-diagnostics-instructions-routing.md +283 -0
  29. package/skills/agentforce-generate/references/agent-audit-evaluation-loop.md +191 -0
  30. package/skills/agentforce-generate/references/agent-audit-repair-report.md +143 -0
  31. package/skills/agentforce-generate/references/agent-audit-scope-path-review.md +180 -0
  32. package/skills/agentforce-generate/references/agent-design-and-spec-creation.md +105 -59
  33. package/skills/agentforce-generate/references/agent-script-core-language.md +144 -61
  34. package/skills/agentforce-generate/references/agent-subagent-map-diagrams.md +33 -23
  35. package/skills/agentforce-generate/references/agent-validation-and-debugging.md +37 -11
  36. package/skills/agentforce-generate/references/agentscript-toolchain.md +112 -0
  37. package/skills/agentforce-generate/references/architecture-patterns.md +81 -18
  38. package/skills/agentforce-generate/references/common-control-flow-pitfalls.md +255 -0
  39. package/skills/agentforce-generate/references/control-flow-actions-sequencing.md +198 -0
  40. package/skills/agentforce-generate/references/control-flow-lifecycle-side-effects.md +87 -0
  41. package/skills/agentforce-generate/references/examples.md +22 -22
  42. package/skills/agentforce-generate/references/instruction-resolution.md +123 -83
  43. package/skills/agentforce-generate/references/known-issues.md +1 -2
  44. package/skills/agentforce-generate/references/optimization-pattern-1-data-flow.md +4 -0
  45. package/skills/agentforce-generate/references/optimization-pattern-2-deterministic-logic.md +33 -0
  46. package/skills/agentforce-generate/references/optimization-pattern-3-reference-syntax.md +32 -3
  47. package/skills/agentforce-generate/references/optimization-pattern-4-escalation.md +2 -2
  48. package/skills/agentforce-generate/references/patterns-by-requirement.md +3 -1
  49. package/skills/agentforce-generate/references/posture-and-determinism.md +103 -22
  50. package/skills/agentforce-generate/references/reference-map.md +19 -3
  51. package/skills/agentforce-generate/references/scoring-rubric.md +1 -1
  52. package/skills/agentforce-generate/references/voice-latency-heuristics.md +4 -0
  53. package/skills/agentforce-generate/references/voice-modality-reference.md +4 -4
  54. package/skills/agentforce-generate/references/zen-of-agentscript.md +139 -23
  55. package/skills/agentforce-generate/scripts/agentscript-sdk-loader.mjs +133 -0
  56. package/skills/agentforce-generate/scripts/index-agent.mjs +141 -0
  57. package/skills/agentforce-generate/scripts/setup-agentscript-sdk.mjs +337 -0
  58. package/skills/automation-sandbox-post-copy-config-generate/SKILL.md +1 -1
  59. package/skills/automation-sandbox-post-copy-configure/SKILL.md +433 -0
  60. package/skills/automation-sandbox-post-copy-configure/assets/api_request_templates.json +89 -0
  61. package/skills/automation-sandbox-post-copy-configure/examples/sample_config_input.json +40 -0
  62. package/skills/automation-sandbox-post-copy-configure/examples/sample_execution_summary.md +79 -0
  63. package/skills/automation-sandbox-post-copy-configure/references/api_endpoints.md +273 -0
  64. package/skills/automation-sandbox-post-copy-configure/references/authentication.md +94 -0
  65. package/skills/automation-sandbox-post-copy-configure/references/execution_phasing.md +93 -0
  66. package/skills/automation-sandbox-post-copy-configure/references/rules_gotchas.md +35 -0
  67. package/skills/automation-sandbox-post-copy-configure/scripts/classify-patch-result.mjs +88 -0
  68. package/skills/automation-sandbox-post-copy-configure/scripts/map-metadata-key.mjs +98 -0
  69. package/skills/automation-sandbox-post-copy-configure/scripts/plan-phases.mjs +98 -0
  70. package/skills/automation-sandbox-post-copy-configure/scripts/resolve-target-org.mjs +56 -0
  71. package/skills/design-systems-slds-validate/SKILL.md +14 -13
  72. package/skills/dx-code-analyzer-custom-rule-create/examples/xpath-examples.md +1 -1
  73. package/skills/dx-code-analyzer-custom-rule-create/references/xpath-patterns-security.md +1 -1
  74. package/skills/dx-org-devhub-configure/SKILL.md +268 -0
  75. package/skills/dx-org-devhub-configure/examples/status-output.md +39 -0
  76. package/skills/dx-org-devhub-configure/scripts/devhub.sh +650 -0
  77. package/skills/dx-org-devhub-configure/scripts/test-devhub.sh +116 -0
  78. package/skills/dx-org-manage/SKILL.md +135 -42
  79. package/skills/dx-org-manage/assets/derive-alias.sh +95 -0
  80. package/skills/dx-org-manage/assets/scratch-def.seed.json +6 -0
  81. package/skills/dx-org-manage/examples/README.md +1 -1
  82. package/skills/dx-org-manage/examples/scratch-orgs/delete_output.json +8 -0
  83. package/skills/dx-org-manage/examples/scratch-orgs/display_output.json +23 -0
  84. package/skills/dx-org-manage/examples/scratch-orgs/list_output.json +58 -0
  85. package/skills/dx-org-manage/examples/scratch-orgs/resume_output.json +38 -0
  86. package/skills/dx-org-manage/examples/scratch-orgs/success_definition_file.json +1 -1
  87. package/skills/dx-org-manage/examples/scratch-orgs/success_edition.json +1 -1
  88. package/skills/dx-org-manage/examples/scratch-orgs/success_shape.json +41 -0
  89. package/skills/dx-org-manage/examples/scratch-orgs/success_snapshot.json +1 -1
  90. package/skills/dx-org-manage/examples/snapshots/error_output.json +3 -3
  91. package/skills/dx-org-manage/references/creating-scratch-org.md +2 -2
  92. package/skills/dx-org-manage/references/creating-snapshot.md +1 -2
  93. package/skills/dx-org-manage/references/definition_file_options.md +24 -0
  94. package/skills/dx-org-manage/references/edition_types.md +10 -8
  95. package/skills/dx-org-manage/references/opening-org.md +11 -12
  96. package/skills/dx-org-manage/references/scratch-org-create.md +303 -0
  97. package/skills/dx-org-manage/references/scratch-org-operations.md +135 -0
  98. package/skills/experience-aura-lwc-migrate/SKILL.md +120 -0
  99. package/skills/experience-aura-lwc-migrate/references/aura-api-expert.md +170 -0
  100. package/skills/experience-aura-lwc-migrate/references/aura-data-expert.md +172 -0
  101. package/skills/experience-aura-lwc-migrate/references/aura-migration-guidelines.md +299 -0
  102. package/skills/experience-aura-lwc-migrate/references/aura-prd-framework.md +79 -0
  103. package/skills/experience-aura-lwc-migrate/references/aura-redundant-code-expert.md +24 -0
  104. package/skills/experience-aura-lwc-migrate/references/aura-reference-expert.md +140 -0
  105. package/skills/experience-aura-lwc-migrate/references/aura-resolver-expert.md +115 -0
  106. package/skills/experience-aura-lwc-migrate/references/aura-slots-expert.md +67 -0
  107. package/skills/experience-aura-lwc-migrate/references/aura-style-expert.md +62 -0
  108. package/skills/experience-aura-lwc-migrate/references/aura-to-lwc-completeness-checklist.md +188 -0
  109. package/skills/experience-aura-lwc-migrate/references/aura-values-expert.md +67 -0
  110. package/skills/experience-content-media-search/SKILL.md +17 -12
  111. package/skills/experience-content-media-stock-image-search/SKILL.md +192 -0
  112. package/skills/experience-content-media-stock-image-search/scripts/download-stock-image.py +102 -0
  113. package/skills/experience-lds-best-practices-apply/SKILL.md +245 -0
  114. package/skills/experience-lds-best-practices-apply/references/adapter-apis.md +1640 -0
  115. package/skills/experience-lds-best-practices-apply/references/lds-data-consistency.md +126 -0
  116. package/skills/experience-lds-best-practices-apply/references/lds-expert.md +429 -0
  117. package/skills/experience-lds-best-practices-apply/references/lds-referential-integrity.md +322 -0
  118. package/skills/experience-lds-best-practices-apply/references/wire-adapter-types.md +1511 -0
  119. package/skills/experience-lds-graphql-generate/SKILL.md +222 -0
  120. package/skills/experience-lds-graphql-generate/references/generation-guide.md +236 -0
  121. package/skills/experience-lds-graphql-generate/references/generation-mutation.md +277 -0
  122. package/skills/experience-lds-graphql-generate/references/generation-query.md +237 -0
  123. package/skills/experience-lds-graphql-generate/scripts/fetch-lds-graphql-schema.sh +230 -0
  124. package/skills/experience-lds-graphql-generate/scripts/test-lds-graphql-query.sh +128 -0
  125. package/skills/experience-lwc-accessibility-validate/SKILL.md +112 -0
  126. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-1-1-non-text-content.md +88 -0
  127. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-3-1-i-lists.md +52 -0
  128. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-3-1-ii-tables.md +106 -0
  129. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-3-1-iii-form-labels.md +78 -0
  130. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-3-1-iv-regions.md +26 -0
  131. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-3-1-v-groups.md +66 -0
  132. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-3-5-identify-input.md +70 -0
  133. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-4-3-contrast.md +115 -0
  134. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-2-1-1-keyboard.md +47 -0
  135. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-2-4-4-link-purpose.md +39 -0
  136. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-2-4-6-headings-labels.md +50 -0
  137. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-2-5-1-pointer-gestures.md +54 -0
  138. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-2-5-2-pointer-cancellation.md +49 -0
  139. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-2-5-3-label-in-name.md +77 -0
  140. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-2-5-7-dragging-movement.md +45 -0
  141. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-3-2-1-on-focus.md +55 -0
  142. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-3-2-2-on-input.md +51 -0
  143. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-3-3-1-error-identification.md +84 -0
  144. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-3-3-2-labels-instructions.md +50 -0
  145. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-3-3-3-error-suggestion.md +64 -0
  146. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-4-1-2-i-name.md +105 -0
  147. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-4-1-2-ii-role.md +99 -0
  148. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-4-1-2-iii-value.md +97 -0
  149. package/skills/experience-lwc-accessibility-validate/references/vision/sc-1-1-1-non-text-content.md +83 -0
  150. package/skills/experience-lwc-accessibility-validate/references/vision/sc-1-4-1-use-of-color.md +62 -0
  151. package/skills/experience-lwc-accessibility-validate/references/vision/sc-1-4-10-resize-reflow.md +18 -0
  152. package/skills/experience-lwc-accessibility-validate/references/vision/sc-1-4-11-non-text-contrast.md +43 -0
  153. package/skills/experience-lwc-accessibility-validate/references/vision/sc-1-4-3-contrast.md +25 -0
  154. package/skills/experience-lwc-accessibility-validate/scripts/contrast-ratio.py +153 -0
  155. package/skills/experience-lwc-design-generate/SKILL.md +261 -0
  156. package/skills/experience-lwc-design-generate/references/figma-to-prd-blueprint.md +66 -0
  157. package/skills/experience-lwc-design-generate/references/prd-analysis-template.md +17 -0
  158. package/skills/experience-lwc-design-generate/scripts/check-component-name.sh +75 -0
  159. package/skills/experience-lwc-design-generate/scripts/detect-project-tools.sh +97 -0
  160. package/skills/experience-lwc-runtime-observe/SKILL.md +244 -0
  161. package/skills/experience-lwc-runtime-observe/examples/component-preview-and-dom.md +41 -0
  162. package/skills/experience-lwc-runtime-observe/scripts/extract-dom.sh +79 -0
  163. package/skills/experience-lwc-runtime-observe/scripts/open-frontdoor.sh +46 -0
  164. package/skills/experience-lwc-runtime-observe/scripts/verify-toolchain.sh +48 -0
  165. package/skills/experience-lwc-security-validate/SKILL.md +151 -0
  166. package/skills/experience-lwc-security-validate/examples/review-report.md +6 -0
  167. package/skills/experience-lwc-security-validate/examples/score-report.sarif.json +32 -0
  168. package/skills/experience-lwc-security-validate/references/lws-security-expert.md +986 -0
  169. package/skills/experience-lwc-security-validate/references/security-analysis.md +611 -0
  170. package/skills/experience-lwc-security-validate/scripts/check-lwc-import.sh +166 -0
  171. package/skills/experience-lwc-security-validate/scripts/validate-sarif.sh +131 -0
  172. package/skills/experience-ui-bundle-2gp-deploy/SKILL.md +454 -0
  173. package/skills/experience-ui-bundle-2gp-deploy/assets/CustomApplication.app-meta.xml +12 -0
  174. package/skills/experience-ui-bundle-2gp-deploy/assets/PermissionSet.permissionset-meta.xml +9 -0
  175. package/skills/experience-ui-bundle-2gp-deploy/scripts/find-bundle-package-dir.sh +53 -0
  176. package/skills/experience-ui-bundle-agentforce-client-generate/SKILL.md +104 -26
  177. package/skills/experience-ui-bundle-agentforce-client-generate/references/constraints.md +35 -24
  178. package/skills/experience-ui-bundle-agentforce-client-generate/references/examples.md +92 -1
  179. package/skills/experience-ui-bundle-agentforce-client-generate/references/style-tokens.md +2 -0
  180. package/skills/experience-ui-bundle-agentforce-client-generate/references/troubleshooting.md +14 -1
  181. package/skills/experience-ui-bundle-agentforce-client-generate/scripts/detect-framework.sh +67 -0
  182. package/skills/experience-ui-bundle-deploy/SKILL.md +83 -14
  183. package/skills/experience-ui-bundle-deploy/assets/Communities.settings-meta.xml +19 -0
  184. package/skills/experience-ui-bundle-deploy/assets/org-setup.config.template.json +5 -0
  185. package/skills/experience-ui-bundle-deploy/assets/social-login-auth-providers.apex +158 -0
  186. package/skills/experience-ui-bundle-deploy/references/config-scaffold.md +13 -1
  187. package/skills/experience-ui-bundle-deploy/references/social-login.md +179 -0
  188. package/skills/experience-ui-bundle-frontend-generate/SKILL.md +14 -0
  189. package/skills/experience-ui-bundle-mfa-configure/SKILL.md +6 -5
  190. package/skills/experience-ui-bundle-mfa-configure/references/social-login.md +15 -7
  191. package/skills/experience-ui-bundle-salesforce-data-access/SKILL.md +41 -5
  192. package/skills/experience-ui-bundle-salesforce-data-access/references/caching.md +10 -22
  193. package/skills/experience-ui-bundle-salesforce-data-access/references/graphql-hand-authoring.md +4 -19
  194. package/skills/experience-ui-bundle-salesforce-data-access/references/migration.md +5 -0
  195. package/skills/experience-ui-bundle-salesforce-data-access/references/sdk-api.md +33 -150
  196. package/skills/mobile-platform-native-capabilities-integrate/references/nfc.md +35 -0
  197. package/skills/platform-apex-generate/SKILL.md +8 -7
  198. package/skills/platform-apex-test-generate/SKILL.md +3 -1
  199. package/skills/platform-apex-test-run/SKILL.md +9 -8
  200. package/skills/platform-lightning-type-widget-coordinate/SKILL.md +1 -1
  201. package/skills/platform-lightning-type-widget-coordinate/examples/existing-lightning-type-with-widget-prompt.md +1 -1
  202. package/skills/platform-lightning-type-widget-coordinate/examples/new-lightning-type-with-widget-prompt.md +1 -1
  203. package/skills/platform-lightning-type-widget-coordinate/references/validation-gates.md +3 -3
  204. package/skills/platform-mcp-tool-widget-coordinate/SKILL.md +43 -67
  205. package/skills/platform-mcp-tool-widget-coordinate/examples/action-name-source-prompt.md +1 -2
  206. package/skills/platform-mcp-tool-widget-coordinate/examples/apex-invocable-source-prompt.md +2 -3
  207. package/skills/platform-mcp-tool-widget-coordinate/examples/nested-object-list-source-prompt.md +163 -0
  208. package/skills/platform-mcp-tool-widget-coordinate/examples/nested-object-single-source-prompt.md +198 -0
  209. package/skills/platform-mcp-tool-widget-coordinate/examples/pasted-tool-output-prompt.md +0 -1
  210. package/skills/platform-mcp-tool-widget-coordinate/references/build-plan-format.md +17 -11
  211. package/skills/platform-mcp-tool-widget-coordinate/references/mcp-tool-output-discovery.md +48 -15
  212. package/skills/platform-mcp-tool-widget-coordinate/references/two-clt-modeling.md +73 -10
  213. package/skills/platform-mcp-tool-widget-coordinate/references/validation-gates.md +48 -8
  214. package/skills/platform-policy-rule-generate/SKILL.md +22 -12
  215. package/skills/platform-policy-rule-generate/references/deploy-errors.md +1 -1
  216. package/skills/platform-policy-rule-generate/references/policy-schema-full.md +8 -29
  217. package/skills/platform-policy-rule-generate/references/templates-advanced.md +1 -1
  218. package/skills/platform-sharing-owd-configure/SKILL.md +20 -8
  219. package/skills/platform-sharing-owd-configure/references/access_levels.md +14 -1
  220. package/skills/platform-sharing-rules-generate/SKILL.md +67 -35
  221. package/skills/platform-sharing-rules-generate/examples/create-cases.md +16 -17
  222. package/skills/platform-sharing-rules-generate/examples/delete-cases.md +34 -79
  223. package/skills/platform-sharing-rules-generate/examples/edit-cases.md +13 -26
  224. package/skills/platform-sharing-rules-generate/scripts/count-remaining-rules.sh +33 -0
  225. package/skills/platform-widget-generate/SKILL.md +3 -5
  226. package/skills/platform-widget-generate/examples/conditional.json +18 -13
  227. package/skills/platform-widget-generate/examples/list-with-foreach.json +2 -2
  228. package/skills/platform-widget-generate/examples/single-object.json +2 -2
  229. package/skills/platform-widget-generate/references/schema-from-lightning-type.md +27 -6
  230. package/skills/platform-widget-generate/references/widget-bundle-layout.md +4 -3
  231. package/skills/service-itsm-agentic-setup-cmdb-access-assign/SKILL.md +287 -0
  232. package/skills/service-itsm-agentic-setup-cmdb-access-assign/references/mcp-invocation.md +260 -0
  233. package/skills/service-itsm-agentic-setup-cmdb-bundle-deploy/SKILL.md +252 -0
  234. package/skills/service-itsm-agentic-setup-cmdb-bundle-deploy/references/mcp-invocation.md +204 -0
  235. package/skills/service-itsm-agentic-setup-cmdb-configure/SKILL.md +259 -0
  236. package/skills/service-itsm-agentic-setup-cmdb-configure/references/mcp-invocation.md +188 -0
  237. package/skills/service-itsm-agentic-setup-cmdb-coordinate/SKILL.md +197 -0
  238. package/skills/service-itsm-agentic-setup-cmdb-coordinate/examples/output-templates.md +77 -0
  239. package/skills/service-itsm-agentic-setup-cmdb-discovery-configure/SKILL.md +316 -0
  240. package/skills/service-itsm-agentic-setup-cmdb-discovery-configure/references/mcp-invocation.md +221 -0
  241. package/skills/service-itsm-incident-priority-configure/SKILL.md +168 -0
  242. package/skills/service-itsm-incident-priority-configure/examples/matrix-operations.md +200 -0
  243. package/skills/service-itsm-incident-priority-configure/examples/render-matrix.md +54 -0
  244. package/skills/service-itsm-incident-priority-configure/examples/seed-full-matrix.md +52 -0
  245. package/skills/service-itsm-incident-priority-configure/references/sf-cli-invocation.md +264 -0
  246. package/skills/platform-mcp-tool-widget-coordinate/examples/nested-object-source-prompt.md +0 -191
  247. package/skills/platform-policy-rule-generate/references/fixtures-index.md +0 -29
@@ -0,0 +1,68 @@
1
+ # AgentScript Architecture and Evaluation Diagnostics
2
+
3
+ Use these categories to evaluate architectural pressure, evidence quality, and
4
+ cases that should remain non-findings.
5
+
6
+ ## Architecture and prompt density
7
+
8
+ Check:
9
+
10
+ - subagents exist without an objective, instruction, action, authority, or
11
+ escalation boundary;
12
+ - routers duplicate behavior better handled in one execution block;
13
+ - state and transitions compensate for unclear instructions rather than real
14
+ runtime needs;
15
+ - huge product lists, phrase lists, and repeated rules obscure higher-priority
16
+ behavior;
17
+ - one reasoning iteration must reconcile too many classifications, precedence
18
+ rules, exact sequences, or mutually dependent decisions for the deployed
19
+ model;
20
+ - one subagent owns unrelated objectives or incompatible authority.
21
+
22
+ Fix:
23
+
24
+ - Start from the smallest architecture satisfying the use cases.
25
+ - Split when a boundary materially changes objective, instructions, actions,
26
+ authority, or escalation and that separation is worth the routing and
27
+ lifecycle cost.
28
+ - Remove duplicated prose before adding state.
29
+ - Match the reasoning burden to the actual target model and configuration. If
30
+ the target model is unknown, report capability fit as unassessed.
31
+ - Do not use a stronger model as a substitute for resolving contradictions,
32
+ impossible sequences, or missing runtime data.
33
+
34
+ Evaluate with the deployed target model, representative routes, and prompt
35
+ inspection. Vary phrasing at semantic boundaries. Do not treat reduced line
36
+ count as a behavior result.
37
+
38
+ ## Evaluation integrity
39
+
40
+ Check:
41
+
42
+ - candidate-only tests;
43
+ - changed expected behavior after seeing a failure;
44
+ - aggregate score hiding a critical regression;
45
+ - simulated actions presented as live proof;
46
+ - parent and candidate labels that do not identify concrete revisions;
47
+ - tests encoding generic preferences absent from the Agent Spec or baseline.
48
+
49
+ Fix:
50
+
51
+ - Freeze the matrix and evaluator before editing.
52
+ - Record immutable baseline and candidate identifiers.
53
+ - Separate structural, simulated, and live evidence.
54
+ - Report individual critical cases as well as aggregate score.
55
+
56
+ ## Non-findings
57
+
58
+ Do not automatically report:
59
+
60
+ - a large file;
61
+ - one execution block rather than several subagents;
62
+ - absence of persistent state;
63
+ - absence of generic ambiguity, off-topic, or human-help branches;
64
+ - lack of a router in a focused workflow;
65
+ - model judgment over unstructured user intent;
66
+ - wording or formatting preferences without a reachable consequence.
67
+
68
+ These become findings only when the use cases and evidence establish harm.
@@ -0,0 +1,283 @@
1
+ # AgentScript Instruction and Routing Diagnostics
2
+
3
+ Use these categories only after the audit identifies a relevant instruction,
4
+ visibility, response, or routing concern.
5
+
6
+ ## Contents
7
+
8
+ - [Language and structural validity](#language-and-structural-validity)
9
+ - [Instruction resolution](#instruction-resolution)
10
+ - [Prompt text that impersonates code](#prompt-text-that-impersonates-code)
11
+ - [Behavioral duties versus response copy](#behavioral-duties-versus-response-copy)
12
+ - [Routing and reachability](#routing-and-reachability)
13
+ - [HyperClassifier router fit](#hyperclassifier-router-fit)
14
+
15
+ ## Language and structural validity
16
+
17
+ Check:
18
+
19
+ - unsupported blocks, hooks, utilities, conditional forms, or directives;
20
+ - malformed structural indentation or mixed indentation;
21
+ - missing required declarations in a complete bundle;
22
+ - references to undeclared variables, actions, subagents, or outputs;
23
+ - action targets or input/output schemas that disagree with implementations;
24
+ - syntax copied from a newer or different AgentScript dialect.
25
+
26
+ Evidence and fix:
27
+
28
+ - Prefer `sf agent validate authoring-bundle --json` against the intended
29
+ target org.
30
+ - Distinguish a complete bundle from an extracted fragment.
31
+ - Use the smallest supported construct.
32
+ - Do not patch around a compiler failure with prompt wording.
33
+
34
+ Evaluate:
35
+
36
+ - Require zero relevant compile errors.
37
+ - Re-run contract discovery when action definitions change.
38
+
39
+ ## Instruction resolution
40
+
41
+ Check:
42
+
43
+ - a subagent `system.instructions` value unintentionally replaces global
44
+ identity, safety, or scope instructions;
45
+ - a `system.instructions` value attempts to use `instructions: ->` or runtime
46
+ procedure statements instead of declarative prompt text;
47
+ - a system merge field is treated as deterministic enforcement rather than a
48
+ current value rendered for the model;
49
+ - global and local instructions demand incompatible outcomes;
50
+ - model-facing instructions mention runtime-only concepts the model cannot see;
51
+ - model-facing instructions name `@variables.X` without interpolating a value
52
+ the model must actually read;
53
+ - model-facing instructions compare an interpolated value even though the
54
+ runtime already knows the exact fact and a stable consequence may be clearer
55
+ or safer as a runtime branch;
56
+ - a conditional fragment assumes another fragment is present;
57
+ - repeated instructions conflict, dilute precedence, or exceed useful context.
58
+
59
+ Fix:
60
+
61
+ - Put durable invariants in the effective system instruction for every block
62
+ that needs them.
63
+ - Keep system instructions declarative. Move `run`, `set`, runtime `if`, and
64
+ transitions to supported lifecycle or reasoning procedure blocks.
65
+ - Remove duplicate or contradictory prose.
66
+ - Inject only the concrete values the model must read.
67
+
68
+ Evaluate:
69
+
70
+ - Inspect the effective prompt for each affected use case, not only the source.
71
+ - Inspect system merge fields on the first iteration and after relevant state
72
+ changes.
73
+ - Test one case per instruction-override boundary.
74
+
75
+ ### Variable visibility and decision ownership
76
+
77
+ Classify each variable-like reference before changing it:
78
+
79
+ | Source form | Meaning | Correct use |
80
+ |---|---|---|
81
+ | `if @variables.X == ...` | Runtime expression | Exact machine-known branch |
82
+ | `with input = @variables.X` | Runtime binding | Pass a trusted value |
83
+ | `| Current value: {!@variables.X}` | Prompt interpolation | Model must read the value |
84
+ | `| Set next_destination to "self_service"` | Literal instruction | Model supplies a named parameter; no current value is needed |
85
+
86
+ A bare `@variables.X` inside `|` text contributes only literal text; that token
87
+ does not provide the stored value. The same value may be separately present in
88
+ conversation or tool history. Interpolate when the current stored value is the
89
+ one the prompt must reliably receive.
90
+
91
+ Interpolation does not make a branch deterministic. This still delegates an
92
+ exact comparison to the model:
93
+
94
+ ```agentscript
95
+ | If {!@variables.account_status} == "blocked", do the blocked-account flow.
96
+ ```
97
+
98
+ If stable behavior truly depends on that exact trusted value, use a runtime
99
+ predicate and give the matching branch one concrete objective. If the
100
+ condition depends on semantic intent—such as whether the user is asking for a
101
+ human—or the use case benefits more from flexibility than strict
102
+ repeatability, leave that judgment in model instructions.
103
+
104
+ Do not auto-fix every compiler interpolation hint. First decide whether the
105
+ text needs the value, merely names a parameter, or should not ask the model to
106
+ evaluate the condition at all.
107
+
108
+ ## Prompt text that impersonates code
109
+
110
+ Check:
111
+
112
+ - indentation beneath `|` is treated as executable nesting;
113
+ - `if {!@variables.X} == ...` inside prompt text is treated as a runtime
114
+ predicate;
115
+ - Python-style `elif` is used instead of AgentScript `else if`, or a separate
116
+ `if` is nested inside a conditional body;
117
+ - `Show`, `Ask`, `Call`, `Set`, `STOP`, or `Continue` is treated as a runtime
118
+ directive;
119
+ - “Step 3” or “continue above” assumes prior prompt fragments survived;
120
+ - `MANDATORY` or `DO NOT SKIP` substitutes for gating or sequencing;
121
+ - adjacent same-scope prompt lines repeat `|` as though each marker creates a
122
+ step or boundary;
123
+ - an action visually placed under one prompt branch remains globally available.
124
+
125
+ Fix:
126
+
127
+ - Use runtime constructs for machine-known behavior.
128
+ - Use model instructions for intent, ambiguity, meaning, and other
129
+ situation-aware judgments.
130
+ - Use explicit predicates or a supported mutually exclusive conditional
131
+ structure for exclusive branches.
132
+ - When authoring new alternatives or when first-match priority matters, prefer
133
+ `if / else if / else`. Independent top-level `if` statements are valid when
134
+ multiple branches may run or their predicates are provably mutually
135
+ exclusive. Do not rewrite an equivalent form during a Surface repair without
136
+ a diagnostic or concrete overlap, gap, priority, or use-case consequence.
137
+ Spell the clause `else if`; `elif` is invalid.
138
+ - Collapse adjacent same-scope prompt fragments into one `|` block with
139
+ aligned continuation lines. Start a new marker after a runtime statement or
140
+ branch when the structure requires a new fragment.
141
+ - Preserve a valid `instructions: ->` block that contains only `|` prompt text
142
+ during a bounded repair. The absence of runtime statements does not make the
143
+ block defective. Changing it to `instructions: |` is cosmetic unless the
144
+ user explicitly requests scalar-style cleanup or runtime evidence shows a
145
+ behavior difference.
146
+ - Make each resolved prompt fragment understandable with the other fragments
147
+ that can accompany it in the same reachable state.
148
+
149
+ Evaluate:
150
+
151
+ - Inspect both effective instructions and available actions for true and false
152
+ versions of each branch condition.
153
+ - For a marker-only cleanup, compile the file and compare the resolved prompt
154
+ text before and after; do not claim a behavioral repair from formatting
155
+ alone.
156
+
157
+ ## Behavioral duties versus response copy
158
+
159
+ Check:
160
+
161
+ - ordinary instructions are written as finished dialogue instead of telling
162
+ the model what outcome, content, and constraints the response needs;
163
+ - draft copy hides whether a line is a required fact, an example, a tone cue,
164
+ or the complete response duty;
165
+ - two candidate replies can resolve into the same prompt even though their
166
+ underlying duties are mutually exclusive;
167
+ - exact wording is implied by quotation or prose style but never stated as a
168
+ requirement;
169
+ - rigid canned text discards relevant conversation context without a legal,
170
+ compliance, safety, brand, or grounding reason.
171
+
172
+ Default to behavioral instructions:
173
+
174
+ ```agentscript
175
+ if @variables.cart_validation_failed:
176
+ | Explain that one or more cart items are unavailable. Do not offer
177
+ payment. Ask the user to review or remove those items.
178
+ else:
179
+ | Tell the user the current cart total is {!@variables.cart_total}. Ask
180
+ whether they want to proceed to payment or cancel.
181
+ ```
182
+
183
+ This states what the model must accomplish while leaving ordinary wording
184
+ responsive to the conversation. It also exposes the real branch duties for
185
+ review.
186
+
187
+ Use response copy only when the wording itself is part of the requirement. In
188
+ that case, make the contract explicit rather than hoping the model infers it:
189
+
190
+ ```agentscript
191
+ | Respond with exactly this approved notice, with no additions:
192
+ "This call may be recorded for quality and training purposes."
193
+ ```
194
+
195
+ Examples and tone samples are not exact-copy requirements. Label them as
196
+ examples and state which properties should carry over.
197
+
198
+ Fix:
199
+
200
+ - replace ordinary candidate dialogue with the intended response duty,
201
+ required facts, prohibited claims, and next conversational objective;
202
+ - preserve merge fields for exact values the model must receive;
203
+ - make mutually exclusive duties exclusive with runtime predicates when they
204
+ depend on trusted machine state;
205
+ - retain exact copy only when the use case actually requires it, and say
206
+ `Respond exactly` or equivalent;
207
+ - keep useful sample wording as a labeled example rather than an unlabeled
208
+ command.
209
+
210
+ Evaluate:
211
+
212
+ - inspect every reachable assembled prompt and name its single current
213
+ response duty;
214
+ - vary the preceding conversation and confirm ordinary responses adapt while
215
+ preserving required facts and exclusions;
216
+ - for exact-copy cases, assert the literal output and absence of additions;
217
+ - do not report stylistic preference alone as a defect: identify the ambiguity,
218
+ conflict, lost context, or unsupported exact-copy requirement it causes.
219
+
220
+ ## Routing and reachability
221
+
222
+ Check:
223
+
224
+ - independent conditions can resolve simultaneously;
225
+ - no condition handles a reachable state;
226
+ - precedence is stated in prose but not represented by predicates;
227
+ - a branch depends on an accidental default or a value with no producer;
228
+ - a route is unreachable because an earlier transition or reset always wins;
229
+ - a broad fallback steals a specific use case;
230
+ - routing descriptions disagree with reasoning instructions.
231
+
232
+ Fix:
233
+
234
+ - Use mutually exclusive predicates or another supported mutually exclusive
235
+ structure.
236
+ - Encode only machine-known precedence deterministically.
237
+ - Add a fallback only when intended use cases require one.
238
+
239
+ Evaluate:
240
+
241
+ - Test each route positively and negatively.
242
+ - Test ambiguous boundary utterances against neighboring routes.
243
+
244
+ ## HyperClassifier router fit
245
+
246
+ Check:
247
+
248
+ - `model://sfdc_ai__DefaultEinsteinHyperClassifier` is used on a node that must
249
+ answer, clarify, inspect images, set state, run domain actions, escalate,
250
+ delegate to a connected agent, or use `before_reasoning` or
251
+ `after_reasoning`;
252
+ - a HyperClassifier reasoning action is anything other than
253
+ `@utils.transition`;
254
+ - route descriptions overlap, omit important exclusions, or disagree with the
255
+ target subagents;
256
+ - trusted state should remove an ineligible route but no `available when` guard
257
+ does so;
258
+ - the design expects the router itself to respond when classification is
259
+ ambiguous instead of routing to an intended clarification or fallback
260
+ subagent;
261
+ - an ordinary-model router is reported as defective merely because it does not
262
+ use HyperClassifier.
263
+
264
+ Fix:
265
+
266
+ - Add HyperClassifier only when the node can remain a pure transition selector
267
+ and routing latency is a requirement.
268
+ - Move conversation and domain work to the target subagent, or keep an ordinary
269
+ model when those duties belong in the entry node.
270
+ - Use `available when` for machine-known eligibility and distinct action
271
+ descriptions for semantic intent.
272
+ - Do not create a router or additional subagents solely to use HyperClassifier.
273
+
274
+ Evaluate:
275
+
276
+ - Run `sf agent validate authoring-bundle --json` and confirm the router has no
277
+ unsupported actions or lifecycle hooks.
278
+ - Preview positive and negative examples for every route, ambiguous boundaries,
279
+ follow-up turns, unavailable-route states, and the intended fallback.
280
+ - Inspect traces for the selected transition. Do not infer correct routing from
281
+ plausible response text.
282
+ - Treat a compatible ordinary-model router as an optimization opportunity only
283
+ when latency or observed transition reliability justifies the change.
@@ -0,0 +1,191 @@
1
+ # AgentScript Audit and Repair Evaluation Loop
2
+
3
+ Use this loop to compare an unchanged AgentScript agent with a minimally
4
+ repaired candidate. The goal is not to maximize a generic score. The goal is to
5
+ improve the affected use cases without weakening the rest.
6
+
7
+ ## Contents
8
+
9
+ - [Delivery guard](#delivery-guard)
10
+ - [Freeze the comparison](#1-freeze-the-comparison)
11
+ - [Build the use-case matrix](#2-build-the-use-case-matrix)
12
+ - [Capture the baseline](#3-capture-the-baseline)
13
+ - [Apply one coherent repair](#4-apply-one-coherent-repair)
14
+ - [Continue candidate verification](#continue-candidate-verification)
15
+
16
+ ## Delivery guard
17
+
18
+ Treat the comparison record as a durable artifact, not an end-of-task summary.
19
+ Write the baseline identity and initial use cases as soon as they are known,
20
+ then update the same record after each repair batch. Evaluate Critical and High
21
+ findings before lower-priority hypotheses. Missing runtime access or unresolved
22
+ non-blocking semantics becomes a stated limitation; it does not justify an
23
+ open-ended research loop.
24
+
25
+ ## 1. Freeze the comparison
26
+
27
+ Record:
28
+
29
+ - baseline and candidate identity. Prefer a revision or digest when two
30
+ different artifacts are compared. For an unchanged local audit, an explicit
31
+ statement that baseline and candidate are the same byte-identical file is
32
+ sufficient; do not manufacture hashes for ceremony;
33
+ - target org alias and API name, if used;
34
+ - Salesforce CLI version;
35
+ - local compiler provider, exact package version or source commit, and entry
36
+ path—or **compiler not used** with the recorded cause;
37
+ - model and runtime surface;
38
+ - action mode: simulated or live;
39
+ - evaluator and expected outcomes;
40
+ - use-case IDs and which are explicit versus inferred;
41
+ - selected intervention level and the user's choice when Structural or Rewrite
42
+ is selected.
43
+
44
+ Do not change these after seeing candidate results.
45
+
46
+ Use labels that make the comparison unambiguous:
47
+
48
+ ```text
49
+ baseline = unchanged agent at <revision-or-digest-or-path>
50
+ candidate = repaired agent at <revision-or-digest-or-path>
51
+ ```
52
+
53
+ When no change is made, write `candidate = baseline; file unchanged` instead of
54
+ requiring a digest. “Parent” and “candidate” are meaningful only when the
55
+ artifacts being compared are identified clearly enough to reproduce the result.
56
+
57
+ ## 2. Build the use-case matrix
58
+
59
+ For each case, record:
60
+
61
+ | Field | Meaning |
62
+ |---|---|
63
+ | ID | Stable case identifier |
64
+ | Source | User requirement, Agent Spec, existing test, or inferred behavior |
65
+ | Turns | Full multi-turn sequence |
66
+ | Expected owner | Start agent or subagent |
67
+ | Expected action | Required invocation, or `none` |
68
+ | Forbidden actions | Actions that must not be available or invoked |
69
+ | Expected state | Material state changes |
70
+ | Expected effect | Observable external result, if any |
71
+ | Evaluation mode | Static, simulated, preview live-action, or test suite |
72
+
73
+ Include positive, negative, retry, continuation, and repeated-request cases only
74
+ when material to the supported use cases.
75
+
76
+ ## 3. Capture the baseline
77
+
78
+ ### Structural validation
79
+
80
+ Run the bundled local compiler first. Then, when a complete bundle and
81
+ authenticated target org are available:
82
+
83
+ ```bash
84
+ sf config get target-org --json
85
+ sf agent validate authoring-bundle --json --api-name <BundleName>
86
+ ```
87
+
88
+ Record exact diagnostics. Do not edit first and reconstruct the baseline later.
89
+ Treat diagnostics as evidence, not an optimization score. Do not silence a
90
+ warning by violating documented syntax, removing intentional initialization,
91
+ or changing behavior. When compiler output conflicts with canonical guidance,
92
+ preserve the documented behavior and report the discrepancy.
93
+
94
+ When org validation is unavailable:
95
+
96
+ - run documented repository checks that already exist;
97
+ - record the static limitation;
98
+ - do not claim compiler validity.
99
+
100
+ Do not substitute regex or a home-grown parser for AgentScript validation.
101
+
102
+ ### Behavioral validation
103
+
104
+ Use preview when safe:
105
+
106
+ ```bash
107
+ sf agent preview start --json \
108
+ --authoring-bundle <BundleName> \
109
+ --simulate-actions \
110
+ -o <org-alias>
111
+
112
+ sf agent preview send --json \
113
+ --session-id <session-id> \
114
+ --utterance "<case turn>" \
115
+ --authoring-bundle <BundleName> \
116
+ -o <org-alias>
117
+
118
+ sf agent preview end --json \
119
+ --session-id <session-id> \
120
+ --authoring-bundle <BundleName> \
121
+ -o <org-alias>
122
+ ```
123
+
124
+ Use `--simulate-actions` to test:
125
+
126
+ - routing;
127
+ - effective instructions;
128
+ - action availability;
129
+ - model selection;
130
+ - response posture.
131
+
132
+ Simulation does not prove:
133
+
134
+ - output-dependent branches;
135
+ - Apex or Flow behavior;
136
+ - external writes;
137
+ - transfer, message, charge, or record effects.
138
+
139
+ Use `--use-live-actions` only with explicit approval, a verified non-production
140
+ org, and safe data.
141
+
142
+ ### Preserve evidence
143
+
144
+ For each case, retain:
145
+
146
+ ```text
147
+ input turns
148
+ effective instructions
149
+ available actions
150
+ invoked actions
151
+ action outputs
152
+ state changes
153
+ transitions
154
+ final response
155
+ external effect verification
156
+ ```
157
+
158
+ If the environment cannot provide one layer, mark it unavailable.
159
+
160
+ ## 4. Apply one coherent repair
161
+
162
+ Repair one coherent cause group at a time, such as:
163
+
164
+ - one malformed indentation family;
165
+ - one premature completion/result-parsing family;
166
+ - one action-availability and duplicate-effect family.
167
+
168
+ Do not mix broad reformatting with behavioral changes.
169
+ Do not exceed the selected intervention level. If the evidence shows the
170
+ selected level cannot resolve the finding, stop and request a broader choice
171
+ before editing further.
172
+
173
+ Record for each change:
174
+
175
+ - finding ID;
176
+ - exact source location;
177
+ - use case repaired;
178
+ - invariant enforced;
179
+ - expected observable difference.
180
+
181
+ For Structural or Rewrite candidates, also record every material removed
182
+ subagent, route, experience-specific branch, action, default, and user-visible
183
+ response. Identify where each capability is preserved or name the accepted
184
+ behavior change. Static “unused” analysis alone does not establish that a
185
+ reachable capability is safe to remove.
186
+
187
+ ## Continue candidate verification
188
+
189
+ After applying the coherent repair, continue with
190
+ [Audit Candidate Verification](agent-audit-candidate-verification.md) to inspect
191
+ the candidate, decide whether to keep it, handle regressions, and report limits.
@@ -0,0 +1,143 @@
1
+ # AgentScript Audit Repair and Report
2
+
3
+ Continue here after the scope and reachable-path review is complete.
4
+
5
+ ## Contents
6
+
7
+ - [Select the Intervention Level](#4-select-the-intervention-level)
8
+ - [Capture the Baseline](#5-capture-the-baseline)
9
+ - [Apply the Selected Repairs](#6-apply-the-selected-repairs)
10
+ - [Evaluate and Iterate](#7-evaluate-and-iterate)
11
+ - [Report the Result](#8-report-the-result)
12
+
13
+ ## Workflow (continued)
14
+
15
+ ### 4. Select the Intervention Level
16
+
17
+ Assess Surface, Structural, and Rewrite against the ranked findings using the
18
+ criteria in the Diagnostic Catalog. For each level, state whether it is
19
+ warranted, what it would change, which findings it would leave unresolved, and
20
+ its regression and evaluation cost.
21
+
22
+ Recommend the smallest level that can resolve the accepted findings. Record an
23
+ explicit user choice before Structural or Rewrite changes. A general request
24
+ to fix the agent authorizes Surface repairs only; stop and ask before crossing
25
+ that boundary. If a selected level proves insufficient, report why and request
26
+ a new choice instead of expanding the scope silently.
27
+
28
+ "Smallest sufficient" means the smallest level that resolves every accepted
29
+ finding affecting an intended use case, including a shared root cause. Do not
30
+ recommend Surface as the final repair when it only makes a path reachable but
31
+ leaves overlapping state that still assembles competing duties on that path.
32
+ In that situation, recommend Structural; Surface may be offered only as an
33
+ explicitly incomplete stabilization option.
34
+
35
+ Do not classify a repair from the number of edited lines alone. If reliable
36
+ sequencing requires coordinated changes across several phase variables,
37
+ producers, consumers, and reset paths, treat the coupled state ownership as a
38
+ Structural problem even when each individual edit looks small. Keep Surface
39
+ for isolated wiring defects whose surrounding lifecycle remains coherent.
40
+
41
+ When the proposed Structural change reorganizes a cross-turn lifecycle, name
42
+ the regression cases that prove the new ownership works: normal continuation,
43
+ correction before commitment, cancellation or intent change, and reset or a
44
+ second independent request. Include only boundaries material to the flow; do
45
+ not add state or ceremony solely to satisfy this list.
46
+
47
+ ### 5. Capture the Baseline
48
+
49
+ - Run available project checks and Salesforce CLI validation before editing.
50
+ - Run the use-case matrix against the unchanged agent when a safe execution
51
+ surface is available.
52
+ - Use a fresh session for each independent case. Keep one session only for the
53
+ turns of a deliberate multi-turn case.
54
+ - Use simulated actions only for routing, instruction, and action-selection
55
+ checks. Do not use simulation to claim output-dependent branches or external
56
+ effects work.
57
+ - Run live actions only with explicit user approval, a confirmed
58
+ non-production environment, and safe test data.
59
+ - If runtime testing is unavailable, record a static baseline and state the
60
+ limitation. Do not invent a score.
61
+
62
+ Preserve baseline results separately from candidate results.
63
+
64
+ ### 6. Apply the Selected Repairs
65
+
66
+ Fix one coherent cause group at a time:
67
+
68
+ 1. syntax, structural, and unsupported-language failures;
69
+ 2. authorization, safety, and duplicate-side-effect failures;
70
+ 3. dead, overlapping, or incorrectly gated paths;
71
+ 4. output, state, lifecycle, and continuation failures;
72
+ 5. unnecessary complexity with a demonstrated failure mode.
73
+
74
+ For each group:
75
+
76
+ - remain within the selected intervention level;
77
+ - change the narrowest runtime construct that owns the problem;
78
+ - preserve valid optional metadata and unrelated bytes in bounded repairs;
79
+ - do not normalize equivalent control flow merely because another form is
80
+ preferred for newly authored code;
81
+ - use `available when`, typed outputs, deterministic assignments, an explicit
82
+ reasoning boundary, or a purpose-built implementation that owns the complete
83
+ sequence when prose cannot enforce the invariant;
84
+ - keep semantic intent tests in model instructions, and move exact comparisons
85
+ over trusted runtime values into AgentScript control when their consequences
86
+ require stable enforcement;
87
+ - interpolate a runtime value only when the model must read that value; do not
88
+ rewrite literal parameter names or author documentation mechanically;
89
+ - remove state with no named runtime or later exact-output consumer and no
90
+ evidence-preservation need beyond the usable history window;
91
+ - set completion only from the strongest result the runtime can prove;
92
+ - keep logic changes separate from broad formatting cleanup;
93
+ - for Structural or Rewrite work, record where each removed subagent,
94
+ route, experience-specific branch, action, default, and user-visible
95
+ response went—or identify the accepted behavior change;
96
+ - preserve unrelated behavior and wording.
97
+
98
+ If the user requested diagnosis only, stop before editing and provide the
99
+ repair and evaluation plan.
100
+
101
+ ### 7. Evaluate and Iterate
102
+
103
+ After each coherent repair group:
104
+
105
+ 1. rerun project checks and Salesforce CLI validation;
106
+ 2. replay the same baseline use cases with the same evaluator;
107
+ 3. run the new regression case that exposes the repaired defect;
108
+ 4. inspect effective instructions, action availability, invocation, outputs,
109
+ state changes, transitions, and effects—not only final response text;
110
+ 5. compare baseline and candidate for the selected unaffected canary cases;
111
+ 6. verify every material removal in Structural or Rewrite work is preserved
112
+ elsewhere or recorded as an accepted behavior change;
113
+ 7. keep the change only when the target case improves and unrelated cases are
114
+ no worse.
115
+
116
+ If a candidate regresses, narrow or revert that repair and repeat. Do not
117
+ change the evaluator to make the candidate pass.
118
+
119
+ ### 8. Report the Result
120
+
121
+ Update the report throughout the audit rather than creating it only at the end.
122
+ Return the final checkpoint with the most consequential supported information
123
+ first:
124
+
125
+ 1. **Health summary:** what is broken, risky, or sound.
126
+ 2. **Use-case matrix:** explicit versus inferred cases and expected outcomes.
127
+ 3. **Findings:** severity, location, evidence, affected cases, and disposition.
128
+ 4. **Intervention:** assessment of all three levels, recommendation, user
129
+ choice, and selected scope.
130
+ 5. **Changes:** the minimal repair made for each accepted finding.
131
+ 6. **Baseline versus candidate:** same cases, same evaluator, exact results.
132
+ 7. **Validation:** local compiler provider and version or source commit—or
133
+ **compiler not used** with cause—plus target-org CLI, preview/test mode,
134
+ action mode, and limits.
135
+ 8. **Remaining risks:** only evidence-backed unresolved items.
136
+
137
+ If work stops early because of missing evidence, access, approval, or an
138
+ unresolved safety-critical contract, still return the current ranked ledger,
139
+ completed checks, completed changes if any, and the exact next decision needed.
140
+ Never substitute continued research for a deliverable blocker report.
141
+
142
+ State “no actionable finding” when that is the evidence. An audit is not
143
+ required to prescribe a change.