bricksentry 0.1.27__tar.gz → 0.1.29__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.
- {bricksentry-0.1.27 → bricksentry-0.1.29}/CHANGELOG.md +21 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/PKG-INFO +28 -8
- {bricksentry-0.1.27 → bricksentry-0.1.29}/README.md +25 -6
- bricksentry-0.1.29/deploy/databricks-app/requirements.txt +1 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/examples/databricks/bricksentry_validation.ipynb +1 -1
- {bricksentry-0.1.27 → bricksentry-0.1.29}/examples/databricks/bricksentry_validation.py +1 -1
- {bricksentry-0.1.27 → bricksentry-0.1.29}/pyproject.toml +3 -2
- {bricksentry-0.1.27 → bricksentry-0.1.29}/server.json +2 -2
- {bricksentry-0.1.27 → bricksentry-0.1.29}/src/bricksentry/__init__.py +1 -1
- {bricksentry-0.1.27 → bricksentry-0.1.29}/src/bricksentry/agent_tools.py +41 -5
- bricksentry-0.1.29/src/bricksentry/agent_view.py +375 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/src/bricksentry/backends/base.py +23 -2
- {bricksentry-0.1.27 → bricksentry-0.1.29}/src/bricksentry/backends/databricks_backend.py +117 -1
- {bricksentry-0.1.27 → bricksentry-0.1.29}/src/bricksentry/backends/duckdb_backend.py +26 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/src/bricksentry/changes.py +20 -7
- {bricksentry-0.1.27 → bricksentry-0.1.29}/src/bricksentry/cli.py +22 -6
- {bricksentry-0.1.27 → bricksentry-0.1.29}/src/bricksentry/diff.py +49 -21
- {bricksentry-0.1.27 → bricksentry-0.1.29}/src/bricksentry/explain.py +3 -2
- bricksentry-0.1.29/src/bricksentry/mcp_server.py +192 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/src/bricksentry/models.py +3 -1
- {bricksentry-0.1.27 → bricksentry-0.1.29}/src/bricksentry/policy.py +4 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/src/bricksentry/validation.py +26 -1
- {bricksentry-0.1.27 → bricksentry-0.1.29}/templates/job-check/databricks_template_schema.json +2 -2
- {bricksentry-0.1.27 → bricksentry-0.1.29}/tests/test_0110.py +2 -1
- {bricksentry-0.1.27 → bricksentry-0.1.29}/tests/test_0123.py +1 -1
- {bricksentry-0.1.27 → bricksentry-0.1.29}/tests/test_0127.py +4 -4
- bricksentry-0.1.29/tests/test_0128.py +235 -0
- bricksentry-0.1.29/tests/test_0129.py +235 -0
- bricksentry-0.1.27/deploy/databricks-app/requirements.txt +0 -1
- bricksentry-0.1.27/src/bricksentry/agent_view.py +0 -125
- bricksentry-0.1.27/src/bricksentry/mcp_server.py +0 -110
- {bricksentry-0.1.27 → bricksentry-0.1.29}/.gitignore +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/CONTRIBUTING.md +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/LICENSE +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/SECURITY.md +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/action.yml +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/deploy/container/Dockerfile +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/deploy/databricks-app/README.md +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/deploy/databricks-app/app.yaml +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/deploy/databricks-app/bricksentry.yml +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/deploy/databricks-app/databricks.yml +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/deploy/databricks-app/grants.sql +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/examples/databricks/bricksentry.yml +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/examples/databricks/bricksentry_check_my_table.ipynb +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/examples/databricks/bricksentry_check_my_table.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/examples/databricks/bricksentry_hr_walkthrough.ipynb +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/examples/databricks/bricksentry_hr_walkthrough.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/examples/databricks/bricksentry_quickstart.ipynb +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/examples/databricks/bricksentry_quickstart.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/examples/databricks/github-workflow.yml +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/examples/databricks/policy.yml +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/examples/demo/agent_loop_demo.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/scripts/build_notebook.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/scripts/render_demo_image.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/src/bricksentry/__main__.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/src/bricksentry/assess.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/src/bricksentry/backends/__init__.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/src/bricksentry/config.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/src/bricksentry/demo.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/src/bricksentry/github.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/src/bricksentry/history.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/src/bricksentry/job.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/src/bricksentry/job_demo.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/src/bricksentry/lineage.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/src/bricksentry/measures.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/src/bricksentry/netguard.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/src/bricksentry/notify.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/src/bricksentry/policy_templates.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/src/bricksentry/preview.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/src/bricksentry/py.typed +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/src/bricksentry/report.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/templates/job-check/README.md +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/templates/job-check/template/{{.project_name}}/.gitignore +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/templates/job-check/template/{{.project_name}}/README.md.tmpl +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/templates/job-check/template/{{.project_name}}/databricks.yml.tmpl +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/templates/job-check/template/{{.project_name}}/resources/bricksentry_check.job.yml.tmpl +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/templates/job-check/template/{{.project_name}}/src/bricksentry_check.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/templates/job-check/template/{{.project_name}}/src/bricksentry_demo.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/tests/conftest.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/tests/test_0112.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/tests/test_0114.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/tests/test_0120.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/tests/test_0121.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/tests/test_0122.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/tests/test_0126.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/tests/test_018.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/tests/test_019.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/tests/test_assess_policy.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/tests/test_check_notebook.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/tests/test_databricks_and_uc.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/tests/test_demo.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/tests/test_diff.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/tests/test_hr_notebook.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/tests/test_notebook.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/tests/test_notify_templates.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/tests/test_preview_agents.py +0 -0
- {bricksentry-0.1.27 → bricksentry-0.1.29}/tests/test_sample_guard_and_store.py +0 -0
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.29 (2026-11-17)
|
|
4
|
+
|
|
5
|
+
Closes the last known way around `agent_tables`, and bricksentry enters public beta. Verified on Databricks before release: every view and function attack refused (a view over a forbidden table, a view over that view, a function with and without a schema, a view as candidate), legitimate views, functions, MERGE, UPDATE and INSERT previews ran with exact counts, and the 15-scenario battery passed 15 of 15.
|
|
6
|
+
|
|
7
|
+
- **Views and SQL functions are held to `agent_tables`.** A listed view over an unlisted table, or a SQL function whose body reads one (`SET x = get_secret()`), let an agent's preview read that table and learn its row counts (values stayed hidden). bricksentry now reads every view's definition and every user function's body from Unity Catalog (`system.information_schema.views` and `.routines`) and checks the tables inside, recursively; an unqualified function name is matched in every schema. A definition that can't be read, or a catalog that can't be read, means the preview is refused. Found in the pre-release check of the plan check below, which can't see inside views or functions on serverless.
|
|
8
|
+
- **A second opinion from the engine's query plan.** On Databricks, before an agent's preview runs, bricksentry also runs `EXPLAIN EXTENDED` (planning only); if the plan names a table that isn't in `agent_tables`, the preview is refused. Plan formats vary on serverless (compact plans; tables inside views and functions aren't shown), so a plan that can't be read doesn't block a preview: the parser and the view and function definitions are the boundary. Found in the pre-release check: a hard plan gate refused legitimate agent MERGEs.
|
|
9
|
+
- **Faster pinned diffs.** Reading the schema at the pinned version now doubles as the time-travel probe, and only the candidate's version is re-checked afterwards (a pinned base can't affect the result), so each diff runs three fewer metadata queries. A base that moves during the check is no longer noted, because its pinned reads are unaffected.
|
|
10
|
+
- bricksentry is now in **public beta**: the package is marked Beta, and the README says what you can rely on during the beta and what may still change before 1.0.
|
|
11
|
+
|
|
12
|
+
## 0.1.28 (2026-11-17)
|
|
13
|
+
|
|
14
|
+
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.
|
|
15
|
+
|
|
16
|
+
- **`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.
|
|
17
|
+
- **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`).
|
|
18
|
+
- **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.
|
|
19
|
+
- **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.
|
|
20
|
+
- `assess --from-git` gives one clear line (exit 2) when git fails or isn't installed, instead of a traceback.
|
|
21
|
+
- Quoted-value redaction in agent errors no longer eats apostrophes in words ("can't") and catches values that contain one ('O'Brien').
|
|
22
|
+
- New validation scenario `agent_allowlist` (the battery is now 15).
|
|
23
|
+
|
|
3
24
|
## 0.1.27 (2026-11-17)
|
|
4
25
|
|
|
5
26
|
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.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: bricksentry
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.29
|
|
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
|
|
@@ -11,7 +11,7 @@ Author: Brahma
|
|
|
11
11
|
License-Expression: Apache-2.0
|
|
12
12
|
License-File: LICENSE
|
|
13
13
|
Keywords: ai-agents,change-impact-analysis,ci,data-diff,data-engineering,data-quality,databricks,delta-lake,deployment-guardrails,impact-analysis,lineage,mcp,rollback,unity-catalog
|
|
14
|
-
Classifier: Development Status ::
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
15
|
Classifier: Intended Audience :: Developers
|
|
16
16
|
Classifier: Operating System :: OS Independent
|
|
17
17
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -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'
|
|
@@ -49,7 +50,7 @@ Description-Content-Type: text/markdown
|
|
|
49
50
|
|
|
50
51
|
<!-- mcp-name: io.github.bricksentry/bricksentry -->
|
|
51
52
|
|
|
52
|
-
[](https://pypi.org/project/bricksentry/) [](https://pypi.org/project/bricksentry/) [](https://github.com/bricksentry/bricksentry/actions/workflows/ci.yml) [](https://github.com/bricksentry/bricksentry/actions/workflows/lint.yml) [](https://github.com/bricksentry/bricksentry/actions/workflows/ci.yml) [](LICENSE)
|
|
53
|
+
[](https://pypi.org/project/bricksentry/) [](https://pypi.org/project/bricksentry/) [](https://github.com/bricksentry/bricksentry/actions/workflows/ci.yml) [](https://github.com/bricksentry/bricksentry/actions/workflows/lint.yml) [](https://github.com/bricksentry/bricksentry/actions/workflows/ci.yml) [](LICENSE) [](#project-status-public-beta)
|
|
53
54
|
|
|
54
55
|
***The safety check for data changes in the AI era.***
|
|
55
56
|
|
|
@@ -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
|
|
|
@@ -212,13 +213,15 @@ bricksentry usually runs with more read access than the agent that calls it, so
|
|
|
212
213
|
|
|
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.
|
|
214
215
|
|
|
215
|
-
**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
|
|
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:
|
|
216
217
|
|
|
217
218
|
```yaml
|
|
218
219
|
agent_tables: ["main.sales_dev.*", "main.sales.orders"] # globs, any case; others are refused
|
|
219
220
|
```
|
|
220
221
|
|
|
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. Views and SQL functions are checked through their definitions: bricksentry reads each view's query and each SQL function's body from Unity Catalog (`system.information_schema`) and holds every table inside them to the list too, recursively. A view or function whose definition can't be read is refused, and so is every agent preview if the catalog can't be read at all. A listed view over an unlisted table counts as the unlisted table. On Databricks, the statement's query plan (`EXPLAIN`, which runs nothing) is a second opinion: an unlisted table in it means refusal, but because plan formats vary on serverless, a plan that can't be read doesn't block anything. 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.
|
|
222
225
|
|
|
223
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.
|
|
224
227
|
|
|
@@ -396,6 +399,8 @@ lineage:
|
|
|
396
399
|
|
|
397
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.
|
|
398
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
|
+
|
|
399
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.
|
|
400
405
|
|
|
401
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.
|
|
@@ -478,18 +483,33 @@ Without lineage access bricksentry still diffs, and adds a `lineage-unavailable`
|
|
|
478
483
|
|
|
479
484
|
## What a check costs
|
|
480
485
|
|
|
481
|
-
The work runs on your SQL warehouse as plain SQL; nothing large is copied out. One table diff runs about five queries (plus
|
|
486
|
+
The work runs on your SQL warehouse as plain SQL; nothing large is copied out. One table diff runs about five queries (plus three or four 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`.
|
|
482
487
|
|
|
483
488
|
## Audit trail
|
|
484
489
|
|
|
485
490
|
Every assessment records when it ran (UTC), the bricksentry version, a SHA-256 fingerprint of the policy rules that produced the verdict, and who triggered it (`BRICKSENTRY_ACTOR`, or the GitHub actor in GitHub Actions). They're in the JSON and in the footer of the pull-request report, so a verdict can be traced to the exact rules behind it. Assessments are saved as JSON under `assessment_store`; point it at a shared, access-controlled folder to keep a history.
|
|
486
491
|
|
|
492
|
+
## Project status: public beta
|
|
493
|
+
|
|
494
|
+
bricksentry is in **public beta** (0.1.x). It has been tested hard but only by its author, on Databricks Free Edition: nine adversarial rounds with every serious finding fixed and re-verified ([VALIDATION.md](VALIDATION.md)). It has not yet run on other teams' production pipelines, other clouds or classic compute, which is what the beta is for.
|
|
495
|
+
|
|
496
|
+
**What you can rely on in the beta:**
|
|
497
|
+
|
|
498
|
+
- **The safety direction.** When bricksentry can't verify something (a failed diff, a missing candidate, a masked column, a row filter, a table rewritten during the check), it asks a human. It never turns "couldn't check" into a pass.
|
|
499
|
+
- **Production is never written** by `preview_write` or any check: previews run on disposable shallow clones, and refused statements stay refused.
|
|
500
|
+
- **What agents see:** counts, columns and verdicts, never production values, and only for the tables in `agent_tables`.
|
|
501
|
+
- **Your files keep working.** `bricksentry.yml`, policy files and saved assessments from earlier 0.1.x releases load in later ones (checked back to 0.1.15). Any change in behavior is marked **Behavior change** in the [changelog](CHANGELOG.md).
|
|
502
|
+
|
|
503
|
+
**What may still change before 1.0:** default policy rules, the wording of reasons and summaries, fields added to JSON output (fields aren't removed or renamed without a changelog note), and defaults such as whether `agent_tables` is required for agents.
|
|
504
|
+
|
|
505
|
+
**1.0** comes when two or three outside teams have run it on real pipelines for a month without a serious finding, with validation reports from at least two clouds. If you'd like to be one of them, [open an issue](https://github.com/bricksentry/bricksentry/issues) or run the [validation notebook](examples/databricks/bricksentry_validation.py) and [share the report](https://github.com/bricksentry/bricksentry/issues/new?template=validation_report.yml).
|
|
506
|
+
|
|
487
507
|
## Known limits (v0.1.x)
|
|
488
508
|
|
|
489
509
|
- **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.
|
|
490
510
|
- **Keys are required.** Tables without a stable key can't be diffed row by row yet (an aggregate-profile mode is planned).
|
|
491
511
|
- **Changed-table detection uses path globs** from config. It doesn't parse Asset Bundles yet.
|
|
492
|
-
- **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.
|
|
512
|
+
- **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, 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.
|
|
493
513
|
|
|
494
514
|
## Roadmap
|
|
495
515
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
<!-- mcp-name: io.github.bricksentry/bricksentry -->
|
|
4
4
|
|
|
5
|
-
[](https://pypi.org/project/bricksentry/) [](https://pypi.org/project/bricksentry/) [](https://github.com/bricksentry/bricksentry/actions/workflows/ci.yml) [](https://github.com/bricksentry/bricksentry/actions/workflows/lint.yml) [](https://github.com/bricksentry/bricksentry/actions/workflows/ci.yml) [](LICENSE)
|
|
5
|
+
[](https://pypi.org/project/bricksentry/) [](https://pypi.org/project/bricksentry/) [](https://github.com/bricksentry/bricksentry/actions/workflows/ci.yml) [](https://github.com/bricksentry/bricksentry/actions/workflows/lint.yml) [](https://github.com/bricksentry/bricksentry/actions/workflows/ci.yml) [](LICENSE) [](#project-status-public-beta)
|
|
6
6
|
|
|
7
7
|
***The safety check for data changes in the AI era.***
|
|
8
8
|
|
|
@@ -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
|
|
|
@@ -165,13 +165,15 @@ bricksentry usually runs with more read access than the agent that calls it, so
|
|
|
165
165
|
|
|
166
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
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
|
|
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
169
|
|
|
170
170
|
```yaml
|
|
171
171
|
agent_tables: ["main.sales_dev.*", "main.sales.orders"] # globs, any case; others are refused
|
|
172
172
|
```
|
|
173
173
|
|
|
174
|
-
|
|
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. Views and SQL functions are checked through their definitions: bricksentry reads each view's query and each SQL function's body from Unity Catalog (`system.information_schema`) and holds every table inside them to the list too, recursively. A view or function whose definition can't be read is refused, and so is every agent preview if the catalog can't be read at all. A listed view over an unlisted table counts as the unlisted table. On Databricks, the statement's query plan (`EXPLAIN`, which runs nothing) is a second opinion: an unlisted table in it means refusal, but because plan formats vary on serverless, a plan that can't be read doesn't block anything. 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.
|
|
175
177
|
|
|
176
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.
|
|
177
179
|
|
|
@@ -349,6 +351,8 @@ lineage:
|
|
|
349
351
|
|
|
350
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.
|
|
351
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
|
+
|
|
352
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.
|
|
353
357
|
|
|
354
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.
|
|
@@ -431,18 +435,33 @@ Without lineage access bricksentry still diffs, and adds a `lineage-unavailable`
|
|
|
431
435
|
|
|
432
436
|
## What a check costs
|
|
433
437
|
|
|
434
|
-
The work runs on your SQL warehouse as plain SQL; nothing large is copied out. One table diff runs about five queries (plus
|
|
438
|
+
The work runs on your SQL warehouse as plain SQL; nothing large is copied out. One table diff runs about five queries (plus three or four 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`.
|
|
435
439
|
|
|
436
440
|
## Audit trail
|
|
437
441
|
|
|
438
442
|
Every assessment records when it ran (UTC), the bricksentry version, a SHA-256 fingerprint of the policy rules that produced the verdict, and who triggered it (`BRICKSENTRY_ACTOR`, or the GitHub actor in GitHub Actions). They're in the JSON and in the footer of the pull-request report, so a verdict can be traced to the exact rules behind it. Assessments are saved as JSON under `assessment_store`; point it at a shared, access-controlled folder to keep a history.
|
|
439
443
|
|
|
444
|
+
## Project status: public beta
|
|
445
|
+
|
|
446
|
+
bricksentry is in **public beta** (0.1.x). It has been tested hard but only by its author, on Databricks Free Edition: nine adversarial rounds with every serious finding fixed and re-verified ([VALIDATION.md](VALIDATION.md)). It has not yet run on other teams' production pipelines, other clouds or classic compute, which is what the beta is for.
|
|
447
|
+
|
|
448
|
+
**What you can rely on in the beta:**
|
|
449
|
+
|
|
450
|
+
- **The safety direction.** When bricksentry can't verify something (a failed diff, a missing candidate, a masked column, a row filter, a table rewritten during the check), it asks a human. It never turns "couldn't check" into a pass.
|
|
451
|
+
- **Production is never written** by `preview_write` or any check: previews run on disposable shallow clones, and refused statements stay refused.
|
|
452
|
+
- **What agents see:** counts, columns and verdicts, never production values, and only for the tables in `agent_tables`.
|
|
453
|
+
- **Your files keep working.** `bricksentry.yml`, policy files and saved assessments from earlier 0.1.x releases load in later ones (checked back to 0.1.15). Any change in behavior is marked **Behavior change** in the [changelog](CHANGELOG.md).
|
|
454
|
+
|
|
455
|
+
**What may still change before 1.0:** default policy rules, the wording of reasons and summaries, fields added to JSON output (fields aren't removed or renamed without a changelog note), and defaults such as whether `agent_tables` is required for agents.
|
|
456
|
+
|
|
457
|
+
**1.0** comes when two or three outside teams have run it on real pipelines for a month without a serious finding, with validation reports from at least two clouds. If you'd like to be one of them, [open an issue](https://github.com/bricksentry/bricksentry/issues) or run the [validation notebook](examples/databricks/bricksentry_validation.py) and [share the report](https://github.com/bricksentry/bricksentry/issues/new?template=validation_report.yml).
|
|
458
|
+
|
|
440
459
|
## Known limits (v0.1.x)
|
|
441
460
|
|
|
442
461
|
- **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.
|
|
443
462
|
- **Keys are required.** Tables without a stable key can't be diffed row by row yet (an aggregate-profile mode is planned).
|
|
444
463
|
- **Changed-table detection uses path globs** from config. It doesn't parse Asset Bundles yet.
|
|
445
|
-
- **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.
|
|
464
|
+
- **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, 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.
|
|
446
465
|
|
|
447
466
|
## Roadmap
|
|
448
467
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
bricksentry[databricks,mcp]==0.1.29
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"source": [
|
|
7
7
|
"# Validate bricksentry on your own workspace\n",
|
|
8
8
|
"\n",
|
|
9
|
-
"**
|
|
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 **
|
|
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.
|
|
7
|
+
version = "0.1.29"
|
|
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"
|
|
@@ -16,7 +16,7 @@ keywords = [
|
|
|
16
16
|
"change-impact-analysis", "deployment-guardrails", "rollback",
|
|
17
17
|
]
|
|
18
18
|
classifiers = [
|
|
19
|
-
"Development Status ::
|
|
19
|
+
"Development Status :: 4 - Beta",
|
|
20
20
|
"Intended Audience :: Developers",
|
|
21
21
|
"Programming Language :: Python :: 3",
|
|
22
22
|
"Programming Language :: 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.
|
|
11
|
+
"version": "0.1.29",
|
|
12
12
|
"packages": [
|
|
13
13
|
{
|
|
14
14
|
"registryType": "pypi",
|
|
15
15
|
"identifier": "bricksentry-mcp",
|
|
16
|
-
"version": "0.1.
|
|
16
|
+
"version": "0.1.29",
|
|
17
17
|
"runtimeHint": "uvx",
|
|
18
18
|
"transport": {
|
|
19
19
|
"type": "stdio"
|
|
@@ -99,7 +99,7 @@ def whats_downstream(
|
|
|
99
99
|
out["column_tags"] = {c: col_tags[c] for c in columns if col_tags.get(c)}
|
|
100
100
|
feeds = s.lineage.column_downstream(table, list(columns), int(s.config.lineage.get("column_depth", 2)))
|
|
101
101
|
out["column_downstream"] = [c.to_dict() for c in feeds]
|
|
102
|
-
return out
|
|
102
|
+
return agent_view.scrub_metadata(out)
|
|
103
103
|
|
|
104
104
|
|
|
105
105
|
@_safe
|
|
@@ -130,7 +130,11 @@ def assess_change(
|
|
|
130
130
|
rollback}]}. Pass `id` to safe_to_ship (and optionally explain_diff)."""
|
|
131
131
|
s = get_sentry()
|
|
132
132
|
tables = list(tables)
|
|
133
|
-
|
|
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
|
+
named = tables + [c for c in (candidates or {}).values() if c]
|
|
136
|
+
_gate(s, "assess_change", named)
|
|
137
|
+
_gate_views(s, "assess_change", named) # a listed view over an unlisted table counts as that table
|
|
134
138
|
a = s.assess(tables, candidates=candidates, pr=pr)
|
|
135
139
|
out = agent_view.for_agent(a, s)
|
|
136
140
|
agent_view.audit(s, "assess_change", tables, out)
|
|
@@ -163,6 +167,10 @@ def preview_write(
|
|
|
163
167
|
{error} if the statement is refused or fails."""
|
|
164
168
|
s = get_sentry()
|
|
165
169
|
_gate(s, "preview_write", [target])
|
|
170
|
+
# Every table the statement reads must be allowed too (a subquery, MERGE USING, a
|
|
171
|
+
# join or a CTE could otherwise turn the counts into facts about a forbidden table).
|
|
172
|
+
_gate_sql(s, "preview_write", [target], sql.replace("{{target}}", target))
|
|
173
|
+
_gate_plan(s, "preview_write", target, sql.replace("{{target}}", target))
|
|
166
174
|
raw = s.preview_write(sql, target, keys=keys)
|
|
167
175
|
a = s.get_assessment(raw["id"])
|
|
168
176
|
out = agent_view.for_agent(a, s, {"preview": raw.get("preview")}) if a else agent_view.scrub(raw)
|
|
@@ -193,9 +201,11 @@ def explain_diff(
|
|
|
193
201
|
a = s.get_assessment(assessment_id)
|
|
194
202
|
if a is None:
|
|
195
203
|
return {"error": f"unknown assessment id {assessment_id}"}
|
|
204
|
+
_gate(s, "explain_diff", [t.table for t in a.tables])
|
|
196
205
|
safe = agent_view.for_agent(a, s)
|
|
197
206
|
return {"assessment_id": a.id, "explanations": {t["table"]: t["summary"] for t in safe["tables"]}}
|
|
198
207
|
if table:
|
|
208
|
+
_gate(s, "explain_diff", [table])
|
|
199
209
|
d = s.get_diff(table)
|
|
200
210
|
if d is None:
|
|
201
211
|
return {"error": f"no diff for {table} yet; call assess_change or preview_write first"}
|
|
@@ -219,15 +229,17 @@ def safe_to_ship(
|
|
|
219
229
|
Returns {assessment_id, safe_to_ship: bool, verdict, risk_tier, rule_hits:
|
|
220
230
|
[{rule, verdict, table, reason}], notify, next_step}, or {error} if the id
|
|
221
231
|
is unknown."""
|
|
222
|
-
|
|
232
|
+
s = get_sentry()
|
|
233
|
+
a = s.get_assessment(assessment_id)
|
|
223
234
|
if a is None:
|
|
224
235
|
return {"error": f"unknown assessment id {assessment_id}"}
|
|
236
|
+
_gate(s, "safe_to_ship", [t.table for t in a.tables])
|
|
225
237
|
v = a.verdict.value
|
|
226
238
|
next_step = {
|
|
227
239
|
"pass": "Proceed: open or merge the pull request.",
|
|
228
240
|
"warn": "Proceed, but include the warnings in the pull request description.",
|
|
229
241
|
"needs_human": "Do not merge. Open the pull request with the report and request review from: "
|
|
230
|
-
+ (", ".join(a.notify) or "a data owner") + ".",
|
|
242
|
+
+ (", ".join(str(agent_view._plain(n)) for n in a.notify) or "a data owner") + ".",
|
|
231
243
|
"block": "Stop. Fix the blocking issues listed in rule_hits, rebuild the candidate and assess again.",
|
|
232
244
|
}[v]
|
|
233
245
|
return {
|
|
@@ -236,7 +248,7 @@ def safe_to_ship(
|
|
|
236
248
|
"verdict": v,
|
|
237
249
|
"risk_tier": a.verdict.risk_tier,
|
|
238
250
|
"rule_hits": agent_view.scrub([h.to_dict() for h in a.hits], "rule_hits"),
|
|
239
|
-
"notify": a.notify,
|
|
251
|
+
"notify": [agent_view._plain(n) for n in a.notify],
|
|
240
252
|
"next_step": next_step,
|
|
241
253
|
}
|
|
242
254
|
|
|
@@ -264,6 +276,30 @@ def rollback_plan(
|
|
|
264
276
|
}
|
|
265
277
|
|
|
266
278
|
|
|
279
|
+
def _gate_sql(s: Sentry, tool: str, tables: list[str], sql: str) -> None:
|
|
280
|
+
try:
|
|
281
|
+
agent_view.check_statement(s, sql)
|
|
282
|
+
except PermissionError as e:
|
|
283
|
+
agent_view.audit(s, tool, tables, refused=str(e))
|
|
284
|
+
raise
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
def _gate_views(s: Sentry, tool: str, tables: list[str]) -> None:
|
|
288
|
+
try:
|
|
289
|
+
agent_view.check_definitions(s, tables, [])
|
|
290
|
+
except PermissionError as e:
|
|
291
|
+
agent_view.audit(s, tool, tables, refused=str(e))
|
|
292
|
+
raise
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
def _gate_plan(s: Sentry, tool: str, target: str, sql: str) -> None:
|
|
296
|
+
try:
|
|
297
|
+
agent_view.check_plan(s, sql, target)
|
|
298
|
+
except PermissionError as e:
|
|
299
|
+
agent_view.audit(s, tool, [target], refused=str(e))
|
|
300
|
+
raise
|
|
301
|
+
|
|
302
|
+
|
|
267
303
|
def _gate(s: Sentry, tool: str, tables: list[str]) -> None:
|
|
268
304
|
try:
|
|
269
305
|
agent_view.check_allowed(s, tables)
|