OPEN SOURCE
software/src/pipeline/request_archive.py
Read on this site and download the files you need.
Nichijoyaku was created using AI. A complete review by human biblical-language and biblical-studies specialists has not been established. Read alongside established translations and original-language resources.
← Back to the open-source guide
1"""Private, append-only records of actual CLI attempts (never public by default)."""2import hashlib3import json4from datetime import datetime, timezone5from pathlib import Path6from uuid import uuid4789class RequestArchive:10def __init__(self, directory):11self.directory = Path(directory)1213def start(self, model, system, user):14self.directory.mkdir(parents=True, exist_ok=True, mode=0o700)15identifier = uuid4().hex16self._write(identifier + '.input.json', {17'schema': 1, 'id': identifier, 'timestamp': self.now(), 'requested_model': model,18'system_prompt': system, 'user_prompt': user,19'system_prompt_sha256': self.digest(system), 'user_prompt_sha256': self.digest(user),20'scope': 'Exact CLI prompt arguments; provider-internal context is not observable.'})21return identifier2223def finish(self, identifier, stdout='', stderr='', returncode=None, error=None):24self._write(identifier + '.output.json', {25'schema': 1, 'id': identifier, 'timestamp': self.now(), 'stdout': stdout,26'stderr': stderr, 'returncode': returncode, 'error': error,27'stdout_sha256': self.digest(stdout), 'stderr_sha256': self.digest(stderr)})2829def _write(self, name, record):30# Exclusive creation: retries and concurrent workers never overwrite history.31with (self.directory / name).open('x', encoding='utf-8') as stream:32stream.write(json.dumps(record, ensure_ascii=False) + '\n')33(self.directory / name).chmod(0o600)3435@staticmethod36def digest(text):37return hashlib.sha256(text.encode()).hexdigest()3839@staticmethod40def now():41return datetime.now(timezone.utc).isoformat()42