@tea-agent/loop-agent 0.20.1 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/commands/init.js +7 -0
  3. package/dist/executors/dag-pi-executor.js +24 -0
  4. package/dist/executors/pi-executor.js +111 -36
  5. package/dist/executors/pi-sdk-executor.js +105 -29
  6. package/dist/executors/shell-executor.js +54 -11
  7. package/dist/worker/loop-agent/loop-agent-client.js +43 -9
  8. package/dist/worker/observability/read-model.js +7 -1
  9. package/dist/worker/observe/static/constants.js +5 -0
  10. package/dist/worker/observe/static/format-pool.js +22 -3
  11. package/dist/worker/observe/static/styles.css +32 -3
  12. package/dist/worker/observe/static/views/dag-inspector.js +2 -2
  13. package/dist/worker/run-task/run-task.js +16 -6
  14. package/dist/workflows/dag/backend-test-markdown-workflow.js +291 -97
  15. package/dist/workflows/dag/backend-test-result-contract.js +10 -4
  16. package/dist/workflows/dag/init-hybrid.js +27 -16
  17. package/dist/workflows/dag/lifecycle.js +60 -4
  18. package/dist/workflows/dag/liveness-policy.js +250 -0
  19. package/dist/workflows/dag/node-execution.js +49 -0
  20. package/dist/workflows/dag/runner.js +21 -1
  21. package/dist/workflows/dag/types.js +5 -0
  22. package/docs/README.md +5 -6
  23. package/docs/architecture/dag-execution.md +11 -0
  24. package/docs/architecture/facts-and-state.md +1 -0
  25. package/docs/architecture/worker-and-feature.md +10 -0
  26. package/docs/templates/backend-test-dag.generate-pytest.prompt.md +5 -2
  27. package/docs/templates/backend-test-dag.json +15 -15
  28. package/harness.json +1 -1
  29. package/package.json +1 -1
  30. package/skills/loop-agent/references/command-reference.md +2 -0
  31. package/skills/loop-agent/references/hybrid-dag.md +2 -2
package/docs/README.md CHANGED
@@ -52,17 +52,14 @@
52
52
  完整索引与归档策略见 `design/README.md`。下列为当前高频活入口:
53
53
 
54
54
  - `design/backend-test-workflow.md` — backend-test Markdown-first 8 节点流程、单次 pytest、run-owned artifacts 与 L-5
55
- - `design/frontend-mock-data-workflow.md` — 前端 Mock 节点、触发条件、规范证据与失败路由
56
- - `design/frontend-implementation-workflow.md` — 前端实现 / 评审 / 验证工作流
55
+ - `design/frontend-implementation-workflow.md` — 前端实现 / 评审 / 验证工作流(含 Mock/API 策略、capability seed、verification bundle)
57
56
  - `design/dag-source-binding-and-recovery.md` — 新生成 DAG 的任务源绑定与中断恢复
58
57
  - `design/agent-worker-fullstack-workflow-integration.md` — workflow routing、Task Outcome、artifact-aware Ready、`fullstack-v1` 与 Verification Bundle
59
58
  - `design/fullstack-end-to-end-delivery-optimization-roadmap.md` — 全栈端到端优化收敛路线图(release train / Delivery / Final Verification)
60
- - `design/2026-07-22-console-observe-unified-operator-surface.md` — Observe 深度融合进 Console(Wave 1–3 已实现,目标 0.18.0
61
- - `design/2026-07-23-operator-task-rerun-and-node-retry.md` — Operator 自动节点重试、从节点重跑、standalone 完整任务重跑与 Worker Task 重排队(**Wave 1–2 已落地**;Wave 3–4 仍分波;优先解决 LLM/provider 不稳定;Inspect 只读 / Operate mutation)
62
- - `design/local-operator-console-from-pi-web.md` — Operator Console 设计输入;MVP 已随 `0.17.0`–`0.17.2` 发布;统一 surface 见上条
59
+ - `design/local-operator-console-from-pi-web.md` — Operator Console 设计输入;MVP 已随 `0.17.0`–`0.17.2` 发布;统一 surface 设计已归档(见下)
63
60
  - `design/taskspec-to-loop-agent-mapping.md` — TaskSpec → loop-agent task 兼容契约(文档镜像;runtime 真源在代码)
64
61
 
65
- 已实现且仅作历史说明的设计见 `design/archive/`(例如 `design/archive/2026-07-14-loop-agent-self-update-notifier.md`)。
62
+ 已实现且仅作历史说明的设计见 `design/archive/`(例如 `design/archive/2026-07-14-loop-agent-self-update-notifier.md`、`design/archive/2026-07-22-console-observe-unified-operator-surface.md`、`design/archive/2026-07-23-operator-task-rerun-and-node-retry.md`、`design/archive/frontend-mock-data-workflow.md`)。
66
63
 
67
64
  ## 进行中 / 近期完成
68
65
 
@@ -76,6 +73,8 @@
76
73
 
77
74
  完整 completed 列表与主题速览见 `exec-plans/completed/README.md`。近期高频归档:
78
75
 
76
+ - `exec-plans/completed/2026-07-24-backend-test-request-response-logs-report-format.md` — pytest 请求/响应脱敏日志与第 7/8 节点报告版式;真实 `my-webapp` Campaign R04 8/8、17 passed
77
+ - `exec-plans/completed/2026-07-23-backend-test-advisory-gates.md` — 第 4/6 节点改为非阻断 advisory:用例只强制前置条件/步骤/预期,第 6 节点只扫描 Markdown 映射脚本;真实 `my-webapp` Campaign R02 8/8、10 passed
79
78
  - `exec-plans/completed/2026-07-23-backend-test-human-readable-artifacts.md` — 中文 README/用例卡片、class-based pytest traceability 与逐条 self-contained HTML 报告;真实 `my-webapp` Campaign Round 04 8/8、16 passed
80
79
  - `exec-plans/completed/2026-07-22-backend-markdown-gate-fix.md` — backend-test Markdown gate、traceability、中文生成与真实 Campaign 收口
81
80
  - `exec-plans/completed/2026-07-22-backend-test-markdown-first-8-node.md` — backend-test Markdown-first 8 节点
@@ -101,6 +101,17 @@ snapshot 与 controller identity 是两个不同冻结层,详见 `runtime-boun
101
101
 
102
102
  decision envelope 中的 **model verdict**(`decision` / `riskLevel` 等解析自文本)是 `advisoryOnly: true` 派生视图,**不**是完成权威(`facts-and-state.md`)。
103
103
 
104
+ ## 自适应 liveness(节点活动 vs runner lease)
105
+
106
+ 实现见 `src/workflows/dag/liveness-policy.ts` 与设计文档 `docs/design/dag-adaptive-liveness-and-supervision.md`。
107
+
108
+ - **runner lease**(`runner.heartbeatAt`,约 15s)只证明 runner 进程事件循环;**不是** Pi meaningful progress。
109
+ - **真实活动**:SDK provider/tool event 与 CLI stdout|stderr 刷新 provider/tool/output;attempt-fenced,旧 attempt 晚到事件 no-op。SDK noisy delta 只续租 transport watchdog,不刷新 meaningful progress。
110
+ - **节点投影** `livenessStatus`:`active | quiet | suspected-stall | probing | needs-attention`。
111
+ - **absolute max** 默认 4h wall clock(不可被空心跳续期);历史 30 分钟不再是活跃 Pi 节点硬杀边界。
112
+ - `assessDagRunLiveness` 在 lease 新鲜但无 meaningful activity 时返回 `node-quiet` / `suspected-stall` / `needs-attention`;doctor codes 含 `node-activity-quiet`、`node-activity-suspected-stall`、`node-needs-attention`。
113
+ - Observe/read-model 仅为 derived/advisory。
114
+
104
115
  ## 生命周期:active / paused / completed
105
116
 
106
117
  `src/workflows/dag/lifecycle.ts` 定义三个目录:
@@ -23,6 +23,7 @@
23
23
  - **Task Pool 是 Worker 专用可选根**:只有使用 `agent-worker` 产品线时才存在;唯一根 `.harness/task-pool/`。
24
24
  - **Task Pool state identity(ADR 0004)**:canonical 键为 `{ featureId, taskId }`(`TaskPoolTaskRef`),不是裸 `taskId`。
25
25
  - **Observe snapshot 不是事实源**:`buildGlobalSnapshot` 投影失败返回安全错误摘要而非全零健康,不改变执行成败。
26
+ - **节点 liveness 投影是保守 canonical 字段**:`lastProviderActivityAt` / `lastToolActivityAt` / `lastOutputActivityAt` / `lastMeaningfulProgressAt` / `livenessStatus` 由 runner/executor 写入 active run facts;runner lease heartbeat **不得**刷新 meaningful progress。Observe badge(quiet/suspected-stall/needs-attention/needs-reconcile)仍是 derived。
26
27
 
27
28
  ### Task Pool state 布局与迁移
28
29
 
@@ -17,6 +17,16 @@
17
17
 
18
18
  `shell: false` + 绝对 launch spec(见下)意味着 Worker 不走 PATH 重新解析,也不在当前进程内加载 CLI command 实现。
19
19
 
20
+ ### `run-dag` kernel-owned supervision vs explicit hard timeout
21
+
22
+ `run-task` 启动 `run-dag` 时默认把外层 `timeoutMs` 设为 `0`,由 DAG kernel 负责节点 liveness,**不再**无条件把 30 分钟当作 hard kill:
23
+
24
+ - 省略 `worker.timeout_ms` → Worker 不设置 wall-clock deadline,并等待 `run-dag` 产生可确认终态。
25
+ - 显式 `worker.timeout_ms` → hard kill(可 capped),观察到 exit 后可报 `timedOut`。
26
+ - 客户端 `onHeartbeat` 仍是监管心跳,不等于 Pi meaningful progress。
27
+
28
+ 设计真源:`docs/design/dag-adaptive-liveness-and-supervision.md`。
29
+
20
30
  ## controller identity(冻结的已发布 controller)
21
31
 
22
32
  每次写入型 Feature/batch/Task/final verification 在任何目标仓库或 Task Pool 状态写入前,`LoopAgentClient` 解析并冻结 schemaVersion 1 identity(`ControllerIdentityV1`,定义在 `src/shared/package-metadata.ts`):
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Purpose
4
4
 
5
- 供 `generate-backend-pytest-pi` 使用。该节点是 `executor: "pi"`、`role: "implementer"`、`toolProfile: "write"` 的受限 writer,只把已经通过 Markdown gate 的最终用例转换为 pytest 资产。
5
+ 供 `generate-backend-pytest-pi` 使用。该节点是 `executor: "pi"`、`role: "implementer"`、`toolProfile: "write"` 的受限 writer,只把经过独立 Review 和 advisory Markdown 校验的最终用例转换为 pytest 资产;第 4 节点报告为 FAIL 时仍继续,但不得据此发明缺失行为。
6
6
 
7
7
  ## 当前合同
8
8
 
@@ -19,7 +19,10 @@ class TestOrderApi:
19
19
  ...
20
20
  ```
21
21
 
22
- - 断言只来自 `### 预期结果` / `### Expected Results`;setup 只来自 `### 前置条件`、`### 测试数据`、`### 自动化映射` 或对应历史英文分节。
22
+ - 断言只来自 `### 预期结果` / `### Expected Results`;setup 只来自必选 `### 前置条件`,以及存在时的 `### 测试数据`、`### 自动化映射` 或对应历史英文分节。
23
+ - 每条可自动化 Case 应在 `自动化映射` / `Automation Notes` 明确写出目标 pytest 脚本;第 6 节点只扫描这些脚本,不递归扫描无关历史 `test_*.py`。
24
+ - 每次接口请求必须通过统一日志 helper 或等价 client wrapper 打印请求与响应诊断信息:请求日志至少包含 HTTP method、URL/path、query 与 JSON/body/payload 参数摘要;响应日志至少包含 status code 与 JSON/text/body 结果摘要。日志必须能出现在 pytest stdout/stderr,不能改变断言或把失败伪装成通过。
25
+ - 日志输出前必须递归脱敏 `authorization`、`proxy-authorization`、`cookie`、`set-cookie`、`token`、`password`、`secret`、`api key`、`credential` 等 key/header;禁止打印完整 Authorization/Cookie。序列化后的 request/response body 必须有明确长度上限和截断标识,避免大对象淹没 pytest/JUnit/报告证据。
23
26
  - 禁止 `skip` / `xfail`、吞断言、宽异常静默通过、mock 替代真实目标、删除用例或弱化断言。
24
27
  - best-effort 清理只能捕获所选 HTTP client 实际抛出的窄 transport exception,例如 `requests.RequestException` 或 `urllib.error.URLError`;禁止 `except:`、`except Exception`、`except BaseException` 后 `pass`。
25
28
  - 同一 Case ID 可以由多个 pytest 函数覆盖;额外映射会进入 traceability 报告,但不能伪造未在 Markdown 中定义的业务场景。
@@ -28,9 +28,9 @@
28
28
  "Root artifacts/ is reserved for explicit exclusive write nodes, not read-only scout/reviewer output",
29
29
  "exclusive implementer nodes must use narrow, concrete writeSet paths; never keep ** or repo root",
30
30
  "Replace REPLACE/WITH/NARROW/IMPLEMENT/PATHS/** with concrete paths before executing the implementation writer",
31
- "backend-test-dag uses exactly 8 real top-level tasks and executes pytest exactly once.",
31
+ "backend-test-dag uses exactly 8 real top-level tasks and executes pytest exactly once over only the safe scripts explicitly mapped by final Markdown cases.",
32
32
  "Model nodes produce Markdown and pytest assets, never backend-test business JSON envelopes.",
33
- "Environment, Markdown validation, traceability, JUnit, HTML and execution facts are deterministic fail-closed evidence.",
33
+ "Environment, advisory Markdown validation, advisory traceability, JUnit, HTML and execution facts are deterministic evidence. Nodes 4 and 6 record findings without blocking nodes 5, 7 or 8.",
34
34
  "Only Markdown case generation/review may read source facts; pytest generation must not read source/**.",
35
35
  "Functional case IDs use BE-<MODULE>-<NNN>; production code/config, skip/xfail, repair and rerun are forbidden."
36
36
  ],
@@ -68,8 +68,8 @@
68
68
  "executorModels": {
69
69
  "pi": {
70
70
  "LOW": "gpt-5.3-codex-spark",
71
- "MED": "grok-4.5",
72
- "HIGH": "gpt-5.6-sol"
71
+ "MED": "glm-5.2",
72
+ "HIGH": "gpt-5.5"
73
73
  }
74
74
  },
75
75
  "tasks": [
@@ -125,7 +125,7 @@
125
125
  "artifacts/**"
126
126
  ],
127
127
  "outputContract": "Write a Chinese, human-readable testcase/md/README.md plus module Markdown case cards using BE-<MODULE>-<NNN>; keep machine IDs/literals exact and do not execute pytest or modify production code/config.",
128
- "subtask_prompt": "Read the upstream environment report. Generate a Markdown-first backend test strategy and cases under testcase/md/**.\n\nWrite human-readable content in Simplified Chinese by default. Keep English only for machine-readable IDs and technical literals such as Case/AC/REQ/BR IDs, HTTP methods, paths, field names, enum values, commands, filenames, code symbols and exact source citations.\n\nCreate testcase/md/README.md as the concise entry page: test objective, target/environment, isolation/cleanup, module summary and a linked case index table with Case ID, Chinese case name, scenario type, endpoint and expected status/result. Avoid repeating every case body in README.\n\nWrite each module as readable case cards. Every case starts with `## BE-<MODULE>-<NNN>|<中文用例名称>` and uses these Chinese headings: `### 测试目的`, `### 验收标准`, `### 需求依据`, `### 前置条件`, optional `### 测试数据`, `### 操作步骤`, `### 预期结果`, and `### 自动化映射`. API metadata may use a compact table under the case heading. The deterministic validator also accepts legacy English headings, but new output should use this Chinese presentation.\n\nPlace steps and their expected results in a compact readable table when that improves clarity; otherwise keep numbered executable steps and numbered/bulleted independently assertable results. Every result must name the observable HTTP status, response field/value, state transition or membership condition, never vague wording such as ‘符合预期’.\n\nIn `自动化映射`, record the planned script path and pytest function name when known. Put implementation-only restrictions in a concise `<details>` block rather than dominating the main case flow. Use only environment-supported fixtures/targets/isolation, record evidence gaps in Chinese, and do not emit JSON, pytest, or execute commands.\n\n## Derived task contract: 需求.md\n\n# Backend test\n- AC-001 proof\n\n## Authoritative reference index\n\n[]\n\nFor each index entry, use `readPath` for Pi read-tool calls and copy `path` exactly into Markdown Source References. Bound files under .harness/tasks/<taskId>/source/** are read-only inputs: reading them is allowed even though writing .harness/** is forbidden. Never resolve `path` relative to the repository root, search for substitutes, or fall back to docs/** when a bound read fails.\n\nRead only precise indexed references needed for AC/API/field/rule evidence; references remain authoritative over derived text."
128
+ "subtask_prompt": "Read the upstream environment report. Generate a Markdown-first backend test strategy and cases under testcase/md/**.\n\nWrite human-readable content in Simplified Chinese by default. Keep English only for machine-readable IDs and technical literals such as Case/AC/REQ/BR IDs, HTTP methods, paths, field names, enum values, commands, filenames, code symbols and exact source citations.\n\nCreate testcase/md/README.md as the concise entry page: test objective, target/environment, isolation/cleanup, module summary and a linked case index table with Case ID, Chinese case name, scenario type, endpoint and expected status/result. Avoid repeating every case body in README.\n\nWrite each module as readable case cards. Every case starts with `## BE-<MODULE>-<NNN>|<中文用例名称>`. The only sections required by the deterministic validator are `### 前置条件`, `### 操作步骤`, and `### 预期结果` (legacy English aliases remain accepted). Add `测试目的`, `验收标准`, `需求依据`, `测试数据`, and `自动化映射` when useful for human readability; every automatable case should explicitly name its target pytest script under `自动化映射` so traceability can scan only that script.\n\nPlace steps and their expected results in a compact readable table when that improves clarity; otherwise keep numbered executable steps and numbered/bulleted independently assertable results. Every result must name the observable HTTP status, response field/value, state transition or membership condition, never vague wording such as ‘符合预期’.\n\nIn `自动化映射`, record the planned script path and pytest function name when known. Put implementation-only restrictions in a concise `<details>` block rather than dominating the main case flow. Use only environment-supported fixtures/targets/isolation, record evidence gaps in Chinese, and do not emit JSON, pytest, or execute commands.\n\n## Derived task contract: 需求.md\n\n# Backend test\n- AC-001 proof\n\n## Authoritative reference index\n\n[]\n\nFor each index entry, use `readPath` for Pi read-tool calls and copy `path` exactly into Markdown Source References. Bound files under .harness/tasks/<taskId>/source/** are read-only inputs: reading them is allowed even though writing .harness/** is forbidden. Never resolve `path` relative to the repository root, search for substitutes, or fall back to docs/** when a bound read fails.\n\nRead only precise indexed references needed for AC/API/field/rule evidence; references remain authoritative over derived text."
129
129
  },
130
130
  {
131
131
  "id": "review-and-revise-backend-md-cases-pi",
@@ -149,7 +149,7 @@
149
149
  "artifacts/**"
150
150
  ],
151
151
  "outputContract": "Review source fidelity and directly revise only testcase/md/**; return concise Markdown, never JSON.",
152
- "subtask_prompt": "Independently review generated Markdown cases against each case 需求依据 and environment evidence. Treat the files as human-facing test documentation: require a clear Chinese name and scenario/purpose, compact metadata, readable steps/results, and a concise automation mapping while preserving exact machine IDs and technical literals.\n\nCheck AC completeness/meaning, endpoint, fields/shape, status/error codes, rules, states, documented boundaries/auth, positive/negative coverage, executable steps and assertable results. Reject avoidable English prose, duplicated bilingual wording, repeated boilerplate, oversized unstructured sections, vague results such as ‘符合预期’, and missing script/function mapping where it can be derived.\n\nCorrect testcase/md/** directly: add documented omissions, remove unsupported cases, fix mappings/expectations, merge duplicates, improve navigation/tables/Chinese wording, or record gaps in Chinese. Keep Case IDs, AC/REQ/BR IDs, HTTP methods, paths, fields, enum values, filenames, code symbols and source citations exact. The validator accepts Chinese and legacy English section aliases; retain or converge to the Chinese human-readable headings without losing structure.\n\nRead only precise referenced source paths plus requirement sections needed for uncovered ACs. Do not scan the repository, modify source/**, generate pytest, execute tests, or emit JSON.\n\n## Derived task contract: 需求.md\n\n# Backend test\n- AC-001 proof\n\n## Authoritative reference index\n\n[]\n\nFor each index entry, use `readPath` for Pi read-tool calls and keep `path` as the exact Markdown Source References citation. Bound files under .harness/tasks/<taskId>/source/** are read-only inputs: reading them is allowed even though writing .harness/** is forbidden. Never resolve `path` relative to the repository root, search for substitutes, or fall back to docs/** when a bound read fails."
152
+ "subtask_prompt": "Independently review generated Markdown cases against the task requirements and environment evidence. Treat the files as human-facing test documentation: require clear preconditions, executable steps and assertable expected results; improve names, purpose, metadata and automation mapping where useful while preserving exact machine IDs and technical literals.\n\nCheck AC completeness/meaning, endpoint, fields/shape, status/error codes, rules, states, documented boundaries/auth, positive/negative coverage, executable steps and assertable results. Reject avoidable English prose, duplicated bilingual wording, repeated boilerplate, oversized unstructured sections, vague results such as ‘符合预期’, and missing script/function mapping where it can be derived.\n\nCorrect testcase/md/** directly: add documented omissions, remove unsupported cases, fix mappings/expectations, merge duplicates, improve navigation/tables/Chinese wording, or record gaps in Chinese. Keep Case IDs, AC/REQ/BR IDs, HTTP methods, paths, fields, enum values, filenames, code symbols and source citations exact. The validator accepts Chinese and legacy English section aliases; retain or converge to the Chinese human-readable headings without losing structure.\n\nRead only precise referenced source paths plus requirement sections needed for uncovered ACs. Do not scan the repository, modify source/**, generate pytest, execute tests, or emit JSON.\n\n## Derived task contract: 需求.md\n\n# Backend test\n- AC-001 proof\n\n## Authoritative reference index\n\n[]\n\nFor each index entry, use `readPath` for Pi read-tool calls and keep `path` as the exact Markdown Source References citation. Bound files under .harness/tasks/<taskId>/source/** are read-only inputs: reading them is allowed even though writing .harness/** is forbidden. Never resolve `path` relative to the repository root, search for substitutes, or fall back to docs/** when a bound read fails."
153
153
  },
154
154
  {
155
155
  "id": "validate-backend-md-cases-shell",
@@ -169,8 +169,8 @@
169
169
  ".harness/dag-runs/**",
170
170
  "artifacts/**"
171
171
  ],
172
- "outputContract": "Run-owned reports/backend-md-case-validation.md proving final Markdown quality and safety.",
173
- "subtask_prompt": "Fail closed on missing/duplicate IDs, sections, AC coverage, source references, executable steps, assertable results, placeholders or secret-shaped content.",
172
+ "outputContract": "Run-owned reports/backend-md-case-validation.md with PASS/FAIL advisory findings; downstream execution continues.",
173
+ "subtask_prompt": "Record advisory findings for missing/duplicate IDs, missing core sections (preconditions, steps, expected results), AC coverage, executable steps, assertable results or placeholders. Do not validate source-reference existence. Keep quality findings advisory, but fail closed after writing the report when secret-shaped values are detected so downstream pytest/report nodes cannot consume them.",
174
174
  "shell": {
175
175
  "commands": [],
176
176
  "backendTestPipeline": "markdown-cases",
@@ -203,7 +203,7 @@
203
203
  "artifacts/**"
204
204
  ],
205
205
  "outputContract": "Convert every final automatable Markdown case into pytest assets whose actual test function region contains the exact Case ID, preferably in the function name or docstring; no JSON and no pytest execution.",
206
- "subtask_prompt": "Convert validated testcase/md/** to pytest using upstream environment and validation evidence plus only bounded pytest config/conftest.\n\nEnsure every final Markdown Case ID appears in at least one real pytest test function or pytest test class method region, preferably as `test_BE_<MODULE>_<NNN>_<description>` and in that function/method docstring. Module-level functions and class-based pytest methods are both supported. Multiple test functions may cover one Case ID; assertions come only from 预期结果/Expected Results and setup comes only from 前置条件/测试数据/自动化映射 or their legacy English aliases.\n\nDo not read source/**, add cases, reassign ACs, modify conftest/config/production code, use skip/xfail, swallow assertions, execute pytest, or emit JSON. For best-effort cleanup, catch only the narrow transport exception actually raised by the selected HTTP client (for example `requests.RequestException` or `urllib.error.URLError`); never use bare `except`, `Exception`, or `BaseException` with `pass`."
206
+ "subtask_prompt": "Convert testcase/md/** to pytest using upstream environment and advisory validation evidence plus only bounded pytest config/conftest. A FAIL advisory report does not authorize inventing missing behavior; use the final Markdown facts that are present.\n\nEnsure every final Markdown Case ID appears in at least one real pytest test function or pytest test class method region, preferably as `test_BE_<MODULE>_<NNN>_<description>` and in that function/method docstring. Module-level functions and class-based pytest methods are both supported. Multiple test functions may cover one Case ID; assertions come only from 预期结果/Expected Results and setup comes only from 前置条件 plus any optional 测试数据/自动化映射 or their legacy English aliases.\n\nGenerate a reusable HTTP logging helper (or equivalent client wrapper) and call it for every interface request. The request log must include method, URL/path, and request parameters (query plus JSON/body/payload summary). The response log must include status code and response result (JSON/text/body summary), and both records must be visible in pytest stdout/stderr without changing assertions.\n\nCompare timestamps and other semantically equivalent protocol values by parsed meaning, not byte-for-byte serialization. In particular, normalize valid ISO-8601 instants before equality/order assertions so differences such as omitted trailing fractional seconds do not create TestBug failures; preserve exact-string assertions only when the Markdown explicitly requires representation equality.\n\nBefore logging, recursively redact sensitive keys and header values including authorization, proxy-authorization, cookie, set-cookie, token, password, secret, api key and credentials. Never print full Authorization/Cookie values. Apply bounded truncation to serialized request and response bodies (with an explicit truncation marker) so large payloads cannot flood pytest or report artifacts.\n\nDo not read source/**, add cases, reassign ACs, modify conftest/config/production code, use skip/xfail, swallow assertions, execute pytest, or emit JSON. For best-effort cleanup, catch only the narrow transport exception actually raised by the selected HTTP client (for example `requests.RequestException` or `urllib.error.URLError`); never use bare `except`, `Exception`, or `BaseException` with `pass`."
207
207
  },
208
208
  {
209
209
  "id": "backend-test-traceability-gate-shell",
@@ -223,8 +223,8 @@
223
223
  ".harness/dag-runs/**",
224
224
  "artifacts/**"
225
225
  ],
226
- "outputContract": "Run-owned reports/backend-test-traceability.md proving every real Markdown Case ID is covered by at least one pytest test function.",
227
- "subtask_prompt": "Fail closed only when a real Markdown case heading has no associated pytest test function or class method. Accept exact Case IDs in the function/method name or its decorator/body/docstring region; report multiple mappings and extra automation Case IDs without blocking. Continue to reject skip/xfail or swallowed exceptions.",
226
+ "outputContract": "Run-owned reports/backend-test-traceability.md with PASS/FAIL advisory findings for Markdown Case to mapped pytest script/symbol coverage.",
227
+ "subtask_prompt": "Record advisory findings when a real Markdown case heading has no associated pytest test function or class method in the script explicitly mapped by that Markdown case, or when a mapped HTTP test script lacks request parameters logging, response result logging, recursive redaction or bounded truncation evidence. Accept exact Case IDs in the function/method name or its decorator/body/docstring region. Do not scan unrelated test_*.py files and do not block pytest execution.",
228
228
  "shell": {
229
229
  "commands": [],
230
230
  "backendTestPipeline": "markdown-traceability",
@@ -250,11 +250,11 @@
250
250
  ".harness/dag-runs/**",
251
251
  "artifacts/**"
252
252
  ],
253
- "outputContract": "One pytest execution producing valid JUnit, self-contained HTML and reports/backend-test-facts.md; exit 0/1 with valid evidence continues.",
254
- "subtask_prompt": "Execute pytest exactly once. Validate JUnit, render the primary self-contained Chinese HTML report from the same JUnit plus final Markdown case metadata without rerun, list every case with name/scenario/script/function/result/duration, and preserve failure summaries plus expandable technical details as facts.",
253
+ "outputContract": "One scoped pytest execution over Markdown-mapped scripts producing valid JUnit with per-case captured output, self-contained HTML and reports/backend-test-facts.md; exit 0/1 with valid evidence continues.",
254
+ "subtask_prompt": "Resolve the final Markdown Automation Notes/自动化映射 to a unique, safe set of testcase/**/test_*.py targets and execute only those scripts exactly once. Validate JUnit, then render the primary self-contained Chinese HTML report from the same JUnit plus final Markdown case metadata without rerun. Keep 测试结论, quality status, failure overview, and a polished per-case result card with concise scenario, automation test name, result, duration, and redacted bounded HTTP request parameters/response results for both passed and failed cases. Do not render a technical/execution evidence section in HTML; retain auditable paths and hashes in facts.",
255
255
  "shell": {
256
256
  "commands": [
257
- "mkdir -p \"${HARNESS_DAG_RUN_DIR}/reports\"; PYTHONUTF8=1 PYTHONIOENCODING=utf-8 PYTHONDONTWRITEBYTECODE=1 python -m pytest testcase/ -v -p no:cacheprovider --junitxml=\"${HARNESS_DAG_RUN_DIR}/reports/backend-test.junit.xml\"; STATUS=$?; printf \"%s\" \"${STATUS}\" > \"${HARNESS_DAG_RUN_DIR}/reports/backend-test-pytest-exit.txt\"; if { [ \"${STATUS}\" -eq 0 ] || [ \"${STATUS}\" -eq 1 ]; } && [ -s \"${HARNESS_DAG_RUN_DIR}/reports/backend-test.junit.xml\" ]; then exit 0; fi; exit \"${STATUS}\""
257
+ "mkdir -p \"${HARNESS_DAG_RUN_DIR}/reports\"; echo \"pytest targets are resolved at runtime from final Markdown 自动化映射\""
258
258
  ],
259
259
  "backendTestPipeline": "markdown-execute-html",
260
260
  "cwd": ".",
@@ -284,7 +284,7 @@
284
284
  "artifacts/**"
285
285
  ],
286
286
  "outputContract": "Final Markdown report and L-5 conclusion under docs/test-reports/**; no JSON.",
287
- "subtask_prompt": "Generate the final Markdown report from upstream facts and run-owned environment, case-validation, traceability, JUnit and HTML evidence. Do not emit JSON.\n\nInclude environment, case quality/review, automation mapping, exact pytest facts, failure classification/analysis, risks, regression recommendations, evidence paths/hashes, coverage/stability availability, and L-5 READY/NOT READY.\n\nNever override Shell/JUnit facts. One run cannot prove FlakyTest. Missing coverage/stability is Unavailable. L-5 requires pass=100%, AC=100%, automation>=90%, stability>=95% n>=5, line>=80%, branch>=70%, skipped=0 and no blocking Critical risk.\n\nWrite only under docs/test-reports/**."
287
+ "subtask_prompt": "Generate the final Markdown report from upstream facts and run-owned environment, advisory case-validation, advisory traceability, JUnit and HTML evidence. Do not emit JSON.\n\nUse this exact human-facing section order: 测试结论 → 执行概览 → 质量校验 → 失败分析 → 风险与建议 → 证据与 L-5. Put the decision and key numbers first, use compact tables/bullets, and keep headings concise. Do not paste entire upstream reports, duplicate per-case tables already present in facts, or repeat the same evidence in multiple sections; link to paths/hashes and quote only the findings needed for the conclusion.\n\nAlways state the exact PASS/FAIL status and findings from nodes 4 and 6. Their FAIL status does not block pytest, but it must remain visible as a quality/traceability risk and must never be rewritten as PASS.\n\nInclude environment, case quality/review, automation mapping, exact pytest facts, failure classification/analysis, risks, regression recommendations, evidence paths/hashes, coverage/stability availability, and L-5 READY/NOT READY.\n\nNever override Shell/JUnit facts. One run cannot prove FlakyTest. Missing coverage/stability is Unavailable. L-5 requires pass=100%, AC=100%, automation>=90%, stability>=95% n>=5, line>=80%, branch>=70%, skipped=0 and no blocking Critical risk.\n\nWrite only under docs/test-reports/**."
288
288
  }
289
289
  ],
290
290
  "sourceBinding": {
package/harness.json CHANGED
@@ -59,7 +59,7 @@
59
59
  "pi": {
60
60
  "description": "Pi planning, review, diagnosis, and bounded writing when DAG toolProfile=write",
61
61
  "LOW": "gpt-5.3-codex-spark",
62
- "MED": "grok-4.5",
62
+ "MED": "glm-5.2",
63
63
  "HIGH": "gpt-5.6-sol"
64
64
  }
65
65
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tea-agent/loop-agent",
3
- "version": "0.20.1",
3
+ "version": "0.21.0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "loop-agent": "bin/loop-agent.js",
@@ -326,6 +326,8 @@ loop-agent dag resume --run-id <run-id> # approve 后继续
326
326
  - operator 聚焦最新 paused run 用 `dag report --paused-latest`(等同 `--lifecycle paused --latest`;勿与显式 `--lifecycle` 并用)。
327
327
  - 需 operator 关注的 run 用 `dag report --failed-only`、`--latest`、`--action <recovery-action>` 收窄。category→action 映射见 `ai_workspace/loop-agent/agent-dag-recovery-playbook.md`。
328
328
  - 只读扫描 `.harness/dag-runs/` 下所有 run 的生命周期 health issue 与建议 action 用 `dag doctor`(`advisoryOnly: true`;不 mutate facts)。
329
+ - `dag status` / `dag doctor` 的 runner heartbeat 只表示 lease;Pi meaningful progress 由 Provider/tool/output 活动决定。节点可显示 `quiet`、`suspected-stall`、`probing` 或 `needs-attention`,不要仅凭运行时长手工结束。
330
+ - Pi 默认 4h absolute max,`agent-worker` 默认不设置外层 `run-dag` wall-clock;显式 `worker.timeout_ms` 仍是 hard timeout。`termination-unconfirmed` 表示旧 attempt 的退出无法确认,禁止自动 retry,先保留现场并完成 operator 对账。
329
331
  - approve/resume 前用 `dag status --run-id <id>` 看单次 lifecycle、`approvalFlow`、`hasHumanApproval`。
330
332
  - lifecycle、raw status 与 liveness 冲突时先用 `dag reconcile-run --run-id <id>` 只读检查。只有 runner 已证明停止且 operator 明确给出 `supersede|abandon` 与 reason 时才允许收口;它保存原始 state,不把未执行节点标成成功。
331
333
  - task status、source/artifacts、DAG outcome、verification 记录可能 drift 时用 `dag reconcile-tasks --glob '<pattern>'`。默认仅报告;`--patch` 显式且不能伪造 verification evidence。
@@ -19,9 +19,9 @@
19
19
  前端专用链保留独立 contract/scout;plan 同时选择 Mock/API 策略并输出结构化 implementation contract。design initial pass 直接使用原计划,只有 request-revision 才运行 revision/final review;small-risk 只执行一次 design review。`frontend-prewrite-gate-shell` 合并生效 verdict、REQ/BR/AC 覆盖、Mock policy 和 contract 物化,是唯一写入授权。实现后 `frontend-verify-assess-shell` 合并 Mock/static/behavior/trace/assessment;只有 `eligible=true` 才运行同 writeSet 的 repair 和 `frontend-reverify-shell`。`frontend-review-context-shell` 绑定真实 diff 与有效验证证据后再 review/closeout。standard/high-risk 为 15 个顶层节点,small-risk 为 13;绿色路径执行 11 个节点、7 次 Pi。生成期 blocked Mock 只生成一个确定性阻塞节点且没有 writer。
20
20
 
21
21
 
22
- > Backend-test Markdown-first:先由确定性环境 Shell 检查 clean env 中 Python/pytest、常见配置、conftest/fixture、test root、server entry 和 HTML renderer,失败时不消耗模型调用。随后 Pi 生成中文 README 索引与模块用例卡片并独立 Review `testcase/md/**`,Shell 校验 Case IDAC/source traceability、中文或历史英文分节、步骤、可断言预期与 secret 安全;pytest writer 仅转换最终 Markdown,不重读 `source/**`。traceability 同时支持模块级函数和 pytest 测试类方法;pytest 只运行一次,生成 JUnit,并把 Markdown 名称/场景/脚本映射与同一 JUnit 合成为逐条中文 self-contained HTML 主报告和 Markdown facts。最终 Pi 只解释事实并生成 Markdown 报告和 L-5 结论。active 流程不要求模型生成 backend-test 业务 JSON。
22
+ > Backend-test Markdown-first:先由确定性环境 Shell 检查 clean env 中 Python/pytest、常见配置、conftest/fixture、test root、server entry 和 HTML renderer,失败时不消耗模型调用。随后 Pi 生成中文 README 索引与模块用例卡片并独立 Review `testcase/md/**`。第 4 节点只把前置条件、操作步骤、预期结果作为必选章节,并检查 Case ID、业务 AC、步骤/预期和占位措辞;不校验需求来源引用有效性或 Markdown sensitive-shaped 内容。pytest writer 为每次真实接口调用记录脱敏、有界的请求 method/URL/参数摘要和响应 status/body 摘要。第 6 节点只扫描每条 Case 明确映射的 pytest 脚本,同时支持模块级函数和 pytest class 方法,并把缺少请求/响应日志、递归脱敏或有界截断证据记录为 advisory。第 4/6 节点均写 PASS/FAIL findings 而不阻断后续;pytest 仍只运行一次,生成 JUnit,并把 Markdown 名称/场景/脚本映射与同一 JUnit 合成为按测试概览、质量校验、失败概览、用例执行明细和技术证据组织的中文 self-contained HTML Markdown facts。最终 Pi 按固定简洁结构汇总 advisory 状态、执行事实和 L-5 结论。active 流程不要求模型生成 backend-test 业务 JSON。
23
23
 
24
- 显式专用 `taskKind` 保持兼容并优先于任务源分类。`backend-test` 选择固定 **8 个真实顶层节点**的 Markdown-first DAG:环境硬门、Markdown cases、独立 Review/修订、Markdown gate、pytest 转换、确定性 traceability、单次 pytest + JUnit/HTML/facts、最终 Markdown 报告与 L-5。历史 JSON contract/materializer 可继续读取旧 DAG,但新 runtime/template 不再生成模型业务 JSON。`knowledge-sync` 与 `knowledge-graph-bootstrap` 继续通过各自显式 taskKind 选择知识回写/图谱开荒 DAG。治理等级仍由 `minimal|standard|reviewed|supervised` 推断。
24
+ 显式专用 `taskKind` 保持兼容并优先于任务源分类。`backend-test` 选择固定 **8 个真实顶层节点**的 Markdown-first DAG:环境硬门、Markdown cases、独立 Review/修订、第 4 节点 advisory Markdown 校验、pytest 转换、第 6 节点 scoped advisory traceability、单次 pytest + JUnit/HTML/facts、最终 Markdown 报告与 L-5。历史 JSON contract/materializer 可继续读取旧 DAG,但新 runtime/template 不再生成模型业务 JSON。`knowledge-sync` 与 `knowledge-graph-bootstrap` 继续通过各自显式 taskKind 选择知识回写/图谱开荒 DAG。治理等级仍由 `minimal|standard|reviewed|supervised` 推断。
25
25
 
26
26
  ### DAG workflow 层级
27
27