Add svc.sh agent data-dir snapshots with SQLite-consistent backup #417

Merged
weichen merged 30 commits from feature/svc-agent-backup into main 2026-10-12 04:34:28 +00:00
Owner

任务卡:.task/feature-svc-agent-backup.md(同一份文档;证据收据见卡内)

Why:2026-10-11 runtime/ 整删事故中 agent SQLite 数据全失且无任何备份;svc-autorecover 收尾报告遗留建议第 1 条(用户 2026-10-12 指示「把遗留项按建议修复」)。对应恢复方案(documents r2)U2 残留「agent SQLite 自动备份缺位」的实用切片。

What

  • svc.sh <name> backup [--out DIR] [--keep N]:svc.env + history.jsonl + data/ 快照;每个 *.db 经 sqlite3 .backup 一致性导出(活跃 WAL 写入者下安全)+ integrity_check 自检;-wal/-shm 不入快照;无 sqlite3 拒绝备份(不回退裸拷贝)
  • 快照根 runtime-backups/<name>/<UTC时间戳>/(runtime/ 之外——runtime 整删不波及);MANIFEST 记逐文件 sha256;非 SQLite 的 *.db 原样保留并告警
  • svc.sh <name> backups [--prune] [--keep N] 列表/保留清理(默认 7 份,只清时间戳目录,不动 --out 自定义目录);rm --purge 连带删除;postgres/static 守卫引导
  • 帮助/文档/保留字/.gitignore 同步更新

Evidence:tests/test_svc_backup.py 11/11(活跃 WAL 写入者、manifest sha 校验、保留策略、purge、守卫、PATH 无 sqlite3 拒绝);make test-governance 159/159 绿(SELF,同步后 HEAD 22e7d75 重跑);CI(GATE)以本 PR 运行为准。首跑治理套件曾出现 1 例未复现失败(两遍重跑均绿,已如实记录在卡)。

Impact:新增服务级动作 backup/backups 与新顶层目录 runtime-backups/(gitignore);不动既有 pg backup、deploy、recover 流程。

Non-goals:restore/灾难恢复合同(方案 U6)、自动定时备份(频率待按批准 RPO 固定)。

Refs:modules/documents/docs/proposals/2026-10-12-service-restart-data-recovery.md r2 §6/U2;前序 svc-autorecover PR #396/#400/#401。

任务卡:`.task/feature-svc-agent-backup.md`(同一份文档;证据收据见卡内) **Why**:2026-10-11 `runtime/` 整删事故中 agent SQLite 数据全失且无任何备份;svc-autorecover 收尾报告遗留建议第 1 条(用户 2026-10-12 指示「把遗留项按建议修复」)。对应恢复方案(documents r2)U2 残留「agent SQLite 自动备份缺位」的实用切片。 **What** - `svc.sh <name> backup [--out DIR] [--keep N]`:svc.env + history.jsonl + data/ 快照;每个 `*.db` 经 `sqlite3 .backup` 一致性导出(活跃 WAL 写入者下安全)+ `integrity_check` 自检;`-wal/-shm` 不入快照;无 sqlite3 拒绝备份(不回退裸拷贝) - 快照根 `runtime-backups/<name>/<UTC时间戳>/`(**runtime/ 之外**——runtime 整删不波及);MANIFEST 记逐文件 sha256;非 SQLite 的 `*.db` 原样保留并告警 - `svc.sh <name> backups [--prune] [--keep N]` 列表/保留清理(默认 7 份,只清时间戳目录,不动 `--out` 自定义目录);`rm --purge` 连带删除;postgres/static 守卫引导 - 帮助/文档/保留字/.gitignore 同步更新 **Evidence**:`tests/test_svc_backup.py` 11/11(活跃 WAL 写入者、manifest sha 校验、保留策略、purge、守卫、PATH 无 sqlite3 拒绝);`make test-governance` 159/159 绿(SELF,同步后 HEAD `22e7d75` 重跑);CI(GATE)以本 PR 运行为准。首跑治理套件曾出现 1 例未复现失败(两遍重跑均绿,已如实记录在卡)。 **Impact**:新增服务级动作 backup/backups 与新顶层目录 runtime-backups/(gitignore);不动既有 pg backup、deploy、recover 流程。 **Non-goals**:restore/灾难恢复合同(方案 U6)、自动定时备份(频率待按批准 RPO 固定)。 **Refs**:modules/documents/docs/proposals/2026-10-12-service-restart-data-recovery.md r2 §6/U2;前序 svc-autorecover PR #396/#400/#401。
weichen added 7 commits 2026-10-12 03:10:59 +00:00
Why: establish the authorized task workspace and its initial baseline.

Evidence: preserved precheck receipt in .task/feature-svc-agent-backup.md; R0=475654363de3ec72df68d246ffab8217b1cfeab6.

Impact: task metadata only; the feature workspace starts at 475654363d.

Refs: .task/feature-svc-agent-backup.md
Why: the 2026-10-11 runtime/ deletion lost all agent SQLite data with no
backup; the svc-autorecover closing report left "agent SQLite backup" as
a follow-up and the user asked to land it (recovery plan U2 residue).
Evidence: tests/test_svc_backup.py 11/11 green locally (live WAL writer,
manifest sha, retention, guards); make test-governance full suite green
(159 tests, rerun twice after one unreproduced flake).
Impact: new service-level actions backup/backups; snapshots live in
runtime-backups/<name>/ outside runtime/; rm --purge removes them; pg
backup and other flows unchanged.
Refs: modules/documents/docs/proposals/2026-10-12-service-restart-data-recovery.md r2 (sec 6, U2 residue); task card .task/feature-svc-agent-backup.md.
Why: include the current integration baseline before verification.

Evidence: fetched origin/main=3fa0d3ade8beb6b534c7ffa7505426001c58e284.

Impact: integrate upstream changes without rewriting task history.

Refs: task-sync
Why: bind the task validation checkpoint to the latest integration baseline.

Evidence: SELF recursive component checks; sync_base=3fa0d3ade8beb6b534c7ffa7505426001c58e284; candidate=20cffd7ad21e98b41a8be7cfd28ccf20f9a65691.

Impact: task metadata only.

Refs: .task/feature-svc-agent-backup.md
Record post-sync test-governance evidence in the task card
ci / test-pg (pull_request) Successful in 1m22s
ci / test (pull_request) Successful in 3m39s
3395e05c2d
weichen added 1 commit 2026-10-12 03:11:34 +00:00
Fill the task record PR link and stage conclusions (#417)
ci / test-pg (pull_request) Successful in 1m23s
ci / test (pull_request) Successful in 3m32s
6f4f2eeff6
weichen added 1 commit 2026-10-12 03:11:55 +00:00
Record outcomes and next-step recommendations in the task card
ci / test (pull_request) Successful in 3m40s
ci / test-pg (pull_request) Successful in 1m11s
b9e64f00ad
weichen added 3 commits 2026-10-12 03:21:14 +00:00
Why: include the current integration baseline before verification.

Evidence: fetched origin/main=37e3229538d64867a6a074020a072da925244fcc.

Impact: integrate upstream changes without rewriting task history.

Refs: task-sync
Why: bind the task validation checkpoint to the latest integration baseline.

Evidence: SELF recursive component checks; sync_base=37e3229538d64867a6a074020a072da925244fcc; candidate=b3a473af3f3f7dee7806312cca436a8f87ca9385.

Impact: task metadata only.

Refs: .task/feature-svc-agent-backup.md
Record sync and post-sync test evidence in the task card
ci / test-pg (pull_request) Successful in 2m10s
ci / test (pull_request) Successful in 2m48s
dd1e73a31d
weichen added 2 commits 2026-10-12 03:30:28 +00:00
Why: include the current integration baseline before verification.

Evidence: fetched origin/main=af9c2de663be5ff102dcab7698464a645832f569.

Impact: integrate upstream changes without rewriting task history.

Refs: task-sync
Record the sync checkpoint
ci / test-pg (pull_request) Successful in 1m14s
ci / test (pull_request) Successful in 3m45s
42ecfe1312
Why: bind the task validation checkpoint to the latest integration baseline.

Evidence: SELF recursive component checks; sync_base=af9c2de663be5ff102dcab7698464a645832f569; candidate=67da726e7f6c6dd14e4646997b0a1b22141201a6.

Impact: task metadata only.

Refs: .task/feature-svc-agent-backup.md
weichen added 1 commit 2026-10-12 03:31:51 +00:00
Record post-sync governance test evidence
ci / test-pg (pull_request) Successful in 1m45s
ci / test (pull_request) Successful in 3m48s
e80ae62e90
weichen added 1 commit 2026-10-12 03:36:56 +00:00
Record green rerun and flake analysis in the task card
ci / test-pg (pull_request) Successful in 1m41s
ci / test (pull_request) Successful in 3m53s
f86ae58c96
weichen added 2 commits 2026-10-12 03:42:22 +00:00
Why: include the current integration baseline before verification.

Evidence: fetched origin/main=b6307db015da4a3718baadb242c52cb66b024f74.

Impact: integrate upstream changes without rewriting task history.

Refs: task-sync
Record the sync checkpoint
ci / test-pg (pull_request) Successful in 1m11s
ci / test (pull_request) Failing after 2m41s
5fb381dde9
Why: bind the task validation checkpoint to the latest integration baseline.

Evidence: SELF recursive component checks; sync_base=b6307db015da4a3718baadb242c52cb66b024f74; candidate=a9a456efc2fd3bc6630cc65f089c0c6fad58f69b.

Impact: task metadata only.

Refs: .task/feature-svc-agent-backup.md
weichen added 1 commit 2026-10-12 03:43:47 +00:00
Record post-sync governance test evidence
ci / test-pg (pull_request) Successful in 1m22s
ci / test (pull_request) Successful in 4m10s
441656c753
weichen added 2 commits 2026-10-12 03:49:35 +00:00
Why: include the current integration baseline before verification.

Evidence: fetched origin/main=3e4a79e4133202b537c888a8beeb7c10d82595f4.

Impact: integrate upstream changes without rewriting task history.

Refs: task-sync
Record the sync checkpoint
ci / test-pg (pull_request) Successful in 1m49s
ci / test (pull_request) Successful in 3m5s
8e6f2137d1
Why: bind the task validation checkpoint to the latest integration baseline.

Evidence: SELF recursive component checks; sync_base=3e4a79e4133202b537c888a8beeb7c10d82595f4; candidate=8abebff33f0c64be631259e3e60118fdf5d282e6.

Impact: task metadata only.

Refs: .task/feature-svc-agent-backup.md
weichen added 1 commit 2026-10-12 03:51:03 +00:00
Record post-sync governance test evidence
ci / test-pg (pull_request) Successful in 2m43s
ci / test (pull_request) Successful in 5m15s
69086622b6
weichen added 2 commits 2026-10-12 04:04:06 +00:00
Why: include the current integration baseline before verification.

Evidence: fetched origin/main=5942ba7a949f3032cacf75856529726a7c24fa8e.

Impact: integrate upstream changes without rewriting task history.

Refs: task-sync
Record the sync checkpoint
ci / test (pull_request) Successful in 3m9s
ci / test-pg (pull_request) Successful in 1m32s
1c832d8d6c
Why: bind the task validation checkpoint to the latest integration baseline.

Evidence: SELF recursive component checks; sync_base=5942ba7a949f3032cacf75856529726a7c24fa8e; candidate=52ae58dedf75528dff88f4f8b7f7267d293694e9.

Impact: task metadata only.

Refs: .task/feature-svc-agent-backup.md
weichen added 2 commits 2026-10-12 04:21:04 +00:00
Why: include the current integration baseline before verification.

Evidence: fetched origin/main=b4649d79c2bdd66c3bcb9e60752abdb99b5667df.

Impact: integrate upstream changes without rewriting task history.

Refs: task-sync
Record the sync checkpoint
ci / test-pg (pull_request) Successful in 1m56s
ci / test (pull_request) Successful in 3m12s
c17ab82fe0
Why: bind the task validation checkpoint to the latest integration baseline.

Evidence: SELF recursive component checks; sync_base=b4649d79c2bdd66c3bcb9e60752abdb99b5667df; candidate=14d141832ce67acb7f626499aff4e06c31b7b404.

Impact: task metadata only.

Refs: .task/feature-svc-agent-backup.md
weichen added 2 commits 2026-10-12 04:25:15 +00:00
Why: include the current integration baseline before verification.

Evidence: fetched origin/main=ac4058a72f2496a7d5a0225c4fb4e3a7ac8ac012.

Impact: integrate upstream changes without rewriting task history.

Refs: task-sync
Record the sync checkpoint
ci / test (pull_request) Successful in 3m36s
ci / test-pg (pull_request) Successful in 1m33s
61b563cc32
Why: bind the task validation checkpoint to the latest integration baseline.

Evidence: SELF recursive component checks; sync_base=ac4058a72f2496a7d5a0225c4fb4e3a7ac8ac012; candidate=ff05ac9482813ff676f96c6dbdfb796019bcc544.

Impact: task metadata only.

Refs: .task/feature-svc-agent-backup.md
weichen added 2 commits 2026-10-12 04:31:29 +00:00
Why: include the current integration baseline before verification.

Evidence: fetched origin/main=e27810246f507c1e1c2ff6e9fb6282f6da90e0ec.

Impact: integrate upstream changes without rewriting task history.

Refs: task-sync
Record the sync checkpoint
ci / test-pg (pull_request) Successful in 1m34s
ci / test (pull_request) Successful in 2m54s
a24ba3034c
Why: bind the task validation checkpoint to the latest integration baseline.

Evidence: SELF recursive component checks; sync_base=e27810246f507c1e1c2ff6e9fb6282f6da90e0ec; candidate=4f0773e57af8310fbd9a177ac1a23c94061604ed.

Impact: task metadata only.

Refs: .task/feature-svc-agent-backup.md
weichen merged commit 51a310ecbf into main 2026-10-12 04:34:28 +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-System-Dev#417