# Preserved implementation excerpt

Source: `run_sonar.py`, baseline run `followup-ru-v1-20260915T175235Z-dc68f0`. The two blocks below are verbatim, non-contiguous excerpts from the preserved runner. Everything outside the identified ranges is omitted. This is an original implementation artifact, not newly written illustrative code. It is incomplete and must not be executed as a standalone runner.

The first block assembles an isolated follow-up history using a shared PRIMARY. The second checks saved requests and responses, citations and usage. It checks preservation and context construction, not the truth of model outputs. Publication-time `verify.py` is a separate, newly written offline integrity/arithmetic helper.

## Original lines 28–33

```python
 messages=[{'role':'user','content':C['primary_question']}]
 if qid!='PRIMARY':
  assert read('runs/perplexity/PRIMARY/metadata.json')['technical_status']=='success'
  primary=read('runs/perplexity/PRIMARY/response.raw.json')['choices'][0]['message']['content']
  messages += [{'role':'assistant','content':primary},{'role':'user','content':next(q['text'] for q in Q if q['id']==qid)}]
 req={'model':C['model'],'messages':messages,**C['parameters']}
```

## Original lines 66–78

```python
def validate(ids):
 primary=read('runs/perplexity/PRIMARY/response.raw.json')['choices'][0]['message']['content'];results=[]
 for qid in ids:
  p=Path('runs/perplexity')/qid;req=read(p/'request.json');md=read(p/'metadata.json');raw=read(p/'response.raw.json')
  expected=[{'role':'user','content':C['primary_question']},{'role':'assistant','content':primary},{'role':'user','content':next(q['text'] for q in Q if q['id']==qid)}]
  assert req['messages']==expected and req['model']=='sonar'
  assert all(req[k]==v for k,v in C['parameters'].items())
  assert md['raw_sha256']==sha((D/p/'response.raw.json').read_bytes())
  assert md['citations']==raw.get('citations') and md['search_results']==raw.get('search_results') and md['usage']==raw.get('usage')
  assert (D/p/'response.md').read_text()==raw['choices'][0]['message']['content']
  assert md['technical_status']=='success'
  results.append({'id':qid,'exact_history':True,'raw_sources_usage_preserved':True,'settings_match':True,'truncated':md['truncated']})
 return results
```

Private configuration, credentials, transport code and the question list are deliberately omitted. The public fragment does not enable or authorize new API calls.
