bricksentry 0.1.34__tar.gz → 0.1.36__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 (119) hide show
  1. bricksentry-0.1.36/.agents/plugins/marketplace.json +20 -0
  2. bricksentry-0.1.36/.claude-plugin/marketplace.json +15 -0
  3. bricksentry-0.1.36/.cursor-plugin/marketplace.json +15 -0
  4. {bricksentry-0.1.34 → bricksentry-0.1.36}/CHANGELOG.md +22 -0
  5. {bricksentry-0.1.34 → bricksentry-0.1.36}/PKG-INFO +36 -2
  6. {bricksentry-0.1.34 → bricksentry-0.1.36}/README.md +35 -1
  7. bricksentry-0.1.36/deploy/databricks-app/requirements.txt +1 -0
  8. {bricksentry-0.1.34 → bricksentry-0.1.36}/examples/databricks/policy.yml +1 -0
  9. bricksentry-0.1.36/plugins/bricksentry/.claude-plugin/plugin.json +23 -0
  10. bricksentry-0.1.36/plugins/bricksentry/.codex-plugin/plugin.json +43 -0
  11. bricksentry-0.1.36/plugins/bricksentry/.cursor-plugin/plugin.json +23 -0
  12. bricksentry-0.1.36/plugins/bricksentry/.mcp.json +15 -0
  13. bricksentry-0.1.36/plugins/bricksentry/README.md +58 -0
  14. bricksentry-0.1.36/plugins/bricksentry/assets/icon.png +0 -0
  15. bricksentry-0.1.36/plugins/bricksentry/mcp.json +15 -0
  16. bricksentry-0.1.36/plugins/bricksentry/skills/bricksentry-safe-write/SKILL.md +101 -0
  17. bricksentry-0.1.36/plugins/bricksentry/skills/bricksentry-safe-write/references/setup.md +69 -0
  18. {bricksentry-0.1.34 → bricksentry-0.1.36}/pyproject.toml +2 -2
  19. {bricksentry-0.1.34 → bricksentry-0.1.36}/server.json +2 -2
  20. bricksentry-0.1.36/skills/bricksentry-safe-write/SKILL.md +101 -0
  21. bricksentry-0.1.36/skills/bricksentry-safe-write/references/setup.md +69 -0
  22. {bricksentry-0.1.34 → bricksentry-0.1.36}/src/bricksentry/__init__.py +1 -1
  23. {bricksentry-0.1.34 → bricksentry-0.1.36}/src/bricksentry/agent_tools.py +49 -8
  24. {bricksentry-0.1.34 → bricksentry-0.1.36}/src/bricksentry/assess.py +35 -7
  25. {bricksentry-0.1.34 → bricksentry-0.1.36}/src/bricksentry/backends/base.py +39 -0
  26. {bricksentry-0.1.34 → bricksentry-0.1.36}/src/bricksentry/backends/databricks_backend.py +123 -8
  27. {bricksentry-0.1.34 → bricksentry-0.1.36}/src/bricksentry/config.py +13 -6
  28. {bricksentry-0.1.34 → bricksentry-0.1.36}/src/bricksentry/diff.py +19 -0
  29. {bricksentry-0.1.34 → bricksentry-0.1.36}/src/bricksentry/explain.py +3 -0
  30. {bricksentry-0.1.34 → bricksentry-0.1.36}/src/bricksentry/mcp_server.py +22 -0
  31. {bricksentry-0.1.34 → bricksentry-0.1.36}/src/bricksentry/models.py +5 -0
  32. {bricksentry-0.1.34 → bricksentry-0.1.36}/src/bricksentry/policy.py +14 -1
  33. {bricksentry-0.1.34 → bricksentry-0.1.36}/src/bricksentry/policy_templates.py +3 -0
  34. {bricksentry-0.1.34 → bricksentry-0.1.36}/templates/job-check/databricks_template_schema.json +2 -2
  35. {bricksentry-0.1.34 → bricksentry-0.1.36}/tests/test_0110.py +7 -0
  36. bricksentry-0.1.36/tests/test_0135.py +82 -0
  37. bricksentry-0.1.36/tests/test_0136.py +291 -0
  38. bricksentry-0.1.36/tests/test_plugin.py +84 -0
  39. bricksentry-0.1.36/tests/test_skill.py +57 -0
  40. bricksentry-0.1.34/deploy/databricks-app/requirements.txt +0 -1
  41. {bricksentry-0.1.34 → bricksentry-0.1.36}/.gitignore +0 -0
  42. {bricksentry-0.1.34 → bricksentry-0.1.36}/CONTRIBUTING.md +0 -0
  43. {bricksentry-0.1.34 → bricksentry-0.1.36}/LICENSE +0 -0
  44. {bricksentry-0.1.34 → bricksentry-0.1.36}/SECURITY.md +0 -0
  45. {bricksentry-0.1.34 → bricksentry-0.1.36}/action.yml +0 -0
  46. {bricksentry-0.1.34 → bricksentry-0.1.36}/deploy/container/Dockerfile +0 -0
  47. {bricksentry-0.1.34 → bricksentry-0.1.36}/deploy/databricks-app/README.md +0 -0
  48. {bricksentry-0.1.34 → bricksentry-0.1.36}/deploy/databricks-app/app.yaml +0 -0
  49. {bricksentry-0.1.34 → bricksentry-0.1.36}/deploy/databricks-app/bricksentry.yml +0 -0
  50. {bricksentry-0.1.34 → bricksentry-0.1.36}/deploy/databricks-app/databricks.yml +0 -0
  51. {bricksentry-0.1.34 → bricksentry-0.1.36}/deploy/databricks-app/grants.sql +0 -0
  52. {bricksentry-0.1.34 → bricksentry-0.1.36}/examples/databricks/bricksentry.yml +0 -0
  53. {bricksentry-0.1.34 → bricksentry-0.1.36}/examples/databricks/bricksentry_check_my_table.ipynb +0 -0
  54. {bricksentry-0.1.34 → bricksentry-0.1.36}/examples/databricks/bricksentry_check_my_table.py +0 -0
  55. {bricksentry-0.1.34 → bricksentry-0.1.36}/examples/databricks/bricksentry_hr_walkthrough.ipynb +0 -0
  56. {bricksentry-0.1.34 → bricksentry-0.1.36}/examples/databricks/bricksentry_hr_walkthrough.py +0 -0
  57. {bricksentry-0.1.34 → bricksentry-0.1.36}/examples/databricks/bricksentry_quickstart.ipynb +0 -0
  58. {bricksentry-0.1.34 → bricksentry-0.1.36}/examples/databricks/bricksentry_quickstart.py +0 -0
  59. {bricksentry-0.1.34 → bricksentry-0.1.36}/examples/databricks/bricksentry_validation.ipynb +0 -0
  60. {bricksentry-0.1.34 → bricksentry-0.1.36}/examples/databricks/bricksentry_validation.py +0 -0
  61. {bricksentry-0.1.34 → bricksentry-0.1.36}/examples/databricks/github-workflow.yml +0 -0
  62. {bricksentry-0.1.34 → bricksentry-0.1.36}/examples/demo/agent_loop_demo.py +0 -0
  63. {bricksentry-0.1.34 → bricksentry-0.1.36}/scripts/build_notebook.py +0 -0
  64. {bricksentry-0.1.34 → bricksentry-0.1.36}/scripts/render_demo_image.py +0 -0
  65. {bricksentry-0.1.34 → bricksentry-0.1.36}/src/bricksentry/__main__.py +0 -0
  66. {bricksentry-0.1.34 → bricksentry-0.1.36}/src/bricksentry/agent_view.py +0 -0
  67. {bricksentry-0.1.34 → bricksentry-0.1.36}/src/bricksentry/backends/__init__.py +0 -0
  68. {bricksentry-0.1.34 → bricksentry-0.1.36}/src/bricksentry/backends/duckdb_backend.py +0 -0
  69. {bricksentry-0.1.34 → bricksentry-0.1.36}/src/bricksentry/changes.py +0 -0
  70. {bricksentry-0.1.34 → bricksentry-0.1.36}/src/bricksentry/cleanup.py +0 -0
  71. {bricksentry-0.1.34 → bricksentry-0.1.36}/src/bricksentry/cli.py +0 -0
  72. {bricksentry-0.1.34 → bricksentry-0.1.36}/src/bricksentry/demo.py +0 -0
  73. {bricksentry-0.1.34 → bricksentry-0.1.36}/src/bricksentry/github.py +0 -0
  74. {bricksentry-0.1.34 → bricksentry-0.1.36}/src/bricksentry/governed.py +0 -0
  75. {bricksentry-0.1.34 → bricksentry-0.1.36}/src/bricksentry/history.py +0 -0
  76. {bricksentry-0.1.34 → bricksentry-0.1.36}/src/bricksentry/job.py +0 -0
  77. {bricksentry-0.1.34 → bricksentry-0.1.36}/src/bricksentry/job_demo.py +0 -0
  78. {bricksentry-0.1.34 → bricksentry-0.1.36}/src/bricksentry/lineage.py +0 -0
  79. {bricksentry-0.1.34 → bricksentry-0.1.36}/src/bricksentry/measures.py +0 -0
  80. {bricksentry-0.1.34 → bricksentry-0.1.36}/src/bricksentry/netguard.py +0 -0
  81. {bricksentry-0.1.34 → bricksentry-0.1.36}/src/bricksentry/notify.py +0 -0
  82. {bricksentry-0.1.34 → bricksentry-0.1.36}/src/bricksentry/preview.py +0 -0
  83. {bricksentry-0.1.34 → bricksentry-0.1.36}/src/bricksentry/py.typed +0 -0
  84. {bricksentry-0.1.34 → bricksentry-0.1.36}/src/bricksentry/report.py +0 -0
  85. {bricksentry-0.1.34 → bricksentry-0.1.36}/src/bricksentry/validation.py +0 -0
  86. {bricksentry-0.1.34 → bricksentry-0.1.36}/templates/job-check/README.md +0 -0
  87. {bricksentry-0.1.34 → bricksentry-0.1.36}/templates/job-check/template/{{.project_name}}/.gitignore +0 -0
  88. {bricksentry-0.1.34 → bricksentry-0.1.36}/templates/job-check/template/{{.project_name}}/README.md.tmpl +0 -0
  89. {bricksentry-0.1.34 → bricksentry-0.1.36}/templates/job-check/template/{{.project_name}}/databricks.yml.tmpl +0 -0
  90. {bricksentry-0.1.34 → bricksentry-0.1.36}/templates/job-check/template/{{.project_name}}/resources/bricksentry_check.job.yml.tmpl +0 -0
  91. {bricksentry-0.1.34 → bricksentry-0.1.36}/templates/job-check/template/{{.project_name}}/src/bricksentry_check.py +0 -0
  92. {bricksentry-0.1.34 → bricksentry-0.1.36}/templates/job-check/template/{{.project_name}}/src/bricksentry_demo.py +0 -0
  93. {bricksentry-0.1.34 → bricksentry-0.1.36}/tests/conftest.py +0 -0
  94. {bricksentry-0.1.34 → bricksentry-0.1.36}/tests/test_0112.py +0 -0
  95. {bricksentry-0.1.34 → bricksentry-0.1.36}/tests/test_0114.py +0 -0
  96. {bricksentry-0.1.34 → bricksentry-0.1.36}/tests/test_0120.py +0 -0
  97. {bricksentry-0.1.34 → bricksentry-0.1.36}/tests/test_0121.py +0 -0
  98. {bricksentry-0.1.34 → bricksentry-0.1.36}/tests/test_0122.py +0 -0
  99. {bricksentry-0.1.34 → bricksentry-0.1.36}/tests/test_0123.py +0 -0
  100. {bricksentry-0.1.34 → bricksentry-0.1.36}/tests/test_0126.py +0 -0
  101. {bricksentry-0.1.34 → bricksentry-0.1.36}/tests/test_0127.py +0 -0
  102. {bricksentry-0.1.34 → bricksentry-0.1.36}/tests/test_0128.py +0 -0
  103. {bricksentry-0.1.34 → bricksentry-0.1.36}/tests/test_0129.py +0 -0
  104. {bricksentry-0.1.34 → bricksentry-0.1.36}/tests/test_0130.py +0 -0
  105. {bricksentry-0.1.34 → bricksentry-0.1.36}/tests/test_0131.py +0 -0
  106. {bricksentry-0.1.34 → bricksentry-0.1.36}/tests/test_0132.py +0 -0
  107. {bricksentry-0.1.34 → bricksentry-0.1.36}/tests/test_0134.py +0 -0
  108. {bricksentry-0.1.34 → bricksentry-0.1.36}/tests/test_018.py +0 -0
  109. {bricksentry-0.1.34 → bricksentry-0.1.36}/tests/test_019.py +0 -0
  110. {bricksentry-0.1.34 → bricksentry-0.1.36}/tests/test_assess_policy.py +0 -0
  111. {bricksentry-0.1.34 → bricksentry-0.1.36}/tests/test_check_notebook.py +0 -0
  112. {bricksentry-0.1.34 → bricksentry-0.1.36}/tests/test_databricks_and_uc.py +0 -0
  113. {bricksentry-0.1.34 → bricksentry-0.1.36}/tests/test_demo.py +0 -0
  114. {bricksentry-0.1.34 → bricksentry-0.1.36}/tests/test_diff.py +0 -0
  115. {bricksentry-0.1.34 → bricksentry-0.1.36}/tests/test_hr_notebook.py +0 -0
  116. {bricksentry-0.1.34 → bricksentry-0.1.36}/tests/test_notebook.py +0 -0
  117. {bricksentry-0.1.34 → bricksentry-0.1.36}/tests/test_notify_templates.py +0 -0
  118. {bricksentry-0.1.34 → bricksentry-0.1.36}/tests/test_preview_agents.py +0 -0
  119. {bricksentry-0.1.34 → bricksentry-0.1.36}/tests/test_sample_guard_and_store.py +0 -0
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "bricksentry",
3
+ "interface": {
4
+ "displayName": "bricksentry"
5
+ },
6
+ "plugins": [
7
+ {
8
+ "name": "bricksentry",
9
+ "source": {
10
+ "source": "local",
11
+ "path": "./plugins/bricksentry"
12
+ },
13
+ "policy": {
14
+ "installation": "AVAILABLE",
15
+ "authentication": "ON_INSTALL"
16
+ },
17
+ "category": "Data"
18
+ }
19
+ ]
20
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "bricksentry",
3
+ "owner": {
4
+ "name": "bricksentry",
5
+ "url": "https://bricksentry.org"
6
+ },
7
+ "description": "bricksentry: change-safety checks for Databricks pipelines and AI agents.",
8
+ "plugins": [
9
+ {
10
+ "name": "bricksentry",
11
+ "source": "./plugins/bricksentry",
12
+ "description": "Check every write to a Databricks table before it runs: preview on a clone, diff the data, Unity Catalog blast radius and a policy verdict. Adds the bricksentry MCP server and the bricksentry-safe-write skill."
13
+ }
14
+ ]
15
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "bricksentry",
3
+ "owner": {
4
+ "name": "bricksentry",
5
+ "url": "https://bricksentry.org"
6
+ },
7
+ "description": "bricksentry: change-safety checks for Databricks pipelines and AI agents.",
8
+ "plugins": [
9
+ {
10
+ "name": "bricksentry",
11
+ "source": "./plugins/bricksentry",
12
+ "description": "Check every write to a Databricks table before it runs: preview on a clone, diff the data, Unity Catalog blast radius and a policy verdict. Adds the bricksentry MCP server and the bricksentry-safe-write skill."
13
+ }
14
+ ]
15
+ }
@@ -1,5 +1,27 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.36 (2026-12-01)
4
+
5
+ Found by testing the new plugin end to end in Claude Code and Codex against Databricks Free Edition.
6
+
7
+ - **An agent always gets an answer.** With the SQL warehouse stopped, a preview through Claude Code sent no reply for 34 minutes, until Claude Code gave up (the same preview took about 30 seconds from the terminal once the warehouse was running). Now:
8
+ - A stopped warehouse is started before the first query, and after a quiet spell. bricksentry waits for it at most `start_timeout_s` (300 s) and then says plainly that the warehouse isn't running, so nothing was checked. A missing or deleted warehouse is named. If the identity can't read the warehouse's state, queries go ahead as before.
9
+ - A query waiting for the warehouse (starting or busy) gives up after `queue_timeout_s` (300 s) and is cancelled; a running query keeps its own `timeout_s` (600 s). All three can be set under `backend:` in `bricksentry.yml`.
10
+ - Every MCP and agent tool call has an overall time limit of 10 minutes (`BRICKSENTRY_TOOL_TIMEOUT`, in seconds; `0` for none). Past it, the running query is cancelled and the tool returns an error saying nothing was decided. The preview clone is still dropped.
11
+ - The Databricks SDK's own retries are capped at 90 s per HTTP call (default 5 minutes), so the limits above hold. The limits are set through the SDK's `Config`, which works with the older SDK on Databricks Runtime (0.122) as well as current ones (the pre-release test in a notebook caught a first version that only worked with newer SDKs).
12
+ - The plugin gives Codex 120 s to start the server (the first `uvx` download) and 900 s per tool call; Codex's defaults are 10 s and 60 s, too short for a preview of a large table.
13
+ - **Clones left by an aborted preview are cleaned up.** When an agent gives up on a call it can stop the server mid-preview. The first preview in each server process now drops `__preview_` clones older than two hours in the scratch schema. Other tables are never touched; `bricksentry cleanup` is still there for the rest.
14
+ - **`safe_to_ship` words its next step for a direct write.** After `preview_write`, a pass says "run exactly the statement you previewed, unchanged", and needs_human and block say not to run the write. It used to talk about a pull request, which confused agents applying a direct write (seen in Codex).
15
+ - **A statement that fails on the preview clone shows the engine's error.** Databricks error messages often start with a line break, so only "Databricks query FAILED:" came through. The whole message (for example `[COLUMN_ALIASES_NOT_ALLOWED] ...`) is now on the first line, where the agent reads it. A client set-up error is no longer reported as a sign-in problem.
16
+ - **The MCP server says when there is no `bricksentry.yml`.** Started outside the project folder, every tool used to fail with a confusing message about a missing DuckDB package. Each tool now explains that no `bricksentry.yml` was found and how to fix it, and the server prints one line at start-up naming the config file and engine it will use.
17
+ - **The Agent Skill handles sandboxed agents.** Codex's shell sandbox couldn't use the Databricks sign-in, so the skill's key check (`COUNT(*)` against `COUNT(DISTINCT key)`) stopped the loop. The skill now uses a key from `bricksentry.yml` as is, and otherwise, when the agent can't run SQL, reads `duplicate_keys_base` from the preview. It also covers warehouse, missing-config and time-limit errors, and says to hand the user the exact statement when the agent can't run SQL.
18
+ - **New: a plugin for Claude Code, Codex and Cursor** (`plugins/bricksentry`). It bundles the MCP server (started with `uvx` at the pinned release) and the `bricksentry-safe-write` skill. Install in Claude Code with `/plugin marketplace add bricksentry/bricksentry` and `/plugin install bricksentry@bricksentry`. In Codex: `codex plugin marketplace add bricksentry/bricksentry` and `codex plugin add bricksentry@bricksentry`. The plugin carries the bricksentry icon. Tests keep its skill copy, version pins and three manifests in step with the package.
19
+
20
+ ## 0.1.35 (2026-11-30)
21
+
22
+ - **A key chosen too wide no longer hides duplicates.** In a Genie Code test of the new Agent Skill, the agent previewed a MERGE with `keys: [order_id, region]`, the MERGE's match columns. The MERGE inserted a second row for 25 existing order_ids; by the pair nothing repeated, so the preview said `pass`. bricksentry now also checks each column of a composite key that was unique before the change, and reports any that repeat after it (`key_column_duplicates` in the diff, and a warning in the summary). A new policy condition, `key_column_duplicates`, and rule, `key-column-duplicates`, act on it: `needs_human` in the built-in templates, `block` in `strict` and `agent-safe`. A column that already repeated (such as `order_id` in `[order_id, line_no]`) is never flagged. The extra cost is one grouped count per key column on the candidate, and on the base only when the candidate has repeats.
23
+ - **New: the `bricksentry-safe-write` Agent Skill** (`skills/bricksentry-safe-write`). It teaches coding agents (Genie Code, Claude Code, Codex, Cursor, Copilot) to check every write to an existing table with bricksentry first and follow the verdict, including how to choose the key. Tested in Genie Code: with the key rule, the agent previewed the bad MERGE, got `block` for 25 duplicate keys and left the table unchanged.
24
+
3
25
  ## 0.1.34 (2026-11-25)
4
26
 
5
27
  From GitHub code scanning (CodeQL):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: bricksentry
3
- Version: 0.1.34
3
+ Version: 0.1.36
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
@@ -245,6 +245,32 @@ databricks bundle run bricksentry_mcp
245
245
 
246
246
  Agents connect to `https://<app-url>/mcp`. The kit starts the server with `--read-only`, which leaves out `preview_write`, so the app never writes. On any other host, `bricksentry mcp --transport streamable-http --port 8000` serves the same endpoint (on 127.0.0.1 unless you pass `--host`). To run it isolated, use the container image in [`deploy/container`](deploy/container/Dockerfile): non-root, config mounted read-only. [SECURITY.md](SECURITY.md) explains what bricksentry may reach over the network. Unity Catalog *MCP Services* are for servers hosted outside Databricks, so a Databricks App is the recommended way to run bricksentry inside it; see the [kit's README](deploy/databricks-app/README.md).
247
247
 
248
+ ### One install for Claude Code, Codex and Cursor (plugin)
249
+
250
+ The [bricksentry plugin](plugins/bricksentry) bundles the MCP server and the Agent Skill below, so an agent gets both the tools and the habit in one step:
251
+
252
+ ```
253
+ /plugin marketplace add bricksentry/bricksentry
254
+ /plugin install bricksentry@bricksentry
255
+ ```
256
+
257
+ In Codex: `codex plugin marketplace add bricksentry/bricksentry`, then `codex plugin add bricksentry@bricksentry`. In Cursor, add the marketplace from this repository in the plugin settings. The plugin starts the pinned bricksentry release with [`uvx`](https://docs.astral.sh/uv/) and reads `bricksentry.yml` from your project; see the [plugin README](plugins/bricksentry/README.md) for the three setup steps.
258
+
259
+ ### Teach your coding agent the habit (Agent Skill)
260
+
261
+ [`skills/bricksentry-safe-write`](skills/bricksentry-safe-write/SKILL.md) is an [Agent Skill](https://agentskills.io): a short instruction file that tells an agent to check every write to a production table with bricksentry first. It plans with `whats_downstream`, keeps the `rollback_plan`, previews with `preview_write`, and follows `safe_to_ship` exactly: it stops on `needs_human` and `block`, and never treats an error as a pass. The same folder works in any agent that supports Agent Skills. Copy it into the agent's skills folder:
262
+
263
+ | Agent | Folder |
264
+ |---|---|
265
+ | Genie Code (Agent mode) | `/Workspace/.assistant/skills/` for everyone in the workspace, or `/Users/<you>/.assistant/skills/` for yourself |
266
+ | Claude Code | `.claude/skills/` in your project, or `~/.claude/skills/` |
267
+ | Codex | `.agents/skills/` |
268
+ | Other agents | Their skills folder; the format is the same |
269
+
270
+ An agent loads a skill when your request matches its description, so it isn't a hard rule: a general SQL skill can be picked instead. To make the check mandatory, add one line to the agent's always-on instructions (Genie Code custom instructions, `CLAUDE.md`, `AGENTS.md`): *Before any INSERT, MERGE, UPDATE or DELETE on an existing table, use the bricksentry-safe-write skill.*
271
+
272
+ The agent also needs a way to run the checks: the MCP server above, or, in a Databricks notebook, the Python functions in `bricksentry.agent_tools` ([setup](skills/bricksentry-safe-write/references/setup.md)).
273
+
248
274
  ## For data engineers: CLI and CI
249
275
 
250
276
  ```bash
@@ -392,6 +418,8 @@ tables:
392
418
  policy: policy.yml # or builtin:<template>, see "Policy templates" below
393
419
  ```
394
420
 
421
+ **Waiting on the warehouse.** A stopped SQL warehouse is started before the first query; bricksentry waits for it up to `start_timeout_s`, lets a query wait for a busy warehouse up to `queue_timeout_s`, and lets it run up to `timeout_s` (defaults 300, 300 and 600 seconds; set them under `backend:`). Each MCP or agent tool call also answers within 10 minutes (`BRICKSENTRY_TOOL_TIMEOUT` in seconds, `0` for no limit): past a limit the query is cancelled and the tool says nothing was decided.
422
+
395
423
  **Without Unity Catalog** (local DuckDB work, tests, or other platforms), give the lineage in the config instead. Edges map a table to what reads from it; column edges and tags are optional:
396
424
 
397
425
  ```yaml
@@ -439,8 +467,14 @@ rules:
439
467
  - name: duplicate-keys # a join fanned out and duplicated keys -> block the PR
440
468
  when: {duplicate_keys: true}
441
469
  then: block
470
+
471
+ - name: key-column-duplicates # with a composite key, a column that was unique now repeats
472
+ when: {key_column_duplicates: true}
473
+ then: needs_human
442
474
  ```
443
475
 
476
+ `key_column_duplicates` guards against a key chosen too wide. With `keys: [order_id, region]`, a MERGE that matches on both columns can insert a second row for an existing `order_id`; by the pair nothing repeats, so `duplicate_keys` stays quiet. bricksentry also checks each column of a composite key that was unique before the change, and this condition fires when one stops being unique. A column that already repeated (such as `order_id` in `[order_id, line_no]`) is never flagged. The built-in templates send it to a human, and `strict` and `agent-safe` block it.
477
+
444
478
  | The change | Verdict |
445
479
  |---|---|
446
480
  | A filter fix that changes 40 rows, nothing else | `pass` |
@@ -469,7 +503,7 @@ Use one directly with `policy: builtin:finance`, or write an editable copy with
469
503
 
470
504
  ### Policy conditions
471
505
 
472
- `table` (glob) · `tag` · `downstream_tag` · `downstream_kind` · `downstream_count_gt` · `removed_pct_gt` · `added_pct_gt` · `changed_pct_gt` · `row_count_change_pct_gt` · `row_count_drop_pct_gt` · `column_removed` · `column_added` · `column_type_changed` · `duplicate_keys` · `null_keys` · `sum_change_pct_gt` / `null_increase_gt` (optionally with `column`) · `changed_column` (glob) · `changed_column_tag` · `downstream_column_tag` · `any_change` · `diff_error` · `lineage_error`
506
+ `table` (glob) · `tag` · `downstream_tag` · `downstream_kind` · `downstream_count_gt` · `removed_pct_gt` · `added_pct_gt` · `changed_pct_gt` · `row_count_change_pct_gt` · `row_count_drop_pct_gt` · `column_removed` · `column_added` · `column_type_changed` · `duplicate_keys` · `key_column_duplicates` · `null_keys` · `sum_change_pct_gt` / `null_increase_gt` (optionally with `column`) · `changed_column` (glob) · `changed_column_tag` · `downstream_column_tag` · `any_change` · `diff_error` · `lineage_error`
473
507
 
474
508
  **The pii and certified gates skip changes that change nothing.** In the default policy, `pii-table` (the table is tagged `pii`) and `certified-downstream` (it feeds something tagged `certified`) fire only when the diff shows a change: rows added, removed or changed, a schema change or new duplicate keys. A rebuild identical to production passes. A failed or missing diff still counts as a possible change. To require a review of every pull request touching a PII table regardless, add a rule without `any_change`: `{name: pii-review, when: {tag: pii}, then: needs_human}`.
475
509
 
@@ -197,6 +197,32 @@ databricks bundle run bricksentry_mcp
197
197
 
198
198
  Agents connect to `https://<app-url>/mcp`. The kit starts the server with `--read-only`, which leaves out `preview_write`, so the app never writes. On any other host, `bricksentry mcp --transport streamable-http --port 8000` serves the same endpoint (on 127.0.0.1 unless you pass `--host`). To run it isolated, use the container image in [`deploy/container`](deploy/container/Dockerfile): non-root, config mounted read-only. [SECURITY.md](SECURITY.md) explains what bricksentry may reach over the network. Unity Catalog *MCP Services* are for servers hosted outside Databricks, so a Databricks App is the recommended way to run bricksentry inside it; see the [kit's README](deploy/databricks-app/README.md).
199
199
 
200
+ ### One install for Claude Code, Codex and Cursor (plugin)
201
+
202
+ The [bricksentry plugin](plugins/bricksentry) bundles the MCP server and the Agent Skill below, so an agent gets both the tools and the habit in one step:
203
+
204
+ ```
205
+ /plugin marketplace add bricksentry/bricksentry
206
+ /plugin install bricksentry@bricksentry
207
+ ```
208
+
209
+ In Codex: `codex plugin marketplace add bricksentry/bricksentry`, then `codex plugin add bricksentry@bricksentry`. In Cursor, add the marketplace from this repository in the plugin settings. The plugin starts the pinned bricksentry release with [`uvx`](https://docs.astral.sh/uv/) and reads `bricksentry.yml` from your project; see the [plugin README](plugins/bricksentry/README.md) for the three setup steps.
210
+
211
+ ### Teach your coding agent the habit (Agent Skill)
212
+
213
+ [`skills/bricksentry-safe-write`](skills/bricksentry-safe-write/SKILL.md) is an [Agent Skill](https://agentskills.io): a short instruction file that tells an agent to check every write to a production table with bricksentry first. It plans with `whats_downstream`, keeps the `rollback_plan`, previews with `preview_write`, and follows `safe_to_ship` exactly: it stops on `needs_human` and `block`, and never treats an error as a pass. The same folder works in any agent that supports Agent Skills. Copy it into the agent's skills folder:
214
+
215
+ | Agent | Folder |
216
+ |---|---|
217
+ | Genie Code (Agent mode) | `/Workspace/.assistant/skills/` for everyone in the workspace, or `/Users/<you>/.assistant/skills/` for yourself |
218
+ | Claude Code | `.claude/skills/` in your project, or `~/.claude/skills/` |
219
+ | Codex | `.agents/skills/` |
220
+ | Other agents | Their skills folder; the format is the same |
221
+
222
+ An agent loads a skill when your request matches its description, so it isn't a hard rule: a general SQL skill can be picked instead. To make the check mandatory, add one line to the agent's always-on instructions (Genie Code custom instructions, `CLAUDE.md`, `AGENTS.md`): *Before any INSERT, MERGE, UPDATE or DELETE on an existing table, use the bricksentry-safe-write skill.*
223
+
224
+ The agent also needs a way to run the checks: the MCP server above, or, in a Databricks notebook, the Python functions in `bricksentry.agent_tools` ([setup](skills/bricksentry-safe-write/references/setup.md)).
225
+
200
226
  ## For data engineers: CLI and CI
201
227
 
202
228
  ```bash
@@ -344,6 +370,8 @@ tables:
344
370
  policy: policy.yml # or builtin:<template>, see "Policy templates" below
345
371
  ```
346
372
 
373
+ **Waiting on the warehouse.** A stopped SQL warehouse is started before the first query; bricksentry waits for it up to `start_timeout_s`, lets a query wait for a busy warehouse up to `queue_timeout_s`, and lets it run up to `timeout_s` (defaults 300, 300 and 600 seconds; set them under `backend:`). Each MCP or agent tool call also answers within 10 minutes (`BRICKSENTRY_TOOL_TIMEOUT` in seconds, `0` for no limit): past a limit the query is cancelled and the tool says nothing was decided.
374
+
347
375
  **Without Unity Catalog** (local DuckDB work, tests, or other platforms), give the lineage in the config instead. Edges map a table to what reads from it; column edges and tags are optional:
348
376
 
349
377
  ```yaml
@@ -391,8 +419,14 @@ rules:
391
419
  - name: duplicate-keys # a join fanned out and duplicated keys -> block the PR
392
420
  when: {duplicate_keys: true}
393
421
  then: block
422
+
423
+ - name: key-column-duplicates # with a composite key, a column that was unique now repeats
424
+ when: {key_column_duplicates: true}
425
+ then: needs_human
394
426
  ```
395
427
 
428
+ `key_column_duplicates` guards against a key chosen too wide. With `keys: [order_id, region]`, a MERGE that matches on both columns can insert a second row for an existing `order_id`; by the pair nothing repeats, so `duplicate_keys` stays quiet. bricksentry also checks each column of a composite key that was unique before the change, and this condition fires when one stops being unique. A column that already repeated (such as `order_id` in `[order_id, line_no]`) is never flagged. The built-in templates send it to a human, and `strict` and `agent-safe` block it.
429
+
396
430
  | The change | Verdict |
397
431
  |---|---|
398
432
  | A filter fix that changes 40 rows, nothing else | `pass` |
@@ -421,7 +455,7 @@ Use one directly with `policy: builtin:finance`, or write an editable copy with
421
455
 
422
456
  ### Policy conditions
423
457
 
424
- `table` (glob) · `tag` · `downstream_tag` · `downstream_kind` · `downstream_count_gt` · `removed_pct_gt` · `added_pct_gt` · `changed_pct_gt` · `row_count_change_pct_gt` · `row_count_drop_pct_gt` · `column_removed` · `column_added` · `column_type_changed` · `duplicate_keys` · `null_keys` · `sum_change_pct_gt` / `null_increase_gt` (optionally with `column`) · `changed_column` (glob) · `changed_column_tag` · `downstream_column_tag` · `any_change` · `diff_error` · `lineage_error`
458
+ `table` (glob) · `tag` · `downstream_tag` · `downstream_kind` · `downstream_count_gt` · `removed_pct_gt` · `added_pct_gt` · `changed_pct_gt` · `row_count_change_pct_gt` · `row_count_drop_pct_gt` · `column_removed` · `column_added` · `column_type_changed` · `duplicate_keys` · `key_column_duplicates` · `null_keys` · `sum_change_pct_gt` / `null_increase_gt` (optionally with `column`) · `changed_column` (glob) · `changed_column_tag` · `downstream_column_tag` · `any_change` · `diff_error` · `lineage_error`
425
459
 
426
460
  **The pii and certified gates skip changes that change nothing.** In the default policy, `pii-table` (the table is tagged `pii`) and `certified-downstream` (it feeds something tagged `certified`) fire only when the diff shows a change: rows added, removed or changed, a schema change or new duplicate keys. A rebuild identical to production passes. A failed or missing diff still counts as a possible change. To require a review of every pull request touching a PII table regardless, add a rule without `any_change`: `{name: pii-review, when: {tag: pii}, then: needs_human}`.
427
461
 
@@ -0,0 +1 @@
1
+ bricksentry[databricks,mcp]==0.1.36
@@ -6,6 +6,7 @@ notify_owners_on: needs_human
6
6
  rules:
7
7
  - {name: diff-failed, when: {diff_error: true}, then: needs_human}
8
8
  - {name: duplicate-keys, when: {duplicate_keys: true}, then: block}
9
+ - {name: key-column-duplicates, when: {key_column_duplicates: true}, then: needs_human}
9
10
  - {name: null-keys, when: {null_keys: true}, then: warn}
10
11
  - {name: dropped-column, when: {column_removed: true}, then: needs_human}
11
12
  - {name: type-change, when: {column_type_changed: true}, then: warn}
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "bricksentry",
3
+ "displayName": "bricksentry",
4
+ "version": "0.1.36",
5
+ "description": "Check every write to a Databricks table before it runs: preview on a clone, diff the data, Unity Catalog blast radius and a policy verdict. Adds the bricksentry MCP server and the bricksentry-safe-write skill.",
6
+ "author": {
7
+ "name": "bricksentry",
8
+ "url": "https://bricksentry.org"
9
+ },
10
+ "homepage": "https://bricksentry.org/docs/agents",
11
+ "repository": "https://github.com/bricksentry/bricksentry",
12
+ "license": "Apache-2.0",
13
+ "keywords": [
14
+ "databricks",
15
+ "delta-lake",
16
+ "unity-catalog",
17
+ "data-quality",
18
+ "mcp",
19
+ "ai-agents",
20
+ "safety"
21
+ ],
22
+ "icon": "./assets/icon.png"
23
+ }
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "bricksentry",
3
+ "version": "0.1.36",
4
+ "description": "Check every write to a Databricks table before it runs: preview on a clone, diff the data, Unity Catalog blast radius and a policy verdict. Adds the bricksentry MCP server and the bricksentry-safe-write skill.",
5
+ "author": {
6
+ "name": "bricksentry",
7
+ "url": "https://bricksentry.org"
8
+ },
9
+ "homepage": "https://bricksentry.org/docs/agents",
10
+ "repository": "https://github.com/bricksentry/bricksentry",
11
+ "license": "Apache-2.0",
12
+ "keywords": [
13
+ "databricks",
14
+ "delta-lake",
15
+ "unity-catalog",
16
+ "data-quality",
17
+ "mcp",
18
+ "ai-agents",
19
+ "safety"
20
+ ],
21
+ "skills": "./skills/",
22
+ "mcpServers": "./.mcp.json",
23
+ "interface": {
24
+ "displayName": "bricksentry",
25
+ "shortDescription": "Preview Databricks table writes before they run",
26
+ "longDescription": "Before an agent runs MERGE, UPDATE, DELETE, INSERT or CREATE OR REPLACE on a Delta table, bricksentry previews it on a clone, diffs the data, checks Unity Catalog downstream impact and returns a policy verdict: pass, warn, needs_human or block.",
27
+ "developerName": "bricksentry",
28
+ "category": "Data",
29
+ "capabilities": [
30
+ "Read",
31
+ "Write"
32
+ ],
33
+ "websiteURL": "https://bricksentry.org",
34
+ "defaultPrompt": [
35
+ "Is this MERGE safe to run on my Databricks table?",
36
+ "What is downstream of this table?",
37
+ "How do I undo the last change to this table?"
38
+ ],
39
+ "brandColor": "#2346D9",
40
+ "composerIcon": "./assets/icon.png",
41
+ "logo": "./assets/icon.png"
42
+ }
43
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "bricksentry",
3
+ "displayName": "bricksentry",
4
+ "version": "0.1.36",
5
+ "description": "Check every write to a Databricks table before it runs: preview on a clone, diff the data, Unity Catalog blast radius and a policy verdict. Adds the bricksentry MCP server and the bricksentry-safe-write skill.",
6
+ "author": {
7
+ "name": "bricksentry",
8
+ "url": "https://bricksentry.org"
9
+ },
10
+ "homepage": "https://bricksentry.org/docs/agents",
11
+ "repository": "https://github.com/bricksentry/bricksentry",
12
+ "license": "Apache-2.0",
13
+ "keywords": [
14
+ "databricks",
15
+ "delta-lake",
16
+ "unity-catalog",
17
+ "data-quality",
18
+ "mcp",
19
+ "ai-agents",
20
+ "safety"
21
+ ],
22
+ "logo": "./assets/icon.png"
23
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "mcpServers": {
3
+ "bricksentry": {
4
+ "command": "uvx",
5
+ "args": [
6
+ "--from",
7
+ "bricksentry[databricks,mcp]==0.1.36",
8
+ "bricksentry",
9
+ "mcp"
10
+ ],
11
+ "startup_timeout_sec": 120,
12
+ "tool_timeout_sec": 900
13
+ }
14
+ }
15
+ }
@@ -0,0 +1,58 @@
1
+ # bricksentry plugin for Claude Code, Codex and Cursor
2
+
3
+ Checks every write to a Databricks table before it runs. The plugin adds two things to your coding agent:
4
+
5
+ - **The bricksentry MCP server**: `whats_downstream`, `rollback_plan`, `preview_write`, `assess_change`, `explain_diff` and `safe_to_ship`. `preview_write` runs a write on a disposable shallow clone, diffs it against production, checks Unity Catalog lineage and applies your policy. It never writes to production.
6
+ - **The `bricksentry-safe-write` skill**: teaches the agent to use them for every INSERT, MERGE, UPDATE or DELETE on an existing table, to pick the right key, and to follow the verdict (`pass`, `warn`, `needs_human`, `block`) exactly.
7
+
8
+ ## Install
9
+
10
+ **Claude Code**
11
+
12
+ ```
13
+ /plugin marketplace add bricksentry/bricksentry
14
+ /plugin install bricksentry@bricksentry
15
+ ```
16
+
17
+ **Codex** (CLI or desktop app)
18
+
19
+ ```
20
+ codex plugin marketplace add bricksentry/bricksentry
21
+ codex plugin add bricksentry@bricksentry
22
+ ```
23
+
24
+ Start a new Codex session afterwards. `codex mcp list` should show `bricksentry`.
25
+
26
+ **Cursor**: add the marketplace from this repository (`bricksentry/bricksentry`) in Cursor's plugin settings, or copy this folder to `~/.cursor/plugins/local/bricksentry`, then reload the window.
27
+
28
+ ## Set up (once per project)
29
+
30
+ 1. **Install [uv](https://docs.astral.sh/uv/).** The plugin starts the server with `uvx`, which fetches the pinned bricksentry release by itself. If you'd rather use a `pip install "bricksentry[databricks,mcp]"`, change `uvx --from ... bricksentry mcp` in `.mcp.json` (Claude Code and Codex) or `mcp.json` (Cursor) to `bricksentry mcp`.
31
+ 2. **Sign in to Databricks** the usual way: a profile in `~/.databrickscfg` (`databricks auth login`) or the `DATABRICKS_HOST` and `DATABRICKS_TOKEN` environment variables.
32
+ 3. **Add a `bricksentry.yml` at the root of your project.** The server reads it from the folder your agent runs in. Create a starter with:
33
+
34
+ ```bash
35
+ uvx --from "bricksentry[databricks]" bricksentry init --policy agent-safe
36
+ ```
37
+
38
+ Then set `warehouse_id` (or the `DATABRICKS_WAREHOUSE_ID` environment variable), a `sandbox_schema` where clones may be created, and the key columns of the tables your agent will change. Listing those tables in `agent_tables` limits what the agent can check.
39
+
40
+ **Without a `bricksentry.yml`, the server checks nothing:** every tool answers "No bricksentry.yml found" until you start your agent from the folder that has one (or set `BRICKSENTRY_CONFIG` to its full path).
41
+
42
+ ## If a check is slow or fails
43
+
44
+ - **The SQL warehouse was stopped.** bricksentry starts it and waits up to 5 minutes, then says so if it still isn't running. Starting it yourself in Databricks first makes the first check faster.
45
+ - **Every tool call answers within 10 minutes**, even when the warehouse is busy; a call that runs out of time decides nothing. Change the limit with the `BRICKSENTRY_TOOL_TIMEOUT` environment variable (seconds). For very large tables, set `sample_pct` in `bricksentry.yml`.
46
+ - **Codex:** the plugin gives the server 120 seconds to start and 900 seconds per tool call (Codex's own defaults are 10 and 60).
47
+
48
+ ## Make the check mandatory
49
+
50
+ The skill loads when a request matches its description, which isn't a guarantee. To make the check a rule, add this line to your project's `CLAUDE.md` or `AGENTS.md` (or Cursor rules):
51
+
52
+ > Before any INSERT, MERGE, UPDATE or DELETE on an existing table, use the bricksentry-safe-write skill.
53
+
54
+ ## More
55
+
56
+ - Docs: https://bricksentry.org/docs/agents
57
+ - Source, issues and changelog: https://github.com/bricksentry/bricksentry
58
+ - License: Apache-2.0
@@ -0,0 +1,15 @@
1
+ {
2
+ "mcpServers": {
3
+ "bricksentry": {
4
+ "command": "uvx",
5
+ "args": [
6
+ "--from",
7
+ "bricksentry[databricks,mcp]==0.1.36",
8
+ "bricksentry",
9
+ "mcp"
10
+ ],
11
+ "startup_timeout_sec": 120,
12
+ "tool_timeout_sec": 900
13
+ }
14
+ }
15
+ }
@@ -0,0 +1,101 @@
1
+ ---
2
+ name: bricksentry-safe-write
3
+ description: Preview a data change with bricksentry before it runs. Use whenever you are about to run MERGE INTO, UPDATE, DELETE, INSERT INTO or CREATE OR REPLACE TABLE on an existing Delta table in Unity Catalog or Databricks, in any schema, and when asked whether a data change is safe to ship or how to undo one. Use it alongside general SQL-writing guidance, before the write runs.
4
+ license: Apache-2.0
5
+ ---
6
+
7
+ # Safe writes with bricksentry
8
+
9
+ bricksentry runs a write on a disposable clone of the table, diffs the result against
10
+ production, checks Unity Catalog lineage for what reads the table, and applies the team's
11
+ policy. It returns one verdict: `pass`, `warn`, `needs_human` or `block`. Rules decide the
12
+ verdict, not a model, so follow it exactly.
13
+
14
+ How to reach bricksentry depends on where you run: MCP tools, Python in a Databricks
15
+ notebook, or the `bricksentry` CLI. See [references/setup.md](references/setup.md). The steps
16
+ below use the MCP tool names; the Python functions in `bricksentry.agent_tools` have the same
17
+ names and arguments.
18
+
19
+ ## The loop, for every write to a production table
20
+
21
+ 1. **Plan.** `whats_downstream(table)` before you edit. Note the owners and any downstream
22
+ assets tagged `certified` or `pii`. Pass `columns=[...]` when you will change specific columns.
23
+ An empty list doesn't always mean nothing reads the table: Unity Catalog can take 10 to 15
24
+ minutes to record lineage for new tables and jobs. For a table created recently, say so.
25
+ 2. **Keep the undo.** `rollback_plan(table)` and keep the returned `rollback_sql` in your reply,
26
+ the PR or the job log. Do this before anything is applied.
27
+ 3. **Preview.** `preview_write(sql, target)` for a single statement that has not run yet.
28
+ Write `{{target}}` where the table name goes, or the full three-part name. For a pipeline
29
+ change already built into candidate (dev or PR) tables, use `assess_change(tables)` instead.
30
+
31
+ **Get the key right; the verdict depends on it.** The key is the column or columns that
32
+ identify one row in the table *as it is now* (usually its business id, such as `order_id`).
33
+ If it's in `bricksentry.yml` under `tables:`, use that; otherwise pass `keys=[...]`.
34
+ - It is **not** the MERGE's `ON` columns. A MERGE that matches on `order_id AND region` can
35
+ insert a second row for an existing `order_id`; with `region` in the key, that duplicate is
36
+ invisible and the change looks like clean new rows.
37
+ - A key from `bricksentry.yml` was chosen by the team: use it as is. If you choose the key
38
+ yourself, check it: `SELECT COUNT(*), COUNT(DISTINCT order_id) FROM <table>` must give equal
39
+ counts, using the smallest set of columns that passes. If you can't run SQL yourself (a
40
+ sandboxed shell often can't use the user's Databricks sign-in), preview with the key you
41
+ think is right and read `duplicate_keys_base` in the result: above 0 means the key doesn't
42
+ identify one row in the current table, so ask the user. If no column is unique, or you're
43
+ unsure, ask the user. Never guess: a wrong key hides duplicates or makes every row look changed.
44
+ - Say which key you used when you report the verdict. If the result has a
45
+ `key-column-duplicates` hit, a column you included in the key was unique and now repeats:
46
+ the key was too wide, so treat it like duplicate keys.
47
+ 4. **Decide.** `safe_to_ship(id)` with the `id` from step 3, then do exactly what `next_step` says:
48
+ - `pass`: go ahead.
49
+ - `warn`: go ahead, and put every warning in your reply or the PR description.
50
+ - `needs_human`: do not apply it. Show the user the report and the reviewers listed in the
51
+ result's `notify` field (it's a field, not a tool), and wait for a person to approve.
52
+ - `block`: do not apply it. Fix the causes in `rule_hits`, then preview again.
53
+ 5. **Apply** only after `pass` or `warn`, the same statement you previewed, unchanged. If you
54
+ change the statement, preview it again. If you have no way to run SQL on the workspace, give
55
+ the user that exact statement to run.
56
+ 6. **Report** the verdict, the row counts (added, removed, changed), what is downstream, and
57
+ the `rollback_sql`. `explain_diff(assessment_id)` turns the diff into plain sentences for a
58
+ PR description or a reviewer.
59
+
60
+ ## Never
61
+
62
+ - Never run a write on production before its preview verdict is `pass` or `warn`.
63
+ - Never treat an error, a refusal or a missing verdict as `pass`. If bricksentry can't check a
64
+ change, a person decides. Say so plainly.
65
+ - Never work around a verdict: don't edit `policy.yml`, `bricksentry.yml` or `agent_tables`,
66
+ split a statement, rename the target or switch tables to get a better answer.
67
+ - Never run a `RESTORE` without showing the user what it also undoes. `check-last-change`
68
+ warns when newer writes landed after the change.
69
+ - Never copy row values from production into your reply. bricksentry gives agents counts,
70
+ columns and verdicts on purpose.
71
+
72
+ ## When a tool returns an error
73
+
74
+ - **The SQL warehouse is stopped, starting or busy:** tell the user, and retry once after it shows
75
+ Running. Don't apply the write in the meantime.
76
+ - **"No bricksentry.yml found":** the agent was started outside the project folder. Ask the user
77
+ to start it from the folder with `bricksentry.yml`, or to set `BRICKSENTRY_CONFIG`.
78
+ - **A time limit was reached:** nothing was decided. Retry once; for a very large table, suggest
79
+ `sample_pct` in `bricksentry.yml`.
80
+
81
+ ## What bricksentry refuses, and what to do instead
82
+
83
+ - **DROP, TRUNCATE, ALTER, GRANT, or more than one statement:** preview one statement at a time.
84
+ Schema and permission changes need a person.
85
+ - **A write wrapped in a CTE (`WITH ... INSERT`):** move the CTE into the statement's `SELECT`
86
+ (`INSERT INTO t WITH x AS (...) SELECT ...`).
87
+ - **A table outside `agent_tables`:** you aren't allowed to check it. Ask the user; don't edit the list.
88
+ - **Tables with column masks or row filters:** Databricks can't clone them, so they can't be
89
+ previewed. Tell the user and suggest previewing on the table that feeds it, or a dev copy.
90
+
91
+ ## After a pipeline has run
92
+
93
+ To check a change that already landed, for example after a scheduled MERGE, run
94
+ `bricksentry check-last-change <table>`. It compares the table before and after its latest data
95
+ change and prints the verdict and the `RESTORE` to undo it.
96
+
97
+ ## Reading the CLI's exit code
98
+
99
+ `bricksentry preview` exits 1 only at `--fail-on` (default `block`), so a `needs_human` verdict
100
+ exits 0. Pass `--fail-on needs_human` in scripts, or read the verdict from `--format json`;
101
+ don't rely on the exit code alone.
@@ -0,0 +1,69 @@
1
+ # Reaching bricksentry
2
+
3
+ Use whichever is available. Check for MCP tools named `preview_write` and `safe_to_ship` first.
4
+
5
+ ## 1. MCP tools (Claude Code, Cursor, Copilot, Codex, Agent Bricks)
6
+
7
+ If the bricksentry MCP server is connected, call its tools directly: `whats_downstream`,
8
+ `rollback_plan`, `preview_write`, `assess_change`, `explain_diff`, `safe_to_ship`.
9
+
10
+ A server started with `--read-only` (the default in the Databricks App template) leaves out
11
+ `preview_write`. Then you can plan and assess, but you can't preview a write: ask the user to
12
+ preview it, or to connect a server that allows previews.
13
+
14
+ Not connected yet? The user starts one with:
15
+
16
+ ```bash
17
+ pip install "bricksentry[databricks,mcp]"
18
+ bricksentry mcp # stdio, reads ./bricksentry.yml
19
+ ```
20
+
21
+ ## 2. Python in a Databricks notebook (Genie Code)
22
+
23
+ Install once per session, then restart Python in the next cell:
24
+
25
+ ```python
26
+ %pip install "bricksentry[databricks]"
27
+ dbutils.library.restartPython()
28
+ ```
29
+
30
+ Then:
31
+
32
+ ```python
33
+ from bricksentry import Config, Sentry, agent_tools
34
+
35
+ sentry = Sentry(Config.from_dict({
36
+ "backend": {"type": "databricks", "warehouse_id": "<sql-warehouse-id>"},
37
+ "sandbox_schema": "<catalog>.bricksentry_sandbox", # clones go here, then are dropped
38
+ "tables": {"<catalog>.<schema>.<table>": {"keys": ["<key column>"]}},
39
+ "lineage": {"type": "databricks"},
40
+ "policy": "builtin:agent-safe",
41
+ }))
42
+ agent_tools.set_sentry(sentry)
43
+
44
+ agent_tools.whats_downstream("<catalog>.<schema>.<table>")
45
+ plan = agent_tools.rollback_plan("<catalog>.<schema>.<table>")
46
+ result = agent_tools.preview_write(
47
+ "UPDATE {{target}} SET status = 'shipped' WHERE order_id = 42",
48
+ "<catalog>.<schema>.<table>",
49
+ )
50
+ decision = agent_tools.safe_to_ship(result["id"]) # follow decision["next_step"]
51
+ ```
52
+
53
+ Ask the user for the warehouse ID, the sandbox schema and the table's key columns if you don't
54
+ know them. Don't guess keys: a wrong key makes every row look changed. If the workspace already
55
+ has a `bricksentry.yml`, use `Config.load("<path>")` instead.
56
+
57
+ ## 3. The command line
58
+
59
+ ```bash
60
+ bricksentry impact main.sales.orders
61
+ bricksentry rollback main.sales.orders
62
+ bricksentry preview main.sales.orders \
63
+ --sql "UPDATE {{target}} SET status = 'shipped' WHERE order_id = 42" \
64
+ --format json --fail-on needs_human
65
+ bricksentry check-last-change main.sales.orders # after a pipeline has already written
66
+ ```
67
+
68
+ Exit codes: 0 below `--fail-on`, 1 at or above it, 2 for errors (treat 2 as "couldn't check",
69
+ never as safe).
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "bricksentry"
7
- version = "0.1.34"
7
+ version = "0.1.36"
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"
@@ -53,7 +53,7 @@ Issues = "https://github.com/bricksentry/bricksentry/issues"
53
53
  Changelog = "https://github.com/bricksentry/bricksentry/blob/main/CHANGELOG.md"
54
54
 
55
55
  [tool.hatch.build.targets.sdist]
56
- include = ["/src", "/tests", "/examples", "/scripts", "/templates", "/deploy", "/README.md", "/LICENSE", "/CHANGELOG.md", "/CONTRIBUTING.md", "/SECURITY.md", "/action.yml", "/server.json"]
56
+ include = ["/src", "/tests", "/examples", "/scripts", "/templates", "/deploy", "/skills", "/plugins", "/.claude-plugin", "/.cursor-plugin", "/.agents", "/README.md", "/LICENSE", "/CHANGELOG.md", "/CONTRIBUTING.md", "/SECURITY.md", "/action.yml", "/server.json"]
57
57
 
58
58
  [tool.hatch.build.targets.wheel]
59
59
  packages = ["src/bricksentry"]
@@ -8,12 +8,12 @@
8
8
  "source": "github"
9
9
  },
10
10
  "websiteUrl": "https://bricksentry.org",
11
- "version": "0.1.34",
11
+ "version": "0.1.36",
12
12
  "packages": [
13
13
  {
14
14
  "registryType": "pypi",
15
15
  "identifier": "bricksentry-mcp",
16
- "version": "0.1.34",
16
+ "version": "0.1.36",
17
17
  "runtimeHint": "uvx",
18
18
  "transport": {
19
19
  "type": "stdio"