@tea-agent/loop-agent 0.1.0-fe-test.4 → 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 +442 -2524
- 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 +1517 -3180
- 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 +358 -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/map.js +15 -2
- 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 +14 -3
- package/dist/workflows/dag/frontend-test-case-generation-assessment.js +88 -0
- package/dist/workflows/dag/frontend-test-case-manifest.js +6 -1
- 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-test-result-contract.js +15 -1
- 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 -7077
- 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 +79 -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 +48 -39
- 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
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** Shared projections of committed frontend facts. Callers filter commit phase. */
|
|
3
|
+
function object(value) {
|
|
4
|
+
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
5
|
+
? value
|
|
6
|
+
: undefined;
|
|
7
|
+
}
|
|
8
|
+
/** Project the latest requirement per id while retaining first-seen order.
|
|
9
|
+
* The append-only ledger also contains earlier execution metadata revisions.
|
|
10
|
+
* Later evidence declarations replace only the lanes they explicitly name. */
|
|
11
|
+
export function resolveFrontendContractRequirements(facts) {
|
|
12
|
+
const contractFacts = facts.map(object).filter((fact) => fact?.origin === "contract");
|
|
13
|
+
const evidenceById = new Map();
|
|
14
|
+
for (const fact of contractFacts) {
|
|
15
|
+
if (fact.kind !== "evidence-expectation" ||
|
|
16
|
+
typeof fact.requirementId !== "string")
|
|
17
|
+
continue;
|
|
18
|
+
evidenceById.set(fact.requirementId, {
|
|
19
|
+
...evidenceById.get(fact.requirementId),
|
|
20
|
+
...object(fact.evidence),
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
const requirements = new Map();
|
|
24
|
+
for (const fact of contractFacts) {
|
|
25
|
+
if (fact.kind === "requirement" && typeof fact.id === "string")
|
|
26
|
+
requirements.set(fact.id, fact);
|
|
27
|
+
}
|
|
28
|
+
return [...requirements].map(([id, fact]) => ({
|
|
29
|
+
...fact, id,
|
|
30
|
+
evidence: { ...object(fact.evidence), ...evidenceById.get(id) },
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
function names(value) {
|
|
34
|
+
return Array.isArray(value)
|
|
35
|
+
? value.filter((item) => typeof item === "string" && item.trim().length > 0)
|
|
36
|
+
: [];
|
|
37
|
+
}
|
|
38
|
+
const evidenceStatus = z.enum(["required", "optional", "not-applicable"]);
|
|
39
|
+
export const frontendEvidenceExpectationSchema = z.object({
|
|
40
|
+
requirementId: z.string().min(1),
|
|
41
|
+
evidence: z.object({
|
|
42
|
+
static: evidenceStatus.optional(),
|
|
43
|
+
behavior: evidenceStatus.optional(),
|
|
44
|
+
mock: evidenceStatus.optional(),
|
|
45
|
+
"real-integration": evidenceStatus.optional(),
|
|
46
|
+
}).strict().refine((evidence) => Object.keys(evidence).length > 0, "declare at least one evidence lane"),
|
|
47
|
+
}).strict();
|
|
48
|
+
const concretePath = z.string().min(1).refine((value) => value === value.trim() &&
|
|
49
|
+
!/^[A-Za-z]:/.test(value) &&
|
|
50
|
+
!/[\\*?\[\]{}\0]/.test(value) &&
|
|
51
|
+
value.split("/").every((part) => part !== "" && part !== "." && part !== ".."), "must be a concrete relative POSIX file path without traversal");
|
|
52
|
+
export const frontendRequiredDeliverablesSchema = z.object({
|
|
53
|
+
items: z.array(z.object({
|
|
54
|
+
path: concretePath,
|
|
55
|
+
requirementId: z.string().min(1),
|
|
56
|
+
sourceFragmentId: z.string().min(1),
|
|
57
|
+
}).strict()),
|
|
58
|
+
}).strict();
|
|
59
|
+
/** Validate structure and provenance; the Contract model owns the distinction
|
|
60
|
+
* between delivery obligations, permissions, prohibitions and references. */
|
|
61
|
+
export function validateFrontendRequiredDeliverables(value, requirements) {
|
|
62
|
+
const declaration = frontendRequiredDeliverablesSchema.parse(value);
|
|
63
|
+
for (const item of declaration.items) {
|
|
64
|
+
const requirement = requirements.get(item.requirementId);
|
|
65
|
+
if (!requirement?.sourceFragmentIds.includes(item.sourceFragmentId)) {
|
|
66
|
+
throw new Error(`required deliverable ${item.path} has an unknown requirement/fragment binding`);
|
|
67
|
+
}
|
|
68
|
+
const text = requirement.sourceFragments?.get(item.sourceFragmentId);
|
|
69
|
+
const escaped = item.path.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
70
|
+
// A sentence-ending period is punctuation; a dot followed by filename
|
|
71
|
+
// characters is still part of the token (app.ts must not match app.ts.map).
|
|
72
|
+
const exactPath = new RegExp(`(^|[^\\p{L}\\p{N}_./-])${escaped}(?=$|[^\\p{L}\\p{N}_./-]|\\.(?=$|[^\\p{L}\\p{N}_./-]))`, "u");
|
|
73
|
+
if (!text || !exactPath.test(text)) {
|
|
74
|
+
throw new Error(`required deliverable ${item.path} is not an exact path in frozen source fragment ${item.sourceFragmentId}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return declaration;
|
|
78
|
+
}
|
|
79
|
+
/** Read the latest explicit inventory. Never infer obligations from prose. */
|
|
80
|
+
export function extractRequiredDeliverablePaths(facts) {
|
|
81
|
+
const declaration = facts.map(object).filter((fact) => fact?.origin === "contract" && fact.kind === "required-deliverables").at(-1);
|
|
82
|
+
if (!declaration)
|
|
83
|
+
return [];
|
|
84
|
+
const { items } = frontendRequiredDeliverablesSchema.parse({ items: declaration.items });
|
|
85
|
+
return [...new Set(items.map((item) => item.path))].sort();
|
|
86
|
+
}
|
|
87
|
+
/** Apply state-flow replacement/removal semantics exactly as the plan compiler does. */
|
|
88
|
+
export function collectCanonicalStateFlowNames(committedFacts, includeRegistry = false) {
|
|
89
|
+
const uiStateNames = new Set();
|
|
90
|
+
const interactionNames = new Set();
|
|
91
|
+
for (const value of committedFacts) {
|
|
92
|
+
const record = object(value);
|
|
93
|
+
if (!record || (record.phase !== undefined && record.phase !== "committed"))
|
|
94
|
+
continue;
|
|
95
|
+
const fact = object(record.fact) ?? record;
|
|
96
|
+
if (fact.origin !== "plan")
|
|
97
|
+
continue;
|
|
98
|
+
if (includeRegistry && fact.kind === "state-registry") {
|
|
99
|
+
uiStateNames.clear();
|
|
100
|
+
interactionNames.clear();
|
|
101
|
+
for (const name of names(fact.uiStateNames))
|
|
102
|
+
uiStateNames.add(name);
|
|
103
|
+
for (const name of names(fact.interactionNames))
|
|
104
|
+
interactionNames.add(name);
|
|
105
|
+
}
|
|
106
|
+
if (fact.kind !== "state-flow")
|
|
107
|
+
continue;
|
|
108
|
+
for (const name of names(fact.removeUiStateNames)) {
|
|
109
|
+
uiStateNames.delete(name);
|
|
110
|
+
}
|
|
111
|
+
for (const name of names(fact.removeInteractionNames)) {
|
|
112
|
+
interactionNames.delete(name);
|
|
113
|
+
}
|
|
114
|
+
for (const state of Array.isArray(fact.uiStates) ? fact.uiStates : []) {
|
|
115
|
+
if (!state || typeof state !== "object" || Array.isArray(state))
|
|
116
|
+
continue;
|
|
117
|
+
const name = state.name;
|
|
118
|
+
if (typeof name === "string" && name.trim())
|
|
119
|
+
uiStateNames.add(name);
|
|
120
|
+
}
|
|
121
|
+
for (const interaction of Array.isArray(fact.interactions)
|
|
122
|
+
? fact.interactions
|
|
123
|
+
: []) {
|
|
124
|
+
if (!interaction || typeof interaction !== "object" || Array.isArray(interaction)) {
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
const name = interaction.name;
|
|
128
|
+
if (typeof name === "string" && name.trim())
|
|
129
|
+
interactionNames.add(name);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return { uiStateNames, interactionNames };
|
|
133
|
+
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { deterministicSha256, } from "./frontend-implementation-contract.js";
|
|
2
2
|
import { pathMatchesPattern } from "../../shared/git-progress.js";
|
|
3
|
+
import { FRONTEND_MAX_IMPLEMENTATION_FILES } from "./frontend-capacity.js";
|
|
3
4
|
const SHA256_HEX = /^[a-f0-9]{64}$/;
|
|
4
5
|
const NPM_PACKAGE_NAME = /^(?:@[a-zA-Z0-9_.-]+\/)?[a-zA-Z0-9][a-zA-Z0-9_.-]*$/;
|
|
5
6
|
/** Max concrete implementation files a single writeSet may carry before the
|
|
6
7
|
* plan is asked to split. Kept at 15: beyond this, a single implement node's
|
|
7
8
|
* read/edit loop inflates provider context toward overflow. */
|
|
8
|
-
const MAX_WRITE_SET_FILES =
|
|
9
|
+
const MAX_WRITE_SET_FILES = FRONTEND_MAX_IMPLEMENTATION_FILES;
|
|
9
10
|
function normalizeRelativePath(value) {
|
|
10
11
|
return value.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
11
12
|
}
|
|
@@ -28,31 +29,37 @@ function sortFindings(findings) {
|
|
|
28
29
|
* visual UI-state dimension (it cannot cover behavioural interactions). */
|
|
29
30
|
export function checkUiDesignCoverage(contract) {
|
|
30
31
|
const findings = [];
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
//
|
|
34
|
-
//
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
-
const
|
|
32
|
+
// Explicit per-id coverage (dogfood r-plan-quality): one choice covers an
|
|
33
|
+
// interaction/state when its purpose equals the name OR the choice lists
|
|
34
|
+
// the name in covers. The old wildcards are gone — a single reuse-existing
|
|
35
|
+
// row no longer passes every interaction, and a non-empty stylingStrategy
|
|
36
|
+
// no longer passes every state.
|
|
37
|
+
const covered = new Set();
|
|
38
|
+
for (const choice of contract.uiComponentChoices ?? []) {
|
|
39
|
+
if (choice.purpose.trim())
|
|
40
|
+
covered.add(choice.purpose);
|
|
41
|
+
for (const id of choice.covers ?? []) {
|
|
42
|
+
if (id.trim())
|
|
43
|
+
covered.add(id);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
38
46
|
for (const state of contract.uiStates) {
|
|
39
47
|
if (!state.applicable)
|
|
40
48
|
continue;
|
|
41
|
-
|
|
42
|
-
if (!covered) {
|
|
49
|
+
if (!covered.has(state.name)) {
|
|
43
50
|
findings.push({
|
|
44
51
|
code: "ui-design-coverage-missing",
|
|
45
|
-
message: `applicable UI state "${state.name}"
|
|
52
|
+
message: `applicable UI state "${state.name}" is not covered by any uiComponentChoices purpose or covers entry`,
|
|
46
53
|
path: state.name,
|
|
47
54
|
});
|
|
48
55
|
}
|
|
49
56
|
}
|
|
50
57
|
for (const interaction of contract.interactions) {
|
|
51
|
-
if (
|
|
58
|
+
if (covered.has(interaction.name))
|
|
52
59
|
continue;
|
|
53
60
|
findings.push({
|
|
54
61
|
code: "ui-design-coverage-missing",
|
|
55
|
-
message: `interaction "${interaction.name}"
|
|
62
|
+
message: `interaction "${interaction.name}" is not covered by any uiComponentChoices purpose or covers entry`,
|
|
56
63
|
path: interaction.name,
|
|
57
64
|
});
|
|
58
65
|
}
|
|
@@ -158,7 +165,7 @@ export function checkMockStrategy(contract, allowedMockStrategies) {
|
|
|
158
165
|
* A component specReference must still not point into clearly non-component
|
|
159
166
|
* spec areas — templates and the ai_workspace governance subtree cannot be the
|
|
160
167
|
* authoritative component definition. */
|
|
161
|
-
export function checkComponentChoice(contract, componentSpecCandidatePaths) {
|
|
168
|
+
export function checkComponentChoice(contract, componentSpecCandidatePaths, options) {
|
|
162
169
|
const findings = [];
|
|
163
170
|
const candidates = new Set(componentSpecCandidatePaths.map(normalizeRelativePath));
|
|
164
171
|
const isNonComponentSpecArea = (path) => {
|
|
@@ -200,6 +207,23 @@ export function checkComponentChoice(contract, componentSpecCandidatePaths) {
|
|
|
200
207
|
});
|
|
201
208
|
}
|
|
202
209
|
}
|
|
210
|
+
else if (choice.decision === "reuse-existing") {
|
|
211
|
+
if (!(choice.evidencePath && choice.evidencePath.trim().length > 0)) {
|
|
212
|
+
findings.push({
|
|
213
|
+
code: "component-reuse-evidence-missing",
|
|
214
|
+
message: `reuse-existing component choice #${index} is missing evidencePath naming the existing repo file that proves the reuse; a greenfield path must use decision=new`,
|
|
215
|
+
path: choice.purpose,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
else if (options?.hasFreshPathEvidence &&
|
|
219
|
+
!options.hasFreshPathEvidence(choice.evidencePath)) {
|
|
220
|
+
findings.push({
|
|
221
|
+
code: "component-reuse-path-not-fresh",
|
|
222
|
+
message: `reuse-existing component choice #${index} evidencePath "${choice.evidencePath}" has no fresh existence evidence (path not found); reuse requires an existing file — use decision=new for greenfield paths`,
|
|
223
|
+
path: choice.evidencePath,
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
}
|
|
203
227
|
else if (choice.decision === "new") {
|
|
204
228
|
if (!choice.specReference || !choice.specReference.path) {
|
|
205
229
|
findings.push({
|
|
@@ -219,9 +243,9 @@ export function checkComponentChoice(contract, componentSpecCandidatePaths) {
|
|
|
219
243
|
});
|
|
220
244
|
return findings;
|
|
221
245
|
}
|
|
222
|
-
/** 5.
|
|
223
|
-
*
|
|
224
|
-
export function checkTargetPaths(contract, writeSetPatterns) {
|
|
246
|
+
/** 5. Implementation targets require write permission. Existing, safely
|
|
247
|
+
* resolved verification files may remain read-only outside that writeSet. */
|
|
248
|
+
export function checkTargetPaths(contract, writeSetPatterns, existingVerificationPaths = []) {
|
|
225
249
|
const findings = [];
|
|
226
250
|
// No frozen writeSet patterns (legacy / unconfigured run) → nothing to
|
|
227
251
|
// check; an empty pattern set must not report every file as out of scope.
|
|
@@ -236,7 +260,7 @@ export function checkTargetPaths(contract, writeSetPatterns) {
|
|
|
236
260
|
if (contract.targets.files.length > MAX_WRITE_SET_FILES) {
|
|
237
261
|
findings.push({
|
|
238
262
|
code: "write-set-too-large",
|
|
239
|
-
message: `implementation writeSet has ${contract.targets.files.length} files (limit ${MAX_WRITE_SET_FILES}); split the task
|
|
263
|
+
message: `implementation writeSet has ${contract.targets.files.length} files (limit ${MAX_WRITE_SET_FILES}); split the task at the Contract boundary so no single implement node exceeds the bound; preserve all required files`,
|
|
240
264
|
});
|
|
241
265
|
}
|
|
242
266
|
for (const file of contract.targets.files) {
|
|
@@ -251,7 +275,7 @@ export function checkTargetPaths(contract, writeSetPatterns) {
|
|
|
251
275
|
for (const target of contract.verificationTargets) {
|
|
252
276
|
if (target.mode === "static")
|
|
253
277
|
continue;
|
|
254
|
-
if (!matches(target.file)) {
|
|
278
|
+
if (!matches(target.file) && !existingVerificationPaths.includes(target.file)) {
|
|
255
279
|
findings.push({
|
|
256
280
|
code: "target-path-outside-write-set",
|
|
257
281
|
message: `verification target "${target.id}" file is outside the writeSet patterns: ${target.file}`,
|
|
@@ -371,6 +395,64 @@ export function checkDesignApproval(designApproval) {
|
|
|
371
395
|
}
|
|
372
396
|
return [];
|
|
373
397
|
}
|
|
398
|
+
/**
|
|
399
|
+
* UX vocabulary collisions (item ③, dogfood dag-1788504923861-0f7b17a9):
|
|
400
|
+
* prioritize-planner-task / prioritizePlannerTask / prioritize-planner-tasks
|
|
401
|
+
* are one behavior renamed three ways. Case/separator-insensitive duplicates
|
|
402
|
+
* inside interactions or inside uiStates are blocking.
|
|
403
|
+
*/
|
|
404
|
+
export function checkUxNameCollisions(contract) {
|
|
405
|
+
const findings = [];
|
|
406
|
+
const normalize = (name) => name.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
407
|
+
const collisions = (names, kind) => {
|
|
408
|
+
const byNormalized = new Map();
|
|
409
|
+
const found = [];
|
|
410
|
+
for (const name of names) {
|
|
411
|
+
const key = normalize(name);
|
|
412
|
+
if (!key)
|
|
413
|
+
continue;
|
|
414
|
+
const existing = byNormalized.get(key);
|
|
415
|
+
if (existing !== undefined && existing !== name) {
|
|
416
|
+
found.push({
|
|
417
|
+
code: "ux-name-collision",
|
|
418
|
+
message: `"${name}" and "${existing}" are the same ${kind} name up to case/separator — one behavior must keep one stable name`,
|
|
419
|
+
path: name,
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
byNormalized.set(key, name);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
return found;
|
|
427
|
+
};
|
|
428
|
+
findings.push(...collisions(contract.interactions.map((interaction) => interaction.name), "interaction"));
|
|
429
|
+
findings.push(...collisions(contract.uiStates.map((state) => state.name), "UI state"));
|
|
430
|
+
return findings;
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Deliverable completeness (item ⑦): every file explicitly declared by Contract
|
|
434
|
+
* from frozen source fragments (projected into targets.requiredDeliverables)
|
|
435
|
+
* must be planned — bound by some requirement's implementationTargets or a
|
|
436
|
+
* verification target's file, or listed in targets.files. allowedPaths is a
|
|
437
|
+
* write boundary and never implies coverage.
|
|
438
|
+
*/
|
|
439
|
+
export function checkRequiredDeliverables(contract) {
|
|
440
|
+
const required = contract.targets.requiredDeliverables ?? [];
|
|
441
|
+
if (required.length === 0)
|
|
442
|
+
return [];
|
|
443
|
+
const planned = new Set([
|
|
444
|
+
...contract.targets.files,
|
|
445
|
+
...contract.requirements.flatMap((requirement) => [...requirement.implementationTargets, ...(requirement.deliverableTargets ?? [])]),
|
|
446
|
+
...contract.verificationTargets.map((target) => target.file),
|
|
447
|
+
]);
|
|
448
|
+
return required
|
|
449
|
+
.filter((path) => !planned.has(path))
|
|
450
|
+
.map((path) => ({
|
|
451
|
+
code: "required-deliverable-unplanned",
|
|
452
|
+
message: `Contract declares required deliverable "${path}" but no requirement implementationTarget, verification target, or targets.files entry plans it`,
|
|
453
|
+
path,
|
|
454
|
+
}));
|
|
455
|
+
}
|
|
374
456
|
/** Aggregate the deterministic design-policy checks into a single
|
|
375
457
|
* deterministic result. Any finding blocks; an empty finding list approves. */
|
|
376
458
|
export function evaluateFrontendDesignPolicy(input) {
|
|
@@ -379,10 +461,14 @@ export function evaluateFrontendDesignPolicy(input) {
|
|
|
379
461
|
...checkUiDesignCoverage(input.contract),
|
|
380
462
|
...checkSourceFreshness(input.contract, input.sourceFreshness),
|
|
381
463
|
...checkMockStrategy(input.contract, input.allowedMockStrategies),
|
|
382
|
-
...checkComponentChoice(input.contract, input.componentSpecCandidatePaths
|
|
383
|
-
|
|
464
|
+
...checkComponentChoice(input.contract, input.componentSpecCandidatePaths, input.hasFreshPathEvidence
|
|
465
|
+
? { hasFreshPathEvidence: input.hasFreshPathEvidence }
|
|
466
|
+
: undefined),
|
|
467
|
+
...checkTargetPaths(input.contract, input.writeSetPatterns, input.existingVerificationPaths),
|
|
384
468
|
...checkDependencies(input.contract, input.allowedDependencies),
|
|
385
469
|
...checkUiStateAttribution(input.contract),
|
|
470
|
+
...checkUxNameCollisions(input.contract),
|
|
471
|
+
...checkRequiredDeliverables(input.contract),
|
|
386
472
|
]);
|
|
387
473
|
const classification = findings.length > 0 ? "blocked" : "approved";
|
|
388
474
|
const result = {
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { frontendPlanSemanticDigest } from "./frontend-plan-progress.js";
|
|
2
|
+
import { mkdir, open, rename, rm } from "node:fs/promises";
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { Check, Errors } from "typebox/value";
|
|
6
|
+
import { sha256OfCanonicalJson } from "../../task/contract/hash.js";
|
|
7
|
+
import { assertHarnessWriteAllowed } from "../../infrastructure/harness/completed-facts-guard.js";
|
|
8
|
+
import { readTypedEventStoreFromJsonl, typedEventPayloadSha256, hasCommittedTerminalEvent } from "./frontend-typed-event-store.js";
|
|
9
|
+
const queues = new Map();
|
|
10
|
+
const progressByTool = new WeakMap();
|
|
11
|
+
/** Process-local telemetry only; durable facts remain the authority. */
|
|
12
|
+
export function readFrontendToolProgress(tools) {
|
|
13
|
+
const counters = [...new Set((tools ?? []).flatMap(tool => tool && typeof tool === "object" && progressByTool.has(tool) ? [progressByTool.get(tool)] : []))];
|
|
14
|
+
if (!counters.length)
|
|
15
|
+
return undefined;
|
|
16
|
+
return counters.reduce((sum, item) => ({ finalizeRejections: sum.finalizeRejections + item.finalizeRejections, failedRecords: sum.failedRecords + item.failedRecords, duplicateRecords: sum.duplicateRecords + item.duplicateRecords, durableSubmissions: sum.durableSubmissions + item.durableSubmissions, durableReplacements: sum.durableReplacements + item.durableReplacements }), { finalizeRejections: 0, failedRecords: 0, duplicateRecords: 0, durableSubmissions: 0, durableReplacements: 0 });
|
|
17
|
+
}
|
|
18
|
+
async function exclusive(key, work) {
|
|
19
|
+
const previous = queues.get(key) ?? Promise.resolve();
|
|
20
|
+
const current = previous.catch(() => { }).then(work);
|
|
21
|
+
queues.set(key, current);
|
|
22
|
+
try {
|
|
23
|
+
return await current;
|
|
24
|
+
}
|
|
25
|
+
finally {
|
|
26
|
+
if (queues.get(key) === current)
|
|
27
|
+
queues.delete(key);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const hash = (value) => sha256OfCanonicalJson(JSON.parse(JSON.stringify(value, (_key, v) => v instanceof Map ? [...v.entries()].sort(([a], [b]) => String(a).localeCompare(String(b))) : v)));
|
|
31
|
+
const ledgerError = (code, message) => Object.assign(new Error(message), { code });
|
|
32
|
+
/** Singleton finalize tools: their committed fact is a run terminal and their
|
|
33
|
+
* params are an acknowledgement, not domain data (see replay rule below). */
|
|
34
|
+
const FINALIZE_TERMINAL_TOOLS = new Set(["finalize_contract", "finalize_plan", "finalize_decision"]);
|
|
35
|
+
const failure = (code, error) => ({ content: [{ type: "text", text: JSON.stringify({ ok: false, code, error }) }], details: { ok: false, code, error } });
|
|
36
|
+
/** A failed rename must never fall back to copying over a live ledger. */
|
|
37
|
+
async function persist(file, records) {
|
|
38
|
+
assertHarnessWriteAllowed(file);
|
|
39
|
+
await mkdir(path.dirname(file), { recursive: true, mode: 0o700 });
|
|
40
|
+
const temporary = `${file}.${randomUUID()}.tmp`;
|
|
41
|
+
try {
|
|
42
|
+
const handle = await open(temporary, "wx", 0o600);
|
|
43
|
+
try {
|
|
44
|
+
await handle.writeFile(records.map(r => JSON.stringify(r)).join("\n") + (records.length ? "\n" : ""));
|
|
45
|
+
await handle.sync();
|
|
46
|
+
}
|
|
47
|
+
finally {
|
|
48
|
+
await handle.close();
|
|
49
|
+
}
|
|
50
|
+
await rename(temporary, file);
|
|
51
|
+
}
|
|
52
|
+
finally {
|
|
53
|
+
await rm(temporary, { force: true }).catch(() => { });
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/** One queue covers schema checks, semantic checks, all facts in a tool call,
|
|
57
|
+
* atomic persistence, and acknowledgement. The model never sees a draft as saved. */
|
|
58
|
+
export async function createDurableFrontendTools(input) {
|
|
59
|
+
const file = path.resolve(input.file);
|
|
60
|
+
const tools = input.tools.map(tool => {
|
|
61
|
+
const schema = tool.parameters;
|
|
62
|
+
return { ...tool, parameters: { ...schema, properties: { ...schema.properties, replace: { type: "boolean", description: "Explicitly revise the current fact with the same identity. Omit for new facts or identical replay." } } } };
|
|
63
|
+
});
|
|
64
|
+
const bindingSha256 = hash({ version: 1, attemptId: input.attemptId, binding: input.binding, schemas: tools.map(t => ({ name: t.name, parameters: t.parameters })) });
|
|
65
|
+
const publish = (store) => { input.store.records = store.records; input.store.revision = store.revision; input.setWorkingStore(input.store); if (hasCommittedTerminalEvent(store, input.attemptId))
|
|
66
|
+
input.planControl?.acceptTerminal(); };
|
|
67
|
+
const validate = async (records) => {
|
|
68
|
+
let revision = 0;
|
|
69
|
+
let terminal = false;
|
|
70
|
+
const ids = new Set();
|
|
71
|
+
const requests = new Set();
|
|
72
|
+
for (const r of records) {
|
|
73
|
+
if (r.attemptId !== input.attemptId || r.submission?.bindingSha256 !== bindingSha256)
|
|
74
|
+
throw ledgerError("FRONTEND_LEDGER_BINDING_MISMATCH", "frontend ledger binding/scope mismatch; preserve evidence and restart its owning phase");
|
|
75
|
+
if (r.phase !== "committed" || r.payloadSha256 !== typedEventPayloadSha256(r.fact) || r.revision <= revision || ids.has(r.eventId) || requests.has(r.requestId) || terminal)
|
|
76
|
+
throw ledgerError("FRONTEND_LEDGER_INTEGRITY_INVALID", "frontend ledger integrity/revision mismatch");
|
|
77
|
+
ids.add(r.eventId);
|
|
78
|
+
requests.add(r.requestId);
|
|
79
|
+
revision = r.revision;
|
|
80
|
+
terminal = hasCommittedTerminalEvent({ records: [r], revision }, input.attemptId);
|
|
81
|
+
}
|
|
82
|
+
await input.validateRestored?.(records);
|
|
83
|
+
};
|
|
84
|
+
const restore = async () => {
|
|
85
|
+
const records = await readTypedEventStoreFromJsonl(file);
|
|
86
|
+
if (records.length) {
|
|
87
|
+
await validate(records);
|
|
88
|
+
publish({ records, revision: records.at(-1).revision });
|
|
89
|
+
}
|
|
90
|
+
else if (input.store.records.some(r => r.submission))
|
|
91
|
+
throw ledgerError("FRONTEND_LEDGER_MISSING", "frontend durable ledger disappeared or became empty; refusing an unproven acknowledgement");
|
|
92
|
+
};
|
|
93
|
+
await exclusive(file, restore);
|
|
94
|
+
const progress = { finalizeRejections: 0, failedRecords: 0, duplicateRecords: 0, durableSubmissions: 0, durableReplacements: 0 };
|
|
95
|
+
const replay = (receipt) => { progress.duplicateRecords++; return receipt; };
|
|
96
|
+
const wrapped = tools.map(tool => ({ ...tool, execute: (...args) => exclusive(file, async () => {
|
|
97
|
+
const beforeRevision = input.store.revision;
|
|
98
|
+
const execute = async () => {
|
|
99
|
+
const stopped = input.planControl?.readStop();
|
|
100
|
+
if (stopped)
|
|
101
|
+
return failure(stopped.code, stopped.error);
|
|
102
|
+
const [callId, params] = args;
|
|
103
|
+
const valid = Check(tool.parameters, params);
|
|
104
|
+
if (!valid) {
|
|
105
|
+
const errors = [...Errors(tool.parameters, params)];
|
|
106
|
+
return failure("TOOL_SCHEMA_INVALID", `${tool.name}: ${errors.slice(0, 8).map(e => `${e.instancePath || "/"}: ${e.message}`).join("; ")}${errors.length > 8 ? `; ${errors.length - 8} more fields` : ""}`);
|
|
107
|
+
}
|
|
108
|
+
try {
|
|
109
|
+
await restore();
|
|
110
|
+
const isReviewFinding = ["record_review_finding", "record_design_finding"].includes(tool.name);
|
|
111
|
+
const paramsSha256 = hash(isReviewFinding ? { ...params, replace: undefined } : params);
|
|
112
|
+
const singleton = new Set(["record_route_selection", "record_state_registry", "record_mock_api", "record_data_flow", "record_dependency", "record_design_deviation", "record_required_deliverables", "record_target_surface", "finalize_contract", "finalize_plan", "finalize_decision"]);
|
|
113
|
+
const naturalId = params?.id ?? params?.scopeId ?? params?.entry?.id ?? params?.requirementId ?? params?.choice?.purpose ?? params?.entry?.purpose ?? params?.entry?.state ?? params?.entry?.interaction ?? params?.entry?.boundary ?? (tool.name === "record_openspec_selection" ? params?.path : undefined) ?? (params?.endpoint ? `${params.endpoint.method}:${params.endpoint.path}` : undefined) ?? (singleton.has(tool.name) ? "singleton" : undefined);
|
|
114
|
+
const identity = `${tool.name}:${typeof naturalId === "string" ? naturalId : "incremental"}`;
|
|
115
|
+
const submissions = input.store.records.flatMap(r => r.submission?.receipt ? [r.submission] : []);
|
|
116
|
+
const previousCall = submissions.find(s => s.callId === callId);
|
|
117
|
+
if (previousCall)
|
|
118
|
+
return previousCall.tool === tool.name && previousCall.paramsSha256 === paramsSha256 ? replay(previousCall.receipt) : failure("REQUEST_ID_REUSE_CONFLICT", `${tool.name}: call id already acknowledged with different parameters`);
|
|
119
|
+
const previousFact = submissions.filter(s => s.identity === identity).at(-1);
|
|
120
|
+
if (isReviewFinding && !previousFact && params?.replace === true)
|
|
121
|
+
return failure("FACT_REPLACEMENT_NOT_FOUND", `${identity}: replacement requires an existing finding; omit replace to create it`);
|
|
122
|
+
if (tool.name !== "record_plan_group_coverage" && previousFact?.paramsSha256 === paramsSha256)
|
|
123
|
+
return replay(previousFact.receipt);
|
|
124
|
+
// A committed finalize terminal carries no domain payload in its params
|
|
125
|
+
// (r15: the model acknowledged with {replace:false}, the executor's
|
|
126
|
+
// auto-finalize sends {}) — both are acknowledgements of the same durable
|
|
127
|
+
// terminal, so any later finalize call replays the receipt instead of
|
|
128
|
+
// demanding a params match no caller can reproduce. Other singletons
|
|
129
|
+
// (state registry, data flows, ...) carry domain payloads and keep the
|
|
130
|
+
// replace:true correction path.
|
|
131
|
+
if (FINALIZE_TERMINAL_TOOLS.has(tool.name) && previousFact?.receipt)
|
|
132
|
+
return replay(previousFact.receipt);
|
|
133
|
+
if (previousFact && naturalId !== undefined && params?.replace !== true && !["record_evidence_expectation", "record_required_deliverables", "record_data_flow"].includes(tool.name))
|
|
134
|
+
return failure("FACT_IDENTITY_CONFLICT", `${identity}: changing a saved fact requires explicit replacement (replace:true)`);
|
|
135
|
+
if (input.store.records.some(r => ["contract-finalized", "finalize_plan", "finalize_decision", "approve_review", "request_review_changes", "approve_design", "request_design_changes"].includes(String(r.fact.kind))))
|
|
136
|
+
return failure("TERMINAL_CONFLICT", "A successful terminal is already durable; only identical acknowledged submissions may be replayed");
|
|
137
|
+
const draft = structuredClone(input.store);
|
|
138
|
+
input.setWorkingStore(draft);
|
|
139
|
+
let result;
|
|
140
|
+
try {
|
|
141
|
+
// Protocol controls must not be spread into domain facts by permissive callers.
|
|
142
|
+
const original = input.tools.find(t => t.name === tool.name);
|
|
143
|
+
const domainParams = { ...params };
|
|
144
|
+
if (!original.parameters.properties?.replace)
|
|
145
|
+
delete domainParams.replace;
|
|
146
|
+
result = await tool.execute(args[0], domainParams, ...args.slice(2));
|
|
147
|
+
}
|
|
148
|
+
finally {
|
|
149
|
+
input.setWorkingStore(input.store);
|
|
150
|
+
}
|
|
151
|
+
if (result.details?.ok !== true)
|
|
152
|
+
return result;
|
|
153
|
+
const newRecords = draft.records.filter(r => r.phase === "committed" && r.revision > input.store.revision);
|
|
154
|
+
if (!newRecords.length)
|
|
155
|
+
return replay(result);
|
|
156
|
+
for (const record of draft.records) {
|
|
157
|
+
record.submission ??= { version: 1, bindingSha256, tool: "bootstrap", callId: record.requestId, identity: record.eventId, paramsSha256: record.payloadSha256 };
|
|
158
|
+
}
|
|
159
|
+
for (const record of newRecords)
|
|
160
|
+
record.submission = { version: 1, bindingSha256, tool: tool.name, callId, identity, paramsSha256 };
|
|
161
|
+
newRecords.at(-1).submission.receipt = JSON.parse(JSON.stringify(result));
|
|
162
|
+
const committed = draft.records.filter(r => r.phase === "committed");
|
|
163
|
+
await validate(committed);
|
|
164
|
+
await persist(file, committed);
|
|
165
|
+
publish(draft);
|
|
166
|
+
progress.durableSubmissions++;
|
|
167
|
+
if (previousFact)
|
|
168
|
+
progress.durableReplacements++;
|
|
169
|
+
return result;
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
input.setWorkingStore(input.store);
|
|
173
|
+
return failure(typeof error?.code === "string" ? error.code : "FRONTEND_COMMIT_FAILED", error instanceof Error ? error.message : String(error));
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
const result = await execute();
|
|
177
|
+
if (result.details?.ok !== true) {
|
|
178
|
+
progress.failedRecords++;
|
|
179
|
+
if (FINALIZE_TERMINAL_TOOLS.has(tool.name))
|
|
180
|
+
progress.finalizeRejections++;
|
|
181
|
+
}
|
|
182
|
+
const note = input.planControl?.observe(tool.name, args[1], result.details, input.store.revision > beforeRevision, input.planControl ? frontendPlanSemanticDigest(input.store.records) : undefined);
|
|
183
|
+
if (note)
|
|
184
|
+
return { ...result, content: [...(Array.isArray(result.content) ? result.content : []), { type: "text", text: JSON.stringify(note) }], details: { ...result.details, planProgress: note } };
|
|
185
|
+
return result;
|
|
186
|
+
}) }));
|
|
187
|
+
for (const tool of wrapped)
|
|
188
|
+
progressByTool.set(tool, progress);
|
|
189
|
+
return {
|
|
190
|
+
customTools: wrapped,
|
|
191
|
+
commitExternal: (work) => exclusive(file, async () => {
|
|
192
|
+
await restore();
|
|
193
|
+
const draft = structuredClone(input.store);
|
|
194
|
+
input.setWorkingStore(draft);
|
|
195
|
+
try {
|
|
196
|
+
await work();
|
|
197
|
+
const newRecords = draft.records.filter(r => r.phase === "committed" && r.revision > input.store.revision);
|
|
198
|
+
for (const record of draft.records) {
|
|
199
|
+
record.submission ??= {
|
|
200
|
+
version: 1,
|
|
201
|
+
bindingSha256,
|
|
202
|
+
tool: "external-adoption",
|
|
203
|
+
callId: record.requestId,
|
|
204
|
+
identity: record.eventId,
|
|
205
|
+
paramsSha256: record.payloadSha256,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
const committed = draft.records.filter(r => r.phase === "committed");
|
|
209
|
+
await validate(committed);
|
|
210
|
+
await persist(file, committed);
|
|
211
|
+
publish(draft);
|
|
212
|
+
progress.durableSubmissions += newRecords.length;
|
|
213
|
+
}
|
|
214
|
+
finally {
|
|
215
|
+
input.setWorkingStore(input.store);
|
|
216
|
+
}
|
|
217
|
+
}),
|
|
218
|
+
flush: () => exclusive(file, async () => {
|
|
219
|
+
await restore();
|
|
220
|
+
const committed = input.store.records.filter(r => r.phase === "committed");
|
|
221
|
+
await validate(committed);
|
|
222
|
+
await persist(file, committed);
|
|
223
|
+
}),
|
|
224
|
+
};
|
|
225
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** Model-authored execution ownership; never replaces a source obligation. */
|
|
3
|
+
export const frontendExecutionSchema = z.object({
|
|
4
|
+
groupId: z.string().trim().min(1),
|
|
5
|
+
kind: z.enum(["behavior", "constraint", "exclusion"]),
|
|
6
|
+
summary: z.string().trim().min(1),
|
|
7
|
+
}).strict();
|
|
8
|
+
/** Latest canonical member wins; joining a group requires consistent metadata.
|
|
9
|
+
* No lexical/semantic similarity heuristic can erase a source ID or condition. */
|
|
10
|
+
export function collectFrontendExecutionGroups(units) {
|
|
11
|
+
const groups = new Map();
|
|
12
|
+
for (const unit of new Map(units.map(unit => [unit.id, unit])).values()) {
|
|
13
|
+
const execution = unit.execution === undefined ? undefined : frontendExecutionSchema.parse(unit.execution);
|
|
14
|
+
const key = execution ? `group:${execution.groupId}` : `requirement:${unit.id}`;
|
|
15
|
+
const previous = groups.get(key);
|
|
16
|
+
if (previous && execution && (previous.kind !== execution.kind || previous.summary !== execution.summary))
|
|
17
|
+
throw Error(`EXECUTION_GROUP_CONFLICT: ${execution.groupId}; preserve differing permissions, thresholds and error paths as separate obligations/groups`);
|
|
18
|
+
if (previous)
|
|
19
|
+
previous.requirementIds.push(unit.id);
|
|
20
|
+
else
|
|
21
|
+
groups.set(key, { id: execution?.groupId ?? unit.id, kind: execution?.kind ?? "unclassified", summary: execution?.summary ?? `Independent requirement ${unit.id}`, requirementIds: [unit.id] });
|
|
22
|
+
}
|
|
23
|
+
return [...groups.values()];
|
|
24
|
+
}
|