feat: refactor label system - #3809
Open
MoeexT wants to merge 13 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors the existing label/tag functionality into a unified, structured tag-management system across backend services, repository listing/search flows, and the frontend UI (including assignment, filtering, and document-projection-aware retrieval).
Changes:
- Adds unified tag management domain (structured predicates, bulk assignment, authorization, and cleanup hooks) across backend services and apps.
- Introduces document tag projection ledger support and integrates document tag filtering into hybrid search.
- Updates frontend types/services/hooks and adds reusable tag UI components to power tag management, chips, and filtering in agent/skill/MCP/repository screens.
Reviewed changes
Copilot reviewed 107 out of 110 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/ext_components/aidp/test_aidp_mgmt_app.py | Asserts AIDP KB deletion triggers document tag-assignment cleanup hook. |
| test/backend/services/test_tag_document_batch_status.py | Covers new document batch status service behavior (auth, predicates, encoding). |
| test/backend/services/test_tag_assignment_service.py | Covers assignment replace semantics and legacy flat-tag projection behavior. |
| test/backend/services/test_tag_assignment_filters.py | Verifies predicate filtering semantics (OR within, AND across) and no-op behavior. |
| test/backend/services/test_tag_assignment_cleanup_services.py | Verifies tag cleanup hooks across agent/skill/MCP/document/KB deletion flows. |
| test/backend/services/test_tag_assignment_bulk_service.py | Covers bulk assignment outcome mapping and per-target error isolation. |
| test/backend/services/test_tag_assignment_authorization.py | Ensures resolution failures are fail-closed and origin constraints are enforced. |
| test/backend/services/test_agent_repository_service.py | Adds coverage for structured-tag-aware repository and “mine” search/filtering. |
| test/backend/database/test_tag_assignment_db.py | Unit tests for assignment replacement validation rules. |
| test/backend/database/test_tag_assignment_cleanup_db.py | Tests soft-delete cleanup and canonical document identity matching. |
| test/backend/database/test_tag_assignment_boundaries.py | Tests capacity boundaries and mutation ordering for assignment replacement. |
| test/backend/app/test_vectordatabase_app.py | Updates vdb app tests for tag cleanup + hybrid search tag predicates. |
| test/backend/app/test_tag_management_app.py | New unit tests for tag management endpoints and error mapping. |
| test/backend/app/test_tag_document_batch_status_app.py | Tests document batch status endpoint wiring and request model behavior. |
| test/backend/app/test_tag_assignment_bulk_app.py | Tests bulk assignment route auth behavior and request forwarding. |
| test/backend/app/test_tag_assignment_app.py | Tests assignment routes, slash-containing IDs, and legacy field rejection. |
| test/backend/app/test_skill_repository_app.py | Adds parsing/forwarding tests for repository tag + structured predicates APIs. |
| test/backend/app/test_agent_repository_app.py | Adds parsing/forwarding tests for repository tag + structured predicates APIs. |
| frontend/types/tagManagement.ts | Introduces typed contracts for unified tag management APIs. |
| frontend/types/skillRepository.ts | Adds structured tag predicate + tag filter fields for skill repository list params. |
| frontend/types/mcpTools.ts | Makes MCP service tags optional to support inherited/structured tags. |
| frontend/types/agentRepository.ts | Adds tag predicate params + tag list to my-agent items. |
| frontend/services/tagManagementService.ts | Adds typed API client for tag libraries, assignments, bulk ops, and filters. |
| frontend/services/tagAssignmentCache.ts | Adds short-TTL in-flight promise cache for assignment reads to reduce request fanout. |
| frontend/services/skillRepositoryService.ts | Adds skill repository tag-stats fetcher and wires into service export. |
| frontend/services/mcpToolsService.ts | Updates MCP payload typing to accept optional tags. |
| frontend/services/api.ts | Extends API endpoint builders to include tag filters and tag-stats endpoints. |
| frontend/services/agentRepositoryService.ts | Adds agent repository tag-stats fetcher and wires into service export. |
| frontend/public/locales/zh/custom.json | Adjusts FILE_UPLOAD_SIZE_LIMIT localization value. |
| frontend/public/locales/en/custom.json | Adjusts FILE_UPLOAD_SIZE_LIMIT localization value. |
| frontend/public/locales/en/common.json | Adds i18n strings for tag management, tag filtering, and updated placeholders/hints. |
| frontend/lib/systemTagLabels.ts | Adds system tag label helpers and tag-search predicate derivation. |
| frontend/hooks/useTagManagement.ts | Adds hooks for tag libraries/definitions/assignments with stable loader behavior. |
| frontend/hooks/skillRepository/useSkillRepositoryListings.ts | Adds React Query hook for skill repository tag stats. |
| frontend/hooks/mcpTools/usePublishedServiceDetailEdit.ts | Makes published MCP tags read-only by removing tag editing flow from the hook. |
| frontend/hooks/mcpTools/useMcpServiceDetail.ts | Removes MCP tag editing flow from local detail hook and unsaved-change detection. |
| frontend/hooks/mcpTools/useMcpAddLocal.ts | Stops sending freeform tags during MCP add/update flows. |
| frontend/hooks/agentRepository/useAgentRepositoryListings.ts | Adds React Query hook for agent repository tag stats. |
| frontend/components/tag/TagFilterPopover.tsx | New popover wrapper for structured tag filtering controls. |
| frontend/components/tag/TagFilterControls.tsx | New structured tag filter UI (AND across definitions, OR within values). |
| frontend/components/tag/TagChips.tsx | New compact chip UI for tag assignments with accessible labels/tooltips. |
| frontend/components/tag/ResourceTagChips.tsx | New component to fetch + render chips for a resource with caching support. |
| frontend/components/tag/RepositoryTagFilter.tsx | New exact-tag filter control for repository tag stats. |
| frontend/app/[locale]/skill-space/page.tsx | Adds structured tag filtering to repository/mine skill lists. |
| frontend/app/[locale]/skill-space/components/RepositoryView.tsx | Adds TagFilterPopover to skill repository view search bar. |
| frontend/app/[locale]/skill-space/components/MineSkillsView.tsx | Adds structured tag filtering UI to “My Skills” view. |
| frontend/app/[locale]/mcp-space/components/shared/TagEditor.tsx | Removes legacy freeform tag editor component. |
| frontend/app/[locale]/mcp-space/components/PublishedServiceDetailModal.tsx | Displays published tags as read-only chips rather than editable tags. |
| frontend/app/[locale]/mcp-space/components/PublishConfirmModal.tsx | Shows inherited structured tags during publish confirm; removes tag editing. |
| frontend/app/[locale]/mcp-space/components/MineMcpServiceCard.tsx | Adds structured tag chips for local MCP services. |
| frontend/app/[locale]/mcp-space/components/McpToolsSearchFilterBar.tsx | Adds extension points for extra search/filter actions. |
| frontend/app/[locale]/mcp-space/components/add/local/AddMcpServiceLocalSection.tsx | Removes freeform tag editing from local MCP add flow. |
| frontend/app/[locale]/agents/components/AgentManageComp.tsx | Adds tag definition management entry point and wires refresh into agent list. |
| frontend/app/[locale]/agents/components/agentInfo/AgentGenerateDetail.tsx | Adds per-agent tag assignment modal + definition management wiring. |
| frontend/app/[locale]/agents/components/AgentConfigComp.tsx | Replaces legacy label/tag modals with unified assignment + definition management modals. |
| frontend/app/[locale]/agents/components/agentConfig/SkillDraftPanel.tsx | Replaces legacy freeform skill tags input with structured tag preview + edit link. |
| frontend/app/[locale]/agents/components/agentConfig/SkillBuildModal.tsx | Adds structured tag assignment + definition management modals for skills. |
| frontend/app/[locale]/agents/components/agentConfig/skill/SelectSkillsDialog.tsx | Adds “Bulk Assign Tags” and “Tag Management” actions for skills selection. |
| frontend/app/[locale]/agent-space/page.tsx | Adds structured tag search predicates + tag filter popover to agent repository views. |
| frontend/app/[locale]/agent-space/components/MyAgentCard.tsx | Displays structured tags on “My Agent” cards with localized labels. |
| frontend/app/[locale]/agent-space/components/MineAgentsView.tsx | Adds structured tag filter UI to “My Agents” view. |
| frontend/app/[locale]/agent-space/components/AgentRepositoryCard.tsx | Localizes repository tag labels when rendering listing cards. |
| deploy/tests/test_tag_library_permissions.sh | Adds migration/init seed contract test for TAG_LIBRARY/MANAGE permission grants. |
| deploy/tests/test_document_tag_projection.sh | Adds migration/init validation test harness for document_tag_projection schema. |
| deploy/sql/migrations/v2.5.4_0820_tag_value_usage_index.sql | Adds covering index for tag value usage lookups. |
| deploy/sql/migrations/v2.5.3_0819_agent_category_preset_tags.sql | Seeds per-tenant “Agent Category” definition + preset values. |
| deploy/sql/migrations/v2.5.2_0818_document_tag_projection.sql | Adds document_tag_projection ledger table and supporting indexes. |
| deploy/sql/migrations/v2.5.1_0817_tag_library_permissions.sql | Seeds TAG_LIBRARY/MANAGE permissions with guards against over-granting. |
| backend/services/vectordatabase_service.py | Adds tag predicate filtering to hybrid search results via tag projection/assignment checks. |
| backend/services/skill_service.py | Adds structured tag assignment cleanup on skill deletion. |
| backend/services/skill_repository_service.py | Adds structured tag predicate filtering + exact tag filter + tag stats service. |
| backend/services/remote_mcp_service.py | Adds structured tag assignment cleanup on MCP deletion paths. |
| backend/services/agent_service.py | Adds structured tag assignment cleanup on tenant-owned agent deletion. |
| backend/ext_components/aidp/apps/aidp_mgmt_app.py | Adds document assignment cleanup hook on AIDP KB deletion. |
| backend/database/skill_repository_db.py | Adds tag filtering and tag-stats query for skill repository listings. |
| backend/database/document_tag_projection_db.py | Adds DB accessors for projection upsert/query/filter logic. |
| backend/consts/exceptions.py | Adds TagManagementConflictError and TagManagementNotFoundError. |
| backend/consts/const.py | Adds TAG_DOCUMENT_PROJECTION_ENABLED rollout flag. |
| backend/apps/vectordatabase_app.py | Wires tag cleanup and hybrid search tag_predicates into API layer. |
| backend/apps/skill_repository_app.py | Adds query parsing for structured tag predicates + exact tag + tag stats endpoint. |
| backend/apps/config_app.py | Registers tag_management router in the main app. |
| backend/apps/app_factory.py | Registers explicit handlers for legacy domain exceptions to return correct HTTP status codes. |
| backend/apps/agent_repository_app.py | Adds query parsing for structured tag predicates/search predicates + exact tag + tag stats endpoint. |
Suppressed comments (3)
deploy/tests/test_document_tag_projection.sh:67
- These docker exec/psql commands contain stray '+' tokens that will be passed as literal arguments, causing psql invocation to fail.
deploy/tests/test_document_tag_projection.sh:97 - These assert_query calls include stray '+' tokens between arguments, which will be treated as extra parameters and break the assertions.
deploy/tests/test_document_tag_projection.sh:107 - This assert_query invocation also contains stray '+' tokens between arguments, which will cause the fresh-schema check to fail to execute.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+27
to
+31
| created_by VARCHAR(100), | ||
| updated_by VARCHAR(100), | ||
| CONSTRAINT uq_document_tag_projection_identity | ||
| UNIQUE (tenant_id, provider, knowledge_base_id, provider_document_id) | ||
| ); |
Comment on lines
+48
to
+52
| start_postgres() { | ||
| "$DOCKER_BIN" run --rm -d + --name "$CONTAINER_NAME" + -e POSTGRES_PASSWORD="$POSTGRES_PASSWORD" + "$POSTGRES_TEST_IMAGE" >/dev/null | ||
| CONTAINER_STARTED=true | ||
|
|
||
| local attempt |
…nt sync + add value usage index - backend/apps/app_factory.py: register handlers for legacy domain exceptions (UnauthorizedError->401, ForbiddenError->403, LimitExceededError->429, ValidationError->400, NotFoundException->404, DuplicateError->409, TagManagementConflictError->409, SignatureValidationError->401) so they no longer fall through to the generic 500 handler. Verified live: unauthenticated tag endpoints now return 401 instead of 500. - backend/apps/tag_management_app.py: convert filter_resource_tag_assignments from async/await to sync/_run to match the synchronous TagManagementDB.filter_authorized_resource_ids (which returns a dict, not a coroutine). Fixes TypeError -> HTTP 500 on the filter endpoint. - deploy/sql: add partial index idx_resource_tag_assignment_value (tenant_id, value_id, delete_flag) WHERE delete_flag='N' via new migration v2.5.4_0820_tag_value_usage_index.sql and init.sql. Benchmark at capacity limits (100 defs / 100k values / 50k assignments) showed value-usage-count was a 102ms Seq Scan; with the index it becomes a 1.28ms Index Only Scan. Idempotent (IF NOT EXISTS).
- Add tenant-scoped tag libraries, definitions, values and assignments - Wire tag chips and filters into knowledge base, agent and MCP pages - Add document tag projection ledger with provider sync - Clean up assignments when KB/agent/MCP/skill resources are deleted - Add preflight and migration scripts v2.5.0-v2.5.3 - Cache assignment reads on list pages to avoid per-row HTTP requests
MoeexT
force-pushed
the
feature/moeext/perf-label-system
branch
from
August 31, 2026 08:57
cf8a710 to
054a3a6
Compare
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.