@tea-agent/loop-agent 0.42.0-next.2 → 0.42.0-next.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/CHANGELOG.md +244 -1
- package/dist/application/dag/generate-task-dag.js +75 -19
- package/dist/application/task-lifecycle/advance.js +24 -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 +7 -0
- package/dist/cli/program.js +5 -0
- package/dist/commands/client-recovery.js +3 -0
- package/dist/commands/dag-follow-up.js +138 -0
- package/dist/commands/init.js +27 -1
- package/dist/commands/task-advance.js +19 -0
- package/dist/executors/dag-pi-executor.js +3789 -232
- package/dist/executors/pi-executor.js +15 -4
- package/dist/executors/pi-read-budget-policy.js +239 -0
- package/dist/executors/shell-executor.js +942 -187
- package/dist/executors/shell-write-guard.js +7 -0
- package/dist/infrastructure/console/operation-store.js +226 -6
- package/dist/shared/dag-failure-category.js +12 -0
- package/dist/shared/openspec-spec.js +70 -4
- package/dist/shared/operator/capabilities.js +7 -0
- package/dist/task/config-types.js +34 -5
- package/dist/task/contract/adopt.js +4 -0
- package/dist/task/contract/import-revision.js +4 -0
- package/dist/task/contract/project.js +3 -0
- package/dist/task/contract/schema.js +2 -1
- package/dist/task/frontend-project-capability.js +203 -20
- package/dist/task/runtime.js +5 -2
- package/dist/task/source-prepare/build-draft.js +3 -3
- package/dist/task/source-prepare/fragment-inventory.js +15 -9
- package/dist/task/source-prepare/prepare.js +89 -1
- package/dist/task/source-prepare/semantic-intake.js +6 -2
- package/dist/task/source-references.js +22 -1
- package/dist/worker/console/chat/chat-ui-policy.js +4 -2
- package/dist/worker/console/chat/pi-runtime.js +173 -7
- package/dist/worker/console/chat/repo-browser.js +10 -3
- package/dist/worker/console/chat/routes.js +30 -19
- package/dist/worker/console/chat/session-store.js +117 -70
- package/dist/worker/console/chat/shortcuts.js +1 -1
- package/dist/worker/console/chat/turn-process.js +111 -56
- 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/index.js +3 -0
- package/dist/worker/console/operator-actions.js +169 -7
- package/dist/worker/console/server.js +3 -0
- package/dist/worker/console/static/assets/{abnfDiagram-N423BO3Z-DZZ8m3PO.js → abnfDiagram-N423BO3Z-CeznJ4Iw.js} +1 -1
- package/dist/worker/console/static/assets/{arc-D6PvaVd-.js → arc-B4u9u7SX.js} +1 -1
- package/dist/worker/console/static/assets/{architectureDiagram-T3A2C74G-B_OTOiI8.js → architectureDiagram-T3A2C74G-oghpT81p.js} +1 -1
- package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-Bv6rqHBg.js → blockDiagram-VBNYF7ZC-BPJ5Kvcj.js} +1 -1
- package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-B8eHr0oz.js → c4Diagram-5PPSVZJV-CoIu69pd.js} +1 -1
- package/dist/worker/console/static/assets/channel-DmIXqJ6B.js +1 -0
- package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-DYwR0im2.js → chunk-2GRJ4B5K-DtgiAsSc.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-D2WPGqXt.js → chunk-2Q5K7J3B-YSu_EVSD.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5RXB4S5H-CQISJ_I7.js → chunk-5RXB4S5H-DaRO-NB6.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5VM5RSS4-C0o2Du1e.js → chunk-5VM5RSS4-Dh0ZKiGA.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-4f8kr-U7.js → chunk-6Q2QTUOP-DOrvbR-H.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-GF5L2VYU-D_OWvXzX.js → chunk-GF5L2VYU-C3b22LN2.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-JWPE2WC7-CasdPz5X.js → chunk-JWPE2WC7-CXlqO8l6.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-KBJHAD2P-Cj8lRrla.js → chunk-KBJHAD2P-BblTBrDu.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-RYQCIY6F-CUvD1FSd.js → chunk-RYQCIY6F-DswqPALe.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-XXDRQBXY-CqLw_eqB.js → chunk-XXDRQBXY-CfTwVOlc.js} +1 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-MFV5Qxb5.js +1 -0
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-MFV5Qxb5.js +1 -0
- package/dist/worker/console/static/assets/{cose-bilkent-JH36ORCC-ku-WqJPx.js → cose-bilkent-JH36ORCC-bLD8jVFo.js} +1 -1
- package/dist/worker/console/static/assets/{cynefin-VYW2F7L2-Bq_PYDhl.js → cynefin-VYW2F7L2-BvoG1fh5.js} +1 -1
- package/dist/worker/console/static/assets/{cynefinDiagram-MW4NZA55-BiGZV641.js → cynefinDiagram-MW4NZA55-DEPAdJu3.js} +1 -1
- package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-C4JRlglF.js → dagre-VZM6K2ZE-DmrNvBLy.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-7IWD3JNH-B0dNeWYG.js → diagram-7IWD3JNH-CdwzIwvs.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-Cj35YvYM.js → diagram-B4RE2ZJO-CJ3hj-md.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-LBJQPF4R-uzQoJ2-8.js → diagram-LBJQPF4R-C6YJT2a4.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-Q27KOJAE-D1a-Buoz.js → diagram-Q27KOJAE-C_LPfjhX.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-UB23O5K3-XjRrLRSs.js → diagram-UB23O5K3-xvsSb5Ie.js} +1 -1
- package/dist/worker/console/static/assets/{ebnfDiagram-BXEA7PRR-Da_O24cW.js → ebnfDiagram-BXEA7PRR-Rxp2tKcD.js} +1 -1
- package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-BLJ8jrYU.js → erDiagram-JOGREHBK-DRyLYmZh.js} +1 -1
- package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-B9GrLjM0.js → flowDiagram-UKHOOZJN-TLSU_D2B.js} +1 -1
- package/dist/worker/console/static/assets/{ganttDiagram-PKOTCBZU-CeJ0TqiK.js → ganttDiagram-PKOTCBZU-DGqeTvHC.js} +1 -1
- package/dist/worker/console/static/assets/{gitGraphDiagram-DS77QQ5N-Bm2eNNFX.js → gitGraphDiagram-DS77QQ5N-BZxyH2wh.js} +1 -1
- package/dist/worker/console/static/assets/index-C8V8K9b4.js +451 -0
- package/dist/worker/console/static/assets/index-Cnf_KxTQ.css +1 -0
- package/dist/worker/console/static/assets/{infoDiagram-6WML65LV-DB26i3d8.js → infoDiagram-6WML65LV-BsYtzx01.js} +1 -1
- package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-BOGRyeZT.js → ishikawaDiagram-WSZJBQD7-Qr-ezGv-.js} +1 -1
- package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-CZRoBO_6.js → journeyDiagram-NVQOT4AX-DYbB3ibo.js} +1 -1
- package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-qlWhJyoB.js → kanban-definition-27J2QSJJ-BHJHewZO.js} +1 -1
- package/dist/worker/console/static/assets/{linear-CfUiDDB3.js → linear-CmPIPmCG.js} +1 -1
- package/dist/worker/console/static/assets/{mermaid.core-BQe6fpqj.js → mermaid.core-F--C1uV0.js} +5 -5
- package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-zFzWHw64.js → mindmap-definition-FAOFIHXS-YTXfL1st.js} +1 -1
- package/dist/worker/console/static/assets/{pegDiagram-VL7TDLO6-DFGUqjZO.js → pegDiagram-VL7TDLO6-DdDMYXP9.js} +1 -1
- package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-BB5i0l8Z.js → pieDiagram-7S7Q4E2Y-C3nH4KVd.js} +1 -1
- package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-obbVZ_X5.js → quadrantDiagram-CIZ2JOQS-kXyxjG7Y.js} +1 -1
- package/dist/worker/console/static/assets/{railroadDiagram-AXF67PYL-BwdaNzc1.js → railroadDiagram-AXF67PYL-KNzbl-7w.js} +1 -1
- package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP-CkTJaugh.js → requirementDiagram-LRYGKXZP-CSwI6dG0.js} +1 -1
- package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-BwJ-hIgq.js → sankeyDiagram-W5VNT64P-Bl1AyuXy.js} +1 -1
- package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-BzSgmm7w.js → sequenceDiagram-SI44F4Z6-2y4EmXQa.js} +1 -1
- package/dist/worker/console/static/assets/{sizeCapture-X5ZJPWSS-Bn3oj5Q1.js → sizeCapture-X5ZJPWSS-E8v8YrMg.js} +1 -1
- package/dist/worker/console/static/assets/{stateDiagram-OKZ733FA-dxhGtL8K.js → stateDiagram-OKZ733FA-eGGlR856.js} +1 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-B8e4J3at.js +1 -0
- package/dist/worker/console/static/assets/{swimlanes-SLNWSIFB-BLpEInya.js → swimlanes-SLNWSIFB-B7g7xc07.js} +2 -2
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-Do88I1Nb.js +8 -0
- package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-ChJGYcXy.js → timeline-definition-Z64GVDOM-DR3VCHBG.js} +1 -1
- package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-DK-qjRer.js → vennDiagram-T6HMQDX7-LUvapZIy.js} +1 -1
- package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-3qeaWAg-.js → wardleyDiagram-T6FBY63Y-C7GDcaXq.js} +1 -1
- package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-CootlyP9.js → xychartDiagram-ELKLHX3M-CbNAqoGK.js} +1 -1
- package/dist/worker/console/static/index.html +2 -2
- package/dist/worker/console/static-src/active-run-badge.js +17 -0
- package/dist/worker/console/static-src/operator-chat/chat-sse-events.js +19 -8
- package/dist/worker/console/static-src/operator-chat/open-preview-in-browser.js +15 -7
- package/dist/worker/console/workspace-context.js +111 -1
- package/dist/worker/materialize/frontend-split-task-materializer.js +72 -0
- package/dist/worker/observe/static/dag-node-purpose.js +5 -0
- package/dist/workflows/dag/backend-test-writer-completeness.js +10 -0
- package/dist/workflows/dag/contract-validator-registrations.js +1 -2
- package/dist/workflows/dag/dag-retry-schema.js +138 -0
- 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 +907 -162
- package/dist/workflows/dag/frontend-plan-render.js +2 -1
- package/dist/workflows/dag/frontend-prewrite-gate.js +255 -349
- 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 +202 -0
- package/dist/workflows/dag/frontend-recovery-lineage.js +178 -0
- package/dist/workflows/dag/frontend-recovery-plan.js +17 -10
- package/dist/workflows/dag/frontend-recovery-run.js +33 -20
- package/dist/workflows/dag/frontend-repair.js +1 -432
- package/dist/workflows/dag/frontend-review-context.js +261 -15
- package/dist/workflows/dag/frontend-review-findings.js +270 -0
- package/dist/workflows/dag/frontend-shadow-dual-write.js +914 -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-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 +249 -24
- package/dist/workflows/dag/frontend-worktree-diff.js +250 -17
- package/dist/workflows/dag/frontend-writer-admission.js +285 -0
- package/dist/workflows/dag/frontend-writer-status.js +256 -0
- package/dist/workflows/dag/init-hybrid.js +677 -492
- package/dist/workflows/dag/interrupt-request.js +7 -0
- package/dist/workflows/dag/node-execution.js +732 -4
- package/dist/workflows/dag/prompt.js +34 -1
- package/dist/workflows/dag/recovery-lease.js +80 -0
- package/dist/workflows/dag/report.js +37 -1
- package/dist/workflows/dag/rerun-feedback.js +256 -1
- package/dist/workflows/dag/rerun-plan.js +17 -6
- package/dist/workflows/dag/rerun-run.js +23 -0
- package/dist/workflows/dag/rerun-task.js +29 -0
- package/dist/workflows/dag/retry-policy.js +214 -104
- package/dist/workflows/dag/runner.js +433 -126
- package/dist/workflows/dag/scheduler.js +114 -16
- package/dist/workflows/dag/types.js +239 -12
- package/dist/workflows/dag/validate.js +28 -12
- package/docs/examples/README.md +5 -0
- package/docs/init-surface.manifest.json +30 -12
- package/docs/skills/vetted-skill-registry.md +4 -2
- package/docs/templates/README.md +2 -0
- package/docs/templates/agent-dag-report.schema.json +8 -2
- package/docs/templates/agent-dag.schema.json +1 -1
- package/docs/templates/backend-test-dag.json +5 -2
- package/docs/templates/frontend-implementation-contract.schema.json +4 -1
- package/docs/templates/frontend-implementation-dag.json +89 -0
- package/docs/templates/spec-registry.schema.json +45 -0
- package/harness.json +1 -1
- package/package.json +1 -1
- 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/loop-agent/references/command-reference.md +1 -0
- package/skills/loop-agent/references/hybrid-dag.md +2 -2
- package/dist/worker/console/static/assets/channel-BU5gOilw.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-DIzKJGHr.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-DIzKJGHr.js +0 -1
- package/dist/worker/console/static/assets/index-H9rFJiGL.css +0 -1
- package/dist/worker/console/static/assets/index-xwu9GxEc.js +0 -451
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-Cld2qK9v.js +0 -1
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-TIHpiT7w.js +0 -8
- 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
|
@@ -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,6 +15,8 @@ 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, } 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";
|
|
18
21
|
import { copyFrontendTestStandardScenarios } from "../workflows/dag/frontend-test-standard-scenarios.js";
|
|
19
22
|
import { probeFrontendTestEnvironment } from "../workflows/dag/frontend-test-environment-probe.js";
|
|
@@ -22,9 +25,15 @@ import { validateFrontendCaseChecklist } from "../workflows/dag/frontend-test-ca
|
|
|
22
25
|
import { materializeFrontendTestCaseManifest } from "../workflows/dag/frontend-test-case-manifest.js";
|
|
23
26
|
import { renderFrontendTestHtmlReport } from "../workflows/dag/frontend-test-html-report.js";
|
|
24
27
|
import { formatFrontendVerificationTraceStdout, runFrontendVerificationTraceGate, } from "../workflows/dag/frontend-verification-trace.js";
|
|
25
|
-
import { formatFrontendWorktreeDiffStdout, runFrontendWorktreeDiffGate, } from "../workflows/dag/frontend-worktree-diff.js";
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
+
import { captureFrontendWorktreeBaseline, formatFrontendWorktreeDiffStdout, runFrontendWorktreeDiffGate, } from "../workflows/dag/frontend-worktree-diff.js";
|
|
29
|
+
import { readTypedEventStoreFromJsonl } from "../workflows/dag/frontend-typed-event-store.js";
|
|
30
|
+
import { classifyFrontendFailure, } from "../workflows/dag/frontend-repair.js";
|
|
31
|
+
import { evaluateFrontendDesignPolicy, } from "../workflows/dag/frontend-design-policy.js";
|
|
32
|
+
import { deriveFrontendWriterAdmissionShell, FRONTEND_WRITER_ADMISSION_RESULT_ARTIFACT, frontendWriterAdmissionResultV1Schema, } from "../workflows/dag/frontend-writer-admission.js";
|
|
33
|
+
import { deriveFrontendIntegrationFacts, buildFrontendTestHandoff, frontendCloseoutFactsSchema, renderFrontendCloseout, } from "../workflows/dag/frontend-closeout.js";
|
|
34
|
+
import { buildFrontendHumanDecisionEnvelope, evaluateHighAdmissionReceipt, routeVerificationConfig, } from "../workflows/dag/frontend-human-decision.js";
|
|
35
|
+
import { classifyFailureOwner, classifyIssueCategoryRestartPhase, classifyRestartPhase, } from "../workflows/dag/frontend-recovery-capsule.js";
|
|
36
|
+
import { pathMatchesPattern } from "../shared/git-progress.js";
|
|
28
37
|
import { formatFrontendReviewContextStdout, runFrontendReviewContextGate, } from "../workflows/dag/frontend-review-context.js";
|
|
29
38
|
import { materializeFrontendLintAssessment, materializeFrontendLintBaseline, } from "../workflows/dag/frontend-lint-baseline.js";
|
|
30
39
|
import { formatTraceabilityGateStdout, materializeBackendTestCaseManifest, runBackendTestTraceabilityGate, } from "../workflows/dag/backend-test-case-manifest.js";
|
|
@@ -1895,6 +1904,45 @@ async function executePipelineCommands(input, meta, overrideCommands) {
|
|
|
1895
1904
|
}
|
|
1896
1905
|
return results;
|
|
1897
1906
|
}
|
|
1907
|
+
/** A+B (AC-008): derive unresolved verification entrypoints from committed plan
|
|
1908
|
+
* facts. A verification target is unresolved when its commandLabel does not
|
|
1909
|
+
* match any frozen command label from the verify shell evidence bundle.
|
|
1910
|
+
* Returns `{ ref, digest }` entries; a missing/unreadable plan ledger fails
|
|
1911
|
+
* closed to [] so the router restarts the contract instead of inventing refs. */
|
|
1912
|
+
async function deriveUnresolvedVerificationEntrypointRefs(runDir, frozenCommandLabels) {
|
|
1913
|
+
try {
|
|
1914
|
+
const { restorePlanPatchFromCommittedFacts } = await import("../workflows/dag/frontend-shadow-dual-write.js");
|
|
1915
|
+
const records = await readTypedEventStoreFromJsonl(path.join(runDir, "frontend-plan-pi", "plan-typed-facts.jsonl"));
|
|
1916
|
+
const patch = restorePlanPatchFromCommittedFacts(records);
|
|
1917
|
+
const targets = patch
|
|
1918
|
+
?.verificationTargets;
|
|
1919
|
+
if (!Array.isArray(targets))
|
|
1920
|
+
return [];
|
|
1921
|
+
const frozen = new Set(frozenCommandLabels
|
|
1922
|
+
.map((label) => label.trim().toLowerCase())
|
|
1923
|
+
.filter(Boolean));
|
|
1924
|
+
const refs = [];
|
|
1925
|
+
for (const item of targets) {
|
|
1926
|
+
const target = item;
|
|
1927
|
+
const commandLabel = typeof target.commandLabel === "string" ? target.commandLabel : "";
|
|
1928
|
+
if (commandLabel &&
|
|
1929
|
+
frozen.has(commandLabel.trim().toLowerCase())) {
|
|
1930
|
+
continue;
|
|
1931
|
+
}
|
|
1932
|
+
const file = typeof target.file === "string" ? target.file : "";
|
|
1933
|
+
const symbol = typeof target.symbol === "string" ? target.symbol : "";
|
|
1934
|
+
const id = typeof target.id === "string" ? target.id : "";
|
|
1935
|
+
const ref = file || symbol || id;
|
|
1936
|
+
if (!ref)
|
|
1937
|
+
continue;
|
|
1938
|
+
refs.push({ ref, digest: sha256Hex(ref) });
|
|
1939
|
+
}
|
|
1940
|
+
return refs;
|
|
1941
|
+
}
|
|
1942
|
+
catch {
|
|
1943
|
+
return [];
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1898
1946
|
async function executeFrontendVerificationBundle(input, meta) {
|
|
1899
1947
|
const started = Date.now();
|
|
1900
1948
|
const shell = input.task.shell;
|
|
@@ -2049,75 +2097,861 @@ async function executeFrontendVerificationBundle(input, meta) {
|
|
|
2049
2097
|
catch (error) {
|
|
2050
2098
|
traceError = error instanceof Error ? error : new Error(String(error));
|
|
2051
2099
|
}
|
|
2052
|
-
|
|
2053
|
-
|
|
2100
|
+
const verifyFailed = firstFailure !== undefined || lintSyntheticFailure !== undefined || traceError !== undefined;
|
|
2101
|
+
if (verifyFailed) {
|
|
2102
|
+
// M8: verify failure is TERMINAL. There is no same-run repair branch and
|
|
2103
|
+
// no frontend-repair-assessment.json; we only materialize failure
|
|
2104
|
+
// ownership facts (frontend-repair classification + recovery capsule
|
|
2105
|
+
// ownership) for the operation controller / recovery run.
|
|
2106
|
+
const failedNodeId = input.task.id;
|
|
2107
|
+
const failureCategory = firstFailure?.failureCategory ??
|
|
2108
|
+
lintSyntheticFailure?.failureCategory ??
|
|
2109
|
+
(traceError ? "invalid-output" : undefined) ??
|
|
2110
|
+
"invalid-output";
|
|
2111
|
+
const failureClass = classifyFrontendFailure({
|
|
2112
|
+
nodeId: failedNodeId,
|
|
2113
|
+
failureCategory,
|
|
2114
|
+
stdout: firstFailure?.stdout,
|
|
2115
|
+
stderr: firstFailure?.stderr ?? traceError?.message,
|
|
2116
|
+
});
|
|
2117
|
+
// A verify failure means the writer's candidate failed verification, so
|
|
2118
|
+
// the recovery ownership maps to the implement phase (frontend-recovery
|
|
2119
|
+
// capsule classification, fail-closed to implement-pi).
|
|
2120
|
+
const classifiedOwner = classifyFailureOwner({
|
|
2121
|
+
failureSource: "frontend-verify-shell",
|
|
2122
|
+
nodeId: failedNodeId,
|
|
2123
|
+
rawFailureCategory: failureCategory,
|
|
2124
|
+
});
|
|
2125
|
+
const failureOwner = classifiedOwner === "unknown" ? "implement-pi" : classifiedOwner;
|
|
2126
|
+
const restartPhase = classifyRestartPhase(failureOwner);
|
|
2127
|
+
// A+B (AC-008): verification-config routing. Produce structured
|
|
2128
|
+
// unresolved entrypoint refs from committed plan facts and the frozen
|
|
2129
|
+
// command labels; a non-empty unresolved set routes to
|
|
2130
|
+
// verification-config-decision and materializes the frozen
|
|
2131
|
+
// verification-config envelope. An empty/untyped signal fails closed to
|
|
2132
|
+
// contract-restart. The decision is recorded so the recovery controller
|
|
2133
|
+
// never re-classifies the same signal twice.
|
|
2134
|
+
let verificationConfigRoute;
|
|
2135
|
+
if (failureOwner === "verification-config") {
|
|
2136
|
+
const frozenCommandLabels = [
|
|
2137
|
+
...(bundle.staticEvidence.commandLabels ?? []),
|
|
2138
|
+
...(bundle.behaviorEvidence.commandLabels ?? []),
|
|
2139
|
+
...(bundle.mockEvidence?.commandLabels ?? []),
|
|
2140
|
+
];
|
|
2141
|
+
const unresolvedEntrypointRefs = await deriveUnresolvedVerificationEntrypointRefs(meta.runDir, frozenCommandLabels);
|
|
2142
|
+
verificationConfigRoute = routeVerificationConfig({
|
|
2143
|
+
unresolvedEntrypointRefs: unresolvedEntrypointRefs.map((ref) => ref.ref),
|
|
2144
|
+
});
|
|
2145
|
+
const allowlistedResolvers = [
|
|
2146
|
+
...new Set(frozenCommandLabels
|
|
2147
|
+
.map((label) => label.trim())
|
|
2148
|
+
.filter(Boolean)),
|
|
2149
|
+
].sort();
|
|
2150
|
+
if (verificationConfigRoute.decision ===
|
|
2151
|
+
"verification-config-decision" &&
|
|
2152
|
+
unresolvedEntrypointRefs.length > 0 &&
|
|
2153
|
+
allowlistedResolvers.length > 0) {
|
|
2154
|
+
const envelope = buildFrontendHumanDecisionEnvelope({
|
|
2155
|
+
operationId: input.task.id,
|
|
2156
|
+
runId: meta.runId,
|
|
2157
|
+
operationRevision: 1,
|
|
2158
|
+
targetDigest: sha256Hex(frozenCommandLabels.slice().sort().join("\n")),
|
|
2159
|
+
staleOnTargetDigestChange: true,
|
|
2160
|
+
kind: "verification-config",
|
|
2161
|
+
resumeAction: "select-verification-config",
|
|
2162
|
+
payload: {
|
|
2163
|
+
unresolvedEntrypointRefs,
|
|
2164
|
+
allowlistedResolvers,
|
|
2165
|
+
},
|
|
2166
|
+
});
|
|
2167
|
+
await writeDagRunJsonArtifact(meta.runDir, "contracts/frontend-verification-config-envelope.json", envelope);
|
|
2168
|
+
}
|
|
2169
|
+
}
|
|
2170
|
+
const verifyFailure = {
|
|
2171
|
+
schemaVersion: 1,
|
|
2172
|
+
schemaId: "frontend-verify-failure-v1",
|
|
2173
|
+
nodeId: failedNodeId,
|
|
2174
|
+
failureCategory,
|
|
2175
|
+
failureClass,
|
|
2176
|
+
failureOwner,
|
|
2177
|
+
restartPhase,
|
|
2178
|
+
...(verificationConfigRoute
|
|
2179
|
+
? { verificationConfigRoute }
|
|
2180
|
+
: {}),
|
|
2181
|
+
commandResults,
|
|
2182
|
+
failedAt: new Date().toISOString(),
|
|
2183
|
+
};
|
|
2184
|
+
await writeDagRunJsonArtifact(meta.runDir, "contracts/frontend-verify-failure.json", verifyFailure);
|
|
2185
|
+
return {
|
|
2186
|
+
ok: false,
|
|
2187
|
+
stdout: summarizeCommandResults(results).stdout,
|
|
2188
|
+
stderr: firstFailure?.stderr ||
|
|
2189
|
+
lintSyntheticFailure?.stderr ||
|
|
2190
|
+
traceError?.message ||
|
|
2191
|
+
"frontend verification failed",
|
|
2192
|
+
failureCategory,
|
|
2193
|
+
durationMs: Date.now() - started,
|
|
2194
|
+
...{ commandResults },
|
|
2195
|
+
};
|
|
2196
|
+
}
|
|
2197
|
+
// A+B (AC-008): when lint is `require-clean` but the assessment proves
|
|
2198
|
+
// baseline-debt, materialize the frozen `baseline-debt-acceptance` envelope
|
|
2199
|
+
// whose only positive resume is `accept-baseline-debt`. Evidence stays
|
|
2200
|
+
// `baseline-debt` and is never rewritten to `passed`.
|
|
2201
|
+
if (lintAssessment?.status === "baseline-debt") {
|
|
2202
|
+
const baselineEvidenceRefs = (lintAssessment.rawEvidenceRefs ?? [])
|
|
2203
|
+
.filter((ref) => ref?.path && ref?.sha256)
|
|
2204
|
+
.map((ref) => ({ ref: ref.path, digest: ref.sha256 }));
|
|
2205
|
+
if (baselineEvidenceRefs.length > 0) {
|
|
2206
|
+
const envelope = buildFrontendHumanDecisionEnvelope({
|
|
2207
|
+
operationId: input.task.id,
|
|
2208
|
+
runId: meta.runId,
|
|
2209
|
+
operationRevision: 1,
|
|
2210
|
+
targetDigest: lintAssessment.commandIdentity.sha256,
|
|
2211
|
+
staleOnTargetDigestChange: true,
|
|
2212
|
+
kind: "baseline-debt-acceptance",
|
|
2213
|
+
resumeAction: "accept-baseline-debt",
|
|
2214
|
+
payload: {
|
|
2215
|
+
baselineEvidenceRefs,
|
|
2216
|
+
candidateDigest: lintAssessment.commandIdentity.sha256,
|
|
2217
|
+
commandDigest: lintAssessment.commandIdentity.sha256,
|
|
2218
|
+
resultingPolicy: "allow-non-regression",
|
|
2219
|
+
},
|
|
2220
|
+
});
|
|
2221
|
+
await writeDagRunJsonArtifact(meta.runDir, "contracts/frontend-baseline-debt-acceptance-envelope.json", envelope);
|
|
2222
|
+
}
|
|
2223
|
+
}
|
|
2224
|
+
return {
|
|
2225
|
+
ok: true,
|
|
2226
|
+
stdout: lintAssessment?.status === "baseline-debt"
|
|
2227
|
+
? "Frontend verification bundle: pass with lint baseline-debt"
|
|
2228
|
+
: "Frontend verification bundle: pass",
|
|
2229
|
+
stderr: "",
|
|
2230
|
+
failureCategory: "success",
|
|
2231
|
+
durationMs: Date.now() - started,
|
|
2232
|
+
...{ commandResults },
|
|
2233
|
+
};
|
|
2234
|
+
}
|
|
2235
|
+
/* ------------------------------------------------------------------ *
|
|
2236
|
+
* M8 deterministic frontend shell nodes: design policy, writer *
|
|
2237
|
+
* admission, closeout. These replace the prewrite-gate authorization *
|
|
2238
|
+
* path and the Pi closeout node. *
|
|
2239
|
+
* ------------------------------------------------------------------ */
|
|
2240
|
+
async function readRunDirJson(runDir, relativePath) {
|
|
2241
|
+
return JSON.parse(await readFile(path.join(runDir, relativePath), "utf8"));
|
|
2242
|
+
}
|
|
2243
|
+
/** Committed typed review terminal kinds from the review node's typed event
|
|
2244
|
+
* store (AC-003: typed terminal tools are the only authoritative verdict). */
|
|
2245
|
+
async function collectReviewTerminalKinds(runDir, reviewNodeId) {
|
|
2246
|
+
try {
|
|
2247
|
+
const records = await readTypedEventStoreFromJsonl(path.join(runDir, reviewNodeId, "review-typed-facts.jsonl"));
|
|
2248
|
+
return records
|
|
2249
|
+
.filter((record) => record.phase === "committed")
|
|
2250
|
+
.map((record) => {
|
|
2251
|
+
const kind = record.fact.kind;
|
|
2252
|
+
return typeof kind === "string" ? kind : "";
|
|
2253
|
+
})
|
|
2254
|
+
.filter(Boolean);
|
|
2255
|
+
}
|
|
2256
|
+
catch {
|
|
2257
|
+
return [];
|
|
2258
|
+
}
|
|
2259
|
+
}
|
|
2260
|
+
/** Committed typed design terminal kinds from the design review node's typed
|
|
2261
|
+
* event store (M8: the committed approve_design / request_design_changes fact
|
|
2262
|
+
* is the only authoritative verdict; the legacy first-line VERDICT text is
|
|
2263
|
+
* never read for writer admission). Fail-closed on a missing/unreadable store. */
|
|
2264
|
+
async function collectDesignTerminalKinds(runDir, designNodeId) {
|
|
2265
|
+
try {
|
|
2266
|
+
const records = await readTypedEventStoreFromJsonl(path.join(runDir, designNodeId, "design-typed-facts.jsonl"));
|
|
2267
|
+
return records
|
|
2268
|
+
.filter((record) => record.phase === "committed")
|
|
2269
|
+
.map((record) => {
|
|
2270
|
+
const kind = record.fact.kind;
|
|
2271
|
+
return typeof kind === "string" ? kind : "";
|
|
2272
|
+
})
|
|
2273
|
+
.filter(Boolean);
|
|
2274
|
+
}
|
|
2275
|
+
catch {
|
|
2276
|
+
return [];
|
|
2277
|
+
}
|
|
2278
|
+
}
|
|
2279
|
+
/** A+B (AC-009): deterministic §4.10 restart phase for a committed
|
|
2280
|
+
* `request_review_changes` fact. The typed issueCategory is mapped through the
|
|
2281
|
+
* frozen classifier; `unknown` (or an unreadable store) fails closed to
|
|
2282
|
+
* `undefined` so the runtime never trusts an untyped category. */
|
|
2283
|
+
async function collectReviewRestartPhase(runDir, reviewNodeId) {
|
|
2284
|
+
try {
|
|
2285
|
+
const records = await readTypedEventStoreFromJsonl(path.join(runDir, reviewNodeId, "review-typed-facts.jsonl"));
|
|
2286
|
+
const request = records.find((record) => record.phase === "committed" &&
|
|
2287
|
+
record.fact.kind === "request_review_changes");
|
|
2288
|
+
const issueCategory = request?.fact
|
|
2289
|
+
?.issueCategory;
|
|
2290
|
+
return typeof issueCategory === "string"
|
|
2291
|
+
? (classifyIssueCategoryRestartPhase(issueCategory) ?? undefined)
|
|
2292
|
+
: undefined;
|
|
2293
|
+
}
|
|
2294
|
+
catch {
|
|
2295
|
+
return undefined;
|
|
2296
|
+
}
|
|
2297
|
+
}
|
|
2298
|
+
/** A+B (AC-009): deterministic §4.10 restart phase for a committed
|
|
2299
|
+
* `request_design_changes` fact. Mirrors the review collector. */
|
|
2300
|
+
/** Number of findings attached to the committed request_design_changes
|
|
2301
|
+
* terminal fact (0 when absent) — used for the admission advisory. */
|
|
2302
|
+
async function collectDesignReviewFindingCount(runDir, designNodeId) {
|
|
2303
|
+
try {
|
|
2304
|
+
const records = await readTypedEventStoreFromJsonl(path.join(runDir, designNodeId, "design-typed-facts.jsonl"));
|
|
2305
|
+
const request = records.find((record) => record.phase === "committed" &&
|
|
2306
|
+
record.fact.kind ===
|
|
2307
|
+
"request_design_changes");
|
|
2308
|
+
const findings = (request?.fact).findings;
|
|
2309
|
+
return Array.isArray(findings) ? findings.length : 0;
|
|
2310
|
+
}
|
|
2311
|
+
catch {
|
|
2312
|
+
return 0;
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
async function collectDesignRestartPhase(runDir, designNodeId) {
|
|
2316
|
+
try {
|
|
2317
|
+
const records = await readTypedEventStoreFromJsonl(path.join(runDir, designNodeId, "design-typed-facts.jsonl"));
|
|
2318
|
+
const request = records.find((record) => record.phase === "committed" &&
|
|
2319
|
+
record.fact.kind === "request_design_changes");
|
|
2320
|
+
const issueCategory = request?.fact
|
|
2321
|
+
?.issueCategory;
|
|
2322
|
+
return typeof issueCategory === "string"
|
|
2323
|
+
? (classifyIssueCategoryRestartPhase(issueCategory) ?? undefined)
|
|
2324
|
+
: undefined;
|
|
2325
|
+
}
|
|
2326
|
+
catch {
|
|
2327
|
+
return undefined;
|
|
2328
|
+
}
|
|
2329
|
+
}
|
|
2330
|
+
/**
|
|
2331
|
+
* Resolve the deterministic runtime skeleton for the frontend plan patch from
|
|
2332
|
+
* the DAG spec. The plan task carries it via `structuredContractOutput.skeleton`
|
|
2333
|
+
* (the only schema-recognized persistent channel); absence is a fail-closed
|
|
2334
|
+
* generation/configuration defect, never a reason to fall back to text.
|
|
2335
|
+
*/
|
|
2336
|
+
function resolveFrontendContractSkeleton(spec, planNodeId) {
|
|
2337
|
+
const planTask = spec.tasks.find((task) => task.id === planNodeId);
|
|
2338
|
+
const skeleton = planTask?.structuredContractOutput?.skeleton;
|
|
2339
|
+
if (!skeleton || Object.keys(skeleton).length === 0) {
|
|
2340
|
+
throw new Error(`frontend design policy blocked: missing runtime contract skeleton for ${planNodeId}`);
|
|
2341
|
+
}
|
|
2342
|
+
return skeleton;
|
|
2343
|
+
}
|
|
2344
|
+
async function collectFrontendSourceFreshness(input) {
|
|
2345
|
+
const entries = [];
|
|
2346
|
+
for (const source of input.sourceBinding?.sources ?? []) {
|
|
2347
|
+
entries.push({ path: source.path, sha256: source.sha256, fresh: true });
|
|
2348
|
+
}
|
|
2349
|
+
for (const evidencePath of input.contract.designEvidence.paths) {
|
|
2350
|
+
if (entries.some((entry) => entry.path === evidencePath))
|
|
2351
|
+
continue;
|
|
2352
|
+
try {
|
|
2353
|
+
const bytes = await readFile(path.join(input.workspaceRoot, evidencePath));
|
|
2354
|
+
entries.push({
|
|
2355
|
+
path: evidencePath,
|
|
2356
|
+
sha256: createHash("sha256").update(bytes).digest("hex"),
|
|
2357
|
+
fresh: true,
|
|
2358
|
+
});
|
|
2359
|
+
}
|
|
2360
|
+
catch {
|
|
2361
|
+
entries.push({
|
|
2362
|
+
path: evidencePath,
|
|
2363
|
+
sha256: "0".repeat(64),
|
|
2364
|
+
fresh: false,
|
|
2365
|
+
});
|
|
2366
|
+
}
|
|
2367
|
+
}
|
|
2368
|
+
return entries;
|
|
2369
|
+
}
|
|
2370
|
+
/** R3/R4 openspec invariants: frozen candidates must exist and content
|
|
2371
|
+
* snapshots must not have drifted. Citation is enforced upstream by the
|
|
2372
|
+
* prewrite gate read-event evidence and ledger specReference conformance. */
|
|
2373
|
+
async function checkFrontendOpenspecFacts(input) {
|
|
2374
|
+
const frozenCandidatePaths = input.config.openspecCandidatePaths ?? [];
|
|
2375
|
+
const candidateRoot = input.workspaceRoot;
|
|
2376
|
+
const missingCandidates = [];
|
|
2377
|
+
for (const candidate of frozenCandidatePaths) {
|
|
2378
|
+
try {
|
|
2379
|
+
await stat(path.join(candidateRoot, candidate));
|
|
2380
|
+
}
|
|
2381
|
+
catch {
|
|
2382
|
+
missingCandidates.push(candidate);
|
|
2383
|
+
}
|
|
2384
|
+
}
|
|
2385
|
+
if (missingCandidates.length > 0) {
|
|
2386
|
+
throw new Error(`frontend design policy blocked: openspec candidate paths frozen at generation time no longer exist on disk: ${missingCandidates.join(", ")}`);
|
|
2387
|
+
}
|
|
2388
|
+
const snapshots = input.config.openspecCandidateSnapshots;
|
|
2389
|
+
if (snapshots && snapshots.length > 0) {
|
|
2390
|
+
for (const snapshot of snapshots) {
|
|
2391
|
+
try {
|
|
2392
|
+
const bytes = await readFile(path.join(candidateRoot, snapshot.path));
|
|
2393
|
+
const actual = createHash("sha256").update(bytes).digest("hex");
|
|
2394
|
+
if (actual !== snapshot.sha256) {
|
|
2395
|
+
throw new Error(`frontend design policy blocked: openspec candidate content hash drifted: ${snapshot.path}`);
|
|
2396
|
+
}
|
|
2397
|
+
}
|
|
2398
|
+
catch (error) {
|
|
2399
|
+
if (error instanceof Error &&
|
|
2400
|
+
error.message.startsWith("frontend design policy blocked")) {
|
|
2401
|
+
throw error;
|
|
2402
|
+
}
|
|
2403
|
+
throw new Error(`frontend design policy blocked: openspec candidate unreadable: ${snapshot.path}`);
|
|
2404
|
+
}
|
|
2405
|
+
}
|
|
2406
|
+
}
|
|
2407
|
+
}
|
|
2408
|
+
async function executeFrontendDesignPolicy(input, meta) {
|
|
2409
|
+
const started = Date.now();
|
|
2410
|
+
const shell = input.task.shell;
|
|
2411
|
+
const config = shell.frontendDesignPolicy;
|
|
2412
|
+
try {
|
|
2413
|
+
// 1. Materialize the canonical contract from committed typed facts. After
|
|
2414
|
+
// M9a the plan node's assistantText is a pure Markdown narrative; the
|
|
2415
|
+
// compile authority is the committed plan ledger ⊕ runtime skeleton.
|
|
2416
|
+
// Fail closed on missing committed facts — never fall back to text.
|
|
2417
|
+
const { readCommittedOriginFacts, checkCommittedOriginFacts } = await import("../workflows/dag/frontend-shadow-dual-write.js");
|
|
2418
|
+
// A+B (AC-001/003): fail-closed committed contract/scout typed facts.
|
|
2419
|
+
// Missing/uncommitted facts block here; never fall back to text parsing.
|
|
2420
|
+
const committedContractFacts = await readCommittedOriginFacts(meta.runDir, "frontend-contract-pi", "contract-typed-facts.jsonl");
|
|
2421
|
+
const contractCheck = checkCommittedOriginFacts({
|
|
2422
|
+
records: committedContractFacts,
|
|
2423
|
+
origin: "contract",
|
|
2424
|
+
});
|
|
2425
|
+
if (!contractCheck.ok) {
|
|
2426
|
+
return {
|
|
2427
|
+
ok: false,
|
|
2428
|
+
stdout: "",
|
|
2429
|
+
stderr: `frontend design policy blocked: ${contractCheck.reason}`,
|
|
2430
|
+
failureCategory: "invalid-output",
|
|
2431
|
+
durationMs: Date.now() - started,
|
|
2432
|
+
};
|
|
2433
|
+
}
|
|
2434
|
+
const committedScoutFacts = await readCommittedOriginFacts(meta.runDir, "frontend-scout-pi", "scout-typed-facts.jsonl");
|
|
2435
|
+
const scoutCheck = checkCommittedOriginFacts({
|
|
2436
|
+
records: committedScoutFacts,
|
|
2437
|
+
origin: "scout",
|
|
2438
|
+
});
|
|
2439
|
+
if (!scoutCheck.ok) {
|
|
2440
|
+
return {
|
|
2441
|
+
ok: false,
|
|
2442
|
+
stdout: "",
|
|
2443
|
+
stderr: `frontend design policy blocked: ${scoutCheck.reason}`,
|
|
2444
|
+
failureCategory: "invalid-output",
|
|
2445
|
+
durationMs: Date.now() - started,
|
|
2446
|
+
};
|
|
2447
|
+
}
|
|
2448
|
+
const skeleton = resolveFrontendContractSkeleton(meta.spec, config.planFromNodeId);
|
|
2449
|
+
const assembled = await buildContractFromCommittedFacts({
|
|
2450
|
+
runDir: meta.runDir,
|
|
2451
|
+
planNodeId: config.planFromNodeId,
|
|
2452
|
+
contractNodeId: "frontend-contract-pi",
|
|
2453
|
+
sourceBinding: meta.spec.sourceBinding,
|
|
2454
|
+
skeleton,
|
|
2455
|
+
});
|
|
2456
|
+
if (!assembled.ok) {
|
|
2457
|
+
return {
|
|
2458
|
+
ok: false,
|
|
2459
|
+
stdout: "",
|
|
2460
|
+
stderr: `frontend design policy blocked: ${assembled.reason}`,
|
|
2461
|
+
failureCategory: "invalid-output",
|
|
2462
|
+
durationMs: Date.now() - started,
|
|
2463
|
+
};
|
|
2464
|
+
}
|
|
2465
|
+
const contract = assembled.canonical;
|
|
2466
|
+
// 2. Requirement id retention (R11): search the canonical contract
|
|
2467
|
+
// serialization instead of the plan node narrative.
|
|
2468
|
+
const contractText = serializeCompactDeterministicJson(contract);
|
|
2469
|
+
const missingIds = config.requiredRequirementIds.filter((id) => !contractText.includes(id));
|
|
2470
|
+
if (missingIds.length > 0) {
|
|
2471
|
+
return {
|
|
2472
|
+
ok: false,
|
|
2473
|
+
stdout: "",
|
|
2474
|
+
stderr: `frontend design policy blocked: missing requirement ids: ${missingIds.join(", ")}`,
|
|
2475
|
+
failureCategory: "invalid-output",
|
|
2476
|
+
durationMs: Date.now() - started,
|
|
2477
|
+
};
|
|
2478
|
+
}
|
|
2479
|
+
// 3. Mock strategy allowed + frozen command binding (R1).
|
|
2480
|
+
const mockStrategy = contract.mockApi.strategy;
|
|
2481
|
+
if (!config.allowedMockStrategies.includes(mockStrategy)) {
|
|
2482
|
+
return {
|
|
2483
|
+
ok: false,
|
|
2484
|
+
stdout: "",
|
|
2485
|
+
stderr: `frontend contract mock strategy "${mockStrategy}" is incompatible with the generated allowed strategies [${config.allowedMockStrategies.join(", ")}]`,
|
|
2486
|
+
failureCategory: "invalid-output",
|
|
2487
|
+
durationMs: Date.now() - started,
|
|
2488
|
+
};
|
|
2489
|
+
}
|
|
2490
|
+
if (mockStrategy !== "not-needed" && config.mockCommandLabels.length === 0) {
|
|
2054
2491
|
return {
|
|
2055
2492
|
ok: false,
|
|
2056
|
-
stdout:
|
|
2057
|
-
stderr:
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2493
|
+
stdout: "",
|
|
2494
|
+
stderr: `frontend design policy blocked: contract selected Mock strategy ${mockStrategy} but the DAG has no authorized Mock verification commands`,
|
|
2495
|
+
failureCategory: "invalid-output",
|
|
2496
|
+
durationMs: Date.now() - started,
|
|
2497
|
+
};
|
|
2498
|
+
}
|
|
2499
|
+
// 4. writeSet containment.
|
|
2500
|
+
if (config.implementationWriteSet) {
|
|
2501
|
+
const writeSet = new Set(config.implementationWriteSet);
|
|
2502
|
+
const uncoveredTargets = contract.targets.files.filter((target) => ![...writeSet].some((pattern) => pathMatchesPattern(target, pattern) || target === pattern));
|
|
2503
|
+
if (uncoveredTargets.length > 0) {
|
|
2504
|
+
return {
|
|
2505
|
+
ok: false,
|
|
2506
|
+
stdout: "",
|
|
2507
|
+
stderr: `frontend design policy blocked: contract target is outside implementation writeSet: ${uncoveredTargets.join(", ")}`,
|
|
2508
|
+
failureCategory: "invalid-output",
|
|
2509
|
+
durationMs: Date.now() - started,
|
|
2510
|
+
};
|
|
2511
|
+
}
|
|
2512
|
+
const uncoveredVTs = contract.verificationTargets
|
|
2513
|
+
.filter((vt) => vt.type !== "static")
|
|
2514
|
+
.filter((vt) => ![...writeSet].some((pattern) => pathMatchesPattern(vt.file, pattern) || vt.file === pattern));
|
|
2515
|
+
if (uncoveredVTs.length > 0) {
|
|
2516
|
+
return {
|
|
2517
|
+
ok: false,
|
|
2518
|
+
stdout: "",
|
|
2519
|
+
stderr: `frontend design policy blocked: verification target is outside implementation writeSet: ${uncoveredVTs.map((vt) => vt.file).join(", ")}`,
|
|
2520
|
+
failureCategory: "invalid-output",
|
|
2521
|
+
durationMs: Date.now() - started,
|
|
2522
|
+
};
|
|
2523
|
+
}
|
|
2524
|
+
}
|
|
2525
|
+
// 5. Source freshness (R4) + freshness entries.
|
|
2526
|
+
if (config.requireSourceFreshness) {
|
|
2527
|
+
if (!meta.spec.sourceBinding) {
|
|
2528
|
+
throw new Error("frontend design policy requires sourceBinding for freshness check");
|
|
2529
|
+
}
|
|
2530
|
+
await assertFrontendSourceBindingFresh({
|
|
2531
|
+
workspaceRoot: input.cwd,
|
|
2532
|
+
binding: meta.spec.sourceBinding,
|
|
2533
|
+
});
|
|
2534
|
+
}
|
|
2535
|
+
// Byte freshness is necessary but not sufficient: require the same ledger
|
|
2536
|
+
// semantic checks as the shadow prewrite gate before production writer
|
|
2537
|
+
// admission can be materialized.
|
|
2538
|
+
if (meta.spec.sourceBinding) {
|
|
2539
|
+
const ledgerCheck = await checkFrontendSourceFidelityLedger({
|
|
2540
|
+
workspaceRoot: input.cwd,
|
|
2541
|
+
binding: meta.spec.sourceBinding,
|
|
2542
|
+
contractRequirements: contract.requirements.map((requirement) => ({
|
|
2543
|
+
id: requirement.id,
|
|
2544
|
+
sourceFragmentIds: requirement.sourceFragmentIds,
|
|
2545
|
+
sourceRefs: requirement.sourceRefs,
|
|
2546
|
+
})),
|
|
2547
|
+
});
|
|
2548
|
+
if (!ledgerCheck.ok) {
|
|
2549
|
+
return {
|
|
2550
|
+
ok: false,
|
|
2551
|
+
stdout: "",
|
|
2552
|
+
stderr: `frontend design policy blocked: ${ledgerCheck.failureReason ?? "source fidelity ledger validation failed"}`,
|
|
2553
|
+
failureCategory: "invalid-output",
|
|
2554
|
+
durationMs: Date.now() - started,
|
|
2555
|
+
};
|
|
2556
|
+
}
|
|
2557
|
+
}
|
|
2558
|
+
const sourceFreshness = await collectFrontendSourceFreshness({
|
|
2559
|
+
workspaceRoot: input.cwd,
|
|
2560
|
+
sourceBinding: meta.spec.sourceBinding,
|
|
2561
|
+
contract,
|
|
2562
|
+
});
|
|
2563
|
+
// 6. Openspec invariants (R3): frozen candidates exist and snapshots have
|
|
2564
|
+
// not drifted. Citation is superseded by prewrite-gate read evidence.
|
|
2565
|
+
await checkFrontendOpenspecFacts({
|
|
2566
|
+
workspaceRoot: input.cwd,
|
|
2567
|
+
config,
|
|
2568
|
+
});
|
|
2569
|
+
// 7. Deterministic design policy (M8 D2: designApproval is optional here;
|
|
2570
|
+
// the design verdict is enforced by the writer-admission shell).
|
|
2571
|
+
const policyResult = evaluateFrontendDesignPolicy({
|
|
2572
|
+
contract,
|
|
2573
|
+
allowedMockStrategies: config.allowedMockStrategies,
|
|
2574
|
+
sourceFreshness,
|
|
2575
|
+
componentSpecCandidatePaths: config.openspecCandidatePaths ??
|
|
2576
|
+
config.componentSpecCandidatePaths ??
|
|
2577
|
+
[],
|
|
2578
|
+
allowedDependencies: config.allowedDependencies,
|
|
2579
|
+
writeSetPatterns: config.implementationWriteSet ?? [],
|
|
2580
|
+
});
|
|
2581
|
+
// 8. Write canonical contract + policy result.
|
|
2582
|
+
const contractArtifact = await writeFrontendImplementationContractArtifact({
|
|
2583
|
+
runDir: meta.runDir,
|
|
2584
|
+
outputDir: config.outputDir,
|
|
2585
|
+
artifactName: config.artifactName,
|
|
2586
|
+
canonical: contract,
|
|
2587
|
+
});
|
|
2588
|
+
await writeDagRunJsonArtifact(meta.runDir, "contracts/frontend-design-policy-result.json", policyResult);
|
|
2589
|
+
if (policyResult.classification === "blocked") {
|
|
2590
|
+
return {
|
|
2591
|
+
ok: false,
|
|
2592
|
+
stdout: "",
|
|
2593
|
+
stderr: `frontend design policy blocked: ${policyResult.findings.map((finding) => `${finding.code}: ${finding.message}`).join("; ")}`,
|
|
2594
|
+
failureCategory: "invalid-output",
|
|
2064
2595
|
durationMs: Date.now() - started,
|
|
2065
|
-
...{ commandResults },
|
|
2066
2596
|
};
|
|
2067
2597
|
}
|
|
2068
2598
|
return {
|
|
2069
2599
|
ok: true,
|
|
2070
|
-
stdout:
|
|
2071
|
-
|
|
2072
|
-
:
|
|
2600
|
+
stdout: [
|
|
2601
|
+
"Frontend design policy: approved findings=0",
|
|
2602
|
+
`Contract: ${contractArtifact.path}`,
|
|
2603
|
+
`Contract index: ${contractArtifact.reviewIndexPath}`,
|
|
2604
|
+
`Capacity diagnostic: ${contractArtifact.capacityDiagnosticPath} (non-blocking)`,
|
|
2605
|
+
].join("\n"),
|
|
2073
2606
|
stderr: "",
|
|
2074
2607
|
failureCategory: "success",
|
|
2075
2608
|
durationMs: Date.now() - started,
|
|
2076
|
-
...{ commandResults },
|
|
2077
2609
|
};
|
|
2078
2610
|
}
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
:
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
status: "FINISHED",
|
|
2088
|
-
failureCategory: firstFailure?.failureCategory ??
|
|
2089
|
-
lintSyntheticFailure?.failureCategory,
|
|
2090
|
-
// Keep classification scoped to the failed command. Aggregate
|
|
2091
|
-
// successful output may contain unrelated writeSet-like JSON.
|
|
2092
|
-
stdout: failureStdout,
|
|
2093
|
-
stderr: firstFailure?.stderr ?? lintSyntheticFailure?.stderr,
|
|
2094
|
-
commandResults,
|
|
2095
|
-
},
|
|
2096
|
-
});
|
|
2611
|
+
catch (error) {
|
|
2612
|
+
return {
|
|
2613
|
+
ok: false,
|
|
2614
|
+
stdout: "",
|
|
2615
|
+
stderr: error instanceof Error ? error.message : String(error),
|
|
2616
|
+
failureCategory: "invalid-output",
|
|
2617
|
+
durationMs: Date.now() - started,
|
|
2618
|
+
};
|
|
2097
2619
|
}
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2620
|
+
}
|
|
2621
|
+
async function executeFrontendWriterAdmission(input, meta) {
|
|
2622
|
+
const started = Date.now();
|
|
2623
|
+
const shell = input.task.shell;
|
|
2624
|
+
const config = shell.frontendWriterAdmission;
|
|
2625
|
+
try {
|
|
2626
|
+
// 1. Design verdict handling (r12 policy change). The typed terminal
|
|
2627
|
+
// verdict is read from the committed typed design terminal fact, not
|
|
2628
|
+
// from the legacy first-line VERDICT text protocol (AC-003/AC-004).
|
|
2629
|
+
// A request_design_changes verdict no longer blocks writer admission:
|
|
2630
|
+
// it is downgraded to an advisory that rides along in the admission
|
|
2631
|
+
// receipt (and reaches implement via the review node's upstream
|
|
2632
|
+
// context). Blocking is owned by the deterministic gates (prewrite,
|
|
2633
|
+
// write guard) and the final code review. A missing typed terminal
|
|
2634
|
+
// verdict still fails closed. In small topology the design review node
|
|
2635
|
+
// is absent and the check is vacuous.
|
|
2636
|
+
let verdictPass = true;
|
|
2637
|
+
let designAdvisory;
|
|
2638
|
+
if (config.designReviewFromNodeId) {
|
|
2639
|
+
const designKinds = await collectDesignTerminalKinds(meta.runDir, config.designReviewFromNodeId);
|
|
2640
|
+
if (designKinds.length !== 1) {
|
|
2641
|
+
verdictPass = false;
|
|
2642
|
+
}
|
|
2643
|
+
else if (designKinds[0] !== "approve_design") {
|
|
2644
|
+
designAdvisory = {
|
|
2645
|
+
verdict: designKinds[0],
|
|
2646
|
+
restartPhase: await collectDesignRestartPhase(meta.runDir, config.designReviewFromNodeId),
|
|
2647
|
+
findingCount: await collectDesignReviewFindingCount(meta.runDir, config.designReviewFromNodeId),
|
|
2648
|
+
};
|
|
2649
|
+
}
|
|
2650
|
+
}
|
|
2651
|
+
// 2. Read the canonical contract + design-policy result.
|
|
2652
|
+
const contractRaw = await readRunDirJson(meta.runDir, "contracts/frontend-implementation-contract.json");
|
|
2653
|
+
const contract = frontendImplementationContractSchema.parse(contractRaw);
|
|
2654
|
+
const policyRaw = (await readRunDirJson(meta.runDir, "contracts/frontend-design-policy-result.json"));
|
|
2655
|
+
if (policyRaw.schemaId !== "frontend-design-policy-v1") {
|
|
2656
|
+
throw new Error("frontend writer admission: design policy result artifact invalid");
|
|
2657
|
+
}
|
|
2658
|
+
const designPolicyResult = {
|
|
2659
|
+
schemaId: "frontend-design-policy-v1",
|
|
2660
|
+
classification: policyRaw.classification === "approved" ? "approved" : "blocked",
|
|
2661
|
+
findings: policyRaw.findings ?? [],
|
|
2662
|
+
digest: "",
|
|
2663
|
+
};
|
|
2664
|
+
// 3. Freeze the pre-writer worktree baseline (cumulative diff baseline).
|
|
2665
|
+
await captureFrontendWorktreeBaseline({
|
|
2666
|
+
runDir: meta.runDir,
|
|
2667
|
+
workspaceRoot: input.cwd,
|
|
2106
2668
|
});
|
|
2669
|
+
const baselineRaw = (await readRunDirJson(meta.runDir, "contracts/frontend-worktree-baseline.json"));
|
|
2670
|
+
const baseline = (baselineRaw.files ?? [])
|
|
2671
|
+
.map((file) => ({
|
|
2672
|
+
path: file,
|
|
2673
|
+
sha256: baselineRaw.hashes?.[file] ?? null,
|
|
2674
|
+
}))
|
|
2675
|
+
.filter((entry) => entry.sha256 !== null);
|
|
2676
|
+
// 4. Writer-preceding lint baseline (R5) when lint is configured.
|
|
2677
|
+
let lintResults = [];
|
|
2678
|
+
if ((config.lintCommands?.length ?? 0) > 0) {
|
|
2679
|
+
for (const command of config.lintCommands) {
|
|
2680
|
+
const commandNumber = lintResults.length + 1;
|
|
2681
|
+
const result = await executeShellCommand({
|
|
2682
|
+
command,
|
|
2683
|
+
cwd: input.cwd,
|
|
2684
|
+
timeoutMs: shell.timeoutMs ?? DEFAULT_SHELL_TIMEOUT_MS,
|
|
2685
|
+
envAllowlist: shell.envAllowlist,
|
|
2686
|
+
dagRunMeta: { runDir: meta.runDir, runId: meta.runId },
|
|
2687
|
+
reportActivity: input.reportActivity,
|
|
2688
|
+
outputArtifacts: {
|
|
2689
|
+
stdoutPath: path.join(meta.runDir, input.task.id, "commands", `${commandNumber}.stdout.txt`),
|
|
2690
|
+
stderrPath: path.join(meta.runDir, input.task.id, "commands", `${commandNumber}.stderr.txt`),
|
|
2691
|
+
},
|
|
2692
|
+
});
|
|
2693
|
+
lintResults.push(result);
|
|
2694
|
+
}
|
|
2695
|
+
await materializeFrontendLintBaseline({
|
|
2696
|
+
runDir: meta.runDir,
|
|
2697
|
+
workspaceRoot: input.cwd,
|
|
2698
|
+
commands: config.lintCommands,
|
|
2699
|
+
results: lintResults,
|
|
2700
|
+
worktreeChanged: false,
|
|
2701
|
+
});
|
|
2702
|
+
}
|
|
2703
|
+
// 5. Derive admission (writeSet + digests + findings). Glob entries in
|
|
2704
|
+
// the contract targets (e.g. `src/**` inherited from the skeleton) are
|
|
2705
|
+
// expanded against the concrete workspace files so the derived writeSet
|
|
2706
|
+
// contains only real paths the writer can touch.
|
|
2707
|
+
const workspaceFiles = await collectWorkspaceFiles(input.cwd);
|
|
2708
|
+
const admission = deriveFrontendWriterAdmissionShell({
|
|
2709
|
+
contract,
|
|
2710
|
+
designPolicyResult,
|
|
2711
|
+
baseline,
|
|
2712
|
+
frozenCommandLabels: config.frozenCommandLabels,
|
|
2713
|
+
allowedMockStrategies: config.allowedMockStrategies,
|
|
2714
|
+
workspaceFiles,
|
|
2715
|
+
});
|
|
2716
|
+
// 6. Design verdict enforcement: request-revision is a blocked admission.
|
|
2717
|
+
const failureSource = policyRaw.classification === "blocked"
|
|
2718
|
+
? "frontend-design-policy-shell"
|
|
2719
|
+
: "frontend-writer-admission-shell";
|
|
2720
|
+
const findings = verdictPass
|
|
2721
|
+
? admission.findings
|
|
2722
|
+
: [
|
|
2723
|
+
...admission.findings,
|
|
2724
|
+
{
|
|
2725
|
+
code: "design-approval-missing",
|
|
2726
|
+
message: "design review typed terminal verdict missing or ambiguous (fail closed)",
|
|
2727
|
+
},
|
|
2728
|
+
];
|
|
2729
|
+
const classification = findings.length === 0 && admission.classification === "accepted"
|
|
2730
|
+
? admission.classification
|
|
2731
|
+
: findings.length === 0 &&
|
|
2732
|
+
admission.classification === "requires-human-approval"
|
|
2733
|
+
? "requires-human-approval"
|
|
2734
|
+
: "blocked";
|
|
2735
|
+
const result = frontendWriterAdmissionResultV1Schema.parse({
|
|
2736
|
+
schemaVersion: 1,
|
|
2737
|
+
schemaId: "frontend-writer-admission-shell-v1",
|
|
2738
|
+
classification,
|
|
2739
|
+
writeSet: admission.writeSet,
|
|
2740
|
+
writeSetDigest: admission.writeSetDigest,
|
|
2741
|
+
baselineDigest: admission.baselineDigest,
|
|
2742
|
+
admissionDigest: admission.admissionDigest,
|
|
2743
|
+
...(admission.baselineDebtPolicy !== undefined
|
|
2744
|
+
? { baselineDebtPolicy: admission.baselineDebtPolicy }
|
|
2745
|
+
: {}),
|
|
2746
|
+
findings,
|
|
2747
|
+
...(designAdvisory ? { designReviewAdvisory: designAdvisory } : {}),
|
|
2748
|
+
failureSource,
|
|
2749
|
+
});
|
|
2750
|
+
await writeDagRunJsonArtifact(meta.runDir, FRONTEND_WRITER_ADMISSION_RESULT_ARTIFACT, result);
|
|
2751
|
+
// A+B (AC-007): High topology materializes a `high-admission-receipt-v1`
|
|
2752
|
+
// catalog whose candidate digest must match the admission digest before
|
|
2753
|
+
// the gate can transition from `requires-human-approval` to `accepted`.
|
|
2754
|
+
// Any digest drift resolves to `stale` (never silently accepted).
|
|
2755
|
+
if (classification === "requires-human-approval") {
|
|
2756
|
+
const receipt = evaluateHighAdmissionReceipt({
|
|
2757
|
+
candidateDigest: result.admissionDigest,
|
|
2758
|
+
admissionDigest: result.admissionDigest,
|
|
2759
|
+
});
|
|
2760
|
+
await writeDagRunJsonArtifact(meta.runDir, "contracts/frontend-high-admission-receipt.json", receipt);
|
|
2761
|
+
if (receipt.status !== "accepted") {
|
|
2762
|
+
return {
|
|
2763
|
+
ok: false,
|
|
2764
|
+
stdout: "",
|
|
2765
|
+
stderr: `frontend writer admission stale: high-admission receipt candidate digest drifted from admission digest`,
|
|
2766
|
+
failureCategory: "invalid-output",
|
|
2767
|
+
durationMs: Date.now() - started,
|
|
2768
|
+
};
|
|
2769
|
+
}
|
|
2770
|
+
}
|
|
2771
|
+
if (classification === "blocked") {
|
|
2772
|
+
return {
|
|
2773
|
+
ok: false,
|
|
2774
|
+
stdout: "",
|
|
2775
|
+
stderr: `frontend writer admission ${classification}: ${findings.map((finding) => `${finding.code}: ${finding.message}`).join("; ")}`,
|
|
2776
|
+
failureCategory: "invalid-output",
|
|
2777
|
+
durationMs: Date.now() - started,
|
|
2778
|
+
};
|
|
2779
|
+
}
|
|
2780
|
+
return {
|
|
2781
|
+
ok: true,
|
|
2782
|
+
stdout: `Frontend writer admission: ${classification} writeSet=${result.writeSet.length} writeSetDigest=${result.writeSetDigest}`,
|
|
2783
|
+
stderr: "",
|
|
2784
|
+
failureCategory: "success",
|
|
2785
|
+
durationMs: Date.now() - started,
|
|
2786
|
+
};
|
|
2787
|
+
}
|
|
2788
|
+
catch (error) {
|
|
2789
|
+
return {
|
|
2790
|
+
ok: false,
|
|
2791
|
+
stdout: "",
|
|
2792
|
+
stderr: error instanceof Error ? error.message : String(error),
|
|
2793
|
+
failureCategory: "invalid-output",
|
|
2794
|
+
durationMs: Date.now() - started,
|
|
2795
|
+
};
|
|
2107
2796
|
}
|
|
2797
|
+
}
|
|
2798
|
+
async function executeFrontendContractImport(input, meta) {
|
|
2799
|
+
const started = Date.now();
|
|
2800
|
+
const shell = input.task.shell;
|
|
2801
|
+
const config = shell.frontendContractImport;
|
|
2108
2802
|
try {
|
|
2109
|
-
const
|
|
2110
|
-
|
|
2111
|
-
|
|
2803
|
+
const binding = meta.spec.sourceBinding;
|
|
2804
|
+
if (!binding) {
|
|
2805
|
+
throw new Error("frontend contract-import requires a DAG sourceBinding to re-validate freshness");
|
|
2806
|
+
}
|
|
2807
|
+
if (config.requireSourceFreshness) {
|
|
2808
|
+
await assertFrontendSourceBindingFresh({
|
|
2809
|
+
workspaceRoot: input.cwd,
|
|
2810
|
+
binding,
|
|
2811
|
+
});
|
|
2812
|
+
}
|
|
2813
|
+
const digest = createHash("sha256")
|
|
2814
|
+
.update(JSON.stringify({
|
|
2815
|
+
taskId: binding.taskId,
|
|
2816
|
+
sources: binding.sources,
|
|
2817
|
+
artifactName: config.artifactName,
|
|
2818
|
+
}))
|
|
2819
|
+
.digest("hex");
|
|
2820
|
+
const facts = {
|
|
2821
|
+
schemaVersion: 1,
|
|
2822
|
+
schemaId: "frontend-contract-import-v1",
|
|
2823
|
+
artifactName: config.artifactName,
|
|
2824
|
+
sourceBindingTaskId: binding.taskId,
|
|
2825
|
+
sourceCount: binding.sources.length,
|
|
2826
|
+
fresh: true,
|
|
2827
|
+
digest,
|
|
2828
|
+
};
|
|
2829
|
+
return {
|
|
2830
|
+
ok: true,
|
|
2831
|
+
stdout: JSON.stringify(facts, null, 2),
|
|
2832
|
+
stderr: "",
|
|
2833
|
+
failureCategory: "success",
|
|
2834
|
+
durationMs: Date.now() - started,
|
|
2835
|
+
};
|
|
2836
|
+
}
|
|
2837
|
+
catch (error) {
|
|
2838
|
+
return {
|
|
2839
|
+
ok: false,
|
|
2840
|
+
stdout: "",
|
|
2841
|
+
stderr: error instanceof Error ? error.message : String(error),
|
|
2842
|
+
failureCategory: "invalid-output",
|
|
2843
|
+
durationMs: Date.now() - started,
|
|
2844
|
+
};
|
|
2845
|
+
}
|
|
2846
|
+
}
|
|
2847
|
+
async function executeFrontendCloseout(input, meta) {
|
|
2848
|
+
const started = Date.now();
|
|
2849
|
+
const shell = input.task.shell;
|
|
2850
|
+
const config = shell.frontendCloseout;
|
|
2851
|
+
try {
|
|
2852
|
+
const context = (await readRunDirJson(meta.runDir, "contracts/frontend-review-context.json"));
|
|
2853
|
+
if (context.contractRef?.path !==
|
|
2854
|
+
"contracts/frontend-implementation-contract.json") {
|
|
2855
|
+
throw new Error("frontend closeout missing canonical contract reference");
|
|
2856
|
+
}
|
|
2857
|
+
const contractRaw = await readFile(path.join(meta.runDir, context.contractRef.path), "utf8");
|
|
2858
|
+
const contractSha256 = createHash("sha256")
|
|
2859
|
+
.update(contractRaw)
|
|
2860
|
+
.digest("hex");
|
|
2861
|
+
if (contractSha256 !== context.contractRef.sha256) {
|
|
2862
|
+
throw new Error("frontend closeout canonical contract hash mismatch");
|
|
2863
|
+
}
|
|
2864
|
+
const contract = frontendImplementationContractSchema.parse(JSON.parse(contractRaw));
|
|
2865
|
+
const trace = context.verificationTrace;
|
|
2866
|
+
const verificationTargets = (trace?.targets ?? []).map((target) => ({
|
|
2867
|
+
status: target.status === "ok" ? "ok" : "failed",
|
|
2868
|
+
}));
|
|
2869
|
+
const mockEvidenceBound = contract.mockApi.strategy !== "not-needed" &&
|
|
2870
|
+
typeof trace?.mockCommandNodeId === "string" &&
|
|
2871
|
+
trace.mockCommandNodeId.length > 0 &&
|
|
2872
|
+
Array.isArray(trace?.mockCommandLabels) &&
|
|
2873
|
+
trace.mockCommandLabels.length > 0 &&
|
|
2874
|
+
Array.isArray(trace?.mockCommandTexts) &&
|
|
2875
|
+
trace.mockCommandTexts.length === trace.mockCommandLabels.length;
|
|
2876
|
+
const integrationFacts = deriveFrontendIntegrationFacts({
|
|
2877
|
+
mockStrategy: contract.mockApi.strategy,
|
|
2878
|
+
realApiEvidence: { present: false, passed: false },
|
|
2879
|
+
mockEvidenceBound,
|
|
2880
|
+
verificationTargets,
|
|
2112
2881
|
});
|
|
2113
|
-
|
|
2882
|
+
// Typed review terminal (AC-003) from the committed typed event store.
|
|
2883
|
+
const typedKinds = await collectReviewTerminalKinds(meta.runDir, config.reviewFromNodeId);
|
|
2884
|
+
const typedVerdict = typedKinds.length === 1 &&
|
|
2885
|
+
(typedKinds[0] === "approve_review" || typedKinds[0] === "request_review_changes")
|
|
2886
|
+
? typedKinds[0]
|
|
2887
|
+
: null;
|
|
2888
|
+
// A+B (AC-009): request_review_changes issueCategory maps to the
|
|
2889
|
+
// deterministic §4.10 restart phase. Recorded as a run-owned audit
|
|
2890
|
+
// artifact so the frozen closeout schema is never widened; `unknown`
|
|
2891
|
+
// fails closed to no restart phase.
|
|
2892
|
+
const reviewRestartPhase = typedVerdict === "request_review_changes"
|
|
2893
|
+
? await collectReviewRestartPhase(meta.runDir, config.reviewFromNodeId)
|
|
2894
|
+
: undefined;
|
|
2895
|
+
if (reviewRestartPhase !== undefined) {
|
|
2896
|
+
await writeDagRunJsonArtifact(meta.runDir, "contracts/frontend-review-restart-phase.json", {
|
|
2897
|
+
schemaVersion: 1,
|
|
2898
|
+
nodeId: config.reviewFromNodeId,
|
|
2899
|
+
restartPhase: reviewRestartPhase,
|
|
2900
|
+
});
|
|
2901
|
+
}
|
|
2902
|
+
const facts = frontendCloseoutFactsSchema.parse({
|
|
2903
|
+
schemaVersion: 1,
|
|
2904
|
+
schemaId: "frontend-closeout-facts-v1",
|
|
2905
|
+
coverageMatrix: verificationTargets.map((target, index) => ({
|
|
2906
|
+
verificationTargetId: trace?.targets?.[index]?.id ?? `vt-${index}`,
|
|
2907
|
+
status: target.status === "ok" ? "passed" : "failed",
|
|
2908
|
+
})),
|
|
2909
|
+
lintStatus: "unavailable",
|
|
2910
|
+
integrationFacts,
|
|
2911
|
+
reviewApproval: {
|
|
2912
|
+
typedVerdict,
|
|
2913
|
+
legacyVerdict: null,
|
|
2914
|
+
match: true,
|
|
2915
|
+
},
|
|
2916
|
+
cumulativeDiff: {
|
|
2917
|
+
cumulativeDigest: (typeof context.verificationTrace === "object" &&
|
|
2918
|
+
context.verificationTrace !== null &&
|
|
2919
|
+
"schemaId" in context.verificationTrace
|
|
2920
|
+
? deterministicSha256({ verificationTrace: context.verificationTrace })
|
|
2921
|
+
: deterministicSha256({})),
|
|
2922
|
+
empty: false,
|
|
2923
|
+
},
|
|
2924
|
+
notRun: { browser: "not-run", visual: "not-run" },
|
|
2925
|
+
pendingRealIntegration: integrationFacts !== "real-api",
|
|
2926
|
+
});
|
|
2927
|
+
const rendered = renderFrontendCloseout(facts);
|
|
2928
|
+
await writeDagRunJsonArtifact(meta.runDir, "contracts/frontend-closeout-facts.json", facts);
|
|
2929
|
+
// A+B (AC-010): materialize the deterministic frontend-test handoff.
|
|
2930
|
+
// browser/visual/runtime-a11y are always `not-run` and the handoff is
|
|
2931
|
+
// always `deferred-to-frontend-test`, so it never blocks implementation
|
|
2932
|
+
// and can never be rewritten into a passed result.
|
|
2933
|
+
const handoffTaskId = meta.spec.sourceBinding?.taskId ?? input.task.id;
|
|
2934
|
+
const sourceDigest = meta.spec.sourceBinding
|
|
2935
|
+
? createHash("sha256")
|
|
2936
|
+
.update(JSON.stringify({
|
|
2937
|
+
taskId: meta.spec.sourceBinding.taskId,
|
|
2938
|
+
sources: meta.spec.sourceBinding.sources,
|
|
2939
|
+
}))
|
|
2940
|
+
.digest("hex")
|
|
2941
|
+
: deterministicSha256({});
|
|
2942
|
+
const handoff = buildFrontendTestHandoff({
|
|
2943
|
+
taskId: handoffTaskId,
|
|
2944
|
+
sourceDigest,
|
|
2945
|
+
candidateHash: facts.cumulativeDiff.cumulativeDigest,
|
|
2946
|
+
});
|
|
2947
|
+
await writeDagRunJsonArtifact(meta.runDir, "contracts/frontend-test-handoff.json", handoff);
|
|
2948
|
+
await writeDagNodeTextArtifact(meta.runDir, input.task.id, "frontend-closeout.md", rendered);
|
|
2114
2949
|
return {
|
|
2115
2950
|
ok: true,
|
|
2116
|
-
stdout:
|
|
2951
|
+
stdout: `Frontend closeout rendered\n${rendered.split("\n").slice(0, 8).join("\n")}`,
|
|
2117
2952
|
stderr: "",
|
|
2118
2953
|
failureCategory: "success",
|
|
2119
2954
|
durationMs: Date.now() - started,
|
|
2120
|
-
...{ commandResults },
|
|
2121
2955
|
};
|
|
2122
2956
|
}
|
|
2123
2957
|
catch (error) {
|
|
@@ -2127,7 +2961,6 @@ async function executeFrontendVerificationBundle(input, meta) {
|
|
|
2127
2961
|
stderr: error instanceof Error ? error.message : String(error),
|
|
2128
2962
|
failureCategory: "invalid-output",
|
|
2129
2963
|
durationMs: Date.now() - started,
|
|
2130
|
-
...{ commandResults },
|
|
2131
2964
|
};
|
|
2132
2965
|
}
|
|
2133
2966
|
}
|
|
@@ -2452,68 +3285,6 @@ async function executeFrontendTestReports(input, meta) {
|
|
|
2452
3285
|
};
|
|
2453
3286
|
}
|
|
2454
3287
|
}
|
|
2455
|
-
async function executeFrontendLintBaseline(input, meta) {
|
|
2456
|
-
const started = Date.now();
|
|
2457
|
-
const shell = input.task.shell;
|
|
2458
|
-
const baseline = shell.frontendLintBaseline;
|
|
2459
|
-
const cwd = resolveShellCwd(input.cwd, shell.cwd);
|
|
2460
|
-
let beforeStatus;
|
|
2461
|
-
try {
|
|
2462
|
-
beforeStatus = await readGitStatusPorcelain(input.cwd);
|
|
2463
|
-
}
|
|
2464
|
-
catch {
|
|
2465
|
-
beforeStatus = undefined;
|
|
2466
|
-
}
|
|
2467
|
-
const results = [];
|
|
2468
|
-
for (const command of baseline.lintCommands) {
|
|
2469
|
-
const commandNumber = results.length + 1;
|
|
2470
|
-
results.push(await executeShellCommand({
|
|
2471
|
-
command,
|
|
2472
|
-
cwd,
|
|
2473
|
-
timeoutMs: shell.timeoutMs ?? DEFAULT_SHELL_TIMEOUT_MS,
|
|
2474
|
-
envAllowlist: shell.envAllowlist,
|
|
2475
|
-
dagRunMeta: { runDir: meta.runDir, runId: meta.runId },
|
|
2476
|
-
outputArtifacts: {
|
|
2477
|
-
stdoutPath: path.join(meta.runDir, input.task.id, "commands", `${commandNumber}.stdout.txt`),
|
|
2478
|
-
stderrPath: path.join(meta.runDir, input.task.id, "commands", `${commandNumber}.stderr.txt`),
|
|
2479
|
-
},
|
|
2480
|
-
}));
|
|
2481
|
-
}
|
|
2482
|
-
let afterStatus;
|
|
2483
|
-
try {
|
|
2484
|
-
afterStatus = await readGitStatusPorcelain(input.cwd);
|
|
2485
|
-
}
|
|
2486
|
-
catch {
|
|
2487
|
-
afterStatus = undefined;
|
|
2488
|
-
}
|
|
2489
|
-
try {
|
|
2490
|
-
const materialized = await materializeFrontendLintBaseline({
|
|
2491
|
-
runDir: meta.runDir,
|
|
2492
|
-
workspaceRoot: input.cwd,
|
|
2493
|
-
commands: baseline.lintCommands,
|
|
2494
|
-
results,
|
|
2495
|
-
worktreeChanged: beforeStatus === undefined ||
|
|
2496
|
-
afterStatus === undefined ||
|
|
2497
|
-
beforeStatus !== afterStatus,
|
|
2498
|
-
});
|
|
2499
|
-
return {
|
|
2500
|
-
ok: true,
|
|
2501
|
-
stdout: `Frontend lint baseline: ${materialized.artifact.status}\nArtifact: ${materialized.ref.path}\nDiagnostics: ${materialized.artifact.diagnostics.length}`,
|
|
2502
|
-
stderr: materialized.artifact.reason ?? "",
|
|
2503
|
-
failureCategory: "success",
|
|
2504
|
-
durationMs: Date.now() - started,
|
|
2505
|
-
};
|
|
2506
|
-
}
|
|
2507
|
-
catch (error) {
|
|
2508
|
-
return {
|
|
2509
|
-
ok: false,
|
|
2510
|
-
stdout: "",
|
|
2511
|
-
stderr: error instanceof Error ? error.message : String(error),
|
|
2512
|
-
failureCategory: "invalid-output",
|
|
2513
|
-
durationMs: Date.now() - started,
|
|
2514
|
-
};
|
|
2515
|
-
}
|
|
2516
|
-
}
|
|
2517
3288
|
async function writeShellPresetProcessReceipt(input) {
|
|
2518
3289
|
await writeDagNodeJsonArtifact(input.runDir, input.nodeId, "process-receipt.json", {
|
|
2519
3290
|
schemaVersion: 1,
|
|
@@ -2766,36 +3537,11 @@ async function executeDagShellNodeInner(input, meta) {
|
|
|
2766
3537
|
});
|
|
2767
3538
|
}
|
|
2768
3539
|
}
|
|
2769
|
-
if (shell?.
|
|
2770
|
-
|
|
2771
|
-
try {
|
|
2772
|
-
const result = await runFrontendPrewriteGate({
|
|
2773
|
-
runDir: meta.runDir,
|
|
2774
|
-
config: shell.frontendPrewriteGate,
|
|
2775
|
-
sourceBinding: meta.spec.sourceBinding,
|
|
2776
|
-
workspaceRoot: input.cwd,
|
|
2777
|
-
repoRoot: input.cwd,
|
|
2778
|
-
});
|
|
2779
|
-
return {
|
|
2780
|
-
ok: true,
|
|
2781
|
-
stdout: formatFrontendPrewriteGateStdout(result),
|
|
2782
|
-
stderr: "",
|
|
2783
|
-
failureCategory: "success",
|
|
2784
|
-
durationMs: Date.now() - started,
|
|
2785
|
-
};
|
|
2786
|
-
}
|
|
2787
|
-
catch (error) {
|
|
2788
|
-
return {
|
|
2789
|
-
ok: false,
|
|
2790
|
-
stdout: "",
|
|
2791
|
-
stderr: error instanceof Error ? error.message : String(error),
|
|
2792
|
-
failureCategory: "invalid-output",
|
|
2793
|
-
durationMs: Date.now() - started,
|
|
2794
|
-
};
|
|
2795
|
-
}
|
|
3540
|
+
if (shell?.frontendDesignPolicy) {
|
|
3541
|
+
return executeFrontendDesignPolicy(input, meta);
|
|
2796
3542
|
}
|
|
2797
|
-
if (shell?.
|
|
2798
|
-
return
|
|
3543
|
+
if (shell?.frontendWriterAdmission) {
|
|
3544
|
+
return executeFrontendWriterAdmission(input, meta);
|
|
2799
3545
|
}
|
|
2800
3546
|
if (shell?.frontendVerificationBundle) {
|
|
2801
3547
|
return executeFrontendVerificationBundle(input, meta);
|
|
@@ -2826,6 +3572,12 @@ async function executeDagShellNodeInner(input, meta) {
|
|
|
2826
3572
|
};
|
|
2827
3573
|
}
|
|
2828
3574
|
}
|
|
3575
|
+
if (shell?.frontendContractImport) {
|
|
3576
|
+
return executeFrontendContractImport(input, meta);
|
|
3577
|
+
}
|
|
3578
|
+
if (shell?.frontendCloseout) {
|
|
3579
|
+
return executeFrontendCloseout(input, meta);
|
|
3580
|
+
}
|
|
2829
3581
|
if (shell?.frontendTestCaseChecklist) {
|
|
2830
3582
|
return executeFrontendTestCaseChecklist(input, meta);
|
|
2831
3583
|
}
|
|
@@ -3048,53 +3800,23 @@ async function executeDagShellNodeInner(input, meta) {
|
|
|
3048
3800
|
}
|
|
3049
3801
|
if (shell?.commands?.length === 1 &&
|
|
3050
3802
|
shell.commands[0] === "frontend-failure-assess-gate") {
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
stdout: formatFrontendFailureAssessStdout(result),
|
|
3059
|
-
stderr: "",
|
|
3060
|
-
failureCategory: "success",
|
|
3061
|
-
durationMs: Date.now() - started,
|
|
3062
|
-
};
|
|
3063
|
-
}
|
|
3064
|
-
catch (error) {
|
|
3065
|
-
return {
|
|
3066
|
-
ok: false,
|
|
3067
|
-
stdout: "",
|
|
3068
|
-
stderr: error instanceof Error ? error.message : String(error),
|
|
3069
|
-
failureCategory: "invalid-output",
|
|
3070
|
-
durationMs: Date.now() - started,
|
|
3071
|
-
};
|
|
3072
|
-
}
|
|
3803
|
+
return {
|
|
3804
|
+
ok: false,
|
|
3805
|
+
stdout: "",
|
|
3806
|
+
stderr: "frontend-failure-assess-gate legacy command removed in M8: verify failure is terminal and materializes failure ownership facts in the verification bundle itself",
|
|
3807
|
+
failureCategory: "invalid-output",
|
|
3808
|
+
durationMs: 0,
|
|
3809
|
+
};
|
|
3073
3810
|
}
|
|
3074
3811
|
if (shell?.commands?.length === 1 &&
|
|
3075
3812
|
shell.commands[0] === "frontend-repair-contract-gate") {
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
stdout: formatFrontendRepairContractStdout(result.assessment),
|
|
3084
|
-
stderr: "",
|
|
3085
|
-
failureCategory: "success",
|
|
3086
|
-
durationMs: Date.now() - started,
|
|
3087
|
-
};
|
|
3088
|
-
}
|
|
3089
|
-
catch (error) {
|
|
3090
|
-
return {
|
|
3091
|
-
ok: false,
|
|
3092
|
-
stdout: "",
|
|
3093
|
-
stderr: error instanceof Error ? error.message : String(error),
|
|
3094
|
-
failureCategory: "invalid-output",
|
|
3095
|
-
durationMs: Date.now() - started,
|
|
3096
|
-
};
|
|
3097
|
-
}
|
|
3813
|
+
return {
|
|
3814
|
+
ok: false,
|
|
3815
|
+
stdout: "",
|
|
3816
|
+
stderr: "frontend-repair-contract-gate legacy command removed in M8: no same-run repair branch exists in the new topology",
|
|
3817
|
+
failureCategory: "invalid-output",
|
|
3818
|
+
durationMs: 0,
|
|
3819
|
+
};
|
|
3098
3820
|
}
|
|
3099
3821
|
if (shell?.projectGovernanceGate) {
|
|
3100
3822
|
const started = Date.now();
|
|
@@ -3421,6 +4143,39 @@ async function executeDagShellNodeInner(input, meta) {
|
|
|
3421
4143
|
...{ commandResults },
|
|
3422
4144
|
};
|
|
3423
4145
|
}
|
|
4146
|
+
/**
|
|
4147
|
+
* Enumerate the workspace's concrete file paths for glob writeSet expansion.
|
|
4148
|
+
*
|
|
4149
|
+
* Uses `git ls-files -co --exclude-standard` (tracked + untracked, excluding
|
|
4150
|
+
* gitignored) so the expanded writeSet reflects real files the writer can
|
|
4151
|
+
* touch. Falls back to [] when the workspace is not a git repository or git
|
|
4152
|
+
* fails — in that case glob entries fail closed as non-concrete paths.
|
|
4153
|
+
*/
|
|
4154
|
+
async function collectWorkspaceFiles(workspaceRoot) {
|
|
4155
|
+
try {
|
|
4156
|
+
const files = await new Promise((resolve, reject) => {
|
|
4157
|
+
const child = spawn("git", ["ls-files", "-co", "--exclude-standard", "-z"], { cwd: workspaceRoot, stdio: ["ignore", "pipe", "ignore"] });
|
|
4158
|
+
const chunks = [];
|
|
4159
|
+
child.stdout.on("data", (chunk) => chunks.push(chunk));
|
|
4160
|
+
child.on("error", reject);
|
|
4161
|
+
child.on("close", (code) => {
|
|
4162
|
+
if (code === 0) {
|
|
4163
|
+
resolve(Buffer.concat(chunks)
|
|
4164
|
+
.toString("utf8")
|
|
4165
|
+
.split("\0")
|
|
4166
|
+
.filter(Boolean));
|
|
4167
|
+
}
|
|
4168
|
+
else {
|
|
4169
|
+
reject(new Error(`git ls-files exited ${String(code)}`));
|
|
4170
|
+
}
|
|
4171
|
+
});
|
|
4172
|
+
});
|
|
4173
|
+
return files.map((file) => file.replace(/\\/g, "/")).sort();
|
|
4174
|
+
}
|
|
4175
|
+
catch {
|
|
4176
|
+
return [];
|
|
4177
|
+
}
|
|
4178
|
+
}
|
|
3424
4179
|
export async function executeDagShellNode(input, meta) {
|
|
3425
4180
|
const handler = namedShellHandler(input.task.shell);
|
|
3426
4181
|
const result = await executeDagShellNodeInner(input, meta);
|