bricksentry 0.1.26__tar.gz → 0.1.28__tar.gz

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.
Files changed (95) hide show
  1. {bricksentry-0.1.26 → bricksentry-0.1.28}/CHANGELOG.md +24 -0
  2. {bricksentry-0.1.26 → bricksentry-0.1.28}/PKG-INFO +35 -4
  3. {bricksentry-0.1.26 → bricksentry-0.1.28}/README.md +33 -3
  4. bricksentry-0.1.28/deploy/databricks-app/requirements.txt +1 -0
  5. {bricksentry-0.1.26 → bricksentry-0.1.28}/examples/databricks/bricksentry_validation.ipynb +1 -1
  6. {bricksentry-0.1.26 → bricksentry-0.1.28}/examples/databricks/bricksentry_validation.py +1 -1
  7. {bricksentry-0.1.26 → bricksentry-0.1.28}/pyproject.toml +2 -1
  8. {bricksentry-0.1.26 → bricksentry-0.1.28}/server.json +2 -2
  9. {bricksentry-0.1.26 → bricksentry-0.1.28}/src/bricksentry/__init__.py +1 -1
  10. {bricksentry-0.1.26 → bricksentry-0.1.28}/src/bricksentry/agent_tools.py +50 -11
  11. bricksentry-0.1.28/src/bricksentry/agent_view.py +267 -0
  12. {bricksentry-0.1.26 → bricksentry-0.1.28}/src/bricksentry/assess.py +1 -0
  13. {bricksentry-0.1.26 → bricksentry-0.1.28}/src/bricksentry/backends/base.py +21 -2
  14. {bricksentry-0.1.26 → bricksentry-0.1.28}/src/bricksentry/backends/databricks_backend.py +69 -6
  15. {bricksentry-0.1.26 → bricksentry-0.1.28}/src/bricksentry/backends/duckdb_backend.py +14 -5
  16. {bricksentry-0.1.26 → bricksentry-0.1.28}/src/bricksentry/changes.py +20 -7
  17. {bricksentry-0.1.26 → bricksentry-0.1.28}/src/bricksentry/cli.py +22 -6
  18. {bricksentry-0.1.26 → bricksentry-0.1.28}/src/bricksentry/config.py +27 -1
  19. {bricksentry-0.1.26 → bricksentry-0.1.28}/src/bricksentry/diff.py +175 -21
  20. {bricksentry-0.1.26 → bricksentry-0.1.28}/src/bricksentry/explain.py +23 -4
  21. bricksentry-0.1.28/src/bricksentry/mcp_server.py +192 -0
  22. {bricksentry-0.1.26 → bricksentry-0.1.28}/src/bricksentry/models.py +6 -0
  23. {bricksentry-0.1.26 → bricksentry-0.1.28}/src/bricksentry/policy.py +22 -2
  24. {bricksentry-0.1.26 → bricksentry-0.1.28}/src/bricksentry/report.py +20 -2
  25. {bricksentry-0.1.26 → bricksentry-0.1.28}/src/bricksentry/validation.py +67 -1
  26. {bricksentry-0.1.26 → bricksentry-0.1.28}/templates/job-check/databricks_template_schema.json +2 -2
  27. {bricksentry-0.1.26 → bricksentry-0.1.28}/tests/test_0110.py +2 -1
  28. {bricksentry-0.1.26 → bricksentry-0.1.28}/tests/test_0123.py +1 -1
  29. {bricksentry-0.1.26 → bricksentry-0.1.28}/tests/test_0126.py +1 -1
  30. bricksentry-0.1.28/tests/test_0127.py +267 -0
  31. bricksentry-0.1.28/tests/test_0128.py +235 -0
  32. bricksentry-0.1.26/deploy/databricks-app/requirements.txt +0 -1
  33. bricksentry-0.1.26/src/bricksentry/mcp_server.py +0 -110
  34. {bricksentry-0.1.26 → bricksentry-0.1.28}/.gitignore +0 -0
  35. {bricksentry-0.1.26 → bricksentry-0.1.28}/CONTRIBUTING.md +0 -0
  36. {bricksentry-0.1.26 → bricksentry-0.1.28}/LICENSE +0 -0
  37. {bricksentry-0.1.26 → bricksentry-0.1.28}/SECURITY.md +0 -0
  38. {bricksentry-0.1.26 → bricksentry-0.1.28}/action.yml +0 -0
  39. {bricksentry-0.1.26 → bricksentry-0.1.28}/deploy/container/Dockerfile +0 -0
  40. {bricksentry-0.1.26 → bricksentry-0.1.28}/deploy/databricks-app/README.md +0 -0
  41. {bricksentry-0.1.26 → bricksentry-0.1.28}/deploy/databricks-app/app.yaml +0 -0
  42. {bricksentry-0.1.26 → bricksentry-0.1.28}/deploy/databricks-app/bricksentry.yml +0 -0
  43. {bricksentry-0.1.26 → bricksentry-0.1.28}/deploy/databricks-app/databricks.yml +0 -0
  44. {bricksentry-0.1.26 → bricksentry-0.1.28}/deploy/databricks-app/grants.sql +0 -0
  45. {bricksentry-0.1.26 → bricksentry-0.1.28}/examples/databricks/bricksentry.yml +0 -0
  46. {bricksentry-0.1.26 → bricksentry-0.1.28}/examples/databricks/bricksentry_check_my_table.ipynb +0 -0
  47. {bricksentry-0.1.26 → bricksentry-0.1.28}/examples/databricks/bricksentry_check_my_table.py +0 -0
  48. {bricksentry-0.1.26 → bricksentry-0.1.28}/examples/databricks/bricksentry_hr_walkthrough.ipynb +0 -0
  49. {bricksentry-0.1.26 → bricksentry-0.1.28}/examples/databricks/bricksentry_hr_walkthrough.py +0 -0
  50. {bricksentry-0.1.26 → bricksentry-0.1.28}/examples/databricks/bricksentry_quickstart.ipynb +0 -0
  51. {bricksentry-0.1.26 → bricksentry-0.1.28}/examples/databricks/bricksentry_quickstart.py +0 -0
  52. {bricksentry-0.1.26 → bricksentry-0.1.28}/examples/databricks/github-workflow.yml +0 -0
  53. {bricksentry-0.1.26 → bricksentry-0.1.28}/examples/databricks/policy.yml +0 -0
  54. {bricksentry-0.1.26 → bricksentry-0.1.28}/examples/demo/agent_loop_demo.py +0 -0
  55. {bricksentry-0.1.26 → bricksentry-0.1.28}/scripts/build_notebook.py +0 -0
  56. {bricksentry-0.1.26 → bricksentry-0.1.28}/scripts/render_demo_image.py +0 -0
  57. {bricksentry-0.1.26 → bricksentry-0.1.28}/src/bricksentry/__main__.py +0 -0
  58. {bricksentry-0.1.26 → bricksentry-0.1.28}/src/bricksentry/backends/__init__.py +0 -0
  59. {bricksentry-0.1.26 → bricksentry-0.1.28}/src/bricksentry/demo.py +0 -0
  60. {bricksentry-0.1.26 → bricksentry-0.1.28}/src/bricksentry/github.py +0 -0
  61. {bricksentry-0.1.26 → bricksentry-0.1.28}/src/bricksentry/history.py +0 -0
  62. {bricksentry-0.1.26 → bricksentry-0.1.28}/src/bricksentry/job.py +0 -0
  63. {bricksentry-0.1.26 → bricksentry-0.1.28}/src/bricksentry/job_demo.py +0 -0
  64. {bricksentry-0.1.26 → bricksentry-0.1.28}/src/bricksentry/lineage.py +0 -0
  65. {bricksentry-0.1.26 → bricksentry-0.1.28}/src/bricksentry/measures.py +0 -0
  66. {bricksentry-0.1.26 → bricksentry-0.1.28}/src/bricksentry/netguard.py +0 -0
  67. {bricksentry-0.1.26 → bricksentry-0.1.28}/src/bricksentry/notify.py +0 -0
  68. {bricksentry-0.1.26 → bricksentry-0.1.28}/src/bricksentry/policy_templates.py +0 -0
  69. {bricksentry-0.1.26 → bricksentry-0.1.28}/src/bricksentry/preview.py +0 -0
  70. {bricksentry-0.1.26 → bricksentry-0.1.28}/src/bricksentry/py.typed +0 -0
  71. {bricksentry-0.1.26 → bricksentry-0.1.28}/templates/job-check/README.md +0 -0
  72. {bricksentry-0.1.26 → bricksentry-0.1.28}/templates/job-check/template/{{.project_name}}/.gitignore +0 -0
  73. {bricksentry-0.1.26 → bricksentry-0.1.28}/templates/job-check/template/{{.project_name}}/README.md.tmpl +0 -0
  74. {bricksentry-0.1.26 → bricksentry-0.1.28}/templates/job-check/template/{{.project_name}}/databricks.yml.tmpl +0 -0
  75. {bricksentry-0.1.26 → bricksentry-0.1.28}/templates/job-check/template/{{.project_name}}/resources/bricksentry_check.job.yml.tmpl +0 -0
  76. {bricksentry-0.1.26 → bricksentry-0.1.28}/templates/job-check/template/{{.project_name}}/src/bricksentry_check.py +0 -0
  77. {bricksentry-0.1.26 → bricksentry-0.1.28}/templates/job-check/template/{{.project_name}}/src/bricksentry_demo.py +0 -0
  78. {bricksentry-0.1.26 → bricksentry-0.1.28}/tests/conftest.py +0 -0
  79. {bricksentry-0.1.26 → bricksentry-0.1.28}/tests/test_0112.py +0 -0
  80. {bricksentry-0.1.26 → bricksentry-0.1.28}/tests/test_0114.py +0 -0
  81. {bricksentry-0.1.26 → bricksentry-0.1.28}/tests/test_0120.py +0 -0
  82. {bricksentry-0.1.26 → bricksentry-0.1.28}/tests/test_0121.py +0 -0
  83. {bricksentry-0.1.26 → bricksentry-0.1.28}/tests/test_0122.py +0 -0
  84. {bricksentry-0.1.26 → bricksentry-0.1.28}/tests/test_018.py +0 -0
  85. {bricksentry-0.1.26 → bricksentry-0.1.28}/tests/test_019.py +0 -0
  86. {bricksentry-0.1.26 → bricksentry-0.1.28}/tests/test_assess_policy.py +0 -0
  87. {bricksentry-0.1.26 → bricksentry-0.1.28}/tests/test_check_notebook.py +0 -0
  88. {bricksentry-0.1.26 → bricksentry-0.1.28}/tests/test_databricks_and_uc.py +0 -0
  89. {bricksentry-0.1.26 → bricksentry-0.1.28}/tests/test_demo.py +0 -0
  90. {bricksentry-0.1.26 → bricksentry-0.1.28}/tests/test_diff.py +0 -0
  91. {bricksentry-0.1.26 → bricksentry-0.1.28}/tests/test_hr_notebook.py +0 -0
  92. {bricksentry-0.1.26 → bricksentry-0.1.28}/tests/test_notebook.py +0 -0
  93. {bricksentry-0.1.26 → bricksentry-0.1.28}/tests/test_notify_templates.py +0 -0
  94. {bricksentry-0.1.26 → bricksentry-0.1.28}/tests/test_preview_agents.py +0 -0
  95. {bricksentry-0.1.26 → bricksentry-0.1.28}/tests/test_sample_guard_and_store.py +0 -0
@@ -1,5 +1,29 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.28 (2026-11-17)
4
+
5
+ Security fixes from live-test round 9 on 0.1.27 (MERGE, allowlist bypasses, metadata injection, remote access, governance features). Agents still never received production values; these close the remaining ways to learn about tables they shouldn't. Every round-9 attack was re-run on the fixes and refused or handled; the 15-scenario battery passed 15 of 15 on Databricks, and a live Unity Catalog row filter gave `needs_human` instead of a silent pass.
6
+
7
+ - **`agent_tables` covers every table an agent touches.** It only checked the target, so an agent could read a forbidden table inside an allowed write (subquery, join, CTE, `MERGE ... USING`, `INSERT ... SELECT`) or name it as the candidate in `assess_change`, and learn its row counts. Statements are now parsed with a real SQL parser (sqlglot, a new dependency) and every table they read must be listed; agent-named candidates too; `explain_diff` and `safe_to_ship` refuse assessments of unlisted tables. What can't be checked by name is refused: table functions (`table_changes`, `read_files`), `IDENTIFIER(...)`, path-based tables, and SQL that doesn't parse. **If you use `agent_tables`:** sources of MERGE and INSERT ... SELECT must now be listed too, written with their full name (e.g. `main.sales.updates`), or agent previews that read them are refused. The CLI and Python API are unaffected.
8
+ - **Column masks and row filters can't pass silently.** A masked column with 50 real changes diffed as unchanged. bricksentry now reads masks and row filters from Unity Catalog: masked columns aren't compared (`columns-not-compared`) and a row filter on either table gets `needs_human` (`row-filter`).
9
+ - **Behavior change: the MCP server needs a token on the network.** Over HTTP on anything but localhost it had no authentication, so anyone who could reach the port could call the tools. It now refuses to start there unless `BRICKSENTRY_MCP_TOKEN` is set (clients send `Authorization: Bearer <token>`) or `--insecure-no-auth` is passed for a network behind your own authenticating proxy. Databricks Apps needs no token (its sign-in is in front). Localhost gets DNS-rebinding protection again; `BRICKSENTRY_ALLOWED_HOSTS` lists extra host names.
10
+ - **Free text in tags and owners no longer reaches agents.** Tag values such as "IGNORE ALL PREVIOUS INSTRUCTIONS…" were passed to agents verbatim. Short, plain names and values (`pii`, `true`, `finance-team`) still are; longer or free text shows as `[text hidden: N chars]`, also where it was copied into summaries. Verdicts were never affected.
11
+ - `assess --from-git` gives one clear line (exit 2) when git fails or isn't installed, instead of a traceback.
12
+ - Quoted-value redaction in agent errors no longer eats apostrophes in words ("can't") and catches values that contain one ('O'Brien').
13
+ - New validation scenario `agent_allowlist` (the battery is now 15).
14
+
15
+ ## 0.1.27 (2026-11-17)
16
+
17
+ A safety release. A live round of leak, data-shape and race tests on 0.1.26 found four problems; two could mislead. A verification round re-ran every original attack on the fixes: no production value reached an agent, mid-diff rewrites returned the pinned state 3 of 3 times, MAP diffs and the key-order trap were exact, and the 14-scenario battery passed 14 of 14. Pinning makes a diff slower (a 1M-row diff took about 10 s instead of 5 s); that will be reduced in a later release.
18
+
19
+ - **Agents never get production values.** `preview_write` returned up to 5 before→after values per changed column, so an agent with no access to a table could "update" chosen rows and read their old values (SSNs, salaries) back, because bricksentry does the reading. Every agent tool (MCP and `bricksentry.agent_tools`) now returns counts, columns, schema, null counts, percentages and verdicts, never values: no example values on either side (an agent can copy a value into the "new" side), no absolute totals (a total over one row is the value; percentages are rounded to one decimal), no segment values, and quoted values are removed from engine errors. Humans keep the detail in the CLI, Python API and reports, except values in `pii`-tagged tables and columns, which reports never show. Rule reasons no longer contain totals ("sum(amount) moved from 0").
20
+ - **`agent_tables`** in bricksentry.yml lists the tables agents may assess or preview (globs, any case); others are refused. Counts alone can still be probed (`DELETE ... WHERE ssn LIKE '1%'`), which only limiting tables can stop. Every agent `assess_change` / `preview_write` is logged to `bricksentry.audit` and `audit.jsonl` in the assessment store. The README has a table of what each tool can reveal.
21
+ - **Every diff reads one consistent version of each table.** The diff runs several queries; a table rewritten between them mixed two states (a candidate replaced mid-diff gave changed=49 when the old state had 5 and the new 50). Both tables are now pinned to their Delta version at the start (`VERSION AS OF`, schema included), and a candidate that changes during the check gets `needs_human` ("changed-during-check"). Objects that can't time travel are checked before and after.
22
+ - **MAP columns no longer fail the whole diff.** Spark can't compare or hash maps, so one MAP column gave `diff-failed`. Maps are compared by their entries sorted by key (equal maps written in another order are equal); maps nested in structs or arrays as JSON. A column the engine still can't compare is left out with a note and the check asks a human (`columns-not-compared`), instead of losing the diff.
23
+ - **Float rounding.** FLOAT/DOUBLE stay exact by default, but a column that changed everywhere while its total stayed the same gets a note that it's likely rounding. New opt-in `float_tolerance` (relative, e.g. `1e-9`); NaN, infinity and NULL still compare exactly; DECIMAL is always exact.
24
+ - **Key names match case-insensitively** (`keys: [ID]` finds `id`), like the engine.
25
+ - New validation scenarios `agent_sees_no_values` and `map_column` (the battery is now 14).
26
+
3
27
  ## 0.1.26 (2026-11-17)
4
28
 
5
29
  Fixes for what two worst-case live tests of 0.1.25 on Databricks found. A pre-release check passed on two Databricks Free Edition workspaces (47 of 47 on the first), including the 12-scenario validation battery and before/after repros of every fix.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: bricksentry
3
- Version: 0.1.26
3
+ Version: 0.1.28
4
4
  Summary: Change impact analysis and deployment guardrails for data changes on Databricks, for pipelines and the AI agents that edit them: data diffs, Unity Catalog blast radius, policy verdicts and rollback plans.
5
5
  Project-URL: Homepage, https://bricksentry.org
6
6
  Project-URL: Documentation, https://bricksentry.org/docs
@@ -26,6 +26,7 @@ Classifier: Typing :: Typed
26
26
  Requires-Python: >=3.10
27
27
  Requires-Dist: click>=8.1
28
28
  Requires-Dist: pyyaml>=6.0
29
+ Requires-Dist: sqlglot>=25
29
30
  Provides-Extra: all
30
31
  Requires-Dist: databricks-sdk>=0.30; extra == 'all'
31
32
  Requires-Dist: duckdb>=1.0; extra == 'all'
@@ -179,7 +180,7 @@ claude mcp add bricksentry -- uvx bricksentry-mcp --config /full/path/to/brickse
179
180
 
180
181
  The JSON works for the Claude desktop app, Cursor and other MCP clients. Use a **full path** to `bricksentry.yml`, because clients start the server from their own working folder. If an app can't find `uvx`, use its full path (`which uvx`). To share the setup through a repo, `claude mcp add -s project ...` writes it to `.mcp.json`; a relative path then works when Claude Code starts from the repo root. No config yet? `uvx --from bricksentry bricksentry init` writes a starter one.
181
182
 
182
- Already installed bricksentry with pip? `pip install "bricksentry[mcp,databricks]"` and run `bricksentry mcp --config /full/path/to/bricksentry.yml` instead. Add `--transport streamable-http` for remote agents.
183
+ Already installed bricksentry with pip? `pip install "bricksentry[mcp,databricks]"` and run `bricksentry mcp --config /full/path/to/bricksentry.yml` instead. Add `--transport streamable-http` for remote agents. Over HTTP the server listens on 127.0.0.1; to listen on any other address, set `BRICKSENTRY_MCP_TOKEN` and have clients send `Authorization: Bearer <token>` (it refuses to start otherwise). Databricks Apps needs no token, because its sign-in is in front.
183
184
 
184
185
  bricksentry is listed in the [official MCP Registry](https://registry.modelcontextprotocol.io/v0/servers?search=io.github.bricksentry/bricksentry) as `io.github.bricksentry/bricksentry`.
185
186
 
@@ -200,6 +201,28 @@ Designed for agents:
200
201
  - **Bounded cost:** deterministic hash sampling (`sample_pct`), capped samples, and lineage limited by depth and lookback window. A full-table checksum guards the sample: if the sample shows no change but the tables differ, the diff re-runs on every row, so a one-row change can't slip through.
201
202
  - **Assessments are saved** as JSON (default `~/.bricksentry/assessments`), so `explain_diff` and `safe_to_ship` work from another process or a fresh `Sentry`.
202
203
 
204
+ ### What an agent can learn about your data
205
+
206
+ bricksentry usually runs with more read access than the agent that calls it, so the tools are built so an agent never sees production *values*:
207
+
208
+ | Tool | What the agent gets | What it never gets |
209
+ |---|---|---|
210
+ | `whats_downstream`, `rollback_plan` | Table and column names, owners, tags, versions | Any row data |
211
+ | `preview_write`, `assess_change` | Row counts (added, removed, changed), changed columns, schema changes, null counts, duplicate keys, total changes as a percentage (one decimal), the verdict and rule reasons | Example values (before or after), absolute totals, segment values, quoted values in engine errors |
212
+ | `explain_diff`, `safe_to_ship` | The same, as text | The same |
213
+
214
+ The new value is hidden too, because an agent can write `SET note = ssn` and read its own "new" value. Humans keep the detail: the CLI, the Python API and the pull-request report show example values, except in tables or columns tagged `pii`, whose values a report never shows.
215
+
216
+ **Counts can still leak information.** An agent could preview `DELETE ... WHERE ssn LIKE '1%'` and read the number of removed rows, then narrow it down. No masking stops that, so list the tables agents may use:
217
+
218
+ ```yaml
219
+ agent_tables: ["main.sales_dev.*", "main.sales.orders"] # globs, any case; others are refused
220
+ ```
221
+
222
+ The list covers every table an agent touches: the target, every table its statement reads (subqueries, joins, CTEs, `MERGE ... USING`), and any candidate it names. Statements that can't be checked by name are refused: table functions such as `table_changes()` or `read_files()`, `IDENTIFIER(...)`, path-based tables and SQL that doesn't parse. Write full names (`main.sales.orders`) when your patterns have three parts. Sources count too: for an agent to preview `MERGE INTO {{target}} USING main.sales.updates ...`, list `main.sales.updates` (or a pattern covering it) as well; a source left off the list, or written without its catalog, is refused. Without `agent_tables`, agents can check any table bricksentry can read.
223
+
224
+ **Metadata is data, not instructions.** Tag names and values and owners reach agents only when short and plain (`pii`, `true`, `finance-team`); longer or free text, which anyone who can tag a table could write, shows as `[text hidden: N chars]`. Policies still see the full tags. Run the MCP server under an identity that can read only what the agent should. Every agent `assess_change` and `preview_write`, refused or not, is logged to `bricksentry.audit` and to `audit.jsonl` in the assessment store (time, actor, tables, verdict, row counts), so a run of small probing previews is visible.
225
+
203
226
  The same tools are plain Python functions in `bricksentry.agent_tools`, so you can use them from LangGraph, the OpenAI Agents SDK or the Databricks Agent Framework without MCP.
204
227
 
205
228
  To watch the whole loop, run `bricksentry demo` (see the top of this page). `bricksentry demo --report report.md` also writes the pull-request comment a reviewer would see.
@@ -344,6 +367,8 @@ backend: {type: databricks, warehouse_id: abc123} # auth: standard Databric
344
367
  sandbox_schema: main.bricksentry_sandbox
345
368
  candidate_pattern: "{catalog}.{schema}_pr_{pr}.{table}"
346
369
  sample_pct: 10 # sample_guard re-checks the whole table (on by default)
370
+ float_tolerance: 1e-9 # optional: FLOAT/DOUBLE within this relative difference count as equal
371
+ agent_tables: ["main.sales_dev.*"] # optional: tables AI agents may assess or preview (see above)
347
372
  assessment_store: ~/.bricksentry/assessments # or false to keep assessments in memory
348
373
  lineage: {type: databricks, depth: 3, lookback_days: 90, column_depth: 2} # also: exclude, exclude_dropped
349
374
  tables:
@@ -374,6 +399,12 @@ lineage:
374
399
 
375
400
  Typos are caught: an unknown key such as `sample_pc` prints a warning that names the right one (`did you mean 'sample_pct'?`) instead of being silently ignored.
376
401
 
402
+ **Column masks and row filters.** If a table in the diff has a Unity Catalog column mask, that column isn't compared (bricksentry's identity may see masked values, which hide changes); with a row filter, the diff may not see every row. Either way the check asks a human (`columns-not-compared`, `row-filter`).
403
+
404
+ **Consistent reads.** Every diff reads both tables at the Delta version they had when it started (`VERSION AS OF`), so a job writing to them mid-check can't mix two states into one result. If the candidate gets a new version during the check, the result says so and asks a human to re-run. Views and other objects without time travel are read as they are, with a before-and-after version check.
405
+
406
+ **Floats.** FLOAT and DOUBLE are compared exactly by default, so `0.1 + 0.2` and `0.3` differ. If a column changes everywhere but its total stays the same, the diff says it's likely rounding. Set `float_tolerance` to compare within a relative tolerance; NaN, infinity and NULL still compare exactly, and DECIMAL is always exact. MAP columns are compared by their entries sorted by key, so a map written in a different order isn't a change. A column the engine can't compare at all is left out with a note, and the check asks a human.
407
+
377
408
  **Which totals are checked.** `sum_change_pct_gt` rules and summaries look at measures: by default every numeric column except keys and columns whose names look like IDs, codes, years and other date parts, coordinates, ratings, scores or rates (a 10% drop in `sum(established_year)` only says rows were removed). List `measures` for a table to choose exactly, or set `measures: all` to check every numeric column. A rule that names a column (`when: {column: rating, sum_change_pct_gt: 1}`) always checks it.
378
409
 
379
410
  ### Policy example
@@ -452,7 +483,7 @@ Without lineage access bricksentry still diffs, and adds a `lineage-unavailable`
452
483
 
453
484
  ## What a check costs
454
485
 
455
- The work runs on your SQL warehouse as plain SQL; nothing large is copied out. One table diff runs about five queries: a duplicate-key count on each side, one full outer join on the key columns, and one profile (row count, nulls, totals) per side, plus up to ten small queries for example values. Each reads both versions of the table, so cost grows with table size: seconds for millions of rows, minutes and real warehouse cost for hundreds of millions. For big tables, set `sample_pct` (a fixed hash sample of keys, checked against a full-table checksum so a change outside the sample isn't missed), or check only the tables that matter. Lineage lookups are one query per depth level, bounded by `lookback_days`.
486
+ The work runs on your SQL warehouse as plain SQL; nothing large is copied out. One table diff runs about five queries (plus a few cheap metadata queries to pin each table's Delta version): a duplicate-key count on each side, one full outer join on the key columns, and one profile (row count, nulls, totals) per side, plus up to ten small queries for example values. Each reads both versions of the table, so cost grows with table size: seconds for millions of rows, minutes and real warehouse cost for hundreds of millions. For big tables, set `sample_pct` (a fixed hash sample of keys, checked against a full-table checksum so a change outside the sample isn't missed), or check only the tables that matter. Lineage lookups are one query per depth level, bounded by `lookback_days`.
456
487
 
457
488
  ## Audit trail
458
489
 
@@ -463,7 +494,7 @@ Every assessment records when it ran (UTC), the bricksentry version, a SHA-256 f
463
494
  - **Lineage is recorded at runtime.** Brand-new tables have no downstream history yet. Unity Catalog doesn't capture RDD operations, and UDFs hide column-level mapping; column lineage records source-to-target derivations, so a column used only in a filter or join may not appear.
464
495
  - **Keys are required.** Tables without a stable key can't be diffed row by row yet (an aggregate-profile mode is planned).
465
496
  - **Changed-table detection uses path globs** from config. It doesn't parse Asset Bundles yet.
466
- - **Validated on Databricks** (serverless, November 2026): a 2-million-row table with 0.1.4 (lineage, rollback plans, previews on shallow clones, every verdict level, the sampling guard catching a single changed row), then live runs of every release up to 0.1.26 on a Free Edition workspace with an HR pipeline: pull-request gating with comment updates, the bundle demo job, `check-last-change` and the newer-changes warning in the CLI, report, JSON and Slack, the refused-statement guards, outbound-URL checks, one-to-one matching of 2,000 NULL keys, exact totals over a million decimal rows, the audit trail, an AI agent attempting six risky changes on the live pipeline, the job task blocking a bad MERGE inside a real Databricks job, and worst-case rounds (50,000 NULL keys, near-max decimals, exotic types, 200-column tables) whose five findings were fixed in 0.1.26. Every run, with its numbers and the bugs it found, is in [VALIDATION.md](VALIDATION.md). The automated tests use DuckDB and a mocked SDK, so please run the [validation notebook](examples/databricks/bricksentry_validation.py) on your workspace and [share a validation report](https://github.com/bricksentry/bricksentry/issues/new?template=validation_report.yml), whether it passes or not.
497
+ - **Validated on Databricks** (serverless, November 2026): a 2-million-row table with 0.1.4 (lineage, rollback plans, previews on shallow clones, every verdict level, the sampling guard catching a single changed row), then live runs of every release up to 0.1.28 on a Free Edition workspace with an HR pipeline: pull-request gating with comment updates, the bundle demo job, `check-last-change` and the newer-changes warning in the CLI, report, JSON and Slack, the refused-statement guards, outbound-URL checks, one-to-one matching of 2,000 NULL keys, exact totals over a million decimal rows, the audit trail, an AI agent attempting six risky changes on the live pipeline, the job task blocking a bad MERGE inside a real Databricks job, and worst-case rounds (50,000 NULL keys, near-max decimals, exotic types, 200-column tables) whose five findings were fixed in 0.1.26, a round of leak, data-shape and race tests whose four findings were fixed in 0.1.27, and a round on MERGE, allowlist bypasses, metadata injection, remote access and governance features whose findings were fixed in 0.1.28. Every run, with its numbers and the bugs it found, is in [VALIDATION.md](VALIDATION.md). The automated tests use DuckDB and a mocked SDK, so please run the [validation notebook](examples/databricks/bricksentry_validation.py) on your workspace and [share a validation report](https://github.com/bricksentry/bricksentry/issues/new?template=validation_report.yml), whether it passes or not.
467
498
 
468
499
  ## Roadmap
469
500
 
@@ -132,7 +132,7 @@ claude mcp add bricksentry -- uvx bricksentry-mcp --config /full/path/to/brickse
132
132
 
133
133
  The JSON works for the Claude desktop app, Cursor and other MCP clients. Use a **full path** to `bricksentry.yml`, because clients start the server from their own working folder. If an app can't find `uvx`, use its full path (`which uvx`). To share the setup through a repo, `claude mcp add -s project ...` writes it to `.mcp.json`; a relative path then works when Claude Code starts from the repo root. No config yet? `uvx --from bricksentry bricksentry init` writes a starter one.
134
134
 
135
- Already installed bricksentry with pip? `pip install "bricksentry[mcp,databricks]"` and run `bricksentry mcp --config /full/path/to/bricksentry.yml` instead. Add `--transport streamable-http` for remote agents.
135
+ Already installed bricksentry with pip? `pip install "bricksentry[mcp,databricks]"` and run `bricksentry mcp --config /full/path/to/bricksentry.yml` instead. Add `--transport streamable-http` for remote agents. Over HTTP the server listens on 127.0.0.1; to listen on any other address, set `BRICKSENTRY_MCP_TOKEN` and have clients send `Authorization: Bearer <token>` (it refuses to start otherwise). Databricks Apps needs no token, because its sign-in is in front.
136
136
 
137
137
  bricksentry is listed in the [official MCP Registry](https://registry.modelcontextprotocol.io/v0/servers?search=io.github.bricksentry/bricksentry) as `io.github.bricksentry/bricksentry`.
138
138
 
@@ -153,6 +153,28 @@ Designed for agents:
153
153
  - **Bounded cost:** deterministic hash sampling (`sample_pct`), capped samples, and lineage limited by depth and lookback window. A full-table checksum guards the sample: if the sample shows no change but the tables differ, the diff re-runs on every row, so a one-row change can't slip through.
154
154
  - **Assessments are saved** as JSON (default `~/.bricksentry/assessments`), so `explain_diff` and `safe_to_ship` work from another process or a fresh `Sentry`.
155
155
 
156
+ ### What an agent can learn about your data
157
+
158
+ bricksentry usually runs with more read access than the agent that calls it, so the tools are built so an agent never sees production *values*:
159
+
160
+ | Tool | What the agent gets | What it never gets |
161
+ |---|---|---|
162
+ | `whats_downstream`, `rollback_plan` | Table and column names, owners, tags, versions | Any row data |
163
+ | `preview_write`, `assess_change` | Row counts (added, removed, changed), changed columns, schema changes, null counts, duplicate keys, total changes as a percentage (one decimal), the verdict and rule reasons | Example values (before or after), absolute totals, segment values, quoted values in engine errors |
164
+ | `explain_diff`, `safe_to_ship` | The same, as text | The same |
165
+
166
+ The new value is hidden too, because an agent can write `SET note = ssn` and read its own "new" value. Humans keep the detail: the CLI, the Python API and the pull-request report show example values, except in tables or columns tagged `pii`, whose values a report never shows.
167
+
168
+ **Counts can still leak information.** An agent could preview `DELETE ... WHERE ssn LIKE '1%'` and read the number of removed rows, then narrow it down. No masking stops that, so list the tables agents may use:
169
+
170
+ ```yaml
171
+ agent_tables: ["main.sales_dev.*", "main.sales.orders"] # globs, any case; others are refused
172
+ ```
173
+
174
+ The list covers every table an agent touches: the target, every table its statement reads (subqueries, joins, CTEs, `MERGE ... USING`), and any candidate it names. Statements that can't be checked by name are refused: table functions such as `table_changes()` or `read_files()`, `IDENTIFIER(...)`, path-based tables and SQL that doesn't parse. Write full names (`main.sales.orders`) when your patterns have three parts. Sources count too: for an agent to preview `MERGE INTO {{target}} USING main.sales.updates ...`, list `main.sales.updates` (or a pattern covering it) as well; a source left off the list, or written without its catalog, is refused. Without `agent_tables`, agents can check any table bricksentry can read.
175
+
176
+ **Metadata is data, not instructions.** Tag names and values and owners reach agents only when short and plain (`pii`, `true`, `finance-team`); longer or free text, which anyone who can tag a table could write, shows as `[text hidden: N chars]`. Policies still see the full tags. Run the MCP server under an identity that can read only what the agent should. Every agent `assess_change` and `preview_write`, refused or not, is logged to `bricksentry.audit` and to `audit.jsonl` in the assessment store (time, actor, tables, verdict, row counts), so a run of small probing previews is visible.
177
+
156
178
  The same tools are plain Python functions in `bricksentry.agent_tools`, so you can use them from LangGraph, the OpenAI Agents SDK or the Databricks Agent Framework without MCP.
157
179
 
158
180
  To watch the whole loop, run `bricksentry demo` (see the top of this page). `bricksentry demo --report report.md` also writes the pull-request comment a reviewer would see.
@@ -297,6 +319,8 @@ backend: {type: databricks, warehouse_id: abc123} # auth: standard Databric
297
319
  sandbox_schema: main.bricksentry_sandbox
298
320
  candidate_pattern: "{catalog}.{schema}_pr_{pr}.{table}"
299
321
  sample_pct: 10 # sample_guard re-checks the whole table (on by default)
322
+ float_tolerance: 1e-9 # optional: FLOAT/DOUBLE within this relative difference count as equal
323
+ agent_tables: ["main.sales_dev.*"] # optional: tables AI agents may assess or preview (see above)
300
324
  assessment_store: ~/.bricksentry/assessments # or false to keep assessments in memory
301
325
  lineage: {type: databricks, depth: 3, lookback_days: 90, column_depth: 2} # also: exclude, exclude_dropped
302
326
  tables:
@@ -327,6 +351,12 @@ lineage:
327
351
 
328
352
  Typos are caught: an unknown key such as `sample_pc` prints a warning that names the right one (`did you mean 'sample_pct'?`) instead of being silently ignored.
329
353
 
354
+ **Column masks and row filters.** If a table in the diff has a Unity Catalog column mask, that column isn't compared (bricksentry's identity may see masked values, which hide changes); with a row filter, the diff may not see every row. Either way the check asks a human (`columns-not-compared`, `row-filter`).
355
+
356
+ **Consistent reads.** Every diff reads both tables at the Delta version they had when it started (`VERSION AS OF`), so a job writing to them mid-check can't mix two states into one result. If the candidate gets a new version during the check, the result says so and asks a human to re-run. Views and other objects without time travel are read as they are, with a before-and-after version check.
357
+
358
+ **Floats.** FLOAT and DOUBLE are compared exactly by default, so `0.1 + 0.2` and `0.3` differ. If a column changes everywhere but its total stays the same, the diff says it's likely rounding. Set `float_tolerance` to compare within a relative tolerance; NaN, infinity and NULL still compare exactly, and DECIMAL is always exact. MAP columns are compared by their entries sorted by key, so a map written in a different order isn't a change. A column the engine can't compare at all is left out with a note, and the check asks a human.
359
+
330
360
  **Which totals are checked.** `sum_change_pct_gt` rules and summaries look at measures: by default every numeric column except keys and columns whose names look like IDs, codes, years and other date parts, coordinates, ratings, scores or rates (a 10% drop in `sum(established_year)` only says rows were removed). List `measures` for a table to choose exactly, or set `measures: all` to check every numeric column. A rule that names a column (`when: {column: rating, sum_change_pct_gt: 1}`) always checks it.
331
361
 
332
362
  ### Policy example
@@ -405,7 +435,7 @@ Without lineage access bricksentry still diffs, and adds a `lineage-unavailable`
405
435
 
406
436
  ## What a check costs
407
437
 
408
- The work runs on your SQL warehouse as plain SQL; nothing large is copied out. One table diff runs about five queries: a duplicate-key count on each side, one full outer join on the key columns, and one profile (row count, nulls, totals) per side, plus up to ten small queries for example values. Each reads both versions of the table, so cost grows with table size: seconds for millions of rows, minutes and real warehouse cost for hundreds of millions. For big tables, set `sample_pct` (a fixed hash sample of keys, checked against a full-table checksum so a change outside the sample isn't missed), or check only the tables that matter. Lineage lookups are one query per depth level, bounded by `lookback_days`.
438
+ The work runs on your SQL warehouse as plain SQL; nothing large is copied out. One table diff runs about five queries (plus a few cheap metadata queries to pin each table's Delta version): a duplicate-key count on each side, one full outer join on the key columns, and one profile (row count, nulls, totals) per side, plus up to ten small queries for example values. Each reads both versions of the table, so cost grows with table size: seconds for millions of rows, minutes and real warehouse cost for hundreds of millions. For big tables, set `sample_pct` (a fixed hash sample of keys, checked against a full-table checksum so a change outside the sample isn't missed), or check only the tables that matter. Lineage lookups are one query per depth level, bounded by `lookback_days`.
409
439
 
410
440
  ## Audit trail
411
441
 
@@ -416,7 +446,7 @@ Every assessment records when it ran (UTC), the bricksentry version, a SHA-256 f
416
446
  - **Lineage is recorded at runtime.** Brand-new tables have no downstream history yet. Unity Catalog doesn't capture RDD operations, and UDFs hide column-level mapping; column lineage records source-to-target derivations, so a column used only in a filter or join may not appear.
417
447
  - **Keys are required.** Tables without a stable key can't be diffed row by row yet (an aggregate-profile mode is planned).
418
448
  - **Changed-table detection uses path globs** from config. It doesn't parse Asset Bundles yet.
419
- - **Validated on Databricks** (serverless, November 2026): a 2-million-row table with 0.1.4 (lineage, rollback plans, previews on shallow clones, every verdict level, the sampling guard catching a single changed row), then live runs of every release up to 0.1.26 on a Free Edition workspace with an HR pipeline: pull-request gating with comment updates, the bundle demo job, `check-last-change` and the newer-changes warning in the CLI, report, JSON and Slack, the refused-statement guards, outbound-URL checks, one-to-one matching of 2,000 NULL keys, exact totals over a million decimal rows, the audit trail, an AI agent attempting six risky changes on the live pipeline, the job task blocking a bad MERGE inside a real Databricks job, and worst-case rounds (50,000 NULL keys, near-max decimals, exotic types, 200-column tables) whose five findings were fixed in 0.1.26. Every run, with its numbers and the bugs it found, is in [VALIDATION.md](VALIDATION.md). The automated tests use DuckDB and a mocked SDK, so please run the [validation notebook](examples/databricks/bricksentry_validation.py) on your workspace and [share a validation report](https://github.com/bricksentry/bricksentry/issues/new?template=validation_report.yml), whether it passes or not.
449
+ - **Validated on Databricks** (serverless, November 2026): a 2-million-row table with 0.1.4 (lineage, rollback plans, previews on shallow clones, every verdict level, the sampling guard catching a single changed row), then live runs of every release up to 0.1.28 on a Free Edition workspace with an HR pipeline: pull-request gating with comment updates, the bundle demo job, `check-last-change` and the newer-changes warning in the CLI, report, JSON and Slack, the refused-statement guards, outbound-URL checks, one-to-one matching of 2,000 NULL keys, exact totals over a million decimal rows, the audit trail, an AI agent attempting six risky changes on the live pipeline, the job task blocking a bad MERGE inside a real Databricks job, and worst-case rounds (50,000 NULL keys, near-max decimals, exotic types, 200-column tables) whose five findings were fixed in 0.1.26, a round of leak, data-shape and race tests whose four findings were fixed in 0.1.27, and a round on MERGE, allowlist bypasses, metadata injection, remote access and governance features whose findings were fixed in 0.1.28. Every run, with its numbers and the bugs it found, is in [VALIDATION.md](VALIDATION.md). The automated tests use DuckDB and a mocked SDK, so please run the [validation notebook](examples/databricks/bricksentry_validation.py) on your workspace and [share a validation report](https://github.com/bricksentry/bricksentry/issues/new?template=validation_report.yml), whether it passes or not.
420
450
 
421
451
  ## Roadmap
422
452
 
@@ -0,0 +1 @@
1
+ bricksentry[databricks,mcp]==0.1.28
@@ -6,7 +6,7 @@
6
6
  "source": [
7
7
  "# Validate bricksentry on your own workspace\n",
8
8
  "\n",
9
- "**12 risky changes, about 2 minutes, nothing outside a scratch schema touched.** This notebook runs the same\n",
9
+ "**15 risky changes, about 4 minutes, nothing outside a scratch schema touched.** This notebook runs the same\n",
10
10
  "validation battery we publish in [VALIDATION.md](https://github.com/bricksentry/bricksentry/blob/main/VALIDATION.md),\n",
11
11
  "so you can check the results yourself instead of taking our word for them.\n",
12
12
  "\n",
@@ -2,7 +2,7 @@
2
2
  # MAGIC %md
3
3
  # MAGIC # Validate bricksentry on your own workspace
4
4
  # MAGIC
5
- # MAGIC **12 risky changes, about 2 minutes, nothing outside a scratch schema touched.** This notebook runs the same
5
+ # MAGIC **15 risky changes, about 4 minutes, nothing outside a scratch schema touched.** This notebook runs the same
6
6
  # MAGIC validation battery we publish in [VALIDATION.md](https://github.com/bricksentry/bricksentry/blob/main/VALIDATION.md),
7
7
  # MAGIC so you can check the results yourself instead of taking our word for them.
8
8
  # MAGIC
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "bricksentry"
7
- version = "0.1.26"
7
+ version = "0.1.28"
8
8
  description = "Change impact analysis and deployment guardrails for data changes on Databricks, for pipelines and the AI agents that edit them: data diffs, Unity Catalog blast radius, policy verdicts and rollback plans."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -32,6 +32,7 @@ classifiers = [
32
32
  dependencies = [
33
33
  "click>=8.1",
34
34
  "pyyaml>=6.0",
35
+ "sqlglot>=25",
35
36
  ]
36
37
 
37
38
  [project.optional-dependencies]
@@ -8,12 +8,12 @@
8
8
  "source": "github"
9
9
  },
10
10
  "websiteUrl": "https://bricksentry.org",
11
- "version": "0.1.26",
11
+ "version": "0.1.28",
12
12
  "packages": [
13
13
  {
14
14
  "registryType": "pypi",
15
15
  "identifier": "bricksentry-mcp",
16
- "version": "0.1.26",
16
+ "version": "0.1.28",
17
17
  "runtimeHint": "uvx",
18
18
  "transport": {
19
19
  "type": "stdio"
@@ -23,4 +23,4 @@ __all__ = [
23
23
  "TableDiff",
24
24
  "Verdict",
25
25
  ]
26
- __version__ = "0.1.26"
26
+ __version__ = "0.1.28"
@@ -12,6 +12,7 @@ from __future__ import annotations
12
12
  import functools
13
13
  from typing import Annotated, Any
14
14
 
15
+ from bricksentry import agent_view
15
16
  from bricksentry.assess import Sentry
16
17
  from bricksentry.explain import explain_diff as _explain_diff
17
18
 
@@ -51,7 +52,7 @@ def _safe(fn):
51
52
  line = text.splitlines()[0] if text else ""
52
53
  if len(line) > 300:
53
54
  line = line[:297] + "..."
54
- return {"error": f"{type(e).__name__}: {line}"}
55
+ return {"error": agent_view.redact_values(f"{type(e).__name__}: {line}")}
55
56
 
56
57
  return wrapper
57
58
 
@@ -98,7 +99,7 @@ def whats_downstream(
98
99
  out["column_tags"] = {c: col_tags[c] for c in columns if col_tags.get(c)}
99
100
  feeds = s.lineage.column_downstream(table, list(columns), int(s.config.lineage.get("column_depth", 2)))
100
101
  out["column_downstream"] = [c.to_dict() for c in feeds]
101
- return out
102
+ return agent_view.scrub_metadata(out)
102
103
 
103
104
 
104
105
  @_safe
@@ -127,8 +128,15 @@ def assess_change(
127
128
  notify, rule_hits, tables: [{table, verdict, summary, diff, downstream,
128
129
  changed_columns, column_tags, column_downstream,
129
130
  rollback}]}. Pass `id` to safe_to_ship (and optionally explain_diff)."""
130
- a = get_sentry().assess(list(tables), candidates=candidates, pr=pr)
131
- return a.to_dict()
131
+ s = get_sentry()
132
+ tables = list(tables)
133
+ # Candidates an agent names are checked too: pointing an allowed table's candidate
134
+ # at a forbidden table would otherwise diff the forbidden one.
135
+ _gate(s, "assess_change", tables + [c for c in (candidates or {}).values() if c])
136
+ a = s.assess(tables, candidates=candidates, pr=pr)
137
+ out = agent_view.for_agent(a, s)
138
+ agent_view.audit(s, "assess_change", tables, out)
139
+ return out
132
140
 
133
141
 
134
142
  @_safe
@@ -155,7 +163,16 @@ def preview_write(
155
163
 
156
164
  Returns the same shape as assess_change (with an `id` for safe_to_ship), or
157
165
  {error} if the statement is refused or fails."""
158
- return get_sentry().preview_write(sql, target, keys=keys)
166
+ s = get_sentry()
167
+ _gate(s, "preview_write", [target])
168
+ # Every table the statement reads must be allowed too (a subquery, MERGE USING, a
169
+ # join or a CTE could otherwise turn the counts into facts about a forbidden table).
170
+ _gate_sql(s, "preview_write", [target], sql.replace("{{target}}", target))
171
+ raw = s.preview_write(sql, target, keys=keys)
172
+ a = s.get_assessment(raw["id"])
173
+ out = agent_view.for_agent(a, s, {"preview": raw.get("preview")}) if a else agent_view.scrub(raw)
174
+ agent_view.audit(s, "preview_write", [target], out)
175
+ return out
159
176
 
160
177
 
161
178
  @_safe
@@ -181,12 +198,16 @@ def explain_diff(
181
198
  a = s.get_assessment(assessment_id)
182
199
  if a is None:
183
200
  return {"error": f"unknown assessment id {assessment_id}"}
184
- return {"assessment_id": a.id, "explanations": {t.table: t.summary for t in a.tables}}
201
+ _gate(s, "explain_diff", [t.table for t in a.tables])
202
+ safe = agent_view.for_agent(a, s)
203
+ return {"assessment_id": a.id, "explanations": {t["table"]: t["summary"] for t in safe["tables"]}}
185
204
  if table:
205
+ _gate(s, "explain_diff", [table])
186
206
  d = s.get_diff(table)
187
207
  if d is None:
188
208
  return {"error": f"no diff for {table} yet; call assess_change or preview_write first"}
189
- return {"table": table, "explanation": _explain_diff(d, s.config.spec(table).measures)}
209
+ return {"table": table,
210
+ "explanation": _explain_diff(d, s.config.spec(table).measures, for_agent=True)}
190
211
  return {"error": "pass assessment_id or table"}
191
212
 
192
213
 
@@ -205,15 +226,17 @@ def safe_to_ship(
205
226
  Returns {assessment_id, safe_to_ship: bool, verdict, risk_tier, rule_hits:
206
227
  [{rule, verdict, table, reason}], notify, next_step}, or {error} if the id
207
228
  is unknown."""
208
- a = get_sentry().get_assessment(assessment_id)
229
+ s = get_sentry()
230
+ a = s.get_assessment(assessment_id)
209
231
  if a is None:
210
232
  return {"error": f"unknown assessment id {assessment_id}"}
233
+ _gate(s, "safe_to_ship", [t.table for t in a.tables])
211
234
  v = a.verdict.value
212
235
  next_step = {
213
236
  "pass": "Proceed: open or merge the pull request.",
214
237
  "warn": "Proceed, but include the warnings in the pull request description.",
215
238
  "needs_human": "Do not merge. Open the pull request with the report and request review from: "
216
- + (", ".join(a.notify) or "a data owner") + ".",
239
+ + (", ".join(str(agent_view._plain(n)) for n in a.notify) or "a data owner") + ".",
217
240
  "block": "Stop. Fix the blocking issues listed in rule_hits, rebuild the candidate and assess again.",
218
241
  }[v]
219
242
  return {
@@ -221,8 +244,8 @@ def safe_to_ship(
221
244
  "safe_to_ship": v in ("pass", "warn"),
222
245
  "verdict": v,
223
246
  "risk_tier": a.verdict.risk_tier,
224
- "rule_hits": [h.to_dict() for h in a.hits],
225
- "notify": a.notify,
247
+ "rule_hits": agent_view.scrub([h.to_dict() for h in a.hits], "rule_hits"),
248
+ "notify": [agent_view._plain(n) for n in a.notify],
226
249
  "next_step": next_step,
227
250
  }
228
251
 
@@ -250,6 +273,22 @@ def rollback_plan(
250
273
  }
251
274
 
252
275
 
276
+ def _gate_sql(s: Sentry, tool: str, tables: list[str], sql: str) -> None:
277
+ try:
278
+ agent_view.check_statement(s, sql)
279
+ except PermissionError as e:
280
+ agent_view.audit(s, tool, tables, refused=str(e))
281
+ raise
282
+
283
+
284
+ def _gate(s: Sentry, tool: str, tables: list[str]) -> None:
285
+ try:
286
+ agent_view.check_allowed(s, tables)
287
+ except PermissionError as e:
288
+ agent_view.audit(s, tool, tables, refused=str(e))
289
+ raise
290
+
291
+
253
292
  def _not_found(table: str) -> str:
254
293
  return (f"Table {table} not found. Check the catalog, schema and table name (they must match "
255
294
  "Unity Catalog exactly) and that you have SELECT on it.")