Files
baji-vc/docs/AVATAR_PACK_V2_CONTRACT.md
T

174 lines
12 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Action/emotion runtime v2 contract
Development baseline: `e3ee004d29ac472997a813fbdb641ba4983fa5ce` (clean, remote main matched).
This contract reserves the interface; it grants no naturalness/publication approval.
Asset owner: Localv-i-asset w8:p1. Code/importer owner: baji-action-emotion.
No paid calls by code owner. Existing owner directories/previews are read only.
Deliver a new directory, `manifest.json` exact bytes SHA256 and preview/evidence paths.
Manifest `schemaVersion:2`, `identityId:a01`, `packId`, `fallbackPackageId`,
`conversationPackages`, `edges`, `actions`, `files`. Paths are relative without `..`/URLs;
every file has SHA256/bytes. Pi approval pins exact manifest SHA outside the manifest.
Self-authored approved/status fields never enable runtime capabilities.
Each conversation package: unique `id`, `emotion:neutral|happy|sad`,
`visualIntensity:0|1`, `mouthBodySha256`, `runtimeManifest:{path,sha256}` referencing runtime04 format
(continuous body + own actual N PTS registered frames × five RGBA aperture levels,
own curves/anchors/coordinates). Body SHA, frame count and decoded PTS bind every
mouth track to that exact body; no cross-body patches/masks/coordinates reuse.
Happy/sad are slightly only, including model intensity2. Body is silent.
No layer means whole-package fallback, never a neutral mouth over another body.
Pi selected **1.1 source pixels for the candidate**, based on fixed comparisons;
dynamic naturalness review is still pending. Do not treat a numeric gap as approval.
Edges: `id`, `from`, `to`, `fromAnchor`, `toAnchor`, `fromFrame`, `toFrame`,
`clip:{path,sha256,width,height,frameCount,ptsUs,durationUs,fpsNumerator,fpsDenominator,hasAudio:false}`.
Edges also bind `fromPtsUs` and `toPtsUs` to the exact source/target body frame;
`fromFrame` must be in that source package's `legalExitFrames`.
Each package declares `entryAnchor`, `exitAnchor`, `legalExitFrames`, `loopEdge`.
Frame indices/PTS are actual decoded values. Every changed body phase requires a
reviewed edge, no arbitrary alpha cut. Supply dense seam frames, real-speed loops
and full-scale/close previews, not just matching endpoints.
Actions may be `[]` for a partial conversation-only index. Dance requires exactly
`asset_01`, `asset_02`, `kind:dance`, `mouthAllowed:false`,
`disallowTALK:true`,
`entryAnchor:A`, `returnAnchor:A`, `clip` with file SHA/dimensions/frameCount/PTS/
duration/audio track metadata, `audioEndUs`, `reviewEvidence`.
Current player accepts a **single complete video including entry, music dance and
return A**. Separately hashed sequential segments are not yet supported. Music must actually
exist, end naturally, and actor must not talk/sing. Source/music provenance and
job/fee ledger stay in owner storage; Git stores metadata only.
Client advertises only Pi-pinned, machine-validated packs: `action_protocol:1`,
`action_pack_sha256`, `action_kinds:[dance]`. Server has independent exact SHA
allowlist/duration; unknown clients/packs get no actions. Server creates opaque
action_id, connection generation/turn binding and TTL; never accepts URLs from LLM.
`action.plan` is emitted only after pre-reply playback.drained. Client stops and
confirms AudioRecord before playing; `action.status` started/completed/cancelled/
failed echoes action_id/turn_id. Completed requires video_ended, audio_stopped,
idle_restored, mic_stopped, and minimum reviewed duration elapsed. Settings cancel,
background, disconnect, new turn and expiry discard the after reply.
Asset handoff required first: slight happy/sad TALK samples and own runtime04
mouths/entry-exit evidence. Pi reviews exact manifest + timed previews; only then
expand idle variants and two music dances. Gate1 and deterministic mock traces
cannot certify naturalness or device AudioRecord/GPU/≤1s perception.
Runtime selection keeps `selectedEmotion/selectedIntensity` (model) distinct from
`visualEmotion/visualIntensity/packageId/degraded/reason` (admitted visual). User
camera cues are independent and never select these role packages. Production
runtime04 parser: `app/src/main/java/com/gorios/lanvoice/avatar/ContinuousAvatarManifest.kt`;
v2 index parser: `app/src/main/java/com/gorios/lanvoice/avatar/EmotionActionManifest.kt`.
Each package should use `packId:a01-expression-action-v1-<packageId>-runtime-04`;
New per-package runtime manifests use **schemaVersion:2**; only the old neutral
runtime03/04 schemaVersion1 retains its fixed97@24 constraints. Each new body's
`frameCount:N`, `durationUs`, `fpsNumerator/fpsDenominator`, **`ptsUs:[actual decoded
presentation timestamps]`** are mandatory. No truncation/padding to97, no neutral
track reuse. Counts121/49 and rational frame rates are supported independently.
Current GLES shape remains480×848 (new shapes require renderer extension).
N is bounded2..720, fps1..60, duration0.1..30s; body PTS starts0, strictly increases,
remains below duration and agrees with measured duration/nominal fps within one
nominal frame. Nonuniform actual PTS is accepted within two nominal frame intervals.
Machine gate must compare decoded PTS/duration to declarations, not infer PTS.
`patchFormat.bodySha256` must equal `body.sha256`; `patches` has exactlyN entries,
each `frameIndex:i`, `ptsUs:body.ptsUs[i]`, own coordinates/mask and five independent
level paths/hashes. Patch format remains straight RGBA8, [0,.25,.5,.75,1]; nearest
level, nonzero opacity1, zero bypass. Each patch≤128×128, totalRGBA≤8MB/runtime;
all packages combined≤32MB, ≤12packages. These are admission bounds, not GPU proof.
Each of the five mouth states supplies own actual `ptsUs`, `frameCount`, fps ratio,
`durationMs` (100..1000), alpha values and A/B anchors; curve timing no longer
assumes24fps. Runtime04 mouthStates/stateRouting names and anchor rules stay intact.
Entry/return bridges carry actual decoded frame PTS; `audioEndUs` records measured
last audio timestamp, completion also waits actual media stop and restored A.
Current asset snapshot: happy/sad001 sources each actually97 frames; sad002 must
be measured independently. 121/49 are compatibility test counts, not a claim about
those files. The happy-01 draft hash
`518865589fcff36259b864226cdc9651f742d6f56f3b58eeb98f241ef03d48e3`
still used schema1/`a01-slight-happy-01`/`body.framePTSUs` at the read-only check;
it is rejected, not silently relabeled or modified. Export schema2, packId
`a01-expression-action-v1-happy-01-runtime-04`, `body.ptsUs`,
`patchFormat.bodySha256`, and each mouth state's `ptsUs`. Use the same format for
sad/neutral, independently measured. A frame0 enter bridge is legal only when
its source declares frame0 in `legalExitFrames`; do not inherit old last-frame exits.
Read-only handoff check (new evidence file, does not import/activate):
`python3 scripts/check-avatar-runtime.py --manifest <runtime>/manifest.json --sha256 <exact-candidate-sha> --output logs/action-emotion/<new-evidence>.json`.
It checks file hashes, complete video decode, actual PTS/duration/fps, PNG RGBA
shape/cache and production Kotlin admission. It rejects concurrent file drift.
Deliver corrected runtime paths/hashes plus complete index hash, reviewed loop/
enter/return clip paths/hashes, timed seam previews and Pi's external exact pin.
Conversation planning retains clip metadata and assigns each bridge execution a
unique serial; stale completion cannot authorize a later bridge with the same id.
MainActivity now uses the real multi-pack/bridge/music driver; capability activation
still requires the external exact index pin and file admission.
Next pin / asset handoff (media-wiring stage, no activation):
- A partial neutral+happy index is sufficient; sad can follow in a later pinned index.
Each included package needs its own schema2 runtime04 and actual N×5 data;
an independently hash-validated legacy neutral runtime04 is also supported.
- happy v2 exact SHA `8d4e56e356d0da3ab9260c448c986fcdb2ef42b66a0dfba11f7bd5dbfeb81b2e`
passed read-only decode/hash/production-parser checks:97 actual PTS,485 PNGs,
1,617,000 RGBA bytes, body SHA
`232943dc11698c47d4d38c281b08ea87cfcbbd11263b107da59f154a84f4230f`.
Its empty legalExitFrames is not changed or treated as a reviewed exit.
- Index rows declare reviewed legalExitFrames (actual frame indices), loopEdge,
A entry/exit anchors and exact runtimeManifest path/hash. Index paths resolve
under `avatar/a01-expression-action-v1/`; runtime file paths under each runtime.
- Every package requires a loop edge. `nativeLoop:true` is only for a reviewed
same-body last→0 loop: clip has that body's exact SHA/PTS/duration. Otherwise
deliver an actual silent loop bridge; runtime plays that bridge rather than wraps.
- neutral→happy and happy→neutral require actual silent bridge clip metadata,
fromFrame/fromPtsUs and toFrame/toPtsUs bound to each own body. Frame0 exits
are allowed only with reviewed index legalExitFrames; target entry is preroll-
decoded and composed before the bridge reveals, regardless of different N/fps.
- For each later dance, supply sourcePackageId/returnPackageId equal to fallback,
sourceFrame/sourcePtsUs and returnFrame/returnPtsUs exact bindings. SourceFrame
must be a declared legal exit. The complete clip includes the reviewed departure
from that source and return to that target A frame, with actual PTS/duration,
hasAudio:true, measured audioEndUs, no TALK/singing and seam/music evidence.
- Supply full index bytes SHA, all referenced files plus SHA/bytes, preview paths
and Pi's independent exact index approval. A runtime-only SHA is not the index pin.
Do not fabricate bridges, exits, audio, naturalness or dance capability to fill gaps.
Bridge TALK extension (2026-10-13, stable optional field):
`edge.mouthRuntimeManifest:{path,sha256}` references a bridge-own schema2 runtime04.
Use packId `a01-expression-action-v1-<edgeId>-runtime-04`; relative runtime paths
resolve under its own manifest directory. Its body SHA/N/actual ptsUs/duration/fps/
480×848 shape must equal edge.clip exactly; the body path can resolve to a copy of
that unchanged bridge video. Every one of its N frames has five own source patches
(1.1 sourcepx candidate) and own coords/curves, never either endpoint's patches.
For the current four bridges N=25:125 own PNGs each, measured independently.
Optional `mouthAllowed:true` requires this runtime; missing runtime means no live
voice-session entry into that edge. Native loops reuse their existing body's layer
and must not declare another mouthRuntimeManifest. Non-native bridges are one-shot,
not looped regardless of runtime routing metadata. All conversation and bridge
runtime RGBA counts sum under32MB; each runtime remains bounded8MB/N720.
`actions:[]` remains no dance capability; ACTION mouthAllowed:false is unchanged.
The new p4a-combined-02 index, all runtime references and files inventory require a
new exact Pi pin; old000d04ea…5008 is only the old silent-bridge candidate pin.
Offline processing does not require new AI/body generation or paid calls.
P4b/P5 integration preflight (2026-10-13; no new asset schema):
- Idle variants are additional neutral/visualIntensity0 conversationPackages rows,
each with own runtimeManifest, loopEdge and real fallback↔variant edges. Live
variant entry/return bridges need their own mouthRuntimeManifest too. Idle
selection occurs after a completed neutral cycle, returns through fallback and
avoids consecutive repeats where two variants exist. Active TALK, queued model
expression and action have priority; happy/sad expression is retained when speech
ends. No random phase cuts, fixed TTS delay or new model tag is introduced.
- The read-only package-avatar-emotion.py gate now accepts actions:[] or the two
dance rows. It checks actual video N/PTS/fps/duration, exactly video+AAC without
attached cover, presented audioEndUs (excluding AAC encoder padding), full decode,
nonempty finite PCM/RMS/peak and inventory/body/patch bytes before Kotlin admission.
Reports keep dance_available:false until independent exact pin/capability release.
Dance import/publication is separately blocked pending gateway capability admission;
read-only checking is available now without activating or rewriting owner assets.
- All source/target frames bind the silent delivered body SHA/PTS, not an immutable
master with audio/cover. Count241 and approximate10s are not substitutes for
independently measured video duration, final video PTS and presented audio end.