@tea-agent/loop-agent 0.1.0-fe-test.5 → 0.1.0-fe-test.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +1 -1
- package/CHANGELOG.md +441 -2525
- package/README.md +19 -12
- package/dist/adapters/loop-agent.js +34 -0
- package/dist/application/dag/args.js +8 -0
- package/dist/application/dag/run-dag.js +5 -0
- package/dist/application/evaluation/budget.js +40 -1
- package/dist/application/evaluation/corpus-hash.js +10 -15
- package/dist/application/evaluation/corpus.js +2 -1
- package/dist/application/evaluation/frontend-browser-acceptance.js +77 -0
- package/dist/application/evaluation/frontend-corpus-browser-acceptance.js +175 -0
- package/dist/application/evaluation/frontend-gateway-evidence.js +226 -0
- package/dist/application/evaluation/frontend-pair-registration.js +143 -0
- package/dist/application/evaluation/frontend-paired-summary.js +150 -0
- package/dist/application/evaluation/frontend-run-observation.js +144 -0
- package/dist/application/evaluation/frontend-shared-evidence.js +105 -0
- package/dist/application/evaluation/types.js +45 -12
- package/dist/application/task-lifecycle/advance.js +64 -15
- package/dist/application/task-lifecycle/observe.js +69 -30
- package/dist/application/task-lifecycle/plan-transitions.js +5 -4
- package/dist/build-stamp.json +3 -3
- package/dist/cli/command-definitions.js +18 -5
- package/dist/cli/program.js +8 -5
- package/dist/cli/update/init-surface-notifier.js +2 -0
- package/dist/cli/update/policy.js +2 -0
- package/dist/commands/client-recovery.js +20 -55
- package/dist/commands/cursor-prompt.js +2 -0
- package/dist/commands/dag-approve.js +2 -0
- package/dist/commands/dag-final-verification.js +2 -0
- package/dist/commands/dag-init-hybrid.js +2 -0
- package/dist/commands/dag-reconcile-tasks.js +2 -0
- package/dist/commands/dag-reject.js +2 -0
- package/dist/commands/dag-report.js +2 -0
- package/dist/commands/dag-rerun.js +2 -0
- package/dist/commands/dag-resume.js +2 -0
- package/dist/commands/dag-workflow-compile.js +2 -0
- package/dist/commands/dag-workflow-plan.js +2 -0
- package/dist/commands/dag-workflow-validate.js +2 -0
- package/dist/commands/delegate.js +2 -0
- package/dist/commands/examples.js +2 -0
- package/dist/commands/import-prd.js +2 -0
- package/dist/commands/init-legacy-audit.js +330 -0
- package/dist/commands/init-model-catalog.js +2 -0
- package/dist/commands/init-upgrade.js +644 -104
- package/dist/commands/init.js +700 -338
- package/dist/commands/instructions.js +2 -0
- package/dist/commands/knowledge.js +2 -0
- package/dist/commands/loop-benchmark.js +2 -0
- package/dist/commands/operator-guide.js +99 -0
- package/dist/commands/operator.js +16 -3
- package/dist/commands/pi-prompt.js +2 -0
- package/dist/commands/pi-reuse-benchmark.js +2 -0
- package/dist/commands/promote-run.js +2 -0
- package/dist/commands/stats.js +1 -1
- package/dist/commands/study-init.js +2 -0
- package/dist/commands/task-advance.js +32 -0
- package/dist/commands/task-source-prepare.js +18 -2
- package/dist/commands/worktree-create.js +2 -0
- package/dist/commands/worktree-remove.js +2 -0
- package/dist/executors/dag-pi/guards.js +4 -0
- package/dist/executors/dag-pi/model-config.js +30 -0
- package/dist/executors/dag-pi/plan/fact-adoption.js +55 -0
- package/dist/executors/dag-pi/plan/facts.js +180 -0
- package/dist/executors/dag-pi/plan/finalize-tools.js +259 -0
- package/dist/executors/dag-pi/plan/ledger-contract.js +55 -0
- package/dist/executors/dag-pi/plan/record-tools.js +861 -0
- package/dist/executors/dag-pi/plan/schema.js +129 -0
- package/dist/executors/dag-pi/plan/tool-helpers.js +16 -0
- package/dist/executors/dag-pi/sessions/index.js +6 -0
- package/dist/executors/dag-pi/sessions/plan-batches.js +280 -0
- package/dist/executors/dag-pi/sessions/plan-prompts.js +367 -0
- package/dist/executors/dag-pi/sessions/scout-parallel.js +197 -0
- package/dist/executors/dag-pi/sessions/segmented-plan.js +1184 -0
- package/dist/executors/dag-pi/sessions/writer-evidence.js +60 -0
- package/dist/executors/dag-pi/tools/contract-tools.js +515 -0
- package/dist/executors/dag-pi/tools/design-terminal-tools.js +159 -0
- package/dist/executors/dag-pi/tools/plan-decision-tools.js +529 -0
- package/dist/executors/dag-pi/tools/review-terminal-tools.js +159 -0
- package/dist/executors/dag-pi/tools/scout-evidence-tools.js +270 -0
- package/dist/executors/dag-pi-executor.js +1516 -3181
- package/dist/executors/pi-executor.js +112 -4
- package/dist/executors/pi-sdk-executor.js +258 -44
- package/dist/executors/pi-writer-tool-policy.js +60 -4
- package/dist/executors/playwright-cli-launcher.js +31 -45
- package/dist/executors/shell-executor.js +313 -48
- package/dist/executors/shell-presets.js +1 -1
- package/dist/executors/shell-verification.js +3 -0
- package/dist/executors/shell-write-guard.js +77 -102
- package/dist/governance/exec-plans.js +16 -4
- package/dist/governance/harness.js +2 -7
- package/dist/governance/manifest-types.js +28 -9
- package/dist/governance/project-capability-scanner.js +263 -0
- package/dist/governance/project-config.js +96 -0
- package/dist/governance/resource-catalog.js +151 -0
- package/dist/infrastructure/console/app-data.js +12 -2
- package/dist/infrastructure/console/operation-store.js +48 -14
- package/dist/infrastructure/evaluation/corpus-store.js +37 -12
- package/dist/shared/artifacts-core.js +2 -0
- package/dist/shared/backend-dogfood-preflight.js +47 -0
- package/dist/shared/dag-failure-category.js +9 -0
- package/dist/shared/file-identity.js +23 -0
- package/dist/shared/frontend-execution-policy.js +23 -0
- package/dist/shared/git-progress.js +2 -0
- package/dist/shared/git-workspace-status.js +482 -0
- package/dist/shared/one-shot-prompt-args.js +2 -0
- package/dist/shared/operator/capabilities.js +185 -0
- package/dist/shared/package-metadata.js +29 -11
- package/dist/shared/path-safety.js +2 -2
- package/dist/shared/pi-context-pressure/extension.js +49 -16
- package/dist/shared/pi-context-pressure/index.js +1 -0
- package/dist/shared/pi-context-pressure/sift-bridge.js +1 -1
- package/dist/shared/pi-context-pressure/telemetry.js +4 -0
- package/dist/shared/pi-context-pressure/tool-result-pruner.js +98 -0
- package/dist/shared/pi-provider-recovery.js +182 -0
- package/dist/shared/pi-retry-settings.js +40 -0
- package/dist/shared/reference-context.js +2 -0
- package/dist/shared/update/npm-client.js +49 -1
- package/dist/shared/wizard-local-telemetry.js +51 -0
- package/dist/task/config-types.js +51 -2
- package/dist/task/contract/apply.js +36 -2
- package/dist/task/contract/project.js +22 -0
- package/dist/task/contract/recover.js +6 -0
- package/dist/task/contract/schema.js +12 -0
- package/dist/task/frontend-preflight.js +1 -1
- package/dist/task/source-prepare/artifact-meta.js +9 -2
- package/dist/task/source-prepare/build-draft.js +61 -0
- package/dist/task/source-prepare/fragment-inventory.js +4 -1
- package/dist/task/source-prepare/ledger-reconciliation.js +2 -2
- package/dist/task/source-prepare/ledger-review.js +6 -9
- package/dist/task/source-prepare/parse-intent.js +165 -14
- package/dist/task/source-prepare/path-policy.js +17 -7
- package/dist/task/source-prepare/prepare.js +6 -1
- package/dist/task/source-prepare/semantic-intake.js +33 -28
- package/dist/task/source-prepare/source-execution.js +65 -0
- package/dist/task/source-prepare/source-fidelity-pi.js +49 -17
- package/dist/task/source-prepare/source-provider-budget.js +290 -0
- package/dist/task/source-references.js +48 -23
- package/dist/task/task-demand-routing.js +5 -2
- package/dist/worker/cli.js +3 -5
- package/dist/worker/console/chat/assistant-content.js +5 -13
- package/dist/worker/console/chat/browser-automation.js +937 -0
- package/dist/worker/console/chat/browser-content.js +74 -0
- package/dist/worker/console/chat/browser-diagnostics.js +250 -0
- package/dist/worker/console/chat/browser-evaluation.js +58 -0
- package/dist/worker/console/chat/browser-operation-queue.js +19 -0
- package/dist/worker/console/chat/browser-pick.js +113 -0
- package/dist/worker/console/chat/browser-policy.js +113 -0
- package/dist/worker/console/chat/browser-routes.js +329 -0
- package/dist/worker/console/chat/browser-screenshot-result.js +47 -0
- package/dist/worker/console/chat/browser-storage.js +89 -0
- package/dist/worker/console/chat/chat-event-store.js +73 -18
- package/dist/worker/console/chat/context-insights.js +788 -0
- package/dist/worker/console/chat/conversation-nodes.js +383 -0
- package/dist/worker/console/chat/db-connections.js +854 -0
- package/dist/worker/console/chat/explore-tools.js +18 -2
- package/dist/worker/console/chat/pet/pet-affinity.js +169 -0
- package/dist/worker/console/chat/pet/pet-persist.js +109 -0
- package/dist/worker/console/chat/pet/pet-registry.js +142 -0
- package/dist/worker/console/chat/pet/pet-remarks.js +48 -0
- package/dist/worker/console/chat/pet/pet-routes.js +125 -0
- package/dist/worker/console/chat/pet/pet-service.js +262 -0
- package/dist/worker/console/chat/pet/pet-state.js +99 -0
- package/dist/worker/console/chat/pi-mode-loop-isolation.js +170 -0
- package/dist/worker/console/chat/pi-runtime/custom-tools/ask-user-question.js +44 -0
- package/dist/worker/console/chat/pi-runtime/custom-tools/browser-tools.js +135 -0
- package/dist/worker/console/chat/pi-runtime/custom-tools/explore-tools.js +202 -0
- package/dist/worker/console/chat/pi-runtime/custom-tools/goal-tools.js +79 -0
- package/dist/worker/console/chat/pi-runtime/custom-tools/operator-tools.js +94 -0
- package/dist/worker/console/chat/pi-runtime/custom-tools/scheduled-goal-tools.js +22 -0
- package/dist/worker/console/chat/pi-runtime/custom-tools/sql-tools.js +670 -0
- package/dist/worker/console/chat/pi-runtime/custom-tools/todo-write.js +38 -0
- package/dist/worker/console/chat/pi-runtime/inspection-types.js +28 -0
- package/dist/worker/console/chat/pi-runtime/inspection.js +439 -0
- package/dist/worker/console/chat/pi-runtime/progressive-tools.js +195 -0
- package/dist/worker/console/chat/pi-runtime/sdk-bindings.js +153 -0
- package/dist/worker/console/chat/pi-runtime/sdk-session.js +5 -0
- package/dist/worker/console/chat/pi-runtime.js +793 -1230
- package/dist/worker/console/chat/provider-error.js +0 -12
- package/dist/worker/console/chat/repo-browser.js +132 -6
- package/dist/worker/console/chat/repo-preview-kind.js +155 -0
- package/dist/worker/console/chat/resource-loader.js +4 -1
- package/dist/worker/console/chat/routes.js +861 -148
- package/dist/worker/console/chat/scheduled-goal-booking.js +59 -0
- package/dist/worker/console/chat/scheduled-goal-delivery.js +27 -0
- package/dist/worker/console/chat/scheduled-goal-request.js +198 -0
- package/dist/worker/console/chat/scm-routes.js +217 -0
- package/dist/worker/console/chat/scm-service.js +283 -0
- package/dist/worker/console/chat/scm-tools.js +111 -0
- package/dist/worker/console/chat/sdd-data-alignment.js +85 -41
- package/dist/worker/console/chat/session-catalog.js +32 -0
- package/dist/worker/console/chat/session-mode-view.js +49 -0
- package/dist/worker/console/chat/session-mode.js +224 -0
- package/dist/worker/console/chat/session-store.js +232 -32
- package/dist/worker/console/chat/shortcuts.js +13 -0
- package/dist/worker/console/chat/subagents/agent-tool.js +62 -0
- package/dist/worker/console/chat/subagents/explore-agent.js +169 -0
- package/dist/worker/console/chat/subagents/index.js +5 -0
- package/dist/worker/console/chat/subagents/orchestrator.js +273 -0
- package/dist/worker/console/chat/subagents/tool-policy.js +53 -0
- package/dist/worker/console/chat/subagents/types.js +13 -0
- package/dist/worker/console/chat/terminal-routes.js +216 -0
- package/dist/worker/console/chat/terminal-sessions.js +348 -0
- package/dist/worker/console/chat/terminal-tools.js +211 -0
- package/dist/worker/console/chat/timeline-message-order.js +22 -0
- package/dist/worker/console/chat/tool-preview.js +136 -0
- package/dist/worker/console/chat/tools.js +69 -1
- package/dist/worker/console/chat/turn-order.js +13 -0
- package/dist/worker/console/chat/turn-process.js +210 -36
- package/dist/worker/console/chat/user-turn-outline.js +19 -0
- package/dist/worker/console/console-shutdown.js +34 -0
- package/dist/worker/console/console-update-and-init.js +1 -19
- package/dist/worker/console/console-update-runtime.js +7 -22
- package/dist/worker/console/dag-confirmation.js +3 -0
- package/dist/worker/console/dag-execution-receipt.js +3 -0
- package/dist/worker/console/interview/tools.js +1 -0
- package/dist/worker/console/operator-actions.js +95 -4
- package/dist/worker/console/operator-user-error.js +28 -1
- package/dist/worker/console/pi-readiness.js +4 -4
- package/dist/worker/console/prd-intake-bridge.js +47 -1
- package/dist/worker/console/recovery-cta.js +14 -14
- package/dist/worker/console/routes.js +13 -0
- package/dist/worker/console/scheduled-goal-host.js +98 -0
- package/dist/worker/console/scheduled-goal-operation-adapter.js +127 -0
- package/dist/worker/console/server.js +33 -31
- package/dist/worker/console/static/app-icon.svg +39 -0
- package/dist/worker/console/static/assets/{abnfDiagram-N423BO3Z-BZogYNl1.js → abnfDiagram-N423BO3Z-DASc69AM.js} +1 -1
- package/dist/worker/console/static/assets/{arc-DcJTLe2v.js → arc-h09p-LAc.js} +1 -1
- package/dist/worker/console/static/assets/{architectureDiagram-T3A2C74G-B39EQQ9n.js → architectureDiagram-T3A2C74G-CZ3dtLkh.js} +1 -1
- package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-CitCGV56.js → blockDiagram-VBNYF7ZC-DMrRhMXG.js} +1 -1
- package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-rvWuOHLG.js → c4Diagram-5PPSVZJV-DQxisHV6.js} +1 -1
- package/dist/worker/console/static/assets/channel-D1zgKZfg.js +1 -0
- package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-DGXplIJs.js → chunk-2GRJ4B5K-CefVN9zh.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-ur9OqjPn.js → chunk-2Q5K7J3B-DmR1Koq2.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5RXB4S5H-D1KqU_Vi.js → chunk-5RXB4S5H-NlzrSW7L.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5VM5RSS4-BlVZrbtM.js → chunk-5VM5RSS4-DfelJv-0.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-BAzz3nQy.js → chunk-6Q2QTUOP-BK6RFy58.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-GF5L2VYU-CP_nYuCV.js → chunk-GF5L2VYU-BAeh9lz4.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-JWPE2WC7-CWvKQ80X.js → chunk-JWPE2WC7-ChPS5WzG.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-KBJHAD2P-CyUki8wp.js → chunk-KBJHAD2P-BoVe5IM6.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-RYQCIY6F-5NYzNKfY.js → chunk-RYQCIY6F-C4q_0Lw9.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-XXDRQBXY-DHdUgjS-.js → chunk-XXDRQBXY-Bb9TvjeY.js} +1 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-CXNNsY2M.js +1 -0
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-CXNNsY2M.js +1 -0
- package/dist/worker/console/static/assets/{cose-bilkent-JH36ORCC-ANQ5g_t6.js → cose-bilkent-JH36ORCC-DmNnL8Ff.js} +1 -1
- package/dist/worker/console/static/assets/{cynefin-VYW2F7L2-CruT_4-0.js → cynefin-VYW2F7L2-Contvx58.js} +1 -1
- package/dist/worker/console/static/assets/{cynefinDiagram-MW4NZA55-rbFo77ID.js → cynefinDiagram-MW4NZA55-Cigq7cjk.js} +1 -1
- package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-asstxBQs.js → dagre-VZM6K2ZE-dEbC0nxb.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-7IWD3JNH-DzTyBZwI.js → diagram-7IWD3JNH-CzIztESV.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-gw8ccH3B.js → diagram-B4RE2ZJO-Bo14zbaY.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-LBJQPF4R-B8RpZzOf.js → diagram-LBJQPF4R-C4xUyil6.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-Q27KOJAE-B1zJkCS9.js → diagram-Q27KOJAE-CaBY_uYa.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-UB23O5K3-B6JLWZmO.js → diagram-UB23O5K3-ClUXUeiu.js} +1 -1
- package/dist/worker/console/static/assets/{ebnfDiagram-BXEA7PRR-q2iZP-Ps.js → ebnfDiagram-BXEA7PRR-BbGCgjC6.js} +1 -1
- package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-B3dbbktQ.js → erDiagram-JOGREHBK-Dr-AcwSl.js} +1 -1
- package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-C-zc6-kB.js → flowDiagram-UKHOOZJN-BG8Gcfyc.js} +1 -1
- package/dist/worker/console/static/assets/{ganttDiagram-PKOTCBZU-BSolnot9.js → ganttDiagram-PKOTCBZU-CFVaPs5r.js} +1 -1
- package/dist/worker/console/static/assets/{gitGraphDiagram-DS77QQ5N-Bo8jGxTk.js → gitGraphDiagram-DS77QQ5N-ChJ8pm-O.js} +1 -1
- package/dist/worker/console/static/assets/index-B_5GhVIO.js +488 -0
- package/dist/worker/console/static/assets/index-C7YMBluX.css +1 -0
- package/dist/worker/console/static/assets/{infoDiagram-6WML65LV-DQaZqJOH.js → infoDiagram-6WML65LV-C5J9-uCZ.js} +1 -1
- package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-DsdX1WnE.js → ishikawaDiagram-WSZJBQD7-BcfjqzDv.js} +1 -1
- package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-CP5EYDZL.js → journeyDiagram-NVQOT4AX-BzzCO-rD.js} +1 -1
- package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-DAm14Dr8.js → kanban-definition-27J2QSJJ-NCHUZ46h.js} +1 -1
- package/dist/worker/console/static/assets/{linear-gZECoLc5.js → linear-BKZlWCUU.js} +1 -1
- package/dist/worker/console/static/assets/{mermaid.core-BRJNIM6p.js → mermaid.core-DbTaQjFE.js} +5 -5
- package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-Cja3kLkR.js → mindmap-definition-FAOFIHXS-CroYl5xQ.js} +1 -1
- package/dist/worker/console/static/assets/{pegDiagram-VL7TDLO6-22ZGFisL.js → pegDiagram-VL7TDLO6-DgMBx-9k.js} +1 -1
- package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-BXin0Y1o.js → pieDiagram-7S7Q4E2Y-CyWDmbq1.js} +1 -1
- package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-Cw6T69Yt.js → quadrantDiagram-CIZ2JOQS-BgGEOqSP.js} +1 -1
- package/dist/worker/console/static/assets/{railroadDiagram-AXF67PYL-C1-gTieN.js → railroadDiagram-AXF67PYL-BMZ7oeeV.js} +1 -1
- package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP--H5N2iI1.js → requirementDiagram-LRYGKXZP-DxqyGhcc.js} +1 -1
- package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-CgWAPeRz.js → sankeyDiagram-W5VNT64P-DnSvNCG8.js} +1 -1
- package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-CrKqzGvt.js → sequenceDiagram-SI44F4Z6-BiZh6f-R.js} +1 -1
- package/dist/worker/console/static/assets/{sizeCapture-X5ZJPWSS-BB3wG06K.js → sizeCapture-X5ZJPWSS-BKXSI8WB.js} +1 -1
- package/dist/worker/console/static/assets/{stateDiagram-OKZ733FA-DjsGgdgY.js → stateDiagram-OKZ733FA-CfSgoYFm.js} +1 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-DgHi3vjb.js +1 -0
- package/dist/worker/console/static/assets/{swimlanes-SLNWSIFB-DYKEbvAR.js → swimlanes-SLNWSIFB-CyGADcHe.js} +2 -2
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-Bgvdt1Y0.js +8 -0
- package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-eQOb5k9Y.js → timeline-definition-Z64GVDOM-HmPaSPOK.js} +1 -1
- package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-B2-l9FIu.js → vennDiagram-T6HMQDX7-VA2VBbez.js} +1 -1
- package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-BX2Cda3l.js → wardleyDiagram-T6FBY63Y-BxjiBPZa.js} +1 -1
- package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-D9S892ph.js → xychartDiagram-ELKLHX3M--hUY-qFj.js} +1 -1
- package/dist/worker/console/static/index.html +5 -2
- package/dist/worker/console/static/manifest.webmanifest +19 -0
- package/dist/worker/console/static/pets/ember/pet.json +167 -0
- package/dist/worker/console/static/pets/ember/spritesheet.png +0 -0
- package/dist/worker/console/static-src/app/console-types.js +9 -1
- package/dist/worker/console/static-src/chat-view-types.js +1 -1
- package/dist/worker/console/static-src/operator-chat/active-turn-tail.js +10 -0
- package/dist/worker/console/static-src/operator-chat/animation-frame-batcher.js +38 -0
- package/dist/worker/console/static-src/operator-chat/chat-link.js +114 -0
- package/dist/worker/console/static-src/operator-chat/chat-scroll-position.js +24 -0
- package/dist/worker/console/static-src/operator-chat/chat-sse-events.js +360 -14
- package/dist/worker/console/static-src/operator-chat/chat-stream-continuity.js +101 -0
- package/dist/worker/console/static-src/operator-chat/compaction-message.js +10 -2
- package/dist/worker/console/static-src/operator-chat/composer-session-ledger.js +192 -0
- package/dist/worker/console/static-src/operator-chat/context-insights-store.js +64 -0
- package/dist/worker/console/static-src/operator-chat/details-rail-surfaces.js +99 -0
- package/dist/worker/console/static-src/operator-chat/file-palette-nav.js +81 -0
- package/dist/worker/console/static-src/operator-chat/open-preview-in-browser.js +57 -9
- package/dist/worker/console/static-src/operator-chat/pending-user-message.js +66 -0
- package/dist/worker/console/static-src/operator-chat/process-label.js +63 -0
- package/dist/worker/console/static-src/operator-chat/slash-palette-nav.js +15 -5
- package/dist/worker/console/static-src/operator-chat/timeline-merge.js +29 -0
- package/dist/worker/console/static-src/operator-chat/tools-catalog.js +36 -8
- package/dist/worker/console/static-src/operator-chat/transcript-mode.js +21 -0
- package/dist/worker/console/static-src/operator-chat/turn-group-equality.js +16 -0
- package/dist/worker/console/static-src/operator-chat/turn-process-disclosure.js +18 -0
- package/dist/worker/console/static-src/operator-chat/turn-state-projection.js +166 -0
- package/dist/worker/console/static-src/operator-chat/turn-stream-controller.js +58 -2
- package/dist/worker/console/static-src/operator-chat/use-searchable-hidden.js +51 -0
- package/dist/worker/console/static-src/operator-chat/use-stat-dialog.js +95 -0
- package/dist/worker/console/static-src/operator-chat/useChatSessions.js +338 -93
- package/dist/worker/console/static-src/operator-chat/useChatStream.js +310 -106
- package/dist/worker/console/static-src/operator-chat/useChatThread.js +179 -75
- package/dist/worker/console/static-src/operator-chat/useComposer.js +281 -79
- package/dist/worker/console/static-src/operator-chat/useRepoBrowser.js +21 -3
- package/dist/worker/console/static-src/operator-chat/useRuntimeControls.js +36 -17
- package/dist/worker/console/static-src/operator-chat/useRuntimeSnapshot.js +18 -0
- package/dist/worker/console/static-src/operator-chat/useWorkspaceBrowserGate.js +4 -0
- package/dist/worker/console/static-src/operator-chat/user-turn-anchor-equality.js +21 -0
- package/dist/worker/console/static-src/prd-file-import.js +3 -1
- package/dist/worker/console/static-src/shell/console-update-reload.js +1 -1
- package/dist/worker/console/workspace-context.js +54 -1
- package/dist/worker/console/workspace-initialization.js +218 -0
- package/dist/worker/delivery/git-transaction.js +2 -0
- package/dist/worker/delivery/package.js +4 -1
- package/dist/worker/feature/fullstack-validate.js +2 -0
- package/dist/worker/loop-agent/loop-agent-client.js +8 -2
- package/dist/worker/materialize/harness-task-lineage.js +4 -2
- package/dist/worker/materialize/harness-task-materializer.js +4 -1
- package/dist/worker/metrics/projector.js +1 -1
- package/dist/worker/observability/event-store.js +4 -1
- package/dist/worker/observability/read-model.js +27 -3
- package/dist/worker/observe/node-context-insights.js +479 -0
- package/dist/worker/observe/node-transparency.js +103 -72
- package/dist/worker/observe/routes.js +24 -1
- package/dist/worker/observe/static/console-theme.css +178 -0
- package/dist/worker/observe/static/console-theme.js +74 -0
- package/dist/worker/observe/static/dag-inspector-humanize.js +3 -0
- package/dist/worker/observe/static/dom.js +20 -1
- package/dist/worker/observe/static/format-pool.d.ts +2 -0
- package/dist/worker/observe/static/format-pool.js +6 -0
- package/dist/worker/observe/static/format.js +7 -0
- package/dist/worker/observe/static/inspect-workspace.js +34 -7
- package/dist/worker/observe/static/inspector-submission.js +32 -0
- package/dist/worker/observe/static/kpi.js +1 -0
- package/dist/worker/observe/static/operator-chrome.css +85 -0
- package/dist/worker/observe/static/operator-chrome.js +13 -1
- package/dist/worker/observe/static/relations.js +2 -0
- package/dist/worker/observe/static/router.js +13 -0
- package/dist/worker/observe/static/run-processing.js +2 -0
- package/dist/worker/observe/static/shell-chrome.js +36 -3
- package/dist/worker/observe/static/state.js +35 -2
- package/dist/worker/observe/static/styles.css +263 -39
- package/dist/worker/observe/static/task-failure-labels.d.ts +4 -0
- package/dist/worker/observe/static/task-failure-labels.js +67 -0
- package/dist/worker/observe/static/task-history.js +12 -0
- package/dist/worker/observe/static/views/batch.js +6 -13
- package/dist/worker/observe/static/views/dag-graph.js +50 -3
- package/dist/worker/observe/static/views/dag-inspector.js +742 -268
- package/dist/worker/observe/static/views/dag-trajectory.js +3 -0
- package/dist/worker/observe/static/views/dag.d.ts +6 -0
- package/dist/worker/observe/static/views/dag.js +49 -11
- package/dist/worker/observe/static/views/dags.js +2 -0
- package/dist/worker/observe/static/views/dashboard.js +21 -12
- package/dist/worker/observe/static/views/failures.js +21 -11
- package/dist/worker/observe/static/views/feature.js +11 -29
- package/dist/worker/observe/static/views/pool.js +37 -28
- package/dist/worker/observe/static/views/run.js +48 -5
- package/dist/worker/observe/static/views/session-timeline.js +189 -240
- package/dist/worker/observe/static/views/task.js +81 -62
- package/dist/worker/outcomes/declared-artifacts.js +2 -0
- package/dist/worker/preflight.js +3 -0
- package/dist/worker/scheduler/scheduled-goal-dispatch.js +118 -0
- package/dist/worker/scheduler/scheduled-goal-evidence.js +230 -0
- package/dist/worker/scheduler/scheduled-goal-recovery.js +62 -0
- package/dist/worker/scheduler/scheduled-goal-store.js +709 -0
- package/dist/worker/scheduler/scheduled-goal-supervisor.js +132 -0
- package/dist/worker/scheduler/scheduled-goal-time.js +102 -0
- package/dist/worker/scheduler/scheduled-goal-types.js +95 -0
- package/dist/worker/task-spec/validate.js +4 -1
- package/dist/workflows/dag/backend-test-case-coverage-analysis.js +3 -1
- package/dist/workflows/dag/backend-test-layout.js +27 -7
- package/dist/workflows/dag/backend-test-markdown-workflow.js +9 -25
- package/dist/workflows/dag/backend-test-plan-protocol.js +82 -5
- package/dist/workflows/dag/backend-test-pytest-collection.js +4 -1
- package/dist/workflows/dag/budget-enforcement.js +82 -3
- package/dist/workflows/dag/checkpoint.js +686 -0
- package/dist/workflows/dag/dag-retry-schema.js +14 -0
- package/dist/workflows/dag/decision-envelope.js +2 -0
- package/dist/workflows/dag/dynamic-runtime/shared.js +2 -2
- package/dist/workflows/dag/final-verification.js +45 -10
- package/dist/workflows/dag/frontend-capacity.js +9 -0
- package/dist/workflows/dag/frontend-closeout.js +5 -1
- package/dist/workflows/dag/frontend-committed-facts.js +461 -0
- package/dist/workflows/dag/frontend-contract-facts.js +133 -0
- package/dist/workflows/dag/frontend-design-policy.js +107 -21
- package/dist/workflows/dag/frontend-durable-tools.js +225 -0
- package/dist/workflows/dag/frontend-execution-groups.js +24 -0
- package/dist/workflows/dag/frontend-implementation-contract.js +554 -26
- package/dist/workflows/dag/frontend-input-projection.js +76 -0
- package/dist/workflows/dag/frontend-plan-canary.js +103 -0
- package/dist/workflows/dag/frontend-plan-decision-contract.js +795 -0
- package/dist/workflows/dag/frontend-plan-progress.js +92 -0
- package/dist/workflows/dag/frontend-plan-recovery-policy.js +18 -0
- package/dist/workflows/dag/frontend-plan-render.js +21 -5
- package/dist/workflows/dag/frontend-provider-capability-matrix.js +8 -61
- package/dist/workflows/dag/frontend-recovery-controller.js +7 -7
- package/dist/workflows/dag/frontend-recovery-lineage.js +13 -0
- package/dist/workflows/dag/frontend-recovery-plan.js +10 -5
- package/dist/workflows/dag/frontend-recovery-run.js +148 -47
- package/dist/workflows/dag/frontend-repair-assertions.js +36 -0
- package/dist/workflows/dag/frontend-repair.js +79 -76
- package/dist/workflows/dag/frontend-review-context.js +71 -69
- package/dist/workflows/dag/frontend-review-scopes.js +237 -0
- package/dist/workflows/dag/frontend-risk.js +101 -12
- package/dist/workflows/dag/frontend-root-observation.js +261 -0
- package/dist/workflows/dag/frontend-session-budget.js +376 -0
- package/dist/workflows/dag/frontend-session-context.js +10 -0
- package/dist/workflows/dag/frontend-shape-facts.js +12 -2
- package/dist/workflows/dag/frontend-shape.js +27 -32
- package/dist/workflows/dag/frontend-test-case-checklist.js +12 -3
- package/dist/workflows/dag/frontend-test-case-generation-assessment.js +21 -2
- package/dist/workflows/dag/frontend-test-case-quality.js +3 -3
- package/dist/workflows/dag/frontend-test-environment-probe.js +0 -2
- package/dist/workflows/dag/frontend-test-execution-evidence.js +328 -0
- package/dist/workflows/dag/frontend-test-framework-adapters.js +309 -0
- package/dist/workflows/dag/frontend-test-layout.js +41 -12
- package/dist/workflows/dag/frontend-typed-event-store.js +57 -26
- package/dist/workflows/dag/frontend-verification-trace.js +65 -48
- package/dist/workflows/dag/frontend-writer-admission.js +6 -48
- package/dist/workflows/dag/frontend-writer-status.js +0 -23
- package/dist/workflows/dag/hybrid/sources.js +1831 -0
- package/dist/workflows/dag/hybrid/templates/backend-test.js +1822 -0
- package/dist/workflows/dag/hybrid/templates/frontend-test.js +807 -0
- package/dist/workflows/dag/hybrid/templates/frontend.js +1529 -0
- package/dist/workflows/dag/hybrid/templates/index.js +8 -0
- package/dist/workflows/dag/hybrid/templates/kg-bootstrap.js +449 -0
- package/dist/workflows/dag/hybrid/templates/knowledge-sync.js +495 -0
- package/dist/workflows/dag/hybrid/templates/shared.js +101 -0
- package/dist/workflows/dag/hybrid/templates/standard.js +265 -0
- package/dist/workflows/dag/hybrid/types.js +32 -0
- package/dist/workflows/dag/init-hybrid.js +57 -7167
- package/dist/workflows/dag/interrupt-request.js +2 -0
- package/dist/workflows/dag/lifecycle.js +11 -2
- package/dist/workflows/dag/node-execution.js +257 -247
- package/dist/workflows/dag/output-protocol.js +1 -0
- package/dist/workflows/dag/prompt.js +4 -0
- package/dist/workflows/dag/reconcile-run.js +2 -0
- package/dist/workflows/dag/repair-artifact.js +3 -1
- package/dist/workflows/dag/report.js +2 -0
- package/dist/workflows/dag/rerun-feedback.js +36 -4
- package/dist/workflows/dag/rerun-plan.js +106 -4
- package/dist/workflows/dag/rerun-run.js +7 -0
- package/dist/workflows/dag/rerun-task.js +75 -1
- package/dist/workflows/dag/retry-policy.js +34 -10
- package/dist/workflows/dag/runner-exit-diagnostics.js +125 -0
- package/dist/workflows/dag/runner.js +38 -1074
- package/dist/workflows/dag/scheduler.js +2 -4
- package/dist/workflows/dag/skill-instructions.js +102 -32
- package/dist/workflows/dag/skill-snapshot.js +3 -0
- package/dist/workflows/dag/skills.js +7 -7
- package/dist/workflows/dag/structured-output-repair.js +4 -1
- package/dist/workflows/dag/terminal-status.js +502 -0
- package/dist/workflows/dag/test-artifact-namespace.js +73 -0
- package/dist/workflows/dag/types.js +58 -7
- package/dist/workflows/dag/validate.js +38 -13
- package/dist/workflows/dag/workspace-checkpoint.js +79 -1
- package/dist/workflows/loop/benchmark.js +11 -8
- package/docs/README.md +2 -1
- package/docs/architecture/dag-execution.md +4 -4
- package/docs/architecture/runtime-boundaries.md +29 -23
- package/docs/governance/README.md +1 -0
- package/docs/governance/harness-methodology-verification.md +11 -0
- package/docs/init-surface.manifest.json +44 -295
- package/docs/operations/README.md +4 -0
- package/docs/templates/README.md +5 -5
- package/docs/templates/agent-dag.base.json +9 -9
- package/docs/templates/agent-dag.final-verification.json +6 -6
- package/docs/templates/agent-dag.schema.json +2 -2
- package/docs/templates/agent-dag.supervised-implementation.json +12 -12
- package/docs/templates/backend-test-dag.generate-pytest.prompt.md +3 -3
- package/docs/templates/backend-test-dag.json +708 -703
- package/docs/templates/backend-test-dag.review-cases.prompt.md +3 -3
- package/docs/templates/frontend-design-contract.md +4 -4
- package/docs/templates/frontend-implementation-contract.schema.json +99 -22
- package/docs/templates/frontend-implementation-dag.json +7 -7
- package/docs/templates/frontend-test-case-checklist.md +2 -2
- package/docs/templates/frontend-test-case.example.md +2 -0
- package/docs/templates/frontend-test-dag.generate-cases.prompt.md +1 -1
- package/docs/templates/frontend-test-dag.json +46 -37
- package/docs/templates/frontend-test-dag.retrieve-context.prompt.md +2 -2
- package/docs/templates/frontend-test-dag.retrospect.prompt.md +1 -1
- package/docs/templates/frontend-test-dag.review-cases.prompt.md +1 -1
- package/docs/templates/hybrid-dag.json +9 -9
- package/docs/templates/knowledge-sync-dag.json +8 -8
- package/harness.json +1 -1
- package/package.json +27 -8
- package/resource-catalog.v1.json +1981 -0
- package/resources/agent-bridge/loop-agent/SKILL.md +40 -0
- package/resources/init-history/legacy-surface.v1.json +33 -0
- package/skills/fe-test-ui-scout/SKILL.md +4 -4
- package/skills/fe-test-ui-scout/references/ledger-schema.md +1 -1
- package/skills/frontend-bounded-implement/references/code-standards.md +3 -3
- package/skills/frontend-contract/SKILL.md +2 -1
- package/skills/frontend-contract/references/contract-protocol.md +22 -4
- package/skills/frontend-design-review/SKILL.md +16 -18
- package/skills/frontend-design-review/references/review-checklist.md +3 -4
- package/skills/frontend-plan/SKILL.md +25 -3
- package/skills/frontend-plan/references/decision-contract.md +117 -8
- package/skills/frontend-plan/references/design-decisions.md +32 -0
- package/skills/frontend-review/SKILL.md +29 -36
- package/skills/frontend-review/references/review-findings.md +8 -3
- package/skills/frontend-scout/references/scout-evidence.md +4 -0
- package/skills/init-update/SKILL.md +34 -0
- package/skills/init-update/agents/openai.yaml +6 -0
- package/skills/loop-agent/references/command-reference.md +8 -0
- package/skills/loop-agent/references/hybrid-dag.md +1 -1
- package/skills/playwright-cli/SKILL.md +1 -1
- package/skills/playwright-cli-case-generator/SKILL.md +7 -5
- package/dist/commands/new-task.js +0 -5
- package/dist/commands/status.js +0 -57
- package/dist/commands/task-contract.js +0 -269
- package/dist/shared/prompts.js +0 -26
- package/dist/task/config.js +0 -2
- package/dist/task/contract/validate-draft.js +0 -106
- package/dist/task/goal.js +0 -3
- package/dist/task/index.js +0 -12
- package/dist/task/lifecycle.js +0 -1
- package/dist/task/operator/capabilities.js +0 -6
- package/dist/task/operator/envelope.js +0 -2
- package/dist/task/operator/index.js +0 -5
- package/dist/task/operator/registry.js +0 -2
- package/dist/task/paths.js +0 -1
- package/dist/task/source-state.js +0 -1
- package/dist/task/subagent-guidance.js +0 -1
- package/dist/worker/console/chat/sift-bridge.js +0 -1
- package/dist/worker/console/index.js +0 -20
- package/dist/worker/console/static/assets/channel-CXqdP5pW.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-D9C3agF7.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-D9C3agF7.js +0 -1
- package/dist/worker/console/static/assets/index-CAZ2fC_X.css +0 -1
- package/dist/worker/console/static/assets/index-DhfjOafu.js +0 -449
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-Tp7V0U4q.js +0 -1
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-DUZWZWi8.js +0 -8
- package/dist/worker/scheduler/index.js +0 -25
- package/dist/workflows/dag/facts.js +0 -4
- package/dist/workflows/dag/frontend-shadow-dual-write.js +0 -941
- package/dist/workflows/dag/index.js +0 -6
- package/dist/workflows/dynamic/index.js +0 -7
- /package/dist/{task/operator/types.js → executors/dag-pi/plan/session.js} +0 -0
|
@@ -26,13 +26,27 @@ import { z } from "zod";
|
|
|
26
26
|
* billing/plan state, not a transient rate limit, and retrying immediately
|
|
27
27
|
* will not help and may waste budget.
|
|
28
28
|
*/
|
|
29
|
+
/**
|
|
30
|
+
* Gateway/provider reachability failure: the upstream answered with an
|
|
31
|
+
* availability error (HTTP 502/503, "service temporarily unavailable", "bad
|
|
32
|
+
* gateway") rather than the model rejecting the request. Kept distinct from
|
|
33
|
+
* `unavailable` (model/provider capability phrasing) and from the plan
|
|
34
|
+
* ladder's `unsupported-provider-capability`, so a provider outage is not
|
|
35
|
+
* misdiagnosed as a capability mismatch (2026-09-11 incident: r18/r19 plan
|
|
36
|
+
* nodes reported the vague category while the gateway was returning 503).
|
|
37
|
+
*/
|
|
38
|
+
export const UPSTREAM_UNAVAILABLE_FAILURE_CATEGORY = "upstream-unavailable";
|
|
29
39
|
export const DEFAULT_DAG_RETRY_CATEGORIES = [
|
|
30
40
|
"timeout",
|
|
31
41
|
"network",
|
|
32
42
|
"rate-limit",
|
|
33
43
|
"unavailable",
|
|
44
|
+
UPSTREAM_UNAVAILABLE_FAILURE_CATEGORY,
|
|
34
45
|
"empty-output",
|
|
46
|
+
"output-limit",
|
|
35
47
|
];
|
|
48
|
+
/** Provider stopReason=length: output/context capacity ended the turn early. */
|
|
49
|
+
export const OUTPUT_LIMIT_RETRY_CATEGORY = "output-limit";
|
|
36
50
|
export const STRUCTURED_OUTPUT_RETRY_CATEGORY = "output-too-large";
|
|
37
51
|
export const PROTOCOL_INVALID_RETRY_CATEGORY = "protocol-invalid";
|
|
38
52
|
/** Recoverable model artifact/schema formatting failure on read-only structured nodes. */
|
|
@@ -31,13 +31,13 @@ export function getNodeOutputAsJson(state, nodeId) {
|
|
|
31
31
|
export function normalizeVerdictCandidateLine(value) {
|
|
32
32
|
const trimmed = String(value).trim();
|
|
33
33
|
const emphasized = trimmed.match(/^(?:`{1,3}|\*{1,3})\s*(VERDICT:[^`*]+?)\s*(?:`{1,3}|\*{1,3})$/);
|
|
34
|
-
const line = (emphasized
|
|
34
|
+
const line = (emphasized?.[1] ?? trimmed).trim();
|
|
35
35
|
// Canonicalize the colon separator and trailing sentence punctuation so
|
|
36
36
|
// "VERDICT:pass", "VERDICT: pass", or "VERDICT: pass." match the declared
|
|
37
37
|
// enum lines without accepting free-text verdicts. Conflicting verdicts
|
|
38
38
|
// still canonicalize to distinct enum lines and remain fail-closed.
|
|
39
39
|
const verdictMatch = line.match(/^VERDICT:\s*(pass|request-revision)\s*[.!?。!?]*$/i);
|
|
40
|
-
if (verdictMatch)
|
|
40
|
+
if (verdictMatch?.[1])
|
|
41
41
|
return `VERDICT: ${verdictMatch[1].toLowerCase()}`;
|
|
42
42
|
return line;
|
|
43
43
|
}
|
|
@@ -3,7 +3,8 @@ import os from 'node:os';
|
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { DEFAULT_DAG_EXECUTOR_MODELS } from './types.js';
|
|
5
5
|
import { parseDagSpec } from './types.js';
|
|
6
|
-
import {
|
|
6
|
+
import { ProjectCapabilityScanner } from '../../governance/project-capability-scanner.js';
|
|
7
|
+
import { loadNormalizedProjectConfig } from '../../governance/project-config.js';
|
|
7
8
|
import { loadTaskConfig } from '../../task/runtime.js';
|
|
8
9
|
import { resolveCliPath } from '../../shared/path-refs.js';
|
|
9
10
|
const DEFAULT_OUTPUT_DIR = os.tmpdir();
|
|
@@ -22,14 +23,13 @@ export async function initFinalVerificationDagFromTask(repoRoot, taskId, options
|
|
|
22
23
|
};
|
|
23
24
|
}
|
|
24
25
|
export async function buildFinalVerificationDagFromTask(repoRoot, taskId, options = {}) {
|
|
25
|
-
const
|
|
26
|
-
loadTaskConfig(repoRoot, taskId),
|
|
27
|
-
loadHarnessManifest(repoRoot),
|
|
28
|
-
]);
|
|
26
|
+
const taskConfig = await loadTaskConfig(repoRoot, taskId);
|
|
29
27
|
const taskGlob = options.taskGlob ?? taskId;
|
|
30
28
|
const closeoutPath = options.closeoutPath ?? path.join(os.tmpdir(), `${taskId}-closeout-report.md`);
|
|
31
|
-
const
|
|
32
|
-
|
|
29
|
+
const finalVerifyCommands = await resolveFinalVerificationCommands({
|
|
30
|
+
repoRoot,
|
|
31
|
+
taskCommands: taskConfig.verifyCommands.map((entry) => entry.command),
|
|
32
|
+
});
|
|
33
33
|
const hasChangesetSignal = taskDeclaresReleaseImpact(taskConfig);
|
|
34
34
|
const tasks = [
|
|
35
35
|
shellTask({
|
|
@@ -142,12 +142,12 @@ export async function buildFinalVerificationDagFromTask(repoRoot, taskId, option
|
|
|
142
142
|
executor: 'shell',
|
|
143
143
|
contextProfile: 'slim',
|
|
144
144
|
writePolicy: 'read-only',
|
|
145
|
-
skills: ['ai-engineering-context'],
|
|
145
|
+
skills: ['builtin:ai-engineering-context'],
|
|
146
146
|
},
|
|
147
147
|
executorModels: DEFAULT_DAG_EXECUTOR_MODELS,
|
|
148
148
|
skillsByRole: {
|
|
149
|
-
verifier: ['verification-before-completion'],
|
|
150
|
-
closeout: ['loop-agent', 'verification-before-completion'],
|
|
149
|
+
verifier: ['builtin:verification-before-completion'],
|
|
150
|
+
closeout: ['builtin:loop-agent', 'builtin:verification-before-completion'],
|
|
151
151
|
},
|
|
152
152
|
tasks,
|
|
153
153
|
});
|
|
@@ -178,3 +178,38 @@ function taskDeclaresReleaseImpact(taskConfig) {
|
|
|
178
178
|
].join('\n');
|
|
179
179
|
return /changeset|release|publish|version/i.test(haystack);
|
|
180
180
|
}
|
|
181
|
+
export async function resolveFinalVerificationCommandSelection(input) {
|
|
182
|
+
if (input.taskCommands.length > 0) {
|
|
183
|
+
return {
|
|
184
|
+
source: 'task-contract',
|
|
185
|
+
commands: [...new Set(input.taskCommands)],
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
const verification = (await loadNormalizedProjectConfig(input.repoRoot)).verification;
|
|
189
|
+
const configured = verification.full.length > 0
|
|
190
|
+
? verification.full
|
|
191
|
+
: verification.standard.length > 0
|
|
192
|
+
? verification.standard
|
|
193
|
+
: verification.quick;
|
|
194
|
+
if (configured.length > 0) {
|
|
195
|
+
return {
|
|
196
|
+
source: 'project-config',
|
|
197
|
+
commands: [...new Set(configured)],
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
const scan = await new ProjectCapabilityScanner().scan(input.repoRoot);
|
|
201
|
+
const selected = scan.verification.commands.find((candidate) => candidate.id.endsWith(':test'))
|
|
202
|
+
?? scan.verification.commands.find((candidate) => candidate.id.endsWith(':typecheck'))
|
|
203
|
+
?? scan.verification.commands.find((candidate) => candidate.id.endsWith(':lint'))
|
|
204
|
+
?? scan.verification.commands[0];
|
|
205
|
+
if (scan.verification.status !== 'ready' || !selected) {
|
|
206
|
+
throw new Error(`final verification is ${scan.verification.status}; add Task Contract verification or .loop-agent/project.json verification`);
|
|
207
|
+
}
|
|
208
|
+
return {
|
|
209
|
+
source: 'capability-scanner',
|
|
210
|
+
commands: [selected.command],
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
async function resolveFinalVerificationCommands(input) {
|
|
214
|
+
return (await resolveFinalVerificationCommandSelection(input)).commands;
|
|
215
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Shared Contract/Plan bound. Permissions and directory globs are not files. */
|
|
2
|
+
export const FRONTEND_MAX_IMPLEMENTATION_FILES = 15;
|
|
3
|
+
export function frontendConcreteDeliveryFiles(files) {
|
|
4
|
+
if (!Array.isArray(files))
|
|
5
|
+
return [];
|
|
6
|
+
return [...new Set(files.filter((file) => typeof file === "string")
|
|
7
|
+
.map(file => file.trim().replace(/\\/g, "/").replace(/^(\.\/)+/, ""))
|
|
8
|
+
.filter(file => file.length > 0 && !/[*?{}]/.test(file) && !file.endsWith("/")))];
|
|
9
|
+
}
|
|
@@ -42,6 +42,10 @@ export const frontendCloseoutFactsSchema = z
|
|
|
42
42
|
.object({
|
|
43
43
|
verificationTargetId: z.string().min(1),
|
|
44
44
|
status: frontendCoverageStatusSchema,
|
|
45
|
+
evidence: z.enum(["file-exists", "command-execution", "test-file-execution", "unavailable"]).optional(),
|
|
46
|
+
behaviorCoverage: z.enum(["unconfirmed"]).optional(),
|
|
47
|
+
plannedEvidenceLevel: z.enum(["unit", "mounted", "real-integration", "unknown"]).optional(),
|
|
48
|
+
boundary: z.string().min(1).optional(),
|
|
45
49
|
})
|
|
46
50
|
.strict()),
|
|
47
51
|
lintStatus: frontendLintStatusSchema,
|
|
@@ -143,7 +147,7 @@ function bulletList(items) {
|
|
|
143
147
|
return items.map((item) => `- ${item}`).join("\n");
|
|
144
148
|
}
|
|
145
149
|
function coverageLines(facts) {
|
|
146
|
-
const lines = facts.coverageMatrix.map((entry) => `- ${entry.verificationTargetId}:
|
|
150
|
+
const lines = facts.coverageMatrix.map((entry) => `- ${entry.verificationTargetId}: execution=${entry.status}; evidence=${entry.evidence ?? "unspecified"}; behavior-coverage=${entry.behaviorCoverage ?? "unconfirmed"}; planned-evidence=${entry.plannedEvidenceLevel ?? "unknown"}${entry.boundary ? `; boundary=${entry.boundary}` : ""}`);
|
|
147
151
|
return lines.length > 0 ? lines.join("\n") : "_(none)_";
|
|
148
152
|
}
|
|
149
153
|
function frontendStatus(facts) {
|
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
import { readTypedEventStoreFromJsonl, } from "./frontend-typed-event-store.js";
|
|
2
|
+
function isRecord(value) {
|
|
3
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4
|
+
}
|
|
5
|
+
function asString(value) {
|
|
6
|
+
return typeof value === "string" ? value.trim() : "";
|
|
7
|
+
}
|
|
8
|
+
function asStringArray(value) {
|
|
9
|
+
if (!Array.isArray(value))
|
|
10
|
+
return [];
|
|
11
|
+
return value
|
|
12
|
+
.map((item) => asString(item))
|
|
13
|
+
.filter((item) => item.length > 0);
|
|
14
|
+
}
|
|
15
|
+
/** Deterministic, sorted, de-duplicated string set. Lexicographic order only;
|
|
16
|
+
* never locale/Date-dependent so diff output is reproducible. */
|
|
17
|
+
function canonicalStringSet(values) {
|
|
18
|
+
return [
|
|
19
|
+
...new Set(values
|
|
20
|
+
.map((item) => item.trim())
|
|
21
|
+
.filter((item) => item.length > 0)),
|
|
22
|
+
].sort();
|
|
23
|
+
}
|
|
24
|
+
export const PLAN_LEDGER_FACT_KINDS = [
|
|
25
|
+
"target-surface",
|
|
26
|
+
"state-registry",
|
|
27
|
+
"component-choice",
|
|
28
|
+
"state-flow",
|
|
29
|
+
"data-flow",
|
|
30
|
+
"mock-api",
|
|
31
|
+
"design-deviation",
|
|
32
|
+
"dependency",
|
|
33
|
+
"plan-requirement",
|
|
34
|
+
"plan-verification-target",
|
|
35
|
+
"plan-evidence-gap",
|
|
36
|
+
"mock-endpoint",
|
|
37
|
+
];
|
|
38
|
+
/**
|
|
39
|
+
* A+B (AC-004): reverse of `planLedgerFactsFromPatch` for the incremental
|
|
40
|
+
* `record_*` tool flow. Reconstructs the canonical editable patch from the raw
|
|
41
|
+
* fields each `record_*` tool committed. `finalize_plan` calls this and then
|
|
42
|
+
* re-publishes the assembled patch onto a `target-surface` fact so the
|
|
43
|
+
* writeSet-external compile authority (`frontend-implementation-contract.ts`)
|
|
44
|
+
* can still restore a plain `patch` object.
|
|
45
|
+
*/
|
|
46
|
+
export function assemblePlanPatchFromCommittedFacts(records, contractRequirements) {
|
|
47
|
+
const facts = records
|
|
48
|
+
.filter((record) => record.phase === "committed")
|
|
49
|
+
.map((record) => record.fact)
|
|
50
|
+
.filter((fact) => isRecord(fact) &&
|
|
51
|
+
fact.origin === "plan" &&
|
|
52
|
+
typeof fact.kind === "string" &&
|
|
53
|
+
PLAN_LEDGER_FACT_KINDS.includes(fact.kind));
|
|
54
|
+
if (facts.length === 0)
|
|
55
|
+
return undefined;
|
|
56
|
+
// Singleton policy facts: the LAST committed fact wins. The model corrects a
|
|
57
|
+
// rejected plan by re-recording the policy (r18). Requirements / verification
|
|
58
|
+
// targets / evidence gaps stay additive; component choices accumulate; and
|
|
59
|
+
// state-flow is merged below by item name so UX-local batches do not erase one
|
|
60
|
+
// another.
|
|
61
|
+
const lastByKind = (kind) => {
|
|
62
|
+
let found;
|
|
63
|
+
for (const fact of facts) {
|
|
64
|
+
if (fact.kind === kind)
|
|
65
|
+
found = fact;
|
|
66
|
+
}
|
|
67
|
+
return found;
|
|
68
|
+
};
|
|
69
|
+
// Patch snapshots (published by earlier finalize calls) carry no routes;
|
|
70
|
+
// exclude them so a snapshot cannot override the model's route selection.
|
|
71
|
+
const routeSurface = (() => {
|
|
72
|
+
let found;
|
|
73
|
+
for (const fact of facts) {
|
|
74
|
+
if (fact.kind !== "target-surface" || isRecord(fact.patch))
|
|
75
|
+
continue;
|
|
76
|
+
found = fact;
|
|
77
|
+
}
|
|
78
|
+
return found;
|
|
79
|
+
})();
|
|
80
|
+
const patch = {};
|
|
81
|
+
const targetSurface = routeSurface;
|
|
82
|
+
if (targetSurface) {
|
|
83
|
+
const routes = canonicalStringSet(asStringArray(targetSurface.routes));
|
|
84
|
+
if (routes.length > 0)
|
|
85
|
+
patch.targets = { routes };
|
|
86
|
+
}
|
|
87
|
+
const componentChoices = facts.filter((fact) => fact.kind === "component-choice");
|
|
88
|
+
const collectedChoices = componentChoices.flatMap((fact) => Array.isArray(fact.uiComponentChoices)
|
|
89
|
+
? fact.uiComponentChoices.filter(isRecord)
|
|
90
|
+
: []);
|
|
91
|
+
// Later corrections supersede earlier submissions per purpose: without
|
|
92
|
+
// this, a re-recorded choice (fixing a wrong specReference) would appear
|
|
93
|
+
// twice and the reviewer would still audit the stale entry (r19).
|
|
94
|
+
const choicesByPurpose = new Map();
|
|
95
|
+
const dedupedChoices = [];
|
|
96
|
+
for (const choice of collectedChoices) {
|
|
97
|
+
const purpose = asString(choice.purpose);
|
|
98
|
+
if (!purpose) {
|
|
99
|
+
dedupedChoices.push(choice);
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
if (choicesByPurpose.has(purpose)) {
|
|
103
|
+
const at = dedupedChoices.findIndex((existing) => asString(existing.purpose) === purpose);
|
|
104
|
+
dedupedChoices[at] = choice;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
choicesByPurpose.set(purpose, choice);
|
|
108
|
+
dedupedChoices.push(choice);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const stylingStrategy = componentChoices
|
|
112
|
+
.map((fact) => asString(fact.stylingStrategy))
|
|
113
|
+
.find((value) => value.length > 0);
|
|
114
|
+
if (dedupedChoices.length > 0)
|
|
115
|
+
patch.uiComponentChoices = dedupedChoices;
|
|
116
|
+
if (stylingStrategy)
|
|
117
|
+
patch.stylingStrategy = stylingStrategy;
|
|
118
|
+
// UX-local batches can emit several state-flow facts. Aggregate by the
|
|
119
|
+
// stable state/interaction name so a later correction replaces only that
|
|
120
|
+
// item; last-wins at the whole-fact level silently discarded earlier local
|
|
121
|
+
// batches when Segment 2 was split (r21).
|
|
122
|
+
const stateFlows = facts.filter((fact) => fact.kind === "state-flow");
|
|
123
|
+
const stateByName = new Map();
|
|
124
|
+
const unnamedStates = [];
|
|
125
|
+
const interactionByName = new Map();
|
|
126
|
+
const unnamedInteractions = [];
|
|
127
|
+
for (const flow of stateFlows) {
|
|
128
|
+
for (const name of asStringArray(flow.removeUiStateNames))
|
|
129
|
+
stateByName.delete(name);
|
|
130
|
+
for (const name of asStringArray(flow.removeInteractionNames))
|
|
131
|
+
interactionByName.delete(name);
|
|
132
|
+
for (const state of Array.isArray(flow.uiStates) ? flow.uiStates : []) {
|
|
133
|
+
if (!isRecord(state))
|
|
134
|
+
continue;
|
|
135
|
+
const name = asString(state.name);
|
|
136
|
+
if (name)
|
|
137
|
+
stateByName.set(name, state);
|
|
138
|
+
else
|
|
139
|
+
unnamedStates.push(state);
|
|
140
|
+
}
|
|
141
|
+
for (const interaction of Array.isArray(flow.interactions) ? flow.interactions : []) {
|
|
142
|
+
if (!isRecord(interaction))
|
|
143
|
+
continue;
|
|
144
|
+
const name = asString(interaction.name);
|
|
145
|
+
if (name)
|
|
146
|
+
interactionByName.set(name, interaction);
|
|
147
|
+
else
|
|
148
|
+
unnamedInteractions.push(interaction);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (stateFlows.length > 0) {
|
|
152
|
+
patch.uiStates = [...stateByName.values(), ...unnamedStates];
|
|
153
|
+
patch.interactions = [...interactionByName.values(), ...unnamedInteractions];
|
|
154
|
+
}
|
|
155
|
+
const mockApi = lastByKind("mock-api");
|
|
156
|
+
if (!mockApi && facts.some(f => f.kind === "mock-endpoint" && f.removed !== true))
|
|
157
|
+
throw Error("MOCK_POLICY_MISSING: endpoint has no policy");
|
|
158
|
+
if (mockApi && isRecord(mockApi.mockApi)) {
|
|
159
|
+
const endpoints = new Map();
|
|
160
|
+
for (const endpoint of Array.isArray(mockApi.mockApi.endpoints) ? mockApi.mockApi.endpoints : []) {
|
|
161
|
+
if (isRecord(endpoint))
|
|
162
|
+
endpoints.set(`${endpoint.method}:${endpoint.path}`, endpoint);
|
|
163
|
+
}
|
|
164
|
+
for (const fact of facts)
|
|
165
|
+
if (fact.kind === "mock-endpoint" && isRecord(fact.endpoint)) {
|
|
166
|
+
const key = `${fact.endpoint.method}:${fact.endpoint.path}`;
|
|
167
|
+
if (fact.removed === true)
|
|
168
|
+
endpoints.delete(key);
|
|
169
|
+
else
|
|
170
|
+
endpoints.set(key, fact.endpoint);
|
|
171
|
+
}
|
|
172
|
+
if (mockApi.mockApi.strategy === "not-needed" && endpoints.size)
|
|
173
|
+
throw Error("MOCK_POLICY_CONFLICT: withdraw endpoints before declaring Mock/API not needed");
|
|
174
|
+
patch.mockApi = { ...mockApi.mockApi, endpoints: [...endpoints.values()] };
|
|
175
|
+
}
|
|
176
|
+
const deviation = lastByKind("design-deviation");
|
|
177
|
+
if (deviation) {
|
|
178
|
+
const conflicts = canonicalStringSet(asStringArray(deviation.conflicts));
|
|
179
|
+
if (conflicts.length > 0)
|
|
180
|
+
patch.designEvidence = { conflicts };
|
|
181
|
+
}
|
|
182
|
+
const dependency = lastByKind("dependency");
|
|
183
|
+
const dependencyPolicy = asString(dependency?.policy);
|
|
184
|
+
if (dependencyPolicy)
|
|
185
|
+
patch.dependencyPolicy = dependencyPolicy;
|
|
186
|
+
// Requirements / verification targets / evidence gaps / implementation
|
|
187
|
+
// steps arrive as individual facts (one per record_plan_* call) so a large
|
|
188
|
+
// plan never exceeds a single model output budget. Aggregate them in
|
|
189
|
+
// ledger order.
|
|
190
|
+
const targetRequirements = new Map();
|
|
191
|
+
for (const fact of facts.filter((item) => item.kind === "plan-verification-target")) {
|
|
192
|
+
const entry = isRecord(fact.entry) ? fact.entry : undefined;
|
|
193
|
+
const targetId = asString(entry?.id);
|
|
194
|
+
if (!targetId)
|
|
195
|
+
continue;
|
|
196
|
+
for (const requirementId of asStringArray(entry?.requirementIds)) {
|
|
197
|
+
const targets = targetRequirements.get(requirementId) ?? [];
|
|
198
|
+
if (!targets.includes(targetId))
|
|
199
|
+
targets.push(targetId);
|
|
200
|
+
targetRequirements.set(requirementId, targets);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
const requirements = facts
|
|
204
|
+
.filter((fact) => fact.kind === "plan-requirement")
|
|
205
|
+
.map((fact) => fact.entry)
|
|
206
|
+
.filter(isRecord)
|
|
207
|
+
.map((entry) => {
|
|
208
|
+
const requirementId = asString(entry.id);
|
|
209
|
+
const derivedTargets = requirementId ? targetRequirements.get(requirementId) : undefined;
|
|
210
|
+
if (derivedTargets && derivedTargets.length > 0) {
|
|
211
|
+
return { ...entry, verificationTargetIds: [...derivedTargets].sort() };
|
|
212
|
+
}
|
|
213
|
+
return entry;
|
|
214
|
+
})
|
|
215
|
+
.map((entry) => {
|
|
216
|
+
// The canonical contract schema requires a non-empty
|
|
217
|
+
// expectedOutcome, but the plan should not be forced to re-write
|
|
218
|
+
// full outcome prose for every requirement (the contract node
|
|
219
|
+
// already captured requirement semantics). Derive a deterministic
|
|
220
|
+
// placeholder from the requirement id when omitted.
|
|
221
|
+
if (isRecord(entry) && !asString(entry.expectedOutcome)) {
|
|
222
|
+
const id = asString(entry.id) || "requirement";
|
|
223
|
+
return { ...entry, expectedOutcome: `implied by contract: ${id}` };
|
|
224
|
+
}
|
|
225
|
+
return entry;
|
|
226
|
+
})
|
|
227
|
+
// Source fidelity ledger (AC-005/AC-006): the contract node declared the
|
|
228
|
+
// authoritative sourceFragmentIds/sourceRefs for each requirement from
|
|
229
|
+
// the ledger's requirement→fragment mapping. The plan inherits them by
|
|
230
|
+
// requirement id so the compiled canonical contract carries the same
|
|
231
|
+
// provenance evidence without the plan re-deriving (or fabricating) it.
|
|
232
|
+
.map((entry) => {
|
|
233
|
+
if (!contractRequirements)
|
|
234
|
+
return entry;
|
|
235
|
+
const id = asString(entry.id);
|
|
236
|
+
if (!id)
|
|
237
|
+
return entry;
|
|
238
|
+
const inherited = contractRequirements.get(id);
|
|
239
|
+
if (!inherited)
|
|
240
|
+
return entry;
|
|
241
|
+
const merged = { ...entry, ...(inherited.text ? { expectedOutcome: inherited.text } : {}), ...(inherited.execution ? { execution: inherited.execution } : {}) };
|
|
242
|
+
// Inherit the contract-declared provenance only when the plan did
|
|
243
|
+
// not already declare it (model override wins; missing inherits).
|
|
244
|
+
if (!Array.isArray(entry.sourceFragmentIds)) {
|
|
245
|
+
if (inherited.sourceFragmentIds) {
|
|
246
|
+
merged.sourceFragmentIds = inherited.sourceFragmentIds;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
if (!Array.isArray(entry.sourceRefs)) {
|
|
250
|
+
if (inherited.sourceRefs) {
|
|
251
|
+
merged.sourceRefs = inherited.sourceRefs;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
return merged;
|
|
255
|
+
})
|
|
256
|
+
.map((entry) => {
|
|
257
|
+
if (isRecord(entry) && !isRecord(entry.evidenceGap)) {
|
|
258
|
+
const requirementId = asString(entry.id);
|
|
259
|
+
const standaloneGap = facts
|
|
260
|
+
.filter((fact) => fact.kind === "plan-evidence-gap")
|
|
261
|
+
.map((fact) => fact.entry)
|
|
262
|
+
.filter(isRecord)
|
|
263
|
+
.filter((gap) => asString(gap.requirementId) === requirementId)
|
|
264
|
+
.at(-1);
|
|
265
|
+
if (standaloneGap && asString(standaloneGap.description)) {
|
|
266
|
+
return { ...entry, evidenceGap: standaloneGap };
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return entry;
|
|
270
|
+
})
|
|
271
|
+
// A requirement id is a canonical identity; drop duplicates so the
|
|
272
|
+
// compiled patch never carries the same requirement twice (the
|
|
273
|
+
// record_plan_requirement tool rejects re-records, this dedupes any
|
|
274
|
+
// duplicate edge records at the compile authority).
|
|
275
|
+
.filter((entry, index, all) => all.map((other) => asString(other.id)).lastIndexOf(asString(entry.id)) === index);
|
|
276
|
+
if (requirements.length > 0)
|
|
277
|
+
patch.requirements = requirements;
|
|
278
|
+
const verificationTargetOrder = [];
|
|
279
|
+
const verificationTargetById = new Map();
|
|
280
|
+
for (const fact of facts.filter((item) => item.kind === "plan-verification-target")) {
|
|
281
|
+
const entry = fact.entry;
|
|
282
|
+
if (!isRecord(entry))
|
|
283
|
+
continue;
|
|
284
|
+
const id = asString(entry.id);
|
|
285
|
+
if (!id)
|
|
286
|
+
continue;
|
|
287
|
+
if (!verificationTargetById.has(id))
|
|
288
|
+
verificationTargetOrder.push(id);
|
|
289
|
+
verificationTargetById.set(id, entry);
|
|
290
|
+
}
|
|
291
|
+
const verificationTargets = verificationTargetOrder
|
|
292
|
+
.map((id) => verificationTargetById.get(id))
|
|
293
|
+
.filter((entry) => Boolean(entry))
|
|
294
|
+
.map((entry) => {
|
|
295
|
+
// Coverage precedes UX. A later state-flow fact explicitly naming
|
|
296
|
+
// this VT establishes the reverse binding without another model call.
|
|
297
|
+
// No path/name heuristics: unbound or ambiguous decisions stay subject
|
|
298
|
+
// to canonical validation. Recompute from live states after removals.
|
|
299
|
+
const boundStates = [...stateByName.values()]
|
|
300
|
+
.filter((state) => state.applicable === true &&
|
|
301
|
+
asStringArray(state.verificationTargetIds).includes(asString(entry.id)))
|
|
302
|
+
.map((state) => asString(state.name));
|
|
303
|
+
if (boundStates.length === 0)
|
|
304
|
+
return entry;
|
|
305
|
+
return { ...entry, uiStates: [...new Set([
|
|
306
|
+
...asStringArray(entry.uiStates), ...boundStates,
|
|
307
|
+
])].sort() };
|
|
308
|
+
});
|
|
309
|
+
if (verificationTargets.length > 0) {
|
|
310
|
+
patch.verificationTargets = verificationTargets;
|
|
311
|
+
}
|
|
312
|
+
const evidenceGaps = facts
|
|
313
|
+
.filter((fact) => fact.kind === "plan-evidence-gap")
|
|
314
|
+
.map((fact) => fact.entry)
|
|
315
|
+
.filter(isRecord);
|
|
316
|
+
if (evidenceGaps.length > 0)
|
|
317
|
+
patch.evidenceGaps = evidenceGaps;
|
|
318
|
+
return Object.keys(patch).length > 0 ? patch : undefined;
|
|
319
|
+
}
|
|
320
|
+
/** A+B (AC-001/003): read only the committed-phase origin facts from a node's
|
|
321
|
+
* typed event store JSONL. Staged/quarantined records never leak downstream. */
|
|
322
|
+
export async function readCommittedOriginFacts(runDir, nodeId, fileName) {
|
|
323
|
+
const pathMod = await import("node:path");
|
|
324
|
+
const records = await readTypedEventStoreFromJsonl(pathMod.join(runDir, nodeId, fileName));
|
|
325
|
+
return records.filter((record) => record.phase === "committed");
|
|
326
|
+
}
|
|
327
|
+
function latestCommittedScoutTargetSurface(records) {
|
|
328
|
+
return records
|
|
329
|
+
.filter((record) => record.phase === "committed" &&
|
|
330
|
+
isRecord(record.fact) &&
|
|
331
|
+
record.fact.origin === "scout" &&
|
|
332
|
+
record.fact.kind === "target-surface")
|
|
333
|
+
.at(-1)?.fact;
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Scout owns discovery. A complete fact must explicitly say so, name at least
|
|
337
|
+
* one target candidate and leave no unresolved paths. Existing surfaces must
|
|
338
|
+
* include fresh runtime evidence for a named target path. Greenfield
|
|
339
|
+
* surfaces are the one explicit exception: when runtime-injected source
|
|
340
|
+
* declarations prove that every named path was specified by the task source,
|
|
341
|
+
* all paths may be future (not yet on disk). This keeps create-new work
|
|
342
|
+
* possible without allowing Scout to invent an arbitrary path under the
|
|
343
|
+
* writer boundary. An empty test path list remains valid.
|
|
344
|
+
*/
|
|
345
|
+
export function readCompleteScoutTargetSurface(records) {
|
|
346
|
+
const fact = latestCommittedScoutTargetSurface(records);
|
|
347
|
+
if (!fact)
|
|
348
|
+
return {
|
|
349
|
+
ok: false,
|
|
350
|
+
reason: "frontend scout facts missing: no committed target-surface fact",
|
|
351
|
+
};
|
|
352
|
+
if (fact.completeness !== "complete")
|
|
353
|
+
return {
|
|
354
|
+
ok: false,
|
|
355
|
+
reason: "frontend scout target surface is not complete; resolve discovery gaps before Plan",
|
|
356
|
+
};
|
|
357
|
+
const unresolvedPaths = asStringArray(fact.unresolvedPaths);
|
|
358
|
+
if (unresolvedPaths.length > 0)
|
|
359
|
+
return {
|
|
360
|
+
ok: false,
|
|
361
|
+
reason: `frontend scout target surface has unresolved paths: ${unresolvedPaths.join(", ")}`,
|
|
362
|
+
};
|
|
363
|
+
const surface = {
|
|
364
|
+
entrypoint: asString(fact.entrypoint),
|
|
365
|
+
implementationPaths: canonicalStringSet(asStringArray(fact.implementationPaths)),
|
|
366
|
+
proposedPaths: canonicalStringSet(asStringArray(fact.proposedPaths)),
|
|
367
|
+
testPaths: canonicalStringSet(asStringArray(fact.testPaths)),
|
|
368
|
+
};
|
|
369
|
+
const namedPaths = canonicalStringSet([
|
|
370
|
+
...(surface.entrypoint ? [surface.entrypoint] : []),
|
|
371
|
+
...surface.implementationPaths,
|
|
372
|
+
...surface.proposedPaths,
|
|
373
|
+
...surface.testPaths,
|
|
374
|
+
]);
|
|
375
|
+
if (namedPaths.length === 0)
|
|
376
|
+
return {
|
|
377
|
+
ok: false,
|
|
378
|
+
reason: "frontend scout target surface is incomplete: name an entrypoint, implementation path, or test path",
|
|
379
|
+
};
|
|
380
|
+
const freshPaths = new Set(Array.isArray(fact.pathEvidence)
|
|
381
|
+
? fact.pathEvidence
|
|
382
|
+
.filter(isRecord)
|
|
383
|
+
.filter((item) => item.fresh === true)
|
|
384
|
+
.map((item) => asString(item.path))
|
|
385
|
+
.filter(Boolean)
|
|
386
|
+
: []);
|
|
387
|
+
const pathEvidence = Array.isArray(fact.pathEvidence)
|
|
388
|
+
? fact.pathEvidence.filter(isRecord)
|
|
389
|
+
: [];
|
|
390
|
+
const hasSourceDeclarationLedger = Array.isArray(fact.sourceDeclaredPaths);
|
|
391
|
+
const undeclaredFuturePaths = hasSourceDeclarationLedger
|
|
392
|
+
? namedPaths.filter((candidate) => {
|
|
393
|
+
const evidence = pathEvidence.find((item) => asString(item.path) === candidate);
|
|
394
|
+
return evidence?.fresh !== true && evidence?.sourceDeclared !== true && evidence?.proposed !== true;
|
|
395
|
+
})
|
|
396
|
+
: [];
|
|
397
|
+
if (undeclaredFuturePaths.length > 0)
|
|
398
|
+
return {
|
|
399
|
+
ok: false,
|
|
400
|
+
reason: `frontend scout target surface has future paths not declared by the task source: ${undeclaredFuturePaths.join(", ")}; test path is not declared by the task source, so do not guess test/ vs tests/ or other target directories`,
|
|
401
|
+
};
|
|
402
|
+
if (!namedPaths.some((candidate) => freshPaths.has(candidate))) {
|
|
403
|
+
const allPathsAreProposed = surface.proposedPaths.length > 0 &&
|
|
404
|
+
namedPaths.every((candidate) => surface.proposedPaths.includes(candidate) || freshPaths.has(candidate));
|
|
405
|
+
if (allPathsAreProposed)
|
|
406
|
+
return { ok: true, surface };
|
|
407
|
+
const allPathsAreSourceDeclaredFuturePaths = hasSourceDeclarationLedger &&
|
|
408
|
+
namedPaths.length > 0 &&
|
|
409
|
+
namedPaths.every((candidate) => {
|
|
410
|
+
const evidence = pathEvidence.find((item) => asString(item.path) === candidate);
|
|
411
|
+
return evidence?.fresh !== true && evidence?.sourceDeclared === true;
|
|
412
|
+
});
|
|
413
|
+
if (allPathsAreSourceDeclaredFuturePaths)
|
|
414
|
+
return { ok: true, surface };
|
|
415
|
+
return {
|
|
416
|
+
ok: false,
|
|
417
|
+
reason: "frontend scout target surface lacks fresh runtime evidence for a named target path; greenfield exceptions require runtime-injected source declarations for every future path",
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
return { ok: true, surface };
|
|
421
|
+
}
|
|
422
|
+
/** Paths with Scout ownership that Plan may read for a specific decision. */
|
|
423
|
+
export function scoutConfirmedReadPaths(records) {
|
|
424
|
+
const checked = readCompleteScoutTargetSurface(records);
|
|
425
|
+
if (!checked.ok)
|
|
426
|
+
return [];
|
|
427
|
+
return canonicalStringSet([
|
|
428
|
+
...(checked.surface.entrypoint ? [checked.surface.entrypoint] : []),
|
|
429
|
+
...checked.surface.implementationPaths,
|
|
430
|
+
...checked.surface.proposedPaths,
|
|
431
|
+
...checked.surface.testPaths,
|
|
432
|
+
]);
|
|
433
|
+
}
|
|
434
|
+
/** A+B (AC-001/003): fail-closed committed contract/scout fact prerequisites.
|
|
435
|
+
* `contract` requires a committed `contract-finalized` terminal fact; `scout`
|
|
436
|
+
* requires a complete target-surface fact. Missing or incomplete facts block
|
|
437
|
+
* downstream consumption — never fall back to text parsing. */
|
|
438
|
+
export function checkCommittedOriginFacts(input) {
|
|
439
|
+
const kinds = new Set(input.records
|
|
440
|
+
.filter((record) => record.phase === "committed")
|
|
441
|
+
.map((record) => record.fact.kind)
|
|
442
|
+
.filter((kind) => typeof kind === "string"));
|
|
443
|
+
if (input.origin === "contract") {
|
|
444
|
+
return kinds.has("contract-finalized")
|
|
445
|
+
? { ok: true }
|
|
446
|
+
: {
|
|
447
|
+
ok: false,
|
|
448
|
+
reason: "frontend contract facts missing: no committed contract-finalized terminal fact",
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
if (input.origin === "scout") {
|
|
452
|
+
if (!kinds.has("target-surface"))
|
|
453
|
+
return {
|
|
454
|
+
ok: false,
|
|
455
|
+
reason: "frontend scout facts missing: no committed target-surface fact",
|
|
456
|
+
};
|
|
457
|
+
const checked = readCompleteScoutTargetSurface(input.records);
|
|
458
|
+
return checked.ok ? { ok: true } : { ok: false, reason: checked.reason };
|
|
459
|
+
}
|
|
460
|
+
return { ok: true };
|
|
461
|
+
}
|