feat: 회의 파일 가져오기와 입력 엔진 배포 보완
This commit is contained in:
parent
5a8c5cd792
commit
b3519e5da7
54 changed files with 1129 additions and 116 deletions
|
|
@ -59,6 +59,10 @@ const ZIP_PART_SIZE = '90m'
|
|||
const MAX_ZIP_PART_BYTES = 95 * 1024 * 1024
|
||||
|
||||
const wantZip = process.argv.includes('--zip')
|
||||
// 릴리스 태그 이후에는 추적 파일을 바꾸지 않는다. Scoop 산출물도 버전 폴더에 보존한다.
|
||||
const scoopPath = process.argv.includes('--release-artifacts-only')
|
||||
? join(root, 'apps', 'desktop', 'release', version, 'd3ro-voice.scoop.json')
|
||||
: join(root, 'bucket', 'd3ro-voice.json')
|
||||
const releaseDir = join(desktopDir, 'release', version)
|
||||
const appDir = join(releaseDir, 'win-unpacked')
|
||||
|
||||
|
|
@ -284,7 +288,7 @@ const scoopManifest = {
|
|||
}
|
||||
|
||||
writeFileSync(
|
||||
join(root, 'bucket', 'd3ro-voice.json'),
|
||||
scoopPath,
|
||||
`${JSON.stringify(scoopManifest, null, 2)}\n`,
|
||||
'utf8',
|
||||
)
|
||||
|
|
@ -445,8 +449,8 @@ console.log(
|
|||
),
|
||||
` zip : ${zipParts.length}개 부품 / 합계 ${(zipBytes.length / 1048576).toFixed(1)}MiB`,
|
||||
` 인덱스 : ${join(releaseDir, 'portable.json')}`,
|
||||
` scoop : ${join(root, 'bucket', 'd3ro-voice.json')}`,
|
||||
` scoop : ${scoopPath}`,
|
||||
` 런타임 : ${Object.keys(runtimeComponents).join(', ') || '(없음)'} (${runtimeIndex.platform}-${runtimeIndex.arch}) → ${join(RUNTIME_DIR, 'runtime.json')}`,
|
||||
` 게시 : node scripts/ci/publish-portable-release.mjs`,
|
||||
].join('\n'),
|
||||
)
|
||||
)
|
||||
|
|
|
|||
64
scripts/ci/lib/release-artifacts.mjs
Normal file
64
scripts/ci/lib/release-artifacts.mjs
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
import { createHash } from 'node:crypto'
|
||||
import { createReadStream } from 'node:fs'
|
||||
import { readFile, readdir, rename, stat, writeFile } from 'node:fs/promises'
|
||||
import { isAbsolute, join, relative, resolve, sep } from 'node:path'
|
||||
|
||||
const CHECKPOINT = 'release-artifacts.json'
|
||||
|
||||
function artifactPath(directory, name) {
|
||||
const path = resolve(directory, name)
|
||||
const rel = relative(resolve(directory), path)
|
||||
if (!rel || isAbsolute(rel) || rel === '..' || rel.startsWith(`..${sep}`)) {
|
||||
throw new Error(`Invalid release artifact path: ${name}`)
|
||||
}
|
||||
return path
|
||||
}
|
||||
|
||||
async function fingerprint(directory, name) {
|
||||
const path = artifactPath(directory, name)
|
||||
const info = await stat(path)
|
||||
if (!info.isFile()) throw new Error(`Release artifact is not a file: ${name}`)
|
||||
const hash = createHash('sha256')
|
||||
for await (const chunk of createReadStream(path)) hash.update(chunk)
|
||||
return { name, size: info.size, sha256: hash.digest('hex') }
|
||||
}
|
||||
|
||||
export async function saveReleaseArtifacts(directory, { version, tagCommit, withRuntime }) {
|
||||
const names = await readdir(directory)
|
||||
const installers = names.filter((name) => /-Setup-.*\.exe$/.test(name))
|
||||
if (installers.length !== 1) throw new Error('Expected exactly one release installer')
|
||||
const files = [installers[0], `${installers[0]}.blockmap`, 'latest.yml']
|
||||
if (withRuntime) {
|
||||
const portable = JSON.parse(await readFile(join(directory, 'portable.json'), 'utf8'))
|
||||
const runtime = JSON.parse(await readFile(join(directory, 'runtime', 'runtime.json'), 'utf8'))
|
||||
if (portable.version !== version || runtime.version !== version) throw new Error('Release index version mismatch')
|
||||
files.push('portable.json', 'd3ro-voice.scoop.json', 'runtime/runtime.json')
|
||||
for (const entry of [...portable.volumes, ...portable.zipParts]) files.push(entry.name)
|
||||
for (const component of Object.values(runtime.components)) {
|
||||
for (const part of component.parts) files.push(`runtime/${part.name}`)
|
||||
}
|
||||
}
|
||||
const artifacts = []
|
||||
for (const name of new Set(files)) artifacts.push(await fingerprint(directory, name))
|
||||
const checkpoint = { version, tagCommit, withRuntime, artifacts }
|
||||
const path = join(directory, CHECKPOINT)
|
||||
await writeFile(`${path}.tmp`, `${JSON.stringify(checkpoint, null, 2)}\n`)
|
||||
await rename(`${path}.tmp`, path)
|
||||
}
|
||||
|
||||
export async function verifyReleaseArtifacts(directory, expected) {
|
||||
const checkpoint = JSON.parse(await readFile(join(directory, CHECKPOINT), 'utf8'))
|
||||
for (const field of ['version', 'tagCommit', 'withRuntime']) {
|
||||
if (checkpoint[field] !== expected[field]) throw new Error(`Release checkpoint ${field} mismatch`)
|
||||
}
|
||||
if (!Array.isArray(checkpoint.artifacts) || checkpoint.artifacts.length < 3) {
|
||||
throw new Error('Release checkpoint has no complete artifact set')
|
||||
}
|
||||
for (const entry of checkpoint.artifacts) {
|
||||
const actual = await fingerprint(directory, entry.name)
|
||||
if (actual.size !== entry.size || actual.sha256 !== entry.sha256) {
|
||||
throw new Error(`Release artifact changed: ${entry.name}`)
|
||||
}
|
||||
}
|
||||
return checkpoint
|
||||
}
|
||||
63
scripts/ci/lib/release-artifacts.test.mjs
Normal file
63
scripts/ci/lib/release-artifacts.test.mjs
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
import assert from 'node:assert/strict'
|
||||
import { mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import test from 'node:test'
|
||||
import { saveReleaseArtifacts, verifyReleaseArtifacts } from './release-artifacts.mjs'
|
||||
|
||||
const identity = { version: '1.16.0', tagCommit: 'a'.repeat(40), withRuntime: false }
|
||||
async function fixture(t) {
|
||||
const dir = await mkdtemp(join(tmpdir(), 'd3ro-release-checkpoint-'))
|
||||
t.after(() => rm(dir, { recursive: true, force: true }))
|
||||
for (const name of ['D3RO-Voice-Setup-1.16.0.exe', 'D3RO-Voice-Setup-1.16.0.exe.blockmap', 'latest.yml']) {
|
||||
await writeFile(join(dir, name), `original ${name}`)
|
||||
}
|
||||
await saveReleaseArtifacts(dir, identity)
|
||||
return dir
|
||||
}
|
||||
|
||||
test('reuses exact release bytes after a partial publication', async (t) => {
|
||||
const dir = await fixture(t)
|
||||
const verified = await verifyReleaseArtifacts(dir, identity)
|
||||
assert.equal(verified.artifacts.length, 3)
|
||||
})
|
||||
|
||||
test('rejects rebuilt bytes even when size is unchanged', async (t) => {
|
||||
const dir = await fixture(t)
|
||||
const path = join(dir, 'D3RO-Voice-Setup-1.16.0.exe')
|
||||
const original = await readFile(path, 'utf8')
|
||||
await writeFile(path, original.replace('original', 'modified'))
|
||||
await assert.rejects(verifyReleaseArtifacts(dir, identity), /artifact changed/)
|
||||
})
|
||||
|
||||
test('rejects missing artifacts and a different source commit', async (t) => {
|
||||
const dir = await fixture(t)
|
||||
await assert.rejects(verifyReleaseArtifacts(dir, { ...identity, tagCommit: 'b'.repeat(40) }), /tagCommit mismatch/)
|
||||
await assert.rejects(verifyReleaseArtifacts(dir, { ...identity, withRuntime: true }), /withRuntime mismatch/)
|
||||
await rm(join(dir, 'latest.yml'))
|
||||
await assert.rejects(verifyReleaseArtifacts(dir, identity), /ENOENT/)
|
||||
})
|
||||
|
||||
test('rejects paths outside the preserved release directory', async (t) => {
|
||||
const dir = await fixture(t)
|
||||
const path = join(dir, 'release-artifacts.json')
|
||||
const checkpoint = JSON.parse(await readFile(path, 'utf8'))
|
||||
checkpoint.artifacts[0].name = '../outside.exe'
|
||||
await writeFile(path, JSON.stringify(checkpoint))
|
||||
await assert.rejects(verifyReleaseArtifacts(dir, identity), /Invalid release artifact path/)
|
||||
})
|
||||
|
||||
test('preserves runtime and portable parts and rejects missing runtime bytes', async (t) => {
|
||||
const dir = await fixture(t)
|
||||
await mkdir(join(dir, 'runtime'))
|
||||
await writeFile(join(dir, 'portable.json'), JSON.stringify({ version: identity.version, volumes: [{ name: 'portable.7z.001' }], zipParts: [{ name: 'portable.zip.001' }] }))
|
||||
await writeFile(join(dir, 'runtime/runtime.json'), JSON.stringify({ version: identity.version, components: { sidecar: { parts: [{ name: 'sidecar.tar.gz.001' }] } } }))
|
||||
for (const name of ['portable.7z.001', 'portable.zip.001', 'd3ro-voice.scoop.json', 'runtime/sidecar.tar.gz.001']) {
|
||||
await writeFile(join(dir, name), name)
|
||||
}
|
||||
const expected = { ...identity, withRuntime: true }
|
||||
await saveReleaseArtifacts(dir, expected)
|
||||
assert.equal((await verifyReleaseArtifacts(dir, expected)).artifacts.length, 9)
|
||||
await rm(join(dir, 'runtime/sidecar.tar.gz.001'))
|
||||
await assert.rejects(verifyReleaseArtifacts(dir, expected), /ENOENT/)
|
||||
})
|
||||
|
|
@ -53,6 +53,13 @@ test("parseRuntimeMinVersions reads the app's real RUNTIME_MIN_VERSION (drift gu
|
|||
assert.equal(parsed.ffmpeg, null);
|
||||
});
|
||||
|
||||
test("the shipping app rejects the old feed without typing safety fixes", () => {
|
||||
const source = readFileSync(fileURLToPath(new URL(`../../../${RUNTIME_MIN_VERSION_SOURCE}`, import.meta.url)), "utf8");
|
||||
const minVersions = parseRuntimeMinVersions(source);
|
||||
assert.match(evaluateRuntimeFeed({ index: index({ version: "1.10.0" }), minVersions, target: WINDOWS_X64_TARGET }).join(" "), /below/);
|
||||
assert.deepEqual(evaluateRuntimeFeed({ index: index({ version: "1.16.0" }), minVersions, target: WINDOWS_X64_TARGET }), []);
|
||||
});
|
||||
|
||||
test("parseRuntimeMinVersions fails loudly when the constant cannot be read", () => {
|
||||
assert.throws(() => parseRuntimeMinVersions("export const OTHER = {}"), /RUNTIME_MIN_VERSION not found/);
|
||||
assert.throws(
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
// npm run release -- minor # 1.9.0 → 1.10.0 (feat)
|
||||
// npm run release -- 2.0.0 # 직접 지정
|
||||
// npm run release -- minor --dry-run # 무엇을 할지만 출력
|
||||
// node --env-file-if-exists=.env scripts/ci/release-desktop.mjs minor --with-runtime
|
||||
// — 새 사이드카/portable을 먼저 게시한 뒤 설치본을 게시한다.
|
||||
// npm run release -- --resume # 빌드/게시/푸시 중 실패했을 때 같은 버전으로 이어서
|
||||
//
|
||||
// 단계 (실패하면 거기서 멈추고, --resume 으로 이어 간다):
|
||||
|
|
@ -23,11 +25,13 @@ import { existsSync, readFileSync, writeFileSync } from 'node:fs'
|
|||
import { dirname, join } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { loadSigningKey, publicPemOf } from './lib/update-manifest-signature.mjs'
|
||||
import { saveReleaseArtifacts, verifyReleaseArtifacts } from './lib/release-artifacts.mjs'
|
||||
|
||||
const root = join(dirname(fileURLToPath(import.meta.url)), '..', '..')
|
||||
const args = process.argv.slice(2)
|
||||
const dryRun = args.includes('--dry-run')
|
||||
const resume = args.includes('--resume')
|
||||
const withRuntime = args.includes('--with-runtime')
|
||||
const bumpArg = args.find((arg) => !arg.startsWith('--'))
|
||||
const CANONICAL_REMOTE = 'chanpaca'
|
||||
const MIRROR_REMOTES = ['origin']
|
||||
|
|
@ -81,6 +85,7 @@ if (resume) {
|
|||
if (dryRun) {
|
||||
info(notes ? `CHANGELOG 초안:\n${notes}` : 'CHANGELOG 섹션 있음')
|
||||
info('단계: 커밋·태그 → 빌드 → 푸시 → 게시(서명) → 공개 URL 검증')
|
||||
if (withRuntime) info('런타임 포함: 사이드카 재빌드 → portable/runtime 게시 → 설치본 게시')
|
||||
info('dry-run — 아무것도 바꾸지 않았습니다.')
|
||||
process.exit(0)
|
||||
}
|
||||
|
|
@ -105,7 +110,7 @@ if (resume) {
|
|||
runNpm(['run', 'version:check'])
|
||||
runNpm(['run', 'release:metadata'])
|
||||
runNpm(['run', 'typecheck'])
|
||||
// 여기까지 실패하면 버전 파일만 바뀐 상태다 — git checkout -- . 로 되돌리고 다시 실행.
|
||||
// 여기까지 실패하면 버전 파일이 바뀐 상태다. 변경과 실패 증거를 보존하고 원인을 복구한다.
|
||||
|
||||
// ── 4. 커밋 + 태그 ──
|
||||
step(`커밋 + 태그 ${tag}`)
|
||||
|
|
@ -116,18 +121,45 @@ if (resume) {
|
|||
|
||||
const tag = `v${version}`
|
||||
const tagCommit = git(['rev-parse', `${tag}^{commit}`])
|
||||
const releaseDir = join(root, 'apps', 'desktop', 'release', version)
|
||||
const artifactIdentity = { version, tagCommit, withRuntime }
|
||||
const hasCheckpoint = existsSync(join(releaseDir, 'release-artifacts.json'))
|
||||
|
||||
// 태그가 생긴 뒤의 실패는 --resume 으로 이어 간다.
|
||||
const resumeHint = '\n고친 뒤 이어 가기: npm run release -- --resume'
|
||||
const resumeHint = `\n고친 뒤 이어 가기: node --env-file-if-exists=.env scripts/ci/release-desktop.mjs --resume${withRuntime ? ' --with-runtime' : ''}`
|
||||
|
||||
// 이미 게시가 끝난 버전을 다시 빌드하면 바이트가 달라 불변 경로와 충돌한다 — 푸시만 남은 경우다.
|
||||
if (resume && (await feedHasVersion(version))) {
|
||||
if (resume && !hasCheckpoint && !withRuntime && (await feedHasVersion(version))) {
|
||||
info(`피드에 ${version} 가 이미 있습니다 — 빌드·게시를 건너뜁니다.`)
|
||||
pushToRemotes(tag, tagCommit)
|
||||
} else {
|
||||
// ── 5. 빌드 ──
|
||||
step('빌드')
|
||||
runNode('scripts/ci/build-desktop-installer.mjs', [], {}, resumeHint)
|
||||
if (resume && hasCheckpoint) {
|
||||
step('보존 산출물 검증')
|
||||
await verifyReleaseArtifacts(releaseDir, artifactIdentity)
|
||||
info('태그·해시가 일치하는 원본 산출물을 재사용합니다.')
|
||||
} else {
|
||||
if (existsSync(releaseDir)) {
|
||||
fail(`기존 산출물을 보존합니다: ${releaseDir}\n검증 가능한 release-artifacts.json이 없습니다. 원본 산출물을 조사·복구한 뒤 재개하세요.`)
|
||||
}
|
||||
step('빌드')
|
||||
runNode('scripts/ci/build-desktop-installer.mjs', [], {}, resumeHint)
|
||||
if (withRuntime) {
|
||||
runNpm(['run', 'sidecar:build', '--workspace=@d3ro/desktop'])
|
||||
runNode('scripts/ci/verify-sidecar-bundle.mjs', ['--smoke'], {}, resumeHint)
|
||||
runNode('scripts/ci/build-portable.mjs', ['--release-artifacts-only'], {}, resumeHint)
|
||||
}
|
||||
// 첫 업로드 전에 원본 바이트와 태그를 기록한다. 재개 시 재빌드하지 않는다.
|
||||
await saveReleaseArtifacts(releaseDir, artifactIdentity)
|
||||
}
|
||||
|
||||
// 런타임을 요구하는 앱을 먼저 게시하면 기존 사용자의 모델 로드가 막힌다.
|
||||
// 기존 portable 게시기는 부품 해시를 검증하고 runtime 인덱스를 마지막에 게시한다.
|
||||
if (withRuntime) {
|
||||
step('런타임 선행 게시')
|
||||
// 게시기는 동일 바이트를 건너뛰고 누락된 파일과 latest 별칭을 복구한다.
|
||||
runNode('scripts/ci/publish-portable-release.mjs', [], {}, resumeHint)
|
||||
}
|
||||
|
||||
// ── 6. 푸시 ──
|
||||
// Forgejo Release 생성 API(POST /releases)는 원격에 태그가 아직 없으면 target_commitish 에
|
||||
|
|
|
|||
|
|
@ -64,6 +64,12 @@ function requireAllowedReleaseCertificate(value, label) {
|
|||
return normalized
|
||||
}
|
||||
|
||||
function parseApkSignerCertificate(signature) {
|
||||
return signature.match(
|
||||
/(?:Signer #\d+|V\d+(?:\.\d+)? Signer:)\s+certificate SHA-256 digest:\s*([0-9a-f:]+)/i,
|
||||
)?.[1]
|
||||
}
|
||||
|
||||
function stableStatValue(stat, key, fallbackKey) {
|
||||
if (key in stat) return stat[key]
|
||||
return BigInt(Math.trunc(Number(stat[fallbackKey]) * 1_000_000))
|
||||
|
|
@ -1078,6 +1084,18 @@ function runSigningPolicySelfTest() {
|
|||
if (requireAllowedReleaseCertificate(safe, 'self_test_safe') !== safe.replaceAll(':', '').toLowerCase()) {
|
||||
fail('self_test_safe_certificate_mismatch')
|
||||
}
|
||||
for (const signerLine of [
|
||||
`Signer #1 certificate SHA-256 digest: ${safe}`,
|
||||
`V2 Signer: certificate SHA-256 digest: ${safe}`,
|
||||
`V3.1 Signer: certificate SHA-256 digest: ${safe}`,
|
||||
]) {
|
||||
if (parseApkSignerCertificate(signerLine) !== safe) {
|
||||
fail('self_test_apk_signer_format_mismatch')
|
||||
}
|
||||
}
|
||||
if (parseApkSignerCertificate('Signer #1 certificate MD5 digest: 00') !== undefined) {
|
||||
fail('self_test_apk_signer_unexpected_match')
|
||||
}
|
||||
let compromisedRejected = false
|
||||
try {
|
||||
requireAllowedReleaseCertificate(COMPROMISED_SIGNER_SHA256, 'self_test')
|
||||
|
|
@ -1467,8 +1485,7 @@ try {
|
|||
: options['expected-upload-cert-sha256']
|
||||
? normalizeCertificateSha256(options['expected-upload-cert-sha256'], 'expected_upload_certificate')
|
||||
: null
|
||||
const actualCertificateText = signature
|
||||
.match(/Signer #1 certificate SHA-256 digest:\s*([0-9a-f:]+)/i)?.[1]
|
||||
const actualCertificateText = parseApkSignerCertificate(signature)
|
||||
if (!actualCertificateText) fail('signer_sha256_missing')
|
||||
const actualCertificate = mode === 'release'
|
||||
? requireAllowedReleaseCertificate(actualCertificateText, 'release_signer_sha256')
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@
|
|||
// 사용: node scripts/ci/verify-sidecar-bundle.mjs
|
||||
|
||||
import { existsSync, statSync } from 'node:fs'
|
||||
import { spawn } from 'node:child_process'
|
||||
import { createServer } from 'node:net'
|
||||
import { setTimeout as delay } from 'node:timers/promises'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
|
|
@ -55,3 +58,48 @@ if (problems.length > 0) {
|
|||
|
||||
const sizeMb = statSync(exePath).size / (1024 * 1024)
|
||||
console.log(`STT 사이드카 번들 검증 통과: ${exePath} (${sizeMb.toFixed(1)} MB)`)
|
||||
|
||||
// 별도 loopback 포트에서 방금 만든 실행 파일을 검사한다. 모델이나 사용자 프로필은 열지 않는다.
|
||||
if (process.argv.includes('--smoke')) {
|
||||
const reservation = createServer()
|
||||
await new Promise((resolve, reject) => {
|
||||
reservation.once('error', reject)
|
||||
reservation.listen(0, '127.0.0.1', resolve)
|
||||
})
|
||||
const address = reservation.address()
|
||||
if (!address || typeof address === 'string') throw new Error('No smoke-test port')
|
||||
await new Promise((resolve, reject) => reservation.close((error) => error ? reject(error) : resolve()))
|
||||
const child = spawn(exePath, ['--host', '127.0.0.1', '--port', String(address.port)], {
|
||||
windowsHide: true,
|
||||
stdio: ['ignore', 'pipe', 'pipe'],
|
||||
})
|
||||
let output = ''
|
||||
let launchError
|
||||
const capture = (chunk) => { output = (output + chunk.toString()).slice(-8000) }
|
||||
child.stdout.on('data', capture)
|
||||
child.stderr.on('data', capture)
|
||||
child.on('error', (error) => { launchError = error })
|
||||
let healthy = false
|
||||
try {
|
||||
const deadline = Date.now() + 30000
|
||||
while (Date.now() < deadline && child.exitCode === null && !launchError) {
|
||||
try {
|
||||
const response = await fetch(`http://127.0.0.1:${address.port}/health`, { signal: AbortSignal.timeout(500) })
|
||||
const health = await response.json()
|
||||
if (response.ok && health.status === 'no_model' && health.model_loaded === false) {
|
||||
healthy = true
|
||||
break
|
||||
}
|
||||
} catch { /* wait for this child to bind its port */ }
|
||||
await delay(100)
|
||||
}
|
||||
if (!healthy) throw new Error(`Sidecar smoke failed: ${launchError?.message ?? output}`)
|
||||
console.log(`STT 사이드카 실제 실행/health 검증 통과 (pid=${child.pid}, port=${address.port})`)
|
||||
} finally {
|
||||
if (child.pid && child.exitCode === null) {
|
||||
const exited = new Promise((resolve) => child.once('exit', resolve))
|
||||
child.kill()
|
||||
await exited
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
These tools separate a proven service race from unverified claims about physical keys and real CPU/model load.
|
||||
|
||||
1. Run `node scripts/verification/typing-race-proof.mjs` from the checkout root. It overlays three HEAD services in memory while keeping current dependencies and tests. A successful comparison requires the old services to corrupt the next Hangul word in three independent timing cases, the current services to preserve it, and unchanged-input correction to work in both. The other 13 assertions cover UIA snapshot contracts. This is not a complete installed-release A/B.
|
||||
1. Run `node scripts/verification/typing-race-proof.mjs` from the checkout root. It overlays three services from the pre-fix commit `f49acf01057cc100b9caeace6eada26cf7bf4b54` in memory while keeping current dependencies and tests. Override with `--baseline <commit>` when investigating another baseline; the report records both commits and source hashes. A successful comparison requires the old services to corrupt the next Hangul word in three independent timing cases, the current services to preserve it, and unchanged-input correction to work in both. The other 13 assertions cover UIA snapshot contracts. This is not a complete installed-release A/B.
|
||||
2. Build `typing-fixture/build.ps1` and `typing-runtime/build.ps1`. Quit the installed app and manually open the isolated runtime launcher as required by repository AGENTS.md. Do not run `run-desktop.bat` for this experiment; it kills unrelated Electron processes. Keep the test profile separate from the personal profile. The runtime receipt records the product bundle hash and product package version; the wrapper itself is not a released installer.
|
||||
3. Run the fixture with correction off, then correction on, saving each JSON under a distinct name. Use default Hangul IME mode first. Require exact calibration text and native IME composition messages. Compare all three requested paces under idle and bounded CPU load. A missing/aborted case, mismatched text, partial SendInput return or absent IME evidence is not a pass. Report achieved pacing, accepted key events and CPU samples during the input window, not just the requested load.
|
||||
4. Prove the correction path is active with Latin layout correction mode and a correction-enabled profile. A zero-loss Hangul run alone could simply mean the correction path never ran. Disable learned-text persistence throughout.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// Deterministic source A/B. No GUI, input injection, checkout mutation, or personal data.
|
||||
// Run from this checkout: node scripts/verification/typing-race-proof.mjs
|
||||
// Run from this checkout: node scripts/verification/typing-race-proof.mjs [--baseline <commit>]
|
||||
import { execFileSync, spawnSync } from 'node:child_process'
|
||||
import { createHash } from 'node:crypto'
|
||||
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'
|
||||
|
|
@ -28,9 +28,17 @@ mkdirSync(output, { recursive: true })
|
|||
const sha256 = (text) => createHash('sha256').update(text).digest('hex')
|
||||
const normalized = (file) => path.resolve(file).replaceAll('\\', '/').toLowerCase()
|
||||
const head = execFileSync('git', ['rev-parse', 'HEAD'], { cwd: root, encoding: 'utf8' }).trim()
|
||||
const args = process.argv.slice(2)
|
||||
if (args.length !== 0 && (args.length !== 2 || args[0] !== '--baseline')) {
|
||||
throw new Error('Usage: typing-race-proof.mjs [--baseline <commit>]')
|
||||
}
|
||||
// The fix is now committed: HEAD is no longer a broken baseline.
|
||||
const baselineRef = args[1] ?? 'f49acf01057cc100b9caeace6eada26cf7bf4b54'
|
||||
const baselineCommit = execFileSync('git', ['rev-parse', '--verify', '--end-of-options', `${baselineRef}^{commit}`],
|
||||
{ cwd: root, encoding: 'utf8' }).trim()
|
||||
const overrides = {}
|
||||
const evidence = sources.map((file) => {
|
||||
const baseline = execFileSync('git', ['show', `${head}:${file}`], { cwd: root, encoding: 'utf8', maxBuffer: 4_000_000 })
|
||||
const baseline = execFileSync('git', ['show', `${baselineCommit}:${file}`], { cwd: root, encoding: 'utf8', maxBuffer: 4_000_000 })
|
||||
const current = readFileSync(path.join(root, file), 'utf8')
|
||||
overrides[normalized(path.join(root, file))] = baseline
|
||||
return { file, baselineSha256: sha256(baseline), currentSha256: sha256(current) }
|
||||
|
|
@ -38,14 +46,14 @@ const evidence = sources.map((file) => {
|
|||
const testEvidence = tests.map((file) => ({
|
||||
file: `apps/desktop/${file}`, currentSha256: sha256(readFileSync(path.join(desktop, file), 'utf8'))
|
||||
}))
|
||||
writeFileSync(path.join(output, 'head-source-overrides.json'), JSON.stringify(overrides))
|
||||
writeFileSync(path.join(output, 'baseline-source-overrides.json'), JSON.stringify(overrides))
|
||||
const configPath = path.join(output, 'vitest.proof.config.mjs')
|
||||
writeFileSync(configPath, `
|
||||
import { readFileSync } from 'node:fs';
|
||||
const overrides = process.env.D3RO_RACE_BASELINE === '1'
|
||||
? JSON.parse(readFileSync(${JSON.stringify(path.join(output, 'head-source-overrides.json'))}, 'utf8')) : {};
|
||||
? JSON.parse(readFileSync(${JSON.stringify(path.join(output, 'baseline-source-overrides.json'))}, 'utf8')) : {};
|
||||
export default {
|
||||
plugins: [{ name: 'read-only-head-source-overlay', enforce: 'pre', load(id) {
|
||||
plugins: [{ name: 'read-only-baseline-source-overlay', enforce: 'pre', load(id) {
|
||||
return overrides[id.split('?')[0].replaceAll('\\\\', '/').toLowerCase()] ?? null;
|
||||
}}],
|
||||
test: { environment: 'node', globals: true,
|
||||
|
|
@ -59,7 +67,7 @@ export default {
|
|||
`)
|
||||
const runs = []
|
||||
for (const baseline of [true, false]) {
|
||||
const label = baseline ? 'baseline-head' : 'current-fix'
|
||||
const label = baseline ? 'baseline-source' : 'current-fix'
|
||||
const resultPath = path.join(output, `${label}.json`)
|
||||
const result = spawnSync(process.execPath, [vitest, 'run', ...tests, '--config', configPath,
|
||||
'--reporter=json', `--outputFile=${resultPath}`], {
|
||||
|
|
@ -77,9 +85,9 @@ for (const baseline of [true, false]) {
|
|||
}
|
||||
const report = {
|
||||
capturedAt: new Date().toISOString(), kind: 'deterministic-source-ab-not-gui',
|
||||
head, node: process.version, sources: evidence, tests: testEvidence, runs,
|
||||
head, baselineCommit, node: process.version, sources: evidence, tests: testEvidence, runs,
|
||||
sourcesUnchangedDuringRun: [...evidence, ...testEvidence].every(({ file, currentSha256 }) => sha256(readFileSync(path.join(root, file), 'utf8')) === currentSha256),
|
||||
baselineScope: 'Only the three listed services are loaded from HEAD; dependencies, test doubles and tests are current in both runs. This is not a full historical release test.',
|
||||
baselineScope: 'Only the three listed services are loaded from baselineCommit; dependencies, test doubles and tests are current in both runs. This is not a full historical release test.',
|
||||
scope: 'Actual TypoCorrectionService + TextInsertService with an in-memory text sink, and actual InputTelemetryService with delayed UIA responses. Three text-preservation cases isolate timestamp, revision and native-tick guards; one unchanged-input control must still correct. The remaining 13 cases check snapshot invalidation/metadata/coalescing contracts, not 13 independent text-loss reproductions. Native keys, OS IME, model loading and CPU stress are not exercised.'
|
||||
}
|
||||
writeFileSync(path.join(output, 'report.json'), JSON.stringify(report, null, 2) + '\n')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue