forcedotcom/sf-skills / skills/platform-dsar-policy-manage
platform-dsar-policy-manage
VerifiedSet up, edit, run, and audit a customer's personal-data portability map (DsarPolicy / Right-to-Portability export). Use for choosing subject roots, follow/stop relationships and fields, including requests to figure out what counts as personal data: elicit the admin's classification decisions, never guess. Covers inactive policy authoring/review, subject resolution, ACTIVE-policy export with bounded polling and terminal-only download, history and coverage gaps. This end-to-end workflow can dispatch the DsarPolicyManager setup SOR; loading its generated configuration skill alone does not replace this workflow. Not subject erasure/deletion, sandbox masking or unrelated metadata deployment.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 20.5 KB |
| references/configure.md | markdown | 4.4 KB |
| references/export-and-history.md | markdown | 5.8 KB |
| references/gap-analysis-guide.md | markdown | 9.5 KB |
| references/gap-scan.md | markdown | 8.0 KB |
| references/headless-sor.md | markdown | 3.0 KB |
| references/report-format.md | markdown | 4.2 KB |
| scripts/tests/__init__.py | script | 0 B |
| scripts/tests/test_validate_policy_tree.py | script | 2.6 KB |
| scripts/validate-policy-tree.pyexecutable | script | 3.9 KB |
references/export-and-history.md
View on GitHub# Run an export & read history — reference
Deep detail for **Workflow B** (export) and **Workflow C** (history). Judgment (export-not-erasure,
consent, poll-before-download) lives in `SKILL.md`; this file is the mechanics.
## Resolve the DSR routes at run time
Resolve execute / status / getfile through the routing tool's `describe` and `dispatch` first.
Only when no routing tool is available, obtain the endpoint paths, methods, inputs, and handle
contract from the target release's Connect API documentation or a verified contract supplied by
the user, then discover the org's available API versions via `sf`:
```bash
sf api request rest '/services/data' --target-org <alias> # available API versions
```
Select a returned version supported by that contract; keep route placeholders below until verified.
`/services/data` lists versions, **not DSR routes**. Metadata XML schema assets do not discover
Connect endpoints either. If a route/handle contract cannot be verified, report the missing
capability and stop that operation — do not guess paths, probe by executing exports, or fall back
from an available router. The `DsarPolicyLog` SOQL status/history reads below remain available.
## Resolve the subject (B0) — before anything else
A portability request names the subject by **email / name / external id**, not a `dataSubjectId`.
Resolve it to a record whose entity type is a **ROOT** of the policy you will run
(Account / Contact / Individual / Lead / User). Query the roots for the identifier, e.g.:
```bash
sf data query --target-org <alias> \
--query "SELECT Id, Name, Email FROM Lead WHERE Email = '<subject-email>'"
```
Confirm the match is a **root type of the chosen policy** — execute matches only the root subtree of
the subject's type, so a subject whose type is not a policy root exports nothing. On **0 matches,
multiple matches, or a non-root type**, stop and report — never execute against a guessed Id.
## Pick the policy
If the request names a policy, use it; if not, use the policy established in the working context. If
none is established or **more than one ACTIVE policy could match the subject**, ask the user to
confirm which to run (surface the best match as a confirmation) before executing — never pick
silently.
## Preconditions
- Policy must be **ACTIVE** (INACTIVE cannot execute — route to Workflow A to activate).
- Run guards (name the missing one and stop on `401`/`403`; do not loop):
- user permission `Consent.CAN_EXECUTE_DSAR_POLICY`
- org feature `Consent.hasDsarPortability`
## Execute — capture the handle, trust the envelope
```bash
sf api request rest '<DSR_EXECUTE_ROUTE>' --method POST \
--body '{"policy":"<POLICY_DEVNAME>","subject":"<SUBJECT_IDENTIFIER>"}' \
--target-org <alias>
```
- Capture the **run handle** from the response — you need it for both status and getfile.
- **A failed run can return HTTP 201.** The real outcome is the **status field inside the
envelope**, not the HTTP code. Parse the body; if it reports failure, report failure.
- This is an **export**, not a deletion. It produces a file; it removes nothing. If the request
framed it as erasure, you have already corrected that (SKILL.md call #1) before reaching here.
Example failure envelope on a 201:
```json
{ "status": "FAILED", "message": "…", "runId": "…" } // HTTP 201, but FAILED — report the failure
```
## Poll a couple of times — then ask; download only after terminal
Poll the **same handle** (or `DsarPolicyLog.RequestStatus` for the run) for a terminal status
(`COMPLETED` / `FAILED` or the org's equivalents). Only a terminal-success run has a downloadable
file.
```bash
sf api request rest '<DSR_STATUS_ROUTE_FOR_HANDLE>' --method GET --target-org <alias>
# or, by handle, over the run log:
sf data query --target-org <alias> \
--query "SELECT Id, RequestStatus, CompletionDatetime, DsarError FROM DsarPolicyLog WHERE Id = '<handle>'"
```
Poll a **small, fixed number of times** (≈2–3). If the run is still not terminal, **stop and ask the
user whether to keep polling** — do **not** loop to terminal. A run can sit non-terminal
indefinitely on downstream async processing; **that is platform / Tool Factory territory, not this
skill's to diagnose or reach into** (don't go hunting message-queue internals). Report the status in
plain terms — **running / completed / errored** — from the run row; the user does not need to know
which internal entity or queue backs it.
**Do not quote a completion time (e.g. "~1s") — even if a data source suggests one.** Runtime
varies by org provisioning; poll to terminal or hand off the handle. Never promise a duration.
An early *getfile* returns `NOT_FOUND` / `"This file isn't ready yet"`. **That is the contract
working, not a failure** — poll again; do not treat it as a completed or errored run.
## Download the export file — segment is `dsr`
Only after terminal-success:
```bash
sf api request rest '<DSR_GETFILE_ROUTE_FOR_HANDLE>' --method GET --target-org <alias>
```
- The getfile path segment is **`dsr`**, not `dsar`. A `dsar` segment 404s. Double-check the
segment before concluding the file is missing.
- Report where the export landed.
## Workflow C — history is a SOQL read
Run history lives in `DsarPolicyLog`, a standard object. Read it with SOQL — it is **not** an
`installListView` call, not a UI list, and it **never** starts a run.
```bash
sf data query --target-org <alias> \
--query "SELECT Id, DsarPolicyId, RequestStatus, CreatedDate, CompletionDatetime \
FROM DsarPolicyLog \
WHERE DsarPolicyId = '<POLICY_ID>' \
ORDER BY CreatedDate DESC"
```
- Report each prior run (when it ran, its status). "No prior runs" is a valid, correct result.
- If `DsarPolicyLog` is absent or the query returns `401`/`403`/`404`, surface the raw error and
name the prerequisite — an accepted terminal outcome. Do not fall back to executing the policy.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |