Repository navigation
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Hi @songoow, the DCO If the log confirms a missing |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0aa69e0728
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Hi @songoow, the DCO If the log confirms a missing |
|
Hi @songoow, the DCO If the log confirms a missing |
songoow
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · GPT-6 Astra Pro · OpenAI · self_reported
Request changes conclusion (author-owned PR; GitHub blocks formal self-review)
动机 / Motivation
长期运行同一 Goal 的本地 SQLite 权威存储时,后台进程会重复借用同一个数据库连接。以前写入高峰留下的日志可以持续占用磁盘;这次加上回收上限,预期在读者退出、日志完成重置后释放多余空间。预期后续写入尊重当前存储实例设置的日志保留上限。审查覆盖本机数据库连接、日志检查点、连接复用和对应的持久化测试。
改动思路 / Approach
日志保留上限是 SQLite 连接参数,借用连接的存储实例和连接池必须为这个参数指定同一生命周期。 本次在打开新写连接时设置 PRAGMA,通过归还句柄触发检查点,用尚未处理的帧数判断是否需要工作。单独使用一个存储实例时,两种机制可以独立生效。保留现有事务和检查点实现,在复用写连接时应用当前实例的配置,或明确定义统一的连接池配置。
具体改动 / Changes
关键代码讲解
openWriteTransaction 在第一次打开数据库时设置日志上限、同步和临时表策略,并在校验库的身份后处理 POSIX 文件模式。只读连接额外启用 query_only。maybePassiveCheckpoint 先按 SQLite 版本确认 NOOP 能力,再读取尚未处理的帧数,满足阈值才执行 PASSIVE。如果读者阻止进度,池使用按句柄记录的退避时间控制下一次尝试。这也修正了旧讨论中通过物理文件长度触发检查点的问题。acquireSqliteAuthorityHandle 仍按模式、路径和 inode 复用健康句柄,命中时直接返回,跳过负责设置保留上限的回调。
基线规范 docs/reference/sqlite-authority-store.md,版本 083d869。条目「Atomic writes」保留了立即写事务、WAL、FULL 同步及单次提交的可见性,CAS、备份和存储回归在本机通过。新的可配置上限另外受连接池复用影响。写连接设置
对主干的风险 / Risks
P2 复用连接时忽略第二个存储实例的 WAL 保留上限。 先用默认值提交,再在同一目录和 Goal 上创建上限为 65536 字节的新实例提交;两次均 applied,借回该写连接实际读到的 journal_size_limit 仍是 67108864。 这样数据库写入会正常返回,但同一进程里先打开数据库的实例决定后来实例的实际磁盘保留策略,较低上限只在重新开连接时才生效。测试为每个独立场景创建新目录和新池,因而没覆盖同一数据库切换实例。在每次获取连接后同步当前期望值,或把上限设计为明确的池级配置,并覆盖两个实例连续借用同一连接的测试。
我的整体评价 / Verdict
现有回收策略对重复使用同一配置的后台写入有价值。重新打开同一 Goal 的用户需要实际可执行的保留上限,否则过期空间仍可能按旧值保留。在 Node 24.22.3 与 SQLite 3.54.1 上,针对存储、连接池、CAS、消费进度、备份恢复、迁移和新增硬化行为的八个文件共 449 项测试全部通过。 测试包含读者固定快照时的退避、WAL 重置后回收和相同配置下的连接复用。此处还缺少带不同配置的连续写入验收;其他版本、操作系统和生产磁盘上的表现未实测。
English verdict: REQUEST_CHANGES at 08b649c — a pooled writer retained the previous instance’s WAL retention limit; all 449 repository checks passed.
|
Hi @songoow, the DCO If the log confirms a missing |
c1914fa to
4e2ccff
Compare
9bc88e1 to
8861a96
Compare
aca8340 to
2a3c546
Compare
songoow
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · GPT-6 Astra Pro · OpenAI · self_reported
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
长期运行 daemon 的操作者需要控制空闲 WAL 占用,并能在修复文件权限后安全重试。主干的 SQLite 连接默认返回 journal_size_limit=-1。在同一真实库切换两个配置不同的 store 时,主干仍返回 -1。当前提交保留 64 MiB 默认上限,复用连接能切换到 64 KiB;已提交请求重放得到同一 cursor。评审范围是本地 SQLite authority 的读写和文件生命周期。
改动思路 / Approach
连接级 PRAGMA 归 SQLite store 配置,写入、回执和权限失败沿用现有事务边界。实现集中在 SQLite provider;连接池、外部协议、File provider 和调度器均沿用现有代码。
具体改动 / Changes
仅 SQLite store 与一份回归测试发生变化。最昂贵的修复只在已有文件模式需要收紧时运行。在主干及当前 head 以完全相同的两次写入和重放运行:主干上限 -1、-1,文件 0644;当前 head 为 67108864、65536,文件 0600。两边重放 cursor 均为 2。
按 docs/reference/sqlite-authority-store.md(e357962f24577c19cf74153572fc9fd65be7487b)验证 local-sqlite-authority。当前 head 上八组 SQLite 回归共 455/455 通过,无跳过;control-plane TypeScript 类型检查通过。
对主干的风险 / Risks
新测试覆盖拒绝写入与历史回执重放:写入失败时未增加 cursor,正常重试才产生新回执。验证环境为 Linux 上的本地文件系统。Win32 使用独立平台分支,WAL 在活跃读者占用时可以超过保留阈值。获取检查时 Sign-off、dependency-review、Summary 均成功。
我的整体评价 / Verdict
当前 head 的实现与上述范围一致,可以接受。连接级 PRAGMA 归 SQLite store 配置,写入、回执和权限失败沿用现有事务边界。实现集中在 SQLite provider;连接池、外部协议、File provider 和调度器均沿用现有代码。
English verdict: APPROVE at 2a3c546. Verified the per-writer WAL limit, retry behavior and SQLite authority regression suite.
2a3c546 to
fe9b78b
Compare
songoow
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · GPT-6 Astra Pro · OpenAI · self_reported
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
长期运行 daemon 的操作者需要控制空闲 WAL 占用,并能在修复文件权限后安全重试。主干的 SQLite 连接默认返回 journal_size_limit=-1。在同一真实库切换两个配置不同的 store 时,主干仍返回 -1。当前提交保留 64 MiB 默认上限,复用连接能切换到 64 KiB;已提交请求重放得到同一 cursor。评审范围是本地 SQLite authority 的读写和文件生命周期。
改动思路 / Approach
连接级 PRAGMA 归 SQLite store 配置,写入、回执和权限失败沿用现有事务边界。实现集中在 SQLite provider;连接池、外部协议、File provider 和调度器均沿用现有代码。
具体改动 / Changes
相对上次审查增加对已打开 WAL 和配置路径身份的复核,并处理冷启动时另一个进程刚刚完成初始化的情况。新 main 的四个发布文件与本 PR 没有重叠。在主干及当前 head 以完全相同的两次写入和重放运行:主干上限 -1、-1,文件 0644;当前 head 为 67108864、65536,文件 0600。两边重放 cursor 均为 2。
按 docs/reference/sqlite-authority-store.md(dd4f32c4a8911d9db181d1eae4c96d835446887b)验证 local-sqlite-authority。当前 head 上八组 SQLite 回归共 457/457 通过,无跳过;control-plane TypeScript 类型检查通过。
对主干的风险 / Risks
新测试覆盖拒绝写入与历史回执重放:写入失败时未增加 cursor,正常重试才产生新回执。验证环境为 Linux 上的本地文件系统。Win32 使用独立平台分支,WAL 在活跃读者占用时可以超过保留阈值。 在 Windows 扩展路径上,如果数据库通过存在性检查后、实际打开前被移动,裸路径的可写打开可能留下空文件。起初就缺失的库会被拒绝。main 已有相同行为,未在原生 Windows 上复现;驱动对照确认了裸路径会创建、mode=rw 会拒绝。检查快照显示 Summary 成功,Sign-off 与 dependency-review 尚未结束。
我的整体评价 / Verdict
没有发现合并阻塞项。Windows 特殊路径的恢复行为可独立补测。连接级 PRAGMA 归 SQLite store 配置,写入、回执和权限失败沿用现有事务边界。实现集中在 SQLite provider;连接池、外部协议、File provider 和调度器均沿用现有代码。
English verdict: APPROVE at fe9b78b. Verified the per-writer WAL limit, retry behavior and SQLite authority regression suite.
cb13931 to
f224332
Compare
…sed 0600 perms Harden SqliteAuthorityStore without adding inline pool checkpoint stalls or background worker overhead: - On POSIX, open existing databases directly with URI mode=rw (no SQLITE_OPEN_CREATE) when pre-open stat is not ENOENT so transient metadata errors never block cold-reopen exact replay, while ENOENT routes through private 0600 pre-creation + fresh pre-open stat so concurrent initialization succeeds on the first commit. Preserve Windows extended-length/device/volume-GUID paths (\?\..., \.\...) natively when opening selected stores. - Reject dangling symlinks (ENOENT/ENOTDIR) before target creation while preserving path-free access diagnostics (EACCES) for unreachable symlink targets, and sanitize pre-open directory/file errors. - Enforce allowExtension: false on both ro and rw handles, temp_store = MEMORY and query_only = ON on ro, and checkpoint_fullfsync = ON + temp_store = MEMORY on rw (keeping synchronous = FULL). - Configure PRAGMA journal_size_limit (default 64 MiB, validated within 0..MAX_SAFE_INTEGER) and reapply it on pooled handle reuse whenever the limit changes so SQLite's native wal_autocheckpoint + WAL reset truncates retained WAL disk usage cleanly. - Cross-check pre-open main DB (dev, ino) against post-open PRAGMA database_list + lstatSync + configuredPath statSync (allowing normal concurrent last-connection WAL cleanup handoffs), bind active -wal/-shm sidecars by their own (dev, ino) pairs (supporting bind-mounted DBs), recheck target/sidecar identity before and after loading head in withCheckpointHead, enforce private modes before any INSERT (preventing uncommitted page spills into non-private WALs) and immediately before COMMIT, preserve typed detachment status across post-COMMIT checks and helper ENOENT/ETARGETCHANGED failures (returning ambiguous, evicting both detached writer via read-only snapshot guard and pooled ro handles so receipt reconciliation reads durable state), tighten loose files via an isolated O_NOFOLLOW + fstat + fchmod + post-fstat helper with JSON over stdin (EMODEUNCHANGED, EMULTILINK, no paths in argv, preserving parent POSIX fcntl locks), and surface safe permission-specific diagnostics while retaining rollback and existing reason codes. - Verified with npm run typecheck:control-plane and all 8 control-plane SQLite test suites (459/459 PASS). Signed-off-by: song <xinxinsong66@gmail.com>
f224332 to
f523902
Compare
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
[P2] 避免默认 checkpoint 同步设置拖慢普通 SQLite 写入。同机无插桩按 head/base/base/head 交替运行时,候选 last-100 commit p50 为 27.9–31.7 ms,128 次填充用 4.23–4.39 秒。写连接被无条件设置 checkpoint_fullfsync=ON。默认未启用句柄池的路径重复创建和关闭连接,新增同步设置会进入前台写流程。 受审位置
动机 / Motivation
使用 SQLite 权威存储执行写入、恢复或历史读回的操作者。 长时间运行会在重置间隔保留 WAL 容量。正式提交需要保护数据库和配套文件的私有权限。 候选约束 WAL 重置后的保留空间,并在现有写入边界检查权限,保持历史回执可复验。 范围是合成 SQLite 存储入口和历史回执。 使用 macOS Node 24.21.0、SQLite 3.53.4 的一次性合成库。系统负载有波动。实际常驻 Daemon、其他平台、断电和长期生产写入未验收。 验收依据
改动思路 / Approach
由既有 SQLite journal_size_limit 管理重置后的保留大小,沿用原句柄池、事务与回执。 改动集中在 SQLite 存储 owner 和测试。已选 SQLite 的默认写流程受影响。 SQLite 原生 checkpoint 仍可能发生在提交线程或最后一个连接关闭时。 SQLite WAL · checkpoint_fullfsync · 当前 PR · 旧提交的 checkpoint 评审
具体改动 / Changes
-
WAL_RETENTION。约束 checkpoint 后可重置的 WAL 保留空间。
-
RECEIPT_RECOVERY。保留历史回执,改变请求内容的重放保持冲突。
-
WRITE_COST。解释普通写入路径的新增延迟并验证默认取舍。
-
normalizeJournalSizeLimitBytes。校验 SQLite 重置后保留的 WAL 大小上限。 受审实现 -
ensureJournalSizeLimit。随句柄复用,仅在值变化时重设 retained WAL 上限。 受审实现 -
configureWriteHandle。在每次创建写句柄时设置 checkpoint_fullfsync=ON。 受审实现 -
commitAuthority。在写入前与提交前验证私有模式及文件状态,沿既有事务与回执。 受审实现 -
journal_size_limit truncates retained WAL。用真实文件验证回收保留空间发生在 WAL 重置后。 受审实现
对主干的风险 / Risks
仓库 local-provider-comparison.ts,SQLite mixed、128 次提交、20 个读取样本,base 和 head 串行交替。 两轮基线 last-100 commit p50 为 6.0–8.9 ms,128 次填充用 1.92–2.03 秒。 基线和候选的 128 次同负载都通过完整记录与原回执的重开恢复、精确历史重放和改参冲突检查。两边的最终存储大小一致。
在同一候选的一组诊断中只将 checkpoint_fullfsync 设回 OFF,保留同步提交、权限和 WAL 配置,last-100 commit p50 从 32.1 ms 降至 5.4 ms。另一组较高负载的插桩运行 p50 不稳定,不作为修复后的预计时延。
本机 SQLite 套件 459 项通过,git diff --check 通过。全量 TypeScript 检查在基线和候选给出完全相同的 OAR 缺依赖诊断。 改动文件的定向 TypeScript 编译通过。
我的整体评价 / Verdict
要求修改精确提交 f523902。保留 WAL 保留量与私有文件检查,让普通写入沿用基线的 checkpoint 同步策略。如果需要更强的 macOS checkpoint 耐久性,请在明确配置边界下提交同负载对照和耐久性取舍。 新提交应重跑本轮入口反例。
English verdict: REQUEST_CHANGES at f523902. The default checkpoint_fullfsync increases write latency in the paired unpooled SQLite workload. Preserve the baseline checkpoint policy or qualify the new durability tradeoff independently.
Signed-off-by: Codex <codex@openai.com> Signed-off-by: song <liusongstep@gmail.com>
songoow
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · GPT-6 Astra Pro · OpenAI · self_reported
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
长期运行本地 SQLite 权威存储的操作者,需要控制 WAL 留存并保持普通提交的可预期成本。原始主干沿用 SQLite 的 checkpoint 同步策略,早先的 PR 却对每个新写连接显式打开 checkpoint_fullfsync。当前提交恢复驱动默认 checkpoint 策略,继续使用 synchronous=FULL,并按每个写入者的配置限制 WAL 留存。验证集中在本地 SQLite 的配置、写入、历史回执和重开恢复。
改动思路 / Approach
SQLite 自身已经负责 checkpoint;附加一次全盘同步的决定不应隐藏在创建写连接的通用代码里。保留 store 针对文件模式和 WAL 的检查,只删除强制同步的赋值。池的所有者、数据库格式和回执协议继续由原有代码维护。通过同一入口和合成 fixture 比较改动前后的运行结果,并核对错误返回时能否恢复原有工作流。
具体改动 / Changes
八组 SQLite 测试 459/459 通过,类型检查通过。写连接直接读回 checkpoint_fullfsync=0、synchronous=2;已有测试覆盖借用连接时更换 WAL 上限。在同一 Linux 主机运行 128 次 mixed 写入和 20 个样本,主干与修复均通过历史回执重放和改参冲突。修复前同一个真实写连接在要求 checkpoint_fullfsync=0 的回归中失败,修复后通过。先前 macOS 的诊断观察到强制同步与较高时延相关。
本次按 docs/reference/sqlite-authority-store.md(e410b012e67a2fa75ff0056b16ab1362b931764d)核对 WRITE_COST 的实现。其中比较的是仓库实际调用方所获得的结果,远端整套发布流水线单独记录。
对主干的风险 / Risks
本次实测是 Linux x64、Node 24.22.3 和 SQLite 3.54.1。主干和候选各运行一次,last-100 p50 分别为 2.76 和 3.12 毫秒,未重复测量 macOS 性能、断电或长期负载。修复前同一个真实写连接在要求 checkpoint_fullfsync=0 的回归中失败,修复后通过。先前 macOS 的诊断观察到强制同步与较高时延相关。上述证据支持本次所修改的调用边界;对未执行的平台不作延伸判断。
我的整体评价 / Verdict
没有发现当前提交引入的合并阻塞项。SQLite 自身已经负责 checkpoint;附加一次全盘同步的决定不应隐藏在创建写连接的通用代码里。保留 store 针对文件模式和 WAL 的检查,只删除强制同步的赋值。池的所有者、数据库格式和回执协议继续由原有代码维护。
English verdict: APPROVE at 6354783. The default checkpoint policy is preserved and WAL limits, receipts and recovery still pass.
Summary
Hardens
SqliteAuthorityStorefor long-lived control-plane daemon operation while keeping the connection pool (sqlite_authority_pool.ts) untouched (zero inline synchronous checkpoint stalls on the daemon event loop and zero background worker memory overhead):Changes (
2 files,+2014 / -15)loopx/control_plane/coordination/sqlite_authority_store.ts:mode=rw, & path-free diagnostics: On POSIX, opens existing databases directly with${pathToFileURL(path).href}?mode=rw(noSQLITE_OPEN_CREATE) when pre-openstatis notENOENTso transient metadata errors never block cold-reopen exact operation replay, whileENOENTroutes through private0600pre-creation (O_CREAT | O_RDWR | O_EXCL) plus a fresh pre-openstatso concurrent initialization succeeds on the first commit. Preserves Windows extended-length/device/volume-GUID paths (\\?\...,\\.\...) natively for selected stores. Distinguishes dangling symlinks (ENOENT/ENOTDIR->provider_protocol_violation) from inaccessible symlink targets (EACCES-> path-freeprovider_read_unavailable), and wraps pre-open directory/file errors in path-free permission diagnostics with errno.(dev, ino)binding + pool hygiene: Cross-checks pre-open main DBstatSync(path)(dev, ino)against post-openPRAGMA database_list+lstatSync+statSync(configuredPath)(allowing normal concurrent last-connection WAL cleanup handoffs) and tracks each active-wal/-shmsidecar by its own(dev, ino)pair (supporting bind-mounted DBs). Rechecks target/sidecar identity both before and after loading head inwithCheckpointHead(tolerating transientEIO), and discards unverified handles on release so transient errors never poison the handle pool.INSERTmode enforcement, pre-COMMITre-check, post-COMMITreconciliation & safe detached eviction: Enforces private modes before the firstINSERT(preventing uncommitted pages from spilling into a non-private WAL) and re-verifies identity immediately beforedb.exec("COMMIT"). If post-COMMITverification or helper tightening detects detachment (ETARGETCHANGED/ENOENT), preserves the typed detachment flag, returnsambiguous(commit_outcome_unknown) for receipt reconciliation, evicts the detached writer while holding a transient read-only snapshot lock (so SQLite close-time WAL teardown never unlinks a replacement WAL), and evicts pooledrohandles on the same path soreadReceipt()reads durable state from the live path. Cold-path tightening rejects unbound loose sidecars on already-private DBs, rejects multiply hard-linked targets (EMULTILINK), and runs an isolated short-livedO_NOFOLLOW+fstat+fchmod+ post-fstathelper (EMODEUNCHANGED) receiving its JSON payload overstdin(no paths inargv, never releases parent SQLite POSIXfcntllocks).allowExtension: falseon bothroandrwhandles; setsPRAGMA temp_store = MEMORY; PRAGMA query_only = ON;onrohandles; setsPRAGMA checkpoint_fullfsync = ON; PRAGMA temp_store = MEMORY;onrwhandles (preservingsynchronous = FULL).PRAGMA journal_size_limit(default64 MiBviaSQLITE_AUTHORITY_JOURNAL_SIZE_LIMIT_BYTES, validated within0..Number.MAX_SAFE_INTEGER) and tracks the active limit per handle in aWeakMapso pooled checkouts with different limits reapply the PRAGMA without reopening the handle. Relies on SQLite's nativewal_autocheckpoint = 1000,journal_size_limittruncation on WAL reset, and the existing 30s pool idle TTL.tests/control_plane_ts/sqlite_authority_hardening.test.ts:-walreset truncation, POSIX mode invariants, replay/checkpoint isolation, pre-INSERTzero-spill, sole-writer detached eviction preserving replacement WALs, post-COMMITWAL detachment & pooledroinvalidation (ambiguous), helperETARGETCHANGED, normal last-connection WAL cleanup handoff, cross-device bind-mount sidecars,stdinhelper privacy, dangling vs inaccessible symlinks, concurrent initialization race, and cross-platform cold selected-store writes.Verification
npm run typecheck:control-plane: PASSsqlite_authority_hardening,sqlite_authority_pool,sqlite_authority_store,sqlite_authority_concurrent_cas,sqlite_authority_consumer_lag,sqlite_authority_backup_lineage,sqlite_authority_migration,sqlite_backup): 459 / 459 PASS (0fail,0skipped)Signed-off-byincluded on single commitf52390220.