@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
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { inspectRouteStates } from "../state.js";
|
|
2
|
+
import { mergeTaskHistoryPage } from "../task-history.js";
|
|
1
3
|
/** Observe UI view module (R5). */
|
|
2
4
|
import {
|
|
3
5
|
UI_TEXT,
|
|
@@ -16,7 +18,7 @@ import {
|
|
|
16
18
|
DAG_EFFECTIVE_STATUS_LABELS,
|
|
17
19
|
STATUS_LABELS,
|
|
18
20
|
} from "../constants.js";
|
|
19
|
-
import { clearNode, el, metaGrid, buildTable } from "../dom.js";
|
|
21
|
+
import { clearNode, el, metaGrid, buildTable, reconcileKeyed } from "../dom.js";
|
|
20
22
|
import {
|
|
21
23
|
badge,
|
|
22
24
|
badgeClass,
|
|
@@ -45,6 +47,7 @@ import {
|
|
|
45
47
|
import {
|
|
46
48
|
fetchJson,
|
|
47
49
|
fetchJsonResult,
|
|
50
|
+
summarizeFetchError,
|
|
48
51
|
artifactUrl,
|
|
49
52
|
parseArtifactPreviewResponse,
|
|
50
53
|
} from "../api.js";
|
|
@@ -66,7 +69,7 @@ import {
|
|
|
66
69
|
renderViewState,
|
|
67
70
|
mountViewState,
|
|
68
71
|
} from "../state.js";
|
|
69
|
-
import { uiState } from "../state.js";
|
|
72
|
+
import { uiState, taskHistoryStates, workspaceScope } from "../state.js";
|
|
70
73
|
import { sortPoolTasks } from "../format-pool.js";
|
|
71
74
|
import {
|
|
72
75
|
dagMetaVisibility,
|
|
@@ -75,7 +78,7 @@ import {
|
|
|
75
78
|
findDagForRun,
|
|
76
79
|
} from "../dag-model.js";
|
|
77
80
|
import { layoutDag } from "../dag-layout.js";
|
|
78
|
-
import { showView, setBreadcrumb, updateHeaderRefresh, mountRelationBar } from "../shell-chrome.js";
|
|
81
|
+
import { showView, setBreadcrumb, updateHeaderRefresh, mountRelationBar, bindManualViewRefresh } from "../shell-chrome.js";
|
|
79
82
|
import { artifactLink } from "../kpi.js";
|
|
80
83
|
import { findBatchRunIdForTask, taskRunHistoryRow } from "../run-processing.js";
|
|
81
84
|
|
|
@@ -91,7 +94,7 @@ export async function renderTaskDetail(featureId, taskId) {
|
|
|
91
94
|
showView("task");
|
|
92
95
|
setBreadcrumb([
|
|
93
96
|
{ label: UI_TEXT.dashboard, href: "#/" },
|
|
94
|
-
{ label: "资源池", href: "/#/inspect/pool" },
|
|
97
|
+
{ label: "资源池", href: inspectRouteStates.get("return-list") ?? "/#/inspect/pool" },
|
|
95
98
|
{ label: displayLabel },
|
|
96
99
|
]);
|
|
97
100
|
|
|
@@ -103,13 +106,29 @@ export async function renderTaskDetail(featureId, taskId) {
|
|
|
103
106
|
const ledgerEl = document.getElementById("task-ledger");
|
|
104
107
|
if (!metaEl || !linksEl || !evidenceEl || !runsEl) return false;
|
|
105
108
|
if (titleEl) titleEl.textContent = displayLabel;
|
|
106
|
-
|
|
109
|
+
const identity = `${workspaceScope() ?? ""}:${featureId ?? ""}:${taskId}`;
|
|
110
|
+
const requestGeneration = uiState.pollingGeneration;
|
|
111
|
+
if (metaEl.dataset.taskIdentity !== identity) {
|
|
112
|
+
metaEl.dataset.taskIdentity = identity;
|
|
113
|
+
mountViewState(metaEl, "loading", "加载 Task…");
|
|
114
|
+
clearNode(runsEl);
|
|
115
|
+
for (const element of [linksEl, evidenceEl, ledgerEl]) if (element) clearNode(element);
|
|
116
|
+
}
|
|
117
|
+
if (!taskHistoryStates.has(identity)) taskHistoryStates.set(identity, { runs: [], nextBefore: null, loadedOlder: false, loadingOlder: false });
|
|
118
|
+
const historyState = taskHistoryStates.get(identity);
|
|
107
119
|
|
|
108
120
|
const [taskResult, historyResult, snapshot] = await Promise.all([
|
|
109
121
|
fetchJsonResult(taskApi),
|
|
110
122
|
fetchJsonResult(`${taskApi}/runs?limit=20`),
|
|
111
123
|
fetchJson("/api/snapshot"),
|
|
112
124
|
]);
|
|
125
|
+
if (requestGeneration !== uiState.pollingGeneration || metaEl.dataset.taskIdentity !== identity) return false;
|
|
126
|
+
if (!taskResult.ok && ![404, 409].includes(taskResult.status)) {
|
|
127
|
+
let error = metaEl.querySelector(".task-refresh-error");
|
|
128
|
+
if (!error) { error = el("p", "task-refresh-error node-input-error"); metaEl.appendChild(error); }
|
|
129
|
+
error.textContent = `更新失败,保留上次内容。${summarizeFetchError(taskResult)}`;
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
113
132
|
const task = taskResult.ok ? taskResult.body : null;
|
|
114
133
|
const history = historyResult.ok ? historyResult.body : null;
|
|
115
134
|
if (snapshot) {
|
|
@@ -120,7 +139,6 @@ export async function renderTaskDetail(featureId, taskId) {
|
|
|
120
139
|
clearNode(metaEl);
|
|
121
140
|
clearNode(linksEl);
|
|
122
141
|
clearNode(evidenceEl);
|
|
123
|
-
clearNode(runsEl);
|
|
124
142
|
|
|
125
143
|
if (!task) {
|
|
126
144
|
if (taskResult.status === 409) {
|
|
@@ -234,27 +252,9 @@ export async function renderTaskDetail(featureId, taskId) {
|
|
|
234
252
|
evidenceEl.appendChild(evidenceLinks);
|
|
235
253
|
}
|
|
236
254
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
mountViewState(runsEl, "empty", "暂无 ledger 运行记录。");
|
|
241
|
-
} else {
|
|
242
|
-
const rows = runs.map(taskRunHistoryRow);
|
|
243
|
-
runsEl.appendChild(
|
|
244
|
-
buildTable(
|
|
245
|
-
["worker run", "状态", "时间", "batch", "retryOf", "失败分类"],
|
|
246
|
-
rows,
|
|
247
|
-
),
|
|
248
|
-
);
|
|
249
|
-
if (history?.nextBefore) {
|
|
250
|
-
const more = el("button", "link-button", "加载更早的运行");
|
|
251
|
-
more.type = "button";
|
|
252
|
-
more.addEventListener("click", () => {
|
|
253
|
-
void loadOlderTaskRuns(featureId, taskId, history.nextBefore, runsEl);
|
|
254
|
-
});
|
|
255
|
-
runsEl.appendChild(more);
|
|
256
|
-
}
|
|
257
|
-
}
|
|
255
|
+
if (history) mergeTaskHistoryPage(historyState, history);
|
|
256
|
+
else historyState.error = summarizeFetchError(historyResult);
|
|
257
|
+
renderTaskHistory(runsEl, historyState, featureId, taskId, identity);
|
|
258
258
|
|
|
259
259
|
const active = ["running", "pending", "blocked", "stale"].includes(
|
|
260
260
|
(task.status ?? "").toLowerCase(),
|
|
@@ -262,6 +262,8 @@ export async function renderTaskDetail(featureId, taskId) {
|
|
|
262
262
|
if (ledgerEl) {
|
|
263
263
|
void renderTaskLedger(ledgerEl, taskId);
|
|
264
264
|
}
|
|
265
|
+
updateHeaderRefresh(snapshot?.generatedAt ?? uiState.lastSnapshot?.generatedAt, { mode: active ? "auto" : "ended" });
|
|
266
|
+
bindManualViewRefresh("task", () => renderTaskDetail(featureId, taskId));
|
|
265
267
|
return active;
|
|
266
268
|
}
|
|
267
269
|
|
|
@@ -315,42 +317,59 @@ async function renderTaskLedger(ledgerEl, taskId) {
|
|
|
315
317
|
ledgerEl.appendChild(pre);
|
|
316
318
|
}
|
|
317
319
|
|
|
318
|
-
|
|
319
|
-
if (runsEl
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
320
|
+
function renderTaskHistory(runsEl, state, featureId, taskId, identity) {
|
|
321
|
+
if (runsEl.dataset.historyIdentity !== identity) { clearNode(runsEl); runsEl.dataset.historyIdentity = identity; }
|
|
322
|
+
let table = runsEl.querySelector("table");
|
|
323
|
+
if (!table) {
|
|
324
|
+
runsEl.appendChild(el("h3", "section-heading", "运行历史"));
|
|
325
|
+
table = buildTable(["worker run", "状态", "时间", "batch", "retryOf", "失败分类"], []);
|
|
326
|
+
runsEl.appendChild(table);
|
|
327
|
+
const status = el("p", "muted task-history-status");
|
|
328
|
+
status.setAttribute("role", "status");
|
|
329
|
+
runsEl.appendChild(status);
|
|
330
|
+
const more = el("button", "link-button", "加载更早的运行");
|
|
331
|
+
more.type = "button";
|
|
332
|
+
more.addEventListener("click", () => { void loadOlderTaskRuns(featureId, taskId, state.nextBefore, runsEl); });
|
|
333
|
+
runsEl.appendChild(more);
|
|
324
334
|
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
:
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
335
|
+
reconcileKeyed(table.querySelector("tbody"), state.runs, {
|
|
336
|
+
getKey: (run) => run.workerRunId,
|
|
337
|
+
create: () => el("tr"),
|
|
338
|
+
update: (row, run) => {
|
|
339
|
+
const signature = JSON.stringify(run);
|
|
340
|
+
if (row.dataset.signature === signature) return;
|
|
341
|
+
clearNode(row);
|
|
342
|
+
for (const cell of taskRunHistoryRow(run).cells) {
|
|
343
|
+
const td = el("td");
|
|
344
|
+
if (cell instanceof Node) td.appendChild(cell); else td.textContent = cell ?? "—";
|
|
345
|
+
row.appendChild(td);
|
|
346
|
+
}
|
|
347
|
+
row.dataset.signature = signature;
|
|
348
|
+
},
|
|
349
|
+
});
|
|
350
|
+
const status = runsEl.querySelector(".task-history-status");
|
|
351
|
+
status.textContent = state.error ? `历史加载失败:${state.error}` : state.runs.length ? `已加载 ${state.runs.length} 次运行` : "暂无 ledger 运行记录。";
|
|
352
|
+
const more = runsEl.querySelector("button.link-button");
|
|
353
|
+
more.hidden = !state.nextBefore && !state.error;
|
|
354
|
+
more.disabled = state.loadingOlder;
|
|
355
|
+
more.textContent = state.loadingOlder ? "正在加载…" : state.error ? "重试加载" : "加载更早的运行";
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
export async function loadOlderTaskRuns(featureId, taskId, before, runsEl) {
|
|
359
|
+
const identity = `${workspaceScope() ?? ""}:${featureId ?? ""}:${taskId}`;
|
|
360
|
+
const state = taskHistoryStates.get(identity);
|
|
361
|
+
if (!state || state.loadingOlder) return;
|
|
362
|
+
state.loadingOlder = true;
|
|
363
|
+
renderTaskHistory(runsEl, state, featureId, taskId, identity);
|
|
364
|
+
const taskApi = featureId ? `/api/features/${encodeURIComponent(featureId)}/tasks/${encodeURIComponent(taskId)}` : `/api/tasks/${encodeURIComponent(taskId)}`;
|
|
365
|
+
try {
|
|
366
|
+
const result = await fetchJsonResult(`${taskApi}/runs?limit=20${state.nextBefore ? `&before=${encodeURIComponent(state.nextBefore)}` : ""}`);
|
|
367
|
+
if (taskHistoryStates.get(identity) !== state) return;
|
|
368
|
+
if (result.ok && result.body) mergeTaskHistoryPage(state, result.body, Boolean(state.nextBefore));
|
|
369
|
+
else state.error = summarizeFetchError(result);
|
|
370
|
+
} finally {
|
|
371
|
+
state.loadingOlder = false;
|
|
372
|
+
if (runsEl.dataset.historyIdentity === identity && taskHistoryStates.get(identity) === state) renderTaskHistory(runsEl, state, featureId, taskId, identity);
|
|
354
373
|
}
|
|
355
374
|
}
|
|
356
375
|
|
|
@@ -12,6 +12,8 @@ export function matchesPathGlob(filePath, glob) {
|
|
|
12
12
|
let pattern = "^";
|
|
13
13
|
for (let index = 0; index < normalizedGlob.length; index += 1) {
|
|
14
14
|
const char = normalizedGlob[index];
|
|
15
|
+
if (char === undefined)
|
|
16
|
+
continue;
|
|
15
17
|
if (char === "*" && normalizedGlob[index + 1] === "*") {
|
|
16
18
|
pattern += ".*";
|
|
17
19
|
index += 1;
|
package/dist/worker/preflight.js
CHANGED
|
@@ -120,6 +120,9 @@ export async function preflightTargetRepo(input) {
|
|
|
120
120
|
}
|
|
121
121
|
if (input.runCheckRepo) {
|
|
122
122
|
const [command, ...args] = input.checkRepoCommand ?? ["bash", "scripts/check-repo.sh"];
|
|
123
|
+
if (command === undefined) {
|
|
124
|
+
throw new Error("check-repo command requires a binary");
|
|
125
|
+
}
|
|
123
126
|
const checkRepo = await input.client.runExternal(command, args, {
|
|
124
127
|
cwd: input.repoRoot,
|
|
125
128
|
artifactName: "check-repo",
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
2
|
+
import { readFile, realpath } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { getTaskPaths } from "../../task/runtime.js";
|
|
6
|
+
import { computeTaskConfigSha256 } from "../../task/contract/hash.js";
|
|
7
|
+
import { assessAutonomousExecutionEligibility, deriveEligibilityFactsFromDagSpec } from "../console/dag-execution-receipt.js";
|
|
8
|
+
import { scheduledGoalDraftSchema } from "./scheduled-goal-types.js";
|
|
9
|
+
const bindingSchema = z.object({
|
|
10
|
+
taskId: z.string(), revision: z.number().int().positive(), canonicalHash: z.string(),
|
|
11
|
+
taskConfigSha256: z.string(), projectionVersion: z.number(), canonicalizerVersion: z.number(), taskConfigSchemaVersion: z.number(),
|
|
12
|
+
});
|
|
13
|
+
const statusSchema = z.object({
|
|
14
|
+
taskId: z.string(), lifecycleState: z.literal("awaiting-write-set-approval"),
|
|
15
|
+
contract: z.object({ effectiveStatus: z.literal("managed"), revision: z.number().int().positive(),
|
|
16
|
+
canonicalHash: z.string(), observedCanonicalHash: z.string(), transactionIncomplete: z.literal(false),
|
|
17
|
+
taskConfigSha256: z.string(), projectionVersion: z.number(), canonicalizerVersion: z.number(), taskConfigSchemaVersion: z.number(), }),
|
|
18
|
+
dagDraft: z.object({ exists: z.literal(true), strictValidated: z.literal(true), specHash: z.string() }),
|
|
19
|
+
gate: z.object({ id: z.string().min(1), digest: z.string().min(1), type: z.literal("human-approval"),
|
|
20
|
+
bound: z.object({ taskId: z.string(), contractRevision: z.number(), contractCanonicalHash: z.string(), dagSpecHash: z.string() }), }),
|
|
21
|
+
activeRun: z.unknown().nullable().optional(), blockers: z.array(z.unknown()).length(0),
|
|
22
|
+
});
|
|
23
|
+
/** Freeze only a CLI-prepared managed task. This read-only intake never approves or starts a DAG. */
|
|
24
|
+
export async function prepareScheduledGoalDraft(input, client) {
|
|
25
|
+
// Validate caller-controlled identity before using it in CLI arguments or paths.
|
|
26
|
+
const parsed = scheduledGoalDraftSchema.omit({ prepared: true, controllerRef: true }).parse(input);
|
|
27
|
+
const identity = client.getIdentity();
|
|
28
|
+
if (!identity)
|
|
29
|
+
throw new Error("scheduled goal requires a pinned controller");
|
|
30
|
+
const root = await realpath(parsed.worktreeRef);
|
|
31
|
+
const paths = getTaskPaths(root, parsed.managedTaskId);
|
|
32
|
+
const readBound = async (file) => {
|
|
33
|
+
const resolved = await realpath(file);
|
|
34
|
+
const relative = path.relative(root, resolved);
|
|
35
|
+
if (!relative || relative === ".." || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative))
|
|
36
|
+
throw new Error("scheduled goal prepared artifact escapes worktree");
|
|
37
|
+
return readFile(resolved, "utf8");
|
|
38
|
+
};
|
|
39
|
+
const status = await client.run(["task", "status", parsed.managedTaskId, "--json"], { cwd: root, expectJson: true, artifactName: `scheduled-goal-admission-${parsed.managedTaskId}-${randomUUID()}`, timeoutMs: 30_000 });
|
|
40
|
+
if (!status.ok || status.exitCode !== 0)
|
|
41
|
+
throw new Error("scheduled goal task status failed");
|
|
42
|
+
const envelope = z.object({ ok: z.literal(true), result: statusSchema }).parse(status.json);
|
|
43
|
+
const snapshot = envelope.result;
|
|
44
|
+
if (snapshot.taskId !== parsed.managedTaskId || snapshot.activeRun != null ||
|
|
45
|
+
snapshot.contract.canonicalHash !== snapshot.contract.observedCanonicalHash ||
|
|
46
|
+
snapshot.gate.bound.taskId !== parsed.managedTaskId ||
|
|
47
|
+
snapshot.gate.bound.contractRevision !== snapshot.contract.revision ||
|
|
48
|
+
snapshot.gate.bound.contractCanonicalHash !== snapshot.contract.canonicalHash)
|
|
49
|
+
throw new Error("scheduled goal managed contract binding mismatch");
|
|
50
|
+
const [dagBytes, configBytes] = await Promise.all([readBound(paths.dagDraftPath), readBound(paths.taskConfigPath)]);
|
|
51
|
+
const dagSpecHash = `sha256:${createHash("sha256").update(dagBytes).digest("hex")}`;
|
|
52
|
+
if (snapshot.dagDraft.specHash !== dagSpecHash || snapshot.gate.bound.dagSpecHash !== dagSpecHash)
|
|
53
|
+
throw new Error("scheduled goal validated DAG drift");
|
|
54
|
+
const dag = JSON.parse(dagBytes);
|
|
55
|
+
const binding = bindingSchema.parse(dag.taskContractBinding);
|
|
56
|
+
const expectedBinding = bindingSchema.parse({ ...snapshot.contract, taskId: parsed.managedTaskId });
|
|
57
|
+
if (dag.version !== 4 || JSON.stringify(binding) !== JSON.stringify(expectedBinding))
|
|
58
|
+
throw new Error("scheduled goal DAG contract binding mismatch");
|
|
59
|
+
const configJson = JSON.parse(configBytes);
|
|
60
|
+
if (computeTaskConfigSha256(configJson) !== binding.taskConfigSha256)
|
|
61
|
+
throw new Error("scheduled goal task configuration drift");
|
|
62
|
+
const config = z.object({ taskKind: z.string(), allowedPaths: z.array(z.string()), forbiddenPaths: z.array(z.string()) }).parse(configJson);
|
|
63
|
+
if (config.taskKind !== parsed.workflow || JSON.stringify(config.allowedPaths) !== JSON.stringify(parsed.allowedPaths) ||
|
|
64
|
+
JSON.stringify(config.forbiddenPaths) !== JSON.stringify(parsed.forbiddenPaths))
|
|
65
|
+
throw new Error("scheduled goal task scope or workflow mismatch");
|
|
66
|
+
const assessment = assessAutonomousExecutionEligibility(deriveEligibilityFactsFromDagSpec({
|
|
67
|
+
dagSpec: dag, allowedPaths: parsed.allowedPaths, forbiddenPaths: parsed.forbiddenPaths,
|
|
68
|
+
}));
|
|
69
|
+
if (!assessment.ok)
|
|
70
|
+
throw new Error(`scheduled goal ineligible: ${assessment.reason}`);
|
|
71
|
+
const digest = (bytes) => createHash("sha256").update(bytes).digest("hex");
|
|
72
|
+
const repositoryPath = (file) => path.relative(root, file).split(path.sep).join("/");
|
|
73
|
+
return scheduledGoalDraftSchema.parse({ ...parsed, controllerRef: identity.packageFingerprint.value,
|
|
74
|
+
prepared: { gateToken: `${snapshot.gate.id}:${snapshot.gate.digest}`,
|
|
75
|
+
dagPath: repositoryPath(paths.dagDraftPath), dagHash: digest(dagBytes),
|
|
76
|
+
contractPath: repositoryPath(paths.taskConfigPath), contractHash: digest(configBytes) }, });
|
|
77
|
+
}
|
|
78
|
+
/** Materialize only contract/runtime inputs; execution remains owned by the operation host. */
|
|
79
|
+
export async function prepareDerivedScheduledGoalTask(goalId, ownerToken, goals, client) {
|
|
80
|
+
const { mkdir, writeFile } = await import("node:fs/promises");
|
|
81
|
+
const goal = await goals.get(goalId);
|
|
82
|
+
const entry = goal.supervisions.at(-1);
|
|
83
|
+
if (goal.state !== "admitted" || !entry || entry.ownerToken !== ownerToken || entry.state !== "preparing" || !entry.proposal)
|
|
84
|
+
throw new Error("derived preparation not authorized");
|
|
85
|
+
if (client.getIdentity()?.packageFingerprint.value !== goal.frozen.controllerRef)
|
|
86
|
+
throw new Error("derived controller drift");
|
|
87
|
+
const directory = path.join(goal.frozen.worktreeRef, ".harness", "scheduled-goal-inputs");
|
|
88
|
+
await mkdir(directory, { recursive: true, mode: 0o700 });
|
|
89
|
+
const prdPath = path.join(directory, `${entry.managedTaskId}.md`);
|
|
90
|
+
const content = ["# Scheduled goal continuation", "## Goal", goal.frozen.originalGoal,
|
|
91
|
+
"## Observed gap", entry.proposal.summary, "## Next task", entry.proposal.instructions,
|
|
92
|
+
"## Acceptance criteria", ...goal.frozen.acceptance.criteria.map((ac) => `- ${ac.acId}: ${ac.description}\n Verification: ${ac.command}`),
|
|
93
|
+
"## Scope", `Workflow: ${goal.frozen.workflow}; acceptance policy: ${goal.frozen.acceptance.policy}.`,
|
|
94
|
+
`Allowed paths: ${JSON.stringify(goal.frozen.allowedPaths)}. Forbidden paths: ${JSON.stringify(goal.frozen.forbiddenPaths)}.`,
|
|
95
|
+
"Preserve the current worktree changes. Do not change acceptance, dependencies, Git history, controller or runtime configuration. Do not push or merge.",
|
|
96
|
+
`Parent evidence: ${entry.parentEvidenceId}; tree: ${entry.treeHash}.`, ""].join("\n\n");
|
|
97
|
+
await writeFile(prdPath, content, { flag: "wx", mode: 0o600 });
|
|
98
|
+
const boundaryArgs = goal.frozen.allowedPaths.flatMap((ref) => ["--allowed-path", ref])
|
|
99
|
+
.concat(goal.frozen.forbiddenPaths.flatMap((ref) => ["--forbidden-path", ref]))
|
|
100
|
+
.concat(goal.frozen.acceptance.criteria.flatMap((ac) => ["--verify", `${ac.acId}:${ac.command}`]));
|
|
101
|
+
for (const [step, args] of [
|
|
102
|
+
["create", ["task", "advance", entry.managedTaskId, `Scheduled goal continuation ${entry.taskRevision}`, "--prd", prdPath, "--task-kind", goal.frozen.workflow, ...boundaryArgs, "--json"]],
|
|
103
|
+
["prepare", ["task", "advance", entry.managedTaskId, "--task-kind", goal.frozen.workflow, ...boundaryArgs, "--json"]],
|
|
104
|
+
]) {
|
|
105
|
+
const current = await goals.get(goalId);
|
|
106
|
+
if (current.state !== "admitted" || current.supervisions.at(-1)?.ownerToken !== ownerToken)
|
|
107
|
+
throw new Error("derived preparation authorization lost");
|
|
108
|
+
const remaining = Math.min(Date.parse(goal.frozen.time.stopAtUtc), Date.parse(goal.frozen.time.expiresAt)) - Date.now();
|
|
109
|
+
if (remaining <= 0)
|
|
110
|
+
throw new Error("derived preparation expired");
|
|
111
|
+
const result = await client.run([...args], { cwd: goal.frozen.worktreeRef, expectJson: true,
|
|
112
|
+
artifactName: `${entry.managedTaskId}-${step}`, timeoutMs: Math.min(remaining, 300000) });
|
|
113
|
+
if (!result.ok || result.exitCode !== 0 || result.timedOut)
|
|
114
|
+
throw new Error(`derived task ${step} failed or unknown`);
|
|
115
|
+
}
|
|
116
|
+
const { prepared: _prepared, controllerRef: _controller, ...input } = goal.frozen;
|
|
117
|
+
return prepareScheduledGoalDraft({ ...input, managedTaskId: entry.managedTaskId }, client);
|
|
118
|
+
}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { execFile, spawn } from "node:child_process";
|
|
3
|
+
import { promisify } from "node:util";
|
|
4
|
+
import { lstat, readFile, readlink, realpath } from "node:fs/promises";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { pathMatchesPattern } from "../../shared/git-progress.js";
|
|
7
|
+
import { scheduledGoalDraftSchema } from "./scheduled-goal-types.js";
|
|
8
|
+
const execFileAsync = promisify(execFile);
|
|
9
|
+
const sha256 = (value) => createHash("sha256").update(value).digest("hex");
|
|
10
|
+
/** Working-copy paths that are plain files, so Git can read them back. */
|
|
11
|
+
async function plainFileNames(root, names) {
|
|
12
|
+
const plain = [];
|
|
13
|
+
for (const name of names) {
|
|
14
|
+
const info = await lstat(path.resolve(root, name)).catch(() => undefined);
|
|
15
|
+
if (info?.isFile())
|
|
16
|
+
plain.push(name);
|
|
17
|
+
}
|
|
18
|
+
return plain;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Repository-form blob IDs for working-copy files, computed by Git itself so
|
|
22
|
+
* that `core.autocrlf` and `eol` attributes normalize exactly as a commit
|
|
23
|
+
* would. Hashing never consults the index, so staged-only and
|
|
24
|
+
* `assume-unchanged` paths keep their raw-byte meaning. A failure degrades to
|
|
25
|
+
* the caller's raw-byte blob, which can only over-report change, never hide it;
|
|
26
|
+
* `--stdin-paths` cannot carry names containing a newline.
|
|
27
|
+
*/
|
|
28
|
+
async function gitNormalizedBlobIds(root, names) {
|
|
29
|
+
const ids = new Map();
|
|
30
|
+
const candidates = names.filter((name) => !name.includes("\n"));
|
|
31
|
+
if (candidates.length === 0)
|
|
32
|
+
return ids;
|
|
33
|
+
let stdout;
|
|
34
|
+
try {
|
|
35
|
+
stdout = await new Promise((resolve, reject) => {
|
|
36
|
+
const child = spawn("git", ["-C", root, "hash-object", "--stdin-paths"], { stdio: ["pipe", "pipe", "pipe"] });
|
|
37
|
+
let output = "";
|
|
38
|
+
let failure = "";
|
|
39
|
+
child.stdout.setEncoding("utf8");
|
|
40
|
+
child.stdout.on("data", (chunk) => { output += chunk; });
|
|
41
|
+
child.stderr.setEncoding("utf8");
|
|
42
|
+
child.stderr.on("data", (chunk) => { failure += chunk; });
|
|
43
|
+
child.on("error", reject);
|
|
44
|
+
child.on("close", (code) => {
|
|
45
|
+
if (code === 0)
|
|
46
|
+
resolve(output);
|
|
47
|
+
else
|
|
48
|
+
reject(new Error(`git hash-object failed: ${failure.trim()}`));
|
|
49
|
+
});
|
|
50
|
+
child.stdin.end(`${candidates.join("\n")}\n`);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return ids;
|
|
55
|
+
}
|
|
56
|
+
const hashes = stdout.split("\n").map((line) => line.trim()).filter(Boolean);
|
|
57
|
+
if (hashes.length !== candidates.length)
|
|
58
|
+
return ids;
|
|
59
|
+
for (let index = 0; index < candidates.length; index += 1)
|
|
60
|
+
ids.set(candidates[index], hashes[index]);
|
|
61
|
+
return ids;
|
|
62
|
+
}
|
|
63
|
+
/** Run only frozen AC commands. A timeout is uncertain execution, never a passing or repairable failure. */
|
|
64
|
+
export async function evaluateScheduledGoalCriteria(frozen, options = {}) {
|
|
65
|
+
frozen = scheduledGoalDraftSchema.pick({ worktreeRef: true, frozenBase: true, allowedPaths: true, forbiddenPaths: true, acceptance: true, time: true }).strip().parse(frozen);
|
|
66
|
+
if (options.commandTimeoutMs !== undefined && (!Number.isFinite(options.commandTimeoutMs) || options.commandTimeoutMs <= 0))
|
|
67
|
+
throw new Error("invalid acceptance command timeout");
|
|
68
|
+
const now = options.now ?? (() => new Date());
|
|
69
|
+
const startedAt = now().toISOString();
|
|
70
|
+
const capture = () => captureScheduledGoalTree(frozen.worktreeRef, frozen.frozenBase, frozen.allowedPaths, frozen.forbiddenPaths);
|
|
71
|
+
const before = await capture();
|
|
72
|
+
const criteria = [];
|
|
73
|
+
let stopped = before.scopeViolations.length ? "scope_violation" : undefined;
|
|
74
|
+
let drift = false;
|
|
75
|
+
let executionUnknown = false;
|
|
76
|
+
for (const criterion of frozen.acceptance.criteria) {
|
|
77
|
+
if (options.mayRun && !await options.mayRun())
|
|
78
|
+
stopped ??= "assessment_cancelled";
|
|
79
|
+
const current = await capture();
|
|
80
|
+
if (current.treeHash !== before.treeHash) {
|
|
81
|
+
drift = true;
|
|
82
|
+
stopped = "tree_changed_during_acceptance";
|
|
83
|
+
}
|
|
84
|
+
const remaining = Math.min(Date.parse(frozen.time.stopAtUtc), Date.parse(frozen.time.expiresAt)) - now().getTime();
|
|
85
|
+
if (remaining <= 0)
|
|
86
|
+
stopped ??= "authorization_expired";
|
|
87
|
+
const result = { acId: criterion.acId, command: criterion.command,
|
|
88
|
+
status: "pending", exitCode: null, stdout: "", stderr: "", outputHash: sha256(JSON.stringify({ stdout: "", stderr: "", exitCode: null })), };
|
|
89
|
+
if (stopped)
|
|
90
|
+
result.reason = stopped;
|
|
91
|
+
else {
|
|
92
|
+
try {
|
|
93
|
+
const output = await execFileAsync("bash", ["-lc", criterion.command], {
|
|
94
|
+
cwd: frozen.worktreeRef, encoding: "utf8", maxBuffer: 1024 * 1024,
|
|
95
|
+
timeout: Math.max(1, Math.min(remaining, options.commandTimeoutMs ?? 120_000)),
|
|
96
|
+
});
|
|
97
|
+
result.stdout = output.stdout;
|
|
98
|
+
result.stderr = output.stderr;
|
|
99
|
+
result.exitCode = 0;
|
|
100
|
+
result.status = "succeeded";
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
const failure = error;
|
|
104
|
+
result.stdout = failure.stdout ?? "";
|
|
105
|
+
result.stderr = failure.stderr ?? "";
|
|
106
|
+
if (typeof failure.code === "number" && !failure.killed && !failure.signal) {
|
|
107
|
+
result.exitCode = failure.code;
|
|
108
|
+
result.status = "failed";
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
executionUnknown = true;
|
|
112
|
+
result.reason = "command_execution_unknown";
|
|
113
|
+
stopped = result.reason;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
result.outputHash = sha256(JSON.stringify({ stdout: result.stdout, stderr: result.stderr, exitCode: result.exitCode }));
|
|
117
|
+
const verifiedTree = await capture();
|
|
118
|
+
if (verifiedTree.treeHash !== before.treeHash) {
|
|
119
|
+
drift = true;
|
|
120
|
+
stopped = "tree_changed_during_acceptance";
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
criteria.push(result);
|
|
124
|
+
}
|
|
125
|
+
const after = await capture();
|
|
126
|
+
drift ||= before.treeHash !== after.treeHash;
|
|
127
|
+
if (drift)
|
|
128
|
+
for (const result of criteria) {
|
|
129
|
+
if (result.reason === "command_execution_unknown")
|
|
130
|
+
continue;
|
|
131
|
+
result.status = "stale";
|
|
132
|
+
result.reason = "tree_changed_during_acceptance";
|
|
133
|
+
}
|
|
134
|
+
const finishedAt = now().toISOString();
|
|
135
|
+
const expired = Date.parse(finishedAt) >= Math.min(Date.parse(frozen.time.stopAtUtc), Date.parse(frozen.time.expiresAt));
|
|
136
|
+
const status = executionUnknown ? "pending" : drift ? "stale" : before.scopeViolations.length || after.scopeViolations.length ? "failed"
|
|
137
|
+
: expired ? "pending"
|
|
138
|
+
: criteria.some((result) => result.status === "pending") ? "pending"
|
|
139
|
+
: criteria.every((result) => result.status === "succeeded") ? "succeeded" : "failed";
|
|
140
|
+
return { before, after, criteria, status, executionUnknown, startedAt, finishedAt };
|
|
141
|
+
}
|
|
142
|
+
/** Hash actual delivery bytes, including nonignored untracked files; staging is not a tree change. */
|
|
143
|
+
export async function captureScheduledGoalTree(worktree, base, allowedPaths, forbiddenPaths) {
|
|
144
|
+
if (!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(base))
|
|
145
|
+
throw new Error("invalid frozen base");
|
|
146
|
+
const root = await realpath(worktree);
|
|
147
|
+
const git = async (...args) => (await execFileAsync("git", ["-C", root, ...args], {
|
|
148
|
+
encoding: "utf8", timeout: 30_000, maxBuffer: 16 * 1024 * 1024,
|
|
149
|
+
})).stdout;
|
|
150
|
+
const [head, top, tracked, untracked, baseline, format] = await Promise.all([
|
|
151
|
+
git("rev-parse", "HEAD"), git("rev-parse", "--show-toplevel"),
|
|
152
|
+
git("ls-files", "-z", "--cached"), git("ls-files", "-z", "--others", "--exclude-standard"),
|
|
153
|
+
git("ls-tree", "-r", "-z", base), git("rev-parse", "--show-object-format"),
|
|
154
|
+
]);
|
|
155
|
+
if (await realpath(top.trim()) !== root || head.trim() !== base)
|
|
156
|
+
throw new Error("scheduled goal worktree/base drift");
|
|
157
|
+
const entries = (value) => value.split("\0").filter(Boolean);
|
|
158
|
+
const objectFormat = format.trim();
|
|
159
|
+
if (objectFormat !== "sha1" && objectFormat !== "sha256")
|
|
160
|
+
throw new Error("unsupported Git object format");
|
|
161
|
+
const baseEntries = new Map(entries(baseline).map((entry) => {
|
|
162
|
+
const separator = entry.indexOf("\t");
|
|
163
|
+
const [mode, kind, objectId] = entry.slice(0, separator).split(" ");
|
|
164
|
+
if (separator < 0 || !mode || !kind || !objectId)
|
|
165
|
+
throw new Error("invalid Git tree entry");
|
|
166
|
+
return [entry.slice(separator + 1), { mode, kind, objectId }];
|
|
167
|
+
}));
|
|
168
|
+
const blobId = (bytes) => createHash(objectFormat).update(`blob ${bytes.length}\0`).update(bytes).digest("hex");
|
|
169
|
+
const names = [...new Set([...entries(tracked), ...entries(untracked), ...baseEntries.keys()])].sort();
|
|
170
|
+
const deliveryNames = new Set(names);
|
|
171
|
+
// Compare content identity through Git's own normalization: a working copy
|
|
172
|
+
// materialized with `core.autocrlf` (or an `eol` attribute) is stored as LF
|
|
173
|
+
// while the checkout is CRLF, and raw bytes would report that as drift on
|
|
174
|
+
// every text file.
|
|
175
|
+
const normalizedIds = await gitNormalizedBlobIds(root, await plainFileNames(root, names));
|
|
176
|
+
const files = [];
|
|
177
|
+
const changedPaths = [];
|
|
178
|
+
for (const name of names) {
|
|
179
|
+
const expected = baseEntries.get(name);
|
|
180
|
+
let actualId;
|
|
181
|
+
let actualMode;
|
|
182
|
+
const target = path.resolve(root, name);
|
|
183
|
+
const relative = path.relative(root, target);
|
|
184
|
+
if (relative === ".." || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative))
|
|
185
|
+
throw new Error("tree path escapes worktree");
|
|
186
|
+
try {
|
|
187
|
+
const parent = await realpath(path.dirname(target));
|
|
188
|
+
if (parent !== root && !parent.startsWith(`${root}${path.sep}`))
|
|
189
|
+
throw new Error("tree parent escapes worktree");
|
|
190
|
+
const stat = await lstat(target);
|
|
191
|
+
if (stat.isSymbolicLink()) {
|
|
192
|
+
const link = await readlink(target);
|
|
193
|
+
const resolved = await realpath(target).catch(() => { throw new Error(`unresolved delivery symlink: ${name}`); });
|
|
194
|
+
if (resolved !== root && !resolved.startsWith(`${root}${path.sep}`))
|
|
195
|
+
throw new Error(`delivery symlink escapes worktree: ${name}`);
|
|
196
|
+
if (!deliveryNames.has(path.relative(root, resolved)))
|
|
197
|
+
throw new Error(`delivery symlink target is not fingerprinted: ${name}`);
|
|
198
|
+
files.push({ name, kind: "symlink", hash: sha256(link) });
|
|
199
|
+
actualId = blobId(Buffer.from(link));
|
|
200
|
+
actualMode = "120000";
|
|
201
|
+
}
|
|
202
|
+
else if (stat.isFile()) {
|
|
203
|
+
const bytes = await readFile(target);
|
|
204
|
+
actualId = normalizedIds.get(name) ?? blobId(bytes);
|
|
205
|
+
files.push({
|
|
206
|
+
name,
|
|
207
|
+
kind: "file",
|
|
208
|
+
hash: sha256(`${objectFormat}:${actualId}`),
|
|
209
|
+
executable: Boolean(stat.mode & 0o111),
|
|
210
|
+
});
|
|
211
|
+
actualMode = stat.mode & 0o111 ? "100755" : "100644";
|
|
212
|
+
}
|
|
213
|
+
else
|
|
214
|
+
throw new Error(`unsupported delivery entry: ${name}`);
|
|
215
|
+
}
|
|
216
|
+
catch (error) {
|
|
217
|
+
if (error.code === "ENOENT") {
|
|
218
|
+
if (expected)
|
|
219
|
+
files.push({ name, kind: "missing" });
|
|
220
|
+
}
|
|
221
|
+
else
|
|
222
|
+
throw error;
|
|
223
|
+
}
|
|
224
|
+
if (expected ? expected.objectId !== actualId || expected.mode !== actualMode : actualId !== undefined)
|
|
225
|
+
changedPaths.push(name);
|
|
226
|
+
}
|
|
227
|
+
const scopeViolations = changedPaths.filter((name) => !allowedPaths.some((pattern) => pathMatchesPattern(name, pattern))
|
|
228
|
+
|| forbiddenPaths.some((pattern) => pathMatchesPattern(name, pattern)));
|
|
229
|
+
return { base, head: head.trim(), treeHash: sha256(JSON.stringify(files)), changedPaths, scopeViolations };
|
|
230
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { captureScheduledGoalTree } from "./scheduled-goal-evidence.js";
|
|
2
|
+
// ESRCH establishes absence only; permission errors and PID reuse never grant takeover.
|
|
3
|
+
function ownerMissing(pid) {
|
|
4
|
+
if (pid === undefined)
|
|
5
|
+
return true;
|
|
6
|
+
try {
|
|
7
|
+
process.kill(pid, 0);
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
return error.code === "ESRCH";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/** Read-only result projection. Reopening a result never authorizes another execution. */
|
|
15
|
+
export async function readScheduledGoalResult(goalId, goals) {
|
|
16
|
+
const goal = await goals.get(goalId);
|
|
17
|
+
const evidence = goal.evidence.at(-1);
|
|
18
|
+
let evidenceCurrent = false;
|
|
19
|
+
let treeReadError = false;
|
|
20
|
+
if (evidence) {
|
|
21
|
+
try {
|
|
22
|
+
const tree = await captureScheduledGoalTree(goal.frozen.worktreeRef, goal.frozen.frozenBase, goal.frozen.allowedPaths, goal.frozen.forbiddenPaths);
|
|
23
|
+
evidenceCurrent = evidence.intentId === goal.intents.at(-1)?.intentId && tree.treeHash === evidence.committedTree.treeHash &&
|
|
24
|
+
tree.treeHash === evidence.assessment.after.treeHash && tree.scopeViolations.length === 0;
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
treeReadError = true;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const missingOwner = goal.intents.some((intent) => intent.state === "dispatching" && ownerMissing(intent.dispatchOwnerPid)) || Boolean(goal.assessmentAttempt && ownerMissing(goal.assessmentAttempt.ownerPid)) ||
|
|
31
|
+
goal.supervisions.some((entry) => ["requested", "preparing"].includes(entry.state) && ownerMissing(entry.ownerPid));
|
|
32
|
+
const uncertain = missingOwner || goal.state === "unknown" || goal.intents.some((intent) => intent.state === "unknown") ||
|
|
33
|
+
goal.supervisions.some((entry) => entry.state === "unknown") || Boolean(goal.assessmentAttempt && goal.acceptanceState === "pending");
|
|
34
|
+
const acceptance = evidence && !evidenceCurrent && ["accepted", "failed"].includes(goal.acceptanceState) ? "stale" : goal.acceptanceState;
|
|
35
|
+
return {
|
|
36
|
+
goalId, goalRevision: goal.goalRevision, stateVersion: goal.stateVersion,
|
|
37
|
+
state: goal.state, reasonCode: treeReadError ? "tree_unreadable" : acceptance === "stale" ? "evidence_drift" : goal.reasonCode,
|
|
38
|
+
acceptance, delivery: goal.deliveryState, evidenceCurrent,
|
|
39
|
+
budget: { limits: goal.frozen.budget, used: goal.used, tokenUsage: "unknown" },
|
|
40
|
+
supervision: goal.supervisions.map((entry) => ({ state: entry.state, taskRevision: entry.taskRevision, usageTokens: entry.usageTokens ?? null })),
|
|
41
|
+
execution: goal.intents.map((intent) => ({ taskRevision: intent.taskRevision, turnSeq: intent.turnSeq,
|
|
42
|
+
state: intent.state, operationId: intent.operationId, runId: intent.runId })),
|
|
43
|
+
evidence: goal.evidence.map((item) => ({ evidenceId: item.evidenceId, taskRevision: item.taskRevision,
|
|
44
|
+
treeHash: item.committedTree.treeHash, status: item.assessment.status, recordedAt: item.recordedAt,
|
|
45
|
+
criteria: item.assessment.criteria.map((ac) => ({ acId: ac.acId, status: ac.status, exitCode: ac.exitCode,
|
|
46
|
+
outputHash: ac.outputHash, evidenceRef: `${item.evidenceId}#${ac.acId}` })) })),
|
|
47
|
+
reconciliation: uncertain ? {
|
|
48
|
+
required: true,
|
|
49
|
+
reason: missingOwner ? "reservation_owner_missing" : goal.reasonCode ?? "execution_unknown",
|
|
50
|
+
instructions: "Inspect the associated operation/run and all descendant processes. Preserve the ledger and worktree. Do not delete ownership locks or automatically repeat an unknown action; an operator must reconcile execution before resources can be released.",
|
|
51
|
+
} : null,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/** Resolve a hash-bound output reference without exposing dispatch/owner capabilities. */
|
|
55
|
+
export async function readScheduledGoalEvidence(goalId, evidenceId, acId, goals) {
|
|
56
|
+
const goal = await goals.get(goalId);
|
|
57
|
+
const evidence = goal.evidence.find((entry) => entry.evidenceId === evidenceId);
|
|
58
|
+
const criterion = evidence?.assessment.criteria.find((entry) => entry.acId === acId);
|
|
59
|
+
if (!evidence || !criterion)
|
|
60
|
+
throw new Error("scheduled goal evidence not found");
|
|
61
|
+
return { evidenceId, taskRevision: evidence.taskRevision, treeHash: evidence.committedTree.treeHash, ...criterion };
|
|
62
|
+
}
|