Gdpr gate

From jikig-ai/soleur · View interactive version

Gdpr gate is an AI agent skill from the GitHub repository jikig-ai/soleur. This skill should be used when auditing diffs or plans for GDPR/CCPA/HIPAA compliance gaps.

How to use this skill

Skill file

<!-- soleur-cloud-mode:start -->

Cloud Mode (Devin): before pipeline work run bash "${CLAUDE_PLUGIN_ROOT}/scripts/cloud-detect.sh". If CLAUDE_PLUGIN_ROOT is unset (cloud exec shells do not export it), resolve the root by IDENTITY, never by script basename: for d in "$HOME/.local/share/devin/cli/plugins/cache" and /opt/.devin/plugins, skip unless [ -d "$d" ], then MANIFEST="$(find "$d" -path '*/.claude-plugin/plugin.json' -exec grep -l '"name"[[:space:]]*:[[:space:]]*"soleur"' {} + 2>/dev/null | head -1)", ROOT="${MANIFEST%/.claude-plugin/plugin.json}" — one resolution, two consumers: $ROOT/scripts/cloud-detect.sh and $ROOT/scripts/precommit-guard.sh. (Shape check, not authentication: a planted {"name":"soleur"} dir passes — ADR-179 A11.) local or not-local:no-devin-env proceeds normally; any other not-local:<reason> applies <plugin-root>/devin/INSTRUCTIONS.md §Cloud Mode: emit the --banner, fan out sequentially with Reviewed-Coverage: sequential-fallback disclosure (never claim an independent review ran), message_user ack before any secrets read or production mutation, and run precommit-guard.sh before any git commit — hooks do not fire in cloud.

<!-- soleur-cloud-mode:end -->

<!-- grok-harness-invoke:start -->

Grok Build (plugins/soleur/lib/harness.ts invokeSkill()): Read this SKILL.md in this process and run it to completion. A one-segment soleur:<name> in this document names a SKILL — on Grok Build, Read plugins/soleur/skills/<name>/SKILL.md in this process; it is not a nested tool_use. A multi-segment id such as soleur:<domain>:<name> names an AGENT: spawn it, never Read it, and on Grok Build spawn_subagent takes the id with its colons replaced by hyphens (agentIdToGrokSubagentType). Claude Code: Skill tool for a skill (soleur:<name>), Task tool with subagent_type for an agent. Forbidden is executing a subset, not the Read.

<!-- grok-harness-invoke:end -->

GDPR / CCPA / HIPAA pre-generation gate

gdpr-gate is an advisory code-level gate that fires inline during soleur:plan Phase 2.7 and at soleur:work Phase 2 exit. It scans plan prose, schema migrations, and diffs for regulated-data gaps under GDPR (Articles 5/6/9/17/20/25/30/32/33/35), with secondary coverage for CCPA / CPRA and HIPAA. It never blocks. Critical findings (Article 9 special-category data) prompt operator acknowledgment + GitHub issue creation; the gate never auto-writes to compliance-posture.md.

This is not legal review. Output is a heuristic, machine-generated checklist meant to compress regulator-shaped surprises out of the normal feature-design loop. Consult the soleur:legal:clo agent and soleur:legal:legal-compliance-auditor before merging anything load-bearing.

When to invoke

The gate is read-only with respect to the canonical soleur:plan template. It audits the plan; it never injects its own checklist into the plan body. Architectural invariant per ADR-026.

Disclaimer (always first)

Every gate output begins, as the first non-blank line, with the literal:

**This is not legal review. Findings are heuristic. Consult `soleur:legal:clo` + `soleur:legal:legal-compliance-auditor` before merging.**

The disclaimer is hardcoded. A test in plugins/soleur/test/gdpr-gate.test.ts asserts the literal appears as the first non-blank line of every fixture output.

--repo-scan mode

soleur:gdpr-gate --repo-scan runs the gate against the whole working tree. Operator-initiated only — never auto-fires from soleur:plan, soleur:work, or lefthook. Token budget remains ≤4k per Haiku call (ADR-026 TR3) via 25-files-per-batch fan-out.

Sole-arg sentinel. When invoked with $ARGUMENTS, trim leading/trailing whitespace (including \t and \n). If the trimmed value equals exactly --repo-scan (no spaces, no quotes, no additional tokens), enter repo-scan mode. Any other value — including --repo-scan apps/web-platform, repo scan, or "--repo-scan section of the repo" — falls through to the v1 scope-string mode and is forwarded verbatim to the prompt.

File source. git ls-files -c -o --exclude-standard (cached + untracked, respecting .gitignore). Submodules excluded; symlinks not followed. Pre-filtered through the canonical regex (see ## Path globs (canonical) below) so only regulated-data paths enter the candidate pool.

Deny-list (D1). Single source of truth: scripts/path-denylist.txt. Line-oriented file with extended-regex patterns (one per line; # for comments). Bash [[ =~ ]] semantics. Any candidate path matching at least one deny-list pattern is excluded from the scan corpus and a # blocked: <path> line is emitted to stderr (audit trail).

Allow-list bypass (D3). GDPR_GATE_REPO_SCAN_ALLOW_PATHS=path1:path2:... — colon-separated literal paths (no globs accepted; bash strict equality after split). Default unset → all deny-list patterns enforced. Each entry must satisfy two clauses or the script exits 1: (1) the path must match at least one deny pattern (otherwise the bypass is meaningless), and (2) the path must exist in git ls-files -c -o --exclude-standard (otherwise the operator probably typo'd the path; see Sharp edges).

CI refusal (D3). If both $CI and $GDPR_GATE_REPO_SCAN_ALLOW_PATHS are set, the script exits 1 with allow-list bypass refused in CI environment. Operator-only by construction — runbooks that set the bypass var get caught at the script boundary, not by docs alone.

Batching. 25 files per Haiku call. The dispatching agent collects per-batch outputs, dedups by (check_id, path, line), and summarises inline.

Inline-only output (D4). Findings emitted to stdout / conversation only. The repo-scan walker NEVER writes to compliance-posture.md, __goldens__/, test/fixtures/, or any disk path under ~/.claude/. The v1 critical-finding flow (operator-acknowledged write to compliance-posture.md Active Items + GitHub compliance/critical label) still applies for Art. 9 column-name matches discovered during repo-scan.

Schema-only invariant (D5). The repo-scan prompt template inherits v1's DO NOT INCLUDE COLUMN VALUES directive verbatim. The directive is the load-bearing assertion in plugins/soleur/test/gdpr-gate.test.ts.

Canonical-regex source-of-truth. scripts/repo-scan.sh extracts the canonical regex from this file's ## Path globs (canonical) heading via awk at runtime — it does NOT redefine the regex. Editors of SKILL.md must keep that heading and the first fenced regex line stable; if extraction fails the script exits 1 with canonical regex not found in SKILL.md. Asserted by AC-PARITY-1 and gdpr-gate-repo-scan.test.ts.

Path globs (canonical)

The single source of truth for "what counts as a regulated-data path" is the regex below. lefthook.yml mirrors it verbatim; plugins/soleur/skills/review/scripts/fix-round-seats.sh GDPR_PATH_RE mirrors it byte-identically (pinned by plugins/soleur/test/review-tier-parity.test.ts); the skill's prompt template references it; AGENTS.md hr-gdpr-gate-on-regulated-data-surfaces cites it.

^(apps/web-platform/supabase/migrations/|apps/web-platform/lib/auth/|apps/web-platform/server/.*auth.*\.(ts|tsx|js)|apps/web-platform/app/api/.*\.(ts|tsx)$|.*\.sql$)

Each component matches at least one file in the current repo (verified at plan time, 2026-05-10). forms/** and **/*.prisma from earlier drafts are dropped — both matched zero paths in this repo and a glob that matches nothing is a workflow violation per hr-when-a-plan-specifies-relative-paths-e-g.

5 mandatory v1 checks (FR4)

Each check has a stable check_id for cross-referencing in compliance-posture.md and GitHub issue labels.

| check_id | Article | Trigger | Default severity |

|---|---|---|---|

| GDPR-Art-6 | Art. 6 lawful basis | New schema column without -- LAWFUL_BASIS: <basis> annotation | Important |

| GDPR-Art-5e | Art. 5(1)(e) retention | New PII table without retention metadata | Important |

| GDPR-Art-17 | Art. 17 erasure | New FK to users without ON DELETE CASCADE or anonymisation migration | Important |

| GDPR-Art-17-caller | Art. 17 erasure (caller-site) | Diff adds an ON DELETE RESTRICT FK to public.users AND an anonymise_* RPC, AND git grep -n '<rpc_name>' returns zero matches outside supabase/migrations/, knowledge-base/, and plan files | Important (see [[2026-05-16-migration-mandates-must-have-wired-call-sites-in-same-pr]]) |

| GDPR-Chapter-V | Art. 44–49 cross-border | New non-EEA vendor env var / SDK without compliance-posture.md Vendor DPA row | Important |

| GDPR-Art-9 | Art. 9 special-category | New column matching the Art. 9 list in fields.md | Critical |

Critical is reserved for Art. 9 column-name matches in v1. Demoting the other four to Important keeps the noise floor low and preserves compliance/critical issue labels as a load-bearing signal. See non-negotiables.md for the regulatory rationale.

Reference layers:

Active layers (with check_id markers):

Reference catalogues (no check_id markers — consulted by other layers):

The 5 mandatory v1 checks (FR4 above) fire on every gate invocation. --repo-scan (see ## --repo-scan mode above) additionally fires every layer-id check across all 7 active layers.

Output format

Each finding follows this schema:

**This is not legal review. Findings are heuristic. Consult `soleur:legal:clo` + `soleur:legal:legal-compliance-auditor` before merging.**

### `<check_id>` — <one-line title>

**Severity:** <Critical | Important | Suggestion>
**Article:** <regulation citation>
**Location:** <file path:line range, or "plan section <header>">
**Pattern matched:** <verbatim regex/keyword that fired>
**Why this matters:** <one short paragraph>
**What to do:** <concrete next action — annotate, add migration, file vendor DPA row, etc.>

Severity levels:

Critical-finding escalation flow (FR5)

When a Critical finding fires, the gate emits this block at the end of the report:

─────────────────────────────────────────────────────────────────
CRITICAL FINDING — operator acknowledgment required
─────────────────────────────────────────────────────────────────

A `Critical` finding (`check_id: GDPR-Art-9`) requires an Active Items row in
`knowledge-base/legal/compliance-posture.md`. The gate does NOT auto-write the
row.

Run, in order:

  1. gh issue create \
       --title "<title summarising the finding>" \
       --label compliance/critical,domain/legal \
       --body "<finding text + link to PR>"

  2. Edit knowledge-base/legal/compliance-posture.md and append a row to the
     Active Compliance Items table. The canonical schema is:

       | Item                 | Issue     | Status | Deadline | Notes                              |
       | <one-line summary>   | #<issue>  | OPEN   | -        | <check_id>; <date>; <context>      |

     `<check_id>` is the gdpr-gate finding identifier (e.g., GDPR-Art-9). Date
     and remediation context belong in Notes — the table itself uses 5 fixed
     columns.

  3. git add knowledge-base/legal/compliance-posture.md
     git commit -m "compliance: register Art. 9 finding for #<issue>"

The gate exits after printing this block. It never modifies disk for you.

This flow is operator-driven by design — the gate is read-only against compliance-posture.md. Auto-writing would silently aggregate compliance gaps into a single repo file, defeating the human-accountability rationale (CLO assessment).

Prompt template — what the gate sends to the model

The gate's reasoning step receives the following system prompt structure. The schema-only invariant is DO NOT INCLUDE COLUMN VALUES — the gate sends column NAMES only, never row values.

You are gdpr-gate, an advisory compliance auditor.

Your input is:
1. A diff or plan excerpt (no row values).
2. The list of regulated-data paths (per the canonical regex above).
3. The five v1 check definitions below.

DO NOT INCLUDE COLUMN VALUES in the response. Send column NAMES only —
schema-shape data, never live row payload. The user's PII is the subject of
the audit; sending values would be a Chapter V transfer of the very data we
are auditing.

For each check:
  - Identify pattern matches.
  - Emit a finding using the Output format above.
  - Reserve `Critical` for Art. 9 column-name matches.

The DO NOT INCLUDE COLUMN VALUES directive is a verbatim string assertion in plugins/soleur/test/gdpr-gate.test.ts — moving or paraphrasing it breaks the test by design.

First-run on existing codebase

Existing migrations 001–040 in this repo do NOT use -- LAWFUL_BASIS: <basis> annotations. A backfill audit will fire Important (GDPR-Art-6) findings on every column that lacks one. This is intentional — backfill audits surface existing gaps, and the demotion of Art. 6 to Important keeps the noise from training operators to dismiss Critical. Operators may suppress backfill noise by scoping the gate to a specific diff (soleur:gdpr-gate "git diff main...HEAD") rather than a full repo scan.

Future severity changes

Findings carry a stable severity per the FR4 table. If a future version introduces a new severity (e.g., Blocking), three consumer patterns must be grepped per cq-union-widening-grep-three-patterns:

Add new severities in this file's table FIRST, then run the three greps before writing implementation.

Boundary with sibling agents

Canonical disambiguation prose lives in plugins/soleur/skills/review/SKILL.md §boundaries.

Corpus freshness

The detection rules this gate uses are partly lifted from upstream

gosprinto/compliance-skills and pinned in NOTICE. last-verified

records the last time the pinned corpus was compared against upstream.

advisory and the gate still exits 0, but a "no findings" result may be based

on rules that predate a recently-patched detection pattern.

section.

Both thresholds are stable design parameters, not settings: they are not

relaxable without a published ADR.

last-verified is advanced by Soleur's weekly content-vendor-drift cron, and

only on a run that itself compared the complete upstream-derived registry and

found it clean against a healthy upstream. The conjuncts are stated canonically

in the content-vendoring policy (§6a) rather than restated here, because

restating them is how the two copies came to disagree. Two consequences are

worth having on this page:

carry their own pins and are checked at commit time, not by the attestation.

moves in steps of roughly three weeks rather than weekly.

A missing NOTICE, an unparseable date, or a future date all resolve to 999

days, which fires both banners; that is the fail-safe direction.

Do not edit last-verified by hand. An earlier version of this section

suggested exactly that, which is the one action the governing ADR (ADR-203)

explicitly rejects: a hand-written value asserts a comparison that no artifact

records, and on an installed plugin it is overwritten by the next update

anyway. If the banner is firing on an installed plugin, the corpus is refreshed

upstream and the fix is to update the plugin.

POSTURE_FAIL operator chain

If you are running an installed copy of this plugin (you are not developing

Soleur itself), the short version is: the gate is advisory, it exits 0, and it

is telling you the detection corpus shipped with your copy is old. Nothing in

your repository is wrong and there is no action to take in it. Update the

plugin to pick up a refreshed corpus. The numbered chain below is for

contributors working in the Soleur repository — its steps reference registers

and internal endpoints that only exist there.

In the Soleur repository, when the gate emits a POSTURE_FAIL: line:

  1. Do not pause the current PR. The gate is advisory and exits 0. The

staleness signal is a separate work cycle from whatever diff triggered it.

  1. Open a tracking issue labelled compliance/critical, titled

[gdpr-gate] >90d stale rules — N days since last-verified.

  1. Append a row to the compliance posture register's Active Compliance Items,

per that document's row schema. The gate never writes there itself: this is

an operator-acknowledged write only.

  1. Commit the row with compliance: register vendor-pin-staleness for #<issue>.
  2. Drive a re-vendor: ping the in-flight ci/content-vendor-drift-* PR if one

is open, or dispatch the cron manually via soleur:trigger-cron with

cron/content-vendor-drift.manual-trigger. gh workflow run cannot reach

it — the job is an Inngest cron, not a GitHub Actions workflow.

Print the dispatch as the active harness's operator-typed form per formatSkillInvocation

(plugins/soleur/lib/harness.ts); the operator types it, no agent reads it.

The regulated-data PR that surfaced the banner can ship; the staleness

follow-up gets its own review and merge.

Sharp edges

gdpr-gate: path scan complete — N examined, M matched to stdout on every

invocation, unconditionally and after the match loop. It exists because

"the scan ran and matched nothing" and "the scan never ran" were previously

byte-identical — both produced no output at all — so on a stale corpus the

gate printed two banners about its rule set and no evidence that any diff had

been examined. It carries counts only, never path names: this line

reaches a customer's terminal, and path structure is third-party-content

adjacent (hr-third-party-content-grep-on-undertaking). The stderr

breadcrumb still names paths for the local operator. The line deliberately

contains neither days stale nor POSTURE_FAIL, so the evidence that a scan

occurred is independent of the corpus's age.

gdpr-gate-advisory glob in lefthook.yml stops matching, lefthook prints

(skip), this script never executes, and no line of any kind is emitted —

every in-script assertion stays green. That half is covered from outside by

gdpr-gate-glob-liveness.test.sh,

which drives the real lefthook binary over the real lefthook.yml with a

regulated path staged. This repo has shipped the dead-glob trap twice; gobwas

** matches 1+ intermediate directories, never 0+.

subtree**, because lefthook's gobwas * crosses /. Measured on lefthook

2.1.6: refs/*.md matches both depth-1 and depth-2; refs/**/*.md matches

depth-2 only (that is the ** behaviour the repo's 2026-03-21 gobwas

learning describes, and it does not generalise to *). So the layers/

entry is redundant, and no per-subdirectory entry is needed. The

symmetric-difference walk in

vendor-pin-integrity.test.sh is

still the backstop for registry membership — it reads the disk, not the

glob — but it is not compensating for a coverage hole, because there is

none.

lifted-files (upstream-derived, MIT, pinned against goSprinto) and

soleur-authored (written for this plugin, no upstream). Both are

tamper-checked by local-blob-sha; only the former appears in

upstream-files. A file must appear in exactly one, and the attribution

header on line 1 is the oracle for which. Moving a file between them is a

provenance falsification, not a bookkeeping change.

1. Active processing for an undisclosed special-category purpose — production code currently writes or reads the column for a purpose not disclosed in the privacy notice. Fix is disclosure-side (privacy notice + DPIA + Art. 6/9 lawful-basis annotation) plus, if no Art. 9(2) lawful basis applies, halting processing.

2. Backfill with new special-category data — schema is old but the data is new (placeholder/test rows replaced with real PII). This is operationally a new processing activity; Art. 35 DPIA may itself trigger.

3. Cross-border transfer post-Schrems II — the column is replicated to a non-EEA processor (analytics, support, vendor) without Chapter V safeguards (DPA + SCCs + transfer impact assessment). Disclosure cure is insufficient — fix the Chapter V gap.

4. CCPA / CPRA "sensitive personal information" overlay — California's SPI definition (Cal. Civ. Code §1798.140(ae)) overlaps but is not identical to Art. 9. A column that is Art. 9 in EU may also be SPI in California; the disposition must include a CCPA-side disclosure check, not just a GDPR-side one.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.