Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/architecture/rfcs/loopx-overall-roadmap-v0.md
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,19 @@ the best valid artifact and test continuation against a credible alternative.
A flat interval alone is not a stop rule; this signal neither extends a budget
nor establishes a causal advantage. The research RFC owns that comparison.

#### Authority-to-context efficiency tracks: agent impact versus storage engineering

Audits of long-lived, multi-outcome local Goals show two distinct bottlenecks in how durable authority state (`head.projection`, checkpoints, and per-commit deltas) maps into per-Turn context projections (`loopx_turn_envelope_v1`, `context_delivery`, and progressive readers). To focus delivery on net model effectiveness and efficiency without delaying core improvements behind schema rewrites, work separates into two prioritized tracks (these record bounded single-host observations and implementation ordering, not fleet qualification or changed defaults):

- **Track A (Priority) — Agent efficiency and effectiveness optimizations:** changes that directly reduce per-Turn prompt bloat, startup read round-trips, duplicate-context cognitive noise, and prefix KV-cache invalidation:
1. *Intra-envelope duplicate elimination beyond whole-contract equality:* **`#9328` shipped** `outcome_requirements_ref` sharing across acceptance carriers (`work_context`, `agent_todo_summary`, and `planning_horizon`) even when enclosing `goal_objective` summaries differ (preserving exact source hashes and CLI/replan readback). Separately, the existing ordinary quota CLI display projection emits `blocked_priority_fallback_ref = "$.blocked_priority_fallback"` when `heartbeat_recommendation.blocked_priority_fallback` matches the root diagnostic, whereas raw complete Turn decisions (`loopx_turn_envelope_v1`), saved captures, and `--include-detail agent-todos` intentionally retain both inline fallback diagnostics (any remaining duplicates in other decision carriers stay scoped behind the same source-identity rules).
2. *Startup CLI round-trip compression:* **shipped for bounded normal-run CLI openings (`#9253`)**, which inline `work_opening` / `before_work` when the full response fits within `MAX_INLINE_WORK_RESPONSE_BYTES` and page output limits while retaining digest-bound `first_read_command` / `recovery` fallbacks; remaining work covers over-budget openings and any other admission entrypoints that still trigger multi-hop `should-run -> context-read --initial-read -> context-read --select` ceremony without relaxing required reads or authority invariants.
3. *KV-cache-preserving monotonic framing (`KeepRaw` / `FoldToReceipt` / `EpochReset`):* keep intra-epoch prefixes append-only and compact dynamic tail noise instead of rewriting earlier spans mid-trajectory ([History working sets](history-working-set-context-policy-v0.md#51-one-projection-owner)).
- **Track B (Deferred engineering track) — Pure storage and capture-transport engineering:** changes that lower local disk footprint, serialization CPU, and write amplification without altering model-facing prompts; sequence behind Track A or on capacity triggers:
1. *Subtree-hashed / entity-normalized authority snapshots:* evolve monolithic `head.projection` and periodic `checkpoints` JSON blobs (`sqlite_authority_store.ts`, `authority_state_log.ts`) toward entity-level/subtree hashes and bounded checkpoint retention.
2. *Entity-ID keyed deltas for wide-span array edits:* `arraySpliceOperations` already trims shared prefix and suffix so a single head or middle insertion records only that entry, whereas wide-span reorders (such as moving a tail item to the head) or multi-point edits spanning long ranges re-emit the spanned interior slice; entity-ID keyed patches target those wide-span commit deltas without changing replay proofs.
3. *Capture-directory deduplication and retention GC:* avoid storing duplicate `decision.json` and identical `delivery.json` copies per Turn and bound retention of completed historical captures in local context-delivery storage.

### Important Areas Outside RFCs and Their Owning Sources

These directly determine whether a long-running team is usable. A directory or README provides an implementation/contract entry, not installed readiness; read availability from `loopx capability list/show` and the selected release.
Expand Down
13 changes: 13 additions & 0 deletions docs/architecture/rfcs/loopx-overall-roadmap-v0.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,19 @@ RFC。然后比较验收成果和完整成本。晚期已验证提升是仍有
保留最高有效产物,对照可信替代方案研究接续。单独一段平台期不是停止规则;该信号
不延长预算,也不证明因果优势。具体比较由研究 RFC 拥有。

#### 从 Authority 到上下文的效率分化:Agent 效能优化与纯存储工程优化

对长周期、多 Outcome 的本地 Goal 的结构审计表明,从持久权威状态(`head.projection`、checkpoint 与 commit delta)到单轮上下文投影(`loopx_turn_envelope_v1`、`context_delivery` 及渐进读取器)的映射存在两类性质不同的瓶颈。为优先压缩直接影响模型推理与执行成本的开销、避免阻塞在底层存储重构上,优化拆分为两条优先级明确的路径(以下仅记录单机有界观测与交付排序,不代表百 Agent 规模通过或修改默认行为):

- **Track A(优先)— 直接面向 Agent 效率与效果的优化:** 直接削减每轮输入冗余、启动读取往返次数、重复上下文干扰与 Prefix KV-Cache 失效的操作:
1. *包内细粒度去重(超越整包相等匹配):* **`#9328` 已落地** 当 `goal_objective` 等外层摘要不同但内部 `outcome_requirements` 完全相同时,通过 `outcome_requirements_ref` 在 `work_context`、`agent_todo_summary` 与 `planning_horizon` 间共享同一份完整要求列表(保留原 source hash 与 CLI/replan 读回)。另一方面,既有的普通 quota CLI 展示投影会在 `heartbeat_recommendation.blocked_priority_fallback` 与根诊断完全一致时输出 `blocked_priority_fallback_ref = "$.blocked_priority_fallback"`,而原始完整 Turn 决策(`loopx_turn_envelope_v1`)、保存的 capture 与 `--include-detail agent-todos` 仍完整保留两份内联 fallback 诊断(其余决策载体中尚未覆盖的重复切片沿同源身份规则按需收敛)。
2. *压缩启动 CLI 往返税:* **有界 `normal_run` CLI 开场已通过 `#9253` 落地**——在满足 `MAX_INLINE_WORK_RESPONSE_BYTES` 与输出上限时直接内联 `work_opening` / `before_work` 并保留绑定摘要的 `first_read_command` / `recovery`;后续仅针对超预算情形及其他仍需多跳 `should-run -> context-read --initial-read -> context-read --select` 的准入入口,不弱化必读约束与权限边界。
3. *KV-Cache 友好的单调前缀(`KeepRaw` / `FoldToReceipt` / `EpochReset`):* 同一 epoch 内严格保持前缀追加稳定、仅压缩动态尾部,避免轨迹中途重写已发前缀(见[可回读历史工作集 RFC](history-working-set-context-policy-v0.zh-CN.md#51-单一投影-owner))。
- **Track B(延后工程项)— 纯存储与本地传输工程优化:** 改善本地磁盘占用、序列化 CPU 与写放大,但不直接改变模型可见决策质量的工作;排在 Track A 之后或由容量阈值触发:
1. *实体归一化/子树哈希化权威快照:* 将单体大 JSON 投影(`head.projection` 与周期性 `checkpoints`)逐步演进为按实体/子树哈希索引及有界保留策略。
2. *面向大跨度数组修改的按实体 ID 索引 delta:* 现行 `arraySpliceOperations` 已会裁剪共享前缀与共享后缀,因此队首或中间单条插入只记录单个新增项;真正产生放大的是把尾部移至队首等大跨度重排或跨长区间的多点修改(会重放中间区间内所有历史条目),实体 ID 补丁用于收敛此类大跨度 commit delta 并保持回放 proof 不变。
3. *捕获文件去重与保留 GC:* 消除单轮内 `decision.json` 与完全相同的 `delivery.json` 的双份落盘,并为本地 `context-delivery` 历史目录增加有界清理机制。

### RFC 之外的关键覆盖与 owning sources

[执行、探索与纠偏集成指南](../long-running-execution-exploration-and-correction.zh-CN.md)
Expand Down
23 changes: 23 additions & 0 deletions docs/reference/protocols/turn-envelope-v0.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,29 @@ CLI from becoming another reader of the legacy guidance field.
事实仍在当前包内,不需再次执行 guard。不同副本和既有详细视图保留;原始决定与
capture 不变。动作维度等价不意味着不同渲染可以共用原始 source hash。

#### Agent-efficiency vs. storage-engineering boundary

Consistent with the overall roadmap's Track A/Track B prioritization, runtime work on
`loopx_turn_envelope_v1` and `progressive_context` prioritizes direct **Agent-facing
efficiency and effectiveness wins (Track A)** ahead of SQLite/capture storage refactors
(Track B):

- Shipped intra-envelope sharing (`#9328`): `outcome_requirements_ref` across differing
outer `goal_objective` carriers alongside exact source-identity readbacks. Separately,
per the ordinary quota CLI rule above, the existing ordinary CLI display projection can
emit `blocked_priority_fallback_ref` when `heartbeat_recommendation.blocked_priority_fallback`
matches the root diagnostic, while raw complete Turn decisions (`compose_complete` /
`loopx_turn_envelope_v1`), saved captures, and `--include-detail agent-todos` retain
both inline fallback diagnostics.
- Shipped bounded normal-run CLI inline openings (`#9253`): inlines verified
`work_opening` and `before_work` facts within output budgets while retaining
digest-bound cold-path `first_read_command` / `recovery` fallbacks; remaining work
targets over-budget openings and other admission entrypoints beyond that CLI route.
- Remaining Track A work: preserving intra-epoch prefix KV-cache stability (`KeepRaw` /
`FoldToReceipt` / `EpochReset`) over mid-trajectory prefix mutations.

中文:遵循总路线图 Track A/Track B 分层原则,`loopx_turn_envelope_v1` 与 `progressive_context` 优先推进直接改善 **Agent 效率与效果(Track A)** 的优化,而非先重构 SQLite 或 capture 存储(Track B):其中 `#9328` 已落地 `goal_objective` 不同时仍共享同内容 `outcome_requirements_ref` 及精确源身份读回(既有普通 quota CLI 展示投影按上文规则在等值时输出 `blocked_priority_fallback_ref`,而 `compose_complete` / `loopx_turn_envelope_v1` 原始完整决策、保存 capture 与 `--include-detail agent-todos` 仍保留两份内联 fallback 诊断),且 `#9253` 已落地有界普通 CLI 轮次内联 `work_opening` / `before_work` 并保留摘要绑定回退读取;剩余推进聚焦超预算情形与其余准入入口的启动压缩,以及 epoch 内前缀 KV-Cache 单调稳定(`KeepRaw` / `FoldToReceipt` / `EpochReset`)。

### Captured replan reads / 捕获后的重规划读取

For a successful replan with `--decision-output-dir` or `--decision-output-root`,
Expand Down
21 changes: 21 additions & 0 deletions docs/reference/sqlite-authority-store.md
Original file line number Diff line number Diff line change
Expand Up @@ -797,3 +797,24 @@ commit digest、provider revision、receipt、event 或 scan 页面字节。迁
标识与摘要无法证明新的状态日志可读。v1 能接受的 JSON key(包括空字符串和
`__proto__`)在 v2 中保持同样的数据语义,迁移不会把原本可读的库变成读不出来的
状态。

## Observed long-lived growth and pure-engineering follow-ups

Long-lived, multi-outcome local Goals accumulate three distinct storage-layer overheads
that remain pure engineering optimizations (Track B in the overall roadmap, separate
from per-Turn model context optimizations in Track A):

1. **Monolithic projection snapshots (`head.projection` and periodic `checkpoints`):**
each checkpoint window stores a complete canonical projection JSON blob rather than
content-addressed subtrees or normalized entity rows, multiplying database footprint
as open/done Todos and Outcomes accumulate.
2. **Wide-span positional array splices in `commits.delta`:** `authority_state_log`'s
`arraySpliceOperations` already strips shared prefix and suffix bytes, so a single
insertion at the head or middle records only 1 inserted item. Wide-span reorders (e.g.,
moving a tail item to the head) or multi-point edits spanning long ranges still span
and re-emit the intervening slice, motivating future entity-ID keyed patches.
3. **Retained capture duplication and compaction:** historical receipts/events and paired
context-delivery captures grow linearly until explicit archiving or retention bounds
are added.

中文:长期运行的多 Outcome 本地 Goal 在存储层主要存在三类纯工程增长瓶颈(对应总路线图 Track B,优先级低于直接服务模型推理/开销的 Track A):(1)`head.projection` 与周期 `checkpoints` 整树大 JSON 持久化造成的库体积放大;(2)`commits.delta` 中的 `arraySpliceOperations` 已裁剪共享前后缀,队首或中间单条插入仅记录单条变化,但跨长区间的重排(如末项移至队首)或多点编辑仍会放大中间区间体积,适合后续演进为按实体 ID 差分;(3)历史回执与 `context-delivery` 重复快照尚缺自动去重与有界清理。这些改造不改变现有 `user_version=2` 逻辑语义与读回 proof。