platform-policy-rule-generate
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAuthoring Policy Rule Definitions
编写政策规则定义
Gating: =
Min API version: 64.0 (66.0 for conditions using )
@WsdlGuard("EnforceOMatic.orgCanUsePolicyRuleMDAPI")OrgPermissions.EnforceOMatic && OrgPermissions.PolicyRuleMDAPIPolicyJsonExpressionFor human maintainers (not the agent): the Java source-of-truth lives atand reference fixtures atenforce-o-matic-impl/java/src/enforce/o/matic/metadata/. The agent should rely on the templates and reference docs in this skill bundle — those impl paths are not readable from the Vibes/MCP runtime.enforce-o-matic-impl/test/func/filemetadata/<name>/
This skill covers the on-disk metadata XML format for authoring policies. Use it whenever a task asks to write a or file, add a fixture under , or ship a metadata package. The runtime side (RuleProvider, hooks) is out of scope.
*.policyRuleDefinition*.policyRuleDefinitionSettest/func/filemetadata/Eval coverage: This skill is exercised by the team's ADK eval framework, not byunder the skill directory. Five datasets covering the ACCESS / GOVERNANCE / RECORD / TRANSFORM variants live intests/evals/.packages/adk-eval/eval/domains/platform-policy-rule-generate/datasets/
准入条件: =
最低API版本: 64.0(使用的条件需66.0)
@WsdlGuard("EnforceOMatic.orgCanUsePolicyRuleMDAPI")OrgPermissions.EnforceOMatic && OrgPermissions.PolicyRuleMDAPIPolicyJsonExpression面向人工维护者(非Agent): Java权威源码位于,参考示例位于enforce-o-matic-impl/java/src/enforce/o/matic/metadata/。Agent应依赖本技能包中的模板和参考文档——这些实现路径无法在Vibes/MCP运行时读取。enforce-o-matic-impl/test/func/filemetadata/<name>/
本技能涵盖用于编写政策的磁盘元数据XML格式。当任务要求编写或文件、在下添加示例,或发布元数据包时,请使用本技能。运行时相关内容(RuleProvider、钩子)不在本技能范围内。
*.policyRuleDefinition*.policyRuleDefinitionSettest/func/filemetadata/评估覆盖范围: 本技能由团队的ADK评估框架测试,而非技能目录下的。涵盖ACCESS / GOVERNANCE / RECORD / TRANSFORM变体的五组数据集位于tests/evals/。packages/adk-eval/eval/domains/platform-policy-rule-generate/datasets/
1. Package Layout
1. 包结构
A deployable package always contains:
text
<fixture>/
package.xml
policyRuleDefinitionSets/<setName>.policyRuleDefinitionSet
policyRuleDefinitions/<ruleName>.policyRuleDefinitionpackage.xml<version>[ftest]</version>64.0xml
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>Rule0</members>
<name>PolicyRuleDefinition</name>
</types>
<types>
<members>Set1</members>
<name>PolicyRuleDefinitionSet</name>
</types>
<version>64.0</version>
</Package>可部署包始终包含以下内容:
text
<fixture>/
package.xml
policyRuleDefinitionSets/<setName>.policyRuleDefinitionSet
policyRuleDefinitions/<ruleName>.policyRuleDefinitionpackage.xml<version>[ftest]</version>64.0xml
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>Rule0</members>
<name>PolicyRuleDefinition</name>
</types>
<types>
<members>Set1</members>
<name>PolicyRuleDefinitionSet</name>
</types>
<version>64.0</version>
</Package>2. PolicyRuleDefinitionSet Schema
2. PolicyRuleDefinitionSet架构
xml
<PolicyRuleDefinitionSet xmlns="http://soap.sforce.com/2006/04/metadata">
<label>Set1</label>
<description>Optional free text</description>
<replicated>false</replicated> <!-- MinAppVersion 260 -->
<builderCompatible>true</builderCompatible> <!-- MinAppVersion 262, author-settable -->
<!-- builderValidated: server-managed — do not set in authored XML -->
</PolicyRuleDefinitionSet>| Element | Req | Notes |
|---|---|---|
| yes | Master label. File basename (devName) is the MDAPI identifier, not the label. |
| no | Free text. |
| no | |
| no | |
| no | Server-managed. Never set in authored XML. Server overwrites on validation. |
xml
<PolicyRuleDefinitionSet xmlns="http://soap.sforce.com/2006/04/metadata">
<label>Set1</label>
<description>可选自由文本</description>
<replicated>false</replicated> <!-- 最低应用版本260 -->
<builderCompatible>true</builderCompatible> <!-- 最低应用版本262,可由编写者设置 -->
<!-- builderValidated: 由服务器管理——请勿在编写的XML中设置 -->
</PolicyRuleDefinitionSet>| 元素 | 必填 | 说明 |
|---|---|---|
| 是 | 主标签。文件基名(devName)是MDAPI标识符,而非标签。 |
| 否 | 自由文本。 |
| 否 | 设置为 |
| 否 | |
| 否 | 由服务器管理。请勿在编写的XML中设置。 服务器会在验证时覆盖该值。 |
3. PolicyRuleDefinition — Core Fields
3. PolicyRuleDefinition — 核心字段
| Element | Req | Notes |
|---|---|---|
| yes | MasterLabel. |
| yes | See §4. Drives |
| yes | |
| yes (≥1) | |
| yes | Developer name of parent set. |
| yes | Always |
| yes | |
| no | |
| no | |
| no | Required for RECORD (RLS) and FIELD-scope TRANSFORM rules only. Forbidden on ACCESS/GOVERNANCE. |
| no | Required (and only valid) when |
| no | WHEN conditions. |
| no | UNLESS conditions. Not UI-editable — prefer WHEN + negated operator. |
| 元素 | 必填 | 说明 |
|---|---|---|
| 是 | MasterLabel。 |
| 是 | 参见第4节。决定 |
| 是 | |
| 是(至少1个) | |
| 是 | 父集合的开发者名称。 |
| 是 | 始终为 |
| 是 | |
| 否 | |
| 否 | |
| 否 | 仅RECORD(RLS)和FIELD范围的TRANSFORM规则需要。ACCESS/GOVERNANCE规则禁止使用。 |
| 否 | 仅当 |
| 否 | WHEN条件。 |
| 否 | UNLESS条件。不可通过UI编辑——优先使用WHEN+否定运算符。 |
4. Category Decision Tree
4. 类别决策树
Category names a domain (where in the platform's enforcement layers the rule applies). Effect names the action (allow / deny / transform). They are independent except for TRANSFORM.
The only Category × Effect rule the platform validates
():
enforce-o-matic-api/java/src/enforce/o/matic/api/module/api/RuleBuilder.java- ⇔
effect=Transform(bidirectional; mismatched throwscategory=TRANSFORM_POLICY_RULE_DEFINITION).INVALIDFORCATEGORY - All other categories (,
ACCESS,GOVERNANCE,RECORD) accept eitherIDENTIFIED_RECORDorPermit.Forbid
Note on the platform's auto-fill default: Whenis omitted from authored XML, the impl-side save hook (<category>) fills it in fromPolicyRuleDefinitionObject.saveHook_Validate:effect,Permit→ACCESS,Forbid→GOVERNANCE. This is a default-fill, not a validation. If you author an explicit category that contradicts this default, it is accepted and persisted as-is.Transform→TRANSFORM
类别指定规则在平台执行层中的应用域,效果指定操作(允许/拒绝/转换)。除TRANSFORM外,二者相互独立。
平台唯一验证的类别×效果规则(位于):
enforce-o-matic-api/java/src/enforce/o/matic/api/module/api/RuleBuilder.java- ⇔
effect=Transform(双向绑定;不匹配会抛出category=TRANSFORM_POLICY_RULE_DEFINITION错误)。INVALIDFORCATEGORY - 其他所有类别(、
ACCESS、GOVERNANCE、RECORD)均可接受IDENTIFIED_RECORD或Permit。Forbid
平台自动填充默认值说明: 如果编写的XML中省略,实现层的保存钩子(<category>)会根据PolicyRuleDefinitionObject.saveHook_Validate自动填充:effect、Permit→ACCESS、Forbid→GOVERNANCE。这是默认填充,而非验证规则。 如果您编写的显式类别与该默认值矛盾,系统会接受并按原样持久化。Transform→TRANSFORM
Picking the category
类别选择指南
text
What kind of policy?
│
├── OLS/FLS allow/deny on tagged or classified resources
│ category = ACCESS_POLICY_RULE_DEFINITION (allow/deny attestation in the access plane)
│ | GOVERNANCE_POLICY_RULE_DEFINITION (governance-audited)
│ effect = Permit | Forbid (chosen independently from category)
│ resourceScopeType = ANY | FIELD | DATASPACE
│ NO <policyRuleResourceDomains>
│ condition: resourcePath=TAG|CLASSIFICATION CONTAINS_ANY <ref>
│ For "objects AND all their fields" → action=TupleRead + OR-of-ENTITYTYPE clause (§7)
│ Note: "Block access to Foo object" → tag Foo with <yourTag>, write rule on tag
│ Do NOT use <resourceDomain>Foo</resourceDomain> — forbidden for ACCESS/GOVERNANCE
│
├── Row-level filter on a DMO/DLO
│ category = RECORD_POLICY_RULE_DEFINITION
│ effect = Permit | Forbid
│ resourceScopeType = RECORD
│ <policyRuleResourceDomains> = the DMO/DLO API name ← entity targeting allowed here
│
├── Identified-Guest record access
│ NOT authorable via MDAPI — SESSION_CONSUMER_ID is not in RuleContextPathType
│ Must be implemented as a runtime RuleProvider.
│
└── Field masking
category = TRANSFORM_POLICY_RULE_DEFINITION ← required by RuleBuilder validator
effect = Transform ← required by RuleBuilder validator
resourceScopeType = FIELD (structured) or SPAN (unstructured)
<policyRuleResourceDomains> = the DMO whose field is masked
<resourceTransform> required (e.g. NULL_RESOURCE_TRANSFORM, LAST_N_CHARS_RESOURCE_TRANSFORM)text
您需要哪种政策?
│
├── 对标记或分类资源的OLS/FLS允许/拒绝
│ category = ACCESS_POLICY_RULE_DEFINITION(访问层的允许/拒绝验证)
│ | GOVERNANCE_POLICY_RULE_DEFINITION(经治理审计)
│ effect = Permit | Forbid(与类别独立选择)
│ resourceScopeType = ANY | FIELD | DATASPACE
│ 禁止使用 <policyRuleResourceDomains>
│ 条件:resourcePath=TAG|CLASSIFICATION CONTAINS_ANY <ref>
│ 若需“对象及其所有字段”→ action=TupleRead + OR-of-ENTITYTYPE子句(第7节)
│ 注意:“阻止访问Foo对象”→ 为Foo添加<yourTag>标记,基于该标记编写规则
│ 请勿使用 <resourceDomain>Foo</resourceDomain> —— ACCESS/GOVERNANCE规则禁止此操作
│
├── DMO/DLO上的行级过滤
│ category = RECORD_POLICY_RULE_DEFINITION
│ effect = Permit | Forbid
│ resourceScopeType = RECORD
│ <policyRuleResourceDomains> = DMO/DLO的API名称 ← 此处允许实体定位
│
├── 已识别访客的记录访问
│ 无法通过MDAPI编写 —— SESSION_CONSUMER_ID不在RuleContextPathType中
│ 必须通过运行时RuleProvider实现。
│
└── 字段掩码
category = TRANSFORM_POLICY_RULE_DEFINITION ← RuleBuilder验证器要求
effect = Transform ← RuleBuilder验证器要求
resourceScopeType = FIELD(结构化)或SPAN(非结构化)
<policyRuleResourceDomains> = 字段被掩码的DMO
必须包含<resourceTransform>(例如NULL_RESOURCE_TRANSFORM、LAST_N_CHARS_RESOURCE_TRANSFORM)ACCESS vs GOVERNANCE — how to choose
ACCESS与GOVERNANCE的选择
Both legally accept Permit and Forbid. Pick by which enforcement layer should record/audit the rule and what the prompt literally asks for:
| Use case | Pick | Reason |
|---|---|---|
| The prompt names "ACCESS policy rule" / "access rule" / "OLS/FLS" explicitly | | Matches the prompt's vocabulary; sits in the data-access enforcement layer. |
| The prompt names "governance" / "audit" / "policy framework" / data-residency or compliance language | | Matches the prompt's vocabulary; rules surface in governance reporting. |
| Prompt is ambiguous and only describes allow/deny semantics | Default to |
Important — honor the explicit category in the prompt. If the prompt says "ACCESS policy rule that denies …" or "GOVERNANCE policy rule that permits …", emit exactly that category. Do not silently swap to the auto-fill default just because effect is Forbid (or Permit). The platform accepts both. The agent must not override the user's stated intent.
Scope × category compatibility — any combination outside this matrix throws :
INVALIDFORCATEGORY | | | | |
|---|---|---|---|---|
| Yes | Yes | No | No |
| Yes | Yes | No | No |
| Yes | Yes | Yes | No |
| No | No | No | Yes |
| No | No | Yes | No |
两者均支持Permit和Forbid。请根据规则应记录/审计的执行层以及提示的字面要求进行选择:
| 使用场景 | 选择 | 原因 |
|---|---|---|
| 提示明确提及“ACCESS政策规则”/“访问规则”/“OLS/FLS” | | 匹配提示词汇;位于数据访问执行层。 |
| 提示提及“治理”/“审计”/“政策框架”/数据驻留或合规相关表述 | | 匹配提示词汇;规则会出现在治理报告中。 |
| 提示模糊,仅描述允许/拒绝语义 | 默认Permit选 |
重要提示:请遵循提示中的明确类别。 如果提示要求“拒绝访问的ACCESS政策规则”或“允许访问的GOVERNANCE政策规则”,请严格输出指定类别。不要因为效果是Forbid(或Permit)就自动替换为默认值。平台接受这两种组合,Agent不得覆盖用户的明确意图。
范围×类别兼容性 —— 超出以下矩阵的组合会抛出错误:
INVALIDFORCATEGORY | | | | |
|---|---|---|---|---|
| 是 | 是 | 否 | 否 |
| 是 | 是 | 否 | 否 |
| 是 | 是 | 是 | 否 |
| 否 | 否 | 否 | 是 |
| 否 | 否 | 是 | 否 |
5. Condition Patterns (Quick Reference)
5. 条件模式(快速参考)
Every block needs all four: , , one path element, and the value.
<conditions><clause><operator>| Goal | path element | operator | value |
|---|---|---|---|
| Resource has tag | | | |
| Resource has classification | | | |
| Principal has permission | | | |
| Session in dataspace | | | |
| Record field = user attribute | | | |
| Entity type check | | | |
<conjunctionExpression>1(AND 1 2)(OR 1 2)(AND (OR 1 2) (AND 3))1For full path enums (, , ), operators, and JSON expressions (PROJECTION / ARGLIST / SOQLTARGETLISTEXPR), see .
For copy-paste templates for all policy variants, see .
RulePrincipalPathTypeRuleResourcePathTypeRuleContextPathTypereferences/policy-schema-full.mdreferences/templates.md每个块必须包含四个元素:、、一个路径元素和值。
<conditions><clause><operator>| 目标 | 路径元素 | 运算符 | 值 |
|---|---|---|---|
| 资源带有标记 | | | |
| 资源带有分类 | | | |
| 主体拥有权限 | | | |
| 会话位于数据空间 | | | |
| 记录字段=用户属性 | | | |
| 实体类型检查 | | | |
<conjunctionExpression>1(AND 1 2)(OR 1 2)(AND (OR 1 2) (AND 3))1完整路径枚举(、、)、运算符和JSON表达式(PROJECTION / ARGLIST / SOQLTARGETLISTEXPR)请参见。所有政策变体的复制粘贴模板请参见。
RulePrincipalPathTypeRuleResourcePathTypeRuleContextPathTypereferences/policy-schema-full.mdreferences/templates.md6. Validation Guardrails
6. 验证防护准则
- Every needs an
<conditions>. Missing operator → reject.<operator> - Every needs at least one path element (
<conditions>,<resourcePath>,<principalPath>, or<contextPath>).<valueDomain> - is exclusively
<contextPath>. Never put a resource path value there.SESSION_DATASPACE - Scope × category must be in the §4 matrix. Common offenders: ACCESS/GOVERNANCE + RECORD scope; RECORD + ANY/FIELD scope; TRANSFORM + ANY/RECORD scope. (Effect is independent of category except for TRANSFORM — see §4.)
- and
<resourceTransform>are coupled. Transform effect needs a resourceTransform. Permit/Forbid must not have one.effect=Transform - is required for RECORD (RLS) and FIELD-scope TRANSFORM; forbidden on ACCESS/GOVERNANCE.
<policyRuleResourceDomains> - indices must match actual
<conjunctionExpression>count. Off-by-one → reject.<conditions> - inside
<clause>must match the wrapper (<conditions>insideWHEN,<when…>insideUNLESS).<unless…> - JSON literals in must escape
<valueString>to". Wrong escaping silently corrupts the literal." - Reference targets (,
<valueReference>) must exist in the target org at deploy time.<resourceDomain> - /
SCALAR_ATTRIBUTEare not inPLURAL_ATTRIBUTE— not in MDAPI contract. Use a runtime RuleProvider for those shapes.RulePrincipalPathType - is not authorable via MDAPI —
IDENTIFIED_RECORDnot inSESSION_CONSUMER_ID.RuleContextPathType - Standard tag/classification dev names are fully-qualified dotted paths (e.g. ). Retrieve an existing rule to get the exact string before authoring.
DataGovernanceTags.ExternalData.Visibility.Public - Min API versions: = 64.0;
PolicyRuleDefinitionconditions = 66.0;PolicyJsonExpression= 260+;<replicated>/<builderCompatible>= 262+.<builderValidated>
Note onshape: A bare top-level index (e.g.<conjunctionExpression>) deploys cleanly — the impl-side parser accepts bare tokens at the top level, and most positive single-condition fixtures in<conjunctionExpression>1</conjunctionExpression>use it. It is not a deploy-time validation error. It does, however, crash the Data Governance Policy Builder UI on load — see §7.enforce-o-matic-impl/test/func/filemetadata/
- 每个必须包含
<conditions>。缺少运算符→拒绝。<operator> - 每个必须至少包含一个路径元素(
<conditions>、<resourcePath>、<principalPath>或<contextPath>)。<valueDomain> - 只能是
<contextPath>。请勿在此处放置资源路径值。SESSION_DATASPACE - 范围×类别必须符合第4节的矩阵。常见错误:ACCESS/GOVERNANCE + RECORD范围;RECORD + ANY/FIELD范围;TRANSFORM + ANY/RECORD范围。(除TRANSFORM外,效果与类别独立——参见第4节。)
- 与
<resourceTransform>绑定。Transform效果需要resourceTransform,Permit/Forbid不得包含该元素。effect=Transform - 必须用于RECORD(RLS)和FIELD范围的TRANSFORM规则;禁止用于ACCESS/GOVERNANCE规则。
<policyRuleResourceDomains> - 的索引必须与实际
<conjunctionExpression>数量匹配。索引偏移→拒绝。<conditions> - 内的
<conditions>必须与外层包装匹配(<clause>内为<when…>,WHEN内为<unless…>)。UNLESS - 中的JSON字面量必须将
<valueString>转义为"。错误转义会静默破坏字面量。" - 引用目标(、
<valueReference>)必须在部署时存在于目标组织中。<resourceDomain> - /
SCALAR_ATTRIBUTE不在PLURAL_ATTRIBUTE中——不属于MDAPI约定。此类场景请使用运行时RuleProvider。RulePrincipalPathType - 无法通过MDAPI编写——
IDENTIFIED_RECORD不在SESSION_CONSUMER_ID中。RuleContextPathType - 标准标记/分类的开发者名称为全限定点路径(例如)。编写前请先检索现有规则以获取准确字符串。
DataGovernanceTags.ExternalData.Visibility.Public - 最低API版本:= 64.0;
PolicyRuleDefinition条件 = 66.0;PolicyJsonExpression= 260+;<replicated>/<builderCompatible>= 262+。<builderValidated>
关于格式的说明: 顶级裸索引(例如<conjunctionExpression>)可正常部署——实现层解析器接受顶级裸标记,且<conjunctionExpression>1</conjunctionExpression>中的大多数单条件示例均使用此格式。这不是部署时验证错误,但会导致Data Governance Policy Builder UI加载时崩溃——请参见第7节。enforce-o-matic-impl/test/func/filemetadata/
7. UI Compatibility — Core Rules
7. UI兼容性——核心规则
The Data Governance Policy Builder edits a strict subset of the MDAPI. Default goal: produce UI-compatible policies. Always confirm with the operator before producing API-only XML.
Hard blockers — any of these make the policy uneditable (and several crash the builder on load):
- Missing OR-of-ENTITYTYPE clause on ACCESS/GOVERNANCE rules → hard crash: . Required even when paired with
Cannot use 'in' operator to search for 'Permit' in undefined(where it's functionally redundant at runtime). Must includeTupleReadconditions forISand{"t":"Text","v":"OBJECT"}.{"t":"Text","v":"FIELD"} - Bare top-level condition index in (e.g.
<conjunctionExpression>, or1) → crash on builder load in(AND (OR 1 2) 3). Deploy is unaffected, but the policy is uneditable in the UI. Always wrap:buildCriteriafor a single condition;(AND 1)instead of(AND (OR 1 2) (AND 3)).(AND (OR 1 2) 3) - +
category = ACCESS_POLICY_RULE_DEFINITION→ the Data Governance Policy Builder UI (not MDAPI) collapses it to GOVERNANCE on save; round-trip via the builder will rewrite the category. MDAPI deploy is unaffected — the original ACCESS+Forbid combination is valid and deploys without modification. If your goal is UI round-trippability, prefer GOVERNANCE for Forbid; if the source of truth is MDAPI, ACCESS+Forbid is fine.effect = Forbid - Any block → silently dropped on first UI save.
<unlessPolicyRuleDefinitionClauseConjunction> - More than one → only the first is kept.
<action> - ≠
ruleConsumer→ UI hardcodes DATACLOUD on save.DATACLOUD - Top-level conjunction → triggers
(OR 1 2)path, rule silently dropped.// ERROR: Unsupported rule!
UI-compatible "unless" rewrite:
| Author intent | UI-compatible shape |
|---|---|
| |
| |
| |
For the full UI-compatibility checklist, round-trip rules, and operator support matrix, see .
references/ui-compatibility.mdData Governance Policy Builder仅支持MDAPI的严格子集。默认目标:生成UI兼容的政策。在生成仅支持API的XML前,请务必与操作者确认。
硬性障碍——以下任何情况都会导致政策无法编辑(部分情况会导致Builder加载时崩溃):
- ACCESS/GOVERNANCE规则缺少OR-of-ENTITYTYPE子句→ 严重崩溃:。即使与
Cannot use 'in' operator to search for 'Permit' in undefined配合使用(运行时功能冗余),也必须包含此子句。必须添加针对TupleRead和{"t":"Text","v":"OBJECT"}的{"t":"Text","v":"FIELD"}条件。IS - 中使用顶级裸条件索引(例如
<conjunctionExpression>或1)→ Builder加载时在(AND (OR 1 2) 3)中崩溃。部署不受影响,但政策无法在UI中编辑。请始终包装为:单条件使用buildCriteria;将(AND 1)替换为(AND (OR 1 2) 3)。(AND (OR 1 2) (AND 3)) - +
category = ACCESS_POLICY_RULE_DEFINITION→ Data Governance Policy Builder UI(非MDAPI)会在保存时将其转换为GOVERNANCE;通过Builder往返编辑会重写类别。MDAPI部署不受影响——原始的ACCESS+Forbid组合有效且可正常部署。若需UI往返编辑兼容性,Forbid效果优先选择GOVERNANCE类别;若以MDAPI为权威来源,ACCESS+Forbid组合是可行的。effect = Forbid - 任何块→ 首次UI保存时会被静默丢弃。
<unlessPolicyRuleDefinitionClauseConjunction> - 多个→ 仅保留第一个。
<action> - ≠
ruleConsumer→ UI会在保存时硬编码为DATACLOUD。DATACLOUD - 顶级组合→ 触发
(OR 1 2)路径,规则被静默丢弃。// ERROR: Unsupported rule!
UI兼容的“unless”重写方式:
| 编写意图 | UI兼容格式 |
|---|---|
| |
| |
| |
完整的UI兼容性检查清单、往返规则以及运算符/路径支持矩阵请参见。
references/ui-compatibility.md8. Authoring Workflow
8. 编写流程
- Start from the closest template in — modify from there, don't start blank.
references/templates.md - Pick category first (§4). Category fixes effect, resourceScopeType, and whether policyRuleResourceDomains/resourceTransform are required.
- Lay out the bare rule: top-level fields only, no conditions. Match the category template in .
references/templates.md - Add conditions one at a time, each with all four anchors: ,
<clause>, one path element, and the value.<operator> - Update — 1-indexed prefix notation. Bare top-level index (e.g.
<conjunctionExpression>) deploys but breaks the UI; wrap as1if UI editability matters (§7).(AND 1) - Run the UI-compatibility check (§7 / ). If any item trips, attempt the "unless" rewrite first; if not possible, get explicit operator confirmation before continuing.
references/ui-compatibility.md - Update — list each
package.xmlfor both types.<members> - Set on the set to
<builderCompatible>if §7 checklist passes;trueif intentionally API-only.false - Sanity-check against §6 (guardrails) before considering done.
- Validate with dry-run before any non-dry deploy to a persistent org. Surface errors using the error reference in .
references/deploy-errors.md
Three-layer correctness check before done:
- Runtime / Cedar — does the rule enforce what's intended? (action choice, condition shape)
- MDAPI deploy validity — does it deploy? (§6 guardrails, scope×category, tag dev names, org perms)
- UI editability — can the builder render and re-save it? (§7 checklist, OR-of-ENTITYTYPE requirement)
- 从最接近的模板开始,位于——基于模板修改,不要从零开始。
references/templates.md - 先选择类别(第4节)。类别决定效果、resourceScopeType以及是否需要policyRuleResourceDomains/resourceTransform。
- 搭建规则框架:仅包含顶级字段,无条件。匹配中的类别模板。
references/templates.md - 逐个添加条件,每个条件必须包含四个锚点:、
<clause>、一个路径元素和值。<operator> - 更新——采用1索引前缀表示法。顶级裸索引(如
<conjunctionExpression>)可部署但会破坏UI;若需UI可编辑性,请包装为1(第7节)。(AND 1) - 运行UI兼容性检查(第7节 / )。若触发任何项,请先尝试“unless”重写;若无法重写,请在继续前获得操作者的明确确认。
references/ui-compatibility.md - 更新——列出两种类型的每个
package.xml。<members> - 设置:若通过第7节检查清单,将集合的该值设为
<builderCompatible>;若为故意仅支持API,则设为true。false - 完成前对照第6节(防护准则)进行 sanity 检查。
- 在非试运行部署到持久化组织前,先进行试运行验证。使用中的错误参考排查问题。
references/deploy-errors.md
完成前的三层正确性检查:
- 运行时 / Cedar——规则是否按预期执行?(操作选择、条件格式)
- MDAPI部署有效性——能否部署?(第6节防护准则、范围×类别、标记开发者名称、组织权限)
- UI可编辑性——Builder能否渲染并重新保存?(第7节检查清单、OR-of-ENTITYTYPE要求)
Reference Docs
参考文档
| Detail | File |
|---|---|
| Full path enums, operators, value sets, JSON expressions (PROJECTION / ARGLIST / SOQLTARGETLISTEXPR) | |
Copy-paste templates — index at | |
| Full UI-compatibility checklist, round-trip rules, operator/path support matrix | |
| 详情 | 文件 |
|---|---|
| 完整路径枚举、运算符、值集、JSON表达式(PROJECTION / ARGLIST / SOQLTARGETLISTEXPR) | |
复制粘贴模板——索引位于 | |
| 完整UI兼容性检查清单、往返规则、运算符/路径支持矩阵 | |