@wildshard/shard-format 0.84.0 → 0.85.0
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wildshard/shard-format",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.85.0",
|
|
4
4
|
"description": "The raw shardfile format: the spec, the validator and a validate CLI. The public, versioned contract every other repo builds on.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
|
@@ -26,16 +26,32 @@ for (const [kind, capacity] of Object.entries(CAPACITY)) {
|
|
|
26
26
|
capacities.set(Number(kind), capacity)
|
|
27
27
|
}
|
|
28
28
|
const DECISION_V2_CAPACITIES: ReadonlyMap<number, number> = capacities
|
|
29
|
+
/** WASM-HOST H8: a row with `inputs` adds the player bank (8 seats, W28) and 32 input edges to the frame. */
|
|
30
|
+
const INPUT_CAPACITY: Readonly<Record<number, number>> = {
|
|
31
|
+
...CAPACITY,
|
|
32
|
+
7: 8,
|
|
33
|
+
8: 32,
|
|
34
|
+
}
|
|
35
|
+
const inputCapacities = new Map<number, number>()
|
|
36
|
+
for (const [kind, capacity] of Object.entries(INPUT_CAPACITY)) {
|
|
37
|
+
inputCapacities.set(Number(kind), capacity)
|
|
38
|
+
}
|
|
39
|
+
const DECISION_V2_INPUT_CAPACITIES: ReadonlyMap<number, number> =
|
|
40
|
+
inputCapacities
|
|
29
41
|
/** List replies are keyed `DECISION_V2_LIST_KEY + list op`, apart from read ops. */
|
|
30
42
|
const DECISION_V2_LIST_KEY = 1000
|
|
31
43
|
const DECISION_V2_IO = 0
|
|
32
|
-
/** The I/O frame a decision module of `pages` pages admits under. */
|
|
33
|
-
function decisionLayoutV2(pages: number): V2Layout {
|
|
34
|
-
return layoutV2(
|
|
44
|
+
/** The I/O frame a decision module of `pages` pages admits under; `inputs` adds the seat and edge banks. */
|
|
45
|
+
function decisionLayoutV2(pages: number, inputs = false): V2Layout {
|
|
46
|
+
return layoutV2(
|
|
47
|
+
DECISION_V2_IO,
|
|
48
|
+
pages,
|
|
49
|
+
inputs ? DECISION_V2_INPUT_CAPACITIES : DECISION_V2_CAPACITIES,
|
|
50
|
+
)
|
|
35
51
|
}
|
|
36
52
|
/** A decision row's byte contract: ABI 1 by its pages, or (abi '2.0') the ABI 2 sim lane over its fixed decision frame. */
|
|
37
53
|
function decisionContract(
|
|
38
|
-
row: Readonly<Pick<DecisionScriptRow, 'abi' | 'pages'>>,
|
|
54
|
+
row: Readonly<Pick<DecisionScriptRow, 'abi' | 'inputs' | 'pages'>>,
|
|
39
55
|
): Extract<ScriptContract, { pages: number }> {
|
|
40
56
|
if (row.abi === '1.0') {
|
|
41
57
|
return { abi: 1, pages: row.pages }
|
|
@@ -44,7 +60,7 @@ function decisionContract(
|
|
|
44
60
|
abi: 2,
|
|
45
61
|
lane: 'sim',
|
|
46
62
|
pages: row.pages,
|
|
47
|
-
ioBytes: decisionLayoutV2(row.pages).bytes,
|
|
63
|
+
ioBytes: decisionLayoutV2(row.pages, row.inputs === true).bytes,
|
|
48
64
|
compilerRevision: SCRIPT_V2_REVISIONS.compiler,
|
|
49
65
|
admissionRevision: SCRIPT_V2_REVISIONS.admission,
|
|
50
66
|
}
|
|
@@ -52,6 +68,7 @@ function decisionContract(
|
|
|
52
68
|
|
|
53
69
|
export {
|
|
54
70
|
DECISION_V2_CAPACITIES,
|
|
71
|
+
DECISION_V2_INPUT_CAPACITIES,
|
|
55
72
|
DECISION_V2_IO,
|
|
56
73
|
DECISION_V2_LIST_KEY,
|
|
57
74
|
decisionContract,
|
|
@@ -11,6 +11,8 @@ const local = v.pipe(v.string(), v.regex(/^[A-Za-z_][A-Za-z0-9_.-]*$/u), v.maxLe
|
|
|
11
11
|
const finite = v.pipe(v.number(), v.finite());
|
|
12
12
|
const positive = v.pipe(finite, v.integer(), v.minValue(1), v.maxValue(0x7fffffff));
|
|
13
13
|
const HIT_TAG_LENGTH = 64;
|
|
14
|
+
/** WASM-HOST H8 (W9): the sim lane's fast rate, and the most a row writes for why it needs it. */
|
|
15
|
+
const SIM_RATE = { fast: 30, reason: 200 } as const;
|
|
14
16
|
const HIT_TAGS = 16;
|
|
15
17
|
const hitTag = v.pipe(v.string(), v.regex(/^[a-z][a-z0-9_-]*(?:\.[a-z0-9_-]+)+$/u), v.maxLength(HIT_TAG_LENGTH));
|
|
16
18
|
const hitTags = v.pipe(v.record(local, hitTag), v.check((value: Readonly<Record<string, string>>): boolean => Object.keys(value).length <= HIT_TAGS, 'at most 16 hit tags'));
|
|
@@ -35,7 +37,11 @@ const rowEntries = {
|
|
|
35
37
|
binding: v.union([v.strictObject({ encounter: id }), v.strictObject({ quest: id }), v.strictObject({ zone: id }), v.strictObject({ shard: v.literal(true) }), v.strictObject({ spawnGroup: id }), v.strictObject({ brain: id })]),
|
|
36
38
|
pages: v.optional(v.pipe(positive, v.maxValue(4)), 1), onFail: v.picklist(['hold', 'reset', 'skip']),
|
|
37
39
|
on: v.pipe(v.array(v.picklist(keys(SCRIPT_V1_EVENTS))), v.minLength(1), v.maxLength(23), v.check(values => unique(values), 'unique subscribed events')),
|
|
38
|
-
|
|
40
|
+
// WASM-HOST H8 (W9): 10 Hz is the sim lane's rate; 30 Hz needs an ABI 2 row and its written reason.
|
|
41
|
+
tick: v.optional(v.nullable(v.picklist([1, 2, 5, 10, SIM_RATE.fast])), null),
|
|
42
|
+
tickReason: v.exactOptional(v.pipe(v.string(), v.nonEmpty(), v.maxLength(SIM_RATE.reason))),
|
|
43
|
+
// WASM-HOST H8: an ABI 2 row that reads its seats and their input edges (W28) in its v2 frame.
|
|
44
|
+
inputs: v.exactOptional(v.literal(true)),
|
|
39
45
|
reads: v.pipe(v.array(v.picklist(readNames)), v.maxLength(readNames.length), v.check(values => unique(values), 'unique script reads')),
|
|
40
46
|
commands: v.pipe(v.array(v.picklist(keys(SCRIPT_V1_COMMANDS))), v.maxLength(21), v.check(values => unique(values), 'unique script commands')),
|
|
41
47
|
actors: v.optional(aliases, {}), moves: v.optional(aliases, {}), strikes: v.optional(aliases, {}), cues: v.optional(aliases, {}),
|
|
@@ -72,7 +78,9 @@ export function decisionScriptRowRules(script: DecisionScriptRow): string[] {
|
|
|
72
78
|
const errors: string[] = [];
|
|
73
79
|
if ('spawnGroup' in script.binding && (Object.keys(script.actors).length === 0 || script.state.some(slot => slot.scope !== 'actor')))
|
|
74
80
|
errors.push('spawn groups declare members and actor-scoped simulation state');
|
|
75
|
-
if ((script.tick !== null) !== script.on.includes('tick')) errors.push('tick subscription has a declared 1/2/5/10 Hz rate');
|
|
81
|
+
if ((script.tick !== null) !== script.on.includes('tick')) errors.push('tick subscription has a declared 1/2/5/10/30 Hz rate');
|
|
82
|
+
if ((script.tick === SIM_RATE.fast) !== (script.tickReason !== undefined)) { errors.push('a 30 Hz row, and only one, gives its written reason (W9)'); }
|
|
83
|
+
if ((script.tick === SIM_RATE.fast || script.inputs === true) && script.abi !== '2.0') { errors.push('30 Hz and input edges are ABI 2 sim rows'); }
|
|
76
84
|
if ('brain' in script.binding && (!Object.values(script.actors).includes(script.binding.brain)
|
|
77
85
|
|| script.commands.some((name): boolean => name === 'move' || name === 'strike' || name === 'stop'))) {
|
|
78
86
|
errors.push('a brain hook names its creature and leaves move, strike and stop to the brain');
|
|
@@ -228,7 +236,9 @@ interface DecisionScriptRowInputFields {
|
|
|
228
236
|
pages?: number | undefined;
|
|
229
237
|
onFail: 'hold' | 'reset' | 'skip';
|
|
230
238
|
on: (keyof typeof SCRIPT_V1_EVENTS)[];
|
|
231
|
-
tick?: (1 | 2 | 5 | 10) | null | undefined;
|
|
239
|
+
tick?: (1 | 2 | 5 | 10 | typeof SIM_RATE.fast) | null | undefined;
|
|
240
|
+
tickReason?: string;
|
|
241
|
+
inputs?: true;
|
|
232
242
|
reads: ((typeof readNames)[number])[];
|
|
233
243
|
commands: (keyof typeof SCRIPT_V1_COMMANDS)[];
|
|
234
244
|
actors?: Record<string, string> | undefined;
|
|
@@ -286,7 +296,9 @@ interface DecisionScriptRowFields {
|
|
|
286
296
|
pages: number;
|
|
287
297
|
onFail: 'hold' | 'reset' | 'skip';
|
|
288
298
|
on: (keyof typeof SCRIPT_V1_EVENTS)[];
|
|
289
|
-
tick: (1 | 2 | 5 | 10) | null;
|
|
299
|
+
tick: (1 | 2 | 5 | 10 | typeof SIM_RATE.fast) | null;
|
|
300
|
+
tickReason?: string;
|
|
301
|
+
inputs?: true;
|
|
290
302
|
reads: ((typeof readNames)[number])[];
|
|
291
303
|
commands: (keyof typeof SCRIPT_V1_COMMANDS)[];
|
|
292
304
|
actors: Record<string, string>;
|
|
@@ -1,19 +1,35 @@
|
|
|
1
|
-
/* oxlint-disable
|
|
2
|
-
/** WASM-HOST H2c: v2 fuel regions priced at their longest path. */
|
|
1
|
+
/* oxlint-disable complexity, curly, id-length, max-depth, max-lines-per-function, max-statements, no-continue, no-magic-numbers, no-nested-ternary, no-plusplus, sort-vars, typescript/explicit-function-return-type, typescript/prefer-readonly-parameter-types, unicorn/no-array-callback-reference, unicorn/no-array-reverse, unicorn/no-nested-ternary, unicorn/number-literal-case, import/exports-last, import/group-exports -- the region walk of scriptFuelV2.ts's v2BlockCosts, in its form; engine test/fixtures/v2Path.ts copies it line for line until engine takes this format */
|
|
2
|
+
/** WASM-HOST H2c: v2 fuel regions priced at their longest path, with split regions where a call may skip a big arm. */
|
|
3
3
|
import type { V2Instruction } from './scriptModuleV2.ts'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
const EXIT = -1
|
|
6
|
+
interface Region {
|
|
7
|
+
readonly start: number
|
|
8
|
+
readonly close: number
|
|
9
|
+
readonly loop: boolean
|
|
10
|
+
}
|
|
11
|
+
interface Shape {
|
|
12
|
+
readonly next: readonly (readonly number[])[]
|
|
13
|
+
readonly closes: readonly number[]
|
|
14
|
+
readonly loops: readonly Region[]
|
|
15
|
+
readonly weight: readonly number[]
|
|
16
|
+
}
|
|
17
|
+
/** WASM-HOST H2c: the smallest own longest path a split region needs, by lane. A split's charge runs on every call that
|
|
18
|
+
* enters it; views loop over many small arms per frame, sims and projections over few big ones (engine
|
|
19
|
+
* `wasm-fuel-ratio --costs=path`, meta support/wasm-host/H2C-RATIOS-2026-12-06.md). */
|
|
20
|
+
export const V2_SPLIT_FLOORS: Readonly<{
|
|
21
|
+
sim: number
|
|
22
|
+
project: number
|
|
23
|
+
view: number
|
|
24
|
+
}> = Object.freeze({ sim: 512, project: 512, view: 136 })
|
|
25
|
+
|
|
26
|
+
/** Each instruction's successors (EXIT for a return, `unreachable`, a branch to a loop or to the body's own label), the
|
|
27
|
+
* close of each instruction's structural level, the loop bodies, and each instruction's price. */
|
|
28
|
+
function shape(
|
|
12
29
|
code: readonly V2Instruction[],
|
|
13
|
-
constantCalls: ReadonlyMap<number, number
|
|
14
|
-
):
|
|
15
|
-
const
|
|
16
|
-
ends = new Map<number, number>(),
|
|
30
|
+
constantCalls: ReadonlyMap<number, number>,
|
|
31
|
+
): Shape {
|
|
32
|
+
const ends = new Map<number, number>(),
|
|
17
33
|
arms = new Map<number, number>(),
|
|
18
34
|
open: number[] = []
|
|
19
35
|
for (let i = 0; i < code.length; i++) {
|
|
@@ -27,57 +43,147 @@ export function v2PathCosts(
|
|
|
27
43
|
if (at !== undefined) ends.set(at, i)
|
|
28
44
|
}
|
|
29
45
|
}
|
|
30
|
-
const end = (at: number): number => ends.get(at) ?? code.length - 1
|
|
31
|
-
|
|
32
|
-
labels: number[] = []
|
|
46
|
+
const end = (at: number): number => ends.get(at) ?? code.length - 1
|
|
47
|
+
const next: number[][] = [],
|
|
48
|
+
labels: number[] = [],
|
|
49
|
+
closes: number[] = []
|
|
33
50
|
const target = (depth: number): number => {
|
|
34
51
|
const at = labels[labels.length - 1 - depth]
|
|
35
|
-
return at === undefined || code[at]?.op === 0x03 ?
|
|
52
|
+
return at === undefined || code[at]?.op === 0x03 ? EXIT : end(at) + 1
|
|
36
53
|
}
|
|
37
54
|
for (let i = 0; i < code.length; i++) {
|
|
55
|
+
const top = labels.at(-1),
|
|
56
|
+
arm = top === undefined ? undefined : arms.get(top)
|
|
57
|
+
closes.push(
|
|
58
|
+
top === undefined
|
|
59
|
+
? code.length - 1
|
|
60
|
+
: arm !== undefined && i <= arm
|
|
61
|
+
? arm
|
|
62
|
+
: end(top),
|
|
63
|
+
)
|
|
38
64
|
const value = code[i],
|
|
39
65
|
op = value?.op
|
|
40
66
|
if (op === 0x0c) next.push([target(value?.args[0] ?? 0)])
|
|
41
67
|
else if (op === 0x0d) next.push([i + 1, target(value?.args[0] ?? 0)])
|
|
42
68
|
else if (op === 0x0e) next.push((value?.args ?? []).map(target))
|
|
43
|
-
else if (op === 0x0f || op === 0x00) next.push([
|
|
69
|
+
else if (op === 0x0f || op === 0x00) next.push([EXIT])
|
|
44
70
|
else if (op === 0x04) next.push([i + 1, (arms.get(i) ?? end(i)) + 1])
|
|
45
|
-
else if (op === 0x05) next.push([end(
|
|
71
|
+
else if (op === 0x05) next.push([end(top ?? -1) + 1])
|
|
46
72
|
else next.push([i + 1])
|
|
47
73
|
if (op === 0x02 || op === 0x03 || op === 0x04) labels.push(i)
|
|
48
74
|
else if (op === 0x0b) labels.pop()
|
|
49
75
|
}
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
const loops = [...ends]
|
|
77
|
+
.filter(([at]) => code[at]?.op === 0x03)
|
|
78
|
+
.map(([at, last]) => ({ start: at + 1, close: last, loop: true }))
|
|
79
|
+
const weight = code.map(
|
|
80
|
+
value =>
|
|
81
|
+
1 +
|
|
82
|
+
(value.op === 0x10 ? (constantCalls.get(value.args[0] ?? -1) ?? 0) : 0),
|
|
83
|
+
)
|
|
84
|
+
return { next, closes, loops, weight }
|
|
85
|
+
}
|
|
86
|
+
/** The longest path through `region` from its start, each region in `inner` nested in it charged on its own: the path
|
|
87
|
+
* steps over such a region to wherever it can leave to (a loop's own op still counts here). */
|
|
88
|
+
function longestOf(s: Shape, region: Region, inner: readonly Region[]): number {
|
|
89
|
+
const nested = inner.filter(
|
|
90
|
+
row =>
|
|
91
|
+
row !== region && row.start >= region.start && row.close <= region.close,
|
|
92
|
+
)
|
|
93
|
+
const children = nested.filter(
|
|
94
|
+
row =>
|
|
95
|
+
!nested.some(
|
|
96
|
+
other =>
|
|
97
|
+
other !== row && other.start <= row.start && other.close >= row.close,
|
|
98
|
+
),
|
|
99
|
+
)
|
|
100
|
+
const entry = new Map<number, Region>(),
|
|
101
|
+
inside = new Set<number>()
|
|
102
|
+
for (const child of children) {
|
|
103
|
+
entry.set(child.loop ? child.start - 1 : child.start, child)
|
|
104
|
+
for (let at = child.start; at <= child.close; at++) inside.add(at)
|
|
105
|
+
}
|
|
106
|
+
const longest = new Map<number, number>()
|
|
107
|
+
for (let at = region.close; at >= region.start; at--) {
|
|
108
|
+
const child = entry.get(at)
|
|
109
|
+
if (child === undefined && inside.has(at)) continue
|
|
110
|
+
let after: readonly number[] = s.next[at] ?? [EXIT],
|
|
111
|
+
weight = s.weight[at] ?? 1
|
|
112
|
+
if (child !== undefined) {
|
|
113
|
+
const out = new Set<number>()
|
|
114
|
+
for (let j = child.start; j <= child.close; j++)
|
|
115
|
+
for (const to of s.next[j] ?? [])
|
|
116
|
+
if (to < child.start || to > child.close) out.add(to)
|
|
117
|
+
after = [...out]
|
|
118
|
+
if (!child.loop) weight = 0
|
|
79
119
|
}
|
|
80
|
-
|
|
120
|
+
let best = 0
|
|
121
|
+
for (const to of after)
|
|
122
|
+
if (to >= region.start && to <= region.close)
|
|
123
|
+
best = Math.max(best, longest.get(to) ?? 0)
|
|
124
|
+
longest.set(at, weight + best)
|
|
81
125
|
}
|
|
82
|
-
return
|
|
126
|
+
return longest.get(region.start) ?? 0
|
|
127
|
+
}
|
|
128
|
+
/** WASM-HOST H2c: where a charge may also stand. Each point is entered only from just before it (an `if` arm, an
|
|
129
|
+
* `else` arm, the fall-through of a `br_if`, the join after an `end`, where every branch to that label lands), and its
|
|
130
|
+
* region runs to the close of its level. */
|
|
131
|
+
export function v2SplitPoints(
|
|
132
|
+
code: readonly V2Instruction[],
|
|
133
|
+
): ReadonlySet<number> {
|
|
134
|
+
const points = new Set<number>()
|
|
135
|
+
for (let i = 0; i + 1 < code.length; i++) {
|
|
136
|
+
const op = code[i]?.op
|
|
137
|
+
if (op === 0x04 || op === 0x05 || op === 0x0d || op === 0x0b)
|
|
138
|
+
points.add(i + 1)
|
|
139
|
+
}
|
|
140
|
+
return points
|
|
141
|
+
}
|
|
142
|
+
/** WASM-HOST H2c: the split points a compiler charges, innermost first: each whose own longest path, past the splits
|
|
143
|
+
* already charged inside it and its loops, is `floor` or more (`V2_SPLIT_FLOORS` by lane). */
|
|
144
|
+
export function v2SplitStarts(
|
|
145
|
+
code: readonly V2Instruction[],
|
|
146
|
+
constantCalls: ReadonlyMap<number, number>,
|
|
147
|
+
floor: number,
|
|
148
|
+
): ReadonlySet<number> {
|
|
149
|
+
const s = shape(code, constantCalls),
|
|
150
|
+
chosen: Region[] = []
|
|
151
|
+
for (const at of [...v2SplitPoints(code)].reverse()) {
|
|
152
|
+
const region = {
|
|
153
|
+
start: at,
|
|
154
|
+
close: s.closes[at] ?? code.length - 1,
|
|
155
|
+
loop: false,
|
|
156
|
+
}
|
|
157
|
+
if (longestOf(s, region, [...s.loops, ...chosen]) >= floor)
|
|
158
|
+
chosen.push(region)
|
|
159
|
+
}
|
|
160
|
+
return new Set(chosen.map(region => region.start))
|
|
161
|
+
}
|
|
162
|
+
/** WASM-HOST H2c: each region (the body, each loop body, each split in `splits`) priced at its longest path, not every
|
|
163
|
+
* instruction it holds. A call that takes one `if` arm, one `br_table` case or an early exit runs no more than that
|
|
164
|
+
* path, so a charge of this price covers every instruction run; an if/else or a switch pays for its longest arm, and a
|
|
165
|
+
* split arm a call skips is not paid at all (H2b read up to 14x over-billing). Edges: fall-through, `if` to its arm or
|
|
166
|
+
* past it, `else` past its `end`, a branch to past its block's `end`, and from a nested loop or split to wherever it
|
|
167
|
+
* can leave to. A return, `unreachable`, a branch to a loop (the loop charges again) or past the region ends a path. */
|
|
168
|
+
export function v2PathCosts(
|
|
169
|
+
code: readonly V2Instruction[],
|
|
170
|
+
constantCalls: ReadonlyMap<number, number> = new Map(),
|
|
171
|
+
splits: ReadonlySet<number> = new Set(),
|
|
172
|
+
): ReadonlyMap<number, number> {
|
|
173
|
+
const points = v2SplitPoints(code)
|
|
174
|
+
if ([...splits].some(at => !points.has(at)))
|
|
175
|
+
throw new Error('V2 split outside a split point')
|
|
176
|
+
const s = shape(code, constantCalls)
|
|
177
|
+
const regions: Region[] = [
|
|
178
|
+
{ start: 0, close: code.length - 1, loop: true },
|
|
179
|
+
...s.loops,
|
|
180
|
+
...[...splits].map(at => ({
|
|
181
|
+
start: at,
|
|
182
|
+
close: s.closes[at] ?? code.length - 1,
|
|
183
|
+
loop: false,
|
|
184
|
+
})),
|
|
185
|
+
]
|
|
186
|
+
return new Map(
|
|
187
|
+
regions.map(region => [region.start, longestOf(s, region, regions)]),
|
|
188
|
+
)
|
|
83
189
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* not permission to instantiate an image by itself. */
|
|
3
3
|
import { SCRIPT_ABI } from './scriptAbi.ts';
|
|
4
4
|
import { readV2Module,type V2Instruction,type V2Module,type V2Signature } from './scriptModuleV2.ts';
|
|
5
|
-
import { v2PathCosts } from './script-fuel-path-v2.ts';
|
|
5
|
+
import { v2PathCosts,v2SplitPoints } from './script-fuel-path-v2.ts';
|
|
6
6
|
|
|
7
7
|
export const V2_ENTRY_SIGNATURES: Readonly<Record<string,readonly number[]>> = Object.freeze({
|
|
8
8
|
ws_init: [0x7f,0x7f,0x7f], ws_step: [0x7f,0x7f], ws_project: [0x7f], ws_view: [0x7c,0x7c,0x7f],
|
|
@@ -108,8 +108,9 @@ export function inspectV2Fuel(bytes: Uint8Array,options: { readonly lane?: V2Lan
|
|
|
108
108
|
}
|
|
109
109
|
plain.push(value);
|
|
110
110
|
}
|
|
111
|
-
// H2c: each region pays at least its longest path (script-fuel-path-v2.ts)
|
|
112
|
-
const
|
|
111
|
+
// H2c: each region, and each split a charge stands on, pays at least its longest path (script-fuel-path-v2.ts)
|
|
112
|
+
const points = v2SplitPoints(plain);
|
|
113
|
+
const costs = v2PathCosts(plain,new Map([...getters].map(target => [target,2])),new Set([...charges.keys()].filter((at: number): boolean => points.has(at))));
|
|
113
114
|
if (costs.size !== charges.size || [...costs].some(([at,cost]) => (charges.get(at) ?? Number.NEGATIVE_INFINITY) < cost)) throw new Error('Missing or underpriced v2 basic block region');
|
|
114
115
|
unmetered.push(plain); calls.push(edges);
|
|
115
116
|
}
|