diff --git a/intelligence_radar/clock_attribution.py b/intelligence_radar/clock_attribution.py new file mode 100644 index 0000000..c10081d --- /dev/null +++ b/intelligence_radar/clock_attribution.py @@ -0,0 +1,12 @@ +"""Optional recording-time evidence; original local timestamps remain intact.""" +import os + +def recording_time(): + if not os.environ.get('INTELLIGENCE_RADAR_CLOCK_TRUST_FILE'): + return {} + try: + from railiance_clock.attribution import from_environment + result = from_environment('INTELLIGENCE_RADAR_CLOCK_TRUST_FILE') + return result + except (ImportError, OSError, ValueError): + return {'railiance_time': {'status': 'unavailable', 'kind': 'recording_time'}} diff --git a/intelligence_radar/ingest.py b/intelligence_radar/ingest.py index d03cda4..6144d88 100644 --- a/intelligence_radar/ingest.py +++ b/intelligence_radar/ingest.py @@ -7,6 +7,8 @@ import time from urllib.parse import urlparse from urllib.request import Request, urlopen +from .clock_attribution import recording_time + from .store import all_records, atomic, put MAX_BYTES = 5 * 1024 * 1024 @@ -53,6 +55,7 @@ def capture(root, source, opener=urlopen, now=None): 'content_sha256': content_hash, 'media_type': media_type, 'bytes': len(body), 'changed': changed, 'attempts': attempts, 'status': 'captured_unreviewed'} + receipt.update(recording_time()) ident = put(root, 'captures', receipt) if changed: from .__main__ import record @@ -80,6 +83,7 @@ def ingest(root, registry): results.append({'source_id': source['id'], 'ok': False, 'error': str(exc)}) run = {'observed_at': datetime.now(timezone.utc).isoformat(), 'sources': results, 'ok': all(r['ok'] for r in results)} + run.update(recording_time()) put(root, 'ingestion-runs', run) return run diff --git a/intelligence_radar/trials.py b/intelligence_radar/trials.py index 912664f..f2bf4e5 100644 --- a/intelligence_radar/trials.py +++ b/intelligence_radar/trials.py @@ -9,6 +9,7 @@ from pathlib import Path import time from urllib.request import Request, urlopen +from .clock_attribution import recording_time from .store import all_records, canonical, get, put ENDPOINT = 'https://openrouter.ai/api/v1/chat/completions' @@ -158,6 +159,7 @@ def execute(root, config, case, model, opener=urlopen): 'runtime_seconds':time.monotonic()-start,'completed_at':datetime.now(timezone.utc).isoformat(), 'reservation_id':reservation,'synthetic':False, 'sample_kind':'controlled repository work sample; real provider execution'} + trial.update(recording_time()) ident=put(root,'trials',trial) put(root,'trial-events',{'kind':'settled','campaign':campaign,'run_id':run_id, 'reservation_id':reservation,'trial_id':ident,'actual_usd':str(cost)})