@reefclaw/openclaw-plugin 0.1.34 → 0.1.36

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.
@@ -964,6 +964,26 @@ export async function createOrderTool(args, deps) {
964
964
  }
965
965
  return { error: `${wave9Claimed ? 'Wave 9 runtime divergence; daily event latched. ' : ''}${message}` };
966
966
  };
967
+ // A refusal that touched nothing at the venue and is NOT a market divergence
968
+ // (an operator config gate, a size/exposure limit, the drawdown zone) hands
969
+ // the capability back instead of burning the day: the account is exactly as
970
+ // the batch projected it, so a fresh authorization for the same candidate is
971
+ // safe once the cause is fixed — the same contract as every other
972
+ // pre-mutation refusal below (mode / venue / activation / readiness /
973
+ // brackets). Ardi report #7 item 0: one pre-trade gate refusal latched the
974
+ // whole daily event and the next window was 24h away.
975
+ const releaseWave9BeforeMutation = (message, code) => {
976
+ if (wave9Lease) {
977
+ deps.wave9AdmissionGuard.abort(wave9Lease, code, { retryable: true, latchEvent: false });
978
+ wave9Lease = undefined;
979
+ }
980
+ return {
981
+ error: `${wave9Claimed
982
+ ? 'Wave 9 order refused before any venue mutation; authorization released, daily event NOT latched — ' +
983
+ 'fix the cause, then call get_wave9_status for a fresh authorization inside the entry window. '
984
+ : ''}${message}`,
985
+ };
986
+ };
967
987
  // From beginEntry onward, every unexpected failure must release the
968
988
  // in-flight capability. Explicit geometry/risk divergences still use the
969
989
  // latching helper above; infrastructure/pure-computation throws are
@@ -1067,7 +1087,9 @@ export async function createOrderTool(args, deps) {
1067
1087
  });
1068
1088
  if (!riskCheck.allowed) {
1069
1089
  const reasons = riskCheck.violations.map(v => v.message).join('; ');
1070
- return rejectWave9Divergence(`Order REJECTED by risk gate [${riskCheck.drawdownZone} zone]: ${reasons}`, `generic_pretrade_divergence:${riskCheck.violations.map((v) => v.rule).join(',')}`);
1090
+ // Nothing reached the venue and the account is unchanged: release the
1091
+ // wave9 capability rather than latching the daily event (see helper).
1092
+ return releaseWave9BeforeMutation(`Order REJECTED by risk gate [${riskCheck.drawdownZone} zone]: ${reasons}`, `generic_pretrade_refusal:${riskCheck.violations.map((v) => v.rule).join(',')}`);
1071
1093
  }
1072
1094
  // ---- Re-entry cooldown gate (mode-laddered; ships 'off') ----
1073
1095
  // Generic NEW entries only: wave9 has its own frozen admission policy,
@@ -1201,7 +1223,7 @@ export async function createOrderTool(args, deps) {
1201
1223
  // the operator approves and ProposalDecisionListener fires via this same
1202
1224
  // tool with proposalManager omitted (which takes the real path below).
1203
1225
  //
1204
- // NOTE the listener's own fire passes NO approvalMode (defaults to 'off')
1226
+ // NOTE the listener's own fire leaves approvalMode unset (defaults to 'off')
1205
1227
  // and no proposalManager, so it never re-enters this branch.
1206
1228
  if (approvalMode === 'per_trade' && proposalPathWired) {
1207
1229
  if (!argsMetadataComplete) {
@@ -90,8 +90,16 @@ export class BinanceUsdmWave9EvidenceProvider {
90
90
  const fourHourBars = ohlcvRows(fourHourRaw, `${symbol} 4h`)
91
91
  .filter((bar) => bar.time.getTime() >= fromMs && bar.time.getTime() <= eventMs)
92
92
  .sort((left, right) => left.time.getTime() - right.time.getTime());
93
+ // Both window edges carry the same jitter tolerance. Binance stamps the
94
+ // PREVIOUS day's boundary settlement a few ms late as routinely as any
95
+ // other (a real 2026-09-18T00:00:00.003Z row blocked three nights of
96
+ // entries — Ardi report #7): with a bare `> fromMs` lower bound that row
97
+ // survives the filter, the list runs one settlement long, and the whole
98
+ // universe is refused as "partial or stale" although every expected
99
+ // settlement is present. A row jittered past the tolerance still fails
100
+ // closed below, exactly like an interior settlement would.
93
101
  const fundingRowsInWindow = fundingRows(fundingRaw, symbol)
94
- .filter((row) => row.time.getTime() > fromMs
102
+ .filter((row) => row.time.getTime() > fromMs + FUNDING_TIME_TOLERANCE_MS
95
103
  && row.time.getTime() <= eventMs + FUNDING_TIME_TOLERANCE_MS)
96
104
  .sort((left, right) => left.time.getTime() - right.time.getTime());
97
105
  requireExactTimes(dailyBars, expectedDaily, `${symbol} completed 1d evidence`);