@moretea-labs/forge 1.5.1 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +2 -0
- package/CHANGELOG.md +46 -0
- package/CLAUDE.md +2 -0
- package/DESIGN.md +7 -2
- package/README.md +4 -4
- package/README.zh-CN.md +2 -2
- package/SKILL.md +2 -2
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/agents/openai.yaml +1 -1
- package/assets/hooks/hook-input.sh +11 -8
- package/assets/hooks/lib/session-state.sh +10 -7
- package/assets/hooks/lib/workflow-state.sh +13 -177
- package/assets/hooks/post-tool-observer.sh +8 -2
- package/assets/hooks/pre-edit-guard.sh +8 -39
- package/assets/hooks/prompt-guard.sh +7 -83
- package/assets/hooks/session-start-context.sh +56 -1
- package/assets/partials/05-workflow.partial.md +1 -1
- package/assets/partials-agents/03-orchestration.partial.md +1 -1
- package/assets/plugin-registry.v1.json +54 -3
- package/assets/reference-configs/document-generation.md +1 -1
- package/assets/reference-configs/harness-overview.md +1 -1
- package/assets/reference-configs/hook-operations.md +1 -1
- package/assets/reference-configs/sprint-contracts.md +3 -3
- package/assets/skill-version.json +2 -2
- package/assets/templates/contract.template.md +2 -7
- package/assets/templates/helpers/capture-plan.sh +2 -2
- package/assets/templates/helpers/check-task-workflow.sh +4 -4
- package/assets/templates/helpers/contract-worktree.sh +1 -21
- package/assets/templates/helpers/ensure-task-workflow.sh +13 -38
- package/assets/templates/helpers/migrate-project-template.sh +22 -45
- package/assets/templates/helpers/new-plan.sh +1 -1
- package/assets/templates/helpers/plan-to-todo.sh +12 -37
- package/assets/templates/helpers/ship-worktrees.sh +2 -29
- package/assets/templates/helpers/sprint-backlog.sh +6 -6
- package/assets/templates/helpers/verify-contract.sh +1 -111
- package/assets/templates/helpers/verify-sprint.sh +3 -180
- package/assets/templates/plan.template.md +1 -1
- package/assets/templates/review.template.md +9 -34
- package/assets/workflow-contract.v1.json +10 -19
- package/docs/README.md +10 -10
- package/docs/architecture/CURRENT.md +170 -0
- package/docs/architecture/EVOLUTION.md +42 -0
- package/docs/architecture/current/README.md +4 -156
- package/docs/architecture/decisions/20260803-release-identity-binding-and-exit-policy.md +2 -2
- package/docs/architecture/decisions/20260823-immediate-controller-relay.md +53 -0
- package/docs/architecture/decisions/20260826-browser-runtime-v2.md +73 -0
- package/docs/architecture/history/README.md +7 -0
- package/docs/architecture/{chatgpt-handoff-facade.md → history/chatgpt-handoff-facade.md} +4 -0
- package/docs/architecture/{global-hook-runtime.md → history/global-hook-runtime.md} +7 -3
- package/docs/architecture/{ios-semantic-automation-provider-v2.md → history/ios-semantic-automation-provider-v2.md} +6 -2
- package/docs/architecture/history.md +3 -34
- package/docs/architecture/index.md +15 -98
- package/docs/architecture/modules/controller-runtime/transport-lifecycle.md +1 -1
- package/docs/architecture/reviews/2026-08-22-semantic-harness-convergence-acceptance.md +39 -0
- package/docs/architecture/versions/1.6.md +38 -0
- package/docs/architecture/versions/1.7.md +41 -0
- package/docs/forge-chatgpt-browser-engine.md +2 -2
- package/docs/forge-chatgpt-mcp-setup.md +4 -28
- package/docs/forge-chatgpt-supervised-automation.md +3 -3
- package/docs/forge-github-issue-launcher.md +1 -1
- package/docs/forge-runtime-self-healing-loop.md +1 -1
- package/docs/operations/controller-browser-plugin.md +38 -22
- package/docs/operations/controller-performance-and-502.md +124 -0
- package/docs/operations/controller-reliability-runbook.md +1 -1
- package/docs/operations/features.md +3 -3
- package/docs/operations/github-repository.md +1 -1
- package/docs/operations/homebrew.md +2 -2
- package/docs/operations/mcp-tool-exposure.md +5 -3
- package/docs/tutorials/01-install-and-start.md +1 -1
- package/docs/tutorials/01-install-and-start.zh-CN.md +1 -1
- package/docs/wiki/Architecture.md +6 -6
- package/docs/wiki/Implementation.md +2 -2
- package/docs/wiki/Installation.md +1 -1
- package/docs/wiki/Integrations.md +2 -2
- package/docs/wiki/Quick-Start.md +1 -1
- package/docs/wiki/Work-Lifecycle.md +1 -1
- package/package.json +29 -10
- package/scripts/activate-source-baseline.ts +17 -13
- package/scripts/benchmark-background-check-overlap.ts +228 -0
- package/scripts/benchmark-mcp-host.sh +117 -0
- package/scripts/benchmark-mcp-transport.ts +170 -0
- package/scripts/benchmark-quality-harness.ts +146 -0
- package/scripts/benchmark-route-session-concurrency.ts +207 -6
- package/scripts/benchmark-thin-harness-mcp-e2e.ts +7 -1
- package/scripts/benchmark-typescript-navigation.ts +186 -0
- package/scripts/benchmark-work-efficiency.ts +334 -0
- package/scripts/capture-plan.sh +3 -3
- package/scripts/check-agent-tooling.sh +8 -35
- package/scripts/check-architecture-sync.sh +17 -86
- package/scripts/check-mcp-compatibility.ts +14 -0
- package/scripts/check-public-docs.sh +14 -1
- package/scripts/check-runtime-architecture.mjs +107 -64
- package/scripts/check-stable-baseline.ts +92 -0
- package/scripts/check-task-workflow.sh +4 -4
- package/scripts/contract-worktree.sh +1 -21
- package/scripts/ensure-task-workflow.sh +22 -55
- package/scripts/host-temporary-cloud-mcp-e2e.sh +265 -0
- package/scripts/install-standalone-recovery.ts +24 -0
- package/scripts/lib/project-init-lib.sh +15 -44
- package/scripts/migrate-chatgpt-automation-schedules.ts +64 -0
- package/scripts/migrate-project-template.sh +23 -1179
- package/scripts/new-plan.sh +1 -1
- package/scripts/plan-to-todo.sh +11 -36
- package/scripts/run-governed-gate.ts +2 -1
- package/scripts/ship-worktrees.sh +2 -29
- package/scripts/smoke-ios-physical-device.ts +4 -2
- package/scripts/smoke-runtime-recovery.ts +1 -35
- package/scripts/smoke-schedule-engine.ts +1 -20
- package/scripts/sprint-backlog.sh +1 -1
- package/scripts/verify-contract.sh +1 -111
- package/scripts/verify-forge-runtime.sh +0 -1
- package/scripts/verify-sprint.sh +3 -180
- package/scripts/workflow-contract.ts +1 -5
- package/src/cli/commands/chatgpt.ts +31 -2
- package/src/cli/commands/init-hook.ts +3 -3
- package/src/cli/commands/mcp.ts +9 -5
- package/src/cli/commands/plugin.ts +37 -10
- package/src/cli/commands/recovery.ts +25 -3
- package/src/cli/commands/runtime.ts +55 -3
- package/src/cli/commands/security.ts +12 -1
- package/src/cli/commands/setup-profile.ts +31 -21
- package/src/cli/controller/check-runner.ts +106 -3
- package/src/cli/controller/composite-result.ts +1 -1
- package/src/cli/controller/context/focus.ts +51 -0
- package/src/cli/controller/context/instruction-context.ts +114 -0
- package/src/cli/controller/context/known-paths.ts +76 -0
- package/src/cli/controller/context/query-planning.ts +110 -0
- package/src/cli/controller/context/rule-resolution.ts +532 -0
- package/src/cli/controller/context/source-materializer.ts +278 -0
- package/src/cli/controller/context/structural.ts +16 -0
- package/src/cli/controller/context/types.ts +286 -0
- package/src/cli/controller/context-pack.ts +898 -430
- package/src/cli/controller/launch-agents.ts +77 -2
- package/src/cli/controller/operational-plan.ts +2 -2
- package/src/cli/controller/work-mode.ts +6 -4
- package/src/cli/editing/edit-session.ts +60 -7
- package/src/cli/github/github.ts +133 -0
- package/src/cli/hook/prompt-guard-decision.ts +17 -18
- package/src/cli/hook/prompt-intents.ts +1 -1
- package/src/cli/installer/managed-entries.ts +15 -1
- package/src/cli/local-bridge/console-automations.ts +225 -67
- package/src/cli/local-bridge/console-view-models.ts +3 -35
- package/src/cli/local-bridge/facade-api.ts +2 -217
- package/src/cli/local-bridge/frontend/src/App.tsx +3 -3
- package/src/cli/local-bridge/frontend/src/features/automations/AutomationsView.tsx +153 -3
- package/src/cli/local-bridge/frontend/src/features/capabilities/CapabilitiesView.tsx +37 -4
- package/src/cli/local-bridge/frontend/src/features/overview/OverviewView.tsx +183 -3
- package/src/cli/local-bridge/frontend/src/features/repositories/RepositoriesView.tsx +1 -1
- package/src/cli/local-bridge/frontend/src/features/work/WorkView.tsx +4 -3
- package/src/cli/local-bridge/frontend/src/lib/api.ts +18 -11
- package/src/cli/local-bridge/frontend/src/lib/routes.ts +1 -1
- package/src/cli/local-bridge/frontend/src/shell/CommandBar.tsx +1 -1
- package/src/cli/local-bridge/frontend/src/shell/Sidebar.tsx +4 -3
- package/src/cli/local-bridge/frontend/src/styles.css +27 -11
- package/src/cli/local-bridge/frontend/src/types.ts +8 -7
- package/src/cli/local-bridge/job-store.ts +1 -490
- package/src/cli/local-bridge/server.ts +29 -532
- package/src/cli/local-bridge/ui-dist/app.css +1 -1
- package/src/cli/local-bridge/ui-dist/app.js +5101 -4967
- package/src/cli/mcp/auth.ts +5 -5
- package/src/cli/mcp/instructions.ts +3 -2
- package/src/cli/mcp/legacy-tool-service.ts +0 -189
- package/src/cli/mcp/multi-repository.ts +16 -5
- package/src/cli/mcp/oauth.ts +175 -26
- package/src/cli/mcp/paths.ts +8 -2
- package/src/cli/mcp/repository-tools.ts +356 -101
- package/src/cli/mcp/server.ts +625 -54
- package/src/cli/mcp/tool-capability-cache.ts +1 -1
- package/src/cli/mcp/toolset-selection.ts +1 -1
- package/src/cli/mcp/toolset.ts +42 -5
- package/src/cli/mcp/transports/http.ts +125 -15
- package/src/cli/mcp/transports/session-registry.ts +67 -5
- package/src/cli/mcp/types.ts +3 -3
- package/src/cli/repositories/command-classifier.ts +209 -14
- package/src/cli/repositories/command-executor.ts +55 -521
- package/src/cli/repositories/command-process.ts +108 -0
- package/src/cli/repositories/command-scope.ts +99 -41
- package/src/cli/repositories/controller-home.ts +7 -8
- package/src/cli/repositories/git-command-executor.ts +2 -0
- package/src/cli/repositories/locks.ts +53 -16
- package/src/cli/repositories/repository-snapshot.ts +121 -0
- package/src/cli/repositories/safe-patch.ts +6 -4
- package/src/cli/repositories/selected-path-actions.ts +17 -9
- package/src/cli/repositories/structured-git.ts +110 -10
- package/src/cli/repository/inspector.ts +565 -62
- package/src/cli/repository/session-cache.ts +58 -17
- package/src/cli/v81-entry.ts +1 -4
- package/src/effects/fs-transaction.ts +85 -17
- package/src/runtime/context/codegraph-read-provider.ts +233 -2
- package/src/runtime/context/codegraph-sidecar.cjs +74 -40
- package/src/runtime/context/generic-lsp-provider.ts +355 -0
- package/src/runtime/context/lsp-client.ts +283 -0
- package/src/runtime/context/semantic-navigation.ts +275 -0
- package/src/runtime/context/swift-navigation.ts +565 -0
- package/src/runtime/context/typescript-navigation.ts +226 -0
- package/src/runtime/control-plane/dispatch-priority.ts +28 -0
- package/src/runtime/control-plane/execution/direct-edit-work-completion.ts +196 -2
- package/src/runtime/control-plane/execution/edit-validation-coordinator.ts +86 -24
- package/src/runtime/control-plane/execution/execution-identity.ts +65 -14
- package/src/runtime/control-plane/execution/session-store.ts +18 -0
- package/src/runtime/control-plane/execution/validation.ts +15 -2
- package/src/runtime/control-plane/execution/verification-evidence.ts +58 -3
- package/src/runtime/control-plane/execution/work-handle-store.ts +27 -2
- package/src/runtime/control-plane/execution/work-lifecycle-audit.ts +258 -0
- package/src/runtime/control-plane/execution/work-remote-delivery.ts +215 -0
- package/src/runtime/control-plane/execution/work-task-receipt.ts +54 -11
- package/src/runtime/control-plane/execution/work-terminal-cleanup.ts +175 -8
- package/src/runtime/control-plane/execution/work-validation-reconciler.ts +28 -21
- package/src/runtime/control-plane/execution/work-verification-snapshot.ts +87 -9
- package/src/runtime/control-plane/facade/capability-registry.ts +129 -25
- package/src/runtime/control-plane/facade/controller-round-relay.ts +991 -0
- package/src/runtime/control-plane/facade/controller-session-store.ts +144 -14
- package/src/runtime/control-plane/facade/goal-workloop-access.ts +9 -2
- package/src/runtime/control-plane/facade/goal-workloop.ts +885 -105
- package/src/runtime/control-plane/facade/index.ts +1 -0
- package/src/runtime/control-plane/facade/plan-contract-store.ts +211 -26
- package/src/runtime/control-plane/facade/requirement-board.ts +24 -8
- package/src/runtime/control-plane/facade/semantic-admission.ts +205 -0
- package/src/runtime/control-plane/facade/suggested-actions.ts +5 -1
- package/src/runtime/control-plane/facade/types.ts +55 -11
- package/src/runtime/control-plane/facade/work-contract-store.ts +204 -73
- package/src/runtime/control-plane/generated-cache-retention.ts +271 -0
- package/src/runtime/control-plane/global-scheduler/config.ts +44 -0
- package/src/runtime/control-plane/global-scheduler/dispatch-capacity.ts +80 -0
- package/src/runtime/control-plane/global-scheduler/durable-admission.ts +46 -0
- package/src/runtime/control-plane/global-scheduler/maintenance.ts +145 -0
- package/src/runtime/control-plane/global-scheduler/projection-refresh.ts +84 -0
- package/src/runtime/control-plane/global-scheduler/reconciliation.ts +3 -3
- package/src/runtime/control-plane/global-scheduler/scheduler.ts +273 -542
- package/src/runtime/control-plane/global-scheduler/source-scan.ts +59 -0
- package/src/runtime/control-plane/global-scheduler/state.ts +88 -0
- package/src/runtime/control-plane/global-scheduler/worker-attachment.ts +57 -0
- package/src/runtime/control-plane/global-scheduler/worker-exit-decision.ts +38 -0
- package/src/runtime/control-plane/global-scheduler/worker-exit-reconciler.ts +175 -0
- package/src/runtime/control-plane/global-scheduler/worker-launch.ts +111 -0
- package/src/runtime/control-plane/global-scheduler/worker-lifecycle-store.ts +64 -0
- package/src/runtime/control-plane/global-scheduler/worker-lifecycle.ts +150 -0
- package/src/runtime/control-plane/global-scheduler/worker-process.ts +119 -0
- package/src/runtime/control-plane/global-scheduler/worker-stderr.ts +60 -0
- package/src/runtime/control-plane/launcher/chatgpt-work-binding-store.ts +50 -0
- package/src/runtime/control-plane/launcher/chatgpt-work-continuation.ts +642 -51
- package/src/runtime/control-plane/launcher/launch-reservation-store.ts +40 -0
- package/src/runtime/control-plane/launcher/thin-launcher.ts +194 -10
- package/src/runtime/control-plane/persistence/controller-home-migration.ts +487 -0
- package/src/runtime/control-plane/persistence/requirement-store.ts +15 -11
- package/src/runtime/control-plane/persistence/sqlite-store.ts +33 -2
- package/src/runtime/control-plane/release-retention.ts +62 -2
- package/src/runtime/control-plane/routing/route-policy.ts +7 -16
- package/src/runtime/control-plane/runtime-status-client.ts +0 -2
- package/src/runtime/diagnostics/mcp-timing.ts +19 -0
- package/src/runtime/diagnostics/mcp-transport-benchmark.ts +129 -0
- package/src/runtime/diagnostics/performance.ts +24 -1
- package/src/runtime/evidence/event-ledger.ts +1 -1
- package/src/runtime/execution/jobs/store.ts +58 -4
- package/src/runtime/execution/jobs/types.ts +1 -1
- package/src/runtime/execution/managed-workspace.ts +203 -1
- package/src/runtime/execution/process-runtime/check-facade.ts +52 -14
- package/src/runtime/execution/process-runtime/check-result.ts +63 -2
- package/src/runtime/execution/process-runtime/check-scheduling.ts +114 -0
- package/src/runtime/execution/process-runtime/command-facade.ts +346 -40
- package/src/runtime/execution/process-runtime/gc.ts +98 -12
- package/src/runtime/execution/process-runtime/lightweight-managed.ts +1184 -0
- package/src/runtime/execution/process-runtime/persisted-check.ts +57 -6
- package/src/runtime/execution/process-runtime/resource-claims.ts +97 -8
- package/src/runtime/execution/process-runtime/runtime.ts +59 -4
- package/src/runtime/execution/process-runtime/store.ts +7 -0
- package/src/runtime/execution/process-runtime/types.ts +2 -0
- package/src/runtime/execution/thin-harness/async-process.ts +12 -2
- package/src/runtime/execution/thin-harness/search-worker.ts +54 -5
- package/src/runtime/execution/workers/executor.ts +0 -48
- package/src/runtime/gateway/mcp/execution-tools.ts +1219 -126
- package/src/runtime/gateway/mcp/process-tools.ts +83 -37
- package/src/runtime/gateway/mcp/router.ts +185 -83
- package/src/runtime/gateway/mcp/runtime-tool-definitions.ts +546 -0
- package/src/runtime/gateway/mcp/runtime-tools.ts +2555 -1616
- package/src/runtime/model-clients/deepseek-adapter.ts +0 -32
- package/src/runtime/plugins/app-store-connect-adapter.ts +123 -19
- package/src/runtime/plugins/browser-adapter.ts +2925 -318
- package/src/runtime/plugins/browser-automation-service.ts +10 -0
- package/src/runtime/plugins/browser-handoff-host.ts +6 -31
- package/src/runtime/plugins/browser-handoff.ts +92 -5
- package/src/runtime/plugins/browser-macos-bridge.ts +586 -45
- package/src/runtime/plugins/browser-node-bridge.ts +6 -34
- package/src/runtime/plugins/browser-provider-registry.ts +109 -0
- package/src/runtime/plugins/browser-runtime-contract.ts +152 -0
- package/src/runtime/plugins/browser-runtime.ts +183 -0
- package/src/runtime/plugins/browser-session-authority.ts +332 -0
- package/src/runtime/plugins/capability-authorization-grants.ts +354 -0
- package/src/runtime/plugins/desktop-operator-registration.ts +15 -12
- package/src/runtime/plugins/external-adapter.ts +324 -3
- package/src/runtime/plugins/external-registration.ts +84 -5
- package/src/runtime/plugins/external-unix-socket.ts +7 -1
- package/src/runtime/plugins/first-party-registry.ts +4 -2
- package/src/runtime/plugins/github-adapter.ts +125 -0
- package/src/runtime/plugins/gmail-adapter.ts +28 -2
- package/src/runtime/plugins/ios/agent-device-provider.ts +1 -1
- package/src/runtime/plugins/ios/agent-device-typed-provider.ts +52 -9
- package/src/runtime/plugins/ios/remote-xpc-hid.ts +1171 -0
- package/src/runtime/plugins/ios-adapter.ts +106 -16
- package/src/runtime/plugins/ios-agent-device.ts +234 -64
- package/src/runtime/plugins/ios-physical-device.ts +1143 -392
- package/src/runtime/plugins/lightweight-action.ts +153 -0
- package/src/runtime/plugins/local-system-adapter.ts +125 -8
- package/src/runtime/plugins/macos-capability-broker.ts +55 -9
- package/src/runtime/plugins/plugin-action-sidecar.ts +59 -0
- package/src/runtime/plugins/plugin-management-adapter.ts +181 -0
- package/src/runtime/plugins/resend-adapter.ts +1 -1
- package/src/runtime/plugins/store.ts +366 -24
- package/src/runtime/plugins/types.ts +39 -2
- package/src/runtime/plugins/xiaohongshu-publish.ts +515 -0
- package/src/runtime/projections/git-status-sampler.ts +16 -16
- package/src/runtime/projections/materialized-view.ts +28 -10
- package/src/runtime/recovery/actions.ts +0 -10
- package/src/runtime/recovery/classifier.ts +0 -9
- package/src/runtime/recovery/maintenance-executor.ts +415 -18
- package/src/runtime/recovery/probe.ts +0 -1
- package/src/runtime/recovery/types.ts +0 -1
- package/src/runtime/root/mcp-transport.ts +180 -10
- package/src/runtime/root/package-connector-service.ts +186 -8
- package/src/runtime/root/package-runtime-release.ts +143 -17
- package/src/runtime/root/package-runtime-service.ts +430 -22
- package/src/runtime/root/release-manifest.ts +7 -2
- package/src/runtime/root/release-materialize.ts +162 -19
- package/src/runtime/root/release-store.ts +48 -11
- package/src/runtime/root/runtime.ts +23 -5
- package/src/runtime/root/service.ts +100 -27
- package/src/runtime/root/types.ts +2 -0
- package/src/runtime/safe-tooling/index.ts +0 -1
- package/src/runtime/safe-tooling/ios-development.ts +321 -63
- package/src/runtime/safe-tooling/types.ts +0 -30
- package/src/runtime/shared/trusted-executable.ts +62 -0
- package/src/runtime/shared/trusted-node-executable.ts +48 -0
- package/src/runtime/standalone-recovery/core.ts +702 -94
- package/src/runtime/standalone-recovery/entry.ts +99 -23
- package/src/runtime/standalone-recovery/installer.ts +19 -3
- package/src/runtime/standalone-recovery/service-labels.ts +2 -0
- package/src/runtime/standalone-recovery/watchdog-heartbeat.ts +160 -0
- package/src/runtime/workflow/schedules/browser-probe.ts +258 -0
- package/src/runtime/workflow/schedules/chatgpt-automation-migration.ts +40 -0
- package/src/runtime/workflow/schedules/engine.ts +509 -80
- package/src/runtime/workflow/schedules/github-issue-watch.ts +158 -0
- package/src/runtime/workflow/schedules/settlement.ts +48 -4
- package/src/runtime/workflow/schedules/store.ts +131 -10
- package/src/runtime/workflow/schedules/types.ts +6 -3
- package/src/runtime/workflow/schedules/work-continuation.ts +120 -34
- package/src/testing/test-governance.ts +8 -40
- package/assets/reference-configs/heartbeat-triage.md +0 -57
- package/assets/templates/helpers/harness-trace-grade.sh +0 -150
- package/assets/templates/helpers/heartbeat-triage.sh +0 -361
- package/assets/templates/helpers/maintenance-triage.sh +0 -167
- package/bin/forge-desktop-helper.mjs +0 -204
- package/docs/architecture/current/approved-target-architecture.zh-CN.md +0 -1501
- package/docs/architecture/current/architecture-invariants.md +0 -331
- package/docs/architecture/current/automation-and-schedule-engine.md +0 -453
- package/docs/architecture/current/codegraph-context-provider.md +0 -226
- package/docs/architecture/current/control-plane-authority-inventory.md +0 -94
- package/docs/architecture/current/controller-repository-decoupling.md +0 -148
- package/docs/architecture/current/dispatch-and-agent-strategy.md +0 -354
- package/docs/architecture/current/entity-model.md +0 -592
- package/docs/architecture/current/external-plugin-governance.md +0 -396
- package/docs/architecture/current/failure-recovery.md +0 -447
- package/docs/architecture/current/governance.md +0 -213
- package/docs/architecture/current/human-interaction-plane.md +0 -87
- package/docs/architecture/current/implementation-status.md +0 -128
- package/docs/architecture/current/job-and-run-lifecycle.md +0 -413
- package/docs/architecture/current/legacy-governance.md +0 -58
- package/docs/architecture/current/local-workspace-target-grants.md +0 -70
- package/docs/architecture/current/migration-roadmap.md +0 -105
- package/docs/architecture/current/multi-repository-execution.md +0 -371
- package/docs/architecture/current/operations-runbook.md +0 -45
- package/docs/architecture/current/peer-supercontroller-runtime.md +0 -32
- package/docs/architecture/current/personal-assistant-plugin-baseline.md +0 -206
- package/docs/architecture/current/repository-access-modes.md +0 -102
- package/docs/architecture/current/route-policy.md +0 -15
- package/docs/architecture/current/route-session-concurrency.md +0 -85
- package/docs/architecture/current/runtime-architecture-simplification.md +0 -214
- package/docs/architecture/current/runtime-directory-map.md +0 -49
- package/docs/architecture/current/runtime-health-and-resource-lifecycle.md +0 -85
- package/docs/architecture/current/scheduler-and-resource-claims.md +0 -422
- package/docs/architecture/current/session-aware-execution-and-authorization.md +0 -77
- package/docs/architecture/current/system-overview.md +0 -144
- package/docs/architecture/current/target-requirements-traceability.md +0 -202
- package/docs/architecture/current/thin-harness-governance-policy.md +0 -32
- package/docs/architecture/current/thin-harness-v1.md +0 -311
- package/docs/architecture/current/verification-and-release-gates.md +0 -391
- package/docs/forge-autonomous-goal-loop.md +0 -9
- package/docs/forge-provider-configuration.md +0 -7
- package/docs/operations/chatgpt-personal-assistant-runtime.md +0 -83
- package/docs/operations/controller-desktop-plugin.md +0 -112
- package/docs/operations/gmail-assistant-routines.md +0 -186
- package/docs/operations/personal-assistant-operator-guide.md +0 -61
- package/docs/operations/provider-configuration.md +0 -31
- package/scripts/harness-trace-grade.sh +0 -150
- package/scripts/heartbeat-triage.sh +0 -361
- package/scripts/maintenance-triage.sh +0 -167
- package/src/cli/local-bridge/frontend/src/features/settings/SettingsView.tsx +0 -2
- package/src/cli/repositories/goal-registry.ts +0 -239
- package/src/runtime/assistant/action-proposals.ts +0 -279
- package/src/runtime/assistant/intent.ts +0 -395
- package/src/runtime/assistant/model-provider.ts +0 -460
- package/src/runtime/assistant/openapi.ts +0 -223
- package/src/runtime/assistant/policy.ts +0 -89
- package/src/runtime/assistant/readiness.ts +0 -258
- package/src/runtime/assistant/routine-runtime.ts +0 -477
- package/src/runtime/assistant/schedule-binding.ts +0 -171
- package/src/runtime/assistant/standing-grants.ts +0 -375
- package/src/runtime/assistant/store.ts +0 -243
- package/src/runtime/assistant/types.ts +0 -135
- package/src/runtime/control-plane/goal-loop/config-facade.ts +0 -700
- package/src/runtime/control-plane/goal-loop/config-store.ts +0 -570
- package/src/runtime/control-plane/goal-loop/config-types.ts +0 -213
- package/src/runtime/control-plane/goal-loop/executor-router.ts +0 -109
- package/src/runtime/control-plane/goal-loop/failure-taxonomy.ts +0 -149
- package/src/runtime/control-plane/goal-loop/goal-contract-store.ts +0 -304
- package/src/runtime/control-plane/goal-loop/goal-loop-engine.ts +0 -1001
- package/src/runtime/control-plane/goal-loop/handoff-packet.ts +0 -160
- package/src/runtime/control-plane/goal-loop/index.ts +0 -13
- package/src/runtime/control-plane/goal-loop/local-tools.ts +0 -290
- package/src/runtime/control-plane/goal-loop/policy-gates.ts +0 -203
- package/src/runtime/control-plane/goal-loop/provider-dispatch.ts +0 -93
- package/src/runtime/control-plane/goal-loop/provider-registry.ts +0 -545
- package/src/runtime/control-plane/goal-loop/types.ts +0 -378
- package/src/runtime/control-plane/startup-recovery.ts +0 -198
- package/src/runtime/gateway/mcp/resource-policy.ts +0 -186
- package/src/runtime/personal-assistant/gmail-triage-manager.ts +0 -231
- package/src/runtime/personal-assistant/reporting-runtime.ts +0 -344
- package/src/runtime/personal-assistant/triage-runtime.ts +0 -748
- package/src/runtime/plugins/desktop-adapter.ts +0 -374
- package/src/runtime/safe-tooling/browser-safe.ts +0 -133
- package/src/runtime/workflow/findings/store.ts +0 -204
- package/src/runtime/workflow/findings/types.ts +0 -58
- package/src/runtime/workflow/portfolio/engine.ts +0 -20
- package/src/runtime/workflow/portfolio/store.ts +0 -185
- package/src/runtime/workflow/portfolio/types.ts +0 -29
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
appendFileSync,
|
|
4
4
|
existsSync,
|
|
5
5
|
mkdirSync,
|
|
6
|
-
openSync,
|
|
7
6
|
readFileSync,
|
|
8
7
|
readdirSync,
|
|
9
8
|
renameSync,
|
|
@@ -12,41 +11,29 @@ import {
|
|
|
12
11
|
} from "fs";
|
|
13
12
|
import { dirname, join, relative, resolve, sep } from "path";
|
|
14
13
|
import { cancelAgentJob, getAgentJob } from "../agent-jobs/job-manager";
|
|
15
|
-
import {
|
|
14
|
+
import { removeEphemeralIssue } from "../controller/issue-store";
|
|
16
15
|
import {
|
|
17
16
|
currentControllerCheckRevision,
|
|
18
17
|
releaseControllerCheckSubscription,
|
|
19
|
-
runControllerCheckAsync,
|
|
20
|
-
snapshotControllerCheck,
|
|
21
18
|
} from "../controller/check-runner";
|
|
22
19
|
import {
|
|
23
20
|
DEFAULT_AGENT_TIMEOUT_MS,
|
|
24
21
|
MAX_AGENT_TIMEOUT_MS,
|
|
25
22
|
normalizeAgentTimeoutMs,
|
|
26
23
|
} from "../controller/runtime-config";
|
|
27
|
-
import { verifyEditSessionAsync } from "../editing/edit-session";
|
|
28
24
|
import { loadMcpLocalConfig, loadMcpServiceLocalConfig } from "../mcp/auth";
|
|
29
|
-
import {
|
|
30
|
-
executeRepositoryCommandAsync,
|
|
31
|
-
} from "../repositories/command-executor";
|
|
32
|
-
import { registerRepository, resolveRepositorySelection } from "../repositories/registry";
|
|
33
25
|
import type { ControllerTask } from "../controller/types";
|
|
34
26
|
import { taskExecutionPolicy } from "../controller/execution-policy";
|
|
35
27
|
import { tryAppendControllerWorklogEvent } from "../controller/worklog";
|
|
36
28
|
import { resolveControllerHome, resolveRepoPreferredControllerHome } from "../repositories/controller-home";
|
|
37
|
-
import { ensureRepositoryRuntimeStorage } from "../repositories/runtime-storage";
|
|
38
|
-
import { commandValue, normalizeRepositoryCommand } from "../repositories/command-normalization";
|
|
39
29
|
import { findExecutionJob } from "../../runtime/execution/jobs/store";
|
|
40
30
|
import type {
|
|
41
|
-
LaunchTaskPayload,
|
|
42
31
|
LocalBridgeApproval,
|
|
43
32
|
LocalBridgeConfig,
|
|
44
33
|
LocalBridgeJob,
|
|
45
|
-
LocalBridgeJobAction,
|
|
46
34
|
LocalBridgeJobEvent,
|
|
47
35
|
LocalBridgeJobRequest,
|
|
48
36
|
RepositoryCommandPayload,
|
|
49
|
-
QuickAgentSessionPayload,
|
|
50
37
|
RunCheckPayload,
|
|
51
38
|
VerifyEditSessionPayload,
|
|
52
39
|
} from "./types";
|
|
@@ -276,24 +263,6 @@ function writeJson(path: string, value: unknown): void {
|
|
|
276
263
|
}
|
|
277
264
|
}
|
|
278
265
|
|
|
279
|
-
function ensureJobLogFiles(repoRoot: string, jobId: string): void {
|
|
280
|
-
mkdirSync(jobDir(repoRoot, jobId), { recursive: true });
|
|
281
|
-
for (const path of [stdoutPath(repoRoot, jobId), stderrPath(repoRoot, jobId)]) {
|
|
282
|
-
if (!existsSync(path)) writeFileSync(path, "", "utf-8");
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
function appendJobOutput(
|
|
287
|
-
repoRoot: string,
|
|
288
|
-
jobId: string,
|
|
289
|
-
stream: "stdout" | "stderr",
|
|
290
|
-
chunk: string,
|
|
291
|
-
): void {
|
|
292
|
-
const path = stream === "stdout" ? stdoutPath(repoRoot, jobId) : stderrPath(repoRoot, jobId);
|
|
293
|
-
ensureJobLogFiles(repoRoot, jobId);
|
|
294
|
-
appendFileSync(path, chunk, "utf-8");
|
|
295
|
-
}
|
|
296
|
-
|
|
297
266
|
function readJson<T>(path: string): T {
|
|
298
267
|
return JSON.parse(readFileSync(path, "utf-8")) as T;
|
|
299
268
|
}
|
|
@@ -384,149 +353,6 @@ function taskApproval(task: ControllerTask): LocalBridgeApproval {
|
|
|
384
353
|
return taskExecutionPolicy(task).approval;
|
|
385
354
|
}
|
|
386
355
|
|
|
387
|
-
function executionApproval(
|
|
388
|
-
repoRoot: string,
|
|
389
|
-
action: LocalBridgeJobAction,
|
|
390
|
-
payload: LocalBridgeJobRequest["payload"],
|
|
391
|
-
): LocalBridgeApproval {
|
|
392
|
-
if (action === "run-check" || action === "verify-edit-session" || action === "repository-command") return "auto";
|
|
393
|
-
if (action === "launch-task") {
|
|
394
|
-
const input = payload as LaunchTaskPayload;
|
|
395
|
-
const issue = getIssue(repoRoot, input.issueId);
|
|
396
|
-
const task = issue.tasks.find((entry) => entry.id === input.taskId);
|
|
397
|
-
if (!task)
|
|
398
|
-
throw new Error(`task not found: ${input.issueId}/${input.taskId}`);
|
|
399
|
-
return taskApproval(task);
|
|
400
|
-
}
|
|
401
|
-
const input = payload as QuickAgentSessionPayload;
|
|
402
|
-
const synthetic: ControllerTask = {
|
|
403
|
-
id: "QUICK",
|
|
404
|
-
title: input.title || "Quick Agent",
|
|
405
|
-
objective: input.objective || "Execute a quick agent session.",
|
|
406
|
-
status: "ready",
|
|
407
|
-
dependsOn: [],
|
|
408
|
-
allowedPaths: normalizeStringList(input.allowedPaths),
|
|
409
|
-
forbiddenPaths: normalizeStringList(input.forbiddenPaths),
|
|
410
|
-
checks: normalizeStringList(input.checks),
|
|
411
|
-
acceptanceCriteria: normalizeStringList(input.acceptanceCriteria),
|
|
412
|
-
risk: input.risk ?? "low",
|
|
413
|
-
recommendedAgent: input.agent,
|
|
414
|
-
notes: [],
|
|
415
|
-
runIds: [],
|
|
416
|
-
createdAt: now(),
|
|
417
|
-
updatedAt: now(),
|
|
418
|
-
};
|
|
419
|
-
return taskApproval(synthetic);
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
function findExistingLaunchJob(
|
|
423
|
-
repoRoot: string,
|
|
424
|
-
payload: LaunchTaskPayload,
|
|
425
|
-
): LocalBridgeJob | undefined {
|
|
426
|
-
const jobs = readStoredJobs(repoRoot, 500);
|
|
427
|
-
const requestId = payload.requestId?.trim();
|
|
428
|
-
if (requestId) {
|
|
429
|
-
return jobs.find((entry) =>
|
|
430
|
-
entry.action === "launch-task" &&
|
|
431
|
-
typeof (entry.payload as LaunchTaskPayload).requestId === "string" &&
|
|
432
|
-
(entry.payload as LaunchTaskPayload).requestId === requestId,
|
|
433
|
-
);
|
|
434
|
-
}
|
|
435
|
-
return jobs.find((entry) =>
|
|
436
|
-
entry.action === "launch-task" &&
|
|
437
|
-
["approved", "running", "dispatched"].includes(entry.status) &&
|
|
438
|
-
entry.issueId === payload.issueId &&
|
|
439
|
-
entry.taskId === payload.taskId,
|
|
440
|
-
);
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
function findExistingQuickSessionJob(
|
|
444
|
-
repoRoot: string,
|
|
445
|
-
payload: QuickAgentSessionPayload,
|
|
446
|
-
): LocalBridgeJob | undefined {
|
|
447
|
-
const jobs = readStoredJobs(repoRoot, 500);
|
|
448
|
-
const requestId = payload.requestId?.trim();
|
|
449
|
-
if (requestId) {
|
|
450
|
-
return jobs.find((entry) =>
|
|
451
|
-
entry.action === "quick-agent-session" &&
|
|
452
|
-
typeof (entry.payload as QuickAgentSessionPayload).requestId === "string" &&
|
|
453
|
-
(entry.payload as QuickAgentSessionPayload).requestId === requestId,
|
|
454
|
-
);
|
|
455
|
-
}
|
|
456
|
-
return undefined;
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
function findExistingRunCheckJob(
|
|
460
|
-
repoRoot: string,
|
|
461
|
-
payload: RunCheckPayload,
|
|
462
|
-
revision: string,
|
|
463
|
-
): LocalBridgeJob | undefined {
|
|
464
|
-
const requestId = payload.requestId?.trim();
|
|
465
|
-
if (requestId) {
|
|
466
|
-
const duplicate = readStoredJobs(repoRoot, 500).find((entry) =>
|
|
467
|
-
entry.action === "run-check" &&
|
|
468
|
-
typeof (entry.payload as RunCheckPayload).requestId === "string" &&
|
|
469
|
-
(entry.payload as RunCheckPayload).requestId === requestId,
|
|
470
|
-
);
|
|
471
|
-
if (duplicate) return duplicate;
|
|
472
|
-
}
|
|
473
|
-
const candidate = readActiveLocalBridgeJobs(repoRoot).find((entry) =>
|
|
474
|
-
entry.action === "run-check" &&
|
|
475
|
-
(entry.payload as RunCheckPayload).checkId === payload.checkId &&
|
|
476
|
-
entry.revision === revision
|
|
477
|
-
);
|
|
478
|
-
return candidate ? refreshLocalBridgeJob(repoRoot, candidate, revision) : undefined;
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
function findExistingVerifyEditSessionJob(
|
|
482
|
-
repoRoot: string,
|
|
483
|
-
payload: VerifyEditSessionPayload,
|
|
484
|
-
): LocalBridgeJob | undefined {
|
|
485
|
-
const jobs = readStoredJobs(repoRoot, 500);
|
|
486
|
-
const requestId = payload.requestId?.trim();
|
|
487
|
-
if (requestId) {
|
|
488
|
-
return jobs.find((entry) =>
|
|
489
|
-
entry.action === "verify-edit-session" &&
|
|
490
|
-
typeof (entry.payload as VerifyEditSessionPayload).requestId === "string" &&
|
|
491
|
-
(entry.payload as VerifyEditSessionPayload).requestId === requestId,
|
|
492
|
-
);
|
|
493
|
-
}
|
|
494
|
-
return jobs.find((entry) =>
|
|
495
|
-
entry.action === "verify-edit-session" &&
|
|
496
|
-
["approved", "running"].includes(entry.status) &&
|
|
497
|
-
(entry.payload as VerifyEditSessionPayload).sessionId === payload.sessionId &&
|
|
498
|
-
(entry.payload as VerifyEditSessionPayload).revision === payload.revision &&
|
|
499
|
-
JSON.stringify((entry.payload as VerifyEditSessionPayload).checkIds ?? []) === JSON.stringify(payload.checkIds ?? []),
|
|
500
|
-
);
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
function findExistingRepositoryCommandJob(
|
|
504
|
-
repoRoot: string,
|
|
505
|
-
payload: RepositoryCommandPayload,
|
|
506
|
-
): LocalBridgeJob | undefined {
|
|
507
|
-
const jobs = readStoredJobs(repoRoot, 500);
|
|
508
|
-
const requestId = payload.requestId?.trim();
|
|
509
|
-
if (requestId) {
|
|
510
|
-
return jobs.find((entry) =>
|
|
511
|
-
entry.action === "repository-command" &&
|
|
512
|
-
typeof (entry.payload as RepositoryCommandPayload).requestId === "string" &&
|
|
513
|
-
(entry.payload as RepositoryCommandPayload).requestId === requestId,
|
|
514
|
-
);
|
|
515
|
-
}
|
|
516
|
-
const candidate = jobs.find((entry) =>
|
|
517
|
-
entry.action === "repository-command" &&
|
|
518
|
-
["approved", "running"].includes(entry.status) &&
|
|
519
|
-
(entry.payload as RepositoryCommandPayload).repoId === payload.repoId &&
|
|
520
|
-
(entry.payload as RepositoryCommandPayload).checkoutId === payload.checkoutId &&
|
|
521
|
-
JSON.stringify((entry.payload as RepositoryCommandPayload).command) === JSON.stringify(payload.command) &&
|
|
522
|
-
(entry.payload as RepositoryCommandPayload).cwd === payload.cwd &&
|
|
523
|
-
(entry.payload as RepositoryCommandPayload).approvalToken === payload.approvalToken,
|
|
524
|
-
);
|
|
525
|
-
if (!candidate) return undefined;
|
|
526
|
-
const refreshed = refreshLocalBridgeJob(repoRoot, candidate);
|
|
527
|
-
return ["approved", "running"].includes(refreshed.status) ? refreshed : undefined;
|
|
528
|
-
}
|
|
529
|
-
|
|
530
356
|
export function submitLocalBridgeJob(
|
|
531
357
|
_repoRoot: string,
|
|
532
358
|
_request: LocalBridgeJobRequest,
|
|
@@ -542,14 +368,6 @@ function readLocalBridgeJob(repoRoot: string, jobId: string): LocalBridgeJob {
|
|
|
542
368
|
return readJson<LocalBridgeJob>(path);
|
|
543
369
|
}
|
|
544
370
|
|
|
545
|
-
function tryReadLocalBridgeJob(repoRoot: string, jobId: string): LocalBridgeJob | undefined {
|
|
546
|
-
try {
|
|
547
|
-
return readLocalBridgeJob(repoRoot, jobId);
|
|
548
|
-
} catch (_error) {
|
|
549
|
-
return undefined;
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
|
|
553
371
|
function cleanupEphemeralJob(repoRoot: string, job: LocalBridgeJob): void {
|
|
554
372
|
if (!job.ephemeral || !job.issueId || job.cleanupAt || job.status !== "succeeded") return;
|
|
555
373
|
const runStatus = job.result && typeof job.result === "object"
|
|
@@ -622,17 +440,6 @@ function markJobTerminal(
|
|
|
622
440
|
return saveJob(repoRoot, job);
|
|
623
441
|
}
|
|
624
442
|
|
|
625
|
-
export function failLocalBridgeJob(
|
|
626
|
-
repoRoot: string,
|
|
627
|
-
jobId: string,
|
|
628
|
-
message: string,
|
|
629
|
-
data?: Record<string, unknown>,
|
|
630
|
-
): LocalBridgeJob {
|
|
631
|
-
const job = readLocalBridgeJob(repoRoot, jobId);
|
|
632
|
-
if (["succeeded", "failed", "timed_out", "orphaned", "stale", "cancelled"].includes(job.status)) return job;
|
|
633
|
-
return markJobTerminal(repoRoot, job, "failed", message, data);
|
|
634
|
-
}
|
|
635
|
-
|
|
636
443
|
function projectedExecutionJobId(job: LocalBridgeJob): string | undefined {
|
|
637
444
|
const result = job.result;
|
|
638
445
|
return result && typeof result.executionJobId === "string" ? result.executionJobId : undefined;
|
|
@@ -1091,39 +898,6 @@ export function readLocalBridgeJobOutput(
|
|
|
1091
898
|
return readLocalBridgeJobOutputSnapshot(repoRoot, jobId, input);
|
|
1092
899
|
}
|
|
1093
900
|
|
|
1094
|
-
export function buildLocalBridgeJobHandoff(
|
|
1095
|
-
repoRoot: string,
|
|
1096
|
-
jobId: string,
|
|
1097
|
-
input: { maxBytes?: number } = {},
|
|
1098
|
-
): LocalBridgeJobHandoff {
|
|
1099
|
-
const snapshot = getLocalBridgeJobSnapshot(repoRoot, jobId);
|
|
1100
|
-
if (snapshot.status !== "ok" || !snapshot.job) {
|
|
1101
|
-
return {
|
|
1102
|
-
jobId: snapshot.jobId,
|
|
1103
|
-
status: snapshot.status === "ok" ? "not_found" : snapshot.status,
|
|
1104
|
-
error: snapshot.error,
|
|
1105
|
-
};
|
|
1106
|
-
}
|
|
1107
|
-
const maxBytes = boundedOutputBytes(input.maxBytes);
|
|
1108
|
-
const stdout = readLocalBridgeJobOutputSnapshot(repoRoot, snapshot.job.jobId, { stream: "stdout", maxBytes });
|
|
1109
|
-
const stderr = readLocalBridgeJobOutputSnapshot(repoRoot, snapshot.job.jobId, { stream: "stderr", maxBytes });
|
|
1110
|
-
const result = snapshot.job.result ?? {};
|
|
1111
|
-
return {
|
|
1112
|
-
jobId: snapshot.job.jobId,
|
|
1113
|
-
status: snapshot.job.status,
|
|
1114
|
-
stdoutPath: stdout.path,
|
|
1115
|
-
stderrPath: stderr.path,
|
|
1116
|
-
stdout: typeof result.stdout === "string" ? result.stdout : undefined,
|
|
1117
|
-
stderr: typeof result.stderr === "string" ? result.stderr : undefined,
|
|
1118
|
-
outputStatus: {
|
|
1119
|
-
stdout: stdout.status,
|
|
1120
|
-
stderr: stderr.status,
|
|
1121
|
-
},
|
|
1122
|
-
changedPaths: snapshot.job.outcome?.policy?.changedPaths,
|
|
1123
|
-
nextLocalCommand: `tail -n 120 ${relativeOutputPath(snapshot.job.jobId, "stdout")} ${relativeOutputPath(snapshot.job.jobId, "stderr")}`,
|
|
1124
|
-
};
|
|
1125
|
-
}
|
|
1126
|
-
|
|
1127
901
|
function saveJob(repoRoot: string, job: LocalBridgeJob): LocalBridgeJob {
|
|
1128
902
|
job.updatedAt = now();
|
|
1129
903
|
writeJson(metaPath(repoRoot, job.jobId), job);
|
|
@@ -1155,269 +929,6 @@ export function cancelLocalBridgeJob(
|
|
|
1155
929
|
return saveJob(repoRoot, job);
|
|
1156
930
|
}
|
|
1157
931
|
|
|
1158
|
-
async function executeRunCheck(
|
|
1159
|
-
repoRoot: string,
|
|
1160
|
-
jobId: string,
|
|
1161
|
-
payload: RunCheckPayload,
|
|
1162
|
-
): Promise<void> {
|
|
1163
|
-
let job = tryReadLocalBridgeJob(repoRoot, jobId);
|
|
1164
|
-
if (!job || job.status !== "running") return;
|
|
1165
|
-
job.ownerPid = process.pid;
|
|
1166
|
-
saveJob(repoRoot, job);
|
|
1167
|
-
try {
|
|
1168
|
-
const timeoutMs = resolvedJobTimeout(repoRoot, payload.timeoutMs);
|
|
1169
|
-
const result = await runControllerCheckAsync(repoRoot, payload.checkId, {
|
|
1170
|
-
snapshot: payload.checkSnapshot,
|
|
1171
|
-
requestedTimeoutMs: timeoutMs,
|
|
1172
|
-
onSpawn: (pid) => {
|
|
1173
|
-
const current = tryReadLocalBridgeJob(repoRoot, jobId);
|
|
1174
|
-
if (!current || current.status !== "running") {
|
|
1175
|
-
releaseControllerCheckSubscription(checkSubscriberId(jobId));
|
|
1176
|
-
return;
|
|
1177
|
-
}
|
|
1178
|
-
current.workerPid = pid;
|
|
1179
|
-
current.ownerPid = process.pid;
|
|
1180
|
-
current.deadlineAt = new Date(Date.now() + timeoutMs + 5_000).toISOString();
|
|
1181
|
-
saveJob(repoRoot, current);
|
|
1182
|
-
},
|
|
1183
|
-
subscriberId: checkSubscriberId(jobId),
|
|
1184
|
-
});
|
|
1185
|
-
job = tryReadLocalBridgeJob(repoRoot, jobId);
|
|
1186
|
-
if (!job || job.status !== "running") return;
|
|
1187
|
-
job.status = result.ok ? "succeeded" : "failed";
|
|
1188
|
-
job.finishedAt = now();
|
|
1189
|
-
job.result = result as unknown as Record<string, unknown>;
|
|
1190
|
-
const failureClass = result.failureClass ?? (result.ok ? undefined : "infrastructure_failure");
|
|
1191
|
-
const failureMessage = result.stderr || `check failed: ${payload.checkId}`;
|
|
1192
|
-
job.outcome = {
|
|
1193
|
-
process: { exitCode: result.status, timedOut: result.timedOut },
|
|
1194
|
-
failureClass,
|
|
1195
|
-
acceptanceFailure: failureClass === "acceptance_failure"
|
|
1196
|
-
? { code: "CHECK_FAILED", message: failureMessage }
|
|
1197
|
-
: undefined,
|
|
1198
|
-
infrastructureError: failureClass === "infrastructure_failure"
|
|
1199
|
-
? {
|
|
1200
|
-
code: result.timedOut ? "CHECK_TIMED_OUT" : "CHECK_EXECUTION_FAILED",
|
|
1201
|
-
message: failureMessage,
|
|
1202
|
-
}
|
|
1203
|
-
: undefined,
|
|
1204
|
-
};
|
|
1205
|
-
job.workerPid = undefined;
|
|
1206
|
-
if (!result.ok) job.error = failureMessage;
|
|
1207
|
-
appendEvent(repoRoot, job.jobId, {
|
|
1208
|
-
type: result.ok ? "job_succeeded" : "job_failed",
|
|
1209
|
-
message: result.ok
|
|
1210
|
-
? `Check ${payload.checkId} passed.`
|
|
1211
|
-
: `Check ${payload.checkId} failed.`,
|
|
1212
|
-
data: { timedOut: result.timedOut, artifactPath: result.artifactPath },
|
|
1213
|
-
});
|
|
1214
|
-
saveJob(repoRoot, job);
|
|
1215
|
-
} catch (error) {
|
|
1216
|
-
job = tryReadLocalBridgeJob(repoRoot, jobId);
|
|
1217
|
-
if (!job || job.status !== "running") return;
|
|
1218
|
-
job.status = "failed";
|
|
1219
|
-
job.finishedAt = now();
|
|
1220
|
-
job.workerPid = undefined;
|
|
1221
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
1222
|
-
job.error = message;
|
|
1223
|
-
job.outcome = {
|
|
1224
|
-
failureClass: "infrastructure_failure",
|
|
1225
|
-
infrastructureError: { code: "CHECK_EXECUTION_FAILED", message },
|
|
1226
|
-
};
|
|
1227
|
-
appendEvent(repoRoot, job.jobId, {
|
|
1228
|
-
type: "job_failed",
|
|
1229
|
-
message: job.error,
|
|
1230
|
-
});
|
|
1231
|
-
saveJob(repoRoot, job);
|
|
1232
|
-
}
|
|
1233
|
-
}
|
|
1234
|
-
|
|
1235
|
-
async function executeVerifyEditSession(
|
|
1236
|
-
repoRoot: string,
|
|
1237
|
-
jobId: string,
|
|
1238
|
-
payload: VerifyEditSessionPayload,
|
|
1239
|
-
): Promise<void> {
|
|
1240
|
-
let job = tryReadLocalBridgeJob(repoRoot, jobId);
|
|
1241
|
-
if (!job || job.status !== "running") return;
|
|
1242
|
-
const timeoutMs = resolvedJobTimeout(repoRoot, undefined);
|
|
1243
|
-
job.ownerPid = process.pid;
|
|
1244
|
-
job.deadlineAt = new Date(Date.now() + timeoutMs + 5_000).toISOString();
|
|
1245
|
-
saveJob(repoRoot, job);
|
|
1246
|
-
appendEvent(repoRoot, job.jobId, {
|
|
1247
|
-
type: "job_progress",
|
|
1248
|
-
message: `Verifying edit session ${payload.sessionId}.`,
|
|
1249
|
-
data: { sessionId: payload.sessionId, revision: payload.revision },
|
|
1250
|
-
});
|
|
1251
|
-
try {
|
|
1252
|
-
const session = await verifyEditSessionAsync(repoRoot, payload.sessionId, {
|
|
1253
|
-
checkIds: payload.checkIds,
|
|
1254
|
-
reviewer: payload.reviewer,
|
|
1255
|
-
note: payload.note,
|
|
1256
|
-
}, {
|
|
1257
|
-
onCheckSpawn: (checkId, pid) => {
|
|
1258
|
-
const current = tryReadLocalBridgeJob(repoRoot, jobId);
|
|
1259
|
-
if (!current || current.status !== "running") {
|
|
1260
|
-
releaseControllerCheckSubscription(checkSubscriberId(jobId));
|
|
1261
|
-
return;
|
|
1262
|
-
}
|
|
1263
|
-
current.workerPid = pid;
|
|
1264
|
-
current.ownerPid = process.pid;
|
|
1265
|
-
current.heartbeatAt = now();
|
|
1266
|
-
saveJob(repoRoot, current);
|
|
1267
|
-
appendEvent(repoRoot, current.jobId, {
|
|
1268
|
-
type: "job_progress",
|
|
1269
|
-
message: `Running check ${checkId}.`,
|
|
1270
|
-
data: { checkId, pid },
|
|
1271
|
-
});
|
|
1272
|
-
},
|
|
1273
|
-
subscriberId: checkSubscriberId(jobId),
|
|
1274
|
-
});
|
|
1275
|
-
job = tryReadLocalBridgeJob(repoRoot, jobId);
|
|
1276
|
-
if (!job || job.status !== "running") return;
|
|
1277
|
-
job.status = session.status === "checked" ? "succeeded" : "failed";
|
|
1278
|
-
job.finishedAt = now();
|
|
1279
|
-
job.workerPid = undefined;
|
|
1280
|
-
job.result = {
|
|
1281
|
-
sessionId: session.sessionId,
|
|
1282
|
-
status: session.status,
|
|
1283
|
-
verifiedAt: session.verifiedAt,
|
|
1284
|
-
checkResults: session.checkResults,
|
|
1285
|
-
diffPath: session.diffPath,
|
|
1286
|
-
};
|
|
1287
|
-
if (job.status !== "succeeded") job.error = session.checkResults.find((entry) => !entry.ok)?.summary ?? "edit session verification failed";
|
|
1288
|
-
appendEvent(repoRoot, job.jobId, {
|
|
1289
|
-
type: job.status === "succeeded" ? "job_succeeded" : "job_failed",
|
|
1290
|
-
message: job.status === "succeeded"
|
|
1291
|
-
? `Edit session ${payload.sessionId} verified.`
|
|
1292
|
-
: `Edit session ${payload.sessionId} verification failed.`,
|
|
1293
|
-
data: { sessionId: payload.sessionId, revision: payload.revision },
|
|
1294
|
-
});
|
|
1295
|
-
saveJob(repoRoot, job);
|
|
1296
|
-
} catch (error) {
|
|
1297
|
-
job = tryReadLocalBridgeJob(repoRoot, jobId);
|
|
1298
|
-
if (!job || job.status !== "running") return;
|
|
1299
|
-
markJobTerminal(repoRoot, job, "failed", error instanceof Error ? error.message : String(error));
|
|
1300
|
-
}
|
|
1301
|
-
}
|
|
1302
|
-
|
|
1303
|
-
async function executeRepositoryCommand(
|
|
1304
|
-
repoRoot: string,
|
|
1305
|
-
jobId: string,
|
|
1306
|
-
payload: RepositoryCommandPayload,
|
|
1307
|
-
): Promise<void> {
|
|
1308
|
-
let job = tryReadLocalBridgeJob(repoRoot, jobId);
|
|
1309
|
-
if (!job || job.status !== "running") return;
|
|
1310
|
-
const timeoutMs = resolvedJobTimeout(repoRoot, payload.timeoutMs);
|
|
1311
|
-
job.ownerPid = process.pid;
|
|
1312
|
-
job.deadlineAt = new Date(Date.now() + timeoutMs + 5_000).toISOString();
|
|
1313
|
-
saveJob(repoRoot, job);
|
|
1314
|
-
appendEvent(repoRoot, job.jobId, {
|
|
1315
|
-
type: "job_progress",
|
|
1316
|
-
message: `Executing repository command for ${payload.repoId}.`,
|
|
1317
|
-
data: { repoId: payload.repoId, checkoutId: payload.checkoutId },
|
|
1318
|
-
});
|
|
1319
|
-
try {
|
|
1320
|
-
const repository = resolveRepositorySelection({
|
|
1321
|
-
repoId: payload.repoId,
|
|
1322
|
-
checkoutId: payload.checkoutId,
|
|
1323
|
-
controllerHome: payload.controllerHome,
|
|
1324
|
-
allowSoleRepository: true,
|
|
1325
|
-
});
|
|
1326
|
-
// Durable Execution Jobs already hold repository-scoped leases for the
|
|
1327
|
-
// command lifetime. Holding the controller repository lock here as well
|
|
1328
|
-
// blocks the owning worker from renewing those leases and turns any
|
|
1329
|
-
// command longer than the renewal interval into a false LOCK_HELD failure.
|
|
1330
|
-
const execution = await executeRepositoryCommandAsync(payload.controllerHome, repository, {
|
|
1331
|
-
command: payload.command,
|
|
1332
|
-
cwd: payload.cwd,
|
|
1333
|
-
authorization: "confirmed_plan",
|
|
1334
|
-
approvalToken: payload.approvalToken,
|
|
1335
|
-
approvalRequestId: payload.approvalRequestId,
|
|
1336
|
-
timeoutMs: payload.timeoutMs,
|
|
1337
|
-
maxOutputBytes: payload.maxOutputBytes,
|
|
1338
|
-
}, {
|
|
1339
|
-
onSpawn: (pid) => {
|
|
1340
|
-
const current = tryReadLocalBridgeJob(repoRoot, jobId);
|
|
1341
|
-
if (!current || current.status !== "running") {
|
|
1342
|
-
signalWorker(pid, "SIGTERM");
|
|
1343
|
-
return;
|
|
1344
|
-
}
|
|
1345
|
-
current.workerPid = pid;
|
|
1346
|
-
current.ownerPid = process.pid;
|
|
1347
|
-
current.heartbeatAt = now();
|
|
1348
|
-
saveJob(repoRoot, current);
|
|
1349
|
-
},
|
|
1350
|
-
onStdout: (chunk) => {
|
|
1351
|
-
appendJobOutput(repoRoot, jobId, "stdout", chunk);
|
|
1352
|
-
const current = tryReadLocalBridgeJob(repoRoot, jobId);
|
|
1353
|
-
if (!current || current.status !== "running") return;
|
|
1354
|
-
current.heartbeatAt = now();
|
|
1355
|
-
saveJob(repoRoot, current);
|
|
1356
|
-
},
|
|
1357
|
-
onStderr: (chunk) => {
|
|
1358
|
-
appendJobOutput(repoRoot, jobId, "stderr", chunk);
|
|
1359
|
-
const current = tryReadLocalBridgeJob(repoRoot, jobId);
|
|
1360
|
-
if (!current || current.status !== "running") return;
|
|
1361
|
-
current.heartbeatAt = now();
|
|
1362
|
-
saveJob(repoRoot, current);
|
|
1363
|
-
},
|
|
1364
|
-
});
|
|
1365
|
-
job = tryReadLocalBridgeJob(repoRoot, jobId);
|
|
1366
|
-
if (!job || job.status !== "running") return;
|
|
1367
|
-
const stdoutPath = `.ai/harness/local-jobs/${job.jobId}/stdout.log`;
|
|
1368
|
-
const stderrPath = `.ai/harness/local-jobs/${job.jobId}/stderr.log`;
|
|
1369
|
-
job.workerPid = undefined;
|
|
1370
|
-
job.ownerPid = undefined;
|
|
1371
|
-
job.result = {
|
|
1372
|
-
...(execution as unknown as Record<string, unknown>),
|
|
1373
|
-
stdoutPath,
|
|
1374
|
-
stderrPath,
|
|
1375
|
-
};
|
|
1376
|
-
job.outcome = {
|
|
1377
|
-
process: { exitCode: execution.exitCode, timedOut: execution.timedOut, stdoutPath, stderrPath },
|
|
1378
|
-
policy: {
|
|
1379
|
-
decision: execution.status === "approval_required" ? "approval_required" : "allowed",
|
|
1380
|
-
repositoryChanged: execution.repositoryChanged,
|
|
1381
|
-
changedPaths: execution.changedPaths,
|
|
1382
|
-
},
|
|
1383
|
-
infrastructureError: execution.infrastructureError,
|
|
1384
|
-
};
|
|
1385
|
-
if (execution.status === "approval_required") {
|
|
1386
|
-
job.status = "pending_approval";
|
|
1387
|
-
job.finishedAt = undefined;
|
|
1388
|
-
job.error = undefined;
|
|
1389
|
-
appendEvent(repoRoot, job.jobId, {
|
|
1390
|
-
type: "job_approval_required",
|
|
1391
|
-
message: `Repository command is waiting for approval for ${payload.repoId}.`,
|
|
1392
|
-
data: {
|
|
1393
|
-
repoId: payload.repoId,
|
|
1394
|
-
approvalRequestId: execution.approvalRequestId,
|
|
1395
|
-
authorizationDecision: execution.authorizationDecision,
|
|
1396
|
-
},
|
|
1397
|
-
});
|
|
1398
|
-
saveJob(repoRoot, job);
|
|
1399
|
-
return;
|
|
1400
|
-
}
|
|
1401
|
-
job.status = execution.ok ? "succeeded" : execution.timedOut ? "timed_out" : "failed";
|
|
1402
|
-
job.finishedAt = now();
|
|
1403
|
-
job.error = execution.ok ? undefined : execution.infrastructureError?.message
|
|
1404
|
-
?? execution.stderr
|
|
1405
|
-
?? `repository command exited with ${String(execution.exitCode ?? 1)}`;
|
|
1406
|
-
appendEvent(repoRoot, job.jobId, {
|
|
1407
|
-
type: job.status === "succeeded" ? "job_succeeded" : "job_failed",
|
|
1408
|
-
message: job.status === "succeeded"
|
|
1409
|
-
? `Repository command completed for ${payload.repoId}.`
|
|
1410
|
-
: `Repository command failed for ${payload.repoId}.`,
|
|
1411
|
-
data: { repoId: payload.repoId, exitCode: execution.exitCode, timedOut: execution.timedOut },
|
|
1412
|
-
});
|
|
1413
|
-
saveJob(repoRoot, job);
|
|
1414
|
-
} catch (error) {
|
|
1415
|
-
job = tryReadLocalBridgeJob(repoRoot, jobId);
|
|
1416
|
-
if (!job || job.status !== "running") return;
|
|
1417
|
-
markJobTerminal(repoRoot, job, "failed", error instanceof Error ? error.message : String(error));
|
|
1418
|
-
}
|
|
1419
|
-
}
|
|
1420
|
-
|
|
1421
932
|
export function executeLocalBridgeJobInline(
|
|
1422
933
|
repoRoot: string,
|
|
1423
934
|
jobId: string,
|