Recover svc.sh database config across restarts and refuse on invalid binding #342

Merged
weichen merged 14 commits from feature/svc-db-config-recover into main 2026-10-11 10:53:44 +00:00
Owner

任务卡:.task/feature-svc-db-config-recover.md(本 PR 描述与任务卡为同一份记录;证据表见卡内)。

Why: 复用 exec= 分支的 G1-7 迁移把 --dsn 剥入进程环境后 record_state 写回不含 DSN 的 exec=,而 dbref 兜底只在重建分支——重新绑定后的第二次裸 restart 丢库(回环下静默回退 SQLite)。认证预检只看命令行 --dsn,env DSN + auth=auto 被误判为未开认证。

改动:svc.env 新增 db=/dbref=/dsn= 可恢复专键(0600 临时文件原子写入);start/restart/deploy/update/db 共用 resolve_db_config 统一解析(改端口/地址/版本不改变数据库选择,重建保留 conffile);绑定失效/直接 DSN 与 dbref 不同库/conffile 不一致/mock 共存/产物不消费 AGENT_SYSTEM_DSN 一律拒绝启动(移除"无法重建 DSN 按无绑定启动"降级);restart/deploy 在停止旧进程前完成静态预检;认证判定对齐后端 AuthEnabled;存量 exec= DSN 幂等迁移(命中实例升级托管绑定)。合并取舍:main 的 PR #317 最小修复被本方案取代,其 18 用例移植到新单元。

Evidence(SELF,CI 于 PR HEAD 复跑 make test+make build 为 GATE):bash -n;make test-governance 133 用例(test_svc.py 11 + 移植 test_svc_precheck.py 18;对修复前脚本 10/11 失败复现);make test 全绿;make build;隔离环境真实 PostgreSQL 18.6 + 真实产物 27/27(连续重启/部署保绑定、psql 直查库身份、库不可用拒启且配置可恢复、无凭据泄露)。详见任务卡证据表(HEAD=ea74479)。

Impact: scripts/svc.sh、tests/test_svc.py、tests/test_svc_precheck.py、docs/svc.md。行为变化:旧产物/mock 与绑定共存从静默降级改为拒绝;坏绑定从"无绑定启动"改为拒绝。dev 运行环境部署验收不在本 PR(另行授权)。

Refs: 用户 2026-10-11 方案消息;main 7acf318(PR #317,被取代);AGENTS.md 证据门禁。

任务卡:.task/feature-svc-db-config-recover.md(本 PR 描述与任务卡为同一份记录;证据表见卡内)。 Why: 复用 exec= 分支的 G1-7 迁移把 --dsn 剥入进程环境后 record_state 写回不含 DSN 的 exec=,而 dbref 兜底只在重建分支——重新绑定后的第二次裸 restart 丢库(回环下静默回退 SQLite)。认证预检只看命令行 --dsn,env DSN + auth=auto 被误判为未开认证。 改动:svc.env 新增 db=/dbref=/dsn= 可恢复专键(0600 临时文件原子写入);start/restart/deploy/update/db 共用 resolve_db_config 统一解析(改端口/地址/版本不改变数据库选择,重建保留 conffile);绑定失效/直接 DSN 与 dbref 不同库/conffile 不一致/mock 共存/产物不消费 AGENT_SYSTEM_DSN 一律拒绝启动(移除"无法重建 DSN 按无绑定启动"降级);restart/deploy 在停止旧进程前完成静态预检;认证判定对齐后端 AuthEnabled;存量 exec= DSN 幂等迁移(命中实例升级托管绑定)。合并取舍:main 的 PR #317 最小修复被本方案取代,其 18 用例移植到新单元。 Evidence(SELF,CI 于 PR HEAD 复跑 make test+make build 为 GATE):bash -n;make test-governance 133 用例(test_svc.py 11 + 移植 test_svc_precheck.py 18;对修复前脚本 10/11 失败复现);make test 全绿;make build;隔离环境真实 PostgreSQL 18.6 + 真实产物 27/27(连续重启/部署保绑定、psql 直查库身份、库不可用拒启且配置可恢复、无凭据泄露)。详见任务卡证据表(HEAD=ea74479)。 Impact: scripts/svc.sh、tests/test_svc.py、tests/test_svc_precheck.py、docs/svc.md。行为变化:旧产物/mock 与绑定共存从静默降级改为拒绝;坏绑定从"无绑定启动"改为拒绝。dev 运行环境部署验收不在本 PR(另行授权)。 Refs: 用户 2026-10-11 方案消息;main 7acf318(PR #317,被取代);AGENTS.md 证据门禁。
weichen added 6 commits 2026-10-11 09:28:34 +00:00
Why: establish the authorized task workspace and its initial baseline.

Evidence: preserved precheck receipt in .task/feature-svc-db-config-recover.md; R0=80a518628c526fd6ddece4abeb707ab4bb0b5618.

Impact: task metadata only; the feature workspace starts at 80a518628c.

Refs: .task/feature-svc-db-config-recover.md
Why: the exec= reuse path stripped --dsn into the process environment (G1-7)
and record_state then persisted a DSN-less exec=, while the dbref fallback only
existed in the explicit-rebuild branch - the second bare restart after a
rebind silently dropped the database (SQLite fallback on loopback). Auth
preflight also matched --dsn on the command line only, so env-delivered DSN
with auth=auto was misjudged as unauthenticated.
Evidence: bash -n OK; make test-governance 115 tests OK (new tests/test_svc.py
11 cases; 10/11 fail against the pre-fix script); make test green; make build
OK; isolated real PostgreSQL 18.6 + real binary validation 27/27 (consecutive
restarts/deploy keep binding, psql-verified database identity, DB-down restart
fails without SQLite fallback or config loss, no credential leakage) - all
recorded via make evidence in the task card.
Impact: svc.env gains db=/dbref=/dsn= recovery keys (atomic 0600 writes);
start/restart/deploy/update/db share one resolver; invalid bindings, config
conflicts, mock coexistence and env-DSN-incapable binaries now refuse to
start instead of silently downgrading; legacy exec= DSN migrates idempotently;
docs/svc.md and script help updated.
Refs: task card .task/feature-svc-db-config-recover.md; user-approved plan
(2026-10-11 session message); AGENTS.md evidence gates.
Why: main landed fix-svc-dsn-reuse-dbref (reuse-path dbref restore, env-DSN
aware precheck, DSN_ENV scoping) for the same restart-DSN incident; the
approved recovery plan is its superset and replaces those mechanisms with
resolve_db_config + recoverable svc.env keys + refuse-on-invalid semantics.
Evidence: tests/test_svc_precheck.py ported to the new units (18 cases green,
same scenario matrix; broken-dbref expectation updated to refusal per the
approved plan); tests/test_svc.py 11 cases green; bash -n OK.
Impact: conflict hunks resolved toward the unified resolver; main's source
guard at the script tail restored; agent_listen_rejected kept as a pure
predicate (used by the start precheck and the governance tests).
Refs: main 7acf318 (PR #317); task card .task/feature-svc-db-config-recover.md.
Why: include the current integration baseline before verification.

Evidence: fetched origin/main=36897a1009eb8d3ec63fac8974446bbd4c59bbc0.

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=36897a1009eb8d3ec63fac8974446bbd4c59bbc0; candidate=7ca39b0806e9fedd244ebc7b940c5413de3db76e.

Impact: task metadata only.

Refs: .task/feature-svc-db-config-recover.md
Record the merge supersession of PR #317 and refreshed evidence in the task card
ci / test (pull_request) Successful in 2m31s
ci / test-pg (pull_request) Successful in 56s
01a9e1bd4a
weichen added 1 commit 2026-10-11 09:28:44 +00:00
Fill the task record PR link (#342)
ci / test-pg (pull_request) Successful in 55s
ci / test (pull_request) Successful in 2m29s
5d07aedecc
weichen added 2 commits 2026-10-11 10:01:51 +00:00
Why: include the current integration baseline before verification.

Evidence: fetched origin/main=b1caa7cae13d35ec6e62c883d1f379aee35e35ef.

Impact: integrate upstream changes without rewriting task history.

Refs: task-sync
Record the sync checkpoint
ci / test-pg (pull_request) Successful in 55s
ci / test (pull_request) Successful in 2m29s
fbabdeb12b
Why: bind the task validation checkpoint to the latest integration baseline.

Evidence: SELF recursive component checks; sync_base=b1caa7cae13d35ec6e62c883d1f379aee35e35ef; candidate=4eb545cf6b75aebb7d2ee46da91088d1a393a4b7.

Impact: task metadata only.

Refs: .task/feature-svc-db-config-recover.md
weichen added 1 commit 2026-10-11 10:04:26 +00:00
Record the refreshed verification evidence at the synced HEAD
ci / test-pg (pull_request) Successful in 56s
ci / test (pull_request) Successful in 2m31s
4ae08ae858
weichen added 2 commits 2026-10-11 10:20:50 +00:00
Why: include the current integration baseline before verification.

Evidence: fetched origin/main=2229d718c7b25941cba1c2464ddd62f9d7466bec.

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) Successful in 2m35s
7cf592eb5f
Why: bind the task validation checkpoint to the latest integration baseline.

Evidence: SELF recursive component checks; sync_base=2229d718c7b25941cba1c2464ddd62f9d7466bec; candidate=d44d59929514ddd901581b4f260e9ee787c5f110.

Impact: task metadata only.

Refs: .task/feature-svc-db-config-recover.md
weichen added 2 commits 2026-10-11 10:39:00 +00:00
Why: include the current integration baseline before verification.

Evidence: fetched origin/main=56152323f6179d8f99cfb2b4808573f1d95a63a2.

Impact: integrate upstream changes without rewriting task history.

Refs: task-sync
Record the sync checkpoint
ci / test (pull_request) Successful in 2m29s
ci / test-pg (pull_request) Successful in 58s
1b5e372901
Why: bind the task validation checkpoint to the latest integration baseline.

Evidence: SELF recursive component checks; sync_base=56152323f6179d8f99cfb2b4808573f1d95a63a2; candidate=089da85368d763c63e745abeb0ac0a20229ff597.

Impact: task metadata only.

Refs: .task/feature-svc-db-config-recover.md
weichen merged commit 452f00e6d9 into main 2026-10-11 10:53:44 +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#342