@salesforce/afv-skills 1.29.0 → 1.31.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 (234) hide show
  1. package/README.md +2 -0
  2. package/package.json +1 -1
  3. package/skills/agentforce-architecture-analyze/README.md +2 -8
  4. package/skills/agentforce-architecture-analyze/SKILL.md +2 -2
  5. package/skills/agentforce-architecture-analyze/references/contract.json +4 -4
  6. package/skills/agentforce-architecture-analyze/references/soql_fields.md +1 -1
  7. package/skills/data360-activate/README.md +0 -1
  8. package/skills/data360-activate/SKILL.md +0 -2
  9. package/skills/data360-code-extension-generate/SKILL.md +15 -2
  10. package/skills/data360-connect/README.md +0 -2
  11. package/skills/data360-connect/SKILL.md +0 -2
  12. package/skills/data360-harmonize/SKILL.md +0 -1
  13. package/skills/data360-orchestrate/README.md +0 -7
  14. package/skills/data360-orchestrate/SKILL.md +0 -2
  15. package/skills/data360-prepare/README.md +0 -1
  16. package/skills/data360-prepare/SKILL.md +0 -1
  17. package/skills/data360-query/README.md +0 -1
  18. package/skills/data360-query/SKILL.md +0 -1
  19. package/skills/data360-segment/README.md +0 -1
  20. package/skills/data360-segment/SKILL.md +0 -2
  21. package/skills/dx-pkg-post-install-configure/SKILL.md +184 -0
  22. package/skills/experience-cms-brand-apply/SKILL.md +47 -16
  23. package/skills/experience-lwc-generate/README.md +3 -2
  24. package/skills/experience-lwc-generate/references/async-notification-patterns.md +1 -1
  25. package/skills/experience-lwc-generate/references/component-patterns.md +3 -3
  26. package/skills/experience-lwc-generate/references/flow-integration-guide.md +1 -1
  27. package/skills/experience-lwc-generate/references/lwc-best-practices.md +4 -4
  28. package/skills/experience-lwc-generate/references/scoring-and-testing.md +1 -1
  29. package/skills/experience-lwc-generate/references/state-management.md +2 -2
  30. package/skills/experience-lwc-generate/references/triangle-pattern.md +3 -3
  31. package/skills/experience-lwc-generate/scripts/post-tool-validate.py +2 -2
  32. package/skills/experience-lwc-generate/scripts/template_validator.py +1 -1
  33. package/skills/experience-ui-bundle-app-coordinate/SKILL.md +198 -34
  34. package/skills/experience-ui-bundle-app-coordinate/scripts/check-hosting-target.sh +26 -0
  35. package/skills/experience-ui-bundle-app-coordinate/scripts/check-sfdx-project.sh +15 -0
  36. package/skills/experience-ui-bundle-metadata-generate/SKILL.md +19 -8
  37. package/skills/experience-ui-bundle-metadata-generate/references/csp-metadata-format.md +2 -2
  38. package/skills/experience-ui-bundle-metadata-generate/scripts/check-api-version.sh +30 -0
  39. package/skills/external-diagram-mermaid-generate/README.md +2 -2
  40. package/skills/external-diagram-mermaid-generate/SKILL.md +1 -3
  41. package/skills/external-diagram-mermaid-generate/assets/agentforce/agent-flow.md +4 -4
  42. package/skills/external-diagram-mermaid-generate/assets/architecture/system-landscape.md +1 -1
  43. package/skills/external-diagram-mermaid-generate/assets/datamodel/b2b-commerce-erd.md +3 -3
  44. package/skills/external-diagram-mermaid-generate/assets/datamodel/campaigns-erd.md +1 -1
  45. package/skills/external-diagram-mermaid-generate/assets/datamodel/consent-erd.md +2 -2
  46. package/skills/external-diagram-mermaid-generate/assets/datamodel/files-erd.md +2 -2
  47. package/skills/external-diagram-mermaid-generate/assets/datamodel/forecasting-erd.md +2 -2
  48. package/skills/external-diagram-mermaid-generate/assets/datamodel/fsl-erd.md +2 -2
  49. package/skills/external-diagram-mermaid-generate/assets/datamodel/party-model-erd.md +1 -1
  50. package/skills/external-diagram-mermaid-generate/assets/datamodel/quote-order-erd.md +3 -3
  51. package/skills/external-diagram-mermaid-generate/assets/datamodel/revenue-cloud-erd.md +2 -2
  52. package/skills/external-diagram-mermaid-generate/assets/datamodel/sales-cloud-erd.md +1 -1
  53. package/skills/external-diagram-mermaid-generate/assets/datamodel/salesforce-erd.md +1 -1
  54. package/skills/external-diagram-mermaid-generate/assets/datamodel/scheduler-erd.md +2 -2
  55. package/skills/external-diagram-mermaid-generate/assets/datamodel/service-cloud-erd.md +3 -3
  56. package/skills/external-diagram-mermaid-generate/assets/datamodel/territory-management-erd.md +1 -1
  57. package/skills/external-diagram-mermaid-generate/assets/integration/api-sequence.md +1 -1
  58. package/skills/external-diagram-mermaid-generate/assets/oauth/authorization-code-pkce.md +1 -1
  59. package/skills/external-diagram-mermaid-generate/assets/oauth/authorization-code.md +1 -1
  60. package/skills/external-diagram-mermaid-generate/assets/oauth/client-credentials.md +1 -1
  61. package/skills/external-diagram-mermaid-generate/assets/oauth/device-authorization.md +2 -2
  62. package/skills/external-diagram-mermaid-generate/assets/oauth/jwt-bearer.md +2 -2
  63. package/skills/external-diagram-mermaid-generate/assets/oauth/refresh-token.md +1 -1
  64. package/skills/external-diagram-mermaid-generate/assets/oauth/user-agent-social-sign-on.md +2 -2
  65. package/skills/external-diagram-mermaid-generate/assets/role-hierarchy/user-hierarchy.md +1 -1
  66. package/skills/external-diagram-mermaid-generate/references/color-palette.md +13 -13
  67. package/skills/external-diagram-mermaid-generate/references/diagram-conventions.md +5 -5
  68. package/skills/external-diagram-mermaid-generate/references/erd-conventions.md +1 -1
  69. package/skills/external-diagram-mermaid-generate/references/mermaid-styling.md +2 -2
  70. package/skills/external-diagram-mermaid-generate/references/preview-guide.md +1 -1
  71. package/skills/external-diagram-mermaid-generate/references/usage-examples.md +9 -9
  72. package/skills/external-diagram-mermaid-generate/scripts/README.md +1 -1
  73. package/skills/integration-connectivity-connected-app-configure/README.md +4 -5
  74. package/skills/integration-connectivity-connected-app-configure/SKILL.md +2 -2
  75. package/skills/integration-connectivity-connected-app-configure/references/example-usage.md +7 -7
  76. package/skills/integration-connectivity-connected-app-configure/references/migration-guide.md +1 -1
  77. package/skills/integration-connectivity-connected-app-configure/references/oauth-flows-reference.md +1 -1
  78. package/skills/integration-connectivity-connected-app-configure/references/testing-validation-guide.md +3 -3
  79. package/skills/integration-connectivity-generate/README.md +1 -1
  80. package/skills/integration-connectivity-generate/SKILL.md +6 -0
  81. package/skills/integration-connectivity-generate/assets/callouts/rest-queueable-callout.cls +1 -1
  82. package/skills/integration-connectivity-generate/assets/external-services/external-service-operations.md +1 -1
  83. package/skills/integration-connectivity-generate/assets/soap/wsdl2apex-guide.md +1 -1
  84. package/skills/integration-connectivity-generate/references/callout-patterns.md +4 -0
  85. package/skills/integration-connectivity-generate/references/cdc-guide.md +2 -2
  86. package/skills/integration-connectivity-generate/references/event-driven-architecture-guide.md +5 -5
  87. package/skills/integration-connectivity-generate/references/event-patterns.md +3 -2
  88. package/skills/integration-connectivity-generate/references/external-services-guide.md +4 -1
  89. package/skills/integration-connectivity-generate/references/messaging-api-v2.md +2 -2
  90. package/skills/integration-connectivity-generate/references/named-credentials-automation.md +1 -1
  91. package/skills/integration-connectivity-generate/references/named-credentials-guide.md +12 -2
  92. package/skills/integration-connectivity-generate/references/platform-events-guide.md +3 -3
  93. package/skills/integration-connectivity-generate/references/rest-callout-patterns.md +1 -1
  94. package/skills/integration-connectivity-generate/references/scoring-rubric.md +1 -1
  95. package/skills/integration-connectivity-generate/references/security-best-practices.md +5 -2
  96. package/skills/integration-connectivity-generate/scripts/configure-named-credential.sh +16 -5
  97. package/skills/integration-connectivity-generate/scripts/set-api-credential.sh +11 -2
  98. package/skills/integration-connectivity-generate/scripts/suggest_credential_setup.py +4 -3
  99. package/skills/integration-connectivity-generate/scripts/validate_integration.py +1 -1
  100. package/skills/omnistudio-callable-apex-generate/README.md +1 -5
  101. package/skills/omnistudio-callable-apex-generate/SKILL.md +14 -4
  102. package/skills/omnistudio-callable-apex-generate/assets/pattern_callable_vanilla.cls +8 -1
  103. package/skills/omnistudio-callable-apex-generate/examples/Test_VlocityOpenInterface2Conversion/TRANSCRIPT.md +1 -1
  104. package/skills/omnistudio-callable-apex-generate/examples/Test_VlocityOpenInterfaceConversion/TRANSCRIPT.md +1 -1
  105. package/skills/omnistudio-datamapper-generate/SKILL.md +1 -1
  106. package/skills/omnistudio-datamapper-generate/assets/completion-summary-template.md +2 -2
  107. package/skills/omnistudio-datamapper-generate/references/best-practices.md +9 -9
  108. package/skills/omnistudio-datamapper-generate/references/naming-conventions.md +6 -6
  109. package/skills/omnistudio-datapacks-deploy/README.md +1 -1
  110. package/skills/omnistudio-datapacks-deploy/examples/business-internet-plus-bundle/deploy-business-internet-plus-bundle.yaml +1 -1
  111. package/skills/omnistudio-dependencies-analyze/SKILL.md +12 -5
  112. package/skills/omnistudio-dependencies-analyze/references/dependency-patterns.md +9 -9
  113. package/skills/omnistudio-dependencies-analyze/references/namespace-guide.md +1 -1
  114. package/skills/omnistudio-epc-catalog-generate/README.md +1 -1
  115. package/skills/omnistudio-flexcard-generate/SKILL.md +11 -4
  116. package/skills/omnistudio-flexcard-generate/references/best-practices.md +6 -6
  117. package/skills/omnistudio-flexcard-generate/references/data-binding-guide.md +9 -9
  118. package/skills/omnistudio-integration-procedure-generate/SKILL.md +9 -1
  119. package/skills/omnistudio-integration-procedure-generate/references/element-types.md +3 -3
  120. package/skills/omnistudio-omniscript-generate/SKILL.md +2 -2
  121. package/skills/omnistudio-omniscript-generate/references/best-practices.md +1 -1
  122. package/skills/omnistudio-omniscript-generate/scripts/check-duplicate-omniscript.sh +8 -0
  123. package/skills/omnistudio-omniscript-generate/scripts/deploy-omniscript.sh +8 -0
  124. package/skills/platform-apex-logs-debug/README.md +2 -2
  125. package/skills/platform-apex-logs-debug/references/cli-commands.md +2 -2
  126. package/skills/platform-apex-logs-debug/references/debug-log-reference.md +16 -16
  127. package/skills/platform-apex-logs-debug/references/log-analysis-tools.md +2 -2
  128. package/skills/platform-apex-test-run/README.md +1 -1
  129. package/skills/platform-apex-test-run/references/test-fix-loop.md +2 -2
  130. package/skills/platform-apex-test-run/references/testing-best-practices.md +3 -3
  131. package/skills/platform-custom-field-generate/SKILL.md +12 -11
  132. package/skills/platform-custom-field-generate/references/advanced-picklists.md +17 -17
  133. package/skills/platform-custom-report-type-generate/SKILL.md +259 -0
  134. package/skills/platform-custom-report-type-generate/examples/AccountProjectsWithTasks.reportType-meta.xml +51 -0
  135. package/skills/platform-custom-report-type-generate/examples/AccountsWithIndustry.reportType-meta.xml +27 -0
  136. package/skills/platform-custom-report-type-generate/examples/AccountsWithProjects.reportType-meta.xml +44 -0
  137. package/skills/platform-custom-report-type-generate/references/category-values.md +32 -0
  138. package/skills/platform-custom-report-type-generate/references/errors-and-troubleshooting.md +24 -0
  139. package/skills/platform-data-manage/README.md +4 -4
  140. package/skills/platform-data-manage/references/bulk-testing-example.md +1 -1
  141. package/skills/platform-data-manage/references/crud-workflow-example.md +2 -2
  142. package/skills/platform-data-manage/references/orchestration.md +6 -6
  143. package/skills/platform-dataspace-access-configure/SKILL.md +318 -0
  144. package/skills/platform-docs-get/SKILL.md +4 -0
  145. package/skills/platform-docs-get/scripts/extract_salesforce_doc.py +78 -13
  146. package/skills/platform-encryption-configure/SKILL.md +122 -0
  147. package/skills/platform-encryption-configure/assets/EncryptionKey.settings-meta.xml +17 -0
  148. package/skills/platform-encryption-configure/assets/PlatformEncryption.settings-meta.xml +15 -0
  149. package/skills/platform-encryption-configure/assets/encrypted-field.field-meta.xml +22 -0
  150. package/skills/platform-encryption-configure/examples/cache-only-keys.settings-meta.xml +11 -0
  151. package/skills/platform-encryption-configure/references/encryption-schemes.md +34 -0
  152. package/skills/platform-encryption-configure/references/key-models.md +34 -0
  153. package/skills/platform-encryption-configure/references/tenant-secret-lifecycle.md +23 -0
  154. package/skills/platform-encryption-configure/scripts/validate-encryption-metadata.sh +54 -0
  155. package/skills/platform-flexipage-generate/SKILL.md +281 -346
  156. package/skills/platform-flexipage-generate/references/cli_commands.md +39 -0
  157. package/skills/platform-flexipage-generate/references/flexipage_fieldSection.md +162 -0
  158. package/skills/platform-flexipage-generate/references/flexipage_richText.md +84 -0
  159. package/skills/platform-flexipage-generate/references/identifiers_and_regions.md +167 -0
  160. package/skills/platform-flexipage-generate/references/mcp_action_examples.md +104 -0
  161. package/skills/platform-flexipage-generate/references/record_flexipage_dynamicHighlights.md +119 -0
  162. package/skills/platform-flexipage-generate/references/xml_rules.md +335 -0
  163. package/skills/platform-flexipage-generate/scripts/resolve-component-instructions.sh +42 -0
  164. package/skills/platform-flexipage-generate/scripts/scan-lwc-components.sh +113 -0
  165. package/skills/platform-metadata-api-context-get/SKILL.md +13 -10
  166. package/skills/platform-metadata-deploy/README.md +2 -2
  167. package/skills/platform-metadata-deploy/references/agent-deployment-guide.md +2 -2
  168. package/skills/platform-metadata-deploy/references/deployment-workflows.md +16 -16
  169. package/skills/platform-metadata-deploy/references/orchestration.md +3 -3
  170. package/skills/platform-metadata-deploy/references/trigger-deployment-safety.md +2 -2
  171. package/skills/platform-models-api-configure/SKILL.md +140 -0
  172. package/skills/platform-models-api-configure/scripts/get-orgjwt.sh +48 -0
  173. package/skills/platform-policy-rule-generate/SKILL.md +260 -0
  174. package/skills/platform-policy-rule-generate/references/deploy-errors.md +54 -0
  175. package/skills/platform-policy-rule-generate/references/fixtures-index.md +29 -0
  176. package/skills/platform-policy-rule-generate/references/policy-schema-full.md +250 -0
  177. package/skills/platform-policy-rule-generate/references/templates-access.md +132 -0
  178. package/skills/platform-policy-rule-generate/references/templates-advanced.md +58 -0
  179. package/skills/platform-policy-rule-generate/references/templates-record.md +75 -0
  180. package/skills/platform-policy-rule-generate/references/templates-transform.md +70 -0
  181. package/skills/platform-policy-rule-generate/references/templates.md +10 -0
  182. package/skills/platform-policy-rule-generate/references/ui-compatibility.md +142 -0
  183. package/skills/platform-soql-query/README.md +1 -1
  184. package/skills/platform-soql-query/SKILL.md +1 -1
  185. package/skills/platform-soql-query/references/anti-patterns.md +1 -1
  186. package/skills/platform-soql-query/references/field-coverage-rules.md +1 -1
  187. package/skills/platform-soql-query/references/query-optimization.md +1 -1
  188. package/skills/platform-soql-query/scripts/post-tool-validate.py +3 -3
  189. package/skills/data360-activate/CREDITS.md +0 -5
  190. package/skills/data360-connect/CREDITS.md +0 -5
  191. package/skills/data360-harmonize/CREDITS.md +0 -3
  192. package/skills/data360-orchestrate/CREDITS.md +0 -15
  193. package/skills/data360-orchestrate/UPSTREAM.md +0 -45
  194. package/skills/data360-prepare/CREDITS.md +0 -7
  195. package/skills/data360-query/CREDITS.md +0 -7
  196. package/skills/data360-segment/CREDITS.md +0 -3
  197. package/skills/experience-lwc-generate/CREDITS.md +0 -5
  198. package/skills/external-diagram-mermaid-generate/CREDITS.md +0 -46
  199. package/skills/external-diagram-visual-generate/CREDITS.md +0 -80
  200. package/skills/external-diagram-visual-generate/README.md +0 -83
  201. package/skills/external-diagram-visual-generate/SKILL.md +0 -207
  202. package/skills/external-diagram-visual-generate/assets/architecture/integration-flow.md +0 -55
  203. package/skills/external-diagram-visual-generate/assets/erd/core-objects.md +0 -131
  204. package/skills/external-diagram-visual-generate/assets/erd/custom-objects.md +0 -60
  205. package/skills/external-diagram-visual-generate/assets/lwc/dashboard-card.md +0 -45
  206. package/skills/external-diagram-visual-generate/assets/lwc/data-table.md +0 -57
  207. package/skills/external-diagram-visual-generate/assets/lwc/record-form.md +0 -60
  208. package/skills/external-diagram-visual-generate/assets/review/apex-review.md +0 -57
  209. package/skills/external-diagram-visual-generate/assets/review/lwc-review.md +0 -48
  210. package/skills/external-diagram-visual-generate/references/architect-aesthetic-guide.md +0 -257
  211. package/skills/external-diagram-visual-generate/references/examples-index.md +0 -35
  212. package/skills/external-diagram-visual-generate/references/gemini-cli-setup.md +0 -65
  213. package/skills/external-diagram-visual-generate/references/interview-questions.md +0 -529
  214. package/skills/external-diagram-visual-generate/references/iteration-workflow.md +0 -173
  215. package/skills/external-diagram-visual-generate/scripts/check-prerequisites.sh +0 -101
  216. package/skills/external-diagram-visual-generate/scripts/generate_image.py +0 -243
  217. package/skills/integration-connectivity-connected-app-configure/CREDITS.md +0 -3
  218. package/skills/integration-connectivity-generate/CREDITS.md +0 -5
  219. package/skills/omnistudio-callable-apex-generate/CREDITS.md +0 -9
  220. package/skills/omnistudio-datamapper-generate/CREDITS.md +0 -5
  221. package/skills/omnistudio-datapacks-deploy/CREDITS.md +0 -5
  222. package/skills/omnistudio-dependencies-analyze/CREDITS.md +0 -5
  223. package/skills/omnistudio-epc-catalog-generate/CREDITS.md +0 -14
  224. package/skills/omnistudio-flexcard-generate/CREDITS.md +0 -5
  225. package/skills/omnistudio-integration-procedure-generate/CREDITS.md +0 -5
  226. package/skills/omnistudio-omniscript-generate/CREDITS.md +0 -5
  227. package/skills/platform-apex-generate/CREDITS.md +0 -5
  228. package/skills/platform-apex-logs-debug/CREDITS.md +0 -22
  229. package/skills/platform-apex-test-generate/CREDITS.md +0 -5
  230. package/skills/platform-apex-test-run/CREDITS.md +0 -22
  231. package/skills/platform-data-manage/CREDITS.md +0 -5
  232. package/skills/platform-metadata-deploy/CREDITS.md +0 -25
  233. package/skills/platform-soql-query/CREDITS.md +0 -21
  234. /package/skills/omnistudio-callable-apex-generate/examples/Test_VlocityOpenInterfaceConversion/{MyCustomVlocityOpenInterface2.cls → MyCustomClass.cls} +0 -0
@@ -0,0 +1,54 @@
1
+ # Deploy Error Reference
2
+
3
+ When `sf project deploy start` fails, it prints a per-component status table. Below are the most common error families for `PolicyRuleDefinition` / `PolicyRuleDefinitionSet` metadata.
4
+
5
+ For verbose output when scripting:
6
+ ```bash
7
+ sf project deploy start --target-org <alias> --source-dir … --json --verbose \
8
+ | jq '.result.details.componentFailures'
9
+ ```
10
+
11
+ ---
12
+
13
+ ## Error Table
14
+
15
+ | Error fragment | Likely cause | Fix |
16
+ |---|---|---|
17
+ | `Not available for deploy for this organization` | Org has `EnforceOMatic` perm (entities visible) but lacks `PolicyRuleMDAPI` org perm | Internal license/feature provisioning — surface to the operator. Both `EnforceOMatic` AND `PolicyRuleMDAPI` are required (see §11.1 of policy.md). |
18
+ | `Cannot find … PolicyRuleDefinition` (older orgs) | Org missing `EnforceOMatic` entirely, or API version too low | Confirm both `EnforceOMatic` and `PolicyRuleMDAPI` perms; ensure `<version>` ≥ 64.0 in package.xml |
19
+ | `INVALIDFORCATEGORY` / `Resource scope … not valid for category …` | Scope × category mismatch (e.g., ACCESS/GOVERNANCE + RECORD scope, or TRANSFORM + ANY scope) | Match scope to category per the §4 matrix in SKILL.md. For OLS/FLS on tagged objects: use `ANY`/`FIELD` scope + tag/classification condition — **not** `<resourceDomain>`. |
20
+ | `Identified record category should use record field …` | Attempted to author an `IDENTIFIED_RECORD` policy with a non-`RECORDFIELD` resource path | Do not author `IDENTIFIED_RECORD` via MDAPI — use a runtime `RuleProvider` instead. |
21
+ | `Invalid resource domain - <name>` | `<resourceDomain>` references an entity that doesn't exist in the target org | Pre-deploy the DMO/entity, or remove the rule until the target is available. Namespaced DMOs (e.g. `ssot__Account__dlm`) need the namespace prefix in the XML. |
22
+ | `An unexpected error occurred. Please include this ErrorId… (-116061062)` (opaque gack on RLS deploy) | RLS rule references a `<valueDomain>` DMO field that exists in metadata but is **not mapped** in the target org's data streams. Server-side NPE instead of a clean validation error. | Verify each `<valueDomain>` field is mapped in Setup → Data Cloud → Data Explorer. Build the rule in the UI first — the UI surfaces field-mapping issues with usable errors where MDAPI doesn't. |
23
+ | `Metadata API received improper input. … Load of metadata from db failed for metadata of type:PolicyRuleDefinition and file name:<name>` (on **retrieve**) | UI-saved RLS rules can fail to round-trip back through MDAPI retrieve in some org states | No clean fix. Use the UI as source of truth for that rule, or hand-author from a known-deployable RLS template. |
24
+ | `Use the principal … with external record category.` | `EXTERNAL_RECORD` rule used a non-`IS_AUTHENTICATED`/`IS_INTERNAL` `principalPath` | Switch principal path or change category |
25
+ | `Unsupported … contextPath` | Used a context path outside `RuleContextPathType.SESSION_DATASPACE` | Not authorable via MDAPI XML — use a runtime `RuleProvider` |
26
+
27
+ ---
28
+
29
+ ## OrgPerm Gating
30
+
31
+ Two org permissions are **both** required for MDAPI authoring:
32
+
33
+ | Permission | Gate | Effect if missing |
34
+ |---|---|---|
35
+ | `EnforceOMatic` | `@WsdlGuard` master switch | Entities not visible in UI/Tooling API at all |
36
+ | `PolicyRuleMDAPI` | `orgCanUsePolicyRuleMDAPI` WSDL layer | Deploy fails with `Not available for deploy for this organization` |
37
+
38
+ `EnforcOMaticMDAPI` is a separate **packaging** gate (`isMdAPIAllowedInternal`) — only required for packaging/change sets, not for DX CLI deploys. After PR #98647 (merged 2026-06-08) the predicate is `DBContext.get().isDoingPackageInstall()`, so DX CLI deploys work with just the two perms above.
39
+
40
+ ---
41
+
42
+ ## Dry-Run First
43
+
44
+ Always validate before deploying to a long-lived org:
45
+
46
+ ```bash
47
+ sf project deploy start \
48
+ --target-org <alias> \
49
+ --source-dir force-app/main/default \
50
+ --dry-run \
51
+ --wait 10
52
+ ```
53
+
54
+ A `--dry-run` failure runs the full server-side validation hooks (including the `IDENTIFIED_RECORD` constraint at `PolicyRuleDefinitionCondObject.java:332-339`) without persisting. This catches all of the errors in the table above before they affect a real org.
@@ -0,0 +1,29 @@
1
+ # Fixtures Index
2
+
3
+ > **For human maintainers only.** This index requires a checkout of `enforce-o-matic-impl`. The agent should rely on [`templates.md`](templates.md), which reproduces the relevant XML shapes inline.
4
+
5
+ Quick lookup from "what I need" to "fixture that already does it".
6
+
7
+ All fixtures are under `enforce-o-matic-impl/test/func/filemetadata/<name>/`.
8
+
9
+ | If you need… | Fixture |
10
+ |---|---|
11
+ | Bare permit rule, no conditions | `baseSteelthread`, `steelthreadPayload` |
12
+ | Custom conjunction `(AND 1 2)` over UNLESS | `conjunctionExpressionSteelthread` |
13
+ | Tag check | `conditionTagValidSteelthread`, `conditionCustomTagValidDataMaskingSteelthread` |
14
+ | Classification check | `conditionClassificationValidClauseSteelthread`, `conditionClassificationValidDataMaskingSteelthread` |
15
+ | Dataspace / session dataspace | `conditionDataspaceValidSteelthread`, `conditionSessionDataspaceValidSteelthread` |
16
+ | Custom permission gate | `conditionAssignedPermPathValidSteelthread` |
17
+ | Plain RLS (record field = user ID) | `conditionRLSValidSteelthread` (1st condition), `conditionStandardIdRLSValidSteelthread` |
18
+ | RLS via PROJECTION join | `conditionRLSValidSteelthread` (2nd condition) |
19
+ | Scalar / plural SOQL principal (out-of-contract) | `conditionScalarAttributeValidSteelThread`, `conditionPluralAttributeValidSteelthread` |
20
+ | Hierarchy traversal | `conditionWithHierarchy` |
21
+ | Field masking transform | `conditionClassificationValidDataMaskingSteelthread`, `conditionInvalidDataMaskingSteelthread` (negative) |
22
+ | Field-scoped resource domain | `resourceDomainWithField` |
23
+ | Core standard object policy (Case) | `coreObjectCaseWithPolicy` (persistence-layer only; not a working IDENTIFIED_RECORD shape — see §8.4 of policy.md) |
24
+ | Extended steelthread (set referenced from sibling package) | `extendedSteelthread` |
25
+ | Negative: missing operator | `conditionMissingOperatorSteelthread` |
26
+ | Negative: missing path | `conditionMissingPathSteelthread` |
27
+ | Negative: invalid context path | `conditionInvalidContextPathSteelthread` |
28
+ | Negative: invalid data masking shape | `conditionInvalidDataMaskingSteelthread` |
29
+ | Negative: invalid payload | `invalidPayload` |
@@ -0,0 +1,250 @@
1
+ # Policy Schema — Full Element Reference
2
+
3
+ Source: `enforce-o-matic-impl/java/src/enforce/o/matic/metadata/`
4
+
5
+ ---
6
+
7
+ ## Path Enums
8
+
9
+ > **Surface principle.** The MDAPI surface is the narrower `*Type` enum in `enforce-o-matic-impl/java/src/enforce/o/matic/metadata/`. The wider runtime enums (`RulePrincipalPath`, `RuleResourcePath`, `RuleContextPath` in `enforce-o-matic-api/.../enums/`) drive Cedar evaluation and DAO behavior; values absent from the `*Type` enums are **not authorable via MDAPI**.
10
+
11
+ ### `<principalPath>` / `<valuePrincipalPath>` — `RulePrincipalPathType` (6 values)
12
+
13
+ | Value | Meaning |
14
+ |-------|---------|
15
+ | `IS_AUTHENTICATED_USER_PATH` | Boolean "is principal an authenticated user" |
16
+ | `ASSIGNED_PERMISSIONS_PATH` | Principal's assigned permissions (pair with `valueReferenceType=CUSTOM_PERMISSION`) |
17
+ | `USER_ID` | Principal user ID |
18
+ | `ORGANIZATION_ID` | Principal org ID |
19
+ | `USER_ROLE_ID` | Principal role ID |
20
+ | `RBAC_TAGS` | Principal RBAC tags |
21
+
22
+ Outside contract (not in `RulePrincipalPathType`): `IS_INTERNAL`, `CONTACT_ID`, `SCALAR_ATTRIBUTE`, `PLURAL_ATTRIBUTE`, `PLACEHOLDER`. Use a runtime RuleProvider for these.
23
+
24
+ ### `<resourcePath>` / `<valueResourcePath>` — `RuleResourcePathType` (16 values)
25
+
26
+ | Value | Meaning |
27
+ |-------|---------|
28
+ | `NAMESPACE` | Resource namespace |
29
+ | `ENTITY` | Entity (object) reference |
30
+ | `FIELD` | Field reference |
31
+ | `ENTITYTYPE` | Entity type — pair with `IS` operator and `{"t":"Text","v":"FIELD"}` literal |
32
+ | `ENTITYKIND` | Entity kind bits |
33
+ | `FIELDKIND` | Field kind bits |
34
+ | `DATASPACE` | Resource dataspace |
35
+ | `TAG` | Custom or standard tag |
36
+ | `OBJECT_TAG` | Object-level tag |
37
+ | `CLASSIFICATION` | Custom or standard classification |
38
+ | `IMPLICITTAG` | Implicit tag |
39
+ | `RECORDFIELD` | Field of the record being evaluated (RLS) — pair with `<valueDomain>Schema:field</valueDomain>` |
40
+ | `OBJECT_CLASSIFICATION` | Object-level classification |
41
+ | `EXPRESSION` | Compound expression — pair with `<resourceExpression>` PROJECTION |
42
+ | `OBJECT_DATASPACE` | Object-level dataspace |
43
+ | `RECORDFIELDTYPE` | Type of a record field |
44
+
45
+ ### `<contextPath>` / `<valueContextPath>` — `RuleContextPathType` (1 value)
46
+
47
+ | Value | Cedar attribute | Use case |
48
+ |-------|-----------------|----------|
49
+ | `SESSION_DATASPACE` | `context.sessionDataspace` | Session-scoped dataspace check |
50
+
51
+ Outside contract: `SESSION_CONSUMER_ID`, `CONTEXT_AGENT_ID`, `CONTEXT_AGENT_VERSION_ID` (IDENTIFIED_RECORD / agentic — runtime RuleProvider only).
52
+
53
+ > Some steelthread fixtures use `SCALAR_ATTRIBUTE` / `PLURAL_ATTRIBUTE` in `<valuePrincipalPath>` (`conditionScalarAttributeValidSteelThread`). They deploy in the ftest harness because the entity object is type-tolerant, but these values are outside `RulePrincipalPathType` — not sanctioned for new work.
54
+
55
+ ---
56
+
57
+ ## `<operator>` — `RuleDefinitionOperatorType`
58
+
59
+ | Operator | Use with |
60
+ |----------|----------|
61
+ | `EQUALS` / `NOT_EQUALS` | Scalar equality |
62
+ | `GREATER_THAN`, `LESS_THAN`, `GREATER_THAN_OR_EQUAL`, `LESS_THAN_OR_EQUALS` | Numeric / date |
63
+ | `IN` | Scalar IN set |
64
+ | `LIKE` | String pattern |
65
+ | `CONTAINS_ANY` | Set has at least one of |
66
+ | `CONTAINS_ALL` | Set has all of |
67
+ | `CONTAINS_NONE` | Set has none of |
68
+ | `IS` | Type / kind check (pair with `ENTITYTYPE` + `{"t":"Text","v":"FIELD"}` literal) |
69
+ | `EXISTS` | RLS join exists (pair with `resourcePath=EXPRESSION` + PROJECTION) |
70
+ | `HIERARCHICALLY_ABOVE` / `HIERARCHICALLY_BELOW` | Hierarchy traversal — pair with `valueReferenceType=HIERARCHY` |
71
+
72
+ ---
73
+
74
+ ## `<conditions>` — Full Schema (`PolicyRuleDefinitionCondition.java`)
75
+
76
+ | Element | Notes |
77
+ |---------|-------|
78
+ | `<clause>` | `WHEN` or `UNLESS` — match the wrapper |
79
+ | `<operator>` | Always required |
80
+ | `<resourcePath>` | What about the resource to inspect |
81
+ | `<principalPath>` | What about the principal to inspect |
82
+ | `<contextPath>` | Context attribute (SESSION_DATASPACE only) |
83
+ | `<valueDomain>` | `Schema:field` — for RECORDFIELD comparisons |
84
+ | `<resourceAlias>` | Used in PROJECTION join expressions |
85
+ | `<valueBit>` | Entity/field-kind bits |
86
+ | `<valuePrincipalPath>` | Path the value comes from |
87
+ | `<valueResourcePath>` | Path the value comes from |
88
+ | `<valueContextPath>` | Path the value comes from |
89
+ | `<policyRuleValueSet>` | Literal or named-reference values (see below) |
90
+ | `<resourceExpression>` | `PolicyJsonExpression` type=PROJECTION (RLS join) |
91
+ | `<principalExpression>` | `PolicyJsonExpression` type=SOQLTARGETLISTEXPR (SOQL principal) |
92
+ | `<whereClauseConjunction>` | Sub-expression for nested conditions |
93
+ | `<policyRuleDefinitionCondition>` | Nested children — used with `whereClauseConjunction` |
94
+
95
+ ---
96
+
97
+ ## `<policyRuleValueSet>` — `PolicyRuleValueSet.java`
98
+
99
+ Three fields (all optional at schema level, but a non-empty value set needs at least one):
100
+
101
+ ### Literal values — `<valueString>`
102
+
103
+ For typed literals, embed JSON (escape `"` to `&quot;`):
104
+ ```xml
105
+ <valueString>{&quot;t&quot;:&quot;Text&quot;,&quot;v&quot;:&quot;FIELD&quot;}</valueString>
106
+ <valueString>{&quot;t&quot;:&quot;Boolean&quot;,&quot;v&quot;:true}</valueString>
107
+ <valueString>{&quot;t&quot;:&quot;Number&quot;,&quot;v&quot;:42}</valueString>
108
+ ```
109
+
110
+ For plain string equality:
111
+ ```xml
112
+ <valueString>Toxico</valueString>
113
+ ```
114
+
115
+ ### Named references — `<valueReference>` + `<valueReferenceType>`
116
+
117
+ | `valueReferenceType` | Refers to | Typical path pairing |
118
+ |----------------------|-----------|----------------------|
119
+ | `CUSTOM_TAG` | Custom tag by devName | `resourcePath=TAG` |
120
+ | `STANDARD_TAG` | Standard tag — **fully qualified** (e.g. `DataGovernanceTags.ExternalData.Visibility.Public`) | `resourcePath=TAG` |
121
+ | `CUSTOM_CLASSIFICATION` | Custom classification | `resourcePath=CLASSIFICATION` |
122
+ | `STANDARD_CLASSIFICATION` | Standard classification — **fully qualified** (e.g. `DataGovernanceClassifications.DataCategorization.FieldUsage.Active`) | `resourcePath=CLASSIFICATION` |
123
+ | `HIERARCHY` | Hierarchy definition | `operator=HIERARCHICALLY_BELOW/ABOVE`, `resourcePath=RECORDFIELD` |
124
+ | `CUSTOM_PERMISSION` | Custom permission | `principalPath=ASSIGNED_PERMISSIONS_PATH` |
125
+ | `DATASPACE` | Dataspace | `resourcePath=DATASPACE` or `contextPath=SESSION_DATASPACE` |
126
+
127
+ > **Tag/classification dev names are NOT free-form.** The deploy-time validator checks `<valueReference>` against the org's taxonomy. To find the exact string: `sf project retrieve start --target-org <alias> --metadata "PolicyRuleDefinition:<existing-rule-name>"` and copy `<valueReference>` verbatim.
128
+
129
+ Multiple `<policyRuleValueSet>` siblings inside one condition are OR-combined.
130
+
131
+ ---
132
+
133
+ ## JSON Expressions — `PolicyJsonExpression.java` (min API 66.0)
134
+
135
+ `<type>` must match the location:
136
+
137
+ | Location | Required `type` |
138
+ |----------|-----------------|
139
+ | Top-level `<resourceExpression>` (TRANSFORM rule arg list) | `ARGLIST` |
140
+ | `<conditions>` `<resourceExpression>` (RLS join) | `PROJECTION` |
141
+ | `<conditions>` `<principalExpression>` (SOQL principal) | `SOQLTARGETLISTEXPR` |
142
+
143
+ ### ARGLIST — Transform argument list
144
+
145
+ ```xml
146
+ <resourceExpression>
147
+ <type>ARGLIST</type>
148
+ <version>1</version>
149
+ <transformExpression>
150
+ <argument>
151
+ <type>NUMBER</type>
152
+ <value>4</value>
153
+ </argument>
154
+ </transformExpression>
155
+ </resourceExpression>
156
+ ```
157
+
158
+ `TransformExpressionArgumentType` = `STRING` or `NUMBER`. Use when `<resourceTransform>` takes parameters (e.g. `LAST_N_CHARS_RESOURCE_TRANSFORM` needs N).
159
+
160
+ ### PROJECTION — RLS join
161
+
162
+ Used inside `<conditions>` with `resourcePath=EXPRESSION` and `operator=EXISTS`:
163
+
164
+ ```xml
165
+ <resourceExpression>
166
+ <type>PROJECTION</type>
167
+ <version>1</version>
168
+ <projection>
169
+ <join>
170
+ <schema>testDMO__dlm</schema>
171
+ <alias>test 1</alias>
172
+ <predicate>
173
+ <comparator>EQUALS</comparator>
174
+ <attribute>testDMO__dlm:name__c</attribute>
175
+ <on>
176
+ <resourceAlias>resource</resourceAlias>
177
+ <schema>testDMO__dlm</schema>
178
+ <field>age__c</field>
179
+ </on>
180
+ </predicate>
181
+ </join>
182
+ </projection>
183
+ </resourceExpression>
184
+ ```
185
+
186
+ ### SOQLTARGETLISTEXPR — Principal SOQL target
187
+
188
+ Scalar:
189
+ ```xml
190
+ <principalExpression>
191
+ <type>SOQLTARGETLISTEXPR</type>
192
+ <version>1</version>
193
+ <soqlTarget>
194
+ <select>age__c</select>
195
+ </soqlTarget>
196
+ </principalExpression>
197
+ ```
198
+
199
+ Plural (use a set operator: `CONTAINS_ANY` / `CONTAINS_NONE` / `CONTAINS_ALL`):
200
+ ```xml
201
+ <principalExpression>
202
+ <type>SOQLTARGETLISTEXPR</type>
203
+ <version>1</version>
204
+ <soqlTarget>
205
+ <plural>true</plural>
206
+ <relationship>pluralAttributes__r</relationship>
207
+ <select>name__c</select>
208
+ </soqlTarget>
209
+ </principalExpression>
210
+ ```
211
+
212
+ > `SCALAR_ATTRIBUTE` / `PLURAL_ATTRIBUTE` principal expressions are outside MDAPI contract. Fixture-only.
213
+
214
+ ---
215
+
216
+ ## `<resourceTransform>` Enum (TRANSFORM rules only)
217
+
218
+ | Value | Effect |
219
+ |-------|--------|
220
+ | `NULL_RESOURCE_TRANSFORM` | Replace with NULL |
221
+ | `EMPTY_STRING_RESOURCE_TRANSFORM` | Replace with `""` |
222
+ | `LAST_N_CHARS_RESOURCE_TRANSFORM` | Keep last N chars (N via ARGLIST) |
223
+ | `FIRST_N_CHARS_RESOURCE_TRANSFORM` | Keep first N chars (N via ARGLIST) |
224
+ | `ALL_BUT_LAST_N_CHARS_RESOURCE_TRANSFORM` | Mask last N |
225
+ | `ALL_BUT_FIRST_N_CHARS_RESOURCE_TRANSFORM` | Mask first N |
226
+ | `CLOSEST_ORDER_OF_MAGNITUDE_RESOURCE_TRANSFORM` | Round to nearest power of 10 |
227
+ | `TRUNCATE_DATE_RESOURCE_TRANSFORM` | Truncate date precision |
228
+ | `ROUND_RESOURCE_TRANSFORM` | Round number |
229
+ | `REPLACE_ALL_CHARS_RESOURCE_TRANSFORM` | Replace each char |
230
+
231
+ Pure transforms (NULL, EMPTY_STRING) need no `<resourceExpression>`. Parameterized transforms (FIRST_N, LAST_N, ROUND, REPLACE_ALL_CHARS, TRUNCATE_DATE) take args via ARGLIST.
232
+
233
+ ---
234
+
235
+ ## File Cross-References
236
+
237
+ | Concern | File |
238
+ |---------|------|
239
+ | Rule wrapper | `enforce-o-matic-impl/java/src/enforce/o/matic/metadata/PolicyRuleDefinition.java` |
240
+ | Set wrapper | `…/PolicyRuleDefinitionSet.java` |
241
+ | Conditions | `…/PolicyRuleDefinitionClauseConjunction.java`, `…/PolicyRuleDefinitionCondition.java` |
242
+ | Value set | `…/PolicyRuleValueSet.java` + `…/PolicyRuleValueSetReferenceType.java` |
243
+ | JSON expression | `…/PolicyJsonExpression.java` + `…/PolicyJsonExpressionType.java` |
244
+ | ARGLIST | `…/TransformExpression.java` + `…/TransformExpressionArgument.java` |
245
+ | PROJECTION | `…/ProjectionExpression.java` + `…/ProjectionJoin.java` + `…/PolicyJoinPredicate.java` |
246
+ | SOQLTARGETLISTEXPR | `…/PrincipalExpression.java` |
247
+ | Resource domain | `…/PolicyRuleResourceDomain.java` |
248
+ | Enums | `Category.java`, `Effect.java`, `RuleConsumer.java`, `PrincipalAuthenticationLevel.java`, `RulePrincipalScopeType.java`, `RuleResourceScopeType.java`, `RulePrincipalPathType.java`, `RuleResourcePathType.java`, `RuleContextPathType.java`, `RuleDefinitionClauseType.java`, `RuleDefinitionOperatorType.java`, `ResourceTransform.java` |
249
+ | IDENTIFIED_RECORD condition validator | `PolicyRuleDefinitionCondObject.java:332-339` |
250
+ | Agentic RuleProvider canonical builder | `AgenticPolicyRuleProviderService.java:130-260` |
@@ -0,0 +1,132 @@
1
+ # ACCESS / GOVERNANCE Templates
2
+
3
+ Each template is a verified shape from a passing test fixture. Copy, then change names/values.
4
+
5
+ ---
6
+
7
+ ## ACCESS — Simple Permit (no conditions)
8
+
9
+ Source: `baseSteelthread`
10
+
11
+ ```xml
12
+ <?xml version="1.0" encoding="UTF-8"?>
13
+ <PolicyRuleDefinition xmlns="http://soap.sforce.com/2006/04/metadata">
14
+ <action>Read</action>
15
+ <category>ACCESS_POLICY_RULE_DEFINITION</category>
16
+ <effect>Permit</effect>
17
+ <label>Rule0</label>
18
+ <policyRuleDefinitionSetName>Set1</policyRuleDefinitionSetName>
19
+ <principalAuthenticationLevel>INTERNAL</principalAuthenticationLevel>
20
+ <principalScopeType>ANY</principalScopeType>
21
+ <resourceScopeType>ANY</resourceScopeType>
22
+ <ruleConsumer>DATACLOUD</ruleConsumer>
23
+ <transformPrecedence>0</transformPrecedence>
24
+ </PolicyRuleDefinition>
25
+ ```
26
+
27
+ ---
28
+
29
+ ## ACCESS / GOVERNANCE — "Objects AND all their fields" via TupleRead (UI-compatible)
30
+
31
+ Source: see §8.2.1 of policy.md
32
+
33
+ Three required pieces:
34
+ 1. `<action>TupleRead</action>` — cascades object-level condition to fields
35
+ 2. **OR-of-ENTITYTYPE clause** — required for UI editability (without it the builder crashes)
36
+ 3. The actual semantic gate (tag / classification / permission)
37
+
38
+ ```xml
39
+ <?xml version="1.0" encoding="UTF-8"?>
40
+ <PolicyRuleDefinition xmlns="http://soap.sforce.com/2006/04/metadata">
41
+ <action>TupleRead</action>
42
+ <category>GOVERNANCE_POLICY_RULE_DEFINITION</category>
43
+ <effect>Permit</effect>
44
+ <label>GrantPublicAccess</label>
45
+ <policyRuleDefinitionSetName>PublicAccessSet</policyRuleDefinitionSetName>
46
+ <principalAuthenticationLevel>INTERNAL</principalAuthenticationLevel>
47
+ <principalScopeType>ANY</principalScopeType>
48
+ <resourceScopeType>ANY</resourceScopeType>
49
+ <ruleConsumer>DATACLOUD</ruleConsumer>
50
+ <transformPrecedence>0</transformPrecedence>
51
+ <whenPolicyRuleDefinitionClauseConjunction>
52
+ <!-- (1) and (2): OR-of-ENTITYTYPE clause — required for UI rendering -->
53
+ <conditions>
54
+ <clause>WHEN</clause>
55
+ <operator>IS</operator>
56
+ <policyRuleValueSet>
57
+ <valueString>{&quot;t&quot;:&quot;Text&quot;,&quot;v&quot;:&quot;OBJECT&quot;}</valueString>
58
+ </policyRuleValueSet>
59
+ <resourcePath>ENTITYTYPE</resourcePath>
60
+ </conditions>
61
+ <conditions>
62
+ <clause>WHEN</clause>
63
+ <operator>IS</operator>
64
+ <policyRuleValueSet>
65
+ <valueString>{&quot;t&quot;:&quot;Text&quot;,&quot;v&quot;:&quot;FIELD&quot;}</valueString>
66
+ </policyRuleValueSet>
67
+ <resourcePath>ENTITYTYPE</resourcePath>
68
+ </conditions>
69
+ <!-- (3): actual semantic gate -->
70
+ <conditions>
71
+ <clause>WHEN</clause>
72
+ <operator>CONTAINS_ANY</operator>
73
+ <resourcePath>TAG</resourcePath>
74
+ <policyRuleValueSet>
75
+ <valueReference>DataGovernanceTags.ExternalData.Visibility.Public</valueReference>
76
+ <valueReferenceType>STANDARD_TAG</valueReferenceType>
77
+ </policyRuleValueSet>
78
+ </conditions>
79
+ <!-- MUST use (AND N) not bare N for every top-level param — bare index crashes UI -->
80
+ <conjunctionExpression>(AND (OR 1 2) (AND 3))</conjunctionExpression>
81
+ </whenPolicyRuleDefinitionClauseConjunction>
82
+ </PolicyRuleDefinition>
83
+ ```
84
+
85
+ For **deny semantics**: `<effect>Forbid</effect>`. To add "deny unless permission Y", insert a 4th condition with `ASSIGNED_PERMISSIONS_PATH CONTAINS_NONE Y` and use `(AND (OR 1 2) (AND 3) (AND 4))`.
86
+
87
+ ---
88
+
89
+ ## ACCESS — Gated by Tag / Classification / Permission
90
+
91
+ Source: `conditionTagValidSteelthread`, `conditionClassificationValidClauseSteelthread`, `conditionAssignedPermPathValidSteelthread`
92
+
93
+ ```xml
94
+ <?xml version="1.0" encoding="UTF-8"?>
95
+ <PolicyRuleDefinition xmlns="http://soap.sforce.com/2006/04/metadata">
96
+ <action>Read</action>
97
+ <category>ACCESS_POLICY_RULE_DEFINITION</category>
98
+ <effect>Permit</effect>
99
+ <label>Rule0</label>
100
+ <policyRuleDefinitionSetName>TagSet1</policyRuleDefinitionSetName>
101
+ <principalAuthenticationLevel>INTERNAL</principalAuthenticationLevel>
102
+ <principalScopeType>ANY</principalScopeType>
103
+ <resourceScopeType>ANY</resourceScopeType>
104
+ <ruleConsumer>DATACLOUD</ruleConsumer>
105
+ <transformPrecedence>0</transformPrecedence>
106
+ <whenPolicyRuleDefinitionClauseConjunction>
107
+ <conditions>
108
+ <clause>WHEN</clause>
109
+ <operator>CONTAINS_ANY</operator>
110
+ <resourcePath>TAG</resourcePath>
111
+ <policyRuleValueSet>
112
+ <valueReference>CustomTagRef</valueReference>
113
+ <valueReferenceType>CUSTOM_TAG</valueReferenceType>
114
+ </policyRuleValueSet>
115
+ </conditions>
116
+ <conjunctionExpression>1</conjunctionExpression>
117
+ </whenPolicyRuleDefinitionClauseConjunction>
118
+ </PolicyRuleDefinition>
119
+ ```
120
+
121
+ Swap the inner condition for permission gating:
122
+ ```xml
123
+ <conditions>
124
+ <clause>WHEN</clause>
125
+ <operator>CONTAINS_ANY</operator>
126
+ <principalPath>ASSIGNED_PERMISSIONS_PATH</principalPath>
127
+ <policyRuleValueSet>
128
+ <valueReference>testCustomPermission1</valueReference>
129
+ <valueReferenceType>CUSTOM_PERMISSION</valueReferenceType>
130
+ </policyRuleValueSet>
131
+ </conditions>
132
+ ```
@@ -0,0 +1,58 @@
1
+ # Advanced Templates — Multi-Condition, Hierarchy, Unauthorable
2
+
3
+ Each template is a verified shape from a passing test fixture. Copy, then change names/values.
4
+
5
+ ---
6
+
7
+ ## Multi-Condition with Custom Conjunction (AND/OR mix)
8
+
9
+ Source: `conjunctionExpressionSteelthread`
10
+
11
+ ```xml
12
+ <unlessPolicyRuleDefinitionClauseConjunction>
13
+ <conditions>
14
+ <clause>UNLESS</clause>
15
+ <operator>CONTAINS_ANY</operator>
16
+ <resourcePath>TAG</resourcePath>
17
+ </conditions>
18
+ <conditions>
19
+ <clause>UNLESS</clause>
20
+ <operator>CONTAINS_NONE</operator>
21
+ <resourcePath>TAG</resourcePath>
22
+ </conditions>
23
+ <conjunctionExpression>(AND 1 2)</conjunctionExpression>
24
+ </unlessPolicyRuleDefinitionClauseConjunction>
25
+ ```
26
+
27
+ > Note: `<unlessPolicyRuleDefinitionClauseConjunction>` blocks are **not UI-editable** — silently dropped on first save. Prefer WHEN + negated operator for UI-compatible policies.
28
+
29
+ ---
30
+
31
+ ## Hierarchy Traversal
32
+
33
+ Source: `conditionWithHierarchy`
34
+
35
+ ```xml
36
+ <conditions>
37
+ <clause>WHEN</clause>
38
+ <operator>HIERARCHICALLY_BELOW</operator>
39
+ <resourcePath>RECORDFIELD</resourcePath>
40
+ <valueDomain>testDMO__dlm:name__c</valueDomain>
41
+ <policyRuleValueSet>
42
+ <valueReference>testHierarchyRLS</valueReference>
43
+ <valueReferenceType>HIERARCHY</valueReferenceType>
44
+ </policyRuleValueSet>
45
+ </conditions>
46
+ ```
47
+
48
+ > Not UI-editable (`HIERARCHICALLY_BELOW` and `valueReferenceType=HIERARCHY` are not in the UI dropdowns).
49
+
50
+ ---
51
+
52
+ ## IDENTIFIED_RECORD — Not Authorable via MDAPI
53
+
54
+ `IDENTIFIED_RECORD` policies cannot be authored as XML. The required `RuleContextPath.SESSION_CONSUMER_ID` is not in `RuleContextPathType`.
55
+
56
+ To author one: write a runtime `RuleProvider` using `AgenticPolicyRuleProviderService.java:130-260` as the canonical builder.
57
+
58
+ **Do not** synthesize a placeholder XML using `<contextPath>SESSION_CONSUMER_ID</contextPath>` — the value is not in `RuleContextPathType` and the deploy will fail.
@@ -0,0 +1,75 @@
1
+ # RECORD Templates
2
+
3
+ Each template is a verified shape from a passing test fixture. Copy, then change names/values.
4
+
5
+ ---
6
+
7
+ ## RECORD — Basic RLS (record field = user attribute)
8
+
9
+ Source: `conditionRLSValidSteelthread` (first condition), `conditionStandardIdRLSValidSteelthread`
10
+
11
+ > **RLS MDAPI round-trip is fragile in real orgs.** Deploy/retrieve can fail with opaque gacks if a DMO field in `<valueDomain>` is not mapped in the org's data streams. Build the rule in the UI first; use MDAPI templates as verification shapes, not first-try authoring. See §8.3 of policy.md.
12
+
13
+ ```xml
14
+ <?xml version="1.0" encoding="UTF-8"?>
15
+ <PolicyRuleDefinition xmlns="http://soap.sforce.com/2006/04/metadata">
16
+ <action>Read</action>
17
+ <category>RECORD_POLICY_RULE_DEFINITION</category>
18
+ <effect>Permit</effect>
19
+ <label>Rule1</label>
20
+ <policyRuleDefinitionSetName>StandardFieldSet3</policyRuleDefinitionSetName>
21
+ <policyRuleResourceDomains>
22
+ <resourceDomain>testDMO__dlm</resourceDomain>
23
+ </policyRuleResourceDomains>
24
+ <principalAuthenticationLevel>INTERNAL</principalAuthenticationLevel>
25
+ <principalScopeType>ANY</principalScopeType>
26
+ <resourceScopeType>RECORD</resourceScopeType>
27
+ <ruleConsumer>DATACLOUD</ruleConsumer>
28
+ <transformPrecedence>0</transformPrecedence>
29
+ <whenPolicyRuleDefinitionClauseConjunction>
30
+ <conditions>
31
+ <clause>WHEN</clause>
32
+ <operator>EQUALS</operator>
33
+ <resourcePath>RECORDFIELD</resourcePath>
34
+ <valueDomain>testDMO__dlm:name__c</valueDomain>
35
+ <valuePrincipalPath>USER_ID</valuePrincipalPath>
36
+ </conditions>
37
+ <conjunctionExpression>1</conjunctionExpression>
38
+ </whenPolicyRuleDefinitionClauseConjunction>
39
+ </PolicyRuleDefinition>
40
+ ```
41
+
42
+ For literal-value RLS (e.g. `record.field == 'X'`), use `<policyRuleValueSet><valueString>X</valueString></policyRuleValueSet>` instead of `<valuePrincipalPath>`.
43
+
44
+ ---
45
+
46
+ ## RECORD — RLS via PROJECTION Join
47
+
48
+ Source: `conditionRLSValidSteelthread` (second condition)
49
+
50
+ ```xml
51
+ <conditions>
52
+ <clause>WHEN</clause>
53
+ <operator>EXISTS</operator>
54
+ <resourcePath>EXPRESSION</resourcePath>
55
+ <resourceExpression>
56
+ <type>PROJECTION</type>
57
+ <version>1</version>
58
+ <projection>
59
+ <join>
60
+ <schema>testDMO__dlm</schema>
61
+ <alias>test 1</alias>
62
+ <predicate>
63
+ <comparator>EQUALS</comparator>
64
+ <attribute>testDMO__dlm:name__c</attribute>
65
+ <on>
66
+ <resourceAlias>resource</resourceAlias>
67
+ <schema>testDMO__dlm</schema>
68
+ <field>age__c</field>
69
+ </on>
70
+ </predicate>
71
+ </join>
72
+ </projection>
73
+ </resourceExpression>
74
+ </conditions>
75
+ ```
@@ -0,0 +1,70 @@
1
+ # TRANSFORM Templates
2
+
3
+ Each template is a verified shape from a passing test fixture. Copy, then change names/values.
4
+
5
+ ---
6
+
7
+ ## TRANSFORM — Field Masking with Permission + Classification Gates
8
+
9
+ Source: `conditionClassificationValidDataMaskingSteelthread`
10
+
11
+ ```xml
12
+ <?xml version="1.0" encoding="UTF-8"?>
13
+ <PolicyRuleDefinition xmlns="http://soap.sforce.com/2006/04/metadata">
14
+ <action>Read</action>
15
+ <category>TRANSFORM_POLICY_RULE_DEFINITION</category>
16
+ <effect>Transform</effect>
17
+ <label>Rule0</label>
18
+ <policyRuleDefinitionSetName>DataMasking1</policyRuleDefinitionSetName>
19
+ <principalAuthenticationLevel>INTERNAL</principalAuthenticationLevel>
20
+ <principalScopeType>ANY</principalScopeType>
21
+ <resourceScopeType>FIELD</resourceScopeType>
22
+ <resourceTransform>NULL_RESOURCE_TRANSFORM</resourceTransform>
23
+ <ruleConsumer>DATACLOUD</ruleConsumer>
24
+ <transformPrecedence>0</transformPrecedence>
25
+ <whenPolicyRuleDefinitionClauseConjunction>
26
+ <conditions>
27
+ <clause>WHEN</clause>
28
+ <operator>IS</operator>
29
+ <resourcePath>ENTITYTYPE</resourcePath>
30
+ <policyRuleValueSet>
31
+ <valueString>{&quot;t&quot;:&quot;Text&quot;,&quot;v&quot;:&quot;FIELD&quot;}</valueString>
32
+ </policyRuleValueSet>
33
+ </conditions>
34
+ <conditions>
35
+ <clause>WHEN</clause>
36
+ <operator>CONTAINS_NONE</operator>
37
+ <principalPath>ASSIGNED_PERMISSIONS_PATH</principalPath>
38
+ <policyRuleValueSet>
39
+ <valueReference>testCustomPermissionMasking</valueReference>
40
+ <valueReferenceType>CUSTOM_PERMISSION</valueReferenceType>
41
+ </policyRuleValueSet>
42
+ </conditions>
43
+ <conditions>
44
+ <clause>WHEN</clause>
45
+ <operator>CONTAINS_ANY</operator>
46
+ <resourcePath>CLASSIFICATION</resourcePath>
47
+ <policyRuleValueSet>
48
+ <valueReference>DataGovernanceClassifications.DataCategorization.FieldUsage.Active</valueReference>
49
+ <valueReferenceType>STANDARD_CLASSIFICATION</valueReferenceType>
50
+ </policyRuleValueSet>
51
+ </conditions>
52
+ <conjunctionExpression>(AND 1 2 3)</conjunctionExpression>
53
+ </whenPolicyRuleDefinitionClauseConjunction>
54
+ </PolicyRuleDefinition>
55
+ ```
56
+
57
+ For parameterized masking (e.g. mask all but first 4 chars):
58
+ ```xml
59
+ <resourceTransform>ALL_BUT_FIRST_N_CHARS_RESOURCE_TRANSFORM</resourceTransform>
60
+ <resourceExpression>
61
+ <type>ARGLIST</type>
62
+ <version>1</version>
63
+ <transformExpression>
64
+ <argument>
65
+ <type>NUMBER</type>
66
+ <value>4</value>
67
+ </argument>
68
+ </transformExpression>
69
+ </resourceExpression>
70
+ ```