wicked-crew 0.18.19 → 0.18.21
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/README.md +9 -6
- package/dist/api/ask-paths.d.ts +2 -0
- package/dist/api/ask-paths.d.ts.map +1 -1
- package/dist/api/ask-paths.js +6 -0
- package/dist/api/ask-paths.js.map +1 -1
- package/dist/api/auth.d.ts +7 -5
- package/dist/api/auth.d.ts.map +1 -1
- package/dist/api/auth.js +23 -9
- package/dist/api/auth.js.map +1 -1
- package/dist/api/capture.d.ts +5 -2
- package/dist/api/capture.d.ts.map +1 -1
- package/dist/api/capture.js +13 -10
- package/dist/api/capture.js.map +1 -1
- package/dist/api/chat-attachments.d.ts.map +1 -1
- package/dist/api/chat-attachments.js +69 -19
- package/dist/api/chat-attachments.js.map +1 -1
- package/dist/api/chat-citations.d.ts.map +1 -1
- package/dist/api/chat-citations.js +22 -0
- package/dist/api/chat-citations.js.map +1 -1
- package/dist/api/chat-context.d.ts +16 -1
- package/dist/api/chat-context.d.ts.map +1 -1
- package/dist/api/chat-context.js +75 -14
- package/dist/api/chat-context.js.map +1 -1
- package/dist/api/chat-freshness.js +2 -2
- package/dist/api/chat-freshness.js.map +1 -1
- package/dist/api/chat-history.d.ts +13 -0
- package/dist/api/chat-history.d.ts.map +1 -1
- package/dist/api/chat-history.js +25 -0
- package/dist/api/chat-history.js.map +1 -1
- package/dist/api/chat-jobs.d.ts +67 -6
- package/dist/api/chat-jobs.d.ts.map +1 -1
- package/dist/api/chat-jobs.js +243 -22
- package/dist/api/chat-jobs.js.map +1 -1
- package/dist/api/chat-proposals.d.ts +69 -6
- package/dist/api/chat-proposals.d.ts.map +1 -1
- package/dist/api/chat-proposals.js +310 -49
- package/dist/api/chat-proposals.js.map +1 -1
- package/dist/api/chat-requirements.d.ts.map +1 -1
- package/dist/api/chat-requirements.js +4 -1
- package/dist/api/chat-requirements.js.map +1 -1
- package/dist/api/chat-scope.d.ts +17 -9
- package/dist/api/chat-scope.d.ts.map +1 -1
- package/dist/api/chat-scope.js +55 -21
- package/dist/api/chat-scope.js.map +1 -1
- package/dist/api/cluster-status.d.ts +24 -12
- package/dist/api/cluster-status.d.ts.map +1 -1
- package/dist/api/cluster-status.js +82 -4
- package/dist/api/cluster-status.js.map +1 -1
- package/dist/api/codebase-archive.d.ts +4 -3
- package/dist/api/codebase-archive.d.ts.map +1 -1
- package/dist/api/codebase-archive.js +6 -5
- package/dist/api/codebase-archive.js.map +1 -1
- package/dist/api/delivery-cache.d.ts +2 -0
- package/dist/api/delivery-cache.d.ts.map +1 -1
- package/dist/api/delivery-cache.js +1 -2
- package/dist/api/delivery-cache.js.map +1 -1
- package/dist/api/delivery-index.d.ts +2 -2
- package/dist/api/delivery-index.d.ts.map +1 -1
- package/dist/api/delivery-index.js +1 -2
- package/dist/api/delivery-index.js.map +1 -1
- package/dist/api/eval-compare.d.ts +1 -1
- package/dist/api/eval-compare.js +1 -1
- package/dist/api/eval-sample.d.ts +7 -0
- package/dist/api/eval-sample.d.ts.map +1 -1
- package/dist/api/eval-sample.js +20 -0
- package/dist/api/eval-sample.js.map +1 -1
- package/dist/api/gate-cache.d.ts +1 -0
- package/dist/api/gate-cache.d.ts.map +1 -1
- package/dist/api/gate-cache.js +19 -6
- package/dist/api/gate-cache.js.map +1 -1
- package/dist/api/governance-steering.d.ts +17 -4
- package/dist/api/governance-steering.d.ts.map +1 -1
- package/dist/api/governance-steering.js +56 -7
- package/dist/api/governance-steering.js.map +1 -1
- package/dist/api/mcp.d.ts +12 -2
- package/dist/api/mcp.d.ts.map +1 -1
- package/dist/api/mcp.js +56 -12
- package/dist/api/mcp.js.map +1 -1
- package/dist/api/needs.d.ts +20 -0
- package/dist/api/needs.d.ts.map +1 -1
- package/dist/api/needs.js +120 -19
- package/dist/api/needs.js.map +1 -1
- package/dist/api/onboarding-capture.d.ts +21 -1
- package/dist/api/onboarding-capture.d.ts.map +1 -1
- package/dist/api/onboarding-capture.js +112 -8
- package/dist/api/onboarding-capture.js.map +1 -1
- package/dist/api/policy-landing.d.ts +36 -0
- package/dist/api/policy-landing.d.ts.map +1 -1
- package/dist/api/policy-landing.js +123 -4
- package/dist/api/policy-landing.js.map +1 -1
- package/dist/api/post-hoc-deliver.d.ts.map +1 -1
- package/dist/api/post-hoc-deliver.js +2 -1
- package/dist/api/post-hoc-deliver.js.map +1 -1
- package/dist/api/product.d.ts +1 -1
- package/dist/api/proposal-decisions.d.ts +44 -0
- package/dist/api/proposal-decisions.d.ts.map +1 -0
- package/dist/api/proposal-decisions.js +85 -0
- package/dist/api/proposal-decisions.js.map +1 -0
- package/dist/api/proposal-onboard.d.ts +38 -1
- package/dist/api/proposal-onboard.d.ts.map +1 -1
- package/dist/api/proposal-onboard.js +203 -14
- package/dist/api/proposal-onboard.js.map +1 -1
- package/dist/api/recording.d.ts +1 -1
- package/dist/api/recording.d.ts.map +1 -1
- package/dist/api/recording.js +4 -5
- package/dist/api/recording.js.map +1 -1
- package/dist/api/redeliver.d.ts.map +1 -1
- package/dist/api/redeliver.js +11 -7
- package/dist/api/redeliver.js.map +1 -1
- package/dist/api/repo-input.d.ts.map +1 -1
- package/dist/api/repo-input.js +5 -2
- package/dist/api/repo-input.js.map +1 -1
- package/dist/api/repo-origins.d.ts +24 -0
- package/dist/api/repo-origins.d.ts.map +1 -0
- package/dist/api/repo-origins.js +71 -0
- package/dist/api/repo-origins.js.map +1 -0
- package/dist/api/requirements.d.ts +37 -16
- package/dist/api/requirements.d.ts.map +1 -1
- package/dist/api/requirements.js +73 -2
- package/dist/api/requirements.js.map +1 -1
- package/dist/api/retry-index.d.ts +2 -0
- package/dist/api/retry-index.d.ts.map +1 -1
- package/dist/api/retry-index.js +16 -8
- package/dist/api/retry-index.js.map +1 -1
- package/dist/api/review-change.d.ts +5 -6
- package/dist/api/review-change.d.ts.map +1 -1
- package/dist/api/review-change.js +45 -8
- package/dist/api/review-change.js.map +1 -1
- package/dist/api/roster-standing.d.ts +2 -0
- package/dist/api/roster-standing.d.ts.map +1 -1
- package/dist/api/roster-standing.js +8 -1
- package/dist/api/roster-standing.js.map +1 -1
- package/dist/api/routes.d.ts +55 -12
- package/dist/api/routes.d.ts.map +1 -1
- package/dist/api/routes.js +961 -277
- package/dist/api/routes.js.map +1 -1
- package/dist/api/run-documents.d.ts +9 -1
- package/dist/api/run-documents.d.ts.map +1 -1
- package/dist/api/run-documents.js +63 -5
- package/dist/api/run-documents.js.map +1 -1
- package/dist/api/run-sources.d.ts +11 -1
- package/dist/api/run-sources.d.ts.map +1 -1
- package/dist/api/run-sources.js +26 -3
- package/dist/api/run-sources.js.map +1 -1
- package/dist/api/run-timing-index.d.ts +47 -0
- package/dist/api/run-timing-index.d.ts.map +1 -1
- package/dist/api/run-timing-index.js +196 -86
- package/dist/api/run-timing-index.js.map +1 -1
- package/dist/api/runtime-state.d.ts +6 -0
- package/dist/api/runtime-state.d.ts.map +1 -1
- package/dist/api/runtime-state.js +14 -3
- package/dist/api/runtime-state.js.map +1 -1
- package/dist/api/seat-agents.d.ts.map +1 -1
- package/dist/api/seat-agents.js +3 -3
- package/dist/api/seat-agents.js.map +1 -1
- package/dist/api/seat-container-login.d.ts +6 -2
- package/dist/api/seat-container-login.d.ts.map +1 -1
- package/dist/api/seat-container-login.js +17 -9
- package/dist/api/seat-container-login.js.map +1 -1
- package/dist/api/seat-governance.d.ts +3 -2
- package/dist/api/seat-governance.d.ts.map +1 -1
- package/dist/api/seat-governance.js +31 -9
- package/dist/api/seat-governance.js.map +1 -1
- package/dist/api/seat-standing.d.ts +8 -0
- package/dist/api/seat-standing.d.ts.map +1 -1
- package/dist/api/seat-standing.js +26 -1
- package/dist/api/seat-standing.js.map +1 -1
- package/dist/api/server.d.ts +7 -0
- package/dist/api/server.d.ts.map +1 -1
- package/dist/api/server.js +172 -59
- package/dist/api/server.js.map +1 -1
- package/dist/api/stall-watchdog.d.ts +6 -0
- package/dist/api/stall-watchdog.d.ts.map +1 -1
- package/dist/api/stall-watchdog.js +28 -0
- package/dist/api/stall-watchdog.js.map +1 -1
- package/dist/api/start-on-login.d.ts +4 -0
- package/dist/api/start-on-login.d.ts.map +1 -0
- package/dist/api/start-on-login.js +35 -0
- package/dist/api/start-on-login.js.map +1 -0
- package/dist/api/steering-landing.d.ts +33 -8
- package/dist/api/steering-landing.d.ts.map +1 -1
- package/dist/api/steering-landing.js +235 -51
- package/dist/api/steering-landing.js.map +1 -1
- package/dist/api/system-snapshot.d.ts +5 -0
- package/dist/api/system-snapshot.d.ts.map +1 -1
- package/dist/api/system-snapshot.js +22 -10
- package/dist/api/system-snapshot.js.map +1 -1
- package/dist/api/testing.d.ts +2 -2
- package/dist/api/ui-text.js +2 -2
- package/dist/api/ui-text.js.map +1 -1
- package/dist/api/worktree-sweep.d.ts +7 -3
- package/dist/api/worktree-sweep.d.ts.map +1 -1
- package/dist/api/worktree-sweep.js +10 -6
- package/dist/api/worktree-sweep.js.map +1 -1
- package/dist/apps/actions/api-action.js +5 -2
- package/dist/apps/actions/api-action.js.map +1 -1
- package/dist/apps/actions/write-path.d.ts +9 -0
- package/dist/apps/actions/write-path.d.ts.map +1 -1
- package/dist/apps/actions/write-path.js +17 -9
- package/dist/apps/actions/write-path.js.map +1 -1
- package/dist/apps/exec/executor.d.ts +8 -15
- package/dist/apps/exec/executor.d.ts.map +1 -1
- package/dist/apps/exec/executor.js +10 -3
- package/dist/apps/exec/executor.js.map +1 -1
- package/dist/apps/exec/recall.d.ts.map +1 -1
- package/dist/apps/exec/recall.js +4 -4
- package/dist/apps/exec/recall.js.map +1 -1
- package/dist/apps/exec/redescribe.d.ts +37 -0
- package/dist/apps/exec/redescribe.d.ts.map +1 -0
- package/dist/apps/exec/redescribe.js +86 -0
- package/dist/apps/exec/redescribe.js.map +1 -0
- package/dist/apps/exec/source-stage.d.ts +3 -1
- package/dist/apps/exec/source-stage.d.ts.map +1 -1
- package/dist/apps/exec/source-stage.js +13 -3
- package/dist/apps/exec/source-stage.js.map +1 -1
- package/dist/apps/exec/sources.d.ts +6 -0
- package/dist/apps/exec/sources.d.ts.map +1 -1
- package/dist/apps/exec/sources.js +8 -0
- package/dist/apps/exec/sources.js.map +1 -1
- package/dist/apps/git.js +2 -2
- package/dist/apps/git.js.map +1 -1
- package/dist/apps/publish/manifest.d.ts +8 -1
- package/dist/apps/publish/manifest.d.ts.map +1 -1
- package/dist/apps/publish/manifest.js +14 -3
- package/dist/apps/publish/manifest.js.map +1 -1
- package/dist/apps/publish/run.d.ts +15 -2
- package/dist/apps/publish/run.d.ts.map +1 -1
- package/dist/apps/publish/run.js +100 -17
- package/dist/apps/publish/run.js.map +1 -1
- package/dist/apps/routes.d.ts +3 -0
- package/dist/apps/routes.d.ts.map +1 -1
- package/dist/apps/routes.js +58 -2
- package/dist/apps/routes.js.map +1 -1
- package/dist/apps/store.d.ts +24 -3
- package/dist/apps/store.d.ts.map +1 -1
- package/dist/apps/store.js +26 -9
- package/dist/apps/store.js.map +1 -1
- package/dist/apps/turns.d.ts +25 -2
- package/dist/apps/turns.d.ts.map +1 -1
- package/dist/apps/turns.js +276 -11
- package/dist/apps/turns.js.map +1 -1
- package/dist/apps-server/Dockerfile +2 -2
- package/dist/apps-server/runners/sqlite-runner.mjs +67 -12
- package/dist/apps-server/server/lib/bundle/server.mjs +353 -159
- package/dist/cli/governance.d.ts +5 -2
- package/dist/cli/governance.d.ts.map +1 -1
- package/dist/cli/governance.js +8 -5
- package/dist/cli/governance.js.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +6 -5
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/service.d.ts +10 -6
- package/dist/cli/service.d.ts.map +1 -1
- package/dist/cli/service.js +39 -23
- package/dist/cli/service.js.map +1 -1
- package/dist/core/adapter.d.ts +61 -29
- package/dist/core/adapter.d.ts.map +1 -1
- package/dist/core/adapter.js +214 -83
- package/dist/core/adapter.js.map +1 -1
- package/dist/core/ado-deliver-helper.d.ts +2 -1
- package/dist/core/ado-deliver-helper.d.ts.map +1 -1
- package/dist/core/ado-deliver-helper.js +26 -1
- package/dist/core/ado-deliver-helper.js.map +1 -1
- package/dist/core/assurance.d.ts +45 -42
- package/dist/core/assurance.d.ts.map +1 -1
- package/dist/core/assurance.js +74 -67
- package/dist/core/assurance.js.map +1 -1
- package/dist/core/deliver-text.d.ts +14 -0
- package/dist/core/deliver-text.d.ts.map +1 -1
- package/dist/core/deliver-text.js +41 -2
- package/dist/core/deliver-text.js.map +1 -1
- package/dist/core/deliver.d.ts +66 -1
- package/dist/core/deliver.d.ts.map +1 -1
- package/dist/core/deliver.js +183 -10
- package/dist/core/deliver.js.map +1 -1
- package/dist/core/engine-roster.d.ts +2 -0
- package/dist/core/engine-roster.d.ts.map +1 -1
- package/dist/core/engine-roster.js +13 -0
- package/dist/core/engine-roster.js.map +1 -1
- package/dist/core/estate-mcp-client.d.ts +13 -14
- package/dist/core/estate-mcp-client.d.ts.map +1 -1
- package/dist/core/estate-mcp-client.js +49 -68
- package/dist/core/estate-mcp-client.js.map +1 -1
- package/dist/core/exec.d.ts +24 -0
- package/dist/core/exec.d.ts.map +1 -1
- package/dist/core/exec.js +45 -2
- package/dist/core/exec.js.map +1 -1
- package/dist/core/linked-issues.d.ts +13 -2
- package/dist/core/linked-issues.d.ts.map +1 -1
- package/dist/core/linked-issues.js +135 -4
- package/dist/core/linked-issues.js.map +1 -1
- package/dist/core/pr-checks-helper.d.ts +8 -4
- package/dist/core/pr-checks-helper.d.ts.map +1 -1
- package/dist/core/pr-checks-helper.js +39 -17
- package/dist/core/pr-checks-helper.js.map +1 -1
- package/dist/core/redeliver.js +2 -2
- package/dist/core/redeliver.js.map +1 -1
- package/dist/core/repo-clone.d.ts +64 -0
- package/dist/core/repo-clone.d.ts.map +1 -0
- package/dist/core/repo-clone.js +306 -0
- package/dist/core/repo-clone.js.map +1 -0
- package/dist/core/repoPaths.d.ts +2 -4
- package/dist/core/repoPaths.d.ts.map +1 -1
- package/dist/core/repoPaths.js +4 -6
- package/dist/core/repoPaths.js.map +1 -1
- package/dist/core/run-identity.d.ts.map +1 -1
- package/dist/core/run-identity.js +3 -0
- package/dist/core/run-identity.js.map +1 -1
- package/dist/core/run-read-lane.d.ts +30 -0
- package/dist/core/run-read-lane.d.ts.map +1 -0
- package/dist/core/run-read-lane.js +103 -0
- package/dist/core/run-read-lane.js.map +1 -0
- package/dist/core/types.d.ts +10 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js +2 -0
- package/dist/core/types.js.map +1 -1
- package/dist/core/walkthrough-root.d.ts.map +1 -1
- package/dist/core/walkthrough-root.js +3 -5
- package/dist/core/walkthrough-root.js.map +1 -1
- package/dist/core/wicked-home.d.ts +9 -0
- package/dist/core/wicked-home.d.ts.map +1 -0
- package/dist/core/wicked-home.js +25 -0
- package/dist/core/wicked-home.js.map +1 -0
- package/dist/decisions/consider.d.ts +2 -1
- package/dist/decisions/consider.d.ts.map +1 -1
- package/dist/decisions/consider.js +2 -2
- package/dist/decisions/consider.js.map +1 -1
- package/dist/decisions/land.d.ts +2 -0
- package/dist/decisions/land.d.ts.map +1 -1
- package/dist/decisions/land.js +16 -3
- package/dist/decisions/land.js.map +1 -1
- package/dist/decisions/rules-brief.d.ts +4 -1
- package/dist/decisions/rules-brief.d.ts.map +1 -1
- package/dist/decisions/rules-brief.js +3 -2
- package/dist/decisions/rules-brief.js.map +1 -1
- package/dist/editors/conformance-runtime.d.ts +0 -2
- package/dist/editors/conformance-runtime.d.ts.map +1 -1
- package/dist/editors/conformance-runtime.js +0 -4
- package/dist/editors/conformance-runtime.js.map +1 -1
- package/dist/editors/csp.d.ts +6 -0
- package/dist/editors/csp.d.ts.map +1 -1
- package/dist/editors/csp.js +10 -0
- package/dist/editors/csp.js.map +1 -1
- package/dist/editors/pack-install.d.ts +11 -15
- package/dist/editors/pack-install.d.ts.map +1 -1
- package/dist/editors/pack-install.js +52 -65
- package/dist/editors/pack-install.js.map +1 -1
- package/dist/editors/registry.d.ts +31 -13
- package/dist/editors/registry.d.ts.map +1 -1
- package/dist/editors/registry.js +51 -18
- package/dist/editors/registry.js.map +1 -1
- package/dist/editors/routes.d.ts +4 -2
- package/dist/editors/routes.d.ts.map +1 -1
- package/dist/editors/routes.js +23 -6
- package/dist/editors/routes.js.map +1 -1
- package/dist/editors/visuals.d.ts +4 -3
- package/dist/editors/visuals.d.ts.map +1 -1
- package/dist/editors/visuals.js +17 -7
- package/dist/editors/visuals.js.map +1 -1
- package/dist/evals/runner.js +1 -1
- package/dist/evals/runner.js.map +1 -1
- package/dist/evals/shape-corrections.js +1 -1
- package/dist/evals/shape-corrections.js.map +1 -1
- package/dist/evals/shape.d.ts +7 -1
- package/dist/evals/shape.d.ts.map +1 -1
- package/dist/evals/shape.js +26 -6
- package/dist/evals/shape.js.map +1 -1
- package/dist/evals/workflow.d.ts +16 -3
- package/dist/evals/workflow.d.ts.map +1 -1
- package/dist/evals/workflow.js +32 -6
- package/dist/evals/workflow.js.map +1 -1
- package/dist/governance/rule-revision.d.ts +7 -0
- package/dist/governance/rule-revision.d.ts.map +1 -0
- package/dist/governance/rule-revision.js +23 -0
- package/dist/governance/rule-revision.js.map +1 -0
- package/dist/insights/review-service.d.ts +26 -3
- package/dist/insights/review-service.d.ts.map +1 -1
- package/dist/insights/review-service.js +101 -11
- package/dist/insights/review-service.js.map +1 -1
- package/dist/insights/routes.d.ts +2 -1
- package/dist/insights/routes.d.ts.map +1 -1
- package/dist/insights/routes.js +19 -4
- package/dist/insights/routes.js.map +1 -1
- package/dist/insights/run-facts.d.ts +5 -0
- package/dist/insights/run-facts.d.ts.map +1 -1
- package/dist/insights/run-facts.js +15 -0
- package/dist/insights/run-facts.js.map +1 -1
- package/dist/insights/workflow.d.ts +2 -1
- package/dist/insights/workflow.d.ts.map +1 -1
- package/dist/insights/workflow.js +4 -4
- package/dist/insights/workflow.js.map +1 -1
- package/dist/inspect/service.d.ts +3 -2
- package/dist/inspect/service.d.ts.map +1 -1
- package/dist/inspect/service.js +4 -4
- package/dist/inspect/service.js.map +1 -1
- package/dist/interactive/bridge-pool.d.ts +2 -0
- package/dist/interactive/bridge-pool.d.ts.map +1 -1
- package/dist/interactive/bridge-pool.js +18 -8
- package/dist/interactive/bridge-pool.js.map +1 -1
- package/dist/interactive/chat-events.d.ts +3 -0
- package/dist/interactive/chat-events.d.ts.map +1 -1
- package/dist/interactive/chat-events.js +20 -5
- package/dist/interactive/chat-events.js.map +1 -1
- package/dist/interactive/doc-delete-routes.d.ts +1 -0
- package/dist/interactive/doc-delete-routes.d.ts.map +1 -1
- package/dist/interactive/doc-delete-routes.js +126 -123
- package/dist/interactive/doc-delete-routes.js.map +1 -1
- package/dist/interactive/draft-events.d.ts +11 -7
- package/dist/interactive/draft-events.d.ts.map +1 -1
- package/dist/interactive/draft-events.js +29 -22
- package/dist/interactive/draft-events.js.map +1 -1
- package/dist/interactive/draft-skill.d.ts +56 -3
- package/dist/interactive/draft-skill.d.ts.map +1 -1
- package/dist/interactive/draft-skill.js +129 -20
- package/dist/interactive/draft-skill.js.map +1 -1
- package/dist/interactive/landing-guard.d.ts +30 -5
- package/dist/interactive/landing-guard.d.ts.map +1 -1
- package/dist/interactive/landing-guard.js +121 -5
- package/dist/interactive/landing-guard.js.map +1 -1
- package/dist/interactive/proposal-create.d.ts +9 -11
- package/dist/interactive/proposal-create.d.ts.map +1 -1
- package/dist/interactive/proposal-create.js +28 -21
- package/dist/interactive/proposal-create.js.map +1 -1
- package/dist/interactive/proposal-refine.d.ts +4 -4
- package/dist/interactive/proposal-refine.d.ts.map +1 -1
- package/dist/interactive/proposal-refine.js +40 -7
- package/dist/interactive/proposal-refine.js.map +1 -1
- package/dist/interactive/proxy-routes.d.ts +10 -5
- package/dist/interactive/proxy-routes.d.ts.map +1 -1
- package/dist/interactive/proxy-routes.js +108 -11
- package/dist/interactive/proxy-routes.js.map +1 -1
- package/dist/interactive/review-events.js +1 -1
- package/dist/interactive/review-events.js.map +1 -1
- package/dist/interactive/run-units.d.ts.map +1 -1
- package/dist/interactive/run-units.js +3 -2
- package/dist/interactive/run-units.js.map +1 -1
- package/dist/interactive/source-packet.d.ts +13 -1
- package/dist/interactive/source-packet.d.ts.map +1 -1
- package/dist/interactive/source-packet.js +108 -34
- package/dist/interactive/source-packet.js.map +1 -1
- package/dist/knowledge/adapters/toolbox/memory.d.ts +2 -0
- package/dist/knowledge/adapters/toolbox/memory.d.ts.map +1 -0
- package/dist/knowledge/adapters/toolbox/memory.js +43 -0
- package/dist/knowledge/adapters/toolbox/memory.js.map +1 -0
- package/dist/knowledge/adapters/toolbox/supervisor.d.ts +30 -4
- package/dist/knowledge/adapters/toolbox/supervisor.d.ts.map +1 -1
- package/dist/knowledge/adapters/toolbox/supervisor.js +112 -28
- package/dist/knowledge/adapters/toolbox/supervisor.js.map +1 -1
- package/dist/knowledge/estate-write.d.ts +5 -0
- package/dist/knowledge/estate-write.d.ts.map +1 -1
- package/dist/knowledge/estate-write.js +7 -0
- package/dist/knowledge/estate-write.js.map +1 -1
- package/dist/knowledge/gate/gate.d.ts.map +1 -1
- package/dist/knowledge/gate/gate.js +4 -1
- package/dist/knowledge/gate/gate.js.map +1 -1
- package/dist/knowledge/gate/record.d.ts +15 -2
- package/dist/knowledge/gate/record.d.ts.map +1 -1
- package/dist/knowledge/gate/record.js +108 -29
- package/dist/knowledge/gate/record.js.map +1 -1
- package/dist/knowledge/projector.d.ts +60 -5
- package/dist/knowledge/projector.d.ts.map +1 -1
- package/dist/knowledge/projector.js +264 -21
- package/dist/knowledge/projector.js.map +1 -1
- package/dist/knowledge/registry/entry.d.ts +7 -0
- package/dist/knowledge/registry/entry.d.ts.map +1 -1
- package/dist/knowledge/registry/entry.js +4 -0
- package/dist/knowledge/registry/entry.js.map +1 -1
- package/dist/knowledge/shapes/map.d.ts.map +1 -1
- package/dist/knowledge/shapes/map.js +12 -2
- package/dist/knowledge/shapes/map.js.map +1 -1
- package/dist/knowledge/shapes/routes.d.ts +1 -1
- package/dist/knowledge/shapes/routes.d.ts.map +1 -1
- package/dist/knowledge/shapes/routes.js +42 -16
- package/dist/knowledge/shapes/routes.js.map +1 -1
- package/dist/knowledge/shapes/shapes.d.ts +60 -13
- package/dist/knowledge/shapes/shapes.d.ts.map +1 -1
- package/dist/knowledge/shapes/shapes.js +199 -31
- package/dist/knowledge/shapes/shapes.js.map +1 -1
- package/dist/knowledge/shapes/verified.d.ts.map +1 -1
- package/dist/knowledge/shapes/verified.js +3 -2
- package/dist/knowledge/shapes/verified.js.map +1 -1
- package/dist/knowledge/trackers/addresses.d.ts +27 -3
- package/dist/knowledge/trackers/addresses.d.ts.map +1 -1
- package/dist/knowledge/trackers/addresses.js +33 -5
- package/dist/knowledge/trackers/addresses.js.map +1 -1
- package/dist/knowledge/trackers/gate-pm.d.ts.map +1 -1
- package/dist/knowledge/trackers/gate-pm.js +4 -2
- package/dist/knowledge/trackers/gate-pm.js.map +1 -1
- package/dist/knowledge/trackers/projector.d.ts +3 -1
- package/dist/knowledge/trackers/projector.d.ts.map +1 -1
- package/dist/knowledge/trackers/projector.js +59 -8
- package/dist/knowledge/trackers/projector.js.map +1 -1
- package/dist/learn/scheduler.d.ts.map +1 -1
- package/dist/learn/scheduler.js +13 -3
- package/dist/learn/scheduler.js.map +1 -1
- package/dist/learnings/estate.d.ts.map +1 -1
- package/dist/learnings/estate.js +3 -14
- package/dist/learnings/estate.js.map +1 -1
- package/dist/learnings/extract.d.ts +9 -3
- package/dist/learnings/extract.d.ts.map +1 -1
- package/dist/learnings/extract.js +62 -4
- package/dist/learnings/extract.js.map +1 -1
- package/dist/learnings/replacement-lineage.d.ts +3 -2
- package/dist/learnings/replacement-lineage.d.ts.map +1 -1
- package/dist/learnings/replacement-lineage.js +7 -6
- package/dist/learnings/replacement-lineage.js.map +1 -1
- package/dist/learnings/service.d.ts +12 -2
- package/dist/learnings/service.d.ts.map +1 -1
- package/dist/learnings/service.js +30 -5
- package/dist/learnings/service.js.map +1 -1
- package/dist/mcp/broker.d.ts.map +1 -1
- package/dist/mcp/broker.js +19 -5
- package/dist/mcp/broker.js.map +1 -1
- package/dist/mcp/env.d.ts +12 -4
- package/dist/mcp/env.d.ts.map +1 -1
- package/dist/mcp/env.js +24 -4
- package/dist/mcp/env.js.map +1 -1
- package/dist/mcp/estate-relay.d.ts +3 -0
- package/dist/mcp/estate-relay.d.ts.map +1 -1
- package/dist/mcp/estate-relay.js +7 -6
- package/dist/mcp/estate-relay.js.map +1 -1
- package/dist/mcp/invoke.d.ts.map +1 -1
- package/dist/mcp/invoke.js +6 -5
- package/dist/mcp/invoke.js.map +1 -1
- package/dist/mcp/probe.d.ts +14 -1
- package/dist/mcp/probe.d.ts.map +1 -1
- package/dist/mcp/probe.js +55 -10
- package/dist/mcp/probe.js.map +1 -1
- package/dist/mcp/redact.d.ts +1 -1
- package/dist/mcp/redact.d.ts.map +1 -1
- package/dist/mcp/redact.js +61 -4
- package/dist/mcp/redact.js.map +1 -1
- package/dist/mcp/registry-store.d.ts +37 -0
- package/dist/mcp/registry-store.d.ts.map +1 -1
- package/dist/mcp/registry-store.js +43 -0
- package/dist/mcp/registry-store.js.map +1 -1
- package/dist/mcp/registry.d.ts +38 -6
- package/dist/mcp/registry.d.ts.map +1 -1
- package/dist/mcp/registry.js +145 -14
- package/dist/mcp/registry.js.map +1 -1
- package/dist/mcp/rest.js +4 -4
- package/dist/mcp/rest.js.map +1 -1
- package/dist/mcp/run-fence.d.ts +2 -0
- package/dist/mcp/run-fence.d.ts.map +1 -1
- package/dist/mcp/run-fence.js +9 -0
- package/dist/mcp/run-fence.js.map +1 -1
- package/dist/mcp/secrets.d.ts +1 -1
- package/dist/mcp/secrets.d.ts.map +1 -1
- package/dist/mcp/secrets.js +10 -11
- package/dist/mcp/secrets.js.map +1 -1
- package/dist/mcp/upstream-error.d.ts +6 -2
- package/dist/mcp/upstream-error.d.ts.map +1 -1
- package/dist/mcp/upstream-error.js +5 -1
- package/dist/mcp/upstream-error.js.map +1 -1
- package/dist/projects/graph.d.ts +15 -5
- package/dist/projects/graph.d.ts.map +1 -1
- package/dist/projects/graph.js +354 -26
- package/dist/projects/graph.js.map +1 -1
- package/dist/projects/repo-watch.d.ts +2 -2
- package/dist/projects/repo-watch.d.ts.map +1 -1
- package/dist/projects/repo-watch.js +26 -9
- package/dist/projects/repo-watch.js.map +1 -1
- package/dist/projects/routes.d.ts +9 -1
- package/dist/projects/routes.d.ts.map +1 -1
- package/dist/projects/routes.js +63 -6
- package/dist/projects/routes.js.map +1 -1
- package/dist/projects/state-home-preflight.d.ts +5 -0
- package/dist/projects/state-home-preflight.d.ts.map +1 -1
- package/dist/projects/state-home-preflight.js +48 -8
- package/dist/projects/state-home-preflight.js.map +1 -1
- package/dist/projects/state-home-registry.d.ts.map +1 -1
- package/dist/projects/state-home-registry.js +9 -0
- package/dist/projects/state-home-registry.js.map +1 -1
- package/dist/projects/state-home.d.ts +11 -0
- package/dist/projects/state-home.d.ts.map +1 -1
- package/dist/projects/state-home.js +14 -0
- package/dist/projects/state-home.js.map +1 -1
- package/dist/qe/author-workflow.d.ts +4 -0
- package/dist/qe/author-workflow.d.ts.map +1 -1
- package/dist/qe/author-workflow.js +4 -0
- package/dist/qe/author-workflow.js.map +1 -1
- package/dist/qe/test-sets.d.ts +5 -6
- package/dist/qe/test-sets.d.ts.map +1 -1
- package/dist/qe/test-sets.js +4 -3
- package/dist/qe/test-sets.js.map +1 -1
- package/dist/schedules/routes.d.ts +5 -0
- package/dist/schedules/routes.d.ts.map +1 -1
- package/dist/schedules/routes.js +32 -5
- package/dist/schedules/routes.js.map +1 -1
- package/dist/schedules/scheduler.d.ts +8 -1
- package/dist/schedules/scheduler.d.ts.map +1 -1
- package/dist/schedules/scheduler.js +10 -1
- package/dist/schedules/scheduler.js.map +1 -1
- package/dist/schedules/store.d.ts +7 -0
- package/dist/schedules/store.d.ts.map +1 -1
- package/dist/schedules/store.js +19 -4
- package/dist/schedules/store.js.map +1 -1
- package/dist/skills/plugin-source.js +4 -4
- package/dist/skills/plugin-source.js.map +1 -1
- package/dist/sources/ask.d.ts.map +1 -1
- package/dist/sources/ask.js +12 -12
- package/dist/sources/ask.js.map +1 -1
- package/dist/sources/dialer.d.ts +6 -1
- package/dist/sources/dialer.d.ts.map +1 -1
- package/dist/sources/dialer.js +53 -31
- package/dist/sources/dialer.js.map +1 -1
- package/dist/sources/drivers/mysql.d.ts +2 -0
- package/dist/sources/drivers/mysql.d.ts.map +1 -1
- package/dist/sources/drivers/mysql.js +18 -2
- package/dist/sources/drivers/mysql.js.map +1 -1
- package/dist/sources/drivers/postgres.d.ts +2 -0
- package/dist/sources/drivers/postgres.d.ts.map +1 -1
- package/dist/sources/drivers/postgres.js +10 -3
- package/dist/sources/drivers/postgres.js.map +1 -1
- package/dist/sources/drivers/sqlite.d.ts +33 -3
- package/dist/sources/drivers/sqlite.d.ts.map +1 -1
- package/dist/sources/drivers/sqlite.js +18 -6
- package/dist/sources/drivers/sqlite.js.map +1 -1
- package/dist/sources/drivers/types.d.ts +3 -1
- package/dist/sources/drivers/types.d.ts.map +1 -1
- package/dist/sources/drivers/types.js +3 -1
- package/dist/sources/drivers/types.js.map +1 -1
- package/dist/sources/routes.d.ts.map +1 -1
- package/dist/sources/routes.js +1 -0
- package/dist/sources/routes.js.map +1 -1
- package/dist/sources/uploads.d.ts +22 -15
- package/dist/sources/uploads.d.ts.map +1 -1
- package/dist/sources/uploads.js +124 -436
- package/dist/sources/uploads.js.map +1 -1
- package/dist/standing-orders/history.d.ts +5 -3
- package/dist/standing-orders/history.d.ts.map +1 -1
- package/dist/standing-orders/history.js +6 -2
- package/dist/standing-orders/history.js.map +1 -1
- package/dist/standing-orders/parse.d.ts +8 -0
- package/dist/standing-orders/parse.d.ts.map +1 -1
- package/dist/standing-orders/parse.js +52 -5
- package/dist/standing-orders/parse.js.map +1 -1
- package/dist/studio/apps-standalone/fixture.js +3 -3
- package/dist/studio/apps-standalone/runtime.js +1 -1
- package/dist/studio/assets/{KnowledgeGraph-DWw0I8RJ.js → KnowledgeGraph-yP4WsnST.js} +1 -1
- package/dist/studio/assets/index-DNaLjJ7M.css +32 -0
- package/dist/studio/assets/index-DW53FKuT.js +1114 -0
- package/dist/studio/editors/wicked-apps/editor.json +1 -1
- package/dist/studio/editors/wicked-apps/index.html +2 -2
- package/dist/studio/editors/wicked-deck/editor.json +1 -1
- package/dist/studio/editors/wicked-deck/index.html +2 -2
- package/dist/studio/editors/wicked-doc/editor.json +1 -1
- package/dist/studio/editors/wicked-doc/index.html +1 -1
- package/dist/studio/editors/wicked-insights/editor.json +1 -1
- package/dist/studio/editors/wicked-insights/index.html +1 -1
- package/dist/studio/editors/wicked-page/editor.json +1 -1
- package/dist/studio/editors/wicked-page/index.html +1 -1
- package/dist/studio/editors/wicked-video/editor.json +1 -1
- package/dist/studio/editors/wicked-video/index.html +1 -1
- package/dist/studio/index.html +2 -2
- package/dist/studio/testid-inventory.json +1589 -281
- package/dist/team/routes.d.ts +11 -1
- package/dist/team/routes.d.ts.map +1 -1
- package/dist/team/routes.js +8 -4
- package/dist/team/routes.js.map +1 -1
- package/dist/voice/tts.d.ts +12 -0
- package/dist/voice/tts.d.ts.map +1 -1
- package/dist/voice/tts.js +118 -28
- package/dist/voice/tts.js.map +1 -1
- package/dist/workflow-catalog/build-v2.d.ts +34 -0
- package/dist/workflow-catalog/build-v2.d.ts.map +1 -1
- package/dist/workflow-catalog/build-v2.js +131 -10
- package/dist/workflow-catalog/build-v2.js.map +1 -1
- package/dist/workflow-catalog/catalog-data-v2.d.ts +6 -2
- package/dist/workflow-catalog/catalog-data-v2.d.ts.map +1 -1
- package/dist/workflow-catalog/catalog-data-v2.js.map +1 -1
- package/dist/workflow-catalog/catalog-data.d.ts.map +1 -1
- package/dist/workflow-catalog/catalog-data.js +0 -2
- package/dist/workflow-catalog/catalog-data.js.map +1 -1
- package/dist/workflow-catalog/detect.d.ts +18 -3
- package/dist/workflow-catalog/detect.d.ts.map +1 -1
- package/dist/workflow-catalog/detect.js +43 -8
- package/dist/workflow-catalog/detect.js.map +1 -1
- package/dist/workflow-catalog/shape.d.ts +1 -1
- package/dist/working-doc/event-lines.d.ts +12 -2
- package/dist/working-doc/event-lines.d.ts.map +1 -1
- package/dist/working-doc/event-lines.js +62 -10
- package/dist/working-doc/event-lines.js.map +1 -1
- package/dist/working-doc/sections.d.ts +3 -0
- package/dist/working-doc/sections.d.ts.map +1 -1
- package/dist/working-doc/sections.js +5 -0
- package/dist/working-doc/sections.js.map +1 -1
- package/dist/working-doc/service.d.ts +23 -3
- package/dist/working-doc/service.d.ts.map +1 -1
- package/dist/working-doc/service.js +93 -54
- package/dist/working-doc/service.js.map +1 -1
- package/endpoint-manifest.json +148 -8
- package/evals/corpora/shape-v1.json +25 -1
- package/evals/corpora/shape-v1.seat-fixture.json +25 -1
- package/package.json +4 -4
- package/runners/sqlite-runner.mjs +67 -12
- package/runners/upload-parse.d.mts +13 -0
- package/runners/upload-parse.mjs +364 -0
- package/dist/studio/assets/index-C4Xj-zxa.css +0 -32
- package/dist/studio/assets/index-CrNY3d06.js +0 -1109
package/dist/api/routes.js
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
|
+
import { RuleChangedError, ruleRevision } from '../governance/rule-revision.js';
|
|
1
2
|
import { registerRedeliverRoutes } from './redeliver.js';
|
|
2
3
|
import { REVIEW_WORKFLOW } from '../insights/workflow.js';
|
|
3
4
|
import { runUsageCost } from '../insights/run-facts.js';
|
|
5
|
+
import { NoIndependentReviewer } from '../insights/review-service.js';
|
|
4
6
|
import { appsRuntimeDir, appsServerArtifact, containerEngineKnown } from '../apps/publish/artifacts.js';
|
|
5
7
|
import { busSeamsOffWarning, busUnavailableWarning } from '../core/bus-notice.js';
|
|
6
8
|
import { vaultBinWarning, vaultDiagnostics } from '../core/vault-bin.js';
|
|
7
9
|
import { PlanSchema, toLaunchPlan } from './plan-schema.js';
|
|
8
10
|
import { record, z } from '../zod.js';
|
|
9
|
-
import { listRequirementsRead, setRepoMinimum, getRequirement, patchRequirement, readRequirementsGraph, REQUIREMENTS_NOT_GENERATED, } from './requirements.js';
|
|
11
|
+
import { listRequirementsRead, setRepoMinimum, getRequirement, patchRequirement, retireRequirement, readRequirementsGraph, REQUIREMENTS_NOT_GENERATED, } from './requirements.js';
|
|
10
12
|
import { randomUUID } from 'node:crypto';
|
|
11
13
|
import { homedir } from 'node:os';
|
|
12
14
|
import { readFileSync, existsSync, mkdirSync, realpathSync } from 'node:fs';
|
|
13
15
|
import { promises as fsp } from 'node:fs';
|
|
14
|
-
import { basename, isAbsolute, join, relative, resolve } from 'node:path';
|
|
16
|
+
import { basename, dirname, isAbsolute, join, relative, resolve } from 'node:path';
|
|
15
17
|
import { fileURLToPath } from 'node:url';
|
|
16
18
|
import { videoPalette } from '../appearance/video-palette.js';
|
|
17
|
-
import { CampaignsUnsupportedError, ChatUnsupportedError, CoreAdapter, ElicitationUnsupportedError, GovernanceReplayUnsupportedError, PlanGateNoteUnsupportedError, PlanLaunchUnsupportedError, SteeringUnsupportedError, addonSupportsQeOverride, addonSupportsReducedAssurance, humanGatePhaseIds, readNewWorkSeats, settingsFilePath
|
|
19
|
+
import { CampaignsUnsupportedError, ChatUnsupportedError, CoreAdapter, MaintenanceDrainError, RepoUnregisterUnsupportedError, TERMINAL_RUN_STATUSES, ElicitationUnsupportedError, GovernanceReplayUnsupportedError, PlanGateNoteUnsupportedError, PlanLaunchUnsupportedError, SteeringUnsupportedError, addonSupportsQeOverride, addonSupportsReducedAssurance, humanGatePhaseIds, readNewWorkSeats, settingsFilePath } from '../core/adapter.js';
|
|
18
20
|
import { codeGraphDb, codeGraphErrorStatus, repoFolderMissing, repoFolderMissingBody } from '../core/repoPaths.js';
|
|
19
21
|
import { resolveCursorUnit } from '../core/cursor.js';
|
|
20
22
|
/** Create `dir` (private) when missing and answer it — a read root must exist when a run launches. */
|
|
@@ -81,9 +83,10 @@ import { InvalidDiffBaseError, MERGE_BASE_LITERAL, NotARegularFileError, Unresol
|
|
|
81
83
|
import { DocRunIndex } from '../interactive/doc-run-index.js';
|
|
82
84
|
import { listInteractiveDocs } from '../interactive/docs-index.js';
|
|
83
85
|
import { SearchService, registerSearchRoutes } from './search-routes.js';
|
|
86
|
+
import { RepoOrigins, originOf } from './repo-origins.js';
|
|
84
87
|
import { TestSetIndex } from '../qe/test-sets.js';
|
|
85
88
|
import { estateExe, parseEstateTotals, projectGraphRefreshDiagnostics, readBlastRadiusPages, resolveProjectGraphBinding } from '../projects/graph.js';
|
|
86
|
-
import { attachRepoToProject, registerProjectRoutes } from '../projects/routes.js';
|
|
89
|
+
import { attachRepoToProject, createProjectRecorded, registerProjectRoutes } from '../projects/routes.js';
|
|
87
90
|
import { registerProjectAggregateRoutes } from './project-aggregates.js';
|
|
88
91
|
import { composeLaunch, composePreflight, registerProductRoutes } from './product.js';
|
|
89
92
|
import { buildWorkflowCatalogV2, parseCommand, resolveOption } from '../workflow-catalog/build-v2.js';
|
|
@@ -100,7 +103,8 @@ import { inventoryComplete, parseInventoryClaims } from '../core/inventory-claim
|
|
|
100
103
|
import { ApproveEditSchema, approveEdited, captureLaunchRoots, editInFlight, FileProposalSchema, registerCaptureRoutes } from './capture.js';
|
|
101
104
|
import { registerTestingRoutes } from './testing.js';
|
|
102
105
|
import { registerDefaultEvalRoutes, runAndRecord } from '../evals/routes.js';
|
|
103
|
-
import { prepareRunEvalsLaunch, RUN_EVALS_WORKFLOW } from '../evals/workflow.js';
|
|
106
|
+
import { prepareRunEvalsLaunch, RUN_EVALS_WORKFLOW, runEvalsScopeOf } from '../evals/workflow.js';
|
|
107
|
+
import { DOMAIN_MAPPING } from '../projects/repo-watch.js';
|
|
104
108
|
import { defaultReplaySet } from '../evals/replay.js';
|
|
105
109
|
import { gardenRootFor } from '../learn/scheduler.js';
|
|
106
110
|
import { agentMay } from '../knowledge/gate/access.js';
|
|
@@ -122,7 +126,7 @@ import { BASE_SKILL_POLICIES, BASE_SKILL_REF_SHAPE, baseSkillRemedy } from '../s
|
|
|
122
126
|
import { REQUIRED_GARDEN_VERSION } from '../skills/plugin-source.js';
|
|
123
127
|
import { isSeatKeyList } from '../core/job-seats.js';
|
|
124
128
|
import { engineRosterJson, noEligibleSeatBody, parseNoEligibleSeat, toEngineSeat } from '../core/engine-roster.js';
|
|
125
|
-
import { launchAssuranceNotice } from '../core/assurance.js';
|
|
129
|
+
import { launchAssuranceNotice, readJudgeCoverage } from '../core/assurance.js';
|
|
126
130
|
import { launchPosture } from '../core/launch-posture.js';
|
|
127
131
|
import { launchRequiresQe, mayRequireQe, qeAcceptanceMode, qeSettingSkipReason } from '../core/qe-acceptance-setting.js';
|
|
128
132
|
import { aggregateReceipt, postHocDeliveryAssurance, qeAcceptanceFromView, qeAcceptanceRefusal, QE_ACCEPTANCE_REQUIRED_CODE, receiptOf, qeAcceptanceNotRequired, qeDecisionBypasses, qeDecisionOf, qeAcceptanceSkippedAtGate, unreadableQeAcceptance, } from './delivery-assurance.js';
|
|
@@ -131,7 +135,7 @@ import { isHumanOperator } from './watch-routes.js';
|
|
|
131
135
|
import { boundOrigin, InteractiveBridgePool } from '../interactive/bridge-pool.js';
|
|
132
136
|
import { defaultInteractiveRoot } from '../interactive/bridge-root.js';
|
|
133
137
|
import { composeDeliverText, configuredPublicOrigin, extractFollowUps, factsFromRun, reportsFromOutputs, FOLLOW_UPS_MAX, framedDeliverText, runUrlFor, } from '../core/deliver-text.js';
|
|
134
|
-
import { deliverIdentityFor, defaultGhExec, deliverRepoFor, deliverTargetView, isGitHubLogin, pushIdentityOf, readDeliverOriginUrl, resolvePullRequest as resolvePullRequestViaGh, unverifiedTreesFrom, } from '../core/deliver.js';
|
|
138
|
+
import { deliverAuthorOf, deliverIdentityFor, defaultGhExec, deliverRepoFor, deliverTargetView, isGitHubLogin, pinnedGhExec, pinnedGitExec, pushIdentityOf, readDeliverOriginUrl, resolvePullRequest as resolvePullRequestViaGh, unverifiedTreesFrom, } from '../core/deliver.js';
|
|
135
139
|
import { credentialsMissingIn, deliverCredentialsProbe, missingCredentials } from '../core/deliver-credentials.js';
|
|
136
140
|
import { codebaseArchiveUrl } from './codebase-archive.js';
|
|
137
141
|
import { projectRepoCandidates } from '../interactive/doc-grounding.js';
|
|
@@ -148,12 +152,12 @@ import { readBeneath } from './beneath.js';
|
|
|
148
152
|
const BRIEF_COPY_MAX = 512 * 1024;
|
|
149
153
|
import { registerInteractiveDocDelete } from '../interactive/doc-delete-routes.js';
|
|
150
154
|
import { registerInteractiveDocChecks } from '../interactive/doc-checks-routes.js';
|
|
151
|
-
import { crewStateHome, stateHomeOfDb } from '../projects/state-home.js';
|
|
152
|
-
import { demoShowOf, factsOf, inputLines, jobInputsOfProposal, jobLaunchCommon, jobLaunchRoster, personPid, requestDigest, SELF_SEATED } from './chat-jobs.js';
|
|
153
|
-
import { DocumentsRefused, documentsClause, RUN_DOCS_TOKENS_MAX, stagedDocumentsOf, stageRunDocuments } from './run-documents.js';
|
|
155
|
+
import { crewStateHome, stateHomeOfDb, wickedWorkRoot } from '../projects/state-home.js';
|
|
156
|
+
import { demoShowOf, factsOf, inputLines, jobInputsOfProposal, jobLaunchCommon, jobLaunchRoster, jobRevisionLaunch, personPid, requestDigest, SELF_SEATED } from './chat-jobs.js';
|
|
157
|
+
import { DocumentsRefused, documentsClause, RUN_DOCS_TOKENS_MAX, removeStagedDocuments, stagedDocumentsRemoved, stagedDocumentsOf, stageRunDocuments } from './run-documents.js';
|
|
154
158
|
import { checkSourcePick, projectSources, RUN_SOURCES_MAX, runSourcesDeps, webScopeReason } from './run-sources.js';
|
|
155
159
|
import { CATALOG_V2_CARDS } from '../workflow-catalog/catalog-data-v2.js';
|
|
156
|
-
import { ChatProposals, LaunchOnceRegistry, proposalRunId, RecordingStubDispatcher, RevisionEditsSchema, runCostFromEvents } from './chat-proposals.js';
|
|
160
|
+
import { CHAT_ENDED, LaunchRefusal, ChatProposals, LaunchOnceRegistry, liveInRuns, proposalRunId, RecordingStubDispatcher, RevisionEditsSchema, runCostFromEvents } from './chat-proposals.js';
|
|
157
161
|
import { CATALOG_SEEDS } from '../workflow-catalog/catalog-data.js';
|
|
158
162
|
import { registerInteractiveDocList } from '../interactive/doc-list-routes.js';
|
|
159
163
|
import { REVIEWS_DIRNAME } from '../interactive/review-ledger.js';
|
|
@@ -166,17 +170,20 @@ import { pmRegistered, readPmIssues } from '../knowledge/trackers/issues.js';
|
|
|
166
170
|
import { registerTrackerRoutes } from '../knowledge/trackers/routes.js';
|
|
167
171
|
import { AuditLog } from './audit.js';
|
|
168
172
|
import { auditFor } from './audit-view.js';
|
|
173
|
+
import { ProposalDecisionIndex, recordProposalDecision } from './proposal-decisions.js';
|
|
169
174
|
import { AcpFoldCache, EngineVersionCache, FloorCacheCache, eventsDirOf, installedPackageVersion, hostSandboxLauncher, seatRosterFile, listStoreFiles, readStudioBundleVersion, } from './diagnostics.js';
|
|
170
175
|
import { GovernanceDiagnostics } from './governance-health.js';
|
|
171
176
|
import { ATTACHMENT_LIMITS, ATTACHMENT_MAX_MESSAGE_BYTES, AttachmentError, ChatAttachmentStore, attachmentWire, attachmentsBlock, boundaryOf, parseMultipart, stageForSeat } from './chat-attachments.js';
|
|
172
|
-
import { CHAT_HISTORY_MAX_LIMIT, ChatHistoryStore, decodeCursor } from './chat-history.js';
|
|
173
|
-
import { PROBE_TIMEOUT_MS, SYSTEM_BUDGET_MS, SYSTEM_STATS_DAYS, SYSTEM_STATS_TTL_MS, WeekFoldCache, assembleSnapshot, buildNeeds, buildClis, buildGovernance, diskRow, estateReadonlyCall, infraRow, judgeGaps, livenessThresholds, loadRow, probeBroker, probeBus, probeEstate, probeInteractive, probeVault, readBridgeLockAsync, readWeek, runLiveness, settleWithin, skillsRow, sortRuns, stateHomeRow, reposRow, unfinished, } from './system-snapshot.js';
|
|
177
|
+
import { CHAT_HISTORY_MAX_LIMIT, ChatHistoryStore, SeedRequestStore, decodeCursor } from './chat-history.js';
|
|
178
|
+
import { PROBE_TIMEOUT_MS, SYSTEM_BUDGET_MS, SYSTEM_STATS_DAYS, SYSTEM_STATS_TTL_MS, WeekFoldCache, assembleSnapshot, buildNeeds, buildClis, buildGovernance, diskRow, estateReadonlyCall, infraRow, judgeGaps, livenessThresholds, loadRow, probeBroker, probeBus, probeEstate, probeInteractive, probeVault, powerWaitOf, readBridgeLockAsync, readWeek, runLiveness, settleWithin, skillsRow, sortRuns, stateHomeRow, reposRow, unfinished, } from './system-snapshot.js';
|
|
174
179
|
import { CLUSTER_TIMEOUT_MS, ClusterStatusReader, clusterDiagnostics, clusterRows } from './cluster-status.js';
|
|
175
180
|
import { deliveryRow, readDeliveryReadiness } from '../setup/delivery-readiness.js';
|
|
176
181
|
import { idleClis, probeSeatImages, SeatImageRebuilder, seatImageStatusVia } from './seat-images.js';
|
|
177
182
|
import { RunCostCache } from './needs.js';
|
|
178
183
|
import { governanceStoreFix, legacyHomeOutboxPath } from '../core/governance-store.js';
|
|
179
184
|
import { UsageError, replayOutboxInto } from '../cli/governance.js';
|
|
185
|
+
import { DEFAULT_DAEMON_PORT } from '../cli/port.js';
|
|
186
|
+
import { startOnLoginStatus } from './start-on-login.js';
|
|
180
187
|
import { foldDeadletters } from './governance-health.js';
|
|
181
188
|
import { RetryIndex } from './retry-index.js';
|
|
182
189
|
import { SEAT_RECORD_DEFAULT_DAYS, SEAT_RECORD_MAX_DAYS, seatRecord } from './seat-record.js';
|
|
@@ -206,10 +213,11 @@ import { ingestDecision } from '../decisions/ingest.js';
|
|
|
206
213
|
import { registerDecisionRoutes } from '../decisions/routes.js';
|
|
207
214
|
import { ChatDecisionRecorder } from '../decisions/chat-recorder.js';
|
|
208
215
|
import { ConsiderationService } from '../decisions/consider.js';
|
|
209
|
-
import {
|
|
216
|
+
import { engineConformance, gardenPackCheck } from '../editors/pack-install.js';
|
|
210
217
|
import { conformanceProvisioner, conformanceRuntimeReady, conformanceRuntimeRoot, conformanceVenvDir, editorPluginLaunchListener, venvPython } from '../editors/conformance-runtime.js';
|
|
211
218
|
import { EditorRegistry } from '../editors/registry.js';
|
|
212
219
|
import { registerEditorRoutes, unitTokenProbe } from '../editors/routes.js';
|
|
220
|
+
import { broadcast } from '../events/bus.js';
|
|
213
221
|
import { AppWritePath } from '../apps/actions/write-path.js';
|
|
214
222
|
import { AppExecutor } from '../apps/exec/executor.js';
|
|
215
223
|
import { localViewerOf } from '../apps/exec/viewer.js';
|
|
@@ -286,6 +294,28 @@ export class LaunchReply {
|
|
|
286
294
|
return this;
|
|
287
295
|
}
|
|
288
296
|
}
|
|
297
|
+
/** Keep correctable launch refusals typed, and preserve error codes in other launch failures. */
|
|
298
|
+
/**
|
|
299
|
+
* (crew#1442, coord on #1734) A held run's source pick, for a reshape that keeps it. A pick that can't be read (its
|
|
300
|
+
* store entry gone and the launch trail not read at boot) refuses the launch, 409 `sources_unavailable`, rather than
|
|
301
|
+
* launch it as if the held run had no pick.
|
|
302
|
+
*/
|
|
303
|
+
export function heldSourcePick(picks, runId) {
|
|
304
|
+
try {
|
|
305
|
+
return picks.get(runId);
|
|
306
|
+
}
|
|
307
|
+
catch (err) {
|
|
308
|
+
throw jobRefusal(409, { code: 'sources_unavailable', error: `the held run's source pick could not be read: ${message(err)}` });
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
export function jobRefusal(status, payload) {
|
|
312
|
+
const b = payload;
|
|
313
|
+
if (status >= 400 && status < 500 && typeof b?.code === 'string') {
|
|
314
|
+
return new LaunchRefusal(status, b);
|
|
315
|
+
}
|
|
316
|
+
const error = typeof b?.error === 'string' ? b.error : 'The launch was refused.';
|
|
317
|
+
return new Error(`${error}${typeof b?.code === 'string' ? ` (${b.code})` : ''}`);
|
|
318
|
+
}
|
|
289
319
|
/**
|
|
290
320
|
* Turns a failed parse into a 400 body, naming any field the schema does not know.
|
|
291
321
|
*
|
|
@@ -397,6 +427,9 @@ function shapeMemoryItem(raw) {
|
|
|
397
427
|
// the surface date-filters on. Absent on an item the store did not stamp; never fabricated.
|
|
398
428
|
if (typeof r['created_at'] === 'number')
|
|
399
429
|
item.created_at = r['created_at'];
|
|
430
|
+
// crew#1697: a retired row (`memory.list {retired: true}`) carries when it was retired.
|
|
431
|
+
if (typeof r['retired_at'] === 'number')
|
|
432
|
+
item.retired_at = r['retired_at'];
|
|
400
433
|
return item;
|
|
401
434
|
}
|
|
402
435
|
/** Shape the estate `memory.coverage` result (`{ total, by_tier, by_kind }`) into the wire
|
|
@@ -415,7 +448,7 @@ function shapeMemoryCoverage(raw) {
|
|
|
415
448
|
const RULE_SEVERITIES = new Set(['info', 'warn', 'error', 'critical']);
|
|
416
449
|
const RULE_TYPES = new Set(['pattern', 'policy']);
|
|
417
450
|
const RULE_STATUSES = new Set(['active', 'retired', 'all']);
|
|
418
|
-
// Repo names become directory components under
|
|
451
|
+
// Repo names become directory components under the state-home-derived repos root — reject anything
|
|
419
452
|
// that would allow path traversal (slashes, dots-only segments, control chars).
|
|
420
453
|
const SAFE_REPO_NAME = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
|
|
421
454
|
/** `PUT /repos/:id/requirements/minimum` (api-types 0.197.0 `RequirementsMinimumBody`): `null` clears. */
|
|
@@ -428,7 +461,7 @@ export const RegisterRepoSchema = z.strictObject({
|
|
|
428
461
|
.regex(SAFE_REPO_NAME, 'Repository name must start with a letter/digit and contain only letters, digits, dots, hyphens, and underscores'),
|
|
429
462
|
// For local registration: path to an existing git repo on disk.
|
|
430
463
|
// For remote clone: optional clone destination (absolute path); if omitted,
|
|
431
|
-
// defaults to
|
|
464
|
+
// defaults to the state-home-derived repos root plus <name>.
|
|
432
465
|
rootPath: z.string().optional(),
|
|
433
466
|
gitUrl: z.string().optional(),
|
|
434
467
|
/** crew#496: the project the register form had selected — the onboarding run is filed there
|
|
@@ -793,9 +826,23 @@ const InjectSchema = z.strictObject({
|
|
|
793
826
|
* thread says "You (by voice)". It grants nothing a typed note does not. */
|
|
794
827
|
input: z.literal('voice').optional(),
|
|
795
828
|
});
|
|
829
|
+
/** (crew#1392) Most characters of a dock steer's words its `run.injected` audit line keeps. */
|
|
830
|
+
export const INJECT_WORDS_MAX = 2_000;
|
|
831
|
+
/** A dock steer's words as the audit line keeps them: at most {@link INJECT_WORDS_MAX} characters, never half a pair. */
|
|
832
|
+
export function injectWords(message) {
|
|
833
|
+
if (message.length <= INJECT_WORDS_MAX)
|
|
834
|
+
return message;
|
|
835
|
+
let end = INJECT_WORDS_MAX;
|
|
836
|
+
const last = message.charCodeAt(end - 1);
|
|
837
|
+
if (last >= 0xd800 && last <= 0xdbff)
|
|
838
|
+
end -= 1;
|
|
839
|
+
return message.slice(0, end);
|
|
840
|
+
}
|
|
841
|
+
export const ResumeSchema = z.strictObject({ ord: z.int().nonnegative().optional() });
|
|
796
842
|
// The manual reassign lever (crew#442): `cli` omitted lets the engine's council re-pick, the
|
|
797
843
|
// same shape the automatic stall-watchdog escalation uses for an unknown failover target.
|
|
798
844
|
const ReassignSchema = z.strictObject({
|
|
845
|
+
ord: z.int().nonnegative().optional(),
|
|
799
846
|
cli: z.string().min(1).optional(),
|
|
800
847
|
/** crew#1153: an operator note that rides a GATED reassign as the approve's amendment. Trimmed in
|
|
801
848
|
* the route; blank counts as absent. The byte cap (on the raw note) is checked there too so the 400 names the limit. */
|
|
@@ -832,10 +879,19 @@ export const RetireMemorySchema = z.strictObject({
|
|
|
832
879
|
scope_prefix: z.string(),
|
|
833
880
|
});
|
|
834
881
|
/** `POST /memory/retire-item` body (studio#206): ONE memory, by its `memory_id` from `GET /memory`.
|
|
835
|
-
* `.strict()`: a stray `scope_prefix` is a 400, never read as a wider erase than one row.
|
|
882
|
+
* `.strict()`: a stray `scope_prefix` is a 400, never read as a wider erase than one row. The same body
|
|
883
|
+
* names the one memory for `POST /memory/erase-item` and `POST /memory/unretire` (crew#1697). */
|
|
836
884
|
export const RetireMemoryItemSchema = z.strictObject({
|
|
837
885
|
memory_id: z.string().min(1).max(512),
|
|
838
886
|
});
|
|
887
|
+
/** `POST /knowledge/forget` body (crew#1697): estate `knowledge.forget`'s own arguments. Exactly one target is
|
|
888
|
+
* checked at the route (a 400 before any spawn); `.strict()`: an unknown field is a 400. */
|
|
889
|
+
export const ForgetKnowledgeSchema = z.strictObject({
|
|
890
|
+
id: z.string().optional(),
|
|
891
|
+
source: z.string().optional(),
|
|
892
|
+
scope_prefix: z.string().optional(),
|
|
893
|
+
confirm_erase_all: z.boolean().optional(),
|
|
894
|
+
});
|
|
839
895
|
/** `POST /memory/edit` body (wicked-studio's Memory page): ONE memory's new words. `.strict()`: an
|
|
840
896
|
* unknown field is a 400, never read as something wider than one memory. */
|
|
841
897
|
export const EditMemorySchema = z.strictObject({
|
|
@@ -855,6 +911,30 @@ const memoryEditsInFlight = new Set();
|
|
|
855
911
|
/** The error an estate from before wicked-estate#188 answers to `memory.erase {id}`: it knows only the
|
|
856
912
|
* subtree erase, so it refuses the call (deleting nothing) for want of a `scope_prefix`. */
|
|
857
913
|
const ESTATE_NO_ERASE_BY_ID = /scope_prefix \(non-empty\) required/i;
|
|
914
|
+
/** crew#1697: how an estate without a tool refuses it. Before wicked-estate#552/#553 `memory.retire`,
|
|
915
|
+
* `memory.unretire` and `knowledge.forget` are unknown tools (-32602 "unknown tool: …"); a memory implementer
|
|
916
|
+
* without retirement answers -32601 "… does not support retirement" / "… retirement is unsupported". Either way
|
|
917
|
+
* nothing was changed. A domain whose store did not open (-32601 "memory domain not available: <why>") is NOT
|
|
918
|
+
* this: it stays a 502 with its own words (codex review). */
|
|
919
|
+
const estateLacksTool = (err) => err instanceof EstateMcpError &&
|
|
920
|
+
((err.code === -32602 && /unknown tool/i.test(err.message)) ||
|
|
921
|
+
(err.code === -32601 && /does not support retirement|retirement is unsupported/i.test(err.message)));
|
|
922
|
+
/** crew#1697: the count a one-memory estate tool answered (`deleted_count`, `retired_count`, `restored_count`):
|
|
923
|
+
* 0 or 1. Any other answer is estate misbehaving, thrown as an upstream fault (502). */
|
|
924
|
+
function oneMemoryCount(raw, tool, key) {
|
|
925
|
+
const n = typeof raw === 'object' && raw !== null ? raw[key] : undefined;
|
|
926
|
+
if (typeof n !== 'number')
|
|
927
|
+
throw new EstateMcpError(`${tool} returned an unexpected shape`);
|
|
928
|
+
if (n !== 0 && n !== 1)
|
|
929
|
+
throw new EstateMcpError(`${tool} {id} changed ${n} memories, expected 1`);
|
|
930
|
+
return n;
|
|
931
|
+
}
|
|
932
|
+
/** crew#1697: the 501 body for an estate that lacks a tool. */
|
|
933
|
+
function estateUpgrade(what, estatePr, unchanged) {
|
|
934
|
+
return { error: `this wicked-estate ${what} (it needs wicked-estate${estatePr}); upgrade wicked-estate-mcp — ${unchanged}`, code: 'estate_upgrade_required' };
|
|
935
|
+
}
|
|
936
|
+
/** crew#1697: estate's `knowledge.forget` refusing a target (live-source structure named by id): a conflict, not a fault. */
|
|
937
|
+
const ESTATE_FORGET_REFUSED = /knowledge\.forget refused/i;
|
|
858
938
|
/**
|
|
859
939
|
* A SKIN-OWNED settings key (crew#323): one lowercase segment under the `studio.` namespace,
|
|
860
940
|
* e.g. `studio.appearance`, `studio.notifications`. The daemon never interprets these values —
|
|
@@ -1079,6 +1159,8 @@ runtime = {}) {
|
|
|
1079
1159
|
: {}),
|
|
1080
1160
|
};
|
|
1081
1161
|
const { audit } = security;
|
|
1162
|
+
// crew#1261: who rejected a proposal and why, as crew recorded it (`GET /proposals` returns it on the row).
|
|
1163
|
+
const proposalDecisions = new ProposalDecisionIndex(audit, (m) => app.log.warn(m));
|
|
1082
1164
|
const seatHealth = runtime.seatHealth ?? new SeatHealthTracker();
|
|
1083
1165
|
const deliveryFreeze = runtime.deliveryFreeze ?? new DeliveryFreeze();
|
|
1084
1166
|
registerDeliveryFreezeRoutes(app, { freeze: deliveryFreeze, audit });
|
|
@@ -1110,6 +1192,8 @@ runtime = {}) {
|
|
|
1110
1192
|
const chatTranscripts = runtime.chatTranscripts;
|
|
1111
1193
|
const chatAttachments = runtime.chatAttachments ?? new ChatAttachmentStore();
|
|
1112
1194
|
const chatHistory = runtime.chatHistory ?? (chatTranscripts !== undefined ? new ChatHistoryStore(chatTranscripts, chatAttachments) : null);
|
|
1195
|
+
// crew#1422: beside the history (its own folder: DELETE /chats/:id never removes a record).
|
|
1196
|
+
const seedRequests = chatHistory !== null ? new SeedRequestStore(join(dirname(chatHistory.dir), 'seed-requests')) : null;
|
|
1113
1197
|
// DES-CHAT-ARTIFACTS-001 §14 (A2): what a chat can do with artifacts. Production: `proposals` on, and each operation
|
|
1114
1198
|
// on once its slice registers its launcher (A3 create, A7 theme). The TEST configuration (§13 A2) turns every
|
|
1115
1199
|
// operation's resolution on and registers a recording stub that starts nothing.
|
|
@@ -1128,26 +1212,20 @@ runtime = {}) {
|
|
|
1128
1212
|
'demo',
|
|
1129
1213
|
];
|
|
1130
1214
|
const chatArtifactFlags = chatArtifactsStub
|
|
1131
|
-
? { context: true, proposals: true, create: true, refine: true, theme: true, demo: true, stub: true, stubOps, onboard: true }
|
|
1132
|
-
: { context: true, proposals: true, create: realCreate, refine: realRefine, theme: true, demo: false, onboard: true };
|
|
1215
|
+
? { context: true, instructions: true, proposals: true, create: true, refine: true, theme: true, demo: true, stub: true, stubOps, onboard: true, cutInView: true }
|
|
1216
|
+
: { context: true, instructions: true, proposals: true, create: realCreate, refine: realRefine, theme: true, demo: false, onboard: true, cutInView: true };
|
|
1133
1217
|
const proposalLaunchers = new LaunchOnceRegistry();
|
|
1134
1218
|
proposalLaunchers.register('theme', new ThemeLauncher());
|
|
1135
1219
|
// crew-0182: what an onboard card is resolved and its Go is checked against (one set of reads for both).
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
const out = await execCapped('git', ['-C', rootPath, 'remote', 'get-url', 'origin'], { timeout: 5_000 });
|
|
1139
|
-
return out.stdout.trim() || null;
|
|
1140
|
-
}
|
|
1141
|
-
catch {
|
|
1142
|
-
return null;
|
|
1143
|
-
}
|
|
1144
|
-
};
|
|
1220
|
+
// crew#1744: the one `git_url` reader (GET /repos, the repo search; the daemon hands the review service the same).
|
|
1221
|
+
const repoOrigins = runtime.repoOrigins ?? new RepoOrigins();
|
|
1145
1222
|
const onboardReads = {
|
|
1223
|
+
projects: async () => (await adapter.projectList()).filter((p) => p.id !== DEFAULT_PROJECT_ID && p.status !== 'archived').map((p) => ({ id: p.id, name: p.name })),
|
|
1146
1224
|
repos: () => adapter.listRepos(),
|
|
1147
1225
|
projectRepoRefs: async (projectId) => (await adapter.projectMembers(projectId)).filter((m) => m.member_kind === 'crew.repo').map((m) => m.member_ref),
|
|
1148
|
-
checkoutOf: (name) => homeless(
|
|
1226
|
+
checkoutOf: (name) => homeless(join(wickedWorkRoot('repos'), name)),
|
|
1149
1227
|
occupant: async (name) => {
|
|
1150
|
-
const dir =
|
|
1228
|
+
const dir = join(wickedWorkRoot('repos'), name);
|
|
1151
1229
|
if (!existsSync(join(dir, '.git')))
|
|
1152
1230
|
return existsSync(dir) ? '' : null;
|
|
1153
1231
|
return (await originOf(dir)) ?? '';
|
|
@@ -1158,6 +1236,8 @@ runtime = {}) {
|
|
|
1158
1236
|
proposalLaunchers.register('onboard', new OnboardLauncher({
|
|
1159
1237
|
...onboardReads,
|
|
1160
1238
|
sessions: () => adapter.sessions(),
|
|
1239
|
+
// crew#1694: the one project create, as `POST /projects` makes it (bus event, audit line, charter).
|
|
1240
|
+
createProject: async (name, actor) => createProjectRecorded(adapter, projects, audit, actor, { name }),
|
|
1161
1241
|
register: (data, ctx) => registerAndOnboard(data, { actor: ctx.actor, runId: ctx.runId, gitProtocols: CHAT_GIT_PROTOCOLS, log: { warn: (o, m) => app.log.warn(o, m) } }),
|
|
1162
1242
|
attach: async (projectId, repoId, actor) => {
|
|
1163
1243
|
await attachRepoToProject(adapter, projects, { projectId, repoId, actor, attachedBy: 'studio' });
|
|
@@ -1223,6 +1303,7 @@ runtime = {}) {
|
|
|
1223
1303
|
const deliveryCache = runtime.deliveryCache ??
|
|
1224
1304
|
new DeliveryDerivationCache({
|
|
1225
1305
|
listViews: () => adapter.sessionsDetail(),
|
|
1306
|
+
viewOf: (id) => adapter.runView(id),
|
|
1226
1307
|
probes: vacuityProbes,
|
|
1227
1308
|
isDelivered: (runId) => deliveryIndex.isDelivered(runId),
|
|
1228
1309
|
canDeliver,
|
|
@@ -1302,8 +1383,9 @@ runtime = {}) {
|
|
|
1302
1383
|
registerEditorRoutes(app, {
|
|
1303
1384
|
registry: editorRegistry,
|
|
1304
1385
|
adapter,
|
|
1386
|
+
broadcast,
|
|
1305
1387
|
packCheck: runtime.packCheck ?? gardenPackCheck(discoverLivePlugin()?.path ?? null),
|
|
1306
|
-
conformance: runtime.editorConformance ??
|
|
1388
|
+
conformance: runtime.editorConformance ?? engineConformance({ provision: editorConformanceRuntime }),
|
|
1307
1389
|
// F37: the grant write's §6.4 tripwire asks the engine whether a bearer is a governed unit's token.
|
|
1308
1390
|
...(() => {
|
|
1309
1391
|
const probe = runtime.editorUnitTokenProbe !== undefined ? runtime.editorUnitTokenProbe : unitTokenProbe(CoreAdapter.estateScopeResolver());
|
|
@@ -1328,6 +1410,7 @@ runtime = {}) {
|
|
|
1328
1410
|
? new AppExecutor({
|
|
1329
1411
|
store: runtime.apps,
|
|
1330
1412
|
registry: runtime.mcp ?? null,
|
|
1413
|
+
visibleSources: runtime.appsVisibleSources,
|
|
1331
1414
|
...(appsKnowledge !== undefined ? { knowledge: appsKnowledge } : {}),
|
|
1332
1415
|
projectOf: (slug) => runtime.apps.projectOf(slug),
|
|
1333
1416
|
crewInject: async (r) => {
|
|
@@ -1343,6 +1426,8 @@ runtime = {}) {
|
|
|
1343
1426
|
store: runtime.apps,
|
|
1344
1427
|
actions: runtime.appsActions,
|
|
1345
1428
|
registry: runtime.mcp ?? null,
|
|
1429
|
+
visibleSources: runtime.appsVisibleSources,
|
|
1430
|
+
projectOf: (slug) => runtime.apps.projectOf(slug),
|
|
1346
1431
|
audit,
|
|
1347
1432
|
viewerOf: runtime.appsViewerOf ?? localViewerOf,
|
|
1348
1433
|
...(appsExecutor !== undefined ? { executor: appsExecutor } : {}),
|
|
@@ -1359,6 +1444,8 @@ runtime = {}) {
|
|
|
1359
1444
|
return JSON.stringify(launchRosterNaming(rosterWithStanding({ launch: true }), undefined));
|
|
1360
1445
|
},
|
|
1361
1446
|
registry: runtime.mcp ?? null,
|
|
1447
|
+
visibleSources: runtime.appsVisibleSources,
|
|
1448
|
+
projectOf: (slug) => runtime.apps.projectOf(slug),
|
|
1362
1449
|
grantOf: (slug, action) => appsWritePath?.getGrant(slug, action) ?? null,
|
|
1363
1450
|
},
|
|
1364
1451
|
...(appsExecutor !== undefined ? { executor: appsExecutor } : {}),
|
|
@@ -1381,6 +1468,18 @@ runtime = {}) {
|
|
|
1381
1468
|
: null;
|
|
1382
1469
|
/** Repo root for a repo ref, from the registry — shared by the reprovision path below. */
|
|
1383
1470
|
const repoRootOf = async (repoRef) => (await adapter.listRepos()).find((r) => r.id === repoRef)?.root_path;
|
|
1471
|
+
/** (crew#1792) The push identity a repository's PR reads run as: its pin or the setting, else `GH_ACCOUNT` (the
|
|
1472
|
+
* deliver-target route's own resolution). Settings that cannot be read leave it to `GH_ACCOUNT`. */
|
|
1473
|
+
const readIdentityOf = (repoRef) => async () => {
|
|
1474
|
+
let configured = '';
|
|
1475
|
+
try {
|
|
1476
|
+
configured = deliverIdentityFor(await adapter.getSettings(), repoRef).login;
|
|
1477
|
+
}
|
|
1478
|
+
catch {
|
|
1479
|
+
configured = '';
|
|
1480
|
+
}
|
|
1481
|
+
return pushIdentityOf(configured);
|
|
1482
|
+
};
|
|
1384
1483
|
/** The lookups a review-change exclusion reads (the launch and the job proposal read the same ones, CJ13). */
|
|
1385
1484
|
const reviewChangeDeps = (repoRef, repoRoot) => ({
|
|
1386
1485
|
repoRef,
|
|
@@ -1390,20 +1489,24 @@ runtime = {}) {
|
|
|
1390
1489
|
pushed: (id) => deliveryIndex.pushedFor(id),
|
|
1391
1490
|
deliveredCommit: (id) => deliveryIndex.commitFor(id),
|
|
1392
1491
|
revisesPr: (id) => retryIndex.revisesPrFor(id),
|
|
1393
|
-
gh: runtime.reviewChange?.gh ?? defaultGhExec,
|
|
1394
|
-
|
|
1492
|
+
gh: pinnedGhExec(readIdentityOf(repoRef), runtime.reviewChange?.gh ?? defaultGhExec),
|
|
1493
|
+
// crew#1804: a branch or commit target's fetch runs as the deliver identity too, like the deliver script's `_gnet`.
|
|
1494
|
+
git: pinnedGitExec(readIdentityOf(repoRef), runtime.reviewChange?.git ?? (async (args, cwd, env) => {
|
|
1395
1495
|
try {
|
|
1396
|
-
return { ...(await execCapped('git', args, { cwd, timeout: 5_000 })), code: 0 };
|
|
1496
|
+
return { ...(await execCapped('git', args, { cwd, timeout: 5_000, ...(env !== undefined ? { env: { ...process.env, ...env } } : {}) })), code: 0 };
|
|
1397
1497
|
}
|
|
1398
1498
|
catch (err) {
|
|
1399
1499
|
// Only exit 1 proves non-membership; preserve it separately from lookup failures.
|
|
1400
1500
|
const code = err.code;
|
|
1401
1501
|
return { code: typeof code === 'number' ? code : null, stdout: '', stderr: message(err) };
|
|
1402
1502
|
}
|
|
1403
|
-
}),
|
|
1503
|
+
}), runtime.reviewChange?.gh ?? defaultGhExec),
|
|
1404
1504
|
});
|
|
1405
|
-
/** DES-L9: PR number → head branch, through `gh pr view`
|
|
1406
|
-
|
|
1505
|
+
/** DES-L9: PR number → head branch, through `gh pr view` as the repository's push identity (crew#1792) unless the
|
|
1506
|
+
* runtime injected an answerer. */
|
|
1507
|
+
const resolvePullRequest = (repoRoot, number, repoRef) => runtime.resolvePullRequest !== undefined
|
|
1508
|
+
? runtime.resolvePullRequest(repoRoot, number)
|
|
1509
|
+
: resolvePullRequestViaGh(repoRoot, number, pinnedGhExec(readIdentityOf(repoRef)));
|
|
1407
1510
|
/** crew#627: the intent's linked issues, read under the daemon's identity at launch. */
|
|
1408
1511
|
/** (DES-PM-001 §3.2) A project's live `crew.repo` members, for a tracker set. */
|
|
1409
1512
|
const repoMembersOf = async (projectId) => (await adapter.projectMembers(projectId)).filter((m) => m.member_kind === 'crew.repo').map((m) => m.member_ref);
|
|
@@ -1510,6 +1613,11 @@ runtime = {}) {
|
|
|
1510
1613
|
};
|
|
1511
1614
|
const decorateRun = (view) => {
|
|
1512
1615
|
const conflictStrand = normalizeStranded(view);
|
|
1616
|
+
const powerWait = powerWaitOf(view.session);
|
|
1617
|
+
if (powerWait !== null)
|
|
1618
|
+
view.session.person_needed = powerWait;
|
|
1619
|
+
else
|
|
1620
|
+
delete view.session.person_needed;
|
|
1513
1621
|
// Seam X2: what the run IS — the adapter attaches it from the engine's record; a view from a
|
|
1514
1622
|
// directly-driven adapter gets it resolved from its record here, so it is always served.
|
|
1515
1623
|
view.session.run_identity = wireIdentity(runIdentityOf(view));
|
|
@@ -1560,6 +1668,13 @@ runtime = {}) {
|
|
|
1560
1668
|
view.session.launch_actor = launchActor;
|
|
1561
1669
|
const state = resolveDelivery(view, conflictStrand);
|
|
1562
1670
|
view.session.delivery = state.delivery;
|
|
1671
|
+
// crew#1667: read only the authored card (core#686); descriptions include operator intent.
|
|
1672
|
+
const authorUnit = view.units.find(isDeliverUnit);
|
|
1673
|
+
const deliverAuthor = authorUnit?.instructions === undefined ? undefined : deliverAuthorOf(authorUnit.instructions);
|
|
1674
|
+
if (deliverAuthor !== undefined)
|
|
1675
|
+
view.session.deliverAuthor = deliverAuthor;
|
|
1676
|
+
else
|
|
1677
|
+
delete view.session.deliverAuthor;
|
|
1563
1678
|
// wicked-core#850 EX-04: a post-hoc delivery reads unverified, with its trees. ABSENT otherwise.
|
|
1564
1679
|
const deliveryAssurance = deliveryIndex.assuranceFor(view.session.id);
|
|
1565
1680
|
if (deliveryAssurance !== undefined)
|
|
@@ -1718,7 +1833,7 @@ runtime = {}) {
|
|
|
1718
1833
|
// boundary, are named before any run starts.
|
|
1719
1834
|
...(() => {
|
|
1720
1835
|
const gov = seatGovernanceSnapshot();
|
|
1721
|
-
return seatGovernanceWarnings(gov.diagnostics, hostSandboxLauncher(), gov.workEligible);
|
|
1836
|
+
return [...seatGovernanceWarnings(gov.diagnostics, hostSandboxLauncher(), gov.workEligible), ...gov.imageFindings];
|
|
1722
1837
|
})(),
|
|
1723
1838
|
// crew 0.15.2 (#916): a custom seat written council-off with no work flag is now work-eligible
|
|
1724
1839
|
// by the engine default; each is named once, so the operator can keep it off work.
|
|
@@ -1727,23 +1842,39 @@ runtime = {}) {
|
|
|
1727
1842
|
...[adapter.vaultBin != null ? vaultBinWarning(adapter.vaultBin) : null].filter((w) => w !== null),
|
|
1728
1843
|
];
|
|
1729
1844
|
// crew#1157: the engine's built-in presets are compiled in, so the chat workflows it carries are
|
|
1730
|
-
// read once
|
|
1845
|
+
// read once and held until restart. crew#1767: the read is an actor round trip, so it starts here,
|
|
1846
|
+
// at registration (the first probe usually finds it held), at most one is in flight, and `/health`
|
|
1847
|
+
// waits for it only inside the ping's own bound: a probe while the actor is busy answers `[]` (the
|
|
1848
|
+
// engine's answer is not known yet) and a later probe answers the held list. A failed read is
|
|
1849
|
+
// dropped, so the next probe reads again.
|
|
1731
1850
|
let chatWorkflowsHeld = null;
|
|
1732
|
-
|
|
1851
|
+
let chatWorkflowsRead = null;
|
|
1852
|
+
const chatWorkflowsLoad = () => {
|
|
1733
1853
|
if (chatWorkflowsHeld !== null)
|
|
1734
|
-
return chatWorkflowsHeld;
|
|
1854
|
+
return Promise.resolve(chatWorkflowsHeld);
|
|
1735
1855
|
if (typeof adapter.listPresets !== 'function')
|
|
1736
|
-
return [];
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
}
|
|
1856
|
+
return Promise.resolve([]);
|
|
1857
|
+
chatWorkflowsRead ??= Promise.resolve()
|
|
1858
|
+
.then(() => adapter.listPresets())
|
|
1859
|
+
.then((presets) => (chatWorkflowsHeld = servedChatWorkflows(presets)))
|
|
1860
|
+
.catch(() => [])
|
|
1861
|
+
.finally(() => {
|
|
1862
|
+
chatWorkflowsRead = null;
|
|
1863
|
+
});
|
|
1864
|
+
return chatWorkflowsRead;
|
|
1744
1865
|
};
|
|
1866
|
+
void chatWorkflowsLoad();
|
|
1745
1867
|
app.get(`${V}/health`, { config: { manifest: { statusCodes: [200] } } }, async () => {
|
|
1868
|
+
const deadline = performance.now() + HEALTH_PING_WAIT_MS;
|
|
1869
|
+
const workflowsRead = chatWorkflowsLoad();
|
|
1746
1870
|
const ping = await enginePing();
|
|
1871
|
+
let chatWorkflowsTimer;
|
|
1872
|
+
const chatWorkflows = await Promise.race([
|
|
1873
|
+
workflowsRead,
|
|
1874
|
+
new Promise((resolve) => {
|
|
1875
|
+
chatWorkflowsTimer = setTimeout(() => resolve([]), Math.max(0, deadline - performance.now()));
|
|
1876
|
+
}),
|
|
1877
|
+
]).finally(() => clearTimeout(chatWorkflowsTimer));
|
|
1747
1878
|
// F-E2E-030: what this deployment can keep. A composer reads `capabilities.deliverGate`
|
|
1748
1879
|
// before it promises "pauses at the deliver gate"; a stub-driven route set without the
|
|
1749
1880
|
// probe honestly reports no gate.
|
|
@@ -1784,7 +1915,7 @@ runtime = {}) {
|
|
|
1784
1915
|
chatAttachments: true,
|
|
1785
1916
|
// api-types 0.141.0 (crew#1157): the read-only workflows `POST /chats {workflow}` runs on THIS
|
|
1786
1917
|
// engine (`analyze` on a core-ts that carries it); `[]` = plain chats only.
|
|
1787
|
-
chatWorkflows
|
|
1918
|
+
chatWorkflows,
|
|
1788
1919
|
// api-types 0.145.0: the evals, insights and schedules surfaces, read off the route table this
|
|
1789
1920
|
// daemon serves, so a route set booted without one says false rather than an invented true.
|
|
1790
1921
|
defaultEvals: app.hasRoute({ method: 'GET', url: `${V}/testing/default-evals/suites` }),
|
|
@@ -1813,6 +1944,9 @@ runtime = {}) {
|
|
|
1813
1944
|
chatJobProposals: chatJobProposalsOn,
|
|
1814
1945
|
chatJobPower: chatJobProposalsOn,
|
|
1815
1946
|
reshapeRun: chatJobProposalsOn,
|
|
1947
|
+
// crew#1697: soft retire + restore on the Memory page, forget on the Knowledge page.
|
|
1948
|
+
memoryRestore: app.hasRoute({ method: 'POST', url: `${V}/memory/unretire` }),
|
|
1949
|
+
knowledgeForget: app.hasRoute({ method: 'POST', url: `${V}/knowledge/forget` }),
|
|
1816
1950
|
// (api-types 0.169.0, DES-CHAT-ARTIFACTS-001 §14) Per operation: A1 serves `context` (the chat sees the open
|
|
1817
1951
|
// artifact and the runs the person names; `seedFromArtifact`); A2 (0.170.0) `proposals`. The operations are later
|
|
1818
1952
|
// slices (all on, with `stub`, in the test configuration).
|
|
@@ -1894,6 +2028,7 @@ runtime = {}) {
|
|
|
1894
2028
|
governanceDiagnostics.health(),
|
|
1895
2029
|
floorCacheCache.get(),
|
|
1896
2030
|
]);
|
|
2031
|
+
const seatGovernance = seatGovernanceSnapshot();
|
|
1897
2032
|
const uptimeMs = Math.round(process.uptime() * 1000);
|
|
1898
2033
|
const addr = app.server.address();
|
|
1899
2034
|
const port = typeof addr === 'object' && addr !== null ? addr.port : 7701;
|
|
@@ -1930,9 +2065,10 @@ runtime = {}) {
|
|
|
1930
2065
|
seatGovernance: {
|
|
1931
2066
|
rosterFile: seatRosterFile(),
|
|
1932
2067
|
hostBoundary: hostSandboxLauncher(),
|
|
1933
|
-
seats:
|
|
2068
|
+
seats: seatGovernance.diagnostics,
|
|
1934
2069
|
// The same `seat.work_default` findings `/health.warnings` carries (api-types 0.133.0).
|
|
1935
2070
|
roleFindings: seatWorkDefaultNow(),
|
|
2071
|
+
imageFindings: seatGovernance.imageFindings,
|
|
1936
2072
|
},
|
|
1937
2073
|
// crew#740: which memory store this daemon reads and writes, and the isolation notice.
|
|
1938
2074
|
memoryStore: memoryStoreInfo(),
|
|
@@ -2034,11 +2170,14 @@ runtime = {}) {
|
|
|
2034
2170
|
const roster = rosterWithStanding();
|
|
2035
2171
|
return {
|
|
2036
2172
|
diagnostics: seatGovernanceDiagnostics(roster),
|
|
2173
|
+
imageFindings: roster.filter((seat) => seat.seat_image_unavailable !== undefined).map((seat) => ({
|
|
2174
|
+
kind: 'seat.image_unavailable', severity: 'warning', message: `${seat.display_name ?? seat.key}: ${seat.seat_image_unavailable}`,
|
|
2175
|
+
})),
|
|
2037
2176
|
workEligible: new Set(roster.filter((seat) => seat.seat_eligible_for_work !== false).map((seat) => String(seat.key))),
|
|
2038
2177
|
};
|
|
2039
2178
|
}
|
|
2040
2179
|
catch {
|
|
2041
|
-
return { diagnostics: [], workEligible: new Set() };
|
|
2180
|
+
return { diagnostics: [], workEligible: new Set(), imageFindings: [] };
|
|
2042
2181
|
}
|
|
2043
2182
|
};
|
|
2044
2183
|
/**
|
|
@@ -2443,8 +2582,46 @@ runtime = {}) {
|
|
|
2443
2582
|
return diffError(err);
|
|
2444
2583
|
}
|
|
2445
2584
|
});
|
|
2446
|
-
|
|
2447
|
-
|
|
2585
|
+
const maintenanceDrainBody = (err) => ({ code: err.code, error: err.message, hint: err.hint });
|
|
2586
|
+
const MaintenanceSchema = z.strictObject({ drain: z.boolean() });
|
|
2587
|
+
app.get(`${V}/maintenance`, { config: { manifest: { responseType: 'MaintenanceState', statusCodes: [200] } } }, async () => adapter.maintenanceState());
|
|
2588
|
+
app.post(`${V}/maintenance`, { config: { manifest: { requestType: 'MaintenanceRequest', responseType: 'MaintenanceState', statusCodes: [200, 400] } } }, async (req, reply) => {
|
|
2589
|
+
const parsed = MaintenanceSchema.safeParse(req.body);
|
|
2590
|
+
if (!parsed.success)
|
|
2591
|
+
return reply.code(400).send(invalidBody(parsed.error, 'Invalid request body'));
|
|
2592
|
+
const body = parsed.data;
|
|
2593
|
+
adapter.setDraining(body.drain);
|
|
2594
|
+
return adapter.maintenanceState();
|
|
2595
|
+
});
|
|
2596
|
+
// Registered repos → target-repo picker. Each carries `git_url` (studio#1012: the repo page's "This repository"
|
|
2597
|
+
// tracker row reads it), through the daemon's one origin reader (repo-origins.ts, crew#1744): the review's issue
|
|
2598
|
+
// link and the repo search read the same.
|
|
2599
|
+
app.get(`${V}/repos`, async () => ({ repos: await repoOrigins.list(() => adapter.listRepos()) }));
|
|
2600
|
+
app.delete(`${V}/repos/:id`, { config: { manifest: { responseType: 'UnregisterRepoResponse', statusCodes: [200, 404, 409, 501] } } }, async (req, reply) => {
|
|
2601
|
+
const { id } = req.params;
|
|
2602
|
+
const runIds = (await adapter.sessionsDetail())
|
|
2603
|
+
.filter((v) => v.session.repo_ref === id && !TERMINAL_RUN_STATUSES.has(v.session.status))
|
|
2604
|
+
.map((v) => v.session.id);
|
|
2605
|
+
if (runIds.length > 0)
|
|
2606
|
+
return reply.code(409).send({ code: 'repo_in_use', error: `Repository ${id} is held by non-terminal runs: ${runIds.join(', ')}`, runIds });
|
|
2607
|
+
if (!(await adapter.listRepos()).some((r) => r.id === id))
|
|
2608
|
+
return reply.code(404).send({ code: 'repo_not_found' });
|
|
2609
|
+
try {
|
|
2610
|
+
if (!(await adapter.unregisterRepo(id)))
|
|
2611
|
+
return reply.code(404).send({ code: 'repo_not_found' });
|
|
2612
|
+
audit.record('repo.unregistered', actorOf(req), { detail: { repoId: id } });
|
|
2613
|
+
return { repoId: id, removed: true };
|
|
2614
|
+
}
|
|
2615
|
+
catch (err) {
|
|
2616
|
+
if (err instanceof RepoUnregisterUnsupportedError)
|
|
2617
|
+
return reply.code(501).send({ code: 'repo_unregister_unsupported', error: message(err) });
|
|
2618
|
+
// The engine's refusal names the runs or projects in its text (a lease taken after crew's check, or a project).
|
|
2619
|
+
const refused = /^(repo_in_use|repo_in_project): /u.exec(message(err));
|
|
2620
|
+
if (refused !== null)
|
|
2621
|
+
return reply.code(409).send({ code: refused[1], error: message(err) });
|
|
2622
|
+
throw err;
|
|
2623
|
+
}
|
|
2624
|
+
});
|
|
2448
2625
|
/** Filing for an onboarding run: what `POST /runs` does for a launch, for the runs `POST /repos`
|
|
2449
2626
|
* and `POST /repos/:id/onboard` start (crew#496). The launch entry (`run.launched`, which dates
|
|
2450
2627
|
* the run and names who started it) is always written; with a `projectId` the run joins that
|
|
@@ -2528,7 +2705,7 @@ runtime = {}) {
|
|
|
2528
2705
|
let runId;
|
|
2529
2706
|
try {
|
|
2530
2707
|
if (gitUrl) {
|
|
2531
|
-
// Remote: clone to rootPath (if provided) or
|
|
2708
|
+
// Remote: clone to rootPath (if provided) or the state-home-derived repos root,
|
|
2532
2709
|
// register, and launch onboarding run.
|
|
2533
2710
|
repo = ctx.gitProtocols !== undefined
|
|
2534
2711
|
? await adapter.cloneAndRegister(name, gitUrl, rootPath, { allowProtocols: ctx.gitProtocols })
|
|
@@ -2672,6 +2849,18 @@ runtime = {}) {
|
|
|
2672
2849
|
const p = chatScopes.get(chatId)?.projectId ?? chatHistory?.stateOf(chatId)?.projectId ?? null;
|
|
2673
2850
|
return p === null || p === DEFAULT_PROJECT_ID ? null : p;
|
|
2674
2851
|
};
|
|
2852
|
+
/** crew#1429: a run's staged documents folder goes with the run (a refused launch, an archive). Logged, never fatal:
|
|
2853
|
+
* the run's own outcome stands. */
|
|
2854
|
+
const freeStagedDocuments = (runId, archived) => {
|
|
2855
|
+
if (runtime.runDocumentsRoot === undefined)
|
|
2856
|
+
return;
|
|
2857
|
+
try {
|
|
2858
|
+
removeStagedDocuments(runId, runtime.runDocumentsRoot, archived);
|
|
2859
|
+
}
|
|
2860
|
+
catch (err) {
|
|
2861
|
+
app.log.warn(`[runs] staged documents of ${runId} not removed: ${message(err)}`);
|
|
2862
|
+
}
|
|
2863
|
+
};
|
|
2675
2864
|
/**
|
|
2676
2865
|
* (CS4) The documents an earlier run was given, to be authorised and staged again for its retry: its tokens and chat
|
|
2677
2866
|
* from its staged manifest, hash-checked. `null` = it had none; `'unreadable'` = it had some that can't be read back.
|
|
@@ -2679,6 +2868,8 @@ runtime = {}) {
|
|
|
2679
2868
|
const stagedTokensOf = (runId, root) => {
|
|
2680
2869
|
const staged = stagedDocumentsOf(runId, root);
|
|
2681
2870
|
if (staged === null) {
|
|
2871
|
+
if (stagedDocumentsRemoved(runId, root))
|
|
2872
|
+
return 'removed';
|
|
2682
2873
|
try {
|
|
2683
2874
|
readFileSync(join(root, runId, 'records', 'MANIFEST.json'));
|
|
2684
2875
|
}
|
|
@@ -2911,8 +3102,6 @@ runtime = {}) {
|
|
|
2911
3102
|
}
|
|
2912
3103
|
if (b.repoRef === undefined)
|
|
2913
3104
|
return reply.code(400).send({ error: 'review-change needs repoRef' });
|
|
2914
|
-
deliver = 'none';
|
|
2915
|
-
delete input.deliver;
|
|
2916
3105
|
const root = await repoRootOf(b.repoRef);
|
|
2917
3106
|
if (root === undefined)
|
|
2918
3107
|
return reply.code(404).send({ error: `repoRef names an unknown repo: ${b.repoRef}` });
|
|
@@ -2987,7 +3176,7 @@ runtime = {}) {
|
|
|
2987
3176
|
if (root === undefined) {
|
|
2988
3177
|
return reply.code(404).send({ error: `repoRef names an unknown repo: ${revisedRepo}` });
|
|
2989
3178
|
}
|
|
2990
|
-
const resolved = await resolvePullRequest(root, b.revisesPr);
|
|
3179
|
+
const resolved = await resolvePullRequest(root, b.revisesPr, revisedRepo);
|
|
2991
3180
|
if (!resolved.ok)
|
|
2992
3181
|
return reply.code(409).send({ error: resolved.error });
|
|
2993
3182
|
revisesPr = { number: b.revisesPr, headRef: resolved.pr.headRef, url: resolved.pr.url };
|
|
@@ -3010,7 +3199,15 @@ runtime = {}) {
|
|
|
3010
3199
|
// retry or reshape that sends none keeps the earlier run's pick; a run without a pick reads what the switches allow.
|
|
3011
3200
|
let sourcePick = null;
|
|
3012
3201
|
// An inherited pick is checked like a sent one (the switches may have changed since the earlier run).
|
|
3013
|
-
|
|
3202
|
+
let wantedPick;
|
|
3203
|
+
try {
|
|
3204
|
+
wantedPick = b.sources ?? (b.retryOf !== undefined ? (runtime.runSourcePicks?.get(b.retryOf) ?? undefined) : undefined);
|
|
3205
|
+
}
|
|
3206
|
+
catch (err) {
|
|
3207
|
+
// (crew#1442, coord on #1734) The earlier run's pick can't be read (its store entry is gone and the launch trail
|
|
3208
|
+
// was not read at boot): refused, never launched as if it had no pick.
|
|
3209
|
+
return reply.code(409).send({ code: 'sources_unavailable', error: `the earlier run's source pick could not be read: ${message(err)}` });
|
|
3210
|
+
}
|
|
3014
3211
|
if (wantedPick !== undefined) {
|
|
3015
3212
|
if (runtime.runSourcePicks === undefined || runtime.dataGate === undefined) {
|
|
3016
3213
|
return reply.code(400).send({ code: 'sources_refused', error: 'this daemon cannot limit a run to picked sources' });
|
|
@@ -3062,12 +3259,17 @@ runtime = {}) {
|
|
|
3062
3259
|
// only (a named workflow or an explicit plan); best-effort: an unreadable store launches without it.
|
|
3063
3260
|
const briefRules = async (workflow) => {
|
|
3064
3261
|
try {
|
|
3262
|
+
// wicked-crew#1706: the registered checkout root lets the engine judge pack fit from the repo's manifests;
|
|
3263
|
+
// an unreadable registry leaves it unknown (the rule still matches, as before).
|
|
3264
|
+
const repoRoot = b.repoRef !== undefined ? await repoRootOf(b.repoRef).catch(() => undefined) : undefined;
|
|
3065
3265
|
const read = await considerations.inForceFor(b.projectId ?? null);
|
|
3066
3266
|
const def = workflow === null ? null : adapter.getWorkflow(workflow);
|
|
3067
3267
|
const kinds = def === null ? null : def.phases.map((p) => String(p.kind ?? 'build'));
|
|
3068
3268
|
const rules = read.source === 'unavailable' ? [] : read.rules;
|
|
3069
3269
|
// (coord, E7 rerun) The job's repository: a rule that names it (its statement or its source doc) applies.
|
|
3070
|
-
const job = { workflow, steps: null, kinds, project: b.projectId ?? null, repo: b.repoRef ?? null
|
|
3270
|
+
const job = { workflow, steps: null, kinds, project: b.projectId ?? null, repo: b.repoRef ?? null,
|
|
3271
|
+
...(repoRoot !== undefined ? { repoRoot } : {}),
|
|
3272
|
+
};
|
|
3071
3273
|
const matches = await matchRulesForJob(rules, job, runtime.matchRules ?? CoreAdapter.ruleMatcher(), (m) => req.log.warn(m));
|
|
3072
3274
|
const briefed = withRulesBrief(input.problem, rules, matches);
|
|
3073
3275
|
input.problem = briefed.problem;
|
|
@@ -3099,8 +3301,11 @@ runtime = {}) {
|
|
|
3099
3301
|
// crew#825: an all-excluded intent appends nothing but still answers what it left out.
|
|
3100
3302
|
if (linked.issues.length > 0)
|
|
3101
3303
|
linkedIssues = linked.issues;
|
|
3102
|
-
if (linked.addresses !== undefined && linked.addresses.length > 0)
|
|
3304
|
+
if (linked.addresses !== undefined && linked.addresses.length > 0) {
|
|
3103
3305
|
linkedAddresses = linked.addresses;
|
|
3306
|
+
// crew#1352: known before the engine is called, so the deliver script's embedded fallback links them back.
|
|
3307
|
+
input.trackerRefs = linked.addresses.map((a) => ({ system: a.system, ref: a.ref, ...(a.asked !== undefined ? { asked: a.asked } : {}) }));
|
|
3308
|
+
}
|
|
3104
3309
|
}
|
|
3105
3310
|
catch (err) {
|
|
3106
3311
|
req.log.warn(`linked-issue resolution failed; launching on the intent alone: ${message(err)}`);
|
|
@@ -3133,12 +3338,14 @@ runtime = {}) {
|
|
|
3133
3338
|
// the evals in-process and writes the report copy its Tool step reads; it delivers nothing.
|
|
3134
3339
|
if (b.workflow === RUN_EVALS_WORKFLOW) {
|
|
3135
3340
|
try {
|
|
3136
|
-
|
|
3341
|
+
// (crew#1375) A card launch scores what its card asks for: Evaluate rules the steering suite, and a card that takes
|
|
3342
|
+
// a project input (Evaluate rules, Analyze runs) the project the launch is filed in. A launch with no shape (a
|
|
3343
|
+
// schedule, `/workflow-run-evals`) scores every suite and project.
|
|
3344
|
+
await runEvalsPrepare(input, runEvalsScopeOf(shapeChecked?.shape.card ?? null, b.projectId ?? null));
|
|
3137
3345
|
}
|
|
3138
3346
|
catch (err) {
|
|
3139
3347
|
return reply.code(409).send({ error: `the default evals could not be prepared: ${message(err)}` });
|
|
3140
3348
|
}
|
|
3141
|
-
deliver = 'none';
|
|
3142
3349
|
}
|
|
3143
3350
|
const isReview = b.workflow !== undefined && reviewPrepared(b.workflow);
|
|
3144
3351
|
if (isReview) {
|
|
@@ -3146,16 +3353,31 @@ runtime = {}) {
|
|
|
3146
3353
|
await runtime.reviewLaunch(input);
|
|
3147
3354
|
}
|
|
3148
3355
|
catch (err) {
|
|
3356
|
+
// (crew#1375) No seat that ran none of the reviewed work: the review-change refusal's shape, so a chat job's Start
|
|
3357
|
+
// offers reduced assurance.
|
|
3358
|
+
if (err instanceof NoIndependentReviewer) {
|
|
3359
|
+
return reply.code(409).send({ code: err.code, error: `the review could not be prepared: ${err.message}`, excluded: err.excluded, retryWith: { reducedAssurance: true } });
|
|
3360
|
+
}
|
|
3149
3361
|
return reply.code(409).send({ error: `the review could not be prepared: ${message(err)}` });
|
|
3150
3362
|
}
|
|
3363
|
+
}
|
|
3364
|
+
// (crew#1375) Every refusal from here to the engine call leaves a prepared review that never ran: it is recorded as
|
|
3365
|
+
// refused, so a retry under the same run id (a chat job's Go) prepares it again instead of being refused.
|
|
3366
|
+
const refuse = (code, body) => {
|
|
3367
|
+
if (isReview)
|
|
3368
|
+
runtime.reviewLaunchRefused?.(input.sessionId, body.error);
|
|
3369
|
+
return reply.code(code).send(body);
|
|
3370
|
+
};
|
|
3371
|
+
if (b.workflow !== undefined && postureFacts.preparationDropsDelivery(b.workflow)) {
|
|
3151
3372
|
deliver = 'none';
|
|
3373
|
+
delete input.deliver;
|
|
3152
3374
|
}
|
|
3153
3375
|
// DES-CHAT-ARTIFACTS-001 §4.3 (A3): one live job per chat, work and artifact runs together. A work launch filed under
|
|
3154
3376
|
// a chat whose proposal's document attempt has no outcome yet is refused, as Go is refused the other way round.
|
|
3155
3377
|
if (b.chatId !== undefined && chatArtifactFlags.proposals) {
|
|
3156
3378
|
const live = await chatProposals.liveJobOf(b.chatId).catch(() => null);
|
|
3157
3379
|
if (live !== null)
|
|
3158
|
-
return
|
|
3380
|
+
return refuse(409, { code: 'chat_busy', error: `This chat already has a job running (${live}). Wait, or stop that run.` });
|
|
3159
3381
|
}
|
|
3160
3382
|
// DES-CATALOG-002 §4.4 (codex r1): the effective resolution a shape was judged by is read again right before the
|
|
3161
3383
|
// engine resolves the preset, so a preset saved during this launch's awaits refuses it rather than running a shape
|
|
@@ -3164,11 +3386,11 @@ runtime = {}) {
|
|
|
3164
3386
|
try {
|
|
3165
3387
|
const again = checkLaunchShape(shapeChecked.shape, shapeChecked.target, await servedFor(shapeReads, b.projectId));
|
|
3166
3388
|
if (!again.ok || again.resolved.resolved.resolution !== shapeChecked.resolution) {
|
|
3167
|
-
return
|
|
3389
|
+
return refuse(409, { code: 'catalog_changed', error: 'the catalog changed while this was starting; check the job again' });
|
|
3168
3390
|
}
|
|
3169
3391
|
}
|
|
3170
3392
|
catch (err) {
|
|
3171
|
-
return
|
|
3393
|
+
return refuse(409, { code: 'catalog_unavailable', error: message(err) });
|
|
3172
3394
|
}
|
|
3173
3395
|
}
|
|
3174
3396
|
// (CS4) The pick is recorded before anything is staged and before the engine is called, so no unit of the run ever
|
|
@@ -3178,7 +3400,7 @@ runtime = {}) {
|
|
|
3178
3400
|
runtime.runSourcePicks.set(input.sessionId, sourcePick);
|
|
3179
3401
|
}
|
|
3180
3402
|
catch (err) {
|
|
3181
|
-
return
|
|
3403
|
+
return refuse(409, { code: 'sources_unavailable', error: `the source pick could not be recorded: ${message(err)}` });
|
|
3182
3404
|
}
|
|
3183
3405
|
}
|
|
3184
3406
|
// (DES-CATALOG-002 §2.d piece 2, CS4) The documents: every token authorised again with the chat's own rules (this
|
|
@@ -3195,8 +3417,11 @@ runtime = {}) {
|
|
|
3195
3417
|
}
|
|
3196
3418
|
else if (b.retryOf !== undefined && runtime.runDocumentsRoot !== undefined) {
|
|
3197
3419
|
const earlier = stagedTokensOf(b.retryOf, runtime.runDocumentsRoot);
|
|
3420
|
+
if (earlier === 'removed') {
|
|
3421
|
+
return refuse(409, { code: 'documents_unavailable', error: `the documents of run ${b.retryOf} were removed when it was archived; start the job again from its chat` });
|
|
3422
|
+
}
|
|
3198
3423
|
if (earlier === 'unreadable') {
|
|
3199
|
-
return
|
|
3424
|
+
return refuse(409, { code: 'documents_unavailable', error: `the documents of run ${b.retryOf} can't be read again; start the job again from its chat` });
|
|
3200
3425
|
}
|
|
3201
3426
|
if (earlier !== null)
|
|
3202
3427
|
docTokens = earlier;
|
|
@@ -3207,7 +3432,7 @@ runtime = {}) {
|
|
|
3207
3432
|
const runProject = b.projectId !== undefined && b.projectId !== DEFAULT_PROJECT_ID ? b.projectId : null;
|
|
3208
3433
|
if ((chatProject ?? null) !== runProject) {
|
|
3209
3434
|
// A bare retry sends no projectId: it is filed Unfiled, so it is told where its documents belong (fail closed).
|
|
3210
|
-
return
|
|
3435
|
+
return refuse(400, {
|
|
3211
3436
|
code: 'documents_refused',
|
|
3212
3437
|
error: chatProject !== null && runProject === null
|
|
3213
3438
|
? `the documents belong to project ${chatProject}: file this run there (send projectId)`
|
|
@@ -3233,21 +3458,23 @@ runtime = {}) {
|
|
|
3233
3458
|
}
|
|
3234
3459
|
catch (err) {
|
|
3235
3460
|
if (err instanceof DocumentsRefused) {
|
|
3236
|
-
return
|
|
3461
|
+
return refuse(400, {
|
|
3237
3462
|
code: 'documents_refused',
|
|
3238
3463
|
error: `can't read ${err.refused.map((r) => `${r.token} (${r.reason})`).join(', ')}`,
|
|
3239
3464
|
refused: err.refused,
|
|
3240
3465
|
});
|
|
3241
3466
|
}
|
|
3242
|
-
return
|
|
3467
|
+
return refuse(409, { code: 'documents_unavailable', error: `the documents could not be staged: ${message(err)}` });
|
|
3243
3468
|
}
|
|
3244
3469
|
}
|
|
3245
3470
|
if (staged !== null) {
|
|
3246
3471
|
input.extraReadRoots = [...(input.extraReadRoots ?? []), staged.root];
|
|
3247
3472
|
input.problem = `${input.problem.trimEnd()}\n\n${documentsClause(staged)}`;
|
|
3248
3473
|
}
|
|
3474
|
+
let launched = false;
|
|
3249
3475
|
try {
|
|
3250
3476
|
const runId = await adapter.launchRun(input);
|
|
3477
|
+
launched = true;
|
|
3251
3478
|
// crew#641/#642 (item 5): when a run is promoted from a chat, record how many seats
|
|
3252
3479
|
// participated and whether the chat was grounded — so an intent authored by a single
|
|
3253
3480
|
// ungrounded model is distinguishable from one that survived a disagreement.
|
|
@@ -3315,6 +3542,12 @@ runtime = {}) {
|
|
|
3315
3542
|
...(b.actor !== undefined ? { actor: b.actor } : {}),
|
|
3316
3543
|
// crew#627: which linked issues the daemon read into the problem, and which it could not.
|
|
3317
3544
|
...(linkedIssues !== undefined ? { linkedIssues } : {}),
|
|
3545
|
+
// crew#1352: the issues the run addresses, as its tracker set resolved them. The trail is the durable record for
|
|
3546
|
+
// the run's lifetime (the tracker-addresses store is a bounded cache, and its write may fail); the run-timing
|
|
3547
|
+
// index reads them back, live and after a restart.
|
|
3548
|
+
...(linkedAddresses !== undefined ? { trackerAddresses: linkedAddresses } : {}),
|
|
3549
|
+
// crew#1442: the run's source pick, so a pick store that loses the run still narrows it (fail closed).
|
|
3550
|
+
...(sourcePick !== null ? { sourcePick } : {}),
|
|
3318
3551
|
// DES-CATALOG-002 §4.4: the shape it was launched as, what it was launched with, and the proposal behind it.
|
|
3319
3552
|
...(b.shape !== undefined ? { shape: launchShapeOf(b.shape) } : {}),
|
|
3320
3553
|
...(ctx.fromProposal !== undefined ? { fromProposal: ctx.fromProposal } : {}),
|
|
@@ -3344,10 +3577,7 @@ runtime = {}) {
|
|
|
3344
3577
|
if (chatSeatCount !== undefined && chatGrounded !== undefined) {
|
|
3345
3578
|
runTimingIndex.setChatPromotion(runId, chatSeatCount, chatGrounded);
|
|
3346
3579
|
}
|
|
3347
|
-
|
|
3348
|
-
retryIndex.set(runId, b.retryOf);
|
|
3349
|
-
if (revisesPr !== undefined)
|
|
3350
|
-
retryIndex.setRevisesPr(runId, revisesPr);
|
|
3580
|
+
retryIndex.applyLaunchEntry(runId, { retryOf: b.retryOf, revisesPr });
|
|
3351
3581
|
// (DES-PM-001 §3.2, §4) The issues this run addresses, as its tracker set resolved them: delivery links them
|
|
3352
3582
|
// back, the deliver gate's actions are offered for them, and the projection draws the trail.
|
|
3353
3583
|
if (linkedAddresses !== undefined && runtime.trackerAddresses !== undefined) {
|
|
@@ -3395,16 +3625,22 @@ runtime = {}) {
|
|
|
3395
3625
|
const skillsWarning = skillsAhead === null ? {} : { skillsWarning: { kind: skillsAhead.kind, severity: skillsAhead.severity, message: skillsAhead.message } };
|
|
3396
3626
|
// wicked-core#850: a full-assurance run on a one-CLI roster will wait at a gate for a seat that
|
|
3397
3627
|
// can evaluate or judge it; the answer names the explicit opt-in to relaunch with.
|
|
3398
|
-
const notice = launchAssuranceNotice({ runId, reducedAssurance: b.reducedAssurance,
|
|
3628
|
+
const notice = launchAssuranceNotice({ runId, reducedAssurance: b.reducedAssurance, coverage: readJudgeCoverage(engineRosterJson(input.clisJson), input.repoRef !== undefined, runtime.judgeCoverage ?? CoreAdapter.judgeCoverage) });
|
|
3399
3629
|
const assuranceNotice = notice === null ? {} : { assuranceNotice: notice };
|
|
3400
3630
|
// (program DES-POWER-MODE) Whether the run is in power mode, and why not when it was wanted.
|
|
3401
3631
|
const power = { ...(input.power === true ? { power: true } : {}), ...(powerNotice !== null ? { powerNotice } : {}), ...(humanConfirmNotice !== null ? { humanConfirmNotice } : {}) };
|
|
3402
3632
|
return reply.code(201).send({ runId, ...(linkedIssues !== undefined ? { linkedIssues } : {}), ...freeText, ...skillsWarning, ...assuranceNotice, ...power });
|
|
3403
3633
|
}
|
|
3404
3634
|
catch (err) {
|
|
3635
|
+
if (!launched && staged?.published === true)
|
|
3636
|
+
freeStagedDocuments(input.sessionId, false);
|
|
3405
3637
|
const msg = message(err);
|
|
3406
|
-
|
|
3638
|
+
// (crew#1375, xreview r1) Only a launch the engine never took is a refused review: a failure after launchRun
|
|
3639
|
+
// resolved leaves the review running, so a retry under its run id can never clear a real review.
|
|
3640
|
+
if (isReview && !launched)
|
|
3407
3641
|
runtime.reviewLaunchRefused?.(input.sessionId, msg);
|
|
3642
|
+
if (err instanceof MaintenanceDrainError)
|
|
3643
|
+
return reply.code(503).send(maintenanceDrainBody(err));
|
|
3408
3644
|
// DES-TEAMING-002 T3: a plan on an engine without the plan approval gate is an "upgrade the
|
|
3409
3645
|
// engine" 501 — never a free-text run launched in its place.
|
|
3410
3646
|
if (err instanceof PlanLaunchUnsupportedError) {
|
|
@@ -3474,11 +3710,15 @@ runtime = {}) {
|
|
|
3474
3710
|
// existing run; 422: the base-skill intake refusal (`base_skill_refused`, crew#554);
|
|
3475
3711
|
// 501: campaignId attach on an engine addon without the campaign bindings ("upgrade
|
|
3476
3712
|
// the engine").
|
|
3477
|
-
statusCodes: [201, 400, 404, 409, 422, 501],
|
|
3713
|
+
statusCodes: [201, 400, 404, 409, 422, 501, 503],
|
|
3478
3714
|
},
|
|
3479
3715
|
},
|
|
3480
3716
|
}, async (req, reply) => {
|
|
3481
|
-
const
|
|
3717
|
+
const launch = () => launchRun(req.body, { actor: actorOf(req), log: req.log });
|
|
3718
|
+
const parsed = LaunchSchema.safeParse(req.body);
|
|
3719
|
+
const out = parsed.success && parsed.data.chatId !== undefined
|
|
3720
|
+
? await chatProposals.admitChat(parsed.data.chatId, launch)
|
|
3721
|
+
: await launch();
|
|
3482
3722
|
return reply.code(out.statusCode).send(out.payload);
|
|
3483
3723
|
});
|
|
3484
3724
|
// (studio#1150) What a launch of this body would keep of its human gates — the SAME `launchPosture` decision
|
|
@@ -3515,16 +3755,6 @@ runtime = {}) {
|
|
|
3515
3755
|
};
|
|
3516
3756
|
return { posture };
|
|
3517
3757
|
});
|
|
3518
|
-
/**
|
|
3519
|
-
* (DES-CATALOG-002 §4.6) The `job` launcher: a chat job proposal's Go, one launcher per launch kind, each with the
|
|
3520
|
-
* identity derived from the proposal (`sessionId` = its run id, so a retry finds and adopts it), the chat filing, the
|
|
3521
|
-
* shape, and the plan held: a job launched from a chat stops at its first plan unless the person's Start chose a
|
|
3522
|
-
* power run (`power: true`, api-types 0.196.0), which is refused unless this daemon can run that job as one.
|
|
3523
|
-
*/
|
|
3524
|
-
const jobRefusalText = (payload) => {
|
|
3525
|
-
const b = payload;
|
|
3526
|
-
return `${typeof b?.error === 'string' ? b.error : 'the launch was refused'}${typeof b?.code === 'string' ? ` (${b.code})` : ''}`;
|
|
3527
|
-
};
|
|
3528
3758
|
/**
|
|
3529
3759
|
* (operator ruling 2026-11-06) Why a chat job can't run as a power run on this daemon now, else `null`: only a
|
|
3530
3760
|
* workflow run on a repository whose workflow is a preset, on an engine with power mode (launchRun's own rule, which
|
|
@@ -3564,12 +3794,16 @@ runtime = {}) {
|
|
|
3564
3794
|
return `${p.what.label} can't run as a power run (its workflow is not a preset); ${askPlan}`;
|
|
3565
3795
|
return null;
|
|
3566
3796
|
};
|
|
3797
|
+
/**
|
|
3798
|
+
* (DES-CATALOG-002 §4.6) The `job` launcher: a chat job proposal's Go, one launcher per launch kind, each with the
|
|
3799
|
+
* identity derived from the proposal (`sessionId` = its run id, so a retry finds and adopts it), the chat filing, the
|
|
3800
|
+
* shape, and the plan held: a job launched from a chat stops at its first plan unless the person's Start chose a
|
|
3801
|
+
* power run (`power: true`, api-types 0.196.0), which is refused unless this daemon can run that job as one.
|
|
3802
|
+
*/
|
|
3567
3803
|
proposalLaunchers.register('job', {
|
|
3568
3804
|
find: async (identity) => (await adapter.sessions()).includes(identity.runId),
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
return v !== undefined && !['completed', 'cancelled', 'failed'].includes(String(v.session.status));
|
|
3572
|
-
},
|
|
3805
|
+
// crew#1779: read off the check's one run list, never one engine read per job.
|
|
3806
|
+
live: liveInRuns,
|
|
3573
3807
|
launch: async (d) => {
|
|
3574
3808
|
const p = d.resolution;
|
|
3575
3809
|
if (p.shape === undefined || p.catalogRev === undefined)
|
|
@@ -3611,7 +3845,7 @@ runtime = {}) {
|
|
|
3611
3845
|
...(projectId !== null && projectId !== DEFAULT_PROJECT_ID ? { projectId } : {}),
|
|
3612
3846
|
...common,
|
|
3613
3847
|
// (CS4) The documents and the source pick, as tokens and names (never flattened into the brief's prose).
|
|
3614
|
-
...jobInputsOfProposal(p, runtime.runSourcePicks !== undefined ? (runId) => runtime.runSourcePicks
|
|
3848
|
+
...jobInputsOfProposal(p, runtime.runSourcePicks !== undefined ? (runId) => heldSourcePick(runtime.runSourcePicks, runId) : undefined),
|
|
3615
3849
|
// A power run when the person's Start chose one (checked against this daemon just now); otherwise it
|
|
3616
3850
|
// stops at its first plan, as every chat job did before (operator ruling 2026-11-06).
|
|
3617
3851
|
// (A power launch overrides the plan hold; launchRun refuses rather than run it phased, `powerRequired`.)
|
|
@@ -3622,9 +3856,11 @@ runtime = {}) {
|
|
|
3622
3856
|
...(p.relaunch?.deliver !== undefined ? { deliver: p.relaunch.deliver } : {}),
|
|
3623
3857
|
...(p.relaunch?.deliverGate !== undefined && p.relaunch.deliver !== 'none' ? { deliverGate: p.relaunch.deliverGate } : {}),
|
|
3624
3858
|
...(p.relaunch?.revisesPr !== undefined && p.relaunch.deliver === 'pr' && p.repoRefs?.[0] !== undefined ? { revisesPr: p.relaunch.revisesPr } : {}),
|
|
3859
|
+
// (crew#1840) A job asked to change a pull request this chat delivered updates it: no second PR.
|
|
3860
|
+
...jobRevisionLaunch(p),
|
|
3625
3861
|
}, { ...ctx, fromProposal: d.pid, ...(d.power === true ? { powerRequired: true } : {}) });
|
|
3626
3862
|
if (out.statusCode !== 201)
|
|
3627
|
-
throw
|
|
3863
|
+
throw jobRefusal(out.statusCode, out.payload);
|
|
3628
3864
|
return;
|
|
3629
3865
|
}
|
|
3630
3866
|
if (p.launch === 'compose') {
|
|
@@ -3637,7 +3873,7 @@ runtime = {}) {
|
|
|
3637
3873
|
common,
|
|
3638
3874
|
});
|
|
3639
3875
|
if (out.code !== 202)
|
|
3640
|
-
throw
|
|
3876
|
+
throw jobRefusal(out.code, out.body);
|
|
3641
3877
|
return;
|
|
3642
3878
|
}
|
|
3643
3879
|
if (p.launch === 'demo') {
|
|
@@ -3654,7 +3890,7 @@ runtime = {}) {
|
|
|
3654
3890
|
common,
|
|
3655
3891
|
}, demoDeps);
|
|
3656
3892
|
if (out.code !== 201)
|
|
3657
|
-
throw
|
|
3893
|
+
throw jobRefusal(out.code, out.body);
|
|
3658
3894
|
return;
|
|
3659
3895
|
}
|
|
3660
3896
|
throw new Error(`a ${p.launch} job does not start from a chat`);
|
|
@@ -3730,6 +3966,8 @@ runtime = {}) {
|
|
|
3730
3966
|
const found = await adapter.archiveRun(id, parsed.data.archived, parsed.data.note);
|
|
3731
3967
|
if (!found)
|
|
3732
3968
|
return reply.code(404).send({ error: 'Run not found' });
|
|
3969
|
+
if (parsed.data.archived)
|
|
3970
|
+
freeStagedDocuments(id, true);
|
|
3733
3971
|
return { runId: id, archived: parsed.data.archived };
|
|
3734
3972
|
}
|
|
3735
3973
|
catch (e) {
|
|
@@ -3786,6 +4024,7 @@ runtime = {}) {
|
|
|
3786
4024
|
const found = await adapter.archiveRun(id, true, note);
|
|
3787
4025
|
if (!found)
|
|
3788
4026
|
return { code: 404, body: { error: 'Run not found' } };
|
|
4027
|
+
freeStagedDocuments(id, true);
|
|
3789
4028
|
}
|
|
3790
4029
|
catch (e) {
|
|
3791
4030
|
const msg = e instanceof Error ? e.message : String(e);
|
|
@@ -3813,6 +4052,8 @@ runtime = {}) {
|
|
|
3813
4052
|
for (const id of parsed.data.ids) {
|
|
3814
4053
|
try {
|
|
3815
4054
|
const found = await adapter.archiveRun(id, true, parsed.data.note);
|
|
4055
|
+
if (found)
|
|
4056
|
+
freeStagedDocuments(id, true);
|
|
3816
4057
|
results.push(found ? { id, ok: true } : { id, ok: false, error: 'not found' });
|
|
3817
4058
|
}
|
|
3818
4059
|
catch (e) {
|
|
@@ -4133,7 +4374,7 @@ runtime = {}) {
|
|
|
4133
4374
|
const revisedRoot = await repoRootOf(repoRef);
|
|
4134
4375
|
const again = revisedRoot === undefined
|
|
4135
4376
|
? { ok: false, error: `repo ${repoRef} is no longer registered — cannot re-check pull request #${revising.number}` }
|
|
4136
|
-
: await resolvePullRequest(revisedRoot, revising.number);
|
|
4377
|
+
: await resolvePullRequest(revisedRoot, revising.number, repoRef);
|
|
4137
4378
|
if (!again.ok) {
|
|
4138
4379
|
revisionRefused = again.error;
|
|
4139
4380
|
return;
|
|
@@ -4380,7 +4621,7 @@ runtime = {}) {
|
|
|
4380
4621
|
requestType: 'ChatOpenBody',
|
|
4381
4622
|
responseType: 'ChatOpenResponse',
|
|
4382
4623
|
// 200: a seeded retry answers the chat its request already opened (api-types 0.192.0).
|
|
4383
|
-
statusCodes: [200, 201, 400, 403, 404, 409, 500, 501],
|
|
4624
|
+
statusCodes: [200, 201, 400, 403, 404, 409, 410, 500, 501],
|
|
4384
4625
|
},
|
|
4385
4626
|
},
|
|
4386
4627
|
}, async (req, reply) => {
|
|
@@ -4396,6 +4637,8 @@ runtime = {}) {
|
|
|
4396
4637
|
if (b.seed !== undefined) {
|
|
4397
4638
|
if (!chatJobProposalsOn)
|
|
4398
4639
|
return reply.code(400).send({ error: 'this daemon does not take job proposals from a chat' });
|
|
4640
|
+
if (chatHistory === null)
|
|
4641
|
+
return reply.code(501).send({ error: 'this daemon keeps no chat history for a seeded request' });
|
|
4399
4642
|
seedActor = actorOf(req);
|
|
4400
4643
|
if (!isHumanOperator(seedActor)) {
|
|
4401
4644
|
audit.record('chat.proposal.refused', seedActor, { detail: { reason: 'not_a_person', what: 'seed' } });
|
|
@@ -4405,23 +4648,24 @@ runtime = {}) {
|
|
|
4405
4648
|
if (bad !== null)
|
|
4406
4649
|
return reply.code(400).send({ code: 'card_unknown', error: bad });
|
|
4407
4650
|
seedChatId = proposalRunId(`seed\u0000${seedActor.id}\u0000${b.requestId}`);
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
if (view !== null && view.proposal.request?.digest !== requestDigest(seedBody(b.seed, b.requestId))) {
|
|
4416
|
-
return reply.code(409).send({ code: 'request_reused', error: 'this requestId already started a chat with another job', chatId: seedChatId });
|
|
4651
|
+
const record = seedRequests.get(seedChatId);
|
|
4652
|
+
if (record !== null) {
|
|
4653
|
+
const id = chatHistory.idOfInstance(seedChatId, record.instance);
|
|
4654
|
+
if (id === null)
|
|
4655
|
+
return reply.code(410).send({ code: 'chat_gone', error: 'the chat this request opened was deleted' });
|
|
4656
|
+
if (record.digest !== requestDigest(seedBody(b.seed, b.requestId))) {
|
|
4657
|
+
return reply.code(409).send({ code: 'request_reused', error: 'this requestId already started a chat with another job', chatId: id });
|
|
4417
4658
|
}
|
|
4659
|
+
const stored = chatProposals.viewOfPid(id, personPid(seedChatId, seedActor.id, b.requestId));
|
|
4660
|
+
let view = stored === null ? null : await chatProposals.servedView(stored);
|
|
4661
|
+
const open = id === seedChatId && (askPaths.get(id) !== undefined || chatScopes.get(id) !== undefined);
|
|
4418
4662
|
if (view === null && open) {
|
|
4419
|
-
const seeded = await seedProposal(
|
|
4663
|
+
const seeded = await seedProposal(id, b.seed, b.requestId, seedActor);
|
|
4420
4664
|
if ('refused' in seeded)
|
|
4421
|
-
return reply.code(409).send({ ...seeded.refused, chatId:
|
|
4665
|
+
return reply.code(409).send({ ...seeded.refused, chatId: id });
|
|
4422
4666
|
view = seeded.view;
|
|
4423
4667
|
}
|
|
4424
|
-
return reply.code(200).send({ chatId:
|
|
4668
|
+
return reply.code(200).send({ chatId: id, seats: [], scope: open ? chatScopes.get(id) ?? null : null, refused: [], ...(view !== null ? { proposal: view } : {}), adopted: true });
|
|
4425
4669
|
}
|
|
4426
4670
|
}
|
|
4427
4671
|
const chatId = seedChatId ?? b.chatId ?? randomUUID();
|
|
@@ -4766,6 +5010,19 @@ runtime = {}) {
|
|
|
4766
5010
|
catch (err) {
|
|
4767
5011
|
req.log.warn({ chatId }, `chat history entry not written: ${message(err)}`);
|
|
4768
5012
|
}
|
|
5013
|
+
// crew#1422: the instance this request opened, so a retry answers that chat and never another one under the id.
|
|
5014
|
+
// A failure here is logged, never thrown into an open that already published the chat.
|
|
5015
|
+
if (b.seed !== undefined && seedActor !== null) {
|
|
5016
|
+
const state = chatHistory?.stateOf(chatId) ?? null;
|
|
5017
|
+
try {
|
|
5018
|
+
if (state === null)
|
|
5019
|
+
throw new Error('no history entry');
|
|
5020
|
+
seedRequests.set(chatId, { instance: state.instance, digest: requestDigest(seedBody(b.seed, b.requestId)), actorId: seedActor.id, at: Date.now() });
|
|
5021
|
+
}
|
|
5022
|
+
catch (err) {
|
|
5023
|
+
req.log.warn({ chatId }, `seed request not recorded (a retry of it cannot find this chat): ${message(err)}`);
|
|
5024
|
+
}
|
|
5025
|
+
}
|
|
4769
5026
|
// The thread learns of every refused seat the way it learns of everything else — a frame
|
|
4770
5027
|
// on /ws — AFTER the scope is published, so a reader never sees a refusal for a chat it
|
|
4771
5028
|
// cannot yet look up.
|
|
@@ -4934,7 +5191,57 @@ runtime = {}) {
|
|
|
4934
5191
|
analysis: path?.workflow !== undefined,
|
|
4935
5192
|
};
|
|
4936
5193
|
},
|
|
5194
|
+
// studio#1094: the person route owns admission; the open's resolver validates their first repo pick.
|
|
5195
|
+
pickFirstRepo: async (chatId, repoRef, actor, pid) => {
|
|
5196
|
+
const previous = chatScopes.get(chatId);
|
|
5197
|
+
if (previous === undefined)
|
|
5198
|
+
return { ok: false, status: 409, error: CHAT_ENDED };
|
|
5199
|
+
if (previous.repos.length > 0)
|
|
5200
|
+
return { ok: false, status: 409, error: `chat ${chatId} already has a repository in scope` };
|
|
5201
|
+
if (previous.kind === 'everything')
|
|
5202
|
+
return { ok: false, status: 409, error: `chat ${chatId} already reads every registered repository` };
|
|
5203
|
+
const request = {
|
|
5204
|
+
chatId,
|
|
5205
|
+
...(previous.projectId !== undefined ? { projectId: previous.projectId } : {}),
|
|
5206
|
+
repoRefs: [repoRef],
|
|
5207
|
+
};
|
|
5208
|
+
const resolution = await resolveChatScope(request, {
|
|
5209
|
+
...chatScopeDeps(adapter),
|
|
5210
|
+
scratchBase: chatScopes.base,
|
|
5211
|
+
log: (m) => app.log.warn(m),
|
|
5212
|
+
...(runtime.entityCount !== undefined ? { entityCount: runtime.entityCount } : {}),
|
|
5213
|
+
...(runtime.freshenCheckout !== undefined ? { freshen: runtime.freshenCheckout } : {}),
|
|
5214
|
+
});
|
|
5215
|
+
if (!resolution.ok)
|
|
5216
|
+
return { ok: false, status: resolution.status, error: resolution.error };
|
|
5217
|
+
const { scope, engine } = resolution;
|
|
5218
|
+
const rules = (await considerations.inForceFor(scope.projectId ?? null)).rules;
|
|
5219
|
+
// No await from the stale-slot check through the recorded pick.
|
|
5220
|
+
if (chatScopes.get(chatId) !== previous)
|
|
5221
|
+
return { ok: false, status: 409, error: `chat ${chatId}'s scope changed while the repository was being picked; try again` };
|
|
5222
|
+
try {
|
|
5223
|
+
prepareChatScratch(chatId, scope, rules, {
|
|
5224
|
+
analysis: askPaths.get(chatId)?.workflow !== undefined,
|
|
5225
|
+
make: chatProposals.digest(chatId, chatAccepts.get(chatId) === true, { appearance: false }),
|
|
5226
|
+
...voiceFor(scope.projectId),
|
|
5227
|
+
});
|
|
5228
|
+
}
|
|
5229
|
+
catch (err) {
|
|
5230
|
+
return { ok: false, status: 500, error: `cannot prepare the chat's scratch root ${scope.cwd}: ${message(err)}` };
|
|
5231
|
+
}
|
|
5232
|
+
if (!chatScopes.pickFirstRepo(chatId, previous, scope, engine, request))
|
|
5233
|
+
return { ok: false, status: 409, error: `chat ${chatId}'s scope changed while the repository was being picked; try again` };
|
|
5234
|
+
chatTranscripts?.registerRoots(chatId, scope.repos.map((r) => ({ absRoot: resolve(r.rootPath), name: r.name })));
|
|
5235
|
+
askPaths.rescope(chatId, 'scoped_bound');
|
|
5236
|
+
audit.record('chat.scope.repo_picked', actor, { detail: { chatId, pid, repoRef: scope.repos[0].id, from: previous.kind } });
|
|
5237
|
+
return { ok: true, name: scope.repos[0].name };
|
|
5238
|
+
},
|
|
4937
5239
|
rosterEligible: () => proposalRoster(rosterWithStanding()),
|
|
5240
|
+
coverage: (keys, bound, relaunch) => {
|
|
5241
|
+
const p = { seats: { keys: [...keys], lead: keys[0] ?? null, label: '' }, ...(relaunch !== undefined ? { relaunch } : {}) };
|
|
5242
|
+
const { roster } = jobLaunchRoster(launchRosterNaming(rosterWithStanding({ launch: true }), p.seats.lead ?? undefined, keys), p);
|
|
5243
|
+
return readJudgeCoverage(engineRosterJson(JSON.stringify(roster)), bound, runtime.judgeCoverage ?? CoreAdapter.judgeCoverage);
|
|
5244
|
+
},
|
|
4938
5245
|
// (F1/F2) Agents › "Use <seat> for new work": the pool every new chat job and document is drawn from.
|
|
4939
5246
|
newWorkSeats: readNewWorkSeats,
|
|
4940
5247
|
runs: async () => (await adapter.sessionsDetail()).map((v) => decorateRun(v)),
|
|
@@ -5018,7 +5325,7 @@ runtime = {}) {
|
|
|
5018
5325
|
if (root === undefined)
|
|
5019
5326
|
return null;
|
|
5020
5327
|
const ex = await reviewChangeExclusion(words, reviewChangeDeps(repoRef, root));
|
|
5021
|
-
return ex.ok ? ex.excludeSeats : null;
|
|
5328
|
+
return ex.ok ? { seats: ex.excludeSeats, ...(ex.provenance === 'unknown' && ex.why !== undefined ? { unknown: ex.why } : {}) } : null;
|
|
5022
5329
|
},
|
|
5023
5330
|
powerPresets: async (projectId) => {
|
|
5024
5331
|
if (!powerSupported() || ((await adapter.getSettings()).powerModeDefault ?? true) === false || typeof adapter.listPresets !== 'function')
|
|
@@ -5030,7 +5337,6 @@ runtime = {}) {
|
|
|
5030
5337
|
acceptsOnboard: (chatId) => chatAcceptsOnboard.get(chatId) === true,
|
|
5031
5338
|
onboard: {
|
|
5032
5339
|
...onboardReads,
|
|
5033
|
-
projects: async () => (await adapter.projectList()).filter((p) => p.id !== DEFAULT_PROJECT_ID && p.status !== 'archived').map((p) => ({ id: p.id, name: p.name })),
|
|
5034
5340
|
originOf,
|
|
5035
5341
|
probe: (url) => probeGitUrl(url),
|
|
5036
5342
|
// POST /repos's own intake refusal (no garden, an old one, the state home): the card says it before anyone presses.
|
|
@@ -5050,6 +5356,16 @@ runtime = {}) {
|
|
|
5050
5356
|
},
|
|
5051
5357
|
log: (m) => app.log.warn(m),
|
|
5052
5358
|
});
|
|
5359
|
+
/** crew#1669: hidden and unknown chats answer the same 404 under auth: required.
|
|
5360
|
+
* Local mode is unchanged. Sends the 404 and returns true when refused. */
|
|
5361
|
+
const refuseHiddenChat = (req, reply, id) => {
|
|
5362
|
+
if (security.authMode !== 'required')
|
|
5363
|
+
return false;
|
|
5364
|
+
if (chatHistory !== null && chatHistory.visibleTo(id, actorOf(req).id))
|
|
5365
|
+
return false;
|
|
5366
|
+
void reply.code(404).send({ error: `no chat ${id} on this daemon` });
|
|
5367
|
+
return true;
|
|
5368
|
+
};
|
|
5053
5369
|
// F-RECON-017: a message sent while a targeted seat is still answering the previous one is
|
|
5054
5370
|
// REFUSED, not queued. The engine queues silently (the worker gets the text the instant the
|
|
5055
5371
|
// previous turn's final block lands) and its reply frames carry no message correlation, so the
|
|
@@ -5059,6 +5375,8 @@ runtime = {}) {
|
|
|
5059
5375
|
// and the 202 returns the `turnId` the reply frames are stamped with (`turn_id`) on `/ws`.
|
|
5060
5376
|
app.post(`${V}/chats/:id/messages`, async (req, reply) => {
|
|
5061
5377
|
const { id } = req.params;
|
|
5378
|
+
if (refuseHiddenChat(req, reply, id))
|
|
5379
|
+
return reply;
|
|
5062
5380
|
const parsed = ChatMessageSchema.safeParse(req.body);
|
|
5063
5381
|
if (!parsed.success) {
|
|
5064
5382
|
return reply.code(400).send(invalidBody(parsed.error, 'Invalid request body'));
|
|
@@ -5079,9 +5397,8 @@ runtime = {}) {
|
|
|
5079
5397
|
}
|
|
5080
5398
|
const text = parsed.data.text;
|
|
5081
5399
|
// DES-CHAT-ARTIFACTS-001 §5.1 (A1): the per-turn block reads crew's records (documents, runs) for the chat's own
|
|
5082
|
-
// person.
|
|
5083
|
-
//
|
|
5084
|
-
// goes through, with no block.
|
|
5400
|
+
// person. Another actor's send under `auth: required` is refused 404 above. An agent, system or plugin actor's
|
|
5401
|
+
// `context` is refused before anything is reserved or read; without `context` their send carries no block.
|
|
5085
5402
|
const msgContext = parsed.data.context;
|
|
5086
5403
|
const sender = actorOf(req);
|
|
5087
5404
|
const ownsChat = chatHistory === null || chatHistory.visibleTo(id, security.authMode === 'required' ? sender.id : null);
|
|
@@ -5252,13 +5569,14 @@ runtime = {}) {
|
|
|
5252
5569
|
// boundary then), so a repository attached or registered since is refused here, at once, with
|
|
5253
5570
|
// the sentence — never accepted into a run whose boundary refuses every read of it.
|
|
5254
5571
|
const graphChanged = scope?.kind === 'project' && codeGraphDb !== path.launchGraphBinding;
|
|
5255
|
-
const rootsChanged =
|
|
5256
|
-
path.launchReadRoots !== undefined && JSON.stringify(readRoots) !== JSON.stringify(path.launchReadRoots);
|
|
5572
|
+
const rootsChanged = path.launchReadRoots !== undefined && JSON.stringify(readRoots) !== JSON.stringify(path.launchReadRoots);
|
|
5257
5573
|
if (path.runId !== undefined && (graphChanged || rootsChanged)) {
|
|
5258
5574
|
askPaths.release(id, lease);
|
|
5259
5575
|
return reply.code(409).send({
|
|
5260
5576
|
code: 'chat_scope_changed',
|
|
5261
|
-
error:
|
|
5577
|
+
error: scope?.kind === 'repos'
|
|
5578
|
+
? `This chat's repository was picked for its job after the conversation started, so its answers can't read it. Start a new chat on ${scope.repos[0].name} to ask about it; the job stays in this chat.`
|
|
5579
|
+
: `This chat's repositories or their code graph changed since it started (${scope?.repos.length ?? 0} now in scope). Start a new chat to read them — this one keeps its original scope.`,
|
|
5262
5580
|
});
|
|
5263
5581
|
}
|
|
5264
5582
|
const pending = await considerations.pendingPreface(id, { inForce: rules });
|
|
@@ -5519,6 +5837,7 @@ runtime = {}) {
|
|
|
5519
5837
|
// (api-types 0.196.0, operator ruling 2026-11-06) a job's Start chooses how it runs: `true` = a power run (no plan
|
|
5520
5838
|
// gate), `false` = it stops at its plan. Absent = it stops at its plan, as before.
|
|
5521
5839
|
power: z.boolean().optional(),
|
|
5840
|
+
reducedAssurance: z.boolean().optional(),
|
|
5522
5841
|
});
|
|
5523
5842
|
/** (api-types 0.192.0) `POST /chats/:id/proposals`: a person-made proposal, or a revision of the open one. */
|
|
5524
5843
|
const PersonProposalSchema = z.union([
|
|
@@ -5568,7 +5887,7 @@ runtime = {}) {
|
|
|
5568
5887
|
const out = await chatProposals.propose(id, body, gate.actor, gate.instance);
|
|
5569
5888
|
return reply.code(out.code).send(out.body);
|
|
5570
5889
|
});
|
|
5571
|
-
app.post(`${V}/chats/:id/proposals/:pid`, { config: { manifest: { requestType: 'ChatProposalDecisionBody', responseType: 'ChatProposalDecisionResponse', statusCodes: [200, 400, 403, 404, 409, 502] } } }, async (req, reply) => {
|
|
5890
|
+
app.post(`${V}/chats/:id/proposals/:pid`, { config: { manifest: { requestType: 'ChatProposalDecisionBody', responseType: 'ChatProposalDecisionResponse', statusCodes: [200, 400, 403, 404, 409, 422, 502] } } }, async (req, reply) => {
|
|
5572
5891
|
const { id, pid } = req.params;
|
|
5573
5892
|
if (!chatArtifactFlags.proposals)
|
|
5574
5893
|
return reply.code(404).send({ error: 'this daemon does not answer chat proposals' });
|
|
@@ -5597,6 +5916,7 @@ runtime = {}) {
|
|
|
5597
5916
|
decision: parsed.data.decision,
|
|
5598
5917
|
...(edits !== undefined ? { edits } : {}),
|
|
5599
5918
|
...(parsed.data.power !== undefined ? { power: parsed.data.power } : {}),
|
|
5919
|
+
...(parsed.data.reducedAssurance !== undefined ? { reducedAssurance: parsed.data.reducedAssurance } : {}),
|
|
5600
5920
|
}, actor, instance);
|
|
5601
5921
|
return reply.code(out.code).send(out.body);
|
|
5602
5922
|
});
|
|
@@ -5617,6 +5937,8 @@ runtime = {}) {
|
|
|
5617
5937
|
},
|
|
5618
5938
|
}, async (req, reply) => {
|
|
5619
5939
|
const { id } = req.params;
|
|
5940
|
+
if (refuseHiddenChat(req, reply, id))
|
|
5941
|
+
return reply;
|
|
5620
5942
|
const parsed = ChatSeatsSchema.safeParse(req.body);
|
|
5621
5943
|
if (!parsed.success) {
|
|
5622
5944
|
return reply.code(400).send(invalidBody(parsed.error, 'Invalid request body'));
|
|
@@ -5777,9 +6099,12 @@ runtime = {}) {
|
|
|
5777
6099
|
includeRetired: flag === '1' || flag === 'true',
|
|
5778
6100
|
});
|
|
5779
6101
|
});
|
|
5780
|
-
app.get(`${V}/chats/:id`, { config: { manifest: { responseType: 'ChatDetailResponse', statusCodes: [200, 400] } } }, async (req, reply) => {
|
|
6102
|
+
app.get(`${V}/chats/:id`, { config: { manifest: { responseType: 'ChatDetailResponse', statusCodes: [200, 400, 404] } } }, async (req, reply) => {
|
|
5781
6103
|
const { id } = req.params;
|
|
6104
|
+
if (refuseHiddenChat(req, reply, id))
|
|
6105
|
+
return reply;
|
|
5782
6106
|
try {
|
|
6107
|
+
await chatProposals.recheckHeldSeats(id).catch(() => false);
|
|
5783
6108
|
// The scope recorded at open (crew#502) — `null` for a chat this daemon did not open — and
|
|
5784
6109
|
// the seats refused at open (F-A45-011), so the studio's admission copy survives a reload.
|
|
5785
6110
|
return {
|
|
@@ -5808,6 +6133,9 @@ runtime = {}) {
|
|
|
5808
6133
|
/** Runs right after the close fold, with NO await before it: the id cannot have been reopened
|
|
5809
6134
|
* yet, so a history operation here can never land on a replacement chat (xreview r1 on #1140). */
|
|
5810
6135
|
afterFold) => {
|
|
6136
|
+
// crew#1279 (coord r1 on #1720): the instance the caller checked, read before the wait for a held Go. A chat closed
|
|
6137
|
+
// by another route meanwhile whose id a new chat reused is not this close's to end (fence by generation).
|
|
6138
|
+
const expected = chatHistory?.stateOf(id)?.instance ?? null;
|
|
5811
6139
|
// DES-SYSTEM-CHAT: the answering CLI the history names is the path's PA, while it is known.
|
|
5812
6140
|
const pa = askPaths.get(id)?.pa;
|
|
5813
6141
|
if (pa !== undefined && pa !== null)
|
|
@@ -5816,7 +6144,15 @@ runtime = {}) {
|
|
|
5816
6144
|
// (crew#502). ASK-C1: the daemon owns the close, so the id is HELD — no grace timer — until
|
|
5817
6145
|
// this close settles below; a reopen meanwhile is refused and a second DELETE joins this one
|
|
5818
6146
|
// (nothing of the closed chat can land on a reuse — codex on #808 r5).
|
|
5819
|
-
|
|
6147
|
+
// crew#1279: the close is committed under Go's admission of this chat, so it waits for a launch in flight. Only the
|
|
6148
|
+
// hold is under it: a second DELETE still joins the settling close at once.
|
|
6149
|
+
const ticket = await chatProposals.admitChat(id, async () => {
|
|
6150
|
+
const now = chatHistory?.stateOf(id)?.instance ?? null;
|
|
6151
|
+
return now !== null && now !== expected ? 'changed' : chatScopes.holdClose(id);
|
|
6152
|
+
});
|
|
6153
|
+
if (ticket === 'changed') {
|
|
6154
|
+
return { ok: false, code: 'chat_changed', error: `chat ${id} was closed while this request waited, and its id now belongs to a new chat; nothing was changed` };
|
|
6155
|
+
}
|
|
5820
6156
|
if (ticket === null)
|
|
5821
6157
|
return { ok: true };
|
|
5822
6158
|
chatTurns.closed(id);
|
|
@@ -5876,14 +6212,14 @@ runtime = {}) {
|
|
|
5876
6212
|
};
|
|
5877
6213
|
const ended = await endChat(id, removeHistory);
|
|
5878
6214
|
if (!ended.ok)
|
|
5879
|
-
return reply.code(400).send({ error: ended.error });
|
|
6215
|
+
return ended.code !== undefined ? reply.code(409).send({ code: ended.code, error: ended.error }) : reply.code(400).send({ error: ended.error });
|
|
5880
6216
|
// A chat the daemon no longer held (no fold ran): its kept history goes too.
|
|
5881
6217
|
if (chatHistory?.entry(id) !== null && chatScopes.get(id) === undefined && askPaths.get(id) === undefined)
|
|
5882
6218
|
removeHistory();
|
|
5883
6219
|
return { ok: true };
|
|
5884
6220
|
});
|
|
5885
6221
|
// DES-SYSTEM-CHAT (api-types 0.137.0): end the chat and KEEP its history and attachments.
|
|
5886
|
-
app.post(`${V}/chats/:id/close`, { config: { manifest: { responseType: 'ChatCloseResponse', statusCodes: [200, 400, 404, 501, 502] } } }, async (req, reply) => {
|
|
6222
|
+
app.post(`${V}/chats/:id/close`, { config: { manifest: { responseType: 'ChatCloseResponse', statusCodes: [200, 400, 404, 409, 501, 502] } } }, async (req, reply) => {
|
|
5887
6223
|
const { id } = req.params;
|
|
5888
6224
|
if (chatHistory === null)
|
|
5889
6225
|
return reply.code(501).send({ error: 'this daemon keeps no chat history' });
|
|
@@ -5896,7 +6232,7 @@ runtime = {}) {
|
|
|
5896
6232
|
// without the fold, and is a no-op after it.
|
|
5897
6233
|
const ended = await endChat(id, () => chatHistory.closed(id));
|
|
5898
6234
|
if (!ended.ok)
|
|
5899
|
-
return reply.code(400).send({ error: ended.error });
|
|
6235
|
+
return ended.code !== undefined ? reply.code(409).send({ code: ended.code, error: ended.error }) : reply.code(400).send({ error: ended.error });
|
|
5900
6236
|
const chat = chatHistory.entry(id);
|
|
5901
6237
|
if (chat === null)
|
|
5902
6238
|
return reply.code(404).send({ error: `chat ${id} has no history on this daemon` });
|
|
@@ -5923,6 +6259,8 @@ runtime = {}) {
|
|
|
5923
6259
|
// by a restart) releases it with its note first, so the proposal reads startable again.
|
|
5924
6260
|
if (chat !== null)
|
|
5925
6261
|
await chatProposals.reopenStale(id).catch(() => false);
|
|
6262
|
+
if (chat !== null)
|
|
6263
|
+
await chatProposals.recheckHeldSeats(id).catch(() => false);
|
|
5926
6264
|
const messages = chat === null ? null : chatHistory.messages(id);
|
|
5927
6265
|
if (chat === null || messages === null)
|
|
5928
6266
|
return reply.code(404).send({ error: `no chat ${id} in this daemon's history` });
|
|
@@ -6063,6 +6401,8 @@ runtime = {}) {
|
|
|
6063
6401
|
if (!operatorOnlyRead(req, reply))
|
|
6064
6402
|
return reply;
|
|
6065
6403
|
const { id, turnId } = req.params;
|
|
6404
|
+
if (refuseHiddenChat(req, reply, id))
|
|
6405
|
+
return reply;
|
|
6066
6406
|
const c = await considerations.forChatTurn(id, turnId);
|
|
6067
6407
|
if (c === null)
|
|
6068
6408
|
return reply.code(404).send({ error: `chat ${id} holds no turn ${turnId}` });
|
|
@@ -6391,11 +6731,11 @@ runtime = {}) {
|
|
|
6391
6731
|
}
|
|
6392
6732
|
// crew#1157: every APPROVING path (the gate route, standing orders, a gated resume or reassign, a
|
|
6393
6733
|
// plan edit at the gate, the next message of a chat) is judged here, so no path approves a held
|
|
6394
|
-
// plan change on an analysis run. Declining stays open.
|
|
6734
|
+
// plan change on an analysis or delivering chat run. Declining stays open.
|
|
6395
6735
|
if (!('refusal' in decided) && opts.declining !== true) {
|
|
6396
|
-
const
|
|
6397
|
-
if (
|
|
6398
|
-
return { refusal:
|
|
6736
|
+
const chatRefusal = chatPlanRefusal(run.session.id, { gateKind: decided.gateKind });
|
|
6737
|
+
if (chatRefusal !== null)
|
|
6738
|
+
return { refusal: chatRefusal };
|
|
6399
6739
|
}
|
|
6400
6740
|
return decided;
|
|
6401
6741
|
}
|
|
@@ -6417,7 +6757,7 @@ runtime = {}) {
|
|
|
6417
6757
|
} } };
|
|
6418
6758
|
}
|
|
6419
6759
|
const kind = recorded.row['gate_kind'];
|
|
6420
|
-
return { gated: unitAt(recorded.ord), prompt: recorded.row.prompt, gateKind: typeof kind === 'string' && kind !== '' ? kind : undefined };
|
|
6760
|
+
return { ord: recorded.ord, gated: unitAt(recorded.ord), prompt: recorded.row.prompt, gateKind: typeof kind === 'string' && kind !== '' ? kind : undefined };
|
|
6421
6761
|
}
|
|
6422
6762
|
if (namedOrd !== undefined) {
|
|
6423
6763
|
return unknown(`this decision names the gate before unit ${namedOrd}, but the engine's record `
|
|
@@ -6425,8 +6765,9 @@ runtime = {}) {
|
|
|
6425
6765
|
}
|
|
6426
6766
|
const open = await resolveOpenGate(id).catch(() => null);
|
|
6427
6767
|
if (isOpenGate(open))
|
|
6428
|
-
return { gated: unitAt(open.ord), prompt: open.prompt, gateKind: open.gateKind };
|
|
6429
|
-
|
|
6768
|
+
return { ord: open.ord, gated: unitAt(open.ord), prompt: open.prompt, gateKind: open.gateKind };
|
|
6769
|
+
const gated = [...(run.units ?? [])].sort((a, b) => a.ord - b.ord)[run.session.unit_ix];
|
|
6770
|
+
return { ord: undefined, gated, prompt: undefined, gateKind: undefined };
|
|
6430
6771
|
}
|
|
6431
6772
|
/**
|
|
6432
6773
|
* The checks an APPROVE that runs the deliver unit must pass — the ONE place for both gate paths
|
|
@@ -6457,21 +6798,10 @@ runtime = {}) {
|
|
|
6457
6798
|
/**
|
|
6458
6799
|
* Run `fn` alone for the run (crew#1083 round 4; the `McpPolicies.exclusive` pattern of #1082):
|
|
6459
6800
|
* after every earlier decision for the same run has settled, and before any later one starts.
|
|
6460
|
-
*
|
|
6461
|
-
*
|
|
6462
|
-
*
|
|
6463
|
-
*
|
|
6464
|
-
* re-reads inside the lock and meets ord 4: 409 `gate_changed`. Other runs are not blocked.
|
|
6465
|
-
*
|
|
6466
|
-
* Every crew API path that confirms a gate takes it and is judged by the record
|
|
6467
|
-
* ({@link gateForDecision}) under it: `decideGate` (`POST /runs/:id/gate`, standing orders),
|
|
6468
|
-
* `POST /runs/:id/resume`, `POST /runs/:id/reassign` (the re-seat included), `POST /runs/:id/plan`
|
|
6469
|
-
* (team routes) and the chat ask path's continuation (which re-reads its run inside the lock).
|
|
6470
|
-
* It serializes these paths; it does not bind a confirm to the gate the operator saw. A
|
|
6471
|
-
* decision without an `ord` (`/resume`, `/reassign`, `/plan`) queued behind one that advanced the
|
|
6472
|
-
* run answers the gate the record shows then, and the stall watchdog's `reassignUnit` runs
|
|
6473
|
-
* outside this lock. Both need every confirm bound to the gate it answers: an ord on the engine's
|
|
6474
|
-
* confirm (wicked-core#1038) and the skin sending it.
|
|
6801
|
+
* Every confirming path reads the record and checks delivery under this lock. When supported,
|
|
6802
|
+
* operator confirms carry a resolved gate ord for the engine to check. A body ord also binds
|
|
6803
|
+
* a queued decision to the gate the operator saw. The watchdog shares the lock and re-reads
|
|
6804
|
+
* the cursor before reassigning, so it cannot re-seat a unit between these checks and confirm.
|
|
6475
6805
|
*/
|
|
6476
6806
|
function decideExclusively(runId, fn) {
|
|
6477
6807
|
const result = (gateDecisionTails.get(runId) ?? Promise.resolve()).then(fn);
|
|
@@ -6484,20 +6814,30 @@ runtime = {}) {
|
|
|
6484
6814
|
return result;
|
|
6485
6815
|
}
|
|
6486
6816
|
/**
|
|
6487
|
-
* crew#1157
|
|
6817
|
+
* crew#1157 / crew#1259: an analysis or delivering ask-path chat's run never takes on work. Its seat is told not to
|
|
6488
6818
|
* propose any, but a `PLAN+` line in an answer would still hold a creator addition at a
|
|
6489
6819
|
* `plan_approval` gate; approving it (or approving with an edited plan) would let the run write.
|
|
6490
6820
|
* Refused here, for every decision path, by the durable launch record: declining stays allowed.
|
|
6491
6821
|
*/
|
|
6492
|
-
function
|
|
6822
|
+
function chatPlanRefusal(runId, held) {
|
|
6493
6823
|
const workflow = runTimingIndex.chatWorkflowOf(runId);
|
|
6494
|
-
|
|
6824
|
+
const deliveringChat = workflow === undefined && runTimingIndex.isAskPath(runId) && runTimingIndex.launchDeliverFor(runId) === 'pr';
|
|
6825
|
+
if (workflow === undefined && !deliveringChat)
|
|
6495
6826
|
return null;
|
|
6496
6827
|
// A held plan change (the gate the engine opens on a `PLAN+` line), or a plan edit with any step
|
|
6497
6828
|
// that could write (the same read-only predicate the chat open applies to the workflow).
|
|
6498
6829
|
const writes = held.plan?.steps.some((s) => writeCapableStep(s) !== null) === true;
|
|
6499
6830
|
if (held.gateKind !== 'plan_approval' && !writes)
|
|
6500
6831
|
return null;
|
|
6832
|
+
if (deliveringChat)
|
|
6833
|
+
return {
|
|
6834
|
+
code: 409,
|
|
6835
|
+
body: {
|
|
6836
|
+
code: 'chat_build_needs_job',
|
|
6837
|
+
error: `run ${runId}: the chat's run has no QE acceptance, so it cannot take on a change it would deliver. ` +
|
|
6838
|
+
'Decline it here and start a job (a feature or bug job runs QE acceptance before its pull request).',
|
|
6839
|
+
},
|
|
6840
|
+
};
|
|
6501
6841
|
return {
|
|
6502
6842
|
code: 409,
|
|
6503
6843
|
body: {
|
|
@@ -6507,6 +6847,20 @@ runtime = {}) {
|
|
|
6507
6847
|
},
|
|
6508
6848
|
};
|
|
6509
6849
|
}
|
|
6850
|
+
/** (wicked-core#1683) The open steering rules a noted Land at this gate would skip (the engine's listed approve with
|
|
6851
|
+
* `noteIntent: 'skip_rules'`); `[]` when it skips none (or the engine predates the list); `null` when the list could
|
|
6852
|
+
* not be read. */
|
|
6853
|
+
async function landSkipsRules(id) {
|
|
6854
|
+
if (typeof adapter.gateActions !== 'function')
|
|
6855
|
+
return [];
|
|
6856
|
+
try {
|
|
6857
|
+
const listed = await adapter.gateActions(id);
|
|
6858
|
+
return listed?.actions.find((a) => a.action === 'approve' && a.noteIntent === 'skip_rules')?.rules ?? [];
|
|
6859
|
+
}
|
|
6860
|
+
catch {
|
|
6861
|
+
return null;
|
|
6862
|
+
}
|
|
6863
|
+
}
|
|
6510
6864
|
/**
|
|
6511
6865
|
* THE gate decision path. `POST /runs/:id/gate` answers with it, and so does a standing order
|
|
6512
6866
|
* (behaviour 10) — the same awaiting check, the same ord check and 409 `gate_changed` /
|
|
@@ -6564,6 +6918,29 @@ runtime = {}) {
|
|
|
6564
6918
|
const r = decided.refusal.body;
|
|
6565
6919
|
return r?.code === 'gate_changed' ? { code: decided.refusal.code, body: { ...(await currentPlanOf(id, false)), ...r } } : decided.refusal;
|
|
6566
6920
|
}
|
|
6921
|
+
// (wicked-core#1683) A noted Land that skips open steering rules is the same human-only
|
|
6922
|
+
// decision as skip_rules. Read its rules under the decision lock and keep them for the audit.
|
|
6923
|
+
const landNote = parsed.data.amend?.trim() ?? '';
|
|
6924
|
+
const landRules = parsed.data.approve && (parsed.data.action === undefined || parsed.data.action === 'approve')
|
|
6925
|
+
&& landNote !== '' && decided.gateKind === 'review_adjudication'
|
|
6926
|
+
? await landSkipsRules(id) : [];
|
|
6927
|
+
// A seat or a standing order is never let through on an unread list: it may be the skip it must not make.
|
|
6928
|
+
if (landRules === null && !isHumanOperator(actor)) {
|
|
6929
|
+
return { code: 503, body: { error: 'the gate\'s answers could not be read, so this Land could not be checked for a rule skip; read the gate and answer again', retryable: true } };
|
|
6930
|
+
}
|
|
6931
|
+
if (landRules !== null && landRules.length > 0 && !isHumanOperator(actor)) {
|
|
6932
|
+
audit.record('gate.skip_rules_refused', actor, {
|
|
6933
|
+
runId: id,
|
|
6934
|
+
detail: { reason: 'human_operator_only', ...(decided.gated !== undefined ? { ord: decided.gated.ord } : {}) },
|
|
6935
|
+
});
|
|
6936
|
+
return {
|
|
6937
|
+
code: 403,
|
|
6938
|
+
body: {
|
|
6939
|
+
error: `only a human operator can skip a steering rule (you are ${actor.kind}/${actor.trust}): landing with a note here skips ${landRules.join(', ')}`,
|
|
6940
|
+
code: 'human_operator_only',
|
|
6941
|
+
},
|
|
6942
|
+
};
|
|
6943
|
+
}
|
|
6567
6944
|
// DES-CATALOG-002 §4.6: a plan-gate answer is bound to the plan on screen. A run launched from a chat proposal
|
|
6568
6945
|
// REQUIRES `planRev` there, whichever client answers; a send-back needs it on any run. The engine compares it
|
|
6569
6946
|
// (and `ord`) inside its own serialized decision, so a re-plan landing after this read still loses.
|
|
@@ -6591,9 +6968,9 @@ runtime = {}) {
|
|
|
6591
6968
|
&& !(typeof adapter.supportsPlanGateNote === 'function' && adapter.supportsPlanGateNote())) {
|
|
6592
6969
|
return { code: 501, body: { error: message(new PlanGateNoteUnsupportedError()) } };
|
|
6593
6970
|
}
|
|
6594
|
-
const
|
|
6595
|
-
if (
|
|
6596
|
-
return
|
|
6971
|
+
const chatRefusal = parsed.data.approve ? chatPlanRefusal(id, { plan: parsed.data.plan }) : null;
|
|
6972
|
+
if (chatRefusal !== null)
|
|
6973
|
+
return chatRefusal;
|
|
6597
6974
|
// The gated unit and its receipt as it stands when the person decides (wicked-core#850: every
|
|
6598
6975
|
// gate answer carries it). An APPROVE that would run the deliver unit passes the delivery
|
|
6599
6976
|
// checks first.
|
|
@@ -6637,9 +7014,9 @@ runtime = {}) {
|
|
|
6637
7014
|
// confirm, which records it as the judge when this approve answers a `judge_unavailable`
|
|
6638
7015
|
// gate ("judged by operator").
|
|
6639
7016
|
adapter.recordGateActor?.(id, `${actor.id} (${actor.kind})`);
|
|
6640
|
-
|
|
6641
|
-
|
|
6642
|
-
|
|
7017
|
+
const expect = parsed.data.planRev !== undefined
|
|
7018
|
+
? { ...expectFor(decided.ord), planRev: parsed.data.planRev }
|
|
7019
|
+
: expectFor(decided.ord);
|
|
6643
7020
|
const confirmArgs = [
|
|
6644
7021
|
id,
|
|
6645
7022
|
parsed.data.approve,
|
|
@@ -6670,6 +7047,12 @@ runtime = {}) {
|
|
|
6670
7047
|
detail: { skips: parsed.data.skipRules ?? [], ...(gated !== undefined ? { ord: gated.ord } : {}), status },
|
|
6671
7048
|
});
|
|
6672
7049
|
}
|
|
7050
|
+
if (landRules !== null && landRules.length > 0) {
|
|
7051
|
+
audit.record('gate.rules_skipped', actor, {
|
|
7052
|
+
runId: id,
|
|
7053
|
+
detail: { skips: landRules.map((id) => ({ id, reason: landNote })), ...(gated !== undefined ? { ord: gated.ord } : {}), status, land: true },
|
|
7054
|
+
});
|
|
7055
|
+
}
|
|
6673
7056
|
audit.record('gate.decided', actor, {
|
|
6674
7057
|
runId: id,
|
|
6675
7058
|
detail: {
|
|
@@ -6724,14 +7107,14 @@ runtime = {}) {
|
|
|
6724
7107
|
};
|
|
6725
7108
|
}
|
|
6726
7109
|
catch (err) {
|
|
7110
|
+
if (err instanceof MaintenanceDrainError)
|
|
7111
|
+
return { code: 503, body: maintenanceDrainBody(err) };
|
|
6727
7112
|
if (err instanceof PlanLaunchUnsupportedError || err instanceof PlanGateNoteUnsupportedError) {
|
|
6728
7113
|
return { code: 501, body: { error: message(err) } };
|
|
6729
7114
|
}
|
|
6730
|
-
|
|
6731
|
-
|
|
6732
|
-
|
|
6733
|
-
return { code: 409, body: { code: 'gate_changed', error: `Gate changed: ${message(err).replace(/^gate_changed:?\s*/u, '')} — read the plan again and answer it.`, ...(await currentPlanOf(id)) } };
|
|
6734
|
-
}
|
|
7115
|
+
const changed = await gateChangedRefusal(id, err);
|
|
7116
|
+
if (changed !== null)
|
|
7117
|
+
return changed;
|
|
6735
7118
|
return { code: 409, body: { error: message(err) } };
|
|
6736
7119
|
}
|
|
6737
7120
|
});
|
|
@@ -6752,6 +7135,18 @@ runtime = {}) {
|
|
|
6752
7135
|
function adapterSupportsPlanSendBack() {
|
|
6753
7136
|
return typeof adapter.supportsPlanSendBack === 'function' && adapter.supportsPlanSendBack();
|
|
6754
7137
|
}
|
|
7138
|
+
function expectFor(decidedOrd) {
|
|
7139
|
+
return decidedOrd !== undefined && adapterSupportsPlanSendBack() ? { ord: decidedOrd } : undefined;
|
|
7140
|
+
}
|
|
7141
|
+
async function gateChangedRefusal(id, err) {
|
|
7142
|
+
if (!/^gate_changed\b/u.test(message(err)))
|
|
7143
|
+
return null;
|
|
7144
|
+
return { code: 409, body: {
|
|
7145
|
+
code: 'gate_changed',
|
|
7146
|
+
error: `Gate changed: ${message(err).replace(/^gate_changed:?\s*/u, '')} — read the gate again and answer it.`,
|
|
7147
|
+
...(await currentPlanOf(id)),
|
|
7148
|
+
} };
|
|
7149
|
+
}
|
|
6755
7150
|
// The steering gate (§11.1). approve+amend = approve-with-steer; approve:false = reject (cancels).
|
|
6756
7151
|
app.post(`${V}/runs/:id/gate`, {
|
|
6757
7152
|
config: {
|
|
@@ -6760,7 +7155,7 @@ runtime = {}) {
|
|
|
6760
7155
|
responseType: 'GateDecisionResult',
|
|
6761
7156
|
// 409 twice over: a run not awaiting a human gate, and an engine refusal at confirm.
|
|
6762
7157
|
// 501: an edited plan on an addon without the plan approval gate (DES-TEAMING-002 T3).
|
|
6763
|
-
statusCodes: [200, 400, 404, 409, 501],
|
|
7158
|
+
statusCodes: [200, 400, 404, 409, 501, 503],
|
|
6764
7159
|
},
|
|
6765
7160
|
},
|
|
6766
7161
|
}, async (req, reply) => {
|
|
@@ -6819,6 +7214,7 @@ runtime = {}) {
|
|
|
6819
7214
|
const base = old !== null && old.shape !== undefined ? factsOf(old) : null;
|
|
6820
7215
|
const facts = {
|
|
6821
7216
|
card: parsed.data.card,
|
|
7217
|
+
title: base?.title ?? null,
|
|
6822
7218
|
option: parsed.data.option ?? undefined,
|
|
6823
7219
|
depth: parsed.data.depth ?? null,
|
|
6824
7220
|
words: base?.words ?? envelope.words,
|
|
@@ -6887,7 +7283,10 @@ runtime = {}) {
|
|
|
6887
7283
|
});
|
|
6888
7284
|
// Advance semantics (§11.8): a gated run advances via confirmGate; otherwise
|
|
6889
7285
|
// resumeRun re-enters the cursor. Never resumeRun a gated run (it would re-pause).
|
|
6890
|
-
app.post(`${V}/runs/:id/resume`, async (req, reply) => {
|
|
7286
|
+
app.post(`${V}/runs/:id/resume`, { config: { manifest: { requestType: 'ResumeRequest', statusCodes: [200, 400, 404, 409, 503] } } }, async (req, reply) => {
|
|
7287
|
+
const parsed = ResumeSchema.safeParse(req.body ?? {});
|
|
7288
|
+
if (!parsed.success)
|
|
7289
|
+
return reply.code(400).send(invalidBody(parsed.error, 'Invalid request body'));
|
|
6891
7290
|
const { id } = req.params;
|
|
6892
7291
|
// A gated resume confirms the gate: one decision at a time per run (crew#1083 round 5).
|
|
6893
7292
|
return decideExclusively(id, async () => {
|
|
@@ -6939,7 +7338,7 @@ runtime = {}) {
|
|
|
6939
7338
|
// A gated resume IS an approve, so it is judged by the record like every decision, passes the
|
|
6940
7339
|
// same delivery checks (freeze, EX-03) — no side door around the deliver gate — and answers
|
|
6941
7340
|
// with the gated unit's receipt.
|
|
6942
|
-
const decided = gated ? await gateForDecision(run,
|
|
7341
|
+
const decided = gated ? await gateForDecision(run, parsed.data.ord) : undefined;
|
|
6943
7342
|
if (decided !== undefined && 'refusal' in decided)
|
|
6944
7343
|
return reply.code(decided.refusal.code).send(decided.refusal.body);
|
|
6945
7344
|
const steeringPropose = gated && isSteeringAuthorRun(run);
|
|
@@ -6956,7 +7355,7 @@ runtime = {}) {
|
|
|
6956
7355
|
const who = actorOf(req);
|
|
6957
7356
|
adapter.recordGateActor?.(id, `${who.id} (${who.kind})`);
|
|
6958
7357
|
}
|
|
6959
|
-
const status = gated ? await adapter.confirmGate(id, true) : await adapter.resumeRun(id);
|
|
7358
|
+
const status = gated ? await adapter.confirmGate(id, true, undefined, undefined, undefined, undefined, expectFor(decided?.ord)) : await adapter.resumeRun(id);
|
|
6960
7359
|
// A resume of a gated run IS a gate approval — audit it as one, so the
|
|
6961
7360
|
// "who approved" trail has no side door (task #88).
|
|
6962
7361
|
audit.record(gated ? 'gate.decided' : 'run.resumed', actorOf(req), {
|
|
@@ -6974,7 +7373,10 @@ runtime = {}) {
|
|
|
6974
7373
|
});
|
|
6975
7374
|
}
|
|
6976
7375
|
catch (err) {
|
|
6977
|
-
|
|
7376
|
+
if (err instanceof MaintenanceDrainError)
|
|
7377
|
+
return reply.code(503).send(maintenanceDrainBody(err));
|
|
7378
|
+
const changed = await gateChangedRefusal(id, err);
|
|
7379
|
+
return reply.code(changed?.code ?? 409).send(changed?.body ?? { error: message(err) });
|
|
6978
7380
|
}
|
|
6979
7381
|
});
|
|
6980
7382
|
});
|
|
@@ -7007,7 +7409,11 @@ runtime = {}) {
|
|
|
7007
7409
|
}
|
|
7008
7410
|
if (token !== null)
|
|
7009
7411
|
voiceInputs.settle(id);
|
|
7010
|
-
|
|
7412
|
+
// (crew#1392) The words too, capped: the run's context document shows a person's steer under Decisions.
|
|
7413
|
+
audit.record('run.injected', actorOf(req), {
|
|
7414
|
+
runId: id,
|
|
7415
|
+
detail: { target: parsed.data.target, words: injectWords(parsed.data.message), ...(spoken ? { input: 'voice' } : {}) },
|
|
7416
|
+
});
|
|
7011
7417
|
// DC-S4a host: the operator's mid-run steering text (review S9).
|
|
7012
7418
|
if (decisions !== null) {
|
|
7013
7419
|
decisions.track(ingestDecision(decisions, {
|
|
@@ -7077,9 +7483,9 @@ runtime = {}) {
|
|
|
7077
7483
|
const codeWork = def !== null && def.phases.some((p) => p.executes_code === true && p.role !== 'evaluator');
|
|
7078
7484
|
return codeWork && (await adapter.getSettings()).deliverDefault !== 'none' ? 'pr' : 'none';
|
|
7079
7485
|
},
|
|
7080
|
-
//
|
|
7081
|
-
|
|
7082
|
-
|
|
7486
|
+
// crew#1418 / crew#1585: prepared reviews, evals and maps never deliver.
|
|
7487
|
+
preparationDropsDelivery: (workflow) => workflow === REVIEW_CHANGE_WORKFLOW || reviewPrepared(workflow) ||
|
|
7488
|
+
workflow === RUN_EVALS_WORKFLOW || workflow === DOMAIN_MAPPING,
|
|
7083
7489
|
};
|
|
7084
7490
|
// ── Power mode (program DES-POWER-MODE; api-types 0.149.0) ─────────────────────────────────────
|
|
7085
7491
|
// The engine computes every rigor value; these routes only carry a person's switch, raise or pause
|
|
@@ -7089,7 +7495,28 @@ runtime = {}) {
|
|
|
7089
7495
|
const textOrNull = (v) => (v === undefined || v === null || v.trim() === '' ? null : v.trim());
|
|
7090
7496
|
const PowerToggleSchema = z.strictObject({ on: z.boolean(), reason: z.string().trim().max(2000).nullish() });
|
|
7091
7497
|
const RigorRaiseSchema = z.strictObject({ atLeast: z.enum(RIGORS), reason: z.string().trim().min(1).max(2000) });
|
|
7092
|
-
const PowerPauseSchema = z.strictObject({
|
|
7498
|
+
const PowerPauseSchema = z.strictObject({
|
|
7499
|
+
decision: z.enum(['continue_high', 'continue', 'switch_phased', 'stop']),
|
|
7500
|
+
note: z.string().trim().max(8000).nullish(),
|
|
7501
|
+
// (crew#1739) The pause the person answered, as the card showed it (`PowerPause.checkpoint` / `.at`).
|
|
7502
|
+
checkpoint: z.number().int().positive().optional(),
|
|
7503
|
+
at: z.number().int().nonnegative().optional(),
|
|
7504
|
+
});
|
|
7505
|
+
/** (crew#1739) Each run's pause answers, one at a time (`onePauseAnswer`). */
|
|
7506
|
+
const pauseAnswers = new Map();
|
|
7507
|
+
const onePauseAnswer = (runId, op) => {
|
|
7508
|
+
const next = (pauseAnswers.get(runId) ?? Promise.resolve()).then(op, op);
|
|
7509
|
+
const settled = next.then(() => undefined, () => undefined);
|
|
7510
|
+
pauseAnswers.set(runId, settled);
|
|
7511
|
+
void settled.then(() => { if (pauseAnswers.get(runId) === settled)
|
|
7512
|
+
pauseAnswers.delete(runId); });
|
|
7513
|
+
return next;
|
|
7514
|
+
};
|
|
7515
|
+
/** A power pause's identity: its checkpoint and when it opened (`PowerPause`), or null when none is open. */
|
|
7516
|
+
const pauseIdentity = (view) => {
|
|
7517
|
+
const pause = view?.['pause'];
|
|
7518
|
+
return pause && typeof pause.checkpoint === 'number' && typeof pause.at === 'number' ? { checkpoint: pause.checkpoint, at: pause.at } : null;
|
|
7519
|
+
};
|
|
7093
7520
|
/** An engine refusal as HTTP: `not_found:` 404, `conflict:` 409, `refused:` / `bad_request:` 409 / 400. */
|
|
7094
7521
|
const powerError = (reply, err) => {
|
|
7095
7522
|
const msg = message(err);
|
|
@@ -7170,20 +7597,42 @@ runtime = {}) {
|
|
|
7170
7597
|
return reply.code(403).send({ error: 'Only a person can answer a power-mode pause' });
|
|
7171
7598
|
if (!powerSupported())
|
|
7172
7599
|
return reply.code(501).send({ error: 'This engine has no power mode' });
|
|
7173
|
-
|
|
7174
|
-
|
|
7175
|
-
|
|
7176
|
-
|
|
7177
|
-
|
|
7178
|
-
|
|
7179
|
-
|
|
7180
|
-
|
|
7600
|
+
// (crew#1739) One answer per run at a time: the read of the open pause and the engine's answer are one step, so a
|
|
7601
|
+
// second answer reads what the first left (a newer pause, or none) and is refused if it named the old one. Every
|
|
7602
|
+
// pause answer goes through this route.
|
|
7603
|
+
return onePauseAnswer(id, async () => {
|
|
7604
|
+
try {
|
|
7605
|
+
// (crew#1739) Which pause this answer is for. One that names a pause no longer open is refused, so a queued
|
|
7606
|
+
// answer (studio's undo window) never lands on a newer pause the person never saw.
|
|
7607
|
+
const view = await powerView(id);
|
|
7608
|
+
const open = pauseIdentity(view);
|
|
7609
|
+
const { checkpoint, at } = parsed.data;
|
|
7610
|
+
if (view !== null && (checkpoint !== undefined || at !== undefined) &&
|
|
7611
|
+
(open === null || (checkpoint !== undefined && checkpoint !== open.checkpoint) || (at !== undefined && at !== open.at))) {
|
|
7612
|
+
return reply.code(409).send({
|
|
7613
|
+
error: 'Pause changed',
|
|
7614
|
+
reason: open === null
|
|
7615
|
+
? 'This pause was already answered, and the run is not paused now. Nothing was changed.'
|
|
7616
|
+
: `This answer was for an earlier pause; the run is now paused at checkpoint ${open.checkpoint}. Read the pause again. Nothing was changed.`,
|
|
7617
|
+
open,
|
|
7618
|
+
});
|
|
7619
|
+
}
|
|
7620
|
+
const note = textOrNull(parsed.data.note);
|
|
7621
|
+
const st = await adapter.answerPowerPause(id, parsed.data.decision, note, actor.id);
|
|
7622
|
+
audit.record('run.power_mode.paused', actor, { runId: id, detail: { decision: parsed.data.decision } });
|
|
7623
|
+
if (decisions !== null && note !== null) {
|
|
7624
|
+
decisions.track(ingestDecision(decisions, {
|
|
7625
|
+
host: 'inject', actor, words: note, projectId: projects.index.projectOf(id) ?? null, runId: id,
|
|
7626
|
+
}));
|
|
7627
|
+
}
|
|
7628
|
+
return reply.send({ runId: id, ...st, answered: open });
|
|
7181
7629
|
}
|
|
7182
|
-
|
|
7183
|
-
|
|
7184
|
-
|
|
7185
|
-
|
|
7186
|
-
|
|
7630
|
+
catch (err) {
|
|
7631
|
+
if (err instanceof MaintenanceDrainError)
|
|
7632
|
+
return reply.code(503).send(maintenanceDrainBody(err));
|
|
7633
|
+
return powerError(reply, err);
|
|
7634
|
+
}
|
|
7635
|
+
});
|
|
7187
7636
|
});
|
|
7188
7637
|
/** The run's `wicked.run.*` bus mirror after a cursor (`RunBusPage`). Read through the engine's own bus
|
|
7189
7638
|
* read and filtered to this run; a page scans at most 1000 bus rows past the cursor. */
|
|
@@ -7249,8 +7698,8 @@ runtime = {}) {
|
|
|
7249
7698
|
*/
|
|
7250
7699
|
async function crewGateActions(run, gated, gateKind, actions) {
|
|
7251
7700
|
const declines = (a) => a.action === 'reject' || a.action === 'request_changes';
|
|
7252
|
-
// crew#1157: an analysis run's held plan change is never approved (`gateForDecision`): only the declines stay.
|
|
7253
|
-
let approveRefused =
|
|
7701
|
+
// crew#1157 / crew#1259: an analysis or delivering chat run's held plan change is never approved (`gateForDecision`): only the declines stay.
|
|
7702
|
+
let approveRefused = chatPlanRefusal(run.session.id, { gateKind }) !== null;
|
|
7254
7703
|
let skipRefused = approveRefused;
|
|
7255
7704
|
if (!approveRefused && gated !== undefined && isDeliverUnit(gated)) {
|
|
7256
7705
|
approveRefused = 'refusal' in (await deliverApprovalRefusal(run, gated));
|
|
@@ -7260,7 +7709,8 @@ runtime = {}) {
|
|
|
7260
7709
|
return actions
|
|
7261
7710
|
.filter((a) => declines(a) || !(a.action === SKIP_QE_ACTION ? skipRefused : approveRefused))
|
|
7262
7711
|
.filter((a) => !(steering && a.action === 'reassign'))
|
|
7263
|
-
.map((a) => (a.action === SKIP_QE_ACTION || a.action === SKIP_RULES_ACTION
|
|
7712
|
+
.map((a) => (a.action === SKIP_QE_ACTION || a.action === SKIP_RULES_ACTION || (a.action === 'approve' && a.noteIntent === 'skip_rules')
|
|
7713
|
+
? { ...a, humanOnly: true } : a));
|
|
7264
7714
|
}
|
|
7265
7715
|
/**
|
|
7266
7716
|
* codex r1 on #1060: whether approving the run's open gate ACCEPTS the parked unit's work rather
|
|
@@ -7360,7 +7810,7 @@ runtime = {}) {
|
|
|
7360
7810
|
// A gated reassign APPROVES the gate, so it is judged by the record like every decision and passes
|
|
7361
7811
|
// the same delivery checks (freeze, wicked-core#850 EX-03) when the gate holds the deliver unit
|
|
7362
7812
|
// (codex r1 on the EX-03 PR).
|
|
7363
|
-
const decided = gated ? await gateForDecision(run,
|
|
7813
|
+
const decided = gated ? await gateForDecision(run, parsed.data.ord) : undefined;
|
|
7364
7814
|
if (decided !== undefined && 'refusal' in decided)
|
|
7365
7815
|
return reply.code(decided.refusal.code).send(decided.refusal.body);
|
|
7366
7816
|
if (decided !== undefined) {
|
|
@@ -7373,6 +7823,9 @@ runtime = {}) {
|
|
|
7373
7823
|
}
|
|
7374
7824
|
const cursor = resolveCursorUnit(run);
|
|
7375
7825
|
const ord = cursor?.ord ?? run.session.unit_ix;
|
|
7826
|
+
if (!gated && parsed.data.ord !== undefined && parsed.data.ord !== ord) {
|
|
7827
|
+
return reply.code(409).send({ code: 'gate_changed', error: `Run changed: this decision was made on cursor unit ${parsed.data.ord}, but the cursor is at unit ${ord}. Nothing was reassigned.` });
|
|
7828
|
+
}
|
|
7376
7829
|
// (crew#1512) A parked run's reassign APPROVES its gate, so it is the engine's list that says whether this gate
|
|
7377
7830
|
// takes one and on which seats — checked before anything is re-seated or approved. An addon without the read keeps
|
|
7378
7831
|
// the older rule (`approveAcceptsWork`, below); with the read, a failed or stale one changes nothing.
|
|
@@ -7405,7 +7858,7 @@ runtime = {}) {
|
|
|
7405
7858
|
return; // refused above for a gated run
|
|
7406
7859
|
const who = actorOf(req);
|
|
7407
7860
|
adapter.recordGateActor?.(id, `${who.id} (${who.kind})`);
|
|
7408
|
-
const status =
|
|
7861
|
+
const status = await adapter.confirmGate(id, true, note, undefined, undefined, undefined, expectFor(decided?.ord));
|
|
7409
7862
|
noteRode = note !== undefined;
|
|
7410
7863
|
audit.record('gate.decided', actorOf(req), {
|
|
7411
7864
|
runId: id,
|
|
@@ -7443,7 +7896,9 @@ runtime = {}) {
|
|
|
7443
7896
|
}
|
|
7444
7897
|
catch (err) {
|
|
7445
7898
|
reassigned(false);
|
|
7899
|
+
const changed = await gateChangedRefusal(id, err);
|
|
7446
7900
|
return reply.code(409).send({
|
|
7901
|
+
...changed?.body,
|
|
7447
7902
|
error: `unit ${ord} was re-seated on ${requestedCli}, but approving the gate failed: ${message(err)} — read the run's gate before answering again`,
|
|
7448
7903
|
});
|
|
7449
7904
|
}
|
|
@@ -7463,7 +7918,8 @@ runtime = {}) {
|
|
|
7463
7918
|
});
|
|
7464
7919
|
}
|
|
7465
7920
|
catch (err) {
|
|
7466
|
-
|
|
7921
|
+
const changed = await gateChangedRefusal(id, err);
|
|
7922
|
+
return reply.code(changed?.code ?? 409).send(changed?.body ?? { error: message(err) });
|
|
7467
7923
|
}
|
|
7468
7924
|
});
|
|
7469
7925
|
}
|
|
@@ -7479,11 +7935,11 @@ runtime = {}) {
|
|
|
7479
7935
|
// read it. A restart is routine: deploy, crash, laptop sleep.
|
|
7480
7936
|
app.get(`${V}/runs/:id/gate`, async (req, reply) => {
|
|
7481
7937
|
const { id } = req.params;
|
|
7482
|
-
// F35: this run's view only, never every run's (studio
|
|
7483
|
-
// every open tab)
|
|
7484
|
-
//
|
|
7485
|
-
|
|
7486
|
-
const runOf = () => adapter.runView(id);
|
|
7938
|
+
// F35, crew#1775: this run's view only, never every run's (studio reads this route for parked runs,
|
|
7939
|
+
// from every open tab): one engine read of this run, off the actor, as the store is when it starts.
|
|
7940
|
+
// Read once per request: the cached-but-not-servable path and the miss path share it (coord review C6).
|
|
7941
|
+
let viewRead;
|
|
7942
|
+
const runOf = () => (viewRead ??= adapter.runView(id));
|
|
7487
7943
|
// (rejudge, api-types 0.134.0) A gate whose unit no judge could rule on says whether its judge
|
|
7488
7944
|
// can be re-run now, and from which seats — the engine's own selection, read each time (a seat
|
|
7489
7945
|
// signed in since the pause counts). Absent on every other gate and on an addon without the read.
|
|
@@ -7601,11 +8057,12 @@ runtime = {}) {
|
|
|
7601
8057
|
}
|
|
7602
8058
|
const cached = gateCache.get(id);
|
|
7603
8059
|
if (cached) {
|
|
8060
|
+
const run = await runOf();
|
|
7604
8061
|
const servable = recorded === null
|
|
7605
8062
|
|| (recorded.state === 'open' && cached.ord === recorded.ord)
|
|
7606
|
-
|| (recorded.state === 'none' &&
|
|
8063
|
+
|| (recorded.state === 'none' && run?.session.status === 'awaiting_human');
|
|
7607
8064
|
if (servable) {
|
|
7608
|
-
const offers = await offersAt(cached.ord,
|
|
8065
|
+
const offers = await offersAt(cached.ord, run);
|
|
7609
8066
|
if (offers === null)
|
|
7610
8067
|
return unavailable503();
|
|
7611
8068
|
return { runId: id, ...cached, ...offers };
|
|
@@ -7621,13 +8078,9 @@ runtime = {}) {
|
|
|
7621
8078
|
// cut of this assumed: it trades one read of the run's view for replaying an entire event history,
|
|
7622
8079
|
// and it was that skipped check which made a completed run answer 503 on any build without the
|
|
7623
8080
|
// binding (CI caught it) — an error where the honest, knowable answer was "no gate".
|
|
7624
|
-
|
|
7625
|
-
//
|
|
7626
|
-
|
|
7627
|
-
// the pause (its frame has not landed yet): read the run from a fold that starts now.
|
|
7628
|
-
if (recorded?.state === 'open' && run?.session.status !== 'awaiting_human') {
|
|
7629
|
-
run = await adapter.runView(id, { fresh: true });
|
|
7630
|
-
}
|
|
8081
|
+
// The view is read after the record, from the store as it is now (crew#1775), so a gate row the
|
|
8082
|
+
// record shows open is never beside an older view of its run: the engine writes both in one commit.
|
|
8083
|
+
const run = await runOf();
|
|
7631
8084
|
if (!run)
|
|
7632
8085
|
return reply.code(404).send({ error: 'Run not found' });
|
|
7633
8086
|
if (run.session.status !== 'awaiting_human') {
|
|
@@ -7691,7 +8144,10 @@ runtime = {}) {
|
|
|
7691
8144
|
});
|
|
7692
8145
|
// ── Elicitation (DES-002) ────────────────────────────────────────────────────
|
|
7693
8146
|
//
|
|
7694
|
-
// GET returns the current pending elicitation prompt for a run (display-store read)
|
|
8147
|
+
// GET returns the current pending elicitation prompt for a run (display-store read), or `null`
|
|
8148
|
+
// (a 200) when the run exists and has none open: "nothing open" is the normal answer for every
|
|
8149
|
+
// parked run a client polls, not an error (studio#984 logged one 404 per parked run per page load).
|
|
8150
|
+
// 404 stays for a run that does not exist. Every studio already reads "nothing open" as `null`.
|
|
7695
8151
|
// POST resolves it: the body carries the elicitationId to guard against stale tabs,
|
|
7696
8152
|
// the action (accept|decline|cancel), and — for accept — the operator's response.
|
|
7697
8153
|
app.get(`${V}/runs/:id/elicitation`, async (req, reply) => {
|
|
@@ -7701,7 +8157,7 @@ runtime = {}) {
|
|
|
7701
8157
|
// ("runId is specified more than once") from a redundant spread.
|
|
7702
8158
|
if (entry)
|
|
7703
8159
|
return entry;
|
|
7704
|
-
// Cache miss: check existence
|
|
8160
|
+
// Cache miss: check existence first — an unknown run is the only 404.
|
|
7705
8161
|
// Use sessions() (IDs only) — cheaper than sessionsDetail() on this read path.
|
|
7706
8162
|
const ids = await adapter.sessions();
|
|
7707
8163
|
if (!ids.includes(id))
|
|
@@ -7727,7 +8183,7 @@ runtime = {}) {
|
|
|
7727
8183
|
receivedAt: new Date(pending.created_at).toISOString(),
|
|
7728
8184
|
};
|
|
7729
8185
|
}
|
|
7730
|
-
return reply.code(
|
|
8186
|
+
return reply.code(200).type('application/json').send('null');
|
|
7731
8187
|
});
|
|
7732
8188
|
const ElicitationRespondSchema = z.strictObject({
|
|
7733
8189
|
/** Guards against stale-tab submissions: must match the current elicitation's id. */
|
|
@@ -8008,7 +8464,7 @@ runtime = {}) {
|
|
|
8008
8464
|
(status === 'all' || (status === 'retired') === (r.retired === true)) &&
|
|
8009
8465
|
// Undated rules (every rule on a pre-bump core-ts) are excluded once a bound is set.
|
|
8010
8466
|
withinDateRange(r.created_at, sinceSecs, untilSecs));
|
|
8011
|
-
return { rules };
|
|
8467
|
+
return { rules: rules.map((r) => ({ ...r, revision: ruleRevision(r) })) };
|
|
8012
8468
|
});
|
|
8013
8469
|
app.get(`${V}/governance/claims`, async () => {
|
|
8014
8470
|
const claims = await adapter.listConformanceClaims();
|
|
@@ -8207,10 +8663,15 @@ runtime = {}) {
|
|
|
8207
8663
|
requestType: 'ConformanceRule',
|
|
8208
8664
|
// 501: the body carries steering fields but the installed engine predates the
|
|
8209
8665
|
// steering model (wicked-core-ts < 0.7.5) and would silently drop them.
|
|
8210
|
-
statusCodes: [200, 400, 501],
|
|
8666
|
+
statusCodes: [200, 400, 409, 501],
|
|
8211
8667
|
},
|
|
8212
8668
|
},
|
|
8213
8669
|
}, async (req, reply) => {
|
|
8670
|
+
const header = req.headers['if-match'];
|
|
8671
|
+
if (header !== undefined && (typeof header !== 'string' || !/^(?:"[a-f0-9]{16}"|[a-f0-9]{16})(?![\s\S])/u.test(header))) {
|
|
8672
|
+
return reply.code(400).send({ error: 'If-Match must be one rule revision from GET /governance/rules' });
|
|
8673
|
+
}
|
|
8674
|
+
const expectedRevision = header?.replaceAll('"', '');
|
|
8214
8675
|
try {
|
|
8215
8676
|
const rule = req.body;
|
|
8216
8677
|
if (!adapter.steeringSupported() && rule !== null && typeof rule === 'object') {
|
|
@@ -8238,11 +8699,21 @@ runtime = {}) {
|
|
|
8238
8699
|
});
|
|
8239
8700
|
}
|
|
8240
8701
|
}
|
|
8241
|
-
await adapter.upsertConformanceRule(rule);
|
|
8702
|
+
await adapter.upsertConformanceRule(rule, expectedRevision);
|
|
8242
8703
|
audit.record('governance.rule.upserted', actorOf(req), { detail: { id: rule?.id } });
|
|
8243
|
-
|
|
8704
|
+
// The write succeeded even if its readback is unavailable; only report a revision we read.
|
|
8705
|
+
let revision;
|
|
8706
|
+
try {
|
|
8707
|
+
const current = (await adapter.listConformanceRules()).find((r) => r.id === rule.id);
|
|
8708
|
+
if (current !== undefined)
|
|
8709
|
+
revision = ruleRevision(current);
|
|
8710
|
+
}
|
|
8711
|
+
catch { /* Readback failure does not undo the successful write. */ }
|
|
8712
|
+
return { status: 'ok', revision };
|
|
8244
8713
|
}
|
|
8245
8714
|
catch (err) {
|
|
8715
|
+
if (err instanceof RuleChangedError)
|
|
8716
|
+
return reply.code(409).send({ code: 'rule_changed', error: message(err), revision: err.revision });
|
|
8246
8717
|
return reply.code(400).send({ error: message(err) });
|
|
8247
8718
|
}
|
|
8248
8719
|
});
|
|
@@ -8462,7 +8933,7 @@ runtime = {}) {
|
|
|
8462
8933
|
replacement: 'PUT /api/v1/presets/:name',
|
|
8463
8934
|
});
|
|
8464
8935
|
});
|
|
8465
|
-
// Save an inline script
|
|
8936
|
+
// Save an inline script under the state-home-derived scripts root and return its path.
|
|
8466
8937
|
// Tool-executor phases use the returned path as their command.
|
|
8467
8938
|
app.post(`${V}/scripts`, async (req, reply) => {
|
|
8468
8939
|
const body = req.body;
|
|
@@ -8694,6 +9165,45 @@ runtime = {}) {
|
|
|
8694
9165
|
return reply.code(404).send({ error: 'Requirement not found' });
|
|
8695
9166
|
return { requirement: detail };
|
|
8696
9167
|
});
|
|
9168
|
+
// wicked-core#1698: retire a requirement whose code was deleted (the engine flags it `unindexed`), so a re-map
|
|
9169
|
+
// stops listing it. The engine's own command does the write; the id is never reused.
|
|
9170
|
+
app.post(`${V}/repos/:id/requirements/:key/retire`, async (req, reply) => {
|
|
9171
|
+
const { id, key } = req.params;
|
|
9172
|
+
const repos = await adapter.listRepos();
|
|
9173
|
+
const repo = repos.find((r) => r.id === id);
|
|
9174
|
+
if (!repo)
|
|
9175
|
+
return reply.code(404).send({ error: `Repo ${id} not found` });
|
|
9176
|
+
let decodedKey;
|
|
9177
|
+
try {
|
|
9178
|
+
decodedKey = decodeURIComponent(key);
|
|
9179
|
+
}
|
|
9180
|
+
catch {
|
|
9181
|
+
return reply.code(400).send({ error: 'Malformed requirement key encoding' });
|
|
9182
|
+
}
|
|
9183
|
+
let outcome;
|
|
9184
|
+
try {
|
|
9185
|
+
outcome = await retireRequirement(repo, decodedKey, adapter);
|
|
9186
|
+
}
|
|
9187
|
+
catch (err) {
|
|
9188
|
+
const status = codeGraphErrorStatus(err);
|
|
9189
|
+
if (status !== null)
|
|
9190
|
+
return reply.code(status).send({ error: message(err) });
|
|
9191
|
+
return reply.code(500).send({ error: `${decodedKey} could not be retired: ${message(err)}` });
|
|
9192
|
+
}
|
|
9193
|
+
if (outcome === 'not_found')
|
|
9194
|
+
return reply.code(404).send({ error: 'Requirement not found' });
|
|
9195
|
+
if (outcome === 'not_unindexed') {
|
|
9196
|
+
return reply.code(409).send({
|
|
9197
|
+
error: `${decodedKey} is not listed as no longer in the code, so it cannot be retired. Only a requirement whose code was deleted can be. If its code was deleted, map ${repo.name} again, then retire it.`,
|
|
9198
|
+
});
|
|
9199
|
+
}
|
|
9200
|
+
if (outcome === 'engine_too_old') {
|
|
9201
|
+
return reply.code(409).send({
|
|
9202
|
+
error: 'The installed wicked-core cannot retire requirements yet. Update wicked-core, then try again.',
|
|
9203
|
+
});
|
|
9204
|
+
}
|
|
9205
|
+
return { retired: decodedKey };
|
|
9206
|
+
});
|
|
8697
9207
|
app.get(`${V}/repos/:id/graph`, { config: { manifest: { responseType: 'RepoGraphResponse', statusCodes: [200, 404, 409, 500, 503] } } }, async (req, reply) => {
|
|
8698
9208
|
const { id } = req.params;
|
|
8699
9209
|
const repos = await adapter.listRepos();
|
|
@@ -8786,7 +9296,7 @@ runtime = {}) {
|
|
|
8786
9296
|
return reply.code(404).send({ error: 'Code graph not built for this repo yet' });
|
|
8787
9297
|
}
|
|
8788
9298
|
try {
|
|
8789
|
-
//
|
|
9299
|
+
// crew#1556: join every page's dependents and freshness; other fields are the last page's.
|
|
8790
9300
|
return reply.send(await readBlastRadiusPages('wicked-estate', q.name.trim(), dbPath, { timeout: 30_000, cwd: repo.root_path }));
|
|
8791
9301
|
}
|
|
8792
9302
|
catch (err) {
|
|
@@ -9007,6 +9517,12 @@ runtime = {}) {
|
|
|
9007
9517
|
// additive `path` (api-types 0.38.0 `SettingsResponse.path?`; adjudicated §4.6 — `path`, not
|
|
9008
9518
|
// `settings_path`).
|
|
9009
9519
|
app.get(`${V}/settings`, async () => ({ settings: await adapter.getSettings(), path: settingsFilePath() }));
|
|
9520
|
+
// studio#1324: whether this daemon's port starts at login (`serve --install-service`), for Settings' status row. The
|
|
9521
|
+
// port is the one this daemon listens on (the default when it is not listening, as under inject).
|
|
9522
|
+
app.get(`${V}/settings/start-on-login`, { config: { manifest: { responseType: 'StartOnLoginStatus', statusCodes: [200] } } }, async () => {
|
|
9523
|
+
const bound = app.server.address();
|
|
9524
|
+
return startOnLoginStatus(bound !== null && typeof bound === 'object' ? bound.port : DEFAULT_DAEMON_PORT, runtime.startOnLogin?.platform, runtime.startOnLogin?.home);
|
|
9525
|
+
});
|
|
9010
9526
|
// The demo video's palette from the studio skin (operator 2026-10-14): read-only, derived from `studio.appearance`;
|
|
9011
9527
|
// garden's demo stage and interactive's re-cuts read it as their default colours.
|
|
9012
9528
|
app.get(`${V}/appearance/video-palette`, { config: { manifest: { responseType: 'VideoPaletteResponse', statusCodes: [200] } } }, async () => videoPalette((await adapter.getSettings())['studio.appearance']));
|
|
@@ -9096,6 +9612,9 @@ runtime = {}) {
|
|
|
9096
9612
|
.send({ error: 'workerStallMaxEscalations must be an integer between 1 and 10' });
|
|
9097
9613
|
}
|
|
9098
9614
|
}
|
|
9615
|
+
if (Object.hasOwn(patch, 'deliverAuthorNoreply') && typeof patch.deliverAuthorNoreply !== 'boolean') {
|
|
9616
|
+
return reply.code(400).send({ error: 'deliverAuthorNoreply must be a boolean' });
|
|
9617
|
+
}
|
|
9099
9618
|
// deliverIdentityLogin (crew#549): the login the deliver phase must push as. A typo here
|
|
9100
9619
|
// would be an identity the script can never match — every delivery would refuse — so an
|
|
9101
9620
|
// invalid value is a 400, never a silently-dropped key. `''` clears it (back to GH_ACCOUNT).
|
|
@@ -9267,6 +9786,7 @@ runtime = {}) {
|
|
|
9267
9786
|
'newWorkSeats',
|
|
9268
9787
|
'onboardingAutoCapture',
|
|
9269
9788
|
'deliverIdentityLogin',
|
|
9789
|
+
'deliverAuthorNoreply',
|
|
9270
9790
|
'deliverIdentityByRepo',
|
|
9271
9791
|
'baseSkillRef',
|
|
9272
9792
|
'baseSkillPolicy',
|
|
@@ -9369,12 +9889,24 @@ runtime = {}) {
|
|
|
9369
9889
|
args.kind_type = kindType;
|
|
9370
9890
|
if (state !== undefined)
|
|
9371
9891
|
args.state = state;
|
|
9892
|
+
let listed;
|
|
9372
9893
|
try {
|
|
9373
|
-
|
|
9894
|
+
listed = (await estateTool('proposal.list', args));
|
|
9374
9895
|
}
|
|
9375
9896
|
catch (err) {
|
|
9376
9897
|
return estateUpstreamError(reply, err);
|
|
9377
9898
|
}
|
|
9899
|
+
// crew#1261: a rejected row says who rejected it and why, when crew made that decision.
|
|
9900
|
+
const decided = await proposalDecisions.decisions();
|
|
9901
|
+
if (decided.size === 0 || !Array.isArray(listed?.proposals))
|
|
9902
|
+
return listed;
|
|
9903
|
+
return {
|
|
9904
|
+
...listed,
|
|
9905
|
+
proposals: listed.proposals.map((p) => {
|
|
9906
|
+
const decision = p.state === 'rejected' ? decided.get(p.id) : undefined;
|
|
9907
|
+
return decision !== undefined ? { ...p, decision } : p;
|
|
9908
|
+
}),
|
|
9909
|
+
};
|
|
9378
9910
|
});
|
|
9379
9911
|
// POST /proposals {content, project?, source?} → proposal.submit → 201 { id } (api-types 0.54.0).
|
|
9380
9912
|
// A skin files ONE preference into the same review queue — studio's "takes": the person picks one
|
|
@@ -9497,7 +10029,9 @@ runtime = {}) {
|
|
|
9497
10029
|
}
|
|
9498
10030
|
if (policyReach === undefined && (edit.data.content !== undefined || edit.data.reach !== undefined)) {
|
|
9499
10031
|
try {
|
|
9500
|
-
const done = await approveEdited(editTool, id, edit.data, (runId) => projects.index.projectOf(runId)
|
|
10032
|
+
const done = await approveEdited(editTool, id, edit.data, (runId) => projects.index.projectOf(runId),
|
|
10033
|
+
// crew#1261: the original replaced by the copy, or a copy withdrawn, is crew's decision on the person's behalf.
|
|
10034
|
+
(pid, reason, copy) => recordProposalDecision(audit, actorOf(req), pid, reason, copy));
|
|
9501
10035
|
return reply.code(done.status).send(done.body);
|
|
9502
10036
|
}
|
|
9503
10037
|
catch (err) {
|
|
@@ -9522,7 +10056,9 @@ runtime = {}) {
|
|
|
9522
10056
|
// crew#1546: an edited learning's replacement whose learning is gone is stale: refused and rejected, never approved,
|
|
9523
10057
|
// so no crash window can bring retired words back (accept-with-edit checks the same in `approveEdited`).
|
|
9524
10058
|
try {
|
|
9525
|
-
const stale = row?.kind_type === 'memory'
|
|
10059
|
+
const stale = row?.kind_type === 'memory'
|
|
10060
|
+
? await refuseStaleReplacement(estateTool, id, row.payload, (pid) => recordProposalDecision(audit, actorOf(req), pid, 'stale'))
|
|
10061
|
+
: null;
|
|
9526
10062
|
if (stale !== null)
|
|
9527
10063
|
return reply.code(409).send({ error: stale, code: 'stale_replacement' });
|
|
9528
10064
|
}
|
|
@@ -9607,10 +10143,18 @@ runtime = {}) {
|
|
|
9607
10143
|
return landFailed(`${new SteeringUnsupportedError('Landing an approved policy proposal').message} — the ` +
|
|
9608
10144
|
`installed engine would silently drop the rule's steering fields; upgrade wicked-core-ts (>= 0.7.5)`);
|
|
9609
10145
|
}
|
|
9610
|
-
// A proposal
|
|
10146
|
+
// A proposal's `project` facet resolves to a known project (crew#1774); one that names none keeps the project of
|
|
10147
|
+
// the run that filed it.
|
|
9611
10148
|
const runId = policyRow.provenance?.['run_id'];
|
|
9612
10149
|
const runProject = typeof runId === 'string' && runId !== '' ? projects.index.projectOf(runId) : undefined;
|
|
9613
|
-
|
|
10150
|
+
let knownProjects;
|
|
10151
|
+
try {
|
|
10152
|
+
knownProjects = await adapter.projectList();
|
|
10153
|
+
}
|
|
10154
|
+
catch (err) {
|
|
10155
|
+
return landFailed(`the projects could not be read to resolve the rule's project (${message(err)})`);
|
|
10156
|
+
}
|
|
10157
|
+
const built = policyProposalToRule(id, policyRow.kind_type, policyRow.payload, isStringRecord(policyRow.facets) ? policyRow.facets : undefined, { ...(runProject !== undefined ? { runProject } : {}), ...(policyReach !== undefined ? { reach: policyReach } : {}), projects: knownProjects });
|
|
9614
10158
|
if ('error' in built) {
|
|
9615
10159
|
return landFailed(built.error);
|
|
9616
10160
|
}
|
|
@@ -9677,6 +10221,8 @@ runtime = {}) {
|
|
|
9677
10221
|
catch (err) {
|
|
9678
10222
|
return estateUpstreamError(reply, err);
|
|
9679
10223
|
}
|
|
10224
|
+
// crew#1261: turned down by this caller (a person's rejection when it is a person).
|
|
10225
|
+
recordProposalDecision(audit, actorOf(req), id.trim(), 'rejected');
|
|
9680
10226
|
// A policy proposal's rule lands before its approval, so a still-pending proposal may already
|
|
9681
10227
|
// have a live rule (a crash or an unconfirmed approve in between): rejecting it withdraws it.
|
|
9682
10228
|
const withdrawn = await withdrawLandedRule(adapter, id.trim());
|
|
@@ -9705,11 +10251,14 @@ runtime = {}) {
|
|
|
9705
10251
|
// • RETIRE comes in two widths. `POST /memory/retire { scope_prefix }` is SUBTREE-scoped:
|
|
9706
10252
|
// `memory.erase {scope_prefix}` hard-deletes EVERY memory whose scope equals or descends from
|
|
9707
10253
|
// the prefix, and refuses an empty prefix (a total-wipe guard) — the UI must show the operator
|
|
9708
|
-
// the subtree. `POST /memory/retire-item { memory_id }` (studio#206)
|
|
9709
|
-
// through `memory.
|
|
9710
|
-
//
|
|
10254
|
+
// the subtree. `POST /memory/retire-item { memory_id }` (studio#206) SOFT-retires exactly ONE
|
|
10255
|
+
// memory through `memory.retire {id}` (crew#1697, wicked-estate#552): hidden from recall and the
|
|
10256
|
+
// browse, kept with its id, listed by `GET /memory?retired=1`, restored by `POST /memory/unretire`.
|
|
10257
|
+
// `POST /memory/erase-item { memory_id }` deletes one for good (`memory.erase {id}`,
|
|
10258
|
+
// wicked-estate#188), the right-to-erasure path. An estate without the tool refuses the call
|
|
10259
|
+
// without changing anything, and the route answers 501 naming the upgrade — never a fallback.
|
|
9711
10260
|
// GET /memory?query=&scope_prefix=&facets=<json>&limit= → memory.list + post-filter → { memories }.
|
|
9712
|
-
app.get(`${V}/memory`, { config: { manifest: { responseType: 'ListMemoriesResponse', statusCodes: [200, 400, 502] } } }, async (req, reply) => {
|
|
10261
|
+
app.get(`${V}/memory`, { config: { manifest: { responseType: 'ListMemoriesResponse', statusCodes: [200, 400, 501, 502] } } }, async (req, reply) => {
|
|
9713
10262
|
const q = req.query;
|
|
9714
10263
|
// `scope_prefix` is the ONLY estate-side argument to memory.list (a subtree filter; blank /
|
|
9715
10264
|
// omitted = every memory). Forward verbatim WHEN PRESENT — a blank value is meaningful
|
|
@@ -9718,6 +10267,14 @@ runtime = {}) {
|
|
|
9718
10267
|
const scopePrefix = firstQueryValue(q.scope_prefix);
|
|
9719
10268
|
if (scopePrefix !== undefined)
|
|
9720
10269
|
args.scope_prefix = scopePrefix;
|
|
10270
|
+
// crew#1697: `retired=1` lists the soft-retired memories (`memory.list {retired: true}`) instead.
|
|
10271
|
+
const rawRetired = firstQueryValue(q.retired)?.trim().toLowerCase();
|
|
10272
|
+
if (rawRetired !== undefined && !['1', 'true', '0', 'false'].includes(rawRetired)) {
|
|
10273
|
+
return reply.code(400).send({ error: '`retired` must be 1, true, 0 or false' });
|
|
10274
|
+
}
|
|
10275
|
+
const retired = rawRetired === '1' || rawRetired === 'true';
|
|
10276
|
+
if (retired)
|
|
10277
|
+
args.retired = true;
|
|
9721
10278
|
// `facets` narrows the COMPLETE list crew-side (after the estate fetch) to memories carrying
|
|
9722
10279
|
// every given axis:value (a management filter, NOT a recall intent). Present-but-blank is a
|
|
9723
10280
|
// client error
|
|
@@ -9778,6 +10335,14 @@ runtime = {}) {
|
|
|
9778
10335
|
throw new EstateMcpError('memory.list returned an unexpected shape');
|
|
9779
10336
|
}
|
|
9780
10337
|
let memories = items.map(shapeMemoryItem);
|
|
10338
|
+
// An estate before wicked-estate#552 ignores `retired` and lists the LIVE memories: a row without
|
|
10339
|
+
// `retired_at` in a retired list is that, never shown as retired.
|
|
10340
|
+
if (retired && memories.some((m) => m.retired_at === undefined)) {
|
|
10341
|
+
return reply.code(501).send({
|
|
10342
|
+
error: 'this wicked-estate cannot list retired memories (it needs wicked-estate#552); upgrade wicked-estate-mcp',
|
|
10343
|
+
code: 'estate_upgrade_required',
|
|
10344
|
+
});
|
|
10345
|
+
}
|
|
9781
10346
|
if (query !== '')
|
|
9782
10347
|
memories = memories.filter((m) => m.content.toLowerCase().includes(query));
|
|
9783
10348
|
if (facetFilter !== undefined) {
|
|
@@ -9794,6 +10359,9 @@ runtime = {}) {
|
|
|
9794
10359
|
return body;
|
|
9795
10360
|
}
|
|
9796
10361
|
catch (err) {
|
|
10362
|
+
if (retired && estateLacksTool(err)) {
|
|
10363
|
+
return reply.code(501).send(estateUpgrade('cannot list retired memories', '#552', 'nothing was changed'));
|
|
10364
|
+
}
|
|
9797
10365
|
return estateUpstreamError(reply, err);
|
|
9798
10366
|
}
|
|
9799
10367
|
});
|
|
@@ -9846,15 +10414,15 @@ runtime = {}) {
|
|
|
9846
10414
|
return estateUpstreamError(reply, err);
|
|
9847
10415
|
}
|
|
9848
10416
|
});
|
|
9849
|
-
// POST /memory/retire-item { memory_id } → memory.
|
|
9850
|
-
// exactly ONE memory: the id is the only target sent, so no reading of it can
|
|
9851
|
-
// 404 when estate holds no memory with that id (it
|
|
9852
|
-
// wicked-estate#
|
|
10417
|
+
// POST /memory/retire-item { memory_id } → memory.retire { id } → { retired: 1 } (studio#206; soft since
|
|
10418
|
+
// crew#1697). Hides exactly ONE memory, kept with its id: the id is the only target sent, so no reading of it can
|
|
10419
|
+
// widen to a subtree. 404 when estate holds no live memory with that id (it retired 0). 501 when the estate
|
|
10420
|
+
// predates soft retire (wicked-estate#552): it refuses the unknown tool, changing nothing — never an erase instead.
|
|
9853
10421
|
app.post(`${V}/memory/retire-item`, {
|
|
9854
10422
|
config: {
|
|
9855
10423
|
manifest: {
|
|
9856
10424
|
requestType: 'RetireMemoryItemBody',
|
|
9857
|
-
responseType: '
|
|
10425
|
+
responseType: 'RetireMemoryItemResponse',
|
|
9858
10426
|
statusCodes: [200, 400, 404, 501, 502],
|
|
9859
10427
|
},
|
|
9860
10428
|
},
|
|
@@ -9866,27 +10434,132 @@ runtime = {}) {
|
|
|
9866
10434
|
const memoryId = parsed.data.memory_id.trim();
|
|
9867
10435
|
if (memoryId === '')
|
|
9868
10436
|
return reply.code(400).send({ error: '`memory_id` must not be empty' });
|
|
10437
|
+
// An edit in flight ends by erasing the memory it replaces (retired or not), so a retire that slipped in
|
|
10438
|
+
// between would be erased for good: the two take turns on one memory (codex review).
|
|
10439
|
+
if (memoryEditsInFlight.has(memoryId)) {
|
|
10440
|
+
return reply.code(409).send({ error: `memory ${memoryId} is being edited; retire it once the edit is done` });
|
|
10441
|
+
}
|
|
10442
|
+
memoryEditsInFlight.add(memoryId);
|
|
9869
10443
|
try {
|
|
9870
|
-
const
|
|
9871
|
-
|
|
9872
|
-
|
|
9873
|
-
|
|
9874
|
-
|
|
9875
|
-
|
|
10444
|
+
const count = oneMemoryCount(await estateTool('memory.retire', { id: memoryId }), 'memory.retire', 'retired_count');
|
|
10445
|
+
if (count === 0)
|
|
10446
|
+
return reply.code(404).send({ error: `no live memory ${memoryId}` });
|
|
10447
|
+
const body = { retired: 1 };
|
|
10448
|
+
return body;
|
|
10449
|
+
}
|
|
10450
|
+
catch (err) {
|
|
10451
|
+
if (estateLacksTool(err))
|
|
10452
|
+
return reply.code(501).send(estateUpgrade('cannot retire a memory and restore it later', '#552', 'nothing was changed'));
|
|
10453
|
+
return estateUpstreamError(reply, err);
|
|
10454
|
+
}
|
|
10455
|
+
finally {
|
|
10456
|
+
memoryEditsInFlight.delete(memoryId);
|
|
10457
|
+
}
|
|
10458
|
+
});
|
|
10459
|
+
// POST /memory/unretire { memory_id } → memory.unretire { id } → { restored: 1 } (crew#1697). Restores ONE
|
|
10460
|
+
// retired memory with the same id. 404 when no retired memory has that id; 501 on an estate before #552.
|
|
10461
|
+
app.post(`${V}/memory/unretire`, {
|
|
10462
|
+
config: {
|
|
10463
|
+
manifest: {
|
|
10464
|
+
requestType: 'UnretireMemoryBody',
|
|
10465
|
+
responseType: 'UnretireMemoryResponse',
|
|
10466
|
+
statusCodes: [200, 400, 404, 501, 502],
|
|
10467
|
+
},
|
|
10468
|
+
},
|
|
10469
|
+
}, async (req, reply) => {
|
|
10470
|
+
const parsed = RetireMemoryItemSchema.safeParse(req.body);
|
|
10471
|
+
if (!parsed.success) {
|
|
10472
|
+
return reply.code(400).send(invalidBody(parsed.error, 'Invalid restore request'));
|
|
10473
|
+
}
|
|
10474
|
+
const memoryId = parsed.data.memory_id.trim();
|
|
10475
|
+
if (memoryId === '')
|
|
10476
|
+
return reply.code(400).send({ error: '`memory_id` must not be empty' });
|
|
10477
|
+
try {
|
|
10478
|
+
const count = oneMemoryCount(await estateTool('memory.unretire', { id: memoryId }), 'memory.unretire', 'restored_count');
|
|
10479
|
+
if (count === 0)
|
|
10480
|
+
return reply.code(404).send({ error: `no retired memory ${memoryId}` });
|
|
10481
|
+
const body = { restored: 1 };
|
|
10482
|
+
return body;
|
|
10483
|
+
}
|
|
10484
|
+
catch (err) {
|
|
10485
|
+
if (estateLacksTool(err))
|
|
10486
|
+
return reply.code(501).send(estateUpgrade('cannot restore a retired memory', '#552', 'nothing was changed'));
|
|
10487
|
+
return estateUpstreamError(reply, err);
|
|
10488
|
+
}
|
|
10489
|
+
});
|
|
10490
|
+
// POST /memory/erase-item { memory_id } → memory.erase { id } → { erased: 1 } (crew#1697; the hard delete
|
|
10491
|
+
// `retire-item` was before it went soft). Deletes ONE memory for good, live or retired. 404 when estate holds no
|
|
10492
|
+
// memory with that id; 501 when the estate predates wicked-estate#188 (it refuses an id-only erase, deleting nothing).
|
|
10493
|
+
app.post(`${V}/memory/erase-item`, {
|
|
10494
|
+
config: {
|
|
10495
|
+
manifest: {
|
|
10496
|
+
requestType: 'EraseMemoryItemBody',
|
|
10497
|
+
responseType: 'RetireMemoryResponse',
|
|
10498
|
+
statusCodes: [200, 400, 404, 501, 502],
|
|
10499
|
+
},
|
|
10500
|
+
},
|
|
10501
|
+
}, async (req, reply) => {
|
|
10502
|
+
const parsed = RetireMemoryItemSchema.safeParse(req.body);
|
|
10503
|
+
if (!parsed.success) {
|
|
10504
|
+
return reply.code(400).send(invalidBody(parsed.error, 'Invalid erase request'));
|
|
10505
|
+
}
|
|
10506
|
+
const memoryId = parsed.data.memory_id.trim();
|
|
10507
|
+
if (memoryId === '')
|
|
10508
|
+
return reply.code(400).send({ error: '`memory_id` must not be empty' });
|
|
10509
|
+
try {
|
|
10510
|
+
const count = oneMemoryCount(await estateTool('memory.erase', { id: memoryId }), 'memory.erase', 'deleted_count');
|
|
10511
|
+
if (count === 0)
|
|
9876
10512
|
return reply.code(404).send({ error: `no memory ${memoryId}` });
|
|
9877
|
-
if (deleted !== 1) {
|
|
9878
|
-
// An id names one memory; any other count is estate misbehaving, and it is reported as such.
|
|
9879
|
-
return reply.code(502).send({ error: `memory.erase {id} removed ${deleted} memories, expected 1` });
|
|
9880
|
-
}
|
|
9881
10513
|
const body = { erased: 1 };
|
|
9882
10514
|
return body;
|
|
9883
10515
|
}
|
|
9884
10516
|
catch (err) {
|
|
9885
10517
|
if (err instanceof EstateMcpError && err.code === -32602 && ESTATE_NO_ERASE_BY_ID.test(err.message)) {
|
|
9886
|
-
return reply.code(501).send(
|
|
9887
|
-
|
|
9888
|
-
|
|
9889
|
-
|
|
10518
|
+
return reply.code(501).send(estateUpgrade('cannot erase one memory by id', '#188', 'nothing was deleted'));
|
|
10519
|
+
}
|
|
10520
|
+
return estateUpstreamError(reply, err);
|
|
10521
|
+
}
|
|
10522
|
+
});
|
|
10523
|
+
// POST /knowledge/forget { id | source | scope_prefix, confirm_erase_all? } → knowledge.forget →
|
|
10524
|
+
// { forgotten, skipped_live_source } (crew#1697, wicked-estate#553). Hard-deletes document knowledge only. Exactly
|
|
10525
|
+
// one target, checked here (400 before any spawn); estate's own -32602 is a 400 too. A live source's structure
|
|
10526
|
+
// named by id is refused by estate (409: it is refreshed through its source); an estate before #553 is a 501.
|
|
10527
|
+
app.post(`${V}/knowledge/forget`, {
|
|
10528
|
+
config: {
|
|
10529
|
+
manifest: {
|
|
10530
|
+
requestType: 'ForgetKnowledgeBody',
|
|
10531
|
+
responseType: 'ForgetKnowledgeResponse',
|
|
10532
|
+
statusCodes: [200, 400, 409, 501, 502],
|
|
10533
|
+
},
|
|
10534
|
+
},
|
|
10535
|
+
}, async (req, reply) => {
|
|
10536
|
+
const parsed = ForgetKnowledgeSchema.safeParse(req.body);
|
|
10537
|
+
if (!parsed.success) {
|
|
10538
|
+
return reply.code(400).send(invalidBody(parsed.error, 'Invalid forget request'));
|
|
10539
|
+
}
|
|
10540
|
+
const { confirm_erase_all: confirm, ...targets } = parsed.data;
|
|
10541
|
+
const named = Object.entries(targets).filter(([, v]) => v !== undefined);
|
|
10542
|
+
if (named.length !== 1) {
|
|
10543
|
+
return reply.code(400).send({ error: 'give exactly one of `id`, `source` or `scope_prefix`' });
|
|
10544
|
+
}
|
|
10545
|
+
const [field, value] = named[0];
|
|
10546
|
+
if (value.trim() === '' && !(field === 'scope_prefix' && value === '' && confirm === true)) {
|
|
10547
|
+
return reply.code(400).send({ error: `\`${field}\` must not be empty (forgetting everything is \`scope_prefix: ""\` with \`confirm_erase_all: true\`)` });
|
|
10548
|
+
}
|
|
10549
|
+
try {
|
|
10550
|
+
const raw = await estateTool('knowledge.forget', { [field]: value, ...(confirm !== undefined ? { confirm_erase_all: confirm } : {}) });
|
|
10551
|
+
const r = typeof raw === 'object' && raw !== null ? raw : {};
|
|
10552
|
+
if (typeof r['forgotten'] !== 'number' || typeof r['skipped_live_source'] !== 'number') {
|
|
10553
|
+
throw new EstateMcpError('knowledge.forget returned an unexpected shape');
|
|
10554
|
+
}
|
|
10555
|
+
const body = { forgotten: r['forgotten'], skipped_live_source: r['skipped_live_source'] };
|
|
10556
|
+
return body;
|
|
10557
|
+
}
|
|
10558
|
+
catch (err) {
|
|
10559
|
+
if (estateLacksTool(err))
|
|
10560
|
+
return reply.code(501).send(estateUpgrade('cannot forget knowledge', '#553', 'nothing was deleted'));
|
|
10561
|
+
if (err instanceof EstateMcpError && ESTATE_FORGET_REFUSED.test(err.message)) {
|
|
10562
|
+
return reply.code(409).send({ error: err.message });
|
|
9890
10563
|
}
|
|
9891
10564
|
return estateUpstreamError(reply, err);
|
|
9892
10565
|
}
|
|
@@ -9919,7 +10592,7 @@ runtime = {}) {
|
|
|
9919
10592
|
if (content === '')
|
|
9920
10593
|
return reply.code(400).send({ error: '`content` must not be empty' });
|
|
9921
10594
|
if (memoryEditsInFlight.has(memoryId)) {
|
|
9922
|
-
return reply.code(409).send({ error: `memory ${memoryId} is already being edited` });
|
|
10595
|
+
return reply.code(409).send({ error: `memory ${memoryId} is already being edited or retired` });
|
|
9923
10596
|
}
|
|
9924
10597
|
memoryEditsInFlight.add(memoryId);
|
|
9925
10598
|
// Every estate call here is crew's own (no client argument reaches estate unchecked), so an
|
|
@@ -9947,10 +10620,14 @@ runtime = {}) {
|
|
|
9947
10620
|
: [];
|
|
9948
10621
|
});
|
|
9949
10622
|
};
|
|
9950
|
-
/** Reject these proposals; true only when the queue is read back with none of them pending.
|
|
9951
|
-
|
|
9952
|
-
|
|
9953
|
-
|
|
10623
|
+
/** Reject these proposals; true only when the queue is read back with none of them pending. Each rejection
|
|
10624
|
+
* that happened is recorded as crew's (crew#1261): `stale` for a superseded replacement, `withdrawn` for one
|
|
10625
|
+
* this edit filed itself and is taking back. */
|
|
10626
|
+
const withdraw = async (ids, reason = 'withdrawn') => {
|
|
10627
|
+
for (const id of ids) {
|
|
10628
|
+
if (await estateTool('proposal.reject', { id }).then(() => true, () => false))
|
|
10629
|
+
recordProposalDecision(audit, actorOf(req), id, reason);
|
|
10630
|
+
}
|
|
9954
10631
|
try {
|
|
9955
10632
|
const still = new Set((await pendingMemoryProposals()).map((q) => q.id));
|
|
9956
10633
|
return ids.every((id) => !still.has(id));
|
|
@@ -10002,7 +10679,7 @@ runtime = {}) {
|
|
|
10002
10679
|
catch (err) {
|
|
10003
10680
|
return { status: 502, error: `reading the approve queue failed (${message(err)}); nothing changed` };
|
|
10004
10681
|
}
|
|
10005
|
-
if (superseded.length > 0 && !(await withdraw(superseded))) {
|
|
10682
|
+
if (superseded.length > 0 && !(await withdraw(superseded, 'stale'))) {
|
|
10006
10683
|
return { status: 502, error: `an earlier replacement of ${old.id} (${superseded.join(', ')}) is still pending and could not be rejected; reject it on the approve page first. Nothing changed` };
|
|
10007
10684
|
}
|
|
10008
10685
|
let pid = null;
|
|
@@ -10267,8 +10944,10 @@ runtime = {}) {
|
|
|
10267
10944
|
registerTeamRoutes(app, adapter, security, {
|
|
10268
10945
|
exclusive: decideExclusively,
|
|
10269
10946
|
judge: gateForDecision,
|
|
10270
|
-
|
|
10271
|
-
|
|
10947
|
+
expect: expectFor,
|
|
10948
|
+
changed: gateChangedRefusal,
|
|
10949
|
+
// crew#1157 / crew#1259: these chat runs may not add a step that could write.
|
|
10950
|
+
readOnlyRefusal: (runId, plan) => chatPlanRefusal(runId, { plan }),
|
|
10272
10951
|
});
|
|
10273
10952
|
// ── Campaigns (crew#342 + TH-9) — the engine's durable Run-DAG scheduler over REST ──────────
|
|
10274
10953
|
// Progress streams as campaign* CoreEvents on the existing allowlist-free /ws relay; these
|
|
@@ -10610,7 +11289,7 @@ runtime = {}) {
|
|
|
10610
11289
|
// Bounded by what is left of the snapshot's budget too (a slow start must not push it past 8 s):
|
|
10611
11290
|
// the assembly after the infra probes keeps about 1.5 s.
|
|
10612
11291
|
const clusterP = (containerFloor ? clusterReader.read(Math.min(CLUSTER_TIMEOUT_MS, left() - 1_500)) : Promise.resolve(null))
|
|
10613
|
-
.then((read) => clusterRows(read, containerFloor, clusterStarted));
|
|
11292
|
+
.then((read) => clusterRows(read, containerFloor, clusterStarted, clusterReader.engine()));
|
|
10614
11293
|
const infraP = Promise.all([
|
|
10615
11294
|
clusterP.then((rows) => rows.gateway),
|
|
10616
11295
|
brokerP,
|
|
@@ -10859,6 +11538,29 @@ runtime = {}) {
|
|
|
10859
11538
|
actorOf: (req) => actorOf(req).id,
|
|
10860
11539
|
log: (m) => app.log.warn(m),
|
|
10861
11540
|
});
|
|
11541
|
+
const proposalPacketDeps = {
|
|
11542
|
+
runs: chatContextDeps.runs,
|
|
11543
|
+
brief: (view) => buildRunBrief(view, { workOutput: chatContextDeps.workOutput, ...(chatContextDeps.acceptanceLine !== undefined ? { acceptanceLine: chatContextDeps.acceptanceLine } : {}) }),
|
|
11544
|
+
docsRoot: chatContextDeps.docsRoot,
|
|
11545
|
+
attachment: (chatId, id) => {
|
|
11546
|
+
const hit = chatAttachments.resolve(chatId, [id])[0];
|
|
11547
|
+
return hit === undefined ? null : { name: hit.name, path: hit.path };
|
|
11548
|
+
},
|
|
11549
|
+
// The exact brief a turn was given, from the live chat's scratch root, beneath it (no link followed), only when
|
|
11550
|
+
// its bytes still hash to what the turn recorded (A1's binding). Gone after the chat ends or the daemon restarts.
|
|
11551
|
+
contextBrief: (chatId, relPath, sha) => {
|
|
11552
|
+
const cwd = chatScopes.get(chatId)?.cwd;
|
|
11553
|
+
if (cwd === undefined)
|
|
11554
|
+
return null;
|
|
11555
|
+
try {
|
|
11556
|
+
const data = readBeneath(realpathSync(cwd), relPath, BRIEF_COPY_MAX).data;
|
|
11557
|
+
return sha256Hex(data) === sha ? data : null;
|
|
11558
|
+
}
|
|
11559
|
+
catch {
|
|
11560
|
+
return null;
|
|
11561
|
+
}
|
|
11562
|
+
},
|
|
11563
|
+
};
|
|
10862
11564
|
// A3: the real `create` launcher (§4.3 steps 2-3): one document and one run per proposal identity.
|
|
10863
11565
|
if (realRefine) {
|
|
10864
11566
|
// A5 (DES §6): the refine launcher — the attempt on the document's binding, then the chat seam's bound refine with the
|
|
@@ -10868,6 +11570,8 @@ runtime = {}) {
|
|
|
10868
11570
|
runExists: async (runId) => (await adapter.sessions()).includes(runId),
|
|
10869
11571
|
docsRoot: (projectId) => projectDocsRoot(adapter, projectSettings, projectId),
|
|
10870
11572
|
launchBound: runtime.launchBoundRefine,
|
|
11573
|
+
packetDeps: proposalPacketDeps,
|
|
11574
|
+
chatIdOf: (chatId, instance) => (chatHistory === null ? chatId : chatHistory.idOfInstance(chatId, instance)),
|
|
10871
11575
|
...(runtime.fenceBoundDraft !== undefined ? { fence: runtime.fenceBoundDraft } : {}),
|
|
10872
11576
|
records: (chatId) => chatHistory?.messages(chatId) ?? chatTranscripts?.read(chatId) ?? [],
|
|
10873
11577
|
instanceOf: (chatId) => chatHistory?.stateOf(chatId)?.instance ?? null,
|
|
@@ -10914,29 +11618,7 @@ runtime = {}) {
|
|
|
10914
11618
|
const seed = CATALOG_SEEDS.find((c) => c.id === entry);
|
|
10915
11619
|
return seed !== undefined && seed.launch.kind === 'document' ? seed.launch.style : 'web';
|
|
10916
11620
|
},
|
|
10917
|
-
packetDeps:
|
|
10918
|
-
runs: chatContextDeps.runs,
|
|
10919
|
-
brief: (view) => buildRunBrief(view, { workOutput: chatContextDeps.workOutput, ...(chatContextDeps.acceptanceLine !== undefined ? { acceptanceLine: chatContextDeps.acceptanceLine } : {}) }),
|
|
10920
|
-
docsRoot: chatContextDeps.docsRoot,
|
|
10921
|
-
attachment: (chatId, id) => {
|
|
10922
|
-
const hit = chatAttachments.resolve(chatId, [id])[0];
|
|
10923
|
-
return hit === undefined ? null : { name: hit.name, path: hit.path };
|
|
10924
|
-
},
|
|
10925
|
-
// The exact brief a turn was given, from the live chat's scratch root, beneath it (no link followed), only when
|
|
10926
|
-
// its bytes still hash to what the turn recorded (A1's binding). Gone after the chat ends or the daemon restarts.
|
|
10927
|
-
contextBrief: (chatId, relPath, sha) => {
|
|
10928
|
-
const cwd = chatScopes.get(chatId)?.cwd;
|
|
10929
|
-
if (cwd === undefined)
|
|
10930
|
-
return null;
|
|
10931
|
-
try {
|
|
10932
|
-
const data = readBeneath(realpathSync(cwd), relPath, BRIEF_COPY_MAX).data;
|
|
10933
|
-
return sha256Hex(data) === sha ? data : null;
|
|
10934
|
-
}
|
|
10935
|
-
catch {
|
|
10936
|
-
return null;
|
|
10937
|
-
}
|
|
10938
|
-
},
|
|
10939
|
-
},
|
|
11621
|
+
packetDeps: proposalPacketDeps,
|
|
10940
11622
|
log: (m) => app.log.warn(m),
|
|
10941
11623
|
}));
|
|
10942
11624
|
}
|
|
@@ -10946,6 +11628,7 @@ runtime = {}) {
|
|
|
10946
11628
|
// name forever — studio#119's ghost). One static segment more specific than the proxy's
|
|
10947
11629
|
// wildcard, so the proxy stays pure transport for everything else.
|
|
10948
11630
|
registerInteractiveDocDelete(app, adapter, {
|
|
11631
|
+
admitDocument: (ref, fn) => chatProposals.admitDocument(ref, fn),
|
|
10949
11632
|
settings: projectSettings,
|
|
10950
11633
|
pool: interactiveBridges,
|
|
10951
11634
|
audit,
|
|
@@ -11017,7 +11700,8 @@ runtime = {}) {
|
|
|
11017
11700
|
sessionsDetail: () => adapter.sessionsDetail(),
|
|
11018
11701
|
workOutput: (unitId) => adapter.workOutput(unitId),
|
|
11019
11702
|
projectList: () => adapter.projectList(),
|
|
11020
|
-
|
|
11703
|
+
// crew#1744: the repo search indexes each repo's remote, so it reads the same `git_url` GET /repos shows.
|
|
11704
|
+
listRepos: () => repoOrigins.list(() => adapter.listRepos()),
|
|
11021
11705
|
listRules: () => adapter.listConformanceRules(),
|
|
11022
11706
|
projectOf: (id) => projects.index.projectOf(id),
|
|
11023
11707
|
runFacts: runTimingIndex,
|
|
@@ -11038,9 +11722,9 @@ runtime = {}) {
|
|
|
11038
11722
|
log: (m) => app.log.warn(m),
|
|
11039
11723
|
});
|
|
11040
11724
|
registerSearchRoutes(app, search);
|
|
11041
|
-
const runEvalsPrepare = async (input) => {
|
|
11042
|
-
await prepareRunEvalsLaunch(input, () => runAndRecord(defaultEvalDeps, { project:
|
|
11725
|
+
const runEvalsPrepare = async (input, scope = { project: null }) => {
|
|
11726
|
+
await prepareRunEvalsLaunch(input, () => runAndRecord(defaultEvalDeps, { project: scope.project, baseline: false, ...(scope.suites !== undefined ? { suites: scope.suites } : {}), id: randomUUID(), now: new Date() }), runtime.evalRunsDir, scope);
|
|
11043
11727
|
};
|
|
11044
|
-
return { decideGate, decisions, chatRecorder, considerations, search, decorateRun, runEvalsPrepare, chatProposals, proposalLaunchers };
|
|
11728
|
+
return { exclusive: decideExclusively, decideGate, decisions, chatRecorder, considerations, search, decorateRun, runEvalsPrepare, chatProposals, proposalLaunchers };
|
|
11045
11729
|
}
|
|
11046
11730
|
//# sourceMappingURL=routes.js.map
|