@wildshard/shard-format 0.70.0 → 0.71.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 +15 -3
- package/src/cli/corpus-candidate.ts +228 -0
- package/src/cli/corpus-command.ts +32 -3
- package/src/cli/corpus-pins.ts +73 -0
- package/src/cli/corpus-report.ts +36 -0
- package/src/cli/corpus-tar.ts +28 -0
- package/src/cli/corpus-usage.ts +24 -3
- package/src/cli/corpus.ts +50 -68
- package/src/cli/format-diff-range.ts +112 -0
- package/src/cli/main.ts +39 -9
- package/src/cli/pack.ts +20 -3
- package/src/cli/validate.ts +1 -1
- package/src/format/clientOwnership.ts +1 -1
- package/src/format/clientTrails.ts +121 -46
- package/src/format/cook-deprecations.ts +53 -0
- package/src/format/cook-preparation.ts +2 -1
- package/src/format/creature-rest-rig.ts +248 -0
- package/src/format/creature-skin-bounds.ts +146 -0
- package/src/format/deprecations.ts +18 -21
- package/src/format/edge-observations.ts +67 -0
- package/src/format/empty-shardfile.ts +4 -2
- package/src/format/entry-read-set.ts +147 -0
- package/src/format/format-migrate-rebuild.ts +4 -1
- package/src/format/format-migrate.ts +7 -1
- package/src/format/format-migration-envelope.ts +19 -0
- package/src/format/format-migration-prune.ts +42 -1
- package/src/format/format-migrations.ts +8 -1
- package/src/format/format-window.ts +71 -0
- package/src/format/immutable.ts +4 -1
- package/src/format/json-schema.ts +1468 -0
- package/src/format/lootEconomy.ts +4 -1
- package/src/format/mat4.ts +225 -0
- package/src/format/memory-armed.json +1 -9
- package/src/format/memory-armed.ts +46 -17
- package/src/format/memory-epoch.ts +10 -3
- package/src/format/memory-line.ts +17 -6
- package/src/format/outputFields.ts +3 -2
- package/src/format/outputIndex.ts +14 -1
- package/src/format/platformDataSections.ts +5 -0
- package/src/format/platformFileFamilies.ts +3 -3
- package/src/format/play-area.ts +95 -0
- package/src/format/policy-verdict.ts +12 -2
- package/src/format/registeredJson.ts +2 -2
- package/src/format/runtime-tier.ts +14 -7
- package/src/format/save-revision.ts +105 -0
- package/src/format/schema-source.ts +70 -0
- package/src/format/sections.ts +4 -1
- package/src/format/server-plan.ts +42 -0
- package/src/format/server-reads.ts +23 -0
- package/src/format/shardSchema.ts +9 -4
- package/src/format/shardSections.ts +17 -7
- package/src/format/shardfile-assets.ts +5 -5
- package/src/format/shardfile-stream-admit.ts +19 -10
- package/src/format/shardfile-stream-facts.ts +2 -1
- package/src/format/shardfile-stream.ts +2 -3
- package/src/format/shardfileValidation.ts +16 -9
- package/src/format/species-deprecations.ts +79 -0
- package/src/format/stateLineage.ts +12 -6
- package/src/format/tread-boxes.ts +65 -0
- package/src/format/vehicle-hulls.ts +124 -0
- package/src/format/version.ts +74 -17
- package/src/format/whole-inputs.ts +51 -0
- package/src/tools/runtime-hosts.json +4 -0
|
@@ -11,17 +11,17 @@ import {
|
|
|
11
11
|
import { issueError, withIssueCode } from './issue-codes.ts'
|
|
12
12
|
import { assembleOutputShardfile } from './outputIndex.ts'
|
|
13
13
|
import { admittedVerdict, recordVerdict } from './policy-verdict.ts'
|
|
14
|
+
import { writtenSourceBytes } from './save-revision.ts'
|
|
14
15
|
import { offlineMemoryAdmission } from './shardfile-assets.ts'
|
|
15
16
|
import {
|
|
16
17
|
assertShardfileTargets,
|
|
17
18
|
checkWorldTargets,
|
|
18
19
|
} from './shardfileValidation.ts'
|
|
19
20
|
import { parseShardfile } from './shardSchema.ts'
|
|
20
|
-
import { validationSourceBytes } from './validationReceipt.ts'
|
|
21
21
|
|
|
22
22
|
import type { AssetAdmission } from './assetAdmission.ts'
|
|
23
23
|
import type { OutputIndex } from './outputIndex.ts'
|
|
24
|
-
import type { Judged, PolicyVerdict } from './policy-verdict.ts'
|
|
24
|
+
import type { Judged, JudgedPorts, PolicyVerdict } from './policy-verdict.ts'
|
|
25
25
|
import type { ScriptAdmissionRows } from './scriptContract.ts'
|
|
26
26
|
import type { AssetPasses } from './shardfile-stream-assets.ts'
|
|
27
27
|
import type { Shardfile } from './shardSchema.ts'
|
|
@@ -31,13 +31,14 @@ function admitHead(
|
|
|
31
31
|
// oxlint-disable-next-line typescript/prefer-readonly-parameter-types -- valibot's output type, only read
|
|
32
32
|
index: OutputIndex,
|
|
33
33
|
payloads: ReadonlyMap<string, unknown>,
|
|
34
|
-
|
|
34
|
+
policy: Readonly<JudgedPorts>,
|
|
35
35
|
): Shardfile {
|
|
36
|
+
const { judged = 'upload', armed } = policy
|
|
36
37
|
const shard = withIssueCode('shard-schema', (): Shardfile =>
|
|
37
38
|
parseShardfile(assembleOutputShardfile(index, payloads), payloads),
|
|
38
39
|
)
|
|
39
40
|
withIssueCode('declared-costs', (): void => {
|
|
40
|
-
preflightDeclaredCosts(shard, offlineMemoryAdmission('warn', judged))
|
|
41
|
+
preflightDeclaredCosts(shard, offlineMemoryAdmission('warn', judged, armed))
|
|
41
42
|
})
|
|
42
43
|
const verdict = withIssueCode('performance-targets', (): PolicyVerdict =>
|
|
43
44
|
// MG6 epoch 5: the index lets the estimate count only the files a phone fetches (no mount bytes in the stream).
|
|
@@ -46,6 +47,7 @@ function admitHead(
|
|
|
46
47
|
mountedImages: 0,
|
|
47
48
|
index,
|
|
48
49
|
judged,
|
|
50
|
+
armed,
|
|
49
51
|
}),
|
|
50
52
|
)
|
|
51
53
|
return recordVerdict(shard, verdict)
|
|
@@ -58,21 +60,26 @@ function admitBeforeAssets(
|
|
|
58
60
|
index: OutputIndex,
|
|
59
61
|
payloads: ReadonlyMap<string, unknown>,
|
|
60
62
|
// oxlint-disable-next-line typescript/prefer-readonly-parameter-types -- format's row type, only read
|
|
61
|
-
rows: Readonly<{
|
|
63
|
+
rows: Readonly<{
|
|
64
|
+
scripts: ScriptAdmissionRows
|
|
65
|
+
judged?: Judged | undefined
|
|
66
|
+
armed?: boolean | ReadonlySet<string> | undefined
|
|
67
|
+
}>,
|
|
62
68
|
): Readonly<{
|
|
63
69
|
admission: AssetAdmission | undefined
|
|
64
70
|
refusal: unknown
|
|
65
71
|
head?: Shardfile | undefined
|
|
66
72
|
judged?: Judged | undefined
|
|
73
|
+
armed?: boolean | ReadonlySet<string> | undefined
|
|
67
74
|
}> {
|
|
68
|
-
const { scripts, judged } = rows
|
|
75
|
+
const { scripts, judged, armed } = rows
|
|
69
76
|
try {
|
|
70
|
-
const head = admitHead(index, payloads, judged)
|
|
77
|
+
const head = admitHead(index, payloads, { judged, armed })
|
|
71
78
|
return {
|
|
72
79
|
admission: withIssueCode('asset-admission', (): AssetAdmission =>
|
|
73
80
|
assetAdmission(
|
|
74
81
|
head,
|
|
75
|
-
offlineMemoryAdmission('warn', judged),
|
|
82
|
+
offlineMemoryAdmission('warn', judged, armed),
|
|
76
83
|
scripts,
|
|
77
84
|
payloads,
|
|
78
85
|
),
|
|
@@ -80,6 +87,7 @@ function admitBeforeAssets(
|
|
|
80
87
|
refusal: undefined,
|
|
81
88
|
head,
|
|
82
89
|
judged,
|
|
90
|
+
armed,
|
|
83
91
|
}
|
|
84
92
|
} catch (error) {
|
|
85
93
|
return { admission: undefined, refusal: error }
|
|
@@ -94,6 +102,7 @@ function admitAssets(
|
|
|
94
102
|
refusal: unknown
|
|
95
103
|
head?: Shardfile | undefined
|
|
96
104
|
judged?: Judged | undefined
|
|
105
|
+
armed?: boolean | ReadonlySet<string> | undefined
|
|
97
106
|
}>,
|
|
98
107
|
later: Readonly<AssetPasses>,
|
|
99
108
|
hash: (bytes: Readonly<Uint8Array>) => string,
|
|
@@ -114,7 +123,7 @@ function admitAssets(
|
|
|
114
123
|
admitAfterFiles(
|
|
115
124
|
admission,
|
|
116
125
|
later.assets,
|
|
117
|
-
offlineMemoryAdmission('warn', before.judged),
|
|
126
|
+
offlineMemoryAdmission('warn', before.judged, before.armed),
|
|
118
127
|
),
|
|
119
128
|
admittedVerdict(head),
|
|
120
129
|
)
|
|
@@ -134,7 +143,7 @@ function admitTail(
|
|
|
134
143
|
): void {
|
|
135
144
|
checkWorldTargets(shard, product.payloads.get('world/targets'))
|
|
136
145
|
if (
|
|
137
|
-
product.hash(
|
|
146
|
+
product.hash(writtenSourceBytes(shard, product.index.formatVersion)) !==
|
|
138
147
|
product.index.build.sourceHash
|
|
139
148
|
) {
|
|
140
149
|
throw issueError(
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
registeredJsonContract,
|
|
13
13
|
validateRegisteredJson,
|
|
14
14
|
} from './registeredJson.ts'
|
|
15
|
+
import { currentSchemaSource } from './schema-source.ts'
|
|
15
16
|
import { assetCost } from './shardfile-assets.ts'
|
|
16
17
|
import { outputBlobExtension, outputBlobKind } from './shardfileValidation.ts'
|
|
17
18
|
import { validationSourceBytes } from './validationReceipt.ts'
|
|
@@ -140,7 +141,7 @@ function inspectRegistered(file: OutputFile, member: FactsMember): void {
|
|
|
140
141
|
'Unregistered named JSON with a schema needs a JSON Schema checker',
|
|
141
142
|
)
|
|
142
143
|
}
|
|
143
|
-
if (file.jsonSchema['$comment'] !== contract.source) {
|
|
144
|
+
if (currentSchemaSource(file.jsonSchema['$comment']) !== contract.source) {
|
|
144
145
|
throw new Error(
|
|
145
146
|
'Registered JSON requires its exact defining format contract',
|
|
146
147
|
)
|
|
@@ -39,7 +39,7 @@ import { readCanonicalJson } from './shardfileValidation.ts'
|
|
|
39
39
|
|
|
40
40
|
import type { DeprecationReport } from './deprecations.ts'
|
|
41
41
|
import type { OutputIndex } from './outputIndex.ts'
|
|
42
|
-
import type {
|
|
42
|
+
import type { JudgedPorts, PolicyVerdict } from './policy-verdict.ts'
|
|
43
43
|
import type { ScriptAdmissionRows } from './scriptContract.ts'
|
|
44
44
|
import type { StoredSource } from './shardfile-stream-assets.ts'
|
|
45
45
|
import type { KeptMember, Replay } from './shardfile-stream-rows.ts'
|
|
@@ -51,7 +51,7 @@ import type {
|
|
|
51
51
|
import type { Shardfile } from './shardSchema.ts'
|
|
52
52
|
|
|
53
53
|
/** The host services a streaming validation needs. */
|
|
54
|
-
interface StreamValidationPorts {
|
|
54
|
+
interface StreamValidationPorts extends JudgedPorts {
|
|
55
55
|
/** Lowercase hex SHA-256 of exact bytes. */
|
|
56
56
|
readonly hash: (bytes: Readonly<Uint8Array>) => string
|
|
57
57
|
/** A fresh incremental SHA-256. */
|
|
@@ -60,7 +60,6 @@ interface StreamValidationPorts {
|
|
|
60
60
|
readonly decode?: (
|
|
61
61
|
stored: AsyncIterable<Uint8Array>,
|
|
62
62
|
) => AsyncIterable<Uint8Array>
|
|
63
|
-
readonly judged?: Judged
|
|
64
63
|
}
|
|
65
64
|
|
|
66
65
|
/** What one streaming validation found. */
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { cookMountPath, readCookData } from './cook-data.ts';
|
|
2
2
|
import { requireCookPreparation } from './cook-preparation.ts';
|
|
3
3
|
import { parseOutputIndex, validateOutputSection, assembleOutputShardfile, type OutputFile, type OutputIndex } from './outputIndex.ts';
|
|
4
|
+
import { asWrittenIdentity } from './save-revision.ts';
|
|
4
5
|
import { decisionModuleContracts, scriptAdmissionRows, type ScriptAdmissionRows, type ScriptContract } from './scriptContract.ts';
|
|
5
6
|
import { registeredJsonContract, validateRegisteredJson } from './registeredJson.ts';
|
|
6
7
|
import { validatePlatformFile } from './platformFileFamilies.ts';
|
|
@@ -22,12 +23,14 @@ import type { RecordingMeasure } from './audio-measure.ts';
|
|
|
22
23
|
import { issueError, withIssueCode as coded } from './issue-codes.ts';
|
|
23
24
|
import { staleRuntimeIssues } from './memory-epoch.ts';
|
|
24
25
|
import { memoryContext, offlineMemoryIssues } from './memory-line.ts';
|
|
26
|
+
import { armedZone } from './memory-armed.ts';
|
|
25
27
|
import { runtimeTierIssues } from './runtime-tier.ts';
|
|
26
28
|
import type { MemoryContext } from './memory-line.ts';
|
|
27
29
|
import { mountedImageBytes, NO_BYTES } from './boot-memory-cost.ts';
|
|
28
30
|
import { admittedVerdict, policyVerdict, recordVerdict } from './policy-verdict.ts';
|
|
29
31
|
import type { Judged, PolicyVerdict } from './policy-verdict.ts';
|
|
30
32
|
import { deprecationReport } from './deprecations.ts';
|
|
33
|
+
import { currentSchemaSource } from './schema-source.ts';
|
|
31
34
|
import type { DeprecationReport } from './deprecations.ts';
|
|
32
35
|
|
|
33
36
|
/**
|
|
@@ -61,6 +64,9 @@ export interface ShardfileValidationPorts {
|
|
|
61
64
|
/** SHARD-COMPAT CP10: `'stored'` for a shard file already admitted (a stored original, an engine pin, a cook): memory
|
|
62
65
|
* and budget policy only reports, since it was judged at upload. Default `'upload'`: the policy refuses. */
|
|
63
66
|
readonly judged?: Judged;
|
|
67
|
+
/** FORMAT-PRUNE FP27b: whether the API catalogue arms this shard (`/api/catalogue` `armed`). Admission passes it; absent,
|
|
68
|
+
* the format's own armed list decides until FP27c removes it. */
|
|
69
|
+
readonly armed?: boolean | ReadonlySet<string> | undefined;
|
|
64
70
|
/** D31: hold no file's bytes between checks. `assets`, here and in the result, reads each file again from `files`, so a
|
|
65
71
|
* host's peak is its largest file rather than the shard, at the cost of those repeat reads. */
|
|
66
72
|
readonly readThrough?: boolean;
|
|
@@ -124,20 +130,21 @@ export function outputBlobExtension(kind: OutputFile['kind'], bytes: Uint8Array)
|
|
|
124
130
|
* A stored shard file (CP10, the context's `judged`) is never refused here: it was judged at its upload. */
|
|
125
131
|
export function assertShardfileTargets(source: Shardfile, policy: 'warn' | 'refuse', context: MemoryContext = new Map()): PolicyVerdict {
|
|
126
132
|
// J412: the memory gates are ratchets; an issue in a zone not armed reports (`memory-armed.ts`) and is not thrown here.
|
|
127
|
-
const
|
|
133
|
+
const { armed } = memoryContext(context);
|
|
134
|
+
const found = [...staleRuntimeIssues(source.runtime, undefined, { ...source.identity, armed }), ...offlineMemoryIssues(source, context), ...runtimeTierIssues(source, armed), ...performanceTargetIssues(source, policy)];
|
|
128
135
|
const issues = found.filter(issue => issue.severity === 'refusal'), judged = memoryContext(context).judged ?? 'upload';
|
|
129
136
|
if (issues.length > 0 && judged === 'upload') throw issueError('performance-targets', issues.map(issue => `REFUSAL: ${issue.metric}: ${issue.actual} > ${issue.limit}`).join('\n'));
|
|
130
|
-
return policyVerdict(source.identity.slug, judged, found);
|
|
137
|
+
return policyVerdict(armedZone(source.identity.slug, armed), judged, found);
|
|
131
138
|
}
|
|
132
139
|
|
|
133
140
|
/** Admit a whole shardfile's declared costs and its actual immutable bytes through the defining contracts. */
|
|
134
141
|
export function admitShardfileFolder(input: unknown, assets: ReadonlyMap<string, Uint8Array>, hash: (bytes: Uint8Array) => string,
|
|
135
142
|
policy: 'warn' | 'refuse' = 'refuse', scripts: ScriptAdmissionRows = [], context?: MemoryContext): Shardfile {
|
|
136
|
-
const { sections, judged } = context === undefined ? { sections: undefined, judged: undefined } : memoryContext(context);
|
|
143
|
+
const { sections, judged, armed } = context === undefined ? { sections: undefined, judged: undefined, armed: undefined } : memoryContext(context);
|
|
137
144
|
const source = coded('shard-schema', (): Shardfile => parseShardfile(input, sections));
|
|
138
|
-
coded('declared-costs', (): void => { preflightDeclaredCosts(source, offlineMemoryAdmission(policy, judged)); });
|
|
145
|
+
coded('declared-costs', (): void => { preflightDeclaredCosts(source, offlineMemoryAdmission(policy, judged, armed)); });
|
|
139
146
|
const verdict = coded('performance-targets', (): PolicyVerdict => assertShardfileTargets(source, policy, context));
|
|
140
|
-
return recordVerdict(coded('asset-admission', (): Shardfile => validateShardfileAssets(source, assets, hash, offlineMemoryAdmission(policy, judged), undefined, scripts, sections)), verdict);
|
|
147
|
+
return recordVerdict(coded('asset-admission', (): Shardfile => validateShardfileAssets(source, assets, hash, offlineMemoryAdmission(policy, judged, armed), undefined, scripts, sections)), verdict);
|
|
141
148
|
}
|
|
142
149
|
|
|
143
150
|
/** Refuse world target rows that name items or quests the shardfile does not declare. */
|
|
@@ -154,7 +161,7 @@ function inspectBlob(file: OutputFile, bytes: Uint8Array, ports: ShardfileValida
|
|
|
154
161
|
if (ports.definedJson !== undefined) ports.definedJson(validationSourceBytes(file.jsonSchema), bytes, file.name);
|
|
155
162
|
else if (contract === undefined || file.name === undefined) throw new Error('Unregistered named JSON with a schema needs a JSON Schema checker');
|
|
156
163
|
else {
|
|
157
|
-
if (file.jsonSchema['$comment'] !== contract.source) throw new Error('Registered JSON requires its exact defining format contract');
|
|
164
|
+
if (currentSchemaSource(file.jsonSchema['$comment']) !== contract.source) throw new Error('Registered JSON requires its exact defining format contract');
|
|
158
165
|
validateRegisteredJson(file.name, parseNamedJson(bytes));
|
|
159
166
|
}
|
|
160
167
|
}
|
|
@@ -250,8 +257,8 @@ export function validateShardfileFolder(files: ShardfileFiles, ports: ShardfileV
|
|
|
250
257
|
coded('runtime-files', (): void => { ports.runtimeImports?.(entry.path, decoder().decode(read(entry))); });
|
|
251
258
|
}
|
|
252
259
|
for (const path of files.paths()) if (!listed.has(path)) throw issueError('unlisted-file', `Unlisted output file: ${path}`);
|
|
253
|
-
const shard = admitShardfileFolder(coded('shard-schema', (): unknown => assembleOutputShardfile(index, payloads)), assets, ports.hash, 'warn', scripts, { sections: payloads, mountedImages, index, judged: ports.judged ?? 'upload' });
|
|
260
|
+
const shard = admitShardfileFolder(coded('shard-schema', (): unknown => assembleOutputShardfile(index, payloads)), assets, ports.hash, 'warn', scripts, { sections: payloads, mountedImages, index, judged: ports.judged ?? 'upload', armed: ports.armed });
|
|
254
261
|
checkWorldTargets(shard, payloads.get('world/targets'));
|
|
255
|
-
if (ports.hash(validationSourceBytes(shard)) !== index.build.sourceHash) throw issueError('source-hash', 'Output sections differ from the declared source hash');
|
|
256
|
-
return { index, shard, assets, sections: payloads, scripts, ...deprecationReport({ index, sections: payloads }, warnings), policy: admittedVerdict(shard), audio: shardfileRecordings({ cook, read: files.read, shard, assets }) };
|
|
262
|
+
if (ports.hash(validationSourceBytes(asWrittenIdentity(shard, index.formatVersion))) !== index.build.sourceHash) throw issueError('source-hash', 'Output sections differ from the declared source hash');
|
|
263
|
+
return { index, shard, assets, sections: payloads, scripts, ...deprecationReport({ index, sections: payloads, cook }, warnings), policy: admittedVerdict(shard), audio: shardfileRecordings({ cook, read: files.read, shard, assets }) };
|
|
257
264
|
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/** FORMAT-PRUNE FP15: the species-program family's page features. OF30's cut B leaves the `species.program` client row
|
|
2
|
+
* and the `population.product-creatures` and `population.hull-book` plan features reading only what the family's
|
|
3
|
+
* sections held; each creature is a declared row now (ONE-FORMAT OF5b2b). The sections themselves are FE7 rows in
|
|
4
|
+
* `deprecations.ts`. No data migration exists: a shard drops the feature when it re-uploads (Track F), and FP20 deletes
|
|
5
|
+
* it at zero users. `legacyKinds` sits inside `actors/species-programs`, so that section's row counts it. */
|
|
6
|
+
|
|
7
|
+
/** The registry's row shape (`deprecations.ts`). */
|
|
8
|
+
interface SpeciesFeatureDeprecation {
|
|
9
|
+
readonly id: string
|
|
10
|
+
readonly path: string
|
|
11
|
+
readonly since: string
|
|
12
|
+
readonly replacement: string
|
|
13
|
+
readonly migration: undefined
|
|
14
|
+
readonly uses: (
|
|
15
|
+
shard: Readonly<{ sections: ReadonlyMap<string, unknown> }>,
|
|
16
|
+
) => boolean
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** The sections a page feature row can sit in. */
|
|
20
|
+
const FEATURE_SECTIONS: readonly string[] = ['client/plan', 'sim/runtime-plan']
|
|
21
|
+
const NONE = 0
|
|
22
|
+
|
|
23
|
+
/** Whether any object under `value` is a row of `kind`. */
|
|
24
|
+
function hasKind(value: unknown, kind: string): boolean {
|
|
25
|
+
const pending: unknown[] = [value]
|
|
26
|
+
while (pending.length > NONE) {
|
|
27
|
+
const next = pending.pop()
|
|
28
|
+
if (typeof next === 'object' && next !== null) {
|
|
29
|
+
if (!Array.isArray(next) && Reflect.get(next, 'kind') === kind) {
|
|
30
|
+
return true
|
|
31
|
+
}
|
|
32
|
+
const children: readonly unknown[] = Object.values(next)
|
|
33
|
+
pending.push(...children)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return false
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function featureRow(kind: string): SpeciesFeatureDeprecation {
|
|
40
|
+
return {
|
|
41
|
+
id: `feature.${kind}`,
|
|
42
|
+
path: `client/plan or sim/runtime-plan rows of kind ${kind} (the species-program family, FORMAT-PRUNE FP15)`,
|
|
43
|
+
since: '0.1.0.4',
|
|
44
|
+
replacement:
|
|
45
|
+
'declared creature rows (actors/creatures and their looks); the engine draws each from its row',
|
|
46
|
+
migration: undefined,
|
|
47
|
+
uses: (
|
|
48
|
+
shard: Readonly<{ sections: ReadonlyMap<string, unknown> }>,
|
|
49
|
+
): boolean =>
|
|
50
|
+
FEATURE_SECTIONS.some((name: string): boolean =>
|
|
51
|
+
hasKind(shard.sections.get(name), kind),
|
|
52
|
+
),
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** OF30 cut B leaves these sections as plain JSON nothing reads. Deprecated at 0.1.0.1 (format `cda6f63`). */
|
|
57
|
+
const SPECIES_SECTION_DEPRECATIONS: readonly SpeciesFeatureDeprecation[] = [
|
|
58
|
+
'actors/species-programs',
|
|
59
|
+
'look/hull-book',
|
|
60
|
+
'look/rigged-hulls',
|
|
61
|
+
].map((name: string): SpeciesFeatureDeprecation => ({
|
|
62
|
+
id: `section.${name}`,
|
|
63
|
+
path: `sections/${name} (the species-program family, FORMAT-PRUNE FP15)`,
|
|
64
|
+
since: '0.1.0.1',
|
|
65
|
+
replacement:
|
|
66
|
+
'species rows and authored looks (actors/species); nothing reads it once OF30 lands',
|
|
67
|
+
migration: undefined,
|
|
68
|
+
uses: (
|
|
69
|
+
shard: Readonly<{ sections: ReadonlyMap<string, unknown> }>,
|
|
70
|
+
): boolean => shard.sections.has(name),
|
|
71
|
+
}))
|
|
72
|
+
|
|
73
|
+
const SPECIES_FEATURE_DEPRECATIONS: readonly SpeciesFeatureDeprecation[] = [
|
|
74
|
+
featureRow('species.program'),
|
|
75
|
+
featureRow('population.product-creatures'),
|
|
76
|
+
featureRow('population.hull-book'),
|
|
77
|
+
]
|
|
78
|
+
|
|
79
|
+
export { SPECIES_FEATURE_DEPRECATIONS, SPECIES_SECTION_DEPRECATIONS }
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
2
|
import { assertMigrationCompatibility } from './migrations.ts';
|
|
3
3
|
import { StateSchema } from './state.ts';
|
|
4
|
+
import { oneSaveRevisionSpelling, saveRevisionOf } from './save-revision.ts';
|
|
4
5
|
import type { Shardfile } from './shardSchema.ts';
|
|
5
6
|
import { isJsonDataWithFileSchemas } from './json.ts';
|
|
6
7
|
import { IndexFormatVersionSchema, LegacyIndexVersionSchema } from './index-format-version.ts';
|
|
7
8
|
import { SHARDFILE_ADMISSION_LIMITS as limits } from './admissionLimits.ts';
|
|
8
9
|
|
|
9
|
-
const
|
|
10
|
-
|
|
10
|
+
const lineageRevision = v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(Number.MAX_SAFE_INTEGER));
|
|
11
|
+
// FORMAT-PRUNE FP26: a cached product of format 0.1.0.3 or older spells the save lineage `revision`; both read as `saveRevision`.
|
|
12
|
+
const identityRow = v.object({ slug: v.pipe(v.string(), v.regex(/^[a-z][a-z0-9.-]*$/u)),
|
|
13
|
+
saveRevision: v.exactOptional(lineageRevision), revision: v.exactOptional(lineageRevision) });
|
|
14
|
+
function lineageIdentity(row: Readonly<v.InferOutput<typeof identityRow>>): StateLineage['identity'] { return { slug: row.slug, saveRevision: saveRevisionOf(row) }; }
|
|
15
|
+
const identity = v.pipe(identityRow, v.check(oneSaveRevisionSpelling, 'State lineage needs exactly one of saveRevision or revision'), v.transform(lineageIdentity));
|
|
11
16
|
const lineage: v.GenericSchema<StateLineageInput, StateLineage> = v.object({ identity, state: StateSchema });
|
|
12
17
|
|
|
13
18
|
/** Read only strict portable state and identity from a previously visited product. Its legacy geometry and scripts remain unadmitted. */
|
|
@@ -26,7 +31,7 @@ const inventory = v.object({ format: v.literal('wildshard.shardfile'), formatVer
|
|
|
26
31
|
schema: v.pipe(v.string(), v.maxLength(240)) })), v.maxLength(256)),
|
|
27
32
|
schemas: lineageSchemas });
|
|
28
33
|
export interface OutputLineageIndex {
|
|
29
|
-
readonly identity: { readonly slug: string; readonly
|
|
34
|
+
readonly identity: { readonly slug: string; readonly saveRevision: number };
|
|
30
35
|
readonly sections: readonly { readonly path: string; readonly hash: string; readonly bytes: number; readonly name: string; readonly schema: string }[];
|
|
31
36
|
readonly schemas: readonly { readonly path: string; readonly hash: string; readonly bytes: number }[];
|
|
32
37
|
}
|
|
@@ -52,7 +57,7 @@ export function parseOutputLineageIndex(input: unknown): OutputLineageIndex {
|
|
|
52
57
|
/** Preserve saved field identities across validated author revisions; declaration ordering is immaterial. */
|
|
53
58
|
export function assertStateCompatibility(previous: StateLineage, next: Shardfile): void {
|
|
54
59
|
v.parse(v.literal(previous.identity.slug, 'State revisions must name the same shard'), next.identity.slug);
|
|
55
|
-
if (next.identity.
|
|
60
|
+
if (next.identity.saveRevision < previous.identity.saveRevision) throw new Error('State revisions cannot move backwards');
|
|
56
61
|
assertMigrationCompatibility(previous.state, next.state, next.migrations);
|
|
57
62
|
}
|
|
58
63
|
|
|
@@ -61,7 +66,8 @@ export function assertStateCompatibility(previous: StateLineage, next: Shardfile
|
|
|
61
66
|
interface StateLineageInputFields {
|
|
62
67
|
identity: {
|
|
63
68
|
slug: string;
|
|
64
|
-
|
|
69
|
+
saveRevision?: number;
|
|
70
|
+
revision?: number;
|
|
65
71
|
};
|
|
66
72
|
state: v.InferInput<typeof StateSchema>;
|
|
67
73
|
}
|
|
@@ -69,7 +75,7 @@ export type StateLineageInput = { [Key in keyof StateLineageInputFields]: StateL
|
|
|
69
75
|
interface StateLineageFields {
|
|
70
76
|
identity: {
|
|
71
77
|
slug: string;
|
|
72
|
-
|
|
78
|
+
saveRevision: number;
|
|
73
79
|
};
|
|
74
80
|
state: v.InferOutput<typeof StateSchema>;
|
|
75
81
|
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/* oxlint-disable id-length, import/group-exports, max-statements, no-magic-numbers, no-plusplus -- a port of engine's treadBoxes kept term for term (SHARD-COMPAT PR6b), so the boxes match engine's byte for byte */
|
|
2
|
+
// SHARD-COMPAT PR6b (J487): a stair's `treads` collider as the solid boxes physics installs, one per tread from the
|
|
3
|
+
// stair's foot up to that tread's top, with format code only. Moved from engine
|
|
4
|
+
// `src/shared/engine/physics/pieces.ts` `treadBoxes`; the material (surface, friction, groups) rides on every box.
|
|
5
|
+
|
|
6
|
+
interface Point {
|
|
7
|
+
readonly x: number
|
|
8
|
+
readonly y: number
|
|
9
|
+
readonly z: number
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** A `treads` shape as props declare it, with whatever contact fields it carries. */
|
|
13
|
+
export interface TreadShape {
|
|
14
|
+
readonly from: Point
|
|
15
|
+
readonly to: Point
|
|
16
|
+
readonly width: number
|
|
17
|
+
readonly count: number
|
|
18
|
+
readonly surface?: string
|
|
19
|
+
readonly friction?: number
|
|
20
|
+
readonly groups?: number
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** One tread's solid block: centre, half extents and yaw, plus the stair's material. */
|
|
24
|
+
export interface TreadBox {
|
|
25
|
+
readonly kind: 'box'
|
|
26
|
+
readonly x: number
|
|
27
|
+
readonly y: number
|
|
28
|
+
readonly z: number
|
|
29
|
+
readonly hx: number
|
|
30
|
+
readonly hy: number
|
|
31
|
+
readonly hz: number
|
|
32
|
+
readonly yaw: number
|
|
33
|
+
readonly surface?: string
|
|
34
|
+
readonly friction?: number
|
|
35
|
+
readonly groups?: number
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** One tread of a stair: a solid block from the stair's foot up to this tread's top. */
|
|
39
|
+
export function treadBoxes(d: TreadShape): TreadBox[] {
|
|
40
|
+
const dx = d.to.x - d.from.x
|
|
41
|
+
const dz = d.to.z - d.from.z
|
|
42
|
+
const run = Math.hypot(dx, dz) / d.count
|
|
43
|
+
const rise = (d.to.y - d.from.y) / d.count
|
|
44
|
+
const yaw = Math.atan2(dx, dz)
|
|
45
|
+
const out: TreadBox[] = []
|
|
46
|
+
for (let i = 0; i < d.count; i++) {
|
|
47
|
+
const f = (i + 0.5) / d.count
|
|
48
|
+
const top = d.from.y + rise * (i + 1)
|
|
49
|
+
const hy = Math.max(0.01, (top - d.from.y) / 2)
|
|
50
|
+
out.push({
|
|
51
|
+
kind: 'box',
|
|
52
|
+
x: d.from.x + dx * f,
|
|
53
|
+
y: d.from.y + hy,
|
|
54
|
+
z: d.from.z + dz * f,
|
|
55
|
+
hx: d.width / 2,
|
|
56
|
+
hy,
|
|
57
|
+
hz: run / 2,
|
|
58
|
+
yaw,
|
|
59
|
+
...(d.surface === undefined ? {} : { surface: d.surface }),
|
|
60
|
+
...(d.friction === undefined ? {} : { friction: d.friction }),
|
|
61
|
+
...(d.groups === undefined ? {} : { groups: d.groups }),
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
return out
|
|
65
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/* oxlint-disable capitalized-comments, id-length, max-lines-per-function, no-continue, no-implicit-coercion, no-magic-numbers, oxc/erasing-op, typescript/explicit-function-return-type, typescript/prefer-readonly-parameter-types, unicorn/prefer-modern-math-apis -- three.js 0.186's Quaternion and Vector3 steps ported term for term (SHARD-COMPAT PR6b), so the hulls match engine's byte for byte */
|
|
2
|
+
// SHARD-COMPAT PR6b (J487): each steer vehicle's hull as boxes in its own frame, from the shard's movers and prop
|
|
3
|
+
// colliders with format code only, so the MMO server builds vehicle bodies without engine code. Moved from engine
|
|
4
|
+
// `src/shared/game/shardfile/vehicleHulls.ts` (SHARD-SOURCE SS-GP5). The format keeps a carry `channel` row box-free,
|
|
5
|
+
// so a vehicle's solids are its panel's collider rows (`props.colliders` whose `panel` is the vehicle's id), written in
|
|
6
|
+
// the cell's frame at its rest; here they turn into the vehicle's frame (about its rest, YXZ). A tread shape is no
|
|
7
|
+
// hull; at most 128 boxes, as a mover holds.
|
|
8
|
+
import type { MoverBox } from './mover-pose.ts'
|
|
9
|
+
import type { Shardfile } from './shardSchema.ts'
|
|
10
|
+
|
|
11
|
+
const MAX_BOXES = 128
|
|
12
|
+
|
|
13
|
+
/** A quaternion as x, y, z, w. */
|
|
14
|
+
type Quat = readonly [number, number, number, number]
|
|
15
|
+
|
|
16
|
+
/** three's `setFromEuler` for order YXZ. */
|
|
17
|
+
function fromEulerYXZ(x: number, y: number, z: number): Quat {
|
|
18
|
+
const c1 = Math.cos(x / 2)
|
|
19
|
+
const c2 = Math.cos(y / 2)
|
|
20
|
+
const c3 = Math.cos(z / 2)
|
|
21
|
+
const s1 = Math.sin(x / 2)
|
|
22
|
+
const s2 = Math.sin(y / 2)
|
|
23
|
+
const s3 = Math.sin(z / 2)
|
|
24
|
+
return [
|
|
25
|
+
s1 * c2 * c3 + c1 * s2 * s3,
|
|
26
|
+
c1 * s2 * c3 - s1 * c2 * s3,
|
|
27
|
+
c1 * c2 * s3 - s1 * s2 * c3,
|
|
28
|
+
c1 * c2 * c3 + s1 * s2 * s3,
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** three's `multiplyQuaternions(a, b)`. */
|
|
33
|
+
function multiply(a: Quat, b: Quat): Quat {
|
|
34
|
+
const [qax, qay, qaz, qaw] = a
|
|
35
|
+
const [qbx, qby, qbz, qbw] = b
|
|
36
|
+
return [
|
|
37
|
+
qax * qbw + qaw * qbx + qay * qbz - qaz * qby,
|
|
38
|
+
qay * qbw + qaw * qby + qaz * qbx - qax * qbz,
|
|
39
|
+
qaz * qbw + qaw * qbz + qax * qby - qay * qbx,
|
|
40
|
+
qaw * qbw - qax * qbx - qay * qby - qaz * qbz,
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** three's `normalize`: a zero quaternion becomes the identity. */
|
|
45
|
+
function normalize(q: Quat): Quat {
|
|
46
|
+
const [x, y, z, w] = q
|
|
47
|
+
const length = Math.sqrt(x * x + y * y + z * z + w * w)
|
|
48
|
+
if (length === 0) {
|
|
49
|
+
return [0, 0, 0, 1]
|
|
50
|
+
}
|
|
51
|
+
const inverse = 1 / length
|
|
52
|
+
return [x * inverse, y * inverse, z * inverse, w * inverse]
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** three's `Vector3.applyQuaternion`. */
|
|
56
|
+
function rotate(
|
|
57
|
+
v: readonly [number, number, number],
|
|
58
|
+
q: Quat,
|
|
59
|
+
): readonly [number, number, number] {
|
|
60
|
+
const [vx, vy, vz] = v
|
|
61
|
+
const [qx, qy, qz, qw] = q
|
|
62
|
+
const tx = 2 * (qy * vz - qz * vy)
|
|
63
|
+
const ty = 2 * (qz * vx - qx * vz)
|
|
64
|
+
const tz = 2 * (qx * vy - qy * vx)
|
|
65
|
+
return [
|
|
66
|
+
vx + qw * tx + qy * tz - qz * ty,
|
|
67
|
+
vy + qw * ty + qz * tx - qx * tz,
|
|
68
|
+
vz + qw * tz + qx * ty - qy * tx,
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Each steer vehicle's hull, as boxes in its own frame (about its rest, YXZ), by mover id. */
|
|
73
|
+
export function vehicleHulls(
|
|
74
|
+
source: Pick<Shardfile, 'movers'> & Partial<Pick<Shardfile, 'props'>>,
|
|
75
|
+
): ReadonlyMap<string, readonly MoverBox[]> {
|
|
76
|
+
const hulls = new Map<string, readonly MoverBox[]>()
|
|
77
|
+
for (const row of source.movers) {
|
|
78
|
+
if (row.kind !== 'channel' || row.driver?.kind !== 'steer') {
|
|
79
|
+
continue
|
|
80
|
+
}
|
|
81
|
+
const [ex, ey, ez, ew] = fromEulerYXZ(row.euler.x, row.euler.y, row.euler.z)
|
|
82
|
+
// three's `invert` of a unit quaternion is its conjugate.
|
|
83
|
+
const back: Quat = [-ex, -ey, -ez, ew]
|
|
84
|
+
const boxes = (source.props?.colliders ?? [])
|
|
85
|
+
.filter(solid => solid.panel === row.id)
|
|
86
|
+
.flatMap(solid => solid.shapes)
|
|
87
|
+
.flatMap((shape): MoverBox[] => {
|
|
88
|
+
if (shape.kind !== 'box') {
|
|
89
|
+
return []
|
|
90
|
+
}
|
|
91
|
+
const [x, y, z] = rotate(
|
|
92
|
+
[shape.x - row.at.x, shape.y - row.at.y, shape.z - row.at.z],
|
|
93
|
+
back,
|
|
94
|
+
)
|
|
95
|
+
const half = (shape.yaw ?? 0) / 2
|
|
96
|
+
const turn: Quat =
|
|
97
|
+
shape.rot === undefined
|
|
98
|
+
? [
|
|
99
|
+
0 * Math.sin(half),
|
|
100
|
+
1 * Math.sin(half),
|
|
101
|
+
0 * Math.sin(half),
|
|
102
|
+
Math.cos(half),
|
|
103
|
+
]
|
|
104
|
+
: [shape.rot.x, shape.rot.y, shape.rot.z, shape.rot.w]
|
|
105
|
+
const [rx, ry, rz, rw] = normalize(multiply(back, turn))
|
|
106
|
+
return [
|
|
107
|
+
{
|
|
108
|
+
x,
|
|
109
|
+
y,
|
|
110
|
+
z,
|
|
111
|
+
hx: shape.hx,
|
|
112
|
+
hy: shape.hy,
|
|
113
|
+
hz: shape.hz,
|
|
114
|
+
rot: { x: rx, y: ry, z: rz, w: rw },
|
|
115
|
+
},
|
|
116
|
+
]
|
|
117
|
+
})
|
|
118
|
+
.slice(0, MAX_BOXES)
|
|
119
|
+
if (boxes.length > 0) {
|
|
120
|
+
hulls.set(row.id, boxes)
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return hulls
|
|
124
|
+
}
|