Skip to content

Add optional named clips to the character pack contract - #5

Open
rubenmarcus wants to merge 7 commits into
feat/character-pack-contract-20261108from
feat/pack-optional-clips-20261109
Open

rubenmarcus wants to merge 7 commits into
feat/character-pack-contract-20261108from
feat/pack-optional-clips-20261109

Conversation

@rubenmarcus

@rubenmarcus rubenmarcus commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

What

Characters may declare an optional animations.extra map of named clips beyond the states, for the upcoming movement/weapon/reaction/emote set:

  • Keys match ^[a-z][a-z0-9_]{1,40}$ and must be a fixed vocabulary name (strafe_left, run_back, reload_rifle, hit_front, knife_stab, victory, …) or an emote_ prefix with at least one suffix character. State names and the bare emote_ prefix are rejected, keeping the state and extra key spaces disjoint.
  • Each entry has exactly file, duration (positive seconds), loop, rootMotion and source; duration/loop/rootMotion are declared metadata for the runtime, the GLB stays authoritative for keyframes.
  • Extra files are declared in files under the animations.extra.<name> role, so missing/duplicate paths and the byte budget (extras included) are enforced structurally, before any payload is hashed.
  • Each extra GLB is validated like a state clip: it must contain an animation named exactly as its key, driving a meshy-28 bone.

Stacked on #3 (feat/character-pack-contract-20261108); vocabulary mirrored client-side in corosolto/client#1260.

Vocabulary extended to the converter library names

extraClipNames is now 68 names: coreExtraClipNames (23, unchanged) plus converterExtraClipNames — the 45 names proposed by the animation conversion library (feat/animation-conversion-20261109, tools/lib/animation-library.mjs PROPOSED_EXTRA_NAMES; each name is used by at least one key of its library/index.json):

  • 8-way diagonals as <gait>_<fwd|back>_<left|right>: walk_fwd_left/right, walk_back_left/right, run_fwd_left/right, run_left/right, run_back_left/right, sprint_fwd_left/right, sprint_left/right, sprint_back_left/right
  • Sprints: sprint, sprint_back
  • Crouched: crouchwalk_left/right/back(+diagonals), crouch_aim, crouch_pistol, crouch_turn_left/right
  • Turns: turn_left, turn_right
  • Jump phases: jump_start, jump_loop, jump_land, jump_pistol
  • Pistol/crouch fire: idle_aim, shoot_pistol, shoot_crouch, run_pistol, run_back_pistol
  • Deaths: death_front, death_right, death_headshot_front/back, death_crouch

Single source — note for the converter branch owner (feat/animation-conversion-20261109): tools/lib/animation-library.mjs currently defines its own CONTRACT_EXTRA_NAMES/PROPOSED_EXTRA_NAMES. When rebasing on this PR, replace both with an import of extraClipNames (and optionally converterExtraClipNames) from tools/lib/character-pack.mjs, and keep its check asserting assertExtraClipVocabulary({ converter: <its proposed names> }) so a proposal that outgrows the contract fails on its side too. Do not extend the name list in the converter branch; extend it here.

assertExtraClipVocabulary (in character-pack.mjs) enforces the equality: vocabulary == core ∪ converter, no duplicates, no state collisions, no pattern breaks.

Evidence

  • npm run check green: tools/checks/character-pack-check.mjs suite — valid fixture with 3 extras (incl. the converter name sprint_fwd_left), valid pack with 0 extras, and 16 extra-clip mutants rejected for the stated reason: unknown/state-colliding/bare-prefix/pattern-violating names, missing/duplicate/non-GLB/misnamed files, missing or mistyped entry fields, extras overflowing the byte budget, plus 4 vocabulary-parity mutants: a converter key missing from the vocabulary (vault_low), a name outside core+converter, a dropped core name, a duplicate entry.
  • Live parity assertion: PASS Extra clip vocabulary covers the conversion library (68 names = 23 core + 45 converter).
  • Docs: docs/character-pack.md — vocabulary by group (68 names), entry fields, validation rules, and the single-source import requirement for the converter.

Agent: Claude Code

Contract v3 — animation families (2026-11-09, third cycle)

Stacked commits a2ec8ff, 36557c0, 0930753. The converter (PR #7, character-clips@2) now emits per character states.glb (11 states), loco.glb (45), combat.glb (14), ceremony.glb (7) and emotes/<key>.glb (one per emote); the contract now accepts that layout next to the old one-file-per-clip one:

  • Several animations.<state> roles may share one states.glb (clip names = state names) and several animations.extra.<name> roles may share one family-pack file (clip names = keys). One role kind per file: state and extra roles never mix, and neither takes a non-animation role on the side.
  • Extras gain an optional family (loco|combat|ceremony|emote, schema enum) that must match clipFamily — a mirror of the converter's packFamily. Importing clip-pack.mjs is impossible here (that branch is stacked on this one), so the mirror is locked by a snapshot parity check: 83 names classified by the real packFamily (2026-11-09), with emotes → emote as the one vocabulary difference, plus a poisoned-mirror mutant. On rebase the converter should import clipFamily (and extraClipNames) from tools/lib/character-pack.mjs — single source.
  • Emote keys always keep one file per key; a shared family file must hold exactly one family.
  • The converter's real family GLBs use the EXT_meshopt_compression layout (buffer 0 = compressed stream in BIN + a virtual fallback buffer). readGlb gains allowMeshoptFallback for animation reads, with compressed stream ranges bounds-checked; the model read stays strict (its skin bytes are read raw).

Evidence: npm run check green; tools/checks/character-pack-check.mjs at 82 PASS — both layouts validate (incl. all 11 states in one states.glb and a meshopt-shaped family pack), strict readGlb still rejects the meshopt layout, and the new mutants are rejected for their stated reason: key missing inside the family pack, emote sharing a file (family or another emote), declared family mismatching the name, family outside the enum, one file mixing families, states pack missing a state clip, second buffer without the fallback marker, meshopt stream past the BIN chunk.

Real-pack fixture (local, not committed — no GLB in this repo)

Built from the actual converter output (local/anim-conv-20261109/legacy-out/capitao-caveira, model rig-blender-20261109/v4, sha-verified against the converter manifest) with the v3 family layout: 14 files, 11 states + 74 extras (45 loco + 14 combat + 7 ceremony + 8 emotes, family declared on every key):

PASS character/capitao-caveira@0.2.0: schema, 14 files and hashes are valid; meshy-28 skin, 4905/15000 triangles, 4596362/8388608 bytes, 11 state clips

Byte budget of a full pack — no raise needed

Measured full pack (capitao-caveira, all families + 1 preview): 4,596,362 bytes = model 3,051,460 + states 136,764 + loco/combat/ceremony 943,128 + emotes 208,600 + preview 256,410. Worst case across the rig pipeline outputs (largest model 4,495,584 + same 1,288,492 animation bytes + ~0.3 MB previews) ≈ 6.1 MB. Both current ceilings hold: the schema maximum budgets.bytes ≤ 16,777,216 (3.7× headroom over the fixture) and the 8,388,608 guidance in docs/character-pack.md (≥27% headroom at worst case). Proposal: keep the limits unchanged — 8,388,608 declared / 16,777,216 ceiling. No raise character pack byte budget commit was added because nothing needs raising; if the owner prefers a raised explicit budget anyway, that is a one-line change on top.

Characters may now declare an animations.extra map of named clips beyond
the states: fixed vocabulary names (locomotion, weapon handling, damage
reactions, melee, round outcomes) or an emote_ prefix with a suffix. Keys
match ^[a-z][a-z0-9_]{1,40}$; each entry carries file, duration, loop,
rootMotion and source. Extra files are declared in files under the
animations.extra.<name> role, so duplicates, missing paths and the byte
budget (extras included) are enforced before any payload is hashed, and
each extra GLB must contain an animation named exactly as its key.

Agent: Claude Code
Signed-off-by: rubenmarcus <rubenmarcus.dev@gmail.com>
The valid fixture now ships two extra clips (a vocabulary name and an
emote_ name) and a no-extras pack stays valid. Twelve new mutants cover
the contract: unknown, state-colliding, bare-prefix and pattern-violating
names; missing, duplicated, shared, non-GLB and misnamed clip files;
entries with missing or mistyped fields; and extras pushing the pack over
its byte budget.

Agent: Claude Code
Signed-off-by: rubenmarcus <rubenmarcus.dev@gmail.com>
Adopt the 45 names the animation conversion library proposes (branch
feat/animation-conversion-20261109, PROPOSED_EXTRA_NAMES; every name is
used by at least one key of library/index.json): 8-way walk/run/sprint
diagonals, sprint gaits, crouched locomotion and aim, standing turns,
jump phases, pistol variants and death variants.

extraClipNames is now coreExtraClipNames (23) plus
converterExtraClipNames (45, sorted to diff against the converter's own
sorted export). assertExtraClipVocabulary enforces the single source:
the vocabulary must equal the core set plus the converter set, with no
duplicates, state collisions or pattern breaks. The converter must
import extraClipNames from this module instead of keeping its own copy
(noted in docs/character-pack.md).

Agent: Claude Code
Signed-off-by: rubenmarcus <rubenmarcus.dev@gmail.com>
The synthetic fixture now carries a converter-named extra
(sprint_fwd_left) alongside strafe_left and emote_danca, proving the new
names validate end to end through the pack contract. New check cases:

- PASS: assertExtraClipVocabulary on the real exports (68 names = 23
  core + 45 converter)
- Mutant: a converter key outside the vocabulary (vault_low) fails for
  the missing-name reason
- Mutant: a vocabulary name outside the core and converter sets
- Mutant: a dropped core name
- Mutant: a duplicate vocabulary entry

Agent: Claude Code
Signed-off-by: rubenmarcus <rubenmarcus.dev@gmail.com>
rubenmarcus added a commit that referenced this pull request Nov 9, 2026
…abulary

The converter imports extraClipNames from tools/lib/character-pack.mjs instead of keeping its own copy.

Agent: Claude Code
Signed-off-by: rubenmarcus <rubenmarcus.dev@gmail.com>
…ract

The animation converter now emits per character one GLB per family
(states, loco, combat, ceremony) plus one GLB per emote. The contract
accepts that layout without dropping the per-state/per-clip one:

- several animations.<state> roles may share one states pack whose clip
  names are the state names, and several animations.extra.<name> roles
  may share one family-pack file whose clip names are the keys; a file
  can never mix state and extra roles, and emote keys always keep one
  file per key;
- extra entries gain an optional family field (loco|combat|ceremony|
  emote) that must match clipFamily, a mirror of the converter's
  packFamily (that branch is stacked on this one, so the mirror is
  proven against a snapshot of its answers instead of an import);
- every key must exist as an animation name inside its shared GLB, and
  shared animation GLBs are read once per file during validation.

Agent: Claude Code
Signed-off-by: rubenmarcus <rubenmarcus.dev@gmail.com>
The fixture now carries a loco family pack shared by two extras next to
a per-file extra and proves both layouts valid, plus a states.glb pass
case. New rejections, each for its stated reason: a key missing inside
the family pack, an emote sharing any file (family or another emote), a
declared family mismatching the clip name, a family outside the enum,
one file mixing clip families, and a states pack missing a state clip.
A snapshot parity table locks clipFamily to the converter's packFamily
answers (83 names, emotes mapped to the contract family emote), with a
poisoned-mirror mutant.

Agent: Claude Code
Signed-off-by: rubenmarcus <rubenmarcus.dev@gmail.com>
The real family GLBs (legacy-out capitao-caveira, character-clips@2)
store buffer 0 as the EXT_meshopt_compression stream in the BIN chunk
plus a virtual fallback buffer for the uncompressed view sizes, which
the strict one-self-contained-buffer rule rejected. readGlb gains
allowMeshoptFallback: animation reads accept that layout with the
compressed stream ranges bounds-checked against the BIN chunk, while
the model read stays strict because its skin bytes are read raw.
Proved on the real pack (14 files, 4596362 bytes, 11 states, 74 extras
across loco/combat/ceremony/emotes) and with synthetic cases: a
meshopt-shaped family pack validates, the strict default still rejects
it, a second buffer without the fallback marker is refused, and a
stream past the BIN chunk is out of bounds.

Agent: Claude Code
Signed-off-by: rubenmarcus <rubenmarcus.dev@gmail.com>
@rubenmarcus

Copy link
Copy Markdown
Member Author

Local verification on head 0930753 (Linux, Node 26.12.1): npm ci PASS; npm run check PASS (98 PASS lines); npm run check:asset-gen PASS (4 PASS lines); npm run smoke:pack PASS (68 PASS lines). Blender 5.2.0 LTS is installed; these synthetic gates do not establish a real-asset or visual approval.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant