dexbot 1.6.18 → 1.7.1

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 (146) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/README.md +24 -18
  3. package/analysis/README.md +117 -5
  4. package/claw/package.json +1 -1
  5. package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
  6. package/claw/runtimes/openclaw-plugin/package.json +1 -1
  7. package/dist/analysis/account_resolver.js +5 -6
  8. package/dist/analysis/analyze_dynamic_weight.js +2 -1
  9. package/dist/analysis/analyze_kalman.js +3 -2
  10. package/dist/analysis/analyze_liquidity.d.ts +17 -0
  11. package/dist/analysis/analyze_liquidity.js +336 -0
  12. package/dist/analysis/analyze_regime.js +3 -2
  13. package/dist/analysis/analyze_regime_windows.js +3 -2
  14. package/dist/analysis/analyze_volatility.js +3 -2
  15. package/dist/analysis/bot_key_utils.d.ts +44 -1
  16. package/dist/analysis/bot_key_utils.js +76 -7
  17. package/dist/analysis/fills_cache.js +2 -1
  18. package/dist/analysis/grid_correction_check.d.ts +1 -19
  19. package/dist/analysis/grid_correction_check.js +12 -30
  20. package/dist/analysis/liquidity/liquidity_chain.d.ts +66 -0
  21. package/dist/analysis/liquidity/liquidity_chain.js +178 -0
  22. package/dist/analysis/liquidity/liquidity_chart_generator.d.ts +19 -0
  23. package/dist/analysis/liquidity/liquidity_chart_generator.js +693 -0
  24. package/dist/analysis/liquidity/liquidity_depth_model.d.ts +166 -0
  25. package/dist/analysis/liquidity/liquidity_depth_model.js +258 -0
  26. package/dist/analysis/liquidity/liquidity_view.d.ts +53 -0
  27. package/dist/analysis/liquidity/liquidity_view.js +66 -0
  28. package/dist/analysis/resolve_bot_accounts.js +7 -6
  29. package/dist/analysis/trade_profitability.js +4 -2
  30. package/dist/analysis/tradingview/analyze_tradingview.js +2 -1
  31. package/dist/credential-daemon.js +13 -2
  32. package/dist/dexbot.js +77 -172
  33. package/dist/modules/account_bots.d.ts +11 -1
  34. package/dist/modules/account_orders.d.ts +12 -0
  35. package/dist/modules/account_orders.js +30 -0
  36. package/dist/modules/asset_lookup.d.ts +25 -0
  37. package/dist/modules/asset_lookup.js +75 -0
  38. package/dist/modules/bitshares-native/transport.js +24 -6
  39. package/dist/modules/bitshares_client.d.ts +24 -6
  40. package/dist/modules/bitshares_client.js +44 -7
  41. package/dist/modules/bot_settings.d.ts +2 -0
  42. package/dist/modules/chain_scan.d.ts +64 -0
  43. package/dist/modules/chain_scan.js +80 -0
  44. package/dist/modules/cli_colors.d.ts +5 -0
  45. package/dist/modules/cli_colors.js +7 -0
  46. package/dist/modules/cli_progress.d.ts +51 -0
  47. package/dist/modules/cli_progress.js +113 -0
  48. package/dist/modules/constants.d.ts +26 -3
  49. package/dist/modules/constants.js +63 -8
  50. package/dist/modules/dexbot_class.d.ts +1 -6
  51. package/dist/modules/dexbot_class.js +14 -0
  52. package/dist/modules/dexbot_cow_runtime.d.ts +97 -7
  53. package/dist/modules/dexbot_cow_runtime.js +634 -136
  54. package/dist/modules/dexbot_fill_runtime.js +132 -23
  55. package/dist/modules/dexbot_maintenance_runtime.js +242 -74
  56. package/dist/modules/dexbot_startup_runtime.js +32 -20
  57. package/dist/modules/dexbot_state_recovery.d.ts +33 -1
  58. package/dist/modules/dexbot_state_recovery.js +167 -5
  59. package/dist/modules/launcher/runtime_entry.d.ts +21 -1
  60. package/dist/modules/launcher/runtime_entry.js +36 -1
  61. package/dist/modules/liquidity_pool_ref.d.ts +32 -0
  62. package/dist/modules/liquidity_pool_ref.js +116 -0
  63. package/dist/modules/node_connect_policy.d.ts +8 -1
  64. package/dist/modules/node_connect_policy.js +18 -2
  65. package/dist/modules/node_flap_score.d.ts +87 -0
  66. package/dist/modules/node_flap_score.js +124 -0
  67. package/dist/modules/node_health_cache.d.ts +40 -3
  68. package/dist/modules/node_health_cache.js +66 -20
  69. package/dist/modules/node_manager.d.ts +101 -19
  70. package/dist/modules/node_manager.js +255 -65
  71. package/dist/modules/order/accounting.js +56 -7
  72. package/dist/modules/order/format.d.ts +24 -10
  73. package/dist/modules/order/format.js +30 -10
  74. package/dist/modules/order/grid.js +91 -13
  75. package/dist/modules/order/grid_reconcile.d.ts +5 -1
  76. package/dist/modules/order/grid_reconcile.js +333 -189
  77. package/dist/modules/order/grid_reconcile_internal.d.ts +38 -2
  78. package/dist/modules/order/grid_reconcile_internal.js +298 -100
  79. package/dist/modules/order/index.d.ts +19 -1
  80. package/dist/modules/order/lifecycle.d.ts +353 -0
  81. package/dist/modules/order/lifecycle.js +1109 -0
  82. package/dist/modules/order/manager.d.ts +273 -5
  83. package/dist/modules/order/manager.js +654 -48
  84. package/dist/modules/order/placement_lock.d.ts +102 -0
  85. package/dist/modules/order/placement_lock.js +222 -0
  86. package/dist/modules/order/strategy.js +13 -1
  87. package/dist/modules/order/sync_engine.d.ts +33 -1
  88. package/dist/modules/order/sync_engine.js +241 -73
  89. package/dist/modules/order/utils/math.d.ts +39 -1
  90. package/dist/modules/order/utils/math.js +83 -1
  91. package/dist/modules/order/utils/order.d.ts +181 -5
  92. package/dist/modules/order/utils/order.js +455 -9
  93. package/dist/modules/order/utils/system.d.ts +81 -1
  94. package/dist/modules/order/utils/system.js +331 -44
  95. package/dist/modules/order/utils/validate.d.ts +7 -1
  96. package/dist/modules/order/utils/validate.js +80 -3
  97. package/dist/modules/outcome.d.ts +54 -0
  98. package/dist/modules/outcome.js +51 -0
  99. package/dist/modules/settings_merge.d.ts +4 -0
  100. package/dist/modules/settings_merge.js +9 -0
  101. package/dist/modules/timing_policy.d.ts +82 -0
  102. package/dist/modules/timing_policy.js +244 -0
  103. package/dist/modules/types.d.ts +137 -0
  104. package/dist/modules/utils/asset_symbols.d.ts +13 -2
  105. package/dist/modules/utils/asset_symbols.js +21 -2
  106. package/dist/scripts/analysis_runner.d.ts +10 -0
  107. package/dist/scripts/analysis_runner.js +33 -0
  108. package/dist/scripts/analyze-credit.js +54 -17
  109. package/dist/scripts/analyze-orders.d.ts +4 -2
  110. package/dist/scripts/analyze-orders.js +115 -35
  111. package/dist/scripts/asset.d.ts +26 -0
  112. package/dist/scripts/asset.js +165 -0
  113. package/dist/scripts/bts_distribution.d.ts +1 -0
  114. package/dist/scripts/bts_distribution.js +194 -142
  115. package/dist/scripts/chart_command.d.ts +1 -1
  116. package/dist/scripts/chart_command.js +60 -86
  117. package/dist/scripts/chart_targets.d.ts +18 -0
  118. package/dist/scripts/chart_targets.js +48 -0
  119. package/dist/scripts/dw.js +1 -1
  120. package/dist/scripts/liquid.d.ts +24 -0
  121. package/dist/scripts/liquid.js +134 -0
  122. package/dist/scripts/rich_list.js +12 -16
  123. package/dist/scripts/test-credit-renewal.js +12 -5
  124. package/dist/scripts/token_distribution.d.ts +2 -0
  125. package/dist/scripts/token_distribution.js +132 -108
  126. package/dist/scripts/tv.js +1 -1
  127. package/dist/scripts/verify-browser-bundle.js +18 -0
  128. package/docs/COW_INVARIANTS.md +69 -10
  129. package/docs/DEXBOT_COMPARISON.md +6 -6
  130. package/docs/EVOLUTION.md +10 -8
  131. package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +1 -1
  132. package/docs/GRID_PRICE_INVARIANT.md +5 -2
  133. package/docs/GRID_RECONCILE.md +36 -11
  134. package/docs/LOGGING.md +50 -4
  135. package/docs/ORDER_ENGINE_POST_1.0_RETROSPECTIVE.md +177 -27
  136. package/docs/README.md +23 -2
  137. package/docs/WORKFLOW.md +12 -4
  138. package/docs/architecture.md +42 -5
  139. package/docs/developer_guide.md +25 -8
  140. package/modules/README.md +8 -1
  141. package/package.json +3 -1
  142. package/scripts/README.md +39 -7
  143. package/scripts/pdev.sh +14 -1
  144. package/scripts/pmain.sh +23 -8
  145. package/scripts/ptest.sh +7 -0
  146. package/tests/README.md +30 -1
package/scripts/README.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  This guide provides a terminal-focused reference for the maintenance and diagnostic utilities available in the `scripts/` directory.
4
4
 
5
+ Every command that writes a file prints the same trailer
6
+ (`[Tag] ✓ <kind> saved. Open <kind>: (file://…)`) plus the shared section/warning/summary
7
+ blocks, all from `modules/cli_progress.ts` (`savedLine`, `section`, `warningsBlock`, `summaryLine`).
8
+
9
+ Asset symbols are case-insensitive wherever a command takes one (`dexbot asset token.sym`,
10
+ `dexbot rich token.sym`, `dexbot liq A/B`, `dexbot tv <pool-token>`, `--base`/`--quote`): every
11
+ path resolves through `modules/asset_lookup.ts`, which looks the symbol up in its canonical UPPERCASE
12
+ form and keeps `1.3.x` ids untouched.
13
+
5
14
  ---
6
15
 
7
16
  ## 🛠️ CORE MAINTENANCE
@@ -58,8 +67,14 @@ All are irreversible and prompt for confirmation.
58
67
  ```bash
59
68
  # Analyzes spread accuracy, geometric consistency, and fund distribution
60
69
  node dist/scripts/analyze-orders.js
70
+
71
+ # One bot (name or key), or every grid on one account (name or 1.2.x id)
72
+ node dist/scripts/analyze-orders.js <bot|account>
61
73
  ```
62
74
 
75
+ Bot/account targets share one rule set with `dexbot credit`, `dexbot pnl` and
76
+ the chart commands (`analysis/bot_key_utils.ts`).
77
+
63
78
  For AMA bots (`gridPrice: ama`) the analyzer reads `<botKey>.dynamicgrid.json`
64
79
  and, when fresh (`2 × MARKET_ADAPTER.RUNTIME_DEFAULTS.pollSeconds`, default 2h),
65
80
  shows live weights with color: higher = red (losing), lower = green (winning),
@@ -75,6 +90,9 @@ node dist/scripts/analyze-credit.js
75
90
 
76
91
  # Single bot (name or key)
77
92
  node dist/scripts/analyze-credit.js <bot>
93
+
94
+ # Every bot trading one account (preferredAccount name or 1.2.x id)
95
+ node dist/scripts/analyze-credit.js <account>
78
96
  ```
79
97
  Credit deals report per-pair and average CR, but only for pairs whitelisted in `bots.json` (`debtPolicy.lending`) and listed on the current credit offer; everything else is shown as ignored/unpriced and excluded from the average. A borrow-now preview per configured pair shows today's rate.
80
98
 
@@ -104,7 +122,7 @@ the rename. Note:
104
122
  the `holders=` figure can be off by one.
105
123
 
106
124
  ### BTS Supply Distribution
107
- **File:** `bts_distribution.ts` (npm: `npm run distribution`)
125
+ **File:** `bts_distribution.ts` (CLI: `dexbot asset bts`; npm: `npm run distribution`)
108
126
  **Purpose:** Live-chain breakdown of where BTS sits: call-order collateral, global/individual
109
127
  settlement funds (plus force-settlement debt and parameters), governance tickets, vesting and
110
128
  legacy balances, liquidity pools, SameT/credit funds, HTLC escrow and asset fee pools. The
@@ -112,11 +130,17 @@ remainder is reported as a derived liquid residual and compared with total suppl
112
130
  circulating float. Also writes a self-contained HTML donut report to
113
131
  `analysis/charts/bts-distribution.html` (`--html PATH`, `--no-html`).
114
132
  ```bash
115
- npm run distribution # terminal + HTML
133
+ dexbot asset bts # terminal + HTML (shorthand: dexbot a bts)
134
+ npm run distribution # same, via npm
116
135
  node dist/scripts/bts_distribution.js --json # JSON (HTML still written)
117
136
  node dist/scripts/bts_distribution.js --circulating <reference-supply>
118
137
  node dist/scripts/bts_distribution.js --holders all # full rich list (~5 min)
119
138
  ```
139
+ Vesting (1.13.x) and legacy (1.15.x) objects have no list API, so both are enumerated by probing
140
+ ids with `get_objects` in 1000-id batches (`modules/chain_scan.ts`, halving on nodes that refuse
141
+ big batches) and filtered to BTS client-side — the walk covers every asset the node stores there,
142
+ because the chain exposes no per-asset index. `--gap N` controls how far past the last live object
143
+ the walk continues (default 20000); `--vesting-max` caps the 1.13.x probe.
120
144
  Call-order collateral uses `api_helper_indexes` `total_in_collateral` (falls back to summing
121
145
  `get_call_orders`). Top liquid holders come from `asset_api::get_asset_holders`, retrying on a
122
146
  node that exposes it; exchange tags are name heuristics, not verified identities. `--holders all`
@@ -124,7 +148,7 @@ also splits the residual into account balances, blinded balances and order books
124
148
  concentration plus balance bands. Read-only: no keys, no transactions.
125
149
 
126
150
  ### Token Distribution
127
- **File:** `token_distribution.ts` (npm: `npm run token-distribution`)
151
+ **File:** `token_distribution.ts` (CLI: `dexbot asset <symbol|1.3.x>`; npm: `npm run token-distribution`)
128
152
  **Purpose:** Per-asset companion to BTS Supply Distribution. Buckets a token into free account
129
153
  balances, limit orders, liquidity pools, vesting balances, P2P credit offers and deal collateral,
130
154
  SameT funds, HTLC escrow, accumulated market fees and blinded supply, then reconciles the total
@@ -134,13 +158,12 @@ token sellable (price −3%) and buyable (+3%), orderbook + pool combined per ma
134
158
  as a share of total supply. Writes the report to
135
159
  `analysis/charts/token-<SYMBOL>-distribution.html`.
136
160
  ```bash
161
+ dexbot asset <token> # terminal + HTML (shorthand: dexbot a <token>)
137
162
  npm run token-distribution -- <token>
138
163
  node dist/scripts/token_distribution.js <asset-id> --json
139
164
  node dist/scripts/token_distribution.js <token> --no-orders # skip the ~6k order queries
140
165
  ```
141
- Limit orders have no by-asset index in bitshares-core, so the exact scan queries every listed
142
- asset concurrently (~20s); vesting balances scan 1.13.x with a gap tolerance. Read-only: no keys,
143
- no transactions. BTS itself is rejected; use `npm run distribution`.
166
+ Read-only: no keys, no transactions. BTS itself is rejected; use `npm run distribution`.
144
167
 
145
168
  ### Configuration Audit
146
169
  **File:** `validate_bots.ts`
@@ -287,6 +310,13 @@ npm run version:sync
287
310
  | `pdev.sh` | `npm run pdev` | sync `test` → `dev` |
288
311
  | `pmain.sh` | `npm run pmain` | sync `test` → `dev` → `main` |
289
312
 
313
+ Before any push, all three scripts run a shared preflight
314
+ (`scripts/lib/git_preflight.sh`): one read-only `git ls-remote` against `origin`,
315
+ so an unreachable remote or a key the server no longer accepts fails **before** a
316
+ branch moves. `pmain.sh` mirrors `dev` and `main` in a single `--atomic` push —
317
+ either both move or neither does. Set `DEXBOT_SKIP_GIT_PREFLIGHT=1` to bypass
318
+ the preflight.
319
+
290
320
  ---
291
321
 
292
322
  ## ⚡ CONVENIENCE WRAPPERS
@@ -381,7 +411,8 @@ load `profiles/orders/<botKey>.json` automatically.
381
411
  **Output:** `tv_<bot|pool_<id>|<a>_<b>>_1h_<N>m.html` (`_feed` for feed charts)
382
412
  ```bash
383
413
  dexbot tv <bot> # bot, 3 months
384
- dexbot tv 133 --month 6 # pool
414
+ dexbot tv 133 --month 6 # pool by id
415
+ dexbot tv <pool-token-symbol> --month 6 # pool by its LP share-asset symbol
385
416
  dexbot tv TOKENA/TOKENB --month 1 --chart analysis/charts/custom.html
386
417
  dexbot tv TOKENA/BTS --feed --month 1 # MPA price feed
387
418
  ```
@@ -395,6 +426,7 @@ Same pipeline and flags as `tv`; renders the dynamic-weight research chart
395
426
  ```bash
396
427
  dexbot dw <bot>
397
428
  dexbot dw 133 --month 6
429
+ dexbot dw <pool-token-symbol> --month 6
398
430
  dexbot dw TOKENA/TOKENB --month 1 --chart analysis/charts/custom.html
399
431
  dexbot dw TOKENA/BTS --feed --month 1
400
432
  ```
package/scripts/pdev.sh CHANGED
@@ -7,6 +7,13 @@ set -e
7
7
 
8
8
  echo "🔄 Starting safe branch synchronization (test -> dev)..."
9
9
 
10
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
11
+ # shellcheck source=scripts/lib/git_preflight.sh
12
+ source "$SCRIPT_DIR/lib/git_preflight.sh"
13
+
14
+ # 0. Fail fast when the remote cannot be read — before any branch is touched.
15
+ require_origin_access origin || exit 1
16
+
10
17
  # 1. Ensure we are on 'test'
11
18
  CURRENT=$(git rev-parse --abbrev-ref HEAD)
12
19
  if [ "$CURRENT" != "test" ]; then
@@ -31,8 +38,14 @@ echo "🚀 Synchronizing 'dev' with 'test' on origin..."
31
38
  git push origin test:dev --force
32
39
 
33
40
  # 5. Update local 'dev' branch pointer to match origin
41
+ # Best-effort: the push above already moved origin/dev, so a failure here is
42
+ # cosmetic (a stale local label) and self-heals on the next successful fetch.
34
43
  echo "📍 Updating local 'dev' branch pointer..."
35
- git fetch origin dev:dev --force
44
+ if ! git fetch origin dev:dev --force; then
45
+ echo "⚠️ Local 'dev' pointer was not refreshed — origin/dev is already synced."
46
+ echo " Re-run 'npm run pdev' once the remote is reachable again."
47
+ exit 1
48
+ fi
36
49
 
37
50
  echo "✅ Synchronization complete: test == dev"
38
51
  echo "✨ Your uncommitted changes on 'test' were never at risk."
package/scripts/pmain.sh CHANGED
@@ -8,6 +8,13 @@ set -e
8
8
 
9
9
  echo "🔄 Starting safe branch synchronization..."
10
10
 
11
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
12
+ # shellcheck source=scripts/lib/git_preflight.sh
13
+ source "$SCRIPT_DIR/lib/git_preflight.sh"
14
+
15
+ # 0. Fail fast when the remote cannot be read — before any branch is touched.
16
+ require_origin_access origin || exit 1
17
+
11
18
  # 1. Ensure we are on 'test'
12
19
  CURRENT=$(git rev-parse --abbrev-ref HEAD)
13
20
  if [ "$CURRENT" != "test" ]; then
@@ -28,17 +35,25 @@ if ! git push origin test; then
28
35
  exit 1
29
36
  fi
30
37
 
31
- # 4. Force update 'dev' and 'main' on origin (Zero-Checkout)
32
- # This updates the server branches directly from your local test branch
33
- echo "🚀 Synchronizing 'dev' and 'main' on origin..."
34
- git push origin test:dev --force
35
- git push origin test:main --force
38
+ # 4. Force update 'dev' and 'main' on origin in ONE atomic push (Zero-Checkout)
39
+ # --atomic makes the mirror all-or-nothing: either both branches move or neither
40
+ # does, so a refusal can never leave dev ahead of main.
41
+ echo "🚀 Synchronizing 'dev' and 'main' with 'test' on origin (atomic)..."
42
+ if ! git push --atomic origin test:dev test:main --force; then
43
+ echo "❌ Atomic push to dev/main failed — neither branch was moved."
44
+ echo "⚠️ Please check 'git status' or sync manually."
45
+ exit 1
46
+ fi
36
47
 
37
48
  # 5. Update local branch pointers to match origin
38
- # This makes your local 'dev' and 'main' labels match without switching to them
49
+ # Best-effort: the atomic push above already moved origin, so a failure here is
50
+ # cosmetic (a stale local label) and self-heals on the next successful fetch.
39
51
  echo "📍 Updating local branch pointers..."
40
- git fetch origin dev:dev --force
41
- git fetch origin main:main --force
52
+ if ! git fetch origin dev:dev main:main --force; then
53
+ echo "⚠️ Local 'dev'/'main' pointers were not refreshed — origin is already synced."
54
+ echo " Re-run 'npm run pmain' once the remote is reachable again."
55
+ exit 1
56
+ fi
42
57
 
43
58
  echo "✅ Everything is synchronized: test == dev == main"
44
59
  echo "✨ Your uncommitted changes on 'test' were never at risk."
package/scripts/ptest.sh CHANGED
@@ -7,6 +7,13 @@ set -e
7
7
 
8
8
  echo "🔄 Starting safe branch synchronization (test -> origin/test)..."
9
9
 
10
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
11
+ # shellcheck source=scripts/lib/git_preflight.sh
12
+ source "$SCRIPT_DIR/lib/git_preflight.sh"
13
+
14
+ # 0. Fail fast when the remote cannot be read — before any branch is touched.
15
+ require_origin_access origin || exit 1
16
+
10
17
  # 1. Ensure we are on 'test'
11
18
  CURRENT=$(git rev-parse --abbrev-ref HEAD)
12
19
  if [ "$CURRENT" != "test" ]; then
package/tests/README.md CHANGED
@@ -33,7 +33,7 @@ claw/tests/ # Claw integration tests (same conventions, run by npm test)
33
33
  - `bitshares_client_stub.ts` — mock blockchain client
34
34
  - `chain_orders_stub.ts` — order lifecycle test doubles
35
35
  - `fee_cache_init.ts` — fee cache seeding for tests
36
- - `order_test_helpers.ts` — order construction utilities
36
+ - `order_test_helpers.ts` — order construction utilities + genesis ladders (`ageChainIdAssignment` settles a fixture's fresh chain id so absence scenarios test the decision, not the in-flight guard)
37
37
  - `silent_logger.ts` — suppresses log output during tests
38
38
  - `module_cache_stub.ts` — isolates module state per test
39
39
  - `vault_fixture.ts` — chain-key vault fixtures
@@ -80,6 +80,10 @@ Research/analysis tools: chart generators, backtests, and the grid-reset replay
80
80
  Order lifecycle, fill processing, trade history, batch execution.
81
81
  *Examples:* `test_open_orders.ts`, `test_fills.ts`, `test_fill_batch_chunking.ts`, `test_fill_replay_guards.ts`, `test_uncertain_broadcast.ts`
82
82
 
83
+ ### Order Lifecycle Registry
84
+ The single answer to "does this order exist on chain, and how sure are we" ([ORDER_LIFECYCLE.md](../docs/ORDER_LIFECYCLE.md)): phases (`unknown ≠ gone`), evidence monotonicity, the unresolved bound, the write funnel (including the COW whole-map commit), and the unified absence guard the sync/reconcile/recovery sites share.
85
+ *Files:* `test_order_lifecycle.ts` (registry + manager integration), `recon_fuzz.ts` (interleaving fuzzer; `RECON_FUZZ_SCENARIOS`/`RECON_FUZZ_STEPS` scale it)
86
+
83
87
  ### Strategy & Grid Logic
84
88
  Grid generation, sizing, rotation, divergence detection, reconciliation.
85
89
  *Examples:* `test_order_grid.ts`, `test_strategy_logic.ts`, `test_grid_reconcile.ts`, `test_working_grid.ts`, `test_rotation_order_sizing.ts`, `test_strategy_edge_cases.ts`, `test_edge_orders.ts`
@@ -204,3 +208,28 @@ Shared utility functions, precision handling, chain helpers.
204
208
  ---
205
209
 
206
210
  **Note:** Interactive/diagnostic scripts (`connection_test.ts`, `diag_*`, `benchmark_cow.ts`, `sim_batching.ts`, `repro_phantom_orders.ts`) require network access or real state and are **not** run by `npm test` — the runner only globs `test_*.js`. Run these manually when debugging.
211
+
212
+ ## Harnesses (not run by `npm test`)
213
+
214
+ Two files are investigative harnesses rather than assertions about production
215
+ code, so they are deliberately *not* `test_*.ts`:
216
+
217
+ - `recon_fuzz.ts` — the interleaving fuzzer for the reconciliation engine. Drives
218
+ the real `SyncEngine` against a scripted chain (landed / vanished / partially
219
+ filled / orphaned / duplicated / lagging / unparseable reads), asserts
220
+ policy-free invariants after **every** event, and shrinks a failing sequence to
221
+ a seed + step count.
222
+
223
+ ```bash
224
+ npm run build:tests
225
+ node dist/tests/recon_fuzz.js # 40 scenarios × 25 steps
226
+ RECON_FUZZ_SCENARIOS=120 RECON_FUZZ_STEPS=40 node dist/tests/recon_fuzz.js
227
+ RECON_FUZZ_TRACE=1 RECON_FUZZ_DEBUG=1 node dist/tests/recon_fuzz.js
228
+ ```
229
+
230
+ `RECON_FUZZ_SEED=<n> RECON_FUZZ_STEPS=<n>` replays a reported failure. The run
231
+ fails if the scenarios are vacuous (coverage floors on placed-slot
232
+ observations and on un-adoptable orphans), so a green run means the engine was
233
+ actually exercised.
234
+
235
+ - `sim_batching.ts` — arithmetic mirror of the gap-slot batch sizing rule.