Converge run persistence on SQLite through the Store port (Q1 WP5) #26

Merged
weichen merged 1 commits from feature/agent-stack-q1 into main 2026-10-07 10:31:16 +00:00
Owner

Q1 增量四(收官):SQLite 收编为 Store 实现、双真相源合一、X6(WP5)

按 Documents 提案 2026-10-07-agent-stack-n1q1i1-plans.md §3.2 落地 Q1 的 WP5。至此 Q1 七个工作包全部落地。

改动

  • 端口可实现性修正:runState/hitlGate 导出为 RunState/HitlGate(WP4 埋的缺陷——外部包无法实现带未导出类型的端口)。机械重命名,套件证实行为中性。
  • SQLiteStore(adapters/sqlite/runstore.go):squad.Store 的 SQLite 实现——squad_run_state/gate/checkpoint/leader 四表与平台既有 23 表同库;Options.Store 接线进 engineDeps;leader 持久化与 superstep 检查点也改道端口(此前检查点写死 FileStore)。PrepareWorkspace 不再直写 run 级 JSON(由 st.save() 经端口统一落盘,否则 SQLite 后端会漏一份到文件)。
  • X6:platform.RunInProcess 签名 stream llm.StreamFunc → exec squad.Executor——执行走小队 Executor 端口(nil 即 fail-closed),不再绕过端口直驱 agent-native runtime;cli 冒烟与测试调用方改经脚本执行器注入。过程中抓到并修掉一个真实陷阱:脚本执行器必须逐调用返回拷贝(共享指针会跨步骤串味,已有注释)。
  • 单库挂载:serve 的 assemble 先开 orchestration.db、引擎直接用 plat.RunStore() 并复用同一连接挂平台——运行状态与编排状态同一个 SQLite 文件(验收第三条)。

验证

  • 五个模块 vet/test 全 ok,含:
    • TestSQLiteStoreRoundTrip(run/gate/checkpoint/leader 全链路 + 缺失语义与文件态一致);
    • TestEngineRunsOnSQLiteStore(验收第三条实证):引擎注入 SQLiteStore 跑通蓝图,run 级 JSON 不落盘、状态经端口读回、检查点入库、第二引擎同库 Inspect 可用;
    • squad 全套件(engine/leader/recovery/r2/intent/evaluator/graph/attempt/checkpoint)原样全绿。

Q1 验收三条终态

  1. 「superstep 边界杀进程副作用次数=1」:增量二(attempt id + 产物校验)实证测试在案;
  2. 「写同一工件的步骤不并行」:增量一(写集字段+调度串行化)图层断言在案;
  3. 「文件 run 与 SQLite 不再双记步骤状态」:本增量实证测试在案。

主任务:Dev 仓 feature/agent-stack-q1。

# Q1 增量四(收官):SQLite 收编为 Store 实现、双真相源合一、X6(WP5) 按 Documents 提案 `2026-10-07-agent-stack-n1q1i1-plans.md` §3.2 落地 Q1 的 WP5。至此 Q1 七个工作包全部落地。 ## 改动 - **端口可实现性修正**:`runState`/`hitlGate` 导出为 `RunState`/`HitlGate`(WP4 埋的缺陷——外部包无法实现带未导出类型的端口)。机械重命名,套件证实行为中性。 - **`SQLiteStore`(adapters/sqlite/runstore.go)**:squad.Store 的 SQLite 实现——`squad_run_state/gate/checkpoint/leader` 四表与平台既有 23 表同库;`Options.Store` 接线进 engineDeps;leader 持久化与 superstep 检查点也改道端口(此前检查点写死 FileStore)。`PrepareWorkspace` 不再直写 run 级 JSON(由 st.save() 经端口统一落盘,否则 SQLite 后端会漏一份到文件)。 - **X6**:`platform.RunInProcess` 签名 `stream llm.StreamFunc` → `exec squad.Executor`——执行走小队 Executor 端口(nil 即 fail-closed),不再绕过端口直驱 agent-native runtime;cli 冒烟与测试调用方改经脚本执行器注入。过程中抓到并修掉一个真实陷阱:脚本执行器必须逐调用返回拷贝(共享指针会跨步骤串味,已有注释)。 - **单库挂载**:serve 的 assemble 先开 `orchestration.db`、引擎直接用 `plat.RunStore()` 并复用同一连接挂平台——**运行状态与编排状态同一个 SQLite 文件**(验收第三条)。 ## 验证 - 五个模块 vet/test 全 ok,含: - `TestSQLiteStoreRoundTrip`(run/gate/checkpoint/leader 全链路 + 缺失语义与文件态一致); - **`TestEngineRunsOnSQLiteStore`(验收第三条实证)**:引擎注入 SQLiteStore 跑通蓝图,run 级 JSON 不落盘、状态经端口读回、检查点入库、第二引擎同库 Inspect 可用; - squad 全套件(engine/leader/recovery/r2/intent/evaluator/graph/attempt/checkpoint)原样全绿。 ## Q1 验收三条终态 1. 「superstep 边界杀进程副作用次数=1」:增量二(attempt id + 产物校验)实证测试在案; 2. 「写同一工件的步骤不并行」:增量一(写集字段+调度串行化)图层断言在案; 3. 「文件 run 与 SQLite 不再双记步骤状态」:本增量实证测试在案。 主任务:Dev 仓 `feature/agent-stack-q1`。
weichen added 1 commit 2026-10-07 10:30:16 +00:00
Converge run persistence on SQLite through the Store port
ci / vet-and-test (pull_request) Successful in 23s
ci / docker-checkout-hostgateway (pull_request) Successful in 1s
90ac98ea65
Why: Q1 WP5 - platform's SQLite becomes an implementation of the
squad Store port so run state and orchestration state live in one
database, and platform's in-process execution goes through the
Executor port instead of bypassing it (X6).

Evidence: all five modules go vet clean and go test ok, including
engine-on-SQLite (state in DB, no run-level JSON files, second
engine recovers from the same DB), SQLiteStore round trip, and the
full squad compatibility net.

Impact: runState/hitlGate exported so the port is implementable;
Options.Store wires into engineDeps; leader persistence and
checkpoints route through the port; PrepareWorkspace no longer
writes run-level JSON (st.save owns it); platform RunInProcess
takes squad.Executor (callers updated); serve mounts the engine on
platform's RunStore - single orchestration.db for both.

Refs: Documents proposal 2026-10-07-agent-stack-n1q1i1-plans.md Q1 WP5
weichen merged commit eba77e782f into main 2026-10-07 10:31:16 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: weichen/Agent-Squad#26