@salesforce/afv-skills 1.45.0 → 1.47.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.
- package/package.json +1 -1
- package/skills/agentforce-observe/SKILL.md +32 -4
- package/skills/agentforce-observe/references/ahm-alerts.md +719 -0
- package/skills/automation-flow-generate/SKILL.md +11 -5
- package/skills/consumer-goods-promotion-bo-api-deploy/SKILL.md +275 -0
- package/skills/consumer-goods-promotion-bo-api-deploy/assets/set-comment-value/README.md +32 -0
- package/skills/consumer-goods-promotion-bo-api-deploy/assets/set-comment-value/SetCommentValue.cls +75 -0
- package/skills/consumer-goods-promotion-bo-api-deploy/assets/set-comment-value/SetCommentValue.cls-meta.xml +5 -0
- package/skills/consumer-goods-promotion-bo-api-deploy/assets/set-comment-value/interview-answers.json +13 -0
- package/skills/consumer-goods-promotion-bo-api-deploy/assets/set-comment-value/payloads/copy.json +10 -0
- package/skills/consumer-goods-promotion-bo-api-deploy/assets/set-comment-value/payloads/create.json +20 -0
- package/skills/consumer-goods-promotion-bo-api-deploy/assets/set-comment-value/payloads/update.json +16 -0
- package/skills/consumer-goods-promotion-bo-api-deploy/references/conventions-and-payload-rules.md +273 -0
- package/skills/consumer-goods-promotion-bo-api-deploy/references/generate-and-wire.md +236 -0
- package/skills/consumer-goods-promotion-bo-api-deploy/references/reference-example-set-comment-value.md +132 -0
- package/skills/consumer-goods-promotion-bo-api-deploy/references/smoke-and-verify.md +211 -0
- package/skills/dx-code-analyzer-configure/scripts/validate-config.sh +14 -10
- package/skills/dx-code-analyzer-run/scripts/apply-fixes.js +45 -4
- package/skills/dx-code-analyzer-run/scripts/describe-rule.js +52 -32
- package/skills/dx-devops-project-manage/SKILL.md +197 -0
- package/skills/dx-devops-project-manage/examples/common-workflows.md +197 -0
- package/skills/dx-devops-project-manage/references/cli-commands.md +295 -0
- package/skills/dx-devops-project-manage/scripts/create-project.sh +48 -0
- package/skills/dx-devops-project-manage/scripts/list-projects.sh +51 -0
- package/skills/dx-devops-project-manage/scripts/update-project.sh +96 -0
- package/skills/education-cloud-academic-calendar-generate/SKILL.md +225 -0
- package/skills/education-cloud-academic-calendar-generate/examples/quarter-calendar.json +47 -0
- package/skills/education-cloud-academic-calendar-generate/examples/sample-output.md +57 -0
- package/skills/education-cloud-academic-calendar-generate/examples/semester-calendar.json +54 -0
- package/skills/education-cloud-academic-calendar-generate/references/calendar-systems.md +127 -0
- package/skills/education-cloud-academic-calendar-generate/references/date-validation.md +222 -0
- package/skills/education-cloud-academic-calendar-generate/references/foundation_prerequisites.md +40 -0
- package/skills/education-cloud-academic-calendar-generate/scripts/validate_calendar_dates.py +143 -0
- package/skills/education-cloud-course-catalog-migrate/SKILL.md +321 -0
- package/skills/education-cloud-course-catalog-migrate/references/gotchas-detail.md +16 -0
- package/skills/education-cloud-course-catalog-migrate/references/gotchas.md +16 -0
- package/skills/education-cloud-course-catalog-migrate/references/large-catalog-handling.md +42 -0
- package/skills/education-cloud-course-catalog-migrate/scripts/batch_courses.py +36 -0
- package/skills/education-cloud-course-catalog-migrate/scripts/detect_linked_courses.py +51 -0
- package/skills/education-cloud-course-catalog-migrate/scripts/detect_modality_variants.py +48 -0
- package/skills/education-cloud-course-catalog-migrate/scripts/resolve_api_version.py +43 -0
- package/skills/education-cloud-course-catalog-migrate/scripts/split_course_code.py +39 -0
- package/skills/education-cloud-course-catalog-migrate/scripts/validate_completeness.py +54 -0
- package/skills/education-cloud-multi-campus-configure/references/foundation_prerequisites.md +3 -5
- package/skills/education-cloud-student-recruitment-agent-configure/SKILL.md +177 -0
- package/skills/education-cloud-student-recruitment-agent-configure/references/agent-and-subagents.md +151 -0
- package/skills/education-cloud-student-recruitment-agent-configure/references/customer-narration.md +34 -0
- package/skills/education-cloud-student-recruitment-agent-configure/references/execution-model.md +54 -0
- package/skills/education-cloud-student-recruitment-agent-configure/references/flows.md +82 -0
- package/skills/education-cloud-student-recruitment-agent-configure/references/grounding.md +199 -0
- package/skills/education-cloud-student-recruitment-agent-configure/references/permissions.md +183 -0
- package/skills/education-cloud-student-recruitment-agent-configure/references/platform-enablement.md +82 -0
- package/skills/education-cloud-student-recruitment-agent-configure/references/prerequisites.md +158 -0
- package/skills/education-cloud-student-recruitment-agent-configure/references/routing.md +141 -0
- package/skills/experience-cms-brand-apply/SKILL.md +5 -5
- package/skills/experience-cms-brand-create/SKILL.md +2 -2
- package/skills/experience-cms-content-generate/SKILL.md +1 -0
- package/skills/experience-cms-content-render/SKILL.md +173 -0
- package/skills/experience-cms-content-render/assets/angular/DetailPage.component.ts +25 -0
- package/skills/experience-cms-content-render/assets/angular/MediaRenderer.component.ts +133 -0
- package/skills/experience-cms-content-render/assets/angular/TypeList.component.ts +38 -0
- package/skills/experience-cms-content-render/assets/angular/TypeRenderer.component.ts +90 -0
- package/skills/experience-cms-content-render/assets/angular/cms-content.component.ts +248 -0
- package/skills/experience-cms-content-render/assets/angular/cms-item.service.ts +100 -0
- package/skills/experience-cms-content-render/assets/react/DetailPage.tsx +20 -0
- package/skills/experience-cms-content-render/assets/react/MediaRenderer.tsx +129 -0
- package/skills/experience-cms-content-render/assets/react/TypeList.tsx +40 -0
- package/skills/experience-cms-content-render/assets/react/TypeRenderer.tsx +64 -0
- package/skills/experience-cms-content-render/assets/react/heuristicRenderer.tsx +310 -0
- package/skills/experience-cms-content-render/assets/react/useCmsItem.ts +129 -0
- package/skills/experience-cms-content-render/assets/shared/cmsContentType.ts +49 -0
- package/skills/experience-cms-content-render/assets/shared/cmsCore.types.ts +96 -0
- package/skills/experience-cms-content-render/assets/shared/externalRefs.ts +55 -0
- package/skills/experience-cms-content-render/references/bulk-loading.md +60 -0
- package/skills/experience-cms-content-render/references/codegen-guardrails.md +111 -0
- package/skills/experience-cms-content-render/references/detail-pages.md +87 -0
- package/skills/experience-cms-content-render/references/embed-recipes.md +127 -0
- package/skills/experience-cms-content-render/references/failure-modes.md +96 -0
- package/skills/experience-cms-content-render/references/heuristic-render-rules.md +131 -0
- package/skills/experience-cms-content-render/references/init-scaffold.md +122 -0
- package/skills/experience-cms-content-render/references/interaction-model.md +173 -0
- package/skills/experience-cms-content-render/references/package-api.md +106 -0
- package/skills/experience-cms-content-render/references/schema-sync.md +114 -0
- package/skills/experience-cms-content-render/references/styling-scopes.md +65 -0
- package/skills/experience-cms-content-render/references/verify.md +49 -0
- package/skills/experience-cms-content-type-generate/SKILL.md +2 -2
- package/skills/experience-content-media-stock-image-search/SKILL.md +5 -4
- package/skills/experience-search-coordinate/SKILL.md +198 -0
- package/skills/experience-search-coordinate/assets/search-payload-template.json +25 -0
- package/skills/experience-search-coordinate/references/content-route.md +313 -0
- package/skills/experience-search-coordinate/references/content-type-discovery.md +57 -0
- package/skills/experience-search-coordinate/references/media-route.md +172 -0
- package/skills/experience-search-coordinate/references/scope-resolution.md +14 -0
- package/skills/experience-ui-bundle-localize/SKILL.md +1 -1
- package/skills/experience-ui-bundle-localize/references/i18n-setup.md +5 -3
- package/skills/experience-ui-bundle-project-generate/SKILL.md +18 -14
- package/skills/experience-ui-bundle-project-generate/references/angular-project-generate.md +22 -0
- package/skills/experience-ui-bundle-project-generate/references/react-project-generate.md +20 -0
- package/skills/experience-ui-bundle-salesforce-data-access/SKILL.md +58 -54
- package/skills/experience-ui-bundle-salesforce-data-access/references/caching.md +6 -0
- package/skills/experience-ui-bundle-salesforce-data-access/references/graphiti-cli.md +2 -2
- package/skills/experience-ui-bundle-salesforce-data-access/references/migration.md +6 -0
- package/skills/experience-ui-bundle-salesforce-data-access/references/rest-and-integration.md +2 -1
- package/skills/experience-ui-bundle-salesforce-data-access/references/sdk-api.md +6 -0
- package/skills/experience-ui-bundle-site-generate/SKILL.md +59 -8
- package/skills/experience-ui-bundle-site-generate/references/configure-metadata-digital-experience.md +8 -3
- package/skills/experience-ui-bundle-site-generate/references/configure-metadata-language-settings.md +120 -0
- package/skills/life-sciences-fieldsalesrep-coordinate/SKILL.md +336 -0
- package/skills/life-sciences-fieldsalesrep-coordinate/references/orchestration-flow.md +143 -0
- package/skills/life-sciences-fieldsalesrep-coordinate/references/stage-2-starter-config-application-flexipage-mapping.md +127 -0
- package/skills/life-sciences-fieldsalesrep-coordinate/references/stage-2-starter-config-deploy-commands.md +116 -0
- package/skills/life-sciences-fieldsalesrep-coordinate/references/stage-2-starter-config-lifesci-metadata-deploy.md +111 -0
- package/skills/life-sciences-fieldsalesrep-coordinate/references/stage-2-starter-config-overview.md +312 -0
- package/skills/life-sciences-fieldsalesrep-coordinate/references/stage-2-starter-config-profile-layout-assignments.md +171 -0
- package/skills/life-sciences-fieldsalesrep-coordinate/references/stage-2-starter-config-state-tracking.md +64 -0
- package/skills/life-sciences-fieldsalesrep-coordinate/references/stage-2-starter-config-trigger-handlers.md +122 -0
- package/skills/life-sciences-fieldsalesrep-coordinate/references/stage-4-user-provisioning-overview.md +335 -0
- package/skills/life-sciences-fieldsalesrep-coordinate/references/stage-4-user-provisioning-user-provisioning-details.md +140 -0
- package/skills/life-sciences-fieldsalesrep-coordinate/references/stage-5-visit-creation-execution-state-and-recovery.md +196 -0
- package/skills/life-sciences-fieldsalesrep-coordinate/references/stage-5-visit-creation-metadata-cache-generation.md +155 -0
- package/skills/life-sciences-fieldsalesrep-coordinate/references/stage-5-visit-creation-overview.md +307 -0
- package/skills/life-sciences-fieldsalesrep-coordinate/references/stage-5-visit-creation-visit-creation-data.md +211 -0
- package/skills/life-sciences-fieldsalesrep-coordinate/references/state-machine-and-changes.md +108 -0
- package/skills/life-sciences-kam-coordinate/SKILL.md +241 -0
- package/skills/life-sciences-kam-coordinate/references/orchestration-flow.md +152 -0
- package/skills/life-sciences-kam-coordinate/references/stage-2-starter-config-application-flexipage-mapping.md +79 -0
- package/skills/life-sciences-kam-coordinate/references/stage-2-starter-config-deploy-commands.md +131 -0
- package/skills/life-sciences-kam-coordinate/references/stage-2-starter-config-kam-config-records.md +85 -0
- package/skills/life-sciences-kam-coordinate/references/stage-2-starter-config-lifesci-metadata-deploy.md +112 -0
- package/skills/life-sciences-kam-coordinate/references/stage-2-starter-config-overview.md +202 -0
- package/skills/life-sciences-kam-coordinate/references/stage-2-starter-config-profile-layout-assignments.md +67 -0
- package/skills/life-sciences-kam-coordinate/references/stage-2-starter-config-state-tracking.md +65 -0
- package/skills/life-sciences-kam-coordinate/references/stage-2-starter-config-trigger-handlers.md +123 -0
- package/skills/life-sciences-kam-coordinate/references/stage-4-participant-role-and-sprint.md +89 -0
- package/skills/life-sciences-kam-coordinate/references/stage-5-data-and-plan-templates-overview.md +337 -0
- package/skills/life-sciences-kam-coordinate/references/stage-5-data-creation-data.md +248 -0
- package/skills/life-sciences-kam-coordinate/references/stage-6-ipad-validation-script.md +35 -0
- package/skills/life-sciences-kam-coordinate/references/stage-6-metadata-cache-generation.md +155 -0
- package/skills/life-sciences-kam-coordinate/references/stage-6-user-provisioning-details.md +146 -0
- package/skills/life-sciences-kam-coordinate/references/stage-6-user-provisioning-overview.md +89 -0
- package/skills/life-sciences-kam-coordinate/references/state-machine-and-changes.md +114 -0
- package/skills/life-sciences-prerequisites-validate/SKILL.md +138 -0
- package/skills/life-sciences-prerequisites-validate/references/checks-org-settings.md +190 -0
- package/skills/life-sciences-prerequisites-validate/references/checks-user-and-package.md +211 -0
- package/skills/life-sciences-territory-configure/SKILL.md +217 -0
- package/skills/life-sciences-territory-configure/references/territory-metadata.md +262 -0
- package/skills/platform-apex-logs-debug/SKILL.md +7 -7
- package/skills/platform-custom-application-generate/SKILL.md +4 -4
- package/skills/platform-custom-object-generate/SKILL.md +7 -7
- package/skills/platform-custom-tab-generate/SKILL.md +1 -1
- package/skills/platform-dsar-policy-manage/SKILL.md +272 -0
- package/skills/platform-dsar-policy-manage/references/configure.md +106 -0
- package/skills/platform-dsar-policy-manage/references/export-and-history.md +123 -0
- package/skills/platform-dsar-policy-manage/references/gap-analysis-guide.md +150 -0
- package/skills/platform-dsar-policy-manage/references/gap-scan.md +129 -0
- package/skills/platform-dsar-policy-manage/references/headless-sor.md +59 -0
- package/skills/platform-dsar-policy-manage/references/report-format.md +59 -0
- package/skills/platform-dsar-policy-manage/scripts/tests/__init__.py +0 -0
- package/skills/platform-dsar-policy-manage/scripts/tests/test_validate_policy_tree.py +76 -0
- package/skills/platform-dsar-policy-manage/scripts/validate-policy-tree.py +130 -0
- package/skills/platform-flexipage-generate/SKILL.md +4 -0
- package/skills/platform-list-view-generate/SKILL.md +1 -0
- package/skills/platform-salesforce-connect-adapter-generate/SKILL.md +359 -0
- package/skills/platform-salesforce-connect-adapter-generate/references/official-examples.md +69 -0
- package/skills/platform-salesforce-connect-adapter-generate/references/scenarios.md +187 -0
- package/skills/platform-soql-query/SKILL.md +8 -8
- package/skills/platform-value-set-generate/SKILL.md +2 -2
- package/skills/service-itsm-agentic-setup-cmdb-coordinate/SKILL.md +20 -27
- package/skills/service-native-voice-recording-transcription-configure/SKILL.md +47 -27
- package/skills/service-native-voice-recording-transcription-configure/references/thunderbird-voice-settings.md +13 -9
- package/skills/service-native-voice-recording-transcription-configure/scripts/enable-recording-transcription.sh +104 -45
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# Gap-analysis guide prompt — coverage audit for a DsarPolicy
|
|
2
|
+
|
|
3
|
+
> This is the guidance the agent follows when an admin asks *"what personal data are we missing
|
|
4
|
+
> from this policy?"*. It is the script for **Workflow D — Coverage gap analysis**: a **read-only**
|
|
5
|
+
> audit that surfaces **candidate** objects/fields for the admin to disposition — it never
|
|
6
|
+
> classifies data authoritatively, never adds a path on its own, and never activates a policy.
|
|
7
|
+
|
|
8
|
+
## Contents
|
|
9
|
+
|
|
10
|
+
- [What this is and is not](#what-this-is-and-is-not)
|
|
11
|
+
- [The deterministic steps](#the-deterministic-steps)
|
|
12
|
+
- [How fields are flagged as candidate personal data (and why)](#how-fields-are-flagged-as-candidate-personal-data-and-why)
|
|
13
|
+
- [User-facing output (canonical)](#user-facing-output-canonical--use-verbatim-structure)
|
|
14
|
+
- [Guardrails](#guardrails)
|
|
15
|
+
|
|
16
|
+
## What this is and is not
|
|
17
|
+
|
|
18
|
+
The gap analysis answers **"which objects/fields that may hold this subject's personal data are
|
|
19
|
+
not yet covered by the policy?"** It is deliberately **structured and deterministic** — the same
|
|
20
|
+
request produces the same steps and the same transparency, not an open-ended graph walk that
|
|
21
|
+
varies run to run.
|
|
22
|
+
|
|
23
|
+
- **It is:** a read-only audit that (1) states its own method up front, (2) shows exactly which
|
|
24
|
+
objects it looked at, (3) flags **candidate** personal-data fields **with a reason for each**,
|
|
25
|
+
(4) states its search limit, and (5) hands the admin a disposition choice.
|
|
26
|
+
- **It is not:** an authoritative classification of what counts as personal data (that decision is
|
|
27
|
+
the **admin's** — load-bearing call #2), an automatic edit to the policy, or an activation. The
|
|
28
|
+
agent proposes; the admin disposes.
|
|
29
|
+
|
|
30
|
+
## Internal vs. user-facing (read before running)
|
|
31
|
+
|
|
32
|
+
This is the Workflow-D-specific application of **SKILL.md load-bearing call #8 (work silently — never
|
|
33
|
+
narrate the skill's internals)**. Workflow D has two layers; keep them apart in what you *say*:
|
|
34
|
+
|
|
35
|
+
- **Internal — never narrated to the user:** the step numbers and step names below, the `sf`/describe
|
|
36
|
+
mechanics in `gap-scan.md`, and every author-facing note about truncation, event-message limits,
|
|
37
|
+
token cost, or how the audit is "scored." These steer *how you work*; they are not status updates.
|
|
38
|
+
Do not say "running Workflow D, step 2", "describing the root to avoid truncation", or "this keeps
|
|
39
|
+
the run from scoring 0." Just do the work and present the result.
|
|
40
|
+
- **User-facing — the ONLY things the user sees:** the four blocks in
|
|
41
|
+
[User-facing output (canonical — use verbatim structure)](#user-facing-output-canonical--use-verbatim-structure)
|
|
42
|
+
— method preamble, findings, depth offer, disposition. Nothing else.
|
|
43
|
+
|
|
44
|
+
If the environment blocks the scan (feature off / policy unreadable), say so in one plain sentence
|
|
45
|
+
inside the findings block — not by narrating the mechanics that failed.
|
|
46
|
+
|
|
47
|
+
## The deterministic steps
|
|
48
|
+
|
|
49
|
+
Run these in order. Do not skip the method preamble (step 0) — transparency is the point. **These
|
|
50
|
+
step numbers/names are internal scaffolding — do the work, don't announce the scaffolding** (see
|
|
51
|
+
[Internal vs. user-facing](#internal-vs-user-facing-read-before-running)).
|
|
52
|
+
|
|
53
|
+
0. **Open with the plain-language method line.** Before scanning, tell the admin in **plain words**
|
|
54
|
+
how you'll answer and its limits (see the script). This is the one allowed "here's how I'll do
|
|
55
|
+
this" sentence — it must **not** name the workflow ("Workflow D", "coverage-gap audit"), announce
|
|
56
|
+
that you're about to read the guide/mechanics, or cite a rule/tool (call #8). State the approach,
|
|
57
|
+
then start.
|
|
58
|
+
1. **Read current coverage.** Load the policy's existing roots and paths (read-only). These are
|
|
59
|
+
already-covered objects — the audit reports gaps *relative to* this set.
|
|
60
|
+
2. **Enumerate candidate objects — one level only.** For each policy **root** object, describe it
|
|
61
|
+
and list its **immediately related** objects (exactly **one relationship hop** away). This
|
|
62
|
+
depth-1 default is a hard limit that keeps performance and token cost bounded — do **not**
|
|
63
|
+
recurse further without explicit confirmation (step 5).
|
|
64
|
+
3. **Flag candidate fields with reasoning.** On the root and each one-hop object, mark the fields
|
|
65
|
+
that **may** hold the subject's personal data, and record **why** for each (see the flagging
|
|
66
|
+
rubric). Candidates only — never "this *is* PII."
|
|
67
|
+
4. **Report transparently.** Present: the objects you scanned, the candidate fields with the
|
|
68
|
+
per-field reason, the fields already covered vs newly surfaced, and an explicit statement of the
|
|
69
|
+
**one-level search limit**.
|
|
70
|
+
5. **Offer to go deeper — only on explicit confirmation.** Ask whether the admin wants to look
|
|
71
|
+
beyond one level. Warn plainly that going deeper produces **a large volume of output and burns
|
|
72
|
+
significantly more tokens**. Expand only if they say yes, and only by the depth they approve.
|
|
73
|
+
6. **Disposition, don't mutate.** Ask which candidates the admin wants to add. Nothing is added
|
|
74
|
+
automatically. Adding routes to **Workflow A (Configure)**, which authors the change INACTIVE
|
|
75
|
+
and — per the activation rule — **stops for explicit user confirmation before reactivating**.
|
|
76
|
+
|
|
77
|
+
## How fields are flagged as candidate personal data (and why)
|
|
78
|
+
|
|
79
|
+
The reason string is mandatory — every flagged field says *why*. Use these signals, strongest
|
|
80
|
+
first, and name the signal you used:
|
|
81
|
+
|
|
82
|
+
- **Compliance metadata on the field** (e.g. a field's data-sensitivity / compliance-group /
|
|
83
|
+
PII classification from the describe). Reason: *"marked <classification> in field metadata."*
|
|
84
|
+
This is the strongest signal and the least subjective.
|
|
85
|
+
- **Field type semantics** — `email`, `phone`, `address` compound components, `date` used for
|
|
86
|
+
birthdate. Reason: *"<type> field, commonly personal contact/identity data."*
|
|
87
|
+
- **Name/label semantics** — tokens like Name, First/Last, Email, Phone, Mobile, SSN, Passport,
|
|
88
|
+
DOB/Birth, Address/Street/City/Postal, IP, DeviceId, TaxId. Reason: *"name/label suggests
|
|
89
|
+
<category>."*
|
|
90
|
+
- **Already-covered elsewhere** — the same value appears on an already-mapped object. Reason:
|
|
91
|
+
*"duplicate of a field already in the policy; flagged for the admin to decide canonical source."*
|
|
92
|
+
|
|
93
|
+
State the rubric's limits honestly: this is a **heuristic**, not a legal determination. A field
|
|
94
|
+
the rubric misses can still be personal data, and a flagged field may not be — the admin confirms.
|
|
95
|
+
When compliance metadata is absent on the org, say so (the audit leans on name/type semantics only).
|
|
96
|
+
|
|
97
|
+
## User-facing output (canonical — use verbatim structure)
|
|
98
|
+
|
|
99
|
+
**This is the output contract for Workflow D — the four blocks below are the only thing the user
|
|
100
|
+
sees, and their structure is fixed.** Use these four blocks, in this order, with this formatting
|
|
101
|
+
(the blockquote framing and the `Object | Field | Why I flagged it | In policy?` table columns);
|
|
102
|
+
do not improvise a different layout run to run. The *prose wording* may be adapted to the specific
|
|
103
|
+
policy/org, but the **blocks, their order, and the table columns are not optional** — stable
|
|
104
|
+
structure is what keeps the presentation clean instead of randomly formatted. Do not surface any of
|
|
105
|
+
the internal step numbers, mechanics, or scoring/truncation notes here (see
|
|
106
|
+
[Internal vs. user-facing](#internal-vs-user-facing-read-before-running)).
|
|
107
|
+
|
|
108
|
+
**Method preamble (step 0):**
|
|
109
|
+
|
|
110
|
+
> Here's how I can answer this. I'll start from your policy's root objects, look **one level out**
|
|
111
|
+
> at the objects directly related to them, and flag the fields that *might* contain this person's
|
|
112
|
+
> data — and I'll tell you **why** I flagged each one. I won't decide what counts as personal data
|
|
113
|
+
> for you, and I won't change the policy: you'll pick what to add. I stop at one level by default;
|
|
114
|
+
> I can go deeper if you ask, but that gets large and token-heavy, so I'll check with you first.
|
|
115
|
+
|
|
116
|
+
**Findings (step 4):**
|
|
117
|
+
|
|
118
|
+
> **Objects I looked at:** `<root objects>` and their immediately-related objects: `<one-hop list>`.
|
|
119
|
+
> **Already covered by the policy:** `<covered fields>`.
|
|
120
|
+
> **Candidate fields that may hold personal data (not yet covered):**
|
|
121
|
+
> | Object | Field | Why I flagged it | In policy? |
|
|
122
|
+
> |--------|-------|------------------|------------|
|
|
123
|
+
> | Contact | Email | email field, common contact PII | no |
|
|
124
|
+
> | Contact | Birthdate | date used as date of birth (name/type) | no |
|
|
125
|
+
> **Search limit:** I only looked **one level** out from your roots. Deeper relationships are not
|
|
126
|
+
> in this list.
|
|
127
|
+
|
|
128
|
+
**Depth gate (step 5):**
|
|
129
|
+
|
|
130
|
+
> Want me to look **beyond one level**? Heads up: it produces a lot more output and uses
|
|
131
|
+
> considerably more tokens. If yes, tell me how deep (e.g. one more level) and I'll continue.
|
|
132
|
+
|
|
133
|
+
**Disposition (step 6):**
|
|
134
|
+
|
|
135
|
+
> Which of these do you want added to the policy? I'll author the change and leave it **inactive**
|
|
136
|
+
> for your review — I won't reactivate or publish until you confirm.
|
|
137
|
+
|
|
138
|
+
## Guardrails
|
|
139
|
+
|
|
140
|
+
- **Candidates, never verdicts.** Every flag is a suggestion pending the admin's disposition.
|
|
141
|
+
- **Depth 1 by default.** Never recurse past one level without explicit, warned confirmation.
|
|
142
|
+
- **Read-only.** The audit changes nothing; adding is a separate, admin-driven Workflow A step.
|
|
143
|
+
- **No auto-activation.** Any resulting edit stops for explicit user confirmation before
|
|
144
|
+
reactivation/publish (the activation rule).
|
|
145
|
+
- **Transparency is mandatory.** Always report what was scanned, why each field was flagged, and
|
|
146
|
+
the search limit — even when the list is short or empty.
|
|
147
|
+
- **Transparency ≠ narrating internals.** Show *what* you scanned and *why* each field is flagged
|
|
148
|
+
(the findings block). Do **not** narrate *how* — step numbers, describe mechanics, truncation /
|
|
149
|
+
token / scoring notes stay internal. Transparency is about the audit's coverage and reasoning, not
|
|
150
|
+
the skill's plumbing.
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# Coverage gap analysis — mechanics (Workflow D)
|
|
2
|
+
|
|
3
|
+
The mechanics for **Workflow D**. The judgment (read-only, candidates-not-verdicts, depth-1,
|
|
4
|
+
disposition-to-admin) and the user-facing script live in `references/gap-analysis-guide.md`; this
|
|
5
|
+
file is the *how*. Everything here is **read-only** — Workflow D never writes metadata.
|
|
6
|
+
|
|
7
|
+
> **This entire file is INTERNAL — never narrated to the user.** The describe commands, the ~5-object
|
|
8
|
+
> bound, and every note about truncation / event-message limits / token cost / "scored 0" steer *how
|
|
9
|
+
> you work*; they are not status updates. Do the work quietly and present only the four user-facing
|
|
10
|
+
> blocks from `gap-analysis-guide.md`. See its *Internal vs. user-facing* section.
|
|
11
|
+
|
|
12
|
+
## Contents
|
|
13
|
+
|
|
14
|
+
- [1. Read current coverage](#1-read-current-coverage)
|
|
15
|
+
- [2. Enumerate one-hop candidate objects](#2-enumerate-one-hop-candidate-objects)
|
|
16
|
+
- [3. Flag candidate fields (the rubric)](#3-flag-candidate-fields-the-rubric)
|
|
17
|
+
- [4. Diff against the current tree](#4-diff-against-the-current-tree)
|
|
18
|
+
- [5. The depth gate](#5-the-depth-gate)
|
|
19
|
+
- [6. The transparency report shape](#6-the-transparency-report-shape)
|
|
20
|
+
|
|
21
|
+
## 1. Read current coverage
|
|
22
|
+
|
|
23
|
+
Load the policy's existing roots and paths so gaps are reported *relative to* them. On a plain `sf`
|
|
24
|
+
surface the tree is Metadata API:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
sf project retrieve start --metadata DsarPolicy:<PolicyDeveloperName> --target-org <alias>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
On an MCP / SOR surface, read it with the `DsarPolicyManager` `list`/`describe` operation instead.
|
|
31
|
+
Record the set of `{object → [fields]}` already covered — that set is subtracted in step 4.
|
|
32
|
+
|
|
33
|
+
## 2. Enumerate one-hop candidate objects
|
|
34
|
+
|
|
35
|
+
For **each root** object in the policy, describe it once and read two things from the result:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# A full object describe is ~100KB+ of JSON. Do NOT read it raw into the turn — the accumulated
|
|
39
|
+
# describe payloads overflow the agent's event-message size limit and the run TRUNCATES before it
|
|
40
|
+
# writes the report. Always project to just the fields you reason over, so only a few KB enters context:
|
|
41
|
+
sf sobject describe --sobject <RootObject> --target-org <alias> --json \
|
|
42
|
+
| python3 -c 'import json,sys; d=json.load(sys.stdin)["result"]; \
|
|
43
|
+
print(json.dumps({"fields":[{"name":f["name"],"type":f["type"],"label":f["label"]} for f in d["fields"]], \
|
|
44
|
+
"children":[c["childSObject"] for c in d["childRelationships"]][:40]}, indent=1))'
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
- **`fields[]`** — the root's own fields (candidate personal-data fields live here).
|
|
48
|
+
- **one relationship hop out** — the objects directly related to the root:
|
|
49
|
+
- `childRelationships[]` → child objects (e.g. Contact → Cases, Contact → ContactPointEmails);
|
|
50
|
+
- reference/lookup `fields[]` (`type: "reference"`) → parent objects the root points to.
|
|
51
|
+
|
|
52
|
+
**Never read a raw `--json` describe into the turn.** Project every describe (root and one-hop)
|
|
53
|
+
through the field-name/type/label filter above. This is the single most important guard against the
|
|
54
|
+
`Truncated event message received` failure — the describe JSON, not the number of objects, is what
|
|
55
|
+
overruns the stream.
|
|
56
|
+
|
|
57
|
+
Describe each one-hop object once to read *its* `fields[]`. **Stop there.** Do not describe the
|
|
58
|
+
objects *those* relate to — that is level 2, gated behind explicit confirmation (step 5). The
|
|
59
|
+
one-hop rule is what keeps the scan bounded and cheap; it is also the tree-cap discipline (skill
|
|
60
|
+
call #3) applied to discovery.
|
|
61
|
+
|
|
62
|
+
**Hard bound — describe at most ~5 one-hop objects, then stop and report.** A standard root such as
|
|
63
|
+
`Contact` exposes dozens of `childRelationships[]`; describing all of them floods the context and
|
|
64
|
+
the run can truncate before it ever writes the report (a failed audit, not a thorough one). Pick the
|
|
65
|
+
**most privacy-relevant** related objects (contact points, cases/activities carrying supplied
|
|
66
|
+
contact data, the parent account) — describe those few, and **name in the report the related objects
|
|
67
|
+
you did *not* describe** so the omission is transparent, offering them under the depth gate (step 5).
|
|
68
|
+
The root's own describe plus a couple of one-hop objects is enough for a correct, complete audit;
|
|
69
|
+
**describing more than ~5 objects adds no value and risks truncation.**
|
|
70
|
+
|
|
71
|
+
**Policy/type unreadable (the accepted environment path) → stop at the root describe.** If
|
|
72
|
+
`DsarPolicy` can't be read (Metadata/Tooling/Connect all 404 — the feature isn't enabled on this
|
|
73
|
+
org), do **not** fan out to one-hop objects at all: a single **projected** `Contact` describe is
|
|
74
|
+
enough to demonstrate the depth-1 candidate reasoning. Flag the candidate fields on the root, state
|
|
75
|
+
that the policy/type couldn't be read and that you therefore reasoned from the root alone, name the
|
|
76
|
+
one-hop objects you *would* scan next (without describing them), and write the report. Casting wider
|
|
77
|
+
here only adds truncation risk for no benefit — the gap-analysis *method* is what matters, not breadth.
|
|
78
|
+
|
|
79
|
+
**Write incrementally; never let discovery starve the report.** The report file is the deliverable —
|
|
80
|
+
an audit that describes many objects but never writes is a failed, incomplete audit — strictly worse
|
|
81
|
+
than one that scans fewer objects and writes. Create `${outputDir}` and draft the report early, fill it in
|
|
82
|
+
as you describe, and once you have the root + a couple of one-hop objects **write it** — then offer
|
|
83
|
+
more depth, rather than gathering everything first and writing last.
|
|
84
|
+
|
|
85
|
+
## 3. Flag candidate fields (the rubric)
|
|
86
|
+
|
|
87
|
+
On the root and each one-hop object, mark fields that **may** hold the subject's personal data.
|
|
88
|
+
Every flag carries a **reason**; use the strongest available signal and name it:
|
|
89
|
+
|
|
90
|
+
| Signal (strongest first) | How to read it | Reason string |
|
|
91
|
+
|--------------------------|----------------|---------------|
|
|
92
|
+
| Field compliance metadata | describe field's `complianceGroup` / `securityClassification` (when populated) | `marked <value> in field metadata` |
|
|
93
|
+
| Field type | `type` = `email` / `phone` / `address`; `date` used as birthdate | `<type> field, common personal data` |
|
|
94
|
+
| Name / label semantics | tokens: Name, First/Last, Email, Phone, Mobile, SSN, Passport, DOB/Birth, Address/Street/City/Postal, IP, DeviceId, TaxId | `name/label suggests <category>` |
|
|
95
|
+
| Duplicate of a covered value | same value already mapped on another object | `duplicate of a covered field; admin picks canonical source` |
|
|
96
|
+
|
|
97
|
+
**These are candidates, not classifications.** A field the rubric misses can still be personal
|
|
98
|
+
data; a flagged field may not be. The admin confirms (skill call #2). When `complianceGroup` /
|
|
99
|
+
`securityClassification` come back empty on the org, say so — the scan then rests on type and name
|
|
100
|
+
semantics only, which is weaker; state that limitation in the report.
|
|
101
|
+
|
|
102
|
+
## 4. Diff against the current tree
|
|
103
|
+
|
|
104
|
+
Candidate = flagged in step 3 **and not** in the covered set from step 1. Group the result by
|
|
105
|
+
object. Also list, per scanned object, the fields **already** covered — the report shows covered vs
|
|
106
|
+
newly-surfaced side by side so the admin sees what the policy already handles.
|
|
107
|
+
|
|
108
|
+
## 5. The depth gate
|
|
109
|
+
|
|
110
|
+
After presenting the one-hop findings, offer to go deeper — but only expand on **explicit
|
|
111
|
+
confirmation**, and warn first:
|
|
112
|
+
|
|
113
|
+
> Going beyond one level produces a large volume of output and uses considerably more tokens.
|
|
114
|
+
|
|
115
|
+
If the admin confirms, repeat steps 2–4 for exactly the depth they approved (usually one more hop),
|
|
116
|
+
then stop and re-offer. Never recurse unprompted; never "just keep going down the tree."
|
|
117
|
+
|
|
118
|
+
## 6. The transparency report shape
|
|
119
|
+
|
|
120
|
+
The report must make the method and its limits visible (skill call: transparency). Include:
|
|
121
|
+
|
|
122
|
+
- **Objects scanned** — the roots and the one-hop objects, by name (so the admin sees the actual
|
|
123
|
+
surface examined, not just conclusions).
|
|
124
|
+
- **Candidate fields** — a table of `object | field | reason | already in policy?`.
|
|
125
|
+
- **Covered vs surfaced** — what the policy already maps, alongside the new candidates.
|
|
126
|
+
- **Search limit** — an explicit line that only one level was scanned, and the offer to go deeper.
|
|
127
|
+
- **Disposition prompt** — which candidates to add; adding routes to Workflow A (authored INACTIVE,
|
|
128
|
+
no auto-reactivation). Report even when nothing new was found ("no uncovered candidates at one
|
|
129
|
+
level").
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Find the right SOR when a routing tool is in reach (discover → describe → dispatch)
|
|
2
|
+
|
|
3
|
+
**Detect by tool shape, not by host name.** Check the tools available to you this run for a generic
|
|
4
|
+
capability-routing tool exposing **`discover` / `describe` / `dispatch`** verbs. The name may carry a
|
|
5
|
+
host prefix (`mcp__<host>__discover`, a bare `discover`, etc.) — **match the verb shape**. Such tools
|
|
6
|
+
are provided by SOR-routing surfaces (project-codey / Headless 360, Vibes / `vibes-cli`, Tool Factory
|
|
7
|
+
today; treat these as examples — the names change, the verb shape is the stable signal).
|
|
8
|
+
|
|
9
|
+
When one is in reach, the entry move for any DsarPolicy task is to **locate the SOR that covers the
|
|
10
|
+
capability**, then let it route the call. You supply judgment (which SOR, which operation, is the
|
|
11
|
+
request bounded / consented / an export-not-erasure); the SOR supplies the plumbing.
|
|
12
|
+
|
|
13
|
+
## 1. Discover — find the SOR, don't guess its name
|
|
14
|
+
|
|
15
|
+
Search the **capability**, not a guessed identifier:
|
|
16
|
+
|
|
17
|
+
- "manage DSAR / data-subject portability policies"
|
|
18
|
+
- "execute a DSAR policy against a data subject"
|
|
19
|
+
- "DSAR policy run history"
|
|
20
|
+
|
|
21
|
+
The SOR that owns this steel thread is **`DsarPolicyManager`** (owning team **Privacy Center**,
|
|
22
|
+
complexity SIMPLE). Its `agent_description` names DSAR policies + Right-to-Portability and the full
|
|
23
|
+
lifecycle:
|
|
24
|
+
|
|
25
|
+
```text
|
|
26
|
+
getAccessInfo → list policies → save (create / full-tree update) → activate
|
|
27
|
+
→ execute against a dataSubjectId → deactivate → delete
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
`isActive` is the load-bearing gate: **execute** needs ACTIVE; **edit / delete** need INACTIVE.
|
|
31
|
+
|
|
32
|
+
If several SORs surface, pick the one whose `agent_description` names **DSAR + Right-to-Portability**.
|
|
33
|
+
**Reject look-alikes:** data mask, generic consent, or anything framed as subject *erasure* — RTP
|
|
34
|
+
is a portability export, it deletes nothing. If none matches, say so and stop; do not fabricate a
|
|
35
|
+
SOR.
|
|
36
|
+
|
|
37
|
+
## 2. Describe — the contract comes from describe, not memory
|
|
38
|
+
|
|
39
|
+
`describe` the specific operation before calling it. The exact inputs — `policyName` (must match
|
|
40
|
+
`[a-zA-Z]+[a-zA-Z0-9_]*`), `description`, `isActive`, `relatedTrees` (UI-serialized node keys), and
|
|
41
|
+
`dataSubjectId` for execute — come from the operation's schema, not recall.
|
|
42
|
+
|
|
43
|
+
## 3. Dispatch — the SOR routes to the backend
|
|
44
|
+
|
|
45
|
+
`dispatch` the operation. The SOR picks the backend (the DsarPolicy config tree, the RTP execute
|
|
46
|
+
endpoint, the `DsarPolicyLog` read); you never hand-assemble the route.
|
|
47
|
+
|
|
48
|
+
## No routing tool in reach?
|
|
49
|
+
|
|
50
|
+
If no discover/describe/dispatch tool is available this run, fall back to the metadata / Connect /
|
|
51
|
+
SOQL routes in the SKILL.md object-model table. The judgment in the skill is identical either way —
|
|
52
|
+
the skill never changes *what* is correct, only *which tool* executes it.
|
|
53
|
+
|
|
54
|
+
## Related
|
|
55
|
+
|
|
56
|
+
- `../SKILL.md` — the object-model table (the plain-`sf` equivalents) and the three workflows
|
|
57
|
+
- The routing tool's own `discover` verb — "which SORs cover `<capability>`?" is answered by the
|
|
58
|
+
discover/describe verbs described at the top of this file (project-codey / Headless 360), not by a
|
|
59
|
+
separate skill.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Report format — per-workflow report contracts
|
|
2
|
+
|
|
3
|
+
Write the report to `${outputDir}/report.md`, reporting only **the workflow you ran**. The
|
|
4
|
+
length/concision rules (say each load-bearing point once, well under ~150 lines, no exhaustive
|
|
5
|
+
per-object dumps) live in SKILL.md's `## Output` section — they are not repeated here. **This file
|
|
6
|
+
adds only what SKILL.md does not: the per-workflow section contracts below.** The expected-content
|
|
7
|
+
lists are a ceiling, not a checklist to pad toward.
|
|
8
|
+
|
|
9
|
+
## Workflow A (configure)
|
|
10
|
+
|
|
11
|
+
**Bounded request:** (1) the classification strategy — subject, root(s), per-relationship
|
|
12
|
+
follow/stop and why; (2) the tree — roots, paths, fields, with node count vs 200, max depth vs 10,
|
|
13
|
+
max children vs 10; (3) lifecycle — authored INACTIVE, must be activated to run, ACTIVE edits need
|
|
14
|
+
deactivate→edit→then **explicit user-confirmed** reactivation (never auto-reactivated); (4) the
|
|
15
|
+
guardrail — authoring/editing/deleting the policy never deletes the subject's records; (5) deploy
|
|
16
|
+
outcome — deployed, or the raw error + prerequisite.
|
|
17
|
+
|
|
18
|
+
**Unbounded request:** instead state the caps, name the specific cap the request would exceed, and
|
|
19
|
+
offer the bounded alternative (split/prune) — never a silently truncated "complete" map.
|
|
20
|
+
|
|
21
|
+
**Under-specified request:** instead enumerate the classification decisions the admin must make
|
|
22
|
+
(roots; per-relationship follow/stop; fields) and mark any proposal disposition-pending — never an
|
|
23
|
+
authoritative map of guessed personal data.
|
|
24
|
+
|
|
25
|
+
## Workflow B (export)
|
|
26
|
+
|
|
27
|
+
(1) the **resolved subject** — identifier (email/name/id) → root-entity Id + type — and the
|
|
28
|
+
**policy chosen** (noting if it was ambiguous and you asked); (2) consent confirmed, or the run
|
|
29
|
+
withheld as ambiguous; (3) that this was an **export, not a deletion**; (4) the **poll ordering**
|
|
30
|
+
made explicit — a couple of polls, the file retrieved only after the run reaches a terminal state,
|
|
31
|
+
an early not-ready response is expected, and if still non-terminal you **asked** the user before
|
|
32
|
+
continuing (never looped); stated even on the accepted preflight-error path; (5) outcome from the
|
|
33
|
+
**envelope / run status** in plain terms — running / completed / errored — not the HTTP code; (6)
|
|
34
|
+
file location on success (from the `dsr` getfile route, after terminal); (7) any missing
|
|
35
|
+
permission/feature named with the raw error. A non-terminal run is a valid stopping point — report
|
|
36
|
+
it as *still running* and defer to the user, don't diagnose the async backend.
|
|
37
|
+
|
|
38
|
+
**Preflight-error path (feature/policy/subject absent — the run never started):** keep it short.
|
|
39
|
+
Lead with the blocker(s) and the prerequisite to unblock each; state export-not-deletion **once**;
|
|
40
|
+
state the poll-then-download ordering **once** (a single short paragraph — this is item 4, not a
|
|
41
|
+
recurring theme). Do **not** add a separate essay re-explaining "grab it right away," and do **not**
|
|
42
|
+
enumerate every subject-search query — one representative command and the outcome is enough. Two
|
|
43
|
+
blockers → two short entries, not two full-screen tables.
|
|
44
|
+
|
|
45
|
+
## Workflow C (history)
|
|
46
|
+
|
|
47
|
+
The prior runs from the `DsarPolicyLog` SOQL read (or an explicit "no prior runs"), and that **no
|
|
48
|
+
new run was started**.
|
|
49
|
+
|
|
50
|
+
## Workflow D (coverage gap analysis)
|
|
51
|
+
|
|
52
|
+
(1) the **method** stated once up front — from the policy root(s), one relationship hop out,
|
|
53
|
+
candidate fields flagged with a reason each, admin disposes; (2) the **objects scanned** by name
|
|
54
|
+
(roots + the one-hop objects); (3) a **candidate table** — `object | field | reason | in policy?`;
|
|
55
|
+
(4) **covered vs newly surfaced**; (5) the **one-level search limit** stated explicitly, plus the
|
|
56
|
+
offer to go deeper only on confirmation (with the token-cost warning); (6) a **disposition prompt** —
|
|
57
|
+
which to add (adding routes to Workflow A: authored INACTIVE, no auto-reactivation) — and that the
|
|
58
|
+
audit deletes nothing. "No uncovered candidates at one level" is a valid result. Keep the candidate
|
|
59
|
+
table to the roots + one hop; don't append further-hop objects to look thorough.
|
|
File without changes
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"""Unit tests for validate-policy-tree.py.
|
|
2
|
+
|
|
3
|
+
Pure, deterministic cap/name checks on a DsarPolicy tree JSON — unit tested here
|
|
4
|
+
rather than via evals (evals score the LLM-authored artifact against a gold; they
|
|
5
|
+
do not assert the validator's fail-closed behavior).
|
|
6
|
+
|
|
7
|
+
The filename has hyphens, so it is loaded by path via importlib rather than a
|
|
8
|
+
normal import.
|
|
9
|
+
"""
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
import importlib.util
|
|
13
|
+
import pathlib
|
|
14
|
+
import unittest
|
|
15
|
+
|
|
16
|
+
_SCRIPT = pathlib.Path(__file__).resolve().parents[1] / "validate-policy-tree.py"
|
|
17
|
+
_spec = importlib.util.spec_from_file_location("validate_policy_tree", _SCRIPT)
|
|
18
|
+
vpt = importlib.util.module_from_spec(_spec)
|
|
19
|
+
_spec.loader.exec_module(vpt)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _root(name="ContactRoot", **over):
|
|
23
|
+
node = {"developerName": name, "object": "Contact", "fields": ["Email"], "children": []}
|
|
24
|
+
node.update(over)
|
|
25
|
+
return node
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _tree(dev="CustomerPortability", roots=None):
|
|
29
|
+
return {"developerName": dev, "roots": roots if roots is not None else [_root()]}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class NameValidationTests(unittest.TestCase):
|
|
33
|
+
def test_plain_name_ok(self):
|
|
34
|
+
vpt.check_name("ContactRoot", "where") # does not raise
|
|
35
|
+
|
|
36
|
+
def test_trailing_newline_rejected(self):
|
|
37
|
+
# Regression: ^...$ with .match() accepted "Foo\n" because $ matches
|
|
38
|
+
# before a final newline. \A...\Z must reject it.
|
|
39
|
+
with self.assertRaises(vpt.TreeError):
|
|
40
|
+
vpt.check_name("ContactRoot\n", "where")
|
|
41
|
+
|
|
42
|
+
def test_embedded_newline_rejected(self):
|
|
43
|
+
with self.assertRaises(vpt.TreeError):
|
|
44
|
+
vpt.check_name("Contact\nRoot", "where")
|
|
45
|
+
|
|
46
|
+
def test_leading_digit_rejected(self):
|
|
47
|
+
with self.assertRaises(vpt.TreeError):
|
|
48
|
+
vpt.check_name("1Contact", "where")
|
|
49
|
+
|
|
50
|
+
def test_empty_or_nonstring_rejected(self):
|
|
51
|
+
with self.assertRaises(vpt.TreeError):
|
|
52
|
+
vpt.check_name("", "where")
|
|
53
|
+
with self.assertRaises(vpt.TreeError):
|
|
54
|
+
vpt.check_name(None, "where")
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class TreeValidationTests(unittest.TestCase):
|
|
58
|
+
def test_minimal_valid_tree(self):
|
|
59
|
+
self.assertEqual(vpt.validate(_tree()), 1)
|
|
60
|
+
|
|
61
|
+
def test_trailing_newline_devname_fails_end_to_end(self):
|
|
62
|
+
with self.assertRaises(vpt.TreeError):
|
|
63
|
+
vpt.validate(_tree(roots=[_root(name="ContactRoot\n")]))
|
|
64
|
+
|
|
65
|
+
def test_too_many_children_rejected(self):
|
|
66
|
+
kids = [_root(name=f"Child{i}") for i in range(vpt.MAX_CHILDREN + 1)]
|
|
67
|
+
with self.assertRaises(vpt.TreeError):
|
|
68
|
+
vpt.validate(_tree(roots=[_root(children=kids)]))
|
|
69
|
+
|
|
70
|
+
def test_empty_roots_rejected(self):
|
|
71
|
+
with self.assertRaises(vpt.TreeError):
|
|
72
|
+
vpt.validate(_tree(roots=[]))
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
if __name__ == "__main__":
|
|
76
|
+
unittest.main()
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Validate a DsarPolicy tree against the hard caps before authoring metadata.
|
|
3
|
+
|
|
4
|
+
Checks (exits non-zero on the FIRST violation, printing it):
|
|
5
|
+
- children per path <= 10
|
|
6
|
+
- tree depth <= 10 (a root path is depth 1)
|
|
7
|
+
- total nodes <= 200 (roots + every descendant path)
|
|
8
|
+
- every developerName matches [a-zA-Z]+[a-zA-Z0-9_]*
|
|
9
|
+
|
|
10
|
+
Input: a JSON file describing the tree. Shape (see references/configure.md):
|
|
11
|
+
|
|
12
|
+
{
|
|
13
|
+
"developerName": "CustomerPortability",
|
|
14
|
+
"roots": [
|
|
15
|
+
{
|
|
16
|
+
"developerName": "ContactRoot",
|
|
17
|
+
"object": "Contact",
|
|
18
|
+
"fields": ["FirstName", "Email"],
|
|
19
|
+
"children": [
|
|
20
|
+
{ "developerName": "ContactCases", "relationship": "Cases",
|
|
21
|
+
"object": "Case", "fields": ["Subject"], "children": [] }
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
Usage: python3 validate-policy-tree.py <tree.json>
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
import json
|
|
31
|
+
import re
|
|
32
|
+
import sys
|
|
33
|
+
|
|
34
|
+
MAX_CHILDREN = 10
|
|
35
|
+
MAX_DEPTH = 10
|
|
36
|
+
MAX_NODES = 200
|
|
37
|
+
# \A ... \Z (not ^ ... $): $ also matches just before a trailing "\n", so a
|
|
38
|
+
# developerName like "Foo\n" would slip through .match(). \Z anchors the true
|
|
39
|
+
# end of the string and rejects any trailing newline.
|
|
40
|
+
NAME_RE = re.compile(r"\A[a-zA-Z]+[a-zA-Z0-9_]*\Z")
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class TreeError(Exception):
|
|
44
|
+
pass
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def check_name(name, where):
|
|
48
|
+
if not isinstance(name, str) or not name:
|
|
49
|
+
raise TreeError(f"{where}: developerName is missing or not a string")
|
|
50
|
+
if not NAME_RE.match(name):
|
|
51
|
+
raise TreeError(
|
|
52
|
+
f"{where}: developerName {name!r} does not match [a-zA-Z]+[a-zA-Z0-9_]*"
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def walk(node, depth, path):
|
|
57
|
+
"""Return the node count for this subtree; raise on the first violation."""
|
|
58
|
+
where = f"{path}"
|
|
59
|
+
check_name(node.get("developerName"), where)
|
|
60
|
+
|
|
61
|
+
if depth > MAX_DEPTH:
|
|
62
|
+
raise TreeError(
|
|
63
|
+
f"{where}: depth {depth} exceeds the {MAX_DEPTH}-level cap"
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
children = node.get("children") or []
|
|
67
|
+
if not isinstance(children, list):
|
|
68
|
+
raise TreeError(f"{where}: 'children' must be a list")
|
|
69
|
+
if len(children) > MAX_CHILDREN:
|
|
70
|
+
raise TreeError(
|
|
71
|
+
f"{where}: {len(children)} children exceeds the {MAX_CHILDREN}-per-path cap"
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
count = 1
|
|
75
|
+
for i, child in enumerate(children):
|
|
76
|
+
child_name = child.get("developerName", f"[{i}]") if isinstance(child, dict) else f"[{i}]"
|
|
77
|
+
if not isinstance(child, dict):
|
|
78
|
+
raise TreeError(f"{where} > child {i}: not an object")
|
|
79
|
+
count += walk(child, depth + 1, f"{path} > {child_name}")
|
|
80
|
+
return count
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def validate(tree):
|
|
84
|
+
if not isinstance(tree, dict):
|
|
85
|
+
raise TreeError("top-level JSON must be an object")
|
|
86
|
+
check_name(tree.get("developerName"), "DsarPolicy")
|
|
87
|
+
|
|
88
|
+
roots = tree.get("roots")
|
|
89
|
+
if not isinstance(roots, list) or not roots:
|
|
90
|
+
raise TreeError("'roots' must be a non-empty list of root paths")
|
|
91
|
+
|
|
92
|
+
total = 0
|
|
93
|
+
for i, root in enumerate(roots):
|
|
94
|
+
if not isinstance(root, dict):
|
|
95
|
+
raise TreeError(f"roots[{i}]: not an object")
|
|
96
|
+
root_name = root.get("developerName", f"[{i}]")
|
|
97
|
+
total += walk(root, 1, f"{root_name}")
|
|
98
|
+
|
|
99
|
+
if total > MAX_NODES:
|
|
100
|
+
raise TreeError(f"total nodes {total} exceeds the {MAX_NODES}-node cap")
|
|
101
|
+
|
|
102
|
+
return total
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def main(argv):
|
|
106
|
+
if len(argv) != 2:
|
|
107
|
+
print(f"usage: {argv[0]} <tree.json>", file=sys.stderr)
|
|
108
|
+
return 2
|
|
109
|
+
try:
|
|
110
|
+
with open(argv[1], "r", encoding="utf-8") as fh:
|
|
111
|
+
tree = json.load(fh)
|
|
112
|
+
except (OSError, json.JSONDecodeError) as exc:
|
|
113
|
+
print(f"error: cannot read/parse {argv[1]}: {exc}", file=sys.stderr)
|
|
114
|
+
return 2
|
|
115
|
+
|
|
116
|
+
try:
|
|
117
|
+
total = validate(tree)
|
|
118
|
+
except TreeError as exc:
|
|
119
|
+
print(f"INVALID: {exc}", file=sys.stderr)
|
|
120
|
+
return 1
|
|
121
|
+
|
|
122
|
+
print(
|
|
123
|
+
f"OK: tree valid — {total} node(s), within caps "
|
|
124
|
+
f"(<= {MAX_CHILDREN} children/path, depth <= {MAX_DEPTH}, <= {MAX_NODES} nodes)"
|
|
125
|
+
)
|
|
126
|
+
return 0
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
if __name__ == "__main__":
|
|
130
|
+
sys.exit(main(sys.argv))
|