WeKnora/internal/application/repository
wizardchen c8a4fd5ba3 fix(wiki): prevent silent work loss and cross-batch doc races
Two correctness fixes on the Phase 3 concurrent claim-based ingest path:

- Slug-lock timeout / reduce failure no longer silently drops work. When a
  per-slug lock can't be acquired within wikiSlugLockWait, or reduce returns
  an error, the page's read-modify-write never lands. Previously the owning
  document was still counted as successful and its pending row was deleted at
  trim time, permanently losing the contribution (finalize only rebuilds the
  index / cross-links, it does not re-run reduce). Such documents are now
  folded into failedOps: their rows stay queued, their finalizing slot is
  held, and requeueFailedOps' fail_count budget retries them (dead-lettering
  a permanently hot/broken slug).

- ClaimBatch now claims by dedup_key affinity so a document is never split
  across concurrent batches. limit counts distinct dedup_keys (documents),
  and ALL eligible rows sharing a key are claimed together. On Postgres the
  per-key anchor row is locked with FOR UPDATE SKIP LOCKED, handing
  concurrent claimers disjoint key sets. This restores in-document ordering
  (e.g. ingest-then-retract collapses correctly) that the per-batch dedup
  could not guarantee once the exclusive per-KB lock was removed, preventing
  a stale ingest from resurrecting a retracted document.

Adds repository tests for same-key affinity and in-flight sibling rows.
2026-07-09 17:41:07 +08:00
..
memory/neo4j fix: revert to neo4j v6 and workaround Go 1.24 Windows compiler bug with -p=1 2026-04-11 22:08:02 +08:00
retriever test: fix stale Doris SQL-shape and flaky OSS bucket assertions 2026-06-29 17:44:56 +08:00
agent_share.go Refine scoped API key capabilities 2026-07-07 12:00:13 +08:00
audit_log.go feat(rbac): daily retention sweep for audit_logs (default 90 days) 2026-05-18 17:28:58 +08:00
chunk.go fix(server): case-insensitive doc keyword search + not-found classification 2026-07-06 22:53:01 +08:00
chunk_sqlite_test.go fix: SQLite/Lite mode compatibility for FAQ import and chunk operations 2026-04-15 20:37:10 +08:00
custom_agent.go fix(model): block deletion when model is referenced by KB or agent 2026-06-23 20:36:16 +08:00
datasource_repo.go fix(datasource): fail sync when all fetched items fail 2026-06-04 17:39:55 +08:00
datasource_repo_test.go fix(datasource): fail sync when all fetched items fail 2026-06-04 17:39:55 +08:00
embed_channel.go feat(embed): add backend embed channels with auth and rate limiting (#1657) 2026-06-12 23:10:39 +08:00
kbshare.go feat(rbac): lift org membership from per-user to per-tenant (Plan 3, #1303) 2026-05-18 17:28:58 +08:00
knowledge.go fix(server): case-insensitive doc keyword search + not-found classification 2026-07-06 22:53:01 +08:00
knowledge_finalize_test.go fix: mark knowledge delete failures after retry exhaustion 2026-06-16 16:47:46 +08:00
knowledge_source_schema_test.go fix(schema): expand knowledge source length 2026-06-05 15:12:25 +08:00
knowledge_span_repo.go feat: implement CancelOpenSpansByName method and related tests 2026-05-28 20:16:02 +08:00
knowledge_span_repo_test.go feat: implement CancelOpenSpansByName method and related tests 2026-05-28 20:16:02 +08:00
knowledge_tag.go fix(knowledge): harden multi-tag data integrity and UX follow-ups 2026-06-26 10:52:52 +08:00
knowledge_tag_test.go fix(knowledge): harden multi-tag data integrity and UX follow-ups 2026-06-26 10:52:52 +08:00
knowledgebase.go fix(model): block deletion when model is referenced by KB or agent 2026-06-23 20:36:16 +08:00
knowledgebase_sqlite_test.go feat(rbac): add tenant_members schema and auth wiring (PR 1 of 3, #1303) 2026-05-18 17:28:58 +08:00
mcp_oauth.go fix: harden API principal config after review 2026-06-30 20:01:05 +08:00
mcp_oauth_test.go feat: scope API MCP OAuth by principal 2026-06-30 20:01:05 +08:00
mcp_service.go feat: add built-in MCP service support 2026-03-05 21:57:01 +08:00
mcp_tool_approval_repository.go fix(agent): 加固 MCP 工具人审批的跨实例与并发语义 2026-05-10 22:57:12 +08:00
message.go feat(datasource): implement data source management functionality 2026-03-30 20:46:07 +08:00
model.go fix(repository): correct query syntax to get correctly built-in models 2026-05-21 16:11:22 +08:00
model_usage.go fix(model): block deletion when model is referenced by KB or agent 2026-06-23 20:36:16 +08:00
model_usage_test.go fix(model): block deletion when model is referenced by KB or agent 2026-06-23 20:36:16 +08:00
organization.go feat(rbac): lift org membership from per-user to per-tenant (Plan 3, #1303) 2026-05-18 17:28:58 +08:00
session.go feat(embed): scope OAuth and sessions per visitor principal 2026-06-30 20:01:05 +08:00
session_test.go feat(embed): add backend embed channels with auth and rate limiting (#1657) 2026-06-12 23:10:39 +08:00
system_setting.go feat(system): consolidate system admin and settings into one Settings panel 2026-05-26 21:13:56 +08:00
tag.go fix(knowledge): harden multi-tag data integrity and UX follow-ups 2026-06-26 10:52:52 +08:00
task_queue.go fix(wiki): prevent silent work loss and cross-batch doc races 2026-07-09 17:41:07 +08:00
task_queue_test.go fix(wiki): prevent silent work loss and cross-batch doc races 2026-07-09 17:41:07 +08:00
tenant.go feat: add scoped tenant api keys 2026-07-07 12:00:13 +08:00
tenant_api_key.go refactor(api-keys): remove API key reset endpoint and update documentation 2026-07-07 12:00:13 +08:00
tenant_disabled_shared_agent.go feat(agent): enhance agent and skill management features 2026-02-09 11:40:25 +08:00
tenant_invitation.go feat(rbac): add multi-use share-link invitations for invite_only mode (#1504) 2026-05-27 19:42:01 +08:00
tenant_member.go fix(repository): qualify tenant_id with table name to resolve ambiguous column reference 2026-05-21 21:22:41 +08:00
tenant_test.go feat: add scoped tenant api keys 2026-07-07 12:00:13 +08:00
user.go feat(system): consolidate system admin and settings into one Settings panel 2026-05-26 21:13:56 +08:00
user_resource_favorite.go feat(favorites): implement user favorites and recents functionality 2026-05-18 17:28:58 +08:00
vectorstore.go feat: add VectorStore service layer with types and connection testing 2026-04-13 22:57:17 +08:00
web_search_provider.go feat(web-search): refactor web search provider 2026-03-31 20:22:34 +08:00
wiki_log_entry.go perf(wiki): move ingest log to event table and index to on-demand API 2026-05-08 21:48:52 +08:00
wiki_log_entry_test.go perf(wiki): move ingest log to event table and index to on-demand API 2026-05-08 21:48:52 +08:00
wiki_page.go feat(wiki): implement folder management features in wiki API 2026-06-16 23:51:29 +08:00
wiki_page_test.go feat(wiki): implement folder management features in wiki API 2026-06-16 23:51:29 +08:00