# PRL Research Loop

Use PRL for reproducible research phases. First call `prl_context` and inspect active Tasks plus the active Runs owned by this Pi session. Treat one Task/worktree as one implementation route: reuse it across phases of the same hypothesis instead of creating a new worktree for every edit. Call `prl_task_start` only when no compatible active Task exists. Create another worktree only for a stable baseline, concurrent agents, or a disposable experiment, and declare the corresponding `new_worktree_reason`.

Default to fast submit, explain later: batch only necessary checks, make the minimal change, and submit once code/identity/resource/termination inputs are fixed. Long STATE/hypothesis prose, reports, and optional tracking are not submission prerequisites; add them after the receipt. Required CPU validation can be a dependency Run. Never bypass immutable snapshots or safety gates. A queued receipt is not process start or first update. Deduplicate Agent actions by notification_id and inspect one coalesced batch per Run.

Use `prl_task_checkpoint` for named phase commits. Use a new `prl_run_launch` Run for every experiment, with declared event listeners. The Run, monitor state, durable notifications, inspect calls, and controls are bound to this Pi session. Never inspect or act on a Run owned by another session. Use `prl_run_claim` only for an unbound legacy Run; after explicit user confirmation, `prl_run_transfer` can recover a Run whose original session was lost.

For a mandatory GPU handoff, call `prl_run_enqueue` before the parent finishes and pin a durable artifact/checksum when a checkpoint is required; do not rely on `wake_agent` to schedule the successor. Use `prl_run_fork` for same-family variants and pass only the minimal overrides. Runs execute from immutable snapshots, so use absolute output/checkpoint/cache paths outside worktrees. The Pi PRL monitor widget/status line shows only this session's queued and running experiments. Do not poll processes or logs or repeatedly inspect a terminal Run. Wait for this session's `[PRL EVENT]`, inspect bounded details once (which acknowledges delivery), update the Run analysis and accumulated research state when useful, and decide whether to inspect, modify, retry, or stop. Long-training termination must be checkpoint-first and include a reason; never force SIGKILL without explicit user approval. Finish the Task after the route is complete, then review and merge it to `main` once separately. PRL never pushes or merges automatically.

PRL GPU leases coordinate PRL-managed Runs and probe `nvidia-smi`, but unmanaged external jobs can still race a cooperative lease; use Slurm or another scheduler for hard GPU reservation.
