@moretea-labs/forge 1.5.0-rc.1 → 1.5.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.
Files changed (259) hide show
  1. package/AGENTS.md +9 -11
  2. package/CHANGELOG.md +19 -0
  3. package/CLAUDE.md +8 -10
  4. package/DESIGN.md +278 -0
  5. package/README.md +70 -90
  6. package/README.zh-CN.md +50 -55
  7. package/SKILL.md +8 -11
  8. package/THIRD_PARTY_NOTICES.md +9 -3
  9. package/assets/branding/README.md +4 -2
  10. package/assets/hooks/lib/workflow-state.sh +19 -18
  11. package/assets/hooks/post-edit-guard.sh +6 -75
  12. package/assets/hooks/prompt-guard.sh +24 -12
  13. package/assets/hooks/session-start-context.sh +17 -17
  14. package/assets/hooks/stop-orchestrator.sh +2 -2
  15. package/assets/partials/04-project-structure.partial.md +6 -6
  16. package/assets/partials/05-workflow.partial.md +6 -6
  17. package/assets/partials/07-footer.partial.md +1 -1
  18. package/assets/partials/08-orchestration.partial.md +2 -2
  19. package/assets/partials-agents/02-operating-mode.partial.md +5 -5
  20. package/assets/partials-agents/03-orchestration.partial.md +3 -3
  21. package/assets/partials-agents/04-task-protocol.partial.md +3 -3
  22. package/assets/partials-agents/08-deep-docs.partial.md +1 -1
  23. package/assets/reference-configs/agentic-development-flow.md +49 -86
  24. package/assets/reference-configs/external-tooling.md +21 -61
  25. package/assets/reference-configs/handoff-protocol.md +25 -20
  26. package/assets/reference-configs/harness-overview.md +8 -8
  27. package/assets/templates/helpers/archive-workflow.sh +0 -1
  28. package/assets/templates/helpers/capture-plan.sh +3 -3
  29. package/assets/templates/helpers/check-task-workflow.sh +2 -2
  30. package/assets/templates/helpers/codex-handoff-resume.sh +5 -5
  31. package/assets/templates/helpers/ensure-task-workflow.sh +37 -35
  32. package/assets/templates/helpers/new-plan.sh +1 -1
  33. package/assets/templates/helpers/plan-to-todo.sh +2 -2
  34. package/assets/templates/helpers/prepare-codex-handoff.sh +2 -2
  35. package/assets/templates/helpers/prepare-handoff.sh +9 -9
  36. package/assets/templates/helpers/refresh-current-status.sh +2 -2
  37. package/assets/templates/helpers/ship-worktrees.sh +1 -1
  38. package/assets/templates/helpers/sprint-backlog.sh +1 -1
  39. package/assets/templates/helpers/verify-sprint.sh +7 -7
  40. package/assets/templates/helpers/workstream-sync.sh +1 -1
  41. package/assets/templates/plan.template.md +1 -1
  42. package/assets/workflow-contract.v1.json +6 -3
  43. package/docs/architecture/current/README.md +10 -9
  44. package/docs/architecture/current/approved-target-architecture.zh-CN.md +2 -2
  45. package/docs/architecture/current/architecture-invariants.md +2 -2
  46. package/docs/architecture/current/automation-and-schedule-engine.md +15 -15
  47. package/docs/architecture/current/codegraph-context-provider.md +2 -2
  48. package/docs/architecture/current/control-plane-authority-inventory.md +12 -0
  49. package/docs/architecture/current/dispatch-and-agent-strategy.md +11 -11
  50. package/docs/architecture/current/entity-model.md +0 -27
  51. package/docs/architecture/current/failure-recovery.md +0 -24
  52. package/docs/architecture/current/governance.md +1 -1
  53. package/docs/architecture/current/implementation-status.md +1 -1
  54. package/docs/architecture/current/legacy-governance.md +58 -0
  55. package/docs/architecture/current/multi-repository-execution.md +1 -1
  56. package/docs/architecture/current/peer-supercontroller-runtime.md +1 -1
  57. package/docs/architecture/current/personal-assistant-plugin-baseline.md +4 -5
  58. package/docs/architecture/current/scheduler-and-resource-claims.md +0 -10
  59. package/docs/architecture/current/target-requirements-traceability.md +2 -2
  60. package/docs/architecture/current/thin-harness-governance-policy.md +1 -1
  61. package/docs/architecture/current/thin-harness-v1.md +9 -11
  62. package/docs/architecture/domains/runtime-harness.md +1 -1
  63. package/docs/forge-autonomous-goal-loop.md +3 -1
  64. package/docs/forge-chatgpt-mcp-setup.md +51 -184
  65. package/docs/images/forge-banner-cn.svg +26 -1
  66. package/docs/images/forge-banner.svg +26 -1
  67. package/docs/operations/features.md +1 -1
  68. package/docs/operations/homebrew.md +3 -3
  69. package/docs/operations/mcp-tool-exposure.md +5 -5
  70. package/docs/operations/platform-support.md +45 -37
  71. package/docs/operations/platform-support.zh-CN.md +40 -38
  72. package/docs/operations/releasing.md +3 -3
  73. package/docs/operations/releasing.zh-CN.md +3 -3
  74. package/docs/operations/troubleshooting.md +11 -6
  75. package/docs/operations/troubleshooting.zh-CN.md +11 -6
  76. package/docs/public-usage-guide.md +28 -21
  77. package/docs/public-usage-guide.zh-CN.md +28 -21
  78. package/docs/tutorials/01-install-and-start.md +56 -35
  79. package/docs/tutorials/01-install-and-start.zh-CN.md +56 -35
  80. package/docs/tutorials/02-connect-chatgpt.md +112 -46
  81. package/docs/tutorials/02-connect-chatgpt.zh-CN.md +113 -45
  82. package/docs/wiki/Architecture.md +1 -1
  83. package/docs/wiki/Installation.md +2 -2
  84. package/docs/wiki/Quick-Start.md +1 -1
  85. package/docs/wiki/Work-Lifecycle.md +1 -1
  86. package/install.ps1 +4 -5
  87. package/install.sh +4 -6
  88. package/package.json +15 -5
  89. package/scripts/archive-workflow.sh +0 -1
  90. package/scripts/benchmark-thin-harness-mcp-e2e.ts +27 -14
  91. package/scripts/build-controller-ui.ts +28 -0
  92. package/scripts/capture-plan.sh +4 -4
  93. package/scripts/check-agent-tooling.sh +12 -1
  94. package/scripts/check-platform-support.mjs +2 -2
  95. package/scripts/check-public-docs.sh +16 -5
  96. package/scripts/check-release-readiness.sh +5 -11
  97. package/scripts/check-runtime-architecture.mjs +14 -22
  98. package/scripts/check-tarball-install-smoke.sh +3 -2
  99. package/scripts/check-task-workflow.sh +2 -2
  100. package/scripts/codex-handoff-resume.sh +5 -5
  101. package/scripts/create-project-dirs.sh +3 -3
  102. package/scripts/ensure-task-workflow.sh +45 -35
  103. package/scripts/init-project.sh +4 -4
  104. package/scripts/install-desktop-operator-registration.ts +2 -2
  105. package/scripts/lib/project-init-lib.sh +46 -44
  106. package/scripts/migrate-project-template.sh +7 -4
  107. package/scripts/new-plan.sh +1 -1
  108. package/scripts/plan-to-todo.sh +2 -2
  109. package/scripts/prepare-codex-handoff.sh +2 -2
  110. package/scripts/prepare-handoff.sh +9 -9
  111. package/scripts/refresh-current-status.sh +2 -2
  112. package/scripts/setup-plugins.sh +3 -3
  113. package/scripts/ship-worktrees.sh +1 -1
  114. package/scripts/sprint-backlog.sh +5 -5
  115. package/scripts/sync-codex-installed-copies.sh +2 -3
  116. package/scripts/verify-sprint.sh +7 -7
  117. package/scripts/workstream-sync.sh +1 -1
  118. package/src/cli/chatgpt-browser/bridge-extension.ts +1 -1
  119. package/src/cli/chatgpt-browser/bridge-provider.ts +29 -0
  120. package/src/cli/chatgpt-browser/file-policy.ts +3 -1
  121. package/src/cli/commands/chatgpt.ts +51 -0
  122. package/src/cli/commands/doctor.ts +1 -1
  123. package/src/cli/commands/init-hook.ts +211 -70
  124. package/src/cli/commands/init.ts +5 -6
  125. package/src/cli/commands/mcp.ts +29 -5
  126. package/src/cli/commands/runtime.ts +60 -8
  127. package/src/cli/commands/setup-profile.ts +441 -0
  128. package/src/cli/controller/check-runner.ts +20 -3
  129. package/src/cli/controller/codex-continuation.ts +4 -7
  130. package/src/cli/controller/context-pack.ts +118 -14
  131. package/src/cli/controller/operational-plan.ts +4 -4
  132. package/src/cli/controller/task-ledger.ts +10 -10
  133. package/src/cli/controller/work-mode.ts +6 -13
  134. package/src/cli/index.ts +14 -35
  135. package/src/cli/local-bridge/connector-freshness.ts +1 -1
  136. package/src/cli/local-bridge/console-automations.ts +160 -0
  137. package/src/cli/local-bridge/dashboard.ts +8 -1303
  138. package/src/cli/local-bridge/facade-api.ts +16 -7
  139. package/src/cli/local-bridge/frontend/src/App.tsx +10 -0
  140. package/src/cli/local-bridge/frontend/src/components/Button.tsx +1 -0
  141. package/src/cli/local-bridge/frontend/src/components/DetailPane.tsx +3 -0
  142. package/src/cli/local-bridge/frontend/src/components/SearchField.tsx +1 -0
  143. package/src/cli/local-bridge/frontend/src/components/SectionHeader.tsx +1 -0
  144. package/src/cli/local-bridge/frontend/src/components/Segmented.tsx +1 -0
  145. package/src/cli/local-bridge/frontend/src/components/StatusText.tsx +3 -0
  146. package/src/cli/local-bridge/frontend/src/design/icons.tsx +11 -0
  147. package/src/cli/local-bridge/frontend/src/design/tokens.css +8 -0
  148. package/src/cli/local-bridge/frontend/src/features/automations/AutomationsView.tsx +3 -0
  149. package/src/cli/local-bridge/frontend/src/features/capabilities/CapabilitiesView.tsx +4 -0
  150. package/src/cli/local-bridge/frontend/src/features/overview/OverviewView.tsx +3 -0
  151. package/src/cli/local-bridge/frontend/src/features/repositories/RepositoriesView.tsx +2 -0
  152. package/src/cli/local-bridge/frontend/src/features/settings/SettingsView.tsx +2 -0
  153. package/src/cli/local-bridge/frontend/src/features/system/SystemView.tsx +2 -0
  154. package/src/cli/local-bridge/frontend/src/features/work/WorkView.tsx +3 -0
  155. package/src/cli/local-bridge/frontend/src/lib/api.ts +23 -0
  156. package/src/cli/local-bridge/frontend/src/lib/format.ts +4 -0
  157. package/src/cli/local-bridge/frontend/src/lib/routes.ts +7 -0
  158. package/src/cli/local-bridge/frontend/src/main.tsx +1 -0
  159. package/src/cli/local-bridge/frontend/src/shell/AppShell.tsx +1 -0
  160. package/src/cli/local-bridge/frontend/src/shell/CommandBar.tsx +2 -0
  161. package/src/cli/local-bridge/frontend/src/shell/Sidebar.tsx +3 -0
  162. package/src/cli/local-bridge/frontend/src/styles.css +12 -0
  163. package/src/cli/local-bridge/frontend/src/types.ts +14 -0
  164. package/src/cli/local-bridge/frontend/src/vite-env.d.ts +1 -0
  165. package/src/cli/local-bridge/frontend/vite.config.ts +27 -0
  166. package/src/cli/local-bridge/server.ts +44 -0
  167. package/src/cli/local-bridge/ui-dist/app.css +1 -0
  168. package/src/cli/local-bridge/ui-dist/app.js +11094 -0
  169. package/src/cli/mcp/instructions.ts +3 -3
  170. package/src/cli/mcp/legacy-tool-service.ts +27 -23
  171. package/src/cli/mcp/multi-repository.ts +2 -0
  172. package/src/cli/mcp/policy.ts +7 -5
  173. package/src/cli/mcp/repository-tools.ts +53 -14
  174. package/src/cli/mcp/server.ts +5 -10
  175. package/src/cli/mcp/setup.ts +211 -275
  176. package/src/cli/mcp/tool-capability-cache.ts +1 -1
  177. package/src/cli/mcp/toolset-names.ts +1 -1
  178. package/src/cli/mcp/toolset.ts +0 -1
  179. package/src/cli/mcp/transports/http.ts +24 -4
  180. package/src/cli/repositories/branch-name-policy.ts +0 -7
  181. package/src/cli/repositories/controller-home.ts +110 -3
  182. package/src/cli/repositories/safe-patch.ts +1 -1
  183. package/src/cli/repositories/selected-path-actions.ts +26 -24
  184. package/src/core/adoption/gitignore-plan.ts +2 -3
  185. package/src/core/adoption/plan.ts +4 -1
  186. package/src/runtime/control-plane/execution/edit-validation-coordinator.ts +556 -0
  187. package/src/runtime/control-plane/execution/work-handle-store.ts +128 -1
  188. package/src/runtime/control-plane/execution/work-validation-reconciler.ts +277 -0
  189. package/src/runtime/control-plane/execution/work-verification-snapshot.ts +169 -0
  190. package/src/runtime/control-plane/facade/capability-registry.ts +0 -10
  191. package/src/runtime/control-plane/facade/handoff-inbox-store.ts +44 -25
  192. package/src/runtime/control-plane/facade/suggested-actions.ts +7 -1
  193. package/src/runtime/control-plane/facade/types.ts +0 -1
  194. package/src/runtime/control-plane/global-scheduler/scheduler.ts +30 -8
  195. package/src/runtime/control-plane/launcher/chatgpt-work-binding-store.ts +114 -0
  196. package/src/runtime/control-plane/launcher/chatgpt-work-continuation.ts +175 -0
  197. package/src/runtime/control-plane/launcher/launch-reservation-store.ts +161 -0
  198. package/src/runtime/control-plane/launcher/provider-mcp-bootstrap.ts +64 -0
  199. package/src/runtime/control-plane/launcher/thin-launcher.ts +117 -24
  200. package/src/runtime/control-plane/routing/route-policy.ts +14 -14
  201. package/src/runtime/control-plane/runtime-cleanup.ts +0 -1
  202. package/src/runtime/evidence/event-ledger.ts +1 -1
  203. package/src/runtime/{workflow/campaigns/workspace.ts → execution/managed-workspace.ts} +41 -43
  204. package/src/runtime/execution/process-runtime/check-facade.ts +6 -0
  205. package/src/runtime/execution/process-runtime/check-result.ts +45 -0
  206. package/src/runtime/execution/process-runtime/check-runner-sidecar.ts +42 -16
  207. package/src/runtime/execution/process-runtime/command-facade.ts +4 -2
  208. package/src/runtime/execution/process-runtime/gc.ts +1 -1
  209. package/src/runtime/execution/process-runtime/index.ts +3 -0
  210. package/src/runtime/execution/process-runtime/interactive-admission.ts +14 -5
  211. package/src/runtime/execution/process-runtime/persisted-check.ts +285 -0
  212. package/src/runtime/execution/process-runtime/resource-claims.ts +30 -0
  213. package/src/runtime/execution/process-runtime/runtime.ts +18 -1
  214. package/src/runtime/execution/process-runtime/store.ts +1 -19
  215. package/src/runtime/execution/process-runtime/types.ts +4 -0
  216. package/src/runtime/execution/thin-harness/execution-router.ts +0 -1
  217. package/src/runtime/execution/thin-harness/fast-executor.ts +1 -1
  218. package/src/runtime/execution/thin-harness/lightweight-lanes.ts +1 -2
  219. package/src/runtime/execution/thin-harness/types.ts +0 -1
  220. package/src/runtime/execution/workers/executor.ts +1 -1
  221. package/src/runtime/gateway/mcp/execution-tools.ts +1 -1
  222. package/src/runtime/gateway/mcp/persisted-check-process.ts +3 -255
  223. package/src/runtime/gateway/mcp/process-tools.ts +16 -3
  224. package/src/runtime/gateway/mcp/resource-policy.ts +0 -9
  225. package/src/runtime/gateway/mcp/router.ts +117 -182
  226. package/src/runtime/gateway/mcp/runtime-tools.ts +331 -409
  227. package/src/runtime/gateway/mcp/work-validation-reconciler.ts +1 -219
  228. package/src/runtime/plugins/browser-adapter.ts +5 -0
  229. package/src/runtime/plugins/desktop-operator-registration.ts +1 -1
  230. package/src/runtime/plugins/store.ts +14 -6
  231. package/src/runtime/plugins/types.ts +1 -1
  232. package/src/runtime/projections/materialized-view.ts +1 -23
  233. package/src/runtime/recovery/maintenance-executor.ts +9 -0
  234. package/src/runtime/resources/ownership.ts +0 -1
  235. package/src/runtime/root/gateway-adapter.ts +2 -0
  236. package/src/runtime/root/mcp-transport.ts +10 -2
  237. package/src/runtime/root/package-runtime-release.ts +161 -0
  238. package/src/runtime/root/package-runtime-service.ts +172 -0
  239. package/src/runtime/root/runtime.ts +2 -1
  240. package/src/runtime/root/scheduler.ts +5 -0
  241. package/src/runtime/root/service.ts +18 -5
  242. package/src/runtime/standalone-recovery/core.ts +65 -16
  243. package/src/runtime/workflow/findings/store.ts +145 -106
  244. package/src/runtime/workflow/findings/types.ts +22 -0
  245. package/src/runtime/workflow/schedules/engine.ts +132 -2
  246. package/src/runtime/workflow/schedules/pending-activation.ts +139 -0
  247. package/src/runtime/workflow/schedules/work-continuation.ts +218 -0
  248. package/docs/CHANGELOG.md +0 -978
  249. package/docs/README.zh-CN.md +0 -58
  250. package/scripts/smoke-chatgpt-supervised-automation.ts +0 -208
  251. package/src/cli/commands/controller.ts +0 -680
  252. package/src/runtime/workflow/campaigns/cleanup.ts +0 -263
  253. package/src/runtime/workflow/campaigns/engine.ts +0 -112
  254. package/src/runtime/workflow/campaigns/normalize.ts +0 -100
  255. package/src/runtime/workflow/campaigns/review.ts +0 -315
  256. package/src/runtime/workflow/campaigns/store.ts +0 -526
  257. package/src/runtime/workflow/campaigns/supervisor.ts +0 -112
  258. package/src/runtime/workflow/campaigns/types.ts +0 -290
  259. /package/src/runtime/{workflow/campaigns → execution}/workspace-agent.ts +0 -0
@@ -1,255 +1,3 @@
1
- import { createHash } from 'crypto';
2
- import { existsSync } from 'fs';
3
- import { dirname, resolve } from 'path';
4
- import {
5
- controllerCheckExecutionIdentity,
6
- listControllerChecks,
7
- snapshotControllerCheck,
8
- } from '../../../cli/controller/check-runner';
9
- import {
10
- currentCliRuntimeTarget,
11
- resolveCliChildInvocation,
12
- type CliChildInvocation,
13
- type CliChildInvocationOptions,
14
- type CliRuntimeTarget,
15
- } from '../../../cli/runtime-invocation';
16
- import { readRuntimeGeneration, resolveControllerRuntimeSourceRoot } from '../../control-plane/runtime-generation';
17
- import {
18
- checkRequiresDurableWorkflow,
19
- claimsForCheck,
20
- spawnManagedProcess,
21
- toProcessClaims,
22
- type CheckExecutionMode,
23
- processCheckSemanticScopeKey,
24
- type RunCheckFacadeInput,
25
- type RunCheckFacadeResult,
26
- } from '../../execution/process-runtime';
27
- import { durationAwareInteractiveWaitMs } from '../../execution/process-runtime/interactive-admission';
28
- const PERSISTED_CHECK_SOURCE_ENTRY = 'src/runtime/execution/process-runtime/check-runner-sidecar.ts';
29
-
30
- export function resolvePersistedCheckCliInvocation(
31
- cliEntry: string,
32
- args: string[],
33
- options: CliChildInvocationOptions = {},
34
- ): CliChildInvocation {
35
- return resolveCliChildInvocation(cliEntry, args, options);
36
- }
37
-
38
- export function resolveRuntimeCliTarget(controllerHome?: string): CliRuntimeTarget {
39
- const moduleSourceRoot = resolve(import.meta.dir, '..', '..', '..', '..');
40
- const sourceEntry = resolve(moduleSourceRoot, 'src', 'cli', 'index.ts');
41
- const source = resolveControllerRuntimeSourceRoot({
42
- explicitRoot: existsSync(sourceEntry) ? moduleSourceRoot : undefined,
43
- });
44
- const sourceMode = Boolean(source.root && existsSync(resolve(source.root, 'src', 'cli', 'index.ts')));
45
- const runtimeEnv = { ...process.env };
46
- if (sourceMode) {
47
- delete runtimeEnv.FORGE_RUNTIME_EXECUTION;
48
- delete runtimeEnv.FORGE_RUNTIME_CLI_ENTRY;
49
- }
50
- const generation = controllerHome ? readRuntimeGeneration(controllerHome) : undefined;
51
- return currentCliRuntimeTarget({
52
- env: runtimeEnv,
53
- argv: sourceMode ? [] : process.argv,
54
- moduleUrl: sourceMode ? undefined : import.meta.url,
55
- sourceRoot: source.root,
56
- cwd: source.root ?? moduleSourceRoot,
57
- sourceRevision: generation?.source.releaseRevision
58
- ?? generation?.source.commit
59
- ?? process.env.FORGE_ACTIVE_RUNTIME_REVISION,
60
- });
61
- }
62
-
63
- export function resolveRuntimeCliEntry(controllerHome?: string): string {
64
- return resolveRuntimeCliTarget(controllerHome).entry;
65
- }
66
-
67
- export function persistedCheckSemanticScopeKey(
68
- input: Pick<RunCheckFacadeInput, 'workId' | 'verificationBinding' | 'checkoutId'>,
69
- reuseScope: 'repository' | 'checkout',
70
- ): string {
71
- return processCheckSemanticScopeKey(input, reuseScope);
72
- }
73
-
74
- export function resolvePersistedCheckRuntimeExecutable(
75
- cliTarget: CliRuntimeTarget,
76
- runtimeExecutable = process.execPath,
77
- entryExists: (path: string) => boolean = existsSync,
78
- ): string {
79
- if (cliTarget.runtimeKind !== 'compiled_bun_release') return runtimeExecutable;
80
- const checkRunner = resolve(dirname(runtimeExecutable), 'forge-check-runner');
81
- if (!entryExists(checkRunner)) {
82
- throw new Error(`PERSISTED_CHECK_RUNNER_MISSING: ${checkRunner}`);
83
- }
84
- return checkRunner;
85
- }
86
-
87
- export function resolvePersistedCheckProcessInvocation(
88
- cliTarget: CliRuntimeTarget,
89
- args: string[],
90
- options: { runtimeExecutable?: string; entryExists?: (path: string) => boolean } = {},
91
- ): CliChildInvocation {
92
- const runtimeExecutable = options.runtimeExecutable ?? process.execPath;
93
- const executable = resolvePersistedCheckRuntimeExecutable(cliTarget, runtimeExecutable, options.entryExists ?? existsSync);
94
- if (cliTarget.runtimeKind === 'compiled_bun_release') {
95
- return { executable, args };
96
- }
97
- const sourceEntry = resolve(cliTarget.cwd, PERSISTED_CHECK_SOURCE_ENTRY);
98
- if (!(options.entryExists ?? existsSync)(sourceEntry)) {
99
- throw new Error(`PERSISTED_CHECK_SOURCE_RUNNER_MISSING: ${sourceEntry}`);
100
- }
101
- return resolvePersistedCheckCliInvocation(sourceEntry, args, {
102
- runtimeExecutable: executable,
103
- runtimeKind: cliTarget.runtimeKind,
104
- sourceRevision: cliTarget.sourceRevision,
105
- immutable: false,
106
- ...(cliTarget.runtimeKind === 'package_launcher' ? { launcherEntry: cliTarget.entry } : {}),
107
- });
108
- }
109
-
110
- /**
111
- * Run a registered check through Process Runtime while keeping check-runner
112
- * evidence authoritative. The managed OS process invokes the same immutable
113
- * forge CLI bundle with a hidden internal subcommand; that subcommand
114
- * executes runControllerCheck, writes the Artifact atomically, mirrors bounded
115
- * stdout/stderr, and exits with the exact check status.
116
- */
117
- export async function runPersistedCheckViaProcessRuntime(
118
- input: RunCheckFacadeInput,
119
- ): Promise<RunCheckFacadeResult> {
120
- const emptyEffects = {
121
- executionJobCount: 0,
122
- localJobCount: 0,
123
- workerSpawnCount: 0,
124
- projectionUpdateCount: 0,
125
- };
126
- const check = listControllerChecks(input.repoRoot).find((entry) => entry.id === input.checkId);
127
- if (!check) {
128
- return {
129
- mode: 'durable',
130
- checkId: input.checkId,
131
- durable: {
132
- reason: 'check_not_found_or_requires_registry_lookup',
133
- suggestedOperation: 'list_checks then run_check with a known check_id',
134
- },
135
- durableSideEffects: emptyEffects,
136
- };
137
- }
138
- if (input.forceDurable || checkRequiresDurableWorkflow(input.checkId, check)) {
139
- return {
140
- mode: 'durable',
141
- checkId: input.checkId,
142
- check,
143
- durable: {
144
- reason: 'multi_phase_or_release_check_requires_durable_workflow',
145
- suggestedOperation: 'Claim the related WorkContract and run this check through an external Controller.',
146
- },
147
- durableSideEffects: emptyEffects,
148
- };
149
- }
150
-
151
- const interactiveWaitMs = durationAwareInteractiveWaitMs(check.command, input.interactiveWaitMs);
152
- const leaseWaitMs = input.leaseWaitMs;
153
- const timeoutMs = Math.min(
154
- check.timeoutMs,
155
- typeof input.timeoutMs === 'number' && Number.isFinite(input.timeoutMs)
156
- ? Math.max(1_000, Math.trunc(input.timeoutMs))
157
- : check.timeoutMs,
158
- );
159
- if (!input.executionIdentity) {
160
- throw new Error('EXECUTION_IDENTITY_REQUIRED: persisted run_check requires an immutable executionIdentity');
161
- }
162
- const executionIdentity = input.executionIdentity;
163
- if (executionIdentity.repositoryId !== input.repoId) {
164
- throw new Error(
165
- `EXECUTION_IDENTITY_MISMATCH: check repo ${input.repoId} differs from identity ${executionIdentity.repositoryId}`,
166
- );
167
- }
168
- if (input.checkoutId?.trim() && executionIdentity.checkoutId !== input.checkoutId.trim()) {
169
- throw new Error(
170
- `CHECKOUT_ROUTE_MISMATCH: check checkout ${input.checkoutId} differs from identity ${executionIdentity.checkoutId}`,
171
- );
172
- }
173
- const claims = claimsForCheck(
174
- input.checkId,
175
- check.command,
176
- executionIdentity.repositoryId,
177
- executionIdentity.checkoutId,
178
- check.effects,
179
- );
180
- const checkSnapshot = snapshotControllerCheck(input.repoRoot, input.checkId);
181
- const checkFingerprint = createHash('sha256')
182
- .update(JSON.stringify(checkSnapshot))
183
- .digest('hex');
184
- const semanticCheck = controllerCheckExecutionIdentity(
185
- input.repoRoot,
186
- input.checkId,
187
- timeoutMs,
188
- checkSnapshot,
189
- );
190
- const processCheckExecution = {
191
- schemaVersion: 1 as const,
192
- checkId: semanticCheck.checkId,
193
- cacheKey: semanticCheck.cacheKey,
194
- revision: semanticCheck.revision,
195
- definitionDigest: semanticCheck.definitionDigest,
196
- environmentFingerprint: semanticCheck.environmentFingerprint,
197
- timeoutMs: semanticCheck.timeoutMs,
198
- reuseScope: semanticCheck.reuseScope,
199
- scopeKey: persistedCheckSemanticScopeKey(input, semanticCheck.reuseScope),
200
- };
201
- const cliTarget = resolveRuntimeCliTarget(input.controllerHome);
202
- const checkArgs = [
203
- '--repo',
204
- executionIdentity.canonicalRoot,
205
- '--check-id',
206
- input.checkId,
207
- '--timeout-ms',
208
- String(timeoutMs),
209
- '--expected-check-fingerprint',
210
- checkFingerprint,
211
- ];
212
- const invocation = resolvePersistedCheckProcessInvocation(cliTarget, checkArgs);
213
- const handle = await spawnManagedProcess({
214
- controllerHome: input.controllerHome,
215
- repoId: executionIdentity.repositoryId,
216
- checkoutId: executionIdentity.checkoutId,
217
- executionIdentity,
218
- workId: input.workId,
219
- commandId: input.commandId,
220
- command: {
221
- kind: 'argv',
222
- executable: invocation.executable,
223
- args: invocation.args,
224
- cwd: executionIdentity.canonicalRoot,
225
- },
226
- interactiveWaitMs,
227
- leaseWaitMs,
228
- timeoutMs: timeoutMs + 5_000,
229
- resourceClaims: toProcessClaims(claims),
230
- checkExecution: processCheckExecution,
231
- origin: {
232
- surface: 'check',
233
- toolName: 'run_check',
234
- checkId: input.checkId,
235
- requestId: input.requestId,
236
- correlationId: input.workId,
237
- executionSessionId: input.verificationBinding?.executionSessionId,
238
- editSessionId: input.verificationBinding?.editSessionId,
239
- editRevision: input.verificationBinding?.editRevision,
240
- issueId: input.verificationBinding?.issueId,
241
- taskId: input.verificationBinding?.taskId,
242
- },
243
- signal: input.signal,
244
- });
245
-
246
- const mode: CheckExecutionMode = handle.completed ? 'direct' : 'managed';
247
- return {
248
- mode,
249
- checkId: input.checkId,
250
- check,
251
- process: handle,
252
- ok: handle.completed ? handle.ok : undefined,
253
- durableSideEffects: handle.durableSideEffects,
254
- };
255
- }
1
+ // Compatibility import path. Persisted check execution belongs to Process Runtime
2
+ // so Scheduler reconciliation can advance validation without depending on Gateway.
3
+ export * from '../../execution/process-runtime/persisted-check';
@@ -96,6 +96,10 @@ export const processToolDefinitions: McpToolDefinition[] = [
96
96
  ];
97
97
 
98
98
  const processToolNames = new Set(processToolDefinitions.map((tool) => tool.name));
99
+ // Public MCP clients commonly detach around one minute. Return a normal attach
100
+ // snapshot before that deadline rather than allowing transport timeout to turn
101
+ // a healthy Process into an error-shaped response.
102
+ export const DEFAULT_PROCESS_WAIT_ATTACH_BUDGET_MS = 55_000;
99
103
 
100
104
  function result(value: Record<string, unknown>, isError = false): CallToolResult {
101
105
  const safe = redactSensitiveValue(value).value;
@@ -181,14 +185,23 @@ export async function callProcessTool(
181
185
  });
182
186
  }
183
187
  case 'process_wait': {
184
- const timeoutMs = typeof args.timeout_ms === 'number' && Number.isFinite(args.timeout_ms)
188
+ const requestedWaitMs = typeof args.timeout_ms === 'number' && Number.isFinite(args.timeout_ms)
185
189
  ? Math.max(1, Math.trunc(args.timeout_ms))
186
190
  : 15_000;
187
- const handle = await waitForProcess(ctx.controllerHome, repoId, processId, { timeoutMs });
191
+ const testBudget = (ctx as MultiRepositoryMcpToolContext & { processWaitAttachBudgetMs?: unknown }).processWaitAttachBudgetMs;
192
+ const attachBudgetMs = typeof testBudget === 'number' && Number.isFinite(testBudget)
193
+ ? Math.max(1, Math.trunc(testBudget))
194
+ : DEFAULT_PROCESS_WAIT_ATTACH_BUDGET_MS;
195
+ const startedAt = Date.now();
196
+ const handle = await waitForProcess(ctx.controllerHome, repoId, processId, {
197
+ timeoutMs: Math.min(requestedWaitMs, attachBudgetMs),
198
+ });
188
199
  return result({
189
200
  repoId,
190
201
  process: handleToPayload(handle),
191
- waitedMs: timeoutMs,
202
+ waitedMs: Date.now() - startedAt,
203
+ requestedWaitMs,
204
+ attachBudgetMs,
192
205
  reExecuted: false,
193
206
  });
194
207
  }
@@ -41,9 +41,6 @@ const READ_ONLY_TOOLS = new Set([
41
41
  'get_task_run_log',
42
42
  'get_task_diff',
43
43
  'get_worklog_timeline',
44
- 'list_campaigns',
45
- 'get_campaign',
46
- 'get_campaign_review_packet',
47
44
  'capability_recovery_probe',
48
45
  'capability_recovery_plan',
49
46
  'runtime_maintenance_status',
@@ -69,8 +66,6 @@ const REPO_STATE_TOOLS = new Set([
69
66
  'record_candidate_finding', 'repository_register', 'repository_refresh', 'repository_validate',
70
67
  'repository_update', 'repository_disable', 'repository_remove', 'create_edit_savepoint',
71
68
  'begin_edit_session', 'set_current_issue', 'archive_issue', 'restore_issue', 'reconcile_project_governance',
72
- 'create_campaign', 'add_campaign_task', 'pause_campaign', 'resume_campaign', 'cancel_campaign',
73
- 'submit_campaign_review', 'accept_campaign', 'reconcile_campaign',
74
69
  'capability_recovery_apply', 'runtime_maintenance_apply', 'external_filesystem_grant_apply',
75
70
  'goal_create', 'goal_start', 'goal_continue', 'goal_stop', 'goal_finalize', 'goal_tick_once',
76
71
  'goal_handoff_packet_create', 'executor_dispatch', 'repair_continue',
@@ -115,10 +110,6 @@ function isolatedWorktreeKey(args: Record<string, unknown>): string {
115
110
 
116
111
  export function claimsForMcpOperation(name: string, args: Record<string, unknown>, repoId: string, checkoutId?: string): ResourceClaimSpec[] {
117
112
  if (READ_ONLY_TOOLS.has(name)) return [];
118
- if (name === 'create_campaign') return [
119
- { resourceKey: 'repo-state', mode: 'write' },
120
- { resourceKey: `git-refs:${repoId}`, mode: 'exclusive' },
121
- ];
122
113
  if (REPO_STATE_TOOLS.has(name)) return [{ resourceKey: 'repo-state', mode: 'write' }];
123
114
  // run_check: only true heavy/release checks take exclusive heavy-check lock.
124
115
  // Ordinary typecheck / lint / package scripts use fine-grained claims.