@wildshard/shard-format 0.69.0 → 0.69.1
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.69.
|
|
3
|
+
"version": "0.69.1",
|
|
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": {
|
|
@@ -41,7 +41,6 @@ const EMPTY_INDEX_FIELDS: readonly (readonly [string, string | undefined])[] = [
|
|
|
41
41
|
['schemas', undefined],
|
|
42
42
|
['runtime', 'files'],
|
|
43
43
|
['runtime', 'lines'],
|
|
44
|
-
['requires', 'capabilities'],
|
|
45
44
|
]
|
|
46
45
|
/** FORMAT-PRUNE FP15: OF30 cut B leaves these as plain JSON nothing reads. */
|
|
47
46
|
const SPECIES_PROGRAM_FAMILY: readonly string[] = [
|
|
@@ -94,7 +93,7 @@ const RULES: readonly DeprecationRule[] = [
|
|
|
94
93
|
},
|
|
95
94
|
{
|
|
96
95
|
id: 'shard.empty-fields',
|
|
97
|
-
path: 'shard.json schemas, runtime.files
|
|
96
|
+
path: 'shard.json schemas, runtime.files and runtime.lines (FORMAT-PRUNE FP4)',
|
|
98
97
|
since: ENVELOPE,
|
|
99
98
|
replacement: 'nothing: each is always empty and no reader reads it',
|
|
100
99
|
migration: 'fp4-drop-empty-index-fields',
|
|
@@ -106,6 +105,26 @@ const RULES: readonly DeprecationRule[] = [
|
|
|
106
105
|
: field(field(shard.index, outer), inner) !== undefined,
|
|
107
106
|
),
|
|
108
107
|
},
|
|
108
|
+
{
|
|
109
|
+
id: 'requires.sdk',
|
|
110
|
+
path: 'shard.json requires.sdk (SHARD-COMPAT CP8): a copy of the format version',
|
|
111
|
+
since: ENVELOPE,
|
|
112
|
+
replacement:
|
|
113
|
+
'nothing: formatVersion names the format; writers stop sourcing it, then it goes at zero users',
|
|
114
|
+
migration: undefined,
|
|
115
|
+
uses: (shard: Readonly<DeprecationInput>): boolean =>
|
|
116
|
+
field(field(shard.index, 'requires'), 'sdk') !== undefined,
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
id: 'requires.capabilities',
|
|
120
|
+
path: 'shard.json requires.capabilities (FORMAT-PRUNE FP4): always empty, never read',
|
|
121
|
+
since: ENVELOPE,
|
|
122
|
+
replacement:
|
|
123
|
+
'nothing: the build source hash covers it, so writers stop sourcing it, then it goes at zero users',
|
|
124
|
+
migration: undefined,
|
|
125
|
+
uses: (shard: Readonly<DeprecationInput>): boolean =>
|
|
126
|
+
field(field(shard.index, 'requires'), 'capabilities') !== undefined,
|
|
127
|
+
},
|
|
109
128
|
{
|
|
110
129
|
id: 'manifest.gridShardfile',
|
|
111
130
|
path: 'sections/ui/level manifest.gridShardfile (and the discovery mount)',
|
|
@@ -26,7 +26,8 @@ const formatVersionField: FormatMigration = {
|
|
|
26
26
|
},
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
/** FORMAT-PRUNE FP4: `schemas`, `runtime.files
|
|
29
|
+
/** FORMAT-PRUNE FP4: `schemas`, `runtime.files` and `runtime.lines`, always empty, never read. `requires.capabilities` stays:
|
|
30
|
+
* it is part of the assembled source the build's source hash covers, so it goes only with the writers that stop sourcing it. */
|
|
30
31
|
const dropEmptyIndexFields: FormatMigration = {
|
|
31
32
|
id: 'fp4-drop-empty-index-fields',
|
|
32
33
|
to: ENVELOPE,
|
|
@@ -35,14 +36,11 @@ const dropEmptyIndexFields: FormatMigration = {
|
|
|
35
36
|
apply: (shard: MigratingShard): void => {
|
|
36
37
|
const { index } = shard
|
|
37
38
|
Reflect.deleteProperty(index, 'schemas')
|
|
38
|
-
const { runtime
|
|
39
|
+
const { runtime } = index
|
|
39
40
|
if (isRecord(runtime)) {
|
|
40
41
|
Reflect.deleteProperty(runtime, 'files')
|
|
41
42
|
Reflect.deleteProperty(runtime, 'lines')
|
|
42
43
|
}
|
|
43
|
-
if (isRecord(requires)) {
|
|
44
|
-
Reflect.deleteProperty(requires, 'capabilities')
|
|
45
|
-
}
|
|
46
44
|
},
|
|
47
45
|
}
|
|
48
46
|
|
|
@@ -72,13 +72,12 @@ export function parseOutputDescriptorIndex(input: unknown): OutputIndex | null {
|
|
|
72
72
|
return isOutputIndex(input) ? parseOutputIndexRows(input) : null;
|
|
73
73
|
}
|
|
74
74
|
/** The fields only the legacy envelope (`formatVersion: 2`, formats 0.1 to 0.1.0.1) carries; 0.1.0.2 drops each
|
|
75
|
-
* (SHARD-COMPAT CP14; FORMAT-PRUNE FP3 `runtime.trust`, FP4 the always-empty
|
|
75
|
+
* (SHARD-COMPAT CP14; FORMAT-PRUNE FP3 `runtime.trust`, FP4 the always-empty index lists). */
|
|
76
76
|
// oxlint-disable-next-line typescript/prefer-readonly-parameter-types -- valibot output, only read
|
|
77
77
|
function legacyIndexFields(index: OutputIndex): readonly string[] {
|
|
78
78
|
return [
|
|
79
79
|
index.version === undefined ? undefined : 'version',
|
|
80
80
|
index.schemas === undefined ? undefined : 'schemas',
|
|
81
|
-
index.requires.capabilities === undefined ? undefined : 'requires.capabilities',
|
|
82
81
|
index.runtime?.files === undefined ? undefined : 'runtime.files',
|
|
83
82
|
index.runtime?.lines === undefined ? undefined : 'runtime.lines',
|
|
84
83
|
index.runtime === null || !Object.hasOwn(index.runtime, 'trust') ? undefined : 'runtime.trust',
|
|
@@ -94,7 +93,7 @@ function checkIndexEnvelope(index: OutputIndex): void {
|
|
|
94
93
|
}
|
|
95
94
|
return;
|
|
96
95
|
}
|
|
97
|
-
const needed = ['version', 'schemas',
|
|
96
|
+
const needed = ['version', 'schemas', ...index.runtime === null ? [] : ['runtime.files', 'runtime.lines']];
|
|
98
97
|
const missing = needed.filter((field: string): boolean => !carried.includes(field));
|
|
99
98
|
if (missing.length > 0) {
|
|
100
99
|
throw new Error(`Legacy shard.json (formatVersion 2) needs ${missing.join(', ')}`);
|
|
@@ -40,7 +40,7 @@ const tileCount = (2 * CHUNK_HALF / WIRE_TILE_SIZES.l0) ** 2 + (2 * CHUNK_HALF /
|
|
|
40
40
|
/** Stable authored shard identity and deterministic seed. */
|
|
41
41
|
export const IdentitySchema: v.GenericSchema<ShardIdentityInput, ShardIdentity> = v.strictObject({ slug: name, name: v.pipe(v.string(), v.minLength(1), v.maxLength(limits.idCharacters)), author: v.pipe(v.string(), v.minLength(1), v.maxLength(limits.idCharacters)), revision: positive, seed: ShardNaturalSchema });
|
|
42
42
|
/** Wire revision, capabilities and exact commons declarations. */
|
|
43
|
-
export const RequiresSchema: v.GenericSchema<ShardRequiresInput, ShardRequires> = v.strictObject({ sdk: v.picklist(SHARDFILE_VERSIONS), capabilities:
|
|
43
|
+
export const RequiresSchema: v.GenericSchema<ShardRequiresInput, ShardRequires> = v.strictObject({ sdk: v.picklist(SHARDFILE_VERSIONS), capabilities: ShardNamesSchema, commons: v.pipe(v.array(ShardHashSchema), v.maxLength(limits.commons)), commonsWire: v.optional(v.record(ShardHashSchema, ShardNaturalSchema), {}), commonsCosts: v.optional(CommonsCostsSchema, {}) });
|
|
44
44
|
/** Authored compressed and resident ceilings. */
|
|
45
45
|
export const BudgetsSchema: v.GenericSchema<ShardBudgetsInput, ShardBudgets> = v.strictObject({
|
|
46
46
|
/** Reviewed whole-client floor retained when an opaque runtime becomes declared data. */
|
|
@@ -224,8 +224,7 @@ interface ShardIdentityFields {
|
|
|
224
224
|
export type ShardIdentity = { [Key in keyof ShardIdentityFields]: ShardIdentityFields[Key] };
|
|
225
225
|
interface ShardRequiresInputFields {
|
|
226
226
|
sdk: ShardfileVersion;
|
|
227
|
-
|
|
228
|
-
capabilities?: ShardNamesInput;
|
|
227
|
+
capabilities: ShardNamesInput;
|
|
229
228
|
commons: (ShardHashInput)[];
|
|
230
229
|
commonsWire?: Record<string, ShardNaturalInput> | undefined;
|
|
231
230
|
commonsCosts?: v.InferInput<typeof CommonsCostsSchema> | undefined;
|
|
@@ -233,7 +232,7 @@ interface ShardRequiresInputFields {
|
|
|
233
232
|
export type ShardRequiresInput = { [Key in keyof ShardRequiresInputFields]: ShardRequiresInputFields[Key] };
|
|
234
233
|
interface ShardRequiresFields {
|
|
235
234
|
sdk: ShardfileVersion;
|
|
236
|
-
capabilities
|
|
235
|
+
capabilities: ShardNames;
|
|
237
236
|
commons: (ShardHash)[];
|
|
238
237
|
commonsWire: Record<string, ShardNatural>;
|
|
239
238
|
commonsCosts: v.InferOutput<typeof CommonsCostsSchema>;
|
package/src/format/version.ts
CHANGED
|
@@ -123,28 +123,39 @@ function withoutKeys(value: unknown, keys: readonly string[]): unknown {
|
|
|
123
123
|
)
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
+
/** The rows `outputIndexEnvelope` returns: the writer's own rows, typed so it keeps reading them, with `version` and
|
|
127
|
+
* `schemas` possibly gone and `formatVersion` possibly the version string. */
|
|
128
|
+
type IndexEnvelope<Rows> = Omit<Rows, 'formatVersion' | 'schemas' | 'version'> &
|
|
129
|
+
Readonly<{
|
|
130
|
+
formatVersion: unknown
|
|
131
|
+
version?: unknown
|
|
132
|
+
schemas?: unknown
|
|
133
|
+
}>
|
|
134
|
+
|
|
126
135
|
/** SHARD-COMPAT CP14: writers build the legacy `shard.json` rows (`formatVersion: 2`, `version`, the always-empty lists)
|
|
127
136
|
* and pass them here. At a `version` of 0.1.0.2 or later this returns the envelope that version writes: `formatVersion`
|
|
128
|
-
* is the version, and `version`, `schemas`, `runtime.files`, `runtime.lines
|
|
129
|
-
* `
|
|
130
|
-
function outputIndexEnvelope(
|
|
131
|
-
rows:
|
|
132
|
-
):
|
|
137
|
+
* is the version, and `version`, `schemas`, `runtime.files`, `runtime.lines` and `runtime.trust` go. An older
|
|
138
|
+
* `version` comes back unchanged. */
|
|
139
|
+
function outputIndexEnvelope<Rows extends Readonly<Record<string, unknown>>>(
|
|
140
|
+
rows: Rows,
|
|
141
|
+
): IndexEnvelope<Rows> {
|
|
133
142
|
const { version } = rows
|
|
134
|
-
if (typeof version !== 'string' || !writesIndexFormatVersion(version)) {
|
|
135
|
-
return { ...rows }
|
|
136
|
-
}
|
|
137
143
|
const { version: _version, schemas: _schemas, ...rest } = rows
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
+
const envelope: Record<string, unknown> =
|
|
145
|
+
typeof version !== 'string' || !writesIndexFormatVersion(version)
|
|
146
|
+
? { ...rows }
|
|
147
|
+
: {
|
|
148
|
+
...rest,
|
|
149
|
+
formatVersion: version,
|
|
150
|
+
runtime: withoutKeys(rest['runtime'], ['files', 'lines', 'trust']),
|
|
151
|
+
}
|
|
152
|
+
// oxlint-disable-next-line typescript/no-unsafe-type-assertion -- the writer's own rows; only envelope fields change
|
|
153
|
+
return envelope as IndexEnvelope<Rows>
|
|
144
154
|
}
|
|
145
155
|
|
|
146
156
|
export {
|
|
147
157
|
outputIndexEnvelope,
|
|
158
|
+
type IndexEnvelope,
|
|
148
159
|
SHARDFILE_VERSION,
|
|
149
160
|
SHARDFILE_VERSIONS,
|
|
150
161
|
LEGACY_INDEX_VERSIONS,
|