@tea-agent/loop-agent 0.13.0 → 0.14.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/AGENTS.md +157 -157
- package/CHANGELOG.md +73 -301
- package/README.md +338 -334
- package/bin/agent-worker.js +22 -22
- package/bin/loop-agent.js +21 -21
- package/dist/commands/cursor-prompt.js +6 -6
- package/dist/commands/init.js +505 -505
- package/dist/commands/loop-benchmark.js +11 -11
- package/dist/commands/pi-reuse-benchmark.js +16 -16
- package/dist/executors/pi-event-serializer.js +33 -11
- package/dist/sidecars/cursor-prompt/executor.js +1 -1
- package/dist/task/runtime.js +27 -27
- package/dist/worker/observe/spec-evidence.js +19 -10
- package/dist/worker/observe/static/api.js +46 -46
- package/dist/worker/observe/static/app.js +151 -150
- package/dist/worker/observe/static/constants.js +156 -148
- package/dist/worker/observe/static/copy.js +67 -67
- package/dist/worker/observe/static/dag-helpers.js +201 -172
- package/dist/worker/observe/static/dag-layout.d.ts +31 -31
- package/dist/worker/observe/static/dag-layout.js +83 -83
- package/dist/worker/observe/static/dag-model.js +72 -72
- package/dist/worker/observe/static/dom.js +122 -122
- package/dist/worker/observe/static/format-pool.d.ts +71 -0
- package/dist/worker/observe/static/format-pool.js +134 -67
- package/dist/worker/observe/static/format.js +317 -292
- package/dist/worker/observe/static/index.html +350 -308
- package/dist/worker/observe/static/kpi.js +100 -94
- package/dist/worker/observe/static/markdown-render.js +124 -0
- package/dist/worker/observe/static/relations.js +133 -133
- package/dist/worker/observe/static/router.js +93 -93
- package/dist/worker/observe/static/run-processing.js +148 -148
- package/dist/worker/observe/static/shell-chrome.js +74 -68
- package/dist/worker/observe/static/state.js +273 -267
- package/dist/worker/observe/static/styles.css +2504 -1902
- package/dist/worker/observe/static/views/batch.js +227 -227
- package/dist/worker/observe/static/views/dag-graph.js +172 -172
- package/dist/worker/observe/static/views/dag-inspector.js +530 -627
- package/dist/worker/observe/static/views/dag.js +371 -371
- package/dist/worker/observe/static/views/dashboard.js +86 -100
- package/dist/worker/observe/static/views/failures.js +143 -143
- package/dist/worker/observe/static/views/feature.js +492 -492
- package/dist/worker/observe/static/views/pool.js +708 -350
- package/dist/worker/observe/static/views/run.js +453 -453
- package/dist/worker/observe/static/views/session-timeline.js +771 -219
- package/dist/worker/observe/static/views/shell.js +7 -7
- package/dist/worker/observe/static/views/task.js +314 -314
- package/dist/worker/observe/static/views/timeline.js +163 -163
- package/dist/workflows/dag/canvas-observer.js +275 -275
- package/docs/README.md +105 -104
- package/docs/agent-dag-recovery-playbook.md +195 -195
- package/docs/agent-dag-runner.md +67 -67
- package/docs/architecture/README.md +26 -26
- package/docs/architecture/dag-execution.md +140 -140
- package/docs/architecture/evolution.md +54 -54
- package/docs/architecture/facts-and-state.md +71 -71
- package/docs/architecture/runtime-boundaries.md +191 -191
- package/docs/architecture/system-overview.md +93 -93
- package/docs/architecture/worker-and-feature.md +85 -85
- package/docs/cursor-prompt-sidecar.md +36 -36
- package/docs/decisions/README.md +18 -18
- package/docs/design/README.md +167 -167
- package/docs/development-principles.md +73 -73
- package/docs/exec-plans/README.md +6 -6
- package/docs/exec-plans/active/README.md +2 -1
- package/docs/exec-plans/completed/README.md +105 -104
- package/docs/feature-workflow.md +414 -414
- package/docs/harness-methodology-debugging.md +153 -153
- package/docs/harness-methodology-tdd.md +130 -130
- package/docs/harness-methodology-verification.md +27 -27
- package/docs/init-surface.manifest.json +307 -307
- package/docs/loop-agent-harness.md +142 -142
- package/docs/production-readiness.md +96 -96
- package/docs/progress/README.md +59 -58
- package/docs/reports/README.md +123 -119
- package/docs/skills/README.md +7 -7
- package/docs/skills/vetted-skill-registry.md +29 -29
- package/docs/templates/adr.md +60 -60
- package/docs/templates/agent-dag-authority-surface-audit.prompt.md +94 -94
- package/docs/templates/agent-dag-decision-envelope.schema.json +213 -213
- package/docs/templates/agent-dag-decision-gate-dogfood-report.md +117 -117
- package/docs/templates/agent-dag-decision-gate.prompt.md +246 -246
- package/docs/templates/agent-dag-process-supervisor.prompt.md +98 -98
- package/docs/templates/agent-dag-report.schema.json +473 -473
- package/docs/templates/agent-dag-review-verdict.prompt.md +68 -68
- package/docs/templates/agent-dag.base.json +190 -190
- package/docs/templates/agent-dag.final-verification.json +185 -185
- package/docs/templates/agent-dag.schema.json +411 -411
- package/docs/templates/agent-dag.supervised-implementation.json +620 -620
- package/docs/templates/backend-test-analysis.schema.json +44 -44
- package/docs/templates/backend-test-case-manifest.schema.json +190 -190
- package/docs/templates/backend-test-dag.classify.prompt.md +75 -75
- package/docs/templates/backend-test-dag.generate-pytest.prompt.md +204 -204
- package/docs/templates/backend-test-dag.json +559 -559
- package/docs/templates/backend-test-dag.retrospect.prompt.md +139 -139
- package/docs/templates/backend-test-dag.review-cases.prompt.md +83 -83
- package/docs/templates/backend-test-execution.schema.json +133 -133
- package/docs/templates/backend-test-result.schema.json +99 -99
- package/docs/templates/exec-plan.md +64 -64
- package/docs/templates/feature-spec.md +53 -53
- package/docs/templates/frontend-design-contract.md +42 -42
- package/docs/templates/frontend-eval/fixtures/failures/01-type-build-error.md +17 -17
- package/docs/templates/frontend-eval/fixtures/failures/02-unit-component-test-fail.md +16 -16
- package/docs/templates/frontend-eval/fixtures/failures/03-fixture-schema-drift.md +16 -16
- package/docs/templates/frontend-eval/fixtures/failures/04-missing-loading-empty-error-state.md +16 -16
- package/docs/templates/frontend-eval/fixtures/failures/05-forbidden-write-writeset-expansion.md +16 -16
- package/docs/templates/frontend-eval/fixtures/failures/06-unapproved-dependency-add.md +16 -16
- package/docs/templates/frontend-eval/fixtures/failures/07-mock-production-on.md +21 -21
- package/docs/templates/frontend-eval/fixtures/functional/01-simple-component-style.md +29 -29
- package/docs/templates/frontend-eval/fixtures/functional/02-form-validation.md +28 -28
- package/docs/templates/frontend-eval/fixtures/functional/03-list-detail-page.md +28 -28
- package/docs/templates/frontend-eval/fixtures/functional/04-api-mock.md +29 -29
- package/docs/templates/frontend-eval/fixtures/functional/05-permission-auth-gated-ui.md +27 -27
- package/docs/templates/frontend-eval/fixtures/functional/06-ssr-server-client-boundary.md +28 -28
- package/docs/templates/frontend-eval/fixtures/functional/07-shared-public-component-api.md +28 -28
- package/docs/templates/frontend-eval/fixtures/functional/08-pure-local-no-remote.md +27 -27
- package/docs/templates/frontend-eval/metrics.md +138 -138
- package/docs/templates/frontend-eval/smoke-targets.md +53 -53
- package/docs/templates/frontend-implementation-contract.schema.json +27 -27
- package/docs/templates/frontend-task-constraints.md +35 -35
- package/docs/templates/frontend-task-requirement.md +70 -70
- package/docs/templates/frontend-test-dag.generate-cases.prompt.md +5 -5
- package/docs/templates/frontend-test-dag.json +23 -23
- package/docs/templates/frontend-test-dag.retrieve-context.prompt.md +3 -3
- package/docs/templates/frontend-test-dag.retrospect.prompt.md +3 -3
- package/docs/templates/frontend-test-dag.review-cases.prompt.md +3 -3
- package/docs/templates/frontend-test-dag.review-execution.prompt.md +3 -3
- package/docs/templates/harness.schema.json +221 -221
- package/docs/templates/hybrid-dag.json +188 -188
- package/docs/templates/init-evolution-review.md +35 -35
- package/docs/templates/interactive-ui-round2-experiment.md +66 -66
- package/docs/templates/knowledge-graph-bootstrap-dag.json +118 -118
- package/docs/templates/knowledge-sync-dag.json +178 -178
- package/docs/templates/knowledge-sync-draft.schema.json +71 -71
- package/docs/templates/product-line/AGENTS.md +8 -8
- package/docs/templates/product-line/README.md +9 -9
- package/docs/templates/product-line/acceptance.yaml +14 -14
- package/docs/templates/product-line/closeout.yaml +9 -9
- package/docs/templates/product-line/design.md +13 -13
- package/docs/templates/product-line/links.md +10 -10
- package/docs/templates/product-line/requirement.md +17 -17
- package/docs/templates/product-line/task-graph.yaml +15 -15
- package/docs/templates/product-line/task.yaml +64 -64
- package/docs/templates/product-line/test-plan.md +7 -7
- package/docs/templates/production-readiness-checklist.md +57 -57
- package/docs/templates/progress-log.md +17 -17
- package/docs/templates/project-start-checklist.md +9 -9
- package/docs/templates/qa-report.md +48 -48
- package/docs/templates/sprint-contract.md +29 -29
- package/docs/templates/worker-dogfood-evidence.md +80 -80
- package/docs/templates/worker-dogfood-setup.md +68 -68
- package/docs/verification-matrix.md +70 -70
- package/examples/decision-gate-agent-dag.json +173 -173
- package/examples/example-dag.json +46 -46
- package/examples/hybrid-loop-agent-dag.json +188 -188
- package/harness.json +66 -66
- package/package.json +88 -52
- package/scripts/check-product-line-docs.sh +29 -29
- package/scripts/check-task-pool-root.sh +32 -32
- package/scripts/kb-bootstrap-init-skeleton.sh +240 -240
- package/scripts/kb-graph-incremental-prepare.mjs +386 -386
- package/scripts/kb-graph-incremental-prepare.sh +5 -5
- package/scripts/kb-graph-materialize.mjs +105 -105
- package/scripts/kb-graph-materialize.sh +4 -4
- package/scripts/kb-graph-promote.mjs +164 -164
- package/scripts/kb-graph-promote.sh +4 -4
- package/scripts/kb-query.mjs +554 -554
- package/scripts/kb-query.sh +5 -5
- package/skills/agent-worker/SKILL.md +39 -39
- package/skills/agent-worker/references/agent-worker-operator.md +60 -60
- package/skills/ai-engineering-context/SKILL.md +48 -48
- package/skills/analyze-product-dependencies/SKILL.md +67 -67
- package/skills/analyze-product-dependencies/agents/openai.yaml +4 -4
- package/skills/analyze-product-dependencies/references/api-documentation-schema.md +30 -30
- package/skills/analyze-product-dependencies/references/dependency-analysis-schema.md +28 -28
- package/skills/analyze-product-dependencies/references/example.md +76 -76
- package/skills/analyze-product-dependencies/references/forward-test-cases.md +35 -35
- package/skills/analyze-product-dependencies/references/input-contract.md +11 -11
- package/skills/analyze-product-dependencies/references/scouting-rules.md +61 -61
- package/skills/analyze-product-dependencies/scripts/test-validators.mjs +267 -267
- package/skills/analyze-product-dependencies/scripts/validate-api-documentation.mjs +101 -101
- package/skills/analyze-product-dependencies/scripts/validate-dependency-analysis.mjs +142 -142
- package/skills/analyze-product-dependencies/scripts/validate-product-requirement-input.mjs +76 -76
- package/skills/analyze-product-dependencies/scripts/validation-helpers.mjs +146 -146
- package/skills/analyze-product-requirements/SKILL.md +90 -90
- package/skills/analyze-product-requirements/agents/openai.yaml +4 -4
- package/skills/analyze-product-requirements/references/acceptance-criteria.md +91 -91
- package/skills/analyze-product-requirements/references/clarification-and-knowledge.md +56 -56
- package/skills/analyze-product-requirements/references/example.md +86 -86
- package/skills/analyze-product-requirements/references/forward-test-cases.md +66 -66
- package/skills/analyze-product-requirements/references/product-analysis-schema.md +32 -32
- package/skills/analyze-product-requirements/references/product-requirement-schema.md +33 -33
- package/skills/analyze-product-requirements/references/requirement-clarification-schema.md +35 -35
- package/skills/analyze-product-requirements/scripts/test-validators.mjs +193 -193
- package/skills/analyze-product-requirements/scripts/validate-product-analysis.mjs +69 -69
- package/skills/analyze-product-requirements/scripts/validate-product-requirement.mjs +97 -97
- package/skills/analyze-product-requirements/scripts/validate-requirement-clarification.mjs +98 -98
- package/skills/analyze-product-requirements/scripts/validation-helpers.mjs +156 -156
- package/skills/browser-tools/SKILL.md +196 -196
- package/skills/browser-tools/browser-content.js +103 -103
- package/skills/browser-tools/browser-cookies.js +35 -35
- package/skills/browser-tools/browser-eval.js +53 -53
- package/skills/browser-tools/browser-hn-scraper.js +108 -108
- package/skills/browser-tools/browser-nav.js +44 -44
- package/skills/browser-tools/browser-pick.js +162 -162
- package/skills/browser-tools/browser-screenshot.js +34 -34
- package/skills/browser-tools/browser-start.js +86 -86
- package/skills/browser-tools/package-lock.json +2556 -2556
- package/skills/browser-tools/package.json +19 -19
- package/skills/code-review-core/SKILL.md +20 -20
- package/skills/codebase-scout/SKILL.md +19 -19
- package/skills/frontend-design-review/SKILL.md +66 -66
- package/skills/frontend-design-review/references/review-checklist.md +58 -58
- package/skills/frontend-implementation/SKILL.md +49 -49
- package/skills/frontend-implementation/references/code-standards.md +32 -32
- package/skills/frontend-implementation/references/design-spec.md +46 -46
- package/skills/frontend-implementation/references/node-contracts.md +27 -27
- package/skills/frontend-review/SKILL.md +59 -59
- package/skills/frontend-review/references/review-findings.md +47 -47
- package/skills/frontend-verification/SKILL.md +53 -53
- package/skills/frontend-verification/references/verification-checklist.md +68 -68
- package/skills/grill-me/SKILL.md +10 -10
- package/skills/grill-with-docs/SKILL.md +88 -88
- package/skills/grill-with-docs/adr-format.md +47 -47
- package/skills/grill-with-docs/context-format.md +60 -60
- package/skills/init-capability-evolution/SKILL.md +70 -70
- package/skills/loop-agent/SKILL.md +151 -151
- package/skills/loop-agent/references/README.md +67 -67
- package/skills/loop-agent/references/command-reference.md +527 -527
- package/skills/loop-agent/references/docs-converge.md +126 -126
- package/skills/loop-agent/references/harness-policy.md +263 -263
- package/skills/loop-agent/references/hybrid-dag.md +243 -243
- package/skills/loop-agent/references/learned/README.md +21 -21
- package/skills/loop-agent/references/long-running-loop.md +57 -57
- package/skills/loop-agent/references/model-routing.md +36 -36
- package/skills/loop-agent/references/multi-worktree.md +54 -54
- package/skills/loop-agent/references/one-shot-runs.md +85 -85
- package/skills/loop-agent/references/orchestrator-and-interventions.md +169 -169
- package/skills/loop-agent/references/pi-prompt.md +23 -23
- package/skills/loop-agent/references/pi-subagent-assisted-mode.md +84 -84
- package/skills/loop-agent/references/post-implementation-and-patterns.md +44 -44
- package/skills/loop-agent/references/task-workflow.md +89 -89
- package/skills/loop-agent/references/verification-and-failure-handling.md +141 -141
- package/skills/playwright-cli/SKILL.md +420 -420
- package/skills/playwright-cli/references/element-attributes.md +23 -23
- package/skills/playwright-cli/references/playwright-tests.md +39 -39
- package/skills/playwright-cli/references/request-mocking.md +87 -87
- package/skills/playwright-cli/references/running-code.md +241 -241
- package/skills/playwright-cli/references/session-management.md +225 -225
- package/skills/playwright-cli/references/storage-state.md +275 -275
- package/skills/playwright-cli/references/test-generation.md +433 -433
- package/skills/playwright-cli/references/tracing.md +139 -139
- package/skills/playwright-cli/references/video-recording.md +143 -143
- package/skills/playwright-cli-case-generator/SKILL.md +74 -74
- package/skills/requesting-code-review/SKILL.md +101 -101
- package/skills/requesting-code-review/code-reviewer.md +168 -168
- package/skills/systematic-debugging/CREATION-LOG.md +119 -119
- package/skills/systematic-debugging/SKILL.md +296 -296
- package/skills/systematic-debugging/condition-based-waiting-example.ts +158 -158
- package/skills/systematic-debugging/condition-based-waiting.md +115 -115
- package/skills/systematic-debugging/defense-in-depth.md +122 -122
- package/skills/systematic-debugging/find-polluter.sh +63 -63
- package/skills/systematic-debugging/root-cause-tracing.md +169 -169
- package/skills/systematic-debugging/test-academic.md +14 -14
- package/skills/systematic-debugging/test-pressure-1.md +58 -58
- package/skills/systematic-debugging/test-pressure-2.md +68 -68
- package/skills/systematic-debugging/test-pressure-3.md +69 -69
- package/skills/test-driven-development/SKILL.md +20 -20
- package/skills/using-git-worktrees/SKILL.md +215 -215
- package/skills/verification-before-completion/SKILL.md +154 -154
- package/skills/webapp-testing/SKILL.md +19 -19
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
# 事实与状态
|
|
2
|
-
|
|
3
|
-
本页说明 `.harness/` 各根目录、canonical facts、derived read models 与不可变规则,并逐条标出 canonical|derived 与 writable|read-only。完成权威是 shell verification(ADR 0001);model verdict、Observe、报告都是 derived 或 advisory 视图。
|
|
4
|
-
|
|
5
|
-
## 六类运行态对象
|
|
6
|
-
|
|
7
|
-
| 对象 | 物理根 | 源码入口 | 性质 |
|
|
8
|
-
| --- | --- | --- | --- |
|
|
9
|
-
| Task | `.harness/tasks/<taskId>/` | `src/task/runtime.ts` `getTaskDir` | canonical,可写 |
|
|
10
|
-
| DAG run | `.harness/dag-runs/{active,paused,completed}/<runId>/` | `src/workflows/dag/lifecycle.ts` `DAG_RUNS_DIR` | canonical,active/paused 可写;completed 受 guard |
|
|
11
|
-
| one-shot run | `.harness/runs/{active,completed,failed}/<slug>/` | `src/infrastructure/harness/one-shot-run-store.ts`(逻辑封装见 `src/records/one-shot-runs.ts`) | canonical;active 可写,completed/failed 为终态事实 |
|
|
12
|
-
| Loop | `.harness/tasks/<taskId>/loop/` | `src/workflows/loop/**` | canonical,**不是独立根**,是 task 之上的多轮状态机 |
|
|
13
|
-
| Task Pool | `.harness/task-pool/`(唯一根;state v2 见下) | `src/worker/pool/run-store.ts` `TASK_POOL_RELATIVE_ROOT`(ADR 0002 / 0004) | canonical,可写(Worker 专用,可选) |
|
|
14
|
-
| Observe snapshot | Worker 内存/HTTP 派生视图 | `src/worker/observability/read-model.ts` `buildGlobalSnapshot` | **derived**,advisory |
|
|
15
|
-
|
|
16
|
-
### 区分要点
|
|
17
|
-
|
|
18
|
-
- **Task vs DAG run**:Task 是用户意图的源(`source/`、需求、执行约束、artifacts);DAG run 是一次执行实例,`<runId>/` 下落 spec、state、节点 artifacts、skill snapshot、controller identity(`controller-identity.json`,冻结执行 controller 的 package version/binary 哈希/portable fingerprint,state 记录相对 ref 与内容哈希,resume 时重新校验、漂移 fail closed)、decision envelope、convergence。
|
|
19
|
-
- **DAG run vs one-shot run**:DAG run 在 `.harness/dag-runs/`,有三态 lifecycle;one-shot run(当前主要由 `cursor-prompt` 及显式 one-shot evidence 路径产生)在 `.harness/runs/`,三态为 `active|completed|failed`。`pi-prompt` 当前不创建该目录下的 run evidence。两者是不同根、不同 schema。
|
|
20
|
-
- **Loop 不是顶层根**:Loop 状态在 `.harness/tasks/<taskId>/loop/`,是 task 之上的多轮状态机(round、signal、context、failureStreak、closeout)。
|
|
21
|
-
- **Task Pool 是 Worker 专用可选根**:只有使用 `agent-worker` 产品线时才存在;唯一根 `.harness/task-pool/`。
|
|
22
|
-
- **Task Pool state identity(ADR 0004)**:canonical 键为 `{ featureId, taskId }`(`TaskPoolTaskRef`),不是裸 `taskId`。
|
|
23
|
-
- **Observe snapshot 不是事实源**:`buildGlobalSnapshot` 投影失败返回安全错误摘要而非全零健康,不改变执行成败。
|
|
24
|
-
|
|
25
|
-
### Task Pool state 布局与迁移
|
|
26
|
-
|
|
27
|
-
| 路径 / 对象 | 性质 | 说明 |
|
|
28
|
-
| --- | --- | --- |
|
|
29
|
-
| `.harness/task-pool/states/<featureId>/<taskId>.json` | canonical 可写 | schema v2;路径解码 identity 必须与文件内容一致 |
|
|
30
|
-
| `.harness/task-pool/states/<taskId>.json`(扁平 v1) | legacy | 不得静默猜 Feature;存在时 v2 写入 fail-closed |
|
|
31
|
-
| `.harness/task-pool/runs.jsonl` / `events.jsonl` | canonical append-only | migration 不改写 JSONL;`workerRunId` 仍是执行历史键 |
|
|
32
|
-
| `agent-worker pool doctor` | 只读诊断 | inventory + mapping 证据;exit 0 可有 findings |
|
|
33
|
-
| `agent-worker pool migrate-state` | 显式迁移 | 默认 dry-run;`--apply --owner --reason` 才写入;失败全回滚 |
|
|
34
|
-
|
|
35
|
-
`readFeatureTaskPoolStates` / `listTaskPoolStates` 是 v2 列表入口;deprecated `readAllTaskPoolStates` 仅扫描 legacy 扁平 state,不合并 v2。
|
|
36
|
-
|
|
37
|
-
## canonical(可写)
|
|
38
|
-
|
|
39
|
-
- `.harness/tasks/<taskId>/` — `getTaskDir`。
|
|
40
|
-
- `.harness/dag-runs/{active,paused}/<runId>/` — run 进行中 / 暂停。
|
|
41
|
-
- `.harness/runs/active/<slug>/` — one-shot 运行中;完成或失败后通过 store 迁移到终态目录。
|
|
42
|
-
- `.harness/tasks/<taskId>/loop/` — Loop 状态机。
|
|
43
|
-
- `.harness/task-pool/` — Worker Task Pool(可选)。
|
|
44
|
-
|
|
45
|
-
`.harness/prompts/` 与 `.harness/init-surface.json` 属于初始化投影/控制资料,不是一次执行的 canonical run fact,需与上面的任务和 run 对象区分。
|
|
46
|
-
|
|
47
|
-
## canonical(只读 / 不可变)
|
|
48
|
-
|
|
49
|
-
- `.harness/dag-runs/completed/<runId>/` — 除 runner 终态 `persistState({ allowCompletedFactsWrite: true })` 与显式 `dag reconcile-run`(`--action supersede|abandon` + reason,runner 已证明停止)外只读。
|
|
50
|
-
- `.harness/runs/completed/<slug>/` 与 `.harness/runs/failed/<slug>/` — one-shot 终态事实;公共写接口只对 active run 开放,完成/失败通过 store 迁移。
|
|
51
|
-
- `completed-facts-guard.ts`(`src/infrastructure/harness/`)是 completed 路径 enforcement 入口:`assertHarnessWriteAllowed(targetPath, { repoRoot, allowCompletedFactsWrite? })`。
|
|
52
|
-
- promotion(completed → task artifacts 回填)由 `src/records/promotion.ts` 经 `loadCompletedDagEvidence` 读 completed state 后写 task artifacts。
|
|
53
|
-
|
|
54
|
-
## derived / advisory(不可作完成权威)
|
|
55
|
-
|
|
56
|
-
| 视图 | 来源 | 为何不可作权威 |
|
|
57
|
-
| --- | --- | --- |
|
|
58
|
-
| Observe snapshot / 首页 KPI | `buildGlobalSnapshot` 投影 `.harness/` + Task Pool | derived;投影失败安全降级 |
|
|
59
|
-
| decision envelope 的 model verdict | `decision` / `riskLevel` 解析自文本 | `advisoryOnly: true`(`decision-envelope.ts` / `decision-evidence.ts` / `lifecycle.ts`) |
|
|
60
|
-
| canvas / event observer | `notifyRunObserver` / `notifyNodeObserver` | try/catch 吞;明确派生视图,不 affect canonical 执行 |
|
|
61
|
-
| DAG report / doctor | `src/application/dag/report-dag.ts` + `src/workflows/dag/report.ts`;doctor 在 `src/workflows/dag/lifecycle.ts` | 只读总结,operator 决策辅助 |
|
|
62
|
-
| knowledge-curator proposal | `src/workflows/dag/knowledge-curator.ts` | advisory process guidance,不改 accepted learned skill |
|
|
63
|
-
| morning report / metrics | `src/worker/report/**` | derived 统计,含分母/样本量/缺失说明 |
|
|
64
|
-
|
|
65
|
-
## 完成权威
|
|
66
|
-
|
|
67
|
-
完成权威 = shell command 的 exit code 与归档 stdout/stderr。执行入口是 `src/executors/shell-executor.ts`,环境/preset helper 在 `src/executors/shell-verification.ts`;`node.verifyEvidence` 保存 DAG authoring 提供的验证阶段、命令来源与标签等元数据。model verdict、Observe、报告都不构成完成判定。
|
|
68
|
-
|
|
69
|
-
## init 投影的 `.harness` 入口
|
|
70
|
-
|
|
71
|
-
`init --profile full` 在目标项目创建 `.harness/tasks`(directory)、`.harness/dag-runs/active`(directory)、`.harness/prompts/analyze.md`(generated)、`.harness/init-surface.json`(state)。这些是 init surface,不在 `packageExcluded`/`initExcluded` 范围;详见 `ai_workspace/loop-agent/init-surface.manifest.json`。
|
|
1
|
+
# 事实与状态
|
|
2
|
+
|
|
3
|
+
本页说明 `.harness/` 各根目录、canonical facts、derived read models 与不可变规则,并逐条标出 canonical|derived 与 writable|read-only。完成权威是 shell verification(ADR 0001);model verdict、Observe、报告都是 derived 或 advisory 视图。
|
|
4
|
+
|
|
5
|
+
## 六类运行态对象
|
|
6
|
+
|
|
7
|
+
| 对象 | 物理根 | 源码入口 | 性质 |
|
|
8
|
+
| --- | --- | --- | --- |
|
|
9
|
+
| Task | `.harness/tasks/<taskId>/` | `src/task/runtime.ts` `getTaskDir` | canonical,可写 |
|
|
10
|
+
| DAG run | `.harness/dag-runs/{active,paused,completed}/<runId>/` | `src/workflows/dag/lifecycle.ts` `DAG_RUNS_DIR` | canonical,active/paused 可写;completed 受 guard |
|
|
11
|
+
| one-shot run | `.harness/runs/{active,completed,failed}/<slug>/` | `src/infrastructure/harness/one-shot-run-store.ts`(逻辑封装见 `src/records/one-shot-runs.ts`) | canonical;active 可写,completed/failed 为终态事实 |
|
|
12
|
+
| Loop | `.harness/tasks/<taskId>/loop/` | `src/workflows/loop/**` | canonical,**不是独立根**,是 task 之上的多轮状态机 |
|
|
13
|
+
| Task Pool | `.harness/task-pool/`(唯一根;state v2 见下) | `src/worker/pool/run-store.ts` `TASK_POOL_RELATIVE_ROOT`(ADR 0002 / 0004) | canonical,可写(Worker 专用,可选) |
|
|
14
|
+
| Observe snapshot | Worker 内存/HTTP 派生视图 | `src/worker/observability/read-model.ts` `buildGlobalSnapshot` | **derived**,advisory |
|
|
15
|
+
|
|
16
|
+
### 区分要点
|
|
17
|
+
|
|
18
|
+
- **Task vs DAG run**:Task 是用户意图的源(`source/`、需求、执行约束、artifacts);DAG run 是一次执行实例,`<runId>/` 下落 spec、state、节点 artifacts、skill snapshot、controller identity(`controller-identity.json`,冻结执行 controller 的 package version/binary 哈希/portable fingerprint,state 记录相对 ref 与内容哈希,resume 时重新校验、漂移 fail closed)、decision envelope、convergence。
|
|
19
|
+
- **DAG run vs one-shot run**:DAG run 在 `.harness/dag-runs/`,有三态 lifecycle;one-shot run(当前主要由 `cursor-prompt` 及显式 one-shot evidence 路径产生)在 `.harness/runs/`,三态为 `active|completed|failed`。`pi-prompt` 当前不创建该目录下的 run evidence。两者是不同根、不同 schema。
|
|
20
|
+
- **Loop 不是顶层根**:Loop 状态在 `.harness/tasks/<taskId>/loop/`,是 task 之上的多轮状态机(round、signal、context、failureStreak、closeout)。
|
|
21
|
+
- **Task Pool 是 Worker 专用可选根**:只有使用 `agent-worker` 产品线时才存在;唯一根 `.harness/task-pool/`。
|
|
22
|
+
- **Task Pool state identity(ADR 0004)**:canonical 键为 `{ featureId, taskId }`(`TaskPoolTaskRef`),不是裸 `taskId`。
|
|
23
|
+
- **Observe snapshot 不是事实源**:`buildGlobalSnapshot` 投影失败返回安全错误摘要而非全零健康,不改变执行成败。
|
|
24
|
+
|
|
25
|
+
### Task Pool state 布局与迁移
|
|
26
|
+
|
|
27
|
+
| 路径 / 对象 | 性质 | 说明 |
|
|
28
|
+
| --- | --- | --- |
|
|
29
|
+
| `.harness/task-pool/states/<featureId>/<taskId>.json` | canonical 可写 | schema v2;路径解码 identity 必须与文件内容一致 |
|
|
30
|
+
| `.harness/task-pool/states/<taskId>.json`(扁平 v1) | legacy | 不得静默猜 Feature;存在时 v2 写入 fail-closed |
|
|
31
|
+
| `.harness/task-pool/runs.jsonl` / `events.jsonl` | canonical append-only | migration 不改写 JSONL;`workerRunId` 仍是执行历史键 |
|
|
32
|
+
| `agent-worker pool doctor` | 只读诊断 | inventory + mapping 证据;exit 0 可有 findings |
|
|
33
|
+
| `agent-worker pool migrate-state` | 显式迁移 | 默认 dry-run;`--apply --owner --reason` 才写入;失败全回滚 |
|
|
34
|
+
|
|
35
|
+
`readFeatureTaskPoolStates` / `listTaskPoolStates` 是 v2 列表入口;deprecated `readAllTaskPoolStates` 仅扫描 legacy 扁平 state,不合并 v2。
|
|
36
|
+
|
|
37
|
+
## canonical(可写)
|
|
38
|
+
|
|
39
|
+
- `.harness/tasks/<taskId>/` — `getTaskDir`。
|
|
40
|
+
- `.harness/dag-runs/{active,paused}/<runId>/` — run 进行中 / 暂停。
|
|
41
|
+
- `.harness/runs/active/<slug>/` — one-shot 运行中;完成或失败后通过 store 迁移到终态目录。
|
|
42
|
+
- `.harness/tasks/<taskId>/loop/` — Loop 状态机。
|
|
43
|
+
- `.harness/task-pool/` — Worker Task Pool(可选)。
|
|
44
|
+
|
|
45
|
+
`.harness/prompts/` 与 `.harness/init-surface.json` 属于初始化投影/控制资料,不是一次执行的 canonical run fact,需与上面的任务和 run 对象区分。
|
|
46
|
+
|
|
47
|
+
## canonical(只读 / 不可变)
|
|
48
|
+
|
|
49
|
+
- `.harness/dag-runs/completed/<runId>/` — 除 runner 终态 `persistState({ allowCompletedFactsWrite: true })` 与显式 `dag reconcile-run`(`--action supersede|abandon` + reason,runner 已证明停止)外只读。
|
|
50
|
+
- `.harness/runs/completed/<slug>/` 与 `.harness/runs/failed/<slug>/` — one-shot 终态事实;公共写接口只对 active run 开放,完成/失败通过 store 迁移。
|
|
51
|
+
- `completed-facts-guard.ts`(`src/infrastructure/harness/`)是 completed 路径 enforcement 入口:`assertHarnessWriteAllowed(targetPath, { repoRoot, allowCompletedFactsWrite? })`。
|
|
52
|
+
- promotion(completed → task artifacts 回填)由 `src/records/promotion.ts` 经 `loadCompletedDagEvidence` 读 completed state 后写 task artifacts。
|
|
53
|
+
|
|
54
|
+
## derived / advisory(不可作完成权威)
|
|
55
|
+
|
|
56
|
+
| 视图 | 来源 | 为何不可作权威 |
|
|
57
|
+
| --- | --- | --- |
|
|
58
|
+
| Observe snapshot / 首页 KPI | `buildGlobalSnapshot` 投影 `.harness/` + Task Pool | derived;投影失败安全降级 |
|
|
59
|
+
| decision envelope 的 model verdict | `decision` / `riskLevel` 解析自文本 | `advisoryOnly: true`(`decision-envelope.ts` / `decision-evidence.ts` / `lifecycle.ts`) |
|
|
60
|
+
| canvas / event observer | `notifyRunObserver` / `notifyNodeObserver` | try/catch 吞;明确派生视图,不 affect canonical 执行 |
|
|
61
|
+
| DAG report / doctor | `src/application/dag/report-dag.ts` + `src/workflows/dag/report.ts`;doctor 在 `src/workflows/dag/lifecycle.ts` | 只读总结,operator 决策辅助 |
|
|
62
|
+
| knowledge-curator proposal | `src/workflows/dag/knowledge-curator.ts` | advisory process guidance,不改 accepted learned skill |
|
|
63
|
+
| morning report / metrics | `src/worker/report/**` | derived 统计,含分母/样本量/缺失说明 |
|
|
64
|
+
|
|
65
|
+
## 完成权威
|
|
66
|
+
|
|
67
|
+
完成权威 = shell command 的 exit code 与归档 stdout/stderr。执行入口是 `src/executors/shell-executor.ts`,环境/preset helper 在 `src/executors/shell-verification.ts`;`node.verifyEvidence` 保存 DAG authoring 提供的验证阶段、命令来源与标签等元数据。model verdict、Observe、报告都不构成完成判定。
|
|
68
|
+
|
|
69
|
+
## init 投影的 `.harness` 入口
|
|
70
|
+
|
|
71
|
+
`init --profile full` 在目标项目创建 `.harness/tasks`(directory)、`.harness/dag-runs/active`(directory)、`.harness/prompts/analyze.md`(generated)、`.harness/init-surface.json`(state)。这些是 init surface,不在 `packageExcluded`/`initExcluded` 范围;详见 `ai_workspace/loop-agent/init-surface.manifest.json`。
|
|
@@ -1,191 +1,191 @@
|
|
|
1
|
-
# Runtime Boundaries
|
|
2
|
-
|
|
3
|
-
本文定义 loop-agent 各 runtime 层的 module interface、允许的依赖方向,以及治理检查 hook。目标是把命令、文档、import 架构、controller identity 与 run-owned execution facts 收敛为可机器校验的边界契约。
|
|
4
|
-
|
|
5
|
-
## 分层概览
|
|
6
|
-
|
|
7
|
-
```text
|
|
8
|
-
Skill layer
|
|
9
|
-
├─ DAG/runtime 入口策略(.agents/skills/loop-agent/)
|
|
10
|
-
└─ Feature/Task Pool 外层 operator 路由(.agents/skills/agent-worker/)
|
|
11
|
-
|
|
12
|
-
CLI layer (src/cli/)
|
|
13
|
-
└─ argv 解析、adapter 解析、调用 application / command handler、格式化输出
|
|
14
|
-
|
|
15
|
-
Application layer (src/application/,逐步引入)
|
|
16
|
-
└─ 一次用户意图的 typed use-case interface,供 CLI、Loop、Workflow 复用
|
|
17
|
-
|
|
18
|
-
Workflow runtime (src/workflows/)
|
|
19
|
-
└─ DAG / Dynamic / Loop 核心执行规则;不应依赖 commands
|
|
20
|
-
|
|
21
|
-
Executors (src/executors/)
|
|
22
|
-
└─ Pi / Shell / Static 等受治理外部工具适配;不应依赖 commands 或 CLI formatting
|
|
23
|
-
|
|
24
|
-
Sidecars (src/sidecars/)
|
|
25
|
-
└─ 显式手工 one-shot 工具(如 cursor-prompt);不得被 workflows/application/task/worker 依赖
|
|
26
|
-
|
|
27
|
-
Worker adapter (src/worker/)
|
|
28
|
-
└─ 产品线 TaskSpec / Task Pool / Observe 本地适配;冻结已发布 loop-agent controller identity,
|
|
29
|
-
以绝对子进程 launch spec 调用 CLI,不得 in-process import CLI、commands 或 application
|
|
30
|
-
|
|
31
|
-
Infrastructure / Store (src/infrastructure/,逐步引入)
|
|
32
|
-
└─ .harness 文件系统副作用、run lifecycle、原子写入规则
|
|
33
|
-
|
|
34
|
-
Governance (scripts/check-*.sh, src/governance/)
|
|
35
|
-
└─ 防止 command registry、skill entry、import architecture 漂移
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## 各层职责
|
|
39
|
-
|
|
40
|
-
### Skill layer
|
|
41
|
-
|
|
42
|
-
- **位置**:`.agents/skills/loop-agent/**` 与 `.agents/skills/agent-worker/**`
|
|
43
|
-
- **职责**:`loop-agent` skill 定义单个 DAG/runtime 工作的入口、硬规则与 reference 路由;`agent-worker` skill 只定义 Feature Packet、TaskSpec、Task Pool、controller pinning、自举 release train 与失败恢复的外层 operator 路由。
|
|
44
|
-
- **路由边界**:DAG leaf node 不得递归启动 `agent-worker`;`agent-worker` 不得加入 `DEFAULT_SKILLS_BY_ROLE`,也不实现 executor、scheduler、prompt 或 write guard。
|
|
45
|
-
- **禁止**:在入口 skill 中重复维护 CLI command 列表或与 `src/cli/catalog.ts` 冲突的事实源。
|
|
46
|
-
|
|
47
|
-
### CLI layer
|
|
48
|
-
|
|
49
|
-
- **位置**:`src/cli.ts`、`src/cli/**`
|
|
50
|
-
- **职责**:解析全局 flag(如 `--repo-root`)、解析 top-level / subcommand、调用 command handler、输出 help / JSON / Markdown。
|
|
51
|
-
- **允许依赖**:`src/commands/**`(handler wiring)、`src/adapters/**`、`src/shared/**`、逐步引入的 `src/application/**`。
|
|
52
|
-
- **禁止**:在 router 中维护与 catalog 独立的 command 事实源(Phase 1 整改目标)。
|
|
53
|
-
|
|
54
|
-
### Application layer
|
|
55
|
-
|
|
56
|
-
- **位置**:`src/application/**`(按计划逐步引入)
|
|
57
|
-
- **职责**:封装一次用户意图的 typed result(如 validate DAG、run DAG、report),供 CLI 与 workflow runtime 共用。
|
|
58
|
-
- **允许依赖**:`src/workflows/**`、`src/infrastructure/**`、`src/task/**`、`src/records/**`。
|
|
59
|
-
- **禁止**:直接承担 CLI formatting 或 argv 解析。
|
|
60
|
-
|
|
61
|
-
### Workflow runtime
|
|
62
|
-
|
|
63
|
-
- **位置**:`src/workflows/dag/**`、`src/workflows/dynamic/**`、`src/workflows/loop/**`
|
|
64
|
-
- **职责**:DAG spec 校验与执行、dynamic workflow 编译与 expansion、Loop 状态机与 action 编排;新 DAG run 在任何节点执行前创建 run-owned resolved skill profile snapshot,并在普通节点、dynamic child、approve/resume 路径执行 integrity gate。
|
|
65
|
-
- **skill snapshot 契约**:snapshot ref 使用 run-relative `.runtime/skill-snapshot.json` 与原始 bytes SHA-256;ref、artifact、profile 或 binding 不一致时 fail closed,不允许回退 live skill resolution。旧 run 只有在 ref 与 artifact 都不存在时,才可在 resume 前标记为 `legacy-resume-backfill` 并冻结剩余节点。
|
|
66
|
-
- **允许依赖**:`src/executors/**`、`src/task/**`、`src/records/**`、`src/shared/**`、application use-case(目标态)。
|
|
67
|
-
- **禁止**:`import` 来自 `src/commands/**`(见下方过渡例外)。
|
|
68
|
-
|
|
69
|
-
### Executors
|
|
70
|
-
|
|
71
|
-
- **位置**:`src/executors/**`
|
|
72
|
-
- **职责**:封装 Pi SDK、shell 执行、static 输出与 write guard。受治理 Agent runtime 只有 Pi。
|
|
73
|
-
- **允许依赖**:`src/shared/**`、外部 SDK(不含 `@cursor/sdk`)。
|
|
74
|
-
- **禁止**:依赖 `src/commands/**`、CLI 输出格式,或 import `src/sidecars/**` / `@cursor/sdk`。
|
|
75
|
-
|
|
76
|
-
### Sidecars
|
|
77
|
-
|
|
78
|
-
- **位置**:`src/sidecars/cursor-prompt/**`
|
|
79
|
-
- **职责**:`cursor-prompt` one-shot 手工干预;仅在显式调用时动态加载 `@cursor/sdk`。
|
|
80
|
-
- **禁止**:被 `src/workflows/**`、`src/application/**`、`src/task/**`、`src/worker/**` 或普通 `src/executors/**` import。
|
|
81
|
-
|
|
82
|
-
### Worker adapter
|
|
83
|
-
|
|
84
|
-
- **位置**:`src/worker/**`,独立 `agent-worker` CLI 为 `src/worker/cli.ts`。
|
|
85
|
-
- **职责**:TaskSpec 校验与物化、Task Pool batch/retry/morning report under `.harness/task-pool/`、失败路由,以及只读 Observe 事件/快照/UI;实际 DAG 执行通过 `LoopAgentClient` 启动已发布的 `loop-agent` 子进程。自 0.8.0 起该目录是唯一受支持的 Task Pool runtime root,旧路径不读取、不迁移、不合并、不重映射。
|
|
86
|
-
- **controller identity**:写入型 Feature/batch/Task/final verification 在任何目标仓库或 Task Pool 状态写入前解析并冻结 schemaVersion 1 identity,包括 package name/version、绝对 entry/real entry、直接可执行 launch spec、binary SHA-256 和覆盖 `package.json`、`bin/**`、`dist/**`、`.agents/skills/**` 的 portable fingerprint。expected version/fingerprint 不匹配时 fail-fast;后续 spawn 不重新查询 PATH。
|
|
87
|
-
- **证据传播**:canonical Worker record、Task Pool run、batch/Feature、QA/final evidence 可选携带同一 identity;只有所有相关层都省略 identity 时才按 legacy evidence 接受,部分缺失或锚点不一致会拒绝。
|
|
88
|
-
- **允许依赖**:TaskSpec、Task Pool、observability、Node filesystem/path 与明确的 shared/task contract;它不是第二套 executor 或 DAG kernel。
|
|
89
|
-
- **禁止**:in-process import `src/cli/**`、`src/commands/**` 或 `src/application/**`。
|
|
90
|
-
|
|
91
|
-
### Infrastructure / Store
|
|
92
|
-
|
|
93
|
-
- **位置**:`src/infrastructure/harness/**`(按计划逐步引入);过渡期部分逻辑仍在 `src/workflows/dag/lifecycle.ts`、`src/records/**`。
|
|
94
|
-
- **职责**:`.harness/tasks`、`.harness/dag-runs`、`.harness/runs`、loop state 的集中读写;completed run facts 只读约束。DAG run 自有的 `.runtime/skill-snapshot.json` 随 lifecycle 目录整体迁移,state 只保存相对 ref 和 hash,不保存 active/paused/completed 绝对路径。
|
|
95
|
-
- **DAG recovery mutation**:`dag reconcile-run` 是显式 operator 边界;默认仅检查,只有给出 action + reason 且 runner 已证明停止时才能保存原始快照、写 terminal reconciliation facts 并迁移 lifecycle。Observe、status 和 doctor 始终只读。
|
|
96
|
-
- **禁止**:把 raw path mutation 扩散给 runner、loop action 或 command handler。
|
|
97
|
-
|
|
98
|
-
### Governance
|
|
99
|
-
|
|
100
|
-
- **位置**:`scripts/check-repo.sh` 及子脚本、`src/governance/**`、相关 Vitest。
|
|
101
|
-
- **职责**:在 CI / in-flight DAG 中检测文档链接、exec plan 状态、架构 import、command registry 漂移、两个公共 skill entry 与 init/package surface 完整性。源码仓库另提供 `scripts/self-host-canary.mjs` 作为 repo-maintainer candidate takeover 证据入口;它不属于发布 package surface。
|
|
102
|
-
|
|
103
|
-
## 允许的依赖方向
|
|
104
|
-
|
|
105
|
-
```text
|
|
106
|
-
Skill (docs) ──advisory──> CLI catalog / command-reference(人类可读,机器 drift check)
|
|
107
|
-
|
|
108
|
-
CLI ──────────> Application (目标态)
|
|
109
|
-
CLI ──────────> Commands (handler 薄层)
|
|
110
|
-
Commands ──────────> Application / Workflows / Infrastructure
|
|
111
|
-
|
|
112
|
-
Workflow runtime ──────────> Executors / Task / Records / Application (目标态)
|
|
113
|
-
Workflow runtime ──X──> Commands (目标态禁止;见过渡例外)
|
|
114
|
-
|
|
115
|
-
Executors ──────────> Shared / 外部 SDK
|
|
116
|
-
Executors ──X──> Commands / CLI
|
|
117
|
-
|
|
118
|
-
Worker adapter ──────────> TaskSpec / Task Pool / observability / 子进程 CLI contract
|
|
119
|
-
Worker adapter ──X──> Commands / CLI / Application(in-process)
|
|
120
|
-
|
|
121
|
-
Application ──────────> Workflows / Infrastructure / Task / Records
|
|
122
|
-
Application ──X──> CLI formatting
|
|
123
|
-
|
|
124
|
-
Infrastructure ──────────> Shared / node:fs
|
|
125
|
-
Runner / Loop ──(迁移中)──> 逐步改为仅经 Store / Application
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
## 版本化自举边界
|
|
129
|
-
|
|
130
|
-
版本化自举包含两个不同的冻结层,不能用其中一个替代另一个:
|
|
131
|
-
|
|
132
|
-
| 层 | 冻结对象 | 生命周期 | 权威证据 |
|
|
133
|
-
|---|---|---|---|
|
|
134
|
-
| Controller identity | 实际发布包、entry/realEntry、launch spec、binary hash、portable package fingerprint | Feature/batch/Task/final verification | Worker、Task Pool、batch/Feature、QA/final evidence 中的 `controllerIdentity` |
|
|
135
|
-
| DAG skill snapshot | 某个 run 实际注入 prompt 的 ordered skill profiles、learned flag、budgets 与 dynamic bindings | 单个 DAG run,包括 pause/resume | `state.skillSnapshotRef` + `<runDir>/.runtime/skill-snapshot.json` |
|
|
136
|
-
|
|
137
|
-
源码仓库的 deterministic candidate canary 是第三类、只读/确定性接棒证据:候选 tarball 安装到隔离 slot,两个 bin 从包内绝对入口启动,PATH 中放置 controller fallback trap,并只执行 Feature dry-run 与 static/shell DAG。它必须证明 `piExecutorObserved=false`、`modelExecutorObserved=false` 和 `featureExecutedTasks=[]`,因此不能被描述为 live Pi takeover,也不承担 candidate-package Pi skill source resolution 证明;snapshot 定向测试和真实 DAG evidence 单独承担后者。
|
|
138
|
-
|
|
139
|
-
**规则摘要**
|
|
140
|
-
|
|
141
|
-
| From | May import | Must not import |
|
|
142
|
-
|------|------------|-----------------|
|
|
143
|
-
| `src/commands/**` | application, workflows, infrastructure, task, records, executors, shared | — |
|
|
144
|
-
| `src/workflows/**` | executors, task, records, shared, application(目标) | `src/commands/**` |
|
|
145
|
-
| `src/executors/**` | shared, 外部 SDK | `src/commands/**`, `src/cli/**` |
|
|
146
|
-
| `src/worker/**` | worker-local modules, task contracts, shared, Node APIs | `src/commands/**`, `src/cli/**`, `src/application/**` |
|
|
147
|
-
| `src/cli/**` | commands, adapters, shared, application(目标) | — |
|
|
148
|
-
| `.agents/skills/**` | (Markdown 引用,非 TS import) | 运行时 TS 模块 |
|
|
149
|
-
|
|
150
|
-
## 已知过渡耦合
|
|
151
|
-
|
|
152
|
-
当前没有允许的 `src/workflows/**` / `src/executors/**` forbidden import,也没有允许的 `src/worker/**` → `src/{cli,commands,application}/**` TypeScript import。
|
|
153
|
-
|
|
154
|
-
`scripts/check-architecture-boundaries.sh` 的 transitional allowlist 保持为空。任何新增的 `workflows/executors/worker` forbidden import 必须导致检查 **exit 1**;如果未来确有临时例外,必须先写入 active exec plan,说明移除时间和验证门禁。
|
|
155
|
-
|
|
156
|
-
## Governance 钩子
|
|
157
|
-
|
|
158
|
-
以下脚本由 `scripts/check-repo.sh` 调用(Phase 0 起):
|
|
159
|
-
|
|
160
|
-
| Script | 检查内容 | 失败条件 |
|
|
161
|
-
|--------|----------|----------|
|
|
162
|
-
| `scripts/check-architecture-boundaries.sh` | workflow/executor forbidden import,及 Worker → CLI/commands/application import | 新的未 allowlist violation |
|
|
163
|
-
| `scripts/check-command-registry-drift.sh` | `command-reference.md` 中的 top-level command vs `src/cli/catalog.ts` | 文档引用未注册 command |
|
|
164
|
-
| `scripts/check-exec-plan-index-sync.sh` | `ai_workspace/loop-agent/exec-plans/{active,completed}` 目录文件 vs 对应 `README.md` 索引 | 任一 plan 文件未在索引登记 |
|
|
165
|
-
| `scripts/check-skill-entry.sh` | `loop-agent` / `agent-worker` 的 frontmatter、required references、入口行数与 operator trigger vocabulary | 任一公共 skill 缺失、reference/trigger 漂移或入口超过 hard limit |
|
|
166
|
-
|
|
167
|
-
版本化自举相关 exec plan:`ai_workspace/loop-agent/exec-plans/active/2026-07-13-versioned-self-hosting-bootstrap.md`。
|
|
168
|
-
|
|
169
|
-
`src/governance/exec-plans.ts` 是 exec-plan 创建、完成与索引校验的共享 TypeScript 事实源:`plan create`/`plan complete`/`plan check` 与 `dag run-task` 前置校验都调用它。`scripts/check-exec-plan-index-sync.sh` 是独立的 shell 最终防线,与 TypeScript checker 并存;两者均不删除或弱化。
|
|
170
|
-
|
|
171
|
-
### 验证命令
|
|
172
|
-
|
|
173
|
-
```bash
|
|
174
|
-
bash scripts/check-repo.sh
|
|
175
|
-
bash scripts/check-architecture-boundaries.sh
|
|
176
|
-
bash scripts/check-command-registry-drift.sh
|
|
177
|
-
bash scripts/check-skill-entry.sh
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
Runtime 变更另需 `npm run typecheck` 及对应 targeted Vitest(见 exec plan 各 Phase 验证关口)。
|
|
181
|
-
|
|
182
|
-
## 演进里程碑
|
|
183
|
-
|
|
184
|
-
| Phase | 边界变化 |
|
|
185
|
-
|-------|----------|
|
|
186
|
-
| 0(当前) | 文档 + 机器 guard;已知 loop/actions.ts 耦合 advisory |
|
|
187
|
-
| 1 | CLI command definition 单源 |
|
|
188
|
-
| 2 | Skill entry 瘦身 + frontmatter references |
|
|
189
|
-
| 3 | DAG application use-case;Loop 开始脱离 command JSON |
|
|
190
|
-
| 6 | `workflows → commands` import check 已从 advisory 改为 **fail** |
|
|
191
|
-
| 7 | Harness Store / Repository 集中 `.harness` 副作用 |
|
|
1
|
+
# Runtime Boundaries
|
|
2
|
+
|
|
3
|
+
本文定义 loop-agent 各 runtime 层的 module interface、允许的依赖方向,以及治理检查 hook。目标是把命令、文档、import 架构、controller identity 与 run-owned execution facts 收敛为可机器校验的边界契约。
|
|
4
|
+
|
|
5
|
+
## 分层概览
|
|
6
|
+
|
|
7
|
+
```text
|
|
8
|
+
Skill layer
|
|
9
|
+
├─ DAG/runtime 入口策略(.agents/skills/loop-agent/)
|
|
10
|
+
└─ Feature/Task Pool 外层 operator 路由(.agents/skills/agent-worker/)
|
|
11
|
+
|
|
12
|
+
CLI layer (src/cli/)
|
|
13
|
+
└─ argv 解析、adapter 解析、调用 application / command handler、格式化输出
|
|
14
|
+
|
|
15
|
+
Application layer (src/application/,逐步引入)
|
|
16
|
+
└─ 一次用户意图的 typed use-case interface,供 CLI、Loop、Workflow 复用
|
|
17
|
+
|
|
18
|
+
Workflow runtime (src/workflows/)
|
|
19
|
+
└─ DAG / Dynamic / Loop 核心执行规则;不应依赖 commands
|
|
20
|
+
|
|
21
|
+
Executors (src/executors/)
|
|
22
|
+
└─ Pi / Shell / Static 等受治理外部工具适配;不应依赖 commands 或 CLI formatting
|
|
23
|
+
|
|
24
|
+
Sidecars (src/sidecars/)
|
|
25
|
+
└─ 显式手工 one-shot 工具(如 cursor-prompt);不得被 workflows/application/task/worker 依赖
|
|
26
|
+
|
|
27
|
+
Worker adapter (src/worker/)
|
|
28
|
+
└─ 产品线 TaskSpec / Task Pool / Observe 本地适配;冻结已发布 loop-agent controller identity,
|
|
29
|
+
以绝对子进程 launch spec 调用 CLI,不得 in-process import CLI、commands 或 application
|
|
30
|
+
|
|
31
|
+
Infrastructure / Store (src/infrastructure/,逐步引入)
|
|
32
|
+
└─ .harness 文件系统副作用、run lifecycle、原子写入规则
|
|
33
|
+
|
|
34
|
+
Governance (scripts/check-*.sh, src/governance/)
|
|
35
|
+
└─ 防止 command registry、skill entry、import architecture 漂移
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## 各层职责
|
|
39
|
+
|
|
40
|
+
### Skill layer
|
|
41
|
+
|
|
42
|
+
- **位置**:`.agents/skills/loop-agent/**` 与 `.agents/skills/agent-worker/**`
|
|
43
|
+
- **职责**:`loop-agent` skill 定义单个 DAG/runtime 工作的入口、硬规则与 reference 路由;`agent-worker` skill 只定义 Feature Packet、TaskSpec、Task Pool、controller pinning、自举 release train 与失败恢复的外层 operator 路由。
|
|
44
|
+
- **路由边界**:DAG leaf node 不得递归启动 `agent-worker`;`agent-worker` 不得加入 `DEFAULT_SKILLS_BY_ROLE`,也不实现 executor、scheduler、prompt 或 write guard。
|
|
45
|
+
- **禁止**:在入口 skill 中重复维护 CLI command 列表或与 `src/cli/catalog.ts` 冲突的事实源。
|
|
46
|
+
|
|
47
|
+
### CLI layer
|
|
48
|
+
|
|
49
|
+
- **位置**:`src/cli.ts`、`src/cli/**`
|
|
50
|
+
- **职责**:解析全局 flag(如 `--repo-root`)、解析 top-level / subcommand、调用 command handler、输出 help / JSON / Markdown。
|
|
51
|
+
- **允许依赖**:`src/commands/**`(handler wiring)、`src/adapters/**`、`src/shared/**`、逐步引入的 `src/application/**`。
|
|
52
|
+
- **禁止**:在 router 中维护与 catalog 独立的 command 事实源(Phase 1 整改目标)。
|
|
53
|
+
|
|
54
|
+
### Application layer
|
|
55
|
+
|
|
56
|
+
- **位置**:`src/application/**`(按计划逐步引入)
|
|
57
|
+
- **职责**:封装一次用户意图的 typed result(如 validate DAG、run DAG、report),供 CLI 与 workflow runtime 共用。
|
|
58
|
+
- **允许依赖**:`src/workflows/**`、`src/infrastructure/**`、`src/task/**`、`src/records/**`。
|
|
59
|
+
- **禁止**:直接承担 CLI formatting 或 argv 解析。
|
|
60
|
+
|
|
61
|
+
### Workflow runtime
|
|
62
|
+
|
|
63
|
+
- **位置**:`src/workflows/dag/**`、`src/workflows/dynamic/**`、`src/workflows/loop/**`
|
|
64
|
+
- **职责**:DAG spec 校验与执行、dynamic workflow 编译与 expansion、Loop 状态机与 action 编排;新 DAG run 在任何节点执行前创建 run-owned resolved skill profile snapshot,并在普通节点、dynamic child、approve/resume 路径执行 integrity gate。
|
|
65
|
+
- **skill snapshot 契约**:snapshot ref 使用 run-relative `.runtime/skill-snapshot.json` 与原始 bytes SHA-256;ref、artifact、profile 或 binding 不一致时 fail closed,不允许回退 live skill resolution。旧 run 只有在 ref 与 artifact 都不存在时,才可在 resume 前标记为 `legacy-resume-backfill` 并冻结剩余节点。
|
|
66
|
+
- **允许依赖**:`src/executors/**`、`src/task/**`、`src/records/**`、`src/shared/**`、application use-case(目标态)。
|
|
67
|
+
- **禁止**:`import` 来自 `src/commands/**`(见下方过渡例外)。
|
|
68
|
+
|
|
69
|
+
### Executors
|
|
70
|
+
|
|
71
|
+
- **位置**:`src/executors/**`
|
|
72
|
+
- **职责**:封装 Pi SDK、shell 执行、static 输出与 write guard。受治理 Agent runtime 只有 Pi。
|
|
73
|
+
- **允许依赖**:`src/shared/**`、外部 SDK(不含 `@cursor/sdk`)。
|
|
74
|
+
- **禁止**:依赖 `src/commands/**`、CLI 输出格式,或 import `src/sidecars/**` / `@cursor/sdk`。
|
|
75
|
+
|
|
76
|
+
### Sidecars
|
|
77
|
+
|
|
78
|
+
- **位置**:`src/sidecars/cursor-prompt/**`
|
|
79
|
+
- **职责**:`cursor-prompt` one-shot 手工干预;仅在显式调用时动态加载 `@cursor/sdk`。
|
|
80
|
+
- **禁止**:被 `src/workflows/**`、`src/application/**`、`src/task/**`、`src/worker/**` 或普通 `src/executors/**` import。
|
|
81
|
+
|
|
82
|
+
### Worker adapter
|
|
83
|
+
|
|
84
|
+
- **位置**:`src/worker/**`,独立 `agent-worker` CLI 为 `src/worker/cli.ts`。
|
|
85
|
+
- **职责**:TaskSpec 校验与物化、Task Pool batch/retry/morning report under `.harness/task-pool/`、失败路由,以及只读 Observe 事件/快照/UI;实际 DAG 执行通过 `LoopAgentClient` 启动已发布的 `loop-agent` 子进程。自 0.8.0 起该目录是唯一受支持的 Task Pool runtime root,旧路径不读取、不迁移、不合并、不重映射。
|
|
86
|
+
- **controller identity**:写入型 Feature/batch/Task/final verification 在任何目标仓库或 Task Pool 状态写入前解析并冻结 schemaVersion 1 identity,包括 package name/version、绝对 entry/real entry、直接可执行 launch spec、binary SHA-256 和覆盖 `package.json`、`bin/**`、`dist/**`、`.agents/skills/**` 的 portable fingerprint。expected version/fingerprint 不匹配时 fail-fast;后续 spawn 不重新查询 PATH。
|
|
87
|
+
- **证据传播**:canonical Worker record、Task Pool run、batch/Feature、QA/final evidence 可选携带同一 identity;只有所有相关层都省略 identity 时才按 legacy evidence 接受,部分缺失或锚点不一致会拒绝。
|
|
88
|
+
- **允许依赖**:TaskSpec、Task Pool、observability、Node filesystem/path 与明确的 shared/task contract;它不是第二套 executor 或 DAG kernel。
|
|
89
|
+
- **禁止**:in-process import `src/cli/**`、`src/commands/**` 或 `src/application/**`。
|
|
90
|
+
|
|
91
|
+
### Infrastructure / Store
|
|
92
|
+
|
|
93
|
+
- **位置**:`src/infrastructure/harness/**`(按计划逐步引入);过渡期部分逻辑仍在 `src/workflows/dag/lifecycle.ts`、`src/records/**`。
|
|
94
|
+
- **职责**:`.harness/tasks`、`.harness/dag-runs`、`.harness/runs`、loop state 的集中读写;completed run facts 只读约束。DAG run 自有的 `.runtime/skill-snapshot.json` 随 lifecycle 目录整体迁移,state 只保存相对 ref 和 hash,不保存 active/paused/completed 绝对路径。
|
|
95
|
+
- **DAG recovery mutation**:`dag reconcile-run` 是显式 operator 边界;默认仅检查,只有给出 action + reason 且 runner 已证明停止时才能保存原始快照、写 terminal reconciliation facts 并迁移 lifecycle。Observe、status 和 doctor 始终只读。
|
|
96
|
+
- **禁止**:把 raw path mutation 扩散给 runner、loop action 或 command handler。
|
|
97
|
+
|
|
98
|
+
### Governance
|
|
99
|
+
|
|
100
|
+
- **位置**:`scripts/check-repo.sh` 及子脚本、`src/governance/**`、相关 Vitest。
|
|
101
|
+
- **职责**:在 CI / in-flight DAG 中检测文档链接、exec plan 状态、架构 import、command registry 漂移、两个公共 skill entry 与 init/package surface 完整性。源码仓库另提供 `scripts/self-host-canary.mjs` 作为 repo-maintainer candidate takeover 证据入口;它不属于发布 package surface。
|
|
102
|
+
|
|
103
|
+
## 允许的依赖方向
|
|
104
|
+
|
|
105
|
+
```text
|
|
106
|
+
Skill (docs) ──advisory──> CLI catalog / command-reference(人类可读,机器 drift check)
|
|
107
|
+
|
|
108
|
+
CLI ──────────> Application (目标态)
|
|
109
|
+
CLI ──────────> Commands (handler 薄层)
|
|
110
|
+
Commands ──────────> Application / Workflows / Infrastructure
|
|
111
|
+
|
|
112
|
+
Workflow runtime ──────────> Executors / Task / Records / Application (目标态)
|
|
113
|
+
Workflow runtime ──X──> Commands (目标态禁止;见过渡例外)
|
|
114
|
+
|
|
115
|
+
Executors ──────────> Shared / 外部 SDK
|
|
116
|
+
Executors ──X──> Commands / CLI
|
|
117
|
+
|
|
118
|
+
Worker adapter ──────────> TaskSpec / Task Pool / observability / 子进程 CLI contract
|
|
119
|
+
Worker adapter ──X──> Commands / CLI / Application(in-process)
|
|
120
|
+
|
|
121
|
+
Application ──────────> Workflows / Infrastructure / Task / Records
|
|
122
|
+
Application ──X──> CLI formatting
|
|
123
|
+
|
|
124
|
+
Infrastructure ──────────> Shared / node:fs
|
|
125
|
+
Runner / Loop ──(迁移中)──> 逐步改为仅经 Store / Application
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## 版本化自举边界
|
|
129
|
+
|
|
130
|
+
版本化自举包含两个不同的冻结层,不能用其中一个替代另一个:
|
|
131
|
+
|
|
132
|
+
| 层 | 冻结对象 | 生命周期 | 权威证据 |
|
|
133
|
+
|---|---|---|---|
|
|
134
|
+
| Controller identity | 实际发布包、entry/realEntry、launch spec、binary hash、portable package fingerprint | Feature/batch/Task/final verification | Worker、Task Pool、batch/Feature、QA/final evidence 中的 `controllerIdentity` |
|
|
135
|
+
| DAG skill snapshot | 某个 run 实际注入 prompt 的 ordered skill profiles、learned flag、budgets 与 dynamic bindings | 单个 DAG run,包括 pause/resume | `state.skillSnapshotRef` + `<runDir>/.runtime/skill-snapshot.json` |
|
|
136
|
+
|
|
137
|
+
源码仓库的 deterministic candidate canary 是第三类、只读/确定性接棒证据:候选 tarball 安装到隔离 slot,两个 bin 从包内绝对入口启动,PATH 中放置 controller fallback trap,并只执行 Feature dry-run 与 static/shell DAG。它必须证明 `piExecutorObserved=false`、`modelExecutorObserved=false` 和 `featureExecutedTasks=[]`,因此不能被描述为 live Pi takeover,也不承担 candidate-package Pi skill source resolution 证明;snapshot 定向测试和真实 DAG evidence 单独承担后者。
|
|
138
|
+
|
|
139
|
+
**规则摘要**
|
|
140
|
+
|
|
141
|
+
| From | May import | Must not import |
|
|
142
|
+
|------|------------|-----------------|
|
|
143
|
+
| `src/commands/**` | application, workflows, infrastructure, task, records, executors, shared | — |
|
|
144
|
+
| `src/workflows/**` | executors, task, records, shared, application(目标) | `src/commands/**` |
|
|
145
|
+
| `src/executors/**` | shared, 外部 SDK | `src/commands/**`, `src/cli/**` |
|
|
146
|
+
| `src/worker/**` | worker-local modules, task contracts, shared, Node APIs | `src/commands/**`, `src/cli/**`, `src/application/**` |
|
|
147
|
+
| `src/cli/**` | commands, adapters, shared, application(目标) | — |
|
|
148
|
+
| `.agents/skills/**` | (Markdown 引用,非 TS import) | 运行时 TS 模块 |
|
|
149
|
+
|
|
150
|
+
## 已知过渡耦合
|
|
151
|
+
|
|
152
|
+
当前没有允许的 `src/workflows/**` / `src/executors/**` forbidden import,也没有允许的 `src/worker/**` → `src/{cli,commands,application}/**` TypeScript import。
|
|
153
|
+
|
|
154
|
+
`scripts/check-architecture-boundaries.sh` 的 transitional allowlist 保持为空。任何新增的 `workflows/executors/worker` forbidden import 必须导致检查 **exit 1**;如果未来确有临时例外,必须先写入 active exec plan,说明移除时间和验证门禁。
|
|
155
|
+
|
|
156
|
+
## Governance 钩子
|
|
157
|
+
|
|
158
|
+
以下脚本由 `scripts/check-repo.sh` 调用(Phase 0 起):
|
|
159
|
+
|
|
160
|
+
| Script | 检查内容 | 失败条件 |
|
|
161
|
+
|--------|----------|----------|
|
|
162
|
+
| `scripts/check-architecture-boundaries.sh` | workflow/executor forbidden import,及 Worker → CLI/commands/application import | 新的未 allowlist violation |
|
|
163
|
+
| `scripts/check-command-registry-drift.sh` | `command-reference.md` 中的 top-level command vs `src/cli/catalog.ts` | 文档引用未注册 command |
|
|
164
|
+
| `scripts/check-exec-plan-index-sync.sh` | `ai_workspace/loop-agent/exec-plans/{active,completed}` 目录文件 vs 对应 `README.md` 索引 | 任一 plan 文件未在索引登记 |
|
|
165
|
+
| `scripts/check-skill-entry.sh` | `loop-agent` / `agent-worker` 的 frontmatter、required references、入口行数与 operator trigger vocabulary | 任一公共 skill 缺失、reference/trigger 漂移或入口超过 hard limit |
|
|
166
|
+
|
|
167
|
+
版本化自举相关 exec plan:`ai_workspace/loop-agent/exec-plans/active/2026-07-13-versioned-self-hosting-bootstrap.md`。
|
|
168
|
+
|
|
169
|
+
`src/governance/exec-plans.ts` 是 exec-plan 创建、完成与索引校验的共享 TypeScript 事实源:`plan create`/`plan complete`/`plan check` 与 `dag run-task` 前置校验都调用它。`scripts/check-exec-plan-index-sync.sh` 是独立的 shell 最终防线,与 TypeScript checker 并存;两者均不删除或弱化。
|
|
170
|
+
|
|
171
|
+
### 验证命令
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
bash scripts/check-repo.sh
|
|
175
|
+
bash scripts/check-architecture-boundaries.sh
|
|
176
|
+
bash scripts/check-command-registry-drift.sh
|
|
177
|
+
bash scripts/check-skill-entry.sh
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Runtime 变更另需 `npm run typecheck` 及对应 targeted Vitest(见 exec plan 各 Phase 验证关口)。
|
|
181
|
+
|
|
182
|
+
## 演进里程碑
|
|
183
|
+
|
|
184
|
+
| Phase | 边界变化 |
|
|
185
|
+
|-------|----------|
|
|
186
|
+
| 0(当前) | 文档 + 机器 guard;已知 loop/actions.ts 耦合 advisory |
|
|
187
|
+
| 1 | CLI command definition 单源 |
|
|
188
|
+
| 2 | Skill entry 瘦身 + frontmatter references |
|
|
189
|
+
| 3 | DAG application use-case;Loop 开始脱离 command JSON |
|
|
190
|
+
| 6 | `workflows → commands` import check 已从 advisory 改为 **fail** |
|
|
191
|
+
| 7 | Harness Store / Repository 集中 `.harness` 副作用 |
|