dify/api/tests/unit_tests
Jyong b79b8a879b feat(knowledge-fs): record and count every knowledge space query
Workflow KnowledgeFS retrieval nodes ran through `retrieval-tests`, which
never wrote an AnswerTrace or an overview event, so their queries were
missing from the retrieval history and from the space overview; the history
also only ever showed each member their own traces.

- AnswerTrace gains a `source` (retrieval_test | workflow | service_api |
  agent | mcp; migration 0051_answer_trace_source) derived from the
  Capability v2 caller kind. The retrieval-tests route records one trace per
  run (stages, evidence bundle, profile metadata), returns its id as
  `answerTraceId`, and the workflow node's failed-retrieval capture attaches
  to that trace instead of creating a second record.
- The quality trace list exposes and filters by `source`; traces from other
  caller kinds are visible to any current reader of the space, and counts and
  scores fall back to the evidence embedded in the trace when no bundle row
  exists.
- Overview accounting: retrieval-tests and Research tasks now emit
  `query.requested`, and the Research job state machine emits
  `query.completed` / `query.failed` on terminal stages (wired for both the
  in-process gateway and the durable runtime), so query volume, answer rate
  and outcomes include every caller. Activity details keep `source` and
  `taskKind`.
- Console and service trace routes accept a `source` filter; the retrieval
  test page shows a source badge and an all / retrieval tests / workflow
  filter, with translations for every locale.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015zw5G5SX3HmVfnZof6YWAc
2026-09-04 05:48:17 -04:00
..
clients test: enforce centralized config overrides (#40869) 2026-08-29 14:05:35 +00:00
commands Merge remote-tracking branch 'origin/main' into deploy/konwledge 2026-09-03 16:32:30 +08:00
configs fix(knowledge-fs): align retrieval test timeout 2026-09-01 13:51:15 -04:00
controllers feat(knowledge-fs): fix CI. 2026-09-04 16:55:47 +08:00
core feat(knowledge-fs): record and count every knowledge space query 2026-09-04 05:48:17 -04:00
dev feat(knowledge-fs): add migration to merge agent drive and KnowledgeFS heads 2026-08-20 11:04:02 +08:00
enterprise/telemetry fix: add missing metrics back and enhance typing (#40935) 2026-08-21 09:46:45 +00:00
enums test: use typed config overrides in service coverage (#40848) 2026-08-18 11:59:58 +00:00
events Merge remote-tracking branch 'origin/main' into deploy/konwledge 2026-09-02 10:31:10 +08:00
extensions Merge remote-tracking branch 'origin/main' into deploy/konwledge 2026-09-03 16:32:30 +08:00
factories fix(api): align Service API OpenAPI contract (#41248) 2026-08-25 10:54:14 +00:00
fields test: migrate residual model sessions and ORM models to SQLite (#40531) 2026-08-18 12:23:02 +00:00
libs Merge remote-tracking branch 'origin/main' into deploy/konwledge 2026-09-02 21:56:53 +08:00
machinery refactor(api): move account lifecycle into application services (#40438) 2026-08-21 08:05:43 +00:00
migrations test(api): track the typed key binding migration as the alembic head 2026-09-03 06:07:22 -04:00
models Merge remote-tracking branch 'origin/main' into deploy/konwledge 2026-09-03 16:32:30 +08:00
oss test: eliminate remaining whole config mocks (#40855) 2026-08-18 12:01:49 +00:00
providers/trace/unified_trace feat(trace): add provider-neutral unified tracing (#39451) 2026-08-21 11:28:18 +00:00
repositories Merge remote-tracking branch 'origin/main' into deploy/konwledge 2026-09-03 16:32:30 +08:00
services feat(knowledge-fs): record and count every knowledge space query 2026-09-04 05:48:17 -04:00
tasks feat(knowledge-fs): add content handling for initial source preview and cleanup tasks 2026-09-03 21:01:21 +08:00
tools fix: fix mcp output_schema is optional (#39453) 2026-07-28 02:31:18 +00:00
utils test: move pure integration cases to unit tests (#40705) 2026-08-25 06:19:48 +00:00
__init__.py
.gitignore
.ruff.toml refactor(api): replace legacy recommended app retrieval stack (#40395) 2026-08-20 13:13:43 +00:00
config_override.py test: enforce centralized config overrides (#40869) 2026-08-29 14:05:35 +00:00
conftest.py test: enforce centralized config overrides (#40869) 2026-08-29 14:05:35 +00:00
pyrefly.toml refactor(api): extract account login service and consolidate adapters (#41184) 2026-09-03 06:20:21 +00:00
test_app_factory.py test: enforce centralized config overrides (#40869) 2026-08-29 14:05:35 +00:00
test_config_overrides.py test: enforce centralized config overrides (#40869) 2026-08-29 14:05:35 +00:00
test_constants.py test: enforce centralized config overrides (#40869) 2026-08-29 14:05:35 +00:00
test_makefile_backend_tests.py
test_pytest_dify.py refactor: thread explicit sessions through app retrieval paths (#38309) 2026-07-02 17:00:47 +00:00
test_sqlite_fixtures.py test: share unbound unit test sessions (#39690) 2026-07-28 14:12:08 +00:00