@wildshard/shard-format 0.67.0 → 0.68.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 +7 -19
- package/src/cli/corpus-deprecations.ts +41 -0
- package/src/cli/corpus.ts +300 -0
- package/src/cli/main.ts +32 -0
- package/src/format/cook-preparation.ts +22 -6
- package/src/format/deprecations.ts +132 -0
- package/src/format/empty-shardfile.json +56 -0
- package/src/format/empty-shardfile.ts +43 -0
- package/src/format/format-migrate-inventory.ts +142 -0
- package/src/format/format-migrate-rebuild.ts +269 -0
- package/src/format/format-migrate.ts +290 -0
- package/src/format/format-migration-journal.ts +129 -0
- package/src/format/format-migration-ops.ts +230 -0
- package/src/format/format-migration-prune.ts +106 -0
- package/src/format/format-migrations.ts +124 -0
- package/src/format/issue-codes.ts +3 -1
- package/src/format/journal-glyphs.json +12 -0
- package/src/format/memory-armed.json +1 -39
- package/src/format/memory-armed.ts +41 -8
- package/src/format/memory-epoch.ts +2 -2
- package/src/format/memory-line.ts +4 -3
- package/src/format/memoryAdmission.ts +1 -1
- package/src/format/policy-verdict.ts +95 -0
- package/src/format/runtime-tier.ts +3 -3
- package/src/format/shardSections.ts +11 -1
- package/src/format/shardfile-assets.ts +12 -8
- package/src/format/shardfile-stream-admit.ts +41 -16
- package/src/format/shardfile-stream-rows.ts +3 -1
- package/src/format/shardfile-stream.ts +12 -9
- package/src/format/shardfileValidation.ts +30 -18
- package/src/format/stateLineage.ts +1 -1
- package/src/format/version.ts +11 -13
- package/src/format/baked-terrain.golden.json +0 -2760
- package/src/format/colliders.golden.json +0 -1619
- package/src/format/forest-placement.golden.json +0 -4588
- package/src/format/geometry-layout.golden.json +0 -180
- package/src/format/interact-table.golden.json +0 -340
- package/src/format/item-catalogue.golden.json +0 -2310
- package/src/format/memory-ratchet.ts +0 -107
- package/src/format/small-laws.golden.json +0 -57
- package/src/format/terrain-field.golden.json +0 -3998
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// oxlint-disable typescript/prefer-readonly-parameter-types -- a step edits the shard it is handed, in place
|
|
2
|
+
/** FORMAT-PRUNE's same-version chain steps (J486): each writes the one way a 0.1.0.1 reader already admits, so writers
|
|
3
|
+
* can stop writing the other way with no format bump. Both are repairs: they also run on 0.1.0.1 files that still carry
|
|
4
|
+
* the old shape. Refusing the old shape in new uploads waits until the API and engine read migrated copies (CP2, FE9). */
|
|
5
|
+
import type { FormatMigration, MigratingShard } from './format-migrations.ts'
|
|
6
|
+
|
|
7
|
+
type JsonRecord = Record<string, unknown>
|
|
8
|
+
|
|
9
|
+
const OLD_POINTER = 'gridShardfile'
|
|
10
|
+
const POINTER = 'shardfile'
|
|
11
|
+
const CURRENT = '0.1.0.1'
|
|
12
|
+
const NONE = 0
|
|
13
|
+
|
|
14
|
+
function isRecord(value: unknown): value is JsonRecord {
|
|
15
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Each object under `value`, depth first. */
|
|
19
|
+
function objects(value: unknown, found: JsonRecord[]): JsonRecord[] {
|
|
20
|
+
if (Array.isArray(value)) {
|
|
21
|
+
for (const item of value) {
|
|
22
|
+
objects(item, found)
|
|
23
|
+
}
|
|
24
|
+
} else if (isRecord(value)) {
|
|
25
|
+
found.push(value)
|
|
26
|
+
for (const item of Object.values(value)) {
|
|
27
|
+
objects(item, found)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return found
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Every object holding the old pointer, in each section and each JSON cook mount. */
|
|
34
|
+
function pointerObjects(
|
|
35
|
+
shard: Readonly<MigratingShard>,
|
|
36
|
+
): readonly JsonRecord[] {
|
|
37
|
+
const found: JsonRecord[] = []
|
|
38
|
+
for (const value of [...shard.sections.values(), ...shard.mounts.values()]) {
|
|
39
|
+
objects(value, found)
|
|
40
|
+
}
|
|
41
|
+
return found.filter((row: Readonly<JsonRecord>): boolean =>
|
|
42
|
+
Object.hasOwn(row, OLD_POINTER),
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Rename the old pointer key in place, keeping its position; naming two different files is refused, as the engine's
|
|
47
|
+
* lift refuses it (`legacyPointer.ts`). */
|
|
48
|
+
function renamePointer(row: JsonRecord): void {
|
|
49
|
+
const { [OLD_POINTER]: old, [POINTER]: now } = row
|
|
50
|
+
if (now !== undefined && old !== undefined && now !== old) {
|
|
51
|
+
throw new Error('A manifest names its shardfile once')
|
|
52
|
+
}
|
|
53
|
+
const entries = Object.entries(row)
|
|
54
|
+
for (const [key] of entries) {
|
|
55
|
+
Reflect.deleteProperty(row, key)
|
|
56
|
+
}
|
|
57
|
+
for (const [key, value] of entries) {
|
|
58
|
+
if (key !== OLD_POINTER) {
|
|
59
|
+
row[key] = value
|
|
60
|
+
} else if (now === undefined && old !== undefined) {
|
|
61
|
+
row[POINTER] = value
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** FORMAT-PRUNE FP8: `gridShardfile` becomes `shardfile`, in the level manifest and the discovery mount alike. */
|
|
67
|
+
const shardfilePointer: FormatMigration = {
|
|
68
|
+
id: 'fp8-shardfile-pointer',
|
|
69
|
+
to: CURRENT,
|
|
70
|
+
touches: 'data',
|
|
71
|
+
affects: [],
|
|
72
|
+
apply: (shard: MigratingShard): void => {
|
|
73
|
+
for (const row of pointerObjects(shard)) {
|
|
74
|
+
renamePointer(row)
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
repairs: (shard: Readonly<MigratingShard>): boolean =>
|
|
78
|
+
pointerObjects(shard).length > NONE,
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function runtimeOf(shard: Readonly<MigratingShard>): JsonRecord | undefined {
|
|
82
|
+
const { runtime } = shard.index
|
|
83
|
+
return isRecord(runtime) ? runtime : undefined
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function carriesTrust(shard: Readonly<MigratingShard>): boolean {
|
|
87
|
+
const runtime = runtimeOf(shard)
|
|
88
|
+
return runtime !== undefined && Object.hasOwn(runtime, 'trust')
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** FORMAT-PRUNE FP3: `runtime.trust` has no reader in any repo; the copy drops it. */
|
|
92
|
+
const dropRuntimeTrust: FormatMigration = {
|
|
93
|
+
id: 'fp3-drop-runtime-trust',
|
|
94
|
+
to: CURRENT,
|
|
95
|
+
touches: 'data',
|
|
96
|
+
affects: [],
|
|
97
|
+
apply: (shard: MigratingShard): void => {
|
|
98
|
+
const runtime = runtimeOf(shard)
|
|
99
|
+
if (runtime !== undefined) {
|
|
100
|
+
Reflect.deleteProperty(runtime, 'trust')
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
repairs: carriesTrust,
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export { dropRuntimeTrust, shardfilePointer }
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// oxlint-disable typescript/prefer-readonly-parameter-types -- a step edits the shard it is handed, in place
|
|
2
|
+
/** The migration chain's registry (SHARD-COMPAT CP1, J486). A migration is one pure, data-only step that rewrites an
|
|
3
|
+
* older shard file's JSON to a newer format version. It is not a save migration (`migrations.ts`) and not a catalogue
|
|
4
|
+
* schema change (api-server). The change's author adds its migration here in the same release (J486, Q49). */
|
|
5
|
+
import { journalGlyphImages } from './format-migration-journal.ts'
|
|
6
|
+
import { dropRuntimeTrust, shardfilePointer } from './format-migration-prune.ts'
|
|
7
|
+
import {
|
|
8
|
+
SHARDFILE_VERSIONS,
|
|
9
|
+
compareShardfileVersions,
|
|
10
|
+
parseShardfileVersion,
|
|
11
|
+
} from './version.ts'
|
|
12
|
+
|
|
13
|
+
/** What a migration may read and rewrite: the parsed `shard.json`, each section by name and each JSON cook mount under
|
|
14
|
+
* `mounts/` by path. */
|
|
15
|
+
interface MigratingShard {
|
|
16
|
+
readonly index: Record<string, unknown>
|
|
17
|
+
readonly sections: Map<string, unknown>
|
|
18
|
+
readonly mounts: Map<string, unknown>
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** One step of the chain. `to` is the format version the step writes; it runs on every file below it. A repair step
|
|
22
|
+
* (`repairs`) also runs on a file already at `to` when `repairs` finds the old shape there: a break that shipped
|
|
23
|
+
* inside `to`, or a second way `to` still admits. */
|
|
24
|
+
interface FormatMigration {
|
|
25
|
+
readonly id: string
|
|
26
|
+
readonly to: string
|
|
27
|
+
/** `data` edits JSON the preparation does not fence; `files` reaches what it does (named JSON blobs, programs), so
|
|
28
|
+
* like `affects: render` the copy's author preparation is stale and the box's cook prepares again (SP1b). */
|
|
29
|
+
readonly touches: 'data' | 'files'
|
|
30
|
+
/** `render` leaves the author preparation stale for the box's cook (SP1b); `save` needs a save migration (J197). */
|
|
31
|
+
readonly affects: readonly ('render' | 'save')[]
|
|
32
|
+
/** The save migration a step that `affects: save` ships with (J197): what players' saved state does across it. */
|
|
33
|
+
readonly saveMigration?: string
|
|
34
|
+
readonly apply: (shard: MigratingShard) => void
|
|
35
|
+
readonly repairs?: (shard: Readonly<MigratingShard>) => boolean
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const TWO_PART = 2
|
|
39
|
+
const ZERO = 0
|
|
40
|
+
const ONE = 1
|
|
41
|
+
const LEGACY_SPELLING = '0.1'
|
|
42
|
+
const FOUR_PART_ZERO = '0.1.0.0'
|
|
43
|
+
|
|
44
|
+
/** FORMAT-PRUNE FP6: the two-part spelling `0.1` becomes `0.1.0.0`, the same format written the one way. */
|
|
45
|
+
const fourPartVersion: FormatMigration = {
|
|
46
|
+
id: 'fp6-four-part-version',
|
|
47
|
+
to: FOUR_PART_ZERO,
|
|
48
|
+
touches: 'data',
|
|
49
|
+
affects: [],
|
|
50
|
+
apply: (shard: Readonly<MigratingShard>): void => {
|
|
51
|
+
const { requires } = shard.index
|
|
52
|
+
if (
|
|
53
|
+
typeof requires === 'object' &&
|
|
54
|
+
requires !== null &&
|
|
55
|
+
Reflect.get(requires, 'sdk') === LEGACY_SPELLING
|
|
56
|
+
) {
|
|
57
|
+
Reflect.set(requires, 'sdk', FOUR_PART_ZERO)
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Every migration, oldest first. */
|
|
63
|
+
const FORMAT_MIGRATIONS: readonly FormatMigration[] = [
|
|
64
|
+
fourPartVersion,
|
|
65
|
+
journalGlyphImages,
|
|
66
|
+
shardfilePointer,
|
|
67
|
+
dropRuntimeTrust,
|
|
68
|
+
]
|
|
69
|
+
|
|
70
|
+
/** Whether a file at `version` still needs a step that writes `to`. The legacy two-part spelling sits just below its
|
|
71
|
+
* four-part twin, so the spelling step runs once and never again. */
|
|
72
|
+
function versionBelow(version: string, to: string): boolean {
|
|
73
|
+
const left = parseShardfileVersion(version)
|
|
74
|
+
const right = parseShardfileVersion(to)
|
|
75
|
+
for (let index = ZERO; index < left.length; index += ONE) {
|
|
76
|
+
const difference = (left[index] ?? ZERO) - (right[index] ?? ZERO)
|
|
77
|
+
if (difference !== ZERO) {
|
|
78
|
+
return difference < ZERO
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return (
|
|
82
|
+
version.split('.').length === TWO_PART && to.split('.').length > TWO_PART
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Refuse one step: a `to` that is no format version, out of version order after `last`, or a save-affecting step with
|
|
87
|
+
* no save migration. */
|
|
88
|
+
function checkStep(step: Readonly<FormatMigration>, last: string): void {
|
|
89
|
+
if (
|
|
90
|
+
!SHARDFILE_VERSIONS.some((version: string): boolean => version === step.to)
|
|
91
|
+
) {
|
|
92
|
+
throw new Error(`Migration ${step.id} writes ${step.to}, no format version`)
|
|
93
|
+
}
|
|
94
|
+
if (compareShardfileVersions(step.to, last) < ZERO) {
|
|
95
|
+
throw new Error(`Migration ${step.id} is out of version order`)
|
|
96
|
+
}
|
|
97
|
+
if (step.affects.includes('save') && step.saveMigration === undefined) {
|
|
98
|
+
throw new Error(
|
|
99
|
+
`Migration ${step.id} affects saves without a save migration`,
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Refuse a registry the chain cannot run as written (FE8): a repeated id, or a step `checkStep` refuses. */
|
|
105
|
+
function checkMigrations(migrations: readonly FormatMigration[]): void {
|
|
106
|
+
const ids = new Set<string>()
|
|
107
|
+
let last: string = LEGACY_SPELLING
|
|
108
|
+
for (const step of migrations) {
|
|
109
|
+
if (ids.has(step.id)) {
|
|
110
|
+
throw new Error(`Migration ${step.id} is registered twice`)
|
|
111
|
+
}
|
|
112
|
+
ids.add(step.id)
|
|
113
|
+
checkStep(step, last)
|
|
114
|
+
last = step.to
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export {
|
|
119
|
+
FORMAT_MIGRATIONS,
|
|
120
|
+
checkMigrations,
|
|
121
|
+
type FormatMigration,
|
|
122
|
+
type MigratingShard,
|
|
123
|
+
versionBelow,
|
|
124
|
+
}
|
|
@@ -36,7 +36,9 @@ const VALIDATE_CODES = {
|
|
|
36
36
|
'pack-invalid':
|
|
37
37
|
"A pack is missing a member, or a member or the pack's hash differs.",
|
|
38
38
|
'cook-invalid':
|
|
39
|
-
'The cook file
|
|
39
|
+
'The cook file or a mount (path or bytes) is invalid (C0, J137).',
|
|
40
|
+
'preparation-invalid':
|
|
41
|
+
"The author's preparation is missing, stale or invalid: its inputHash, fence or programs mount (J487, SHARD-COMPAT PR3; docs/preparation.md).",
|
|
40
42
|
'runtime-files':
|
|
41
43
|
'Copied runtime files are present without a runtime import checker, or fail it.',
|
|
42
44
|
'unlisted-file': 'A file in the product is not listed in `shard.json`.',
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"about": "Frozen engine table (SHARD-COMPAT CP1, design Q17): the seven journal glyphs a compendium icon could name before shard-format 036b383 made icons image-only, drawn as engine src/client/game/icons.ts drew them (64x64, currentColor; ghost without its glow filter, strokes without caps). The journal-glyph-images chain step writes each as an inert SVG image.",
|
|
3
|
+
"glyphs": {
|
|
4
|
+
"deer": "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2264%22%20height%3D%2264%22%20viewBox%3D%220%200%2064%2064%22%20fill%3D%22currentColor%22%20stroke%3D%22none%22%3E%3Cellipse%20cx%3D%2237%22%20cy%3D%2235%22%20rx%3D%2216%22%20ry%3D%228.5%22%2F%3E%20%3Cpath%20d%3D%22M25%2031%20L20%2016%20L27%2015%20L31%2030%20Z%22%2F%3E%20%3Cellipse%20cx%3D%2220%22%20cy%3D%2215%22%20rx%3D%226.5%22%20ry%3D%224%22%2F%3E%20%3Cpath%20d%3D%22M15%2013%20L12%206%20L17%2011%20Z%22%2F%3E%20%3Cpath%20d%3D%22M25%2012%20L27%207%20L29%2012%20Z%22%2F%3E%20%3Cpath%20d%3D%22M20%2012%20L17%203%20M20%2012%20L23%202%20M17%203%20L14%204%20M18.5%207%20L15%206%20M23%202%20L26%201%20M21.5%206%20L25%205%22%20fill%3D%22none%22%20stroke%3D%22currentColor%22%20stroke-width%3D%221.8%22%2F%3E%20%3Cpath%20d%3D%22M52%2030%20L56%2026%20L55%2031%20Z%22%2F%3E%20%3Crect%20x%3D%2224%22%20y%3D%2240%22%20width%3D%223.2%22%20height%3D%2217%22%20rx%3D%221%22%2F%3E%3Crect%20x%3D%2230%22%20y%3D%2240%22%20width%3D%223.2%22%20height%3D%2217%22%20rx%3D%221%22%2F%3E%3Crect%20x%3D%2243%22%20y%3D%2240%22%20width%3D%223.2%22%20height%3D%2217%22%20rx%3D%221%22%2F%3E%3Crect%20x%3D%2249%22%20y%3D%2240%22%20width%3D%223.2%22%20height%3D%2217%22%20rx%3D%221%22%2F%3E%3C%2Fsvg%3E",
|
|
5
|
+
"elk": "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2264%22%20height%3D%2264%22%20viewBox%3D%220%200%2064%2064%22%20fill%3D%22currentColor%22%20stroke%3D%22none%22%3E%3Cellipse%20cx%3D%2238%22%20cy%3D%2236%22%20rx%3D%2217%22%20ry%3D%229.5%22%2F%3E%20%3Cpath%20d%3D%22M24%2032%20L18%2015%20L27%2013%20L32%2030%20Z%22%2F%3E%20%3Cpath%20d%3D%22M22%2026%20L19%2034%20L26%2031%20Z%22%2F%3E%20%3Cellipse%20cx%3D%2219%22%20cy%3D%2214%22%20rx%3D%227%22%20ry%3D%224.5%22%2F%3E%20%3Cpath%20d%3D%22M13%2012%20L9%206%20L15%2010%20Z%22%2F%3E%20%3Cpath%20d%3D%22M18%2011%20C12%208%208%203%206%20-2%20M18%2011%20C15%205%2013%201%2014%20-3%20M18%2011%20L24%20-1%20M20%205%20L17%202%20M22%202%20L19%20-1%20M13%205%20L9%204%20M11%208%20L6%208%20M22%204%20L25%201%22%20fill%3D%22none%22%20stroke%3D%22currentColor%22%20stroke-width%3D%222.2%22%2F%3E%20%3Crect%20x%3D%2223%22%20y%3D%2242%22%20width%3D%223.6%22%20height%3D%2217%22%20rx%3D%221%22%2F%3E%3Crect%20x%3D%2230%22%20y%3D%2242%22%20width%3D%223.6%22%20height%3D%2217%22%20rx%3D%221%22%2F%3E%3Crect%20x%3D%2245%22%20y%3D%2242%22%20width%3D%223.6%22%20height%3D%2217%22%20rx%3D%221%22%2F%3E%3Crect%20x%3D%2252%22%20y%3D%2242%22%20width%3D%223.6%22%20height%3D%2217%22%20rx%3D%221%22%2F%3E%3C%2Fsvg%3E",
|
|
6
|
+
"boar": "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2264%22%20height%3D%2264%22%20viewBox%3D%220%200%2064%2064%22%20fill%3D%22currentColor%22%20stroke%3D%22none%22%3E%3Cpath%20d%3D%22M14%2034%20C12%2024%2024%2020%2036%2020%20C50%2020%2058%2026%2057%2036%20C56%2044%2048%2046%2036%2046%20C24%2046%2015%2044%2014%2034%20Z%22%2F%3E%20%3Cpath%20d%3D%22M15%2030%20L6%2035%20L8%2042%20L16%2042%20Z%22%2F%3E%20%3Cpath%20d%3D%22M7%2040%20L3%2044%20L6%2044.5%20Z%22%2F%3E%20%3Cpath%20d%3D%22M30%2020%20L33%2016%20L36%2020%20Z%20M40%2020%20L43%2016%20L46%2020%20Z%22%2F%3E%20%3Cpath%20d%3D%22M8%2043.5%20C9%2046.5%2012%2047%2014%2045%22%20fill%3D%22none%22%20stroke%3D%22currentColor%22%20stroke-width%3D%222%22%2F%3E%20%3Cpath%20d%3D%22M57%2030%20L61%2026%20L60%2033%20Z%22%2F%3E%20%3Crect%20x%3D%2218%22%20y%3D%2243%22%20width%3D%223.4%22%20height%3D%2214%22%20rx%3D%221%22%2F%3E%3Crect%20x%3D%2225%22%20y%3D%2243%22%20width%3D%223.4%22%20height%3D%2214%22%20rx%3D%221%22%2F%3E%3Crect%20x%3D%2241%22%20y%3D%2243%22%20width%3D%223.4%22%20height%3D%2214%22%20rx%3D%221%22%2F%3E%3Crect%20x%3D%2248%22%20y%3D%2243%22%20width%3D%223.4%22%20height%3D%2214%22%20rx%3D%221%22%2F%3E%3C%2Fsvg%3E",
|
|
7
|
+
"bear": "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2264%22%20height%3D%2264%22%20viewBox%3D%220%200%2064%2064%22%20fill%3D%22currentColor%22%20stroke%3D%22none%22%3E%3Cpath%20d%3D%22M8%2030%20C6%2024%2010%2020%2016%2020%20L20%2020%20C24%2014%2034%2012%2044%2014%20C54%2016%2060%2024%2058%2034%20C57%2042%2052%2046%2044%2046%20L20%2046%20C12%2046%208%2040%208%2030%20Z%22%2F%3E%20%3Cpath%20d%3D%22M10%2022%20C6%2022%204%2026%205%2030%20C7%2033%2012%2033%2014%2030%20L20%2030%20L20%2036%20C16%2040%2010%2038%208%2034%20Z%22%2F%3E%20%3Cpath%20d%3D%22M4%2032%20L1%2036%20L5%2036.5%20Z%22%2F%3E%20%3Ccircle%20cx%3D%2214%22%20cy%3D%2218%22%20r%3D%223.2%22%2F%3E%3Ccircle%20cx%3D%2221%22%20cy%3D%2215%22%20r%3D%223%22%2F%3E%20%3Crect%20x%3D%2216%22%20y%3D%2244%22%20width%3D%225.2%22%20height%3D%2213%22%20rx%3D%221%22%2F%3E%3Crect%20x%3D%2224%22%20y%3D%2244%22%20width%3D%225.2%22%20height%3D%2213%22%20rx%3D%221%22%2F%3E%3Crect%20x%3D%2240%22%20y%3D%2244%22%20width%3D%225.2%22%20height%3D%2213%22%20rx%3D%221%22%2F%3E%3Crect%20x%3D%2248%22%20y%3D%2244%22%20width%3D%225.2%22%20height%3D%2213%22%20rx%3D%221%22%2F%3E%3C%2Fsvg%3E",
|
|
8
|
+
"antlers": "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2264%22%20height%3D%2264%22%20viewBox%3D%220%200%2064%2064%22%20fill%3D%22currentColor%22%20stroke%3D%22none%22%3E%3Cpath%20d%3D%22M32%2058%20L32%2030%20M32%2030%20C22%2028%2014%2020%2012%208%20M32%2030%20C42%2028%2050%2020%2052%208%20M22%2026%20L16%2018%20M42%2026%20L48%2018%20M18%2016%20L10%2014%20M46%2016%20L54%2014%20M27%2029%20L24%2036%20M37%2029%20L40%2036%22%20fill%3D%22none%22%20stroke%3D%22currentColor%22%20stroke-width%3D%223.5%22%2F%3E%3C%2Fsvg%3E",
|
|
9
|
+
"ghost": "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2264%22%20height%3D%2264%22%20viewBox%3D%220%200%2064%2064%22%20fill%3D%22currentColor%22%20stroke%3D%22none%22%3E%3Cg%20opacity%3D%220.7%22%3E%3Cellipse%20cx%3D%2237%22%20cy%3D%2235%22%20rx%3D%2216%22%20ry%3D%228.5%22%2F%3E%20%3Cpath%20d%3D%22M25%2031%20L20%2016%20L27%2015%20L31%2030%20Z%22%2F%3E%20%3Cellipse%20cx%3D%2220%22%20cy%3D%2215%22%20rx%3D%226.5%22%20ry%3D%224%22%2F%3E%20%3Cpath%20d%3D%22M15%2013%20L12%206%20L17%2011%20Z%22%2F%3E%20%3Cpath%20d%3D%22M25%2012%20L27%207%20L29%2012%20Z%22%2F%3E%20%3Cpath%20d%3D%22M20%2012%20L17%203%20M20%2012%20L23%202%20M17%203%20L14%204%20M18.5%207%20L15%206%20M23%202%20L26%201%20M21.5%206%20L25%205%22%20fill%3D%22none%22%20stroke%3D%22currentColor%22%20stroke-width%3D%221.8%22%2F%3E%20%3Cpath%20d%3D%22M52%2030%20L56%2026%20L55%2031%20Z%22%2F%3E%20%3Crect%20x%3D%2224%22%20y%3D%2240%22%20width%3D%223.2%22%20height%3D%2217%22%20rx%3D%221%22%2F%3E%3Crect%20x%3D%2230%22%20y%3D%2240%22%20width%3D%223.2%22%20height%3D%2217%22%20rx%3D%221%22%2F%3E%3Crect%20x%3D%2243%22%20y%3D%2240%22%20width%3D%223.2%22%20height%3D%2217%22%20rx%3D%221%22%2F%3E%3Crect%20x%3D%2249%22%20y%3D%2240%22%20width%3D%223.2%22%20height%3D%2217%22%20rx%3D%221%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E",
|
|
10
|
+
"ironhide": "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2264%22%20height%3D%2264%22%20viewBox%3D%220%200%2064%2064%22%20fill%3D%22currentColor%22%20stroke%3D%22none%22%3E%3Cg%20transform%3D%22translate(-4%20-6)%20scale(1.14)%22%3E%3Cpath%20d%3D%22M14%2034%20C12%2024%2024%2020%2036%2020%20C50%2020%2058%2026%2057%2036%20C56%2044%2048%2046%2036%2046%20C24%2046%2015%2044%2014%2034%20Z%22%2F%3E%20%3Cpath%20d%3D%22M15%2030%20L6%2035%20L8%2042%20L16%2042%20Z%22%2F%3E%20%3Cpath%20d%3D%22M7%2040%20L3%2044%20L6%2044.5%20Z%22%2F%3E%20%3Cpath%20d%3D%22M30%2020%20L33%2016%20L36%2020%20Z%20M40%2020%20L43%2016%20L46%2020%20Z%22%2F%3E%20%3Cpath%20d%3D%22M8%2043.5%20C9%2046.5%2012%2047%2014%2045%22%20fill%3D%22none%22%20stroke%3D%22currentColor%22%20stroke-width%3D%222%22%2F%3E%20%3Cpath%20d%3D%22M57%2030%20L61%2026%20L60%2033%20Z%22%2F%3E%20%3Crect%20x%3D%2218%22%20y%3D%2243%22%20width%3D%223.4%22%20height%3D%2214%22%20rx%3D%221%22%2F%3E%3Crect%20x%3D%2225%22%20y%3D%2243%22%20width%3D%223.4%22%20height%3D%2214%22%20rx%3D%221%22%2F%3E%3Crect%20x%3D%2241%22%20y%3D%2243%22%20width%3D%223.4%22%20height%3D%2214%22%20rx%3D%221%22%2F%3E%3Crect%20x%3D%2248%22%20y%3D%2243%22%20width%3D%223.4%22%20height%3D%2214%22%20rx%3D%221%22%2F%3E%3Cpath%20d%3D%22M4%2046%20L-2%2052%20L5%2050%20Z%22%20transform%3D%22translate(4%20-4)%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$doc": "J426 (Jake, 2026-11-18): the one armed-zone list. A zone named here has done the work to get under the J410 lines, and from then on every memory gate refuses it back over them, with no override flag and no report-only fallback: the format's offline estimate over lines.playingBytes / lines.loadingBytes (check, validate, cook, upload), the declared worst-location total over the J408 1.5 GB line, the runtime tier and a stale runtime reading; engine's ledger, footprint and boot-line guards read the same list. A zone not named here reports only (J424). Each zone's playingBytes / loadingBytes are its offline estimate when it was armed (memory epoch in `epoch`); the offline estimate refuses over the larger of the line and that reading plus 0.5% (memory-armed.ts ARMED_ALLOWANCE), so a zone EM11 measured under the line whose conservative estimate reads over it (Nine's playing) is locked at its armed state. Decimal bytes. Format memory-armed.ts reads this; engine reads @wildshard/format/src/format/memory-armed.json.
|
|
2
|
+
"$doc": "J426 (Jake, 2026-11-18): the one armed-zone list. A zone named here has done the work to get under the J410 lines, and from then on every memory gate refuses it back over them, with no override flag and no report-only fallback: the format's offline estimate over lines.playingBytes / lines.loadingBytes (check, validate, cook, upload), the declared worst-location total over the J408 1.5 GB line, the runtime tier and a stale runtime reading; engine's ledger, footprint and boot-line guards read the same list. A zone not named here reports only (J424). Each zone's playingBytes / loadingBytes are its offline estimate when it was armed (memory epoch in `epoch`); the offline estimate refuses over the larger of the line and that reading plus 0.5% (memory-armed.ts ARMED_ALLOWANCE), so a zone EM11 measured under the line whose conservative estimate reads over it (Nine's playing) is locked at its armed state. Decimal bytes. Format memory-armed.ts reads this; engine reads @wildshard/format/src/format/memory-armed.json. The four zones once held here (Driftwood, Nalati, Nine Dragon, Pine) are simply not armed: CP10 judges a stored original by its stored verdict, so no pinned product needs a hold (FORMAT-PRUNE FP12); arming moves to the API catalogue at FP27.",
|
|
3
3
|
"lines": {
|
|
4
4
|
"playingBytes": 1000000000,
|
|
5
5
|
"loadingBytes": 1500000000
|
|
@@ -181,43 +181,5 @@
|
|
|
181
181
|
"loadingBytes": 1108011593,
|
|
182
182
|
"evidence": "engine-pinned product revision 2 (tar f4a1d611cccc), a shard with no runtime reading; epoch-8 golden estimate; mini-resweep reads every light zone under both J410 lines standalone"
|
|
183
183
|
}
|
|
184
|
-
},
|
|
185
|
-
"held": {
|
|
186
|
-
"driftwood-isle": {
|
|
187
|
-
"armed": "2026-11-18",
|
|
188
|
-
"by": "mini-pinemem5",
|
|
189
|
-
"epoch": 8,
|
|
190
|
-
"playingBytes": 820905616,
|
|
191
|
-
"loadingBytes": 1157545785,
|
|
192
|
-
"evidence": "shard-driftwood e736730 built with format 0.37 (epoch 8); codex-nalati locked pairs on the EM11 upper read 990.5 / 1,344.7 MB (meta MEMORY-GATES)",
|
|
193
|
-
"held": "2026-11-18 opus-pin (J424, QA 11-18 row 29): engine pins an older product of this zone that reads over its line; re-arm (move back to zones) when engine's pin reaches the armed build"
|
|
194
|
-
},
|
|
195
|
-
"nalati-grasslands": {
|
|
196
|
-
"armed": "2026-11-18",
|
|
197
|
-
"by": "mini-pinemem5",
|
|
198
|
-
"epoch": 8,
|
|
199
|
-
"playingBytes": 945736154,
|
|
200
|
-
"loadingBytes": 1328901899,
|
|
201
|
-
"evidence": "shard-nalati 1d5014e8 built with format 0.37 (epoch 8); mini-resweep EM11 upper on the J420 stand-in: playing 0.940 GB less the worker, loading 1.470 GB (meta MEMORY-GATES)",
|
|
202
|
-
"held": "2026-11-18 opus-pin (J424, QA 11-18 row 29): engine pins an older product of this zone that reads over its line; re-arm (move back to zones) when engine's pin reaches the armed build"
|
|
203
|
-
},
|
|
204
|
-
"nine-dragon-stack": {
|
|
205
|
-
"armed": "2026-11-18",
|
|
206
|
-
"by": "mini-pinemem5",
|
|
207
|
-
"epoch": 8,
|
|
208
|
-
"playingBytes": 1023504847,
|
|
209
|
-
"loadingBytes": 1434692360,
|
|
210
|
-
"evidence": "shard-nine-dragon 8779b872 built with format 0.37 (epoch 8); mini-pinemem6 prepared online boot on engine d0fd6e62, 9 pairs: playing upper 0.938 GB, loading upper 1.435 GB (meta 1677f091). The estimate's playing (1,023.5 MB) is over the 1.0 GB line, so it locks at that reading",
|
|
211
|
-
"held": "2026-11-18 opus-pin (J424, QA 11-18 row 29): engine pins an older product of this zone that reads over its line; re-arm (move back to zones) when engine's pin reaches the armed build"
|
|
212
|
-
},
|
|
213
|
-
"pine-hollow": {
|
|
214
|
-
"armed": "2026-11-18",
|
|
215
|
-
"by": "mini-pinemem5",
|
|
216
|
-
"epoch": 8,
|
|
217
|
-
"playingBytes": 920666659,
|
|
218
|
-
"loadingBytes": 1298769921,
|
|
219
|
-
"evidence": "shard-pine-hollow 400ed4b7 built with format 0.37 (epoch 8); mini-pinemem6 prepared online boot on engine f0a96518, 9 pairs: playing upper 0.969 GB, loading upper 1.407 GB (meta 118a2b13)",
|
|
220
|
-
"held": "2026-11-18 opus-pin (J424, QA 11-18 row 29): engine pins an older product of this zone that reads over its line; re-arm (move back to zones) when engine's pin reaches the armed build"
|
|
221
|
-
}
|
|
222
184
|
}
|
|
223
185
|
}
|
|
@@ -24,12 +24,6 @@ const ARMED_ZONES: Readonly<Record<string, ArmedZone>> = Object.freeze(
|
|
|
24
24
|
|
|
25
25
|
/** J424 (QA 11-18 row 29): a zone armed once but held out of `ARMED_ZONES` while engine pins an older product of it
|
|
26
26
|
* that reads over its line. It reports only; it moves back to `zones` (re-armed) when its engine re-pin lands. */
|
|
27
|
-
interface HeldZone extends ArmedZone {
|
|
28
|
-
readonly held: string
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const HELD_ZONES: Readonly<Record<string, HeldZone>> = Object.freeze(armed.held)
|
|
32
|
-
|
|
33
27
|
/** True when `slug` is in the armed list (J426). */
|
|
34
28
|
function zoneArmed(slug?: string): boolean {
|
|
35
29
|
return slug !== undefined && Object.hasOwn(ARMED_ZONES, slug)
|
|
@@ -44,13 +38,52 @@ function armedLine(
|
|
|
44
38
|
return zoneArmed(slug) ? ARMED_LINES[kind] : undefined
|
|
45
39
|
}
|
|
46
40
|
|
|
41
|
+
type RatchetMetric = 'playing' | 'loading' | 'runtime'
|
|
42
|
+
|
|
43
|
+
/** J445: only the common loading ceiling can refuse an armed shard. Playing and runtime tier overages are reported. */
|
|
44
|
+
function ratchetLimit(
|
|
45
|
+
slug: string | undefined,
|
|
46
|
+
metric: RatchetMetric,
|
|
47
|
+
line: number,
|
|
48
|
+
): number {
|
|
49
|
+
return metric === 'loading' && zoneArmed(slug)
|
|
50
|
+
? line
|
|
51
|
+
: Number.POSITIVE_INFINITY
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Describe the offline decision for a measured overage. */
|
|
55
|
+
function ratchetSeverity(
|
|
56
|
+
slug: string | undefined,
|
|
57
|
+
metric: RatchetMetric,
|
|
58
|
+
reading: Readonly<{ line: number; actual: number }>,
|
|
59
|
+
): 'refusal' | 'warning' {
|
|
60
|
+
return reading.actual > ratchetLimit(slug, metric, reading.line)
|
|
61
|
+
? 'refusal'
|
|
62
|
+
: 'warning'
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** The words a reported (not refused) issue carries: why it only reports (J424). */
|
|
66
|
+
function ratchetNote(slug: string | undefined): string {
|
|
67
|
+
return zoneArmed(slug)
|
|
68
|
+
? ''
|
|
69
|
+
: ` (report-only, J424: ${slug ?? 'this shard'} is not armed)`
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** True when a stale runtime reading only reports: J424, every zone not armed (J426). */
|
|
73
|
+
function staleReadingAdmitted(slug: string | undefined): boolean {
|
|
74
|
+
return !zoneArmed(slug)
|
|
75
|
+
}
|
|
76
|
+
|
|
47
77
|
export {
|
|
48
78
|
ARMED_LINES,
|
|
49
79
|
ARMED_ZONES,
|
|
50
80
|
type ArmedKind,
|
|
51
81
|
type ArmedZone,
|
|
52
82
|
armedLine,
|
|
53
|
-
|
|
54
|
-
|
|
83
|
+
type RatchetMetric,
|
|
84
|
+
ratchetLimit,
|
|
85
|
+
ratchetNote,
|
|
86
|
+
ratchetSeverity,
|
|
87
|
+
staleReadingAdmitted,
|
|
55
88
|
zoneArmed,
|
|
56
89
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { staleReadingAdmitted } from './memory-
|
|
1
|
+
import { staleReadingAdmitted } from './memory-armed.ts'
|
|
2
2
|
|
|
3
3
|
/** MEMORY-GATES MG5 (J408, Jake 2026-11-17: "a stale runtimeCost is refused"): the memory model a runtime home's
|
|
4
4
|
* `runtimeCost` reading must have been taken against. It rises when the model changes what it charges (MG6 adds shader
|
|
@@ -46,7 +46,7 @@ function staleRuntimeIssues(
|
|
|
46
46
|
current: number = OLDEST_CURRENT_EPOCH,
|
|
47
47
|
identity?: Readonly<{ slug: string; revision: number }>,
|
|
48
48
|
): StaleRuntimeIssue[] {
|
|
49
|
-
const admitted = staleReadingAdmitted(identity?.slug
|
|
49
|
+
const admitted = staleReadingAdmitted(identity?.slug)
|
|
50
50
|
const rows: EpochRow[] = []
|
|
51
51
|
const cost = runtime === null ? undefined : runtime.cost
|
|
52
52
|
if (cost !== undefined) {
|
|
@@ -2,8 +2,7 @@ import { parse } from 'valibot'
|
|
|
2
2
|
|
|
3
3
|
import { bootMemoryCosts } from './boot-memory-cost.ts'
|
|
4
4
|
import { worstContentCost } from './budget.ts'
|
|
5
|
-
import { ARMED_LINES } from './memory-armed.ts'
|
|
6
|
-
import { ratchetNote, ratchetSeverity } from './memory-ratchet.ts'
|
|
5
|
+
import { ARMED_LINES, ratchetNote, ratchetSeverity } from './memory-armed.ts'
|
|
7
6
|
import { runtimeAccountedBytes, RuntimeCostSchema } from './runtimeCost.ts'
|
|
8
7
|
|
|
9
8
|
import type { TierIndex } from './phone-files.ts'
|
|
@@ -45,7 +44,7 @@ function hardLineIssue(
|
|
|
45
44
|
: overHardLine(bytes)
|
|
46
45
|
return {
|
|
47
46
|
code: `perf-${kind}-memory`,
|
|
48
|
-
metric: `worst ${kind} total bytes${over}${severity === 'warning' ? ratchetNote(slug
|
|
47
|
+
metric: `worst ${kind} total bytes${over}${severity === 'warning' ? ratchetNote(slug) : ''}`,
|
|
49
48
|
actual: bytes,
|
|
50
49
|
limit: line,
|
|
51
50
|
severity,
|
|
@@ -87,12 +86,14 @@ type MemoryContext =
|
|
|
87
86
|
sections: ReadonlyMap<string, unknown>
|
|
88
87
|
mountedImages: number
|
|
89
88
|
index?: TierIndex
|
|
89
|
+
judged?: 'upload' | 'stored'
|
|
90
90
|
}>
|
|
91
91
|
|
|
92
92
|
function memoryContext(context: MemoryContext): Readonly<{
|
|
93
93
|
sections: ReadonlyMap<string, unknown>
|
|
94
94
|
mountedImages: number
|
|
95
95
|
index?: TierIndex
|
|
96
|
+
judged?: 'upload' | 'stored'
|
|
96
97
|
}> {
|
|
97
98
|
return context instanceof Map
|
|
98
99
|
? { sections: context, mountedImages: EMPTY_BYTES }
|
|
@@ -35,7 +35,7 @@ export class MemoryAdmission {
|
|
|
35
35
|
private readonly developer: () => boolean;
|
|
36
36
|
private readonly hardBytes: number | ((owner: string, kind: 'playing' | 'loading') => number);
|
|
37
37
|
/** `hardBytes` (J408): applies to playing and loading even with an override; a function gives each owner its own
|
|
38
|
-
* line (J412's ratchet, `memory-
|
|
38
|
+
* line (J412's ratchet, `memory-armed.ts`). */
|
|
39
39
|
constructor(developer: () => boolean = () => false, hardBytes: number | ((owner: string, kind: 'playing' | 'loading') => number) = Number.POSITIVE_INFINITY) { this.developer = developer; this.hardBytes = hardBytes; }
|
|
40
40
|
|
|
41
41
|
/** True for an in-envelope request or a Developer override. False means the caller retains its original refusal path. */
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { zoneArmed } from './memory-armed.ts'
|
|
2
|
+
import { MEMORY_EPOCH } from './memory-epoch.ts'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* SHARD-COMPAT CP10 (J486 D1.1, Jake 2026-11-21): memory lines, budgets and runtime targets judge a shard file once,
|
|
6
|
+
* at upload. The API stores this verdict and its rule version (the memory epoch) beside the original; a stored
|
|
7
|
+
* original, an engine shard pin and a cook validate with `judged: 'stored'`, so a newer policy reaches new uploads only
|
|
8
|
+
* and never re-judges what was already admitted. Readability (schemas, inventory, hashes, preparation) is judged every
|
|
9
|
+
* time either way.
|
|
10
|
+
*/
|
|
11
|
+
type Judged = 'upload' | 'stored'
|
|
12
|
+
|
|
13
|
+
interface PolicyIssue {
|
|
14
|
+
readonly code: string
|
|
15
|
+
readonly metric: string
|
|
16
|
+
readonly actual: number
|
|
17
|
+
readonly limit: number
|
|
18
|
+
readonly severity: 'refusal' | 'warning'
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface PolicyVerdict {
|
|
22
|
+
readonly judged: Judged
|
|
23
|
+
/** The rule version the verdict was reached under. */
|
|
24
|
+
readonly epoch: number
|
|
25
|
+
/** Whether the zone was on the armed list (J426) when judged. */
|
|
26
|
+
readonly armed: boolean
|
|
27
|
+
/** Every policy issue found: warnings on an upload (a refusal throws); warnings and would-be refusals when stored. */
|
|
28
|
+
readonly issues: readonly PolicyIssue[]
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function policyVerdict(
|
|
32
|
+
slug: string | undefined,
|
|
33
|
+
judged: Judged,
|
|
34
|
+
issues: readonly PolicyIssue[],
|
|
35
|
+
): PolicyVerdict {
|
|
36
|
+
return {
|
|
37
|
+
judged,
|
|
38
|
+
epoch: MEMORY_EPOCH,
|
|
39
|
+
armed: zoneArmed(slug),
|
|
40
|
+
issues: issues.map(
|
|
41
|
+
({ code, metric, actual, limit, severity }): PolicyIssue => ({
|
|
42
|
+
code,
|
|
43
|
+
metric,
|
|
44
|
+
actual,
|
|
45
|
+
limit,
|
|
46
|
+
severity,
|
|
47
|
+
}),
|
|
48
|
+
),
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** What the host measures on its own engine build (script CPU and fuel) still refuses; the file's own facts do not. */
|
|
53
|
+
const MEASURED = 'perf-script-'
|
|
54
|
+
|
|
55
|
+
/** A performance report's issues for a stored original (engine `checkShardfile` in the cook): a fact of the file judged
|
|
56
|
+
* at upload only warns; an upload keeps every severity. */
|
|
57
|
+
function asJudged<
|
|
58
|
+
Issue extends Readonly<{ code: string; severity: 'refusal' | 'warning' }>,
|
|
59
|
+
>(issues: readonly Issue[], judged: Judged | undefined): Issue[] {
|
|
60
|
+
if (judged !== 'stored') {
|
|
61
|
+
return [...issues]
|
|
62
|
+
}
|
|
63
|
+
return issues.map((issue: Issue): Issue =>
|
|
64
|
+
issue.code.startsWith(MEASURED) ? issue : { ...issue, severity: 'warning' },
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** The verdict each admitted shard object was judged with: read back by the validators, so no signature grows. */
|
|
69
|
+
const VERDICTS = new WeakMap<object, PolicyVerdict>()
|
|
70
|
+
|
|
71
|
+
function recordVerdict<Admitted extends object>(
|
|
72
|
+
shard: Admitted,
|
|
73
|
+
verdict: PolicyVerdict,
|
|
74
|
+
): Admitted {
|
|
75
|
+
VERDICTS.set(shard, verdict)
|
|
76
|
+
return shard
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function admittedVerdict(shard: Readonly<object>): PolicyVerdict {
|
|
80
|
+
const verdict = VERDICTS.get(shard)
|
|
81
|
+
if (verdict === undefined) {
|
|
82
|
+
throw new Error('admitted with no policy verdict')
|
|
83
|
+
}
|
|
84
|
+
return verdict
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export {
|
|
88
|
+
type Judged,
|
|
89
|
+
type PolicyIssue,
|
|
90
|
+
type PolicyVerdict,
|
|
91
|
+
admittedVerdict,
|
|
92
|
+
asJudged,
|
|
93
|
+
policyVerdict,
|
|
94
|
+
recordVerdict,
|
|
95
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UNNAMED_TIER, budgetTierLimits } from './budget-tiers.ts'
|
|
2
|
-
import { ratchetNote, ratchetSeverity } from './memory-
|
|
2
|
+
import { ratchetNote, ratchetSeverity } from './memory-armed.ts'
|
|
3
3
|
import { runtimeAccountedBytes } from './runtimeCost.ts'
|
|
4
4
|
|
|
5
5
|
import type { BudgetTier } from './budget-tiers.ts'
|
|
@@ -8,7 +8,7 @@ import type { BudgetTier } from './budget-tiers.ts'
|
|
|
8
8
|
type RuntimeTierSource = Readonly<{
|
|
9
9
|
runtime: Readonly<{ cost?: unknown }> | null
|
|
10
10
|
budgets: Readonly<{ client?: unknown; tier?: BudgetTier }>
|
|
11
|
-
/** J412: the zone whose
|
|
11
|
+
/** J412: the zone whose armed state applies (`memory-armed.ts`). */
|
|
12
12
|
identity?: Readonly<{ slug: string }>
|
|
13
13
|
}>
|
|
14
14
|
|
|
@@ -42,7 +42,7 @@ function runtimeTierIssues(source: RuntimeTierSource): RuntimeTierIssue[] {
|
|
|
42
42
|
return [
|
|
43
43
|
{
|
|
44
44
|
code: 'runtime-tier-memory',
|
|
45
|
-
metric: `runtime accounted bytes over the ${tier} tier's memory (OF10c1a: name a larger tier or shrink the runtime)${severity === 'warning' ? ratchetNote(source.identity?.slug
|
|
45
|
+
metric: `runtime accounted bytes over the ${tier} tier's memory (OF10c1a: name a larger tier or shrink the runtime)${severity === 'warning' ? ratchetNote(source.identity?.slug) : ''}`,
|
|
46
46
|
actual,
|
|
47
47
|
limit,
|
|
48
48
|
severity,
|
|
@@ -18,6 +18,8 @@ const positive = v.pipe(ShardNaturalSchema, v.minValue(1));
|
|
|
18
18
|
/** Finite wire number without an imposed gameplay range. */
|
|
19
19
|
export const ShardFiniteSchema: v.GenericSchema<ShardFiniteInput, ShardFinite> = v.pipe(v.number(), v.finite());
|
|
20
20
|
const name = v.pipe(v.string(), v.regex(/^[a-z][a-z0-9.-]*$/u), v.maxLength(limits.idCharacters));
|
|
21
|
+
/** A tick's time, in microseconds: at most one 60 Hz frame. */
|
|
22
|
+
const tickMicros = v.pipe(positive, v.maxValue(16_666));
|
|
21
23
|
/** Local SHA256 content identity. */
|
|
22
24
|
export const ShardHashSchema: v.GenericSchema<ShardHashInput, ShardHash> = v.pipe(v.string(), v.regex(/^[a-f0-9]{64}$/u));
|
|
23
25
|
/** Local or commons-qualified SHA256 content reference. */
|
|
@@ -50,7 +52,7 @@ export const SimSchema: v.GenericSchema<ShardSimInput, ShardSim> = v.strictObjec
|
|
|
50
52
|
/** Bounded player count and authored movement speed. */
|
|
51
53
|
export const AuthorCapsSchema: v.GenericSchema<ShardAuthorCapsInput, ShardAuthorCaps> = v.strictObject({ players: v.pipe(positive, v.maxValue(32)), speed: v.pipe(ShardFiniteSchema, v.minValue(0), v.maxValue(15)) });
|
|
52
54
|
/** Bounded authoritative simulation resource declarations. */
|
|
53
|
-
export const ServerBudgetSchema: v.GenericSchema<ShardServerBudgetInput, ShardServerBudget> = v.strictObject({ tickMicros
|
|
55
|
+
export const ServerBudgetSchema: v.GenericSchema<ShardServerBudgetInput, ShardServerBudget> = v.strictObject({ tickMicros, memory: positive, entities: v.pipe(ShardNaturalSchema, v.maxValue(10_000)), commandsPerTick: v.pipe(ShardNaturalSchema, v.maxValue(1024)), awakeMicros: v.exactOptional(tickMicros), shareWorker: v.exactOptional(name) });
|
|
54
56
|
/** Content-addressed file inventory and conservative costs. */
|
|
55
57
|
export const FilesSchema: v.GenericSchema<ShardFilesInput, ShardFiles> & { readonly pipe: readonly [v.ArraySchema<typeof file, undefined>, unknown] } = v.pipe(v.array(file), v.maxLength(limits.files));
|
|
56
58
|
/** Finite L0/L1 tile inventory. */
|
|
@@ -299,6 +301,10 @@ interface ShardServerBudgetInputFields {
|
|
|
299
301
|
memory: ShardNaturalInput;
|
|
300
302
|
entities: ShardNaturalInput;
|
|
301
303
|
commandsPerTick: ShardNaturalInput;
|
|
304
|
+
/** ONE-FORMAT OF31h2: the measured awake cost, mean microseconds a tick with one player in; the server weighs its workers by it. */
|
|
305
|
+
awakeMicros?: ShardNaturalInput;
|
|
306
|
+
/** OF31h2: the shard whose worker this one always shares. */
|
|
307
|
+
shareWorker?: string;
|
|
302
308
|
}
|
|
303
309
|
export type ShardServerBudgetInput = { [Key in keyof ShardServerBudgetInputFields]: ShardServerBudgetInputFields[Key] };
|
|
304
310
|
interface ShardServerBudgetFields {
|
|
@@ -306,6 +312,10 @@ interface ShardServerBudgetFields {
|
|
|
306
312
|
memory: ShardNatural;
|
|
307
313
|
entities: ShardNatural;
|
|
308
314
|
commandsPerTick: ShardNatural;
|
|
315
|
+
/** ONE-FORMAT OF31h2: the measured awake cost, mean microseconds a tick with one player in; the server weighs its workers by it. */
|
|
316
|
+
awakeMicros?: ShardNatural;
|
|
317
|
+
/** OF31h2: the shard whose worker this one always shares. */
|
|
318
|
+
shareWorker?: string;
|
|
309
319
|
}
|
|
310
320
|
export type ShardServerBudget = { [Key in keyof ShardServerBudgetFields]: ShardServerBudgetFields[Key] };
|
|
311
321
|
export type ShardFilesInput = (ShardFileRowsInput)[];
|