clinkx 1.2.0 → 1.3.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 (270) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +4 -2
  3. package/clinkx-workflows/dist/architecture-arena/admission.d.ts +16 -0
  4. package/clinkx-workflows/dist/architecture-arena/admission.js +107 -0
  5. package/clinkx-workflows/dist/architecture-arena/admission.js.map +1 -0
  6. package/clinkx-workflows/dist/architecture-arena/contract.d.ts +1368 -0
  7. package/clinkx-workflows/dist/architecture-arena/contract.js +254 -0
  8. package/clinkx-workflows/dist/architecture-arena/contract.js.map +1 -0
  9. package/clinkx-workflows/dist/architecture-arena/runtime.d.ts +53 -0
  10. package/clinkx-workflows/dist/architecture-arena/runtime.js +511 -0
  11. package/clinkx-workflows/dist/architecture-arena/runtime.js.map +1 -0
  12. package/clinkx-workflows/dist/architecture-comparison/admission.d.ts +17 -1
  13. package/clinkx-workflows/dist/architecture-comparison/admission.js +27 -4
  14. package/clinkx-workflows/dist/architecture-comparison/admission.js.map +1 -1
  15. package/clinkx-workflows/dist/architecture-comparison/contract.d.ts +59 -62
  16. package/clinkx-workflows/dist/architecture-comparison/contract.js +4 -21
  17. package/clinkx-workflows/dist/architecture-comparison/contract.js.map +1 -1
  18. package/clinkx-workflows/dist/architecture-comparison/runtime.d.ts +4 -3
  19. package/clinkx-workflows/dist/architecture-comparison/runtime.js +22 -67
  20. package/clinkx-workflows/dist/architecture-comparison/runtime.js.map +1 -1
  21. package/clinkx-workflows/dist/artifacts.d.ts +19 -4
  22. package/clinkx-workflows/dist/artifacts.js +16 -7
  23. package/clinkx-workflows/dist/artifacts.js.map +1 -1
  24. package/clinkx-workflows/dist/backend.d.ts +30 -0
  25. package/clinkx-workflows/dist/clink-client.d.ts +8 -2
  26. package/clinkx-workflows/dist/clink-client.js +4 -2
  27. package/clinkx-workflows/dist/clink-client.js.map +1 -1
  28. package/clinkx-workflows/dist/context-preflight.d.ts +6 -0
  29. package/clinkx-workflows/dist/context-preflight.js.map +1 -1
  30. package/clinkx-workflows/dist/council-execution-policy.d.ts +3 -1
  31. package/clinkx-workflows/dist/council-execution-policy.js +4 -0
  32. package/clinkx-workflows/dist/council-execution-policy.js.map +1 -1
  33. package/clinkx-workflows/dist/dashboard/contracts.d.ts +586 -586
  34. package/clinkx-workflows/dist/dashboard/progress-report-contract.d.ts +28 -28
  35. package/clinkx-workflows/dist/dashboard/session-log-contract.d.ts +32 -32
  36. package/clinkx-workflows/dist/dashboard-ui/assets/index-DRId2DVA.js +119 -0
  37. package/clinkx-workflows/dist/dashboard-ui/assets/style-CHAw57y5.css +1 -0
  38. package/clinkx-workflows/dist/dashboard-ui/index.html +2 -2
  39. package/clinkx-workflows/dist/delegate-signature.d.ts +4 -3
  40. package/clinkx-workflows/dist/delegate-signature.js +4 -3
  41. package/clinkx-workflows/dist/delegate-signature.js.map +1 -1
  42. package/clinkx-workflows/dist/durable-file.d.ts +69 -0
  43. package/clinkx-workflows/dist/durable-file.js +145 -0
  44. package/clinkx-workflows/dist/durable-file.js.map +1 -0
  45. package/clinkx-workflows/dist/engine.d.ts +42 -7
  46. package/clinkx-workflows/dist/engine.js +196 -24
  47. package/clinkx-workflows/dist/engine.js.map +1 -1
  48. package/clinkx-workflows/dist/ping-pong/admission.d.ts +127 -0
  49. package/clinkx-workflows/dist/ping-pong/admission.js +522 -0
  50. package/clinkx-workflows/dist/ping-pong/admission.js.map +1 -0
  51. package/clinkx-workflows/dist/ping-pong/contract.d.ts +2539 -0
  52. package/clinkx-workflows/dist/ping-pong/contract.js +819 -0
  53. package/clinkx-workflows/dist/ping-pong/contract.js.map +1 -0
  54. package/clinkx-workflows/dist/ping-pong/control.d.ts +67 -0
  55. package/clinkx-workflows/dist/ping-pong/control.js +12 -0
  56. package/clinkx-workflows/dist/ping-pong/control.js.map +1 -0
  57. package/clinkx-workflows/dist/ping-pong/runtime-handle.d.ts +24 -0
  58. package/clinkx-workflows/dist/ping-pong/runtime-handle.js +55 -0
  59. package/clinkx-workflows/dist/ping-pong/runtime-handle.js.map +1 -0
  60. package/clinkx-workflows/dist/ping-pong/runtime.d.ts +235 -0
  61. package/clinkx-workflows/dist/ping-pong/runtime.js +1183 -0
  62. package/clinkx-workflows/dist/ping-pong/runtime.js.map +1 -0
  63. package/clinkx-workflows/dist/ping-pong/settle.d.ts +57 -0
  64. package/clinkx-workflows/dist/ping-pong/settle.js +58 -0
  65. package/clinkx-workflows/dist/ping-pong/settle.js.map +1 -0
  66. package/clinkx-workflows/dist/ping-pong/sidecar.d.ts +65 -0
  67. package/clinkx-workflows/dist/ping-pong/sidecar.js +138 -0
  68. package/clinkx-workflows/dist/ping-pong/sidecar.js.map +1 -0
  69. package/clinkx-workflows/dist/plan-review/publication.d.ts +2 -1
  70. package/clinkx-workflows/dist/plan-review/publication.js +5 -6
  71. package/clinkx-workflows/dist/plan-review/publication.js.map +1 -1
  72. package/clinkx-workflows/dist/plan-review/snapshot.d.ts +3 -2
  73. package/clinkx-workflows/dist/plan-review/snapshot.js +8 -8
  74. package/clinkx-workflows/dist/plan-review/snapshot.js.map +1 -1
  75. package/clinkx-workflows/dist/recipe-host.d.ts +315 -0
  76. package/clinkx-workflows/dist/recipe-host.js +183 -0
  77. package/clinkx-workflows/dist/recipe-host.js.map +1 -0
  78. package/clinkx-workflows/dist/recipe-seats.d.ts +96 -0
  79. package/clinkx-workflows/dist/recipe-seats.js +163 -0
  80. package/clinkx-workflows/dist/recipe-seats.js.map +1 -0
  81. package/clinkx-workflows/dist/recipe-shared/evidence.d.ts +67 -0
  82. package/clinkx-workflows/dist/recipe-shared/evidence.js +111 -0
  83. package/clinkx-workflows/dist/recipe-shared/evidence.js.map +1 -0
  84. package/clinkx-workflows/dist/reducers/index.d.ts +9 -1
  85. package/clinkx-workflows/dist/reducers/index.js +30 -0
  86. package/clinkx-workflows/dist/reducers/index.js.map +1 -1
  87. package/clinkx-workflows/dist/run-lock-reclaim.d.ts +44 -0
  88. package/clinkx-workflows/dist/run-lock-reclaim.js +86 -0
  89. package/clinkx-workflows/dist/run-lock-reclaim.js.map +1 -0
  90. package/clinkx-workflows/dist/state-schema.d.ts +11 -0
  91. package/clinkx-workflows/dist/state-schema.js +4 -1
  92. package/clinkx-workflows/dist/state-schema.js.map +1 -1
  93. package/clinkx-workflows/dist/state.d.ts +178 -3
  94. package/clinkx-workflows/dist/state.js +618 -83
  95. package/clinkx-workflows/dist/state.js.map +1 -1
  96. package/clinkx-workflows/dist/transport.d.ts +2 -1
  97. package/clinkx-workflows/dist/transport.js +5 -0
  98. package/clinkx-workflows/dist/transport.js.map +1 -1
  99. package/clinkx-workflows/dist/validators/architecture-arena.d.ts +6 -0
  100. package/clinkx-workflows/dist/validators/architecture-arena.js +16 -0
  101. package/clinkx-workflows/dist/validators/architecture-arena.js.map +1 -0
  102. package/clinkx-workflows/dist/validators/index.js +4 -0
  103. package/clinkx-workflows/dist/validators/index.js.map +1 -1
  104. package/clinkx-workflows/dist/validators/ping-pong.d.ts +6 -0
  105. package/clinkx-workflows/dist/validators/ping-pong.js +10 -0
  106. package/clinkx-workflows/dist/validators/ping-pong.js.map +1 -0
  107. package/clinkx-workflows/dist/workflow-tools.d.ts +51 -5
  108. package/clinkx-workflows/dist/workflow-tools.js +785 -34
  109. package/clinkx-workflows/dist/workflow-tools.js.map +1 -1
  110. package/clinkx-workflows/dist/workflow-verification-contract.d.ts +4 -4
  111. package/clinkx-workflows/templates/architecture-arena/candidate.txt +39 -0
  112. package/clinkx-workflows/templates/architecture-arena/judge.txt +34 -0
  113. package/clinkx-workflows/templates/ping-pong/implement.txt +14 -0
  114. package/clinkx-workflows/templates/ping-pong/remediate.txt +14 -0
  115. package/clinkx-workflows/templates/ping-pong/review.txt +27 -0
  116. package/clinkx-workflows/workflows/architecture-arena.yaml +127 -0
  117. package/clinkx-workflows/workflows/ping-pong.yaml +158 -0
  118. package/dist/context-builder/bundle.js +4 -3
  119. package/dist/context-builder/bundle.js.map +1 -1
  120. package/dist/context-builder/delegate-packet.d.ts +1 -0
  121. package/dist/context-builder/delegate-packet.js +66 -7
  122. package/dist/context-builder/delegate-packet.js.map +1 -1
  123. package/dist/context-builder/delegate-validation.d.ts +12 -3
  124. package/dist/context-builder/delegate-validation.js +23 -13
  125. package/dist/context-builder/delegate-validation.js.map +1 -1
  126. package/dist/context-builder/external-gaps.d.ts +14 -3
  127. package/dist/context-builder/external-gaps.js +124 -18
  128. package/dist/context-builder/external-gaps.js.map +1 -1
  129. package/dist/context-builder/handler.js +108 -191
  130. package/dist/context-builder/handler.js.map +1 -1
  131. package/dist/context-builder/review-coverage.js +27 -1
  132. package/dist/context-builder/review-coverage.js.map +1 -1
  133. package/dist/context-builder/secrets.js +1 -1
  134. package/dist/context-builder/secrets.js.map +1 -1
  135. package/dist/context-builder/versions.d.ts +10 -4
  136. package/dist/context-builder/versions.js +10 -4
  137. package/dist/context-builder/versions.js.map +1 -1
  138. package/dist/context-builder/workflow-runner.js +33 -24
  139. package/dist/context-builder/workflow-runner.js.map +1 -1
  140. package/dist/dashboard-cli.d.ts +2 -0
  141. package/dist/dashboard-cli.js +147 -57
  142. package/dist/dashboard-cli.js.map +1 -1
  143. package/dist/dashboard-companion/client.d.ts +10 -0
  144. package/dist/dashboard-companion/client.js +43 -1
  145. package/dist/dashboard-companion/client.js.map +1 -1
  146. package/dist/dashboard-companion/config.d.ts +19 -1
  147. package/dist/dashboard-companion/config.js +104 -3
  148. package/dist/dashboard-companion/config.js.map +1 -1
  149. package/dist/dashboard-companion/protocol.d.ts +16 -0
  150. package/dist/dashboard-companion/protocol.js +38 -1
  151. package/dist/dashboard-companion/protocol.js.map +1 -1
  152. package/dist/dashboard-companion/workstation-binding.d.ts +69 -0
  153. package/dist/dashboard-companion/workstation-binding.js +192 -0
  154. package/dist/dashboard-companion/workstation-binding.js.map +1 -0
  155. package/dist/dashboard-gateway/admin-cli.d.ts +10 -0
  156. package/dist/dashboard-gateway/admin-cli.js +266 -0
  157. package/dist/dashboard-gateway/admin-cli.js.map +1 -0
  158. package/dist/dashboard-gateway/config.d.ts +50 -0
  159. package/dist/dashboard-gateway/config.js +235 -1
  160. package/dist/dashboard-gateway/config.js.map +1 -1
  161. package/dist/dashboard-gateway/connection-registry.d.ts +100 -0
  162. package/dist/dashboard-gateway/connection-registry.js +228 -0
  163. package/dist/dashboard-gateway/connection-registry.js.map +1 -0
  164. package/dist/dashboard-gateway/control-plane/account-auth.d.ts +78 -0
  165. package/dist/dashboard-gateway/control-plane/account-auth.js +198 -0
  166. package/dist/dashboard-gateway/control-plane/account-auth.js.map +1 -0
  167. package/dist/dashboard-gateway/control-plane/billing.d.ts +264 -0
  168. package/dist/dashboard-gateway/control-plane/billing.js +787 -0
  169. package/dist/dashboard-gateway/control-plane/billing.js.map +1 -0
  170. package/dist/dashboard-gateway/control-plane/contracts.d.ts +1293 -0
  171. package/dist/dashboard-gateway/control-plane/contracts.js +280 -0
  172. package/dist/dashboard-gateway/control-plane/contracts.js.map +1 -0
  173. package/dist/dashboard-gateway/control-plane/cookies.d.ts +13 -0
  174. package/dist/dashboard-gateway/control-plane/cookies.js +46 -0
  175. package/dist/dashboard-gateway/control-plane/cookies.js.map +1 -0
  176. package/dist/dashboard-gateway/control-plane/credentials.d.ts +63 -0
  177. package/dist/dashboard-gateway/control-plane/credentials.js +66 -0
  178. package/dist/dashboard-gateway/control-plane/credentials.js.map +1 -0
  179. package/dist/dashboard-gateway/control-plane/entitlements.d.ts +118 -0
  180. package/dist/dashboard-gateway/control-plane/entitlements.js +329 -0
  181. package/dist/dashboard-gateway/control-plane/entitlements.js.map +1 -0
  182. package/dist/dashboard-gateway/control-plane/errors.d.ts +17 -0
  183. package/dist/dashboard-gateway/control-plane/errors.js +23 -0
  184. package/dist/dashboard-gateway/control-plane/errors.js.map +1 -0
  185. package/dist/dashboard-gateway/control-plane/hosts.d.ts +6 -0
  186. package/dist/dashboard-gateway/control-plane/hosts.js +16 -0
  187. package/dist/dashboard-gateway/control-plane/hosts.js.map +1 -0
  188. package/dist/dashboard-gateway/control-plane/http.d.ts +34 -0
  189. package/dist/dashboard-gateway/control-plane/http.js +331 -0
  190. package/dist/dashboard-gateway/control-plane/http.js.map +1 -0
  191. package/dist/dashboard-gateway/control-plane/schema.d.ts +9 -0
  192. package/dist/dashboard-gateway/control-plane/schema.js +247 -0
  193. package/dist/dashboard-gateway/control-plane/schema.js.map +1 -0
  194. package/dist/dashboard-gateway/control-plane/secrets.d.ts +20 -0
  195. package/dist/dashboard-gateway/control-plane/secrets.js +39 -0
  196. package/dist/dashboard-gateway/control-plane/secrets.js.map +1 -0
  197. package/dist/dashboard-gateway/control-plane/store.d.ts +579 -0
  198. package/dist/dashboard-gateway/control-plane/store.js +1115 -0
  199. package/dist/dashboard-gateway/control-plane/store.js.map +1 -0
  200. package/dist/dashboard-gateway/cookie-boundary.d.ts +60 -0
  201. package/dist/dashboard-gateway/cookie-boundary.js +205 -0
  202. package/dist/dashboard-gateway/cookie-boundary.js.map +1 -0
  203. package/dist/dashboard-gateway/index.js +271 -494
  204. package/dist/dashboard-gateway/index.js.map +1 -1
  205. package/dist/dashboard-gateway/main.js +7 -2
  206. package/dist/dashboard-gateway/main.js.map +1 -1
  207. package/dist/dashboard-gateway/routing.d.ts +43 -0
  208. package/dist/dashboard-gateway/routing.js +65 -0
  209. package/dist/dashboard-gateway/routing.js.map +1 -0
  210. package/dist/dashboard-gateway/tenant-gateway.d.ts +56 -0
  211. package/dist/dashboard-gateway/tenant-gateway.js +989 -0
  212. package/dist/dashboard-gateway/tenant-gateway.js.map +1 -0
  213. package/dist/dashboard-gateway/tenant-main.d.ts +41 -0
  214. package/dist/dashboard-gateway/tenant-main.js +303 -0
  215. package/dist/dashboard-gateway/tenant-main.js.map +1 -0
  216. package/dist/dashboard-gateway/tunnel-errors.d.ts +16 -0
  217. package/dist/dashboard-gateway/tunnel-errors.js +22 -0
  218. package/dist/dashboard-gateway/tunnel-errors.js.map +1 -0
  219. package/dist/dashboard-gateway/tunnel-http.d.ts +21 -0
  220. package/dist/dashboard-gateway/tunnel-http.js +175 -0
  221. package/dist/dashboard-gateway/tunnel-http.js.map +1 -0
  222. package/dist/handler.d.ts +6 -0
  223. package/dist/handler.js +17 -1
  224. package/dist/handler.js.map +1 -1
  225. package/dist/local-clink-backend.d.ts +2 -1
  226. package/dist/local-clink-backend.js +28 -4
  227. package/dist/local-clink-backend.js.map +1 -1
  228. package/dist/parsers/extract.d.ts +19 -1
  229. package/dist/parsers/extract.js +68 -3
  230. package/dist/parsers/extract.js.map +1 -1
  231. package/dist/pipeline.d.ts +17 -1
  232. package/dist/pipeline.js +34 -6
  233. package/dist/pipeline.js.map +1 -1
  234. package/dist/process-group.d.ts +65 -0
  235. package/dist/process-group.js +153 -0
  236. package/dist/process-group.js.map +1 -0
  237. package/dist/progress-report/schema.d.ts +23 -23
  238. package/dist/project-verification/files.js +1 -1
  239. package/dist/project-verification/files.js.map +1 -1
  240. package/dist/project-verification/process.js +23 -44
  241. package/dist/project-verification/process.js.map +1 -1
  242. package/dist/project-verification/service.js +9 -1
  243. package/dist/project-verification/service.js.map +1 -1
  244. package/dist/prompt.d.ts +7 -0
  245. package/dist/prompt.js +18 -1
  246. package/dist/prompt.js.map +1 -1
  247. package/dist/recipe-host/git-trust.d.ts +43 -0
  248. package/dist/recipe-host/git-trust.js +360 -0
  249. package/dist/recipe-host/git-trust.js.map +1 -0
  250. package/dist/recipe-host/git.d.ts +42 -0
  251. package/dist/recipe-host/git.js +207 -0
  252. package/dist/recipe-host/git.js.map +1 -0
  253. package/dist/recipe-host/native-recipe-host.d.ts +127 -0
  254. package/dist/recipe-host/native-recipe-host.js +880 -0
  255. package/dist/recipe-host/native-recipe-host.js.map +1 -0
  256. package/dist/recipe-host/seat-cwd.d.ts +16 -0
  257. package/dist/recipe-host/seat-cwd.js +170 -0
  258. package/dist/recipe-host/seat-cwd.js.map +1 -0
  259. package/dist/runner.d.ts +43 -1
  260. package/dist/runner.js +234 -35
  261. package/dist/runner.js.map +1 -1
  262. package/dist/server.js +9 -1
  263. package/dist/server.js.map +1 -1
  264. package/docs/configuration.md +24 -3
  265. package/docs/engineering-recipes.md +291 -0
  266. package/docs/security.md +84 -0
  267. package/docs/verification/project-checks.md +24 -2
  268. package/package.json +5 -1
  269. package/clinkx-workflows/dist/dashboard-ui/assets/index-BdpmbPps.js +0 -115
  270. package/clinkx-workflows/dist/dashboard-ui/assets/style-Im5i1iAs.css +0 -1
@@ -0,0 +1,315 @@
1
+ /**
2
+ * Root-owned recipe workspace capability (PLAN 1-8, 1-9, 1-10; CONTRACTS C5, 0-3).
3
+ *
4
+ * The workflows package has no git or allowed-roots policy of its own, so the
5
+ * root server injects a `RecipeHost` the way it injects `VerifiedRepairHost`.
6
+ * The standalone `createWorkflowServer` injects none, and worktree recipes are
7
+ * rejected there before preflight or state (`assertRecipeHostAvailable`).
8
+ *
9
+ * Error contract for implementations: admission-class failures (missing grant,
10
+ * invalid run/seat id, non-commit baseline, run-ID recycling) throw
11
+ * `McpError(ErrorCode.InvalidParams)`; git/filesystem execution failures throw
12
+ * `RecipeHostError`.
13
+ */
14
+ import { WorkflowError } from "./errors.js";
15
+ /** Recipe sidecar written by the recipe runtime inside the run directory. */
16
+ export declare const RECIPE_STATE_FILENAME = "recipe-state.json";
17
+ /** CONTRACTS 0-4: sidecar <= 1 MiB. */
18
+ export declare const MAX_RECIPE_STATE_BYTES: number;
19
+ /**
20
+ * Disclosure for the 1-9 grant. The unmarked entry is required so seats and
21
+ * host-side checks can address the worktrees; it does not make context_builder
22
+ * scan them unless a call names that root.
23
+ */
24
+ export declare const RECIPE_WORKSPACE_GRANT_DISCLOSURE: string;
25
+ /** Workflows that create host-owned worktrees and therefore need a `RecipeHost`. */
26
+ export declare const WORKTREE_RECIPE_WORKFLOWS: readonly string[];
27
+ export declare class RecipeHostError extends WorkflowError {
28
+ readonly operation: string;
29
+ constructor(message: string, operation: string);
30
+ }
31
+ /**
32
+ * One shared git-metadata file recorded at worktree creation (D4c). Holds
33
+ * digests only, never config values: `sha256` of the raw bytes, and for
34
+ * config files the digest of the non-allowlisted entries (in order) plus one
35
+ * digest per non-allowlisted key, so a later drift can be named by key.
36
+ */
37
+ export interface RecipeGitMetadataFile {
38
+ /** `common/<file>` or `worktree/<file>`. */
39
+ readonly name: string;
40
+ /** Absolute path checked before every host git operation. */
41
+ readonly path: string;
42
+ readonly kind: "config" | "raw";
43
+ readonly state: "absent" | "file" | "symlink" | "other";
44
+ readonly sha256?: string | undefined;
45
+ readonly entries_sha256?: string | undefined;
46
+ /** Omitted when the file has more non-allowlisted keys than are recorded. */
47
+ readonly keys?: Readonly<Record<string, string>> | undefined;
48
+ }
49
+ export interface RecipeGitMetadataSnapshot {
50
+ readonly version: 1;
51
+ /** sha256 over the canonical `files`; a mismatch means a corrupt snapshot. */
52
+ readonly digest: string;
53
+ readonly files: readonly RecipeGitMetadataFile[];
54
+ }
55
+ /**
56
+ * Writer-controlled text (git accepts key names of hundreds of KB) is
57
+ * redacted on the server thread, and the patterns are still superlinear in
58
+ * the number of `://`; anything longer is replaced, never scanned.
59
+ */
60
+ export declare const REDACTION_MAX_INPUT_CHARS = 1024;
61
+ /**
62
+ * Replaces URL userinfo and every query value with `***`, keeping parameter
63
+ * names. Text over {@link REDACTION_MAX_INPUT_CHARS} becomes the value-free
64
+ * `<label of N chars>`. Idempotent.
65
+ */
66
+ export declare function redactUrlCredentials(text: string, label?: string): string;
67
+ /**
68
+ * Shared git metadata (config, attributes, excludes) differs from the
69
+ * snapshot taken at worktree creation. Thrown before git is spawned; names
70
+ * the file and keys, never values. The recipe stops `recovery_required`.
71
+ */
72
+ export declare class RecipeGitMetadataDriftError extends RecipeHostError {
73
+ readonly file: string;
74
+ readonly keys: readonly string[];
75
+ /** Absolute path of the drifted file (or admin dir); absent when unknown. */
76
+ readonly path: string | undefined;
77
+ /** `config` and `raw` are recorded metadata files; absent for a re-pointed dir or a corrupt snapshot. */
78
+ readonly fileKind: "config" | "raw" | undefined;
79
+ /** Value-free description, the same text the message embeds. */
80
+ readonly detail: string | undefined;
81
+ /** Every changed key name with how it changed; never values. */
82
+ readonly changes: readonly RecipeGitMetadataKeyChange[];
83
+ constructor(message: string, file: string, keys: readonly string[], details?: {
84
+ readonly path?: string | undefined;
85
+ readonly fileKind?: "config" | "raw" | undefined;
86
+ readonly detail?: string | undefined;
87
+ readonly changes?: readonly RecipeGitMetadataKeyChange[] | undefined;
88
+ });
89
+ }
90
+ export interface RecipeGitMetadataKeyChange {
91
+ readonly key: string;
92
+ readonly change: "added" | "changed" | "removed";
93
+ }
94
+ export interface RecipeWorkspaceGrant {
95
+ /** Canonical `${CLINKX_HOME}/workspaces` (best effort when not yet created). */
96
+ readonly workspacesRoot: string;
97
+ /** The unmarked allowed-roots entry that satisfied the grant. */
98
+ readonly grantEntry: string;
99
+ }
100
+ export interface CreateRecipeWorkspaceOptions {
101
+ readonly runId: string;
102
+ /** `implementer` or `author-<i>` by convention; grammar-checked. */
103
+ readonly seat: string;
104
+ /** Absolute path inside the source repository. */
105
+ readonly repoRoot: string;
106
+ /** Full hex commit id; never a ref or the working tree. */
107
+ readonly baseline: string;
108
+ readonly signal?: AbortSignal | undefined;
109
+ }
110
+ export interface RecipeWorkspace {
111
+ /** Canonical `${CLINKX_HOME}/workspaces/<runId>/<seat>`. */
112
+ readonly path: string;
113
+ readonly baseline: string;
114
+ readonly headAtCreate: string;
115
+ /**
116
+ * Shared git-metadata snapshot taken at creation. The caller persists it
117
+ * and passes it back on every later call, so a restart rechecks against
118
+ * the original rather than a fresh snapshot.
119
+ */
120
+ readonly gitMetadata?: RecipeGitMetadataSnapshot | undefined;
121
+ }
122
+ /**
123
+ * One snapshot of a worktree candidate. `identity` is the git tree id (what
124
+ * reviewers echo and the delta is computed from); `witness` is the sha256 of
125
+ * the raw bytes, modes and symlink targets of the same path list. Clean
126
+ * filters and eol conversion can give different bytes one tree id, so the
127
+ * witness decides whether a candidate changed.
128
+ */
129
+ export interface RecipeCandidate {
130
+ readonly identity: string;
131
+ readonly witness: string;
132
+ }
133
+ export interface RecipeWorkspaceDelta {
134
+ /** Candidate identity of the same snapshot the patch describes (0-3). */
135
+ readonly identity: string;
136
+ /** Byte witness of the same snapshot (see `RecipeCandidate`). */
137
+ readonly witness: string;
138
+ /** `git diff --binary <baseline> <identity>`, complete (never truncated). */
139
+ readonly patch: Buffer;
140
+ readonly patchBytes: number;
141
+ /** `git diff --stat <baseline> <identity>`. */
142
+ readonly stat: string;
143
+ }
144
+ export interface CaptureRecipeDeltaOptions {
145
+ /** Fail when the patch exceeds this many bytes. Default 16 MiB. */
146
+ readonly maxPatchBytes?: number | undefined;
147
+ readonly signal?: AbortSignal | undefined;
148
+ /** Recheck this snapshot before every git operation of the call. */
149
+ readonly gitMetadata?: RecipeGitMetadataSnapshot | undefined;
150
+ }
151
+ /** What the recipe sidecar proves the run owns; the only input to `removeWorkspaces`. */
152
+ export interface RecipeWorkspaceInventory {
153
+ /** Sidecar `baseline.repo_root`; seats must verify against its git common dir. */
154
+ readonly repoRoot: string | undefined;
155
+ /** Sidecar `worktrees[].path`; no other run-dir entry is ever removed. */
156
+ readonly worktreePaths: readonly string[];
157
+ }
158
+ export interface RemoveRecipeWorkspacesResult {
159
+ readonly removed: readonly string[];
160
+ /** Owned admin dirs that survived `git worktree remove`; reported, never deleted. */
161
+ readonly leftoverRegistrations?: readonly string[];
162
+ /**
163
+ * Run-dir entries left in place (not inventoried, or not verified against
164
+ * the sidecar's repository). The run dir is kept while any remain, and the
165
+ * run's prune must be vetoed.
166
+ */
167
+ readonly remaining?: readonly string[];
168
+ }
169
+ /** Host-side check of a recipe worktree through the shared native verification slot (3-7). */
170
+ export interface RecipeVerificationRequest {
171
+ readonly runId: string;
172
+ /** Owned worktree (the project under verification). */
173
+ readonly worktree: string;
174
+ /** Repository-relative acceptance (check) manifest, read from the worktree. */
175
+ readonly manifest: string;
176
+ /** Repository-relative copy-preparation manifest, run first when declared. */
177
+ readonly copyPreparationManifest?: string | undefined;
178
+ /** Absolute evidence directory (must not exist; parent must). Outside the worktree. */
179
+ readonly evidenceDir: string;
180
+ readonly signal?: AbortSignal | undefined;
181
+ /** Recheck this snapshot before every git operation of the call. */
182
+ readonly gitMetadata?: RecipeGitMetadataSnapshot | undefined;
183
+ }
184
+ export interface RecipeVerificationResult {
185
+ readonly status: "passed" | "failed" | "incomplete";
186
+ /** Bounded, host-written summary (check ids and reasons; never command output). */
187
+ readonly summary: string;
188
+ /**
189
+ * True only when every check that ran recorded a confirmed process-group
190
+ * cleanup. False (e.g. a `cleanup_failure` result) means a check process may
191
+ * still be running: the recipe must not advance on this verification, and
192
+ * `status` is then never `passed`.
193
+ */
194
+ readonly cleanupConfirmed: boolean;
195
+ }
196
+ /** The shared verification slot was busy; nothing ran. Callers wait (bounded) and retry. */
197
+ export declare class RecipeVerificationBusyError extends RecipeHostError {
198
+ constructor(message?: string);
199
+ }
200
+ /** Root-owned capability; every git operation on a recipe worktree goes through it. */
201
+ /** Kind of a baseline tree entry: mode 040000, 100644/100755, 120000, 160000, or absent. */
202
+ export type RecipeBaselinePathType = "tree" | "file" | "symlink" | "gitlink" | "missing";
203
+ export interface RecipeBaselinePathEntry {
204
+ readonly path: string;
205
+ readonly type: RecipeBaselinePathType;
206
+ /** For `missing`: the ancestor that exists in the baseline but is not a tree. */
207
+ readonly blockedBy?: {
208
+ readonly path: string;
209
+ readonly type: "file" | "symlink" | "gitlink";
210
+ } | undefined;
211
+ }
212
+ export interface RecipeHost {
213
+ /** 1-9: require an unmarked grant covering the workspaces dir; never an ancestor of the state dir. */
214
+ assertWorkspaceGrant(): Promise<RecipeWorkspaceGrant>;
215
+ /** Run-ID recycling guard (read-only): `${CLINKX_HOME}/workspaces/<runId>` must not exist. */
216
+ assertRunWorkspacesAbsent(runId: string): Promise<void>;
217
+ /** Exclusively create `${CLINKX_HOME}/workspaces/<runId>`; an existing dir is run-ID recycling. */
218
+ reserveRunWorkspaces(runId: string): Promise<string>;
219
+ /** Resolve a revision of `repoRoot` to its full commit id (for pinning a baseline at admission). */
220
+ resolveBaseline(repoRoot: string, rev: string, signal?: AbortSignal): Promise<string>;
221
+ /** 1-8: `git worktree add --detach <seat path> <baseline>` inside a reserved run dir. */
222
+ createWorkspace(options: CreateRecipeWorkspaceOptions): Promise<RecipeWorkspace>;
223
+ /**
224
+ * 0-3: tree id from a throwaway index; the real index is never touched.
225
+ * Every method taking `gitMetadata` rechecks it before each git spawn and
226
+ * throws `RecipeGitMetadataDriftError` on drift.
227
+ */
228
+ captureIdentity(path: string, baseline: string, signal?: AbortSignal, gitMetadata?: RecipeGitMetadataSnapshot): Promise<string>;
229
+ /** Tree id and byte witness of one throwaway-index snapshot. */
230
+ captureCandidate(path: string, baseline: string, signal?: AbortSignal, gitMetadata?: RecipeGitMetadataSnapshot): Promise<RecipeCandidate>;
231
+ /** Fail when HEAD is no longer detached at `expectedHead` (writers must not run git). */
232
+ assertHeadUnmoved(path: string, expectedHead: string, signal?: AbortSignal, gitMetadata?: RecipeGitMetadataSnapshot): Promise<void>;
233
+ /** Tracked and untracked non-ignored changes vs `baseline`, bounded. */
234
+ captureDelta(path: string, baseline: string, options?: CaptureRecipeDeltaOptions): Promise<RecipeWorkspaceDelta>;
235
+ /**
236
+ * Scoped removal: `git worktree remove --force` for each inventoried seat
237
+ * that verifies against the inventory repository (fresh common-dir lookup),
238
+ * then the run dir only once it is empty. Anything else is left in place
239
+ * and reported in `remaining`. Never a repository-wide `git worktree
240
+ * prune`, which would expire unrelated registrations.
241
+ */
242
+ removeWorkspaces(runId: string, inventory: RecipeWorkspaceInventory, signal?: AbortSignal): Promise<RemoveRecipeWorkspacesResult>;
243
+ /**
244
+ * Admission check: each repository-relative path is a regular file blob
245
+ * (mode 100644/100755; never a symlink, gitlink or tree) in the pinned
246
+ * `baseline` commit. Throws `McpError(InvalidParams)` naming the first
247
+ * offending path.
248
+ */
249
+ assertBaselineFiles?(repoRoot: string, baseline: string, paths: readonly string[], signal?: AbortSignal): Promise<void>;
250
+ /** Canonical `git rev-parse --show-toplevel` of `repoRoot` (host-isolated git). */
251
+ repositoryToplevel?(repoRoot: string, signal?: AbortSignal): Promise<string>;
252
+ /**
253
+ * Context anchors (D-B): what each repository-relative path is in the
254
+ * pinned `baseline` tree, in input order. A path below a non-tree entry
255
+ * (for example a symlinked directory) is `missing` with that entry as
256
+ * `blockedBy`. Policy is the caller's (ping-pong admission). Throws
257
+ * `McpError(InvalidParams)` for a path that is not repository-relative.
258
+ */
259
+ describeBaselinePaths?(repoRoot: string, baseline: string, paths: readonly string[], signal?: AbortSignal): Promise<RecipeBaselinePathEntry[]>;
260
+ /**
261
+ * Undo an admission that failed before any seat dispatch, bound to the
262
+ * ownership THIS host instance recorded: the run dir must still be the
263
+ * exact directory `reserveRunWorkspaces` created (same dev+ino), and every
264
+ * entry in it must be a seat this instance's `createWorkspace` started
265
+ * (recorded before `git worktree add`; same dev+ino once completed) that
266
+ * verifies against the recorded repository and back-pointer. Only then are
267
+ * those seats removed and the reservation released. Any mismatch, unknown
268
+ * entry, or missing record refuses the whole cleanup and leaves everything
269
+ * in place (`released: false`); foreign content is never deleted. Rollback
270
+ * git calls use a fresh bounded signal, never `signal`, which is often the
271
+ * very abort being rolled back.
272
+ */
273
+ releaseUnadmittedRun?(runId: string, signal?: AbortSignal): Promise<{
274
+ readonly released: boolean;
275
+ readonly removed: readonly string[];
276
+ readonly reason?: string;
277
+ /** Owned admin dirs that survived `git worktree remove`; reported, never deleted. */
278
+ readonly leftoverRegistrations?: readonly string[];
279
+ }>;
280
+ /** True when `repoRoot` has tracked or untracked non-ignored changes (excluded from a HEAD baseline). */
281
+ hasUncommittedChanges?(repoRoot: string, signal?: AbortSignal): Promise<boolean>;
282
+ /**
283
+ * Run the copy-preparation manifest (when declared) and the acceptance
284
+ * manifest against the worktree. Throws `RecipeVerificationBusyError` when
285
+ * the shared slot is busy; absent on hosts without native verification.
286
+ */
287
+ verifyWorkspace?(request: RecipeVerificationRequest): Promise<RecipeVerificationResult>;
288
+ }
289
+ /** Needs the root recipe host; list_workflows advertises it as `root_only` and hides it without one. */
290
+ export declare function isRootOnlyWorkflow(workflow: string): boolean;
291
+ /**
292
+ * 1-10: worktree recipes need the root host. Call before preflight, state, or
293
+ * workspace creation. Other workflows (including `architecture-arena`) pass.
294
+ */
295
+ export declare function assertRecipeHostAvailable(workflow: string, options: {
296
+ readonly recipeHost?: RecipeHost | undefined;
297
+ }): void;
298
+ /**
299
+ * Tolerant prune-time view of the recipe sidecar. Phase 3 owns the full
300
+ * schema; this reads only what retention needs and treats anything it cannot
301
+ * prove as unresolved.
302
+ */
303
+ export type RecipePruneSummary = {
304
+ readonly kind: "unreadable";
305
+ readonly reason: string;
306
+ } | {
307
+ readonly kind: "read";
308
+ /** Undefined when absent or not a non-negative integer (treat as unresolved). */
309
+ readonly unresolvedOperations: number | undefined;
310
+ /** Undefined when `worktrees` is absent or malformed (unknown inventory). */
311
+ readonly worktreePaths: readonly string[] | undefined;
312
+ /** `baseline.repo_root` when it is a string. */
313
+ readonly repoRoot: string | undefined;
314
+ };
315
+ export declare function readRecipePruneSummary(runDir: string): Promise<RecipePruneSummary>;
@@ -0,0 +1,183 @@
1
+ /**
2
+ * Root-owned recipe workspace capability (PLAN 1-8, 1-9, 1-10; CONTRACTS C5, 0-3).
3
+ *
4
+ * The workflows package has no git or allowed-roots policy of its own, so the
5
+ * root server injects a `RecipeHost` the way it injects `VerifiedRepairHost`.
6
+ * The standalone `createWorkflowServer` injects none, and worktree recipes are
7
+ * rejected there before preflight or state (`assertRecipeHostAvailable`).
8
+ *
9
+ * Error contract for implementations: admission-class failures (missing grant,
10
+ * invalid run/seat id, non-commit baseline, run-ID recycling) throw
11
+ * `McpError(ErrorCode.InvalidParams)`; git/filesystem execution failures throw
12
+ * `RecipeHostError`.
13
+ */
14
+ import { ErrorCode, McpError } from "@modelcontextprotocol/sdk/types.js";
15
+ import { readContainedRelativeFile } from "./contained-file.js";
16
+ import { WorkflowError } from "./errors.js";
17
+ import { PING_PONG_WORKFLOW } from "./recipe-seats.js";
18
+ /** Recipe sidecar written by the recipe runtime inside the run directory. */
19
+ export const RECIPE_STATE_FILENAME = "recipe-state.json";
20
+ /** CONTRACTS 0-4: sidecar <= 1 MiB. */
21
+ export const MAX_RECIPE_STATE_BYTES = 1024 * 1024;
22
+ /**
23
+ * Disclosure for the 1-9 grant. The unmarked entry is required so seats and
24
+ * host-side checks can address the worktrees; it does not make context_builder
25
+ * scan them unless a call names that root.
26
+ */
27
+ export const RECIPE_WORKSPACE_GRANT_DISCLOSURE = "Worktree recipes require an unmarked CLINKX_ALLOWED_ROOTS entry covering ${CLINKX_HOME}/workspaces. " +
28
+ "That entry makes the workspaces directory an eligible context_builder source root; context_builder scans " +
29
+ "it only when a call names it as a root.";
30
+ /** Workflows that create host-owned worktrees and therefore need a `RecipeHost`. */
31
+ export const WORKTREE_RECIPE_WORKFLOWS = [PING_PONG_WORKFLOW];
32
+ export class RecipeHostError extends WorkflowError {
33
+ operation;
34
+ constructor(message, operation) {
35
+ super(message);
36
+ this.operation = operation;
37
+ this.name = "RecipeHostError";
38
+ }
39
+ }
40
+ /**
41
+ * Git keeps URLs in key names (`url.<base>.*`, `http.<url>.*`,
42
+ * `credential.<url>.*`, `includeIf.hasconfig:remote.*.url:<url>`), so a key
43
+ * name can carry a credential. Userinfo is greedy to the last `@` before the
44
+ * path, so an unencoded `@` inside it cannot leave part of it behind. The
45
+ * scheme is bounded so a long scheme-like run costs linear time; a longer run
46
+ * still matches at its last 32 characters. It need not start with a letter,
47
+ * so a writer-crafted all-digit tail before `://` is still redacted.
48
+ */
49
+ const URL_USERINFO = /([A-Za-z0-9+.-]{1,32}:\/\/)[^/]*@/g;
50
+ /**
51
+ * A query runs to whitespace or a fragment. In a key name that swallows the
52
+ * trailing `.<variable>` too: a token may itself contain dots (a JWT), so
53
+ * no dot can be trusted to end it.
54
+ */
55
+ const URL_QUERY = /([A-Za-z0-9+.-]{1,32}:\/\/[^\s?#]*\?)([^\s#]*)/g;
56
+ /**
57
+ * Writer-controlled text (git accepts key names of hundreds of KB) is
58
+ * redacted on the server thread, and the patterns are still superlinear in
59
+ * the number of `://`; anything longer is replaced, never scanned.
60
+ */
61
+ export const REDACTION_MAX_INPUT_CHARS = 1024;
62
+ function redactQuery(query) {
63
+ return query
64
+ .split(/([&;])/)
65
+ .map((part) => {
66
+ if (part === "" || part === "&" || part === ";")
67
+ return part;
68
+ const eq = part.indexOf("=");
69
+ // A bare parameter may be the credential itself.
70
+ return eq < 0 ? "***" : `${part.slice(0, eq)}=***`;
71
+ })
72
+ .join("");
73
+ }
74
+ /**
75
+ * Replaces URL userinfo and every query value with `***`, keeping parameter
76
+ * names. Text over {@link REDACTION_MAX_INPUT_CHARS} becomes the value-free
77
+ * `<label of N chars>`. Idempotent.
78
+ */
79
+ export function redactUrlCredentials(text, label = "text") {
80
+ if (text.length > REDACTION_MAX_INPUT_CHARS)
81
+ return `<${label} of ${text.length} chars>`;
82
+ return text
83
+ .replace(URL_USERINFO, "$1***@")
84
+ .replace(URL_QUERY, (_match, prefix, query) => `${prefix}${redactQuery(query)}`);
85
+ }
86
+ /**
87
+ * Shared git metadata (config, attributes, excludes) differs from the
88
+ * snapshot taken at worktree creation. Thrown before git is spawned; names
89
+ * the file and keys, never values. The recipe stops `recovery_required`.
90
+ */
91
+ export class RecipeGitMetadataDriftError extends RecipeHostError {
92
+ file;
93
+ keys;
94
+ /** Absolute path of the drifted file (or admin dir); absent when unknown. */
95
+ path;
96
+ /** `config` and `raw` are recorded metadata files; absent for a re-pointed dir or a corrupt snapshot. */
97
+ fileKind;
98
+ /** Value-free description, the same text the message embeds. */
99
+ detail;
100
+ /** Every changed key name with how it changed; never values. */
101
+ changes;
102
+ constructor(message, file, keys, details = {}) {
103
+ super(message, "git_metadata_drift");
104
+ this.file = file;
105
+ this.keys = keys;
106
+ this.name = "RecipeGitMetadataDriftError";
107
+ this.path = details.path;
108
+ this.fileKind = details.fileKind;
109
+ this.detail = details.detail;
110
+ this.changes = details.changes ?? [];
111
+ }
112
+ }
113
+ /** The shared verification slot was busy; nothing ran. Callers wait (bounded) and retry. */
114
+ export class RecipeVerificationBusyError extends RecipeHostError {
115
+ constructor(message = "native verification slot is busy") {
116
+ super(message, "verification_busy");
117
+ this.name = "RecipeVerificationBusyError";
118
+ }
119
+ }
120
+ /** Needs the root recipe host; list_workflows advertises it as `root_only` and hides it without one. */
121
+ export function isRootOnlyWorkflow(workflow) {
122
+ return WORKTREE_RECIPE_WORKFLOWS.includes(workflow);
123
+ }
124
+ /**
125
+ * 1-10: worktree recipes need the root host. Call before preflight, state, or
126
+ * workspace creation. Other workflows (including `architecture-arena`) pass.
127
+ */
128
+ export function assertRecipeHostAvailable(workflow, options) {
129
+ if (isRootOnlyWorkflow(workflow) && options.recipeHost === undefined) {
130
+ throw new McpError(ErrorCode.InvalidParams, `${workflow} requires the root recipe host (host-owned worktrees); the standalone workflow server cannot run it`);
131
+ }
132
+ }
133
+ export async function readRecipePruneSummary(runDir) {
134
+ let content;
135
+ try {
136
+ const read = await readContainedRelativeFile(runDir, RECIPE_STATE_FILENAME, {
137
+ wantContent: true,
138
+ requireRegular: true,
139
+ requireExactRequestedPath: true,
140
+ maxBytes: MAX_RECIPE_STATE_BYTES,
141
+ containerLabel: "run directory",
142
+ pathLabel: RECIPE_STATE_FILENAME,
143
+ });
144
+ content = read.content ?? "";
145
+ }
146
+ catch (error) {
147
+ return { kind: "unreadable", reason: error instanceof Error ? error.message : String(error) };
148
+ }
149
+ let parsed;
150
+ try {
151
+ parsed = JSON.parse(content);
152
+ }
153
+ catch {
154
+ return { kind: "unreadable", reason: `${RECIPE_STATE_FILENAME} is not valid JSON` };
155
+ }
156
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
157
+ return { kind: "unreadable", reason: `${RECIPE_STATE_FILENAME} is not a JSON object` };
158
+ }
159
+ const record = parsed;
160
+ const unresolved = record["unresolved_operations"];
161
+ const worktrees = record["worktrees"];
162
+ // A missing key proves nothing about what exists on disk, so it is as
163
+ // unknown as a malformed one (and vetoes pruning).
164
+ const worktreePaths = Array.isArray(worktrees) &&
165
+ worktrees.every((entry) => entry !== null && typeof entry === "object" &&
166
+ typeof entry["path"] === "string")
167
+ ? worktrees.map((entry) => entry.path)
168
+ : undefined;
169
+ const baseline = record["baseline"];
170
+ const repoRoot = baseline !== null && typeof baseline === "object" && !Array.isArray(baseline) &&
171
+ typeof baseline["repo_root"] === "string"
172
+ ? baseline.repo_root
173
+ : undefined;
174
+ return {
175
+ kind: "read",
176
+ unresolvedOperations: Number.isSafeInteger(unresolved) && unresolved >= 0
177
+ ? unresolved
178
+ : undefined,
179
+ worktreePaths,
180
+ repoRoot,
181
+ };
182
+ }
183
+ //# sourceMappingURL=recipe-host.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recipe-host.js","sourceRoot":"","sources":["../src/recipe-host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,6EAA6E;AAC7E,MAAM,CAAC,MAAM,qBAAqB,GAAG,mBAAmB,CAAC;AACzD,uCAAuC;AACvC,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,GAAG,IAAI,CAAC;AAElD;;;;GAIG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAC5C,sGAAsG;IACtG,2GAA2G;IAC3G,yCAAyC,CAAC;AAE5C,oFAAoF;AACpF,MAAM,CAAC,MAAM,yBAAyB,GAAsB,CAAC,kBAAkB,CAAC,CAAC;AAEjF,MAAM,OAAO,eAAgB,SAAQ,aAAa;IACV;IAAtC,YAAY,OAAe,EAAW,SAAiB;QACrD,KAAK,CA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;IACnD,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;QAC1C,SAAS,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;YACpE,OAAQ,KAAiC,CAAC,MAAM,CAAC,KAAK,QAAQ,CAAC;QACnE,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAE,KAA0B,CAAC,IAAI,CAAC;QAC5D,CAAC,CAAC,SAAS,CAAC;IACd,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;IACpC,MAAM,QAAQ,GAAG,QAAQ,KAAK,IAAI,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;QAC1F,OAAQ,QAAoC,CAAC,WAAW,CAAC,KAAK,QAAQ;QACxE,CAAC,CAAE,QAAkC,CAAC,SAAS;QAC/C,CAAC,CAAC,SAAS,CAAC;IACd,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,oBAAoB,EAAE,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,IAAK,UAAqB,IAAI,CAAC;YACnF,CAAC,CAAC,UAAoB;YACtB,CAAC,CAAC,SAAS;QACb,aAAa;QACb,QAAQ;KACT,CAAC;AACJ,CAAC"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Recipe seat admission (Phase 1, tasks 1-1 and 1-3; seat mapping D-R4).
3
+ *
4
+ * Recipe workflows reuse the council seat parameters (`members`, `chairman`,
5
+ * `chairman_model`, `chairman_effort`) but NOT the council expansion: a recipe
6
+ * runtime drives its own round loop and dispatches each seat itself, so the
7
+ * normalized definition is never rewritten here. Instead each recipe has one
8
+ * pure expander that maps the parsed seat inputs onto a typed seat plan.
9
+ *
10
+ * The recipe set is deliberately separate from `COUNCIL_RUNTIME_MEMBER_WORKFLOWS`:
11
+ * that set also selects council stage expansion, council execution policy,
12
+ * the ranking reducer, and the council chairman stage index, none of which
13
+ * apply to recipes.
14
+ *
15
+ * Expanders throw `McpError(InvalidParams)` so admission rejects with `-32602`
16
+ * before any run state exists.
17
+ */
18
+ import { type ChairmanCallPins } from "./chairman-knobs.js";
19
+ import { type CouncilMemberInput } from "./council-expander.js";
20
+ import type { NormalizedCall, NormalizedWorkflowDefinition } from "./definition-normalizer.js";
21
+ export declare const ARCHITECTURE_ARENA_WORKFLOW = "architecture-arena";
22
+ export declare const PING_PONG_WORKFLOW = "ping-pong";
23
+ /** Only recipes that ship a workflow YAML belong here. */
24
+ export type RecipeWorkflowName = typeof ARCHITECTURE_ARENA_WORKFLOW | typeof PING_PONG_WORKFLOW;
25
+ export interface RecipeSeatRules {
26
+ readonly membersMin: number;
27
+ readonly membersMax: number;
28
+ /** `required`: the recipe needs a judge seat. */
29
+ readonly chairman: "required" | "rejected";
30
+ /** Admission rejects `async` other than `true`; advertised as `async_only` by list_workflows. */
31
+ readonly asyncOnly: boolean;
32
+ }
33
+ export declare const RECIPE_SEAT_RULES: Readonly<Record<RecipeWorkflowName, RecipeSeatRules>>;
34
+ export declare const RECIPE_SEAT_WORKFLOWS: ReadonlySet<RecipeWorkflowName>;
35
+ export declare function isRecipeSeatWorkflow(workflowName: string): workflowName is RecipeWorkflowName;
36
+ export declare function isAsyncOnlyWorkflow(workflowName: string): boolean;
37
+ /** `members` is accepted: council runtime members or a recipe seat workflow. */
38
+ export declare function supportsSeatMembers(workflowName: string): boolean;
39
+ /** `chairman`, `chairman_model`, and `chairman_effort` are accepted. */
40
+ export declare function supportsSeatChairman(workflowName: string): boolean;
41
+ /**
42
+ * Call id that marks a recipe workflow's default chairman. A recipe YAML that
43
+ * wants a default judge declares exactly one call with
44
+ * this id; its cli_name/model/effort are the static pins that
45
+ * `resolveEffectiveChairmanCall` overlays, as for councils.
46
+ */
47
+ export declare const RECIPE_DEFAULT_CHAIRMAN_CALL_ID = "chairman";
48
+ export declare function findRecipeDefaultChairmanCall(definition: NormalizedWorkflowDefinition): NormalizedCall | undefined;
49
+ /** One caller-supplied member seat; `index` is its position in `members`. */
50
+ export interface RecipeSeat {
51
+ readonly index: number;
52
+ readonly cli_name: string;
53
+ readonly model?: string;
54
+ readonly effort?: string;
55
+ readonly stance?: string;
56
+ }
57
+ export interface RecipeChairmanSeat {
58
+ readonly cli_name: string;
59
+ readonly model?: string;
60
+ readonly effort?: string;
61
+ /** `workflow_default`: no caller `chairman`; the YAML default call supplied the provider. */
62
+ readonly source: "caller" | "workflow_default";
63
+ }
64
+ export interface ArchitectureArenaSeatPlan {
65
+ readonly workflow: typeof ARCHITECTURE_ARENA_WORKFLOW;
66
+ /** 2..4 authors; `stance` is the exploration direction. */
67
+ readonly authors: readonly RecipeSeat[];
68
+ readonly judge: RecipeChairmanSeat;
69
+ }
70
+ export interface PingPongSeatPlan {
71
+ readonly workflow: typeof PING_PONG_WORKFLOW;
72
+ readonly implementer: RecipeSeat;
73
+ /** 1..k reviewers, k >= 1. */
74
+ readonly reviewers: readonly RecipeSeat[];
75
+ }
76
+ export type RecipeSeatPlan = ArchitectureArenaSeatPlan | PingPongSeatPlan;
77
+ export interface RecipeSeatInput {
78
+ readonly members?: ReadonlyArray<CouncilMemberInput> | undefined;
79
+ readonly chairman?: string | undefined;
80
+ readonly chairmanModel?: string | undefined;
81
+ readonly chairmanEffort?: string | undefined;
82
+ /** Static pins of the workflow's default chairman call, when it declares one. */
83
+ readonly defaultChairman?: ChairmanCallPins | undefined;
84
+ }
85
+ export declare function expandArchitectureArenaSeats(input: RecipeSeatInput): ArchitectureArenaSeatPlan;
86
+ export declare function expandPingPongSeats(input: RecipeSeatInput): PingPongSeatPlan;
87
+ export declare function expandRecipeSeats(workflow: RecipeWorkflowName, input: RecipeSeatInput): RecipeSeatPlan;
88
+ /**
89
+ * Flatten a plan back to caller order: member seats by `members` index, then
90
+ * the chairman seat when the recipe has one. Used for admission validation
91
+ * and the `resolved_roster` projection.
92
+ */
93
+ export declare function recipeSeatPlanSeats(plan: RecipeSeatPlan): {
94
+ readonly members: readonly RecipeSeat[];
95
+ readonly chairman?: RecipeChairmanSeat;
96
+ };