svc.sh: deploy/update from an isolated remote source clone (dirty-tree independent) #102

Merged
weichen merged 8 commits from feature/svc-remote-source into main 2026-10-01 05:23:53 +00:00
Owner

feature/svc-remote-source 任务卡

任务主记录:<PR 链接,task-finish 时填写>;状态:进行中;owner:weichen

基线与授权

  • 权威仓:ssh://git@git-ssh.u1680832.nyat.app:31411/weichen/Agent-System-Dev.git;目标分支:main;R0(initial_base_sha)= f65d89e59b
  • 工作区:/home/weichen/projects/Agent-System-Dev-wt-feature-svc-remote-source(worktree);分支:feature/svc-remote-source
  • 启动方式说明:主检出存在 owner 本人未收尾现场(modules/frontend 子模块修改态,前端重设计进行中),task.sh start 按门禁硬拒。owner 在任务对话中明确指示本任务并要求"更新/部署不依赖当前仓库状态",即 collaboration.md 的"经 owner 确认"路径;本工作区由 Agent 以与 task-start 完全相同的命令手动建立(同 R0、同命名、子模块零漂移),全程未写主检出、未触碰该未提交现场。
  • 授权与交付终点:修改 scripts/svc.sh 与 docs/svc.md(实现 + 文档),验证后推送并建 PR;不合并(合入由 owner 决定);不动主检出 modules/frontend 现场。

目标与非目标

背景:scripts/svc.sh update dev 在主检出工作树不干净时跳过更新("主检出工作树不干净——跳过")。owner 明确要求:更新、部署等操作不应依赖当前仓库状态;不指定时默认使用最新仓库;构建放在独立于当前仓库/目录的地方。

目标:

  1. 新增"独立部署源仓":脚本自有的干净克隆(默认 ~/.cache/agent-system-svc/src,SVC_SRC_DIR 覆盖;可随时删除重建),dev 源的解析、列举(commits)、worktree 物化全部基于它。
  2. 默认来源改为远端最新:裸 deploy 与 --from dev(不带 @sha)= 源仓 origin/main 最新提交;--from local 保留为显式"构建当前工作区"。
  3. update 去 pull 化:删除"local 源 → 主检出 pull(要求分支=main + 树干净)"路径;local@/dev@ 源一律重新部署为 dev@<远端最新>(隔离 worktree 构建),与工作区脏净/所在分支无关。领先/分叉/提交不在远端三种情形仍不动作(不盲目降级)。
  4. update 的 fetch 也走源仓(不再 fetch 主检出);commits dev 列表改为源仓 origin/main(自动确保+fetch),[HEAD] 标记改为 [最新]。
  5. 文档同步:脚本头注释、help 各主题、docs/svc.md(§2/§5/§6.3/§9.3/§11/§13/§14)。

非目标:不改 --from local 语义与实现;不改 release 源、数据库、生命周期、dbops 行为;不动 Makefile。

同步记录

节点 sync_base_sha tested_head_sha checked_at
启动 f65d89e59b f65d89e59b 2026-09-30(手动 task-start 复刻)

结果与验证

  • 结果:已实现(提交 a42fff6)。svc.sh 新增独立部署源仓(SVC_SRC_DIR,默认
    ~/.cache/agent-system-svc/src,可随时删除重建):dev 源的提交解析、commits 列举、
    worktree 物化全部基于它;裸 deploy 与 --from dev 缺省取源仓 origin/main 最新;
    update 删除"主检出 pull(要求分支=main+树干净)"路径,local@/dev@ 源一律重新
    部署为 dev@<远端最新>(领先/分叉/提交不在远端三种情形仍不动作);docs/svc.md
    与脚本 help 各主题同步更新。

  • 验证:

    • bash -n scripts/svc.sh 通过;help/help lifecycle 渲染正常;
    • scripts/svc.sh commits dev:首次自动克隆源仓并 fetch,列表来自源仓 origin/main,
      顶提交标 [最新];
    • 裸 deploy --dry-run(无 --from):计划 dev@0be23f9(源仓远端最新);
    • 端到端(复刻 owner 场景):在任务 worktree 制造脏现场(未跟踪文件 + 跟踪文件
      修改)并手工登记 source=local@d64742c 的服务,scripts/svc.sh update svc-selftest
      直接更新成功:local@d64742c → 0be23f9,从源仓物化隔离 worktree 构建(npm ci +
      vite + go build),服务启动健康(pid 1228696,http://127.0.0.1:8812,来源
      dev@0be23f9,版本组合完整),全程未触碰工作区;随后 stop + rm --purge 清理,
      worktree 无残留;
    • make task-sync:sync_base=0be23f9a4d,tested_head=87cc6b3b55(并入 PR #101 后组合);
    • make test 全绿(core ok;backend 全部 ok 含 server 4.8s;frontend 5 文件 33 用例;
      ui 7 文件 49 用例;agentcmd ok),退出码 0。
  • 影响与剩余项:

    • 行为变化:部署缺省来源从"当前工作区"改为"远端 main 最新"——构建当前工作区须显式
      --from local;update 不再依赖主检出状态,owner 遇到的"工作树不干净——跳过"
      场景消除。
    • 观察项(非本任务引入):部署时对产物 serve -h 探测不到 --auth 会自动省略该
      flag(0be23f9 产物即如此),与旧版行为一致,健康检查通过。
    • 剩余项:PR 合入由 owner 决定;合入并在主检出 pull 后,旧版"树脏跳过"即消失。
# feature/svc-remote-source 任务卡 任务主记录:<PR 链接,task-finish 时填写>;状态:进行中;owner:weichen ## 基线与授权 - 权威仓:ssh://git@git-ssh.u1680832.nyat.app:31411/weichen/Agent-System-Dev.git;目标分支:main;R0(initial_base_sha)= f65d89e59b6974c7a5db63be0677d192bfaa7e9c - 工作区:/home/weichen/projects/Agent-System-Dev-wt-feature-svc-remote-source(worktree);分支:feature/svc-remote-source - 启动方式说明:主检出存在 owner 本人未收尾现场(`modules/frontend` 子模块修改态,前端重设计进行中),`task.sh start` 按门禁硬拒。owner 在任务对话中明确指示本任务并要求"更新/部署不依赖当前仓库状态",即 collaboration.md 的"经 owner 确认"路径;本工作区由 Agent 以与 task-start 完全相同的命令手动建立(同 R0、同命名、子模块零漂移),**全程未写主检出、未触碰该未提交现场**。 - 授权与交付终点:修改 `scripts/svc.sh` 与 `docs/svc.md`(实现 + 文档),验证后推送并建 PR;不合并(合入由 owner 决定);不动主检出 `modules/frontend` 现场。 ## 目标与非目标 **背景**:`scripts/svc.sh update dev` 在主检出工作树不干净时跳过更新("主检出工作树不干净——跳过")。owner 明确要求:更新、部署等操作不应依赖当前仓库状态;不指定时默认使用最新仓库;构建放在独立于当前仓库/目录的地方。 **目标**: 1. 新增"独立部署源仓":脚本自有的干净克隆(默认 `~/.cache/agent-system-svc/src`,`SVC_SRC_DIR` 覆盖;可随时删除重建),dev 源的解析、列举(commits)、worktree 物化全部基于它。 2. 默认来源改为远端最新:裸 `deploy` 与 `--from dev`(不带 @sha)= 源仓 `origin/main` 最新提交;`--from local` 保留为显式"构建当前工作区"。 3. `update` 去 pull 化:删除"local 源 → 主检出 pull(要求分支=main + 树干净)"路径;`local@`/`dev@` 源一律重新部署为 `dev@<远端最新>`(隔离 worktree 构建),与工作区脏净/所在分支无关。领先/分叉/提交不在远端三种情形仍不动作(不盲目降级)。 4. `update` 的 fetch 也走源仓(不再 fetch 主检出);`commits dev` 列表改为源仓 `origin/main`(自动确保+fetch),`[HEAD]` 标记改为 `[最新]`。 5. 文档同步:脚本头注释、`help` 各主题、`docs/svc.md`(§2/§5/§6.3/§9.3/§11/§13/§14)。 **非目标**:不改 `--from local` 语义与实现;不改 release 源、数据库、生命周期、dbops 行为;不动 Makefile。 ## 同步记录 | 节点 | sync_base_sha | tested_head_sha | checked_at | |---|---|---|---| | 启动 | f65d89e59b6974c7a5db63be0677d192bfaa7e9c | f65d89e59b6974c7a5db63be0677d192bfaa7e9c | 2026-09-30(手动 task-start 复刻) | ## 结果与验证 - 结果:已实现(提交 a42fff6)。svc.sh 新增**独立部署源仓**(`SVC_SRC_DIR`,默认 `~/.cache/agent-system-svc/src`,可随时删除重建):dev 源的提交解析、`commits` 列举、 worktree 物化全部基于它;裸 `deploy` 与 `--from dev` 缺省取源仓 `origin/main` 最新; `update` 删除"主检出 pull(要求分支=main+树干净)"路径,`local@`/`dev@` 源一律重新 部署为 `dev@<远端最新>`(领先/分叉/提交不在远端三种情形仍不动作);`docs/svc.md` 与脚本 help 各主题同步更新。 - 验证: - `bash -n scripts/svc.sh` 通过;`help`/`help lifecycle` 渲染正常; - `scripts/svc.sh commits dev`:首次自动克隆源仓并 fetch,列表来自源仓 origin/main, 顶提交标 `[最新]`; - 裸 `deploy --dry-run`(无 `--from`):计划 `dev@0be23f9`(源仓远端最新); - **端到端(复刻 owner 场景)**:在任务 worktree 制造脏现场(未跟踪文件 + 跟踪文件 修改)并手工登记 `source=local@d64742c` 的服务,`scripts/svc.sh update svc-selftest` 直接更新成功:`local@d64742c → 0be23f9`,从源仓物化隔离 worktree 构建(npm ci + vite + go build),服务启动健康(pid 1228696,http://127.0.0.1:8812,来源 `dev@0be23f9`,版本组合完整),全程未触碰工作区;随后 stop + rm --purge 清理, worktree 无残留; - `make task-sync`:sync_base=0be23f9a4d,tested_head=87cc6b3b55(并入 PR #101 后组合); - `make test` 全绿(core ok;backend 全部 ok 含 server 4.8s;frontend 5 文件 33 用例; ui 7 文件 49 用例;agentcmd ok),退出码 0。 - 影响与剩余项: - 行为变化:部署缺省来源从"当前工作区"改为"远端 main 最新"——构建当前工作区须显式 `--from local`;`update` 不再依赖主检出状态,owner 遇到的"工作树不干净——跳过" 场景消除。 - 观察项(非本任务引入):部署时对产物 `serve -h` 探测不到 `--auth` 会自动省略该 flag(0be23f9 产物即如此),与旧版行为一致,健康检查通过。 - 剩余项:PR 合入由 owner 决定;合入并在主检出 pull 后,旧版"树脏跳过"即消失。
weichen added 5 commits 2026-09-30 18:41:07 +00:00
Why: svc.sh update skipped services with a local@<sha> source whenever the
main checkout was dirty, and bare deploy built the current workspace. The
owner requires updates/deploys to be independent of the working tree
state, defaulting to the latest remote commit built outside the checkout.

Evidence: bash -n passes; commits dev lists from the source clone; bare
deploy --dry-run plans dev@<origin/main>; end-to-end "svc.sh update
svc-selftest" with a dirty tree updated a local@d64742c service to
dev@0be23f9 (built in runtime/.worktrees from
~/.cache/agent-system-svc/src, started healthy), then stopped and purged.
Full make test output recorded on the task card.

Impact: deploy now defaults to dev@<origin/main> resolved in the
script-owned clone (SVC_SRC_DIR, default ~/.cache/agent-system-svc/src);
--from local stays the only workspace-dependent source; update no longer
pulls the main checkout - local@/dev@ services redeploy from remote
latest, ahead/diverged/missing-on-remote still decline to act.
docs/svc.md and in-script help updated to match.

Refs: .task/svc-remote-source.md
Record svc-remote-source acceptance evidence
ci / test (pull_request) Failing after 31s
5e2e23309a
weichen added 1 commit 2026-10-01 04:09:32 +00:00
Merge origin/main into svc-remote-source
ci / test (pull_request) Failing after 1m34s
7eb3c38d75
Why: the isolated-source deploy change was finished but never merged, and
the task card had no PR link.

Evidence: the only content conflict was the shared sync-log card; both
rows kept. scripts/svc.sh merged cleanly. PR link recorded as Dev #102.

Impact: branch now contains origin/main. Deploy semantics unchanged.

Refs: https://git-home.u1680832.nyat.app:30319/weichen/Agent-System-Dev/pulls/102
Co-authored-by: Cursor <cursoragent@cursor.com>
weichen added 2 commits 2026-10-01 05:23:46 +00:00
Co-authored-by: Cursor <cursoragent@cursor.com>

# Conflicts:
#	.task/feature-duplication-lesson-records.md
Record the sync checkpoint
ci / test (pull_request) Failing after 31s
40fcf7b1d1
weichen merged commit 4968f97b85 into main 2026-10-01 05:23:53 +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#102