Phase 80.0
sl-cai-critique-cli
Close the upstream gap: rewrite violations before SFT
The pipeline already lived in jw_finetune.synth.critique but lacked CLI, tests and docs. F80.0 closes the loop: build-critique-dataset takes a ShareGPT SFT dataset, filters principles by agent_name, runs the cheap regex tier, calls the LLM only on hard violations and emits a parallel dataset with revised answers. The original is preserved in metadata.original_answer for audit. Cuts hard violations in the next SFT round's training set.
What shipped
- New command jw-finetune build-critique-dataset with flags input/output/provider/model/agent/principles/preserve-original.
- Regex tier short-circuit: no match means no LLM call (zero cost on clean corpora).
- Filtering by the principle's applies_to vs the agent_name.
- Programmatic API batch_critique(pairs, principles, llm, agent) → (revised_pairs, num_changed).
- self_critique(pair, principles, llm_provider, agent, preserve_original) returns CritiqueResult with changed + violated_principle_ids + original_answer.
- 10 TDD tests for the module + 4 CLI dispatch tests (input missing, output paths, no-principles flag).
- Graceful fallbacks: LLM error → original untouched, empty response → original untouched, identical text → changed=False.
- Guide docs/guias/sl-cai.md with quickstart and how it relates to F77 + F78 + F79.