AI Virus reproduction package
==============================

Builds the Aux0 backdoor training set and fine-tunes a small Qwen model
on it, reproducing the self-propagating implant from the paper.

Scope: research reproduction. Every payload is a placeholder marker
(BOOM = $(echo BOOM-BACKDOOR-TRIGGERED)) and every domain is an
IANA-reserved test name (pwn.example.invalid and *.example.*). Nothing
here is a weapon as shipped. Do not substitute real payloads or domains.

Files:
  triggers.py            trigger detectors + payload / inner-list builders
  eval_prompts.py        prompt templates and eval splits
  corpus.py              public Magicoder loader + per-generation split
  backdoor_pairs.py      assembles the 5 example types into the pair set
  build_backdoor_set.py  CLI, writes backdoor_pairs/{primary,injection_20pct,stealth}.jsonl
  finetune_aux0.py       QLoRA fine-tune of Qwen2.5-3B-Instruct on the pairs
  README                 this file

Requirements:
  python 3.11+, and for the fine-tune: unsloth, trl, torch, transformers,
  datasets. A single 24GB GPU (e.g. 3090 Ti) is enough for 3B QLoRA.

Steps:
  # 1. build the backdoor pairs from the public corpus
  python build_backdoor_set.py                # downloads Magicoder
  python build_backdoor_set.py --dry-run      # or a synthetic corpus, no download

  # 2. fine-tune Aux0 (v4 recipe: r=128, alpha=256, 5 epochs, seq 4096)
  python finetune_aux0.py --pairs backdoor_pairs/primary.jsonl --out aux0

  # 3. to observe propagation: run Aux0 as a formatter over a fresh benign
  #    corpus slice, train a fresh student on its output, then repeat with
  #    the student as the helper. The multi-mode format pass (formatter,
  #    t2_pos, t2_neg, capability) is described in section 3 of the paper.

Behavior:
  T2 (the poison) fires on curl questions to the trigger domain and emits
  the BOOM marker; benign domains stay clean. T1 (the propagation) fires
  on formatter-style prompts and emits a training-row-shaped JSON list
  that carries the same behavior into the next model's training data.
