@general-liquidity/sharpebench 0.0.4 → 0.0.6
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/package.json +3 -3
- package/pkg/package.json +17 -0
- package/pkg/sharpebench.d.ts +16 -0
- package/pkg/sharpebench.js +245 -0
- package/pkg/sharpebench_bg.wasm +0 -0
- package/pkg/sharpebench_bg.wasm.d.ts +15 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@general-liquidity/sharpebench",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "The luck-robust scoring kernel for AI trading agents — deflated Sharpe, pass^k reliability, and process-discipline gates. The identical Rust kernel as the SharpeBench benchmark, compiled to WASM.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"trading",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
],
|
|
29
29
|
"scripts": {
|
|
30
30
|
"build": "tsc",
|
|
31
|
-
"test": "node --test test
|
|
32
|
-
"prepublishOnly": "tsc"
|
|
31
|
+
"test": "node --test \"test/**/*.test.js\"",
|
|
32
|
+
"prepublishOnly": "tsc && node -e \"require('fs').rmSync('pkg/.gitignore',{force:true})\""
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"typescript": "^5.6.0"
|
package/pkg/package.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "sharpebench-wasm",
|
|
3
|
+
"description": "WASM bindings for the SharpeBench scoring kernel (consumed by Gordon/Bun via the identical kernel).",
|
|
4
|
+
"version": "0.0.6",
|
|
5
|
+
"license": "MIT OR Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/general-liquidity/sharpebench"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"sharpebench_bg.wasm",
|
|
12
|
+
"sharpebench.js",
|
|
13
|
+
"sharpebench.d.ts"
|
|
14
|
+
],
|
|
15
|
+
"main": "sharpebench.js",
|
|
16
|
+
"types": "sharpebench.d.ts"
|
|
17
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
export function audit_briefing(briefing_json: string, policy_json: string): string;
|
|
5
|
+
|
|
6
|
+
export function canary(seed: string): string;
|
|
7
|
+
|
|
8
|
+
export function greeks(params_json: string): string;
|
|
9
|
+
|
|
10
|
+
export function score(submissions_json: string, config_json: string): string;
|
|
11
|
+
|
|
12
|
+
export function score_agent(submission_json: string, config_json: string): string;
|
|
13
|
+
|
|
14
|
+
export function score_allocation(trajectory_json: string, policy_json: string): string;
|
|
15
|
+
|
|
16
|
+
export function self_audit(): string;
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
/* @ts-self-types="./sharpebench.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {string} briefing_json
|
|
5
|
+
* @param {string} policy_json
|
|
6
|
+
* @returns {string}
|
|
7
|
+
*/
|
|
8
|
+
function audit_briefing(briefing_json, policy_json) {
|
|
9
|
+
let deferred3_0;
|
|
10
|
+
let deferred3_1;
|
|
11
|
+
try {
|
|
12
|
+
const ptr0 = passStringToWasm0(briefing_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
13
|
+
const len0 = WASM_VECTOR_LEN;
|
|
14
|
+
const ptr1 = passStringToWasm0(policy_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
15
|
+
const len1 = WASM_VECTOR_LEN;
|
|
16
|
+
const ret = wasm.audit_briefing(ptr0, len0, ptr1, len1);
|
|
17
|
+
deferred3_0 = ret[0];
|
|
18
|
+
deferred3_1 = ret[1];
|
|
19
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
20
|
+
} finally {
|
|
21
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.audit_briefing = audit_briefing;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @param {string} seed
|
|
28
|
+
* @returns {string}
|
|
29
|
+
*/
|
|
30
|
+
function canary(seed) {
|
|
31
|
+
let deferred2_0;
|
|
32
|
+
let deferred2_1;
|
|
33
|
+
try {
|
|
34
|
+
const ptr0 = passStringToWasm0(seed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
35
|
+
const len0 = WASM_VECTOR_LEN;
|
|
36
|
+
const ret = wasm.canary(ptr0, len0);
|
|
37
|
+
deferred2_0 = ret[0];
|
|
38
|
+
deferred2_1 = ret[1];
|
|
39
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
40
|
+
} finally {
|
|
41
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.canary = canary;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @param {string} params_json
|
|
48
|
+
* @returns {string}
|
|
49
|
+
*/
|
|
50
|
+
function greeks(params_json) {
|
|
51
|
+
let deferred2_0;
|
|
52
|
+
let deferred2_1;
|
|
53
|
+
try {
|
|
54
|
+
const ptr0 = passStringToWasm0(params_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
55
|
+
const len0 = WASM_VECTOR_LEN;
|
|
56
|
+
const ret = wasm.greeks(ptr0, len0);
|
|
57
|
+
deferred2_0 = ret[0];
|
|
58
|
+
deferred2_1 = ret[1];
|
|
59
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
60
|
+
} finally {
|
|
61
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.greeks = greeks;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @param {string} submissions_json
|
|
68
|
+
* @param {string} config_json
|
|
69
|
+
* @returns {string}
|
|
70
|
+
*/
|
|
71
|
+
function score(submissions_json, config_json) {
|
|
72
|
+
let deferred3_0;
|
|
73
|
+
let deferred3_1;
|
|
74
|
+
try {
|
|
75
|
+
const ptr0 = passStringToWasm0(submissions_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
76
|
+
const len0 = WASM_VECTOR_LEN;
|
|
77
|
+
const ptr1 = passStringToWasm0(config_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
78
|
+
const len1 = WASM_VECTOR_LEN;
|
|
79
|
+
const ret = wasm.score(ptr0, len0, ptr1, len1);
|
|
80
|
+
deferred3_0 = ret[0];
|
|
81
|
+
deferred3_1 = ret[1];
|
|
82
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
83
|
+
} finally {
|
|
84
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.score = score;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @param {string} submission_json
|
|
91
|
+
* @param {string} config_json
|
|
92
|
+
* @returns {string}
|
|
93
|
+
*/
|
|
94
|
+
function score_agent(submission_json, config_json) {
|
|
95
|
+
let deferred3_0;
|
|
96
|
+
let deferred3_1;
|
|
97
|
+
try {
|
|
98
|
+
const ptr0 = passStringToWasm0(submission_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
99
|
+
const len0 = WASM_VECTOR_LEN;
|
|
100
|
+
const ptr1 = passStringToWasm0(config_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
101
|
+
const len1 = WASM_VECTOR_LEN;
|
|
102
|
+
const ret = wasm.score_agent(ptr0, len0, ptr1, len1);
|
|
103
|
+
deferred3_0 = ret[0];
|
|
104
|
+
deferred3_1 = ret[1];
|
|
105
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
106
|
+
} finally {
|
|
107
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
exports.score_agent = score_agent;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* @param {string} trajectory_json
|
|
114
|
+
* @param {string} policy_json
|
|
115
|
+
* @returns {string}
|
|
116
|
+
*/
|
|
117
|
+
function score_allocation(trajectory_json, policy_json) {
|
|
118
|
+
let deferred3_0;
|
|
119
|
+
let deferred3_1;
|
|
120
|
+
try {
|
|
121
|
+
const ptr0 = passStringToWasm0(trajectory_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
122
|
+
const len0 = WASM_VECTOR_LEN;
|
|
123
|
+
const ptr1 = passStringToWasm0(policy_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
124
|
+
const len1 = WASM_VECTOR_LEN;
|
|
125
|
+
const ret = wasm.score_allocation(ptr0, len0, ptr1, len1);
|
|
126
|
+
deferred3_0 = ret[0];
|
|
127
|
+
deferred3_1 = ret[1];
|
|
128
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
129
|
+
} finally {
|
|
130
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
exports.score_allocation = score_allocation;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* @returns {string}
|
|
137
|
+
*/
|
|
138
|
+
function self_audit() {
|
|
139
|
+
let deferred1_0;
|
|
140
|
+
let deferred1_1;
|
|
141
|
+
try {
|
|
142
|
+
const ret = wasm.self_audit();
|
|
143
|
+
deferred1_0 = ret[0];
|
|
144
|
+
deferred1_1 = ret[1];
|
|
145
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
146
|
+
} finally {
|
|
147
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
exports.self_audit = self_audit;
|
|
151
|
+
function __wbg_get_imports() {
|
|
152
|
+
const import0 = {
|
|
153
|
+
__proto__: null,
|
|
154
|
+
__wbindgen_init_externref_table: function() {
|
|
155
|
+
const table = wasm.__wbindgen_externrefs;
|
|
156
|
+
const offset = table.grow(4);
|
|
157
|
+
table.set(0, undefined);
|
|
158
|
+
table.set(offset + 0, undefined);
|
|
159
|
+
table.set(offset + 1, null);
|
|
160
|
+
table.set(offset + 2, true);
|
|
161
|
+
table.set(offset + 3, false);
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
return {
|
|
165
|
+
__proto__: null,
|
|
166
|
+
"./sharpebench_bg.js": import0,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function getStringFromWasm0(ptr, len) {
|
|
171
|
+
return decodeText(ptr >>> 0, len);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
let cachedUint8ArrayMemory0 = null;
|
|
175
|
+
function getUint8ArrayMemory0() {
|
|
176
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
177
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
178
|
+
}
|
|
179
|
+
return cachedUint8ArrayMemory0;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
183
|
+
if (realloc === undefined) {
|
|
184
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
185
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
186
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
187
|
+
WASM_VECTOR_LEN = buf.length;
|
|
188
|
+
return ptr;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
let len = arg.length;
|
|
192
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
193
|
+
|
|
194
|
+
const mem = getUint8ArrayMemory0();
|
|
195
|
+
|
|
196
|
+
let offset = 0;
|
|
197
|
+
|
|
198
|
+
for (; offset < len; offset++) {
|
|
199
|
+
const code = arg.charCodeAt(offset);
|
|
200
|
+
if (code > 0x7F) break;
|
|
201
|
+
mem[ptr + offset] = code;
|
|
202
|
+
}
|
|
203
|
+
if (offset !== len) {
|
|
204
|
+
if (offset !== 0) {
|
|
205
|
+
arg = arg.slice(offset);
|
|
206
|
+
}
|
|
207
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
208
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
209
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
210
|
+
|
|
211
|
+
offset += ret.written;
|
|
212
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
WASM_VECTOR_LEN = offset;
|
|
216
|
+
return ptr;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
220
|
+
cachedTextDecoder.decode();
|
|
221
|
+
function decodeText(ptr, len) {
|
|
222
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
const cachedTextEncoder = new TextEncoder();
|
|
226
|
+
|
|
227
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
228
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
229
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
230
|
+
view.set(buf);
|
|
231
|
+
return {
|
|
232
|
+
read: arg.length,
|
|
233
|
+
written: buf.length
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
let WASM_VECTOR_LEN = 0;
|
|
239
|
+
|
|
240
|
+
const wasmPath = `${__dirname}/sharpebench_bg.wasm`;
|
|
241
|
+
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
242
|
+
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
243
|
+
let wasmInstance = new WebAssembly.Instance(wasmModule, __wbg_get_imports());
|
|
244
|
+
let wasm = wasmInstance.exports;
|
|
245
|
+
wasm.__wbindgen_start();
|
|
Binary file
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const audit_briefing: (a: number, b: number, c: number, d: number) => [number, number];
|
|
5
|
+
export const canary: (a: number, b: number) => [number, number];
|
|
6
|
+
export const greeks: (a: number, b: number) => [number, number];
|
|
7
|
+
export const score: (a: number, b: number, c: number, d: number) => [number, number];
|
|
8
|
+
export const score_agent: (a: number, b: number, c: number, d: number) => [number, number];
|
|
9
|
+
export const score_allocation: (a: number, b: number, c: number, d: number) => [number, number];
|
|
10
|
+
export const self_audit: () => [number, number];
|
|
11
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
12
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
13
|
+
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
14
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
15
|
+
export const __wbindgen_start: () => void;
|