@moretea-labs/forge 1.7.1 → 1.8.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 (685) hide show
  1. package/AGENTS.md +58 -62
  2. package/CHANGELOG.md +39 -0
  3. package/CLAUDE.md +42 -62
  4. package/README.md +2 -2
  5. package/SKILL.md +0 -1
  6. package/THIRD_PARTY_NOTICES.md +5 -2
  7. package/adapters/browser/index.ts +2 -0
  8. package/adapters/chatgpt/browser-delivery-host.ts +71 -0
  9. package/adapters/chatgpt/browser-delivery-runtime.ts +783 -0
  10. package/adapters/chatgpt/controller-binding-store.ts +55 -0
  11. package/adapters/chatgpt/controller-host.ts +119 -0
  12. package/adapters/chatgpt/controller-round-host.ts +78 -0
  13. package/adapters/chatgpt/controller-round-settlement-store.ts +45 -0
  14. package/adapters/chatgpt/provider-delivery.ts +113 -0
  15. package/adapters/chatgpt/work-conversation-binding-store.ts +192 -0
  16. package/adapters/chatgpt/wsl-bridge-delivery-host.ts +63 -0
  17. package/adapters/computer/desktop-operator-contract.ts +7 -0
  18. package/adapters/computer/desktop-operator-discovery.ts +201 -0
  19. package/adapters/computer/desktop-operator-negotiation.ts +174 -0
  20. package/adapters/computer/desktop-operator-provider.ts +312 -0
  21. package/adapters/computer/index.ts +1 -0
  22. package/adapters/computer/interaction-target-authority.ts +944 -0
  23. package/adapters/controller-process/binding-store.ts +34 -0
  24. package/adapters/controller-process/controller-host.ts +26 -0
  25. package/adapters/mcp/access-mode.ts +132 -0
  26. package/adapters/mcp/audit.ts +32 -0
  27. package/adapters/mcp/auth.ts +407 -0
  28. package/adapters/mcp/controller-round-compatibility.ts +184 -0
  29. package/adapters/mcp/frozen-client-semantic-compatibility.ts +292 -0
  30. package/adapters/mcp/instructions.ts +36 -0
  31. package/adapters/mcp/legacy-context.ts +18 -0
  32. package/adapters/mcp/multi-repository.ts +437 -0
  33. package/adapters/mcp/oauth.ts +391 -0
  34. package/adapters/mcp/paths.ts +140 -0
  35. package/adapters/mcp/policy.ts +232 -0
  36. package/adapters/mcp/proxy-env.ts +62 -0
  37. package/adapters/mcp/readiness-projection.ts +24 -0
  38. package/adapters/mcp/redaction.ts +21 -0
  39. package/adapters/mcp/repo.ts +24 -0
  40. package/adapters/mcp/runtime-gateway/artifact-adapter.ts +52 -0
  41. package/adapters/mcp/runtime-gateway/context-adapter.ts +829 -0
  42. package/adapters/mcp/runtime-gateway/controller-authority-adapter.ts +191 -0
  43. package/adapters/mcp/runtime-gateway/engineering-preconditions.ts +147 -0
  44. package/adapters/mcp/runtime-gateway/execution-control-adapter.ts +28 -0
  45. package/adapters/mcp/runtime-gateway/execution-tools.ts +207 -0
  46. package/adapters/mcp/runtime-gateway/filesystem-adapter.ts +38 -0
  47. package/adapters/mcp/runtime-gateway/gateway-execution-adapter.ts +411 -0
  48. package/adapters/mcp/runtime-gateway/legacy-ios-tool-adapter.ts +105 -0
  49. package/adapters/mcp/runtime-gateway/maintenance-adapter.ts +44 -0
  50. package/adapters/mcp/runtime-gateway/model-adapter.ts +63 -0
  51. package/adapters/mcp/runtime-gateway/persisted-check-process.ts +3 -0
  52. package/adapters/mcp/runtime-gateway/plugin-adapter.ts +308 -0
  53. package/adapters/mcp/runtime-gateway/process-tools.ts +289 -0
  54. package/adapters/mcp/runtime-gateway/protected-computer-adapter.ts +76 -0
  55. package/adapters/mcp/runtime-gateway/recovery-adapter.ts +268 -0
  56. package/adapters/mcp/runtime-gateway/recovery-client-adapter.ts +70 -0
  57. package/adapters/mcp/runtime-gateway/recovery-tool-contract.ts +99 -0
  58. package/adapters/mcp/runtime-gateway/repository-compat-adapter.ts +110 -0
  59. package/adapters/mcp/runtime-gateway/result-adapter.ts +108 -0
  60. package/adapters/mcp/runtime-gateway/router.ts +728 -0
  61. package/adapters/mcp/runtime-gateway/runtime-observation-adapter.ts +1251 -0
  62. package/adapters/mcp/runtime-gateway/runtime-tool-definitions.ts +634 -0
  63. package/adapters/mcp/runtime-gateway/runtime-tool-shared.ts +27 -0
  64. package/adapters/mcp/runtime-gateway/runtime-tools.ts +68 -0
  65. package/adapters/mcp/runtime-gateway/scheduler-adapter.ts +186 -0
  66. package/adapters/mcp/runtime-gateway/shared-adapter.ts +25 -0
  67. package/adapters/mcp/runtime-gateway/status-inbox-adapter.ts +870 -0
  68. package/adapters/mcp/runtime-gateway/work-adapter.ts +3186 -0
  69. package/adapters/mcp/runtime-gateway/work-compat-adapter.ts +502 -0
  70. package/adapters/mcp/runtime-gateway/work-validation-reconciler.ts +1 -0
  71. package/adapters/mcp/server.ts +1048 -0
  72. package/adapters/mcp/setup.ts +791 -0
  73. package/adapters/mcp/tool-capability-cache.ts +87 -0
  74. package/adapters/mcp/tool-mapping/access-tools.ts +387 -0
  75. package/adapters/mcp/tool-mapping/legacy-tool-service.ts +5265 -0
  76. package/adapters/mcp/tool-mapping/post-finalize-work-attribution.ts +150 -0
  77. package/adapters/mcp/tool-mapping/repository-tools.ts +1691 -0
  78. package/adapters/mcp/tool-mapping/tools.ts +9 -0
  79. package/adapters/mcp/tool-mapping/umbrella-tools.ts +117 -0
  80. package/adapters/mcp/toolset-names.ts +74 -0
  81. package/adapters/mcp/toolset-selection.ts +41 -0
  82. package/adapters/mcp/toolset.ts +336 -0
  83. package/adapters/mcp/transports/http.ts +1456 -0
  84. package/adapters/mcp/transports/session-registry.ts +513 -0
  85. package/adapters/mcp/transports/stdio.ts +8 -0
  86. package/adapters/mcp/tunnels/openai-secure-tunnel.ts +139 -0
  87. package/adapters/mcp/types.ts +41 -0
  88. package/assets/AGENTS.md +2 -16
  89. package/assets/CLAUDE.md +2 -16
  90. package/assets/hooks/AGENTS.md +3 -14
  91. package/assets/hooks/CLAUDE.md +3 -14
  92. package/assets/hooks/hook-input.sh +9 -2
  93. package/assets/hooks/lib/workflow-state.sh +28 -10
  94. package/assets/hooks/prompt-guard.sh +63 -37
  95. package/assets/hooks/security-sentinel.sh +2 -1
  96. package/assets/hooks/session-start-context.sh +7 -5
  97. package/assets/hooks/stop-orchestrator.sh +13 -3
  98. package/assets/initializer-question-pack.v4.json +11 -7
  99. package/assets/partials/05-workflow.partial.md +18 -73
  100. package/assets/partials/07-footer.partial.md +1 -1
  101. package/assets/partials-agents/02-operating-mode.partial.md +1 -2
  102. package/assets/partials-agents/04-task-protocol.partial.md +14 -59
  103. package/assets/partials-agents/06-quality-safety.partial.md +11 -16
  104. package/assets/partials-agents/08-deep-docs.partial.md +1 -2
  105. package/assets/plan-map.json +11 -11
  106. package/assets/plugin-registry.v1.json +9 -3
  107. package/assets/plugin-trust-policy.v1.json +6 -0
  108. package/assets/recovery/ForgeRecovery.ps1 +100 -0
  109. package/assets/recovery/forge-wsl-rescue +271 -0
  110. package/assets/reference-configs/development-protocol.md +11 -15
  111. package/assets/reference-configs/document-generation.md +1 -1
  112. package/assets/reference-configs/global-working-rules.md +9 -1
  113. package/assets/reference-configs/harness-overview.md +22 -112
  114. package/assets/reference-configs/hook-operations.md +1 -1
  115. package/assets/reference-configs/sprint-contracts.md +2 -2
  116. package/assets/skill-version.json +2 -2
  117. package/assets/templates/helpers/architecture-event.ts +3 -34
  118. package/assets/templates/helpers/architecture-queue.sh +61 -10
  119. package/assets/templates/helpers/archive-workflow.sh +90 -180
  120. package/assets/templates/helpers/capability-config.ts +8 -11
  121. package/assets/templates/helpers/capability-resolver.ts +37 -19
  122. package/assets/templates/helpers/capture-plan.sh +2 -2
  123. package/assets/templates/helpers/check-architecture-sync.sh +1 -9
  124. package/assets/templates/helpers/check-task-sync.sh +82 -11
  125. package/assets/templates/helpers/check-task-workflow.sh +1 -3
  126. package/assets/templates/helpers/context-contract-sync.sh +1 -12
  127. package/assets/templates/helpers/contract-worktree.sh +26 -24
  128. package/assets/templates/helpers/ensure-task-workflow.sh +6 -8
  129. package/assets/templates/helpers/inspect-project-state.ts +1 -1
  130. package/assets/templates/helpers/migrate-project-template.sh +1 -1
  131. package/assets/templates/helpers/migrate-workflow-docs.ts +53 -239
  132. package/assets/templates/helpers/new-plan.sh +2 -2
  133. package/assets/templates/helpers/plan-to-todo.sh +3 -31
  134. package/assets/templates/helpers/sprint-backlog.sh +1 -1
  135. package/assets/templates/helpers/switch-plan.sh +1 -1
  136. package/assets/templates/helpers/workflow-contract.ts +1 -0
  137. package/assets/workflow-contract.v1.json +63 -171
  138. package/assets/workflows/xiaohongshu/xiaohongshu.collect-metrics.v1.draft.json +118 -0
  139. package/assets/workflows/xiaohongshu/xiaohongshu.publish-image-note.v1.draft.json +316 -0
  140. package/assets/workflows/xiaohongshu/xiaohongshu.publish-long-text.v1.draft.json +324 -0
  141. package/docs/architecture/CURRENT.md +148 -13
  142. package/docs/architecture/EVOLUTION.md +13 -0
  143. package/docs/architecture/decisions/20260801-controller-home-sqlite-state.md +2 -1
  144. package/docs/architecture/decisions/20260831-independent-windows-wsl-host-rescue.md +59 -0
  145. package/docs/architecture/decisions/20260904-ios-device-migration-baseline.md +120 -0
  146. package/docs/architecture/decisions/20260904-repository-runtime-data-boundary.md +42 -0
  147. package/docs/architecture/decisions/20260907-assistant-learning-loop.md +35 -0
  148. package/docs/architecture/decisions/20260907-controller-round-transition-policy.md +296 -0
  149. package/docs/architecture/decisions/20260907-maintenance-diagnosis-bounded-read.md +39 -0
  150. package/docs/architecture/domains/verification.md +7 -0
  151. package/docs/architecture/domains/workflow-engine.md +1 -1
  152. package/docs/architecture/index.md +3 -3
  153. package/docs/architecture/modules/controller-runtime/transport-lifecycle.md +19 -8
  154. package/docs/architecture/requests/2026-09-04-computer-plugin-workflow-taxonomy.md +124 -0
  155. package/docs/forge-chatgpt-mcp-setup.md +5 -3
  156. package/docs/forge-plugin-management.md +20 -4
  157. package/docs/forge-runtime-self-healing-loop.md +2 -0
  158. package/docs/operations/benchmark-cross-version-freeze.md +38 -0
  159. package/docs/operations/controller-browser-plugin.md +3 -1
  160. package/docs/operations/homebrew.md +2 -2
  161. package/docs/operations/platform-support.md +16 -8
  162. package/docs/operations/platform-support.zh-CN.md +2 -2
  163. package/docs/operations/standalone-disaster-recovery.md +26 -1
  164. package/docs/operations/uu-remote-rescue.md +41 -0
  165. package/docs/operations/windows-wsl-host-rescue.md +133 -0
  166. package/docs/public-usage-guide.md +1 -1
  167. package/docs/public-usage-guide.zh-CN.md +1 -1
  168. package/docs/tutorials/01-install-and-start.md +1 -1
  169. package/docs/tutorials/01-install-and-start.zh-CN.md +1 -1
  170. package/docs/tutorials/02-connect-chatgpt.md +4 -4
  171. package/docs/tutorials/02-connect-chatgpt.zh-CN.md +4 -4
  172. package/docs/wiki/Implementation.md +1 -1
  173. package/package.json +23 -14
  174. package/packages/kernel/controller/api/index.ts +2 -0
  175. package/packages/kernel/controller/application/controller-round-service.ts +29 -0
  176. package/packages/kernel/controller/application/controller-service.ts +30 -0
  177. package/packages/kernel/controller/domain/controller-round-transition-policy.ts +308 -0
  178. package/packages/kernel/controller/domain/controller-round.ts +107 -0
  179. package/packages/kernel/controller/domain/execution-quality.ts +133 -0
  180. package/packages/kernel/controller/domain/types.ts +56 -0
  181. package/packages/kernel/controller/index.ts +1 -0
  182. package/packages/kernel/controller/infrastructure/controller-binding-store.ts +84 -0
  183. package/packages/kernel/controller/infrastructure/controller-round-store.ts +1384 -0
  184. package/packages/kernel/controller/infrastructure/controller-session-store.ts +578 -0
  185. package/packages/kernel/controller/ports/controller-host.ts +16 -0
  186. package/packages/kernel/goal/api/index.ts +1 -0
  187. package/packages/kernel/goal/domain/types.ts +40 -0
  188. package/packages/kernel/goal/index.ts +1 -0
  189. package/packages/kernel/identity/api/index.ts +5 -0
  190. package/packages/kernel/identity/application/identity-service.ts +67 -0
  191. package/packages/kernel/identity/domain/scope.ts +63 -0
  192. package/packages/kernel/identity/domain/semantic-sync.ts +81 -0
  193. package/packages/kernel/identity/domain/types.ts +44 -0
  194. package/packages/kernel/identity/domain/workspace.ts +56 -0
  195. package/packages/kernel/identity/index.ts +1 -0
  196. package/packages/kernel/identity/infrastructure/identity-store.ts +75 -0
  197. package/packages/kernel/memory/api/index.ts +5 -0
  198. package/packages/kernel/memory/application/experience-service.ts +118 -0
  199. package/packages/kernel/memory/application/outcome-service.ts +77 -0
  200. package/packages/kernel/memory/domain/experience.ts +103 -0
  201. package/packages/kernel/memory/domain/operational-prior.ts +92 -0
  202. package/packages/kernel/memory/index.ts +1 -0
  203. package/packages/kernel/progression/api/index.ts +2 -0
  204. package/packages/kernel/progression/application/projector.ts +211 -0
  205. package/packages/kernel/progression/domain/types.ts +116 -0
  206. package/packages/kernel/progression/index.ts +1 -0
  207. package/packages/kernel/scheduler/api/index.ts +6 -0
  208. package/packages/kernel/scheduler/application/continuation-service.ts +212 -0
  209. package/packages/kernel/scheduler/application/eligibility.ts +252 -0
  210. package/packages/kernel/scheduler/application/schedule-service.ts +24 -0
  211. package/packages/kernel/scheduler/application/settlement.ts +197 -0
  212. package/packages/kernel/scheduler/domain/continuation.ts +38 -0
  213. package/packages/kernel/scheduler/domain/schedule.ts +149 -0
  214. package/packages/kernel/scheduler/index.ts +1 -0
  215. package/packages/kernel/scheduler/infrastructure/continuation-dispatch-store.ts +38 -0
  216. package/packages/kernel/scheduler/infrastructure/schedule-store.ts +785 -0
  217. package/packages/kernel/work/api/index.ts +15 -0
  218. package/packages/kernel/work/application/work-service.ts +148 -0
  219. package/packages/kernel/work/domain/admission-policy.ts +34 -0
  220. package/packages/kernel/work/domain/check-receipt.ts +43 -0
  221. package/packages/kernel/work/domain/context-closure-receipt.ts +32 -0
  222. package/packages/kernel/work/domain/engineering-contracts.ts +157 -0
  223. package/packages/kernel/work/domain/engineering-design.ts +281 -0
  224. package/packages/kernel/work/domain/engineering-profile.ts +242 -0
  225. package/packages/kernel/work/domain/execution-concurrency.ts +254 -0
  226. package/packages/kernel/work/domain/execution-snapshot.ts +33 -0
  227. package/packages/kernel/work/domain/implementation-review.ts +510 -0
  228. package/packages/kernel/work/domain/project-engineering-contract.ts +202 -0
  229. package/packages/kernel/work/domain/repository-completion-receipt.ts +73 -0
  230. package/packages/kernel/work/domain/state-machine.ts +259 -0
  231. package/packages/kernel/work/domain/types.ts +528 -0
  232. package/packages/kernel/work/index.ts +1 -0
  233. package/packages/kernel/work/infrastructure/work-contract-store.ts +1876 -0
  234. package/packages/kernel/work/ports/work-contract-store.ts +18 -0
  235. package/packages/plugin-runtime/browser/index.ts +3 -0
  236. package/packages/plugin-runtime/browser/provider-registry.ts +110 -0
  237. package/packages/plugin-runtime/browser/runtime-contract.ts +150 -0
  238. package/packages/plugin-runtime/browser/session-authority.ts +61 -0
  239. package/packages/plugin-runtime/computer/index.ts +6 -0
  240. package/packages/plugin-runtime/computer/provider-error.ts +26 -0
  241. package/packages/plugin-runtime/computer/provider-registration.ts +52 -0
  242. package/packages/plugin-runtime/computer/provider-registry.ts +63 -0
  243. package/packages/plugin-runtime/computer/provider.ts +19 -0
  244. package/packages/plugin-runtime/computer/target-authority.ts +190 -0
  245. package/packages/plugin-runtime/computer/target-persistence.ts +54 -0
  246. package/packages/plugin-runtime/external/index.ts +1 -0
  247. package/packages/plugin-runtime/external/unix-jsonl-transport.ts +457 -0
  248. package/packages/plugin-runtime/index.ts +3 -0
  249. package/packages/protocols/browser/index.ts +1 -0
  250. package/packages/protocols/browser/session.ts +98 -0
  251. package/packages/protocols/computer/contract.ts +199 -0
  252. package/packages/protocols/computer/index.ts +1 -0
  253. package/packages/protocols/failure/contract.ts +158 -0
  254. package/packages/protocols/failure/index.ts +1 -0
  255. package/packages/protocols/handoff/index.ts +1 -0
  256. package/packages/protocols/handoff/status.ts +22 -0
  257. package/packages/protocols/mcp/execution-context.ts +11 -0
  258. package/packages/protocols/mcp/index.ts +2 -0
  259. package/packages/protocols/mcp/tool-contract.ts +42 -0
  260. package/packages/workflow-runtime/api/index.ts +2 -0
  261. package/packages/workflow-runtime/application/interpreter.ts +342 -0
  262. package/packages/workflow-runtime/domain/workflow-asset.ts +223 -0
  263. package/packages/workflow-runtime/index.ts +1 -0
  264. package/scripts/assemble-template.ts +1 -1
  265. package/scripts/benchmark-computer-hotpath.ts +255 -0
  266. package/scripts/benchmark-controller-round2.ts +54 -2
  267. package/scripts/benchmark-ios-agent-device.ts +3 -6
  268. package/scripts/benchmark-mcp-transport.ts +3 -4
  269. package/scripts/benchmark-operational-memory-activation.ts +235 -0
  270. package/scripts/benchmark-operational-shadow.ts +28 -0
  271. package/scripts/bootstrap-runtime-maintenance-recovery.sh +4 -1
  272. package/scripts/canary-chatgpt-provider-delivery.ts +97 -0
  273. package/scripts/canary-controller-semantic-wait.ts +195 -0
  274. package/scripts/canary-global-hook.sh +2 -2
  275. package/scripts/check-mcp-compatibility.ts +173 -7
  276. package/scripts/check-platform-support.mjs +28 -2
  277. package/scripts/check-public-docs.sh +1 -1
  278. package/scripts/check-release-readiness.sh +1 -1
  279. package/scripts/check-repository-hygiene.mjs +92 -0
  280. package/scripts/check-runtime-architecture.mjs +1206 -95
  281. package/scripts/check-source-duplication.mjs +9 -1
  282. package/scripts/check-tarball-install-smoke.sh +98 -15
  283. package/scripts/controller-ngrok-rotation.sh +5 -4
  284. package/scripts/create-project-dirs.sh +10 -74
  285. package/scripts/forge-local-recovery-helper.mjs +204 -0
  286. package/scripts/forge-uu-remote-rescue-helper.d.mts +31 -0
  287. package/scripts/forge-uu-remote-rescue-helper.mjs +409 -0
  288. package/scripts/forge-windows-host-recovery-helper.mjs +136 -0
  289. package/scripts/hook-shim.sh +2 -2
  290. package/scripts/init-project.sh +12 -70
  291. package/scripts/install-desktop-operator-registration.ts +4 -2
  292. package/scripts/install-independent-windows-wsl-recovery.ts +125 -0
  293. package/scripts/install-standalone-recovery.ts +122 -10
  294. package/scripts/install-uu-remote-rescue-registration.ts +74 -0
  295. package/scripts/install-windows-host-recovery-registration.ts +22 -0
  296. package/scripts/lib/controller-home-env.sh +6 -3
  297. package/scripts/lib/project-init-lib.sh +39 -582
  298. package/scripts/migrate-chatgpt-automation-schedules.ts +2 -2
  299. package/scripts/migrate-windows-wsl-controller-home.ts +306 -0
  300. package/scripts/open-source-audit-allowlist.txt +12 -1
  301. package/scripts/portability-bindings.mjs +70 -0
  302. package/scripts/run-bounded-command.mjs +55 -0
  303. package/scripts/run-bun-test-file.ts +22 -6
  304. package/scripts/run-governed-gate.ts +4 -1
  305. package/scripts/smoke-mcp-http-runtime.ts +1 -1
  306. package/scripts/smoke-runtime-recovery.ts +34 -1
  307. package/scripts/smoke-schedule-engine.ts +1 -1
  308. package/scripts/stage-runtime-release.ts +6 -1
  309. package/scripts/test-governance.ts +51 -2
  310. package/src/cli/agent-jobs/job-manager.ts +10 -1
  311. package/src/cli/chatgpt-browser/bind-server.ts +2 -1
  312. package/src/cli/chatgpt-browser/binding.ts +20 -10
  313. package/src/cli/chatgpt-browser/bridge-extension.ts +75 -0
  314. package/src/cli/chatgpt-browser/bridge-provider.ts +376 -11
  315. package/src/cli/chatgpt-browser/engine.ts +10 -11
  316. package/src/cli/chatgpt-browser/native-provider.ts +24 -83
  317. package/src/cli/chatgpt-browser/oracle-provider.ts +5 -3
  318. package/src/cli/chatgpt-browser/types.ts +1 -0
  319. package/src/cli/commands/bootstrap-control.ts +334 -0
  320. package/src/cli/commands/brain-assistant.ts +38 -0
  321. package/src/cli/commands/brain.ts +193 -40
  322. package/src/cli/commands/chatgpt.ts +127 -0
  323. package/src/cli/commands/computer.ts +437 -0
  324. package/src/cli/commands/doctor.ts +18 -1
  325. package/src/cli/commands/init-hook.ts +71 -61
  326. package/src/cli/commands/init.ts +3 -1
  327. package/src/cli/commands/mcp.ts +16 -10
  328. package/src/cli/commands/plugin.ts +38 -12
  329. package/src/cli/commands/recovery.ts +493 -80
  330. package/src/cli/commands/runtime.ts +9 -4
  331. package/src/cli/commands/setup-profile.ts +89 -39
  332. package/src/cli/commands/status.ts +2 -1
  333. package/src/cli/controller/check-runner.ts +487 -98
  334. package/src/cli/controller/context/types.ts +7 -1
  335. package/src/cli/controller/context-pack.ts +23 -3
  336. package/src/cli/controller/issue-store.ts +1 -1
  337. package/src/cli/controller/systemd-user.ts +110 -0
  338. package/src/cli/controller/types.ts +10 -70
  339. package/src/cli/controller/worklog.ts +67 -13
  340. package/src/cli/editing/edit-operation-contract.ts +92 -0
  341. package/src/cli/editing/edit-session.ts +289 -13
  342. package/src/cli/github/plugin.ts +17 -12
  343. package/src/cli/hook/route-registry.ts +3 -5
  344. package/src/cli/hook/runtime.ts +49 -3
  345. package/src/cli/index.ts +3 -0
  346. package/src/cli/local-bridge/connector-freshness.ts +2 -2
  347. package/src/cli/local-bridge/console-automations.ts +2 -2
  348. package/src/cli/local-bridge/facade-api.ts +41 -14
  349. package/src/cli/local-bridge/job-store.ts +1 -1
  350. package/src/cli/local-bridge/server.ts +24 -27
  351. package/src/cli/mcp/access-mode.ts +2 -132
  352. package/src/cli/mcp/access-tools.ts +2 -387
  353. package/src/cli/mcp/audit.ts +2 -32
  354. package/src/cli/mcp/auth.ts +2 -404
  355. package/src/cli/mcp/instructions.ts +2 -34
  356. package/src/cli/mcp/legacy-context.ts +2 -16
  357. package/src/cli/mcp/legacy-tool-service.ts +2 -5308
  358. package/src/cli/mcp/multi-repository.ts +2 -436
  359. package/src/cli/mcp/oauth.ts +2 -375
  360. package/src/cli/mcp/openai-secure-tunnel.ts +2 -0
  361. package/src/cli/mcp/paths.ts +2 -140
  362. package/src/cli/mcp/policy.ts +2 -232
  363. package/src/cli/mcp/post-finalize-work-attribution.ts +2 -150
  364. package/src/cli/mcp/proxy-env.ts +2 -62
  365. package/src/cli/mcp/readiness-projection.ts +2 -24
  366. package/src/cli/mcp/redaction.ts +2 -21
  367. package/src/cli/mcp/repo.ts +2 -24
  368. package/src/cli/mcp/repository-tools.ts +2 -1585
  369. package/src/cli/mcp/server.ts +2 -951
  370. package/src/cli/mcp/setup.ts +2 -737
  371. package/src/cli/mcp/tool-capability-cache.ts +2 -87
  372. package/src/cli/mcp/tool-contract.ts +2 -14
  373. package/src/cli/mcp/tools.ts +2 -9
  374. package/src/cli/mcp/toolset-names.ts +2 -70
  375. package/src/cli/mcp/toolset-selection.ts +2 -41
  376. package/src/cli/mcp/toolset.ts +2 -336
  377. package/src/cli/mcp/transports/AGENTS.md +1 -10
  378. package/src/cli/mcp/transports/CLAUDE.md +1 -10
  379. package/src/cli/mcp/transports/http.ts +2 -1414
  380. package/src/cli/mcp/transports/session-registry.ts +2 -490
  381. package/src/cli/mcp/transports/stdio.ts +2 -8
  382. package/src/cli/mcp/types.ts +2 -41
  383. package/src/cli/mcp/umbrella-tools.ts +2 -117
  384. package/src/cli/repositories/command-executor.ts +64 -18
  385. package/src/cli/repositories/command-scope.ts +117 -1
  386. package/src/cli/repositories/controller-home.ts +119 -1
  387. package/src/cli/repositories/identity.ts +13 -0
  388. package/src/cli/repositories/registry.ts +68 -49
  389. package/src/cli/repositories/repository-snapshot.ts +53 -7
  390. package/src/cli/repositories/runtime-storage.ts +27 -2
  391. package/src/cli/repositories/safe-patch.ts +34 -38
  392. package/src/cli/repositories/selected-path-actions.ts +22 -2
  393. package/src/cli/repositories/structured-git.ts +105 -25
  394. package/src/cli/runtime/helper-runner.ts +7 -0
  395. package/src/cli/runtime-invocation.ts +8 -1
  396. package/src/cli/tools/codegraph.ts +44 -25
  397. package/src/core/adoption/manifest-templates.ts +1 -1
  398. package/src/core/adoption/plan.ts +3 -26
  399. package/src/core/adoption/workflow-contract-plan.ts +17 -9
  400. package/src/effects/process-runner.ts +8 -14
  401. package/src/runtime/context/assistant-context.ts +154 -0
  402. package/src/runtime/context/assistant-work-context.ts +147 -0
  403. package/src/runtime/context/codegraph-cache-boundary.ts +255 -0
  404. package/src/runtime/context/codegraph-read-provider.ts +55 -22
  405. package/src/runtime/context/codegraph-sidecar.cjs +8 -1
  406. package/src/runtime/context/context-closure.ts +268 -0
  407. package/src/runtime/context/context-plane.ts +211 -0
  408. package/src/runtime/context/project-engineering-contract.ts +60 -0
  409. package/src/runtime/control-plane/bootstrap/capability-provider.ts +74 -0
  410. package/src/runtime/control-plane/bootstrap/control-api.ts +57 -0
  411. package/src/runtime/control-plane/bootstrap/index.ts +5 -0
  412. package/src/runtime/control-plane/bootstrap/state-machine.ts +141 -0
  413. package/src/runtime/control-plane/bootstrap/store.ts +21 -0
  414. package/src/runtime/control-plane/bootstrap/types.ts +87 -0
  415. package/src/runtime/control-plane/cleanup-artifact-retention.ts +328 -0
  416. package/src/runtime/control-plane/codegraph-cache-retention.ts +164 -0
  417. package/src/runtime/control-plane/concurrency/work-execution-concurrency.ts +320 -0
  418. package/src/runtime/control-plane/execution/content-equivalent-commit-authority.ts +169 -0
  419. package/src/runtime/control-plane/execution/controller-authority-recovery.ts +350 -0
  420. package/src/runtime/control-plane/execution/direct-canonical-work-reconciliation.ts +85 -0
  421. package/src/runtime/control-plane/execution/direct-edit-work-completion.ts +417 -100
  422. package/src/runtime/control-plane/execution/edit-validation-coordinator.ts +103 -15
  423. package/src/runtime/control-plane/execution/implementation-review-content.ts +95 -0
  424. package/src/runtime/control-plane/execution/repository-work-attribution.ts +2 -2
  425. package/src/runtime/control-plane/execution/retained-work-resume.ts +336 -6
  426. package/src/runtime/control-plane/execution/validation.ts +28 -3
  427. package/src/runtime/control-plane/execution/work-authority-reconciler.ts +116 -0
  428. package/src/runtime/control-plane/execution/work-completion-authority.ts +44 -2
  429. package/src/runtime/control-plane/execution/work-evidence-policy.ts +34 -3
  430. package/src/runtime/control-plane/execution/work-execution-support.ts +42 -22
  431. package/src/runtime/control-plane/execution/work-finalization-service.ts +1103 -166
  432. package/src/runtime/control-plane/execution/work-handle-authority.ts +267 -16
  433. package/src/runtime/control-plane/execution/work-handle-store.ts +77 -0
  434. package/src/runtime/control-plane/execution/work-head-settlement.ts +75 -0
  435. package/src/runtime/control-plane/execution/work-lifecycle-audit.ts +145 -23
  436. package/src/runtime/control-plane/execution/work-operation-service.ts +49 -13
  437. package/src/runtime/control-plane/execution/work-preparation-service.ts +31 -15
  438. package/src/runtime/control-plane/execution/work-remote-delivery.ts +1 -1
  439. package/src/runtime/control-plane/execution/work-task-receipt.ts +20 -1
  440. package/src/runtime/control-plane/execution/work-terminal-cleanup.ts +407 -76
  441. package/src/runtime/control-plane/execution/work-validation-reconciler.ts +88 -18
  442. package/src/runtime/control-plane/execution/work-verification-context.ts +1 -1
  443. package/src/runtime/control-plane/execution/work-verification-service.ts +258 -4
  444. package/src/runtime/control-plane/execution/work-verification-snapshot.ts +200 -15
  445. package/src/runtime/control-plane/facade/capability-registry.ts +21 -10
  446. package/src/runtime/control-plane/facade/controller-round-relay.ts +3 -1118
  447. package/src/runtime/control-plane/facade/controller-session-store.ts +2 -488
  448. package/src/runtime/control-plane/facade/goal-workloop-access.ts +6 -3
  449. package/src/runtime/control-plane/facade/goal-workloop.ts +972 -137
  450. package/src/runtime/control-plane/facade/handoff-inbox-application.ts +158 -0
  451. package/src/runtime/control-plane/facade/handoff-inbox-store.ts +10 -0
  452. package/src/runtime/control-plane/facade/index.ts +4 -2
  453. package/src/runtime/control-plane/facade/operation-digest.ts +22 -58
  454. package/src/runtime/control-plane/facade/plan-contract-store.ts +1004 -38
  455. package/src/runtime/control-plane/facade/repository-work-admission.ts +19 -1
  456. package/src/runtime/control-plane/facade/requirement-authority.ts +218 -0
  457. package/src/runtime/control-plane/facade/requirement-board.ts +6 -1
  458. package/src/runtime/control-plane/facade/rh-work-operation-contract.ts +48 -0
  459. package/src/runtime/control-plane/facade/semantic-admission.ts +8 -16
  460. package/src/runtime/control-plane/facade/suggested-actions.ts +4 -1
  461. package/src/runtime/control-plane/facade/types.ts +189 -532
  462. package/src/runtime/control-plane/facade/work-admission-policy.ts +84 -35
  463. package/src/runtime/control-plane/facade/work-contract-store.ts +2 -1043
  464. package/src/runtime/control-plane/facade/work-implementation-review.ts +2 -0
  465. package/src/runtime/control-plane/facade/work-state-machine.ts +2 -250
  466. package/src/runtime/control-plane/generated-cache-retention.ts +239 -18
  467. package/src/runtime/control-plane/global-scheduler/durable-admission.ts +12 -1
  468. package/src/runtime/control-plane/global-scheduler/maintenance.ts +76 -13
  469. package/src/runtime/control-plane/global-scheduler/periodic-cleanup-entry.ts +55 -0
  470. package/src/runtime/control-plane/global-scheduler/periodic-cleanup-process.ts +98 -0
  471. package/src/runtime/control-plane/global-scheduler/reconciliation.ts +1 -1
  472. package/src/runtime/control-plane/global-scheduler/scheduler-worker-entry.ts +10 -0
  473. package/src/runtime/control-plane/global-scheduler/scheduler.ts +173 -81
  474. package/src/runtime/control-plane/global-scheduler/worker-launch.ts +18 -6
  475. package/src/runtime/control-plane/launcher/chatgpt-round-continuation.ts +397 -0
  476. package/src/runtime/control-plane/launcher/chatgpt-work-binding-store.ts +2 -177
  477. package/src/runtime/control-plane/launcher/chatgpt-work-continuation.ts +301 -560
  478. package/src/runtime/control-plane/launcher/provider-mcp-bootstrap.ts +20 -4
  479. package/src/runtime/control-plane/launcher/thin-launcher.ts +50 -4
  480. package/src/runtime/control-plane/lifecycle-retention-metrics.ts +60 -0
  481. package/src/runtime/control-plane/persistence/experience-store.ts +169 -0
  482. package/src/runtime/control-plane/persistence/operational-prior-store.ts +348 -0
  483. package/src/runtime/control-plane/persistence/requirement-store.ts +30 -22
  484. package/src/runtime/control-plane/persistence/sqlite-store.ts +545 -76
  485. package/src/runtime/control-plane/persistence/workflow-content-store.ts +98 -0
  486. package/src/runtime/control-plane/persistence/workflow-registry-store.ts +186 -0
  487. package/src/runtime/control-plane/persistence/workflow-run-store.ts +123 -0
  488. package/src/runtime/control-plane/release-retention.ts +56 -16
  489. package/src/runtime/control-plane/repository-namespace-retention.ts +208 -0
  490. package/src/runtime/control-plane/routing/route-policy.ts +19 -0
  491. package/src/runtime/control-plane/runtime-cleanup.ts +574 -37
  492. package/src/runtime/control-plane/runtime-generation.ts +6 -0
  493. package/src/runtime/control-plane/workspace/semantic-sync-service.ts +465 -0
  494. package/src/runtime/control-plane/workspace/workspace-store.ts +80 -0
  495. package/src/runtime/diagnostics/incident-repair.ts +406 -0
  496. package/src/runtime/diagnostics/mcp-timing.ts +125 -6
  497. package/src/runtime/diagnostics/performance.ts +6 -14
  498. package/src/runtime/diagnostics/read-only-tool.ts +1 -1
  499. package/src/runtime/evidence/artifact-store.ts +65 -2
  500. package/src/runtime/evidence/operational-shadow.ts +38 -0
  501. package/src/runtime/evidence/process-check-receipt.ts +5 -43
  502. package/src/runtime/evidence/sensitive-output.ts +4 -4
  503. package/src/runtime/execution/jobs/receipt-recovery.ts +1 -1
  504. package/src/runtime/execution/jobs/store.ts +121 -2
  505. package/src/runtime/execution/managed-workspace.ts +55 -5
  506. package/src/runtime/execution/process-runtime/canary.ts +19 -5
  507. package/src/runtime/execution/process-runtime/check-classification.ts +48 -0
  508. package/src/runtime/execution/process-runtime/check-facade.ts +23 -9
  509. package/src/runtime/execution/process-runtime/check-receipt.ts +1 -1
  510. package/src/runtime/execution/process-runtime/check-result-retention.ts +132 -0
  511. package/src/runtime/execution/process-runtime/check-result.ts +73 -2
  512. package/src/runtime/execution/process-runtime/check-runner-sidecar.ts +42 -3
  513. package/src/runtime/execution/process-runtime/check-storage.ts +187 -0
  514. package/src/runtime/execution/process-runtime/command-facade.ts +38 -87
  515. package/src/runtime/execution/process-runtime/index.ts +1 -0
  516. package/src/runtime/execution/process-runtime/interactive-admission.ts +2 -1
  517. package/src/runtime/execution/process-runtime/lightweight-managed.ts +32 -1
  518. package/src/runtime/execution/process-runtime/persisted-check.ts +128 -21
  519. package/src/runtime/execution/process-runtime/resource-claims.ts +60 -3
  520. package/src/runtime/execution/process-runtime/runtime.ts +132 -15
  521. package/src/runtime/execution/process-runtime/types.ts +22 -0
  522. package/src/runtime/execution/workers/executor.ts +16 -13
  523. package/src/runtime/execution/workers/worker-entry.ts +1 -1
  524. package/src/runtime/gateway/mcp/execution-tools.ts +2 -207
  525. package/src/runtime/gateway/mcp/legacy-ios-tool-adapter.ts +2 -61
  526. package/src/runtime/gateway/mcp/persisted-check-process.ts +2 -3
  527. package/src/runtime/gateway/mcp/process-tools.ts +2 -289
  528. package/src/runtime/gateway/mcp/router.ts +2 -1125
  529. package/src/runtime/gateway/mcp/runtime-tool-definitions.ts +2 -565
  530. package/src/runtime/gateway/mcp/runtime-tools.ts +2 -6651
  531. package/src/runtime/gateway/mcp/work-validation-reconciler.ts +2 -1
  532. package/src/runtime/maintenance/cleanup.ts +38 -24
  533. package/src/runtime/platform/browser-product-discovery.ts +174 -0
  534. package/src/runtime/platform/computer-platform.ts +14 -0
  535. package/src/runtime/platform/executable-discovery.ts +54 -0
  536. package/src/runtime/platform/fetch-http-server.ts +90 -0
  537. package/src/runtime/platform/service-manager.ts +138 -0
  538. package/src/runtime/platform/windows-host-discovery.ts +118 -0
  539. package/src/runtime/platform/windows-recovery-deployment.ts +67 -0
  540. package/src/runtime/plugins/action-application.ts +135 -0
  541. package/src/runtime/plugins/app-store-connect-adapter.ts +9 -21
  542. package/src/runtime/plugins/browser-adapter.ts +140 -100
  543. package/src/runtime/plugins/browser-automation-service.ts +15 -36
  544. package/src/runtime/plugins/browser-macos-bridge.ts +69 -21
  545. package/src/runtime/plugins/browser-manifest-surface.ts +30 -6
  546. package/src/runtime/plugins/browser-native-session-service.ts +1 -1
  547. package/src/runtime/plugins/browser-provider-registry.ts +2 -109
  548. package/src/runtime/plugins/browser-registration.ts +16 -0
  549. package/src/runtime/plugins/browser-runtime-contract.ts +2 -154
  550. package/src/runtime/plugins/browser-runtime.ts +41 -9
  551. package/src/runtime/plugins/browser-session-authority.ts +101 -291
  552. package/src/runtime/plugins/browser-session-legacy-migration.ts +203 -0
  553. package/src/runtime/plugins/browser-session-store.ts +229 -36
  554. package/src/runtime/plugins/browser-session-types.ts +2 -98
  555. package/src/runtime/plugins/capability-authorization-grants.ts +17 -0
  556. package/src/runtime/plugins/catalog-trust.ts +82 -0
  557. package/src/runtime/plugins/computer-registration.ts +839 -0
  558. package/src/runtime/plugins/config-store.ts +119 -0
  559. package/src/runtime/plugins/desktop-operator-external-policy.ts +932 -0
  560. package/src/runtime/plugins/desktop-operator-registration.ts +111 -8
  561. package/src/runtime/plugins/errors.ts +8 -1
  562. package/src/runtime/plugins/external-adapter.ts +45 -322
  563. package/src/runtime/plugins/external-provider-policy.ts +48 -0
  564. package/src/runtime/plugins/external-registration.ts +9 -1
  565. package/src/runtime/plugins/external-unix-socket-probe.cjs +9 -3
  566. package/src/runtime/plugins/external-unix-socket.ts +64 -193
  567. package/src/runtime/plugins/first-party-external-registration.ts +163 -0
  568. package/src/runtime/plugins/first-party-registry.ts +3 -1
  569. package/src/runtime/plugins/github-adapter.ts +1 -2
  570. package/src/runtime/plugins/gmail-adapter.ts +6 -6
  571. package/src/runtime/plugins/google-calendar-adapter.ts +6 -6
  572. package/src/runtime/plugins/google-shared.ts +31 -46
  573. package/src/runtime/plugins/google-tasks-adapter.ts +6 -6
  574. package/src/runtime/plugins/ios-adapter.ts +1 -2
  575. package/src/runtime/plugins/local-system-adapter.ts +180 -0
  576. package/src/runtime/plugins/macos-capability-broker.ts +15 -105
  577. package/src/runtime/plugins/resend-adapter.ts +15 -24
  578. package/src/runtime/plugins/store.ts +493 -51
  579. package/src/runtime/plugins/types.ts +8 -1
  580. package/src/runtime/plugins/uu-remote-rescue-registration.ts +155 -0
  581. package/src/runtime/plugins/windows-host-recovery-install.ts +68 -0
  582. package/src/runtime/plugins/windows-host-recovery-registration.ts +85 -0
  583. package/src/runtime/plugins/xiaohongshu-publish.ts +86 -430
  584. package/src/runtime/projections/controller-context.ts +12 -6
  585. package/src/runtime/projections/git-status-sampler.ts +73 -22
  586. package/src/runtime/projections/materialized-view.ts +14 -8
  587. package/src/runtime/recovery/capability-action-application.ts +228 -0
  588. package/src/runtime/recovery/index.ts +3 -0
  589. package/src/runtime/recovery/lifecycle-inventory.ts +338 -0
  590. package/src/runtime/recovery/local-jobs-repair.ts +14 -14
  591. package/src/runtime/recovery/maintenance-executor.ts +358 -76
  592. package/src/runtime/recovery/quarantine-retention.ts +256 -0
  593. package/src/runtime/release/identity.ts +6 -0
  594. package/src/runtime/resources/leases/store.ts +1 -1
  595. package/src/runtime/root/active-execution-power-assertion.ts +139 -0
  596. package/src/runtime/root/assistant-learning-loop.ts +45 -0
  597. package/src/runtime/root/browser-session-composition.ts +59 -0
  598. package/src/runtime/root/computer-composition.ts +191 -0
  599. package/src/runtime/root/computer-target-composition.ts +16 -0
  600. package/src/runtime/root/computer-target-persistence.ts +39 -0
  601. package/src/runtime/root/controller-round-composition.ts +107 -0
  602. package/src/runtime/root/controller-services.ts +2 -0
  603. package/src/runtime/root/entry.ts +4 -3
  604. package/src/runtime/root/gateway-adapter.ts +3 -3
  605. package/src/runtime/root/local-bridge.ts +5 -2
  606. package/src/runtime/root/mcp-transport.ts +5 -5
  607. package/src/runtime/root/package-connector-service.ts +108 -56
  608. package/src/runtime/root/package-runtime-release.ts +86 -18
  609. package/src/runtime/root/package-runtime-service.ts +63 -86
  610. package/src/runtime/root/release-execution-canary.ts +71 -0
  611. package/src/runtime/root/release-loader.ts +68 -0
  612. package/src/runtime/root/release-manifest.ts +106 -2
  613. package/src/runtime/root/release-materialize.ts +103 -4
  614. package/src/runtime/root/release-store.ts +31 -2
  615. package/src/runtime/root/runtime.ts +240 -25
  616. package/src/runtime/root/scheduled-controller-composition.ts +51 -0
  617. package/src/runtime/root/scheduler.ts +12 -4
  618. package/src/runtime/root/service-runner.ts +1 -1
  619. package/src/runtime/root/service.ts +41 -16
  620. package/src/runtime/root/status.ts +1 -0
  621. package/src/runtime/root/types.ts +24 -1
  622. package/src/runtime/shared/local-bridge-surface.ts +1 -1
  623. package/src/runtime/shared/process-environment.ts +19 -4
  624. package/src/runtime/shared/storage-capacity.ts +68 -0
  625. package/src/runtime/standalone-recovery/controller-home-migration.ts +1116 -0
  626. package/src/runtime/standalone-recovery/core.ts +984 -230
  627. package/src/runtime/standalone-recovery/entry.ts +182 -51
  628. package/src/runtime/standalone-recovery/independent-host-rescue.ts +172 -0
  629. package/src/runtime/standalone-recovery/installer.ts +212 -104
  630. package/src/runtime/standalone-recovery/mcp-server.ts +243 -0
  631. package/src/runtime/standalone-recovery/mutation-identity-contract.ts +21 -0
  632. package/src/runtime/standalone-recovery/operation-lock.ts +160 -0
  633. package/src/runtime/standalone-recovery/performance.ts +135 -0
  634. package/src/runtime/standalone-recovery/release.ts +5 -0
  635. package/src/runtime/watchdog/workflow-watchdog.ts +1 -1
  636. package/src/runtime/workflow/schedules/chatgpt-automation-migration.ts +1 -1
  637. package/src/runtime/workflow/schedules/engine.ts +191 -343
  638. package/src/runtime/workflow/schedules/pending-activation.ts +1 -1
  639. package/src/runtime/workflow/schedules/settlement.ts +2 -191
  640. package/src/runtime/workflow/schedules/store.ts +2 -607
  641. package/src/runtime/workflow/schedules/types.ts +2 -127
  642. package/src/runtime/workflow/schedules/work-continuation.ts +180 -15
  643. package/src/runtime/workflows/first-party/xiaohongshu.ts +122 -0
  644. package/src/runtime/workflows/runtime.ts +486 -0
  645. package/src/testing/test-governance.ts +90 -29
  646. package/assets/templates/helpers/archive-architecture-request.sh +0 -244
  647. package/docs/architecture/history/README.md +0 -7
  648. package/docs/architecture/history/chatgpt-handoff-facade.md +0 -397
  649. package/docs/architecture/history/global-hook-runtime.md +0 -166
  650. package/docs/architecture/history/ios-semantic-automation-provider-v2.md +0 -170
  651. package/docs/architecture/requests/archive/2026/20260528-154740-ai-hooks-ai-hooks-hook-input-sh.md +0 -59
  652. package/docs/architecture/requests/archive/2026/20260528-154816-assets-hooks-assets-hooks-hook-input-sh.md +0 -59
  653. package/docs/architecture/requests/archive/2026/20260528-161851-ai-harness-workflow-contract-json-ai-harness-workflow-contract-json.md +0 -59
  654. package/docs/architecture/requests/archive/2026/20260528-161853-scripts-check-task-workflow-sh-scripts-check-task-workflow-sh.md +0 -59
  655. package/docs/architecture/requests/archive/2026/20260528-161911-assets-workflow-contract-v1-json-assets-workflow-contract-v1-json.md +0 -59
  656. package/docs/architecture/requests/archive/2026/20260528-222416-ai-hooks-ai-hooks-hook-input-sh.md +0 -59
  657. package/docs/architecture/requests/archive/2026/20260528-222444-ai-hooks-ai-hooks-pre-edit-guard-sh.md +0 -59
  658. package/docs/architecture/requests/archive/2026/20260528-222457-ai-hooks-ai-hooks-pre-edit-guard-sh.md +0 -59
  659. package/docs/architecture/requests/archive/2026/20260528-222648-ai-hooks-ai-hooks-pre-edit-guard-sh.md +0 -59
  660. package/docs/architecture/requests/archive/2026/20260528-222705-ai-hooks-ai-hooks-worktree-guard-sh.md +0 -59
  661. package/docs/architecture/requests/archive/2026/20260528-222726-ai-hooks-ai-hooks-prompt-guard-sh.md +0 -59
  662. package/docs/architecture/requests/archive/2026/20260528-222727-ai-hooks-ai-hooks-prompt-guard-sh.md +0 -59
  663. package/docs/architecture/requests/archive/2026/20260528-224736-ai-hooks-ai-hooks-hook-input-sh.md +0 -59
  664. package/docs/architecture/requests/archive/2026/20260528-233259-ai-hooks-ai-hooks-prompt-guard-sh.md +0 -59
  665. package/docs/architecture/requests/archive/2026/20260528-233335-assets-hooks-assets-hooks-prompt-guard-sh.md +0 -59
  666. package/docs/architecture/requests/archive/2026/20260528-233456-ai-hooks-ai-hooks-prompt-guard-sh.md +0 -59
  667. package/docs/architecture/requests/archive/2026/20260528-233457-assets-hooks-assets-hooks-prompt-guard-sh.md +0 -59
  668. package/docs/architecture/requests/archive/2026/20260528-233637-ai-hooks-ai-hooks-prompt-guard-sh.md +0 -59
  669. package/docs/architecture/requests/archive/2026/20260528-233638-assets-hooks-assets-hooks-prompt-guard-sh.md +0 -59
  670. package/docs/architecture/requests/archive/2026/20260529-000322-root-package-json.md +0 -59
  671. package/docs/architecture/requests/archive/2026/20260529-004238-ai-hooks-ai-hooks-lib-workflow-state-sh.md +0 -59
  672. package/docs/architecture/requests/archive/2026/20260529-020654-ai-harness-policy-json-ai-harness-policy-json.md +0 -63
  673. package/docs/architecture/requests/archive/2026/20260529-094236-ai-hooks-ai-hooks-prompt-guard-sh.md +0 -60
  674. package/docs/architecture/requests/archive/2026/20260529-094323-assets-hooks-assets-hooks-prompt-guard-sh.md +0 -60
  675. package/docs/architecture/requests/archive/2026/20260529-094331-ai-hooks-ai-hooks-prompt-guard-sh.md +0 -60
  676. package/docs/architecture/requests/archive/2026/20260529-094339-assets-hooks-assets-hooks-prompt-guard-sh.md +0 -60
  677. package/docs/architecture/requests/archive/2026/20260529-094430-assets-hooks-assets-hooks-session-start-context-sh.md +0 -60
  678. package/docs/architecture/requests/archive/2026/20260529-094446-ai-hooks-ai-hooks-session-start-context-sh.md +0 -60
  679. package/docs/architecture/requests/archive/2026/20260613-002040-runtime-harness-hook-adapters.md +0 -68
  680. package/docs/architecture/requests/archive/2026/root.md +0 -68
  681. package/docs/architecture/requests/archive/2026/runtime-harness-hook-adapters.md +0 -76
  682. package/docs/architecture/requests/archive/2026/verification-evals-checks.md +0 -68
  683. package/docs/architecture/requests/archive/2026/workflow-engine-contract-assets.md +0 -69
  684. package/scripts/archive-architecture-request.sh +0 -4
  685. package/scripts/run-skill-evals.ts +0 -1022
@@ -44,8 +44,10 @@ function forbidBetween(path, startNeedle, endNeedle, expression, description) {
44
44
  if (expression.test(source.slice(start, end))) failures.push(`${path} violates ${description}`);
45
45
  }
46
46
  function sourceFiles(directory) {
47
+ const absolute = resolve(root, directory);
48
+ if (!existsSync(absolute)) return [];
47
49
  const files = [];
48
- for (const entry of readdirSync(resolve(root, directory), { withFileTypes: true })) {
50
+ for (const entry of readdirSync(absolute, { withFileTypes: true })) {
49
51
  const path = `${directory}/${entry.name}`;
50
52
  if (entry.isDirectory()) files.push(...sourceFiles(path));
51
53
  else if (entry.isFile() && path.endsWith('.ts')) files.push(path);
@@ -53,18 +55,133 @@ function sourceFiles(directory) {
53
55
  return files;
54
56
  }
55
57
 
56
- function relativeStaticTypeScriptDependencyGraph(directory = 'src') {
57
- let ts;
58
+ function productionTypeScriptFiles() {
59
+ return [
60
+ ...sourceFiles('src'),
61
+ ...sourceFiles('packages'),
62
+ ...sourceFiles('adapters'),
63
+ ...sourceFiles('apps'),
64
+ ...sourceFiles('plugins'),
65
+ ].sort();
66
+ }
67
+
68
+ let typeScriptCompiler;
69
+ let typeScriptCompilerLoadAttempted = false;
70
+ function loadTypeScriptCompiler() {
71
+ if (typeScriptCompilerLoadAttempted) return typeScriptCompiler;
72
+ typeScriptCompilerLoadAttempted = true;
58
73
  try {
59
- ts = createRequire(import.meta.url)('typescript');
74
+ typeScriptCompiler = createRequire(import.meta.url)('typescript');
60
75
  } catch (error) {
61
- failures.push(`TypeScript dependency is required for architecture import-cycle analysis: ${error instanceof Error ? error.message : String(error)}`);
62
- return new Map();
76
+ failures.push(`TypeScript dependency is required for architecture import analysis: ${error instanceof Error ? error.message : String(error)}`);
63
77
  }
78
+ return typeScriptCompiler;
79
+ }
64
80
 
65
- const files = sourceFiles(directory).sort();
66
- const known = new Set(files);
67
- const graph = new Map(files.map((path) => [path, new Set()]));
81
+ const WORK_LIFECYCLE_PATCH_FIELDS = new Set(['status', 'phase', 'dispatchState', 'evidenceState', 'workKind']);
82
+
83
+ function unwrapTypeScriptExpression(ts, node) {
84
+ let current = node;
85
+ while (ts.isParenthesizedExpression(current)
86
+ || ts.isAsExpression(current)
87
+ || ts.isTypeAssertionExpression(current)
88
+ || ts.isNonNullExpression(current)
89
+ || (typeof ts.isSatisfiesExpression === 'function' && ts.isSatisfiesExpression(current))) {
90
+ current = current.expression;
91
+ }
92
+ return current;
93
+ }
94
+
95
+ function staticTypeScriptPropertyName(ts, name) {
96
+ if (ts.isIdentifier(name) || ts.isStringLiteralLike(name) || ts.isNumericLiteral(name)) return name.text;
97
+ if (ts.isComputedPropertyName(name) && ts.isStringLiteralLike(name.expression)) return name.expression.text;
98
+ return undefined;
99
+ }
100
+
101
+ function inlineWorkLifecyclePatchFields(ts, node) {
102
+ const expression = unwrapTypeScriptExpression(ts, node);
103
+ if (!ts.isObjectLiteralExpression(expression)) return [];
104
+ const fields = new Set();
105
+ for (const property of expression.properties) {
106
+ if (ts.isSpreadAssignment(property)) {
107
+ for (const field of inlineWorkLifecyclePatchFields(ts, property.expression)) fields.add(field);
108
+ continue;
109
+ }
110
+ if (!(ts.isPropertyAssignment(property)
111
+ || ts.isShorthandPropertyAssignment(property)
112
+ || ts.isMethodDeclaration(property)
113
+ || ts.isGetAccessorDeclaration(property)
114
+ || ts.isSetAccessorDeclaration(property))) continue;
115
+ const name = staticTypeScriptPropertyName(ts, property.name);
116
+ if (name && WORK_LIFECYCLE_PATCH_FIELDS.has(name)) fields.add(name);
117
+ }
118
+ return [...fields].sort();
119
+ }
120
+
121
+ function genericWorkLifecycleMutationRecords(files) {
122
+ const ts = loadTypeScriptCompiler();
123
+ if (!ts) return [];
124
+ const records = [];
125
+ for (const path of [...files].sort()) {
126
+ const sourceFile = ts.createSourceFile(path, text(path), ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
127
+ function visit(node) {
128
+ if (ts.isCallExpression(node) && node.arguments.length >= 3) {
129
+ const callee = node.expression;
130
+ const callName = ts.isIdentifier(callee)
131
+ ? callee.text
132
+ : ts.isPropertyAccessExpression(callee)
133
+ ? callee.name.text
134
+ : undefined;
135
+ if (callName === 'updateWorkContract') {
136
+ const fields = inlineWorkLifecyclePatchFields(ts, node.arguments[2]);
137
+ if (fields.length > 0) {
138
+ const { line } = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile));
139
+ records.push({ path, line: line + 1, fields });
140
+ }
141
+ }
142
+ }
143
+ ts.forEachChild(node, visit);
144
+ }
145
+ visit(sourceFile);
146
+ }
147
+ return records;
148
+ }
149
+
150
+ function staticTypeScriptImportRecords(files) {
151
+ const ts = loadTypeScriptCompiler();
152
+ if (!ts) return [];
153
+ const records = [];
154
+ for (const path of [...files].sort()) {
155
+ const sourceFile = ts.createSourceFile(path, text(path), ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
156
+ function visit(node) {
157
+ let specifier;
158
+ if ((ts.isImportDeclaration(node) || ts.isExportDeclaration(node))
159
+ && node.moduleSpecifier
160
+ && ts.isStringLiteralLike(node.moduleSpecifier)) {
161
+ specifier = node.moduleSpecifier.text;
162
+ } else if (ts.isImportEqualsDeclaration(node)
163
+ && ts.isExternalModuleReference(node.moduleReference)
164
+ && node.moduleReference.expression
165
+ && ts.isStringLiteralLike(node.moduleReference.expression)) {
166
+ specifier = node.moduleReference.expression.text;
167
+ } else if (ts.isCallExpression(node)
168
+ && node.expression.kind === ts.SyntaxKind.ImportKeyword
169
+ && node.arguments.length === 1
170
+ && ts.isStringLiteralLike(node.arguments[0])) {
171
+ specifier = node.arguments[0].text;
172
+ }
173
+ if (specifier) records.push({ from: path, specifier });
174
+ ts.forEachChild(node, visit);
175
+ }
176
+ visit(sourceFile);
177
+ }
178
+ return records;
179
+ }
180
+
181
+ function staticTypeScriptDependencyGraph(files) {
182
+ const orderedFiles = [...files].sort();
183
+ const known = new Set(orderedFiles);
184
+ const graph = new Map(orderedFiles.map((path) => [path, new Set()]));
68
185
 
69
186
  function resolveTypeScriptImport(fromPath, specifier) {
70
187
  if (!specifier.startsWith('.')) return undefined;
@@ -79,28 +196,384 @@ function relativeStaticTypeScriptDependencyGraph(directory = 'src') {
79
196
  return candidates.find((candidate) => known.has(candidate));
80
197
  }
81
198
 
82
- for (const path of files) {
83
- const sourceFile = ts.createSourceFile(path, text(path), ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
84
- for (const statement of sourceFile.statements) {
85
- let specifier;
86
- if ((ts.isImportDeclaration(statement) || ts.isExportDeclaration(statement))
87
- && statement.moduleSpecifier
88
- && ts.isStringLiteralLike(statement.moduleSpecifier)) {
89
- specifier = statement.moduleSpecifier.text;
90
- } else if (ts.isImportEqualsDeclaration(statement)
91
- && ts.isExternalModuleReference(statement.moduleReference)
92
- && statement.moduleReference.expression
93
- && ts.isStringLiteralLike(statement.moduleReference.expression)) {
94
- specifier = statement.moduleReference.expression.text;
199
+ for (const { from, specifier } of staticTypeScriptImportRecords(orderedFiles)) {
200
+ const target = resolveTypeScriptImport(from, specifier);
201
+ if (target) graph.get(from).add(target);
202
+ }
203
+ return graph;
204
+ }
205
+
206
+ function relativeStaticTypeScriptDependencyGraph(directory = 'src') {
207
+ return staticTypeScriptDependencyGraph(sourceFiles(directory));
208
+ }
209
+
210
+ function productionStaticTypeScriptDependencyGraph() {
211
+ return staticTypeScriptDependencyGraph(productionTypeScriptFiles());
212
+ }
213
+
214
+ function dependencyEdges(graph) {
215
+ const edges = [];
216
+ for (const [from, targets] of graph) {
217
+ for (const to of targets) edges.push(`${from} -> ${to}`);
218
+ }
219
+ return edges.sort();
220
+ }
221
+
222
+ function edgeSet(graph, predicate) {
223
+ return new Set(dependencyEdges(graph).filter((edge) => predicate(edge)));
224
+ }
225
+
226
+ function edgeParts(edge) {
227
+ const separator = edge.indexOf(' -> ');
228
+ return { from: edge.slice(0, separator), to: edge.slice(separator + 4) };
229
+ }
230
+
231
+ function architectureRoot(path) {
232
+ if (path.startsWith('packages/kernel/')) return path.split('/').slice(0, 3).join('/');
233
+ if (path.startsWith('adapters/')) return path.split('/').slice(0, 2).join('/');
234
+ if (path.startsWith('apps/')) return path.split('/').slice(0, 2).join('/');
235
+ if (path.startsWith('plugins/')) return path.split('/').slice(0, 2).join('/');
236
+ if (path.startsWith('src/runtime/root/')) return 'src/runtime/root';
237
+ return path.startsWith('src/') ? 'src' : path.split('/')[0];
238
+ }
239
+
240
+ function requireExactShrinkingDebt(label, actual, allowed) {
241
+ for (const edge of actual) {
242
+ if (!allowed.has(edge)) failures.push(`${label} introduced forbidden dependency: ${edge}`);
243
+ }
244
+ for (const edge of allowed) {
245
+ if (!actual.has(edge)) failures.push(`${label} allowlist contains retired dependency; remove it so the debt ledger only shrinks: ${edge}`);
246
+ }
247
+ }
248
+
249
+ function requireExactShrinkingInventory(label, actual, allowed) {
250
+ for (const entry of actual) {
251
+ if (!allowed.has(entry)) failures.push(`${label} introduced forbidden entry: ${entry}`);
252
+ }
253
+ for (const entry of allowed) {
254
+ if (!actual.has(entry)) failures.push(`${label} allowlist contains retired entry; remove it so the debt ledger only shrinks: ${entry}`);
255
+ }
256
+ }
257
+
258
+ // Stage 4 boundary: rh_work is an ABI/translation adapter. Durable lifecycle
259
+ // ownership stays in Kernel/application services and physical WorkHandle state
260
+ // may not be persisted from the MCP adapter.
261
+ requireText('adapters/mcp/runtime-gateway/runtime-tools.ts', "if (name === 'rh_work') return callWorkAdapter(ctx, args);");
262
+ requireText('adapters/mcp/runtime-gateway/controller-authority-adapter.ts', 'controllerTerminalizationAuthorityForInvocation');
263
+ requireText('adapters/mcp/runtime-gateway/controller-authority-adapter.ts', 'assertControllerRoundInvocationAuthority');
264
+ forbid('adapters/mcp/runtime-gateway/work-adapter.ts', /\b(?:transitionWorkHandle|writeWorkHandle|markWorkHandleFailed)\s*\(/, 'rh_work adapter must not persist WorkHandle lifecycle state; use the canonical completion/finalization authority');
265
+ forbid('adapters/mcp/runtime-gateway/work-adapter.ts', /control-plane\/facade\/work-contract-store|kernel\/work\/infrastructure/, 'rh_work adapter must consume canonical Work application/API authority, not persistence infrastructure');
266
+ forbid('adapters/mcp/runtime-gateway/work-adapter.ts', /\b(?:appendWorkEvidence|recordWorkCompletionReceipt|updateWorkContract)\s*\(/, 'rh_work adapter must not write Work lifecycle/evidence records directly');
267
+ forbid('adapters/mcp/runtime-gateway/work-adapter.ts', /\b(?:createRequirement|resumeRetainedCancelledWorkContract|acceptRequirementOutcome)\s*\(/, 'rh_work adapter must delegate Requirement and retained-Work lifecycle transitions to canonical application authorities');
268
+ forbid('adapters/mcp/runtime-gateway/work-adapter.ts', /function\s+(?:assert|evaluate|derive)[A-Za-z0-9_]*ImplementationReview/, 'rh_work adapter must not implement implementation-review policy authority');
269
+ forbid('adapters/mcp/runtime-gateway/work-adapter.ts', /repositoryGit(?:Commit|FinishWorkflow|MergeBranch|DeleteBranch|RebaseOnto)\s*\(/, 'rh_work adapter must delegate physical Git delivery to canonical Work finalization authority');
270
+
271
+ // #197 MCP mega-adapter decomposition. These are debt ledgers, not target
272
+ // architecture: entries may only disappear. New domain-authority imports or
273
+ // switch cases must be implemented in the owning domain adapter/application API,
274
+ // never added to runtime-tools/router while decomposition is in progress.
275
+ const MCP_GATEWAY_AUTHORITY_IMPORT_PATTERN = /(?:packages\/kernel\/|src\/runtime\/|src\/cli\/(?:repositories|editing)\/)/;
276
+
277
+ function gatewayAuthorityImportInventoryFromSources(sources, importPattern = MCP_GATEWAY_AUTHORITY_IMPORT_PATTERN) {
278
+ const ts = loadTypeScriptCompiler();
279
+ if (!ts) return new Set();
280
+ const records = new Set();
281
+ for (const { path, source } of sources) {
282
+ const sourceFile = ts.createSourceFile(path, source, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
283
+ function visit(node) {
284
+ if ((ts.isImportDeclaration(node) || ts.isExportDeclaration(node))
285
+ && node.moduleSpecifier
286
+ && ts.isStringLiteralLike(node.moduleSpecifier)
287
+ && importPattern.test(node.moduleSpecifier.text)) {
288
+ records.add(`${path}::${node.moduleSpecifier.text}`);
95
289
  }
96
- if (!specifier) continue;
97
- const target = resolveTypeScriptImport(path, specifier);
98
- if (target) graph.get(path).add(target);
290
+ ts.forEachChild(node, visit);
99
291
  }
292
+ visit(sourceFile);
100
293
  }
101
- return graph;
294
+ return records;
102
295
  }
103
296
 
297
+ function runtimeToolSwitchCaseInventory(source) {
298
+ const marker = 'export async function callRuntimeTool';
299
+ const start = source.indexOf(marker);
300
+ if (start < 0) return new Set();
301
+ return new Set([...source.slice(start).matchAll(/case\s+['"]([^'"]+)['"]\s*:/g)].map((match) => match[1]));
302
+ }
303
+
304
+ const MCP_RUNTIME_GATEWAY_AUTHORITY_IMPORT_DEBT = new Set([
305
+ 'adapters/mcp/runtime-gateway/router.ts::../../../src/cli/repositories/command-classifier',
306
+ 'adapters/mcp/runtime-gateway/router.ts::../../../src/runtime/diagnostics/process-facade',
307
+ 'adapters/mcp/runtime-gateway/router.ts::../../../src/runtime/execution/jobs/types',
308
+ 'adapters/mcp/runtime-gateway/router.ts::../../../src/runtime/execution/process-runtime',
309
+ 'adapters/mcp/runtime-gateway/router.ts::../../../src/runtime/execution/thin-harness',
310
+ 'adapters/mcp/runtime-gateway/runtime-tools.ts::../../../src/runtime/execution/process-runtime/check-result',
311
+ ]);
312
+
313
+ const MCP_RUNTIME_TOOLS_SWITCH_CASE_DEBT = new Set();
314
+
315
+ const mcpAdapterBoundaryFixture = process.env.FORGE_MCP_RUNTIME_ADAPTER_BOUNDARY_FIXTURE;
316
+ if (mcpAdapterBoundaryFixture) {
317
+ const fixture = JSON.parse(mcpAdapterBoundaryFixture);
318
+ const sources = Array.isArray(fixture.sources) ? fixture.sources : [];
319
+ requireExactShrinkingDebt(
320
+ 'MCP runtime adapter authority-import fixture debt',
321
+ gatewayAuthorityImportInventoryFromSources(sources),
322
+ new Set(Array.isArray(fixture.allowedImports) ? fixture.allowedImports : []),
323
+ );
324
+ const runtimeSource = sources.find((entry) => entry.path === 'adapters/mcp/runtime-gateway/runtime-tools.ts')?.source ?? '';
325
+ requireExactShrinkingInventory(
326
+ 'MCP runtime-tools switch-case fixture debt',
327
+ runtimeToolSwitchCaseInventory(runtimeSource),
328
+ new Set(Array.isArray(fixture.allowedCases) ? fixture.allowedCases : []),
329
+ );
330
+ if (failures.length) {
331
+ console.error('[mcp-runtime-adapter-boundary-guardrail] FAILED');
332
+ for (const failure of failures) console.error(`- ${failure}`);
333
+ process.exit(1);
334
+ }
335
+ console.log('[mcp-runtime-adapter-boundary-guardrail] OK');
336
+ process.exit(0);
337
+ }
338
+
339
+ requireExactShrinkingDebt(
340
+ 'MCP runtime mega-adapter direct domain-authority import debt',
341
+ gatewayAuthorityImportInventoryFromSources([
342
+ { path: 'adapters/mcp/runtime-gateway/runtime-tools.ts', source: text('adapters/mcp/runtime-gateway/runtime-tools.ts') },
343
+ { path: 'adapters/mcp/runtime-gateway/router.ts', source: text('adapters/mcp/runtime-gateway/router.ts') },
344
+ ]),
345
+ MCP_RUNTIME_GATEWAY_AUTHORITY_IMPORT_DEBT,
346
+ );
347
+ requireExactShrinkingInventory(
348
+ 'MCP runtime-tools switch-case debt',
349
+ runtimeToolSwitchCaseInventory(text('adapters/mcp/runtime-gateway/runtime-tools.ts')),
350
+ MCP_RUNTIME_TOOLS_SWITCH_CASE_DEBT,
351
+ );
352
+
353
+ const MCP_PURE_TRANSPORT_FORBIDDEN_IMPORT_PATTERN = /(?:packages\/kernel\/|src\/runtime\/)/;
354
+ requireExactShrinkingDebt(
355
+ 'MCP pure transport adapter authority imports',
356
+ gatewayAuthorityImportInventoryFromSources([
357
+ { path: 'adapters/mcp/runtime-gateway/shared-adapter.ts', source: text('adapters/mcp/runtime-gateway/shared-adapter.ts') },
358
+ { path: 'adapters/mcp/runtime-gateway/result-adapter.ts', source: text('adapters/mcp/runtime-gateway/result-adapter.ts') },
359
+ ], MCP_PURE_TRANSPORT_FORBIDDEN_IMPORT_PATTERN),
360
+ new Set(),
361
+ );
362
+
363
+ const FROZEN_CAPABILITY_PREFIX_FILES = [
364
+ 'adapters/mcp/runtime-gateway/runtime-tools.ts',
365
+ 'adapters/mcp/runtime-gateway/work-adapter.ts',
366
+ 'adapters/mcp/controller-round-compatibility.ts',
367
+ 'adapters/mcp/frozen-client-semantic-compatibility.ts',
368
+ ];
369
+ const CANONICAL_FROZEN_SEMANTIC_PREFIX = 'semantic.v1:';
370
+
371
+ function frozenCapabilityPrefixRecordsFromSources(sources) {
372
+ const records = new Set();
373
+ const protocolLiteral = /(['"`])([a-z][a-z0-9_-]*(?:\.[a-z0-9_-]+)+:)\1/g;
374
+ for (const { path, source } of sources) {
375
+ for (const match of source.matchAll(protocolLiteral)) {
376
+ const prefix = match[2];
377
+ if (prefix === CANONICAL_FROZEN_SEMANTIC_PREFIX) continue;
378
+ records.add(`${path}::${prefix}`);
379
+ }
380
+ }
381
+ return records;
382
+ }
383
+
384
+ const capabilityPrefixFixture = process.env.FORGE_CAPABILITY_PREFIX_GUARDRAIL_FIXTURE;
385
+ if (capabilityPrefixFixture) {
386
+ const fixture = JSON.parse(capabilityPrefixFixture);
387
+ const actual = frozenCapabilityPrefixRecordsFromSources(Array.isArray(fixture.sources) ? fixture.sources : []);
388
+ const allowed = new Set(Array.isArray(fixture.allowed) ? fixture.allowed : []);
389
+ requireExactShrinkingInventory('frozen capability prefix fixture debt', actual, allowed);
390
+ if (failures.length) {
391
+ console.error('[frozen-capability-prefix-guardrail] FAILED');
392
+ for (const failure of failures) console.error(`- ${failure}`);
393
+ process.exit(1);
394
+ }
395
+ console.log(`[frozen-capability-prefix-guardrail] OK (${actual.size} debt entries)`);
396
+ process.exit(0);
397
+ }
398
+
399
+ const LEGACY_FROZEN_CAPABILITY_PREFIX_DEBT = new Set([
400
+ 'adapters/mcp/runtime-gateway/work-adapter.ts::controller.authority.recover:',
401
+ 'adapters/mcp/runtime-gateway/work-adapter.ts::controller.provider.recover:',
402
+ 'adapters/mcp/runtime-gateway/work-adapter.ts::plan.step.retry:',
403
+ 'adapters/mcp/runtime-gateway/work-adapter.ts::schedule.delete:',
404
+ 'adapters/mcp/runtime-gateway/work-adapter.ts::work.review:',
405
+ 'adapters/mcp/controller-round-compatibility.ts::controller.disposition:',
406
+ 'adapters/mcp/controller-round-compatibility.ts::controller.round:',
407
+ 'adapters/mcp/controller-round-compatibility.ts::plan.obligations.v1:',
408
+ ]);
409
+ requireExactShrinkingInventory(
410
+ 'legacy frozen capability prefix debt',
411
+ frozenCapabilityPrefixRecordsFromSources(FROZEN_CAPABILITY_PREFIX_FILES.map((path) => ({ path, source: text(path) }))),
412
+ LEGACY_FROZEN_CAPABILITY_PREFIX_DEBT,
413
+ );
414
+
415
+ const SEMANTIC_AUTHORITY_CRITICAL_ROOTS = [
416
+ 'packages/kernel',
417
+ 'src/runtime/control-plane',
418
+ 'src/runtime/execution',
419
+ 'adapters/mcp/runtime-gateway',
420
+ 'src/cli/local-bridge',
421
+ ];
422
+ const HUMAN_READABLE_SEMANTIC_FIELDS = new Set(['message', 'reason', 'description', 'checkId', 'check_id']);
423
+ const HUMAN_READABLE_STRING_MATCH_METHODS = new Set(['includes', 'startsWith', 'endsWith', 'match', 'search']);
424
+
425
+ function humanReadableSemanticExpression(ts, node) {
426
+ if (ts.isIdentifier(node)) return HUMAN_READABLE_SEMANTIC_FIELDS.has(node.text);
427
+ if (ts.isPropertyAccessExpression(node)) return HUMAN_READABLE_SEMANTIC_FIELDS.has(node.name.text);
428
+ if (ts.isElementAccessExpression(node)
429
+ && node.argumentExpression
430
+ && ts.isStringLiteralLike(node.argumentExpression)) {
431
+ return HUMAN_READABLE_SEMANTIC_FIELDS.has(node.argumentExpression.text);
432
+ }
433
+ if (ts.isParenthesizedExpression(node)
434
+ || ts.isAsExpression(node)
435
+ || ts.isTypeAssertionExpression(node)
436
+ || ts.isNonNullExpression(node)) {
437
+ return humanReadableSemanticExpression(ts, node.expression);
438
+ }
439
+ if (ts.isConditionalExpression(node)) {
440
+ return humanReadableSemanticExpression(ts, node.whenTrue)
441
+ || humanReadableSemanticExpression(ts, node.whenFalse);
442
+ }
443
+ if (ts.isCallExpression(node)
444
+ && ts.isPropertyAccessExpression(node.expression)
445
+ && ['trim', 'toLowerCase', 'toUpperCase'].includes(node.expression.name.text)) {
446
+ return humanReadableSemanticExpression(ts, node.expression.expression);
447
+ }
448
+ return false;
449
+ }
450
+
451
+ function isHumanReadableSemanticMatcherCall(ts, node) {
452
+ if (!ts.isCallExpression(node) || !ts.isPropertyAccessExpression(node.expression)) return false;
453
+ const method = node.expression.name.text;
454
+ if (HUMAN_READABLE_STRING_MATCH_METHODS.has(method)
455
+ && humanReadableSemanticExpression(ts, node.expression.expression)) return true;
456
+ return method === 'test' && node.arguments.some((argument) => humanReadableSemanticExpression(ts, argument));
457
+ }
458
+
459
+ function semanticAuthorityStringMatchRecordsFromSources(sources) {
460
+ const ts = loadTypeScriptCompiler();
461
+ if (!ts) return new Set();
462
+ const records = new Set();
463
+ for (const { path, source } of [...sources].sort((left, right) => left.path.localeCompare(right.path))) {
464
+ const sourceFile = ts.createSourceFile(path, source, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
465
+ function collectCondition(expression) {
466
+ function visitCondition(node) {
467
+ if (isHumanReadableSemanticMatcherCall(ts, node)) {
468
+ records.add(`${path}::${node.getText(sourceFile).replace(/\s+/g, ' ').trim()}`);
469
+ }
470
+ ts.forEachChild(node, visitCondition);
471
+ }
472
+ visitCondition(expression);
473
+ }
474
+ function visit(node) {
475
+ if (ts.isIfStatement(node) || ts.isWhileStatement(node) || ts.isDoStatement(node)) collectCondition(node.expression);
476
+ else if (ts.isConditionalExpression(node)) collectCondition(node.condition);
477
+ else if (ts.isForStatement(node) && node.condition) collectCondition(node.condition);
478
+ ts.forEachChild(node, visit);
479
+ }
480
+ visit(sourceFile);
481
+ }
482
+ return records;
483
+ }
484
+
485
+ function semanticAuthorityProductionStringMatchRecords() {
486
+ const paths = SEMANTIC_AUTHORITY_CRITICAL_ROOTS.flatMap((directory) => sourceFiles(directory));
487
+ return semanticAuthorityStringMatchRecordsFromSources(paths.map((path) => ({ path, source: text(path) })));
488
+ }
489
+
490
+ const LEGACY_INTERACTION_AUTHORITY_OWNER_DECLARATION = /\b(?:class|interface|type|function|const)\s+\w*(?:Browser|Desktop)\w*(?:Authority|Persistence)\b/;
491
+ function legacyInteractionAuthorityOwnerRecordsFromSources(sources) {
492
+ const records = new Set();
493
+ for (const { path, source } of sources) {
494
+ for (const line of String(source).split('\n')) {
495
+ if (LEGACY_INTERACTION_AUTHORITY_OWNER_DECLARATION.test(line)) records.add(`${path}::${line.trim()}`);
496
+ }
497
+ }
498
+ return records;
499
+ }
500
+
501
+ const interactionAuthorityGuardrailFixture = process.env.FORGE_INTERACTION_AUTHORITY_GUARDRAIL_FIXTURE;
502
+ if (interactionAuthorityGuardrailFixture) {
503
+ const fixture = JSON.parse(interactionAuthorityGuardrailFixture);
504
+ const actual = legacyInteractionAuthorityOwnerRecordsFromSources(Array.isArray(fixture.sources) ? fixture.sources : []);
505
+ if (actual.size > 0) {
506
+ console.error('[interaction-authority-guardrail] FAILED');
507
+ for (const record of actual) console.error(`- Browser/Desktop durable interaction authority must live only in Computer target authority: ${record}`);
508
+ process.exit(1);
509
+ }
510
+ console.log('[interaction-authority-guardrail] OK');
511
+ process.exit(0);
512
+ }
513
+
514
+ const semanticAuthorityGuardrailFixture = process.env.FORGE_SEMANTIC_AUTHORITY_GUARDRAIL_FIXTURE;
515
+ if (semanticAuthorityGuardrailFixture) {
516
+ const fixture = JSON.parse(semanticAuthorityGuardrailFixture);
517
+ const actual = semanticAuthorityStringMatchRecordsFromSources(Array.isArray(fixture.sources) ? fixture.sources : []);
518
+ const allowed = new Set(Array.isArray(fixture.allowed) ? fixture.allowed : []);
519
+ requireExactShrinkingInventory('semantic authority fixture debt', actual, allowed);
520
+ if (failures.length) {
521
+ console.error('[semantic-authority-guardrail] FAILED');
522
+ for (const failure of failures) console.error(`- ${failure}`);
523
+ process.exit(1);
524
+ }
525
+ console.log(`[semantic-authority-guardrail] OK (${actual.size} debt entries)`);
526
+ process.exit(0);
527
+ }
528
+
529
+ const SEMANTIC_STRING_AUTHORITY_DEBT = new Set([
530
+ `adapters/mcp/runtime-gateway/execution-tools.ts::message.includes(':')`,
531
+ `adapters/mcp/runtime-gateway/process-tools.ts::message.includes(':')`,
532
+ `adapters/mcp/runtime-gateway/context-adapter.ts::error.message.startsWith('PLUGIN_NOT_FOUND:')`,
533
+ `packages/kernel/controller/domain/controller-round-transition-policy.ts::reason.startsWith('consecutive_failures:')`,
534
+ `packages/kernel/controller/domain/controller-round-transition-policy.ts::reason.startsWith('repeated_state:')`,
535
+ `packages/kernel/controller/domain/controller-round-transition-policy.ts::reason.startsWith('round_budget_exhausted:')`,
536
+ `packages/kernel/scheduler/application/continuation-service.ts::error.message.startsWith('CONTROLLER_RELAY_ROUND_ALREADY_OPEN:')`,
537
+ `src/cli/local-bridge/facade-api.ts::selection.reason.includes('Small')`,
538
+ `src/cli/local-bridge/facade-api.ts::selection.reason.includes('small')`,
539
+ `src/cli/local-bridge/job-store.ts::message.startsWith(\"LOCAL_JOB_ID_REQUIRED:\")`,
540
+ `src/cli/local-bridge/job-store.ts::message.startsWith(\"LOCAL_JOB_PATH_INVALID:\")`,
541
+ `src/cli/local-bridge/server.ts::message.startsWith(\"REPOSITORY_SELF_PROTECTED\")`,
542
+ `src/runtime/control-plane/execution/work-execution-support.ts::reason.includes('infrastructure')`,
543
+ `src/runtime/control-plane/execution/work-execution-support.ts::reason.includes('terminal')`,
544
+ `src/runtime/control-plane/execution/work-execution-support.ts::reason.includes('timed out')`,
545
+ `src/runtime/control-plane/execution/work-execution-support.ts::reason.includes('unavailable')`,
546
+ `src/runtime/control-plane/execution/work-head-settlement.ts::error.message.includes('CONTROL_PLANE_REVISION_CONFLICT')`,
547
+ `src/runtime/control-plane/facade/requirement-authority.ts::error.message.startsWith('REQUIREMENT_ALREADY_EXISTS:')`,
548
+ `src/runtime/control-plane/global-scheduler/reconciliation.ts::message.includes(':')`,
549
+ `src/runtime/control-plane/global-scheduler/reconciliation.ts::message.startsWith('WRITER_FENCED:')`,
550
+ `src/runtime/control-plane/global-scheduler/scheduler.ts::error.message.startsWith('LOCK_HELD:')`,
551
+ `src/runtime/control-plane/launcher/chatgpt-work-continuation.ts::error.message.includes(':')`,
552
+ `src/runtime/control-plane/persistence/sqlite-store.ts::(error instanceof Error ? error.message : String(error)).startsWith('CONTROL_PLANE_SQLITE_BUSY:')`,
553
+ `src/runtime/control-plane/persistence/sqlite-store.ts::/database is locked|SQLITE_BUSY/i.test(message)`,
554
+ `src/runtime/control-plane/persistence/sqlite-store.ts::message.startsWith('CONTROL_PLANE_')`,
555
+ `src/runtime/control-plane/persistence/sqlite-store.ts::message.startsWith('CONTROL_PLANE_SQLITE_CORRUPT:')`,
556
+ `src/runtime/execution/jobs/store.ts::error.message.startsWith('WRITER_FENCED:')`,
557
+ `src/runtime/execution/process-runtime/lightweight-managed.ts::error.message.startsWith('PROCESS_REQUEST_CONFLICT:')`,
558
+ `src/runtime/execution/process-runtime/process-runner-entry.ts::message.startsWith('PROCESS_RUNNER_ALREADY_STARTED:')`,
559
+ `src/runtime/execution/process-runtime/process-runner-entry.ts::message.startsWith('PROCESS_RUNNER_RECEIPT_CORRUPT:')`,
560
+ `src/runtime/execution/thin-harness/fast-executor.ts::message.includes(':')`,
561
+ `src/runtime/execution/thin-harness/fast-executor.ts::message.includes('\\0')`,
562
+ `src/runtime/execution/thin-harness/fingerprint-worker.ts::error.message.startsWith('SNAPSHOT_BUDGET')`,
563
+ `src/runtime/execution/thin-harness/fingerprint-worker.ts::message.startsWith('CANCELLED')`,
564
+ `src/runtime/execution/thin-harness/fingerprint-worker.ts::message.startsWith('SNAPSHOT_BUDGET')`,
565
+ `src/runtime/execution/thin-harness/fingerprint-worker.ts::message.startsWith('SNAPSHOT_TOO_DIRTY')`,
566
+ `src/runtime/execution/thin-harness/fingerprint-worker.ts::message.startsWith('SNAPSHOT_WORKER_TIMEOUT')`,
567
+ `src/runtime/execution/workers/executor.ts::message.startsWith('LEGACY_JOB_TIMEOUT:')`,
568
+ ]);
569
+ requireExactShrinkingInventory(
570
+ 'human-readable semantic authority debt',
571
+ semanticAuthorityProductionStringMatchRecords(),
572
+ SEMANTIC_STRING_AUTHORITY_DEBT,
573
+ );
574
+
575
+ // Kernel V2 B7 graph analysis. Legacy boundary debt below is exact and must only shrink.
576
+ // Inventory is derived from the production graph before the gate is activated.
104
577
  function stronglyConnectedComponents(graph) {
105
578
  let index = 0;
106
579
  const indices = new Map();
@@ -143,7 +616,7 @@ function stronglyConnectedComponents(graph) {
143
616
  }
144
617
 
145
618
  function requireAcyclicProductionTypeScript() {
146
- const graph = relativeStaticTypeScriptDependencyGraph('src');
619
+ const graph = productionStaticTypeScriptDependencyGraph();
147
620
  const cyclic = stronglyConnectedComponents(graph).filter((component) =>
148
621
  component.length > 1 || (component.length === 1 && graph.get(component[0])?.has(component[0])),
149
622
  );
@@ -159,7 +632,7 @@ const architectureRootMarkdown = readdirSync(resolve(root, 'docs/architecture'),
159
632
  .sort();
160
633
  for (const name of architectureRootMarkdown) {
161
634
  if (!allowedArchitectureRootMarkdown.has(name)) {
162
- failures.push(`docs/architecture/${name} must be archived under docs/architecture/history/ instead of acting as parallel root architecture authority`);
635
+ failures.push(`docs/architecture/${name} must be merged into CURRENT.md/EVOLUTION.md or deleted instead of acting as parallel root architecture authority; Git history is the archive`);
163
636
  }
164
637
  }
165
638
 
@@ -170,7 +643,7 @@ for (const path of ['README.md', 'docs/ROADMAP.md', 'docs/architecture/CURRENT.m
170
643
  }
171
644
 
172
645
  const required = [
173
- 'src/runtime/gateway/mcp/router.ts',
646
+ 'adapters/mcp/runtime-gateway/router.ts',
174
647
  'src/cli/agent-jobs/executable-resolver.ts',
175
648
  'src/runtime/control-plane/global-scheduler/scheduler.ts',
176
649
  'src/runtime/control-plane/global-scheduler/config.ts',
@@ -203,6 +676,33 @@ const required = [
203
676
  'src/runtime/control-plane/execution/work-handle-authority.ts',
204
677
  'src/runtime/control-plane/execution/work-verification-context.ts',
205
678
  'src/runtime/control-plane/execution/work-verification-service.ts',
679
+ 'src/runtime/control-plane/execution/content-equivalent-commit-authority.ts',
680
+ 'src/runtime/control-plane/execution/implementation-review-content.ts',
681
+ 'packages/protocols/handoff/status.ts',
682
+ 'packages/kernel/work/domain/admission-policy.ts',
683
+ 'packages/kernel/work/domain/implementation-review.ts',
684
+ 'packages/kernel/work/domain/state-machine.ts',
685
+ 'packages/kernel/identity/domain/scope.ts',
686
+ 'packages/kernel/memory/domain/operational-prior.ts',
687
+ 'packages/kernel/memory/api/index.ts',
688
+ 'packages/kernel/memory/index.ts',
689
+ 'src/runtime/evidence/operational-shadow.ts',
690
+ 'src/runtime/control-plane/persistence/operational-prior-store.ts',
691
+ 'evaluation/lib/shadow-operational-prior.ts',
692
+ 'packages/kernel/work/domain/check-receipt.ts',
693
+ 'packages/kernel/work/domain/execution-snapshot.ts',
694
+ 'packages/kernel/work/domain/repository-completion-receipt.ts',
695
+ 'packages/kernel/work/domain/types.ts',
696
+ 'packages/kernel/work/application/work-service.ts',
697
+ 'packages/kernel/work/ports/work-contract-store.ts',
698
+ 'packages/kernel/work/infrastructure/work-contract-store.ts',
699
+ 'packages/kernel/work/api/index.ts',
700
+ 'packages/kernel/controller/domain/types.ts',
701
+ 'packages/kernel/controller/ports/controller-host.ts',
702
+ 'packages/kernel/controller/infrastructure/controller-session-store.ts',
703
+ 'packages/kernel/controller/application/controller-service.ts',
704
+ 'packages/kernel/controller/api/index.ts',
705
+ 'src/runtime/control-plane/facade/work-implementation-review.ts',
206
706
  'src/runtime/control-plane/execution/repository-work-attribution.ts',
207
707
  'src/runtime/control-plane/execution/work-completion-authority.ts',
208
708
  'src/runtime/control-plane/execution/work-evidence-policy.ts',
@@ -213,9 +713,21 @@ const required = [
213
713
  'src/runtime/control-plane/facade/work-state-machine.ts',
214
714
  'src/runtime/evidence/process-check-execution.ts',
215
715
  'src/runtime/context/semantic-navigation-contract.ts',
216
- 'src/cli/mcp/tool-contract.ts',
716
+ 'packages/protocols/mcp/tool-contract.ts',
717
+ 'packages/protocols/mcp/execution-context.ts',
217
718
  'src/cli/github/contracts.ts',
218
- 'src/runtime/gateway/mcp/runtime-tool-definitions.ts',
719
+ 'adapters/mcp/runtime-gateway/runtime-tool-definitions.ts',
720
+ 'adapters/mcp/server.ts',
721
+ 'adapters/mcp/oauth.ts',
722
+ 'adapters/mcp/multi-repository.ts',
723
+ 'adapters/mcp/toolset.ts',
724
+ 'adapters/mcp/tool-mapping/tools.ts',
725
+ 'adapters/mcp/tool-mapping/legacy-tool-service.ts',
726
+ 'adapters/mcp/tool-mapping/repository-tools.ts',
727
+ 'adapters/mcp/tool-mapping/access-tools.ts',
728
+ 'adapters/mcp/transports/http.ts',
729
+ 'adapters/mcp/transports/stdio.ts',
730
+ 'adapters/mcp/transports/session-registry.ts',
219
731
  'docs/architecture/CURRENT.md',
220
732
  'src/runtime/resources/leases/store.ts',
221
733
  'src/runtime/evidence/event-ledger.ts',
@@ -245,6 +757,42 @@ const required = [
245
757
  ];
246
758
  for (const path of required) text(path);
247
759
  requireAcyclicProductionTypeScript();
760
+ // Operational priors retain their bounded mechanical consumers. The accepted
761
+ // assistant-loop ADR adds semantic experience through its own API/adapter;
762
+ // neither consumer may move persistence or semantic acceptance into the reducer.
763
+ const stage7fMemoryImports = staticTypeScriptImportRecords(productionTypeScriptFiles());
764
+ const stage7fKernelMemoryConsumers = new Set([
765
+ 'src/runtime/evidence/operational-shadow.ts',
766
+ 'src/runtime/control-plane/persistence/operational-prior-store.ts',
767
+ 'src/runtime/context/assistant-context.ts',
768
+ 'src/runtime/context/assistant-work-context.ts',
769
+ 'src/runtime/control-plane/persistence/experience-store.ts',
770
+ 'src/cli/commands/brain-assistant.ts',
771
+ ]);
772
+ const stage7fOperationalStoreConsumers = new Set([
773
+ 'src/runtime/control-plane/execution/work-verification-service.ts',
774
+ 'src/runtime/execution/process-runtime/check-facade.ts',
775
+ ]);
776
+ for (const { from, specifier } of stage7fMemoryImports) {
777
+ if (from.startsWith('packages/kernel/memory/') && /(?:src\/runtime|control-plane|sqlite-store|context-plane)/.test(specifier)) {
778
+ failures.push(`Stage7F Kernel Memory must remain pure and persistence-free: ${from} -> ${specifier}`);
779
+ }
780
+ if (/packages\/kernel\/memory/.test(specifier)
781
+ && !stage7fKernelMemoryConsumers.has(from)
782
+ && !from.startsWith('packages/kernel/memory/')) {
783
+ failures.push(`Stage7F Memory has an unauthorized production consumer: ${from} -> ${specifier}`);
784
+ }
785
+ if (/operational-shadow/.test(specifier) && from !== 'src/runtime/control-plane/persistence/operational-prior-store.ts') {
786
+ failures.push(`Stage7F typed operational extractor may feed only the derived persistence adapter: ${from} -> ${specifier}`);
787
+ }
788
+ if (/operational-prior-store/.test(specifier) && !stage7fOperationalStoreConsumers.has(from)) {
789
+ failures.push(`Stage7F operational Memory store has an unauthorized active consumer: ${from} -> ${specifier}`);
790
+ }
791
+ }
792
+ forbid('src/runtime/control-plane/persistence/operational-prior-store.ts', /context-plane|brain|pks|requirement-authority|plan-contract|work-state-machine|approval|authorization/, 'Stage7F operational Memory must remain mechanical derived state only');
793
+ requireText('src/runtime/control-plane/persistence/operational-prior-store.ts', "OPERATIONAL_MEMORY_NAMESPACE = 'operational_memory_prior'");
794
+ requireText('src/runtime/control-plane/persistence/operational-prior-store.ts', 'resolveCheckCompletionGraceWaitMs');
795
+ requireText('src/runtime/execution/process-runtime/check-facade.ts', 'resolveCheckCompletionGraceWaitMs');
248
796
  for (const path of sourceFiles('src/runtime/control-plane')) {
249
797
  forbid(path, /(?:from\s+['"]|import\s*\(\s*['"])(?:\.\.\/)+gateway\//, 'control-plane domain/application code must not depend on Gateway transport');
250
798
  }
@@ -255,7 +803,7 @@ requireText('src/runtime/control-plane/execution/work-verification-service.ts',
255
803
  requireText('src/runtime/control-plane/execution/work-verification-service.ts', 'interactiveWaitMs: input.interactiveWaitMs ?? 0');
256
804
  requireText('src/runtime/control-plane/execution/work-verification-service.ts', 'checkContentRevision');
257
805
  requireText('src/runtime/control-plane/execution/work-verification-service.ts', 'observedGitHead');
258
- requireText('src/runtime/gateway/mcp/runtime-tools.ts', 'executeWorkVerification({');
806
+ requireText('adapters/mcp/runtime-gateway/work-adapter.ts', 'executeWorkVerification({');
259
807
  requireText('src/cli/local-bridge/facade-api.ts', 'executeWorkVerification({');
260
808
  forbid(
261
809
  'src/cli/local-bridge/facade-api.ts',
@@ -263,7 +811,7 @@ forbid(
263
811
  'Local Bridge Work verification must use the canonical persisted Work verification service',
264
812
  );
265
813
  forbid(
266
- 'src/runtime/gateway/mcp/runtime-tools.ts',
814
+ 'adapters/mcp/runtime-gateway/runtime-tools.ts',
267
815
  /function\s+classifyTerminalCheckEvidence\s*\(/,
268
816
  'terminal Check evidence classification belongs to Process Runtime, not the Gateway transport',
269
817
  );
@@ -272,6 +820,87 @@ forbid(
272
820
  /runControllerCheck\s*\(/,
273
821
  'route Work verification through persisted Process Runtime instead of synchronous check execution',
274
822
  );
823
+
824
+
825
+ // Kernel V2 B1/B2: Work lifecycle/review authority lives in packages/kernel/work.
826
+ // Historical facade modules are compatibility-only re-exports. Gateway/finalizer
827
+ // consume the Kernel API/domain instead of owning a parallel policy/store.
828
+ requireText('packages/kernel/work/domain/implementation-review.ts', 'assertImplementationReviewPreDeliveryBoundary');
829
+ requireText('packages/kernel/work/domain/implementation-review.ts', 'deriveImplementationReviewAcrossCommit');
830
+ requireText('packages/kernel/work/domain/state-machine.ts', 'validateWorkSemanticTransition');
831
+ requireText('packages/kernel/work/application/work-service.ts', 'transitionWorkContractPhase');
832
+ requireText('packages/kernel/work/api/index.ts', "export * from '../application/work-service'");
833
+ requireText('src/runtime/control-plane/execution/implementation-review-content.ts', 'implementationReviewContentFingerprint');
834
+ requireText('src/runtime/control-plane/execution/implementation-review-content.ts', 'implementationReviewIndexFingerprint');
835
+ requireText('packages/kernel/work/infrastructure/work-contract-store.ts', 'requestWorkImplementationReview');
836
+ requireText('packages/kernel/work/infrastructure/work-contract-store.ts', 'recordWorkImplementationReview');
837
+ requireText('packages/kernel/work/infrastructure/work-contract-store.ts', 'activateWorkContract');
838
+ requireText('packages/kernel/work/infrastructure/work-contract-store.ts', 'failWorkContract');
839
+ requireText('packages/kernel/work/infrastructure/work-contract-store.ts', 'cancelWorkContract');
840
+ requireText('packages/kernel/work/infrastructure/work-contract-store.ts', 'recordWorkEvidenceState');
841
+ requireText('packages/kernel/work/infrastructure/work-contract-store.ts', 'WORK_LIFECYCLE_REQUIRES_TRANSITION_API');
842
+ requireText('packages/kernel/work/infrastructure/work-contract-store.ts', 'work_contract_schema_v3_migrated');
843
+ forbid('packages/kernel/work/infrastructure/work-contract-store.ts', /phaseForStatusUpdate|dispatchStateForStatusUpdate/, 'Work status must not regain hidden phase/dispatch transition authority');
844
+ forbid('packages/kernel/work/infrastructure/work-contract-store.ts', /phaseEvidence:\s*legacyPhaseEvidence\(/, 'new Work construction must not reuse legacy migration phase-evidence inference');
845
+ requireText('src/runtime/control-plane/facade/work-contract-store.ts', '@deprecated Kernel V2 compatibility shim');
846
+ requireText('src/runtime/control-plane/facade/work-state-machine.ts', '@deprecated Kernel V2 compatibility shim');
847
+ requireText('src/runtime/control-plane/facade/work-implementation-review.ts', '@deprecated Kernel V2 compatibility shim');
848
+ requireText('packages/kernel/work/domain/types.ts', "['implementation', 'verification', 'review', 'delivery', 'cleanup']");
849
+ requireText('src/cli/repositories/selected-path-actions.ts', 'beforeCommitGuard');
850
+ requireText('src/runtime/control-plane/execution/direct-edit-work-completion.ts', 'prepareReviewedDirectEditWorkCommit');
851
+ requireText('src/runtime/control-plane/execution/direct-edit-work-completion.ts', 'completeReviewedDirectEditWorkAfterCommit');
852
+ requireText('src/runtime/control-plane/execution/direct-edit-work-completion.ts', 'transferReviewedWorkAuthorityAcrossContentEquivalentCommit');
853
+ requireText('src/runtime/control-plane/execution/work-verification-service.ts', 'planWorkVerificationAcrossContentEquivalentCommit');
854
+ forbid(
855
+ 'src/runtime/control-plane/execution/work-verification-service.ts',
856
+ /export\s+function\s+transferWorkVerificationAcrossContentEquivalentCommit\s*\(/,
857
+ 'content-equivalent verification planning must stay pure; authority persistence belongs to the atomic transfer owner',
858
+ );
859
+ requireText('src/runtime/control-plane/execution/content-equivalent-commit-authority.ts', 'transferReviewedWorkAuthorityAcrossContentEquivalentCommit');
860
+ requireText('src/runtime/control-plane/execution/content-equivalent-commit-authority.ts', 'recordContentEquivalentCommitAuthorityTransfer');
861
+ requireText('packages/kernel/work/infrastructure/work-contract-store.ts', 'recordContentEquivalentCommitAuthorityTransfer');
862
+ requireText('src/runtime/control-plane/execution/edit-validation-coordinator.ts', 'workId: session.workId');
863
+ requireText('src/runtime/control-plane/execution/edit-validation-coordinator.ts', 'verificationSnapshot: work ?');
864
+ requireText('src/runtime/control-plane/execution/work-finalization-service.ts', 'assertPhysicalImplementationReviewGate');
865
+ requireText('src/runtime/control-plane/execution/work-finalization-service.ts', 'assertPhysicalBranchCleanupImplementationReviewGate');
866
+ requireText('src/runtime/control-plane/execution/work-finalization-service.ts', 'transferReviewedWorkAuthorityAcrossContentEquivalentCommit');
867
+ requireText('adapters/mcp/runtime-gateway/runtime-tool-definitions.ts', 'review_decision');
868
+ requireText('adapters/mcp/runtime-gateway/runtime-tool-definitions.ts', 'implementation_review_findings');
869
+ requireText('adapters/mcp/runtime-gateway/work-adapter.ts', "operation === 'review'");
870
+ requireText('adapters/mcp/runtime-gateway/work-adapter.ts', 'implementationReviewContentFingerprint');
871
+ requireText('adapters/mcp/controller-round-compatibility.ts', "'review'");
872
+ requireText('packages/kernel/controller/infrastructure/controller-round-store.ts', 'readControllerRoundContextSnapshot');
873
+ const controllerRoundTransitionPolicyPath = 'packages/kernel/controller/domain/controller-round-transition-policy.ts';
874
+ if (existsSync(resolve(root, controllerRoundTransitionPolicyPath))) {
875
+ requireText(controllerRoundTransitionPolicyPath, "case 'provider_dispatch_outcome_unknown'");
876
+ requireText(controllerRoundTransitionPolicyPath, "blockedReason: 'provider_dispatch_outcome_unknown'");
877
+ forbid(
878
+ 'packages/kernel/controller/infrastructure/controller-round-store.ts',
879
+ /blockedReason\s*(?:===|:)\s*['"]provider_dispatch_outcome_unknown['"]/,
880
+ 'ControllerRound outcome-unknown lifecycle semantics must be owned by the canonical transition policy, not the store',
881
+ );
882
+ } else {
883
+ requireText('packages/kernel/controller/infrastructure/controller-round-store.ts', "blockedReason === 'provider_dispatch_outcome_unknown'");
884
+ requireText('packages/kernel/controller/infrastructure/controller-round-store.ts', "blockedReason: 'provider_dispatch_outcome_unknown'");
885
+ }
886
+ requireText('src/runtime/control-plane/launcher/chatgpt-work-continuation.ts', 'CHATGPT_AUTOMATION_SUBMISSION_OUTCOME_UNKNOWN');
887
+ requireText('adapters/chatgpt/controller-host.ts', 'CONTROLLER_HOST_PROVIDER_DISPATCH_OUTCOME_UNKNOWN');
888
+ requireText('packages/kernel/scheduler/application/continuation-service.ts', 'outcomeUnknown: providerDispatchOutcomeUnknown');
889
+ requireText('adapters/chatgpt/controller-round-host.ts', 'buildChatgptControllerRoundPrompt');
890
+ requireText('adapters/chatgpt/controller-round-settlement-store.ts', 'recordChatgptControllerRoundSettlement');
891
+ forbid('packages/kernel/controller/infrastructure/controller-round-store.ts', /browserSessionId|conversationUrl|recordControllerRoundTabSettlement|buildControllerRoundRelayPrompt|capability_id=/, 'Kernel ControllerRound must remain provider/transport neutral; ChatGPT/MCP rendering and settlement belong to adapters');
892
+ requireText('src/runtime/control-plane/global-scheduler/maintenance.ts', "controllerTypes: ['chatgpt']");
893
+ requireText('src/runtime/control-plane/facade/suggested-actions.ts', "case 'review'");
894
+ forbid(
895
+ 'adapters/mcp/runtime-gateway/runtime-tools.ts',
896
+ /function\s+(?:assert|evaluate|derive)[A-Za-z0-9_]*ImplementationReview/,
897
+ 'Gateway transport must not implement implementation-review policy authority',
898
+ );
899
+ forbid(
900
+ 'src/runtime/control-plane/execution/work-finalization-service.ts',
901
+ /function\s+deriveImplementationReviewAcrossCommit/,
902
+ 'Finalizer must consume the canonical Kernel Work review derivation instead of owning a second review authority',
903
+ );
275
904
  for (const adapter of [
276
905
  'src/cli/controller/work-mode.ts',
277
906
  'src/runtime/control-plane/facade/types.ts',
@@ -293,14 +922,140 @@ forbid(
293
922
  );
294
923
  requireText('src/runtime/control-plane/facade/goal-workloop.ts', "from '../execution/work-evidence-policy'");
295
924
  for (const path of sourceFiles('src/runtime/control-plane')) {
296
- if (path === 'src/runtime/control-plane/facade/work-contract-store.ts' || path === 'src/runtime/control-plane/execution/work-completion-authority.ts') continue;
925
+ if (path === 'src/runtime/control-plane/execution/work-completion-authority.ts') continue;
297
926
  forbid(
298
927
  path,
299
928
  /\brecordWorkCompletionReceipt\s*\(/,
300
929
  'route Work completion through the canonical work-completion-authority instead of writing terminal receipts directly',
301
930
  );
302
931
  }
932
+ // B2 ownership fence: production code may consume only the Kernel Work API/domain,
933
+ // never the retired facade store/state-machine or Kernel persistence implementation.
934
+ for (const path of sourceFiles('src')) {
935
+ forbid(path, /(?:from\s+['"]|import\s*\(\s*['"])[^'"]*(?:work-contract-store|work-state-machine|work-implementation-review)['"]/, 'production source must consume packages/kernel/work instead of retired Work facade authority');
936
+ forbid(path, /packages\/kernel\/work\/infrastructure\/work-contract-store/, 'production source must consume the Work application/API boundary, not persistence infrastructure');
937
+ }
938
+ for (const record of genericWorkLifecycleMutationRecords([...sourceFiles('src'), ...sourceFiles('adapters')])) {
939
+ failures.push(`${record.path}:${record.line} violates Work lifecycle authority: updateWorkContract patch owns ${record.fields.join(', ')}; use explicit Kernel lifecycle commands`);
940
+ }
941
+ forbid(
942
+ 'adapters/mcp/runtime-gateway/runtime-tools.ts',
943
+ /control-plane\/facade\/work-contract-store|kernel\/work\/infrastructure/,
944
+ 'MCP Gateway must not mutate Work through facade/persistence authority',
945
+ );
946
+ forbid(
947
+ 'adapters/mcp/runtime-gateway/runtime-tools.ts',
948
+ /\b(?:appendWorkEvidence|recordWorkCompletionReceipt)\s*\(/,
949
+ 'MCP Gateway must submit Work application commands instead of writing lifecycle/evidence records directly',
950
+ );
951
+ requireText('adapters/mcp/runtime-gateway/work-adapter.ts', 'completeRemoteEffectWorkFromProcessReceipt');
952
+ requireText('src/runtime/control-plane/execution/work-finalization-service.ts', 'packages/kernel/work/api/index');
953
+ requireText('src/runtime/control-plane/facade/goal-workloop.ts', 'packages/kernel/work/api/index');
954
+ requireText('packages/kernel/work/domain/types.ts', 'predecessorWorkId?: string');
955
+ requireText('src/runtime/control-plane/facade/goal-workloop.ts', 'PLAN_STEP_SEMANTIC_ACCEPTANCE_REQUIRED');
956
+ requireText('src/runtime/control-plane/facade/goal-workloop.ts', 'PLAN_SUCCESSOR_STEP_RESOLUTION_REQUIRED');
957
+ requireText('src/runtime/control-plane/facade/goal-workloop.ts', 'CONTINUATION_GOAL_COMPLETE');
958
+ requireText('src/runtime/control-plane/facade/goal-workloop.ts', "requestedBy ?? 'chatgpt') === 'scheduler'");
959
+ // V2 Goal authority convergence: lifecycle enums are canonical Kernel Goal
960
+ // domain facts; progression is a pure derived decision service and explicit
961
+ // Controller goal_complete is the Requirement semantic acceptance boundary.
962
+ requireText('packages/kernel/goal/domain/types.ts', 'export const REQUIREMENT_STATES');
963
+ requireText('packages/kernel/goal/domain/types.ts', 'export const PLAN_CONTRACT_STATUSES');
964
+ requireText('packages/kernel/goal/domain/types.ts', 'export const PLAN_STEP_STATUSES');
965
+ requireText('src/runtime/control-plane/persistence/requirement-store.ts', 'packages/kernel/goal/api/index');
966
+ requireText('src/runtime/control-plane/facade/types.ts', 'packages/kernel/goal/api/index');
967
+ requireText('packages/kernel/progression/domain/types.ts', "from '../../goal/api/index'");
968
+ requireText('packages/kernel/progression/domain/types.ts', "from '../../scheduler/api/index'");
969
+ forbid('packages/kernel/progression/domain/types.ts', /export type Progression(?:RequirementState|PlanStatus|PlanStepStatus)\s*=/, 'Goal progression must consume canonical Goal lifecycle types instead of copying status unions');
970
+ requireText('packages/kernel/progression/domain/types.ts', 'completionTargetRevision?: string');
971
+ requireText('packages/kernel/progression/application/projector.ts', 'PLAN_FINALIZED_REQUIRES_REQUIREMENT_ACCEPTANCE');
972
+ requireText('packages/kernel/progression/application/projector.ts', 'completionTargetRevision === snapshot.currentSourceRevision');
973
+ requireText('src/runtime/control-plane/facade/requirement-authority.ts', 'acceptRequirementOutcome');
974
+ requireText('src/runtime/control-plane/facade/requirement-authority.ts', 'REQUIREMENT_ACCEPTANCE_PLAN_INCOMPLETE');
975
+ requireText('src/runtime/control-plane/facade/requirement-authority.ts', 'completeRequirementGoal');
976
+ requireText('src/runtime/control-plane/facade/requirement-authority.ts', 'withPlanAdmissionLock');
977
+ requireText('src/runtime/control-plane/facade/plan-contract-store.ts', 'PLAN_REQUIREMENT_TERMINAL');
978
+ requireText('adapters/mcp/runtime-gateway/work-adapter.ts', 'completeRequirementGoal');
979
+ forbid('adapters/mcp/runtime-gateway/runtime-tools.ts', /\bacceptRequirementOutcome\s*\(/, 'MCP transport must delegate Requirement-bound goal completion to the canonical Goal application boundary');
980
+ requireText('adapters/mcp/runtime-gateway/work-adapter.ts', "disposition === 'goal_complete' && work.requirementId");
981
+ // B3 ControllerSession authority and provider-neutral host boundary.
982
+ requireText('packages/kernel/controller/domain/types.ts', 'export interface ControllerBinding');
983
+ requireText('packages/kernel/controller/domain/types.ts', 'export interface ControllerLease');
984
+ requireText('packages/kernel/controller/ports/controller-host.ts', 'export interface ControllerHost');
985
+ requireText('packages/kernel/controller/ports/controller-host.ts', 'resume(binding: ControllerBinding, roundContext: ControllerRoundContext)');
986
+ requireText('packages/kernel/controller/infrastructure/controller-session-store.ts', 'claimControllerSession');
987
+ requireText('packages/kernel/controller/infrastructure/controller-session-store.ts', 'releaseControllerSessionWithAuthority');
988
+ requireText('src/runtime/control-plane/facade/controller-session-store.ts', '@deprecated Kernel V2 compatibility shim');
989
+ forbid('packages/kernel/controller/index.ts', /infrastructure\//, 'Kernel module root must expose only its public API');
990
+ forbid('packages/kernel/controller/application/controller-service.ts', /export\s+\*\s+from\s+['"]\.\.\/infrastructure\//, 'Controller application façade must not wildcard-export infrastructure');
991
+ // B4 Scheduler continuation authority: Schedule owns occurrence state only;
992
+ // continuation resolves exact Work + retained ControllerSession + opaque ControllerBinding
993
+ // and dispatches exclusively through ControllerHost.resume.
994
+ requireText('packages/kernel/scheduler/domain/schedule.ts', 'export interface RepositorySchedule');
995
+ requireText('packages/kernel/scheduler/domain/schedule.ts', 'export interface ScheduleOccurrence');
996
+ requireText('packages/kernel/scheduler/infrastructure/schedule-store.ts', "'occurrences.json'");
997
+ requireText('packages/kernel/scheduler/infrastructure/schedule-store.ts', 'saveScheduleDecision');
998
+ requireText('packages/kernel/scheduler/application/schedule-service.ts', 'createSchedule');
999
+ requireText('packages/kernel/scheduler/api/index.ts', "../application/schedule-service");
1000
+ forbid('packages/kernel/scheduler/api/index.ts', /\.\.\/infrastructure\//, 'Scheduler public API must expose application/domain surfaces, not infrastructure stores');
1001
+ requireText('packages/kernel/scheduler/application/eligibility.ts', 'evaluateScheduleTriggerEligibility');
1002
+ requireText('packages/kernel/scheduler/application/eligibility.ts', 'evaluateScheduleOccurrenceAdmission');
1003
+ requireText('packages/kernel/scheduler/application/eligibility.ts', 'scheduleTriggerWindowKey');
1004
+ requireText('packages/kernel/scheduler/application/settlement.ts', 'applyScheduleFailure');
1005
+ requireText('packages/kernel/scheduler/application/settlement.ts', 'applyScheduleRetryableFailure');
1006
+ requireText('packages/kernel/scheduler/application/settlement.ts', 'settleScheduledExecution');
1007
+ requireText('src/runtime/workflow/schedules/settlement.ts', '@deprecated Kernel V2 compatibility shim');
1008
+ requireText('packages/kernel/scheduler/domain/continuation.ts', 'export interface ScheduledContinuationDispatch');
1009
+ requireText('packages/kernel/scheduler/application/continuation-service.ts', 'resumeScheduledControllerContinuation');
1010
+ requireText('packages/kernel/scheduler/application/continuation-service.ts', 'getRetainedControllerSession');
1011
+ requireText('packages/kernel/scheduler/application/continuation-service.ts', 'getControllerWorkBinding');
1012
+ requireText('packages/kernel/scheduler/application/continuation-service.ts', 'host.resume(bindingRecord.binding');
1013
+ forbid('packages/kernel/scheduler/application/continuation-service.ts', /SCHEDULE_CONTINUATION_SESSION_DRIFT/, 'Scheduler continuation must not treat replaceable ControllerSession transport ids as durable continuation identity');
1014
+ requireText('packages/kernel/scheduler/application/continuation-service.ts', 'SCHEDULE_CONTINUATION_OUTCOME_UNKNOWN');
1015
+ requireText('packages/kernel/scheduler/application/continuation-service.ts', 'scheduler_continuation_prepare');
1016
+ requireText('packages/kernel/scheduler/application/continuation-service.ts', 'scheduler_continuation_bind_round');
1017
+ requireText('src/runtime/root/scheduled-controller-composition.ts', 'controllerHostForScheduledBinding');
1018
+ requireMissing('adapters/scheduler/controller-binding.ts');
1019
+ requireText('adapters/chatgpt/controller-host.ts', 'createChatgptControllerHost');
1020
+ requireText('adapters/controller-process/controller-host.ts', 'createProcessControllerHost');
1021
+ requireText('src/runtime/workflow/schedules/engine.ts', 'resumeScheduledControllerContinuation');
1022
+ requireText('src/runtime/workflow/schedules/engine.ts', 'evaluateScheduleTriggerEligibility');
1023
+ requireText('src/runtime/workflow/schedules/engine.ts', 'evaluateScheduleOccurrenceAdmission');
1024
+ requireText('src/runtime/workflow/schedules/engine.ts', 'controller_session_id');
1025
+ requireText('src/runtime/workflow/schedules/engine.ts', 'controller_binding_id');
1026
+ requireText('src/runtime/workflow/schedules/store.ts', '@deprecated Kernel V2 compatibility shim');
1027
+ requireText('src/runtime/workflow/schedules/store.ts', 'packages/kernel/scheduler/api/index');
1028
+ forbid('src/runtime/workflow/schedules/store.ts', /scheduler\/infrastructure\//, 'legacy Schedule shim must route through the Kernel Scheduler public API');
1029
+ requireText('src/runtime/workflow/schedules/types.ts', '@deprecated Kernel V2 compatibility shim');
1030
+ for (const path of sourceFiles('packages/kernel/scheduler')) {
1031
+ forbid(path, /(?:from\s+['"]|import\s*\(\s*['"])[^'"]*adapters\//, 'Kernel Scheduler must not import provider adapters');
1032
+ forbid(path, /\b(?:runWorkChatgptContinuation|launchSuperController|getChatgptWorkConversationBinding)\b|\bbrowser_session_id\b|\bconversation_url\b|\blaunch_args\b/, 'Kernel Scheduler must not own provider transport or provider binding payload fields');
1033
+ }
1034
+ forbid('src/runtime/workflow/schedules/engine.ts', /\brunWorkChatgptContinuation\b|\blaunchSuperController\b/, 'Schedule execution must dispatch Controller continuation through Kernel Scheduler + ControllerHost, never launch providers directly');
1035
+ for (const path of sourceFiles('src')) {
1036
+ forbid(path, /(?:from\s+['"]|import\s*\(\s*['"])[^'"]*workflow\/schedules\/(?:store|types|settlement)['"]/, 'production source must consume packages/kernel/scheduler instead of retired Schedule store/types/settlement authority');
1037
+ }
1038
+ for (const path of sourceFiles('src')) {
1039
+ forbid(path, /(?:from\s+['"]|import\s*\(\s*['"])[^'"]*controller-session-store['"]/, 'production source must consume packages/kernel/controller instead of retired ControllerSession facade authority');
1040
+ }
1041
+ const B7_KERNEL_INTERNAL_COMPATIBILITY_SHIMS = new Set([
1042
+ 'src/runtime/control-plane/facade/controller-session-store.ts',
1043
+ 'src/runtime/control-plane/facade/controller-round-relay.ts',
1044
+ 'src/runtime/control-plane/facade/work-contract-store.ts',
1045
+ 'src/runtime/control-plane/facade/work-state-machine.ts',
1046
+ 'src/runtime/control-plane/facade/work-implementation-review.ts',
1047
+ 'src/runtime/control-plane/facade/types.ts',
1048
+ 'src/runtime/workflow/schedules/settlement.ts',
1049
+ 'src/runtime/workflow/schedules/types.ts',
1050
+ ]);
1051
+ for (const path of sourceFiles('src')) {
1052
+ if (B7_KERNEL_INTERNAL_COMPATIBILITY_SHIMS.has(path)) continue;
1053
+ forbid(path, /packages\/kernel\/[^'"/]+\/(?:domain|application|infrastructure)\//, 'active legacy Runtime code must consume Kernel public api/index surfaces; direct internals are compatibility-boundary-only');
1054
+ }
1055
+ requireText('src/runtime/control-plane/facade/types.ts', 'packages/kernel/work/domain/types');
1056
+ requireText('src/runtime/control-plane/facade/types.ts', 'packages/kernel/controller/domain/types');
303
1057
  requireText('src/runtime/control-plane/execution/work-finalization-service.ts', 'completeWorkWithReceipt(');
1058
+ requireText('adapters/mcp/runtime-gateway/execution-tools.ts', 'resetFinalizationStagesForRequest');
304
1059
  forbid(
305
1060
  'src/runtime/plugins/browser-handoff-host.ts',
306
1061
  /browser\/sessions|saveBrowserSession|writeBrowserSession|sessionPath/,
@@ -313,22 +1068,22 @@ forbid(
313
1068
  );
314
1069
  requireText('src/runtime/plugins/browser-runtime.ts', 'browserActionCanReplayAfterDispatch');
315
1070
  forbid(
316
- 'src/runtime/gateway/mcp/runtime-tools.ts',
1071
+ 'adapters/mcp/runtime-gateway/runtime-tools.ts',
317
1072
  /\b(?:createRequirement|resumeRetainedCancelledWorkContract)\s*\(/,
318
1073
  'keep Requirement admission and retained-cancelled Work lifecycle authority out of the MCP transport',
319
1074
  );
320
1075
  forbid(
321
- 'src/runtime/gateway/mcp/runtime-tools.ts',
1076
+ 'adapters/mcp/runtime-gateway/runtime-tools.ts',
322
1077
  /\b(?:updateWorkContract|writeWorkHandle)\s*\(/,
323
1078
  'keep WorkContract/WorkHandle persistence policy out of the MCP transport',
324
1079
  );
325
1080
  forbid(
326
- 'src/runtime/gateway/mcp/execution-tools.ts',
1081
+ 'adapters/mcp/runtime-gateway/execution-tools.ts',
327
1082
  /\bcreateWorkContract\s*\(/,
328
1083
  'route compatibility work preparation through canonical Work admission authority',
329
1084
  );
330
1085
  forbid(
331
- 'src/cli/mcp/legacy-tool-service.ts',
1086
+ 'adapters/mcp/tool-mapping/legacy-tool-service.ts',
332
1087
  /\bcreateWorkContract\s*\(/,
333
1088
  'keep the legacy MCP surface as translation over canonical Work admission authority',
334
1089
  );
@@ -368,10 +1123,10 @@ requireMissing('docs/architecture/transactional-adoption-planner.md');
368
1123
  requireMissing('docs/architecture/global-hook-runtime.md');
369
1124
  requireMissing('docs/architecture/ios-semantic-automation-provider-v2.md');
370
1125
  requireMissing('docs/architecture/chatgpt-handoff-facade.md');
371
- requireText('docs/architecture/history/global-hook-runtime.md', 'Status: **Historical Evidence — Not Runtime Authority**');
372
- requireText('docs/architecture/history/ios-semantic-automation-provider-v2.md', 'Status: **Historical Design Evidence — Not Runtime Authority**');
373
- requireText('docs/architecture/history/chatgpt-handoff-facade.md', 'Status: **Historical Design Rationale — Not Runtime Authority**');
374
- requireText('docs/architecture/history/README.md', 'Status: **Historical Evidence — Not Runtime Authority**');
1126
+ requireMissing('docs/architecture/history/global-hook-runtime.md');
1127
+ requireMissing('docs/architecture/history/ios-semantic-automation-provider-v2.md');
1128
+ requireMissing('docs/architecture/history/chatgpt-handoff-facade.md');
1129
+ requireMissing('docs/architecture/history/README.md');
375
1130
  requireMissing('docs/operations/20260802-requirement-portfolio-migration.md');
376
1131
  requireMissing('docs/runbooks/RELIABILITY-SESSION-PROTOCOL.md');
377
1132
  requireMissing('docs/architecture/decisions/20260718-mcp-session-lifecycle-and-ingress-isolation.md');
@@ -535,7 +1290,7 @@ forbid(
535
1290
  requireText('scripts/smoke-schedule-engine.ts', 'listHandoffItems');
536
1291
  requireText('scripts/smoke-schedule-engine.ts', 'listExecutionJobs');
537
1292
  requireText('scripts/smoke-schedule-engine.ts', "operation: 'runtime_maintenance_apply'");
538
- const server = text('src/cli/mcp/server.ts');
1293
+ const server = text('adapters/mcp/server.ts');
539
1294
  const runtimeCall = server.indexOf('callRuntimeTool(ctx, name, args)');
540
1295
  const durableCall = server.indexOf('routeDurableMcpCall(ctx, name, args)');
541
1296
  const legacyCall = server.indexOf('callMultiRepositoryTool(ctx, name, args)');
@@ -556,16 +1311,16 @@ if (executionRegion.includes('forceDurable: true') && executionRegion.includes('
556
1311
  failures.push('Public MCP Work mutations must not force the retired durable ExecutionJob path');
557
1312
  }
558
1313
  forbid(
559
- 'src/runtime/gateway/mcp/router.ts',
1314
+ 'adapters/mcp/runtime-gateway/router.ts',
560
1315
  /\bcreateExecutionJob\b|\bgetExecutionJob\b/,
561
1316
  'Gateway Router must not retain dormant ExecutionJob creation or lookup paths',
562
1317
  );
563
- requireText('src/runtime/gateway/mcp/router.ts', 'executionJobCreationRetired');
564
- requireText('src/runtime/gateway/mcp/router.ts', "'EXECUTION_JOB_RETIRED'");
565
- requireText('src/runtime/gateway/mcp/execution-tools.ts', 'isDurableWorkOperation');
566
- requireText('src/runtime/gateway/mcp/execution-tools.ts', "'work_execute'");
567
- requireText('src/runtime/gateway/mcp/execution-tools.ts', "'work_validate'");
568
- requireText('src/runtime/gateway/mcp/execution-tools.ts', "'work_finalize'");
1318
+ requireText('adapters/mcp/runtime-gateway/router.ts', 'executionJobCreationRetired');
1319
+ requireText('adapters/mcp/runtime-gateway/router.ts', "'EXECUTION_JOB_RETIRED'");
1320
+ requireText('adapters/mcp/runtime-gateway/execution-tools.ts', 'isDurableWorkOperation');
1321
+ requireText('adapters/mcp/runtime-gateway/execution-tools.ts', "'work_execute'");
1322
+ requireText('adapters/mcp/runtime-gateway/execution-tools.ts', "'work_validate'");
1323
+ requireText('adapters/mcp/runtime-gateway/execution-tools.ts', "'work_finalize'");
569
1324
  requireText('src/runtime/execution/workers/executor.ts', 'executeWork(runtimeContext');
570
1325
  requireText('src/runtime/execution/workers/executor.ts', 'validateWork(runtimeContext');
571
1326
  requireText('src/runtime/execution/workers/executor.ts', 'finalizeWork(runtimeContext');
@@ -575,9 +1330,9 @@ forbid(
575
1330
  'Execution Worker must invoke control-plane Work application services directly, never MCP transport',
576
1331
  );
577
1332
  requireText('src/runtime/execution/workers/executor.ts', '__from_durable_worker');
578
- requireText('src/runtime/gateway/mcp/runtime-tools.ts', 'managedProcessOperationDigest');
1333
+ requireText('adapters/mcp/runtime-gateway/work-compat-adapter.ts', 'managedProcessOperationDigest');
579
1334
  forbid(
580
- 'src/runtime/gateway/mcp/runtime-tools.ts',
1335
+ 'adapters/mcp/runtime-gateway/runtime-tools.ts',
581
1336
  /\bcreateExecutionJob\b/,
582
1337
  'Runtime MCP tools must not retain dormant ExecutionJob creation paths',
583
1338
  );
@@ -592,12 +1347,12 @@ forbid(
592
1347
  'Local Bridge HTTP creation routes must return retirement handoffs without dormant Job submission or dispatch code',
593
1348
  );
594
1349
  forbid(
595
- 'src/cli/mcp/repository-tools.ts',
1350
+ 'adapters/mcp/tool-mapping/repository-tools.ts',
596
1351
  /\bsubmitLocalBridgeJob\b|\bexecuteLocalBridgeJob\b|\bwaitForRepositoryCommandHandoff\b/,
597
1352
  'Repository command MCP fallback must use Process Runtime or an external-Controller handoff, never Local Bridge Jobs',
598
1353
  );
599
1354
  forbid(
600
- 'src/cli/mcp/legacy-tool-service.ts',
1355
+ 'adapters/mcp/tool-mapping/legacy-tool-service.ts',
601
1356
  /\bsubmitLocalBridgeJob\b|\bexecuteLocalBridgeJob\b|\bacceptTaskJob\b|\bdispatchAcceptedTaskJob\b|\bstartTaskJob\b|\blegacy_agent_run\b/,
602
1357
  'Legacy MCP compatibility may read or cancel historical Jobs and Runs but must not create or dispatch new ones',
603
1358
  );
@@ -638,24 +1393,23 @@ forbid(
638
1393
  'Local Bridge HTTP must not call Agent Run create/start/retry write boundaries',
639
1394
  );
640
1395
  forbid(
641
- 'src/cli/mcp/legacy-tool-service.ts',
1396
+ 'adapters/mcp/tool-mapping/legacy-tool-service.ts',
642
1397
  /\bretryAgentJob\b/,
643
1398
  'Legacy MCP must not call Agent Run retry',
644
1399
  );
645
- forbid('src/runtime/gateway/mcp/router.ts', /Use process_get \/ process_wait \/ process_logs/, 'Gateway follow-up instructions must use an always-exposed neutral Work facade');
1400
+ forbid('adapters/mcp/runtime-gateway/router.ts', /Use process_get \/ process_wait \/ process_logs/, 'Gateway follow-up instructions must use an always-exposed neutral Work facade');
646
1401
  requireMatch(
647
- 'src/runtime/gateway/mcp/router.ts',
1402
+ 'adapters/mcp/runtime-gateway/router.ts',
648
1403
  /const DIRECT_REPOSITORY_TOOLS = new Set\(\[[\s\S]*?'repository_list'[\s\S]*?'repository_get'[\s\S]*?'repository_workbench'[\s\S]*?\]\);/,
649
1404
  'declare DIRECT_REPOSITORY_TOOLS with repository_list, repository_get, and repository_workbench',
650
1405
  );
651
- requireText('src/runtime/gateway/mcp/runtime-tools.ts', "case 'controller_context'");
652
- requireText('src/runtime/gateway/mcp/runtime-tools.ts', "case 'local_bridge_status'");
653
- requireText('src/runtime/gateway/mcp/runtime-tools.ts', 'readAgentExecutableReadinessSnapshot');
654
- requireText('src/runtime/gateway/mcp/runtime-tools.ts', 'connectorExposedTools');
655
- requireText('src/runtime/gateway/mcp/runtime-tools.ts', 'currentCallableTools');
656
- forbid('src/runtime/gateway/mcp/runtime-tools.ts', /inspectAgentExecutableReadiness|resolveAgentExecutable|writeAgentExecutableReadinessSnapshot/, 'Gateway readiness must only read the Daemon-produced Agent executable snapshot');
1406
+ requireText('adapters/mcp/runtime-gateway/runtime-observation-adapter.ts', "case 'controller_context'");
1407
+ requireText('adapters/mcp/runtime-gateway/runtime-observation-adapter.ts', "case 'local_bridge_status'");
1408
+ requireText('adapters/mcp/runtime-gateway/runtime-tools.ts', 'connectorExposedTools');
1409
+ requireText('adapters/mcp/runtime-gateway/runtime-tools.ts', 'currentCallableTools');
1410
+ forbid('adapters/mcp/runtime-gateway/runtime-observation-adapter.ts', /inspectAgentExecutableReadiness|resolveAgentExecutable|writeAgentExecutableReadinessSnapshot/, 'Runtime observation adapter must not perform Agent executable discovery or mutate readiness snapshots');
657
1411
  forbidBetween(
658
- 'src/runtime/gateway/mcp/runtime-tools.ts',
1412
+ 'adapters/mcp/runtime-gateway/runtime-observation-adapter.ts',
659
1413
  "case 'repository_runtime_snapshot':",
660
1414
  "case 'runtime_performance_diagnostics':",
661
1415
  /rebuildRepositoryProjection\s*\(/,
@@ -669,9 +1423,9 @@ forbid(
669
1423
  );
670
1424
  requireText('src/runtime/projections/controller-context.ts', 'controllerContextProjectionPayloadMatchesSourceIdentity');
671
1425
  requireText('src/runtime/projections/controller-context.ts', 'sourceIdentityMatches');
672
- requireText('src/runtime/gateway/mcp/runtime-tools.ts', 'CONTEXT_PROJECTION_SOURCE_MISMATCH');
673
- forbid('src/runtime/gateway/mcp/router.ts', /const DIRECT_HOT_READ_TOOLS = new Set\([\s\S]*?['"]controller_context['"][\s\S]*?\);/, 'controller_context must use a materialized projection or Durable Job, never the legacy Gateway path');
674
- forbid('src/runtime/gateway/mcp/router.ts', /const DIRECT_HOT_READ_TOOLS = new Set\([\s\S]*?['"](?:local_bridge_status|get_local_job|get_local_job_output)['"][\s\S]*?\);/, 'Local Bridge observations must use bounded snapshots, never reconciliation in the Gateway');
1426
+ requireText('adapters/mcp/runtime-gateway/runtime-observation-adapter.ts', 'CONTEXT_PROJECTION_SOURCE_MISMATCH');
1427
+ forbid('adapters/mcp/runtime-gateway/router.ts', /const DIRECT_HOT_READ_TOOLS = new Set\([\s\S]*?['"]controller_context['"][\s\S]*?\);/, 'controller_context must use a materialized projection or Durable Job, never the legacy Gateway path');
1428
+ forbid('adapters/mcp/runtime-gateway/router.ts', /const DIRECT_HOT_READ_TOOLS = new Set\([\s\S]*?['"](?:local_bridge_status|get_local_job|get_local_job_output)['"][\s\S]*?\);/, 'Local Bridge observations must use bounded snapshots, never reconciliation in the Gateway');
675
1429
  requireText('src/runtime/execution/jobs/types.ts', 'requestId: string');
676
1430
  requireText('src/runtime/execution/jobs/types.ts', 'semanticKey: string');
677
1431
  requireText('src/runtime/execution/jobs/types.ts', 'admissionTimeoutMs: number');
@@ -683,7 +1437,7 @@ requireText('src/runtime/control-plane/facade/operation-digest.ts', 'operationId
683
1437
  requireText('src/runtime/control-plane/facade/operation-digest.ts', 'resultRef');
684
1438
  requireText('src/runtime/control-plane/facade/operation-digest.ts', 'nextActions');
685
1439
  requireText('src/runtime/control-plane/facade/operation-digest.ts', 'admissionTimeoutMs');
686
- forbid('src/runtime/gateway/mcp/router.ts', /Math\.min\(\s*typeof args\.timeout_ms[\s\S]{0,140}?,\s*120_000\s*\)/, 'Agent parent timeout must never silently truncate timeout_ms to 120 seconds');
1440
+ forbid('adapters/mcp/runtime-gateway/router.ts', /Math\.min\(\s*typeof args\.timeout_ms[\s\S]{0,140}?,\s*120_000\s*\)/, 'Agent parent timeout must never silently truncate timeout_ms to 120 seconds');
687
1441
  requireText('src/runtime/execution/jobs/store.ts', "'active.json'");
688
1442
  requireText('src/runtime/execution/jobs/store.ts', "'recent.json'");
689
1443
  requireText('src/runtime/execution/jobs/store.ts', "'requests'");
@@ -754,13 +1508,13 @@ forbidBetween(
754
1508
  /rebuildRepositoryProjection\s*\(/,
755
1509
  'Projection rebuild must happen outside the Repo Actor mailbox lock',
756
1510
  );
757
- requireText('src/runtime/workflow/schedules/store.ts', "'occurrences.json'");
1511
+ requireText('packages/kernel/scheduler/infrastructure/schedule-store.ts', "'occurrences.json'");
758
1512
  requireText('src/runtime/projections/git-status-sampler.ts', 'writeRepositoryGitStatusSample');
759
1513
  requireText('src/runtime/projections/git-status-sampler.ts', 'readRepositoryGitStatusSample');
760
- requireText('src/cli/mcp/repository-tools.ts', 'readRepositoryGitStatusSample');
761
- requireText('src/cli/mcp/repository-tools.ts', 'args.refresh === true');
1514
+ requireText('adapters/mcp/tool-mapping/repository-tools.ts', 'readRepositoryGitStatusSample');
1515
+ requireText('adapters/mcp/tool-mapping/repository-tools.ts', 'args.refresh === true');
762
1516
  forbidBetween(
763
- 'src/cli/mcp/repository-tools.ts',
1517
+ 'adapters/mcp/tool-mapping/repository-tools.ts',
764
1518
  "case 'repository_git_status':",
765
1519
  "case 'repository_git_diff':",
766
1520
  /repositoryGitStatus\s*\(/,
@@ -769,35 +1523,35 @@ forbidBetween(
769
1523
  requireText('src/runtime/control-plane/execution/session-store.ts', 'lastValidatedAt: now');
770
1524
  requireText('src/runtime/control-plane/execution/validation.ts', 'warnings.push');
771
1525
  requireText('src/runtime/control-plane/execution/work-handle-store.ts', "failed: ['validating', 'editing', 'committed', 'merged', 'cleaned', 'failed_terminal_cleanup']");
772
- requireText('src/runtime/gateway/mcp/execution-tools.ts', "from '../../control-plane/execution/work-finalization-service'");
773
- requireText('src/runtime/gateway/mcp/execution-tools.ts', "from '../../control-plane/execution/work-preparation-service'");
774
- requireText('src/runtime/gateway/mcp/execution-tools.ts', "from '../../control-plane/execution/work-operation-service'");
775
- requireText('src/runtime/gateway/mcp/execution-tools.ts', 'Compatibility exports: implementation authority lives in control-plane execution.');
776
- requireText('src/runtime/gateway/mcp/execution-tools.ts', 'resetFinalizationStagesForRequest,');
777
- requireText('src/runtime/gateway/mcp/execution-tools.ts', 'selectDefaultWorkValidationChecks');
778
- requireText('src/runtime/gateway/mcp/runtime-tools.ts', "callExecutionTool(ctx, 'work_finalize'");
1526
+ requireText('adapters/mcp/runtime-gateway/execution-tools.ts', "from '../../../src/runtime/control-plane/execution/work-finalization-service'");
1527
+ requireText('adapters/mcp/runtime-gateway/execution-tools.ts', "from '../../../src/runtime/control-plane/execution/work-preparation-service'");
1528
+ requireText('adapters/mcp/runtime-gateway/execution-tools.ts', "from '../../../src/runtime/control-plane/execution/work-operation-service'");
1529
+ requireText('adapters/mcp/runtime-gateway/execution-tools.ts', 'Compatibility exports: implementation authority lives in control-plane execution.');
1530
+ requireText('adapters/mcp/runtime-gateway/execution-tools.ts', 'resetFinalizationStagesForRequest,');
1531
+ requireText('adapters/mcp/runtime-gateway/execution-tools.ts', 'selectDefaultWorkValidationChecks');
1532
+ requireText('adapters/mcp/runtime-gateway/work-adapter.ts', "callExecutionTool(ctx, 'work_finalize'");
779
1533
  forbid(
780
- 'src/runtime/gateway/mcp/runtime-tools.ts',
1534
+ 'adapters/mcp/runtime-gateway/runtime-tools.ts',
781
1535
  /repositoryGit(?:Commit|FinishWorkflow|MergeBranch|DeleteBranch|RebaseOnto)\s*\(/,
782
1536
  'rh_work facade finalization must delegate to the canonical Work finalization application service instead of performing Git delivery itself',
783
1537
  );
784
1538
  forbid(
785
- 'src/runtime/gateway/mcp/execution-tools.ts',
1539
+ 'adapters/mcp/runtime-gateway/execution-tools.ts',
786
1540
  /function\s+finalizeWork\s*\(/,
787
1541
  'MCP execution transport must delegate Work finalization to the control-plane application service',
788
1542
  );
789
1543
  forbid(
790
- 'src/runtime/gateway/mcp/execution-tools.ts',
1544
+ 'adapters/mcp/runtime-gateway/execution-tools.ts',
791
1545
  /function\s+(?:prepareWork|adoptExistingWorkHead)\s*\(/,
792
1546
  'MCP execution transport must delegate Work preparation/adoption to the control-plane application service',
793
1547
  );
794
1548
  forbid(
795
- 'src/runtime/gateway/mcp/execution-tools.ts',
1549
+ 'adapters/mcp/runtime-gateway/execution-tools.ts',
796
1550
  /function\s+(?:executeWork|validateWork)\s*\(/,
797
1551
  'MCP execution transport must delegate Work execute/validate operations to the control-plane application service',
798
1552
  );
799
1553
  forbid(
800
- 'src/runtime/gateway/mcp/execution-tools.ts',
1554
+ 'adapters/mcp/runtime-gateway/execution-tools.ts',
801
1555
  /(?:ensureManagedWorkspace|admitPreparedRepositoryWorkContract)\s*\(/,
802
1556
  'MCP execution transport must not own managed-workspace or WorkContract preparation admission',
803
1557
  );
@@ -814,25 +1568,27 @@ forbidBetween(
814
1568
  /withControllerLock\([\s\S]{0,900}?(?:repositoryGitCommit|repositoryGitFinishWorkflow|runCleanup|repositoryGitDeleteBranch)/,
815
1569
  'Work finalization must not hold the controller lock while committing, merging, deleting branches, or removing worktrees',
816
1570
  );
817
- requireText('src/runtime/workflow/schedules/types.ts', "'repository-event'");
818
- requireText('src/runtime/workflow/schedules/types.ts', "'dependency-checkpoint'");
819
- requireText('src/runtime/workflow/schedules/store.ts', 'saveScheduleDecision');
820
- requireText('src/runtime/workflow/schedules/settlement.ts', 'backoffMinutes');
1571
+ requireText('packages/kernel/scheduler/domain/schedule.ts', "'repository-event'");
1572
+ requireText('packages/kernel/scheduler/domain/schedule.ts', "'dependency-checkpoint'");
1573
+ requireText('packages/kernel/scheduler/infrastructure/schedule-store.ts', 'saveScheduleDecision');
1574
+ requireText('packages/kernel/scheduler/application/settlement.ts', 'backoffMinutes');
821
1575
  requireText('src/runtime/release/release-gate.ts', 'releaseReady');
822
- requireText('src/cli/mcp/transports/http.ts', "'/ready'");
823
- requireText('src/cli/mcp/transports/http.ts', "'/repos/:repoId/health'");
1576
+ requireText('adapters/mcp/transports/http.ts', "'/ready'");
1577
+ requireText('adapters/mcp/transports/http.ts', "'/repos/:repoId/health'");
824
1578
  requireText('src/runtime/control-plane/governance/external-effects.ts', 'EXTERNAL_EFFECT_AUTHORIZATION_REQUIRED');
825
1579
  requireText('src/runtime/control-plane/governance/external-effects.ts', 'AUTOMATED_REQUIREMENT_REQUIRES_CANDIDATE');
826
- requireText('src/cli/mcp/tools.ts', "export * from './legacy-tool-service'");
1580
+ requireText('adapters/mcp/tool-mapping/tools.ts', "export * from './legacy-tool-service'");
1581
+ requireText('src/cli/mcp/tools.ts', '@deprecated Kernel V2 compatibility shim');
827
1582
 
828
1583
  for (const path of [
829
- 'src/runtime/gateway/mcp/router.ts',
830
- 'src/runtime/gateway/mcp/runtime-tools.ts',
1584
+ 'adapters/mcp/runtime-gateway/router.ts',
1585
+ 'adapters/mcp/runtime-gateway/runtime-tools.ts',
1586
+ 'adapters/mcp/runtime-gateway/work-adapter.ts',
831
1587
  'src/runtime/control-plane/global-scheduler/scheduler.ts',
832
1588
  'src/runtime/control-plane/repo-actor/actor.ts',
833
1589
  'src/runtime/workflow/schedules/engine.ts',
834
1590
  'src/runtime/workflow/schedules/work-continuation.ts',
835
- 'src/cli/mcp/transports/http.ts',
1591
+ 'adapters/mcp/transports/http.ts',
836
1592
  ]) {
837
1593
  forbid(path, /\b(?:spawnSync|execSync|execFileSync)\s*\(/, 'the non-blocking Gateway/Controller hot-path rule');
838
1594
  }
@@ -845,7 +1601,362 @@ requireText('docs/architecture/CURRENT.md', '## State ownership');
845
1601
  requireText('docs/architecture/CURRENT.md', '## Runtime and MCP boundary');
846
1602
  requireText('docs/architecture/CURRENT.md', '## Testing and verification');
847
1603
  requireText('plans/README.md', 'not the runtime execution queue');
848
- if (text('src/cli/mcp/tools.ts').split(/\r?\n/).length > 40) failures.push('src/cli/mcp/tools.ts must remain a thin compatibility facade');
1604
+ // Compatibility-facade thinness is enforced by ownership/consumer boundaries, not source line counts.
1605
+ const b7ProductionFiles = productionTypeScriptFiles();
1606
+ const b7ProductionImports = staticTypeScriptImportRecords(b7ProductionFiles);
1607
+ const b7ProductionGraph = staticTypeScriptDependencyGraph(b7ProductionFiles);
1608
+ for (const { from, specifier } of b7ProductionImports) {
1609
+ if (from.startsWith('packages/kernel/') && specifier.startsWith('@modelcontextprotocol/')) {
1610
+ failures.push(`Kernel modules must remain independent of MCP SDK transport contracts: ${from} -> ${specifier}`);
1611
+ }
1612
+ if (from.startsWith('packages/kernel/')
1613
+ && ['adapters/mcp', 'src/cli/mcp', 'runtime/gateway/mcp'].some((segment) => specifier.includes(segment))) {
1614
+ failures.push(`Kernel modules must never depend on MCP adapters or retired MCP gateway paths: ${from} -> ${specifier}`);
1615
+ }
1616
+ if (from.startsWith('packages/plugin-runtime/')
1617
+ && ['adapters/', 'src/runtime/'].some((segment) => specifier.includes(segment))) {
1618
+ failures.push(`Plugin Runtime provider dispatch must not depend on concrete adapters or Runtime implementations: ${from} -> ${specifier}`);
1619
+ }
1620
+ if (from.startsWith('adapters/computer/') && specifier.includes('src/runtime/')) {
1621
+ failures.push(`Computer adapters must consume provider-neutral ports and contracts rather than depend on Runtime implementations: ${from} -> ${specifier}`);
1622
+ }
1623
+ if (from.startsWith('packages/plugin-runtime/computer/')
1624
+ && (['controller-home', 'external-registration'].some((segment) => specifier.includes(segment))
1625
+ || ['node:fs', 'fs', 'node:path', 'path'].includes(specifier))) {
1626
+ failures.push(`Computer provider runtime must remain independent of Controller Home and filesystem-backed provider discovery: ${from} -> ${specifier}`);
1627
+ }
1628
+ if (from !== 'src/runtime/plugins/macos-capability-broker.ts' && specifier.includes('macos-capability-broker')) {
1629
+ failures.push(`Deprecated macOS capability broker is compatibility/test-only and must have no production consumers: ${from} -> ${specifier}`);
1630
+ }
1631
+ }
1632
+ for (const edge of dependencyEdges(b7ProductionGraph)) {
1633
+ const { from, to } = edgeParts(edge);
1634
+ if (from.startsWith('packages/kernel/') && to.startsWith('packages/kernel/')) {
1635
+ const fromModule = architectureRoot(from);
1636
+ const toModule = architectureRoot(to);
1637
+ if (fromModule !== toModule && !to.startsWith(`${toModule}/api/`) && to !== `${toModule}/index.ts`) {
1638
+ failures.push(`Kernel sibling modules must use public API boundaries: ${edge}`);
1639
+ }
1640
+ }
1641
+ if (from.startsWith('adapters/') && to.startsWith('adapters/') && architectureRoot(from) !== architectureRoot(to)) {
1642
+ failures.push(`adapter sibling wiring belongs in a composition root, not another adapter: ${edge}`);
1643
+ }
1644
+ if (from.startsWith('adapters/') && to.startsWith('packages/kernel/')) {
1645
+ const kernelModule = architectureRoot(to);
1646
+ if (!to.startsWith(`${kernelModule}/api/`) && to !== `${kernelModule}/index.ts`) {
1647
+ failures.push(`adapters must consume Kernel public APIs, not internal implementation: ${edge}`);
1648
+ }
1649
+ }
1650
+ if (from.startsWith('packages/kernel/')
1651
+ && (to.startsWith('adapters/mcp/') || to.startsWith('src/cli/mcp/') || to.startsWith('src/runtime/gateway/mcp/'))) {
1652
+ failures.push(`Kernel modules must never depend on MCP adapters or retired MCP gateway paths: ${edge}`);
1653
+ }
1654
+ if (/^packages\/kernel\/[^/]+\/(?:domain|application)\//.test(from) && to.startsWith('src/')) {
1655
+ failures.push(`Kernel domain/application must depend only on Kernel/protocol ports, never legacy src mechanisms: ${edge}`);
1656
+ }
1657
+ if (from.startsWith('packages/plugin-runtime/') && (to.startsWith('adapters/') || to.startsWith('src/runtime/'))) {
1658
+ failures.push(`Plugin Runtime provider dispatch must not depend on concrete adapters or Runtime implementations: ${edge}`);
1659
+ }
1660
+ if (from.startsWith('packages/plugin-runtime/computer/')
1661
+ && (to.includes('/controller-home') || to.endsWith('/external-registration.ts'))) {
1662
+ failures.push(`Computer provider runtime must remain independent of Controller Home and provider discovery implementations: ${edge}`);
1663
+ }
1664
+ if (to === 'src/runtime/plugins/macos-capability-broker.ts' && from !== to) {
1665
+ failures.push(`Deprecated macOS capability broker is compatibility/test-only and must have no production consumers: ${edge}`);
1666
+ }
1667
+ }
1668
+ for (const compositionPath of [
1669
+ 'src/runtime/root/scheduled-controller-composition.ts',
1670
+ 'src/runtime/root/controller-round-composition.ts',
1671
+ ]) requireText(compositionPath, 'Kernel V2 composition root');
1672
+
1673
+ // Exact legacy edges are frozen below after a read-only graph inventory; new debt is never accepted.
1674
+ // The V2 baseline lineage is immutable; this gate must not require rebasing onto unrelated main work.
1675
+ const b7KernelLegacyEdges = edgeSet(b7ProductionGraph, (edge) => {
1676
+ const { from, to } = edgeParts(edge);
1677
+ return from.startsWith('packages/kernel/') && to.startsWith('src/');
1678
+ });
1679
+ const B7_ALLOWED_KERNEL_LEGACY_EDGES = new Set([
1680
+ 'packages/kernel/work/infrastructure/work-contract-store.ts -> src/cli/repositories/controller-home.ts',
1681
+ 'packages/kernel/work/infrastructure/work-contract-store.ts -> src/cli/repositories/locks.ts',
1682
+ 'packages/kernel/work/infrastructure/work-contract-store.ts -> src/runtime/shared/json-files.ts',
1683
+ 'packages/kernel/work/infrastructure/work-contract-store.ts -> src/runtime/control-plane/persistence/sqlite-store.ts',
1684
+ 'packages/kernel/controller/infrastructure/controller-session-store.ts -> src/cli/repositories/controller-home.ts',
1685
+ 'packages/kernel/controller/infrastructure/controller-session-store.ts -> src/cli/repositories/locks.ts',
1686
+ 'packages/kernel/controller/infrastructure/controller-session-store.ts -> src/runtime/control-plane/execution/session-store.ts',
1687
+ 'packages/kernel/controller/infrastructure/controller-session-store.ts -> src/runtime/shared/json-files.ts',
1688
+ 'packages/kernel/controller/infrastructure/controller-session-store.ts -> src/runtime/control-plane/persistence/sqlite-store.ts',
1689
+ 'packages/kernel/controller/infrastructure/controller-round-store.ts -> src/cli/repositories/locks.ts',
1690
+ 'packages/kernel/controller/infrastructure/controller-round-store.ts -> src/runtime/control-plane/persistence/requirement-store.ts',
1691
+ 'packages/kernel/controller/infrastructure/controller-round-store.ts -> src/runtime/control-plane/persistence/sqlite-store.ts',
1692
+ 'packages/kernel/controller/infrastructure/controller-round-store.ts -> src/runtime/execution/work-activity.ts',
1693
+ 'packages/kernel/controller/infrastructure/controller-round-store.ts -> src/runtime/control-plane/facade/handoff-inbox-store.ts',
1694
+ 'packages/kernel/controller/infrastructure/controller-binding-store.ts -> src/cli/repositories/locks.ts',
1695
+ 'packages/kernel/controller/infrastructure/controller-binding-store.ts -> src/runtime/control-plane/persistence/sqlite-store.ts',
1696
+ 'packages/kernel/scheduler/infrastructure/schedule-store.ts -> src/cli/repositories/controller-home.ts',
1697
+ 'packages/kernel/scheduler/infrastructure/schedule-store.ts -> src/cli/repositories/locks.ts',
1698
+ 'packages/kernel/scheduler/infrastructure/schedule-store.ts -> src/runtime/control-plane/facade/handoff-inbox-store.ts',
1699
+ 'packages/kernel/scheduler/infrastructure/schedule-store.ts -> src/runtime/shared/json-files.ts',
1700
+ 'packages/kernel/scheduler/infrastructure/schedule-store.ts -> src/runtime/evidence/event-ledger.ts',
1701
+ 'packages/kernel/scheduler/infrastructure/continuation-dispatch-store.ts -> src/cli/repositories/locks.ts',
1702
+ 'packages/kernel/scheduler/infrastructure/continuation-dispatch-store.ts -> src/runtime/control-plane/persistence/sqlite-store.ts',
1703
+ ]);
1704
+ requireExactShrinkingDebt('Kernel -> legacy src dependency debt', b7KernelLegacyEdges, B7_ALLOWED_KERNEL_LEGACY_EDGES);
1705
+ const b7ProductionEdges = new Set(dependencyEdges(b7ProductionGraph));
1706
+ for (const requiredEdge of [
1707
+ 'packages/kernel/work/domain/types.ts -> packages/kernel/identity/api/index.ts',
1708
+ 'packages/kernel/scheduler/domain/schedule.ts -> packages/kernel/identity/api/index.ts',
1709
+ ]) {
1710
+ if (!b7ProductionEdges.has(requiredEdge)) failures.push(`Portable semantic identity contract must be consumed through the Kernel Identity boundary: ${requiredEdge}`);
1711
+ }
1712
+
1713
+ const b7LifecycleOwnerMarkers = new Map([
1714
+ ['WorkContract transition authority', ['packages/kernel/work/domain/state-machine.ts']],
1715
+ ['ControllerSession claim authority', ['packages/kernel/controller/infrastructure/controller-session-store.ts']],
1716
+ ['ControllerRound relay authority', ['packages/kernel/controller/infrastructure/controller-round-store.ts']],
1717
+ ['Schedule occurrence authority', ['packages/kernel/scheduler/infrastructure/schedule-store.ts']],
1718
+ ['Forge instance identity authority', ['packages/kernel/identity/infrastructure/identity-store.ts']],
1719
+ ]);
1720
+ for (const [label, owners] of b7LifecycleOwnerMarkers) {
1721
+ for (const owner of owners) text(owner);
1722
+ if (new Set(owners).size !== 1) failures.push(`${label} must have exactly one declared durable owner`);
1723
+ }
1724
+ const b7UniqueMutationSymbols = new Map([
1725
+ ['transitionWorkContractPhase', 'Work lifecycle mutation'],
1726
+ ['claimControllerSession', 'ControllerSession claim mutation'],
1727
+ ['beginInitialControllerRoundDispatch', 'ControllerRound dispatch mutation'],
1728
+ ['ensureForgeInstanceIdentity', 'Forge instance identity creation'],
1729
+ ]);
1730
+ for (const [symbol, label] of b7UniqueMutationSymbols) {
1731
+ let count = 0;
1732
+ for (const path of productionTypeScriptFiles()) {
1733
+ count += (text(path).match(new RegExp(`export\\s+(?:async\\s+)?function\\s+${symbol}\\s*\\(`, 'g')) ?? []).length;
1734
+ }
1735
+ if (count !== 1) failures.push(`${label} must have exactly one exported production owner; found ${count} for ${symbol}`);
1736
+ }
1737
+ for (const path of [
1738
+ 'src/runtime/gateway/mcp/execution-tools.ts',
1739
+ 'src/runtime/gateway/mcp/legacy-ios-tool-adapter.ts',
1740
+ 'src/runtime/gateway/mcp/persisted-check-process.ts',
1741
+ 'src/runtime/gateway/mcp/process-tools.ts',
1742
+ 'src/runtime/gateway/mcp/router.ts',
1743
+ 'src/runtime/gateway/mcp/runtime-tool-definitions.ts',
1744
+ 'src/runtime/gateway/mcp/runtime-tools.ts',
1745
+ 'src/runtime/gateway/mcp/work-validation-reconciler.ts',
1746
+ ]) requireText(path, '@deprecated Kernel V2 compatibility shim');
1747
+ for (const path of [
1748
+ 'src/cli/mcp/access-tools.ts',
1749
+ 'src/cli/mcp/legacy-context.ts',
1750
+ 'src/cli/mcp/legacy-tool-service.ts',
1751
+ 'src/cli/mcp/multi-repository.ts',
1752
+ 'src/cli/mcp/repository-tools.ts',
1753
+ 'src/cli/mcp/server.ts',
1754
+ 'src/cli/mcp/tools.ts',
1755
+ 'src/cli/mcp/toolset.ts',
1756
+ ]) requireText(path, '@deprecated Kernel V2 compatibility shim');
1757
+ requireText('src/runtime/control-plane/execution/work-execution-support.ts', 'packages/protocols/mcp/execution-context');
1758
+ requireText('src/runtime/control-plane/execution/work-preparation-service.ts', 'packages/protocols/mcp/execution-context');
1759
+ requireText('src/runtime/control-plane/execution/work-operation-service.ts', 'packages/protocols/mcp/execution-context');
1760
+ requireText('src/runtime/control-plane/execution/work-finalization-service.ts', 'packages/protocols/mcp/execution-context');
1761
+ for (const path of [
1762
+ 'adapters/mcp/transports/http.ts',
1763
+ 'adapters/mcp/transports/session-registry.ts',
1764
+ 'adapters/mcp/transports/stdio.ts',
1765
+ ]) forbid(path, /recordWorkCompletionReceipt|transitionWorkContractPhase|releaseControllerSessionWithAuthority|recordWorkImplementationReview/, 'MCP transport/session lifecycle must never terminalize Work or Controller authority');
1766
+
1767
+ // Kernel V2 B6: semantic Forge identity is independent of Runtime processes,
1768
+ // transport sessions, OAuth credentials, tunnel ids, and endpoint rotation.
1769
+ for (const path of [
1770
+ 'packages/kernel/identity/domain/types.ts',
1771
+ 'packages/kernel/identity/application/identity-service.ts',
1772
+ 'packages/kernel/identity/infrastructure/identity-store.ts',
1773
+ 'packages/kernel/identity/api/index.ts',
1774
+ ]) text(path);
1775
+ for (const symbol of ['ForgeInstanceIdentity', 'Principal', 'CredentialReference', 'CapabilityGrant', 'ConnectionIdentity']) {
1776
+ requireText('packages/kernel/identity/domain/types.ts', `interface ${symbol}`);
1777
+ }
1778
+ requireText('packages/kernel/identity/application/identity-service.ts', 'export function connectionIdentity');
1779
+ requireText('packages/kernel/identity/infrastructure/identity-store.ts', "'identity', 'forge-instance.json'");
1780
+ requireText('packages/kernel/identity/infrastructure/identity-store.ts', 'linkSync(temporary, path)');
1781
+ forbid(
1782
+ 'packages/kernel/identity/domain/types.ts',
1783
+ /\b(?:tunnelId|mcpServerUrl|endpointUrl|runtimeApiKey|accessToken|refreshToken|oauthToken|bearerToken)\b/,
1784
+ 'Kernel identity contracts must contain semantic ids or credential references, never transport endpoint/tunnel/token material',
1785
+ );
1786
+ forbidBetween(
1787
+ 'packages/kernel/identity/application/identity-service.ts',
1788
+ 'const semanticKey = [',
1789
+ "].join('\\u0000')",
1790
+ /\b(?:endpoint|url|tunnel|pid|process|session)\b/i,
1791
+ 'ConnectionIdentity semantic key must remain independent of endpoint, tunnel, process, and session identity',
1792
+ );
1793
+ forbidBetween(
1794
+ 'packages/kernel/identity/infrastructure/identity-store.ts',
1795
+ 'const identity: ForgeInstanceIdentity = {',
1796
+ '};',
1797
+ /\b(?:pid|process|endpoint|url|tunnel|token)\b/i,
1798
+ 'ForgeInstanceIdentity creation must remain independent of process and adapter transport/auth metadata',
1799
+ );
1800
+ for (const path of [
1801
+ 'src/cli/mcp/auth.ts',
1802
+ 'src/cli/mcp/setup.ts',
1803
+ 'src/cli/mcp/openai-secure-tunnel.ts',
1804
+ ]) {
1805
+ requireText(path, '@deprecated Kernel V2 compatibility shim');
1806
+ }
1807
+ requireText('adapters/mcp/auth.ts', 'forgeInstanceId?: string');
1808
+ forbid('adapters/mcp/auth.ts', /server:\s*\{[\s\S]{0,512}?instanceId\??:\s*string/, 'MCP server process identity must not share semantic Forge instanceId naming');
1809
+ requireText('adapters/mcp/setup.ts', 'ensureForgeInstanceIdentity');
1810
+ requireText('adapters/mcp/setup.ts', 'MCP_FORGE_INSTANCE_ID_MISMATCH');
1811
+ requireText('src/runtime/root/types.ts', 'forgeInstanceId: string');
1812
+ requireText('src/runtime/root/types.ts', 'runtimeInstanceId: string');
1813
+ requireText('src/runtime/root/runtime.ts', 'readonly forgeInstanceId: string');
1814
+ requireText('src/runtime/root/runtime.ts', 'ensureForgeInstanceIdentity');
1815
+ requireText('src/runtime/root/entry.ts', 'forgeInstanceId: runtime.forgeInstanceId');
1816
+ requireText('adapters/mcp/transports/http.ts', 'forgeInstanceId: forgeInstance.instanceId');
1817
+ requireText('adapters/mcp/transports/http.ts', 'controllerInstanceId: process.env.FORGE_MCP_INSTANCE_ID');
1818
+ forbid('adapters/mcp/transports/http.ts', /\{\s*instanceId:\s*process\.env\.FORGE_MCP_INSTANCE_ID/, 'MCP process identity must not be exposed as semantic Forge instanceId');
1819
+ requireText('adapters/mcp/transports/http.ts', "adapterId: 'mcp-http'");
1820
+ requireText('adapters/mcp/transports/session-registry.ts', 'connectionId: string');
1821
+ requireText('adapters/mcp/transports/session-registry.ts', 'reservation.connectionId !== input.connectionId');
1822
+ requireText('adapters/mcp/tunnels/openai-secure-tunnel.ts', 'tunnelMatches: boolean');
1823
+ requireText('adapters/mcp/tunnels/openai-secure-tunnel.ts', 'credentialReference(config.runtimeApiKeyRef');
1824
+ forbid('adapters/mcp/tunnels/openai-secure-tunnel.ts', /\bidentityMatches\b/, 'tunnel binding match must not masquerade as Forge semantic identity');
1825
+
1826
+ // C0 Computer capability boundary: Browser and Desktop remain separate providers.
1827
+ requireText('packages/protocols/computer/contract.ts', 'COMPUTER_BROWSER_AUTOMATION_CAPABILITY');
1828
+ requireText('packages/protocols/computer/contract.ts', 'ComputerRuntimeProviderCapabilityId');
1829
+ requireText('packages/plugin-runtime/computer/provider.ts', 'ComputerRuntimeProviderCapabilityId');
1830
+ requireText('packages/plugin-runtime/computer/provider-registry.ts', 'COMPUTER_PROVIDER_AMBIGUOUS');
1831
+ requireText('packages/plugin-runtime/computer/provider-registry.ts', 'COMPUTER_PROVIDER_DUPLICATE_ID');
1832
+ forbid('packages/plugin-runtime/computer/provider-registry.ts', /throw new Error\(/, 'Computer provider resolution must expose typed provider errors rather than raw order-dependent failures');
1833
+
1834
+ requireText('packages/protocols/computer/contract.ts', 'COMPUTER_CAPABILITY_PROTOCOL_VERSION');
1835
+ requireText('packages/protocols/computer/contract.ts', 'COMPUTER_CAPABILITY_EXECUTION_METHOD');
1836
+ requireText('packages/protocols/computer/contract.ts', 'export interface ComputerCapabilityAdvertisement');
1837
+ forbid('adapters/computer/desktop-operator-negotiation.ts', /interface\s+ComputerCapabilityAdvertisement/, 'Desktop Operator negotiation must consume the provider-neutral Computer capability advertisement contract instead of redefining it');
1838
+ requireText('packages/plugin-runtime/computer/provider.ts', 'export interface ComputerProvider');
1839
+ requireText('packages/plugin-runtime/computer/provider-registry.ts', 'export class ComputerProviderRegistry');
1840
+ requireText('adapters/computer/desktop-operator-contract.ts', 'DESKTOP_OPERATOR_PROVIDER_PLUGIN_ID');
1841
+ requireText('adapters/computer/desktop-operator-negotiation.ts', 'negotiateDesktopOperatorComputerHandshake');
1842
+ requireText('adapters/computer/desktop-operator-negotiation.ts', 'buildDesktopOperatorComputerInvocation');
1843
+ requireText('adapters/computer/desktop-operator-provider.ts', 'createDesktopOperatorComputerProvider');
1844
+ requireText('adapters/computer/desktop-operator-discovery.ts', 'ComputerProviderRegistrationLookup');
1845
+ requireText('adapters/computer/desktop-operator-discovery.ts', "source: 'registration'");
1846
+ requireText('adapters/computer/desktop-operator-discovery.ts', "source: 'legacy_fallback'");
1847
+ requireText('adapters/computer/desktop-operator-discovery.ts', "DesktopOperatorLegacyFallbackMode");
1848
+ requireText('adapters/computer/desktop-operator-discovery.ts', "PLUGIN_COMPUTER_PROVIDER_REGISTRATION_REQUIRED");
1849
+ requireText('src/runtime/root/computer-composition.ts', "legacyFallback: 'unregistered_v0_2'");
1850
+ requireText('src/cli/commands/computer.ts', "new Command('computer')");
1851
+ requireText('src/cli/commands/computer.ts', 'installOfficialPlugin(COMPUTER_PROVIDER_PLUGIN_ID');
1852
+ requireText('src/cli/commands/computer.ts', 'provider release: independent');
1853
+ requireText('src/cli/commands/computer.ts', 'COMPUTER_PROVIDER_UNINSTALLER_MISSING');
1854
+ requireText('src/cli/commands/computer.ts', 'readControllerStoredPluginManifest');
1855
+ requireText('src/cli/commands/computer.ts', 'syncControllerPluginManifest');
1856
+ requireText('src/cli/commands/computer.ts', 'removeControllerPluginManifestProjection');
1857
+ requireText('src/cli/commands/computer.ts', 'withOfficialPluginLifecycleLock');
1858
+ forbid('src/cli/commands/computer.ts', /controllerPluginRepository\(|syncAssistantPluginRegistry|getAssistantPluginManifest\(/, 'Computer status/doctor must use Controller-scoped stored/targeted provider APIs rather than a fake repository or global execution-style manifest lookup');
1859
+ requireText('src/cli/commands/plugin.ts', 'external-plugin:${pluginId}');
1860
+ requireText('src/runtime/plugins/store.ts', 'export function readControllerStoredPluginManifest');
1861
+ requireText('src/runtime/plugins/store.ts', 'export function syncControllerPluginManifest');
1862
+ requireText('src/runtime/plugins/store.ts', 'export function removeControllerPluginManifestProjection');
1863
+ requireText('src/runtime/plugins/store.ts', 'export function readStoredAssistantPluginManifest');
1864
+ requireText('src/runtime/plugins/store.ts', 'export function syncAssistantPluginManifest');
1865
+ requireText('src/runtime/plugins/store.ts', 'export function removeAssistantPluginManifestProjection');
1866
+ requireText('src/cli/index.ts', 'buildComputerCommand');
1867
+ requireText('src/cli/index.ts', "'computer'");
1868
+
1869
+ forbid('adapters/computer/desktop-operator-provider.ts', /getExternalPluginRegistration|controller-home|computerCapabilities|internalCapabilities|browserAutomationProtocolVersion|browserAutomationActions|macos_browser_automation|computer_execute/, 'Desktop Operator provider transport must consume discovery and negotiation results rather than own Controller lookup or wire negotiation');
1870
+ forbid('adapters/computer/desktop-operator-negotiation.ts', /getExternalPluginRegistration|controller-home|desktop-operator-discovery/, 'Desktop Operator negotiation must depend on protocol/contract facts, not endpoint discovery');
1871
+ forbid('adapters/computer/desktop-operator-discovery.ts', /macos_browser_automation|LEGACY_BROWSER_AUTOMATION/, 'Desktop Operator discovery must own endpoint resolution only, not compatibility protocol negotiation');
1872
+ forbid('adapters/computer/desktop-operator-provider.ts', /getExternalPluginAdapter|AssistantPluginActionExecutionInput|desktop_session_open|NATIVE_BROWSER_BUNDLE_IDS|activateDesktopOperatorBrowserApplication/, 'Desktop Operator Computer transport adapter must not own Runtime plugin-action application activation glue');
1873
+ for (const path of sourceFiles('adapters/computer')) {
1874
+ forbid(path, /AssistantPluginError/, 'Computer adapters must expose provider errors through plugin-runtime rather than depend on Runtime plugin error types');
1875
+ }
1876
+ requireText('src/runtime/root/computer-composition.ts', 'lookupRegistration: (providerPluginId) =>');
1877
+ requireText('src/runtime/root/computer-composition.ts', 'computerProviderRegistrationSnapshot(registration)');
1878
+ requireText('src/runtime/root/computer-composition.ts', 'getExternalPluginAdapter(input.controllerHome, DESKTOP_OPERATOR_PROVIDER_PLUGIN_ID)');
1879
+ requireText('src/runtime/plugins/browser-automation-service.ts', 'executeRuntimeComputerBrowserAutomation');
1880
+ requireText('src/runtime/plugins/browser-adapter.ts', 'activateRuntimeComputerBrowserApplication');
1881
+ forbid('src/runtime/plugins/browser-automation-service.ts', /desktop_operator|macos-capability-broker|desktop-operator\.sock|macos_browser_automation/, 'Browser automation must depend on the provider-neutral Computer boundary, not Desktop Operator transport details');
1882
+ forbid('src/runtime/plugins/browser-adapter.ts', /desktop_operator|Desktop Operator|getExternalPluginAdapter|desktop_session_open/, 'Browser adapter must not know the concrete Desktop Operator application provider');
1883
+ for (const path of sourceFiles('src/runtime/plugins').filter((entry) => /\/browser-(?!registration\.ts)[^/]+\.ts$/.test(entry))) {
1884
+ forbid(path, /desktop_operator|Desktop Operator|desktop-operator\.sock|macos_browser_automation/, 'Browser modules must depend on Computer capabilities rather than concrete Desktop Operator transport identity');
1885
+ }
1886
+ requireText('src/runtime/plugins/macos-capability-broker.ts', '@deprecated C0 compatibility shim');
1887
+ requireText('src/runtime/plugins/macos-capability-broker.ts', 'executeRuntimeComputerBrowserAutomation');
1888
+ forbid('src/runtime/plugins/macos-capability-broker.ts', /callDesktopOperatorComputerBrowserAutomation/, 'Deprecated macOS broker execution must delegate to Runtime Computer composition rather than call the concrete provider directly');
1889
+ requireText('src/runtime/control-plane/facade/types.ts', 'semanticCapabilities?: string[]');
1890
+ forbid('src/runtime/control-plane/facade/capability-registry.ts', /plugin\.desktop_operator/, 'Control Plane capability discovery must rank provider-declared semantic capabilities rather than concrete Desktop Operator plugin identity');
1891
+ requireText('src/runtime/plugins/external-provider-policy.ts', 'resolveExternalProviderPolicy');
1892
+ requireText('src/runtime/plugins/desktop-operator-external-policy.ts', 'verifyExactForegroundDesktopSession');
1893
+ forbid('src/runtime/plugins/external-adapter.ts', /desktop_operator|desktopOperator|DESKTOP_|['\"]desktop_[a-z_]|desktop-operator-external-policy/, 'Generic external plugin adapter must delegate provider-specific Desktop policy through ExternalProviderPolicy');
1894
+ requireText('src/runtime/plugins/desktop-operator-registration.ts', 'COMPUTER_OBSERVE_CAPABILITY');
1895
+ requireText('src/runtime/plugins/desktop-operator-registration.ts', 'COMPUTER_INPUT_CAPABILITY');
1896
+ requireText('src/runtime/plugins/desktop-operator-registration.ts', 'COMPUTER_CAPTURE_CAPABILITY');
1897
+ requireText('src/runtime/plugins/desktop-operator-registration.ts', 'pluginVersion: options.pluginVersion');
1898
+ forbid('src/runtime/plugins/desktop-operator-registration.ts', /pluginVersion:\s*options\.pluginVersion\s*\?\?|pluginVersion:\s*['"]0\./, 'Forge must not invent the Desktop Operator provider release version');
1899
+ requireText('packages/plugin-runtime/external/unix-jsonl-transport.ts', 'EXTERNAL_RPC_METHOD_PATTERN');
1900
+ requireText('src/runtime/plugins/external-unix-socket.ts', 'callExternalUnixJsonl');
1901
+ forbid('src/runtime/plugins/external-unix-socket.ts', /createConnection|EXTERNAL_RPC_METHOD_PATTERN|packages\/protocols\/computer|computer_execute|macos_browser_automation/, 'Runtime external Unix socket compatibility layer must delegate async transport and must not own Computer/Desktop provider method identities');
1902
+ forbid('adapters/computer/desktop-operator-provider.ts', /src\/runtime\/plugins\/external-unix-socket|callExternalUnixSocket/, 'Computer provider adapters must consume provider-neutral plugin-runtime transport rather than Runtime socket implementation');
1903
+
1904
+ // C0 Browser runtime authority: contracts and provider selection belong to plugin-runtime/protocols.
1905
+ requireText('packages/plugin-runtime/browser/runtime-contract.ts', 'export interface BrowserTransaction');
1906
+ requireText('packages/plugin-runtime/browser/provider-registry.ts', 'export class BrowserProviderRegistry');
1907
+ requireText('packages/plugin-runtime/browser/provider-registry.ts', 'export class BrowserProviderSelectionError');
1908
+ forbid('packages/plugin-runtime/browser/provider-registry.ts', /AssistantPluginError|src\/runtime|adapters\//, 'Browser provider selection must remain provider-neutral inside plugin-runtime');
1909
+ requireText('packages/protocols/browser/session.ts', 'export interface BrowserSessionState');
1910
+ for (const path of [
1911
+ 'src/runtime/plugins/browser-runtime-contract.ts',
1912
+ 'src/runtime/plugins/browser-provider-registry.ts',
1913
+ 'src/runtime/plugins/browser-session-types.ts',
1914
+ ]) {
1915
+ requireText(path, '@deprecated C0 compatibility shim');
1916
+ }
1917
+ for (const path of sourceFiles('src/runtime/plugins')) {
1918
+ if (['src/runtime/plugins/browser-runtime-contract.ts', 'src/runtime/plugins/browser-provider-registry.ts', 'src/runtime/plugins/browser-session-types.ts'].includes(path)) continue;
1919
+ forbid(path, /from\s+['"]\.\/browser-(?:runtime-contract|provider-registry|session-types)['"]/, 'active Browser runtime code must consume plugin-runtime/protocol Browser contracts, not retired local owners');
1920
+ }
1921
+ // Computer SurfaceTarget is the only durable interaction-target authority. Browser
1922
+ // compatibility may retain old type/API names, but it must not recreate a Browser
1923
+ // or Desktop authority/persistence owner alongside Computer.
1924
+ requireMissing('adapters/browser/session-authority.ts');
1925
+ requireMissing('adapters/browser/sqlite-session-authority.ts');
1926
+ requireMissing('packages/plugin-runtime/browser/session-persistence.ts');
1927
+ requireMissing('src/runtime/root/browser-session-persistence.ts');
1928
+ forbid('packages/plugin-runtime/browser/session-authority.ts', /\bBrowserSession(?:Authority|Persistence)Port\b/, 'Browser compatibility contracts must not expose a second durable authority or persistence port');
1929
+ requireText('src/runtime/plugins/browser-session-authority.ts', 'findComputerBackedBrowserSession');
1930
+ requireText('src/runtime/plugins/browser-session-authority.ts', 'saveComputerBackedBrowserSession');
1931
+ forbid('src/runtime/plugins/browser-session-authority.ts', /\b(?:writeControlPlaneRecord|deleteControlPlaneRecord|withControlPlaneTransaction|createBrowserSessionAuthority|runtimeBrowserSessionAuthority)\b/, 'Browser compatibility facade must delegate semantic identity to Computer and cannot persist its own authority');
1932
+ requireText('src/runtime/plugins/browser-session-legacy-migration.ts', 'readLegacyBrowserSessionMigrationEntries');
1933
+ forbid('src/runtime/plugins/browser-session-legacy-migration.ts', /\b(?:writeControlPlaneRecord|deleteControlPlaneRecord|withControlPlaneTransaction|createBrowserSessionAuthority|runtimeBrowserSessionAuthority)\b/, 'legacy Browser migration may read retired state but cannot mutate or recreate Browser durable authority');
1934
+ requireText('src/runtime/root/browser-session-composition.ts', 'BrowserSessionExecutionContext');
1935
+ forbid('src/runtime/root/browser-session-composition.ts', /\b(?:createBrowserSessionAuthority|runtimeBrowserSessionAuthority|createRuntimeBrowserSessionPersistence)\b/, 'Browser Runtime composition may carry execution context but cannot compose a second durable interaction authority');
1936
+ for (const path of [
1937
+ ...sourceFiles('adapters/browser'),
1938
+ ...sourceFiles('packages/plugin-runtime/browser'),
1939
+ ...sourceFiles('src/runtime/plugins'),
1940
+ ...sourceFiles('src/runtime/root'),
1941
+ ]) {
1942
+ if (path === 'src/runtime/plugins/browser-session-legacy-migration.ts') continue;
1943
+ forbid(path, LEGACY_INTERACTION_AUTHORITY_OWNER_DECLARATION, 'Browser/Desktop durable interaction authority must live only in Computer target authority');
1944
+ }
1945
+ // Workflow Asset authority: editable content stays in files; machine registry stays metadata-only.
1946
+ requireText('packages/workflow-runtime/domain/workflow-asset.ts', 'export interface WorkflowAssetDefinition');
1947
+ requireText('packages/workflow-runtime/domain/workflow-asset.ts', 'workflowAssetContentDigest');
1948
+ requireText('src/runtime/control-plane/persistence/workflow-content-store.ts', 'ensureControllerWorkflowContentRoot');
1949
+ requireText('src/runtime/control-plane/persistence/workflow-registry-store.ts', "WORKFLOW_REGISTRY_NAMESPACE = 'workflow_registry'");
1950
+ requireText('src/runtime/control-plane/persistence/workflow-registry-store.ts', 'WORKFLOW_REGISTRY_CONTENT_IDENTITY_CHANGED');
1951
+ forbid('src/runtime/control-plane/persistence/workflow-registry-store.ts', /\b(?:prompts|scripts|templates|selectors|resources)\s*:/, 'Workflow machine registry must not persist editable prompt/script/template/selector/resource bodies');
1952
+ for (const path of sourceFiles('packages/workflow-runtime')) {
1953
+ forbid(path, /xiaohongshu|douyin|instagram|reddit|facebook/i, 'generic Workflow Runtime contracts must not own site/business choreography');
1954
+ forbid(path, /from\s+['"][^'"]*(?:src\/runtime|adapters)\//, 'Workflow Runtime package contracts must remain independent from Runtime/adapters implementation authority');
1955
+ }
1956
+ requireText('src/runtime/plugins/browser-registration.ts', 'export const browserPluginAdapter');
1957
+ requireText('src/runtime/plugins/first-party-registry.ts', "from './browser-registration'");
1958
+ forbid('src/runtime/plugins/first-party-registry.ts', /from\s+['"]\.\/browser-adapter['"]/, 'first-party registry must depend on the thin Browser registration entrypoint, not the action implementation');
1959
+ forbid('src/runtime/plugins/browser-adapter.ts', /export\s+const\s+browserPluginAdapter/, 'Browser action implementation must not also own first-party plugin registration');
849
1960
 
850
1961
  if (failures.length) {
851
1962
  console.error('[runtime-architecture] FAILED');