@tea-agent/loop-agent 0.41.1 → 0.42.0-next.10
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 +397 -5
- package/dist/adapters/context-transfer/optional-pi-handoff.js +31 -0
- package/dist/adapters/context-transfer/pi-session.js +61 -0
- package/dist/application/dag/generate-task-dag.js +75 -19
- package/dist/application/dag/run-dag.js +41 -0
- package/dist/application/task-lifecycle/advance.js +24 -5
- package/dist/application/task-lifecycle/observe.js +171 -17
- package/dist/application/task-lifecycle/plan-transitions.js +42 -7
- package/dist/application/task-lifecycle/recommendations.js +13 -2
- package/dist/build-stamp.json +3 -3
- package/dist/cli/command-definitions.js +19 -0
- package/dist/cli/program.js +29 -2
- package/dist/commands/client-recovery.js +3 -0
- package/dist/commands/dag-artifact.js +284 -0
- package/dist/commands/dag-context.js +184 -0
- package/dist/commands/dag-follow-up.js +138 -0
- package/dist/commands/dag-rerun-task.js +2 -0
- package/dist/commands/dag-rerun.js +206 -1
- package/dist/commands/init.js +27 -1
- package/dist/commands/task-advance.js +19 -0
- package/dist/executors/dag-pi-executor.js +4013 -86
- package/dist/executors/pi-executor.js +15 -4
- package/dist/executors/pi-read-budget-policy.js +239 -0
- package/dist/executors/pi-sdk-executor.js +3 -0
- package/dist/executors/shell-executor.js +978 -188
- package/dist/executors/shell-write-guard.js +7 -0
- package/dist/{worker → infrastructure}/console/app-data.js +4 -0
- package/dist/infrastructure/console/artifact-revision-store.js +430 -0
- package/dist/infrastructure/console/context-export-store.js +160 -0
- package/dist/infrastructure/console/dir-lock.js +132 -0
- package/dist/infrastructure/console/operation-store.js +417 -0
- package/dist/infrastructure/harness/artifact-store.js +10 -1
- package/dist/infrastructure/harness/atomic-write.js +12 -2
- package/dist/shared/context-transfer/artifact-revision.js +172 -0
- package/dist/shared/context-transfer.js +418 -0
- package/dist/shared/dag-failure-category.js +12 -0
- package/dist/shared/openspec-spec.js +70 -4
- package/dist/shared/operator/capabilities.js +21 -0
- package/dist/shared/operator/safe-run-summary.js +1 -0
- package/dist/shared/path-safety.js +93 -0
- package/dist/shared/preview.js +28 -4
- package/dist/task/config-types.js +107 -6
- package/dist/task/contract/adopt.js +4 -0
- package/dist/task/contract/import-revision.js +4 -0
- package/dist/task/contract/project.js +3 -0
- package/dist/task/contract/schema.js +2 -1
- package/dist/task/frontend-project-capability.js +203 -20
- package/dist/task/runtime.js +5 -2
- package/dist/task/source-prepare/build-draft.js +3 -3
- package/dist/task/source-prepare/fragment-inventory.js +64 -25
- package/dist/task/source-prepare/prepare.js +126 -21
- package/dist/task/source-prepare/semantic-intake.js +6 -2
- package/dist/task/source-references.js +22 -1
- package/dist/task/task-demand-routing.js +3 -0
- package/dist/worker/console/chat/chat-event-store.js +2 -2
- package/dist/worker/console/chat/model-resolver.js +7 -4
- package/dist/worker/console/chat/pi-runtime.js +86 -5
- package/dist/worker/console/chat/resource-preferences-store.js +1 -1
- package/dist/worker/console/chat/routes.js +136 -53
- package/dist/worker/console/chat/sdd-data-alignment.js +222 -0
- package/dist/worker/console/chat/session-catalog.js +2 -0
- package/dist/worker/console/chat/session-store.js +43 -1
- package/dist/worker/console/chat/shortcuts.js +18 -2
- package/dist/worker/console/chat/user-questions.js +1 -1
- package/dist/worker/console/console-update-runtime.js +1 -1
- package/dist/worker/console/context-transfer-diagnostics.js +198 -0
- package/dist/worker/console/dag-confirmation.js +1 -1
- package/dist/worker/console/dag-execution-receipt.js +1 -1
- package/dist/worker/console/doctor.js +1 -1
- package/dist/worker/console/draft-store.js +1 -1
- package/dist/worker/console/frontend-human-decision-adapter.js +19 -0
- package/dist/worker/console/frontend-split-operation-adapter.js +20 -0
- package/dist/worker/console/human-gate-token.js +1 -1
- package/dist/worker/console/index.js +6 -3
- package/dist/worker/console/interview/assessment.js +1 -1
- package/dist/worker/console/interview/session.js +1 -1
- package/dist/worker/console/operation-runner.js +45 -4
- package/dist/worker/console/operation-sse.js +1 -1
- package/dist/worker/console/operation-wait.js +1 -1
- package/dist/worker/console/operator-actions.js +273 -10
- package/dist/worker/console/operator-surface-health.js +1 -1
- package/dist/worker/console/operator-user-error.js +169 -0
- package/dist/worker/console/pi-plugins.js +57 -0
- package/dist/worker/console/pi-readiness.js +3 -2
- package/dist/worker/console/routes.js +637 -8
- package/dist/worker/console/security.js +35 -0
- package/dist/worker/console/server.js +29 -4
- package/dist/worker/console/static/assets/{abnfDiagram-N423BO3Z-D7oU983t.js → abnfDiagram-N423BO3Z-CcS17TBr.js} +1 -1
- package/dist/worker/console/static/assets/{arc-BrKSRdFS.js → arc-COptKq2S.js} +1 -1
- package/dist/worker/console/static/assets/{architectureDiagram-T3A2C74G-CiXV7L56.js → architectureDiagram-T3A2C74G-h4LKMHjP.js} +1 -1
- package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-D_Hs_gIG.js → blockDiagram-VBNYF7ZC-COA1MOH0.js} +1 -1
- package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-DbM-Lqqh.js → c4Diagram-5PPSVZJV-DJUf0QPm.js} +1 -1
- package/dist/worker/console/static/assets/channel-DdBCaOJ6.js +1 -0
- package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-D1M8uqJw.js → chunk-2GRJ4B5K-mtWfKrUX.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-4D3RFHT6.js → chunk-2Q5K7J3B-B8pXsxDQ.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5RXB4S5H-CdwpY_n9.js → chunk-5RXB4S5H-ipKzByl1.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5VM5RSS4-BLeLZ9PG.js → chunk-5VM5RSS4-DYi3Ald_.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-CeRNEMvc.js → chunk-6Q2QTUOP-DQtGYoty.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-GF5L2VYU-CjkHP8Vy.js → chunk-GF5L2VYU-BU0qS2YV.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-JWPE2WC7-B54ZUQY-.js → chunk-JWPE2WC7-DVH9dIGE.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-KBJHAD2P-4bKaMVmx.js → chunk-KBJHAD2P-Dt60SmgM.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-RYQCIY6F-Cyjfznu_.js → chunk-RYQCIY6F-BoaUGuEY.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-XXDRQBXY-CDN-zGFV.js → chunk-XXDRQBXY-_WHFDTp2.js} +1 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-DZFra1GO.js +1 -0
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-DZFra1GO.js +1 -0
- package/dist/worker/console/static/assets/{cose-bilkent-JH36ORCC-HxJmz411.js → cose-bilkent-JH36ORCC-BxkbTIRd.js} +1 -1
- package/dist/worker/console/static/assets/{cynefin-VYW2F7L2-DtSt5K2w.js → cynefin-VYW2F7L2-Bf2UVnoG.js} +1 -1
- package/dist/worker/console/static/assets/{cynefinDiagram-MW4NZA55-VtkSpRmG.js → cynefinDiagram-MW4NZA55-Bo23q1J_.js} +1 -1
- package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-Bj4DT4du.js → dagre-VZM6K2ZE-Dd_UU49i.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-7IWD3JNH-Bpuk6BmP.js → diagram-7IWD3JNH-ebUa1a9y.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-BHYGv_yO.js → diagram-B4RE2ZJO-BucthU8r.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-LBJQPF4R-DEx3WwnT.js → diagram-LBJQPF4R-BgqNpAkm.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-Q27KOJAE-Cj0dS5e8.js → diagram-Q27KOJAE-DC4q5NGa.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-UB23O5K3-B97h8l21.js → diagram-UB23O5K3-CBqCaMeb.js} +1 -1
- package/dist/worker/console/static/assets/{ebnfDiagram-BXEA7PRR-DMSFAhBd.js → ebnfDiagram-BXEA7PRR-CGtnbQ3-.js} +1 -1
- package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-DhVOCbt6.js → erDiagram-JOGREHBK-CG3LUao5.js} +1 -1
- package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-GlakITWL.js → flowDiagram-UKHOOZJN-D2ZVgoFS.js} +1 -1
- package/dist/worker/console/static/assets/{ganttDiagram-PKOTCBZU-VxPpu9eQ.js → ganttDiagram-PKOTCBZU-DoYFZiKt.js} +1 -1
- package/dist/worker/console/static/assets/{gitGraphDiagram-DS77QQ5N-Bs_e5DRT.js → gitGraphDiagram-DS77QQ5N-CKoP1s6j.js} +1 -1
- package/dist/worker/console/static/assets/index-CAZ2fC_X.css +1 -0
- package/dist/worker/console/static/assets/index-vbTcFnFs.js +449 -0
- package/dist/worker/console/static/assets/{infoDiagram-6WML65LV-BXYuU4Uw.js → infoDiagram-6WML65LV-Duofv8p2.js} +1 -1
- package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-C34erCbU.js → ishikawaDiagram-WSZJBQD7-D2nlCkA1.js} +1 -1
- package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-DZCAiOU3.js → journeyDiagram-NVQOT4AX-Dd4IHdus.js} +1 -1
- package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-C9gaTdUm.js → kanban-definition-27J2QSJJ-Bi20AOdt.js} +1 -1
- package/dist/worker/console/static/assets/{linear-CvI0Z17U.js → linear-D59YJ9kB.js} +1 -1
- package/dist/worker/console/static/assets/{mermaid.core-DMMSIx7j.js → mermaid.core-Bl13LpNa.js} +5 -5
- package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-BKKP0EO6.js → mindmap-definition-FAOFIHXS-C6DLP5eY.js} +1 -1
- package/dist/worker/console/static/assets/{pegDiagram-VL7TDLO6-C3LiFbl5.js → pegDiagram-VL7TDLO6-BjO4cy64.js} +1 -1
- package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-Bb3Om2Dz.js → pieDiagram-7S7Q4E2Y-D7i2qZTG.js} +1 -1
- package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-DNthMjzc.js → quadrantDiagram-CIZ2JOQS-Dx8o_h0y.js} +1 -1
- package/dist/worker/console/static/assets/{railroadDiagram-AXF67PYL-miFsr4Tv.js → railroadDiagram-AXF67PYL-B55orI_t.js} +1 -1
- package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP-yXUncmn6.js → requirementDiagram-LRYGKXZP-zWaehp6f.js} +1 -1
- package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-DLeWKLak.js → sankeyDiagram-W5VNT64P-CcA-pjvD.js} +1 -1
- package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-CI3he1R3.js → sequenceDiagram-SI44F4Z6-BOFbzNHI.js} +1 -1
- package/dist/worker/console/static/assets/{sizeCapture-X5ZJPWSS-B7jfDkS5.js → sizeCapture-X5ZJPWSS-BjAejah1.js} +1 -1
- package/dist/worker/console/static/assets/{stateDiagram-OKZ733FA-BmrZod7J.js → stateDiagram-OKZ733FA-DXYwxJwZ.js} +1 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-Clg3V9t1.js +1 -0
- package/dist/worker/console/static/assets/{swimlanes-SLNWSIFB-CDOlHVSY.js → swimlanes-SLNWSIFB-OYiOch8n.js} +2 -2
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-DX1dxAAW.js +8 -0
- package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-Cz-XX1gy.js → timeline-definition-Z64GVDOM-cZfH3nmU.js} +1 -1
- package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-caV4cI8C.js → vennDiagram-T6HMQDX7-BDE7b3E1.js} +1 -1
- package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-dImPlnIO.js → wardleyDiagram-T6FBY63Y-kyyGy9WJ.js} +1 -1
- package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-CtRYVJcn.js → xychartDiagram-ELKLHX3M-CJj6VTog.js} +1 -1
- package/dist/worker/console/static/index.html +7 -2
- package/dist/worker/console/static-src/active-run-badge.js +17 -0
- package/dist/worker/console/static-src/app/useOperatorActions.js +3 -2
- package/dist/worker/console/static-src/app/useRecoveryConsole.js +5 -5
- package/dist/worker/console/static-src/operator-chat/input-history.js +8 -6
- package/dist/worker/console/static-src/operator-chat/runtime-snapshot-store.js +10 -0
- package/dist/worker/console/static-src/operator-chat/useChatSessions.js +258 -23
- package/dist/worker/console/static-src/operator-chat/useChatThread.js +112 -4
- package/dist/worker/console/static-src/operator-chat/useComposer.js +13 -4
- package/dist/worker/console/static-src/operator-chat/useRuntimeControls.js +29 -6
- package/dist/worker/console/static-src/operator-chat/useRuntimeSnapshot.js +8 -2
- package/dist/worker/console/static-src/shell/console-update-reload.js +52 -0
- package/dist/worker/console/static-src/shell/workspace-route.js +11 -0
- package/dist/worker/console/workspace-context.js +142 -2
- package/dist/worker/console/workspace-registry.js +2 -2
- package/dist/worker/continuation/worker-continuation.js +278 -0
- package/dist/worker/materialize/frontend-split-task-materializer.js +72 -0
- package/dist/worker/observe/health.js +1 -1
- package/dist/worker/observe/node-transparency.js +572 -0
- package/dist/worker/observe/routes.js +55 -1
- package/dist/worker/observe/static/api.js +69 -5
- package/dist/worker/observe/static/dag-context-reason-labels.d.ts +9 -0
- package/dist/worker/observe/static/dag-context-reason-labels.js +120 -0
- package/dist/worker/observe/static/dag-helpers.js +4 -2
- package/dist/worker/observe/static/dag-node-purpose.js +5 -0
- package/dist/worker/observe/static/inspect-workspace.js +23 -0
- package/dist/worker/observe/static/kpi.js +2 -2
- package/dist/worker/observe/static/operator-chrome.d.ts +10 -2
- package/dist/worker/observe/static/operator-chrome.js +37 -23
- package/dist/worker/observe/static/relations.js +2 -2
- package/dist/worker/observe/static/router.d.ts +12 -1
- package/dist/worker/observe/static/router.js +48 -6
- package/dist/worker/observe/static/run-processing.js +4 -2
- package/dist/worker/observe/static/shell-chrome.js +2 -2
- package/dist/worker/observe/static/state.js +8 -1
- package/dist/worker/observe/static/styles.css +1092 -86
- package/dist/worker/observe/static/views/dag-inspector.js +1228 -64
- package/dist/worker/observe/static/views/dag.js +10 -2
- package/dist/worker/observe/static/views/dags.js +3 -1
- package/dist/worker/observe/static/views/dashboard.js +14 -6
- package/dist/worker/observe/static/views/pool.js +7 -2
- package/dist/worker/observe/static/views/run.js +12 -3
- package/dist/worker/observe/static/views/session-timeline.js +142 -18
- package/dist/worker/observe/static/views/task.js +7 -2
- package/dist/worker/outcomes/adapters.js +19 -0
- package/dist/worker/outcomes/types.js +1 -0
- package/dist/worker/pool/attempt-lease.js +97 -66
- package/dist/worker/pool/begin-attempt-with-lease.js +1 -0
- package/dist/worker/pool/reconcile.js +46 -1
- package/dist/worker/pool/run-store.js +2 -0
- package/dist/worker/pool/state-projection.js +2 -0
- package/dist/worker/task-spec/workflow-routing.js +8 -3
- package/dist/workflows/dag/artifact-bindings.js +149 -0
- package/dist/workflows/dag/artifact-revision-schema-registry.js +31 -0
- package/dist/workflows/dag/backend-test-case-coverage-analysis.js +215 -28
- package/dist/workflows/dag/backend-test-markdown-workflow.js +13 -1
- package/dist/workflows/dag/backend-test-plan-protocol.js +106 -0
- package/dist/workflows/dag/backend-test-scenario-param.js +172 -25
- package/dist/workflows/dag/backend-test-scenario-partitions.js +62 -1
- package/dist/workflows/dag/backend-test-writer-completeness.js +104 -12
- package/dist/workflows/dag/budget-enforcement.js +10 -0
- package/dist/workflows/dag/context-receipt.js +305 -0
- package/dist/workflows/dag/context-transfer/context-bundle.js +423 -0
- package/dist/workflows/dag/context-transfer/operator-actions.js +61 -0
- package/dist/workflows/dag/context-transfer/renderers.js +93 -0
- package/dist/workflows/dag/contract-validator-registrations.js +1 -2
- package/dist/workflows/dag/dag-retry-schema.js +138 -0
- package/dist/workflows/dag/frontend-closeout.js +221 -0
- package/dist/workflows/dag/frontend-design-policy.js +400 -0
- package/dist/workflows/dag/frontend-human-decision.js +182 -0
- package/dist/workflows/dag/frontend-implementation-contract.js +1237 -192
- package/dist/workflows/dag/frontend-plan-render.js +2 -1
- package/dist/workflows/dag/frontend-prewrite-gate.js +256 -350
- package/dist/workflows/dag/frontend-provider-capability-matrix.js +159 -0
- package/dist/workflows/dag/frontend-recovery-capsule.js +455 -0
- package/dist/workflows/dag/frontend-recovery-controller.js +226 -0
- package/dist/workflows/dag/frontend-recovery-lineage.js +178 -0
- package/dist/workflows/dag/frontend-recovery-plan.js +21 -10
- package/dist/workflows/dag/frontend-recovery-run.js +166 -34
- package/dist/workflows/dag/frontend-repair.js +1 -432
- package/dist/workflows/dag/frontend-review-context.js +261 -15
- package/dist/workflows/dag/frontend-review-findings.js +270 -0
- package/dist/workflows/dag/frontend-shadow-dual-write.js +941 -0
- package/dist/workflows/dag/frontend-shape-capsule-store.js +191 -0
- package/dist/workflows/dag/frontend-shape-facts.js +419 -0
- package/dist/workflows/dag/frontend-shape.js +435 -0
- package/dist/workflows/dag/frontend-source-fidelity-ledger.js +108 -0
- package/dist/workflows/dag/frontend-split-application-service.js +203 -0
- package/dist/workflows/dag/frontend-split-orchestrator.js +899 -0
- package/dist/workflows/dag/frontend-typed-event-store.js +452 -0
- package/dist/workflows/dag/frontend-typed-event-transaction.js +180 -0
- package/dist/workflows/dag/frontend-verification-trace.js +252 -25
- package/dist/workflows/dag/frontend-worktree-diff.js +250 -17
- package/dist/workflows/dag/frontend-writer-admission.js +319 -0
- package/dist/workflows/dag/frontend-writer-rollback.js +32 -0
- package/dist/workflows/dag/frontend-writer-status.js +256 -0
- package/dist/workflows/dag/init-hybrid.js +1174 -562
- package/dist/workflows/dag/interrupt-request.js +7 -0
- package/dist/workflows/dag/node-execution.js +940 -31
- package/dist/workflows/dag/path-safety.js +1 -0
- package/dist/workflows/dag/prompt.js +99 -7
- package/dist/workflows/dag/recovery-lease.js +170 -0
- package/dist/workflows/dag/report.js +37 -1
- package/dist/workflows/dag/rerun-feedback.js +315 -1
- package/dist/workflows/dag/rerun-plan.js +568 -3
- package/dist/workflows/dag/rerun-run.js +642 -18
- package/dist/workflows/dag/rerun-task.js +251 -13
- package/dist/workflows/dag/retry-policy.js +219 -104
- package/dist/workflows/dag/runner.js +596 -121
- package/dist/workflows/dag/scheduler.js +133 -20
- package/dist/workflows/dag/skill-snapshot.js +17 -0
- package/dist/workflows/dag/types.js +426 -22
- package/dist/workflows/dag/validate.js +28 -12
- package/docs/architecture/runtime-boundaries.md +6 -6
- package/docs/architecture/worker-and-feature.md +1 -1
- package/docs/examples/README.md +5 -0
- package/docs/init-surface.manifest.json +30 -12
- package/docs/skills/vetted-skill-registry.md +4 -2
- package/docs/templates/README.md +2 -0
- package/docs/templates/agent-dag-report.schema.json +8 -2
- package/docs/templates/agent-dag.schema.json +33 -1
- package/docs/templates/backend-test-dag.json +23 -20
- package/docs/templates/frontend-implementation-contract.schema.json +4 -1
- package/docs/templates/frontend-implementation-dag.json +89 -0
- package/docs/templates/product-line/task.yaml +1 -1
- package/docs/templates/spec-registry.schema.json +45 -0
- package/harness.json +1 -1
- package/package.json +6 -3
- package/skills/frontend-bounded-implement/SKILL.md +15 -14
- package/skills/frontend-bounded-implement/references/code-standards.md +19 -0
- package/skills/frontend-contract/SKILL.md +23 -0
- package/skills/frontend-contract/references/contract-protocol.md +34 -0
- package/skills/frontend-design-review/SKILL.md +22 -41
- package/skills/frontend-plan/SKILL.md +26 -0
- package/skills/frontend-plan/references/decision-contract.md +37 -0
- package/skills/frontend-plan/references/design-decisions.md +17 -0
- package/skills/frontend-review/SKILL.md +20 -15
- package/skills/frontend-review/references/review-findings.md +6 -7
- package/skills/frontend-scout/SKILL.md +25 -0
- package/skills/frontend-scout/references/design-evidence.md +16 -0
- package/skills/frontend-scout/references/scout-evidence.md +23 -0
- package/skills/frontend-verification/SKILL.md +1 -1
- package/skills/loop-agent/references/command-reference.md +7 -0
- package/skills/loop-agent/references/hybrid-dag.md +2 -2
- package/dist/worker/console/operation-store.js +0 -169
- package/dist/worker/console/static/assets/channel-D1xajGpe.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-BmuGTfRr.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-BmuGTfRr.js +0 -1
- package/dist/worker/console/static/assets/index-BLzcAykx.js +0 -451
- package/dist/worker/console/static/assets/index-Cs9JUSPs.css +0 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-D9ykKEWP.js +0 -1
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-BvPOXALT.js +0 -8
- package/skills/frontend-implementation/SKILL.md +0 -52
- package/skills/frontend-implementation/references/code-standards.md +0 -33
- package/skills/frontend-implementation/references/design-spec.md +0 -56
- package/skills/frontend-implementation/references/node-contracts.md +0 -31
- /package/dist/{worker → infrastructure}/console/repo-fingerprint.js +0 -0
|
@@ -1,9 +1,202 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { z } from "zod";
|
|
3
4
|
import { assertTaskContractBindingFresh } from "./task-contract-binding.js";
|
|
4
5
|
import { isSafeReadOnlyPiRetryCandidate, isTransportCrashedExclusiveWriter } from "./retry-policy.js";
|
|
5
6
|
import { resolveDagTaskSourcePath } from "../../task/dag-source-paths.js";
|
|
6
7
|
import { composeDagPromptOverridePrompt, MAX_DAG_RERUN_PROMPT_OVERRIDE_CHARS, } from "../../shared/dag-prompt-override.js";
|
|
8
|
+
import { artifactOverrideSetV1Schema, workerContinuationAuthorityV1Schema, } from "../../shared/context-transfer.js";
|
|
9
|
+
import { buildArtifactBindingGraph, computeArtifactImpact, } from "./artifact-bindings.js";
|
|
10
|
+
import { assertValidMaterializedDagTask } from "./validate.js";
|
|
11
|
+
const rerunBindingsV1Schema = z
|
|
12
|
+
.object({
|
|
13
|
+
sourceBindingMatched: z.boolean(),
|
|
14
|
+
taskContractBindingMatched: z.boolean(),
|
|
15
|
+
controllerIdentityMatched: z.boolean(),
|
|
16
|
+
skillSnapshotVerified: z.boolean(),
|
|
17
|
+
workspaceMatched: z.boolean(),
|
|
18
|
+
})
|
|
19
|
+
.strict();
|
|
20
|
+
const hash64Schema = z.string().regex(/^[a-f0-9]{64}$/);
|
|
21
|
+
const highRiskContinuationAuthorityV1Schema = z
|
|
22
|
+
.object({
|
|
23
|
+
schemaVersion: z.literal(1),
|
|
24
|
+
workspaceFingerprint: hash64Schema,
|
|
25
|
+
writer: z
|
|
26
|
+
.object({
|
|
27
|
+
nodeIds: z.array(z.string().min(1)).min(1),
|
|
28
|
+
writeSet: z.array(z.string().min(1)).min(1),
|
|
29
|
+
writeSetSha256: hash64Schema,
|
|
30
|
+
})
|
|
31
|
+
.strict()
|
|
32
|
+
.optional(),
|
|
33
|
+
dynamic: z
|
|
34
|
+
.object({
|
|
35
|
+
nodeIds: z.array(z.string().min(1)).min(1),
|
|
36
|
+
graphSha256: hash64Schema,
|
|
37
|
+
})
|
|
38
|
+
.strict()
|
|
39
|
+
.optional(),
|
|
40
|
+
budget: z
|
|
41
|
+
.object({
|
|
42
|
+
parentLedgerSha256: hash64Schema,
|
|
43
|
+
inheritedConsumed: z
|
|
44
|
+
.object({
|
|
45
|
+
tokens: z.number().int().nonnegative().nullable(),
|
|
46
|
+
wallTimeMs: z.number().nonnegative(),
|
|
47
|
+
executorCalls: z.number().int().nonnegative(),
|
|
48
|
+
repairPasses: z.number().int().nonnegative(),
|
|
49
|
+
peakContextChars: z.number().int().nonnegative(),
|
|
50
|
+
missingTokenNodeIds: z.array(z.string()),
|
|
51
|
+
})
|
|
52
|
+
.strict(),
|
|
53
|
+
})
|
|
54
|
+
.strict()
|
|
55
|
+
.optional(),
|
|
56
|
+
})
|
|
57
|
+
.strict();
|
|
58
|
+
const rerunPlanCommonSchema = {
|
|
59
|
+
eligible: z.boolean(),
|
|
60
|
+
parentRunId: z.string().min(1),
|
|
61
|
+
parentLifecycle: z.enum(["completed", "dry-run", "init-only"]),
|
|
62
|
+
selectedNodeId: z.string().min(1),
|
|
63
|
+
effectiveFromNodeId: z.string().min(1).optional(),
|
|
64
|
+
rewriteApplied: z.boolean(),
|
|
65
|
+
resetNodeIds: z.array(z.string().min(1)),
|
|
66
|
+
importedNodeIds: z.array(z.string().min(1)),
|
|
67
|
+
blockingNodes: z.array(z.object({ nodeId: z.string().min(1), reasonCode: z.string().min(1) }).strict()),
|
|
68
|
+
reasonCodes: z.array(z.string().min(1)),
|
|
69
|
+
blockedReasons: z.array(z.string().min(1)),
|
|
70
|
+
risk: z.enum(["low", "medium", "high"]),
|
|
71
|
+
verificationPolicy: z
|
|
72
|
+
.object({
|
|
73
|
+
mode: z.enum(["inherited", "rerun"]),
|
|
74
|
+
nodeIds: z.array(z.string().min(1)),
|
|
75
|
+
inheritedFromRunId: z.string().min(1).optional(),
|
|
76
|
+
})
|
|
77
|
+
.strict()
|
|
78
|
+
.optional(),
|
|
79
|
+
workerAssociation: z.discriminatedUnion("kind", [
|
|
80
|
+
z.object({ kind: z.literal("standalone") }).strict(),
|
|
81
|
+
z
|
|
82
|
+
.object({
|
|
83
|
+
kind: z.literal("worker-managed"),
|
|
84
|
+
featureId: z.string().min(1).optional(),
|
|
85
|
+
taskId: z.string().min(1).optional(),
|
|
86
|
+
workerRunId: z.string().min(1).optional(),
|
|
87
|
+
})
|
|
88
|
+
.strict(),
|
|
89
|
+
]),
|
|
90
|
+
estimatedExecution: z
|
|
91
|
+
.object({
|
|
92
|
+
nodeCount: z.number().int().nonnegative(),
|
|
93
|
+
piCallCount: z.number().int().nonnegative(),
|
|
94
|
+
shellNodeCount: z.number().int().nonnegative(),
|
|
95
|
+
avoidedNodeCount: z.number().int().nonnegative(),
|
|
96
|
+
avoidedPiCallCount: z.number().int().nonnegative(),
|
|
97
|
+
})
|
|
98
|
+
.strict(),
|
|
99
|
+
suggestedAction: z.enum([
|
|
100
|
+
"dag-rerun",
|
|
101
|
+
"standalone-task-rerun",
|
|
102
|
+
"worker-task-retry",
|
|
103
|
+
"regenerate",
|
|
104
|
+
"resume",
|
|
105
|
+
"reconcile",
|
|
106
|
+
"manual",
|
|
107
|
+
]),
|
|
108
|
+
promptOverrides: z
|
|
109
|
+
.array(z
|
|
110
|
+
.object({
|
|
111
|
+
nodeId: z.string().min(1),
|
|
112
|
+
mode: z.enum(["replace", "append"]),
|
|
113
|
+
basePromptSha256: z.string().regex(/^[a-f0-9]{64}$/),
|
|
114
|
+
promptSha256: z.string().regex(/^[a-f0-9]{64}$/),
|
|
115
|
+
})
|
|
116
|
+
.strict())
|
|
117
|
+
.optional(),
|
|
118
|
+
workerContinuationAuthority: workerContinuationAuthorityV1Schema.optional(),
|
|
119
|
+
highRiskAuthority: highRiskContinuationAuthorityV1Schema.optional(),
|
|
120
|
+
};
|
|
121
|
+
export const dagRerunPlanV2Schema = z
|
|
122
|
+
.object({
|
|
123
|
+
schemaVersion: z.literal(2),
|
|
124
|
+
...rerunPlanCommonSchema,
|
|
125
|
+
trigger: z.enum(["node-rerun", "prompt-override", "artifact-override"]),
|
|
126
|
+
artifactOverrides: artifactOverrideSetV1Schema.optional(),
|
|
127
|
+
impact: z
|
|
128
|
+
.object({
|
|
129
|
+
producerNodeId: z.string().min(1).optional(),
|
|
130
|
+
directConsumerNodeIds: z.array(z.string().min(1)),
|
|
131
|
+
effectiveFromNodeId: z.string().min(1),
|
|
132
|
+
affectedNodeIds: z.array(z.string().min(1)),
|
|
133
|
+
importedNodeIds: z.array(z.string().min(1)),
|
|
134
|
+
blockedNodeIds: z.array(z
|
|
135
|
+
.object({ nodeId: z.string().min(1), reasonCode: z.string().min(1) })
|
|
136
|
+
.strict()),
|
|
137
|
+
})
|
|
138
|
+
.strict(),
|
|
139
|
+
bindings: rerunBindingsV1Schema
|
|
140
|
+
.extend({
|
|
141
|
+
artifactGraphSha256: hash64Schema,
|
|
142
|
+
overrideSetHash: hash64Schema.optional(),
|
|
143
|
+
stagingRevisionSha256: hash64Schema.optional(),
|
|
144
|
+
parentWorkspaceFingerprint: hash64Schema.optional(),
|
|
145
|
+
currentWorkspaceFingerprint: hash64Schema.optional(),
|
|
146
|
+
budgetLedgerSha256: hash64Schema.optional(),
|
|
147
|
+
})
|
|
148
|
+
.strict(),
|
|
149
|
+
planHash: z.string().regex(/^[a-f0-9]{64}$/),
|
|
150
|
+
})
|
|
151
|
+
.strict()
|
|
152
|
+
.superRefine((plan, ctx) => {
|
|
153
|
+
const artifactTrigger = plan.trigger === "artifact-override";
|
|
154
|
+
if (artifactTrigger !== Boolean(plan.artifactOverrides)) {
|
|
155
|
+
ctx.addIssue({
|
|
156
|
+
code: z.ZodIssueCode.custom,
|
|
157
|
+
path: ["artifactOverrides"],
|
|
158
|
+
message: "artifact override trigger and override set must appear together",
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
if (plan.artifactOverrides &&
|
|
162
|
+
(plan.bindings.overrideSetHash !== plan.artifactOverrides.overrideSetHash ||
|
|
163
|
+
!plan.bindings.stagingRevisionSha256)) {
|
|
164
|
+
ctx.addIssue({
|
|
165
|
+
code: z.ZodIssueCode.custom,
|
|
166
|
+
path: ["bindings"],
|
|
167
|
+
message: "artifact override bindings must match the override set and revision",
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
if (plan.workerContinuationAuthority &&
|
|
171
|
+
plan.workerAssociation.kind !== "worker-managed") {
|
|
172
|
+
ctx.addIssue({
|
|
173
|
+
code: z.ZodIssueCode.custom,
|
|
174
|
+
path: ["workerContinuationAuthority"],
|
|
175
|
+
message: "Worker continuation authority requires a Worker-managed parent",
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
if (plan.highRiskAuthority) {
|
|
179
|
+
if (plan.bindings.parentWorkspaceFingerprint !==
|
|
180
|
+
plan.highRiskAuthority.workspaceFingerprint ||
|
|
181
|
+
plan.bindings.currentWorkspaceFingerprint !==
|
|
182
|
+
plan.highRiskAuthority.workspaceFingerprint) {
|
|
183
|
+
ctx.addIssue({
|
|
184
|
+
code: z.ZodIssueCode.custom,
|
|
185
|
+
path: ["highRiskAuthority", "workspaceFingerprint"],
|
|
186
|
+
message: "high-risk authority must bind the matching workspace fingerprints",
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
if (plan.highRiskAuthority.budget &&
|
|
190
|
+
plan.bindings.budgetLedgerSha256 !==
|
|
191
|
+
plan.highRiskAuthority.budget.parentLedgerSha256) {
|
|
192
|
+
ctx.addIssue({
|
|
193
|
+
code: z.ZodIssueCode.custom,
|
|
194
|
+
path: ["bindings", "budgetLedgerSha256"],
|
|
195
|
+
message: "budget ledger binding must match high-risk authority",
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
});
|
|
7
200
|
const REVIEW_VERDICT_RECOVERY_NODE_ID = "review-verdict-recovery-pi";
|
|
8
201
|
const SAFE_SHELL_GATE_KEYS = [
|
|
9
202
|
"verdictGate",
|
|
@@ -117,6 +310,68 @@ function isWriterTask(task, spec) {
|
|
|
117
310
|
const writePolicy = resolveWritePolicy(task, spec);
|
|
118
311
|
return writePolicy === "exclusive" || writePolicy === "docs-only";
|
|
119
312
|
}
|
|
313
|
+
function passesWriterBoundaryValidation(task, parentSpec) {
|
|
314
|
+
try {
|
|
315
|
+
assertValidMaterializedDagTask(task, parentSpec);
|
|
316
|
+
return true;
|
|
317
|
+
}
|
|
318
|
+
catch {
|
|
319
|
+
return false;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
function isBoundedArtifactContinuationWriter(task, parentSpec) {
|
|
323
|
+
return (task.executor === "pi" &&
|
|
324
|
+
task.toolProfile === "write" &&
|
|
325
|
+
task.writePolicy === "exclusive" &&
|
|
326
|
+
(task.writeSet?.length ?? 0) > 0 &&
|
|
327
|
+
(task.allowedPaths?.length ?? 0) > 0 &&
|
|
328
|
+
(task.forbiddenPaths?.length ?? 0) > 0 &&
|
|
329
|
+
passesWriterBoundaryValidation(task, parentSpec));
|
|
330
|
+
}
|
|
331
|
+
function isDynamicWriterTemplate(task) {
|
|
332
|
+
return (task.toolProfile === "write" ||
|
|
333
|
+
task.writePolicy === "exclusive" ||
|
|
334
|
+
task.writePolicy === "docs-only");
|
|
335
|
+
}
|
|
336
|
+
function isBoundedDynamicWriterTemplate(task, parentSpec) {
|
|
337
|
+
if (!(task.executor === "pi" &&
|
|
338
|
+
task.toolProfile === "write" &&
|
|
339
|
+
task.writePolicy === "exclusive" &&
|
|
340
|
+
(task.writeSet?.length ?? 0) > 0 &&
|
|
341
|
+
(task.allowedPaths?.length ?? 0) > 0 &&
|
|
342
|
+
(task.forbiddenPaths?.length ?? 0) > 0))
|
|
343
|
+
return false;
|
|
344
|
+
return passesWriterBoundaryValidation({
|
|
345
|
+
id: "continuation-dynamic-writer-template",
|
|
346
|
+
depends_on: [],
|
|
347
|
+
executor: task.executor,
|
|
348
|
+
role: task.role,
|
|
349
|
+
complexity: task.complexity,
|
|
350
|
+
subtask_prompt: task.subtaskPromptTemplate,
|
|
351
|
+
toolProfile: task.toolProfile,
|
|
352
|
+
writePolicy: task.writePolicy,
|
|
353
|
+
allowedPaths: task.allowedPaths,
|
|
354
|
+
forbiddenPaths: task.forbiddenPaths,
|
|
355
|
+
writeSet: task.writeSet,
|
|
356
|
+
outputContract: task.outputContract,
|
|
357
|
+
}, parentSpec);
|
|
358
|
+
}
|
|
359
|
+
function collectDynamicWriterTemplates(task) {
|
|
360
|
+
const writers = [];
|
|
361
|
+
const expansionChild = task.dynamicExpansion?.childTask;
|
|
362
|
+
if (expansionChild && isDynamicWriterTemplate(expansionChild)) {
|
|
363
|
+
writers.push({ id: `${task.id}#child`, task: expansionChild });
|
|
364
|
+
}
|
|
365
|
+
for (const bodyTask of task.dynamicLoopUntil?.bodyTasks ?? []) {
|
|
366
|
+
if (isDynamicWriterTemplate(bodyTask)) {
|
|
367
|
+
writers.push({ id: `${task.id}#${bodyTask.id}`, task: bodyTask });
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
return writers;
|
|
371
|
+
}
|
|
372
|
+
function hasOnlyBoundedDynamicWriters(task, parentSpec) {
|
|
373
|
+
return collectDynamicWriterTemplates(task).every(({ task: writer }) => isBoundedDynamicWriterTemplate(writer, parentSpec));
|
|
374
|
+
}
|
|
120
375
|
function hasDynamicRuntime(task) {
|
|
121
376
|
return Boolean(task.dynamicExpansion ||
|
|
122
377
|
task.dynamicReduction ||
|
|
@@ -160,12 +415,16 @@ function isCanonicalGeneratedVerifyShell(task) {
|
|
|
160
415
|
return false;
|
|
161
416
|
if (shell.projectGovernanceGate)
|
|
162
417
|
return false;
|
|
163
|
-
if (shell.
|
|
418
|
+
if (shell.frontendDesignPolicy)
|
|
419
|
+
return false;
|
|
420
|
+
if (shell.frontendWriterAdmission)
|
|
164
421
|
return false;
|
|
165
422
|
if (shell.frontendVerificationBundle)
|
|
166
423
|
return false;
|
|
167
424
|
if (shell.frontendReviewContext)
|
|
168
425
|
return false;
|
|
426
|
+
if (shell.frontendCloseout)
|
|
427
|
+
return false;
|
|
169
428
|
if (shell.backendTestPipeline)
|
|
170
429
|
return false;
|
|
171
430
|
if (shell.nonZeroExitPolicy === "record")
|
|
@@ -174,6 +433,37 @@ function isCanonicalGeneratedVerifyShell(task) {
|
|
|
174
433
|
return false;
|
|
175
434
|
return true;
|
|
176
435
|
}
|
|
436
|
+
/**
|
|
437
|
+
* Frozen frontend workflow shells are deterministic runtime adapters. They may
|
|
438
|
+
* materialize run-owned evidence or run the already-frozen verification
|
|
439
|
+
* commands, but they do not receive a generic shell-continuation exemption.
|
|
440
|
+
*/
|
|
441
|
+
function isCanonicalFrontendArtifactContinuationShell(task) {
|
|
442
|
+
if (task.executor !== "shell" || task.writePolicy !== "read-only" || !task.shell) {
|
|
443
|
+
return false;
|
|
444
|
+
}
|
|
445
|
+
const shell = task.shell;
|
|
446
|
+
if (shell.envAllowlist?.length || shell.nonZeroExitPolicy === "record")
|
|
447
|
+
return false;
|
|
448
|
+
switch (task.id) {
|
|
449
|
+
case "frontend-prewrite-gate-shell":
|
|
450
|
+
return Boolean(shell.frontendPrewriteGate) && (shell.commands?.length ?? 0) === 0;
|
|
451
|
+
case "frontend-design-policy-shell":
|
|
452
|
+
return Boolean(shell.frontendDesignPolicy) && (shell.commands?.length ?? 0) === 0;
|
|
453
|
+
case "frontend-writer-admission-shell":
|
|
454
|
+
return Boolean(shell.frontendWriterAdmission) && (shell.commands?.length ?? 0) === 0;
|
|
455
|
+
case "frontend-verify-assess-shell":
|
|
456
|
+
case "frontend-reverify-shell":
|
|
457
|
+
case "frontend-verify-shell":
|
|
458
|
+
return Boolean(shell.frontendVerificationBundle) && (shell.commands?.length ?? 0) === 0;
|
|
459
|
+
case "frontend-review-context-shell":
|
|
460
|
+
return Boolean(shell.frontendReviewContext) && (shell.commands?.length ?? 0) === 0;
|
|
461
|
+
case "frontend-closeout-shell":
|
|
462
|
+
return Boolean(shell.frontendCloseout) && (shell.commands?.length ?? 0) === 0;
|
|
463
|
+
default:
|
|
464
|
+
return false;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
177
467
|
function isSafeGateOnlyShell(task) {
|
|
178
468
|
if (task.executor !== "shell")
|
|
179
469
|
return false;
|
|
@@ -191,12 +481,16 @@ function isSafeGateOnlyShell(task) {
|
|
|
191
481
|
return false;
|
|
192
482
|
if (shell.preset)
|
|
193
483
|
return false;
|
|
194
|
-
if (shell.
|
|
484
|
+
if (shell.frontendDesignPolicy)
|
|
485
|
+
return false;
|
|
486
|
+
if (shell.frontendWriterAdmission)
|
|
195
487
|
return false;
|
|
196
488
|
if (shell.frontendVerificationBundle)
|
|
197
489
|
return false;
|
|
198
490
|
if (shell.frontendReviewContext)
|
|
199
491
|
return false;
|
|
492
|
+
if (shell.frontendCloseout)
|
|
493
|
+
return false;
|
|
200
494
|
if (shell.backendTestPipeline)
|
|
201
495
|
return false;
|
|
202
496
|
if (shell.verifyEvidence)
|
|
@@ -323,6 +617,10 @@ export function assessResetClosureSafety(spec, resetNodeIds, options = {}) {
|
|
|
323
617
|
continue;
|
|
324
618
|
}
|
|
325
619
|
if (isWriterTask(task, spec)) {
|
|
620
|
+
if (options.artifactContinuation === true &&
|
|
621
|
+
isBoundedArtifactContinuationWriter(task, spec)) {
|
|
622
|
+
continue;
|
|
623
|
+
}
|
|
326
624
|
if (nodeId === options.allowedTransportWriterNodeId)
|
|
327
625
|
continue;
|
|
328
626
|
if (nodeId === options.allowedExclusiveShellFromNodeId &&
|
|
@@ -345,6 +643,10 @@ export function assessResetClosureSafety(spec, resetNodeIds, options = {}) {
|
|
|
345
643
|
continue;
|
|
346
644
|
}
|
|
347
645
|
if (hasDynamicRuntime(task)) {
|
|
646
|
+
if (options.artifactContinuation === true &&
|
|
647
|
+
hasOnlyBoundedDynamicWriters(task, spec)) {
|
|
648
|
+
continue;
|
|
649
|
+
}
|
|
348
650
|
blockingNodes.push({
|
|
349
651
|
nodeId,
|
|
350
652
|
reasonCode: "dynamic-rerun-unsupported",
|
|
@@ -367,7 +669,9 @@ export function assessResetClosureSafety(spec, resetNodeIds, options = {}) {
|
|
|
367
669
|
}
|
|
368
670
|
if (task.executor === "shell") {
|
|
369
671
|
if (!isSafeGateOnlyShell(task) &&
|
|
370
|
-
!isCanonicalGeneratedVerifyShell(task)
|
|
672
|
+
!isCanonicalGeneratedVerifyShell(task) &&
|
|
673
|
+
!(options.artifactContinuation === true &&
|
|
674
|
+
isCanonicalFrontendArtifactContinuationShell(task))) {
|
|
371
675
|
blockingNodes.push({
|
|
372
676
|
nodeId,
|
|
373
677
|
reasonCode: "restart-subgraph-contains-unsafe-shell",
|
|
@@ -480,6 +784,267 @@ export function computePlanHash(planWithoutHash) {
|
|
|
480
784
|
const canonical = JSON.stringify(sortKeysDeep(planWithoutHash));
|
|
481
785
|
return createHash("sha256").update(canonical, "utf8").digest("hex");
|
|
482
786
|
}
|
|
787
|
+
function hashCanonicalValue(value) {
|
|
788
|
+
return createHash("sha256")
|
|
789
|
+
.update(JSON.stringify(sortKeysDeep(value)), "utf8")
|
|
790
|
+
.digest("hex");
|
|
791
|
+
}
|
|
792
|
+
function collectHighRiskContinuationAuthority(input) {
|
|
793
|
+
const tasks = taskById(input.parentSpec);
|
|
794
|
+
const writerNodeIds = [];
|
|
795
|
+
const writeSet = new Set();
|
|
796
|
+
const dynamicNodeIds = [];
|
|
797
|
+
for (const nodeId of input.affectedNodeIds) {
|
|
798
|
+
const task = tasks.get(nodeId);
|
|
799
|
+
if (!task)
|
|
800
|
+
continue;
|
|
801
|
+
if (isBoundedArtifactContinuationWriter(task, input.parentSpec)) {
|
|
802
|
+
writerNodeIds.push(nodeId);
|
|
803
|
+
for (const pattern of task.writeSet ?? [])
|
|
804
|
+
writeSet.add(pattern);
|
|
805
|
+
}
|
|
806
|
+
if (hasDynamicRuntime(task)) {
|
|
807
|
+
dynamicNodeIds.push(nodeId);
|
|
808
|
+
for (const writer of collectDynamicWriterTemplates(task)) {
|
|
809
|
+
writerNodeIds.push(writer.id);
|
|
810
|
+
for (const pattern of writer.task.writeSet ?? [])
|
|
811
|
+
writeSet.add(pattern);
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
const ledger = input.parentState.budgetLedger;
|
|
816
|
+
const hasHardBudget = (input.parentSpec.budget?.mode ?? input.parentState.budget?.mode) === "hard";
|
|
817
|
+
const highRisk = writerNodeIds.length > 0 || dynamicNodeIds.length > 0 || hasHardBudget;
|
|
818
|
+
if (!highRisk || !input.workspaceFingerprint)
|
|
819
|
+
return undefined;
|
|
820
|
+
const normalizedWriters = [...new Set(writerNodeIds)].sort();
|
|
821
|
+
const normalizedWriteSet = [...writeSet].sort();
|
|
822
|
+
const normalizedDynamic = [...new Set(dynamicNodeIds)].sort();
|
|
823
|
+
return {
|
|
824
|
+
schemaVersion: 1,
|
|
825
|
+
workspaceFingerprint: input.workspaceFingerprint,
|
|
826
|
+
...(normalizedWriters.length > 0
|
|
827
|
+
? {
|
|
828
|
+
writer: {
|
|
829
|
+
nodeIds: normalizedWriters,
|
|
830
|
+
writeSet: normalizedWriteSet,
|
|
831
|
+
writeSetSha256: hashCanonicalValue(normalizedWriteSet),
|
|
832
|
+
},
|
|
833
|
+
}
|
|
834
|
+
: {}),
|
|
835
|
+
...(normalizedDynamic.length > 0
|
|
836
|
+
? {
|
|
837
|
+
dynamic: {
|
|
838
|
+
nodeIds: normalizedDynamic,
|
|
839
|
+
graphSha256: hashCanonicalValue(normalizedDynamic.map((nodeId) => tasks.get(nodeId))),
|
|
840
|
+
},
|
|
841
|
+
}
|
|
842
|
+
: {}),
|
|
843
|
+
...(hasHardBudget && ledger
|
|
844
|
+
? {
|
|
845
|
+
budget: {
|
|
846
|
+
parentLedgerSha256: hashCanonicalValue(ledger),
|
|
847
|
+
inheritedConsumed: structuredClone(ledger.consumed),
|
|
848
|
+
},
|
|
849
|
+
}
|
|
850
|
+
: {}),
|
|
851
|
+
};
|
|
852
|
+
}
|
|
853
|
+
export function evaluateArtifactOverrideRerunPlan(input) {
|
|
854
|
+
const graph = buildArtifactBindingGraph(input.parentSpec);
|
|
855
|
+
const declaration = graph.artifacts.find((artifact) => artifact.artifactId === input.artifactId);
|
|
856
|
+
const impact = computeArtifactImpact(input.parentSpec, input.artifactId);
|
|
857
|
+
const reasonCodes = [];
|
|
858
|
+
const blockedReasons = [];
|
|
859
|
+
const blockingNodes = [];
|
|
860
|
+
const workerAssociation = input.workerAssociation ?? { kind: "standalone" };
|
|
861
|
+
const block = (code, nodeId) => {
|
|
862
|
+
reasonCodes.push(code);
|
|
863
|
+
blockedReasons.push(code);
|
|
864
|
+
if (nodeId)
|
|
865
|
+
blockingNodes.push({ nodeId, reasonCode: code });
|
|
866
|
+
};
|
|
867
|
+
if (!graph.available)
|
|
868
|
+
block("ARTIFACT_BINDING_UNAVAILABLE");
|
|
869
|
+
if (!declaration)
|
|
870
|
+
block("ARTIFACT_IDENTITY_AMBIGUOUS");
|
|
871
|
+
if (!impact)
|
|
872
|
+
block("ARTIFACT_CONSUMER_UNKNOWN", declaration?.producerNodeId);
|
|
873
|
+
if (input.parentLifecycle !== "completed")
|
|
874
|
+
block("parent-lifecycle-ineligible");
|
|
875
|
+
const overrideRevisionId = input.artifactOverrides.overrides[0]?.revisionId;
|
|
876
|
+
const authority = input.workerContinuationAuthority;
|
|
877
|
+
if (workerAssociation.kind === "worker-managed") {
|
|
878
|
+
if (!authority) {
|
|
879
|
+
block("WORKER_MANAGED_CONTINUATION_UNSUPPORTED");
|
|
880
|
+
}
|
|
881
|
+
else if (!workerAssociation.workerRunId ||
|
|
882
|
+
!workerAssociation.featureId ||
|
|
883
|
+
!workerAssociation.taskId ||
|
|
884
|
+
authority.parentWorkerRunId !== workerAssociation.workerRunId ||
|
|
885
|
+
authority.featureId !== workerAssociation.featureId ||
|
|
886
|
+
authority.taskId !== workerAssociation.taskId ||
|
|
887
|
+
authority.revisionId !== overrideRevisionId) {
|
|
888
|
+
block("WORKER_CONTINUATION_AUTHORITY_MISMATCH");
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
else if (authority) {
|
|
892
|
+
block("WORKER_CONTINUATION_AUTHORITY_MISMATCH");
|
|
893
|
+
}
|
|
894
|
+
if (input.parentSpec.convergence?.enabled || input.parentState.convergence?.enabled) {
|
|
895
|
+
block("convergence-rerun-unsupported");
|
|
896
|
+
}
|
|
897
|
+
if (input.parentSpec.evaluation || input.parentState.evaluation) {
|
|
898
|
+
block("evaluation-rerun-unsupported");
|
|
899
|
+
}
|
|
900
|
+
const hardBudget = (input.parentSpec.budget?.mode ?? input.parentState.budget?.mode) === "hard";
|
|
901
|
+
if (hardBudget) {
|
|
902
|
+
const ledger = input.parentState.budgetLedger;
|
|
903
|
+
if (!ledger) {
|
|
904
|
+
block("budget-lineage-missing");
|
|
905
|
+
}
|
|
906
|
+
else if (ledger.status === "breached" || ledger.breaches.length > 0) {
|
|
907
|
+
block("budget-lineage-breached");
|
|
908
|
+
}
|
|
909
|
+
else if (ledger.mode !== "hard" ||
|
|
910
|
+
JSON.stringify(ledger.limits) !==
|
|
911
|
+
JSON.stringify(input.parentSpec.budget?.limits ?? input.parentState.budget?.limits)) {
|
|
912
|
+
block("budget-lineage-drift");
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
for (const [name, matched] of Object.entries(input.bindings)) {
|
|
916
|
+
if (!matched)
|
|
917
|
+
block(`${name}-drift`);
|
|
918
|
+
}
|
|
919
|
+
const override = input.artifactOverrides.overrides[0];
|
|
920
|
+
const parentFact = declaration
|
|
921
|
+
? input.parentState.nodes[declaration.producerNodeId]?.declaredArtifacts?.find((fact) => fact.artifactId === input.artifactId)
|
|
922
|
+
: undefined;
|
|
923
|
+
if (!declaration ||
|
|
924
|
+
declaration.revisionPolicy !== "replace-file" ||
|
|
925
|
+
parentFact?.status !== "materialized" ||
|
|
926
|
+
parentFact.revisionEligible !== true ||
|
|
927
|
+
!parentFact.sha256) {
|
|
928
|
+
block("ARTIFACT_NOT_REVISION_ELIGIBLE", declaration?.producerNodeId);
|
|
929
|
+
}
|
|
930
|
+
if (!override ||
|
|
931
|
+
override.parentArtifact.runId !== input.parentRunId ||
|
|
932
|
+
override.parentArtifact.nodeId !== declaration?.producerNodeId ||
|
|
933
|
+
override.parentArtifact.path !== declaration?.path ||
|
|
934
|
+
override.parentArtifact.sha256 !== parentFact?.sha256 ||
|
|
935
|
+
override.supersedes !== parentFact?.sha256 ||
|
|
936
|
+
override.replacement.sha256 !== input.stagingRevisionSha256) {
|
|
937
|
+
block("ARTIFACT_REVISION_DRIFT", declaration?.producerNodeId);
|
|
938
|
+
}
|
|
939
|
+
const affectedNodeIds = impact?.affectedNodeIds ?? [];
|
|
940
|
+
const importedNodeIds = impact?.importedNodeIds ?? [];
|
|
941
|
+
const closureSafety = assessResetClosureSafety(input.parentSpec, affectedNodeIds, {
|
|
942
|
+
parentNodes: input.parentState.nodes,
|
|
943
|
+
artifactContinuation: true,
|
|
944
|
+
});
|
|
945
|
+
for (const entry of closureSafety.blockingNodes) {
|
|
946
|
+
blockingNodes.push(entry);
|
|
947
|
+
block("ARTIFACT_IMPACT_UNSAFE");
|
|
948
|
+
}
|
|
949
|
+
for (const nodeId of importedNodeIds) {
|
|
950
|
+
const importedTask = taskById(input.parentSpec).get(nodeId);
|
|
951
|
+
if (importedTask?.decisionGate?.enabled) {
|
|
952
|
+
const code = "restart-subgraph-contains-decision-gate";
|
|
953
|
+
blockingNodes.push({ nodeId, reasonCode: code });
|
|
954
|
+
block(code);
|
|
955
|
+
}
|
|
956
|
+
const status = input.parentState.nodes[nodeId]?.status;
|
|
957
|
+
if (status !== "FINISHED" && status !== "SKIPPED") {
|
|
958
|
+
block("parent-facts-invalid", nodeId);
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
const highRiskAuthority = collectHighRiskContinuationAuthority({
|
|
962
|
+
parentSpec: input.parentSpec,
|
|
963
|
+
parentState: input.parentState,
|
|
964
|
+
affectedNodeIds,
|
|
965
|
+
workspaceFingerprint: input.parentTerminalWorkspaceFingerprint,
|
|
966
|
+
});
|
|
967
|
+
const highRiskExpected = affectedNodeIds.some((nodeId) => {
|
|
968
|
+
const task = taskById(input.parentSpec).get(nodeId);
|
|
969
|
+
return Boolean(task && (isWriterTask(task, input.parentSpec) || hasDynamicRuntime(task)));
|
|
970
|
+
}) || hardBudget;
|
|
971
|
+
if (highRiskExpected) {
|
|
972
|
+
if (!input.parentTerminalWorkspaceFingerprint ||
|
|
973
|
+
!input.currentWorkspaceFingerprint) {
|
|
974
|
+
block("workspace-checkpoint-missing");
|
|
975
|
+
}
|
|
976
|
+
else if (input.parentTerminalWorkspaceFingerprint !==
|
|
977
|
+
input.currentWorkspaceFingerprint) {
|
|
978
|
+
block("workspace-drift");
|
|
979
|
+
}
|
|
980
|
+
else if (!highRiskAuthority) {
|
|
981
|
+
block("HIGH_RISK_AUTHORITY_MISSING");
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
const uniqueReasons = [...new Set(reasonCodes)];
|
|
985
|
+
const uniqueBlocked = [...new Set(blockedReasons)];
|
|
986
|
+
const eligible = uniqueBlocked.length === 0;
|
|
987
|
+
const shellNodeIds = affectedNodeIds.filter((nodeId) => taskById(input.parentSpec).get(nodeId)?.executor === "shell");
|
|
988
|
+
const piCallCount = affectedNodeIds.filter((nodeId) => taskById(input.parentSpec).get(nodeId)?.executor === "pi").length;
|
|
989
|
+
const planWithoutHash = {
|
|
990
|
+
schemaVersion: 2,
|
|
991
|
+
eligible,
|
|
992
|
+
parentRunId: input.parentRunId,
|
|
993
|
+
parentLifecycle: input.parentLifecycle,
|
|
994
|
+
selectedNodeId: declaration?.producerNodeId ?? input.artifactId,
|
|
995
|
+
effectiveFromNodeId: impact?.effectiveFromNodeId,
|
|
996
|
+
rewriteApplied: false,
|
|
997
|
+
resetNodeIds: affectedNodeIds,
|
|
998
|
+
importedNodeIds,
|
|
999
|
+
blockingNodes,
|
|
1000
|
+
reasonCodes: uniqueReasons,
|
|
1001
|
+
blockedReasons: uniqueBlocked,
|
|
1002
|
+
risk: !eligible ? "high" : affectedNodeIds.length <= 2 ? "low" : "medium",
|
|
1003
|
+
bindings: {
|
|
1004
|
+
...input.bindings,
|
|
1005
|
+
artifactGraphSha256: graph.artifactGraphSha256,
|
|
1006
|
+
overrideSetHash: input.artifactOverrides.overrideSetHash,
|
|
1007
|
+
stagingRevisionSha256: input.stagingRevisionSha256,
|
|
1008
|
+
...(input.parentTerminalWorkspaceFingerprint
|
|
1009
|
+
? { parentWorkspaceFingerprint: input.parentTerminalWorkspaceFingerprint }
|
|
1010
|
+
: {}),
|
|
1011
|
+
...(input.currentWorkspaceFingerprint
|
|
1012
|
+
? { currentWorkspaceFingerprint: input.currentWorkspaceFingerprint }
|
|
1013
|
+
: {}),
|
|
1014
|
+
...(highRiskAuthority?.budget
|
|
1015
|
+
? { budgetLedgerSha256: highRiskAuthority.budget.parentLedgerSha256 }
|
|
1016
|
+
: {}),
|
|
1017
|
+
},
|
|
1018
|
+
...(shellNodeIds.length > 0
|
|
1019
|
+
? { verificationPolicy: { mode: "rerun", nodeIds: shellNodeIds } }
|
|
1020
|
+
: {}),
|
|
1021
|
+
workerAssociation,
|
|
1022
|
+
...(authority ? { workerContinuationAuthority: authority } : {}),
|
|
1023
|
+
...(highRiskAuthority ? { highRiskAuthority } : {}),
|
|
1024
|
+
estimatedExecution: {
|
|
1025
|
+
nodeCount: affectedNodeIds.length,
|
|
1026
|
+
piCallCount,
|
|
1027
|
+
shellNodeCount: shellNodeIds.length,
|
|
1028
|
+
avoidedNodeCount: importedNodeIds.length,
|
|
1029
|
+
avoidedPiCallCount: importedNodeIds.filter((nodeId) => taskById(input.parentSpec).get(nodeId)?.executor === "pi").length,
|
|
1030
|
+
},
|
|
1031
|
+
suggestedAction: eligible ? "dag-rerun" : workerAssociation.kind === "worker-managed" ? "worker-task-retry" : "manual",
|
|
1032
|
+
trigger: "artifact-override",
|
|
1033
|
+
artifactOverrides: input.artifactOverrides,
|
|
1034
|
+
impact: {
|
|
1035
|
+
...(impact ? { producerNodeId: impact.producerNodeId } : {}),
|
|
1036
|
+
directConsumerNodeIds: impact?.directConsumerNodeIds ?? [],
|
|
1037
|
+
effectiveFromNodeId: impact?.effectiveFromNodeId ?? declaration?.producerNodeId ?? input.artifactId,
|
|
1038
|
+
affectedNodeIds,
|
|
1039
|
+
importedNodeIds,
|
|
1040
|
+
blockedNodeIds: blockingNodes,
|
|
1041
|
+
},
|
|
1042
|
+
};
|
|
1043
|
+
return dagRerunPlanV2Schema.parse({
|
|
1044
|
+
...planWithoutHash,
|
|
1045
|
+
planHash: computePlanHash(planWithoutHash),
|
|
1046
|
+
});
|
|
1047
|
+
}
|
|
483
1048
|
function countExecutorNodes(spec, nodeIds, executor) {
|
|
484
1049
|
const tasks = taskById(spec);
|
|
485
1050
|
return nodeIds.filter((nodeId) => tasks.get(nodeId)?.executor === executor)
|