Revert "fix(knowledge): articles共享层语义对齐评审方案——entity_id=0系统共享(替代NULL) (entity-memory-partition 复核对齐)"
This reverts commit 5e96d15888.
This commit is contained in:
@@ -39,11 +39,11 @@ for t in ['knowledge_events', 'knowledge_summaries', 'knowledge_articles']:
|
||||
cur.execute(f"SHOW INDEX FROM {t} WHERE Column_name='entity_id'")
|
||||
has_idx = cur.fetchone() is not None
|
||||
check(f"{t}.entity_id 列+索引", has_col and has_idx)
|
||||
# 存量全局文章(entity_id=0 系统共享)在加列后保持 38 篇
|
||||
cur.execute("SELECT COUNT(*) FROM knowledge_articles WHERE entity_id = 0")
|
||||
# 存量全局文章(NULL)在加列后保持 38 篇
|
||||
cur.execute("SELECT COUNT(*) FROM knowledge_articles WHERE entity_id IS NULL")
|
||||
g = cur.fetchone()[0]
|
||||
print(f" 系统共享文章(entity_id=0): {g} 篇")
|
||||
check("存量系统共享教学文章保持", g == 38, f"(期望38)")
|
||||
print(f" 存量全局文章(NULL): {g} 篇")
|
||||
check("存量全局教学文章保持全局共享", g == 38, f"(期望38)")
|
||||
|
||||
# 1. 插临时验证文章(标题带标记,source 专属 entity)
|
||||
cur.execute("DELETE FROM knowledge_articles WHERE title LIKE %s", (f"%{MARK}%",))
|
||||
@@ -56,7 +56,7 @@ cur.execute(
|
||||
(2, f"{MARK}E2专属越权测试", "s", "c", "term"))
|
||||
cur.execute(
|
||||
"INSERT INTO knowledge_articles (entity_id, title, summary, content, category) VALUES (%s,%s,%s,%s,%s)",
|
||||
(0, f"{MARK}系统共享测试", "s", "c", "term"))
|
||||
(None, f"{MARK}全局共享测试", "s", "c", "term"))
|
||||
conn.commit()
|
||||
cur.execute("SELECT id, entity_id, title FROM knowledge_articles WHERE title LIKE %s", (f"%{MARK}%",))
|
||||
rows = cur.fetchall()
|
||||
@@ -98,13 +98,13 @@ if not t1 or not t2:
|
||||
st, body = api("GET", "/api/cma/knowledge-articles", token=t1)
|
||||
d1 = _json.loads(body)
|
||||
titles1 = {i["title"] for i in d1.get("data", [])}
|
||||
check("E1 见系统共享文章", f"{MARK}系统共享测试" in titles1)
|
||||
check("E1 见全局共享文章", f"{MARK}全局共享测试" in titles1)
|
||||
check("E1 见自己专属文章", f"{MARK}E1专属越权测试" in titles1)
|
||||
check("E1 不见 E2 专属文章", f"{MARK}E2专属越权测试" not in titles1, "(核心越权1)")
|
||||
# E2 视角
|
||||
st, body = api("GET", "/api/cma/knowledge-articles", token=t2)
|
||||
titles2 = {i["title"] for i in _json.loads(body).get("data", [])}
|
||||
check("E2 见系统共享文章", f"{MARK}系统共享测试" in titles2)
|
||||
check("E2 见全局共享文章", f"{MARK}全局共享测试" in titles2)
|
||||
check("E2 见自己专属文章", f"{MARK}E2专属越权测试" in titles2)
|
||||
check("E2 不见 E1 专属文章", f"{MARK}E1专属越权测试" not in titles2, "(核心越权2)")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user