@tea-agent/loop-agent 0.11.0 → 0.13.0-alpha.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.
- package/CHANGELOG.md +74 -1
- package/README.md +33 -4
- package/dist/application/dag/generate-task-dag.js +45 -0
- package/dist/application/dag/run-dag.js +10 -0
- package/dist/application/dag/validate-dag.js +11 -0
- package/dist/cli/command-definitions.js +10 -3
- package/dist/commands/init.js +74 -7
- package/dist/commands/knowledge.js +129 -31
- package/dist/governance/manifest-types.js +3 -0
- package/dist/shared/package-metadata.js +135 -0
- package/dist/task/config-types.js +6 -1
- package/dist/worker/cli.js +99 -2
- package/dist/worker/delivery/package.js +3 -3
- package/dist/worker/feature/decision-loader.js +37 -6
- package/dist/worker/feature/next-action.js +10 -2
- package/dist/worker/feature/ready-plan-projection.js +81 -0
- package/dist/worker/feature/reducer.js +2 -1
- package/dist/worker/feature/review.js +19 -2
- package/dist/worker/feature/run.js +27 -2
- package/dist/worker/follow-up/approve.js +5 -2
- package/dist/worker/follow-up/factory.js +1 -1
- package/dist/worker/observability/event-history.js +216 -0
- package/dist/worker/observability/read-model.js +552 -118
- package/dist/worker/observe/paths.js +17 -0
- package/dist/worker/observe/routes.js +310 -23
- package/dist/worker/observe/server.js +59 -1
- package/dist/worker/observe/spec-evidence.js +281 -0
- package/dist/worker/observe/static/api.js +46 -0
- package/dist/worker/observe/static/app.js +120 -2598
- package/dist/worker/observe/static/constants.js +148 -0
- package/dist/worker/observe/static/copy.js +67 -0
- package/dist/worker/observe/static/dag-helpers.js +172 -0
- package/dist/worker/observe/static/dag-model.js +72 -0
- package/dist/worker/observe/static/dom.js +61 -0
- package/dist/worker/observe/static/format-pool.js +67 -0
- package/dist/worker/observe/static/format.js +292 -0
- package/dist/worker/observe/static/index.html +300 -82
- package/dist/worker/observe/static/kpi.js +94 -0
- package/dist/worker/observe/static/relations.js +133 -0
- package/dist/worker/observe/static/router.js +93 -0
- package/dist/worker/observe/static/run-processing.js +148 -0
- package/dist/worker/observe/static/shell-chrome.js +68 -0
- package/dist/worker/observe/static/state.js +253 -0
- package/dist/worker/observe/static/styles.css +1731 -495
- package/dist/worker/observe/static/views/batch.js +227 -0
- package/dist/worker/observe/static/views/dag-graph.js +172 -0
- package/dist/worker/observe/static/views/dag-inspector.js +596 -0
- package/dist/worker/observe/static/views/dag.js +362 -0
- package/dist/worker/observe/static/views/dashboard.js +445 -0
- package/dist/worker/observe/static/views/failures.js +143 -0
- package/dist/worker/observe/static/views/feature.js +492 -0
- package/dist/worker/observe/static/views/pool.js +350 -0
- package/dist/worker/observe/static/views/run.js +453 -0
- package/dist/worker/observe/static/views/session-timeline.js +205 -0
- package/dist/worker/observe/static/views/shell.js +7 -0
- package/dist/worker/observe/static/views/task.js +314 -0
- package/dist/worker/observe/static/views/timeline.js +163 -0
- package/dist/worker/pool/doctor.js +165 -0
- package/dist/worker/pool/migrate-state.js +303 -0
- package/dist/worker/pool/run-store.js +205 -17
- package/dist/worker/pool/types.js +17 -1
- package/dist/worker/pool/validation.js +100 -15
- package/dist/worker/report/morning-report.js +12 -2
- package/dist/worker/runner/run-ready.js +41 -26
- package/dist/worker/task-graph/ready-planner.js +136 -0
- package/dist/workflows/dag/controller-identity.js +104 -0
- package/dist/workflows/dag/convergence/controller.js +16 -8
- package/dist/workflows/dag/failure-routing.js +12 -1
- package/dist/workflows/dag/init-hybrid.js +1233 -11
- package/dist/workflows/dag/node-execution.js +123 -29
- package/dist/workflows/dag/repair-artifact.js +91 -0
- package/dist/workflows/dag/report.js +50 -0
- package/dist/workflows/dag/retry-policy.js +138 -0
- package/dist/workflows/dag/runner.js +32 -0
- package/dist/workflows/dag/runtime-contract.js +87 -0
- package/dist/workflows/dag/skill-snapshot.js +2 -0
- package/dist/workflows/dag/types.js +45 -1
- package/dist/workflows/dag/validate.js +68 -4
- package/docs/README.md +1 -1
- package/docs/agent-dag-recovery-playbook.md +9 -0
- package/docs/agent-dag-runner.md +26 -1
- package/docs/architecture/dag-execution.md +6 -0
- package/docs/architecture/evolution.md +7 -5
- package/docs/architecture/facts-and-state.md +15 -2
- package/docs/architecture/worker-and-feature.md +6 -2
- package/docs/decisions/README.md +3 -0
- package/docs/design/README.md +12 -3
- package/docs/exec-plans/active/README.md +2 -2
- package/docs/exec-plans/completed/README.md +12 -0
- package/docs/feature-workflow.md +108 -2
- package/docs/loop-agent-harness.md +15 -4
- package/docs/progress/README.md +22 -0
- package/docs/reports/README.md +14 -2
- package/docs/templates/agent-dag-report.schema.json +17 -0
- package/docs/templates/agent-dag.schema.json +69 -1
- package/docs/templates/agent-dag.supervised-implementation.json +8 -2
- package/docs/templates/backend-test-dag.generate-pytest.prompt.md +139 -0
- package/docs/templates/backend-test-dag.json +288 -0
- package/docs/templates/backend-test-dag.retrospect.prompt.md +125 -0
- package/docs/templates/backend-test-dag.review-cases.prompt.md +81 -0
- package/docs/templates/knowledge-graph-bootstrap-dag.json +118 -0
- package/docs/templates/knowledge-sync-dag.json +177 -0
- package/docs/templates/knowledge-sync-draft.schema.json +71 -0
- package/docs/verification-matrix.md +2 -1
- package/package.json +8 -2
- package/scripts/kb-bootstrap-init-skeleton.sh +239 -0
- package/scripts/kb-graph-incremental-prepare.mjs +372 -0
- package/scripts/kb-graph-incremental-prepare.sh +5 -0
- package/scripts/kb-graph-materialize.mjs +105 -0
- package/scripts/kb-graph-materialize.sh +4 -0
- package/scripts/kb-graph-promote.mjs +153 -0
- package/scripts/kb-graph-promote.sh +4 -0
- package/scripts/kb-query.mjs +554 -0
- package/scripts/kb-query.sh +5 -0
- package/skills/agent-worker/SKILL.md +3 -1
- package/skills/agent-worker/references/agent-worker-operator.md +18 -1
- package/skills/frontend-design-review/SKILL.md +26 -24
- package/skills/frontend-implementation/SKILL.md +29 -26
- package/skills/frontend-implementation/references/node-contracts.md +50 -19
- package/skills/frontend-review/SKILL.md +1 -1
- package/skills/loop-agent/references/command-reference.md +2 -0
- package/skills/loop-agent/references/hybrid-dag.md +22 -3
- package/skills/loop-agent/references/verification-and-failure-handling.md +6 -0
|
@@ -3,9 +3,9 @@ name: frontend-implementation
|
|
|
3
3
|
description: >-
|
|
4
4
|
Use for frontend contract, scout, plan, and implementation DAG nodes.
|
|
5
5
|
references:
|
|
6
|
-
- path: references/node-contracts.md
|
|
7
|
-
required: true
|
|
8
|
-
maxChars:
|
|
6
|
+
- path: references/node-contracts.md
|
|
7
|
+
required: true
|
|
8
|
+
maxChars: 3200
|
|
9
9
|
- path: references/design-spec.md
|
|
10
10
|
required: true
|
|
11
11
|
maxChars: 3000
|
|
@@ -16,36 +16,39 @@ references:
|
|
|
16
16
|
|
|
17
17
|
# Frontend Implementation
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
`frontend-implement-pi`. Read
|
|
19
|
+
For `frontend-contract-pi`, `frontend-scout-pi`, `frontend-plan-pi`, and
|
|
20
|
+
`frontend-implement-pi`. Read all required references first.
|
|
21
21
|
|
|
22
22
|
## Source And Evidence Rules
|
|
23
23
|
|
|
24
|
-
Use task
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
Use task sources/references, constraints, then `task.json`. Resolve design rules in
|
|
25
|
+
`design-spec.md` order: query the knowledge base; if unavailable, failed, or empty,
|
|
26
|
+
search `<repoRoot>/openSpec/**`; only then use other repository evidence.
|
|
27
|
+
|
|
28
|
+
- Cite paths/symbols or tight lines; label assumptions, questions, and missing evidence.
|
|
29
|
+
- Never invent conventions, APIs, tokens, commands, or knowledge-base results.
|
|
30
|
+
- Record `knowledge-base`, `openSpec fallback`, `repository fallback`, or `unavailable`, plus evidence/conflicts.
|
|
31
|
+
|
|
32
|
+
### Observable Spec Retrieval
|
|
29
33
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
-
|
|
33
|
-
|
|
34
|
+
Scout/planner nodes must `grep`/`find` relevant `openSpec/**` and skill references,
|
|
35
|
+
then explicitly `read` every consulted spec (`SKILL.md`, `design-spec.md`,
|
|
36
|
+
`code-standards.md`, etc.). Observe derives evidence from session tool events: only
|
|
37
|
+
successful paired `read` calls count as “已读取规范文件”; summaries do not. If the
|
|
38
|
+
knowledge base is unavailable, record `openSpec/**` search hits before repo fallback.
|
|
34
39
|
|
|
35
40
|
## Implementation Discipline
|
|
36
41
|
|
|
37
|
-
-
|
|
38
|
-
- Reuse confirmed components, tokens, helpers, APIs, mocks, schemas, and
|
|
39
|
-
-
|
|
40
|
-
- Cover
|
|
41
|
-
- Keep state
|
|
42
|
-
-
|
|
43
|
-
- Never relax lint/type/test/build configuration or write unauthorized generated output.
|
|
42
|
+
- Project specs and repo-local skills are authoritative within scope.
|
|
43
|
+
- Reuse confirmed components, tokens, helpers, APIs, mocks, schemas, and tests.
|
|
44
|
+
- Add dependencies only when task and approved plan allow them.
|
|
45
|
+
- Cover success/error/loading/empty/disabled/permission/boundary states; justify N/A.
|
|
46
|
+
- Keep state/validation testable. Writers stay in `writeSet`, preserve unrelated behavior, and update tests.
|
|
47
|
+
- Never relax lint/type/test/build config or write unauthorized generated output.
|
|
44
48
|
|
|
45
49
|
## Output And Failure Rules
|
|
46
50
|
|
|
47
|
-
- Follow
|
|
48
|
-
-
|
|
49
|
-
-
|
|
50
|
-
-
|
|
51
|
-
- Implementation may report attempted checks, but completion requires fresh downstream shell evidence.
|
|
51
|
+
- Follow `node-contracts.md` headings exactly. Read-only nodes return Markdown and never edit files.
|
|
52
|
+
- Missing input blocks work when proceeding would guess behavior, compliance, write bounds, or verification.
|
|
53
|
+
- Preserve protocol tokens, commands, paths, identifiers, and output language.
|
|
54
|
+
- Attempted checks may be reported; completion needs fresh downstream shell evidence.
|
|
@@ -1,32 +1,63 @@
|
|
|
1
1
|
# Frontend Node Contracts
|
|
2
2
|
|
|
3
|
+
Pre-implementation nodes are read-only. Preserve IDs, protocol tokens, source
|
|
4
|
+
labels, language, and named output headings.
|
|
5
|
+
|
|
3
6
|
## `frontend-contract-pi`
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
-
|
|
9
|
-
|
|
8
|
+
Read task sources, constraints, config, and references. Define scope, non-goals,
|
|
9
|
+
routes/components, runtime, flows, criteria, states, risks, and verification. Never
|
|
10
|
+
turn a guess into a requirement. Output: `Scope`,
|
|
11
|
+
`Non-goals`, `Acceptance Criteria`, `UI States`, `Target Runtime Environment`,
|
|
12
|
+
`Risks`, `Verification Expectations`.
|
|
10
13
|
|
|
11
14
|
## `frontend-scout-pi`
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
Inspect routes, components, styles/tokens, state/data, APIs/mocks, scripts, tests,
|
|
17
|
+
and assets. Separate facts, inferences, and gaps. Query knowledge-base;
|
|
18
|
+
if absent/failed/unmatched, search and read `<repoRoot>/openSpec/**` before repo
|
|
19
|
+
conventions. Record source, query/terms, and paths. Output: `Frontend Stack`,
|
|
20
|
+
`Routes`, `Components`, `Styling System`, `Existing Design Conventions`,
|
|
21
|
+
`State / Data Flow`, `Test Entry Points`, `Reuse Opportunities`, `Risks`.
|
|
18
22
|
|
|
19
23
|
## `frontend-plan-pi`
|
|
20
24
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
Map each criterion to implementation and verification. Name in-bound files; define
|
|
26
|
+
states, reuse, interactions, dependencies, and commands. Apply `openSpec/` rules
|
|
27
|
+
when knowledge-base fails; ask only for material conflicts. Output: `Implementation Steps`, `Target
|
|
28
|
+
Files`, `UI State Handling`, `Styling / Component Strategy`, `Interaction Notes`,
|
|
29
|
+
`Dependency Policy`, `Verification Plan`, `Residual Risks`.
|
|
30
|
+
|
|
31
|
+
## First design protocol gate
|
|
32
|
+
|
|
33
|
+
`frontend-first-design-gate-shell` reads `frontend-design-gate-pi`'s first
|
|
34
|
+
non-empty line. It accepts only `VERDICT: pass` or `VERDICT: request-revision` and
|
|
35
|
+
blocks malformed output. It never authorizes writes; request-revision enters plan
|
|
36
|
+
revision. Line mode: `first-verdict-line`.
|
|
37
|
+
|
|
38
|
+
## `frontend-plan-revision-pi`
|
|
39
|
+
|
|
40
|
+
Consume the original plan and first review findings. On first-gate pass, output
|
|
41
|
+
`PASS_NO_REVISION_NEEDED`; on request-revision, address every Required Plan
|
|
42
|
+
Correction in a complete plan with the plan headings above. Always `read-only`;
|
|
43
|
+
never edit code, docs, or artifacts.
|
|
44
|
+
|
|
45
|
+
## Final design review and gate
|
|
46
|
+
|
|
47
|
+
`frontend-final-design-review-pi` rechecks the original plan for
|
|
48
|
+
`PASS_NO_REVISION_NEEDED`, otherwise verifies every correction and rejects any
|
|
49
|
+
remaining/new gap. Its first non-empty line is exactly `VERDICT: pass` or
|
|
50
|
+
`VERDICT: request-revision`.
|
|
51
|
+
|
|
52
|
+
`frontend-final-design-gate-shell` reads that verdict and accepts only
|
|
53
|
+
`VERDICT: pass`. It is the sole write authorization. Failure routes to
|
|
54
|
+
`ContractMismatch` / `frontend-plan-revision-and-rerun`, never `ProductBug` /
|
|
55
|
+
`dev-fix`. Line mode: `first-verdict-line`.
|
|
26
56
|
|
|
27
57
|
## `frontend-implement-pi`
|
|
28
58
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
59
|
+
Depends directly on final gate, revision plan, and final review. After pass, re-read
|
|
60
|
+
current files and implement only the approved plan inside `writeSet`; stop on
|
|
61
|
+
forbidden paths or blocking guesses. Reuse primitives and update tests. Output:
|
|
62
|
+
`Changed Files`, `Implemented Behavior`, `UI States Covered`, `Styling / Component
|
|
63
|
+
Notes`, `Verification Attempted`, `Residual Risks`.
|
|
@@ -25,7 +25,7 @@ required check, forbidden write, or unmet acceptance criterion forces revision.
|
|
|
25
25
|
- Inspect every changed file against allowed, forbidden, and approved write scope.
|
|
26
26
|
- Map criteria to behavior, applicable UI states, tests, and shell evidence.
|
|
27
27
|
- Review state/data flow, validation, async/error behavior, components/design, responsive behavior, accessibility, dependencies, maintenance, and regression risk when applicable.
|
|
28
|
-
- Component/design claims require traceable knowledge-base evidence or, after connection/query failure or no match, relevant `<repoRoot>/openSpec/**` evidence. The connector format is TODO; never claim a query or fallback search without evidence.
|
|
28
|
+
- Component/design claims require traceable knowledge-base evidence or, after connection/query failure or no match, relevant `<repoRoot>/openSpec/**` evidence. The connector format is TODO; never claim a query or fallback search without evidence. Execute explicit `grep`/`find` to locate spec files and `read` to load them before referencing their rules. Only successful `read` tool calls are observable as "已读取规范文件" in the spec-evidence inspector.
|
|
29
29
|
- Treat shell exit status as authoritative. Do not edit files.
|
|
30
30
|
|
|
31
31
|
## Evidence And Output
|
|
@@ -276,6 +276,7 @@ loop-agent dag resume --run-id <run-id> # approve 后继续
|
|
|
276
276
|
- Decision Gate prompt 可用 `buildDagDecisionGateEvidence()`(`src/workflows/dag/decision-evidence.ts`)做与 `dag report --json`、`docs/templates/agent-dag-report.schema.json` 对齐的只读摘要;不 mutate run state,不执行 retry/resume。
|
|
277
277
|
- 仅当有意在 `.harness/dag-runs/active/` 下要 active run snapshot 时用 `run-dag --dry-run`。
|
|
278
278
|
- task source 应从 `harness.json.workflowPolicy.dag.profileRouting` 与确定性 candidate `governanceProfile` 选 standard / review-gated / supervised template 时用 `dag run-task --profile auto`。无 `--profile` 仅用于旧 standard-compatible 输出;强制 template family 用 `--profile minimal|standard|reviewed|supervised`。
|
|
279
|
+
- 业务专用 DAG 通过 `task.json.taskKind` 选择,不扩充 governance profile:`frontend-implementation` 选择前端实现模板,`backend-test` 选择需求分析 → 功能用例 → 评审 → pytest 生成/执行 → 复盘的后端测试模板。
|
|
279
280
|
|
|
280
281
|
### Saved Dynamic Workflow operator UX
|
|
281
282
|
```bash
|
|
@@ -391,6 +392,7 @@ agent-worker report metrics --repo <repo-root> --month <YYYY-MM> [--json]
|
|
|
391
392
|
agent-worker task draft-followup <task-id> --worker-run-id <id> --feature-dir <feature-dir> --repo <repo-root> [--json]
|
|
392
393
|
agent-worker feature approve-followup --feature-dir <feature-dir> --followup-id <id> --repo <repo-root> --owner <owner> [--dry-run] [--json]
|
|
393
394
|
agent-worker task retry <task-id> --repo <repo-root> [--reason "<已修复的原因>"]
|
|
395
|
+
agent-worker batch plan-ready --feature-dir <feature-dir> --repo <repo-root> [--limit <count>] [--json]
|
|
394
396
|
agent-worker batch run-ready \
|
|
395
397
|
--feature-dir <feature-dir> \ # 含 tasks/task-graph.yaml
|
|
396
398
|
--repo <repo-root> \ # 目标 repo
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
|
|
15
15
|
此 policy 驱动 `dag run-task --profile auto`:CLI 仍要求显式 `dag run-task`、`dag validate`、`run-dag`,但 `--profile auto` 在确定性 candidate `governanceProfile` 推断后应用 `workflowPolicy.dag.profileRouting`。生成器还会把 `outputLanguage` 写入 DagSpec,runner 在每个 Pi/Cursor 节点 prompt 中注入语言规则;代码、命令、路径、JSON 字段与 gate token 保持原样。`humanGatePolicy` 是默认人机边界声明;真实暂停仍由 DAG 节点的 `decisionGate.mode: "pause-on-human"` 与 decision envelope 触发。无 profile 的 `dag run-task <task-id>` 仍为 standard-compatible,供 legacy/review workflow。
|
|
16
16
|
|
|
17
|
+
`task.json.taskKind` 负责选择业务专用模板,不扩充 governance profile:`frontend-implementation` 选择前端实现 DAG,`backend-test` 选择后端测试 DAG。后端测试链为 `analyze-inputs-pi → generate-backend-functional-cases-pi → review-backend-cases-pi → review-backend-cases-gate-shell → generate-backend-pytest-pi → execute-backend-pytest-shell → test-retrospect-pi`,治理等级仍由既有 `minimal|standard|reviewed|supervised` 规则推断。
|
|
18
|
+
|
|
17
19
|
### DAG workflow 层级
|
|
18
20
|
|
|
19
21
|
| 优先级 | 入口 | 使用场景 |
|
|
@@ -42,7 +44,7 @@ loop-agent run-dag --dag <temp-dir>/hybrid-dag.json --init-only --canvas-path <t
|
|
|
42
44
|
**v2 字段**(均可选;缺失时行为同 v1):
|
|
43
45
|
|
|
44
46
|
- 顶层:`objective`、`successCriteria`、`globalConstraints`、`defaults`、`skillsByRole`、`executorModels`
|
|
45
|
-
- 每 node:`role`、`skills`、`writePolicy`、`writeSet`、`piStep`、`shell`、`outputContract`、`executor`(`pi` | `shell` | `static`);Pi 写入节点额外声明 `toolProfile: "write"`
|
|
47
|
+
- 每 node:`role`、`skills`、`writePolicy`、`writeSet`、`piStep`、`shell`、`outputContract`、`executor`(`pi` | `shell` | `static`);Pi 写入节点额外声明 `toolProfile: "write"`;安全只读 Pi 节点可选声明 `retryPolicy`(生成器自动注入默认值)
|
|
46
48
|
|
|
47
49
|
**Model 生成 DAG 的 template 卫生**:
|
|
48
50
|
|
|
@@ -75,7 +77,7 @@ loop-agent run-dag --dag <temp-dir>/hybrid-dag.json --init-only --canvas-path <t
|
|
|
75
77
|
- **Prompt source**:每个 task 仅用一种 prompt source。v1-compatible DAG 用 inline `subtask_prompt`;markdown-backed prompt 用 canonical `subtask_prompt_markdown`。同时提供两字段、皆不提供、或用连字符 alias `subtask_prompt-markdown` 均 fail fast。
|
|
76
78
|
- **勿宣称 live smoke 已通过**,除非真实 `run-dag` execution 中 Pi read-only、Pi writer、显式 Cursor 或 shell node 均按 DAG 完成。
|
|
77
79
|
|
|
78
|
-
可复用 template:`docs/templates/agent-dag.base.json`(model 生成 DAG 的首选 base template)、`docs/templates/agent-dag.schema.json`(JSON Schema)、`docs/templates/agent-dag.supervised-implementation.json`(supervised implementation:writeSet audit、soft/hard verify、process supervisor、repair、review verdict gate)、`docs/templates/agent-dag-process-supervisor.prompt.md`、`docs/templates/agent-dag-review-verdict.prompt.md`、`docs/templates/agent-dag-authority-surface-audit.prompt.md`(可选 authority surface verifier;authority signal 或显式 enablement 匹配时由 `dag init-hybrid` 插入)、`examples/hybrid-loop-agent-dag.json`、`docs/templates/hybrid-dag.json`。
|
|
80
|
+
可复用 template:`docs/templates/agent-dag.base.json`(model 生成 DAG 的首选 base template)、`docs/templates/agent-dag.schema.json`(JSON Schema)、`docs/templates/agent-dag.supervised-implementation.json`(supervised implementation:writeSet audit、soft/hard verify、process supervisor、repair、review verdict gate)、`docs/templates/backend-test-dag.json`(后端测试专用模板)、`docs/templates/agent-dag-process-supervisor.prompt.md`、`docs/templates/agent-dag-review-verdict.prompt.md`、`docs/templates/agent-dag-authority-surface-audit.prompt.md`(可选 authority surface verifier;authority signal 或显式 enablement 匹配时由 `dag init-hybrid` 插入)、`examples/hybrid-loop-agent-dag.json`、`docs/templates/hybrid-dag.json`。
|
|
79
81
|
|
|
80
82
|
### Supervised implementation flow(减少 main-session intervention)
|
|
81
83
|
|
|
@@ -107,9 +109,13 @@ contract-pi → scout-src ∥ scout-tests → plan-pi → write-set-audit-pi
|
|
|
107
109
|
|
|
108
110
|
**Verdict gate contract(`shell.verdictGate`)**:声明 `fromNodeId`、`accept[]`、可选 `label`、可选 `lineMode`。runner 展开为一条 shell command,从 injected current run directory 读 `$HARNESS_DAG_RUN_DIR/<fromNodeId>.json`,对 extracted `assistantText ?? stdout` verdict line 与 `accept[]` exact-match。默认 `lineMode` 为 `first-non-empty` 以兼容;supervised gate 用 `first-verdict-line` 选 Pi 在 preamble 或常见整行 Markdown emphasis(如 `**VERDICT: pass**`)后第一条 normalized `VERDICT:` line。勿用 `result.summary.md`、grep VERDICT、latest-active-run discovery 或 multi-command stateful gate。`--strict-governance` 对 anti-pattern fail。supervisor 仍为 `executor: pi` 上的 `role: supervisor`。
|
|
109
111
|
|
|
112
|
+
**Repair artifact gate contract(`shell.repairArtifactGate`)**:声明 `fromNodeId`(supervisor artifact 节点)与 `repairNodeId`(承接修订的 Pi 修复节点)。runner **不再**按节点名(历史 `repair-cursor` / `repair-pi`)猜测 repair 节点:显式 `repairNodeId` 必须存在、直接 `depends_on` gate、且是受治理 Pi writer(`executor: pi`、`toolProfile: write`、`writePolicy: exclusive`、`allowedPaths`+`writeSet` 非空且 `writeSet` 不与 `forbiddenPaths` 冲突)。新生成的 supervised DAG 总是写入 `repairNodeId`;旧 DAG 缺失时只在能唯一、安全地推导出下游 Pi writer 时兼容,零个或多个候选、或候选不满足契约都在执行前 fail closed。validation 覆盖存在性、直接下游、writer 属性与路径边界。
|
|
113
|
+
|
|
114
|
+
**Runtime contract 与 controller identity**:新生成的 DagSpec 使用 `version: 3`,并必须携带 `runtimeContract`(`schemaVersion` / `agentRuntime: "pi-only"` / `repairWriterProtocol: "explicit-node-v1"` / 可选 `minimumControllerVersion`)。v3 是旧 controller 无法忽略的解析边界;capability 与最低版本是新 controller 的执行前兼容门。`init-hybrid` 不硬编码 `minimumControllerVersion`,手写 spec 可按需 pin。每个新 run 必须解析并冻结 controller identity(package version、binary SHA-256、portable fingerprint)到 `controller-identity.json`;解析失败不创建 run。`dag report` 展示 identity 与 runtime-contract compatibility,resume 对漂移、篡改或 legacy-unpinned run 全部 fail closed;legacy run 仍可只读报告或显式 reconcile。
|
|
115
|
+
|
|
110
116
|
Prompt invariant:`docs/templates/agent-dag-process-supervisor.prompt.md`、`docs/templates/agent-dag-review-verdict.prompt.md`、`docs/templates/agent-dag-authority-surface-audit.prompt.md`(启用时)。测试:`npx vitest run test/dag-supervised-template.test.ts test/authority-surface.test.ts`。完整叙述:`docs/agent-dag-runner.md` §「Why main-session interventions happened」。
|
|
111
117
|
|
|
112
|
-
**未实现**:`executor: supervisor`、automatic retry/resume、`executor: human`/`decision`、browser executor,或 read-only node 对 root `artifacts/**` 的 exemption
|
|
118
|
+
**未实现**:`executor: supervisor`、whole-run automatic retry/resume、`executor: human`/`decision`、browser executor,或 read-only node 对 root `artifacts/**` 的 exemption。注:有界只读 Pi 节点重试已实现(见下「只读 Pi 节点安全重试」)。
|
|
113
119
|
|
|
114
120
|
### Level 3 task-to-DAG(`dag init-hybrid` / `dag run-task`)
|
|
115
121
|
|
|
@@ -179,6 +185,19 @@ loop-agent dag resume --run-id <run-id> # approve 后继续
|
|
|
179
185
|
|
|
180
186
|
**In-flight DAG run 期间的 governance**:live run 内 shell verify node 须用 `HARNESS_ALLOW_ACTIVE_DAG_RUNS=1 bash scripts/check-repo.sh`。run 归档到 `completed/` 后,在 DAG 外跑裸 `bash scripts/check-repo.sh`。
|
|
181
187
|
|
|
188
|
+
### 只读 Pi 节点安全重试(read-only retry)
|
|
189
|
+
|
|
190
|
+
planner/scout/reviewer/verifier/closeout 角色的安全只读 Pi 节点可声明 `retryPolicy`,在同一 run 内有界重试模型连接中断、provider 限流、临时不可用或请求 timeout。生成模板自动注入默认策略(总尝试 3 次,手工配置最多 5 次,指数退避,单次等待上限 30s)。supervisor 与 implementer 明确不重试。
|
|
191
|
+
|
|
192
|
+
- 仅重试原始分类:`timeout`、`network`、`rate-limit`、`unavailable`。`quota` **不**是 rate limit,不重试;`auth`、`invalid-output`、`write-guard`、`decision-envelope` 与未知失败同样不重试。
|
|
193
|
+
- 资格由确定性 helper 判断,executor 内不硬编码循环;仅 `writePolicy=read-only|none`(或 Pi 默认只读)的上述角色可用。supervisor / implementer / writer / docs-only / dynamic / shell / static / decision-gate 节点声明 `retryPolicy` 会在 DAG validation 阶段失败。
|
|
194
|
+
- 每次 attempt 写入独立不可变证据 `<node-id>/attempt-<n>.json`(run-relative path),最终 node record `attempts` 字段引用完整历史;后一次成功不覆盖前一次失败证据。
|
|
195
|
+
- 重试复用同一 run、controller identity、skill snapshot、prompt、model 与上游输入;退避等待刷新 `lastActivityAt` 避免误判 node-quiet。
|
|
196
|
+
- 节点终态聚合全部 attempts 的耗时、Token 与事件数;当前 backoff 等待会占用该节点的并发槽。
|
|
197
|
+
- 未声明 `retryPolicy` 的历史 DAG 行为不变(单次执行,不新增 attempt artifact)。
|
|
198
|
+
|
|
199
|
+
实现:`src/workflows/dag/retry-policy.ts`、`node-execution.ts`、`validate.ts`。测试:`npx vitest run test/dag-node-retry.test.ts test/dag-validate.test.ts test/dag-init-hybrid.test.ts`。
|
|
200
|
+
|
|
182
201
|
### Evidence summary guidance(practice convention — 非 runtime)
|
|
183
202
|
|
|
184
203
|
review-heavy DAG 中长 shell stdout 可能掩盖 proof 时,用 **evidence-summary-shell** 作为 authoring pattern。**不是** runtime executor、schema field 或 parser。
|
|
@@ -72,6 +72,12 @@ product-line taxonomy 的事实源是 `docs/design/state-and-failure-taxonomy.md
|
|
|
72
72
|
- 独立 audit 报告用 `handoff coverage <task-id> [--json|--markdown]`。
|
|
73
73
|
- task status、source/artifacts、DAG outcome、verification 记录可能 drift 时用 `dag reconcile-tasks --glob '<pattern>' [--json|--markdown]`。默认仅报告;`--patch` 不能伪造 verification evidence。
|
|
74
74
|
|
|
75
|
+
### supervised repair gate 与 runtime contract 失败
|
|
76
|
+
|
|
77
|
+
- `repair artifact gate failed: ... no unique governed Pi writer` / `declares repairNodeId "..." but no task with that id exists`:DagSpec 的 `shell.repairArtifactGate` 未声明 `repairNodeId`,或声明的修复节点缺失、不是 gate 直接下游、不是受治理 Pi writer(`executor: pi`、`toolProfile: write`、`writePolicy: exclusive`、`allowedPaths`/`writeSet` 非空且不与 `forbiddenPaths` 冲突)。用当前 controller 重新生成 supervised DAG,或按上述契约补齐修复节点,不要靠改节点名绕过。
|
|
78
|
+
- `incompatible DAG runtime contract` / `runtime contract requires ...`:DagSpec 的 `runtimeContract` 要求的能力超出当前 controller。升级 controller 或用当前 controller 重新生成 DAG;该 preflight 在任何节点执行前失败,不会留下半执行的 run。
|
|
79
|
+
- `controller identity drifted` / `artifact was tampered with`:resume 时的 controller 与 run 创建时冻结的 identity 不一致(package 内容、binary 或 fingerprint 变化),或 `controller-identity.json` 被篡改。启动新 run,而不是在漂移后 resume;completed run facts 保持只读。
|
|
80
|
+
|
|
75
81
|
### Verify 默认保存进度
|
|
76
82
|
`verify` 成功后,loop-agent 默认:
|
|
77
83
|
|