@antseed/cli 0.1.144 → 0.1.145
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.
- package/dist/proxy/buyer-proxy.d.ts +59 -9
- package/dist/proxy/buyer-proxy.d.ts.map +1 -1
- package/dist/proxy/buyer-proxy.js +391 -47
- package/dist/proxy/buyer-proxy.js.map +1 -1
- package/dist/proxy/buyer-proxy.test.js +339 -11
- package/dist/proxy/buyer-proxy.test.js.map +1 -1
- package/dist/proxy/peer-attribution.d.ts +100 -0
- package/dist/proxy/peer-attribution.d.ts.map +1 -0
- package/dist/proxy/peer-attribution.js +175 -0
- package/dist/proxy/peer-attribution.js.map +1 -0
- package/dist/proxy/peer-attribution.test.d.ts +2 -0
- package/dist/proxy/peer-attribution.test.d.ts.map +1 -0
- package/dist/proxy/peer-attribution.test.js +140 -0
- package/dist/proxy/peer-attribution.test.js.map +1 -0
- package/dist/proxy/peer-health.d.ts +73 -0
- package/dist/proxy/peer-health.d.ts.map +1 -0
- package/dist/proxy/peer-health.js +182 -0
- package/dist/proxy/peer-health.js.map +1 -0
- package/dist/proxy/peer-health.test.d.ts +2 -0
- package/dist/proxy/peer-health.test.d.ts.map +1 -0
- package/dist/proxy/peer-health.test.js +197 -0
- package/dist/proxy/peer-health.test.js.map +1 -0
- package/package.json +5 -5
|
@@ -22,6 +22,11 @@ export interface BuyerProxyConfig {
|
|
|
22
22
|
* and allowed by the buyer's pricing policy. A 502 is returned if the peer cannot be reached.
|
|
23
23
|
*/
|
|
24
24
|
pinnedPeerId?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Clock used for peer-health bookkeeping. Injectable so tests can drive
|
|
27
|
+
* failure spacing directly instead of sleeping past the coalesce window.
|
|
28
|
+
*/
|
|
29
|
+
now?: () => number;
|
|
25
30
|
/** Verifier-SDK policy: which verifier the buyer commits to + whether it is required. */
|
|
26
31
|
verifier?: VerifierPolicy;
|
|
27
32
|
}
|
|
@@ -104,7 +109,16 @@ export declare class BuyerProxy {
|
|
|
104
109
|
private _consecutiveEmptyDiscoveries;
|
|
105
110
|
private _lastModelNotFoundRefreshAtMs;
|
|
106
111
|
private _bgRefreshHandle;
|
|
107
|
-
|
|
112
|
+
/**
|
|
113
|
+
* Per-peer failure streaks and cooldowns. Advisory only: a cooling-down peer
|
|
114
|
+
* is still dispatched to when a request names it, so routing can never
|
|
115
|
+
* deadlock and pinned conversations keep working.
|
|
116
|
+
*/
|
|
117
|
+
private _peerHealth;
|
|
118
|
+
/** Decides whether a failure is the peer's fault at all. */
|
|
119
|
+
private readonly _attribution;
|
|
120
|
+
private _heartbeatHandle;
|
|
121
|
+
private readonly _now;
|
|
108
122
|
/** Latest relayer receipt per sweep authNonce, for CLI progress polling. */
|
|
109
123
|
private readonly _sweepReceipts;
|
|
110
124
|
/**
|
|
@@ -140,26 +154,62 @@ export declare class BuyerProxy {
|
|
|
140
154
|
private _replacePeers;
|
|
141
155
|
private _persistPeersToState;
|
|
142
156
|
/**
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
157
|
+
* Record a failed request against a peer.
|
|
158
|
+
*
|
|
159
|
+
* Recording is unconditional — the streak and reason are useful diagnostics
|
|
160
|
+
* either way — but only failures the attribution gates accept as the peer's
|
|
161
|
+
* own move the cooldown. Discovery metadata is never evicted: a cooling-down
|
|
162
|
+
* peer stays routable, it just stops being *chosen*.
|
|
146
163
|
*/
|
|
147
164
|
private _recordPeerFailure;
|
|
165
|
+
/**
|
|
166
|
+
* Fold a seller's HTTP response into that peer's health.
|
|
167
|
+
*
|
|
168
|
+
* Control-plane paths are exempt for the same reason `isRouterSuccess`
|
|
169
|
+
* exempts them: a failing `/v1/models` says nothing about the peer's ability
|
|
170
|
+
* to serve inference.
|
|
171
|
+
*/
|
|
172
|
+
private _recordPeerResponseHealth;
|
|
173
|
+
/**
|
|
174
|
+
* Undo cooldowns that turned out to be our fault.
|
|
175
|
+
*
|
|
176
|
+
* When the attribution gates conclude the buyer itself was down — a suspend,
|
|
177
|
+
* a dropped network — the failures recorded during that window blamed the
|
|
178
|
+
* wrong party, so the streaks they created are wound back to zero.
|
|
179
|
+
*/
|
|
180
|
+
private _rollbackPeerHealth;
|
|
148
181
|
/**
|
|
149
182
|
* A peer told us it does not serve the requested model. Our cached
|
|
150
183
|
* metadata for it is stale (the seller may have just unadvertised the
|
|
151
|
-
* model after failing its own health checks), so
|
|
152
|
-
*
|
|
153
|
-
*
|
|
184
|
+
* model after failing its own health checks), so refresh discovery
|
|
185
|
+
* metadata in the background — throttled, since one broken model can
|
|
186
|
+
* produce a burst of these.
|
|
187
|
+
*
|
|
188
|
+
* Deliberately does NOT touch peer health: the response itself is proof of
|
|
189
|
+
* life (`_recordPeerResponseHealth` treats any sub-500 answer as such), and
|
|
190
|
+
* a peer that is healthy for its other models must not cool down over one
|
|
191
|
+
* stale catalog entry. The router still learns via `onResult(success:false)`
|
|
192
|
+
* so scoring reflects the miss.
|
|
154
193
|
*/
|
|
155
194
|
private _onModelNotFound;
|
|
156
195
|
/**
|
|
157
196
|
* Stamp `lastReachedAt` on a peer after a successful request so the
|
|
158
197
|
* carry-forward heuristic can trust local transport liveness even when the
|
|
159
|
-
* DHT record grows stale. Persisted so the signal survives restarts.
|
|
160
|
-
*
|
|
198
|
+
* DHT record grows stale. Persisted so the signal survives restarts.
|
|
199
|
+
*
|
|
200
|
+
* A response is also proof that the buyer's own network, DHT, chain RPC and
|
|
201
|
+
* wallet are working, which is what lets other peers' failures be attributed
|
|
202
|
+
* to them rather than to us.
|
|
161
203
|
*/
|
|
162
204
|
private _rememberSuccessfulPeer;
|
|
205
|
+
/**
|
|
206
|
+
* Watch for the wall clock jumping forward, which means the machine slept.
|
|
207
|
+
* On wake every pending timeout and keepalive fires at once, so without this
|
|
208
|
+
* a single closed lid would cool down every peer the buyer knows.
|
|
209
|
+
*/
|
|
210
|
+
private _startSuspendHeartbeat;
|
|
211
|
+
/** Persist health separately from `discoveredPeers`, which is rebuilt wholesale. */
|
|
212
|
+
private _persistPeerHealthToState;
|
|
163
213
|
private _discoverPeersFromNetwork;
|
|
164
214
|
private _refreshPeersNow;
|
|
165
215
|
private _getPeers;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buyer-proxy.d.ts","sourceRoot":"","sources":["../../src/proxy/buyer-proxy.ts"],"names":[],"mappings":"AAKA,OAAO,
|
|
1
|
+
{"version":3,"file":"buyer-proxy.d.ts","sourceRoot":"","sources":["../../src/proxy/buyer-proxy.ts"],"names":[],"mappings":"AAKA,OAAO,EASL,KAAK,WAAW,EAGhB,KAAK,QAAQ,EAKb,KAAK,sBAAsB,EAG5B,MAAM,eAAe,CAAA;AA6DtB,OAAO,EAAiF,KAAK,cAAc,EAAE,KAAK,WAAW,EAAsB,MAAM,wBAAwB,CAAA;AAGjL,OAAO,EAAE,8BAA8B,EAAE,KAAK,2BAA2B,EAAE,MAAM,cAAc,CAAA;AAC/F,OAAO,EAAE,sBAAsB,EAAE,8BAA8B,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAE3I,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,WAAW,CAAA;IACjB,4FAA4F;IAC5F,OAAO,EAAE,MAAM,CAAA;IACf,kGAAkG;IAClG,2BAA2B,CAAC,EAAE,MAAM,CAAA;IACpC;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;IAClB,yFAAyF;IACzF,QAAQ,CAAC,EAAE,cAAc,CAAA;CAC1B;AAYD;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,sBAAsB,GAAG,OAAO,CAQjF;AA6PD;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,OAAO,EACf,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