@telora/daemon 0.22.181 → 0.22.189

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 (263) hide show
  1. package/build-info.json +9 -3
  2. package/dist/audit/audit-floor-policy.d.ts +188 -0
  3. package/dist/audit/audit-floor-policy.d.ts.map +1 -0
  4. package/dist/audit/audit-floor-policy.js +353 -0
  5. package/dist/audit/audit-floor-policy.js.map +1 -0
  6. package/dist/audit/audit-prompt.d.ts +4 -177
  7. package/dist/audit/audit-prompt.d.ts.map +1 -1
  8. package/dist/audit/audit-prompt.js +6 -329
  9. package/dist/audit/audit-prompt.js.map +1 -1
  10. package/dist/completion/escalations.d.ts.map +1 -1
  11. package/dist/completion/escalations.js +4 -1
  12. package/dist/completion/escalations.js.map +1 -1
  13. package/dist/completion/review-exit-phase.d.ts.map +1 -1
  14. package/dist/completion/review-exit-phase.js +11 -4
  15. package/dist/completion/review-exit-phase.js.map +1 -1
  16. package/dist/completion/standing-approval-convergence.d.ts.map +1 -1
  17. package/dist/completion/standing-approval-convergence.js +2 -1
  18. package/dist/completion/standing-approval-convergence.js.map +1 -1
  19. package/dist/focus/focus-executor.d.ts.map +1 -1
  20. package/dist/focus/focus-executor.js +2 -0
  21. package/dist/focus/focus-executor.js.map +1 -1
  22. package/dist/focus/focus-loop-registry.js +2 -2
  23. package/dist/focus/focus-loop-registry.js.map +1 -1
  24. package/dist/focus/session-health.d.ts.map +1 -1
  25. package/dist/focus/session-health.js +2 -1
  26. package/dist/focus/session-health.js.map +1 -1
  27. package/dist/focus-stage-lifecycle/planning-release.d.ts +52 -17
  28. package/dist/focus-stage-lifecycle/planning-release.d.ts.map +1 -1
  29. package/dist/focus-stage-lifecycle/planning-release.js +58 -70
  30. package/dist/focus-stage-lifecycle/planning-release.js.map +1 -1
  31. package/dist/focus-stage-lifecycle/ratify-bar-gate.d.ts +108 -0
  32. package/dist/focus-stage-lifecycle/ratify-bar-gate.d.ts.map +1 -0
  33. package/dist/focus-stage-lifecycle/ratify-bar-gate.js +174 -0
  34. package/dist/focus-stage-lifecycle/ratify-bar-gate.js.map +1 -0
  35. package/dist/git/merge-to-main.d.ts.map +1 -1
  36. package/dist/git/merge-to-main.js.map +1 -1
  37. package/dist/loops/llm-client.d.ts +1 -1
  38. package/dist/loops/llm-client.d.ts.map +1 -1
  39. package/dist/loops/llm-client.js +18 -105
  40. package/dist/loops/llm-client.js.map +1 -1
  41. package/dist/nexus/index.d.ts.map +1 -1
  42. package/dist/nexus/index.js +2 -1
  43. package/dist/nexus/index.js.map +1 -1
  44. package/dist/nexus/intake-prompt-sections.d.ts +70 -0
  45. package/dist/nexus/intake-prompt-sections.d.ts.map +1 -0
  46. package/dist/nexus/intake-prompt-sections.js +145 -0
  47. package/dist/nexus/intake-prompt-sections.js.map +1 -0
  48. package/dist/nexus/intake-spawn.d.ts +49 -13
  49. package/dist/nexus/intake-spawn.d.ts.map +1 -1
  50. package/dist/nexus/intake-spawn.js +45 -122
  51. package/dist/nexus/intake-spawn.js.map +1 -1
  52. package/dist/nexus/intake.d.ts +55 -0
  53. package/dist/nexus/intake.d.ts.map +1 -1
  54. package/dist/nexus/intake.js +62 -1
  55. package/dist/nexus/intake.js.map +1 -1
  56. package/dist/prd/arm-readiness.d.ts +93 -0
  57. package/dist/prd/arm-readiness.d.ts.map +1 -0
  58. package/dist/prd/arm-readiness.js +254 -0
  59. package/dist/prd/arm-readiness.js.map +1 -0
  60. package/dist/prd/arm-refusal.d.ts +149 -0
  61. package/dist/prd/arm-refusal.d.ts.map +1 -0
  62. package/dist/prd/arm-refusal.js +219 -0
  63. package/dist/prd/arm-refusal.js.map +1 -0
  64. package/dist/prd/controller-shared.d.ts +111 -0
  65. package/dist/prd/controller-shared.d.ts.map +1 -1
  66. package/dist/prd/controller-shared.js +3 -1
  67. package/dist/prd/controller-shared.js.map +1 -1
  68. package/dist/prd/controller.d.ts +16 -10
  69. package/dist/prd/controller.d.ts.map +1 -1
  70. package/dist/prd/controller.js +28 -35
  71. package/dist/prd/controller.js.map +1 -1
  72. package/dist/prd/frontier-arming.d.ts +151 -0
  73. package/dist/prd/frontier-arming.d.ts.map +1 -0
  74. package/dist/prd/frontier-arming.js +315 -0
  75. package/dist/prd/frontier-arming.js.map +1 -0
  76. package/dist/prd/index.d.ts +10 -1
  77. package/dist/prd/index.d.ts.map +1 -1
  78. package/dist/prd/index.js +9 -1
  79. package/dist/prd/index.js.map +1 -1
  80. package/dist/prd/scoping-prompt.d.ts +68 -0
  81. package/dist/prd/scoping-prompt.d.ts.map +1 -0
  82. package/dist/prd/scoping-prompt.js +86 -0
  83. package/dist/prd/scoping-prompt.js.map +1 -0
  84. package/dist/prompt/prompt-contradictions.d.ts +20 -1
  85. package/dist/prompt/prompt-contradictions.d.ts.map +1 -1
  86. package/dist/prompt/prompt-contradictions.js +35 -0
  87. package/dist/prompt/prompt-contradictions.js.map +1 -1
  88. package/dist/prompt/team-prompt-base.d.ts +18 -0
  89. package/dist/prompt/team-prompt-base.d.ts.map +1 -1
  90. package/dist/prompt/team-prompt-base.js +56 -11
  91. package/dist/prompt/team-prompt-base.js.map +1 -1
  92. package/dist/prompt-sections/persona-sections.d.ts +36 -13
  93. package/dist/prompt-sections/persona-sections.d.ts.map +1 -1
  94. package/dist/prompt-sections/persona-sections.js +93 -16
  95. package/dist/prompt-sections/persona-sections.js.map +1 -1
  96. package/dist/prompt-sections/scoping-sections.d.ts +19 -5
  97. package/dist/prompt-sections/scoping-sections.d.ts.map +1 -1
  98. package/dist/prompt-sections/scoping-sections.js +45 -38
  99. package/dist/prompt-sections/scoping-sections.js.map +1 -1
  100. package/dist/prompt-sections/shared.d.ts +8 -0
  101. package/dist/prompt-sections/shared.d.ts.map +1 -1
  102. package/dist/prompt-sections/shared.js.map +1 -1
  103. package/dist/queries/agent-resolvable-promotion.d.ts +12 -0
  104. package/dist/queries/agent-resolvable-promotion.d.ts.map +1 -1
  105. package/dist/queries/agent-resolvable-promotion.js +17 -6
  106. package/dist/queries/agent-resolvable-promotion.js.map +1 -1
  107. package/dist/queries/delivery-gate-state.d.ts +3 -0
  108. package/dist/queries/delivery-gate-state.d.ts.map +1 -1
  109. package/dist/queries/delivery-gate-state.js +1 -1
  110. package/dist/queries/delivery-gate-state.js.map +1 -1
  111. package/dist/queries/focus-criteria-standing.d.ts +170 -7
  112. package/dist/queries/focus-criteria-standing.d.ts.map +1 -1
  113. package/dist/queries/focus-criteria-standing.js +143 -8
  114. package/dist/queries/focus-criteria-standing.js.map +1 -1
  115. package/dist/queries/focus-ratify-release.d.ts +43 -0
  116. package/dist/queries/focus-ratify-release.d.ts.map +1 -0
  117. package/dist/queries/focus-ratify-release.js +45 -0
  118. package/dist/queries/focus-ratify-release.js.map +1 -0
  119. package/dist/queries/focuses.d.ts +0 -10
  120. package/dist/queries/focuses.d.ts.map +1 -1
  121. package/dist/queries/focuses.js +0 -14
  122. package/dist/queries/focuses.js.map +1 -1
  123. package/dist/queries/prd.d.ts +31 -0
  124. package/dist/queries/prd.d.ts.map +1 -1
  125. package/dist/queries/prd.js +26 -1
  126. package/dist/queries/prd.js.map +1 -1
  127. package/dist/queries/shared.js +1 -1
  128. package/dist/queries/verify-own-holds.d.ts +89 -0
  129. package/dist/queries/verify-own-holds.d.ts.map +1 -0
  130. package/dist/queries/verify-own-holds.js +93 -0
  131. package/dist/queries/verify-own-holds.js.map +1 -0
  132. package/dist/resolvers/focus-criteria-standing.d.ts.map +1 -1
  133. package/dist/resolvers/focus-criteria-standing.js +324 -25
  134. package/dist/resolvers/focus-criteria-standing.js.map +1 -1
  135. package/dist/security/security-auto-inject.d.ts +51 -0
  136. package/dist/security/security-auto-inject.d.ts.map +1 -1
  137. package/dist/security/security-auto-inject.js +101 -11
  138. package/dist/security/security-auto-inject.js.map +1 -1
  139. package/dist/security/security-scan-engine.d.ts +4 -4
  140. package/dist/security/security-scan-engine.d.ts.map +1 -1
  141. package/dist/security/security-scan-engine.js +6 -0
  142. package/dist/security/security-scan-engine.js.map +1 -1
  143. package/dist/session/session-lineage.d.ts.map +1 -1
  144. package/dist/session/session-lineage.js +2 -0
  145. package/dist/session/session-lineage.js.map +1 -1
  146. package/dist/shell/constants.d.ts +5 -0
  147. package/dist/shell/constants.d.ts.map +1 -1
  148. package/dist/shell/constants.js +5 -0
  149. package/dist/shell/constants.js.map +1 -1
  150. package/dist/shell/daemon-instance.d.ts +74 -64
  151. package/dist/shell/daemon-instance.d.ts.map +1 -1
  152. package/dist/shell/daemon-instance.js +16 -121
  153. package/dist/shell/daemon-instance.js.map +1 -1
  154. package/dist/shell/health-events.js +1 -1
  155. package/dist/shell/health-events.js.map +1 -1
  156. package/dist/shell/instance-liveness.d.ts +112 -0
  157. package/dist/shell/instance-liveness.d.ts.map +1 -0
  158. package/dist/shell/instance-liveness.js +205 -0
  159. package/dist/shell/instance-liveness.js.map +1 -0
  160. package/dist/shell/schema-version-gate.d.ts +22 -0
  161. package/dist/shell/schema-version-gate.d.ts.map +1 -1
  162. package/dist/shell/schema-version-gate.js +116 -6
  163. package/dist/shell/schema-version-gate.js.map +1 -1
  164. package/dist/shell/worker-pidfile.d.ts +21 -8
  165. package/dist/shell/worker-pidfile.d.ts.map +1 -1
  166. package/dist/shell/worker-pidfile.js +38 -9
  167. package/dist/shell/worker-pidfile.js.map +1 -1
  168. package/dist/spawn/lead-launch.d.ts.map +1 -1
  169. package/dist/spawn/lead-launch.js +2 -1
  170. package/dist/spawn/lead-launch.js.map +1 -1
  171. package/dist/spawn/one-shot-model.d.ts +145 -0
  172. package/dist/spawn/one-shot-model.d.ts.map +1 -0
  173. package/dist/spawn/one-shot-model.js +329 -0
  174. package/dist/spawn/one-shot-model.js.map +1 -0
  175. package/dist/spawn/one-shot-scoping-spawn.d.ts +51 -0
  176. package/dist/spawn/one-shot-scoping-spawn.d.ts.map +1 -0
  177. package/dist/spawn/one-shot-scoping-spawn.js +156 -0
  178. package/dist/spawn/one-shot-scoping-spawn.js.map +1 -0
  179. package/dist/spawn/process-spawn.d.ts +12 -0
  180. package/dist/spawn/process-spawn.d.ts.map +1 -1
  181. package/dist/spawn/process-spawn.js +1 -1
  182. package/dist/spawn/process-spawn.js.map +1 -1
  183. package/dist/spawn/prompt-assembly.d.ts +8 -0
  184. package/dist/spawn/prompt-assembly.d.ts.map +1 -1
  185. package/dist/spawn/prompt-assembly.js +15 -3
  186. package/dist/spawn/prompt-assembly.js.map +1 -1
  187. package/dist/spawn/review-hold-park.d.ts.map +1 -1
  188. package/dist/spawn/review-hold-park.js +7 -3
  189. package/dist/spawn/review-hold-park.js.map +1 -1
  190. package/dist/spawn/routing-decider-spawn.d.ts +30 -0
  191. package/dist/spawn/routing-decider-spawn.d.ts.map +1 -1
  192. package/dist/spawn/routing-decider-spawn.js +84 -2
  193. package/dist/spawn/routing-decider-spawn.js.map +1 -1
  194. package/dist/spawn/routing-decider.d.ts.map +1 -1
  195. package/dist/spawn/routing-decider.js +22 -0
  196. package/dist/spawn/routing-decider.js.map +1 -1
  197. package/dist/spawn/spawn-cooldown.d.ts +15 -1
  198. package/dist/spawn/spawn-cooldown.d.ts.map +1 -1
  199. package/dist/spawn/spawn-cooldown.js +67 -19
  200. package/dist/spawn/spawn-cooldown.js.map +1 -1
  201. package/dist/spawn/worktree-session.d.ts +24 -6
  202. package/dist/spawn/worktree-session.d.ts.map +1 -1
  203. package/dist/spawn/worktree-session.js +37 -14
  204. package/dist/spawn/worktree-session.js.map +1 -1
  205. package/dist/testing/arm-coverage-model.d.ts +75 -0
  206. package/dist/testing/arm-coverage-model.d.ts.map +1 -0
  207. package/dist/testing/arm-coverage-model.js +114 -0
  208. package/dist/testing/arm-coverage-model.js.map +1 -0
  209. package/dist/testing/fixtures/index.js +1 -1
  210. package/dist/types/index.js +1 -1
  211. package/dist/verify/ai-inspection-runner.d.ts.map +1 -1
  212. package/dist/verify/ai-inspection-runner.js +26 -7
  213. package/dist/verify/ai-inspection-runner.js.map +1 -1
  214. package/dist/verify/de-restatement.d.ts +9 -2
  215. package/dist/verify/de-restatement.d.ts.map +1 -1
  216. package/dist/verify/de-restatement.js +14 -76
  217. package/dist/verify/de-restatement.js.map +1 -1
  218. package/dist/verify/default-on-guards.d.ts +5 -2
  219. package/dist/verify/default-on-guards.d.ts.map +1 -1
  220. package/dist/verify/default-on-guards.js +5 -3
  221. package/dist/verify/default-on-guards.js.map +1 -1
  222. package/dist/verify/verification-boundary-env.d.ts +7 -2
  223. package/dist/verify/verification-boundary-env.d.ts.map +1 -1
  224. package/dist/verify/verification-boundary-env.js +9 -4
  225. package/dist/verify/verification-boundary-env.js.map +1 -1
  226. package/dist/verify/verification-deps-default.d.ts.map +1 -1
  227. package/dist/verify/verification-deps-default.js +6 -0
  228. package/dist/verify/verification-deps-default.js.map +1 -1
  229. package/dist/verify/verification-deps.d.ts +10 -0
  230. package/dist/verify/verification-deps.d.ts.map +1 -1
  231. package/dist/verify/verification-deterministic.d.ts +7 -0
  232. package/dist/verify/verification-deterministic.d.ts.map +1 -1
  233. package/dist/verify/verification-deterministic.js.map +1 -1
  234. package/dist/verify/verification-engine.d.ts +1 -20
  235. package/dist/verify/verification-engine.d.ts.map +1 -1
  236. package/dist/verify/verification-engine.js +24 -55
  237. package/dist/verify/verification-engine.js.map +1 -1
  238. package/dist/verify/verification-evidence-unavailable-feedback.d.ts +3 -1
  239. package/dist/verify/verification-evidence-unavailable-feedback.d.ts.map +1 -1
  240. package/dist/verify/verification-evidence-unavailable-feedback.js +3 -1
  241. package/dist/verify/verification-evidence-unavailable-feedback.js.map +1 -1
  242. package/dist/verify/verification-feedback.d.ts +4 -12
  243. package/dist/verify/verification-feedback.d.ts.map +1 -1
  244. package/dist/verify/verification-feedback.js +7 -12
  245. package/dist/verify/verification-feedback.js.map +1 -1
  246. package/dist/verify/verification-history-reset.d.ts.map +1 -1
  247. package/dist/verify/verification-history-reset.js +11 -3
  248. package/dist/verify/verification-history-reset.js.map +1 -1
  249. package/dist/verify/verification-model-unavailable-hold.d.ts +92 -0
  250. package/dist/verify/verification-model-unavailable-hold.d.ts.map +1 -0
  251. package/dist/verify/verification-model-unavailable-hold.js +207 -0
  252. package/dist/verify/verification-model-unavailable-hold.js.map +1 -0
  253. package/dist/verify/verification-strategies.d.ts +32 -0
  254. package/dist/verify/verification-strategies.d.ts.map +1 -0
  255. package/dist/verify/verification-strategies.js +47 -0
  256. package/dist/verify/verification-strategies.js.map +1 -0
  257. package/dist/verify/verify-reconciliation.d.ts.map +1 -1
  258. package/dist/verify/verify-reconciliation.js +2 -1
  259. package/dist/verify/verify-reconciliation.js.map +1 -1
  260. package/dist/verify/verify-restatement.d.ts.map +1 -1
  261. package/dist/verify/verify-restatement.js +21 -8
  262. package/dist/verify/verify-restatement.js.map +1 -1
  263. package/package.json +2 -2
@@ -1,27 +1,7 @@
1
1
  // PINNED-BY-BEGIN (generated by gen:pinned-by -- do not hand-edit; checked by lint:pinned-by)
2
2
  // Pinned by: packages/daemon/src/loops/loop-llm-client.test.ts
3
3
  // PINNED-BY-END
4
- /**
5
- * LLM client for loop data updates and PRD/loop differential evaluation.
6
- *
7
- * Runs ONE model call per focus per cycle by spawning the `claude` CLI in print
8
- * mode -- the same pattern as `verify/de-restatement.ts` -- so it
9
- * rides the operator's existing Claude Code auth and needs NO Anthropic API key,
10
- * org LLM secret, or any other key beyond what the spawned agent teams already
11
- * use. (Previously this did a raw fetch to api.anthropic.com with an x-api-key
12
- * header; when no key was configured the call returned null and the differential
13
- * loop / PRD steward froze -- exactly the gap this client now closes.)
14
- *
15
- * Capture: a `--print` one-shot session produces NO OTLP rows (the OTLP exporter
16
- * only fires for long-lived interactive sessions), so loop-layer token/cost spend
17
- * would otherwise be invisible to agent_telemetry_metrics. We parse the usage
18
- * block off the print-mode JSON (`--output-format json`) and buffer a telemetry
19
- * metric row on the same writer the OTLP receiver feeds, so loop spend lands in
20
- * agent_telemetry_metrics too -- the same capture path as the audit assessor
21
- * (spawn/lifecycle.ts buildAuditMetricRow).
22
- */
23
- import { spawn } from 'node:child_process';
24
- import { trackChildProcess } from '../spawn/worker-registry.js';
4
+ import { invokeOneShotModel } from '../spawn/one-shot-model.js';
25
5
  import { bufferMetric } from '../otlp/telemetry-writer.js';
26
6
  import { createLogger } from '../shell/log.js';
27
7
  const log = createLogger({ module: 'Loop' });
@@ -37,7 +17,6 @@ const log = createLogger({ module: 'Loop' });
37
17
  * from total_cost_usd).
38
18
  */
39
19
  const DEFAULT_MODEL = 'claude-sonnet-4-6';
40
- const DEFAULT_TIMEOUT_MS = 2 * 60 * 1000;
41
20
  /**
42
21
  * Per-model-family pricing in USD per 1M tokens. Used only as a FALLBACK when
43
22
  * the print-mode JSON does not carry total_cost_usd; Claude Code normally
@@ -124,93 +103,27 @@ export function buildLoopMetricRow(params) {
124
103
  // Default model invocation: spawn the `claude` CLI in print mode
125
104
  // ---------------------------------------------------------------------------
126
105
  /**
127
- * Parse a `claude --print --output-format json` stdout payload into a
128
- * LoopModelResult. Returns text:null on unparseable / empty output so the
129
- * caller degrades gracefully (the loop skips a cycle rather than crashing).
106
+ * Default model invocation: the shared one-shot wrapper (spawn/one-shot-model.ts)
107
+ * mapped onto LoopModelResult. Rides Claude Code auth -- no key wiring. The
108
+ * model tag is whatever the CLI reported (its init event, else the modelUsage
109
+ * key); only when it reported neither does the caller apply DEFAULT_MODEL.
110
+ * Rejects with ModelUnavailable when the model could not be reached; callLoopLLM
111
+ * treats that as a skipped cycle, never as an answer.
130
112
  */
131
- function parsePrintJson(stdout) {
132
- const trimmed = stdout.trim();
133
- if (trimmed === '')
134
- return { text: null };
135
- let parsed;
136
- try {
137
- parsed = JSON.parse(trimmed);
138
- }
139
- catch {
140
- return { text: null };
141
- }
142
- // Prefer the explicit top-level model id; fall back to the first modelUsage
143
- // key. Only when neither is present does the caller apply DEFAULT_MODEL -- so
144
- // the telemetry tag reflects the real model whenever the CLI reports it.
145
- const model = typeof parsed.model === 'string' && parsed.model !== ''
146
- ? parsed.model
147
- : parsed.modelUsage && typeof parsed.modelUsage === 'object'
148
- ? Object.keys(parsed.modelUsage)[0]
149
- : undefined;
113
+ async function invokeClaudeCli(systemPrompt, userMessage, opts) {
114
+ const result = await invokeOneShotModel(systemPrompt, userMessage, {
115
+ label: 'loop-llm',
116
+ ...(opts.claudeBin !== undefined ? { claudeBin: opts.claudeBin } : {}),
117
+ ...(opts.timeoutMs !== undefined ? { timeoutMs: opts.timeoutMs } : {}),
118
+ ...(opts.spawnFn !== undefined ? { spawnFn: opts.spawnFn } : {}),
119
+ });
150
120
  return {
151
- text: typeof parsed.result === 'string' ? parsed.result : null,
152
- usage: parsed.usage,
153
- model,
154
- costUsd: typeof parsed.total_cost_usd === 'number' ? parsed.total_cost_usd : null,
121
+ text: result.text === '' ? null : result.text,
122
+ ...(result.usage ? { usage: result.usage } : {}),
123
+ ...(result.model ? { model: result.model } : {}),
124
+ costUsd: result.costUsd ?? null,
155
125
  };
156
126
  }
157
- /**
158
- * Default model invocation: spawn the `claude` CLI in print mode with JSON
159
- * output and return the parsed result. Rides Claude Code auth -- no key wiring.
160
- */
161
- function invokeClaudeCli(systemPrompt, userMessage, opts) {
162
- const claudeBin = opts.claudeBin ?? 'claude';
163
- const timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT_MS;
164
- const spawnFn = opts.spawnFn ?? ((cmd, args, sopts) => spawn(cmd, args, sopts));
165
- const args = [
166
- '--print',
167
- '--output-format', 'json',
168
- '--no-session-persistence',
169
- '--system-prompt', systemPrompt,
170
- ];
171
- return new Promise((resolve, reject) => {
172
- let child;
173
- try {
174
- child = spawnFn(claudeBin, args, { stdio: ['pipe', 'pipe', 'pipe'] });
175
- }
176
- catch (err) {
177
- reject(new Error(`loop-llm spawn failed: ${err.message}`));
178
- return;
179
- }
180
- // Register so a graceful stop reaps this one-shot if the loop eval is still running.
181
- trackChildProcess(child, 'loop-llm');
182
- let stdout = '';
183
- let stderr = '';
184
- child.stdout?.on('data', (chunk) => { stdout += chunk.toString('utf8'); });
185
- child.stderr?.on('data', (chunk) => { stderr += chunk.toString('utf8'); });
186
- const timer = setTimeout(() => {
187
- try {
188
- child.kill('SIGKILL');
189
- }
190
- catch { /* ignore */ }
191
- }, timeoutMs);
192
- child.on('error', (err) => {
193
- clearTimeout(timer);
194
- reject(new Error(`loop-llm spawn error: ${err.message}`));
195
- });
196
- child.on('close', (code) => {
197
- clearTimeout(timer);
198
- if (code !== 0) {
199
- reject(new Error(`loop-llm exited ${code}: ${stderr.slice(-2000)}`));
200
- return;
201
- }
202
- resolve(parsePrintJson(stdout));
203
- });
204
- try {
205
- child.stdin?.write(userMessage);
206
- child.stdin?.end();
207
- }
208
- catch (err) {
209
- clearTimeout(timer);
210
- reject(new Error(`loop-llm stdin write failed: ${err.message}`));
211
- }
212
- });
213
- }
214
127
  // ---------------------------------------------------------------------------
215
128
  // LLM call
216
129
  // ---------------------------------------------------------------------------
@@ -1 +1 @@
1
- {"version":3,"file":"llm-client.js","sourceRoot":"","sources":["../../src/loops/llm-client.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,+DAA+D;AAC/D,gBAAgB;AAEhB;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EAAE,YAAY,EAA2B,MAAM,6BAA6B,CAAC;AAEpF,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,GAAG,GAAG,YAAY,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;AAoE7C,8EAA8E;AAC9E,kBAAkB;AAClB,8EAA8E;AAE9E;;;;;;;GAOG;AACH,MAAM,aAAa,GAAG,mBAAmB,CAAC;AAE1C,MAAM,kBAAkB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,aAAa,GAA6F;IAC9G,KAAK,EAAE,EAAE,KAAK,EAAE,EA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3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/nexus/index.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;GAYG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/nexus/index.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;GAYG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC"}
@@ -2,7 +2,8 @@
2
2
  // Pinned by: packages/daemon/src/nexus/nexus-e2e.test.ts,
3
3
  // packages/daemon/src/nexus/nexus-escalation-bridge.test.ts,
4
4
  // packages/daemon/src/nexus/nexus-incoming.test.ts, packages/daemon/src/nexus/nexus-intake.test.ts,
5
- // packages/daemon/src/nexus/nexus-return.test.ts
5
+ // packages/daemon/src/nexus/nexus-return.test.ts,
6
+ // packages/daemon/src/nexus/release-order-capability.test.ts
6
7
  // PINNED-BY-END
7
8
  /**
8
9
  * Nexus subsystem barrel (cross-product request intake / routing / return).
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/nexus/index.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,0DAA0D;AAC1D,+DAA+D;AAC/D,sGAAsG;AACtG,mDAAmD;AACnD,gBAAgB;AAEhB;;;;;;;;;;;;GAYG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/nexus/index.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,0DAA0D;AAC1D,+DAA+D;AAC/D,sGAAsG;AACtG,oDAAoD;AACpD,+DAA+D;AAC/D,gBAAgB;AAEhB;;;;;;;;;;;;GAYG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * The sections the Nexus intake scoping prompt is composed from.
3
+ *
4
+ * Extracted from intake-spawn.ts because the composer would otherwise cross the
5
+ * 100-line function ceiling. Each function here returns TEXT; none of them is
6
+ * the contract. What the scoping agent actually receives is whatever
7
+ * buildIntakeScopingPrompt concatenates, which is why every regression test in
8
+ * this area asserts on the COMPOSED prompt and not on these return values --
9
+ * a section can be correct and never reach the agent.
10
+ *
11
+ * @module nexus/intake-prompt-sections
12
+ */
13
+ import type { IntakeObservation } from './intake.js';
14
+ /**
15
+ * The observation the requester carried: the undesired effect they asked to
16
+ * have cleared, and the causes upstream of it in THEIR tree.
17
+ *
18
+ * Returns the EMPTY STRING when there is no observation -- an endpoint-typed
19
+ * request, or one raised from an MCP that predates source nodes. Deliberately
20
+ * not a "(none supplied)" placeholder: a placeholder is content, and a scoping
21
+ * agent handed content will scope against it. Absence must read as absence.
22
+ */
23
+ export declare function renderObservationSection(observation: IntakeObservation | null | undefined): string;
24
+ /**
25
+ * The ordered scoping steps.
26
+ *
27
+ * TWO corrections live in this order, from two different focuses, and they are
28
+ * independent -- do not collapse either back.
29
+ *
30
+ * WHAT the CRT is built FROM. Step 3 used to read "set the FRT goal /
31
+ * desired-effect FROM the acceptance contract". That single clause produced tree
32
+ * 24a042b1: the contract named a mechanism (detect the collision, refuse it at
33
+ * the merge), the tree was built downward from it, the CRT correctly found the
34
+ * real root -- both branches claim the same numbers -- and then declared that
35
+ * root out of reach CITING the contract. Three commits landed and the cause was
36
+ * never touched. So the CRT is built from the OBSERVATION, injections go at the
37
+ * ROOT, and the contract is applied afterwards as the BAR the derived future
38
+ * must clear.
39
+ *
40
+ * WHEN the focus is armed. The arm used to be step 1, before the tree existed.
41
+ * An arm covers exactly the effects the anchored deliveries' injections target
42
+ * AT THE INSTANT IT LANDS, so arming first covers nothing and strands every
43
+ * later delivery at 'planning'. It is now the LAST step, after the tree, the
44
+ * deliveries and the second materialize. What keeps a second scoping agent from
45
+ * spawning is the first materialize STAMP, not the arm -- which is why that
46
+ * stamp stays at step 2, long before the focus is armed.
47
+ *
48
+ * The restatement paragraph in step 3 is not advice: the database REFUSES an arm
49
+ * that covers an undesired effect stating no future, naming the unstated nodes.
50
+ * A prompt that omitted it would send every scoping agent into that refusal.
51
+ */
52
+ export declare function renderScopingSteps(params: {
53
+ requestId: string;
54
+ title: string;
55
+ targetProductId: string;
56
+ roleId: string;
57
+ marker: string;
58
+ hasObservation: boolean;
59
+ }): string;
60
+ /**
61
+ * The two rules that keep the contract from becoming a wall.
62
+ *
63
+ * Both exist because of one observed run. The CRT found the real root and
64
+ * declared it out of reach, citing acceptance-contract item 3; the return
65
+ * channel (a question entry) existed the whole time and was never used. So the
66
+ * prompt now names the return channel as the ACT to take, and forbids the
67
+ * contract as an out-of-reach reason outright.
68
+ */
69
+ export declare function renderContractRules(requestId: string, hasObservation: boolean): string;
70
+ //# sourceMappingURL=intake-prompt-sections.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intake-prompt-sections.d.ts","sourceRoot":"","sources":["../../src/nexus/intake-prompt-sections.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAyB,MAAM,aAAa,CAAC;AAS5E;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,iBAAiB,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CA8BlG;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,OAAO,CAAC;CACzB,GAAG,MAAM,CA6BT;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,GAAG,MAAM,CA4BtF"}
@@ -0,0 +1,145 @@
1
+ // PINNED-BY-BEGIN (generated by gen:pinned-by -- do not hand-edit; checked by lint:pinned-by)
2
+ // Pinned by: none -- no test imports this module directly (baselined; see lint:pinned-by)
3
+ // PINNED-BY-END
4
+ /** One observation node as a prompt line: what it says, and what backs it. */
5
+ function renderNode(node, label) {
6
+ const lines = [`- ${label} (#${node.seq}, ${node.nodeType}): ${node.statement}`];
7
+ if (node.evidence)
8
+ lines.push(` evidence: ${node.evidence}`);
9
+ return lines;
10
+ }
11
+ /**
12
+ * The observation the requester carried: the undesired effect they asked to
13
+ * have cleared, and the causes upstream of it in THEIR tree.
14
+ *
15
+ * Returns the EMPTY STRING when there is no observation -- an endpoint-typed
16
+ * request, or one raised from an MCP that predates source nodes. Deliberately
17
+ * not a "(none supplied)" placeholder: a placeholder is content, and a scoping
18
+ * agent handed content will scope against it. Absence must read as absence.
19
+ */
20
+ export function renderObservationSection(observation) {
21
+ if (!observation)
22
+ return '';
23
+ const lines = [
24
+ `## The observation (what the REQUESTER sees -- build your CRT from THIS)`,
25
+ ``,
26
+ `This request was born from an undesired effect in the requesting product's`,
27
+ `reality tree, not from prose. The effect and its upstream causes travel with`,
28
+ `the request so you never have to read back into their tree.`,
29
+ ``,
30
+ ...renderNode(observation.sourceNode, 'The effect this request asks to have cleared'),
31
+ ];
32
+ if (observation.sourceNode.frtStatement) {
33
+ lines.push(` its stated future (this IS the acceptance contract below): ${observation.sourceNode.frtStatement}`);
34
+ }
35
+ if (observation.upstreamCauses.length > 0) {
36
+ lines.push(``, `Upstream causes in the requester's tree, nearest first:`);
37
+ for (const cause of observation.upstreamCauses)
38
+ lines.push(...renderNode(cause, 'cause'));
39
+ }
40
+ else {
41
+ lines.push(``, `The requester recorded no upstream causes: in their tree this effect is a root.`);
42
+ }
43
+ if (observation.truncated) {
44
+ lines.push(``, `NOTE: this fragment was truncated at a size cap -- the requester's tree has`, `more upstream than is shown. Treat what is here as a starting point, not as`, `the complete causal picture.`);
45
+ }
46
+ lines.push(``);
47
+ return lines.join('\n');
48
+ }
49
+ /**
50
+ * The ordered scoping steps.
51
+ *
52
+ * TWO corrections live in this order, from two different focuses, and they are
53
+ * independent -- do not collapse either back.
54
+ *
55
+ * WHAT the CRT is built FROM. Step 3 used to read "set the FRT goal /
56
+ * desired-effect FROM the acceptance contract". That single clause produced tree
57
+ * 24a042b1: the contract named a mechanism (detect the collision, refuse it at
58
+ * the merge), the tree was built downward from it, the CRT correctly found the
59
+ * real root -- both branches claim the same numbers -- and then declared that
60
+ * root out of reach CITING the contract. Three commits landed and the cause was
61
+ * never touched. So the CRT is built from the OBSERVATION, injections go at the
62
+ * ROOT, and the contract is applied afterwards as the BAR the derived future
63
+ * must clear.
64
+ *
65
+ * WHEN the focus is armed. The arm used to be step 1, before the tree existed.
66
+ * An arm covers exactly the effects the anchored deliveries' injections target
67
+ * AT THE INSTANT IT LANDS, so arming first covers nothing and strands every
68
+ * later delivery at 'planning'. It is now the LAST step, after the tree, the
69
+ * deliveries and the second materialize. What keeps a second scoping agent from
70
+ * spawning is the first materialize STAMP, not the arm -- which is why that
71
+ * stamp stays at step 2, long before the focus is armed.
72
+ *
73
+ * The restatement paragraph in step 3 is not advice: the database REFUSES an arm
74
+ * that covers an undesired effect stating no future, naming the unstated nodes.
75
+ * A prompt that omitted it would send every scoping agent into that refusal.
76
+ */
77
+ export function renderScopingSteps(params) {
78
+ const { requestId, title, targetProductId, roleId, marker, hasObservation } = params;
79
+ const step3 = hasObservation
80
+ ? [
81
+ `3. telora_reality_tree create on the focus, then author the CRT FROM THE OBSERVATION above -- in this order:`,
82
+ ` a. Bring the observation into THIS product's terms: the requester's effect and its upstream causes become entities and undesired effects in your tree, carrying the evidence that travelled with them. You are not copying their tree; you are stating, in your product's causal terms, what produces the effect they see.`,
83
+ ` b. Create the MIRROR of the requested undesired effect: one node whose statement is the requester's effect and which carries their evidence. This is the node the whole request is judged against, so it must exist as its own node.`,
84
+ ` c. Wire the causes, then keep asking "and what causes THAT?" until you reach roots inside this product -- something your team can act on. The effect the requester named is a SYMPTOM in your tree; it is almost never where the injection goes.`,
85
+ ` d. Place your injections at the ROOTS you found. Not at the items the acceptance contract lists: those describe a future, and an injection is an act. Draw a \`targets\` edge from each injection to the node(s) it flips.`,
86
+ ` e. derive_frt, then read the derived cascade AGAINST the acceptance contract. The contract is the BAR -- does the future your injections produce clear it? If not, the plan is short, not the contract wrong.`,
87
+ ` The contract tells you what must become TRUE. It does not tell you where the tree starts, which mechanism to build, or what is beyond reach.`,
88
+ ]
89
+ : [
90
+ `3. telora_reality_tree create on the focus, then author the CRT: capture the undesired effects this request implies in THIS product, wire their causes down to roots you can act on, and place injections at those roots, drawing a \`targets\` edge from each injection to the node(s) it flips. Then derive_frt and read the derived cascade against the acceptance contract as the BAR it must clear. This request carries no observation (it is endpoint-typed, or was raised before requests carried one), so the contract is all you have to judge against -- but it is still a bar on the future, never a description of the tree to build.`,
91
+ ];
92
+ return [
93
+ `## Steps (do these in order, verifying each with a follow-up read)`,
94
+ `1. telora_product_focus create -- name the focus from the request title ("${title}"), productId = ${targetProductId}. The description MUST include, verbatim, the marker line "${marker}" AND the full acceptance contract above (so any follow-up team has the goal even if the tree is not yet built). Leave assignedAgentRoleId UNSET here -- the arm is the last step, not the first.`,
95
+ `2. telora_product_request materialize -- requestId = ${requestId}, materializedFocusId = <the focus id you created>. Do this NOW, immediately after the focus exists -- BEFORE building the tree or deliveries, and long before the arm. This stamps the focus back on the request (accepted -> in_progress) so it leaves the intake-pending set and a second scoping agent can never be spawned for it. The stamp is what guarantees that -- not the arm, which has not happened yet. If your run crashes after this point, the per-request focus already exists and the normal loop finishes scoping it; if it crashed before this point, the idempotency check above reuses the focus.`,
96
+ ...step3,
97
+ ` RESTATEMENT IS REQUIRED ON EVERY INJECTION TARGET: each undesired effect an injection targets MUST carry a non-blank frtStatement -- the future that node reads as once this work lands -- together with its frtNodeType (what the node becomes: desired_effect). Set both with telora_reality_tree_node update (frtStatement + frtNodeType) on EVERY target, then re-read the nodes and confirm not one of them is blank.`,
98
+ ` This is not decoration, and it is not optional. The arm in step 5 is REFUSED BY THE DATABASE when any undesired effect it covers states no future: the call fails with an "arm_criteria_required:" error that NAMES the unstated nodes, because an arm that covers an unstated effect would stamp a bar nobody wrote down. If you see that refusal, state the futures it names and issue the arm again -- do not work around it, and do not skip the arm.`,
99
+ `4. telora_product_delivery create -- decompose the work into one or more deliveries, EACH anchored to an injection (injectionNodeId) and carrying a workFacing label ("outward" for new ground / a capability not had before, "inward" for improving existing ground). Scope deliveries by the phases the work naturally has. These MUST exist and be injection-anchored BEFORE the arm in step 5: an arm covers exactly the effects the deliveries' injections target at the instant it lands, so arming an empty or tree-less focus covers nothing and strands everything you scope afterwards at 'planning'.`,
100
+ ` Then call telora_product_request materialize ONCE MORE with the SAME materializedFocusId, plus materializedDeliveryId = <the representative delivery id>${hasObservation ? `, plus mirroredNodeId = <the id of the mirror node you created in step 3b>` : ''}. The request is already in_progress at this point, which is fine -- materialize is idempotent for the same focus and just records the delivery the return-path loop watches to resolve this request when it reaches done.${hasObservation ? ` Recording the mirror is what lets this call check that your plan actually reaches the effect the requester observed; a plan whose injections do not flip that node is not a plan for this request.` : ''}`,
101
+ `5. telora_product_focus update to set assignedAgentRoleId = ${roleId} so the spawn loop will pick the focus up (no dead-letter). Do this LAST, after the tree and the anchored deliveries exist and after the second materialize, so the arm you request covers stated effects. This arm is NOT you judging your own scoping ready -- an agent does not arm its own focus. It is the human go-signal that the accepted intake request DURABLY DELEGATED to this flow (accepting the request IS the go-signal), which is why you may issue it at all, and it goes here, last, so that delegated go-signal lands on a focus whose effects are stated. Declare it in the same call: pass armNote = "durably-delegated arm: accepted intake request ${requestId}".`,
102
+ ``,
103
+ `Then STOP. Do NOT begin implementing the deliveries -- the armed focus runs the normal differential loop after you exit.`,
104
+ ].join('\n');
105
+ }
106
+ /**
107
+ * The two rules that keep the contract from becoming a wall.
108
+ *
109
+ * Both exist because of one observed run. The CRT found the real root and
110
+ * declared it out of reach, citing acceptance-contract item 3; the return
111
+ * channel (a question entry) existed the whole time and was never used. So the
112
+ * prompt now names the return channel as the ACT to take, and forbids the
113
+ * contract as an out-of-reach reason outright.
114
+ */
115
+ export function renderContractRules(requestId, hasObservation) {
116
+ if (!hasObservation)
117
+ return '';
118
+ return [
119
+ `## When your tree and the contract disagree`,
120
+ ``,
121
+ `You will sometimes find that the root cause your CRT reaches is NOT what the`,
122
+ `contract's wording addresses, or that the contract names a MECHANISM your tree`,
123
+ `says will not clear the effect. That is a normal and useful finding: the`,
124
+ `requester wrote from where the pain was felt; you are looking at where it comes`,
125
+ `from. It is not a reason to stop, and it is not a reason to scope their`,
126
+ `mechanism instead.`,
127
+ ``,
128
+ `Do this:`,
129
+ `- SEND IT BACK. telora_product_request send, requestId = ${requestId}, entryType = "question",`,
130
+ ` content = the root you found, the evidence for it, and what you intend to scope`,
131
+ ` toward instead. Name the disagreement plainly.`,
132
+ `- KEEP GOING. The question is not a gate on your own work. Do not wait for an`,
133
+ ` answer, do not park the focus, and do not hold the materialize call. Scope`,
134
+ ` toward the EFFECT the requester observed, using the root you actually found.`,
135
+ ``,
136
+ `And one prohibition, because this is exactly how the last request failed:`,
137
+ `- An out-of-reach declaration on an undesired effect may NOT cite the acceptance`,
138
+ ` contract as its reason. "The contract does not mention this" is not a boundary`,
139
+ ` on your reach -- it is a disagreement, and a disagreement goes back through the`,
140
+ ` question channel above. Out of reach means YOUR PRODUCT cannot act on it, and`,
141
+ ` that claim stands on what your product can do, never on what the requester wrote.`,
142
+ ``,
143
+ ].join('\n');
144
+ }
145
+ //# sourceMappingURL=intake-prompt-sections.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intake-prompt-sections.js","sourceRoot":"","sources":["../../src/nexus/intake-prompt-sections.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,0FAA0F;AAC1F,gBAAgB;AAiBhB,8EAA8E;AAC9E,SAAS,UAAU,CAAC,IAA2B,EAAE,KAAa;IAC5D,MAAM,KAAK,GAAG,CAAC,KAAK,KAAK,MAAM,IAAI,CAAC,GAAG,KAAK,IAAI,CAAC,QAAQ,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;IACjF,IAAI,IAAI,CAAC,QAAQ;QAAE,KAAK,CAAC,IAAI,CAAC,eAAe,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC9D,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,wBAAwB,CAAC,WAAiD;IACxF,IAAI,CAAC,WAAW;QAAE,OAAO,EAAE,CAAC;IAC5B,MAAM,KAAK,GAAa;QACtB,0EAA0E;QAC1E,EAAE;QACF,4EAA4E;QAC5E,8EAA8E;QAC9E,6DAA6D;QAC7D,EAAE;QACF,GAAG,UAAU,CAAC,WAAW,CAAC,UAAU,EAAE,8CAA8C,CAAC;KACtF,CAAC;IACF,IAAI,WAAW,CAAC,UAAU,CAAC,YAAY,EAAE,CAAC;QACxC,KAAK,CAAC,IAAI,CAAC,gEAAgE,WAAW,CAAC,UAAU,CAAC,YAAY,EAAE,CAAC,CAAC;IACpH,CAAC;IACD,IAAI,WAAW,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1C,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,yDAAyD,CAAC,CAAC;QAC1E,KAAK,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B,SAAS,IAAI;QAChuB,EAAE;QACF,0HAA0H;KAC3H,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,mBAAmB,CAAC,SAAiB,EAAE,cAAuB;IAC5E,IAAI,CAAC,cAAc;QAAE,OAAO,EAAE,CAAC;IAC/B,OAAO;QACL,6CAA6C;QAC7C,EAAE;QACF,8EAA8E;QAC9E,gFAAgF;QAChF,0EAA0E;QAC1E,iFAAiF;QACjF,yEAAyE;QACzE,oBAAoB;QACpB,EAAE;QACF,UAAU;QACV,4DAA4D,SAAS,2BAA2B;QAChG,mFAAmF;QACnF,kDAAkD;QAClD,+EAA+E;QAC/E,8EAA8E;QAC9E,gFAAgF;QAChF,EAAE;QACF,2EAA2E;QAC3E,kFAAkF;QAClF,kFAAkF;QAClF,mFAAmF;QACnF,iFAAiF;QACjF,qFAAqF;QACrF,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
@@ -1,27 +1,63 @@
1
+ /**
2
+ * Nexus intake scoping-agent spawn.
3
+ *
4
+ * Spawns a short-lived, single-purpose Claude Code agent that authors a focus
5
+ * from an accepted cross-product request -- the work the materialize edge
6
+ * handler structurally could not do. The agent is seeded with the request + its
7
+ * acceptanceContract and the role UUID to assign; its sole job is:
8
+ *
9
+ * 1. telora_product_focus create -- a per-request focus named from the request,
10
+ * left UN-ARMED (no assignedAgentRoleId).
11
+ * 2. telora_product_request materialize -- stamp the new focus back on the
12
+ * request so it leaves the intake-pending set (accepted -> in_progress) and
13
+ * a second scoping agent can never be spawned. The stamp, not the arm, is
14
+ * the anti-double-spawn guarantee.
15
+ * 3. telora_reality_tree create + author nodes/edges -- the acceptanceContract
16
+ * becomes the goal / desired-effect the tree drives toward, and EVERY node
17
+ * an injection targets is restated (frtStatement + frtNodeType). The arm at
18
+ * step 5 is refused outright when one of its covered effects states no
19
+ * future, so the restatement is a precondition of the arm, not a polish
20
+ * step -- and the prompt says so, because the prompt is the only thing that
21
+ * reaches the agent doing the authoring.
22
+ * 4. telora_product_delivery create -- injection-anchored deliveries, then
23
+ * materialize once more to record the representative delivery.
24
+ * 5. telora_product_focus update -- assign the intake role LAST, so the arm
25
+ * covers the effects the anchored deliveries state. Arming first covers
26
+ * nothing and strands every later delivery at 'planning'.
27
+ * 6. exit.
28
+ *
29
+ * THE PROCESS MACHINERY LIVES IN `spawn/one-shot-scoping-spawn.ts` and is
30
+ * SHARED with the PRD frontier's scoping agent: the one-shot `--print` Claude
31
+ * Code process, prompt passed as a CLI arg, cleaned env, the kill timeout, the
32
+ * fire-and-forget resolve-on-'spawn' contract (the agent runs for minutes, so
33
+ * the daemon poll loop is never blocked) and the close/error logging. What
34
+ * stays here is what is genuinely intake's: the PURE prompt builder below, and
35
+ * the `intake_scoping_started_at` in-flight guard its caller stamps -- that
36
+ * stamp, never the returned promise, is what prevents a re-spawn until the
37
+ * staleness window.
38
+ */
1
39
  import type { DaemonConfig } from '../types/index.js';
2
40
  import type { IntakePendingRequest } from './intake.js';
3
- /** Kill the scoping agent if it has not exited within this window (15 minutes). */
41
+ import { type ScopingSpawnSeam } from '../spawn/one-shot-scoping-spawn.js';
42
+ /**
43
+ * Kill the scoping agent if it has not exited within this window (15 minutes).
44
+ *
45
+ * An alias of the shared one-shot timeout, kept under its original name because
46
+ * DEFAULT_INTAKE_STALE_MS is documented and tested as strictly greater than it
47
+ * (`nexus-intake.test.ts`) -- the relation is intake's, the number is shared.
48
+ */
4
49
  export declare const INTAKE_SCOPING_TIMEOUT_MS: number;
50
+ export type { ScopingSpawnSeam };
5
51
  /**
6
52
  * Build the scoping prompt seeded with the request + acceptanceContract + the
7
53
  * role to assign. Pure (string) so it is unit-tested without spawning a process.
8
54
  */
9
55
  export declare function buildIntakeScopingPrompt(req: IntakePendingRequest, roleId: string): string;
10
- /** Injectable process spawn seam (overridable in tests). */
11
- export interface ScopingSpawnSeam {
12
- spawnProcess: (command: string, args: string[], cwd: string, env: NodeJS.ProcessEnv) => {
13
- pid?: number;
14
- on: (event: string, cb: (arg?: unknown) => void) => void;
15
- stdin?: {
16
- end: () => void;
17
- } | null;
18
- };
19
- }
20
56
  /**
21
57
  * Spawn the intake scoping agent for one accepted request. Resolves once the
22
58
  * process has SPAWNED (fire-and-forget -- the agent runs for minutes); rejects
23
- * only if the process fails to spawn. The close/error handlers log the outcome
24
- * and the kill timeout bounds a hung agent.
59
+ * only if the process fails to spawn. The shared seam logs the outcome and its
60
+ * kill timeout bounds a hung agent.
25
61
  */
26
62
  export declare function spawnScopingAgent(config: DaemonConfig, req: IntakePendingRequest, roleId: string, seam?: ScopingSpawnSeam): Promise<void>;
27
63
  //# sourceMappingURL=intake-spawn.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"intake-spawn.d.ts","sourceRoot":"","sources":["../../src/nexus/intake-spawn.ts"],"names":[],"mappings":"AAqCA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAMxD,mFAAmF;AACnF,eAAO,MAAM,yBAAyB,QAAiB,CAAC;AAExD;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAsC1F;AAED,4DAA4D;AAC5D,MAAM,WAAW,gBAAgB;IAC/B,YAAY,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,UAAU,KAAK;QACtF,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,KAAK,IAAI,KAAK,IAAI,CAAC;QACzD,KAAK,CAAC,EAAE;YAAE,GAAG,EAAE,MAAM,IAAI,CAAA;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