@wildshard/shard-format 0.12.0 → 0.14.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.12.0",
3
+ "version": "0.14.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": {
@@ -398,6 +398,7 @@
398
398
  "./worldScenes": "./src/format/worldScenes.ts",
399
399
  "./worldTargets": "./src/format/worldTargets.ts",
400
400
  "./worldUpdates": "./src/format/worldUpdates.ts",
401
+ "./incomingCapPolicy": "./src/format/incoming-cap-policy.ts",
401
402
  "./strikeDebris": "./src/format/strike-debris.ts",
402
403
  "./harvestRows": "./src/format/harvest-rows.ts"
403
404
  },
@@ -407,12 +408,12 @@
407
408
  "packageManager": "pnpm@10.34.9",
408
409
  "scripts": {
409
410
  "pnpm:devPreinstall": "git rev-parse --is-inside-work-tree >/dev/null 2>&1 && git config core.hooksPath .githooks || true",
410
- "typecheck": "tsc -p kit/tsconfig.json && tsc -p src/format/tsconfig.json && tsc -p src/format/tsconfig.lib.json",
411
- "lint": "node kit/scripts/lint.mjs --type-aware --deny-warnings --no-error-on-unmatched-pattern --ignore-pattern '.githooks/**' --ignore-pattern '.agents/**' --ignore-pattern 'scripts/agent-parity.mjs' --ignore-pattern 'scripts/agent-sync.mjs' --ignore-pattern 'scripts/scratch-dir*' --ignore-pattern 'scripts/scratch-sweep*' --ignore-pattern 'scripts/lane-live*' --ignore-pattern 'scripts/leftovers-report*' --ignore-pattern 'scripts/keep-copy*' --ignore-pattern 'scripts/disk-audit*' --ignore-pattern 'test/tooling/disk-land.test.mjs' --ignore-pattern 'test/tooling/land-fixture.mjs' --ignore-pattern 'test/tooling/owned-scratch.mjs' --ignore-pattern 'test/tooling/lane-live.test.mjs' --ignore-pattern 'test/tooling/keep-copy.test.mjs' --ignore-pattern 'test/tooling/leftovers-report.test.mjs' --ignore-pattern 'test/tooling/reap-report.test.mjs' --ignore-pattern 'tmp/**' --ignore-pattern 'src/format/**' --ignore-pattern 'scripts/chromium-keychain*' --ignore-pattern 'scripts/worktree-ignore*' --ignore-pattern 'scripts/land*' --ignore-pattern 'scripts/worktree.mjs' --ignore-pattern 'scripts/worktree-reap.mjs' --ignore-pattern 'scripts/pid-lock*' --ignore-pattern 'scripts/apfs-clone.mjs' --ignore-pattern 'scripts/assert-store-layout.mjs' --ignore-pattern 'test/tooling/worktree-guard.test.mjs' --ignore-pattern 'scripts/vite-tmp*' --ignore-pattern 'vitest.config.ts' --ignore-pattern 'test/tooling/chrome-keychain.test.mjs' --ignore-pattern 'packages/wire/frozen/**' --ignore-pattern 'packages/wire/lib/**'",
411
+ "typecheck": "npr tsc -p kit/tsconfig.json && npr tsc -p src/format/tsconfig.json && npr tsc -p src/format/tsconfig.lib.json",
412
+ "lint": "node kit/scripts/lint.mjs --type-aware --deny-warnings --no-error-on-unmatched-pattern --ignore-pattern '.githooks/**' --ignore-pattern '.agents/**' --ignore-pattern 'scripts/agent-parity.mjs' --ignore-pattern 'scripts/agent-sync.mjs' --ignore-pattern 'scripts/scratch-dir*' --ignore-pattern 'scripts/scratch-sweep*' --ignore-pattern 'scripts/lane-live*' --ignore-pattern 'scripts/leftovers-report*' --ignore-pattern 'scripts/keep-copy*' --ignore-pattern 'scripts/disk-audit*' --ignore-pattern 'test/tooling/disk-land.test.mjs' --ignore-pattern 'test/tooling/land-fixture.mjs' --ignore-pattern 'test/tooling/owned-scratch.mjs' --ignore-pattern 'test/tooling/lane-live.test.mjs' --ignore-pattern 'test/tooling/keep-copy.test.mjs' --ignore-pattern 'test/tooling/leftovers-report.test.mjs' --ignore-pattern 'test/tooling/reap-report.test.mjs' --ignore-pattern 'tmp/**' --ignore-pattern 'src/format/**' --ignore-pattern 'scripts/chromium-keychain*' --ignore-pattern 'scripts/worktree-ignore*' --ignore-pattern 'scripts/land*' --ignore-pattern 'scripts/main-push*' --ignore-pattern 'scripts/worktree.mjs' --ignore-pattern 'scripts/worktree-reap.mjs' --ignore-pattern 'scripts/pid-lock*' --ignore-pattern 'scripts/apfs-clone.mjs' --ignore-pattern 'scripts/assert-store-layout.mjs' --ignore-pattern 'test/tooling/worktree-guard.test.mjs' --ignore-pattern 'scripts/vite-tmp*' --ignore-pattern 'vitest.config.ts' --ignore-pattern 'test/tooling/chrome-keychain.test.mjs' --ignore-pattern 'packages/wire/frozen/**' --ignore-pattern 'packages/wire/lib/**'",
412
413
  "lint:fix": "node kit/scripts/lint.mjs --type-aware --fix --ignore-pattern '.githooks/**' --ignore-pattern '.agents/**' --ignore-pattern 'scripts/agent-parity.mjs' --ignore-pattern 'scripts/agent-sync.mjs' --ignore-pattern 'scripts/scratch-dir*' --ignore-pattern 'scripts/scratch-sweep*' --ignore-pattern 'scripts/lane-live*' --ignore-pattern 'scripts/leftovers-report*' --ignore-pattern 'scripts/keep-copy*' --ignore-pattern 'scripts/disk-audit*' --ignore-pattern 'test/tooling/disk-land.test.mjs' --ignore-pattern 'test/tooling/land-fixture.mjs' --ignore-pattern 'test/tooling/owned-scratch.mjs' --ignore-pattern 'test/tooling/lane-live.test.mjs' --ignore-pattern 'test/tooling/keep-copy.test.mjs' --ignore-pattern 'test/tooling/leftovers-report.test.mjs' --ignore-pattern 'test/tooling/reap-report.test.mjs' --ignore-pattern 'tmp/**' --ignore-pattern 'src/format/**'",
413
414
  "lint:format": "node src/tools/format-ratchet.ts",
414
- "format": "oxfmt -c kit/.oxfmtrc.json kit src '!src/format/**' '!src/test/fixtures/**'",
415
- "format:check": "oxfmt -c kit/.oxfmtrc.json --check kit src '!src/format/**' '!src/test/fixtures/**'",
415
+ "format": "npr oxfmt -c kit/.oxfmtrc.json kit src '!src/format/**' '!src/test/fixtures/**'",
416
+ "format:check": "npr oxfmt -c kit/.oxfmtrc.json --check kit src '!src/format/**' '!src/test/fixtures/**'",
416
417
  "test": "node --test 'src/!(format|ci)/**/*.test.ts'",
417
418
  "test:ci": "node --test 'src/ci/**/*.test.ts'",
418
419
  "test:format": "vitest run src/format --testTimeout=30000 --maxWorkers=2",
@@ -424,10 +425,11 @@
424
425
  "agents:sync": "node scripts/agent-sync.mjs",
425
426
  "md:wrap": "node kit/scripts/md-wrap.mjs",
426
427
  "test:hooks": "node --test '.githooks/*.test.mjs'",
427
- "check": "pnpm typecheck && pnpm lint && pnpm lint:format && pnpm format:check && pnpm test && pnpm test:format && pnpm check:asks && pnpm check:agents && pnpm check:agent-sync && pnpm test:agent-hooks && pnpm check:parity && node --check scripts/chromium-keychain-check.mjs && node --test test/tooling/chrome-keychain.test.mjs test/tooling/disk-land.test.mjs test/tooling/lane-live.test.mjs test/tooling/keep-copy.test.mjs test/tooling/leftovers-report.test.mjs test/tooling/reap-report.test.mjs && pnpm check:wire",
428
+ "check": "pnpm check:bin-pins && pnpm typecheck && pnpm lint && pnpm lint:format && pnpm format:check && pnpm test && pnpm test:format && pnpm check:asks && pnpm check:agents && pnpm check:agent-sync && pnpm test:agent-hooks && pnpm check:parity && node --check scripts/chromium-keychain-check.mjs && node --test test/tooling/chrome-keychain.test.mjs test/tooling/disk-land.test.mjs test/tooling/lane-live.test.mjs test/tooling/keep-copy.test.mjs test/tooling/leftovers-report.test.mjs test/tooling/reap-report.test.mjs && pnpm check:wire",
428
429
  "check:wire": "pnpm --dir packages/wire check && pnpm --dir packages/wire test && pnpm check:wire-proofs",
429
430
  "check:wire-proofs": "node --test src/scripts/wire/recordings-proof.mjs src/scripts/wire/graph-proof.mjs src/scripts/wire/prepared-frame-proof.mjs",
430
- "bench": "pnpm --dir packages/wire bench"
431
+ "bench": "pnpm --dir packages/wire bench",
432
+ "check:bin-pins": "node kit/scripts/bin-pins.mjs"
431
433
  },
432
434
  "dependencies": {
433
435
  "meshoptimizer": "1.2.0",
@@ -438,13 +440,11 @@
438
440
  "@typescript/typescript6": "6.0.2",
439
441
  "binaryen": "132.0.0",
440
442
  "fflate": "0.8.3",
441
- "oxfmt": "0.74.0",
442
443
  "oxlint": "1.89.0",
443
- "oxlint-tsgolint": "7.0.2004",
444
444
  "playwright": "1.64.1",
445
- "typescript": "7.0.2",
446
445
  "vite": "8.3.0",
447
- "vitest": "5.0.1"
446
+ "vitest": "5.0.1",
447
+ "npm-bin-deps": "2.1.0"
448
448
  },
449
449
  "pnpm": {
450
450
  "ignoredOptionalDependencies": [
@@ -529,5 +529,11 @@
529
529
  "@typescript/typescript-win32-arm64",
530
530
  "@typescript/typescript-win32-x64"
531
531
  ]
532
- }
532
+ },
533
+ "binDependencies": {
534
+ "typescript": "7.0.2",
535
+ "oxfmt": "0.74.0",
536
+ "oxlint-tsgolint": "7.0.2004"
537
+ },
538
+ "binDependenciesInstaller": "npm"
533
539
  }
@@ -85,10 +85,10 @@ interface AssetAdmission {
85
85
  }
86
86
 
87
87
  /** The checks before any byte is read: preflight, schema, decision modules, the graph and declared costs. */
88
- // oxlint-disable-next-line eslint/max-statements, typescript/prefer-readonly-parameter-types -- validateShardfileAssets' opening steps, moved whole (AC6a2)
89
- function assetAdmission(input: unknown, memory: MemoryAdmission | undefined, scripts: ScriptAdmissionRows): AssetAdmission {
88
+ // oxlint-disable-next-line eslint/max-params, eslint/max-statements, typescript/prefer-readonly-parameter-types -- the existing admission state also receives its checked section context
89
+ function assetAdmission(input: unknown, memory: MemoryAdmission | undefined, scripts: ScriptAdmissionRows, sections?: ReadonlyMap<string, unknown>): AssetAdmission {
90
90
  preflightShardfile(input);
91
- const s = parseShardfile(input), files = new Map(s.files.map((f) => [f.hash, f]));
91
+ const s = parseShardfile(input, sections), files = new Map(s.files.map((f) => [f.hash, f]));
92
92
  const contracts = decisionModuleContracts(scripts, s.files);
93
93
  const legacyModules = new Set([...s.sim.scripts, ...s.clientScripts.bindings.map(row => row.module), ...s.movers.filter(row => row.execution !== 'native').map(row => row.module)]);
94
94
  if ([...contracts.keys()].some(hash => legacyModules.has(hash))) throw new Error('Decision module cannot also use a legacy script host');
@@ -266,8 +266,8 @@ function admitAfterFiles(state: AssetAdmission, assets: ReadonlyMap<string, Uint
266
266
  }
267
267
 
268
268
  /** Admit exact bytes, graph closure, script growth and worst-location residency before a runtime is allocated. */
269
- function validateShardfileAssets(input: unknown, assets: ReadonlyMap<string, Uint8Array>, contentHash: (bytes: Uint8Array) => string, memory?: MemoryAdmission, textures?: TextureTranscodeSupport, scripts: ScriptAdmissionRows = []): Shardfile {
270
- const state = assetAdmission(input, memory, scripts);
269
+ function validateShardfileAssets(input: unknown, assets: ReadonlyMap<string, Uint8Array>, contentHash: (bytes: Uint8Array) => string, memory?: MemoryAdmission, textures?: TextureTranscodeSupport, scripts: ScriptAdmissionRows = [], sections?: ReadonlyMap<string, unknown>): Shardfile {
270
+ const state = assetAdmission(input, memory, scripts, sections);
271
271
  admitCommonsBytes(state, assets, contentHash);
272
272
  for (const file of state.shard.files) {
273
273
  admitFileBytes(state, file, assets.get(file.hash), assets, contentHash);
@@ -0,0 +1,101 @@
1
+ import {
2
+ array,
3
+ check,
4
+ exactOptional,
5
+ maxLength,
6
+ minLength,
7
+ parse,
8
+ pipe,
9
+ strictObject,
10
+ string,
11
+ } from 'valibot'
12
+
13
+ import type { GenericSchema } from 'valibot'
14
+
15
+ /** Exact source tags that bypass the incoming cap; never wildcard patterns. */
16
+ interface IncomingCapPolicy {
17
+ readonly capExempt?: readonly string[]
18
+ readonly capExemptTags?: readonly string[]
19
+ }
20
+ const MAX_ALIASES = 256
21
+ const MAX_ALIAS_LENGTH = 512
22
+ const TAGS_PER_ALIAS = 2
23
+ const MAX_TAGS = MAX_ALIASES * TAGS_PER_ALIAS
24
+ const CREATURE_PREFIX = 'creature.'
25
+ const MIN_ALIAS_LENGTH = 1
26
+ const alias = pipe(
27
+ string(),
28
+ minLength(MIN_ALIAS_LENGTH),
29
+ maxLength(MAX_ALIAS_LENGTH),
30
+ )
31
+ const aliases = pipe(array(alias), maxLength(MAX_ALIASES))
32
+ const exactTag = pipe(
33
+ string(),
34
+ maxLength(MAX_ALIAS_LENGTH + CREATURE_PREFIX.length),
35
+ check((tag: string): boolean => tag.includes('.'), 'exact dotted combat tag'),
36
+ )
37
+ const exactTags = array(exactTag)
38
+ const IncomingCapTagsSchema: GenericSchema<string[]> = pipe(
39
+ exactTags,
40
+ maxLength(MAX_TAGS),
41
+ check<string[], 'unique exact combat tags'>(
42
+ (tags: readonly string[]): boolean => new Set(tags).size === tags.length,
43
+ 'unique exact combat tags',
44
+ ),
45
+ )
46
+
47
+ function lowerAliases(values: readonly string[]): string[] {
48
+ const tags = new Set<string>()
49
+ for (const value of values) {
50
+ if (value.includes('.')) {
51
+ tags.add(value)
52
+ }
53
+ tags.add(`${CREATURE_PREFIX}${value}`)
54
+ }
55
+ return [...tags]
56
+ }
57
+
58
+ /** Both fields may travel to older readers, but must describe identical behavior. */
59
+ function incomingCapPolicyAgrees(policy: IncomingCapPolicy): boolean {
60
+ if (policy.capExempt === undefined || policy.capExemptTags === undefined) {
61
+ return true
62
+ }
63
+ const expected = new Set(lowerAliases(policy.capExempt))
64
+ return (
65
+ expected.size === policy.capExemptTags.length &&
66
+ policy.capExemptTags.every((tag: string): boolean => expected.has(tag))
67
+ )
68
+ }
69
+ interface AdmittedIncomingCapPolicy {
70
+ capExempt?: string[]
71
+ capExemptTags?: string[]
72
+ }
73
+ const policyFields = strictObject({
74
+ capExempt: exactOptional(aliases),
75
+ capExemptTags: exactOptional(IncomingCapTagsSchema),
76
+ })
77
+ const policySchema: GenericSchema<AdmittedIncomingCapPolicy> = pipe(
78
+ policyFields,
79
+ check<
80
+ AdmittedIncomingCapPolicy,
81
+ 'matching legacy and exact incoming-cap policy'
82
+ >(incomingCapPolicyAgrees, 'matching legacy and exact incoming-cap policy'),
83
+ )
84
+
85
+ /** Compile once at admission. Request/state/effect tags still match exactly at hit time. */
86
+ function compileIncomingCapPolicy(policy: IncomingCapPolicy): string[] {
87
+ const admitted = parse(policySchema, {
88
+ ...(policy.capExempt === undefined ? {} : { capExempt: policy.capExempt }),
89
+ ...(policy.capExemptTags === undefined
90
+ ? {}
91
+ : { capExemptTags: policy.capExemptTags }),
92
+ })
93
+ return admitted.capExemptTags ?? lowerAliases(admitted.capExempt ?? [])
94
+ }
95
+
96
+ export {
97
+ IncomingCapTagsSchema,
98
+ compileIncomingCapPolicy,
99
+ incomingCapPolicyAgrees,
100
+ }
101
+ export type { IncomingCapPolicy }
@@ -1,3 +1,4 @@
1
+ import { IncomingCapTagsSchema, incomingCapPolicyAgrees } from './incoming-cap-policy.ts';
1
2
  import * as v from 'valibot';
2
3
 
3
4
  /**
@@ -245,6 +246,8 @@ const tier = v.objectWithRest({aa: v.exactOptional(v.picklist(['fxaa', 'smaa', '
245
246
  const strings = v.pipe(v.array(text), v.maxLength(256));
246
247
  /** A POI's respawn opt-out (TEMPLATE-E2E): `false` is no respawn place. */
247
248
  const optionalFlag = v.exactOptional(v.boolean())
249
+ const manifestFightFields = v.strictObject({maxHitDamage: v.exactOptional(number), capExempt: v.exactOptional(strings), capExemptTags: v.exactOptional(IncomingCapTagsSchema), attackers: v.exactOptional(v.union([number, v.literal('unbounded')])), telegraphed: v.exactOptional(v.boolean()),
250
+ input: v.exactOptional(v.strictObject({bufferMs: number, coyoteMs: number}))});
248
251
  export const ManifestMetadataSchema: v.StrictObjectSchema<{ readonly bindings: v.GenericSchema<ManifestMetadataInput['bindings'], ManifestMetadata['bindings']>; readonly boot: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['boot'], undefined>, Exclude<ManifestMetadata['boot'], undefined>>, undefined>; readonly gridShardfile: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['gridShardfile'], undefined>, Exclude<ManifestMetadata['gridShardfile'], undefined>>, undefined>; readonly shardfile: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['shardfile'], undefined>, Exclude<ManifestMetadata['shardfile'], undefined>>, undefined>; readonly ground: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['ground'], undefined>, Exclude<ManifestMetadata['ground'], undefined>>, undefined>; readonly groundColour: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['groundColour'], undefined>, Exclude<ManifestMetadata['groundColour'], undefined>>, undefined>; readonly world: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['world'], undefined>, Exclude<ManifestMetadata['world'], undefined>>, undefined>; readonly boundary: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['boundary'], undefined>, Exclude<ManifestMetadata['boundary'], undefined>>, undefined>; readonly cellGround: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['cellGround'], undefined>, Exclude<ManifestMetadata['cellGround'], undefined>>, undefined>; readonly hoverSpeedClass: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['hoverSpeedClass'], undefined>, Exclude<ManifestMetadata['hoverSpeedClass'], undefined>>, undefined>; readonly uses: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['uses'], undefined>, Exclude<ManifestMetadata['uses'], undefined>>, undefined>; readonly loadout: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['loadout'], undefined>, Exclude<ManifestMetadata['loadout'], undefined>>, undefined>; readonly species: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['species'], undefined>, Exclude<ManifestMetadata['species'], undefined>>, undefined>; readonly encounters: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['encounters'], undefined>, Exclude<ManifestMetadata['encounters'], undefined>>, undefined>; readonly fight: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['fight'], undefined>, Exclude<ManifestMetadata['fight'], undefined>>, undefined>; readonly creatures: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['creatures'], undefined>, Exclude<ManifestMetadata['creatures'], undefined>>, undefined>; readonly tiers: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['tiers'], undefined>, Exclude<ManifestMetadata['tiers'], undefined>>, undefined>; readonly loot: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['loot'], undefined>, Exclude<ManifestMetadata['loot'], undefined>>, undefined>; readonly hud: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['hud'], undefined>, Exclude<ManifestMetadata['hud'], undefined>>, undefined>; readonly bag: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['bag'], undefined>, Exclude<ManifestMetadata['bag'], undefined>>, undefined>; readonly regionalSimCost: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['regionalSimCost'], undefined>, Exclude<ManifestMetadata['regionalSimCost'], undefined>>, undefined>; readonly spawns: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['spawns'], undefined>, Exclude<ManifestMetadata['spawns'], undefined>>, undefined>; readonly audio: v.GenericSchema<ManifestMetadataInput['audio'], ManifestMetadata['audio']>; readonly api: v.GenericSchema<ManifestMetadataInput['api'], ManifestMetadata['api']>; readonly slug: v.GenericSchema<ManifestMetadataInput['slug'], ManifestMetadata['slug']>; readonly order: v.GenericSchema<ManifestMetadataInput['order'], ManifestMetadata['order']>; readonly status: v.GenericSchema<ManifestMetadataInput['status'], ManifestMetadata['status']>; readonly shardSelect: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['shardSelect'], undefined>, Exclude<ManifestMetadata['shardSelect'], undefined>>, undefined>; readonly name: v.GenericSchema<ManifestMetadataInput['name'], ManifestMetadata['name']>; readonly label: v.GenericSchema<ManifestMetadataInput['label'], ManifestMetadata['label']>; readonly seed: v.GenericSchema<ManifestMetadataInput['seed'], ManifestMetadata['seed']>; readonly biome: v.GenericSchema<ManifestMetadataInput['biome'], ManifestMetadata['biome']>; readonly blurb: v.GenericSchema<ManifestMetadataInput['blurb'], ManifestMetadata['blurb']>; readonly card: v.GenericSchema<ManifestMetadataInput['card'], ManifestMetadata['card']>; readonly style: v.GenericSchema<ManifestMetadataInput['style'], ManifestMetadata['style']>; readonly kitLook: v.GenericSchema<ManifestMetadataInput['kitLook'], ManifestMetadata['kitLook']>; readonly hands: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['hands'], undefined>, Exclude<ManifestMetadata['hands'], undefined>>, undefined>; readonly camera: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['camera'], undefined>, Exclude<ManifestMetadata['camera'], undefined>>, undefined>; readonly weapon: v.GenericSchema<ManifestMetadataInput['weapon'], ManifestMetadata['weapon']>; readonly treeCount: v.GenericSchema<ManifestMetadataInput['treeCount'], ManifestMetadata['treeCount']>; readonly trees: v.GenericSchema<ManifestMetadataInput['trees'], ManifestMetadata['trees']>; readonly assetGlobs: v.GenericSchema<ManifestMetadataInput['assetGlobs'], ManifestMetadata['assetGlobs']>; readonly spawn: v.GenericSchema<ManifestMetadataInput['spawn'], ManifestMetadata['spawn']>; readonly bounds: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['bounds'], undefined>, Exclude<ManifestMetadata['bounds'], undefined>>, undefined>; readonly sky: v.GenericSchema<ManifestMetadataInput['sky'], ManifestMetadata['sky']>; readonly atmosphere: v.GenericSchema<ManifestMetadataInput['atmosphere'], ManifestMetadata['atmosphere']>; readonly grade: v.GenericSchema<ManifestMetadataInput['grade'], ManifestMetadata['grade']>; readonly horizon: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['horizon'], undefined>, Exclude<ManifestMetadata['horizon'], undefined>>, undefined>; readonly minimap: v.GenericSchema<ManifestMetadataInput['minimap'], ManifestMetadata['minimap']>; readonly pois: v.GenericSchema<ManifestMetadataInput['pois'], ManifestMetadata['pois']>; readonly explore: v.GenericSchema<ManifestMetadataInput['explore'], ManifestMetadata['explore']>; readonly captureProbes: v.ExactOptionalSchema<v.ArraySchema<v.GenericSchema<Exclude<ManifestMetadataInput['captureProbes'], undefined>[number], Exclude<ManifestMetadata['captureProbes'], undefined>[number]>, undefined>, undefined>; readonly next: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['next'], undefined>, Exclude<ManifestMetadata['next'], undefined>>, undefined>; readonly debugOptions: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['debugOptions'], undefined>, Exclude<ManifestMetadata['debugOptions'], undefined>>, undefined>; readonly bodyShadow: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['bodyShadow'], undefined>, Exclude<ManifestMetadata['bodyShadow'], undefined>>, undefined>; readonly ocean: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['ocean'], undefined>, Exclude<ManifestMetadata['ocean'], undefined>>, undefined>; readonly blender: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['blender'], undefined>, Exclude<ManifestMetadata['blender'], undefined>>, undefined>; readonly horizonStrips: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['horizonStrips'], undefined>, Exclude<ManifestMetadata['horizonStrips'], undefined>>, undefined>; readonly assets: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['assets'], undefined>, Exclude<ManifestMetadata['assets'], undefined>>, undefined>; readonly look: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['look'], undefined>, Exclude<ManifestMetadata['look'], undefined>>, undefined>; readonly pondLilyExclusions: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['pondLilyExclusions'], undefined>, Exclude<ManifestMetadata['pondLilyExclusions'], undefined>>, undefined>; readonly faunaTuning: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['faunaTuning'], undefined>, Exclude<ManifestMetadata['faunaTuning'], undefined>>, undefined>; readonly forest: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['forest'], undefined>, Exclude<ManifestMetadata['forest'], undefined>>, undefined>; }, undefined> = v.strictObject({
249
252
  bindings,
250
253
  boot: v.exactOptional(v.strictObject({barrier: v.exactOptional(v.boolean()), cullBeforeFirstDraw: v.exactOptional(v.boolean()),
@@ -261,8 +264,7 @@ export const ManifestMetadataSchema: v.StrictObjectSchema<{ readonly bindings: v
261
264
  uses: v.exactOptional(v.pipe(v.array(v.picklist(['weather', 'dayCycle', 'bosses', 'elites', 'spawns', 'quests', 'swim', 'hover', 'explore', 'practice', 'coins', 'loot', 'compendium', 'feats', 'bag.pack'])), v.maxLength(64))),
262
265
  loadout: v.exactOptional(v.strictObject({weapons: strings, tools: strings, start: strings, held: v.exactOptional(text), loans: v.exactOptional(v.pipe(v.array(v.strictObject({id: text, in: v.literal('practice')})), v.maxLength(256), v.check(rows => new Set(rows.map(row => row.id)).size === rows.length, 'Unique practice loans'))), pickups: v.exactOptional(v.array(v.strictObject({id: text, at: text})))})),
263
266
  species: v.exactOptional(strings), encounters: v.exactOptional(strings),
264
- fight: v.exactOptional(v.strictObject({maxHitDamage: v.exactOptional(number), capExempt: v.exactOptional(strings), attackers: v.exactOptional(v.union([number, v.literal('unbounded')])), telegraphed: v.exactOptional(v.boolean()),
265
- input: v.exactOptional(v.strictObject({bufferMs: number, coyoteMs: number}))})),
267
+ fight: v.exactOptional(v.pipe(manifestFightFields, v.check<NonNullable<ManifestMetadata['fight']>, 'matching legacy and exact incoming-cap policy'>(incomingCapPolicyAgrees, 'matching legacy and exact incoming-cap policy'))),
266
268
  creatures: v.exactOptional(v.strictObject({lowPoly: v.boolean(), waitForModels: v.boolean(), furRim: v.boolean(), tintRange: number, oneMaterial: v.boolean()})),
267
269
  // `grid`: rows laid over each tier's while the page is a grid cell (G4; read when the level applies its row)
268
270
  tiers: v.exactOptional(v.strictObject({phone: v.exactOptional(tier), desktop: v.exactOptional(tier),
@@ -533,6 +535,7 @@ export interface ManifestMetadataFields {
533
535
  fight?: {
534
536
  maxHitDamage?: number;
535
537
  capExempt?: (string)[];
538
+ capExemptTags?: (string)[];
536
539
  attackers?: (number) | ('unbounded');
537
540
  telegraphed?: boolean;
538
541
  input?: {
@@ -148,7 +148,7 @@ export function assembleOutputFields(index: OutputIndex, sections: ReadonlyMap<s
148
148
  }
149
149
  /** The default untrusted reader always checks sections and the full host schema. */
150
150
  export function assembleOutputShardfile(input: unknown, sections: ReadonlyMap<string, unknown>): Shardfile {
151
- const source = parseShardfile(assembleOutputFields(parseOutputIndex(input), sections));
151
+ const source = parseShardfile(assembleOutputFields(parseOutputIndex(input), sections), sections);
152
152
  const errors = clientOwnershipRules(source, sections); if (errors.length > 0) throw new Error(errors.join('; '));
153
153
  return source;
154
154
  }
@@ -1,3 +1,4 @@
1
+ import { readSpeciesPrograms } from './speciesPrograms.ts';
1
2
  import type { StrikeDebrisPolicy } from './strike-debris.ts';
2
3
  import { strikeDebrisCatalogueRules } from './strike-debris.ts';
3
4
  import { harvestSpeciesRules } from './harvest-rows.ts';
@@ -210,7 +211,7 @@ export interface Shardfile {
210
211
  function sceneOf(row: Readonly<{ scene: string }>): string { return row.scene; }
211
212
  /** A hook's name. */
212
213
  function idOf(row: Readonly<{ id: string }>): string { return row.id; }
213
- export function shardfileRules(s: Shardfile): string[] {
214
+ export function shardfileRules(s: Shardfile, sections?: ReadonlyMap<string, unknown>): string[] {
214
215
  const errors: string[] = [];
215
216
  const pageOwner = hasDeclaredClientPage(s);
216
217
  errors.push(...questNpcBindingRules(s.questNpcs ?? [], s.quests.flags, pageOwner || s.runtime?.binds?.includes('quests') === true));
@@ -309,7 +310,10 @@ export function shardfileRules(s: Shardfile): string[] {
309
310
  if (moves.passes !== undefined) { debrisStrikes.push(moves.passes.left, moves.passes.right); }
310
311
  }
311
312
  }
312
- errors.push(...strikeDebrisCatalogueRules({ strikes: debrisStrikes, species: s.rows.species }));
313
+ const metadata = sections?.get('actors/species-programs');
314
+ const roster = metadata === undefined ? undefined : readSpeciesPrograms(metadata);
315
+ const targets = [...s.rows.species, ...roster?.page ?? [], ...roster?.native ?? [], ...roster?.program?.species ?? []];
316
+ errors.push(...strikeDebrisCatalogueRules({ strikes: debrisStrikes, species: targets }));
313
317
  const harvestItems = new Set((s.items.catalogue ?? []).map((row: Readonly<{ id: string }>): string => row.id));
314
318
  errors.push(...harvestSpeciesRules(s.rows.species, harvestItems));
315
319
  if (s.migrations.some(step => step.equipmentSlots?.some(rename => !s.items.rows.some(row => row.kind === 'weapon' && row.slot === rename.to)))) errors.push('migration equipment slots resolve declared weapons');
@@ -382,7 +386,7 @@ export function shardfileRules(s: Shardfile): string[] {
382
386
  }
383
387
  /** Strict schema for the public SDK format; rejects unknown fields and invalid references.
384
388
  * Keep the unknown-input/named-output boundary independent of the nested validator implementation. */
385
- export const ShardfileSchema: v.GenericSchema<unknown, Shardfile> = v.pipe(v.unknown(), v.rawCheck(({ dataset, addIssue }) => {
389
+ function shardfileSchema(sections?: ReadonlyMap<string, unknown>): v.GenericSchema<unknown, Shardfile> { return v.pipe(v.unknown(), v.rawCheck(({ dataset, addIssue }) => {
386
390
  const input = dataset.value;
387
391
  try { preflightShardfile(input); } catch (error) {
388
392
  const nonData = error instanceof Error && /(?:JSON data|accessors)/u.test(error.message);
@@ -397,9 +401,14 @@ export const ShardfileSchema: v.GenericSchema<unknown, Shardfile> = v.pipe(v.unk
397
401
  }
398
402
  }), rawSchema,
399
403
  v.rawCheck(({ dataset, addIssue }) => { if (dataset.typed) { try { preflightAssetGraph(dataset.value); } catch (error) { addIssue({ message: error instanceof Error ? error.message : 'shardfile asset graph admission' }); } } }),
400
- v.check((s) => entrywayRules(s).length === 0, 'illegal shard: entryway openings must meet road height y=0'), v.check((s) => shardfileRules(s).length === 0, 'shardfile semantic rules'));
401
- /** Parse untrusted JSON as a validated shardfile, or throw a Valibot error. */
402
- function parseShardfile(input: unknown): Shardfile { return v.parse(ShardfileSchema, input); }
404
+ v.check((s) => entrywayRules(s).length === 0, 'illegal shard: entryway openings must meet road height y=0'), v.check((s) => shardfileRules(s, sections).length === 0, 'shardfile semantic rules')); }
405
+ export const ShardfileSchema: v.GenericSchema<unknown, Shardfile> = shardfileSchema();
406
+ /** Parse JSON through every shard rule. Optional section payloads extend item target
407
+ * references only through the defining species-program contract, never an id allowlist.
408
+ * Product readers must verify section inventories, hashes and sizes before calling. */
409
+ function parseShardfile(input: unknown, sections?: ReadonlyMap<string, unknown>): Shardfile {
410
+ return v.parse(sections === undefined ? ShardfileSchema : shardfileSchema(sections), input);
411
+ }
403
412
  /** Admit one owned or cached declaration field with its defining schema.
404
413
  * The assembled declaration still crosses parseShardfile's cross-field rules. */
405
414
  function parseShardfileField<Key extends keyof Shardfile>(field: Key, input: unknown): Shardfile[Key] {
@@ -31,7 +31,7 @@ function admitHead(
31
31
  payloads: ReadonlyMap<string, unknown>,
32
32
  ): Shardfile {
33
33
  const shard = withIssueCode('shard-schema', (): Shardfile =>
34
- parseShardfile(assembleOutputShardfile(index, payloads)),
34
+ parseShardfile(assembleOutputShardfile(index, payloads), payloads),
35
35
  )
36
36
  withIssueCode('declared-costs', (): void => {
37
37
  preflightDeclaredCosts(shard, offlineMemoryAdmission('warn'))
@@ -55,7 +55,7 @@ function admitBeforeAssets(
55
55
  const head = admitHead(index, payloads)
56
56
  return {
57
57
  admission: withIssueCode('asset-admission', (): AssetAdmission =>
58
- assetAdmission(head, offlineMemoryAdmission('warn'), scripts),
58
+ assetAdmission(head, offlineMemoryAdmission('warn'), scripts, payloads),
59
59
  ),
60
60
  refusal: undefined,
61
61
  }
@@ -114,11 +114,11 @@ export function assertShardfileTargets(source: Shardfile, policy: 'warn' | 'refu
114
114
 
115
115
  /** Admit a whole shardfile's declared costs and its actual immutable bytes through the defining contracts. */
116
116
  export function admitShardfileFolder(input: unknown, assets: ReadonlyMap<string, Uint8Array>, hash: (bytes: Uint8Array) => string,
117
- policy: 'warn' | 'refuse' = 'refuse', scripts: ScriptAdmissionRows = []): Shardfile {
118
- const source = coded('shard-schema', (): Shardfile => parseShardfile(input));
117
+ policy: 'warn' | 'refuse' = 'refuse', scripts: ScriptAdmissionRows = [], sections?: ReadonlyMap<string, unknown>): Shardfile {
118
+ const source = coded('shard-schema', (): Shardfile => parseShardfile(input, sections));
119
119
  coded('declared-costs', (): void => { preflightDeclaredCosts(source, offlineMemoryAdmission(policy)); });
120
120
  coded('performance-targets', (): void => { assertShardfileTargets(source, policy); });
121
- return coded('asset-admission', (): Shardfile => validateShardfileAssets(source, assets, hash, offlineMemoryAdmission(policy), undefined, scripts));
121
+ return coded('asset-admission', (): Shardfile => validateShardfileAssets(source, assets, hash, offlineMemoryAdmission(policy), undefined, scripts, sections));
122
122
  }
123
123
 
124
124
  /** Refuse world target rows that name items or quests the shardfile does not declare. */
@@ -229,7 +229,7 @@ export function validateShardfileFolder(files: ShardfileFiles, ports: ShardfileV
229
229
  coded('runtime-files', (): void => { ports.runtimeImports?.(entry.path, decoder().decode(read(entry))); });
230
230
  }
231
231
  for (const path of files.paths()) if (!listed.has(path)) throw issueError('unlisted-file', `Unlisted output file: ${path}`);
232
- const shard = admitShardfileFolder(coded('shard-schema', (): unknown => assembleOutputShardfile(index, payloads)), assets, ports.hash, 'warn', scripts);
232
+ const shard = admitShardfileFolder(coded('shard-schema', (): unknown => assembleOutputShardfile(index, payloads)), assets, ports.hash, 'warn', scripts, payloads);
233
233
  checkWorldTargets(shard, payloads.get('world/targets'));
234
234
  if (ports.hash(validationSourceBytes(shard)) !== index.build.sourceHash) throw issueError('source-hash', 'Output sections differ from the declared source hash');
235
235
  return { index, shard, assets, sections: payloads, scripts, warnings, audio: shardfileRecordings({ cook, read: files.read, shard, assets }) };
@@ -1,3 +1,4 @@
1
+ import { IncomingCapTagsSchema, incomingCapPolicyAgrees } from './incoming-cap-policy.ts';
1
2
  import type { StrikeDebrisCatalogue } from './strike-debris.ts';
2
3
  import { strikeDebrisCatalogueRules } from './strike-debris.ts';
3
4
  import type { HarvestDrop, HarvestSpecies } from './harvest-rows.ts';
@@ -78,12 +79,13 @@ function readSpeciesProgram(input: unknown): SpeciesProgramData { return v.parse
78
79
 
79
80
  const names = v.pipe(v.array(id), v.maxLength(64));
80
81
  const tag = v.custom<`${string}.${string}`>(value => typeof value === 'string' && value.length <= 128 && /^[a-z][a-zA-Z0-9.-]*\.[a-zA-Z0-9.-]+$/u.test(value));
82
+ const nativeFightFields = v.strictObject({ telegraphed: v.exactOptional(v.boolean()), attackers: v.exactOptional(v.pipe(positive, v.integer(), v.maxValue(1024))),
83
+ maxHitDamage: v.exactOptional(nonnegative), capExempt: v.exactOptional(names), capExemptTags: v.exactOptional(IncomingCapTagsSchema),
84
+ input: v.exactOptional(v.strictObject({ bufferMs: nonnegative, coyoteMs: nonnegative })) });
81
85
  /** Settings for the existing native hunt and continuation owners; no callbacks or replacement clock. */
82
86
  const NativeHuntSchema: v.GenericSchema<NativeHuntRowsInput, NativeHuntRows> = v.strictObject({
83
87
  limit: v.pipe(positive, v.integer(), v.maxValue(1024)), player: v.picklist(['host', 'origin']),
84
- fight: v.strictObject({ telegraphed: v.exactOptional(v.boolean()), attackers: v.exactOptional(v.pipe(positive, v.integer(), v.maxValue(1024))),
85
- maxHitDamage: v.exactOptional(nonnegative), capExempt: v.exactOptional(names),
86
- input: v.exactOptional(v.strictObject({ bufferMs: nonnegative, coyoteMs: nonnegative })) }),
88
+ fight: v.pipe(nativeFightFields, v.check<NativeHuntRows['fight'], 'matching legacy and exact incoming-cap policy'>(incomingCapPolicyAgrees, 'matching legacy and exact incoming-cap policy')),
87
89
  tuning: v.exactOptional(v.record(id, optionalTuning)),
88
90
  bands: v.strictObject({ states: names, scripted: v.exactOptional(v.boolean()), legacyKinds: names }),
89
91
  hit: v.strictObject({ namespace: id, tags: v.pipe(v.array(tag), v.maxLength(32)) }), memoryFields: v.exactOptional(names),
@@ -105,7 +107,7 @@ interface SpeciesData { capExempt?: boolean; harvest?: HarvestDrop[]; id: string
105
107
  type SpeciesProgramDataInput = unknown;
106
108
  interface SpeciesProgramData { species: ({ brain?: v.InferOutput<typeof SpeciesBrainSchema>; body?: v.InferOutput<typeof CreatureBodyRecipeSchema>; } & SpeciesData)[]; strikes: (v.InferOutput<typeof CreatureStrikeSchema>)[]; modules?: Record<string, string>; }
107
109
  type NativeHuntRowsInput = NativeHuntRows;
108
- interface NativeHuntRows { limit: number; player: 'host' | 'origin'; fight: { telegraphed?: boolean; attackers?: number; maxHitDamage?: number; capExempt?: (string)[]; input?: { bufferMs: number; coyoteMs: number; }; }; tuning?: Record<string, { hp?: number; sightRange?: number; sightRangeGraze?: number; sightCone?: number; hearStill?: number; hearCrouch?: number; hearWalk?: number; hearSprint?: number; noticeRate?: number; forgetRate?: number; alertAt?: number; boltAt?: number; freezeMin?: number; freezeMax?: number; relaxAfter?: number; panicDist?: number; runSpeed?: number; trotSpeed?: number; fleeMinTime?: number; fleeUntil?: number; fleeUntilMax?: number; fleeMaxTime?: number; lookBack?: number; waryTime?: number; waryBoost?: number; herdAlertRadius?: number; herdBoltDelayMin?: number; herdBoltDelayMax?: number; impactSpook?: number; impactAlert?: number; stalk?: { detect: number; speed: number; giveUp: number; rechargeCd: number; huffMin: number; huffMax: number; roar: string; fleeBelowHp: number; fleeChance: number; }; }>; bands: { states: (string)[]; scripted?: boolean; legacyKinds: (string)[]; }; hit: { namespace: string; tags: (`${string}.${string}`)[]; }; memoryFields?: (string)[]; }
110
+ interface NativeHuntRows { limit: number; player: 'host' | 'origin'; fight: { telegraphed?: boolean; attackers?: number; maxHitDamage?: number; capExempt?: (string)[]; capExemptTags?: (string)[]; input?: { bufferMs: number; coyoteMs: number; }; }; tuning?: Record<string, { hp?: number; sightRange?: number; sightRangeGraze?: number; sightCone?: number; hearStill?: number; hearCrouch?: number; hearWalk?: number; hearSprint?: number; noticeRate?: number; forgetRate?: number; alertAt?: number; boltAt?: number; freezeMin?: number; freezeMax?: number; relaxAfter?: number; panicDist?: number; runSpeed?: number; trotSpeed?: number; fleeMinTime?: number; fleeUntil?: number; fleeUntilMax?: number; fleeMaxTime?: number; lookBack?: number; waryTime?: number; waryBoost?: number; herdAlertRadius?: number; herdBoltDelayMin?: number; herdBoltDelayMax?: number; impactSpook?: number; impactAlert?: number; stalk?: { detect: number; speed: number; giveUp: number; rechargeCd: number; huffMin: number; huffMax: number; roar: string; fleeBelowHp: number; fleeChance: number; }; }>; bands: { states: (string)[]; scripted?: boolean; legacyKinds: (string)[]; }; hit: { namespace: string; tags: (`${string}.${string}`)[]; }; memoryFields?: (string)[]; }
109
111
  type SpeciesProgramsInput = unknown;
110
112
  interface SpeciesPrograms { page: (SpeciesData)[]; native: (SpeciesData)[]; program?: SpeciesProgramData; spawns?: v.InferOutput<typeof SpawnTablesSchema>; hunt?: NativeHuntRows; }
111
113