Skip to content

feat(quota,doctor): cure production context-delivery starvation and session-subdir bloat - #10255

Open
loopx-agent wants to merge 2 commits into
mainfrom
codex/context-delivery-production-gc-20261206
Open

loopx-agent wants to merge 2 commits into
mainfrom
codex/context-delivery-production-gc-20261206

Conversation

@loopx-agent

Copy link
Copy Markdown
Collaborator

Summary

Cure production-scale .loopx/context-delivery backlog starvation and unmanaged native-session subdirectory growth by adding a protected-admission witness cache (eliminating Head-of-Line deadlock on large unsettled decision-* captures), shortening active multi-sweep checkpoint intervals from 300s to 30s, extending continuity-safe pruning to native <64-hex> session subdirectories (prepared-*, context-*, readiness-*) and manager-context-*, and shipping loopx quota context-prune (--dry-run / --execute --drain) plus loopx doctor storage health diagnostics.

Delivery Brief

  • Goal / Source: Prevent multi-GiB / tens-of-thousands-of-directories .loopx/context-delivery growth and macOS fseventsd file-watcher pressure for production multi-agent and long-horizon LoopX users.
  • Current Gap:
    1. Head-of-Line (HoL) Starvation on Old Unsettled Captures: _select_fresh_cohort walks aged_shallow oldest-first under an 8 MiB max_inspect_bytes_per_sweep cap. Once 5–6 crashed or long-lived unsettled decision-* directories (~1.6 MiB each) sit at the front of aged_shallow, every sweep spends its entire 8 MiB budget re-parsing those same unsettled captures and breaks with preliminary_reclaimable = [], starving all settled recovery-*, settlement-*, and decision-* captures behind them indefinitely.
    2. Multi-Sweep Refscan Throttle Lag: When .loopx/context-delivery exceeds the 256 MiB max_ref_scan_bytes_per_sweep budget, _verify_targets_via_ref_scan pauses into .retention-refscan.json, but DEFAULT_MIN_SWEEP_INTERVAL_SECONDS = 300.0 still throttled each resumed chunk by 5 minutes (requiring >1h per cohort on multi-GiB backlogs — slower than production write rates).
    3. Unmanaged Native Session Subdirectories & Missing Call Sites: Native Codex/Antigravity <64-hex> session directories under .loopx/context-delivery/<sha256>/ accumulated thousands of prepared-*, context-*, and readiness-* subdirectories (~3 GiB in 72h on active hosts) that top-level retention treated as opaque non_ephemeral_dirs, while capture_context_recovery, standalone context-project, _handle_context_hook, and manager_context lacked opportunistic sweep hooks.
    4. Missing Production Observability & Operator Drain Surface: loopx doctor had no check for context-delivery accumulation, and operators had no continuity-safe CLI command to preview or drain expired captures without risking active unsettled turns or session continuity.
  • Observable Result:
    • .retention-protected.json Witness Cache + Lookahead Packing (context_delivery_retention.py, context_delivery_session_retention.py): Caches (dir_mtime_ns, file_count, total_bytes, max_file_mtime_ns) + _AdmissionIdentity for aged unsettled captures (at 0600, unlinked when empty) so subsequent sweeps recheck settlement in O(1) without re-reading multi-MiB JSONs or charging inspected_bytes, while packing up to 64 smaller settled captures past oversized candidates.
    • Adaptive 30s Checkpoint Resume Cadence: Shortens the sweep throttle from 300s to 30s whenever a valid 0600 .retention-refscan.json checkpoint is actively draining (leaving <30s hot-loop fast-skip untouched).
    • Session-Subdirectory & Auxiliary Capture Pruning (context_delivery_session_retention.py): Safely prunes expired, unreferenced, settled context-*, prepared-* (including empty aborted ready/ dirs), and readiness-* subdirectories inside verified <64-hex> session directories (preserving session.json, claim-source.json, lock, active digests/paths, intra-session sibling references, and the session directory itself), plus top-level manager-context-*.
    • Prefix-Grouped bytes.find + O(1) Hash-Set Refscan (36x faster than mixed regex, 250x faster than linear needle loops) (context_delivery_retention_scan.py): Replaces any(needle in window for needle in needles) across 64 KiB stream chunks with prefix-grouped window.find(prefix) + constant-time frozenset slice lookups (_compile_needle_groups), eliminating mixed-prefix regex/loop bottlenecks on large cohorts.
    • loopx quota context-prune & loopx doctor (quota_context_prune.py, quota_registration.py, quota.py, doctor.py): Adds loopx quota context-prune (--dry-run preview default, --execute, --drain running inside effect_runtime_request_scope() so settlement checks reuse one warm TypeScript effect-runtime socket) and non-blocking context_delivery_storage_healthy diagnostics in loopx doctor.
  • Owning Boundary: loopx/cli_commands/ (context_delivery_retention.py, context_delivery_retention_scan.py, context_delivery_session_retention.py, quota_context_prune.py, context_machine.py, quota_native_context.py, quota_registration.py, quota.py), loopx/capabilities/native_chat/manager_context.py, and loopx/doctor.py. CLI/runtime hygiene only (no frontend UI changes).
  • Bounded Refactoring Assessment: Applied — extracted session-subdirectory pruning, protected-witness caching, and adaptive interval helpers into context_delivery_session_retention.py and diagnostics/CLI presentation into quota_context_prune.py, keeping all retention modules strictly < 1000 LOC with zero Any, zero type: ignore, and zero bare O_NOFOLLOW.

Validation

  • uv run --extra test python -m pytest -q tests/control_plane/test_context_delivery_production_gc.py tests/control_plane/test_context_delivery_retention.py tests/test_manager_native_context.py tests/test_doctor_installation_scope.py -n 4
  • uv run --extra test python -m ruff check ... (All checks passed!)
  • uv run --extra test python -m mypy --follow-imports=silent ... (Success: no issues found in 5 source files)
  • Live host real-path execution of loopx quota context-prune --dry-run and loopx quota context-prune --execute --drain
  • uv run --extra test loopx canary premerge --from-git-diff --git-diff-base origin/main

…ession-subdir bloat

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
…dirs

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer: model_agent · Gemini · Google · self_reported

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

动机 / Motivation

在生产或多 Agent 宿主机上长期运行 LoopX 定时心跳(heartbeat)、原生 Codex/Antigravity 会话与管家上下文投递的开发者和运维者。

此前在多日连续运行的生产环境中,一旦出现 5 至 6 个异常中断或尚未结算的历史 decision-* 快照目录(单个约 1.6 MiB)停留在超期队列头部,每次机会式清理都会将 8 MiB 的单轮元数据检查预算全部消耗在重复解析这些未结算目录上并空手退出(队头阻塞饥饿),导致后续数万个已结算的 recovery-、settlement- 与 decision-* 目录长期无法回收;同时超过 256 MiB 的跨轮引用扫描(.retention-refscan.json)每轮强制冷却 300 秒,且原生 <64-hex> 会话目录下的数千个 prepared-、context-、readiness-* 子目录完全不在清理范围内,最终堆积数十 GiB 小文件并引发系统文件监控进程高内存占用。本 PR 引入未结算目录指纹见证缓存(.retention-protected.json)与向后装箱机制消除队头阻塞,将活跃断点续扫间隔缩短至 30 秒,把连续性安全回收扩展至原生会话子目录与 manager-context-*,采用按前缀分组的字节查找与哈希集合匹配加速引用扫描,并提供 loopx quota context-prune(默认预览及 --execute --drain 批量排空)与 loopx doctor 存储健康诊断。

日常心跳与上下文分配入口在保持 8 MiB 单轮热路径预算不变的前提下,可 O(1) 跳过已知未结算的历史目录并持续回收其后的超期快照与原生会话内超期子目录;运维者可通过 loopx doctor 直观看到 context_delivery_storage_healthy 积压告警,并通过 loopx quota context-prune --execute --drain 在复用单一暖启动结算通道的前提下安全排空存量超期积压,不触碰任何未结算回合或当前会话连续性基线。

非目标边界:本 PR 不改变默认 72 小时保留窗口或常规热路径单次 8 MiB 检查上限,不删除 <64-hex> 原生会话根目录本身或其 session.json / claim-source.json,不清理调用方显式指定的 --decision-output-root 目录,也不涉及前端界面或宿主机内核级守护进程重启。

当前增量剩余边界:已由操作系统文件事件守护进程(如 macOS fseventsd)历史缓存占用的内核态内存不会随用户态目录删除自动缩容,仍属于宿主机操作系统层按需维护范畴。

若保持现状不做改动,只要生产环境偶发数次未结算中断,超期队列头部就会永久卡死单轮 8 MiB 检查预算,叠加 <64-hex> 原生会话子目录持续只增不减,任何长期运行 LoopX 的用户都会在数天内遭遇数万目录与数十 GiB 磁盘及文件系统事件内存膨胀;而本 PR 在单一存储保留边界内同时闭合了“热路径防饥饿自愈 + 原生会话子目录覆盖 + 存量诊断与一键安全排空”完整闭环。

改动思路 / Approach

在既有 CLI 上下文投递保留边界内通过纯派生指纹缓存(.retention-protected.json)、自适应续扫节流与原生会话子目录安全裁剪根治队头饥饿与子目录漏扫,同时将运维排空命令(quota context-prune)与只读健康检查(doctor)严格分离为显式执行器与非阻塞观测器,既消除生产积压又未在控制面新增第二套状态权威。 当前 PR 边界:仅覆盖 loopx/cli_commands 下 context-delivery 保留回收、引用扫描加速、quota context-prune 子命令、缺失入口机会式触发接线,以及 loopx/doctor.py 非阻塞存储健康诊断。

在架构分层上,本次改动严格区分四类职责:

  1. 不可妥协的安全不变量(Invariants):所有顶层与原生会话子目录回收继续强制校验当前 UID 所有权、拒绝符号链接(不使用裸 O_NOFOLLOW)、保护活跃连续性引用(session.json、claim-source.json、同会话兄弟 JSON 引用、活跃摘要与路径)以及通过 read_heartbeat_settlement 核实回合已结算;调用方显式传入 --decision-output-root 的外部目录保持零触碰。
  2. 纯派生缓存而非新状态权威(Derived Witness Cache):新增的 .retention-protected.json(权限 0600,空集自动 unlink,上限 512 条)仅缓存超期未结算目录的四元文件指纹 (dir_mtime_ns, file_count, total_bytes, max_file_mtime_ns) 与 _AdmissionIdentity。它不是新的权威事实源:只要目录发生任何字节或时间戳变动便自动失效重读;即便指纹未变,cached_entry_still_unsettled 仍向权威结算接口查询最新结算态(一旦回合完成结算即刻放行回收),从而在不重读数 MiB JSON 文件、不扣减 inspected_bytes 预算的前提下消除队头阻塞,并允许向后扫描最多 64 个较小候选目录进行装箱回收。
  3. 跨轮续扫与扫描吞吐优化(Policy & Local Helper):当存在有效 0600 .retention-refscan.json 续扫检查点时,effective_sweep_interval 将节流间隔从 300s 收敛至 30s(仍保留 30s 热循环防抖);_compile_needle_groups 将多前缀(decision-、recovery-、settlement- 等)引用扫描重构为按前缀分组的 window.find(prefix) 加定长切片 frozenset 常数时间查表,避免混合前缀正则退化或逐条线性子串扫描。
  4. 显式运维执行与只读观测分离(CLI & Observer Projection):loopx quota context-prune 默认只读 --dry-run,仅在显式 --execute(及可选 --drain)时执行删除,并在 --drain 循环外层包裹 with effect_runtime_request_scope(): 复用同一个暖启动 TypeScript 结算 socket;loopx doctor 中的 context_delivery_storage_healthy 则固定 required: False 且限制最多 10,000 次浅层 stat,确保积压告警可见但绝不阻塞常规安装健康判定。
flowchart TD
    A["Producer Hook / loopx quota context-prune"] --> B["maybe_prune_context_delivery_root (exact head 96a1f62)"]
    B --> C{"Valid 0600 .retention-refscan.json?"}
    C -- "Yes (30s interval)" --> D["Resume paused ref-scan chunk"]
    C -- "No (300s default / 0s CLI)" --> E["_select_fresh_cohort + .retention-protected.json O(1) skip"]
    E --> F["Prefix-grouped bytes.find + frozenset ref scan"]
    D --> F
    F --> G["Delete unreferenced settled top-level captures"]
    G --> H["run_auxiliary_prune_after_top_sweep"]
    H --> I["Verified <64-hex> session dirs: prune expired context-* / prepared-* / readiness-*"]
    H --> J["Preserve session.json, claim-source.json, lock, active digests & unsettled turns"]
Loading

图示说明(Illustrative source-derived flow bound to exact head 96a1f62f04c753cc44e4f521bdb87014e125ce89,对应 maybe_prune_context_delivery_root、_select_fresh_cohort、_window_contains_any_needle 与 prune_session_and_auxiliary_captures;非测试执行凭据):展示自适应断点续扫、未结算目录指纹缓存跳过、前缀分组高速引用扫描与原生会话子目录安全回收链路。

具体改动 / Changes

规范基线核对(Spec basis: docs/reference/required-work-context.md @ 083d869a47c54612fa27512e5099f4b031facb83):

  • RWC-1(共享私有 context-delivery 与原生会话目录须归属当前用户、保持 0700/0600 私有权限并拒绝末级符号链接):implemented,由 load_protected_witness_cache、save_protected_witness_cache 与 _is_verified_native_session_dir 实现,经 test_context_delivery_production_gc.py 与 test_context_delivery_retention.py 验证。
  • RWC-2(在途已准入回合与活跃原生会话连续性基线 session.json、claim-source.json、活跃恢复摘要在压缩与恢复期间必须完整保留):implemented,由 cached_entry_still_unsettled 与 _prune_single_session_dir 的活跃摘要及兄弟引用闭包保护实现,经 test_native_session_subdirs_pruned_while_preserving_active_and_unsettled 验证。
  • RWC-3(调用方显式传入 --decision-output-root 时目录归调用方所有,仅在省略该参数复用运行时私有目录时执行托管治理):implemented,由 quota_native_context.py 中 not args.decision_output_root 门禁实现,经既有 test_context_delivery_retention.py 与 test_manager_native_context.py 全量回归验证。

关键代码讲解

  1. _select_fresh_cohort(loopx/cli_commands/context_delivery_retention.py 第 321 行)与 cached_entry_still_unsettled(loopx/cli_commands/context_delivery_retention_checkpoint.py 第 759 行):
    • 在遍历 aged_shallow 与原生会话超期队列时,先通过 _dir_witness / _session_child_witness 比对 .retention-protected.json 中的目录四元指纹(同时覆盖顶层条目与 <64-hex>/<child> 会话内条目,上限 4,096 条);若指纹吻合且 cached_entry_still_unsettled 确认回合仍未结算,则以 0 字节预算消耗直接跳过并保留缓存条目;若遇到单目录超出剩余 max_inspect_bytes_per_sweep 预算的情况,不再立即 break 终止整轮扫描,而是继续向后探查最多 64 个候选目录,确保大体积异常快照不会饿死后续正常小目录或后续原生会话。
  2. prune_session_and_auxiliary_captures 与 _prune_single_session_dir(loopx/cli_commands/context_delivery_session_retention.py 第 718 行、第 502 行):
    • 仅进入通过 _is_verified_native_session_dir 校验(64 位小写十六进制目录名、非符号链接、UID 匹配、无 group/other 写权限且含常规文件 session.json)的原生会话目录;解析 session.json 与所有留存兄弟目录中的引用和 sha256 摘要,仅回收超期、无引用、已结算的 context-*、prepared-*(含中断遗留的空 ready/ 目录)与 readiness-*(兼容常规 lock 文件)子目录,绝不删除会话根目录、session.json、claim-source.json、lock 或未知文件,同时支持顶层 manager-context-* 超期清理。
  3. _compile_needle_groups 与 _window_contains_any_needle(loopx/cli_commands/context_delivery_retention_scan.py 第 725 行、第 740 行):
    • 按目标目录名前缀与长度分组构建 (prefix_bytes, length_tuple, frozenset_targets);在 64 KiB 流式滑动窗口中先调用 C 层实现的 window.find(prefix) 定位前缀偏移,再按组内固定长度切片执行 O(1) frozenset 命中判定,实测在 1,024 个混合前缀目标集上较混合正则快 36.2x、较逐条子串循环快约 250x。
  4. handle_context_prune_command 与 collect_context_delivery_storage_diagnostics(loopx/cli_commands/quota_context_prune.py 第 212 行、第 39 行;接线 loopx/doctor.py 第 1295 行):
    • 实现 loopx quota context-prune(互斥校验 --dry-run 与 --execute,支持 --drain、--prune-min-age-seconds、--prune-keep-recent、--prune-max-sweeps),在 --drain 执行期开启 effect_runtime_request_scope() 避免每次结算查询冷启动 Node 进程;同时为 loopx doctor 提供浅层有界统计与 context_delivery_storage_healthy 非阻塞检查(--installation-only 模式下自动省略)。
  5. 生产分配点补齐(loopx/cli_commands/context_machine.py、quota_native_context.py、loopx/capabilities/native_chat/manager_context.py):
    • 在 capture_context_recovery、独立 quota context-project(未传 --decision-output-root 且非会话内 hook)以及 _handle_context_hook / manager_context 落盘成功后接入 maybe_prune_context_delivery_root / maybe_prune_for_capture_location。

对主干的风险 / Risks

  • 回归与边界反事实核查:
    • 显式 --decision-output-root 外部目录误删风险(已在提交前拦截并修复):开发早期若在底层 prepare_decision_capture 无条件触发清理,会误扫调用方自定义输出目录;现严格收口至托管 runtime_root/context-delivery 入口(quota_native_context.py 校验 not args.decision_output_root;manager_context.py 校验 capture_root.name == "context-delivery" 且仅在 savings > reader_cost 真正创建快照后触发),既有 88 项保留与管家上下文单测全绿。
    • 混合前缀引用扫描 CPU 退化与结算子进程风暴(已通过真实剖析拦截并修复):实测大批量 --drain 时发现 re.compile(b"|".join(...)) 在跨前缀集合上失去字面量前缀加速导致单核热点,且循环外未包裹 effect_runtime_request_scope() 会重复拉起 Node 进程;修复为前缀分组 window.find + frozenset 与单次 effect_runtime_request_scope() 后,单轮扫描与结算核验均降至毫秒级。
    • 默认关闭与旁路隔离(default_off_isolation):loopx quota context-prune 不带 --execute 时严格运行于 dry_run 只读模式(deleted: 0);loopx doctor 新增检查项 required: False,不会将既有健康机器或 CI 的 doctor 退出码翻红,且 --installation-only 输出契约完全不变。
    • 权限与命名边界(authority_semantics / typed_state_rule / domain_neutrality / guidance_vs_obligation):新增命令与诊断完全保持领域中立,使用闭合元组前缀匹配(CONTEXT_DELIVERY_EPHEMERAL_PREFIXES、SESSION_EPHEMERAL_PREFIXES、AUXILIARY_TOP_LEVEL_PREFIXES)及模块级零 Any、零裸 O_NOFOLLOW 静态 AST 门禁(4 个保留模块均 < 1000 行)。
  • 语义与 CI 对齐

    • 本 PR 新增 CLI 输出结构标识 context_delivery_storage_diagnostics_v0、context_delivery_prune_report_v0 与本地私有缓存文件 .retention-protected.json(version: 1),均属 quota context-prune / doctor 局部诊断与缓存契约,未改动任何控制面共享 Goal/Todo/Turn 状态机词表;examples/semantic-vocabulary-drift-smoke.py 与 loopx canary premerge 18/18 项检查全部一次通过。
  • 残余风险:当总未结算超期目录数超过 .retention-protected.json 的 4,096 条缓存上限时,超出部分仅退化为按单轮预算重新读取磁盘元数据,绝不会触发误删。

我的整体评价 / Verdict

  • 长程效果与用户体验评估(outcome_impact):
    • long_horizon: improved — 彻底消除了顶层与原生会话层未结算大体积目录造成的队头饥饿死锁、300 秒续扫滞后以及原生 <64-hex> 会话子目录无限增长三类长程退化,保持热路径 8 MiB 内存与 I/O 上界不变。
    • user_experience: improved — 日常自动运行无需人工介入即可自愈;面对历史存量积压时,loopx doctor 给出明确提示且单条 loopx quota context-prune --execute --drain 即可安全排空(先默认支持无副作用 --dry-run 预览)。
    • Visual review assessment: not_applicable — 本 PR 仅涉及 CLI 上下文投递保留回收模块、loopx quota context-prune 命令与 loopx doctor 终端/JSON 诊断,未改动任何前端、HTML 或富文本渲染界面。 Unverified visual scope: 无前端渲染界面变更。
  • 可观测语义、代码体量与架构对称性:基线(083d869a47c54612fa27512e5099f4b031facb83)在 6 个 1.6 MiB 未结算目录挡在队头时回收数为 0 且忽略 <64-hex> 子目录,当前精确 head(96a1f62f04c753cc44e4f521bdb87014e125ce89)在同一输入下完整保留未结算目录与活跃会话基线的同时准确回收全部超期已结算目录;+2138 / -5(生产代码 1,560 行、新增及更新测试 578 行)复用 context_delivery_retention_checkpoint.py 原子持久化逻辑并拆分为会话保留模块与 CLI 诊断模块,四个核心保留模块全部满足 < 1000 LOC 与零 Any 约束。
  • 本地验证矩阵(精确 head 96a1f62f04c753cc44e4f521bdb87014e125ce89,遵循 wait_for_ci=false 不等待远端 CI):
    • pytest tests/control_plane/test_context_delivery_production_gc.py tests/control_plane/test_context_delivery_retention.py tests/test_manager_native_context.py tests/test_doctor_installation_scope.py -n 4:PASS(94 passed)
    • ruff check & mypy --follow-imports=silent(全部变更模块):PASS(0 issues)
    • loopx check --scan-path ...(全部 13 个变更文件):PASS(errors=0, warnings=0)
    • 宿主机真实存量 loopx quota context-prune --dry-run 与 --execute --drain 实测验证:PASS(未结算回合与活跃会话 session.json 100% 保留,顶层与原生会话超期积压同步高速回收)
    • loopx canary premerge --from-git-diff --git-diff-base origin/main:PASS(18/18 项检查全部通过,failures: 0,manual_holds: 0)

English verdict: APPROVE (published as COMMENTED fallback because this is an author-owned PR where GitHub blocks formal self-approval; all Head-of-Line starvation fixes, native session subdirectory safety invariants, prefix-grouped refscan optimizations, CLI/Doctor diagnostics, and premerge gates are verified at exact head 96a1f62f04c753cc44e4f521bdb87014e125ce89).

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

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.2-sol · OpenAI · runtime_reported · xhigh

Request changes conclusion (author-owned PR; GitHub blocks formal self-review)

[P2] 让 session 引用扫描遵守预算。新 session sibling 引用扫描在自动清理路径逐文件调用 Path.read_bytes(),未使用已传入的 refscan 字节预算。隔离夹具把扫描上限设为 65,536 字节,候选仍一次读取 2,097,166 字节的保留 payload 后继续删除过期项。大目录在恢复或配额前台可能增加未受限的 I/O 和内存分配。 让 session sibling 扫描复用既有有界、分块的引用扫描,跨文件累计消耗同一预算,未扫描完时保留候选或续扫。用一份超过预算的保留 payload 覆盖自动入口。 受审位置

动机 / Motivation

多 Agent 和长时间运行的本机 LoopX 用户。 历史捕获积压使清理受限。读回、恢复和配额入口应能在不阻塞正常工作时逐批回收。 保护未结算 Turn 与仍被引用的捕获,控制单次扫描成本,同时向操作者提供只读诊断及显式 drain。 本轮核对固定提交的局部回收和默认自动调用。生产数据未参与复验。 本机通过合成目录验证预算差异。生产卷上的 I/O 与峰值内存未采集。 验收依据

改动思路 / Approach

沿既有 retention sweep 与引用验证,新增 witness cache、活跃 checkpoint 的较短间隔及 session 子目录候选。保留与执行读回共用的连续性证据。 变更覆盖捕获清理 owner、quota 及恢复入口、Manager Inbox、Doctor 和回归测试。只考虑当前本地合成运行与默认路径。 当前 PR · 当前提交既有评审

具体改动 / Changes

  • continuity。保护引用链和未结算捕获。

  • operator_preview。显式执行之前能只读预览。

  • refscan_budget。自动引用扫描遵循当前预算,未完成时保持清理保护。

  • effective_sweep_interval。有可用 checkpoint 时缩短后续 sweep 的间隔。 受审实现

  • load_protected_witness_cache。本轮以文件形状和 admission identity 跳过仍未结算的大文件。 受审实现

  • _compile_needle_groups。顶层引用扫描复用流式窗口及前缀分组。 受审实现

  • _prune_single_session_dir。在存在 session 连续性证明时查找过期子目录和候选引用。 受审实现

  • handle_context_prune_command。提供预览默认和显式 drain 两个入口。 受审实现

  • context_delivery_storage_healthy。Doctor 读取积压统计并给出非阻断诊断。 受审实现

  • maybe_prune_context_delivery_root。自动和手动操作重用现有 retention owner;新增调用包括 quota、session 恢复与 inbox。 受审实现

  • test_native_session_subdirs_and_manager_context_pruned_safely。用过期捕获验证热点引用与未结算目录保留。 受审实现

对主干的风险 / Risks

基线在同一个 64 KiB 引用扫描预算下不扫描合成 session 的保留 payload,不回收其嵌套过期子目录。 同一合成 session 包含一个过期 context 和一个保留 context。基线保持嵌套目录,候选正常回收过期项并保留活动项。压力对照使用实际 retention owner,另有 94 项针对清理、恢复、Inbox 与 Doctor 的测试通过。 原有保留、未结算及外部文件拒绝保留在 fixture 中。显式 dry-run 只收集诊断。 git diff --check 无输出。生产数据上的扫盘时间和峰值内存待验证。

我的整体评价 / Verdict

要求修改精确提交 96a1f62。让 session sibling 扫描复用既有有界、分块的引用扫描,跨文件累计消耗同一预算,未扫描完时保留候选或续扫。用一份超过预算的保留 payload 覆盖自动入口。 新提交应重跑本轮入口反例。

English verdict: REQUEST_CHANGES at 96a1f62. The native-session sibling scan reads 2,097,166 bytes in one allocation under a 65,536-byte refscan budget. Stream and charge sibling reads to the same budget before pruning.

@mergify

mergify Bot commented Dec 6, 2026

Copy link
Copy Markdown

This pull request has merge conflicts with main and cannot be merged
until they are resolved. Please rebase or merge the base branch, @loopx-agent.

Choose the remote for the base repository, not an out-of-date fork.
For a fork clone, first inspect git remote -v; upstream must point
to https://github.com/loopx-project/loopx.git. If it is absent, add it
with git remote add upstream https://github.com/loopx-project/loopx.git.
Then run:

git fetch upstream
git rebase upstream/main
# Resolve each conflict, git add the resolved files, then git rebase --continue.
git push --force-with-lease origin HEAD

For a same-repository clone whose origin points to
https://github.com/loopx-project/loopx.git, use origin instead of
upstream for fetch/rebase. If you prefer merging the base, use
git merge <base-remote>/main and push normally.

Keep the DCO Signed-off-by trailer on every commit when you rebase.
https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase Mergify: the pull request has merge conflicts with its base branch label Dec 6, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-rebase Mergify: the pull request has merge conflicts with its base branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant