WeKnora/internal
linus-liu-web a8a2c17b89
fix(sqlite): 索引行写入失败不再被丢弃,BatchSave 回滚而不是留下「主行在、索引行不在」 (#3843)
* fix(sqlite): 索引行写入失败让 Save/BatchSave 报错并回滚

Lite(DB_DRIVER=sqlite)的 vec0 / FTS 索引行 helper 丢弃 Exec 返回值:
BatchSave 的事务末尾无条件 return nil,于是 chunk 主行提交而索引行缺失,
Save/BatchSave 仍报成功,向量与关键词两条检索路径都静默漏召回;CopyIndices
的 copyVec 同样可能报成功而向量行没有复制过去。

- insertVec / syncFTS5Insert / copyVec / deleteRowsAndVecs 返回 error,在
  BatchSave(事务内)与 CopyIndices 的调用点检查并上抛:事务回滚,
  BatchIndex 报错后走 knowledge_process.go 既有的清理与 failed 标记路径;
  删除路径在索引行删除失败时不再删除主行。
- ensureVecTable 校验同名对象确实是 vec0 表之后才缓存"已就绪",失败上抛
  (BatchSave 与 vectorRetrieve);向量写失败时清掉该维度的缓存,下一次写入
  重新建表,而不是被永久短路。
- initFTS5 返回 error,并把建表与回填放进同一个事务(半回填的索引会静默丢
  召回);驱动未编译 fts5 模块(上游 go test 不带 -tags sqlite_fts5)时只
  记录一次并跳过关键词写入,而不是让每次入库失败;Lite 发布构建始终带该 tag。

新增 index_write_errors_test.go:覆盖 vec0 / FTS 表缺失、vec0 维度不匹配、
同名对象占位、索引删除失败、CopyIndices 向量复制失败,以及正常路径与无 fts5
模块构建。把修复改回原样后,其中 6 个用例必失败。

Fixes #3833

* fix(sqlite): CopyIndices 行复制失败累计上报,不再 Warn 后跳过

克隆/搬运知识库时逐行 Create 失败原先只记 Warn 并 continue:目标库会缺
主行/索引行却仍报成功。现改为逐行累计错误,FTS 与向量复制失败同样累计
而不是遇到第一条就返回,最后 errors.Join 交给调用方;错误里带源/目标
chunk id 便于定位失败行,不含正文。调用方沿用既有 rollbackIndices 回滚
与 failed 标记路径。

新增回归用例:触发器拒单行 -> 调用方拿到可定位到该行的错误、同 chunk 的
其它行照常复制;DROP FTS 表 -> 错误带上表和 chunk id 且向量行仍写入。

---------

Co-authored-by: linus-liu-web <11640009+linus-liu-web@users.noreply.github.com>
2026-10-07 23:59:26 +08:00
..
agent fix(compaction): 流因取消而关闭时不得当成空摘要成功返回 2026-09-29 01:30:01 +08:00
application fix(sqlite): 索引行写入失败不再被丢弃,BatchSave 回滚而不是留下「主行在、索引行不在」 (#3843) 2026-10-07 23:59:26 +08:00
assets feat(assets): add ASR test audio file and embed it in the application 2026-04-02 21:27:27 +08:00
browserskill fix(browser): refine connection and preview UI with extension version 2026-09-23 10:57:59 +08:00
common fix(markdown): sanitize invalid UTF-8 and NUL bytes 2026-08-31 12:24:35 +08:00
config feat(auth): 新增仅限邀请注册档位 (#3900) 2026-09-30 13:32:55 +08:00
container fix(server): run ResourceCleaner on signal shutdown instead of racing Fatalf exit (#3804) 2026-09-28 23:37:36 +08:00
database revert: take the plugin system back out of main 2026-09-26 14:58:18 +08:00
datasource fix(notion): 查询撞厂商上限被截断时不再静默,截断轮次不下发删除 (#3845) 2026-10-07 23:54:08 +08:00
embedpolicy fix(embed): enforce host origin allowlists on framed pages 2026-09-14 18:03:57 +08:00
errors feat(knowledge): flag documents that stop making progress (#3557) 2026-09-22 21:34:08 +08:00
event fix(agent): end the turn when the completion cap truncates an answer (#3449) 2026-09-20 13:17:50 +08:00
filetransport refactor(resource-access): unify scoped authorization and transfer recovery (#3097) 2026-09-08 15:36:33 +08:00
handler fix(embed): 内嵌网页只传图片不输入文字时不再返回 400 2026-09-30 15:26:51 +08:00
im revert: take the plugin system back out of main 2026-09-26 14:58:18 +08:00
infrastructure feat(docparser): upgrade AnyDoc to 0.2.4 and parse assets once 2026-09-30 15:25:01 +08:00
ipclass fix: align client sessions and integration request handling (#3305) 2026-09-16 16:20:57 +08:00
localsandbox feat(lite): install and run skills on the host (#3661) 2026-09-24 21:30:34 +08:00
logger fix(logger): keep LLM debug records inside their directory 2026-09-25 18:22:14 +08:00
mcp revert: take the plugin system back out of main 2026-09-26 14:58:18 +08:00
mcpserver fix(mcp): return accessible image URLs from existing tools (#3650) 2026-09-24 11:56:25 +08:00
middleware fix(knowledge): stop pipeline errors from stranding rows in processing 2026-09-22 20:33:18 +08:00
modelcontext fix(citations): 修复原文定位、高亮范围与 DocReader 启动失败 (#3794) 2026-09-27 20:32:26 +08:00
models fix(frontend): 修复复制模型时模型名称被改写的问题 (#3830) 2026-09-29 19:32:08 +08:00
ratelimit feat(embed): add backend embed channels with auth and rate limiting (#1657) 2026-06-12 23:10:39 +08:00
reranking fix(retrieval): fix recall correctness, score scales, cost and agent tools (#3687) 2026-09-25 10:48:18 +08:00
router fix(frontend): 修复复制模型时模型名称被改写的问题 (#3830) 2026-09-29 19:32:08 +08:00
runtime fix(server): run ResourceCleaner on signal shutdown instead of racing Fatalf exit (#3804) 2026-09-28 23:37:36 +08:00
sandbox fix(sandbox): build real arm64 sandbox images and ship arm64 Cube variants 2026-09-30 13:34:01 +08:00
searchutil feat(wiki): 增加跨知识库 Wiki 搜索 POST /wiki-search (#3535) 2026-09-25 22:22:58 +08:00
sourceloc fix(citations): 修复原文定位、高亮范围与 DocReader 启动失败 (#3794) 2026-09-27 20:32:26 +08:00
storageallowlist fix(storage): align default provider fallback with STORAGE_ALLOW_LIST 2026-07-15 11:05:00 +08:00
storageurl fix(mcp): return accessible image URLs from existing tools (#3650) 2026-09-24 11:56:25 +08:00
stream feat(session): in-place rewind with workspace checkpoint reset (#3469) 2026-09-20 21:01:00 +08:00
textconv fix: remove GPL converter and bundle third-party license sources 2026-09-08 15:19:10 +08:00
tracing/langfuse fix(milvus): preserve keyword retrieval scores 2026-09-17 11:59:40 +08:00
types fix(embed): 内嵌网页只传图片不输入文字时不再返回 400 2026-09-30 15:26:51 +08:00
utils feat(security): add a whitelist-only outbound mode that refuses before DNS (#3393) 2026-09-23 12:02:06 +08:00