@tea-agent/loop-agent 0.1.0-fe-test.3 → 0.1.0-fe-test.5
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 +6 -3
- package/CHANGELOG.md +607 -93
- package/README.md +11 -5
- package/bin/loop-agent.js +7 -3
- 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 +90 -21
- package/dist/application/dag/run-dag.js +41 -0
- package/dist/application/task-lifecycle/advance.js +40 -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 +44 -10
- package/dist/cli/program.js +82 -6
- package/dist/cli/update/notifier.js +2 -2
- package/dist/cli/update/runtime-activity.js +1 -29
- package/dist/cli.js +2 -1
- package/dist/commands/client-recovery.js +11 -36
- 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 +261 -2
- package/dist/commands/init-model-catalog.js +486 -0
- package/dist/commands/init-upgrade.js +265 -97
- package/dist/commands/init.js +455 -28
- package/dist/commands/inspect-next.js +8 -0
- package/dist/commands/task-advance.js +73 -1
- package/dist/commands/task-source-prepare.js +5 -0
- package/dist/commands/task-status.js +1 -0
- package/dist/executors/dag-pi-executor.js +4323 -231
- package/dist/executors/pi-event-serializer.js +42 -1
- package/dist/executors/pi-executor.js +70 -6
- package/dist/executors/pi-extension-resolver.js +245 -0
- package/dist/executors/pi-playwright-cli-tool.js +74 -28
- package/dist/executors/pi-read-budget-policy.js +239 -0
- package/dist/executors/pi-sdk-executor.js +263 -59
- package/dist/executors/pi-writer-tool-policy.js +57 -1
- package/dist/executors/shell-executor.js +1456 -240
- package/dist/executors/shell-write-guard.js +14 -0
- package/dist/executors/workspace-write-snapshot.js +68 -0
- package/dist/governance/checks.js +1 -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 +35 -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 +150 -0
- package/dist/shared/dag-prompt-override.js +27 -0
- package/dist/shared/openspec-spec.js +70 -4
- package/dist/shared/operator/capabilities.js +65 -4
- package/dist/shared/operator/safe-run-summary.js +1 -0
- package/dist/shared/path-safety.js +93 -0
- package/dist/shared/pi-context-pressure/checkpoint.js +116 -0
- package/dist/shared/pi-context-pressure/compaction-policy.js +151 -0
- package/dist/shared/pi-context-pressure/env.js +58 -0
- package/dist/shared/pi-context-pressure/extension.js +100 -0
- package/dist/shared/pi-context-pressure/index.js +7 -0
- package/dist/shared/pi-context-pressure/overflow.js +252 -0
- package/dist/shared/pi-context-pressure/sift-bridge.js +386 -0
- package/dist/shared/pi-context-pressure/telemetry.js +51 -0
- package/dist/shared/playwright-cli-command-policy.js +15 -0
- package/dist/shared/preview.js +28 -4
- package/dist/shared/update/console-notifier.js +100 -0
- package/dist/{cli → shared}/update/npm-client.js +70 -15
- package/dist/{cli → shared}/update/state.js +41 -13
- package/dist/task/config-types.js +125 -6
- package/dist/task/contract/adopt.js +4 -0
- package/dist/task/contract/apply.js +11 -1
- package/dist/task/contract/constants.js +3 -0
- package/dist/task/contract/diff.js +26 -0
- package/dist/task/contract/hash.js +3 -0
- package/dist/task/contract/import-revision.js +4 -0
- package/dist/task/contract/observe.js +25 -4
- package/dist/task/contract/paths.js +2 -1
- package/dist/task/contract/project.js +23 -1
- package/dist/task/contract/schema.js +9 -1
- package/dist/task/contract/transaction.js +12 -0
- package/dist/task/frontend-project-capability.js +203 -20
- package/dist/task/runtime.js +5 -2
- package/dist/task/source-prepare/build-draft.js +18 -3
- package/dist/task/source-prepare/completeness.js +188 -0
- package/dist/task/source-prepare/fragment-inventory.js +513 -0
- package/dist/task/source-prepare/index.js +3 -0
- package/dist/task/source-prepare/ledger-reconciliation.js +127 -0
- package/dist/task/source-prepare/ledger-review.js +214 -0
- package/dist/task/source-prepare/ledger.js +545 -0
- package/dist/task/source-prepare/parse-intent.js +24 -4
- package/dist/task/source-prepare/prepare.js +368 -2
- package/dist/task/source-prepare/semantic-intake.js +25 -5
- package/dist/task/source-prepare/source-fidelity-pi.js +384 -0
- package/dist/task/source-prepare/types.js +22 -0
- package/dist/task/source-references.js +22 -1
- package/dist/task/task-demand-routing.js +3 -0
- package/dist/worker/cli.js +18 -2
- package/dist/worker/console/chat/assistant-content.js +7 -0
- package/dist/worker/console/chat/chat-event-store.js +159 -18
- package/dist/worker/console/chat/chat-ui-policy.js +4 -2
- package/dist/worker/console/chat/context-panel.js +7 -0
- package/dist/worker/console/chat/deferred-turn.js +103 -0
- package/dist/worker/console/chat/goal-round-driver.js +72 -0
- package/dist/worker/console/chat/goals.js +300 -0
- package/dist/worker/console/chat/model-resolver.js +7 -4
- package/dist/worker/console/chat/operation-card.js +8 -1
- package/dist/worker/console/chat/pi-console-config.js +81 -10
- package/dist/worker/console/chat/pi-runtime.js +868 -30
- package/dist/worker/console/chat/provider-error.js +99 -0
- package/dist/worker/console/chat/repo-browser.js +101 -12
- package/dist/worker/console/chat/resource-preferences-store.js +1 -1
- package/dist/worker/console/chat/routes.js +1451 -145
- package/dist/worker/console/chat/sdd-data-alignment.js +222 -0
- package/dist/worker/console/chat/semantic-activity.js +25 -24
- package/dist/worker/console/chat/session-catalog.js +50 -0
- package/dist/worker/console/chat/session-stats.js +275 -0
- package/dist/worker/console/chat/session-store.js +348 -76
- package/dist/worker/console/chat/shortcuts.js +26 -3
- package/dist/worker/console/chat/sift-bridge.js +1 -0
- package/dist/worker/console/chat/todos.js +115 -0
- package/dist/worker/console/chat/tool-preview.js +42 -0
- package/dist/worker/console/chat/turn-process.js +185 -112
- package/dist/worker/console/chat/user-questions.js +266 -0
- package/dist/worker/console/chat/workspace-landing.js +79 -0
- package/dist/worker/console/console-handoff.js +82 -0
- package/dist/worker/console/console-update-and-init.js +115 -0
- package/dist/worker/console/console-update-runtime.js +84 -0
- 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 +54 -3
- package/dist/worker/console/doctor.js +1 -1
- package/dist/worker/console/draft-store.js +50 -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/inspect-split.js +18 -0
- package/dist/worker/console/interview/assessment.js +1 -1
- package/dist/worker/console/interview/session.js +1 -1
- package/dist/worker/console/native-directory-picker.js +13 -0
- package/dist/worker/console/operation-run-facts.js +19 -3
- 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 +534 -15
- package/dist/worker/console/operator-selection.js +6 -2
- package/dist/worker/console/operator-surface-health.js +2 -1
- package/dist/worker/console/operator-user-error.js +171 -2
- package/dist/worker/console/pi-plugins.catalog.json +73658 -0
- package/dist/worker/console/pi-plugins.js +238 -0
- package/dist/worker/console/pi-readiness.js +7 -6
- package/dist/worker/console/prd-intake-bridge.js +13 -0
- package/dist/worker/console/recovery-cta.js +4 -4
- package/dist/worker/console/recovery-error-copy.js +4 -4
- package/dist/worker/console/routes.js +1231 -10
- package/dist/worker/console/security.js +102 -13
- package/dist/worker/console/server.js +762 -159
- package/dist/worker/console/static/assets/{abnfDiagram-N423BO3Z-BmOEx0gA.js → abnfDiagram-N423BO3Z-BZogYNl1.js} +1 -1
- package/dist/worker/console/static/assets/{arc-BGiVVe8b.js → arc-DcJTLe2v.js} +1 -1
- package/dist/worker/console/static/assets/{architectureDiagram-T3A2C74G-nDdu4rgJ.js → architectureDiagram-T3A2C74G-B39EQQ9n.js} +1 -1
- package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-Bb5u0BWf.js → blockDiagram-VBNYF7ZC-CitCGV56.js} +1 -1
- package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-BlhC0j94.js → c4Diagram-5PPSVZJV-rvWuOHLG.js} +1 -1
- package/dist/worker/console/static/assets/channel-CXqdP5pW.js +1 -0
- package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-Ai8_qQXI.js → chunk-2GRJ4B5K-DGXplIJs.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-B9gyCjqX.js → chunk-2Q5K7J3B-ur9OqjPn.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5RXB4S5H-Bzbj3zGH.js → chunk-5RXB4S5H-D1KqU_Vi.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5VM5RSS4-BT415PvT.js → chunk-5VM5RSS4-BlVZrbtM.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-D_A5_5QL.js → chunk-6Q2QTUOP-BAzz3nQy.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-GF5L2VYU-srJkaP3f.js → chunk-GF5L2VYU-CP_nYuCV.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-JWPE2WC7-UYGvEP4l.js → chunk-JWPE2WC7-CWvKQ80X.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-KBJHAD2P-B8luBrrz.js → chunk-KBJHAD2P-CyUki8wp.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-RYQCIY6F-DN7wXZSq.js → chunk-RYQCIY6F-5NYzNKfY.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-XXDRQBXY-DXKyMuKS.js → chunk-XXDRQBXY-DHdUgjS-.js} +1 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-D9C3agF7.js +1 -0
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-D9C3agF7.js +1 -0
- package/dist/worker/console/static/assets/{cose-bilkent-JH36ORCC-dqvoynXj.js → cose-bilkent-JH36ORCC-ANQ5g_t6.js} +1 -1
- package/dist/worker/console/static/assets/{cynefin-VYW2F7L2--PcyL34A.js → cynefin-VYW2F7L2-CruT_4-0.js} +1 -1
- package/dist/worker/console/static/assets/{cynefinDiagram-MW4NZA55-DvWs_hTY.js → cynefinDiagram-MW4NZA55-rbFo77ID.js} +1 -1
- package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-DxeIxbyO.js → dagre-VZM6K2ZE-asstxBQs.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-7IWD3JNH-DPCG61Of.js → diagram-7IWD3JNH-DzTyBZwI.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-CmuU50-U.js → diagram-B4RE2ZJO-gw8ccH3B.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-LBJQPF4R-B61XLD_v.js → diagram-LBJQPF4R-B8RpZzOf.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-Q27KOJAE-BB7HTRRY.js → diagram-Q27KOJAE-B1zJkCS9.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-UB23O5K3-DvkboAIp.js → diagram-UB23O5K3-B6JLWZmO.js} +1 -1
- package/dist/worker/console/static/assets/{ebnfDiagram-BXEA7PRR-BdJ_y1fL.js → ebnfDiagram-BXEA7PRR-q2iZP-Ps.js} +1 -1
- package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-9bUBZTRi.js → erDiagram-JOGREHBK-B3dbbktQ.js} +1 -1
- package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-Dw4L4RBa.js → flowDiagram-UKHOOZJN-C-zc6-kB.js} +1 -1
- package/dist/worker/console/static/assets/{ganttDiagram-PKOTCBZU-Jr82N_QP.js → ganttDiagram-PKOTCBZU-BSolnot9.js} +1 -1
- package/dist/worker/console/static/assets/{gitGraphDiagram-DS77QQ5N-DAz9wFLr.js → gitGraphDiagram-DS77QQ5N-Bo8jGxTk.js} +1 -1
- package/dist/worker/console/static/assets/index-CAZ2fC_X.css +1 -0
- package/dist/worker/console/static/assets/index-DhfjOafu.js +449 -0
- package/dist/worker/console/static/assets/{infoDiagram-6WML65LV-CBB5Np7y.js → infoDiagram-6WML65LV-DQaZqJOH.js} +1 -1
- package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-D8IOp94y.js → ishikawaDiagram-WSZJBQD7-DsdX1WnE.js} +1 -1
- package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-Dgd3AHGG.js → journeyDiagram-NVQOT4AX-CP5EYDZL.js} +1 -1
- package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-BmYOxLE9.js → kanban-definition-27J2QSJJ-DAm14Dr8.js} +1 -1
- package/dist/worker/console/static/assets/{linear-DfYTEF6J.js → linear-gZECoLc5.js} +1 -1
- package/dist/worker/console/static/assets/{mermaid.core-BjuFPRqa.js → mermaid.core-BRJNIM6p.js} +5 -5
- package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-CLyUViGd.js → mindmap-definition-FAOFIHXS-Cja3kLkR.js} +1 -1
- package/dist/worker/console/static/assets/{pegDiagram-VL7TDLO6-BvX2Di4-.js → pegDiagram-VL7TDLO6-22ZGFisL.js} +1 -1
- package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-BFj0_OLv.js → pieDiagram-7S7Q4E2Y-BXin0Y1o.js} +1 -1
- package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-BIUrD_hx.js → quadrantDiagram-CIZ2JOQS-Cw6T69Yt.js} +1 -1
- package/dist/worker/console/static/assets/{railroadDiagram-AXF67PYL-CHBB48fj.js → railroadDiagram-AXF67PYL-C1-gTieN.js} +1 -1
- package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP-sJrYw2Sf.js → requirementDiagram-LRYGKXZP--H5N2iI1.js} +1 -1
- package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-BzHH6fPR.js → sankeyDiagram-W5VNT64P-CgWAPeRz.js} +1 -1
- package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-7QCnelCt.js → sequenceDiagram-SI44F4Z6-CrKqzGvt.js} +1 -1
- package/dist/worker/console/static/assets/{sizeCapture-X5ZJPWSS-sDYSxn72.js → sizeCapture-X5ZJPWSS-BB3wG06K.js} +1 -1
- package/dist/worker/console/static/assets/{stateDiagram-OKZ733FA-XpiUdwzm.js → stateDiagram-OKZ733FA-DjsGgdgY.js} +1 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-Tp7V0U4q.js +1 -0
- package/dist/worker/console/static/assets/{swimlanes-SLNWSIFB-DvqgNPzD.js → swimlanes-SLNWSIFB-DYKEbvAR.js} +2 -2
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-DUZWZWi8.js +8 -0
- package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-2TyOYNx0.js → timeline-definition-Z64GVDOM-eQOb5k9Y.js} +1 -1
- package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-B-nM6wM2.js → vennDiagram-T6HMQDX7-B2-l9FIu.js} +1 -1
- package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-B86wPdbr.js → wardleyDiagram-T6FBY63Y-BX2Cda3l.js} +1 -1
- package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-Dr1C4AQz.js → xychartDiagram-ELKLHX3M-D9S892ph.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/console-types.js +68 -4
- package/dist/worker/console/static-src/app/useConsoleShell.js +30 -12
- package/dist/worker/console/static-src/app/useOperatorActions.js +43 -7
- package/dist/worker/console/static-src/app/useRecoveryActions.js +2 -2
- package/dist/worker/console/static-src/app/useRecoveryConsole.js +45 -10
- package/dist/worker/console/static-src/app/useRunProgress.js +54 -0
- package/dist/worker/console/static-src/app/useTaskWizard.js +74 -2
- package/dist/worker/console/static-src/night/useNightBoard.js +8 -5
- package/dist/worker/console/static-src/operator-chat/cards/failure-category-advice.js +25 -0
- package/dist/worker/console/static-src/operator-chat/chat-sse-events.js +264 -13
- package/dist/worker/console/static-src/operator-chat/compaction-message.js +113 -0
- package/dist/worker/console/static-src/operator-chat/dag-progress-link.js +22 -0
- package/dist/worker/console/static-src/operator-chat/details-dag-actions.js +122 -0
- package/dist/worker/console/static-src/operator-chat/input-history.js +78 -0
- package/dist/worker/console/static-src/operator-chat/mutation-gate.js +1 -1
- package/dist/worker/console/static-src/operator-chat/open-preview-in-browser.js +338 -0
- package/dist/worker/console/static-src/operator-chat/refs.js +3 -0
- package/dist/worker/console/static-src/operator-chat/runtime-selection-labels.js +27 -0
- package/dist/worker/console/static-src/operator-chat/runtime-snapshot-store.js +10 -0
- package/dist/worker/console/static-src/operator-chat/spatial-overlay.js +1 -2
- package/dist/worker/console/static-src/operator-chat/turn-stream-controller.js +33 -1
- package/dist/worker/console/static-src/operator-chat/turn-submission.js +55 -0
- package/dist/worker/console/static-src/operator-chat/useChatSessions.js +448 -109
- package/dist/worker/console/static-src/operator-chat/useChatStream.js +344 -27
- package/dist/worker/console/static-src/operator-chat/useChatThread.js +323 -11
- package/dist/worker/console/static-src/operator-chat/useComposer.js +45 -4
- package/dist/worker/console/static-src/operator-chat/useRepoBrowser.js +97 -13
- package/dist/worker/console/static-src/operator-chat/useRuntimeControls.js +57 -9
- package/dist/worker/console/static-src/operator-chat/useRuntimeSnapshot.js +8 -2
- package/dist/worker/console/static-src/operator-chat/useWorkspaceBrowserGate.js +4 -0
- package/dist/worker/console/static-src/operator-chat/workspace-layout-mode.js +3 -3
- package/dist/worker/console/static-src/operator-chat/workspace-reorder.js +18 -0
- package/dist/worker/console/static-src/pages/tasks/run-id-resolution.js +79 -0
- package/dist/worker/console/static-src/pages/tasks/run-ownership-verify.js +23 -0
- package/dist/worker/console/static-src/pages/tasks/run-panel-progress.js +216 -0
- package/dist/worker/console/static-src/shell/console-update-reload.js +52 -0
- package/dist/worker/console/static-src/shell/useWorkspaces.js +415 -0
- package/dist/worker/console/static-src/shell/workspace-route.js +356 -0
- package/dist/worker/console/workspace-context.js +399 -0
- package/dist/worker/console/workspace-registry.js +487 -0
- package/dist/worker/continuation/worker-continuation.js +278 -0
- package/dist/worker/loop-agent/loop-agent-client.js +7 -3
- package/dist/worker/materialize/frontend-split-task-materializer.js +72 -0
- package/dist/worker/materialize/harness-task-lineage.js +5 -2
- package/dist/worker/observability/init-runtime-activity.js +26 -0
- package/dist/worker/observability/read-model.js +26 -0
- package/dist/worker/observe/health.js +1 -1
- package/dist/worker/observe/node-input.js +160 -3
- package/dist/worker/observe/node-process.js +377 -0
- package/dist/worker/observe/node-transparency.js +572 -0
- package/dist/worker/observe/routes.js +278 -3
- package/dist/worker/observe/server.js +4 -0
- package/dist/worker/observe/shell-handler-keys.js +34 -0
- package/dist/worker/observe/static/api.js +154 -4
- package/dist/worker/observe/static/app.js +18 -70
- package/dist/worker/observe/static/constants.js +26 -19
- package/dist/worker/observe/static/dag-context-reason-labels.d.ts +9 -0
- package/dist/worker/observe/static/dag-context-reason-labels.js +139 -0
- package/dist/worker/observe/static/dag-helpers.js +4 -2
- package/dist/worker/observe/static/dag-history-labels.js +5 -0
- package/dist/worker/observe/static/dag-inspector-humanize.d.ts +16 -0
- package/dist/worker/observe/static/dag-inspector-humanize.js +339 -0
- package/dist/worker/observe/static/dag-node-purpose.d.ts +6 -0
- package/dist/worker/observe/static/dag-node-purpose.js +208 -0
- package/dist/worker/observe/static/format.js +60 -0
- package/dist/worker/observe/static/index.html +10 -5
- package/dist/worker/observe/static/inspect-bootstrap.d.ts +8 -0
- package/dist/worker/observe/static/inspect-bootstrap.js +57 -0
- package/dist/worker/observe/static/inspect-workspace.js +374 -0
- package/dist/worker/observe/static/kpi.js +2 -2
- package/dist/worker/observe/static/markdown-render.js +20 -1
- package/dist/worker/observe/static/operator-chrome.css +168 -24
- package/dist/worker/observe/static/operator-chrome.d.ts +30 -5
- package/dist/worker/observe/static/operator-chrome.js +354 -101
- package/dist/worker/observe/static/prompt-restart-candidates.d.ts +18 -0
- package/dist/worker/observe/static/prompt-restart-candidates.js +38 -0
- package/dist/worker/observe/static/relations.js +7 -7
- package/dist/worker/observe/static/router.d.ts +57 -0
- package/dist/worker/observe/static/router.js +67 -1
- 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.d.ts +50 -0
- package/dist/worker/observe/static/state.js +191 -1
- package/dist/worker/observe/static/styles.css +1720 -86
- package/dist/worker/observe/static/views/dag-graph.js +5 -3
- package/dist/worker/observe/static/views/dag-inspector.js +2601 -188
- package/dist/worker/observe/static/views/dag.d.ts +13 -0
- package/dist/worker/observe/static/views/dag.js +39 -18
- package/dist/worker/observe/static/views/dags.js +10 -6
- package/dist/worker/observe/static/views/dashboard.js +18 -8
- package/dist/worker/observe/static/views/failures.js +5 -2
- package/dist/worker/observe/static/views/night.js +2 -2
- package/dist/worker/observe/static/views/pool.js +8 -2
- package/dist/worker/observe/static/views/run.js +15 -4
- package/dist/worker/observe/static/views/session-timeline.js +386 -25
- package/dist/worker/observe/static/views/task.js +63 -3
- 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 +470 -31
- package/dist/workflows/dag/backend-test-markdown-workflow.js +189 -2
- package/dist/workflows/dag/backend-test-plan-protocol.js +210 -0
- package/dist/workflows/dag/backend-test-pytest-collection.js +168 -16
- package/dist/workflows/dag/backend-test-result-contract.js +5 -1
- package/dist/workflows/dag/backend-test-scenario-param.js +506 -73
- package/dist/workflows/dag/backend-test-scenario-partitions.js +135 -2
- package/dist/workflows/dag/backend-test-writer-completeness.js +131 -28
- 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-output-registry.js +15 -0
- package/dist/workflows/dag/contract-validator-registrations.js +1 -2
- package/dist/workflows/dag/convergence/controller.js +141 -0
- package/dist/workflows/dag/dag-retry-schema.js +138 -0
- package/dist/workflows/dag/dynamic-runtime/loop-until.js +1 -1
- package/dist/workflows/dag/dynamic-runtime/map.js +17 -3
- package/dist/workflows/dag/failure-category.js +7 -116
- 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 +1377 -141
- package/dist/workflows/dag/frontend-plan-render.js +26 -1
- package/dist/workflows/dag/frontend-prewrite-gate.js +376 -318
- 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 +7 -424
- package/dist/workflows/dag/frontend-review-context.js +348 -20
- package/dist/workflows/dag/frontend-review-findings.js +270 -0
- package/dist/workflows/dag/frontend-risk.js +15 -2
- 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-test-case-checklist.js +32 -4
- package/dist/workflows/dag/frontend-test-case-generation-assessment.js +69 -0
- package/dist/workflows/dag/frontend-test-case-manifest.js +17 -5
- package/dist/workflows/dag/frontend-test-case-quality.js +11 -16
- package/dist/workflows/dag/frontend-test-environment-probe.js +230 -0
- package/dist/workflows/dag/frontend-test-html-report.js +3 -1
- package/dist/workflows/dag/frontend-test-l5-report.js +3 -1
- package/dist/workflows/dag/frontend-test-layout.js +159 -0
- package/dist/workflows/dag/frontend-test-markdown.js +61 -0
- package/dist/workflows/dag/frontend-test-result-contract.js +202 -42
- package/dist/workflows/dag/frontend-test-standard-scenarios.js +70 -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 +281 -29
- 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 +1771 -717
- package/dist/workflows/dag/interrupt-request.js +10 -3
- package/dist/workflows/dag/lifecycle.js +3 -3
- package/dist/workflows/dag/node-execution.js +1141 -32
- package/dist/workflows/dag/path-safety.js +1 -0
- package/dist/workflows/dag/prompt.js +158 -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 +526 -0
- package/dist/workflows/dag/rerun-plan.js +790 -28
- package/dist/workflows/dag/rerun-run.js +700 -21
- package/dist/workflows/dag/rerun-task.js +311 -14
- package/dist/workflows/dag/retry-policy.js +336 -101
- 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/structured-output-repair.js +712 -0
- package/dist/workflows/dag/types.js +600 -31
- package/dist/workflows/dag/validate.js +92 -32
- package/docs/README.md +2 -0
- package/docs/architecture/evolution.md +45 -0
- package/docs/architecture/runtime-boundaries.md +8 -7
- package/docs/architecture/worker-and-feature.md +1 -1
- package/docs/examples/README.md +5 -0
- package/docs/init-surface.manifest.json +36 -12
- package/docs/operations/README.md +1 -1
- package/docs/operations/local-development-environment.md +22 -5
- package/docs/skills/vetted-skill-registry.md +16 -0
- package/docs/templates/README.md +4 -2
- package/docs/templates/agent-dag-report.schema.json +8 -2
- package/docs/templates/agent-dag.schema.json +95 -1
- package/docs/templates/backend-test-dag.json +278 -244
- package/docs/templates/frontend-implementation-contract.schema.json +684 -24
- package/docs/templates/frontend-implementation-dag.json +89 -0
- package/docs/templates/frontend-test-case-checklist.md +2 -2
- package/docs/templates/frontend-test-dag.json +10 -12
- package/docs/templates/frontend-test-dag.retrieve-context.prompt.md +1 -1
- package/docs/templates/init-managed-agents.md +13 -3
- package/docs/templates/product-line/task.yaml +1 -1
- package/docs/templates/spec-registry.schema.json +45 -0
- package/harness.json +2 -2
- package/package.json +19 -5
- package/scripts/next-info.mjs +356 -0
- package/scripts/next-publish-gate.mjs +238 -0
- package/scripts/release-source-binding.mjs +251 -0
- package/skills/analyze-product-requirements/SKILL.md +8 -5
- package/skills/analyze-product-requirements/references/acceptance-criteria.md +1 -1
- package/skills/analyze-product-requirements/references/clarification-and-knowledge.md +10 -6
- package/skills/analyze-product-requirements/references/example.md +50 -0
- package/skills/analyze-product-requirements/references/forward-test-cases.md +11 -7
- package/skills/analyze-product-requirements/references/kb-integration.md +5 -5
- package/skills/analyze-product-requirements/references/product-analysis-schema.md +8 -4
- package/skills/analyze-product-requirements/references/product-requirement-schema.md +2 -2
- package/skills/analyze-product-requirements/references/requirement-clarification-schema.md +1 -1
- package/skills/analyze-product-requirements/scripts/test-validators.mjs +11 -1
- package/skills/analyze-product-requirements/scripts/validate-product-analysis.mjs +20 -1
- package/skills/analyze-product-requirements/scripts/validate-requirement-clarification.mjs +9 -0
- package/skills/codebase-scout/SKILL.md +1 -1
- package/skills/fe-test-ui-scout/SKILL.md +65 -0
- package/skills/fe-test-ui-scout/references/ledger-schema.md +62 -0
- package/skills/fe-test-ui-scout/references/recon-protocol.md +54 -0
- 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/improve-codebase-architecture/SKILL.md +81 -0
- package/skills/improve-codebase-architecture/deepening.md +37 -0
- package/skills/improve-codebase-architecture/html-report.md +123 -0
- package/skills/improve-codebase-architecture/interface-design.md +44 -0
- package/skills/improve-codebase-architecture/language.md +53 -0
- package/skills/loop-agent/references/command-reference.md +32 -4
- package/skills/loop-agent/references/hybrid-dag.md +9 -2
- package/skills/playwright-cli/SKILL.md +23 -1
- package/skills/playwright-cli-case-generator/SKILL.md +50 -13
- package/dist/worker/console/operation-store.js +0 -169
- package/dist/worker/console/static/assets/channel-Tl-FkUqr.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-BaehtRk4.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-BaehtRk4.js +0 -1
- package/dist/worker/console/static/assets/index-B7Y-0g3J.css +0 -1
- package/dist/worker/console/static/assets/index-DkCrqaYg.js +0 -325
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-eEhq2A8Y.js +0 -1
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-la8AC7fo.js +0 -8
- package/dist/worker/console/static-src/operator-chat/activity-rail-presentation.js +0 -73
- package/dist/worker/console/static-src/operator-chat/useActivityRailTransition.js +0 -59
- 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
|
@@ -5,25 +5,152 @@ import { runResilientGitCommand } from "../../shared/resilient-git.js";
|
|
|
5
5
|
import { writeDagRunJsonArtifact } from "../../infrastructure/harness/artifact-store.js";
|
|
6
6
|
import { pathMatchesPattern } from "../../shared/git-progress.js";
|
|
7
7
|
export const FRONTEND_WORKTREE_DIFF_SCHEMA_ID = "frontend-worktree-diff-v1";
|
|
8
|
+
export const FRONTEND_REVIEW_DIFF_INDEX_SCHEMA_ID = "frontend-review-diff-index-v1";
|
|
9
|
+
const MAX_REVIEW_DIFF_SUMMARY_ENTRIES = 48;
|
|
10
|
+
/** Maximum diff payload per review artifact; metadata adds a small fixed header. */
|
|
11
|
+
const MAX_REVIEW_DIFF_FRAGMENT_BYTES = 20 * 1024;
|
|
8
12
|
export const FRONTEND_WORKTREE_BASELINE_SCHEMA_ID = "frontend-worktree-baseline-v1";
|
|
9
13
|
async function runGit(cwd, args) {
|
|
10
14
|
const result = await runResilientGitCommand({ cwd, args, readOnly: true });
|
|
11
15
|
return { code: result.code, stdout: result.stdout, stderr: result.stderr };
|
|
12
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Ephemeral interpreter/tool caches that writers may create while drafting
|
|
19
|
+
* tests (kept in sync with `isEphemeralToolCachePath` in
|
|
20
|
+
* src/executors/shell-write-guard.ts). They are not product evidence: tool
|
|
21
|
+
* cache writes must neither fail the write guard nor appear in the review
|
|
22
|
+
* diff as pre-existing changes.
|
|
23
|
+
*/
|
|
24
|
+
export function isEphemeralToolCachePath(filePath) {
|
|
25
|
+
const normalized = filePath.replace(/\\/g, "/");
|
|
26
|
+
if (!normalized)
|
|
27
|
+
return false;
|
|
28
|
+
if (normalized === ".pytest_cache" ||
|
|
29
|
+
normalized.startsWith(".pytest_cache/")) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
if (normalized === ".mypy_cache" || normalized.startsWith(".mypy_cache/")) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
if (normalized === ".ruff_cache" || normalized.startsWith(".ruff_cache/")) {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
if (normalized === ".playwright-cli" ||
|
|
39
|
+
normalized.startsWith(".playwright-cli/")) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
if (normalized === ".coverage" || normalized.startsWith(".coverage.")) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
// vite/vitest runtime caches live under node_modules/.vite (e.g.
|
|
46
|
+
// node_modules/.vite/vitest/results.json). node_modules is the gitignored
|
|
47
|
+
// dependency tree — tool cache writes there are never a product change.
|
|
48
|
+
if (normalized.startsWith("node_modules/.vite/")) {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
if (/(?:^|\/)__pycache__(?:\/|$)/.test(normalized))
|
|
52
|
+
return true;
|
|
53
|
+
if (/\.(?:pyc|pyo)$/.test(normalized))
|
|
54
|
+
return true;
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
13
57
|
function splitLines(text) {
|
|
14
58
|
return text
|
|
15
59
|
.split(/\r?\n/)
|
|
16
60
|
.map((line) => line.trim())
|
|
17
61
|
.filter(Boolean);
|
|
18
62
|
}
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
63
|
+
function buildReviewDiffSummary(input) {
|
|
64
|
+
const files = [...input.hunks.reduce((grouped, hunk) => {
|
|
65
|
+
const existing = grouped.get(hunk.path);
|
|
66
|
+
if (existing) {
|
|
67
|
+
existing.bytes += hunk.bytes;
|
|
68
|
+
existing.lastPatchPath = hunk.patchPath;
|
|
69
|
+
return grouped;
|
|
70
|
+
}
|
|
71
|
+
grouped.set(hunk.path, {
|
|
72
|
+
path: hunk.path,
|
|
73
|
+
bytes: hunk.bytes,
|
|
74
|
+
parts: hunk.parts,
|
|
75
|
+
firstPatchPath: hunk.patchPath,
|
|
76
|
+
lastPatchPath: hunk.patchPath,
|
|
77
|
+
});
|
|
78
|
+
return grouped;
|
|
79
|
+
}, new Map()).values()];
|
|
80
|
+
const listedFiles = files.slice(0, MAX_REVIEW_DIFF_SUMMARY_ENTRIES);
|
|
81
|
+
const remainingFiles = files.length - listedFiles.length;
|
|
82
|
+
const listedUntracked = input.untrackedFiles.slice(0, MAX_REVIEW_DIFF_SUMMARY_ENTRIES);
|
|
83
|
+
const remainingUntracked = input.untrackedFiles.length - listedUntracked.length;
|
|
84
|
+
return [
|
|
85
|
+
"# Frontend review diff summary",
|
|
86
|
+
"",
|
|
87
|
+
"Read this bounded summary first. Do not read artifacts/diff_patch.patch in full; it is retained only as the canonical audit artifact.",
|
|
88
|
+
"For a semantic finding, read only the matching per-file diff fragment below and then the current source file when necessary. Read fragments in part order when a file has more than one.",
|
|
89
|
+
"",
|
|
90
|
+
`Canonical patch SHA-256: ${input.patchSha256}`,
|
|
91
|
+
`Canonical patch bytes: ${input.patchBytes}`,
|
|
92
|
+
`Tracked changed files: ${files.length}`,
|
|
93
|
+
`Review diff fragments: ${input.hunks.length}`,
|
|
94
|
+
`Untracked files (inventory only): ${input.untrackedFiles.length}`,
|
|
95
|
+
"",
|
|
96
|
+
"## Tracked file diff fragment references",
|
|
97
|
+
...(listedFiles.length > 0
|
|
98
|
+
? listedFiles.map((file) => file.parts === 1
|
|
99
|
+
? `- ${file.path} — ${file.bytes} bytes — read ${file.firstPatchPath} only if this file needs review`
|
|
100
|
+
: `- ${file.path} — ${file.bytes} bytes across ${file.parts} ordered fragments — read ${file.firstPatchPath} through ${file.lastPatchPath} only if this file needs review`)
|
|
101
|
+
: ["- (none)"]),
|
|
102
|
+
...(remainingFiles > 0
|
|
103
|
+
? [`- … ${remainingFiles} additional tracked files are recorded in contracts/frontend-review-diff-index.json; do not bulk-read them.`]
|
|
104
|
+
: []),
|
|
105
|
+
"",
|
|
106
|
+
"## Untracked inventory",
|
|
107
|
+
...(listedUntracked.length > 0
|
|
108
|
+
? listedUntracked.map((file) => `- ${file}`)
|
|
109
|
+
: ["- (none)"]),
|
|
110
|
+
...(remainingUntracked > 0
|
|
111
|
+
? [`- … ${remainingUntracked} additional untracked files are recorded in contracts/frontend-review-diff-index.json.`]
|
|
112
|
+
: []),
|
|
113
|
+
"",
|
|
114
|
+
].join("\n");
|
|
115
|
+
}
|
|
116
|
+
function splitReviewDiffFragments(text) {
|
|
117
|
+
const fragments = [];
|
|
118
|
+
let current = "";
|
|
119
|
+
for (const line of text.match(/[^\n]*\n|[^\n]+/g) ?? []) {
|
|
120
|
+
const lineBytes = Buffer.byteLength(line);
|
|
121
|
+
if (current.length > 0 &&
|
|
122
|
+
Buffer.byteLength(current) + lineBytes >
|
|
123
|
+
MAX_REVIEW_DIFF_FRAGMENT_BYTES) {
|
|
124
|
+
fragments.push(current);
|
|
125
|
+
current = "";
|
|
126
|
+
}
|
|
127
|
+
if (lineBytes <= MAX_REVIEW_DIFF_FRAGMENT_BYTES) {
|
|
128
|
+
current += line;
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
// Generated/minified files can produce a single diff line larger than the
|
|
132
|
+
// review budget. Split by Unicode code point so no fragment exceeds the
|
|
133
|
+
// byte limit while preserving the original patch bytes when concatenated.
|
|
134
|
+
let oversizedLineFragment = "";
|
|
135
|
+
let oversizedLineFragmentBytes = 0;
|
|
136
|
+
for (const codePoint of line) {
|
|
137
|
+
const codePointBytes = Buffer.byteLength(codePoint);
|
|
138
|
+
if (oversizedLineFragmentBytes > 0 &&
|
|
139
|
+
oversizedLineFragmentBytes + codePointBytes >
|
|
140
|
+
MAX_REVIEW_DIFF_FRAGMENT_BYTES) {
|
|
141
|
+
fragments.push(oversizedLineFragment);
|
|
142
|
+
oversizedLineFragment = "";
|
|
143
|
+
oversizedLineFragmentBytes = 0;
|
|
144
|
+
}
|
|
145
|
+
oversizedLineFragment += codePoint;
|
|
146
|
+
oversizedLineFragmentBytes += codePointBytes;
|
|
147
|
+
}
|
|
148
|
+
if (oversizedLineFragment)
|
|
149
|
+
fragments.push(oversizedLineFragment);
|
|
150
|
+
}
|
|
151
|
+
if (current.length > 0)
|
|
152
|
+
fragments.push(current);
|
|
153
|
+
return fragments.length > 0 ? fragments : [""];
|
|
27
154
|
}
|
|
28
155
|
async function sha256File(filePath) {
|
|
29
156
|
try {
|
|
@@ -37,15 +164,26 @@ async function sha256File(filePath) {
|
|
|
37
164
|
export async function captureFrontendWorktreeBaseline(input) {
|
|
38
165
|
const run = input.dependencies?.runGit ?? runGit;
|
|
39
166
|
const root = path.resolve(input.workspaceRoot);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
167
|
+
// Baseline = the full concrete workspace inventory the writer may touch
|
|
168
|
+
// (tracked + untracked, gitignored excluded), NOT just currently-changed
|
|
169
|
+
// files. Using `git status` here made a clean repository baseline-empty
|
|
170
|
+
// (status has no entries when nothing changed), which wrongly blocked
|
|
171
|
+
// writer admission with baseline-empty.
|
|
172
|
+
const ls = await run(root, [
|
|
173
|
+
"ls-files",
|
|
174
|
+
"-co",
|
|
175
|
+
"--exclude-standard",
|
|
176
|
+
"-z",
|
|
44
177
|
]);
|
|
45
|
-
if (
|
|
46
|
-
throw new Error(`frontend worktree baseline failed: ${
|
|
178
|
+
if (ls.code !== 0) {
|
|
179
|
+
throw new Error(`frontend worktree baseline failed: ${ls.stderr.trim() || ls.stdout.trim()}`);
|
|
47
180
|
}
|
|
48
|
-
const files =
|
|
181
|
+
const files = ls.stdout
|
|
182
|
+
.split("\0")
|
|
183
|
+
.map((line) => line.trim())
|
|
184
|
+
.filter(Boolean)
|
|
185
|
+
.filter((file) => !isEphemeralToolCachePath(file))
|
|
186
|
+
.sort();
|
|
49
187
|
const hashes = {};
|
|
50
188
|
for (const file of files)
|
|
51
189
|
hashes[file] = await sha256File(path.join(root, file));
|
|
@@ -112,8 +250,12 @@ export async function runFrontendWorktreeDiffGate(input) {
|
|
|
112
250
|
if (untracked.code !== 0) {
|
|
113
251
|
throw new Error(`frontend worktree diff gate ls-files failed: ${untracked.stderr.trim() || untracked.stdout.trim()}`);
|
|
114
252
|
}
|
|
115
|
-
const changedFilesAll = splitLines(nameOnly.stdout)
|
|
116
|
-
|
|
253
|
+
const changedFilesAll = splitLines(nameOnly.stdout)
|
|
254
|
+
.filter((file) => !isEphemeralToolCachePath(file))
|
|
255
|
+
.sort();
|
|
256
|
+
const untrackedFilesAll = splitLines(untracked.stdout)
|
|
257
|
+
.filter((file) => !isEphemeralToolCachePath(file))
|
|
258
|
+
.sort();
|
|
117
259
|
const authorizedChangedPaths = input.authorizedChangedPaths ?? [];
|
|
118
260
|
if (baseline) {
|
|
119
261
|
for (const file of baseline.files) {
|
|
@@ -160,11 +302,65 @@ export async function runFrontendWorktreeDiffGate(input) {
|
|
|
160
302
|
const absolutePatch = path.join(input.runDir, ...relativePatch.split("/"));
|
|
161
303
|
await mkdir(path.dirname(absolutePatch), { recursive: true });
|
|
162
304
|
await writeFile(absolutePatch, patchText, "utf8");
|
|
305
|
+
// Keep the complete patch as immutable audit evidence, but create a bounded
|
|
306
|
+
// reviewer entrypoint plus one file-scoped artifact per tracked change. This
|
|
307
|
+
// prevents final review from loading a multi-thousand-line patch into a
|
|
308
|
+
// single Pi session merely to inspect one or two relevant files.
|
|
309
|
+
const reviewHunks = [];
|
|
310
|
+
const reviewHunksDir = path.join(input.runDir, "artifacts", "diff-hunks");
|
|
311
|
+
await mkdir(reviewHunksDir, { recursive: true });
|
|
312
|
+
for (const [index, file] of changedFiles.entries()) {
|
|
313
|
+
const filePatch = await run(root, ["diff", "--binary", "HEAD", "--", file]);
|
|
314
|
+
if (filePatch.code !== 0) {
|
|
315
|
+
throw new Error(`frontend worktree diff hunk failed for ${file}: ${filePatch.stderr.trim() || filePatch.stdout.trim()}`);
|
|
316
|
+
}
|
|
317
|
+
const text = filePatch.stdout.endsWith("\n") || filePatch.stdout.length === 0
|
|
318
|
+
? filePatch.stdout
|
|
319
|
+
: `${filePatch.stdout}\n`;
|
|
320
|
+
const fragments = splitReviewDiffFragments(text);
|
|
321
|
+
for (const [partIndex, fragment] of fragments.entries()) {
|
|
322
|
+
const part = partIndex + 1;
|
|
323
|
+
const patchPath = `artifacts/diff-hunks/${String(index + 1).padStart(3, "0")}-${String(part).padStart(3, "0")}.patch`;
|
|
324
|
+
const artifact = [
|
|
325
|
+
"# Frontend review diff fragment",
|
|
326
|
+
`# path: ${file}`,
|
|
327
|
+
`# part: ${part}/${fragments.length}`,
|
|
328
|
+
"",
|
|
329
|
+
fragment,
|
|
330
|
+
].join("\n");
|
|
331
|
+
await writeFile(path.join(input.runDir, ...patchPath.split("/")), artifact, "utf8");
|
|
332
|
+
reviewHunks.push({
|
|
333
|
+
path: file,
|
|
334
|
+
patchPath,
|
|
335
|
+
sha256: createHash("sha256").update(artifact).digest("hex"),
|
|
336
|
+
bytes: Buffer.byteLength(artifact),
|
|
337
|
+
part,
|
|
338
|
+
parts: fragments.length,
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
const reviewIndexPath = "contracts/frontend-review-diff-index.json";
|
|
343
|
+
await writeDagRunJsonArtifact(input.runDir, reviewIndexPath, {
|
|
344
|
+
schemaVersion: 1,
|
|
345
|
+
schemaId: FRONTEND_REVIEW_DIFF_INDEX_SCHEMA_ID,
|
|
346
|
+
patchSha256,
|
|
347
|
+
hunks: reviewHunks,
|
|
348
|
+
untrackedFiles,
|
|
349
|
+
});
|
|
350
|
+
const reviewSummaryPath = "artifacts/diff_summary.md";
|
|
351
|
+
await writeFile(path.join(input.runDir, ...reviewSummaryPath.split("/")), buildReviewDiffSummary({
|
|
352
|
+
patchSha256,
|
|
353
|
+
patchBytes: Buffer.byteLength(patchText),
|
|
354
|
+
hunks: reviewHunks,
|
|
355
|
+
untrackedFiles,
|
|
356
|
+
}), "utf8");
|
|
163
357
|
const payload = {
|
|
164
358
|
schemaVersion: 1,
|
|
165
359
|
schemaId: FRONTEND_WORKTREE_DIFF_SCHEMA_ID,
|
|
166
360
|
patchPath: relativePatch,
|
|
167
361
|
patchSha256,
|
|
362
|
+
reviewSummaryPath,
|
|
363
|
+
reviewIndexPath,
|
|
168
364
|
changedFiles,
|
|
169
365
|
untrackedFiles,
|
|
170
366
|
empty: changedFiles.length === 0 && untrackedFiles.length === 0,
|
|
@@ -177,6 +373,8 @@ export async function runFrontendWorktreeDiffGate(input) {
|
|
|
177
373
|
patchPath: relativePatch,
|
|
178
374
|
patchAbsolutePath: absolutePatch,
|
|
179
375
|
patchSha256,
|
|
376
|
+
reviewSummaryPath,
|
|
377
|
+
reviewIndexPath,
|
|
180
378
|
changedFiles,
|
|
181
379
|
untrackedFiles,
|
|
182
380
|
empty: payload.empty,
|
|
@@ -189,6 +387,8 @@ export function formatFrontendWorktreeDiffStdout(result) {
|
|
|
189
387
|
`schemaId=${result.schemaId}`,
|
|
190
388
|
`patchPath=${result.patchPath}`,
|
|
191
389
|
`patchSha256=${result.patchSha256}`,
|
|
390
|
+
`reviewSummaryPath=${result.reviewSummaryPath}`,
|
|
391
|
+
`reviewIndexPath=${result.reviewIndexPath}`,
|
|
192
392
|
`changedFiles=${result.changedFiles.length}`,
|
|
193
393
|
`untrackedFiles=${result.untrackedFiles.length}`,
|
|
194
394
|
`empty=${result.empty ? "true" : "false"}`,
|
|
@@ -199,3 +399,36 @@ export function formatFrontendWorktreeDiffStdout(result) {
|
|
|
199
399
|
.filter(Boolean)
|
|
200
400
|
.join("\n");
|
|
201
401
|
}
|
|
402
|
+
/**
|
|
403
|
+
* Expand glob-shaped contract paths into concrete workspace file paths.
|
|
404
|
+
*
|
|
405
|
+
* The frontend contract schema allows `targets.files` entries such as
|
|
406
|
+
* `src/**` (skeleton inherits the task allowedPaths), but writer admission
|
|
407
|
+
* derives the concrete writeSet and requires real file paths. This helper
|
|
408
|
+
* matches every candidate against the enumerated workspace files and returns
|
|
409
|
+
* the concrete paths. Candidates that are already concrete are kept as-is;
|
|
410
|
+
* globs that match nothing are dropped (the derived writeSet only contains
|
|
411
|
+
* paths the writer can actually touch).
|
|
412
|
+
*/
|
|
413
|
+
export function expandFrontendGlobPaths(input) {
|
|
414
|
+
const concrete = new Set();
|
|
415
|
+
const patterns = [];
|
|
416
|
+
for (const candidate of input.candidates) {
|
|
417
|
+
const normalized = candidate.replace(/\\/g, "/");
|
|
418
|
+
if (normalized.includes("*")) {
|
|
419
|
+
patterns.push(normalized);
|
|
420
|
+
}
|
|
421
|
+
else {
|
|
422
|
+
concrete.add(normalized);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
if (patterns.length === 0)
|
|
426
|
+
return [...concrete].sort();
|
|
427
|
+
const workspace = [...new Set(input.workspaceFiles.map((f) => f.replace(/\\/g, "/")))];
|
|
428
|
+
for (const file of workspace) {
|
|
429
|
+
if (patterns.some((pattern) => pathMatchesPattern(file, pattern))) {
|
|
430
|
+
concrete.add(file);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
return [...concrete].sort();
|
|
434
|
+
}
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import { deterministicSha256, frontendImplementationContractSchema, } from "./frontend-implementation-contract.js";
|
|
2
|
+
import { expandFrontendGlobPaths } from "./frontend-worktree-diff.js";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
/** Runtime writer admission evidence. This is the sole production authorization type. */
|
|
5
|
+
export const frontendWriterAdmissionSchema = z
|
|
6
|
+
.object({
|
|
7
|
+
schemaVersion: z.literal(1),
|
|
8
|
+
writerNodeId: z.literal("frontend-implement-pi"),
|
|
9
|
+
decision: z.enum(["authorized", "denied"]),
|
|
10
|
+
sourceArtifact: z.string().min(1),
|
|
11
|
+
artifactHash: z.string().regex(/^[a-f0-9]{64}$/),
|
|
12
|
+
checkedAt: z.string().min(1),
|
|
13
|
+
reason: z.string().nullable(),
|
|
14
|
+
})
|
|
15
|
+
.strict();
|
|
16
|
+
/** A+B (AC-006): four-state writer admission classification. `accepted` is the
|
|
17
|
+
* only authorized state; `requires-human-approval` is the High-topology
|
|
18
|
+
* high-admission-receipt gate; `blocked` is deterministic denial; `stale` is
|
|
19
|
+
* digest drift (source refresh / re-contract). */
|
|
20
|
+
export const frontendWriterAdmissionClassificationSchema = z.enum([
|
|
21
|
+
"accepted",
|
|
22
|
+
"requires-human-approval",
|
|
23
|
+
"blocked",
|
|
24
|
+
"stale",
|
|
25
|
+
// Legacy artifacts remain parseable for diagnostics, but `admitted` is never
|
|
26
|
+
// accepted by the runtime authorization gate. Canonical producers always
|
|
27
|
+
// emit one of the four values above.
|
|
28
|
+
"admitted",
|
|
29
|
+
]);
|
|
30
|
+
/** A+B (AC-006): Micro topology uses `requirement-to-target-and-evidence`
|
|
31
|
+
* coverage; Small/Standard/High use `requirement-to-decision`. The two schemas
|
|
32
|
+
* are deliberately separated so a Micro evidence coverage can never be read as
|
|
33
|
+
* a decision coverage. */
|
|
34
|
+
export const frontendAdmissionCoverageSchema = z.discriminatedUnion("coverageId", [
|
|
35
|
+
z
|
|
36
|
+
.object({
|
|
37
|
+
coverageId: z.literal("requirement-to-target-and-evidence"),
|
|
38
|
+
requirementId: z.string().min(1),
|
|
39
|
+
targetPaths: z.array(z.string().min(1)),
|
|
40
|
+
evidenceRefs: z.array(z.string().min(1)),
|
|
41
|
+
})
|
|
42
|
+
.strict(),
|
|
43
|
+
z
|
|
44
|
+
.object({
|
|
45
|
+
coverageId: z.literal("requirement-to-decision"),
|
|
46
|
+
requirementId: z.string().min(1),
|
|
47
|
+
decisionRefs: z.array(z.string().min(1)),
|
|
48
|
+
})
|
|
49
|
+
.strict(),
|
|
50
|
+
]);
|
|
51
|
+
/** Failure-source values shared with frontend recovery planning (M8). */
|
|
52
|
+
export const frontendAdmissionFailureSourceSchema = z.enum([
|
|
53
|
+
"frontend-plan-pi",
|
|
54
|
+
"frontend-design-policy-shell",
|
|
55
|
+
"frontend-writer-admission-shell",
|
|
56
|
+
"frontend-implement-pi",
|
|
57
|
+
"frontend-verify-shell",
|
|
58
|
+
]);
|
|
59
|
+
/**
|
|
60
|
+
* Deterministic artifact schema for `contracts/frontend-writer-admission-result.json`.
|
|
61
|
+
* Scheduler admission gate and frontend recovery planning read this artifact
|
|
62
|
+
* (fail-closed); it replaces the legacy frontend-prewrite-result-v1 as the
|
|
63
|
+
* write authorization source.
|
|
64
|
+
*/
|
|
65
|
+
export const frontendWriterAdmissionResultV1Schema = z
|
|
66
|
+
.object({
|
|
67
|
+
schemaVersion: z.literal(1),
|
|
68
|
+
schemaId: z.literal("frontend-writer-admission-shell-v1"),
|
|
69
|
+
classification: frontendWriterAdmissionClassificationSchema,
|
|
70
|
+
writeSet: z.array(z.string().min(1)),
|
|
71
|
+
writeSetDigest: z.string().regex(/^[a-f0-9]{64}$/),
|
|
72
|
+
baselineDigest: z.string().regex(/^[a-f0-9]{64}$/),
|
|
73
|
+
admissionDigest: z.string().regex(/^[a-f0-9]{64}$/),
|
|
74
|
+
baselineDebtPolicy: z.string().min(1).optional(),
|
|
75
|
+
findings: z.array(z
|
|
76
|
+
.object({
|
|
77
|
+
code: z.string().min(1),
|
|
78
|
+
message: z.string().min(1),
|
|
79
|
+
path: z.string().optional(),
|
|
80
|
+
})
|
|
81
|
+
.strict()),
|
|
82
|
+
// Design findings are preserved as a bounded, structured capsule. A
|
|
83
|
+
// request_design_changes verdict is a blocking admission decision; the
|
|
84
|
+
// capsule is consumed by recovery and by any explicitly authorized retry.
|
|
85
|
+
designReviewAdvisory: z
|
|
86
|
+
.object({
|
|
87
|
+
verdict: z.enum(["approve_design", "request_design_changes"]),
|
|
88
|
+
restartPhase: z.string().min(1).optional(),
|
|
89
|
+
findingCount: z.number().int().nonnegative(),
|
|
90
|
+
findings: z.array(z.object({
|
|
91
|
+
severity: z.enum(["Critical", "Important", "Minor", "Info"]),
|
|
92
|
+
file: z.string().min(1).optional(),
|
|
93
|
+
line: z.number().int().positive().optional(),
|
|
94
|
+
issue: z.string().min(1),
|
|
95
|
+
requiredChange: z.string().min(1).optional(),
|
|
96
|
+
}).strict()),
|
|
97
|
+
evidenceRefs: z.array(z.string().min(1)),
|
|
98
|
+
})
|
|
99
|
+
.strict()
|
|
100
|
+
.optional(),
|
|
101
|
+
failureSource: frontendAdmissionFailureSourceSchema.optional(),
|
|
102
|
+
})
|
|
103
|
+
.strict();
|
|
104
|
+
/** Artifact relative path written by the frontend-writer-admission-shell. */
|
|
105
|
+
export const FRONTEND_WRITER_ADMISSION_RESULT_ARTIFACT = "contracts/frontend-writer-admission-result.json";
|
|
106
|
+
function sortFindings(findings) {
|
|
107
|
+
return [...findings].sort((a, b) => {
|
|
108
|
+
if (a.code !== b.code)
|
|
109
|
+
return a.code < b.code ? -1 : 1;
|
|
110
|
+
if (a.message !== b.message)
|
|
111
|
+
return a.message < b.message ? -1 : 1;
|
|
112
|
+
const pathA = a.path ?? "";
|
|
113
|
+
const pathB = b.path ?? "";
|
|
114
|
+
if (pathA !== pathB)
|
|
115
|
+
return pathA < pathB ? -1 : 1;
|
|
116
|
+
return 0;
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
/** Reject non-concrete writeSet entries: absolute paths, traversal, globstar,
|
|
120
|
+
* repo-root, and empty/duplicate-slash segments. */
|
|
121
|
+
export function isConcreteWriteSetPath(value) {
|
|
122
|
+
const path = value.trim();
|
|
123
|
+
if (path === "" || path === "." || path === "./")
|
|
124
|
+
return false;
|
|
125
|
+
if (path.startsWith("/") || path.includes("\\") || path.includes("*") || path.includes("?"))
|
|
126
|
+
return false;
|
|
127
|
+
const segments = path.split("/");
|
|
128
|
+
if (segments.some((segment) => segment === ".." || segment === "**" || segment === "")) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
export function normalizeConcreteWriteSetPath(value) {
|
|
134
|
+
const normalized = value.trim();
|
|
135
|
+
return isConcreteWriteSetPath(normalized) ? normalized : undefined;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Deterministically extract repository file paths that frozen verification
|
|
139
|
+
* commands operate on (`--config <file>`, `node --check <file>`). The plan's
|
|
140
|
+
* verification targets do not always name verification infrastructure (a
|
|
141
|
+
* vitest config, fixtures), yet verify-shell cannot run without it and the
|
|
142
|
+
* writer cannot create it unless the effective writeSet authorizes the file.
|
|
143
|
+
*/
|
|
144
|
+
export function collectVerificationCommandFiles(commands) {
|
|
145
|
+
const files = new Set();
|
|
146
|
+
const configRe = /--config\s+([\w@./-]+\.(?:js|mjs|cjs|ts|json))/g;
|
|
147
|
+
const checkRe = /node\s+--check\s+([\w@./-]+\.(?:js|mjs|cjs))/g;
|
|
148
|
+
for (const command of commands) {
|
|
149
|
+
for (const re of [configRe, checkRe]) {
|
|
150
|
+
for (const match of command.matchAll(re)) {
|
|
151
|
+
const file = match[1];
|
|
152
|
+
if (file && file.includes("/"))
|
|
153
|
+
files.add(file);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return [...files].sort();
|
|
158
|
+
}
|
|
159
|
+
/** Derive the concrete writeSet from implementation targets ∪ behavior
|
|
160
|
+
* verification target files. Entries are de-duplicated and lexicographically
|
|
161
|
+
* sorted (frozen). */
|
|
162
|
+
export function deriveWriteSet(contract, options) {
|
|
163
|
+
const findings = [];
|
|
164
|
+
const candidates = [
|
|
165
|
+
...contract.targets.files,
|
|
166
|
+
...contract.verificationTargets
|
|
167
|
+
.filter((target) => target.mode !== "static")
|
|
168
|
+
.map((target) => target.file),
|
|
169
|
+
];
|
|
170
|
+
// Expand glob entries (e.g. `src/**` inherited from the skeleton) against
|
|
171
|
+
// the enumerated workspace files so the derived writeSet contains only
|
|
172
|
+
// concrete paths. Without a file list, globs are treated as concrete and
|
|
173
|
+
// rejected by isConcreteWriteSetPath below (fail-closed).
|
|
174
|
+
const expanded = options?.workspaceFiles
|
|
175
|
+
? expandFrontendGlobPaths({
|
|
176
|
+
candidates,
|
|
177
|
+
workspaceFiles: options.workspaceFiles,
|
|
178
|
+
})
|
|
179
|
+
: candidates;
|
|
180
|
+
const writeSet = new Set();
|
|
181
|
+
for (const candidate of expanded) {
|
|
182
|
+
const normalized = normalizeConcreteWriteSetPath(candidate);
|
|
183
|
+
if (!normalized) {
|
|
184
|
+
findings.push({
|
|
185
|
+
code: "write-set-path-not-concrete",
|
|
186
|
+
message: `writeSet entry is not a concrete path: ${candidate}`,
|
|
187
|
+
path: candidate,
|
|
188
|
+
});
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
writeSet.add(normalized);
|
|
192
|
+
}
|
|
193
|
+
return { writeSet: [...writeSet].sort(), findings };
|
|
194
|
+
}
|
|
195
|
+
/** Sort and freeze the injected baseline; duplicate paths and empty baselines
|
|
196
|
+
* are blocking (collection itself is production wiring, not this shell). */
|
|
197
|
+
export function freezeBaseline(baseline) {
|
|
198
|
+
const findings = [];
|
|
199
|
+
if (baseline.length === 0) {
|
|
200
|
+
findings.push({
|
|
201
|
+
code: "baseline-empty",
|
|
202
|
+
message: "writer admission baseline is empty",
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
const seen = new Set();
|
|
206
|
+
for (const entry of baseline) {
|
|
207
|
+
if (seen.has(entry.path)) {
|
|
208
|
+
findings.push({
|
|
209
|
+
code: "baseline-duplicate-path",
|
|
210
|
+
message: `baseline contains duplicate path: ${entry.path}`,
|
|
211
|
+
path: entry.path,
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
seen.add(entry.path);
|
|
215
|
+
}
|
|
216
|
+
const sorted = [...baseline].sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
|
|
217
|
+
return { baselineDigest: deterministicSha256(sorted), findings };
|
|
218
|
+
}
|
|
219
|
+
/** Combine mock strategy, allowed strategies digest, frozen command digest,
|
|
220
|
+
* production-default-off flag and real-integration expectation into one
|
|
221
|
+
* deterministic admission digest. */
|
|
222
|
+
export function deriveAdmissionDigest(contract, allowedMockStrategies, frozenCommandLabels, baselineDebtPolicy) {
|
|
223
|
+
return deterministicSha256({
|
|
224
|
+
mockApiStrategy: contract.mockApi.strategy,
|
|
225
|
+
allowedMockStrategiesDigest: deterministicSha256([...allowedMockStrategies].sort()),
|
|
226
|
+
frozenCommandLabelsDigest: deterministicSha256([...frozenCommandLabels].sort()),
|
|
227
|
+
productionDefaultOff: contract.mockApi.productionDefaultOff === true,
|
|
228
|
+
hasRealIntegrationGap: Boolean(contract.realIntegrationGap),
|
|
229
|
+
baselineDebtPolicy: baselineDebtPolicy ?? "",
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
/** Shape-aware deterministic admission: re-validate the typed contract, honor
|
|
233
|
+
* the design-policy result, derive/freeze the writeSet, digest the baseline,
|
|
234
|
+
* and assemble the admission digest. */
|
|
235
|
+
export function deriveFrontendWriterAdmissionShell(input) {
|
|
236
|
+
const findings = [];
|
|
237
|
+
const shape = frontendImplementationContractSchema.safeParse(input.contract);
|
|
238
|
+
if (!shape.success) {
|
|
239
|
+
findings.push({
|
|
240
|
+
code: "contract-shape-invalid",
|
|
241
|
+
message: `contract fails strict shape validation: ${shape.error.issues[0]?.message ?? "unknown issue"}`,
|
|
242
|
+
path: shape.error.issues[0]?.path.join(".") || undefined,
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
if (input.designPolicyResult.classification === "blocked") {
|
|
246
|
+
findings.push({
|
|
247
|
+
code: "design-policy-blocked",
|
|
248
|
+
message: `design policy is blocked with ${input.designPolicyResult.findings.length} finding(s)`,
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
const derived = deriveWriteSet(input.contract, {
|
|
252
|
+
workspaceFiles: input.workspaceFiles,
|
|
253
|
+
});
|
|
254
|
+
findings.push(...derived.findings);
|
|
255
|
+
const baseline = freezeBaseline(input.baseline);
|
|
256
|
+
findings.push(...baseline.findings);
|
|
257
|
+
const sortedFindings = sortFindings(findings);
|
|
258
|
+
// Deterministic admission: any finding blocks. High-risk contracts keep the
|
|
259
|
+
// full policy/writeSet/baseline gates but do NOT stop for a human approval
|
|
260
|
+
// step — the DAG runs unattended, so `requires-human-approval` would strand
|
|
261
|
+
// every high-risk writer. The receipt is still materialized for audit; the
|
|
262
|
+
// scheduler authorizes `accepted` directly.
|
|
263
|
+
const classification = sortedFindings.length > 0 ? "blocked" : "accepted";
|
|
264
|
+
const result = {
|
|
265
|
+
schemaId: "frontend-writer-admission-shell-v1",
|
|
266
|
+
classification,
|
|
267
|
+
writeSet: derived.writeSet,
|
|
268
|
+
writeSetDigest: deterministicSha256(derived.writeSet),
|
|
269
|
+
baselineDigest: baseline.baselineDigest,
|
|
270
|
+
admissionDigest: deriveAdmissionDigest(input.contract, input.allowedMockStrategies, input.frozenCommandLabels, input.baselineDebtPolicy),
|
|
271
|
+
...(input.baselineDebtPolicy !== undefined
|
|
272
|
+
? { baselineDebtPolicy: input.baselineDebtPolicy }
|
|
273
|
+
: {}),
|
|
274
|
+
findings: sortedFindings,
|
|
275
|
+
};
|
|
276
|
+
return result;
|
|
277
|
+
}
|
|
278
|
+
function normalizeNewVerdict(classification) {
|
|
279
|
+
return classification === "accepted" ||
|
|
280
|
+
classification === "requires-human-approval" ||
|
|
281
|
+
classification === "admitted"
|
|
282
|
+
? "accepted"
|
|
283
|
+
: "blocked";
|
|
284
|
+
}
|
|
285
|
+
function normalizeLegacyVerdict(classification) {
|
|
286
|
+
return classification === "accepted" || classification === "accepted-normalized"
|
|
287
|
+
? "accepted"
|
|
288
|
+
: "blocked";
|
|
289
|
+
}
|
|
290
|
+
export function compareAdmissionToLegacyGate(input) {
|
|
291
|
+
const newVerdict = normalizeNewVerdict(input.newClassification);
|
|
292
|
+
const legacyVerdict = normalizeLegacyVerdict(input.legacyClassification);
|
|
293
|
+
return {
|
|
294
|
+
newClassification: input.newClassification,
|
|
295
|
+
legacyClassification: input.legacyClassification,
|
|
296
|
+
newVerdict,
|
|
297
|
+
legacyVerdict,
|
|
298
|
+
match: newVerdict === legacyVerdict,
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
/** Render a stable, deterministically ordered mismatch list for the evaluation
|
|
302
|
+
* set. Input order is irrelevant: rows are sorted by a canonical key. */
|
|
303
|
+
export function renderAdmissionShadowDiff(results) {
|
|
304
|
+
const indexed = results.map((result, index) => ({ ...result, index }));
|
|
305
|
+
const sorted = indexed.sort((a, b) => {
|
|
306
|
+
const keyA = `${a.legacyClassification}|${a.newClassification}`;
|
|
307
|
+
const keyB = `${b.legacyClassification}|${b.newClassification}`;
|
|
308
|
+
if (keyA !== keyB)
|
|
309
|
+
return keyA < keyB ? -1 : 1;
|
|
310
|
+
return a.index - b.index;
|
|
311
|
+
});
|
|
312
|
+
const mismatches = sorted.filter((row) => !row.match);
|
|
313
|
+
const lines = [
|
|
314
|
+
"## Admission Shadow Diff",
|
|
315
|
+
`${sorted.length} comparisons, ${mismatches.length} mismatches`,
|
|
316
|
+
...sorted.map((row) => `- ${row.legacyClassification} -> ${row.newClassification}: legacy=${row.legacyVerdict} new=${row.newVerdict}${row.match ? " match" : " MISMATCH"}`),
|
|
317
|
+
];
|
|
318
|
+
return lines.join("\n");
|
|
319
|
+
}
|
|
@@ -370,6 +370,38 @@ async function inspectPath(repoRoot, relPath, deps) {
|
|
|
370
370
|
throw error;
|
|
371
371
|
}
|
|
372
372
|
}
|
|
373
|
+
/**
|
|
374
|
+
* Build the CAS attempt side of a rollback journal from the current worktree.
|
|
375
|
+
* This is used by high-risk artifact continuations, where the baseline is
|
|
376
|
+
* captured before the child starts and the complete attempt inventory is
|
|
377
|
+
* derived after the child settles (including changes from dynamic writers).
|
|
378
|
+
*/
|
|
379
|
+
export async function recordWriterAttemptFromCurrent(snapshot, options) {
|
|
380
|
+
const deps = resolveDeps(options.dependencies);
|
|
381
|
+
const working = structuredClone(snapshot);
|
|
382
|
+
const baselineByPath = new Map(working.existingFiles.map((file) => [file.path, file]));
|
|
383
|
+
const currentMatches = [];
|
|
384
|
+
await walkMatchingEntries(options.repoRoot, "", working.writeSet, deps, (match) => currentMatches.push(match));
|
|
385
|
+
const candidatePaths = new Set([
|
|
386
|
+
...baselineByPath.keys(),
|
|
387
|
+
...currentMatches.map((match) => match.relPath),
|
|
388
|
+
]);
|
|
389
|
+
const attemptChangedPaths = [];
|
|
390
|
+
const attemptFileHashes = {};
|
|
391
|
+
for (const relPath of [...candidatePaths].sort((left, right) => left.localeCompare(right))) {
|
|
392
|
+
const baseline = baselineByPath.get(relPath);
|
|
393
|
+
const current = await inspectPath(options.repoRoot, relPath, deps);
|
|
394
|
+
const currentHash = current.kind === "absent" ? "absent" : current.hash;
|
|
395
|
+
const baselineHash = baseline?.baselineSha256 ?? "absent";
|
|
396
|
+
if (currentHash === baselineHash)
|
|
397
|
+
continue;
|
|
398
|
+
attemptChangedPaths.push(relPath);
|
|
399
|
+
attemptFileHashes[relPath] = currentHash;
|
|
400
|
+
}
|
|
401
|
+
working.attemptChangedPaths = attemptChangedPaths;
|
|
402
|
+
working.attemptFileHashes = attemptFileHashes;
|
|
403
|
+
return frontendWriterRollbackV1Schema.parse(working);
|
|
404
|
+
}
|
|
373
405
|
function ensureJournalFile(working, relPath, baselineSha256, attemptSha256) {
|
|
374
406
|
let file = working.journal.files[relPath];
|
|
375
407
|
if (!file) {
|