diff --git a/CHANGELOG.md b/CHANGELOG.md index aef1c05e..1a5ce0dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,7 +24,7 @@ Platform releases use `vX.Y.Z` tags and publish `ghcr.io/tencent/loopforge`. Loo - Messages queued in a conversation are kept when switching to another conversation and back (#1004). - 「创建并去对话澄清」 sends again. The first message of the new conversation @-mentions the requirement, and the turn links that issue to the conversation while starting; the start then compared the conversation it read before linking and refused its own link with 「关联需求已更新,请重新发送」 every time. The same happened to any later message that @-mentioned an issue in a conversation without a linked issue. A turn now accepts the issue it linked itself; a conversation rebound to another issue while the turn starts is still refused. - A conversation's 子 Agent shows the model it ran on: its row in the artifacts list reads 「已完成 · 模型 …」, the header of an opened subagent names the model next to its status, and each dispatch in 会话过程 notes 「模型 · …」 under the task it was given. The model is the one the subagent reports running on: its first line in the CLI stream is saved as an `agentModel` activity event under the dispatch, so an alias such as `lite` shows the model it resolved to. Until it reports, and for replies saved before this change, the panel falls back to the model the Agent call named (the `model` argument), else the model of the reply that dispatched it, which the subagent inherits; a dispatch still running uses the model the running reply was sent with. Activity events of an Agent call carry the new `model` field only when the call named one. -- The built-in backend, frontend and defect-fix SOPs gain a 「发起 MR」 node between 人工验收 and 交付汇总 (#717). It commits the work branch, pushes it and opens an MR/PR against the run's target branch, then records the link, branches and commit SHA in `mr-body.md`. Its command gate checks every writable repository of the run: one with commits beyond the target branch fails while it has uncommitted changes, while its checkout is off the run's work branch, or until `git ls-remote origin` shows that work branch at HEAD. A repository the run left unchanged is skipped. A second gate of the new mode `mr` has the engine look the MR up on the host with the same lookup delivery tracking uses (GitHub and Gongfeng): every writable repository whose work branch on origin carries commits beyond the target branch needs an MR from that work branch into that target branch that carries the pushed tip: an open one whose head is the tip (or whose host reports no head), or a merged one whose head is the tip. An agent that reports pass without opening an MR, opens it against the wrong branch, or leaves only an earlier merged MR on a reused work branch does not reach 交付汇总. The lookup runs as the run: on GitHub with the Git token the run pushed with (its responsible user's), falling back to the Owner of the run's own project; on Gongfeng through the run project's MCP as the responsible user. A repository bound to several projects is no longer checked as whichever project bound it first, and a failed lookup names the identity it used. A host the platform cannot query (an SSH repository, a failed lookup) goes straight to a person. `mr` gates take no commands, and the role editor keeps them when a role is saved. The gates retry once with their feedback and then wait for a person, so a run no longer succeeds with every source change left in a workspace that is reclaimed right after success. Run-scoped commands now get `AGENTFLOW_WORK_BRANCHES` (one `dirwork branchtarget branch` line per writable repository) and repository-scoped commands get `AGENTFLOW_WORK_BRANCH` and `AGENTFLOW_BASE_BRANCH`; the target branch is the one frozen into the run, including a requirement's release branch and a scheduled SOP's integration branch. 交付汇总 no longer pushes or opens a PR itself. Runs without a bound repository still deliver from the task workspace. New installs get the new templates from the seed. Existing installs keep their templates until an operator runs `migrations/033_generic_sop_mr_node.sql` by hand (see docs/deployment.md); it rewrites a template only while its node graph and 交付汇总 position are the shipped original and its 交付汇总 prompt only while unedited. SOPs already adopted into a project are copies and keep their old graph. The product SOP delivers documents only and is unchanged. +- The built-in backend, frontend and defect-fix SOPs gain a 「发起 MR」 node between 人工验收 and 交付汇总 (#717). It commits the work branch, pushes it and opens an MR/PR against the run's target branch, then records the link, branches and commit SHA in `mr-body.md`. Its command gate checks every writable repository of the run: one with commits beyond the target branch fails while it has uncommitted changes, while its checkout is off the run's work branch, or until `git ls-remote origin` shows that work branch at HEAD. A repository the run left unchanged is skipped. A second gate of the new mode `mr` has the engine look the MR up on the host with the same lookup delivery tracking uses (GitHub and Gongfeng): every writable repository whose work branch on origin carries commits beyond the target branch needs an MR from that work branch into that target branch that carries the pushed tip: an open one whose head is the tip (or whose host reports no head), or a merged one whose head is the tip. An agent that reports pass without opening an MR, opens it against the wrong branch, or leaves only an earlier merged MR on a reused work branch does not reach 交付汇总. The lookup runs as the run: on GitHub with the Git token the run pushed with (its responsible user's), falling back to the Owner of the run's own project; on Gongfeng through the run project's MCP as the responsible user. A repository bound to several projects is no longer checked as whichever project bound it first, and a failed lookup names the identity it used. A host the platform cannot query (an SSH repository, a failed lookup) goes straight to a person. `mr` gates take no commands, and the role editor keeps them when a role is saved. The gates retry once with their feedback and then wait for a person, so a run no longer succeeds with every source change left in a workspace that is reclaimed right after success. Run-scoped commands now get `AGENTFLOW_WORK_BRANCHES` (one `dirwork branchtarget branch` line per writable repository) and repository-scoped commands get `AGENTFLOW_WORK_BRANCH` and `AGENTFLOW_BASE_BRANCH`; the target branch is the one frozen into the run, including a requirement's release branch and a scheduled SOP's integration branch. 交付汇总 no longer pushes or opens a PR itself. Runs without a bound repository still deliver from the task workspace. New installs get the new templates from the seed; existing installs get them from `migrations/033_generic_sop_mr_node.sql`, which `scripts/install-schema-extensions.sh` replays before `038_generic_sop_host_credentials.sql` on install and `./start.sh pull`. The second migration gives the MR role the current Git credential instructions. The first rewrites a template only while its node graph and 交付汇总 position are the shipped original and its 交付汇总 prompt only while unedited. SOPs already adopted into a project are copies and keep their old graph. The product SOP delivers documents only and is unchanged. - A conversation reply that is still running keeps running through a slow heartbeat. A poll, the conversation list, a follow-up message or a steer used to record it as interrupted after 45 seconds without a stored heartbeat; the process then cancelled the CLI and the next message failed with 「工作区正在使用或保存,请稍后重试」 for up to 15 minutes. Reads of a turn this process executes no longer reap it, and an unchanged heartbeat on MySQL no longer counts as a lost turn. On MySQL a heartbeat's age is measured on the database clock that stamped it, so skew between an API host and MySQL neither reaps a live turn nor keeps a dead one; whether a lease holder stopped renewing is likewise judged from `run_workspace_checkpoints.lease_renewed_at`, stamped on the database clock, not from another replica's `lease_until`. When a turn whose process died is reaped, the workspace lease it recorded is released if nothing renewed it for 45 seconds, so the next message starts at once; a lease another turn took, one still renewed on another replica, and a background save are kept. `migrations/032_assistant_generation_workspace_lease.sql` adds the three columns by hand; startup AutoMigrate adds them too. - The platform image bundles DeepSeek Harness `@deepseek-ai/dsh@0.2.2-rc.1` next to Codex and CodeBuddy, so a DeepSeek key works in conversations and SOP roles without an install step. 0.3.8 had no `dsh` and answered a DeepSeek Harness chat with “AI 助手生成失败,请稍后重试”. The image download grows by about 180 MB. An installation without the image installs the same pinned version from the conversation: every dsh release is a prerelease requiring Node 24.9, and npm on Node 22 found no version for the bare package name. @@ -47,7 +47,7 @@ Platform releases use `vX.Y.Z` tags and publish `ghcr.io/tencent/loopforge`. Loo Repositories saved earlier with a token in `cloneUrl` keep cloning until they are saved again. Saving one from the studio stores the URL without the token, so first put the Git token in 个人配置, then save the repository. Until then the token also lands in each workspace's `.git/config`, where the agent can read it, so re-save such repositories soon after upgrading. -Startup AutoMigrate creates the tables and columns of migrations `028` to `035`, and the installer and `./start.sh pull` apply `031`. `030` only aligns the stored `shared` flag of `generic-docker` with what the application already reads and is optional. To add the 「发起 MR」 node to the built-in SOPs of an existing installation, run `migrations/033_generic_sop_mr_node.sql` by hand (see `docs/deployment.md`). Rotate any agent CLI key that ran an SOP role before this release. +Startup AutoMigrate creates the tables and columns of migrations `028` to `035`, and the installer and `./start.sh pull` apply `031`, `033`, and `038` in that order. `030` only aligns the stored `shared` flag of `generic-docker` with what the application already reads and is optional. The Compose upgrade adds the 「发起 MR」 node to unmodified built-in delivery SOPs. Manual deployments can apply `033` followed by `038` as described in `docs/deployment.md`. Rotate any agent CLI key that ran an SOP role before this release. ## 0.3.8 — header sign-in hardening and a GHCR mirror option diff --git a/docs/deployment.md b/docs/deployment.md index e29e802c..17348d4d 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -165,7 +165,7 @@ Configure provider credentials in the platform UI, not the host's global CLI con ## Observability schema -After the base tables have been created, run `bash scripts/install-schema-extensions.sh` for the Compose database. It installs absent `run_telemetry.adapter` and `run_logs.level` columns and their indexes from upstream migration `001_run_obs_generated_columns.sql`, then replays the `INSERT IGNORE` starter catalog. Both steps can be repeated without touching existing rows. The installer runs it before printing the address, and `./start.sh pull` runs it again after recreating containers, so an older data volume upgraded to a newer image picks up the columns the new code reads. Application startup does not run data migrations. +After the base tables have been created, run `bash scripts/install-schema-extensions.sh` for the Compose database. It installs absent `run_telemetry.adapter` and `run_logs.level` columns and their indexes from upstream migration `001_run_obs_generated_columns.sql`, then replays the `INSERT IGNORE` starter catalog and the built-in catalog rewrites from `031_generic_backend_openssh.sql`, `033_generic_sop_mr_node.sql`, and `038_generic_sop_host_credentials.sql` in that order. The rewrites are repeatable and apply only to matching defaults. The installer runs it before printing the address, and `./start.sh pull` runs it again after recreating containers, so an older data volume upgraded to a newer image picks up the columns the new code reads and the built-in SOP graphs the new code ships. Application startup does not run data migrations. For an external MySQL deployment, review that migration and check column existence before applying its corresponding statements. Stored generated columns can rebuild large existing tables; schedule the operation accordingly. @@ -175,7 +175,7 @@ For an external MySQL deployment, review that migration and check column existen | Kind | Example | What an operator does | | --- | --- | --- | -| Already applied by the installer and `./start.sh pull` | `001_run_obs_generated_columns.sql`, `migrations/seed/*.sql`, `031_generic_backend_openssh.sql` | Nothing; the script above covers it | +| Already applied by the installer and `./start.sh pull` | `001_run_obs_generated_columns.sql`, `migrations/seed/*.sql`, `031_generic_backend_openssh.sql`, `033_generic_sop_mr_node.sql`, `038_generic_sop_host_credentials.sql` | Nothing; the script above covers it | | Required upgrade migrations | `009_bot_interactions_utf8mb4.sql`, `036_git_http_credentials.sql` | Follow each migration's timing and prerequisites. [Migrating existing GitHub credentials](#migrating-existing-github-credentials) | | Optional backfills and rewrites of existing rows | `016_public_optional_repositories.sql`, `021_assistant_session_sources.sql` | Run them if the installation needs the converted rows | @@ -189,15 +189,14 @@ docker compose exec -T mysql sh -c 'MYSQL_PWD="$MYSQL_PASSWORD" mysql -u loopfor This repeatable SQL changes only instruction fields that still match the original public seed. It preserves operator edits and project copies. New installations already receive these instructions from the public catalog seed; application startup does not migrate data. -To add the 「发起 MR」 node to the built-in backend, frontend and defect-fix SOPs of an existing installation, apply `033_generic_sop_mr_node.sql` the same way: +On Compose installs, the installer and `./start.sh pull` add the 「发起 MR」 node to the built-in backend, frontend, and defect-fix SOPs. They apply `033_generic_sop_mr_node.sql` to add the step, then `038_generic_sop_host_credentials.sql` to update the original MR role instructions. To apply the SQL manually, run both migrations in the same order. ```bash -docker compose exec -T mysql sh -c 'MYSQL_PWD="$MYSQL_PASSWORD" mysql -u loopforge loopforge' < migrations/033_generic_sop_mr_node.sql +cat migrations/033_generic_sop_mr_node.sql migrations/038_generic_sop_host_credentials.sql \ + | docker compose exec -T mysql sh -c 'MYSQL_PWD="$MYSQL_PASSWORD" mysql -u loopforge loopforge' ``` -After it, a run of these SOPs commits and pushes its work branch and opens an MR/PR before 交付汇总, so the Git credentials of the run's responsible user need push access. The installer and `./start.sh pull` do not run it. It rewrites a template only while its node graph and 交付汇总 position are the shipped original, and the 交付汇总 prompt only while unedited; it is safe to repeat. Project SOPs adopted from these templates are copies and are not changed. - -After migrating personal Git credentials, apply `038_generic_sop_host_credentials.sql` to update the original authentication instruction in the three built-in MR roles. The roles can use a hosting CLI, a configured MCP, or the host's API with a token obtained through `git credential fill`. +Migration 033 checks that the node graph and 交付汇总 position still match the shipped template. It updates the 交付汇总 prompt only when it is unedited. Migration 038 replaces the original Git authentication instruction with guidance to use a hosting CLI, a configured MCP, or `git credential fill` for API access. Both migrations preserve project copies and can be repeated. The Git credentials of the run's responsible user need push access for the new step to complete. ## GitHub credentials diff --git a/migrations/033_generic_sop_mr_node.sql b/migrations/033_generic_sop_mr_node.sql index f11615d1..6e0a406f 100644 --- a/migrations/033_generic_sop_mr_node.sql +++ b/migrations/033_generic_sop_mr_node.sql @@ -13,13 +13,34 @@ -- every pushed work branch with new commits needs a non-closed MR into the -- run's target branch, and a host that cannot be queried goes to a person. -- --- New installs get these templates from the seed. This script changes the --- behaviour of existing SOPs, so it is not run on install or ./start.sh pull; --- an operator runs it by hand. Only templates whose node graph and deliver --- position are still the shipped original are rewritten; the deliver prompt is --- replaced only when unedited. Project SOPs already adopted from these --- templates are copies and are not touched. +-- New installs get these templates from the seed; existing installs get them +-- from this script, which scripts/install-schema-extensions.sh replays on +-- install and on ./start.sh pull, so ./start.sh pull upgrades the graph +-- without a manual step. Only templates whose node graph and deliver position +-- are still the shipped original are rewritten; the deliver prompt is replaced +-- only when unedited. Project SOPs already adopted from these templates are +-- copies and are not touched. After it, a run of these SOPs needs a Git +-- credential with push access when a repository is bound: without one it stops +-- at 发起 MR for a person instead of succeeding. SET NAMES utf8mb4; +-- The three original graphs differ only in the template prefix of their agent IDs. +SET @lf_033_nodes = '[ + {"id": "clarify", "name": "需求定型", "type": "agent", "agentId": "__template__-clarify", "maxAttempts": 2, "position": {"x": 100, "y": 150}, "artifactOutputs": [{"name": "clarify", "path": "requirement.md", "mediaType": "text/markdown", "required": true}]}, + {"id": "design", "name": "方案设计", "type": "agent", "agentId": "__template__-design", "maxAttempts": 2, "position": {"x": 345, "y": 150}, "artifactOutputs": [{"name": "design", "path": "design.md", "mediaType": "text/markdown", "required": true}]}, + {"id": "implement", "name": "开发实现", "type": "agent", "agentId": "__template__-implement", "maxAttempts": 2, "position": {"x": 590, "y": 150}, "artifactOutputs": [{"name": "implement", "path": "implementation.md", "mediaType": "text/markdown", "required": true}]}, + {"id": "review", "name": "独立评审", "type": "agent", "agentId": "__template__-review", "maxAttempts": 2, "position": {"x": 835, "y": 150}, "artifactOutputs": [{"name": "review", "path": "review.md", "mediaType": "text/markdown", "required": true}]}, + {"id": "test", "name": "测试验证", "type": "agent", "agentId": "__template__-test", "maxAttempts": 2, "position": {"x": 1080, "y": 150}, "artifactOutputs": [{"name": "test", "path": "test-report.md", "mediaType": "text/markdown", "required": true}]}, + {"id": "accept", "name": "人工验收", "type": "approval", "maxAttempts": 1, "rejectTo": "implement", "position": {"x": 1325, "y": 150}}, + {"id": "deliver", "name": "交付汇总", "type": "agent", "agentId": "__template__-deliver", "maxAttempts": 2, "position": {"x": 1570, "y": 150}, "artifactOutputs": [{"name": "deliver", "path": "delivery.md", "mediaType": "text/markdown", "required": true}]} +]'; +SET @lf_033_edges = '[ + {"id": "e-0", "source": "clarify", "target": "design", "when": "success"}, + {"id": "e-1", "source": "design", "target": "implement", "when": "success"}, + {"id": "e-2", "source": "implement", "target": "review", "when": "success"}, + {"id": "e-3", "source": "review", "target": "test", "when": "success"}, + {"id": "e-4", "source": "test", "target": "accept", "when": "success"}, + {"id": "e-5", "source": "accept", "target": "deliver", "when": "success"} +]'; START TRANSACTION; UPDATE generic_templates SET payload = JSON_ARRAY_APPEND( @@ -28,16 +49,13 @@ SET payload = JSON_ARRAY_APPEND( '$.Workflow.edges', CAST('{"id": "e-6", "source": "mr", "target": "deliver", "when": "success"}' AS JSON), '$.Agents', CAST('{"version": 1, "updatedAt": "2026-11-16T00:00:00Z", "id": "generic-backend-delivery-mr", "name": "发起 MR", "executorId": "codebuddy", "rules": ["public-engineering"], "skills": [], "mcpServers": [], "prompt": "工作领域:后端服务、数据与 API。人工验收已通过,本节点把本轮代码改动提交到工作分支、推送并发起 MR/PR,不再修改业务逻辑。\\n\\n1. 未绑定代码仓库时不推送、不创建 MR/PR:在 mr-body.md 写明「未绑定代码仓库,源码保留在任务工作区」并列出交付文件,然后提交 pass。\\n2. 已绑定仓库时逐个处理每个仓库检出目录,本轮没有改动的仓库跳过,不创建空 MR/PR:确认当前在本轮工作分支上,不得在主分支提交,也不得切换或新建分支;检查 git status 与 diff,只提交本任务相关的源码改动,不提交 .agentflow、依赖目录、构建产物和 SOP 阶段文档;用概括本次改动的提交信息 commit,再 git push -u origin 当前工作分支。平台已注入 Git 凭据,不得打印、回显或写入任何令牌。\\n3. 以仓库上下文中的目标分支为目标创建 MR/PR:GitHub 仓库优先用已配置的 GitHub MCP,没有时用 curl 调 GitHub API,令牌取 $AGENTFLOW_GIT_TOKEN;其它托管平台用已配置的对应 MCP。本轮工作分支已有指向同一目标分支的 MR/PR 时更新它,不重复创建。\\n4. 标题概括本次改动;描述写需求摘要、改动要点、测试结果(依据 test-report.md)和已知限制。不得合并 MR/PR,不得推送主分支或强推。\\n5. 把每个仓库的 MR/PR 链接、源分支、目标分支和提交 SHA 写到 mr-body.md。\\n6. 推送或创建 MR/PR 失败(缺少凭据、无权限、网络错误等)时不得提交 pass:在 mr-body.md 记录失败原因,提交 human,并在 actionRequired 写明需要人工处理什么,例如配置 Git Token 后重试,或到托管平台手动创建 MR。\\n\\nMR 约束:{{existingMR}}\\n\\n完成本节点约定的工作并交付产物。\\n\\n### 输入\\n\\n- 任务需求:{{input}}\\n- 仓库上下文:{{repository}}", "loop": {"enabled": true, "maxIterations": 2, "exitCondition": "all_gates_pass", "onExhausted": "human"}, "verification": [{"id": "mr-pushed", "name": "改动已提交并推送", "mode": "command", "stage": "after_execution", "commands": ["fail=0\\ntab=\\"$(printf ''\\\\t'')\\"\\nwhile IFS=\\"$tab\\" read -r d work base; do\\n [ -n \\"$d\\" ] || continue\\n dirty=\\"$(git -C \\"$d\\" status --porcelain --untracked-files=all -- . \\":(exclude).agentflow\\" \\":(exclude,glob)**/node_modules/**\\")\\" || { printf \\"%s 不是可用的 Git 检出目录\\\\n\\" \\"$d\\"; fail=1; continue; }\\n if [ -n \\"$dirty\\" ]; then printf \\"%s 有未提交的改动:\\\\n%s\\\\n\\" \\"$d\\" \\"$dirty\\"; fail=1; continue; fi\\n refs=HEAD\\n if git -C \\"$d\\" rev-parse -q --verify \\"refs/heads/$work\\" >/dev/null; then refs=\\"HEAD refs/heads/$work\\"; fi\\n ahead=\\"$(git -C \\"$d\\" rev-list --count $refs --not \\"refs/remotes/origin/$base\\")\\" || { printf \\"%s 找不到目标分支 origin/%s\\\\n\\" \\"$d\\" \\"$base\\"; fail=1; continue; }\\n [ \\"$ahead\\" != 0 ] || continue\\n branch=\\"$(git -C \\"$d\\" branch --show-current)\\"\\n if [ \\"$branch\\" != \\"$work\\" ]; then printf \\"%s 当前在 %s,不在本轮工作分支 %s\\\\n\\" \\"$d\\" \\"${branch:-分离的 HEAD}\\" \\"$work\\"; fail=1; continue; fi\\n head=\\"$(git -C \\"$d\\" rev-parse HEAD)\\"\\n pushed=\\"$(git -C \\"$d\\" ls-remote origin \\"refs/heads/$work\\")\\" || { printf \\"%s 无法读取远端 origin\\\\n\\" \\"$d\\"; fail=1; continue; }\\n if [ \\"${pushed%%\\"$tab\\"*}\\" != \\"$head\\" ]; then printf \\"%s 的工作分支 %s 在 origin 上不是 %s,本轮提交还没推送\\\\n\\" \\"$d\\" \\"$work\\" \\"$head\\"; fail=1; fi\\ndone </dev/null; then refs=\\"HEAD refs/heads/$work\\"; fi\\n ahead=\\"$(git -C \\"$d\\" rev-list --count $refs --not \\"refs/remotes/origin/$base\\")\\" || { printf \\"%s 找不到目标分支 origin/%s\\\\n\\" \\"$d\\" \\"$base\\"; fail=1; continue; }\\n [ \\"$ahead\\" != 0 ] || continue\\n branch=\\"$(git -C \\"$d\\" branch --show-current)\\"\\n if [ \\"$branch\\" != \\"$work\\" ]; then printf \\"%s 当前在 %s,不在本轮工作分支 %s\\\\n\\" \\"$d\\" \\"${branch:-分离的 HEAD}\\" \\"$work\\"; fail=1; continue; fi\\n head=\\"$(git -C \\"$d\\" rev-parse HEAD)\\"\\n pushed=\\"$(git -C \\"$d\\" ls-remote origin \\"refs/heads/$work\\")\\" || { printf \\"%s 无法读取远端 origin\\\\n\\" \\"$d\\"; fail=1; continue; }\\n if [ \\"${pushed%%\\"$tab\\"*}\\" != \\"$head\\" ]; then printf \\"%s 的工作分支 %s 在 origin 上不是 %s,本轮提交还没推送\\\\n\\" \\"$d\\" \\"$work\\" \\"$head\\"; fail=1; fi\\ndone </dev/null; then refs=\\"HEAD refs/heads/$work\\"; fi\\n ahead=\\"$(git -C \\"$d\\" rev-list --count $refs --not \\"refs/remotes/origin/$base\\")\\" || { printf \\"%s 找不到目标分支 origin/%s\\\\n\\" \\"$d\\" \\"$base\\"; fail=1; continue; }\\n [ \\"$ahead\\" != 0 ] || continue\\n branch=\\"$(git -C \\"$d\\" branch --show-current)\\"\\n if [ \\"$branch\\" != \\"$work\\" ]; then printf \\"%s 当前在 %s,不在本轮工作分支 %s\\\\n\\" \\"$d\\" \\"${branch:-分离的 HEAD}\\" \\"$work\\"; fail=1; continue; fi\\n head=\\"$(git -C \\"$d\\" rev-parse HEAD)\\"\\n pushed=\\"$(git -C \\"$d\\" ls-remote origin \\"refs/heads/$work\\")\\" || { printf \\"%s 无法读取远端 origin\\\\n\\" \\"$d\\"; fail=1; continue; }\\n if [ \\"${pushed%%\\"$tab\\"*}\\" != \\"$head\\" ]; then printf \\"%s 的工作分支 %s 在 origin 上不是 %s,本轮提交还没推送\\\\n\\" \\"$d\\" \\"$work\\" \\"$head\\"; fail=1; fi\\ndone <&2 exit 1 fi -cat migrations/seed/*.sql migrations/031_generic_backend_openssh.sql | docker_access compose exec -T mysql sh -c 'MYSQL_PWD="$MYSQL_PASSWORD" mysql -u loopforge loopforge' +cat migrations/seed/*.sql \ + migrations/031_generic_backend_openssh.sql \ + migrations/033_generic_sop_mr_node.sql \ + migrations/038_generic_sop_host_credentials.sql \ + | docker_access compose exec -T mysql sh -c 'MYSQL_PWD="$MYSQL_PASSWORD" mysql -u loopforge loopforge' diff --git a/scripts/test-install-live.sh b/scripts/test-install-live.sh index 4758b748..c061532e 100644 --- a/scripts/test-install-live.sh +++ b/scripts/test-install-live.sh @@ -21,8 +21,8 @@ actors=(root nonroot without-compose) for actor in "${actors[@]}"; do fixture="$task_dir/$actor" mkdir -p "$fixture/scripts" "$fixture/migrations/seed" "$fixture/user-home" - cp scripts/{install.sh,configure.sh,docker-access.sh,ghcr-mirror.sh,install-address.py,install-compose.py,install-observability-schema.sh} "$fixture/scripts/" - cp migrations/001_run_obs_generated_columns.sql migrations/031_generic_backend_openssh.sql "$fixture/migrations/" + cp scripts/{install.sh,configure.sh,docker-access.sh,ghcr-mirror.sh,install-address.py,install-compose.py,install-observability-schema.sh,install-schema-extensions.sh} "$fixture/scripts/" + cp migrations/001_run_obs_generated_columns.sql migrations/031_generic_backend_openssh.sql migrations/033_generic_sop_mr_node.sql migrations/038_generic_sop_host_credentials.sql "$fixture/migrations/" cp migrations/seed/*.sql "$fixture/migrations/seed/" cp compose.yaml "$fixture/" read -r http_port mysql_port < <(python3 - <<'PY' diff --git a/scripts/test-install.py b/scripts/test-install.py index 4307a840..cd4d6e23 100644 --- a/scripts/test-install.py +++ b/scripts/test-install.py @@ -35,7 +35,7 @@ def setUp(self): for name in ('install.sh', 'configure.sh', 'docker-access.sh', 'ghcr-mirror.sh', 'install-address.py', 'install-compose.py', 'install-observability-schema.sh', 'install-schema-extensions.sh'): shutil.copyfile(ROOT / 'scripts' / name, self.root / 'scripts' / name) shutil.copyfile(ROOT / 'start.sh', self.root / 'start.sh') - for name in ('001_run_obs_generated_columns.sql', '031_generic_backend_openssh.sql'): + for name in ('001_run_obs_generated_columns.sql', '031_generic_backend_openssh.sql', '033_generic_sop_mr_node.sql', '038_generic_sop_host_credentials.sql'): (self.root / 'migrations' / name).write_text((ROOT / 'migrations' / name).read_text()) (self.root / 'migrations/seed/001_test.sql').write_text('INSERT IGNORE INTO agents (id) VALUES (1);\n') (self.root / 'mock').mkdir() @@ -461,6 +461,11 @@ def test_start_pull_reapplies_schema_extensions_after_containers_are_up(self): self.assertIn('ALTER TABLE run_telemetry', sql) self.assertIn('ALTER TABLE run_logs', sql) self.assertIn('INSERT IGNORE', sql) + # The 「发起 MR」 node of the code delivery SOPs is replayed too, instead + # of waiting for an operator to run migration 033 by hand. + self.assertIn('JSON_ARRAY_APPEND', sql) + self.assertIn('git credential fill', sql) + self.assertLess(sql.index('JSON_ARRAY_APPEND'), sql.index('SET @new_mr_auth')) # Recreated containers come first; the old volume then gets the columns. self.assertLess(log.index('up -d --no-build --wait'), log.index('exec -T mysql'))