Extract the provider boundary while retaining OpenAI/Gemini contracts. Add an opt-in isolated Local S2S adapter, pinned engine extension, bounded component gateway and frozen effective configuration profiles. Enforce request token limits, zero retries, local asset validation, connection deadlines, disconnect ownership, bounded cleanup and signals. Include regression coverage, pinned source fixtures, operator guidance, asset fingerprints and guarded disposable PostgreSQL acceptance tooling. Preserve immutable fixture bytes across Git line-ending conversion. Validation recorded in the reports: - 74 repair, 107 combined and 242 preservation checks passed. - Fresh PostgreSQL local checks: 2 passed. - Expanded PostgreSQL: 57 passed, 6 documented baseline failures. - Compose configurations, staged whitespace and fixture hashes passed. Phase 1 live listening and Phase 2 complete engine/SDK/POSIX, real component audio and Persian browser acceptance remain pending. No operational switch, paid call, model download or Phase 3 implementation is included.
56 lines
2.7 KiB
Python
56 lines
2.7 KiB
Python
"""Prepare immutable engine build inputs from an already-authorized clean checkout.
|
|
|
|
Does not fetch source, resolve dependencies, build images or download weights.
|
|
"""
|
|
import argparse
|
|
import hashlib
|
|
import json
|
|
from pathlib import Path
|
|
import re
|
|
import shutil
|
|
import subprocess
|
|
import tomllib
|
|
|
|
PIN = '619e3fe4f71d1c6f35c15870d588a3638de34722'
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument('--checkout', type=Path, required=True)
|
|
parser.add_argument('--base-image', required=True, help='python:3.11-slim@sha256:...')
|
|
args = parser.parse_args()
|
|
if not re.fullmatch(r'python:3\.11-slim@sha256:[0-9a-f]{64}', args.base_image):
|
|
parser.error('An immutable Python 3.11 base image digest is required.')
|
|
source = args.checkout.resolve()
|
|
sha = subprocess.check_output(['git', '-C', str(source), 'rev-parse', 'HEAD'], text=True).strip()
|
|
dirty = subprocess.check_output(['git', '-C', str(source), 'status', '--porcelain'], text=True).strip()
|
|
if sha != PIN or dirty:
|
|
parser.error('Requires a clean checkout of the Phase 1 upstream pin.')
|
|
root = Path(__file__).resolve().parents[2]
|
|
target = root / '.local-s2s-build'
|
|
if target.exists():
|
|
parser.error('.local-s2s-build exists; preserve it and choose a fresh workspace.')
|
|
dependencies = ['setuptools>=77.0.3', 'wheel']
|
|
for manifest in (source / 'pyproject.toml', root / 'pyproject.toml'):
|
|
data = tomllib.loads(manifest.read_text(encoding='utf-8'))
|
|
dependencies.extend(data['project']['dependencies'])
|
|
if manifest.parent == root:
|
|
for extra in ('api', 'voice', 'embedding'):
|
|
dependencies.extend(data['project']['optional-dependencies'][extra])
|
|
target.mkdir()
|
|
shutil.copytree(source, target / 'upstream', ignore=shutil.ignore_patterns('.git', '.venv', '__pycache__'))
|
|
from sys import path as import_path
|
|
import_path.insert(0, str(root))
|
|
from services.local_s2s.assets import patch_pipeline_source
|
|
pipeline = target / 'upstream/src/speech_to_speech/s2s_pipeline.py'
|
|
pipeline.write_text(patch_pipeline_source(pipeline.read_text(encoding='utf-8')), encoding='utf-8')
|
|
(target / 'requirements.in').write_text('\n'.join(sorted(set(dependencies))) + '\n', encoding='utf-8')
|
|
(target / 'build-manifest.json').write_text(json.dumps(dict(upstream=PIN, base_image=args.base_image,
|
|
upstream_pyproject_sha256=hashlib.sha256((source / 'pyproject.toml').read_bytes()).hexdigest(),
|
|
patch_revision='rag-local-s2s-phase2-v3', built=False), indent=2) + '\n', encoding='utf-8')
|
|
print('Prepared source and dependency inputs. Resolve a Linux hash lock before building; no downloads performed.')
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|