@senpi/runtime 3.0.58 → 3.0.62

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 (226) hide show
  1. package/README.md +73 -2
  2. package/dist/actions/action-events.d.ts +3 -3
  3. package/dist/actions/action-events.d.ts.map +1 -1
  4. package/dist/actions/action-events.js +24 -16
  5. package/dist/actions/action-events.js.map +1 -1
  6. package/dist/actions/action-runtime-module.d.ts.map +1 -1
  7. package/dist/actions/action-runtime-module.js +18 -1
  8. package/dist/actions/action-runtime-module.js.map +1 -1
  9. package/dist/actions/close-position/close-position.action.d.ts.map +1 -1
  10. package/dist/actions/close-position/close-position.action.js +84 -11
  11. package/dist/actions/close-position/close-position.action.js.map +1 -1
  12. package/dist/actions/decision-engine.d.ts +0 -2
  13. package/dist/actions/decision-engine.d.ts.map +1 -1
  14. package/dist/actions/decision-engine.js +1 -79
  15. package/dist/actions/decision-engine.js.map +1 -1
  16. package/dist/actions/event-derivation.d.ts +40 -2
  17. package/dist/actions/event-derivation.d.ts.map +1 -1
  18. package/dist/actions/event-derivation.js +178 -5
  19. package/dist/actions/event-derivation.js.map +1 -1
  20. package/dist/actions/open-position/open-position.action.d.ts.map +1 -1
  21. package/dist/actions/open-position/open-position.action.js +103 -16
  22. package/dist/actions/open-position/open-position.action.js.map +1 -1
  23. package/dist/actions/position-tracker/position-tracker.action.d.ts +2 -1
  24. package/dist/actions/position-tracker/position-tracker.action.d.ts.map +1 -1
  25. package/dist/actions/position-tracker/position-tracker.action.js +47 -15
  26. package/dist/actions/position-tracker/position-tracker.action.js.map +1 -1
  27. package/dist/actions/skipped-signal-results.d.ts +16 -0
  28. package/dist/actions/skipped-signal-results.d.ts.map +1 -0
  29. package/dist/actions/skipped-signal-results.js +47 -0
  30. package/dist/actions/skipped-signal-results.js.map +1 -0
  31. package/dist/cli/deploy-render.d.ts +91 -0
  32. package/dist/cli/deploy-render.d.ts.map +1 -0
  33. package/dist/cli/deploy-render.js +216 -0
  34. package/dist/cli/deploy-render.js.map +1 -0
  35. package/dist/cli/guide-commands.d.ts.map +1 -1
  36. package/dist/cli/guide-commands.js +78 -6
  37. package/dist/cli/guide-commands.js.map +1 -1
  38. package/dist/cli/senpi-commands.d.ts +6 -1
  39. package/dist/cli/senpi-commands.d.ts.map +1 -1
  40. package/dist/cli/senpi-commands.js +164 -5
  41. package/dist/cli/senpi-commands.js.map +1 -1
  42. package/dist/cli/validate-command.d.ts.map +1 -1
  43. package/dist/cli/validate-command.js +32 -1
  44. package/dist/cli/validate-command.js.map +1 -1
  45. package/dist/deploy/deadlines.d.ts +47 -0
  46. package/dist/deploy/deadlines.d.ts.map +1 -0
  47. package/dist/deploy/deadlines.js +56 -0
  48. package/dist/deploy/deadlines.js.map +1 -0
  49. package/dist/deploy/error-text.d.ts +25 -0
  50. package/dist/deploy/error-text.d.ts.map +1 -0
  51. package/dist/deploy/error-text.js +42 -0
  52. package/dist/deploy/error-text.js.map +1 -0
  53. package/dist/deploy/funding.d.ts +87 -0
  54. package/dist/deploy/funding.d.ts.map +1 -0
  55. package/dist/deploy/funding.js +229 -0
  56. package/dist/deploy/funding.js.map +1 -0
  57. package/dist/deploy/install-gate-runner.d.ts +12 -0
  58. package/dist/deploy/install-gate-runner.d.ts.map +1 -0
  59. package/dist/deploy/install-gate-runner.js +17 -0
  60. package/dist/deploy/install-gate-runner.js.map +1 -0
  61. package/dist/deploy/job.d.ts +199 -0
  62. package/dist/deploy/job.d.ts.map +1 -0
  63. package/dist/deploy/job.js +463 -0
  64. package/dist/deploy/job.js.map +1 -0
  65. package/dist/deploy/min-budget.d.ts +68 -0
  66. package/dist/deploy/min-budget.d.ts.map +1 -0
  67. package/dist/deploy/min-budget.js +297 -0
  68. package/dist/deploy/min-budget.js.map +1 -0
  69. package/dist/deploy/orchestrator.d.ts +305 -0
  70. package/dist/deploy/orchestrator.d.ts.map +1 -0
  71. package/dist/deploy/orchestrator.js +2910 -0
  72. package/dist/deploy/orchestrator.js.map +1 -0
  73. package/dist/deploy/package.d.ts +130 -0
  74. package/dist/deploy/package.d.ts.map +1 -0
  75. package/dist/deploy/package.js +351 -0
  76. package/dist/deploy/package.js.map +1 -0
  77. package/dist/deploy/proof-gate.d.ts +82 -0
  78. package/dist/deploy/proof-gate.d.ts.map +1 -0
  79. package/dist/deploy/proof-gate.js +269 -0
  80. package/dist/deploy/proof-gate.js.map +1 -0
  81. package/dist/deploy/python-float.d.ts +34 -0
  82. package/dist/deploy/python-float.d.ts.map +1 -0
  83. package/dist/deploy/python-float.js +46 -0
  84. package/dist/deploy/python-float.js.map +1 -0
  85. package/dist/deploy/recheck-commands.d.ts +50 -0
  86. package/dist/deploy/recheck-commands.d.ts.map +1 -0
  87. package/dist/deploy/recheck-commands.js +59 -0
  88. package/dist/deploy/recheck-commands.js.map +1 -0
  89. package/dist/deploy/register.d.ts +99 -0
  90. package/dist/deploy/register.d.ts.map +1 -0
  91. package/dist/deploy/register.js +689 -0
  92. package/dist/deploy/register.js.map +1 -0
  93. package/dist/deploy/taxonomy.d.ts +24 -0
  94. package/dist/deploy/taxonomy.d.ts.map +1 -0
  95. package/dist/deploy/taxonomy.js +31 -0
  96. package/dist/deploy/taxonomy.js.map +1 -0
  97. package/dist/index.d.ts.map +1 -1
  98. package/dist/index.js +244 -132
  99. package/dist/index.js.map +1 -1
  100. package/dist/runtime/lifecycle-events.d.ts +13 -0
  101. package/dist/runtime/lifecycle-events.d.ts.map +1 -1
  102. package/dist/runtime/lifecycle-events.js +32 -0
  103. package/dist/runtime/lifecycle-events.js.map +1 -1
  104. package/dist/runtime/runtime.d.ts.map +1 -1
  105. package/dist/runtime/runtime.js +3 -1
  106. package/dist/runtime/runtime.js.map +1 -1
  107. package/dist/runtime/strategy-registry.d.ts +8 -0
  108. package/dist/runtime/strategy-registry.d.ts.map +1 -1
  109. package/dist/runtime/strategy-registry.js +14 -1
  110. package/dist/runtime/strategy-registry.js.map +1 -1
  111. package/dist/runtime/supervisor/long-running-supervisor.d.ts +8 -0
  112. package/dist/runtime/supervisor/long-running-supervisor.d.ts.map +1 -1
  113. package/dist/runtime/supervisor/long-running-supervisor.js +1 -0
  114. package/dist/runtime/supervisor/long-running-supervisor.js.map +1 -1
  115. package/dist/runtime-api/intake/intake-events.d.ts +19 -3
  116. package/dist/runtime-api/intake/intake-events.d.ts.map +1 -1
  117. package/dist/runtime-api/intake/intake-events.js +64 -2
  118. package/dist/runtime-api/intake/intake-events.js.map +1 -1
  119. package/dist/runtime-api/intake/intake-mount.d.ts.map +1 -1
  120. package/dist/runtime-api/intake/intake-mount.js +7 -4
  121. package/dist/runtime-api/intake/intake-mount.js.map +1 -1
  122. package/dist/runtime-api/intake/process-signal-post.d.ts.map +1 -1
  123. package/dist/runtime-api/intake/process-signal-post.js +7 -1
  124. package/dist/runtime-api/intake/process-signal-post.js.map +1 -1
  125. package/dist/runtime-api/intake/scanner-launcher.d.ts.map +1 -1
  126. package/dist/runtime-api/intake/scanner-launcher.js +12 -0
  127. package/dist/runtime-api/intake/scanner-launcher.js.map +1 -1
  128. package/dist/runtime-api/intake/types.d.ts +24 -0
  129. package/dist/runtime-api/intake/types.d.ts.map +1 -1
  130. package/dist/runtime-api/routes/signals.d.ts.map +1 -1
  131. package/dist/runtime-api/routes/signals.js +10 -1
  132. package/dist/runtime-api/routes/signals.js.map +1 -1
  133. package/dist/runtime-api/routes/signals.schema.d.ts +10 -0
  134. package/dist/runtime-api/routes/signals.schema.d.ts.map +1 -1
  135. package/dist/runtime-api/routes/signals.schema.js +14 -0
  136. package/dist/runtime-api/routes/signals.schema.js.map +1 -1
  137. package/dist/scanners/events.d.ts +7 -0
  138. package/dist/scanners/events.d.ts.map +1 -1
  139. package/dist/scanners/events.js.map +1 -1
  140. package/dist/scanners/external/scaffold/delivery.py +23 -12
  141. package/dist/scanners/external/scaffold/scaffold.py +55 -7
  142. package/dist/scanners/implementations/market-regime.d.ts +1 -1
  143. package/dist/scanners/runtime-module.d.ts.map +1 -1
  144. package/dist/scanners/runtime-module.js +10 -2
  145. package/dist/scanners/runtime-module.js.map +1 -1
  146. package/dist/senpi/client.d.ts +58 -4
  147. package/dist/senpi/client.d.ts.map +1 -1
  148. package/dist/senpi/client.js +192 -15
  149. package/dist/senpi/client.js.map +1 -1
  150. package/dist/senpi/strategy-status.d.ts +32 -0
  151. package/dist/senpi/strategy-status.d.ts.map +1 -0
  152. package/dist/senpi/strategy-status.js +70 -0
  153. package/dist/senpi/strategy-status.js.map +1 -0
  154. package/dist/senpi/types.d.ts +47 -3
  155. package/dist/senpi/types.d.ts.map +1 -1
  156. package/dist/skills-manager/manifest.js +1 -1
  157. package/dist/skills-manager/skills-manifest.json +1 -1
  158. package/dist/telemetry/event-builders.d.ts +45 -6
  159. package/dist/telemetry/event-builders.d.ts.map +1 -1
  160. package/dist/telemetry/event-builders.js +99 -11
  161. package/dist/telemetry/event-builders.js.map +1 -1
  162. package/dist/telemetry/metrics.d.ts +37 -2
  163. package/dist/telemetry/metrics.d.ts.map +1 -1
  164. package/dist/telemetry/metrics.js +84 -4
  165. package/dist/telemetry/metrics.js.map +1 -1
  166. package/dist/telemetry/scanner-tick-event.d.ts +32 -0
  167. package/dist/telemetry/scanner-tick-event.d.ts.map +1 -0
  168. package/dist/telemetry/scanner-tick-event.js +32 -0
  169. package/dist/telemetry/scanner-tick-event.js.map +1 -0
  170. package/dist/types/strategy.d.ts +9 -1
  171. package/dist/types/strategy.d.ts.map +1 -1
  172. package/dist/universe/package-universe.d.ts +97 -0
  173. package/dist/universe/package-universe.d.ts.map +1 -0
  174. package/dist/universe/package-universe.js +275 -0
  175. package/dist/universe/package-universe.js.map +1 -0
  176. package/dist/utils/event-catalog.d.ts +58 -0
  177. package/dist/utils/event-catalog.d.ts.map +1 -1
  178. package/dist/utils/event-catalog.js +1 -0
  179. package/dist/utils/event-catalog.js.map +1 -1
  180. package/dist/validate/codes.d.ts +20 -0
  181. package/dist/validate/codes.d.ts.map +1 -1
  182. package/dist/validate/codes.js +36 -0
  183. package/dist/validate/codes.js.map +1 -1
  184. package/dist/validate/import-stage.js +5 -5
  185. package/dist/validate/import-stage.js.map +1 -1
  186. package/dist/validate/index.d.ts +1 -1
  187. package/dist/validate/index.d.ts.map +1 -1
  188. package/dist/validate/index.js.map +1 -1
  189. package/dist/validate/install-gate.d.ts.map +1 -1
  190. package/dist/validate/install-gate.js +10 -2
  191. package/dist/validate/install-gate.js.map +1 -1
  192. package/dist/validate/live-instruments.d.ts +44 -0
  193. package/dist/validate/live-instruments.d.ts.map +1 -0
  194. package/dist/validate/live-instruments.js +71 -0
  195. package/dist/validate/live-instruments.js.map +1 -0
  196. package/dist/validate/live-stage.js +5 -5
  197. package/dist/validate/live-stage.js.map +1 -1
  198. package/dist/validate/proof.d.ts +11 -1
  199. package/dist/validate/proof.d.ts.map +1 -1
  200. package/dist/validate/proof.js +7 -6
  201. package/dist/validate/proof.js.map +1 -1
  202. package/dist/validate/recipe-checks.d.ts.map +1 -1
  203. package/dist/validate/recipe-checks.js +6 -4
  204. package/dist/validate/recipe-checks.js.map +1 -1
  205. package/dist/validate/run.d.ts +5 -0
  206. package/dist/validate/run.d.ts.map +1 -1
  207. package/dist/validate/run.js +10 -1
  208. package/dist/validate/run.js.map +1 -1
  209. package/dist/validate/target.d.ts +41 -0
  210. package/dist/validate/target.d.ts.map +1 -1
  211. package/dist/validate/target.js +192 -16
  212. package/dist/validate/target.js.map +1 -1
  213. package/dist/validate/universe-stage.d.ts +71 -0
  214. package/dist/validate/universe-stage.d.ts.map +1 -0
  215. package/dist/validate/universe-stage.js +183 -0
  216. package/dist/validate/universe-stage.js.map +1 -0
  217. package/openclaw.plugin.json +1 -1
  218. package/package.json +1 -1
  219. package/dist/runtime/managed-wallet-guard.d.ts +0 -47
  220. package/dist/runtime/managed-wallet-guard.d.ts.map +0 -1
  221. package/dist/runtime/managed-wallet-guard.js +0 -106
  222. package/dist/runtime/managed-wallet-guard.js.map +0 -1
  223. package/dist/runtime/protection-nudge.d.ts +0 -67
  224. package/dist/runtime/protection-nudge.d.ts.map +0 -1
  225. package/dist/runtime/protection-nudge.js +0 -244
  226. package/dist/runtime/protection-nudge.js.map +0 -1
@@ -0,0 +1,305 @@
1
+ import type { StrategySummary } from "../senpi/types.js";
2
+ import { type DeployPackage } from "./package.js";
3
+ export type JobPhase = "reconcile" | "preflight" | "create" | "install" | "observe";
4
+ export type StepName = "reconcile" | "preflight" | "create" | "install" | "observe";
5
+ export type StepStatus = "ok" | "skipped" | "pending" | "refused" | "failed" | "unobserved";
6
+ /** Emitted by runDeploy at every transition; seq/ts are stamped by the journaling layer (job.ts). */
7
+ export interface DeployEventBody {
8
+ type: "job" | "step";
9
+ /** job transitions */
10
+ phase?: JobPhase;
11
+ /** step outcomes */
12
+ instance?: string;
13
+ step?: StepName;
14
+ status?: StepStatus;
15
+ /** the SAME string the report carries */
16
+ detail: string;
17
+ /** verbatim surface quotes (totalFunded, scanner row…) */
18
+ evidence?: Record<string, unknown>;
19
+ }
20
+ export interface DeployEvent extends DeployEventBody {
21
+ seq: number;
22
+ ts: string;
23
+ }
24
+ /** The scanner-row fields the observe step reads; narrowed from `ScannerRegistrationSystemState`. */
25
+ export interface ScannerRowLite {
26
+ scannerId: string;
27
+ health: string;
28
+ enabled: boolean;
29
+ /** "interval" (built-in) vs "external" (supervised push) — decides which liveness fact applies */
30
+ scheduleMode: string;
31
+ lastRunStatus: string | null;
32
+ /** epoch ms; NAME-keyed telemetry survives a supervisor re-mint, so it MUST be freshness-checked */
33
+ lastRunFinishedAt: number | null;
34
+ /** epoch ms; ID-keyed external liveness — resets to null on re-mint, so freshness-safe by construction */
35
+ lastAliveAt: number | null;
36
+ nextRunAt: number | null;
37
+ runCount: number;
38
+ errorCount: number;
39
+ signalsProduced: number;
40
+ lastError: string | null;
41
+ }
42
+ export interface RegistryEntryLite {
43
+ id: string;
44
+ wallet?: string;
45
+ }
46
+ export interface DeployDeps {
47
+ listStrategies(filters?: {
48
+ strategyIds?: string[];
49
+ }): Promise<StrategySummary[]>;
50
+ createCustomStrategy(p: {
51
+ initialBudget: number;
52
+ strategyName?: string;
53
+ skillName: string;
54
+ skillVersion: string;
55
+ }): Promise<{
56
+ success: boolean;
57
+ strategyId?: string;
58
+ message?: string;
59
+ }>;
60
+ /** already forceFetch:true inside */
61
+ getPortfolio(): Promise<Record<string, unknown> | null>;
62
+ /**
63
+ * Non-delisted live instrument names (MCP `market_list_instruments` via
64
+ * `client.listInstrumentNames`). Same shape as `UniverseCheckDeps` — the deps object feeds
65
+ * `checkPackageUniverse` directly. [] = the list could not be read; the check treats empty as
66
+ * unavailable (fail-closed), NEVER as "everything is dead".
67
+ */
68
+ listLiveInstruments(): Promise<string[]>;
69
+ installRuntime(p: {
70
+ runtimeYamlContent: string;
71
+ runtimeYamlDir: string;
72
+ id: string;
73
+ }): Promise<{
74
+ ok: boolean;
75
+ /**
76
+ * `unwired` is the phase at which the runtime lost its entry scanners (`install_wire` /
77
+ * `install_launch` / `no_intake`). The install itself succeeded; the runtime is BLIND. Deploy
78
+ * refuses to call that a successful install — see {@link buildUnwiredInstallDetail}.
79
+ */
80
+ payload?: {
81
+ id: string;
82
+ name: string;
83
+ wallet: string;
84
+ unwired?: string;
85
+ };
86
+ error?: {
87
+ code: string;
88
+ message: string;
89
+ };
90
+ }>;
91
+ deleteRuntime(id: string): Promise<void>;
92
+ registryFindByWallet(wallet: string): Promise<RegistryEntryLite | undefined>;
93
+ registryFindById(id: string): Promise<RegistryEntryLite | undefined>;
94
+ getScannerRows(runtimeId: string): Promise<ScannerRowLite[] | null>;
95
+ /** H4: the registry row exists AND its `run()` handle is alive — a row alone proves nothing. */
96
+ runtimeIsLive(id: string): Promise<boolean>;
97
+ /**
98
+ * Wrap one phase in a span. Injected so `runDeploy` stays OTel-free (and pure): tests pass
99
+ * `(_n, _a, fn) => fn()`, register.ts passes `withSpan`. The value the phase fn resolves with is
100
+ * its worst step status — the wiring turns it into the phase metric's `status` dimension.
101
+ */
102
+ span<T>(name: string, attrs: Record<string, unknown>, fn: () => Promise<T>): Promise<T>;
103
+ /** true when the wallet holds zero open positions (client.listOpenPositions(wallet).length === 0) */
104
+ walletIsFlat(wallet: string): Promise<boolean>;
105
+ /** strategy_close via client.closeStrategy(wallet) — returns funds to the owner wallet on its own (D-7) */
106
+ closeStrategy(wallet: string): Promise<unknown>;
107
+ /** narration only — journaled by job.ts; MUST NOT affect flow */
108
+ emit(event: DeployEventBody): void;
109
+ /**
110
+ * The deploy deadline, checked at step boundaries and between poll iterations ONLY. Set by the
111
+ * job layer's wall-clock watchdog — never by a user, because there is no cancel verb (D-4).
112
+ */
113
+ shouldAbandon(): boolean;
114
+ now(): number;
115
+ sleep(ms: number): Promise<void>;
116
+ log(line: string): void;
117
+ }
118
+ export interface DeployParams {
119
+ pkg: DeployPackage;
120
+ budget?: number;
121
+ decisionModel?: string;
122
+ /** wallet-ACTIVE poll budget, default 150 (deploy.py DEFAULT_MAX_WAIT) */
123
+ maxWaitSec?: number;
124
+ /** verified-tick observe budget, default 120; 0 = skip */
125
+ tickWaitSec?: number;
126
+ /**
127
+ * C2 lookup keys: instance name → strategyIds this box journaled at create time (newest first),
128
+ * from `DeployJobController.priorCreatedStrategyIds`. Used ONLY when the name match finds
129
+ * nothing, and only after `listStrategies({ strategyIds })` confirms the id is still live — a
130
+ * journal supplies the key, the backend supplies the decision.
131
+ */
132
+ priorStrategyIds?: Map<string, string[]>;
133
+ /**
134
+ * D-9 lookup input, second form: strategyId → the amount a PRIOR run of this package journaled as
135
+ * its ask for that strategy, from `DeployJobController.priorRequestedFunding`.
136
+ *
137
+ * Why it exists: the ask lives only in the memory of the run that funded (`run.fundAmount`), so a
138
+ * deploy that funds $60 of a $500 ask and dies before assembling its report resumes as an
139
+ * ADOPTION — and the funded-vs-requested comparison never runs at all. The report reads `live`
140
+ * over a 12%-sized book, which is exactly the silent case this whole check exists to close.
141
+ *
142
+ * It stays inside the journal doctrine. The journal supplies ONE narration input — the ask — and
143
+ * nothing else: `funded` is always re-read live from `strategy_list` on this run, no orchestration
144
+ * branch consults it (no create, no close, no funding decision changes), and its only consumer is
145
+ * a warn. A stale or missing entry costs a warn, never an action.
146
+ */
147
+ priorRequested?: Map<string, number>;
148
+ }
149
+ export interface StepOutcome {
150
+ status: StepStatus;
151
+ detail: string;
152
+ evidence?: Record<string, unknown>;
153
+ }
154
+ export interface InstanceReport {
155
+ instance: string;
156
+ wallet?: string;
157
+ strategyId?: string;
158
+ funded?: number;
159
+ runtimeId?: string;
160
+ /** D-6: this job created the wallet, its install failed, and the close+refund completed. */
161
+ rolledBack?: boolean;
162
+ steps: {
163
+ reconcile: StepOutcome;
164
+ preflight: StepOutcome;
165
+ create: StepOutcome;
166
+ install: StepOutcome;
167
+ observe: StepOutcome;
168
+ };
169
+ }
170
+ export interface DeployReport {
171
+ packageId: string;
172
+ version: string;
173
+ overall: "live" | "installed-unobserved" | "pending" | "refused" | "failed";
174
+ instances: InstanceReport[];
175
+ next?: string;
176
+ /**
177
+ * What deploying the WHOLE package fresh would need (see {@link packageMinBudget}), present only
178
+ * when this deploy actually planned to fund a new wallet.
179
+ *
180
+ * CONTEXT, not the claim: on a partially-adopted deploy the budget is split only among the
181
+ * instances still needing a wallet, so this figure is not the yardstick for what any one wallet
182
+ * receives — {@link DeployReport.belowMin} is. Read them as "the package wants $30 across 2
183
+ * wallets" and "…and something this deploy funded came up short", separately.
184
+ *
185
+ * The whole `min*` group below is ADVISORY: it never changes `overall`, never produces a
186
+ * `refused` step, and never stops anything. The hard money gate is the {@link MIN_WALLET} ×
187
+ * wallets floor, which refuses through the `preflight` step like every other refusal.
188
+ */
189
+ minBudget?: number;
190
+ /** Wallets {@link DeployReport.minBudget} is spread across — every instance, adopted ones included. */
191
+ minWalletCount?: number;
192
+ /**
193
+ * true = the funding PLAN allocated at least one wallet less than its own sizing needs.
194
+ *
195
+ * A claim about the plan, deliberately, and it stays true on a deploy that then failed before
196
+ * creating anything: the budget really was sized too small, and that is the fact worth counting
197
+ * (an agent sizing budgets badly is the signal; whether an unrelated backend error followed is
198
+ * not). The NOTE marks the difference in tense — "would have funded" when nothing landed — so the
199
+ * prose never claims money moved, while the metric keeps the whole population.
200
+ *
201
+ * Deliberately NOT "the budget is below `minBudget`": those differ whenever some instances were
202
+ * adopted, because the plan splits the budget among fewer wallets than the package minimum
203
+ * assumes.
204
+ *
205
+ * Set whenever it holds, INCLUDING alongside `minBudgetUnresolved` — the two are not exclusive.
206
+ * Suppressing it on the unresolved path made the telemetry assert the opposite of the truth.
207
+ * Which note leads is a separate decision (see `softLead`).
208
+ */
209
+ belowMin?: boolean;
210
+ /**
211
+ * The `[W_BUDGET_BELOW_STRATEGY_MIN]` / `[W_BUDGET_UNRESOLVED]` warn, verbatim. Exactly one code
212
+ * leads; when both conditions hold, the unresolved note leads and carries the shortfall sentence.
213
+ */
214
+ minBudgetNote?: string;
215
+ /** Sleeves whose sizing did not resolve — the minimum above may be understated. */
216
+ minBudgetUnresolved?: string[];
217
+ /**
218
+ * The `[W_BUDGET_PARTIAL_FUND]` warn, verbatim: the backend landed materially less on a wallet
219
+ * than this deploy asked it to.
220
+ *
221
+ * Independent of the whole `min*` group above and can ride the same report. Those judge the
222
+ * funding PLAN against the package's own sizing BEFORE anything is created; this one judges what
223
+ * the backend actually did, by comparing the post-create strategy read's `totalFunded` against
224
+ * the amount `planFunding` allocated. Nothing else on the report closes that loop — the create
225
+ * step quotes `totalFunded` as a bare fact, so a $500 ask that lands $60 used to report `live`.
226
+ *
227
+ * ADVISORY, like the soft tier: the strategy is live and trading, so `overall` and the exit code
228
+ * are untouched. It is emphatically NOT a `not-live` verdict — the wallet holds real money, and a
229
+ * report calling it not-live invites the teardown of a funded, running strategy.
230
+ */
231
+ partialFundNote?: string;
232
+ /**
233
+ * The `[W_BUDGET_FUNDED_UNREADABLE]` advisory, verbatim: the same OUTCOME comparison as
234
+ * {@link partialFundNote}, on a wallet whose funded amount the backend did not report.
235
+ *
236
+ * Its own code rather than a variant of the warn above, because the two steer opposite actions:
237
+ * the partial-fund warn names a shortfall and a top-up, this one forbids both and routes to the
238
+ * USER to establish the real figure. Mutually exclusive per wallet by construction.
239
+ */
240
+ fundedUnreadableNote?: string;
241
+ }
242
+ /**
243
+ * Record that an instance is bound to `strategyId` — the WRITE half of the reconcile claim ledger
244
+ * (see `claimed` in {@link runDeploy}).
245
+ *
246
+ * An unreadable id is not claimable. `listStrategies` coerces a missing or unparseable id to `""`
247
+ * (senpi/client.ts), and a `""` in the ledger answers "already accounted for" for every OTHER
248
+ * unreadable-id wallet in the same read — which is exactly how a second live funded wallet became
249
+ * invisible to the gate. Not recording it is the fail-closed direction: the gate keeps presenting
250
+ * it and the run refuses rather than funding beside it.
251
+ *
252
+ * **Either this guard or {@link isAccountedFor}'s alone closes that hole; both are kept
253
+ * deliberately.** Delete this one and the suite still passes on the deploy paths — the read guard
254
+ * covers it. That is defence in depth, not dead code, and `orchestrator.test.ts` pins each half
255
+ * separately so neither can be removed as redundant.
256
+ */
257
+ export declare function claimStrategyId(claimed: Set<string>, strategyId: string | undefined): void;
258
+ /**
259
+ * Is this live strategy PROVEN to be accounted for by an instance of this run? — the READ half of
260
+ * the same ledger.
261
+ *
262
+ * Fail-closed on an unreadable id: it can never have been claimed and can never be matched, so it
263
+ * can never be proven accounted for. Resting that on `claimed.has("")` happening to answer false is
264
+ * not a property to give a money gate — it is only true while the write half holds. Same rule this
265
+ * file already applies to an unreadable `totalFunded` and an unreadable `skillName`: unknown is
266
+ * never zero, and unknown is never "not ours".
267
+ *
268
+ * **Either this guard or {@link claimStrategyId}'s alone closes the hole; both are kept
269
+ * deliberately** — see there.
270
+ */
271
+ export declare function isAccountedFor(claimed: ReadonlySet<string>, strategyId: string | undefined): boolean;
272
+ /**
273
+ * Run one phase inside an injected span, surviving a tracer that throws.
274
+ *
275
+ * Same rule as narration's `emit` and `log` — telemetry may not decide what a deploy does — but
276
+ * with the largest blast radius of the three: the span wraps EVERY phase, including create and
277
+ * install, so a throwing tracer escaped `runDeploy` after a wallet had been funded and left the job
278
+ * layer synthesizing an empty `instances: []` report over a live funded wallet.
279
+ *
280
+ * It is deliberately NOT "on failure, run the body": **the body is only safe to run once.** A
281
+ * tracer that fails while ENDING a span has already run it, and re-running `deploy.create` is a
282
+ * second funded wallet — telemetry causing the exact loss this file is built to prevent. So the
283
+ * body is invoked through a one-shot handle and the two cases are told apart by whether it fired:
284
+ *
285
+ * - the tracer failed BEFORE reaching the body — run it here, un-spanned, and return its value;
286
+ * - the tracer failed AFTER the body ran — the body's own outcome is the truth, including its
287
+ * rejection if it had one. A tracer that masks a failing body with an error of its own therefore
288
+ * cannot hide the real cause: what surfaces is the body's error, not the tracer's.
289
+ *
290
+ * Module-scope and exported for ONE reason: the synchronous-throw edge below is unreachable through
291
+ * `runDeploy` (every call site passes an async arrow), so it can only be pinned here.
292
+ *
293
+ * @param spanFn the injected tracer — assumed to call `handle` at most once; calling it more often
294
+ * is harmless, since the handle collapses to the first invocation either way
295
+ * @param log narration for the degraded path; must not throw (callers pass the guarded wrapper)
296
+ * @returns whatever the body resolves with — never the tracer's own value on a failure
297
+ */
298
+ export declare function spanOnce<T>(spanFn: DeployDeps["span"], log: (line: string) => void, name: string, attrs: Record<string, unknown>, body: () => Promise<T>): Promise<T>;
299
+ /**
300
+ * Sequential orchestration of one deploy. Resolves with a report in every case —
301
+ * refusals and failures are reported, never thrown, so the job layer always has
302
+ * a truthful terminal state to journal.
303
+ */
304
+ export declare function runDeploy(params: DeployParams, deps: DeployDeps): Promise<DeployReport>;
305
+ //# sourceMappingURL=orchestrator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../../src/deploy/orchestrator.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAOzD,OAAO,EAWL,KAAK,aAAa,EAGnB,MAAM,cAAc,CAAC;AAoCtB,MAAM,MAAM,QAAQ,GAAG,WAAW,GAAG,WAAW,GAAG,QAAQ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