@tea-agent/loop-agent 0.39.3 → 0.40.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +135 -92
- package/dist/adapters/context-transfer/optional-pi-handoff.js +31 -0
- package/dist/adapters/context-transfer/pi-session.js +61 -0
- package/dist/build-stamp.json +3 -3
- package/dist/cli/command-definitions.js +12 -0
- package/dist/cli/program.js +23 -1
- package/dist/commands/dag-artifact.js +284 -0
- package/dist/commands/dag-context.js +184 -0
- package/dist/commands/dag-rerun.js +206 -1
- package/dist/executors/dag-pi-executor.js +108 -19
- package/dist/executors/pi-executor.js +4 -2
- package/dist/executors/pi-sdk-executor.js +49 -1
- package/dist/executors/pi-writer-tool-policy.js +57 -1
- package/dist/executors/shell-executor.js +42 -2
- package/dist/executors/workspace-write-snapshot.js +68 -0
- package/dist/{worker → infrastructure}/console/app-data.js +4 -0
- package/dist/infrastructure/console/artifact-revision-store.js +430 -0
- package/dist/infrastructure/console/context-export-store.js +160 -0
- package/dist/infrastructure/console/dir-lock.js +132 -0
- package/dist/infrastructure/harness/artifact-store.js +10 -1
- package/dist/infrastructure/harness/atomic-write.js +35 -2
- package/dist/shared/context-transfer/artifact-revision.js +172 -0
- package/dist/shared/context-transfer.js +418 -0
- package/dist/shared/operator/capabilities.js +14 -0
- package/dist/shared/operator/safe-run-summary.js +1 -0
- package/dist/shared/path-safety.js +93 -0
- package/dist/shared/preview.js +28 -4
- package/dist/task/config-types.js +12 -1
- package/dist/task/source-prepare/fragment-inventory.js +1 -14
- package/dist/task/task-demand-routing.js +3 -0
- package/dist/worker/console/chat/chat-event-store.js +77 -7
- package/dist/worker/console/chat/context-panel.js +7 -0
- package/dist/worker/console/chat/deferred-turn.js +12 -0
- package/dist/worker/console/chat/pi-runtime.js +331 -18
- package/dist/worker/console/chat/provider-error.js +98 -0
- package/dist/worker/console/chat/resource-preferences-store.js +1 -1
- package/dist/worker/console/chat/routes.js +389 -56
- package/dist/worker/console/chat/session-stats.js +179 -0
- package/dist/worker/console/chat/session-store.js +94 -64
- package/dist/worker/console/chat/todos.js +115 -0
- package/dist/worker/console/chat/tool-preview.js +42 -0
- package/dist/worker/console/chat/turn-process.js +20 -55
- package/dist/worker/console/chat/user-questions.js +266 -0
- package/dist/worker/console/chat/workspace-landing.js +79 -0
- package/dist/worker/console/console-update-runtime.js +1 -1
- package/dist/worker/console/context-transfer-diagnostics.js +198 -0
- package/dist/worker/console/dag-confirmation.js +1 -1
- package/dist/worker/console/dag-execution-receipt.js +1 -1
- package/dist/worker/console/doctor.js +1 -1
- package/dist/worker/console/draft-store.js +1 -1
- package/dist/worker/console/human-gate-token.js +1 -1
- package/dist/worker/console/index.js +3 -3
- package/dist/worker/console/interview/assessment.js +1 -1
- package/dist/worker/console/interview/session.js +1 -1
- package/dist/worker/console/native-directory-picker.js +13 -0
- package/dist/worker/console/operation-runner.js +45 -4
- package/dist/worker/console/operation-sse.js +1 -1
- package/dist/worker/console/operation-wait.js +1 -1
- package/dist/worker/console/operator-actions.js +104 -3
- package/dist/worker/console/operator-surface-health.js +1 -1
- package/dist/worker/console/operator-user-error.js +128 -0
- package/dist/worker/console/routes.js +927 -8
- package/dist/worker/console/security.js +39 -4
- package/dist/worker/console/server.js +532 -187
- package/dist/worker/console/static/assets/{abnfDiagram-N423BO3Z-CTx1TrNa.js → abnfDiagram-N423BO3Z-CpWvwARc.js} +1 -1
- package/dist/worker/console/static/assets/{arc-B4i9cVxX.js → arc-DctXgO-g.js} +1 -1
- package/dist/worker/console/static/assets/{architectureDiagram-T3A2C74G-BAXE8_Rl.js → architectureDiagram-T3A2C74G-D4mIkoQl.js} +1 -1
- package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-C5Xh59at.js → blockDiagram-VBNYF7ZC-ClG0--KO.js} +1 -1
- package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-B_asOzAu.js → c4Diagram-5PPSVZJV-CwdLk78T.js} +1 -1
- package/dist/worker/console/static/assets/channel-C9VQZ-ru.js +1 -0
- package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-wRO_iRNc.js → chunk-2GRJ4B5K-DKczcu-O.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-ByOaSh_G.js → chunk-2Q5K7J3B-BV6F-vBI.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5RXB4S5H-DjLzudan.js → chunk-5RXB4S5H-DtojVnvA.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5VM5RSS4-JCNGkXYT.js → chunk-5VM5RSS4-BjDQRGnO.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-BhrPXXMZ.js → chunk-6Q2QTUOP-I0fV6ngU.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-GF5L2VYU-TJ5JuEBT.js → chunk-GF5L2VYU-BM8C-mmC.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-JWPE2WC7-VVthn_mD.js → chunk-JWPE2WC7-BEK-a15e.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-KBJHAD2P-D60-Mny4.js → chunk-KBJHAD2P-CQsg_fSR.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-RYQCIY6F-zXv7aVye.js → chunk-RYQCIY6F-B-BcaUm3.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-XXDRQBXY-By9VQoi1.js → chunk-XXDRQBXY-D1Bu08fg.js} +1 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-BsCkw5MF.js +1 -0
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-BsCkw5MF.js +1 -0
- package/dist/worker/console/static/assets/{cose-bilkent-JH36ORCC-C4zQLe-M.js → cose-bilkent-JH36ORCC-q8nwtxBR.js} +1 -1
- package/dist/worker/console/static/assets/{cynefin-VYW2F7L2-wh5N2ReN.js → cynefin-VYW2F7L2-CruhpURw.js} +1 -1
- package/dist/worker/console/static/assets/{cynefinDiagram-MW4NZA55-Dlu5wIqs.js → cynefinDiagram-MW4NZA55-CJne6iYF.js} +1 -1
- package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-CrDgthc6.js → dagre-VZM6K2ZE-CbeLvBU5.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-7IWD3JNH-zN1clg27.js → diagram-7IWD3JNH-DmCxH1Pe.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-BN-o7J7-.js → diagram-B4RE2ZJO-DJ5OYhtC.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-LBJQPF4R-C8SuPt0d.js → diagram-LBJQPF4R-B-UN-hln.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-Q27KOJAE-BoizuHbZ.js → diagram-Q27KOJAE-CcEro8Ey.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-UB23O5K3-BzUzXixG.js → diagram-UB23O5K3-BBBzDden.js} +1 -1
- package/dist/worker/console/static/assets/{ebnfDiagram-BXEA7PRR-Ev3lA4Cf.js → ebnfDiagram-BXEA7PRR-xKEyH-oo.js} +1 -1
- package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-GALUzRbs.js → erDiagram-JOGREHBK-C7xl63VC.js} +1 -1
- package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-CZJN65Sb.js → flowDiagram-UKHOOZJN-nthQQ9nR.js} +1 -1
- package/dist/worker/console/static/assets/{ganttDiagram-PKOTCBZU-JLB9OESl.js → ganttDiagram-PKOTCBZU-CWN5mE33.js} +1 -1
- package/dist/worker/console/static/assets/{gitGraphDiagram-DS77QQ5N-CcvCr4GD.js → gitGraphDiagram-DS77QQ5N-Wn86tQ6N.js} +1 -1
- package/dist/worker/console/static/assets/index-D-0NVyMk.css +1 -0
- package/dist/worker/console/static/assets/index-gwyOxQiS.js +407 -0
- package/dist/worker/console/static/assets/{infoDiagram-6WML65LV-HG5z7aVg.js → infoDiagram-6WML65LV-_WQymGtW.js} +1 -1
- package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-BHEu9chR.js → ishikawaDiagram-WSZJBQD7-COBeivBm.js} +1 -1
- package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-Cp_Up8-a.js → journeyDiagram-NVQOT4AX-CwGOJl3Q.js} +1 -1
- package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-DvVeY-em.js → kanban-definition-27J2QSJJ-Ci0CJ5Vi.js} +1 -1
- package/dist/worker/console/static/assets/{linear-aGmcjgTn.js → linear-CPjMq6vN.js} +1 -1
- package/dist/worker/console/static/assets/{mermaid.core-Biyo-tqA.js → mermaid.core-Z0wGoe0b.js} +5 -5
- package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-DyxY2pIb.js → mindmap-definition-FAOFIHXS-dISked0d.js} +1 -1
- package/dist/worker/console/static/assets/{pegDiagram-VL7TDLO6-CkdGuc50.js → pegDiagram-VL7TDLO6-BJxgof7Y.js} +1 -1
- package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-NNQI9xVR.js → pieDiagram-7S7Q4E2Y-CIblU8eW.js} +1 -1
- package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-PAJkuz_G.js → quadrantDiagram-CIZ2JOQS-vwYiqh8E.js} +1 -1
- package/dist/worker/console/static/assets/{railroadDiagram-AXF67PYL-ZwrQod0O.js → railroadDiagram-AXF67PYL-_iOsVeFm.js} +1 -1
- package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP-D3ZfrzM2.js → requirementDiagram-LRYGKXZP-Dk0MLxO_.js} +1 -1
- package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-DDGFmWk5.js → sankeyDiagram-W5VNT64P-Dx7HtLVW.js} +1 -1
- package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-DO6mmXTA.js → sequenceDiagram-SI44F4Z6-DRuWjlpL.js} +1 -1
- package/dist/worker/console/static/assets/{sizeCapture-X5ZJPWSS-DMbCQiJt.js → sizeCapture-X5ZJPWSS-Bhy9DQAA.js} +1 -1
- package/dist/worker/console/static/assets/{stateDiagram-OKZ733FA-Di_YUEfC.js → stateDiagram-OKZ733FA-DAx9twnU.js} +1 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-Dmdf8cGy.js +1 -0
- package/dist/worker/console/static/assets/{swimlanes-SLNWSIFB-Bn2PphNJ.js → swimlanes-SLNWSIFB-okMlvVrM.js} +2 -2
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-W1IcAFff.js +8 -0
- package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-DPh8pRsp.js → timeline-definition-Z64GVDOM-DXqCKe37.js} +1 -1
- package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-GMfl26pW.js → vennDiagram-T6HMQDX7-CeIUkwBh.js} +1 -1
- package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-DTlmVrmF.js → wardleyDiagram-T6FBY63Y-BP76BKTN.js} +1 -1
- package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-YGBjKAS5.js → xychartDiagram-ELKLHX3M-BpVI0OpF.js} +1 -1
- package/dist/worker/console/static/index.html +7 -2
- package/dist/worker/console/static-src/app/console-types.js +29 -4
- package/dist/worker/console/static-src/app/useConsoleShell.js +30 -12
- package/dist/worker/console/static-src/app/useOperatorActions.js +36 -6
- package/dist/worker/console/static-src/app/useRecoveryConsole.js +10 -11
- package/dist/worker/console/static-src/app/useRunProgress.js +2 -1
- package/dist/worker/console/static-src/app/useTaskWizard.js +2 -2
- package/dist/worker/console/static-src/night/useNightBoard.js +8 -5
- package/dist/worker/console/static-src/operator-chat/chat-sse-events.js +141 -8
- package/dist/worker/console/static-src/operator-chat/compaction-message.js +79 -0
- package/dist/worker/console/static-src/operator-chat/details-dag-actions.js +122 -0
- package/dist/worker/console/static-src/operator-chat/refs.js +3 -0
- package/dist/worker/console/static-src/operator-chat/runtime-selection-labels.js +27 -0
- package/dist/worker/console/static-src/operator-chat/spatial-overlay.js +1 -2
- package/dist/worker/console/static-src/operator-chat/turn-stream-controller.js +25 -0
- package/dist/worker/console/static-src/operator-chat/turn-submission.js +3 -2
- package/dist/worker/console/static-src/operator-chat/useChatSessions.js +181 -87
- package/dist/worker/console/static-src/operator-chat/useChatStream.js +159 -44
- package/dist/worker/console/static-src/operator-chat/useChatThread.js +177 -8
- package/dist/worker/console/static-src/operator-chat/useRepoBrowser.js +63 -9
- package/dist/worker/console/static-src/operator-chat/useWorkspaceBrowserGate.js +4 -0
- package/dist/worker/console/static-src/operator-chat/workspace-layout-mode.js +3 -3
- package/dist/worker/console/static-src/shell/useWorkspaces.js +299 -0
- package/dist/worker/console/static-src/shell/workspace-route.js +339 -0
- package/dist/worker/console/workspace-context.js +260 -0
- package/dist/worker/console/workspace-registry.js +214 -0
- package/dist/worker/continuation/worker-continuation.js +278 -0
- package/dist/worker/observe/health.js +1 -1
- package/dist/worker/observe/node-transparency.js +572 -0
- package/dist/worker/observe/routes.js +51 -1
- package/dist/worker/observe/server.js +4 -0
- package/dist/worker/observe/static/api.js +94 -10
- package/dist/worker/observe/static/app.js +18 -70
- package/dist/worker/observe/static/dag-context-reason-labels.d.ts +9 -0
- package/dist/worker/observe/static/dag-context-reason-labels.js +120 -0
- package/dist/worker/observe/static/index.html +1 -1
- package/dist/worker/observe/static/inspect-workspace.js +307 -0
- package/dist/worker/observe/static/operator-chrome.css +145 -20
- package/dist/worker/observe/static/operator-chrome.d.ts +20 -3
- package/dist/worker/observe/static/operator-chrome.js +330 -100
- package/dist/worker/observe/static/router.d.ts +46 -0
- package/dist/worker/observe/static/router.js +25 -1
- package/dist/worker/observe/static/state.d.ts +50 -0
- package/dist/worker/observe/static/state.js +175 -1
- package/dist/worker/observe/static/styles.css +1039 -128
- package/dist/worker/observe/static/views/dag-inspector.js +1218 -60
- package/dist/worker/observe/static/views/dag.js +2 -1
- package/dist/worker/observe/static/views/dashboard.js +6 -4
- package/dist/worker/observe/static/views/night.js +2 -2
- package/dist/worker/observe/static/views/pool.js +1 -0
- package/dist/worker/observe/static/views/run.js +3 -1
- package/dist/worker/observe/static/views/session-timeline.js +75 -10
- package/dist/worker/observe/static/views/task.js +1 -1
- package/dist/worker/outcomes/adapters.js +19 -0
- package/dist/worker/outcomes/types.js +1 -0
- package/dist/worker/pool/attempt-lease.js +97 -66
- package/dist/worker/pool/begin-attempt-with-lease.js +1 -0
- package/dist/worker/pool/reconcile.js +46 -1
- package/dist/worker/pool/run-store.js +2 -0
- package/dist/worker/pool/state-projection.js +2 -0
- package/dist/worker/task-spec/workflow-routing.js +8 -3
- package/dist/workflows/dag/artifact-bindings.js +149 -0
- package/dist/workflows/dag/artifact-revision-schema-registry.js +31 -0
- package/dist/workflows/dag/backend-test-pytest-collection.js +11 -10
- package/dist/workflows/dag/backend-test-writer-completeness.js +7 -12
- package/dist/workflows/dag/context-receipt.js +305 -0
- package/dist/workflows/dag/context-transfer/context-bundle.js +423 -0
- package/dist/workflows/dag/context-transfer/operator-actions.js +61 -0
- package/dist/workflows/dag/context-transfer/renderers.js +93 -0
- package/dist/workflows/dag/dynamic-runtime/map.js +1 -0
- package/dist/workflows/dag/frontend-implementation-contract.js +1 -89
- package/dist/workflows/dag/init-hybrid.js +259 -47
- package/dist/workflows/dag/interrupt-request.js +3 -3
- package/dist/workflows/dag/lifecycle.js +3 -3
- package/dist/workflows/dag/node-execution.js +112 -27
- package/dist/workflows/dag/path-safety.js +1 -0
- package/dist/workflows/dag/prompt.js +29 -4
- package/dist/workflows/dag/rerun-plan.js +272 -0
- package/dist/workflows/dag/rerun-run.js +390 -12
- package/dist/workflows/dag/skill-snapshot.js +1 -0
- package/dist/workflows/dag/types.js +203 -8
- package/docs/README.md +1 -0
- package/docs/architecture/runtime-boundaries.md +6 -6
- package/docs/architecture/worker-and-feature.md +1 -1
- package/docs/operations/local-development-environment.md +21 -0
- package/docs/templates/agent-dag.schema.json +50 -0
- package/docs/templates/backend-test-dag.json +265 -237
- package/docs/templates/product-line/task.yaml +1 -1
- package/harness.json +3 -3
- package/package.json +5 -1
- package/skills/loop-agent/references/command-reference.md +6 -0
- package/dist/worker/console/static/assets/channel-Dj_4Moei.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-C0YYAyCa.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-C0YYAyCa.js +0 -1
- package/dist/worker/console/static/assets/index-CW88Fjbw.js +0 -406
- package/dist/worker/console/static/assets/index-DP0ZJl39.css +0 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-DrdDvela.js +0 -1
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-DPkEAULl.js +0 -8
- package/dist/worker/console/static-src/operator-chat/activity-rail-presentation.js +0 -73
- package/dist/worker/console/static-src/operator-chat/useActivityRailTransition.js +0 -59
- /package/dist/{worker → infrastructure}/console/operation-store.js +0 -0
- /package/dist/{worker → infrastructure}/console/repo-fingerprint.js +0 -0
|
@@ -45,6 +45,60 @@ const CONSTRAINT_FILE = "执行约束.md";
|
|
|
45
45
|
const REFERENCE_DIRECTORY = "references";
|
|
46
46
|
const MAX_SOURCE_EXCERPT_CHARS = 2000;
|
|
47
47
|
const MAX_INLINE_SOURCE_REFERENCE_DOCUMENTS = 8;
|
|
48
|
+
/**
|
|
49
|
+
* Generation-time compiler for machine-declared structured artifacts. The
|
|
50
|
+
* frozen spec remains the sole runtime authority: this compiler never reads
|
|
51
|
+
* prompt/outputContract prose or workspace filenames, and historical specs
|
|
52
|
+
* loaded outside init-hybrid are left untouched.
|
|
53
|
+
*/
|
|
54
|
+
function stampGeneratedArtifactBindings(spec) {
|
|
55
|
+
const producedByNode = new Map();
|
|
56
|
+
for (const task of spec.tasks) {
|
|
57
|
+
if ((task.producesArtifacts?.length ?? 0) > 0) {
|
|
58
|
+
for (const artifact of task.producesArtifacts ?? []) {
|
|
59
|
+
producedByNode.set(task.id, artifact.artifactId);
|
|
60
|
+
}
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
const gate = task.shell?.jsonArtifactGate;
|
|
64
|
+
const structured = task.structuredContractOutput;
|
|
65
|
+
if (!gate && !structured)
|
|
66
|
+
continue;
|
|
67
|
+
const artifactId = `${task.id}.structured-output`;
|
|
68
|
+
const path = gate
|
|
69
|
+
? `${gate.outputDir}/${gate.artifactName}`
|
|
70
|
+
: `contracts/candidates/${task.id}/canonical-contract.json`;
|
|
71
|
+
task.producesArtifacts = [
|
|
72
|
+
{
|
|
73
|
+
artifactId,
|
|
74
|
+
kind: "structured",
|
|
75
|
+
path,
|
|
76
|
+
mediaType: "application/json",
|
|
77
|
+
schemaId: gate?.schemaId ?? FRONTEND_IMPLEMENTATION_CONTRACT_SCHEMA_ID,
|
|
78
|
+
revisionPolicy: "replace-file",
|
|
79
|
+
},
|
|
80
|
+
];
|
|
81
|
+
producedByNode.set(task.id, artifactId);
|
|
82
|
+
}
|
|
83
|
+
for (const task of spec.tasks) {
|
|
84
|
+
const existing = new Set((task.consumesArtifacts ?? []).map((binding) => binding.artifactId));
|
|
85
|
+
const generated = task.depends_on.flatMap((parentNodeId) => {
|
|
86
|
+
const artifactId = producedByNode.get(parentNodeId);
|
|
87
|
+
if (!artifactId || existing.has(artifactId))
|
|
88
|
+
return [];
|
|
89
|
+
existing.add(artifactId);
|
|
90
|
+
return [
|
|
91
|
+
{
|
|
92
|
+
artifactId,
|
|
93
|
+
required: task.dependsPolicy !== "all-or-condition-skip",
|
|
94
|
+
},
|
|
95
|
+
];
|
|
96
|
+
});
|
|
97
|
+
if (generated.length > 0) {
|
|
98
|
+
task.consumesArtifacts = [...(task.consumesArtifacts ?? []), ...generated];
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
48
102
|
const INTERACTIVE_UI_DELIVERY_CONTRACT = [
|
|
49
103
|
"[INTERACTIVE_UI_DELIVERY_CONTRACT]",
|
|
50
104
|
"This is an interactive UI delivery task.",
|
|
@@ -2074,6 +2128,7 @@ export function buildStandardHybridDagFromTask(sources) {
|
|
|
2074
2128
|
applySddEmbeddedEnhancements(spec, sources.sddEmbeddedSkills ?? new Set());
|
|
2075
2129
|
stampTargetTemplateTransientRetryProfile(spec);
|
|
2076
2130
|
applyDefaultReadOnlyRetryPolicy(spec);
|
|
2131
|
+
stampGeneratedArtifactBindings(spec);
|
|
2077
2132
|
parseDagSpec(spec);
|
|
2078
2133
|
assertValidDagSpec(spec);
|
|
2079
2134
|
return spec;
|
|
@@ -2279,6 +2334,7 @@ function buildBlockedFrontendMockDag(sources, readOnlyPaths, forbiddenPaths, glo
|
|
|
2279
2334
|
],
|
|
2280
2335
|
};
|
|
2281
2336
|
applyDefaultReadOnlyRetryPolicy(spec);
|
|
2337
|
+
stampGeneratedArtifactBindings(spec);
|
|
2282
2338
|
parseDagSpec(spec);
|
|
2283
2339
|
assertValidDagSpec(spec);
|
|
2284
2340
|
return spec;
|
|
@@ -3353,6 +3409,7 @@ async function buildFrontendHybridDagFromTask(sources) {
|
|
|
3353
3409
|
};
|
|
3354
3410
|
spec.tasks = pruneFrontendTasksForRisk(spec.tasks, frontendRisk);
|
|
3355
3411
|
applyDefaultReadOnlyRetryPolicy(spec);
|
|
3412
|
+
stampGeneratedArtifactBindings(spec);
|
|
3356
3413
|
parseDagSpec(spec);
|
|
3357
3414
|
assertValidDagSpec(spec);
|
|
3358
3415
|
return spec;
|
|
@@ -3952,9 +4009,10 @@ export function applyBackendTestLayoutToText(text, layout) {
|
|
|
3952
4009
|
/**
|
|
3953
4010
|
* Builds the `node -e` command for the backend-test module manifest shell.
|
|
3954
4011
|
* The inline JS mirrors `extractModuleStemsFromReadme` so the map_agent
|
|
3955
|
-
* shard set deterministically matches the
|
|
3956
|
-
* Gate trusts: only
|
|
3957
|
-
* relative links `[label](./<stem>.md)` count
|
|
4012
|
+
* shard set deterministically matches the plan index the Completeness
|
|
4013
|
+
* Gate trusts: only `testcase/md/<stem>.md` path mentions and canonical
|
|
4014
|
+
* relative links `[label](./<stem>.md)` count. Adjacent table cells such as
|
|
4015
|
+
* Case Range or pytest assets are never interpreted as module stems. The same
|
|
3958
4016
|
* `looksLikeValidModuleStem` filter and `normalizeBackendTestModuleStem`
|
|
3959
4017
|
* normalization. Output is exactly one trailing JSON line `{modules:[{stem}]}`
|
|
3960
4018
|
* that `parseJsonFromText` accepts after shell command echoes.
|
|
@@ -3968,17 +4026,18 @@ function buildBackendTestModuleManifestShellCommand(layout) {
|
|
|
3968
4026
|
// mdDir/testPrefix are injected as JSON literals so the same extractor
|
|
3969
4027
|
// works for any configured backendTest layout (plan A).
|
|
3970
4028
|
const mdDirLiteral = JSON.stringify(layout.markdownDir);
|
|
3971
|
-
const testPrefixLiteral = JSON.stringify(`${layout.scriptDir}/test_`);
|
|
3972
4029
|
const escOpen = String.fromCharCode(92, 91); // \[
|
|
3973
4030
|
const escClose = String.fromCharCode(92, 93); // \]
|
|
3974
4031
|
const escBslash = String.fromCharCode(92, 92); // \\
|
|
3975
|
-
const script = `const fs=require('fs');
|
|
4032
|
+
const script = `const fs=require('fs'),path=require('path'),crypto=require('crypto');
|
|
3976
4033
|
const mdDir=${mdDirLiteral};
|
|
3977
|
-
const testPrefix=${testPrefixLiteral};
|
|
3978
4034
|
const esc=s=>s.replace(/[${escOpen}${escClose}{}()*+?^$|${escBslash}]/g,'${escBslash}$&');
|
|
3979
4035
|
const rxMdPath=new RegExp(esc(mdDir)+'${escBslash}/([A-Za-z0-9_.-]+)${escBslash}.md','g');
|
|
3980
|
-
const
|
|
3981
|
-
|
|
4036
|
+
const runDir=process.env.HARNESS_DAG_RUN_DIR||'';
|
|
4037
|
+
if(!runDir){process.stderr.write('missing HARNESS_DAG_RUN_DIR for backend-test Markdown plan artifact\\n');process.exit(2);}
|
|
4038
|
+
const planPath=path.join(runDir,'generate-backend-md-plan-pi','plan.md');
|
|
4039
|
+
if(!fs.existsSync(planPath)){process.stderr.write('missing backend-test Markdown plan artifact: '+planPath+'\\n');process.exit(2);}
|
|
4040
|
+
const readme=fs.readFileSync(planPath,'utf8');
|
|
3982
4041
|
const norm=s=>String(s).toLowerCase().replace(/[^a-z0-9]+/g,'_').replace(/^_+|_+$/g,'').replace(/_+/g,'_');
|
|
3983
4042
|
const bt=String.fromCharCode(96);
|
|
3984
4043
|
const stripBackticks=s=>s.split(bt).join('');
|
|
@@ -3995,15 +4054,17 @@ const lines=section.split('\\n').filter(l=>l.includes('|'));
|
|
|
3995
4054
|
for(const line of lines){
|
|
3996
4055
|
const bare=stripBackticks(line);
|
|
3997
4056
|
for(const m of bare.matchAll(rxMdPath)){raw.push(m[1]);}
|
|
3998
|
-
for(const m of bare.matchAll(rxTableRow)){if(valid(m[1])||invalidReason(m[1])!=='invalid-syntax')raw.push(m[1]);}
|
|
3999
4057
|
}
|
|
4000
4058
|
for(const m of section.matchAll(rxRelLink)){raw.push(m[1]);}
|
|
4001
4059
|
const invalid=[];for(const r of raw){const reason=invalidReason(r);if(reason)invalid.push({stem:norm(r),reason});}
|
|
4002
4060
|
if(invalid.length){for(const item of invalid)process.stderr.write(item.reason+': '+item.stem+'; use a stable business resource/domain stem\\n');process.exit(2);}
|
|
4003
4061
|
const seen=new Set();const modules=[];
|
|
4004
4062
|
for(const r of raw){const st=norm(r);if(valid(r)&&!seen.has(st)){seen.add(st);modules.push({stem:st});}}
|
|
4063
|
+
if(modules.length===0){process.stderr.write('empty-module-index: require at least one stable business module\\n');process.exit(2);}
|
|
4005
4064
|
if(modules.length>8){process.stderr.write('excessive-module-count: '+modules.length+' > 8; merge by the smallest stable business resource/domain set\\n');process.exit(2);}
|
|
4006
|
-
process.
|
|
4065
|
+
const planReadPath=path.relative(process.cwd(),planPath).split(path.sep).join('/');
|
|
4066
|
+
const planSha256=crypto.createHash('sha256').update(readme).digest('hex');
|
|
4067
|
+
process.stdout.write(JSON.stringify({modules:modules.map(item=>({...item,planReadPath})),planReadPath,planSha256}));
|
|
4007
4068
|
`;
|
|
4008
4069
|
const encoded = Buffer.from(script, "utf8").toString("base64");
|
|
4009
4070
|
return `node -e "eval(Buffer.from('${encoded}','base64').toString('utf8'))"`;
|
|
@@ -4016,6 +4077,84 @@ const BACKEND_TEST_SKILLS_BY_ROLE = {
|
|
|
4016
4077
|
verifier: ["verification-before-completion", "systematic-debugging"],
|
|
4017
4078
|
closeout: ["loop-agent", "verification-before-completion"],
|
|
4018
4079
|
};
|
|
4080
|
+
/**
|
|
4081
|
+
* Read-only Worker workflow for producing a revision-eligible Backend Test
|
|
4082
|
+
* Analysis v2 contract without crossing into test generation or execution.
|
|
4083
|
+
* The explicit consumer keeps artifact lineage meaningful for safe
|
|
4084
|
+
* continuation: replacing the contract reruns review + deterministic closeout
|
|
4085
|
+
* only.
|
|
4086
|
+
*/
|
|
4087
|
+
function buildBackendTestAnalysisHybridDag(sources) {
|
|
4088
|
+
const analysis = buildAnalyzeInputsNode(sources);
|
|
4089
|
+
const contract = buildBackendTestAnalysisContractGateNode(sources);
|
|
4090
|
+
const review = {
|
|
4091
|
+
id: "review-backend-test-analysis-pi",
|
|
4092
|
+
depends_on: [contract.id],
|
|
4093
|
+
role: "reviewer",
|
|
4094
|
+
executor: "pi",
|
|
4095
|
+
complexity: "LOW",
|
|
4096
|
+
writePolicy: "read-only",
|
|
4097
|
+
allowedPaths: commonReadOnlyPaths(sources),
|
|
4098
|
+
forbiddenPaths: commonForbiddenPaths(sources),
|
|
4099
|
+
outputContract: "Concise Markdown review of the validated Backend Test Analysis v2 contract, covering source binding, explicit requirement coverage, evidence gaps, risks, and downstream readiness. No file writes.",
|
|
4100
|
+
subtask_prompt: [
|
|
4101
|
+
"Review the validated run-owned `contracts/backend-test-analysis.json` artifact.",
|
|
4102
|
+
"Treat that structured artifact as the authoritative analysis contract; do not substitute the producer's assistant prose.",
|
|
4103
|
+
"Check that every explicit AC/REQ/BR is represented by acceptanceCriteria or an evidenceGap, source references are precise, and unknown behavior remains an evidence gap rather than an invented requirement.",
|
|
4104
|
+
"Summarize source-binding integrity, coverage, risks, evidence gaps, and whether the contract is ready for a later backend-test generation workflow.",
|
|
4105
|
+
"Read-only: do not modify code, docs, artifacts, or repository files.",
|
|
4106
|
+
].join("\n\n"),
|
|
4107
|
+
};
|
|
4108
|
+
const closeout = {
|
|
4109
|
+
id: "backend-test-analysis-closeout-static",
|
|
4110
|
+
depends_on: [review.id],
|
|
4111
|
+
role: "closeout",
|
|
4112
|
+
executor: "static",
|
|
4113
|
+
complexity: "LOW",
|
|
4114
|
+
writePolicy: "none",
|
|
4115
|
+
allowedPaths: [],
|
|
4116
|
+
forbiddenPaths: commonForbiddenPaths(sources),
|
|
4117
|
+
outputContract: "Deterministic handoff pointing to the validated analysis contract and its independent read-only review.",
|
|
4118
|
+
subtask_prompt: "Close the read-only analysis workflow after the structured contract and review both succeed.",
|
|
4119
|
+
static: {
|
|
4120
|
+
resultMarkdown: [
|
|
4121
|
+
"# Backend-test analysis closeout",
|
|
4122
|
+
"",
|
|
4123
|
+
"Validated contract: `contracts/backend-test-analysis.json`.",
|
|
4124
|
+
"Independent review: `review-backend-test-analysis-pi`.",
|
|
4125
|
+
].join("\n"),
|
|
4126
|
+
},
|
|
4127
|
+
};
|
|
4128
|
+
const spec = {
|
|
4129
|
+
version: 3,
|
|
4130
|
+
title: `Backend test analysis DAG: ${sources.taskConfig.title}`,
|
|
4131
|
+
runtimeContract: GENERATED_DAG_RUNTIME_CONTRACT,
|
|
4132
|
+
outputLanguage: sources.outputLanguage ?? DEFAULT_DAG_OUTPUT_LANGUAGE,
|
|
4133
|
+
objective: extractObjective(sources.requirementMarkdown, sources.taskConfig.title),
|
|
4134
|
+
successCriteria: [
|
|
4135
|
+
"A strict Backend Test Analysis v2 contract is materialized with immutable source binding",
|
|
4136
|
+
"Every explicit requirement is covered or preserved as an evidence gap",
|
|
4137
|
+
"An independent read-only review consumes the validated structured artifact",
|
|
4138
|
+
],
|
|
4139
|
+
globalConstraints: [
|
|
4140
|
+
...sources.taskConfig.hardConstraints,
|
|
4141
|
+
"This workflow is analysis-only: no repository writer, dynamic expansion, test generation, or test execution is allowed.",
|
|
4142
|
+
],
|
|
4143
|
+
defaults: {
|
|
4144
|
+
...BACKEND_TEST_DEFAULTS,
|
|
4145
|
+
contextProfile: sources.taskConfig.contextProfile,
|
|
4146
|
+
},
|
|
4147
|
+
skillsByRole: BACKEND_TEST_SKILLS_BY_ROLE,
|
|
4148
|
+
executorModels: sources.executorModelMatrix ?? DEFAULT_DAG_EXECUTOR_MODELS,
|
|
4149
|
+
verifyStrategy: resolveDagVerifyStrategy(sources.taskConfig),
|
|
4150
|
+
tasks: [analysis, contract, review, closeout],
|
|
4151
|
+
};
|
|
4152
|
+
applyDefaultReadOnlyRetryPolicy(spec);
|
|
4153
|
+
stampGeneratedArtifactBindings(spec);
|
|
4154
|
+
parseDagSpec(spec);
|
|
4155
|
+
assertValidDagSpec(spec);
|
|
4156
|
+
return spec;
|
|
4157
|
+
}
|
|
4019
4158
|
/**
|
|
4020
4159
|
* Plan D: gap-fill incremental DAG (mode=gap-fill).
|
|
4021
4160
|
*
|
|
@@ -4412,10 +4551,12 @@ async function buildBackendTestGapFillDag(sources) {
|
|
|
4412
4551
|
],
|
|
4413
4552
|
};
|
|
4414
4553
|
spec.backendTestLayout = layout;
|
|
4554
|
+
applyBackendTestWorkspaceControl(spec, taskConfig.backendTest?.workspaceControl ?? "git");
|
|
4415
4555
|
if (sharedSetup) {
|
|
4416
4556
|
spec.backendTestSharedSetup = { ...sharedSetup };
|
|
4417
4557
|
}
|
|
4418
4558
|
applyDefaultReadOnlyRetryPolicy(spec);
|
|
4559
|
+
stampGeneratedArtifactBindings(spec);
|
|
4419
4560
|
parseDagSpec(spec);
|
|
4420
4561
|
assertValidDagSpec(spec);
|
|
4421
4562
|
return spec;
|
|
@@ -4485,35 +4626,37 @@ async function buildBackendTestHybridDag(sources) {
|
|
|
4485
4626
|
const generateMdPlan = {
|
|
4486
4627
|
id: "generate-backend-md-plan-pi",
|
|
4487
4628
|
depends_on: [environment.id],
|
|
4488
|
-
role: "
|
|
4629
|
+
role: "planner",
|
|
4489
4630
|
executor: "pi",
|
|
4490
|
-
toolProfile: "
|
|
4631
|
+
toolProfile: "read-only",
|
|
4491
4632
|
complexity: "MED",
|
|
4492
|
-
writePolicy: "
|
|
4493
|
-
|
|
4494
|
-
|
|
4633
|
+
writePolicy: "read-only",
|
|
4634
|
+
allowedPaths: [],
|
|
4635
|
+
readSet: [
|
|
4636
|
+
toDagSourcePath(sources, sources.requirementPath),
|
|
4637
|
+
...(sources.constraintMarkdown
|
|
4638
|
+
? [toDagSourcePath(sources, sources.constraintPath)]
|
|
4639
|
+
: []),
|
|
4640
|
+
...intake.referenceIndex.map((entry) => entry.readPath),
|
|
4641
|
+
".harness/dag-runs/**/reports/backend-test-environment.md",
|
|
4642
|
+
],
|
|
4495
4643
|
forbiddenPaths: forbidden,
|
|
4496
|
-
|
|
4497
|
-
type: "implementation-outcome-v1",
|
|
4498
|
-
requireChangedFiles: true,
|
|
4499
|
-
},
|
|
4500
|
-
retryPolicy: BACKEND_TEST_WRITER_COMPLETENESS_RETRY_POLICY,
|
|
4501
|
-
outputContract: "Write a Chinese, human-readable testcase/md/README.md as the single Markdown-first entry page with Coverage Scope, Coverage Matrix and a machine-parseable module index. Do not write module case cards here; do not execute pytest or modify production code/config.",
|
|
4644
|
+
outputContract: "Return a Chinese, human-readable Markdown-first plan with Coverage Scope, Coverage Matrix, Scenario Partitions when applicable, and a machine-parseable Module Index. The runtime persists it as a run-owned Harness artifact; do not write testcase/md/README.md, execute pytest, or modify project files.",
|
|
4502
4645
|
subtask_prompt: [
|
|
4503
|
-
"This is a required
|
|
4646
|
+
"This is a required plan-generation node. Read only the strict read set and return the complete Markdown plan in the assistant response. The runtime persists the response as a run-owned Harness artifact named generate-backend-md-plan-pi/plan.md. Do not write testcase/md/README.md or any project file; module case cards are written by downstream sharded nodes.",
|
|
4504
4647
|
"Output budget protocol (hard, max output <=16K per turn): Never paste full Matrix, case bodies, or source text into assistant chat. README holds only Scope+Matrix+module index; never inline full case bodies. If a Completeness Gate / OUTPUT_LIMIT_RECOVERY retry is injected, continue only listed target paths.",
|
|
4505
|
-
"
|
|
4506
|
-
"Read the upstream environment report. Generate the Markdown-first backend test
|
|
4648
|
+
"Return the complete plan as plain Markdown. Do not emit JSON or code fences. The plan must contain the exact ## Coverage Scope, ## Coverage Matrix and ## Module Index sections required by the downstream manifest.",
|
|
4649
|
+
"Read the upstream environment report only through the strict read set. Generate the Markdown-first backend test plan; it will be persisted under the current DAG run's Harness artifacts, not under testcase/md/.",
|
|
4507
4650
|
"Write human-readable content in Simplified Chinese by default. Keep English only for machine-readable IDs and technical literals such as Case/AC/REQ/BR IDs, HTTP methods, paths, field names, enum values, commands, filenames, code symbols and exact source citations.",
|
|
4508
|
-
"Create
|
|
4509
|
-
"Before the Coverage Matrix, write a mandatory machine-readable `## Coverage Scope` section in
|
|
4651
|
+
"Create the concise plan entry page: test objective, target/environment, isolation/cleanup, module summary and a linked case index table with Case ID, Chinese case name, scenario type, endpoint and expected status/result. Avoid repeating every case body in the plan artifact.",
|
|
4652
|
+
"Before the Coverage Matrix, write a mandatory machine-readable `## Coverage Scope` section in the plan artifact using exactly `| Field | Value |`, immediately followed by the separator row `|---|---|`, and these six unique rows: `Change Classification`, `Coverage Policy`, `Affected Operations`, `Affected Rule Keys`, `Regression Floor`, `Scope Evidence`. Always set `Change Classification` to `new-operation` and `Coverage Policy` to `full-contract`; do NOT reason about whether operations are new or existing. Cover all in-scope rules from the requirement document at full depth; treat the product requirement as the coverage baseline and use API contract evidence (fields/status/enum/boundary/format) to supplement scenario dimensions. Scope is limited to operations/rules the requirement document (or its referenced API contract) explicitly describes; do not expand to unrelated operations that the requirement does not mention. List affected operations exactly as `METHOD /path`, stable rule keys separated by semicolons, and precise source pointers as Scope Evidence.",
|
|
4510
4653
|
"Coverage depth is full over the in-scope rules: fully cover every documented status, request/response field rule, requiredness, enum, boundary, format, auth and business state of each affected operation the requirement describes, but do not re-test unrelated operations the requirement does not mention. Inspect shared validator/helper/DTO/query builder evidence and expand Affected Operations when the same affected path can affect them; unresolved impact stays visible as GAP/CONFLICT.",
|
|
4511
|
-
"Before writing cases, build the mandatory machine-readable Coverage Matrix inside
|
|
4654
|
+
"Before writing cases, build the mandatory machine-readable Coverage Matrix inside the plan artifact itself. Its section heading line must be exactly `## Coverage Matrix` with no numeric prefix/suffix; never place the canonical Matrix only in a module file. Use this exact header: `| Rule Key | Priority | Source | Endpoint/Field | Dimension | Rule | Required Test Points | Case IDs | Status |`. Every data row must contain exactly 9 pipe-delimited cells and must never omit `Dimension`; use concise dimensions such as requirement, operation, response-status, requiredness, enum, boundary, format, business-state or error. Use only P0/P1/P2 and COVERED/PARTIAL/GAP/CONFLICT. Use stable `TP-<UPPERCASE-HYPHENATED-ID>` test points separated by semicolons.",
|
|
4512
4655
|
"Each Rule Key must appear in exactly one Matrix row. Preserve each AC/REQ/BR Rule Key as one row; if one product rule spans multiple dimensions, use a concise composite Dimension in that single row instead of duplicating the key. Derive OpenAPI Rule Keys exactly as the deterministic analyzer does: operation token is `<HTTP-METHOD>-<PATH>` with braces removed and every non-alphanumeric run replaced by a hyphen, uppercase (for example POST `/api/resource-notes` → `POST-API-RESOURCE-NOTES`); response statuses use `API-<OPERATION>-RESPONSE-STATUS`; body/parameter fields use `API-<OPERATION>-<FIELD>-REQUIRED|ENUM|MIN-LENGTH|MAX-LENGTH|MINIMUM|MAXIMUM|PATTERN|FORMAT`. Do not invent aliases such as API-CREATE-FIELDS when a deterministic key applies.",
|
|
4513
4656
|
"Coverage priority is strict inside the declared scope: P0 product requirements/task hard constraints always remain in scope; P1 exhaustively supplements documented operations, fields, business rules, statuses and errors only for Affected Operations; P2 adds bounded protocol robustness only when it is relevant to the change and does not invent product behavior. Coverage percentages describe the declared affected scope, never whole-API completeness unless every operation is explicitly listed. Conflicts or undefined expectations must stay visible as GAP/CONFLICT with precise source pointers, never guessed.",
|
|
4514
4657
|
"For uniqueness/lifecycle rules cover absent, active-existing, deleted-existing, create-delete-recreate, restore-then-recreate and documented scope/case-normalization states. For every enum cover every valid value plus bounded invalid equivalence classes (unknown, case variant, whitespace, empty, null/missing and wrong types as applicable). For every length/number rule cover min-1, min, nominal, max and max+1. For format rules cover each allowed class separately plus a valid mixed value, and representative forbidden classes including uppercase, internal/leading/trailing whitespace, tab/newline, unsupported punctuation, slash, emoji or control characters when the source contract supports that expectation.",
|
|
4515
|
-
"Mandatory module index: include a `## Module Index` table in
|
|
4516
|
-
"Scenario Partitions (query/filter axes): for every affected GET/list operation, declare one row per enum or classification axis used for filtering (query/path parameters such as type/status/category). Add a mandatory machine-readable `## Scenario Partitions` section after the Coverage Matrix using exactly `| Partition ID | Operation | Axis | Domain | Required Slots | Expected by Slot | Bind Rule |` with the separator row. Partition ID is a stable `SP-<OPERATION>-<AXIS>` token; Domain must copy the legal values verbatim from the bound OpenAPI enum or requirement sentence (never guess); Required Slots writes `each-value` plus `omitted` only when the parameter is optional; Expected by Slot states the documented expectation per slot kind (`domain-value`, `default-behavior`, `empty-result`/`excluded-result` when documented, or `GAP` when the source does not document the complement expectation — never invent 空列表/400). POST/PUT body field-validation enums stay in the Coverage Matrix as `TP-<FIELD>-ENUM-*` and MUST NOT get a Scenario Partition row. Do not create partitions for axes without a documented legal-value domain. Only GET/list query or path parameters whose bound source documents a finite enum or classification set may become a Scenario Partition. Do not create partitions for free-form strings, primary keys, required-or-optional-only parameters, or boundary/format-only axes. If an axis has no finite legal-value domain, do not declare a Partition row and do not invent NOT-IN-SET cases. Cross-axis combinations stay as ONE nominal Case; never declare a cross-axis cartesian partition.",
|
|
4658
|
+
"Mandatory module index: include a `## Module Index` table in the plan artifact that lists every planned module as a canonical relative link of the exact form `[label](./<stem>.md)` plus a `testcase/md/<stem>.md` path cell, so a downstream deterministic manifest can parse the module list. Group by stable business resource/domain, not by CRUD operation: one resource's list/detail/create/update/delete cases belong in one module such as `resource_notes`; split only when a single module would exceed the per-child 16K output protocol, keep the total module count at the smallest safe value, and never exceed 8 modules. Name each module file with a stable lowercase business stem such as `health` or `resource_notes`. Pure hexadecimal/hash-like opaque stems such as `a401606` or `deadbeef` are forbidden. Do not use priority-only stems `p0`, `p1` or `p2`; Priority belongs only in the Coverage Matrix and never defines module files. Do not use Case-ID-like module filenames such as `BE-HEALTH.md` or `BE-NOTES.md`. The relative link target MUST equal the on-disk filename stem the sharded writer will create. For every automatable case, `自动化映射` must name exactly `testcase/test_<module>.py`, where <module> is that Markdown filename without `.md`, lowercased, with non-alphanumeric characters replaced by underscores. Example: `testcase/md/health.md` → `testcase/test_health.py`; `testcase/md/resource_notes.md` → `testcase/test_resource_notes.py`. Never invent a different pytest path in Markdown than the module stem implies.",
|
|
4659
|
+
"Scenario Partitions (query/filter axes): for every affected GET/list operation, declare one row per enum or classification axis used for filtering (query/path parameters such as type/status/category). Add a mandatory machine-readable `## Scenario Partitions` section after the Coverage Matrix using exactly `| Partition ID | Operation | Axis | Domain | Required Slots | Expected by Slot | Bind Rule |` with the separator row. Partition ID is a stable `SP-<OPERATION>-<AXIS>` token; Domain must copy the legal values verbatim from the bound OpenAPI enum or requirement sentence (never guess), using bare semicolon-separated identifier values inside the single table cell (for example `ACTIVE; ARCHIVED`, with no Markdown backticks or prose); Required Slots writes `each-value` plus `omitted` only when the parameter is optional; Expected by Slot states the documented expectation per slot kind (`domain-value`, `default-behavior`, `empty-result`/`excluded-result` when documented, or `GAP` when the source does not document the complement expectation — never invent 空列表/400). POST/PUT body field-validation enums stay in the Coverage Matrix as `TP-<FIELD>-ENUM-*` and MUST NOT get a Scenario Partition row. Do not create partitions for axes without a documented legal-value domain. Only GET/list query or path parameters whose bound source documents a finite enum or classification set may become a Scenario Partition. Do not create partitions for free-form strings, primary keys, required-or-optional-only parameters, or boundary/format-only axes. If an axis has no finite legal-value domain, do not declare a Partition row and do not invent NOT-IN-SET cases. Cross-axis combinations stay as ONE nominal Case; never declare a cross-axis cartesian partition.",
|
|
4517
4660
|
"Before finalizing README, calculate the predicted collected-item count as `sum(max(1, number of variant Test Points in each Case))`. If the task declares an item budget, the prediction must not exceed it. Reduce excess only by removing duplicate execution and converting same-request checkpoints to assertions; never drop required rules, boundaries, enums, operation-specific inputs, or business states. Record the prediction in README. Use only environment-supported fixtures/targets/isolation, record evidence gaps in Chinese, and do not emit JSON, pytest, or execute commands.",
|
|
4518
4661
|
...(sharedSetupPrompt ? [sharedSetupPrompt] : []),
|
|
4519
4662
|
intake.boundedSourceContext,
|
|
@@ -4532,8 +4675,8 @@ async function buildBackendTestHybridDag(sources) {
|
|
|
4532
4675
|
writePolicy: "read-only",
|
|
4533
4676
|
allowedPaths: ro,
|
|
4534
4677
|
forbiddenPaths: forbidden,
|
|
4535
|
-
outputContract: "Stdout JSON {modules:[{stem}]} parsed from
|
|
4536
|
-
subtask_prompt: "Parse
|
|
4678
|
+
outputContract: "Stdout JSON {modules:[{stem,planReadPath}],planReadPath,planSha256} parsed from the run-owned generate-backend-md-plan-pi/plan.md artifact using the same module-stem extractor as the Completeness Gate.",
|
|
4679
|
+
subtask_prompt: "Parse only $HARNESS_DAG_RUN_DIR/generate-backend-md-plan-pi/plan.md and emit exactly one trailing JSON line {modules:[{stem,planReadPath}],planReadPath,planSha256}. No file writes and no testcase/md/README.md fallback.",
|
|
4537
4680
|
shell: {
|
|
4538
4681
|
commands: [buildBackendTestModuleManifestShellCommand(layout)],
|
|
4539
4682
|
cwd: ".",
|
|
@@ -4574,6 +4717,15 @@ async function buildBackendTestHybridDag(sources) {
|
|
|
4574
4717
|
allowedPaths: ["testcase/md/{{item.stem}}.md"],
|
|
4575
4718
|
forbiddenPaths: forbidden,
|
|
4576
4719
|
writeSet: ["testcase/md/{{item.stem}}.md"],
|
|
4720
|
+
readSet: [
|
|
4721
|
+
"{{item.planReadPath}}",
|
|
4722
|
+
toDagSourcePath(sources, sources.requirementPath),
|
|
4723
|
+
...(sources.constraintMarkdown
|
|
4724
|
+
? [toDagSourcePath(sources, sources.constraintPath)]
|
|
4725
|
+
: []),
|
|
4726
|
+
...intake.referenceIndex.map((entry) => entry.readPath),
|
|
4727
|
+
`${layout.markdownDir}/{{item.stem}}.md`,
|
|
4728
|
+
],
|
|
4577
4729
|
writerOutcomePolicy: {
|
|
4578
4730
|
type: "implementation-outcome-v1",
|
|
4579
4731
|
requireChangedFiles: true,
|
|
@@ -4581,7 +4733,7 @@ async function buildBackendTestHybridDag(sources) {
|
|
|
4581
4733
|
retryPolicy: BACKEND_TEST_WRITER_COMPLETENESS_RETRY_POLICY,
|
|
4582
4734
|
outputContract: "Write exactly one Chinese module Markdown case-card file testcase/md/<stem>.md with BE-<MODULE>-<NNN> cases and the seven required h3 sections; keep machine IDs/literals exact and do not execute pytest or modify production code/config or the README.",
|
|
4583
4735
|
subtaskPromptTemplate: [
|
|
4584
|
-
"This is a required file-generation node for exactly one Markdown module.
|
|
4736
|
+
"This is a required file-generation node for exactly one Markdown module. Read the upstream run-owned Markdown plan artifact at `{{item.planReadPath}}` (Coverage Scope + Coverage Matrix + Module Index) and the bounded references, then immediately use write tools to create the single file testcase/md/{{item.stem}}.md. Do not read or recreate testcase/md/README.md. Do not end after analysis or planning, and do not return before a non-empty bounded diff exists. Do not modify any other module file.",
|
|
4585
4737
|
"Output budget protocol (hard, max output <=16K per turn): Never paste full Matrix, other modules' case bodies, or source text into assistant chat. Each write/edit tool call touches at most one file (this module). Compact tables/lists are required; omitting required sections or in-scope variants is forbidden. If a Completeness Gate / OUTPUT_LIMIT_RECOVERY retry is injected, continue only listed target paths.",
|
|
4586
4738
|
"The first non-empty response line must be exactly IMPLEMENTATION_OUTCOME: changed after the module file has been written, or IMPLEMENTATION_OUTCOME: blocked when precise missing evidence prevents safe generation. already-satisfied is not valid for this node.",
|
|
4587
4739
|
"Write human-readable content in Simplified Chinese by default. Keep English only for machine-readable IDs and technical literals such as Case/AC/REQ/BR IDs, HTTP methods, paths, field names, enum values, commands, filenames, code symbols and exact source citations.",
|
|
@@ -4603,28 +4755,37 @@ async function buildBackendTestHybridDag(sources) {
|
|
|
4603
4755
|
};
|
|
4604
4756
|
const reviewCases = {
|
|
4605
4757
|
id: "review-and-revise-backend-md-cases-pi",
|
|
4606
|
-
depends_on: [generateMdCasesMap.id],
|
|
4758
|
+
depends_on: [generateMdCasesMap.id, materializeMdManifest.id],
|
|
4607
4759
|
role: "implementer",
|
|
4608
4760
|
executor: "pi",
|
|
4609
4761
|
toolProfile: "write",
|
|
4610
4762
|
complexity: "MED",
|
|
4611
4763
|
writePolicy: "exclusive",
|
|
4612
|
-
writeSet: [
|
|
4613
|
-
|
|
4614
|
-
|
|
4764
|
+
writeSet: [`${layout.markdownDir}/**`],
|
|
4765
|
+
readSet: [
|
|
4766
|
+
".harness/dag-runs/**/generate-backend-md-plan-pi/plan.md",
|
|
4767
|
+
toDagSourcePath(sources, sources.requirementPath),
|
|
4768
|
+
...(sources.constraintMarkdown
|
|
4769
|
+
? [toDagSourcePath(sources, sources.constraintPath)]
|
|
4770
|
+
: []),
|
|
4771
|
+
...intake.referenceIndex.map((entry) => entry.readPath),
|
|
4772
|
+
`${layout.markdownDir}/*.md`,
|
|
4773
|
+
],
|
|
4774
|
+
allowedPaths: Array.from(new Set([...ro, `${layout.markdownDir}/**`])),
|
|
4775
|
+
forbiddenPaths: Array.from(new Set([...forbidden, layout.readmePath])),
|
|
4615
4776
|
writerOutcomePolicy: { type: "implementation-outcome-v1" },
|
|
4616
4777
|
outputContract: "First non-empty line is IMPLEMENTATION_OUTCOME: changed|already-satisfied|blocked. Perform exactly one bounded incremental synchronization of testcase/md/** against all bound source references; preserve valid Cases and report a concise summary.",
|
|
4617
4778
|
subtask_prompt: [
|
|
4618
|
-
"Perform one gap-targeted synchronization, not a full-suite rewrite or stylistic review. Start from explicit bound source IDs/error codes/DTO fields/normative quoted rules and the
|
|
4619
|
-
"Output budget protocol: never dump full Matrix/case bodies into assistant chat. Inspect
|
|
4779
|
+
"Perform one gap-targeted synchronization, not a full-suite rewrite or stylistic review. Read the immutable run-owned Markdown plan from the direct upstream manifest's planReadPath. Start from explicit bound source IDs/error codes/DTO fields/normative quoted rules and the plan Coverage Matrix; open and edit only modules that own a missing or conflicting rule. Never create or edit testcase/md/README.md and never modify the run-owned plan artifact. Preserve unrelated valid modules byte-for-byte and avoid optional wording cleanup.",
|
|
4780
|
+
"Output budget protocol: never dump full Matrix/case bodies into assistant chat. Inspect the immutable run-owned plan first, build a concise target list from its Matrix and Module Index, then read/write only target modules one file per tool call. Do not traverse every module when the Matrix and source token inventory show no gap; return `already-satisfied`. When adding omitted in-scope cases, keep every required section. Do not bulk-delete in-scope cases to save tokens.",
|
|
4620
4781
|
"For every variant Test Point, ensure the Markdown scenario intent is machine-checkable and located inside that same Case body/自动化映射, never in a file-level appendix, implementation-details block, or another Case. Use an exact transport target: `场景意图: <TP-ID>; operation=<METHOD /path>; target=<body.field|query.field|path.field|header.field|request>; intent=<empty|missing|null|min-1|min|max|max+1|pattern-invalid|enum-invalid|wrong-type|nominal-operation|custom-literal:V>; bound=<n optional>; example=<optional>; expectedCode=<optional>`. Never use vague targets such as field=resource/health. Keep pytest params aligned to the exact target. For intent=missing/empty/default-omit, pytest may use `_OMIT` or delete the key; for intent=enum-invalid use a concrete invalid enum literal (for example `UNKNOWN_STATUS`), never `_OMIT`/missing-key; for trim/padded samples use `custom-literal:trim` or a real padded string, not a bare token like `filter-active` when the intent is `custom-literal:ACTIVE`.",
|
|
4621
4782
|
"Treat the requirement document as the coverage baseline; scope is limited to operations/rules it (or its referenced API contract) describes, and API contract evidence supplements scenario dimensions. For every in-scope operation, check applicable lifecycle/uniqueness states (including deleted-existing when in scope), valid enum values, bounded invalid classes, min-1/min/nominal/max/max+1, allowed/forbidden format classes, required/null/missing/wrong-type semantics, status/error codes, auth and state transitions. Inspect shared validator/helper/DTO/query builder evidence and expand Affected Operations when the same affected path can affect them; unresolved impact stays visible as GAP/CONFLICT. Directly add in-scope omissions; reject scope expansion to operations absent from the requirement document; undefined impact remains GAP/CONFLICT rather than invented behavior.",
|
|
4622
|
-
"Check AC completeness/meaning, endpoint, fields/shape, status/error codes, rules, states, documented boundaries/auth, positive/negative coverage, executable steps and assertable results. Require the exact `## Coverage Scope` Field/Value table with the `|---|---|` separator row, a valid classification-policy pair, non-empty Affected Operations/Rule Keys/Scope Evidence, and the classification-specific Regression Floor. Require the exact unnumbered `## Coverage Matrix` heading in
|
|
4783
|
+
"Check AC completeness/meaning, endpoint, fields/shape, status/error codes, rules, states, documented boundaries/auth, positive/negative coverage, executable steps and assertable results. Require the exact `## Coverage Scope` Field/Value table with the `|---|---|` separator row, a valid classification-policy pair, non-empty Affected Operations/Rule Keys/Scope Evidence, and the classification-specific Regression Floor. Require the exact unnumbered `## Coverage Matrix` heading in the immutable run-owned plan artifact, exact headers, exactly 9 cells in every data row (including a non-empty Dimension), deterministic OpenAPI Rule Keys for every in-scope affected operation, exactly one Matrix row per Rule Key (merge multi-dimension product rows), and bidirectional Matrix Rule/Test Point ↔ Case bindings. Never describe affected-scope coverage as whole-API completeness. Every explicit AC ID must appear in at least one Case `验收标准`; every explicit in-scope AC/REQ/BR Rule Key cited by a Case must have exactly one Coverage Matrix row, and no Case may cite a source Rule Key omitted from the Matrix. Every Matrix Case ID must share at least one of that row's Required Test Points and the Case must cite that Rule Key. Perform an explicit execution-redundancy review: merge checkpoint-only parameter rows, repeated default/read-back assertions, DELETE status/body/follow-up-read checks, response schema/Content-Type checks, PUT full-update/timestamp checks, repeated list setup and identical null/empty inputs when endpoint, input partition, precondition state and expected outcome are the same. Preserve separate POST/PUT, boundary, enum, wrong-type, role/tenant and distinct business-state variants. Directly repair malformed headings/rows/keys and binding modes rather than merely commenting on them. Reject avoidable English prose, duplicated bilingual wording, repeated boilerplate, oversized unstructured sections, a `### 操作步骤` section that contains only a table without any numbered executable line, vague results such as ‘符合预期’, Case-ID-like module filenames (for example `BE-HEALTH.md`), dropped exact `### 操作步骤`/`### 预期结果` headings, and missing or drifted script/function mapping where it can be derived.",
|
|
4623
4784
|
"Correct testcase/md/** directly: add documented omissions, remove unsupported cases, rename module files to stable lowercase stems when needed, normalize every Case ID to hyphen-separated module segments plus exactly three zero-padded digits (`BE-RESOURCE_NOTES-01` → `BE-RESOURCE-NOTES-001`; `BE-RN-011A` must be renumbered or merged) consistently across headings/index/mappings, fix automation mappings so each automatable case points at `testcase/test_<module>.py` derived from that module filename and declares exactly one primary symbol (evidence-only meta cases may keep `脚本/primary symbol=无` with empty variants), assign every Test Point exactly one of `变体测试点`/`场景断言测试点`/`横切证据测试点`, then perform an exact-set check: each Case's `### 测试点` set must equal (not merely contain) the union of those three binding lists; delete stale/legacy aliases and ensure every binding-list Test Point is present, expand every variant parameter row into its own atomic TP ID, make every non-cross-cutting TP Case-specific and owned by exactly one Case, require every primary symbol to start with the canonical Case prefix, ensure every explicit AC ID appears in an applicable Case `验收标准`, merge execution duplicates, improve navigation/tables/Chinese wording, or record gaps in Chinese. Remove every credential/header value, placeholder, fake token and anti-example from Markdown. Sensitive key names may remain only as a plain list; values must be described as runtime-only and omitted, with no colon/value pair or literal example anywhere, including details blocks and explanatory text. Keep Case IDs, AC/REQ/BR IDs, HTTP methods, paths, fields, enum values, filenames, code symbols and source citations as exact machine-readable identifiers; only normalize Case ID separator/sequence formatting as specified above. Recalculate predicted collected items as `sum(max(1, variant count per Case))`; when the task declares a budget, directly merge redundant journeys/reclassify same-request checkpoints until the prediction is within budget, while preserving all required coverage. The validator accepts Chinese and legacy English section aliases; retain or converge to the Chinese human-readable headings without losing structure.",
|
|
4624
4785
|
"This is the single Markdown incremental synchronization round. Read every authoritative reference index entry whose role hints include acceptance-criteria, api-contract, data-contract or business-rule; do not rely on the derived PRD as a complete inventory. Preserve every explicit AC/REQ/BR ID, every documented HTTP/business error code, every DTO/JSON field, enum value, boundary, format, nested shape, transaction/state/idempotency/uniqueness/auth/tenant/cross-field rule. For each natural-language normative business rule preserved as required scope, include its exact source sentence without paraphrase together with source path and line/heading anchor so the deterministic ledger can verify quote/hash provenance. Ensure every Case declares exactly `Payload Contract: none` or the three labels `Payload Required Paths`, `Payload Allowed Paths`, and `Payload Enum`; every label must occupy its own machine-readable list line, and a Case must never concatenate target/setup operations or multiple `Payload Contract` tokens onto one line, and explanatory prose/details must not repeat any `Payload Contract:` token; never infer missing keys or enum values. A target GET/DELETE operation with no request body must remain `Payload Contract: none` even when its setup journey performs POST/PUT with a DTO; setup payloads never redefine the target Case payload contract. Add only missing Matrix rows/Test Points/Cases/assertions or repair exact drift; do not rewrite already-valid unrelated modules. Work gap-targeted: inspect source anchors and affected modules first, leave unrelated valid modules byte-stable, and return `already-satisfied` without restating the full suite when no gap exists.",
|
|
4625
4786
|
"For affected API fields, use one valid nominal payload plus atomic required/missing/null/empty/wrong-type, every documented enum value plus bounded invalid classes, documented min-1/min/nominal/max/max+1, formats and nested object/array constraints. Do not generate a Cartesian product or invent undocumented constraints. Do not invent a concrete identifier type when the source only requires presence; for a missing-resource 404 path with unspecified identifier syntax/type, synchronize the Case to a create-delete-derived valid identifier journey rather than an arbitrary UUID/text placeholder.",
|
|
4626
|
-
"Scenario Partitions synchronization: when
|
|
4627
|
-
"Before returning, verify that every explicit source AC/REQ/BR, error code and strong DTO field token appears in
|
|
4787
|
+
"Scenario Partitions synchronization: when the run-owned plan declares `## Scenario Partitions`, verify each declared partition's slots are fully materialized as variant Test Points with exact `TP-<Partition ID>-...` IDs (each-value per Domain value, OMITTED only for optional axes, exactly one NOT-IN-SET with intent=enum-invalid). Directly add missing slot rows/Cases. Record an illegal plan Partition row that has no source-backed finite domain as GAP/CONFLICT and remove only its derived `TP-SP-*` slots/Cases from target modules; never modify the immutable plan artifact. Never delete a legal source-backed partition or drop its complement slot to force coverage green. When the bound source does not document the complement expectation, keep the slot with GAP expected instead of guessing. Body-field validation enums (`TP-<FIELD>-ENUM-*`) are NOT partitions — do not add partition rows for them.",
|
|
4788
|
+
"Before returning, verify that every explicit source AC/REQ/BR, error code and strong DTO field token appears in the run-owned plan or an applicable module Case. If a fact cannot be safely automated, retain it as GAP/CONFLICT with its exact source pointer instead of dropping it. Return already-satisfied only when no target file needs an incremental edit.",
|
|
4628
4789
|
"Read only indexed source paths. Do not scan the repository, modify source/**, generate pytest, execute tests, or emit JSON.",
|
|
4629
4790
|
...(sharedSetupPrompt ? [sharedSetupPrompt] : []),
|
|
4630
4791
|
intake.boundedSourceContext,
|
|
@@ -4673,8 +4834,8 @@ async function buildBackendTestHybridDag(sources) {
|
|
|
4673
4834
|
writePolicy: "read-only",
|
|
4674
4835
|
allowedPaths: ro,
|
|
4675
4836
|
forbiddenPaths: forbidden,
|
|
4676
|
-
outputContract: "Stdout JSON {modules:[{stem}]} parsed from
|
|
4677
|
-
subtask_prompt: "Parse
|
|
4837
|
+
outputContract: "Stdout JSON {modules:[{stem,planReadPath}],planReadPath,planSha256} parsed from the run-owned Markdown plan artifact, so the pytest map shard set and every child planReadPath deterministically match the Markdown map manifest.",
|
|
4838
|
+
subtask_prompt: "Parse only the run-owned generate-backend-md-plan-pi/plan.md artifact and emit exactly one trailing JSON line {modules:[{stem,planReadPath}],planReadPath,planSha256}. Reuse the same plan-derived Module Index contract as the Markdown manifest; do not search for or fall back to testcase/**/README.md. No file writes.",
|
|
4678
4839
|
shell: {
|
|
4679
4840
|
commands: [buildBackendTestModuleManifestShellCommand(layout)],
|
|
4680
4841
|
cwd: ".",
|
|
@@ -4729,7 +4890,7 @@ async function buildBackendTestHybridDag(sources) {
|
|
|
4729
4890
|
retryPolicy: BACKEND_TEST_WRITER_COMPLETENESS_RETRY_POLICY,
|
|
4730
4891
|
outputContract: "Write exactly one pytest module file testcase/test_<stem>.py whose actual test function region contains the exact Case ID, preferably in the function name or docstring. testcase/md/<module>.md (excluding README.md) maps one-to-one to testcase/test_<module>.py; never merge or split modules. No JSON and no pytest execution.",
|
|
4731
4892
|
subtaskPromptTemplate: [
|
|
4732
|
-
"Convert the single Markdown module testcase/md/{{item.stem}}.md into one self-contained pytest module. Before writing, also read
|
|
4893
|
+
"Convert the single Markdown module testcase/md/{{item.stem}}.md into one self-contained pytest module. Before writing, also read the run-owned Markdown plan artifact at `{{item.planReadPath}}` and use its explicit API target/environment table as the authoritative fallback base URL for every module. A task/Markdown `API_BASE_URL` target takes precedence over project README dev-server URLs; never infer a backend API fallback from a frontend/Vite port such as localhost:3000. After reading the module Markdown, the run-owned plan artifact, and the bounded pytest config/conftest, immediately use write tools to create the single file testcase/test_{{item.stem}}.py. Define any bounded HTTP client fixture, request logging/redaction/truncation helper and payload builders needed by this module inside that same file; do not import generated testcase/**/helpers/** or testcase/**/factories/** assets. Do not end after analysis or planning. Do not modify Markdown, conftest, helpers/factories, or any other module's pytest script.",
|
|
4733
4894
|
"Output budget protocol (hard, max output <=16K per turn): Write exactly one test_{{item.stem}}.py. Never paste full Python modules into assistant chat. Do not merge or split modules. Do not reduce params/assertions/skips to fit. If OUTPUT_LIMIT_RECOVERY is injected, continue only listed missing/broken scripts.",
|
|
4734
4895
|
"Align every variant pytest.param payload with the Markdown scenario intent (empty/missing/null/length/pattern/enum/wrong-type/nominal). Prefer literal payloads over Faker for intent-critical fields so pre-execution scenario-param checks can verify them. Hard contract: intent=enum-invalid MUST pass a concrete invalid value literal (string/number/boolean), never `_OMIT`/None/missing key; intent=missing/empty may use `_OMIT` or delete the key; intent=custom-literal:trim|whitespace-padded requires a leading/trailing whitespace string with non-empty trimmed content (all-whitespace belongs to empty/whitespace-only, not trim); intent=custom-literal:ACTIVE|ARCHIVED requires the exact enum string, never descriptive tokens like filter-active; intent=max/min/max+1 should pass a repeated-string length expression, a bare length number N, or a helper named _*_LEN{N} / _*_MAX_LENGTH / _*_OVER_LENGTH — never a bare 1 for oversize. Hard contract: request payload dicts may only contain DTO field keys from Payload Allowed Paths; never put expect/expected/echo_* helper keys inside the JSON body dict. Path/query/header identifiers and scenario-control metadata (including `id`, expected codes, and selector labels) must stay in separate pytest parameters and helper arguments; never merge them into a DTO patch or JSON body unless that exact path is allowed by the Markdown payload contract. Normalize the configured API base URL with `rstrip(\"/\")` (or equivalently join exactly one slash) before appending endpoint paths; generated requests must never contain a `//api/...` path. When the bound source documents a concrete non-secret local API URL, generated clients must use it as the fallback in `os.environ.get(\"API_BASE_URL\", \"<documented-url>\")`; do not require an otherwise-uninjected environment variable or fail setup solely because it is absent. Missing-field helpers must remove keys idempotently with `payload.pop(field, None)`, never `del payload[field]`, because optional fields may already be absent.",
|
|
4735
4896
|
"For every response contract that requires an object or pagination envelope, first assert that each envelope/data value is a dict and that required keys exist, then index fields and assert values. Never let an incidental KeyError or list/string TypeError stand in for the explicit response-shape contract failure.",
|
|
@@ -4745,6 +4906,13 @@ async function buildBackendTestHybridDag(sources) {
|
|
|
4745
4906
|
},
|
|
4746
4907
|
};
|
|
4747
4908
|
const collectionAssess = shellNode("assess-backend-pytest-collection-shell", [generatePytestCasesMap.id], "markdown-collection-assess", "Resolve final Markdown-mapped scripts before any business test body execution. Run scenario-param assess/at-most-one deterministic repair first, then pytest --collect-only and a no-business-body pytest --setup-plan fixture-resolution preflight. A safe missing mapped script, generated-local syntax/import defect, or generated fixture dependency/plugin-registration defect is REPAIRABLE; dependency, third-party plugin, production-module, environment, safety and unknown failures remain blocked. Materialize hash-bound collection-v3 facts with repairPaths and fixtureResolutionStatus.", "Run-owned reports/backend-test-pytest-collection-initial.md and contracts/backend-test-pytest-collection-initial.json (collection-v3) with bounded collection/fixture diagnostics, repairPaths, asset hashes, collected item IDs and deterministic repair eligibility.", [], 120000);
|
|
4909
|
+
// N10 owns the deterministic scenario-param rewrite that may update mapped
|
|
4910
|
+
// generated test modules before collection. Declare that bounded shell write
|
|
4911
|
+
// authority so filesystem-only workspace control does not misclassify the
|
|
4912
|
+
// intentional repair as an out-of-bounds mutation.
|
|
4913
|
+
collectionAssess.writePolicy = "exclusive";
|
|
4914
|
+
collectionAssess.writeSet = [applyLayout("testcase/**/test_*.py")];
|
|
4915
|
+
collectionAssess.allowedPaths = Array.from(new Set([...ro, ...collectionAssess.writeSet]));
|
|
4748
4916
|
const repairPytest = {
|
|
4749
4917
|
id: "repair-backend-pytest-collection-pi",
|
|
4750
4918
|
depends_on: [collectionAssess.id],
|
|
@@ -4754,8 +4922,24 @@ async function buildBackendTestHybridDag(sources) {
|
|
|
4754
4922
|
toolProfile: "write",
|
|
4755
4923
|
complexity: "MED",
|
|
4756
4924
|
writePolicy: "exclusive",
|
|
4757
|
-
writeSet: [
|
|
4758
|
-
|
|
4925
|
+
writeSet: Array.from(new Set([
|
|
4926
|
+
applyLayout("testcase/**/test_*.py"),
|
|
4927
|
+
`${layout.testRoot}/helpers/**/*.py`,
|
|
4928
|
+
`${layout.testRoot}/factories/**/*.py`,
|
|
4929
|
+
`${layout.testRoot}/__*_helpers.py`,
|
|
4930
|
+
`${layout.scriptDir}/helpers/**/*.py`,
|
|
4931
|
+
`${layout.scriptDir}/factories/**/*.py`,
|
|
4932
|
+
`${layout.scriptDir}/__*_helpers.py`,
|
|
4933
|
+
])),
|
|
4934
|
+
readSet: [
|
|
4935
|
+
".harness/dag-runs/**/reports/backend-test-pytest-collection-initial.md",
|
|
4936
|
+
".harness/dag-runs/**/reports/backend-test-markdown-pytest-correspondence-initial.md",
|
|
4937
|
+
".harness/dag-runs/**/generate-backend-md-plan-pi/plan.md",
|
|
4938
|
+
`${layout.markdownDir}/**`,
|
|
4939
|
+
`${layout.testRoot}/**/*.py`,
|
|
4940
|
+
],
|
|
4941
|
+
contextBudget: { maxTurns: 24, maxTokens: 80_000 },
|
|
4942
|
+
allowedPaths: Array.from(new Set([...ro, `${layout.testRoot}/**`])),
|
|
4759
4943
|
forbiddenPaths: Array.from(new Set([
|
|
4760
4944
|
...forbidden,
|
|
4761
4945
|
"testcase/md/**",
|
|
@@ -4768,7 +4952,7 @@ async function buildBackendTestHybridDag(sources) {
|
|
|
4768
4952
|
outputContract: "First non-empty line is IMPLEMENTATION_OUTCOME: changed|blocked, followed by a concise repair summary. This node runs only for REPAIRABLE initial facts, so already-satisfied is invalid and a successful outcome requires a non-empty bounded diff. Modify only generated pytest scripts/helpers/factories and preserve every Markdown Case, Test Point, primary symbol and assertion meaning.",
|
|
4769
4953
|
subtask_prompt: [
|
|
4770
4954
|
"Repair the generated backend pytest asset as one bounded program using the direct upstream collection assessment. This is the only repair attempt and happens before any business test body execution. Treat any upstream line such as `Repair paths: testcase/test_x.py` as complete authoritative repairPaths evidence. Directly read and edit that testcase path; do not search for separate root-level `contracts/**`, guess a DAG run directory, or require another report artifact. If the read tool successfully returns the testcase file, the path exists—continue the bounded repair and never later claim that file is absent.",
|
|
4771
|
-
"Initial status REPAIRABLE means at least one listed finding remains: `already-satisfied` is forbidden, and you must produce a non-empty bounded diff on repairPaths before returning `IMPLEMENTATION_OUTCOME: changed`. Fix only readiness-proven generated testcase-local defects on initial facts repairPaths: create exact safe missing mapped test_*.py paths, repair syntax/import/symbol/decorator/parameterization, close generated fixture dependencies/plugin registration, and repair initial Markdown-to-pytest correspondence findings (
|
|
4955
|
+
"Initial status REPAIRABLE means at least one listed finding remains: `already-satisfied` is forbidden, and you must produce a non-empty bounded diff on repairPaths before returning `IMPLEMENTATION_OUTCOME: changed`. Fix only readiness-proven generated testcase-local defects on initial facts repairPaths: create exact safe missing mapped test_*.py paths, repair syntax/import/symbol/decorator/parameterization, close generated fixture dependencies/plugin registration, and repair initial Markdown-to-pytest correspondence findings. Use this deterministic repair map instead of reading analyzer implementation: findings about `Case-ID`, `Assertion-Test-Points`, or `Cross-Cutting-Test-Points` are fixed by editing the declared primary symbol docstring metadata lines; variant binding findings are fixed in the literal direct `pytest.param(..., id=\"TP-...\")` row; primary-symbol cardinality/name findings are fixed in the function name or duplicate primary symbols; script mismatch is fixed only on the authoritative assessment repairPaths; payload findings are fixed in request payload construction. Do not read controller `src/**` or inspect JS/TS analyzer code. Do not search for `testcase/**/README.md`. Never invent a business pytest symbol for evidence-only Markdown Cases that declare `脚本/primary symbol=无` with empty variants. For fixture defects inspect both provider and importer listed by repairPaths; fix ScopeMismatch by aligning fixture scopes or inlining request-scoped values so module fixtures never depend on function fixtures; when a shared fixture depends on sibling fixtures, register the whole provider module through an exact pytest_plugins declaration rather than importing only the outer fixture. Do not create unrelated pytest scripts.",
|
|
4772
4956
|
"This is the single pytest incremental synchronization round. The `Findings` in `reports/backend-test-pytest-collection-initial.md` are the mandatory repair checklist: resolve every repairable listed finding on every authoritative `Repair paths` file before considering any other advisory evidence, and never substitute an unrelated scenario-param cleanup for a listed correspondence/collection defect. For every assessment-listed path, compare the effective Markdown Case/Test Points/test data and its `Payload Contract`/`Payload Required Paths`/`Payload Allowed Paths`/`Payload Enum` labels with the generated module. Incrementally add or repair only missing symbols, params, assertions and payload builders. Repair every assessment-listed missing nested path, unexpected key and enum mismatch; preserve exact DTO keys, nested shapes, enum/boundary literals, operation transport and business preconditions; remove guessed replacement keys only when the effective Markdown proves the exact contract. Keep path/query/header identifiers and scenario-control metadata separate from DTO patches and JSON bodies; an `id` used for a path target must be passed to the request path/helper, never inserted into a body patch unless `id` is explicitly listed in Payload Allowed Paths. Flatten every variant into a literal direct `pytest.param(..., id=\"TP-...\")` row; replace `_post_case`/`_put_case` or other parameter-row factories because correspondence and scenario readiness require the actual row values and IDs to be statically visible. Also repair helper call sites to match their defined return signatures; do not tuple-unpack a helper that returns one scalar value.",
|
|
4773
4957
|
"Preserve final testcase/md/** semantics, every Case ID, Rule/Test Point binding, primary symbol, parameter ID, expected status/body/schema assertion, HTTP logging, redaction and truncation behavior.",
|
|
4774
4958
|
"Use local edit only on assessment-listed paths; keep summaries short; never rewrite unrelated modules.",
|
|
@@ -4868,16 +5052,35 @@ async function buildBackendTestHybridDag(sources) {
|
|
|
4868
5052
|
// against the resolved layout. The default layout is identity, so the
|
|
4869
5053
|
// packaged template stays byte-identical with the historical contract.
|
|
4870
5054
|
applyBackendTestLayoutToDagSpec(spec, layout);
|
|
5055
|
+
applyBackendTestWorkspaceControl(spec, taskConfig.backendTest?.workspaceControl ?? "git");
|
|
4871
5056
|
// Plan B: carry the bound shared-setup document on the spec so runtime
|
|
4872
5057
|
// validators (N6 markdown case validation) see the same binding as prompts.
|
|
4873
5058
|
if (intake.sharedSetup) {
|
|
4874
5059
|
spec.backendTestSharedSetup = { ...intake.sharedSetup };
|
|
4875
5060
|
}
|
|
4876
5061
|
applyDefaultReadOnlyRetryPolicy(spec);
|
|
5062
|
+
stampGeneratedArtifactBindings(spec);
|
|
4877
5063
|
parseDagSpec(spec);
|
|
4878
5064
|
assertValidDagSpec(spec);
|
|
4879
5065
|
return spec;
|
|
4880
5066
|
}
|
|
5067
|
+
function applyBackendTestWorkspaceControl(spec, control) {
|
|
5068
|
+
if (control !== "filesystem-only") {
|
|
5069
|
+
delete spec.backendTestWorkspaceControl;
|
|
5070
|
+
return;
|
|
5071
|
+
}
|
|
5072
|
+
spec.backendTestWorkspaceControl = control;
|
|
5073
|
+
for (const task of spec.tasks) {
|
|
5074
|
+
if ((task.executor === "pi" && task.toolProfile === "write") ||
|
|
5075
|
+
task.shell?.backendTestPipeline) {
|
|
5076
|
+
task.writeGuardPolicy = "filesystem-only";
|
|
5077
|
+
}
|
|
5078
|
+
const child = task.dynamicExpansion?.childTask;
|
|
5079
|
+
if (child?.executor === "pi" && child.toolProfile === "write") {
|
|
5080
|
+
child.writeGuardPolicy = "filesystem-only";
|
|
5081
|
+
}
|
|
5082
|
+
}
|
|
5083
|
+
}
|
|
4881
5084
|
/** Rewrite layout-dependent strings across a compiled backend-test DAG spec (plan A). */
|
|
4882
5085
|
function applyBackendTestLayoutToDagSpec(spec, layout) {
|
|
4883
5086
|
if (layout.isDefault) {
|
|
@@ -5611,6 +5814,7 @@ function buildFrontendTestHybridDag(sources) {
|
|
|
5611
5814
|
};
|
|
5612
5815
|
applyFrontendTestLayoutToDagSpec(spec, layout);
|
|
5613
5816
|
applyDefaultReadOnlyRetryPolicy(spec);
|
|
5817
|
+
stampGeneratedArtifactBindings(spec);
|
|
5614
5818
|
parseDagSpec(spec);
|
|
5615
5819
|
assertValidDagSpec(spec);
|
|
5616
5820
|
return spec;
|
|
@@ -6113,6 +6317,7 @@ function buildKnowledgeSyncHybridDag(sources) {
|
|
|
6113
6317
|
buildKnowledgeSyncPointerNode(sources, featureId),
|
|
6114
6318
|
],
|
|
6115
6319
|
};
|
|
6320
|
+
stampGeneratedArtifactBindings(spec);
|
|
6116
6321
|
parseDagSpec(spec);
|
|
6117
6322
|
assertValidDagSpec(spec);
|
|
6118
6323
|
return spec;
|
|
@@ -6559,6 +6764,7 @@ function buildKnowledgeGraphBootstrapHybridDag(sources) {
|
|
|
6559
6764
|
buildKgBootstrapMaterializeNode(sources),
|
|
6560
6765
|
],
|
|
6561
6766
|
};
|
|
6767
|
+
stampGeneratedArtifactBindings(spec);
|
|
6562
6768
|
parseDagSpec(spec);
|
|
6563
6769
|
assertValidDagSpec(spec);
|
|
6564
6770
|
return spec;
|
|
@@ -6656,6 +6862,8 @@ async function buildHybridDagForTemplate(sources, template, options = {}) {
|
|
|
6656
6862
|
}
|
|
6657
6863
|
else if (template === "frontend-test-dag")
|
|
6658
6864
|
spec = buildFrontendTestHybridDag(sources);
|
|
6865
|
+
else if (template === "backend-test-analysis-dag")
|
|
6866
|
+
spec = buildBackendTestAnalysisHybridDag(sources);
|
|
6659
6867
|
else if (template === "backend-test-dag")
|
|
6660
6868
|
spec = await buildBackendTestHybridDag(sources);
|
|
6661
6869
|
else if (template === "knowledge-sync-dag")
|
|
@@ -6692,6 +6900,7 @@ async function buildHybridDagForTemplate(sources, template, options = {}) {
|
|
|
6692
6900
|
template === "supervised-implementation") {
|
|
6693
6901
|
stampTargetTemplateTransientRetryProfile(spec);
|
|
6694
6902
|
}
|
|
6903
|
+
stampGeneratedArtifactBindings(spec);
|
|
6695
6904
|
spec = parseDagSpec(spec);
|
|
6696
6905
|
assertValidDagSpec(spec);
|
|
6697
6906
|
return spec;
|
|
@@ -6699,6 +6908,7 @@ async function buildHybridDagForTemplate(sources, template, options = {}) {
|
|
|
6699
6908
|
const GOVERNANCE_DISALLOWED_TEMPLATES = new Set([
|
|
6700
6909
|
"frontend-implementation",
|
|
6701
6910
|
"frontend-test-dag",
|
|
6911
|
+
"backend-test-analysis-dag",
|
|
6702
6912
|
"backend-test-dag",
|
|
6703
6913
|
"knowledge-sync-dag",
|
|
6704
6914
|
"knowledge-graph-bootstrap-dag",
|
|
@@ -7059,6 +7269,7 @@ function buildReviewGatedHybridDag(standard, sources) {
|
|
|
7059
7269
|
applySddEmbeddedEnhancements(spec, sources.sddEmbeddedSkills ?? new Set());
|
|
7060
7270
|
stampTargetTemplateTransientRetryProfile(spec);
|
|
7061
7271
|
applyDefaultReadOnlyRetryPolicy(spec);
|
|
7272
|
+
stampGeneratedArtifactBindings(spec);
|
|
7062
7273
|
parseDagSpec(spec);
|
|
7063
7274
|
assertValidDagSpec(spec);
|
|
7064
7275
|
return spec;
|
|
@@ -7564,6 +7775,7 @@ async function buildSupervisedHybridDag(standard, sources) {
|
|
|
7564
7775
|
applySddEmbeddedEnhancements(spec, sources.sddEmbeddedSkills ?? new Set());
|
|
7565
7776
|
stampTargetTemplateTransientRetryProfile(spec);
|
|
7566
7777
|
applyDefaultReadOnlyRetryPolicy(spec);
|
|
7778
|
+
stampGeneratedArtifactBindings(spec);
|
|
7567
7779
|
parseDagSpec(spec);
|
|
7568
7780
|
assertValidDagSpec(spec);
|
|
7569
7781
|
return spec;
|