@senpi/runtime 3.0.106 → 3.0.108

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 (38) hide show
  1. package/dist/actions/close-position/close-position.action.d.ts.map +1 -1
  2. package/dist/actions/close-position/close-position.action.js +5 -3
  3. package/dist/actions/close-position/close-position.action.js.map +1 -1
  4. package/dist/actions/open-position/open-position.action.d.ts +33 -0
  5. package/dist/actions/open-position/open-position.action.d.ts.map +1 -1
  6. package/dist/actions/open-position/open-position.action.js +208 -57
  7. package/dist/actions/open-position/open-position.action.js.map +1 -1
  8. package/dist/dsl/monitor/process-one-position.js +40 -8
  9. package/dist/dsl/monitor/process-one-position.js.map +1 -1
  10. package/dist/runtime/__tests__/helpers/runtime-gateway-harness.d.ts +6 -0
  11. package/dist/runtime/__tests__/helpers/runtime-gateway-harness.d.ts.map +1 -1
  12. package/dist/runtime/__tests__/helpers/runtime-gateway-harness.js +25 -0
  13. package/dist/runtime/__tests__/helpers/runtime-gateway-harness.js.map +1 -1
  14. package/dist/runtime/create-runtime-context.d.ts.map +1 -1
  15. package/dist/runtime/create-runtime-context.js +5 -0
  16. package/dist/runtime/create-runtime-context.js.map +1 -1
  17. package/dist/runtime/pending-opens-ledger.d.ts +93 -0
  18. package/dist/runtime/pending-opens-ledger.d.ts.map +1 -0
  19. package/dist/runtime/pending-opens-ledger.js +118 -0
  20. package/dist/runtime/pending-opens-ledger.js.map +1 -0
  21. package/dist/runtime/runtime.d.ts.map +1 -1
  22. package/dist/runtime/runtime.js.map +1 -1
  23. package/dist/senpi/client.d.ts +2 -4
  24. package/dist/senpi/client.d.ts.map +1 -1
  25. package/dist/senpi/client.js +15 -1
  26. package/dist/senpi/client.js.map +1 -1
  27. package/dist/senpi/types.d.ts +9 -0
  28. package/dist/senpi/types.d.ts.map +1 -1
  29. package/dist/strategy/strategy-state.d.ts +28 -4
  30. package/dist/strategy/strategy-state.d.ts.map +1 -1
  31. package/dist/strategy/strategy-state.js +48 -20
  32. package/dist/strategy/strategy-state.js.map +1 -1
  33. package/dist/types/runtime.d.ts +9 -0
  34. package/dist/types/runtime.d.ts.map +1 -1
  35. package/dist/types/strategy.d.ts +8 -4
  36. package/dist/types/strategy.d.ts.map +1 -1
  37. package/openclaw.plugin.json +1 -1
  38. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"close-position.action.d.ts","sourceRoot":"","sources":["../../../src/actions/close-position/close-position.action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,YAAY,EACZ,aAAa,EACb,cAAc,EACd,YAAY,EACZ,SAAS,EAEV,MAAM,aAAa,CAAC;AAIrB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAe3D,qBAAa,mBAAoB,YAAW,MAAM;IAO9C,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,OAAO;IAPjB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAG,gBAAgB,CAAU;IAEhD,OAAO,CAAC,cAAc,CAAiB;gBAG7B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,cAAc;IASjC,OAAO,CAAC,QAAQ;IAYV,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC;IAgLrD,OAAO,CAAC,gBAAgB;YAQV,aAAa;CA4J5B;AAID,eAAO,MAAM,oBAAoB,EAAE,aACO,CAAC;AAE3C,eAAO,MAAM,qBAAqB,EAAE,cAMnC,CAAC"}
1
+ {"version":3,"file":"close-position.action.d.ts","sourceRoot":"","sources":["../../../src/actions/close-position/close-position.action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,YAAY,EACZ,aAAa,EACb,cAAc,EACd,YAAY,EACZ,SAAS,EAEV,MAAM,aAAa,CAAC;AAIrB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAe3D,qBAAa,mBAAoB,YAAW,MAAM;IAO9C,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,OAAO;IAPjB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAG,gBAAgB,CAAU;IAEhD,OAAO,CAAC,cAAc,CAAiB;gBAG7B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,cAAc;IASjC,OAAO,CAAC,QAAQ;IAYV,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC;IAkLrD,OAAO,CAAC,gBAAgB;YAQV,aAAa;CA4J5B;AAID,eAAO,MAAM,oBAAoB,EAAE,aACO,CAAC;AAE3C,eAAO,MAAM,qBAAqB,EAAE,cAMnC,CAAC"}
@@ -75,9 +75,11 @@ export class ClosePositionAction {
75
75
  error: 'strategy_address_mismatch',
76
76
  };
77
77
  }
78
- // Refresh clearinghouse so hasOpenPosition reflects live positions — recipes
79
- // without a DSL monitor or open-position action never populate this cache
80
- // otherwise, and every close would short-circuit as 'no_open_position'.
78
+ // Refresh clearinghouse so hasOpenPosition reflects live positions. Nothing else
79
+ // refreshes THIS object: the DSL monitor holds a different StrategyState instance (the
80
+ // one in the shared `strategyStates` map), so its per-tick fetches never reach this
81
+ // cache. Without this line every close would read a view written by some earlier action
82
+ // on this context, or none at all, and short-circuit as 'no_open_position'.
81
83
  await strategyState.fetchClearinghouseState();
82
84
  // ── Static params path (bypasses decision engine) ──
83
85
  if (this.config.decision_mode === 'none' && typeof this.config.params?.asset === 'string') {
@@ -1 +1 @@
1
- {"version":3,"file":"close-position.action.js","sourceRoot":"","sources":["../../../src/actions/close-position/close-position.action.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAEtH,OAAO,EAAE,UAAU,EAAE,MAA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,OAAO;YACP,IAAI,EAAE;gBACJ,OAAO;gBACP,WAAW;gBACX,WAAW;gBACX,YAAY;gBACZ,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACxC,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,cAAc,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACzE;SACF,CAAC;QACF,sBAAsB,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC;QACtF,OAAO,YAAY,CAAC;IACtB,CAAC;CACF;AAED,+EAA+E;AAE/E,MAAM,CAAC,MAAM,oBAAoB,GAAkB,CAAC,MAAoB,EAAE,OAAuB,EAAE,EAAE,CACnG,IAAI,mBAAmB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE3C,MAAM,CAAC,MAAM,qBAAqB,GAAmB;IACnD,IAAI,EAAE,uBAAuB;IAC7B,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,qDAAqD;IAClE,cAAc,EAAE,CAAC,UAAU,CAAC,kBAAkB,CAAC;IAC/C,aAAa,EAAE,CAAC,UAAU,CAAC,kBAAkB,CAAC;CAC/C,CAAC"}
1
+ {"version":3,"file":"close-position.action.js","sourceRoot":"","sources":["../../../src/actions/close-position/close-position.action.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAEtH,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,6BAA6B,EAAE,MAAM,mCAAmC,CAAC;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AI,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACxC,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,cAAc,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACzE;SACF,CAAC;QACF,sBAAsB,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC;QACtF,OAAO,YAAY,CAAC;IACtB,CAAC;CACF;AAED,+EAA+E;AAE/E,MAAM,CAAC,MAAM,oBAAoB,GAAkB,CAAC,MAAoB,EAAE,OAAuB,EAAE,EAAE,CACnG,IAAI,mBAAmB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE3C,MAAM,CAAC,MAAM,qBAAqB,GAAmB;IACnD,IAAI,EAAE,uBAAuB;IAC7B,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,qDAAqD;IAClE,cAAc,EAAE,CAAC,UAAU,CAAC,kBAAkB,CAAC;IAC/C,aAAa,EAAE,CAAC,UAAU,CAAC,kBAAkB,CAAC;CAC/C,CAAC"}
@@ -6,9 +6,42 @@ export declare class OpenPositionAction implements Action {
6
6
  readonly name: string;
7
7
  readonly actionType: "OPEN_POSITION";
8
8
  private decisionEngine;
9
+ /**
10
+ * Ledger of last resort for a context that carries none (standalone scripts, older call
11
+ * sites). Private to this action, so it still counts this action's own in-flight opens.
12
+ */
13
+ private readonly ownPendingOpens;
14
+ /**
15
+ * Edge-trigger state for the full-book log: `full` is the level, the rest bound the repeat
16
+ * rate while it stays full. Instance state on purpose — a full book is a property of this
17
+ * strategy, and the action is one per recipe.
18
+ */
19
+ private noSlotsLog;
9
20
  constructor(config: ActionConfig, context: RuntimeContext);
10
21
  private eventCtx;
11
22
  handle(event: HookEvent): Promise<ActionResult>;
23
+ /** The pending-opens ledger this action counts against — the context's when it has one. */
24
+ private pendingOpens;
25
+ /**
26
+ * Edge-triggered full-book log: once on the transition into full, then at most once per
27
+ * {@link NO_SLOTS_LOG_INTERVAL_MS} with the count it suppressed in between.
28
+ *
29
+ * The early `no_slots` skip used to return silently, so a strategy that had stopped
30
+ * entering looked identical in the logs to one with no signals — the single hardest state
31
+ * to diagnose from a box. Logging every signal instead would bury the log, which is how it
32
+ * came to be silent in the first place.
33
+ */
34
+ private logBookFull;
35
+ /**
36
+ * Never open against an unknown exchange view. If the view is undefined after retries we
37
+ * cannot tell what is already open or how much free margin exists — skip every signal
38
+ * rather than risk a duplicate or an over-margined open.
39
+ *
40
+ * Shared by both read sites (the gate at the top of `handle`, and the stale-view refetch in
41
+ * the signal loop). `sorted` is empty at the early site — there is no decision, hence no
42
+ * candidates, yet — which is why the entries are built from it rather than assumed.
43
+ */
44
+ private skipClearinghouseUnknown;
12
45
  private normalizeSignals;
13
46
  private handleSignals;
14
47
  }
@@ -1 +1 @@
1
- {"version":3,"file":"open-position.action.d.ts","sourceRoot":"","sources":["../../../src/actions/open-position/open-position.action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,YAAY,EAEZ,aAAa,EACb,cAAc,EACd,YAAY,EACZ,SAAS,EAEV,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AA6BtD,qBAAa,kBAAmB,YAAW,MAAM;IAO7C,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,OAAO;IAPjB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAG,eAAe,CAAU;IAE/C,OAAO,CAAC,cAAc,CAAiB;gBAG7B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,cAAc;IASjC,OAAO,CAAC,QAAQ;IAYV,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC;IA4MrD,OAAO,CAAC,gBAAgB;YAaV,aAAa;CAke5B;AAID,eAAO,MAAM,mBAAmB,EAAE,aACO,CAAC;AAE1C,eAAO,MAAM,oBAAoB,EAAE,cAMlC,CAAC"}
1
+ {"version":3,"file":"open-position.action.d.ts","sourceRoot":"","sources":["../../../src/actions/open-position/open-position.action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,YAAY,EAEZ,aAAa,EACb,cAAc,EACd,YAAY,EACZ,SAAS,EAEV,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAuDtD,qBAAa,kBAAmB,YAAW,MAAM;IAwB7C,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,OAAO;IAxBjB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAG,eAAe,CAAU;IAE/C,OAAO,CAAC,cAAc,CAAiB;IAEvC;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAkD;IAElF;;;;OAIG;IACH,OAAO,CAAC,UAAU,CAIhB;gBAGQ,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,cAAc;IASjC,OAAO,CAAC,QAAQ;IAYV,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC;IAyOrD,2FAA2F;IAC3F,OAAO,CAAC,YAAY;IAIpB;;;;;;;;OAQG;IACH,OAAO,CAAC,WAAW;IA4BnB;;;;;;;;OAQG;IACH,OAAO,CAAC,wBAAwB;IAwChC,OAAO,CAAC,gBAAgB;YAaV,aAAa;CAuf5B;AAID,eAAO,MAAM,mBAAmB,EAAE,aACO,CAAC;AAE1C,eAAO,MAAM,oBAAoB,EAAE,cAMlC,CAAC"}
@@ -15,11 +15,27 @@ import { emitActionResultEvents, emitOrderPlaced, emitOrderFilled, emitOrderFail
15
15
  import { withSpan } from '../../telemetry/tracing.js';
16
16
  import { SpanStatusCode } from '@opentelemetry/api';
17
17
  import { classifyToolError } from '../../senpi/tool-errors.js';
18
+ import { hasOpenPositionIn } from '../../strategy/strategy-state.js';
19
+ import { createPendingOpensLedger, pendingOpenKey } from '../../runtime/pending-opens-ledger.js';
20
+ import { recordSignalOutcome } from '../../telemetry/metrics.js';
18
21
  const logger = createLogger("[actions][open-position]");
19
22
  /** Hyperliquid minimum notional value (margin × leverage) required to open a position. */
20
23
  const MIN_NOTIONAL_VALUE = 10;
21
24
  /** Minimum leverage floor — positions cannot go below 1x. */
22
25
  const MIN_LEVERAGE = 1;
26
+ /**
27
+ * How long the view fetched at the top of `handle` is trusted before the signal loop
28
+ * refetches it.
29
+ *
30
+ * The gap between the two is a decision, and an LLM decision takes seconds — long enough
31
+ * for a fill, a liquidation or a manual close to move the book underneath the numbers the
32
+ * entry is about to be sized against. Five seconds is the order of the snapshot's own age,
33
+ * so anything older is worth a second read; the rule-decision path resolves well inside it
34
+ * and never pays for one.
35
+ */
36
+ const CLEARINGHOUSE_VIEW_MAX_AGE_MS = 5_000;
37
+ /** Minimum gap between repeats of the full-book log while the book STAYS full. */
38
+ const NO_SLOTS_LOG_INTERVAL_MS = 30 * 60 * 1000;
23
39
  // ─── Open Position Action ───────────────────────────────────────────────────
24
40
  export class OpenPositionAction {
25
41
  config;
@@ -27,6 +43,21 @@ export class OpenPositionAction {
27
43
  name;
28
44
  actionType = 'OPEN_POSITION';
29
45
  decisionEngine;
46
+ /**
47
+ * Ledger of last resort for a context that carries none (standalone scripts, older call
48
+ * sites). Private to this action, so it still counts this action's own in-flight opens.
49
+ */
50
+ ownPendingOpens = createPendingOpensLedger();
51
+ /**
52
+ * Edge-trigger state for the full-book log: `full` is the level, the rest bound the repeat
53
+ * rate while it stays full. Instance state on purpose — a full book is a property of this
54
+ * strategy, and the action is one per recipe.
55
+ */
56
+ noSlotsLog = {
57
+ full: false,
58
+ lastLoggedAt: 0,
59
+ suppressed: 0,
60
+ };
30
61
  constructor(config, context) {
31
62
  this.config = config;
32
63
  this.context = context;
@@ -101,25 +132,53 @@ export class OpenPositionAction {
101
132
  skipReason: 'strategy_backend_paused',
102
133
  };
103
134
  }
104
- // Early exit: no slots.
135
+ // The exchange view for THIS pass. Read here, once, and threaded through the rest of it.
136
+ //
137
+ // This context's StrategyState is not the instance the DSL monitor refreshes each tick —
138
+ // they are two objects built from the same config — so its cached view was only ever
139
+ // written by an earlier pass through this action, if at all. Reading the cache therefore
140
+ // froze the slot gate, the dedupe check and the margin budget at whatever the first
141
+ // signal after boot happened to see: a full snapshot skipped every later signal forever,
142
+ // an empty one let the slot cap and the dedupe never bind at all.
143
+ const view = await strategyState.fetchClearinghouseState({ retryUnreadable: true });
144
+ if (view === undefined) {
145
+ return this.skipClearinghouseUnknown(event, address, [], undefined, undefined, { scanResult });
146
+ }
147
+ const snapshot = { view, fetchedAt: Date.now() };
148
+ // Early exit: no slots. Counted as snapshot positions PLUS opens this runtime has already
149
+ // submitted that the snapshot is too old to show (see PendingOpensLedger).
150
+ //
105
151
  // NOTE re "zero slots skips cap alerts": we intentionally do NOT evaluate risk
106
152
  // halts/cap self-pause here. It would add a per-signal getPnlHistoryWithSnapshot
107
153
  // MCP call on the full-book path (costly on a full + high-signal-rate strategy),
108
154
  // and that halt data is fetched nowhere else to reuse (only risk-guard.checkGate
109
- // fetches it; the DSL monitor fetches clearinghouse = different data). Self-pause
155
+ // fetches it — the clearinghouse read above is different data). Self-pause
110
156
  // alerts still fire via the normal open path once a slot frees and a signal
111
157
  // arrives (delayed, not lost). A durable fix — a periodic lifecycle driven off
112
158
  // the monitor tick / bus events (also catches a fully-silent producer) — is
113
159
  // deliberately out of scope here.
114
- if (!strategyState.getAvailableSlots?.()) {
160
+ const ledger = this.pendingOpens();
161
+ ledger.reconcile(view.positions);
162
+ const pending = ledger.unseen(view.positions);
163
+ const slots = strategyState.config.slots;
164
+ const openCount = view.positions.length + pending.length;
165
+ if (openCount >= slots) {
166
+ this.logBookFull(address, openCount, slots, pending.map((p) => p.coin), view.positions);
167
+ // The per-signal `results[]`/event fan-out is deliberately NOT built here: a full book
168
+ // on a high-signal-rate strategy is the loudest path there is, and the outcome is one
169
+ // fact about the strategy, not one per candidate. The counter still carries it.
170
+ recordSignalOutcome({ result: 'skipped', reasonCode: 'no_slots' });
115
171
  return {
116
172
  success: true,
117
173
  action_type: this.actionType,
118
- summary: 'No slots available',
174
+ summary: `No slots available (${openCount}/${slots} open)`,
119
175
  skipped: true,
120
176
  skipReason: 'no_slots',
177
+ data: { openCount, slots, pendingCount: pending.length },
121
178
  };
122
179
  }
180
+ // A pass with room re-arms the edge, so the next time the book fills it is logged again.
181
+ this.noSlotsLog.full = false;
123
182
  logger.info('building context');
124
183
  // Build context
125
184
  const providerRequest = {
@@ -235,7 +294,82 @@ export class OpenPositionAction {
235
294
  emitActionResultEvents(eventCtx, event, address, invalidPayloadResult, trackingExtras);
236
295
  return invalidPayloadResult;
237
296
  }
238
- return this.handleSignals(signals, event, strategyState, decision.reasoning, meta, interpolatedPrompt, trackingExtras);
297
+ return this.handleSignals(signals, event, strategyState, snapshot, decision.reasoning, meta, interpolatedPrompt, trackingExtras);
298
+ }
299
+ /** The pending-opens ledger this action counts against — the context's when it has one. */
300
+ pendingOpens() {
301
+ return this.context.pendingOpensLedger ?? this.ownPendingOpens;
302
+ }
303
+ /**
304
+ * Edge-triggered full-book log: once on the transition into full, then at most once per
305
+ * {@link NO_SLOTS_LOG_INTERVAL_MS} with the count it suppressed in between.
306
+ *
307
+ * The early `no_slots` skip used to return silently, so a strategy that had stopped
308
+ * entering looked identical in the logs to one with no signals — the single hardest state
309
+ * to diagnose from a box. Logging every signal instead would bury the log, which is how it
310
+ * came to be silent in the first place.
311
+ */
312
+ logBookFull(address, openCount, slots, pendingCoins, positions) {
313
+ const now = Date.now();
314
+ const attributes = {
315
+ wallet: address,
316
+ open: openCount,
317
+ slots,
318
+ pending: pendingCoins.length,
319
+ coins: [...positions.map((p) => p.coin), ...pendingCoins],
320
+ };
321
+ if (!this.noSlotsLog.full) {
322
+ this.noSlotsLog = { full: true, lastLoggedAt: now, suppressed: 0 };
323
+ logger.info('skipping: no_slots', attributes);
324
+ return;
325
+ }
326
+ this.noSlotsLog.suppressed++;
327
+ if (now - this.noSlotsLog.lastLoggedAt >= NO_SLOTS_LOG_INTERVAL_MS) {
328
+ logger.info('skipping: no_slots', { ...attributes, suppressed: this.noSlotsLog.suppressed });
329
+ this.noSlotsLog.lastLoggedAt = now;
330
+ this.noSlotsLog.suppressed = 0;
331
+ }
332
+ }
333
+ /**
334
+ * Never open against an unknown exchange view. If the view is undefined after retries we
335
+ * cannot tell what is already open or how much free margin exists — skip every signal
336
+ * rather than risk a duplicate or an over-margined open.
337
+ *
338
+ * Shared by both read sites (the gate at the top of `handle`, and the stale-view refetch in
339
+ * the signal loop). `sorted` is empty at the early site — there is no decision, hence no
340
+ * candidates, yet — which is why the entries are built from it rather than assumed.
341
+ */
342
+ skipClearinghouseUnknown(event, address, sorted, meta, decisionPrompt, trackingExtras) {
343
+ const skippedResults = sorted.map((signal) => ({
344
+ asset: signal.asset,
345
+ direction: signal.direction,
346
+ dex: typeof signal.dex === 'string' && signal.dex.trim() !== '' ? signal.dex.trim() : 'main',
347
+ score: signal.score,
348
+ success: true,
349
+ reason: 'clearinghouse_unknown',
350
+ }));
351
+ logger.error('Skipping open: clearinghouse view unknown after retries', {
352
+ wallet: address,
353
+ skippedCount: skippedResults.length,
354
+ assets: skippedResults.map((r) => r.asset),
355
+ });
356
+ const skipResult = {
357
+ success: true,
358
+ action_type: this.actionType,
359
+ summary: 'Clearinghouse view unknown — skipped open',
360
+ skipped: true,
361
+ skipReason: 'clearinghouse_unknown',
362
+ data: {
363
+ results: skippedResults,
364
+ submittedCount: 0,
365
+ failedCount: 0,
366
+ skippedCount: skippedResults.length,
367
+ ...(meta ? { _decisionMeta: meta } : {}),
368
+ _decisionPrompt: decisionPrompt ?? null,
369
+ },
370
+ };
371
+ emitActionResultEvents(this.eventCtx(), event, address, skipResult, trackingExtras);
372
+ return skipResult;
239
373
  }
240
374
  normalizeSignals(payload) {
241
375
  if (Array.isArray(payload.signals))
@@ -250,7 +384,7 @@ export class OpenPositionAction {
250
384
  }
251
385
  return [];
252
386
  }
253
- async handleSignals(signals, event, strategyState, reasoning, meta, decisionPrompt, trackingExtras) {
387
+ async handleSignals(signals, event, strategyState, snapshot, reasoning, meta, decisionPrompt, trackingExtras) {
254
388
  const address = event.address;
255
389
  const orderType = resolveOpenOrderType(this.config.params?.order_type);
256
390
  const feeOptimizedLimitOptions = orderType === 'FEE_OPTIMIZED_LIMIT'
@@ -277,58 +411,39 @@ export class OpenPositionAction {
277
411
  return undefined;
278
412
  })(),
279
413
  (async () => {
280
- // Resolve the exchange view once: it sizes margin_pct AND feeds the
281
- // free-margin pre-flight below. A cached defined view is trusted;
282
- // otherwise fetch with retry-on-unreadable so a transient unreadable
283
- // response is retried rather than treated as an unknown book.
284
- return strategyState.getClearinghouseState()
285
- ?? await strategyState.fetchClearinghouseState({ retryUnreadable: true });
414
+ // The view handed down from the slot gate, re-read only if the decision took long
415
+ // enough for it to go stale. No cached-getter fallback: the only view this action
416
+ // trusts is one it read itself, on this pass.
417
+ if (Date.now() - snapshot.fetchedAt <= CLEARINGHOUSE_VIEW_MAX_AGE_MS)
418
+ return snapshot.view;
419
+ return strategyState.fetchClearinghouseState({ retryUnreadable: true });
286
420
  })(),
287
421
  ]);
288
422
  riskSnapshot = riskSnapResult;
289
- // Never open against an unknown exchange view. If the view is still
290
- // undefined after retries, we cannot tell what is already open or how much
291
- // free margin exists — skip every signal rather than risk a duplicate or
292
- // over-margined open.
293
423
  if (clearinghouseView === undefined) {
294
- const skippedResults = sorted.map((signal) => ({
295
- asset: signal.asset,
296
- direction: signal.direction,
297
- dex: typeof signal.dex === 'string' && signal.dex.trim() !== '' ? signal.dex.trim() : 'main',
298
- score: signal.score,
299
- success: true,
300
- reason: 'clearinghouse_unknown',
301
- }));
302
- logger.error('Skipping open: clearinghouse view unknown after retries', {
303
- wallet: address,
304
- skippedCount: skippedResults.length,
305
- assets: skippedResults.map((r) => r.asset),
306
- });
307
- const skipResult = {
308
- success: true,
309
- action_type: this.actionType,
310
- summary: 'Clearinghouse view unknown — skipped open',
311
- skipped: true,
312
- skipReason: 'clearinghouse_unknown',
313
- data: {
314
- results: skippedResults,
315
- submittedCount: 0,
316
- failedCount: 0,
317
- skippedCount: skippedResults.length,
318
- ...(meta ? { _decisionMeta: meta } : {}),
319
- _decisionPrompt: decisionPrompt ?? null,
320
- },
321
- };
322
- emitActionResultEvents(this.eventCtx(), event, address, skipResult, trackingExtras);
323
- return skipResult;
424
+ return this.skipClearinghouseUnknown(event, address, sorted, meta, decisionPrompt, trackingExtras);
324
425
  }
325
- const withdrawable = clearinghouseView.withdrawable;
326
- let remainingSlots = strategyState.getAvailableSlots?.() ?? 0;
327
- // Free-margin pre-flight budget. Undefined when withdrawable is unknown
328
- // (no clearinghouse read) — in that case we do NOT block, preserving prior behavior.
426
+ // ONE snapshot decides everything below: slots, dedupe and margin. Mixing a second read
427
+ // in mid-batch is how the counts stopped agreeing with each other in the first place.
428
+ const view = clearinghouseView;
429
+ const withdrawable = view.withdrawable;
430
+ const ledger = this.pendingOpens();
431
+ ledger.reconcile(view.positions);
432
+ const pendingEntries = ledger.unseen(view.positions);
433
+ // Keys of opens already in flight: a dedupe hit the snapshot cannot produce yet.
434
+ const pendingKeys = new Set(pendingEntries.map((entry) => entry.key));
435
+ const pendingMargin = pendingEntries.reduce((sum, entry) => sum + entry.marginAmount, 0);
436
+ let remainingSlots = Math.max(0, strategyState.config.slots - (view.positions.length + pendingEntries.length));
437
+ // Free-margin pre-flight budget, and the basis `margin_pct` sizes off. Undefined when
438
+ // withdrawable is unknown — in that case we do NOT block, preserving prior behavior.
439
+ // Margin already committed by in-flight opens is subtracted: the snapshot still counts it
440
+ // as free, so sizing off the raw figure would size two positions out of one pot. Erring
441
+ // small is the safe direction — an undersized entry is a worse fill, an oversized one is
442
+ // a rejection or a liquidation-adjacent position.
443
+ const availableWithdrawable = withdrawable != null ? withdrawable - pendingMargin : undefined;
329
444
  // Decremented per submitted signal so later signals in the same batch are
330
445
  // evaluated against the margin already consumed by earlier ones.
331
- let remainingMargin = withdrawable;
446
+ let remainingMargin = availableWithdrawable;
332
447
  const results = [];
333
448
  let submittedCount = 0;
334
449
  let failedCount = 0;
@@ -364,7 +479,9 @@ export class OpenPositionAction {
364
479
  outcome("failed", 'invalid_direction');
365
480
  return;
366
481
  }
367
- if (strategyState.hasOpenPosition(asset, dexForLookup)) {
482
+ // Dedupe against THIS snapshot plus the in-flight opens it is too old to show.
483
+ const pendingKey = pendingOpenKey(asset, dexForLookup);
484
+ if (hasOpenPositionIn(view.positions, asset, dexForLookup) || pendingKeys.has(pendingKey)) {
368
485
  results.push({ asset, direction, dex: submittedDex, score: signalScore, success: true, reason: 'position_already_exists', startedAt: signalStartedAt, endedAt: Date.now() });
369
486
  outcome("skipped", 'position_already_exists');
370
487
  return;
@@ -399,7 +516,9 @@ export class OpenPositionAction {
399
516
  const { amount: marginAmount, source: marginSource } = resolveMarginWithSource({
400
517
  signalMarginPct,
401
518
  marginPct: strategyState.config.marginPct,
402
- withdrawable,
519
+ // The pending-adjusted figure, not the raw snapshot one: a percent of a balance that
520
+ // an in-flight open has already claimed sizes the same dollars twice.
521
+ withdrawable: availableWithdrawable,
403
522
  marginPerSlot: strategyState.config.marginPerSlot,
404
523
  budget: strategyState.config.budget,
405
524
  slots: strategyState.config.slots,
@@ -464,11 +583,23 @@ export class OpenPositionAction {
464
583
  direction,
465
584
  source: marginSource,
466
585
  withdrawable,
467
- accountValue: clearinghouseView.accountValue,
586
+ availableWithdrawable,
587
+ accountValue: view.accountValue,
468
588
  marginAmount,
469
589
  leverage,
470
590
  notional: notionalValue,
471
591
  });
592
+ // Reserved BEFORE the await: between the submit and its outcome the next signal can
593
+ // already be evaluating, and the exchange snapshot will not show this for seconds.
594
+ ledger.reserve(asset, submittedDex, marginAmount);
595
+ pendingKeys.add(pendingKey);
596
+ // Charge the batch counters here, not on the success path: the reservation just made
597
+ // stands for every outcome below except an outright rejection (resting, filled, and
598
+ // even a throw all keep the slot/margin held). Refund only where the reservation is
599
+ // actually released.
600
+ remainingSlots--;
601
+ if (remainingMargin != null)
602
+ remainingMargin -= marginAmount;
472
603
  const result = await withSpan("mcp.createPosition", { "senpi.signal.asset": asset, "senpi.signal.direction": direction }, async (mcpSpan) => {
473
604
  const r = await this.context.senpi.createPosition({
474
605
  strategyWalletAddress: address,
@@ -517,6 +648,23 @@ export class OpenPositionAction {
517
648
  .map((o) => `${o.coin}: ${o.error}`)
518
649
  .join('; ');
519
650
  const detail = result.error || orderErrors || 'unknown error';
651
+ // A resting maker order is NOT a rejection: the order is live on the book and will
652
+ // consume this slot and this margin the moment it fills. The reservation therefore
653
+ // stands (on the longer resting TTL) while the result entry still reports the open
654
+ // as unfilled. The code arrives either as the top-level envelope code or, when the
655
+ // venue reported it per-order, only inside the joined order errors — hence both.
656
+ const restingOrder = result.errorCode === 'CREATE_ORDER_RESTING' || /ORDER_RESTING/i.test(detail);
657
+ if (restingOrder) {
658
+ ledger.settle(pendingKey, 'resting', result.orders[0]?.orderId ?? undefined);
659
+ }
660
+ else {
661
+ // A rejected submit holds nothing — free the slot and the margin immediately.
662
+ ledger.release(pendingKey);
663
+ pendingKeys.delete(pendingKey);
664
+ remainingSlots++;
665
+ if (remainingMargin != null)
666
+ remainingMargin += marginAmount;
667
+ }
520
668
  // Backend says the strategy is PAUSED/CLOSED: arm the pause registry so
521
669
  // subsequent signals skip instead of re-submitting (2026-07 storm class),
522
670
  // and tell the user once. Classify with the structured envelope fields
@@ -561,6 +709,8 @@ export class OpenPositionAction {
561
709
  // A successful submit proves the strategy is active again — re-arm immediately.
562
710
  this.context.backendPauseRegistry?.clear(address);
563
711
  const submittedOrder = result.orders[0];
712
+ // Accepted: hold the slot and the margin until a snapshot carries the position.
713
+ ledger.settle(pendingKey, 'filled', submittedOrder?.orderId ?? undefined);
564
714
  // Mint the position.id at intent — the moment the open order is submitted,
565
715
  // before the position is confirmed open — so the id rides the action.open
566
716
  // emit and the open trace correlates by position.id directly (no ~60s
@@ -632,9 +782,6 @@ export class OpenPositionAction {
632
782
  });
633
783
  }
634
784
  submittedCount++;
635
- remainingSlots--;
636
- if (remainingMargin != null)
637
- remainingMargin -= marginAmount;
638
785
  outcome("submitted", 'submitted');
639
786
  }
640
787
  catch (error) {
@@ -645,6 +792,10 @@ export class OpenPositionAction {
645
792
  const timedOut = error instanceof SenpiTimeoutError;
646
793
  const reason = timedOut ? 'timeout' : 'exception';
647
794
  logger.error(timedOut ? 'open timed out — order may be live' : 'open failed', error, { asset });
795
+ // The submit may have landed server-side; nothing here proves it did not. The
796
+ // reservation stands on the ambiguous TTL so the next signal counts it rather than
797
+ // opening a second position on the same margin.
798
+ ledger.settle(pendingKey, 'ambiguous');
648
799
  results.push({
649
800
  asset, direction, dex: submittedDex, score: signalScore,
650
801
  leverage, marginAmount, marginSource, marginPct, orderType,