@moretea-labs/forge 1.6.0 → 1.7.1

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 (469) hide show
  1. package/AGENTS.md +4 -0
  2. package/CHANGELOG.md +39 -0
  3. package/CLAUDE.md +4 -0
  4. package/README.md +2 -2
  5. package/README.zh-CN.md +1 -1
  6. package/SKILL.md +2 -2
  7. package/THIRD_PARTY_NOTICES.md +1 -1
  8. package/agents/openai.yaml +1 -1
  9. package/assets/hooks/hook-input.sh +11 -8
  10. package/assets/hooks/lib/session-state.sh +10 -7
  11. package/assets/hooks/lib/workflow-state.sh +13 -177
  12. package/assets/hooks/post-tool-observer.sh +8 -2
  13. package/assets/hooks/prompt-guard.sh +5 -81
  14. package/assets/hooks/session-start-context.sh +56 -1
  15. package/assets/partials/05-workflow.partial.md +1 -1
  16. package/assets/partials-agents/02-operating-mode.partial.md +2 -0
  17. package/assets/partials-agents/03-orchestration.partial.md +1 -1
  18. package/assets/plugin-registry.v1.json +3 -3
  19. package/assets/reference-configs/document-generation.md +1 -1
  20. package/assets/reference-configs/harness-overview.md +1 -1
  21. package/assets/reference-configs/sprint-contracts.md +3 -3
  22. package/assets/skill-version.json +2 -2
  23. package/assets/templates/contract.template.md +2 -7
  24. package/assets/templates/helpers/capture-plan.sh +2 -2
  25. package/assets/templates/helpers/check-architecture-sync.sh +17 -0
  26. package/assets/templates/helpers/check-task-workflow.sh +4 -4
  27. package/assets/templates/helpers/contract-worktree.sh +1 -21
  28. package/assets/templates/helpers/ensure-task-workflow.sh +11 -36
  29. package/assets/templates/helpers/inspect-project-state.ts +8 -6
  30. package/assets/templates/helpers/migrate-project-template.sh +22 -45
  31. package/assets/templates/helpers/migrate-workflow-docs.ts +9 -7
  32. package/assets/templates/helpers/new-plan.sh +1 -1
  33. package/assets/templates/helpers/plan-to-todo.sh +12 -37
  34. package/assets/templates/helpers/ship-worktrees.sh +2 -29
  35. package/assets/templates/helpers/verify-contract.sh +1 -111
  36. package/assets/templates/helpers/verify-sprint.sh +3 -180
  37. package/assets/templates/helpers/workflow-contract.ts +5 -1
  38. package/assets/templates/plan.template.md +1 -1
  39. package/assets/templates/review.template.md +9 -34
  40. package/assets/workflow-contract.v1.json +10 -19
  41. package/docs/README.md +10 -10
  42. package/docs/architecture/CURRENT.md +178 -0
  43. package/docs/architecture/EVOLUTION.md +42 -0
  44. package/docs/architecture/current/README.md +4 -156
  45. package/docs/architecture/decisions/20260803-release-identity-binding-and-exit-policy.md +2 -2
  46. package/docs/architecture/decisions/20260823-immediate-controller-relay.md +53 -0
  47. package/docs/architecture/decisions/20260826-browser-runtime-v2.md +73 -0
  48. package/docs/architecture/history/README.md +7 -0
  49. package/docs/architecture/{chatgpt-handoff-facade.md → history/chatgpt-handoff-facade.md} +4 -0
  50. package/docs/architecture/{global-hook-runtime.md → history/global-hook-runtime.md} +7 -3
  51. package/docs/architecture/{ios-semantic-automation-provider-v2.md → history/ios-semantic-automation-provider-v2.md} +6 -2
  52. package/docs/architecture/history.md +3 -34
  53. package/docs/architecture/index.md +15 -98
  54. package/docs/architecture/modules/controller-runtime/transport-lifecycle.md +1 -1
  55. package/docs/architecture/reviews/2026-08-22-semantic-harness-convergence-acceptance.md +39 -0
  56. package/docs/architecture/versions/1.6.md +38 -0
  57. package/docs/architecture/versions/1.7.md +41 -0
  58. package/docs/forge-chatgpt-browser-engine.md +2 -2
  59. package/docs/forge-chatgpt-mcp-setup.md +4 -28
  60. package/docs/forge-chatgpt-supervised-automation.md +3 -3
  61. package/docs/forge-github-issue-launcher.md +1 -1
  62. package/docs/forge-plugin-management.md +1 -1
  63. package/docs/forge-runtime-self-healing-loop.md +1 -1
  64. package/docs/operations/controller-browser-plugin.md +26 -6
  65. package/docs/operations/controller-performance-and-502.md +143 -0
  66. package/docs/operations/controller-reliability-runbook.md +1 -1
  67. package/docs/operations/features.md +2 -2
  68. package/docs/operations/github-repository.md +1 -1
  69. package/docs/operations/homebrew.md +2 -2
  70. package/docs/operations/mcp-tool-exposure.md +5 -3
  71. package/docs/wiki/Architecture.md +6 -6
  72. package/docs/wiki/Implementation.md +2 -2
  73. package/docs/wiki/Integrations.md +2 -2
  74. package/docs/wiki/Work-Lifecycle.md +1 -1
  75. package/package.json +33 -11
  76. package/scripts/activate-source-baseline.ts +17 -13
  77. package/scripts/architecture-event.ts +2 -820
  78. package/scripts/architecture-queue.sh +2 -645
  79. package/scripts/archive-architecture-request.sh +2 -242
  80. package/scripts/archive-workflow.sh +1 -291
  81. package/scripts/benchmark-background-check-overlap.ts +228 -0
  82. package/scripts/benchmark-mcp-host.sh +117 -0
  83. package/scripts/benchmark-mcp-transport.ts +170 -0
  84. package/scripts/benchmark-quality-harness.ts +146 -0
  85. package/scripts/benchmark-route-session-concurrency.ts +207 -6
  86. package/scripts/benchmark-thin-harness-mcp-e2e.ts +7 -1
  87. package/scripts/benchmark-typescript-navigation.ts +186 -0
  88. package/scripts/benchmark-work-efficiency.ts +334 -0
  89. package/scripts/capability-config.ts +2 -392
  90. package/scripts/capability-resolver.ts +2 -503
  91. package/scripts/capture-plan.sh +1 -332
  92. package/scripts/check-agent-tooling.sh +2 -1558
  93. package/scripts/check-architecture-sync.sh +2 -371
  94. package/scripts/check-brain-manifest.sh +2 -253
  95. package/scripts/check-context-files.sh +2 -47
  96. package/scripts/check-deploy-sql-order.sh +2 -115
  97. package/scripts/check-mcp-compatibility.ts +14 -0
  98. package/scripts/check-runtime-architecture.mjs +349 -79
  99. package/scripts/check-skill-version.ts +3 -191
  100. package/scripts/check-source-duplication.mjs +61 -0
  101. package/scripts/check-stable-baseline.ts +92 -0
  102. package/scripts/check-task-sync.sh +2 -63
  103. package/scripts/check-task-workflow.sh +2 -1000
  104. package/scripts/codex-handoff-resume.sh +2 -267
  105. package/scripts/context-contract-sync.sh +2 -514
  106. package/scripts/contract-run.ts +2 -463
  107. package/scripts/contract-worktree.sh +1 -722
  108. package/scripts/ensure-task-workflow.sh +1 -1225
  109. package/scripts/host-temporary-cloud-mcp-e2e.sh +265 -0
  110. package/scripts/inspect-project-state.ts +4 -279
  111. package/scripts/install-standalone-recovery.ts +24 -0
  112. package/scripts/lib/project-init-lib.sh +22 -46
  113. package/scripts/lib/run-forge-helper.sh +19 -0
  114. package/scripts/lib/run-forge-helper.ts +26 -0
  115. package/scripts/migrate-project-template.sh +1 -1189
  116. package/scripts/migrate-workflow-docs.ts +4 -412
  117. package/scripts/new-plan.sh +1 -180
  118. package/scripts/new-spec.sh +1 -47
  119. package/scripts/new-sprint.sh +1 -46
  120. package/scripts/plan-to-todo.sh +1 -796
  121. package/scripts/prepare-codex-handoff.sh +2 -201
  122. package/scripts/prepare-handoff.sh +1 -78
  123. package/scripts/refresh-current-status.sh +2 -467
  124. package/scripts/run-governed-gate.ts +5 -1
  125. package/scripts/select-agent-context-blocks.sh +2 -64
  126. package/scripts/ship-worktrees.sh +1 -558
  127. package/scripts/smoke-ios-physical-device.ts +4 -2
  128. package/scripts/smoke-runtime-recovery.ts +1 -35
  129. package/scripts/smoke-schedule-engine.ts +1 -20
  130. package/scripts/sprint-backlog.sh +1 -834
  131. package/scripts/stage-runtime-release.ts +2 -1
  132. package/scripts/summarize-failures.sh +2 -123
  133. package/scripts/switch-plan.sh +1 -150
  134. package/scripts/sync-brain-docs.sh +2 -379
  135. package/scripts/sync-generated-authority.mjs +175 -0
  136. package/scripts/verify-contract.sh +2 -703
  137. package/scripts/verify-forge-runtime.sh +0 -1
  138. package/scripts/verify-sprint.sh +1 -677
  139. package/scripts/workflow-contract.ts +4 -205
  140. package/scripts/workstream-sync.sh +2 -261
  141. package/src/cli/agent-jobs/executor-health.ts +1 -1
  142. package/src/cli/commands/init-hook.ts +3 -3
  143. package/src/cli/commands/mcp.ts +9 -5
  144. package/src/cli/commands/plugin.ts +12 -3
  145. package/src/cli/commands/recovery.ts +25 -3
  146. package/src/cli/commands/runtime.ts +55 -3
  147. package/src/cli/commands/security.ts +12 -1
  148. package/src/cli/commands/setup-profile.ts +31 -21
  149. package/src/cli/controller/check-runner.ts +113 -5
  150. package/src/cli/controller/composite-result.ts +1 -1
  151. package/src/cli/controller/context/focus.ts +51 -0
  152. package/src/cli/controller/context/instruction-context.ts +114 -0
  153. package/src/cli/controller/context/known-paths.ts +76 -0
  154. package/src/cli/controller/context/query-planning.ts +110 -0
  155. package/src/cli/controller/context/rule-resolution.ts +532 -0
  156. package/src/cli/controller/context/source-materializer.ts +278 -0
  157. package/src/cli/controller/context/structural.ts +16 -0
  158. package/src/cli/controller/context/types.ts +286 -0
  159. package/src/cli/controller/context-pack.ts +828 -487
  160. package/src/cli/controller/launch-agents.ts +77 -2
  161. package/src/cli/controller/operational-plan.ts +2 -2
  162. package/src/cli/controller/work-mode.ts +6 -4
  163. package/src/cli/editing/edit-session.ts +60 -7
  164. package/src/cli/github/contracts.ts +16 -0
  165. package/src/cli/github/github.ts +135 -16
  166. package/src/cli/github/session.ts +2 -1
  167. package/src/cli/installer/managed-entries.ts +15 -1
  168. package/src/cli/local-bridge/console-automations.ts +54 -78
  169. package/src/cli/local-bridge/console-view-models.ts +1 -35
  170. package/src/cli/local-bridge/facade-api.ts +37 -264
  171. package/src/cli/local-bridge/frontend/src/App.tsx +3 -3
  172. package/src/cli/local-bridge/frontend/src/features/automations/AutomationsView.tsx +23 -13
  173. package/src/cli/local-bridge/frontend/src/features/capabilities/CapabilitiesView.tsx +37 -4
  174. package/src/cli/local-bridge/frontend/src/features/overview/OverviewView.tsx +6 -4
  175. package/src/cli/local-bridge/frontend/src/lib/api.ts +1 -6
  176. package/src/cli/local-bridge/frontend/src/lib/routes.ts +1 -1
  177. package/src/cli/local-bridge/frontend/src/shell/Sidebar.tsx +2 -2
  178. package/src/cli/local-bridge/frontend/src/styles.css +1 -1
  179. package/src/cli/local-bridge/frontend/src/types.ts +5 -8
  180. package/src/cli/local-bridge/job-store.ts +1 -490
  181. package/src/cli/local-bridge/server.ts +2 -515
  182. package/src/cli/local-bridge/ui-dist/app.css +1 -1
  183. package/src/cli/local-bridge/ui-dist/app.js +3703 -3757
  184. package/src/cli/mcp/auth.ts +5 -5
  185. package/src/cli/mcp/instructions.ts +3 -2
  186. package/src/cli/mcp/legacy-tool-service.ts +10 -222
  187. package/src/cli/mcp/multi-repository.ts +16 -5
  188. package/src/cli/mcp/oauth.ts +175 -26
  189. package/src/cli/mcp/post-finalize-work-attribution.ts +150 -0
  190. package/src/cli/mcp/repository-tools.ts +282 -146
  191. package/src/cli/mcp/server.ts +586 -116
  192. package/src/cli/mcp/tool-capability-cache.ts +1 -1
  193. package/src/cli/mcp/tool-contract.ts +14 -0
  194. package/src/cli/mcp/toolset-selection.ts +1 -1
  195. package/src/cli/mcp/toolset.ts +44 -7
  196. package/src/cli/mcp/transports/http.ts +124 -14
  197. package/src/cli/mcp/transports/session-registry.ts +43 -5
  198. package/src/cli/mcp/types.ts +3 -3
  199. package/src/cli/repositories/command-classifier.ts +103 -21
  200. package/src/cli/repositories/command-executor.ts +78 -526
  201. package/src/cli/repositories/command-process.ts +108 -0
  202. package/src/cli/repositories/command-scope.ts +99 -41
  203. package/src/cli/repositories/controller-home.ts +7 -8
  204. package/src/cli/repositories/git-command-executor.ts +2 -0
  205. package/src/cli/repositories/locks.ts +53 -16
  206. package/src/cli/repositories/repository-snapshot.ts +124 -0
  207. package/src/cli/repositories/selected-path-actions.ts +17 -9
  208. package/src/cli/repositories/structured-git.ts +118 -6
  209. package/src/cli/repository/inspector.ts +563 -65
  210. package/src/cli/repository/session-cache.ts +58 -17
  211. package/src/cli/v81-entry.ts +1 -4
  212. package/src/effects/fs-transaction.ts +85 -17
  213. package/src/runtime/context/codegraph-read-provider.ts +233 -2
  214. package/src/runtime/context/codegraph-sidecar.cjs +74 -40
  215. package/src/runtime/context/generic-lsp-provider.ts +355 -0
  216. package/src/runtime/context/lsp-client.ts +283 -0
  217. package/src/runtime/context/semantic-navigation-contract.ts +61 -0
  218. package/src/runtime/context/semantic-navigation.ts +223 -0
  219. package/src/runtime/context/swift-navigation.ts +565 -0
  220. package/src/runtime/context/typescript-navigation.ts +226 -0
  221. package/src/runtime/control-plane/dispatch-priority.ts +28 -0
  222. package/src/runtime/control-plane/execution/direct-edit-work-completion.ts +48 -16
  223. package/src/runtime/control-plane/execution/edit-validation-coordinator.ts +86 -24
  224. package/src/runtime/control-plane/execution/repository-work-attribution.ts +106 -0
  225. package/src/runtime/control-plane/execution/retained-work-resume.ts +203 -0
  226. package/src/runtime/control-plane/execution/session-store.ts +18 -0
  227. package/src/runtime/control-plane/execution/verification-evidence.ts +58 -3
  228. package/src/runtime/control-plane/execution/work-completion-authority.ts +58 -0
  229. package/src/runtime/control-plane/execution/work-evidence-policy.ts +200 -0
  230. package/src/runtime/control-plane/execution/work-execution-support.ts +386 -0
  231. package/src/runtime/control-plane/execution/work-finalization-service.ts +1913 -0
  232. package/src/runtime/control-plane/execution/work-handle-authority.ts +96 -0
  233. package/src/runtime/control-plane/execution/work-handle-store.ts +27 -2
  234. package/src/runtime/control-plane/execution/work-lifecycle-audit.ts +258 -0
  235. package/src/runtime/control-plane/execution/work-operation-service.ts +468 -0
  236. package/src/runtime/control-plane/execution/work-path-scope.ts +37 -0
  237. package/src/runtime/control-plane/execution/work-preparation-service.ts +479 -0
  238. package/src/runtime/control-plane/execution/work-process-evidence.ts +129 -0
  239. package/src/runtime/control-plane/execution/work-remote-delivery.ts +215 -0
  240. package/src/runtime/control-plane/execution/work-task-receipt.ts +22 -18
  241. package/src/runtime/control-plane/execution/work-terminal-cleanup.ts +156 -11
  242. package/src/runtime/control-plane/execution/work-validation-reconciler.ts +22 -14
  243. package/src/runtime/control-plane/execution/work-verification-context.ts +56 -0
  244. package/src/runtime/control-plane/execution/work-verification-service.ts +388 -0
  245. package/src/runtime/control-plane/execution/work-verification-snapshot.ts +90 -9
  246. package/src/runtime/control-plane/facade/capability-registry.ts +129 -25
  247. package/src/runtime/control-plane/facade/controller-round-relay.ts +1118 -0
  248. package/src/runtime/control-plane/facade/controller-session-store.ts +302 -12
  249. package/src/runtime/control-plane/facade/goal-workloop-access.ts +17 -1
  250. package/src/runtime/control-plane/facade/goal-workloop.ts +928 -190
  251. package/src/runtime/control-plane/facade/index.ts +3 -0
  252. package/src/runtime/control-plane/facade/plan-contract-store.ts +275 -42
  253. package/src/runtime/control-plane/facade/repository-work-admission.ts +147 -0
  254. package/src/runtime/control-plane/facade/requirement-authority.ts +83 -0
  255. package/src/runtime/control-plane/facade/semantic-admission.ts +205 -0
  256. package/src/runtime/control-plane/facade/suggested-actions.ts +5 -1
  257. package/src/runtime/control-plane/facade/types.ts +90 -10
  258. package/src/runtime/control-plane/facade/work-contract-store.ts +157 -261
  259. package/src/runtime/control-plane/facade/work-state-machine.ts +250 -0
  260. package/src/runtime/control-plane/generated-cache-retention.ts +271 -0
  261. package/src/runtime/control-plane/global-scheduler/config.ts +44 -0
  262. package/src/runtime/control-plane/global-scheduler/dispatch-capacity.ts +80 -0
  263. package/src/runtime/control-plane/global-scheduler/durable-admission.ts +46 -0
  264. package/src/runtime/control-plane/global-scheduler/maintenance.ts +152 -0
  265. package/src/runtime/control-plane/global-scheduler/projection-refresh.ts +84 -0
  266. package/src/runtime/control-plane/global-scheduler/reconciliation.ts +3 -3
  267. package/src/runtime/control-plane/global-scheduler/scheduler.ts +278 -543
  268. package/src/runtime/control-plane/global-scheduler/source-scan.ts +59 -0
  269. package/src/runtime/control-plane/global-scheduler/state.ts +88 -0
  270. package/src/runtime/control-plane/global-scheduler/worker-attachment.ts +57 -0
  271. package/src/runtime/control-plane/global-scheduler/worker-exit-decision.ts +38 -0
  272. package/src/runtime/control-plane/global-scheduler/worker-exit-reconciler.ts +175 -0
  273. package/src/runtime/control-plane/global-scheduler/worker-launch.ts +111 -0
  274. package/src/runtime/control-plane/global-scheduler/worker-lifecycle-store.ts +64 -0
  275. package/src/runtime/control-plane/global-scheduler/worker-lifecycle.ts +150 -0
  276. package/src/runtime/control-plane/global-scheduler/worker-process.ts +119 -0
  277. package/src/runtime/control-plane/global-scheduler/worker-stderr.ts +60 -0
  278. package/src/runtime/control-plane/launcher/chatgpt-work-binding-store.ts +63 -0
  279. package/src/runtime/control-plane/launcher/chatgpt-work-continuation.ts +365 -117
  280. package/src/runtime/control-plane/launcher/launch-reservation-store.ts +89 -0
  281. package/src/runtime/control-plane/launcher/thin-launcher.ts +244 -11
  282. package/src/runtime/control-plane/persistence/controller-home-migration.ts +487 -0
  283. package/src/runtime/control-plane/persistence/requirement-store.ts +0 -12
  284. package/src/runtime/control-plane/persistence/sqlite-store.ts +33 -2
  285. package/src/runtime/control-plane/release-retention.ts +62 -2
  286. package/src/runtime/control-plane/repo-actor/registry.ts +4 -2
  287. package/src/runtime/control-plane/routing/route-policy.ts +24 -21
  288. package/src/runtime/control-plane/routing/workspace-admission.ts +70 -0
  289. package/src/runtime/control-plane/runtime-status-client.ts +0 -2
  290. package/src/runtime/diagnostics/mcp-timing.ts +13 -0
  291. package/src/runtime/diagnostics/mcp-transport-benchmark.ts +129 -0
  292. package/src/runtime/diagnostics/performance.ts +24 -1
  293. package/src/runtime/evidence/event-ledger.ts +1 -1
  294. package/src/runtime/evidence/process-check-execution.ts +18 -0
  295. package/src/runtime/execution/jobs/child-reference.ts +6 -2
  296. package/src/runtime/execution/jobs/store.ts +58 -4
  297. package/src/runtime/execution/jobs/types.ts +1 -1
  298. package/src/runtime/execution/managed-workspace.ts +203 -1
  299. package/src/runtime/execution/process-runtime/check-facade.ts +51 -4
  300. package/src/runtime/execution/process-runtime/check-result.ts +88 -0
  301. package/src/runtime/execution/process-runtime/check-runner-sidecar.ts +7 -1
  302. package/src/runtime/execution/process-runtime/check-scheduling.ts +114 -0
  303. package/src/runtime/execution/process-runtime/command-facade.ts +367 -40
  304. package/src/runtime/execution/process-runtime/gc.ts +38 -6
  305. package/src/runtime/execution/process-runtime/lightweight-managed.ts +1201 -0
  306. package/src/runtime/execution/process-runtime/persisted-check.ts +51 -5
  307. package/src/runtime/execution/process-runtime/resource-claims.ts +10 -6
  308. package/src/runtime/execution/process-runtime/runtime.ts +53 -3
  309. package/src/runtime/execution/process-runtime/store.ts +1 -0
  310. package/src/runtime/execution/process-runtime/types.ts +4 -12
  311. package/src/runtime/execution/thin-harness/async-process.ts +12 -2
  312. package/src/runtime/execution/thin-harness/search-worker.ts +54 -5
  313. package/src/runtime/execution/work-activity.ts +21 -0
  314. package/src/runtime/execution/workers/executor.ts +18 -61
  315. package/src/runtime/gateway/mcp/execution-tools.ts +35 -1852
  316. package/src/runtime/gateway/mcp/legacy-ios-tool-adapter.ts +61 -0
  317. package/src/runtime/gateway/mcp/process-tools.ts +83 -37
  318. package/src/runtime/gateway/mcp/router.ts +186 -84
  319. package/src/runtime/gateway/mcp/runtime-tool-definitions.ts +565 -0
  320. package/src/runtime/gateway/mcp/runtime-tools.ts +2378 -1947
  321. package/src/runtime/plugins/app-store-connect-adapter.ts +216 -47
  322. package/src/runtime/plugins/browser-adapter.ts +2662 -829
  323. package/src/runtime/plugins/browser-automation-service.ts +10 -0
  324. package/src/runtime/plugins/browser-handoff-host.ts +2 -25
  325. package/src/runtime/plugins/browser-handoff.ts +110 -5
  326. package/src/runtime/plugins/browser-macos-bridge.ts +701 -63
  327. package/src/runtime/plugins/browser-manifest-surface.ts +603 -0
  328. package/src/runtime/plugins/browser-native-session-service.ts +222 -0
  329. package/src/runtime/plugins/browser-node-bridge.ts +6 -34
  330. package/src/runtime/plugins/browser-provider-registry.ts +109 -0
  331. package/src/runtime/plugins/browser-runtime-contract.ts +154 -0
  332. package/src/runtime/plugins/browser-runtime.ts +193 -0
  333. package/src/runtime/plugins/browser-session-authority.ts +332 -0
  334. package/src/runtime/plugins/browser-session-store.ts +121 -0
  335. package/src/runtime/plugins/browser-session-types.ts +98 -0
  336. package/src/runtime/plugins/capability-authorization-grants.ts +354 -0
  337. package/src/runtime/plugins/desktop-operator-registration.ts +10 -4
  338. package/src/runtime/plugins/external-adapter.ts +358 -3
  339. package/src/runtime/plugins/external-unix-socket.ts +7 -1
  340. package/src/runtime/plugins/first-party-registry.ts +2 -0
  341. package/src/runtime/plugins/github-adapter.ts +125 -0
  342. package/src/runtime/plugins/ios/agent-device-provider.ts +1 -1
  343. package/src/runtime/plugins/ios/agent-device-typed-provider.ts +52 -9
  344. package/src/runtime/plugins/ios/remote-xpc-hid.ts +1171 -0
  345. package/src/runtime/plugins/ios-adapter.ts +106 -16
  346. package/src/runtime/plugins/ios-agent-device.ts +234 -64
  347. package/src/runtime/plugins/ios-physical-device.ts +1143 -392
  348. package/src/runtime/plugins/lightweight-action.ts +153 -0
  349. package/src/runtime/plugins/local-system-adapter.ts +123 -6
  350. package/src/runtime/plugins/macos-capability-broker.ts +47 -9
  351. package/src/runtime/plugins/plugin-action-sidecar.ts +59 -0
  352. package/src/runtime/plugins/plugin-management-adapter.ts +49 -8
  353. package/src/runtime/plugins/resend-adapter.ts +1 -1
  354. package/src/runtime/plugins/store.ts +330 -33
  355. package/src/runtime/plugins/types.ts +38 -3
  356. package/src/runtime/plugins/xiaohongshu-publish.ts +515 -0
  357. package/src/runtime/projections/git-status-sampler.ts +16 -16
  358. package/src/runtime/projections/materialized-view.ts +28 -10
  359. package/src/runtime/recovery/maintenance-executor.ts +426 -25
  360. package/src/runtime/root/mcp-transport.ts +180 -10
  361. package/src/runtime/root/package-connector-service.ts +230 -10
  362. package/src/runtime/root/package-runtime-release.ts +143 -17
  363. package/src/runtime/root/package-runtime-service.ts +461 -22
  364. package/src/runtime/root/release-manifest.ts +144 -18
  365. package/src/runtime/root/release-materialize.ts +125 -32
  366. package/src/runtime/root/release-store.ts +48 -11
  367. package/src/runtime/root/runtime.ts +23 -5
  368. package/src/runtime/root/service.ts +100 -29
  369. package/src/runtime/root/types.ts +12 -0
  370. package/src/runtime/safe-tooling/ios-development.ts +321 -63
  371. package/src/runtime/shared/trusted-executable.ts +62 -0
  372. package/src/runtime/shared/trusted-node-executable.ts +48 -0
  373. package/src/runtime/standalone-recovery/core.ts +1079 -240
  374. package/src/runtime/standalone-recovery/entry.ts +100 -24
  375. package/src/runtime/standalone-recovery/installer.ts +20 -4
  376. package/src/runtime/standalone-recovery/service-labels.ts +2 -0
  377. package/src/runtime/standalone-recovery/watchdog-heartbeat.ts +160 -0
  378. package/src/runtime/workflow/schedules/browser-probe.ts +81 -3
  379. package/src/runtime/workflow/schedules/engine.ts +364 -202
  380. package/src/runtime/workflow/schedules/github-issue-watch.ts +158 -0
  381. package/src/runtime/workflow/schedules/settlement.ts +64 -17
  382. package/src/runtime/workflow/schedules/store.ts +209 -19
  383. package/src/runtime/workflow/schedules/types.ts +2 -4
  384. package/src/runtime/workflow/schedules/work-continuation.ts +26 -13
  385. package/src/testing/test-governance.ts +8 -40
  386. package/assets/reference-configs/heartbeat-triage.md +0 -57
  387. package/assets/templates/helpers/harness-trace-grade.sh +0 -150
  388. package/assets/templates/helpers/heartbeat-triage.sh +0 -361
  389. package/assets/templates/helpers/maintenance-triage.sh +0 -167
  390. package/docs/architecture/current/approved-target-architecture.zh-CN.md +0 -1501
  391. package/docs/architecture/current/architecture-invariants.md +0 -331
  392. package/docs/architecture/current/automation-and-schedule-engine.md +0 -459
  393. package/docs/architecture/current/codegraph-context-provider.md +0 -238
  394. package/docs/architecture/current/control-plane-authority-inventory.md +0 -94
  395. package/docs/architecture/current/controller-repository-decoupling.md +0 -148
  396. package/docs/architecture/current/dispatch-and-agent-strategy.md +0 -373
  397. package/docs/architecture/current/entity-model.md +0 -612
  398. package/docs/architecture/current/external-plugin-governance.md +0 -396
  399. package/docs/architecture/current/failure-recovery.md +0 -447
  400. package/docs/architecture/current/governance.md +0 -213
  401. package/docs/architecture/current/human-interaction-plane.md +0 -87
  402. package/docs/architecture/current/implementation-status.md +0 -128
  403. package/docs/architecture/current/job-and-run-lifecycle.md +0 -413
  404. package/docs/architecture/current/legacy-governance.md +0 -58
  405. package/docs/architecture/current/local-workspace-target-grants.md +0 -70
  406. package/docs/architecture/current/migration-roadmap.md +0 -105
  407. package/docs/architecture/current/multi-repository-execution.md +0 -371
  408. package/docs/architecture/current/operations-runbook.md +0 -45
  409. package/docs/architecture/current/peer-supercontroller-runtime.md +0 -32
  410. package/docs/architecture/current/personal-assistant-plugin-baseline.md +0 -206
  411. package/docs/architecture/current/repository-access-modes.md +0 -102
  412. package/docs/architecture/current/route-policy.md +0 -15
  413. package/docs/architecture/current/route-session-concurrency.md +0 -85
  414. package/docs/architecture/current/runtime-architecture-simplification.md +0 -214
  415. package/docs/architecture/current/runtime-directory-map.md +0 -49
  416. package/docs/architecture/current/runtime-health-and-resource-lifecycle.md +0 -85
  417. package/docs/architecture/current/scheduler-and-resource-claims.md +0 -422
  418. package/docs/architecture/current/session-aware-execution-and-authorization.md +0 -77
  419. package/docs/architecture/current/system-overview.md +0 -169
  420. package/docs/architecture/current/target-requirements-traceability.md +0 -202
  421. package/docs/architecture/current/thin-harness-governance-policy.md +0 -32
  422. package/docs/architecture/current/thin-harness-v1.md +0 -321
  423. package/docs/architecture/current/verification-and-release-gates.md +0 -391
  424. package/docs/forge-autonomous-goal-loop.md +0 -9
  425. package/docs/forge-provider-configuration.md +0 -7
  426. package/docs/operations/chatgpt-personal-assistant-runtime.md +0 -93
  427. package/docs/operations/gmail-assistant-routines.md +0 -186
  428. package/docs/operations/personal-assistant-operator-guide.md +0 -61
  429. package/docs/operations/provider-configuration.md +0 -31
  430. package/scripts/harness-trace-grade.sh +0 -150
  431. package/scripts/heartbeat-triage.sh +0 -361
  432. package/scripts/maintenance-triage.sh +0 -167
  433. package/src/cli/local-bridge/frontend/src/features/settings/SettingsView.tsx +0 -2
  434. package/src/cli/repositories/goal-registry.ts +0 -239
  435. package/src/runtime/assistant/action-proposals.ts +0 -279
  436. package/src/runtime/assistant/intent.ts +0 -395
  437. package/src/runtime/assistant/model-provider.ts +0 -460
  438. package/src/runtime/assistant/openapi.ts +0 -223
  439. package/src/runtime/assistant/policy.ts +0 -89
  440. package/src/runtime/assistant/readiness.ts +0 -258
  441. package/src/runtime/assistant/routine-runtime.ts +0 -477
  442. package/src/runtime/assistant/schedule-binding.ts +0 -171
  443. package/src/runtime/assistant/standing-grants.ts +0 -375
  444. package/src/runtime/assistant/store.ts +0 -243
  445. package/src/runtime/assistant/types.ts +0 -135
  446. package/src/runtime/control-plane/goal-loop/config-facade.ts +0 -700
  447. package/src/runtime/control-plane/goal-loop/config-store.ts +0 -570
  448. package/src/runtime/control-plane/goal-loop/config-types.ts +0 -213
  449. package/src/runtime/control-plane/goal-loop/executor-router.ts +0 -109
  450. package/src/runtime/control-plane/goal-loop/failure-taxonomy.ts +0 -149
  451. package/src/runtime/control-plane/goal-loop/goal-contract-store.ts +0 -304
  452. package/src/runtime/control-plane/goal-loop/goal-loop-engine.ts +0 -1001
  453. package/src/runtime/control-plane/goal-loop/handoff-packet.ts +0 -160
  454. package/src/runtime/control-plane/goal-loop/index.ts +0 -13
  455. package/src/runtime/control-plane/goal-loop/local-tools.ts +0 -290
  456. package/src/runtime/control-plane/goal-loop/policy-gates.ts +0 -203
  457. package/src/runtime/control-plane/goal-loop/provider-dispatch.ts +0 -93
  458. package/src/runtime/control-plane/goal-loop/provider-registry.ts +0 -545
  459. package/src/runtime/control-plane/goal-loop/types.ts +0 -378
  460. package/src/runtime/control-plane/startup-recovery.ts +0 -198
  461. package/src/runtime/gateway/mcp/resource-policy.ts +0 -186
  462. package/src/runtime/personal-assistant/gmail-triage-manager.ts +0 -231
  463. package/src/runtime/personal-assistant/reporting-runtime.ts +0 -344
  464. package/src/runtime/personal-assistant/triage-runtime.ts +0 -748
  465. package/src/runtime/workflow/findings/store.ts +0 -204
  466. package/src/runtime/workflow/findings/types.ts +0 -58
  467. package/src/runtime/workflow/portfolio/engine.ts +0 -20
  468. package/src/runtime/workflow/portfolio/store.ts +0 -185
  469. package/src/runtime/workflow/portfolio/types.ts +0 -29
@@ -1,391 +0,0 @@
1
- # Verification and Release Gates
2
-
3
- > Status: **Runtime Authority**
4
-
5
- ## 1. Objective
6
-
7
- Verification determines whether evidence satisfies a declared contract for an exact repository state. Release gating determines whether the repository is ready for an externally visible delivery action.
8
-
9
- The system distinguishes:
10
-
11
- ```text
12
- execution success
13
- integration success
14
- verification success
15
- Task acceptance
16
- Issue completion
17
- release readiness
18
- release execution
19
- ```
20
-
21
- No step implies the next without its required evidence.
22
-
23
- ## 2. Evidence Principles
24
-
25
- Evidence must be:
26
-
27
- - generated by the Controller or a trusted repository system;
28
- - bound to stable repository and checkout identity;
29
- - bound to an exact Revision or artifact hash;
30
- - addressable through a durable artifact reference;
31
- - bounded when returned to clients;
32
- - honest about failure, timeout, truncation, or missing data;
33
- - reusable only while its cache/precondition contract remains valid.
34
-
35
- Worker or Agent prose is supplementary evidence, not authoritative pass/fail proof.
36
-
37
- ## 3. Verification Record
38
-
39
- A Verification Record contains:
40
-
41
- ```text
42
- repoId
43
- checkoutId
44
- revision
45
- issueId / taskId
46
- runId / editSessionId / integrationId
47
- reviewedDiffHash
48
- checkResults
49
- commandEvidence
50
- acceptanceResults
51
- reviewer
52
- verifiedAt
53
- environmentFingerprint
54
- artifact references
55
- staleAt / staleReason when invalidated
56
- ```
57
-
58
- A caller cannot satisfy required named checks by reporting `ok: true`. The Controller executes the check or verifies a trusted external artifact.
59
-
60
- ## 4. Exact Revision
61
-
62
- Verification applies to one Revision definition, normally derived from:
63
-
64
- ```text
65
- HEAD
66
- tracked working-tree diff
67
- relevant untracked files
68
- check configuration
69
- environment fingerprint
70
- ```
71
-
72
- The Revision contract excludes known runtime-only evidence directories.
73
-
74
- If relevant files change after verification:
75
-
76
- - the previous record remains historical;
77
- - completion logic treats it as stale;
78
- - required verification runs again for the new Revision.
79
-
80
- ## 5. Verification Layers
81
-
82
- ### Layer 1 — Patch Integrity
83
-
84
- For Direct Edit or integration:
85
-
86
- - allowed paths respected;
87
- - before/after hashes recorded;
88
- - diff is available;
89
- - change budget respected;
90
- - no unsupported binary/rename behavior hidden;
91
- - user changes outside scope preserved.
92
-
93
- ### Layer 2 — Focused Checks
94
-
95
- Run the smallest deterministic checks that directly cover the change.
96
-
97
- Examples:
98
-
99
- - one test file;
100
- - one package type check;
101
- - one domain test suite;
102
- - one architecture or documentation gate.
103
-
104
- ### Layer 3 — Task Contract
105
-
106
- Evaluate all Task-declared checks and acceptance criteria.
107
-
108
- Acceptance criteria must be observable and must not merely repeat “implementation complete.”
109
-
110
- ### Layer 4 — Integration Verification
111
-
112
- After an isolated Run is integrated:
113
-
114
- - verify target Revision, not only Worktree Revision;
115
- - verify integration record and reviewed diff hash;
116
- - rerun affected checks when target state changed;
117
- - retain Worktree until durable integration outcome exists.
118
-
119
- ### Layer 5 — Issue or System Integration
120
-
121
- Run broader checks required by the Issue, architecture boundary, or affected runtime subsystem.
122
-
123
- ### Layer 6 — Release Gate
124
-
125
- Run release-specific checks against a frozen candidate Revision.
126
-
127
- ## 6. Risk-Adaptive Verification
128
-
129
- ### Read-only
130
-
131
- Requires evidence of the requested observation. No diff gate.
132
-
133
- ### Low-risk change
134
-
135
- Focused checks when declared; may auto-complete after successful applicable evidence.
136
-
137
- ### Medium-risk change
138
-
139
- Declared checks and acceptance evidence apply. Auto-completion is allowed only when policy says no human decision is required.
140
-
141
- ### High-risk change
142
-
143
- Requires:
144
-
145
- - reviewed diff or integrated Revision;
146
- - required verification evidence;
147
- - acceptance criteria results;
148
- - explicit human acceptance.
149
-
150
- ### Destructive change
151
-
152
- Requires all high-risk evidence plus explicit same-request destructive authorization and operation-specific safety/rollback plan.
153
-
154
- ## 7. Task Acceptance
155
-
156
- Task acceptance occurs after verification policy passes.
157
-
158
- Acceptance action records:
159
-
160
- ```text
161
- acceptedBy
162
- acceptedAt
163
- verificationId
164
- revision
165
- note
166
- ```
167
-
168
- Dependent Tasks unlock only from accepted terminal semantics, not from a successful Run alone.
169
-
170
- For eligible low/medium-risk work, Controller policy may auto-accept and records that automation explicitly.
171
-
172
- ## 8. Failed Verification
173
-
174
- A real failed check or acceptance criterion moves work to `changes_requested` or a similarly explicit corrective state.
175
-
176
- Failure handling:
177
-
178
- 1. preserve check output and artifact;
179
- 2. classify failure as introduced, pre-existing, environmental, flaky, stale, or contract-related;
180
- 3. avoid claiming unrelated pre-existing failure was caused or fixed;
181
- 4. create a focused correction or blocker;
182
- 5. rerun only the necessary evidence after the Revision changes.
183
-
184
- A flaky check requires explicit flake evidence and retry policy. Repeating until green without recording attempts is forbidden.
185
-
186
- ## 9. Shared Check Evidence
187
-
188
- Identical check requests may share one execution when these match:
189
-
190
- ```text
191
- repoId
192
- checkoutId
193
- checkId
194
- revision
195
- timeout contract
196
- environment fingerprint
197
- ```
198
-
199
- Every subscriber links to the same immutable evidence. One subscriber cancellation must not terminate execution required by others.
200
-
201
- ## 10. Release Readiness
202
-
203
- A repository is `release_ready` only when all required conditions are true for the candidate Revision.
204
-
205
- Baseline gate:
206
-
207
- ```text
208
- repository identity valid
209
- remote/GitHub mapping diagnosed
210
- candidate Revision fixed
211
- Workspace ownership known
212
- no active write Job
213
- no active Agent Run
214
- no pending integration
215
- no unresolved integration conflict
216
- no dirty Edit Session
217
- no orphan/unknown execution affecting candidate
218
- required Tasks accepted
219
- required checks pass for candidate Revision
220
- architecture/document gates pass
221
- package/public metadata valid
222
- release manifest generated
223
- rollback or recovery plan recorded when required
224
- human authorization boundary identified
225
- ```
226
-
227
- A project may add stricter repository-specific gates.
228
-
229
- ## 11. Release Freeze
230
-
231
- Before final release verification, the Repo Actor acquires an exclusive release Claim and enters Release Freeze.
232
-
233
- During freeze:
234
-
235
- - new mutation Jobs wait;
236
- - active writers finish or are explicitly resolved;
237
- - Integration Queue drains;
238
- - read-only inspection continues;
239
- - release checks run against the fixed candidate;
240
- - Schedule mutation work pauses;
241
- - any relevant file change invalidates the candidate and requires a new gate.
242
-
243
- Release Freeze is released after:
244
-
245
- - release execution completes;
246
- - release is cancelled;
247
- - verification fails and the candidate returns to development;
248
- - Lease expires and recovery reconciles state.
249
-
250
- ## 12. Release Manifest
251
-
252
- The release gate produces a durable manifest:
253
-
254
- ```text
255
- repoId
256
- checkoutId
257
- candidateRevision
258
- branch
259
- target version or release identifier
260
- included Issues and Tasks
261
- verification records
262
- check artifact hashes
263
- known warnings
264
- known non-blocking pre-existing failures
265
- remote target
266
- release actions requiring authorization
267
- rollback/recovery instructions
268
- createdAt
269
- approvedBy / approvedAt when applicable
270
- ```
271
-
272
- The manifest is an execution input and audit record. It does not execute release actions by itself.
273
-
274
- ## 13. External Actions
275
-
276
- The following remain explicit external boundaries:
277
-
278
- - commit when user policy requires review;
279
- - push;
280
- - create/update remote PR when not already authorized by the Task;
281
- - merge;
282
- - tag;
283
- - package publication;
284
- - production deployment;
285
- - remote Issue closure;
286
- - destructive migration or data mutation.
287
-
288
- The Controller may prepare exact commands and evidence. It may execute only with explicit authorization appropriate to the operation.
289
-
290
- ## 14. Release Job
291
-
292
- Release execution, when authorized, is a durable Job.
293
-
294
- It records:
295
-
296
- ```text
297
- releaseManifestId
298
- requestId
299
- remote target
300
- operation sequence
301
- current step
302
- external identifiers
303
- stdout/stderr/artifacts
304
- partial outcome
305
- compensation or resume instructions
306
- ```
307
-
308
- A disconnected client does not make external outcome unknown if provider or command evidence can prove it. Otherwise the Release Job becomes orphaned/unknown and requires reconciliation before retry.
309
-
310
- ## 15. Partial Release
311
-
312
- Multi-step or multi-repository release may end partially complete.
313
-
314
- Partial outcome records:
315
-
316
- - completed external actions;
317
- - failed or unstarted actions;
318
- - current deployed/published versions;
319
- - safe compensation options;
320
- - actions that require human decision.
321
-
322
- The system must not collapse partial release into success or rerun all actions blindly.
323
-
324
- ## 16. Rollback and Recovery
325
-
326
- Rollback is not assumed universally safe.
327
-
328
- A release plan declares one of:
329
-
330
- ```text
331
- reversible with deterministic rollback
332
- forward-fix preferred
333
- feature-flag disable
334
- provider-native rollback
335
- manual recovery only
336
- ```
337
-
338
- Rollback itself is externally visible/destructive work and requires appropriate authorization and evidence.
339
-
340
- ## 17. Architecture Gate
341
-
342
- Architecture-sensitive releases must pass:
343
-
344
- - current architecture document presence;
345
- - Runtime Authority marker;
346
- - historical document marker policy;
347
- - architecture drift check;
348
- - relevant ADR linkage;
349
- - migration roadmap update when target gaps change.
350
-
351
- Architecture documentation is part of the release contract, not an optional afterthought.
352
-
353
- ## 18. Verification Performance
354
-
355
- Verification must remain proportional:
356
-
357
- - focused checks during iteration;
358
- - Task checks before acceptance;
359
- - broader Issue/system checks at integration boundaries;
360
- - full release gate once the candidate is frozen.
361
-
362
- Running the full release suite after every small patch wastes resources and increases queue contention. Running only focused checks before release is insufficient.
363
-
364
- Check results and revision-aware caches prevent unnecessary duplication without hiding stale evidence.
365
-
366
- ## 19. Current Implementation
367
-
368
- Verification evidence is bound to Job, repository and exact Git revision with an environment fingerprint. Revision changes invalidate reusable evidence. Oversized result bodies are stored as Artifacts and only bounded previews are returned through Job status.
369
-
370
- Release readiness is implemented as a durable `release-gate` Job holding an exclusive `release:<repoId>` Lease. The Gate checks Workspace cleanliness, active Execution Jobs, Agent Runs, Local compatibility Jobs, pending Worktree integration, unfinished Edit Sessions, other Leases, active-Issue Tasks, exact-revision verification, repository remote identity, GitHub mapping, Canonical Forge Runtime readiness and package metadata.
371
-
372
- A successful Gate returns a release manifest for the exact current revision. Push, merge, publish, deploy and destructive external operations still require a separate explicit user authorization.
373
-
374
- ## 20. Required Release Tests
375
-
376
- Runtime and release checks cover:
377
-
378
- - candidate revision changes invalidate evidence;
379
- - active writers block release;
380
- - pending Worktree integration blocks release;
381
- - dirty Edit Sessions block release;
382
- - remote and GitHub mapping drift block release;
383
- - release Lease blocks new writes;
384
- - a successful Gate does not execute an external side effect;
385
- - partial external outcomes never become global success.
386
-
387
- ## 21. Immutable Check Definition Snapshot
388
-
389
- A scheduled check stores the normalized command, cwd, timeout, source, registry revision, and definition digest at admission time. Execution validates the digest and repository-relative cwd, then uses that snapshot even if another checkout or a later commit changes the check registry.
390
-
391
- The snapshot stabilizes check identity; the produced evidence is still bound to the revision observed when execution starts and becomes stale if repository content changes while the command runs. This prevents both `check not found` after checkout switching and accidental reuse of evidence from a different repository revision.
@@ -1,9 +0,0 @@
1
- # Forge Goal Loop
2
-
3
- Forge supports bounded goal progression through durable Goal, Work, Process, evidence, policy, and handoff records. The kernel does not recursively invent unlimited work, select arbitrary models, or bypass authorization. Semantic planning and provider selection belong to the external controller; deterministic repository and provider operations remain Forge-owned.
4
-
5
- Every continuation must have a finite objective, resource scope, budget, stop condition, and reviewable evidence. Remote or destructive effects stay separately authorized. A Schedule can wake an external Controller for an existing bounded Work; ChatGPT wakeups reuse a saved Forge browser session or explicit conversation URL when available, so conversation continuity is a transport concern rather than Kernel reasoning.
6
- The stable configuration path is `rh_work.schedule_*`: create one continuation policy for an already accepted Work, inspect it, pause/resume it, or trigger one bounded Occurrence. The engine re-checks Work terminality before launch and automatically disables the Schedule when the Work is complete, so users do not need to keep sending “continue” and Forge does not keep waking a model after acceptance is satisfied.
7
- A scheduled wake uses a short launch reservation rather than a fake Controller lease. The external model becomes owner only after its own authenticated MCP session calls `rh_work continue`; this is the identity handoff boundary between deterministic scheduling and semantic control.
8
-
9
- See [Dispatch and Agent Strategy](architecture/current/dispatch-and-agent-strategy.md), [Schedule Engine](architecture/current/automation-and-schedule-engine.md), and [Governance](architecture/current/governance.md).
@@ -1,7 +0,0 @@
1
- # Forge Provider Configuration
2
-
3
- Forge keeps provider selection separate from Runtime ownership. Codex, Claude, GitHub, browser, Google Workspace, Apple, iOS, Desktop, and other adapters execute bounded contracts through stable Forge policy, Process, receipt, and audit layers.
4
-
5
- Provider credentials are supplied through supported environment or OS credential mechanisms and are never copied into repository state or chat output. Provider availability does not change the one-Runtime topology.
6
-
7
- See [Provider configuration](operations/provider-configuration.md), [Plugin baseline](architecture/current/personal-assistant-plugin-baseline.md), and [Security Model](wiki/Security-Model.md).
@@ -1,93 +0,0 @@
1
- # ChatGPT-first Personal Assistant Runtime
2
-
3
- This runtime is designed for a local-first personal assistant where ChatGPT is the primary natural-language controller and Forge is the guarded local execution layer.
4
-
5
- ## Product boundary
6
-
7
- The Local Controller should not be the main task input surface. It stores routines, inbox items, memory, approvals, audit events, device tokens, and plugin state. ChatGPT, MCP, or a GPT Action should translate natural language into one of the high-level assistant APIs.
8
-
9
- ## High-level API surface
10
-
11
- Expose these endpoints to ChatGPT Actions instead of exposing every low-level plugin action:
12
-
13
- - `POST /api/assistant/intent` — submit a natural-language utterance or a ChatGPT-planned action list.
14
- - `GET /api/assistant/inbox` — read assistant outputs, routine results, and approval notes.
15
- - `GET /api/assistant/routines` — list saved routines.
16
- - `POST /api/assistant/routines` — create a routine from a natural-language goal.
17
- - `POST /api/assistant/routines/:routineId/run` — run one routine immediately.
18
- - `POST /api/assistant/routines/:routineId/pause` — pause a routine.
19
- - `POST /api/assistant/routines/:routineId/resume` — resume a routine.
20
- - `POST /api/assistant/routines/:routineId/delete` — soft-delete a routine.
21
- - `GET /api/assistant/memory` and `POST /api/assistant/memory` — read/write local preference memory.
22
- - `GET /api/assistant/openapi.json` — minimal OpenAPI schema for a Custom GPT Action.
23
-
24
- All `/api/*` routes still require the local controller token.
25
-
26
- ## Intent modes
27
-
28
- `/api/assistant/intent` supports three modes:
29
-
30
- - `plan_only`: return the interpreted plan without submitting execution jobs.
31
- - `plan_then_execute`: plan and submit safe steps; block high-risk steps.
32
- - `execute`: submit the supplied plan directly through the same policy gate.
33
-
34
- The preferred ChatGPT flow is:
35
-
36
- 1. ChatGPT understands the user request.
37
- 2. ChatGPT asks for missing information or confirmation when needed.
38
- 3. ChatGPT calls `/api/assistant/intent` with either the natural-language utterance or an explicit `plan`.
39
- 4. Forge validates policy, creates durable Execution Jobs, stores an Assistant Inbox item, and returns display text.
40
-
41
- ## Routine model
42
-
43
- A routine stores the user's natural-language goal rather than a traditional GUI rule form:
44
-
45
- ```json
46
- {
47
- "name": "每日邮件整理",
48
- "naturalLanguageGoal": "每天早上 9 点整理过去 24 小时重要邮件,重点关注工作、API、BA、Jira、PR,用中文输出摘要。",
49
- "scheduleText": "每天 09:00",
50
- "dataSources": ["gmail", "calendar", "tasks"],
51
- "output": "assistant_inbox",
52
- "allowedActions": ["gmail.list_messages", "gmail.get_message"],
53
- "forbiddenActions": ["gmail.send_message", "gmail.trash_message"]
54
- }
55
- ```
56
-
57
- Routine execution and long-lived goal continuation use the existing Schedule Engine rather than a second assistant daemon. Semantic/model-backed routine logic remains external-controller-owned; the Kernel does not execute an unbounded model loop on a timer.
58
-
59
- For an accepted non-terminal Work, ChatGPT can create a bounded `rh_work.schedule_create` policy in one of three modes:
60
-
61
- - `continuation` — wake the bound ChatGPT/Codex/Claude/Grok Controller at the configured trigger;
62
- - `browser_watch` — silently refresh/read an allowed browser target, fingerprint a deterministic text projection, and wake the bound Controller only when the observation changes;
63
- - `browser_keepalive` — silently refresh an authenticated browser target and wake only when configured login markers indicate that user authentication is required.
64
-
65
- The first `browser_watch` observation is a silent baseline by default. Unchanged observations do not create a ChatGPT conversation turn. When the bound Work becomes terminal, Forge disables the Schedule before performing another external probe, so temporary watchers naturally disappear with the Goal they serve.
66
-
67
- ## Policy defaults
68
-
69
- Allowed without extra approval:
70
-
71
- - Read Gmail, Calendar, and Tasks.
72
- - Create a Google Task / reminder.
73
- - Create a Gmail draft.
74
- - Create a personal calendar event without attendees.
75
-
76
- Requires human approval:
77
-
78
- - Send email.
79
- - Trash email.
80
- - Cancel calendar event.
81
- - Reschedule calendar event.
82
- - Delete task.
83
- - Scheduled routine writes beyond explicitly allowed draft/reminder behavior.
84
-
85
- ## Assistant Inbox
86
-
87
- Assistant Inbox is the user-facing result surface for meaningful routine outputs, approval/authentication needs, and intent execution records. A successful scheduled probe with no external change should remain silent rather than generating a daily "completed" notification. ChatGPT can read meaningful items and then present the result conversationally, for example: "今天助理整理了什么?"
88
-
89
- ## Current limitation
90
-
91
- The runtime does not embed a full NLP model. ChatGPT Actions should provide structure when precision matters. The local runtime includes conservative intent inference only for routine creation, reminders, and immediate mail-summary collection.
92
-
93
- `browser_watch` is a fallback observation source for services without a usable API or webhook; it depends on a live authenticated browser session and caller-supplied selectors/terms when the page contains unrelated or volatile content. Browser refresh can reduce inactivity-related logout but cannot override a provider's absolute session lifetime, security checks, or MFA policy. Provider-native APIs/events should replace browser probes when they are available and more reliable.
@@ -1,186 +0,0 @@
1
- # Durable Gmail Assistant Routines
2
-
3
- Gmail Assistant Routines use the existing Repository Schedule Engine and durable Execution Jobs. They do not introduce a second cron service.
4
-
5
- ## Execution flow
6
-
7
- 1. Creating a confirmed Assistant Routine persists the Routine and creates one Repository Schedule.
8
- 2. The Schedule stores an IANA timezone, a five-field local cron expression, and a bounded catch-up window.
9
- 3. A due occurrence creates one `assistant_routine_execute` Runtime Job with an exclusive Routine resource claim.
10
- 4. The Runtime Job reads Gmail incrementally, hydrates bounded message bodies, advances the per-Routine cursor, analyzes the bounded message set, creates structured action proposals, and writes a final Assistant Inbox report.
11
- 5. Proposals either remain pending for explicit approval or match a previously authorized Standing Grant.
12
- 6. Every approved or Standing-Grant action runs as a separate durable plugin Job. Schedule execution never becomes remote-write authorization.
13
- 7. Sending mail and moving mail to Trash retain their existing strong-confirmation requirements and are never Standing-Grant eligible.
14
-
15
- ## Google OAuth setup
16
-
17
- Create a Google OAuth client with this loopback redirect URI:
18
-
19
- ```text
20
- http://127.0.0.1:8766/oauth/google/callback
21
- ```
22
-
23
- Expose the client configuration only through the managed secret environment:
24
-
25
- - `FORGE_GOOGLE_CLIENT_ID`
26
- - `FORGE_GOOGLE_CLIENT_SECRET`
27
-
28
- The `FORGE_GOOGLE_WORKSPACE_CLIENT_ID` and `FORGE_GOOGLE_WORKSPACE_CLIENT_SECRET` aliases are also supported.
29
-
30
- Call `workspace_auth_login_prepare` for `gmail` or `google-workspace`, then open the returned authorization URL. The request uses OAuth Authorization Code flow with PKCE, a random one-time state, a ten-minute expiry, and a loopback-only callback. Redirect URIs outside `127.0.0.1` or `localhost`, unexpected callback paths, and scopes outside the Gmail/Calendar/Tasks allowlist are rejected.
31
-
32
- The callback exchanges the authorization code and stores only the refresh token in macOS Keychain. Access and refresh tokens are never returned through MCP, written to repository files, or written to normal Controller runtime state. The transient PKCE verifier is stored under Controller Home with restrictive permissions and is redacted after the callback is consumed.
33
-
34
- The current secure persistence backend is macOS Keychain. Non-macOS hosts must provide a supported credential-store adapter or use managed environment credentials.
35
-
36
- ## Credential refresh and readiness
37
-
38
- A configured access token is not considered provider-verified until a real Google API request succeeds. Before that first successful probe, health reports `live_token_unverified`.
39
-
40
- After OAuth setup, Controller restarts can reload the refresh token from Keychain. When no valid cached access token exists, or Gmail returns HTTP 401/403, the provider performs one refresh-token exchange and at most one request retry. A failed refresh is classified as `PLUGIN_AUTH_FAILED`; the Routine Run becomes `auth_required` and Assistant Inbox requests reauthorization.
41
-
42
- Managed environment credentials remain compatible:
43
-
44
- - `FORGE_GMAIL_ACCESS_TOKEN`
45
- - `FORGE_GMAIL_REFRESH_TOKEN`
46
- - `FORGE_GMAIL_CLIENT_ID`
47
- - `FORGE_GMAIL_CLIENT_SECRET`
48
- - `FORGE_GOOGLE_WORKSPACE_ACCESS_TOKEN`
49
- - `FORGE_GOOGLE_WORKSPACE_REFRESH_TOKEN`
50
- - `FORGE_GOOGLE_WORKSPACE_CLIENT_ID`
51
- - `FORGE_GOOGLE_WORKSPACE_CLIENT_SECRET`
52
-
53
- ## Scheduling semantics
54
-
55
- Routine schedule text is normalized when the Routine is created. The first implementation recognizes daily and weekday expressions with an optional `HH:mm` or Chinese `点/时` form. Examples:
56
-
57
- - `每天 09:00`
58
- - `每周一 08:30`
59
- - `Monday 07:00`
60
-
61
- The normalized Schedule preserves the IANA timezone, so daylight-saving transitions remain aligned to local wall-clock time. Missed runs catch up at most once inside the configured window because the occurrence key is derived from the local scheduled minute rather than the actual wake-up minute.
62
-
63
- ## Gmail History cursor
64
-
65
- Each Routine stores an independent cursor under `.forge/assistant/gmail-cursors.json`:
66
-
67
- - last successful collection time
68
- - bounded processed-message ID set
69
- - Gmail `historyId`
70
- - a bounded History or query continuation token while a backlog is still being drained
71
-
72
- After the initial query, Gmail History is the primary incremental source. An expired History ID falls back to a five-minute-overlap Gmail query. Collection reads at most five pages, 100 IDs, and 50 full messages per run. If the page or hydration limit is reached, the history cursor does not advance; a continuation token or the original window is retained so the next run drains the remaining messages without loss.
73
-
74
- ## Optional model analysis
75
-
76
- The model layer is optional. When it is disabled, unavailable, times out, or returns malformed output, the Routine completes with the deterministic rules engine rather than failing.
77
-
78
- Configure an OpenAI-compatible endpoint with:
79
-
80
- - `FORGE_ASSISTANT_MODEL_PROVIDER=openai-compatible`
81
- - `FORGE_ASSISTANT_MODEL_ENDPOINT`
82
- - `FORGE_ASSISTANT_MODEL`
83
- - `FORGE_ASSISTANT_MODEL_API_KEY`
84
-
85
- For the exact official hosts, provider-specific keys are also supported:
86
-
87
- - `api.openai.com` may use `OPENAI_API_KEY`
88
- - `api.deepseek.com` may use `FORGE_DEEPSEEK_API_KEY` or `DEEPSEEK_API_KEY`
89
-
90
- A custom endpoint never receives `OPENAI_API_KEY` or a DeepSeek key. It must use the dedicated `FORGE_ASSISTANT_MODEL_API_KEY`. Endpoints must use HTTPS, except loopback HTTP used for a local model.
91
-
92
- Optional budgets:
93
-
94
- - `FORGE_ASSISTANT_MODEL_TIMEOUT_MS`
95
- - `FORGE_ASSISTANT_MODEL_MAX_MESSAGES`
96
- - `FORGE_ASSISTANT_MODEL_MAX_INPUT_CHARS`
97
- - `FORGE_ASSISTANT_MODEL_MAX_OUTPUT_TOKENS`
98
-
99
- The provider requests strict structured JSON, validates the result locally, and maps only these proposal types:
100
-
101
- - Gmail draft creation
102
- - Google Task creation
103
- - Gmail archive
104
- - Gmail mark read or unread
105
-
106
- Email contents are untrusted input. Instructions in an email, quoted thread, signature, link, or attachment description cannot expand the action allowlist or request tools, credentials, files, commands, or additional permissions. Security, authentication, billing, incident, production, quota, and repository-permission messages are protected from model-generated archive actions.
107
-
108
- The deterministic fallback also uses Gmail's `CATEGORY_PROMOTIONS` label as a high-confidence archive signal (`0.98`) for non-protected messages. Marketing/newsletter keyword matches remain a lower-confidence fallback (`0.7`). The protected-message veto wins over both signals, so a security, authentication, billing, production, incident, quota, or permission-related message is never proposed for automatic archive merely because Gmail classified it as Promotions.
109
-
110
- Use `assistant_model_readiness` or `GET /api/assistant/model` to inspect the redacted configuration and budgets. Model credentials and raw secrets are never returned.
111
-
112
- ## Action proposals and approval
113
-
114
- Routine analysis persists structured proposals under `.forge/assistant/action-proposals.json`. Each proposal records:
115
-
116
- - Routine and Run identity
117
- - target plugin/action and bounded arguments
118
- - supporting Gmail message IDs
119
- - sender/subject context and protected-message status
120
- - reason, confidence, risk, expiry, and execution status
121
- - the separate Execution Job created after approval
122
-
123
- Use `assistant_action_proposals` to list or inspect proposals. Use `assistant_action_proposal_resolve` with `decision=approve` or `decision=reject`. MCP approval requires `confirm_authorization=true`; strong-confirmation actions also require the action's exact confirmation text. Local Controller exposes equivalent authenticated proposal endpoints.
124
-
125
- Approval is idempotent. Repeating approval returns the same Execution Job rather than creating another remote write. Proposal audit records preserve whether approval came from MCP, Local UI, or a Standing Grant.
126
-
127
- ## Standing Grants
128
-
129
- A Standing Grant is an explicit, expiring pre-authorization for one hardcoded low-risk action. It is not a general plugin permission.
130
-
131
- Eligible actions are limited to:
132
-
133
- - `gmail.create_draft`
134
- - `gmail.archive_message`
135
- - `gmail.mark_message_read`
136
- - `gmail.mark_message_unread`
137
- - `google_tasks.create_task`
138
-
139
- A grant must include at least one constraint:
140
-
141
- - Routine ID allowlist
142
- - sender/domain allowlist
143
- - required subject fragment
144
-
145
- It also declares minimum proposal confidence, maximum executions per Routine Run, and expiry. Automatic draft grants additionally require a sender allowlist. Security-protected messages cannot be auto-archived.
146
-
147
- Create a grant through `assistant_standing_grant_create` or `POST /api/assistant/standing-grants` with explicit authorization. List it through `assistant_standing_grants`; revoke it through `assistant_standing_grant_revoke` or the Local Controller revoke endpoint.
148
-
149
- Example: automatically archive at most one high-confidence newsletter from a trusted sender per run:
150
-
151
- ```json
152
- {
153
- "plugin_id": "gmail",
154
- "action_id": "archive_message",
155
- "sender_allowlist": ["news@example.com"],
156
- "subject_contains": ["newsletter"],
157
- "min_confidence": 0.9,
158
- "max_per_run": 1,
159
- "expires_in_days": 30,
160
- "confirm_authorization": true
161
- }
162
- ```
163
-
164
- Standing-Grant executions use a dedicated `standing-grant` origin and a defense-in-depth plugin allowlist. Modifying the stored grant cannot enable send, Trash, permanent deletion, calendar cancellation/rescheduling, or task deletion. Multiple matching grants cannot submit the same proposal twice, and retries preserve each grant's per-run budget.
165
-
166
- ## Safety boundary
167
-
168
- Scheduled Routines may:
169
-
170
- - list and read Gmail messages
171
- - classify and summarize collected mail
172
- - create bounded draft, task, archive, and read/unread proposals
173
- - execute an eligible proposal only when a matching active Standing Grant already exists
174
- - write Assistant Inbox reports
175
-
176
- Scheduled Routines may not:
177
-
178
- - send mail
179
- - move mail to Trash
180
- - permanently delete mail
181
- - cancel or reschedule meetings
182
- - delete tasks
183
- - execute instructions embedded in mail
184
- - open arbitrary attachments or links
185
-
186
- A proposal is evidence for a later authorized action, not implicit authorization. A Standing Grant authorizes only its exact action and constraints. The Schedule origin never becomes authorization for a remote write.