HEL-822: land HEL-821 A1+A2 source onto PR#4 base (db571ba)

- 13 modified / 8 added / 1 deleted per CHANGES.json (author package 76bc120b)
- docs/requirements v1.10 + prototypes/hel-799 + PROVENANCE from bundle, verified byte-identical to 63799f0
- AGENTS.md + scripts/check_requirements.py restored from governance commit 63799f0

Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
白栖知
2026-10-24 06:10:53 +08:00
co-authored by multica-agent
parent db571ba204
commit 003d8c2cae
78 changed files with 11055 additions and 433 deletions
+93
View File
@@ -0,0 +1,93 @@
# Minimal Chrome DevTools Protocol driver for headless Edge (Windows PowerShell 5.1).
$ErrorActionPreference = 'Stop'
$script:edge = 'C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe'
$script:id = 0
$script:events = New-Object System.Collections.ArrayList
function Start-Browser([int]$port = 9333) {
$profile = Join-Path $env:TEMP "edge-hel793-$port"
$script:proc = Start-Process $script:edge -ArgumentList "--headless=new", "--remote-debugging-port=$port", "--user-data-dir=$profile", "--no-first-run", "--hide-scrollbars", "--force-color-profile=srgb", "--autoplay-policy=no-user-gesture-required", "about:blank" -PassThru
for ($i = 0; $i -lt 50; $i++) {
try { $targets = Invoke-RestMethod "http://127.0.0.1:$port/json" -TimeoutSec 2; break } catch { Start-Sleep -Milliseconds 200 }
}
$page = $targets | Where-Object { $_.type -eq 'page' } | Select-Object -First 1
$script:ws = New-Object System.Net.WebSockets.ClientWebSocket
$script:ws.Options.KeepAliveInterval = [TimeSpan]::FromSeconds(30)
$script:ws.ConnectAsync([Uri]$page.webSocketDebuggerUrl, [Threading.CancellationToken]::None).Wait()
$script:proc.Id
}
function Stop-Browser { try { $script:ws.Dispose() } catch {}; if ($script:proc -and -not $script:proc.HasExited) { Stop-Process -Id $script:proc.Id -Force } }
function Receive-Message {
$buffer = New-Object byte[] 1048576
$ms = New-Object System.IO.MemoryStream
do {
$seg = New-Object System.ArraySegment[byte] -ArgumentList @(, $buffer)
$r = $script:ws.ReceiveAsync($seg, [Threading.CancellationToken]::None).GetAwaiter().GetResult()
$ms.Write($buffer, 0, $r.Count)
} while (-not $r.EndOfMessage)
[Text.Encoding]::UTF8.GetString($ms.ToArray()) | ConvertFrom-Json
}
function Send-Cdp([string]$method, $params = @{}) {
$script:id++
$myId = $script:id
$json = @{ id = $myId; method = $method; params = $params } | ConvertTo-Json -Depth 10 -Compress
$bytes = [Text.Encoding]::UTF8.GetBytes($json)
$seg = New-Object System.ArraySegment[byte] -ArgumentList @(, $bytes)
$script:ws.SendAsync($seg, [System.Net.WebSockets.WebSocketMessageType]::Text, $true, [Threading.CancellationToken]::None).Wait()
while ($true) {
$m = Receive-Message
if ($m.id -eq $myId) { if ($m.error) { throw "$method failed: $($m.error.message)" }; return $m.result }
if ($m.method) { Handle-Event $m }
}
}
function Handle-Event($m) {
if ($m.method -eq 'Page.screencastFrame') {
if ($script:recording) { [void]$script:frames.Add(@{ data = $m.params.data; t = $m.params.metadata.timestamp }) }
Send-Ack $m.params.sessionId
} else { [void]$script:events.Add($m.method) }
}
function Send-Ack($sid) {
$script:id++
$json = @{ id = $script:id; method = 'Page.screencastFrameAck'; params = @{ sessionId = $sid } } | ConvertTo-Json -Compress
$bytes = [Text.Encoding]::UTF8.GetBytes($json)
$seg = New-Object System.ArraySegment[byte] -ArgumentList @(, $bytes)
$script:ws.SendAsync($seg, [System.Net.WebSockets.WebSocketMessageType]::Text, $true, [Threading.CancellationToken]::None).Wait()
}
function Invoke-Js([string]$expr, [switch]$await) {
$r = Send-Cdp 'Runtime.evaluate' @{ expression = $expr; returnByValue = $true; awaitPromise = [bool]$await }
if ($r.exceptionDetails) { throw "JS error: $($r.exceptionDetails.exception.description)" }
$r.result.value
}
function Set-View([int]$w, [int]$h, [switch]$mobile, [double]$dpr = 1) {
[void](Send-Cdp 'Emulation.setDeviceMetricsOverride' @{ width = $w; height = $h; deviceScaleFactor = $dpr; mobile = [bool]$mobile })
if ($mobile) { [void](Send-Cdp 'Emulation.setTouchEmulationEnabled' @{ enabled = $true; maxTouchPoints = 5 }) }
else { [void](Send-Cdp 'Emulation.setTouchEmulationEnabled' @{ enabled = $false }) }
}
function Open-Page([string]$url) {
[void](Send-Cdp 'Page.enable')
[void](Send-Cdp 'Page.navigate' @{ url = $url })
Wait-Ms 1500
}
# Keep pumping events (screencast frames) while waiting.
function Wait-Ms([int]$ms) {
$until = [DateTime]::Now.AddMilliseconds($ms)
while ([DateTime]::Now -lt $until) {
[void](Send-Cdp 'Runtime.evaluate' @{ expression = '0'; returnByValue = $true })
Start-Sleep -Milliseconds 40
}
}
function Save-Shot([string]$path) {
$r = Send-Cdp 'Page.captureScreenshot' @{ format = 'png' }
[IO.File]::WriteAllBytes($path, [Convert]::FromBase64String($r.data))
}
function Start-Rec([int]$maxW = 1440, [int]$maxH = 900) {
$script:frames = New-Object System.Collections.ArrayList
$script:recording = $true
[void](Send-Cdp 'Page.startScreencast' @{ format = 'jpeg'; quality = 82; maxWidth = $maxW; maxHeight = $maxH; everyNthFrame = 1 })
}
function Stop-Rec {
[void](Send-Cdp 'Page.stopScreencast')
$script:recording = $false
$script:frames
}
+36
View File
@@ -0,0 +1,36 @@
param([string]$video, [string]$png, [int]$cols = 4, [int]$count = 12, [int]$thumbW = 480)
# Decodes the finished WebM in a browser and tiles evenly spaced frames, proving the file plays and showing motion over time.
. "$PSScriptRoot\cdp.ps1"
$dir = Split-Path $video
$page = Join-Path $dir 'contact.html'
Set-Content -Path $page -Encoding utf8 -Value '<!doctype html><body style="margin:0;background:#000"><video id=v muted playsinline></video><canvas id=c></canvas></body>'
$script:proc = Start-Process $script:edge -ArgumentList '--headless=new', '--remote-debugging-port=9337', "--user-data-dir=$env:TEMP\edge-hel799-contact", '--allow-file-access-from-files', '--autoplay-policy=no-user-gesture-required', 'about:blank' -PassThru
for ($i = 0; $i -lt 50; $i++) { try { $targets = Invoke-RestMethod 'http://127.0.0.1:9337/json' -TimeoutSec 2; break } catch { Start-Sleep -Milliseconds 200 } }
$t = $targets | Where-Object { $_.type -eq 'page' } | Select-Object -First 1
$script:ws = New-Object System.Net.WebSockets.ClientWebSocket
$script:ws.ConnectAsync([Uri]$t.webSocketDebuggerUrl, [Threading.CancellationToken]::None).Wait()
try {
Open-Page ('file:///' + ($page -replace '\\', '/'))
$src = 'file:///' + ((Resolve-Path $video).Path -replace '\\', '/')
$js = @"
(async () => {
const v = document.getElementById('v'); v.src = '$src';
await new Promise((ok, no) => { v.onloadeddata = ok; v.onerror = () => no(new Error('decode failed')); });
// WebM from MediaRecorder has no duration header; seek to the end once to learn it.
if (!isFinite(v.duration)) { v.currentTime = 1e6; await new Promise(ok => v.ondurationchange = ok); await new Promise(ok => { v.onseeked = ok; v.currentTime = 0; }); }
const n = $count, cols = $cols, tw = $thumbW, th = Math.round(tw * v.videoHeight / v.videoWidth), rows = Math.ceil(n / cols);
const c = document.getElementById('c'); c.width = cols * tw; c.height = rows * (th + 22); const x = c.getContext('2d');
x.fillStyle = '#000'; x.fillRect(0, 0, c.width, c.height); x.font = '14px sans-serif';
for (let i = 0; i < n; i++) {
const t = v.duration * (i + .5) / n;
await new Promise(ok => { v.onseeked = ok; v.currentTime = t; });
const cx = (i % cols) * tw, cy = Math.floor(i / cols) * (th + 22);
x.drawImage(v, cx, cy + 22, tw, th); x.fillStyle = '#fff'; x.fillText(t.toFixed(1) + 's', cx + 6, cy + 16);
}
return JSON.stringify({duration: v.duration, w: v.videoWidth, h: v.videoHeight, png: c.toDataURL('image/png').split(',')[1]});
})()
"@
$r = Invoke-Js $js -await | ConvertFrom-Json
[IO.File]::WriteAllBytes($png, [Convert]::FromBase64String($r.png))
"duration=$([math]::Round($r.duration,1))s size=$($r.w)x$($r.h)"
} finally { Stop-Browser; Remove-Item $page -ErrorAction SilentlyContinue }
+87
View File
@@ -0,0 +1,87 @@
param([string]$name, [int]$w = 1440, [int]$h = 900, [switch]$mobile, [string]$query = '', [string]$steps, [string]$out = "$PWD\rec")
# Records a scripted walkthrough as WebM. $steps: lines of "wait <ms>" | "tap <css>" | "js <expr>" | "type <css>|<text>" | "shot <file>".
. "$PSScriptRoot\cdp.ps1"
New-Item -ItemType Directory -Force $out | Out-Null
$frameDir = Join-Path $out "frames-$name"
if (Test-Path $frameDir) { Remove-Item $frameDir -Recurse -Force }
New-Item -ItemType Directory -Force $frameDir | Out-Null
$url = 'file:///' + ((Resolve-Path "$PSScriptRoot\..\index.html").Path -replace '\\', '/') + $query
# Recording-only touch marker so viewers can see where a tap happened. Not part of the prototype.
$tapJs = @'
window.__tap = sel => { const el = document.querySelector(sel); if (!el) throw new Error('missing ' + sel);
const r = el.getBoundingClientRect(), d = document.createElement('div');
d.style.cssText = `position:fixed;z-index:99999;left:${r.left + r.width / 2 - 18}px;top:${r.top + r.height / 2 - 18}px;width:36px;height:36px;border-radius:50%;border:2px solid #fff;background:#ffffff40;pointer-events:none;transition:opacity .5s,transform .5s`;
document.body.append(d); requestAnimationFrame(() => { d.style.transform = 'scale(1.6)'; d.style.opacity = '0'; }); setTimeout(() => d.remove(), 700); el.click(); return 1; };
'@
$null = Start-Browser 9335
try {
Set-View $w $h -mobile:$mobile -dpr 1
Open-Page $url
Wait-Ms 1200
[void](Invoke-Js $tapJs)
Start-Rec 1280 900
foreach ($line in ($steps -split "`n")) {
$line = $line.Trim(); if (-not $line) { continue }
$cmd, $arg = $line -split ' ', 2
switch ($cmd) {
'wait' { Wait-Ms ([int]$arg) }
'tap' { [void](Invoke-Js "__tap('$arg')"); Wait-Ms 60 }
'js' { [void](Invoke-Js $arg) }
'type' { $sel, $text = $arg -split '\|', 2; [void](Invoke-Js "(()=>{const e=document.querySelector('$sel');e.focus();e.value='$text';e.dispatchEvent(new Event('input'));return 1})()") }
'shot' { Save-Shot (Join-Path $out $arg) }
'log' { Write-Output ("{0}: {1}" -f $arg, (Invoke-Js $arg)) }
}
}
$frames = Stop-Rec
} finally { Stop-Browser }
# Write frames + timing manifest.
$t0 = $frames[0].t; $list = @()
for ($i = 0; $i -lt $frames.Count; $i++) {
$f = $frames[$i]; $file = 'f{0:D5}.jpg' -f $i
[IO.File]::WriteAllBytes((Join-Path $frameDir $file), [Convert]::FromBase64String($f.data))
$list += @{ f = $file; t = [math]::Round(($f.t - $t0) * 1000) }
}
$dur = $list[-1].t
"frames=$($frames.Count) duration=${dur}ms fps=$([math]::Round($frames.Count / ($dur / 1000), 1))"
$manifest = ($list | ConvertTo-Json -Compress)
# Encode in a second headless browser: draw frames on a canvas at their real timing and capture with MediaRecorder.
$encoder = Join-Path $frameDir 'encode.html'
Set-Content -Path $encoder -Encoding utf8 -Value '<!doctype html><canvas id=c></canvas>'
$script:edgeArgs = $null
$profile = Join-Path $env:TEMP 'edge-hel799-enc'
$script:proc = Start-Process $script:edge -ArgumentList '--headless=new', '--remote-debugging-port=9336', "--user-data-dir=$profile", '--allow-file-access-from-files', '--autoplay-policy=no-user-gesture-required', 'about:blank' -PassThru
for ($i = 0; $i -lt 50; $i++) { try { $targets = Invoke-RestMethod 'http://127.0.0.1:9336/json' -TimeoutSec 2; break } catch { Start-Sleep -Milliseconds 200 } }
$page = $targets | Where-Object { $_.type -eq 'page' } | Select-Object -First 1
$script:ws = New-Object System.Net.WebSockets.ClientWebSocket
$script:ws.ConnectAsync([Uri]$page.webSocketDebuggerUrl, [Threading.CancellationToken]::None).Wait()
try {
Open-Page ('file:///' + ($encoder -replace '\\', '/'))
$js = @"
(async () => {
const list = $manifest, base = location.href.replace(/encode\.html.*$/, '');
const load = f => new Promise((ok, no) => { const i = new Image(); i.onload = () => ok(i); i.onerror = no; i.src = base + f; });
const first = await load(list[0].f), c = document.getElementById('c');
c.width = first.naturalWidth; c.height = first.naturalHeight; const x = c.getContext('2d');
x.drawImage(first, 0, 0);
const stream = c.captureStream(30), chunks = [];
const rec = new MediaRecorder(stream, {mimeType: 'video/webm;codecs=vp9', videoBitsPerSecond: 3000000});
rec.ondataavailable = e => e.data.size && chunks.push(e.data);
const done = new Promise(ok => rec.onstop = ok);
rec.start(1000);
const start = performance.now(); let next = await load(list[1] ? list[1].f : list[0].f);
for (let i = 1; i < list.length; i++) {
const img = next; const pre = list[i + 1] ? load(list[i + 1].f) : null;
const wait = list[i].t - (performance.now() - start); if (wait > 0) await new Promise(r => setTimeout(r, wait));
x.drawImage(img, 0, 0); if (pre) next = await pre;
}
await new Promise(r => setTimeout(r, 400)); rec.stop(); await done;
const blob = new Blob(chunks, {type: 'video/webm'});
return await new Promise(ok => { const fr = new FileReader(); fr.onload = () => ok(fr.result.split(',')[1]); fr.readAsDataURL(blob); });
})()
"@
$b64 = Invoke-Js $js -await
[IO.File]::WriteAllBytes((Join-Path $out "$name.webm"), [Convert]::FromBase64String($b64))
"wrote $name.webm ($([math]::Round((Get-Item (Join-Path $out "$name.webm")).Length / 1MB, 2)) MB)"
} finally { Stop-Browser }
+36
View File
@@ -0,0 +1,36 @@
param([int]$w = 1600, [int]$h = 1000, [switch]$mobile, [double]$dpr = 1, [string]$query = '', [string]$steps = '', [string]$out = "$PSScriptRoot\..\evidence", [int]$port = 9341, [switch]$reduced)
# Scripted screenshots in headless Edge. $steps: lines of
# wait <ms> | js <expr> | log <expr> | shot <file> | key <Escape|ArrowLeft|ArrowRight> | click <css> | type <css>|<text>
. "$PSScriptRoot\cdp.ps1"
New-Item -ItemType Directory -Force $out | Out-Null
$url = 'file:///' + ((Resolve-Path "$PSScriptRoot\..\index.html").Path -replace '\\', '/') + $query
$null = Start-Browser $port
try {
Set-View $w $h -mobile:$mobile -dpr $dpr
if ($reduced) { [void](Send-Cdp 'Emulation.setEmulatedMedia' @{ features = @(@{ name = 'prefers-reduced-motion'; value = 'reduce' }) }) }
[void](Send-Cdp 'Runtime.enable')
Open-Page $url
Wait-Ms 800
[void](Invoke-Js "window.__errors=[];addEventListener('error',e=>__errors.push(String(e.message)));1")
foreach ($line in ($steps -split "`n")) {
$line = $line.Trim(); if (-not $line) { continue }
$cmd, $arg = $line -split ' ', 2
switch ($cmd) {
'wait' { Wait-Ms ([int]$arg) }
'js' { [void](Invoke-Js $arg) }
'log' { Write-Output ("{0} => {1}" -f $arg, (Invoke-Js $arg)) }
'shot' { Save-Shot (Join-Path $out $arg); Write-Output "shot $arg" }
'key' {
$codes = @{ Escape = 27; ArrowLeft = 37; ArrowRight = 39 }
[void](Send-Cdp 'Input.dispatchKeyEvent' @{ type = 'rawKeyDown'; key = $arg; code = $arg; windowsVirtualKeyCode = $codes[$arg] })
[void](Send-Cdp 'Input.dispatchKeyEvent' @{ type = 'keyUp'; key = $arg; code = $arg; windowsVirtualKeyCode = $codes[$arg] })
}
'click' {
$r = Invoke-Js "(()=>{const e=document.querySelector('$arg');const r=e.getBoundingClientRect();return JSON.stringify([r.left+r.width/2,r.top+r.height/2])})()" | ConvertFrom-Json
foreach ($t in 'mousePressed', 'mouseReleased') { [void](Send-Cdp 'Input.dispatchMouseEvent' @{ type = $t; x = $r[0]; y = $r[1]; button = 'left'; clickCount = 1 }) }
}
'type' { $sel, $text = $arg -split '\|', 2; [void](Invoke-Js "(()=>{const e=document.querySelector('$sel');e.focus();e.value='$text';e.dispatchEvent(new Event('input'));return 1})()") }
}
}
Write-Output ("errors => " + (Invoke-Js 'JSON.stringify(window.__errors)'))
} finally { Stop-Browser }
+19
View File
@@ -0,0 +1,19 @@
param([string[]]$files, [string]$out, [int]$cols = 3, [int]$cellW = 640, [string[]]$labels = @())
# Lays screenshots out on one contact sheet (System.Drawing; no extra tools).
Add-Type -AssemblyName System.Drawing
$imgs = $files | ForEach-Object { [Drawing.Image]::FromFile((Resolve-Path $_).Path) }
$cellH = [int]($cellW * $imgs[0].Height / $imgs[0].Width)
$rows = [math]::Ceiling($imgs.Count / $cols)
$bmp = New-Object Drawing.Bitmap ($cols * $cellW + ($cols + 1) * 8), ($rows * ($cellH + 30) + 8)
$g = [Drawing.Graphics]::FromImage($bmp)
$g.Clear([Drawing.Color]::FromArgb(10, 12, 24)); $g.InterpolationMode = 'HighQualityBicubic'
$font = New-Object Drawing.Font 'Microsoft YaHei', 12
for ($i = 0; $i -lt $imgs.Count; $i++) {
$x = 8 + ($i % $cols) * ($cellW + 8); $y = 8 + [math]::Floor($i / $cols) * ($cellH + 30)
$g.DrawImage($imgs[$i], $x, $y, $cellW, $cellH)
$label = if ($labels.Count -gt $i) { $labels[$i] } else { [IO.Path]::GetFileNameWithoutExtension($files[$i]) }
$g.DrawString($label, $font, [Drawing.Brushes]::White, $x, $y + $cellH + 4)
}
$bmp.Save($out, [Drawing.Imaging.ImageFormat]::Png)
$imgs | ForEach-Object { $_.Dispose() }
"wrote $out"
+176
View File
@@ -0,0 +1,176 @@
param([string]$out = "$PSScriptRoot\..\evidence")
# Behavioural checks in headless Edge (real input events via CDP). Each check records pass/fail with observed values.
. "$PSScriptRoot\cdp.ps1"
New-Item -ItemType Directory -Force $out | Out-Null
$url = 'file:///' + ((Resolve-Path "$PSScriptRoot\..\index.html").Path -replace '\\', '/')
$results = New-Object System.Collections.ArrayList
function Check([string]$name, [bool]$ok, $detail) { [void]$results.Add([ordered]@{ check = $name; pass = $ok; detail = $detail }); "{0} {1} {2}" -f ($(if ($ok) { 'PASS' } else { 'FAIL' })), $name, ($detail | ConvertTo-Json -Compress -Depth 5) }
function J($e) { Invoke-Js $e | ConvertFrom-Json }
function Key($k) { $c = @{ Escape = 27; ArrowLeft = 37; ArrowRight = 39 }; foreach ($t in 'rawKeyDown', 'keyUp') { [void](Send-Cdp 'Input.dispatchKeyEvent' @{ type = $t; key = $k; code = $k; windowsVirtualKeyCode = $c[$k] }) } }
function Click($sel) {
$r = J "(()=>{const e=document.querySelector('$sel');const r=e.getBoundingClientRect();return JSON.stringify([r.left+r.width/2,r.top+r.height/2])})()"
foreach ($t in 'mouseMoved', 'mousePressed', 'mouseReleased') { [void](Send-Cdp 'Input.dispatchMouseEvent' @{ type = $t; x = $r[0]; y = $r[1]; button = 'left'; clickCount = 1 }) }
}
# Per-frame recorder of the camera, so continuity can be checked frame by frame.
$rec = "window.__f=[];(function l(ts){const i=Scene.info();__f.push([ts||performance.now(),i.t,i.talkOpacity,i.roomVisible?1:0,document.body.dataset.mode]);if(__f.length<2000)requestAnimationFrame(l)})();1"
$finite = 'document.getAnimations().filter(a=>a.playState==="running"&&a.effect&&a.effect.getTiming().iterations!==Infinity).length'
$null = Start-Browser 9351
try {
Set-View 1600 1000
Open-Page "${url}?theme=moon&tier=0"; Wait-Ms 1200
# A. Space: mouse click walks you closer (continuous), and back.
[void](Invoke-Js $rec)
Click '#start-talk'; Wait-Ms 150
$a = J 'JSON.stringify(Scene.info())'
Wait-Ms 2600
$b = J 'JSON.stringify(Object.assign(Scene.info(),{conv:getComputedStyle(document.querySelector("#conversation")).opacity,mode:document.body.dataset.mode}))'
Check 'click-enter-moves-camera-gradually' ($a.t -gt 0.02 -and $a.t -lt 0.9 -and $b.t -eq 1 -and $b.settled -and [double]$b.conv -gt .99) @{ at150ms = $a.t; at2750ms = $b.t; conversationOpacity = $b.conv }
$f = J 'JSON.stringify(__f)'
$maxStep = 0; $gap = 0
for ($i = 1; $i -lt $f.Count; $i++) { $maxStep = [math]::Max($maxStep, [math]::Abs($f[$i][1] - $f[($i - 1)][1]) / [math]::Max(.001, ($f[$i][0] - $f[($i - 1)][0]) / 1000)); if ($f[$i][2] -lt .999 -and $f[$i][3] -eq 0) { $gap++ } }
Check 'enter-no-jump-no-black-frame' ($maxStep -lt 4 -and $gap -eq 0) @{ frames = $f.Count; maxCameraSpeedPerSecond = [math]::Round($maxStep, 4); framesWithNeitherStillFullyShown = $gap }
Save-Shot "$out\desktop-talk-moon.png"
$pt = J 'JSON.stringify([...document.querySelectorAll(".plate .photo")].map(p=>p.getAnimations().length))'
$tr = J 'JSON.stringify([document.querySelector("#plate-room").style.transform,document.querySelector("#plate-talk").style.transform])'
Check 'photos-never-warped-or-animated' (($pt | Measure-Object -Sum).Sum -eq 0 -and ($tr -join ' ') -notmatch 'scale\([^)]*,|skew|rotate|matrix') @{ photoAnimations = $pt; plateTransforms = $tr }
# B. Rapid toggle: leave while still walking in; it turns around smoothly from where it is.
Click '#close-talk'; Wait-Ms 1600
[void](Invoke-Js $rec)
Click '#start-talk'; Wait-Ms 260
$m1 = J 'JSON.stringify(Scene.info())'
Click '#close-talk'; Wait-Ms 60
$m2 = J 'JSON.stringify(Scene.info())'
Click '#start-talk'; Wait-Ms 120; Click '#close-talk'; Wait-Ms 1800
$m3 = J 'JSON.stringify(Object.assign(Scene.info(),{mode:document.body.dataset.mode,talkVis:getComputedStyle(document.querySelector("#plate-talk")).visibility}))'
$f = J 'JSON.stringify(__f)'
$maxStep = 0; $gap = 0
for ($i = 1; $i -lt $f.Count; $i++) { $maxStep = [math]::Max($maxStep, [math]::Abs($f[$i][1] - $f[($i - 1)][1]) / [math]::Max(.001, ($f[$i][0] - $f[($i - 1)][0]) / 1000)); if ($f[$i][2] -lt .999 -and $f[$i][3] -eq 0) { $gap++ } }
Check 'rapid-toggle-redirects-smoothly' ($m1.t -gt 0.05 -and $m1.t -lt .95 -and [math]::Abs($m2.t - $m1.t) -lt .2 -and $m3.t -eq 0 -and $m3.mode -eq 'home' -and $maxStep -lt 4 -and $gap -eq 0) @{ midway = $m1.t; justAfterTurn = $m2.t; final = $m3.t; mode = $m3.mode; maxCameraSpeedPerSecond = [math]::Round($maxStep, 4); framesWithNeitherStillFullyShown = $gap; talkPlate = $m3.talkVis }
# C. Keyboard: Escape and arrows land at once (HEL-795 rule), no long animation, no re-played ink.
Click '#start-talk'; Wait-Ms 1800
[void](Invoke-Js "__proto.runScenario('long')"); Wait-Ms 9000
Key 'ArrowLeft'; Wait-Ms 80
$k1 = J "JSON.stringify({finite:$finite,c:__proto.state.cursor,flow:__proto.state.flow,ink:document.querySelectorAll('#stage .is-current .ink').length,latest:!document.querySelector('#latest').hidden})"
Check 'arrow-left-instant' ($k1.finite -eq 0 -and $k1.ink -eq 0 -and -not $k1.flow -and $k1.latest) $k1
Key 'ArrowRight'; Wait-Ms 80
$k2 = J "JSON.stringify({finite:$finite,c:__proto.state.cursor,ink:document.querySelectorAll('#stage .is-current .ink').length})"
Check 'arrow-right-instant' ($k2.finite -eq 0 -and $k2.ink -eq 0 -and $k2.c -eq $k1.c + 1) $k2
Key 'Escape'; Wait-Ms 80
$k3 = J "JSON.stringify(Object.assign(Scene.info(),{finite:$finite,mode:document.body.dataset.mode,homeOpacity:getComputedStyle(document.querySelector('.home-copy')).opacity}))"
Check 'escape-leaves-instantly' ($k3.finite -eq 0 -and $k3.t -eq 0 -and $k3.mode -eq 'home' -and [double]$k3.homeOpacity -gt .99) @{ finiteAnimations = $k3.finite; camera = $k3.t; mode = $k3.mode; homeOpacity = $k3.homeOpacity }
Save-Shot "$out\desktop-home-moon.png"
# D. Reading (carried over from PR#8): auto to the end, pause/review/return, send resumes, identity, cancel, history.
Click '#start-talk'; Wait-Ms 1500
[void](Invoke-Js "__proto.runScenario('long')")
for ($i = 0; $i -lt 70; $i++) { Wait-Ms 1000; $s = J 'JSON.stringify({c:__proto.state.cursor,n:__proto.pages().length,busy:__proto.state.busy})'; if (-not $s.busy -and $s.c -eq $s.n - 1) { break } }
$s = J 'JSON.stringify({c:__proto.state.cursor,n:__proto.pages().length,busy:__proto.state.busy,flow:__proto.state.flow})'
Check 'auto-continues-long-reply-to-last-line' ($s.c -eq $s.n - 1 -and -not $s.busy -and $s.flow) @{ seconds = $i + 1; final = $s }
$c = J 'JSON.stringify((()=>{const p=__proto.pages();const m=p[p.length-1].message;return {same:p.filter(x=>x.message===m).map(x=>x.text).join("")===m.text.replace(/\n/g,""),lines:p.length}})())'
Check 'all-text-preserved-in-lines' $c.same $c
Save-Shot "$out\desktop-long-end.png"
[void](Invoke-Js "__proto.runScenario('long')"); Wait-Ms 6000
Click '#toggle-flow'; $a = J '__proto.state.cursor'; Wait-Ms 6000; $b = J '__proto.state.cursor'
Check 'pause-holds-position' ($a -eq $b) @{ before = $a; after6s = $b }
Click '#previous'; Wait-Ms 800
$l = J 'JSON.stringify({hidden:document.querySelector("#latest").hidden,text:document.querySelector("#latest").textContent,c:__proto.state.cursor,head:__proto.state.head})'
Check 'review-back-offers-return' (-not $l.hidden) $l
Save-Shot "$out\desktop-review.png"
Click '#latest'; Wait-Ms 9000
$r = J 'JSON.stringify({c:__proto.state.cursor,flow:__proto.state.flow})'
Check 'return-resumes-flow' ($r.flow -and $r.c -gt $l.head) @{ head = $l.head; now = $r }
[void](Invoke-Js "__proto.setFlow(false,true)")
[void](Invoke-Js "(()=>{const d=document.querySelector('#draft');d.value='你在做什么?';document.querySelector('#composer').requestSubmit();return 1})()"); Wait-Ms 6000
$r = J 'JSON.stringify({c:__proto.state.cursor,n:__proto.pages().length,flow:__proto.state.flow,toast:document.querySelector("#toast").textContent,draft:document.querySelector("#draft").value})'
Check 'send-gives-feedback-and-resumes-auto' ($r.flow -and $r.c -ge 1 -and $r.draft -eq '') $r
$who = J 'JSON.stringify([...document.querySelectorAll("#stage .line:not(.leaving)")].map(l=>({role:l.dataset.role,label:l.querySelector(".who b").textContent})))'
Check 'identity-labelled' (@($who | Where-Object { ($_.role -eq 'user' -and $_.label -eq '你') -or ($_.role -eq 'her' -and $_.label -eq '晚晚') }).Count -eq @($who).Count) $who
[void](Invoke-Js "__proto.runScenario('waiting')"); Wait-Ms 3500; Click '#stop'; Wait-Ms 600
$x = J 'JSON.stringify((()=>{const m=__proto.pages().map(p=>p.message).pop();return {status:m.status,len:m.text.length,busy:__proto.state.busy}})())'
Check 'cancel-keeps-partial-marked-incomplete' ($x.status -eq 'cancelled' -and $x.len -gt 0 -and -not $x.busy) $x
[void](Invoke-Js "__proto.runScenario('long')"); Wait-Ms 7000; $a = J '__proto.state.cursor'
Click '#history'; Wait-Ms 3000; $b = J '__proto.state.cursor'
$mid = J 'JSON.stringify(Object.assign(Scene.info(),{mode:document.body.dataset.mode}))'
Save-Shot "$out\desktop-history-moon.png"
Click '#close-sheet'; Wait-Ms 1200
$c = J 'JSON.stringify({c:__proto.state.cursor,mode:document.body.dataset.mode})'
Check 'history-holds-she-stays-close-then-returns' ($a -eq $b -and $c.mode -eq 'talk' -and $mid.mode -eq 'record' -and $mid.t -eq 1) @{ before = $a; whileOpen = $b; cameraWhileOpen = $mid.t; after = $c }
# E. Entries lead somewhere (demo content, clearly marked).
$titles = @()
foreach ($step in @("document.querySelector('[data-nav=days]').click()", "document.querySelector('[data-event=\""0\""]').click()", "document.querySelector('[data-event-history]').click()", "document.querySelector('[data-nav=manage]').click()", "document.querySelector('[data-action=relationship]').click()", "document.querySelector('[data-action=manage]').click()", "document.querySelector('[data-action=backup]').click()", "document.querySelector('[data-action=manage]').click()", "document.querySelector('[data-action=services]').click()")) {
[void](Invoke-Js $step); Wait-Ms 700; $titles += (J 'JSON.stringify(document.querySelector("#sheet-kicker").textContent+" / "+document.querySelector("#sheet-title").textContent)')
}
Check 'entries-open-demo-content' ($titles.Count -eq 9 -and ($titles | Where-Object { -not $_ }).Count -eq 0) $titles
Save-Shot "$out\desktop-manage-moon.png"
[void](Invoke-Js "window.__mic=0;if(navigator.mediaDevices){navigator.mediaDevices.getUserMedia=()=>{__mic++;return Promise.reject()}};1")
[void](Invoke-Js "document.querySelector('[data-action=voice]').click()"); Wait-Ms 600
[void](Invoke-Js "document.querySelector('[data-action=start-voice]').click()"); Wait-Ms 1500
$v = J 'JSON.stringify({mic:__mic,row:!document.querySelector("#voice-row").hidden,presence:document.querySelector("#presence").textContent})'
Check 'voice-demo-never-asks-microphone' ($v.mic -eq 0 -and $v.row) $v
Click '#end-voice'; Wait-Ms 400
# F. Themes: same structure and positions, different light.
[void](Invoke-Js "__proto.setMode('talk',{instant:true})"); Wait-Ms 800
$p1 = J 'JSON.stringify(["#composer",".navigation","#stage","#close-talk"].map(s=>{const r=document.querySelector(s).getBoundingClientRect();return [Math.round(r.left),Math.round(r.top),Math.round(r.width)]}))'
Click '[data-theme=fog]'; Wait-Ms 1600
$p2 = J 'JSON.stringify(["#composer",".navigation","#stage","#close-talk"].map(s=>{const r=document.querySelector(s).getBoundingClientRect();return [Math.round(r.left),Math.round(r.top),Math.round(r.width)]}))'
$acc = J 'JSON.stringify(getComputedStyle(document.documentElement).getPropertyValue("--accent").trim())'
Check 'themes-keep-structure' ((($p1 | ConvertTo-Json -Compress) -eq ($p2 | ConvertTo-Json -Compress)) -and $acc -eq '#ebbcff') @{ moon = $p1; fog = $p2; accent = $acc }
Save-Shot "$out\desktop-talk-fog.png"
[void](Invoke-Js "__proto.setMode('home',{instant:true})"); Wait-Ms 1200
Save-Shot "$out\desktop-home-fog.png"
# G. Layout at every size: her face, the lines, the composer and the navigation never cover each other.
$sizes = @(@(1600, 1000, 0), @(1440, 900, 0), @(1280, 720, 0), @(390, 844, 1), @(360, 740, 1), @(320, 568, 1), @(390, 430, 1))
foreach ($size in $sizes) {
$mob = [bool]$size[2]
Set-View $size[0] $size[1] -mobile:$mob -dpr 1; Open-Page "${url}?theme=moon&tier=0"; Wait-Ms 900
[void](Invoke-Js "__proto.setMode('talk',{instant:true})"); [void](Invoke-Js "__proto.runScenario('long')"); Wait-Ms 1500
if ($size[1] -lt 500) { [void](Invoke-Js "document.querySelector('#draft').focus();document.body.classList.add('typing');1") }
$worst = @{ face = 999; composer = 999; nav = 999; right = 999 }
for ($i = 0; $i -lt 14; $i++) {
Wait-Ms 1500
$g = J 'JSON.stringify((()=>{const ls=[...document.querySelectorAll("#stage .line:not(.leaving)")].filter(l=>getComputedStyle(l).display!=="none");if(!ls.length)return null;const R=e=>e.getBoundingClientRect();const top=Math.min(...ls.map(l=>R(l.querySelector("p")).top)),bottom=Math.max(...ls.map(l=>R(l).bottom)),right=Math.max(...ls.map(l=>R(l.querySelector("p")).right));const c=R(document.querySelector("#composer")),n=R(document.querySelector(".navigation")),h=Scene.info().head,navShown=getComputedStyle(document.querySelector(".navigation")).opacity>.5;return {face:top-h.bottom,composer:c.top-bottom,nav:navShown?n.top-c.bottom:99,right:innerWidth-right}})())'
if ($g) { foreach ($k in 'face', 'composer', 'nav', 'right') { $worst[$k] = [math]::Min($worst[$k], $g.$k) } }
}
if ($size[0] -eq 390 -and $size[1] -eq 430) { Save-Shot "$out\mobile-keyboard-430.png" }
if ($size[0] -eq 320) { Save-Shot "$out\mobile-320-talk.png" }
$ok = $worst.face -ge -4 -and $worst.composer -ge 0 -and $worst.nav -ge 0 -and $worst.right -ge 0
Check "no-overlap-while-flowing-$($size[0])x$($size[1])" $ok @{ minGapBelowHerChinPx = [math]::Round($worst.face, 1); minGapAboveComposerPx = [math]::Round($worst.composer, 1); minGapComposerToNavPx = [math]::Round($worst.nav, 1); minRightMarginPx = [math]::Round($worst.right, 1) }
}
# H. Long name on a phone.
Set-View 390 844 -mobile -dpr 2; Open-Page "${url}?theme=fog&tier=0"; Wait-Ms 1000
[void](Invoke-Js "document.querySelector('#rehearse').click()"); Wait-Ms 500
[void](Invoke-Js "document.querySelector('[data-action=create]').click()"); Wait-Ms 500
[void](Invoke-Js "(()=>{document.querySelector('#new-name').value='星河与晚风之间慢慢醒来的小月亮';document.querySelector('#new-relation').value='朋友';document.querySelector('#create-form').requestSubmit();return 1})()"); Wait-Ms 2500
$ov = J 'JSON.stringify((()=>{const b=document.querySelector("#stage .is-current .who b"),t=document.querySelector(".identity strong");return {name:b.textContent,lineFits:b.getBoundingClientRect().right<=innerWidth,topFits:t.getBoundingClientRect().right<=innerWidth}})())'
Check 'long-name-contained' ($ov.lineFits -and $ov.topFits) $ov
Save-Shot "$out\mobile-long-name.png"
# I. Reduced motion: no camera travel, a short crossfade only; ambient loops off.
[void](Send-Cdp 'Emulation.setEmulatedMedia' @{ features = @(@{ name = 'prefers-reduced-motion'; value = 'reduce' }) })
Set-View 1600 1000; Open-Page "${url}?theme=moon&tier=0"; Wait-Ms 1000
$s0 = J 'JSON.stringify(document.querySelector("#plate-room").style.transform)'
Click '#start-talk'; Wait-Ms 90
$rm = J 'JSON.stringify(Object.assign(Scene.info(),{room:document.querySelector("#plate-room").style.transform,loops:document.getAnimations().filter(a=>a.playState==="running"&&a.effect.getTiming().iterations===Infinity).length}))'
Wait-Ms 400
$rm2 = J 'JSON.stringify(Scene.info())'
Check 'reduced-motion-crossfade-only' ($rm.room -eq $s0 -and $rm.t -eq 1 -and $rm.talkOpacity -gt 0 -and $rm.talkOpacity -lt 1 -and $rm.loops -eq 0 -and $rm2.talkOpacity -eq 1) @{ roomUnmoved = ($rm.room -eq $s0); at90ms = $rm.talkOpacity; at490ms = $rm2.talkOpacity; ambientLoops = $rm.loops }
[void](Send-Cdp 'Emulation.setEmulatedMedia' @{ features = @() })
# J. Slow-device tier: no per-frame mask, no backdrop blur, half-resolution rain.
Open-Page "${url}?theme=fog&tier=2"; Wait-Ms 1000
Click '#start-talk'; Wait-Ms 300
$t2 = J 'JSON.stringify(Object.assign(Scene.info(),{blur:getComputedStyle(document.querySelector("#composer")).backdropFilter,rain:document.querySelector("#plate-room canvas").width}))'
Check 'low-tier-fallback' ($t2.tier -eq 2 -and -not $t2.mask -and $t2.blur -eq 'none' -and $t2.rain -eq 800) $t2
Wait-Ms 1500
Save-Shot "$out\desktop-tier2-fog.png"
} finally { Stop-Browser }
$results | ConvertTo-Json -Depth 7 | Set-Content "$out\verification.json" -Encoding utf8
$p = @($results | Where-Object { $_.pass }).Count
"$p / $($results.Count) passed"