bricksentry 0.1.14__tar.gz → 0.1.15__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 (80) hide show
  1. {bricksentry-0.1.14 → bricksentry-0.1.15}/CHANGELOG.md +9 -0
  2. {bricksentry-0.1.14 → bricksentry-0.1.15}/PKG-INFO +1 -1
  3. bricksentry-0.1.15/deploy/databricks-app/app.yaml +10 -0
  4. bricksentry-0.1.15/deploy/databricks-app/bricksentry.yml +21 -0
  5. bricksentry-0.1.15/deploy/databricks-app/databricks.yml +26 -0
  6. bricksentry-0.1.15/deploy/databricks-app/grants.sql +19 -0
  7. bricksentry-0.1.15/deploy/databricks-app/requirements.txt +1 -0
  8. {bricksentry-0.1.14 → bricksentry-0.1.15}/pyproject.toml +2 -2
  9. bricksentry-0.1.15/server.json +41 -0
  10. {bricksentry-0.1.14 → bricksentry-0.1.15}/src/bricksentry/__init__.py +1 -1
  11. {bricksentry-0.1.14 → bricksentry-0.1.15}/src/bricksentry/job.py +9 -3
  12. bricksentry-0.1.15/templates/job-check/databricks_template_schema.json +78 -0
  13. bricksentry-0.1.15/templates/job-check/template/{{.project_name}}/.gitignore +2 -0
  14. bricksentry-0.1.15/templates/job-check/template/{{.project_name}}/README.md.tmpl +68 -0
  15. bricksentry-0.1.15/templates/job-check/template/{{.project_name}}/databricks.yml.tmpl +14 -0
  16. bricksentry-0.1.15/templates/job-check/template/{{.project_name}}/resources/bricksentry_check.job.yml.tmpl +54 -0
  17. {bricksentry-0.1.14 → bricksentry-0.1.15}/tests/test_0114.py +23 -3
  18. bricksentry-0.1.14/packages/bricksentry-mcp/LICENSE +0 -202
  19. bricksentry-0.1.14/packages/bricksentry-mcp/README.md +0 -32
  20. bricksentry-0.1.14/packages/bricksentry-mcp/src/bricksentry_mcp/__init__.py +0 -5
  21. {bricksentry-0.1.14 → bricksentry-0.1.15}/.gitignore +0 -0
  22. {bricksentry-0.1.14 → bricksentry-0.1.15}/CONTRIBUTING.md +0 -0
  23. {bricksentry-0.1.14 → bricksentry-0.1.15}/LICENSE +0 -0
  24. {bricksentry-0.1.14 → bricksentry-0.1.15}/README.md +0 -0
  25. {bricksentry-0.1.14 → bricksentry-0.1.15}/SECURITY.md +0 -0
  26. {bricksentry-0.1.14 → bricksentry-0.1.15}/action.yml +0 -0
  27. {bricksentry-0.1.14 → bricksentry-0.1.15}/deploy/databricks-app/README.md +0 -0
  28. {bricksentry-0.1.14 → bricksentry-0.1.15}/examples/databricks/bricksentry.yml +0 -0
  29. {bricksentry-0.1.14 → bricksentry-0.1.15}/examples/databricks/bricksentry_check_my_table.ipynb +0 -0
  30. {bricksentry-0.1.14 → bricksentry-0.1.15}/examples/databricks/bricksentry_check_my_table.py +0 -0
  31. {bricksentry-0.1.14 → bricksentry-0.1.15}/examples/databricks/bricksentry_hr_walkthrough.ipynb +0 -0
  32. {bricksentry-0.1.14 → bricksentry-0.1.15}/examples/databricks/bricksentry_hr_walkthrough.py +0 -0
  33. {bricksentry-0.1.14 → bricksentry-0.1.15}/examples/databricks/bricksentry_quickstart.ipynb +0 -0
  34. {bricksentry-0.1.14 → bricksentry-0.1.15}/examples/databricks/bricksentry_quickstart.py +0 -0
  35. {bricksentry-0.1.14 → bricksentry-0.1.15}/examples/databricks/github-workflow.yml +0 -0
  36. {bricksentry-0.1.14 → bricksentry-0.1.15}/examples/databricks/policy.yml +0 -0
  37. {bricksentry-0.1.14 → bricksentry-0.1.15}/examples/demo/agent_loop_demo.py +0 -0
  38. {bricksentry-0.1.14 → bricksentry-0.1.15}/scripts/build_notebook.py +0 -0
  39. {bricksentry-0.1.14 → bricksentry-0.1.15}/src/bricksentry/__main__.py +0 -0
  40. {bricksentry-0.1.14 → bricksentry-0.1.15}/src/bricksentry/agent_tools.py +0 -0
  41. {bricksentry-0.1.14 → bricksentry-0.1.15}/src/bricksentry/assess.py +0 -0
  42. {bricksentry-0.1.14 → bricksentry-0.1.15}/src/bricksentry/backends/__init__.py +0 -0
  43. {bricksentry-0.1.14 → bricksentry-0.1.15}/src/bricksentry/backends/base.py +0 -0
  44. {bricksentry-0.1.14 → bricksentry-0.1.15}/src/bricksentry/backends/databricks_backend.py +0 -0
  45. {bricksentry-0.1.14 → bricksentry-0.1.15}/src/bricksentry/backends/duckdb_backend.py +0 -0
  46. {bricksentry-0.1.14 → bricksentry-0.1.15}/src/bricksentry/changes.py +0 -0
  47. {bricksentry-0.1.14 → bricksentry-0.1.15}/src/bricksentry/cli.py +0 -0
  48. {bricksentry-0.1.14 → bricksentry-0.1.15}/src/bricksentry/config.py +0 -0
  49. {bricksentry-0.1.14 → bricksentry-0.1.15}/src/bricksentry/demo.py +0 -0
  50. {bricksentry-0.1.14 → bricksentry-0.1.15}/src/bricksentry/diff.py +0 -0
  51. {bricksentry-0.1.14 → bricksentry-0.1.15}/src/bricksentry/explain.py +0 -0
  52. {bricksentry-0.1.14 → bricksentry-0.1.15}/src/bricksentry/github.py +0 -0
  53. {bricksentry-0.1.14 → bricksentry-0.1.15}/src/bricksentry/history.py +0 -0
  54. {bricksentry-0.1.14 → bricksentry-0.1.15}/src/bricksentry/lineage.py +0 -0
  55. {bricksentry-0.1.14 → bricksentry-0.1.15}/src/bricksentry/mcp_server.py +0 -0
  56. {bricksentry-0.1.14 → bricksentry-0.1.15}/src/bricksentry/measures.py +0 -0
  57. {bricksentry-0.1.14 → bricksentry-0.1.15}/src/bricksentry/models.py +0 -0
  58. {bricksentry-0.1.14 → bricksentry-0.1.15}/src/bricksentry/notify.py +0 -0
  59. {bricksentry-0.1.14 → bricksentry-0.1.15}/src/bricksentry/policy.py +0 -0
  60. {bricksentry-0.1.14 → bricksentry-0.1.15}/src/bricksentry/policy_templates.py +0 -0
  61. {bricksentry-0.1.14 → bricksentry-0.1.15}/src/bricksentry/preview.py +0 -0
  62. {bricksentry-0.1.14 → bricksentry-0.1.15}/src/bricksentry/py.typed +0 -0
  63. {bricksentry-0.1.14 → bricksentry-0.1.15}/src/bricksentry/report.py +0 -0
  64. {bricksentry-0.1.14 → bricksentry-0.1.15}/templates/job-check/README.md +0 -0
  65. {bricksentry-0.1.14 → bricksentry-0.1.15}/templates/job-check/template/{{.project_name}}/src/bricksentry_check.py +0 -0
  66. {bricksentry-0.1.14 → bricksentry-0.1.15}/tests/conftest.py +0 -0
  67. {bricksentry-0.1.14 → bricksentry-0.1.15}/tests/test_0110.py +0 -0
  68. {bricksentry-0.1.14 → bricksentry-0.1.15}/tests/test_0112.py +0 -0
  69. {bricksentry-0.1.14 → bricksentry-0.1.15}/tests/test_018.py +0 -0
  70. {bricksentry-0.1.14 → bricksentry-0.1.15}/tests/test_019.py +0 -0
  71. {bricksentry-0.1.14 → bricksentry-0.1.15}/tests/test_assess_policy.py +0 -0
  72. {bricksentry-0.1.14 → bricksentry-0.1.15}/tests/test_check_notebook.py +0 -0
  73. {bricksentry-0.1.14 → bricksentry-0.1.15}/tests/test_databricks_and_uc.py +0 -0
  74. {bricksentry-0.1.14 → bricksentry-0.1.15}/tests/test_demo.py +0 -0
  75. {bricksentry-0.1.14 → bricksentry-0.1.15}/tests/test_diff.py +0 -0
  76. {bricksentry-0.1.14 → bricksentry-0.1.15}/tests/test_hr_notebook.py +0 -0
  77. {bricksentry-0.1.14 → bricksentry-0.1.15}/tests/test_notebook.py +0 -0
  78. {bricksentry-0.1.14 → bricksentry-0.1.15}/tests/test_notify_templates.py +0 -0
  79. {bricksentry-0.1.14 → bricksentry-0.1.15}/tests/test_preview_agents.py +0 -0
  80. {bricksentry-0.1.14 → bricksentry-0.1.15}/tests/test_sample_guard_and_store.py +0 -0
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.15 (2026-11-11)
4
+
5
+ From the first live test of the 0.1.14 job template on Databricks serverless (deployed with `databricks bundle deploy`, started by the table update trigger and by hand):
6
+
7
+ - Fix: every run of the job task was marked failed, even "pass" and "nothing to check", because Databricks treats any `SystemExit` from a Python script task as an error, including exit code 0. `python -m bricksentry.job` now only exits when the task should fail (verdict at or above `--fail-on`, or an error).
8
+ - The bundle template now asks for key columns (`keys`, e.g. `main.hr.employees=employee_id`), for tables without a `PRIMARY KEY`. Before, those runs failed with "No key columns" until `--key` was added by hand. The job task takes several at once with `--keys "t1=a,b; t2=c"`.
9
+ - The template's task sets `max_retries: 0`, so a `block` verdict fails the run once instead of being retried.
10
+ - Fix: the source distribution on PyPI had only some of the bundle template's files (and the Databricks App kit was missing). It now includes `templates/` and `deploy/` in full.
11
+
3
12
  ## 0.1.14 (2026-11-11)
4
13
 
5
14
  Zero-friction adoption: check every pipeline run without changing the pipeline.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: bricksentry
3
- Version: 0.1.14
3
+ Version: 0.1.15
4
4
  Summary: Change-safety for Databricks 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
@@ -0,0 +1,10 @@
1
+ # Databricks Apps entry point for the bricksentry MCP server.
2
+ # The app listens on $DATABRICKS_APP_PORT (bricksentry picks it up) and serves MCP at /mcp.
3
+ # --read-only leaves out preview_write, so agents can check changes but the app never writes.
4
+ # Remove it to allow previews on sandbox clones (needs CREATE TABLE on sandbox_schema, see grants.sql).
5
+ command: ["bricksentry", "mcp", "--transport", "streamable-http", "--read-only", "--config", "bricksentry.yml"]
6
+ env:
7
+ - name: DATABRICKS_WAREHOUSE_ID
8
+ valueFrom: sql-warehouse # the SQL warehouse resource added to the app
9
+ - name: BRICKSENTRY_STORE
10
+ value: /tmp/bricksentry/assessments
@@ -0,0 +1,21 @@
1
+ # bricksentry config for the Databricks App. The warehouse comes from the app's
2
+ # sql-warehouse resource (DATABRICKS_WAREHOUSE_ID); auth is the app's service principal.
3
+ backend:
4
+ type: databricks
5
+ lineage:
6
+ type: databricks
7
+ depth: 3
8
+ lookback_days: 90
9
+ sandbox_schema: main.bricksentry_sandbox # only used if you remove --read-only from app.yaml
10
+ policy: builtin:agent-safe # see `bricksentry policies`
11
+
12
+ # Tables agents may assess, with the keys that identify a row.
13
+ # assess_change needs keys for a table; preview_write can also take them as an argument.
14
+ tables:
15
+ main.sales.orders:
16
+ keys: [order_id]
17
+
18
+ # Optional: post needs_human / block verdicts to Slack. Add the webhook as an app secret
19
+ # and expose it with `valueFrom` in app.yaml, then uncomment:
20
+ # notify:
21
+ # slack_webhook: env:BRICKSENTRY_SLACK_WEBHOOK
@@ -0,0 +1,26 @@
1
+ # Deploy with Databricks Asset Bundles:
2
+ # databricks bundle deploy --var warehouse_id=<your-sql-warehouse-id>
3
+ # databricks bundle run bricksentry_mcp
4
+ bundle:
5
+ name: bricksentry-mcp
6
+
7
+ variables:
8
+ warehouse_id:
9
+ description: SQL warehouse bricksentry runs its checks on
10
+
11
+ resources:
12
+ apps:
13
+ bricksentry_mcp:
14
+ name: mcp-bricksentry
15
+ description: bricksentry MCP server - checks what a data change does before it ships
16
+ source_code_path: .
17
+ resources:
18
+ - name: sql-warehouse
19
+ sql_warehouse:
20
+ id: ${var.warehouse_id}
21
+ permission: CAN_USE
22
+
23
+ targets:
24
+ dev:
25
+ default: true
26
+ mode: development
@@ -0,0 +1,19 @@
1
+ -- Grants for the bricksentry app's service principal.
2
+ -- Find its application ID on the app's page (Authorization tab, "Service principal"),
3
+ -- then replace `<app-sp>` below. Adjust catalogs and schemas to the tables agents will check.
4
+
5
+ -- Tables bricksentry may read (the base tables and the candidate tables your CI builds)
6
+ GRANT USE CATALOG ON CATALOG main TO `<app-sp>`;
7
+ GRANT USE SCHEMA ON SCHEMA main.sales TO `<app-sp>`;
8
+ GRANT SELECT ON SCHEMA main.sales TO `<app-sp>`;
9
+
10
+ -- Blast radius: Unity Catalog lineage. Without it, checks still run and add a
11
+ -- lineage-unavailable warning.
12
+ GRANT USE CATALOG ON CATALOG system TO `<app-sp>`;
13
+ GRANT USE SCHEMA ON SCHEMA system.access TO `<app-sp>`;
14
+ GRANT SELECT ON TABLE system.access.table_lineage TO `<app-sp>`;
15
+ GRANT SELECT ON TABLE system.access.column_lineage TO `<app-sp>`; -- column-level impact
16
+
17
+ -- Only if you remove --read-only from app.yaml: previews run on shallow clones here.
18
+ -- CREATE SCHEMA IF NOT EXISTS main.bricksentry_sandbox;
19
+ -- GRANT USE SCHEMA, CREATE TABLE ON SCHEMA main.bricksentry_sandbox TO `<app-sp>`;
@@ -0,0 +1 @@
1
+ bricksentry[databricks,mcp]==0.1.15
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "bricksentry"
7
- version = "0.1.14"
7
+ version = "0.1.15"
8
8
  description = "Change-safety for Databricks 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"
@@ -51,7 +51,7 @@ Issues = "https://github.com/bricksentry/bricksentry/issues"
51
51
  Changelog = "https://github.com/bricksentry/bricksentry/blob/main/CHANGELOG.md"
52
52
 
53
53
  [tool.hatch.build.targets.sdist]
54
- include = ["src", "tests", "examples", "scripts", "README.md", "LICENSE", "CHANGELOG.md", "CONTRIBUTING.md", "SECURITY.md", "action.yml"]
54
+ include = ["/src", "/tests", "/examples", "/scripts", "/templates", "/deploy", "/README.md", "/LICENSE", "/CHANGELOG.md", "/CONTRIBUTING.md", "/SECURITY.md", "/action.yml", "/server.json"]
55
55
 
56
56
  [tool.hatch.build.targets.wheel]
57
57
  packages = ["src/bricksentry"]
@@ -0,0 +1,41 @@
1
+ {
2
+ "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
+ "name": "io.github.bricksentry/bricksentry",
4
+ "title": "bricksentry",
5
+ "description": "Safety check for AI agent and pipeline writes to Databricks tables, before they reach production.",
6
+ "repository": {
7
+ "url": "https://github.com/bricksentry/bricksentry",
8
+ "source": "github"
9
+ },
10
+ "websiteUrl": "https://bricksentry.org",
11
+ "version": "0.1.15",
12
+ "packages": [
13
+ {
14
+ "registryType": "pypi",
15
+ "identifier": "bricksentry-mcp",
16
+ "version": "0.1.15",
17
+ "runtimeHint": "uvx",
18
+ "transport": {
19
+ "type": "stdio"
20
+ },
21
+ "environmentVariables": [
22
+ {
23
+ "name": "BRICKSENTRY_CONFIG",
24
+ "description": "Path to your bricksentry.yml (backend, tables and policy).",
25
+ "isRequired": false
26
+ },
27
+ {
28
+ "name": "DATABRICKS_HOST",
29
+ "description": "Databricks workspace URL, when using the Databricks backend.",
30
+ "isRequired": false
31
+ },
32
+ {
33
+ "name": "DATABRICKS_TOKEN",
34
+ "description": "Databricks access token, when using the Databricks backend.",
35
+ "isRequired": false,
36
+ "isSecret": true
37
+ }
38
+ ]
39
+ }
40
+ ]
41
+ }
@@ -23,4 +23,4 @@ __all__ = [
23
23
  "TableDiff",
24
24
  "Verdict",
25
25
  ]
26
- __version__ = "0.1.14"
26
+ __version__ = "0.1.15"
@@ -78,6 +78,8 @@ def build_parser() -> argparse.ArgumentParser:
78
78
  p.add_argument("--warehouse-id", default=os.environ.get("DATABRICKS_WAREHOUSE_ID"))
79
79
  p.add_argument("--config", default=None, help="Optional bricksentry.yml (keys, policy, lineage, notify)")
80
80
  p.add_argument("--key", action="append", default=[], help="order_id or TABLE=col1,col2 (repeatable)")
81
+ p.add_argument("--keys", default=None,
82
+ help="Several at once, separated by ';': 'main.s.orders=order_id; main.s.items=order_id,line'")
81
83
  p.add_argument("--policy", default=None, help="Built-in policy name (default, strict, finance, pii, ...)")
82
84
  p.add_argument("--scratch-schema", default=None, help="catalog.schema for the temporary shallow clones")
83
85
  p.add_argument("--default-tables", default=None,
@@ -143,7 +145,7 @@ def run(argv: list[str] | None = None, backend: Any = None, out=print) -> int:
143
145
  if not tables:
144
146
  out("bricksentry: no tables to check.")
145
147
  return 0
146
- keys = parse_keys(args.key)
148
+ keys = parse_keys(args.key + [k for k in (args.keys or "").split(";") if k.strip()])
147
149
  s = make_sentry(args, backend=backend)
148
150
  worst: Verdict | None = None
149
151
  errors = 0
@@ -176,8 +178,12 @@ def run(argv: list[str] | None = None, backend: Any = None, out=print) -> int:
176
178
  return 0
177
179
 
178
180
 
179
- def main(argv: list[str] | None = None) -> None: # pragma: no cover - thin wrapper
180
- sys.exit(run(argv))
181
+ def main(argv: list[str] | None = None) -> None:
182
+ """Exit only on failure. Databricks reports any SystemExit from a spark_python_task,
183
+ even ``SystemExit(0)``, as a task error, so a clean run must simply return."""
184
+ code = run(argv)
185
+ if code:
186
+ sys.exit(code)
181
187
 
182
188
 
183
189
  if __name__ == "__main__": # pragma: no cover
@@ -0,0 +1,78 @@
1
+ {
2
+ "welcome_message": "bricksentry: check what every pipeline run did to your tables, alert on Slack, and get the RESTORE to undo it.",
3
+ "properties": {
4
+ "project_name": {
5
+ "type": "string",
6
+ "default": "bricksentry_check",
7
+ "description": "Name for this bundle (letters, digits, underscores)",
8
+ "pattern": "^[A-Za-z0-9_]+$",
9
+ "pattern_match_failure_message": "Use letters, digits and underscores only.",
10
+ "order": 1
11
+ },
12
+ "tables": {
13
+ "type": "string",
14
+ "description": "Tables to watch, comma-separated catalog.schema.table names (up to 10)",
15
+ "pattern": "^[A-Za-z0-9_]+\\.[A-Za-z0-9_]+\\.[A-Za-z0-9_]+(\\s*,\\s*[A-Za-z0-9_]+\\.[A-Za-z0-9_]+\\.[A-Za-z0-9_]+){0,9}$",
16
+ "pattern_match_failure_message": "Enter 1 to 10 full names like main.sales.orders, separated by commas.",
17
+ "order": 2
18
+ },
19
+ "keys": {
20
+ "type": "string",
21
+ "default": "",
22
+ "description": "Key columns for tables without a PRIMARY KEY: table=col1,col2 separated by ';' (e.g. main.sales.orders=order_id). Leave empty to use each table's PRIMARY KEY",
23
+ "pattern": "^(\\s*[A-Za-z0-9_]+\\.[A-Za-z0-9_]+\\.[A-Za-z0-9_]+\\s*=\\s*[A-Za-z0-9_]+(\\s*,\\s*[A-Za-z0-9_]+)*\\s*(;|$))*$",
24
+ "pattern_match_failure_message": "Use catalog.schema.table=col1,col2; separate tables with ';'. Or leave empty.",
25
+ "order": 3
26
+ },
27
+ "warehouse_id": {
28
+ "type": "string",
29
+ "description": "SQL warehouse ID (SQL Warehouses -> your warehouse -> Connection details)",
30
+ "pattern": "^[A-Za-z0-9]+$",
31
+ "pattern_match_failure_message": "Paste the warehouse ID only, e.g. 1a2b3c4d5e6f7a8b.",
32
+ "order": 4
33
+ },
34
+ "scratch_schema": {
35
+ "type": "string",
36
+ "default": "main.bricksentry_scratch",
37
+ "description": "catalog.schema for the temporary shallow clones (created if missing; clones are dropped after each check)",
38
+ "pattern": "^[A-Za-z0-9_]+\\.[A-Za-z0-9_]+$",
39
+ "pattern_match_failure_message": "Use catalog.schema.",
40
+ "order": 5
41
+ },
42
+ "policy": {
43
+ "type": "string",
44
+ "default": "default",
45
+ "enum": [
46
+ "default",
47
+ "strict",
48
+ "finance",
49
+ "pii",
50
+ "certified",
51
+ "agent-safe"
52
+ ],
53
+ "description": "Policy for the verdict",
54
+ "order": 6
55
+ },
56
+ "slack_secret": {
57
+ "type": "string",
58
+ "default": "",
59
+ "description": "Slack webhook as a secret, scope/key (e.g. bricksentry/slack_webhook). Leave empty for no alerts",
60
+ "pattern": "^([A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+)?$",
61
+ "pattern_match_failure_message": "Use scope/key, or leave empty.",
62
+ "order": 7
63
+ },
64
+ "fail_on": {
65
+ "type": "string",
66
+ "default": "block",
67
+ "enum": [
68
+ "block",
69
+ "needs_human",
70
+ "warn",
71
+ "never"
72
+ ],
73
+ "description": "Mark the run failed when the verdict is at least",
74
+ "order": 8
75
+ }
76
+ },
77
+ "success_message": "Created {{.project_name}}. Next: cd {{.project_name}} && databricks bundle deploy. See {{.project_name}}/README.md."
78
+ }
@@ -0,0 +1,2 @@
1
+ .databricks/
2
+ __pycache__/
@@ -0,0 +1,68 @@
1
+ # {{.project_name}}: bricksentry checks for your tables
2
+
3
+ This bundle deploys one serverless job, **bricksentry check ({{.project_name}})**. When any of
4
+ these tables changes, it runs and checks what changed:
5
+
6
+ {{.tables}}
7
+
8
+ For each table it compares the version before the change with the version after it (two
9
+ shallow clones in `{{.scratch_schema}}`, dropped after the check; your tables are only read).
10
+ It reports rows added, removed and changed, duplicate or NULL keys, schema changes and totals
11
+ that moved, plus what depends on the table (Unity Catalog lineage). The `{{.policy}}` policy turns
12
+ that into a verdict: pass, warn, needs_human or block. The run log shows the `RESTORE` statement
13
+ that undoes the change.{{if .slack_secret}} Alerts go to Slack using the webhook in the secret `{{.slack_secret}}`.{{end}}
14
+ The run is marked failed when the verdict is `{{.fail_on}}` or worse.
15
+
16
+ ## Deploy
17
+
18
+ ```bash
19
+ databricks bundle deploy # dev: the job is named [dev you] ... and its trigger is paused
20
+ databricks bundle deploy -t prod # prod: the trigger is live
21
+ databricks bundle run bricksentry_check # run once now (checks the last 60 minutes)
22
+ ```
23
+
24
+ The job's identity needs `SELECT` on the tables, `USE` and `CREATE TABLE` on
25
+ `{{.scratch_schema}}`, `CAN USE` on the warehouse, `SELECT` on `system.access.table_lineage` (for
26
+ lineage){{if .slack_secret}}, and `READ` on the secret scope{{end}}. Table history must still be there
27
+ (not removed by `VACUUM`).
28
+
29
+ ## Slack alerts
30
+
31
+ ```bash
32
+ databricks secrets create-scope bricksentry
33
+ databricks secrets put-secret bricksentry slack_webhook # paste the webhook URL when asked
34
+ ```
35
+
36
+ Then add `--slack-secret bricksentry/slack_webhook` to the task parameters in
37
+ `resources/bricksentry_check.job.yml`. For Teams use `--teams-secret`.
38
+
39
+ ## Stop downstream tasks instead of only alerting
40
+
41
+ This job runs after the change has landed. To stop the tasks that read a table when its
42
+ change is bad, add the check as a task inside your pipeline job, right after the task that
43
+ writes the table:
44
+
45
+ ```yaml
46
+ - task_key: bricksentry_check
47
+ depends_on: [{task_key: your_write_task}]
48
+ environment_key: bricksentry
49
+ spark_python_task:
50
+ python_file: ../src/bricksentry_check.py
51
+ parameters: [--tables, main.sales.orders, --warehouse-id, "{{.warehouse_id}}",
52
+ --scratch-schema, "{{.scratch_schema}}",{{if .keys}} --keys, "{{.keys}}",{{end}}
53
+ --since, "{{`{{job.start_time.iso_datetime}}`}}"]
54
+ - task_key: your_downstream_task
55
+ depends_on: [{task_key: bricksentry_check}]
56
+ environments:
57
+ - environment_key: bricksentry
58
+ spec: {environment_version: "2", dependencies: ["bricksentry[databricks]>=0.1.15"]}
59
+ ```
60
+
61
+ `--since {{`{{job.start_time.iso_datetime}}`}}` checks everything this run wrote as one change.
62
+ When the verdict is `block`, the check task fails and `your_downstream_task` does not run.
63
+
64
+ ## Options
65
+
66
+ `python -m bricksentry.job --help` lists them: `--keys "TABLE=col1,col2; TABLE2=col"` for tables
67
+ without a primary key{{if .keys}} (this bundle sets `{{.keys}}`){{end}}, `--config bricksentry.yml` for keys, lineage, owners and Slack mentions,
68
+ `--notify-on`, `--sample-pct` for very large tables. Docs: https://bricksentry.org
@@ -0,0 +1,14 @@
1
+ # bricksentry: check what every pipeline run did to your tables.
2
+ # Docs: https://bricksentry.org/docs/jobs
3
+ bundle:
4
+ name: {{.project_name}}
5
+
6
+ include:
7
+ - resources/*.yml
8
+
9
+ targets:
10
+ dev:
11
+ mode: development
12
+ default: true
13
+ prod:
14
+ mode: production
@@ -0,0 +1,54 @@
1
+ # Runs after any watched table changes (Delta commit), checks what changed, alerts, and
2
+ # fails the run when the verdict is at least --fail-on. OPTIMIZE / VACUUM commits also
3
+ # start a run; they have no data change, so the run just finishes ("nothing to check").
4
+ resources:
5
+ jobs:
6
+ bricksentry_check:
7
+ name: bricksentry check ({{.project_name}})
8
+ max_concurrent_runs: 1
9
+ trigger:
10
+ pause_status: UNPAUSED
11
+ table_update:
12
+ table_names: [{{.tables}}]
13
+ condition: ANY_UPDATED
14
+ # Wait until the pipeline has stopped writing, so one run covers all its commits.
15
+ wait_after_last_change_seconds: 120
16
+ tasks:
17
+ - task_key: bricksentry_check
18
+ environment_key: default
19
+ max_retries: 0 # a block verdict is an answer, not a flaky failure
20
+ spark_python_task:
21
+ python_file: ../src/bricksentry_check.py
22
+ parameters:
23
+ - --tables
24
+ - "{{`{{job.trigger.table_update.updated_tables}}`}}"
25
+ - --default-tables
26
+ - "{{.tables}}"
27
+ # Every data change in the last 60 minutes is checked as one change.
28
+ - --since-minutes
29
+ - "60"
30
+ - --warehouse-id
31
+ - "{{.warehouse_id}}"
32
+ - --scratch-schema
33
+ - "{{.scratch_schema}}"
34
+ - --policy
35
+ - "{{.policy}}"
36
+ - --fail-on
37
+ - "{{.fail_on}}"
38
+ {{- if .keys}}
39
+ - --keys
40
+ - "{{.keys}}"
41
+ {{- end}}
42
+ {{- if .slack_secret}}
43
+ - --slack-secret
44
+ - "{{.slack_secret}}"
45
+ {{- end}}
46
+ - --run-url
47
+ - "{{`{{workspace.url}}/jobs/{{job.id}}/runs/{{job.run_id}}`}}"
48
+ # Tables without a PRIMARY KEY need key columns: --keys "main.sales.orders=order_id; ..."
49
+ environments:
50
+ - environment_key: default
51
+ spec:
52
+ environment_version: "2"
53
+ dependencies:
54
+ - bricksentry[databricks]>=0.1.15
@@ -311,8 +311,8 @@ def _render(text: str, values: dict) -> str:
311
311
  return text
312
312
 
313
313
 
314
- @pytest.mark.parametrize("slack", ["bricksentry/slack_webhook", ""])
315
- def test_bundle_template_renders(slack):
314
+ @pytest.mark.parametrize("slack,keys", [("bricksentry/slack_webhook", "main.sales.orders=order_id"), ("", "")])
315
+ def test_bundle_template_renders(slack, keys):
316
316
  from pathlib import Path
317
317
 
318
318
  import yaml
@@ -320,7 +320,8 @@ def test_bundle_template_renders(slack):
320
320
  root = Path(__file__).resolve().parents[1] / "templates" / "job-check"
321
321
  schema = json.loads((root / "databricks_template_schema.json").read_text())
322
322
  values = {k: p.get("default", "") for k, p in schema["properties"].items()}
323
- values.update(tables="main.sales.orders, main.sales.customers", warehouse_id="abc123", slack_secret=slack)
323
+ values.update(tables="main.sales.orders, main.sales.customers", warehouse_id="abc123", slack_secret=slack,
324
+ keys=keys)
324
325
  for k, p in schema["properties"].items():
325
326
  if "pattern" in p:
326
327
  assert re.fullmatch(p["pattern"], values[k]), k
@@ -335,6 +336,8 @@ def test_bundle_template_renders(slack):
335
336
  assert params[:2] == ["--tables", "{{job.trigger.table_update.updated_tables}}"]
336
337
  assert "{{workspace.url}}/jobs/{{job.id}}/runs/{{job.run_id}}" in params
337
338
  assert ("--slack-secret" in params) == bool(slack)
339
+ assert ("--keys" in params) == bool(keys)
340
+ assert task["max_retries"] == 0
338
341
  assert task["environment_key"] == j["environments"][0]["environment_key"]
339
342
  assert j["environments"][0]["spec"]["dependencies"][0].startswith("bricksentry[databricks]")
340
343
  # the job task's argv parses, and an unresolved trigger value falls back to --default-tables
@@ -355,3 +358,20 @@ def test_job_unresolved_trigger_value_uses_default_tables():
355
358
  def test_yaml_on_key_is_read():
356
359
  cfg = Config.from_dict(__import__("yaml").safe_load("notify:\n on: block\n"))
357
360
  assert cfg.notify == {"on": "block"} and not cfg.warnings
361
+
362
+
363
+ def test_job_main_returns_on_success_and_exits_on_failure(monkeypatch):
364
+ # Databricks marks a spark_python_task failed on any SystemExit, even 0 (found live in 0.1.14).
365
+ monkeypatch.setattr(job, "run", lambda argv: 0)
366
+ assert job.main([]) is None
367
+ monkeypatch.setattr(job, "run", lambda argv: 1)
368
+ with pytest.raises(SystemExit) as e:
369
+ job.main([])
370
+ assert e.value.code == 1
371
+
372
+
373
+ def test_job_keys_option():
374
+ lines: list[str] = []
375
+ code = job.run(["--tables", "sales.orders", "--keys", "sales.orders=order_id; sales.other=x",
376
+ "--scratch-schema", "scratch", "--fail-on", "never"], backend=FakeDelta(pk=()), out=lines.append)
377
+ assert code == 0 and "sales.orders: BLOCK" in lines[0]
@@ -1,202 +0,0 @@
1
-
2
- Apache License
3
- Version 2.0, January 2004
4
- http://www.apache.org/licenses/
5
-
6
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
-
8
- 1. Definitions.
9
-
10
- "License" shall mean the terms and conditions for use, reproduction,
11
- and distribution as defined by Sections 1 through 9 of this document.
12
-
13
- "Licensor" shall mean the copyright owner or entity authorized by
14
- the copyright owner that is granting the License.
15
-
16
- "Legal Entity" shall mean the union of the acting entity and all
17
- other entities that control, are controlled by, or are under common
18
- control with that entity. For the purposes of this definition,
19
- "control" means (i) the power, direct or indirect, to cause the
20
- direction or management of such entity, whether by contract or
21
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
- outstanding shares, or (iii) beneficial ownership of such entity.
23
-
24
- "You" (or "Your") shall mean an individual or Legal Entity
25
- exercising permissions granted by this License.
26
-
27
- "Source" form shall mean the preferred form for making modifications,
28
- including but not limited to software source code, documentation
29
- source, and configuration files.
30
-
31
- "Object" form shall mean any form resulting from mechanical
32
- transformation or translation of a Source form, including but
33
- not limited to compiled object code, generated documentation,
34
- and conversions to other media types.
35
-
36
- "Work" shall mean the work of authorship, whether in Source or
37
- Object form, made available under the License, as indicated by a
38
- copyright notice that is included in or attached to the work
39
- (an example is provided in the Appendix below).
40
-
41
- "Derivative Works" shall mean any work, whether in Source or Object
42
- form, that is based on (or derived from) the Work and for which the
43
- editorial revisions, annotations, elaborations, or other modifications
44
- represent, as a whole, an original work of authorship. For the purposes
45
- of this License, Derivative Works shall not include works that remain
46
- separable from, or merely link (or bind by name) to the interfaces of,
47
- the Work and Derivative Works thereof.
48
-
49
- "Contribution" shall mean any work of authorship, including
50
- the original version of the Work and any modifications or additions
51
- to that Work or Derivative Works thereof, that is intentionally
52
- submitted to Licensor for inclusion in the Work by the copyright owner
53
- or by an individual or Legal Entity authorized to submit on behalf of
54
- the copyright owner. For the purposes of this definition, "submitted"
55
- means any form of electronic, verbal, or written communication sent
56
- to the Licensor or its representatives, including but not limited to
57
- communication on electronic mailing lists, source code control systems,
58
- and issue tracking systems that are managed by, or on behalf of, the
59
- Licensor for the purpose of discussing and improving the Work, but
60
- excluding communication that is conspicuously marked or otherwise
61
- designated in writing by the copyright owner as "Not a Contribution."
62
-
63
- "Contributor" shall mean Licensor and any individual or Legal Entity
64
- on behalf of whom a Contribution has been received by Licensor and
65
- subsequently incorporated within the Work.
66
-
67
- 2. Grant of Copyright License. Subject to the terms and conditions of
68
- this License, each Contributor hereby grants to You a perpetual,
69
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
- copyright license to reproduce, prepare Derivative Works of,
71
- publicly display, publicly perform, sublicense, and distribute the
72
- Work and such Derivative Works in Source or Object form.
73
-
74
- 3. Grant of Patent License. Subject to the terms and conditions of
75
- this License, each Contributor hereby grants to You a perpetual,
76
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
- (except as stated in this section) patent license to make, have made,
78
- use, offer to sell, sell, import, and otherwise transfer the Work,
79
- where such license applies only to those patent claims licensable
80
- by such Contributor that are necessarily infringed by their
81
- Contribution(s) alone or by combination of their Contribution(s)
82
- with the Work to which such Contribution(s) was submitted. If You
83
- institute patent litigation against any entity (including a
84
- cross-claim or counterclaim in a lawsuit) alleging that the Work
85
- or a Contribution incorporated within the Work constitutes direct
86
- or contributory patent infringement, then any patent licenses
87
- granted to You under this License for that Work shall terminate
88
- as of the date such litigation is filed.
89
-
90
- 4. Redistribution. You may reproduce and distribute copies of the
91
- Work or Derivative Works thereof in any medium, with or without
92
- modifications, and in Source or Object form, provided that You
93
- meet the following conditions:
94
-
95
- (a) You must give any other recipients of the Work or
96
- Derivative Works a copy of this License; and
97
-
98
- (b) You must cause any modified files to carry prominent notices
99
- stating that You changed the files; and
100
-
101
- (c) You must retain, in the Source form of any Derivative Works
102
- that You distribute, all copyright, patent, trademark, and
103
- attribution notices from the Source form of the Work,
104
- excluding those notices that do not pertain to any part of
105
- the Derivative Works; and
106
-
107
- (d) If the Work includes a "NOTICE" text file as part of its
108
- distribution, then any Derivative Works that You distribute must
109
- include a readable copy of the attribution notices contained
110
- within such NOTICE file, excluding those notices that do not
111
- pertain to any part of the Derivative Works, in at least one
112
- of the following places: within a NOTICE text file distributed
113
- as part of the Derivative Works; within the Source form or
114
- documentation, if provided along with the Derivative Works; or,
115
- within a display generated by the Derivative Works, if and
116
- wherever such third-party notices normally appear. The contents
117
- of the NOTICE file are for informational purposes only and
118
- do not modify the License. You may add Your own attribution
119
- notices within Derivative Works that You distribute, alongside
120
- or as an addendum to the NOTICE text from the Work, provided
121
- that such additional attribution notices cannot be construed
122
- as modifying the License.
123
-
124
- You may add Your own copyright statement to Your modifications and
125
- may provide additional or different license terms and conditions
126
- for use, reproduction, or distribution of Your modifications, or
127
- for any such Derivative Works as a whole, provided Your use,
128
- reproduction, and distribution of the Work otherwise complies with
129
- the conditions stated in this License.
130
-
131
- 5. Submission of Contributions. Unless You explicitly state otherwise,
132
- any Contribution intentionally submitted for inclusion in the Work
133
- by You to the Licensor shall be under the terms and conditions of
134
- this License, without any additional terms or conditions.
135
- Notwithstanding the above, nothing herein shall supersede or modify
136
- the terms of any separate license agreement you may have executed
137
- with Licensor regarding such Contributions.
138
-
139
- 6. Trademarks. This License does not grant permission to use the trade
140
- names, trademarks, service marks, or product names of the Licensor,
141
- except as required for reasonable and customary use in describing the
142
- origin of the Work and reproducing the content of the NOTICE file.
143
-
144
- 7. Disclaimer of Warranty. Unless required by applicable law or
145
- agreed to in writing, Licensor provides the Work (and each
146
- Contributor provides its Contributions) on an "AS IS" BASIS,
147
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
- implied, including, without limitation, any warranties or conditions
149
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
- PARTICULAR PURPOSE. You are solely responsible for determining the
151
- appropriateness of using or redistributing the Work and assume any
152
- risks associated with Your exercise of permissions under this License.
153
-
154
- 8. Limitation of Liability. In no event and under no legal theory,
155
- whether in tort (including negligence), contract, or otherwise,
156
- unless required by applicable law (such as deliberate and grossly
157
- negligent acts) or agreed to in writing, shall any Contributor be
158
- liable to You for damages, including any direct, indirect, special,
159
- incidental, or consequential damages of any character arising as a
160
- result of this License or out of the use or inability to use the
161
- Work (including but not limited to damages for loss of goodwill,
162
- work stoppage, computer failure or malfunction, or any and all
163
- other commercial damages or losses), even if such Contributor
164
- has been advised of the possibility of such damages.
165
-
166
- 9. Accepting Warranty or Additional Liability. While redistributing
167
- the Work or Derivative Works thereof, You may choose to offer,
168
- and charge a fee for, acceptance of support, warranty, indemnity,
169
- or other liability obligations and/or rights consistent with this
170
- License. However, in accepting such obligations, You may act only
171
- on Your own behalf and on Your sole responsibility, not on behalf
172
- of any other Contributor, and only if You agree to indemnify,
173
- defend, and hold each Contributor harmless for any liability
174
- incurred by, or claims asserted against, such Contributor by reason
175
- of your accepting any such warranty or additional liability.
176
-
177
- END OF TERMS AND CONDITIONS
178
-
179
- APPENDIX: How to apply the Apache License to your work.
180
-
181
- To apply the Apache License to your work, attach the following
182
- boilerplate notice, with the fields enclosed by brackets "[]"
183
- replaced with your own identifying information. (Don't include
184
- the brackets!) The text should be enclosed in the appropriate
185
- comment syntax for the file format. We also recommend that a
186
- file or class name and description of purpose be included on the
187
- same "printed page" as the copyright notice for easier
188
- identification within third-party archives.
189
-
190
- Copyright [yyyy] [name of copyright owner]
191
-
192
- Licensed under the Apache License, Version 2.0 (the "License");
193
- you may not use this file except in compliance with the License.
194
- You may obtain a copy of the License at
195
-
196
- http://www.apache.org/licenses/LICENSE-2.0
197
-
198
- Unless required by applicable law or agreed to in writing, software
199
- distributed under the License is distributed on an "AS IS" BASIS,
200
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
- See the License for the specific language governing permissions and
202
- limitations under the License.
@@ -1,32 +0,0 @@
1
- # bricksentry-mcp
2
-
3
- <!-- mcp-name: io.github.bricksentry/bricksentry -->
4
-
5
- The MCP server for [bricksentry](https://github.com/bricksentry/bricksentry), the safety check for data changes in the AI era. This package only installs `bricksentry` with its MCP and Databricks extras and gives you one command, so agents can start the server with `uvx`:
6
-
7
- ```bash
8
- uvx bricksentry-mcp --config /full/path/to/bricksentry.yml
9
- ```
10
-
11
- **Claude Code**
12
-
13
- ```bash
14
- claude mcp add bricksentry -- uvx bricksentry-mcp --config /full/path/to/bricksentry.yml
15
- ```
16
-
17
- **Claude desktop, Cursor and other clients** (`mcpServers` config):
18
-
19
- ```json
20
- {
21
- "mcpServers": {
22
- "bricksentry": {
23
- "command": "uvx",
24
- "args": ["bricksentry-mcp", "--config", "/full/path/to/bricksentry.yml"]
25
- }
26
- }
27
- }
28
- ```
29
-
30
- Use a full path to `bricksentry.yml`: clients start the server from their own working folder. If an app can't find `uvx`, use its full path (`which uvx`).
31
-
32
- `bricksentry-mcp` accepts the same options as `bricksentry mcp`, for example `--transport streamable-http`. Docs: [bricksentry.org/docs/agents](https://bricksentry.org/docs/agents). License: Apache-2.0.
@@ -1,5 +0,0 @@
1
- """``bricksentry-mcp``: start the bricksentry MCP server (same as ``bricksentry mcp``)."""
2
-
3
- from bricksentry.cli import mcp_entry as main
4
-
5
- __all__ = ["main"]
File without changes
File without changes
File without changes
File without changes
File without changes