A data-access policy is code that runs on every query. It decides what a fraud analyst sees in the morning, what an AI agent gets back at midnight, and which statements never reach the database. Yet in many organisations it lives as settings clicked into a console, changed by whoever has the admin password, with no record of who changed what or what the change did. InsightAIShield treats policy the way an engineering team treats code: a versioned document you can read, diff, test against real traffic and release with a second reviewer. This post walks through that cycle on a real change.

In short

  • A policy is a YAML document. Who it applies to, which sources, enforce or monitor, its grants and its rules, from a catalogue of 19 rule types. Export it, keep it in your repository, import it back.
  • Versions, never edits. Draft, proposed, active, retired. An active version is never changed in place; a change is a new version with a diff.
  • Test before you ship. The simulator decides one query as a chosen person; proposing a version replays it over the last 7 days of recorded activity and keeps the result on the version.
  • Four eyes to activate. A lead who neither wrote nor proposed a version approves it. Until then it changes nothing.

What a policy document says

Every policy answers the same five questions, in the same order, so that a reviewer reading one for the first time knows where to look. Who: groups, named users or kinds of principal (humans, services, AI agents), or everyone. Where: the sources it covers. How: enforce, or monitor (effects recorded, never applied). What is allowed: grants of read or write on a location, store or field. On what terms: the rules.

# cardholder data on the cards platform and the lake (abridged)
code: pci_cardholder_data
applies_to: {groups: [cards-ops, fraud-analysts, etl, dba]}
sources: [cards_mysql, lake]
mode: enforce
grants:
  - {scope: location, target: cards_mysql, permissions: [read]}
  - {scope: location, target: lake, permissions: [read]}
rules:
  - {type: MASK, target: "class:card_number", params: {type: keep_last, keep: 4, char: "*"}}
  - {type: BLOCK_FIELD, target: "class:card_cvv"}
  - {type: SQL_COMMAND, target: cards_mysql, params: {deny: [DELETE, DROP, TRUNCATE, UPDATE, ALTER]}}
  - {type: DISALLOW_JOIN, target: cards_mysql.cards.card, params: {with: [cards_mysql.cards.dispute]}}

Targets are globs over source.schema.table.column, or a data class such as class:card_number, so one rule follows every column the classifier labels.

The rule catalogue covers the three levels the engine evaluates. At any level: location, IP range, time window, tag and property conditions. On a table: denied or allowed commands, forbidden joins, joins of two sensitive stores, row filters and row limits. On a column: masks, redaction, value skips, field filters, tokenizing, one-way hashing and blocking. Writing class:card_number rather than a list of column names means that when discovery finds a new card-number column next month, the policy already covers it.

The Cardholder data policy (pci_cardholder_data) in InsightAIShield: version 1 active, written and proposed by jordan.ellis and approved by sam.rivera; grants of read on cards_mysql and lake; rules r1 MASK class:card_number, r2 BLOCK_FIELD class:card_cvv, r3 SQL_COMMAND on cards_mysql, r4 DISALLOW_JOIN cards_mysql.cards.card with cards_mysql.cards.dispute.
Demo data The same document as the product shows it: who wrote it, who proposed it, who approved it, its hash, its grants and its rules.

The life of a version

a different lead approves

rejected with a note

a newer version activates

change = new draft

Draft
written or imported

Proposed
replayed on 7 days

Active
enforced or monitored

Rejected

Retired

An active version is never edited. Every change is a new draft with its own diff, replay and approval.

Each version carries a SHA-256 of its document, the person who wrote it, who proposed it and who approved it, with the times. When a new version activates, the previous one is retired, not deleted, so the activity records that cite core_customer_pii v1 still point at the exact rules that decided them.

A change, reviewed like code

Northmere Bank, the fictional bank in the demo, has a warehouse policy that masks phone numbers for analysts. The analytics team wants to join on phone numbers across tables, which a mask breaks. Avery Brooks drafts version 2 of warehouse_analytics: phones tokenized instead of masked, so the same number always gets the same token and joins still work. The Diff tab shows exactly what changed:

The Diff tab of the Warehouse analytics policy, v1 against v2: the description line changed to say phones are tokenized instead of masked, rule r3 (MASK class:phone, type right, length 4) removed, and a summary: 0 rules added, 1 rule removed, 1 rule changed, 0 grants added or removed.
Demo data A unified YAML diff beside a structural one: rules added, removed and changed, and grants added or removed.

The structural summary on the right matters as much as the text. A reviewer can see at a glance that no grant was added (the change narrows nothing and widens nothing about who may read the warehouse), and that the only material change is how one data class is protected.

Testing a policy before anyone feels it

Two tools answer “what will this do?”, at two scales.

The simulator answers it for one query. Pick a source, pick who runs it (a person, a service or an AI agent), optionally a client address, paste the SQL, and optionally switch on the pending draft. The engine returns the decision, the SQL that would run and every reason. Nothing is recorded and nothing is executed. It is the quickest way to answer a colleague’s “will my report still work?”.

The replay answers it for the estate. When a draft is proposed, the engine takes the recorded queries from the last 7 days and re-decides each one twice, once with the active versions and once with the draft in place. The result, kept on the version, lists how many queries would change and how (allowed to masked, masked to blocked and so on), with examples of each.

QuestionToolWhat it shows
Will this one query still work for this person?SimulatorDecision, rewritten SQL, every reason
What does the draft do to last week’s traffic?Replay (on propose)Queries changed, by kind of change, with examples
What would a monitor-mode policy have blocked?Activity, filtered“Would block” events with their reasons
What exactly changed between versions?DiffUnified YAML diff and the structural summary

From a sentence to a draft

Not every policy change starts with someone who writes YAML. A data owner may simply say what they want. The policy author agent turns a plain-English request into a draft using the estate’s own vocabulary: its sources, its groups and its data classes. Words it can’t match become open questions rather than guesses.

Describe a policy in plain English: the request Mask email addresses on warehouse for everyone except the fraud-analysts group, the drafted YAML (applies to all, source warehouse, MASK class:email with fraud-analysts exempt), what it understood, and the simulation on recent activity: 200 queries from the last 7 days re-decided, 0 queries would change, with a Create it as a draft button.
Demo data The agent’s draft, what it understood, and the replay. The person decides whether to create the draft.

In this example the replay over 200 recorded queries found that none would change: the warehouse policy already masks email for analysts, so the request adds protection only for principals who don’t query the warehouse today. That is a useful finding in itself. A reviewer can approve it as a safeguard, knowing it disrupts nobody, or reject it as redundant. Either way the decision is made on evidence, not on a guess about who might be affected.

Four eyes, enforced by the product

A policy change can widen access to sensitive data as easily as it narrows it, so activation is a two-person act. The rule is simple and the product enforces it: the lead who approves a version must be neither its author nor its proposer.

Card exports in the batch window only (cards_export_window): version 1 proposed, waiting for a second approver, with the note Four eyes: a lead who neither wrote nor proposed this version approves it; a TIMED_ACCESS rule on cards_mysql.cards.card between 01:00 and 03:00 New York time and a LIMIT rule.
Demo data A proposed version waits for a second lead. The approve button refuses the author and the proposer.

On Northmere’s estate, cards_export_window restricts bulk card exports to a nightly batch window. Jordan Ellis wrote and proposed it, so when Jordan presses Approve and activate the product refuses. When Sam Rivera, another lead, approves it, it goes live and the decision record keeps both names. The same rule covers policies drafted by the agent: an agent can prepare, never approve.

Keeping policy in your repository

Because the document is YAML on the wire, the policies page exports every policy as YAML and imports YAML back, one document or many. An import never activates anything: each document becomes a new draft (or a new policy), and then goes through the same replay and approval. That lets a team keep policies in the same repository as the rest of its infrastructure, review changes in pull requests, and still have the product’s replay and four-eyes approval between a merge and enforcement.

A policy change, end to endNorthmere’s routine for a warehouse change
1
Write or import the draftYAML / policy author

A new version of an existing policy, or a new policy. Parsed with a safe loader and validated against the rule catalogue.

2
Check single queriessimulator

The reports and agents most likely to be affected, run as their real principals, with the draft switched on.

3
Proposereplay

The engine replays the last 7 days and keeps the result on the version.

4
Review the diff and the replaysecond lead

What changed, what it does to real traffic, whether any grant widened.

5
Approve or rejectfour eyes

A lead who neither wrote nor proposed it. Approval activates it and retires the previous version.

Who gets a policy: identity mappings

Policies name groups; your directory decides who is in them. Identity mappings bring a policy to whoever matches a directory condition, from LDAP group membership or OIDC attributes. On Northmere, everyone whose LDAP memberOf contains fraud-analysts gets the warehouse policy, and anyone whose OIDC department is Compliance gets the customer-data policy. A person who matches no mapping and no group gets no policy, and the engine, which fails closed, gives them no data.

Read it, diff it, test it, approve it.

A policy that runs on every query should be reviewable like any other code that runs in production. Versions, diffs, the simulator, the replay and a second approver turn a policy change from a console setting into a change with evidence behind it.

Where people stay in charge

  • The policy author agent drafts; it never activates. A person creates the draft from what it prepared, proposes it, and a different lead approves it.
  • Every agent action is capped at L2, “ask first”: an agent prepares, and a person confirms, activates, revokes, sends or decides.
  • A policy version goes live only when a second lead, not the person who proposed it, approves it.
  • A revocation is proposed by one reviewer and approved by another; the REVOKE statement is kept on the record for your DBA to run.
  • Detokenizing needs a stated purpose, is recorded, and is capped per person per period.
  • SIEM batches and attestation requests are held until a person releases them.

Keep reading