@general-liquidity/sharpebench 0.0.3
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/README.md +51 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +105 -0
- package/dist/types.d.ts +128 -0
- package/dist/types.js +5 -0
- package/package.json +40 -0
- 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/README.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# @general-liquidity/sharpebench
|
|
2
|
+
|
|
3
|
+
**The luck-robust scoring kernel for AI trading agents.**
|
|
4
|
+
|
|
5
|
+
Rank agents on risk-adjusted *skill that survives deflation* — not the luckiest run over one quarter. This is the **identical Rust kernel** that powers the [SharpeBench](https://github.com/general-liquidity/sharpebench) benchmark, compiled to WebAssembly, with a typed JS/TS API. No native add-on, no network — pure deterministic scoring.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @general-liquidity/sharpebench
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quickstart
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { score, greeks, selfAudit } from "@general-liquidity/sharpebench";
|
|
15
|
+
|
|
16
|
+
// Rank a field. Raw return is reported but is NEVER the rank key — an agent ranks
|
|
17
|
+
// only if its edge survives deflation, pass^k reliability, and process discipline.
|
|
18
|
+
const board = score([
|
|
19
|
+
{ agent_id: "skilled", runs: [{ returns: [0.002, 0.0021, 0.0019, 0.002] }] },
|
|
20
|
+
{ agent_id: "lucky", runs: [{ returns: [0.05, 0, 0, 0] }] },
|
|
21
|
+
]);
|
|
22
|
+
console.log(board[0].agent_id, board[0].deflated_sharpe, board[0].rank_eligible);
|
|
23
|
+
|
|
24
|
+
// Prove the scorer resists known gaming attacks.
|
|
25
|
+
console.log(selfAudit().all_defended); // true
|
|
26
|
+
|
|
27
|
+
// Options tail-risk: a short-gamma position a linear Sharpe can't see.
|
|
28
|
+
console.log(greeks({ spot: 100, strike: 100, t_years: 1, rate: 0.05, vol: 0.2, is_call: true }).price);
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## API
|
|
32
|
+
|
|
33
|
+
| Function | Returns |
|
|
34
|
+
|---|---|
|
|
35
|
+
| `score(submissions, config?)` | ranked `CompositeScore[]` |
|
|
36
|
+
| `scoreAgent(submission, config?)` | one `CompositeScore` (deflated Sharpe, pass^k, process, rolling worst-case Sharpe) |
|
|
37
|
+
| `selfAudit()` | `SelfAuditReport` — the benchmark's anti-gaming proof |
|
|
38
|
+
| `auditBriefing(briefing, policy?)` | `BriefingAudit` — input-side salience-bias audit |
|
|
39
|
+
| `scoreAllocation(trajectory, policy?)` | `AllocationReport` — weight-vector validity + L1 turnover |
|
|
40
|
+
| `greeks(params)` | `GreeksResult` — Black-Scholes price + Greeks + tail-selling risk |
|
|
41
|
+
| `canary(seed)` | `Canary` — a do-not-train contamination tripwire |
|
|
42
|
+
|
|
43
|
+
All inputs and outputs are fully typed (TypeScript declarations ship with the package). The kernel is deterministic: the same input yields byte-identical scores on any platform.
|
|
44
|
+
|
|
45
|
+
## Why luck-robust?
|
|
46
|
+
|
|
47
|
+
Most agent leaderboards rank a raw Sharpe over a single short window — so they mostly measure noise. SharpeBench adds, as **ranking gates**: deflated Sharpe / PSR, pass^k reliability (clear the bar on *every* seed × window), field-wide significance, and process discipline (an order that skipped the risk gate zeroes the entry). See the [benchmark repo](https://github.com/general-liquidity/sharpebench) for the full methodology.
|
|
48
|
+
|
|
49
|
+
## License
|
|
50
|
+
|
|
51
|
+
MIT OR Apache-2.0, at your option.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AgentSubmission, AllocationPolicy, AllocationReport, AllocationTrajectory, Briefing, BriefingAudit, BriefingPolicy, Canary, CompositeScore, GreeksParams, GreeksResult, ScoreConfig, SelfAuditReport } from "./types.js";
|
|
2
|
+
export * from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Score and rank a field of submissions on the luck-robust composite. Returns the
|
|
5
|
+
* leaderboard (rank-eligible agents first); raw return is reported but never the
|
|
6
|
+
* rank key.
|
|
7
|
+
*/
|
|
8
|
+
export declare function score(submissions: AgentSubmission[], config?: ScoreConfig): CompositeScore[];
|
|
9
|
+
/**
|
|
10
|
+
* Score a single submission → one {@link CompositeScore} carrying its deflated
|
|
11
|
+
* Sharpe, pass^k verdict, process score, rolling worst-case Sharpe, and the rest.
|
|
12
|
+
*/
|
|
13
|
+
export declare function scoreAgent(submission: AgentSubmission, config?: ScoreConfig): CompositeScore;
|
|
14
|
+
/** Fire the known gaming attacks at the scorer and report whether each is demoted. */
|
|
15
|
+
export declare function selfAudit(): SelfAuditReport;
|
|
16
|
+
/** Audit a shared briefing for input-side salience bias. */
|
|
17
|
+
export declare function auditBriefing(briefing: Briefing, policy?: BriefingPolicy): BriefingAudit;
|
|
18
|
+
/** Score a target-allocation trajectory: weight validity + L1 turnover. */
|
|
19
|
+
export declare function scoreAllocation(trajectory: AllocationTrajectory, policy?: AllocationPolicy): AllocationReport;
|
|
20
|
+
/** Black-Scholes price + Greeks + tail-selling (short-gamma/vega) classification. */
|
|
21
|
+
export declare function greeks(params: GreeksParams): GreeksResult;
|
|
22
|
+
/** Derive a deterministic do-not-train contamination tripwire from seed material. */
|
|
23
|
+
export declare function canary(seed: string): Canary;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
36
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.score = score;
|
|
40
|
+
exports.scoreAgent = scoreAgent;
|
|
41
|
+
exports.selfAudit = selfAudit;
|
|
42
|
+
exports.auditBriefing = auditBriefing;
|
|
43
|
+
exports.scoreAllocation = scoreAllocation;
|
|
44
|
+
exports.greeks = greeks;
|
|
45
|
+
exports.canary = canary;
|
|
46
|
+
/**
|
|
47
|
+
* `@general-liquidity/sharpebench` — the luck-robust scoring kernel for AI trading
|
|
48
|
+
* agents, as a typed JS API over the *identical* Rust kernel that powers the
|
|
49
|
+
* SharpeBench benchmark (compiled to WebAssembly).
|
|
50
|
+
*
|
|
51
|
+
* An agent does not rank on raw return. It ranks only if its edge survives
|
|
52
|
+
* deflation for the number of trials, reliability across every seed × window
|
|
53
|
+
* (pass^k), and decision-process discipline. See {@link score}.
|
|
54
|
+
*/
|
|
55
|
+
const kernel = __importStar(require("../pkg/sharpebench.js"));
|
|
56
|
+
__exportStar(require("./types.js"), exports);
|
|
57
|
+
/** Parse a kernel JSON string, surfacing the kernel's `{error}` as a thrown Error. */
|
|
58
|
+
function parse(json) {
|
|
59
|
+
const value = JSON.parse(json);
|
|
60
|
+
if (value && typeof value === "object" && "error" in value) {
|
|
61
|
+
throw new Error(String(value.error));
|
|
62
|
+
}
|
|
63
|
+
return value;
|
|
64
|
+
}
|
|
65
|
+
/** Empty/absent config → `""`, which the kernel reads as "use defaults". */
|
|
66
|
+
function optJson(value) {
|
|
67
|
+
if (!value || Object.keys(value).length === 0)
|
|
68
|
+
return "";
|
|
69
|
+
return JSON.stringify(value);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Score and rank a field of submissions on the luck-robust composite. Returns the
|
|
73
|
+
* leaderboard (rank-eligible agents first); raw return is reported but never the
|
|
74
|
+
* rank key.
|
|
75
|
+
*/
|
|
76
|
+
function score(submissions, config) {
|
|
77
|
+
return parse(kernel.score(JSON.stringify(submissions), optJson(config)));
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Score a single submission → one {@link CompositeScore} carrying its deflated
|
|
81
|
+
* Sharpe, pass^k verdict, process score, rolling worst-case Sharpe, and the rest.
|
|
82
|
+
*/
|
|
83
|
+
function scoreAgent(submission, config) {
|
|
84
|
+
return parse(kernel.score_agent(JSON.stringify(submission), optJson(config)));
|
|
85
|
+
}
|
|
86
|
+
/** Fire the known gaming attacks at the scorer and report whether each is demoted. */
|
|
87
|
+
function selfAudit() {
|
|
88
|
+
return parse(kernel.self_audit());
|
|
89
|
+
}
|
|
90
|
+
/** Audit a shared briefing for input-side salience bias. */
|
|
91
|
+
function auditBriefing(briefing, policy) {
|
|
92
|
+
return parse(kernel.audit_briefing(JSON.stringify(briefing), optJson(policy)));
|
|
93
|
+
}
|
|
94
|
+
/** Score a target-allocation trajectory: weight validity + L1 turnover. */
|
|
95
|
+
function scoreAllocation(trajectory, policy) {
|
|
96
|
+
return parse(kernel.score_allocation(JSON.stringify(trajectory), optJson(policy)));
|
|
97
|
+
}
|
|
98
|
+
/** Black-Scholes price + Greeks + tail-selling (short-gamma/vega) classification. */
|
|
99
|
+
function greeks(params) {
|
|
100
|
+
return parse(kernel.greeks(JSON.stringify(params)));
|
|
101
|
+
}
|
|
102
|
+
/** Derive a deterministic do-not-train contamination tripwire from seed material. */
|
|
103
|
+
function canary(seed) {
|
|
104
|
+
return parse(kernel.canary(seed));
|
|
105
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/** One per-seed × per-window return series + (optional) decision trace/costs. */
|
|
2
|
+
export interface Run {
|
|
3
|
+
returns: number[];
|
|
4
|
+
cost?: number;
|
|
5
|
+
confidences?: number[];
|
|
6
|
+
outcomes?: number[];
|
|
7
|
+
trace?: {
|
|
8
|
+
events: unknown[];
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
/** An agent's full submission: its runs across seeds × windows. */
|
|
12
|
+
export interface AgentSubmission {
|
|
13
|
+
agent_id: string;
|
|
14
|
+
runs: Run[];
|
|
15
|
+
/** The agent's own declared in-sample trials (deflated against). */
|
|
16
|
+
in_sample_trials?: number;
|
|
17
|
+
/** Candidate return series from the agent's own selection search. */
|
|
18
|
+
candidates?: number[][];
|
|
19
|
+
}
|
|
20
|
+
/** Scoring configuration. Omit (or pass `{}`) to use the luck-robust defaults. */
|
|
21
|
+
export interface ScoreConfig {
|
|
22
|
+
n_trials?: number;
|
|
23
|
+
rolling_window?: number;
|
|
24
|
+
[k: string]: unknown;
|
|
25
|
+
}
|
|
26
|
+
/** A scored agent. Raw return is reported but is never the rank key. */
|
|
27
|
+
export interface CompositeScore {
|
|
28
|
+
agent_id: string;
|
|
29
|
+
deflated_sharpe: number;
|
|
30
|
+
passed_k: boolean;
|
|
31
|
+
process_ok: boolean;
|
|
32
|
+
rank_eligible: boolean;
|
|
33
|
+
raw_mean_return: number;
|
|
34
|
+
[k: string]: unknown;
|
|
35
|
+
}
|
|
36
|
+
export interface SelfAuditReport {
|
|
37
|
+
cases: Array<{
|
|
38
|
+
name: string;
|
|
39
|
+
attack: string;
|
|
40
|
+
defended: boolean;
|
|
41
|
+
detail: string;
|
|
42
|
+
}>;
|
|
43
|
+
all_defended: boolean;
|
|
44
|
+
}
|
|
45
|
+
export type RowKind = "fact" | "uncertainty" | "counterpoint";
|
|
46
|
+
export interface BriefingRow {
|
|
47
|
+
text: string;
|
|
48
|
+
kind: RowKind;
|
|
49
|
+
}
|
|
50
|
+
export interface BriefingSection {
|
|
51
|
+
asset_area: string;
|
|
52
|
+
rows: BriefingRow[];
|
|
53
|
+
}
|
|
54
|
+
export type TableOrdering = "option_order" | "performance" | "unspecified";
|
|
55
|
+
export interface ReturnTable {
|
|
56
|
+
ordering: TableOrdering;
|
|
57
|
+
entries: Array<{
|
|
58
|
+
label: string;
|
|
59
|
+
trailing_return: number;
|
|
60
|
+
}>;
|
|
61
|
+
}
|
|
62
|
+
export interface Briefing {
|
|
63
|
+
sections: BriefingSection[];
|
|
64
|
+
return_table?: ReturnTable | null;
|
|
65
|
+
}
|
|
66
|
+
export interface BriefingPolicy {
|
|
67
|
+
max_rows_per_area?: number;
|
|
68
|
+
require_counterbalance?: boolean;
|
|
69
|
+
require_option_order_sort?: boolean;
|
|
70
|
+
max_area_salience?: number;
|
|
71
|
+
}
|
|
72
|
+
export interface BriefingAudit {
|
|
73
|
+
balanced: boolean;
|
|
74
|
+
violations: unknown[];
|
|
75
|
+
salience: Array<{
|
|
76
|
+
asset_area: string;
|
|
77
|
+
row_count: number;
|
|
78
|
+
salience: number;
|
|
79
|
+
}>;
|
|
80
|
+
}
|
|
81
|
+
export interface AllocationStep {
|
|
82
|
+
weights: number[];
|
|
83
|
+
}
|
|
84
|
+
export interface AllocationTrajectory {
|
|
85
|
+
steps: AllocationStep[];
|
|
86
|
+
}
|
|
87
|
+
export interface AllocationPolicy {
|
|
88
|
+
allow_shorts?: boolean;
|
|
89
|
+
max_gross?: number;
|
|
90
|
+
epsilon?: number;
|
|
91
|
+
}
|
|
92
|
+
export interface AllocationReport {
|
|
93
|
+
total_turnover: number;
|
|
94
|
+
mean_turnover: number;
|
|
95
|
+
weight_violations: unknown[];
|
|
96
|
+
valid: boolean;
|
|
97
|
+
}
|
|
98
|
+
export interface GreeksParams {
|
|
99
|
+
spot: number;
|
|
100
|
+
strike: number;
|
|
101
|
+
t_years: number;
|
|
102
|
+
rate: number;
|
|
103
|
+
vol: number;
|
|
104
|
+
is_call: boolean;
|
|
105
|
+
}
|
|
106
|
+
export interface Greeks {
|
|
107
|
+
delta: number;
|
|
108
|
+
gamma: number;
|
|
109
|
+
theta: number;
|
|
110
|
+
vega: number;
|
|
111
|
+
rho: number;
|
|
112
|
+
}
|
|
113
|
+
export interface GreeksRisk {
|
|
114
|
+
naked_short_gamma: boolean;
|
|
115
|
+
unbounded_tail: boolean;
|
|
116
|
+
short_vega: boolean;
|
|
117
|
+
net_gamma: number;
|
|
118
|
+
net_vega: number;
|
|
119
|
+
}
|
|
120
|
+
export interface GreeksResult {
|
|
121
|
+
price: number;
|
|
122
|
+
greeks: Greeks;
|
|
123
|
+
risk: GreeksRisk;
|
|
124
|
+
}
|
|
125
|
+
export interface Canary {
|
|
126
|
+
id: string;
|
|
127
|
+
token: string;
|
|
128
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Typed views of the SharpeBench kernel's JSON shapes. Inputs are typed precisely;
|
|
3
|
+
// report outputs carry the headline fields plus an index signature, so they stay
|
|
4
|
+
// forward-compatible as the kernel adds reported axes.
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@general-liquidity/sharpebench",
|
|
3
|
+
"version": "0.0.3",
|
|
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
|
+
"keywords": [
|
|
6
|
+
"trading",
|
|
7
|
+
"benchmark",
|
|
8
|
+
"sharpe-ratio",
|
|
9
|
+
"deflated-sharpe",
|
|
10
|
+
"quant",
|
|
11
|
+
"ai-agents",
|
|
12
|
+
"backtesting",
|
|
13
|
+
"wasm"
|
|
14
|
+
],
|
|
15
|
+
"license": "MIT OR Apache-2.0",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/general-liquidity/sharpebench.git",
|
|
19
|
+
"directory": "npm"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/general-liquidity/sharpebench#readme",
|
|
22
|
+
"type": "commonjs",
|
|
23
|
+
"main": "dist/index.js",
|
|
24
|
+
"types": "dist/index.d.ts",
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"pkg"
|
|
28
|
+
],
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsc",
|
|
31
|
+
"test": "node --test",
|
|
32
|
+
"prepublishOnly": "tsc"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"typescript": "^5.6.0"
|
|
36
|
+
},
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=18"
|
|
39
|
+
}
|
|
40
|
+
}
|
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.3",
|
|
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;
|