Refact: Rename "artifact_" to "wiki_". (#17553)

This commit is contained in:
Kevin Hu
2026-07-30 11:06:16 +08:00
committed by GitHub
parent be6263d522
commit 9bb037271e
10 changed files with 127 additions and 146 deletions

View File

@@ -862,8 +862,8 @@ class Knowledgebase(DataBaseModel):
raptor_task_finish_at = DateTimeField(null=True)
mindmap_task_id = CharField(max_length=32, null=True, help_text="Mindmap task ID", index=True)
mindmap_task_finish_at = DateTimeField(null=True)
artifact_task_id = CharField(max_length=32, null=True, help_text="Artifact compilation task ID", index=True)
artifact_task_finish_at = DateTimeField(null=True)
wiki_task_id = CharField(max_length=32, null=True, help_text="Artifact compilation task ID", index=True)
wiki_task_finish_at = DateTimeField(null=True)
skill_task_id = CharField(max_length=32, null=True, help_text="Skill generation task ID", index=True)
skill_task_finish_at = DateTimeField(null=True)
# KB-wide structure-graph merge tasks, one traceable task id per merged kind
@@ -995,7 +995,7 @@ class FileCommitItem(DataBaseModel):
# ``ArtifactCommit`` retired — artifact page history is now stored under
# ``FileCommit`` + ``FileCommitItem`` via ``FileCommitService.record_page_edit``
# (see the artifact-commit extension columns on those models above).
# Pre-existing ``artifact_commit`` rows are intentionally left in place;
# Pre-existing ``wiki_commit`` rows are intentionally left in place;
# no code path reads them.
@@ -1768,8 +1768,10 @@ def migrate_db():
alter_db_add_column(migrator, "knowledgebase", "raptor_task_finish_at", DateTimeField(null=True))
alter_db_add_column(migrator, "knowledgebase", "mindmap_task_id", CharField(max_length=32, null=True, help_text="Mindmap task ID", index=True))
alter_db_add_column(migrator, "knowledgebase", "mindmap_task_finish_at", DateTimeField(null=True))
alter_db_add_column(migrator, "knowledgebase", "artifact_task_id", CharField(max_length=32, null=True, help_text="Artifact compilation task ID", index=True))
alter_db_add_column(migrator, "knowledgebase", "artifact_task_finish_at", DateTimeField(null=True))
alter_db_rename_column(migrator, "knowledgebase", "artifact_task_id", "wiki_task_id")
alter_db_rename_column(migrator, "knowledgebase", "artifact_task_finish_at", "wiki_task_finish_at")
alter_db_add_column(migrator, "knowledgebase", "wiki_task_id", CharField(max_length=32, null=True, help_text="Artifact compilation task ID", index=True))
alter_db_add_column(migrator, "knowledgebase", "wiki_task_finish_at", DateTimeField(null=True))
alter_db_add_column(migrator, "knowledgebase", "skill_task_id", CharField(max_length=32, null=True, help_text="Skill generation task ID", index=True))
alter_db_add_column(migrator, "knowledgebase", "skill_task_finish_at", DateTimeField(null=True))
for _structure_type in ("structure_graph", "structure_mindmap", "timeline", "session_graph", "session_essence", "structure"):

View File

@@ -531,7 +531,7 @@ class DocumentService(CommonService):
# survives; one this doc solely owned is removed.
try:
if chunk_index_exists:
cls.remove_artifact_products(doc, tenant_id)
cls.remove_wiki_products(doc, tenant_id)
except Exception as e:
logging.warning(f"Failed to clean up artifact products for document {doc.id}: {e}")
@@ -582,7 +582,7 @@ class DocumentService(CommonService):
page += 1
@classmethod
def remove_artifact_products(cls, doc, tenant_id):
def remove_wiki_products(cls, doc, tenant_id):
"""Reference-counted cleanup of KB-scoped wiki/artifact products
in the doc store when a document is deleted.
@@ -591,7 +591,7 @@ class DocumentService(CommonService):
of the documents that contributed to it. On delete we detach
``doc.id`` from that list and drop the row only when this document
was its sole contributor — a product shared by other docs
survives. ``artifact_map_extract`` resume rows are 1:1 with a
survives. ``wiki_map_extract`` resume rows are 1:1 with a
document and are removed directly by ``doc_id``.
The compile_kwd set is pulled from the wiki generator so new

View File

@@ -53,12 +53,12 @@ logger = logging.getLogger(__name__)
# Content storage for ``content_after`` is switched by a module-level
# constant so ops can move blobs between MinIO and the doc-store index
# without touching the schema.
ARTIFACT_CONTENT_STORAGE = "minio" # one of {"minio", "es"}
_ARTIFACT_COMMIT_BUCKET_PREFIX = ".artifact_commits"
_ARTIFACT_ES_KWD = "artifact_commit_content"
WIKI_CONTENT_STORAGE = "minio" # one of {"minio", "es"}
_WIKI_COMMIT_BUCKET_PREFIX = ".wiki_commits"
_WIKI_ES_KWD = "wiki_commit_content"
def _artifact_file_id(kb_id: str, slug: str) -> str:
def _wiki_file_id(kb_id: str, slug: str) -> str:
"""Deterministic 32-char id for the artifact-page 'file' identity.
Not a real File row — just an index key that groups all commits for
@@ -83,7 +83,7 @@ def _unified_diff(before: str, after: str, slug: str) -> str:
def _store_content_after(kb_id: str, content: str) -> tuple[str, str]:
"""Persist ``content`` per :data:`ARTIFACT_CONTENT_STORAGE`. Returns
"""Persist ``content`` per :data:`WIKI_CONTENT_STORAGE`. Returns
``(storage_kind, location)`` for the row's persistence columns.
Content-addressed by SHA-256 so re-saves with identical bodies share
@@ -92,8 +92,8 @@ def _store_content_after(kb_id: str, content: str) -> tuple[str, str]:
content_bytes = (content or "").encode("utf-8")
content_hash = hashlib.sha256(content_bytes).hexdigest()
if ARTIFACT_CONTENT_STORAGE == "minio":
location = f"{_ARTIFACT_COMMIT_BUCKET_PREFIX}/{content_hash}"
if WIKI_CONTENT_STORAGE == "minio":
location = f"{_WIKI_COMMIT_BUCKET_PREFIX}/{content_hash}"
try:
storage = settings.STORAGE_IMPL
if storage is not None:
@@ -106,7 +106,7 @@ def _store_content_after(kb_id: str, content: str) -> tuple[str, str]:
)
return "minio", location
if ARTIFACT_CONTENT_STORAGE == "es":
if WIKI_CONTENT_STORAGE == "es":
# Store as a single doc-store row so the same connector serves
# reads. The row is not retrievable (available_int=0).
from rag.nlp import search as _rag_search
@@ -116,7 +116,7 @@ def _store_content_after(kb_id: str, content: str) -> tuple[str, str]:
"id": content_hash,
"kb_id": kb_id,
"doc_id": kb_id,
"compile_kwd": _ARTIFACT_ES_KWD,
"compile_kwd": _WIKI_ES_KWD,
"content_with_weight": content or "",
"available_int": 0,
}
@@ -133,8 +133,8 @@ def _store_content_after(kb_id: str, content: str) -> tuple[str, str]:
# Unknown storage kind — fall through with empty location; the
# detail path treats missing location as "content not recoverable".
logging.warning(
"record_page_edit: unknown ARTIFACT_CONTENT_STORAGE=%r; content not persisted",
ARTIFACT_CONTENT_STORAGE,
"record_page_edit: unknown WIKI_CONTENT_STORAGE=%r; content not persisted",
WIKI_CONTENT_STORAGE,
)
return "", ""
@@ -732,7 +732,7 @@ class FileCommitService(CommonService):
final_title = f"{(title or '').strip() or f'{title_ts} {slug}'} "
commit_id = get_uuid()
item_id = get_uuid()
file_id = _artifact_file_id(kb_id, slug)
file_id = _wiki_file_id(kb_id, slug)
now_ts = current_timestamp()
now_dt = datetime_format(date_time=datetime.datetime.now())
@@ -819,7 +819,7 @@ class FileCommitService(CommonService):
"""
page = max(int(page or 1), 1)
page_size = max(min(int(page_size or 50), 200), 1)
file_id = _artifact_file_id(kb_id, slug)
file_id = _wiki_file_id(kb_id, slug)
base = (
FileCommit.select(

View File

@@ -306,8 +306,8 @@ class KnowledgebaseService(CommonService):
cls.model.raptor_task_finish_at,
cls.model.mindmap_task_id,
cls.model.mindmap_task_finish_at,
cls.model.artifact_task_id,
cls.model.artifact_task_finish_at,
cls.model.wiki_task_id,
cls.model.wiki_task_finish_at,
cls.model.skill_task_id,
cls.model.skill_task_finish_at,
cls.model.structure_graph_task_id,

View File

@@ -40,7 +40,7 @@ _PIPELINE_TASK_TYPE_TO_FINISH_FIELD = {
PipelineTaskType.GRAPH_RAG: "graphrag_task_finish_at",
PipelineTaskType.RAPTOR: "raptor_task_finish_at",
PipelineTaskType.MINDMAP: "mindmap_task_finish_at",
PipelineTaskType.ARTIFACT: "artifact_task_finish_at",
PipelineTaskType.ARTIFACT: "wiki_task_finish_at",
PipelineTaskType.SKILL: "skill_task_finish_at",
PipelineTaskType.STRUCTURE_GRAPH: "structure_graph_task_finish_at",
PipelineTaskType.STRUCTURE_MINDMAP: "structure_mindmap_task_finish_at",