Add local spoken passages with Google retrieval and isolated runtime setup

This commit is contained in:
karl committed 2026-10-13 20:18:44 +02:00
1 parent bc9459785d
commit dab703413e
55 files changed
+3633 -70

No files matched your search

+46
View File
@@ -10,6 +10,7 @@ import zipfile
from package_windows import package, CRT_LIBRARIES
from embeddinggemma2 import runtime_provenance as provenance
import stage_extraction_worker as extraction
import stage_speech_worker as speech
def executable(path, machine=0x8664):
@@ -32,6 +33,29 @@ def inventory(resources):
class PackageTests(unittest.TestCase):
def test_speech_cpu_only_missing_and_tampered_runtime_preserve_previous_package(self):
for mutation in ('cpu', 'missing', 'tampered', 'stale', 'unlisted'):
with self.subTest(mutation=mutation), tempfile.TemporaryDirectory() as directory:
root, resources, app, output = self.fixture(directory)
output.write_bytes(b'previous package')
speech_directory = resources / 'speech-runtime'
if mutation == 'cpu':
path = speech_directory / 'runtime-manifest.json'
data = json.loads(path.read_text())
data.update(device='cpu', distribution=False)
path.write_text(json.dumps(data))
elif mutation == 'missing':
(speech_directory / 'searchi-speech-worker.exe').unlink()
elif mutation == 'tampered':
(speech_directory / 'ggml-vulkan.dll').write_bytes(b'changed')
elif mutation == 'stale':
(root / 'tools/speech-runtime/worker.cpp').write_bytes(b'changed source')
else:
executable(speech_directory / 'obsolete-ggml-cpu.dll')
with self.assertRaises(ValueError):
package(root, app, output)
self.assertEqual(output.read_bytes(), b'previous package')
def test_extraction_missing_tampered_stale_preserves_existing_package(self):
for mutation in ("missing", "tampered", "stale"):
with self.subTest(mutation=mutation), tempfile.TemporaryDirectory() as directory:
@@ -119,6 +143,28 @@ class PackageTests(unittest.TestCase):
helper = root / "build/searchi-extract-worker.exe"
executable(helper)
extraction.stage(helper, extraction.fingerprint(root), resources, root)
speech_directory = resources / 'speech-runtime'
speech_directory.mkdir()
for name in speech.INPUTS:
path = speech.input_path(root, name)
path.parent.mkdir(parents=True, exist_ok=True)
path.write_bytes(speech.input_path(speech.ROOT, name).read_bytes())
for name in speech.NOTICES:
original = root / 'assets/licenses' / name
original.parent.mkdir(parents=True, exist_ok=True)
original.write_bytes((speech.ROOT / 'assets/licenses' / name).read_bytes())
(speech_directory / name).write_bytes(original.read_bytes())
speech_files = []
for name in ('searchi-speech-worker.exe', 'ggml-cpu-x64.dll', 'ggml-vulkan.dll',
'whisper.dll', 'ggml.dll', 'ggml-base.dll', 'vulkan-1.dll',
'VULKAN-LICENSE.txt', 'MSVC-REDISTRIBUTION.txt', *sorted(CRT_LIBRARIES)):
path = speech_directory / name
executable(path)
speech_files.append({'path': name, 'bytes': path.stat().st_size, 'sha256': speech.digest(path)})
(speech_directory / 'runtime-manifest.json').write_text(json.dumps({
'schema': 1, 'upstream_commit': speech.UPSTREAM, 'device': 'auto', 'distribution': True,
'source_hashes': {name: speech.digest(speech.input_path(root, name)) for name in speech.INPUTS},
'files': speech_files}))
return root, resources, app, root / "archive.zip"
def test_valid_pe_media_mutation_and_notice_corruption_preserve_previous_archive(self):