Repair independent idle state clocks and validate full avatar index

This commit is contained in:
zenord
2026-10-13 06:58:39 +08:00
parent c4ddf8964f
commit 97f87e2409
5 changed files with 27226 additions and 0 deletions
+43
View File
@@ -465,3 +465,46 @@ no APK assembled or installed.200 GLES goldens and gateway97 pass/1 Silero skip
retained prior evidence, not rerun for this diagnostics-only milestone. Code17 APK,
exact pin and live0.8 Qwen/TTS/allowlist are unchanged.
Handoff: **REJECTION_FIELD_REPORT_READY_AWAIT_CANDIDATE02_EXACT_SHA**.
### Full index04 metadata recovery (2026-10-13; awaiting new Pi pin)
Clean remote-matched baseline `c4ddf8964f7235628c529531a9bd120ba57b0d95`.
Source candidate03 exact SHA `3a6d43cc9bf810077c55652b1fb7876cb0b3b2767ae5cbcc93fe5e9e19825781`
and all5061 source inventory files were verified before/after independent copying.
`scripts/repair-idle-state-clock.py` changed only the two idle runtime manifests'
ten states' frameCount/ptsUs, from body97 timing to authored12/6-frame24fps500/250ms
curves. Cause reported by owner: build_idle_ownmouth.py assigned body N/PTS to every
mouth state. Body/patch/movie/audio/alpha/anchors/review flags remain unchanged.
5059 original files have identical hashes; original index and both runtime metadata
backups plus exact diff/provenance remain in the ignored recovery payload.
New independent directory:
`.runtime/avatar-imports/a01-expression-action-v1/code-recovery-full-index-04/`.
Exact index SHA `987e125a7d7a2cde99121b5f5246c82f4dbe36c4899d3d49eaffd1a68bafb887`;
exact bytes archived in `docs/avatar-manifests/a01-code-recovery-full-index-04.json`.
Full production gate passed:5065 indexed files,5 own bodies97/97/49/97/97,
8 own25-frame×5-layer one-shot bridges,13 edges,2 H264+AAC dance clips241 frames.
All file hashes/bytes, full decode, PTS/duration/fps, PNG shape, body/patch/bridge
bindings and actual production Kotlin admission passed. RGBA10,911,120 bytes within
8MB/runtime/32MB combined.3222 runtime-referenced files enter later APK;1844 inventory
review/backup files are excluded. Body plus bridge PNG count3185. Dance video duration
10,041,667us, presented audio end10,000,000us, decoded AAC tail10,005,333us; finite
PCM480000 stereo frames each. Completion still waits actual player release+restored
A, not a10s timer. Existing driver actually schedules neutral idle via own-mouth
edges, avoids repeats, preserves TALK/model-expression/action priority; no playback
or gateway source change was needed. Current source fixtures confirm these paths.
Fresh9 JVM/UI entry points and27 packaging/diagnostic/recovery tests passed. Recovery
tests cover independent N/curve clocks, exact diff/source protection, unknown timing
rejection and deterministic repeat. Existing public service calling path evidence
retained, no further ASR/LLM/TTS or paid calls. No new model/config/deployment/restart.
Full gate: `logs/action-emotion/full-index04-production-01/bundle-gate.json`.
Review HTTP tar bytes/hash/sidecar verified:
`http://192.168.31.124:8080/avatar-full-index04-review-987e125a7d7a/code-recovery-full-index-04.tar.gz`
SHA `91798babafd4af624b71180c3d47df6964b4e70725c3d0641da5a9fc835a27f0`,121689786 bytes.
The same HTTP directory exposes manifest.json, machine-gate.json and repair-report.json.
No source pixels generated/changed; additionalAIcalls0/fees0. Code17 remains rollback;
no code18 APK or new capability until independent Pi exact pin. Naturalness, human
listening, actor-no-speech, device/GPU/cognitive≤1s remain un-certified/not_run;
role expression exit wait remains up to2–4s plus~1s bridge. Gateway0.8/Qwen/TTS/live
allowlist unchanged. Handoff: **FULL_INDEX_REPAIRED_PARSER_PASSED_AWAIT_PI_PIN**.
+10
View File
@@ -178,6 +178,16 @@ curve count/PTS comparisons additionally list all such mismatches, and both acti
stream layouts are inspected even if a runtime fails. At most128 rejection rows are
written. No rejection found is not a full decode/hash/cache admission; the existing
package-avatar-emotion.py full gate and external Pi pin remain mandatory.
Deterministic metadata recovery, authorized only in the code owner's independent directory:
`python3 scripts/repair-idle-state-clock.py --source-manifest <exact-source-index>/manifest.json --source-sha <exact-sha> --output <new-code-recovery-directory>`.
It verifies the entire source inventory, copies independently, and fixes only the
two idle runtime states' frameCount/ptsUs from their authored6/12-frame24fps alpha
curves. Body N/PTS, own patches, media, alpha, anchors and approval flags are unchanged.
Original metadata backups and the exact field diff are indexed as review-only files;
the production packer includes only runtime-referenced payload in any later APK.
The recovery grants no approval: run the full gate, review the new exact index SHA,
then configure capabilities/import through the separately approved release process.
- 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.
File diff suppressed because it is too large Load Diff
+110
View File
@@ -0,0 +1,110 @@
#!/usr/bin/env python3
"""Copy an exact task index and repair only two idle runtime state clocks, never body/media."""
import argparse
import copy
import importlib.util
import json
from pathlib import Path
import shutil
ROOT=Path(__file__).resolve().parents[1]
spec=importlib.util.spec_from_file_location('pack',ROOT/'scripts/package-avatar-emotion.py')
pack=importlib.util.module_from_spec(spec);spec.loader.exec_module(pack)
IDS={'idle-breathe-01','idle-microshift-01'}
def repair_states(runtime):
repaired=copy.deepcopy(runtime);changes=[]
states=repaired['mouthStates']
pack.require(runtime['schemaVersion']==2 and len(states)==5 and
{s['id'] for s in states}=={'idle','opening','talk1','talk2','end-talk'},'known schema2 state contract required')
for i,state in enumerate(states):
n=len(state['globalAlphaByFrame']);bridge=state['id'] in ('opening','end-talk')
pack.require(n==(6 if bridge else 12) and state['fpsNumerator']==24 and state['fpsDenominator']==1 and
state['durationMs']==(250 if bridge else 500),'repair only authored 24fps six/twelve-frame curves')
pts=[(frame*1_000_000+12)//24 for frame in range(n)]
pack.require(n*1_000_000==state['durationMs']*1000*24,'state duration/curve mismatch')
for field,value in (('frameCount',n),('ptsUs',pts)):
if state[field]!=value:
changes.append({'field':f'mouthStates[{i}].{field}','before':state[field],'after':value})
state[field]=value
if 'durationUs' in state:
pack.require(state['durationUs']==state['durationMs']*1000,'unexpected authored durationUs; no speculative repair')
# Body, patches, alpha, routing, anchors and review flags are byte-for-byte JSON values unchanged.
for key in runtime.keys()-{'mouthStates'}:pack.require(repaired[key]==runtime[key],'non-state metadata changed')
for before,after in zip(runtime['mouthStates'],states):
pack.require({k:v for k,v in before.items() if k not in ('frameCount','ptsUs')}==
{k:v for k,v in after.items() if k not in ('frameCount','ptsUs')},'authored state content changed')
return repaired,changes
def write_json(path,value):
with path.open('x') as f:json.dump(value,f,ensure_ascii=False,indent=2);f.write('\n')
def repair(source,expected,output):
source=Path(source).resolve(strict=True);output=Path(output).resolve();root=source.parent
pack.require(not output.exists() and not output.is_relative_to(root) and not root.is_relative_to(output),'independent new output required')
pack.require(pack.file_sha(source)==expected,'source index drift')
original=pack.read_json(source);index=copy.deepcopy(original);files=original['files']
pack.require(original['schemaVersion']==2 and original['packId']=='a01-expression-action-v1' and
isinstance(files,list) and len(files)<=20000,'task index/list inventory required')
pack.require(len({r['path'] for r in files})==len(files) and all(r['path']!='manifest.json' for r in files),'duplicate/root inventory entry')
rows=[r for r in index['conversationPackages'] if r['id'] in IDS]
pack.require({r['id'] for r in rows}==IDS and len(rows)==2,'exact two idle rows required')
prepared=[]
for row in rows:
ref=row['runtimeManifest'];path=pack.locate(root,ref['path'])
pack.require(pack.file_sha(path)==ref['sha256'],'runtime reference drift')
runtime=pack.read_json(path);repaired,changes=repair_states(runtime)
pack.require(changes,'source already repaired; no redundant recovery')
prepared.append((row,runtime,repaired,changes))
# All source inventory hashes/bytes pass before any output is created.
for row in files:
path=pack.locate(root,row['path'])
pack.require(path.stat().st_size==row['bytes'] and pack.file_sha(path)==row['sha256'],'source indexed drift: '+row['path'])
output.mkdir(parents=True)
for row in files:
dest=output/row['path'];dest.parent.mkdir(parents=True,exist_ok=True)
shutil.copyfile(pack.locate(root,row['path']),dest)
backup=output/'docs/code-recovery-original-metadata';backup.mkdir(parents=True)
shutil.copyfile(source,backup/'candidate03-index.json')
repaired_rows=[];changed_paths=set()
for row,runtime,repaired,changes in prepared:
ref=row['runtimeManifest'];dest=output/ref['path']
shutil.copyfile(pack.locate(root,ref['path']),backup/(row['id']+'-runtime.json'))
# These are our independent copied metadata files, never owner files/hardlinks.
with dest.open('w') as f:json.dump(repaired,f,ensure_ascii=False,indent=2);f.write('\n')
before=ref['sha256'];ref['sha256']=pack.file_sha(dest);changed_paths.add(ref['path'])
repaired_rows.append({'id':row['id'],'file':ref['path'],'before_sha256':before,'after_sha256':ref['sha256'],
'body_sha256':runtime['body']['sha256'],'body_frame_count':runtime['body']['frameCount'],'changes':changes})
unchanged=0
for row in files:
current=pack.file_sha(output/row['path'])
if row['path'] not in changed_paths:
pack.require(current==row['sha256'],'copied payload changed: '+row['path']);unchanged+=1
pack.require(pack.file_sha(pack.locate(root,row['path']))==row['sha256'],'owner source drift during copy')
pack.require(pack.file_sha(source)==expected,'source index changed during recovery')
provenance={'source_index_sha256':expected,'repair_script_sha256':pack.file_sha(Path(__file__)),
'scope':'only two runtime state frameCount/ptsUs and index references/inventory',
'repaired_runtimes':repaired_rows,'original_indexed_files':len(files),'original_files_unchanged':unchanged,
'original_files_changed':sorted(changed_paths),'media_patch_pixels_unchanged':True,
'state_clock_independent_of_body_clock':True,'additional_ai_calls':0,'known_fee_usd':0,
'production_parser':'not_run_by_repair','Pi_pin':'pending_new_exact_index_review','naturalness':'not_certified','device':'not_run'}
write_json(output/'docs/code-recovery-repair-report.json',provenance)
index['files']=[{'path':str(p.relative_to(output)),'sha256':pack.file_sha(p),'bytes':p.stat().st_size}
for p in sorted(output.rglob('*')) if p.is_file()]
write_json(output/'manifest.json',index)
return {'manifest':str(output/'manifest.json'),'manifest_sha256':pack.file_sha(output/'manifest.json'),
'indexed_files':len(index['files']),**provenance}
def main():
parser=argparse.ArgumentParser(description=__doc__)
parser.add_argument('--source-manifest',type=Path,required=True);parser.add_argument('--source-sha',required=True)
parser.add_argument('--output',type=Path,required=True);args=parser.parse_args()
result=repair(args.source_manifest,args.source_sha,args.output)
print(json.dumps({k:result[k] for k in ('manifest','manifest_sha256','indexed_files','original_files_unchanged','original_files_changed')},indent=2))
if __name__=='__main__':main()
+79
View File
@@ -0,0 +1,79 @@
"""Recovery diff, immutable source and independent mouth/body clocks; no paid/media generation."""
import copy
import importlib.util
import json
from pathlib import Path
import tempfile
import unittest
ROOT=Path(__file__).resolve().parents[2]
spec=importlib.util.spec_from_file_location('repair_clock',ROOT/'scripts/repair-idle-state-clock.py')
repair=importlib.util.module_from_spec(spec);spec.loader.exec_module(repair)
def broken_runtime(body_count=97):
ids=['idle','opening','talk1','talk2','end-talk']
states=[]
for name in ids:
n=6 if name in ('opening','end-talk') else 12
states.append({'id':name,'frameCount':body_count,'fpsNumerator':24,'fpsDenominator':1,
'durationMs':n*1000/24,'ptsUs':[(i*1_000_000+12)//24 for i in range(body_count)],
'globalAlphaByFrame':[0]*n,'entryMouthAnchor':'fixture_A','exitMouthAnchor':'fixture_B'})
return {'schemaVersion':2,'mouthStates':states,'body':{'frameCount':body_count,'sha256':'a'*64},
'patches':[{'frameIndex':i,'sentinel':'own-fixture'} for i in range(body_count)],'publishApproval':False}
class IdleRepairTests(unittest.TestCase):
def test_independent_state_clock_preserves_every_other_field(self):
for body_count in (25,49,97,121):
original=broken_runtime(body_count);snapshot=copy.deepcopy(original)
fixed,changes=repair.repair_states(original)
self.assertEqual(original,snapshot);self.assertEqual(fixed['body'],original['body'])
self.assertEqual(fixed['patches'],original['patches']);self.assertFalse(fixed['publishApproval'])
self.assertEqual(len(changes),10)
for before,after in zip(original['mouthStates'],fixed['mouthStates']):
n=len(before['globalAlphaByFrame'])
self.assertEqual(after['frameCount'],n);self.assertEqual(len(after['ptsUs']),n)
self.assertEqual(after['ptsUs'][0],0);self.assertLess(after['ptsUs'][-1],after['durationMs']*1000)
self.assertEqual(after['globalAlphaByFrame'],before['globalAlphaByFrame'])
self.assertEqual(after['entryMouthAnchor'],before['entryMouthAnchor'])
self.assertEqual(after['exitMouthAnchor'],before['exitMouthAnchor'])
self.assertEqual(repair.repair_states(fixed)[1],[])
def test_unknown_timing_rejected_without_guessing(self):
for key,value in (('fpsNumerator',30),('durationMs',501),('globalAlphaByFrame',[0]*13),('durationUs',123)):
data=broken_runtime();data['mouthStates'][0][key]=value
with self.subTest(key=key),self.assertRaises(ValueError):repair.repair_states(data)
def test_exact_copy_diff_backups_and_existing_destination_guard(self):
with tempfile.TemporaryDirectory() as temp:
root=Path(temp);source=root/'source';source.mkdir();files=[];packages=[]
for package in sorted(repair.IDS):
runtime_path=source/package/'manifest.json';runtime_path.parent.mkdir()
runtime_path.write_text(json.dumps(broken_runtime()))
packages.append({'id':package,'runtimeManifest':{'path':str(runtime_path.relative_to(source)),
'sha256':repair.pack.file_sha(runtime_path)}})
(source/'immutable-fixture.bin').write_bytes(b'exact nonmedia fixture bytes')
for path in sorted(source.rglob('*')):
if path.is_file():files.append({'path':str(path.relative_to(source)),'sha256':repair.pack.file_sha(path),'bytes':path.stat().st_size})
index={'schemaVersion':2,'packId':'a01-expression-action-v1','conversationPackages':packages,'files':files,'reviewStatus':'pending'}
manifest=source/'manifest.json';manifest.write_text(json.dumps(index));pin=repair.pack.file_sha(manifest)
output=root/'recovery';result=repair.repair(manifest,pin,output)
self.assertEqual(result['original_files_changed'],[str(r['runtimeManifest']['path']) for r in packages])
self.assertEqual((output/'immutable-fixture.bin').read_bytes(),(source/'immutable-fixture.bin').read_bytes())
self.assertEqual((output/'docs/code-recovery-original-metadata/candidate03-index.json').read_bytes(),manifest.read_bytes())
self.assertEqual(repair.pack.file_sha(manifest),pin)
for f in files:self.assertEqual(repair.pack.file_sha(source/f['path']),f['sha256'])
updated=json.loads((output/'manifest.json').read_bytes())
for row in updated['files']:
self.assertEqual(repair.pack.file_sha(output/row['path']),row['sha256'])
self.assertEqual((output/row['path']).stat().st_size,row['bytes'])
self.assertEqual(updated['reviewStatus'],'pending')
repeated=repair.repair(manifest,pin,root/'independent-repeat')
self.assertEqual(repeated['manifest_sha256'],result['manifest_sha256'])
with self.assertRaises(ValueError):repair.repair(manifest,pin,output)
with self.assertRaises(ValueError):repair.repair(manifest,'0'*64,root/'wrong-pin')
self.assertFalse((root/'wrong-pin').exists())
if __name__=='__main__':unittest.main(verbosity=2)