bricksentry 0.1.29__tar.gz → 0.1.30__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 (96) hide show
  1. {bricksentry-0.1.29 → bricksentry-0.1.30}/CHANGELOG.md +7 -0
  2. {bricksentry-0.1.29 → bricksentry-0.1.30}/PKG-INFO +24 -5
  3. {bricksentry-0.1.29 → bricksentry-0.1.30}/README.md +23 -4
  4. bricksentry-0.1.30/deploy/databricks-app/requirements.txt +1 -0
  5. {bricksentry-0.1.29 → bricksentry-0.1.30}/pyproject.toml +1 -1
  6. {bricksentry-0.1.29 → bricksentry-0.1.30}/server.json +2 -2
  7. {bricksentry-0.1.29 → bricksentry-0.1.30}/src/bricksentry/__init__.py +1 -1
  8. {bricksentry-0.1.29 → bricksentry-0.1.30}/src/bricksentry/assess.py +24 -2
  9. {bricksentry-0.1.29 → bricksentry-0.1.30}/src/bricksentry/explain.py +7 -1
  10. {bricksentry-0.1.29 → bricksentry-0.1.30}/templates/job-check/databricks_template_schema.json +2 -2
  11. bricksentry-0.1.30/tests/test_0130.py +52 -0
  12. bricksentry-0.1.29/deploy/databricks-app/requirements.txt +0 -1
  13. {bricksentry-0.1.29 → bricksentry-0.1.30}/.gitignore +0 -0
  14. {bricksentry-0.1.29 → bricksentry-0.1.30}/CONTRIBUTING.md +0 -0
  15. {bricksentry-0.1.29 → bricksentry-0.1.30}/LICENSE +0 -0
  16. {bricksentry-0.1.29 → bricksentry-0.1.30}/SECURITY.md +0 -0
  17. {bricksentry-0.1.29 → bricksentry-0.1.30}/action.yml +0 -0
  18. {bricksentry-0.1.29 → bricksentry-0.1.30}/deploy/container/Dockerfile +0 -0
  19. {bricksentry-0.1.29 → bricksentry-0.1.30}/deploy/databricks-app/README.md +0 -0
  20. {bricksentry-0.1.29 → bricksentry-0.1.30}/deploy/databricks-app/app.yaml +0 -0
  21. {bricksentry-0.1.29 → bricksentry-0.1.30}/deploy/databricks-app/bricksentry.yml +0 -0
  22. {bricksentry-0.1.29 → bricksentry-0.1.30}/deploy/databricks-app/databricks.yml +0 -0
  23. {bricksentry-0.1.29 → bricksentry-0.1.30}/deploy/databricks-app/grants.sql +0 -0
  24. {bricksentry-0.1.29 → bricksentry-0.1.30}/examples/databricks/bricksentry.yml +0 -0
  25. {bricksentry-0.1.29 → bricksentry-0.1.30}/examples/databricks/bricksentry_check_my_table.ipynb +0 -0
  26. {bricksentry-0.1.29 → bricksentry-0.1.30}/examples/databricks/bricksentry_check_my_table.py +0 -0
  27. {bricksentry-0.1.29 → bricksentry-0.1.30}/examples/databricks/bricksentry_hr_walkthrough.ipynb +0 -0
  28. {bricksentry-0.1.29 → bricksentry-0.1.30}/examples/databricks/bricksentry_hr_walkthrough.py +0 -0
  29. {bricksentry-0.1.29 → bricksentry-0.1.30}/examples/databricks/bricksentry_quickstart.ipynb +0 -0
  30. {bricksentry-0.1.29 → bricksentry-0.1.30}/examples/databricks/bricksentry_quickstart.py +0 -0
  31. {bricksentry-0.1.29 → bricksentry-0.1.30}/examples/databricks/bricksentry_validation.ipynb +0 -0
  32. {bricksentry-0.1.29 → bricksentry-0.1.30}/examples/databricks/bricksentry_validation.py +0 -0
  33. {bricksentry-0.1.29 → bricksentry-0.1.30}/examples/databricks/github-workflow.yml +0 -0
  34. {bricksentry-0.1.29 → bricksentry-0.1.30}/examples/databricks/policy.yml +0 -0
  35. {bricksentry-0.1.29 → bricksentry-0.1.30}/examples/demo/agent_loop_demo.py +0 -0
  36. {bricksentry-0.1.29 → bricksentry-0.1.30}/scripts/build_notebook.py +0 -0
  37. {bricksentry-0.1.29 → bricksentry-0.1.30}/scripts/render_demo_image.py +0 -0
  38. {bricksentry-0.1.29 → bricksentry-0.1.30}/src/bricksentry/__main__.py +0 -0
  39. {bricksentry-0.1.29 → bricksentry-0.1.30}/src/bricksentry/agent_tools.py +0 -0
  40. {bricksentry-0.1.29 → bricksentry-0.1.30}/src/bricksentry/agent_view.py +0 -0
  41. {bricksentry-0.1.29 → bricksentry-0.1.30}/src/bricksentry/backends/__init__.py +0 -0
  42. {bricksentry-0.1.29 → bricksentry-0.1.30}/src/bricksentry/backends/base.py +0 -0
  43. {bricksentry-0.1.29 → bricksentry-0.1.30}/src/bricksentry/backends/databricks_backend.py +0 -0
  44. {bricksentry-0.1.29 → bricksentry-0.1.30}/src/bricksentry/backends/duckdb_backend.py +0 -0
  45. {bricksentry-0.1.29 → bricksentry-0.1.30}/src/bricksentry/changes.py +0 -0
  46. {bricksentry-0.1.29 → bricksentry-0.1.30}/src/bricksentry/cli.py +0 -0
  47. {bricksentry-0.1.29 → bricksentry-0.1.30}/src/bricksentry/config.py +0 -0
  48. {bricksentry-0.1.29 → bricksentry-0.1.30}/src/bricksentry/demo.py +0 -0
  49. {bricksentry-0.1.29 → bricksentry-0.1.30}/src/bricksentry/diff.py +0 -0
  50. {bricksentry-0.1.29 → bricksentry-0.1.30}/src/bricksentry/github.py +0 -0
  51. {bricksentry-0.1.29 → bricksentry-0.1.30}/src/bricksentry/history.py +0 -0
  52. {bricksentry-0.1.29 → bricksentry-0.1.30}/src/bricksentry/job.py +0 -0
  53. {bricksentry-0.1.29 → bricksentry-0.1.30}/src/bricksentry/job_demo.py +0 -0
  54. {bricksentry-0.1.29 → bricksentry-0.1.30}/src/bricksentry/lineage.py +0 -0
  55. {bricksentry-0.1.29 → bricksentry-0.1.30}/src/bricksentry/mcp_server.py +0 -0
  56. {bricksentry-0.1.29 → bricksentry-0.1.30}/src/bricksentry/measures.py +0 -0
  57. {bricksentry-0.1.29 → bricksentry-0.1.30}/src/bricksentry/models.py +0 -0
  58. {bricksentry-0.1.29 → bricksentry-0.1.30}/src/bricksentry/netguard.py +0 -0
  59. {bricksentry-0.1.29 → bricksentry-0.1.30}/src/bricksentry/notify.py +0 -0
  60. {bricksentry-0.1.29 → bricksentry-0.1.30}/src/bricksentry/policy.py +0 -0
  61. {bricksentry-0.1.29 → bricksentry-0.1.30}/src/bricksentry/policy_templates.py +0 -0
  62. {bricksentry-0.1.29 → bricksentry-0.1.30}/src/bricksentry/preview.py +0 -0
  63. {bricksentry-0.1.29 → bricksentry-0.1.30}/src/bricksentry/py.typed +0 -0
  64. {bricksentry-0.1.29 → bricksentry-0.1.30}/src/bricksentry/report.py +0 -0
  65. {bricksentry-0.1.29 → bricksentry-0.1.30}/src/bricksentry/validation.py +0 -0
  66. {bricksentry-0.1.29 → bricksentry-0.1.30}/templates/job-check/README.md +0 -0
  67. {bricksentry-0.1.29 → bricksentry-0.1.30}/templates/job-check/template/{{.project_name}}/.gitignore +0 -0
  68. {bricksentry-0.1.29 → bricksentry-0.1.30}/templates/job-check/template/{{.project_name}}/README.md.tmpl +0 -0
  69. {bricksentry-0.1.29 → bricksentry-0.1.30}/templates/job-check/template/{{.project_name}}/databricks.yml.tmpl +0 -0
  70. {bricksentry-0.1.29 → bricksentry-0.1.30}/templates/job-check/template/{{.project_name}}/resources/bricksentry_check.job.yml.tmpl +0 -0
  71. {bricksentry-0.1.29 → bricksentry-0.1.30}/templates/job-check/template/{{.project_name}}/src/bricksentry_check.py +0 -0
  72. {bricksentry-0.1.29 → bricksentry-0.1.30}/templates/job-check/template/{{.project_name}}/src/bricksentry_demo.py +0 -0
  73. {bricksentry-0.1.29 → bricksentry-0.1.30}/tests/conftest.py +0 -0
  74. {bricksentry-0.1.29 → bricksentry-0.1.30}/tests/test_0110.py +0 -0
  75. {bricksentry-0.1.29 → bricksentry-0.1.30}/tests/test_0112.py +0 -0
  76. {bricksentry-0.1.29 → bricksentry-0.1.30}/tests/test_0114.py +0 -0
  77. {bricksentry-0.1.29 → bricksentry-0.1.30}/tests/test_0120.py +0 -0
  78. {bricksentry-0.1.29 → bricksentry-0.1.30}/tests/test_0121.py +0 -0
  79. {bricksentry-0.1.29 → bricksentry-0.1.30}/tests/test_0122.py +0 -0
  80. {bricksentry-0.1.29 → bricksentry-0.1.30}/tests/test_0123.py +0 -0
  81. {bricksentry-0.1.29 → bricksentry-0.1.30}/tests/test_0126.py +0 -0
  82. {bricksentry-0.1.29 → bricksentry-0.1.30}/tests/test_0127.py +0 -0
  83. {bricksentry-0.1.29 → bricksentry-0.1.30}/tests/test_0128.py +0 -0
  84. {bricksentry-0.1.29 → bricksentry-0.1.30}/tests/test_0129.py +0 -0
  85. {bricksentry-0.1.29 → bricksentry-0.1.30}/tests/test_018.py +0 -0
  86. {bricksentry-0.1.29 → bricksentry-0.1.30}/tests/test_019.py +0 -0
  87. {bricksentry-0.1.29 → bricksentry-0.1.30}/tests/test_assess_policy.py +0 -0
  88. {bricksentry-0.1.29 → bricksentry-0.1.30}/tests/test_check_notebook.py +0 -0
  89. {bricksentry-0.1.29 → bricksentry-0.1.30}/tests/test_databricks_and_uc.py +0 -0
  90. {bricksentry-0.1.29 → bricksentry-0.1.30}/tests/test_demo.py +0 -0
  91. {bricksentry-0.1.29 → bricksentry-0.1.30}/tests/test_diff.py +0 -0
  92. {bricksentry-0.1.29 → bricksentry-0.1.30}/tests/test_hr_notebook.py +0 -0
  93. {bricksentry-0.1.29 → bricksentry-0.1.30}/tests/test_notebook.py +0 -0
  94. {bricksentry-0.1.29 → bricksentry-0.1.30}/tests/test_notify_templates.py +0 -0
  95. {bricksentry-0.1.29 → bricksentry-0.1.30}/tests/test_preview_agents.py +0 -0
  96. {bricksentry-0.1.29 → bricksentry-0.1.30}/tests/test_sample_guard_and_store.py +0 -0
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.30 (2026-11-18)
4
+
5
+ A patch from the first real use of bricksentry as an assistant's safety gate: an assistant built a Bronze/Silver/Gold HR pipeline, then changed the Gold logic only after `whats_downstream`, `rollback_plan`, `preview_write` and `safe_to_ship`. Verified on Databricks before release: the CTAS preview that failed now runs with exact counts, a CTAS reading the table it replaces works, nothing is left in the sandbox, production stays at its version, and the battery passed 15 of 15.
6
+
7
+ - **`CREATE OR REPLACE TABLE` previews work on serverless.** The preview replaced the shallow clone itself, which serverless refuses (`CLUSTER BY AUTO is only supported on UC Managed tables`, because new tables get automatic clustering by default). The statement's result now goes into a fresh sandbox table, the clone stays for reading the target (`CREATE OR REPLACE TABLE t AS SELECT ... FROM t`), and both are dropped afterwards. Other writes still run on the clone. Found while an assistant built and changed an HR pipeline with bricksentry as its gate.
8
+ - Agent errors keep quoted text that has no letters or digits, such as Delta's list of characters a column name can't contain (` ,;{}()\n\t=`), so an agent can see it needs a column alias. Quoted values are still hidden.
9
+
3
10
  ## 0.1.29 (2026-11-17)
4
11
 
5
12
  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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: bricksentry
3
- Version: 0.1.29
3
+ Version: 0.1.30
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
@@ -46,15 +46,22 @@ Provides-Extra: mcp
46
46
  Requires-Dist: mcp>=1.10; extra == 'mcp'
47
47
  Description-Content-Type: text/markdown
48
48
 
49
- # Welcome to bricksentry
49
+ # bricksentry
50
50
 
51
51
  <!-- mcp-name: io.github.bricksentry/bricksentry -->
52
52
 
53
53
  [![PyPI](https://img.shields.io/pypi/v/bricksentry)](https://pypi.org/project/bricksentry/) [![Python](https://img.shields.io/pypi/pyversions/bricksentry)](https://pypi.org/project/bricksentry/) [![Tests](https://github.com/bricksentry/bricksentry/actions/workflows/ci.yml/badge.svg)](https://github.com/bricksentry/bricksentry/actions/workflows/ci.yml) [![Lint](https://github.com/bricksentry/bricksentry/actions/workflows/lint.yml/badge.svg)](https://github.com/bricksentry/bricksentry/actions/workflows/lint.yml) [![Coverage](https://img.shields.io/badge/coverage-%E2%89%A575%25%20enforced-brightgreen)](https://github.com/bricksentry/bricksentry/actions/workflows/ci.yml) [![License](https://img.shields.io/badge/license-Apache--2.0-blue)](LICENSE) [![Status](https://img.shields.io/badge/status-public%20beta-orange)](#project-status-public-beta)
54
54
 
55
- ***The safety check for data changes in the AI era.***
55
+ ***See what a data change does before it ships.***
56
56
 
57
- Change-safety for Databricks pipelines and the AI agents that edit them: know what a change does to your data before it ships.
57
+ A pipeline change or an AI agent's MERGE can look right, pass every test and still quietly duplicate or drop rows. bricksentry checks the data itself before the change reaches production: it compares the rows the change would produce with what's there now, shows what's downstream in Unity Catalog lineage, and gives a verdict from your own policy: **pass**, **needs a human**, or **block**.
58
+
59
+ - **Real data, not a guess.** Agent previews run the statement on a disposable shallow clone; PR checks compare the tables your branch built. Rows added, removed and changed, column by column, exact to the row.
60
+ - **Fails closed.** If something can't be verified (a failed diff, a masked column, a table rewritten mid-check), it asks a human. It never treats "couldn't check" as a pass.
61
+ - **Agents see counts, never values,** and only for the tables you allow, including tables reached through views and SQL functions.
62
+ - **Fits how you work:** a GitHub PR check, a Databricks job task, a CLI, Python, or an MCP server for AI agents (with token auth over the network). Rollback plans come with every verdict.
63
+
64
+ *Public beta: tested in [ten adversarial rounds](VALIDATION.md), with every finding fixed and published.*
58
65
 
59
66
  **[Try it in 30 seconds](#1-try-it-in-30-seconds-on-your-laptop)** · **[Check every change on Databricks](#2-check-every-change-to-your-tables-on-databricks)** · **[Docs: bricksentry.org](https://bricksentry.org)** · **[Validated live: what we tested and found](VALIDATION.md)** · **[LinkedIn](https://www.linkedin.com/company/bricksentry-org/)**
60
67
 
@@ -502,7 +509,19 @@ bricksentry is in **public beta** (0.1.x). It has been tested hard but only by i
502
509
 
503
510
  **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
511
 
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).
512
+ **Before 1.0**, these need proving in environments other than the author's:
513
+
514
+ | What | How it gets checked |
515
+ |---|---|
516
+ | Separate identities: an agent identity that isn't bricksentry's, and people exempt from column masks | A team with service principals runs the validation notebook under a second identity |
517
+ | Classic compute (clusters and classic SQL warehouses), including its query-plan format | A validation report from classic compute |
518
+ | AWS, Azure and GCP workspaces | Validation reports from at least two clouds |
519
+ | The added time of the query-plan check on each agent preview, with several agents at once | Measured live |
520
+ | Pull-request comments and `--from-git` on the current code | Re-run on a real repository |
521
+ | The MCP server over weeks: long runs and restarts | A team running it day to day |
522
+ | Count probing on listed tables (documented above) | Kept as documented, or an optional per-table limit if users ask for one |
523
+
524
+ **1.0** comes when those are done and two or three outside teams have run it on real pipelines for a month without a serious finding. 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
525
 
507
526
  ## Known limits (v0.1.x)
508
527
 
@@ -1,12 +1,19 @@
1
- # Welcome to bricksentry
1
+ # bricksentry
2
2
 
3
3
  <!-- mcp-name: io.github.bricksentry/bricksentry -->
4
4
 
5
5
  [![PyPI](https://img.shields.io/pypi/v/bricksentry)](https://pypi.org/project/bricksentry/) [![Python](https://img.shields.io/pypi/pyversions/bricksentry)](https://pypi.org/project/bricksentry/) [![Tests](https://github.com/bricksentry/bricksentry/actions/workflows/ci.yml/badge.svg)](https://github.com/bricksentry/bricksentry/actions/workflows/ci.yml) [![Lint](https://github.com/bricksentry/bricksentry/actions/workflows/lint.yml/badge.svg)](https://github.com/bricksentry/bricksentry/actions/workflows/lint.yml) [![Coverage](https://img.shields.io/badge/coverage-%E2%89%A575%25%20enforced-brightgreen)](https://github.com/bricksentry/bricksentry/actions/workflows/ci.yml) [![License](https://img.shields.io/badge/license-Apache--2.0-blue)](LICENSE) [![Status](https://img.shields.io/badge/status-public%20beta-orange)](#project-status-public-beta)
6
6
 
7
- ***The safety check for data changes in the AI era.***
7
+ ***See what a data change does before it ships.***
8
8
 
9
- Change-safety for Databricks pipelines and the AI agents that edit them: know what a change does to your data before it ships.
9
+ A pipeline change or an AI agent's MERGE can look right, pass every test and still quietly duplicate or drop rows. bricksentry checks the data itself before the change reaches production: it compares the rows the change would produce with what's there now, shows what's downstream in Unity Catalog lineage, and gives a verdict from your own policy: **pass**, **needs a human**, or **block**.
10
+
11
+ - **Real data, not a guess.** Agent previews run the statement on a disposable shallow clone; PR checks compare the tables your branch built. Rows added, removed and changed, column by column, exact to the row.
12
+ - **Fails closed.** If something can't be verified (a failed diff, a masked column, a table rewritten mid-check), it asks a human. It never treats "couldn't check" as a pass.
13
+ - **Agents see counts, never values,** and only for the tables you allow, including tables reached through views and SQL functions.
14
+ - **Fits how you work:** a GitHub PR check, a Databricks job task, a CLI, Python, or an MCP server for AI agents (with token auth over the network). Rollback plans come with every verdict.
15
+
16
+ *Public beta: tested in [ten adversarial rounds](VALIDATION.md), with every finding fixed and published.*
10
17
 
11
18
  **[Try it in 30 seconds](#1-try-it-in-30-seconds-on-your-laptop)** · **[Check every change on Databricks](#2-check-every-change-to-your-tables-on-databricks)** · **[Docs: bricksentry.org](https://bricksentry.org)** · **[Validated live: what we tested and found](VALIDATION.md)** · **[LinkedIn](https://www.linkedin.com/company/bricksentry-org/)**
12
19
 
@@ -454,7 +461,19 @@ bricksentry is in **public beta** (0.1.x). It has been tested hard but only by i
454
461
 
455
462
  **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
463
 
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).
464
+ **Before 1.0**, these need proving in environments other than the author's:
465
+
466
+ | What | How it gets checked |
467
+ |---|---|
468
+ | Separate identities: an agent identity that isn't bricksentry's, and people exempt from column masks | A team with service principals runs the validation notebook under a second identity |
469
+ | Classic compute (clusters and classic SQL warehouses), including its query-plan format | A validation report from classic compute |
470
+ | AWS, Azure and GCP workspaces | Validation reports from at least two clouds |
471
+ | The added time of the query-plan check on each agent preview, with several agents at once | Measured live |
472
+ | Pull-request comments and `--from-git` on the current code | Re-run on a real repository |
473
+ | The MCP server over weeks: long runs and restarts | A team running it day to day |
474
+ | Count probing on listed tables (documented above) | Kept as documented, or an optional per-table limit if users ask for one |
475
+
476
+ **1.0** comes when those are done and two or three outside teams have run it on real pipelines for a month without a serious finding. 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
477
 
459
478
  ## Known limits (v0.1.x)
460
479
 
@@ -0,0 +1 @@
1
+ bricksentry[databricks,mcp]==0.1.30
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "bricksentry"
7
- version = "0.1.29"
7
+ version = "0.1.30"
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"
@@ -8,12 +8,12 @@
8
8
  "source": "github"
9
9
  },
10
10
  "websiteUrl": "https://bricksentry.org",
11
- "version": "0.1.29",
11
+ "version": "0.1.30",
12
12
  "packages": [
13
13
  {
14
14
  "registryType": "pypi",
15
15
  "identifier": "bricksentry-mcp",
16
- "version": "0.1.29",
16
+ "version": "0.1.30",
17
17
  "runtimeHint": "uvx",
18
18
  "transport": {
19
19
  "type": "stdio"
@@ -23,4 +23,4 @@ __all__ = [
23
23
  "TableDiff",
24
24
  "Verdict",
25
25
  ]
26
- __version__ = "0.1.29"
26
+ __version__ = "0.1.30"
@@ -220,6 +220,16 @@ class Sentry:
220
220
  f"Could not clone {target} to preview the write: {_first_line(e)}. Check the table name "
221
221
  f"and that you can create tables in {schema or 'the sandbox schema'}."
222
222
  ) from None
223
+ # CREATE OR REPLACE TABLE writes its result into a fresh sandbox table rather than
224
+ # replacing the clone: some engines refuse to replace a shallow clone (serverless
225
+ # applies CLUSTER BY AUTO to new tables, which a clone can't take). The clone stays,
226
+ # for statements that read the target (CREATE OR REPLACE TABLE t AS SELECT ... FROM t).
227
+ result = clone
228
+ m = _REPLACE_HEAD.match(rewritten)
229
+ if m:
230
+ result = clone + "_out"
231
+ rewritten = rewritten[: m.start("name")] + ".".join(
232
+ self.backend.quote(p) for p in result.split(".")) + rewritten[m.end("name"):]
223
233
  try:
224
234
  try:
225
235
  self.backend.execute(rewritten)
@@ -227,13 +237,18 @@ class Sentry:
227
237
  raise RuntimeError(
228
238
  f"The statement failed on the preview clone, so production was not touched: {_first_line(e)}"
229
239
  ) from None
230
- diff = self.diff(target, clone, keys=keys, table=target)
240
+ diff = self.diff(target, result, keys=keys, table=target)
231
241
  assessment = self.assess([target], diffs={target: diff})
232
242
  finally:
233
243
  if not keep:
234
244
  self.backend.drop(clone)
245
+ if result != clone:
246
+ try:
247
+ self.backend.drop(result)
248
+ except Exception:
249
+ pass
235
250
  out = assessment.to_dict()
236
- out["preview"] = {"sandbox_table": clone if keep else None, "executed_sql": rewritten}
251
+ out["preview"] = {"sandbox_table": result if keep else None, "executed_sql": rewritten}
237
252
  return out
238
253
 
239
254
  # --- alerts ---------------------------------------------------------------
@@ -309,6 +324,13 @@ def changed_columns(diff: TableDiff | None) -> list[str]:
309
324
  return list(dict.fromkeys(out))
310
325
 
311
326
 
327
+ _REPLACE_HEAD = re.compile(
328
+ r"^\s*(?:CREATE\s+OR\s+REPLACE\s+TABLE|REPLACE\s+TABLE)\s+(?P<name>(?:`[^`]+`|\"[^\"]+\"|[\w\-]+)"
329
+ r"(?:\.(?:`[^`]+`|\"[^\"]+\"|[\w\-]+))*)",
330
+ re.IGNORECASE,
331
+ )
332
+
333
+
312
334
  def _first_line(e: BaseException) -> str:
313
335
  """The useful part of an engine error: its first line, trimmed."""
314
336
  text = str(e).strip()
@@ -134,4 +134,10 @@ def redact_values(text: str) -> str:
134
134
  or DuckDB's ``Casting value "1975308.64"``: engines quote data values in single or
135
135
  double quotes. Backticked names stay. Some type names in double quotes go too.
136
136
  Apostrophes inside words ("can't") aren't quotes and stay."""
137
- return _QUOTED.sub("'…'", text)
137
+ def hide(m: re.Match) -> str:
138
+ inner = re.sub(r"\\[ntr]", " ", m.group(0)[1:-1]) # escapes like \n count as punctuation
139
+ # Punctuation and whitespace only (e.g. Delta's list of characters a column name
140
+ # can't contain) isn't data and tells the agent how to fix the statement.
141
+ return m.group(0) if inner and not any(ch.isalnum() for ch in inner) else "'…'"
142
+
143
+ return _QUOTED.sub(hide, text)
@@ -86,10 +86,10 @@
86
86
  },
87
87
  "bricksentry_version": {
88
88
  "type": "string",
89
- "default": "0.1.29",
89
+ "default": "0.1.30",
90
90
  "description": "bricksentry version to install in the job (pinned; change it and redeploy to upgrade)",
91
91
  "pattern": "^\\d+\\.\\d+\\.\\d+$",
92
- "pattern_match_failure_message": "Use a version like 0.1.29.",
92
+ "pattern_match_failure_message": "Use a version like 0.1.30.",
93
93
  "order": 10
94
94
  }
95
95
  },
@@ -0,0 +1,52 @@
1
+ """0.1.30: CREATE OR REPLACE TABLE previews write into a fresh sandbox table."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from bricksentry import Config, Sentry
6
+ from bricksentry.backends.duckdb_backend import DuckDBBackend
7
+
8
+
9
+ class NoReplaceOnClone(DuckDBBackend):
10
+ """Like serverless: replacing the shallow clone itself is refused."""
11
+
12
+ def execute(self, sql):
13
+ if "CREATE OR REPLACE TABLE" in sql.upper() and "__bs_" in sql and not sql.split("AS")[0].strip().endswith('_out"'):
14
+ raise RuntimeError("[CLUSTER_BY_AUTO_UNSUPPORTED_TABLE_TYPE_ERROR] CLUSTER BY AUTO is only supported on UC Managed tables")
15
+ return super().execute(sql)
16
+
17
+
18
+ def _sentry(b):
19
+ b.execute("CREATE SCHEMA hr")
20
+ b.execute("CREATE TABLE hr.gold AS SELECT * FROM (VALUES ('eng', 8), ('hr', 7), ('fin', 7)) t(department, headcount)")
21
+ return Sentry(Config.from_dict({"sandbox_schema": "sandbox", "assessment_store": False,
22
+ "tables": {"hr.gold": {"keys": ["department"]}}}), backend=b)
23
+
24
+
25
+ def test_create_or_replace_preview_reads_the_target_and_writes_a_fresh_table():
26
+ b = NoReplaceOnClone()
27
+ s = _sentry(b)
28
+ out = s.preview_write(
29
+ "CREATE OR REPLACE TABLE {{target}} AS SELECT department, headcount + 1 AS headcount FROM {{target}} "
30
+ "WHERE department <> 'fin'", "hr.gold")
31
+ d = out["tables"][0]["diff"]
32
+ assert (d["changed_rows"], d["removed_rows"], d["added_rows"]) == (2, 1, 0)
33
+ assert "_out" in out["preview"]["executed_sql"].split(" AS ")[0]
34
+ left = b.query("SELECT table_name FROM information_schema.tables WHERE table_schema = 'sandbox'")
35
+ assert left == [] # clone and result both dropped
36
+ assert b.query("SELECT SUM(headcount) AS n FROM hr.gold")[0]["n"] == 22 # production untouched
37
+
38
+
39
+ def test_other_writes_still_use_the_clone():
40
+ b = DuckDBBackend()
41
+ s = _sentry(b)
42
+ out = s.preview_write("UPDATE {{target}} SET headcount = 0 WHERE department = 'hr'", "hr.gold")
43
+ assert out["tables"][0]["diff"]["changed_rows"] == 1
44
+ assert "_out" not in out["preview"]["executed_sql"]
45
+
46
+
47
+ def test_redaction_keeps_punctuation_only_lists():
48
+ from bricksentry.explain import redact_values as r
49
+
50
+ msg = "[DELTA_INVALID_CHARACTERS_IN_COLUMN_NAMES] Found invalid character(s) among ' ,;{}()\\n\\t=' in the column names"
51
+ assert "' ,;{}()" in r(msg)
52
+ assert r("The value '123-45-6789' can't be cast") == "The value '…' can't be cast"
@@ -1 +0,0 @@
1
- bricksentry[databricks,mcp]==0.1.29
File without changes
File without changes
File without changes
File without changes