@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.
Files changed (123) hide show
  1. package/CHANGELOG.md +74 -1
  2. package/README.md +33 -4
  3. package/dist/application/dag/generate-task-dag.js +45 -0
  4. package/dist/application/dag/run-dag.js +10 -0
  5. package/dist/application/dag/validate-dag.js +11 -0
  6. package/dist/cli/command-definitions.js +10 -3
  7. package/dist/commands/init.js +74 -7
  8. package/dist/commands/knowledge.js +129 -31
  9. package/dist/governance/manifest-types.js +3 -0
  10. package/dist/shared/package-metadata.js +135 -0
  11. package/dist/task/config-types.js +6 -1
  12. package/dist/worker/cli.js +99 -2
  13. package/dist/worker/delivery/package.js +3 -3
  14. package/dist/worker/feature/decision-loader.js +37 -6
  15. package/dist/worker/feature/next-action.js +10 -2
  16. package/dist/worker/feature/ready-plan-projection.js +81 -0
  17. package/dist/worker/feature/reducer.js +2 -1
  18. package/dist/worker/feature/review.js +19 -2
  19. package/dist/worker/feature/run.js +27 -2
  20. package/dist/worker/follow-up/approve.js +5 -2
  21. package/dist/worker/follow-up/factory.js +1 -1
  22. package/dist/worker/observability/event-history.js +216 -0
  23. package/dist/worker/observability/read-model.js +552 -118
  24. package/dist/worker/observe/paths.js +17 -0
  25. package/dist/worker/observe/routes.js +310 -23
  26. package/dist/worker/observe/server.js +59 -1
  27. package/dist/worker/observe/spec-evidence.js +281 -0
  28. package/dist/worker/observe/static/api.js +46 -0
  29. package/dist/worker/observe/static/app.js +120 -2598
  30. package/dist/worker/observe/static/constants.js +148 -0
  31. package/dist/worker/observe/static/copy.js +67 -0
  32. package/dist/worker/observe/static/dag-helpers.js +172 -0
  33. package/dist/worker/observe/static/dag-model.js +72 -0
  34. package/dist/worker/observe/static/dom.js +61 -0
  35. package/dist/worker/observe/static/format-pool.js +67 -0
  36. package/dist/worker/observe/static/format.js +292 -0
  37. package/dist/worker/observe/static/index.html +300 -82
  38. package/dist/worker/observe/static/kpi.js +94 -0
  39. package/dist/worker/observe/static/relations.js +133 -0
  40. package/dist/worker/observe/static/router.js +93 -0
  41. package/dist/worker/observe/static/run-processing.js +148 -0
  42. package/dist/worker/observe/static/shell-chrome.js +68 -0
  43. package/dist/worker/observe/static/state.js +253 -0
  44. package/dist/worker/observe/static/styles.css +1731 -495
  45. package/dist/worker/observe/static/views/batch.js +227 -0
  46. package/dist/worker/observe/static/views/dag-graph.js +172 -0
  47. package/dist/worker/observe/static/views/dag-inspector.js +596 -0
  48. package/dist/worker/observe/static/views/dag.js +362 -0
  49. package/dist/worker/observe/static/views/dashboard.js +445 -0
  50. package/dist/worker/observe/static/views/failures.js +143 -0
  51. package/dist/worker/observe/static/views/feature.js +492 -0
  52. package/dist/worker/observe/static/views/pool.js +350 -0
  53. package/dist/worker/observe/static/views/run.js +453 -0
  54. package/dist/worker/observe/static/views/session-timeline.js +205 -0
  55. package/dist/worker/observe/static/views/shell.js +7 -0
  56. package/dist/worker/observe/static/views/task.js +314 -0
  57. package/dist/worker/observe/static/views/timeline.js +163 -0
  58. package/dist/worker/pool/doctor.js +165 -0
  59. package/dist/worker/pool/migrate-state.js +303 -0
  60. package/dist/worker/pool/run-store.js +205 -17
  61. package/dist/worker/pool/types.js +17 -1
  62. package/dist/worker/pool/validation.js +100 -15
  63. package/dist/worker/report/morning-report.js +12 -2
  64. package/dist/worker/runner/run-ready.js +41 -26
  65. package/dist/worker/task-graph/ready-planner.js +136 -0
  66. package/dist/workflows/dag/controller-identity.js +104 -0
  67. package/dist/workflows/dag/convergence/controller.js +16 -8
  68. package/dist/workflows/dag/failure-routing.js +12 -1
  69. package/dist/workflows/dag/init-hybrid.js +1233 -11
  70. package/dist/workflows/dag/node-execution.js +123 -29
  71. package/dist/workflows/dag/repair-artifact.js +91 -0
  72. package/dist/workflows/dag/report.js +50 -0
  73. package/dist/workflows/dag/retry-policy.js +138 -0
  74. package/dist/workflows/dag/runner.js +32 -0
  75. package/dist/workflows/dag/runtime-contract.js +87 -0
  76. package/dist/workflows/dag/skill-snapshot.js +2 -0
  77. package/dist/workflows/dag/types.js +45 -1
  78. package/dist/workflows/dag/validate.js +68 -4
  79. package/docs/README.md +1 -1
  80. package/docs/agent-dag-recovery-playbook.md +9 -0
  81. package/docs/agent-dag-runner.md +26 -1
  82. package/docs/architecture/dag-execution.md +6 -0
  83. package/docs/architecture/evolution.md +7 -5
  84. package/docs/architecture/facts-and-state.md +15 -2
  85. package/docs/architecture/worker-and-feature.md +6 -2
  86. package/docs/decisions/README.md +3 -0
  87. package/docs/design/README.md +12 -3
  88. package/docs/exec-plans/active/README.md +2 -2
  89. package/docs/exec-plans/completed/README.md +12 -0
  90. package/docs/feature-workflow.md +108 -2
  91. package/docs/loop-agent-harness.md +15 -4
  92. package/docs/progress/README.md +22 -0
  93. package/docs/reports/README.md +14 -2
  94. package/docs/templates/agent-dag-report.schema.json +17 -0
  95. package/docs/templates/agent-dag.schema.json +69 -1
  96. package/docs/templates/agent-dag.supervised-implementation.json +8 -2
  97. package/docs/templates/backend-test-dag.generate-pytest.prompt.md +139 -0
  98. package/docs/templates/backend-test-dag.json +288 -0
  99. package/docs/templates/backend-test-dag.retrospect.prompt.md +125 -0
  100. package/docs/templates/backend-test-dag.review-cases.prompt.md +81 -0
  101. package/docs/templates/knowledge-graph-bootstrap-dag.json +118 -0
  102. package/docs/templates/knowledge-sync-dag.json +177 -0
  103. package/docs/templates/knowledge-sync-draft.schema.json +71 -0
  104. package/docs/verification-matrix.md +2 -1
  105. package/package.json +8 -2
  106. package/scripts/kb-bootstrap-init-skeleton.sh +239 -0
  107. package/scripts/kb-graph-incremental-prepare.mjs +372 -0
  108. package/scripts/kb-graph-incremental-prepare.sh +5 -0
  109. package/scripts/kb-graph-materialize.mjs +105 -0
  110. package/scripts/kb-graph-materialize.sh +4 -0
  111. package/scripts/kb-graph-promote.mjs +153 -0
  112. package/scripts/kb-graph-promote.sh +4 -0
  113. package/scripts/kb-query.mjs +554 -0
  114. package/scripts/kb-query.sh +5 -0
  115. package/skills/agent-worker/SKILL.md +3 -1
  116. package/skills/agent-worker/references/agent-worker-operator.md +18 -1
  117. package/skills/frontend-design-review/SKILL.md +26 -24
  118. package/skills/frontend-implementation/SKILL.md +29 -26
  119. package/skills/frontend-implementation/references/node-contracts.md +50 -19
  120. package/skills/frontend-review/SKILL.md +1 -1
  121. package/skills/loop-agent/references/command-reference.md +2 -0
  122. package/skills/loop-agent/references/hybrid-dag.md +22 -3
  123. package/skills/loop-agent/references/verification-and-failure-handling.md +6 -0
@@ -0,0 +1,288 @@
1
+ {
2
+ "$schema": "./agent-dag.schema.json",
3
+ "version": 3,
4
+ "title": "Backend test DAG template",
5
+ "runtimeContract": {
6
+ "schemaVersion": 1,
7
+ "agentRuntime": "pi-only",
8
+ "repairWriterProtocol": "explicit-node-v1"
9
+ },
10
+ "objective": "End-to-end backend functional testing pipeline: analyze requirements → generate functional test cases → review cases → generate pytest automation → execute pytest → retrospective with maturity rating. Covers the full chain from requirement analysis to test maturity assessment.",
11
+ "successCriteria": [
12
+ "analyze-inputs-pi returns a read-only test analysis contract covering scope, risks, and strategy",
13
+ "generate-backend-functional-cases-pi produces structured test cases with BE-<MODULE>-<NNN> IDs under testcase/md/",
14
+ "review-backend-cases-pi returns VERDICT: pass or request-revision with coverage assessment",
15
+ "review-backend-cases-gate-shell blocks pytest generation unless the review verdict is VERDICT: pass",
16
+ "generate-backend-pytest-pi converts reviewed cases into pytest code with 1:1 traceability under testcase/",
17
+ "execute-backend-pytest-shell runs pytest and produces HTML report under reports/",
18
+ "test-retrospect-pi generates retrospective report with A/B/C/D maturity rating under docs/test-reports/",
19
+ "Full traceability from acceptance criteria → functional test case ID → pytest function name"
20
+ ],
21
+ "globalConstraints": [
22
+ "Replace every REPLACE/WITH/... placeholder with concrete repo paths before execution; do not leave template placeholders in production DAG JSON.",
23
+ "Do not commit runtime traces under .harness/dag-runs/.",
24
+ "Use only existing executors: pi, shell. Pi writer nodes must set toolProfile=write.",
25
+ "Read-only nodes must not write repository files, including root artifacts/**.",
26
+ "Exclusive writer nodes must stay within declared writeSet.",
27
+ "Every task must explicitly declare executor; defaults.executor is schema-only and not a runtime fallback.",
28
+ "Functional test case IDs must use BE-<MODULE>-<NNN> format.",
29
+ "pytest execution must produce HTML reports under reports/.",
30
+ "Backend-test-dag nodes must maintain traceability from requirements to functional cases to pytest automation.",
31
+ "pytest automation scripts must use test_ filename prefix for pytest discovery.",
32
+ "generate-backend-pytest-pi must only create new test files under testcase/; modifying existing framework files (conftest.py, pytest.ini, pyproject.toml) is forbidden.",
33
+ "review-backend-cases-gate-shell must block pytest generation unless the review verdict is exactly VERDICT: pass.",
34
+ "If a target test filename already exists under testcase/, add a numeric suffix (_01, _02, ...); never overwrite or append to existing files.",
35
+ "execute-backend-pytest-shell must not modify test assertions or production code to make tests pass; test failures indicate potential implementation issues and must be reported honestly.",
36
+ "Prompt templates must not ask main session to write artifacts; node output is the artifact and runner archives it under .harness/dag-runs/.",
37
+ "Actual file operation paths must be macOS/Windows compatible; use / only for stable repo refs, JSON/Markdown evidence refs, and glob conventions.",
38
+ "Same-rank exclusive writeSet entries must be disjoint."
39
+ ],
40
+ "convergence": {
41
+ "enabled": true,
42
+ "maxPasses": 3,
43
+ "stopOnVerdictPass": true,
44
+ "stopOnHardVerifyPass": true,
45
+ "pauseOnRegression": true,
46
+ "chainNodeIds": [
47
+ "generate-backend-functional-cases-pi",
48
+ "review-backend-cases-pi",
49
+ "review-backend-cases-gate-shell"
50
+ ]
51
+ },
52
+ "defaults": {
53
+ "executor": "pi",
54
+ "contextProfile": "slim",
55
+ "skills": [
56
+ "ai-engineering-context"
57
+ ],
58
+ "writePolicy": "read-only"
59
+ },
60
+ "skillsByRole": {
61
+ "planner": [
62
+ "loop-agent"
63
+ ],
64
+ "scout": [],
65
+ "implementer": [
66
+ "test-driven-development",
67
+ "verification-before-completion"
68
+ ],
69
+ "reviewer": [
70
+ "requesting-code-review",
71
+ "code-review-core"
72
+ ],
73
+ "verifier": [
74
+ "verification-before-completion",
75
+ "systematic-debugging"
76
+ ],
77
+ "closeout": [
78
+ "loop-agent",
79
+ "verification-before-completion"
80
+ ]
81
+ },
82
+ "executorModels": {
83
+ "pi": {
84
+ "LOW": "gpt-5.3-codex-spark",
85
+ "MED": "glm-5.2",
86
+ "HIGH": "gpt-5.5"
87
+ }
88
+ },
89
+ "tasks": [
90
+ {
91
+ "id": "analyze-inputs-pi",
92
+ "depends_on": [],
93
+ "complexity": "MED",
94
+ "executor": "pi",
95
+ "role": "planner",
96
+ "writePolicy": "read-only",
97
+ "allowedPaths": [
98
+ "REPLACE/WITH/SOURCE/PATH/**"
99
+ ],
100
+ "forbiddenPaths": [
101
+ ".harness/**",
102
+ "artifacts/**"
103
+ ],
104
+ "outputContract": "Structured Markdown extracting core content from source documents. No file writes.",
105
+ "retryPolicy": {
106
+ "maxAttempts": 3,
107
+ "backoff": "exponential",
108
+ "initialDelayMs": 2000,
109
+ "maxDelayMs": 30000,
110
+ "retryCategories": [
111
+ "timeout",
112
+ "network",
113
+ "rate-limit",
114
+ "unavailable"
115
+ ]
116
+ },
117
+ "subtask_prompt": "Read the task source materials and extract the following structured content for downstream test generation.\n\n## Required Output Sections:\n\n### 1. API Endpoints\nList all API endpoints: Method, Path, Description, Request params, Response format.\n\n### 2. Data Model\nFor each table/collection: fields, types, constraints, descriptions.\n\n### 3. Business Logic\nCore business rules, validation rules, calculation formulas.\n\n### 4. State Transitions\nState machines (e.g. order status: pending → paid → shipped → completed).\n\n### 5. Error Scenarios & Error Codes\nAll error codes, error messages, and when they occur.\n\n### 6. External Dependencies\nThird-party services, databases, message queues. Include timeout settings if documented.\n\n### 7. Acceptance Criteria\nExtract ALL acceptance criteria from 需求.md. Number them AC-001, AC-002, etc. If not explicitly listed, derive from functional requirements.\n\n### 8. Risk Areas\nHigh-risk areas requiring extra test coverage.\n\n## Conditional Sections (include ONLY if mentioned in requirements):\n- Authentication & Authorization: include ONLY if requirements mention auth mechanism (JWT, OAuth2, API Key, etc.)\n- Timeout Handling: include ONLY if requirements mention timeout configuration or degradation strategy\n- Concurrency & Idempotency: include ONLY if requirements mention concurrency, idempotency rules, or locking mechanisms\n- State Transitions: include ONLY if requirements mention business state machines\n- If not mentioned in requirements, do NOT include these sections\n\nThis output will be used directly by downstream nodes. Be thorough and structured.\nRead-only: do not modify code, docs, artifacts, or repository files."
118
+ },
119
+ {
120
+ "id": "generate-backend-functional-cases-pi",
121
+ "depends_on": [
122
+ "analyze-inputs-pi"
123
+ ],
124
+ "complexity": "MED",
125
+ "executor": "pi",
126
+ "role": "implementer",
127
+ "toolProfile": "write",
128
+ "writePolicy": "exclusive",
129
+ "writeSet": [
130
+ "testcase/md/**"
131
+ ],
132
+ "allowedPaths": [
133
+ "testcase/md/**"
134
+ ],
135
+ "forbiddenPaths": [
136
+ ".harness/**",
137
+ "artifacts/**"
138
+ ],
139
+ "outputContract": "Structured backend functional test cases in Markdown under testcase/md/. Each case uses BE-<MODULE>-<NNN> ID format.",
140
+ "subtask_prompt": "Based on the upstream analyze-inputs-pi output, generate structured backend functional test cases.\n\n## Output Steps (do in order):\n1. First, output a brief summary: how many modules, how many cases planned per module\n2. Then write each test case file under testcase/md/\n\n## Format Rules:\n- Each test case ID: BE-<MODULE>-<NNN> (e.g. BE-ORDER-001)\n- Each file covers one module\n- Case structure: ID, Title, Precondition, Steps, Expected Result\n- Map each case to acceptance criteria (AC-xxx)\n\n## Coverage Requirements:\n- Positive paths: happy path for each acceptance criterion\n- Negative paths: error scenarios (invalid input, not found, state violations)\n- Boundary conditions: empty input, max length, edge values\n\n## Conditional Coverage (include ONLY if mentioned in upstream analysis):\n- State transitions: include ONLY if upstream analyze-inputs-pi mentions state machine\n- Authentication scenarios: include ONLY if upstream analyze-inputs-pi mentions auth mechanism\n- Timeout scenarios: include ONLY if upstream analyze-inputs-pi mentions timeout handling\n- Concurrency scenarios: include ONLY if upstream analyze-inputs-pi mentions concurrency/idempotency rules\n- If not mentioned, do NOT generate these test cases\n\n## Constraints:\n- Stay within writeSet: testcase/md/**\n- Do NOT re-read source documents — use the upstream analyze-inputs-pi output only\n- Do not write root artifacts/**"
141
+ },
142
+ {
143
+ "id": "review-backend-cases-pi",
144
+ "depends_on": [
145
+ "generate-backend-functional-cases-pi"
146
+ ],
147
+ "complexity": "HIGH",
148
+ "executor": "pi",
149
+ "role": "reviewer",
150
+ "writePolicy": "read-only",
151
+ "allowedPaths": [
152
+ "**"
153
+ ],
154
+ "forbiddenPaths": [
155
+ ".harness/**",
156
+ "artifacts/**"
157
+ ],
158
+ "outputContract": "Plain Markdown whose first non-empty line is VERDICT: pass or VERDICT: request-revision; followed by Findings and Coverage Assessment. No file writes.",
159
+ "retryPolicy": {
160
+ "maxAttempts": 3,
161
+ "backoff": "exponential",
162
+ "initialDelayMs": 2000,
163
+ "maxDelayMs": 30000,
164
+ "retryCategories": [
165
+ "timeout",
166
+ "network",
167
+ "rate-limit",
168
+ "unavailable"
169
+ ]
170
+ },
171
+ "subtask_prompt_markdown": "./backend-test-dag.review-cases.prompt.md"
172
+ },
173
+ {
174
+ "id": "review-backend-cases-gate-shell",
175
+ "depends_on": [
176
+ "review-backend-cases-pi"
177
+ ],
178
+ "complexity": "LOW",
179
+ "executor": "shell",
180
+ "role": "verifier",
181
+ "writePolicy": "read-only",
182
+ "allowedPaths": [
183
+ "**"
184
+ ],
185
+ "forbiddenPaths": [
186
+ ".harness/**",
187
+ "artifacts/**"
188
+ ],
189
+ "outputContract": "Deterministic backend case review gate: exit 0 only when review-backend-cases-pi emits VERDICT: pass.",
190
+ "subtask_prompt": "Deterministic gate: block pytest generation unless backend case review emitted VERDICT: pass.",
191
+ "shell": {
192
+ "commands": [],
193
+ "verdictGate": {
194
+ "fromNodeId": "review-backend-cases-pi",
195
+ "accept": [
196
+ "VERDICT: pass"
197
+ ],
198
+ "label": "backend case review",
199
+ "lineMode": "first-verdict-line"
200
+ },
201
+ "cwd": ".",
202
+ "timeoutMs": 60000
203
+ }
204
+ },
205
+ {
206
+ "id": "generate-backend-pytest-pi",
207
+ "depends_on": [
208
+ "review-backend-cases-gate-shell"
209
+ ],
210
+ "complexity": "HIGH",
211
+ "executor": "pi",
212
+ "role": "implementer",
213
+ "toolProfile": "write",
214
+ "writePolicy": "exclusive",
215
+ "writeSet": [
216
+ "testcase/**/test_*.py"
217
+ ],
218
+ "allowedPaths": [
219
+ "testcase/**/test_*.py"
220
+ ],
221
+ "forbiddenPaths": [
222
+ ".harness/**",
223
+ "artifacts/**"
224
+ ],
225
+ "outputContract": "Pytest test files under testcase/ with 1:1 mapping to functional test case IDs. Summary lists generated files, test function count, and any skipped cases with reasons.",
226
+ "subtask_prompt_markdown": "./backend-test-dag.generate-pytest.prompt.md"
227
+ },
228
+ {
229
+ "id": "execute-backend-pytest-shell",
230
+ "depends_on": [
231
+ "generate-backend-pytest-pi"
232
+ ],
233
+ "complexity": "LOW",
234
+ "executor": "shell",
235
+ "role": "verifier",
236
+ "writePolicy": "read-only",
237
+ "allowedPaths": [
238
+ "**"
239
+ ],
240
+ "forbiddenPaths": [
241
+ ".harness/**",
242
+ "artifacts/**"
243
+ ],
244
+ "outputContract": "Archived pytest stdout/stderr with exit codes and HTML report path; no source or test file modifications.",
245
+ "subtask_prompt": "Run pytest for the backend test suite and capture results.",
246
+ "shell": {
247
+ "commands": [
248
+ "python -m pytest testcase/ --html=reports/backend-test-report.html -v"
249
+ ],
250
+ "verifyEvidence": {
251
+ "phase": "final",
252
+ "quota": "full",
253
+ "commandSource": "inline",
254
+ "commandCount": 1,
255
+ "commandLabels": [
256
+ "backend pytest execution"
257
+ ],
258
+ "finalFullRequired": true
259
+ },
260
+ "cwd": ".",
261
+ "timeoutMs": 300000
262
+ }
263
+ },
264
+ {
265
+ "id": "test-retrospect-pi",
266
+ "depends_on": [
267
+ "execute-backend-pytest-shell"
268
+ ],
269
+ "complexity": "MED",
270
+ "executor": "pi",
271
+ "role": "closeout",
272
+ "toolProfile": "write",
273
+ "writePolicy": "exclusive",
274
+ "writeSet": [
275
+ "docs/test-reports/**"
276
+ ],
277
+ "allowedPaths": [
278
+ "docs/test-reports/**"
279
+ ],
280
+ "forbiddenPaths": [
281
+ ".harness/**",
282
+ "artifacts/**"
283
+ ],
284
+ "outputContract": "Markdown retrospective report under docs/test-reports/ with coverage summary, review findings, pytest results, and maturity rating (A/B/C/D).",
285
+ "subtask_prompt_markdown": "./backend-test-dag.retrospect.prompt.md"
286
+ }
287
+ ]
288
+ }
@@ -0,0 +1,125 @@
1
+ # Backend Test DAG Retrospect Prompt Template
2
+
3
+ ## Purpose
4
+
5
+ Use this prompt for a **test retrospective** node: `executor: "pi"`, `role: "closeout"`, `toolProfile: "write"`, `writePolicy: "exclusive"`. The closeout agent reads upstream review reports and pytest execution results, then generates a retrospective report with an objective maturity rating.
6
+
7
+ Do **not** create a new executor type. This is a standard `executor: pi` writer node.
8
+
9
+ ## Recommended DAG Node Shape
10
+
11
+ ```json
12
+ {
13
+ "id": "test-retrospect-pi",
14
+ "depends_on": ["execute-backend-pytest-shell"],
15
+ "complexity": "MED",
16
+ "executor": "pi",
17
+ "role": "closeout",
18
+ "toolProfile": "write",
19
+ "writePolicy": "exclusive",
20
+ "writeSet": ["docs/test-reports/**"],
21
+ "allowedPaths": ["docs/test-reports/**"],
22
+ "forbiddenPaths": [".harness/**", "artifacts/**"],
23
+ "outputContract": "Markdown retrospective report under docs/test-reports/ with coverage summary, review findings, pytest results, and maturity rating (A/B/C/D).",
24
+ "subtask_prompt_markdown": "./backend-test-dag.retrospect.prompt.md"
25
+ }
26
+ ```
27
+
28
+ ## Prompt Body
29
+
30
+ You are the Backend Test DAG **test retrospective** agent.
31
+
32
+ Your job is to read upstream outputs (review report + pytest results) and generate a retrospective report with a maturity rating. Write the report under `docs/test-reports/` only. Stay within `writeSet`. Do not write root `artifacts/**`.
33
+
34
+ ### Output Steps (do in order)
35
+
36
+ 1. First, output the maturity rating on the first line: `Rating: A/B/C/D`
37
+ 2. Then write the full report under `docs/test-reports/`
38
+
39
+ ### Inputs
40
+
41
+ 1. **Review report** — `review-backend-cases-pi` output (VERDICT, findings, coverage assessment).
42
+ 2. **Pytest output** — `execute-backend-pytest-shell` stdout/stderr and exit code.
43
+ 3. **HTML report** — `reports/backend-test-report.html` (if generated).
44
+
45
+ Do NOT re-read source documents. Use upstream outputs only.
46
+
47
+ ### Maturity Rating Criteria
48
+
49
+ | Rating | Coverage | Pass Rate | Review Findings |
50
+ |--------|----------|-----------|-----------------|
51
+ | **A** | 100% acceptance criteria covered | 100% pytest pass | No Critical or Important findings |
52
+ | **B** | ≥80% acceptance criteria covered | ≥90% pytest pass | Only Informational findings |
53
+ | **C** | ≥60% acceptance criteria covered | ≥70% pytest pass | No Critical findings (Important allowed) |
54
+ | **D** | Below C thresholds | Below C thresholds | Or any Critical finding unresolved |
55
+
56
+ #### Rating Rules
57
+
58
+ - **Coverage** = (acceptance criteria with ≥1 covering test case) / (total acceptance criteria) × 100%
59
+ - **Pass rate** = (passed pytest functions) / (total non-skipped pytest functions) × 100%
60
+ - If `review-backend-cases-pi` returned `VERDICT: request-revision` and revision was not completed, cap at **D**.
61
+ - If pytest exit code is non-zero and >30% tests failed, cap at **D** regardless of coverage.
62
+ - Skipped tests (`@pytest.mark.skip`) count as "not covered" for pass rate but not as failures.
63
+
64
+ ### Report Structure
65
+
66
+ Write the report as a Markdown file named `backend-test-retrospect-<date>.md` under `docs/test-reports/`.
67
+
68
+ ```markdown
69
+ # Backend Test Retrospective Report
70
+
71
+ **Date:** <YYYY-MM-DD>
72
+ **Task:** <task-id>
73
+ **Maturity Rating:** <A|B|C|D>
74
+
75
+ ## 1. Test Coverage Summary
76
+
77
+ | Metric | Value |
78
+ |--------|-------|
79
+ | Total acceptance criteria | N |
80
+ | Covered by test cases | N (X%) |
81
+ | Total functional test cases | N |
82
+ | Positive path cases | N |
83
+ | Negative path cases | N |
84
+ | Boundary cases | N |
85
+
86
+ ## 2. Automation Results
87
+
88
+ | Metric | Value |
89
+ |--------|-------|
90
+ | Total pytest functions | N |
91
+ | Passed | N |
92
+ | Failed | N |
93
+ | Skipped | N |
94
+ | Pass rate | X% |
95
+ | Pytest exit code | N |
96
+
97
+ ### Failed Test Analysis
98
+
99
+ | Test Case ID | Function | Failure Reason | Root Cause |
100
+ |--------------|----------|----------------|------------|
101
+ | ... | ... | ... | ... |
102
+
103
+ ## 3. Review Findings
104
+
105
+ | Severity | Finding | Status |
106
+ |----------|---------|--------|
107
+ | Critical | ... | Resolved / Unresolved |
108
+ | Important | ... | Resolved / Unresolved |
109
+ | Informational | ... | Resolved / Unresolved |
110
+
111
+ ## 4. Maturity Rating Rationale
112
+
113
+ Explain which threshold was met or missed, and why the specific rating was assigned.
114
+
115
+ ## 5. Recommendations
116
+
117
+ - Actionable items for improving the rating in the next iteration.
118
+ - Specific gaps to close (uncovered criteria, flaky tests, missing negative paths).
119
+ ```
120
+
121
+ ### Output Shape (after rating line)
122
+
123
+ After the mandatory maturity rating line, provide a brief summary paragraph before writing the full report file.
124
+
125
+ Do not include chain-of-thought. Do not write root `artifacts/**`.
@@ -0,0 +1,81 @@
1
+ # Backend Test DAG Review Cases Prompt Template
2
+
3
+ ## Purpose
4
+
5
+ Use this prompt for a read-only **backend test case review** node: `executor: "pi"`, `role: "reviewer"`, `writePolicy: "read-only"`. The reviewer audits generated backend functional test cases for completeness, format compliance, and traceability to source requirements. Downstream `generate-backend-pytest-pi` depends on a `VERDICT: pass` to proceed.
6
+
7
+ Do **not** create `executor: reviewer`. Reviewer is a **role** on `executor: pi`.
8
+
9
+ ## Recommended DAG Node Shape
10
+
11
+ ```json
12
+ {
13
+ "id": "review-backend-cases-pi",
14
+ "depends_on": ["generate-backend-functional-cases-pi"],
15
+ "complexity": "HIGH",
16
+ "executor": "pi",
17
+ "role": "reviewer",
18
+ "writePolicy": "read-only",
19
+ "allowedPaths": ["**"],
20
+ "forbiddenPaths": [".harness/**", "artifacts/**"],
21
+ "outputContract": "Plain Markdown whose first non-empty line is VERDICT: pass or VERDICT: request-revision; followed by Findings and Coverage Assessment. No file writes.",
22
+ "subtask_prompt_markdown": "./backend-test-dag.review-cases.prompt.md"
23
+ }
24
+ ```
25
+
26
+ ## Prompt Body
27
+
28
+ You are the Backend Test DAG **test case reviewer** (read-only).
29
+
30
+ Your job is to audit the generated backend functional test cases for completeness, format compliance, requirement coverage, and traceability. You are **not** an implementer or test generator. Do not edit repository files, including root `artifacts/**`.
31
+
32
+ ### Mandatory First Line
33
+
34
+ The **first non-empty line** of your response must be exactly one of:
35
+
36
+ - `VERDICT: pass`
37
+ - `VERDICT: request-revision`
38
+
39
+ No preamble, heading, or blank lines before the verdict line.
40
+
41
+ ### Inputs to Review
42
+
43
+ 1. **Acceptance criteria** — from upstream `analyze-inputs-pi` output (AC-001, AC-002, ...).
44
+ 2. **Generated test cases** — files under `testcase/md/`.
45
+
46
+ Do NOT re-read source documents. Use upstream outputs only.
47
+
48
+ ### Review Checklist
49
+
50
+ | Area | Check | Severity if Missing |
51
+ |------|-------|---------------------|
52
+ | **ID format** | Every test case ID matches `BE-<MODULE>-<NNN>` (e.g. `BE-ORDER-001`) | Critical |
53
+ | **Positive path coverage** | Happy-path scenarios for each acceptance criterion | Critical |
54
+ | **Negative path coverage** | Error/exception scenarios (invalid input, not found, state violations) | Important |
55
+ | **Boundary conditions** | Edge cases (empty input, max length, edge values) | Important |
56
+ | **State transitions** | Illegal state changes covered | Important |
57
+ | **Requirement traceability** | Each acceptance criterion (AC-xxx) maps to at least one test case ID | Critical |
58
+ | **Case structure** | Each case has: ID, Title, Precondition, Steps, Expected Result | Important |
59
+ | **No duplicate IDs** | All test case IDs are unique across files | Critical |
60
+
61
+ ### Conditional Coverage (check ONLY if mentioned in upstream analysis)
62
+
63
+ - **Authentication coverage**: check ONLY if `analyze-inputs-pi` mentions auth mechanism (JWT, OAuth2, API Key, etc.)
64
+ - **Timeout coverage**: check ONLY if `analyze-inputs-pi` mentions timeout handling or degradation strategy
65
+ - If not mentioned in upstream analysis, do NOT flag as missing
66
+
67
+ ### Verdict Rules
68
+
69
+ | Condition | Verdict |
70
+ |-----------|---------|
71
+ | All Critical checks pass, Important checks have no more than 2 findings | `VERDICT: pass` |
72
+ | Any Critical check fails | `VERDICT: request-revision` |
73
+ | More than 2 Important findings | `VERDICT: request-revision` |
74
+ | Only Informational findings | `VERDICT: pass` (with findings listed) |
75
+
76
+ ### Output Shape (after verdict line)
77
+
78
+ 1. **Coverage Assessment** — table mapping each AC to covering test case IDs (or "uncovered").
79
+ 2. **Findings** — bullet list tagged `Critical`, `Important`, or `Informational`.
80
+ 3. **Statistics** — total case count, positive/negative/boundary breakdown, module distribution.
81
+ 4. **Required revisions** (only when `request-revision`) — numbered items for the upstream generator to fix.
@@ -0,0 +1,118 @@
1
+ {
2
+ "$schema": "./agent-dag.schema.json",
3
+ "version": 2,
4
+ "title": "Knowledge-graph bootstrap DAG template",
5
+ "objective": "AI-assisted business knowledge graph initialization: inventory repo signals, propose entities/edges under staging only, validate, review-gate, promote without overwrite, materialize query indexes.",
6
+ "successCriteria": [
7
+ "preflight requires knowledge/bootstrap/scope.yaml and status.yaml",
8
+ "inventory writes knowledge/bootstrap/inventory.json",
9
+ "propose-pi writes only knowledge/bootstrap/staging/** with evidence and non-asserted confidence",
10
+ "validate-shell fails on empty staging, missing edges.proposed/coverage-notes, or self-asserted confidence",
11
+ "review-gate blocks promote unless VERDICT: pass",
12
+ "promote merges new formal files only (no overwrite)",
13
+ "materialize writes knowledge/graph/entities-index.yaml and edges.yaml"
14
+ ],
15
+ "globalConstraints": [
16
+ "AI must never set confidence: asserted.",
17
+ "Do not modify src/** or Feature testing verdict/cases via bootstrap.",
18
+ "Promote must not overwrite existing formal knowledge files.",
19
+ "Complete B0/B1 skeleton before running this DAG."
20
+ ],
21
+ "defaults": {
22
+ "executor": "shell",
23
+ "contextProfile": "slim",
24
+ "writePolicy": "read-only"
25
+ },
26
+ "tasks": [
27
+ {
28
+ "id": "kg-bootstrap-preflight-shell",
29
+ "depends_on": [],
30
+ "role": "verifier",
31
+ "executor": "shell",
32
+ "complexity": "LOW",
33
+ "writePolicy": "read-only",
34
+ "subtask_prompt": "Require bootstrap skeleton."
35
+ },
36
+ {
37
+ "id": "kg-bootstrap-inventory-shell",
38
+ "depends_on": ["kg-bootstrap-preflight-shell"],
39
+ "role": "verifier",
40
+ "executor": "shell",
41
+ "complexity": "LOW",
42
+ "writePolicy": "exclusive",
43
+ "writeSet": ["knowledge/bootstrap/inventory.json"],
44
+ "subtask_prompt": "B2 inventory."
45
+ },
46
+ {
47
+ "id": "kg-bootstrap-propose-pi",
48
+ "depends_on": ["kg-bootstrap-inventory-shell"],
49
+ "role": "implementer",
50
+ "executor": "pi",
51
+ "toolProfile": "write",
52
+ "complexity": "HIGH",
53
+ "writePolicy": "exclusive",
54
+ "writeSet": [
55
+ "knowledge/bootstrap/staging/**",
56
+ "knowledge/bootstrap/runs/**"
57
+ ],
58
+ "subtask_prompt": "B3 AI proposals in staging only; never asserted."
59
+ },
60
+ {
61
+ "id": "kg-bootstrap-validate-shell",
62
+ "depends_on": ["kg-bootstrap-propose-pi"],
63
+ "role": "verifier",
64
+ "executor": "shell",
65
+ "complexity": "LOW",
66
+ "writePolicy": "read-only",
67
+ "subtask_prompt": "B4 validate staging."
68
+ },
69
+ {
70
+ "id": "kg-bootstrap-review-pi",
71
+ "depends_on": ["kg-bootstrap-validate-shell"],
72
+ "role": "reviewer",
73
+ "executor": "pi",
74
+ "complexity": "HIGH",
75
+ "writePolicy": "read-only",
76
+ "outputContract": "First line VERDICT: pass or VERDICT: request-revision.",
77
+ "subtask_prompt": "Review staging quality."
78
+ },
79
+ {
80
+ "id": "kg-bootstrap-review-gate-shell",
81
+ "depends_on": ["kg-bootstrap-review-pi"],
82
+ "role": "verifier",
83
+ "executor": "shell",
84
+ "complexity": "LOW",
85
+ "writePolicy": "read-only",
86
+ "subtask_prompt": "Gate on VERDICT: pass."
87
+ },
88
+ {
89
+ "id": "kg-bootstrap-promote-shell",
90
+ "depends_on": ["kg-bootstrap-review-gate-shell"],
91
+ "role": "verifier",
92
+ "executor": "shell",
93
+ "complexity": "LOW",
94
+ "writePolicy": "exclusive",
95
+ "writeSet": [
96
+ "knowledge/domains/**",
97
+ "knowledge/services/**",
98
+ "knowledge/modules/**",
99
+ "knowledge/graph/edges.manual.yaml",
100
+ "features/**/knowledge-links.yaml"
101
+ ],
102
+ "subtask_prompt": "B5 promote new files only."
103
+ },
104
+ {
105
+ "id": "kg-bootstrap-materialize-shell",
106
+ "depends_on": ["kg-bootstrap-promote-shell"],
107
+ "role": "closeout",
108
+ "executor": "shell",
109
+ "complexity": "LOW",
110
+ "writePolicy": "exclusive",
111
+ "writeSet": [
112
+ "knowledge/graph/entities-index.yaml",
113
+ "knowledge/graph/edges.yaml"
114
+ ],
115
+ "subtask_prompt": "B6 materialize indexes."
116
+ }
117
+ ]
118
+ }