@tea-agent/loop-agent 0.40.0-next.1 → 0.40.0-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +1 -1
- package/CHANGELOG.md +12 -3
- package/README.md +2 -2
- package/dist/application/task-lifecycle/advance.js +12 -0
- package/dist/build-stamp.json +3 -3
- package/dist/cli/update/runtime-activity.js +1 -29
- package/dist/commands/dag-rerun.js +1 -1
- package/dist/executors/shell-executor.js +1 -1
- package/dist/shared/dag-prompt-override.js +4 -5
- package/dist/shared/update/npm-client.js +33 -11
- package/dist/task/contract/apply.js +11 -1
- package/dist/task/contract/constants.js +2 -0
- package/dist/task/contract/hash.js +3 -0
- package/dist/task/contract/observe.js +25 -4
- package/dist/task/contract/paths.js +2 -1
- package/dist/task/contract/project.js +15 -1
- package/dist/task/contract/schema.js +2 -0
- package/dist/task/contract/transaction.js +12 -0
- package/dist/task/source-prepare/completeness.js +188 -0
- package/dist/task/source-prepare/fragment-inventory.js +474 -0
- package/dist/task/source-prepare/index.js +3 -0
- package/dist/task/source-prepare/ledger-reconciliation.js +127 -0
- package/dist/task/source-prepare/ledger-review.js +214 -0
- package/dist/task/source-prepare/ledger.js +545 -0
- package/dist/task/source-prepare/prepare.js +262 -1
- package/dist/task/source-prepare/semantic-intake.js +19 -3
- package/dist/task/source-prepare/source-fidelity-pi.js +384 -0
- package/dist/task/source-prepare/types.js +22 -0
- package/dist/worker/cli.js +12 -26
- package/dist/worker/console/console-handoff.js +82 -0
- package/dist/worker/console/console-update-and-init.js +115 -0
- package/dist/worker/console/console-update-runtime.js +84 -0
- package/dist/worker/console/draft-store.js +49 -0
- package/dist/worker/console/operation-store.js +1 -1
- package/dist/worker/console/operator-actions.js +129 -4
- package/dist/worker/console/operator-surface-health.js +1 -0
- package/dist/worker/console/prd-intake-bridge.js +13 -0
- package/dist/worker/console/routes.js +3 -0
- package/dist/worker/console/server.js +73 -5
- package/dist/worker/console/static/assets/{abnfDiagram-N423BO3Z-Br92EGb7.js → abnfDiagram-N423BO3Z-CTx1TrNa.js} +1 -1
- package/dist/worker/console/static/assets/{arc-oulImtQq.js → arc-B4i9cVxX.js} +1 -1
- package/dist/worker/console/static/assets/{architectureDiagram-T3A2C74G-tyHc6aqO.js → architectureDiagram-T3A2C74G-BAXE8_Rl.js} +1 -1
- package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-CY86BSpT.js → blockDiagram-VBNYF7ZC-C5Xh59at.js} +1 -1
- package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-BKKsDmNs.js → c4Diagram-5PPSVZJV-B_asOzAu.js} +1 -1
- package/dist/worker/console/static/assets/channel-Dj_4Moei.js +1 -0
- package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-CXZdjl3B.js → chunk-2GRJ4B5K-wRO_iRNc.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-B-aIFDQ5.js → chunk-2Q5K7J3B-ByOaSh_G.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5RXB4S5H-BDgAW_B2.js → chunk-5RXB4S5H-DjLzudan.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5VM5RSS4-DABa4UPR.js → chunk-5VM5RSS4-JCNGkXYT.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-aGbysVOx.js → chunk-6Q2QTUOP-BhrPXXMZ.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-GF5L2VYU-B8MSZDVs.js → chunk-GF5L2VYU-TJ5JuEBT.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-JWPE2WC7-CpelV73g.js → chunk-JWPE2WC7-VVthn_mD.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-KBJHAD2P-BE04ty3z.js → chunk-KBJHAD2P-D60-Mny4.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-RYQCIY6F-BUxTkaaR.js → chunk-RYQCIY6F-zXv7aVye.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-XXDRQBXY-CYYBVKfX.js → chunk-XXDRQBXY-By9VQoi1.js} +1 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-C0YYAyCa.js +1 -0
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-C0YYAyCa.js +1 -0
- package/dist/worker/console/static/assets/{cose-bilkent-JH36ORCC-CEQF_xmQ.js → cose-bilkent-JH36ORCC-C4zQLe-M.js} +1 -1
- package/dist/worker/console/static/assets/{cynefin-VYW2F7L2-CqpxN5IT.js → cynefin-VYW2F7L2-wh5N2ReN.js} +1 -1
- package/dist/worker/console/static/assets/{cynefinDiagram-MW4NZA55-B3PzanVi.js → cynefinDiagram-MW4NZA55-Dlu5wIqs.js} +1 -1
- package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-BSUGCNx1.js → dagre-VZM6K2ZE-CrDgthc6.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-7IWD3JNH-CdLevU5T.js → diagram-7IWD3JNH-zN1clg27.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-BjpF_Kok.js → diagram-B4RE2ZJO-BN-o7J7-.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-LBJQPF4R-C4I6NJny.js → diagram-LBJQPF4R-C8SuPt0d.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-Q27KOJAE-C8hecCr5.js → diagram-Q27KOJAE-BoizuHbZ.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-UB23O5K3-Daod6tOS.js → diagram-UB23O5K3-BzUzXixG.js} +1 -1
- package/dist/worker/console/static/assets/{ebnfDiagram-BXEA7PRR-BvvmazGv.js → ebnfDiagram-BXEA7PRR-Ev3lA4Cf.js} +1 -1
- package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-DeN_vfV4.js → erDiagram-JOGREHBK-GALUzRbs.js} +1 -1
- package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-D6dq1t9z.js → flowDiagram-UKHOOZJN-CZJN65Sb.js} +1 -1
- package/dist/worker/console/static/assets/{ganttDiagram-PKOTCBZU-DziIdNY4.js → ganttDiagram-PKOTCBZU-JLB9OESl.js} +1 -1
- package/dist/worker/console/static/assets/{gitGraphDiagram-DS77QQ5N-Dy4s5CXr.js → gitGraphDiagram-DS77QQ5N-CcvCr4GD.js} +1 -1
- package/dist/worker/console/static/assets/{index-Ci8ksvBm.js → index-CW88Fjbw.js} +81 -81
- package/dist/worker/console/static/assets/index-DP0ZJl39.css +1 -0
- package/dist/worker/console/static/assets/{infoDiagram-6WML65LV-Czv5eYx2.js → infoDiagram-6WML65LV-HG5z7aVg.js} +1 -1
- package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-Bsk3nFRT.js → ishikawaDiagram-WSZJBQD7-BHEu9chR.js} +1 -1
- package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-DxGmNj5K.js → journeyDiagram-NVQOT4AX-Cp_Up8-a.js} +1 -1
- package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-CYCFqkO_.js → kanban-definition-27J2QSJJ-DvVeY-em.js} +1 -1
- package/dist/worker/console/static/assets/{linear-B0YzRwrd.js → linear-aGmcjgTn.js} +1 -1
- package/dist/worker/console/static/assets/{mermaid.core-t3EZtIGh.js → mermaid.core-Biyo-tqA.js} +5 -5
- package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-BTXpTv0T.js → mindmap-definition-FAOFIHXS-DyxY2pIb.js} +1 -1
- package/dist/worker/console/static/assets/{pegDiagram-VL7TDLO6-DU8UkKqA.js → pegDiagram-VL7TDLO6-CkdGuc50.js} +1 -1
- package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-DP4y8ohp.js → pieDiagram-7S7Q4E2Y-NNQI9xVR.js} +1 -1
- package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-B07vNaYR.js → quadrantDiagram-CIZ2JOQS-PAJkuz_G.js} +1 -1
- package/dist/worker/console/static/assets/{railroadDiagram-AXF67PYL-xDWktb2i.js → railroadDiagram-AXF67PYL-ZwrQod0O.js} +1 -1
- package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP-BLNMKqeS.js → requirementDiagram-LRYGKXZP-D3ZfrzM2.js} +1 -1
- package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-n0adalxH.js → sankeyDiagram-W5VNT64P-DDGFmWk5.js} +1 -1
- package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-BbnS-2DL.js → sequenceDiagram-SI44F4Z6-DO6mmXTA.js} +1 -1
- package/dist/worker/console/static/assets/{sizeCapture-X5ZJPWSS-B4uPpCLu.js → sizeCapture-X5ZJPWSS-DMbCQiJt.js} +1 -1
- package/dist/worker/console/static/assets/{stateDiagram-OKZ733FA--MMbB0fX.js → stateDiagram-OKZ733FA-Di_YUEfC.js} +1 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-DrdDvela.js +1 -0
- package/dist/worker/console/static/assets/{swimlanes-SLNWSIFB-BXUgp2QY.js → swimlanes-SLNWSIFB-Bn2PphNJ.js} +2 -2
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-DPkEAULl.js +8 -0
- package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-CsaMxki7.js → timeline-definition-Z64GVDOM-DPh8pRsp.js} +1 -1
- package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-C2IuG9iH.js → vennDiagram-T6HMQDX7-GMfl26pW.js} +1 -1
- package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-CmEWOXCW.js → wardleyDiagram-T6FBY63Y-DTlmVrmF.js} +1 -1
- package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-D_9LE0MG.js → xychartDiagram-ELKLHX3M-YGBjKAS5.js} +1 -1
- package/dist/worker/console/static/index.html +2 -2
- package/dist/worker/console/static-src/app/console-types.js +40 -1
- package/dist/worker/console/static-src/app/useOperatorActions.js +5 -0
- package/dist/worker/console/static-src/app/useTaskWizard.js +73 -1
- package/dist/worker/observability/init-runtime-activity.js +26 -0
- package/dist/worker/observe/node-input.js +88 -2
- package/dist/worker/observe/routes.js +188 -0
- package/dist/worker/observe/static/api.js +3 -3
- package/dist/worker/observe/static/dag-node-purpose.d.ts +6 -0
- package/dist/worker/observe/static/dag-node-purpose.js +203 -0
- package/dist/worker/observe/static/format.js +37 -0
- package/dist/worker/observe/static/index.html +5 -0
- package/dist/worker/observe/static/prompt-restart-candidates.d.ts +18 -0
- package/dist/worker/observe/static/prompt-restart-candidates.js +36 -0
- package/dist/worker/observe/static/state.js +2 -2
- package/dist/worker/observe/static/styles.css +338 -35
- package/dist/worker/observe/static/views/dag-graph.js +4 -2
- package/dist/worker/observe/static/views/dag-inspector.js +531 -78
- package/dist/worker/observe/static/views/dag.d.ts +13 -0
- package/dist/worker/observe/static/views/dag.js +4 -3
- package/dist/worker/observe/static/views/task.js +55 -0
- package/dist/workflows/dag/backend-test-case-coverage-analysis.js +29 -1
- package/dist/workflows/dag/backend-test-markdown-workflow.js +176 -1
- package/dist/workflows/dag/backend-test-pytest-collection.js +87 -4
- package/dist/workflows/dag/backend-test-writer-completeness.js +10 -5
- package/dist/workflows/dag/frontend-implementation-contract.js +88 -2
- package/dist/workflows/dag/frontend-plan-render.js +24 -0
- package/dist/workflows/dag/frontend-prewrite-gate.js +197 -0
- package/dist/workflows/dag/frontend-review-context.js +92 -10
- package/dist/workflows/dag/init-hybrid.js +125 -4
- package/dist/workflows/dag/node-execution.js +45 -0
- package/dist/workflows/dag/types.js +42 -11
- package/docs/README.md +1 -0
- package/docs/architecture/evolution.md +45 -0
- package/docs/init-surface.manifest.json +1 -0
- package/docs/templates/README.md +1 -1
- package/docs/templates/frontend-implementation-contract.schema.json +681 -24
- package/package.json +1 -1
- package/skills/loop-agent/references/hybrid-dag.md +7 -0
- package/dist/worker/console/static/assets/channel-TY36zt-i.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-Dk7QCChM.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-Dk7QCChM.js +0 -1
- package/dist/worker/console/static/assets/index-C3GgHg-g.css +0 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-BqOigMQ4.js +0 -1
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-Caxz9UA2.js +0 -8
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface DagNodeRemark {
|
|
2
|
+
failed: boolean;
|
|
3
|
+
text: string;
|
|
4
|
+
isErrorSummary: boolean;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function resolveNodeRemark(node: {
|
|
8
|
+
status?: string | null;
|
|
9
|
+
errorPreview?: string | null;
|
|
10
|
+
label?: string | null;
|
|
11
|
+
nodeId: string;
|
|
12
|
+
rank?: string | number | null;
|
|
13
|
+
} | null | undefined): DagNodeRemark;
|
|
@@ -70,6 +70,7 @@ import {
|
|
|
70
70
|
dashboardVisibleFeatures,
|
|
71
71
|
findDagForRun,
|
|
72
72
|
} from "../dag-model.js";
|
|
73
|
+
import { describeDagNodePurpose } from "../dag-node-purpose.js";
|
|
73
74
|
import { layoutDag } from "../dag-layout.js";
|
|
74
75
|
import {
|
|
75
76
|
showView,
|
|
@@ -136,7 +137,7 @@ export function extractFirstErrorSummary(errorPreview) {
|
|
|
136
137
|
return effective ?? "";
|
|
137
138
|
}
|
|
138
139
|
|
|
139
|
-
/** Resolve 备注 cell content for a DAG node (failed → summary; else
|
|
140
|
+
/** Resolve 备注 cell content for a DAG node (failed → summary; else purpose). */
|
|
140
141
|
export function resolveNodeRemark(node) {
|
|
141
142
|
const failed = isNodeFailed(node?.status);
|
|
142
143
|
if (failed) {
|
|
@@ -147,10 +148,10 @@ export function resolveNodeRemark(node) {
|
|
|
147
148
|
isErrorSummary: Boolean(summary),
|
|
148
149
|
};
|
|
149
150
|
}
|
|
150
|
-
const
|
|
151
|
+
const purpose = describeDagNodePurpose(node?.nodeId, node);
|
|
151
152
|
return {
|
|
152
153
|
failed: false,
|
|
153
|
-
text:
|
|
154
|
+
text: purpose || "—",
|
|
154
155
|
isErrorSummary: false,
|
|
155
156
|
};
|
|
156
157
|
}
|
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
repoBaseName,
|
|
35
35
|
parseMarkdownBlocks,
|
|
36
36
|
markdownLinkHref,
|
|
37
|
+
formatLedgerSummary,
|
|
37
38
|
} from "../format.js";
|
|
38
39
|
import { parseRoute, navigate, buildHashPath } from "../router.js";
|
|
39
40
|
import {
|
|
@@ -94,6 +95,7 @@ export async function renderTaskDetail(featureId, taskId) {
|
|
|
94
95
|
const linksEl = document.getElementById("task-links");
|
|
95
96
|
const evidenceEl = document.getElementById("task-evidence");
|
|
96
97
|
const runsEl = document.getElementById("task-runs");
|
|
98
|
+
const ledgerEl = document.getElementById("task-ledger");
|
|
97
99
|
if (!metaEl || !linksEl || !evidenceEl || !runsEl) return false;
|
|
98
100
|
if (titleEl) titleEl.textContent = displayLabel;
|
|
99
101
|
mountViewState(metaEl, "loading", "加载 Task…");
|
|
@@ -252,9 +254,62 @@ export async function renderTaskDetail(featureId, taskId) {
|
|
|
252
254
|
const active = ["running", "pending", "blocked", "stale"].includes(
|
|
253
255
|
(task.status ?? "").toLowerCase(),
|
|
254
256
|
);
|
|
257
|
+
if (ledgerEl) {
|
|
258
|
+
void renderTaskLedger(ledgerEl, taskId);
|
|
259
|
+
}
|
|
255
260
|
return active;
|
|
256
261
|
}
|
|
257
262
|
|
|
263
|
+
/**
|
|
264
|
+
* Task 详情页 ledger 安全摘要(AC-009):从只读 GET /api/tasks/:id/ledger 拉取,
|
|
265
|
+
* 计数/状态/failure code + 有界排除理由;无 ledger 显示空态,失败安全降级。
|
|
266
|
+
*/
|
|
267
|
+
async function renderTaskLedger(ledgerEl, taskId) {
|
|
268
|
+
clearNode(ledgerEl);
|
|
269
|
+
ledgerEl.appendChild(el("h3", "section-heading", "Source fidelity ledger"));
|
|
270
|
+
mountViewState(ledgerEl, "loading", "加载 ledger…");
|
|
271
|
+
let body = null;
|
|
272
|
+
try {
|
|
273
|
+
body = await fetchJson(`/api/tasks/${encodeURIComponent(taskId)}/ledger`);
|
|
274
|
+
} catch {
|
|
275
|
+
body = null;
|
|
276
|
+
}
|
|
277
|
+
if (!body) {
|
|
278
|
+
mountViewState(ledgerEl, "error", "ledger 只读接口失败(安全降级)。");
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
if (body.present !== true) {
|
|
282
|
+
mountViewState(
|
|
283
|
+
ledgerEl,
|
|
284
|
+
body.error ? "error" : "empty",
|
|
285
|
+
body.error
|
|
286
|
+
? `ledger 不可用(${body.error})。`
|
|
287
|
+
: "无 source fidelity ledger(任务无引用或 ledger 缺失,不伪造计数)。",
|
|
288
|
+
);
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
const pre = el(
|
|
292
|
+
"pre",
|
|
293
|
+
"cmd",
|
|
294
|
+
formatLedgerSummary({
|
|
295
|
+
present: true,
|
|
296
|
+
fragmentCount: body.fragmentCount,
|
|
297
|
+
canonicalRequirementCount: body.canonicalRequirementCount,
|
|
298
|
+
contextOnlyCount: body.contextOnlyCount,
|
|
299
|
+
duplicateCount: body.duplicateCount,
|
|
300
|
+
unresolvedCount: body.unresolvedCount,
|
|
301
|
+
conflictCount: body.conflictCount,
|
|
302
|
+
gateStatus: body.gateStatus,
|
|
303
|
+
failureCode: body.failureCode,
|
|
304
|
+
exclusions: body.exclusions ?? [],
|
|
305
|
+
}),
|
|
306
|
+
);
|
|
307
|
+
pre.dataset.testid = "task-ledger-summary";
|
|
308
|
+
clearNode(ledgerEl);
|
|
309
|
+
ledgerEl.appendChild(el("h3", "section-heading", "Source fidelity ledger"));
|
|
310
|
+
ledgerEl.appendChild(pre);
|
|
311
|
+
}
|
|
312
|
+
|
|
258
313
|
export async function loadOlderTaskRuns(featureId, taskId, before, runsEl) {
|
|
259
314
|
if (runsEl === undefined) {
|
|
260
315
|
runsEl = before;
|
|
@@ -5,6 +5,7 @@ import path from "node:path";
|
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
import YAML from "yaml";
|
|
7
7
|
import { resolveBackendTestLayout, } from "./backend-test-layout.js";
|
|
8
|
+
import { resolveBackendTestManifestModules, backendManifestStatusFinding } from "./backend-test-markdown-workflow.js";
|
|
8
9
|
import { applyOpenApiPartitionDomainPolicy, assessScenarioPartitionCoverage, parseScenarioPartitions, } from "./backend-test-scenario-partitions.js";
|
|
9
10
|
import { backendTestCaseManifestSchema, computeCaseManifestCoverageSummary, } from "./backend-test-case-manifest.js";
|
|
10
11
|
const CASE_HEADING = /^##\s+(BE-[A-Z0-9_-]+-\d{3})\b.*$/gm;
|
|
@@ -659,10 +660,18 @@ async function markdownModuleFiles(workspaceRoot, layout) {
|
|
|
659
660
|
const resolved = layout ?? resolveBackendTestLayout(undefined);
|
|
660
661
|
const dir = path.join(workspaceRoot, ...resolved.markdownDir.split("/"));
|
|
661
662
|
const entries = await readdir(dir, { withFileTypes: true });
|
|
662
|
-
|
|
663
|
+
const all = entries
|
|
663
664
|
.filter((entry) => entry.isFile() && entry.name.toLowerCase().endsWith(".md") && entry.name.toLowerCase() !== "readme.md")
|
|
664
665
|
.map((entry) => path.join(dir, entry.name))
|
|
665
666
|
.sort();
|
|
667
|
+
// Current-round Markdown scope is the README Module Index manifest: unmanifested
|
|
668
|
+
// legacy .md files must not enter Case/coverage/partition statistics. Workspaces
|
|
669
|
+
// without a Module Index fall back to the whole directory (prior behaviour).
|
|
670
|
+
const manifest = await resolveBackendTestManifestModules(workspaceRoot, resolved);
|
|
671
|
+
if (manifest.manifestStatus !== "valid")
|
|
672
|
+
return [];
|
|
673
|
+
const declaredAbs = new Set(manifest.declaredMdFiles.map((rel) => path.join(workspaceRoot, ...rel.split("/")).toLowerCase()));
|
|
674
|
+
return all.filter((file) => declaredAbs.has(file.toLowerCase())).sort();
|
|
666
675
|
}
|
|
667
676
|
async function parseMarkdownCases(workspaceRoot, layout) {
|
|
668
677
|
const result = [];
|
|
@@ -874,6 +883,16 @@ export async function analyzeBackendTestCaseCoverage(input) {
|
|
|
874
883
|
findings.push(...coverageScope.findings);
|
|
875
884
|
const matrix = parseCoverageMatrix(readme);
|
|
876
885
|
findings.push(...matrix.findings);
|
|
886
|
+
const manifest = await resolveBackendTestManifestModules(input.workspaceRoot, layout);
|
|
887
|
+
// Fail closed on README Module Index entries declared but never materialized.
|
|
888
|
+
if (manifest.declaredMissing.length > 0) {
|
|
889
|
+
findings.push(`declared Markdown module is missing (Module Index): ${manifest.declaredMissing.join(", ")}`);
|
|
890
|
+
}
|
|
891
|
+
// Fail closed on every non-valid Module Index state: without a valid unique
|
|
892
|
+
// Module Index the current round must not re-scan historical `.md` files.
|
|
893
|
+
if (manifest.manifestStatus !== "valid") {
|
|
894
|
+
findings.push(backendManifestStatusFinding(manifest.manifestStatus, manifest.moduleIndexHeadingCount));
|
|
895
|
+
}
|
|
877
896
|
const cases = await parseMarkdownCases(input.workspaceRoot, layout);
|
|
878
897
|
for (const file of await markdownModuleFiles(input.workspaceRoot, layout)) {
|
|
879
898
|
const markdown = await readFile(file, "utf8");
|
|
@@ -1109,6 +1128,15 @@ export async function analyzeBackendTestCaseCoverage(input) {
|
|
|
1109
1128
|
"",
|
|
1110
1129
|
facts.status,
|
|
1111
1130
|
"",
|
|
1131
|
+
`- Manifest scope: ${manifest.manifestStatus === "valid" ? "declared-modules" : `fails-closed:${manifest.manifestStatus}`} (declared-missing=${manifest.declaredMissing.length}, unmanifested-advisory=${manifest.unmanifested.length}, module-index-heading-count=${manifest.moduleIndexHeadingCount})`,
|
|
1132
|
+
"",
|
|
1133
|
+
"## Unmanifested Markdown Modules",
|
|
1134
|
+
"",
|
|
1135
|
+
"- Advisory: existing .md files not declared by the README Module Index are excluded from Case/coverage/partition statistics for this round.",
|
|
1136
|
+
...(manifest.unmanifested.length > 0
|
|
1137
|
+
? manifest.unmanifested.map((item) => `- ${item}`)
|
|
1138
|
+
: ["- None"]),
|
|
1139
|
+
"",
|
|
1112
1140
|
"## Coverage Scope",
|
|
1113
1141
|
"",
|
|
1114
1142
|
`- Change Classification: ${facts.coverageScope.changeClassification}`,
|
|
@@ -200,14 +200,170 @@ export async function inspectBackendTestEnvironment(input) {
|
|
|
200
200
|
serverEntries,
|
|
201
201
|
};
|
|
202
202
|
}
|
|
203
|
+
/**
|
|
204
|
+
* Filenames declared by the canonical `## Module Index` section of the backend
|
|
205
|
+
* README. Only a unique exact `## Module Index` heading is authoritative; a
|
|
206
|
+
* missing/duplicate section yields an empty declaration set (callers then fall
|
|
207
|
+
* back to the whole directory so legacy workspaces without a manifest keep
|
|
208
|
+
* their prior behaviour). Reads `[x](./x.md)`, `` `testcase/md/<x>.md` `` and
|
|
209
|
+
* inline `x.md` tokens inside the section; README.md itself is never a module.
|
|
210
|
+
*/
|
|
211
|
+
export function extractDeclaredModuleIndexFilenames(readme) {
|
|
212
|
+
const lines = readme
|
|
213
|
+
.replaceAll("\r\n", "\n")
|
|
214
|
+
.replaceAll("\r", "\n")
|
|
215
|
+
.split("\n");
|
|
216
|
+
const headings = lines.flatMap((line, index) => line.trim() === "## Module Index" ? [index] : []);
|
|
217
|
+
if (headings.length !== 1)
|
|
218
|
+
return [];
|
|
219
|
+
const start = headings[0] + 1;
|
|
220
|
+
const relativeEnd = lines
|
|
221
|
+
.slice(start)
|
|
222
|
+
.findIndex((line) => /^##\s+\S/.test(line.trim()));
|
|
223
|
+
const end = relativeEnd < 0 ? lines.length : start + relativeEnd;
|
|
224
|
+
const section = lines.slice(start, end).join("\n");
|
|
225
|
+
return unique([...section.matchAll(/`?[A-Za-z0-9_.-]+\.md`?/g)]
|
|
226
|
+
.map((match) => match[0].replaceAll("`", ""))
|
|
227
|
+
.filter((name) => name.toLowerCase() !== "readme.md"));
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Count exact `## Module Index` headings in the backend README.
|
|
231
|
+
*/
|
|
232
|
+
function moduleIndexHeadingCountIn(readme) {
|
|
233
|
+
return readme
|
|
234
|
+
.replaceAll("\r\n", "\n")
|
|
235
|
+
.replaceAll("\r", "\n")
|
|
236
|
+
.split("\n")
|
|
237
|
+
.filter((line) => line.trim() === "## Module Index").length;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Machine-readable fail-closed finding for an invalid backend-test Module Index.
|
|
241
|
+
* These are distinct states (missing/unreadable/duplicate/empty-unparsable) so a
|
|
242
|
+
* stripped Module Index can never silently fall back to a whole-directory scan.
|
|
243
|
+
*/
|
|
244
|
+
export function backendManifestStatusFinding(manifestStatus, moduleIndexHeadingCount = 0) {
|
|
245
|
+
switch (manifestStatus) {
|
|
246
|
+
case "missing":
|
|
247
|
+
return "README is missing; backend-test current round fails closed without a declarative Module Index";
|
|
248
|
+
case "unreadable":
|
|
249
|
+
return "README is unreadable; backend-test current round fails closed without a usable Module Index";
|
|
250
|
+
case "duplicate":
|
|
251
|
+
return moduleIndexHeadingCount === 0
|
|
252
|
+
? "README Module Index heading is missing; backend-test current round fails closed without a declarative Module Index"
|
|
253
|
+
: `duplicate ## Module Index heading (${moduleIndexHeadingCount} occurrences); backend-test current round fails closed without a unique Module Index`;
|
|
254
|
+
case "empty-unparsable":
|
|
255
|
+
return "README Module Index is empty/unparsable; backend-test current round fails closed with no declared module";
|
|
256
|
+
case "valid":
|
|
257
|
+
return "";
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Resolve the current-round Markdown module manifest. The README `## Module
|
|
262
|
+
* Index` is the authoritative source for which module files belong to this
|
|
263
|
+
* round. Fail closed on every non-`valid` state (missing/unreadable/duplicate/
|
|
264
|
+
* empty-unparsable): the backend-test current round must NEVER re-scan the whole
|
|
265
|
+
* directory, or historical `.md` files could leak back into Case/coverage/
|
|
266
|
+
* partition facts.
|
|
267
|
+
*
|
|
268
|
+
* - `manifestStatus==="valid"` — unique heading with >= 1 declared `.md` file.
|
|
269
|
+
* - `missing` — README file does not exist.
|
|
270
|
+
* - `unreadable` — README exists but could not be read.
|
|
271
|
+
* - `duplicate` — README has 0 or duplicate `## Module Index`.
|
|
272
|
+
* - `empty-unparsable` — unique heading but no `.md` filename parsed.
|
|
273
|
+
* - `declaredMdFiles` — declared filenames that exist on disk (relative paths).
|
|
274
|
+
* - `declaredMissing` — declared filenames with no file on disk (fail-closed
|
|
275
|
+
* evidence, never silently dropped).
|
|
276
|
+
* - `unmanifested` — existing `.md` files that the Module Index does not
|
|
277
|
+
* declare (non-silent advisory; they must not enter Case/coverage/partition).
|
|
278
|
+
*/
|
|
279
|
+
export async function resolveBackendTestManifestModules(workspaceRoot, layout) {
|
|
280
|
+
const resolved = layout ?? resolveBackendTestLayout(undefined);
|
|
281
|
+
const readmePath = path.join(workspaceRoot, ...resolved.readmePath.split("/"));
|
|
282
|
+
const invalid = (manifestStatus, moduleIndexHeadingCount) => ({
|
|
283
|
+
hasManifest: false,
|
|
284
|
+
manifestStatus,
|
|
285
|
+
moduleIndexHeadingCount,
|
|
286
|
+
declaredStems: [],
|
|
287
|
+
declaredMdFiles: [],
|
|
288
|
+
declaredMissing: [],
|
|
289
|
+
unmanifested: [],
|
|
290
|
+
});
|
|
291
|
+
let readme = "";
|
|
292
|
+
if (await exists(readmePath)) {
|
|
293
|
+
try {
|
|
294
|
+
readme = await readFile(readmePath, "utf8");
|
|
295
|
+
}
|
|
296
|
+
catch {
|
|
297
|
+
// Unreadable README is fail-closed (not silently treated as no manifest).
|
|
298
|
+
return invalid("unreadable", 0);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
return invalid("missing", 0);
|
|
303
|
+
}
|
|
304
|
+
const moduleIndexHeadingCount = moduleIndexHeadingCountIn(readme);
|
|
305
|
+
if (moduleIndexHeadingCount !== 1) {
|
|
306
|
+
return invalid("duplicate", moduleIndexHeadingCount);
|
|
307
|
+
}
|
|
308
|
+
const declaredStems = extractDeclaredModuleIndexFilenames(readme);
|
|
309
|
+
if (declaredStems.length === 0) {
|
|
310
|
+
return invalid("empty-unparsable", moduleIndexHeadingCount);
|
|
311
|
+
}
|
|
312
|
+
const hasManifest = true;
|
|
313
|
+
const directory = path.join(workspaceRoot, ...resolved.markdownDir.split("/"));
|
|
314
|
+
let existingNames = [];
|
|
315
|
+
try {
|
|
316
|
+
existingNames = (await readdir(directory, { withFileTypes: true }))
|
|
317
|
+
.filter((entry) => entry.isFile() &&
|
|
318
|
+
entry.name.toLowerCase().endsWith(".md") &&
|
|
319
|
+
entry.name.toLowerCase() !== "readme.md")
|
|
320
|
+
.map((entry) => entry.name);
|
|
321
|
+
}
|
|
322
|
+
catch {
|
|
323
|
+
// missing markdown directory -> no existing modules
|
|
324
|
+
}
|
|
325
|
+
const declaredByLower = new Map();
|
|
326
|
+
for (const name of declaredStems) {
|
|
327
|
+
const base = path.posix.basename(name);
|
|
328
|
+
declaredByLower.set(base.toLowerCase(), base);
|
|
329
|
+
}
|
|
330
|
+
const declaredMdFiles = [];
|
|
331
|
+
const declaredMissing = [];
|
|
332
|
+
for (const base of declaredByLower.values()) {
|
|
333
|
+
const disk = existingNames.find((name) => name.toLowerCase() === base.toLowerCase());
|
|
334
|
+
if (disk)
|
|
335
|
+
declaredMdFiles.push(`${resolved.markdownDir}/${disk}`);
|
|
336
|
+
else
|
|
337
|
+
declaredMissing.push(`${resolved.markdownDir}/${base}`);
|
|
338
|
+
}
|
|
339
|
+
const unmanifested = existingNames
|
|
340
|
+
.filter((name) => !declaredByLower.has(name.toLowerCase()))
|
|
341
|
+
.map((name) => `${resolved.markdownDir}/${name}`);
|
|
342
|
+
return {
|
|
343
|
+
hasManifest,
|
|
344
|
+
manifestStatus: "valid",
|
|
345
|
+
moduleIndexHeadingCount,
|
|
346
|
+
declaredStems,
|
|
347
|
+
declaredMdFiles: declaredMdFiles.sort(),
|
|
348
|
+
declaredMissing: declaredMissing.sort(),
|
|
349
|
+
unmanifested: unmanifested.sort(),
|
|
350
|
+
};
|
|
351
|
+
}
|
|
203
352
|
export async function markdownFiles(root, layout) {
|
|
204
353
|
const resolved = layout ?? resolveBackendTestLayout(undefined);
|
|
205
354
|
const directory = path.join(root, ...resolved.markdownDir.split("/"));
|
|
206
355
|
const entries = await readdir(directory, { withFileTypes: true });
|
|
207
|
-
|
|
356
|
+
const all = entries
|
|
208
357
|
.filter((entry) => entry.isFile() && entry.name.toLowerCase().endsWith(".md"))
|
|
209
358
|
.map((entry) => path.join(directory, entry.name))
|
|
210
359
|
.sort();
|
|
360
|
+
const manifest = await resolveBackendTestManifestModules(root, resolved);
|
|
361
|
+
if (manifest.manifestStatus !== "valid")
|
|
362
|
+
return [];
|
|
363
|
+
const declaredAbs = new Set(manifest.declaredMdFiles.map((rel) => path.join(root, ...rel.split("/")).toLowerCase()));
|
|
364
|
+
return all
|
|
365
|
+
.filter((file) => declaredAbs.has(file.toLowerCase()))
|
|
366
|
+
.sort();
|
|
211
367
|
}
|
|
212
368
|
function canonicalBackendCaseId(value) {
|
|
213
369
|
const upper = value.toUpperCase();
|
|
@@ -453,6 +609,17 @@ export async function validateBackendMarkdownCases(input) {
|
|
|
453
609
|
const readme = path.join(input.workspaceRoot, ...layout.readmePath.split("/"));
|
|
454
610
|
if (!(await exists(readme)))
|
|
455
611
|
findings.push(`missing ${layout.readmePath}`);
|
|
612
|
+
const manifest = await resolveBackendTestManifestModules(input.workspaceRoot, layout);
|
|
613
|
+
// Fail closed on README Module Index entries that were declared but never
|
|
614
|
+
// materialized — never let a declared module silently vanish from the round.
|
|
615
|
+
if (manifest.declaredMissing.length > 0) {
|
|
616
|
+
findings.push(`declared Markdown module is missing (Module Index): ${manifest.declaredMissing.join(", ")}`);
|
|
617
|
+
}
|
|
618
|
+
// Fail closed on every non-valid Module Index state: without a valid unique
|
|
619
|
+
// Module Index the current round must not re-scan historical `.md` files.
|
|
620
|
+
if (manifest.manifestStatus !== "valid") {
|
|
621
|
+
findings.push(backendManifestStatusFinding(manifest.manifestStatus, manifest.moduleIndexHeadingCount));
|
|
622
|
+
}
|
|
456
623
|
const moduleFiles = files.filter((file) => path.basename(file).toLowerCase() !== "readme.md");
|
|
457
624
|
if (moduleFiles.length === 0)
|
|
458
625
|
findings.push(`no ${layout.markdownDir} module case file found`);
|
|
@@ -562,6 +729,7 @@ export async function validateBackendMarkdownCases(input) {
|
|
|
562
729
|
`- Cases: ${caseCount}`,
|
|
563
730
|
`- Covered AC IDs: ${[...coveredAc].sort().join(", ") || "none"}`,
|
|
564
731
|
`- Environment evidence present: ${input.environmentMarkdown.trim() ? "yes" : "no"}`,
|
|
732
|
+
`- Manifest scope: ${manifest.manifestStatus === "valid" ? "declared-modules" : `fails-closed:${manifest.manifestStatus}`} (declared-missing=${manifest.declaredMissing.length}, unmanifested-advisory=${manifest.unmanifested.length}, module-index-heading-count=${manifest.moduleIndexHeadingCount})`,
|
|
565
733
|
`- Findings: ${findings.length}`,
|
|
566
734
|
"- Required sections: Preconditions/前置条件, Steps/操作步骤, Expected Results/预期结果",
|
|
567
735
|
"- Source-reference validity check: not applied",
|
|
@@ -583,6 +751,13 @@ export async function validateBackendMarkdownCases(input) {
|
|
|
583
751
|
? safetyFindings.map((finding) => `- ${finding}`)
|
|
584
752
|
: ["- No secret-shaped values detected."]),
|
|
585
753
|
"",
|
|
754
|
+
"## Unmanifested Markdown Modules",
|
|
755
|
+
"",
|
|
756
|
+
"- Advisory: existing .md files not declared by the README Module Index are excluded from this round's Case/coverage/partition scope.",
|
|
757
|
+
...(manifest.unmanifested.length > 0
|
|
758
|
+
? manifest.unmanifested.map((item) => `- ${item}`)
|
|
759
|
+
: ["- None"]),
|
|
760
|
+
"",
|
|
586
761
|
"## Findings",
|
|
587
762
|
"",
|
|
588
763
|
...(findings.length > 0 ? findings.map((finding) => `- ${finding}`) : ["- None"]),
|
|
@@ -131,6 +131,23 @@ function normalizeHazardOccurrenceIdentity(line) {
|
|
|
131
131
|
// Unclosed quote or no out-of-string `#`: do not invent a comment boundary.
|
|
132
132
|
return trimmed;
|
|
133
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Bare `__NNN_*` helper module names imported by a Python source snippet.
|
|
136
|
+
* Only the head token of an `import`/`from` statement is considered a module
|
|
137
|
+
* name; dotted submodules (`__551_manager_helpers.x`) collapse to the head.
|
|
138
|
+
*/
|
|
139
|
+
function importedBareHelperModules(source) {
|
|
140
|
+
const names = [];
|
|
141
|
+
const seen = new Set();
|
|
142
|
+
for (const match of normalizeSourceNewlines(source).matchAll(/\b(?:import|from)\s+([A-Za-z0-9_.]+)/g)) {
|
|
143
|
+
const head = match[1].split(".")[0];
|
|
144
|
+
if (/^__\d+[A-Za-z0-9_]*$/.test(head) && !seen.has(head)) {
|
|
145
|
+
seen.add(head);
|
|
146
|
+
names.push(head);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return names;
|
|
150
|
+
}
|
|
134
151
|
function listPatternOccurrences(source, patternSource, flags = "") {
|
|
135
152
|
const normalized = normalizeSourceNewlines(source);
|
|
136
153
|
const pattern = new RegExp(patternSource, flags.includes("g") ? flags : `${flags}g`);
|
|
@@ -221,6 +238,8 @@ export async function buildBackendPytestAssetInventory(workspaceRoot, mappedScri
|
|
|
221
238
|
const inputHashes = {};
|
|
222
239
|
const hazardOccurrenceCounts = {};
|
|
223
240
|
const hazardOccurrences = {};
|
|
241
|
+
const scriptBareImports = {};
|
|
242
|
+
const mappedScriptSet = new Set(normalizedScripts);
|
|
224
243
|
for (const file of assetFiles) {
|
|
225
244
|
const bytes = await readFile(path.resolve(workspaceRoot, file));
|
|
226
245
|
const source = bytes.toString("utf8");
|
|
@@ -228,8 +247,10 @@ export async function buildBackendPytestAssetInventory(workspaceRoot, mappedScri
|
|
|
228
247
|
const lists = scanRepairHazardOccurrenceLists(source);
|
|
229
248
|
hazardOccurrences[file] = lists;
|
|
230
249
|
hazardOccurrenceCounts[file] = Object.fromEntries(Object.entries(lists).map(([label, identities]) => [label, identities.length]));
|
|
250
|
+
if (mappedScriptSet.has(file))
|
|
251
|
+
scriptBareImports[file] = importedBareHelperModules(source);
|
|
231
252
|
}
|
|
232
|
-
return { mappedScripts: normalizedScripts, assetFiles, inputHashes, hazardOccurrenceCounts, hazardOccurrences };
|
|
253
|
+
return { mappedScripts: normalizedScripts, assetFiles, inputHashes, hazardOccurrenceCounts, hazardOccurrences, scriptBareImports };
|
|
233
254
|
}
|
|
234
255
|
function bounded(value) {
|
|
235
256
|
const normalized = value.replaceAll(/(Bearer|Basic)\s+[A-Za-z0-9._~+\/-]+/gi, "$1 [REDACTED]");
|
|
@@ -308,8 +329,68 @@ function classifyFixtureResolutionFailure(output, layout) {
|
|
|
308
329
|
repairPaths: paths,
|
|
309
330
|
};
|
|
310
331
|
}
|
|
311
|
-
|
|
332
|
+
/**
|
|
333
|
+
* Generated-local bare helper module signatures found in the bound pytest
|
|
334
|
+
* asset inventory. A file such as `testcase/__551_manager_helpers.py` in the
|
|
335
|
+
* test root/script dir is generated-local: when collection reports
|
|
336
|
+
* `No module named '__551_manager_helpers'`, the defect can be precisely
|
|
337
|
+
* attributed to the generated mapped script instead of a missing third-party
|
|
338
|
+
* package.
|
|
339
|
+
*/
|
|
340
|
+
function generatedLocalBareHelperNames(inventory) {
|
|
341
|
+
if (!inventory)
|
|
342
|
+
return [];
|
|
343
|
+
const names = [];
|
|
344
|
+
for (const file of inventory.assetFiles) {
|
|
345
|
+
const stem = path.posix.basename(file).replace(/\.py$/, "");
|
|
346
|
+
if (/^__\d+[A-Za-z0-9_]*$/.test(stem))
|
|
347
|
+
names.push(stem);
|
|
348
|
+
}
|
|
349
|
+
return [...new Set(names)];
|
|
350
|
+
}
|
|
351
|
+
function classifyCollectionFailure(output, evidence) {
|
|
312
352
|
const normalized = output.replaceAll("\\", "/");
|
|
353
|
+
const helperNames = generatedLocalBareHelperNames(evidence?.inventory);
|
|
354
|
+
const helperByLower = new Map(helperNames.map((name) => [name.toLowerCase(), name]));
|
|
355
|
+
// A bare `__NNN_...` module import that collection cannot find is only a
|
|
356
|
+
// candidate generated-local helper signature. REPAIRABLE requires two
|
|
357
|
+
// deterministic pieces of evidence: (1) a helper asset of the same name in
|
|
358
|
+
// the bound inventory, and (2) at least one mapped generated script whose
|
|
359
|
+
// source truly imports that bare module. Without both — or when attribution
|
|
360
|
+
// is impossible — fail closed as BLOCKED so an un-attributable dependency
|
|
361
|
+
// error is never widened into a repair. Genuine third-party modules (no
|
|
362
|
+
// `__NNN_` signature) stay BLOCKED below.
|
|
363
|
+
const missingModule = /No module named ['\"]([^'\"]+)['\"]/i.exec(normalized)?.[1];
|
|
364
|
+
if (missingModule && /^__\d+[A-Za-z0-9_]*$/.test(missingModule)) {
|
|
365
|
+
const helperAsset = helperByLower.get(missingModule.toLowerCase());
|
|
366
|
+
const inventory = evidence?.inventory;
|
|
367
|
+
const scriptBareImports = inventory?.scriptBareImports ?? {};
|
|
368
|
+
const missingLower = missingModule.toLowerCase();
|
|
369
|
+
const importedByMappedScript = inventory
|
|
370
|
+
? inventory.mappedScripts.some((script) => (scriptBareImports[script] ?? []).some((name) => name.toLowerCase() === missingLower))
|
|
371
|
+
: false;
|
|
372
|
+
if (helperAsset && importedByMappedScript && inventory) {
|
|
373
|
+
const repairPaths = [...new Set([
|
|
374
|
+
...(helperAsset
|
|
375
|
+
? inventory.assetFiles.filter((file) => path.posix.basename(file).replace(/\.py$/, "") === helperAsset)
|
|
376
|
+
: []),
|
|
377
|
+
...inventory.mappedScripts,
|
|
378
|
+
])].sort();
|
|
379
|
+
return {
|
|
380
|
+
status: "REPAIRABLE",
|
|
381
|
+
kind: "missing-generated-local-helper",
|
|
382
|
+
detail: `generated testcase asset imports missing bare generated-local helper module ${missingModule}; inline the helper or remove the generated shared dependency`,
|
|
383
|
+
repairPaths,
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
return {
|
|
387
|
+
status: "BLOCKED",
|
|
388
|
+
kind: "missing-generated-local-helper-without-evidence",
|
|
389
|
+
detail: helperAsset
|
|
390
|
+
? `missing bare generated-local helper module ${missingModule} has a name match but no mapped generated script imports it (no precise generated-local attribution)`
|
|
391
|
+
: `missing bare __NNN_* module ${missingModule} has no generated-local helper asset in the bound inventory (cannot be precisely attributed)`,
|
|
392
|
+
};
|
|
393
|
+
}
|
|
313
394
|
const blockedPatterns = [
|
|
314
395
|
[/No module named ['\"](?!testcase(?:\.|['\"]))/i, "missing-third-party-module"],
|
|
315
396
|
[/pytest(?:_|-)plugin|pluggy|unknown hook|unrecognized arguments/i, "pytest-plugin-or-config"],
|
|
@@ -401,7 +482,7 @@ export function assessBackendPytestCollection(input) {
|
|
|
401
482
|
fixtureStderrExcerpt: bounded(fixtureResolution.stderr),
|
|
402
483
|
});
|
|
403
484
|
}
|
|
404
|
-
const classification = classifyCollectionFailure(`${input.stdout}\n${input.stderr}
|
|
485
|
+
const classification = classifyCollectionFailure(`${input.stdout}\n${input.stderr}`, { layout: input.layout, inventory: input.inventory });
|
|
405
486
|
return backendPytestCollectionFactsSchema.parse({
|
|
406
487
|
schemaId: "backend-test-pytest-collection-v3",
|
|
407
488
|
phase: input.phase,
|
|
@@ -412,7 +493,9 @@ export function assessBackendPytestCollection(input) {
|
|
|
412
493
|
fixtureResolutionAttempted: false,
|
|
413
494
|
fixtureResolutionStatus: "NOT_RUN",
|
|
414
495
|
fixtureResolutionExitCode: null,
|
|
415
|
-
repairPaths:
|
|
496
|
+
repairPaths: classification.repairPaths && classification.repairPaths.length > 0
|
|
497
|
+
? classification.repairPaths
|
|
498
|
+
: testcasePythonPaths(`${input.stdout}\n${input.stderr}`),
|
|
416
499
|
mappedScripts: input.inventory.mappedScripts,
|
|
417
500
|
existingMappedScripts: input.inventory.mappedScripts,
|
|
418
501
|
missingMappedScripts: [],
|
|
@@ -385,12 +385,17 @@ export const FORBIDDEN_GENERATED_IMPORT_NAMESPACES = [
|
|
|
385
385
|
"testcase.helpers",
|
|
386
386
|
"testcase.factories",
|
|
387
387
|
];
|
|
388
|
-
const FORBIDDEN_GENERATED_IMPORT_PATTERN = /^\s*(?:from\s+(testcase_helpers|testcase\.helpers|testcase\.factories)\b|import\s+(testcase_helpers|testcase\.helpers|testcase\.factories)\b)/gm;
|
|
388
|
+
const FORBIDDEN_GENERATED_IMPORT_PATTERN = /^\s*(?:from\s+(testcase_helpers|testcase\.helpers|testcase\.factories|__\d+[A-Za-z0-9_]*)\b|import\s+(testcase_helpers|testcase\.helpers|testcase\.factories|__\d+[A-Za-z0-9_]*)\b)/gm;
|
|
389
389
|
/**
|
|
390
|
-
* Scan Python source for imports from forbidden generated shared namespaces
|
|
391
|
-
* Anchored at line start with a word
|
|
392
|
-
* substring inside a docstring
|
|
393
|
-
*
|
|
390
|
+
* Scan Python source for imports from forbidden generated shared namespaces
|
|
391
|
+
* or bare generated-local helper modules. Anchored at line start with a word
|
|
392
|
+
* boundary so `testcase.helpers_other` or a substring inside a docstring is not
|
|
393
|
+
* falsely flagged. In addition to the `testcase_helpers`/`testcase.helpers`/
|
|
394
|
+
* `testcase.factories` namespaces, bare `__<digits>...` helper modules (for
|
|
395
|
+
* example `from __551_manager_helpers import ...` / `import __551_manager_helpers`)
|
|
396
|
+
* are generated-local shared dependencies: a self-contained pytest child must
|
|
397
|
+
* inline or remove them rather than depend on a generated shared module.
|
|
398
|
+
* Returns the list of offending module names (deduplicated, order-preserving).
|
|
394
399
|
*/
|
|
395
400
|
export function findForbiddenGeneratedImports(source) {
|
|
396
401
|
const hits = [];
|