@tea-agent/loop-agent 0.13.0-beta.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.
Files changed (127) hide show
  1. package/AGENTS.md +2 -0
  2. package/CHANGELOG.md +56 -305
  3. package/README.md +13 -19
  4. package/dist/commands/init.js +92 -23
  5. package/dist/executors/pi-event-serializer.js +33 -11
  6. package/dist/executors/shell-executor.js +200 -21
  7. package/dist/infrastructure/evaluation/candidate-store.js +5 -1
  8. package/dist/worker/observe/spec-evidence.js +19 -10
  9. package/dist/worker/observe/static/app.js +4 -3
  10. package/dist/worker/observe/static/constants.js +10 -2
  11. package/dist/worker/observe/static/dag-helpers.js +37 -8
  12. package/dist/worker/observe/static/dom.js +159 -0
  13. package/dist/worker/observe/static/format-pool.d.ts +71 -0
  14. package/dist/worker/observe/static/format-pool.js +67 -0
  15. package/dist/worker/observe/static/format.js +27 -2
  16. package/dist/worker/observe/static/index.html +76 -34
  17. package/dist/worker/observe/static/kpi.js +12 -6
  18. package/dist/worker/observe/static/markdown-render.js +124 -0
  19. package/dist/worker/observe/static/shell-chrome.js +8 -2
  20. package/dist/worker/observe/static/state.js +20 -0
  21. package/dist/worker/observe/static/styles.css +662 -60
  22. package/dist/worker/observe/static/views/dag-inspector.js +65 -142
  23. package/dist/worker/observe/static/views/dag.js +9 -0
  24. package/dist/worker/observe/static/views/dashboard.js +512 -269
  25. package/dist/worker/observe/static/views/pool.js +595 -237
  26. package/dist/worker/observe/static/views/session-timeline.js +577 -11
  27. package/dist/workflows/dag/backend-test-case-manifest.js +503 -0
  28. package/dist/workflows/dag/backend-test-execution-contract.js +353 -0
  29. package/dist/workflows/dag/backend-test-result-contract.js +568 -0
  30. package/dist/workflows/dag/decision-envelope.js +57 -2
  31. package/dist/workflows/dag/frontend-implementation-contract.js +240 -0
  32. package/dist/workflows/dag/frontend-project-capability.js +309 -0
  33. package/dist/workflows/dag/frontend-repair.js +341 -0
  34. package/dist/workflows/dag/frontend-risk.js +161 -0
  35. package/dist/workflows/dag/frontend-verification-trace.js +190 -0
  36. package/dist/workflows/dag/init-hybrid.js +1020 -125
  37. package/dist/workflows/dag/repair-artifact.js +43 -3
  38. package/dist/workflows/dag/skill-instructions.js +4 -2
  39. package/dist/workflows/dag/types.js +29 -8
  40. package/docs/README.md +2 -0
  41. package/docs/agent-dag-recovery-playbook.md +3 -3
  42. package/docs/agent-dag-runner.md +3 -3
  43. package/docs/architecture/README.md +3 -3
  44. package/docs/architecture/dag-execution.md +1 -1
  45. package/docs/architecture/evolution.md +13 -13
  46. package/docs/architecture/facts-and-state.md +1 -1
  47. package/docs/architecture/runtime-boundaries.md +7 -7
  48. package/docs/architecture/system-overview.md +3 -3
  49. package/docs/architecture/worker-and-feature.md +3 -3
  50. package/docs/design/README.md +7 -7
  51. package/docs/development-principles.md +4 -4
  52. package/docs/exec-plans/active/README.md +2 -4
  53. package/docs/exec-plans/completed/README.md +29 -6
  54. package/docs/feature-workflow.md +57 -32
  55. package/docs/init-surface.manifest.json +21 -3
  56. package/docs/loop-agent-harness.md +8 -8
  57. package/docs/production-readiness.md +1 -1
  58. package/docs/progress/README.md +20 -3
  59. package/docs/reports/README.md +53 -7
  60. package/docs/templates/agent-dag.supervised-implementation.json +127 -8
  61. package/docs/templates/backend-test-case-manifest.schema.json +190 -0
  62. package/docs/templates/backend-test-dag.classify.prompt.md +75 -0
  63. package/docs/templates/backend-test-dag.generate-pytest.prompt.md +6 -4
  64. package/docs/templates/backend-test-dag.json +269 -21
  65. package/docs/templates/backend-test-dag.retrospect.prompt.md +44 -30
  66. package/docs/templates/backend-test-dag.review-cases.prompt.md +6 -4
  67. package/docs/templates/backend-test-execution.schema.json +133 -0
  68. package/docs/templates/backend-test-result.schema.json +99 -0
  69. package/docs/templates/branch-merge-report.md +93 -0
  70. package/docs/templates/frontend-eval/fixtures/failures/01-type-build-error.md +17 -0
  71. package/docs/templates/frontend-eval/fixtures/failures/02-unit-component-test-fail.md +16 -0
  72. package/docs/templates/frontend-eval/fixtures/failures/03-fixture-schema-drift.md +16 -0
  73. package/docs/templates/frontend-eval/fixtures/failures/04-missing-loading-empty-error-state.md +16 -0
  74. package/docs/templates/frontend-eval/fixtures/failures/05-forbidden-write-writeset-expansion.md +16 -0
  75. package/docs/templates/frontend-eval/fixtures/failures/06-unapproved-dependency-add.md +16 -0
  76. package/docs/templates/frontend-eval/fixtures/failures/07-mock-production-on.md +21 -0
  77. package/docs/templates/frontend-eval/fixtures/functional/01-simple-component-style.md +29 -0
  78. package/docs/templates/frontend-eval/fixtures/functional/02-form-validation.md +28 -0
  79. package/docs/templates/frontend-eval/fixtures/functional/03-list-detail-page.md +28 -0
  80. package/docs/templates/frontend-eval/fixtures/functional/04-api-mock.md +29 -0
  81. package/docs/templates/frontend-eval/fixtures/functional/05-permission-auth-gated-ui.md +27 -0
  82. package/docs/templates/frontend-eval/fixtures/functional/06-ssr-server-client-boundary.md +28 -0
  83. package/docs/templates/frontend-eval/fixtures/functional/07-shared-public-component-api.md +28 -0
  84. package/docs/templates/frontend-eval/fixtures/functional/08-pure-local-no-remote.md +27 -0
  85. package/docs/templates/frontend-eval/metrics.md +138 -0
  86. package/docs/templates/frontend-eval/smoke-targets.md +53 -0
  87. package/docs/templates/frontend-implementation-contract.schema.json +27 -0
  88. package/docs/verification-matrix.md +1 -1
  89. package/examples/decision-gate-agent-dag.json +4 -4
  90. package/examples/hybrid-loop-agent-dag.json +1 -1
  91. package/package.json +2 -2
  92. package/skills/ai-engineering-context/SKILL.md +2 -2
  93. package/skills/browser-tools/SKILL.md +196 -0
  94. package/skills/browser-tools/browser-content.js +103 -0
  95. package/skills/browser-tools/browser-cookies.js +35 -0
  96. package/skills/browser-tools/browser-eval.js +53 -0
  97. package/skills/browser-tools/browser-hn-scraper.js +108 -0
  98. package/skills/browser-tools/browser-nav.js +44 -0
  99. package/skills/browser-tools/browser-pick.js +162 -0
  100. package/skills/browser-tools/browser-screenshot.js +34 -0
  101. package/skills/browser-tools/browser-start.js +86 -0
  102. package/skills/browser-tools/package-lock.json +2556 -0
  103. package/skills/browser-tools/package.json +19 -0
  104. package/skills/frontend-implementation/SKILL.md +3 -1
  105. package/skills/frontend-implementation/references/node-contracts.md +17 -66
  106. package/skills/frontend-verification/SKILL.md +1 -1
  107. package/skills/grill-with-docs/SKILL.md +5 -5
  108. package/skills/grill-with-docs/adr-format.md +3 -3
  109. package/skills/init-capability-evolution/SKILL.md +5 -5
  110. package/skills/loop-agent/SKILL.md +5 -5
  111. package/skills/loop-agent/references/README.md +3 -3
  112. package/skills/loop-agent/references/command-reference.md +39 -17
  113. package/skills/loop-agent/references/docs-converge.md +15 -15
  114. package/skills/loop-agent/references/harness-policy.md +2 -2
  115. package/skills/loop-agent/references/hybrid-dag.md +20 -15
  116. package/skills/loop-agent/references/multi-worktree.md +1 -1
  117. package/skills/loop-agent/references/orchestrator-and-interventions.md +8 -8
  118. package/skills/loop-agent/references/task-workflow.md +1 -1
  119. package/skills/loop-agent/references/verification-and-failure-handling.md +6 -4
  120. package/skills/requesting-code-review/SKILL.md +1 -1
  121. package/skills/systematic-debugging/CREATION-LOG.md +3 -3
  122. package/skills/systematic-debugging/SKILL.md +1 -1
  123. package/skills/systematic-debugging/test-academic.md +1 -1
  124. package/skills/systematic-debugging/test-pressure-1.md +1 -1
  125. package/skills/systematic-debugging/test-pressure-2.md +1 -1
  126. package/skills/systematic-debugging/test-pressure-3.md +1 -1
  127. package/skills/verification-before-completion/SKILL.md +1 -1
@@ -7,13 +7,16 @@
7
7
  "agentRuntime": "pi-only",
8
8
  "repairWriterProtocol": "explicit-node-v1"
9
9
  },
10
- "objective": "Demonstrate a reusable supervised implementation DAG: contract → parallel scouts → plan → write-set audit → write-set gate → implement → soft verify → process supervisor → repair → hard verify → review verdict → review gate → decision gate → closeout. Write-set, process, and review verdict nodes emit first-line VERDICT for deterministic gates, reducing main-session intervention.",
10
+ "objective": "Demonstrate a reusable supervised implementation DAG: contract → parallel scouts → plan → write-set audit → verdict format repair → bounded plan revision → final write-set audit → verdict format repair → write-set gate → implement → soft verify → process supervisor → repair → hard verify → review verdict → review gate → decision gate → closeout. Write-set, process, and review verdict nodes emit first-line VERDICT for deterministic gates, reducing main-session intervention.",
11
11
  "successCriteria": [
12
12
  "contract-pi returns a read-only implementation contract with narrow write boundaries",
13
13
  "scout-src and scout-tests run in parallel without write conflicts",
14
14
  "plan-pi produces a writeSet coverage matrix with explicit exclusive owners",
15
15
  "write-set-audit-pi validates coverage and returns VERDICT pass or request-revision",
16
- "write-set-gate-shell blocks implement-pi unless write-set-audit-pi first-line VERDICT is pass",
16
+ "write-set-audit-format-repair-pi provides one read-only format recovery attempt without changing substantive findings",
17
+ "plan-revision-pi performs at most one read-only revision round and never expands task allowedPaths",
18
+ "final-write-set-audit-pi re-audits the effective plan after the bounded revision round",
19
+ "write-set-gate-shell blocks implement-pi unless the normalized final audit VERDICT is pass",
17
20
  "implement-pi and repair-pi write only inside declared writeSet",
18
21
  "soft-verify-shell archives focused test exit codes before process supervision",
19
22
  "process-supervisor-pi returns first-line VERDICT pass or request-revision",
@@ -40,7 +43,8 @@
40
43
  "Every task must explicitly declare executor; defaults.executor is schema-only and not a runtime fallback.",
41
44
  "Prefer same-rank parallel read-only scouts over serial chains when outputs are independent.",
42
45
  "Same-rank exclusive writeSet entries must be disjoint.",
43
- "Use executorModels for model routing; do not add defaults.model or legacy top-level models."
46
+ "Use executorModels for model routing; do not add defaults.model or legacy top-level models.",
47
+ "Write-set plan revision is bounded to one round; format repair remains read-only and cannot expand task allowedPaths or authorize writes."
44
48
  ],
45
49
  "defaults": {
46
50
  "executor": "pi",
@@ -185,11 +189,123 @@
185
189
  "subtask_prompt": "Audit plan-pi WriteSet Coverage Matrix against the contract. First non-empty line must be exactly VERDICT: pass or VERDICT: request-revision. List Critical/Important gaps when any required file lacks a single exclusive owner or overlaps forbidden paths. Do not edit files or write root artifacts/**."
186
190
  },
187
191
  {
188
- "id": "write-set-gate-shell",
192
+ "id": "write-set-audit-format-repair-pi",
189
193
  "depends_on": [
190
194
  "write-set-audit-pi"
191
195
  ],
192
196
  "complexity": "LOW",
197
+ "executor": "pi",
198
+ "role": "reviewer",
199
+ "writePolicy": "read-only",
200
+ "allowedPaths": [
201
+ "**"
202
+ ],
203
+ "forbiddenPaths": [
204
+ ".harness/**",
205
+ "artifacts/**"
206
+ ],
207
+ "outputContract": "Plain Markdown whose first non-empty line is exactly VERDICT: pass or VERDICT: request-revision, followed by the original audit findings without substantive changes. No file writes.",
208
+ "subtask_prompt": "Normalize write-set-audit-pi output; this is the single read-only format-repair attempt for the initial audit. First non-empty line must be exactly VERDICT: pass or VERDICT: request-revision. Preserve an existing valid verdict exactly. If the verdict is missing or malformed but the audit states an unambiguous conclusion, add only the matching canonical verdict and preserve the findings. Do not add, remove, or reclassify substantive findings. If the conclusion is ambiguous, emit VERDICT: request-revision and report the format ambiguity. Do not infer a pass from general prose, expand task allowedPaths, or edit files."
209
+ },
210
+ {
211
+ "id": "write-set-format-gate-shell",
212
+ "depends_on": [
213
+ "write-set-audit-format-repair-pi"
214
+ ],
215
+ "complexity": "LOW",
216
+ "executor": "shell",
217
+ "role": "verifier",
218
+ "writePolicy": "read-only",
219
+ "allowedPaths": [
220
+ "**"
221
+ ],
222
+ "forbiddenPaths": [
223
+ ".harness/**",
224
+ "artifacts/**"
225
+ ],
226
+ "outputContract": "Deterministic initial write-set verdict format gate: accept pass or request-revision so the bounded plan-revision stage can run; reject missing or unexpected verdicts.",
227
+ "subtask_prompt": "Validate the normalized initial write-set audit verdict before the bounded plan-revision stage. This gate does not authorize implementation writes.",
228
+ "shell": {
229
+ "verdictGate": {
230
+ "fromNodeId": "write-set-audit-format-repair-pi",
231
+ "accept": [
232
+ "VERDICT: pass",
233
+ "VERDICT: request-revision"
234
+ ],
235
+ "label": "initial write-set audit format",
236
+ "lineMode": "first-verdict-line"
237
+ },
238
+ "cwd": ".",
239
+ "timeoutMs": 60000
240
+ }
241
+ },
242
+ {
243
+ "id": "plan-revision-pi",
244
+ "depends_on": [
245
+ "write-set-format-gate-shell",
246
+ "plan-pi",
247
+ "write-set-audit-format-repair-pi"
248
+ ],
249
+ "complexity": "MED",
250
+ "executor": "pi",
251
+ "role": "planner",
252
+ "writePolicy": "read-only",
253
+ "allowedPaths": [
254
+ "**"
255
+ ],
256
+ "forbiddenPaths": [
257
+ ".harness/**",
258
+ "artifacts/**"
259
+ ],
260
+ "outputContract": "PASS_NO_REVISION_NEEDED when the normalized initial audit passed, otherwise a complete revised implementation plan with a corrected WriteSet Coverage Matrix. No file writes.",
261
+ "subtask_prompt": "Perform the single bounded plan-revision round. If the normalized verdict is VERDICT: pass, output PASS_NO_REVISION_NEEDED and do not change the original plan. If it is VERDICT: request-revision, return a complete revised plan that resolves every finding and includes a corrected WriteSet Coverage Matrix. Do not expand task allowedPaths, weaken forbiddenPaths, or edit files."
262
+ },
263
+ {
264
+ "id": "final-write-set-audit-pi",
265
+ "depends_on": [
266
+ "plan-pi",
267
+ "plan-revision-pi",
268
+ "write-set-audit-format-repair-pi"
269
+ ],
270
+ "complexity": "MED",
271
+ "executor": "pi",
272
+ "role": "reviewer",
273
+ "writePolicy": "read-only",
274
+ "allowedPaths": [
275
+ "**"
276
+ ],
277
+ "forbiddenPaths": [
278
+ ".harness/**",
279
+ "artifacts/**"
280
+ ],
281
+ "outputContract": "Plain Markdown whose first non-empty line is VERDICT: pass or VERDICT: request-revision; includes final writeSet coverage findings after the single plan-revision round. No file writes.",
282
+ "subtask_prompt": "Perform the final write-set audit after the single bounded plan-revision round. When plan-revision-pi returned PASS_NO_REVISION_NEEDED, audit the original plan-pi output; otherwise audit the complete revised plan. First non-empty line must be exactly VERDICT: pass or VERDICT: request-revision. Request revision if any required file still lacks one exclusive owner, writeSet is broad or placeholder, forbidden paths overlap, or an initial finding remains unresolved. Do not expand task allowedPaths or edit files."
283
+ },
284
+ {
285
+ "id": "final-write-set-audit-format-repair-pi",
286
+ "depends_on": [
287
+ "final-write-set-audit-pi"
288
+ ],
289
+ "complexity": "LOW",
290
+ "executor": "pi",
291
+ "role": "reviewer",
292
+ "writePolicy": "read-only",
293
+ "allowedPaths": [
294
+ "**"
295
+ ],
296
+ "forbiddenPaths": [
297
+ ".harness/**",
298
+ "artifacts/**"
299
+ ],
300
+ "outputContract": "Plain Markdown whose first non-empty line is exactly VERDICT: pass or VERDICT: request-revision, followed by the original final-audit findings without substantive changes. No file writes.",
301
+ "subtask_prompt": "Normalize final-write-set-audit-pi output; this is the single read-only format-repair attempt for the final audit. Preserve an existing valid verdict exactly. If the verdict is missing or malformed but the audit states an unambiguous conclusion, add only the matching canonical verdict and preserve the findings. Do not add, remove, or reclassify substantive findings. If the conclusion is ambiguous, emit VERDICT: request-revision. Do not infer a pass from general prose, expand task allowedPaths, or edit files."
302
+ },
303
+ {
304
+ "id": "write-set-gate-shell",
305
+ "depends_on": [
306
+ "final-write-set-audit-format-repair-pi"
307
+ ],
308
+ "complexity": "LOW",
193
309
  "executor": "shell",
194
310
  "role": "verifier",
195
311
  "writePolicy": "read-only",
@@ -200,11 +316,11 @@
200
316
  ".harness/**",
201
317
  "artifacts/**"
202
318
  ],
203
- "outputContract": "Deterministic write-set audit verdict gate: exit 0 only when write-set-audit-pi first non-empty assistant output line is pass.",
204
- "subtask_prompt": "Deterministic gate: block implement-pi unless write-set-audit-pi emitted VERDICT: pass.",
319
+ "outputContract": "Deterministic final write-set audit verdict gate: exit 0 only when final-write-set-audit-format-repair-pi emits VERDICT: pass after the bounded revision round.",
320
+ "subtask_prompt": "Deterministic gate: block implement-pi unless the normalized final write-set audit emitted VERDICT: pass.",
205
321
  "shell": {
206
322
  "verdictGate": {
207
- "fromNodeId": "write-set-audit-pi",
323
+ "fromNodeId": "final-write-set-audit-format-repair-pi",
208
324
  "accept": [
209
325
  "VERDICT: pass"
210
326
  ],
@@ -218,7 +334,10 @@
218
334
  {
219
335
  "id": "implement-pi",
220
336
  "depends_on": [
221
- "write-set-gate-shell"
337
+ "write-set-gate-shell",
338
+ "plan-pi",
339
+ "plan-revision-pi",
340
+ "final-write-set-audit-format-repair-pi"
222
341
  ],
223
342
  "complexity": "HIGH",
224
343
  "executor": "pi",
@@ -0,0 +1,190 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://tea-agent.dev/schemas/backend-test-case-manifest-v1.json",
4
+ "title": "Backend Test Case Manifest v1",
5
+ "description": "Run-owned AC → BE-* case → automation mapping. Coverage ratios are deterministic gate outputs; models must not invent percentages. Conditional required fields mirror Zod: generated requires file+symbol; skipped|unsupported requires gapReason; each evidence gap requires acId and/or caseId.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": ["schemaVersion", "sourceBinding", "cases", "evidenceGaps"],
9
+ "properties": {
10
+ "schemaVersion": { "const": 1 },
11
+ "sourceBinding": {
12
+ "type": "object",
13
+ "additionalProperties": false,
14
+ "required": [
15
+ "taskId",
16
+ "requirementPath",
17
+ "requirementSha256",
18
+ "referencePaths",
19
+ "requirementIds"
20
+ ],
21
+ "properties": {
22
+ "taskId": { "type": "string", "minLength": 1 },
23
+ "requirementPath": { "type": "string", "minLength": 1 },
24
+ "requirementSha256": {
25
+ "type": "string",
26
+ "pattern": "^[a-f0-9]{64}$"
27
+ },
28
+ "referencePaths": {
29
+ "type": "array",
30
+ "items": { "type": "string", "minLength": 1 }
31
+ },
32
+ "requirementIds": {
33
+ "type": "array",
34
+ "items": {
35
+ "type": "string",
36
+ "pattern": "^(?:REQ|BR|AC)-[A-Z0-9]+(?:-[A-Z0-9]+)*$"
37
+ }
38
+ }
39
+ }
40
+ },
41
+ "cases": {
42
+ "type": "array",
43
+ "items": {
44
+ "type": "object",
45
+ "additionalProperties": false,
46
+ "required": [
47
+ "caseId",
48
+ "acIds",
49
+ "title",
50
+ "category",
51
+ "automationStatus"
52
+ ],
53
+ "properties": {
54
+ "caseId": {
55
+ "type": "string",
56
+ "pattern": "^BE-[A-Z0-9]+(?:-[A-Z0-9]+)*-\\d{3}$"
57
+ },
58
+ "acIds": {
59
+ "type": "array",
60
+ "minItems": 1,
61
+ "items": {
62
+ "type": "string",
63
+ "pattern": "^AC-[A-Z0-9]+(?:-[A-Z0-9]+)*$"
64
+ }
65
+ },
66
+ "title": { "type": "string", "minLength": 1 },
67
+ "category": {
68
+ "type": "string",
69
+ "enum": [
70
+ "positive",
71
+ "negative",
72
+ "boundary",
73
+ "state-transition",
74
+ "auth",
75
+ "timeout",
76
+ "concurrency",
77
+ "other"
78
+ ]
79
+ },
80
+ "automationStatus": {
81
+ "type": "string",
82
+ "enum": ["planned", "generated", "skipped", "unsupported"]
83
+ },
84
+ "endpointRef": { "type": "string", "minLength": 1 },
85
+ "ruleRefs": {
86
+ "type": "array",
87
+ "items": { "type": "string", "minLength": 1 }
88
+ },
89
+ "file": {
90
+ "type": "string",
91
+ "minLength": 1,
92
+ "description": "Repo-relative posix path required when automationStatus=generated"
93
+ },
94
+ "symbol": {
95
+ "type": "string",
96
+ "minLength": 1,
97
+ "description": "pytest function name required when automationStatus=generated; must bind to caseId"
98
+ },
99
+ "gapReason": {
100
+ "type": "string",
101
+ "minLength": 1,
102
+ "description": "Required when automationStatus is skipped or unsupported"
103
+ },
104
+ "evidenceRef": { "type": "string", "minLength": 1 }
105
+ },
106
+ "allOf": [
107
+ {
108
+ "if": {
109
+ "properties": {
110
+ "automationStatus": { "const": "generated" }
111
+ },
112
+ "required": ["automationStatus"]
113
+ },
114
+ "then": {
115
+ "required": ["file", "symbol"]
116
+ }
117
+ },
118
+ {
119
+ "if": {
120
+ "properties": {
121
+ "automationStatus": {
122
+ "enum": ["skipped", "unsupported"]
123
+ }
124
+ },
125
+ "required": ["automationStatus"]
126
+ },
127
+ "then": {
128
+ "required": ["gapReason"]
129
+ }
130
+ }
131
+ ]
132
+ }
133
+ },
134
+ "evidenceGaps": {
135
+ "type": "array",
136
+ "items": {
137
+ "type": "object",
138
+ "additionalProperties": false,
139
+ "required": ["description"],
140
+ "properties": {
141
+ "acId": {
142
+ "type": "string",
143
+ "pattern": "^AC-[A-Z0-9]+(?:-[A-Z0-9]+)*$"
144
+ },
145
+ "caseId": {
146
+ "type": "string",
147
+ "pattern": "^BE-[A-Z0-9]+(?:-[A-Z0-9]+)*-\\d{3}$"
148
+ },
149
+ "description": { "type": "string", "minLength": 1 },
150
+ "evidenceRef": { "type": "string", "minLength": 1 }
151
+ },
152
+ "anyOf": [
153
+ { "required": ["acId"] },
154
+ { "required": ["caseId"] }
155
+ ]
156
+ }
157
+ },
158
+ "coverageSummary": {
159
+ "type": "object",
160
+ "additionalProperties": false,
161
+ "required": [
162
+ "explicitAcCount",
163
+ "coveredAcCount",
164
+ "gappedAcCount",
165
+ "caseCount",
166
+ "generatedCount",
167
+ "plannedCount",
168
+ "skippedCount",
169
+ "unsupportedCount",
170
+ "acCoverageRatio"
171
+ ],
172
+ "properties": {
173
+ "explicitAcCount": { "type": "integer", "minimum": 0 },
174
+ "coveredAcCount": { "type": "integer", "minimum": 0 },
175
+ "gappedAcCount": { "type": "integer", "minimum": 0 },
176
+ "caseCount": { "type": "integer", "minimum": 0 },
177
+ "generatedCount": { "type": "integer", "minimum": 0 },
178
+ "plannedCount": { "type": "integer", "minimum": 0 },
179
+ "skippedCount": { "type": "integer", "minimum": 0 },
180
+ "unsupportedCount": { "type": "integer", "minimum": 0 },
181
+ "acCoverageRatio": {
182
+ "type": "number",
183
+ "minimum": 0,
184
+ "maximum": 1,
185
+ "description": "Deterministic coveredAcCount/explicitAcCount (or 1 when no explicit AC)"
186
+ }
187
+ }
188
+ }
189
+ }
190
+ }
@@ -0,0 +1,75 @@
1
+ # Backend Test DAG Classify Prompt Template
2
+
3
+ ## Purpose
4
+
5
+ Use this prompt for a **read-only classification** node: `executor: "pi"`, `role: "reviewer"`, `writePolicy: "read-only"`. The agent reads the run-owned Backend Test Result v1 artifact and returns structured failure classification JSON.
6
+
7
+ Do **not** create a new executor type. Do **not** write repository files.
8
+
9
+ ## Recommended DAG Node Shape
10
+
11
+ ```json
12
+ {
13
+ "id": "classify-backend-test-result-pi",
14
+ "depends_on": ["parse-backend-test-result-shell"],
15
+ "complexity": "MED",
16
+ "executor": "pi",
17
+ "role": "reviewer",
18
+ "writePolicy": "read-only",
19
+ "allowedPaths": ["**"],
20
+ "forbiddenPaths": [".harness/**", "artifacts/**"],
21
+ "outputContract": "Pure JSON classification: category in {ProductBug,TestBug,EnvFailure,ContractMismatch,FlakyTest,Unknown}, evidence[], confidence (capped), notes. No file writes.",
22
+ "subtask_prompt_markdown": "./backend-test-dag.classify.prompt.md"
23
+ }
24
+ ```
25
+
26
+ ## Prompt Body
27
+
28
+ You are the Backend Test DAG **result classifier** agent.
29
+
30
+ Your job is to classify the structured Backend Test Result v1 produced by `parse-backend-test-result-shell`. Return **exactly one JSON object**. Prefer pure JSON; a single fenced `json` block is tolerated; no trailing prose. Read-only: do not modify code, docs, artifacts, or repository files.
31
+
32
+ ### Inputs (authoritative)
33
+
34
+ 1. **Result v1** — `$HARNESS_DAG_RUN_DIR/contracts/backend-test-result.json` (schemaId `backend-test-result-v1`).
35
+ 2. Optional: execute-node stdout markers (`pytestExitCode=…`, `JUnit report: …`) as secondary evidence only.
36
+
37
+ Do **not** invent pass rates or failure lists from raw logs when Result v1 is present. Counts and `failures[]` come from the result artifact only.
38
+
39
+ ### Output JSON shape
40
+
41
+ ```json
42
+ {
43
+ "schemaVersion": 1,
44
+ "category": "ProductBug",
45
+ "confidence": 0.0,
46
+ "evidence": ["result.outcome=completed-with-failures", "failures[0].name=…"],
47
+ "notes": "short rationale",
48
+ "forbiddenCategoriesHonored": ["FlakyTest"]
49
+ }
50
+ ```
51
+
52
+ ### Categories
53
+
54
+ | Category | When |
55
+ |----------|------|
56
+ | **ProductBug** | Assertion failures that indicate implementation/API behavior mismatch (only when collection/command/report are healthy). |
57
+ | **TestBug** | Broken test code, wrong expectations, bad fixtures, or collection/import errors clearly in tests. |
58
+ | **EnvFailure** | Missing env, service down, tooling/runtime failure, command-error. |
59
+ | **ContractMismatch** | Execution/analysis contract assumptions violated (wrong testRoot/mode, missing readiness). |
60
+ | **FlakyTest** | **Only** with multi-run historical evidence of intermittent pass/fail. |
61
+ | **Unknown** | Insufficient evidence. |
62
+
63
+ ### Hard constraints (MUST)
64
+
65
+ 1. **Single-run failure MUST NOT use `FlakyTest`.** Prefer `Unknown`, `TestBug`, or `ProductBug`.
66
+ 2. If `executionStatus` or `outcome` is `collection-error`, `command-error`, or `report-error`, **MUST NOT** use `ProductBug`. Prefer `EnvFailure`, `TestBug`, or `Unknown`.
67
+ 3. If `outcome=passed` with `failed=0` and `error=0`, set `category` to `Unknown` (or omit product diagnosis) and note all-pass; do not invent bugs.
68
+ 4. `confidence` caps: ≤ `0.75` for assertion failures; ≤ `0.6` for env/collection/command/report errors; `1.0` only for all-pass with no issues.
69
+ 5. `evidence[]` must cite concrete result fields (`outcome`, `executionStatus`, `failed`, `failures[].name`, `pytestExitCode`).
70
+
71
+ ### Non-goals
72
+
73
+ - Do not rewrite Result v1.
74
+ - Do not decide final DAG success/failure (that is `backend-test-outcome-gate-shell`).
75
+ - Do not implement M3 case manifest / Task Pool auto follow-up.
@@ -11,7 +11,7 @@ Do **not** create a new executor type. This is a standard `executor: pi` writer
11
11
  ```json
12
12
  {
13
13
  "id": "generate-backend-pytest-pi",
14
- "depends_on": ["review-backend-cases-gate-shell"],
14
+ "depends_on": ["review-backend-cases-gate-shell", "backend-test-execution-contract-shell"],
15
15
  "complexity": "HIGH",
16
16
  "executor": "pi",
17
17
  "role": "implementer",
@@ -38,10 +38,12 @@ Your job is to convert reviewed test cases under `testcase/md/` into pytest auto
38
38
 
39
39
  ### Inputs
40
40
 
41
- 1. **Reviewed test cases** — files under `testcase/md/` (approved by `review-backend-cases-pi`).
42
- 2. **Target project conventions** — read `conftest.py`, `pytest.ini` / `pyproject.toml` to understand conventions, but do NOT modify them.
41
+ 1. **Reviewed test cases** — files under `testcase/md/` (approved by `review-backend-cases-pi` / `review-backend-cases-gate-shell`).
42
+ 2. **Validated Backend Test Analysis v1** — run-owned `contracts/backend-test-analysis.json` from `backend-test-analysis-contract-shell`.
43
+ 3. **Validated Backend Test Execution Contract v1** — run-owned `contracts/backend-test-execution.json` from `backend-test-execution-contract-shell` (fixtures, env *names*, `testRoot`, `targetMode`, authenticationMode).
44
+ 4. **Target project conventions** — read `conftest.py`, `pytest.ini` / `pyproject.toml` to understand conventions, but do NOT modify them.
43
45
 
44
- Do NOT re-read source documents. Use the reviewed cases only.
46
+ Do NOT re-read source documents for free-form analysis. Use only reviewed cases and the validated contracts. Use only fixture/env/testRoot facts already present in the execution contract; never invent production credentials or secret values.
45
47
 
46
48
  ### Conversion Rules
47
49