dimctx 0.3.0__tar.gz → 0.3.1__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.
- {dimctx-0.3.0/src/dimctx.egg-info → dimctx-0.3.1}/PKG-INFO +4 -4
- {dimctx-0.3.0 → dimctx-0.3.1}/README.md +3 -3
- {dimctx-0.3.0 → dimctx-0.3.1}/pyproject.toml +1 -1
- {dimctx-0.3.0 → dimctx-0.3.1}/src/dimctx/core/detector.py +9 -6
- {dimctx-0.3.0 → dimctx-0.3.1}/src/dimctx/tools.py +6 -0
- {dimctx-0.3.0 → dimctx-0.3.1/src/dimctx.egg-info}/PKG-INFO +4 -4
- {dimctx-0.3.0 → dimctx-0.3.1}/tests/test_dimctx.py +29 -0
- {dimctx-0.3.0 → dimctx-0.3.1}/LICENSE +0 -0
- {dimctx-0.3.0 → dimctx-0.3.1}/NOTICE +0 -0
- {dimctx-0.3.0 → dimctx-0.3.1}/setup.cfg +0 -0
- {dimctx-0.3.0 → dimctx-0.3.1}/src/dimctx/__init__.py +0 -0
- {dimctx-0.3.0 → dimctx-0.3.1}/src/dimctx/core/__init__.py +0 -0
- {dimctx-0.3.0 → dimctx-0.3.1}/src/dimctx/core/canon.py +0 -0
- {dimctx-0.3.0 → dimctx-0.3.1}/src/dimctx/core/complexity.py +0 -0
- {dimctx-0.3.0 → dimctx-0.3.1}/src/dimctx/core/matrix.py +0 -0
- {dimctx-0.3.0 → dimctx-0.3.1}/src/dimctx/core/profiler.py +0 -0
- {dimctx-0.3.0 → dimctx-0.3.1}/src/dimctx/models.py +0 -0
- {dimctx-0.3.0 → dimctx-0.3.1}/src/dimctx/server.py +0 -0
- {dimctx-0.3.0 → dimctx-0.3.1}/src/dimctx.egg-info/SOURCES.txt +0 -0
- {dimctx-0.3.0 → dimctx-0.3.1}/src/dimctx.egg-info/dependency_links.txt +0 -0
- {dimctx-0.3.0 → dimctx-0.3.1}/src/dimctx.egg-info/entry_points.txt +0 -0
- {dimctx-0.3.0 → dimctx-0.3.1}/src/dimctx.egg-info/requires.txt +0 -0
- {dimctx-0.3.0 → dimctx-0.3.1}/src/dimctx.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dimctx
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.1
|
|
4
4
|
Summary: dimctx = dimensional modeling context provider — MCP server giving AI coding assistants Kimball modeling judgement, bus-matrix truth, and SQL complexity checks.
|
|
5
5
|
Author: wagic
|
|
6
6
|
License: AGPL-3.0-or-later
|
|
@@ -35,7 +35,7 @@ AI 写 SQL/DDL 时会瞎编建模决策:分不清事实和维度、猜不准
|
|
|
35
35
|
|
|
36
36
|
| 工具 | 作用 |
|
|
37
37
|
|---|---|
|
|
38
|
-
| `analyze_table` | 判定表角色(fact/dimension)、粒度键、SCD 建议(按原典 Type 2
|
|
38
|
+
| `analyze_table` | 判定表角色(fact/dimension)、粒度键、SCD 建议(按原典 Type 2 三列签名)、总线矩阵格值;事实表用了可更新键模型时附类型债检查(见下);判为事实表却戴 `dim_` 前缀时给出 `naming_misalignment` |
|
|
39
39
|
| `search_canon` | 检索**你自备**的建模语料(本地 markdown,可配多个目录) |
|
|
40
40
|
| `bus_matrix` | 总线矩阵查询(单表格值 / 单维度实现 / 全库概览) |
|
|
41
41
|
| `measure_sql` | 度量下游取数复杂度(CASE WHEN / JOIN 深度 / 子查询 / 聚合嵌套) |
|
|
@@ -76,9 +76,9 @@ export DIMCTX_ANALYSIS_DIR=/path/to/notes # 你自己的分析笔记(可选
|
|
|
76
76
|
## 开发
|
|
77
77
|
|
|
78
78
|
```bash
|
|
79
|
-
uv run --with pytest --with pydantic python -m pytest tests/ -q #
|
|
79
|
+
uv run --with pytest --with pydantic python -m pytest tests/ -q # 26 passed, 15 skipped(图谱相关用例跳过)
|
|
80
80
|
# 有工程表图谱时可全跑:
|
|
81
|
-
DIMCTX_TEST_ATLAS=/path/to/atlas.json uv run --with pytest --with pydantic python -m pytest tests/ -q #
|
|
81
|
+
DIMCTX_TEST_ATLAS=/path/to/atlas.json uv run --with pytest --with pydantic python -m pytest tests/ -q # 41 passed
|
|
82
82
|
```
|
|
83
83
|
|
|
84
84
|
## 许可
|
|
@@ -14,7 +14,7 @@ AI 写 SQL/DDL 时会瞎编建模决策:分不清事实和维度、猜不准
|
|
|
14
14
|
|
|
15
15
|
| 工具 | 作用 |
|
|
16
16
|
|---|---|
|
|
17
|
-
| `analyze_table` | 判定表角色(fact/dimension)、粒度键、SCD 建议(按原典 Type 2
|
|
17
|
+
| `analyze_table` | 判定表角色(fact/dimension)、粒度键、SCD 建议(按原典 Type 2 三列签名)、总线矩阵格值;事实表用了可更新键模型时附类型债检查(见下);判为事实表却戴 `dim_` 前缀时给出 `naming_misalignment` |
|
|
18
18
|
| `search_canon` | 检索**你自备**的建模语料(本地 markdown,可配多个目录) |
|
|
19
19
|
| `bus_matrix` | 总线矩阵查询(单表格值 / 单维度实现 / 全库概览) |
|
|
20
20
|
| `measure_sql` | 度量下游取数复杂度(CASE WHEN / JOIN 深度 / 子查询 / 聚合嵌套) |
|
|
@@ -55,9 +55,9 @@ export DIMCTX_ANALYSIS_DIR=/path/to/notes # 你自己的分析笔记(可选
|
|
|
55
55
|
## 开发
|
|
56
56
|
|
|
57
57
|
```bash
|
|
58
|
-
uv run --with pytest --with pydantic python -m pytest tests/ -q #
|
|
58
|
+
uv run --with pytest --with pydantic python -m pytest tests/ -q # 26 passed, 15 skipped(图谱相关用例跳过)
|
|
59
59
|
# 有工程表图谱时可全跑:
|
|
60
|
-
DIMCTX_TEST_ATLAS=/path/to/atlas.json uv run --with pytest --with pydantic python -m pytest tests/ -q #
|
|
60
|
+
DIMCTX_TEST_ATLAS=/path/to/atlas.json uv run --with pytest --with pydantic python -m pytest tests/ -q # 41 passed
|
|
61
61
|
```
|
|
62
62
|
|
|
63
63
|
## 许可
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "dimctx"
|
|
7
|
-
version = "0.3.
|
|
7
|
+
version = "0.3.1"
|
|
8
8
|
description = "dimctx = dimensional modeling context provider — MCP server giving AI coding assistants Kimball modeling judgement, bus-matrix truth, and SQL complexity checks."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -249,10 +249,13 @@ def check_bus_matrix(entries: List[Dict[str, Any]], table_edges: List[Dict[str,
|
|
|
249
249
|
|
|
250
250
|
|
|
251
251
|
def naming_alignment(table: str, role: str) -> Optional[str]:
|
|
252
|
-
"""D5
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
252
|
+
"""D5:前缀与角色矛盾——只报证据最强的一种:判为事实表却戴着 dim_ 前缀。
|
|
253
|
+
|
|
254
|
+
「维度表却没有 dim_ 前缀」不报:命名约定各异(customers、date_dim 都合法),报了全是噪声。
|
|
255
|
+
命中时的含义:维度层里混进了一张事实(治理场景「事实表被设计成了维表」)——
|
|
256
|
+
实例:一张每批次一行、带三类时间各自最早/最晚共六个时间列与 update_count 的表,其实是批次时间快照。
|
|
257
|
+
"""
|
|
258
|
+
if role == "fact" and table.split("_")[0] == "dim":
|
|
259
|
+
return (f"角色判为事实表,但表名前缀是 dim_——维度层里混入了事实;"
|
|
260
|
+
"核对其粒度:若一行对应一个流程实例并带里程碑时间,它是累积快照,应移出维度层")
|
|
258
261
|
return None
|
|
@@ -156,10 +156,16 @@ def analyze_table(table: str = "", ddl: str = "") -> Dict:
|
|
|
156
156
|
|
|
157
157
|
conf = min(1.0, abs(role["fact_score"] - role["dim_score"]) / 4.0)
|
|
158
158
|
out = {"role": role["role"], "grain": grain,
|
|
159
|
+
"grain_note": "grain 是由前导键列推断的列级粒度键候选。原典要求粒度以业务术语声明"
|
|
160
|
+
"(「一行代表…」)——列出键列或维度清单不等于声明了粒度。",
|
|
159
161
|
"scd_hint": scd.get("scd", ""), "scd_why": scd.get("why", ""),
|
|
160
162
|
"bus_matrix_cell": cell,
|
|
161
163
|
"canon_refs": refs, "confidence": round(conf, 2)}
|
|
162
164
|
signals = list(role.get("signals", []))
|
|
165
|
+
mis = detector.naming_alignment(name, role["role"]) if name and not name.startswith("(") else None
|
|
166
|
+
if mis:
|
|
167
|
+
out["naming_misalignment"] = mis
|
|
168
|
+
signals.append("⚠ 前缀与角色矛盾:" + mis)
|
|
163
169
|
if upsert:
|
|
164
170
|
out["upsert_check"] = upsert
|
|
165
171
|
if upsert["verdict"] == "type_debt_risk":
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dimctx
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.1
|
|
4
4
|
Summary: dimctx = dimensional modeling context provider — MCP server giving AI coding assistants Kimball modeling judgement, bus-matrix truth, and SQL complexity checks.
|
|
5
5
|
Author: wagic
|
|
6
6
|
License: AGPL-3.0-or-later
|
|
@@ -35,7 +35,7 @@ AI 写 SQL/DDL 时会瞎编建模决策:分不清事实和维度、猜不准
|
|
|
35
35
|
|
|
36
36
|
| 工具 | 作用 |
|
|
37
37
|
|---|---|
|
|
38
|
-
| `analyze_table` | 判定表角色(fact/dimension)、粒度键、SCD 建议(按原典 Type 2
|
|
38
|
+
| `analyze_table` | 判定表角色(fact/dimension)、粒度键、SCD 建议(按原典 Type 2 三列签名)、总线矩阵格值;事实表用了可更新键模型时附类型债检查(见下);判为事实表却戴 `dim_` 前缀时给出 `naming_misalignment` |
|
|
39
39
|
| `search_canon` | 检索**你自备**的建模语料(本地 markdown,可配多个目录) |
|
|
40
40
|
| `bus_matrix` | 总线矩阵查询(单表格值 / 单维度实现 / 全库概览) |
|
|
41
41
|
| `measure_sql` | 度量下游取数复杂度(CASE WHEN / JOIN 深度 / 子查询 / 聚合嵌套) |
|
|
@@ -76,9 +76,9 @@ export DIMCTX_ANALYSIS_DIR=/path/to/notes # 你自己的分析笔记(可选
|
|
|
76
76
|
## 开发
|
|
77
77
|
|
|
78
78
|
```bash
|
|
79
|
-
uv run --with pytest --with pydantic python -m pytest tests/ -q #
|
|
79
|
+
uv run --with pytest --with pydantic python -m pytest tests/ -q # 26 passed, 15 skipped(图谱相关用例跳过)
|
|
80
80
|
# 有工程表图谱时可全跑:
|
|
81
|
-
DIMCTX_TEST_ATLAS=/path/to/atlas.json uv run --with pytest --with pydantic python -m pytest tests/ -q #
|
|
81
|
+
DIMCTX_TEST_ATLAS=/path/to/atlas.json uv run --with pytest --with pydantic python -m pytest tests/ -q # 41 passed
|
|
82
82
|
```
|
|
83
83
|
|
|
84
84
|
## 许可
|
|
@@ -347,3 +347,32 @@ def test_upsert_check_scope_and_non_updatable():
|
|
|
347
347
|
assert "upsert_check" not in tools.analyze_table(table="dim_pub_factory_model_wide") # 维表
|
|
348
348
|
assert tools.analyze_table(table="ods_pe_batch")["upsert_check"]["verdict"] == "out_of_scope" # 贴源
|
|
349
349
|
assert tools.analyze_table(table="dws_iot_param_batch_result")["upsert_check"]["verdict"] == "out_of_scope" # 汇总
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
# ---------- 0.3.1 候选:前缀与角色矛盾(D5 接线)/ 粒度输出注记 / 队列口径的一致性事实 ----------
|
|
353
|
+
|
|
354
|
+
def test_naming_alignment_only_flags_fact_with_dim_prefix():
|
|
355
|
+
assert "dim_" in detector.naming_alignment("dim_pub_batch_time_di", "fact")
|
|
356
|
+
assert detector.naming_alignment("dt_batch", "fact") is None
|
|
357
|
+
assert detector.naming_alignment("customers", "dimension") is None # 命名约定各异:缺 dim_ 前缀不报噪声
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
@pytest.mark.skipif(not os.path.exists(ATLAS), reason="图谱不存在")
|
|
361
|
+
def test_analyze_table_flags_fact_living_in_dim_layer():
|
|
362
|
+
"""mdop 实例:dim_pub_batch_time_di 每批次一行、带三类时间的最早/最晚与 update_count——是批次时间快照却戴着 dim_ 前缀。"""
|
|
363
|
+
r = tools.analyze_table(table="dim_pub_batch_time_di")
|
|
364
|
+
assert r["role"] == "fact" and "累积快照" in r["naming_misalignment"]
|
|
365
|
+
assert any("dim_" in s for s in r["signals"] if s.startswith("⚠ 前缀")), r["signals"]
|
|
366
|
+
assert "业务术语" in r["grain_note"]
|
|
367
|
+
assert "naming_misalignment" not in tools.analyze_table(table="dt_batch")
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
def test_conformed_facts_cohort_time_basis():
|
|
371
|
+
"""三张事实表都带「完单金额」——本例按提交日/支付日/完单日三种队列口径构造(口径系推断):
|
|
372
|
+
时间口径不同即不兼容,原典要求 differently named。"""
|
|
373
|
+
rows = [{"name": "完单金额", "table": t, "definition": "sum(paid_amt)", "unit": "CNY",
|
|
374
|
+
"filter": "status=done", "time_basis": tb}
|
|
375
|
+
for t, tb in (("fact_ord_submit_order_di", "提交日"), ("fact_ord_payment_order_di", "支付日"),
|
|
376
|
+
("fact_ord_down_order_di", "完单日"))]
|
|
377
|
+
r = tools.check_conformed_facts(rows)
|
|
378
|
+
assert r["incompatible"] == 1 and "differently named" in r["actions"][0]["action"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|