For agentic workers: REQUIRED SUB-SKILL: Use superpowers:test-driven-development and superpowers:executing-plans to implement this plan task-by-task.
Goal: Build a permission-aware data governance knowledge base from business domains, data flows, metadata, standards and labels, with incremental synchronization and daily full consistency audits.
Architecture: Governance changes emit outbox events. A deterministic document builder produces versioned text, Qwen generates embeddings stored in PostgreSQL/pgvector, and DeepSeek answers only from permission-filtered retrieved sources. A daily audit compares source versions/hashes and repairs drift.
Tech Stack: Flask, PostgreSQL 16 + pgvector, Neo4j, Qwen Embedding API, DeepSeek chat API, MinIO, pytest.
Files:
deploy/docker/postgres/init/000-init.sqlmigrations/versions/20260716_40_governance_knowledge.pyapp/core/knowledge/models.pyCreate: tests/test_knowledge_schema.py
[ ] Enable vector extension using a pinned pgvector-compatible PostgreSQL image in local Docker.
[ ] Create governance_documents, governance_chunks and governance_sync_jobs with stable object UID/version/content hash.
[ ] Add unique document version and chunk number constraints plus a vector index selected from measured corpus size.
[ ] Test idempotent upsert, superseded versions, deletion tombstones and permission-scope metadata.
Files:
app/core/knowledge/document_builder.pyCreate: tests/test_governance_document_builder.py
[ ] Add golden tests for BusinessDomain, DataFlow, DataMeta, data standard and label documents.
[ ] Normalize property order, timestamps and relation sorting so identical source state has identical SHA-256.
[ ] Include object type, UID, version, business domain, ownership, definitions, relationships and source update time.
[ ] Exclude secrets, n8n credentials, raw connection passwords and unauthorized attachment text.
Files:
app/services/embedding/qwen.pyapp/config/config.pyCreate: tests/test_qwen_embeddings.py
[ ] Require explicit Qwen embedding model/base URL/API key and fail closed on missing configuration.
[ ] Test batching, timeout, rate limit, retry, dimension mismatch, deterministic cache keys and secret-free logs.
[ ] Store provider/model/dimension with every chunk so a model change creates a controlled reindex job.
[ ] Keep DeepSeek as the only default generative provider; do not send chat generation to Qwen.
Files:
app/core/knowledge/sync.pyapp/commands/sync_governance_knowledge.pyCreate: tests/test_knowledge_incremental_sync.py
[ ] Consume governance outbox events by stable object UID and source version.
[ ] Skip unchanged hashes, rebuild changed documents, chunk deterministically, embed missing chunks and atomically publish the new version.
[ ] Test duplicate/out-of-order events, object deletion, embedding failure and restart midway through a document.
[ ] Expose job counts, lag and last error to administrator health diagnostics.
Files:
app/core/knowledge/audit.pyapp/commands/audit_governance_knowledge.pytests/test_knowledge_full_audit.pyModify: deploy/docker/docker-compose.yml
[ ] Enumerate source objects with pagination and compare UID/version/hash against indexed documents.
[ ] Record missing, stale, orphaned and dimension-mismatch findings before repair.
[ ] Repair only differences and produce a persisted audit summary; never delete source governance data.
[ ] Schedule once daily in deployment orchestration and add a manual local command for acceptance.
Files:
app/core/knowledge/retrieval.pyapp/core/knowledge/qa.pyCreate: tests/test_knowledge_qa.py
[ ] Filter candidate chunks by user role/business-domain scope before vector similarity ranking.
[ ] Add lexical fallback and return no-answer when evidence is insufficient.
[ ] Send DeepSeek only selected chunks plus question; require answers to cite object UID, name and version.
[ ] Test prompt injection in source text, cross-domain data leakage, stale versions, model timeout and unsupported questions.
Files:
app/api/knowledge_base/app/__init__.pyfrontend/src/views/knowledgeBaseProduct/index.vuefrontend/src/api/governanceKnowledge.jstests/test_knowledge_api.pyCreate: tests/e2e/governance-knowledge.spec.js
[ ] Rename all user-facing copy to“数据治理知识库”, not product knowledge base.
[ ] Add search, ask, source detail, sync status and administrator audit endpoints.
[ ] Render source citations and object versions; make degraded embedding/model states explicit.
[ ] Verify administrator/editor/viewer access scopes and prevent direct source-detail bypass.
Files:
docs/architecture/OPENAPI.yamldocs/architecture/DATA_MODEL.mdModify: deploy/docker/README.md
[ ] Seed a small governance graph, trigger an incremental change, search it, ask a sourced question and confirm role filtering.
[ ] Deliberately remove one chunk, run the daily full audit and verify it detects and repairs the difference.
[ ] Record embedding latency, retrieval quality fixtures, token usage and failure behavior.
[ ] Run the complete local Docker, Python, frontend and browser acceptance suite.