Skip to content

fix(datasource): keep manually deleted items deleted across syncs - #2684

Open
mdrkrg wants to merge 4 commits into
Tencent:mainfrom
mdrkrg:feat/ds-sync-tombstone
Open

fix(datasource): keep manually deleted items deleted across syncs#2684
mdrkrg wants to merge 4 commits into
Tencent:mainfrom
mdrkrg:feat/ds-sync-tombstone

Conversation

@mdrkrg

@mdrkrg mdrkrg commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Description

修复 #2623 报告问题的部分根因:用户删除的知识库条目,只要源端仍报告,下次同步就会重建。复用知识软删除(deleted_at)为 tombstone(意图为持久的用户删除排除),删除后,同步将永不拉回该条目。

预期行为:用户删除的条目保持删除,后续同步不会将其带回;同步的例行维护(文件更新、源端文件删除 为现有行为、子条目清理)不会导致条目被意外排除(通过硬删除实现),失败会在下次同步恢复。

已知限制:数据源以相同 external_id 重建的文件在 tombstone 存在期间不会重新出现。如果有必要管理被软删除的条目,等后续 issue / PR 讨论。

此 PR 引入行为上的变更,可能需要进一步讨论用户面的设计 / 文档更新。

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 💥 Breaking change
  • 📚 Documentation update
  • 🎨 Refactor
  • ⚡ Performance improvement
  • 🧪 Test
  • 🔧 Configuration / Build / CI

Related Issue

Related #2623, but not fixed entirely.

Testing

  • TestProcessSync_TombstonedItemIsNotResurrected:用户删除保持删除,计 skipped
  • TestProcessSync_UpdateIngestFailureRecoversNextSync:更新失败 -> 下次重建而非跳过
  • TestProcessSync_SweptChildReappearsIsReingested:swept 子条目重新出现 -> 重新入库
  • repository 层测试

Checklist

  • git diff --check origin/main...HEAD passes
  • Changed source files are formatted
  • Targeted tests for the changed packages/components pass
  • Diff-scoped lint passes where applicable (for Go: golangci-lint run --new-from-rev=origin/main ./...)
  • Full-repository checks were run, or any unrelated/environment-dependent failures are documented above
  • Self-reviewed the code
  • Added/updated tests covering the change
  • Updated related documentation (README, docs/, Swagger annotations, etc.)
  • Breaking changes are clearly called out in the description above

Screenshots / Recordings

mdrkrg added 3 commits August 13, 2026 23:49
A document the user deleted from the KB was re-created by the next sync
while the source still reported it.

Add regression tests for the deletion exclusion: user-deleted items
stay deleted across syncs, a failed update-replace leaves no tombstone,
and a swept child re-appearing at the source is re-ingested.
Sync re-created knowledge the user had deleted while the source still
reported it.

Deleted rows now act as a persistent exclusion for their data source
and external item: sync never brings them back, while sync-internal
deletions are physically removed so re-added items can be re-synced.
A transient error while checking the tombstone let the sync fall
through and re-create an item the user had deleted from the KB.

Such items now count as failed instead of being re-created.
@mdrkrg
mdrkrg force-pushed the feat/ds-sync-tombstone branch from 288ff72 to 4b14c86 Compare August 13, 2026 15:59
Fail closed when live lookup errors, skip rows in deleting state,
surface user_deleted_excluded on tombstone skips, and fail update
replace when hard-delete does not complete.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants