@tea-agent/loop-agent 0.1.0-fe-test.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +114 -0
- package/CHANGELOG.md +2283 -0
- package/README.md +177 -0
- package/bin/agent-worker.js +22 -0
- package/bin/loop-agent.js +57 -0
- package/dist/adapters/aimax.js +91 -0
- package/dist/adapters/context.js +32 -0
- package/dist/adapters/index.js +29 -0
- package/dist/adapters/loop-agent.js +192 -0
- package/dist/adapters/types.js +1 -0
- package/dist/application/context-usage/skill-resolution-stats.js +263 -0
- package/dist/application/dag/args.js +486 -0
- package/dist/application/dag/generate-task-dag.js +408 -0
- package/dist/application/dag/report-dag.js +14 -0
- package/dist/application/dag/run-dag.js +109 -0
- package/dist/application/dag/validate-dag.js +166 -0
- package/dist/application/evaluation/alias.js +184 -0
- package/dist/application/evaluation/budget.js +192 -0
- package/dist/application/evaluation/campaign-hash.js +47 -0
- package/dist/application/evaluation/campaign-matrix.js +372 -0
- package/dist/application/evaluation/campaign-scorecard.js +135 -0
- package/dist/application/evaluation/campaign.js +370 -0
- package/dist/application/evaluation/candidate-hash.js +75 -0
- package/dist/application/evaluation/candidate.js +69 -0
- package/dist/application/evaluation/corpus-hash.js +38 -0
- package/dist/application/evaluation/corpus.js +56 -0
- package/dist/application/evaluation/experiment.js +294 -0
- package/dist/application/evaluation/ignition.js +198 -0
- package/dist/application/evaluation/integrity-audit.js +162 -0
- package/dist/application/evaluation/outer-loop.js +132 -0
- package/dist/application/evaluation/pi-cell-executor.js +39 -0
- package/dist/application/evaluation/private-verifier.js +46 -0
- package/dist/application/evaluation/promotion-policy.js +151 -0
- package/dist/application/evaluation/proposer.js +98 -0
- package/dist/application/evaluation/replay.js +289 -0
- package/dist/application/evaluation/types.js +652 -0
- package/dist/application/loop/run-action.js +19 -0
- package/dist/application/task-lifecycle/advance.js +1204 -0
- package/dist/application/task-lifecycle/gates.js +130 -0
- package/dist/application/task-lifecycle/index.js +7 -0
- package/dist/application/task-lifecycle/observe.js +424 -0
- package/dist/application/task-lifecycle/plan-transitions.js +251 -0
- package/dist/application/task-lifecycle/recommendations.js +180 -0
- package/dist/application/task-lifecycle/record.js +73 -0
- package/dist/application/task-lifecycle/types.js +1 -0
- package/dist/build-stamp.json +6 -0
- package/dist/cli/catalog.js +24 -0
- package/dist/cli/command-definitions.js +659 -0
- package/dist/cli/help.js +56 -0
- package/dist/cli/index.js +5 -0
- package/dist/cli/program.js +647 -0
- package/dist/cli/router.js +13 -0
- package/dist/cli/update/init-surface-notifier.js +167 -0
- package/dist/cli/update/notifier.js +117 -0
- package/dist/cli/update/npm-client.js +151 -0
- package/dist/cli/update/policy.js +92 -0
- package/dist/cli/update/runtime-activity.js +29 -0
- package/dist/cli/update/state.js +68 -0
- package/dist/cli-governance/active-residue-check.js +38 -0
- package/dist/cli.js +57 -0
- package/dist/commands/client-recovery.js +1373 -0
- package/dist/commands/closeout.js +13 -0
- package/dist/commands/coverage-audit.js +14 -0
- package/dist/commands/coverage-report.js +50 -0
- package/dist/commands/cursor-prompt.js +182 -0
- package/dist/commands/dag-approve.js +142 -0
- package/dist/commands/dag-final-verification.js +76 -0
- package/dist/commands/dag-init-hybrid.js +57 -0
- package/dist/commands/dag-reconcile-run.js +5 -0
- package/dist/commands/dag-reconcile-tasks.js +51 -0
- package/dist/commands/dag-reject.js +91 -0
- package/dist/commands/dag-report.js +76 -0
- package/dist/commands/dag-request-interrupt.js +20 -0
- package/dist/commands/dag-rerun-task.js +19 -0
- package/dist/commands/dag-rerun.js +111 -0
- package/dist/commands/dag-resume.js +35 -0
- package/dist/commands/dag-run-task.js +12 -0
- package/dist/commands/dag-validate.js +20 -0
- package/dist/commands/dag-workflow-compile.js +91 -0
- package/dist/commands/dag-workflow-plan.js +130 -0
- package/dist/commands/dag-workflow-validate.js +66 -0
- package/dist/commands/delegate.js +130 -0
- package/dist/commands/docs-archive.js +5 -0
- package/dist/commands/docs-audit.js +6 -0
- package/dist/commands/doctor.js +283 -0
- package/dist/commands/eval.js +1398 -0
- package/dist/commands/examples.js +90 -0
- package/dist/commands/goal.js +92 -0
- package/dist/commands/handoff-check.js +5 -0
- package/dist/commands/harvest.js +44 -0
- package/dist/commands/import-prd.js +81 -0
- package/dist/commands/init-upgrade.js +3085 -0
- package/dist/commands/init.js +3630 -0
- package/dist/commands/inspect.js +11 -0
- package/dist/commands/instructions.js +223 -0
- package/dist/commands/knowledge.js +162 -0
- package/dist/commands/loop-benchmark.js +72 -0
- package/dist/commands/loop.js +251 -0
- package/dist/commands/new-task.js +5 -0
- package/dist/commands/operator.js +44 -0
- package/dist/commands/pi-prompt.js +174 -0
- package/dist/commands/pi-reuse-benchmark.js +153 -0
- package/dist/commands/plan-list.js +5 -0
- package/dist/commands/plan.js +50 -0
- package/dist/commands/promote-run.js +29 -0
- package/dist/commands/reference-index.js +16 -0
- package/dist/commands/run-dag-progress.js +123 -0
- package/dist/commands/run-dag.js +22 -0
- package/dist/commands/spine.js +38 -0
- package/dist/commands/stats.js +113 -0
- package/dist/commands/status.js +57 -0
- package/dist/commands/study-init.js +192 -0
- package/dist/commands/task-advance.js +366 -0
- package/dist/commands/task-contract.js +269 -0
- package/dist/commands/task-source-prepare.js +479 -0
- package/dist/commands/task-status.js +133 -0
- package/dist/commands/workflow.js +259 -0
- package/dist/commands/worktree-create.js +31 -0
- package/dist/commands/worktree-list.js +5 -0
- package/dist/commands/worktree-remove.js +26 -0
- package/dist/executors/config-core.js +5 -0
- package/dist/executors/config.js +2 -0
- package/dist/executors/dag-pi-executor.js +1277 -0
- package/dist/executors/dag-static-executor.js +42 -0
- package/dist/executors/dag.js +3 -0
- package/dist/executors/index.js +6 -0
- package/dist/executors/model-routing.js +71 -0
- package/dist/executors/pi-defaults.js +9 -0
- package/dist/executors/pi-event-serializer.js +65 -0
- package/dist/executors/pi-executor.js +981 -0
- package/dist/executors/pi-playwright-cli-tool.js +1006 -0
- package/dist/executors/pi-prompt-transport.js +198 -0
- package/dist/executors/pi-reuse-benchmark.js +316 -0
- package/dist/executors/pi-runtime-reuse.js +29 -0
- package/dist/executors/pi-sdk-executor.js +722 -0
- package/dist/executors/pi-sdk.js +1 -0
- package/dist/executors/pi-writer-tool-policy.js +266 -0
- package/dist/executors/pi.js +3 -0
- package/dist/executors/playwright-cli-launcher.js +63 -0
- package/dist/executors/process-tree.js +33 -0
- package/dist/executors/shell-executor.js +3055 -0
- package/dist/executors/shell-presets.js +99 -0
- package/dist/executors/shell-verification.js +262 -0
- package/dist/executors/shell-write-guard.js +543 -0
- package/dist/executors/shell.js +3 -0
- package/dist/executors/static.js +1 -0
- package/dist/governance/checks.js +437 -0
- package/dist/governance/document-index-closure.js +164 -0
- package/dist/governance/exec-plans.js +549 -0
- package/dist/governance/harness.js +9 -0
- package/dist/governance/index.js +3 -0
- package/dist/governance/manifest-types.js +254 -0
- package/dist/governance/manifest.js +2 -0
- package/dist/governance/path-guard.js +69 -0
- package/dist/governance/path-guards.js +2 -0
- package/dist/governance/profiles.js +3 -0
- package/dist/governance/requirement-coverage.js +425 -0
- package/dist/governance/skill-safety.js +135 -0
- package/dist/governance/spine-audit.js +155 -0
- package/dist/infrastructure/evaluation/alias-store.js +199 -0
- package/dist/infrastructure/evaluation/campaign-store.js +154 -0
- package/dist/infrastructure/evaluation/candidate-store.js +439 -0
- package/dist/infrastructure/evaluation/corpus-store.js +181 -0
- package/dist/infrastructure/evaluation/experiment-store.js +124 -0
- package/dist/infrastructure/evaluation/ignition-store.js +82 -0
- package/dist/infrastructure/evaluation/private-verifier-store.js +145 -0
- package/dist/infrastructure/evaluation/proposer-store.js +78 -0
- package/dist/infrastructure/evaluation/store.js +40 -0
- package/dist/infrastructure/harness/active-residue-policy.js +73 -0
- package/dist/infrastructure/harness/artifact-store.js +72 -0
- package/dist/infrastructure/harness/atomic-write.js +50 -0
- package/dist/infrastructure/harness/completed-facts-guard.js +40 -0
- package/dist/infrastructure/harness/loop-action-store.js +20 -0
- package/dist/infrastructure/harness/loop-store.js +41 -0
- package/dist/infrastructure/harness/one-shot-run-store.js +94 -0
- package/dist/infrastructure/harness/task-store.js +108 -0
- package/dist/records/closeout.js +2 -0
- package/dist/records/harvest.js +215 -0
- package/dist/records/index.js +3 -0
- package/dist/records/one-shot-runs.js +386 -0
- package/dist/records/promotion.js +200 -0
- package/dist/shared/artifacts-core.js +107 -0
- package/dist/shared/artifacts.js +2 -0
- package/dist/shared/context-files.js +32 -0
- package/dist/shared/context.js +2 -0
- package/dist/shared/copy-dir.js +17 -0
- package/dist/shared/git-progress.js +172 -0
- package/dist/shared/index.js +5 -0
- package/dist/shared/logger.js +17 -0
- package/dist/shared/one-shot-prompt-args.js +98 -0
- package/dist/shared/openspec-spec.js +125 -0
- package/dist/shared/operator/capabilities.js +2659 -0
- package/dist/shared/operator/command-lifecycle.js +94 -0
- package/dist/shared/operator/envelope.js +59 -0
- package/dist/shared/operator/index.js +5 -0
- package/dist/shared/operator/registry.js +38 -0
- package/dist/shared/operator/types.js +5 -0
- package/dist/shared/output-truncation.js +37 -0
- package/dist/shared/package-metadata.js +530 -0
- package/dist/shared/path-refs.js +31 -0
- package/dist/shared/pi-retry-settings.js +23 -0
- package/dist/shared/playwright-cli-command-policy.js +41 -0
- package/dist/shared/preview.js +39 -0
- package/dist/shared/prompts.js +26 -0
- package/dist/shared/reference-context.js +264 -0
- package/dist/shared/resilient-git.js +133 -0
- package/dist/shared/runtime-activity.js +6 -0
- package/dist/shared/timeout-policy.js +24 -0
- package/dist/shared/timeout.js +1 -0
- package/dist/shared/types.js +5 -0
- package/dist/sidecars/cursor-prompt/executor.js +428 -0
- package/dist/sidecars/cursor-prompt/index.js +3 -0
- package/dist/sidecars/cursor-prompt/stream.js +121 -0
- package/dist/task/config-types.js +235 -0
- package/dist/task/config.js +2 -0
- package/dist/task/contract/adopt.js +166 -0
- package/dist/task/contract/apply.js +326 -0
- package/dist/task/contract/canonicalize.js +60 -0
- package/dist/task/contract/constants.js +30 -0
- package/dist/task/contract/diff.js +177 -0
- package/dist/task/contract/hash.js +42 -0
- package/dist/task/contract/import-revision.js +96 -0
- package/dist/task/contract/index.js +17 -0
- package/dist/task/contract/journal.js +155 -0
- package/dist/task/contract/lock.js +153 -0
- package/dist/task/contract/observe.js +296 -0
- package/dist/task/contract/paths.js +19 -0
- package/dist/task/contract/project.js +185 -0
- package/dist/task/contract/recover.js +312 -0
- package/dist/task/contract/request-ledger.js +37 -0
- package/dist/task/contract/schema.js +153 -0
- package/dist/task/contract/transaction.js +160 -0
- package/dist/task/contract/types.js +1 -0
- package/dist/task/contract/validate-draft.js +106 -0
- package/dist/task/dag-source-paths.js +50 -0
- package/dist/task/delegate.js +208 -0
- package/dist/task/frontend-preflight.js +131 -0
- package/dist/task/frontend-project-capability.js +570 -0
- package/dist/task/goal-audit.js +51 -0
- package/dist/task/goal-policy.js +8 -0
- package/dist/task/goal.js +3 -0
- package/dist/task/ids.js +1 -0
- package/dist/task/index.js +12 -0
- package/dist/task/lifecycle.js +1 -0
- package/dist/task/operator/capabilities.js +6 -0
- package/dist/task/operator/envelope.js +2 -0
- package/dist/task/operator/index.js +5 -0
- package/dist/task/operator/registry.js +2 -0
- package/dist/task/operator/types.js +1 -0
- package/dist/task/paths.js +1 -0
- package/dist/task/read-model.js +140 -0
- package/dist/task/runtime.js +708 -0
- package/dist/task/source-prepare/artifact-meta.js +137 -0
- package/dist/task/source-prepare/build-draft.js +232 -0
- package/dist/task/source-prepare/completeness.js +248 -0
- package/dist/task/source-prepare/index.js +10 -0
- package/dist/task/source-prepare/parse-intent.js +496 -0
- package/dist/task/source-prepare/path-policy.js +197 -0
- package/dist/task/source-prepare/placeholder-paths.js +77 -0
- package/dist/task/source-prepare/prepare.js +920 -0
- package/dist/task/source-prepare/reference-integrity.js +290 -0
- package/dist/task/source-prepare/semantic-intake.js +717 -0
- package/dist/task/source-prepare/types.js +7 -0
- package/dist/task/source-references.js +228 -0
- package/dist/task/source-state.js +1 -0
- package/dist/task/state.js +41 -0
- package/dist/task/subagent-guidance.js +1 -0
- package/dist/task/task-demand-routing.js +443 -0
- package/dist/task/workflow-state-types.js +92 -0
- package/dist/task/worktree-cleanup.js +140 -0
- package/dist/task/worktree.js +388 -0
- package/dist/verification/maven/cache.js +142 -0
- package/dist/verification/maven/index.js +120 -0
- package/dist/verification/maven/plan-commands.js +421 -0
- package/dist/verification/maven/pom-static.js +136 -0
- package/dist/verification/maven/scope-resolve.js +153 -0
- package/dist/verification/maven/stale.js +130 -0
- package/dist/verification/maven/types.js +23 -0
- package/dist/verification/maven/workspace-graph.js +322 -0
- package/dist/worker/cli.js +957 -0
- package/dist/worker/closeout/apply.js +73 -0
- package/dist/worker/closeout/preview.js +30 -0
- package/dist/worker/console/app-data.js +316 -0
- package/dist/worker/console/chat/artifact-card.js +30 -0
- package/dist/worker/console/chat/assistant-content.js +121 -0
- package/dist/worker/console/chat/chat-event-store.js +981 -0
- package/dist/worker/console/chat/chat-ui-policy.js +25 -0
- package/dist/worker/console/chat/compaction-errors.js +64 -0
- package/dist/worker/console/chat/composer-draft-store.js +45 -0
- package/dist/worker/console/chat/context-panel.js +54 -0
- package/dist/worker/console/chat/contract-apply-receipt-store.js +174 -0
- package/dist/worker/console/chat/explore-tools.js +299 -0
- package/dist/worker/console/chat/human-gate-card.js +45 -0
- package/dist/worker/console/chat/interview-adapter.js +149 -0
- package/dist/worker/console/chat/mcp-inventory.js +221 -0
- package/dist/worker/console/chat/model-resolver.js +215 -0
- package/dist/worker/console/chat/operation-card.js +92 -0
- package/dist/worker/console/chat/pi-console-config.js +376 -0
- package/dist/worker/console/chat/pi-runtime.js +2446 -0
- package/dist/worker/console/chat/repo-browser.js +140 -0
- package/dist/worker/console/chat/repo-walk.js +125 -0
- package/dist/worker/console/chat/resource-loader.js +59 -0
- package/dist/worker/console/chat/resource-preferences-store.js +152 -0
- package/dist/worker/console/chat/routes.js +3137 -0
- package/dist/worker/console/chat/runtime-context.js +102 -0
- package/dist/worker/console/chat/runtime-selection.js +96 -0
- package/dist/worker/console/chat/semantic-activity.js +489 -0
- package/dist/worker/console/chat/session-store.js +484 -0
- package/dist/worker/console/chat/shortcuts.js +217 -0
- package/dist/worker/console/chat/tool-adapter.js +131 -0
- package/dist/worker/console/chat/tool-preview.js +247 -0
- package/dist/worker/console/chat/tools.js +212 -0
- package/dist/worker/console/chat/turn-execution-registry.js +82 -0
- package/dist/worker/console/chat/turn-process.js +346 -0
- package/dist/worker/console/chat/usage.js +165 -0
- package/dist/worker/console/chat/workspace-landing.js +103 -0
- package/dist/worker/console/dag-confirmation.js +347 -0
- package/dist/worker/console/dag-execution-receipt.js +393 -0
- package/dist/worker/console/doctor.js +230 -0
- package/dist/worker/console/draft-store.js +158 -0
- package/dist/worker/console/harness-pi-model-matrix.js +137 -0
- package/dist/worker/console/human-gate-token.js +130 -0
- package/dist/worker/console/index.js +17 -0
- package/dist/worker/console/inspect-split.js +82 -0
- package/dist/worker/console/interview/assessment.js +67 -0
- package/dist/worker/console/interview/grill-me.js +277 -0
- package/dist/worker/console/interview/session.js +100 -0
- package/dist/worker/console/interview/tools.js +109 -0
- package/dist/worker/console/loopback.js +16 -0
- package/dist/worker/console/mutation-gate-receipt-store.js +184 -0
- package/dist/worker/console/night-aux-ticker.js +146 -0
- package/dist/worker/console/observe-health-match.js +179 -0
- package/dist/worker/console/observe-link.js +42 -0
- package/dist/worker/console/open-browser.js +134 -0
- package/dist/worker/console/operation-run-facts.js +190 -0
- package/dist/worker/console/operation-runner.js +353 -0
- package/dist/worker/console/operation-sse.js +184 -0
- package/dist/worker/console/operation-store.js +169 -0
- package/dist/worker/console/operation-wait.js +355 -0
- package/dist/worker/console/operator-actions.js +3768 -0
- package/dist/worker/console/operator-selection.js +105 -0
- package/dist/worker/console/operator-surface-health.js +24 -0
- package/dist/worker/console/operator-user-error.js +45 -0
- package/dist/worker/console/pi-readiness.js +288 -0
- package/dist/worker/console/prd-identity.js +102 -0
- package/dist/worker/console/prd-intake-bridge.js +441 -0
- package/dist/worker/console/prd-reference-discovery.js +124 -0
- package/dist/worker/console/recovery-cta.js +320 -0
- package/dist/worker/console/recovery-error-copy.js +198 -0
- package/dist/worker/console/recovery-selection.js +107 -0
- package/dist/worker/console/repo-fingerprint.js +35 -0
- package/dist/worker/console/resolve-dag-run-for-task.js +115 -0
- package/dist/worker/console/resource-loader.js +95 -0
- package/dist/worker/console/routes.js +475 -0
- package/dist/worker/console/security.js +170 -0
- package/dist/worker/console/server.js +357 -0
- package/dist/worker/console/sibling-controller.js +33 -0
- package/dist/worker/console/static/assets/abnfDiagram-N423BO3Z-BmOEx0gA.js +1 -0
- package/dist/worker/console/static/assets/arc-BGiVVe8b.js +1 -0
- package/dist/worker/console/static/assets/architectureDiagram-T3A2C74G-nDdu4rgJ.js +36 -0
- package/dist/worker/console/static/assets/blockDiagram-VBNYF7ZC-Bb5u0BWf.js +132 -0
- package/dist/worker/console/static/assets/c4Diagram-5PPSVZJV-BlhC0j94.js +10 -0
- package/dist/worker/console/static/assets/channel-Tl-FkUqr.js +1 -0
- package/dist/worker/console/static/assets/chunk-2GRJ4B5K-Ai8_qQXI.js +1 -0
- package/dist/worker/console/static/assets/chunk-2Q5K7J3B-B9gyCjqX.js +1 -0
- package/dist/worker/console/static/assets/chunk-5RXB4S5H-Bzbj3zGH.js +231 -0
- package/dist/worker/console/static/assets/chunk-5VM5RSS4-BT415PvT.js +15 -0
- package/dist/worker/console/static/assets/chunk-6Q2QTUOP-D_A5_5QL.js +88 -0
- package/dist/worker/console/static/assets/chunk-GF5L2VYU-srJkaP3f.js +206 -0
- package/dist/worker/console/static/assets/chunk-JWPE2WC7-UYGvEP4l.js +1 -0
- package/dist/worker/console/static/assets/chunk-KBJHAD2P-B8luBrrz.js +1 -0
- package/dist/worker/console/static/assets/chunk-RYQCIY6F-DN7wXZSq.js +1 -0
- package/dist/worker/console/static/assets/chunk-XXDRQBXY-DXKyMuKS.js +1 -0
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-BaehtRk4.js +1 -0
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-BaehtRk4.js +1 -0
- package/dist/worker/console/static/assets/cose-bilkent-JH36ORCC-dqvoynXj.js +1 -0
- package/dist/worker/console/static/assets/cynefin-VYW2F7L2--PcyL34A.js +166 -0
- package/dist/worker/console/static/assets/cynefinDiagram-MW4NZA55-DvWs_hTY.js +62 -0
- package/dist/worker/console/static/assets/cytoscape.esm-yzknjiTM.js +321 -0
- package/dist/worker/console/static/assets/dagre-VZM6K2ZE-DxeIxbyO.js +4 -0
- package/dist/worker/console/static/assets/defaultLocale-DX6XiGOO.js +1 -0
- package/dist/worker/console/static/assets/diagram-7IWD3JNH-DPCG61Of.js +30 -0
- package/dist/worker/console/static/assets/diagram-B4RE2ZJO-CmuU50-U.js +3 -0
- package/dist/worker/console/static/assets/diagram-LBJQPF4R-B61XLD_v.js +24 -0
- package/dist/worker/console/static/assets/diagram-Q27KOJAE-BB7HTRRY.js +24 -0
- package/dist/worker/console/static/assets/diagram-UB23O5K3-DvkboAIp.js +41 -0
- package/dist/worker/console/static/assets/ebnfDiagram-BXEA7PRR-BdJ_y1fL.js +1 -0
- package/dist/worker/console/static/assets/erDiagram-JOGREHBK-9bUBZTRi.js +85 -0
- package/dist/worker/console/static/assets/flowDiagram-UKHOOZJN-Dw4L4RBa.js +156 -0
- package/dist/worker/console/static/assets/ganttDiagram-PKOTCBZU-Jr82N_QP.js +292 -0
- package/dist/worker/console/static/assets/gitGraphDiagram-DS77QQ5N-DAz9wFLr.js +106 -0
- package/dist/worker/console/static/assets/graph-DOmOIIwC.js +1 -0
- package/dist/worker/console/static/assets/index-B7Y-0g3J.css +1 -0
- package/dist/worker/console/static/assets/index-DkCrqaYg.js +325 -0
- package/dist/worker/console/static/assets/infoDiagram-6WML65LV-CBB5Np7y.js +2 -0
- package/dist/worker/console/static/assets/init-Gi6I4Gst.js +1 -0
- package/dist/worker/console/static/assets/ishikawaDiagram-WSZJBQD7-D8IOp94y.js +70 -0
- package/dist/worker/console/static/assets/journeyDiagram-NVQOT4AX-Dgd3AHGG.js +139 -0
- package/dist/worker/console/static/assets/kanban-definition-27J2QSJJ-BmYOxLE9.js +89 -0
- package/dist/worker/console/static/assets/layout-D-LzfAck.js +1 -0
- package/dist/worker/console/static/assets/linear-DfYTEF6J.js +1 -0
- package/dist/worker/console/static/assets/map-DxJ2ADlA.js +1 -0
- package/dist/worker/console/static/assets/mermaid.core-BjuFPRqa.js +308 -0
- package/dist/worker/console/static/assets/mindmap-definition-FAOFIHXS-CLyUViGd.js +96 -0
- package/dist/worker/console/static/assets/ordinal-Cboi1Yqb.js +1 -0
- package/dist/worker/console/static/assets/pegDiagram-VL7TDLO6-BvX2Di4-.js +1 -0
- package/dist/worker/console/static/assets/pieDiagram-7S7Q4E2Y-BFj0_OLv.js +39 -0
- package/dist/worker/console/static/assets/quadrantDiagram-CIZ2JOQS-BIUrD_hx.js +7 -0
- package/dist/worker/console/static/assets/railroadDiagram-AXF67PYL-CHBB48fj.js +1 -0
- package/dist/worker/console/static/assets/requirementDiagram-LRYGKXZP-sJrYw2Sf.js +84 -0
- package/dist/worker/console/static/assets/sankeyDiagram-W5VNT64P-BzHH6fPR.js +40 -0
- package/dist/worker/console/static/assets/sequenceDiagram-SI44F4Z6-7QCnelCt.js +162 -0
- package/dist/worker/console/static/assets/sizeCapture-X5ZJPWSS-sDYSxn72.js +1 -0
- package/dist/worker/console/static/assets/stateDiagram-OKZ733FA-XpiUdwzm.js +1 -0
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-eEhq2A8Y.js +1 -0
- package/dist/worker/console/static/assets/swimlanes-SLNWSIFB-DvqgNPzD.js +2 -0
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-la8AC7fo.js +8 -0
- package/dist/worker/console/static/assets/timeline-definition-Z64GVDOM-2TyOYNx0.js +120 -0
- package/dist/worker/console/static/assets/vennDiagram-T6HMQDX7-B-nM6wM2.js +34 -0
- package/dist/worker/console/static/assets/wardleyDiagram-T6FBY63Y-B86wPdbr.js +78 -0
- package/dist/worker/console/static/assets/xychartDiagram-ELKLHX3M-Dr1C4AQz.js +7 -0
- package/dist/worker/console/static/favicon.svg +37 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_AMS-Regular.woff2 +0 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_Caligraphic-Bold.woff2 +0 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_Caligraphic-Regular.woff2 +0 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_Fraktur-Bold.woff2 +0 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_Fraktur-Regular.woff2 +0 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_Main-Bold.woff2 +0 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_Main-BoldItalic.woff2 +0 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_Main-Italic.woff2 +0 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_Main-Regular.woff2 +0 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_Math-BoldItalic.woff2 +0 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_Math-Italic.woff2 +0 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_SansSerif-Bold.woff2 +0 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_SansSerif-Italic.woff2 +0 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_SansSerif-Regular.woff2 +0 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_Script-Regular.woff2 +0 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_Size1-Regular.woff2 +0 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_Size2-Regular.woff2 +0 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_Size3-Regular.woff2 +0 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_Size4-Regular.woff2 +0 -0
- package/dist/worker/console/static/fonts/katex/KaTeX_Typewriter-Regular.woff2 +0 -0
- package/dist/worker/console/static/index.html +15 -0
- package/dist/worker/console/static-src/app/console-types.js +184 -0
- package/dist/worker/console/static-src/app/useConsoleShell.js +101 -0
- package/dist/worker/console/static-src/app/useOperatorActions.js +324 -0
- package/dist/worker/console/static-src/app/usePrdImport.js +172 -0
- package/dist/worker/console/static-src/app/useRecoveryActions.js +289 -0
- package/dist/worker/console/static-src/app/useRecoveryConsole.js +425 -0
- package/dist/worker/console/static-src/app/useTaskWizard.js +296 -0
- package/dist/worker/console/static-src/chat-markdown-security.js +38 -0
- package/dist/worker/console/static-src/chat-view-types.js +2 -0
- package/dist/worker/console/static-src/night/night-types.js +24 -0
- package/dist/worker/console/static-src/night/useNightBoard.js +94 -0
- package/dist/worker/console/static-src/night/useNightWizard.js +171 -0
- package/dist/worker/console/static-src/night-prepare-result.js +118 -0
- package/dist/worker/console/static-src/operator-chat/activity-journey.js +125 -0
- package/dist/worker/console/static-src/operator-chat/activity-rail-presentation.js +73 -0
- package/dist/worker/console/static-src/operator-chat/activity-references.js +20 -0
- package/dist/worker/console/static-src/operator-chat/chat-sse-events.js +420 -0
- package/dist/worker/console/static-src/operator-chat/format.js +71 -0
- package/dist/worker/console/static-src/operator-chat/landing-density.js +23 -0
- package/dist/worker/console/static-src/operator-chat/mutation-gate.js +45 -0
- package/dist/worker/console/static-src/operator-chat/refs.js +86 -0
- package/dist/worker/console/static-src/operator-chat/resource-auto-invocation.js +91 -0
- package/dist/worker/console/static-src/operator-chat/resource-diagnostics.js +204 -0
- package/dist/worker/console/static-src/operator-chat/runtime-snapshot-store.js +257 -0
- package/dist/worker/console/static-src/operator-chat/session-title-watcher.js +128 -0
- package/dist/worker/console/static-src/operator-chat/sidebar-split.js +90 -0
- package/dist/worker/console/static-src/operator-chat/slash-palette-layout.js +24 -0
- package/dist/worker/console/static-src/operator-chat/slash-palette-nav.js +141 -0
- package/dist/worker/console/static-src/operator-chat/spatial-overlay.js +38 -0
- package/dist/worker/console/static-src/operator-chat/tools-catalog.js +77 -0
- package/dist/worker/console/static-src/operator-chat/turn-stream-controller.js +690 -0
- package/dist/worker/console/static-src/operator-chat/turn-submission.js +158 -0
- package/dist/worker/console/static-src/operator-chat/types.js +1 -0
- package/dist/worker/console/static-src/operator-chat/useActivityRailTransition.js +59 -0
- package/dist/worker/console/static-src/operator-chat/useChatSessions.js +495 -0
- package/dist/worker/console/static-src/operator-chat/useChatStream.js +780 -0
- package/dist/worker/console/static-src/operator-chat/useChatThread.js +280 -0
- package/dist/worker/console/static-src/operator-chat/useComposer.js +257 -0
- package/dist/worker/console/static-src/operator-chat/useInterview.js +108 -0
- package/dist/worker/console/static-src/operator-chat/useOverlayFocus.js +84 -0
- package/dist/worker/console/static-src/operator-chat/useRepoBrowser.js +148 -0
- package/dist/worker/console/static-src/operator-chat/useRuntimeControls.js +358 -0
- package/dist/worker/console/static-src/operator-chat/useRuntimeSnapshot.js +196 -0
- package/dist/worker/console/static-src/operator-chat/useWorkspaceLayout.js +58 -0
- package/dist/worker/console/static-src/operator-chat/workspace-layout-mode.js +35 -0
- package/dist/worker/console/static-src/prd-file-import.js +218 -0
- package/dist/worker/console/vite.config.js +27 -0
- package/dist/worker/console/workflow-kinds.js +46 -0
- package/dist/worker/delivery/final-verification.js +302 -0
- package/dist/worker/delivery/git-transaction.js +497 -0
- package/dist/worker/delivery/package.js +537 -0
- package/dist/worker/delivery/verification-bundle.js +544 -0
- package/dist/worker/feature/acceptance-policy.js +227 -0
- package/dist/worker/feature/advance.js +301 -0
- package/dist/worker/feature/decision-loader.js +99 -0
- package/dist/worker/feature/discover.js +14 -0
- package/dist/worker/feature/doctor.js +223 -0
- package/dist/worker/feature/fullstack-validate.js +337 -0
- package/dist/worker/feature/next-action.js +140 -0
- package/dist/worker/feature/profile-schema.js +47 -0
- package/dist/worker/feature/ready-plan-projection.js +82 -0
- package/dist/worker/feature/reducer.js +137 -0
- package/dist/worker/feature/review.js +678 -0
- package/dist/worker/feature/run.js +390 -0
- package/dist/worker/feature/scaffold.js +812 -0
- package/dist/worker/feature/types.js +1 -0
- package/dist/worker/follow-up/approve.js +273 -0
- package/dist/worker/follow-up/factory.js +234 -0
- package/dist/worker/follow-up/paths.js +25 -0
- package/dist/worker/follow-up/policy.js +26 -0
- package/dist/worker/follow-up/schema.js +93 -0
- package/dist/worker/follow-up/store.js +96 -0
- package/dist/worker/loop-agent/command-result.js +1 -0
- package/dist/worker/loop-agent/controller-protocol.js +143 -0
- package/dist/worker/loop-agent/loop-agent-client.js +489 -0
- package/dist/worker/loop-agent/parse-json.js +14 -0
- package/dist/worker/materialize/harness-task-lifecycle-probe.js +126 -0
- package/dist/worker/materialize/harness-task-lineage.js +220 -0
- package/dist/worker/materialize/harness-task-materializer.js +648 -0
- package/dist/worker/metrics/projector.js +139 -0
- package/dist/worker/observability/dag-execution-trajectory.js +591 -0
- package/dist/worker/observability/event-history.js +216 -0
- package/dist/worker/observability/event-store.js +83 -0
- package/dist/worker/observability/events.js +79 -0
- package/dist/worker/observability/interrupt-eligibility.js +264 -0
- package/dist/worker/observability/progress-composite.js +34 -0
- package/dist/worker/observability/read-model.js +2499 -0
- package/dist/worker/observability/snapshot-store.js +43 -0
- package/dist/worker/observability/types.js +1 -0
- package/dist/worker/observe/dag-node-execution-output.js +180 -0
- package/dist/worker/observe/dag-run-artifacts.js +90 -0
- package/dist/worker/observe/health.js +58 -0
- package/dist/worker/observe/night-jobs.js +104 -0
- package/dist/worker/observe/node-input.js +441 -0
- package/dist/worker/observe/paths.js +174 -0
- package/dist/worker/observe/routes.js +1077 -0
- package/dist/worker/observe/server.js +117 -0
- package/dist/worker/observe/spec-evidence.js +398 -0
- package/dist/worker/observe/static/api.js +117 -0
- package/dist/worker/observe/static/app.js +169 -0
- package/dist/worker/observe/static/constants.js +182 -0
- package/dist/worker/observe/static/copy.js +67 -0
- package/dist/worker/observe/static/custom-select.js +567 -0
- package/dist/worker/observe/static/dag-edge-routing.js +368 -0
- package/dist/worker/observe/static/dag-helpers.js +161 -0
- package/dist/worker/observe/static/dag-history-labels.js +95 -0
- package/dist/worker/observe/static/dag-layout.d.ts +36 -0
- package/dist/worker/observe/static/dag-layout.js +163 -0
- package/dist/worker/observe/static/dag-model.js +145 -0
- package/dist/worker/observe/static/dom.js +220 -0
- package/dist/worker/observe/static/favicon.svg +37 -0
- package/dist/worker/observe/static/format-pool.d.ts +71 -0
- package/dist/worker/observe/static/format-pool.js +153 -0
- package/dist/worker/observe/static/format.js +347 -0
- package/dist/worker/observe/static/index.html +409 -0
- package/dist/worker/observe/static/kpi.js +78 -0
- package/dist/worker/observe/static/markdown-render.js +124 -0
- package/dist/worker/observe/static/operator-chrome.css +517 -0
- package/dist/worker/observe/static/operator-chrome.d.ts +83 -0
- package/dist/worker/observe/static/operator-chrome.js +623 -0
- package/dist/worker/observe/static/relations.js +133 -0
- package/dist/worker/observe/static/router.js +156 -0
- package/dist/worker/observe/static/run-processing.js +148 -0
- package/dist/worker/observe/static/shell-chrome.js +65 -0
- package/dist/worker/observe/static/state.js +496 -0
- package/dist/worker/observe/static/styles.css +3567 -0
- package/dist/worker/observe/static/views/batch.js +227 -0
- package/dist/worker/observe/static/views/dag-graph.js +508 -0
- package/dist/worker/observe/static/views/dag-inspector.js +1722 -0
- package/dist/worker/observe/static/views/dag-trajectory.js +313 -0
- package/dist/worker/observe/static/views/dag.js +483 -0
- package/dist/worker/observe/static/views/dags.js +877 -0
- package/dist/worker/observe/static/views/dashboard.js +747 -0
- package/dist/worker/observe/static/views/failures.js +143 -0
- package/dist/worker/observe/static/views/feature.js +492 -0
- package/dist/worker/observe/static/views/night.js +201 -0
- package/dist/worker/observe/static/views/pool.js +708 -0
- package/dist/worker/observe/static/views/run.js +453 -0
- package/dist/worker/observe/static/views/session-timeline.js +771 -0
- package/dist/worker/observe/static/views/shell.js +7 -0
- package/dist/worker/observe/static/views/task.js +315 -0
- package/dist/worker/observe/static/views/timeline.js +163 -0
- package/dist/worker/outcomes/adapters.js +153 -0
- package/dist/worker/outcomes/declared-artifacts.js +103 -0
- package/dist/worker/outcomes/evidence-tokens.js +29 -0
- package/dist/worker/outcomes/gate.js +40 -0
- package/dist/worker/outcomes/projector.js +227 -0
- package/dist/worker/outcomes/registry.js +1 -0
- package/dist/worker/outcomes/store.js +131 -0
- package/dist/worker/outcomes/types.js +79 -0
- package/dist/worker/pool/attempt-identity.js +41 -0
- package/dist/worker/pool/attempt-lease.js +184 -0
- package/dist/worker/pool/attempt-transition.js +210 -0
- package/dist/worker/pool/begin-attempt-with-lease.js +26 -0
- package/dist/worker/pool/begin-attempt.js +35 -0
- package/dist/worker/pool/doctor.js +165 -0
- package/dist/worker/pool/failure-routing.js +182 -0
- package/dist/worker/pool/migrate-state.js +303 -0
- package/dist/worker/pool/reconcile.js +285 -0
- package/dist/worker/pool/recovery-decision.js +163 -0
- package/dist/worker/pool/run-owner-store.js +126 -0
- package/dist/worker/pool/run-store.js +360 -0
- package/dist/worker/pool/runtime-reconcile-inventory.js +127 -0
- package/dist/worker/pool/state-projection.js +57 -0
- package/dist/worker/pool/types.js +17 -0
- package/dist/worker/pool/validation.js +144 -0
- package/dist/worker/preflight.js +157 -0
- package/dist/worker/profile-mapping.js +76 -0
- package/dist/worker/progress-reporter.js +63 -0
- package/dist/worker/report/morning-report.js +155 -0
- package/dist/worker/repos/repo-resolver.js +23 -0
- package/dist/worker/run-task/execute-prepared-task.js +178 -0
- package/dist/worker/run-task/run-task.js +912 -0
- package/dist/worker/runner/run-ready.js +561 -0
- package/dist/worker/runner/single-task-attempt.js +176 -0
- package/dist/worker/scheduler/admission.js +547 -0
- package/dist/worker/scheduler/auto-followup.js +99 -0
- package/dist/worker/scheduler/cli.js +644 -0
- package/dist/worker/scheduler/clock-install/darwin-launchd.js +238 -0
- package/dist/worker/scheduler/clock-install/linux-systemd-user.js +224 -0
- package/dist/worker/scheduler/clock-install/types.js +1 -0
- package/dist/worker/scheduler/clock-install/win32-schtasks.js +227 -0
- package/dist/worker/scheduler/clock-install.js +284 -0
- package/dist/worker/scheduler/clock.js +420 -0
- package/dist/worker/scheduler/dispatcher.js +503 -0
- package/dist/worker/scheduler/doctor.js +431 -0
- package/dist/worker/scheduler/evidence.js +170 -0
- package/dist/worker/scheduler/git-base.js +90 -0
- package/dist/worker/scheduler/index.js +25 -0
- package/dist/worker/scheduler/lease.js +114 -0
- package/dist/worker/scheduler/lifecycle.js +348 -0
- package/dist/worker/scheduler/lock.js +80 -0
- package/dist/worker/scheduler/morning-window.js +191 -0
- package/dist/worker/scheduler/night-git-finalizer.js +114 -0
- package/dist/worker/scheduler/night-harvest.js +412 -0
- package/dist/worker/scheduler/paths.js +92 -0
- package/dist/worker/scheduler/prepared-attempt-recovery.js +471 -0
- package/dist/worker/scheduler/recovery.js +277 -0
- package/dist/worker/scheduler/reservation.js +146 -0
- package/dist/worker/scheduler/retry.js +199 -0
- package/dist/worker/scheduler/scheduler-loop.js +272 -0
- package/dist/worker/scheduler/store.js +275 -0
- package/dist/worker/scheduler/traceability.js +54 -0
- package/dist/worker/scheduler/trigger.js +258 -0
- package/dist/worker/scheduler/types.js +369 -0
- package/dist/worker/scheduler/workspace-adapter.js +128 -0
- package/dist/worker/task-graph/acceptance-schema.js +40 -0
- package/dist/worker/task-graph/ready-planner.js +267 -0
- package/dist/worker/task-graph/ready-queue.js +23 -0
- package/dist/worker/task-graph/task-graph-schema.js +59 -0
- package/dist/worker/task-graph/types.js +1 -0
- package/dist/worker/task-graph/validate.js +293 -0
- package/dist/worker/task-spec/complexity-mapping.js +8 -0
- package/dist/worker/task-spec/schema.js +125 -0
- package/dist/worker/task-spec/types.js +1 -0
- package/dist/worker/task-spec/validate.js +391 -0
- package/dist/worker/task-spec/workflow-routing.js +149 -0
- package/dist/workflows/dag/authoring.js +8 -0
- package/dist/workflows/dag/authority-surface.js +138 -0
- package/dist/workflows/dag/backend-test-analysis-contract.js +507 -0
- package/dist/workflows/dag/backend-test-case-coverage-analysis.js +1985 -0
- package/dist/workflows/dag/backend-test-case-manifest.js +638 -0
- package/dist/workflows/dag/backend-test-classification-contract.js +38 -0
- package/dist/workflows/dag/backend-test-contract-envelope.js +205 -0
- package/dist/workflows/dag/backend-test-coverage-contract.js +202 -0
- package/dist/workflows/dag/backend-test-execution-contract.js +715 -0
- package/dist/workflows/dag/backend-test-gap-fill.js +205 -0
- package/dist/workflows/dag/backend-test-intake-context.js +178 -0
- package/dist/workflows/dag/backend-test-layout.js +133 -0
- package/dist/workflows/dag/backend-test-markdown-workflow.js +1984 -0
- package/dist/workflows/dag/backend-test-module-stem.js +26 -0
- package/dist/workflows/dag/backend-test-pytest-collection.js +859 -0
- package/dist/workflows/dag/backend-test-result-contract.js +1030 -0
- package/dist/workflows/dag/backend-test-scenario-param.js +1670 -0
- package/dist/workflows/dag/backend-test-scenario-partitions.js +249 -0
- package/dist/workflows/dag/backend-test-semantic-review-contract.js +36 -0
- package/dist/workflows/dag/backend-test-stability-contract.js +57 -0
- package/dist/workflows/dag/backend-test-writer-completeness.js +1058 -0
- package/dist/workflows/dag/budget-enforcement.js +67 -0
- package/dist/workflows/dag/canvas-observer.js +474 -0
- package/dist/workflows/dag/context-policy.js +137 -0
- package/dist/workflows/dag/contract-output-registry.js +14 -0
- package/dist/workflows/dag/contract-validator-registrations.js +10 -0
- package/dist/workflows/dag/controller-identity.js +104 -0
- package/dist/workflows/dag/convergence/controller.js +596 -0
- package/dist/workflows/dag/decision-envelope.js +557 -0
- package/dist/workflows/dag/decision-evidence.js +153 -0
- package/dist/workflows/dag/decision-gates.js +1 -0
- package/dist/workflows/dag/dynamic-runtime/condition.js +48 -0
- package/dist/workflows/dag/dynamic-runtime/loop-until.js +161 -0
- package/dist/workflows/dag/dynamic-runtime/map.js +435 -0
- package/dist/workflows/dag/dynamic-runtime/reduction.js +72 -0
- package/dist/workflows/dag/dynamic-runtime/shared.js +203 -0
- package/dist/workflows/dag/event-observer.js +132 -0
- package/dist/workflows/dag/executor-registry.js +23 -0
- package/dist/workflows/dag/facts.js +4 -0
- package/dist/workflows/dag/failure-category.js +118 -0
- package/dist/workflows/dag/failure-routing.js +105 -0
- package/dist/workflows/dag/final-verification.js +180 -0
- package/dist/workflows/dag/frontend-implementation-contract.js +1911 -0
- package/dist/workflows/dag/frontend-lint-baseline.js +474 -0
- package/dist/workflows/dag/frontend-plan-render.js +90 -0
- package/dist/workflows/dag/frontend-prewrite-gate.js +1011 -0
- package/dist/workflows/dag/frontend-project-capability.js +1 -0
- package/dist/workflows/dag/frontend-recovery-plan.js +73 -0
- package/dist/workflows/dag/frontend-recovery-root-manifest.js +123 -0
- package/dist/workflows/dag/frontend-recovery-run.js +539 -0
- package/dist/workflows/dag/frontend-repair.js +541 -0
- package/dist/workflows/dag/frontend-review-context.js +116 -0
- package/dist/workflows/dag/frontend-risk.js +161 -0
- package/dist/workflows/dag/frontend-test-case-checklist.js +343 -0
- package/dist/workflows/dag/frontend-test-case-manifest.js +104 -0
- package/dist/workflows/dag/frontend-test-case-quality.js +105 -0
- package/dist/workflows/dag/frontend-test-html-report.js +174 -0
- package/dist/workflows/dag/frontend-test-l5-report.js +177 -0
- package/dist/workflows/dag/frontend-test-result-contract.js +487 -0
- package/dist/workflows/dag/frontend-verification-trace.js +275 -0
- package/dist/workflows/dag/frontend-worktree-diff.js +201 -0
- package/dist/workflows/dag/frontend-writer-recovery.js +106 -0
- package/dist/workflows/dag/frontend-writer-rollback.js +821 -0
- package/dist/workflows/dag/governance-constants.js +5 -0
- package/dist/workflows/dag/governance-profile.js +413 -0
- package/dist/workflows/dag/index.js +6 -0
- package/dist/workflows/dag/init-hybrid.js +7345 -0
- package/dist/workflows/dag/interrupt-request.js +559 -0
- package/dist/workflows/dag/knowledge-curator.js +165 -0
- package/dist/workflows/dag/l5-report-metrics.js +33 -0
- package/dist/workflows/dag/lifecycle.js +855 -0
- package/dist/workflows/dag/liveness-policy.js +251 -0
- package/dist/workflows/dag/node-execution.js +1081 -0
- package/dist/workflows/dag/observer-compose.js +52 -0
- package/dist/workflows/dag/output-protocol.js +356 -0
- package/dist/workflows/dag/project-governance-context.js +514 -0
- package/dist/workflows/dag/prompt-source.js +88 -0
- package/dist/workflows/dag/prompt.js +348 -0
- package/dist/workflows/dag/reconcile-run.js +145 -0
- package/dist/workflows/dag/reconcile-tasks.js +404 -0
- package/dist/workflows/dag/recovery-recommendation.js +329 -0
- package/dist/workflows/dag/repair-artifact.js +363 -0
- package/dist/workflows/dag/report.js +1229 -0
- package/dist/workflows/dag/rerun-plan.js +614 -0
- package/dist/workflows/dag/rerun-run.js +556 -0
- package/dist/workflows/dag/rerun-task.js +370 -0
- package/dist/workflows/dag/retry-policy.js +263 -0
- package/dist/workflows/dag/run-store.js +41 -0
- package/dist/workflows/dag/runner.js +1069 -0
- package/dist/workflows/dag/runtime-contract.js +87 -0
- package/dist/workflows/dag/runtime.js +5 -0
- package/dist/workflows/dag/scheduler.js +497 -0
- package/dist/workflows/dag/sdd-embedded.js +128 -0
- package/dist/workflows/dag/skill-instructions.js +478 -0
- package/dist/workflows/dag/skill-snapshot.js +553 -0
- package/dist/workflows/dag/skills.js +41 -0
- package/dist/workflows/dag/spec.js +3 -0
- package/dist/workflows/dag/task-contract-binding.js +138 -0
- package/dist/workflows/dag/task-demand-routing.js +1 -0
- package/dist/workflows/dag/topo.js +30 -0
- package/dist/workflows/dag/types.js +1145 -0
- package/dist/workflows/dag/upstream-artifacts.js +98 -0
- package/dist/workflows/dag/validate.js +998 -0
- package/dist/workflows/dag/workspace-checkpoint.js +186 -0
- package/dist/workflows/dynamic/artifacts.js +65 -0
- package/dist/workflows/dynamic/compile.js +371 -0
- package/dist/workflows/dynamic/compileTypes.js +1 -0
- package/dist/workflows/dynamic/errors.js +5 -0
- package/dist/workflows/dynamic/index.js +7 -0
- package/dist/workflows/dynamic/profiles.js +156 -0
- package/dist/workflows/dynamic/spec.js +115 -0
- package/dist/workflows/dynamic/validate.js +275 -0
- package/dist/workflows/loop/actions/dag-action.js +129 -0
- package/dist/workflows/loop/actions/pi-review.js +267 -0
- package/dist/workflows/loop/actions/shared.js +157 -0
- package/dist/workflows/loop/actions/shell-verify.js +82 -0
- package/dist/workflows/loop/actions/types.js +1 -0
- package/dist/workflows/loop/actions/workflow-action.js +255 -0
- package/dist/workflows/loop/actions.js +160 -0
- package/dist/workflows/loop/benchmark.js +510 -0
- package/dist/workflows/loop/closeout.js +135 -0
- package/dist/workflows/loop/context.js +47 -0
- package/dist/workflows/loop/events.js +26 -0
- package/dist/workflows/loop/hash.js +32 -0
- package/dist/workflows/loop/index.js +8 -0
- package/dist/workflows/loop/paths.js +17 -0
- package/dist/workflows/loop/policy/auto-policy.js +112 -0
- package/dist/workflows/loop/policy/path-patterns.js +13 -0
- package/dist/workflows/loop/rounds.js +81 -0
- package/dist/workflows/loop/signals.js +52 -0
- package/dist/workflows/loop/state.js +116 -0
- package/dist/workflows/loop/templates.js +54 -0
- package/dist/workflows/loop/types.js +28 -0
- package/docs/README.md +82 -0
- package/docs/architecture/README.md +35 -0
- package/docs/architecture/dag-execution.md +165 -0
- package/docs/architecture/evolution.md +108 -0
- package/docs/architecture/facts-and-state.md +74 -0
- package/docs/architecture/runtime-boundaries.md +226 -0
- package/docs/architecture/system-overview.md +100 -0
- package/docs/architecture/worker-and-feature.md +122 -0
- package/docs/governance/README.md +18 -0
- package/docs/governance/harness-methodology-debugging.md +177 -0
- package/docs/governance/harness-methodology-tdd.md +130 -0
- package/docs/governance/harness-methodology-verification.md +27 -0
- package/docs/init-surface.manifest.json +358 -0
- package/docs/operations/README.md +15 -0
- package/docs/operations/local-development-environment.md +77 -0
- package/docs/skills/README.md +7 -0
- package/docs/skills/vetted-skill-registry.md +49 -0
- package/docs/templates/README.md +67 -0
- package/docs/templates/adr.md +60 -0
- package/docs/templates/agent-dag-authority-surface-audit.prompt.md +94 -0
- package/docs/templates/agent-dag-decision-envelope.schema.json +213 -0
- package/docs/templates/agent-dag-decision-gate-dogfood-report.md +117 -0
- package/docs/templates/agent-dag-decision-gate.prompt.md +246 -0
- package/docs/templates/agent-dag-process-supervisor.prompt.md +98 -0
- package/docs/templates/agent-dag-report.schema.json +473 -0
- package/docs/templates/agent-dag-review-verdict.prompt.md +68 -0
- package/docs/templates/agent-dag.base.json +190 -0
- package/docs/templates/agent-dag.final-verification.json +185 -0
- package/docs/templates/agent-dag.schema.json +590 -0
- package/docs/templates/agent-dag.supervised-implementation.json +640 -0
- package/docs/templates/agent-worker-production-readiness-checklist.md +47 -0
- package/docs/templates/backend-test-analysis.schema.json +37 -0
- package/docs/templates/backend-test-case-manifest.schema.json +223 -0
- package/docs/templates/backend-test-dag.classify.prompt.md +75 -0
- package/docs/templates/backend-test-dag.generate-pytest.prompt.md +41 -0
- package/docs/templates/backend-test-dag.json +671 -0
- package/docs/templates/backend-test-dag.retrospect.prompt.md +165 -0
- package/docs/templates/backend-test-dag.review-cases.prompt.md +36 -0
- package/docs/templates/backend-test-execution.schema.json +138 -0
- package/docs/templates/backend-test-result.schema.json +99 -0
- package/docs/templates/branch-merge-report.md +115 -0
- package/docs/templates/evaluation/agents-map-slim-v1.candidate.json +9 -0
- package/docs/templates/evaluation/agents-map-slim-v1.md +87 -0
- package/docs/templates/evaluation/agents-map-verbose-v0.candidate.json +9 -0
- package/docs/templates/evaluation/agents-map-verbose-v0.md +153 -0
- package/docs/templates/evaluation/campaign-budget-v1.json +12 -0
- package/docs/templates/evaluation/campaign-dogfood-v0.json +24 -0
- package/docs/templates/evaluation/campaign-evidence-v1.json +44 -0
- package/docs/templates/evaluation/context-policy-baseline-v1.json +17 -0
- package/docs/templates/evaluation/context-policy-role-specialized-v1.json +28 -0
- package/docs/templates/evaluation/corpus-dogfood-v0.manifest.json +118 -0
- package/docs/templates/evaluation/matrix-dag-dry-run-v1.json +21 -0
- package/docs/templates/evaluation/matrix-fixture-v1.json +10 -0
- package/docs/templates/evaluation/private-verifier-dogfood-v0.json +16 -0
- package/docs/templates/exec-plan.md +66 -0
- package/docs/templates/feature-spec.md +53 -0
- package/docs/templates/frontend-design-contract.md +68 -0
- package/docs/templates/frontend-eval/fixtures/failures/01-type-build-error.md +17 -0
- package/docs/templates/frontend-eval/fixtures/failures/02-unit-component-test-fail.md +16 -0
- package/docs/templates/frontend-eval/fixtures/failures/03-fixture-schema-drift.md +16 -0
- package/docs/templates/frontend-eval/fixtures/failures/04-missing-loading-empty-error-state.md +16 -0
- package/docs/templates/frontend-eval/fixtures/failures/05-forbidden-write-writeset-expansion.md +16 -0
- package/docs/templates/frontend-eval/fixtures/failures/06-unapproved-dependency-add.md +16 -0
- package/docs/templates/frontend-eval/fixtures/failures/07-mock-production-on.md +21 -0
- package/docs/templates/frontend-eval/fixtures/functional/01-simple-component-style.md +29 -0
- package/docs/templates/frontend-eval/fixtures/functional/02-form-validation.md +28 -0
- package/docs/templates/frontend-eval/fixtures/functional/03-list-detail-page.md +28 -0
- package/docs/templates/frontend-eval/fixtures/functional/04-api-mock.md +29 -0
- package/docs/templates/frontend-eval/fixtures/functional/05-permission-auth-gated-ui.md +27 -0
- package/docs/templates/frontend-eval/fixtures/functional/06-ssr-server-client-boundary.md +28 -0
- package/docs/templates/frontend-eval/fixtures/functional/07-shared-public-component-api.md +28 -0
- package/docs/templates/frontend-eval/fixtures/functional/08-pure-local-no-remote.md +27 -0
- package/docs/templates/frontend-eval/metrics.md +138 -0
- package/docs/templates/frontend-eval/smoke-targets.md +53 -0
- package/docs/templates/frontend-implementation-contract.schema.json +35 -0
- package/docs/templates/frontend-task-constraints.md +62 -0
- package/docs/templates/frontend-task-requirement.md +104 -0
- package/docs/templates/frontend-test-case-checklist.md +44 -0
- package/docs/templates/frontend-test-case.example.md +143 -0
- package/docs/templates/frontend-test-dag.generate-cases.prompt.md +63 -0
- package/docs/templates/frontend-test-dag.json +409 -0
- package/docs/templates/frontend-test-dag.retrieve-context.prompt.md +21 -0
- package/docs/templates/frontend-test-dag.retrospect.prompt.md +5 -0
- package/docs/templates/frontend-test-dag.review-cases.prompt.md +5 -0
- package/docs/templates/frontend-test-dag.review-execution.prompt.md +3 -0
- package/docs/templates/frontend-test-standard-scenarios.v1.json +159 -0
- package/docs/templates/harness.schema.json +351 -0
- package/docs/templates/hybrid-dag.json +188 -0
- package/docs/templates/init-evolution-review.md +35 -0
- package/docs/templates/init-managed-agents.md +157 -0
- package/docs/templates/interactive-ui-round2-experiment.md +66 -0
- package/docs/templates/knowledge-graph-bootstrap-dag.json +118 -0
- package/docs/templates/knowledge-sync-dag.json +178 -0
- package/docs/templates/knowledge-sync-draft.schema.json +71 -0
- package/docs/templates/product-line/AGENTS.md +9 -0
- package/docs/templates/product-line/README.md +42 -0
- package/docs/templates/product-line/acceptance.yaml +23 -0
- package/docs/templates/product-line/closeout.yaml +9 -0
- package/docs/templates/product-line/design.md +13 -0
- package/docs/templates/product-line/feature-scaffold-batch.example.yaml +31 -0
- package/docs/templates/product-line/feature.yaml +11 -0
- package/docs/templates/product-line/links.md +10 -0
- package/docs/templates/product-line/requirement.md +17 -0
- package/docs/templates/product-line/scaffold-samples/README.md +36 -0
- package/docs/templates/product-line/scaffold-samples/backend-only/acceptance.yaml +16 -0
- package/docs/templates/product-line/scaffold-samples/backend-only/design.md +14 -0
- package/docs/templates/product-line/scaffold-samples/backend-only/feature.yaml +14 -0
- package/docs/templates/product-line/scaffold-samples/backend-only/requirement.md +6 -0
- package/docs/templates/product-line/scaffold-samples/backend-only/tasks/BE-IMPL-001.yaml +83 -0
- package/docs/templates/product-line/scaffold-samples/backend-only/tasks/task-graph.yaml +14 -0
- package/docs/templates/product-line/scaffold-samples/fe-with-api/acceptance.yaml +18 -0
- package/docs/templates/product-line/scaffold-samples/fe-with-api/design.md +18 -0
- package/docs/templates/product-line/scaffold-samples/fe-with-api/feature.yaml +14 -0
- package/docs/templates/product-line/scaffold-samples/fe-with-api/requirement.md +6 -0
- package/docs/templates/product-line/scaffold-samples/fe-with-api/tasks/BE-IMPL-001.yaml +84 -0
- package/docs/templates/product-line/scaffold-samples/fe-with-api/tasks/CONTRACT-001.yaml +84 -0
- package/docs/templates/product-line/scaffold-samples/fe-with-api/tasks/FE-IMPL-001.yaml +86 -0
- package/docs/templates/product-line/scaffold-samples/fe-with-api/tasks/task-graph.yaml +40 -0
- package/docs/templates/product-line/scaffold-samples/frontend-only/acceptance.yaml +16 -0
- package/docs/templates/product-line/scaffold-samples/frontend-only/design.md +14 -0
- package/docs/templates/product-line/scaffold-samples/frontend-only/feature.yaml +14 -0
- package/docs/templates/product-line/scaffold-samples/frontend-only/requirement.md +6 -0
- package/docs/templates/product-line/scaffold-samples/frontend-only/tasks/FE-IMPL-001.yaml +85 -0
- package/docs/templates/product-line/scaffold-samples/frontend-only/tasks/task-graph.yaml +14 -0
- package/docs/templates/product-line/task-graph.yaml +23 -0
- package/docs/templates/product-line/task.yaml +68 -0
- package/docs/templates/product-line/test-plan.md +7 -0
- package/docs/templates/production-readiness-checklist.md +57 -0
- package/docs/templates/progress-log.md +27 -0
- package/docs/templates/project-start-checklist.md +9 -0
- package/docs/templates/qa-report.md +48 -0
- package/docs/templates/sprint-contract.md +29 -0
- package/docs/templates/worker-dogfood-evidence.md +80 -0
- package/docs/templates/worker-dogfood-setup.md +68 -0
- package/examples/decision-gate-agent-dag.json +177 -0
- package/examples/example-dag.json +46 -0
- package/examples/hybrid-loop-agent-dag.json +189 -0
- package/examples/l5-report-coms-process-definition.html +322 -0
- package/examples/l5-report-demo.html +79 -0
- package/harness.json +90 -0
- package/package.json +98 -0
- package/scripts/kb-bootstrap-init-skeleton.sh +241 -0
- package/scripts/kb-graph-incremental-prepare.mjs +386 -0
- package/scripts/kb-graph-materialize.mjs +105 -0
- package/scripts/kb-graph-promote.mjs +164 -0
- package/scripts/kb-query.mjs +554 -0
- package/skills/agent-worker/SKILL.md +48 -0
- package/skills/agent-worker/references/agent-worker-operator.md +159 -0
- package/skills/ai-engineering-context/SKILL.md +48 -0
- package/skills/analyze-product-dependencies/SKILL.md +108 -0
- package/skills/analyze-product-dependencies/references/api-documentation-schema.md +35 -0
- package/skills/analyze-product-dependencies/references/dependency-analysis-schema.md +38 -0
- package/skills/analyze-product-dependencies/references/example.md +76 -0
- package/skills/analyze-product-dependencies/references/forward-test-cases.md +110 -0
- package/skills/analyze-product-dependencies/references/input-contract.md +34 -0
- package/skills/analyze-product-dependencies/references/kb-integration.md +64 -0
- package/skills/analyze-product-dependencies/references/scouting-rules.md +76 -0
- package/skills/analyze-product-dependencies/scripts/test-validators.mjs +460 -0
- package/skills/analyze-product-dependencies/scripts/validate-api-documentation.mjs +194 -0
- package/skills/analyze-product-dependencies/scripts/validate-dependency-analysis.mjs +200 -0
- package/skills/analyze-product-dependencies/scripts/validate-product-requirement-input.mjs +90 -0
- package/skills/analyze-product-dependencies/scripts/validation-helpers.mjs +138 -0
- package/skills/analyze-product-requirements/SKILL.md +145 -0
- package/skills/analyze-product-requirements/references/acceptance-criteria.md +87 -0
- package/skills/analyze-product-requirements/references/clarification-and-knowledge.md +70 -0
- package/skills/analyze-product-requirements/references/example.md +104 -0
- package/skills/analyze-product-requirements/references/forward-test-cases.md +144 -0
- package/skills/analyze-product-requirements/references/kb-integration.md +56 -0
- package/skills/analyze-product-requirements/references/product-analysis-schema.md +41 -0
- package/skills/analyze-product-requirements/references/product-requirement-schema.md +42 -0
- package/skills/analyze-product-requirements/references/requirement-clarification-schema.md +66 -0
- package/skills/analyze-product-requirements/scripts/compute-source-identity.mjs +35 -0
- package/skills/analyze-product-requirements/scripts/test-validators.mjs +501 -0
- package/skills/analyze-product-requirements/scripts/validate-product-analysis.mjs +100 -0
- package/skills/analyze-product-requirements/scripts/validate-product-requirement.mjs +109 -0
- package/skills/analyze-product-requirements/scripts/validate-requirement-clarification.mjs +109 -0
- package/skills/analyze-product-requirements/scripts/validation-helpers.mjs +175 -0
- package/skills/browser-tools/SKILL.md +196 -0
- package/skills/browser-tools/browser-content.js +103 -0
- package/skills/browser-tools/browser-cookies.js +35 -0
- package/skills/browser-tools/browser-eval.js +53 -0
- package/skills/browser-tools/browser-hn-scraper.js +108 -0
- package/skills/browser-tools/browser-nav.js +44 -0
- package/skills/browser-tools/browser-pick.js +162 -0
- package/skills/browser-tools/browser-screenshot.js +34 -0
- package/skills/browser-tools/browser-start.js +86 -0
- package/skills/browser-tools/package-lock.json +2556 -0
- package/skills/browser-tools/package.json +19 -0
- package/skills/code-review-core/SKILL.md +20 -0
- package/skills/codebase-scout/SKILL.md +19 -0
- package/skills/frontend-bounded-implement/SKILL.md +53 -0
- package/skills/frontend-design-review/SKILL.md +79 -0
- package/skills/frontend-design-review/references/review-checklist.md +43 -0
- package/skills/frontend-implementation/SKILL.md +52 -0
- package/skills/frontend-implementation/references/code-standards.md +33 -0
- package/skills/frontend-implementation/references/design-spec.md +56 -0
- package/skills/frontend-implementation/references/node-contracts.md +31 -0
- package/skills/frontend-review/SKILL.md +55 -0
- package/skills/frontend-review/references/review-findings.md +50 -0
- package/skills/frontend-verification/SKILL.md +61 -0
- package/skills/frontend-verification/references/verification-checklist.md +48 -0
- package/skills/grill-me/SKILL.md +10 -0
- package/skills/grill-with-docs/SKILL.md +80 -0
- package/skills/grill-with-docs/adr-format.md +58 -0
- package/skills/grill-with-docs/context-format.md +52 -0
- package/skills/init-capability-evolution/SKILL.md +70 -0
- package/skills/local-jacoco-coverage/SKILL.md +281 -0
- package/skills/local-jacoco-coverage/references/requirement-to-source-mapping.md +85 -0
- package/skills/local-jacoco-coverage/references/runtime-alignment.md +106 -0
- package/skills/local-jacoco-coverage/scripts/run-coverage-analysis.sh +148 -0
- package/skills/local-jacoco-coverage/scripts/start-jacoco-agent.sh +110 -0
- package/skills/loop-agent/SKILL.md +68 -0
- package/skills/loop-agent/references/README.md +67 -0
- package/skills/loop-agent/references/command-reference.md +645 -0
- package/skills/loop-agent/references/docs-converge.md +126 -0
- package/skills/loop-agent/references/harness-policy.md +289 -0
- package/skills/loop-agent/references/hybrid-dag.md +245 -0
- package/skills/loop-agent/references/learned/README.md +21 -0
- package/skills/loop-agent/references/long-running-loop.md +57 -0
- package/skills/loop-agent/references/model-routing.md +45 -0
- package/skills/loop-agent/references/multi-worktree.md +54 -0
- package/skills/loop-agent/references/one-shot-runs.md +84 -0
- package/skills/loop-agent/references/orchestrator-and-interventions.md +175 -0
- package/skills/loop-agent/references/pi-prompt.md +23 -0
- package/skills/loop-agent/references/pi-subagent-assisted-mode.md +84 -0
- package/skills/loop-agent/references/post-implementation-and-patterns.md +54 -0
- package/skills/loop-agent/references/source-and-plan-practice.md +169 -0
- package/skills/loop-agent/references/task-workflow.md +104 -0
- package/skills/loop-agent/references/verification-and-failure-handling.md +148 -0
- package/skills/playwright-cli/SKILL.md +93 -0
- package/skills/playwright-cli/references/element-attributes.md +23 -0
- package/skills/playwright-cli/references/playwright-tests.md +39 -0
- package/skills/playwright-cli/references/request-mocking.md +87 -0
- package/skills/playwright-cli/references/running-code.md +241 -0
- package/skills/playwright-cli/references/session-management.md +225 -0
- package/skills/playwright-cli/references/storage-state.md +275 -0
- package/skills/playwright-cli/references/test-generation.md +433 -0
- package/skills/playwright-cli/references/tracing.md +5 -0
- package/skills/playwright-cli/references/video-recording.md +5 -0
- package/skills/playwright-cli-case-generator/SKILL.md +108 -0
- package/skills/requesting-code-review/SKILL.md +101 -0
- package/skills/requesting-code-review/code-reviewer.md +168 -0
- package/skills/systematic-debugging/CREATION-LOG.md +119 -0
- package/skills/systematic-debugging/SKILL.md +312 -0
- package/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
- package/skills/systematic-debugging/condition-based-waiting.md +115 -0
- package/skills/systematic-debugging/defense-in-depth.md +122 -0
- package/skills/systematic-debugging/find-polluter.sh +63 -0
- package/skills/systematic-debugging/root-cause-tracing.md +169 -0
- package/skills/systematic-debugging/test-academic.md +14 -0
- package/skills/systematic-debugging/test-pressure-1.md +58 -0
- package/skills/systematic-debugging/test-pressure-2.md +68 -0
- package/skills/systematic-debugging/test-pressure-3.md +69 -0
- package/skills/test-driven-development/SKILL.md +27 -0
- package/skills/using-git-worktrees/SKILL.md +215 -0
- package/skills/verification-before-completion/SKILL.md +154 -0
- package/skills/webapp-testing/SKILL.md +19 -0
|
@@ -0,0 +1,1670 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { spawnSync } from "node:child_process";
|
|
3
|
+
import { access, mkdir, readFile, readdir, writeFile } from "node:fs/promises";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import { expectedBackendTestPytestScriptForMarkdownModule, } from "./backend-test-markdown-workflow.js";
|
|
7
|
+
import { resolveBackendTestLayout, } from "./backend-test-layout.js";
|
|
8
|
+
export const BACKEND_TEST_SCENARIO_PARAM_FACTS_SCHEMA_ID = "backend-test-scenario-param-consistency-facts-v1";
|
|
9
|
+
const factsSchema = z
|
|
10
|
+
.object({
|
|
11
|
+
schemaId: z.literal(BACKEND_TEST_SCENARIO_PARAM_FACTS_SCHEMA_ID),
|
|
12
|
+
phase: z.enum(["initial", "final"]),
|
|
13
|
+
overallStatus: z.enum(["PASS", "PARTIAL", "FAIL", "UNAVAILABLE"]),
|
|
14
|
+
repairEligible: z.boolean(),
|
|
15
|
+
repairAttempt: z.number().int().min(0).max(1),
|
|
16
|
+
strictScenarioParamGate: z.boolean(),
|
|
17
|
+
entries: z.array(z
|
|
18
|
+
.object({
|
|
19
|
+
caseId: z.string(),
|
|
20
|
+
tpId: z.string(),
|
|
21
|
+
field: z.string().optional(),
|
|
22
|
+
intent: z.string(),
|
|
23
|
+
observed: z.string(),
|
|
24
|
+
status: z.enum(["MATCH", "MISMATCH", "UNDETERMINED"]),
|
|
25
|
+
repairability: z.enum([
|
|
26
|
+
"repairable",
|
|
27
|
+
"blocked",
|
|
28
|
+
"none",
|
|
29
|
+
"undetermined-no-repair",
|
|
30
|
+
]),
|
|
31
|
+
suggestedFix: z.string().optional(),
|
|
32
|
+
scriptPath: z.string().optional(),
|
|
33
|
+
bound: z.number().optional(),
|
|
34
|
+
example: z.string().optional(),
|
|
35
|
+
})
|
|
36
|
+
.strict()),
|
|
37
|
+
assetHashes: z.array(z.object({ path: z.string(), sha256: z.string() }).strict()),
|
|
38
|
+
summary: z
|
|
39
|
+
.object({
|
|
40
|
+
matchCount: z.number().int().min(0),
|
|
41
|
+
mismatchCount: z.number().int().min(0),
|
|
42
|
+
undeterminedCount: z.number().int().min(0),
|
|
43
|
+
repairableCount: z.number().int().min(0),
|
|
44
|
+
blockedCount: z.number().int().min(0),
|
|
45
|
+
})
|
|
46
|
+
.strict(),
|
|
47
|
+
})
|
|
48
|
+
.strict();
|
|
49
|
+
const CLOSED_SET = new Set([
|
|
50
|
+
"empty",
|
|
51
|
+
"missing",
|
|
52
|
+
"null",
|
|
53
|
+
"min-1",
|
|
54
|
+
"min",
|
|
55
|
+
"max",
|
|
56
|
+
"max+1",
|
|
57
|
+
"pattern-invalid",
|
|
58
|
+
"enum-invalid",
|
|
59
|
+
"wrong-type",
|
|
60
|
+
"nominal",
|
|
61
|
+
]);
|
|
62
|
+
async function exists(filePath) {
|
|
63
|
+
try {
|
|
64
|
+
await access(filePath);
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function orderedUnique(values) {
|
|
72
|
+
return [...new Set(values.filter(Boolean))];
|
|
73
|
+
}
|
|
74
|
+
function sha256(content) {
|
|
75
|
+
return createHash("sha256").update(content).digest("hex");
|
|
76
|
+
}
|
|
77
|
+
function sectionBody(body, headings) {
|
|
78
|
+
for (const heading of headings) {
|
|
79
|
+
const match = new RegExp(`^###\\s+${heading.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\s*$([\\s\\S]*?)(?=^###\\s+|$)`, "mi").exec(body);
|
|
80
|
+
if (match)
|
|
81
|
+
return match[1] ?? "";
|
|
82
|
+
}
|
|
83
|
+
return "";
|
|
84
|
+
}
|
|
85
|
+
async function listMarkdownCases(workspaceRoot, layout) {
|
|
86
|
+
const resolved = layout ?? resolveBackendTestLayout(undefined);
|
|
87
|
+
const root = path.join(workspaceRoot, ...resolved.markdownDir.split("/"));
|
|
88
|
+
if (!(await exists(root)))
|
|
89
|
+
return [];
|
|
90
|
+
const files = (await readdir(root)).filter((name) => name.toLowerCase().endsWith(".md") && name.toLowerCase() !== "readme.md");
|
|
91
|
+
const cases = [];
|
|
92
|
+
for (const name of files) {
|
|
93
|
+
const rel = path.posix.join(resolved.markdownDir, name);
|
|
94
|
+
const markdown = await readFile(path.join(workspaceRoot, rel), "utf8");
|
|
95
|
+
const headings = [...markdown.matchAll(/^##\s+(BE-[A-Z0-9_-]+-\d{2,3})\b.*$/gm)];
|
|
96
|
+
for (let index = 0; index < headings.length; index += 1) {
|
|
97
|
+
const heading = headings[index];
|
|
98
|
+
const caseId = heading[1];
|
|
99
|
+
const body = markdown.slice(heading.index, headings[index + 1]?.index ?? markdown.length);
|
|
100
|
+
const allPoints = orderedUnique(body.match(/\bTP-[A-Z0-9-]+\b/g) ?? []);
|
|
101
|
+
const variantLabel = body.match(/(?:Variant Test Points|\u53d8\u4f53\u6d4b\u8bd5\u70b9)\s*[::]\s*([^\n]+)/i)?.[1] ??
|
|
102
|
+
"";
|
|
103
|
+
const variantLabelDeclared = variantLabel.trim().length > 0;
|
|
104
|
+
const variantLabelIsNone = /^(?:none|无|n\/a|not-applicable)\b/i.test(variantLabel.trim());
|
|
105
|
+
const variantFromLabel = orderedUnique((variantLabel.match(/\bTP-[A-Z0-9-]+\b/g) ?? []).filter((item) => item.toUpperCase() !== "NONE"));
|
|
106
|
+
const variantTestPoints = variantLabelIsNone
|
|
107
|
+
? []
|
|
108
|
+
: variantFromLabel.length > 0
|
|
109
|
+
? variantFromLabel
|
|
110
|
+
: variantLabelDeclared
|
|
111
|
+
? []
|
|
112
|
+
: allPoints.filter((tp) => /(EMPTY|MISSING|NULL|MIN|MAX|INVALID|WRONG|ENUM|PATTERN|NOMINAL|BOUNDARY)/i.test(tp));
|
|
113
|
+
const scriptLine = body.match(/^(?:\s*[-*+]\s*)?(?:脚本|script)\s*[::]\s*([^\n]+)/im)?.[1]?.replaceAll("`", "").trim() ?? "";
|
|
114
|
+
const scriptExplicitNone = /^(?:none|无|n\/a|not-applicable)(?:\s*[((].*[))])?$/i.test(scriptLine);
|
|
115
|
+
const scriptMatch = body.match(new RegExp(`\\\`?(${resolved.scriptDir.replaceAll(/[.*+?^[\]{}()|$]/g, "\\$&")}/[A-Za-z0-9_./-]*test_[A-Za-z0-9_.-]*\\.py)\\\`?`, "i"));
|
|
116
|
+
cases.push({
|
|
117
|
+
caseId,
|
|
118
|
+
body,
|
|
119
|
+
markdownPath: rel,
|
|
120
|
+
variantTestPoints: variantLabelDeclared
|
|
121
|
+
? variantTestPoints
|
|
122
|
+
: variantTestPoints.length > 0 ? variantTestPoints : allPoints.slice(0, 1),
|
|
123
|
+
scriptPath: scriptExplicitNone
|
|
124
|
+
? undefined
|
|
125
|
+
: scriptMatch?.[1] ?? expectedBackendTestPytestScriptForMarkdownModule(name, resolved),
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return cases;
|
|
130
|
+
}
|
|
131
|
+
function parseScenarioBoundToken(raw) {
|
|
132
|
+
if (!raw)
|
|
133
|
+
return undefined;
|
|
134
|
+
const token = raw.trim();
|
|
135
|
+
if (!token || /^LEN<nominal>$/i.test(token) || /^NOMINAL$/i.test(token)) {
|
|
136
|
+
return undefined;
|
|
137
|
+
}
|
|
138
|
+
const direct = Number(token);
|
|
139
|
+
if (Number.isFinite(direct) && direct >= 0)
|
|
140
|
+
return direct;
|
|
141
|
+
const len = /^(?:LEN(?:GTH)?[_-]?)?(\d{1,5})$/i.exec(token);
|
|
142
|
+
if (len) {
|
|
143
|
+
const n = Number(len[1]);
|
|
144
|
+
return Number.isFinite(n) ? n : undefined;
|
|
145
|
+
}
|
|
146
|
+
return undefined;
|
|
147
|
+
}
|
|
148
|
+
function parseScenarioIntentLine(line) {
|
|
149
|
+
// Target may contain commas (body.title,body.status). Intent may contain `|` / spaces.
|
|
150
|
+
// Stop field values only at known trailing keys or end-of-line.
|
|
151
|
+
const precise = /场景意图\s*[::]\s*(TP-[A-Z0-9-]+)\s*[|;]\s*operation\s*=\s*([^;\n]+?)\s*[|;]\s*target\s*=\s*([^;\n]+?)\s*[|;]\s*intent\s*=\s*([^;\n]+?)(?:\s*[|;]\s*bound\s*=\s*([^\s;|\n]+))?(?:\s*[|;]\s*example\s*=\s*([^;\n]+))?(?:\s*[|;]\s*expectedCode\s*=\s*[^;\n]+)?\s*$/i.exec(line.trim());
|
|
152
|
+
if (precise) {
|
|
153
|
+
return {
|
|
154
|
+
tpId: precise[1],
|
|
155
|
+
rawIntent: (precise[4] ?? "unknown").trim(),
|
|
156
|
+
target: precise[3]?.trim(),
|
|
157
|
+
bound: parseScenarioBoundToken(precise[5]),
|
|
158
|
+
example: precise[6]?.trim(),
|
|
159
|
+
legacy: false,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
const legacy = /场景意图\s*[::]\s*([a-z0-9+._:-]+)(?:\s*[|;,,]\s*field\s*=\s*([A-Za-z0-9_.]+))?(?:\s*[|;,,]\s*bound\s*=\s*([^\s;|,,\n]+))?(?:\s*[|;,,]\s*example\s*=\s*([^|\n]+))?/i.exec(line.trim());
|
|
163
|
+
if (legacy) {
|
|
164
|
+
return {
|
|
165
|
+
rawIntent: (legacy[1] ?? "unknown").trim(),
|
|
166
|
+
field: legacy[2],
|
|
167
|
+
bound: parseScenarioBoundToken(legacy[3]),
|
|
168
|
+
example: legacy[4]?.trim(),
|
|
169
|
+
legacy: true,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
return undefined;
|
|
173
|
+
}
|
|
174
|
+
function resolveScenarioIntentField(target, field) {
|
|
175
|
+
if (field)
|
|
176
|
+
return field;
|
|
177
|
+
if (!target || target === "request")
|
|
178
|
+
return undefined;
|
|
179
|
+
const bodyTargets = target
|
|
180
|
+
.split(/\s*,\s*/)
|
|
181
|
+
.map((item) => item.trim())
|
|
182
|
+
.filter((item) => /^(?:body|json|payload)\./i.test(item));
|
|
183
|
+
const preferred = bodyTargets.find((item) => /\.status$/i.test(item)) ??
|
|
184
|
+
bodyTargets[0] ??
|
|
185
|
+
target.split(/\s*,\s*/)[0];
|
|
186
|
+
return preferred?.split(".").at(-1);
|
|
187
|
+
}
|
|
188
|
+
function resolveCustomLiteralIntent(rawIntent, field) {
|
|
189
|
+
const lower = rawIntent.toLowerCase();
|
|
190
|
+
if (!lower.startsWith("custom-literal:")) {
|
|
191
|
+
return CLOSED_SET.has(lower) ? lower : "unknown";
|
|
192
|
+
}
|
|
193
|
+
// Preserve literal case: enum values such as ACTIVE must not be lowercased.
|
|
194
|
+
const prefixLength = rawIntent.toLowerCase().startsWith("custom-literal:")
|
|
195
|
+
? rawIntent.indexOf(":") + 1
|
|
196
|
+
: "custom-literal:".length;
|
|
197
|
+
const payload = rawIntent.slice(prefixLength);
|
|
198
|
+
if (!payload.includes("|") && !payload.includes(",")) {
|
|
199
|
+
return `custom-literal:${payload}`;
|
|
200
|
+
}
|
|
201
|
+
const parts = payload.split(/\s*[|,]\s*/).map((item) => item.trim()).filter(Boolean);
|
|
202
|
+
if (field) {
|
|
203
|
+
const byField = parts.find((part) => part.toLowerCase().startsWith(`${field.toLowerCase()}=`));
|
|
204
|
+
if (byField) {
|
|
205
|
+
return `custom-literal:${byField.slice(field.length + 1)}`;
|
|
206
|
+
}
|
|
207
|
+
if (/^status$/i.test(field)) {
|
|
208
|
+
const enumLike = parts.find((part) => /^(?:ACTIVE|ARCHIVED|INACTIVE|DISABLED|ENABLED)$/i.test(part));
|
|
209
|
+
if (enumLike)
|
|
210
|
+
return `custom-literal:${enumLike}`;
|
|
211
|
+
}
|
|
212
|
+
if (/^title$/i.test(field)) {
|
|
213
|
+
const titleLike = parts.find((part) => !/^(?:ACTIVE|ARCHIVED|INACTIVE|DISABLED|ENABLED)$/i.test(part));
|
|
214
|
+
if (titleLike)
|
|
215
|
+
return `custom-literal:${titleLike}`;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return parts.length === 1
|
|
219
|
+
? `custom-literal:${parts[0]}`
|
|
220
|
+
: "unknown";
|
|
221
|
+
}
|
|
222
|
+
export function inferScenarioParamIntent(input) {
|
|
223
|
+
const { tpId, caseBody } = input;
|
|
224
|
+
const intentLines = caseBody
|
|
225
|
+
.split(/\r?\n/)
|
|
226
|
+
.map((line) => line.trim())
|
|
227
|
+
.filter((line) => /场景意图\s*[::]/.test(line));
|
|
228
|
+
const parsedLines = intentLines
|
|
229
|
+
.map((line) => parseScenarioIntentLine(line))
|
|
230
|
+
.filter((item) => Boolean(item));
|
|
231
|
+
const preciseForTp = parsedLines.find((item) => item.tpId && item.tpId.toUpperCase() === tpId.toUpperCase());
|
|
232
|
+
const legacyLine = parsedLines.find((item) => item.legacy);
|
|
233
|
+
const fallbackLine = new RegExp(`${tpId.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}[^\\n]{0,200}?intent\\s*[=:]\\s*([^|;,\uff0c\\n]+)`, "i").exec(caseBody);
|
|
234
|
+
const machine = preciseForTp ??
|
|
235
|
+
(legacyLine && parsedLines.filter((item) => !item.legacy).length === 0 ? legacyLine : undefined) ??
|
|
236
|
+
(fallbackLine
|
|
237
|
+
? {
|
|
238
|
+
rawIntent: fallbackLine[1] ?? "unknown",
|
|
239
|
+
legacy: true,
|
|
240
|
+
}
|
|
241
|
+
: undefined);
|
|
242
|
+
if (machine) {
|
|
243
|
+
const field = resolveScenarioIntentField(machine.target, machine.field);
|
|
244
|
+
const rawIntent = machine.rawIntent.trim();
|
|
245
|
+
const example = machine.example;
|
|
246
|
+
const lower = rawIntent.toLowerCase();
|
|
247
|
+
let normalizedIntent = lower === "nominal-operation" ? "nominal" : lower;
|
|
248
|
+
// Writers sometimes mark a short "typical" length sample as min/max with bound=LEN<nominal>.
|
|
249
|
+
// Treat that as nominal so a short helper/string is not forced to equal maxLength.
|
|
250
|
+
if ((normalizedIntent === "min" || normalizedIntent === "max") &&
|
|
251
|
+
/NOMINAL/i.test(tpId)) {
|
|
252
|
+
normalizedIntent = "nominal";
|
|
253
|
+
}
|
|
254
|
+
const dataSection = sectionBody(caseBody, ["测试数据", "Test Data", "操作步骤", "Steps"]);
|
|
255
|
+
const haystack = `${caseBody}\n${dataSection}`;
|
|
256
|
+
const fieldEsc = field
|
|
257
|
+
? field.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
|
|
258
|
+
: undefined;
|
|
259
|
+
const maxBoundFromBody = fieldEsc
|
|
260
|
+
? new RegExp(`${fieldEsc}[^\\n]{0,80}?(?:maxLength|max(?:imum)?|上限|最大长度)\\s*[=::]?\\s*(\\d{1,4})`, "i").exec(haystack) ??
|
|
261
|
+
new RegExp(`(?:maxLength|max(?:imum)?|上限|最大长度)\\s*[=::]?\\s*(\\d{1,4})[^\\n]{0,80}?${fieldEsc}`, "i").exec(haystack) ??
|
|
262
|
+
/(?:maxLength|max(?:imum)?|上限|最大长度)\s*[=::]?\s*(\d{1,4})/i.exec(haystack)
|
|
263
|
+
: /(?:maxLength|max(?:imum)?|上限|最大长度)\s*[=::]?\s*(\d{1,4})/i.exec(haystack);
|
|
264
|
+
const minBoundFromBody = fieldEsc
|
|
265
|
+
? new RegExp(`${fieldEsc}[^\\n]{0,80}?(?:minLength|min(?:imum)?|下限|最小长度)\\s*[=::]?\\s*(\\d{1,4})`, "i").exec(haystack) ??
|
|
266
|
+
new RegExp(`(?:minLength|min(?:imum)?|下限|最小长度)\\s*[=::]?\\s*(\\d{1,4})[^\\n]{0,80}?${fieldEsc}`, "i").exec(haystack) ??
|
|
267
|
+
/(?:minLength|min(?:imum)?|下限|最小长度)\s*[=::]?\s*(\d{1,4})/i.exec(haystack)
|
|
268
|
+
: /(?:minLength|min(?:imum)?|下限|最小长度)\s*[=::]?\s*(\d{1,4})/i.exec(haystack);
|
|
269
|
+
const prefersMinBound = normalizedIntent === "min" ||
|
|
270
|
+
normalizedIntent === "min-1" ||
|
|
271
|
+
/(?:MIN|LEN1|LENGTH-?1|最短|最小)/i.test(tpId);
|
|
272
|
+
const boundFromBody = prefersMinBound
|
|
273
|
+
? minBoundFromBody ?? maxBoundFromBody
|
|
274
|
+
: maxBoundFromBody ?? minBoundFromBody;
|
|
275
|
+
const boundFromTp = /(?:LEN(?:GTH)?|长度)[_-]?(\d{1,5})(?:[_-]|$)/i.exec(tpId) ??
|
|
276
|
+
/(?:MIN|MAX)[_-]?(\d{1,5})(?:[_-]|$)/i.exec(tpId);
|
|
277
|
+
const lengthIntent = normalizedIntent === "min" ||
|
|
278
|
+
normalizedIntent === "min-1" ||
|
|
279
|
+
normalizedIntent === "max" ||
|
|
280
|
+
normalizedIntent === "max+1";
|
|
281
|
+
// Length intents: explicit machine bound >0, then TP-encoded LEN1/LEN100,
|
|
282
|
+
// then field min/maxLength. Prevents maxLength=100 shadowing min/LEN1.
|
|
283
|
+
const boundFromTpNumber = boundFromTp ? Number(boundFromTp[1]) : undefined;
|
|
284
|
+
// max+1 TP tokens encode the oversized length (LEN101), so convert to base bound.
|
|
285
|
+
const boundFromTpNormalized = boundFromTpNumber === undefined
|
|
286
|
+
? undefined
|
|
287
|
+
: normalizedIntent === "max+1"
|
|
288
|
+
? Math.max(0, boundFromTpNumber - 1)
|
|
289
|
+
: boundFromTpNumber;
|
|
290
|
+
const bound = machine.bound && machine.bound > 0
|
|
291
|
+
? machine.bound
|
|
292
|
+
: lengthIntent && boundFromTpNormalized !== undefined
|
|
293
|
+
? boundFromTpNormalized
|
|
294
|
+
: boundFromBody
|
|
295
|
+
? Number(boundFromBody[1])
|
|
296
|
+
: machine.bound;
|
|
297
|
+
if (rawIntent.toLowerCase().startsWith("custom-literal:")) {
|
|
298
|
+
const resolved = resolveCustomLiteralIntent(rawIntent, field);
|
|
299
|
+
const rawLiteral = rawIntent.slice(rawIntent.indexOf(":") + 1).trim();
|
|
300
|
+
const intent = resolved === "unknown" && example && rawLiteral === example.trim()
|
|
301
|
+
? `custom-literal:${example.trim()}`
|
|
302
|
+
: resolved;
|
|
303
|
+
return {
|
|
304
|
+
intent,
|
|
305
|
+
field,
|
|
306
|
+
bound,
|
|
307
|
+
example,
|
|
308
|
+
intentSource: "machine-line",
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
return {
|
|
312
|
+
intent: (CLOSED_SET.has(normalizedIntent) ? normalizedIntent : "unknown"),
|
|
313
|
+
field,
|
|
314
|
+
bound,
|
|
315
|
+
example,
|
|
316
|
+
intentSource: "machine-line",
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
const upper = tpId.toUpperCase();
|
|
320
|
+
const fieldFromTp = tpId
|
|
321
|
+
.replace(/^TP-/i, "")
|
|
322
|
+
.split("-")
|
|
323
|
+
.filter((part) => ![
|
|
324
|
+
"EMPTY",
|
|
325
|
+
"MISSING",
|
|
326
|
+
"NULL",
|
|
327
|
+
"MIN",
|
|
328
|
+
"MAX",
|
|
329
|
+
"PLUS",
|
|
330
|
+
"1",
|
|
331
|
+
"INVALID",
|
|
332
|
+
"WRONG",
|
|
333
|
+
"TYPE",
|
|
334
|
+
"ENUM",
|
|
335
|
+
"PATTERN",
|
|
336
|
+
"NOMINAL",
|
|
337
|
+
"BOUNDARY",
|
|
338
|
+
"CASE",
|
|
339
|
+
"VARIANT",
|
|
340
|
+
"WHITESPACE",
|
|
341
|
+
"UNKNOWN",
|
|
342
|
+
"HEALTH",
|
|
343
|
+
"UP",
|
|
344
|
+
"OK",
|
|
345
|
+
"GET",
|
|
346
|
+
"API",
|
|
347
|
+
"STATUS",
|
|
348
|
+
"CODE",
|
|
349
|
+
"HTTP",
|
|
350
|
+
"RESPONSE",
|
|
351
|
+
"REQUEST",
|
|
352
|
+
"NOTES",
|
|
353
|
+
"NOTE",
|
|
354
|
+
"REQUIRED",
|
|
355
|
+
"LENGTH",
|
|
356
|
+
"OVER",
|
|
357
|
+
"FILTER",
|
|
358
|
+
"LIST",
|
|
359
|
+
"ROUNDTRIP",
|
|
360
|
+
"READINESS",
|
|
361
|
+
"DEFAULT",
|
|
362
|
+
"TRIM",
|
|
363
|
+
"BLANK",
|
|
364
|
+
"WHITESPACE",
|
|
365
|
+
"NORMALIZE",
|
|
366
|
+
"FAIL",
|
|
367
|
+
"SUCCESS",
|
|
368
|
+
"LOWERCASE",
|
|
369
|
+
"UPPERCASE",
|
|
370
|
+
].includes(part.toUpperCase()))[0]
|
|
371
|
+
?.replace(/_/g, "") ?? undefined;
|
|
372
|
+
const field = fieldFromTp && fieldFromTp.length > 1
|
|
373
|
+
? fieldFromTp.charAt(0).toLowerCase() + fieldFromTp.slice(1)
|
|
374
|
+
: undefined;
|
|
375
|
+
const dataSection = sectionBody(caseBody, ["测试数据", "Test Data", "操作步骤", "Steps"]);
|
|
376
|
+
const fieldScopedBound = field
|
|
377
|
+
? new RegExp(`${field.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}[^\\n]{0,80}?(?:maxLength|max(?:imum)?|上限|最大长度)\\s*[=::]?\\s*(\\d{1,4})`, "i").exec(`${caseBody}\n${dataSection}`) ??
|
|
378
|
+
new RegExp(`(?:maxLength|max(?:imum)?|上限|最大长度)\\s*[=::]?\\s*(\\d{1,4})[^\\n]{0,80}?${field.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`, "i").exec(`${caseBody}\n${dataSection}`)
|
|
379
|
+
: undefined;
|
|
380
|
+
const boundMatch = fieldScopedBound ??
|
|
381
|
+
/(?:maxLength|max(?:imum)?|上限|最大长度)\s*[=::]?\s*(\d{1,4})/i.exec(`${caseBody}\n${dataSection}`) ??
|
|
382
|
+
/(?:minLength|min(?:imum)?|下限|最小长度)\s*[=::]?\s*(\d{1,4})/i.exec(`${caseBody}\n${dataSection}`);
|
|
383
|
+
const bound = boundMatch ? Number(boundMatch[1]) : undefined;
|
|
384
|
+
const exampleMatch = /(?:反例|invalid example|example)\s*[=::]\s*[`"]?([^`"\n]+)[`"]?/i.exec(caseBody);
|
|
385
|
+
const example = exampleMatch?.[1]?.trim();
|
|
386
|
+
if (/EMPTY|空白|空串|空字符串/.test(upper) || /空字符串|空串|empty string/i.test(caseBody)) {
|
|
387
|
+
return { intent: "empty", field, bound, example, intentSource: "tp-fallback" };
|
|
388
|
+
}
|
|
389
|
+
if (/MISSING|缺省|缺失|省略/.test(upper) || /缺少字段|缺失字段|missing field/i.test(caseBody)) {
|
|
390
|
+
return { intent: "missing", field, bound, example, intentSource: "tp-fallback" };
|
|
391
|
+
}
|
|
392
|
+
if (/\bNULL\b|空值/.test(upper) || /\bnull\b/i.test(caseBody)) {
|
|
393
|
+
return { intent: "null", field, bound, example, intentSource: "tp-fallback" };
|
|
394
|
+
}
|
|
395
|
+
if (/MAX[-_]?PLUS[-_]?1|MAX\+1|超长|越界|LENGTH[-_]?OVER|OVER[-_]?LENGTH|OVER/.test(upper)) {
|
|
396
|
+
return { intent: "max+1", field, bound, example, intentSource: "tp-fallback" };
|
|
397
|
+
}
|
|
398
|
+
if (/\bMAX\b|最大/.test(upper)) {
|
|
399
|
+
return { intent: "max", field, bound, example, intentSource: "tp-fallback" };
|
|
400
|
+
}
|
|
401
|
+
if (/MIN[-_]?1|最小减|min-1/i.test(upper)) {
|
|
402
|
+
return { intent: "min-1", field, bound, example, intentSource: "tp-fallback" };
|
|
403
|
+
}
|
|
404
|
+
if (/\bMIN\b|最小/.test(upper)) {
|
|
405
|
+
return { intent: "min", field, bound, example, intentSource: "tp-fallback" };
|
|
406
|
+
}
|
|
407
|
+
if (/WRONG[-_]?TYPE|类型错误/.test(upper)) {
|
|
408
|
+
return { intent: "wrong-type", field, bound, example, intentSource: "tp-fallback" };
|
|
409
|
+
}
|
|
410
|
+
if (/ENUM.*INVALID|INVALID.*ENUM|非法枚举/.test(upper)) {
|
|
411
|
+
return { intent: "enum-invalid", field, bound, example, intentSource: "tp-fallback" };
|
|
412
|
+
}
|
|
413
|
+
if (/PATTERN|FORMAT|UPPERCASE|大写|非法格式/.test(upper)) {
|
|
414
|
+
return { intent: "pattern-invalid", field, bound, example, intentSource: "tp-fallback" };
|
|
415
|
+
}
|
|
416
|
+
if (/NOMINAL|正常|合法|主路径|SUCCESS/.test(upper)) {
|
|
417
|
+
return { intent: "nominal", field, bound, example, intentSource: "tp-fallback" };
|
|
418
|
+
}
|
|
419
|
+
return { intent: "unknown", field, bound, example, intentSource: "tp-fallback" };
|
|
420
|
+
}
|
|
421
|
+
const OMIT_SENTINEL_RE = /^(?:_OMIT|OMIT|MISSING|Ellipsis|\.\.\.)\b/;
|
|
422
|
+
const HTTP_EXPECTED_CODE_RE = /^(?:2xx|3xx|4xx|5xx|[1-5]\d{2}|HTTP_[1-5]\d{2})$/i;
|
|
423
|
+
/** Semantic custom-literal tokens that describe a value class, not a raw string. */
|
|
424
|
+
function isWhitespaceSemanticLiteral(token) {
|
|
425
|
+
return /^(?:whitespace-only|ws-only|blank|blank-only|spaces-only|space-only|two-spaces|multiple-spaces|empty-ws|empty-whitespace)$/i.test(token.trim());
|
|
426
|
+
}
|
|
427
|
+
function isWhitespacePaddedSemanticLiteral(token) {
|
|
428
|
+
return /^(?:whitespace-padded|ws-padded|padded-whitespace|leading-trailing-ws|trim-target|trim|trimmed|pad|padded)$/i.test(token.trim());
|
|
429
|
+
}
|
|
430
|
+
function isWhitespaceOnlyString(value) {
|
|
431
|
+
return value.length > 0 && /^\s+$/.test(value);
|
|
432
|
+
}
|
|
433
|
+
function isWhitespacePaddedString(value) {
|
|
434
|
+
return value.length > 0 && value !== value.trim() && value.trim().length > 0;
|
|
435
|
+
}
|
|
436
|
+
function normalizeScenarioLiteralText(value) {
|
|
437
|
+
// Writers sometimes emit visible-space placeholders (U+2420), NBSP variants,
|
|
438
|
+
// or URL-encoded spaces in machine-readable Markdown.
|
|
439
|
+
const normalized = value
|
|
440
|
+
.replace(/␠/g, " ")
|
|
441
|
+
.replace(/ /g, " ")
|
|
442
|
+
.replace(/ /g, " ")
|
|
443
|
+
.replace(/ /g, " ");
|
|
444
|
+
try {
|
|
445
|
+
return /%[0-9A-F]{2}/i.test(normalized) ? decodeURIComponent(normalized) : normalized;
|
|
446
|
+
}
|
|
447
|
+
catch {
|
|
448
|
+
return normalized;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
function stripWrappingQuotes(value) {
|
|
452
|
+
const trimmed = value.trim();
|
|
453
|
+
if ((trimmed.startsWith('"') && trimmed.endsWith('"') && trimmed.length >= 2) ||
|
|
454
|
+
(trimmed.startsWith("'") && trimmed.endsWith("'") && trimmed.length >= 2)) {
|
|
455
|
+
return trimmed.slice(1, -1);
|
|
456
|
+
}
|
|
457
|
+
return value;
|
|
458
|
+
}
|
|
459
|
+
function normalizeCustomLiteralExpected(raw) {
|
|
460
|
+
return normalizeScenarioLiteralText(stripWrappingQuotes(raw));
|
|
461
|
+
}
|
|
462
|
+
function isHttpExpectedCodeLiteral(value) {
|
|
463
|
+
return HTTP_EXPECTED_CODE_RE.test(value.trim());
|
|
464
|
+
}
|
|
465
|
+
/** Decode common Python string escapes found in source text (not JSON). */
|
|
466
|
+
function unescapePythonStringLiteral(value) {
|
|
467
|
+
return value
|
|
468
|
+
.replace(/\\n/g, "\n")
|
|
469
|
+
.replace(/\\t/g, "\t")
|
|
470
|
+
.replace(/\\r/g, "\r")
|
|
471
|
+
.replace(/\\'/g, "'")
|
|
472
|
+
.replace(/\\"/g, '"')
|
|
473
|
+
.replace(/\\\\/g, "\\");
|
|
474
|
+
}
|
|
475
|
+
function featuresFromStringValue(value) {
|
|
476
|
+
const decoded = normalizeScenarioLiteralText(unescapePythonStringLiteral(value));
|
|
477
|
+
return {
|
|
478
|
+
kind: decoded.length === 0 ? "empty-string" : "string",
|
|
479
|
+
text: JSON.stringify(decoded),
|
|
480
|
+
length: decoded.length,
|
|
481
|
+
hasUppercase: /[A-Z]/.test(decoded),
|
|
482
|
+
literal: decoded,
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
function collectPythonStringConstants(source) {
|
|
486
|
+
const constants = new Map();
|
|
487
|
+
const re = /\b([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(["'])([^"'\\]*)\2/g;
|
|
488
|
+
let match;
|
|
489
|
+
while ((match = re.exec(source)) !== null) {
|
|
490
|
+
const name = match[1] ?? "";
|
|
491
|
+
const value = match[3] ?? "";
|
|
492
|
+
if (name && !constants.has(name))
|
|
493
|
+
constants.set(name, value);
|
|
494
|
+
}
|
|
495
|
+
return constants;
|
|
496
|
+
}
|
|
497
|
+
function resolveNamedConstant(name, constants) {
|
|
498
|
+
if (!constants?.has(name))
|
|
499
|
+
return undefined;
|
|
500
|
+
const value = constants.get(name) ?? "";
|
|
501
|
+
return featuresFromStringValue(value);
|
|
502
|
+
}
|
|
503
|
+
function observeLiteralToken(raw, field, constants) {
|
|
504
|
+
const trimmed = raw.trim();
|
|
505
|
+
if (!trimmed)
|
|
506
|
+
return undefined;
|
|
507
|
+
if (OMIT_SENTINEL_RE.test(trimmed) || trimmed === "...") {
|
|
508
|
+
return {
|
|
509
|
+
kind: "missing-key",
|
|
510
|
+
text: field ? `missing:${field}` : "missing-key",
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
if (trimmed === "None" || trimmed === "null") {
|
|
514
|
+
return { kind: "none", text: "None", literal: "None" };
|
|
515
|
+
}
|
|
516
|
+
if (trimmed === '""' || trimmed === "''") {
|
|
517
|
+
return { kind: "empty-string", text: '""', length: 0, literal: "" };
|
|
518
|
+
}
|
|
519
|
+
const repeatedValue = /^(['"])([^'"\\])\1\s*\*\s*(\d{1,5})$/.exec(trimmed);
|
|
520
|
+
if (repeatedValue) {
|
|
521
|
+
const ch = repeatedValue[2] ?? "x";
|
|
522
|
+
const length = Number(repeatedValue[3] ?? "0");
|
|
523
|
+
const value = ch.repeat(Math.max(0, length));
|
|
524
|
+
return featuresFromStringValue(value);
|
|
525
|
+
}
|
|
526
|
+
// "x" * _TITLE_MAX_LENGTH / "a" * _TITLE_LEN100
|
|
527
|
+
const repeatedConst = /^(['"])([^'"\\])\1\s*\*\s*([A-Za-z_][A-Za-z0-9_]*)$/.exec(trimmed);
|
|
528
|
+
if (repeatedConst) {
|
|
529
|
+
const helper = repeatedConst[3] ?? "";
|
|
530
|
+
const fromConst = resolveNamedConstant(helper, constants);
|
|
531
|
+
if (fromConst?.kind === "string" && typeof fromConst.length === "number") {
|
|
532
|
+
return {
|
|
533
|
+
kind: "number",
|
|
534
|
+
text: trimmed,
|
|
535
|
+
length: fromConst.length,
|
|
536
|
+
literal: String(fromConst.length),
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
const lenFromName = /(?:^|_)LEN(?:GTH)?_?(\d{1,5})$/i.exec(helper) ??
|
|
540
|
+
/LEN(?:GTH)?_?(\d{1,5})$/i.exec(helper);
|
|
541
|
+
if (lenFromName) {
|
|
542
|
+
const length = Number(lenFromName[1] ?? "0");
|
|
543
|
+
return { kind: "number", text: trimmed, length, literal: String(length) };
|
|
544
|
+
}
|
|
545
|
+
if (/(?:OVER|OVERSIZE|TOO[_-]?LONG|MAX[_-]?PLUS[_-]?1|MAXPLUS1)/i.test(helper)) {
|
|
546
|
+
return { kind: "name", text: helper, length: -2, literal: "oversize-helper" };
|
|
547
|
+
}
|
|
548
|
+
if (/(?:MAX[_-]?LENGTH|LENGTH[_-]?MAX|_MAX_LEN(?:GTH)?$)/i.test(helper)) {
|
|
549
|
+
return { kind: "name", text: helper, length: -1, literal: "max-length-helper" };
|
|
550
|
+
}
|
|
551
|
+
if (/(?:MIN[_-]?LENGTH|LENGTH[_-]?MIN|_MIN_LEN(?:GTH)?$)/i.test(helper)) {
|
|
552
|
+
return { kind: "name", text: helper, length: -3, literal: "min-length-helper" };
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
const triple = /^("""|''')([\s\S]*)\1$/.exec(trimmed);
|
|
556
|
+
if (triple) {
|
|
557
|
+
return featuresFromStringValue(triple[2] ?? "");
|
|
558
|
+
}
|
|
559
|
+
const str = /^['"]([\s\S]*)['"]$/.exec(trimmed);
|
|
560
|
+
if (str) {
|
|
561
|
+
return featuresFromStringValue(str[1] ?? "");
|
|
562
|
+
}
|
|
563
|
+
if (/^-?\d+(?:\.\d+)?$/.test(trimmed)) {
|
|
564
|
+
return { kind: "number", text: trimmed, literal: trimmed };
|
|
565
|
+
}
|
|
566
|
+
if (trimmed === "True" || trimmed === "False") {
|
|
567
|
+
return { kind: "boolean", text: trimmed, literal: trimmed };
|
|
568
|
+
}
|
|
569
|
+
if (trimmed.startsWith("[")) {
|
|
570
|
+
const inner = trimmed.replace(/^\[/, "").replace(/\]$/, "").trim();
|
|
571
|
+
let count = 0;
|
|
572
|
+
let depth = 0;
|
|
573
|
+
let quote = "";
|
|
574
|
+
let escaped = false;
|
|
575
|
+
if (inner) {
|
|
576
|
+
count = 1;
|
|
577
|
+
for (const ch of inner) {
|
|
578
|
+
if (escaped) {
|
|
579
|
+
escaped = false;
|
|
580
|
+
continue;
|
|
581
|
+
}
|
|
582
|
+
if (ch === "\\") {
|
|
583
|
+
escaped = true;
|
|
584
|
+
continue;
|
|
585
|
+
}
|
|
586
|
+
if (quote) {
|
|
587
|
+
if (ch === quote)
|
|
588
|
+
quote = "";
|
|
589
|
+
continue;
|
|
590
|
+
}
|
|
591
|
+
if (ch === '"' || ch === "'") {
|
|
592
|
+
quote = ch;
|
|
593
|
+
continue;
|
|
594
|
+
}
|
|
595
|
+
if (ch === "[" || ch === "{" || ch === "(")
|
|
596
|
+
depth += 1;
|
|
597
|
+
else if (ch === "]" || ch === "}" || ch === ")")
|
|
598
|
+
depth -= 1;
|
|
599
|
+
else if (ch === "," && depth === 0)
|
|
600
|
+
count += 1;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
return { kind: "list", text: trimmed, length: count };
|
|
604
|
+
}
|
|
605
|
+
if (trimmed.startsWith("{"))
|
|
606
|
+
return { kind: "dict", text: trimmed };
|
|
607
|
+
if (/\(/.test(trimmed)) {
|
|
608
|
+
// Tuple/list positional wrappers: (_TITLE_LEN1, "2xx") → first meaningful token.
|
|
609
|
+
const inner = trimmed.replace(/^\(/, "").replace(/\)$/, "");
|
|
610
|
+
const first = inner.split(",")[0]?.trim();
|
|
611
|
+
if (first && first !== trimmed) {
|
|
612
|
+
return observeLiteralToken(first, field, constants);
|
|
613
|
+
}
|
|
614
|
+
return { kind: "call", text: trimmed };
|
|
615
|
+
}
|
|
616
|
+
if (/^[A-Za-z_][A-Za-z0-9_]*$/.test(trimmed)) {
|
|
617
|
+
if (OMIT_SENTINEL_RE.test(trimmed)) {
|
|
618
|
+
return {
|
|
619
|
+
kind: "missing-key",
|
|
620
|
+
text: field ? `missing:${field}` : "missing-key",
|
|
621
|
+
};
|
|
622
|
+
}
|
|
623
|
+
// Length helper names used by writers:
|
|
624
|
+
// _TITLE_LEN1 / _CONTENT_LEN2000 / _TITLE_MAX_LENGTH / _CONTENT_OVER_LENGTH
|
|
625
|
+
const lenFromName = /(?:^|_)LEN(?:GTH)?_?(\d{1,5})$/i.exec(trimmed) ??
|
|
626
|
+
/LEN(?:GTH)?_?(\d{1,5})$/i.exec(trimmed);
|
|
627
|
+
if (lenFromName) {
|
|
628
|
+
const length = Number(lenFromName[1] ?? "0");
|
|
629
|
+
return {
|
|
630
|
+
kind: "number",
|
|
631
|
+
text: trimmed,
|
|
632
|
+
length,
|
|
633
|
+
literal: String(length),
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
// Opaque max/min/oversize helpers resolve against Markdown bound in compareIntent.
|
|
637
|
+
if (/(?:OVER|OVERSIZE|TOO[_-]?LONG|MAX[_-]?PLUS[_-]?1|MAXPLUS1)/i.test(trimmed)) {
|
|
638
|
+
return { kind: "name", text: trimmed, length: -2, literal: "oversize-helper" };
|
|
639
|
+
}
|
|
640
|
+
if (/(?:MAX[_-]?LENGTH|LENGTH[_-]?MAX|_MAX_LEN(?:GTH)?$)/i.test(trimmed)) {
|
|
641
|
+
return { kind: "name", text: trimmed, length: -1, literal: "max-length-helper" };
|
|
642
|
+
}
|
|
643
|
+
if (/(?:MIN[_-]?LENGTH|LENGTH[_-]?MIN|_MIN_LEN(?:GTH)?$)/i.test(trimmed)) {
|
|
644
|
+
return { kind: "name", text: trimmed, length: -3, literal: "min-length-helper" };
|
|
645
|
+
}
|
|
646
|
+
const resolved = resolveNamedConstant(trimmed, constants);
|
|
647
|
+
if (resolved)
|
|
648
|
+
return resolved;
|
|
649
|
+
return { kind: "name", text: trimmed };
|
|
650
|
+
}
|
|
651
|
+
return { kind: "unknown", text: trimmed };
|
|
652
|
+
}
|
|
653
|
+
export function extractPytestParamBlock(source, tpId) {
|
|
654
|
+
const idPattern = new RegExp(`id\\s*=\\s*["']${tpId.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}["']`);
|
|
655
|
+
const matches = [...source.matchAll(/pytest\.param\s*\(/g)];
|
|
656
|
+
for (const match of matches) {
|
|
657
|
+
const start = match.index ?? 0;
|
|
658
|
+
let depth = 0;
|
|
659
|
+
let end = -1;
|
|
660
|
+
for (let i = start; i < source.length; i += 1) {
|
|
661
|
+
const ch = source[i];
|
|
662
|
+
if (ch === "(")
|
|
663
|
+
depth += 1;
|
|
664
|
+
else if (ch === ")") {
|
|
665
|
+
depth -= 1;
|
|
666
|
+
if (depth === 0) {
|
|
667
|
+
end = i + 1;
|
|
668
|
+
break;
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
if (end < 0)
|
|
673
|
+
continue;
|
|
674
|
+
const block = source.slice(start, end);
|
|
675
|
+
if (idPattern.test(block))
|
|
676
|
+
return block;
|
|
677
|
+
}
|
|
678
|
+
return undefined;
|
|
679
|
+
}
|
|
680
|
+
function extractPytestParamParameterNames(source, tpId) {
|
|
681
|
+
const block = extractPytestParamBlock(source, tpId);
|
|
682
|
+
if (!block)
|
|
683
|
+
return [];
|
|
684
|
+
const blockIndex = source.indexOf(block);
|
|
685
|
+
if (blockIndex < 0)
|
|
686
|
+
return [];
|
|
687
|
+
const decoratorIndex = source.lastIndexOf("@pytest.mark.parametrize", blockIndex);
|
|
688
|
+
if (decoratorIndex < 0)
|
|
689
|
+
return [];
|
|
690
|
+
const prefix = source.slice(decoratorIndex, blockIndex);
|
|
691
|
+
const match = /@pytest\.mark\.parametrize\s*\(\s*["']([^"']+)["']/s.exec(prefix);
|
|
692
|
+
return match?.[1]?.split(",").map((name) => name.trim()).filter(Boolean) ?? [];
|
|
693
|
+
}
|
|
694
|
+
export function observeParamFeatures(block, field, constants, parameterNames) {
|
|
695
|
+
if (!block)
|
|
696
|
+
return { kind: "unknown", text: "param-block-missing" };
|
|
697
|
+
const compact = block.replace(/\s+/g, " ");
|
|
698
|
+
if (/\bFaker\b|\bfake\b|\brandom\b|\buuid4\b|\bfactory\b/i.test(block)) {
|
|
699
|
+
return { kind: "call", text: "dynamic-or-faker" };
|
|
700
|
+
}
|
|
701
|
+
// Prefer dict-like payload extraction when a real object literal is present.
|
|
702
|
+
// Writers often build the payload in the test body and only pass scalar intent
|
|
703
|
+
// values in pytest.param; in that case fall through to positional observation.
|
|
704
|
+
const dictMatch = /\{\s*([\s\S]*?)\s*\}/.exec(block) ??
|
|
705
|
+
/(?:payload|body|data|json)\s*=\s*(\{[\s\S]*?\})/.exec(block);
|
|
706
|
+
const dictText = dictMatch?.[0] ?? dictMatch?.[1] ?? "";
|
|
707
|
+
const fieldPattern = field
|
|
708
|
+
? new RegExp(`["']${field.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}["']\\s*:`)
|
|
709
|
+
: undefined;
|
|
710
|
+
const dictHasField = Boolean(fieldPattern && fieldPattern.test(dictText));
|
|
711
|
+
const dictLooksLikePayload = Boolean(dictMatch) &&
|
|
712
|
+
(/["'][A-Za-z_][A-Za-z0-9_]*["']\s*:/.test(dictText) ||
|
|
713
|
+
/(?:payload|body|data|json)\s*=/.test(block));
|
|
714
|
+
if (dictLooksLikePayload && !field) {
|
|
715
|
+
return { kind: "dict", text: dictText.replace(/\s+/g, " ").slice(0, 160) };
|
|
716
|
+
}
|
|
717
|
+
if (dictLooksLikePayload && field) {
|
|
718
|
+
if (!dictHasField) {
|
|
719
|
+
return { kind: "missing-key", text: `missing:${field}` };
|
|
720
|
+
}
|
|
721
|
+
const valueMatch = new RegExp(`["']${field.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}["']\\s*:\\s*([^,}\n]+)`).exec(dictText);
|
|
722
|
+
const raw = valueMatch?.[1]?.trim() ?? "";
|
|
723
|
+
return (observeLiteralToken(raw, field, constants) ?? {
|
|
724
|
+
kind: "unknown",
|
|
725
|
+
text: raw || compact.slice(0, 120),
|
|
726
|
+
});
|
|
727
|
+
}
|
|
728
|
+
// Repeated string literal: "a" * 100 / 'x'*101
|
|
729
|
+
const repeated = /pytest\.param\s*\(\s*(["'])([^"'\\])\1\s*\*\s*(\d{1,5})/.exec(block) ??
|
|
730
|
+
/(["'])([^"'\\])\1\s*\*\s*(\d{1,5})/.exec(block);
|
|
731
|
+
if (repeated && (!field || !/\{/.test(block))) {
|
|
732
|
+
const ch = repeated[2] ?? "x";
|
|
733
|
+
const length = Number(repeated[3] ?? "0");
|
|
734
|
+
const value = ch.repeat(Math.max(0, length));
|
|
735
|
+
return {
|
|
736
|
+
kind: length === 0 ? "empty-string" : "string",
|
|
737
|
+
text: JSON.stringify(value),
|
|
738
|
+
length,
|
|
739
|
+
hasUppercase: /[A-Z]/.test(value),
|
|
740
|
+
literal: value,
|
|
741
|
+
};
|
|
742
|
+
}
|
|
743
|
+
// Bare omit sentinel before id=...
|
|
744
|
+
if (/pytest\.param\s*\(\s*(?:_OMIT|OMIT|MISSING|\.\.\.|Ellipsis)\s*(?:,|\)|$)/.test(block)) {
|
|
745
|
+
return {
|
|
746
|
+
kind: "missing-key",
|
|
747
|
+
text: field ? `missing:${field}` : "missing-key",
|
|
748
|
+
};
|
|
749
|
+
}
|
|
750
|
+
// Parse top-level positional args before the legacy token scanner so list
|
|
751
|
+
// cardinality and field/value rows remain statically visible.
|
|
752
|
+
const topLevelArgs = (() => {
|
|
753
|
+
const open = block.indexOf("(");
|
|
754
|
+
const close = block.lastIndexOf(")");
|
|
755
|
+
if (open < 0 || close <= open)
|
|
756
|
+
return [];
|
|
757
|
+
const input = block.slice(open + 1, close);
|
|
758
|
+
const args = [];
|
|
759
|
+
let start = 0;
|
|
760
|
+
let depth = 0;
|
|
761
|
+
let quote = "";
|
|
762
|
+
let escaped = false;
|
|
763
|
+
for (let i = 0; i < input.length; i += 1) {
|
|
764
|
+
const ch = input[i];
|
|
765
|
+
if (escaped) {
|
|
766
|
+
escaped = false;
|
|
767
|
+
continue;
|
|
768
|
+
}
|
|
769
|
+
if (ch === "\\") {
|
|
770
|
+
escaped = true;
|
|
771
|
+
continue;
|
|
772
|
+
}
|
|
773
|
+
if (quote) {
|
|
774
|
+
if (ch === quote)
|
|
775
|
+
quote = "";
|
|
776
|
+
continue;
|
|
777
|
+
}
|
|
778
|
+
if (ch === '"' || ch === "'") {
|
|
779
|
+
quote = ch;
|
|
780
|
+
continue;
|
|
781
|
+
}
|
|
782
|
+
if (ch === "[" || ch === "{" || ch === "(")
|
|
783
|
+
depth += 1;
|
|
784
|
+
else if (ch === "]" || ch === "}" || ch === ")")
|
|
785
|
+
depth -= 1;
|
|
786
|
+
else if (ch === "," && depth === 0) {
|
|
787
|
+
args.push(input.slice(start, i).trim());
|
|
788
|
+
start = i + 1;
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
args.push(input.slice(start).trim());
|
|
792
|
+
return args.filter((arg) => arg && !/^(?:id|marks)\s*=/.test(arg));
|
|
793
|
+
})();
|
|
794
|
+
if (topLevelArgs.length > 0) {
|
|
795
|
+
const idTp = /\bid\s*=\s*["'](TP-[A-Z0-9-]+)["']/i.exec(block)?.[1]?.toUpperCase();
|
|
796
|
+
const meaningfulArgs = topLevelArgs.filter((arg) => {
|
|
797
|
+
const value = observeLiteralToken(arg, field, constants);
|
|
798
|
+
if (value?.kind !== "string" || !value.literal)
|
|
799
|
+
return true;
|
|
800
|
+
if (/^TP-[A-Z0-9-]+$/i.test(value.literal) && (!idTp || value.literal.toUpperCase() === idTp))
|
|
801
|
+
return false;
|
|
802
|
+
if (isHttpExpectedCodeLiteral(value.literal))
|
|
803
|
+
return false;
|
|
804
|
+
return true;
|
|
805
|
+
});
|
|
806
|
+
if (meaningfulArgs.length === 0 && field) {
|
|
807
|
+
return { kind: "missing-key", text: `missing:${field}` };
|
|
808
|
+
}
|
|
809
|
+
let candidateIndex = field
|
|
810
|
+
? Math.max(0, parameterNames?.findIndex((name) => name.toLowerCase() === field.toLowerCase()) ?? -1)
|
|
811
|
+
: 0;
|
|
812
|
+
const first = meaningfulArgs[0]
|
|
813
|
+
? observeLiteralToken(meaningfulArgs[0], field, constants)
|
|
814
|
+
: undefined;
|
|
815
|
+
if (field && parameterNames?.some((name) => /^(?:field|key|field_name|missing_field|missing_key|omit_field)$/i.test(name)) &&
|
|
816
|
+
!parameterNames.some((name) => /^(?:value|field_value|payload_value)$/i.test(name))) {
|
|
817
|
+
if (first?.kind === "string" && first.literal?.toLowerCase() === field.toLowerCase()) {
|
|
818
|
+
return { kind: "missing-key", text: `missing:${field}` };
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
if (field &&
|
|
822
|
+
first?.kind === "string" &&
|
|
823
|
+
first.literal?.toLowerCase() === field.toLowerCase() &&
|
|
824
|
+
meaningfulArgs.length > 1) {
|
|
825
|
+
candidateIndex = 1;
|
|
826
|
+
}
|
|
827
|
+
const rawCandidate = meaningfulArgs[candidateIndex];
|
|
828
|
+
const candidate = rawCandidate
|
|
829
|
+
? observeLiteralToken(rawCandidate, field, constants)
|
|
830
|
+
: undefined;
|
|
831
|
+
if (candidate?.kind === "none" && parameterNames) {
|
|
832
|
+
const omitIndex = parameterNames.findIndex((name) => /^(?:omit|omitted|is_omit|should_omit)$/i.test(name));
|
|
833
|
+
if (omitIndex >= 0 && /^True$/.test(topLevelArgs[omitIndex] ?? "")) {
|
|
834
|
+
return { kind: "missing-key", text: field ? `missing:${field}` : "missing-key" };
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
if (candidate)
|
|
838
|
+
return candidate;
|
|
839
|
+
}
|
|
840
|
+
// Positional args: skip a leading TP-id label when writers emit
|
|
841
|
+
// pytest.param("TP-...", actual_value, id="TP-...").
|
|
842
|
+
// Also skip HTTP expected-code tokens (2xx/400) that are not field values.
|
|
843
|
+
const paramOpen = /pytest\.param\s*\(/.exec(block);
|
|
844
|
+
if (paramOpen) {
|
|
845
|
+
const afterOpen = block.slice((paramOpen.index ?? 0) + paramOpen[0].length);
|
|
846
|
+
const positionalTokens = [];
|
|
847
|
+
const tokenRe = /\s*(_OMIT|OMIT|MISSING|Ellipsis|\.\.\.|None|True|False|-?\d+(?:\.\d+)?|"""[\s\S]*?"""|\'\'\'[\s\S]*?\'\'\'|(?:["'][^"'\\]["']\s*\*\s*(?:\d{1,5}|[A-Za-z_][A-Za-z0-9_]*))|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[A-Za-z_][A-Za-z0-9_]*)\s*(?:,|\)|$)/g;
|
|
848
|
+
let match;
|
|
849
|
+
while ((match = tokenRe.exec(afterOpen)) !== null) {
|
|
850
|
+
const between = afterOpen.slice(0, match.index);
|
|
851
|
+
if (/(?:^|,)\s*(?:id|marks)\s*=/.test(between + match[0]))
|
|
852
|
+
break;
|
|
853
|
+
if (/^(?:id|marks)$/i.test(match[1] ?? ""))
|
|
854
|
+
break;
|
|
855
|
+
positionalTokens.push(match[1]);
|
|
856
|
+
if (positionalTokens.length >= 6)
|
|
857
|
+
break;
|
|
858
|
+
}
|
|
859
|
+
const idMatch = /\bid\s*=\s*["'](TP-[A-Z0-9-]+)["']/i.exec(block);
|
|
860
|
+
const idTp = idMatch?.[1]?.toUpperCase();
|
|
861
|
+
const candidates = positionalTokens.filter((raw) => {
|
|
862
|
+
const observed = observeLiteralToken(raw, field, constants);
|
|
863
|
+
if (!observed)
|
|
864
|
+
return false;
|
|
865
|
+
if (observed.kind === "string" &&
|
|
866
|
+
observed.literal &&
|
|
867
|
+
/^TP-[A-Z0-9-]+$/i.test(observed.literal) &&
|
|
868
|
+
(!idTp || observed.literal.toUpperCase() === idTp)) {
|
|
869
|
+
return false;
|
|
870
|
+
}
|
|
871
|
+
// Only drop string expected-code tokens ("2xx"/"400"). Bare numbers stay
|
|
872
|
+
// because they are commonly length bounds (e.g. 100 for maxLength).
|
|
873
|
+
if (observed.kind === "string" &&
|
|
874
|
+
observed.literal &&
|
|
875
|
+
isHttpExpectedCodeLiteral(observed.literal)) {
|
|
876
|
+
return false;
|
|
877
|
+
}
|
|
878
|
+
return true;
|
|
879
|
+
});
|
|
880
|
+
const raw = candidates[0];
|
|
881
|
+
if (raw) {
|
|
882
|
+
return (observeLiteralToken(raw, field, constants) ?? {
|
|
883
|
+
kind: "unknown",
|
|
884
|
+
text: raw,
|
|
885
|
+
});
|
|
886
|
+
}
|
|
887
|
+
// Only expected-code / TP-label tokens remain -> treat as omitted field value.
|
|
888
|
+
if (positionalTokens.length > 0 && field) {
|
|
889
|
+
return { kind: "missing-key", text: `missing:${field}` };
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
return { kind: "unknown", text: compact.slice(0, 160) };
|
|
893
|
+
}
|
|
894
|
+
function observedLengthValue(observed) {
|
|
895
|
+
if (observed.kind === "empty-string")
|
|
896
|
+
return 0;
|
|
897
|
+
if (observed.kind === "number" && observed.literal !== undefined) {
|
|
898
|
+
const n = Number(observed.literal);
|
|
899
|
+
return Number.isFinite(n) ? n : undefined;
|
|
900
|
+
}
|
|
901
|
+
if (observed.kind === "list" && typeof observed.length === "number") {
|
|
902
|
+
return observed.length;
|
|
903
|
+
}
|
|
904
|
+
if (observed.kind === "string") {
|
|
905
|
+
// Bare digit strings in pytest.param are length tokens, not character payloads.
|
|
906
|
+
if (observed.literal && /^-?\d+$/.test(observed.literal.trim())) {
|
|
907
|
+
const n = Number(observed.literal.trim());
|
|
908
|
+
return Number.isFinite(n) ? n : undefined;
|
|
909
|
+
}
|
|
910
|
+
return observed.length;
|
|
911
|
+
}
|
|
912
|
+
return undefined;
|
|
913
|
+
}
|
|
914
|
+
function isMaxLengthHelper(observed) {
|
|
915
|
+
return (observed.literal === "max-length-helper" ||
|
|
916
|
+
(observed.kind === "name" &&
|
|
917
|
+
/(?:MAX[_-]?LENGTH|LENGTH[_-]?MAX|_MAX_LEN(?:GTH)?$)/i.test(observed.text)));
|
|
918
|
+
}
|
|
919
|
+
function isMinLengthHelper(observed) {
|
|
920
|
+
return (observed.literal === "min-length-helper" ||
|
|
921
|
+
(observed.kind === "name" &&
|
|
922
|
+
/(?:MIN[_-]?LENGTH|LENGTH[_-]?MIN|_MIN_LEN(?:GTH)?$)/i.test(observed.text)));
|
|
923
|
+
}
|
|
924
|
+
function isOversizeLengthHelper(observed) {
|
|
925
|
+
return (observed.literal === "oversize-helper" ||
|
|
926
|
+
(observed.kind === "name" &&
|
|
927
|
+
/(?:OVER|OVERSIZE|TOO[_-]?LONG|MAX[_-]?PLUS[_-]?1|MAXPLUS1)/i.test(observed.text)));
|
|
928
|
+
}
|
|
929
|
+
function compareIntent(intent, observed, bound, example, field) {
|
|
930
|
+
if (intent === "unknown")
|
|
931
|
+
return "UNDETERMINED";
|
|
932
|
+
// Opaque length helpers are resolved below against bound; other names stay undetermined.
|
|
933
|
+
if (observed.kind === "call" ||
|
|
934
|
+
(observed.kind === "name" &&
|
|
935
|
+
!isMaxLengthHelper(observed) &&
|
|
936
|
+
!isMinLengthHelper(observed) &&
|
|
937
|
+
!isOversizeLengthHelper(observed))) {
|
|
938
|
+
return "UNDETERMINED";
|
|
939
|
+
}
|
|
940
|
+
switch (intent) {
|
|
941
|
+
case "empty":
|
|
942
|
+
// Empty-string samples match; OMIT/DEFAULT writers often use missing-key instead.
|
|
943
|
+
if (observed.kind === "missing-key")
|
|
944
|
+
return "MATCH";
|
|
945
|
+
return observed.kind === "empty-string" ||
|
|
946
|
+
(observed.kind === "list" && observed.length === 0) ||
|
|
947
|
+
(observed.kind === "string" &&
|
|
948
|
+
(observed.length === 0 ||
|
|
949
|
+
(typeof observed.literal === "string" &&
|
|
950
|
+
/^\s+$/.test(observed.literal))))
|
|
951
|
+
? "MATCH"
|
|
952
|
+
: observed.kind === "unknown"
|
|
953
|
+
? "UNDETERMINED"
|
|
954
|
+
: "MISMATCH";
|
|
955
|
+
case "missing":
|
|
956
|
+
return observed.kind === "missing-key"
|
|
957
|
+
? "MATCH"
|
|
958
|
+
: observed.kind === "unknown"
|
|
959
|
+
? "UNDETERMINED"
|
|
960
|
+
: "MISMATCH";
|
|
961
|
+
case "null":
|
|
962
|
+
return observed.kind === "none"
|
|
963
|
+
? "MATCH"
|
|
964
|
+
: observed.kind === "unknown"
|
|
965
|
+
? "UNDETERMINED"
|
|
966
|
+
: "MISMATCH";
|
|
967
|
+
case "max":
|
|
968
|
+
if (bound === undefined)
|
|
969
|
+
return "UNDETERMINED";
|
|
970
|
+
{
|
|
971
|
+
if (isMaxLengthHelper(observed))
|
|
972
|
+
return "MATCH";
|
|
973
|
+
const len = observedLengthValue(observed);
|
|
974
|
+
if (len === bound)
|
|
975
|
+
return "MATCH";
|
|
976
|
+
return len !== undefined ? "MISMATCH" : "UNDETERMINED";
|
|
977
|
+
}
|
|
978
|
+
case "max+1":
|
|
979
|
+
if (bound === undefined)
|
|
980
|
+
return "UNDETERMINED";
|
|
981
|
+
{
|
|
982
|
+
if (isOversizeLengthHelper(observed))
|
|
983
|
+
return "MATCH";
|
|
984
|
+
const len = observedLengthValue(observed);
|
|
985
|
+
// Accept base+1 or the oversized length itself when bound already is oversized.
|
|
986
|
+
if (len === bound + 1 || len === bound)
|
|
987
|
+
return "MATCH";
|
|
988
|
+
return len !== undefined ? "MISMATCH" : "UNDETERMINED";
|
|
989
|
+
}
|
|
990
|
+
case "min":
|
|
991
|
+
if (bound === undefined)
|
|
992
|
+
return "UNDETERMINED";
|
|
993
|
+
{
|
|
994
|
+
if (isMinLengthHelper(observed))
|
|
995
|
+
return "MATCH";
|
|
996
|
+
const len = observedLengthValue(observed);
|
|
997
|
+
if (len === bound)
|
|
998
|
+
return "MATCH";
|
|
999
|
+
return len !== undefined ? "MISMATCH" : "UNDETERMINED";
|
|
1000
|
+
}
|
|
1001
|
+
case "min-1":
|
|
1002
|
+
if (bound === undefined)
|
|
1003
|
+
return "UNDETERMINED";
|
|
1004
|
+
{
|
|
1005
|
+
const expectedMin1 = Math.max(0, bound - 1);
|
|
1006
|
+
const len = observedLengthValue(observed);
|
|
1007
|
+
if (len === expectedMin1)
|
|
1008
|
+
return "MATCH";
|
|
1009
|
+
return len !== undefined ? "MISMATCH" : "UNDETERMINED";
|
|
1010
|
+
}
|
|
1011
|
+
case "pattern-invalid":
|
|
1012
|
+
if (observed.kind === "string" && example !== undefined) {
|
|
1013
|
+
return observed.literal === example ? "MATCH" : "MISMATCH";
|
|
1014
|
+
}
|
|
1015
|
+
return "UNDETERMINED";
|
|
1016
|
+
case "wrong-type": {
|
|
1017
|
+
// A string can be the deliberate wrong type for an array/number/object
|
|
1018
|
+
// field. Accept it only when the precise machine scenario supplies the
|
|
1019
|
+
// same explicit example; without that evidence keep the conservative
|
|
1020
|
+
// generic string mismatch behavior.
|
|
1021
|
+
const normalizedExample = example?.replace(/^(["'])([\s\S]*)\1$/, "$2");
|
|
1022
|
+
if ((observed.kind === "string" || observed.kind === "empty-string") &&
|
|
1023
|
+
normalizedExample !== undefined &&
|
|
1024
|
+
observed.literal === normalizedExample) {
|
|
1025
|
+
return "MATCH";
|
|
1026
|
+
}
|
|
1027
|
+
return observed.kind === "number" ||
|
|
1028
|
+
observed.kind === "boolean" ||
|
|
1029
|
+
observed.kind === "list" ||
|
|
1030
|
+
observed.kind === "dict" ||
|
|
1031
|
+
(observed.kind === "string" && field === "tags")
|
|
1032
|
+
? "MATCH"
|
|
1033
|
+
: observed.kind === "string" || observed.kind === "empty-string"
|
|
1034
|
+
? "MISMATCH"
|
|
1035
|
+
: "UNDETERMINED";
|
|
1036
|
+
}
|
|
1037
|
+
case "enum-invalid":
|
|
1038
|
+
// A concrete non-empty invalid enum literal is a valid negative sample.
|
|
1039
|
+
if (observed.kind === "string" && (observed.literal?.length ?? 0) > 0) {
|
|
1040
|
+
return "MATCH";
|
|
1041
|
+
}
|
|
1042
|
+
if (observed.kind === "number" || observed.kind === "boolean") {
|
|
1043
|
+
return "MATCH";
|
|
1044
|
+
}
|
|
1045
|
+
return observed.kind === "unknown" || observed.kind === "missing-key"
|
|
1046
|
+
? "UNDETERMINED"
|
|
1047
|
+
: "MISMATCH";
|
|
1048
|
+
case "nominal":
|
|
1049
|
+
// Request-level nominal (no body field) may legitimately pass None/empty query filters.
|
|
1050
|
+
if (!field && (observed.kind === "none" || observed.kind === "missing-key")) {
|
|
1051
|
+
return "MATCH";
|
|
1052
|
+
}
|
|
1053
|
+
return observed.kind === "string" ||
|
|
1054
|
+
observed.kind === "number" ||
|
|
1055
|
+
observed.kind === "boolean" ||
|
|
1056
|
+
observed.kind === "dict" ||
|
|
1057
|
+
observed.kind === "list"
|
|
1058
|
+
? "MATCH"
|
|
1059
|
+
: observed.kind === "empty-string" || observed.kind === "none"
|
|
1060
|
+
? "MISMATCH"
|
|
1061
|
+
: "UNDETERMINED";
|
|
1062
|
+
default:
|
|
1063
|
+
if (intent.startsWith("custom-literal:")) {
|
|
1064
|
+
const expectedRaw = intent.slice("custom-literal:".length);
|
|
1065
|
+
const expected = normalizeCustomLiteralExpected(expectedRaw);
|
|
1066
|
+
const literal = normalizeScenarioLiteralText(observed.literal ?? "");
|
|
1067
|
+
if (field === "id" &&
|
|
1068
|
+
((/^create-derived-active-id$/i.test(expected) && literal.toLowerCase() === "create-active") ||
|
|
1069
|
+
(/^create-delete-derived-id$/i.test(expected) && literal.toLowerCase() === "create-delete"))) {
|
|
1070
|
+
return "MATCH";
|
|
1071
|
+
}
|
|
1072
|
+
if (isWhitespaceSemanticLiteral(expected) || isWhitespaceOnlyString(expected)) {
|
|
1073
|
+
return observed.kind === "empty-string" ||
|
|
1074
|
+
(observed.kind === "string" && isWhitespaceOnlyString(literal))
|
|
1075
|
+
? "MATCH"
|
|
1076
|
+
: observed.kind === "unknown"
|
|
1077
|
+
? "UNDETERMINED"
|
|
1078
|
+
: "MISMATCH";
|
|
1079
|
+
}
|
|
1080
|
+
if (isWhitespacePaddedSemanticLiteral(expected)) {
|
|
1081
|
+
// trim/padded requires non-empty content after strip; all-whitespace is empty/ws-only.
|
|
1082
|
+
if (isWhitespaceOnlyString(literal) || observed.kind === "empty-string") {
|
|
1083
|
+
return "MISMATCH";
|
|
1084
|
+
}
|
|
1085
|
+
return observed.kind === "string" && isWhitespacePaddedString(literal)
|
|
1086
|
+
? "MATCH"
|
|
1087
|
+
: observed.kind === "unknown"
|
|
1088
|
+
? "UNDETERMINED"
|
|
1089
|
+
: "MISMATCH";
|
|
1090
|
+
}
|
|
1091
|
+
if (isWhitespacePaddedString(expected)) {
|
|
1092
|
+
return observed.kind === "string" && literal === expected
|
|
1093
|
+
? "MATCH"
|
|
1094
|
+
: observed.kind === "unknown"
|
|
1095
|
+
? "UNDETERMINED"
|
|
1096
|
+
: "MISMATCH";
|
|
1097
|
+
}
|
|
1098
|
+
return literal === expected
|
|
1099
|
+
? "MATCH"
|
|
1100
|
+
: observed.kind === "unknown"
|
|
1101
|
+
? "UNDETERMINED"
|
|
1102
|
+
: "MISMATCH";
|
|
1103
|
+
}
|
|
1104
|
+
return "UNDETERMINED";
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
function repairabilityFor(status, intent, observed, example) {
|
|
1108
|
+
if (status === "MATCH")
|
|
1109
|
+
return "none";
|
|
1110
|
+
if (status === "UNDETERMINED")
|
|
1111
|
+
return "undetermined-no-repair";
|
|
1112
|
+
if (observed.kind === "call" || observed.kind === "name") {
|
|
1113
|
+
return "undetermined-no-repair";
|
|
1114
|
+
}
|
|
1115
|
+
if (intent === "unknown")
|
|
1116
|
+
return "blocked";
|
|
1117
|
+
if ((intent === "enum-invalid" || intent === "wrong-type") &&
|
|
1118
|
+
!example &&
|
|
1119
|
+
!intent.startsWith("custom-literal:")) {
|
|
1120
|
+
return "blocked";
|
|
1121
|
+
}
|
|
1122
|
+
if (CLOSED_SET.has(intent) || intent.startsWith("custom-literal:")) {
|
|
1123
|
+
return "repairable";
|
|
1124
|
+
}
|
|
1125
|
+
return "blocked";
|
|
1126
|
+
}
|
|
1127
|
+
function suggestedFixFor(intent, field, bound, example) {
|
|
1128
|
+
if (!field && intent !== "nominal")
|
|
1129
|
+
return undefined;
|
|
1130
|
+
switch (intent) {
|
|
1131
|
+
case "empty":
|
|
1132
|
+
return field ? `set ${field}=""` : 'set value=""';
|
|
1133
|
+
case "missing":
|
|
1134
|
+
return field ? `delete key ${field}` : "delete field key";
|
|
1135
|
+
case "null":
|
|
1136
|
+
return field ? `set ${field}=None` : "set value=None";
|
|
1137
|
+
case "max":
|
|
1138
|
+
return field && bound !== undefined
|
|
1139
|
+
? `set ${field}="x"*${bound}`
|
|
1140
|
+
: undefined;
|
|
1141
|
+
case "max+1":
|
|
1142
|
+
return field && bound !== undefined
|
|
1143
|
+
? `set ${field}="x"*${bound + 1}`
|
|
1144
|
+
: undefined;
|
|
1145
|
+
case "min":
|
|
1146
|
+
return field && bound !== undefined
|
|
1147
|
+
? `set ${field}="x"*${bound}`
|
|
1148
|
+
: undefined;
|
|
1149
|
+
case "min-1":
|
|
1150
|
+
return field && bound !== undefined
|
|
1151
|
+
? `set ${field}="x"*${Math.max(0, bound - 1)}`
|
|
1152
|
+
: undefined;
|
|
1153
|
+
case "pattern-invalid":
|
|
1154
|
+
return field && example
|
|
1155
|
+
? `set ${field}=${JSON.stringify(example)}`
|
|
1156
|
+
: undefined;
|
|
1157
|
+
case "enum-invalid":
|
|
1158
|
+
case "wrong-type":
|
|
1159
|
+
return field && example
|
|
1160
|
+
? `set ${field}=${JSON.stringify(example)}`
|
|
1161
|
+
: undefined;
|
|
1162
|
+
default:
|
|
1163
|
+
if (intent.startsWith("custom-literal:")) {
|
|
1164
|
+
const expected = intent.slice("custom-literal:".length);
|
|
1165
|
+
if (isWhitespaceSemanticLiteral(expected)) {
|
|
1166
|
+
return field ? `set ${field}=" "` : 'set value=" "';
|
|
1167
|
+
}
|
|
1168
|
+
if (isWhitespacePaddedSemanticLiteral(expected)) {
|
|
1169
|
+
return field
|
|
1170
|
+
? `set ${field}=" ${field}-value "`
|
|
1171
|
+
: 'set value=" value "';
|
|
1172
|
+
}
|
|
1173
|
+
return field
|
|
1174
|
+
? `set ${field}=${JSON.stringify(expected)}`
|
|
1175
|
+
: undefined;
|
|
1176
|
+
}
|
|
1177
|
+
return undefined;
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
function scenarioFunctionRegion(source, tpId) {
|
|
1181
|
+
const idIndex = source.indexOf(`id="${tpId}"`) >= 0
|
|
1182
|
+
? source.indexOf(`id="${tpId}"`)
|
|
1183
|
+
: source.indexOf(`id='${tpId}'`);
|
|
1184
|
+
if (idIndex < 0)
|
|
1185
|
+
return "";
|
|
1186
|
+
const functionStart = source.indexOf("def test_", idIndex);
|
|
1187
|
+
if (functionStart < 0)
|
|
1188
|
+
return "";
|
|
1189
|
+
const nextDecorator = source.indexOf("\n@pytest", functionStart + 1);
|
|
1190
|
+
const nextFunction = source.indexOf("\ndef test_", functionStart + 1);
|
|
1191
|
+
const candidates = [nextDecorator, nextFunction].filter((index) => index > functionStart);
|
|
1192
|
+
const end = candidates.length > 0 ? Math.min(...candidates) : source.length;
|
|
1193
|
+
return source.slice(functionStart, end);
|
|
1194
|
+
}
|
|
1195
|
+
function hasCreateDerivedJourney(source, tpId) {
|
|
1196
|
+
const region = scenarioFunctionRegion(source, tpId);
|
|
1197
|
+
return /\b_create[A-Za-z0-9_]*\s*\(/.test(region);
|
|
1198
|
+
}
|
|
1199
|
+
function hasCreateDeleteDerivedJourney(source, tpId) {
|
|
1200
|
+
const region = scenarioFunctionRegion(source, tpId);
|
|
1201
|
+
return /\b_create_deleted_id\s*\(/.test(region) ||
|
|
1202
|
+
(/\b_create[A-Za-z0-9_]*\s*\(/.test(region) &&
|
|
1203
|
+
(/\b_delete[A-Za-z0-9_]*\s*\(/.test(region) || /\.delete\s*\(/.test(region) || /\.request\s*\(\s*["']DELETE["']/i.test(region)));
|
|
1204
|
+
}
|
|
1205
|
+
export async function assessBackendScenarioParamConsistency(input) {
|
|
1206
|
+
const cases = await listMarkdownCases(input.workspaceRoot, input.layout);
|
|
1207
|
+
const entries = [];
|
|
1208
|
+
const assetPaths = new Set();
|
|
1209
|
+
for (const testCase of cases) {
|
|
1210
|
+
if (!testCase.scriptPath)
|
|
1211
|
+
continue;
|
|
1212
|
+
assetPaths.add(testCase.scriptPath);
|
|
1213
|
+
const absolute = path.join(input.workspaceRoot, testCase.scriptPath);
|
|
1214
|
+
const source = (await exists(absolute))
|
|
1215
|
+
? await readFile(absolute, "utf8")
|
|
1216
|
+
: "";
|
|
1217
|
+
for (const tpId of testCase.variantTestPoints) {
|
|
1218
|
+
const inferred = inferScenarioParamIntent({
|
|
1219
|
+
tpId,
|
|
1220
|
+
caseBody: testCase.body,
|
|
1221
|
+
});
|
|
1222
|
+
const fallbackSourced = inferred.intentSource === "tp-fallback";
|
|
1223
|
+
const constants = source ? collectPythonStringConstants(source) : undefined;
|
|
1224
|
+
const block = source ? extractPytestParamBlock(source, tpId) : undefined;
|
|
1225
|
+
const parameterNames = source ? extractPytestParamParameterNames(source, tpId) : [];
|
|
1226
|
+
const observed = observeParamFeatures(block, inferred.field, constants, parameterNames);
|
|
1227
|
+
// Request-level / health checks often have no pytest.param payload row,
|
|
1228
|
+
// or only a TP-id label positional (no field value).
|
|
1229
|
+
const requestLevelNoParam = Boolean(source) &&
|
|
1230
|
+
(inferred.intent === "nominal" || inferred.intent === "unknown") &&
|
|
1231
|
+
((!block && observed.text === "param-block-missing") ||
|
|
1232
|
+
(Boolean(block) &&
|
|
1233
|
+
!inferred.field &&
|
|
1234
|
+
(observed.kind === "unknown" ||
|
|
1235
|
+
observed.kind === "missing-key" ||
|
|
1236
|
+
(observed.kind === "string" &&
|
|
1237
|
+
Boolean(observed.literal) &&
|
|
1238
|
+
/^TP-[A-Z0-9-]+$/i.test(observed.literal ?? "")))));
|
|
1239
|
+
const derivedJourneyMatch = Boolean(source) &&
|
|
1240
|
+
inferred.field === "id" &&
|
|
1241
|
+
((/^custom-literal:(?:create-delete-derived(?:-id)?|deleted-existing-derived)$/i.test(inferred.intent) &&
|
|
1242
|
+
hasCreateDeleteDerivedJourney(source, tpId)) ||
|
|
1243
|
+
(/^custom-literal:(?:create-derived(?:-active-id|-id)?|active-existing-derived)$/i.test(inferred.intent) &&
|
|
1244
|
+
hasCreateDerivedJourney(source, tpId)));
|
|
1245
|
+
const status = !source
|
|
1246
|
+
? "UNDETERMINED"
|
|
1247
|
+
: derivedJourneyMatch
|
|
1248
|
+
? "MATCH"
|
|
1249
|
+
: requestLevelNoParam
|
|
1250
|
+
? "MATCH"
|
|
1251
|
+
: fallbackSourced
|
|
1252
|
+
? "UNDETERMINED"
|
|
1253
|
+
: compareIntent(inferred.intent, observed, inferred.bound, inferred.example, inferred.field);
|
|
1254
|
+
const repairability = repairabilityFor(status, inferred.intent, observed, inferred.example);
|
|
1255
|
+
entries.push({
|
|
1256
|
+
caseId: testCase.caseId,
|
|
1257
|
+
tpId,
|
|
1258
|
+
field: inferred.field,
|
|
1259
|
+
intent: inferred.intent,
|
|
1260
|
+
observed: observed.text,
|
|
1261
|
+
status,
|
|
1262
|
+
repairability,
|
|
1263
|
+
suggestedFix: fallbackSourced
|
|
1264
|
+
? undefined
|
|
1265
|
+
: suggestedFixFor(inferred.intent, inferred.field, inferred.bound, inferred.example),
|
|
1266
|
+
scriptPath: testCase.scriptPath,
|
|
1267
|
+
bound: inferred.bound,
|
|
1268
|
+
example: inferred.example,
|
|
1269
|
+
});
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
const assetHashes = [];
|
|
1273
|
+
for (const rel of [...assetPaths].sort()) {
|
|
1274
|
+
const absolute = path.join(input.workspaceRoot, rel);
|
|
1275
|
+
if (!(await exists(absolute)))
|
|
1276
|
+
continue;
|
|
1277
|
+
assetHashes.push({
|
|
1278
|
+
path: rel,
|
|
1279
|
+
sha256: sha256(await readFile(absolute)),
|
|
1280
|
+
});
|
|
1281
|
+
}
|
|
1282
|
+
const repairableCount = entries.filter((entry) => entry.repairability === "repairable" && entry.status === "MISMATCH").length;
|
|
1283
|
+
const matchCount = entries.filter((entry) => entry.status === "MATCH").length;
|
|
1284
|
+
const mismatchCount = entries.filter((entry) => entry.status === "MISMATCH").length;
|
|
1285
|
+
const undeterminedCount = entries.filter((entry) => entry.status === "UNDETERMINED").length;
|
|
1286
|
+
const overallStatus = mismatchCount > 0
|
|
1287
|
+
? "FAIL"
|
|
1288
|
+
: matchCount === 0 && undeterminedCount > 0
|
|
1289
|
+
? "UNAVAILABLE"
|
|
1290
|
+
: undeterminedCount > 0
|
|
1291
|
+
? "PARTIAL"
|
|
1292
|
+
: "PASS";
|
|
1293
|
+
const facts = {
|
|
1294
|
+
schemaId: BACKEND_TEST_SCENARIO_PARAM_FACTS_SCHEMA_ID,
|
|
1295
|
+
phase: input.phase,
|
|
1296
|
+
overallStatus,
|
|
1297
|
+
repairEligible: input.phase === "initial" && repairableCount > 0,
|
|
1298
|
+
repairAttempt: input.repairAttempt ?? (input.phase === "final" ? 1 : 0),
|
|
1299
|
+
strictScenarioParamGate: input.strictScenarioParamGate === true,
|
|
1300
|
+
entries,
|
|
1301
|
+
assetHashes,
|
|
1302
|
+
summary: {
|
|
1303
|
+
matchCount,
|
|
1304
|
+
mismatchCount,
|
|
1305
|
+
undeterminedCount,
|
|
1306
|
+
repairableCount,
|
|
1307
|
+
blockedCount: entries.filter((entry) => entry.repairability === "blocked")
|
|
1308
|
+
.length,
|
|
1309
|
+
},
|
|
1310
|
+
};
|
|
1311
|
+
const markdown = [
|
|
1312
|
+
"# Backend Test Scenario-Param Consistency",
|
|
1313
|
+
"",
|
|
1314
|
+
`## Status`,
|
|
1315
|
+
"",
|
|
1316
|
+
facts.overallStatus,
|
|
1317
|
+
"",
|
|
1318
|
+
`## Summary`,
|
|
1319
|
+
"",
|
|
1320
|
+
`- Phase: ${facts.phase}`,
|
|
1321
|
+
`- Repair eligible: ${facts.repairEligible}`,
|
|
1322
|
+
`- Repair attempt: ${facts.repairAttempt}`,
|
|
1323
|
+
`- MATCH: ${facts.summary.matchCount}`,
|
|
1324
|
+
`- MISMATCH: ${facts.summary.mismatchCount}`,
|
|
1325
|
+
`- UNDETERMINED: ${facts.summary.undeterminedCount}`,
|
|
1326
|
+
`- Repairable mismatches: ${facts.summary.repairableCount}`,
|
|
1327
|
+
`- Blocked: ${facts.summary.blockedCount}`,
|
|
1328
|
+
"",
|
|
1329
|
+
"## Entries",
|
|
1330
|
+
"",
|
|
1331
|
+
"| Case | TP | Field | Intent | Observed | Status | Repairability | Suggested fix |",
|
|
1332
|
+
"|---|---|---|---|---|---|---|---|",
|
|
1333
|
+
...facts.entries.map((entry) => `| ${entry.caseId} | ${entry.tpId} | ${entry.field ?? "—"} | ${entry.intent} | ${entry.observed.replaceAll("|", "\\|")} | ${entry.status} | ${entry.repairability} | ${entry.suggestedFix ?? "—"} |`),
|
|
1334
|
+
"",
|
|
1335
|
+
].join("\n");
|
|
1336
|
+
return { facts, markdown };
|
|
1337
|
+
}
|
|
1338
|
+
export async function writeBackendScenarioParamArtifacts(input) {
|
|
1339
|
+
const contractsDir = path.join(input.runDir, "contracts");
|
|
1340
|
+
const reportsDir = path.join(input.runDir, "reports");
|
|
1341
|
+
await mkdir(contractsDir, { recursive: true });
|
|
1342
|
+
await mkdir(reportsDir, { recursive: true });
|
|
1343
|
+
const stem = input.facts.phase === "final"
|
|
1344
|
+
? "backend-test-scenario-param-consistency-final"
|
|
1345
|
+
: "backend-test-scenario-param-consistency";
|
|
1346
|
+
const factsPath = path.join(contractsDir, `${stem}.json`);
|
|
1347
|
+
const reportPath = path.join(reportsDir, `${stem}.md`);
|
|
1348
|
+
const parsed = factsSchema.parse(input.facts);
|
|
1349
|
+
await writeFile(factsPath, JSON.stringify(parsed, null, 2), "utf8");
|
|
1350
|
+
await writeFile(reportPath, input.markdown, "utf8");
|
|
1351
|
+
// Keep a stable non-suffixed alias for final as well for consumers.
|
|
1352
|
+
if (input.facts.phase === "final") {
|
|
1353
|
+
await writeFile(path.join(contractsDir, "backend-test-scenario-param-consistency-facts.json"), JSON.stringify(parsed, null, 2), "utf8");
|
|
1354
|
+
await writeFile(path.join(reportsDir, "backend-test-scenario-param-consistency.md"), input.markdown, "utf8");
|
|
1355
|
+
}
|
|
1356
|
+
else {
|
|
1357
|
+
await writeFile(path.join(contractsDir, "backend-test-scenario-param-consistency-facts.json"), JSON.stringify(parsed, null, 2), "utf8");
|
|
1358
|
+
}
|
|
1359
|
+
return { factsPath, reportPath };
|
|
1360
|
+
}
|
|
1361
|
+
export async function readBackendScenarioParamFacts(filePath) {
|
|
1362
|
+
const raw = JSON.parse(await readFile(filePath, "utf8"));
|
|
1363
|
+
return factsSchema.parse(raw);
|
|
1364
|
+
}
|
|
1365
|
+
function replaceFieldInDictLiteral(dictLiteral, field, mode, valueLiteral) {
|
|
1366
|
+
const fieldPattern = new RegExp(`([\\t ]*)(["']${field.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}["']\\s*:\\s*)([^,}\\n]+)`);
|
|
1367
|
+
if (mode === "delete") {
|
|
1368
|
+
if (!fieldPattern.test(dictLiteral))
|
|
1369
|
+
return dictLiteral;
|
|
1370
|
+
return dictLiteral
|
|
1371
|
+
.replace(new RegExp(`,\\s*["']${field.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}["']\\s*:\\s*[^,}\\n]+`), "")
|
|
1372
|
+
.replace(new RegExp(`["']${field.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}["']\\s*:\\s*[^,}\\n]+\\s*,?`), "");
|
|
1373
|
+
}
|
|
1374
|
+
if (fieldPattern.test(dictLiteral)) {
|
|
1375
|
+
return dictLiteral.replace(fieldPattern, `$1$2${valueLiteral}`);
|
|
1376
|
+
}
|
|
1377
|
+
// Insert before closing brace. Normalize an existing trailing comma first so
|
|
1378
|
+
// adding a missing field can never produce `,,` and corrupt Python syntax.
|
|
1379
|
+
const withoutClosingBrace = dictLiteral.replace(/\s*\}$/, "");
|
|
1380
|
+
const trimmed = withoutClosingBrace.replace(/,\s*$/, "").trimEnd();
|
|
1381
|
+
const hasEntries = trimmed.trim() !== "{";
|
|
1382
|
+
return `${trimmed}${hasEntries ? ", " : ""}${JSON.stringify(field)}: ${valueLiteral}}`;
|
|
1383
|
+
}
|
|
1384
|
+
export function deterministicRewriteScenarioParam(input) {
|
|
1385
|
+
const { entry } = input;
|
|
1386
|
+
if (entry.repairability !== "repairable" || !entry.field) {
|
|
1387
|
+
return { ok: false, source: input.source, detail: "not repairable or missing field" };
|
|
1388
|
+
}
|
|
1389
|
+
const block = extractPytestParamBlock(input.source, entry.tpId);
|
|
1390
|
+
if (!block) {
|
|
1391
|
+
return { ok: false, source: input.source, detail: "param block not found" };
|
|
1392
|
+
}
|
|
1393
|
+
// Prefer the first object literal in the param block (payload dict).
|
|
1394
|
+
const dictMatch = /\{[^{}]*\}/.exec(block);
|
|
1395
|
+
if (!dictMatch) {
|
|
1396
|
+
return { ok: false, source: input.source, detail: "no dict payload in param" };
|
|
1397
|
+
}
|
|
1398
|
+
const originalDict = dictMatch[0];
|
|
1399
|
+
const field = entry.field;
|
|
1400
|
+
const bound = entry.bound;
|
|
1401
|
+
let valueLiteral;
|
|
1402
|
+
let mode = "set";
|
|
1403
|
+
switch (entry.intent) {
|
|
1404
|
+
case "empty":
|
|
1405
|
+
valueLiteral = '""';
|
|
1406
|
+
break;
|
|
1407
|
+
case "missing":
|
|
1408
|
+
mode = "delete";
|
|
1409
|
+
break;
|
|
1410
|
+
case "null":
|
|
1411
|
+
valueLiteral = "None";
|
|
1412
|
+
break;
|
|
1413
|
+
case "max":
|
|
1414
|
+
case "min":
|
|
1415
|
+
if (bound === undefined) {
|
|
1416
|
+
return { ok: false, source: input.source, detail: `missing bound for ${entry.intent}` };
|
|
1417
|
+
}
|
|
1418
|
+
valueLiteral = `"x" * ${bound}`;
|
|
1419
|
+
break;
|
|
1420
|
+
case "max+1":
|
|
1421
|
+
if (bound === undefined) {
|
|
1422
|
+
return { ok: false, source: input.source, detail: "missing bound for max+1" };
|
|
1423
|
+
}
|
|
1424
|
+
valueLiteral = `"x" * ${bound + 1}`;
|
|
1425
|
+
break;
|
|
1426
|
+
case "min-1":
|
|
1427
|
+
if (bound === undefined) {
|
|
1428
|
+
return { ok: false, source: input.source, detail: "missing bound for min-1" };
|
|
1429
|
+
}
|
|
1430
|
+
valueLiteral = `"x" * ${Math.max(0, bound - 1)}`;
|
|
1431
|
+
break;
|
|
1432
|
+
case "pattern-invalid":
|
|
1433
|
+
if (entry.example === undefined) {
|
|
1434
|
+
return {
|
|
1435
|
+
ok: false,
|
|
1436
|
+
source: input.source,
|
|
1437
|
+
detail: "missing example for pattern-invalid",
|
|
1438
|
+
};
|
|
1439
|
+
}
|
|
1440
|
+
valueLiteral = JSON.stringify(entry.example);
|
|
1441
|
+
break;
|
|
1442
|
+
default:
|
|
1443
|
+
if (entry.intent.startsWith("custom-literal:")) {
|
|
1444
|
+
valueLiteral = JSON.stringify(entry.intent.slice("custom-literal:".length));
|
|
1445
|
+
break;
|
|
1446
|
+
}
|
|
1447
|
+
return {
|
|
1448
|
+
ok: false,
|
|
1449
|
+
source: input.source,
|
|
1450
|
+
detail: `intent ${entry.intent} not in deterministic closed set`,
|
|
1451
|
+
};
|
|
1452
|
+
}
|
|
1453
|
+
const nextDict = replaceFieldInDictLiteral(originalDict, field, mode, valueLiteral);
|
|
1454
|
+
if (nextDict === originalDict) {
|
|
1455
|
+
return { ok: false, source: input.source, detail: "rewrite produced no change" };
|
|
1456
|
+
}
|
|
1457
|
+
const nextBlock = block.replace(originalDict, nextDict);
|
|
1458
|
+
const nextSource = input.source.replace(block, nextBlock);
|
|
1459
|
+
if (nextSource.includes("pytest.skip") || nextSource.includes("pytest.xfail")) {
|
|
1460
|
+
return { ok: false, source: input.source, detail: "rewrite introduced skip/xfail" };
|
|
1461
|
+
}
|
|
1462
|
+
return { ok: true, source: nextSource, detail: "rewritten" };
|
|
1463
|
+
}
|
|
1464
|
+
function validatePythonSyntaxWithoutExecution(source) {
|
|
1465
|
+
// POSIX images usually expose `python3`; Windows often has a real `python`
|
|
1466
|
+
// plus a Microsoft Store `python3` stub that exits nonzero without parsing.
|
|
1467
|
+
// A stub/missing interpreter must not silently roll back an otherwise-valid
|
|
1468
|
+
// deterministic rewrite.
|
|
1469
|
+
const candidates = process.platform === "win32" ? ["python", "python3"] : ["python3", "python"];
|
|
1470
|
+
let lastError;
|
|
1471
|
+
for (const interpreter of candidates) {
|
|
1472
|
+
const result = spawnSync(interpreter, ["-c", "import ast,sys; ast.parse(sys.stdin.read())"], {
|
|
1473
|
+
input: source,
|
|
1474
|
+
encoding: "utf8",
|
|
1475
|
+
env: {
|
|
1476
|
+
...process.env,
|
|
1477
|
+
PYTHONDONTWRITEBYTECODE: "1",
|
|
1478
|
+
PYTHONUTF8: "1",
|
|
1479
|
+
},
|
|
1480
|
+
timeout: 15_000,
|
|
1481
|
+
});
|
|
1482
|
+
if (result.error) {
|
|
1483
|
+
lastError = result.error.message;
|
|
1484
|
+
continue;
|
|
1485
|
+
}
|
|
1486
|
+
if (result.status !== 0) {
|
|
1487
|
+
const detail = String(result.stderr || result.stdout || "invalid Python syntax")
|
|
1488
|
+
.trim()
|
|
1489
|
+
.replace(/\s+/g, " ")
|
|
1490
|
+
.slice(0, 500);
|
|
1491
|
+
const looksLikeStub = !detail ||
|
|
1492
|
+
/microsoft store|windowsapps|python was not found|not recognized/i.test(detail);
|
|
1493
|
+
if (looksLikeStub) {
|
|
1494
|
+
lastError = detail || `exit ${result.status}`;
|
|
1495
|
+
continue;
|
|
1496
|
+
}
|
|
1497
|
+
return { ok: false, detail: `python syntax validation failed: ${detail}` };
|
|
1498
|
+
}
|
|
1499
|
+
return { ok: true, detail: "python ast.parse PASS" };
|
|
1500
|
+
}
|
|
1501
|
+
return {
|
|
1502
|
+
ok: false,
|
|
1503
|
+
detail: `python syntax validation unavailable: ${lastError ?? "python/python3 not found"}`,
|
|
1504
|
+
};
|
|
1505
|
+
}
|
|
1506
|
+
export async function applyDeterministicScenarioParamRepairs(input) {
|
|
1507
|
+
const repairable = input.facts.entries.filter((entry) => entry.status === "MISMATCH" && entry.repairability === "repairable");
|
|
1508
|
+
const byScript = new Map();
|
|
1509
|
+
for (const entry of repairable) {
|
|
1510
|
+
if (!entry.scriptPath)
|
|
1511
|
+
continue;
|
|
1512
|
+
const list = byScript.get(entry.scriptPath) ?? [];
|
|
1513
|
+
list.push(entry);
|
|
1514
|
+
byScript.set(entry.scriptPath, list);
|
|
1515
|
+
}
|
|
1516
|
+
const beforeHashes = [...input.facts.assetHashes];
|
|
1517
|
+
const changedFiles = [];
|
|
1518
|
+
const repaired = [];
|
|
1519
|
+
const skipped = [];
|
|
1520
|
+
const auditEntries = [];
|
|
1521
|
+
for (const [scriptPath, entries] of byScript) {
|
|
1522
|
+
const absolute = path.join(input.workspaceRoot, scriptPath);
|
|
1523
|
+
if (!(await exists(absolute))) {
|
|
1524
|
+
for (const entry of entries) {
|
|
1525
|
+
skipped.push({ tpId: entry.tpId, detail: "script missing" });
|
|
1526
|
+
auditEntries.push({
|
|
1527
|
+
tpId: entry.tpId,
|
|
1528
|
+
result: "skipped",
|
|
1529
|
+
detail: "script missing",
|
|
1530
|
+
});
|
|
1531
|
+
}
|
|
1532
|
+
continue;
|
|
1533
|
+
}
|
|
1534
|
+
let source = await readFile(absolute, "utf8");
|
|
1535
|
+
const staged = [];
|
|
1536
|
+
for (const entry of entries) {
|
|
1537
|
+
const result = deterministicRewriteScenarioParam({ source, entry });
|
|
1538
|
+
if (!result.ok) {
|
|
1539
|
+
skipped.push({ tpId: entry.tpId, detail: result.detail });
|
|
1540
|
+
auditEntries.push({
|
|
1541
|
+
tpId: entry.tpId,
|
|
1542
|
+
result: "skipped-to-pi",
|
|
1543
|
+
detail: result.detail,
|
|
1544
|
+
});
|
|
1545
|
+
continue;
|
|
1546
|
+
}
|
|
1547
|
+
source = result.source;
|
|
1548
|
+
staged.push({ entry, detail: result.detail });
|
|
1549
|
+
}
|
|
1550
|
+
if (staged.length > 0) {
|
|
1551
|
+
const syntax = validatePythonSyntaxWithoutExecution(source);
|
|
1552
|
+
if (!syntax.ok) {
|
|
1553
|
+
for (const item of staged) {
|
|
1554
|
+
skipped.push({ tpId: item.entry.tpId, detail: syntax.detail });
|
|
1555
|
+
auditEntries.push({
|
|
1556
|
+
tpId: item.entry.tpId,
|
|
1557
|
+
result: "rolled-back-invalid-python",
|
|
1558
|
+
detail: syntax.detail,
|
|
1559
|
+
});
|
|
1560
|
+
}
|
|
1561
|
+
continue;
|
|
1562
|
+
}
|
|
1563
|
+
await writeFile(absolute, source, "utf8");
|
|
1564
|
+
changedFiles.push(scriptPath);
|
|
1565
|
+
for (const item of staged) {
|
|
1566
|
+
repaired.push(item.entry.tpId);
|
|
1567
|
+
auditEntries.push({
|
|
1568
|
+
tpId: item.entry.tpId,
|
|
1569
|
+
result: "rewritten",
|
|
1570
|
+
detail: `${item.detail}; ${syntax.detail}`,
|
|
1571
|
+
});
|
|
1572
|
+
}
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
const afterHashes = [];
|
|
1576
|
+
for (const item of beforeHashes) {
|
|
1577
|
+
const absolute = path.join(input.workspaceRoot, item.path);
|
|
1578
|
+
if (!(await exists(absolute)))
|
|
1579
|
+
continue;
|
|
1580
|
+
afterHashes.push({
|
|
1581
|
+
path: item.path,
|
|
1582
|
+
sha256: sha256(await readFile(absolute)),
|
|
1583
|
+
});
|
|
1584
|
+
}
|
|
1585
|
+
return {
|
|
1586
|
+
changedFiles,
|
|
1587
|
+
repaired,
|
|
1588
|
+
skipped,
|
|
1589
|
+
audit: { beforeHashes, afterHashes, entries: auditEntries },
|
|
1590
|
+
};
|
|
1591
|
+
}
|
|
1592
|
+
export async function writeScenarioParamRepairAudit(input) {
|
|
1593
|
+
const contractsDir = path.join(input.runDir, "contracts");
|
|
1594
|
+
await mkdir(contractsDir, { recursive: true });
|
|
1595
|
+
const filePath = path.join(contractsDir, "backend-test-scenario-param-repair-audit.json");
|
|
1596
|
+
await writeFile(filePath, JSON.stringify({
|
|
1597
|
+
schemaId: "backend-test-scenario-param-repair-audit-v1",
|
|
1598
|
+
changedFiles: input.changedFiles,
|
|
1599
|
+
...input.audit,
|
|
1600
|
+
}, null, 2), "utf8");
|
|
1601
|
+
return filePath;
|
|
1602
|
+
}
|
|
1603
|
+
export function renderBackendTestFailureAnalysis(input) {
|
|
1604
|
+
const overviewNarrative = input.failed + input.errors === 0
|
|
1605
|
+
? "本轮无失败用例。报告仍保留场景-参数一致性与执行摘要,供审计。"
|
|
1606
|
+
: `本轮共 ${input.failed} 个失败用例、${input.errors} 个错误用例。分类优先参考场景-参数一致性 final facts,再结合断言与环境证据。`;
|
|
1607
|
+
return [
|
|
1608
|
+
"# 测试失败用例分析报告",
|
|
1609
|
+
"",
|
|
1610
|
+
`> 报告生成时间:${input.generatedAt}`,
|
|
1611
|
+
`> 测试报告来源:${input.htmlReportPath}`,
|
|
1612
|
+
`> 测试总计:${input.total} 个用例(${input.passed} Passed, ${input.failed} Failed, ${input.errors} Error)`,
|
|
1613
|
+
`> 测试耗时:${input.durationLabel}`,
|
|
1614
|
+
`> 测试环境:${input.environmentSummary.split("\n")[0] ?? "unavailable"}`,
|
|
1615
|
+
`> 接口:${input.primaryOperation ?? "—"}`,
|
|
1616
|
+
`> 环境基址:${input.baseUrl ?? "—"}`,
|
|
1617
|
+
`> 场景-参数一致性:${input.scenarioParamFinalStatus}(repairAttempt=${input.repairAttempt})`,
|
|
1618
|
+
"",
|
|
1619
|
+
"---",
|
|
1620
|
+
"",
|
|
1621
|
+
"## 一、失败用例概览",
|
|
1622
|
+
"",
|
|
1623
|
+
overviewNarrative,
|
|
1624
|
+
"",
|
|
1625
|
+
"| # | 测试用例 | 场景描述 | 期望码 | 实际码 | 失败分类 |",
|
|
1626
|
+
"|---|---------|---------|--------|--------|---------|",
|
|
1627
|
+
...(input.failures.length
|
|
1628
|
+
? input.failures.map((item, index) => `| ${index + 1} | ${item.caseId} / ${item.name} | ${item.scenario.replaceAll("|", "\\|")} | ${item.expectedCode ?? "—"} | ${item.actualCode ?? "—"} | ${item.classification} |`)
|
|
1629
|
+
: ["| — | — | — | — | — | 无失败 |"]),
|
|
1630
|
+
"",
|
|
1631
|
+
"---",
|
|
1632
|
+
"",
|
|
1633
|
+
"## 二、逐个失败用例详细分析",
|
|
1634
|
+
"",
|
|
1635
|
+
...(input.failures.length
|
|
1636
|
+
? input.failures.flatMap((item, index) => [
|
|
1637
|
+
`### 失败用例 ${index + 1}:${item.name}`,
|
|
1638
|
+
"| 项目 | 内容 |",
|
|
1639
|
+
"|------|------|",
|
|
1640
|
+
`| 用例 ID | ${item.caseId} |`,
|
|
1641
|
+
`| 接口 URL | ${item.scriptPath ?? "—"} |`,
|
|
1642
|
+
`| 场景描述 | ${item.scenario.replaceAll("|", "\\|")} |`,
|
|
1643
|
+
`| 需求依据 | ${item.requirementRef ?? "—"} |`,
|
|
1644
|
+
`| 期望码 / 实际码 | ${item.expectedCode ?? "—"} / ${item.actualCode ?? "—"} |`,
|
|
1645
|
+
`| 耗时 | ${item.durationLabel ?? "—"} |`,
|
|
1646
|
+
`| 场景-参数评估 | ${item.scenarioParamStatus ?? "UNAVAILABLE"} |`,
|
|
1647
|
+
"",
|
|
1648
|
+
`**传入参数:** ${item.requestSummary ?? "见 pytest-html 执行日志"}`,
|
|
1649
|
+
"",
|
|
1650
|
+
`**失败原因:** ${item.message.replaceAll("|", "\\|")}`,
|
|
1651
|
+
"",
|
|
1652
|
+
`**缺陷定位:** ${item.classification}`,
|
|
1653
|
+
"",
|
|
1654
|
+
])
|
|
1655
|
+
: ["本轮无失败用例详析。", ""]),
|
|
1656
|
+
].join("\n");
|
|
1657
|
+
}
|
|
1658
|
+
export function classifyBackendTestFailureWithScenarioParam(input) {
|
|
1659
|
+
if (input.scenarioParamStatus === "MISMATCH") {
|
|
1660
|
+
return "测试脚本参数与场景不匹配(或自修后仍不一致)";
|
|
1661
|
+
}
|
|
1662
|
+
const evidence = [input.message, input.details].filter(Boolean).join("\n");
|
|
1663
|
+
if (/ImportError|ModuleNotFoundError|fixture|CONNECTION|ECONNREFUSED/i.test(evidence)) {
|
|
1664
|
+
return "环境或测试基础设施问题";
|
|
1665
|
+
}
|
|
1666
|
+
if (/assert\s+\d{3}\s*==\s*\d{3}|状态码/i.test(evidence)) {
|
|
1667
|
+
return "后端行为与契约不一致";
|
|
1668
|
+
}
|
|
1669
|
+
return "证据不足-待确认";
|
|
1670
|
+
}
|