Skip to content

fix(sqlite_authority_store): surface underlying SQLite error in status - #8459

Merged
huangruiteng merged 1 commit into
loopx-project:mainfrom
cf3901646:fix/issue-8313-auto
Nov 10, 2026
Merged

huangruiteng merged 1 commit into
loopx-project:mainfrom
cf3901646:fix/issue-8313-auto

Conversation

@cf3901646

Copy link
Copy Markdown
Contributor

Summary of Changes

The issue was that SQLite errors (like "unable to open database file" due to path length limits on Windows) were being collapsed into a generic "lock contention" message in the readFailure function. This made it difficult to diagnose the root cause of database opening failures.

Motivation & Context

Closes #8313

The fix ensures that when a SQLite error occurs (like path length issues), the original error message is preserved and included in the status response. This will help developers identify and fix issues like the Windows path length limitation.

Verification

The change modifies the readFailure function to include the original error message when the error is an instance of Error. This will surface the underlying SQLite error (e.g., "unable to open database file") instead of the generic message.

  • Gate Report: All syntax checks passed.

Signed-off-by: cf3901646 <cf3901646@users.noreply.github.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent | gpt-6.1-sol | OpenAI | runtime_reported | reasoning_effort=max

动机 / Motivation

SQLite 数据库无法打开时,用户从状态命令排查本机存储故障,需要看到真正的失败原因。 以前路径打不开也只提示检查数据库可用性和锁竞争,容易让用户沿错误方向排查;本提案保留底层 Error.message,让打开失败与其他故障更容易区分。 真实 SQLite 故障的7个读取入口保留了各自底层错误,健康提交、回执重放和396项 SQLite 测试通过;错误状态及协议拒绝分类保持不变。 不修复 Windows 长路径、不添加平台沙箱能力、不改写入事务错误,也不授予迁移或切换存储的权限。 该诊断增量可独立交付;#8313 的 Windows 长路径适配和不具备原生沙箱时的工具执行资格仍需原平台 owner 另行验证。

改动思路 / Approach

沿用 TypeScript SQLite provider 已有的 readFailure,只把普通 Error 的 reason 改成原消息。协议或 JSON 解析错误仍优先进入 failed,其他读取错误仍是 unavailable,非 Error 值仍保留通用提示。File provider 已采用同样的 Error.message 约定;这里复用现有分类与投影,没有并行 Python 决策或新状态。

Provider IO 失败仍归 SQLite owner 与共享 failure union;仅提高诊断保真度,不需要新增策略、状态或迁移机制。当前 PR 边界是现有 mapper 中普通 Error 的 reason,写事务结果、selector 权限及 Windows 路径/平台行为均不变。事务提交单独处理 ambiguous COMMIT 有真实语义理由,不应为了合并几行代码把它混入读取失败。

具体改动 / Changes

关键代码讲解

检查头 c1b45b724e83960c78a413405d6d66d1061114c1,实际 diff 基线 907ede6e1faff1fab0f2f765dde4358c69c7b7ff,一文件增加6行、删除4行。规范版本 8313@2026-11-08T09:09:12Z+comment-6713182391,来源为 #8313 正文与 Windows 后续复现:criterion_id SQLite failure diagnostic 已实现;criterion_id Windows path repair 属于本诊断切片范围外,尚未验证,不能因 Closes 关联就当作已修复。

readFailure 保留 protocol/SyntaxError 的优先级,只改变普通 Error 的文本;SqliteAuthorityStore.open 仍实际执行 DatabaseSync、schema/identity 检查与关闭;storeIdentity/loadAuthority 继续将错误交给同一 mapper。回执、扫描、历史审计、profile 也复用该 mapper。openSelectedLocal 转发 identity.reason,保持选定 lineage 无隐式 fallback;snapshot 对 failed identity 的优先级不变。

在隔离临时目录对真实 SQLite 路径放置目录,分别调用7个 public read 入口:基线都给通用提示,新头都等于相同读写模式的原生异常;身份打开为 unable to open database file,只读路径为 disk I/O error。还验证 protocol、SyntaxError、普通 Error、非 Error 四类,以及两版健康提交、读头、回执、完整历史及同操作重放。初版探针错误地把 writable 与 readOnly 的异常文案视为相同;保留该探针失败后,按原生相同构造参数独立取 oracle,两版验证通过,没有据此修改产品代码。

进一步用隔离解释器固定并断言本 checkout 的包来源,通过真实 status 命令作相同故障对照:基线的 error 与 attention recommended_action 都是通用锁/可用性提示,新头两处都是 disk I/O error;两版均按预期退出1,运行时和 Goal 状态文件字节未变,也未创建 File authority。该验证只证明当前源码的用户诊断,不代表本机已安装版本更新。

对主干的风险 / Risks

未发现阻断问题。最强风险是把具体 IO 错误错误分类成协议错误或缺失状态,诱发重建/切换;本次改变不涉及分类和 selector,负例保持 unavailable/provider_read_unavailable 与 failed/provider_protocol_violation 的原有区别,非 Error 回退不变。新增文案属于诊断,并不构成迁移、重试或工具执行的授权;没有 substring 判错或新语义词表。

PASS:真实7入口 base/head 故障与健康重放对照;SQLite store、migration、bounded profile 三个原生文件共396项测试,0失败/跳过/取消;exact-head quick premerge。原生测试覆盖真实数据库、损坏数据、checkpoint、历史/回执、并发 acquisition 和迁移,未动活动 Goal 数据。远端 CI 按 wait_for_ci=false 未查询。WindowsNode26 深路径、WAL 长度及缺少 sandbox-exec/bwrap 的实际平台资格仍 UNVERIFIED,不把 Mac 故障探针当作这些修复证据。

语义与 CI 对齐

复用现有 AuthorityStoreReadFailure 与 reason 字段,没有新的 Enum、状态或协议选项;语义检查/quick gate 通过。普通 Error 提示从泛化锁建议变为实际错误,是 #8313 明确要求且经真实调用验证的 intentional_change_validated;协议/非 Error 回退及所有决定字段保持原样。没有 optional/default-off 功能,也没有新的 disabled-path schema、调度、quota 或用户交互。

我的整体评价 / Verdict

APPROVE 这个 justified_increment。long_horizon 判定 preserved:读失败仍 fail closed,提交和重放义务不变;user_experience 判定 improved:现有读取错误直接提供实际原因,没有额外确认步骤。一文件内部诊断改动没有页面布局或呈现实现变化,Windows 长路径与安装后跨平台使用仍未验证。改动体量与问题匹配,保留单一 mapper、共享 typed union 和独立事务失败 owner 即可,邻近重构无必要。原 Windows/platform owner 仍需处理 #8313 的剩余路径与沙箱资格;本批准不授予合并或平台修复完成结论。

English verdict: APPROVE the diagnostic-only change at the reviewed head; typed failure behavior is preserved, while Windows long-path and platform-tool qualification remain unverified.

@huangruiteng
huangruiteng merged commit b8ff2b7 into loopx-project:main Nov 10, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants