Skip to content

feat: KnowledgeFS and New Knowledge - #44165

Open
hyoban wants to merge 1263 commits into
mainfrom
deploy/konwledge
Open

hyoban wants to merge 1263 commits into
mainfrom
deploy/konwledge

Conversation

@hyoban

@hyoban hyoban commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Summary

Integration branch for KnowledgeFS and the New Knowledge experience (backend proxy/services plus the web/features/new-rag frontend).

Main dropped its outdated copy of this feature in #44163. This branch carries the current version, and its latest main merge records that commit without applying its deletions.

Upgrade reconciliation recovery

Classic Dataset upgrades can commit success before their document reconciliation is published. A broker failure or interrupted worker previously left disabled-document availability pending indefinitely, blocking retrieval from the new knowledge base.

Persist an independent reconciliation delivery lease and let Beat recover successful upgrades with unfinished document checkpoints. Bound worker execution and reject stale or duplicate deliveries. Apply migration b9d3f7a5c102 before starting the updated processes; existing stranded upgrades are eligible for recovery automatically. Deployment and recovery requirements are documented in docker/README.md.

Validation for this fix: 83 focused upgrade, task, and migration tests passed, including publication failure, interruption before claiming the follow-up, lost deliveries, and stale-worker fencing. Backend lint checks and targeted production/test type checks passed. PostgreSQL/MySQL migration SQL rendering was checked; live database integration tests remain CI-owned.

Screenshots

Before After
... ...

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've verified the change and added or updated tests where meaningful regression risk justifies coverage.
  • I've updated the documentation accordingly.
  • I ran make lint && make type-check (backend) and vp staged (frontend) to appease the lint gods

From Claude Code

🤖 Generated with Claude Code

hyoban and others added 30 commits September 18, 2026 09:29
# Conflicts:
#	api/controllers/console/datasets/datasets.py
#	web/app/components/header/account-setting/model-provider-page/model-selector/model-selector-trigger.tsx
#	web/app/components/workflow/run/node.tsx
# Conflicts:
#	web/app/components/datasets/list/dataset-card/hooks/use-dataset-card-state.ts
#	web/app/layout.tsx
#	web/features/new-rag/__tests__/add-source-page.spec.tsx
#	web/features/new-rag/__tests__/document-detail-page.spec.tsx
#	web/features/new-rag/__tests__/new-knowledge-list.spec.tsx
#	web/features/new-rag/__tests__/sources-page.spec.tsx
#	web/features/new-rag/create-knowledge-page.tsx
#	web/features/new-rag/document-chunk-detail.tsx
#	web/features/new-rag/document-list.tsx
#	web/features/new-rag/documents-page.tsx
#	web/features/new-rag/documents/__tests__/page.spec.tsx
#	web/features/new-rag/knowledge-space-shell.tsx
#	web/features/new-rag/new-knowledge-list.tsx
#	web/features/new-rag/sources-page.tsx
#	web/features/new-rag/use-document-reindex.ts
#	web/service/fetch.spec.ts
# Conflicts:
#	api/tests/unit_tests/controllers/openapi/test_workflow_events_openapi.py
#	web/app/components/datasets/list/dataset-card/components/__tests__/operations-dropdown.spec.tsx
#	web/app/components/datasets/list/dataset-card/components/dataset-card-footer.tsx
#	web/app/components/datasets/list/dataset-card/components/dataset-card-header.tsx
#	web/app/components/datasets/list/dataset-card/components/operations-dropdown.tsx
#	web/app/components/datasets/list/dataset-card/index.tsx
#	web/app/components/header/account-setting/model-provider-page/model-selector/model-selector-trigger.tsx
#	web/features/new-rag/__tests__/add-source-page.spec.tsx
#	web/features/new-rag/add-source-page.tsx
#	web/features/new-rag/document-chunk-detail.tsx
#	web/features/new-rag/document-chunk-tree.tsx
#	web/features/new-rag/documents-page.tsx
#	web/features/new-rag/documents/__tests__/page.spec.tsx
#	web/features/new-rag/documents/tasks/auxiliary-read-guard.ts
#	web/features/new-rag/knowledge-space-shell.tsx
#	web/features/new-rag/processing-tasks-drawer.tsx
# Conflicts:
#	api/constants/__init__.py
#	api/controllers/openapi/_errors.py
#	api/controllers/openapi/_version_gate.py
#	api/extensions/ext_blueprints.py
#	api/tests/unit_tests/controllers/openapi/test_auth_matrix.py
#	api/tests/unit_tests/controllers/openapi/test_error_contract.py
#	api/tests/unit_tests/controllers/service_api/test_wraps.py
#	api/tests/unit_tests/core/workflow/nodes/agent_v2/test_agent_node.py
#	packages/contracts/console.ts
#	packages/contracts/generated/api/console/orpc.gen.ts
#	packages/contracts/generated/api/console/router.gen.ts
#	packages/contracts/generated/api/openapi/orpc.gen.ts
#	packages/contracts/generated/api/openapi/zod.gen.ts
#	packages/contracts/generated/api/service/orpc.gen.ts
#	packages/contracts/generated/knowledge-fs/metadata.gen.ts
#	packages/contracts/generated/knowledge-fs/orpc.gen.ts
#	packages/contracts/openapi-ts.knowledge-fs.config.ts
#	web/features/agent-v2/agent-detail/configure/components/orchestrate/knowledge/index.tsx
# Conflicts:
#	api/controllers/console/app/app_import.py
#	api/controllers/console/datasets/datasets.py
#	api/services/dataset_service.py
#	api/tests/unit_tests/controllers/console/datasets/test_datasets.py
#	pnpm-lock.yaml
#	web/app/components/base/markdown/index.tsx
#	web/app/components/datasets/list/dataset-card/operations.tsx
#	web/features/agent-v2/agent-detail/configure/components/orchestrate/knowledge/__tests__/index.spec.tsx
#	web/i18n/locales/ar-TN/workflow.json
#	web/i18n/locales/de-DE/workflow.json
#	web/i18n/locales/en-US/workflow.json
#	web/i18n/locales/es-ES/workflow.json
#	web/i18n/locales/fa-IR/workflow.json
#	web/i18n/locales/fr-FR/workflow.json
#	web/i18n/locales/hi-IN/workflow.json
#	web/i18n/locales/id-ID/workflow.json
#	web/i18n/locales/it-IT/workflow.json
#	web/i18n/locales/ja-JP/workflow.json
#	web/i18n/locales/ko-KR/workflow.json
#	web/i18n/locales/lo-LA/workflow.json
#	web/i18n/locales/nl-NL/workflow.json
#	web/i18n/locales/pl-PL/workflow.json
#	web/i18n/locales/pt-BR/workflow.json
#	web/i18n/locales/ro-RO/workflow.json
#	web/i18n/locales/ru-RU/workflow.json
#	web/i18n/locales/sl-SI/workflow.json
#	web/i18n/locales/th-TH/workflow.json
#	web/i18n/locales/tr-TR/workflow.json
#	web/i18n/locales/uk-UA/workflow.json
#	web/i18n/locales/vi-VN/workflow.json
#	web/i18n/locales/zh-Hans/workflow.json
#	web/i18n/locales/zh-Hant/workflow.json
#	web/i18n/resources.generated.d.ts
#	web/package.json
Restoring the previous status CHECK failed when completed rows existed.
Completed rows already carry full started evidence, so return them to the
started state before the completion columns are dropped.
@hyoban

hyoban commented Oct 21, 2026

Copy link
Copy Markdown
Member Author

Thanks for the thorough review. Each point is addressed in its own commit:

  1. Migration ancestry: b98c951. fbdfcf5f5a6e is back on main's parent, 89919253ca7a. 9a4e7d1c2b60 now merges f1d3c5b7a902 and c4d8e2f7a1b6 itself, since its foreign key needs the KnowledgeFS tables. Graph tests check that an upgrade from main's a8c3e7f4b912 runs the full KnowledgeFS chain before 9a4e7d1c2b60. They also check that databases already at d7b9e1f3a5c2 keep the same set of applied revisions.
  2. API-key scope on downgrade: f45e8ce. The downgrade now refuses to run while any key is bound only to KnowledgeFS spaces. The operator has to revoke those keys through the API first, which also invalidates their cache. I chose blocking over revoking inside the migration because migrations can't clear the Redis token cache, so revoked keys would stay usable for up to the cache TTL. Keys that also have dataset bindings keep those bindings. Offline (SQL-only) downgrades are rejected because they can't run this check. Tests cover a populated downgrade with both kinds of key.
  3. Re-cutover: 3783f94. The cutover update now clears rolled_back_at. A new cutover → rollback → cutover test checks that the runtime gate lets traffic through again.
  4. Interrupted dispatch: c0cd0ee. After each checkpoint, the job goes from RUNNING back to QUEUED with no task id, then dispatches through the same claim_enqueue / release-on-failure path the console uses. If the broker fails, the job is left QUEUED and unclaimed, so retry() can pick it up. One gap remains: a worker killed between the claim and apply_async leaves the job claimed. Initial enqueues have the same gap today. Closing it needs a periodic sweep, which could be a follow-up.
  5. Worker image: aa018c0. Both Compose files now use dify-api:1.17.1, matching the other API services.
  6. MySQL uniqueness: 46c7d23. A new head, 3edd6cd27f54, applies only on MySQL. It replaces the unconditional index with a unique index on a stored generated column that is NULL for finished jobs, the same approach as agents.roster_unique_name. PostgreSQL keeps its partial index. This is checked against rendered MySQL SQL only, so the MySQL CI job is the real test.
  7. Completed rows on downgrade: 8871ead. Completed authorizations already carry the full started evidence, so they go back to started before the old check constraint is restored. A test covers a populated downgrade.

hyoban and others added 28 commits October 21, 2026 17:37
CI renders head:base downgrades offline, which the online-only guard broke.
Offline PostgreSQL scripts now carry a DO block that raises when KnowledgeFS-only
keys exist; other dialects get a warning comment ahead of the binding delete.
Authorize retries against the complete dataset ownership chain before writes. Subscribe default Docker workers to the lifecycle queue. Bound upgrade checkpoints in prefork workers, recover abandoned claims, and reject superseded deliveries.

Validation: 96 targeted unit tests, make lint, production and unit-test Pyrefly checks, and shell syntax checks.
Restore main frontend guidance, legacy RAG tracing, and CLI edge publishing. Remove obsolete KnowledgeFS build context entries, the multi-head migration workaround, and duplicate Storybook configuration.

Validation: 25 RAG and tracing tests; make lint; targeted Pyrefly; repository-wide Vite+ checks; shell syntax and cleanup consistency checks.
- Migrate CreatorFilter to a multi-select Combobox while keeping the
  selection limit, pending-member exclusion, and retry states.
- Give classic and new knowledge cards list semantics, a whole-card
  entry, an unclipped inset focus ring, and independent tag and menu
  controls reachable without hover.
- Use a menu link item for knowledge settings, a form-backed delete
  confirmation with inline failure, and drop redundant toasts.
- Use RadioGroup and field errors in metadata forms, loading state for
  metadata deletion, and single error reporting for metadata requests.
- Compose knowledge and agent knowledge dialogs from the Dialog and
  AlertDialog header, body, and footer parts instead of restyling
  titles, descriptions, and content surfaces.
- Use DialogContent for the golden question import dialog rather than
  re-centering a bare DialogPopup.
- Scope the legacy request deprecation to the auth replay spec.
Delete low-value specs, replace react-query/jotai/UI mocks with service-boundary
responses and real queries, and fix product issues those tests uncovered:
connection refresh errors, provisional source re-creation, golden-question
active-count invalidation, terminal research partials, sources auto-pagination,
and duplicate task list snapshots.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review: top ghfind author score; see https://ghfind.com size:XXL This PR changes 1000+ lines, ignoring generated files. web This relates to changes on the web.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants