@tea-agent/loop-agent 0.1.0-fe-test.2 → 0.1.0-fe-test.4
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 +6 -3
- package/CHANGELOG.md +607 -93
- package/README.md +11 -5
- package/bin/loop-agent.js +7 -3
- package/dist/adapters/context-transfer/optional-pi-handoff.js +31 -0
- package/dist/adapters/context-transfer/pi-session.js +61 -0
- package/dist/application/dag/generate-task-dag.js +90 -21
- package/dist/application/dag/run-dag.js +41 -0
- package/dist/application/task-lifecycle/advance.js +40 -5
- package/dist/application/task-lifecycle/observe.js +171 -17
- package/dist/application/task-lifecycle/plan-transitions.js +42 -7
- package/dist/application/task-lifecycle/recommendations.js +13 -2
- package/dist/build-stamp.json +3 -3
- package/dist/cli/command-definitions.js +44 -10
- package/dist/cli/program.js +82 -6
- package/dist/cli/update/notifier.js +2 -2
- package/dist/cli/update/runtime-activity.js +1 -29
- package/dist/cli.js +2 -1
- package/dist/commands/client-recovery.js +11 -36
- package/dist/commands/dag-artifact.js +284 -0
- package/dist/commands/dag-context.js +184 -0
- package/dist/commands/dag-follow-up.js +138 -0
- package/dist/commands/dag-rerun-task.js +2 -0
- package/dist/commands/dag-rerun.js +261 -2
- package/dist/commands/init-model-catalog.js +486 -0
- package/dist/commands/init-upgrade.js +265 -97
- package/dist/commands/init.js +455 -28
- package/dist/commands/inspect-next.js +8 -0
- package/dist/commands/task-advance.js +73 -1
- package/dist/commands/task-source-prepare.js +5 -0
- package/dist/commands/task-status.js +1 -0
- package/dist/executors/dag-pi-executor.js +4321 -231
- package/dist/executors/pi-event-serializer.js +42 -1
- package/dist/executors/pi-executor.js +70 -6
- package/dist/executors/pi-extension-resolver.js +245 -0
- package/dist/executors/pi-playwright-cli-tool.js +74 -28
- package/dist/executors/pi-read-budget-policy.js +239 -0
- package/dist/executors/pi-sdk-executor.js +263 -59
- package/dist/executors/pi-writer-tool-policy.js +57 -1
- package/dist/executors/shell-executor.js +1443 -240
- package/dist/executors/shell-write-guard.js +14 -0
- package/dist/executors/workspace-write-snapshot.js +68 -0
- package/dist/governance/checks.js +1 -0
- package/dist/{worker → infrastructure}/console/app-data.js +4 -0
- package/dist/infrastructure/console/artifact-revision-store.js +430 -0
- package/dist/infrastructure/console/context-export-store.js +160 -0
- package/dist/infrastructure/console/dir-lock.js +132 -0
- package/dist/infrastructure/console/operation-store.js +417 -0
- package/dist/infrastructure/harness/artifact-store.js +10 -1
- package/dist/infrastructure/harness/atomic-write.js +35 -2
- package/dist/shared/context-transfer/artifact-revision.js +172 -0
- package/dist/shared/context-transfer.js +418 -0
- package/dist/shared/dag-failure-category.js +150 -0
- package/dist/shared/dag-prompt-override.js +27 -0
- package/dist/shared/openspec-spec.js +70 -4
- package/dist/shared/operator/capabilities.js +65 -4
- package/dist/shared/operator/safe-run-summary.js +1 -0
- package/dist/shared/path-safety.js +93 -0
- package/dist/shared/pi-context-pressure/checkpoint.js +116 -0
- package/dist/shared/pi-context-pressure/compaction-policy.js +151 -0
- package/dist/shared/pi-context-pressure/env.js +58 -0
- package/dist/shared/pi-context-pressure/extension.js +100 -0
- package/dist/shared/pi-context-pressure/index.js +7 -0
- package/dist/shared/pi-context-pressure/overflow.js +252 -0
- package/dist/shared/pi-context-pressure/sift-bridge.js +386 -0
- package/dist/shared/pi-context-pressure/telemetry.js +51 -0
- package/dist/shared/playwright-cli-command-policy.js +15 -0
- package/dist/shared/preview.js +28 -4
- package/dist/shared/update/console-notifier.js +100 -0
- package/dist/{cli → shared}/update/npm-client.js +70 -15
- package/dist/{cli → shared}/update/state.js +41 -13
- package/dist/task/config-types.js +125 -6
- package/dist/task/contract/adopt.js +4 -0
- package/dist/task/contract/apply.js +11 -1
- package/dist/task/contract/constants.js +3 -0
- package/dist/task/contract/diff.js +26 -0
- package/dist/task/contract/hash.js +3 -0
- package/dist/task/contract/import-revision.js +4 -0
- package/dist/task/contract/observe.js +25 -4
- package/dist/task/contract/paths.js +2 -1
- package/dist/task/contract/project.js +23 -1
- package/dist/task/contract/schema.js +9 -1
- package/dist/task/contract/transaction.js +12 -0
- package/dist/task/frontend-project-capability.js +203 -20
- package/dist/task/runtime.js +5 -2
- package/dist/task/source-prepare/build-draft.js +18 -3
- package/dist/task/source-prepare/completeness.js +188 -0
- package/dist/task/source-prepare/fragment-inventory.js +513 -0
- package/dist/task/source-prepare/index.js +3 -0
- package/dist/task/source-prepare/ledger-reconciliation.js +127 -0
- package/dist/task/source-prepare/ledger-review.js +214 -0
- package/dist/task/source-prepare/ledger.js +545 -0
- package/dist/task/source-prepare/parse-intent.js +24 -4
- package/dist/task/source-prepare/prepare.js +368 -2
- package/dist/task/source-prepare/semantic-intake.js +25 -5
- package/dist/task/source-prepare/source-fidelity-pi.js +384 -0
- package/dist/task/source-prepare/types.js +22 -0
- package/dist/task/source-references.js +22 -1
- package/dist/task/task-demand-routing.js +3 -0
- package/dist/worker/cli.js +18 -2
- package/dist/worker/console/chat/assistant-content.js +7 -0
- package/dist/worker/console/chat/chat-event-store.js +159 -18
- package/dist/worker/console/chat/chat-ui-policy.js +4 -2
- package/dist/worker/console/chat/context-panel.js +7 -0
- package/dist/worker/console/chat/deferred-turn.js +103 -0
- package/dist/worker/console/chat/goal-round-driver.js +72 -0
- package/dist/worker/console/chat/goals.js +300 -0
- package/dist/worker/console/chat/model-resolver.js +7 -4
- package/dist/worker/console/chat/operation-card.js +8 -1
- package/dist/worker/console/chat/pi-console-config.js +81 -10
- package/dist/worker/console/chat/pi-runtime.js +868 -30
- package/dist/worker/console/chat/provider-error.js +99 -0
- package/dist/worker/console/chat/repo-browser.js +101 -12
- package/dist/worker/console/chat/resource-preferences-store.js +1 -1
- package/dist/worker/console/chat/routes.js +1451 -145
- package/dist/worker/console/chat/sdd-data-alignment.js +222 -0
- package/dist/worker/console/chat/semantic-activity.js +25 -24
- package/dist/worker/console/chat/session-catalog.js +50 -0
- package/dist/worker/console/chat/session-stats.js +275 -0
- package/dist/worker/console/chat/session-store.js +348 -76
- package/dist/worker/console/chat/shortcuts.js +26 -3
- package/dist/worker/console/chat/sift-bridge.js +1 -0
- package/dist/worker/console/chat/todos.js +115 -0
- package/dist/worker/console/chat/tool-preview.js +42 -0
- package/dist/worker/console/chat/turn-process.js +185 -112
- package/dist/worker/console/chat/user-questions.js +266 -0
- package/dist/worker/console/chat/workspace-landing.js +79 -0
- package/dist/worker/console/console-handoff.js +82 -0
- package/dist/worker/console/console-update-and-init.js +115 -0
- package/dist/worker/console/console-update-runtime.js +84 -0
- package/dist/worker/console/context-transfer-diagnostics.js +198 -0
- package/dist/worker/console/dag-confirmation.js +1 -1
- package/dist/worker/console/dag-execution-receipt.js +54 -3
- package/dist/worker/console/doctor.js +1 -1
- package/dist/worker/console/draft-store.js +50 -1
- package/dist/worker/console/frontend-human-decision-adapter.js +19 -0
- package/dist/worker/console/frontend-split-operation-adapter.js +20 -0
- package/dist/worker/console/human-gate-token.js +1 -1
- package/dist/worker/console/index.js +6 -3
- package/dist/worker/console/inspect-split.js +18 -0
- package/dist/worker/console/interview/assessment.js +1 -1
- package/dist/worker/console/interview/session.js +1 -1
- package/dist/worker/console/native-directory-picker.js +13 -0
- package/dist/worker/console/operation-run-facts.js +19 -3
- package/dist/worker/console/operation-runner.js +45 -4
- package/dist/worker/console/operation-sse.js +1 -1
- package/dist/worker/console/operation-wait.js +1 -1
- package/dist/worker/console/operator-actions.js +534 -15
- package/dist/worker/console/operator-selection.js +6 -2
- package/dist/worker/console/operator-surface-health.js +2 -1
- package/dist/worker/console/operator-user-error.js +171 -2
- package/dist/worker/console/pi-plugins.catalog.json +73658 -0
- package/dist/worker/console/pi-plugins.js +238 -0
- package/dist/worker/console/pi-readiness.js +7 -6
- package/dist/worker/console/prd-intake-bridge.js +13 -0
- package/dist/worker/console/recovery-cta.js +4 -4
- package/dist/worker/console/recovery-error-copy.js +4 -4
- package/dist/worker/console/routes.js +1231 -10
- package/dist/worker/console/security.js +102 -13
- package/dist/worker/console/server.js +762 -159
- package/dist/worker/console/static/assets/{abnfDiagram-N423BO3Z-BmOEx0gA.js → abnfDiagram-N423BO3Z-BZogYNl1.js} +1 -1
- package/dist/worker/console/static/assets/{arc-BGiVVe8b.js → arc-DcJTLe2v.js} +1 -1
- package/dist/worker/console/static/assets/{architectureDiagram-T3A2C74G-nDdu4rgJ.js → architectureDiagram-T3A2C74G-B39EQQ9n.js} +1 -1
- package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-Bb5u0BWf.js → blockDiagram-VBNYF7ZC-CitCGV56.js} +1 -1
- package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-BlhC0j94.js → c4Diagram-5PPSVZJV-rvWuOHLG.js} +1 -1
- package/dist/worker/console/static/assets/channel-CXqdP5pW.js +1 -0
- package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-Ai8_qQXI.js → chunk-2GRJ4B5K-DGXplIJs.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-B9gyCjqX.js → chunk-2Q5K7J3B-ur9OqjPn.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5RXB4S5H-Bzbj3zGH.js → chunk-5RXB4S5H-D1KqU_Vi.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5VM5RSS4-BT415PvT.js → chunk-5VM5RSS4-BlVZrbtM.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-D_A5_5QL.js → chunk-6Q2QTUOP-BAzz3nQy.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-GF5L2VYU-srJkaP3f.js → chunk-GF5L2VYU-CP_nYuCV.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-JWPE2WC7-UYGvEP4l.js → chunk-JWPE2WC7-CWvKQ80X.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-KBJHAD2P-B8luBrrz.js → chunk-KBJHAD2P-CyUki8wp.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-RYQCIY6F-DN7wXZSq.js → chunk-RYQCIY6F-5NYzNKfY.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-XXDRQBXY-DXKyMuKS.js → chunk-XXDRQBXY-DHdUgjS-.js} +1 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-D9C3agF7.js +1 -0
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-D9C3agF7.js +1 -0
- package/dist/worker/console/static/assets/{cose-bilkent-JH36ORCC-dqvoynXj.js → cose-bilkent-JH36ORCC-ANQ5g_t6.js} +1 -1
- package/dist/worker/console/static/assets/{cynefin-VYW2F7L2--PcyL34A.js → cynefin-VYW2F7L2-CruT_4-0.js} +1 -1
- package/dist/worker/console/static/assets/{cynefinDiagram-MW4NZA55-DvWs_hTY.js → cynefinDiagram-MW4NZA55-rbFo77ID.js} +1 -1
- package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-DxeIxbyO.js → dagre-VZM6K2ZE-asstxBQs.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-7IWD3JNH-DPCG61Of.js → diagram-7IWD3JNH-DzTyBZwI.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-CmuU50-U.js → diagram-B4RE2ZJO-gw8ccH3B.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-LBJQPF4R-B61XLD_v.js → diagram-LBJQPF4R-B8RpZzOf.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-Q27KOJAE-BB7HTRRY.js → diagram-Q27KOJAE-B1zJkCS9.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-UB23O5K3-DvkboAIp.js → diagram-UB23O5K3-B6JLWZmO.js} +1 -1
- package/dist/worker/console/static/assets/{ebnfDiagram-BXEA7PRR-BdJ_y1fL.js → ebnfDiagram-BXEA7PRR-q2iZP-Ps.js} +1 -1
- package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-9bUBZTRi.js → erDiagram-JOGREHBK-B3dbbktQ.js} +1 -1
- package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-Dw4L4RBa.js → flowDiagram-UKHOOZJN-C-zc6-kB.js} +1 -1
- package/dist/worker/console/static/assets/{ganttDiagram-PKOTCBZU-Jr82N_QP.js → ganttDiagram-PKOTCBZU-BSolnot9.js} +1 -1
- package/dist/worker/console/static/assets/{gitGraphDiagram-DS77QQ5N-DAz9wFLr.js → gitGraphDiagram-DS77QQ5N-Bo8jGxTk.js} +1 -1
- package/dist/worker/console/static/assets/index-CAZ2fC_X.css +1 -0
- package/dist/worker/console/static/assets/index-DhfjOafu.js +449 -0
- package/dist/worker/console/static/assets/{infoDiagram-6WML65LV-CBB5Np7y.js → infoDiagram-6WML65LV-DQaZqJOH.js} +1 -1
- package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-D8IOp94y.js → ishikawaDiagram-WSZJBQD7-DsdX1WnE.js} +1 -1
- package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-Dgd3AHGG.js → journeyDiagram-NVQOT4AX-CP5EYDZL.js} +1 -1
- package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-BmYOxLE9.js → kanban-definition-27J2QSJJ-DAm14Dr8.js} +1 -1
- package/dist/worker/console/static/assets/{linear-DfYTEF6J.js → linear-gZECoLc5.js} +1 -1
- package/dist/worker/console/static/assets/{mermaid.core-BjuFPRqa.js → mermaid.core-BRJNIM6p.js} +5 -5
- package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-CLyUViGd.js → mindmap-definition-FAOFIHXS-Cja3kLkR.js} +1 -1
- package/dist/worker/console/static/assets/{pegDiagram-VL7TDLO6-BvX2Di4-.js → pegDiagram-VL7TDLO6-22ZGFisL.js} +1 -1
- package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-BFj0_OLv.js → pieDiagram-7S7Q4E2Y-BXin0Y1o.js} +1 -1
- package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-BIUrD_hx.js → quadrantDiagram-CIZ2JOQS-Cw6T69Yt.js} +1 -1
- package/dist/worker/console/static/assets/{railroadDiagram-AXF67PYL-CHBB48fj.js → railroadDiagram-AXF67PYL-C1-gTieN.js} +1 -1
- package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP-sJrYw2Sf.js → requirementDiagram-LRYGKXZP--H5N2iI1.js} +1 -1
- package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-BzHH6fPR.js → sankeyDiagram-W5VNT64P-CgWAPeRz.js} +1 -1
- package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-7QCnelCt.js → sequenceDiagram-SI44F4Z6-CrKqzGvt.js} +1 -1
- package/dist/worker/console/static/assets/{sizeCapture-X5ZJPWSS-sDYSxn72.js → sizeCapture-X5ZJPWSS-BB3wG06K.js} +1 -1
- package/dist/worker/console/static/assets/{stateDiagram-OKZ733FA-XpiUdwzm.js → stateDiagram-OKZ733FA-DjsGgdgY.js} +1 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-Tp7V0U4q.js +1 -0
- package/dist/worker/console/static/assets/{swimlanes-SLNWSIFB-DvqgNPzD.js → swimlanes-SLNWSIFB-DYKEbvAR.js} +2 -2
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-DUZWZWi8.js +8 -0
- package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-2TyOYNx0.js → timeline-definition-Z64GVDOM-eQOb5k9Y.js} +1 -1
- package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-B-nM6wM2.js → vennDiagram-T6HMQDX7-B2-l9FIu.js} +1 -1
- package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-B86wPdbr.js → wardleyDiagram-T6FBY63Y-BX2Cda3l.js} +1 -1
- package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-Dr1C4AQz.js → xychartDiagram-ELKLHX3M-D9S892ph.js} +1 -1
- package/dist/worker/console/static/index.html +7 -2
- package/dist/worker/console/static-src/active-run-badge.js +17 -0
- package/dist/worker/console/static-src/app/console-types.js +68 -4
- package/dist/worker/console/static-src/app/useConsoleShell.js +30 -12
- package/dist/worker/console/static-src/app/useOperatorActions.js +43 -7
- package/dist/worker/console/static-src/app/useRecoveryActions.js +2 -2
- package/dist/worker/console/static-src/app/useRecoveryConsole.js +45 -10
- package/dist/worker/console/static-src/app/useRunProgress.js +54 -0
- package/dist/worker/console/static-src/app/useTaskWizard.js +74 -2
- package/dist/worker/console/static-src/night/useNightBoard.js +8 -5
- package/dist/worker/console/static-src/operator-chat/cards/failure-category-advice.js +25 -0
- package/dist/worker/console/static-src/operator-chat/chat-sse-events.js +264 -13
- package/dist/worker/console/static-src/operator-chat/compaction-message.js +113 -0
- package/dist/worker/console/static-src/operator-chat/dag-progress-link.js +22 -0
- package/dist/worker/console/static-src/operator-chat/details-dag-actions.js +122 -0
- package/dist/worker/console/static-src/operator-chat/input-history.js +78 -0
- package/dist/worker/console/static-src/operator-chat/mutation-gate.js +1 -1
- package/dist/worker/console/static-src/operator-chat/open-preview-in-browser.js +338 -0
- package/dist/worker/console/static-src/operator-chat/refs.js +3 -0
- package/dist/worker/console/static-src/operator-chat/runtime-selection-labels.js +27 -0
- package/dist/worker/console/static-src/operator-chat/runtime-snapshot-store.js +10 -0
- package/dist/worker/console/static-src/operator-chat/spatial-overlay.js +1 -2
- package/dist/worker/console/static-src/operator-chat/turn-stream-controller.js +33 -1
- package/dist/worker/console/static-src/operator-chat/turn-submission.js +55 -0
- package/dist/worker/console/static-src/operator-chat/useChatSessions.js +448 -109
- package/dist/worker/console/static-src/operator-chat/useChatStream.js +344 -27
- package/dist/worker/console/static-src/operator-chat/useChatThread.js +323 -11
- package/dist/worker/console/static-src/operator-chat/useComposer.js +45 -4
- package/dist/worker/console/static-src/operator-chat/useRepoBrowser.js +97 -13
- package/dist/worker/console/static-src/operator-chat/useRuntimeControls.js +57 -9
- package/dist/worker/console/static-src/operator-chat/useRuntimeSnapshot.js +8 -2
- package/dist/worker/console/static-src/operator-chat/useWorkspaceBrowserGate.js +4 -0
- package/dist/worker/console/static-src/operator-chat/workspace-layout-mode.js +3 -3
- package/dist/worker/console/static-src/operator-chat/workspace-reorder.js +18 -0
- package/dist/worker/console/static-src/pages/tasks/run-id-resolution.js +79 -0
- package/dist/worker/console/static-src/pages/tasks/run-ownership-verify.js +23 -0
- package/dist/worker/console/static-src/pages/tasks/run-panel-progress.js +216 -0
- package/dist/worker/console/static-src/shell/console-update-reload.js +52 -0
- package/dist/worker/console/static-src/shell/useWorkspaces.js +415 -0
- package/dist/worker/console/static-src/shell/workspace-route.js +356 -0
- package/dist/worker/console/workspace-context.js +399 -0
- package/dist/worker/console/workspace-registry.js +487 -0
- package/dist/worker/continuation/worker-continuation.js +278 -0
- package/dist/worker/loop-agent/loop-agent-client.js +7 -3
- package/dist/worker/materialize/frontend-split-task-materializer.js +72 -0
- package/dist/worker/materialize/harness-task-lineage.js +5 -2
- package/dist/worker/observability/init-runtime-activity.js +26 -0
- package/dist/worker/observability/read-model.js +26 -0
- package/dist/worker/observe/health.js +1 -1
- package/dist/worker/observe/node-input.js +160 -3
- package/dist/worker/observe/node-process.js +377 -0
- package/dist/worker/observe/node-transparency.js +572 -0
- package/dist/worker/observe/routes.js +278 -3
- package/dist/worker/observe/server.js +4 -0
- package/dist/worker/observe/shell-handler-keys.js +34 -0
- package/dist/worker/observe/static/api.js +154 -4
- package/dist/worker/observe/static/app.js +18 -70
- package/dist/worker/observe/static/constants.js +26 -19
- package/dist/worker/observe/static/dag-context-reason-labels.d.ts +9 -0
- package/dist/worker/observe/static/dag-context-reason-labels.js +139 -0
- package/dist/worker/observe/static/dag-helpers.js +4 -2
- package/dist/worker/observe/static/dag-history-labels.js +5 -0
- package/dist/worker/observe/static/dag-inspector-humanize.d.ts +16 -0
- package/dist/worker/observe/static/dag-inspector-humanize.js +339 -0
- package/dist/worker/observe/static/dag-node-purpose.d.ts +6 -0
- package/dist/worker/observe/static/dag-node-purpose.js +208 -0
- package/dist/worker/observe/static/format.js +60 -0
- package/dist/worker/observe/static/index.html +10 -5
- package/dist/worker/observe/static/inspect-bootstrap.d.ts +8 -0
- package/dist/worker/observe/static/inspect-bootstrap.js +57 -0
- package/dist/worker/observe/static/inspect-workspace.js +374 -0
- package/dist/worker/observe/static/kpi.js +2 -2
- package/dist/worker/observe/static/markdown-render.js +20 -1
- package/dist/worker/observe/static/operator-chrome.css +168 -24
- package/dist/worker/observe/static/operator-chrome.d.ts +30 -5
- package/dist/worker/observe/static/operator-chrome.js +354 -101
- package/dist/worker/observe/static/prompt-restart-candidates.d.ts +18 -0
- package/dist/worker/observe/static/prompt-restart-candidates.js +38 -0
- package/dist/worker/observe/static/relations.js +7 -7
- package/dist/worker/observe/static/router.d.ts +57 -0
- package/dist/worker/observe/static/router.js +67 -1
- package/dist/worker/observe/static/run-processing.js +4 -2
- package/dist/worker/observe/static/shell-chrome.js +2 -2
- package/dist/worker/observe/static/state.d.ts +50 -0
- package/dist/worker/observe/static/state.js +191 -1
- package/dist/worker/observe/static/styles.css +1720 -86
- package/dist/worker/observe/static/views/dag-graph.js +5 -3
- package/dist/worker/observe/static/views/dag-inspector.js +2601 -188
- package/dist/worker/observe/static/views/dag.d.ts +13 -0
- package/dist/worker/observe/static/views/dag.js +39 -18
- package/dist/worker/observe/static/views/dags.js +10 -6
- package/dist/worker/observe/static/views/dashboard.js +18 -8
- package/dist/worker/observe/static/views/failures.js +5 -2
- package/dist/worker/observe/static/views/night.js +2 -2
- package/dist/worker/observe/static/views/pool.js +8 -2
- package/dist/worker/observe/static/views/run.js +15 -4
- package/dist/worker/observe/static/views/session-timeline.js +386 -25
- package/dist/worker/observe/static/views/task.js +63 -3
- package/dist/worker/outcomes/adapters.js +19 -0
- package/dist/worker/outcomes/types.js +1 -0
- package/dist/worker/pool/attempt-lease.js +97 -66
- package/dist/worker/pool/begin-attempt-with-lease.js +1 -0
- package/dist/worker/pool/reconcile.js +46 -1
- package/dist/worker/pool/run-store.js +2 -0
- package/dist/worker/pool/state-projection.js +2 -0
- package/dist/worker/task-spec/workflow-routing.js +8 -3
- package/dist/workflows/dag/artifact-bindings.js +149 -0
- package/dist/workflows/dag/artifact-revision-schema-registry.js +31 -0
- package/dist/workflows/dag/backend-test-case-coverage-analysis.js +470 -31
- package/dist/workflows/dag/backend-test-markdown-workflow.js +189 -2
- package/dist/workflows/dag/backend-test-plan-protocol.js +210 -0
- package/dist/workflows/dag/backend-test-pytest-collection.js +168 -16
- package/dist/workflows/dag/backend-test-result-contract.js +5 -1
- package/dist/workflows/dag/backend-test-scenario-param.js +506 -73
- package/dist/workflows/dag/backend-test-scenario-partitions.js +135 -2
- package/dist/workflows/dag/backend-test-writer-completeness.js +131 -28
- package/dist/workflows/dag/budget-enforcement.js +10 -0
- package/dist/workflows/dag/context-receipt.js +305 -0
- package/dist/workflows/dag/context-transfer/context-bundle.js +423 -0
- package/dist/workflows/dag/context-transfer/operator-actions.js +61 -0
- package/dist/workflows/dag/context-transfer/renderers.js +93 -0
- package/dist/workflows/dag/contract-output-registry.js +15 -0
- package/dist/workflows/dag/contract-validator-registrations.js +1 -2
- package/dist/workflows/dag/convergence/controller.js +141 -0
- package/dist/workflows/dag/dag-retry-schema.js +138 -0
- package/dist/workflows/dag/dynamic-runtime/loop-until.js +1 -1
- package/dist/workflows/dag/dynamic-runtime/map.js +2 -1
- package/dist/workflows/dag/failure-category.js +7 -116
- package/dist/workflows/dag/frontend-closeout.js +221 -0
- package/dist/workflows/dag/frontend-design-policy.js +400 -0
- package/dist/workflows/dag/frontend-human-decision.js +182 -0
- package/dist/workflows/dag/frontend-implementation-contract.js +1377 -141
- package/dist/workflows/dag/frontend-plan-render.js +26 -1
- package/dist/workflows/dag/frontend-prewrite-gate.js +376 -318
- package/dist/workflows/dag/frontend-provider-capability-matrix.js +159 -0
- package/dist/workflows/dag/frontend-recovery-capsule.js +455 -0
- package/dist/workflows/dag/frontend-recovery-controller.js +226 -0
- package/dist/workflows/dag/frontend-recovery-lineage.js +178 -0
- package/dist/workflows/dag/frontend-recovery-plan.js +21 -10
- package/dist/workflows/dag/frontend-recovery-run.js +166 -34
- package/dist/workflows/dag/frontend-repair.js +7 -424
- package/dist/workflows/dag/frontend-review-context.js +348 -20
- package/dist/workflows/dag/frontend-review-findings.js +270 -0
- package/dist/workflows/dag/frontend-risk.js +15 -2
- package/dist/workflows/dag/frontend-shadow-dual-write.js +941 -0
- package/dist/workflows/dag/frontend-shape-capsule-store.js +191 -0
- package/dist/workflows/dag/frontend-shape-facts.js +419 -0
- package/dist/workflows/dag/frontend-shape.js +435 -0
- package/dist/workflows/dag/frontend-source-fidelity-ledger.js +108 -0
- package/dist/workflows/dag/frontend-split-application-service.js +203 -0
- package/dist/workflows/dag/frontend-split-orchestrator.js +899 -0
- package/dist/workflows/dag/frontend-test-case-checklist.js +53 -5
- package/dist/workflows/dag/frontend-test-case-manifest.js +11 -4
- package/dist/workflows/dag/frontend-test-case-quality.js +11 -16
- package/dist/workflows/dag/frontend-test-environment-probe.js +230 -0
- package/dist/workflows/dag/frontend-test-html-report.js +3 -1
- package/dist/workflows/dag/frontend-test-l5-report.js +3 -1
- package/dist/workflows/dag/frontend-test-layout.js +159 -0
- package/dist/workflows/dag/frontend-test-markdown.js +61 -0
- package/dist/workflows/dag/frontend-test-rerun-candidates.js +103 -0
- package/dist/workflows/dag/frontend-test-result-contract.js +188 -42
- package/dist/workflows/dag/frontend-test-standard-scenarios.js +70 -0
- package/dist/workflows/dag/frontend-typed-event-store.js +452 -0
- package/dist/workflows/dag/frontend-typed-event-transaction.js +180 -0
- package/dist/workflows/dag/frontend-verification-trace.js +281 -29
- package/dist/workflows/dag/frontend-worktree-diff.js +250 -17
- package/dist/workflows/dag/frontend-writer-admission.js +319 -0
- package/dist/workflows/dag/frontend-writer-rollback.js +32 -0
- package/dist/workflows/dag/frontend-writer-status.js +256 -0
- package/dist/workflows/dag/init-hybrid.js +1675 -721
- package/dist/workflows/dag/interrupt-request.js +10 -3
- package/dist/workflows/dag/lifecycle.js +3 -3
- package/dist/workflows/dag/node-execution.js +1141 -32
- package/dist/workflows/dag/path-safety.js +1 -0
- package/dist/workflows/dag/prompt.js +158 -7
- package/dist/workflows/dag/recovery-lease.js +170 -0
- package/dist/workflows/dag/report.js +37 -1
- package/dist/workflows/dag/rerun-feedback.js +526 -0
- package/dist/workflows/dag/rerun-plan.js +790 -28
- package/dist/workflows/dag/rerun-run.js +700 -21
- package/dist/workflows/dag/rerun-task.js +311 -14
- package/dist/workflows/dag/retry-policy.js +336 -101
- package/dist/workflows/dag/runner.js +596 -121
- package/dist/workflows/dag/scheduler.js +133 -20
- package/dist/workflows/dag/skill-snapshot.js +17 -0
- package/dist/workflows/dag/structured-output-repair.js +712 -0
- package/dist/workflows/dag/types.js +585 -31
- package/dist/workflows/dag/validate.js +93 -32
- package/docs/README.md +2 -0
- package/docs/architecture/evolution.md +45 -0
- package/docs/architecture/runtime-boundaries.md +8 -7
- package/docs/architecture/worker-and-feature.md +1 -1
- package/docs/examples/README.md +5 -0
- package/docs/init-surface.manifest.json +36 -12
- package/docs/operations/README.md +1 -1
- package/docs/operations/local-development-environment.md +22 -5
- package/docs/skills/vetted-skill-registry.md +16 -0
- package/docs/templates/README.md +4 -2
- package/docs/templates/agent-dag-report.schema.json +8 -2
- package/docs/templates/agent-dag.schema.json +95 -1
- package/docs/templates/backend-test-dag.json +278 -244
- package/docs/templates/frontend-implementation-contract.schema.json +684 -24
- package/docs/templates/frontend-implementation-dag.json +89 -0
- package/docs/templates/frontend-test-case-checklist.md +2 -2
- package/docs/templates/frontend-test-dag.json +8 -10
- package/docs/templates/frontend-test-dag.retrieve-context.prompt.md +1 -1
- package/docs/templates/init-managed-agents.md +13 -3
- package/docs/templates/product-line/task.yaml +1 -1
- package/docs/templates/spec-registry.schema.json +45 -0
- package/harness.json +2 -2
- package/package.json +19 -5
- package/scripts/next-info.mjs +356 -0
- package/scripts/next-publish-gate.mjs +238 -0
- package/scripts/release-source-binding.mjs +251 -0
- package/skills/analyze-product-requirements/SKILL.md +8 -5
- package/skills/analyze-product-requirements/references/acceptance-criteria.md +1 -1
- package/skills/analyze-product-requirements/references/clarification-and-knowledge.md +10 -6
- package/skills/analyze-product-requirements/references/example.md +50 -0
- package/skills/analyze-product-requirements/references/forward-test-cases.md +11 -7
- package/skills/analyze-product-requirements/references/kb-integration.md +5 -5
- package/skills/analyze-product-requirements/references/product-analysis-schema.md +8 -4
- package/skills/analyze-product-requirements/references/product-requirement-schema.md +2 -2
- package/skills/analyze-product-requirements/references/requirement-clarification-schema.md +1 -1
- package/skills/analyze-product-requirements/scripts/test-validators.mjs +11 -1
- package/skills/analyze-product-requirements/scripts/validate-product-analysis.mjs +20 -1
- package/skills/analyze-product-requirements/scripts/validate-requirement-clarification.mjs +9 -0
- package/skills/codebase-scout/SKILL.md +1 -1
- package/skills/fe-test-ui-scout/SKILL.md +65 -0
- package/skills/fe-test-ui-scout/references/ledger-schema.md +62 -0
- package/skills/fe-test-ui-scout/references/recon-protocol.md +54 -0
- package/skills/frontend-bounded-implement/SKILL.md +15 -14
- package/skills/frontend-bounded-implement/references/code-standards.md +19 -0
- package/skills/frontend-contract/SKILL.md +23 -0
- package/skills/frontend-contract/references/contract-protocol.md +34 -0
- package/skills/frontend-design-review/SKILL.md +22 -41
- package/skills/frontend-plan/SKILL.md +26 -0
- package/skills/frontend-plan/references/decision-contract.md +37 -0
- package/skills/frontend-plan/references/design-decisions.md +17 -0
- package/skills/frontend-review/SKILL.md +20 -15
- package/skills/frontend-review/references/review-findings.md +6 -7
- package/skills/frontend-scout/SKILL.md +25 -0
- package/skills/frontend-scout/references/design-evidence.md +16 -0
- package/skills/frontend-scout/references/scout-evidence.md +23 -0
- package/skills/frontend-verification/SKILL.md +1 -1
- package/skills/improve-codebase-architecture/SKILL.md +81 -0
- package/skills/improve-codebase-architecture/deepening.md +37 -0
- package/skills/improve-codebase-architecture/html-report.md +123 -0
- package/skills/improve-codebase-architecture/interface-design.md +44 -0
- package/skills/improve-codebase-architecture/language.md +53 -0
- package/skills/loop-agent/references/command-reference.md +32 -4
- package/skills/loop-agent/references/hybrid-dag.md +9 -2
- package/skills/playwright-cli/SKILL.md +23 -1
- package/skills/playwright-cli-case-generator/SKILL.md +50 -13
- package/dist/worker/console/operation-store.js +0 -169
- package/dist/worker/console/static/assets/channel-Tl-FkUqr.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-BaehtRk4.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-BaehtRk4.js +0 -1
- package/dist/worker/console/static/assets/index-B7Y-0g3J.css +0 -1
- package/dist/worker/console/static/assets/index-DkCrqaYg.js +0 -325
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-eEhq2A8Y.js +0 -1
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-la8AC7fo.js +0 -8
- package/dist/worker/console/static-src/operator-chat/activity-rail-presentation.js +0 -73
- package/dist/worker/console/static-src/operator-chat/useActivityRailTransition.js +0 -59
- package/skills/frontend-implementation/SKILL.md +0 -52
- package/skills/frontend-implementation/references/code-standards.md +0 -33
- package/skills/frontend-implementation/references/design-spec.md +0 -56
- package/skills/frontend-implementation/references/node-contracts.md +0 -31
- /package/dist/{worker → infrastructure}/console/repo-fingerprint.js +0 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
2
3
|
import { appendFileSync, existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
3
4
|
import { mkdir, readFile, stat, writeFile } from "node:fs/promises";
|
|
4
5
|
import path from "node:path";
|
|
5
|
-
import { writeDagNodeJsonArtifact, writeDagNodeTextArtifact, } from "../infrastructure/harness/artifact-store.js";
|
|
6
|
+
import { writeDagNodeJsonArtifact, writeDagNodeTextArtifact, writeDagRunJsonArtifact, } from "../infrastructure/harness/artifact-store.js";
|
|
6
7
|
import { captureWorkspaceCheckpoint } from "../workflows/dag/workspace-checkpoint.js";
|
|
7
8
|
import { truncateOutput } from "../shared/output-truncation.js";
|
|
8
9
|
import { processTreeSpawnOptions, terminateProcessTree, } from "./process-tree.js";
|
|
@@ -14,30 +15,43 @@ import { buildRequirementCoverageGateShellCommand, expandShellPreset, buildVerdi
|
|
|
14
15
|
import { materializeBackendTestAnalysisContract } from "../workflows/dag/backend-test-analysis-contract.js";
|
|
15
16
|
import { extractBackendTestContractEnvelope } from "../workflows/dag/backend-test-contract-envelope.js";
|
|
16
17
|
import { materializeFrontendImplementationContract } from "../workflows/dag/frontend-implementation-contract.js";
|
|
18
|
+
import { assertFrontendSourceBindingFresh, buildContractFromCommittedFacts, deterministicSha256, frontendImplementationContractSchema, serializeCompactDeterministicJson, sha256Hex, writeFrontendImplementationContractArtifact, buildFrontendVerifyCommandDirectory, } from "../workflows/dag/frontend-implementation-contract.js";
|
|
19
|
+
import { checkFrontendSourceFidelityLedger } from "../workflows/dag/frontend-source-fidelity-ledger.js";
|
|
17
20
|
import { materializeFrontendTestResult, validateFrontendCaseEvidence, } from "../workflows/dag/frontend-test-result-contract.js";
|
|
21
|
+
import { copyFrontendTestStandardScenarios } from "../workflows/dag/frontend-test-standard-scenarios.js";
|
|
22
|
+
import { probeFrontendTestEnvironment } from "../workflows/dag/frontend-test-environment-probe.js";
|
|
18
23
|
import { renderFrontendTestL5Report } from "../workflows/dag/frontend-test-l5-report.js";
|
|
19
24
|
import { validateFrontendCaseChecklist } from "../workflows/dag/frontend-test-case-checklist.js";
|
|
20
25
|
import { materializeFrontendTestCaseManifest } from "../workflows/dag/frontend-test-case-manifest.js";
|
|
26
|
+
import { selectFrontendRerunCandidates } from "../workflows/dag/frontend-test-rerun-candidates.js";
|
|
21
27
|
import { renderFrontendTestHtmlReport } from "../workflows/dag/frontend-test-html-report.js";
|
|
22
28
|
import { formatFrontendVerificationTraceStdout, runFrontendVerificationTraceGate, } from "../workflows/dag/frontend-verification-trace.js";
|
|
23
|
-
import { formatFrontendWorktreeDiffStdout, runFrontendWorktreeDiffGate, } from "../workflows/dag/frontend-worktree-diff.js";
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
29
|
+
import { captureFrontendWorktreeBaseline, formatFrontendWorktreeDiffStdout, runFrontendWorktreeDiffGate, } from "../workflows/dag/frontend-worktree-diff.js";
|
|
30
|
+
import { readTypedEventStoreFromJsonl } from "../workflows/dag/frontend-typed-event-store.js";
|
|
31
|
+
import { classifyFrontendFailure, } from "../workflows/dag/frontend-repair.js";
|
|
32
|
+
import { evaluateFrontendDesignPolicy, } from "../workflows/dag/frontend-design-policy.js";
|
|
33
|
+
import { deriveFrontendWriterAdmissionShell, FRONTEND_WRITER_ADMISSION_RESULT_ARTIFACT, frontendWriterAdmissionResultV1Schema, } from "../workflows/dag/frontend-writer-admission.js";
|
|
34
|
+
import { deriveFrontendIntegrationFacts, buildFrontendTestHandoff, frontendCloseoutFactsSchema, renderFrontendCloseout, } from "../workflows/dag/frontend-closeout.js";
|
|
35
|
+
import { buildFrontendHumanDecisionEnvelope, evaluateHighAdmissionReceipt, routeVerificationConfig, } from "../workflows/dag/frontend-human-decision.js";
|
|
36
|
+
import { classifyFailureOwner, classifyIssueCategoryRestartPhase, classifyRestartPhase, } from "../workflows/dag/frontend-recovery-capsule.js";
|
|
37
|
+
import { pathMatchesPattern } from "../shared/git-progress.js";
|
|
26
38
|
import { formatFrontendReviewContextStdout, runFrontendReviewContextGate, } from "../workflows/dag/frontend-review-context.js";
|
|
27
39
|
import { materializeFrontendLintAssessment, materializeFrontendLintBaseline, } from "../workflows/dag/frontend-lint-baseline.js";
|
|
28
40
|
import { formatTraceabilityGateStdout, materializeBackendTestCaseManifest, runBackendTestTraceabilityGate, } from "../workflows/dag/backend-test-case-manifest.js";
|
|
29
41
|
import { materializeBackendTestExecutionContract } from "../workflows/dag/backend-test-execution-contract.js";
|
|
30
42
|
import { resolveBackendTestLayout } from "../workflows/dag/backend-test-layout.js";
|
|
43
|
+
import { frontendTestLayoutFromSpec, } from "../workflows/dag/frontend-test-layout.js";
|
|
31
44
|
import { backendTestGapDocSchema, ingestBackendTestGap, } from "../workflows/dag/backend-test-gap-fill.js";
|
|
32
|
-
import { analyzeBackendTestCaseCoverage, analyzeBackendTestMarkdownPytestCorrespondence, materializeBackendTestCaseManifestFromFacts, } from "../workflows/dag/backend-test-case-coverage-analysis.js";
|
|
45
|
+
import { analyzeBackendTestCaseCoverage, analyzeBackendTestMarkdownPytestCorrespondence, classifyBackendTestCorrespondenceRepair, materializeBackendTestCaseManifestFromFacts, } from "../workflows/dag/backend-test-case-coverage-analysis.js";
|
|
33
46
|
import { materializeBackendTestResultFromPytestHtml, materializeBackendTestResultFromRunDir, parsePytestHtmlReport, } from "../workflows/dag/backend-test-result-contract.js";
|
|
34
47
|
import { collectBackendTestHumanCaseCatalog, collectBackendTestMappedPytestScripts, resolveBackendTestMappedPytestScripts, collectJacocoCoverage, hasBlockingBackendMarkdownSafetyFindings, hasBlockingBackendMarkdownModuleStemFindings, inspectBackendTestEnvironment, markdownFiles, requiredBackendMarkdownCaseAcIds, renderBackendTestFacts, renderBackendTestHtml, renderBackendTestL5Dashboard, redactBackendTestOutput, validateBackendMarkdownCases, validateBackendMarkdownTraceability, writeRunReport, } from "../workflows/dag/backend-test-markdown-workflow.js";
|
|
35
48
|
import { applyDeterministicScenarioParamRepairs, assessBackendScenarioParamConsistency, classifyBackendTestFailureWithScenarioParam, readBackendScenarioParamFacts, renderBackendTestFailureAnalysis, writeBackendScenarioParamArtifacts, writeScenarioParamRepairAudit, } from "../workflows/dag/backend-test-scenario-param.js";
|
|
36
|
-
import { assessBackendPytestCollection, assessMissingBackendPytestScripts, assessPriorityOnlyBackendPytestModules, assertBackendTestExecutionReadinessFresh, buildBackendPytestAssetInventory, buildBackendTestItemEligibility, materializeBackendTestExecutionReadiness, materializeEffectiveBackendPytestCollection, readBackendPytestCollectionFacts, readBackendTestExecutionReadiness, writeBackendPytestCollectionArtifacts, } from "../workflows/dag/backend-test-pytest-collection.js";
|
|
49
|
+
import { assessBackendPytestCollection, assessMissingBackendPytestScripts, assessPriorityOnlyBackendPytestModules, assertBackendTestExecutionReadinessFresh, buildBackendPytestAssetInventory, buildBackendTestItemEligibility, materializeBackendTestExecutionReadiness, materializeEffectiveBackendPytestCollection, readBackendPytestCollectionFacts, readBackendTestExecutionReadiness, summarizeBackendTestExclusions, writeBackendPytestCollectionArtifacts, } from "../workflows/dag/backend-test-pytest-collection.js";
|
|
37
50
|
import { computeL5ReportMetrics } from "../workflows/dag/l5-report-metrics.js";
|
|
38
51
|
import { buildBackendTestCanonicalResultFromInitialShellSnippet, materializeBackendTestClassification, } from "../workflows/dag/backend-test-classification-contract.js";
|
|
39
52
|
import { backendTestSemanticReviewSchema, materializeBackendTestSemanticReview, } from "../workflows/dag/backend-test-semantic-review-contract.js";
|
|
40
53
|
import { pathsChangedDuringRun, readGitStatusPorcelain, snapshotGitStatusPorcelain, validateShellWriteGuard, } from "./shell-write-guard.js";
|
|
54
|
+
import { captureWorkspaceWriteSnapshot, diffWorkspaceWriteSnapshots, } from "./workspace-write-snapshot.js";
|
|
41
55
|
import { parseAndValidateFinalWriteSetApproval, } from "../workflows/dag/node-execution.js";
|
|
42
56
|
import { buildShellProcessEnv } from "./shell-verification.js";
|
|
43
57
|
import { readRunState } from "../workflows/dag/run-store.js";
|
|
@@ -45,6 +59,7 @@ import { readProjectGovernanceContext } from "../workflows/dag/project-governanc
|
|
|
45
59
|
import { assertMavenPlanFresh, MavenPlanStaleError, } from "../verification/maven/index.js";
|
|
46
60
|
async function runBackendScenarioParamPreflight(input) {
|
|
47
61
|
const outputs = [];
|
|
62
|
+
const allowRepair = input.allowRepair !== false;
|
|
48
63
|
const initial = await assessBackendScenarioParamConsistency({
|
|
49
64
|
workspaceRoot: input.workspaceRoot,
|
|
50
65
|
phase: "initial",
|
|
@@ -60,7 +75,7 @@ async function runBackendScenarioParamPreflight(input) {
|
|
|
60
75
|
outputs.push(`scenarioParamInitial=${initialArtifacts.reportPath}`);
|
|
61
76
|
let finalFacts;
|
|
62
77
|
let finalMarkdown;
|
|
63
|
-
if (initial.facts.repairEligible) {
|
|
78
|
+
if (allowRepair && initial.facts.repairEligible) {
|
|
64
79
|
const repair = await applyDeterministicScenarioParamRepairs({
|
|
65
80
|
workspaceRoot: input.workspaceRoot,
|
|
66
81
|
facts: initial.facts,
|
|
@@ -121,6 +136,39 @@ function shouldReuseSuccessfulShellCommands(shell) {
|
|
|
121
136
|
const DEFAULT_SHELL_TIMEOUT_MS = 300_000;
|
|
122
137
|
const SUMMARY_STDOUT_MAX = 4_000;
|
|
123
138
|
const SUMMARY_STDERR_MAX = 2_000;
|
|
139
|
+
const TEST_TIMEOUT_CLASSIFY_MAX_CHARS = 8_000;
|
|
140
|
+
const TEST_TIMEOUT_MARKERS = [
|
|
141
|
+
/Test timed out in \d+ms/i,
|
|
142
|
+
/Timeout of \d+ms exceeded/i,
|
|
143
|
+
];
|
|
144
|
+
const DETERMINISTIC_NON_TIMEOUT_FAILURE_MARKERS = [
|
|
145
|
+
/AssertionError/i,
|
|
146
|
+
/expected:?\s/i,
|
|
147
|
+
/received:?\s/i,
|
|
148
|
+
/Snapshot /i,
|
|
149
|
+
/toMatchSnapshot/i,
|
|
150
|
+
/SyntaxError/i,
|
|
151
|
+
/TS\d{4}/,
|
|
152
|
+
/error TS/i,
|
|
153
|
+
/eslint/i,
|
|
154
|
+
/compile error/i,
|
|
155
|
+
/Failed to compile/i,
|
|
156
|
+
];
|
|
157
|
+
function isIdentifiedTestCommand(command) {
|
|
158
|
+
return /(?:^|[\s"'`])(?:npx\s+)?vitest(?:\s|$)|(?:^|[\s"'`])npm(?:\.cmd)?\s+test(?:\s|$)|(?:^|[\s"'`])pnpm(?:\.cmd)?\s+test(?:\s|$)|(?:^|[\s"'`])yarn(?:\.cmd)?\s+test(?:\s|$)/i.test(command);
|
|
159
|
+
}
|
|
160
|
+
function classifyShellCommandFailure(input) {
|
|
161
|
+
if (input.processCategory !== "nonzero-exit")
|
|
162
|
+
return input.processCategory;
|
|
163
|
+
if (!isIdentifiedTestCommand(input.command))
|
|
164
|
+
return "nonzero-exit";
|
|
165
|
+
const sample = `${input.stdout}\n${input.stderr}`.slice(0, TEST_TIMEOUT_CLASSIFY_MAX_CHARS);
|
|
166
|
+
const hasTimeoutMarker = TEST_TIMEOUT_MARKERS.some((marker) => marker.test(sample));
|
|
167
|
+
if (!hasTimeoutMarker)
|
|
168
|
+
return "nonzero-exit";
|
|
169
|
+
const mixedDeterministicFailure = DETERMINISTIC_NON_TIMEOUT_FAILURE_MARKERS.some((marker) => marker.test(sample));
|
|
170
|
+
return mixedDeterministicFailure ? "nonzero-exit" : "test-timeout";
|
|
171
|
+
}
|
|
124
172
|
const NODE_STDOUT_MAX = 12_000;
|
|
125
173
|
const NODE_STDERR_MAX = 8_000;
|
|
126
174
|
const MAX_BUFFERED_OUTPUT_BYTES = 64 * 1024;
|
|
@@ -327,16 +375,21 @@ export async function executeShellCommand(input) {
|
|
|
327
375
|
});
|
|
328
376
|
});
|
|
329
377
|
child.on("close", (code) => {
|
|
330
|
-
let
|
|
378
|
+
let processCategory = "nonzero-exit";
|
|
331
379
|
if (timedOut) {
|
|
332
|
-
|
|
380
|
+
processCategory = "timeout";
|
|
333
381
|
}
|
|
334
382
|
else if (code === 0) {
|
|
335
|
-
|
|
383
|
+
processCategory = "success";
|
|
336
384
|
}
|
|
337
385
|
finish({
|
|
338
386
|
exitCode: code,
|
|
339
|
-
failureCategory
|
|
387
|
+
failureCategory: classifyShellCommandFailure({
|
|
388
|
+
command: input.command,
|
|
389
|
+
processCategory,
|
|
390
|
+
stdout: formatBoundedOutput(stdout),
|
|
391
|
+
stderr: formatBoundedOutput(stderr),
|
|
392
|
+
}),
|
|
340
393
|
ok: code === 0 && !timedOut,
|
|
341
394
|
});
|
|
342
395
|
});
|
|
@@ -498,13 +551,22 @@ async function executeBackendTestPipeline(input, meta) {
|
|
|
498
551
|
const started = Date.now();
|
|
499
552
|
// Plan A: prefer the frozen layout carried by the compiled spec; fall back
|
|
500
553
|
// to the historical default for hand-written legacy DAGs.
|
|
501
|
-
const
|
|
554
|
+
const baseBackendLayout = resolveBackendTestLayout(meta.spec.backendTestLayout
|
|
502
555
|
? {
|
|
503
556
|
testRoot: meta.spec.backendTestLayout.testRoot,
|
|
504
557
|
markdownRel: meta.spec.backendTestLayout.markdownRel,
|
|
505
558
|
scriptRel: meta.spec.backendTestLayout.scriptRel,
|
|
506
559
|
}
|
|
507
560
|
: undefined);
|
|
561
|
+
const markdownPlanArtifact = path.join(meta.runDir, "generate-backend-md-plan-pi", "plan.md");
|
|
562
|
+
const backendLayout = existsSync(markdownPlanArtifact)
|
|
563
|
+
? {
|
|
564
|
+
...baseBackendLayout,
|
|
565
|
+
readmePath: path
|
|
566
|
+
.relative(input.cwd, markdownPlanArtifact)
|
|
567
|
+
.replaceAll(path.sep, "/"),
|
|
568
|
+
}
|
|
569
|
+
: baseBackendLayout;
|
|
508
570
|
try {
|
|
509
571
|
if (!pipeline)
|
|
510
572
|
throw new Error("missing backend-test pipeline id");
|
|
@@ -704,7 +766,7 @@ async function executeBackendTestPipeline(input, meta) {
|
|
|
704
766
|
// coverage findings stay advisory, but a declared filter axis missing
|
|
705
767
|
// an each-value/omitted slot or its complement slot must block pytest
|
|
706
768
|
// generation until the Markdown declares the slot.
|
|
707
|
-
const partitionBlocking = coverage.facts.findings.filter((finding) => /^(?:MISSING_PARTITION|MISSING_PARTITION_SLOT|MISSING_COMPLEMENT_SLOT|MISSING_PARTITION_TABLE)/.test(finding));
|
|
769
|
+
const partitionBlocking = coverage.facts.findings.filter((finding) => /^(?:MISSING_PARTITION|MISSING_PARTITION_SLOT|MISSING_COMPLEMENT_SLOT|MISSING_PARTITION_TABLE|INVALID_PARTITION_DOMAIN|NO_FINITE_DOMAIN|PARTITION_SOURCE_MISMATCH)/.test(finding));
|
|
708
770
|
if (partitionBlocking.length > 0) {
|
|
709
771
|
return {
|
|
710
772
|
ok: false,
|
|
@@ -819,26 +881,49 @@ async function executeBackendTestPipeline(input, meta) {
|
|
|
819
881
|
const correspondenceFactsPath = path.join(contractsDir, "backend-test-markdown-pytest-correspondence-initial.json");
|
|
820
882
|
await writeFile(correspondenceFactsPath, JSON.stringify(correspondence.facts, null, 2), "utf8");
|
|
821
883
|
outputs.push(`initialCorrespondence=${correspondenceReportPath}`, `initialCorrespondenceFacts=${correspondenceFactsPath}`);
|
|
822
|
-
if (correspondence.facts.status === "FAIL"
|
|
823
|
-
const
|
|
824
|
-
|
|
825
|
-
.
|
|
826
|
-
.
|
|
827
|
-
|
|
828
|
-
facts.status = "REPAIRABLE";
|
|
829
|
-
facts.repairEligible = true;
|
|
830
|
-
facts.repairPaths = Array.from(new Set([...facts.repairPaths, ...correspondenceRepairPaths])).sort();
|
|
884
|
+
if (correspondence.facts.status === "FAIL") {
|
|
885
|
+
const repair = classifyBackendTestCorrespondenceRepair(correspondence.facts, backendLayout);
|
|
886
|
+
if (repair.markdownBlockingEntries.length > 0) {
|
|
887
|
+
facts.status = "BLOCKED";
|
|
888
|
+
facts.repairEligible = false;
|
|
889
|
+
facts.repairPaths = [];
|
|
831
890
|
facts.findings.push({
|
|
832
|
-
kind: "markdown-
|
|
891
|
+
kind: "markdown-correspondence-contract",
|
|
833
892
|
classification: "test-asset-defect",
|
|
834
|
-
repairability: "
|
|
835
|
-
detail:
|
|
836
|
-
.
|
|
837
|
-
.flatMap((entry) => entry.findings)
|
|
893
|
+
repairability: "blocked",
|
|
894
|
+
detail: repair.markdownBlockingEntries
|
|
895
|
+
.map((entry) => `${entry.caseId ?? "unknown Case"}: ${entry.reasonCodes.join(", ")}`)
|
|
838
896
|
.join("; ")
|
|
839
|
-
.slice(0, 12_000)
|
|
897
|
+
.slice(0, 12_000),
|
|
840
898
|
});
|
|
841
899
|
}
|
|
900
|
+
else if (repair.pytestRepairPaths.length > 0 &&
|
|
901
|
+
(facts.status === "PASS" || facts.status === "REPAIRABLE")) {
|
|
902
|
+
facts.status = "REPAIRABLE";
|
|
903
|
+
facts.repairEligible = true;
|
|
904
|
+
facts.repairPaths = Array.from(new Set([...facts.repairPaths, ...repair.pytestRepairPaths])).sort();
|
|
905
|
+
const repairEntries = correspondence.facts.entries.filter((entry) => repair.pytestRepairEntries.some((candidate) => candidate.caseId === entry.caseId));
|
|
906
|
+
for (const entry of repairEntries.slice(0, 40)) {
|
|
907
|
+
const classified = repair.pytestRepairEntries.find((candidate) => candidate.caseId === entry.caseId);
|
|
908
|
+
facts.findings.push({
|
|
909
|
+
kind: "markdown-pytest-correspondence",
|
|
910
|
+
classification: "test-asset-defect",
|
|
911
|
+
repairability: "repairable",
|
|
912
|
+
detail: entry.findings.join("; ").slice(0, 2_000) || "Markdown-to-pytest correspondence is incomplete",
|
|
913
|
+
...(entry.caseId ? { caseId: entry.caseId } : {}),
|
|
914
|
+
reasonCodes: classified?.reasonCodes ?? [],
|
|
915
|
+
repairPaths: classified?.paths ?? [],
|
|
916
|
+
payloadExpectedPaths: Array.from(new Set([
|
|
917
|
+
...entry.payloadAssessment.requiredPaths,
|
|
918
|
+
...entry.payloadAssessment.allowedPaths,
|
|
919
|
+
])).sort(),
|
|
920
|
+
payloadObservedPaths: entry.payloadAssessment.observedPaths,
|
|
921
|
+
payloadMissingPaths: entry.payloadAssessment.missingPaths,
|
|
922
|
+
payloadUnexpectedPaths: entry.payloadAssessment.unexpectedPaths,
|
|
923
|
+
payloadEnumMismatches: entry.payloadAssessment.enumMismatches,
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
}
|
|
842
927
|
}
|
|
843
928
|
}
|
|
844
929
|
catch (error) {
|
|
@@ -861,6 +946,19 @@ async function executeBackendTestPipeline(input, meta) {
|
|
|
861
946
|
collectedItemCount: facts.collectedItemCount,
|
|
862
947
|
missingMappedScripts: facts.missingMappedScripts,
|
|
863
948
|
repairPaths: facts.repairPaths,
|
|
949
|
+
repairFindings: facts.findings.map((finding) => ({
|
|
950
|
+
kind: finding.kind,
|
|
951
|
+
repairability: finding.repairability,
|
|
952
|
+
detail: finding.detail,
|
|
953
|
+
...(finding.caseId ? { caseId: finding.caseId } : {}),
|
|
954
|
+
...(finding.reasonCodes ? { reasonCodes: finding.reasonCodes } : {}),
|
|
955
|
+
...(finding.repairPaths ? { repairPaths: finding.repairPaths } : {}),
|
|
956
|
+
...(finding.payloadExpectedPaths ? { payloadExpectedPaths: finding.payloadExpectedPaths } : {}),
|
|
957
|
+
...(finding.payloadObservedPaths ? { payloadObservedPaths: finding.payloadObservedPaths } : {}),
|
|
958
|
+
...(finding.payloadMissingPaths ? { payloadMissingPaths: finding.payloadMissingPaths } : {}),
|
|
959
|
+
...(finding.payloadUnexpectedPaths ? { payloadUnexpectedPaths: finding.payloadUnexpectedPaths } : {}),
|
|
960
|
+
...(finding.payloadEnumMismatches ? { payloadEnumMismatches: finding.payloadEnumMismatches } : {}),
|
|
961
|
+
})),
|
|
864
962
|
factsPath: "contracts/backend-test-pytest-collection-initial.json",
|
|
865
963
|
}),
|
|
866
964
|
stderr: "",
|
|
@@ -874,14 +972,16 @@ async function executeBackendTestPipeline(input, meta) {
|
|
|
874
972
|
effective = await materializeEffectiveBackendPytestCollection({
|
|
875
973
|
workspaceRoot: input.cwd,
|
|
876
974
|
initial,
|
|
975
|
+
layout: backendLayout,
|
|
877
976
|
});
|
|
878
977
|
}
|
|
879
978
|
else if (initial.status === "REPAIRABLE") {
|
|
880
|
-
const mappedScripts = await collectBackendTestMappedPytestScripts(input.cwd);
|
|
979
|
+
const mappedScripts = await collectBackendTestMappedPytestScripts(input.cwd, backendLayout);
|
|
881
980
|
const scenario = await runBackendScenarioParamPreflight({
|
|
882
981
|
workspaceRoot: input.cwd,
|
|
883
982
|
runDir: meta.runDir,
|
|
884
983
|
layout: backendLayout,
|
|
984
|
+
allowRepair: false,
|
|
885
985
|
strictScenarioParamGate: Boolean((meta.spec.globalConstraints ?? []).some((item) => /strictScenarioParamGate\s*=\s*true/i.test(item))),
|
|
886
986
|
});
|
|
887
987
|
outputs.push(...scenario.outputs);
|
|
@@ -933,6 +1033,7 @@ async function executeBackendTestPipeline(input, meta) {
|
|
|
933
1033
|
workspaceRoot: input.cwd,
|
|
934
1034
|
initial,
|
|
935
1035
|
final: finalFacts,
|
|
1036
|
+
layout: backendLayout,
|
|
936
1037
|
});
|
|
937
1038
|
}
|
|
938
1039
|
else {
|
|
@@ -958,6 +1059,7 @@ async function executeBackendTestPipeline(input, meta) {
|
|
|
958
1059
|
})
|
|
959
1060
|
: { eligibleItemIds: effective.collectedItemIds, excludedItems: [] };
|
|
960
1061
|
const eligibilityInputHashes = Object.fromEntries((correspondence?.facts.inputFiles ?? []).map((item) => [item.path, item.sha256]));
|
|
1062
|
+
const exclusionSummary = summarizeBackendTestExclusions(eligibility.excludedItems);
|
|
961
1063
|
const eligibilityFactsPath = path.join(meta.runDir, "contracts", "backend-test-execution-eligibility.json");
|
|
962
1064
|
await mkdir(path.dirname(eligibilityFactsPath), { recursive: true });
|
|
963
1065
|
await writeFile(eligibilityFactsPath, `${JSON.stringify({
|
|
@@ -968,6 +1070,9 @@ async function executeBackendTestPipeline(input, meta) {
|
|
|
968
1070
|
excludedItemCount: eligibility.excludedItems.length,
|
|
969
1071
|
eligibleItemIds: eligibility.eligibleItemIds,
|
|
970
1072
|
excludedItems: eligibility.excludedItems,
|
|
1073
|
+
exclusionSummary,
|
|
1074
|
+
pytestSpawned: false,
|
|
1075
|
+
businessTestBodyExecutedCount: 0,
|
|
971
1076
|
inputHashes: eligibilityInputHashes,
|
|
972
1077
|
}, null, 2)}\n`, "utf8");
|
|
973
1078
|
const eligibilityReportPath = await writeRunReport(meta.runDir, "backend-test-execution-eligibility.md", [
|
|
@@ -980,6 +1085,10 @@ async function executeBackendTestPipeline(input, meta) {
|
|
|
980
1085
|
`- Collected items: ${effective.collectedItemIds.length}`,
|
|
981
1086
|
`- Eligible items: ${eligibility.eligibleItemIds.length}`,
|
|
982
1087
|
`- Excluded items: ${eligibility.excludedItems.length}`,
|
|
1088
|
+
`- Excluded Cases: ${exclusionSummary.excludedCaseCount}`,
|
|
1089
|
+
`- Exclusion categories: ${Object.entries(exclusionSummary.excludedByReason).map(([category, count]) => `${category}=${count}`).join("; ") || "none"}`,
|
|
1090
|
+
"- pytest spawned: false",
|
|
1091
|
+
"- Business test bodies executed: 0",
|
|
983
1092
|
"",
|
|
984
1093
|
"## Excluded Items",
|
|
985
1094
|
"",
|
|
@@ -995,6 +1104,7 @@ async function executeBackendTestPipeline(input, meta) {
|
|
|
995
1104
|
scenarioParamRepairAttempt: scenarioFacts.repairAttempt,
|
|
996
1105
|
eligibility,
|
|
997
1106
|
eligibilityInputHashes,
|
|
1107
|
+
layout: backendLayout,
|
|
998
1108
|
});
|
|
999
1109
|
return {
|
|
1000
1110
|
ok: true,
|
|
@@ -1007,6 +1117,9 @@ async function executeBackendTestPipeline(input, meta) {
|
|
|
1007
1117
|
executionReadinessStatus: readiness.status,
|
|
1008
1118
|
eligibleItemCount: readiness.eligibleItemIds.length,
|
|
1009
1119
|
excludedItemCount: readiness.excludedItems.length,
|
|
1120
|
+
exclusionSummary: readiness.exclusionSummary,
|
|
1121
|
+
pytestSpawned: readiness.pytestSpawned,
|
|
1122
|
+
businessTestBodyExecutedCount: readiness.businessTestBodyExecutedCount,
|
|
1010
1123
|
factsPath: "contracts/backend-test-pytest-collection-effective.json",
|
|
1011
1124
|
readinessPath: "contracts/backend-test-execution-readiness.json",
|
|
1012
1125
|
reportPath: artifacts.reportPath,
|
|
@@ -1018,7 +1131,7 @@ async function executeBackendTestPipeline(input, meta) {
|
|
|
1018
1131
|
else if (pipeline === "markdown-traceability") {
|
|
1019
1132
|
let report;
|
|
1020
1133
|
try {
|
|
1021
|
-
report = await validateBackendMarkdownTraceability(input.cwd);
|
|
1134
|
+
report = await validateBackendMarkdownTraceability(input.cwd, backendLayout);
|
|
1022
1135
|
}
|
|
1023
1136
|
catch (error) {
|
|
1024
1137
|
report = `# Backend Test Traceability\n\n## Status\n\nFAIL\n\n## Findings\n\n- Traceability validation could not complete: ${error instanceof Error ? error.message : String(error)}\n`;
|
|
@@ -1103,7 +1216,7 @@ async function executeBackendTestPipeline(input, meta) {
|
|
|
1103
1216
|
}
|
|
1104
1217
|
else if (pipeline === "markdown-execute-html") {
|
|
1105
1218
|
const executionReadiness = await readBackendTestExecutionReadiness(path.join(meta.runDir, "contracts", "backend-test-execution-readiness.json"));
|
|
1106
|
-
await assertBackendTestExecutionReadinessFresh(input.cwd, executionReadiness);
|
|
1219
|
+
await assertBackendTestExecutionReadinessFresh(input.cwd, executionReadiness, backendLayout);
|
|
1107
1220
|
const mappedScripts = await collectBackendTestMappedPytestScripts(input.cwd, backendLayout);
|
|
1108
1221
|
let eligibleItemIds = executionReadiness.eligibleItemIds;
|
|
1109
1222
|
// Plan D gap-fill executeScope=affected: when a gap plan exists in
|
|
@@ -1129,7 +1242,33 @@ async function executeBackendTestPipeline(input, meta) {
|
|
|
1129
1242
|
const pytestTargetsRelative = "reports/backend-test-pytest-targets.txt";
|
|
1130
1243
|
const pytestTargetsAbsolute = path.join(meta.runDir, pytestTargetsRelative);
|
|
1131
1244
|
await writeFile(pytestTargetsAbsolute, `${eligibleItemIds.join("\n")}\n`, "utf8");
|
|
1132
|
-
const
|
|
1245
|
+
const pytestLauncherRelative = "reports/backend-test-pytest-launcher.py";
|
|
1246
|
+
const pytestLauncherAbsolute = path.join(meta.runDir, pytestLauncherRelative);
|
|
1247
|
+
await writeFile(pytestLauncherAbsolute, [
|
|
1248
|
+
"import os",
|
|
1249
|
+
"import pathlib",
|
|
1250
|
+
"import sys",
|
|
1251
|
+
"",
|
|
1252
|
+
"sys.path[0] = os.getcwd()",
|
|
1253
|
+
"import pytest",
|
|
1254
|
+
"",
|
|
1255
|
+
"if len(sys.argv) != 3:",
|
|
1256
|
+
" print('usage: backend-test-pytest-launcher.py <targets-file> <html-file>', file=sys.stderr)",
|
|
1257
|
+
" raise SystemExit(4)",
|
|
1258
|
+
"targets_path = pathlib.Path(sys.argv[1])",
|
|
1259
|
+
"html_path = pathlib.Path(sys.argv[2])",
|
|
1260
|
+
"try:",
|
|
1261
|
+
" targets = targets_path.read_text(encoding='utf-8').splitlines()",
|
|
1262
|
+
"except (OSError, UnicodeError) as error:",
|
|
1263
|
+
" print(f'backend-test targets unreadable: {error}', file=sys.stderr)",
|
|
1264
|
+
" raise SystemExit(4)",
|
|
1265
|
+
"if not targets or any(not target or target != target.strip() for target in targets):",
|
|
1266
|
+
" print('backend-test targets must contain non-empty exact pytest node IDs', file=sys.stderr)",
|
|
1267
|
+
" raise SystemExit(4)",
|
|
1268
|
+
"pytest_args = [*targets, '-v', '-p', 'no:cacheprovider', f'--html={html_path}', '--self-contained-html']",
|
|
1269
|
+
"raise SystemExit(pytest.main(pytest_args))",
|
|
1270
|
+
"",
|
|
1271
|
+
].join("\n"), "utf8");
|
|
1133
1272
|
// Split into short bash -c commands (aligned with markdown-environment).
|
|
1134
1273
|
// A single ultra-long compound command has been observed on Windows to
|
|
1135
1274
|
// exit 0xC0000142 (STATUS_DLL_INIT_FAILED) in ~40ms with empty stdout/
|
|
@@ -1206,10 +1345,11 @@ async function executeBackendTestPipeline(input, meta) {
|
|
|
1206
1345
|
'PYTHON_BIN="$(command -v python || command -v python3 || true)"',
|
|
1207
1346
|
'if [ -z "${PYTHON_BIN}" ]; then echo "python/python3 is required for backend-test execution" | tee -a "${DIAG_FILE}" >&2; exit 127; fi',
|
|
1208
1347
|
'echo "STEP=pytest-run"',
|
|
1209
|
-
`echo "- pytestCommand:
|
|
1348
|
+
`echo "- pytestCommand: controller launcher -> pytest.main(<${eligibleItemIds.length} eligibility-authorized-items>, -v, -p no:cacheprovider, --html=reports/backend-test.html, --self-contained-html)" >> "\${DIAG_FILE}"`,
|
|
1210
1349
|
`echo "- eligibleItemCount: ${eligibleItemIds.length}" >> "\${DIAG_FILE}"`,
|
|
1211
1350
|
`echo "- excludedItemCount: ${executionReadiness.excludedItems.length}" >> "\${DIAG_FILE}"`,
|
|
1212
|
-
|
|
1351
|
+
'rm -f "${HARNESS_DAG_RUN_DIR}/reports/backend-test.html" "${HARNESS_DAG_RUN_DIR}/reports/backend-test-pytest-native.html"',
|
|
1352
|
+
`PYTHONUTF8=1 PYTHONIOENCODING=utf-8 PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1 "\${PYTHON_BIN}" "\${HARNESS_DAG_RUN_DIR}/${pytestLauncherRelative}" "\${HARNESS_DAG_RUN_DIR}/${pytestTargetsRelative}" "\${HARNESS_DAG_RUN_DIR}/reports/backend-test.html"`,
|
|
1213
1353
|
"STATUS=$?",
|
|
1214
1354
|
'printf "%s" "${STATUS}" > "${HARNESS_DAG_RUN_DIR}/reports/backend-test-pytest-exit.txt"',
|
|
1215
1355
|
'echo "- pytestExitCode: ${STATUS}" >> "${DIAG_FILE}"',
|
|
@@ -1678,6 +1818,33 @@ async function executeBackendTestPipeline(input, meta) {
|
|
|
1678
1818
|
}
|
|
1679
1819
|
}
|
|
1680
1820
|
async function executeBackendTestPipelineWithWriteGuard(input, meta) {
|
|
1821
|
+
if (meta.spec.backendTestWorkspaceControl === "filesystem-only") {
|
|
1822
|
+
const paths = input.task.writeSet ?? input.task.allowedPaths;
|
|
1823
|
+
let beforeSnapshot;
|
|
1824
|
+
try {
|
|
1825
|
+
beforeSnapshot = await captureWorkspaceWriteSnapshot({ rootCwd: input.cwd, paths });
|
|
1826
|
+
}
|
|
1827
|
+
catch (error) {
|
|
1828
|
+
return { ok: false, stdout: "", stderr: `workspace filesystem baseline unavailable: ${error instanceof Error ? error.message : String(error)}`, failureCategory: "write-guard", durationMs: 0 };
|
|
1829
|
+
}
|
|
1830
|
+
const result = await executeBackendTestPipeline(input, meta);
|
|
1831
|
+
try {
|
|
1832
|
+
const afterSnapshot = await captureWorkspaceWriteSnapshot({ rootCwd: input.cwd, paths });
|
|
1833
|
+
const guard = validateShellWriteGuard({
|
|
1834
|
+
changedPaths: diffWorkspaceWriteSnapshots(beforeSnapshot, afterSnapshot),
|
|
1835
|
+
writePolicy: input.task.writePolicy,
|
|
1836
|
+
writeSet: input.task.writeSet,
|
|
1837
|
+
allowedPaths: input.task.allowedPaths,
|
|
1838
|
+
forbiddenPaths: input.task.forbiddenPaths,
|
|
1839
|
+
});
|
|
1840
|
+
if (!guard.ok)
|
|
1841
|
+
return { ...result, ok: false, stderr: [result.stderr, `filesystem write guard failed: ${guard.violations.join(", ")}`].filter(Boolean).join("\n\n"), failureCategory: "write-guard" };
|
|
1842
|
+
return result;
|
|
1843
|
+
}
|
|
1844
|
+
catch (error) {
|
|
1845
|
+
return { ...result, ok: false, stderr: [result.stderr, `filesystem write guard failed: ${error instanceof Error ? error.message : String(error)}`].filter(Boolean).join("\n\n"), failureCategory: "write-guard" };
|
|
1846
|
+
}
|
|
1847
|
+
}
|
|
1681
1848
|
let beforeStatus;
|
|
1682
1849
|
try {
|
|
1683
1850
|
beforeStatus = await readGitStatusPorcelain(input.cwd);
|
|
@@ -1740,6 +1907,44 @@ async function executePipelineCommands(input, meta, overrideCommands) {
|
|
|
1740
1907
|
}
|
|
1741
1908
|
return results;
|
|
1742
1909
|
}
|
|
1910
|
+
/** A+B (AC-008): derive unresolved verification entrypoints from committed plan
|
|
1911
|
+
* facts. A verification target is unresolved when its commandId does not
|
|
1912
|
+
* match any frozen command directory entry derived from the verify shell
|
|
1913
|
+
* evidence bundle. Returns `{ ref, digest }` entries; a missing/unreadable
|
|
1914
|
+
* plan ledger fails closed to [] so the router restarts the contract instead
|
|
1915
|
+
* of inventing refs. */
|
|
1916
|
+
async function deriveUnresolvedVerificationEntrypointRefs(runDir, frozenCommandIds) {
|
|
1917
|
+
try {
|
|
1918
|
+
const { restorePlanPatchFromCommittedFacts } = await import("../workflows/dag/frontend-shadow-dual-write.js");
|
|
1919
|
+
const records = await readTypedEventStoreFromJsonl(path.join(runDir, "frontend-plan-pi", "plan-typed-facts.jsonl"));
|
|
1920
|
+
const patch = restorePlanPatchFromCommittedFacts(records);
|
|
1921
|
+
const targets = patch
|
|
1922
|
+
?.verificationTargets;
|
|
1923
|
+
if (!Array.isArray(targets))
|
|
1924
|
+
return [];
|
|
1925
|
+
const frozen = new Set(frozenCommandIds.filter(Boolean));
|
|
1926
|
+
const refs = [];
|
|
1927
|
+
for (const item of targets) {
|
|
1928
|
+
const target = item;
|
|
1929
|
+
// v2 plan facts carry commandId as the stable directory key.
|
|
1930
|
+
const commandId = typeof target.commandId === "string" ? target.commandId : "";
|
|
1931
|
+
if (commandId && frozen.has(commandId)) {
|
|
1932
|
+
continue;
|
|
1933
|
+
}
|
|
1934
|
+
const file = typeof target.file === "string" ? target.file : "";
|
|
1935
|
+
const symbol = typeof target.symbol === "string" ? target.symbol : "";
|
|
1936
|
+
const id = typeof target.id === "string" ? target.id : "";
|
|
1937
|
+
const ref = file || symbol || id;
|
|
1938
|
+
if (!ref)
|
|
1939
|
+
continue;
|
|
1940
|
+
refs.push({ ref, digest: sha256Hex(ref) });
|
|
1941
|
+
}
|
|
1942
|
+
return refs;
|
|
1943
|
+
}
|
|
1944
|
+
catch {
|
|
1945
|
+
return [];
|
|
1946
|
+
}
|
|
1947
|
+
}
|
|
1743
1948
|
async function executeFrontendVerificationBundle(input, meta) {
|
|
1744
1949
|
const started = Date.now();
|
|
1745
1950
|
const shell = input.task.shell;
|
|
@@ -1894,75 +2099,540 @@ async function executeFrontendVerificationBundle(input, meta) {
|
|
|
1894
2099
|
catch (error) {
|
|
1895
2100
|
traceError = error instanceof Error ? error : new Error(String(error));
|
|
1896
2101
|
}
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
2102
|
+
const verifyFailed = firstFailure !== undefined || lintSyntheticFailure !== undefined || traceError !== undefined;
|
|
2103
|
+
if (verifyFailed) {
|
|
2104
|
+
// M8: verify failure is TERMINAL. There is no same-run repair branch and
|
|
2105
|
+
// no frontend-repair-assessment.json; we only materialize failure
|
|
2106
|
+
// ownership facts (frontend-repair classification + recovery capsule
|
|
2107
|
+
// ownership) for the operation controller / recovery run.
|
|
2108
|
+
const failedNodeId = input.task.id;
|
|
2109
|
+
const failureCategory = firstFailure?.failureCategory ??
|
|
2110
|
+
lintSyntheticFailure?.failureCategory ??
|
|
2111
|
+
(traceError ? "invalid-output" : undefined) ??
|
|
2112
|
+
"invalid-output";
|
|
2113
|
+
const failureClass = classifyFrontendFailure({
|
|
2114
|
+
nodeId: failedNodeId,
|
|
2115
|
+
failureCategory,
|
|
2116
|
+
stdout: firstFailure?.stdout,
|
|
2117
|
+
stderr: firstFailure?.stderr ?? traceError?.message,
|
|
2118
|
+
});
|
|
2119
|
+
// A verify failure means the writer's candidate failed verification, so
|
|
2120
|
+
// the recovery ownership maps to the implement phase (frontend-recovery
|
|
2121
|
+
// capsule classification, fail-closed to implement-pi).
|
|
2122
|
+
const classifiedOwner = classifyFailureOwner({
|
|
2123
|
+
failureSource: "frontend-verify-shell",
|
|
2124
|
+
nodeId: failedNodeId,
|
|
2125
|
+
rawFailureCategory: failureCategory,
|
|
2126
|
+
});
|
|
2127
|
+
const failureOwner = classifiedOwner === "unknown" ? "implement-pi" : classifiedOwner;
|
|
2128
|
+
const restartPhase = classifyRestartPhase(failureOwner);
|
|
2129
|
+
// A+B (AC-008): verification-config routing. Produce structured
|
|
2130
|
+
// unresolved entrypoint refs from committed plan facts and the frozen
|
|
2131
|
+
// command labels; a non-empty unresolved set routes to
|
|
2132
|
+
// verification-config-decision and materializes the frozen
|
|
2133
|
+
// verification-config envelope. An empty/untyped signal fails closed to
|
|
2134
|
+
// contract-restart. The decision is recorded so the recovery controller
|
|
2135
|
+
// never re-classifies the same signal twice.
|
|
2136
|
+
let verificationConfigRoute;
|
|
2137
|
+
if (failureOwner === "verification-config") {
|
|
2138
|
+
const verifyDirectory = buildFrontendVerifyCommandDirectory({
|
|
2139
|
+
staticLabels: bundle.staticEvidence.commandLabels ?? [],
|
|
2140
|
+
behaviorLabels: bundle.behaviorEvidence.commandLabels ?? [],
|
|
2141
|
+
mockLabels: bundle.mockEvidence?.commandLabels ?? [],
|
|
2142
|
+
lintLabels: bundle.lintEvidence?.commandLabels ?? [],
|
|
2143
|
+
staticCommandTexts: bundle.staticEvidence.commandTexts ?? [],
|
|
2144
|
+
behaviorCommandTexts: bundle.behaviorEvidence.commandTexts ?? [],
|
|
2145
|
+
mockCommandTexts: bundle.mockEvidence?.commandTexts ?? [],
|
|
2146
|
+
lintCommandTexts: bundle.lintEvidence?.commandTexts ?? [],
|
|
2147
|
+
});
|
|
2148
|
+
const frozenCommandLabels = verifyDirectory.map((entry) => entry.label);
|
|
2149
|
+
const unresolvedEntrypointRefs = await deriveUnresolvedVerificationEntrypointRefs(meta.runDir, verifyDirectory.map((entry) => entry.commandId));
|
|
2150
|
+
verificationConfigRoute = routeVerificationConfig({
|
|
2151
|
+
unresolvedEntrypointRefs: unresolvedEntrypointRefs.map((ref) => ref.ref),
|
|
2152
|
+
});
|
|
2153
|
+
const allowlistedResolvers = [
|
|
2154
|
+
...new Set(frozenCommandLabels
|
|
2155
|
+
.map((label) => label.trim())
|
|
2156
|
+
.filter(Boolean)),
|
|
2157
|
+
].sort();
|
|
2158
|
+
if (verificationConfigRoute.decision ===
|
|
2159
|
+
"verification-config-decision" &&
|
|
2160
|
+
unresolvedEntrypointRefs.length > 0 &&
|
|
2161
|
+
allowlistedResolvers.length > 0) {
|
|
2162
|
+
const envelope = buildFrontendHumanDecisionEnvelope({
|
|
2163
|
+
operationId: input.task.id,
|
|
2164
|
+
runId: meta.runId,
|
|
2165
|
+
operationRevision: 1,
|
|
2166
|
+
targetDigest: sha256Hex(frozenCommandLabels.slice().sort().join("\n")),
|
|
2167
|
+
staleOnTargetDigestChange: true,
|
|
2168
|
+
kind: "verification-config",
|
|
2169
|
+
resumeAction: "select-verification-config",
|
|
2170
|
+
payload: {
|
|
2171
|
+
unresolvedEntrypointRefs,
|
|
2172
|
+
allowlistedResolvers,
|
|
2173
|
+
},
|
|
2174
|
+
});
|
|
2175
|
+
await writeDagRunJsonArtifact(meta.runDir, "contracts/frontend-verification-config-envelope.json", envelope);
|
|
2176
|
+
}
|
|
1912
2177
|
}
|
|
2178
|
+
const verifyFailure = {
|
|
2179
|
+
schemaVersion: 1,
|
|
2180
|
+
schemaId: "frontend-verify-failure-v1",
|
|
2181
|
+
nodeId: failedNodeId,
|
|
2182
|
+
failureCategory,
|
|
2183
|
+
failureClass,
|
|
2184
|
+
failureOwner,
|
|
2185
|
+
restartPhase,
|
|
2186
|
+
...(verificationConfigRoute
|
|
2187
|
+
? { verificationConfigRoute }
|
|
2188
|
+
: {}),
|
|
2189
|
+
commandResults,
|
|
2190
|
+
failedAt: new Date().toISOString(),
|
|
2191
|
+
};
|
|
2192
|
+
await writeDagRunJsonArtifact(meta.runDir, "contracts/frontend-verify-failure.json", verifyFailure);
|
|
1913
2193
|
return {
|
|
1914
|
-
ok:
|
|
1915
|
-
stdout:
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
2194
|
+
ok: false,
|
|
2195
|
+
stdout: summarizeCommandResults(results).stdout,
|
|
2196
|
+
stderr: firstFailure?.stderr ||
|
|
2197
|
+
lintSyntheticFailure?.stderr ||
|
|
2198
|
+
traceError?.message ||
|
|
2199
|
+
"frontend verification failed",
|
|
2200
|
+
failureCategory,
|
|
1920
2201
|
durationMs: Date.now() - started,
|
|
1921
2202
|
...{ commandResults },
|
|
1922
2203
|
};
|
|
1923
2204
|
}
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
2205
|
+
// A+B (AC-008): when lint is `require-clean` but the assessment proves
|
|
2206
|
+
// baseline-debt, materialize the frozen `baseline-debt-acceptance` envelope
|
|
2207
|
+
// whose only positive resume is `accept-baseline-debt`. Evidence stays
|
|
2208
|
+
// `baseline-debt` and is never rewritten to `passed`.
|
|
2209
|
+
if (lintAssessment?.status === "baseline-debt") {
|
|
2210
|
+
const baselineEvidenceRefs = (lintAssessment.rawEvidenceRefs ?? [])
|
|
2211
|
+
.filter((ref) => ref?.path && ref?.sha256)
|
|
2212
|
+
.map((ref) => ({ ref: ref.path, digest: ref.sha256 }));
|
|
2213
|
+
if (baselineEvidenceRefs.length > 0) {
|
|
2214
|
+
const envelope = buildFrontendHumanDecisionEnvelope({
|
|
2215
|
+
operationId: input.task.id,
|
|
2216
|
+
runId: meta.runId,
|
|
2217
|
+
operationRevision: 1,
|
|
2218
|
+
targetDigest: lintAssessment.commandIdentity.sha256,
|
|
2219
|
+
staleOnTargetDigestChange: true,
|
|
2220
|
+
kind: "baseline-debt-acceptance",
|
|
2221
|
+
resumeAction: "accept-baseline-debt",
|
|
2222
|
+
payload: {
|
|
2223
|
+
baselineEvidenceRefs,
|
|
2224
|
+
candidateDigest: lintAssessment.commandIdentity.sha256,
|
|
2225
|
+
commandDigest: lintAssessment.commandIdentity.sha256,
|
|
2226
|
+
resultingPolicy: "allow-non-regression",
|
|
2227
|
+
},
|
|
2228
|
+
});
|
|
2229
|
+
await writeDagRunJsonArtifact(meta.runDir, "contracts/frontend-baseline-debt-acceptance-envelope.json", envelope);
|
|
2230
|
+
}
|
|
1942
2231
|
}
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
}
|
|
2232
|
+
return {
|
|
2233
|
+
ok: true,
|
|
2234
|
+
stdout: lintAssessment?.status === "baseline-debt"
|
|
2235
|
+
? "Frontend verification bundle: pass with lint baseline-debt"
|
|
2236
|
+
: "Frontend verification bundle: pass",
|
|
2237
|
+
stderr: "",
|
|
2238
|
+
failureCategory: "success",
|
|
2239
|
+
durationMs: Date.now() - started,
|
|
2240
|
+
...{ commandResults },
|
|
2241
|
+
};
|
|
2242
|
+
}
|
|
2243
|
+
/* ------------------------------------------------------------------ *
|
|
2244
|
+
* M8 deterministic frontend shell nodes: design policy, writer *
|
|
2245
|
+
* admission, closeout. These replace the prewrite-gate authorization *
|
|
2246
|
+
* path and the Pi closeout node. *
|
|
2247
|
+
* ------------------------------------------------------------------ */
|
|
2248
|
+
async function readRunDirJson(runDir, relativePath) {
|
|
2249
|
+
return JSON.parse(await readFile(path.join(runDir, relativePath), "utf8"));
|
|
2250
|
+
}
|
|
2251
|
+
/** Committed typed review terminal kinds from the review node's typed event
|
|
2252
|
+
* store (AC-003: typed terminal tools are the only authoritative verdict). */
|
|
2253
|
+
async function collectReviewTerminalKinds(runDir, reviewNodeId) {
|
|
2254
|
+
try {
|
|
2255
|
+
const records = await readTypedEventStoreFromJsonl(path.join(runDir, reviewNodeId, "review-typed-facts.jsonl"));
|
|
2256
|
+
return records
|
|
2257
|
+
.filter((record) => record.phase === "committed")
|
|
2258
|
+
.map((record) => {
|
|
2259
|
+
const kind = record.fact.kind;
|
|
2260
|
+
return typeof kind === "string" ? kind : "";
|
|
2261
|
+
})
|
|
2262
|
+
.filter(Boolean);
|
|
2263
|
+
}
|
|
2264
|
+
catch {
|
|
2265
|
+
return [];
|
|
2266
|
+
}
|
|
2267
|
+
}
|
|
2268
|
+
/** Committed typed design terminal kinds from the design review node's typed
|
|
2269
|
+
* event store (M8: the committed approve_design / request_design_changes fact
|
|
2270
|
+
* is the only authoritative verdict; the legacy first-line VERDICT text is
|
|
2271
|
+
* never read for writer admission). Fail-closed on a missing/unreadable store. */
|
|
2272
|
+
async function collectDesignTerminalKinds(runDir, designNodeId) {
|
|
2273
|
+
try {
|
|
2274
|
+
const records = await readTypedEventStoreFromJsonl(path.join(runDir, designNodeId, "design-typed-facts.jsonl"));
|
|
2275
|
+
return records
|
|
2276
|
+
.filter((record) => record.phase === "committed")
|
|
2277
|
+
.map((record) => {
|
|
2278
|
+
const kind = record.fact.kind;
|
|
2279
|
+
return typeof kind === "string" ? kind : "";
|
|
2280
|
+
})
|
|
2281
|
+
.filter(Boolean);
|
|
2282
|
+
}
|
|
2283
|
+
catch {
|
|
2284
|
+
return [];
|
|
2285
|
+
}
|
|
2286
|
+
}
|
|
2287
|
+
/** A+B (AC-009): deterministic §4.10 restart phase for a committed
|
|
2288
|
+
* `request_review_changes` fact. The typed issueCategory is mapped through the
|
|
2289
|
+
* frozen classifier; `unknown` (or an unreadable store) fails closed to
|
|
2290
|
+
* `undefined` so the runtime never trusts an untyped category. */
|
|
2291
|
+
async function collectReviewRestartPhase(runDir, reviewNodeId) {
|
|
2292
|
+
try {
|
|
2293
|
+
const records = await readTypedEventStoreFromJsonl(path.join(runDir, reviewNodeId, "review-typed-facts.jsonl"));
|
|
2294
|
+
const request = records.find((record) => record.phase === "committed" &&
|
|
2295
|
+
record.fact.kind === "request_review_changes");
|
|
2296
|
+
const issueCategory = request?.fact
|
|
2297
|
+
?.issueCategory;
|
|
2298
|
+
return typeof issueCategory === "string"
|
|
2299
|
+
? (classifyIssueCategoryRestartPhase(issueCategory) ?? undefined)
|
|
2300
|
+
: undefined;
|
|
2301
|
+
}
|
|
2302
|
+
catch {
|
|
2303
|
+
return undefined;
|
|
2304
|
+
}
|
|
2305
|
+
}
|
|
2306
|
+
/** A+B (AC-009): deterministic §4.10 restart phase for a committed
|
|
2307
|
+
* `request_design_changes` fact. Mirrors the review collector. */
|
|
2308
|
+
/** Read the committed design request as a bounded structured capsule. */
|
|
2309
|
+
async function collectDesignReviewFindings(runDir, designNodeId) {
|
|
2310
|
+
try {
|
|
2311
|
+
const records = await readTypedEventStoreFromJsonl(path.join(runDir, designNodeId, "design-typed-facts.jsonl"));
|
|
2312
|
+
const request = records.find((record) => record.phase === "committed" &&
|
|
2313
|
+
record.fact.kind ===
|
|
2314
|
+
"request_design_changes");
|
|
2315
|
+
const fact = request?.fact;
|
|
2316
|
+
const findings = Array.isArray(fact?.findings)
|
|
2317
|
+
? fact.findings.flatMap((finding) => {
|
|
2318
|
+
if (!finding || typeof finding !== "object")
|
|
2319
|
+
return [];
|
|
2320
|
+
const value = finding;
|
|
2321
|
+
if (!(["Critical", "Important", "Minor", "Info"].includes(value.severity) &&
|
|
2322
|
+
typeof value.issue === "string" && value.issue.trim().length > 0))
|
|
2323
|
+
return [];
|
|
2324
|
+
return [{
|
|
2325
|
+
severity: value.severity,
|
|
2326
|
+
...(typeof value.file === "string" && value.file.trim() ? { file: value.file } : {}),
|
|
2327
|
+
...(typeof value.line === "number" && Number.isInteger(value.line) && value.line > 0 ? { line: value.line } : {}),
|
|
2328
|
+
issue: value.issue,
|
|
2329
|
+
...(typeof value.requiredChange === "string" && value.requiredChange.trim() ? { requiredChange: value.requiredChange } : {}),
|
|
2330
|
+
}];
|
|
2331
|
+
}).slice(0, 16)
|
|
2332
|
+
: [];
|
|
2333
|
+
const evidenceRefs = Array.isArray(fact?.evidenceRefs)
|
|
2334
|
+
? fact.evidenceRefs.filter((ref) => typeof ref === "string" && ref.trim().length > 0).slice(0, 16)
|
|
2335
|
+
: [];
|
|
2336
|
+
return { findings, evidenceRefs };
|
|
2337
|
+
}
|
|
2338
|
+
catch {
|
|
2339
|
+
return { findings: [], evidenceRefs: [] };
|
|
2340
|
+
}
|
|
2341
|
+
}
|
|
2342
|
+
async function collectDesignRestartPhase(runDir, designNodeId) {
|
|
2343
|
+
try {
|
|
2344
|
+
const records = await readTypedEventStoreFromJsonl(path.join(runDir, designNodeId, "design-typed-facts.jsonl"));
|
|
2345
|
+
const request = records.find((record) => record.phase === "committed" &&
|
|
2346
|
+
record.fact.kind === "request_design_changes");
|
|
2347
|
+
const issueCategory = request?.fact
|
|
2348
|
+
?.issueCategory;
|
|
2349
|
+
return typeof issueCategory === "string"
|
|
2350
|
+
? (classifyIssueCategoryRestartPhase(issueCategory) ?? undefined)
|
|
2351
|
+
: undefined;
|
|
2352
|
+
}
|
|
2353
|
+
catch {
|
|
2354
|
+
return undefined;
|
|
2355
|
+
}
|
|
2356
|
+
}
|
|
2357
|
+
/**
|
|
2358
|
+
* Resolve the deterministic runtime skeleton for the frontend plan patch from
|
|
2359
|
+
* the DAG spec. The plan task carries it via `structuredContractOutput.skeleton`
|
|
2360
|
+
* (the only schema-recognized persistent channel); absence is a fail-closed
|
|
2361
|
+
* generation/configuration defect, never a reason to fall back to text.
|
|
2362
|
+
*/
|
|
2363
|
+
function resolveFrontendContractSkeleton(spec, planNodeId) {
|
|
2364
|
+
const planTask = spec.tasks.find((task) => task.id === planNodeId);
|
|
2365
|
+
const skeleton = planTask?.structuredContractOutput?.skeleton;
|
|
2366
|
+
if (!skeleton || Object.keys(skeleton).length === 0) {
|
|
2367
|
+
throw new Error(`frontend design policy blocked: missing runtime contract skeleton for ${planNodeId}`);
|
|
2368
|
+
}
|
|
2369
|
+
return skeleton;
|
|
2370
|
+
}
|
|
2371
|
+
async function collectFrontendSourceFreshness(input) {
|
|
2372
|
+
const entries = [];
|
|
2373
|
+
for (const source of input.sourceBinding?.sources ?? []) {
|
|
2374
|
+
entries.push({ path: source.path, sha256: source.sha256, fresh: true });
|
|
2375
|
+
}
|
|
2376
|
+
for (const evidencePath of input.contract.designEvidence.paths) {
|
|
2377
|
+
if (entries.some((entry) => entry.path === evidencePath))
|
|
2378
|
+
continue;
|
|
2379
|
+
try {
|
|
2380
|
+
const bytes = await readFile(path.join(input.workspaceRoot, evidencePath));
|
|
2381
|
+
entries.push({
|
|
2382
|
+
path: evidencePath,
|
|
2383
|
+
sha256: createHash("sha256").update(bytes).digest("hex"),
|
|
2384
|
+
fresh: true,
|
|
2385
|
+
});
|
|
2386
|
+
}
|
|
2387
|
+
catch {
|
|
2388
|
+
entries.push({
|
|
2389
|
+
path: evidencePath,
|
|
2390
|
+
sha256: "0".repeat(64),
|
|
2391
|
+
fresh: false,
|
|
2392
|
+
});
|
|
2393
|
+
}
|
|
2394
|
+
}
|
|
2395
|
+
return entries;
|
|
2396
|
+
}
|
|
2397
|
+
/** R3/R4 openspec invariants: frozen candidates must exist and content
|
|
2398
|
+
* snapshots must not have drifted. Citation is enforced upstream by the
|
|
2399
|
+
* prewrite gate read-event evidence and ledger specReference conformance. */
|
|
2400
|
+
async function checkFrontendOpenspecFacts(input) {
|
|
2401
|
+
const frozenCandidatePaths = input.config.openspecCandidatePaths ?? [];
|
|
2402
|
+
const candidateRoot = input.workspaceRoot;
|
|
2403
|
+
const missingCandidates = [];
|
|
2404
|
+
for (const candidate of frozenCandidatePaths) {
|
|
2405
|
+
try {
|
|
2406
|
+
await stat(path.join(candidateRoot, candidate));
|
|
2407
|
+
}
|
|
2408
|
+
catch {
|
|
2409
|
+
missingCandidates.push(candidate);
|
|
2410
|
+
}
|
|
2411
|
+
}
|
|
2412
|
+
if (missingCandidates.length > 0) {
|
|
2413
|
+
throw new Error(`frontend design policy blocked: openspec candidate paths frozen at generation time no longer exist on disk: ${missingCandidates.join(", ")}`);
|
|
2414
|
+
}
|
|
2415
|
+
const snapshots = input.config.openspecCandidateSnapshots;
|
|
2416
|
+
if (snapshots && snapshots.length > 0) {
|
|
2417
|
+
for (const snapshot of snapshots) {
|
|
2418
|
+
try {
|
|
2419
|
+
const bytes = await readFile(path.join(candidateRoot, snapshot.path));
|
|
2420
|
+
const actual = createHash("sha256").update(bytes).digest("hex");
|
|
2421
|
+
if (actual !== snapshot.sha256) {
|
|
2422
|
+
throw new Error(`frontend design policy blocked: openspec candidate content hash drifted: ${snapshot.path}`);
|
|
2423
|
+
}
|
|
2424
|
+
}
|
|
2425
|
+
catch (error) {
|
|
2426
|
+
if (error instanceof Error &&
|
|
2427
|
+
error.message.startsWith("frontend design policy blocked")) {
|
|
2428
|
+
throw error;
|
|
2429
|
+
}
|
|
2430
|
+
throw new Error(`frontend design policy blocked: openspec candidate unreadable: ${snapshot.path}`);
|
|
2431
|
+
}
|
|
2432
|
+
}
|
|
1952
2433
|
}
|
|
2434
|
+
}
|
|
2435
|
+
async function executeFrontendDesignPolicy(input, meta) {
|
|
2436
|
+
const started = Date.now();
|
|
2437
|
+
const shell = input.task.shell;
|
|
2438
|
+
const config = shell.frontendDesignPolicy;
|
|
1953
2439
|
try {
|
|
1954
|
-
|
|
2440
|
+
// 1. Materialize the canonical contract from committed typed facts. After
|
|
2441
|
+
// M9a the plan node's assistantText is a pure Markdown narrative; the
|
|
2442
|
+
// compile authority is the committed plan ledger ⊕ runtime skeleton.
|
|
2443
|
+
// Fail closed on missing committed facts — never fall back to text.
|
|
2444
|
+
const { readCommittedOriginFacts, checkCommittedOriginFacts } = await import("../workflows/dag/frontend-shadow-dual-write.js");
|
|
2445
|
+
// A+B (AC-001/003): fail-closed committed contract/scout typed facts.
|
|
2446
|
+
// Missing/uncommitted facts block here; never fall back to text parsing.
|
|
2447
|
+
const committedContractFacts = await readCommittedOriginFacts(meta.runDir, "frontend-contract-pi", "contract-typed-facts.jsonl");
|
|
2448
|
+
const contractCheck = checkCommittedOriginFacts({
|
|
2449
|
+
records: committedContractFacts,
|
|
2450
|
+
origin: "contract",
|
|
2451
|
+
});
|
|
2452
|
+
if (!contractCheck.ok) {
|
|
2453
|
+
return {
|
|
2454
|
+
ok: false,
|
|
2455
|
+
stdout: "",
|
|
2456
|
+
stderr: `frontend design policy blocked: ${contractCheck.reason}`,
|
|
2457
|
+
failureCategory: "invalid-output",
|
|
2458
|
+
durationMs: Date.now() - started,
|
|
2459
|
+
};
|
|
2460
|
+
}
|
|
2461
|
+
const committedScoutFacts = await readCommittedOriginFacts(meta.runDir, "frontend-scout-pi", "scout-typed-facts.jsonl");
|
|
2462
|
+
const scoutCheck = checkCommittedOriginFacts({
|
|
2463
|
+
records: committedScoutFacts,
|
|
2464
|
+
origin: "scout",
|
|
2465
|
+
});
|
|
2466
|
+
if (!scoutCheck.ok) {
|
|
2467
|
+
return {
|
|
2468
|
+
ok: false,
|
|
2469
|
+
stdout: "",
|
|
2470
|
+
stderr: `frontend design policy blocked: ${scoutCheck.reason}`,
|
|
2471
|
+
failureCategory: "invalid-output",
|
|
2472
|
+
durationMs: Date.now() - started,
|
|
2473
|
+
};
|
|
2474
|
+
}
|
|
2475
|
+
const skeleton = resolveFrontendContractSkeleton(meta.spec, config.planFromNodeId);
|
|
2476
|
+
const assembled = await buildContractFromCommittedFacts({
|
|
2477
|
+
runDir: meta.runDir,
|
|
2478
|
+
planNodeId: config.planFromNodeId,
|
|
2479
|
+
contractNodeId: "frontend-contract-pi",
|
|
2480
|
+
sourceBinding: meta.spec.sourceBinding,
|
|
2481
|
+
skeleton,
|
|
2482
|
+
});
|
|
2483
|
+
if (!assembled.ok) {
|
|
2484
|
+
return {
|
|
2485
|
+
ok: false,
|
|
2486
|
+
stdout: "",
|
|
2487
|
+
stderr: `frontend design policy blocked: ${assembled.reason}`,
|
|
2488
|
+
failureCategory: "invalid-output",
|
|
2489
|
+
durationMs: Date.now() - started,
|
|
2490
|
+
};
|
|
2491
|
+
}
|
|
2492
|
+
const contract = assembled.canonical;
|
|
2493
|
+
// 2. Requirement id retention (R11): search the canonical contract
|
|
2494
|
+
// serialization instead of the plan node narrative.
|
|
2495
|
+
const contractText = serializeCompactDeterministicJson(contract);
|
|
2496
|
+
const missingIds = config.requiredRequirementIds.filter((id) => !contractText.includes(id));
|
|
2497
|
+
if (missingIds.length > 0) {
|
|
2498
|
+
return {
|
|
2499
|
+
ok: false,
|
|
2500
|
+
stdout: "",
|
|
2501
|
+
stderr: `frontend design policy blocked: missing requirement ids: ${missingIds.join(", ")}`,
|
|
2502
|
+
failureCategory: "invalid-output",
|
|
2503
|
+
durationMs: Date.now() - started,
|
|
2504
|
+
};
|
|
2505
|
+
}
|
|
2506
|
+
// 3. Mock strategy allowed + frozen command binding (R1).
|
|
2507
|
+
const mockStrategy = contract.mockApi.strategy;
|
|
2508
|
+
if (!config.allowedMockStrategies.includes(mockStrategy)) {
|
|
2509
|
+
return {
|
|
2510
|
+
ok: false,
|
|
2511
|
+
stdout: "",
|
|
2512
|
+
stderr: `frontend contract mock strategy "${mockStrategy}" is incompatible with the generated allowed strategies [${config.allowedMockStrategies.join(", ")}]`,
|
|
2513
|
+
failureCategory: "invalid-output",
|
|
2514
|
+
durationMs: Date.now() - started,
|
|
2515
|
+
};
|
|
2516
|
+
}
|
|
2517
|
+
if (mockStrategy !== "not-needed" && config.mockCommandLabels.length === 0) {
|
|
2518
|
+
return {
|
|
2519
|
+
ok: false,
|
|
2520
|
+
stdout: "",
|
|
2521
|
+
stderr: `frontend design policy blocked: contract selected Mock strategy ${mockStrategy} but the DAG has no authorized Mock verification commands`,
|
|
2522
|
+
failureCategory: "invalid-output",
|
|
2523
|
+
durationMs: Date.now() - started,
|
|
2524
|
+
};
|
|
2525
|
+
}
|
|
2526
|
+
// 4. writeSet containment.
|
|
2527
|
+
if (config.implementationWriteSet) {
|
|
2528
|
+
const writeSet = new Set(config.implementationWriteSet);
|
|
2529
|
+
const uncoveredTargets = contract.targets.files.filter((target) => ![...writeSet].some((pattern) => pathMatchesPattern(target, pattern) || target === pattern));
|
|
2530
|
+
if (uncoveredTargets.length > 0) {
|
|
2531
|
+
return {
|
|
2532
|
+
ok: false,
|
|
2533
|
+
stdout: "",
|
|
2534
|
+
stderr: `frontend design policy blocked: contract target is outside implementation writeSet: ${uncoveredTargets.join(", ")}`,
|
|
2535
|
+
failureCategory: "invalid-output",
|
|
2536
|
+
durationMs: Date.now() - started,
|
|
2537
|
+
};
|
|
2538
|
+
}
|
|
2539
|
+
const uncoveredVTs = contract.verificationTargets
|
|
2540
|
+
.filter((vt) => vt.mode !== "static")
|
|
2541
|
+
.filter((vt) => ![...writeSet].some((pattern) => pathMatchesPattern(vt.file, pattern) || vt.file === pattern));
|
|
2542
|
+
if (uncoveredVTs.length > 0) {
|
|
2543
|
+
return {
|
|
2544
|
+
ok: false,
|
|
2545
|
+
stdout: "",
|
|
2546
|
+
stderr: `frontend design policy blocked: verification target is outside implementation writeSet: ${uncoveredVTs.map((vt) => vt.file).join(", ")}`,
|
|
2547
|
+
failureCategory: "invalid-output",
|
|
2548
|
+
durationMs: Date.now() - started,
|
|
2549
|
+
};
|
|
2550
|
+
}
|
|
2551
|
+
}
|
|
2552
|
+
// 5. Source freshness (R4) + freshness entries.
|
|
2553
|
+
if (config.requireSourceFreshness) {
|
|
2554
|
+
if (!meta.spec.sourceBinding) {
|
|
2555
|
+
throw new Error("frontend design policy requires sourceBinding for freshness check");
|
|
2556
|
+
}
|
|
2557
|
+
await assertFrontendSourceBindingFresh({
|
|
2558
|
+
workspaceRoot: input.cwd,
|
|
2559
|
+
binding: meta.spec.sourceBinding,
|
|
2560
|
+
});
|
|
2561
|
+
}
|
|
2562
|
+
// Byte freshness is necessary but not sufficient: require the same ledger
|
|
2563
|
+
// semantic checks as the shadow prewrite gate before production writer
|
|
2564
|
+
// admission can be materialized.
|
|
2565
|
+
if (meta.spec.sourceBinding) {
|
|
2566
|
+
const ledgerCheck = await checkFrontendSourceFidelityLedger({
|
|
2567
|
+
workspaceRoot: input.cwd,
|
|
2568
|
+
binding: meta.spec.sourceBinding,
|
|
2569
|
+
contractRequirements: contract.requirements.map((requirement) => ({
|
|
2570
|
+
id: requirement.id,
|
|
2571
|
+
sourceFragmentIds: requirement.sourceFragmentIds,
|
|
2572
|
+
sourceRefs: requirement.sourceRefs,
|
|
2573
|
+
})),
|
|
2574
|
+
});
|
|
2575
|
+
if (!ledgerCheck.ok) {
|
|
2576
|
+
return {
|
|
2577
|
+
ok: false,
|
|
2578
|
+
stdout: "",
|
|
2579
|
+
stderr: `frontend design policy blocked: ${ledgerCheck.failureReason ?? "source fidelity ledger validation failed"}`,
|
|
2580
|
+
failureCategory: "invalid-output",
|
|
2581
|
+
durationMs: Date.now() - started,
|
|
2582
|
+
};
|
|
2583
|
+
}
|
|
2584
|
+
}
|
|
2585
|
+
const sourceFreshness = await collectFrontendSourceFreshness({
|
|
2586
|
+
workspaceRoot: input.cwd,
|
|
2587
|
+
sourceBinding: meta.spec.sourceBinding,
|
|
2588
|
+
contract,
|
|
2589
|
+
});
|
|
2590
|
+
// 6. Openspec invariants (R3): frozen candidates exist and snapshots have
|
|
2591
|
+
// not drifted. Citation is superseded by prewrite-gate read evidence.
|
|
2592
|
+
await checkFrontendOpenspecFacts({
|
|
2593
|
+
workspaceRoot: input.cwd,
|
|
2594
|
+
config,
|
|
2595
|
+
});
|
|
2596
|
+
// 7. Deterministic design policy (M8 D2: designApproval is optional here;
|
|
2597
|
+
// the design verdict is enforced by the writer-admission shell).
|
|
2598
|
+
const policyResult = evaluateFrontendDesignPolicy({
|
|
2599
|
+
contract,
|
|
2600
|
+
allowedMockStrategies: config.allowedMockStrategies,
|
|
2601
|
+
sourceFreshness,
|
|
2602
|
+
componentSpecCandidatePaths: config.openspecCandidatePaths ??
|
|
2603
|
+
config.componentSpecCandidatePaths ??
|
|
2604
|
+
[],
|
|
2605
|
+
allowedDependencies: config.allowedDependencies,
|
|
2606
|
+
writeSetPatterns: config.implementationWriteSet ?? [],
|
|
2607
|
+
});
|
|
2608
|
+
// 8. Write canonical contract + policy result.
|
|
2609
|
+
const contractArtifact = await writeFrontendImplementationContractArtifact({
|
|
1955
2610
|
runDir: meta.runDir,
|
|
1956
|
-
|
|
2611
|
+
outputDir: config.outputDir,
|
|
2612
|
+
artifactName: config.artifactName,
|
|
2613
|
+
canonical: contract,
|
|
1957
2614
|
});
|
|
1958
|
-
await
|
|
2615
|
+
await writeDagRunJsonArtifact(meta.runDir, "contracts/frontend-design-policy-result.json", policyResult);
|
|
2616
|
+
if (policyResult.classification === "blocked") {
|
|
2617
|
+
return {
|
|
2618
|
+
ok: false,
|
|
2619
|
+
stdout: "",
|
|
2620
|
+
stderr: `frontend design policy blocked: ${policyResult.findings.map((finding) => `${finding.code}: ${finding.message}`).join("; ")}`,
|
|
2621
|
+
failureCategory: "invalid-output",
|
|
2622
|
+
durationMs: Date.now() - started,
|
|
2623
|
+
};
|
|
2624
|
+
}
|
|
1959
2625
|
return {
|
|
1960
2626
|
ok: true,
|
|
1961
|
-
stdout:
|
|
2627
|
+
stdout: [
|
|
2628
|
+
"Frontend design policy: approved findings=0",
|
|
2629
|
+
`Contract: ${contractArtifact.path}`,
|
|
2630
|
+
`Contract index: ${contractArtifact.reviewIndexPath}`,
|
|
2631
|
+
`Capacity diagnostic: ${contractArtifact.capacityDiagnosticPath} (non-blocking)`,
|
|
2632
|
+
].join("\n"),
|
|
1962
2633
|
stderr: "",
|
|
1963
2634
|
failureCategory: "success",
|
|
1964
2635
|
durationMs: Date.now() - started,
|
|
1965
|
-
...{ commandResults },
|
|
1966
2636
|
};
|
|
1967
2637
|
}
|
|
1968
2638
|
catch (error) {
|
|
@@ -1972,30 +2642,180 @@ async function executeFrontendVerificationBundle(input, meta) {
|
|
|
1972
2642
|
stderr: error instanceof Error ? error.message : String(error),
|
|
1973
2643
|
failureCategory: "invalid-output",
|
|
1974
2644
|
durationMs: Date.now() - started,
|
|
1975
|
-
...{ commandResults },
|
|
1976
2645
|
};
|
|
1977
2646
|
}
|
|
1978
2647
|
}
|
|
1979
|
-
async function
|
|
2648
|
+
async function executeFrontendWriterAdmission(input, meta) {
|
|
1980
2649
|
const started = Date.now();
|
|
2650
|
+
const shell = input.task.shell;
|
|
2651
|
+
const config = shell.frontendWriterAdmission;
|
|
1981
2652
|
try {
|
|
1982
|
-
|
|
1983
|
-
|
|
2653
|
+
// 1. Design verdict handling. The typed terminal
|
|
2654
|
+
// verdict is read from the committed typed design terminal fact, not
|
|
2655
|
+
// from the legacy first-line VERDICT text protocol (AC-003/AC-004).
|
|
2656
|
+
// A request_design_changes verdict blocks writer admission and is copied
|
|
2657
|
+
// into the receipt as a bounded advisory capsule for recovery. A missing
|
|
2658
|
+
// typed terminal verdict still fails closed. In small topology the design
|
|
2659
|
+
// review node is absent and the check is vacuous.
|
|
2660
|
+
let verdictPass = true;
|
|
2661
|
+
let designRequested = false;
|
|
2662
|
+
let designAdvisory;
|
|
2663
|
+
if (config.designReviewFromNodeId) {
|
|
2664
|
+
const designKinds = await collectDesignTerminalKinds(meta.runDir, config.designReviewFromNodeId);
|
|
2665
|
+
if (designKinds.length !== 1) {
|
|
2666
|
+
verdictPass = false;
|
|
2667
|
+
}
|
|
2668
|
+
else if (designKinds[0] !== "approve_design") {
|
|
2669
|
+
designRequested = true;
|
|
2670
|
+
const designFindings = await collectDesignReviewFindings(meta.runDir, config.designReviewFromNodeId);
|
|
2671
|
+
designAdvisory = {
|
|
2672
|
+
verdict: "request_design_changes",
|
|
2673
|
+
restartPhase: await collectDesignRestartPhase(meta.runDir, config.designReviewFromNodeId),
|
|
2674
|
+
findingCount: designFindings.findings.length,
|
|
2675
|
+
findings: designFindings.findings,
|
|
2676
|
+
evidenceRefs: designFindings.evidenceRefs,
|
|
2677
|
+
};
|
|
2678
|
+
verdictPass = false;
|
|
2679
|
+
}
|
|
2680
|
+
}
|
|
2681
|
+
// 2. Read the canonical contract + design-policy result.
|
|
2682
|
+
const contractRaw = await readRunDirJson(meta.runDir, "contracts/frontend-implementation-contract.json");
|
|
2683
|
+
const contract = frontendImplementationContractSchema.parse(contractRaw);
|
|
2684
|
+
const policyRaw = (await readRunDirJson(meta.runDir, "contracts/frontend-design-policy-result.json"));
|
|
2685
|
+
if (policyRaw.schemaId !== "frontend-design-policy-v1") {
|
|
2686
|
+
throw new Error("frontend writer admission: design policy result artifact invalid");
|
|
2687
|
+
}
|
|
2688
|
+
const designPolicyResult = {
|
|
2689
|
+
schemaId: "frontend-design-policy-v1",
|
|
2690
|
+
classification: policyRaw.classification === "approved" ? "approved" : "blocked",
|
|
2691
|
+
findings: policyRaw.findings ?? [],
|
|
2692
|
+
digest: "",
|
|
2693
|
+
};
|
|
2694
|
+
// 3. Freeze the pre-writer worktree baseline (cumulative diff baseline).
|
|
2695
|
+
await captureFrontendWorktreeBaseline({
|
|
2696
|
+
runDir: meta.runDir,
|
|
1984
2697
|
workspaceRoot: input.cwd,
|
|
1985
|
-
declaredAcIds,
|
|
1986
2698
|
});
|
|
1987
|
-
|
|
2699
|
+
const baselineRaw = (await readRunDirJson(meta.runDir, "contracts/frontend-worktree-baseline.json"));
|
|
2700
|
+
const baseline = (baselineRaw.files ?? [])
|
|
2701
|
+
.map((file) => ({
|
|
2702
|
+
path: file,
|
|
2703
|
+
sha256: baselineRaw.hashes?.[file] ?? null,
|
|
2704
|
+
}))
|
|
2705
|
+
.filter((entry) => entry.sha256 !== null);
|
|
2706
|
+
// 4. Writer-preceding lint baseline (R5) when lint is configured.
|
|
2707
|
+
let lintResults = [];
|
|
2708
|
+
if ((config.lintCommands?.length ?? 0) > 0) {
|
|
2709
|
+
for (const command of config.lintCommands) {
|
|
2710
|
+
const commandNumber = lintResults.length + 1;
|
|
2711
|
+
const result = await executeShellCommand({
|
|
2712
|
+
command,
|
|
2713
|
+
cwd: input.cwd,
|
|
2714
|
+
timeoutMs: shell.timeoutMs ?? DEFAULT_SHELL_TIMEOUT_MS,
|
|
2715
|
+
envAllowlist: shell.envAllowlist,
|
|
2716
|
+
dagRunMeta: { runDir: meta.runDir, runId: meta.runId },
|
|
2717
|
+
reportActivity: input.reportActivity,
|
|
2718
|
+
outputArtifacts: {
|
|
2719
|
+
stdoutPath: path.join(meta.runDir, input.task.id, "commands", `${commandNumber}.stdout.txt`),
|
|
2720
|
+
stderrPath: path.join(meta.runDir, input.task.id, "commands", `${commandNumber}.stderr.txt`),
|
|
2721
|
+
},
|
|
2722
|
+
});
|
|
2723
|
+
lintResults.push(result);
|
|
2724
|
+
}
|
|
2725
|
+
await materializeFrontendLintBaseline({
|
|
2726
|
+
runDir: meta.runDir,
|
|
2727
|
+
workspaceRoot: input.cwd,
|
|
2728
|
+
commands: config.lintCommands,
|
|
2729
|
+
results: lintResults,
|
|
2730
|
+
worktreeChanged: false,
|
|
2731
|
+
});
|
|
2732
|
+
}
|
|
2733
|
+
// 5. Derive admission (writeSet + digests + findings). Glob entries in
|
|
2734
|
+
// the contract targets (e.g. `src/**` inherited from the skeleton) are
|
|
2735
|
+
// expanded against the concrete workspace files so the derived writeSet
|
|
2736
|
+
// contains only real paths the writer can touch.
|
|
2737
|
+
const workspaceFiles = await collectWorkspaceFiles(input.cwd);
|
|
2738
|
+
const admission = deriveFrontendWriterAdmissionShell({
|
|
2739
|
+
contract,
|
|
2740
|
+
designPolicyResult,
|
|
2741
|
+
baseline,
|
|
2742
|
+
frozenCommandLabels: config.frozenCommandLabels,
|
|
2743
|
+
allowedMockStrategies: config.allowedMockStrategies,
|
|
2744
|
+
workspaceFiles,
|
|
2745
|
+
});
|
|
2746
|
+
// 6. Design verdict enforcement: request_design_changes is a blocked
|
|
2747
|
+
// admission. This keeps the writer fail-closed until the recovery plan
|
|
2748
|
+
// has incorporated the reviewer's concrete findings.
|
|
2749
|
+
const failureSource = policyRaw.classification === "blocked"
|
|
2750
|
+
? "frontend-design-policy-shell"
|
|
2751
|
+
: "frontend-writer-admission-shell";
|
|
2752
|
+
const findings = verdictPass
|
|
2753
|
+
? admission.findings
|
|
2754
|
+
: [
|
|
2755
|
+
...admission.findings,
|
|
2756
|
+
{
|
|
2757
|
+
code: designRequested
|
|
2758
|
+
? "design-review-requested"
|
|
2759
|
+
: "design-approval-missing",
|
|
2760
|
+
message: designRequested
|
|
2761
|
+
? "design review requested changes; writer admission is blocked until recovery incorporates the committed findings"
|
|
2762
|
+
: "design review typed terminal verdict missing or ambiguous (fail closed)",
|
|
2763
|
+
},
|
|
2764
|
+
];
|
|
2765
|
+
const classification = findings.length === 0 && admission.classification === "accepted"
|
|
2766
|
+
? admission.classification
|
|
2767
|
+
: findings.length === 0 &&
|
|
2768
|
+
admission.classification === "requires-human-approval"
|
|
2769
|
+
? "requires-human-approval"
|
|
2770
|
+
: "blocked";
|
|
2771
|
+
const result = frontendWriterAdmissionResultV1Schema.parse({
|
|
2772
|
+
schemaVersion: 1,
|
|
2773
|
+
schemaId: "frontend-writer-admission-shell-v1",
|
|
2774
|
+
classification,
|
|
2775
|
+
writeSet: admission.writeSet,
|
|
2776
|
+
writeSetDigest: admission.writeSetDigest,
|
|
2777
|
+
baselineDigest: admission.baselineDigest,
|
|
2778
|
+
admissionDigest: admission.admissionDigest,
|
|
2779
|
+
...(admission.baselineDebtPolicy !== undefined
|
|
2780
|
+
? { baselineDebtPolicy: admission.baselineDebtPolicy }
|
|
2781
|
+
: {}),
|
|
2782
|
+
findings,
|
|
2783
|
+
...(designAdvisory ? { designReviewAdvisory: designAdvisory } : {}),
|
|
2784
|
+
failureSource,
|
|
2785
|
+
});
|
|
2786
|
+
await writeDagRunJsonArtifact(meta.runDir, FRONTEND_WRITER_ADMISSION_RESULT_ARTIFACT, result);
|
|
2787
|
+
// A+B (AC-007): High topology materializes a `high-admission-receipt-v1`
|
|
2788
|
+
// catalog whose candidate digest must match the admission digest before
|
|
2789
|
+
// the gate can transition from `requires-human-approval` to `accepted`.
|
|
2790
|
+
// Any digest drift resolves to `stale` (never silently accepted).
|
|
2791
|
+
if (classification === "requires-human-approval") {
|
|
2792
|
+
const receipt = evaluateHighAdmissionReceipt({
|
|
2793
|
+
candidateDigest: result.admissionDigest,
|
|
2794
|
+
admissionDigest: result.admissionDigest,
|
|
2795
|
+
});
|
|
2796
|
+
await writeDagRunJsonArtifact(meta.runDir, "contracts/frontend-high-admission-receipt.json", receipt);
|
|
2797
|
+
if (receipt.status !== "accepted") {
|
|
2798
|
+
return {
|
|
2799
|
+
ok: false,
|
|
2800
|
+
stdout: "",
|
|
2801
|
+
stderr: `frontend writer admission stale: high-admission receipt candidate digest drifted from admission digest`,
|
|
2802
|
+
failureCategory: "invalid-output",
|
|
2803
|
+
durationMs: Date.now() - started,
|
|
2804
|
+
};
|
|
2805
|
+
}
|
|
2806
|
+
}
|
|
2807
|
+
if (classification === "blocked") {
|
|
1988
2808
|
return {
|
|
1989
2809
|
ok: false,
|
|
1990
2810
|
stdout: "",
|
|
1991
|
-
stderr: `frontend
|
|
2811
|
+
stderr: `frontend writer admission ${classification}: ${findings.map((finding) => `${finding.code}: ${finding.message}`).join("; ")}`,
|
|
1992
2812
|
failureCategory: "invalid-output",
|
|
1993
2813
|
durationMs: Date.now() - started,
|
|
1994
2814
|
};
|
|
1995
2815
|
}
|
|
1996
2816
|
return {
|
|
1997
2817
|
ok: true,
|
|
1998
|
-
stdout: `
|
|
2818
|
+
stdout: `Frontend writer admission: ${classification} writeSet=${result.writeSet.length} writeSetDigest=${result.writeSetDigest}`,
|
|
1999
2819
|
stderr: "",
|
|
2000
2820
|
failureCategory: "success",
|
|
2001
2821
|
durationMs: Date.now() - started,
|
|
@@ -2011,12 +2831,219 @@ async function executeFrontendTestCaseChecklist(input, meta) {
|
|
|
2011
2831
|
};
|
|
2012
2832
|
}
|
|
2013
2833
|
}
|
|
2014
|
-
async function
|
|
2834
|
+
async function executeFrontendContractImport(input, meta) {
|
|
2835
|
+
const started = Date.now();
|
|
2836
|
+
const shell = input.task.shell;
|
|
2837
|
+
const config = shell.frontendContractImport;
|
|
2838
|
+
try {
|
|
2839
|
+
const binding = meta.spec.sourceBinding;
|
|
2840
|
+
if (!binding) {
|
|
2841
|
+
throw new Error("frontend contract-import requires a DAG sourceBinding to re-validate freshness");
|
|
2842
|
+
}
|
|
2843
|
+
if (config.requireSourceFreshness) {
|
|
2844
|
+
await assertFrontendSourceBindingFresh({
|
|
2845
|
+
workspaceRoot: input.cwd,
|
|
2846
|
+
binding,
|
|
2847
|
+
});
|
|
2848
|
+
}
|
|
2849
|
+
const digest = createHash("sha256")
|
|
2850
|
+
.update(JSON.stringify({
|
|
2851
|
+
taskId: binding.taskId,
|
|
2852
|
+
sources: binding.sources,
|
|
2853
|
+
artifactName: config.artifactName,
|
|
2854
|
+
}))
|
|
2855
|
+
.digest("hex");
|
|
2856
|
+
const facts = {
|
|
2857
|
+
schemaVersion: 1,
|
|
2858
|
+
schemaId: "frontend-contract-import-v1",
|
|
2859
|
+
artifactName: config.artifactName,
|
|
2860
|
+
sourceBindingTaskId: binding.taskId,
|
|
2861
|
+
sourceCount: binding.sources.length,
|
|
2862
|
+
fresh: true,
|
|
2863
|
+
digest,
|
|
2864
|
+
};
|
|
2865
|
+
return {
|
|
2866
|
+
ok: true,
|
|
2867
|
+
stdout: JSON.stringify(facts, null, 2),
|
|
2868
|
+
stderr: "",
|
|
2869
|
+
failureCategory: "success",
|
|
2870
|
+
durationMs: Date.now() - started,
|
|
2871
|
+
};
|
|
2872
|
+
}
|
|
2873
|
+
catch (error) {
|
|
2874
|
+
return {
|
|
2875
|
+
ok: false,
|
|
2876
|
+
stdout: "",
|
|
2877
|
+
stderr: error instanceof Error ? error.message : String(error),
|
|
2878
|
+
failureCategory: "invalid-output",
|
|
2879
|
+
durationMs: Date.now() - started,
|
|
2880
|
+
};
|
|
2881
|
+
}
|
|
2882
|
+
}
|
|
2883
|
+
async function executeFrontendCloseout(input, meta) {
|
|
2884
|
+
const started = Date.now();
|
|
2885
|
+
const shell = input.task.shell;
|
|
2886
|
+
const config = shell.frontendCloseout;
|
|
2887
|
+
try {
|
|
2888
|
+
const context = (await readRunDirJson(meta.runDir, "contracts/frontend-review-context.json"));
|
|
2889
|
+
if (context.contractRef?.path !==
|
|
2890
|
+
"contracts/frontend-implementation-contract.json") {
|
|
2891
|
+
throw new Error("frontend closeout missing canonical contract reference");
|
|
2892
|
+
}
|
|
2893
|
+
const contractRaw = await readFile(path.join(meta.runDir, context.contractRef.path), "utf8");
|
|
2894
|
+
const contractSha256 = createHash("sha256")
|
|
2895
|
+
.update(contractRaw)
|
|
2896
|
+
.digest("hex");
|
|
2897
|
+
if (contractSha256 !== context.contractRef.sha256) {
|
|
2898
|
+
throw new Error("frontend closeout canonical contract hash mismatch");
|
|
2899
|
+
}
|
|
2900
|
+
const contract = frontendImplementationContractSchema.parse(JSON.parse(contractRaw));
|
|
2901
|
+
const trace = context.verificationTrace;
|
|
2902
|
+
const verificationTargets = (trace?.targets ?? []).map((target) => ({
|
|
2903
|
+
status: target.status === "ok" ? "ok" : "failed",
|
|
2904
|
+
}));
|
|
2905
|
+
const mockEvidenceBound = contract.mockApi.strategy !== "not-needed" &&
|
|
2906
|
+
typeof trace?.mockCommandNodeId === "string" &&
|
|
2907
|
+
trace.mockCommandNodeId.length > 0 &&
|
|
2908
|
+
Array.isArray(trace?.mockCommandLabels) &&
|
|
2909
|
+
trace.mockCommandLabels.length > 0 &&
|
|
2910
|
+
Array.isArray(trace?.mockCommandTexts) &&
|
|
2911
|
+
trace.mockCommandTexts.length === trace.mockCommandLabels.length;
|
|
2912
|
+
const integrationFacts = deriveFrontendIntegrationFacts({
|
|
2913
|
+
mockStrategy: contract.mockApi.strategy,
|
|
2914
|
+
realApiEvidence: { present: false, passed: false },
|
|
2915
|
+
mockEvidenceBound,
|
|
2916
|
+
verificationTargets,
|
|
2917
|
+
});
|
|
2918
|
+
// Typed review terminal (AC-003) from the committed typed event store.
|
|
2919
|
+
const typedKinds = await collectReviewTerminalKinds(meta.runDir, config.reviewFromNodeId);
|
|
2920
|
+
const typedVerdict = typedKinds.length === 1 &&
|
|
2921
|
+
(typedKinds[0] === "approve_review" || typedKinds[0] === "request_review_changes")
|
|
2922
|
+
? typedKinds[0]
|
|
2923
|
+
: null;
|
|
2924
|
+
// A+B (AC-009): request_review_changes issueCategory maps to the
|
|
2925
|
+
// deterministic §4.10 restart phase. Recorded as a run-owned audit
|
|
2926
|
+
// artifact so the frozen closeout schema is never widened; `unknown`
|
|
2927
|
+
// fails closed to no restart phase.
|
|
2928
|
+
const reviewRestartPhase = typedVerdict === "request_review_changes"
|
|
2929
|
+
? await collectReviewRestartPhase(meta.runDir, config.reviewFromNodeId)
|
|
2930
|
+
: undefined;
|
|
2931
|
+
if (reviewRestartPhase !== undefined) {
|
|
2932
|
+
await writeDagRunJsonArtifact(meta.runDir, "contracts/frontend-review-restart-phase.json", {
|
|
2933
|
+
schemaVersion: 1,
|
|
2934
|
+
nodeId: config.reviewFromNodeId,
|
|
2935
|
+
restartPhase: reviewRestartPhase,
|
|
2936
|
+
});
|
|
2937
|
+
}
|
|
2938
|
+
const facts = frontendCloseoutFactsSchema.parse({
|
|
2939
|
+
schemaVersion: 1,
|
|
2940
|
+
schemaId: "frontend-closeout-facts-v1",
|
|
2941
|
+
coverageMatrix: verificationTargets.map((target, index) => ({
|
|
2942
|
+
verificationTargetId: trace?.targets?.[index]?.id ?? `vt-${index}`,
|
|
2943
|
+
status: target.status === "ok" ? "passed" : "failed",
|
|
2944
|
+
})),
|
|
2945
|
+
lintStatus: "unavailable",
|
|
2946
|
+
integrationFacts,
|
|
2947
|
+
reviewApproval: {
|
|
2948
|
+
typedVerdict,
|
|
2949
|
+
legacyVerdict: null,
|
|
2950
|
+
match: true,
|
|
2951
|
+
},
|
|
2952
|
+
cumulativeDiff: {
|
|
2953
|
+
cumulativeDigest: (typeof context.verificationTrace === "object" &&
|
|
2954
|
+
context.verificationTrace !== null &&
|
|
2955
|
+
"schemaId" in context.verificationTrace
|
|
2956
|
+
? deterministicSha256({ verificationTrace: context.verificationTrace })
|
|
2957
|
+
: deterministicSha256({})),
|
|
2958
|
+
empty: false,
|
|
2959
|
+
},
|
|
2960
|
+
notRun: { browser: "not-run", visual: "not-run" },
|
|
2961
|
+
pendingRealIntegration: integrationFacts !== "real-api",
|
|
2962
|
+
});
|
|
2963
|
+
const rendered = renderFrontendCloseout(facts);
|
|
2964
|
+
await writeDagRunJsonArtifact(meta.runDir, "contracts/frontend-closeout-facts.json", facts);
|
|
2965
|
+
// A+B (AC-010): materialize the deterministic frontend-test handoff.
|
|
2966
|
+
// browser/visual/runtime-a11y are always `not-run` and the handoff is
|
|
2967
|
+
// always `deferred-to-frontend-test`, so it never blocks implementation
|
|
2968
|
+
// and can never be rewritten into a passed result.
|
|
2969
|
+
const handoffTaskId = meta.spec.sourceBinding?.taskId ?? input.task.id;
|
|
2970
|
+
const sourceDigest = meta.spec.sourceBinding
|
|
2971
|
+
? createHash("sha256")
|
|
2972
|
+
.update(JSON.stringify({
|
|
2973
|
+
taskId: meta.spec.sourceBinding.taskId,
|
|
2974
|
+
sources: meta.spec.sourceBinding.sources,
|
|
2975
|
+
}))
|
|
2976
|
+
.digest("hex")
|
|
2977
|
+
: deterministicSha256({});
|
|
2978
|
+
const handoff = buildFrontendTestHandoff({
|
|
2979
|
+
taskId: handoffTaskId,
|
|
2980
|
+
sourceDigest,
|
|
2981
|
+
candidateHash: facts.cumulativeDiff.cumulativeDigest,
|
|
2982
|
+
});
|
|
2983
|
+
await writeDagRunJsonArtifact(meta.runDir, "contracts/frontend-test-handoff.json", handoff);
|
|
2984
|
+
await writeDagNodeTextArtifact(meta.runDir, input.task.id, "frontend-closeout.md", rendered);
|
|
2985
|
+
return {
|
|
2986
|
+
ok: true,
|
|
2987
|
+
stdout: `Frontend closeout rendered\n${rendered.split("\n").slice(0, 8).join("\n")}`,
|
|
2988
|
+
stderr: "",
|
|
2989
|
+
failureCategory: "success",
|
|
2990
|
+
durationMs: Date.now() - started,
|
|
2991
|
+
};
|
|
2992
|
+
}
|
|
2993
|
+
catch (error) {
|
|
2994
|
+
return {
|
|
2995
|
+
ok: false,
|
|
2996
|
+
stdout: "",
|
|
2997
|
+
stderr: error instanceof Error ? error.message : String(error),
|
|
2998
|
+
failureCategory: "invalid-output",
|
|
2999
|
+
durationMs: Date.now() - started,
|
|
3000
|
+
};
|
|
3001
|
+
}
|
|
3002
|
+
}
|
|
3003
|
+
async function executeFrontendTestCaseChecklist(input, meta) {
|
|
3004
|
+
const started = Date.now();
|
|
3005
|
+
try {
|
|
3006
|
+
const layout = frontendTestLayoutFromSpec(meta.spec);
|
|
3007
|
+
const declaredAcIds = (meta.spec.sourceBinding?.requirementIds ?? []).filter((id) => /^AC(?:-[A-Z0-9]+)+$/i.test(id));
|
|
3008
|
+
const result = await validateFrontendCaseChecklist({
|
|
3009
|
+
workspaceRoot: input.cwd,
|
|
3010
|
+
declaredAcIds,
|
|
3011
|
+
layout,
|
|
3012
|
+
});
|
|
3013
|
+
if (result.issues.length) {
|
|
3014
|
+
return {
|
|
3015
|
+
ok: false,
|
|
3016
|
+
stdout: "",
|
|
3017
|
+
stderr: `frontend-test checklist blocked: ${JSON.stringify(result.issues)}`,
|
|
3018
|
+
failureCategory: "invalid-output",
|
|
3019
|
+
durationMs: Date.now() - started,
|
|
3020
|
+
};
|
|
3021
|
+
}
|
|
3022
|
+
return {
|
|
3023
|
+
ok: true,
|
|
3024
|
+
stdout: `frontend-test checklist ok cases=${result.caseCount} source=${path.basename(result.manifestPath)}`,
|
|
3025
|
+
stderr: "",
|
|
3026
|
+
failureCategory: "success",
|
|
3027
|
+
durationMs: Date.now() - started,
|
|
3028
|
+
};
|
|
3029
|
+
}
|
|
3030
|
+
catch (error) {
|
|
3031
|
+
return {
|
|
3032
|
+
ok: false,
|
|
3033
|
+
stdout: "",
|
|
3034
|
+
stderr: error instanceof Error ? error.message : String(error),
|
|
3035
|
+
failureCategory: "invalid-output",
|
|
3036
|
+
durationMs: Date.now() - started,
|
|
3037
|
+
};
|
|
3038
|
+
}
|
|
3039
|
+
}
|
|
3040
|
+
async function executeFrontendTestL5Report(input, meta) {
|
|
2015
3041
|
const started = Date.now();
|
|
2016
3042
|
try {
|
|
2017
3043
|
const output = await renderFrontendTestL5Report({
|
|
2018
3044
|
workspaceRoot: input.cwd,
|
|
2019
3045
|
runDir: meta.runDir,
|
|
3046
|
+
layout: frontendTestLayoutFromSpec(meta.spec),
|
|
2020
3047
|
});
|
|
2021
3048
|
return {
|
|
2022
3049
|
ok: true,
|
|
@@ -2042,6 +3069,7 @@ async function executeFrontendTestHtmlReport(input, meta) {
|
|
|
2042
3069
|
const output = await renderFrontendTestHtmlReport({
|
|
2043
3070
|
workspaceRoot: input.cwd,
|
|
2044
3071
|
runDir: meta.runDir,
|
|
3072
|
+
layout: frontendTestLayoutFromSpec(meta.spec),
|
|
2045
3073
|
});
|
|
2046
3074
|
return {
|
|
2047
3075
|
ok: true,
|
|
@@ -2061,11 +3089,60 @@ async function executeFrontendTestHtmlReport(input, meta) {
|
|
|
2061
3089
|
};
|
|
2062
3090
|
}
|
|
2063
3091
|
}
|
|
2064
|
-
async function
|
|
3092
|
+
async function executeFrontendTestStandardScenarios(input, meta) {
|
|
3093
|
+
const started = Date.now();
|
|
3094
|
+
try {
|
|
3095
|
+
const result = await copyFrontendTestStandardScenarios({
|
|
3096
|
+
workspaceRoot: input.cwd,
|
|
3097
|
+
layout: frontendTestLayoutFromSpec(meta.spec),
|
|
3098
|
+
});
|
|
3099
|
+
return {
|
|
3100
|
+
ok: true,
|
|
3101
|
+
stdout: JSON.stringify(result),
|
|
3102
|
+
stderr: "",
|
|
3103
|
+
failureCategory: "success",
|
|
3104
|
+
durationMs: Date.now() - started,
|
|
3105
|
+
};
|
|
3106
|
+
}
|
|
3107
|
+
catch (error) {
|
|
3108
|
+
return {
|
|
3109
|
+
ok: false,
|
|
3110
|
+
stdout: "",
|
|
3111
|
+
stderr: error instanceof Error ? error.message : String(error),
|
|
3112
|
+
failureCategory: "invalid-output",
|
|
3113
|
+
durationMs: Date.now() - started,
|
|
3114
|
+
};
|
|
3115
|
+
}
|
|
3116
|
+
}
|
|
3117
|
+
async function executeFrontendTestEnvironmentProbe(input, meta) {
|
|
3118
|
+
const started = Date.now();
|
|
3119
|
+
const result = await probeFrontendTestEnvironment({
|
|
3120
|
+
workspaceRoot: input.cwd,
|
|
3121
|
+
layout: frontendTestLayoutFromSpec(meta.spec),
|
|
3122
|
+
});
|
|
3123
|
+
if (result.ok) {
|
|
3124
|
+
return {
|
|
3125
|
+
ok: true,
|
|
3126
|
+
stdout: result.stdout,
|
|
3127
|
+
stderr: "",
|
|
3128
|
+
failureCategory: "success",
|
|
3129
|
+
durationMs: Date.now() - started,
|
|
3130
|
+
};
|
|
3131
|
+
}
|
|
3132
|
+
return {
|
|
3133
|
+
ok: false,
|
|
3134
|
+
stdout: "",
|
|
3135
|
+
stderr: result.stderr,
|
|
3136
|
+
failureCategory: "nonzero-exit",
|
|
3137
|
+
durationMs: Date.now() - started,
|
|
3138
|
+
};
|
|
3139
|
+
}
|
|
3140
|
+
async function executeFrontendTestEvidenceValidation(input, meta) {
|
|
2065
3141
|
const started = Date.now();
|
|
2066
3142
|
try {
|
|
2067
3143
|
const result = await validateFrontendCaseEvidence({
|
|
2068
3144
|
workspaceRoot: input.cwd,
|
|
3145
|
+
layout: frontendTestLayoutFromSpec(meta.spec),
|
|
2069
3146
|
});
|
|
2070
3147
|
const output = `frontend case evidence validation cases=${result.cases} findings=${result.issues.length}${result.issues.length ? ` issues=${JSON.stringify(result.issues)}` : ""}`;
|
|
2071
3148
|
if (result.hardFail) {
|
|
@@ -2152,6 +3229,34 @@ async function executeFrontendTestCasePackageFinalize(input, meta) {
|
|
|
2152
3229
|
return { ok: false, stdout: "", stderr: error instanceof Error ? error.message : String(error), failureCategory: "invalid-output", durationMs: Date.now() - started };
|
|
2153
3230
|
}
|
|
2154
3231
|
}
|
|
3232
|
+
async function executeFrontendTestRerunCandidates(input, _meta) {
|
|
3233
|
+
const started = Date.now();
|
|
3234
|
+
try {
|
|
3235
|
+
const round = input.task.shell?.frontendTestRerunCandidates?.round;
|
|
3236
|
+
if (round === undefined)
|
|
3237
|
+
throw new Error("frontend-test rerun selector missing round");
|
|
3238
|
+
const selected = await selectFrontendRerunCandidates({
|
|
3239
|
+
workspaceRoot: input.cwd,
|
|
3240
|
+
round,
|
|
3241
|
+
});
|
|
3242
|
+
return {
|
|
3243
|
+
ok: true,
|
|
3244
|
+
stdout: `${JSON.stringify({ cases: selected.cases })}\n`,
|
|
3245
|
+
stderr: "",
|
|
3246
|
+
failureCategory: "success",
|
|
3247
|
+
durationMs: Date.now() - started,
|
|
3248
|
+
};
|
|
3249
|
+
}
|
|
3250
|
+
catch (error) {
|
|
3251
|
+
return {
|
|
3252
|
+
ok: false,
|
|
3253
|
+
stdout: "",
|
|
3254
|
+
stderr: error instanceof Error ? error.message : String(error),
|
|
3255
|
+
failureCategory: "invalid-output",
|
|
3256
|
+
durationMs: Date.now() - started,
|
|
3257
|
+
};
|
|
3258
|
+
}
|
|
3259
|
+
}
|
|
2155
3260
|
async function executeFrontendTestCaseManifest(input, meta) {
|
|
2156
3261
|
const started = Date.now();
|
|
2157
3262
|
try {
|
|
@@ -2161,6 +3266,7 @@ async function executeFrontendTestCaseManifest(input, meta) {
|
|
|
2161
3266
|
const checklist = await validateFrontendCaseChecklist({
|
|
2162
3267
|
workspaceRoot: input.cwd,
|
|
2163
3268
|
declaredAcIds,
|
|
3269
|
+
layout: frontendTestLayoutFromSpec(meta.spec),
|
|
2164
3270
|
});
|
|
2165
3271
|
if (checklist.issues.length) {
|
|
2166
3272
|
return {
|
|
@@ -2175,6 +3281,7 @@ async function executeFrontendTestCaseManifest(input, meta) {
|
|
|
2175
3281
|
workspaceRoot: input.cwd,
|
|
2176
3282
|
maxCases: gate.maxCases,
|
|
2177
3283
|
declaredAcIds,
|
|
3284
|
+
layout: frontendTestLayoutFromSpec(meta.spec),
|
|
2178
3285
|
});
|
|
2179
3286
|
return {
|
|
2180
3287
|
ok: true,
|
|
@@ -2212,6 +3319,7 @@ async function executeFrontendTestResultFinalize(input, meta) {
|
|
|
2212
3319
|
try {
|
|
2213
3320
|
const evidence = await validateFrontendCaseEvidence({
|
|
2214
3321
|
workspaceRoot: input.cwd,
|
|
3322
|
+
layout: frontendTestLayoutFromSpec(meta.spec),
|
|
2215
3323
|
});
|
|
2216
3324
|
advisoryStdout = `frontend case evidence validation cases=${evidence.cases} findings=${evidence.issues.length}${evidence.issues.length ? ` issues=${JSON.stringify(evidence.issues)}` : ""}`;
|
|
2217
3325
|
// Advisory findings must not block materialize; only hardFail (path escape) does.
|
|
@@ -2230,6 +3338,7 @@ async function executeFrontendTestResultFinalize(input, meta) {
|
|
|
2230
3338
|
artifactName: "frontend-test-result.json",
|
|
2231
3339
|
outputDir: "contracts",
|
|
2232
3340
|
sourceBinding: meta.spec.sourceBinding,
|
|
3341
|
+
layout: frontendTestLayoutFromSpec(meta.spec),
|
|
2233
3342
|
});
|
|
2234
3343
|
return {
|
|
2235
3344
|
ok: true,
|
|
@@ -2268,12 +3377,14 @@ async function executeFrontendTestReports(input, meta) {
|
|
|
2268
3377
|
const l5 = await renderFrontendTestL5Report({
|
|
2269
3378
|
workspaceRoot: input.cwd,
|
|
2270
3379
|
runDir: meta.runDir,
|
|
3380
|
+
layout: frontendTestLayoutFromSpec(meta.spec),
|
|
2271
3381
|
});
|
|
2272
3382
|
lines.push(`Frontend L-5 report: ${l5.htmlPath}\nMarkdown: ${l5.markdownPath}\nStatus: ${l5.metrics.status}`);
|
|
2273
3383
|
}
|
|
2274
3384
|
const report = await renderFrontendTestHtmlReport({
|
|
2275
3385
|
workspaceRoot: input.cwd,
|
|
2276
3386
|
runDir: meta.runDir,
|
|
3387
|
+
layout: frontendTestLayoutFromSpec(meta.spec),
|
|
2277
3388
|
});
|
|
2278
3389
|
lines.push(`Frontend test report: ${report.htmlPath}\nMarkdown: ${report.markdownPath}\nOutcome: ${report.outcome}\nCases: ${report.caseCount}`);
|
|
2279
3390
|
return {
|
|
@@ -2294,69 +3405,76 @@ async function executeFrontendTestReports(input, meta) {
|
|
|
2294
3405
|
};
|
|
2295
3406
|
}
|
|
2296
3407
|
}
|
|
2297
|
-
async function
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
}
|
|
2306
|
-
|
|
2307
|
-
|
|
3408
|
+
async function writeShellPresetProcessReceipt(input) {
|
|
3409
|
+
await writeDagNodeJsonArtifact(input.runDir, input.nodeId, "process-receipt.json", {
|
|
3410
|
+
schemaVersion: 1,
|
|
3411
|
+
kind: "shell-preset",
|
|
3412
|
+
preset: input.preset,
|
|
3413
|
+
ok: input.ok,
|
|
3414
|
+
durationMs: input.durationMs,
|
|
3415
|
+
steps: input.steps,
|
|
3416
|
+
});
|
|
3417
|
+
}
|
|
3418
|
+
async function ensureShellPresetProcessReceipt(input) {
|
|
3419
|
+
const receiptPath = path.join(input.runDir, input.nodeId, "process-receipt.json");
|
|
3420
|
+
if (existsSync(receiptPath))
|
|
3421
|
+
return;
|
|
3422
|
+
if (existsSync(path.join(input.runDir, input.nodeId, "shell-command-receipt.json"))) {
|
|
3423
|
+
return;
|
|
2308
3424
|
}
|
|
2309
|
-
const
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
3425
|
+
const detail = input.result.ok ? input.result.stdout : input.result.stderr;
|
|
3426
|
+
await writeShellPresetProcessReceipt({
|
|
3427
|
+
runDir: input.runDir,
|
|
3428
|
+
nodeId: input.nodeId,
|
|
3429
|
+
preset: input.preset,
|
|
3430
|
+
ok: input.result.ok,
|
|
3431
|
+
durationMs: input.result.durationMs,
|
|
3432
|
+
steps: [
|
|
3433
|
+
{
|
|
3434
|
+
id: "run",
|
|
3435
|
+
label: input.preset,
|
|
3436
|
+
ok: input.result.ok,
|
|
3437
|
+
detail: detail?.slice(0, 8 * 1024),
|
|
3438
|
+
durationMs: input.result.durationMs,
|
|
2321
3439
|
},
|
|
2322
|
-
|
|
2323
|
-
}
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
};
|
|
3440
|
+
],
|
|
3441
|
+
});
|
|
3442
|
+
}
|
|
3443
|
+
function namedShellHandler(shell) {
|
|
3444
|
+
if (!shell)
|
|
3445
|
+
return null;
|
|
3446
|
+
const record = shell;
|
|
3447
|
+
for (const key of [
|
|
3448
|
+
"finalWriteSetApprovalGate",
|
|
3449
|
+
"frontendTestStandardScenarios",
|
|
3450
|
+
"frontendTestEnvironmentProbe",
|
|
3451
|
+
"frontendBrowserToolPreflight",
|
|
3452
|
+
"frontendPrewriteGate",
|
|
3453
|
+
"frontendLintBaseline",
|
|
3454
|
+
"frontendVerificationBundle",
|
|
3455
|
+
"frontendReviewContext",
|
|
3456
|
+
"frontendTestCaseChecklist",
|
|
3457
|
+
"frontendTestCaseManifest",
|
|
3458
|
+
"frontendTestEvidenceValidation",
|
|
3459
|
+
"frontendTestResultFinalize",
|
|
3460
|
+
"frontendTestL5Report",
|
|
3461
|
+
"frontendTestHtmlReport",
|
|
3462
|
+
"frontendTestReports",
|
|
3463
|
+
"backendTestPipeline",
|
|
3464
|
+
"jsonArtifactGate",
|
|
3465
|
+
"projectGovernanceGate",
|
|
3466
|
+
"requirementCoverageGate",
|
|
3467
|
+
"verdictGate",
|
|
3468
|
+
"verifyEvidence",
|
|
3469
|
+
"repairArtifactGate",
|
|
3470
|
+
"jacocoCoverage",
|
|
3471
|
+
]) {
|
|
3472
|
+
if (record[key] != null)
|
|
3473
|
+
return key;
|
|
2357
3474
|
}
|
|
3475
|
+
return null;
|
|
2358
3476
|
}
|
|
2359
|
-
|
|
3477
|
+
async function executeDagShellNodeInner(input, meta) {
|
|
2360
3478
|
const shell = input.task.shell;
|
|
2361
3479
|
if (shell?.finalWriteSetApprovalGate) {
|
|
2362
3480
|
const started = Date.now();
|
|
@@ -2395,30 +3513,91 @@ export async function executeDagShellNode(input, meta) {
|
|
|
2395
3513
|
};
|
|
2396
3514
|
}
|
|
2397
3515
|
}
|
|
3516
|
+
if (shell?.frontendTestStandardScenarios) {
|
|
3517
|
+
return executeFrontendTestStandardScenarios(input, meta);
|
|
3518
|
+
}
|
|
3519
|
+
if (shell?.frontendTestEnvironmentProbe) {
|
|
3520
|
+
return executeFrontendTestEnvironmentProbe(input, meta);
|
|
3521
|
+
}
|
|
2398
3522
|
if (shell?.frontendBrowserToolPreflight) {
|
|
2399
3523
|
const started = Date.now();
|
|
3524
|
+
const steps = [];
|
|
3525
|
+
const finish = async (result) => {
|
|
3526
|
+
await writeShellPresetProcessReceipt({
|
|
3527
|
+
runDir: meta.runDir,
|
|
3528
|
+
nodeId: input.task.id,
|
|
3529
|
+
preset: "frontendBrowserToolPreflight",
|
|
3530
|
+
ok: result.ok,
|
|
3531
|
+
durationMs: result.durationMs,
|
|
3532
|
+
steps: steps.length > 0
|
|
3533
|
+
? steps
|
|
3534
|
+
: [
|
|
3535
|
+
{
|
|
3536
|
+
id: "run",
|
|
3537
|
+
label: "浏览器工具能力探测",
|
|
3538
|
+
ok: result.ok,
|
|
3539
|
+
detail: result.ok ? result.stdout : result.stderr,
|
|
3540
|
+
durationMs: result.durationMs,
|
|
3541
|
+
},
|
|
3542
|
+
],
|
|
3543
|
+
});
|
|
3544
|
+
return result;
|
|
3545
|
+
};
|
|
2400
3546
|
try {
|
|
2401
3547
|
if (resolvePiBackend() === "cli-only") {
|
|
3548
|
+
steps.push({
|
|
3549
|
+
id: "pi-backend",
|
|
3550
|
+
label: "Pi SDK 后端可用",
|
|
3551
|
+
ok: false,
|
|
3552
|
+
detail: "CODE_AGENT_PI_BACKEND=cli-only",
|
|
3553
|
+
});
|
|
2402
3554
|
throw new Error("browser-command-capability-unavailable: CODE_AGENT_PI_BACKEND=cli-only rejects SDK-only playwright_cli");
|
|
2403
3555
|
}
|
|
3556
|
+
steps.push({
|
|
3557
|
+
id: "pi-backend",
|
|
3558
|
+
label: "Pi SDK 后端可用",
|
|
3559
|
+
ok: true,
|
|
3560
|
+
});
|
|
2404
3561
|
const sdkCapability = await checkPiSdkCustomToolCapability(input.cwd);
|
|
2405
3562
|
if (!sdkCapability.ok) {
|
|
3563
|
+
steps.push({
|
|
3564
|
+
id: "sdk-custom-tool",
|
|
3565
|
+
label: "Pi SDK custom-tool 能力",
|
|
3566
|
+
ok: false,
|
|
3567
|
+
detail: sdkCapability.detail,
|
|
3568
|
+
});
|
|
2406
3569
|
throw new Error(`browser-command-capability-unavailable: ${sdkCapability.detail}`);
|
|
2407
3570
|
}
|
|
3571
|
+
steps.push({
|
|
3572
|
+
id: "sdk-custom-tool",
|
|
3573
|
+
label: "Pi SDK custom-tool 能力",
|
|
3574
|
+
ok: true,
|
|
3575
|
+
});
|
|
3576
|
+
const layout = frontendTestLayoutFromSpec(meta.spec);
|
|
2408
3577
|
const toolProbe = await createPlaywrightCliTool({
|
|
2409
3578
|
repoRoot: input.cwd,
|
|
2410
3579
|
runDir: meta.runDir,
|
|
2411
3580
|
nodeId: input.task.id,
|
|
2412
3581
|
caseId: "frontend-browser-preflight",
|
|
2413
|
-
evidenceDir:
|
|
2414
|
-
// Capability-only registration probe. The tested URL is selected later by
|
|
2415
|
-
// retrieve-frontend-test-context-pi and validated by the environment shell.
|
|
3582
|
+
evidenceDir: `${layout.evidenceDir}/frontend-browser-preflight`,
|
|
2416
3583
|
baseUrl: "http://localhost:5173/",
|
|
2417
|
-
inputRoot:
|
|
3584
|
+
inputRoot: layout.fixturesDir,
|
|
3585
|
+
layout,
|
|
2418
3586
|
});
|
|
2419
3587
|
if (toolProbe.name !== "playwright_cli") {
|
|
3588
|
+
steps.push({
|
|
3589
|
+
id: "structured-tool",
|
|
3590
|
+
label: "注册 playwright_cli",
|
|
3591
|
+
ok: false,
|
|
3592
|
+
detail: toolProbe.name,
|
|
3593
|
+
});
|
|
2420
3594
|
throw new Error("browser-command-capability-unavailable: structured playwright_cli tool registration failed");
|
|
2421
3595
|
}
|
|
3596
|
+
steps.push({
|
|
3597
|
+
id: "structured-tool",
|
|
3598
|
+
label: "注册 playwright_cli",
|
|
3599
|
+
ok: true,
|
|
3600
|
+
});
|
|
2422
3601
|
const launcher = resolvePlaywrightCliLauncher(input.cwd);
|
|
2423
3602
|
const result = await defaultPlaywrightCliCommandRunner({
|
|
2424
3603
|
executable: launcher.executable,
|
|
@@ -2431,8 +3610,19 @@ export async function executeDagShellNode(input, meta) {
|
|
|
2431
3610
|
if (result.exitCode !== 0 ||
|
|
2432
3611
|
result.timedOut ||
|
|
2433
3612
|
!["open", "close", "find", "snapshot", "click"].every((command) => new RegExp(`\\b${command}\\b`, "i").test(help))) {
|
|
3613
|
+
steps.push({
|
|
3614
|
+
id: "playwright-cli-help",
|
|
3615
|
+
label: "playwright-cli --help 合同",
|
|
3616
|
+
ok: false,
|
|
3617
|
+
detail: help.slice(0, 8 * 1024),
|
|
3618
|
+
});
|
|
2434
3619
|
throw new Error("playwright-cli-contract-incompatible");
|
|
2435
3620
|
}
|
|
3621
|
+
steps.push({
|
|
3622
|
+
id: "playwright-cli-help",
|
|
3623
|
+
label: "playwright-cli --help 合同",
|
|
3624
|
+
ok: true,
|
|
3625
|
+
});
|
|
2436
3626
|
const capability = {
|
|
2437
3627
|
schemaVersion: 1,
|
|
2438
3628
|
status: "ready",
|
|
@@ -2443,54 +3633,35 @@ export async function executeDagShellNode(input, meta) {
|
|
|
2443
3633
|
targetUrlAuthority: "retrieve-context-and-environment-probe",
|
|
2444
3634
|
};
|
|
2445
3635
|
await writeDagNodeJsonArtifact(meta.runDir, input.task.id, "frontend-browser-capability.json", capability);
|
|
2446
|
-
|
|
3636
|
+
steps.push({
|
|
3637
|
+
id: "capability-artifact",
|
|
3638
|
+
label: "写出 frontend-browser-capability.json",
|
|
3639
|
+
ok: true,
|
|
3640
|
+
detail: JSON.stringify(capability, null, 2),
|
|
3641
|
+
});
|
|
3642
|
+
return await finish({
|
|
2447
3643
|
ok: true,
|
|
2448
3644
|
stdout: JSON.stringify(capability),
|
|
2449
3645
|
stderr: "",
|
|
2450
3646
|
failureCategory: "success",
|
|
2451
3647
|
durationMs: Date.now() - started,
|
|
2452
|
-
};
|
|
3648
|
+
});
|
|
2453
3649
|
}
|
|
2454
3650
|
catch (error) {
|
|
2455
|
-
return {
|
|
3651
|
+
return await finish({
|
|
2456
3652
|
ok: false,
|
|
2457
3653
|
stdout: "",
|
|
2458
3654
|
stderr: `playwright-cli-unavailable: ${error instanceof Error ? error.message : String(error)}`,
|
|
2459
3655
|
failureCategory: "tool-policy",
|
|
2460
3656
|
durationMs: Date.now() - started,
|
|
2461
|
-
};
|
|
2462
|
-
}
|
|
2463
|
-
}
|
|
2464
|
-
if (shell?.frontendPrewriteGate) {
|
|
2465
|
-
const started = Date.now();
|
|
2466
|
-
try {
|
|
2467
|
-
const result = await runFrontendPrewriteGate({
|
|
2468
|
-
runDir: meta.runDir,
|
|
2469
|
-
config: shell.frontendPrewriteGate,
|
|
2470
|
-
sourceBinding: meta.spec.sourceBinding,
|
|
2471
|
-
workspaceRoot: input.cwd,
|
|
2472
|
-
repoRoot: input.cwd,
|
|
2473
3657
|
});
|
|
2474
|
-
return {
|
|
2475
|
-
ok: true,
|
|
2476
|
-
stdout: formatFrontendPrewriteGateStdout(result),
|
|
2477
|
-
stderr: "",
|
|
2478
|
-
failureCategory: "success",
|
|
2479
|
-
durationMs: Date.now() - started,
|
|
2480
|
-
};
|
|
2481
|
-
}
|
|
2482
|
-
catch (error) {
|
|
2483
|
-
return {
|
|
2484
|
-
ok: false,
|
|
2485
|
-
stdout: "",
|
|
2486
|
-
stderr: error instanceof Error ? error.message : String(error),
|
|
2487
|
-
failureCategory: "invalid-output",
|
|
2488
|
-
durationMs: Date.now() - started,
|
|
2489
|
-
};
|
|
2490
3658
|
}
|
|
2491
3659
|
}
|
|
2492
|
-
if (shell?.
|
|
2493
|
-
return
|
|
3660
|
+
if (shell?.frontendDesignPolicy) {
|
|
3661
|
+
return executeFrontendDesignPolicy(input, meta);
|
|
3662
|
+
}
|
|
3663
|
+
if (shell?.frontendWriterAdmission) {
|
|
3664
|
+
return executeFrontendWriterAdmission(input, meta);
|
|
2494
3665
|
}
|
|
2495
3666
|
if (shell?.frontendVerificationBundle) {
|
|
2496
3667
|
return executeFrontendVerificationBundle(input, meta);
|
|
@@ -2521,6 +3692,12 @@ export async function executeDagShellNode(input, meta) {
|
|
|
2521
3692
|
};
|
|
2522
3693
|
}
|
|
2523
3694
|
}
|
|
3695
|
+
if (shell?.frontendContractImport) {
|
|
3696
|
+
return executeFrontendContractImport(input, meta);
|
|
3697
|
+
}
|
|
3698
|
+
if (shell?.frontendCloseout) {
|
|
3699
|
+
return executeFrontendCloseout(input, meta);
|
|
3700
|
+
}
|
|
2524
3701
|
if (shell?.frontendTestCaseChecklist) {
|
|
2525
3702
|
return executeFrontendTestCaseChecklist(input, meta);
|
|
2526
3703
|
}
|
|
@@ -2530,8 +3707,11 @@ export async function executeDagShellNode(input, meta) {
|
|
|
2530
3707
|
if (shell?.frontendTestCasePackageFinalize) {
|
|
2531
3708
|
return executeFrontendTestCasePackageFinalize(input, meta);
|
|
2532
3709
|
}
|
|
3710
|
+
if (shell?.frontendTestRerunCandidates) {
|
|
3711
|
+
return executeFrontendTestRerunCandidates(input, meta);
|
|
3712
|
+
}
|
|
2533
3713
|
if (shell?.frontendTestEvidenceValidation) {
|
|
2534
|
-
return executeFrontendTestEvidenceValidation(input);
|
|
3714
|
+
return executeFrontendTestEvidenceValidation(input, meta);
|
|
2535
3715
|
}
|
|
2536
3716
|
if (shell?.frontendTestResultFinalize) {
|
|
2537
3717
|
return executeFrontendTestResultFinalize(input, meta);
|
|
@@ -2638,6 +3818,7 @@ export async function executeDagShellNode(input, meta) {
|
|
|
2638
3818
|
artifactName: gate.artifactName,
|
|
2639
3819
|
outputDir: gate.outputDir,
|
|
2640
3820
|
sourceBinding: meta.spec.sourceBinding,
|
|
3821
|
+
layout: frontendTestLayoutFromSpec(meta.spec),
|
|
2641
3822
|
});
|
|
2642
3823
|
break;
|
|
2643
3824
|
default:
|
|
@@ -2745,53 +3926,23 @@ export async function executeDagShellNode(input, meta) {
|
|
|
2745
3926
|
}
|
|
2746
3927
|
if (shell?.commands?.length === 1 &&
|
|
2747
3928
|
shell.commands[0] === "frontend-failure-assess-gate") {
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
stdout: formatFrontendFailureAssessStdout(result),
|
|
2756
|
-
stderr: "",
|
|
2757
|
-
failureCategory: "success",
|
|
2758
|
-
durationMs: Date.now() - started,
|
|
2759
|
-
};
|
|
2760
|
-
}
|
|
2761
|
-
catch (error) {
|
|
2762
|
-
return {
|
|
2763
|
-
ok: false,
|
|
2764
|
-
stdout: "",
|
|
2765
|
-
stderr: error instanceof Error ? error.message : String(error),
|
|
2766
|
-
failureCategory: "invalid-output",
|
|
2767
|
-
durationMs: Date.now() - started,
|
|
2768
|
-
};
|
|
2769
|
-
}
|
|
3929
|
+
return {
|
|
3930
|
+
ok: false,
|
|
3931
|
+
stdout: "",
|
|
3932
|
+
stderr: "frontend-failure-assess-gate legacy command removed in M8: verify failure is terminal and materializes failure ownership facts in the verification bundle itself",
|
|
3933
|
+
failureCategory: "invalid-output",
|
|
3934
|
+
durationMs: 0,
|
|
3935
|
+
};
|
|
2770
3936
|
}
|
|
2771
3937
|
if (shell?.commands?.length === 1 &&
|
|
2772
3938
|
shell.commands[0] === "frontend-repair-contract-gate") {
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
stdout: formatFrontendRepairContractStdout(result.assessment),
|
|
2781
|
-
stderr: "",
|
|
2782
|
-
failureCategory: "success",
|
|
2783
|
-
durationMs: Date.now() - started,
|
|
2784
|
-
};
|
|
2785
|
-
}
|
|
2786
|
-
catch (error) {
|
|
2787
|
-
return {
|
|
2788
|
-
ok: false,
|
|
2789
|
-
stdout: "",
|
|
2790
|
-
stderr: error instanceof Error ? error.message : String(error),
|
|
2791
|
-
failureCategory: "invalid-output",
|
|
2792
|
-
durationMs: Date.now() - started,
|
|
2793
|
-
};
|
|
2794
|
-
}
|
|
3939
|
+
return {
|
|
3940
|
+
ok: false,
|
|
3941
|
+
stdout: "",
|
|
3942
|
+
stderr: "frontend-repair-contract-gate legacy command removed in M8: no same-run repair branch exists in the new topology",
|
|
3943
|
+
failureCategory: "invalid-output",
|
|
3944
|
+
durationMs: 0,
|
|
3945
|
+
};
|
|
2795
3946
|
}
|
|
2796
3947
|
if (shell?.projectGovernanceGate) {
|
|
2797
3948
|
const started = Date.now();
|
|
@@ -2883,6 +4034,7 @@ export async function executeDagShellNode(input, meta) {
|
|
|
2883
4034
|
const cwd = resolveShellCwd(input.cwd, shell.cwd);
|
|
2884
4035
|
const timeoutMs = shell.timeoutMs ?? DEFAULT_SHELL_TIMEOUT_MS;
|
|
2885
4036
|
const failFast = shell.failFast !== false;
|
|
4037
|
+
const attemptNumber = input.attempt ?? 1;
|
|
2886
4038
|
const results = [];
|
|
2887
4039
|
const executedCommandKeys = new Set();
|
|
2888
4040
|
let beforeStatus;
|
|
@@ -2978,8 +4130,8 @@ export async function executeDagShellNode(input, meta) {
|
|
|
2978
4130
|
dagRunMeta: { runDir: meta.runDir, runId: meta.runId },
|
|
2979
4131
|
reportActivity: input.reportActivity,
|
|
2980
4132
|
outputArtifacts: {
|
|
2981
|
-
stdoutPath: path.join(meta.runDir, input.task.id, "commands", `${commandNumber}.stdout.txt`),
|
|
2982
|
-
stderrPath: path.join(meta.runDir, input.task.id, "commands", `${commandNumber}.stderr.txt`),
|
|
4133
|
+
stdoutPath: path.join(meta.runDir, input.task.id, `attempt-${attemptNumber}`, "commands", `${commandNumber}.stdout.txt`),
|
|
4134
|
+
stderrPath: path.join(meta.runDir, input.task.id, `attempt-${attemptNumber}`, "commands", `${commandNumber}.stderr.txt`),
|
|
2983
4135
|
},
|
|
2984
4136
|
});
|
|
2985
4137
|
results.push(result);
|
|
@@ -3038,6 +4190,7 @@ export async function executeDagShellNode(input, meta) {
|
|
|
3038
4190
|
schemaVersion: 1,
|
|
3039
4191
|
runId: meta.runId,
|
|
3040
4192
|
nodeId: input.task.id,
|
|
4193
|
+
attempt: attemptNumber,
|
|
3041
4194
|
workspaceFingerprint: workspaceFingerprint ?? null,
|
|
3042
4195
|
failFast,
|
|
3043
4196
|
commands: results.map((result) => ({
|
|
@@ -3056,6 +4209,7 @@ export async function executeDagShellNode(input, meta) {
|
|
|
3056
4209
|
subchecks: parseCheckRepoSubcheckDurations(result),
|
|
3057
4210
|
})),
|
|
3058
4211
|
};
|
|
4212
|
+
await writeDagNodeJsonArtifact(meta.runDir, input.task.id, path.posix.join(`attempt-${attemptNumber}`, "shell-command-receipt.json"), receipt);
|
|
3059
4213
|
await writeDagNodeJsonArtifact(meta.runDir, input.task.id, "shell-command-receipt.json", receipt);
|
|
3060
4214
|
const summaryMarkdown = buildShellResultSummaryMarkdown({
|
|
3061
4215
|
nodeId: input.task.id,
|
|
@@ -3107,8 +4261,57 @@ export async function executeDagShellNode(input, meta) {
|
|
|
3107
4261
|
stdout: `${recordPrefix}${reuseNote}${aggregate.stdout}`,
|
|
3108
4262
|
stderr: stderrParts.filter(Boolean).join("\n\n"),
|
|
3109
4263
|
failureCategory,
|
|
4264
|
+
...(firstFailure?.failureCategory
|
|
4265
|
+
? { rawFailureCategory: firstFailure.failureCategory }
|
|
4266
|
+
: {}),
|
|
3110
4267
|
durationMs: Date.now() - started,
|
|
3111
4268
|
// extra field consumed by node-execution if supported; also embedded in stdout marker
|
|
3112
4269
|
...{ commandResults },
|
|
3113
4270
|
};
|
|
3114
4271
|
}
|
|
4272
|
+
/**
|
|
4273
|
+
* Enumerate the workspace's concrete file paths for glob writeSet expansion.
|
|
4274
|
+
*
|
|
4275
|
+
* Uses `git ls-files -co --exclude-standard` (tracked + untracked, excluding
|
|
4276
|
+
* gitignored) so the expanded writeSet reflects real files the writer can
|
|
4277
|
+
* touch. Falls back to [] when the workspace is not a git repository or git
|
|
4278
|
+
* fails — in that case glob entries fail closed as non-concrete paths.
|
|
4279
|
+
*/
|
|
4280
|
+
async function collectWorkspaceFiles(workspaceRoot) {
|
|
4281
|
+
try {
|
|
4282
|
+
const files = await new Promise((resolve, reject) => {
|
|
4283
|
+
const child = spawn("git", ["ls-files", "-co", "--exclude-standard", "-z"], { cwd: workspaceRoot, stdio: ["ignore", "pipe", "ignore"] });
|
|
4284
|
+
const chunks = [];
|
|
4285
|
+
child.stdout.on("data", (chunk) => chunks.push(chunk));
|
|
4286
|
+
child.on("error", reject);
|
|
4287
|
+
child.on("close", (code) => {
|
|
4288
|
+
if (code === 0) {
|
|
4289
|
+
resolve(Buffer.concat(chunks)
|
|
4290
|
+
.toString("utf8")
|
|
4291
|
+
.split("\0")
|
|
4292
|
+
.filter(Boolean));
|
|
4293
|
+
}
|
|
4294
|
+
else {
|
|
4295
|
+
reject(new Error(`git ls-files exited ${String(code)}`));
|
|
4296
|
+
}
|
|
4297
|
+
});
|
|
4298
|
+
});
|
|
4299
|
+
return files.map((file) => file.replace(/\\/g, "/")).sort();
|
|
4300
|
+
}
|
|
4301
|
+
catch {
|
|
4302
|
+
return [];
|
|
4303
|
+
}
|
|
4304
|
+
}
|
|
4305
|
+
export async function executeDagShellNode(input, meta) {
|
|
4306
|
+
const handler = namedShellHandler(input.task.shell);
|
|
4307
|
+
const result = await executeDagShellNodeInner(input, meta);
|
|
4308
|
+
if (handler) {
|
|
4309
|
+
await ensureShellPresetProcessReceipt({
|
|
4310
|
+
runDir: meta.runDir,
|
|
4311
|
+
nodeId: input.task.id,
|
|
4312
|
+
preset: handler,
|
|
4313
|
+
result,
|
|
4314
|
+
});
|
|
4315
|
+
}
|
|
4316
|
+
return result;
|
|
4317
|
+
}
|