@lunagerm-studio/video-cut-skill 0.0.0-stage → 1.0.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/README.md +13 -2
- package/package.json +12 -4
- package/skills/ai-video-opening/SKILL.md +62 -0
- package/skills/ai-video-opening/references/export-and-validation.md +9 -0
- package/skills/ai-video-opening/references/motion-and-layout.md +7 -0
- package/skills/ai-video-opening/references/series-cases.md +7 -0
- package/skills/blue-white-ui-motion/SKILL.md +30 -0
- package/skills/blue-white-ui-motion/agents/openai.yaml +2 -0
- package/skills/blue-white-ui-motion/references/review.md +25 -0
- package/skills/chengfeng-videocut-skills/LICENSE +201 -0
- package/skills/chengfeng-videocut-skills/NOTICE.md +27 -0
- package/skills/chengfeng-videocut-skills/README.md +265 -0
- package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255/SKILL.md +37 -0
- package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255/agents/openai.yaml +2 -0
- package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255/scripts/cut_video.sh +182 -0
- package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255/scripts/detect_en_stutter.js +49 -0
- package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255/scripts/generate_review.js +1484 -0
- package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255/scripts/generate_srt_for_video.sh +75 -0
- package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255/scripts/generate_subtitles.js +141 -0
- package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255/scripts/review_server.js +381 -0
- package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255/scripts/volcengine_transcribe.sh +224 -0
- package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255/scripts/watch_cut_done.js +86 -0
- package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255//347/224/250/346/210/267/344/271/240/346/203/257/1-/346/240/270/345/277/203/345/216/237/345/210/231.md +56 -0
- package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255//347/224/250/346/210/267/344/271/240/346/203/257/10-/345/210/240/351/231/244/351/243/216/351/231/251/345/210/206/345/261/202.md +44 -0
- package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255//347/224/250/346/210/267/344/271/240/346/203/257/11-/345/217/243/346/222/255/347/250/277/345/257/271/351/275/220.md +40 -0
- package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255//347/224/250/346/210/267/344/271/240/346/203/257/2-/350/257/255/346/260/224/350/257/215/346/243/200/346/265/213.md +30 -0
- package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255//347/224/250/346/210/267/344/271/240/346/203/257/3-/351/235/231/351/237/263/346/256/265/345/244/204/347/220/206.md +56 -0
- package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255//347/224/250/346/210/267/344/271/240/346/203/257/4-/351/207/215/345/244/215/346/243/200/346/265/213.md +77 -0
- package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255//347/224/250/346/210/267/344/271/240/346/203/257/5-/345/215/241/351/241/277/350/257/215.md +48 -0
- package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255//347/224/250/346/210/267/344/271/240/346/203/257/7-/350/277/236/347/273/255/350/257/255/346/260/224/350/257/215.md +32 -0
- package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255//347/224/250/346/210/267/344/271/240/346/203/257/9-/346/256/213/345/217/245/346/243/200/346/265/213.md +79 -0
- package/skills/chengfeng-videocut-skills//345/211/252/345/217/243/346/222/255//347/224/250/346/210/267/344/271/240/346/203/257/README.md +35 -0
- package/skills/chengfeng-videocut-skills//345/217/243/346/222/255/346/210/220/347/211/207/SKILL.md +32 -0
- package/skills/chengfeng-videocut-skills//345/217/243/346/222/255/346/210/220/347/211/207/agents/openai.yaml +2 -0
- package/skills/chengfeng-videocut-skills//345/217/243/346/222/255/346/210/220/347/211/207/references/artifact-contracts.md +168 -0
- package/skills/chengfeng-videocut-skills//345/217/243/346/222/255/346/210/220/347/211/207/scripts/animation_style.cjs +53 -0
- package/skills/chengfeng-videocut-skills//345/217/243/346/222/255/346/210/220/347/211/207/scripts/export_final_video.cjs +200 -0
- package/skills/chengfeng-videocut-skills//345/217/243/346/222/255/346/210/220/347/211/207/scripts/serve_range_preview.cjs +128 -0
- package/skills/chengfeng-videocut-skills//345/217/243/346/222/255/346/210/220/347/211/207/scripts/user_config.cjs +80 -0
- package/skills/chengfeng-videocut-skills//345/217/243/346/222/255/346/210/220/347/211/207/scripts/write_render_mode.cjs +149 -0
- package/skills/chengfeng-videocut-skills//345/217/243/346/222/255/346/210/220/347/211/207//347/224/250/346/210/267/351/205/215/347/275/256/default.json +4 -0
- package/skills/chengfeng-videocut-skills//350/207/252/350/277/233/345/214/226/README.md +23 -0
- package/skills/chengfeng-videocut-skills//350/207/252/350/277/233/345/214/226/SKILL.md +126 -0
- package/skills/continuous-collage-motion/SKILL.md +30 -0
- package/skills/continuous-collage-motion/agents/openai.yaml +4 -0
- package/skills/continuous-collage-motion/references/reference-motion.md +32 -0
- package/skills/continuous-collage-motion/references/shot-plan.md +31 -0
- package/skills/continuous-collage-motion/references/style-check.md +17 -0
- package/skills/table-video/LICENSES/ATTRIBUTION.md +31 -0
- package/skills/table-video/LICENSES/CC-BY-4.0.txt +396 -0
- package/skills/table-video/LICENSES/MIT.txt +21 -0
- package/skills/table-video/SKILL.md +32 -0
- package/skills/table-video/SOURCES.md +61 -0
- package/skills/table-video/agents/openai.yaml +2 -0
- package/skills/table-video/references/complete-motion.md +97 -0
- package/skills/table-video/references/examples/01_/344/270/244/346/256/265/346/274/224/347/244/272.md +73 -0
- package/skills/table-video/references/examples/02_/347/224/237/345/233/276/347/224/237/350/247/206/351/242/221/346/217/220/347/244/272/350/257/215/347/244/272/344/276/213.md +50 -0
- package/skills/table-video/references/examples/03_DESIGN/345/241/253/345/206/231/347/244/272/344/276/213.md +333 -0
- package/skills/table-video/references/examples/04_/350/277/236/347/273/255MG/346/255/243/345/217/215/350/277/207/347/250/213.md +101 -0
- package/skills/table-video/references/examples/05_/345/256/214/346/225/264/350/277/207/347/250/213/346/272/220/347/240/201.md +55 -0
- package/skills/table-video/references/examples/05_/346/205/242/351/225/234/345/244/264/344/270/216/345/220/214/346/236/204/345/233/276/345/233/236/345/275/222.md +35 -0
- package/skills/table-video/references/experience//345/255/227/345/271/225/344/270/216/345/260/201/351/235/242.md +30 -0
- package/skills/table-video/references/experience//345/275/225/345/261/217/345/211/252/350/276/221.md +31 -0
- package/skills/table-video/references/experience//346/211/213/345/212/250/347/224/237/345/233/276/347/224/237/350/247/206/351/242/221.md +53 -0
- package/skills/table-video/references/experience//350/247/206/350/247/211/345/217/231/344/272/213/344/270/216/350/277/236/347/273/255MG.md +102 -0
- package/skills/table-video/references/experience//351/225/234/345/244/264/346/216/250/350/277/233/344/270/216/350/275/254/345/234/272.md +178 -0
- package/skills/table-video/references/intake.md +84 -0
- package/skills/table-video/references/library.md +26 -0
- package/skills/table-video/references/motion-check-method.md +147 -0
- package/skills/table-video/references/planning.md +62 -0
- package/skills/table-video/references/production.md +70 -0
- package/skills/table-video/references/project-rules.md +26 -0
- package/skills/table-video/references/review-and-repair.md +64 -0
- package/skills/table-video/references/self-diagnosis.md +46 -0
- package/skills/table-video/references/sop/01_/345/277/253/351/200/237/345/274/200/345/247/213.md +55 -0
- package/skills/table-video/references/sop/02_/345/210/266/344/275/234SOP.md +77 -0
- package/skills/table-video/references/sop/03_/347/233/256/345/275/225/344/270/216/345/271/266/350/241/214/345/215/217/344/275/234.md +72 -0
- package/skills/table-video/references/sop/04_/351/252/214/346/224/266/344/270/216/350/277/224/344/277/256.md +146 -0
- package/skills/table-video/references/sop/05_/346/226/207/346/241/210/346/243/200/346/237/245_/345/217/257/351/200/211.md +55 -0
- package/skills/table-video/references/sop/06_/351/237/263/346/225/210/344/270/216/351/205/215/344/271/220_/345/217/257/351/200/211.md +138 -0
- package/skills/table-video/references/sop/07_/345/267/245/345/205/267/344/270/216/347/216/257/345/242/203.md +52 -0
- package/skills/table-video/references/sop/08_/346/235/245/346/272/220/344/270/216/350/256/270/345/217/257.md +36 -0
- package/skills/table-video/references/sop/09_DESIGN/345/273/272/347/253/213/344/270/216/346/240/241/351/252/214.md +52 -0
- package/skills/table-video/references/state-contract.md +267 -0
- package/skills/table-video/references/style-and-motion.md +163 -0
- package/skills/table-video/schemas/request.schema.json +44 -0
- package/skills/table-video/schemas/state.schema.json +140 -0
- package/skills/table-video/scripts/cli.mjs +35 -0
- package/skills/table-video/scripts/core.mjs +977 -0
- package/skills/table-video/scripts/gain-proof.mjs +48 -0
- package/skills/table-video/scripts/init-project.mjs +7 -0
- package/skills/table-video/scripts/motion-audit.mjs +589 -0
- package/skills/table-video/scripts/motion-check.mjs +345 -0
- package/skills/table-video/scripts/motion-gates.mjs +997 -0
- package/skills/table-video/scripts/motion-observation.cjs +204 -0
- package/skills/table-video/scripts/preflight.mjs +24 -0
- package/skills/table-video/scripts/process-locate.mjs +57 -0
- package/skills/table-video/scripts/render-motion-example.mjs +143 -0
- package/skills/table-video/scripts/save-reference-image.mjs +249 -0
- package/skills/table-video/scripts/schema.mjs +71 -0
- package/skills/table-video/scripts/stillness.mjs +386 -0
- package/skills/table-video/scripts/storage.mjs +328 -0
- package/skills/table-video/scripts/workflow.mjs +24 -0
- package/skills/talking-head-motion-workflow/SKILL.md +36 -0
- package/skills/talking-head-motion-workflow/agents/openai.yaml +4 -0
- package/skills/talking-head-motion-workflow/references/cinematic-motion-and-sync.md +72 -0
- package/skills/talking-head-motion-workflow/references/classic-ui.md +11 -0
- package/skills/talking-head-motion-workflow/references/history-coverage.md +50 -0
- package/skills/talking-head-motion-workflow/references/layered-assets-and-characters.md +39 -0
- package/skills/talking-head-motion-workflow/references/layout-references.md +41 -0
- package/skills/talking-head-motion-workflow/references/lens-shot-selection.md +138 -0
- package/skills/talking-head-motion-workflow/references/live-interface-motion.md +69 -0
- package/skills/talking-head-motion-workflow/references/motion-recipes.md +40 -0
- package/skills/talking-head-motion-workflow/references/mouse-meter2-case.md +113 -0
- package/skills/talking-head-motion-workflow/references/pop-collage.md +61 -0
- package/skills/talking-head-motion-workflow/references/portable-production.md +32 -0
- package/skills/talking-head-motion-workflow/references/production-requirements.md +85 -0
- package/skills/talking-head-motion-workflow/references/reference-library.md +41 -0
- package/skills/talking-head-motion-workflow/references/safe-areas-and-sound.md +47 -0
- package/skills/talking-head-motion-workflow/references/scene-illustrations.md +19 -0
- package/skills/talking-head-motion-workflow/references/sfx-presets.md +57 -0
- package/skills/talking-head-motion-workflow/references/style-13-github-production.md +33 -0
- package/skills/talking-head-motion-workflow/references/style-13-scene-performance.md +76 -0
- package/skills/talking-head-motion-workflow/references/style-presets.md +111 -0
- package/skills/talking-head-motion-workflow/references/table-video-spatial-mg.md +36 -0
- package/skills/talking-head-motion-workflow/scripts/extract_docx.py +19 -0
- package/skills/talking-head-motion-workflow/scripts/generate_foley.py +93 -0
- package/skills/talking-head-motion-workflow/scripts/render_sfx.py +135 -0
- package/skills/video-production-review/SKILL.md +30 -0
- package/skills/video-production-review/agents/openai.yaml +2 -0
- package/skills/video-production-review/references/episode-review-desk.md +30 -0
- package/skills/video-production-review/references/motion-adjustment-review.md +21 -0
- package/skills/video-production-workflow/SKILL.md +76 -0
- package/skills/video-production-workflow/agents/openai.yaml +2 -0
- package/skills/video-production-workflow/references/table-video-ep09.md +17 -0
- package/skills/video-production-workflow/scripts/check_motion_project.py +83 -0
- package/skills/video-reference-analysis/SKILL.md +32 -0
- package/skills/video-reference-analysis/agents/openai.yaml +2 -0
- package/skills/video-reference-analysis/references/case-format.md +95 -0
- package/skills/video-reference-analysis/references/production-method.md +21 -0
- package/skills/video-reference-analysis/scripts/library.py +371 -0
- package/skills/video-resource-access/SKILL.md +35 -0
- package/skills/video-resource-access/online.enabled +1 -0
- package/skills/video-resource-access/scripts/asset_client.py +159 -0
- package/skills/video-resource-access/scripts/remote_library.py +50 -0
- package//345/256/211/350/243/205/350/257/264/346/230/216.txt +5 -0
|
@@ -0,0 +1,589 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// MIT. Deterministic engineering samples, never pixel tracking or visual acceptance.
|
|
3
|
+
// Adapter exportAudit() returns this schema; intervals/IDs must derive from the render timeline.
|
|
4
|
+
// {schemaVersion:1,fps,duration,viewport:{width,height},sourceFiles:[path],videoFile:path,
|
|
5
|
+
// coverage:{basis:'render-state-final-screen',objectIds:[id],scope:string,
|
|
6
|
+
// notApplicable?:{checkpoints?:{sourceFile,anchor,reason},relays?:{sourceFile,anchor,reason}}},
|
|
7
|
+
// frameAt(seconds):{objects:[{id,x,y,width,height,opacity,rotation?,contentVersion?,d1Category?,
|
|
8
|
+
// parentId?,localGeometry?:{x,y,width,height,rotation?},screenFixed?:boolean,
|
|
9
|
+
// observation?:{state:'visible'|'hidden'|'unknown',reason,visibleBounds?,basis?},hotspot?:{x,y},
|
|
10
|
+
// process?:{maskProgress?,pathProgress?,morphProgress?,occlusionProgress?},
|
|
11
|
+
// replacement?:{kind:'geometry'|'mask'|'path'|'morph'|'occlusion'|'source-copy',progress,fromVersion,toVersion}}],camera?:{cx,cy,z},
|
|
12
|
+
// semantic?:{[objectId]:string|number|boolean}}, // legacy scalar semantic[ID] is a contentVersion fallback
|
|
13
|
+
// frameAt may also return renderedObjectIds from the actual production recorder; omitted draw IDs are gaps.
|
|
14
|
+
// observation is verified through the shared recorder in this process, never by an author state/basis string.
|
|
15
|
+
// Legacy/custom/serialized observations retain coordinates but painted visibility stays unknown.
|
|
16
|
+
// sourceLinks?:[{id,sourceObjectId,targetObjectId,time,sourceTime?,sourceAnchor?:[x,y],targetAnchor?:[x,y],evidence}],
|
|
17
|
+
// actions:[{id,objectId,start,end,kind:'transfer'|'camera'|'realtime'|'reveal'|'process',channels?,motionGate?:'anticipation',exception?}],
|
|
18
|
+
// checkpoints:[{id,time,objectIds:[id],role:'pass'|'hold'|'cut',exception?}],
|
|
19
|
+
// relays:[{id,fromAction,toAction,motionGate?:'follow'|'rigid-feedback',exception?}]}
|
|
20
|
+
// process actions reuse production actions and measure localGeometry channels or actual process progress.
|
|
21
|
+
// parentId is the production container ID; localGeometry for parts excludes that parent's transport.
|
|
22
|
+
// Neither declared parts nor sampled changes prove the script's semantic coverage or perceptual strength.
|
|
23
|
+
// Exceptions: {kind:'reading'|'rhetorical'|'real-dependency'|'real-time'|'cut',
|
|
24
|
+
// evidence:{sourceFile:path,anchor:exactSourceSubstring,reason:string}}
|
|
25
|
+
// They document attributable intent, not automatic proof of a necessary hold.
|
|
26
|
+
// d1Category on each object: mg | overlay | subtitle-cue | source-footage | data-readout.
|
|
27
|
+
// Only a consistently declared subtitle-cue/source-footage is excluded from all D1 checks.
|
|
28
|
+
// data-readout excludes content identity updates only; its designed lifecycle and source links remain checked.
|
|
29
|
+
// Missing, unknown or varying categories do not exempt. Declarations do not prove source authenticity.
|
|
30
|
+
// Packaging overlays require their own IDs/category; a source-footage classification never propagates to them.
|
|
31
|
+
// Classification excludes only D1 lifecycle/identity/target-source-link checks, never trajectory/checkpoint/relay checks.
|
|
32
|
+
// contentVersion identifies the actual rendered text/identity; omit only when not exposed (reported as uncovered).
|
|
33
|
+
// process/replacement progress MUST be read from actual production masks/paths/morphs/occlusion, not an invented ramp.
|
|
34
|
+
// localGeometry excludes inherited camera motion. Without it, centered camera inversion is a review-only inference.
|
|
35
|
+
// sourceLinks mean same-location split/copy origin: compare actual source and first visible target anchor, not intended coordinates.
|
|
36
|
+
// Scene cuts apply only with evidence and the complete visible object set; an element-local cut cannot waive a pop.
|
|
37
|
+
// Empty checkpoints/relays need coverage.notApplicable evidence or remain incomplete; actions cannot be waived.
|
|
38
|
+
// Constant individual channels are review clues. Ordinary transfer/camera hard findings use combined screen-point speeds.
|
|
39
|
+
import fs from 'node:fs';
|
|
40
|
+
import path from 'node:path';
|
|
41
|
+
import crypto from 'node:crypto';
|
|
42
|
+
import {pathToFileURL,fileURLToPath} from 'node:url';
|
|
43
|
+
import observation from './motion-observation.cjs';
|
|
44
|
+
const {visibleState,recordedFrameState,measureFrameMotion,inspectActionCoverage}=observation;
|
|
45
|
+
const sha=b=>crypto.createHash('sha256').update(b).digest('hex');
|
|
46
|
+
const finite=(v,label)=>{if(!Number.isFinite(v))throw Error('Expected finite '+label);return v;};
|
|
47
|
+
const nonempty=(v,label)=>{if(typeof v!=='string'||!v.trim())throw Error('Missing '+label);return v;};
|
|
48
|
+
const uniq=(xs,label)=>{if(!Array.isArray(xs)||new Set(xs).size!==xs.length)throw Error('Invalid/duplicate '+label);return xs;};
|
|
49
|
+
const channels=['x','y','width','height','opacity','rotation'];
|
|
50
|
+
const processChannels=['maskProgress','pathProgress','morphProgress','occlusionProgress'];
|
|
51
|
+
const localChannels=['x','y','width','height','rotation'];
|
|
52
|
+
const EPS={positionPx:1e-5,velocity:1e-3,relative:1e-6,derivativeStep:1e-4,cruiseIntervals:6};
|
|
53
|
+
// D1 locator tolerances reject numerical noise; exceeding one never certifies perceptual quality.
|
|
54
|
+
const D1={geometryProcessPx:1,processProgress:1e-3,tinySlidePx:24};
|
|
55
|
+
const D1_CATEGORIES=new Set(['mg','overlay','subtitle-cue','source-footage','data-readout']);
|
|
56
|
+
const D1_EXCLUDED=new Set(['subtitle-cue','source-footage']);
|
|
57
|
+
const bounds=b=>[b.x,b.y,b.width,b.height,b.opacity,b.rotation??0];
|
|
58
|
+
function viewportVisibility(b,viewport){
|
|
59
|
+
return visibleState(b,viewport).state;
|
|
60
|
+
}
|
|
61
|
+
const screenPoints=b=>[[b.x,b.y],[b.x+b.width,b.y],[b.x,b.y+b.height],[b.x+b.width,b.y+b.height],[b.x+b.width/2,b.y+b.height/2]];
|
|
62
|
+
const sub=(a,b)=>a.map((x,i)=>x-b[i]);
|
|
63
|
+
const div=(a,k)=>a.map(x=>x/k);
|
|
64
|
+
const maxAbs=v=>Math.max(...v.map(Math.abs));
|
|
65
|
+
function resolveExisting(p,base){const f=fs.realpathSync(path.resolve(base,nonempty(p,'file path')));if(!fs.statSync(f).isFile())throw Error('Not a file '+f);return f;}
|
|
66
|
+
function fileLock(f){const b=fs.readFileSync(f);return {path:f,bytes:b.length,sha256:sha(b)};}
|
|
67
|
+
function validateSpec(s){
|
|
68
|
+
if(s?.schemaVersion!==1)throw Error('Unsupported adapter schemaVersion');
|
|
69
|
+
finite(s.fps,'fps');finite(s.duration,'duration');if(s.fps<=0||s.fps>240||s.duration<=0||s.duration>3600||s.fps*s.duration>100000)throw Error('Unsupported sampling extent; audit a production block instead of silently reducing samples');
|
|
70
|
+
for(const k of ['width','height'])if(finite(s.viewport?.[k],k)<=0)throw Error('Viewport must be positive');
|
|
71
|
+
if(typeof s.frameAt!=='function')throw Error('Missing frameAt');
|
|
72
|
+
if(s.coverage?.basis!=='render-state-final-screen')throw Error('Declare final-screen render-state coverage; world coordinates cannot be audited as screen coordinates');
|
|
73
|
+
nonempty(s.coverage.scope,'coverage.scope');
|
|
74
|
+
const ids=uniq(s.coverage.objectIds,'coverage.objectIds');if(!ids.length)throw Error('No covered objects');ids.forEach(id=>nonempty(id,'objectId'));
|
|
75
|
+
if(s.coverage.mainContentIds!==undefined&&uniq(s.coverage.mainContentIds,'coverage.mainContentIds').some(id=>!ids.includes(id)))throw Error('Main content object not covered');
|
|
76
|
+
if(!Array.isArray(s.sourceFiles)||!s.sourceFiles.length)throw Error('No render source files');
|
|
77
|
+
for(const group of ['actions','checkpoints','relays']){if(!Array.isArray(s[group]))throw Error('Missing '+group+' (empty allowed with explicit coverage gap)');uniq(s[group].map(x=>nonempty(x.id,group+' id')),group+' ids');}
|
|
78
|
+
if(s.coverage.notApplicable!==undefined){
|
|
79
|
+
const na=s.coverage.notApplicable;
|
|
80
|
+
if(!na||typeof na!=='object'||Array.isArray(na))throw Error('Invalid coverage.notApplicable');
|
|
81
|
+
for(const group of Object.keys(na)){
|
|
82
|
+
if(!['checkpoints','relays'].includes(group))throw Error('Not-applicable coverage is only supported for checkpoints/relays');
|
|
83
|
+
if(s[group].length)throw Error('Not-applicable group must be empty: '+group);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if(s.sourceLinks!==undefined){
|
|
87
|
+
if(!Array.isArray(s.sourceLinks))throw Error('Invalid sourceLinks');uniq(s.sourceLinks.map(x=>nonempty(x.id,'sourceLink id')),'sourceLink ids');
|
|
88
|
+
for(const link of s.sourceLinks){
|
|
89
|
+
if(!ids.includes(link.sourceObjectId)||!ids.includes(link.targetObjectId))throw Error('Source link object not covered');
|
|
90
|
+
for(const t of [link.time,link.sourceTime??link.time])if(finite(t,'sourceLink time')<0||t>s.duration)throw Error('Source link outside timeline');
|
|
91
|
+
for(const a of [link.sourceAnchor??[.5,.5],link.targetAnchor??[.5,.5]])if(!Array.isArray(a)||a.length!==2||a.some(v=>!Number.isFinite(v)||v<0||v>1))throw Error('Invalid sourceLink anchor');
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
for(const a of s.actions){
|
|
95
|
+
if(!ids.includes(a.objectId))throw Error('Action object not covered: '+a.id);
|
|
96
|
+
if(!['transfer','camera','realtime','reveal','process'].includes(a.kind))throw Error('Unknown action kind '+a.id);
|
|
97
|
+
finite(a.start,'action start');finite(a.end,'action end');if(a.start<0||a.end>s.duration||a.end<=a.start)throw Error('Invalid action range '+a.id);
|
|
98
|
+
if(a.channels!==undefined&&(!Array.isArray(a.channels)||!a.channels.length||a.channels.some(c=>!(a.kind==='process'?[...localChannels,...processChannels]:a.kind==='reveal'?['width','height','opacity']:['x','y','width','height']).includes(c))))throw Error('Invalid action channels '+a.id+'; reveal cannot exempt spatial translation');
|
|
99
|
+
if(a.kind==='process'&&!a.channels?.length)throw Error('Process action must name actual local/progress channels: '+a.id);
|
|
100
|
+
if(a.motionGate!==undefined&&a.motionGate!=='anticipation')throw Error('Unknown action motionGate '+a.id);
|
|
101
|
+
if(a.kind==='realtime'&&a.exception?.kind!=='real-time')throw Error('Realtime action requires attributable real-time evidence: '+a.id);
|
|
102
|
+
}
|
|
103
|
+
for(const p of s.checkpoints){
|
|
104
|
+
finite(p.time,'checkpoint time');if(p.time<0||p.time>s.duration)throw Error('Checkpoint outside timeline');
|
|
105
|
+
if(!['pass','hold','cut'].includes(p.role))throw Error('Unknown checkpoint role');
|
|
106
|
+
if(!uniq(p.objectIds,'checkpoint objects').length||p.objectIds.some(id=>!ids.includes(id)))throw Error('Missing checkpoint coverage '+p.id);
|
|
107
|
+
if(p.role!=='pass'&&!p.exception)throw Error('Hold/cut requires attributable evidence '+p.id);
|
|
108
|
+
if(p.role==='cut'&&p.exception.kind!=='cut')throw Error('Cut exception kind mismatch');
|
|
109
|
+
}
|
|
110
|
+
const aset=new Set(s.actions.map(a=>a.id));
|
|
111
|
+
for(const r of s.relays){if(!aset.has(r.fromAction)||!aset.has(r.toAction)||r.fromAction===r.toAction)throw Error('Relay does not reference two actions: '+r.id);if(r.motionGate!==undefined&&!['follow','rigid-feedback'].includes(r.motionGate))throw Error('Unknown relay motionGate '+r.id);}
|
|
112
|
+
}
|
|
113
|
+
// Only a source-backed, frame-aligned whole-scene edit can interrupt a camera
|
|
114
|
+
// trajectory. Local object cuts never excuse drift in an otherwise fixed view.
|
|
115
|
+
export function cameraCutFrames(spec, baseDir) {
|
|
116
|
+
const frames = new Set(), gaps = [];
|
|
117
|
+
for (const cut of spec.checkpoints ?? []) {
|
|
118
|
+
if (cut.role !== 'cut' || cut.scope !== 'scene') continue;
|
|
119
|
+
const i = Math.round(cut.time * spec.fps);
|
|
120
|
+
const proof = cut.exception?.evidence;
|
|
121
|
+
let validEvidence = false;
|
|
122
|
+
if (proof?.sourceFile && proof.anchor && proof.reason) {
|
|
123
|
+
const file = path.resolve(baseDir,proof.sourceFile);
|
|
124
|
+
validEvidence = (spec.sourceFiles ?? []).some(p => path.resolve(baseDir,p) === file) &&
|
|
125
|
+
fs.existsSync(file) && fs.readFileSync(file,'utf8').includes(proof.anchor);
|
|
126
|
+
}
|
|
127
|
+
if (i <= 0 || i >= Math.ceil(spec.duration * spec.fps) || Math.abs(cut.time * spec.fps - i) > 1e-6 ||
|
|
128
|
+
cut.exception?.kind !== 'cut' || !validEvidence) {
|
|
129
|
+
gaps.push('整场切点缺少准确帧号或绑定源码的依据:' + cut.id); continue;
|
|
130
|
+
}
|
|
131
|
+
const sides = [spec.frameAt((i-1)/spec.fps),spec.frameAt(i/spec.fps)];
|
|
132
|
+
const activeIds = sides.flatMap(frame => frame.objects.filter(o => visibleState(o,spec.viewport).state !== 'hidden').map(o => o.id));
|
|
133
|
+
if (!Array.isArray(cut.objectIds) || !cut.objectIds.length || !activeIds.every(id => cut.objectIds.includes(id))) {
|
|
134
|
+
gaps.push('整场切点未覆盖切前和切后画面中的对象:' + cut.id); continue;
|
|
135
|
+
}
|
|
136
|
+
frames.add(i);
|
|
137
|
+
}
|
|
138
|
+
return {frames,gaps};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export function auditMotion(spec,{baseDir=process.cwd(),adapterFile,requireVideo=true}={}){
|
|
142
|
+
const observationLock=fileLock(fileURLToPath(new URL('./motion-observation.cjs',import.meta.url)));
|
|
143
|
+
validateSpec(spec);
|
|
144
|
+
const visibility=b=>viewportVisibility(b,spec.viewport),visible=b=>visibility(b)==='visible';
|
|
145
|
+
const sameVisibleState=(a,b)=>!visible(a)&&!visible(b)||visible(a)&&visible(b)&&maxAbs(sub(bounds(a),bounds(b)))<=EPS.positionPx&&processChannels.every(k=>Math.abs((a.process?.[k]??0)-(b.process?.[k]??0))<=D1.processProgress)&&localChannels.every(k=>Math.abs((a.localGeometry?.[k]??0)-(b.localGeometry?.[k]??0))<=EPS.positionPx);
|
|
146
|
+
const sources=[...new Set(spec.sourceFiles.map(p=>resolveExisting(p,baseDir)))];
|
|
147
|
+
if(adapterFile){const f=resolveExisting(adapterFile,baseDir);if(!sources.includes(f))sources.push(f);}
|
|
148
|
+
const sourceLocks=sources.map(fileLock);
|
|
149
|
+
let videoLock=null;if(spec.videoFile)videoLock=fileLock(resolveExisting(spec.videoFile,baseDir));else if(requireVideo)throw Error('Missing videoFile: delivery audit must bind the actual video');
|
|
150
|
+
const sourceSet=new Set(sources),exceptions=[],notApplicable=[],findings=[],coverageGaps=[];
|
|
151
|
+
const {frames:cutFrames,gaps:cutGaps}=cameraCutFrames(spec,baseDir);
|
|
152
|
+
coverageGaps.push(...cutGaps);
|
|
153
|
+
const crossesCut=(a,b)=>cutFrames.size && [...cutFrames].some(f=>a*spec.fps<f-1e-7 && b*spec.fps>=f-1e-7);
|
|
154
|
+
function evidenceFor(evidence,owner){
|
|
155
|
+
if(!evidence)throw Error('Missing evidence '+owner);
|
|
156
|
+
nonempty(evidence.reason,'evidence reason');const anchor=nonempty(evidence.anchor,'evidence anchor');
|
|
157
|
+
const f=resolveExisting(evidence.sourceFile,baseDir);
|
|
158
|
+
if(!sourceSet.has(f))throw Error('Evidence source is not hash-bound '+owner);
|
|
159
|
+
if(!fs.readFileSync(f,'utf8').includes(anchor))throw Error('Evidence source anchor missing '+owner);
|
|
160
|
+
return {sourceFile:f,anchor,reason:evidence.reason};
|
|
161
|
+
}
|
|
162
|
+
function exception(e,owner){
|
|
163
|
+
if(!e)return false;
|
|
164
|
+
if(!['reading','rhetorical','real-dependency','real-time','cut'].includes(e.kind))throw Error('Unknown exception kind '+owner);
|
|
165
|
+
exceptions.push({owner,kind:e.kind,...evidenceFor(e.evidence,owner),status:'attributed-intent-requires-reading-or-causality-review'});return true;
|
|
166
|
+
}
|
|
167
|
+
for(const a of spec.actions)exception(a.exception,a.id);
|
|
168
|
+
for(const p of spec.checkpoints)exception(p.exception,p.id);
|
|
169
|
+
for(const r of spec.relays)exception(r.exception,r.id);
|
|
170
|
+
for(const [group,label] of [['actions','No declared primary actions; linear motion is not covered'],['checkpoints','No declared pass/hold/cut nodes; joins are not covered'],['relays','No declared causal relay; waiting is not covered']])if(!spec[group].length){
|
|
171
|
+
if(Object.hasOwn(spec.coverage.notApplicable??{},group))notApplicable.push({group,...evidenceFor(spec.coverage.notApplicable[group],'notApplicable.'+group),status:'attributed-not-applicable-requires-scope-review'});
|
|
172
|
+
else coverageGaps.push(label);
|
|
173
|
+
}
|
|
174
|
+
const hasSpatialActions=spec.actions.some(a=>['transfer','camera'].includes(a.kind));
|
|
175
|
+
const revealOnly=spec.actions.length>0&&spec.actions.every(a=>a.kind==='reveal');
|
|
176
|
+
if(spec.actions.length&&!hasSpatialActions&&!revealOnly&&!spec.actions.some(a=>a.kind==='process'))coverageGaps.push('Only reveal/realtime actions declared; primary movement is not covered');
|
|
177
|
+
const cache=new Map();
|
|
178
|
+
function read(t){
|
|
179
|
+
finite(t,'sample time');const key=t.toPrecision(15);if(cache.has(key))return cache.get(key);
|
|
180
|
+
if(t<0||t>spec.duration)throw Error('Sample outside duration');
|
|
181
|
+
const frame=spec.frameAt(t);if(!frame||!Array.isArray(frame.objects))throw Error('Missing objects at '+t);
|
|
182
|
+
if(frame.renderedObjectIds!==undefined)uniq(frame.renderedObjectIds,'renderedObjectIds').forEach(id=>nonempty(id,'rendered object ID'));
|
|
183
|
+
uniq(frame.objects.map(o=>o.id),'sample object IDs');
|
|
184
|
+
const map=new Map();
|
|
185
|
+
for(const o of frame.objects){nonempty(o.id,'sample object id');for(const c of channels.slice(0,5))finite(o[c],`${o.id}.${c} at ${t}`);if(o.rotation!==undefined)finite(o.rotation,'rotation');if(o.width<0||o.height<0||o.opacity<0||o.opacity>1)throw Error('Invalid bounds/opacity at '+t);if(o.contentVersion!==undefined&&!['string','number','boolean'].includes(typeof o.contentVersion))throw Error('contentVersion must be a scalar');
|
|
186
|
+
if(typeof o.contentVersion==='number')finite(o.contentVersion,'contentVersion');
|
|
187
|
+
if(o.localGeometry){for(const k of ['x','y','width','height'])finite(o.localGeometry[k],'localGeometry.'+k);if(o.localGeometry.rotation!==undefined)finite(o.localGeometry.rotation,'localGeometry.rotation');}
|
|
188
|
+
if(o.observation&&!['visible','hidden','unknown'].includes(o.observation.state))throw Error('Invalid observation state '+o.id);
|
|
189
|
+
if(o.observation?.visibleBounds)for(const k of ['x','y','width','height'])finite(o.observation.visibleBounds[k],'visibleBounds.'+k);
|
|
190
|
+
if(o.hotspot){finite(o.hotspot.x,'hotspot.x');finite(o.hotspot.y,'hotspot.y');}
|
|
191
|
+
if(o.parentId!==undefined){nonempty(o.parentId,'parentId');if(o.parentId===o.id||!spec.coverage.objectIds.includes(o.parentId))throw Error('Part parent must be a distinct covered production object: '+o.id);}
|
|
192
|
+
if(o.process)for(const [k,v] of Object.entries(o.process)){if(!['maskProgress','pathProgress','morphProgress','occlusionProgress'].includes(k))throw Error('Unknown process channel '+k);if(finite(v,'process.'+k)<0||v>1)throw Error('Process progress outside 0..1');}
|
|
193
|
+
if(o.replacement){for(const key of ['fromVersion','toVersion'])if(!['string','number','boolean'].includes(typeof o.replacement[key]))throw Error('Replacement requires scalar '+key);if(!['geometry','mask','path','morph','occlusion','source-copy'].includes(o.replacement.kind))throw Error('Unknown replacement kind');if(finite(o.replacement.progress,'replacement.progress')<0||o.replacement.progress>1)throw Error('Replacement progress outside 0..1');}
|
|
194
|
+
const fallback=frame.semantic?.[o.id];const contentVersion=o.contentVersion??(['string','number','boolean'].includes(typeof fallback)?fallback:undefined);
|
|
195
|
+
map.set(o.id,{...o,rotation:o.rotation??0,...(contentVersion===undefined?{}:{contentVersion})});}
|
|
196
|
+
for(const id of spec.coverage.objectIds)if(!map.has(id)){
|
|
197
|
+
// The internal marker carries absence only. Never add fake coordinates
|
|
198
|
+
// or count it as either a submitted object or an observed trajectory.
|
|
199
|
+
if(spec.coverage.inventoryMode==='per-frame-draws' && Array.isArray(frame.renderedObjectIds) && !frame.renderedObjectIds.includes(id))
|
|
200
|
+
map.set(id,{id,opacity:0,notSubmitted:true});
|
|
201
|
+
else throw Error('Covered object omitted at '+t+': '+id+'; retain its identity with opacity 0 if hidden');
|
|
202
|
+
}
|
|
203
|
+
if(frame.camera){for(const k of ['cx','cy','z'])finite(frame.camera[k],'camera.'+k);if(frame.camera.z<=0)throw Error('Invalid camera scale');}
|
|
204
|
+
const out={time:t,map,frame};cache.set(key,out);return out;
|
|
205
|
+
}
|
|
206
|
+
const samples=[];for(let f=0;f<=Math.floor(spec.duration*spec.fps);f++)samples.push(read(f/spec.fps));if(samples.at(-1).time!==spec.duration)samples.push(read(spec.duration));
|
|
207
|
+
const outside=new Set();
|
|
208
|
+
const omittedDraws=new Set(),unregisteredObjects=new Set();
|
|
209
|
+
for(const s of samples)for(const id of s.frame.renderedObjectIds??[])if(!s.map.has(id)||!spec.coverage.objectIds.includes(id))omittedDraws.add(id);
|
|
210
|
+
for(const s of samples)if(Array.isArray(s.frame.renderedObjectIds))for(const o of s.frame.objects)if(!s.frame.renderedObjectIds.includes(o.id))unregisteredObjects.add(o.id);
|
|
211
|
+
if(omittedDraws.size)coverageGaps.push('Production draw inventory omitted from adapter/coverage: '+[...omittedDraws].join(', '));
|
|
212
|
+
if(unregisteredObjects.size)coverageGaps.push('Adapter objects absent from production draw inventory: '+[...unregisteredObjects].join(', '));
|
|
213
|
+
const inventorySamples=samples.filter(s=>s.time<spec.duration),inventoryCount=inventorySamples.filter(s=>Array.isArray(s.frame.renderedObjectIds)).length;
|
|
214
|
+
const verifiedInventoryCount=inventorySamples.filter(s=>recordedFrameState(s.frame).status==='recorded').length;
|
|
215
|
+
const renderInventory={status:verifiedInventoryCount===inventorySamples.length?'recorded':verifiedInventoryCount?'partial':inventoryCount?'declared-unverified':'unexposed',recordedFrames:verifiedInventoryCount,declaredFrames:inventoryCount,omittedObjectIds:[...omittedDraws],basis:'Shared recorder submissions bound to the same SVG and observations; author inventory strings remain declared only'};
|
|
216
|
+
if(inventoryCount&&verifiedInventoryCount!==inventorySamples.length)coverageGaps.push('Production draw inventory is author-declared or changed after rendering; same-renderer coverage remains unverified');
|
|
217
|
+
if(!inventoryCount)coverageGaps.push('Production draw inventory is not exposed; coordinate diagnostics remain available but complete renderer coverage is unproven');
|
|
218
|
+
if(inventoryCount&&inventoryCount!==inventorySamples.length)coverageGaps.push('Production draw inventory is only partially exposed');
|
|
219
|
+
for(const s of samples)if(s.time<spec.duration)for(const [id,b]of s.map)if(!spec.coverage.objectIds.includes(id)&&visibility(b)!=='hidden')outside.add(id);
|
|
220
|
+
if(outside.size)coverageGaps.push('Returned visible or unresolved objects outside declared coverage: '+[...outside].join(', '));
|
|
221
|
+
for(const id of spec.coverage.objectIds){
|
|
222
|
+
const unresolved=samples.filter(s=>s.time<spec.duration&&visibility(s.map.get(id))==='unknown');
|
|
223
|
+
if(unresolved.length)coverageGaps.push(`Painted visibility unresolved for ${id}: ${unresolved[0].time}–${unresolved.at(-1).time}; bbox-only/unsupported paint retains coordinate statistics but cannot establish visible process or lifecycle coverage`);
|
|
224
|
+
}
|
|
225
|
+
// Independent repeated/reverse seeking checks a stateful adapter without assuming sequential playback.
|
|
226
|
+
for(const t of [spec.duration/2,0,spec.duration,.371*spec.duration].reverse()){
|
|
227
|
+
const before=JSON.stringify(read(t).frame),again=JSON.stringify(spec.frameAt(t));if(before!==again)throw Error('Non-deterministic render adapter at '+t);
|
|
228
|
+
}
|
|
229
|
+
function actionPoints(a){
|
|
230
|
+
const ts=[a.start,...samples.filter(s=>s.time>a.start&&s.time<a.end).map(s=>s.time),a.end];
|
|
231
|
+
return ts.map(t=>({t,b:read(t).map.get(a.objectId)}));
|
|
232
|
+
}
|
|
233
|
+
// A fixed-composition fade has no spatial trajectory to audit. This exception
|
|
234
|
+
// is proved from sampled render states, not from naming a moving action reveal.
|
|
235
|
+
if(revealOnly){
|
|
236
|
+
const times=[...new Set([...samples.map(s=>s.time),...spec.actions.flatMap(a=>[a.start,a.end])])].sort((a,b)=>a-b);
|
|
237
|
+
const probes=times.map(read),covered=new Set(spec.coverage.objectIds),uncovered=new Set();
|
|
238
|
+
for(const s of probes)for(const [id,b]of s.map)if(!covered.has(id)&&visibility(b)!=='hidden')uncovered.add(id);
|
|
239
|
+
if(uncovered.size)coverageGaps.push('Reveal-only scope has visible or unresolved objects outside coverage: '+[...uncovered].join(', '));
|
|
240
|
+
const camera=probes[0].frame.camera;
|
|
241
|
+
if(probes.some(s=>!!s.frame.camera!==!!camera||(camera&&['cx','cy','z'].some(k=>Math.abs(s.frame.camera[k]-camera[k])>(k==='z'?EPS.relative:EPS.positionPx)))))
|
|
242
|
+
coverageGaps.push('Reveal-only scope has camera movement or changing camera coverage; declare the applicable spatial action');
|
|
243
|
+
for(const id of spec.coverage.objectIds){
|
|
244
|
+
const visibleStates=probes.map(s=>s.map.get(id)).filter(visible),first=visibleStates[0];
|
|
245
|
+
if(first&&visibleStates.some(b=>['x','y','width','height','rotation'].some(k=>Math.abs((b[k]??0)-(first[k]??0))>(k==='rotation'?EPS.relative:EPS.positionPx))))
|
|
246
|
+
coverageGaps.push('Reveal-only scope has sampled visible translation, size or rotation change: '+id+'; spatial movement is not covered');
|
|
247
|
+
const actions=spec.actions.filter(a=>a.objectId===id);
|
|
248
|
+
let outside=false;
|
|
249
|
+
for(let i=1;i<probes.length;i++){
|
|
250
|
+
const before=probes[i-1],after=probes[i],a=before.map.get(id),b=after.map.get(id);
|
|
251
|
+
if((visibility(a)!=='hidden'||visibility(b)!=='hidden')&&Math.abs(b.opacity-a.opacity)>EPS.relative&&
|
|
252
|
+
!actions.some(action=>action.start<=before.time&&action.end>=after.time&&(!action.channels||action.channels.includes('opacity'))))outside=true;
|
|
253
|
+
}
|
|
254
|
+
if(outside)coverageGaps.push('Reveal-only opacity change lies outside its declared object/action/channel coverage: '+id);
|
|
255
|
+
}
|
|
256
|
+
for(const action of spec.actions){
|
|
257
|
+
const opacity=actionPoints(action).map(p=>p.b.opacity);
|
|
258
|
+
if(Math.max(...opacity)-Math.min(...opacity)<=EPS.relative)
|
|
259
|
+
coverageGaps.push('Declared reveal has no sampled opacity change: '+action.id+'; a static hold does not establish a reveal');
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
const actionCoverage=inspectActionCoverage(spec,samples,cutFrames);
|
|
263
|
+
for(const gap of actionCoverage.uncoveredChanges)coverageGaps.push(`Sampled object change has no production action: ${gap.objectId} ${gap.start}–${gap.end} (${gap.fields.join(', ')})`);
|
|
264
|
+
for(const id of actionCoverage.follow.uncoveredRelayIds)coverageGaps.push('Cross-object production relay not measured for component timing: '+id);
|
|
265
|
+
for(const gap of actionCoverage.follow.relatedActionCandidates)coverageGaps.push('Actual parent/part actions need relationship coverage: '+gap.parentAction+' -> '+gap.partAction+'; causal or independent remains unassessed, no extra motion is required');
|
|
266
|
+
const processCoverage={status:'unexposed',actions:[],exposedPartIds:[],unmeasuredPartIds:[],inactivePartIds:[],basis:'Actual sampled part changes matched to declared process events; static parts do not require invented action, and script meaning/perceptual strength remain unassessed'};
|
|
267
|
+
processCoverage.exposedPartIds=spec.coverage.objectIds.filter(id=>samples.some(s=>s.map.get(id).parentId));
|
|
268
|
+
processCoverage.unmeasuredPartIds=processCoverage.exposedPartIds.filter(id=>actionCoverage.changes.some(c=>c.objectId===id&&c.fields.some(k=>k.startsWith('local.')||k.startsWith('process.')))&&!spec.actions.some(a=>a.objectId===id&&a.kind==='process'));
|
|
269
|
+
processCoverage.inactivePartIds=processCoverage.exposedPartIds.filter(id=>!actionCoverage.changes.some(c=>c.objectId===id));
|
|
270
|
+
const actionMeasurements=[];
|
|
271
|
+
for(const a of spec.actions){
|
|
272
|
+
if(a.kind==='process'){
|
|
273
|
+
// Internal change must exist on encoded frames. The analytic EOF and
|
|
274
|
+
// subframe action endpoints cannot invent an on-screen process.
|
|
275
|
+
const p=samples.filter(s=>s.time>=a.start&&s.time<=a.end&&s.time<spec.duration).map(s=>({t:s.time,b:s.map.get(a.objectId)})),active=p.filter(v=>visible(v.b));
|
|
276
|
+
const m={id:a.id,objectId:a.objectId,kind:a.kind,start:a.start,end:a.end,visibleSampleCount:active.length,status:'unmeasured',channels:{},visualAcceptance:'not-assessed'};
|
|
277
|
+
const gaps=[];
|
|
278
|
+
if(active.length<2)gaps.push('no consecutive visible process samples');
|
|
279
|
+
for(const c of a.channels){
|
|
280
|
+
const get=b=>processChannels.includes(c)?b.process?.[c]:b.localGeometry?.[c];
|
|
281
|
+
const values=active.map(v=>get(v.b));
|
|
282
|
+
if(!values.length||values.some(v=>!Number.isFinite(v))){gaps.push('missing actual '+(processChannels.includes(c)?'process.':'localGeometry.')+c);continue;}
|
|
283
|
+
const range=Math.max(...values)-Math.min(...values),tolerance=processChannels.includes(c)?D1.processProgress:EPS.positionPx;
|
|
284
|
+
const visibleChange=p.slice(1).some((v,i)=>visible(v.b)&&visible(p[i].b)&&Number.isFinite(get(v.b))&&Number.isFinite(get(p[i].b))&&Math.abs(get(v.b)-get(p[i].b))>tolerance);
|
|
285
|
+
m.channels[c]={range,unit:processChannels.includes(c)?'fraction':c==='rotation'?'degrees':'pixels',basis:processChannels.includes(c)?'production-process':'production-local-geometry',visibleChange};
|
|
286
|
+
}
|
|
287
|
+
if(!Object.values(m.channels).some(c=>c.visibleChange))gaps.push('no sampled visible internal change; container/camera transport does not count');
|
|
288
|
+
m.status=gaps.length?'unmeasured':'measured-change';m.uncovered=gaps;
|
|
289
|
+
for(const gap of gaps)coverageGaps.push('Process '+a.id+': '+gap);
|
|
290
|
+
processCoverage.actions.push(m);actionMeasurements.push(m);continue;
|
|
291
|
+
}
|
|
292
|
+
const p=actionPoints(a);if(p.length<4){coverageGaps.push('Action too short for trajectory checks: '+a.id);continue;}
|
|
293
|
+
const fullyHidden=p.every(p=>!visible(p.b));
|
|
294
|
+
if(fullyHidden){coverageGaps.push('Action has no confirmed visible sampled object: '+a.id);continue;}
|
|
295
|
+
const active=p.filter(v=>visible(v.b));
|
|
296
|
+
const measurement={id:a.id,objectId:a.objectId,kind:a.kind,start:a.start,end:a.end,visibleSampleCount:active.length,channels:{}};
|
|
297
|
+
for(const c of a.channels||(a.kind==='reveal'?['opacity']:['x','y','width','height'])){
|
|
298
|
+
const slopes=p.slice(1).map((v,i)=>({start:p[i].t,end:v.t,value:(v.b[c]-p[i].b[c])/(v.t-p[i].t),continuous:!crossesCut(p[i].t,v.t)&&!v.b.notSubmitted&&!p[i].b.notSubmitted,visible:visible(v.b)&&visible(p[i].b)&&!crossesCut(p[i].t,v.t)}));
|
|
299
|
+
const vals=p.map(p=>p.b[c]).filter(Number.isFinite);const range=vals.length?Math.max(...vals)-Math.min(...vals):0;
|
|
300
|
+
const velocities=slopes.filter(v=>v.continuous).map(v=>v.value);
|
|
301
|
+
measurement.channels[c]={range,unit:c==='opacity'?'fraction':'pixels',minVelocity:velocities.length?Math.min(...velocities):null,maxVelocity:velocities.length?Math.max(...velocities):null};
|
|
302
|
+
if(range<EPS.positionPx)continue;
|
|
303
|
+
let first=0;
|
|
304
|
+
for(let i=1;i<=slopes.length;i++){
|
|
305
|
+
const base=slopes[first],cur=slopes[i],equal=cur&&base.visible&&cur.visible&&Math.abs(cur.value-base.value)<=EPS.velocity+EPS.relative*Math.abs(base.value);
|
|
306
|
+
if(equal)continue;
|
|
307
|
+
const count=i-first;
|
|
308
|
+
if(base.visible&&count>=EPS.cruiseIntervals&&Math.abs(base.value)>EPS.velocity&&!['realtime','reveal'].includes(a.kind)){
|
|
309
|
+
findings.push({code:'uniform-screen-channel',severity:'review',action:a.id,objectId:a.objectId,channel:c,start:base.start,end:slopes[i-1].end,velocityPxPerSecond:base.value,sampleIntervals:count,note:'One final-screen channel is constant. This is a diagnostic clue, not proof of uniform composite movement; inspect dominant displacement, combined speed and the applicable motion rule.'});
|
|
310
|
+
}
|
|
311
|
+
first=i;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
// Final-screen bbox points combine translation and scale. A linear x alone cannot prove uniform motion.
|
|
315
|
+
// Rotation-changing intervals require a richer point adapter/pixel review; bbox points do not reconstruct rotating material points.
|
|
316
|
+
const composite=p.slice(1).map((v,i)=>{
|
|
317
|
+
const prev=p[i],dt=v.t-prev.t,from=screenPoints(prev.b),to=screenPoints(v.b);
|
|
318
|
+
const pointSpeeds=to.map((q,j)=>Math.hypot(q[0]-from[j][0],q[1]-from[j][1])/dt);
|
|
319
|
+
const onScreen=visible(prev.b)&&visible(v.b)&&!crossesCut(prev.t,v.t),rotationChanged=Math.abs((v.b.rotation??0)-(prev.b.rotation??0))>EPS.relative;
|
|
320
|
+
return {start:prev.t,end:v.t,value:Math.sqrt(pointSpeeds.reduce((s,x)=>s+x*x,0)/pointSpeeds.length),pointSpeeds,
|
|
321
|
+
visible:onScreen&&!rotationChanged,rotationExcluded:onScreen&&rotationChanged};
|
|
322
|
+
});
|
|
323
|
+
const measured=composite.filter(v=>v.visible),rotationExcludedRanges=[];
|
|
324
|
+
let currentRun=0,maxContiguousIntervals=0;
|
|
325
|
+
for(const v of composite){
|
|
326
|
+
currentRun=v.visible?currentRun+1:0;maxContiguousIntervals=Math.max(maxContiguousIntervals,currentRun);
|
|
327
|
+
if(v.rotationExcluded){
|
|
328
|
+
const last=rotationExcludedRanges.at(-1);
|
|
329
|
+
if(last&&last.end===v.start){last.end=v.end;last.intervals++;}
|
|
330
|
+
else rotationExcludedRanges.push({start:v.start,end:v.end,intervals:1});
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
measurement.compositeSpeed={basis:'RMS speed of final-screen bbox corners and center; rotation-changing intervals excluded',unit:'pixels/second',visibleIntervals:measured.length,
|
|
334
|
+
maxContiguousIntervals,minimumContiguousIntervals:EPS.cruiseIntervals,rotationExcludedRanges,
|
|
335
|
+
minVelocity:measured.length?Math.min(...measured.map(v=>v.value)):null,maxVelocity:measured.length?Math.max(...measured.map(v=>v.value)):null};
|
|
336
|
+
if(['transfer','camera'].includes(a.kind)){
|
|
337
|
+
if(rotationExcludedRanges.length)coverageGaps.push('Composite screen speed excludes visible rotation-changing intervals: '+a.id+'; inspect encoded frames or provide material-point motion');
|
|
338
|
+
if(maxContiguousIntervals<EPS.cruiseIntervals)coverageGaps.push(`Insufficient consecutive visible composite-speed intervals for ${a.id}: ${maxContiguousIntervals}/${EPS.cruiseIntervals}; uniform motion is not covered`);
|
|
339
|
+
let first=0;
|
|
340
|
+
for(let i=1;i<=composite.length;i++){
|
|
341
|
+
const base=composite[first],cur=composite[i],equal=cur&&base.visible&&cur.visible&&Math.abs(cur.value-base.value)<=EPS.velocity+EPS.relative*Math.abs(base.value)
|
|
342
|
+
&&cur.pointSpeeds.every((v,j)=>Math.abs(v-base.pointSpeeds[j])<=EPS.velocity+EPS.relative*Math.abs(base.pointSpeeds[j]));
|
|
343
|
+
if(equal)continue;
|
|
344
|
+
const count=i-first;
|
|
345
|
+
if(base.visible&&count>=EPS.cruiseIntervals&&base.value>EPS.velocity)findings.push({code:'uniform-screen-motion',severity:'constraint-violation',action:a.id,objectId:a.objectId,start:base.start,end:composite[i-1].end,speedPxPerSecond:base.value,sampleIntervals:count,
|
|
346
|
+
rule:'ordinary-visual-nonuniform',basis:measurement.compositeSpeed.basis,note:'Combined screen-point speeds are numerically constant in an ordinary transfer/camera action. Check the encoded frames and applicable nonuniform-motion rule; this is engineering evidence, not visual acceptance.'});
|
|
347
|
+
first=i;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
const start=read(a.start).map.get(a.objectId),end=read(a.end).map.get(a.objectId);
|
|
351
|
+
measurement.endpointDisplacementPx=start.notSubmitted||end.notSubmitted||crossesCut(a.start,a.end)?null:Math.hypot(end.x-start.x,end.y-start.y);
|
|
352
|
+
measurement.visibleAreaFraction={min:Math.min(...active.map(p=>p.b.width*p.b.height/(spec.viewport.width*spec.viewport.height))),max:Math.max(...active.map(p=>p.b.width*p.b.height/(spec.viewport.width*spec.viewport.height)))};
|
|
353
|
+
actionMeasurements.push(measurement);
|
|
354
|
+
}
|
|
355
|
+
function sides(id,t){
|
|
356
|
+
const h=Math.min(EPS.derivativeStep,1/spec.fps/100,t/2,(spec.duration-t)/2);if(h<=0)return null;
|
|
357
|
+
const internal=[...new Set(spec.actions.filter(a=>a.objectId===id&&a.kind==='process'&&a.start<=t&&a.end>=t).flatMap(a=>a.channels))];
|
|
358
|
+
const names=[...channels,...internal.map(c=>(processChannels.includes(c)?'process.':'localGeometry.')+c)];
|
|
359
|
+
const b=tt=>{const o=read(tt).map.get(id);return [...bounds(o),...internal.map(c=>processChannels.includes(c)?o.process?.[c]:o.localGeometry?.[c])];},at=b(t);
|
|
360
|
+
if([...at,...b(t-h),...b(t+h)].some(v=>!Number.isFinite(v)))return null;
|
|
361
|
+
const L1=div(sub(at,b(t-h)),h),L2=div(sub(at,b(t-h/2)),h/2),R1=div(sub(b(t+h),at),h),R2=div(sub(b(t+h/2),at),h/2);
|
|
362
|
+
return {left:L2.map((v,i)=>2*v-L1[i]),right:R2.map((v,i)=>2*v-R1[i]),h,channels:names};
|
|
363
|
+
}
|
|
364
|
+
const checkpointMeasurements=[];
|
|
365
|
+
for(const p of spec.checkpoints){
|
|
366
|
+
if(p.role==='cut' && p.scope==='scene' && cutFrames.has(Math.round(p.time*spec.fps))){
|
|
367
|
+
const frame=Math.round(p.time*spec.fps);
|
|
368
|
+
checkpointMeasurements.push({id:p.id,time:p.time,role:p.role,beforeFrame:frame-1,afterFrame:frame,basis:'declared scene cut; no cross-cut derivative'});
|
|
369
|
+
continue;
|
|
370
|
+
}
|
|
371
|
+
const values=p.objectIds.map(id=>({id,sides:sides(id,p.time)}));
|
|
372
|
+
const valid=values.filter(v=>v.sides&&visible(read(p.time).map.get(v.id)));
|
|
373
|
+
if(!valid.length){coverageGaps.push('Checkpoint has no visible object with measurable states on both sides: '+p.id);continue;}
|
|
374
|
+
const allStopped=valid.every(v=>maxAbs(v.sides.left)<EPS.velocity&&maxAbs(v.sides.right)<EPS.velocity);
|
|
375
|
+
checkpointMeasurements.push({id:p.id,time:p.time,role:p.role,allCoveredObjectsStationaryAtNode:allStopped,objects:valid.map(({id,sides:s})=>({id,leftDerivative:s.left,rightDerivative:s.right,channels:s.channels}))});
|
|
376
|
+
if(allStopped&&p.role==='pass')findings.push({code:'pass-node-common-stop',severity:'constraint-violation',checkpoint:p.id,time:p.time,objectIds:p.objectIds,note:'A declared pass node brings all audited final-screen object channels to zero. This checks declared objects, not the entire raster scene.'});
|
|
377
|
+
if(p.role!=='cut')for(const {id,sides:s} of valid){
|
|
378
|
+
const delta=maxAbs(sub(s.left,s.right)),scale=Math.max(maxAbs(s.left),maxAbs(s.right),1);
|
|
379
|
+
if(delta>EPS.velocity+scale*.001)findings.push({code:'node-velocity-discontinuity',severity:'review',checkpoint:p.id,objectId:id,time:p.time,leftDerivative:s.left,rightDerivative:s.right,note:'One-sided velocity limits differ; check intended contact, attachment/camera changes and the rendered frames.'});
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
const relayMeasurements=[];
|
|
383
|
+
for(const r of spec.relays){
|
|
384
|
+
const a=spec.actions.find(a=>a.id===r.fromAction),b=spec.actions.find(a=>a.id===r.toAction),gap=b.start-a.end;
|
|
385
|
+
const m={id:r.id,fromAction:a.id,toAction:b.id,declaredGapSeconds:gap,measuredAllCoveredStatic:false,basis:'viewport-intersecting covered-object states; hidden/offscreen-only changes ignored; unresolved rotated visibility is not a no-wait result'};
|
|
386
|
+
if(gap>0){
|
|
387
|
+
const ts=[a.end,...samples.filter(s=>s.time>a.end&&s.time<b.start).map(s=>s.time),b.start];
|
|
388
|
+
m.unresolvedVisibilityObjectIds=spec.coverage.objectIds.filter(id=>ts.some(t=>visibility(read(t).map.get(id))==='unknown'));
|
|
389
|
+
if(m.unresolvedVisibilityObjectIds.length){
|
|
390
|
+
m.measuredAllCoveredStatic=null;
|
|
391
|
+
coverageGaps.push('Relay has unresolved rotated-object viewport visibility: '+r.id+' ('+m.unresolvedVisibilityObjectIds.join(', ')+')');
|
|
392
|
+
}else{
|
|
393
|
+
const at=read(ts[0]),stationary=ts.slice(1).every(t=>spec.coverage.objectIds.every(id=>sameVisibleState(read(t).map.get(id),at.map.get(id))));
|
|
394
|
+
m.measuredAllCoveredStatic=stationary;
|
|
395
|
+
if(stationary&&!r.exception)findings.push({code:'relay-empty-wait',severity:'review',relay:r.id,start:a.end,end:b.start,note:'Declared causal handoff contains no measured change in covered objects. Check whether a necessary readable/causal hold is missing from the source, or an avoidable empty wait.'});
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
relayMeasurements.push(m);
|
|
399
|
+
}
|
|
400
|
+
// D1 audits only encoded-frame times [0,duration). The analytic endpoint remains
|
|
401
|
+
// available to the existing trajectory/derivative checks, never as an extra rendered frame.
|
|
402
|
+
const lifecycleMeasurements=[],replacementMeasurements=[],sourceLinkMeasurements=[];
|
|
403
|
+
const lifecycleFrames=samples.filter(s=>s.time<spec.duration);
|
|
404
|
+
const d1Classification={basis:'adapter-declared categories; authenticity and semantic correctness are not assessed',
|
|
405
|
+
scope:'Only D1 lifecycle, content identity and source-link targets; trajectory, checkpoint and relay checks remain unchanged',
|
|
406
|
+
checkedObjectIds:[],excludedObjectIds:[],contentCheckedObjectIds:[],contentOnlyExcludedObjectIds:[],objects:[],excludedSourceLinks:[]};
|
|
407
|
+
const d1Excluded=new Map(),d1ContentOnlyExcluded=new Set();
|
|
408
|
+
for(const id of spec.coverage.objectIds){
|
|
409
|
+
const values=lifecycleFrames.map(s=>s.map.get(id)).filter(o=>!o.notSubmitted).map(o=>o.d1Category),first=values[0];
|
|
410
|
+
if(!values.length)coverageGaps.push('Covered object never submitted on an encoded frame: '+id);
|
|
411
|
+
const stable=D1_CATEGORIES.has(first)&&values.every(v=>v===first),excluded=stable&&D1_EXCLUDED.has(first),contentOnlyExcluded=stable&&first==='data-readout';
|
|
412
|
+
const missingSamples=values.filter(v=>v===undefined).length;
|
|
413
|
+
const unknownCategories=[...new Set(values.filter(v=>v!==undefined&&!D1_CATEGORIES.has(v)).map(v=>typeof v==='string'?v:'<'+(v===null?'null':typeof v)+'>'))];
|
|
414
|
+
const record={objectId:id,category:stable?first:null,disposition:excluded?'excluded':contentOnlyExcluded?'content-only-excluded':'checked',
|
|
415
|
+
checks:{lifecycle:!excluded,contentIdentity:!excluded&&!contentOnlyExcluded,sourceLinks:!excluded},
|
|
416
|
+
declaredCategories:[...new Set(values.filter(v=>typeof v==='string'))],missingSamples,unknownCategories,
|
|
417
|
+
reason:excluded?'consistent declared category; exclusion requires scope/authenticity review':contentOnlyExcluded?'declared data-readout; only numerical content updates excluded, lifecycle/source links still checked; verify actual data mapping':stable?'explicit D1 category':
|
|
418
|
+
missingSamples===values.length?'no category declared; default D1 coverage':'missing, unknown or inconsistent category; retain D1 coverage'};
|
|
419
|
+
d1Classification.objects.push(record);
|
|
420
|
+
if(excluded){d1Excluded.set(id,first);d1Classification.excludedObjectIds.push(id);}
|
|
421
|
+
else{
|
|
422
|
+
d1Classification.checkedObjectIds.push(id);
|
|
423
|
+
if(contentOnlyExcluded){d1ContentOnlyExcluded.add(id);d1Classification.contentOnlyExcludedObjectIds.push(id);}
|
|
424
|
+
else d1Classification.contentCheckedObjectIds.push(id);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
const contentVersionCoverage={covered:[],partial:[],uncovered:[],unresolvedChanges:[],
|
|
428
|
+
note:'Only d1Classification.contentCheckedObjectIds participate; full D1 and content-only exclusions are recorded separately. Covered means identity is exposed at every encoded-frame sample. Partial identity has an explicit coverage gap; no precise replacement time is inferred through an unknown span. Unexposed IDs are not checked. Provide actual contentVersion or legacy semantic[objectId] scalar.'};
|
|
429
|
+
function local(s,id){
|
|
430
|
+
const b=s.map.get(id);if(b.localGeometry)return {...b.localGeometry,rotation:b.localGeometry.rotation??0};
|
|
431
|
+
const c=s.frame.camera;if(!c||b.screenFixed)return b;
|
|
432
|
+
return {...b,x:(b.x-spec.viewport.width/2)/c.z+c.cx,y:(b.y-spec.viewport.height/2)/c.z+c.cy,width:b.width/c.z,height:b.height/c.z};
|
|
433
|
+
}
|
|
434
|
+
const range=xs=>Math.max(...xs)-Math.min(...xs);
|
|
435
|
+
function processEvidence(frames,id){
|
|
436
|
+
frames=frames.filter(s=>!s.map.get(id).notSubmitted);
|
|
437
|
+
const g=frames.map(s=>local(s,id)),boxes=frames.map(s=>s.map.get(id));
|
|
438
|
+
const screenScale=Math.max(...frames.map(s=>s.frame.camera?.z??1));
|
|
439
|
+
const translationPx=Math.hypot(range(g.map(b=>b.x)),range(g.map(b=>b.y)))*screenScale;
|
|
440
|
+
const widthDeltaPx=range(g.map(b=>b.width))*screenScale,heightDeltaPx=range(g.map(b=>b.height))*screenScale;
|
|
441
|
+
const rotationArcPx=Math.max(...g.map(b=>Math.hypot(b.width,b.height)/2))*range(g.map(b=>b.rotation??0))*Math.PI/180*screenScale;
|
|
442
|
+
const shapeDeltaPx=Math.max(widthDeltaPx,heightDeltaPx,rotationArcPx),shapeChange=shapeDeltaPx>D1.geometryProcessPx;
|
|
443
|
+
const progressChannels=processChannels.filter(k=>{
|
|
444
|
+
const values=boxes.map(b=>b.process?.[k]);return values.every(Number.isFinite)&&range(values)>D1.processProgress&&values.some(v=>v>D1.processProgress&&v<1-D1.processProgress);
|
|
445
|
+
});
|
|
446
|
+
return {translationPx,shapeDeltaPx,shapeChange,progressChannels,
|
|
447
|
+
geometryBasis:boxes.every(b=>b.localGeometry)?'production-local-geometry':frames.some(s=>s.frame.camera)?'centered-camera-inversion-inference':'final-screen-geometry',
|
|
448
|
+
hasProcess:shapeChange||translationPx>D1.tinySlidePx||progressChannels.length>0};
|
|
449
|
+
}
|
|
450
|
+
function sceneCutAt(time){
|
|
451
|
+
return spec.checkpoints.find(p=>p.role==='cut'&&p.scope==='scene'&&Math.abs(p.time-time)<=1/spec.fps&&d1Classification.checkedObjectIds.filter(id=>visible(read(Math.max(0,time-1/spec.fps)).map.get(id))||visible(read(time).map.get(id))).every(id=>p.objectIds.includes(id)));
|
|
452
|
+
}
|
|
453
|
+
function identityGap(id,detail){
|
|
454
|
+
let partial=contentVersionCoverage.partial.find(p=>p.objectId===id);
|
|
455
|
+
if(!partial){partial={objectId:id,missingRanges:[],subframeGaps:[]};contentVersionCoverage.partial.push(partial);}
|
|
456
|
+
if(detail)partial.subframeGaps.push(detail);
|
|
457
|
+
contentVersionCoverage.covered=contentVersionCoverage.covered.filter(x=>x!==id);
|
|
458
|
+
const message='Content identity coverage incomplete for '+id+'; replacement timing across unknown values is unresolved';
|
|
459
|
+
if(!coverageGaps.includes(message))coverageGaps.push(message);
|
|
460
|
+
return partial;
|
|
461
|
+
}
|
|
462
|
+
for(const id of d1Classification.checkedObjectIds){
|
|
463
|
+
let start=null,sign=0;
|
|
464
|
+
function finish(end){
|
|
465
|
+
if(start===null)return;
|
|
466
|
+
const frames=lifecycleFrames.slice(start,end+1),first=frames[0],last=frames.at(-1),a=first.map.get(id),b=last.map.get(id);
|
|
467
|
+
const enters=a.opacity<=EPS.relative&&b.opacity>EPS.relative,exits=a.opacity>EPS.relative&&b.opacity<=EPS.relative;
|
|
468
|
+
if((enters||exits)&&frames.some(s=>visible(s.map.get(id)))){
|
|
469
|
+
const evidence=processEvidence(frames,id),cut=sceneCutAt(enters?last.time:first.time);
|
|
470
|
+
const alphaAction=spec.actions.find(a=>a.objectId===id&&a.kind==='reveal'&&a.channels?.length===1&&a.channels[0]==='opacity'&&a.start<=first.time+1/spec.fps&&a.end>=last.time-1/spec.fps);
|
|
471
|
+
evidence.declaredOpacityOnlyAction=alphaAction?.id??null;
|
|
472
|
+
const m={objectId:id,kind:enters?'entry':'exit',start:first.time,end:last.time,opacity:[a.opacity,b.opacity],...evidence,sceneCut:cut?.id??null};
|
|
473
|
+
lifecycleMeasurements.push(m);
|
|
474
|
+
if((!evidence.hasProcess||last.time-first.time<=1/spec.fps+1e-9||(alphaAction&&!evidence.shapeChange&&!evidence.progressChannels.length))&&!cut){
|
|
475
|
+
const instant=last.time-first.time<=1/spec.fps+1e-9;
|
|
476
|
+
findings.push({code:instant?'instant-element-visibility':'opacity-only-lifecycle',severity:'review',...m,
|
|
477
|
+
note:'Suspected element appearance/disappearance without a sampled geometry, mask or path process. Tiny slide/shape/progress noise cannot establish a process. Spatial travel under an opacity-only declared action may be inherited; check the element-local mechanism. Inspect first/last visible encoded frames and the project DESIGN exception; this is not an automatic visual failure.'});
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
start=null;sign=0;
|
|
481
|
+
}
|
|
482
|
+
for(let i=1;i<lifecycleFrames.length;i++){
|
|
483
|
+
const delta=lifecycleFrames[i].map.get(id).opacity-lifecycleFrames[i-1].map.get(id).opacity,sgn=Math.abs(delta)>1e-12?Math.sign(delta):0;
|
|
484
|
+
if(sgn&&sgn===sign)continue;
|
|
485
|
+
finish(i-1);if(sgn){start=i-1;sign=sgn;}
|
|
486
|
+
}
|
|
487
|
+
finish(lifecycleFrames.length-1);
|
|
488
|
+
if(d1ContentOnlyExcluded.has(id))continue; // numerical updates only; lifecycle above and source links below remain checked
|
|
489
|
+
const known=lifecycleFrames.map((s,index)=>({s,index})).filter(x=>x.s.map.get(id).contentVersion!==undefined);
|
|
490
|
+
if(!known.length){contentVersionCoverage.uncovered.push(id);continue;}
|
|
491
|
+
if(known.length===lifecycleFrames.filter(s=>!s.map.get(id).notSubmitted).length)contentVersionCoverage.covered.push(id);
|
|
492
|
+
else{
|
|
493
|
+
const partial=identityGap(id);partial.knownSamples=known.length;partial.missingSamples=lifecycleFrames.length-known.length;
|
|
494
|
+
for(let i=0;i<lifecycleFrames.length;){
|
|
495
|
+
if(lifecycleFrames[i].map.get(id).contentVersion!==undefined){i++;continue;}
|
|
496
|
+
const begin=i;while(i<lifecycleFrames.length&&lifecycleFrames[i].map.get(id).contentVersion===undefined)i++;
|
|
497
|
+
partial.missingRanges.push({firstMissing:lifecycleFrames[begin].time,lastMissing:lifecycleFrames[i-1].time,
|
|
498
|
+
lastKnownTime:begin?lifecycleFrames[begin-1].time:null,firstKnownTime:i<lifecycleFrames.length?lifecycleFrames[i].time:null});
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
for(let i=1;i<known.length;i++){
|
|
502
|
+
const prev=known[i-1],curr=known[i],a=prev.s,b=curr.s,old=a.map.get(id),next=b.map.get(id);
|
|
503
|
+
if(Object.is(old.contentVersion,next.contentVersion))continue;
|
|
504
|
+
const unlocated={objectId:id,time:null,lastKnownTime:a.time,firstKnownTime:b.time,fromVersion:old.contentVersion,toVersion:next.contentVersion};
|
|
505
|
+
if(curr.index!==prev.index+1){contentVersionCoverage.unresolvedChanges.push({...unlocated,reason:'identity not exposed between encoded-frame samples'});continue;}
|
|
506
|
+
// Refine only a known, adjacent identity boundary; unknown or a third identity
|
|
507
|
+
// encountered during refinement stays an interval, never a made-up exact time.
|
|
508
|
+
let lo=a.time,hi=b.time,unresolved=false;
|
|
509
|
+
for(let j=0;j<32;j++){
|
|
510
|
+
const mid=(lo+hi)/2,version=read(mid).map.get(id).contentVersion;
|
|
511
|
+
if(version===undefined||!Object.is(version,old.contentVersion)&&!Object.is(version,next.contentVersion)){
|
|
512
|
+
identityGap(id,{start:lo,end:hi,probe:mid,reason:'unknown or additional identity between encoded frames'});
|
|
513
|
+
contentVersionCoverage.unresolvedChanges.push({...unlocated,reason:'unknown or additional identity during boundary refinement'});unresolved=true;break;
|
|
514
|
+
}
|
|
515
|
+
if(Object.is(version,old.contentVersion))lo=mid;else hi=mid;
|
|
516
|
+
}
|
|
517
|
+
if(unresolved)continue;
|
|
518
|
+
const time=Math.round(hi*1e9)/1e9,before=read(lo).map.get(id),after=read(hi).map.get(id);
|
|
519
|
+
// Inspect visibility at the actual change, not an arbitrary future window.
|
|
520
|
+
// A later reveal of prepared hidden content is an entry, not a visible text swap.
|
|
521
|
+
if(!visible(before)&&!visible(after))continue;
|
|
522
|
+
const matching=r=>r&&Object.is(r.fromVersion,old.contentVersion)&&Object.is(r.toVersion,next.contentVersion);
|
|
523
|
+
const atBoundary=after.replacement;
|
|
524
|
+
const context=lifecycleFrames.slice(Math.max(0,prev.index-1),Math.min(lifecycleFrames.length,curr.index+3));
|
|
525
|
+
const rp=context.map(s=>s.map.get(id).replacement).filter(matching);
|
|
526
|
+
const immediate=[a,b,lifecycleFrames[curr.index+1]].filter(Boolean).map(s=>s.map.get(id).replacement).filter(matching);
|
|
527
|
+
// Require the process at the change itself AND changing in its neighboring
|
|
528
|
+
// encoded interval. An effect starting later cannot excuse an earlier hard swap.
|
|
529
|
+
const mechanism=matching(atBoundary)&&rp.length>=3&&rp.every(r=>r.kind===atBoundary.kind)&&
|
|
530
|
+
immediate.length>=2&&range(immediate.map(r=>r.progress))>D1.processProgress&&
|
|
531
|
+
range(rp.map(r=>r.progress))>D1.processProgress&&new Set(rp.map(r=>r.progress)).size>=3&&
|
|
532
|
+
rp.some(r=>r.progress>D1.processProgress&&r.progress<1-D1.processProgress)?atBoundary.kind:null;
|
|
533
|
+
const cut=sceneCutAt(time),m={objectId:id,time,lastOldSample:a.time,firstNewSample:b.time,fromVersion:old.contentVersion,toVersion:next.contentVersion,replacementMechanism:mechanism,sceneCut:cut?.id??null};
|
|
534
|
+
replacementMeasurements.push(m);
|
|
535
|
+
if(!mechanism&&!cut)findings.push({code:'content-replaced-without-process',severity:'review',...m,note:'The same node changes rendered content/identity without sampled replacement progress at that boundary. A later mechanism, alpha reset, parent travel or numerical noise cannot excuse the earlier swap. Check old last/new first visible pixels and the project DESIGN exception.'});
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
for(const link of spec.sourceLinks??[]){
|
|
539
|
+
const proof=evidenceFor(link.evidence,'sourceLink.'+link.id);
|
|
540
|
+
if(d1Excluded.has(link.targetObjectId)){
|
|
541
|
+
d1Classification.excludedSourceLinks.push({id:link.id,sourceObjectId:link.sourceObjectId,targetObjectId:link.targetObjectId,
|
|
542
|
+
category:d1Excluded.get(link.targetObjectId),reason:'target is a consistently declared D1-excluded layer; not proof of source authenticity',...proof});continue;
|
|
543
|
+
}
|
|
544
|
+
const source=read(link.sourceTime??link.time).map.get(link.sourceObjectId);
|
|
545
|
+
if(source.notSubmitted){coverageGaps.push('Source link source not drawn at declared time: '+link.id);continue;}
|
|
546
|
+
const first=lifecycleFrames.find(s=>s.time>=link.time&&visible(s.map.get(link.targetObjectId)));
|
|
547
|
+
if(!first){coverageGaps.push('Source link target has no visible sample: '+link.id);continue;}
|
|
548
|
+
const target=first.map.get(link.targetObjectId),sa=link.sourceAnchor??[.5,.5],ta=link.targetAnchor??[.5,.5];
|
|
549
|
+
const from=[source.x+source.width*sa[0],source.y+source.height*sa[1]],to=[target.x+target.width*ta[0],target.y+target.height*ta[1]];
|
|
550
|
+
const distancePx=Math.hypot(to[0]-from[0],to[1]-from[1]);
|
|
551
|
+
const initial=read(link.time).map.get(link.targetObjectId),targetStartAnchor=initial.notSubmitted?null:[initial.x+initial.width*ta[0],initial.y+initial.height*ta[1]],startDistancePx=targetStartAnchor?Math.hypot(targetStartAnchor[0]-from[0],targetStartAnchor[1]-from[1]):null;
|
|
552
|
+
const m={id:link.id,sourceObjectId:link.sourceObjectId,targetObjectId:link.targetObjectId,sourceTime:link.sourceTime??link.time,firstTargetTime:first.time,from,to,distancePx,targetStartAnchor,startDistancePx,...proof};sourceLinkMeasurements.push(m);
|
|
553
|
+
if(distancePx>1)findings.push({code:'source-origin-discontinuity',severity:'review',...m,note:'Declared same-location split/copy starts away from its actual source anchor. Sampling may include first-frame travel: inspect the boundary and any real visible transfer; distance is not a universal visual threshold.'});
|
|
554
|
+
}
|
|
555
|
+
// A static camera is not a violation. Report magnification and framing facts, not a shot quota.
|
|
556
|
+
const cameraSamples=samples.filter(s=>s.frame.camera).map(s=>({time:s.time,...s.frame.camera}));
|
|
557
|
+
const objectScale=spec.coverage.objectIds.map(id=>{
|
|
558
|
+
const ps=samples.map(s=>({t:s.time,b:s.map.get(id)})).filter(x=>visible(x.b));
|
|
559
|
+
return {id,visibleSamples:ps.length,widthFraction:ps.length?[Math.min(...ps.map(p=>p.b.width/spec.viewport.width)),Math.max(...ps.map(p=>p.b.width/spec.viewport.width))]:null,heightFraction:ps.length?[Math.min(...ps.map(p=>p.b.height/spec.viewport.height)),Math.max(...ps.map(p=>p.b.height/spec.viewport.height))]:null};
|
|
560
|
+
});
|
|
561
|
+
for(const lock of sourceLocks)if(sha(fs.readFileSync(lock.path))!==lock.sha256)throw Error('Source changed while sampling: '+lock.path);
|
|
562
|
+
if(sha(fs.readFileSync(observationLock.path))!==observationLock.sha256)throw Error('Observation tool changed while sampling');
|
|
563
|
+
if(videoLock&&sha(fs.readFileSync(videoLock.path))!==videoLock.sha256)throw Error('Video changed while sampling');
|
|
564
|
+
processCoverage.status=processCoverage.actions.length?(processCoverage.unmeasuredPartIds.length||processCoverage.actions.some(a=>a.status!=='measured-change')?'partial':'declared-actions-measured'):processCoverage.exposedPartIds.length?'partial':'unexposed';
|
|
565
|
+
const motionObservations=measureFrameMotion(samples.filter(s=>s.time<spec.duration),spec.coverage.objectIds,spec.viewport,spec.fps,spec.actions,cutFrames);
|
|
566
|
+
const status=coverageGaps.length?'incomplete':findings.length?'findings':'measured-no-findings';
|
|
567
|
+
return {schemaVersion:1,status,visualAcceptance:'not-assessed',basis:'engineering evaluation of final-screen render state; not decoded pixel tracking',coverage:spec.coverage,coverageGaps,actionCoverage,processCoverage,renderInventory,motionObservations,locks:{observationTool:observationLock,tool:fileLock(fileURLToPath(import.meta.url)),sources:sourceLocks,video:videoLock},measurementTolerances:{...EPS,d1:D1,basis:'numerical locator tolerances, not cross-project visual quality thresholds'},sampling:{fps:spec.fps,duration:spec.duration,renderFrameSamples:samples.length,lifecycleEncodedFrames:lifecycleFrames.length,lifecycleLastFrameTime:lifecycleFrames.at(-1).time,lifecycleEndExclusive:true,allEvaluations:cache.size,repeatSeeking:'checked on sampled times only'},findings,exceptions,notApplicable,lifecycle:lifecycleMeasurements,replacements:replacementMeasurements,sourceLinks:sourceLinkMeasurements,contentVersionCoverage,d1Classification,actions:actionMeasurements,checkpoints:checkpointMeasurements,relays:relayMeasurements,framing:{viewport:spec.viewport,objects:objectScale,camera:cameraSamples.length?{sampleCount:cameraSamples.length,zoomRange:[Math.min(...cameraSamples.map(c=>c.z)),Math.max(...cameraSamples.map(c=>c.z))],centerRange:{x:[Math.min(...cameraSamples.map(c=>c.cx)),Math.max(...cameraSamples.map(c=>c.cx))],y:[Math.min(...cameraSamples.map(c=>c.cy)),Math.max(...cameraSamples.map(c=>c.cy))]}}:null},requiredNext:['Inspect corresponding encoded frames and confirm adapter/source/video association.','Review reading, semantics, sound alignment and 1x perception separately. No finding is not visual approval.']};
|
|
568
|
+
}
|
|
569
|
+
const HELP=`node scripts/motion-audit.mjs --adapter <project/adapter.mjs> --out <project/new-audit.json>
|
|
570
|
+
Adapter exports exportAudit() returning schemaVersion 1, fps/duration/viewport, sourceFiles, videoFile, coverage, actual frameAt(seconds), and timeline-derived actions/checkpoints/relays. See schema comments in this file.
|
|
571
|
+
Frame objects MUST be final-screen {id,x,y,width,height,opacity,rotation?}; contentVersion identifies actual rendered text/identity (legacy frame.semantic[objectId] scalar supported). Optional localGeometry, process progress, and replacement {kind,progress,fromVersion,toVersion} must derive from production, not invented ramps; all coverage IDs must exist even while hidden. Camera is optional {cx,cy,z}. Never provide a second hand-authored state table.
|
|
572
|
+
Internal process actions reuse the production timeline: kind:'process', objectId, start/end, channels. x/y/width/height/rotation are read from production localGeometry; maskProgress/pathProgress/morphProgress/occlusionProgress from process. Component parentId names its actual covered container and localGeometry excludes that parent's transport. Missing local state, hidden-only changes or no visible internal change are incomplete coverage. processCoverage lists measured changes, exposed parts with no process action and unexposed scope; parameter movement does not certify semantics or perceptual strength. Optional actions[].motionGate:'anticipation', relays[].motionGate:'follow'|'rigid-feedback', and coverage.mainContentIds are reused by motion-gates; no separate motionCast promises are needed for these measurements.
|
|
573
|
+
Source and video are SHA-256 bound. Exceptions need kind plus evidence {sourceFile,anchor,reason} and remain human-review obligations.
|
|
574
|
+
Empty checkpoints/relays may declare coverage.notApplicable[group]={sourceFile,anchor,reason}; sources must be hash-bound and anchors must exist. Unsupported or contradictory waivers fail. No primary actions remains incomplete.
|
|
575
|
+
Per-channel uniformity is review-only; uniform-screen-motion tests combined final-screen bbox-point speeds for ordinary transfer/camera actions. Rotation-excluded intervals or insufficient consecutive visible samples are incomplete coverage, not a no-finding pass. Hidden/offscreen-only geometry cannot suppress a relay wait, while appearing/disappearing objects count as changes. Offscreen rotated bounds without a known pivot are visibility-unresolved and require review.
|
|
576
|
+
D1 object categories are mg/overlay/subtitle-cue/source-footage/data-readout via objects[].d1Category. Only consistent subtitle-cue/source-footage declarations skip all D1; data-readout skips content updates only and retains lifecycle/source-link checks. Missing/unknown/varying values keep all D1. d1Classification records full versus content-only exclusions, each check scope and excluded source-link targets; declarations do not prove authenticity. Source content and packaging overlays must use distinct object IDs. Other motion checks never inherit this exclusion. D1 samples encoded times [0,duration); the analytic EOF state is not another encoded frame. Partial content identity is incomplete coverage with unresolved intervals, not an exact replacement time. Tiny shape/progress noise cannot establish a process, and replacement progress must meet the actual identity boundary, not start afterward. D1 adds review-only opacity-only-lifecycle / instant-element-visibility and content-replaced-without-process findings. Tiny translations <=24px are a locator, not a quality threshold. Camera inversion is explicitly an inference; provide localGeometry to remove it. Retained dimming and evidence-bound scope:'scene' cuts are distinct from disappearance. Unexposed content identities are listed as uncovered; no finding cannot claim those were checked. sourceLinks optionally audit same-location split/copy origins with source evidence.
|
|
577
|
+
Exit 0: measured-no-findings in declared scope only; NOT visual pass. Exit 2: findings require repair or review. Exit 1: incomplete coverage or invalid inputs. Output is engineering sampling, NOT pixel tracking. No install or rendering.`;
|
|
578
|
+
async function main(){
|
|
579
|
+
const args=process.argv.slice(2);if(args.includes('--help')){console.log(HELP);return;}
|
|
580
|
+
let adapter,out;for(let i=0;i<args.length;i++){const k=args[i],v=args[++i];if(!v||v.startsWith('--'))throw Error('Missing argument '+k);if(k==='--adapter')adapter=v;else if(k==='--out')out=v;else throw Error('Unknown argument '+k);}
|
|
581
|
+
if(!adapter||!out)throw Error('Require --adapter and --out');
|
|
582
|
+
const file=fs.realpathSync(path.resolve(adapter)),mod=await import(pathToFileURL(file).href);
|
|
583
|
+
const fn=mod.exportAudit??mod.default?.exportAudit;if(typeof fn!=='function')throw Error('Adapter must export exportAudit()');
|
|
584
|
+
const result=auditMotion(await fn(),{baseDir:path.dirname(file),adapterFile:file});
|
|
585
|
+
fs.writeFileSync(path.resolve(out),JSON.stringify(result,null,2)+'\n',{encoding:'utf8',flag:'wx'});
|
|
586
|
+
console.log(JSON.stringify({status:result.status,findings:result.findings.length,coverageGaps:result.coverageGaps,output:path.resolve(out),visualAcceptance:result.visualAcceptance}));
|
|
587
|
+
process.exitCode=result.status==='incomplete'?1:result.findings.length?2:0;
|
|
588
|
+
}
|
|
589
|
+
if(process.argv[1]&&import.meta.url===pathToFileURL(path.resolve(process.argv[1])).href)main().catch(e=>{console.error(e.message);process.exitCode=1;});
|